/* HSBSG Squash – UI-Farbsystem und Layout
   Markenfarben aus dem Logo: Blau #00A0E3, Gelb/Orange #F9B33B, Dunkelgrau #434242. */

@font-face { font-family: "Barlow"; font-weight: 400; font-display: swap; src: url("../fonts/barlow-latin-400-normal.2bc763014449.woff2") format("woff2"); }
@font-face { font-family: "Barlow"; font-weight: 500; font-display: swap; src: url("../fonts/barlow-latin-500-normal.d312d179276a.woff2") format("woff2"); }
@font-face { font-family: "Barlow"; font-weight: 600; font-display: swap; src: url("../fonts/barlow-latin-600-normal.8074c760fbdd.woff2") format("woff2"); }
@font-face { font-family: "Barlow"; font-weight: 700; font-display: swap; src: url("../fonts/barlow-latin-700-normal.c3609c36a150.woff2") format("woff2"); }
@font-face { font-family: "Barlow Condensed"; font-weight: 600; font-display: swap; src: url("../fonts/barlow-condensed-latin-600-normal.16cc9e59e14c.woff2") format("woff2"); }
@font-face { font-family: "Barlow Condensed"; font-weight: 700; font-display: swap; src: url("../fonts/barlow-condensed-latin-700-normal.936740600377.woff2") format("woff2"); }
@font-face { font-family: "Barlow Condensed"; font-weight: 800; font-display: swap; src: url("../fonts/barlow-condensed-latin-800-normal.7afb40486142.woff2") format("woff2"); }

