/* razkid — app styles.
   Sections 1–3 are razkid-design/{tokens,components,mobile}.css verbatim, with two mechanical changes:
   - the selected state (aria-pressed="true") also matches a label with a checked radio inside,
     because the lineup form is a plain HTML form;
   - the .m-side-filter button rules also apply to links (filters are links + htmx).
   Section 4 is glue for server-rendered markup; it only uses values from the tokens. */

/* ==================== 1. tokens.css ==================== */
/* razkid — design tokens. Single source of truth for colors, type, spacing, radii.
   Dark theme only (by requirement). All components in components.css use these vars. */

:root {
  /* ---- Surfaces (darkest → lightest) ---- */
  --bg-lightbox: #050607;   /* fullscreen image viewer background */
  --bg: #0e1012;            /* page background, input background inside dialogs */
  --bg-sidebar: #121417;    /* sidebar, dashed "custom" input */
  --bg-aside: #141619;      /* images column inside form dialog */
  --surface: #171a1d;       /* segmented controls, tiles, dialogs */
  --surface-2: #1c1f23;     /* image rows inside form */
  --surface-active: #1f2327;/* selected map / selected lineup row / neutral chip */
  --surface-hover: #1a1d21; /* hover on list rows and map links */

  /* ---- Lines ---- */
  --line-subtle: #1f2327;   /* layout dividers (sidebar edge, topbar bottom, list edge) */
  --line: #22262a;          /* card/tile borders, dialog internal dividers */
  --line-strong: #2a2f34;   /* input borders, outlined buttons */
  --line-selected: #3a3f45; /* selected row border, dashed dropzone */
  --line-danger: #3a2a26;   /* outlined delete button */

  /* ---- Text ---- */
  --text: #ebe7df;          /* primary text; also primary button fill */
  --text-muted: #a3a8ad;    /* secondary text, labels */
  --text-faint: #898f96;    /* tertiary: counts, hints, placeholders */
  --text-on-light: #0e1012; /* text on --text-filled buttons */

  /* ---- Semantic ---- */
  --side-t: #e0a24a;                   /* Terrorist side */
  --side-t-bg: rgba(224, 162, 74, 0.14);
  --side-ct: #78a6de;                  /* Counter-Terrorist side */
  --side-ct-bg: rgba(120, 166, 222, 0.14);

  --fresh: #6cc38a;   --fresh-bg: rgba(108, 195, 138, 0.12);  /* checked ≤ 30 days ago */
  --stale: #d8b54a;   --stale-bg: rgba(216, 181, 74, 0.12);   /* 31–90 days */
  --old:   #e0694f;   --old-bg:   rgba(224, 105, 79, 0.14);   /* > 90 days */

  --danger: #e8826b;        /* danger icon/text on dark */
  --danger-fill: #b8432c;   /* destructive primary button (white text) */

  --scrim: rgba(5, 6, 7, 0.72);            /* behind modal dialogs */
  --overlay-control: rgba(14, 16, 18, 0.72); /* round buttons on top of images */
  --focus: #78a6de;

  /* ---- Placeholder (until real screenshots load) ---- */
  --ph-a: #1c2024;
  --ph-b: #16191c;

  /* ---- Typography ---- */
  --font-display: 'Unbounded', system-ui, sans-serif;     /* wordmark, page & dialog titles */
  --font-body: 'IBM Plex Sans', system-ui, sans-serif;    /* everything else */
  --font-mono: 'JetBrains Mono', ui-monospace, monospace; /* point names, enums, counters, T/CT */

  --fs-11: 12px;  /* overline, meta, badges */
  --fs-13: 13px;  /* hints, field labels in dialogs */
  --fs-14: 14px;  /* secondary text, segmented items */
  --fs-15: 15px;  /* list titles, buttons, nav */
  --fs-16: 16px;  /* body / description */
  --fs-20: 20px;  /* dialog title */
  --fs-22: 22px;  /* wordmark, login title */
  --fs-26: 26px;  /* lineup title */
  --fs-28: 28px;  /* page title (map name) */

  /* ---- Radii ---- */
  --r-6: 6px; --r-7: 7px; --r-8: 8px; --r-10: 10px; --r-12: 12px;
  --r-14: 14px; --r-16: 16px; --r-20: 20px; --r-pill: 999px;

  /* ---- Sizing ---- */
  --control-h: 44px;      /* minimum hit target */
  --control-h-sm: 40px;   /* items inside a segmented control (container adds 4px padding) */
  --sidebar-w: 240px;
  --topbar-h: 84px;
  --list-w: 420px;
}

/* ==================== 2. components.css ==================== */
/* razkid — component styles (desktop). Requires tokens.css.
   Class names are BEM-ish and framework-agnostic; port them as-is or map to components.
   State is expressed with ARIA attributes (aria-current, aria-pressed), not extra classes. */

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: var(--fs-16);
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.mono { font-family: var(--font-mono); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.icon { width: 18px; height: 18px; flex-shrink: 0; }
.icon--20 { width: 20px; height: 20px; }
.icon--16 { width: 16px; height: 16px; }

/* Striped placeholder shown until an image loads (and for empty slots). */
.ph { background: repeating-linear-gradient(135deg, var(--ph-a) 0 12px, var(--ph-b) 12px 24px); }
.ph--fine { background: repeating-linear-gradient(135deg, var(--ph-a) 0 6px, var(--ph-b) 6px 12px); }
.ph img, .thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* ============ App shell ============ */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  height: 100vh;
  min-width: 1024px;
  overflow: hidden;
}

