/* Blazingflix dashboard — shares the "Ember" design system with the app (same tokens, type, radii and motion).
   Tokens → base → shell → components → screens. Dark is default; light via [data-theme="light"]. */

:root {
  color-scheme: dark;
  --accent: #f9af12;
  --accent-hi: #ffc83d;
  --ember: #ff6a3a;
  --grad: linear-gradient(135deg, #ffd04a 0%, #ffa11a 48%, #ff6a3a 100%);
  --on-grad: #1b1100;
  --bg: #0a0a10;
  --bg-2: #0f0f17;
  --surface: #15151f;
  --surface-2: #1e1e2a;
  --surface-3: #292937;
  --text: #f5f4fa;
  --muted: #9d9cb0;
  --line: rgba(255,255,255,.09);
  --glass: rgba(24,24,34,.62);
  --glass-strong: rgba(18,18,26,.9);
  --scrim: rgba(4,4,8,.66);
  --good: #3ddc97;
  --bad: #ff5d6c;
  --blue: #6aa8ff;
  --violet: #b693ff;
  --shadow: 0 18px 50px rgba(0,0,0,.45);
  --r-sm: 10px;
  --r: 16px;
  --r-lg: 26px;
  --side: 248px;
  --pad: clamp(16px, 2.4vw, 36px);
  --ease: cubic-bezier(.2,.8,.2,1);
  font-family: "Figtree", system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}
:root[data-theme="light"] {
  color-scheme: light;
  --accent: #c47600;
  --accent-hi: #a86300;
  --bg: #f4f2ec;
  --bg-2: #efece4;
  --surface: #ffffff;
  --surface-2: #f1eee6;
  --surface-3: #e5e1d6;
  --text: #17150f;
  --muted: #625e53;
  --line: rgba(20,16,0,.12);
  --glass: rgba(255,255,255,.7);
  --glass-strong: rgba(255,255,255,.94);
  --scrim: rgba(20,16,0,.42);
  --good: #12935f;
  --bad: #d23547;
  --blue: #2c6fd6;
  --violet: #7c4fd6;
  --shadow: 0 18px 44px rgba(60,40,0,.16);
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { min-width: 320px; background: var(--bg); -webkit-text-size-adjust: 100%; }
body { margin: 0; min-height: 100dvh; background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.5; }
body, button, input, select, textarea { font: inherit; }
button, a, input, select { -webkit-tap-highlight-color: transparent; }
a { color: inherit; text-decoration: none; }
button { color: inherit; cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 6px; }
img { display: block; max-width: 100%; }
h1, h2, h3, h4, p { margin: 0; }
h1 { font-size: clamp(26px, 3vw, 36px); letter-spacing: -.03em; font-weight: 800; line-height: 1.1; }
h2 { font-size: 18px; letter-spacing: -.01em; font-weight: 800; }
h3 { font-size: 15px; font-weight: 700; }
.i { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
:root[data-theme="light"] .only-dark, :root:not([data-theme="light"]) .only-light { display: none; }
.eyebrow { color: var(--accent); font-size: 11px; font-weight: 800; letter-spacing: .16em; text-transform: uppercase; }
.muted { color: var(--muted); }
.mono { font-variant-numeric: tabular-nums; }
small { font-size: 12px; color: var(--muted); }
kbd { font: 600 11px/1 inherit; padding: 4px 7px; border: 1px solid var(--line); border-radius: 6px; color: var(--muted); background: var(--surface-2); }

/* ---------------------------------------------------------------- shell */
.shell { display: grid; grid-template-columns: var(--side) minmax(0, 1fr); min-height: 100dvh; }
.side { position: sticky; top: 0; height: 100dvh; display: flex; flex-direction: column; gap: 6px; padding: 18px 14px; background: var(--bg-2); border-right: 1px solid var(--line); overflow-y: auto; }
.side-brand { display: flex; align-items: center; gap: 12px; padding: 6px 10px 18px; }
.side-brand span { display: flex; align-items: center; line-height: 1; }
.side-brand strong { font-size: 17px; font-weight: 900; letter-spacing: -.02em; }
.side-brand small { font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--accent); font-weight: 800; }
.side-nav { display: grid; gap: 2px; flex: 1; align-content: start; }
.side-group { margin: 16px 12px 6px; font-size: 10.5px; font-weight: 800; letter-spacing: .16em; text-transform: uppercase; color: var(--muted); }
.side-link { display: flex; align-items: center; gap: 12px; width: 100%; padding: 10px 12px; border: 0; border-radius: 12px; background: none; color: var(--muted); font-weight: 650; font-size: 14.5px; text-align: left; transition: color .2s, background .2s; }
.side-link:hover { color: var(--text); background: var(--surface-2); }
.side-link[aria-current="page"] { color: var(--text); background: var(--surface-2); box-shadow: inset 3px 0 0 var(--accent); }
.side-link[aria-current="page"] .i { color: var(--accent); }
.side-foot { display: grid; gap: 2px; padding-top: 10px; border-top: 1px solid var(--line); }
.side-scrim { position: fixed; inset: 0; z-index: 29; background: var(--scrim); }

.stage { min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px; padding: 12px var(--pad); background: color-mix(in srgb, var(--bg) 82%, transparent); backdrop-filter: blur(18px) saturate(1.4); -webkit-backdrop-filter: blur(18px) saturate(1.4); border-bottom: 1px solid var(--line); }
.menu-btn { display: none; }
.search-pill { flex: 1; max-width: 460px; display: flex; align-items: center; gap: 10px; height: 44px; padding: 0 12px 0 14px; border: 1px solid var(--line); border-radius: 999px; background: var(--glass); color: var(--muted); font-size: 14px; text-align: left; }
.search-pill span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search-pill:hover { border-color: color-mix(in srgb, var(--accent) 50%, var(--line)); color: var(--text); }
.topbar-add { margin-left: auto; }
.me { display: flex; align-items: center; gap: 6px; }
.me-chip { display: flex; align-items: center; gap: 10px; padding: 4px 12px 4px 4px; border-radius: 999px; border: 1px solid var(--line); background: var(--glass); }
.me-avatar { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; background: var(--grad); color: var(--on-grad); font-weight: 900; }
.me-name { display: grid; line-height: 1.1; font-weight: 700; font-size: 13.5px; }
.me-name small { font-size: 11px; }
.icon-btn { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 50%; border: 1px solid var(--line); background: var(--glass); color: var(--text); }
.icon-btn:hover { border-color: var(--accent); }

.content { padding: clamp(18px, 2.6vw, 34px) var(--pad) 80px; display: grid; gap: 22px; align-content: start; width: 100%; max-width: 1480px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.page-head > div:first-child { display: grid; gap: 6px; min-width: 0; }
.page-sub { color: var(--muted); max-width: 70ch; }
.page-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* ---------------------------------------------------------------- controls */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 42px; padding: 0 18px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface-2); color: var(--text); font-weight: 700; font-size: 14px; white-space: nowrap; transition: transform .15s var(--ease), border-color .2s, background .2s, box-shadow .2s; }
.btn:hover { border-color: color-mix(in srgb, var(--accent) 55%, var(--line)); }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn--primary { border: 0; background: var(--grad); color: var(--on-grad); box-shadow: 0 8px 26px rgba(255,140,30,.28); }
.btn--primary:hover { box-shadow: 0 10px 32px rgba(255,140,30,.42); }
.btn--danger { background: color-mix(in srgb, var(--bad) 16%, var(--surface-2)); border-color: color-mix(in srgb, var(--bad) 45%, var(--line)); color: var(--bad); }
.btn--danger:hover { background: var(--bad); color: #fff; border-color: var(--bad); }
.btn--ghost { background: transparent; }
.btn--sm { min-height: 36px; padding: 0 14px; font-size: 13px; }
.btn--block { width: 100%; }
.inline-form { display: inline; margin: 0; }

.field { display: grid; gap: 7px; min-width: 0; }
.field-label { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; font-size: 12.5px; font-weight: 700; color: var(--muted); }
.field-label small { font-weight: 500; }
input[type="text"], input[type="search"], input[type="email"], input[type="password"], input[type="number"], input[type="url"], input[type="date"], input[type="datetime-local"], select, textarea {
  width: 100%; min-height: 44px; padding: 10px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-2); color: var(--text); font-size: 14px; outline: 0; transition: border-color .2s, box-shadow .2s; }
textarea { resize: vertical; line-height: 1.5; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 20px) 50%, calc(100% - 14px) 50%; background-size: 6px 6px; background-repeat: no-repeat; padding-right: 36px; }
input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--accent); }
input[type="file"] { padding: 9px 12px; font-size: 14px; }
.check { display: flex; align-items: center; gap: 10px; font-weight: 650; cursor: pointer; }
.stack { display: grid; gap: 16px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.form-grid .field--wide { grid-column: 1 / -1; }
.form-grid .field--third { grid-column: span 1; }

.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 999px; font-size: 11.5px; font-weight: 800; letter-spacing: .02em; background: var(--surface-3); color: var(--muted); white-space: nowrap; }
.badge--accent { background: color-mix(in srgb, var(--accent) 18%, transparent); color: var(--accent); }
.badge--green { background: color-mix(in srgb, var(--good) 18%, transparent); color: var(--good); }
.badge--red { background: color-mix(in srgb, var(--bad) 18%, transparent); color: var(--bad); }
.badge--blue { background: color-mix(in srgb, var(--blue) 18%, transparent); color: var(--blue); }
.badge--violet { background: color-mix(in srgb, var(--violet) 18%, transparent); color: var(--violet); }