:root {
  color-scheme: light;
  --brand-blue: #00a0e3;
  --brand-yellow: #f9b33b;
  --brand-dark: #434242;

  --bg: #f3f6f8;
  --surface: #ffffff;
  --surface-2: #eef3f6;
  --surface-3: #e4ecf1;
  --border: #dce4e9;
  --border-strong: #c3ced5;
  --text: #1d2124;
  --text-2: #4c5358;
  --muted: #6a737a;
  --link: #00719f;
  --accent: #00a0e3;
  --accent-ink: #00719f;
  --accent-soft: #e0f3fc;
  --accent-2: #f9b33b;
  --accent-2-soft: #fff2d9;
  --accent-2-ink: #8a5a00;
  --on-accent: #ffffff;
  --on-accent-2: #2b2200;
  --header: #ffffff;

  --ok: #0a7d32; --ok-soft: #e3f5e8;
  --warn: #9a5b00; --warn-soft: #fff1d6; --warn-line: #e5a11c;
  --err: #b42318; --err-soft: #fde8e6; --err-line: #d64535;
  --info: #00719f; --info-soft: #e0f3fc;

  /* Diagramm-Palette (validiert, Reihenfolge = CVD-Sicherheit) */
  --series-1: #0a8fcc; --series-2: #eb6834; --series-3: #1baf7a; --series-4: #eda100;
  --series-5: #e87ba4; --series-6: #008300; --series-7: #6250d6; --series-8: #e34948;
  --series-muted: #c3ced5;
  --chart-grid: #e6ecef; --chart-axis: #c3ced5; --chart-text: #6a737a;

  --radius: 14px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(16, 24, 32, .06), 0 4px 16px rgba(16, 24, 32, .05);
  --font: "Barlow", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-display: "Barlow Condensed", "Barlow", system-ui, sans-serif;
  --maxw: 1180px;
  --gutter: 16px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #101417; --surface: #181e22; --surface-2: #1f272c; --surface-3: #263037;
    --border: #2b353b; --border-strong: #3a464d;
    --text: #eef2f4; --text-2: #c2cace; --muted: #8b969c;
    --link: #5cc4f0; --accent: #1f9ad6; --accent-ink: #5cc4f0; --accent-soft: #11303f;
    --accent-2-soft: #3a2c10; --accent-2-ink: #f9c66b; --header: #14191c;
    --ok: #4cc276; --ok-soft: #12301d; --warn: #f2b84b; --warn-soft: #3a2a0c; --warn-line: #c98500;
    --err: #ff8a7a; --err-soft: #3c1714; --err-line: #e66767; --info: #5cc4f0; --info-soft: #11303f;
    --series-1: #1f9ad6; --series-2: #d95926; --series-3: #199e70; --series-4: #c98500;
    --series-5: #d55181; --series-6: #008300; --series-7: #9085e9; --series-8: #e66767;
    --series-muted: #3a464d; --chart-grid: #263037; --chart-axis: #3a464d; --chart-text: #8b969c;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #101417; --surface: #181e22; --surface-2: #1f272c; --surface-3: #263037;
  --border: #2b353b; --border-strong: #3a464d;
  --text: #eef2f4; --text-2: #c2cace; --muted: #8b969c;
  --link: #5cc4f0; --accent: #1f9ad6; --accent-ink: #5cc4f0; --accent-soft: #11303f;
  --accent-2-soft: #3a2c10; --accent-2-ink: #f9c66b; --header: #14191c;
  --ok: #4cc276; --ok-soft: #12301d; --warn: #f2b84b; --warn-soft: #3a2a0c; --warn-line: #c98500;
  --err: #ff8a7a; --err-soft: #3c1714; --err-line: #e66767; --info: #5cc4f0; --info-soft: #11303f;
  --series-1: #1f9ad6; --series-2: #d95926; --series-3: #199e70; --series-4: #c98500;
  --series-5: #d55181; --series-6: #008300; --series-7: #9085e9; --series-8: #e66767;
  --series-muted: #3a464d; --chart-grid: #263037; --chart-axis: #3a464d; --chart-text: #8b969c;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 400 16px/1.5 var(--font);
  overflow-x: hidden;
}
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }
h1, h2, h3 { font-family: var(--font-display); font-weight: 700; line-height: 1.15; letter-spacing: .01em; margin: 0 0 .5em; }
h1 { font-size: clamp(1.8rem, 4vw, 2.5rem); }
h2 { font-size: 1.45rem; }
h3 { font-size: 1.15rem; }
p { margin: 0 0 1em; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.nowrap { white-space: nowrap; }
.num { font-variant-numeric: tabular-nums; text-align: right; }
.pos { color: var(--ok); }
.neg { color: var(--err); }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

/* ---------- Header & Navigation ---------- */
.site-header {
  background: var(--header); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 40;
}
.site-header .inner {
  max-width: var(--maxw); margin: 0 auto; padding: 8px var(--gutter);
  display: flex; align-items: center; gap: 20px;
}
.brand { display: flex; align-items: center; color: inherit; flex-shrink: 0; }
.brand:hover { text-decoration: none; }
/* Original-Logo (PNG mit Transparenz). Im Dunkelmodus auf heller Fläche, damit der
   dunkle Squashball und die ausgesparte Schrift im Band sichtbar bleiben. */
.logo-img { height: 48px; width: auto; display: block; }
:root[data-theme="dark"] .logo-img { background: #ffffff; border-radius: 8px; padding: 4px 8px; box-sizing: content-box; height: 40px; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .logo-img { background: #ffffff; border-radius: 8px; padding: 4px 8px; box-sizing: content-box; height: 40px; }
}

.main-nav { display: flex; gap: 4px; flex: 1; }
.main-nav a, .member-nav a {
  color: var(--text-2); font-weight: 600; padding: 8px 12px; border-radius: 999px; white-space: nowrap;
}
.main-nav a:hover, .member-nav a:hover { background: var(--surface-2); text-decoration: none; color: var(--text); }
.main-nav a[aria-current="page"] { background: var(--accent-soft); color: var(--accent-ink); }
.member-nav { display: flex; gap: 4px; align-items: center; }
.btn-capture {
  background: var(--accent-2); color: var(--on-accent-2) !important; font-weight: 700;
}
.btn-capture:hover { filter: brightness(.97); background: var(--accent-2) !important; }

.bottom-nav { display: none; }
@media (max-width: 860px) {
  .main-nav { display: none; }
  .member-nav .hide-mobile { display: none; }
  .site-header .inner { justify-content: space-between; gap: 8px; }
  .logo-img { height: 40px; }
  .bottom-nav {
    display: grid; grid-template-columns: repeat(5, 1fr);
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
    background: var(--header); border-top: 1px solid var(--border);
    padding: 4px 4px calc(4px + env(safe-area-inset-bottom));
  }
  .bottom-nav a {
    display: flex; flex-direction: column; align-items: center; gap: 2px;
    color: var(--muted); font-size: .72rem; font-weight: 600; padding: 6px 0; border-radius: 10px;
  }
  .bottom-nav a svg { width: 22px; height: 22px; }
  .bottom-nav a[aria-current="page"] { color: var(--accent-ink); background: var(--accent-soft); }
  .bottom-nav a.capture { color: var(--accent-2-ink); }
  body { padding-bottom: 76px; }
}

/* ---------- Layout ---------- */
main { max-width: var(--maxw); margin: 0 auto; padding: 20px var(--gutter) 48px; }
.page-head { display: flex; flex-wrap: wrap; align-items: end; justify-content: space-between; gap: 12px; margin: 8px 0 18px; }
.page-head h1 { margin: 0; }
.eyebrow { font: 700 .8rem/1 var(--font-display); letter-spacing: .14em; text-transform: uppercase; color: var(--accent-ink); margin-bottom: 6px; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-main { grid-template-columns: minmax(0, 1.65fr) minmax(0, 1fr); }
@media (max-width: 960px) { .grid-2, .grid-3, .grid-main { grid-template-columns: minmax(0, 1fr); } }
.stack > * + * { margin-top: 16px; }

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 18px; min-width: 0;
}
.card > h2:first-child, .card > h3:first-child, .card-head h2, .card-head h3 { margin-bottom: 0; }
.card-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 8px 16px; margin-bottom: 14px; }
.card-flush { padding: 0; overflow: hidden; }
.card-flush .card-head { padding: 16px 18px 0; }
.card.accent { border-top: 4px solid var(--accent); }
.card.accent-2 { border-top: 4px solid var(--accent-2); }