/* ---- Sidebar ---- */
.sidebar {
  display: flex; flex-direction: column; gap: 20px;
  padding: 24px 12px 20px;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--line-subtle);
  min-height: 0;
}
.brand {
  padding: 0 12px;
  font-family: var(--font-display); font-weight: 700; font-size: var(--fs-22);
  letter-spacing: -0.02em; text-decoration: none;
}
.map-nav { display: flex; flex-direction: column; gap: 2px; overflow-y: auto; }
.nav-label {
  padding: 0 12px 8px;
  font-size: var(--fs-11); letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--text-faint);
}
.map-link {
  height: var(--control-h); padding: 0 12px; border-radius: var(--r-10);
  display: flex; align-items: center; justify-content: space-between;
  text-decoration: none; font-size: var(--fs-15);
}
.map-link:hover { background: var(--surface-hover); }
.map-link[aria-current="page"] { background: var(--surface-active); font-weight: 600; }
.map-link__count { font-family: var(--font-mono); font-size: var(--fs-11); color: var(--text-faint); }
.sidebar__foot { margin-top: auto; padding: 0 4px; }
.session {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 0 8px; font-size: var(--fs-14); color: var(--text-muted);
}
.session__state { display: flex; align-items: center; gap: 8px; }
.session a { color: var(--text-muted); }

