*,
*::before,
*::after { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 ui-sans-serif, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font: inherit; color: inherit; }

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

.muted { color: var(--muted); }
.small { font-size: 12px; }
.spacer { flex: 1; }

/* ---------- layout ---------- */

.app {
  display: grid;
  grid-template-columns: 60px 1fr;
  min-height: 100vh;
  min-height: 100dvh;
}

.frame { display: flex; flex-direction: column; min-width: 0; }

.content { padding: 16px 20px 40px; min-width: 0; }

/* ---------- rail ---------- */

.rail {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 12px 0;
  background: var(--surface);
  border-right: 1px solid var(--line);
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100dvh;
}

.rail-mark {
  width: 32px; height: 32px; margin-bottom: 10px;
  display: grid; place-items: center;
  border-radius: 8px;
  background: var(--accent);
  color: var(--accent-ink);
}
.rail-mark svg { width: 18px; height: 18px; }

.rail-gap { flex: 1; }

.rail-btn {
  width: 44px; height: 44px;
  display: grid; place-items: center;
  border: 0; border-radius: 9px;
  background: transparent; color: var(--muted);
  cursor: pointer;
  position: relative;
}
.rail-btn svg { width: 20px; height: 20px; }
.rail-btn:hover { background: var(--raised); color: var(--text); }
.rail-btn.active { background: var(--accent-dim); color: var(--accent); }
.rail-label { display: none; }

/* ---------- topbar ---------- */

.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}

.brand { font-size: 13px; letter-spacing: 0.06em; white-space: nowrap; }
.brand b { font-weight: 700; }
.brand span { color: var(--accent); }

/* identity — logo plus whose desk this is */
.ident { display: flex; align-items: center; gap: 10px; flex: none; }
.ident-mark {
  display: grid; place-items: center; flex: none;
  width: 34px; height: 34px; border-radius: 8px;
  background: var(--accent); color: var(--accent-ink);
}
.ident-mark svg { width: 19px; height: 19px; }
.ident-text { display: grid; gap: 1px; min-width: 0; }
.ident-role {
  font-size: 9px; font-weight: 700; letter-spacing: 0.14em;
  text-transform: uppercase; color: var(--muted);
}
/* The composer's full name is the headline of the whole app — sized to be read
   at a glance and never truncated, since a clipped credit is worse than none. */
.ident-name {
  font-size: clamp(17px, 1.7vw, 23px); font-weight: 700; letter-spacing: 0.01em;
  line-height: 1.1; text-transform: uppercase; white-space: nowrap;
}
.ident-name.unset {
  color: var(--accent); text-transform: none; font-weight: 600;
  font-size: 13px; text-decoration: none;
}

.ident.lg { align-self: flex-start; }
.ident.lg .ident-mark { width: 48px; height: 48px; border-radius: 10px; }
.ident.lg .ident-mark svg { width: 26px; height: 26px; }
.ident.lg .ident-name { font-size: clamp(19px, 2vw, 26px); }

/* The name gets the room it needs; the project block yields first. */
.ident-mark { align-self: center; }
.topbar .ident { margin-right: 4px; }
.topbar-project h1 { font-size: 14px; font-weight: 500; color: var(--soft); }

/* project hero */
.proj-hero {
  display: flex; align-items: center; gap: 18px; flex-wrap: wrap;
  padding: 22px 24px; background: var(--panel);
  border: 1px solid var(--line); border-radius: var(--radius);
}
.proj-art {
  width: 92px; height: 92px; flex: none; object-fit: cover;
  border-radius: var(--radius-sm); border: 1px solid var(--line);
}
.proj-hero-body { flex: 1; min-width: 220px; }
.proj-title {
  margin: 0 0 4px; font-size: clamp(24px, 4.2vw, 40px); line-height: 1.05;
  letter-spacing: -0.01em; text-transform: uppercase; font-weight: 700;
}
.proj-credit { margin: 0 0 6px; display: flex; align-items: baseline; gap: 8px; }
.proj-credit-label {
  font-size: 10px; font-weight: 700; letter-spacing: 0.14em;
  text-transform: uppercase; color: var(--muted);
}
.proj-credit b { font-size: 15px; }

