/* Game media admin — tokens */
:root {
  --bg: #EDF0F2;
  --surface: #FFFFFF;
  --surface-2: #F5F7F8;
  --ink: #17202B;
  --muted: #5A6676;
  --line: #D5DBE1;
  --accent: #B9770E;
  --danger: #B42318;
  --ok: #1F7A4D;
  --bezel: #1E252D;
  --accent-soft: color-mix(in srgb, var(--accent) 14%, var(--surface));
  --r-s: 6px;
  --r-m: 10px;
  --r-phone: 22px;
  --font: 'Schibsted Grotesk', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #11161C;
    --surface: #19212A;
    --surface-2: #1F2832;
    --ink: #E7ECF1;
    --muted: #94A1AF;
    --line: #2B3540;
    --danger: #F0645A;
    --ok: #4CC38A;
    --bezel: #3A4652;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 400 15px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
}
button, input, select { font: inherit; color: inherit; }
img, video { display: block; max-width: 100%; }
h1, h2, h3 { margin: 0; line-height: 1.2; }
p { margin: 0; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.boot { padding: 40px; color: var(--muted); }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }

/* Buttons & fields */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 38px; padding: 0 14px;
  border: 1px solid var(--line); border-radius: var(--r-s);
  background: var(--surface); cursor: pointer; font-weight: 500; white-space: nowrap; text-decoration: none;
}
.btn:hover { border-color: var(--muted); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--ink); border-color: var(--ink); color: var(--surface); }
.btn-primary:hover { border-color: var(--ink); background: color-mix(in srgb, var(--ink) 86%, var(--accent)); }
.btn-danger { color: var(--danger); }
.btn-danger:hover { border-color: var(--danger); }
.btn-danger-solid { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-quiet { border-color: transparent; background: transparent; }
.btn-quiet:hover { background: var(--surface-2); border-color: transparent; }
.btn-s { min-height: 30px; padding: 0 10px; font-size: 13px; }

.field { display: grid; gap: 5px; }
.field > span { font-size: 13px; font-weight: 500; color: var(--muted); }
.input, .select {
  min-height: 38px; padding: 0 10px; width: 100%;
  border: 1px solid var(--line); border-radius: var(--r-s); background: var(--surface);
}
.select { padding-right: 28px; }
.input:focus, .select:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
.field-invalid .select, .select.invalid { border-color: var(--danger); }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--accent); }
.error-text { color: var(--danger); font-size: 13px; }

/* Login */
.login { min-height: 100%; display: grid; place-items: center; padding: 24px; }
.login form { width: min(380px, 100%); display: grid; gap: 16px; }
.login h1 { font-size: 30px; font-weight: 700; letter-spacing: -.01em; }
.login .lede { color: var(--muted); margin-top: -8px; }

/* Shell */
.shell { display: grid; grid-template-columns: 236px 1fr; min-height: 100%; }
.nav {
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  display: flex; flex-direction: column; gap: 22px;
  padding: 22px 14px; background: var(--surface); border-right: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; padding: 0 8px; font-weight: 700; font-size: 17px; }
.brand-mark { width: 14px; height: 24px; border-radius: 4px; background: var(--bezel); position: relative; }
.brand-mark::after { content: ''; position: absolute; inset: 3px 2px 5px; border-radius: 2px; background: var(--accent); }
.nav-group { display: grid; gap: 2px; }
.nav-group > p { padding: 0 8px 4px; font-size: 13px; color: var(--muted); }
.nav-link {
  display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: var(--r-s);
  color: inherit; text-decoration: none; font-weight: 500;
}
.nav-link:hover { background: var(--surface-2); }
.nav-link[aria-current="page"] { background: var(--accent-soft); }
.nav-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--dot, var(--muted)); flex: none; }
.nav-sub { padding-left: 27px; font-weight: 400; font-size: 14px; }
.nav-foot { margin-top: auto; display: grid; gap: 6px; padding: 12px 8px 0; border-top: 1px solid var(--line); }
.nav-user { font-weight: 600; }
.nav-role { font-size: 13px; color: var(--muted); }
.nav-foot .row { display: flex; gap: 4px; flex-wrap: wrap; margin-left: -10px; }

