/* Wubblserver – ruhig, angelehnt an das Schriftfeld von norbertwinter.at. Modi "hell" und "blau". */

html[data-mode=hell] {
  --page: #f3f4f6; --paper: #ffffff; --ink: #111; --strong: #000;
  --txt: rgba(17,17,17,.86); --muted: rgba(17,17,17,.56); --line: rgba(17,17,17,.55); --soft: rgba(17,17,17,.14);
  --grid: rgba(20,30,50,.045); --hi: rgba(20,70,160,.07); --shadow: rgba(20,30,50,.12); --bar: #111;
  --accent: #1446a0; --accent-soft: rgba(20,70,160,.1);
  --ok: #15803d; --ok-soft: rgba(21,128,61,.12); --warn: #b45309; --warn-soft: rgba(180,83,9,.13);
  --crit: #c62828; --crit-soft: rgba(198,40,40,.12);
}
html[data-mode=blau] {
  --page: #0b2e6e; --paper: #0f3778; --ink: #eaf2ff; --strong: #fff;
  --txt: rgba(226,236,255,.92); --muted: rgba(214,230,255,.62); --line: rgba(214,230,255,.5); --soft: rgba(214,230,255,.18);
  --grid: rgba(255,255,255,.045); --hi: rgba(214,230,255,.1); --shadow: rgba(0,6,30,.35); --bar: #eaf2ff;
  --accent: #9dbdff; --accent-soft: rgba(127,168,255,.16);
  --ok: #5ee6a0; --ok-soft: rgba(94,230,160,.15); --warn: #ffc857; --warn-soft: rgba(255,200,87,.16);
  --crit: #ff7b7b; --crit-soft: rgba(255,123,123,.16);
}

* { box-sizing: border-box; margin: 0; }
html { background: var(--page); scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  min-height: 100vh; background: var(--page); color: var(--txt);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  transition: background-color .5s, color .5s;
}
.mono, .label, .num { font-family: ui-monospace, "JetBrains Mono", "SF Mono", Menlo, Consolas, monospace; }
.label { font-size: 12px; line-height: 1.25; letter-spacing: .06em; text-transform: uppercase; }
.muted { color: var(--muted); }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 2px solid var(--strong); outline-offset: 2px; }

/* ---------- Schriftfeld (Panel) ---------- */
.panel {
  border: 1px solid var(--line); background-color: var(--paper);
  background-image: linear-gradient(var(--grid) 1px, transparent 1px), linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 10px 10px;
  transition: background-color .5s, border-color .5s;
}
.panel .head { display: flex; align-items: center; justify-content: space-between; gap: 10px;
  min-height: 42px; padding: 8px 14px; border-bottom: 1px solid var(--line); background: var(--accent-soft); }
.panel .head > .label:first-child { color: var(--accent); font-weight: 600; }
.panel .head .label span { color: var(--muted); margin-left: 8px; font-weight: 400; }
.cells { display: grid; grid-template-columns: 1fr 1fr; }
.cells.three { grid-template-columns: repeat(3, 1fr); }
.cell { padding: 12px 14px; display: grid; gap: 4px; align-content: start; min-width: 0; border-top: 1px solid var(--line); }
.cells > .cell + .cell { border-left: 1px solid var(--line); }
.cells:not(.three) > .cell:nth-child(2n+1) { border-left: 0; }
.cells.three > .cell:nth-child(3n+1) { border-left: 0; }
.cell .v { color: var(--strong); font-size: 17px; overflow-wrap: anywhere; }
/* Keine doppelte Linie direkt unter der Kopfzeile (nur erste Zellenreihe) */
.head + .cells > .cell:nth-child(-n+2), .head + .cells.three > .cell:nth-child(3) { border-top: 0; }
@media (max-width: 420px) { .head + .cells.three > .cell:nth-child(3) { border-top: 1px solid var(--line); } }

/* Aktions-Zeile wie "SCHREIB MIR" – Fläche füllt sich von links */
.act { display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%;
  min-height: 52px; padding: 0 14px; border-top: 1px solid var(--line); color: var(--accent);
  font: 600 13px/1 ui-monospace, "JetBrains Mono", "SF Mono", Menlo, Consolas, monospace; letter-spacing: .06em; text-transform: uppercase;
  position: relative; overflow: hidden; }