/* ---------- Buttons & Forms ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 10px 18px; border-radius: 999px; border: 1px solid transparent;
  font: 700 1rem/1 var(--font); cursor: pointer; text-decoration: none !important;
  background: var(--accent); color: var(--on-accent);
}
.btn:hover { filter: brightness(1.05); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.btn-secondary:hover { background: var(--surface-2); }
.btn-accent { background: var(--accent-2); color: var(--on-accent-2); }
.btn-danger { background: var(--surface); color: var(--err); border-color: var(--err-line); }
.btn-ghost { background: transparent; color: var(--link); padding-inline: 10px; }
.btn-sm { min-height: 34px; padding: 6px 12px; font-size: .875rem; }
.btn-lg { min-height: 56px; padding: 14px 26px; font-size: 1.1rem; }
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }

label { font-weight: 600; font-size: .9rem; color: var(--text-2); }
input[type=text], input[type=password], input[type=date], input[type=number], input[type=search], select, textarea {
  font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); padding: 9px 11px; min-height: 42px; width: 100%;
}
textarea { min-height: 80px; }
.field { display: flex; flex-direction: column; gap: 4px; }
.form-row { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); align-items: end; }
.checkbox { display: flex; gap: 8px; align-items: center; font-weight: 500; color: var(--text); }
.checkbox input { width: 20px; height: 20px; }

.filter-bar {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: end;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; margin-bottom: 16px;
}
.filter-bar .field { min-width: 140px; flex: 1 1 140px; }
.filter-bar .btn { flex: 0 0 auto; }

/* ---------- KPI / Stat tiles ---------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 12px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
.kpi .label { font-size: .8rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.kpi .value { font: 700 1.9rem/1.1 var(--font-display); margin-top: 4px; }
.kpi .hint { font-size: .82rem; color: var(--text-2); margin-top: 2px; }
.kpi.highlight { background: linear-gradient(135deg, var(--accent-soft), var(--surface)); border-color: transparent; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.data { width: 100%; border-collapse: collapse; font-size: .95rem; }
table.data th, table.data td { padding: 10px 10px; border-bottom: 1px solid var(--border); text-align: left; }
table.data th { font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; white-space: nowrap; background: var(--surface); }
table.data tbody tr:hover { background: var(--surface-2); }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.data .rank { width: 44px; font: 700 1.1rem/1 var(--font-display); color: var(--text-2); text-align: center; }
table.data tr.top-1 .rank { color: var(--on-accent-2); }
table.data tr.top-1 .rank span.rk { background: var(--accent-2); border-radius: 999px; display: inline-block; min-width: 28px; padding: 5px 0; }
table.data .points { font-weight: 700; font-size: 1.05rem; }
table.data .player-cell { font-weight: 600; white-space: nowrap; }
table.data tr.is-me { background: var(--accent-soft); }
.card-flush table.data th:first-child, .card-flush table.data td:first-child { padding-left: 18px; }
.card-flush table.data th:last-child, .card-flush table.data td:last-child { padding-right: 18px; }
@media (max-width: 640px) {
  table.data th, table.data td { padding: 9px 7px; }
  .hide-sm { display: none; }
}
.move { font-size: .7rem; margin-left: 4px; vertical-align: middle; }
.move-up { color: var(--ok); }
.move-down { color: var(--err); }
.move-same { display: none; }
.move-new { color: var(--accent-ink); font-weight: 700; font-size: .68rem; text-transform: uppercase; }

.badge {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px;
  font-size: .75rem; font-weight: 700; background: var(--surface-3); color: var(--text-2); white-space: nowrap;
}
.badge-accent { background: var(--accent-soft); color: var(--accent-ink); }
.badge-gold { background: var(--accent-2-soft); color: var(--accent-2-ink); }
.badge-ok { background: var(--ok-soft); color: var(--ok); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-err { background: var(--err-soft); color: var(--err); }

/* ---------- Ergebnismatrix (Anzeige) ---------- */
.matrix-wrap { overflow-x: auto; }
table.matrix { border-collapse: separate; border-spacing: 0; font-variant-numeric: tabular-nums; }
table.matrix th, table.matrix td {
  border-right: 1px solid var(--border); border-bottom: 1px solid var(--border);
  min-width: 62px; height: 42px; text-align: center; padding: 4px 6px; font-size: .95rem;
}
table.matrix tr:first-child th { border-top: 1px solid var(--border); }
table.matrix th:first-child, table.matrix td:first-child { border-left: 1px solid var(--border); }
table.matrix thead th { background: var(--surface-2); font-weight: 700; font-size: .85rem; white-space: nowrap; }
table.matrix tbody th { background: var(--surface-2); text-align: left; white-space: nowrap; position: sticky; left: 0; z-index: 1; font-size: .9rem; }
table.matrix td.diag {
  background:
    linear-gradient(to top right, transparent calc(50% - 1px), var(--border-strong) 50%, transparent calc(50% + 1px)),
    linear-gradient(to bottom right, transparent calc(50% - 1px), var(--border-strong) 50%, transparent calc(50% + 1px)),
    var(--surface-3);
}
table.matrix td.win { background: var(--accent-soft); font-weight: 700; }
table.matrix td.loss { color: var(--text-2); }
.matrix-legend { font-size: .82rem; color: var(--muted); margin-top: 8px; }

