/* ══════════════════════════════════════════════════════════════════
   BandRaven — core design system
   Tokens · base · left rail · shared components · toasts · sheet
   ══════════════════════════════════════════════════════════════════ */

:root {
  /* ── Surfaces ─────────────────────────────── */
  --bg:          #050505;
  --bg-elev:     #0e0e10;
  --surface:     #131315;
  --surface-2:   #1b1b1d;
  --surface-3:   #1f1f21;
  --surface-4:   #2a2a2c;
  --scrim:       rgba(0, 0, 0, 0.72);
  --landing-veil: rgba(5, 5, 5, 0.78);
  --landing-veil-2: rgba(14, 14, 16, 0.72);
  --landing-amber: #d6a25c;
  --landing-amber-soft: rgba(214, 162, 92, 0.14);
  --shadow-soft: 0 20px 70px rgba(0, 0, 0, 0.38);
  --shadow-strong: 0 34px 120px rgba(0, 0, 0, 0.58);

  /* ── Hairline borders ─────────────────────── */
  --line:        rgba(69, 70, 84, 0.30);
  --line-2:      rgba(69, 70, 84, 0.55);
  --line-3:      rgba(143, 143, 160, 0.35);

  /* ── Text ─────────────────────────────────── */
  --text:        #e4e2e4;
  --text-2:      #c5c5d7;
  --text-3:      #8f8fa0;
  --text-4:      #454654;

  /* ── Accent — hardware indigo ─────────────── */
  --accent:      #5b6df5;
  --accent-h:    #7686ff;
  --accent-d:    #3c4ed6;
  --accent-ink:  #fff;
  --accent-r:    91;
  --accent-g:    109;
  --accent-b:    245;
  --accent-rgb:  91, 109, 245;
  --accent-soft: rgba(91, 109, 245, 0.10);
  --accent-ghost:rgba(91, 109, 245, 0.06);
  --accent-glow: rgba(91, 109, 245, 0.15);
  --accent-ring: rgba(91, 109, 245, 0.25);
  --accent-line: rgba(91, 109, 245, 0.50);

  /* ── Status ───────────────────────────────── */
  --ok:    #4ec07e;
  --ok-bg: rgba(78, 192, 126, 0.12);
  --warn:  #d6a25c;
  --warn-bg: rgba(214, 162, 92, 0.12);
  --err:   #ffb4ab;
  --err-bg: rgba(255, 180, 171, 0.12);

  /* ── Radius ───────────────────────────────── */
  --r-xs: 2px;
  --r-sm: 3px;
  --r-md: 4px;
  --r-lg: 6px;
  --r-xl: 8px;

  /* ── Spacing (4pt) ────────────────────────── */
  --s1: 4px;  --s2: 8px;  --s3: 12px; --s4: 16px;
  --s5: 24px; --s6: 32px; --s7: 48px; --s8: 64px;

  /* ── Type ─────────────────────────────────── */
  --ui:   "Geist", -apple-system, system-ui, sans-serif;
  --serif:"Instrument Serif", Georgia, serif;
  --mono: "JetBrains Mono", ui-monospace, monospace;

  /* ── Motion ───────────────────────────────── */
  --spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --sheet:  cubic-bezier(0.32, 0.72, 0, 1);
  --ease:   cubic-bezier(0.4, 0, 0.2, 1);

  --rail-w: 200px;
  --rail-c: 56px;
}

/* rose alternate (Tweak toggle) */
[data-accent="rose"] {
  --accent:      #d75a73;
  --accent-h:    #e7758d;
  --accent-d:    #a8425a;
  --accent-rgb:  215, 90, 115;
  --accent-soft: rgba(215, 90, 115, 0.10);
  --accent-ghost:rgba(215, 90, 115, 0.06);
  --accent-glow: rgba(215, 90, 115, 0.15);
  --accent-ring: rgba(215, 90, 115, 0.25);
  --accent-line: rgba(215, 90, 115, 0.50);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--ui);
  font-size: 14px;
  line-height: 1.5;
  letter-spacing: -0.006em;
  font-feature-settings: "ss01" on, "cv11" on;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow: hidden;
}

::selection { background: var(--accent); color: #fff; }

::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.08);
  border-radius: 99px;
  border: 2px solid transparent;
  background-clip: padding-box;
}
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.16); background-clip: padding-box; }
* { scrollbar-width: thin; scrollbar-color: rgba(255,255,255,0.1) transparent; }

.serif { font-family: var(--serif); font-style: italic; font-weight: 400; }
.mono  { font-family: var(--mono); }