.act::before { content: ""; position: absolute; inset: 0; background: var(--accent); transform: scaleX(0); transform-origin: left;
  transition: transform .3s cubic-bezier(.65,0,.35,1); }
.act > * { position: relative; transition: color .2s; }
.act:hover::before, .act:focus-visible::before, .act:active::before { transform: scaleX(1); }
.act:hover > *, .act:focus-visible > *, .act:active > * { color: var(--page); }
.act svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.6; }
.act.done::before { transform: scaleX(1); background: var(--ok); }
.act.done > * { color: var(--page); }

/* Kleine Rahmen-Buttons in der Kopfzeile */
.tool { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-width: 44px; height: 44px; padding: 0 12px;
  border: 1px solid var(--line); color: var(--ink); background: var(--paper); transition: background-color .2s, color .2s; }
.tool:hover { background: var(--strong); color: var(--page); }
.tool svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
/* Aktualisieren: lädt (dreht) → fertig (grünes Häkchen) / Fehler (rot) */
#refresh { transition: background-color .25s, color .25s, border-color .25s; }
#refresh .i-ok, #refresh .i-fail { display: none; }
#refresh.loading { cursor: progress; background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }
#refresh.loading .i-reload { animation: spin .7s linear infinite; }
#refresh.ok { background: var(--ok); border-color: var(--ok); color: var(--page); }
#refresh.fail { background: var(--crit); border-color: var(--crit); color: var(--page); }
#refresh.ok .i-reload, #refresh.fail .i-reload { display: none; }
#refresh.ok .i-ok, #refresh.fail .i-fail { display: block; animation: popin .35s cubic-bezier(.34,1.56,.64,1); }
#refresh .i-ok path, #refresh .i-fail path { stroke-width: 2.4; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes popin { from { transform: scale(.3); opacity: 0; } }
.flash { animation: flash 1.2s ease-out; }
@keyframes flash { 0% { background: var(--ok-soft); color: var(--ok); } }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Modus-Umschalter (Sonne / Mond) ---------- */
#theme { position: relative; width: 44px; height: 44px; padding: 0; color: var(--ink); flex-shrink: 0; }
#theme svg { position: absolute; inset: 7px; width: 30px; height: 30px; overflow: visible;
  transition: transform .7s cubic-bezier(.34,1.56,.64,1), opacity .35s ease; }
#theme .rays line { stroke: currentColor; stroke-width: 2.5; stroke-linecap: round; }
html[data-mode=blau] #theme .moon { transform: rotate(-90deg) scale(.3); opacity: 0; }
html[data-mode=hell] #theme .sun { transform: rotate(90deg) scale(.3); opacity: 0; }
#theme.pop { animation: pop .75s cubic-bezier(.34,1.56,.64,1); }
@keyframes pop { 0% { transform: scale(1) rotate(0); } 30% { transform: scale(.65) rotate(-45deg); } 100% { transform: scale(1) rotate(360deg); } }

/* ---------- Login ---------- */
.login { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 80px 16px 32px; }
.login .panel { width: 100%; max-width: 360px; box-shadow: 0 16px 40px var(--shadow); }
.login-top { position: fixed; top: max(12px, env(safe-area-inset-top)); right: 12px; }
.field { display: grid; gap: 6px; padding: 12px; border-top: 1px solid var(--line); }
.head + .field { border-top: 0; }
.field input { font: inherit; font-size: 17px; color: var(--strong); background: var(--hi); border: 1px solid transparent;
  padding: 10px 12px; border-radius: 0; min-height: 44px; }
.field input:focus { outline: none; border-color: var(--strong); background: transparent; }
.error { border: 1px solid var(--crit); background: var(--crit-soft); color: var(--crit); padding: 12px 14px; font-size: 15px; font-weight: 500; }
.panel .error { border: 0; border-top: 1px solid var(--crit); }

/* ---------- Dashboard ---------- */
.topbar { position: sticky; top: 0; z-index: 10; background: var(--paper); border-bottom: 1px solid var(--line);
  padding-top: env(safe-area-inset-top); transition: background-color .5s, border-color .5s; }
