/* Warlogs — colori del logo: verde #5EBC67, nero #222, bianco */
:root {
  --blue: #222222;        /* nero del logo: barra, pulsanti principali, scelte attive */
  --blue-ink: #111111;
  --accent: #2E8A3B;      /* verde scuro leggibile su chiaro: link, schede attive */
  --gold: #5EBC67;        /* verde del logo: riempimenti e segni di evidenza */
  --gold-soft: #E3F3E5;
  --red: #C2302B;
  --red-soft: #FBE6E4;
  --green: #2E8A3B;
  --green-soft: #E3F3E5;
  --warn: #C98A1E;
  --warn-soft: #FBF0DC;
  --ink: #222222;
  --muted: #5E625E;
  --line: #D9DCD9;
  --bg: #F3F4F3;
  --surface: #FFFFFF;
  --surface-2: #F7F8F7;
  --onblue: #FFFFFF;
  --shadow: 0 6px 24px rgba(0, 0, 0, .14);
  --cond: "Roboto Condensed", "sans-serif-condensed", "Arial Narrow", "Helvetica Neue", sans-serif;
  --sans: Roboto, "Segoe UI", system-ui, -apple-system, sans-serif;
  --nav-h: 64px;
  --bar-h: 56px;
  color-scheme: light;
}
[data-theme="dark"] {
  --blue: #5EBC67;        /* nel tema scuro i pulsanti principali sono verdi */
  --accent: #74CF7C;
  --gold: #5EBC67;
  --gold-soft: #1F3322;
  --red: #EF6A63;
  --red-soft: #3D2322;
  --green: #74CF7C;
  --green-soft: #1F3322;
  --warn: #E5A94A;
  --warn-soft: #3A3020;
  --ink: #EDEFED;
  --muted: #A4A9A4;
  --line: #3A3D3A;
  --bg: #181918;
  --surface: #222422;
  --surface-2: #2A2D2A;
  --onblue: #101610;
  --shadow: 0 8px 28px rgba(0, 0, 0, .5);
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--sans); font-size: 16px; line-height: 1.45; color: var(--ink); background: var(--bg);
  overscroll-behavior: none; -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { font-family: var(--cond); font-weight: 700; line-height: 1.15; margin: 0; letter-spacing: .005em; }
