/* Shared design system: tokens + primitives used by the player and the admin panel. */

:root {
  --bg: #05060a;
  --fg: #f5f6fa;
  --fg-2: rgba(245, 246, 250, 0.68);
  --fg-3: rgba(245, 246, 250, 0.42);
  --glass: rgba(255, 255, 255, 0.055);
  --glass-strong: rgba(255, 255, 255, 0.09);
  --glass-line: rgba(255, 255, 255, 0.11);
  --glass-hi: rgba(255, 255, 255, 0.16);
  --shadow: 0 30px 80px -20px rgba(0, 0, 0, 0.55);
  --accent: #9fb4ff;
  --accent-2: #c79bff;
  --glow: rgba(150, 170, 255, 0.45);
  --ok: #7fe0a8;
  --warn: #ffc070;
  --danger: #ff6b81;
  --radius: 28px;
  --radius-sm: 16px;
  --gutter: clamp(16px, 3.2vw, 40px);
  --font: 'Manrope', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font);
  font-feature-settings: 'ss01', 'cv11';
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
button, input, select, textarea { font: inherit; color: inherit; }
svg { display: block; }
:focus-visible { outline: 2px solid rgba(255, 255, 255, 0.7); outline-offset: 3px; }
[hidden] { display: none !important; }
/* No transitions until the first frame, so panels do not slide in on page load. */
.preload *, .preload *::before, .preload *::after { transition: none !important; }

/* ---------- glass surfaces ---------- */
.glass {
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.085), rgba(255, 255, 255, 0.03));
  border: 1px solid var(--glass-line);
  border-radius: var(--radius);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.09), var(--shadow);
  backdrop-filter: blur(26px) saturate(150%);
  -webkit-backdrop-filter: blur(26px) saturate(150%);
}
.glass-pill {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--glass-line);
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  border-radius: 999px;
}

/* ---------- buttons ---------- */
.icon-btn {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  cursor: pointer;
  padding: 0;
  transition: background 0.3s, transform 0.2s var(--ease);
}
.icon-btn:active { transform: scale(0.94); }
.icon-btn svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn.bare { background: none; border: 0; width: 36px; height: 36px; border-radius: 50%; }