.eyebrow {
  font-family: var(--mono);
  font-size: 10.5px;
  font-weight: 400;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-3);
}
.eyebrow a { color: var(--text-2); text-decoration: none; transition: color 140ms var(--ease); }
.eyebrow a:hover { color: var(--text); }

/* ── Focus ring (global, keyboard) ──────────── */
:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--accent-ring);
  border-radius: var(--r-xs);
}

/* ══ APP SHELL ════════════════════════════════ */
#app { height: 100vh; display: flex; flex-direction: column; }

.app-stage { flex: 1; display: flex; min-height: 0; position: relative; }

/* radial atmosphere wash */
.app-stage::before {
  content: "";
  position: absolute; inset: 0;
  pointer-events: none; z-index: 0;
  background:
    radial-gradient(60% 50% at 78% 0%, var(--accent-glow), transparent 70%),
    radial-gradient(50% 40% at 0% 100%, rgba(255,255,255,0.018), transparent 70%);
}

/* ══ LEFT RAIL ════════════════════════════════ */
.rail {
  width: var(--rail-c);
  flex: 0 0 var(--rail-c);
  background: var(--bg-elev);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
  padding: var(--s3) 0;
  position: relative; z-index: 20;
  transition: width 280ms var(--ease), flex-basis 280ms var(--ease);
}
.rail:hover, .rail.pinned { width: var(--rail-w); flex-basis: var(--rail-w); }

.rail-brand {
  display: flex; align-items: center; gap: var(--s3);
  height: 40px; padding: 0 0 0 16px; margin-bottom: var(--s5);
  overflow: hidden; white-space: nowrap;
}
.rail-mark { flex: 0 0 24px; width: 24px; height: 24px; }
.rail-word {
  font-size: 17px; letter-spacing: -0.02em; font-weight: 600;
  opacity: 0; transform: translateX(-6px);
  transition: opacity 200ms var(--ease) 60ms, transform 200ms var(--ease) 60ms;
}
.rail:hover .rail-word, .rail.pinned .rail-word { opacity: 1; transform: none; }
.rail-word b { font-weight: 600; }
.rail-word i { font-family: var(--serif); font-style: italic; color: var(--accent); font-weight: 400; }
.rail-np-mark { cursor: pointer; }
.rail-np-word { font-size: 12px; cursor: pointer; }
.rail-np-word b { font-weight: 600; color: var(--text); }
.rail-np-word i { font-weight: 400; color: var(--text-2); font-style: normal; font-family: inherit; }
.rail:hover .rail-np-word { opacity: 1; }

.rail-nav { display: flex; flex-direction: column; gap: 2px; padding: 0 8px; }

.rail-item {
  display: flex; align-items: center; gap: var(--s3);
  height: 40px; padding: 0 8px; border-radius: var(--r-sm);
  color: var(--text-3); cursor: pointer; position: relative;
  white-space: nowrap; overflow: hidden;
  transition: color 160ms var(--ease), background 160ms var(--ease);
}
.rail-item svg { flex: 0 0 22px; width: 22px; height: 22px; stroke-width: 1.6; }
.rail-item .rail-label {
  font-family: var(--mono); font-size: 12px; font-weight: 500; letter-spacing: 0.02em;
  opacity: 0; transform: translateX(-6px);
  transition: opacity 180ms var(--ease) 40ms, transform 180ms var(--ease) 40ms;
}
.rail:hover .rail-label, .rail.pinned .rail-label { opacity: 1; transform: none; }
.rail-item:hover { color: var(--text); background: rgba(255,255,255,0.04); }
.rail-item.active { color: var(--text); background: var(--accent-ghost); }
.rail-item.active::before {
  content: ""; position: absolute; left: -8px; top: 9px; bottom: 9px; width: 2px;
  background: var(--accent); border-radius: 0 3px 3px 0;
  box-shadow: 0 0 12px var(--accent-glow);
}
.rail-item .rail-count {
  margin-left: auto; font-family: var(--mono); font-size: 10.5px;
  color: var(--text-3); background: var(--surface-2);
  border: 1px solid var(--line); border-radius: 99px; padding: 1px 7px;
  opacity: 0; transition: opacity 180ms var(--ease) 40ms;
}
.rail:hover .rail-count, .rail.pinned .rail-count { opacity: 1; }

.rail-spacer { flex: 1; }

