/* ============================================================
   Ziffernleser: dark lab theme, flache Flaechen, keine Deko.
   Eigenes Violett: #31184d fuer Linien, #a97fd1 als Akzent.
   Self-contained: system font stack, no external assets.
   ============================================================ */

:root {
  --bg: #0c0813;
  --panel: #150e20;
  --panel-2: #1b1229;
  --ink-well: #0e0917;
  --line: #31184d;
  --line-2: #45276b;
  --text: #ece7f6;
  --dim: #b3a6c9;
  --faint: #82749d;
  --accent: #a97fd1;
  --accent-deep: #6c46a3;
  --accent-soft: rgba(169, 127, 209, 0.13);
  --green: #34d399;
  --amber: #fbbf24;
  --blue: #38bdf8;
  --mono:
    ui-monospace, "Cascadia Mono", Consolas, "Segoe UI Mono", Menlo, monospace;
  --sans:
    system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial,
    sans-serif;
  --radius: 12px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font: 400 15px/1.55 var(--sans);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

.mono {
  font-family: var(--mono);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--accent);
  color: #211138;
  font-weight: 600;
  padding: 8px 14px;
  border-radius: 0 0 8px 0;
  z-index: 10000;
  text-decoration: none;
}
.skip-link:focus-visible {
  left: 0;
}

.shell {
  max-width: 1280px;
  margin: 0 auto;
  padding: 18px clamp(12px, 2.5vw, 28px) 84px;
}

/* ---------- Topbar ---------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  padding: 6px 2px 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}
.brand-logo {
  display: grid;
  place-items: center;
  flex: none;
}
.brand-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.brand-text strong {
  font-size: 19px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
.brand-text small {
  color: var(--dim);
  font-size: 12.5px;
}

.top-status {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font: 600 11.5px/1 var(--mono);
  letter-spacing: 0.12em;
  padding: 7px 12px;
  border-radius: 999px;
  border: 1px solid var(--line-2);
  background: var(--panel-2);
}
.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--amber);
  animation: pulse 1.4s ease-in-out infinite;
}
.status-badge[data-state="ready"] .status-dot {
  background: var(--green);
  animation: none;
}
.status-badge[data-state="ready"] {
  border-color: rgba(52, 211, 153, 0.4);
}
.status-badge[data-state="tune"] .status-dot {
  background: var(--accent);
}
@keyframes pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.35;
  }
}

.epoch-tag {
  font-size: 12px;
  color: var(--dim);
  border: 1px solid var(--line);
  background: var(--panel);
  padding: 7px 12px;
  border-radius: 999px;
  white-space: nowrap;
}

/* ---------- Honest copy ---------- */

.honest {
  margin: 0 0 18px;
  padding: 13px 16px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: 10px;
  background: var(--panel);
  color: var(--dim);
  font-size: 14px;
}
.honest strong,
.honest em {
  color: var(--text);
}

/* ---------- Layout ---------- */

.deck {
  display: grid;
  grid-template-columns: minmax(0, 26fr) minmax(0, 21fr);
  gap: 16px;
  align-items: start;
}

.side {
  display: grid;
  gap: 16px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
}

.panel-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.panel-head h2 {
  margin: 0;
  font-size: 14px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--dim);
  font-weight: 600;
}

/* ---------- Buttons ---------- */

.btn {
  appearance: none;
  border: 1px solid var(--line-2);
  background: var(--panel-2);
  color: var(--text);
  font: 500 13px/1 var(--sans);
  padding: 8px 13px;
  border-radius: 9px;
  cursor: pointer;
}
.btn:hover {
  border-color: var(--accent-deep);
  background: #241536;
}
.btn:active {
  transform: translateY(1px);
}
.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}
.btn-tool[aria-pressed="true"] {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: #eadffa;
}

.tools {
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
}

/* ---------- Zeichenfeld ---------- */

.draw-row {
  display: flex;
  gap: 16px;
  align-items: stretch;
  flex-wrap: wrap;
}

.draw-wrap {
  position: relative;
  width: min(280px, 100%);
  flex: none;
}

#draw-canvas {
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
  background: var(--ink-well);
  border: 1px solid var(--line-2);
  border-radius: 10px;
  touch-action: none;
  cursor: crosshair;
}

.train-overlay {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 16px;
  text-align: center;
  background: rgba(10, 5, 20, 0.86);
  border-radius: 10px;
  transition: opacity 0.35s ease;
}
.train-overlay.done {
  opacity: 0;
  pointer-events: none;
}
.overlay-title {
  font-weight: 600;
  font-size: 14.5px;
}
.overlay-detail {
  color: var(--dim);
  font-size: 12.5px;
}
.overlay-bar {
  width: min(180px, 80%);
  height: 6px;
  border-radius: 999px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  overflow: hidden;
}
.overlay-fill {
  display: block;
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: var(--accent);
}

.noscript-note {
  position: absolute;
  inset: 0;
  z-index: 6;
  display: grid;
  place-items: center;
  margin: 0;
  padding: 20px;
  text-align: center;
  color: var(--dim);
  background: var(--ink-well);
  border-radius: 10px;
}

.net-view {
  flex: 1 1 130px;
  min-width: 120px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
  border: 1px dashed var(--line-2);
  border-radius: 10px;
  background: var(--panel-2);
}
.net-view-label {
  font-size: 12px;
  color: var(--dim);
  line-height: 1.4;
}
#input-preview {
  width: 84px;
  height: 84px;
  image-rendering: pixelated;
  background: var(--ink-well);
  border: 1px solid var(--line);
  border-radius: 6px;
}
.net-view-sub {
  font-size: 11px;
  color: var(--faint);
  line-height: 1.45;
}

.draw-hint {
  margin: 10px 0 0;
  color: var(--faint);
  font-size: 12.5px;
}