.result-list { list-style: none; margin: 0; padding: 0; }
.result-list li { display: grid; grid-template-columns: 1fr auto 1fr auto; gap: 8px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--border); }
.result-list .w { font-weight: 700; text-align: right; }
.result-list .score { font: 700 1.05rem/1 var(--font-display); background: var(--surface-2); padding: 6px 10px; border-radius: 8px; min-width: 64px; text-align: center; }
.result-list .pts { font-size: .78rem; color: var(--muted); white-space: nowrap; }

/* ---------- Chips (Spielerauswahl in Diagrammen) ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; min-height: 36px;
  border: 1px solid var(--border-strong); border-radius: 999px; background: var(--surface);
  font: 600 .875rem/1 var(--font); color: var(--text-2); cursor: pointer;
}
.chip .swatch { width: 12px; height: 12px; border-radius: 50%; background: var(--series-muted); flex: 0 0 auto; }
.chip[aria-pressed="true"] { color: var(--text); border-color: currentColor; background: var(--surface-2); }
.chip:disabled { opacity: .45; cursor: not-allowed; }
.chart-box { position: relative; height: 320px; }
.chart-box.tall { height: 380px; }
.chart-box.short { height: 240px; }
@media (max-width: 640px) { .chart-box { height: 260px; } .chart-box.tall { height: 320px; } }
details.table-view { margin-top: 10px; }
details.table-view summary { cursor: pointer; color: var(--link); font-weight: 600; font-size: .9rem; }
.chart-note { font-size: .82rem; color: var(--muted); margin-top: 6px; }

/* ---------- Fakten ---------- */
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 10px; }
.fact { background: var(--surface-2); border-radius: var(--radius-sm); padding: 12px 14px; }
.fact .k { font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; }
.fact .v { font-weight: 700; font-size: 1.05rem; margin-top: 2px; }
.fact .d { font-size: .85rem; color: var(--text-2); }

