/* BinLab -- Tablet-first, hell/dunkel nach Systemeinstellung oder Umschalter. Keine externen Ressourcen.
   Grundgerüst aus GateLab übernommen; BinLab-eigene Teile stehen am Ende. */

:root {
  --bg: #f4f5f7;
  --panel: #ffffff;
  --ink: #1d2433;
  --muted: #5f6b7f;
  --line: #d5dae2;
  --accent: #2563eb;
  --accent-ink: #ffffff;
  --hi: #f59e0b;        /* Leitung = 1 */
  --hi-glow: rgba(245, 158, 11, .35);
  --lo: #6b7a90;        /* Leitung = 0 */
  --unk: #b4bcc8;       /* undefiniert */
  --ok: #15803d;
  --ok-bg: #e8f6ec;
  --bad: #dc2626;
  --bad-bg: #fdecec;
  --gate-fill: #ffffff;
  --gate-stroke: #1d2433;
  --radius: 12px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}

/* Dunkles Schema: per Systemeinstellung oder per Umschalter (data-theme, theme.ts) */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #12161f;
    --panel: #1b212d;
    --ink: #e6e9ef;
    --muted: #9aa5b7;
    --line: #2f3747;
    --accent: #5b8cff;
    --hi: #fbbf24;
    --hi-glow: rgba(251, 191, 36, .35);
    --lo: #7c8aa1;
    --unk: #4a5468;
    --ok: #4ade80;
    --ok-bg: #173323;
    --bad: #f87171;
    --bad-bg: #3a1c1c;
    --gate-fill: #232a38;
    --gate-stroke: #e6e9ef;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #12161f;
  --panel: #1b212d;
  --ink: #e6e9ef;
  --muted: #9aa5b7;
  --line: #2f3747;
  --accent: #5b8cff;
  --hi: #fbbf24;
  --hi-glow: rgba(251, 191, 36, .35);
  --lo: #7c8aa1;
  --unk: #4a5468;
  --ok: #4ade80;
  --ok-bg: #173323;
  --bad: #f87171;
  --bad-bg: #3a1c1c;
  --gate-fill: #232a38;
  --gate-stroke: #e6e9ef;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body { font-size: 16px; line-height: 1.4; -webkit-text-size-adjust: 100%; }
#app { padding: max(12px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right))
       max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
       max-width: 1500px; margin: 0 auto; }
button { font: inherit; color: inherit; }
a { color: var(--accent); }
.loading, .load-error { color: var(--muted); padding: 2rem 0; }

/* ---------------------------------------------------------------- Übersicht */

.overview { max-width: 720px; margin: 0 auto; }
.overview h1 { font-size: 2.2rem; margin: .5rem 0 .25rem; }
.lead { color: var(--muted); margin: 0 0 .5rem; }
.total { font-weight: 600; color: var(--hi); margin: 0 0 1rem; }
.task-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.task-card {
  display: grid; grid-template-columns: 2.4rem 1fr auto auto; align-items: center; gap: 12px;
  padding: 14px 16px; min-height: 64px; border-radius: var(--radius);
  background: var(--panel); border: 1px solid var(--line); color: var(--ink); text-decoration: none;
}
.task-card:active { transform: scale(.99); }
.task-card .num {
  width: 2.2rem; height: 2.2rem; border-radius: 50%; display: grid; place-items: center;
  background: var(--bg); font-weight: 700; color: var(--muted);
}
.task-card.done .num { background: var(--ok-bg); color: var(--ok); }
.task-card .title { font-weight: 600; font-size: 1.1rem; }
.task-card .parts { display: flex; gap: 2px; }
.task-card .parts svg { width: 28px; height: 24px; }
.task-card .stars { color: var(--hi); font-size: 1.2rem; letter-spacing: 1px; white-space: nowrap; }
.privacy { color: var(--muted); font-size: .85rem; margin-top: 1.5rem; }
.link-btn { background: none; border: 0; padding: 4px 0; margin-left: .4em; color: var(--accent);
  text-decoration: underline; cursor: pointer; font-size: inherit; }
