*,*::before,*::after{box-sizing:border-box}:root{padding-top:env(safe-area-inset-top);padding-bottom:env(safe-area-inset-bottom)}body{margin:0;font:14px/1.4 system-ui,sans-serif}[hidden]{display:none}
/* Layout: ett lerret av Clockwork-papir med svakt rutenett fyller skjermen; alle kontroller flyter over det i glass, inne i én ytre ramme med sidemargen. */
:root {
  --paper: #f6f5f0;
  --panel: #fffefa;
  --ink: #26322e;
  --ink-strong: #141f1c;
  --muted: #696e68;
  --line: #e3e5dc;
  --line-strong: #cfd6c3;
  --coral: #ec6066;
  --coral-strong: #c8454c;
  --coral-deep: #b63d44;
  --blush: #f3cec1;
  --blush-soft: #fbebdf;
  --sage: #a4ba86;
  --green: #263b30;
  --green-hover: #3b513e;
  --on-green: #fff8ec;
  --on-coral: #fff9ee;
  --field: #fffdf7;
  --field-edge: #868e80;
  --glass: rgb(255 254 250 / 0.74);
  --glass-edge: rgb(255 255 255 / 0.85);
  --hover: rgb(38 59 48 / 0.07);
  --active: rgb(38 59 48 / 0.13);
  --grid: rgb(38 50 46 / 0.055);
  --scrim: rgb(20 31 28 / 0.3);
  --warn-bg: #f6edd5;
  --warn-ink: #5f4a12;
  --shadow: 0 10px 30px rgb(20 31 28 / 0.1), 0 1px 2px rgb(20 31 28 / 0.08);
  --font: "Söhne", "Soehne", ui-sans-serif, -apple-system, BlinkMacSystemFont, "Helvetica Neue", Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --radius: 14px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #141f1c;
    --panel: #1f2a25;
    --ink: #f0f1e8;
    --ink-strong: #ffffff;
    --muted: #b2bdb4;
    --line: #33403a;
    --line-strong: #4a5950;
    --coral: #f18b7e;
    --coral-strong: #f18b7e;
    --coral-deep: #f5a396;
    --blush: #4a2f2a;
    --blush-soft: #3b2a25;
    --sage: #a4ba86;
    --green: #dfe7d4;
    --green-hover: #f0f4ea;
    --on-green: #141f1c;
    --on-coral: #261914;
    --field: #19231f;
    --field-edge: #7f8b82;
    --glass: rgb(27 37 32 / 0.76);
    --glass-edge: rgb(255 255 255 / 0.09);
    --hover: rgb(240 241 232 / 0.07);
    --active: rgb(240 241 232 / 0.14);
    --grid: rgb(240 241 232 / 0.045);
    --scrim: rgb(0 0 0 / 0.5);
    --warn-bg: #3d3420;
    --warn-ink: #f3dfae;
    --shadow: 0 10px 30px rgb(0 0 0 / 0.38), 0 1px 2px rgb(0 0 0 / 0.3);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #141f1c;
  --panel: #1f2a25;
  --ink: #f0f1e8;
  --ink-strong: #ffffff;
  --muted: #b2bdb4;
  --line: #33403a;
  --line-strong: #4a5950;
  --coral: #f18b7e;
  --coral-strong: #f18b7e;
  --coral-deep: #f5a396;
  --blush: #4a2f2a;
  --blush-soft: #3b2a25;
  --sage: #a4ba86;
  --green: #dfe7d4;
  --green-hover: #f0f4ea;
  --on-green: #141f1c;
  --on-coral: #261914;
  --field: #19231f;
  --field-edge: #7f8b82;
  --glass: rgb(27 37 32 / 0.76);
  --glass-edge: rgb(255 255 255 / 0.09);
  --hover: rgb(240 241 232 / 0.07);
  --active: rgb(240 241 232 / 0.14);
  --grid: rgb(240 241 232 / 0.045);
  --scrim: rgb(0 0 0 / 0.5);
  --warn-bg: #3d3420;
  --warn-ink: #f3dfae;
  --shadow: 0 10px 30px rgb(0 0 0 / 0.38), 0 1px 2px rgb(0 0 0 / 0.3);
  color-scheme: dark;
}

html, body { height: 100%; }
html { box-sizing: border-box; overflow: hidden; }
[hidden] { display: none !important; }
body {
  margin: 0;
  overflow: hidden;
  background: var(--paper);
  color: var(--ink);
  font: 400 15px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--coral-deep); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Ikoner i Clockwork-stilen «Streken»: strek på 1,5 på et rutenett på 24, rette ender og skarpe hjørner, én prikk i korall. */
.ic { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: butt; stroke-linejoin: miter; }
.ic .dot { fill: var(--coral); stroke: none; }
.cw { fill: var(--coral); flex: none; }

#app { position: relative; height: 100%; }