.flash { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-radius: var(--r-sm); border: 1px solid var(--line); background: var(--surface); font-weight: 600; }
.flash--ok { border-color: color-mix(in srgb, var(--good) 45%, var(--line)); background: color-mix(in srgb, var(--good) 10%, var(--surface)); }
.flash--ok .i { color: var(--good); }
.flash--error { border-color: color-mix(in srgb, var(--bad) 50%, var(--line)); background: color-mix(in srgb, var(--bad) 10%, var(--surface)); }
.flash--error .i { color: var(--bad); }
.flash--info .i { color: var(--blue); }

.card { padding: clamp(16px, 2vw, 24px); border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); display: grid; gap: 16px; align-content: start; min-width: 0; }
.card--flat { background: transparent; }
.card.narrow { max-width: 560px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.card-head p { color: var(--muted); font-size: 13px; }
.danger-zone { border-color: color-mix(in srgb, var(--bad) 35%, var(--line)); }

.grid { display: grid; gap: 18px; }
.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.split { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 18px; align-items: start; }

.stat { position: relative; display: grid; gap: 4px; padding: 18px 20px; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); overflow: hidden; }
.stat-icon { position: absolute; top: 16px; right: 16px; display: grid; place-items: center; width: 36px; height: 36px; border-radius: 12px; background: var(--surface-2); color: var(--accent); }
.stat-label { font-size: 12.5px; font-weight: 700; color: var(--muted); letter-spacing: .02em; }
.stat-value { font-size: clamp(26px, 2.6vw, 34px); font-weight: 900; letter-spacing: -.03em; line-height: 1.1; }
.stat-hint { font-size: 12.5px; color: var(--muted); }
.stat-hint b { color: var(--good); font-weight: 800; }
.stat-hint b.neg { color: var(--bad); }
.stat--hero { background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 22%, var(--surface)), var(--surface) 70%); }