.reset-confirm { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: .9rem;
  padding: 10px 12px; border: 1px solid var(--bad); border-radius: 8px; background: var(--bad-bg); }
.reset-confirm[hidden] { display: none; }
.reset-confirm button { padding: 8px 14px; border-radius: 8px; border: 1px solid var(--muted);
  background: var(--bg); cursor: pointer; }
.reset-confirm button.danger { background: var(--bad); border-color: var(--bad); color: #fff; }

/* ---------------------------------------------------------------- Aufgabenkopf */

.task-head { margin-bottom: 10px; }
.task-head .back { display: inline-block; padding: 6px 0; text-decoration: none; font-weight: 600; }
.task-head h1 { font-size: 1.5rem; margin: 2px 0 4px; }
.task-head p { margin: 0; color: var(--muted); max-width: 70ch; }

/* ---------------------------------------------------------------- Werkbank */

.workbench {
  display: grid; gap: 12px;
  grid-template-columns: 116px minmax(0, 1fr) 300px;
  align-items: start;
}

/* Viele Tabellenspalten (z. B. 2-Bit-Rechenwerk): breitere Tabelle, engere Zellen */
@media (min-width: 1101px) {
  .workbench.wide { grid-template-columns: 116px minmax(0, 1fr) 390px; }
}
.workbench.wide .truth th, .workbench.wide .truth td { padding: 6px 2px; }

.palette, .side, .canvas-wrap {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
}
.palette { padding: 8px; display: flex; flex-direction: column; gap: 8px; position: sticky; top: 8px;
           transition: background .15s, border-color .15s; }
.palette-title { font-size: .8rem; color: var(--muted); text-transform: uppercase; letter-spacing: .05em;
                 text-align: center; }
.part {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 8px 4px 6px; min-height: 84px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--bg); cursor: grab; touch-action: none;
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
}
.part svg { width: 64px; height: 52px; }
.part:disabled { opacity: .35; cursor: not-allowed; }
.part-name { font-size: .8rem; font-weight: 600; }
.part .count { position: absolute; top: 4px; right: 6px; font-size: .75rem; color: var(--muted); }
.trash-hint { display: none; font-size: .8rem; text-align: center; color: var(--bad); padding: 6px 2px; }
.palette.trash-hot { background: var(--bad-bg); border-color: var(--bad); }
.palette.trash-hot .trash-hint { display: block; }

.canvas-wrap { overflow: hidden; }
/* Wischen scrollt die Seite; nur ein Ziehen, das auf einem Baustein beginnt, unterdrückt das (touchstart im Code) */
.canvas { display: block; width: 100%; height: auto; touch-action: manipulation; user-select: none;
          -webkit-user-select: none; -webkit-touch-callout: none; }

.toolbar { display: flex; flex-wrap: wrap; gap: 8px; padding: 8px; border-top: 1px solid var(--line); }
.toolbar .spacer { flex: 1; }
.toolbar button {
  min-height: 44px; padding: 0 14px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--bg); cursor: pointer;
}
.toolbar button:disabled { opacity: .4; cursor: default; }
.toolbar button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent);
                          font-weight: 700; padding: 0 22px; }

/* ---------------------------------------------------------------- SVG-Elemente */

.gate-body { fill: var(--gate-fill); stroke: var(--gate-stroke); stroke-width: 2.5; }
.gate-bubble { fill: var(--gate-fill); stroke: var(--gate-stroke); stroke-width: 2.5; } /* Negation: Teil des Gatters */
.gate-sym { font-size: 26px; font-weight: 600; text-anchor: middle; fill: var(--gate-stroke); }
.gate-label { font-size: 13px; text-anchor: middle; fill: var(--muted); }
.gate-out { font-size: 15px; font-weight: 600; text-anchor: end; fill: var(--gate-stroke); }
.stub { stroke: var(--gate-stroke); stroke-width: 2.5; }
.gate-hit { fill: transparent; }
.gate { cursor: grab; }
.gate.selected .gate-body { stroke: var(--accent); stroke-width: 4; }
.gate.error .gate-body { stroke: var(--bad); stroke-width: 4; }
.gate.ghost { opacity: .5; pointer-events: none; }