.pill-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 32px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid var(--glass-line);
  background: rgba(255, 255, 255, 0.08);
  font-size: 13px;
  font-weight: 600;
  color: var(--fg);
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.25s, opacity 0.25s, transform 0.2s var(--ease);
}
.pill-btn:active { transform: scale(0.97); }
.pill-btn:disabled { opacity: 0.45; cursor: default; }
.pill-btn.primary { background: #fff; color: #0b0c10; border-color: transparent; }
.pill-btn.accent { background: linear-gradient(120deg, var(--accent), var(--accent-2)); color: #0b0c10; border-color: transparent; }
.pill-btn.danger { color: var(--danger); }
.pill-btn.sm { height: 26px; padding: 0 10px; font-size: 12px; }

/* ---------- chips ---------- */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 26px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  color: var(--fg-2);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
  white-space: nowrap;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chip b { color: var(--fg); font-weight: 700; }
.chip.new, .chip.accent { color: #111; background: linear-gradient(120deg, var(--accent), var(--accent-2)); border-color: transparent; }
.chip.ok { color: var(--ok); border-color: rgba(127, 224, 168, 0.3); }
.chip.warn { color: var(--warn); border-color: rgba(255, 192, 112, 0.3); }
.chip.danger { color: var(--danger); border-color: rgba(255, 107, 129, 0.3); }
.dot { width: 8px; height: 8px; border-radius: 50%; flex: none; background: var(--c, var(--accent)); box-shadow: 0 0 10px var(--c, var(--accent)); }

/* ---------- form controls ---------- */
.field {
  width: 100%;
  height: 42px;
  padding: 0 14px;
  border-radius: 14px;
  border: 1px solid var(--glass-line);
  background: rgba(0, 0, 0, 0.25);
  outline: none;
  transition: border-color 0.25s, background 0.25s;
}
textarea.field { height: auto; min-height: 120px; padding: 12px 14px; resize: vertical; line-height: 1.5; }
.field:focus { border-color: rgba(255, 255, 255, 0.35); background: rgba(0, 0, 0, 0.35); }
.field::placeholder { color: var(--fg-3); }
select.field { appearance: none; -webkit-appearance: none; padding-right: 32px; background-image: linear-gradient(45deg, transparent 50%, var(--fg-2) 50%), linear-gradient(135deg, var(--fg-2) 50%, transparent 50%); background-position: calc(100% - 18px) 18px, calc(100% - 13px) 18px; background-size: 5px 5px; background-repeat: no-repeat; }
select.field option { background: #15161d; }

input[type='range'] {
  -webkit-appearance: none;
  appearance: none;
  width: 96px;
  height: 24px;
  background: transparent;
  cursor: pointer;
  --v: 100%;
}
input[type='range']::-webkit-slider-runnable-track { height: 4px; border-radius: 4px; background: linear-gradient(90deg, #fff var(--v), rgba(255, 255, 255, 0.18) var(--v)); }
input[type='range']::-moz-range-track { height: 4px; border-radius: 4px; background: rgba(255, 255, 255, 0.18); }
input[type='range']::-moz-range-progress { height: 4px; border-radius: 4px; background: #fff; }
input[type='range']::-webkit-slider-thumb { -webkit-appearance: none; width: 14px; height: 14px; margin-top: -5px; border-radius: 50%; background: #fff; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4); }
input[type='range']::-moz-range-thumb { width: 14px; height: 14px; border: 0; border-radius: 50%; background: #fff; }

.toggle { display: flex; align-items: center; gap: 14px; padding: 10px 0; cursor: pointer; }
.toggle input { appearance: none; -webkit-appearance: none; flex: none; width: 44px; height: 26px; border-radius: 999px; background: rgba(255, 255, 255, 0.14); position: relative; cursor: pointer; transition: background 0.3s; margin: 0; }
.toggle input::after { content: ''; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: transform 0.3s var(--ease); box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35); }
.toggle input:checked { background: linear-gradient(120deg, var(--accent), var(--accent-2)); }
.toggle input:checked::after { transform: translateX(18px); }
.toggle span { display: grid; gap: 2px; }
.toggle b { font-size: 14px; font-weight: 700; }
.toggle small { font-size: 12px; color: var(--fg-3); }

/* ---------- copyable link ---------- */
.copy-link { display: flex; gap: 8px; align-items: center; padding: 4px 4px 4px 12px; border-radius: 12px; background: rgba(0, 0, 0, 0.25); border: 1px solid var(--glass-line); min-width: 0; }
.copy-link code { flex: 1; min-width: 0; font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--fg-2); background: none; padding: 0; }
.copy-link .tag { font-size: 11px; font-weight: 800; color: var(--fg-3); letter-spacing: 0.08em; }

/* Hover feedback only where there is a real pointer: on touch screens :hover sticks after a tap. */
@media (hover: hover) {
  .icon-btn:hover { background: rgba(255, 255, 255, 0.12); }
  .icon-btn.bare:hover { background: rgba(255, 255, 255, 0.08); }
  .pill-btn:hover { background: rgba(255, 255, 255, 0.14); }
  .pill-btn.primary:hover { background: #fff; box-shadow: 0 6px 24px -6px var(--glow); }
  .tab:hover { color: var(--fg); }
}

/* ---------- text helpers ---------- */
.eyebrow-label { margin: 0 0 12px; font-size: 11px; font-weight: 800; letter-spacing: 0.16em; text-transform: uppercase; color: var(--fg-3); }
.hint { margin: 0 0 12px; font-size: 13px; color: var(--fg-2); line-height: 1.5; }
.muted { color: var(--fg-3); }
.ellipsis { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }

/* ---------- tabs (segmented control) ---------- */
.tabs { display: flex; gap: 4px; padding: 4px; border-radius: 999px; background: rgba(0, 0, 0, 0.22); border: 1px solid var(--glass-line); }
.tab {
  position: relative;
  flex: 1;
  height: 34px;
  padding: 0 14px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  font-size: 13px;
  font-weight: 700;
  color: var(--fg-2);
  cursor: pointer;
  transition: background 0.3s var(--ease), color 0.3s;
  white-space: nowrap;
}
.tab[aria-selected='true'] { background: rgba(255, 255, 255, 0.14); color: var(--fg); box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12); }
.tabs.seg .tab { height: 30px; font-size: 12px; padding: 0 10px; }
.tabs.seg .tab[aria-checked='true'] { background: rgba(255, 255, 255, 0.14); color: var(--fg); box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12); }
.setting { display: grid; gap: 10px; padding: 10px 0; }
.setting > span { display: grid; gap: 2px; }
.setting b { font-size: 14px; font-weight: 700; }
.setting small { font-size: 12px; color: var(--fg-3); }
.tab-badge { display: inline-grid; place-items: center; min-width: 18px; height: 18px; margin-left: 6px; padding: 0 5px; border-radius: 9px; font-style: normal; font-size: 11px; background: linear-gradient(120deg, var(--accent), var(--accent-2)); color: #111; vertical-align: 1px; }

/* ---------- toast ---------- */
.toast {
  position: fixed;
  z-index: 20;
  left: 50%;
  bottom: calc(var(--safe-b) + 24px);
  transform: translate(-50%, 20px);
  max-width: min(480px, calc(100vw - 32px));
  padding: 12px 18px;
  border-radius: 18px;
  font-size: 14px;
  font-weight: 600;
  opacity: 0;
  transition: opacity 0.4s var(--ease), transform 0.4s var(--ease);
  pointer-events: none;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- media row (cover + two lines), used in lists everywhere ---------- */
/* minmax(0, 1fr): the text column may shrink below its content, so long titles never push the row sideways. */
.media-row { display: grid; grid-template-columns: 44px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 6px; border-radius: 14px; }
.media-row img, .media-row .thumb { width: 44px; height: 44px; border-radius: 10px; object-fit: cover; background: rgba(255, 255, 255, 0.06); }
.media-row .mr-text { min-width: 0; display: grid; gap: 1px; }
.media-row .mr-title {
  font-weight: 700;
  font-size: 14px;
  line-height: 1.3;
  overflow-wrap: anywhere;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.media-row .mr-sub { font-size: 12px; color: var(--fg-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* Tap a row to read the full title. */
.media-row.expanded .mr-title { -webkit-line-clamp: unset; }
.media-row.expanded .mr-sub { white-space: normal; overflow-wrap: anywhere; }
.list, .media-list { grid-template-columns: minmax(0, 1fr); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0.01ms !important; }
}