.rail-foot { padding: 0 8px; border-top: 1px solid var(--line); padding-top: var(--s3); margin-top: var(--s3); }
.rail-user {
  display: flex; align-items: center; gap: var(--s3);
  height: 44px; padding: 0 6px; border-radius: var(--r-sm); cursor: pointer;
  overflow: hidden; white-space: nowrap; transition: background 160ms var(--ease);
}
.rail-user:hover { background: rgba(255,255,255,0.04); }
.rail-avatar {
  flex: 0 0 30px; width: 30px; height: 30px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-d));
  display: grid; place-items: center; font-size: 12px; font-weight: 600; color: #fff;
}
.rail-user-meta { min-width: 0; opacity: 0; transition: opacity 180ms var(--ease) 40ms; }
.rail:hover .rail-user-meta, .rail.pinned .rail-user-meta { opacity: 1; }
.rail-user-name { font-size: 12.5px; font-weight: 500; line-height: 1.2; }
.rail-user-mail { font-size: 11px; color: var(--text-3); line-height: 1.3; overflow: hidden; text-overflow: ellipsis; }

/* keyboard hint pill that floats when collapsed */
.rail-hint {
  position: absolute; bottom: 14px; left: 50%; transform: translateX(-50%);
  font-family: var(--mono); font-size: 9.5px; color: var(--text-4);
  border: 1px solid var(--line); border-radius: var(--r-xs); padding: 2px 5px;
  opacity: 0; transition: opacity 180ms var(--ease);
}

/* ══ MAIN COLUMN ══════════════════════════════ */
.main {
  flex: 1; min-width: 0; position: relative; z-index: 1;
  display: flex; flex-direction: column;
  overflow-y: auto; overflow-x: hidden;
}
.view { min-height: 100%; }

/* page enter transition */
.view-enter { animation: viewEnter 200ms var(--ease) both; }
@keyframes viewEnter {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: none; }
}

.wrap { max-width: 1320px; margin: 0 auto; padding: var(--s7) var(--s7) 120px; }

/* ── Page header ─────────────────────────────── */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--s5); margin-bottom: var(--s6); }
/* Title block (first child) always claims remaining width so the h1 never
   collapses to min-content and wraps under its own subtitle. */
.page-head > div:first-child { flex: 1 1 auto; min-width: 0; }
.page-head h1 { font-size: 24px; font-weight: 700; letter-spacing: -0.01em; line-height: 1.15; text-wrap: balance; }
.page-head h1 i { font-family: var(--serif); font-style: italic; font-weight: 400; color: var(--accent); }
.page-head p { color: var(--text-3); font-size: 13.5px; margin-top: 6px; }
.page-head-actions { display: flex; align-items: center; gap: var(--s2); flex-shrink: 0; }

/* ══ BUTTONS ══════════════════════════════════ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s2);
  font-family: var(--ui); font-size: 13px; font-weight: 500; letter-spacing: -0.01em;
  height: 34px; padding: 0 14px; border-radius: var(--r-sm);
  border: 1px solid var(--line-2); background: var(--surface-2); color: var(--text);
  cursor: pointer; white-space: nowrap; user-select: none;
  transition: background 140ms var(--ease), border-color 140ms var(--ease), transform 80ms var(--ease), box-shadow 140ms var(--ease);
}
.btn svg { width: 15px; height: 15px; stroke-width: 1.8; }
.btn:hover { background: var(--surface-3); border-color: var(--line-3); }
.btn:active { transform: translateY(1px); }

.btn-primary {
  background: var(--accent); border-color: transparent; color: var(--accent-ink);
  position: relative; overflow: hidden;
}
.btn-primary:hover { background: var(--accent-h); box-shadow: 0 0 0 3px var(--accent-ring); }
.btn-primary:active { background: var(--accent-d); }
/* shimmer sweep */
.btn-primary.shimmer::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(110deg, transparent 30%, rgba(255,255,255,0.22) 50%, transparent 70%);
  transform: translateX(-120%); transition: none;
}
.btn-primary.shimmer:hover::after { animation: shimmer 900ms var(--ease); }
@keyframes shimmer { to { transform: translateX(120%); } }

.btn-ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn-ghost:hover { background: rgba(255,255,255,0.05); color: var(--text); }