/* ---------- Spielerkarten ---------- */
.player-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.player-card { display: block; color: inherit; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
.player-card:hover { text-decoration: none; border-color: var(--accent); }
.player-card .name { font: 700 1.3rem/1.1 var(--font-display); }
.player-card .meta { font-size: .85rem; color: var(--text-2); margin-top: 6px; display: flex; flex-wrap: wrap; gap: 4px 12px; }
.avatar {
  width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; flex: 0 0 auto;
  background: var(--accent-soft); color: var(--accent-ink); font: 800 1.2rem/1 var(--font-display);
}
.profile-head { display: flex; gap: 16px; align-items: center; }
.profile-head .avatar { width: 64px; height: 64px; font-size: 1.7rem; }

/* ---------- Hinweise ---------- */
.messages { list-style: none; padding: 0; margin: 0 0 16px; display: grid; gap: 8px; }
.messages li { padding: 12px 14px; border-radius: var(--radius-sm); border-left: 4px solid var(--info); background: var(--info-soft); }
.messages li.success { border-color: var(--ok); background: var(--ok-soft); }
.messages li.warning { border-color: var(--warn-line); background: var(--warn-soft); }
.messages li.error { border-color: var(--err-line); background: var(--err-soft); }
.callout { padding: 12px 14px; border-radius: var(--radius-sm); background: var(--surface-2); border-left: 4px solid var(--accent); }
.callout.warn { background: var(--warn-soft); border-color: var(--warn-line); }

/* ---------- Footer ---------- */
.site-footer { max-width: var(--maxw); margin: 0 auto; padding: 24px var(--gutter) 40px; color: var(--muted); font-size: .85rem; display: flex; flex-wrap: wrap; gap: 8px 20px; justify-content: space-between; }
.theme-toggle { background: none; border: 1px solid var(--border-strong); border-radius: 999px; color: var(--text-2); padding: 4px 10px; font: inherit; cursor: pointer; }

/* ---------- Erfassung / Matrix-Editor ---------- */
.capture-hero { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
@media (max-width: 760px) { .capture-hero { grid-template-columns: 1fr; } }
.capture-option { display: flex; flex-direction: column; gap: 12px; align-items: flex-start; }
.capture-option .icon { width: 52px; height: 52px; border-radius: 14px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent-ink); }
.capture-option.photo .icon { background: var(--accent-2-soft); color: var(--accent-2-ink); }
.dropzone { width: 100%; border: 2px dashed var(--border-strong); border-radius: var(--radius); padding: 18px; text-align: center; background: var(--surface-2); }
.dropzone input[type=file] { width: 100%; }
.steps { display: flex; gap: 6px; flex-wrap: wrap; list-style: none; padding: 0; margin: 0 0 16px; counter-reset: step; }
.steps li { counter-increment: step; display: flex; align-items: center; gap: 8px; padding: 6px 12px 6px 6px; border-radius: 999px; background: var(--surface); border: 1px solid var(--border); font-weight: 600; font-size: .88rem; color: var(--muted); }
.steps li::before { content: counter(step); width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-3); font-size: .8rem; }
.steps li.done { color: var(--text-2); }
.steps li.done::before { content: "✓"; background: var(--ok-soft); color: var(--ok); }
.steps li.current { color: var(--text); border-color: var(--accent); }
.steps li.current::before { background: var(--accent); color: var(--on-accent); }