/* ---- Buttons ---- */
.btn {
  height: var(--control-h); padding: 0 18px; border-radius: var(--r-12);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid transparent; background: transparent;
  font-size: var(--fs-15); font-weight: 500; text-decoration: none; white-space: nowrap;
}
.btn--primary { background: var(--text); color: var(--text-on-light); font-weight: 600; }
.btn--primary:hover { background: #ffffff; }
.btn--outline { border-color: var(--line-strong); }
.btn--outline:hover { background: var(--surface-hover); }
.btn--danger { background: var(--danger-fill); color: #ffffff; font-weight: 600; }
.btn--danger:hover { background: #a63a25; }
.btn--block { width: 100%; }
.btn--with-icon { padding-left: 14px; }

.icon-btn {
  width: var(--control-h); height: var(--control-h); border-radius: var(--r-12);
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--line-strong); background: transparent; color: var(--text);
}
.icon-btn:hover { background: var(--surface-hover); }
.icon-btn--danger { border-color: var(--line-danger); color: var(--danger); }
.icon-btn--plain { border-color: transparent; color: var(--text-muted); }
/* Round translucent button placed over an image */
.icon-btn--overlay { border: 0; border-radius: 50%; background: var(--overlay-control); }
.icon-btn--overlay:hover { background: rgba(14, 16, 18, 0.9); }

/* ============ Main column ============ */
.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.topbar {
  height: var(--topbar-h); flex-shrink: 0; padding: 0 28px;
  display: flex; align-items: center; gap: 24px;
  border-bottom: 1px solid var(--line-subtle);
}
.page-title {
  margin: 0; min-width: 150px;
  font-family: var(--font-display); font-weight: 500; font-size: var(--fs-28);
}
.topbar__end { margin-left: auto; }

/* ---- Segmented control (grenade type, side filter) ---- */
.segmented {
  display: flex; gap: 4px; padding: 4px;
  border-radius: var(--r-14); background: var(--surface); border: 1px solid var(--line);
}
.segmented__item {
  height: var(--control-h-sm); padding: 0 14px; border: 0; border-radius: var(--r-10);
  display: inline-flex; align-items: center; gap: 8px;
  background: transparent; font-size: var(--fs-14); font-weight: 500;
}
.segmented__item:hover { background: var(--surface-hover); }
.segmented__item:is([aria-pressed="true"], :has(> input:checked)) { background: var(--text); color: var(--text-on-light); font-weight: 600; }
/* Side filter: selected uses a neutral fill so T/CT keep their colours */
.segmented--side .segmented__item { padding: 0 16px; }
.segmented--side .segmented__item:is([aria-pressed="true"], :has(> input:checked)) { background: var(--line-strong); color: var(--text); }
.segmented__item--t { font-family: var(--font-mono); color: var(--side-t); }
.segmented__item--ct { font-family: var(--font-mono); color: var(--side-ct); }
.segmented--side .segmented__item--t:is([aria-pressed="true"], :has(> input:checked)) { color: var(--side-t); }
.segmented--side .segmented__item--ct:is([aria-pressed="true"], :has(> input:checked)) { color: var(--side-ct); }

/* ============ Content: list + detail ============ */
.content { flex: 1; min-height: 0; display: grid; grid-template-columns: var(--list-w) minmax(0, 1fr); }

/* ---- Lineup list ---- */
.lineup-list {
  display: flex; flex-direction: column; gap: 6px;
  padding: 16px 12px 16px 16px;
  border-right: 1px solid var(--line-subtle);
  overflow-y: auto; min-height: 0;
  list-style: none; margin: 0;
}
.lineup-list__count { padding: 0 4px 6px; font-size: var(--fs-13); color: var(--text-faint); }
.lineup-row {
  display: flex; align-items: center; gap: 12px;
  padding: 8px 12px 8px 8px; border-radius: var(--r-14);
  border: 1px solid transparent; text-decoration: none;
}
.lineup-row:hover { background: var(--surface-hover); }
.lineup-row[aria-current="true"] { background: var(--surface-active); border-color: var(--line-selected); }
.lineup-row .thumb { width: 80px; height: 45px; border-radius: var(--r-8); flex-shrink: 0; overflow: hidden; }
.lineup-row__body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.lineup-row__title { font-size: var(--fs-15); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lineup-row__from { font-weight: 400; color: var(--text-muted); }
.lineup-row__meta { display: flex; gap: 6px; white-space: nowrap; overflow: hidden; font-family: var(--font-mono); font-size: var(--fs-11); color: var(--text-muted); }
.side-t { color: var(--side-t); }
.side-ct { color: var(--side-ct); }

/* ---- Check-age badge ---- */
.age {
  flex-shrink: 0; display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 8px; border-radius: var(--r-8);
  font-family: var(--font-mono); font-size: var(--fs-11);
}
.age::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.age--fresh { color: var(--fresh); background: var(--fresh-bg); }
.age--stale { color: var(--stale); background: var(--stale-bg); }
.age--old   { color: var(--old);   background: var(--old-bg); }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
.dot--fresh { background: var(--fresh); } .dot--stale { background: var(--stale); } .dot--old { background: var(--old); }

/* ---- Detail pane ---- */
.detail { min-width: 0; padding: 24px 28px; display: flex; flex-direction: column; gap: 14px; overflow-y: auto; }
.detail__head { display: flex; align-items: flex-start; gap: 16px; }
.detail__heading { flex: 1; display: flex; flex-direction: column; gap: 6px; }
.detail__titleline { display: flex; align-items: baseline; gap: 14px; }
.detail__title { margin: 0; font-family: var(--font-display); font-weight: 500; font-size: var(--fs-26); }
.route { font-family: var(--font-mono); font-size: var(--fs-14); color: var(--text-muted); white-space: nowrap; }
.detail__actions { display: flex; gap: 8px; }
.chips { display: flex; gap: 6px; }
.chip { padding: 3px 8px; border-radius: var(--r-7); font-family: var(--font-mono); font-size: var(--fs-11); background: var(--surface-active); color: var(--text-muted); }
.chip--t { background: var(--side-t-bg); color: var(--side-t); }
.chip--ct { background: var(--side-ct-bg); color: var(--side-ct); }

/* ---- Gallery (carousel) ---- */
.gallery {
  position: relative; flex-shrink: 0; aspect-ratio: 16 / 9; max-height: 408px;
  border-radius: var(--r-16); overflow: hidden;
  display: flex; align-items: center; justify-content: center;
}
.gallery__nav { position: absolute; top: 50%; transform: translateY(-50%); }
.gallery__nav--prev { left: 12px; }
.gallery__nav--next { right: 12px; }
.gallery__expand { position: absolute; top: 12px; right: 12px; }
.gallery__counter {
  position: absolute; left: 12px; bottom: 12px; padding: 4px 9px; border-radius: var(--r-8);
  background: var(--overlay-control); font-family: var(--font-mono); font-size: var(--fs-11); color: var(--text-muted);
}
.ph-label { font-family: var(--font-mono); font-size: var(--fs-13); color: var(--text-faint); }
.thumbs { display: flex; gap: 8px; }
.thumbs__item {
  width: 96px; height: 54px; padding: 0; border-radius: var(--r-8);
  border: 2px solid transparent; opacity: 0.6; overflow: hidden;
}
.thumbs__item:hover { opacity: 0.85; }
.thumbs__item[aria-current="true"] { border-color: var(--text); opacity: 1; }

/* ---- Info row under gallery ---- */
.detail__info { display: flex; gap: 20px; align-items: flex-start; }
.detail__text { flex: 1; display: flex; flex-direction: column; gap: 10px; }
.desc { margin: 0; font-size: var(--fs-16); line-height: 1.5; }
.checked { display: flex; align-items: center; gap: 8px; font-size: var(--fs-14); color: var(--text-muted); }
.specs { display: flex; gap: 8px; flex-shrink: 0; }
.spec-tile {
  min-width: 120px; padding: 10px 14px; border-radius: var(--r-12);
  background: var(--surface); border: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 2px;
}
.spec-tile__label { font-size: var(--fs-11); color: var(--text-muted); }
.spec-tile__value { display: flex; align-items: center; gap: 6px; font-size: var(--fs-16); font-weight: 500; }
.spec-tile__value--mono { font-family: var(--font-mono); font-weight: 400; }

/* ---- Empty state (no lineups for current filters) ---- */
.empty { padding: 40px 16px; text-align: center; color: var(--text-muted); font-size: var(--fs-14); }

/* ============ Overlays ============ */
.scrim { position: fixed; inset: 0; background: var(--scrim); display: flex; align-items: center; justify-content: center; z-index: 10; }
.dialog {
  width: 400px; padding: 28px; border-radius: var(--r-20);
  background: var(--surface); border: 1px solid var(--line-strong);
  display: flex; flex-direction: column; gap: 18px;
}
.dialog--confirm { width: 440px; gap: 20px; }
.dialog__head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.dialog__title { margin: 0; font-family: var(--font-display); font-weight: 500; font-size: var(--fs-20); }
.dialog__title--lg { font-size: var(--fs-22); }
.dialog__text { margin: 0; font-size: var(--fs-15); line-height: 1.5; color: var(--text-muted); }
.dialog__text strong { font-family: var(--font-mono); font-weight: 400; color: var(--text); }
.dialog__note { margin: 0; font-size: var(--fs-13); color: var(--text-muted); }
.dialog__actions { display: flex; justify-content: flex-end; gap: 8px; }
.dialog__close { width: 36px; height: 36px; margin: -6px -8px 0 0; border-radius: var(--r-10); }
.error-text { margin: 0; font-size: var(--fs-13); color: var(--old); }

/* ---- Form fields ---- */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
fieldset.field { margin: 0; padding: 0; border: 0; }
.field__label { padding: 0; margin-bottom: 0; font-size: var(--fs-13); color: var(--text-muted); }
fieldset.field > .field__label { margin-bottom: 6px; }
.input, .select, .textarea {
  width: 100%; height: var(--control-h); padding: 0 12px;
  border-radius: var(--r-10); border: 1px solid var(--line-strong);
  background: var(--bg); font-size: var(--fs-15);
}
.input--lg { height: 46px; padding: 0 14px; border-radius: var(--r-12); font-size: var(--fs-16); }
.input--mono { font-family: var(--font-mono); }
.input--dashed { border-style: dashed; border-color: var(--line-selected); background: var(--bg-sidebar); font-size: var(--fs-14); }
.input[aria-invalid="true"], .textarea[aria-invalid="true"] { border-color: var(--old); }
.textarea { height: auto; padding: 12px; line-height: 1.45; resize: none; }
.input::placeholder, .textarea::placeholder { color: var(--text-faint); }

/* Grid of equal choice buttons (single select) */
.choices { display: grid; gap: 4px; }
.choices--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.choices--4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.choice {
  height: var(--control-h); border-radius: var(--r-10);
  border: 1px solid var(--line-strong); background: var(--bg); font-size: var(--fs-14);
}
.choice:hover { background: var(--surface-hover); }
.choice:is([aria-pressed="true"], :has(> input:checked)) { border-color: var(--text); background: var(--text); color: var(--text-on-light); font-weight: 600; }
.choice--mono { font-family: var(--font-mono); font-size: var(--fs-13); }
.choice--t { font-family: var(--font-mono); color: var(--side-t); }
.choice--ct { font-family: var(--font-mono); color: var(--side-ct); }
.choice--t:is([aria-pressed="true"], :has(> input:checked)) { border-color: var(--side-t); background: var(--side-t-bg); color: var(--side-t); font-weight: 400; }
.choice--ct:is([aria-pressed="true"], :has(> input:checked)) { border-color: var(--side-ct); background: var(--side-ct-bg); color: var(--side-ct); font-weight: 400; }

/* Technique pills */
.pills { display: flex; flex-wrap: wrap; gap: 6px; }
.pill {
  height: var(--control-h-sm); padding: 0 12px; border-radius: var(--r-pill);
  border: 1px solid var(--line-strong); background: var(--bg);
  font-family: var(--font-mono); font-size: var(--fs-13);
}
.pill:hover { background: var(--surface-hover); }
.pill:is([aria-pressed="true"], :has(> input:checked)) { border-color: var(--text); background: var(--text); color: var(--text-on-light); }

/* ---- Lineup form dialog ---- */
.form-dialog {
  width: 1040px; height: min(800px, calc(100vh - 48px));
  border-radius: var(--r-20); background: var(--surface); border: 1px solid var(--line-strong);
  display: flex; flex-direction: column; overflow: hidden;
}
.form-dialog__head {
  height: 68px; flex-shrink: 0; padding: 0 16px 0 28px;
  display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid var(--line);
}
.form-dialog__body { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) 400px; }
.form-dialog__fields { padding: 24px 28px; display: flex; flex-direction: column; gap: 18px; overflow-y: auto; }
.form-dialog__images {
  margin: 0; padding: 24px 28px 24px 24px; border: 0; border-left: 1px solid var(--line);
  background: var(--bg-aside); display: flex; flex-direction: column; gap: 10px; overflow-y: auto;
}
.form-dialog__foot {
  height: 72px; flex-shrink: 0; padding: 0 28px;
  display: flex; align-items: center; justify-content: flex-end; gap: 8px;
  border-top: 1px solid var(--line);
}
.row-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.row-map-type { display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: 16px; }
.hint { margin: 0; font-size: var(--fs-13); line-height: 1.45; color: var(--text-faint); }

/* Image list with drag reordering */
.image-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.image-item {
  display: flex; align-items: center; gap: 10px; padding: 6px 6px 6px 2px;
  border-radius: var(--r-12); background: var(--surface-2); border: 1px solid #262a2f;
}
.image-item.is-dragging { opacity: 0.5; }
.image-item.is-drop-target { border-color: var(--focus); }
.image-item .thumb { width: 80px; height: 45px; border-radius: var(--r-6); overflow: hidden; flex-shrink: 0; }
.image-item__name { flex: 1; min-width: 0; font-family: var(--font-mono); font-size: var(--fs-13); }
.image-item__name span { font-family: var(--font-body); color: var(--text-faint); }
.drag-handle { width: 28px; height: var(--control-h); border: 0; background: transparent; color: var(--text-faint); cursor: grab; display: flex; align-items: center; justify-content: center; }
.dropzone {
  margin-top: 4px; height: 120px; border-radius: var(--r-12); border: 1px dashed var(--line-selected);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  font-size: var(--fs-14); cursor: pointer;
}
.dropzone:hover, .dropzone.is-over { border-color: var(--text-muted); background: var(--surface-hover); }
.dropzone small { font-size: var(--fs-11); color: var(--text-faint); }

/* ---- Lightbox (fullscreen image) ---- */
.lightbox { position: fixed; inset: 0; z-index: 20; background: var(--bg-lightbox); display: flex; flex-direction: column; }
.lightbox__bar { height: 64px; flex-shrink: 0; padding: 0 16px 0 28px; display: flex; align-items: center; gap: 16px; }
.lightbox__title { font-size: var(--fs-15); font-weight: 600; }
.lightbox__title span { font-weight: 400; color: var(--text-muted); }
.lightbox__counter { font-family: var(--font-mono); font-size: var(--fs-13); color: var(--text-muted); }
.lightbox__help { margin-left: auto; font-size: var(--fs-13); color: var(--text-faint); }
.lightbox__close { border: 0; border-radius: 50%; background: var(--surface); }
.lightbox__stage { flex: 1; min-height: 0; position: relative; display: flex; align-items: center; justify-content: center; padding: 0 88px 72px; overflow: hidden; }
.lightbox__image { width: 100%; max-width: 1264px; aspect-ratio: 16 / 9; max-height: 100%; border-radius: var(--r-8); display: flex; align-items: center; justify-content: center; cursor: grab; }
.lightbox__nav { position: absolute; top: calc(50% - 36px); transform: translateY(-50%); width: 52px; height: 52px; border: 0; border-radius: 50%; background: var(--surface); }
.lightbox__nav--prev { left: 20px; }
.lightbox__nav--next { right: 20px; }
.zoom-ctrl {
  position: absolute; left: 50%; bottom: 12px; transform: translateX(-50%); display: flex; align-items: center; gap: 2px;
  padding: 4px; border-radius: var(--r-12); background: rgba(23, 26, 29, 0.9);
}
.zoom-ctrl button { width: 40px; height: 40px; border: 0; border-radius: var(--r-8); background: transparent; font-size: 20px; }
.zoom-ctrl button:hover { background: var(--surface-hover); }
.zoom-ctrl__value { width: 56px; text-align: center; font-family: var(--font-mono); font-size: var(--fs-13); }

/* ============ Breakpoints ============
   ≥ 1280px  — desktop, as drawn (reference/*.html at 1440×900)
   1024–1279 — desktop, compact: narrower sidebar and list, card info stacks
   < 1024px  — mobile layout (mobile.css, reference/mobile/*.html); .app is not rendered */
@media (max-width: 1279px) {
  :root { --sidebar-w: 200px; --list-w: 340px; }
  .topbar { gap: 12px; padding: 0 20px; }
  .page-title { min-width: 0; font-size: 24px; }
  .segmented__item { padding: 0 10px; }
  .detail { padding: 20px; }
  .detail__head { flex-wrap: wrap; }
  .detail__info { flex-direction: column; }
  .lineup-row .thumb { display: none; }   /* list is too narrow for thumbnails */
  .lineup-row { padding-left: 12px; }
  .session { font-size: var(--fs-13); white-space: nowrap; }
}

/* ==================== 3. mobile.css ==================== */
/* razkid — mobile layout (viewport < 1024px). Requires tokens.css + components.css.
   Mobile reuses the shared components (.btn, .icon-btn, .age, .chip, .choice, .pill, .input,
   .field, .image-item, .dropzone, .ph, .dot …) and adds only screen layout, prefixed .m-.
   Screens are separate routes: maps → list → card; dialogs become pages or bottom sheets. */

.m-screen {
  position: relative;
  min-height: 100dvh;
  max-width: 640px;          /* on tablets the column is centred */
  margin: 0 auto;
  display: flex; flex-direction: column;
  background: var(--bg);
}

/* ---- Top bars ---- */
.m-brandbar { display: flex; align-items: center; justify-content: space-between; padding: 20px 16px 12px 20px; }
.m-brandbar .brand { padding: 0; }
.m-header {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 8px;
  padding: 12px 16px 8px 8px;
  background: var(--bg);
}
.m-header__title { margin: 0; flex: 1; min-width: 0; font-family: var(--font-display); font-weight: 500; font-size: 24px; }
.m-header__title--sm { font-size: var(--fs-20); }
.m-header .icon-btn { border-color: transparent; }
.m-session { display: flex; align-items: center; gap: 6px; font-size: var(--fs-13); color: var(--text-muted); }

.m-intro { padding: 12px 20px 16px; display: flex; flex-direction: column; gap: 4px; }
.m-intro h1 { margin: 0; font-family: var(--font-display); font-weight: 500; font-size: var(--fs-28); line-height: 1.15; }
.m-intro p { margin: 0; font-size: var(--fs-15); color: var(--text-muted); }

/* ---- Map grid (start screen) ---- */
.m-map-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; padding: 0 16px 24px; }
.m-map-tile {
  position: relative; height: 112px; padding: 12px 14px; border-radius: var(--r-16);
  border: 1px solid var(--line-strong); overflow: hidden; text-decoration: none;
  display: flex; flex-direction: column; justify-content: flex-end;
}
.m-map-tile img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: .45; }
.m-map-tile__name { position: relative; font-family: var(--font-display); font-weight: 500; font-size: 17px; }
.m-map-tile__count { position: relative; font-size: var(--fs-13); color: var(--text-muted); }
.m-map-tile[aria-current="page"] { border-color: var(--text); }

