/* ============================================================
   ShortRex — Design tokens + app shell + shared components
   ============================================================ */

:root {
  /* Surfaces */
  --bg:        oklch(0.14  0.008 285);
  --bg-2:      oklch(0.165 0.009 285);
  --surface:   oklch(0.195 0.010 285);
  --surface-2: oklch(0.235 0.011 285);
  --surface-3: oklch(0.285 0.012 285);

  /* Borders */
  --border:    oklch(1 0 0 / 0.07);
  --border-2:  oklch(1 0 0 / 0.12);

  /* Text */
  --text:   oklch(0.97 0.005 285);
  --text-2: oklch(0.78 0.012 285);
  --text-3: oklch(0.58 0.012 285);
  --text-4: oklch(0.42 0.012 285);

  /* Brand — rose accent */
  --accent:      oklch(0.66 0.22 18);
  --accent-h:    oklch(0.72 0.22 18);
  --accent-d:    oklch(0.58 0.22 18);
  --accent-soft: oklch(0.66 0.22 18 / 0.14);
  --accent-glow: oklch(0.66 0.22 18 / 0.35);

  /* Status */
  --ok:     oklch(0.74 0.16 155);
  --warn:   oklch(0.82 0.16  85);
  --info:   oklch(0.72 0.13 230);
  --danger: oklch(0.65 0.22  25);

  /* Type */
  --font-sans:    "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono:    "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --font-display: "Instrument Serif", "Times New Roman", serif;

  /* Radii */
  --r-sm: 6px;
  --r:    10px;
  --r-md: 14px;
  --r-lg: 20px;

  /* Shadows */
  --shadow-1: 0 1px 0 oklch(1 0 0 / 0.04) inset, 0 1px 2px oklch(0 0 0 / 0.4);
  --shadow-2: 0 8px 24px -8px oklch(0 0 0 / 0.5), 0 2px 4px oklch(0 0 0 / 0.3);
  --shadow-glow: 0 0 32px -4px var(--accent-glow);

  /* Sidebar width */
  --sidebar-w: 240px;
}

/* ============================================================
   Reset
   ============================================================ */

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; padding: 0; }
input, textarea, select { font: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--surface-2); border-radius: 99px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: var(--surface-3); }

/* ============================================================
   App shell — sidebar layout
   ============================================================ */

.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  height: 100vh;
  overflow: hidden;
}
.app--compact { --sidebar-w: 76px; }

.main {
  overflow-y: auto;
  overflow-x: hidden;
  position: relative;
  background: var(--bg);
}

/* ============================================================
   Sidebar
   ============================================================ */

.side {
  background: var(--bg-2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 18px 14px;
  gap: 24px;
  overflow: hidden;
  position: relative;
  z-index: 2;
}

.side__brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 6px 0;
  height: 36px;
  flex-shrink: 0;
}
.side__mark {
  width: 28px; height: 28px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--accent), oklch(0.6 0.21 5));
  border-radius: 9px;
  box-shadow: 0 0 0 1px oklch(1 0 0 / 0.06) inset, 0 6px 16px -6px var(--accent-glow);
  color: white;
  flex: 0 0 auto;
}
.side__wordmark {
  font-family: var(--font-display);
  font-size: 22px;
  letter-spacing: 0.2px;
  font-weight: 400;
  white-space: nowrap;
}
.side__wordmark em { font-style: normal; color: var(--accent); }

.side__group { display: flex; flex-direction: column; gap: 2px; }
.side__label {
  font-size: 10.5px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-4);
  padding: 8px 10px 6px;
  white-space: nowrap;
}

