/* IronLog V2 prototype — tokens copied UNCHANGED from docs/design/handover.md §1 */
:root {
  /* Farben */
  --bg:        #07090F;   /* App-Hintergrund, kühles Fast-Schwarz */
  --panel:     #0D1422;   /* System-Fenster-Fläche */
  --line:      #223455;   /* ruhende Rahmen, Trenner */
  --accent:    #53A8FF;   /* elektrisches Blau: XP, CTA, aktiv — 8,0:1 auf --bg */
  --accent-2:  #A78BFF;   /* Violett: NUR Level-Up / Rang-Aufstieg — 7,4:1 */
  --text-hi:   #EAF2FF;   /* 17:1 */
  --text-mid:  #9FB1D1;   /* 9:1 */
  --text-low:  #7388AE;   /* 5,5:1 — Minimum für Text */

  /* Effekte */
  --glow:      0 0 0 1px rgba(83,168,255,.28), 0 0 18px rgba(83,168,255,.15);
  --glow-up:   0 0 0 1px rgba(167,139,255,.45), 0 0 32px rgba(167,139,255,.30);
  --radius:    4px;

  /* Abstands-Skala */
  --sp-1: 4px;  --sp-2: 8px;  --sp-3: 16px;  --sp-4: 24px;

  /* Typo-Skala */
  --fs-1: 13px; --fs-2: 16px; --fs-3: 22px; --fs-4: 34px; --fs-5: 52px;
  --font:      system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: ui-monospace, "SF Mono", "Cascadia Mono", Consolas, monospace;

  /* Ergonomie */
  --tap: 48px;  /* Touch-Minimum, bewusst > 44px */
}

/* base */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text-hi);
  font-family: var(--font);
  font-size: var(--fs-2);
  overflow: hidden;
}
[hidden] { display: none !important; }
button {
  font: inherit;
  color: inherit;
  margin: 0;
  padding: 0;
  background: none;
  border: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
svg { display: block; }
#app {
  position: relative;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  background: var(--bg);
  user-select: none;
  -webkit-user-select: none;
}
/* desktop / dev preview frame — phones are unaffected */
@media (min-width: 520px) {
  body { display: flex; align-items: center; justify-content: center; background: #0A0D15; }
  #app {
    width: 390px;
    height: min(844px, 100dvh - 32px);
    border: 1px solid var(--line);
    border-radius: 8px;
  }
}

/* utilities */
.mono { font-family: var(--font-mono); }
.tnum { font-variant-numeric: tabular-nums; }
.small { font-size: var(--fs-1); }
.accent { color: var(--accent); }
.violet { color: var(--accent-2); }
.dim2 { color: var(--text-low); }
.row { display: flex; justify-content: space-between; }
.baseline { align-items: baseline; }
.center-v { align-items: center; }
.col { display: flex; flex-direction: column; }
.gap2 { gap: 2px; }
.gap8 { gap: var(--sp-2); }
.grow { flex: 1; min-width: 0; }
.spacer { flex: 1; }
.pad-x { padding-left: var(--sp-3); padding-right: var(--sp-3); }
.center { text-align: center; }
.syslabel, .caplabel {
  font-family: var(--font-mono);
  font-size: var(--fs-1);
  text-transform: uppercase;
}
.syslabel { letter-spacing: 0.18em; }
.caplabel { letter-spacing: 0.14em; color: var(--text-low); }
.t-name { font-size: var(--fs-2); font-weight: 600; }

/* screens */
.screen { display: none; height: 100%; position: relative; }
.screen.active { display: flex; flex-direction: column; }
#screen-home.active { gap: var(--sp-3); }
.scanlines {
  background: repeating-linear-gradient(0deg, #07090F, #07090F 3px, #080B12 3px, #080B12 6px);
}
.center-col.active { justify-content: center; padding: var(--sp-4) var(--sp-3) 156px; }

/* header bar */
.bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--sp-3);
}
.pad-top { padding-top: calc(var(--sp-3) + env(safe-area-inset-top)); }
.dimmed { opacity: 0.4; }
.btn-x {
  width: 44px;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text-low);
  font-size: 18px;
  position: relative;
}
/* invisible hit-area extension: visual stays per design, target ≥ --tap */
.btn-x::after, .np-cancel::after, .select-btn::after, .btn-text::after {
  content: "";
  position: absolute;
  inset: -8px;
}