h2 { font-size: 21px; }
h3 { font-size: 17px; }
p { margin: 0 0 .6em; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.hidden { display: none !important; }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* ------------------------------------------------ shell */
#app { display: grid; grid-template-rows: var(--bar-h) 1fr var(--nav-h); grid-template-columns: minmax(0, 1fr); height: 100%; }
main { min-width: 0; }
.appbar {
  background: #222222; color: #FFFFFF; display: flex; align-items: center; gap: 4px;
  padding: 0 4px 0 8px; z-index: 5;
}
.appbar h1 { font-size: 21px; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding-left: 8px; }
.appbar .sub { display: block; font-family: var(--sans); font-weight: 400; font-size: 12px; opacity: .8; }
.iconbtn {
  width: 44px; height: 44px; border: 0; background: transparent; border-radius: 22px; display: grid; place-items: center;
  color: inherit; cursor: pointer; flex: none;
}
.iconbtn:active { background: rgba(255,255,255,.16); }
.iconbtn svg { width: 24px; height: 24px; }
main { overflow-y: auto; overflow-x: hidden; -webkit-overflow-scrolling: touch; position: relative; }
.page { max-width: 1100px; margin: 0 auto; padding: 16px 16px 96px; }
.nav {
  display: grid; grid-template-columns: repeat(5, 1fr); background: var(--surface); border-top: 1px solid var(--line); z-index: 5;
}
.nav button {
  border: 0; background: none; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  font-size: 12px; color: var(--muted); cursor: pointer; padding: 6px 0;
}
.nav button svg { width: 24px; height: 24px; }
.nav button[aria-current="page"] { color: var(--accent); font-weight: 600; }
.nav button[aria-current="page"] .pill { background: var(--gold-soft); }
.nav .pill { width: 56px; height: 30px; border-radius: 15px; display: grid; place-items: center; }

@media (min-width: 840px) {
  #app { grid-template-columns: 96px minmax(0, 1fr); grid-template-rows: var(--bar-h) 1fr; }
  .appbar { grid-column: 2; grid-row: 1; }
  main { grid-column: 2; grid-row: 2; }
  .nav { grid-column: 1; grid-row: 1 / span 2; grid-template-columns: 1fr; grid-auto-rows: 76px; align-content: start;
    border-top: 0; border-right: 1px solid var(--line); padding-top: 12px; }
  .page { padding: 24px 28px 64px; }
}

/* ------------------------------------------------ elementi base */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 18px;
  border-radius: 10px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; font-weight: 600;
}
.btn svg { width: 20px; height: 20px; }
.btn.primary { background: var(--blue); color: var(--onblue); border-color: var(--blue); }
.btn.gold { background: var(--gold); color: #101610; border-color: var(--gold); }
.btn.danger { color: var(--red); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .45; cursor: default; }
.row-btns { display: flex; gap: 10px; flex-wrap: wrap; }
.fab {
  position: fixed; right: 20px; bottom: calc(var(--nav-h) + 20px); z-index: 6; min-height: 56px; border-radius: 16px;
  padding: 0 22px; box-shadow: var(--shadow);
}
@media (min-width: 840px) { .fab { bottom: 28px; right: 32px; } }

.field { display: block; margin: 0 0 14px; }
.field > span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.input, select.input, textarea.input {
  width: 100%; min-height: 46px; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--surface); outline: none;
}
.input:focus { border-color: var(--accent); }
textarea.input { min-height: 120px; resize: vertical; font-family: monospace; font-size: 13px; }

.seg { display: flex; background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; padding: 3px; gap: 3px; overflow-x: auto; }
.seg button { flex: 1; min-height: 38px; border: 0; background: transparent; border-radius: 9px; cursor: pointer; white-space: nowrap; padding: 0 12px; }
.seg button[aria-pressed="true"] { background: var(--surface); box-shadow: 0 1px 3px rgba(0,0,0,.12); font-weight: 600; color: var(--accent); }

.section { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; margin-bottom: 16px; overflow: hidden; }
.section > header { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; padding: 12px 16px 8px; }
.section > header h2, .section > header h3 { font-size: 17px; }
.section .body { padding: 0 16px 14px; }
.list { list-style: none; margin: 0; padding: 0; }
.item {
  display: flex; align-items: center; gap: 12px; min-height: 56px; padding: 10px 16px; border-top: 1px solid var(--line); cursor: pointer;
}
.item:first-child { border-top: 0; }
.section > header + .list .item:first-child { border-top: 1px solid var(--line); }
.item:active { background: var(--surface-2); }
.item .main { flex: 1; min-width: 0; }
.item > svg { flex: none; color: var(--muted); }
.item .title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.item .meta { font-size: 13px; color: var(--muted); }
.item .end { text-align: right; flex: none; }
.pts { font-family: var(--cond); font-weight: 700; font-size: 18px; font-variant-numeric: tabular-nums; }
.dot { width: 10px; height: 10px; border-radius: 5px; flex: none; background: var(--green); }
.dot.bad { background: var(--red); }
.dot.warn { background: var(--warn); }
.badge { display: inline-block; font-size: 12px; padding: 1px 8px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); color: var(--muted); }
.badge.gold { background: var(--gold-soft); border-color: transparent; color: var(--ink); }
.badge.red { background: var(--red-soft); border-color: transparent; color: var(--red); }
.badge.green { background: var(--green-soft); border-color: transparent; color: var(--green); }