.side__item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--r);
  color: var(--text-2);
  font-weight: 500;
  font-size: 13.5px;
  position: relative;
  transition: background 120ms, color 120ms;
  white-space: nowrap;
  text-align: left;
  width: 100%;
  text-decoration: none;
}
.side__item:hover { background: var(--surface); color: var(--text); }
.side__item.is-active { background: var(--surface-2); color: var(--text); }
.side__item.is-active::before {
  content: "";
  position: absolute;
  left: -14px;
  top: 8px; bottom: 8px;
  width: 3px;
  background: var(--accent);
  border-radius: 0 3px 3px 0;
  box-shadow: 0 0 12px var(--accent-glow);
}
.side__item svg { flex: 0 0 auto; }
.side__count {
  margin-left: auto;
  font-size: 11px;
  color: var(--text-4);
  font-variant-numeric: tabular-nums;
  background: var(--surface);
  padding: 2px 6px;
  border-radius: 99px;
  font-weight: 600;
}
.side__item.is-active .side__count { background: var(--accent-soft); color: var(--accent-h); }
.side__spacer { flex: 1; }

.side__user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--r);
  background: var(--surface);
  border: 1px solid var(--border);
  flex-shrink: 0;
}
.side__avatar {
  width: 30px; height: 30px;
  border-radius: 8px;
  background: linear-gradient(135deg, oklch(0.7 0.16 280), oklch(0.6 0.22 15));
  display: grid; place-items: center;
  font-weight: 700;
  color: white;
  font-size: 13px;
  flex: 0 0 auto;
  overflow: hidden;
}
.side__avatar img { width: 100%; height: 100%; object-fit: cover; }
.side__userinfo { min-width: 0; flex: 1; overflow: hidden; }
.side__username { font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side__planpill {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 10px; font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--accent-h);
}
.side__planpill::before {
  content: "";
  width: 6px; height: 6px;
  border-radius: 99px;
  background: var(--accent);
  animation: pulse 1.6s ease-out infinite;
}

/* Compact sidebar */
.app--compact .side__wordmark,
.app--compact .side__label,
.app--compact .side__item span:not(.side__count),
.app--compact .side__userinfo { display: none; }
.app--compact .side__item { justify-content: center; padding: 10px; }
.app--compact .side__user { justify-content: center; padding: 6px; }
.app--compact .side__count {
  position: absolute; top: 2px; right: 2px;
  padding: 0 4px; min-width: 14px; height: 14px;
  font-size: 9.5px; line-height: 14px;
}

/* ============================================================
   Top utility bar
   ============================================================ */

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 32px;
  background: linear-gradient(to bottom, var(--bg) 65%, transparent);
  backdrop-filter: blur(8px);
}
.topbar__search {
  flex: 1;
  max-width: 420px;
  position: relative;
}
.topbar__search input {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 8px 36px 8px 36px;
  outline: none;
  color: var(--text);
  font-size: 13px;
}
.topbar__search input::placeholder { color: var(--text-4); }
.topbar__search input:focus { border-color: var(--border-2); background: var(--surface-2); }
.topbar__search .topbar__icon {
  position: absolute;
  left: 11px; top: 50%; transform: translateY(-50%);
  color: var(--text-4);
  pointer-events: none;
}
.topbar__kbd {
  position: absolute;
  right: 8px; top: 50%; transform: translateY(-50%);
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--text-4);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 2px 5px;
}
.topbar__spacer { flex: 1; }
.topbar__btn {
  width: 34px; height: 34px;
  border-radius: var(--r);
  display: grid; place-items: center;
  color: var(--text-2);
  background: var(--surface);
  border: 1px solid var(--border);
  transition: background 120ms;
  position: relative;
  flex-shrink: 0;
}
.topbar__btn:hover { background: var(--surface-2); color: var(--text); }
.topbar__btn .dot {
  position: absolute;
  top: 6px; right: 6px;
  width: 8px; height: 8px;
  background: var(--accent);
  border-radius: 99px;
  box-shadow: 0 0 0 2px var(--bg);
}

/* ============================================================
   Page common
   ============================================================ */