.main { min-width: 0; padding: 28px clamp(16px, 3vw, 40px) 120px; }

/* Page head */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.crumb { color: var(--muted); font-size: 14px; margin-bottom: 4px; }
.page-title { display: flex; align-items: baseline; gap: 14px; font-size: 30px; font-weight: 700; letter-spacing: -.015em; }
.page-title .count { font-size: 30px; font-weight: 400; color: var(--muted); font-variant-numeric: tabular-nums; }
.page-sub { color: var(--muted); margin-top: 6px; }

/* Facets: dropdown values with counts, clickable as filters */
.facets { display: grid; gap: 12px; margin-bottom: 18px; }
.facet { display: grid; grid-template-columns: 120px 1fr; align-items: start; gap: 12px; }
.facet-label { font-size: 13px; font-weight: 500; color: var(--muted); padding-top: 6px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex; align-items: baseline; gap: 7px;
  min-height: 32px; padding: 5px 11px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface); cursor: pointer; font-size: 14px;
}
.chip .n { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.chip:hover { border-color: var(--muted); }
.chip[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); font-weight: 600; }
.chip[aria-pressed="true"] .n { color: var(--ink); }
.chip-empty { opacity: .55; }

/* Toolbar */
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 12px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); margin-bottom: 20px; }
.toolbar .search { flex: 1 1 220px; max-width: 340px; }
.toolbar .select { width: auto; }
.toolbar .spacer { flex: 1; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: var(--r-s); overflow: hidden; }
.seg button { border: 0; background: var(--surface); padding: 0 12px; min-height: 36px; cursor: pointer; font-size: 14px; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--surface); }

/* Phone tiles — the wallpaper is shown the way a player sees it */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(158px, 1fr)); gap: 26px 18px; }
.tile { position: relative; display: grid; gap: 8px; }
.phone {
  position: relative; display: block; width: 100%; aspect-ratio: 9 / 16; padding: 0;
  border: 4px solid var(--bezel); border-radius: var(--r-phone); overflow: hidden;
  background: #2A323B; cursor: zoom-in;
}
.phone img, .phone video { width: 100%; height: 100%; object-fit: cover; }
.phone::before {
  content: ''; position: absolute; z-index: 2; top: 7px; left: 50%; translate: -50% 0;
  width: 34%; height: 11px; border-radius: 999px; background: var(--bezel);
}
.phone-clock {
  position: absolute; z-index: 2; top: 15%; left: 0; right: 0; text-align: center;
  color: #fff; font-size: 34px; font-weight: 600; letter-spacing: -.02em; line-height: 1;
  text-shadow: 0 1px 12px rgba(0, 0, 0, .45); font-variant-numeric: tabular-nums; pointer-events: none;
}
.phone-clock small { display: block; margin-top: 6px; font-size: 12px; font-weight: 500; letter-spacing: 0; }
.phone-badges { position: absolute; z-index: 2; left: 8px; right: 8px; bottom: 10px; display: flex; gap: 4px; justify-content: center; flex-wrap: wrap; pointer-events: none; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; background: rgba(15, 20, 26, .78); color: #fff; }
.badge-warn { background: var(--danger); }
.tile.is-hidden .phone img, .tile.is-hidden .phone video { opacity: .45; filter: grayscale(.6); }
.tile.is-selected .phone { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.tile-check {
  position: absolute; z-index: 3; top: 10px; left: 10px; width: 26px; height: 26px;
  display: grid; place-items: center; border-radius: 50%; background: rgba(15, 20, 26, .6); cursor: pointer;
}
.tile-check input { width: 16px; height: 16px; margin: 0; accent-color: var(--accent); cursor: pointer; }
.tile-info { display: flex; justify-content: space-between; gap: 6px; align-items: baseline; }
.tile-id { font-weight: 700; font-variant-numeric: tabular-nums; }
.tile-tags { font-size: 13px; color: var(--muted); line-height: 1.35; }
.tile-actions { display: flex; gap: 2px; margin-left: -10px; }

/* Table view */
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-m); }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; white-space: nowrap; }
th { font-weight: 600; color: var(--muted); font-size: 13px; background: var(--surface-2); }
tr:last-child td { border-bottom: 0; }
tr.is-selected td { background: var(--accent-soft); }
.mini-phone { width: 36px; aspect-ratio: 9 / 16; border: 2px solid var(--bezel); border-radius: 7px; overflow: hidden; background: #2A323B; padding: 0; cursor: zoom-in; }
.mini-phone img, .mini-phone video { width: 100%; height: 100%; object-fit: cover; }
.status-dot { display: inline-flex; align-items: center; gap: 6px; }
.status-dot::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--ok); }
.status-dot.off::before { background: var(--muted); }