.review { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr); gap: 16px; align-items: start; }
.review.no-photo { grid-template-columns: minmax(0, 1fr); }
@media (max-width: 1080px) { .review { grid-template-columns: minmax(0, 1fr); } }
.photo-panel { position: sticky; top: 76px; }
@media (max-width: 1080px) { .photo-panel { position: static; } }
.photo-stage {
  position: relative; overflow: hidden; border-radius: var(--radius-sm); background: #1b1f22;
  height: min(62vh, 620px); touch-action: none; cursor: grab;
}
.photo-stage.dragging { cursor: grabbing; }
.photo-stage .layer { position: absolute; left: 0; top: 0; transform-origin: 0 0; }
.photo-stage img { display: block; max-width: none; user-select: none; -webkit-user-drag: none; }
.photo-stage .hl { position: absolute; border: 3px solid var(--brand-yellow); border-radius: 6px; box-shadow: 0 0 0 9999px rgba(0,0,0,.35); pointer-events: none; display: none; }
.photo-tools { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.photo-tabs { display: none; }
@media (max-width: 1080px) {
  .photo-tabs { display: flex; gap: 6px; margin-bottom: 12px; position: sticky; top: 62px; z-index: 30; background: var(--bg); padding: 6px 0; }
  .photo-tabs button { flex: 1; }
  .review[data-tab="matrix"] .photo-panel { display: none; }
  .review[data-tab="photo"] .editor-panel { display: none; }
}

.editor-meta { display: grid; gap: 12px; grid-template-columns: 1.3fr .8fr .8fr; }
@media (max-width: 640px) { .editor-meta { grid-template-columns: 1fr 1fr; } .editor-meta .field:first-child { grid-column: span 2; } }
.editor-grid-wrap { overflow: auto; max-height: 72vh; border: 1px solid var(--border); border-radius: var(--radius-sm); margin-top: 12px; }
table.editor { border-collapse: separate; border-spacing: 0; }
table.editor th, table.editor td { border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); padding: 0; }
table.editor thead th { position: sticky; top: 0; z-index: 3; background: var(--surface-2); }
table.editor tbody th { position: sticky; left: 0; z-index: 2; background: var(--surface-2); }
table.editor thead th:first-child { left: 0; z-index: 4; }
table.editor .head { display: flex; flex-direction: column; gap: 4px; padding: 6px; min-width: 104px; }
table.editor .head select, table.editor .head input { min-height: 34px; padding: 5px 7px; font-size: .88rem; }
table.editor .head .raw { font-size: .75rem; color: var(--muted); }
table.editor .head.is-error { box-shadow: inset 0 0 0 2px var(--err-line); background: var(--err-soft); }
table.editor .head.is-warning { box-shadow: inset 0 0 0 2px var(--warn-line); background: var(--warn-soft); }
table.editor .rowhead { padding: 6px 10px; min-width: 84px; font-weight: 700; white-space: nowrap; }
table.editor .head-tools { display: flex; gap: 3px; }
table.editor .head-tools .icon-btn { min-width: 26px; height: 26px; font-size: .8rem; }
table.editor .head-tools .icon-btn:disabled { opacity: .35; cursor: default; }
table.editor td.cell { position: relative; }
table.editor td.cell input {
  width: 64px; height: 46px; border: 0; border-radius: 0; text-align: center; font: 600 1rem/1 var(--font);
  font-variant-numeric: tabular-nums; background: transparent; color: var(--text); padding: 0; min-height: 0;
}
table.editor td.cell input:focus { outline: none; background: var(--accent-soft); }
table.editor td.cell.is-mirror-focus { background: var(--accent-soft); }
table.editor td.cell.is-error { box-shadow: inset 0 0 0 2px var(--err-line); background: var(--err-soft); }
table.editor td.cell.is-warning { box-shadow: inset 0 0 0 2px var(--warn-line); background: var(--warn-soft); }
table.editor td.cell.is-info input { color: var(--accent-ink); }
table.editor td.cell .flag { position: absolute; top: 2px; right: 3px; font-size: .65rem; font-weight: 800; line-height: 1; pointer-events: none; }
table.editor td.cell.is-error .flag { color: var(--err); }
table.editor td.cell.is-warning .flag { color: var(--warn); }
table.editor td.cell.is-changed input { text-decoration: underline wavy var(--accent-2); }
table.editor td.diag { background:
    linear-gradient(to top right, transparent calc(50% - 1px), var(--border-strong) 50%, transparent calc(50% + 1px)),
    linear-gradient(to bottom right, transparent calc(50% - 1px), var(--border-strong) 50%, transparent calc(50% + 1px)),
    var(--surface-3); width: 72px; }