.page {
  padding: 8px 32px 80px;
  max-width: 1280px;
}
.page__head {
  display: flex;
  align-items: flex-end;
  gap: 16px;
  margin: 12px 0 28px;
  flex-wrap: wrap;
}
.page__title {
  font-family: var(--font-display);
  font-size: 44px;
  line-height: 1;
  letter-spacing: -0.01em;
  font-weight: 400;
  margin: 0;
}
.page__title em { font-style: italic; color: var(--accent); }
.page__sub { color: var(--text-3); font-size: 13.5px; margin: 6px 0 0; }
.page__actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }

/* ============================================================
   Buttons
   ============================================================ */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 14px;
  border-radius: var(--r);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.005em;
  transition: background 120ms, border-color 120ms, transform 60ms;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  white-space: nowrap;
  text-decoration: none;
}
.btn:hover { background: var(--surface-2); border-color: var(--border-2); }
.btn:active { transform: translateY(1px); }
.btn--primary {
  background: var(--accent);
  border-color: transparent;
  color: white;
  box-shadow: 0 0 0 1px oklch(1 0 0 / 0.12) inset, 0 6px 18px -6px var(--accent-glow);
}
.btn--primary:hover { background: var(--accent-h); border-color: transparent; }
.btn--ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn--ghost:hover { background: var(--surface); color: var(--text); }
.btn--danger { color: var(--danger); }
.btn--danger:hover { background: oklch(0.65 0.22 25 / 0.12); border-color: oklch(0.65 0.22 25 / 0.3); }
.btn--sm { padding: 6px 10px; font-size: 12px; }
.btn--icon { width: 34px; height: 34px; padding: 0; justify-content: center; }
.btn--lg { padding: 12px 18px; font-size: 14px; }
.btn--discord {
  background: oklch(0.5 0.15 270);
  border-color: transparent;
  color: white;
  justify-content: center;
}
.btn--discord:hover { background: oklch(0.55 0.15 270); border-color: transparent; }

/* ============================================================
   Cards
   ============================================================ */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  overflow: hidden;
}

/* ============================================================
   Form elements
   ============================================================ */

.field { display: block; }
.field__label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-2);
  margin: 0 0 6px;
  letter-spacing: 0.02em;
}
.field__label .req { color: var(--accent); }
.field__hint { font-size: 11.5px; color: var(--text-4); margin: 6px 0 0; }
.input, .select, .textarea {
  display: block;
  width: 100%;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 10px 12px;
  font-size: 13.5px;
  outline: none;
  color: var(--text);
  transition: border-color 120ms, background 120ms, box-shadow 120ms;
}
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--accent);
  background: var(--bg);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.input::placeholder { color: var(--text-4); }
.select { appearance: none; cursor: pointer; }

/* ============================================================
   Modal
   ============================================================ */

.modal-backdrop {
  position: fixed; inset: 0;
  background: oklch(0 0 0 / 0.6);
  backdrop-filter: blur(6px);
  display: grid; place-items: center;
  padding: 20px;
  z-index: 100;
  animation: fade 160ms ease;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.modal {
  width: 100%;
  max-width: 480px;
  background: var(--surface);
  border: 1px solid var(--border-2);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-2);
  padding: 28px;
  animation: pop 180ms cubic-bezier(.2,.8,.2,1);
}
@keyframes pop {
  from { opacity: 0; transform: translateY(8px) scale(0.98); }
  to   { opacity: 1; transform: none; }
}
.modal__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 22px;
}
.modal__title {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 28px;
  letter-spacing: -0.01em;
  margin: 0;
  line-height: 1.05;
}
.modal__sub { color: var(--text-3); font-size: 13px; margin: 4px 0 0; }
.modal__close {
  width: 30px; height: 30px;
  border-radius: 8px;
  color: var(--text-3);
  display: grid; place-items: center;
  flex-shrink: 0;
}
.modal__close:hover { background: var(--surface-2); color: var(--text); }
.modal__body { display: flex; flex-direction: column; gap: 16px; }
.modal__foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 24px; }