/* system window */
.syswin {
  position: relative;
  background: var(--panel);
  border: 1px solid rgba(83,168,255,0.5);
  border-radius: var(--radius);
  box-shadow: var(--glow);
}
.cor { position: absolute; inset: 0; display: block; pointer-events: none; }
.syswin::before, .syswin::after, .cor::before, .cor::after {
  content: "";
  position: absolute;
  width: 12px;
  height: 12px;
  pointer-events: none;
}
.syswin::before { top: -1px; left: -1px; border-top: 2px solid var(--accent); border-left: 2px solid var(--accent); }
.syswin::after { bottom: -1px; right: -1px; border-bottom: 2px solid var(--accent); border-right: 2px solid var(--accent); }
.cor::before { top: -1px; right: -1px; border-top: 2px solid var(--accent); border-right: 2px solid var(--accent); }
.cor::after { bottom: -1px; left: -1px; border-bottom: 2px solid var(--accent); border-left: 2px solid var(--accent); }
.syswin.up { border-color: rgba(167,139,255,0.6); box-shadow: var(--glow-up); }
.syswin.up::before, .syswin.up::after,
.syswin.up .cor::before, .syswin.up .cor::after { border-color: var(--accent-2); }

.sysrow { display: flex; align-items: center; gap: 10px; }
.diamond { width: 8px; height: 8px; background: var(--accent); transform: rotate(45deg); }
.diamond.violet { background: var(--accent-2); }
.pulse { animation: softPulse 2.4s ease-in-out infinite; }
@keyframes softPulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.55; } }

/* bars (XP / timer) */
.bar-track {
  height: 8px;
  background: var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.bar-track.slim { height: 4px; }
.bar-fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #53A8FF, #7FBDFF);
  transform-origin: left;
  transform: scaleX(0);
}
.bar-fill.anim { transition: transform 1.4s ease-out; }
.up-fill { background: linear-gradient(90deg, #53A8FF, #A78BFF); }
.xp-block { display: flex; flex-direction: column; gap: 6px; }

/* buttons */
.btn-primary, .btn-cta {
  width: 100%;
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  background: rgba(83,168,255,0.12);
  color: var(--text-hi);
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.04em;
}
.btn-primary { height: 64px; box-shadow: var(--glow); }
.btn-cta { height: 60px; }
.btn-cta.glow { box-shadow: var(--glow); }
.btn-primary:active, .btn-cta:active { transform: translateY(1px); }
.btn-primary.violet {
  border-color: var(--accent-2);
  background: rgba(167,139,255,0.12);
  box-shadow: var(--glow-up);
}
.btn-primary.h56 { height: 56px; }
.btn-secondary {
  height: 64px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--text-mid);
  font-size: var(--fs-2);
}
.btn-outline, .btn-text {
  width: 100%;
  height: var(--tap);
  color: var(--text-low);
  font-family: var(--font-mono);
  font-size: var(--fs-1);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.btn-outline { border: 1px solid var(--line); border-radius: var(--radius); }
.btn-text { position: relative; }

/* cards */
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

/* home */
.status-panel { padding: var(--sp-4); display: flex; flex-direction: column; gap: var(--sp-3); }
.level-big { font-size: var(--fs-4); font-weight: 700; line-height: 1; }
.rank { font-size: var(--fs-2); font-weight: 600; color: var(--accent); }
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-2); }
.card.stat { padding: var(--sp-3); display: flex; flex-direction: column; gap: var(--sp-1); }
.stat-val { font-size: var(--fs-3); font-weight: 700; }
.stat-val small, .step-val small { font-size: var(--fs-1); font-weight: 400; color: var(--text-low); }
.last-session { padding: 14px var(--sp-3); display: flex; justify-content: space-between; align-items: center; gap: var(--sp-2); }