.icon-btn { border: 1px solid var(--border-strong); background: var(--surface); color: var(--text-2); border-radius: 8px; min-width: 30px; height: 30px; cursor: pointer; font-weight: 700; }
.icon-btn:hover { background: var(--surface-2); }
.icon-btn.danger { color: var(--err); }
.icon-btn.armed { background: var(--err-soft); border-color: var(--err-line); padding: 0 6px; font-size: .75rem; }

.issues { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.issues li { display: flex; gap: 10px; align-items: flex-start; padding: 9px 12px; border-radius: var(--radius-sm); background: var(--surface-2); font-size: .92rem; }
.issues li .lvl { flex: 0 0 auto; font-weight: 800; font-size: .7rem; padding: 3px 7px; border-radius: 6px; text-transform: uppercase; letter-spacing: .05em; margin-top: 1px; }
.issues li.error { background: var(--err-soft); } .issues li.error .lvl { background: var(--err-line); color: #fff; }
.issues li.warning { background: var(--warn-soft); } .issues li.warning .lvl { background: var(--warn-line); color: #241600; }
.issues li.info .lvl { background: var(--surface-3); color: var(--text-2); }
.issues li .msg { flex: 1; }
.issues li button { flex: 0 0 auto; }
.issue-summary { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 10px; }
.sticky-actions {
  position: sticky; bottom: 0; z-index: 20; background: var(--surface); border-top: 1px solid var(--border);
  margin: 16px -18px -18px; padding: 12px 18px; border-radius: 0 0 var(--radius) var(--radius);
  display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between;
}
@media (max-width: 860px) { .sticky-actions { bottom: 66px; } }

.diff-list { margin: 0; padding-left: 18px; }
.diff-list li { margin: 2px 0; }
pre.json { background: var(--surface-2); border-radius: var(--radius-sm); padding: 12px; overflow: auto; max-height: 420px; font-size: .8rem; }
.pagination { display: flex; gap: 8px; align-items: center; justify-content: center; margin-top: 16px; }
.empty { text-align: center; padding: 32px 16px; color: var(--muted); }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { padding: 8px 0; border-bottom: 1px solid var(--border); display: flex; gap: 10px; justify-content: space-between; flex-wrap: wrap; font-size: .92rem; }
@media (max-width: 640px) {
  .sticky-actions { padding: 8px 12px; }
  .sticky-actions [data-save-hint] { display: none; }
  .sticky-actions > .btn-row { flex-wrap: nowrap; width: 100%; }
  .sticky-actions > .btn-row .btn { flex: 1 1 auto; min-height: 46px; padding: 10px 12px; font-size: 1rem; }
  .photo-stage { height: 52vh; }
}
