/* Offhours — warm, editorial, after-hours. */
@import url("https://fonts.googleapis.com/css2?family=Fraunces:ital,opsz,wght@0,9..144,300..700;1,9..144,300..600&family=Geist:wght@400;500;600&family=Geist+Mono:wght@400;500&display=swap");

:root {
  --bg: #12110f;
  --bg-2: #1a1916;
  --bg-3: #24221e;
  --bg-raise: #1e1d1a;
  --line: rgba(239, 233, 220, 0.09);
  --line-2: rgba(239, 233, 220, 0.18);
  --text: #efe9dc;
  --muted: #a8a194;
  --faint: #6f6a61;
  --accent: #e9a64c;
  --accent-ink: #1d1406;
  --accent-soft: rgba(233, 166, 76, 0.14);
  --danger: #e2735c;
  --ok: #94b783;
  --shadow: 0 18px 40px -18px rgba(0, 0, 0, 0.7);
  --radius: 10px;
  --serif: "Fraunces", "Iowan Old Style", Georgia, serif;
  --sans: "Geist", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "Geist Mono", ui-monospace, "SFMono-Regular", Consolas, monospace;
  --gutter: clamp(16px, 3.2vw, 40px);
  --top: 64px;
  color-scheme: dark;
}
:root[data-theme="light"] {
  --bg: #f4efe5;
  --bg-2: #ebe5d8;
  --bg-3: #e0d8c8;
  --bg-raise: #fbf8f2;
  --line: rgba(29, 26, 21, 0.1);
  --line-2: rgba(29, 26, 21, 0.2);
  --text: #1d1a15;
  --muted: #645d51;
  --faint: #978f81;
  --accent: #b4521d;
  --accent-ink: #fff7ee;
  --accent-soft: rgba(180, 82, 29, 0.1);
  --danger: #b23a22;
  --ok: #4c7a3b;
  --shadow: 0 18px 40px -22px rgba(60, 40, 20, 0.45);
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  overflow-x: hidden;
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
img { display: block; max-width: 100%; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
::selection { background: var(--accent); color: var(--accent-ink); }
.ico { display: inline-flex; line-height: 0; }
.muted { color: var(--muted); }
.mono { font-family: var(--mono); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.label {
  font: 500 11px/1 var(--mono);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--faint);
}

/* ------------------------------------------------------------ top bar */
.topbar {
  position: sticky; top: 0; z-index: 40;
  height: var(--top);
  display: flex; align-items: center; gap: 28px;
  padding: 0 var(--gutter);
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: blur(14px) saturate(1.2);
  border-bottom: 1px solid var(--line);
}
.wordmark {
  font: italic 400 26px/1 var(--serif);
  font-variation-settings: "opsz" 144;
  letter-spacing: -0.02em;
  display: flex; align-items: baseline; gap: 6px;
  white-space: nowrap;
}
.wordmark .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); display: inline-block; transform: translateY(-2px); }
.nav { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; }
.nav::-webkit-scrollbar { display: none; }
.nav a {
  padding: 8px 12px; border-radius: 8px;
  color: var(--muted); white-space: nowrap; font-weight: 500;
  display: flex; align-items: baseline; gap: 6px;
}
.nav a sup { font: 10px var(--mono); color: var(--faint); }
.nav a:hover { color: var(--text); background: var(--bg-2); }
.nav a.active { color: var(--text); }
.nav a.active::after { content: ""; display: block; }
.nav a.active { box-shadow: inset 0 -2px 0 var(--accent); border-radius: 8px 8px 0 0; }
.nav a.soon { opacity: 0.55; }
.top-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.search-btn {
  display: flex; align-items: center; gap: 10px;
  min-width: 240px; height: 38px; padding: 0 10px 0 12px;
  background: var(--bg-2); border: 1px solid var(--line); border-radius: 999px;
  color: var(--faint); text-align: left;
}
.search-btn:hover { border-color: var(--line-2); color: var(--muted); }
.search-btn span.txt { flex: 1; }
kbd {
  font: 11px var(--mono); padding: 2px 6px; border-radius: 5px;
  border: 1px solid var(--line-2); color: var(--muted); background: var(--bg);
}
.avatar {
  width: 36px; height: 36px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--bg-3); border: 1px solid var(--line-2);
  font: italic 500 16px var(--serif);
}
.menu {
  position: absolute; right: var(--gutter); top: calc(var(--top) - 6px);
  min-width: 220px; padding: 6px;
  background: var(--bg-raise); border: 1px solid var(--line-2); border-radius: 12px;
  box-shadow: var(--shadow);
  display: none;
}
.menu.open { display: block; animation: pop 0.14s ease-out; }
.menu .who { padding: 10px 12px 12px; border-bottom: 1px solid var(--line); margin-bottom: 6px; }
.menu .who b { display: block; font: 500 17px var(--serif); }
.menu a, .menu button {
  width: 100%; display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: 8px; border: 0; background: none; text-align: left; color: var(--muted);
}
.menu a:hover, .menu button:hover { background: var(--bg-2); color: var(--text); }
@keyframes pop { from { opacity: 0; transform: translateY(-4px); } }