/* Lerretet */
#stage {
  position: absolute; inset: 0; overflow: hidden; outline: none;
  background-color: var(--canvas, var(--paper));
  background-image: linear-gradient(var(--grid-c, var(--grid)) 1px, transparent 1px), linear-gradient(90deg, var(--grid-c, var(--grid)) 1px, transparent 1px);
  background-size: 24px 24px;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
}
#stage.panning { cursor: grabbing; }
#stage.relmode, #stage.relmode .n { cursor: crosshair; }
#svg { position: absolute; inset: 0; width: 100%; height: 100%; display: block; user-select: none; -webkit-user-select: none; overflow: visible; }
.n { cursor: default; }
.n .sel { fill: none; stroke: var(--sel, var(--coral-strong)); stroke-width: 2; display: none; }
.n.selected .sel { display: block; }
.n .hov { fill: none; stroke: var(--line-strong); stroke-width: 1.5; opacity: 0; }
.n:hover .hov { opacity: 1; }
.n.selected .hov { opacity: 0; }
.n.dragging { opacity: 0.3; }
.n.editing .txt { visibility: hidden; }
.n .match { fill: var(--blush); display: none; }
.n.is-match .match { display: block; }
.n.is-current .match { fill: var(--coral); opacity: 0.35; }
.n .glow { fill: none; stroke: var(--coral); stroke-width: 6; opacity: 0; }
.n.flash .glow { animation: glow 2.6s ease-out; }
@keyframes glow { 0% { opacity: 0.9; } 100% { opacity: 0; } }
.fold { cursor: pointer; opacity: 0; transition: opacity 0.12s; }
.n:hover .fold, .n.selected .fold, .fold.collapsed { opacity: 1; }
.rel { cursor: pointer; }
.rel .rel-hit { stroke: transparent; stroke-width: 14; fill: none; }
.rel.selected .rel-line { stroke: var(--sel, var(--coral-strong)); }
.indicator { cursor: pointer; }
.drop-line { stroke: var(--sel, var(--coral-strong)); stroke-width: 3; stroke-linecap: round; }
.drop-box { fill: none; stroke: var(--sel, var(--coral-strong)); stroke-width: 2; stroke-dasharray: 5 4; }
.ghost-line { stroke: var(--sel, var(--coral-strong)); stroke-width: 1.5; stroke-dasharray: 5 4; fill: none; }
#stage.pan-ready { cursor: grab; }
#stage.pan-ready.panning { cursor: grabbing; }
.marquee { fill: rgb(236 96 102 / 0.07); stroke: var(--sel, var(--coral-strong)); stroke-width: 1.25; stroke-dasharray: 5 4; vector-effect: non-scaling-stroke; }
.ghost { pointer-events: none; }
.sk { cursor: default; }
.sk .sel { fill: none; stroke: var(--sel, var(--coral-strong)); stroke-width: 2; display: none; }
.sk.selected .sel { display: block; }
.sk.dragging { opacity: 0.3; }
.sk.editing .txt { visibility: hidden; }
.grp { cursor: grab; }
.fmove { cursor: grab; }
.fmove circle { transition: transform 0.1s; transform-box: fill-box; transform-origin: center; }
.fmove:hover circle { transform: scale(1.15); }
[data-frame].dragging { opacity: 0.3; }
.ink-sel { fill: none; stroke: var(--sel, var(--coral-strong)); stroke-width: 1.5; stroke-dasharray: 5 4; vector-effect: non-scaling-stroke; pointer-events: none; }
.ink-sel.pre { opacity: 0.75; }
.hdl .hit { fill: transparent; }
.hdl .tri { fill: var(--sel, var(--coral-strong)); stroke: var(--canvas, var(--paper)); stroke-width: 1.5; stroke-linejoin: round; transform-box: fill-box; transform-origin: center; transition: transform 0.1s; }
.hdl-link { cursor: crosshair; }
.hdl-link:hover .tri { transform: scale(1.3); }
.hdl .corner { fill: none; stroke: var(--sel, var(--coral-strong)); stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }
.hdl-rs-r, .hdl-ink-rs { cursor: nwse-resize; }
.hdl-rs-l { cursor: nesw-resize; }
#edit2 {
  position: absolute; z-index: 4; margin: 0; padding: 0; border: 0; outline: none; resize: none; overflow: hidden;
  background: transparent; color: #26322e; white-space: pre-wrap; overflow-wrap: break-word; caret-color: #c8454c;
  font-family: var(--font); font-weight: 400; text-align: left;
}
#edit2::selection { background: rgb(236 96 102 / 0.3); }
.switch { display: flex; align-items: center; gap: 12px; width: 100%; padding: 10px 12px; border: 1px solid var(--line-strong); border-radius: 12px; background: transparent; color: inherit; font: inherit; text-align: left; cursor: pointer; }
.switch:focus-visible { outline: 2px solid var(--coral-strong); outline-offset: 2px; }
.switch .knob { flex: none; width: 34px; height: 20px; border-radius: 10px; background: var(--line-strong); position: relative; transition: background 0.15s; }
.switch .knob::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fffefa; box-shadow: 0 1px 2px rgb(0 0 0 / 0.2); transition: transform 0.15s; }
.switch[aria-checked="true"] .knob { background: var(--coral-strong); }
.switch[aria-checked="true"] .knob::after { transform: translateX(14px); }
.switch .sw-t { display: block; font-weight: 500; }
.switch .sw-d { display: block; color: var(--muted); font-size: 12.5px; line-height: 1.35; margin-top: 2px; }
.icon-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(38px, 1fr)); gap: 6px; }
.icon-grid .mk-btn svg { width: 22px; height: 22px; }
.hint-note { color: var(--muted); font-size: 12.5px; margin: 6px 0 0; }