/* ---------- Vorhersage ---------- */

.result {
  margin-top: 14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel-2);
}

.result-top {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 12px;
}

.pred-digit {
  font-size: 64px;
  font-weight: 700;
  line-height: 1;
  min-width: 58px;
  text-align: center;
  color: var(--accent);
}

.pred-meta {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}
.pred-label {
  font-size: 11.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--faint);
}
.pred-conf {
  font-size: 15px;
  color: var(--dim);
}

.bars {
  display: grid;
  gap: 5px;
}
.bar-row {
  display: grid;
  grid-template-columns: 16px minmax(0, 1fr) 46px;
  align-items: center;
  gap: 9px;
}
.bar-digit {
  font: 600 12.5px/1 var(--mono);
  color: var(--faint);
  text-align: center;
}
.bar-track {
  height: 9px;
  border-radius: 999px;
  background: var(--ink-well);
  border: 1px solid var(--line);
  overflow: hidden;
}
.bar-fill {
  display: block;
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent-deep), var(--accent));
  opacity: 0.55;
  transition: width 0.22s ease-out;
}
.bar-val {
  font: 500 11.5px/1 var(--mono);
  color: var(--faint);
  text-align: right;
  white-space: nowrap;
}
.bar-row.top .bar-digit,
.bar-row.top .bar-val {
  color: var(--text);
}
.bar-row.top .bar-fill {
  opacity: 1;
}

/* ---------- Nachlernen ---------- */

.teach {
  margin-top: 14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel-2);
}
.teach-label {
  display: block;
  font-size: 13px;
  color: var(--dim);
  margin-bottom: 10px;
}
.teach-btns {
  display: grid;
  grid-template-columns: repeat(10, minmax(0, 1fr));
  gap: 6px;
}
.teach-btn {
  appearance: none;
  border: 1px solid var(--line-2);
  background: var(--panel-2);
  color: var(--text);
  font: 600 15px/1 var(--mono);
  padding: 9px 0;
  border-radius: 8px;
  cursor: pointer;
}
.teach-btn:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.teach-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.teach-status {
  margin: 10px 0 0;
  min-height: 1.2em;
  font-size: 12.5px;
  color: var(--dim);
}
.teach-status.ok {
  color: var(--green);
}

/* ---------- Training / Metriken ---------- */

.train-pct {
  font-size: 12.5px;
  color: var(--accent);
}

.metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}
.metric {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}
.metric-label {
  font-size: 10.5px;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--faint);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.metric-value {
  font-size: 17px;
  font-weight: 600;
}

.curve-wrap {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--ink-well);
  padding: 10px 10px 8px;
}
#curve {
  display: block;
  width: 100%;
  height: 120px;
}
.curve-legend {
  display: flex;
  gap: 16px;
  margin-top: 7px;
  font-size: 11.5px;
  color: var(--faint);
}
.curve-legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.sw {
  width: 14px;
  height: 3px;
  border-radius: 2px;
  display: inline-block;
}
.sw-loss {
  background: var(--accent);
}
.sw-acc {
  background: var(--green);
}

.final-acc {
  margin: 12px 0 0;
  padding: 12px 14px;
  border: 1px solid rgba(52, 211, 153, 0.35);
  border-radius: 10px;
  background: rgba(52, 211, 153, 0.08);
  font-size: 14px;
  color: var(--dim);
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
}
.final-acc[hidden] {
  display: none;
}
.final-acc b {
  font-size: 26px;
  color: var(--green);
}
.final-acc small {
  color: var(--faint);
  font-size: 11.5px;
}

/* ---------- Blick ins Netz ---------- */

#weights {
  display: block;
  width: 100%;
  height: auto;
  image-rendering: pixelated;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--ink-well);
}
.weights-note {
  margin: 10px 0 0;
  font-size: 12.5px;
  color: var(--faint);
  line-height: 1.55;
}
.weights-note .pos {
  color: var(--accent);
}
.weights-note .neg {
  color: var(--blue);
}

/* ---------- So funktioniert's ---------- */

.how-list {
  margin: 0;
  padding-left: 20px;
  color: var(--dim);
  font-size: 13px;
  display: grid;
  gap: 8px;
}

/* ---------- Footer ---------- */

.site-footer {
  margin-top: 26px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  color: var(--dim);
  font-size: 13px;
}
.site-footer p {
  margin: 0 0 6px;
}
.site-footer strong {
  color: var(--text);
}
.footer-tech {
  color: var(--faint);
  font-size: 12px;
}
.footer-log {
  color: var(--faint);
  font-size: 11px;
  letter-spacing: 0.01em;
}

/* ---------- Responsive ---------- */

@media (max-width: 980px) {
  .deck {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 480px) {
  .shell {
    padding-left: 10px;
    padding-right: 10px;
  }
  .panel {
    padding: 12px;
  }
  .teach-btns {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }
  .metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .pred-digit {
    font-size: 52px;
    min-width: 48px;
  }
  .brand-text small {
    white-space: normal;
  }
}

/* ---------- Reduced motion ---------- */

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

/* ---------- Demo ribbon (Standard) ---------- */

.demo-ribbon {
  position: fixed;
  left: 14px;
  bottom: 14px;
  z-index: 9999;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: rgba(15, 18, 22, 0.85);
  color: #fff;
  font:
    500 12px/1 system-ui,
    -apple-system,
    "Segoe UI",
    Roboto,
    sans-serif;
  padding: 9px 13px;
  border-radius: 999px;
  text-decoration: none;
  letter-spacing: 0.01em;
  opacity: 0.85;
}
.demo-ribbon:hover,
.demo-ribbon:focus-visible {
  opacity: 1;
}
@media print {
  .demo-ribbon {
    display: none;
  }
}