.empty { display: grid; gap: 8px; justify-items: center; padding: 40px 20px; text-align: center; border: 1px dashed var(--line); border-radius: var(--r); color: var(--muted); }
.empty h3 { color: var(--text); font-size: 17px; }

.pager { display: flex; align-items: center; justify-content: center; gap: 6px; flex-wrap: wrap; padding-top: 6px; }
.page { display: grid; place-items: center; min-width: 38px; height: 38px; padding: 0 10px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); font-weight: 700; font-size: 14px; }
a.page:hover { border-color: var(--accent); }
.page--on { background: var(--grad); color: var(--on-grad); border-color: transparent; }
.page--gap { border: 0; background: none; color: var(--muted); }

/* ---------------------------------------------------------------- tables & lists */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { position: sticky; top: 0; padding: 12px 16px; text-align: left; font-size: 11.5px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); background: var(--surface); border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 12px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: color-mix(in srgb, var(--surface-2) 70%, transparent); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table .actions { text-align: right; white-space: nowrap; }
.cell-title { display: flex; align-items: center; gap: 12px; min-width: 220px; }
.cell-title strong { display: block; font-weight: 700; }
.cell-title small { display: block; }
.thumb { width: 38px; height: 56px; flex: none; border-radius: 8px; object-fit: cover; background: var(--surface-3); }
.thumb--wide { width: 96px; height: 54px; }
.avatar { display: grid; place-items: center; width: 38px; height: 38px; flex: none; border-radius: 50%; background: var(--surface-3); font-weight: 800; color: var(--accent); overflow: hidden; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }

