/* Shelf Portrait Sessions: a studio track sheet. Mobile first. */

:root {
  --bg: #e7ebef;
  --bg-2: #dde3e8;
  --card: #ffffff;
  --ink: #12161b;
  --ink-2: #39424c;
  --muted: #5f6a76;
  --line: #cfd6dd;
  --line-2: #e3e8ec;
  --rec: #e0261b;
  --rec-soft: #fdeceb;
  --amber: #f0a81c;
  --amber-ink: #8a5800;
  --amber-soft: #fff5de;
  --on-amber: #2a1c00;
  --ok: #1d7f47;
  --focus: #2462d6;
  --meter-lo: #23a35a;
  --shadow: 0 1px 2px rgba(18, 22, 27, .05), 0 6px 18px rgba(18, 22, 27, .05);
  --radius: 16px;
  --f-head: 'Bricolage Grotesque', ui-sans-serif, system-ui, -apple-system, sans-serif;
  --f-body: 'Atkinson Hyperlegible', ui-sans-serif, system-ui, -apple-system, sans-serif;
  --f-mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d1013;
    --bg-2: #1b2026;
    --card: #161a1f;
    --ink: #edf0f3;
    --ink-2: #c2c9d1;
    --muted: #8e99a5;
    --line: #2d343c;
    --line-2: #232930;
    --rec: #ff4b3e;
    --rec-soft: #3a1513;
    --amber: #f5b937;
    --amber-ink: #f5b937;
    --amber-soft: #2e230b;
    --on-amber: #241700;
    --ok: #4fcf86;
    --focus: #79a8ff;
    --meter-lo: #3cc775;
    --shadow: none;
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 400 17px/1.45 var(--f-body);
  -webkit-font-smoothing: antialiased; overflow-x: hidden;
}
h1, h2 { font-family: var(--f-head); margin: 0; }
p { margin: 0; }
a { color: inherit; }
button, input, textarea { font: inherit; color: inherit; }
button { -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 8px; }
.mono { font-family: var(--f-mono); font-variant-numeric: tabular-nums; }
.label {
  font: 500 11px/1.2 var(--f-mono); letter-spacing: .12em; text-transform: uppercase; color: var(--muted);
}

.page {
  max-width: 760px; margin: 0 auto;
  padding: max(18px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) 0 max(16px, env(safe-area-inset-left));
}
.card {
  background: var(--card); border: 1px solid var(--line-2); border-radius: var(--radius); box-shadow: var(--shadow);
}

/* ---------- masthead */
.masthead { padding: 4px 2px 18px; }
.mast-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 44px; }
.masthead h1 {
  font-weight: 800; font-size: clamp(32px, 9vw, 46px); line-height: .98; letter-spacing: -.025em;
  font-variation-settings: 'opsz' 96; margin-top: 2px;
}
.sub { margin-top: 8px; color: var(--muted); font-size: 15px; }
.masthead .sub { font-style: italic; }
.btn-text {
  min-height: 44px; padding: 0 4px 0 14px; border: 0; background: none; cursor: pointer; white-space: nowrap;
  font: 500 12px/1 var(--f-mono); letter-spacing: .1em; text-transform: uppercase; color: var(--ink-2);
}
.notice {
  margin: 0 0 14px; padding: 12px 14px; border-radius: 12px; background: var(--rec-soft); color: var(--ink);
  border: 1px solid var(--rec); font-size: 15px;
}