/* ---- Filters on the list screen ---- */
.m-type-tabs { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; padding: 8px 16px 0; }
.m-type-tab {
  height: 60px; border-radius: var(--r-12); border: 1px solid var(--line-strong); background: var(--surface);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  font-size: var(--fs-13); font-weight: 500;
}
.m-type-tab .icon { width: 20px; height: 20px; }
.m-type-tab:is([aria-pressed="true"], :has(> input:checked)) { border-color: var(--text); background: var(--text); color: var(--text-on-light); font-weight: 600; }
.m-side-filter { display: flex; gap: 6px; padding: 10px 16px 12px; }
.m-side-filter :is(a, button) {
  flex: 1; height: var(--control-h); border-radius: 22px;
  border: 1px solid var(--line-strong); background: transparent; font-size: var(--fs-15);
}
.m-side-filter :is(a, button):is([aria-pressed="true"], :has(> input:checked)) { border-color: var(--text); background: #262a2f; font-weight: 600; }
.m-side-filter .t { font-family: var(--font-mono); color: var(--side-t); }
.m-side-filter .ct { font-family: var(--font-mono); color: var(--side-ct); }

/* ---- List ---- */
.m-list { list-style: none; margin: 0; padding: 0 16px 120px; display: flex; flex-direction: column; gap: 8px; }
.m-row {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px 10px 10px; border-radius: var(--r-16);
  background: var(--surface); border: 1px solid var(--line); text-decoration: none;
}
.m-row:active { background: var(--surface-active); }
.m-row .thumb { width: 64px; height: 64px; border-radius: var(--r-10); overflow: hidden; flex-shrink: 0; }
.m-row__body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.m-row__title { font-size: 17px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.m-row__from { font-size: var(--fs-14); color: var(--text-muted); }
.m-row__meta { display: flex; gap: 6px; font-family: var(--font-mono); font-size: var(--fs-11); color: var(--text-muted); }
.m-row .age { padding: 5px 9px; border-radius: var(--r-10); }

.m-fab {
  position: fixed; right: max(16px, calc(50vw - 320px + 16px)); bottom: calc(24px + env(safe-area-inset-bottom));
  height: 56px; padding: 0 22px 0 18px; border-radius: 28px;
  background: var(--text); color: var(--text-on-light); text-decoration: none;
  display: flex; align-items: center; gap: 8px; font-size: var(--fs-16); font-weight: 600;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .5); z-index: 6;
}

/* ---- Card ---- */
.m-gallery {
  position: relative; width: 100%; aspect-ratio: 16 / 9; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  touch-action: pan-y;          /* horizontal swipe handled by the carousel */
}
.m-gallery__back { position: absolute; left: 12px; top: 12px; }
.m-gallery__zoom { position: absolute; right: 12px; top: 12px; }
.m-gallery__dots { position: absolute; left: 0; right: 0; bottom: 10px; display: flex; justify-content: center; gap: 6px; }
.m-gallery__dots span { width: 6px; height: 6px; border-radius: 3px; background: rgba(235, 231, 223, .4); }
.m-gallery__dots span[aria-current="true"] { width: 20px; background: var(--text); }
.m-gallery__counter {
  position: absolute; right: 12px; bottom: 6px; padding: 3px 8px; border-radius: var(--r-8);
  background: var(--overlay-control); font-family: var(--font-mono); font-size: var(--fs-11);
}
.m-card { padding: 18px 20px 24px; display: flex; flex-direction: column; gap: 14px; }
.m-card__title { margin: 0; font-family: var(--font-display); font-weight: 500; font-size: var(--fs-26); line-height: 1.15; }
.m-card__heading { display: flex; flex-direction: column; gap: 6px; }
.m-card .route { font-size: var(--fs-14); }
.m-card .chip { padding: 4px 9px; border-radius: var(--r-8); }
.m-specs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.m-specs .spec-tile { padding: 12px 14px; border-radius: var(--r-14); gap: 4px; }
.m-specs .spec-tile__value { font-size: 17px; }

.m-actionbar {
  position: sticky; bottom: 0; margin-top: auto; z-index: 5;
  display: flex; gap: 8px;
  padding: 12px 16px calc(16px + env(safe-area-inset-bottom));
  background: #121417; border-top: 1px solid var(--line);
}
.m-actionbar .btn { height: 52px; border-radius: var(--r-14); font-size: var(--fs-16); }
.m-actionbar .btn--grow { flex: 1; }
.m-actionbar .btn--grow2 { flex: 2; }
.m-actionbar .icon-btn { width: 52px; height: 52px; border-radius: var(--r-14); }

/* ---- Bottom sheet (delete confirm) ---- */
.m-sheet-scrim { position: fixed; inset: 0; z-index: 10; background: var(--scrim); display: flex; align-items: flex-end; justify-content: center; }
.m-sheet {
  width: 100%; max-width: 640px;
  padding: 12px 20px calc(28px + env(safe-area-inset-bottom));
  border-radius: 22px 22px 0 0; background: var(--surface); border-top: 1px solid var(--line-strong);
  display: flex; flex-direction: column; gap: 16px;
}
.m-sheet__grip { align-self: center; width: 40px; height: 4px; border-radius: 2px; background: var(--line-selected); }
.m-sheet .btn { height: 52px; border-radius: var(--r-14); font-size: var(--fs-16); }
.m-sheet__actions { display: flex; flex-direction: column; gap: 8px; }

/* ---- Page forms (login, lineup form) ---- */
.m-form { padding: 20px 16px 24px; display: flex; flex-direction: column; gap: 22px; }
.m-form--login { padding: 24px 20px; gap: 20px; }
.m-form .field { gap: 8px; }
.m-form .field__label { font-size: var(--fs-14); }
.m-form .input, .m-form .select { height: 52px; padding: 0 16px; border-radius: var(--r-14); background: var(--surface); font-size: 17px; }
.m-form .input--mono { font-size: var(--fs-16); }
.m-form .input--dashed { background: var(--bg-sidebar); font-size: var(--fs-16); }
.m-form .textarea { padding: 14px 16px; border-radius: var(--r-14); background: var(--surface); font-size: var(--fs-16); }
.m-form .choice { height: 48px; border-radius: var(--r-12); background: var(--surface); font-size: var(--fs-15); }
.m-form .choice--mono { font-size: var(--fs-14); }
.m-form .choices { gap: 6px; }
.m-form .pill { height: var(--control-h); padding: 0 14px; background: var(--surface); font-size: var(--fs-14); }
.m-form .image-item { padding: 6px 6px 6px 4px; border-radius: var(--r-14); background: var(--surface); border-color: var(--line); }
.m-form .image-item .thumb { width: 72px; height: 52px; border-radius: var(--r-8); }
.m-form .drag-handle { width: 36px; height: 52px; }
.m-form .dropzone { height: 64px; flex-direction: row; gap: 8px; font-size: var(--fs-15); }
.m-form .btn--primary.btn--block { height: 52px; border-radius: var(--r-14); font-size: var(--fs-16); }
.m-form__title { margin: 0; font-family: var(--font-display); font-weight: 500; font-size: var(--fs-28); }
.m-form__lead { margin: 0; font-size: var(--fs-15); line-height: 1.45; color: var(--text-muted); }

/* ---- Lightbox (fullscreen image, touch) ---- */
.m-lightbox { position: fixed; inset: 0; z-index: 20; background: var(--bg-lightbox); display: flex; flex-direction: column; }
.m-lightbox__bar { display: flex; align-items: center; gap: 12px; padding: 12px 12px 12px 20px; }
.m-lightbox__title { flex: 1; min-width: 0; font-size: var(--fs-15); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.m-lightbox__title span { font-weight: 400; color: var(--text-muted); }
.m-lightbox__stage { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; touch-action: none; }
.m-lightbox__image { width: 100%; aspect-ratio: 16 / 9; display: flex; align-items: center; justify-content: center; }
.m-lightbox__foot { padding: 16px 20px calc(24px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; align-items: center; gap: 10px; }
.m-lightbox__foot .m-gallery__dots { position: static; }
.m-lightbox__hint { font-size: var(--fs-13); color: var(--text-faint); }

/* selected states must win over the mobile surface overrides above */
.m-form .choice:is([aria-pressed="true"], :has(> input:checked)), .m-form .pill:is([aria-pressed="true"], :has(> input:checked)) { border-color: var(--text); background: var(--text); color: var(--text-on-light); }
.m-form .choice--t:is([aria-pressed="true"], :has(> input:checked)) { border-color: var(--side-t); background: var(--side-t-bg); color: var(--side-t); }
.m-form .choice--ct:is([aria-pressed="true"], :has(> input:checked)) { border-color: var(--side-ct); background: var(--side-ct-bg); color: var(--side-ct); }


/* ==================== 4. app glue ==================== */

/* One response carries both layouts; the breakpoint picks one (DESIGN.md §3). */
@media (min-width: 1024px) { .m-only { display: none !important; } }
@media (max-width: 1023px) { .d-only { display: none !important; } }

.contents { display: contents; }
.stack-6 { display: flex; flex-direction: column; gap: 6px; }
.stack-8 { display: flex; flex-direction: column; gap: 8px; }
.m-pad { padding: 0 20px; }
.btn--compact { padding: 0 14px; }
.btn--46 { height: 46px; }
.btn[disabled] { opacity: 0.6; cursor: default; }
.dialog__note--lead { font-size: var(--fs-14); line-height: 1.45; }
.field__label--14 { font-size: var(--fs-14); }
.legend-float { float: left; }
.clear { clear: both; }
.legend-4 { margin-bottom: 4px !important; }
.hint--4 { margin-bottom: 4px; }
.m-header--ruled { border-bottom: 1px solid var(--line-subtle); }
form { margin: 0; }

/* Links styled as the design's buttons */
a.segmented__item, a.m-type-tab, .m-side-filter a, a.icon-btn { text-decoration: none; }
.m-side-filter a { display: flex; align-items: center; justify-content: center; }
.link-btn { padding: 0; border: 0; background: none; color: var(--text-muted); font-size: inherit; text-decoration: underline; }
.m-session form { display: inline; margin-left: 4px; }

/* Radios inside .choice / .pill labels */
label.choice, label.pill { position: relative; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; user-select: none; }
.choice > input, .pill > input { position: absolute; width: 1px; height: 1px; margin: 0; opacity: 0; pointer-events: none; }
.choice:has(> input:focus-visible), .pill:has(> input:focus-visible) { outline: 2px solid var(--focus); outline-offset: 2px; }
fieldset.field { min-width: 0; }
.field--technique { gap: 8px; }
/* "Своя техника" is shown only while technique = custom */
.tech-custom { display: none; }
.field--technique:has(input[value="custom"]:checked) .tech-custom { display: block; }
.image-item--static { padding-left: 6px; }

/* Empty states */
.detail--empty { align-items: center; justify-content: center; color: var(--text-muted); font-size: var(--fs-15); }
.empty .btn { margin-top: 16px; }
.m-list .empty { list-style: none; }

/* Carousel: native horizontal scroll with scroll-snap */
.gallery, .m-gallery { overflow: hidden; }
.m-gallery { touch-action: auto; }
.gallery__track, .m-gallery__track {
  position: absolute; inset: 0; display: flex;
  overflow-x: auto; overflow-y: hidden; overscroll-behavior-x: contain;
  scroll-snap-type: x mandatory; scroll-behavior: smooth; scrollbar-width: none;
}
.gallery__track::-webkit-scrollbar, .m-gallery__track::-webkit-scrollbar { display: none; }
.gallery__track img, .m-gallery__track img {
  flex: 0 0 100%; width: 100%; height: 100%; object-fit: contain;
  scroll-snap-align: start; scroll-snap-stop: always;
}
.thumbs__item img { width: 100%; height: 100%; object-fit: cover; display: block; }
.m-row .thumb img, .lineup-row .thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* Native <dialog>: reset UA styles, reuse the design's containers inside */
dialog { color: inherit; }
dialog.dlg { padding: 0; border: 0; background: transparent; max-width: calc(100vw - 32px); max-height: calc(100dvh - 32px); overflow: visible; }
dialog.dlg--sheet { width: 100%; max-width: 640px; margin: auto auto 0; max-height: 100dvh; }
dialog.dlg::backdrop { background: rgba(5, 6, 7, 0.72); }
dialog.lightbox, dialog.m-lightbox { width: 100%; height: 100%; max-width: none; max-height: none; margin: 0; padding: 0; border: 0; }
dialog.lightbox:not([open]), dialog.m-lightbox:not([open]) { display: none; }
dialog.lightbox::backdrop, dialog.m-lightbox::backdrop { background: #050607; }
.m-lightbox__stage { overflow: hidden; }
.lightbox__image img, .m-lightbox__image img {
  width: 100%; height: 100%; object-fit: contain; display: block;
  transform-origin: center; user-select: none; -webkit-user-drag: none; touch-action: none;
}
.lightbox__image { touch-action: none; }
.m-lightbox__foot .m-gallery__dots span { cursor: default; }

/* List skeletons (DESIGN.md §5 "Загрузка"): striped rows the size of a real one */
.skeleton-row { flex-shrink: 0; height: 63px; border-radius: var(--r-14); list-style: none; }
.m-list .skeleton-row { height: 84px; border-radius: var(--r-16); }

/* Portrait screenshots (taken on a phone). The design frames every gallery
   as 16:9; a tall image inside it shrinks to a sliver. With --ar set by the
   server the frame takes the image's own proportions instead:
   - desktop: the image stands on the left at the full height of the pane,
     title, thumbnails and description go to the right of it;
   - phone: full width, up to the height of the screen;
   - fullscreen view: the whole stage, not a 16:9 box inside it. */
.detail--portrait {
  --pad: 24px;
  display: grid; grid-template-columns: auto minmax(0, 1fr); grid-auto-rows: min-content;
  column-gap: 28px; row-gap: 14px; align-content: start;
}
.detail--portrait > * { grid-column: 2; }
.detail--portrait > .gallery--portrait {
  grid-column: 1; grid-row: 1 / span 4;
  height: calc(100vh - var(--topbar-h) - 2 * var(--pad)); min-height: 408px;
  aspect-ratio: var(--ar); max-height: none; max-width: 60vw;
}
.detail--portrait .detail__head, .detail--portrait .detail__titleline { flex-wrap: wrap; }
.detail--portrait .detail__info { flex-direction: column; }
.detail--portrait .thumbs { flex-wrap: wrap; }
@media (max-width: 1279px) { .detail--portrait { --pad: 20px; column-gap: 20px; } }
.m-gallery--portrait { aspect-ratio: var(--ar); max-height: 100dvh; }
.lightbox--portrait .lightbox__image,
.m-lightbox--portrait .m-lightbox__image { aspect-ratio: auto; height: 100%; }

/* Fifth kind: wallbangs. The design draws four grenade types. */
.m-type-tabs { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.m-type-tab { font-size: var(--fs-11); }
/* Five tabs do not fit the compact desktop topbar with icons: text only there. */
@media (min-width: 1024px) and (max-width: 1279px) {
  .topbar .segmented__item .icon { display: none; }
  .page-title { white-space: nowrap; }
}
.choices--5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.m-form .choices--5 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
/* Technique and button make no sense for a wallbang: the form disables those
   fieldsets (so they are neither validated nor sent) and hides them. */
fieldset[data-throw-only]:disabled { display: none; }