.list { display: grid; }
.list-row { display: flex; align-items: center; gap: 14px; padding: 12px 0; border-bottom: 1px solid var(--line); min-width: 0; }
.list-row:last-child { border-bottom: 0; }
.list-row .grow { flex: 1; min-width: 0; }
.list-row .grow strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 700; }
.list-row .grow small { display: block; margin-top: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 10px 22px; margin: 0; }
.kv dt { color: var(--muted); font-weight: 650; font-size: 13.5px; }
.kv dd { margin: 0; font-weight: 600; min-width: 0; overflow-wrap: anywhere; }

/* ---------------------------------------------------------------- toolbar, chips, tabs */
.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.toolbar .search { flex: 1; min-width: 220px; max-width: 420px; position: relative; }
.toolbar .search input { padding-left: 42px; border-radius: 999px; }
.toolbar .search .i { position: absolute; left: 14px; top: 12px; color: var(--muted); }
.toolbar select { width: auto; min-width: 150px; border-radius: 999px; }
[data-titles-results] { display: grid; gap: 22px; min-width: 0; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { display: inline-flex; align-items: center; gap: 8px; padding: 8px 15px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); font-weight: 700; font-size: 13.5px; color: var(--muted); }
.chip:hover { color: var(--text); border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); }
.chip[aria-current="true"], .chip.is-on { background: var(--text); color: var(--bg); border-color: var(--text); }
.chip em { font-style: normal; font-size: 12px; opacity: .7; }
.tabs { display: flex; gap: 4px; padding: 4px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); width: max-content; max-width: 100%; overflow-x: auto; }
.tabs a, .tabs button { padding: 8px 18px; border: 0; border-radius: 999px; background: none; font-weight: 700; font-size: 14px; color: var(--muted); white-space: nowrap; }
.tabs [aria-current="page"], .tabs .is-on { background: var(--text); color: var(--bg); }