.announce {
  display: flex; gap: 12px; align-items: center; justify-content: center;
  padding: 9px var(--gutter);
  background: var(--accent-soft); color: var(--text);
  border-bottom: 1px solid var(--line);
  font-size: 14px; text-align: center;
}
.announce .label { color: var(--accent); }

/* ------------------------------------------------------------ page */
main { padding: 0 var(--gutter) 96px; max-width: 1560px; margin: 0 auto; }
.hero { padding: clamp(40px, 8vw, 96px) 0 clamp(28px, 4vw, 48px); border-bottom: 1px solid var(--line); margin-bottom: 40px; }
.hero h1 {
  margin: 0;
  font: 300 clamp(44px, 8.2vw, 116px)/0.95 var(--serif);
  font-variation-settings: "opsz" 144;
  letter-spacing: -0.035em;
  max-width: 14ch;
}
.hero h1 em { font-style: italic; color: var(--accent); font-weight: 400; }
.hero-meta { display: flex; flex-wrap: wrap; gap: 10px 28px; margin-top: 28px; align-items: center; }
.hero-meta p { margin: 0; max-width: 46ch; color: var(--muted); font-size: 17px; }
.stats { display: flex; gap: 22px; flex-wrap: wrap; }
.stat b { display: block; font: 400 28px/1 var(--serif); letter-spacing: -0.02em; }
.stat span { font: 11px var(--mono); letter-spacing: 0.08em; text-transform: uppercase; color: var(--faint); }
.hero-actions { display: flex; gap: 10px; margin-left: auto; }

.page-head { padding: 48px 0 24px; display: flex; flex-wrap: wrap; align-items: end; gap: 16px 32px; }
.page-head h1 {
  margin: 0; font: 300 clamp(40px, 6vw, 76px)/1 var(--serif);
  font-variation-settings: "opsz" 144; letter-spacing: -0.03em;
}
.page-head h1 sup { font: 13px var(--mono); color: var(--faint); letter-spacing: 0; vertical-align: top; margin-left: 6px; }
.page-head p { margin: 0 0 6px; color: var(--muted); max-width: 52ch; }

/* ------------------------------------------------------------ shelves (horizontal rows) */
.shelf { margin: 0 0 44px; }
.shelf-head { display: flex; align-items: baseline; gap: 12px; margin-bottom: 14px; }
.shelf-head h2 { margin: 0; font: 400 26px/1.1 var(--serif); letter-spacing: -0.015em; }
.shelf-head .count { font: 12px var(--mono); color: var(--faint); }
.shelf-head .more { margin-left: auto; color: var(--muted); font-size: 14px; display: flex; gap: 4px; align-items: center; }
.shelf-head .more:hover { color: var(--accent); }
.track {
  display: grid; grid-auto-flow: column; grid-auto-columns: clamp(138px, 15vw, 180px);
  gap: 18px; overflow-x: auto; padding: 4px 2px 14px; scroll-snap-type: x proximity;
  scrollbar-width: thin; scrollbar-color: var(--line-2) transparent;
}
.track > * { scroll-snap-align: start; }

/* ------------------------------------------------------------ cards + covers */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 28px 18px; }
.card { display: block; position: relative; min-width: 0; }
.card .cover { transition: transform 0.25s cubic-bezier(.2,.8,.2,1), box-shadow 0.25s; }
.card:hover .cover, .card:focus-visible .cover { transform: translateY(-4px) rotate(-0.4deg); box-shadow: var(--shadow); }
.card:focus-visible { outline: none; }
.card:focus-visible .cover { outline: 2px solid var(--accent); outline-offset: 3px; }
.card .cap { padding: 10px 2px 0; }
.card .cap b { display: block; font-weight: 500; font-size: 14px; line-height: 1.3; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card .cap span { font: 11px var(--mono); color: var(--faint); letter-spacing: 0.04em; }
.card .play-dot {
  position: absolute; right: 10px; top: calc(100% - 90px); z-index: 2;
  width: 38px; height: 38px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--accent); color: var(--accent-ink);
  opacity: 0; transform: scale(0.8); transition: 0.2s;
}
.card:hover .play-dot { opacity: 1; transform: scale(1); }
.card .pin-flag { position: absolute; left: 8px; top: 8px; z-index: 2; color: var(--accent); filter: drop-shadow(0 1px 2px rgba(0,0,0,.5)); }