.btn-lg { height: 42px; padding: 0 20px; font-size: 14px; border-radius: var(--r-sm); }
.btn-sm { height: 28px; padding: 0 10px; font-size: 12px; }
.btn-icon { width: 34px; padding: 0; }
.btn-icon.btn-sm { width: 28px; }
.btn.on { background: var(--ok); border-color: transparent; color: #fff; }
.btn.on.btn-primary { background: var(--ok); box-shadow: none; }

.btn:disabled { opacity: 0.4; pointer-events: none; }

.link {
  color: var(--text-3); cursor: pointer; font-size: 12.5px;
  background: none; border: none; font-family: var(--ui);
  transition: color 140ms var(--ease);
}
.link:hover { color: var(--text); }

/* ══ CHIPS / PILLS / BADGES ═══════════════════ */
.chip {
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
  font-family: var(--mono); font-size: 10.5px; letter-spacing: 0.02em;
  padding: 3px 8px; border-radius: var(--r-xs);
  border: 1px solid var(--line); color: var(--text-3); background: var(--surface);
}
.chip .dot { flex: 0 0 6px; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.chip.ok   { color: var(--ok);   border-color: rgba(78,192,126,0.3);  background: var(--ok-bg); }
.chip.warn { color: var(--warn); border-color: rgba(214,162,92,0.3);  background: var(--warn-bg); }
.chip.err  { color: var(--err);  border-color: rgba(240,98,110,0.3);  background: var(--err-bg); }

/* pill toggle group */
.pills { display: inline-flex; gap: 3px; padding: 3px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); }
.pill {
  font-size: 12.5px; font-weight: 500; padding: 5px 14px; border-radius: var(--r-sm);
  color: var(--text-3); cursor: pointer; background: transparent; border: none;
  transition: color 140ms var(--ease), background 140ms var(--ease);
}
.pill:hover { color: var(--text); }
.pill.active { color: var(--accent-ink); background: var(--accent); }
[data-accent] .pill.active { box-shadow: 0 1px 8px var(--accent-glow); }

/* ══ INPUTS ═══════════════════════════════════ */
.input {
  width: 100%; height: 38px; padding: 0 12px;
  background: var(--surface-2); border: 1px solid var(--line-2); border-radius: var(--r-sm);
  color: var(--text); font-family: var(--ui); font-size: 13.5px;
  transition: border-color 150ms var(--ease), box-shadow 150ms var(--ease), background 150ms var(--ease);
}
.input::placeholder { color: var(--text-4); }
.input:focus { outline: none; border-color: var(--accent-line); box-shadow: 0 0 0 3px var(--accent-ring); background: var(--surface-3); }

.search {
  position: relative; display: flex; align-items: center;
}
.search svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); width: 15px; height: 15px; color: var(--text-3); pointer-events: none; }
.search .input { padding-left: 33px; padding-right: 30px; }
/* keyboard-shortcut hint pill (replaces the bare "/" in placeholders) */
.search kbd {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  display: grid; place-items: center; min-width: 17px; height: 17px;
  padding: 0 4px; font-family: var(--mono); font-size: 10px; line-height: 1;
  color: var(--text-4); background: var(--surface); border: 1px solid var(--line-2);
  border-radius: var(--r-xs); pointer-events: none;
  transition: opacity 140ms var(--ease);
}
.search:focus-within kbd { opacity: 0; }

/* ══ CARD / SURFACE ───────────────────────────── */
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
}

/* ══ TOASTS ═══════════════════════════════════ */
#toasts {
  position: fixed; bottom: 20px; right: 20px; z-index: 200;
  display: flex; flex-direction: column-reverse; gap: var(--s2); pointer-events: none;
}
.toast {
  pointer-events: auto; min-width: 260px; max-width: 360px;
  background: var(--surface-3); border: 1px solid var(--line-2); border-radius: var(--r-md);
  padding: 12px 14px 13px; position: relative; overflow: hidden; cursor: pointer;
  box-shadow: 0 20px 50px rgba(0,0,0,0.5);
  animation: toastIn 360ms var(--spring) both;
  display: flex; gap: 10px; align-items: flex-start;
}
.toast.out { animation: toastOut 200ms var(--ease) forwards; }
@keyframes toastIn  { from { opacity: 0; transform: translateY(20px) scale(0.96); } to { opacity: 1; transform: none; } }
@keyframes toastOut { to { opacity: 0; transform: translateX(30px); } }
.toast-ico { flex: 0 0 18px; width: 18px; height: 18px; margin-top: 1px; color: var(--accent); }
.toast.ok .toast-ico { color: var(--ok); }
.toast.err .toast-ico { color: var(--err); }
.toast-body { min-width: 0; }
.toast-title { font-size: 13px; font-weight: 600; }
.toast-msg { font-size: 12px; color: var(--text-3); margin-top: 1px; }
.toast-action { margin-top: 7px; padding: 0; border: 0; background: transparent; color: var(--accent); font: 600 12px var(--ui); cursor: pointer; }
.toast-action:hover { color: var(--accent-h); }
.toast-prog { position: absolute; left: 0; bottom: 0; height: 2px; background: var(--accent); width: 100%; transform-origin: left; animation: toastProg var(--toast-duration, 3s) linear forwards; }
@keyframes toastProg { from { transform: scaleX(1); } to { transform: scaleX(0); } }