.empty { text-align: center; padding: 48px 20px; color: var(--muted); }
.empty h2 { color: var(--ink); margin-bottom: 8px; }
.empty .btn { margin-top: 16px; }
.banner { display: flex; gap: 10px; align-items: center; padding: 10px 14px; border-radius: 10px; background: var(--surface); border: 1px solid var(--line); margin-bottom: 16px; font-size: 14px; }
.banner.info { border-left: 4px solid var(--accent); }
.banner.ok { border-left: 4px solid var(--green); }
.banner.err { border-left: 4px solid var(--red); }
.banner .grow { flex: 1; }
.progress { height: 4px; background: var(--line); border-radius: 2px; overflow: hidden; margin-top: 6px; }
.progress > i { display: block; height: 100%; background: var(--gold); width: 0; transition: width .2s; }

/* ------------------------------------------------ editor lista */
.gauge { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; margin-bottom: 16px; }
.gauge .top { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.gauge .big { font-family: var(--cond); font-weight: 700; font-size: 44px; line-height: 1; font-variant-numeric: tabular-nums; }
.gauge .of { font-family: var(--cond); font-size: 20px; color: var(--muted); }
.gauge .bar { height: 8px; border-radius: 4px; background: var(--line); margin: 12px 0 10px; overflow: hidden; }
.gauge .bar > i { display: block; height: 100%; background: var(--gold); border-radius: 4px; }
.gauge.over .bar > i { background: var(--red); }
.gauge.over .big { color: var(--red); }
.gauge .chips { display: flex; gap: 8px; flex-wrap: wrap; }
.errs { list-style: none; margin: 10px 0 0; padding: 0; font-size: 14px; }
.errs li { padding: 6px 0 6px 12px; border-left: 3px solid var(--red); margin-bottom: 4px; background: var(--red-soft); border-radius: 0 6px 6px 0; }
.errs li.warn { border-left-color: var(--warn); background: var(--warn-soft); }
.errs li[data-uid] { cursor: pointer; }

.split { display: block; }
@media (min-width: 1000px) {
  .split { display: grid; grid-template-columns: minmax(360px, 5fr) 6fr; gap: 20px; align-items: start; }
  .split > .pane { position: sticky; top: 0; max-height: calc(100vh - var(--bar-h) - 24px); overflow: auto; border-radius: 12px; }
  .item.selected { background: var(--gold-soft); }
}
.pane-empty { padding: 40px 20px; text-align: center; color: var(--muted); border: 1px dashed var(--line); border-radius: 12px; }

.opt-group { border-top: 1px solid var(--line); padding: 10px 0 6px; }
.opt-group:first-child { border-top: 0; }
.opt-group > .gh { display: flex; justify-content: space-between; gap: 8px; font-weight: 600; margin-bottom: 6px; }
.opt-group > .gh .range { font-weight: 400; font-size: 13px; color: var(--muted); white-space: nowrap; }
.opt-row { display: flex; align-items: center; gap: 10px; min-height: 48px; }
.opt-row .name { flex: 1; min-width: 0; }
.opt-row .cost { font-size: 13px; color: var(--muted); }
.nested { margin: 2px 0 8px 12px; padding-left: 12px; border-left: 2px solid var(--line); }
.fixed { font-size: 14px; color: var(--muted); padding: 4px 0; }
.stepper { display: inline-flex; align-items: center; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; flex: none; }
.stepper button { width: 44px; height: 42px; border: 0; background: var(--surface-2); cursor: pointer; font-size: 20px; line-height: 1; }
.stepper button:disabled { opacity: .35; }
.stepper output { min-width: 40px; text-align: center; font-family: var(--cond); font-weight: 700; font-size: 18px; font-variant-numeric: tabular-nums; }
.choices { display: flex; flex-wrap: wrap; gap: 8px; }
.choice { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 8px 14px; cursor: pointer; min-height: 40px; text-align: left; }
.choice[aria-pressed="true"] { background: var(--blue); color: var(--onblue); border-color: var(--blue); }

/* ------------------------------------------------ scheda (datasheet) */
.ds h3 { margin: 16px 0 8px; font-size: 15px; color: var(--muted); font-family: var(--sans); font-weight: 600; }
.tbl-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 10px; }
table.stats { border-collapse: collapse; width: 100%; font-size: 14px; }
table.stats th, table.stats td { padding: 7px 8px; text-align: center; border-top: 1px solid var(--line); white-space: nowrap; }
table.stats thead th { border-top: 0; background: var(--surface-2); font-size: 12px; color: var(--muted); font-weight: 600; }
table.stats td:first-child, table.stats th:first-child { text-align: left; white-space: normal; min-width: 140px; }
table.stats td.kw { text-align: left; white-space: normal; min-width: 140px; }
.ability { padding: 10px 0; border-top: 1px solid var(--line); font-size: 15px; }
.ability:first-of-type { border-top: 0; }
.ability b.n { display: block; margin-bottom: 2px; }
.kw-line { font-size: 13px; color: var(--muted); }
.rref {
  border: 0; background: none; padding: 0; margin: 0; color: var(--accent); cursor: pointer; font: inherit;
  text-decoration: underline dotted; text-underline-offset: 3px; text-align: left;
}
.chip-rule { display: inline-block; border: 1px solid var(--line); border-radius: 999px; padding: 4px 10px; margin: 0 6px 6px 0; background: var(--surface-2); font-size: 14px; cursor: pointer; color: var(--ink); }
.chip-rule:active { background: var(--gold-soft); }
.kw { font-weight: 600; letter-spacing: .02em; }