.topbar-project { flex: 1; min-width: 0; }
.topbar-project h1 {
  margin: 0; font-size: 15px; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.meta {
  margin: 2px 0 0; display: flex; align-items: center; gap: 8px;
  color: var(--muted); font-size: 12px; flex-wrap: wrap;
}
.dot { width: 3px; height: 3px; border-radius: 50%; background: currentColor; opacity: 0.5; }

.progress {
  margin-top: 6px; height: 3px; border-radius: 2px;
  background: var(--line); overflow: hidden; max-width: 280px;
}
.progress span { display: block; height: 100%; background: var(--green); }

/* ---------- toolbar ---------- */

.toolbar {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 20px;
  border-bottom: 1px solid var(--line-soft);
  background: var(--bg);
  flex-wrap: wrap;
}

.view-picker select,
.search input,
.form-grid input,
.form-grid select,
.form-grid textarea {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 7px 10px;
  color: var(--text);
}

.search { position: relative; display: flex; align-items: center; flex: 1; max-width: 320px; }
.search svg { position: absolute; left: 9px; width: 15px; height: 15px; color: var(--muted); }
.search input { width: 100%; padding-left: 30px; }

/* ---------- buttons ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid transparent; border-radius: var(--radius-sm);
  padding: 8px 13px; cursor: pointer; white-space: nowrap;
  background: var(--raised); color: var(--text);
}
.btn svg { width: 15px; height: 15px; }
.btn:hover { border-color: var(--line); }
.btn.primary { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn.ghost { background: transparent; border-color: var(--line); color: var(--soft); }
.btn.danger { background: transparent; border-color: var(--line); color: var(--red); }
.btn.sm { padding: 5px 9px; font-size: 12px; }

.icon-btn {
  display: grid; place-items: center;
  width: 34px; height: 34px; border: 0; border-radius: 8px;
  background: transparent; color: var(--soft); cursor: pointer;
}
.icon-btn:hover { background: var(--raised); }
.icon-btn svg { width: 18px; height: 18px; }

.only-mobile { display: none; }

/* ---------- timeline ---------- */

.timeline {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 8px 10px 12px;
  margin-bottom: 14px;
}

.ruler {
  display: flex; justify-content: space-between;
  font-size: 10px; color: var(--muted);
  border-bottom: 1px solid var(--line-soft);
  padding-bottom: 5px; margin-bottom: 8px;
}

.track { position: relative; height: 40px; }
.timeline.compact .track { height: 26px; }

.block {
  position: absolute; top: 0; bottom: 0;
  border: 0; border-radius: 4px; cursor: pointer;
  background: var(--st, var(--slate));
  color: #08111c;
  font-size: 10px; font-weight: 600;
  overflow: hidden; padding: 0 4px;
  display: flex; align-items: center;
}
.block:hover { outline: 2px solid var(--text); }
.timeline.compact .block span { display: none; }

.empty-inline { color: var(--muted); font-size: 12px; margin: 6px 0 0; }

/* ---------- picture stage ---------- */

.stage {
  display: grid; gap: 10px; margin-bottom: 14px;
  grid-template-columns: minmax(0, 1.35fr) minmax(280px, 0.9fr) 150px;
}

/* linked-picture bar — stated loudly, because nothing is uploaded and this
   reference is the only record of which cut a mark belongs to */
.pic-bar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 9px 14px; margin-bottom: 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-left: 3px solid var(--green);
  border-radius: var(--radius);
  font-size: 12px;
}
/* Named 'unlinked', not 'empty' — .empty is the grid's no-rows state and would
   otherwise turn this row into a tall centred panel. */
.pic-bar.unlinked { border-left-color: var(--muted); }

.pic-dot {
  width: 8px; height: 8px; border-radius: 50%; flex: none;
  background: var(--green); box-shadow: 0 0 0 3px color-mix(in srgb, var(--green) 22%, transparent);
}
.pic-dot.off { background: var(--muted); box-shadow: none; }

.pic-name {
  font-weight: 600; font-size: 13px;
  max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.pic-meta { color: var(--muted); }
.pic-meta code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  background: var(--raised); padding: 1px 5px; border-radius: 3px;
}
.pic-local {
  color: var(--green); border: 1px solid color-mix(in srgb, var(--green) 45%, transparent);
  background: color-mix(in srgb, var(--green) 12%, transparent);
  border-radius: 999px; padding: 2px 9px; font-size: 11px; white-space: nowrap;
}
.pic-warn {
  color: var(--amber); border: 1px solid color-mix(in srgb, var(--amber) 50%, transparent);
  background: color-mix(in srgb, var(--amber) 12%, transparent);
  border-radius: 999px; padding: 2px 10px; white-space: nowrap;
}