/* ============================================================
   Pills
   ============================================================ */

.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 99px;
  background: var(--surface-2);
  color: var(--text-2);
  letter-spacing: 0.01em;
}
.pill--accent { background: var(--accent-soft); color: var(--accent-h); }
.pill--ok     { background: oklch(0.74 0.16 155 / 0.14); color: var(--ok); }
.pill--warn   { background: oklch(0.82 0.16  85 / 0.14); color: var(--warn); }
.pill--info   { background: oklch(0.72 0.13 230 / 0.14); color: var(--info); }
.pill--danger { background: oklch(0.65 0.22 25 / 0.14); color: var(--danger); }
.pill__dot { width: 6px; height: 6px; border-radius: 99px; background: currentColor; }

/* ============================================================
   Code / mono token
   ============================================================ */

.mono {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--accent-h);
  background: var(--accent-soft);
  padding: 2px 7px;
  border-radius: 6px;
}

/* ============================================================
   Tooltip
   ============================================================ */

.tip { position: relative; }
.tip::after {
  content: attr(data-tip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%; transform: translateX(-50%);
  background: var(--bg);
  border: 1px solid var(--border-2);
  color: var(--text);
  font-size: 11px;
  padding: 4px 8px;
  border-radius: 6px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 120ms;
  z-index: 50;
}
.tip:hover::after { opacity: 1; }

/* ============================================================
   Stat block
   ============================================================ */

.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 24px;
}
.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 18px;
  position: relative;
  overflow: hidden;
}
.stat__label {
  font-size: 11.5px;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
  margin: 0;
}
.stat__value {
  font-family: var(--font-display);
  font-size: 40px;
  line-height: 1.05;
  margin: 8px 0 4px;
  font-weight: 400;
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
}
.stat__delta { font-size: 11.5px; color: var(--ok); font-weight: 600; }
.stat__delta--down { color: var(--danger); }
.stat__spark {
  position: absolute;
  inset: auto 0 0 0;
  height: 36px;
  opacity: 0.7;
  pointer-events: none;
}

/* ============================================================
   Panels (shared between music + admin)
   ============================================================ */

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  overflow: hidden;
}
.panel__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px 10px;
}
.panel__title {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-3);
  margin: 0;
}
.panel__action { font-size: 11.5px; color: var(--text-3); background: none; border: none; cursor: pointer; }
.panel__action:hover { color: var(--text); }

/* ============================================================
   Premium locked overlay (blur + lock icon)
   ============================================================ */

.premium-gate {
  position: relative;
  border-radius: var(--r-md);
  overflow: hidden;
}
.premium-gate__overlay {
  position: absolute;
  inset: 0;
  backdrop-filter: blur(8px);
  background: oklch(0 0 0 / 0.45);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  z-index: 10;
  border-radius: var(--r-md);
}
.premium-gate__icon {
  width: 44px; height: 44px;
  background: var(--surface-2);
  border: 1px solid var(--border-2);
  border-radius: 50%;
  display: grid; place-items: center;
  color: var(--accent);
}
.premium-gate__label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-2);
}
.premium-gate__cta {
  font-size: 11.5px;
  color: var(--text-3);
}

/* ============================================================
   Error toast
   ============================================================ */

.err-toast {
  position: fixed;
  bottom: 24px; right: 24px;
  background: var(--danger);
  color: white;
  padding: 12px 16px;
  border-radius: var(--r);
  font-size: 13px;
  font-weight: 500;
  z-index: 200;
  max-width: 360px;
  box-shadow: var(--shadow-2);
  animation: slideup 200ms ease;
}
@keyframes slideup {
  from { transform: translateY(16px); opacity: 0; }
  to   { transform: none; opacity: 1; }
}

/* ============================================================
   Animations
   ============================================================ */

@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 var(--accent-glow); }
  100% { box-shadow: 0 0 0 10px transparent; }
}