/* ---------------------------------------------------------------- title cards */
.titles { display: grid; grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); gap: 18px; }
.tcard { position: relative; display: grid; gap: 10px; align-content: start; }
.tcard-poster { position: relative; aspect-ratio: 2 / 3; border-radius: 14px; overflow: hidden; background: var(--surface-3); border: 1px solid var(--line); transition: transform .25s var(--ease), border-color .2s, box-shadow .25s; }
.tcard-poster img { width: 100%; height: 100%; object-fit: cover; }
.tcard:hover .tcard-poster { transform: translateY(-3px); border-color: color-mix(in srgb, var(--accent) 60%, var(--line)); box-shadow: var(--shadow); }
.tcard-tags { position: absolute; top: 8px; left: 8px; display: flex; gap: 5px; flex-wrap: wrap; }
.tcard-tags .badge { background: rgba(8,8,14,.78); backdrop-filter: blur(8px); color: #fff; }
.tcard-body { display: grid; gap: 2px; padding: 0 2px; }
.tcard-body strong { font-weight: 700; font-size: 14px; line-height: 1.3; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.tcard-body small { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.tcard a.cover { position: absolute; inset: 0; z-index: 1; }

/* ---------------------------------------------------------------- charts */
.bars { display: flex; align-items: flex-end; gap: 4px; height: 150px; padding-top: 10px; }
.bar { flex: 1; min-width: 4px; display: grid; align-items: end; height: 100%; position: relative; }
.bar i { display: block; width: 100%; min-height: 3px; border-radius: 6px 6px 3px 3px; background: var(--grad); opacity: .9; transition: opacity .2s; }
.bar:hover i { opacity: 1; }
.bar b { position: absolute; bottom: calc(100% + 6px); left: 50%; translate: -50% 0; padding: 4px 8px; border-radius: 8px; background: var(--text); color: var(--bg); font-size: 11.5px; white-space: nowrap; pointer-events: none; opacity: 0; transition: opacity .15s; z-index: 2; }
.bar:hover b { opacity: 1; }
.bars-axis { display: flex; justify-content: space-between; font-size: 11.5px; color: var(--muted); }
.meter { height: 8px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.meter i { display: block; height: 100%; border-radius: 99px; background: var(--grad); }
.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 13px; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; background: var(--accent); vertical-align: -1px; }

/* ---------------------------------------------------------------- editor */
.editor { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 22px; align-items: start; }
.editor-aside { position: sticky; top: 84px; display: grid; gap: 14px; }
.poster-frame { aspect-ratio: 2 / 3; border-radius: var(--r); overflow: hidden; border: 1px solid var(--line); background: var(--surface-3); }
.poster-frame img { width: 100%; height: 100%; object-fit: cover; }
.backdrop-frame { aspect-ratio: 16 / 9; border-radius: var(--r); overflow: hidden; border: 1px solid var(--line); background: var(--surface-3); }
.backdrop-frame img { width: 100%; height: 100%; object-fit: cover; }
.trailer-frame iframe { display: block; width: 100%; height: 100%; border: 0; }
.side-actions { display: grid; gap: 8px; }
.side-actions .btn, .side-actions .inline-form, .side-actions .inline-form .btn { width: 100%; }
.switch { position: relative; display: inline-flex; align-items: center; gap: 12px; cursor: pointer; font-weight: 650; }
.switch input { position: absolute; opacity: 0; }
.switch i { position: relative; width: 44px; height: 26px; border-radius: 99px; background: var(--surface-3); transition: background .2s; flex: none; }
.switch i::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: transform .2s var(--ease); }
.switch input:checked + i { background: var(--accent); }
.switch input:checked + i::after { transform: translateX(18px); }
.switch input:focus-visible + i { outline: 2px solid var(--accent); outline-offset: 3px; }

.season { border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); overflow: hidden; }
.season > summary { display: flex; align-items: center; gap: 14px; padding: 14px 18px; cursor: pointer; list-style: none; font-weight: 800; }
.season > summary::-webkit-details-marker { display: none; }
.season > summary .badge { margin-left: auto; }
.season[open] > summary { border-bottom: 1px solid var(--line); }
.ep { display: flex; align-items: center; gap: 14px; padding: 10px 18px; border-bottom: 1px solid var(--line); }
.ep:last-child { border-bottom: 0; }
.ep-no { width: 40px; font-weight: 800; color: var(--muted); font-variant-numeric: tabular-nums; }
.ep .grow { flex: 1; min-width: 0; }
.ep .grow strong { display: block; font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------------------------------------------------------------- add title */
.hits { display: grid; gap: 10px; }
.hit { display: flex; gap: 14px; padding: 10px; border-radius: 14px; border: 1px solid var(--line); background: var(--surface-2); text-align: left; width: 100%; }
.hit:hover { border-color: var(--accent); }
.hit img { width: 52px; height: 78px; border-radius: 8px; object-fit: cover; background: var(--surface-3); flex: none; }
.hit strong { display: block; }
.hit p { color: var(--muted); font-size: 13px; margin-top: 4px; }

/* ---------------------------------------------------------------- rank list (top 10) */
/* minmax(0, 1fr) and min-width: 0 keep a long one-line title from widening the list past its card. */
.rank-list { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; min-width: 0; counter-reset: rank; }
.rank-item { display: flex; align-items: center; gap: 14px; padding: 10px 14px 10px 10px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }
.rank-item.drag-over { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
.rank-item.dragging { opacity: .45; }
.rank-no { width: 44px; text-align: center; font-size: 26px; font-weight: 900; letter-spacing: -.04em; background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.rank-item .grip { color: var(--muted); cursor: grab; display: grid; place-items: center; width: 28px; height: 36px; }
.rank-item .grow { flex: 1; min-width: 0; }
.rank-item .grow strong { display: block; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.log { max-height: 360px; overflow: auto; padding: 14px 16px; border-radius: var(--r-sm); background: var(--bg-2); border: 1px solid var(--line); font: 500 12.5px/1.6 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; white-space: pre-wrap; word-break: break-word; }
.progress { display: grid; gap: 8px; }
.progress .meter { height: 10px; }

/* ---------------------------------------------------------------- overlays */
dialog { color: var(--text); border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--glass-strong); backdrop-filter: blur(24px); -webkit-backdrop-filter: blur(24px); box-shadow: var(--shadow); padding: 0; }
dialog::backdrop { background: var(--scrim); backdrop-filter: blur(4px); }
.palette { width: min(620px, calc(100vw - 28px)); margin: 12vh auto auto; }
.palette-box { display: grid; }
.palette-input { display: flex; align-items: center; gap: 12px; padding: 16px 18px; border-bottom: 1px solid var(--line); color: var(--muted); }
.palette-input input { flex: 1; border: 0; background: none; min-height: 28px; padding: 0; font-size: 16px; box-shadow: none !important; color: var(--text); }
.palette-results { max-height: 52vh; overflow-y: auto; padding: 8px; }
.palette-hint { padding: 22px 14px; color: var(--muted); text-align: center; }
.palette-group { padding: 10px 12px 4px; font-size: 11px; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.palette-item { display: flex; align-items: center; gap: 12px; padding: 9px 12px; border-radius: 12px; }
.palette-item:hover, .palette-item.is-on { background: var(--surface-2); }
.palette-item img { width: 32px; height: 48px; border-radius: 6px; object-fit: cover; background: var(--surface-3); }
.palette-item strong { display: block; font-weight: 700; }
.confirm { width: min(440px, calc(100vw - 28px)); margin: auto; }
.confirm-box { display: grid; gap: 12px; padding: 24px; }
.confirm-box p { color: var(--muted); }
.confirm-actions { display: flex; justify-content: flex-end; gap: 10px; padding-top: 6px; }
.toast { position: fixed; left: 50%; bottom: 28px; translate: -50% 30px; z-index: 80; padding: 12px 20px; border-radius: 999px; background: var(--text); color: var(--bg); font-weight: 700; box-shadow: var(--shadow); opacity: 0; pointer-events: none; transition: opacity .25s, translate .3s var(--ease); max-width: calc(100vw - 32px); }
.toast.is-on { opacity: 1; translate: -50% 0; }

/* ---------------------------------------------------------------- sign in */
.auth-body { display: grid; min-height: 100dvh; background: radial-gradient(1100px 600px at 50% -10%, color-mix(in srgb, var(--accent) 16%, transparent), transparent 70%), var(--bg); }
.auth { display: grid; place-items: center; padding: 24px; }
.auth-card { width: min(420px, 100%); display: grid; gap: 16px; padding: 32px; border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--glass-strong); backdrop-filter: blur(20px); box-shadow: var(--shadow); }
.auth-logo { margin: 0 auto 4px; }
.auth-card h1 { text-align: center; font-size: 28px; }
.auth-sub { text-align: center; color: var(--muted); margin-top: -8px; }

/* ---------------------------------------------------------------- responsive */
@media (max-width: 1180px) {
  .cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .split { grid-template-columns: 1fr; }
  .editor { grid-template-columns: 1fr; }
  .editor-aside { position: static; grid-template-columns: 150px minmax(0, 1fr); align-items: start; }
}
@media (max-width: 920px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; z-index: 30; inset: 0 auto 0 0; width: min(300px, 86vw); translate: -102% 0; transition: translate .3s var(--ease); box-shadow: var(--shadow); }
  body.side-open .side { translate: 0 0; }
  .menu-btn { display: grid; }
  .me-name { display: none; }
  .me-chip { padding: 4px; }
  .cols-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .topbar-add span { display: none; }
  .topbar-add { padding: 0; width: 42px; }
}
@media (max-width: 640px) {
  .cols-2, .cols-3, .cols-4, .form-grid { grid-template-columns: 1fr; }
  .cols-4.keep-2, .cols-3.keep-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .titles { grid-template-columns: repeat(auto-fill, minmax(138px, 1fr)); gap: 14px; }
  .editor-aside { grid-template-columns: 110px minmax(0, 1fr); }
  .search-pill span { display: none; }
  .search-pill { flex: none; width: 44px; padding: 0; justify-content: center; }
  .search-pill kbd { display: none; }
  .topbar-add { margin-left: auto; }
  .table th, .table td { padding: 10px 12px; }
  .page-head { align-items: flex-start; }
  .kv { grid-template-columns: 1fr; gap: 2px; }
  .kv dd { margin-bottom: 10px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

.callout { display: flex; align-items: center; gap: 14px; padding: 14px 18px; border-radius: var(--r); border: 1px solid color-mix(in srgb, var(--accent) 40%, var(--line)); background: color-mix(in srgb, var(--accent) 10%, var(--surface)); }
.callout > span { flex: 1; min-width: 0; }
.callout:hover { border-color: var(--accent); }
.picker > summary { list-style: none; cursor: pointer; width: max-content; }
.picker > summary::-webkit-details-marker { display: none; }

/* Scrollbars follow the theme (page, sidebar, dialogs, tables) */
:root { --sb-thumb: #3a3a48; --sb-thumb-hover: #55556a; --sb-track: transparent; }
:root[data-theme="light"] { --sb-thumb: #c4c4d0; --sb-thumb-hover: #a0a0b2; }
* { scrollbar-width: thin; scrollbar-color: var(--sb-thumb) var(--sb-track); }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: var(--sb-track); }
*::-webkit-scrollbar-thumb { background: var(--sb-thumb); border-radius: 99px; border: 2px solid transparent; background-clip: padding-box; }
*::-webkit-scrollbar-thumb:hover { background: var(--sb-thumb-hover); background-clip: padding-box; }
*::-webkit-scrollbar-corner { background: transparent; }

/* File inputs become a drop zone (see dashboard.js) */
.dropzone { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; width: 100%; min-height: 130px; padding: 22px 20px; text-align: center; border: 2px dashed var(--line); border-radius: 16px; background: var(--surface-2); color: var(--muted); transition: border-color .15s, background .15s; }
.dropzone:hover, .dropzone:focus-within, .dropzone.is-over { border-color: var(--accent, #ff9a1f); background: color-mix(in srgb, var(--accent, #ff9a1f) 8%, transparent); }
.dropzone-icon { width: 28px; height: 28px; color: var(--accent, #ff9a1f); }
.dropzone-title { color: var(--text); font-size: 15px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dropzone-hint { font-size: 13px; }
.dropzone.has-file { border-style: solid; }

.list-row .list-side { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; flex: none; }

/* Button labels read in Title Case. */
.btn, .button { text-transform: capitalize; }

/* Title picker: a search box with a results list. */
.picker { position: relative; }
.picker-list { position: absolute; z-index: 30; left: 0; right: 0; top: calc(100% + 6px); max-height: 320px; overflow-y: auto; padding: 6px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); box-shadow: 0 18px 44px rgba(0,0,0,.45); }
.picker-item { display: flex; align-items: baseline; justify-content: space-between; gap: 14px; width: 100%; padding: 10px 12px; border: 0; border-radius: 10px; background: none; color: var(--text); text-align: left; font: inherit; cursor: pointer; }
.picker-item:hover, .picker-item.is-on { background: var(--surface-2); }
.picker-item strong { font-weight: 700; }
.picker-item small { flex: none; color: var(--muted); }
.picker-empty { padding: 16px 12px; color: var(--muted); text-align: center; }

/* Collections */
.coll-art { width: 100%; aspect-ratio: 16 / 9; border-radius: var(--r-sm); overflow: hidden; border: 1px solid var(--line); background: var(--surface-3); }
.coll-art img { width: 100%; height: 100%; object-fit: cover; }
.coll-row { flex-wrap: wrap; }
.move-bar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 10px 14px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface-2); }
.move-bar[hidden] { display: none; }
.move-bar select { flex: 1 1 220px; width: auto; min-width: 0; }
.rank-item > input[type="checkbox"] { flex: none; margin: 0 0 0 4px; cursor: pointer; }
[data-collection-titles]:not(.can-move) .rank-item > input[type="checkbox"] { display: none; }
.coll-row .grow { flex: 1 1 180px; }
.coll-controls { display: flex; align-items: center; gap: 14px; margin-left: auto; }
.coll-row .switch { gap: 8px; font-size: 13px; }

/* Activity: short columns stay on one line; long id lists wrap inside Details instead of squeezing the rest. */
.activity-table td:nth-child(-n+3) { white-space: nowrap; }
.activity-table td:nth-child(4) { min-width: 260px; }
.activity-table td:nth-child(5) { min-width: 320px; overflow-wrap: anywhere; }

/* Email campaign reports (pages/email_campaign.php) */
a.list-row { color: inherit; }
a.list-row:hover strong { color: var(--accent); }
.list-row > .badge, .list-row > small { flex: none; }
.meter--split { display: flex; }
.meter--split i, .meter--split b { display: block; height: 100%; border-radius: 0; }
.meter--split i { background: var(--good); }
.meter--split b { background: var(--bad); }
.key { display: inline-block; width: 10px; height: 10px; border-radius: 3px; background: var(--surface-3); margin-left: 8px; }
.key:first-child { margin-left: 0; }
.key--good { background: var(--good); }
.key--bad { background: var(--bad); }
.reason { display: block; overflow-wrap: anywhere; font-size: 13.5px; }
