/* xvolley.dk – Momentum Monitor v2
   Layout rule #1: nothing above the scoring buttons may change height at runtime.
   Every element whose text varies has a reserved height. The scoring buttons
   themselves live in a fixed bar and are never affected by content reflow.   */

:root{
  --bg:#0b1118; --panel:#151f28; --panel2:#1d2a35; --line:#2c3c48;
  --text:#f6f8f9; --muted:#9fb0bd; --dim:#728692;
  --a:#63d5aa; --b:#f2a15c; --warn:#ffd166; --bad:#ff8a8a;
  --bar-h:150px;
}
*{box-sizing:border-box}
html{-webkit-text-size-adjust:100%}
body{
  margin:0; background:var(--bg); color:var(--text);
  font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,sans-serif;
  font-size:14px; line-height:1.5;
  overscroll-behavior-y:contain;
}
.app{
  max-width:560px; margin:auto;
  padding:calc(12px + env(safe-area-inset-top)) 14px 28px;
}
body.scoring .app{ padding-bottom:calc(var(--bar-h) + 28px + env(safe-area-inset-bottom)) }
.hidden{display:none !important}

/* ---------- header ---------- */
.head{display:flex;justify-content:space-between;align-items:flex-start;gap:10px;margin-bottom:12px}
h1{font-size:20px;margin:0;letter-spacing:-.2px}
.sub{color:var(--muted);font-size:11px}
.badge{
  border:1px solid var(--line);border-radius:999px;padding:8px 12px;color:#fff;
  font-size:11px;background:#17232d;font-weight:800;cursor:pointer;white-space:nowrap;
}
.badge:active{background:#1f2f3b}

/* ---------- privacy banner ---------- */
.privacy{
  display:flex;gap:10px;align-items:flex-start;
  background:#12222b;border:1px solid #2b4a4a;border-left:3px solid var(--a);
  border-radius:12px;padding:11px 12px;margin-bottom:12px;font-size:12px;color:var(--muted);
}
.privacy strong{color:var(--text);display:block}
.privacy-icon{font-size:14px;line-height:1.3}
.privacy-x{
  background:none;border:0;color:var(--dim);font-size:20px;line-height:1;
  padding:0 2px;cursor:pointer;margin-left:auto;flex:none;
}
.linklike{background:none;border:0;padding:0;color:var(--a);font:inherit;text-decoration:underline;cursor:pointer}

/* ---------- tabs ---------- */
.tabs{display:grid;grid-template-columns:repeat(4,1fr);gap:6px;margin-bottom:12px}
.tab{
  padding:10px 4px;border:1px solid var(--line);background:#17232d;color:var(--muted);
  border-radius:12px;font:inherit;font-weight:600;cursor:pointer;
}
.tab.on{background:#fff;color:#111;border-color:#fff}

/* ---------- cards & forms ---------- */
.card{background:var(--panel);border:1px solid var(--line);border-radius:18px;padding:15px;margin-bottom:12px}
.title{text-transform:uppercase;letter-spacing:.7px;color:var(--muted);font-size:11px;margin-bottom:9px}
.title-row{display:flex;justify-content:space-between;align-items:baseline;gap:10px}
.title-row .title{margin-bottom:9px}
.grid2{display:grid;grid-template-columns:1fr 1fr;gap:9px}
.full{grid-column:1/-1}
label{font-size:10px;color:var(--muted);display:block;margin-bottom:4px}
input,select,textarea{
  width:100%;background:#0d151c;color:#fff;border:1px solid var(--line);
  border-radius:11px;padding:11px;font:inherit;font-size:16px; /* 16px stops iOS zoom-on-focus */
}
input:focus,select:focus,textarea:focus{outline:2px solid var(--a);outline-offset:1px;border-color:transparent}
textarea{min-height:82px;resize:vertical}
.hint{color:var(--dim);font-size:11px;margin:2px 0 0;line-height:1.45}
.body{font-size:13px;color:var(--muted);margin:0 0 10px}
.body strong{color:var(--text)}
.body a{color:var(--a)}
ul.body{padding-left:18px}
ul.body li{margin-bottom:5px}
.muted{color:var(--muted)}

button{font:inherit;border:0;border-radius:14px;cursor:pointer;touch-action:manipulation}
.btn-primary{background:#243542;color:#fff;border:1px solid #39505f;padding:16px;font-weight:800}
.btn-dark{background:#243542;color:#fff;border:1px solid #39505f;padding:14px;font-weight:800}
.btn-white{background:#fff;color:#111;padding:14px;font-weight:800}
.btn-primary:active,.btn-dark:active{background:#2d4150}

/* ---------- scoreboard (all heights reserved) ---------- */
.score{display:grid;grid-template-columns:1fr auto 1fr;align-items:start;text-align:center;gap:6px}
.side{min-width:0}
.sname{
  color:var(--muted);font-size:13px;font-weight:600;
  height:34px;               /* reserved: 1–2 lines */
  display:flex;align-items:center;justify-content:center;
  overflow:hidden;line-height:1.25;
}
.sseed{display:flex;justify-content:center;align-items:center;gap:5px;color:var(--dim);font-size:10px;height:30px}
.sseed input{width:64px;padding:5px 6px;font-size:13px;text-align:center;border-radius:8px}
.sbig{
  font-size:60px;font-weight:800;line-height:1;
  height:60px;                /* reserved */
  font-variant-numeric:tabular-nums;font-feature-settings:"tnum";
}
.sserve{height:16px;font-size:10px;color:var(--a);letter-spacing:.5px;font-weight:700}
.dash{color:var(--dim);font-size:28px;padding-top:56px}

.meta{
  display:flex;justify-content:space-between;gap:10px;
  border-top:1px solid var(--line);padding-top:12px;margin-top:12px;
  font-size:11px;color:var(--muted);height:41px;align-items:center;
}
.meta strong{color:#fff}

/* win probability — a bar can't reflow, unlike the old text label */
.prob{margin-top:12px}
.prob-head{display:flex;justify-content:space-between;font-size:11px;color:var(--muted);margin-bottom:5px}
.prob-head strong{color:#fff;font-variant-numeric:tabular-nums}
.prob-bar{height:10px;border-radius:999px;background:var(--b);overflow:hidden;border:1px solid var(--line)}
.prob-fill{height:100%;width:50%;background:var(--a);transition:width .25s}
.prob-legend{display:flex;justify-content:space-between;font-size:10px;color:var(--dim);margin-top:4px}

/* ---------- momentum (fixed height, this was the main "jump" source) ---------- */
.mrow{display:flex;align-items:center;height:38px;overflow:hidden}
.mval{
  font-size:26px;font-weight:800;white-space:nowrap;
  font-variant-numeric:tabular-nums;letter-spacing:-.4px;
}
.track{
  height:15px;border:1px solid var(--line);border-radius:999px;position:relative;
  background:linear-gradient(90deg,#f2a15c55,#ffffff12 50%,#63d5aa55);margin:8px 0 4px;
}
.track-labels{
  display:flex;justify-content:space-between;font-size:9px;color:var(--dim);
  letter-spacing:.4px;text-transform:uppercase;margin-bottom:10px;
}
.dot{
  position:absolute;top:50%;left:50%;width:17px;height:17px;border-radius:50%;background:#fff;
  transform:translate(-50%,-50%);transition:left .25s;
}
.alert{
  padding:10px 12px;border:1px solid #ffd16644;background:#ffd16612;border-radius:12px;
  font-size:13px;line-height:1.35;
  height:76px;               /* reserved: fits the longest Danish string at 320px */
  display:flex;flex-direction:column;justify-content:center;overflow:hidden;
}
.alert strong{color:var(--warn);display:block;font-size:11px;letter-spacing:.8px;margin-bottom:2px}
.alert.shift{border-color:#ffd16688;background:#ffd1661f}
.alert.strong{border-color:#ff8a8a66;background:#ff8a8a14}
.alert.strong strong{color:var(--bad)}

/* ---------- stats ---------- */
.stats{display:grid;grid-template-columns:1fr 1fr;gap:8px}
.stat{background:var(--panel2);border:1px solid var(--line);border-radius:12px;padding:10px;min-height:58px}
.stat .k{font-size:10px;color:var(--muted)}
.stat .v{font-size:16px;font-weight:700;margin-top:4px;font-variant-numeric:tabular-nums}

/* ---------- event log ---------- */
.recent{display:flex;gap:6px;margin-bottom:10px;min-height:52px}
.rchip{
  flex:1;background:var(--panel2);border:1px solid var(--line);border-radius:10px;
  padding:7px 8px;text-align:center;min-width:0;
}
.rchip .rw{font-size:12px;font-weight:800;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.rchip .rt{font-size:10px;color:var(--dim);font-variant-numeric:tabular-nums;margin-top:2px}
.rchip.ra .rw{color:var(--a)} .rchip.rb .rw{color:var(--b)}
.rchip.empty{color:var(--dim);display:flex;align-items:center;justify-content:center;font-size:11px}

.log{list-style:none;margin:0;padding:0;max-height:262px;overflow-y:auto;-webkit-overflow-scrolling:touch}
.log li{
  display:grid;grid-template-columns:52px 14px 1fr auto;gap:8px;align-items:baseline;
  padding:7px 10px 7px 2px;border-top:1px solid #22303b;font-size:12px;
}
.log::-webkit-scrollbar{width:6px}
.log::-webkit-scrollbar-thumb{background:#2c3c48;border-radius:3px}
.log li:first-child{border-top:0}
.log .lt{color:var(--dim);font-size:11px;font-variant-numeric:tabular-nums}
.log .lm{font-size:11px;line-height:1}
.log .lw{color:var(--text);min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.log .ls{color:var(--muted);font-variant-numeric:tabular-nums;font-weight:700;white-space:nowrap}
.log .tag{font-size:9px;color:var(--dim);border:1px solid var(--line);border-radius:5px;padding:1px 4px;margin-left:5px;white-space:nowrap}
.log li.ev-a .lm{color:var(--a)} .log li.ev-b .lm{color:var(--b)}
.log li.ev-note{background:#ffd1660d}
.log li.ev-note .lw{color:var(--warn)}
.log li.ev-set{background:#ffffff08}
.log li.ev-set .lw{color:var(--text);font-weight:700}
.log .empty{color:var(--dim);padding:10px 2px;font-size:12px}

/* ---------- history / eval ---------- */
#search{margin-bottom:10px}
.hist{border:1px solid var(--line);border-radius:14px;padding:12px;margin-top:9px;background:#18242e}
.hist h3{font-size:14px;margin:0 0 3px}
.actions{display:flex;gap:8px;margin-top:10px}
.actions button{flex:1;padding:9px;font-size:11px;background:#243542;color:#fff;border:1px solid var(--line);font-weight:700}
.evalrow{display:flex;justify-content:space-between;gap:12px;font-size:12px;margin:7px 0}
.evalrow span:first-child{color:var(--muted)}
.timeline{background:#101820;border:1px solid var(--line);border-radius:12px;padding:10px;font-size:11px;color:var(--muted);line-height:1.6;word-break:break-word}
.momChart{margin-top:8px;background:#101b23;border:1px solid var(--line);border-radius:12px;padding:8px}
.momChart canvas{width:100%;height:190px;display:block}
.momLegend{display:flex;justify-content:space-between;font-size:10px;color:var(--dim);margin-top:4px}
.wordCount{text-align:right;color:var(--dim);font-size:10px;margin-top:4px}
.shareActions{display:grid;grid-template-columns:1fr 1fr;gap:8px;margin-top:10px}
.shareActions button{padding:11px;border-radius:10px;font-size:11px;background:#243542;color:#fff;border:1px solid var(--line);font-weight:700}

/* ---------- about ---------- */
.factbox{border:1px solid var(--line);border-radius:12px;padding:12px;margin-bottom:10px;background:#18242e}
.fact-h{font-size:11px;text-transform:uppercase;letter-spacing:.7px;font-weight:800;margin-bottom:8px;color:var(--muted)}
.fact-h.fact-yes{color:var(--a)} .fact-h.fact-no{color:var(--b)}

/* ---------- fixed action bar ---------- */
.actionbar{
  position:fixed;left:0;right:0;bottom:0;z-index:40;
  background:linear-gradient(180deg,#0b1118cc,#0b1118 22%);
  border-top:1px solid var(--line);
  padding:10px 14px calc(10px + env(safe-area-inset-bottom));
  backdrop-filter:blur(8px);
}
.actionbar-inner{max-width:560px;margin:auto;display:grid;gap:8px}
.ab-main{display:grid;grid-template-columns:1fr 1fr;gap:10px}
.pt{
  height:66px;border-radius:16px;font-weight:800;color:#0b1118;
  display:flex;flex-direction:column;align-items:center;justify-content:center;gap:2px;padding:0 8px;
}
.pt-k{font-size:11px;letter-spacing:.5px;opacity:.72}
.pt-n{font-size:15px;max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.pa{background:var(--a)} .pb{background:var(--b)}
.pt:active{filter:brightness(.9)}
.ab-sub{display:grid;grid-template-columns:repeat(4,1fr);gap:6px}
.ab-sub button{
  background:#243542;color:#fff;border:1px solid #39505f;border-radius:11px;
  padding:10px 2px;font-size:10px;font-weight:700;
}
.ab-sub button:active{background:#2d4150}
.ab-sub button:disabled{opacity:.4}

/* ---------- toast ---------- */
.toast{
  position:fixed;left:50%;bottom:calc(var(--bar-h) + 20px);transform:translateX(-50%);
  background:#fff;color:#111;padding:9px 14px;border-radius:999px;font-size:12px;font-weight:600;
  opacity:0;pointer-events:none;transition:opacity .2s;z-index:60;
}
.toast.show{opacity:1}

@media (max-width:360px){
  .sbig{font-size:52px;height:52px}
  .dash{padding-top:48px}
  .mval{font-size:22px}
}
@media (prefers-reduced-motion:reduce){
  *{transition:none !important}
}

/* Utility classes replacing inline style attributes, so the site can ship a
   CSP with no 'unsafe-inline' for styles. Programmatic .style.left/.width
   assignments in app.js are CSSOM and unaffected by CSP. */
.mt-s{margin-top:8px}
.mt-m{margin-top:12px}
.mt-l{margin-top:16px}
.hist-meta{color:var(--muted);font-size:11px}
.eval-h{margin:0 0 4px;font-size:15px}
.log-tall{max-height:340px}

/* Storage-full warning. Deliberately sticky and non-dismissible: it means
   nothing is being written, so it must not be mistakable for a passing toast. */
.alertbar{
  display:flex;gap:10px;align-items:flex-start;
  background:#2a1618;border:1px solid #ff8a8a55;border-left:3px solid var(--bad);
  border-radius:12px;padding:11px 12px;margin-bottom:12px;font-size:12px;color:#f3d3d3;
}
.alertbar strong{color:#fff;display:block}
.alertbar-icon{line-height:1.3}
.alertbar-act{
  margin-left:auto;flex:none;align-self:center;background:#fff;color:#111;
  border-radius:9px;padding:8px 11px;font-size:11px;font-weight:800;
}