/* ══ DETAIL SHEET (right slide-in) ════════════ */
#scrim {
  position: fixed; inset: 0; background: var(--scrim); z-index: 100;
  opacity: 0; pointer-events: none; transition: opacity 320ms var(--ease);
  backdrop-filter: blur(2px);
}
#scrim.show { opacity: 1; pointer-events: auto; }

.sheet {
  position: fixed; top: 0; right: 0; bottom: 0; width: 420px; max-width: 92vw; z-index: 101;
  background: var(--bg-elev); border-left: 1px solid var(--line-2);
  transform: translateX(100%); transition: transform 380ms var(--sheet);
  display: flex; flex-direction: column; box-shadow: -30px 0 80px rgba(0,0,0,0.5);
}
.sheet.show { transform: none; }

/* ── Numbers that count up ──────────────────── */
.count { font-variant-numeric: tabular-nums; }

/* compact density (Tweak) */
[data-density="compact"] { --s5: 18px; --s6: 24px; --s7: 32px; }
[data-density="compact"] .rel-grid { gap: var(--s3); grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); }
[data-density="compact"] .wrap { padding-top: var(--s6); }
[data-density="compact"] .page-head { margin-bottom: var(--s5); }

/* utility */
.hidden { display: none !important; }
.spin { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.muted { color: var(--text-3); }
.flex { display: flex; }
.between { display: flex; align-items: center; justify-content: space-between; }

/* ══ MOBILE TAB BAR ═══════════════════════════ */
.tabbar { display: none; }

@media (max-width: 880px) {
  .rail { display: none; }
  .wrap { padding: var(--s5) var(--s4) 110px; }
  .page-head h1 { font-size: 24px; }
  .tabbar {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 60;
    height: 60px; padding-bottom: env(safe-area-inset-bottom);
    background: rgba(12,12,13,0.82); backdrop-filter: blur(20px) saturate(140%);
    border-top: 1px solid var(--line);
  }
  .tabbar a {
    flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
    color: var(--text-3); text-decoration: none; -webkit-tap-highlight-color: transparent;
  }
  .tabbar a svg { width: 22px; height: 22px; stroke-width: 1.7; transition: transform 220ms var(--spring); }
  .tabbar a span { font-size: 9.5px; font-weight: 500; letter-spacing: 0.01em; }
  .tabbar a.active { color: var(--accent); }
  .tabbar a:active svg { transform: scale(0.82); }
  .sheet { width: 100%; max-width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

/* ── Cookie consent banner ─────────────────────────────────── */
.cookie-banner {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 300;
  display: none; padding: 14px;
}
.cookie-banner.show { display: block; animation: cookieIn 300ms var(--ease) both; }
.cookie-banner-inner {
  max-width: 920px; margin: 0 auto;
  background: var(--surface); border: 1px solid var(--line-2);
  border-radius: var(--r-lg); padding: 14px 18px;
  display: flex; align-items: center; gap: 18px; flex-wrap: wrap;
  box-shadow: 0 12px 44px rgba(0, 0, 0, 0.5);
}
.cookie-banner-text { flex: 1; min-width: 240px; font-size: 13px; line-height: 1.5; color: var(--text-2); }
.cookie-banner-text strong { display: block; color: var(--text); font-size: 13px; margin-bottom: 2px; font-weight: 600; }
.cookie-banner-text a { color: var(--accent); text-decoration: none; }
.cookie-banner-text a:hover { text-decoration: underline; }
.cookie-banner-actions { display: flex; gap: 8px; flex-shrink: 0; }
.cookie-btn {
  font: inherit; font-size: 13px; font-weight: 500; padding: 8px 18px;
  border-radius: var(--r-md); cursor: pointer;
  border: 1px solid var(--line-2); background: transparent; color: var(--text);
  transition: color 160ms var(--ease), background 160ms var(--ease), border-color 160ms var(--ease);
}
.cookie-btn-ghost { color: var(--text-3); }
.cookie-btn-ghost:hover { color: var(--text); border-color: var(--text-3); }
.cookie-btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.cookie-btn-primary:hover { filter: brightness(1.08); }
@keyframes cookieIn { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
@media (max-width: 560px) {
  .cookie-banner-actions { width: 100%; }
  .cookie-btn { flex: 1; }
}