/* Empty / pager */
.empty { padding: 56px 24px; text-align: center; border: 1px dashed var(--line); border-radius: var(--r-m); display: grid; gap: 12px; justify-items: center; }
.empty h2 { font-size: 20px; }
.empty p { color: var(--muted); max-width: 46ch; }
.pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 26px; flex-wrap: wrap; }
.pager .row { display: flex; gap: 8px; align-items: center; white-space: nowrap; flex-wrap: wrap; }
.pager .select { width: auto; }

/* Bulk bar */
.bulkbar {
  position: fixed; z-index: 20; left: 50%; bottom: 18px; translate: -50% 0;
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  max-width: calc(100vw - 32px); padding: 10px 12px;
  background: var(--ink); color: var(--surface); border-radius: var(--r-m);
  box-shadow: 0 10px 30px rgba(10, 15, 20, .3);
}
.bulkbar .count { font-weight: 600; padding: 0 6px; }
.bulkbar .select { width: auto; min-height: 32px; background: var(--ink); color: var(--surface); border-color: color-mix(in srgb, var(--surface) 30%, transparent); }
.bulkbar .btn { min-height: 32px; background: transparent; color: var(--surface); border-color: color-mix(in srgb, var(--surface) 30%, transparent); }
.bulkbar .btn:hover { border-color: var(--surface); }
.bulkbar .btn-danger { color: #FF9B93; }

/* Dialogs */
.dlg {
  width: min(560px, calc(100vw - 24px)); max-height: calc(100vh - 32px);
  padding: 0; border: 1px solid var(--line); border-radius: var(--r-m);
  background: var(--surface); color: var(--ink); box-shadow: 0 24px 60px rgba(10, 15, 20, .35);
}
.dlg::backdrop { background: rgba(12, 17, 23, .55); }
.dlg[open] { animation: dlg-in .16s ease-out; }
@keyframes dlg-in { from { opacity: 0; translate: 0 8px; } }
.dlg-body { padding: 22px; display: grid; gap: 18px; }
.dlg-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.dlg-head h2 { font-size: 22px; font-weight: 700; }
.dlg-head p { color: var(--muted); margin-top: 4px; }
.dlg-foot { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.dlg-foot .left { margin-right: auto; }
.dlg-wide { width: min(880px, calc(100vw - 24px)); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.edit-layout { display: grid; grid-template-columns: 200px 1fr; gap: 24px; align-items: start; }
.edit-layout .phone { cursor: default; }
.facts { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; font-size: 14px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; overflow-wrap: anywhere; }
.replace-box { border: 1px dashed var(--line); border-radius: var(--r-s); padding: 12px; display: grid; gap: 8px; }
.replace-box .hint { font-size: 13px; color: var(--muted); }

/* Upload */
.drop {
  display: grid; justify-items: center; gap: 6px; padding: 26px; text-align: center;
  border: 2px dashed var(--line); border-radius: var(--r-m); background: var(--surface-2); cursor: pointer;
}
.drop.is-over { border-color: var(--accent); background: var(--accent-soft); }
.drop strong { font-size: 16px; }
.drop span { color: var(--muted); font-size: 14px; }
.apply-all { display: grid; grid-template-columns: auto 1fr 1fr; gap: 12px; align-items: end; }
.apply-all > p { font-size: 13px; color: var(--muted); padding-bottom: 10px; }
.queue { display: grid; gap: 0; max-height: 46vh; overflow-y: auto; border: 1px solid var(--line); border-radius: var(--r-m); }
.qrow { display: grid; grid-template-columns: 34px 1fr 168px 168px 32px; gap: 10px; align-items: center; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.qrow:last-child { border-bottom: 0; }
.qrow .mini-phone { width: 34px; cursor: default; }
.qname { min-width: 0; }
.qname b { display: block; font-weight: 500; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.qname small { font-size: 12px; color: var(--muted); }
.qname small.err { color: var(--danger); }
.qname small.done { color: var(--ok); }
.qrow .select { min-height: 32px; font-size: 13px; }
.progress { height: 3px; border-radius: 2px; background: var(--line); margin-top: 4px; overflow: hidden; }
.progress i { display: block; height: 100%; width: var(--p, 0%); background: var(--accent); }

/* Lightbox */
.lightbox { width: 100vw; height: 100vh; max-width: none; max-height: none; border: 0; border-radius: 0; background: #0B0F13; color: #E7ECF1; }
.lightbox[open] { display: grid; grid-template-columns: 1fr 300px; }
.lb-stage { position: relative; display: grid; place-items: center; padding: 24px 64px; min-height: 0; }
.lb-stage img, .lb-stage video { max-height: calc(100vh - 48px); max-width: 100%; object-fit: contain; border-radius: 6px; }
.lb-nav { position: absolute; top: 50%; translate: 0 -50%; width: 44px; height: 44px; border-radius: 50%; border: 1px solid #3A4652; background: #161D24; color: #E7ECF1; cursor: pointer; font-size: 20px; }
.lb-prev { left: 12px; }
.lb-next { right: 12px; }
.lb-side { padding: 24px; background: #121920; display: flex; flex-direction: column; gap: 18px; overflow-y: auto; }
.lb-side h2 { font-size: 26px; }
.lb-side .facts dt { color: #94A1AF; }
.lb-side .btn { background: transparent; border-color: #3A4652; color: #E7ECF1; }
.lb-side .btn:hover { border-color: #E7ECF1; }
.lb-side .actions { display: flex; flex-wrap: wrap; gap: 8px; }
.lb-close { margin-left: auto; }

/* Users / activity */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-m); }
.role { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; border: 1px solid var(--line); }
.role-admin { border-color: var(--accent); background: var(--accent-soft); }
.games-checks { display: grid; gap: 8px; }
.feed { list-style: none; margin: 0; padding: 0; }
.feed li { display: grid; grid-template-columns: 1fr auto; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.feed li:last-child { border-bottom: 0; }
.feed time { color: var(--muted); font-size: 13px; white-space: nowrap; }

/* Toasts */
#toasts { position: fixed; z-index: 100; right: 18px; bottom: 18px; display: grid; gap: 8px; }
.toast { padding: 11px 14px; border-radius: var(--r-s); background: var(--ink); color: var(--surface); box-shadow: 0 8px 24px rgba(10, 15, 20, .25); max-width: 380px; font-size: 14px; }
.toast-error { background: var(--danger); color: #fff; }

/* Responsive */
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .nav { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 12px; padding: 12px; border-right: 0; border-bottom: 1px solid var(--line); }
  .nav-group { display: flex; flex-wrap: wrap; }
  .nav-group > p { display: none; }
  .nav-sub { padding-left: 8px; }
  .nav-foot { margin: 0; border: 0; padding: 0; width: 100%; grid-template-columns: auto 1fr; align-items: center; }
  .facet { grid-template-columns: 1fr; gap: 6px; }
  .facet-label { padding-top: 0; }
  .lightbox[open] { grid-template-columns: 1fr; grid-template-rows: 1fr auto; }
  .lb-stage { padding: 16px 52px; }
  .lb-stage img, .lb-stage video { max-height: 60vh; }
}
@media (max-width: 640px) {
  .edit-layout { grid-template-columns: 1fr; }
  .edit-layout .phone { width: 160px; }
  .form-grid, .apply-all { grid-template-columns: 1fr; }
  .qrow { grid-template-columns: 34px 1fr 32px; }
  .qrow .select { grid-column: 2 / 3; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 20px 12px; }
}
@media (prefers-reduced-motion: reduce) {
  .dlg[open] { animation: none; }
}
