:root {
  --paper: #faf9f6;
  --card: #ffffff;
  --ink: #23262b;
  --ink-2: #6b7078;
  --ink-3: #a2a7ae;
  --line: #e7e4dc;
  --accent: #b06f1e;
  --accent-ink: #8f5a17;
  --accent-wash: #f6ecdc;
  --ok: #2e7d4f;
  --ok-wash: #e2efe7;
  --err: #b04a3a;
  --err-wash: #f5e3df;
  --shadow: 0 1px 2px rgba(35, 38, 43, 0.05), 0 4px 14px rgba(35, 38, 43, 0.06);
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Code", Menlo, Consolas, monospace;
  --fade: 150ms ease;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  display: grid;
  grid-template-columns: 252px 1fr;
  min-height: 100vh;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
}

/* ---------- rail ---------- */
.rail {
  border-right: 1px solid var(--line);
  padding: 26px 20px 20px;
  display: flex;
  flex-direction: column;
  gap: 26px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.wordmark { font-weight: 700; font-size: 16px; letter-spacing: 0.01em; }
.wordmark span { color: var(--ink-3); font-weight: 500; }

.conn { display: flex; flex-direction: column; gap: 12px; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field span {
  font-size: 10.5px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--ink-2);
}
.field span em { font-style: normal; color: var(--ink-3); font-weight: 500; }
.field input {
  font-family: var(--mono); font-size: 12px;
  border: 1px solid var(--line); border-radius: 6px;
  padding: 7px 9px; background: var(--card); color: var(--ink);
  transition: border-color var(--fade);
}
.field input:focus { outline: none; border-color: var(--accent); }
.rootkey summary {
  font-size: 10.5px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--ink-3); cursor: pointer; margin-bottom: 6px;
}
.conn-status { font-size: 12px; color: var(--ink-2); min-height: 18px; }
.conn-status.ok { color: var(--ok); }
.conn-status.err { color: var(--err); }

.views { display: flex; flex-direction: column; gap: 2px; }
.navbtn {
  all: unset; cursor: pointer;
  display: flex; flex-direction: column; gap: 1px;
  padding: 9px 12px; border-radius: 7px;
  font-size: 14px; font-weight: 550; color: var(--ink);
  transition: background var(--fade), opacity var(--fade);
}
.navbtn .need { font-size: 10.5px; color: var(--ink-3); font-weight: 450; }
.navbtn:hover { background: rgba(35, 38, 43, 0.045); }
.navbtn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.navbtn[aria-current="true"] { background: var(--accent-wash); }
.navbtn[aria-current="true"] .need { color: var(--accent-ink); }
.navbtn[data-off="true"] { opacity: 0.42; }

.rail-foot { margin-top: auto; font-size: 11.5px; color: var(--ink-3); line-height: 1.55; }
.rail-foot a { color: var(--ink-2); }

/* ---------- main ---------- */
main { padding: 44px 56px 120px; min-width: 0; }
#view-root { max-width: 980px; animation: appear var(--fade); }
@keyframes appear { from { opacity: 0; } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
  #view-root { animation: none; }
  * { transition: none !important; }
}

.view-head { margin-bottom: 30px; max-width: 62ch; }
.view-head h1 { font-size: 24px; margin: 0 0 6px; letter-spacing: -0.01em; }
.view-head p { margin: 0; color: var(--ink-2); }
.blocked {
  border: 1px dashed var(--line); border-radius: 10px; padding: 22px;
  color: var(--ink-2); max-width: 52ch; background: var(--card);
}
.blocked code { font-family: var(--mono); font-size: 12px; }

button.act {
  font: inherit; font-size: 13px; font-weight: 550;
  border: 1px solid var(--line); border-radius: 7px;
  background: var(--card); color: var(--ink);
  padding: 7px 14px; cursor: pointer;
  transition: border-color var(--fade), background var(--fade);
}
button.act:hover { border-color: var(--ink-3); }
button.act:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
button.act.primary { background: var(--ink); border-color: var(--ink); color: var(--paper); }
button.act.primary:hover { background: #3a3e45; }
button.act.danger { color: var(--err); }
button.act.danger:hover { border-color: var(--err); }
button.act:disabled { opacity: 0.45; cursor: default; }

input.inline, select.inline, textarea.inline {
  font-family: var(--mono); font-size: 12.5px;
  border: 1px solid var(--line); border-radius: 6px;
  padding: 7px 9px; background: var(--card); color: var(--ink);
}
input.inline:focus, select.inline:focus, textarea.inline:focus { outline: none; border-color: var(--accent); }
select.inline { font-family: var(--sans); font-size: 13px; }

/* ---------- catalog ---------- */
.listen-as {
  display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
  margin-bottom: 34px;
}
.listen-as .who {
  font-size: 13px; color: var(--ink-2);
}
.listen-as .who b { color: var(--accent-ink); font-weight: 650; }
.collection-grid { display: flex; flex-direction: column; gap: 22px; }
.release {
  display: grid; grid-template-columns: 168px 1fr; gap: 0;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  overflow: hidden; box-shadow: var(--shadow);
}
.release .art {
  width: 168px; height: 168px; background: var(--accent-wash);
  display: flex; align-items: center; justify-content: center;
  color: var(--ink-3); font-size: 11px;
}
.release .art img { width: 100%; height: 100%; object-fit: cover; display: block; }
.release .body { padding: 16px 22px 14px; min-width: 0; }
.release .rtype {
  font-size: 10px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--ink-3);
}
.release h2 { font-size: 18px; margin: 2px 0 0; }
.release .artist { color: var(--ink-2); font-size: 13px; margin-bottom: 10px; }
.tracks { display: flex; flex-direction: column; }
.track {
  display: flex; align-items: center; gap: 10px;
  padding: 5px 0; border-top: 1px solid var(--line);
  font-size: 13.5px; min-width: 0;
}
.track .no { font-family: var(--mono); font-size: 11px; color: var(--ink-3); width: 18px; text-align: right; }
.track .t { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.track button {
  all: unset; cursor: pointer; font-size: 12px; color: var(--ink-2);
  padding: 3px 8px; border-radius: 5px; transition: background var(--fade), color var(--fade);
}
.track button:hover { background: var(--accent-wash); color: var(--accent-ink); }
.track button:focus-visible { outline: 2px solid var(--accent); }
.track button.playing { color: var(--accent-ink); font-weight: 650; }
.empty-catalog {
  border: 1px dashed var(--line); border-radius: 12px; padding: 34px;
  text-align: center; color: var(--ink-2); background: var(--card);
}
.empty-catalog b { color: var(--ink); }
.standalone-head {
  font-size: 11px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--ink-3); margin: 30px 0 8px;
}