.wire { fill: none; stroke-width: 4; stroke-linejoin: round; stroke-linecap: round; pointer-events: none; }
.wire.hi { stroke: var(--hi); filter: drop-shadow(0 0 4px var(--hi-glow)); }
.wire.lo { stroke: var(--lo); }
.wire.unk { stroke: var(--unk); stroke-dasharray: 6 6; }
.wire.selected { stroke: var(--accent); stroke-width: 6; stroke-dasharray: none; }
.wire-hit { fill: none; stroke: transparent; stroke-width: 22; cursor: pointer; }
.dot { stroke: none; }
.dot.hi { fill: var(--hi); } .dot.lo { fill: var(--lo); } .dot.unk { fill: var(--unk); }
.rubber { stroke: var(--accent); stroke-width: 3; stroke-dasharray: 8 6; pointer-events: none; }

.pin { cursor: crosshair; }
.pin-hit { fill: transparent; }
/* Anschlüsse: ausgefüllte Punkte in Signalfarbe -- bewusst anders als der hohle Negationskreis */
.pin-dot { stroke: none; fill: var(--unk); }
.pin-dot.hi { fill: var(--hi); } .pin-dot.lo { fill: var(--lo); }
.pin-dot.open { fill: none; stroke: var(--accent); stroke-width: 2.5; }
.pin.hot .pin-dot { fill: var(--accent); stroke: var(--accent); r: 10; }
.pin.error .pin-dot { fill: var(--bad); stroke: var(--bad); r: 9; }