#edit {
  position: absolute; z-index: 4; margin: 0; padding: 0; border: 0; outline: none; resize: none; overflow: hidden;
  background: transparent; white-space: pre-wrap; overflow-wrap: break-word; caret-color: var(--coral-strong);
  font-family: var(--font); text-align: center;
}
#stage.dropping::after { content: ""; position: absolute; inset: 12px; border: 2px dashed var(--coral-strong); border-radius: 18px; pointer-events: none; }
#edit::selection { background: rgb(236 96 102 / 0.3); }

/* Ytre ramme for alt som flyter over lerretet. Sidemargen settes bare her. */
#chrome {
  position: absolute; inset: 0; pointer-events: none;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  padding-block: 12px;
}
#chrome-in { position: relative; height: 100%; }
#chrome-in > * { pointer-events: auto; }

.glass {
  background: var(--glass);
  -webkit-backdrop-filter: blur(16px) saturate(1.2);
  backdrop-filter: blur(16px) saturate(1.2);
  border: 1px solid var(--glass-edge);
  box-shadow: var(--shadow);
  border-radius: var(--radius);
}

/* Toppen */
#topbar { position: absolute; top: 0; left: 0; right: 0; display: flex; align-items: center; gap: 10px; padding: 6px; min-width: 0; }
.brand { display: flex; align-items: center; gap: 9px; padding: 4px 10px 4px 6px; border: 0; background: none; border-radius: 10px; flex: none; color: var(--ink); }
.brand:hover { background: var(--hover); }
.brand .cw { width: 26px; height: 28px; }
.wordmark { display: grid; line-height: 1; letter-spacing: 0.14em; font-weight: 500; font-size: 11px; text-align: left; }
.wordmark span + span { color: var(--coral-deep); margin-top: 3px; }
.titlebox { display: flex; flex-direction: column; min-width: 0; flex: 0 1 auto; padding-right: 6px; border-left: 1px solid var(--line); padding-left: 12px; }
.map-title { font-weight: 500; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 32ch; }
.save-state { font-size: 12px; color: var(--muted); display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.save-state::before { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--sage); margin-right: 6px; vertical-align: 1px; }
.save-state[data-s="saving"]::before { background: var(--blush); outline: 1px solid var(--coral); }
.save-state[data-s="error"]::before { background: var(--coral-strong); }
.save-state[data-s="local"]::before { background: var(--line-strong); }
.tools { display: flex; align-items: center; gap: 2px; flex: 1 1 auto; justify-content: safe center; min-width: 0; overflow-x: auto; overflow-y: hidden; scrollbar-width: none; }
.tools::-webkit-scrollbar { display: none; }
.tools.compact .lbl { display: none; }
#topbar.tight .wordmark { display: none; }
#topbar.tight .btn.claude-btn { padding: 0; width: 38px; border: 0; }
#topbar.tight .btn.claude-btn .lbl { display: none; }
.tools .sep { width: 1px; height: 22px; background: var(--line); margin: 0 6px; flex: none; }
.side-tools { display: flex; align-items: center; gap: 2px; flex: none; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  min-height: 38px; min-width: 38px; padding: 0 9px; border: 0; border-radius: 10px;
  background: none; color: var(--ink); white-space: nowrap; font-size: 14px; flex: none;
}
.btn:hover { background: var(--hover); }
.btn:active { background: var(--active); }
.btn[aria-pressed="true"] { background: var(--active); }
.btn:disabled { opacity: 0.4; cursor: default; background: none; }
.btn.icon-only { padding: 0; width: 38px; }
.btn .lbl { font-size: 13px; }
.btn.primary { background: var(--green); color: var(--on-green); padding: 0 14px; font-weight: 500; }
.btn.primary:hover { background: var(--green-hover); }
.btn.danger { background: var(--coral-strong); color: var(--on-coral); padding: 0 14px; font-weight: 500; }
.btn.danger:hover { background: var(--coral-deep); }
.btn.outline { border: 1px solid var(--line-strong); padding: 0 12px; }
.btn.small { min-height: 30px; min-width: 30px; font-size: 13px; padding: 0 8px; border-radius: 8px; }
.btn.claude-btn { gap: 8px; padding: 0 12px 0 6px; border: 1px solid var(--line-strong); }
.btn.claude-btn .ring { width: 26px; height: 26px; }
.btn.claude-btn[aria-busy="true"] .ring rect { animation: stave 1.1s ease-in-out infinite; }
.kbd { font: 11px/1 var(--font-mono); padding: 3px 5px; border: 1px solid var(--line-strong); border-bottom-width: 2px; border-radius: 5px; color: var(--muted); white-space: nowrap; }

/* Frekvensringen: de 48 stavene fra Clockwork-symbolet, brukt når Claude arbeider eller lytter. */
.ring { flex: none; }
.ring rect { transform-box: fill-box; transform-origin: 50% 0; }
.ring.live rect { animation: stave 1.1s ease-in-out infinite; }
@keyframes stave { 0%, 100% { transform: scaleY(1); } 50% { transform: scaleY(0.45); } }