.thumb-wrap { position: relative; display: inline-block; }
.thumb-drift {
  position: absolute; top: -4px; right: -4px;
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--amber); color: #1a1205;
  font-size: 10px; display: grid; place-items: center; cursor: help;
}

/* spotting panel */
.spotter {
  display: flex; flex-direction: column; gap: 12px;
  padding: 14px; background: var(--panel);
  border: 1px solid var(--line); border-radius: var(--radius);
}
.spotter.idle { opacity: 0.55; }

.spot-steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.spot-steps li { display: flex; align-items: center; gap: 9px; }

.mark-btn {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--raised); color: var(--text);
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 8px 12px; cursor: pointer; min-height: 38px;
}
.mark-btn:hover:not([disabled]) { border-color: var(--accent); color: var(--accent); }
.mark-btn[disabled] { opacity: 0.45; cursor: not-allowed; }
.mark-glyph {
  display: grid; place-items: center;
  width: 18px; height: 18px; border-radius: 3px;
  background: var(--text); color: var(--panel); font-weight: 700; line-height: 1;
}
.spot-steps li.done .mark-btn { border-color: var(--green); color: var(--green); }
.mark-tc {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px; color: var(--muted);
}
.spot-steps li.done .mark-tc { color: var(--text); }

.cue-name {
  width: 100%; background: var(--raised); color: var(--text);
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 9px 12px; font-size: 17px; letter-spacing: 0.06em;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.cue-name::placeholder { color: var(--muted); letter-spacing: 0.1em; }

.snap { display: flex; gap: 10px; align-items: flex-start; }
.snap-preview {
  width: 148px; aspect-ratio: 16 / 9; flex: none;
  background: #05080d; border: 1px dashed var(--line); border-radius: var(--radius-sm);
  display: grid; place-items: center; overflow: hidden;
}
.snap-preview img { width: 100%; height: 100%; object-fit: cover; }
.snap-actions { display: grid; gap: 6px; }

.spot-commit {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  border-top: 1px solid var(--line); padding-top: 10px; margin-top: auto;
}
.spot-commit .btn[disabled] { opacity: 0.45; cursor: not-allowed; }

.transport { display: flex; gap: 4px; }
.icon-btn.sm { width: 28px; height: 28px; border: 1px solid var(--line); }
.icon-btn.sm[disabled] { opacity: 0.4; cursor: not-allowed; }
.file-name {
  max-width: 130px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.stage-frame {
  position: relative; aspect-ratio: 16 / 9; max-height: 46vh;
  background: #05080d; border: 1px solid var(--line);
  border-radius: var(--radius); overflow: hidden;
  display: grid; place-items: center;
}
.stage-video { width: 100%; height: 100%; object-fit: contain; }
.stage-empty { text-align: center; padding: 20px; display: grid; gap: 8px; justify-items: center; }
.stage-empty p { margin: 0; }
.stage-readout {
  display: flex; flex-direction: column; justify-content: center; align-items: center;
  gap: 2px; background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius);
}
.tc-big { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 17px; }

/* ---------- grid ---------- */

.grid-scroll {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
}

.grid { width: 100%; border-collapse: collapse; min-width: 760px; }

.grid th {
  text-align: left; font-size: 11px; font-weight: 600;
  letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted);
  padding: 9px 10px; background: var(--surface);
  border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5;
}

.grid td {
  padding: 6px 10px; border-bottom: 1px solid var(--line-soft);
  vertical-align: middle;
}
.grid tbody tr:hover { background: var(--raised); }

.cue-no {
  display: inline-block; font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px; font-weight: 600; padding: 2px 7px; border-radius: 4px;
  background: color-mix(in srgb, var(--st, var(--slate)) 20%, transparent);
  color: var(--st, var(--slate));
  border: 1px solid color-mix(in srgb, var(--st, var(--slate)) 40%, transparent);
}

.pill {
  display: inline-block; font-size: 11px; font-weight: 600;
  padding: 3px 9px; border-radius: 999px;
  background: color-mix(in srgb, var(--st, var(--slate)) 18%, transparent);
  color: var(--st, var(--slate));
}

.thumb {
  width: 84px; height: 47px; border-radius: 4px; object-fit: cover;
  background: #05080d; border: 1px solid var(--line); display: block;
}
.thumb-empty {
  color: var(--muted); font-size: 11px; cursor: pointer;
  display: grid; place-items: center;
}
.thumb-empty:hover { border-color: var(--accent); color: var(--accent); }