/* ------------------------------------------------ popover e fogli */
.pop {
  position: fixed; z-index: 50; background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: var(--shadow); padding: 14px 16px; max-width: min(400px, calc(100vw - 24px)); max-height: 60vh; overflow: auto; font-size: 15px;
}
.pop h3 { margin-bottom: 6px; }
.scrim { position: fixed; inset: 0; background: rgba(20, 22, 30, .45); z-index: 40; display: flex; align-items: flex-end; justify-content: center; }
.sheet {
  background: var(--surface); width: 100%; max-height: 88vh; overflow: auto; border-radius: 18px 18px 0 0; padding: 18px 18px 24px;
  animation: up .18s ease-out;
}
.sheet > h2 { margin-bottom: 14px; }
.sheet .actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; flex-wrap: wrap; }
@keyframes up { from { transform: translateY(24px); opacity: .6; } to { transform: none; opacity: 1; } }
@media (min-width: 700px) {
  .scrim { align-items: center; }
  .sheet { width: min(560px, 92vw); border-radius: 16px; }
  .sheet.wide { width: min(860px, 94vw); }
}
.toast {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--nav-h) + 16px); z-index: 60; background: var(--ink); color: var(--bg);
  padding: 10px 16px; border-radius: 10px; font-size: 14px; max-width: 90vw; box-shadow: var(--shadow);
}
@media (min-width: 840px) { .toast { bottom: 24px; } }

.search { position: sticky; top: 0; z-index: 3; background: var(--bg); padding: 0 0 10px; }
.cat-title { font-family: var(--cond); font-weight: 700; font-size: 15px; color: var(--muted); padding: 14px 0 6px; }

