/* cadmini - Fase 1 - retning: instrument / værksted */
* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --chrome:      #102a44;   /* instrumentpanel - marineblå */
  --chrome-2:    #0b1f33;
  --chrome-line: #25496e;
  --field:       #16344f;
  --field-line:  #2c557d;
  --field-focus: #3c6a98;
  --ink:         #eaf1f8;   /* tekst på mørkt */
  --muted:       #9fb0c4;
  --label:       #bcc8d8;   /* feltlabels - læsbare */
  --amber:       #ffb02e;   /* signal / display */
  --amber-deep:  #d98e16;
  --blueprint:   #103e68;   /* tegneflade */
  --mono: ui-monospace, 'SF Mono', SFMono-Regular, Menlo, Consolas, monospace;
}

html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--chrome-2);
  color: var(--ink);
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

/* ---- Instrumentpanel (værktøjslinje) ---- */
.toolbar {
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, #20242a 0%, var(--chrome) 100%);
  border-bottom: 1px solid #000;
  box-shadow: 0 1px 0 rgba(255,255,255,0.04) inset, 0 2px 8px rgba(0,0,0,0.4);
  z-index: 5;
}

.bar-top {
  display: flex; align-items: center; gap: 0.9rem;
  padding: 0.5rem 0.85rem;
  border-bottom: 1px solid var(--chrome-line);
}
.brand { display: flex; align-items: center; gap: 0.5rem; flex: none; }

/* Redigerbart tegningsnavn (titel) */
.title-input {
  flex: 1 1 auto; min-width: 0;
  background: transparent; border: 1px solid transparent; border-radius: 7px;
  color: var(--ink); font-size: 0.98rem; font-weight: 600; letter-spacing: 0.01em;
  padding: 0.3rem 0.55rem; outline: none;
  transition: background 0.12s, border-color 0.12s;
}
.title-input::placeholder { color: var(--muted); font-weight: 400; font-style: italic; }
.title-input:hover { background: rgba(255,255,255,0.05); }
.title-input:focus {
  background: var(--field); border-color: var(--amber);
  box-shadow: 0 0 0 3px rgba(255,176,46,0.18);
}
.brand .logo { width: 22px; height: 22px; color: var(--amber); flex: none; }
.brand .wordmark {
  font-weight: 700; font-size: 0.95rem; letter-spacing: 0.18em;
  text-transform: uppercase; color: var(--ink);
}

