/* Measure Twice — light, calendar-like look with Airtable-style tags. */

:root {
  --bg: #ffffff;
  --bg-soft: #f6f8fb;
  --panel: #ffffff;
  --hover: #f1f3f6;
  --line: #e3e6eb;
  --line-soft: #eef0f3;
  --text: #1f2328;
  --muted: #5f6672;
  --faint: #9aa1ac;
  --accent: #2563eb;
  --accent-soft: #e8f0fe;
  --danger: #d93025;
  --grid-bar: #e6e8ec;
  --grid-beat: #f3f4f6;
  --wave: #b8c0cc;
  --tint: 16%;        /* pastel fill strength for parts and tags */
  --ink: 58%;         /* how much of the colour goes into text on a pastel */
  --ink-base: #111;
  --band: 5%;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .1);
  --shadow-lg: 0 8px 28px rgba(16, 24, 40, .16), 0 2px 6px rgba(16, 24, 40, .08);
  --radius: 8px;
  --head-w: 176px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #17181b; --bg-soft: #1d1f23; --panel: #1b1d21; --hover: #262930;
    --line: #2d3037; --line-soft: #24272d; --text: #e8eaed; --muted: #a0a6b1; --faint: #6b717c;
    --accent: #7aa2ff; --accent-soft: #233150; --danger: #f28b82;
    --grid-bar: #2b2e35; --grid-beat: #212329; --wave: #565c68;
    --tint: 30%; --ink: 45%; --ink-base: #fff; --band: 7%;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4); --shadow-lg: 0 10px 30px rgba(0, 0, 0, .5);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--text); overflow: hidden;
  font: 13px/1.4 Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
code { font: 12px ui-monospace, SFMono-Regular, Menlo, monospace; background: var(--hover); padding: 1px 5px; border-radius: 4px; }

/* ---------- buttons & fields ---------- */
.btn {
  border: 1px solid var(--line); background: var(--panel); border-radius: 999px;
  padding: 7px 14px; font-weight: 500; cursor: pointer; white-space: nowrap;
  transition: background .12s, box-shadow .12s;
}
.btn:hover { background: var(--hover); }
.btn.small { padding: 4px 10px; font-size: 12px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; box-shadow: var(--shadow); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn.ghost:hover { background: var(--hover); color: var(--text); }
.btn.danger { color: var(--danger); }
.icon-btn {
  border: 0; background: transparent; width: 34px; height: 34px; border-radius: 50%;
  display: inline-grid; place-items: center; cursor: pointer; color: var(--muted); font-size: 16px; flex: none;
}
.icon-btn:hover { background: var(--hover); color: var(--text); }
.icon-btn:disabled { opacity: .35; cursor: default; background: transparent; }
.icon-btn.on { background: var(--accent-soft); color: var(--accent); }
.icon-btn.tiny { width: 24px; height: 24px; font-size: 13px; }
.field { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12px; white-space: nowrap; }
.field input, .field select {
  border: 1px solid var(--line); border-radius: 6px; background: var(--panel); padding: 4px 6px; color: var(--text);
}
.field input[type=number] { width: 64px; }
.field.zoom input { width: 100px; accent-color: var(--accent); }
.spacer { flex: 1; }

/* ---------- layout ---------- */
#app { display: flex; height: 100vh; }
#sidebar {
  width: 264px; flex: none; background: var(--bg-soft); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; transition: margin-left .2s ease; min-height: 0;
}
#app.sidebar-hidden #sidebar { margin-left: -264px; }
#main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
#inspector {
  width: 300px; flex: none; border-left: 1px solid var(--line); background: var(--panel);
  display: flex; flex-direction: column; transition: margin-right .2s ease; min-height: 0;
}
#app.inspector-hidden #inspector { margin-right: -300px; }