/* Paneler */
.panel {
  position: absolute; top: 64px; right: 0; bottom: 84px; width: 330px; max-width: 100%;
  display: flex; flex-direction: column; overflow: hidden; z-index: 3;
}
.panel-head { display: flex; align-items: center; gap: 8px; padding: 10px 8px 6px 16px; border-bottom: 1px solid var(--line); }
.panel-head h2 { font-size: 15px; font-weight: 500; margin: 0; flex: 1; text-wrap: balance; }
.tabs { display: flex; gap: 2px; }
.tab { border: 0; background: none; padding: 6px 10px; border-radius: 8px; font-size: 13px; color: var(--muted); min-height: 32px; }
.tab[aria-selected="true"] { background: var(--active); color: var(--ink); font-weight: 500; }
.panel-body { overflow: auto; padding: 4px 16px 18px; flex: 1; overscroll-behavior: contain; }
.sect { padding: 12px 0; border-bottom: 1px solid var(--line); display: grid; gap: 8px; }
.sect:last-child { border-bottom: 0; }
.sect h3 { margin: 0; font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase; font-weight: 500; color: var(--muted); }
.sect p { margin: 0; color: var(--muted); font-size: 13px; }
.row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.seg { display: inline-flex; border: 1px solid var(--line-strong); border-radius: 10px; padding: 2px; gap: 2px; flex-wrap: wrap; }
.seg button { border: 0; background: none; border-radius: 8px; min-height: 32px; min-width: 34px; padding: 0 9px; font-size: 13px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; color: var(--ink); }
.seg button:hover { background: var(--hover); }
.seg button[aria-pressed="true"] { background: var(--green); color: var(--on-green); }
.swatches { display: grid; grid-template-columns: repeat(8, 1fr); gap: 6px; }
.swatch { aspect-ratio: 1; max-width: 100%; border-radius: 50%; border: 1px solid rgb(20 31 28 / 0.15); padding: 0; position: relative; }
.swatch[aria-pressed="true"] { outline: 2px solid var(--coral-strong); outline-offset: 2px; }
.swatch.auto { background: var(--panel); border: 1px dashed var(--field-edge); }
.swatch.auto::after { content: ""; position: absolute; left: 20%; right: 20%; top: 50%; height: 1.5px; background: var(--muted); transform: rotate(-45deg); }
.markers { display: grid; gap: 8px; }
.mk-group { display: grid; gap: 2px; }
.mk-row { display: flex; flex-wrap: wrap; gap: 4px; }
.mk-btn { border: 1px solid transparent; background: none; border-radius: 8px; width: 36px; height: 36px; display: inline-flex; align-items: center; justify-content: center; padding: 0; }
.mk-btn:hover { background: var(--hover); }
.mk-btn[aria-pressed="true"] { border-color: var(--coral-strong); background: var(--blush-soft); }
.field, .area {
  width: 100%; box-sizing: border-box; border: 1px solid var(--field-edge); border-radius: 10px; background: var(--field);
  padding: 8px 10px; font-size: 14px; color: var(--ink);
}
.area { min-height: 96px; resize: vertical; line-height: 1.45; }
.field:focus, .area:focus { outline: 2px solid var(--coral-deep); outline-offset: 0; border-color: transparent; }
.hint { font-size: 12px; color: var(--muted); }
.err { font-size: 12px; color: var(--coral-deep); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 2px 4px 2px 10px; border-radius: 999px; background: var(--hover); font-size: 13px; }
.chip button { border: 0; background: none; width: 24px; height: 24px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; padding: 0; color: var(--muted); }
.chip button:hover { background: var(--active); color: var(--ink); }
.chip .ic { width: 14px; height: 14px; }
.ext-link { color: var(--coral-deep); overflow-wrap: anywhere; font-size: 13px; }
.themes { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.theme-card { border: 1px solid var(--line-strong); border-radius: 12px; background: none; padding: 8px; text-align: left; display: grid; gap: 6px; min-width: 0; }
.theme-card:hover { background: var(--hover); }
.theme-card[aria-pressed="true"] { border-color: var(--coral-strong); box-shadow: inset 0 0 0 1px var(--coral-strong); }
.theme-card .prev { height: 40px; border-radius: 8px; display: block; width: 100%; }
.theme-card b { font-weight: 500; font-size: 13px; }
.theme-card span { font-size: 12px; color: var(--muted); }
.looks { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.look-card { border: 1px solid var(--line-strong); border-radius: 12px; background: none; padding: 6px 6px 8px; display: grid; gap: 6px; min-width: 0; text-align: center; color: var(--ink); }
.look-card:hover { background: var(--hover); }
.look-card[aria-pressed="true"] { border-color: var(--green); box-shadow: inset 0 0 0 1px var(--green); }
.look-card .prev { display: block; width: 100%; height: auto; aspect-ratio: 96 / 56; border-radius: 8px; }
.look-card b { font-weight: 500; font-size: 13px; }
.pals { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.pal-card { border: 1px solid var(--line-strong); border-radius: 10px; background: none; padding: 6px 6px 7px; display: grid; gap: 5px; min-width: 0; text-align: center; color: var(--ink); }
.pal-card:hover { background: var(--hover); }
.pal-card[aria-pressed="true"] { border-color: var(--green); box-shadow: inset 0 0 0 1px var(--green); }
.pal-card .pal-prev { display: block; width: 100%; height: auto; aspect-ratio: 60 / 20; }
.pal-card b { font-weight: 500; font-size: 12.5px; }
.layouts { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.layouts button { border: 1px solid var(--line-strong); border-radius: 10px; background: none; padding: 8px 10px; display: flex; align-items: center; gap: 8px; font-size: 13px; min-height: 40px; text-align: left; }
.layouts button:hover { background: var(--hover); }
.layouts button[aria-pressed="true"] { border-color: var(--green); background: var(--green); color: var(--on-green); }

/* Disposisjonen */
.outline { list-style: none; margin: 0; padding: 4px 0; font-size: 14px; }
.ol-row { display: flex; align-items: center; gap: 2px; min-height: 30px; border-radius: 8px; padding-right: 6px; }
.ol-row:hover { background: var(--hover); }
.ol-row.selected { background: var(--active); }
.ol-row .tw { width: 22px; height: 22px; border: 0; background: none; display: inline-flex; align-items: center; justify-content: center; border-radius: 6px; padding: 0; color: var(--muted); flex: none; }
.ol-row .tw .ic { width: 14px; height: 14px; transition: transform 0.12s; }
.ol-row .tw[aria-expanded="false"] .ic { transform: rotate(-90deg); }
.ol-row .tx { border: 0; background: none; text-align: left; flex: 1; min-width: 0; padding: 4px 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.ol-row .bullet { width: 6px; height: 6px; border-radius: 50%; flex: none; margin: 0 8px; }
.ol-row.lvl0 .tx { font-weight: 500; }
.ol-row.lvl1 .tx { font-weight: 500; }

/* Kartene dine */
.drawer {
  position: absolute; top: 64px; left: 0; bottom: 84px; width: 340px; max-width: 100%;
  display: flex; flex-direction: column; overflow: hidden; z-index: 3;
}
.drawer .panel-body { padding-top: 10px; }
.drawer-actions { display: flex; gap: 8px; flex-wrap: wrap; padding: 12px 16px 8px; }
.map-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.map-item { display: flex; align-items: center; gap: 4px; border-radius: 10px; }
.map-item:hover { background: var(--hover); }
.map-item.current { background: var(--active); }
.map-open { flex: 1; min-width: 0; border: 0; background: none; text-align: left; padding: 8px 10px; display: grid; gap: 2px; border-radius: 10px; }
.map-open b { font-weight: 500; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.map-open span { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.badge { display: inline-block; font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase; padding: 1px 6px; border-radius: 999px; background: var(--blush-soft); color: var(--coral-deep); margin-left: 6px; vertical-align: 1px; font-weight: 500; }
.trash-toggle { margin-top: 14px; }
.empty-note { color: var(--muted); font-size: 13px; padding: 8px 10px; }
.privacy { display: flex; gap: 8px; align-items: flex-start; font-size: 12px; color: var(--muted); margin: 16px 0 0; }
.privacy .ic { width: 16px; height: 16px; margin-top: 1px; }

/* Innboksen */
.inbox-btn { position: relative; }
.inbox-count { position: absolute; top: 2px; right: 1px; min-width: 17px; height: 17px; padding: 0 4px; border-radius: 999px; background: var(--coral-strong); color: var(--on-coral); font-size: 10.5px; font-weight: 600; line-height: 17px; text-align: center; font-variant-numeric: tabular-nums; pointer-events: none; box-shadow: 0 0 0 2px var(--panel); }
.inbox-count:empty { display: none; }
.ib-intro { font-size: 13px; color: var(--muted); margin: 12px 0 2px; text-wrap: pretty; }
.ib-card { border: 1px solid var(--line); border-radius: 12px; padding: 12px; margin-top: 10px; display: grid; gap: 6px; background: var(--panel); min-width: 0; }
.ib-title { margin: 0; font-size: 14px; font-weight: 500; overflow-wrap: anywhere; text-wrap: balance; }
.ib-meta { margin: 0; font-size: 12px; color: var(--muted); }
.ib-where { margin: 0; font-size: 13px; display: flex; gap: 6px; align-items: flex-start; text-wrap: pretty; overflow-wrap: anywhere; }
.ib-where .ic { width: 15px; height: 15px; margin-top: 2px; color: var(--muted); }
.ib-tree { list-style: none; margin: 2px 0 0; padding: 8px 10px; border-radius: 8px; background: var(--hover); font-size: 13px; display: grid; gap: 3px; min-width: 0; }
.ib-tree li { display: flex; align-items: center; gap: 4px; min-width: 0; }
.ib-tree li span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.ib-tree li.top { font-weight: 500; }
.ib-tree .ib-hasnote { width: 13px; height: 13px; color: var(--muted); }
.ib-more { color: var(--muted); font-size: 12px; }
.ib-note { margin: 0; padding: 8px 10px; border-radius: 8px; background: var(--hover); font-size: 13px; white-space: pre-wrap; overflow-wrap: anywhere; max-height: 10.5em; overflow: hidden; }
.ib-acts { margin-top: 4px; }
.ol-head { font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); padding: 14px 6px 4px; font-weight: 500; }
.tpl-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 6px; }
.tpl-grid .theme-card { min-height: 64px; align-content: start; }

/* Søk */
.searchbox { position: absolute; top: 64px; right: 0; display: flex; align-items: center; gap: 4px; padding: 6px; z-index: 4; width: min(360px, 100%); box-sizing: border-box; }
.searchbox input { flex: 1; min-width: 0; border: 0; background: none; padding: 6px 8px; font-size: 15px; outline: none; }
.searchbox .count { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; padding: 0 4px; }

/* Claude-linja */
.claudebar {
  position: absolute; left: 50%; bottom: 0; transform: translateX(-50%); width: min(680px, 100%);
  box-sizing: border-box; padding: 6px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 6px; z-index: 3;
}
.cb-row { display: flex; align-items: center; gap: 6px; min-width: 0; }
.cb-row .ring { width: 30px; height: 30px; margin-left: 4px; }
.cb-input {
  flex: 1 1 0; width: 0; min-width: 0; border: 0; background: none; font-size: 15px; padding: 8px 6px; outline: none; resize: none;
  max-height: 120px; line-height: 1.4;
}
.cb-input.partial { color: var(--muted); }
.cb-out { display: grid; gap: 6px; padding: 4px 10px 6px; font-size: 14px; }
.cb-out .answer { white-space: pre-wrap; overflow-wrap: anywhere; }
.cb-out .changes { font-size: 13px; color: var(--muted); }
.cb-out .acts { display: flex; gap: 6px; flex-wrap: wrap; }
.cb-status { font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 8px; }
.cb-out .hint { display: flex; gap: 8px; align-items: flex-start; }
.cb-out .hint .ic { width: 16px; height: 16px; flex: none; margin-top: 1px; }
.cb-out .err { font-size: 14px; }
.mic[aria-pressed="true"] { background: var(--coral-strong); color: var(--on-coral); }
.mic[aria-pressed="true"] .dot { fill: var(--on-coral); }

/* Zoom nederst til høyre. Viker for Claude-linja når den er åpen. */
.zoombar { position: absolute; right: 0; bottom: 0; display: flex; align-items: center; gap: 2px; padding: 4px; z-index: 2; }
.zoombar #zoom-label { min-width: 58px; font-variant-numeric: tabular-nums; }
.claudebar:not([hidden]) ~ .zoombar { display: none; }

/* Mobil */
.mobilebar { position: absolute; left: 0; right: 0; bottom: 0; display: none; justify-content: space-around; padding: 4px; z-index: 3; }
.mobilebar .btn { min-height: 44px; min-width: 44px; flex-direction: column; gap: 2px; font-size: 11px; padding: 2px 6px; }

/* Varsler */
.toasts { position: absolute; left: 0; bottom: 90px; display: grid; gap: 8px; z-index: 6; max-width: min(420px, 100%); }
/* Med kartlista åpen legger varslene seg ved siden av den, ikke oppå. */
.drawer:not([hidden]) ~ .toasts { left: 352px; max-width: min(420px, calc(100% - 352px)); }
.toast { padding: 10px 12px 10px 14px; display: flex; align-items: center; gap: 10px; font-size: 14px; animation: rise 0.18s ease-out; }
.toast.warn { border-color: var(--coral-strong); }
.toast .btn { min-height: 30px; }
@keyframes rise { from { transform: translateY(6px); opacity: 0; } to { transform: none; opacity: 1; } }

/* Meny og dialog */
.menu { position: fixed; z-index: 20; min-width: 220px; max-width: min(320px, calc(100vw - 32px)); padding: 6px; display: grid; gap: 1px; max-height: min(70vh, 560px); overflow: auto; }
.menu button { display: flex; align-items: center; gap: 10px; border: 0; background: none; text-align: left; padding: 8px 10px; border-radius: 8px; font-size: 14px; min-height: 36px; }
.menu button:hover, .menu button:focus-visible { background: var(--hover); }
.menu button .kbd { margin-left: auto; }
.menu button.danger-item { color: var(--coral-deep); }
.menu .menu-note { font-size: 12px; color: var(--muted); padding: 0 10px 8px; }
.menu hr { border: 0; border-top: 1px solid var(--line); margin: 4px 6px; }
.menu .menu-label { font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); padding: 8px 10px 4px; }
.modal-wrap { position: fixed; inset: 0; z-index: 30; display: grid; place-items: center; background: var(--scrim); padding: 16px; -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); }
.modal { width: min(520px, 100%); max-height: calc(100% - 32px); display: flex; flex-direction: column; background: var(--panel); border-radius: 18px; box-shadow: var(--shadow); border: 1px solid var(--line); overflow: hidden; }
.modal header { padding: 18px 20px 6px; display: flex; gap: 12px; align-items: flex-start; }
.modal h2 { margin: 0; font-size: 18px; font-weight: 500; flex: 1; text-wrap: balance; }
.modal .body { padding: 6px 20px 8px; overflow: auto; color: var(--ink); }
.modal .body p { margin: 0 0 10px; text-wrap: pretty; }
.modal footer { padding: 12px 20px 18px; display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.keys { width: 100%; border-collapse: collapse; font-size: 14px; }
.keys td { padding: 6px 4px; border-bottom: 1px solid var(--line); vertical-align: top; }
.keys td:first-child { white-space: nowrap; width: 1%; padding-right: 14px; }
.keys h4 { margin: 14px 0 4px; font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); font-weight: 500; }

/* Tilstander over lerretet */
.overlay { position: absolute; inset: 0; z-index: 10; display: grid; place-items: center; background: var(--paper); padding: 24px; box-sizing: border-box; }
.overlay.soft { background: transparent; pointer-events: none; }
.overlay.soft .card { pointer-events: auto; }
.card { width: min(460px, 100%); padding: 28px; display: grid; gap: 14px; justify-items: start; text-align: left; box-sizing: border-box; }
.card .cw { width: 44px; height: 48px; }
.card h1 { margin: 0; font-size: 24px; line-height: 1.2; font-weight: 500; text-wrap: balance; }
.card p { margin: 0; color: var(--muted); text-wrap: pretty; }
.card .row { margin-top: 4px; }
.card .ring { width: 64px; height: 64px; }
.lock .ic { width: 22px; height: 22px; }
.notice { display: flex; gap: 8px; align-items: flex-start; background: var(--warn-bg); color: var(--warn-ink); border-radius: 10px; padding: 8px 10px; font-size: 13px; }

.only-narrow { display: none !important; }
@media (max-width: 1180px) {
  .tools .lbl { display: none; }
  .map-title { max-width: 24ch; }
}
@media (max-width: 900px) {
  .wordmark { display: none; }
  .btn.claude-btn { padding: 0; width: 38px; border: 0; }
  .btn.claude-btn .lbl { display: none; }
}
@media (max-width: 760px) {
  .tools { display: none; }
  .only-wide { display: none !important; }
  .only-narrow { display: inline-flex !important; }
  .titlebox { flex: 1 1 auto; }
  .map-title { max-width: 100%; }
  .wordmark { display: none; }
  .btn.claude-btn { padding: 0; width: 44px; border: 0; }
  .btn.claude-btn .lbl { display: none; }
  .panel, .drawer { z-index: 5; }
  .mobilebar { display: flex; }
  .zoombar { display: none; }
  .claudebar { bottom: 64px; }
  .toasts { bottom: 150px; }
  .drawer:not([hidden]) ~ .toasts, .panel:not([hidden]) ~ .toasts { left: 0; bottom: auto; top: 64px; max-width: 100%; }
  .panel, .drawer { top: auto; bottom: 0; left: 0; right: 0; width: auto; max-height: 64%; }
  .searchbox { width: 100%; }
  .btn { min-height: 44px; min-width: 44px; }
  .btn.icon-only { width: 44px; }
  .field, .area, .cb-input, .searchbox input { font-size: 16px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}

/* Panelet og skuffen tar fokus ved klikk på tomme flater, så tastene ikke går til kartet. */
.panel:focus, .drawer:focus { outline: none; }

/* Ikonbiblioteket og ikonene i kartet */
.hdl-ic-rs { cursor: nwse-resize; }
.hdl .knob { fill: var(--sel, var(--coral-strong)); stroke: var(--canvas, var(--paper)); stroke-width: 1.5; transform-box: fill-box; transform-origin: center; transition: transform 0.1s; }
.hdl-ic-rs:hover .knob { transform: scale(1.25); }
.ticon { pointer-events: none; }
.ic-body .ic-top { position: sticky; top: 0; z-index: 1; background: var(--panel-solid, var(--paper)); padding-top: 10px; }
.ic-search { width: 100%; min-height: 36px; padding: 0 12px; border: 1px solid var(--line-strong); border-radius: 10px; background: transparent; color: inherit; font: inherit; }
.ic-search:focus-visible { outline: 2px solid var(--coral-strong); outline-offset: 1px; }
.ic-lib { display: grid; grid-template-columns: repeat(auto-fill, minmax(70px, 1fr)); gap: 4px; }
.ic-tile { display: grid; justify-items: center; align-content: start; gap: 3px; padding: 8px 2px 6px; border: 1px solid transparent; border-radius: 10px; background: none; color: var(--ink); font: inherit; font-size: 11.5px; line-height: 1.2; text-align: center; cursor: grab; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.ic-tile img { width: 44px; height: 44px; object-fit: contain; pointer-events: none; }
.ic-tile:hover { background: var(--hover); }
.ic-tile:focus-visible { outline: 2px solid var(--coral-strong); outline-offset: 1px; }
.ic-tile[aria-pressed="true"] { border-color: var(--coral-strong); background: var(--blush-soft); }
.ic-tile[hidden] { display: none; }
.ic-none { color: var(--muted); font-size: 13px; padding: 12px 0; margin: 0; }
.ic-ghost { position: fixed; z-index: 60; width: 64px; height: 64px; margin: -32px 0 0 -32px; pointer-events: none; filter: drop-shadow(0 6px 14px rgb(0 0 0 / 0.25)); }
.ic-current { display: flex; align-items: center; gap: 10px; font-weight: 500; }
.ic-current img { width: 40px; height: 40px; object-fit: contain; }
.ic-size { display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 10px; font-size: 13px; color: var(--muted); }
.ic-size input { width: 100%; accent-color: var(--coral-strong); }

/* Fest til rutenett: rutene vises tydeligere når de er på */
#stage.snap { background-image: linear-gradient(var(--grid-s, var(--grid)) 1px, transparent 1px), linear-gradient(90deg, var(--grid-s, var(--grid)) 1px, transparent 1px); }
.zoombar .sep { width: 1px; align-self: stretch; margin: 6px 2px; background: var(--line); }

/* Tegning. Strekene ligger over emnene og tar ikke imot klikk. I tegnemodus går alt til pennen. */
.ink { pointer-events: none; }
.ink.erasing { opacity: 0.15; }
.ink.dragging { opacity: 0.2; }
#stage.inking, #stage.inking * { cursor: crosshair; }
#stage.inking #svg * { pointer-events: none; }
.ink-eraser { fill: none; stroke: var(--ink); stroke-width: 1.5; vector-effect: non-scaling-stroke; opacity: 0.75; }
.inkbar { position: absolute; top: 64px; left: 50%; transform: translateX(-50%); display: flex; align-items: center; gap: 2px; padding: 4px; z-index: 4; max-width: 100%; box-sizing: border-box; overflow-x: auto; scrollbar-width: none; }
.inkbar .sep { width: 1px; align-self: stretch; margin: 6px 4px; background: var(--line); flex: none; }
.ink-grp { display: flex; align-items: center; gap: 2px; flex: none; }
.ink-sw { width: 32px; height: 32px; padding: 0; border: 0; border-radius: 50%; background: none; display: grid; place-items: center; flex: none; cursor: pointer; }
.ink-sw::before { content: ""; width: 20px; height: 20px; border-radius: 50%; background: var(--sw); box-shadow: inset 0 0 0 1px rgb(0 0 0 / 0.14); }
.ink-sw.mark::before { border-radius: 6px; }
.ink-sw:hover { background: var(--hover); }
.ink-sw[aria-pressed="true"] { box-shadow: inset 0 0 0 2px var(--ink); }
.ink-sz .dot { width: var(--d); height: var(--d); border-radius: 50%; background: currentColor; }
.ink-cols { width: calc(6 * 32px + 5 * 2px); }
.ink-hint { font-size: 12px; line-height: 1.25; color: var(--muted); padding: 0 6px; }
.ink-sz .dot.ring { background: none; border: 1.5px solid currentColor; box-sizing: border-box; }
@media (max-width: 760px) {
  .inkbar { top: auto; bottom: 64px; left: 0; transform: none; }
  /* På smal skjerm går tegnelinja over to rader: verktøy, tykkelse og Ferdig øverst, farger og Angre under. */
  .inkbar { flex-wrap: wrap; justify-content: center; row-gap: 2px; }
  .inkbar .sep { display: none; }
  .inkbar > .ink-tools { order: 1; }
  .inkbar > .ink-sizes { order: 2; }
  .inkbar > [data-k="done"] { order: 3; }
  .inkbar > .ink-cols { order: 4; }
  .inkbar > [data-k="undo"] { order: 5; }
  .inkbar > [data-k="clear"] { order: 6; }
  .inkbar .btn.icon-only { width: 40px; min-width: 40px; min-height: 40px; }
  .ink-sw { width: 36px; height: 36px; }
  .ink-cols { width: calc(6 * 36px + 5 * 2px); }
}

/* Møteopptak nederst på midten. Zoomen viker, og Claude-linja legger seg over. */
.recbar { position: absolute; left: 50%; bottom: 0; transform: translateX(-50%); width: min(640px, 100%); box-sizing: border-box; padding: 8px 10px; display: grid; gap: 6px; z-index: 3; }
.recbar:not([hidden]) ~ .zoombar { display: none; }
.recbar:not([hidden]) ~ .claudebar { bottom: 176px; }
.rec-top { display: flex; align-items: center; gap: 8px; min-width: 0; flex-wrap: wrap; }
.rec-top .grow { flex: 1 1 auto; }
.rec-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--line-strong); flex: none; }
.recbar.live .rec-dot { background: var(--coral-strong); animation: recpulse 1.4s ease-in-out infinite; }
@keyframes recpulse { 50% { opacity: 0.35; } }
.rec-state { font-weight: 500; font-size: 14px; }
.rec-time, .rec-words { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.rec-text { max-height: 96px; overflow-y: auto; font-size: 14px; line-height: 1.45; white-space: pre-wrap; overflow-wrap: anywhere; }
.rec-text .partial { color: var(--muted); }
.rec-msg { font-size: 13px; }
.rec-note { font-size: 12px; color: var(--muted); }
@media (prefers-reduced-motion: reduce) { .recbar.live .rec-dot { animation: none; } }
@media (max-width: 760px) {
  .recbar { bottom: 64px; }
  .recbar:not([hidden]) ~ .claudebar { bottom: 240px; }
}