.cell-edit {
  display: block; width: 100%; text-align: left;
  background: transparent; border: 1px solid transparent; border-radius: 5px;
  padding: 3px 5px; cursor: text; color: inherit;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.cell-edit:hover { border-color: var(--line); background: var(--surface); }
.cell-edit.tc { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }

.tc-pair { display: flex; flex-direction: column; gap: 1px; }

.inline-control {
  width: 100%; background: var(--raised); color: var(--text);
  border: 1px solid var(--accent); border-radius: 5px; padding: 3px 5px;
}
.inline-control.tc { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
.inline-area { min-height: 56px; resize: vertical; }

.row-actions { text-align: right; }

.empty {
  display: grid; gap: 12px; justify-items: center;
  padding: 60px 20px; color: var(--muted);
  border: 1px dashed var(--line); border-radius: var(--radius);
}
.empty p { margin: 0; }

/* ---------- cue cell, revisions ---------- */

.cue-cell { display: flex; align-items: center; gap: 5px; }

.disclose {
  width: 18px; height: 18px; flex: none; padding: 0;
  border: 0; border-radius: 4px; cursor: pointer;
  background: transparent; color: var(--muted);
  font-size: 11px; line-height: 1;
  transform: rotate(-90deg); transition: transform 0.15s ease;
}
.disclose:hover { background: var(--raised); color: var(--text); }
.disclose.open { transform: rotate(0deg); color: var(--accent); }
.disclose-spacer { width: 18px; flex: none; }

.cue-ver { font-size: 10px; color: var(--muted); }
.cue-ver.old { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11px; }

.rev-row { background: var(--surface); }
.rev-row td { border-bottom: 1px solid var(--line-soft); padding-top: 4px; padding-bottom: 4px; }
.rev-gutter { position: relative; white-space: nowrap; padding-left: 26px !important; }
.rev-line {
  position: absolute; left: 12px; top: 0; bottom: 0;
  width: 1px; background: var(--line);
}
.rev-body {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  font-size: 12px; color: var(--muted);
}
.rev-when { color: var(--soft); }
.rev-tc, .rev-len { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.rev-desc { flex: 1; min-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rev-tag {
  font-size: 10px; text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--accent); border: 1px solid var(--accent);
  border-radius: 999px; padding: 1px 7px;
}

/* ---------- revision column ---------- */

.rev-cell {
  display: block; width: 100%; text-align: left; cursor: pointer;
  background: transparent; border: 1px solid transparent;
  border-radius: 5px; padding: 3px 5px; color: inherit;
}
.rev-cell:hover { border-color: var(--line); background: var(--surface); }
.rev-head { display: flex; align-items: center; gap: 7px; }
.rev-n { font-size: 10px; color: var(--accent); }
.rev-n.muted { color: var(--muted); }
.rev-note {
  display: block; font-size: 12px; margin-top: 2px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.rev-note.muted { color: var(--muted); }
.rev-desc.strong { color: var(--text); }

.ver-chip {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px; font-weight: 600; padding: 2px 7px; border-radius: 4px;
  background: var(--accent-dim); color: var(--accent);
  border: 1px solid color-mix(in srgb, var(--accent) 40%, transparent);
}
.ver-chip.big { font-size: 15px; padding: 6px 12px; }

.rev-current {
  display: flex; align-items: center; gap: 14px;
  padding: 12px 14px; margin-bottom: 16px;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
}
.rev-current p { margin: 2px 0 0; }
.rev-entry { border-left-color: var(--accent); }

/* ---------- spotting notes ---------- */

.spot, .spot-add {
  display: block; width: 100%; text-align: left; cursor: pointer;
  background: transparent; border: 1px solid transparent;
  border-radius: 5px; padding: 3px 5px; color: inherit;
}
.spot:hover, .spot-add:hover { border-color: var(--line); background: var(--surface); }
.spot-add { color: var(--muted); font-size: 12px; }
.spot-add:hover { color: var(--accent); border-color: var(--accent); }

.spot-line {
  display: flex; gap: 6px; align-items: baseline;
  font-size: 12px; line-height: 1.35;
}
.spot-line + .spot-line { margin-top: 3px; }
.spot-who {
  flex: none; font-size: 9px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.05em;
  border-radius: 3px; padding: 1px 4px; margin-top: 1px;
}
.spot-line.side-production .spot-who {
  color: var(--blue); background: color-mix(in srgb, var(--blue) 16%, transparent);
}
.spot-line.side-composer .spot-who {
  color: var(--brass); background: color-mix(in srgb, var(--brass) 18%, transparent);
}
.spot-body { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.spot-count { display: block; font-size: 10px; color: var(--muted); margin-top: 3px; }

.notes-list { list-style: none; margin: 0 0 18px; padding: 0; display: grid; gap: 10px; }
.note {
  border: 1px solid var(--line); border-left: 3px solid var(--slate);
  border-radius: var(--radius-sm); padding: 10px 12px; background: var(--panel);
}
.note.side-production { border-left-color: var(--blue); }
.note.side-composer { border-left-color: var(--brass); }
.note-head {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  font-size: 12px; margin-bottom: 5px;
}
.note-tc { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--accent); }
.note-side {
  font-size: 10px; text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: 1px 7px;
}
.note-date { color: var(--muted); }
.note p { margin: 0; font-size: 13px; }

.note-form { display: grid; gap: 10px; border-top: 1px solid var(--line); padding-top: 14px; }
.note-form label { display: grid; gap: 5px; font-size: 12px; color: var(--muted); }
.note-form-row { display: grid; grid-template-columns: 150px 140px 1fr; gap: 10px; }
.note-form input, .note-form select, .note-form textarea {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 8px 10px; color: var(--text); width: 100%;
}
.note-form textarea { resize: vertical; font-family: inherit; }
.note-form input.tc { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }

/* ---------- panels, cards, tiles ---------- */

.stack { display: grid; gap: 14px; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.section-head h2 { margin: 0; font-size: 17px; }

.panel {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px;
}
.panel h3 { margin: 0 0 10px; font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }
.tile {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px; display: grid; gap: 2px;
}
.tile-num { font-size: 24px; font-weight: 600; }
.tile-label { font-size: 12px; color: var(--muted); }

.chips { display: flex; flex-wrap: wrap; gap: 7px; }
.chip {
  display: inline-flex; align-items: center; gap: 7px;
  background: var(--raised); border: 1px solid var(--line);
  border-radius: 999px; padding: 5px 11px; font-size: 12px;
}
.chip b { color: var(--muted); }
.swatch { width: 8px; height: 8px; border-radius: 50%; background: var(--st, var(--slate)); }

.cards { display: grid; gap: 10px; }
.card {
  display: flex; align-items: center; gap: 14px;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 12px 14px;
}
.card.active { border-color: var(--accent); }
.card-art {
  width: 54px; height: 54px; flex: none; border-radius: 7px;
  background: var(--raised); display: grid; place-items: center; color: var(--muted);
}
.card-art svg { width: 22px; height: 22px; }
.card-body { flex: 1; min-width: 0; }
.card-body h2 { margin: 0; font-size: 15px; display: flex; align-items: center; gap: 8px; }

/* A label, not a control — square-ish, quiet, and never mistaken for a button. */
.tag-current {
  font-size: 10px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--green); background: color-mix(in srgb, var(--green) 14%, transparent);
  border: 1px solid color-mix(in srgb, var(--green) 40%, transparent);
  border-radius: 4px; padding: 2px 6px;
}

.card-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.card-actions .btn { min-height: 34px; border-radius: var(--radius-sm); }

/* Reads as state rather than an invitation, but still takes you to the cues. */
.btn.open-already {
  background: transparent; color: var(--green);
  border-color: color-mix(in srgb, var(--green) 45%, transparent);
  font-weight: 600;
}
.btn.open-already:hover {
  background: color-mix(in srgb, var(--green) 12%, transparent);
  border-color: var(--green);
}

.row-btns { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- forms ---------- */

.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
.form-grid label { display: grid; gap: 5px; font-size: 12px; color: var(--muted); }
.form-grid label.wide { grid-column: 1 / -1; }
.form-grid input, .form-grid select, .form-grid textarea { color: var(--text); }
.form-grid textarea { resize: vertical; font-family: inherit; }

/* ---------- modal ---------- */

.backdrop {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(4, 8, 14, 0.6);
  display: grid; place-items: center; padding: 16px;
}
.modal {
  width: min(760px, 100%); max-height: 88vh; display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.modal-head, .modal-foot {
  display: flex; align-items: center; gap: 8px; padding: 12px 16px;
}
.modal-head { border-bottom: 1px solid var(--line); }
.modal-head h2 { margin: 0; font-size: 15px; }
.modal-foot { border-top: 1px solid var(--line); }
.modal-body { padding: 16px; overflow: auto; }

/* ---------- toast ---------- */

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: var(--raised); border: 1px solid var(--line);
  border-radius: 999px; padding: 9px 18px; box-shadow: var(--shadow); z-index: 80;
}

/* ---------- responsive ---------- */

@media (max-width: 1100px) {
  .stage { grid-template-columns: minmax(0, 1fr) minmax(260px, 0.85fr); }
  .stage-readout {
    grid-column: 1 / -1; flex-direction: row; flex-wrap: wrap;
    gap: 10px; padding: 8px 12px;
  }
}

@media (max-width: 760px) {
  .stage { grid-template-columns: 1fr; }
  .snap-preview { width: 118px; }
}

@media (max-width: 780px) {
  .app { grid-template-columns: 1fr; }

  /* Rail becomes a bottom tab bar; thumb-reachable and out of the way. */
  .rail {
    position: fixed; bottom: 0; left: 0; right: 0; top: auto;
    height: auto; flex-direction: row; justify-content: space-around;
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
    border-right: 0; border-top: 1px solid var(--line); z-index: 40;
  }
  .rail-mark { display: none; }
  .rail-gap { display: none; }
  .rail-btn { width: 56px; height: 46px; gap: 2px; flex-direction: column; }
  .rail-btn svg { width: 19px; height: 19px; }
  .rail-label { display: block; font-size: 9px; line-height: 1; }

  .frame { padding-bottom: 76px; }
  .content { padding: 12px 12px 32px; }
  .topbar { padding: 10px 12px; gap: 10px; flex-wrap: wrap; }
  .brand { display: none; }
  /* Keep the mark and the full name — identity is the point of it. The name
     wraps rather than clipping if it genuinely cannot fit on one line. */
  .ident-mark { width: 32px; height: 32px; }
  .ident-name { font-size: 16px; white-space: normal; }
  .ident-role { font-size: 8px; }
  .proj-hero { padding: 16px; gap: 14px; }
  .proj-art { width: 64px; height: 64px; }
  .ident.lg .ident-mark { width: 38px; height: 38px; }
  .ident.lg .ident-name { font-size: 15px; }
  .only-mobile { display: grid; }
  .toolbar { padding: 10px 12px; }
  .search { max-width: none; }

  /* Table collapses into one card per cue. */
  .grid-scroll { border: 0; background: transparent; overflow: visible; }
  .grid { min-width: 0; }
  .grid thead { display: none; }
  .grid tbody, .grid tr, .grid td { display: block; }
  .grid tr {
    background: var(--panel); border: 1px solid var(--line);
    border-radius: var(--radius); padding: 10px 12px; margin-bottom: 10px;
  }
  .grid td {
    display: flex; align-items: center; justify-content: space-between;
    gap: 12px; padding: 5px 0; border-bottom: 0; text-align: right;
  }
  .grid td::before {
    content: attr(data-label);
    font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em;
    color: var(--muted); flex: none; text-align: left;
  }
  .grid td:empty, .grid td[data-label=""]::before { display: none; }
  .cell-edit { text-align: right; width: auto; min-width: 0; }
  .tc-pair { align-items: flex-end; }
  .inline-control { width: auto; min-width: 140px; }
  .row-actions { justify-content: flex-end; padding-top: 8px; }

  /* Revision rows sit under their cue as an indented strip rather than a card. */
  .grid tr.rev-row {
    margin: -8px 0 10px; border-top: 0;
    border-top-left-radius: 0; border-top-right-radius: 0;
    padding: 8px 12px; background: var(--surface);
  }
  .grid tr.rev-row td { display: block; text-align: left; padding: 2px 0; }
  .grid tr.rev-row td::before { display: none; }
  .rev-gutter { padding-left: 0 !important; }
  .rev-line { display: none; }
  .rev-body { font-size: 11px; }
  .rev-desc { white-space: normal; }

  .spot, .spot-add { text-align: right; }
  .spot-line { justify-content: flex-end; }
  .spot-body { white-space: normal; }

  .note-form-row { grid-template-columns: 1fr; }

  .modal { max-height: 92vh; }
  .modal-foot { flex-wrap: wrap; }
}

@media (max-width: 420px) {
  .form-grid { grid-template-columns: 1fr; }
  .card { flex-wrap: wrap; }
  .rail-label { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