/* LED-agtigt aflæsnings-display */
.readout {
  margin-left: auto;
  display: flex; align-items: baseline; gap: 0.55rem;
  font-family: var(--mono); font-size: 0.9rem;
  color: var(--muted); font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.readout b {
  color: var(--amber); font-weight: 600;
  text-shadow: 0 0 9px rgba(255,176,46,0.35);
}
.readout .unit { color: var(--muted); font-weight: 400; }
.readout .sep { color: var(--chrome-line); }

.bar-controls {
  display: flex; flex-wrap: wrap; align-items: flex-end;
  gap: 0.4rem 0;
  padding: 0.45rem 0.85rem;
}
.bar-section {
  display: flex; flex-direction: column; gap: 0.22rem;
  padding: 0 0.9rem;
  border-right: 1px solid var(--chrome-line);
}
.bar-section:first-child { padding-left: 0; }
.bar-section:last-child { border-right: none; }
.bar-label {
  font-size: 0.6rem; font-weight: 700; letter-spacing: 0.07em;
  text-transform: uppercase; color: var(--muted);
}
.group { display: flex; align-items: flex-end; gap: 0.5rem; }
.group.divide { padding-left: 0.9rem; border-left: 1px solid var(--chrome-line); }

/* ---- Flydende zoom-kontrol ---- */
.zoom-ctrl {
  position: absolute; bottom: 0.7rem; right: 0.7rem; z-index: 8;
  display: flex; gap: 0.35rem; align-items: center;
}
.zoom-ctrl button {
  height: 36px; min-width: 36px; padding: 0 0.7rem;
  background: rgba(11,31,51,0.88); border: 1px solid var(--chrome-line);
  border-radius: 8px; color: var(--ink); font-size: 0.9rem;
  backdrop-filter: blur(6px); cursor: pointer;
}
.zoom-ctrl button:hover { background: rgba(40,70,100,0.9); border-color: var(--field-focus); }
.zoom-ctrl .icon { font-family: var(--mono); font-size: 1.2rem; }

.field { display: flex; flex-direction: column; gap: 0.2rem; }
.field > span {
  font-size: 0.68rem; font-weight: 500; letter-spacing: 0.04em; text-transform: uppercase;
  color: var(--label); padding-left: 0.15rem;
}
.num {
  display: flex; align-items: center;
  background: var(--field); border: 1px solid var(--field-line); border-radius: 8px;
  padding: 0 0.6rem; height: 40px;
  transition: border-color 0.12s, box-shadow 0.12s;
}
.num:focus-within { border-color: var(--amber); box-shadow: 0 0 0 3px rgba(255,176,46,0.18); }
.num input {
  width: 4rem; border: none; background: transparent; outline: none;
  font-family: var(--mono); font-size: 1rem; color: var(--ink);
  text-align: right; font-variant-numeric: tabular-nums; -moz-appearance: textfield;
}
.num input::-webkit-outer-spin-button,
.num input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.num i { font-style: normal; font-size: 0.75rem; color: var(--muted); margin-left: 0.35rem; }
.num .pre { font-size: 0.72rem; font-weight: 600; color: var(--muted); margin-right: 0.3rem; }

button {
  height: 40px; min-width: 40px; padding: 0 0.9rem;
  border: 1px solid var(--field-line); border-radius: 8px;
  background: var(--field); color: var(--ink);
  font-size: 0.9rem; cursor: pointer; white-space: nowrap;
  display: inline-flex; align-items: center; justify-content: center;
  transition: background 0.12s, border-color 0.12s;
}
button:hover { background: #313742; border-color: var(--field-focus); }
button:active { transform: translateY(1px); }
button:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; }
button.primary {
  background: var(--amber); border-color: var(--amber-deep); color: #2a1c00; font-weight: 600;
}
button.primary:hover { background: #ffbe52; }
button.icon { font-size: 1.2rem; padding: 0; font-family: var(--mono); }
button.active {
  background: var(--amber); border-color: var(--amber-deep); color: #2a1c00; font-weight: 600;
}
button.active:hover { background: #ffbe52; }

/* ---- Tegneflade (blueprint) ---- */
.stage { flex: 1; position: relative; min-height: 0; background: var(--blueprint); }
#canvas {
  width: 100%; height: 100%; display: block;
  background: var(--blueprint); touch-action: none; cursor: grab;
}
#canvas:active { cursor: grabbing; }

.wall { fill: url(#wallhatch); stroke: #eaf2fb; stroke-width: 1.6; vector-effect: non-scaling-stroke; }
.dim-line { stroke: rgba(233,242,251,0.65); stroke-width: 1.1; vector-effect: non-scaling-stroke; }
.dim-text {
  fill: #eaf2fb; font-family: var(--mono); font-weight: 400;
  font-variant-numeric: tabular-nums; letter-spacing: 0.02em;
}

/* ---- Døre / vinduer ---- */
.element { cursor: pointer; }
.door-leaf { stroke: #eaf2fb; stroke-width: 1.5; fill: none; vector-effect: non-scaling-stroke; }
.door-arc { stroke: rgba(233,242,251,0.55); stroke-width: 1; fill: none; vector-effect: non-scaling-stroke; }
.win-line { stroke: #eaf2fb; stroke-width: 1.4; vector-effect: non-scaling-stroke; }
.win-glass { stroke: rgba(150,196,238,0.85); stroke-width: 1; vector-effect: non-scaling-stroke; }
.el-hit { fill: transparent; stroke: none; }
.element.sel .el-hit {
  fill: rgba(255,176,46,0.14); stroke: var(--amber); stroke-width: 1.5; vector-effect: non-scaling-stroke;
}

/* ---- Installationssymboler ---- */
.fixture { cursor: pointer; }
.fixture.el    { color: #ffd34d; }
.fixture.vand  { color: #5bb0ff; }
.fixture.aflob { color: #67d0c4; }
.fixture.varme { color: #ff8a5c; }
.fx-line { stroke: currentColor; stroke-width: 1.5; fill: none; vector-effect: non-scaling-stroke; }
.fx-fill { fill: currentColor; stroke: none; }
.fx-text { fill: currentColor; font-family: var(--mono); font-weight: 600; }
.fx-hit { fill: transparent; stroke: none; }
.fixture.sel .fx-hit { fill: rgba(255,176,46,0.14); stroke: var(--amber); stroke-width: 1.5; vector-effect: non-scaling-stroke; }

/* ---- Resize-håndtag ---- */
.resize-handle {
  fill: var(--amber); stroke: #1a1000; stroke-width: 1.5;
  vector-effect: non-scaling-stroke; cursor: crosshair; opacity: 0.82;
}
.resize-handle:hover { opacity: 1; fill: #ffcc66; }

/* ---- Møbler (tegnes i rigtige mål) ---- */
.furniture { cursor: pointer; color: #d8be8a; }
.furn-line { stroke: currentColor; stroke-width: 1.4; fill: none; vector-effect: non-scaling-stroke; }
.furn-fill { fill: currentColor; stroke: none; }
.furn-soft { stroke: currentColor; stroke-width: 1; fill: none; opacity: 0.55; vector-effect: non-scaling-stroke; }
.furn-dash { stroke: currentColor; stroke-width: 1.3; fill: none; stroke-dasharray: 6 4; vector-effect: non-scaling-stroke; }
.furn-slab { fill: rgba(216,190,138,0.16); stroke: currentColor; stroke-width: 1.4; vector-effect: non-scaling-stroke; }
.furn-hit { fill: transparent; stroke: none; }
.furniture.sel .furn-hit { fill: rgba(255,176,46,0.12); stroke: var(--amber); stroke-width: 1.5; vector-effect: non-scaling-stroke; }
.sym-mini.furn { color: #d8be8a; }

/* ---- Element-måltal (lettere end rummets) ---- */
.edim-line { stroke: rgba(233,242,251,0.40); stroke-width: 1; vector-effect: non-scaling-stroke; }
.edim-text {
  fill: #ccd9ea; font-family: var(--mono); font-weight: 400;
  font-variant-numeric: tabular-nums; letter-spacing: 0.02em;
}

/* ---- Flydende element-panel ---- */
.el-panel {
  position: absolute; left: 50%; bottom: 1rem;
  transform: translateX(-50%) translateY(150%);
  display: flex; align-items: center; gap: 0.5rem;
  padding: 0.5rem 0.6rem;
  background: linear-gradient(180deg, #20242a 0%, var(--chrome) 100%);
  border: 1px solid var(--chrome-line); border-radius: 12px;
  box-shadow: 0 8px 28px rgba(0,0,0,0.45);
  opacity: 0; pointer-events: none; z-index: 7;
  transition: transform 0.18s ease, opacity 0.18s ease;
}
.el-panel.show { transform: translateX(-50%) translateY(0); opacity: 1; pointer-events: auto; }
.el-panel .pl-label { font-size: 0.85rem; font-weight: 600; color: var(--ink); padding: 0 0.25rem; }
.el-panel .num { height: 36px; }
.el-panel .num input { width: 3.1rem; }
.el-panel button { height: 36px; min-width: 36px; }
.el-panel .danger { color: #ffb4b4; border-color: #5a2f33; }
.el-panel .danger:hover { background: #4a2429; border-color: #7a3a40; }

/* ---- Symbol-palet ---- */
.inst-palette {
  position: absolute; top: 0.7rem; right: 0.7rem; width: 270px; max-height: calc(100% - 1.4rem);
  overflow-y: auto; padding: 0.7rem; z-index: 8;
  background: linear-gradient(180deg, #20242a 0%, var(--chrome) 100%);
  border: 1px solid var(--chrome-line); border-radius: 12px;
  box-shadow: 0 8px 28px rgba(0,0,0,0.5);
}
.inst-palette[hidden] { display: none; }
.sym-cat { margin-bottom: 0.6rem; }
.sym-cat-h {
  font-size: 0.68rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase;
  margin: 0.2rem 0 0.4rem 0.1rem;
}
.sym-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.4rem; }
.sym-btn {
  display: flex; flex-direction: column; align-items: center; gap: 0.2rem;
  height: auto; padding: 0.4rem 0.2rem; min-width: 0;
  background: var(--field); border: 1px solid var(--field-line); border-radius: 8px;
  color: var(--label); font-size: 0.6rem; line-height: 1.1; text-align: center; white-space: normal;
}
.sym-btn:hover { background: #313742; border-color: var(--field-focus); }
.sym-btn.active { background: var(--amber); border-color: var(--amber-deep); color: #2a1c00; }
.sym-mini { width: 30px; height: 30px; display: block; }

/* ---- Lag-styring + legende ---- */
.layers { position: absolute; top: 0.7rem; left: 0.7rem; z-index: 8; display: flex; flex-direction: column; gap: 0.4rem; align-items: flex-start; }
.layer-chips { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.lay-chip {
  height: 30px; min-width: 0; padding: 0 0.6rem; gap: 0.35rem;
  background: rgba(16,42,68,0.85); border: 1px solid var(--chrome-line); border-radius: 16px;
  color: var(--ink); font-size: 0.72rem; backdrop-filter: blur(4px);
}
.lay-chip i { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.lay-chip.off { opacity: 0.4; text-decoration: line-through; }
.legend-btn {
  height: 30px; padding: 0 0.7rem; font-size: 0.72rem;
  background: rgba(16,42,68,0.85); border: 1px solid var(--chrome-line); border-radius: 16px;
  color: var(--ink); backdrop-filter: blur(4px);
}
.legend-btn.active { background: var(--amber); border-color: var(--amber-deep); color: #2a1c00; }
.legend-box {
  background: rgba(11,31,51,0.92); border: 1px solid var(--chrome-line); border-radius: 10px;
  padding: 0.5rem 0.6rem; max-width: 220px; max-height: 50vh; overflow-y: auto; backdrop-filter: blur(4px);
}
.legend-box[hidden] { display: none; }
.legend-list { display: flex; flex-direction: column; gap: 0.3rem; }
.legend-row { display: flex; align-items: center; gap: 0.45rem; font-size: 0.74rem; color: var(--ink); }
.legend-row .sym-mini { width: 24px; height: 24px; flex: none; }
.legend-empty { font-size: 0.74rem; color: var(--muted); font-style: italic; }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---- Versionsfooter ---- */
.ver { position: fixed; bottom: 0.45rem; right: 0.7rem; font-size: 0.7rem; color: #9aa0a6; z-index: 6; }
.ver a { color: #7d838a; text-decoration: none; }
.ver a:hover { text-decoration: underline; }

dialog { border: none; border-radius: 12px; padding: 1.4rem 1.6rem; max-width: 420px; width: calc(100% - 2rem); box-shadow: 0 10px 40px rgba(0,0,0,0.3); }
dialog h2 { font-size: 1.1rem; margin-bottom: 0.9rem; }
dialog .entry { margin-bottom: 1rem; }
dialog .entry b { font-size: 0.85rem; color: #333; }
dialog .entry .date { color: #aaa; font-weight: 400; font-size: 0.75rem; margin-left: 0.4rem; }
dialog ul { margin: 0.3rem 0 0 1.1rem; }
dialog li { color: #555; font-size: 0.9rem; line-height: 1.5; }
dialog .close { margin-top: 0.6rem; background: var(--chrome); color: #fff; border: none; border-radius: 8px; padding: 0.45rem 1.05rem; font-size: 0.85rem; cursor: pointer; }

/* ---- Mobil ---- */
@media (max-width: 640px) {
  .bar-top { padding: 0.5rem 0.65rem; }
  .brand .wordmark { font-size: 0.85rem; letter-spacing: 0.14em; }
  .readout { font-size: 0.8rem; gap: 0.4rem; }
  .bar-controls { gap: 0.5rem 0.6rem; padding: 0.5rem 0.65rem; }
  .group.divide { padding-left: 0; border-left: none; }
  .num input { width: 3.2rem; }
  button { padding: 0 0.7rem; }
}