/* tab bar */
.tabbar {
  border-top: 1px solid var(--line);
  padding: 10px var(--sp-3) calc(18px + env(safe-area-inset-bottom));
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-2);
}
.tab {
  height: var(--tap);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  border-radius: var(--radius);
  color: var(--text-low);
  font-family: var(--font-mono);
  font-size: var(--fs-1);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.tab.on { background: rgba(83,168,255,0.08); color: var(--accent); }
.ic-diamond { width: 10px; height: 10px; background: currentColor; transform: rotate(45deg); }
.ic-bars { display: flex; align-items: flex-end; gap: 2px; }
.ic-bars b { width: 3px; background: currentColor; }
.ic-bars b:nth-child(1) { height: 6px; }
.ic-bars b:nth-child(2) { height: 10px; }
.ic-bars b:nth-child(3) { height: 8px; }

/* quote / complete overlays */
.overlay-win { padding: 32px var(--sp-4); display: flex; flex-direction: column; gap: var(--sp-4); }
.quote { margin: 0; font-size: 26px; line-height: 1.35; font-weight: 600; text-wrap: pretty; }
.overlay-meta { border-top: 1px solid var(--line); padding-top: var(--sp-3); display: flex; flex-direction: column; gap: var(--sp-1); }
.overlay-title { font-size: 26px; font-weight: 700; }
.bottom-stack { display: flex; flex-direction: column; gap: 12px; }
.center-col .bottom-stack {
  position: absolute;
  left: var(--sp-3);
  right: var(--sp-3);
  bottom: calc(var(--sp-4) + env(safe-area-inset-bottom));
}
.complete-variant { display: contents; }
.statlist { display: flex; flex-direction: column; }
.statline {
  display: flex;
  justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}
.statline.last { border-bottom: none; }
.statline > span:first-child { color: var(--text-mid); }
.statline > span:last-child { font-weight: 700; }
.xp-gain { font-size: var(--fs-3); font-weight: 700; color: var(--accent); }
.lvl-jump { display: flex; align-items: baseline; justify-content: center; gap: var(--sp-3); padding: var(--sp-2) 0; }
.lvl-old { font-size: var(--fs-4); font-weight: 700; color: var(--text-low); }
.lvl-arrow { font-size: 26px; color: var(--accent-2); }
.lvl-new { font-size: 64px; font-weight: 700; line-height: 1; }
.rankline {
  border-top: 1px solid var(--line);
  padding-top: var(--sp-3);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.rankline > span:first-child { color: var(--text-mid); }
.rankline > span:last-child { font-weight: 600; }

/* logging */
.ex-head { padding: 0 var(--sp-3); display: flex; flex-direction: column; gap: 6px; }
.ex-name { font-size: var(--fs-3); font-weight: 700; }
.ex-last { font-size: var(--fs-2); color: var(--text-low); }
.log-body { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.fieldrow {
  padding: 20px var(--sp-3) 0;
  display: grid;
  grid-template-columns: 1.3fr 1fr 1fr;
  gap: var(--sp-2);
}
.fieldcard {
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
  align-items: center;
  min-height: var(--tap);
}
.fieldcard .fval {
  font-family: var(--font-mono);
  font-size: 26px;
  font-weight: 700;
}
.fieldcard.on, .stepper.on { border-color: var(--accent); box-shadow: var(--glow); }
.fieldcard.on .caplabel, .stepper.on .caplabel { color: var(--accent); }
.fval.empty, .np-buffer.empty { color: var(--text-low); }
.hintzone {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 var(--sp-4);
  text-align: center;
}
.actionzone {
  padding: 0 var(--sp-3) calc(18px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: opacity 0.25s ease;
}
.numpad-open .actionzone { opacity: 0; pointer-events: none; }
.numpad-open .hintzone { align-items: flex-start; padding-top: var(--sp-2); }
.stepper { padding: 12px 12px 16px; display: flex; flex-direction: column; gap: var(--sp-2); }
.stepper-row { display: flex; align-items: center; gap: var(--sp-2); }
.step-btn, .np-key {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg);
  font-family: var(--font-mono);
}
.step-btn {
  width: 64px;
  height: 64px;
  flex-shrink: 0;
  color: var(--text-mid);
  font-size: 26px;
}
.step-btn:active, .np-key:active { background: rgba(83,168,255,0.15); }
.step-btn.plus { border-color: var(--accent); background: rgba(83,168,255,0.1); color: var(--accent); }
.step-btn.plus:active { background: rgba(83,168,255,0.25); transform: translateY(1px); }
.step-val {
  flex: 1;
  height: 64px;
  border: 1px dashed rgba(83,168,255,0.45);
  border-radius: var(--radius);
  font-size: 40px;
  font-weight: 700;
  color: var(--text-hi);
}

/* timer variant */
.timerzone {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--sp-3);
  padding: 0 var(--sp-3);
}
.big-time { font-size: 76px; font-weight: 700; line-height: 1; }
.ptrack { width: 200px; }
.rest-track { width: 100%; max-width: 280px; height: 6px; }
.log-body .bottom-stack { padding: 0 var(--sp-3) calc(18px + env(safe-area-inset-bottom)); }

/* stacked variant */
.stack-zone { padding: 0 var(--sp-3); display: flex; flex-direction: column; gap: 12px; }
.restrow {
  margin: 12px var(--sp-3) 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px var(--sp-3);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.ctazone { padding: var(--sp-3) var(--sp-3) calc(18px + env(safe-area-inset-bottom)); }

/* rest screen */
#screen-rest .timerzone { gap: 20px; }
.next-box { padding: 14px 20px; display: flex; flex-direction: column; gap: var(--sp-1); align-items: center; }
.next-line { font-size: var(--fs-2); }
.rest-actions {
  padding: 0 var(--sp-3) calc(18px + env(safe-area-inset-bottom));
  display: grid;
  grid-template-columns: 1fr 1.6fr;
  gap: var(--sp-2);
}

/* history */
.hist-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 0 var(--sp-3) var(--sp-3);
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
}
.sessionlist { display: flex; flex-direction: column; gap: var(--sp-2); }
.session-item { padding: 12px 14px; display: flex; align-items: center; gap: 12px; }
.session-date { width: 40px; flex-shrink: 0; display: flex; flex-direction: column; align-items: center; }
.session-date .d { font-family: var(--font-mono); font-size: var(--fs-2); font-weight: 700; }
.session-date .m { font-family: var(--font-mono); font-size: var(--fs-1); color: var(--text-low); }
.session-mid { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.session-mid .n { font-size: var(--fs-2); font-weight: 600; }
.session-mid .meta { font-family: var(--font-mono); font-size: var(--fs-1); color: var(--text-low); }
.session-mid .n, .session-mid .meta { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.session-xp { flex-shrink: 0; font-family: var(--font-mono); font-size: var(--fs-1); font-weight: 700; color: var(--accent); }
.chart-card { padding: var(--sp-3); display: flex; flex-direction: column; gap: 12px; }
#prog-chart { width: 100%; height: 96px; }
.select-btn {
  height: 32px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text-hi);
  font-size: var(--fs-1);
  position: relative;
}
.bw-card { padding: var(--sp-3); display: flex; align-items: center; gap: var(--sp-3); }
#bw-chart { width: 120px; height: 24px; }
.btn-add {
  height: var(--tap);
  padding: 0 var(--sp-3);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  background: rgba(83,168,255,0.1);
  color: var(--accent);
  font-size: var(--fs-2);
  font-weight: 600;
  flex-shrink: 0;
}
.btn-add:active { transform: translateY(1px); }

/* numpad */
.numpad {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 50;
  transform: translateY(108%);
  transition: transform 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
  background: var(--panel);
  border-top: 1px solid var(--accent);
  box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.5);
  padding: 12px var(--sp-3) calc(18px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}
.numpad.open { transform: translateY(0); }
.numpad-head { display: flex; align-items: center; gap: 12px; padding: 0 2px 2px; }
.np-buffer { flex: 1; text-align: right; font-size: var(--fs-3); font-weight: 700; }
.np-cancel {
  width: 44px;
  height: 32px;
  color: var(--text-low);
  font-size: var(--fs-1);
  position: relative;
}
.np-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: var(--sp-2); }
.np-key { height: 52px; color: var(--text-hi); font-size: var(--fs-3); }
#np-apply { height: 56px; margin-top: var(--sp-1); }

/* dialog */
.dialog-backdrop {
  position: absolute;
  inset: 0;
  z-index: 60;
  background: rgba(7, 9, 15, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--sp-4) var(--sp-3);
}
.dialog-win { width: 100%; padding: var(--sp-4); display: flex; flex-direction: column; gap: var(--sp-3); }
.dialog-text { margin: 0; color: var(--text-mid); }
.dialog-actions { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-2); }
.dialog-actions .btn-outline { height: 56px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