/* ------------------------------------------------ partita */
.score { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-bottom: 14px; }
@media (max-width: 520px) {
  .score { gap: 8px; }
  .side { padding: 10px; }
  .side .vp { font-size: 44px; }
  .side .cp { flex-wrap: wrap; gap: 4px; }
  .side .cp .stepper button { width: 38px; }
  .side .cp .stepper output { min-width: 32px; }
}
.side { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; border-top: 4px solid var(--line); }
.side.active { border-top-color: var(--gold); }
.side .who { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side .vp { font-family: var(--cond); font-weight: 700; font-size: 56px; line-height: 1; font-variant-numeric: tabular-nums; margin: 6px 0 2px; }
.side .vpl { font-size: 13px; color: var(--muted); }
.side .cp { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 10px; font-size: 14px; }
.side .cp + .cp { margin-top: 6px; }
.phases { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; margin: 10px 0 12px; }
.phases span { text-align: center; font-size: 12px; padding: 8px 2px; border-radius: 8px; background: var(--surface-2); border: 1px solid var(--line); color: var(--muted); }
.phases span.on { background: var(--blue); color: var(--onblue); border-color: var(--blue); font-weight: 600; }
.phases span.done { color: var(--ink); }
.roundline { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.roundline .r { font-family: var(--cond); font-weight: 700; font-size: 24px; }
.vpgrid { width: 100%; border-collapse: collapse; font-size: 14px; }
.vpgrid th, .vpgrid td { padding: 6px 4px; text-align: center; border-top: 1px solid var(--line); font-variant-numeric: tabular-nums; }
.vpgrid thead th { border-top: 0; color: var(--muted); font-weight: 600; font-size: 12px; }
.vpgrid td.cur { background: var(--gold-soft); font-weight: 700; }
.vpgrid td:first-child, .vpgrid th:first-child { text-align: left; }
.scorer { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.scorer .lbl { font-size: 13px; color: var(--muted); margin: 6px 0 4px; }
.unit-row.dead .title { text-decoration: line-through; color: var(--muted); }
.two { display: grid; grid-template-columns: 1fr; gap: 16px; }
@media (min-width: 900px) { .two { grid-template-columns: 1fr 1fr; } }

/* ------------------------------------------------ tornei */
table.standings { width: 100%; border-collapse: collapse; font-size: 14px; }
table.standings th, table.standings td { padding: 8px 6px; border-top: 1px solid var(--line); text-align: center; font-variant-numeric: tabular-nums; }
table.standings thead th { border-top: 0; color: var(--muted); font-size: 12px; font-weight: 600; }
table.standings td.nm, table.standings th.nm { text-align: left; }
table.standings td.pos { font-family: var(--cond); font-weight: 700; width: 32px; }
table.standings tr.first td.pos { color: var(--gold); }
.pair { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--line); cursor: pointer; }
.pair:first-child { border-top: 0; }
.pair .a { text-align: right; }
.pair .res { font-family: var(--cond); font-weight: 700; font-size: 20px; min-width: 72px; text-align: center; font-variant-numeric: tabular-nums; }
.pair .res.pending { color: var(--muted); font-size: 14px; font-family: var(--sans); font-weight: 400; }
.pair .win { font-weight: 700; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: 15px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 600; }
.fmt-grid { display: grid; grid-template-columns: 1fr; gap: 16px; }
@media (min-width: 900px) { .fmt-grid { grid-template-columns: repeat(3, 1fr); } }
.fmt-card { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 16px; }
.fmt-card .pts-big { font-family: var(--cond); font-weight: 700; font-size: 34px; line-height: 1; margin: 6px 0 12px; }
.fmt-card .pts-big small { font-size: 16px; color: var(--muted); font-weight: 400; }
.note { font-size: 13px; color: var(--muted); margin-top: 10px; }
.rule-body { font-size: 15px; }
.rule-body p { margin: 0 0 .5em; }
details.rule { border-top: 1px solid var(--line); }
details.rule summary { padding: 12px 16px; cursor: pointer; font-weight: 600; list-style: none; }
details.rule summary::-webkit-details-marker { display: none; }
details.rule .rule-body { padding: 0 16px 14px; }
.loading { padding: 40px; text-align: center; color: var(--muted); }
.rule-list { margin: 0; padding-left: 18px; font-size: 15px; }
.rule-list li { margin: 0 0 6px; }
table.matrix th, table.matrix td { white-space: normal; min-width: 96px; font-size: 13px; }
table.matrix td.mirror { background: var(--gold-soft); }

/* ------------------------------------------------ interruttore */
.switch-row { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 48px; background: none; border: 0; padding: 6px 0; text-align: left; cursor: pointer; }
.switch-row .sw-text { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.switch-row .sw-label { font-weight: 600; }
.switch-row .sw-sub { font-size: 13px; color: var(--muted); }
.switch { position: relative; width: 52px; height: 32px; border-radius: 16px; background: var(--line); transition: background .15s; flex: none; }
.switch .knob { position: absolute; top: 3px; left: 3px; width: 26px; height: 26px; border-radius: 13px; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.3); transition: transform .15s; }
.switch-row[aria-checked="true"] .switch { background: var(--gold); }
.switch-row[aria-checked="true"] .knob { transform: translateX(20px); }
.side .switch-row { min-height: 40px; padding: 2px 0; margin-top: 6px; }
.side .switch-row .sw-label { font-weight: 500; font-size: 14px; }

/* ------------------------------------------------ carte missione */
.cgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 10px; margin-bottom: 8px; }
.mcard { position: relative; display: flex; flex-direction: column; padding: 0; border: 0; background: none; cursor: pointer; text-align: left; }
.mcard img, .mcard .mcard-ph { width: 100%; aspect-ratio: 5 / 7; object-fit: cover; border-radius: 10px; display: flex; }
.mcard .mcard-ph { flex-direction: column; justify-content: space-between; padding: 8px; background: var(--surface); border: 2px solid var(--line); }
.mcard.prim .mcard-ph { border-color: var(--blue); }
[data-theme="dark"] .mcard.prim .mcard-ph { border-color: var(--accent); }
.mcard.sec .mcard-ph { border-color: var(--gold); }
.mcard-type { font-size: 10px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.mcard-name { font-family: var(--cond); font-weight: 700; font-size: 15px; line-height: 1.15; }
.mcard-hint { font-size: 10px; color: var(--muted); }
.mcard-cap { font-size: 12px; color: var(--muted); margin-top: 4px; }
.mcard.small { width: 96px; }
.mcard.small .mcard-name { font-size: 13px; }
.mcard.on img, .mcard.on .mcard-ph { outline: 3px solid var(--gold); outline-offset: 2px; }
.cardrow { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-start; }
.card-view { border-radius: 12px; overflow: hidden; background: var(--surface-2); display: flex; justify-content: center; }
.card-view img { max-width: 100%; max-height: 70vh; object-fit: contain; }
.card-view.empty-card { padding: 28px 20px; text-align: center; color: var(--muted); border: 2px dashed var(--line); }

/* ------------------------------------------------ layout */
.lgrid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.lthumb { border: 2px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--surface); display: flex; flex-direction: column; }
.lthumb.on { border-color: var(--gold); box-shadow: 0 0 0 2px var(--gold-soft); }
.lpick { border: 0; background: none; padding: 0; cursor: pointer; display: flex; flex-direction: column; text-align: center; }
.lpick .lname { font-weight: 600; padding: 6px 0 2px; }
.lthumb.on .lname { color: var(--gold); }
.lopen { border: 0; background: var(--surface-2); padding: 8px 0; font-size: 13px; cursor: pointer; color: var(--accent); }
.imgwrap { width: 100%; min-height: 90px; display: flex; align-items: center; justify-content: center; background: var(--surface-2); }
.imgwrap img { width: 100%; display: block; }
.imgwrap.loading-img::after { content: 'Caricamento…'; font-size: 12px; color: var(--muted); padding: 30px 0; }
.imgwrap.failed::after { content: 'Pagina non disponibile'; font-size: 12px; color: var(--muted); padding: 30px 0; }
.layout-view { overflow: auto; border-radius: 10px; border: 1px solid var(--line); max-height: 70vh; cursor: zoom-in; }
.layout-view.zoom { cursor: zoom-out; }
.layout-view.zoom img { width: 220%; max-width: none; }
.roles { display: flex; gap: 6px; flex-wrap: wrap; margin: 4px 0 2px; }
.roles .badge { cursor: pointer; }
.awake { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); margin-top: 8px; }
.awake svg { width: 16px; height: 16px; }
.deck-cards { display: flex; gap: 10px; flex-wrap: wrap; margin: 8px 0; }
.missing { font-size: 13px; color: var(--red); margin: 8px 0 0; }
.assign { display: flex; flex-direction: column; gap: 10px; }
.assign-row { display: flex; gap: 12px; align-items: center; }
.assign-row img { width: 64px; height: 90px; object-fit: cover; border-radius: 8px; flex: none; background: var(--surface-2); }
.assign-row .main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.credits { font-size: 13px; color: var(--muted); }
.credits h3 { color: var(--ink); font-family: var(--sans); font-size: 15px; margin: 0 0 8px; }
.credits p { margin: 0 0 8px; }
.credits b { color: var(--ink); font-weight: 600; }