.topbar .row { max-width: 1040px; margin: 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 16px; }
.brand { color: var(--strong); }
.brand span { color: var(--muted); }
.topbar .right { display: flex; align-items: center; gap: 6px; }
.tabs { max-width: 1040px; margin: 0 auto; display: flex; padding: 0 16px; border-top: 1px solid var(--soft); overflow-x: auto; scrollbar-width: none; }
.tabs a { flex: 1; text-align: center; padding: 12px 8px; color: var(--muted); text-decoration: none; border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs a.on { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }

.wrap { max-width: 1040px; margin: 0 auto; padding: 24px 16px 48px; }
section.block { scroll-margin-top: 120px; }
section.block + section.block { margin-top: 36px; }
.sec { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; color: var(--strong); font-size: 14px; font-weight: 600; }
.sec::after { content: ""; flex: 1; border-top: 1px solid var(--soft); }
.sec .n { color: var(--accent); }
.sec .count { border: 1px solid var(--line); padding: 3px 6px; }
.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.note { margin: -4px 0 14px; color: var(--muted); font-size: 15px; }

/* Ampel: .lvl-ok / .lvl-warn / .lvl-crit auf der Karte */
.meter { --c: var(--ok); --cs: var(--ok-soft); }
.meter.lvl-warn { --c: var(--warn); --cs: var(--warn-soft); }
.meter.lvl-crit { --c: var(--crit); --cs: var(--crit-soft); }
.big { display: flex; align-items: baseline; gap: 4px; padding: 16px 14px 10px; }
.big .num { font-size: 48px; line-height: 1; font-weight: 400; color: var(--c); font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.big small { font-size: 20px; color: var(--c); opacity: .75; }
.big .unit { margin-left: 6px; font-size: 16px; }
.bar { margin: 2px 14px 16px; height: 10px; background: var(--cs); position: relative; }
.bar > div { position: absolute; left: 0; top: 0; bottom: 0; width: 0; background: var(--c); transition: width .7s cubic-bezier(.65,0,.35,1); }
.flag { padding: 4px 8px; background: var(--cs); color: var(--c); font-weight: 600; }

.breakdown { list-style: none; padding: 0; }
.breakdown li { display: grid; grid-template-columns: 1fr auto; gap: 6px 10px; padding: 12px 14px; border-top: 1px solid var(--soft); font-size: 16px; }
.breakdown li:first-child { border-top: 0; }
.breakdown b { font-weight: 600; color: var(--strong); }
.breakdown i { grid-column: 1 / -1; height: 6px; background: var(--accent-soft); position: relative; }
.breakdown i::after { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: var(--w); background: var(--accent); }

/* Sessions */
.sessions { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.session .head { align-items: flex-start; padding: 12px 14px; background: transparent; }
.session.is-live { border-color: var(--ok); }
.session.is-live .head { background: var(--ok-soft); }
.session h3 { font-size: 18px; font-weight: 600; line-height: 1.3; color: var(--strong); overflow-wrap: anywhere; }
.session .sub { margin-top: 3px; font-size: 15px; color: var(--muted); overflow-wrap: anywhere; }
.status { flex-shrink: 0; display: inline-flex; align-items: center; gap: 6px; padding: 5px 8px; background: var(--hi); color: var(--muted); font-weight: 600; }
.status.live { background: var(--ok); color: var(--page); }
.status .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; animation: blink 1.6s infinite; }
@keyframes blink { 50% { opacity: .25; } }

.titleblock { margin-top: 40px; }
.titleblock .cells > .cell:nth-child(-n+2) { border-top: 0; }

@media (min-width: 720px) {
  .titleblock { margin-left: auto; max-width: 420px; }
  .tabs { justify-content: flex-start; }
  .tabs a { flex: 0 0 auto; padding: 10px 14px; }
}
@media (max-width: 420px) {
  .topbar .tool .txt { display: none; }
  .cells.three { grid-template-columns: 1fr 1fr; }
  .cells.three > .cell:nth-child(3n+1) { border-left: 1px solid var(--line); }
  .cells.three > .cell:nth-child(2n+1) { border-left: 0; }
  .cells.three > .cell:last-child:nth-child(odd) { grid-column: 1 / -1; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  html { scroll-behavior: auto; }
}