.cover {
  --paper: #d9cbb0; --ink: #1d1a16;
  position: relative; overflow: hidden;
  aspect-ratio: 4 / 5;
  border-radius: 6px;
  background: var(--paper);
  color: var(--ink);
  container-type: inline-size;
  isolation: isolate;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.08);
}
/* paper grain */
.cover::after {
  content: ""; position: absolute; inset: 0; z-index: 3; pointer-events: none;
  background-image: radial-gradient(rgba(0,0,0,.09) 1px, transparent 1px), radial-gradient(rgba(255,255,255,.06) 1px, transparent 1px);
  background-size: 3px 3px, 5px 5px; background-position: 0 0, 1px 2px;
  mix-blend-mode: multiply; opacity: .6;
}
.cover img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; z-index: 1; }
.cover.has-img .cover-title, .cover.has-img .cover-mark, .cover.has-img .cover-no { display: none; }
.cover.has-img .cover-cat { z-index: 2; background: rgba(0,0,0,.55); color: #fff; padding: 3px 6px; border-radius: 4px; }
.cover-cat, .cover-no {
  position: absolute; top: 9cqi; font: 500 clamp(8px, 6.4cqi, 11px)/1 var(--mono);
  letter-spacing: .08em; text-transform: uppercase; opacity: .75; z-index: 2;
}
.cover-cat { left: 9cqi; right: 40cqi; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cover-no { right: 9cqi; }
.cover-title {
  position: absolute; left: 9cqi; right: 9cqi; bottom: 9cqi; z-index: 2;
  font: 400 clamp(15px, 14cqi, 34px)/0.98 var(--serif);
  font-variation-settings: "opsz" 72;
  letter-spacing: -0.02em;
  display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden;
  overflow-wrap: anywhere; hyphens: auto;
}
.cover-mark { position: absolute; z-index: 1; }
/* v0 — rule above the title */
.cover.v0 .cover-mark { left: 9cqi; right: 9cqi; top: 22cqi; height: 1px; background: currentColor; opacity: .5; }
/* v1 — a big ring sitting off the top-right edge, italic title */
.cover.v1 .cover-mark { width: 92cqi; height: 92cqi; right: -30cqi; top: -18cqi; border-radius: 50%; border: 1.5px solid currentColor; opacity: .35; }
.cover.v1 .cover-title { font-style: italic; }
/* v2 — solid block in the top half, title reversed below */
.cover.v2 .cover-mark { left: 0; right: 0; top: 0; height: 46%; background: var(--ink); opacity: .9; }
.cover.v2 .cover-cat, .cover.v2 .cover-no { color: var(--paper); opacity: .85; }
/* v3 — thick vertical band on the left */
.cover.v3 .cover-mark { left: 0; top: 0; bottom: 0; width: 14cqi; background: var(--ink); opacity: .88; }
.cover.v3 .cover-cat { left: 22cqi; }
.cover.v3 .cover-title { left: 22cqi; }

/* list view */
.rows { border-top: 1px solid var(--line); }
.row {
  display: grid; grid-template-columns: 72px 44px minmax(0, 1fr) 200px 90px 40px;
  align-items: center; gap: 16px; padding: 10px 6px;
  border-bottom: 1px solid var(--line);
}
.row:hover { background: var(--bg-2); }
.row .no { font: 12px var(--mono); color: var(--faint); }
.row .mini { width: 36px; }
.row .mini .cover { border-radius: 3px; }
.row .mini .cover > span:not(.cover-mark) { display: none; }
.row .t { font: 400 19px/1.2 var(--serif); letter-spacing: -0.01em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .c, .row .s { font: 12px var(--mono); color: var(--muted); }
.row .s { text-align: right; color: var(--faint); }

/* ------------------------------------------------------------ toolbar & controls */
.toolbar {
  position: sticky; top: var(--top); z-index: 20;
  display: flex; flex-wrap: wrap; gap: 10px; align-items: center;
  padding: 12px 0; margin-bottom: 24px;
  background: var(--bg); border-bottom: 1px solid var(--line);
}
.chips { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; flex: 1 1 380px; min-width: 0; padding: 2px; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; padding: 6px 12px; border-radius: 999px;
  border: 1px solid var(--line-2); background: transparent; color: var(--muted);
  font-size: 13px; white-space: nowrap;
}
.chip sup { font: 10px var(--mono); color: var(--faint); margin-left: 3px; }
.chip:hover { color: var(--text); border-color: var(--muted); }
.chip.on { background: var(--text); color: var(--bg); border-color: var(--text); }
.chip.on sup { color: var(--bg); opacity: .6; }
.seg { display: inline-flex; border: 1px solid var(--line-2); border-radius: 8px; overflow: hidden; }
.seg button { border: 0; background: none; padding: 7px 9px; color: var(--faint); }
.seg button.on { background: var(--bg-3); color: var(--text); }

.input, select.input, textarea.input {
  width: 100%; height: 40px; padding: 0 12px;
  background: var(--bg-2); border: 1px solid var(--line-2); border-radius: 8px;
  outline: none; transition: border-color .15s, box-shadow .15s;
}
textarea.input { height: auto; min-height: 96px; padding: 10px 12px; resize: vertical; font-family: var(--mono); font-size: 13px; }
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.input.sm { height: 34px; font-size: 14px; }
.input-icon { position: relative; }
.input-icon .ico { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--faint); pointer-events: none; }
.input-icon .input { padding-left: 36px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 38px; padding: 0 16px; border-radius: 8px;
  border: 1px solid var(--line-2); background: var(--bg-2); color: var(--text);
  font-weight: 500; font-size: 14px; white-space: nowrap;
  transition: background .15s, border-color .15s, transform .1s;
}
.btn:hover { border-color: var(--muted); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; pointer-events: none; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.danger { color: var(--danger); }
.btn.danger.primary { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.ghost { background: none; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { color: var(--text); background: var(--bg-2); }
.btn.sm { height: 32px; padding: 0 11px; font-size: 13px; }
.icon-btn {
  width: 36px; height: 36px; display: inline-grid; place-items: center;
  border: 1px solid transparent; border-radius: 8px; background: none; color: var(--muted);
}
.icon-btn:hover { background: var(--bg-2); color: var(--text); }
.icon-btn.on { color: var(--accent); }

.field { display: flex; flex-direction: column; gap: 6px; }
.field-label { font: 500 11px/1 var(--mono); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.field-hint { font-size: 12px; color: var(--faint); }
.check { display: flex; gap: 10px; align-items: center; cursor: pointer; }
.check input { accent-color: var(--accent); width: 16px; height: 16px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }
.switch { position: relative; width: 38px; height: 22px; flex: none; }
.switch input { opacity: 0; width: 100%; height: 100%; position: absolute; margin: 0; cursor: pointer; z-index: 1; }
.switch span { position: absolute; inset: 0; border-radius: 999px; background: var(--bg-3); border: 1px solid var(--line-2); transition: .2s; }
.switch span::after { content: ""; position: absolute; width: 16px; height: 16px; left: 2px; top: 2px; border-radius: 50%; background: var(--muted); transition: .2s; }
.switch input:checked + span { background: var(--accent); border-color: var(--accent); }
.switch input:checked + span::after { transform: translateX(16px); background: var(--accent-ink); }

/* ------------------------------------------------------------ player */
.player { margin: 0 calc(var(--gutter) * -1); }
.player-bar {
  display: flex; align-items: center; gap: 14px;
  height: 56px; padding: 0 var(--gutter);
  border-bottom: 1px solid var(--line);
}
.player-bar h1 { margin: 0; font: 400 22px/1 var(--serif); letter-spacing: -0.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.player-bar .label { white-space: nowrap; }
.player-bar .tools { margin-left: auto; display: flex; gap: 2px; }
.stage { position: relative; background: #000; height: calc(100vh - var(--top) - 56px); min-height: 360px; }
.stage iframe, .stage video { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; background: #000; }
.stage .loading {
  position: absolute; inset: 0; display: grid; place-items: center; color: #8a8478;
  font: italic 300 22px var(--serif); pointer-events: none; transition: opacity .4s;
}
.stage .loading.gone { opacity: 0; }
.proxy-bar { display: flex; gap: 8px; padding: 10px var(--gutter); border-bottom: 1px solid var(--line); }
.after-player { padding: 36px 0 0; }
.notice {
  max-width: 560px; margin: 12vh auto; text-align: center; padding: 0 16px;
}
.notice h2 { font: 300 44px/1.05 var(--serif); letter-spacing: -.02em; margin: 0 0 12px; }
.notice p { color: var(--muted); }

/* ------------------------------------------------------------ command palette */
.scrim {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(8, 7, 6, .62); backdrop-filter: blur(4px);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 12vh 16px 16px; opacity: 0; transition: opacity .18s;
}
.scrim.in { opacity: 1; }
.palette {
  width: min(680px, 100%); max-height: 72vh; display: flex; flex-direction: column;
  background: var(--bg-raise); border: 1px solid var(--line-2); border-radius: 16px;
  box-shadow: 0 40px 80px -30px rgba(0,0,0,.8); overflow: hidden;
}
.palette .q { display: flex; align-items: center; gap: 12px; padding: 0 18px; border-bottom: 1px solid var(--line); }
.palette .q input { flex: 1; height: 64px; border: 0; background: none; outline: none; font: 300 26px var(--serif); letter-spacing: -.01em; }
.palette .q input::placeholder { color: var(--faint); }
.palette ul { list-style: none; margin: 0; padding: 6px; overflow-y: auto; }
.palette li a { display: grid; grid-template-columns: 34px 1fr auto; gap: 14px; align-items: center; padding: 8px 10px; border-radius: 10px; }
.palette li a .mini .cover > span:not(.cover-mark) { display: none; }
.palette li a .mini .cover { border-radius: 3px; }
.palette li a b { font-weight: 500; }
.palette li a span.c { font: 11px var(--mono); color: var(--faint); text-transform: uppercase; letter-spacing: .06em; }
.palette li.sel a, .palette li a:hover { background: var(--bg-3); }
.palette .empty { padding: 28px; text-align: center; color: var(--faint); font-style: italic; font-family: var(--serif); font-size: 18px; }
.palette .foot { padding: 10px 16px; border-top: 1px solid var(--line); display: flex; gap: 16px; color: var(--faint); font-size: 12px; }

/* ------------------------------------------------------------ dialogs & toasts */
.dialog {
  width: min(520px, 100%); max-height: 84vh; display: flex; flex-direction: column;
  background: var(--bg-raise); border: 1px solid var(--line-2); border-radius: 16px;
  box-shadow: 0 40px 80px -30px rgba(0,0,0,.8);
  transform: translateY(8px); transition: transform .2s;
}
.dialog.wide { width: min(820px, 100%); }
.scrim.in .dialog { transform: none; }
.dialog header { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px 10px 24px; }
.dialog header h3 { margin: 0; font: 400 24px/1.1 var(--serif); letter-spacing: -.01em; }
.dialog-body { padding: 8px 24px 20px; overflow-y: auto; display: flex; flex-direction: column; gap: 16px; }
.dialog footer { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--line); }
#toasts { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast {
  padding: 10px 16px; border-radius: 10px; background: var(--text); color: var(--bg);
  font-size: 14px; font-weight: 500; box-shadow: var(--shadow);
  opacity: 0; transform: translateY(8px); transition: .25s;
}
.toast.in { opacity: 1; transform: none; }
.toast.error { background: var(--danger); color: #fff; }
.toast.ok { background: var(--ok); color: #10180c; }
.toast.warn { background: var(--accent); color: var(--accent-ink); }

/* ------------------------------------------------------------ settings & admin layout */
.split { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 48px; padding-top: 8px; }
.sidenav { position: sticky; top: calc(var(--top) + 24px); align-self: start; display: flex; flex-direction: column; gap: 2px; }
.sidenav .label { padding: 0 12px 10px; }
.sidenav a { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 8px; color: var(--muted); font-weight: 500; }
.sidenav a:hover { color: var(--text); background: var(--bg-2); }
.sidenav a.active { color: var(--text); background: var(--bg-2); box-shadow: inset 2px 0 0 var(--accent); }
.panel { border: 1px solid var(--line); border-radius: 14px; background: var(--bg-raise); padding: 24px; margin-bottom: 20px; }
.panel h2 { margin: 0 0 4px; font: 400 24px/1.15 var(--serif); letter-spacing: -.01em; }
.panel > p.muted { margin: 0 0 20px; }
.panel-row { display: flex; align-items: center; gap: 16px; padding: 14px 0; border-top: 1px solid var(--line); }
.panel-row:first-of-type { border-top: 0; }
.panel-row .grow { flex: 1; min-width: 0; }
.panel-row .grow b { display: block; font-weight: 500; }
.panel-row .grow span { font-size: 13px; color: var(--muted); }
.section-title { display: flex; align-items: center; gap: 12px; margin: 0 0 18px; flex-wrap: wrap; }
.section-title h2 { margin: 0; font: 300 38px/1 var(--serif); letter-spacing: -.02em; }
.section-title .actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; margin-bottom: 24px; }
.tile { border: 1px solid var(--line); border-radius: 14px; padding: 18px; background: var(--bg-raise); }
.tile b { display: block; font: 300 40px/1 var(--serif); letter-spacing: -.02em; margin-top: 10px; }
.tile small { color: var(--muted); }

.table-wrap { border: 1px solid var(--line); border-radius: 14px; overflow: auto; background: var(--bg-raise); max-height: 68vh; }
table.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th {
  position: sticky; top: 0; z-index: 1; background: var(--bg-raise);
  text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--line-2);
  font: 500 11px var(--mono); letter-spacing: .08em; text-transform: uppercase; color: var(--faint); white-space: nowrap;
}
.table td { padding: 9px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--bg-2); }
.table td.t { font-weight: 500; max-width: 340px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.table td.k { font: 12px var(--mono); color: var(--muted); max-width: 300px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.table td.r { text-align: right; white-space: nowrap; }
.table .cb { width: 36px; }
.badge {
  display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px; border-radius: 999px;
  font: 500 11px/18px var(--mono); letter-spacing: .04em; border: 1px solid var(--line-2); color: var(--muted); white-space: nowrap;
}
.badge.accent { border-color: var(--accent); color: var(--accent); }
.badge.danger { border-color: var(--danger); color: var(--danger); }
.badge.ok { border-color: var(--ok); color: var(--ok); }
.bulkbar { display: flex; align-items: center; gap: 8px; padding: 10px 14px; margin-bottom: 12px; border-radius: 12px; background: var(--accent-soft); border: 1px solid var(--accent); flex-wrap: wrap; }
.dirty-bar {
  position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); z-index: 60;
  display: flex; align-items: center; gap: 14px; padding: 10px 10px 10px 18px;
  background: var(--text); color: var(--bg); border-radius: 999px; box-shadow: var(--shadow);
}
.dirty-bar .btn { height: 34px; }
.dirty-bar .btn.ghost { color: var(--bg); opacity: .7; }
.dropzone {
  border: 1.5px dashed var(--line-2); border-radius: 12px; padding: 28px; text-align: center; color: var(--muted);
  transition: .15s;
}
.dropzone.over { border-color: var(--accent); background: var(--accent-soft); color: var(--text); }
.progress { height: 4px; background: var(--bg-3); border-radius: 4px; overflow: hidden; }
.progress i { display: block; height: 100%; background: var(--accent); width: 0; transition: width .2s; }
.crumbs { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; font: 13px var(--mono); }
.crumbs a { color: var(--muted); padding: 3px 6px; border-radius: 5px; }
.crumbs a:hover { background: var(--bg-2); color: var(--text); }
.empty-state { padding: 60px 20px; text-align: center; color: var(--muted); }
.empty-state h3 { font: italic 300 28px var(--serif); margin: 0 0 6px; color: var(--text); }

/* ------------------------------------------------------------ login */
.auth-page { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(360px, 0.85fr); }
.auth-art { position: relative; overflow: hidden; border-right: 1px solid var(--line); background: var(--bg-2); }
.auth-art .wall {
  position: absolute; inset: -10% -20%;
  display: grid; grid-template-columns: repeat(6, 1fr); gap: 16px;
  transform: rotate(-8deg); opacity: .9;
}
.auth-art .wall .col { display: flex; flex-direction: column; gap: 16px; animation: drift 60s linear infinite; }
.auth-art .wall .col:nth-child(2n) { animation-direction: reverse; animation-duration: 75s; }
@keyframes drift { from { transform: translateY(0); } to { transform: translateY(-50%); } }
.auth-art::after { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, transparent 40%, var(--bg-2) 100%), linear-gradient(0deg, var(--bg-2) 0%, transparent 35%); }
.auth-art .caption { position: absolute; left: clamp(24px, 4vw, 56px); bottom: clamp(24px, 4vw, 56px); z-index: 2; max-width: 30ch; }
.auth-art .caption h2 { margin: 0; font: 300 clamp(36px, 4.5vw, 64px)/1 var(--serif); letter-spacing: -.03em; }
.auth-art .caption h2 em { color: var(--accent); }
.auth-form { display: flex; flex-direction: column; justify-content: center; padding: clamp(28px, 6vw, 80px); gap: 22px; }
.auth-form .wordmark { font-size: 34px; margin-bottom: 18px; }
.auth-form h1 { margin: 0; font: 300 40px/1.05 var(--serif); letter-spacing: -.02em; }
.auth-form form { display: flex; flex-direction: column; gap: 16px; max-width: 380px; }
.auth-form .btn { height: 46px; font-size: 15px; }
.form-error { color: var(--danger); font-size: 14px; min-height: 1.4em; margin: 0; }
.setup-card { max-width: 720px; margin: 8vh auto; padding: 0 var(--gutter); }
.setup-card ol { padding-left: 20px; color: var(--muted); }
.setup-card ol li { margin: 8px 0; }
.setup-card code { font: 13px var(--mono); background: var(--bg-2); padding: 2px 6px; border-radius: 5px; color: var(--text); }

/* ------------------------------------------------------------ responsive */
@media (max-width: 1040px) {
  .search-btn { min-width: 0; }
  .search-btn .txt, .search-btn kbd { display: none; }
}
@media (max-width: 860px) {
  .topbar { gap: 14px; }
  .nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 50; justify-content: space-around; background: var(--bg-raise); border-top: 1px solid var(--line); padding: 6px 8px calc(6px + env(safe-area-inset-bottom)); }
  .nav a.active { box-shadow: none; color: var(--accent); }
  main { padding-bottom: 120px; }
  .split { grid-template-columns: 1fr; gap: 20px; }
  .sidenav { position: static; flex-direction: row; overflow-x: auto; scrollbar-width: none; }
  .sidenav .label { display: none; }
  .sidenav a { white-space: nowrap; }
  .row { grid-template-columns: 40px minmax(0, 1fr) 40px; }
  .row .no, .row .c, .row .s { display: none; }
  .auth-page { grid-template-columns: 1fr; }
  .auth-art { display: none; }
  .hero-actions { margin-left: 0; }
  .stage { height: calc(100vh - var(--top) - 56px - 64px); }
}
@media (max-width: 520px) {
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 22px 14px; }
  .player-bar .label { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
.shelf-head .more .ico { transform: rotate(180deg); }
.mini .cover > span:not(.cover-mark) { display: none; } .mini .cover { border-radius: 3px; }
@media (max-width: 860px) { .topbar { backdrop-filter: none; -webkit-backdrop-filter: none; background: var(--bg); } }
.controls-hint { display: flex; flex-wrap: wrap; gap: 8px 18px; align-items: center; padding: 10px var(--gutter); border-top: 1px solid var(--line); font-size: 13px; color: var(--muted); }
.req-already { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: -6px; }
.req-already:empty { display: none; }
/* login: one screen at a time ([hidden] must beat display:flex) */
.auth-screen { display: flex; flex-direction: column; gap: 22px; max-width: 380px; }
.auth-screen[hidden], .auth-form form[hidden] { display: none; }
.auth-screen > p.muted { margin: -8px 0 0; }
.field-row { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.text-link { font-size: 13px; color: var(--muted); text-decoration: underline; text-decoration-color: var(--line-2); text-underline-offset: 3px; }
.text-link:hover { color: var(--accent); text-decoration-color: currentColor; }
.back-link { align-self: flex-start; text-decoration: none; margin-bottom: -6px; }

/* ------------------------------------------------------------ ask (chat) */
.chat { display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: 0; margin: 24px 0 0; border: 1px solid var(--line); border-radius: 16px; overflow: hidden; background: var(--bg-raise); height: calc(100vh - var(--top) - 72px); min-height: 480px; }
.chat-side { border-right: 1px solid var(--line); padding: 14px; overflow-y: auto; background: var(--bg-2); }
.chat-list { display: flex; flex-direction: column; gap: 4px; }
.chat-new { width: 100%; margin-bottom: 10px; }
.chat-item { display: flex; align-items: center; border-radius: 8px; }
.chat-item:hover, .chat-item.on { background: var(--bg-3); }
.chat-item-title { flex: 1; min-width: 0; text-align: left; border: 0; background: none; padding: 8px 10px; color: var(--muted); font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-item.on .chat-item-title { color: var(--text); }
.chat-item .icon-btn { opacity: 0; width: 30px; height: 30px; }
.chat-item:hover .icon-btn, .chat-item.on .icon-btn { opacity: 1; }
.chat-main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.chat-head { display: flex; align-items: baseline; gap: 14px; padding: 14px 22px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.chat-head h2 { margin: 0; font: 400 22px/1.2 var(--serif); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 60%; }
.chat-head .label { margin-left: auto; }
.chat-thread { flex: 1; overflow-y: auto; padding: 22px; display: flex; flex-direction: column; gap: 18px; }
.chat-empty { margin: auto; text-align: center; max-width: 560px; display: flex; flex-direction: column; gap: 10px; align-items: center; }
.chat-empty h3 { font: 300 40px/1.1 var(--serif); letter-spacing: -.02em; margin: 0; }
.msg { max-width: 760px; width: fit-content; }
.msg.user { align-self: flex-end; }
.msg.user .msg-body { background: var(--bg-3); border: 1px solid var(--line); padding: 10px 14px; border-radius: 14px 14px 4px 14px; white-space: pre-wrap; }
.msg.assistant { align-self: flex-start; width: 100%; }
.msg-who { display: block; font: 500 11px var(--mono); letter-spacing: .08em; text-transform: uppercase; color: var(--faint); margin-bottom: 6px; }
.msg.user .msg-who { text-align: right; }
.msg-body { line-height: 1.6; overflow-wrap: anywhere; }
.msg-body p { margin: 0 0 10px; } .msg-body p:last-child { margin-bottom: 0; }
.msg-body ul, .msg-body ol { margin: 0 0 10px; padding-left: 22px; }
.msg-body h3, .msg-body h4, .msg-body h5, .msg-body h6 { font-family: var(--serif); font-weight: 500; margin: 14px 0 6px; }
.msg-body code { font: 13px var(--mono); background: var(--bg-3); padding: 1px 5px; border-radius: 4px; }
.msg-body pre.md-code { position: relative; background: #0c0b0a; color: #e8e2d5; border: 1px solid var(--line); border-radius: 10px; padding: 14px; overflow-x: auto; margin: 0 0 10px; }
.msg-body pre.md-code code { background: none; padding: 0; color: inherit; }
.md-copy { position: absolute; top: 8px; right: 8px; font: 11px var(--mono); padding: 3px 8px; border-radius: 6px; border: 1px solid rgba(255,255,255,.15); background: rgba(255,255,255,.06); color: #cfc8bb; }
.msg-body blockquote { margin: 0 0 10px; padding-left: 12px; border-left: 3px solid var(--line-2); color: var(--muted); }
.msg-body a { color: var(--accent); text-decoration: underline; }
.msg-tools { margin-top: 4px; opacity: 0; transition: opacity .15s; }
.msg.assistant:hover .msg-tools { opacity: 1; }
.msg.streaming .msg-tools { display: none; }
.msg-note { margin-top: 8px; font-size: 13px; color: var(--muted); font-style: italic; }
.msg-note.error { color: var(--danger); font-style: normal; }
.typing { display: inline-flex; gap: 4px; padding: 6px 0; }
.typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--faint); animation: blink 1.2s infinite ease-in-out; }
.typing i:nth-child(2) { animation-delay: .15s; } .typing i:nth-child(3) { animation-delay: .3s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }
.chat-composer { display: flex; gap: 10px; align-items: flex-end; margin: 0 22px; padding: 10px; border: 1px solid var(--line-2); border-radius: 14px; background: var(--bg-2); }
.chat-composer:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.chat-input { flex: 1; resize: none; border: 0; background: none; outline: none; font: 15px/1.5 var(--sans); max-height: 220px; padding: 6px 4px; }
.chat-send { width: 40px; height: 40px; padding: 0; border-radius: 10px; flex: none; }
.chat-send .ico { transform: rotate(90deg); }
.chat-send[aria-label="Stop"] .ico { transform: none; }
.chat-fine { margin: 8px 22px 14px; font-size: 12px; color: var(--faint); text-align: center; }
@media (max-width: 860px) {
  .chat { grid-template-columns: 1fr; height: calc(100vh - var(--top) - 150px); border-radius: 12px; }
  .chat-side { display: none; }
  .chat-thread { padding: 16px; } .chat-composer { margin: 0 12px; } .chat-head { padding: 12px 16px; }
}

/* long select options / grid children must not widen the page */
.form-grid > *, .split > * { min-width: 0; }
select.input { min-width: 0; max-width: 100%; text-overflow: ellipsis; }

/* switches: clearer off/on states */
.switch { width: 44px; height: 24px; }
.switch span { background: var(--bg); border: 1.5px solid var(--muted); }
.switch span::after { width: 16px; height: 16px; left: 3px; top: 2.5px; background: var(--muted); box-shadow: 0 1px 2px rgba(0,0,0,.4); }
.switch:hover span { border-color: var(--text); }
.switch:hover span::after { background: var(--text); }
.switch input:checked + span { background: var(--accent); border-color: var(--accent); }
.switch input:checked + span::after { transform: translateX(20px); background: var(--accent-ink); }
.switch input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.toggle-row { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; }
.toggle-state { font: 500 12px var(--mono); letter-spacing: .06em; text-transform: uppercase; color: var(--faint); min-width: 26px; }
.toggle-state.on { color: var(--accent); }
.table tr.access-on td.t { color: var(--text); }

/* chat attachments */
.chat-composer { display: block; }
.chat-compose-inner { display: flex; flex-direction: column; gap: 8px; }
.chat-compose-row { display: flex; gap: 8px; align-items: flex-end; }
.chat-attach { flex: none; width: 40px; height: 40px; }
.chat-pending { display: flex; flex-wrap: wrap; gap: 6px; }
.chat-pending:empty { display: none; }
.file-chip { display: inline-flex; align-items: center; gap: 6px; max-width: 240px; padding: 4px 6px 4px 8px; border-radius: 8px; border: 1px solid var(--line-2); background: var(--bg-raise); font-size: 12px; color: var(--muted); }
.file-chip img { width: 22px; height: 22px; object-fit: cover; border-radius: 4px; }
.file-chip button { border: 0; background: none; color: var(--faint); padding: 2px; display: inline-flex; border-radius: 4px; }
.file-chip button:hover { color: var(--text); background: var(--bg-3); }
.file-chip { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.msg-files { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; }
.msg-thumb { max-width: 220px; max-height: 180px; border-radius: 8px; border: 1px solid var(--line); object-fit: cover; }
.chat-main { position: relative; }
.chat-main.drop::after { content: "Drop files to attach"; position: absolute; inset: 8px; border: 2px dashed var(--accent); border-radius: 12px; background: color-mix(in srgb, var(--bg-raise) 85%, transparent); display: grid; place-items: center; font: italic 300 26px var(--serif); color: var(--text); z-index: 5; pointer-events: none; }
.limit-input { width: 150px; }