/* ---------- sidebar ---------- */
.sb-head { padding: 16px 18px 8px; }
.logo { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 16px; letter-spacing: -.01em; }
.logo-text { display: flex; flex-direction: column; line-height: 1.2; }
.logo-text small { font-size: 11px; font-weight: 500; color: var(--muted); letter-spacing: 0; }
.logo-mark { display: grid; gap: 3px; width: 22px; }
.logo-mark i { display: block; height: 5px; border-radius: 3px; }
.logo-mark i:nth-child(1) { background: #3b82f6; width: 70%; }
.logo-mark i:nth-child(2) { background: #ef4444; width: 100%; margin-left: 20%; }
.logo-mark i:nth-child(3) { background: #10b981; width: 55%; margin-left: 10%; }
.sb-actions { display: flex; flex-direction: column; gap: 8px; padding: 8px 14px 12px; }
.sb-actions .btn { text-align: left; padding: 9px 16px; }
#song-search {
  margin: 0 14px 8px; border: 1px solid var(--line); background: var(--panel); border-radius: 999px; padding: 7px 14px; outline: none;
}
#song-search:focus { border-color: var(--accent); }
#song-list { list-style: none; margin: 0; padding: 4px 8px; overflow: auto; flex: 1; }
.song-item { padding: 9px 10px 10px; border-radius: 10px; cursor: pointer; margin-bottom: 2px; }
.song-item:hover { background: var(--hover); }
.song-item.active { background: var(--accent-soft); }
.si-top { display: flex; align-items: center; gap: 6px; }
.si-title { font-weight: 600; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.si-badge { color: var(--accent); font-size: 12px; }
.si-menu { opacity: 0; }
.song-item:hover .si-menu, .song-item.active .si-menu { opacity: 1; }
.si-meta { color: var(--muted); font-size: 11.5px; margin: 1px 0 7px; }
.si-strip { display: flex; gap: 1px; height: 6px; border-radius: 3px; overflow: hidden; background: var(--line); }
.si-strip i { display: block; min-width: 1px; }
.si-empty { color: var(--faint); padding: 12px; }
.sb-foot { display: flex; align-items: center; justify-content: space-between; padding: 10px 12px; border-top: 1px solid var(--line); }

/* ---------- top bar & toolbar ---------- */
#topbar { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-bottom: 1px solid var(--line); min-height: 56px; }
.title-input {
  border: 1px solid transparent; background: transparent; font-size: 20px; font-weight: 600; letter-spacing: -.01em;
  padding: 4px 8px; border-radius: 6px; min-width: 120px; width: 28ch; max-width: 36vw; outline: none;
}
.title-input:hover { border-color: var(--line); }
.title-input:focus { border-color: var(--accent); background: var(--panel); }
.view-switch { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; padding: 2px; background: var(--bg-soft); }
.view-switch button {
  border: 0; background: transparent; border-radius: 999px; padding: 5px 12px; cursor: pointer; color: var(--muted);
  display: inline-flex; align-items: center; gap: 6px; font-weight: 500;
}
.view-switch button.on { background: var(--panel); color: var(--text); box-shadow: var(--shadow); }
.transport { display: flex; align-items: center; gap: 4px; }
.icon-btn.play { background: var(--accent); color: #fff; width: 36px; height: 36px; font-size: 13px; }
.icon-btn.play:hover { background: var(--accent); filter: brightness(1.08); color: #fff; }
#time-readout { display: flex; align-items: center; gap: 8px; min-width: 150px; padding: 0 6px; font-variant-numeric: tabular-nums; }
#time-readout b { font-size: 15px; min-width: 42px; }
#time-readout span:not(.tag) { color: var(--muted); }

#toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; padding: 8px 12px; border-bottom: 1px solid var(--line); }
/* when space runs out the right-hand group wraps to its own row, still right-aligned */
.tb-left { flex: 1 1 420px; min-width: 0; display: flex; align-items: center; gap: 10px; }
.tb-right { flex: none; margin-left: auto; display: flex; align-items: center; gap: 14px; min-height: 28px; }
.tb-label { color: var(--muted); font-size: 12px; font-weight: 500; white-space: nowrap; }
/* one row that scrolls sideways when space is tight, fading at the edge */
#section-chips {
  display: flex; gap: 6px; min-width: 0; overflow-x: auto; scrollbar-width: none; padding: 2px 0;
}
#section-chips.fade { mask-image: linear-gradient(to right, #000 calc(100% - 32px), transparent); }
#section-chips::-webkit-scrollbar { display: none; }
#section-chips .tag { flex: none; }
#btn-structure { flex: none; }
#zoom-tools { display: flex; align-items: center; gap: 10px; }
.field.zoom { gap: 2px; }

/* toggle switch */
.switch { display: inline-flex; align-items: center; gap: 7px; font-size: 12px; font-weight: 500; color: var(--muted); cursor: pointer; user-select: none; white-space: nowrap; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch .track { width: 30px; height: 18px; border-radius: 9px; background: var(--line); position: relative; transition: background .15s; flex: none; }
.switch .track::after { content: ''; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, .3); transition: transform .15s; }
.switch input:checked + .track { background: var(--accent); }
.switch input:checked + .track::after { transform: translateX(12px); }
.switch input:focus-visible + .track { box-shadow: 0 0 0 3px var(--accent-soft); }
.switch.disabled { opacity: .5; cursor: not-allowed; }

/* ---------- tags (Airtable-style pills) ---------- */
.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag {
  display: inline-flex; align-items: center; gap: 4px; border: 0; border-radius: 999px; padding: 3px 10px;
  background: color-mix(in srgb, var(--c) var(--tint), var(--bg));
  color: color-mix(in srgb, var(--c) var(--ink), var(--ink-base));
  font-weight: 600; font-size: 12px; white-space: nowrap; cursor: pointer; line-height: 1.5;
}
.tag.small { padding: 1px 8px; font-size: 11.5px; }
.tag:hover { box-shadow: inset 0 0 0 1px var(--c); }
.tag.on { background: var(--c); color: #fff; }
.tag.chip { padding: 4px 11px; }

/* ---------- timeline ---------- */
#timeline-wrap { position: relative; flex: 1; min-height: 0; }
#timeline { position: absolute; inset: 0; overflow: auto; outline: none; }
.tl-inner { position: relative; min-height: 100%; }
.tl-top { position: sticky; top: 0; z-index: 5; background: var(--bg); }
.tl-row { display: flex; border-bottom: 1px solid var(--line-soft); }
.tl-row > .head {
  position: sticky; left: 0; z-index: 4; width: var(--head-w); flex: none; background: var(--bg);
  border-right: 1px solid var(--line); display: flex; align-items: center; gap: 6px; padding: 0 8px 0 12px;
}
.tl-row > .body { position: relative; flex: none; }
.row-title { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.ruler { height: 28px; }
.ruler .head.corner { font-size: 11px; color: var(--faint); text-transform: uppercase; letter-spacing: .06em; font-weight: 600; }
.ruler .body { cursor: text; background: linear-gradient(to right, var(--grid-bar) 1px, transparent 1px) 0 100% / var(--bar-w) 7px repeat-x; }
.bar-num { position: absolute; top: 6px; transform: translateX(4px); font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; pointer-events: none; }

.sections { height: 42px; border-bottom: 1px solid var(--line); }
.section {
  position: absolute; top: 6px; bottom: 6px; border-radius: 6px; background: var(--c); color: #fff;
  display: flex; align-items: center; gap: 6px; padding: 0 10px; overflow: hidden; cursor: grab;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .06); margin-left: 1px; max-width: calc(100% - 2px);
}
.section + .section { margin-left: 2px; }
.section:hover { filter: brightness(1.05); }
.section.gap { background: repeating-linear-gradient(135deg, transparent 0 6px, var(--line-soft) 6px 12px); color: var(--faint); box-shadow: inset 0 0 0 1px var(--line); border: 1px dashed var(--faint); }
.section.gap .s-name { font-weight: 500; font-style: italic; }
.section.gap.sel { box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--faint); }
.tag.gap { background: transparent; color: var(--faint); border: 1px dashed var(--faint); font-style: italic; font-weight: 500; }
.gap-row td { color: var(--faint); }
.section.sel { box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--c); z-index: 2; }
.section.dragging { opacity: .85; box-shadow: var(--shadow-lg); z-index: 3; }
.s-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; pointer-events: none; }
.s-len { font-size: 11px; opacity: .8; pointer-events: none; font-variant-numeric: tabular-nums; }
.row-hint { position: absolute; left: 12px; top: 12px; color: var(--faint); white-space: nowrap; }

.audio { height: 92px; border-bottom: 1px solid var(--line); }
.audio .row-title { text-transform: none; letter-spacing: 0; font-size: 12px; max-width: 100%; }
.audio .head { flex-direction: column; align-items: flex-start; justify-content: center; gap: 6px; }
.audio .body { cursor: text; }
.legend { display: flex; align-items: center; gap: 4px; font-size: 10.5px; color: var(--faint); }
.legend i { width: 8px; height: 8px; border-radius: 2px; display: inline-block; margin-left: 4px; }
.legend i.lo { background: #f59e0b; } .legend i.mi { background: #10b981; } .legend i.hi { background: #6366f1; }
canvas.wave { position: sticky; left: var(--head-w); display: block; }

.lanes { position: relative; }
.bands { position: absolute; top: 0; bottom: 0; pointer-events: none; z-index: 0; }
.band { position: absolute; top: 0; bottom: 0; background: color-mix(in srgb, var(--c) var(--band), transparent); border-left: 1px solid color-mix(in srgb, var(--c) 30%, transparent); }
.lane { position: relative; z-index: 1; }
.lane.dragging { z-index: 3; box-shadow: var(--shadow-lg); background: var(--bg); }
.lane-head { cursor: grab; }
.lane-head .grip { color: var(--faint); font-size: 12px; opacity: 0; transition: opacity .1s; }
.lane-head:hover .grip { opacity: 1; }
.lane-head .lname { flex: 1; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lane-head .icon-btn { opacity: 0; }
.lane-head:hover .icon-btn { opacity: 1; }
.dot { width: 12px; height: 12px; border-radius: 50%; background: var(--c); border: 0; padding: 0; cursor: pointer; flex: none; }
.dot.static { display: inline-block; cursor: default; margin-right: 6px; vertical-align: -1px; width: 10px; height: 10px; }
.dot:hover { box-shadow: 0 0 0 3px color-mix(in srgb, var(--c) 30%, transparent); }

.body.grid {
  cursor: crosshair;
  background-image: linear-gradient(to right, var(--grid-bar) 1px, transparent 1px), linear-gradient(to right, var(--grid-beat) 1px, transparent 1px);
  background-size: var(--bar-w) 100%, var(--beat-w) 100%;
}
.no-beats .body.grid { background-image: linear-gradient(to right, var(--grid-bar) 1px, transparent 1px); background-size: var(--bar-w) 100%; }

/* parts look like calendar events */
.block {
  position: absolute; top: 6px; bottom: 6px; border-radius: 6px;
  background: color-mix(in srgb, var(--c) var(--tint), var(--bg));
  color: color-mix(in srgb, var(--c) var(--ink), var(--ink-base));
  border-left: 4px solid var(--c);
  display: flex; align-items: center; overflow: hidden; cursor: grab; font-size: 12px; font-weight: 600;
  transition: box-shadow .12s;
}
.block:hover { box-shadow: var(--shadow); }
.block.sel { background: var(--c); color: #fff; box-shadow: var(--shadow-lg); z-index: 2; }
.block.narrow .b-label { padding: 0 4px; }
.b-label { padding: 0 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; pointer-events: none; }
.b-note { font-size: 11px; opacity: .7; margin-right: 8px; pointer-events: none; }
.handle { position: absolute; top: 0; bottom: 0; width: 8px; cursor: ew-resize; z-index: 1; }
.handle.l { left: 0; }
.handle.r { right: 0; }
.section .handle.r { width: 10px; }
.handle:hover { background: color-mix(in srgb, currentColor 18%, transparent); }

.add-row { border-bottom: 0; height: 52px; }
.add-row .head { border-right: 1px solid var(--line); }
.playhead { position: absolute; top: 0; bottom: 0; width: 2px; margin-left: -1px; background: var(--danger); z-index: 6; pointer-events: none; }
.playhead::before { content: ''; position: absolute; top: 0; left: -5px; width: 12px; height: 12px; border-radius: 50%; background: var(--danger); }

#empty-hint { position: absolute; left: calc(var(--head-w) + 40px); top: 160px; max-width: 460px; color: var(--muted); background: var(--panel); padding: 14px 18px; border: 1px dashed var(--line); border-radius: var(--radius); z-index: 7; }
#empty-hint p { margin: 0; }
#empty-hint a { color: var(--accent); }

body.dragging, body.dragging * { cursor: grabbing !important; user-select: none; }

/* ---------- grid view ---------- */
#grid { flex: 1; min-height: 0; overflow: auto; }
.grid-table { border-collapse: separate; border-spacing: 0; min-width: 100%; }
.grid-table th, .grid-table td { border-bottom: 1px solid var(--line-soft); border-right: 1px solid var(--line-soft); padding: 6px 8px; text-align: left; vertical-align: middle; height: 42px; }
.grid-table th { position: sticky; top: 0; z-index: 2; background: var(--bg-soft); font-weight: 600; font-size: 12px; color: var(--muted); white-space: nowrap; height: 36px; border-bottom-color: var(--line); }
.grid-table tbody tr:hover td { background: var(--bg-soft); }
.grid-table tbody tr.sel td { background: var(--accent-soft); }
.grid-table tbody tr.dragging td { background: var(--hover); }
.c-num { width: 54px; color: var(--faint); font-variant-numeric: tabular-nums; }
.c-num .grip { cursor: grab; opacity: 0; margin-right: 6px; }
tr:hover .c-num .grip { opacity: 1; }
.c-name { min-width: 160px; white-space: nowrap; }
.c-name .row-menu { opacity: 0; margin-left: 4px; }
tr:hover .c-name .row-menu { opacity: 1; }
.c-bars { width: 80px; }
.grid-table td.c-bars input { width: 64px; }
.c-start { width: 64px; font-variant-numeric: tabular-nums; }
.c-lane { min-width: 140px; }
.c-notes { min-width: 220px; }
.c-add { width: 40px; }
.grid-table td input { width: 100%; border: 1px solid transparent; background: transparent; padding: 4px 6px; border-radius: 5px; outline: none; }
.grid-table td input:hover { border-color: var(--line); }
.grid-table td input:focus { border-color: var(--accent); background: var(--panel); }
.pill {
  display: inline-flex; align-items: center; gap: 2px; margin: 2px 4px 2px 0; padding: 2px 4px 2px 9px; border-radius: 999px;
  background: color-mix(in srgb, var(--c) var(--tint), var(--bg)); color: color-mix(in srgb, var(--c) var(--ink), var(--ink-base));
  font-weight: 600; font-size: 12px; cursor: pointer; max-width: 220px;
}
.pill i { font-weight: 500; opacity: .75; }
.pill.sel { background: var(--c); color: #fff; }
.pill .x { border: 0; background: transparent; color: inherit; opacity: 0; cursor: pointer; padding: 0 4px; border-radius: 50%; }
.pill:hover .x { opacity: .7; }
.cell-add { border: 1px dashed var(--line); background: transparent; color: var(--faint); border-radius: 999px; width: 24px; height: 22px; cursor: pointer; opacity: 0; }
td:hover .cell-add { opacity: 1; }
.cell-add:hover { border-color: var(--accent); color: var(--accent); }
.grid-foot { display: flex; align-items: center; gap: 14px; padding: 12px; }

/* ---------- inspector ---------- */
.insp-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 12px 6px 18px; font-weight: 700; font-size: 15px; }
#inspector-body { padding: 4px 18px 24px; overflow: auto; flex: 1; }
.insp-kicker { color: var(--muted); font-size: 12px; margin-bottom: 12px; display: flex; align-items: center; }
.f { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; font-size: 12px; color: var(--muted); font-weight: 500; }
.f input, .f select, .f textarea {
  border: 1px solid var(--line); border-radius: 6px; padding: 7px 9px; background: var(--panel); color: var(--text); font-size: 13px; font-weight: 400; outline: none; width: 100%;
}
.f input:focus, .f select:focus, .f textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.f input:disabled { background: var(--bg-soft); color: var(--muted); }
.f textarea { resize: vertical; line-height: 1.45; }
.f2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.btn-row { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.hint { color: var(--faint); font-size: 12px; margin: 6px 0 0; }
.stats { color: var(--muted); font-size: 12px; margin: -4px 0 14px; }
.swatches { display: flex; flex-wrap: wrap; gap: 6px; }
.sw { width: 22px; height: 22px; border-radius: 50%; border: 0; background: var(--c); cursor: pointer; padding: 0; }
.sw.on { box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--c); }
.sw.none { background: var(--hover); color: var(--muted); font-size: 12px; }
.sw.none.on { box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--muted); }
.audio-box { background: var(--bg-soft); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; margin-bottom: 16px; }
.ab-title { font-weight: 600; margin-bottom: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.audio-box .muted { font-size: 12px; margin-bottom: 10px; }
.shortcuts { border-top: 1px solid var(--line); padding-top: 12px; font-size: 12px; }
.sc-title { font-weight: 700; margin-bottom: 8px; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.shortcuts div:not(.sc-title) { display: flex; justify-content: space-between; gap: 10px; padding: 3px 0; }
.shortcuts b { font-weight: 500; }
.shortcuts span { color: var(--muted); text-align: right; }

/* ---------- menu, inline edit, toast, dialogs ---------- */
.menu {
  position: fixed; z-index: 50; min-width: 220px; max-width: 320px; background: var(--panel); border-radius: 10px;
  box-shadow: var(--shadow-lg); border: 1px solid var(--line); padding: 6px 0;
}
.menu-item {
  display: flex; justify-content: space-between; align-items: center; gap: 16px; width: 100%; border: 0; background: transparent;
  padding: 7px 14px; text-align: left; cursor: pointer;
}
.menu-item:hover { background: var(--hover); }
.menu-item:disabled { opacity: .4; }
.menu-item.danger { color: var(--danger); }
.menu-item kbd { font: 11px inherit; color: var(--faint); }
.menu-sep { height: 1px; background: var(--line); margin: 6px 0; }
.menu-header { padding: 6px 14px 4px; font-size: 11px; color: var(--faint); text-transform: uppercase; letter-spacing: .06em; font-weight: 600; }
.menu-swatches, .menu-tags { padding: 4px 14px 8px; }
.inline-edit {
  position: fixed; z-index: 60; border: 2px solid var(--accent); border-radius: 6px; padding: 2px 8px; background: var(--panel);
  color: var(--text); font-weight: 600; outline: none; box-shadow: var(--shadow-lg);
}
#toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: #202124; color: #fff; padding: 11px 18px; border-radius: 8px; box-shadow: var(--shadow-lg);
  transition: opacity .18s, transform .18s; z-index: 70; max-width: min(560px, calc(100vw - 32px));
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#drop-overlay {
  position: fixed; inset: 0; z-index: 80; display: none; place-items: center; pointer-events: none;
  background: color-mix(in srgb, var(--accent) 12%, transparent); border: 3px dashed var(--accent);
}
#drop-overlay div { background: var(--panel); padding: 16px 24px; border-radius: 12px; box-shadow: var(--shadow-lg); font-weight: 600; font-size: 15px; }
body.drop #drop-overlay { display: grid; }
#analyze-overlay { position: fixed; inset: 0; z-index: 90; display: grid; place-items: center; background: rgba(15, 17, 21, .35); }
.analyze-card { background: var(--panel); border-radius: 14px; padding: 26px 30px; width: min(380px, calc(100vw - 32px)); box-shadow: var(--shadow-lg); text-align: center; }
#analyze-msg { font-weight: 600; margin: 12px 0; }
.progress { height: 6px; border-radius: 3px; background: var(--hover); overflow: hidden; }
#analyze-bar { height: 100%; width: 0; background: var(--accent); transition: width .2s; }
.eq { display: flex; justify-content: center; align-items: flex-end; gap: 4px; height: 28px; }
.eq i { width: 6px; border-radius: 3px; background: var(--accent); animation: eq 0.9s ease-in-out infinite; }
.eq i:nth-child(2) { animation-delay: .15s; background: #ef4444; }
.eq i:nth-child(3) { animation-delay: .3s; background: #10b981; }
.eq i:nth-child(4) { animation-delay: .45s; background: #8b5cf6; }
.eq i:nth-child(5) { animation-delay: .6s; background: #f59e0b; }
@keyframes eq { 0%, 100% { height: 6px; } 50% { height: 28px; } }

dialog { border: 0; border-radius: 14px; padding: 0; box-shadow: var(--shadow-lg); background: var(--panel); color: var(--text); width: min(560px, calc(100vw - 32px)); }
dialog::backdrop { background: rgba(15, 17, 21, .35); }
dialog form { padding: 22px 24px; }
dialog h3 { margin: 0 0 6px; font-size: 18px; }
dialog p { margin: 0 0 12px; }
dialog textarea { width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; background: var(--panel); color: var(--text); resize: vertical; outline: none; }
dialog textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
#structure-preview { margin: 10px 0; min-height: 22px; }
.dlg-opts { display: flex; gap: 18px; margin: 8px 0; }
.dlg-btns { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

/* ---------- narrow screens ---------- */
@media (max-width: 900px) {
  #sidebar { position: fixed; z-index: 40; top: 0; bottom: 0; left: 0; box-shadow: var(--shadow-lg); }
  #inspector { position: fixed; z-index: 40; top: 0; bottom: 0; right: 0; box-shadow: var(--shadow-lg); }
  .title-input { width: 16ch; font-size: 16px; }
  .field:not(.zoom) { display: none; }
  #time-readout span { display: none; }
}