/* ---------- buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 50px; padding: 0 18px; border: 0; border-radius: 12px; cursor: pointer;
  font: 700 16px/1.1 var(--f-body); text-decoration: none; white-space: nowrap;
}
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn-wide { width: 100%; }
.btn-ink { background: var(--ink); color: var(--card); }
.btn-line { background: transparent; color: var(--ink); box-shadow: inset 0 0 0 1.5px var(--line); }
.btn-rec { background: var(--rec); color: #fff; }
.btn-stop, .btn-stoprec { background: var(--ink); color: var(--card); }
.btn-stoprec { background: var(--rec); color: #fff; }
.ico { width: 20px; height: 20px; fill: currentColor; flex: none; }
.ico-s { width: 14px; height: 14px; flex: none; }
.btn-mini {
  min-height: 44px; padding: 0 14px; border-radius: 10px; border: 0; cursor: pointer;
  background: var(--bg-2); color: var(--ink); font: 700 15px/1 var(--f-body);
}
.btn-mini-ink { background: var(--ink); color: var(--card); }
.btn-danger { background: var(--rec); color: #fff; }
.icon-btn {
  width: 44px; height: 44px; flex: none; display: inline-grid; place-items: center; padding: 0;
  border: 0; border-radius: 50%; background: var(--ink); color: var(--card); cursor: pointer;
}
.icon-btn .i-pause { display: none; }
.is-playing .icon-btn.play .i-play, .dock.is-playing .i-play { display: none; }
.is-playing .icon-btn.play .i-pause, .dock.is-playing .i-pause { display: block; }

/* ---------- overview */
.overview { padding: 16px 16px 18px; }
.stats { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.35fr) minmax(0, 1fr); gap: 8px; }
.stat { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.stat + .stat { border-left: 1px solid var(--line-2); padding-left: 12px; }
.stat-v {
  font: 700 clamp(22px, 6.6vw, 30px)/1 var(--f-mono); font-variant-numeric: tabular-nums; letter-spacing: -.02em;
  white-space: nowrap;
}
.stat-v.is-long { font-size: clamp(18px, 5.2vw, 30px); } /* h:mm:ss on a 320 px phone */
.meter9 { display: grid; grid-template-columns: repeat(9, minmax(0, 1fr)); gap: 4px; margin-top: 18px; }
.seg {
  height: 46px; border: 0; padding: 0 0 6px; border-radius: 7px; min-width: 0;
  display: flex; align-items: flex-end; justify-content: center;
  font: 700 10px/1 var(--f-mono); color: var(--muted);
  background: transparent; box-shadow: inset 0 0 0 1.5px var(--line);
}
.seg[data-state="takes"] {
  color: var(--ink-2); box-shadow: inset 0 0 0 1.5px var(--line);
  background: repeating-linear-gradient(135deg, var(--line) 0 3px, transparent 3px 7px), var(--bg-2);
}
.seg[data-state="keeper"] { background: var(--amber); color: var(--on-amber); box-shadow: none; }
.seg[data-state="rec"] { background: var(--rec); color: #fff; box-shadow: none; animation: pulse 1.2s ease-in-out infinite; }
.seg.is-playing { outline: 2.5px solid var(--ink); outline-offset: 2px; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 10px; font: 500 11px/1.2 var(--f-mono); color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.sw { width: 14px; height: 10px; border-radius: 3px; display: inline-block; box-shadow: inset 0 0 0 1.5px var(--line); }
.sw-takes { background: repeating-linear-gradient(135deg, var(--line) 0 2px, transparent 2px 5px), var(--bg-2); }
.sw-keeper { background: var(--amber); box-shadow: none; }
.order { margin-top: 18px; }
.order-now { border-top: 1px dashed var(--line); padding-top: 14px; }
.order-top { display: flex; justify-content: space-between; gap: 8px; }
.order-title { display: flex; align-items: baseline; gap: 10px; margin: 8px 0 10px; font-weight: 700; min-width: 0; }
.order-title #order-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.order-trk { font: 800 20px/1 var(--f-head); white-space: nowrap; }
.order-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 12px; }
.live-dot {
  display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--ok); margin-right: 7px;
  vertical-align: 1px; animation: pulse 1.6s ease-in-out infinite;
}
.bar { height: 6px; border-radius: 3px; background: var(--line-2); overflow: hidden; }
.bar > i { display: block; height: 100%; width: 0; background: var(--ink); border-radius: 3px; transition: width .2s linear; }
.order .bar > i { transition: none; } /* would slide backwards at each new track */

/* ---------- tracks */
.tracks { list-style: none; margin: 16px 0 0; padding: 0; display: grid; gap: 14px; }
.track { position: relative; overflow: hidden; padding: 16px 16px 6px 20px; scroll-margin-top: 12px; }
.track::before { content: ''; position: absolute; inset: 0 auto 0 0; width: 5px; background: var(--line); }
.track[data-state="takes"]::before { background: var(--ink-2); }
.track[data-state="keeper"]::before { background: var(--amber); }
.track[data-state="rec"]::before { background: var(--rec); }
.track.is-playing { box-shadow: 0 0 0 2px var(--ink), var(--shadow); }

.trk-head { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 14px; align-items: start; }
.trk-num { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding-top: 2px; }
.trk-num .label { font-weight: 700; color: var(--ink-2); }
.num {
  font: 800 44px/.86 var(--f-head); letter-spacing: -.03em; font-variant-numeric: tabular-nums;
  font-variation-settings: 'opsz' 96;
}
.trk-title { min-width: 0; padding-top: 2px; }
.trk-title .title {
  font-weight: 700; font-size: 21px; line-height: 1.12; letter-spacing: -.01em; margin-top: 3px;
  overflow-wrap: anywhere; font-variation-settings: 'opsz' 28;
}
.trk-title .part:empty { display: none; }
.trk-title .part:empty + .title { margin-top: 6px; font-size: 26px; }
.byline { margin-top: 0; color: var(--ink-2); font-size: 15px; display: flex; flex-wrap: wrap; align-items: center; gap: 2px 12px; }
.byline:empty, .byline.is-empty { display: none; }
.book-link {
  display: inline-flex; align-items: center; gap: 4px; min-height: 44px; text-decoration: none;
  font: 500 12px/1 var(--f-mono); letter-spacing: .06em; text-transform: uppercase; color: var(--ink);
  padding: 0; text-decoration-line: underline; text-decoration-color: var(--amber); text-decoration-thickness: 2px;
  text-underline-offset: 4px;
}
.status {
  font: 700 11px/1 var(--f-mono); letter-spacing: .08em; text-transform: uppercase; white-space: nowrap;
  padding: 6px 8px; border-radius: 6px; color: var(--muted); box-shadow: inset 0 0 0 1px var(--line);
}
.track[data-state="takes"] .status { color: var(--ink-2); }
.track[data-state="keeper"] .status { background: var(--amber-soft); color: var(--amber-ink); box-shadow: inset 0 0 0 1px var(--amber); }
.track[data-state="rec"] .status { background: var(--rec); color: #fff; box-shadow: none; }

.prompt {
  margin: 14px 0 0; padding: 2px 0 2px 12px; border-left: 2px solid var(--line);
  color: var(--ink-2); font-size: 15px; line-height: 1.45;
}

.controls { margin-top: 14px; }
.idle { display: flex; gap: 10px; }
.idle .btn-rec { flex: 1 1 58%; }
.idle .btn-line { flex: 1 1 42%; padding: 0 12px; }
.rec-dot { width: 12px; height: 12px; border-radius: 50%; background: currentColor; display: inline-block; flex: none; }
.btn-rec .rec-dot { background: #fff; box-shadow: 0 0 0 3px rgba(255, 255, 255, .28); }

.live { border-radius: 12px; background: var(--rec-soft); padding: 12px; }
.live-row { display: flex; align-items: center; justify-content: space-between; }
.rec-badge { display: inline-flex; align-items: center; gap: 8px; font: 700 13px/1 var(--f-mono); letter-spacing: .14em; color: var(--rec); }
.rec-badge .rec-dot { animation: pulse 1s ease-in-out infinite; }
.rec-time { font: 700 34px/1 var(--f-mono); font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.level {
  position: relative; height: 16px; margin: 12px 0; border-radius: 4px; overflow: hidden; background: var(--line-2);
}
.level-fill {
  position: absolute; inset: 0; clip-path: inset(0 100% 0 0);
  background: linear-gradient(90deg, var(--meter-lo) 0 62%, var(--amber) 62% 84%, var(--rec) 84% 100%);
}
.level::after { /* LED segments */
  content: ''; position: absolute; inset: 0;
  background: repeating-linear-gradient(90deg, transparent 0 9px, var(--rec-soft) 9px 11px);
}
.level-peak { position: absolute; top: 0; bottom: 0; width: 3px; left: 0; background: var(--ink); opacity: .7; z-index: 1; }
.live-actions { display: flex; gap: 10px; }
.live-actions .btn-stoprec { flex: 1 1 auto; }
.sq { width: 14px; height: 14px; border-radius: 2px; background: #fff; display: inline-block; }

.busy { border-radius: 12px; background: var(--bg); padding: 12px; }
.busy-row { display: flex; justify-content: space-between; gap: 10px; margin-bottom: 10px; font-size: 15px; font-weight: 700; }
.busy-label { min-width: 0; overflow-wrap: anywhere; }
.busy-pct { font-size: 13px; color: var(--ink-2); white-space: nowrap; }
.busy-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.busy.is-failed .bar { display: none; }
.busy.is-failed .busy-label { color: var(--rec); }

.msg { font-size: 15px; margin-top: 10px; color: var(--ink-2); }
.msg:empty { display: none; }
.msg.is-error, .msg-error { color: var(--rec); }
.msg.is-ok { color: var(--ok); }

/* ---------- takes */
.takes { list-style: none; margin: 14px 0 0; padding: 0; border-top: 1px solid var(--line-2); }
.take { padding: 10px 0 10px; border-bottom: 1px solid var(--line-2); }
.take:last-child { border-bottom: 0; }
.take-top { display: grid; grid-template-columns: 44px minmax(0, 1fr) auto auto; align-items: center; gap: 4px; }
.star {
  width: 44px; height: 44px; display: grid; place-items: center; padding: 0; border: 0; background: none; cursor: pointer;
  margin-left: -6px;
}
.star svg { width: 26px; height: 26px; fill: none; stroke: var(--muted); stroke-width: 1.6; stroke-linejoin: round; }
.star[aria-pressed="true"] svg { fill: var(--amber); stroke: var(--amber); }
.take-name { min-width: 0; display: flex; flex-direction: column; gap: 3px; padding-left: 2px; }
.take-n { font: 700 17px/1.1 var(--f-head); }
.take.is-keeper .take-n::after {
  content: 'Keeper'; margin-left: 8px; font: 700 10px/1 var(--f-mono); letter-spacing: .1em; text-transform: uppercase;
  color: var(--amber-ink); vertical-align: 2px;
}
.take-meta { display: flex; flex-wrap: wrap; gap: 0 8px; font: 500 12px/1.3 var(--f-mono); color: var(--muted); font-variant-numeric: tabular-nums; }
.take-len { color: var(--ink-2); font-weight: 700; }
.act {
  min-height: 44px; display: inline-flex; align-items: center; padding: 0 8px; border: 0; background: none; cursor: pointer;
  font: 500 12px/1 var(--f-mono); letter-spacing: .04em; color: var(--ink-2); text-decoration: none; white-space: nowrap;
}
.act-del { color: var(--rec); }
.take-play { display: grid; grid-template-columns: 44px minmax(0, 1fr) auto; align-items: center; gap: 10px; margin-top: 4px; }
.take-play .icon-btn { background: var(--bg-2); color: var(--ink); }
.take.is-active .take-play .icon-btn { background: var(--ink); color: var(--card); }
.ptime { font: 500 12px/1 var(--f-mono); color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.take.is-active .ptime { color: var(--ink); }
.confirm {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 8px; padding: 8px 8px 8px 12px;
  border-radius: 12px; background: var(--rec-soft);
}
.confirm-q { font-weight: 700; margin-right: auto; }

.scrub {
  -webkit-appearance: none; appearance: none; width: 100%; height: 44px; margin: 0; background: transparent; cursor: pointer;
  --p: 0%;
}
.scrub::-webkit-slider-runnable-track {
  height: 6px; border-radius: 3px; background: linear-gradient(90deg, var(--ink) var(--p), var(--line) var(--p));
}
.scrub::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none; width: 20px; height: 20px; margin-top: -7px; border-radius: 50%;
  background: var(--ink); border: 3px solid var(--card); box-shadow: 0 0 0 1px var(--line);
}
.scrub::-moz-range-track { height: 6px; border-radius: 3px; background: var(--line); }
.scrub::-moz-range-progress { height: 6px; border-radius: 3px; background: var(--ink); }
.scrub::-moz-range-thumb { width: 16px; height: 16px; border-radius: 50%; background: var(--ink); border: 3px solid var(--card); }
.take:not(.is-active) .scrub::-webkit-slider-thumb { background: var(--muted); }

/* ---------- notes */
.notes { margin: 8px 0 0; border-top: 1px solid var(--line-2); }
.notes summary {
  list-style: none; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  min-height: 48px; cursor: pointer; font-weight: 700; font-size: 15px;
}
.notes summary::-webkit-details-marker { display: none; }
.notes-h::before {
  content: ''; display: inline-block; width: 8px; height: 8px; margin-right: 10px; vertical-align: 2px;
  border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(-45deg);
  transition: transform .15s;
}
.notes[open] .notes-h::before { transform: rotate(45deg); }
.notes-state { font: 500 11px/1 var(--f-mono); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.notes textarea {
  display: block; width: 100%; margin: 0 0 12px; padding: 12px; resize: vertical; min-height: 140px;
  border: 1.5px solid var(--line); border-radius: 12px; background: var(--bg); color: var(--ink);
  font: 400 16px/1.5 var(--f-body);
}
.notes textarea:focus { outline: none; border-color: var(--ink-2); }

/* ---------- footer, dock, toast */
.foot {
  padding: 26px 4px calc(28px + env(safe-area-inset-bottom)); text-align: center; color: var(--muted); font-size: 13px;
}
body.has-dock .foot { padding-bottom: calc(110px + env(safe-area-inset-bottom)); }
.dock {
  position: fixed; z-index: 10; left: 50%; transform: translateX(-50%);
  bottom: calc(10px + env(safe-area-inset-bottom)); width: min(728px, calc(100% - 20px));
  display: flex; align-items: center; gap: 10px; padding: 10px 10px 10px 16px;
  background: var(--ink); color: var(--card); border-radius: 18px; box-shadow: 0 10px 30px rgba(0, 0, 0, .25);
}
.dock-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.dock .label { color: var(--card); opacity: .8; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dock .mono { font-size: 15px; font-weight: 700; }
.dock .icon-btn { background: var(--card); color: var(--ink); }
.dock .i-pause { display: none; }
.toast {
  position: fixed; z-index: 20; left: 50%; transform: translateX(-50%); top: calc(12px + env(safe-area-inset-top));
  width: min(560px, calc(100% - 24px)); padding: 12px 16px; border-radius: 12px;
  background: var(--ink); color: var(--card); font-size: 15px; box-shadow: 0 10px 30px rgba(0, 0, 0, .25);
}

/* ---------- login */
.login-page { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding-bottom: 24px; }
.login-card { width: 100%; max-width: 420px; padding: 22px 20px 20px; }
.login-card h1 { font-weight: 800; font-size: 40px; line-height: 1; letter-spacing: -.025em; margin-top: 6px; }
.login-strip { display: grid; grid-template-columns: repeat(9, 1fr); gap: 4px; margin-bottom: 18px; }
.login-strip i { height: 10px; border-radius: 3px; box-shadow: inset 0 0 0 1.5px var(--line); }
.login-strip i:nth-child(-n+3) { background: var(--amber); box-shadow: none; }
.login-strip i:nth-child(4) { background: var(--rec); box-shadow: none; }
#login-form { display: flex; flex-direction: column; gap: 10px; margin-top: 22px; }
#login-form input {
  min-height: 52px; padding: 0 14px; border-radius: 12px; border: 1.5px solid var(--line); background: var(--bg);
  font: 400 18px/1 var(--f-body); color: var(--ink);
}
#login-form input:focus { outline: none; border-color: var(--ink-2); }
#login-form .btn { margin-top: 6px; }

@keyframes pulse { 50% { opacity: .35; } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- wider screens */
@media (min-width: 640px) {
  .page { padding-top: 32px; }
  .overview { padding: 20px 22px 22px; }
  .track { padding: 20px 22px 8px 26px; }
  .num { font-size: 52px; }
  .trk-title .title { font-size: 24px; }
  .idle .btn-rec, .idle .btn-line { flex: 0 0 auto; min-width: 180px; }
  .take-top { grid-template-columns: 44px minmax(0, 1fr) auto auto; }
}