/* ------------------------------------------------ marchio */
.splash { min-height: 70vh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; padding: 24px; }
.brand-lockup { color: var(--ink); }
.brand-lockup svg { display: block; height: 56px; width: auto; }
.splash .brand-lockup svg { height: 64px; }
.info-logo { margin: 4px 0 14px; }
.info-logo svg { height: 44px; }
.nav .brand { display: none; }
@media (min-width: 840px) {
  .nav .brand { display: flex; justify-content: center; align-items: center; height: 64px; }
  .nav .brand svg { width: 44px; height: 44px; }
}

/* ------------------------------------------------ account e dashboard */
#app.gated .nav { display: none; }
#app.gated { grid-template-rows: var(--bar-h) 1fr; }
@media (min-width: 840px) { #app.gated { grid-template-columns: minmax(0, 1fr); } #app.gated .appbar, #app.gated main { grid-column: 1; } }
.page.narrow { max-width: 620px; }
.auth-card { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 22px 20px; margin-top: 8px; }
.auth-logo { display: flex; justify-content: center; margin-bottom: 6px; }
.auth-logo svg { height: 52px; }
.avatar { display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 20px; background: var(--gold); color: #101610; font-family: var(--cond); font-weight: 700; font-size: 17px; flex: none; }
.avatar.small { width: 32px; height: 32px; font-size: 14px; border: 2px solid rgba(255,255,255,.7); }
.avatar.big { width: 64px; height: 64px; border-radius: 32px; font-size: 26px; }
.profile-head { display: flex; align-items: center; gap: 16px; margin: 4px 0 18px; }
.profile-head h2 { font-size: 24px; }
.hello { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.hello h2 { font-size: 26px; }
.sync-dot { width: 12px; height: 12px; border-radius: 6px; background: var(--muted); flex: none; }
.sync-dot.ok { background: var(--green); }
.sync-dot.pending, .sync-dot.busy { background: var(--warn); }
.sync-dot.error { background: var(--red); }
.quick { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
@media (min-width: 700px) { .stat-grid { grid-template-columns: repeat(4, 1fr); } }
.stat { background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; }
.stat-v { font-family: var(--cond); font-weight: 700; font-size: 28px; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat-l { font-size: 13px; color: var(--muted); }
.chart svg { width: 100%; height: 90px; display: block; }

/* ------------------------------------------------ editor dei dati */
.grid-fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 0 12px; }
.grid-fields .field:has(textarea) { grid-column: 1 / -1; }
.profile-edit { border-top: 1px solid var(--line); padding-top: 12px; margin-top: 6px; }
.profile-edit:first-child { border-top: 0; margin-top: 0; padding-top: 0; }
.input.changed { border-color: var(--gold); background: var(--gold-soft); }
.savebar { position: sticky; bottom: 0; background: var(--bg); padding: 12px 0; display: flex; justify-content: flex-end; border-top: 1px solid var(--line); margin-top: 8px; z-index: 4; }
details.raw > summary { padding: 14px 16px; cursor: pointer; font-weight: 600; }
details.raw textarea { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12px; }
details.minor > summary { cursor: pointer; padding: 4px 0; }