.terminal text { text-anchor: middle; }
.term-name { font-size: 22px; font-weight: 700; fill: var(--ink); }
.term-val { font-size: 22px; font-weight: 700; }
.terminal.input { cursor: pointer; }
.terminal.const { cursor: default; }
.terminal.const rect { stroke-dasharray: 6 4; }
.terminal.const .term-name { font-size: 15px; }
.terminal.input rect { stroke-width: 2.5; }
.terminal.input.lo rect { fill: var(--panel); stroke: var(--lo); }
.terminal.input.lo .term-val { fill: var(--lo); }
.terminal.input.hi rect { fill: var(--hi); stroke: var(--hi); filter: drop-shadow(0 0 6px var(--hi-glow)); }
.terminal.input.hi .term-val { fill: #1d2433; }
.lamp { stroke-width: 2.5; fill: var(--panel); stroke: var(--unk); }
.terminal.output.lo .lamp { stroke: var(--lo); }
.terminal.output.hi .lamp { fill: var(--hi); stroke: var(--hi); filter: drop-shadow(0 0 10px var(--hi-glow)); }
.terminal.output .term-val { fill: var(--muted); }
.terminal.output.hi .term-val { fill: #1d2433; }
.terminal.output.error .lamp { stroke: var(--bad); stroke-width: 4; }

/* ---------------------------------------------------------------- Seitenleiste */

.side { padding: 12px; display: flex; flex-direction: column; gap: 12px; }
.truth { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; }
.truth th, .truth td { text-align: center; padding: 6px 4px; }
.truth thead th { font-size: .8rem; color: var(--muted); font-weight: 600; }
.truth thead tr:last-child th { font-size: 1rem; color: var(--ink); border-bottom: 2px solid var(--line); }
.truth tbody tr { cursor: pointer; border-bottom: 1px solid var(--line); }
.truth tbody td { height: 40px; }
.truth .soll { background: color-mix(in srgb, var(--bg) 70%, transparent); }
.truth .ist { font-weight: 700; }
.truth tr.current { outline: 3px solid var(--accent); outline-offset: -3px; }
.truth tr.ok .mark { color: var(--ok); }
.truth tr.bad .mark, .truth tr.bad .ist { color: var(--bad); }
.truth tr.wrong { background: var(--bad-bg); }
.tip { margin: 0; font-size: .85rem; color: var(--muted); }

.feedback { border-radius: 10px; padding: 10px 12px; }
.feedback ul { margin: 6px 0 0; padding-left: 1.2em; }
.feedback.success { background: var(--ok-bg); color: var(--ok); }
.feedback.error { background: var(--bad-bg); color: var(--bad); }
.feedback .stars { font-size: 2rem; color: var(--hi); letter-spacing: 3px; }
.hints { background: var(--bg); border-radius: 10px; padding: 10px 12px; }
.hints ul { margin: 6px 0 0; padding-left: 1.2em; }

/* ---------------------------------------------------------------- Schmale Bildschirme */

@media (max-width: 1100px) {
  .workbench { grid-template-columns: 104px minmax(0, 1fr); }
  .side { grid-column: 1 / -1; }
  .side { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: start; }
  .side .truth { grid-row: span 3; }
}

@media (max-width: 700px) {
  .workbench { grid-template-columns: minmax(0, 1fr); }
  .palette { position: static; flex-direction: row; overflow-x: auto; }
  .palette-title { display: none; }
  .part { min-width: 84px; }
  .side { display: flex; }
  .toolbar button { padding: 0 10px; }
}

/* ---------------------------------------------------------------- Hörsaal-Barometer */

.barometer { margin: 2px 0 6px !important; color: var(--hi) !important; font-weight: 600; }

/* ---------------------------------------------------------------- Kopfzeile mit Logo */

:root { --logo: #2a2068; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --logo: #c9c3f2; } }
:root[data-theme="dark"] { --logo: #c9c3f2; }

.site-header {
  display: flex; align-items: center; gap: 12px;
  padding: max(8px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) 8px
           max(16px, env(safe-area-inset-left));
  background: var(--panel); border-bottom: 1px solid var(--line);
}
.site-brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink);
              max-width: 1500px; width: 100%; margin: 0 auto; }
.theme-toggle { flex: none; display: grid; place-items: center; width: 44px; height: 44px;
  border: 1px solid var(--line); border-radius: 50%; background: var(--bg); color: var(--ink); cursor: pointer; }
.theme-toggle .icon { width: 22px; height: 22px; }
.hs-logo { height: 30px; width: auto; color: var(--logo); flex: none; }
.site-org { font-weight: 600; color: var(--logo); }
.site-name { font-weight: 800; padding-left: 10px; border-left: 2px solid var(--line); }
.site-brand a { display: flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; }
.site-brand .hs-link:hover .site-org { text-decoration: underline; }
.site-footer { text-align: center; font-size: .8rem; color: var(--muted);
               padding: 24px 16px max(16px, env(safe-area-inset-bottom)); }
.site-footer a { color: inherit; }
#app { padding-top: 12px; }

@media (max-width: 500px) {
  .site-org { display: none; }
  .site-name { padding-left: 0; border-left: 0; }
}

/* ---------------------------------------------------------------- Symbole */

.icon { width: 1.15em; height: 1.15em; vertical-align: -0.2em; flex: none; }
.toolbar button { display: inline-flex; align-items: center; gap: 6px; }

/* ---------------------------------------------------------------- Phase 4: Level, Badges, Effekte */

.overview h2 { font-size: 1.2rem; margin: 28px 0 10px; display: flex; gap: 10px; align-items: baseline; }
.overview h2 .muted { color: var(--muted); font-size: .9rem; font-weight: 500; }
.progress { display: flex; align-items: center; gap: 12px; margin: 0 0 16px; font-weight: 700; color: var(--hi); }
.progress .bar { flex: 1; height: 12px; border-radius: 999px; background: var(--line); overflow: hidden; }
.progress .bar div { height: 100%; background: var(--hi); border-radius: 999px; transition: width .6s ease; }

.level-path .task-card.done .num { background: var(--ok-bg); color: var(--ok); }
.level-path .task-card.next { border-color: var(--accent); box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 35%, transparent); }
.level-path .task-card.next .num { background: var(--accent); color: var(--accent-ink); }
.level-path .task-card .title { display: flex; flex-direction: column; gap: 2px; }
.level-path .tag { align-self: flex-start; font-size: .75rem; font-weight: 700; color: var(--accent-ink);
                   background: var(--accent); border-radius: 999px; padding: 1px 8px; }

.badge-shelf { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px;
               grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.badge { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: var(--radius);
         background: var(--panel); border: 1px solid var(--line); opacity: .45; filter: grayscale(1); }
.badge.earned { opacity: 1; filter: none; }
.badge-icon { flex: none; width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center;
              font-weight: 800; font-size: 1.1rem; color: #1d2433; background: var(--hi);
              box-shadow: inset 0 0 0 3px color-mix(in srgb, #fff 45%, transparent); }
.badge-text { display: flex; flex-direction: column; }
.badge-text small { color: var(--muted); }

.next-task { display: inline-flex; align-items: center; gap: 6px; margin-top: 10px; padding: 10px 14px;
             border-radius: 10px; background: var(--ok); color: var(--panel); font-weight: 700; text-decoration: none; }

.stars.pop { animation: pop .6s cubic-bezier(.2, 1.6, .4, 1); transform-origin: left center; }
@keyframes pop { 0% { transform: scale(.3); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }

/* Signal „fließt“: Strichmuster wandert von der Quelle zum Ziel */
.canvas.flowing .wire.hi { stroke-dasharray: 14 8; animation: flow .5s linear infinite; }
.canvas.flowing .terminal.output.hi .lamp { animation: glow .55s ease-in-out infinite alternate; }
@keyframes flow { to { stroke-dashoffset: -22; } }
@keyframes glow { to { filter: drop-shadow(0 0 18px var(--hi)); } }

.toast { position: fixed; left: 50%; transform: translateX(-50%); z-index: 50; display: flex; gap: 12px;
         align-items: center; padding: 10px 16px 10px 10px; border-radius: 999px; background: var(--panel);
         border: 1px solid var(--line); box-shadow: 0 8px 30px rgba(0, 0, 0, .25);
         animation: toast-in .4s ease; transition: opacity .5s, transform .5s; }
.toast small { display: block; color: var(--muted); font-size: .75rem; }
.toast.leave { opacity: 0; transform: translateX(-50%) translateY(20px); }
@keyframes toast-in { from { opacity: 0; transform: translateX(-50%) translateY(20px); } }

.confetti { position: fixed; inset: 0; width: 100vw; height: 100vh; pointer-events: none; z-index: 40; }

@media (prefers-reduced-motion: reduce) {
  .stars.pop, .toast, .canvas.flowing .wire.hi, .canvas.flowing .terminal.output.hi .lamp { animation: none; }
}

/* ================================================================ BinLab */

.task-card .typ { font-size: .8rem; font-weight: 600; color: var(--muted); border: 1px solid var(--line);
                  border-radius: 999px; padding: 2px 10px; white-space: nowrap; }

/* Training: Kacheln für Zufallsaufgaben */
.training-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px;
                 grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }
.training-card { display: flex; flex-direction: column; gap: 2px; padding: 12px 14px; min-height: 56px;
                 justify-content: center; border-radius: var(--radius); background: var(--panel);
                 border: 1px solid var(--line); color: var(--ink); text-decoration: none; }
.training-card:hover { border-color: var(--accent); }
.training-card small { color: var(--hi); font-weight: 600; }

.workbench.uebung { grid-template-columns: minmax(0, 1fr) 320px; }
@media (max-width: 1100px) { .workbench.uebung { grid-template-columns: minmax(0, 1fr); } }

.tafel-wrap { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.auftrag { margin: 0; padding: 16px 16px 4px; font-size: 1.15rem; display: flex; flex-wrap: wrap;
           align-items: baseline; gap: 10px; }
.zahl { font-family: ui-monospace, Menlo, monospace; font-weight: 800; font-size: 1.6rem; white-space: nowrap; }
.zahl sub, .dez-eingabe sub { font-size: .55em; color: var(--muted); font-weight: 600; }
.pfeil { color: var(--muted); font-size: 1.4rem; }

/* Stellenwert-Tafel: Beschriftung | n Spalten | Dezimalwert */
.tafel-scroll { overflow-x: auto; padding: 12px 16px 16px; }
.tafel { display: grid; grid-template-columns: max-content repeat(var(--n), minmax(30px, 58px)) minmax(4.5em, max-content);
         gap: 8px 5px; align-items: center; justify-content: center; min-width: max-content; }
.t-label { text-align: right; padding-right: 8px; color: var(--muted); font-size: .85rem; font-weight: 600; }
.t-label .op { font-size: 2.2rem; line-height: 1; color: var(--ink); font-weight: 800; }
.t-wert { padding-left: 8px; font-weight: 700; color: var(--accent); white-space: nowrap; font-variant-numeric: tabular-nums; }
.g-ende { margin-right: 10px; }  /* Lücke zwischen Bitgruppen (Hex: 4, Oktal: 3) */

.stw { display: flex; flex-direction: column; align-items: center; line-height: 1.1;
       font-variant-numeric: tabular-nums; color: var(--muted); font-weight: 700; font-size: .9rem; }
.stw small { font-weight: 500; font-size: .75rem; opacity: .8; }

.bit { height: 58px; border-radius: 10px; border: 2px solid var(--lo); background: var(--panel); color: var(--lo);
       font: 800 1.5rem ui-monospace, Menlo, monospace; display: grid; place-items: center; padding: 0;
       touch-action: manipulation; user-select: none; -webkit-user-select: none; }
button.bit { cursor: pointer; }
button.bit:hover:not(:disabled) { border-color: var(--hi); }
.bit.on { background: var(--hi); border-color: var(--hi); color: #1d2433; box-shadow: 0 0 10px var(--hi-glow); }
.bit.fest { border-style: dashed; height: 46px; font-size: 1.25rem; }
.bit.fest.on { border-style: solid; }
.bit.leer { border: 0; background: none; }

.ziffer { height: 58px; width: 100%; min-width: 0; border-radius: 10px; text-align: center;
          font: 800 1.6rem ui-monospace, Menlo, monospace; text-transform: uppercase; }
input.ziffer { border: 2px solid var(--accent); background: var(--panel); color: var(--ink); }
input.ziffer:focus { outline: 3px solid color-mix(in srgb, var(--accent) 40%, transparent); }
.ziffer.fest { display: grid; place-items: center; background: var(--bg); border: 2px dashed var(--line); }

.notiz { height: 30px; border-radius: 8px; border: 1px dashed var(--line); background: none; cursor: pointer;
         color: var(--accent); font: 700 1rem ui-monospace, Menlo, monospace; padding: 0; }
.notiz.on { border-color: var(--accent); border-style: solid; }
.strich { grid-column: 2 / span var(--n); border-top: 3px solid var(--ink); }

.tafel.geloest button.bit.on, .tafel.geloest input.ziffer { border-color: var(--ok); }
.tafel.geloest input.ziffer { background: var(--ok-bg); color: var(--ok); opacity: 1; }
.tafel button.bit:disabled { cursor: default; }

.dez-eingabe { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; padding: 0 16px 16px;
               justify-content: center; font-weight: 600; color: var(--muted); }
.dez-eingabe span { display: inline-flex; align-items: baseline; gap: 4px; }
.dez-eingabe input { width: 9ch; height: 58px; border-radius: 10px; border: 2px solid var(--accent); text-align: center;
                     font: 800 1.6rem ui-monospace, Menlo, monospace; background: var(--panel); color: var(--ink); }

.toolbar button.aktiv { border-color: var(--accent); color: var(--accent); font-weight: 700; }
.toolbar button.primary:disabled { opacity: .45; }

.methode { background: var(--bg); border-radius: 10px; padding: 10px 12px; }
.methode p { margin: 6px 0 0; font-size: .92rem; }
.serie { font-weight: 700; margin-top: 4px; }
.serie-info { margin: 0; color: var(--hi); font-weight: 700; }
button.next-task { font: inherit; cursor: pointer; }

/* Teilprodukte beim Multiplizieren */
.bit.teil { height: 40px; font-size: 1.1rem; border-style: dashed; }
.bit.teil.on { border-style: solid; }
.bit.teil.ok { border-color: var(--ok); border-style: solid; }
.bit.teil.ok:not(.on) { color: var(--ok); }
.teil-label { font-family: ui-monospace, Menlo, monospace; font-size: .85rem; white-space: nowrap; }
.teil-label sub { font-size: .7em; }
.teil-ok { color: var(--ok); font-size: 1.3rem; }
.strich.duenn { border-top: 1px dashed var(--line); }
.t-label .op.mal { font-size: 3.4rem; line-height: .5; }  /* der Malpunkt ist in jeder Schrift winzig */

/* Divisionsmethode: n : 2 = q Rest r, Zeile für Zeile */
.division { margin: 8px 16px 0; padding: 12px 14px; border-radius: 10px; background: var(--bg); }
.div-titel { font-size: .8rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .05em;
             margin-bottom: 8px; }
.div-grid { display: grid; grid-template-columns: max-content max-content 6ch max-content max-content 2em;
            gap: 8px 10px; align-items: center; justify-content: start; }
.div-n { grid-column: 1; text-align: right; font: 800 1.3rem ui-monospace, Menlo, monospace; font-variant-numeric: tabular-nums; }
.div-op { color: var(--muted); font-weight: 600; }
.div-grid input { width: 6ch; height: 44px; border-radius: 8px; border: 2px solid var(--accent); text-align: center;
                  font: 800 1.2rem ui-monospace, Menlo, monospace; background: var(--panel); color: var(--ink); }
.div-grid input.div-r { width: 4ch; }
.div-grid input.ok { border-color: var(--ok); background: var(--ok-bg); color: var(--ok); opacity: 1; }
.div-grid input.falsch { border-color: var(--bad); background: var(--bad-bg); }
.div-rest { display: inline-flex; align-items: center; gap: 6px; }
.div-hex { color: var(--ok); font-weight: 700; white-space: nowrap; }
.div-pfeil { grid-column: 6; align-self: stretch; display: grid; place-items: center; font-size: 1.8rem; font-weight: 800;
             color: var(--accent); border-left: 3px solid var(--accent); border-radius: 0 0 0 4px; }
.div-fertig { margin: 10px 0 0; font-size: .92rem; }

@media (max-width: 500px) {
  /* Handy: Zeilenbeschriftung nur als Rechenzeichen, Dezimalwert-Spalte nur bei Bedarf */
  .tafel-scroll { padding: 10px 8px 12px; }
  .tafel { grid-template-columns: max-content repeat(var(--n), minmax(0, 44px)) max-content; gap: 6px 3px;
           min-width: calc(var(--n) * 27px + 30px); }
  .bit, .ziffer, .dez-eingabe input { height: 46px; font-size: 1.15rem; }
  .bit.fest { height: 40px; }
  .t-label { font-size: 0; padding-right: 2px; }
  .t-label .op { font-size: 1.4rem; }
  .t-label .teil-label { font-size: .65rem; }
  .t-wert { padding-left: 4px; font-size: .85rem; }
  .stw { font-size: .75rem; }
  .stw small { font-size: .62rem; }
  .g-ende { margin-right: 5px; }
  .tafel-wrap .toolbar button { padding: 0 10px; }
}
.toolbar button[hidden] { display: none; }