/* ---------- tables ---------- */
.tablecard { background: var(--card); border: 1px solid var(--line); border-radius: 10px; overflow-x: auto; box-shadow: var(--shadow); }
table.data { border-collapse: collapse; width: 100%; font-size: 13px; }
.data th, .data td { text-align: left; padding: 9px 14px; border-bottom: 1px solid var(--line); }
.data thead th {
  font-size: 10.5px; font-weight: 650; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--ink-3); border-bottom: 1px solid var(--line);
}
.data tbody tr:last-child td { border-bottom: none; }
.data td.mono, .mono { font-family: var(--mono); font-size: 12px; }
.data td .sub { color: var(--ink-3); font-size: 11.5px; }
.pill {
  display: inline-block; font-size: 11px; font-weight: 600; border-radius: 999px;
  padding: 2px 9px; background: var(--paper); color: var(--ink-2); border: 1px solid var(--line);
}
.pill.on { background: var(--ok-wash); color: var(--ok); border-color: transparent; }
.pill.warn { background: var(--accent-wash); color: var(--accent-ink); border-color: transparent; }
.pill.off { background: var(--err-wash); color: var(--err); border-color: transparent; }

.formrow { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; margin: 26px 0 10px; }
.formrow .field span { text-transform: none; letter-spacing: 0; font-size: 11.5px; }
.checks { display: flex; gap: 12px; align-items: center; padding-bottom: 8px; font-size: 13px; color: var(--ink-2); }
.checks label { display: flex; gap: 5px; align-items: center; cursor: pointer; }

.reveal {
  margin: 14px 0; padding: 12px 16px; border-radius: 8px;
  background: var(--accent-wash); border: 1px solid rgba(176, 111, 30, 0.25);
  font-family: var(--mono); font-size: 12.5px; word-break: break-all;
}
.reveal .note { font-family: var(--sans); font-size: 11.5px; color: var(--accent-ink); margin-top: 4px; }

/* ---------- console ---------- */
.console-bar { display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.console-bar select { width: 92px; }
.console-bar input[type="text"] { flex: 1; min-width: 280px; }
textarea.inline { width: 100%; min-height: 90px; resize: vertical; }
.resp { margin-top: 18px; }
.resp .status {
  font-family: var(--mono); font-size: 13px; margin-bottom: 8px;
  display: flex; gap: 12px; align-items: baseline;
}
.resp .status .code.ok { color: var(--ok); font-weight: 700; }
.resp .status .code.err { color: var(--err); font-weight: 700; }
.resp .status .ms { color: var(--ink-3); font-size: 11.5px; }
pre.payload {
  background: #f2f0ea; border: 1px solid var(--line); border-radius: 8px;
  padding: 14px 16px; overflow-x: auto; font-family: var(--mono); font-size: 12px;
  line-height: 1.55; margin: 0; max-height: 480px; overflow-y: auto;
}
.hist { margin-top: 26px; }
.hist .h {
  font-size: 11px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--ink-3); margin-bottom: 6px;
}
.hist button {
  all: unset; cursor: pointer; display: block; width: 100%;
  font-family: var(--mono); font-size: 12px; padding: 5px 8px; border-radius: 5px;
  color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.hist button:hover { background: rgba(35, 38, 43, 0.05); color: var(--ink); }
.hint { font-size: 12px; color: var(--ink-3); margin-top: 8px; }
.hint code { font-family: var(--mono); }

/* ---------- player ---------- */
.player[hidden] { display: none; }
.player {
  position: fixed; left: 292px; right: 40px; bottom: 22px;
  display: flex; align-items: center; gap: 14px;
  background: var(--ink); color: var(--paper);
  border-radius: 10px; padding: 10px 18px;
  box-shadow: 0 8px 28px rgba(35, 38, 43, 0.28);
}
.player button {
  all: unset; cursor: pointer; font-size: 13px; width: 30px; height: 30px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%; background: rgba(250, 249, 246, 0.14);
}
.player button:focus-visible { outline: 2px solid var(--accent); }
.player-meta { min-width: 0; }
#player-title { font-size: 13.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#player-sub { font-size: 11.5px; color: var(--ink-3); }

@media (max-width: 860px) {
  body { grid-template-columns: 1fr; }
  .rail { position: static; height: auto; border-right: none; border-bottom: 1px solid var(--line); }
  main { padding: 28px 20px 120px; }
  .player { left: 16px; right: 16px; }
  .release { grid-template-columns: 108px 1fr; }
  .release .art { width: 108px; height: 108px; }
}
