:root {
  --bg: #f7f8fb;
  --surface: #ffffff;
  --surface-strong: #eef2f7;
  --text: #172033;
  --muted: #5c667a;
  --border: #d8dee9;
  --wire: #96a0b5;
  --electron: #16a36f;
  --electron-soft: #dff7ed;
  --lamp: #f7b731;
  --lamp-soft: #fff1bf;
  --accent: #3867d6;
  --accent-hover: #274fb0;
  --accent-soft: #eef3ff;
  --danger: #d64545;
  --danger-soft: #fdecec;
  --success: #08724b;
  --soft: #fbfcff;
  --shadow: 0 12px 30px rgba(23, 32, 51, 0.08);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f141c;
    --surface: #1a2230;
    --surface-strong: #263041;
    --text: #e7ecf5;
    --muted: #9aa6bd;
    --border: #313d52;
    --wire: #66738e;
    --electron: #2bbd88;
    --electron-soft: #10362a;
    --lamp: #f7b731;
    --lamp-soft: #3b3117;
    --accent: #6d93ff;
    --accent-hover: #8aa8ff;
    --accent-soft: #1d2b47;
    --danger: #e06a6a;
    --danger-soft: #3a2222;
    --success: #63dca6;
    --soft: #1e2735;
    --shadow: 0 12px 30px rgba(0, 0, 0, 0.45);
    color-scheme: dark;
  }
}

* {
  box-sizing: border-box;
}

/* ---------- ავტორიზაცია ---------- */
.login-screen {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 24px;
  background: var(--bg);
}

body[data-authed] .login-screen {
  display: none;
}

body:not([data-authed]) .top-bar,
body:not([data-authed]) .app-shell {
  display: none;
}

.login-card {
  width: min(420px, 100%);
  display: grid;
  gap: 12px;
  padding: 28px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.login-card h1 {
  margin: 0;
  font-size: clamp(1.4rem, 3vw, 2rem);
}

.login-sub {
  margin: 0 0 4px;
  color: var(--muted);
  font-weight: 700;
}

.login-users {
  display: grid;
  gap: 8px;
}

.login-user {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  text-align: left;
}

.login-user:hover,
.login-user:focus-visible {
  border-color: var(--accent);
}

.login-user.is-selected {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.login-user-name {
  font-weight: 900;
}

.login-user-role {
  color: var(--muted);
  font-weight: 700;
  font-size: 0.85rem;
}

.login-field {
  display: grid;
  gap: 6px;
}

.login-field span {
  color: var(--muted);
  font-weight: 800;
  font-size: 0.85rem;
}

.login-password {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
}

.login-password:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.login-error {
  margin: 0;
  min-height: 1.2em;
  color: var(--danger);
  font-weight: 700;
}

.login-submit {
  width: 100%;
}

.login-note {
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.5;
}

.top-bar-right {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

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

.user-badge {
  display: grid;
  line-height: 1.2;
}

.user-badge-name {
  font-weight: 900;
}

.user-badge-role {
  color: var(--muted);
  font-weight: 700;
  font-size: 0.8rem;
}

.top-bar-user .secondary-button {
  min-height: 36px;
  padding: 6px 12px;
  font-size: 0.85rem;
}

.dash-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(0, 0, 0, 0.5);
}

.dash-panel {
  width: min(480px, 100%);
  display: grid;
  gap: 14px;
  padding: 24px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.dash-panel h2 {
  margin: 0;
}

.dash-row {
  display: grid;
  gap: 8px 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.dash-row:last-of-type { border-bottom: none; }

.dash-name {
  font-weight: 800;
  font-size: 1.02rem;
}

.dash-metric {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
}
.dash-metric-label {
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 700;
}

.dash-track {
  height: 10px;
  border-radius: 999px;
  background: var(--surface-strong);
  overflow: hidden;
}

.dash-fill {
  height: 100%;
  border-radius: 999px;
  background: var(--electron);
  transition: width 260ms ease;
}

.dash-count {
  color: var(--muted);
  font-weight: 800;
  font-size: 0.9rem;
  white-space: nowrap;
}

html {
  min-height: 100%;
}

body {
  min-height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family:
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 22px clamp(16px, 4vw, 44px);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.course-name {
  margin: 0 0 4px;
  color: var(--accent);
  font-weight: 700;
}

h1 {
  margin: 0;
  font-size: clamp(1.45rem, 2.5vw, 2.4rem);
  letter-spacing: 0;
}

.lesson-counter {
  margin: 0;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--muted);
  font-weight: 700;
  white-space: nowrap;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(220px, 280px) minmax(0, 1fr);
  gap: 24px;
  width: min(1240px, 100%);
  margin: 0 auto;
  padding: 24px clamp(14px, 3vw, 34px) 40px;
}

.lesson-sidebar {
  align-self: start;
  position: sticky;
  top: 18px;
}

.lesson-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.lesson-tab {
  width: 100%;
  display: grid;
  grid-template-columns: 34px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  text-align: left;
  box-shadow: none;
}

.lesson-tab:hover,
.lesson-tab:focus-visible {
  border-color: var(--accent);
}

.lesson-tab.is-active {
  background: var(--accent-soft);
  border-color: var(--accent);
}

.lesson-tab-number {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: var(--surface-strong);
  color: var(--muted);
  font-weight: 800;
}

.lesson-tab.is-active .lesson-tab-number {
  background: var(--accent);
  color: #fff;
}

.lesson-tab-title {
  font-weight: 700;
  line-height: 1.25;
}

.lesson-tab.is-complete .lesson-tab-number {
  background: var(--electron);
  color: #fff;
}

.lesson-tab.is-active.is-complete .lesson-tab-number {
  background: var(--accent);
}

.lesson-tab-check {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--electron-soft);
  color: var(--success);
  font-weight: 900;
  font-size: 0.85rem;
}

.progress-summary {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
}

.progress-track {
  height: 8px;
  border-radius: 999px;
  background: var(--surface-strong);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: var(--electron);
  transition: width 260ms ease;
}

.progress-caption {
  margin: 0;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
}

.progress-reset {
  justify-self: start;
  padding: 4px 9px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 700;
}

.progress-reset:hover,
.progress-reset:focus-visible {
  border-color: var(--danger);
  color: var(--danger);
}

.lesson-root {
  min-width: 0;
}

.lesson-panel {
  display: grid;
  gap: 18px;
}

.lesson-heading {
  padding: 24px;
  border-radius: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.lesson-kicker {
  margin: 0 0 8px;
  color: var(--muted);
  font-weight: 700;
}

.lesson-heading h2 {
  margin: 0;
  font-size: clamp(1.6rem, 3vw, 2.35rem);
  letter-spacing: 0;
}

.section-band {
  padding: 22px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}

.section-band h3 {
  margin: 0 0 14px;
  font-size: 1.08rem;
  letter-spacing: 0;
}

.explanation-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.info-box {
  min-height: 150px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--soft);
}

.info-box strong {
  display: block;
  margin-bottom: 8px;
  color: var(--accent);
}

.info-box p {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.simulation-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(220px, 0.85fr);
  gap: 18px;
  align-items: stretch;
}

.sim-card,
.challenge-box {
  min-width: 0;
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--soft);
}

.sim-card {
  display: grid;
  gap: 16px;
  align-content: start;
}

.challenge-box {
  display: grid;
  gap: 12px;
  align-content: start;
}

.challenge-prompt {
  margin: 0;
  color: var(--text);
  line-height: 1.55;
}

.challenge-status {
  margin: 0;
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--surface-strong);
  color: var(--muted);
  font-weight: 700;
}

.challenge-status.is-done {
  background: var(--electron-soft);
  color: var(--success);
}

.primary-button,
.secondary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 9px 14px;
  border-radius: 8px;
  border: 1px solid transparent;
  font-weight: 800;
}

.primary-button {
  background: var(--accent);
  color: #fff;
}

.primary-button:hover,
.primary-button:focus-visible {
  background: var(--accent-hover);
}

.primary-button:disabled,
.secondary-button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.secondary-button {
  background: var(--surface);
  border-color: var(--border);
  color: var(--text);
}

.secondary-button:hover,
.secondary-button:focus-visible {
  border-color: var(--accent);
}

.lesson-actions {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.lesson-actions button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.control-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
}

.state-note {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.breakdown-panel {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}

.breakdown-panel h4 {
  margin: 0;
  font-size: 1rem;
  letter-spacing: 0;
}

.breakdown-note,
.formula-line {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.formula-line {
  padding: 10px 12px;
  border-left: 4px solid var(--accent);
  background: var(--accent-soft);
  font-weight: 800;
}

.signal-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.signal-chip {
  display: inline-grid;
  grid-template-columns: auto 34px;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  padding: 6px 8px 6px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--soft);
}

.signal-label {
  color: var(--muted);
  font-weight: 800;
}

.signal-value {
  display: grid;
  place-items: center;
  min-width: 30px;
  height: 28px;
  border-radius: 8px;
  background: var(--surface-strong);
  font-weight: 900;
}

.signal-chip.is-one .signal-value {
  background: var(--electron-soft);
  color: var(--success);
}

.signal-chip.is-zero .signal-value {
  background: var(--surface-strong);
  color: var(--muted);
}

.breakdown-flow {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
}

.breakdown-step {
  display: grid;
  gap: 8px;
  align-content: start;
  min-height: 138px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--soft);
  transition:
    background 160ms ease,
    border-color 160ms ease,
    box-shadow 160ms ease;
}

.breakdown-step strong {
  color: var(--text);
}

.breakdown-step p {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.breakdown-step.is-active {
  border-color: var(--electron);
  background: var(--electron-soft);
  box-shadow: inset 0 0 0 1px rgba(22, 163, 111, 0.14);
}

.breakdown-step.is-active p {
  color: var(--success);
}

.step-value {
  align-self: end;
  display: inline-flex;
  width: fit-content;
  min-height: 30px;
  align-items: center;
  padding: 5px 8px;
  border-radius: 8px;
  background: var(--surface-strong);
  color: var(--muted);
  font-weight: 900;
}

.binary-lab {
  display: grid;
  gap: 16px;
}

.bin-analogy {
  display: grid;
  gap: 8px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-strong);
}

.bin-analogy .breakdown-note {
  color: var(--text);
}

.bin-places {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(148px, 1fr));
  gap: 12px;
}

.bin-place {
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  transition:
    border-color 160ms ease,
    background 160ms ease;
}

.bin-place.is-on {
  border-color: var(--electron);
  background: var(--electron-soft);
}

.bin-place .switch-control {
  min-width: 0;
}

.bin-place .switch-label {
  display: none;
}

.bin-power-head {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.bin-power {
  font-size: 1.55rem;
  font-weight: 900;
  color: var(--accent);
  line-height: 1;
}

.bin-place.is-on .bin-power {
  color: var(--electron);
}

.bin-power-eq {
  color: var(--muted);
  font-weight: 800;
}

.bin-contrib {
  margin: 0;
  padding-top: 8px;
  border-top: 1px dashed var(--border);
  color: var(--muted);
  font-weight: 800;
}

.bin-contrib.is-on {
  color: var(--success);
}

.bin-summary {
  display: grid;
  gap: 12px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}

.bin-summary-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.bin-summary-label {
  color: var(--muted);
  font-weight: 800;
}

.bin-word,
.bin-decimal {
  font-size: 1.9rem;
  font-weight: 900;
  letter-spacing: 0.12em;
  line-height: 1;
}

.bin-word {
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  color: var(--accent);
}

.bin-decimal {
  color: var(--success);
}

.switch-control {
  display: inline-grid;
  gap: 8px;
  min-width: 146px;
}

.switch-label {
  color: var(--muted);
  font-weight: 800;
}

.switch-button {
  display: grid;
  grid-template-columns: 46px 1fr;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
}

.switch-knob {
  width: 34px;
  height: 24px;
  border-radius: 14px;
  background: #a9b2c3;
  position: relative;
  transition:
    background 160ms ease,
    transform 160ms ease;
}

.switch-knob::after {
  content: "";
  position: absolute;
  width: 18px;
  height: 18px;
  top: 3px;
  left: 3px;
  border-radius: 50%;
  background: #fff;
  transition: transform 160ms ease;
  box-shadow: 0 1px 4px rgba(23, 32, 51, 0.22);
}

.switch-button[data-on="true"] .switch-knob {
  background: var(--electron);
}

.switch-button[data-on="true"] .switch-knob::after {
  transform: translateX(10px);
}

.switch-text {
  font-weight: 900;
}

.bit-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  min-height: 34px;
  border-radius: 8px;
  background: var(--surface-strong);
  font-weight: 900;
}

.wire-stack,
.horizontal-circuit {
  display: grid;
  gap: 14px;
  justify-items: center;
}

.part-label {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  min-width: 148px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  font-weight: 900;
}

/* კონვენციური სქემატური სიმბოლოები */
.symbol-svg {
  display: block;
}

.symbol-vdd,
.symbol-ground {
  width: 42px;
  height: 38px;
}

.symbol-battery {
  width: 62px;
  height: 38px;
}

.symbol-lamp {
  width: 44px;
  height: 44px;
}

.symbol-resistor {
  width: 38px;
  height: 74px;
}

.symbol-transistor {
  width: 58px;
  height: 76px;
}

.symbol-gate {
  width: 92px;
  height: 58px;
}

.schematic-part {
  display: grid;
  gap: 6px;
  justify-items: center;
  min-width: 128px;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  transition:
    border-color 160ms ease,
    background 160ms ease,
    color 160ms ease;
}

.schematic-part.is-conducting {
  border-color: var(--electron);
  background: var(--electron-soft);
  color: var(--success);
}

.part-word {
  font-weight: 800;
}

.part-code {
  color: var(--muted);
  font-weight: 800;
  font-size: 0.82rem;
  letter-spacing: 0.03em;
}

.schematic-part.is-conducting .part-code {
  color: var(--success);
}

.gate-symbol {
  display: grid;
  justify-items: center;
  gap: 6px;
  color: var(--accent);
}

.gate-symbol-label {
  color: var(--accent);
  font-weight: 900;
  letter-spacing: 0.04em;
}

.adder-core {
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 6px;
  min-height: 82px;
  padding: 12px 14px;
  border: 2px solid var(--accent);
  border-radius: 8px;
  background: var(--surface);
  color: var(--accent);
}

.adder-core-symbol {
  font-size: 1.9rem;
  font-weight: 900;
  line-height: 1;
}

.adder-core-label {
  font-weight: 800;
  font-size: 0.85rem;
  text-align: center;
}

/* ჰორიზონტალური ტრანზისტორული წრედი — ერთი SVG, 100% სიგანეზე */
.circuit-svg {
  display: block;
  width: 100%;
  max-width: 460px;
  height: auto;
  margin: 6px auto 10px;
}

.circuit-svg .wire {
  fill: none;
  stroke: var(--wire);
  stroke-width: 2.5;
  transition: stroke 180ms ease;
}

.circuit-svg .wire.on {
  stroke: var(--electron);
}

/* აქტიური მავთულების მოძრავი ნაკადი (ყველა SVG სქემაში) */
@keyframes wire-flow {
  to {
    stroke-dashoffset: -13;
  }
}

.circuit-svg .wire.on,
.schematic-diagram .wire.on,
.datapath .wire.on {
  stroke-dasharray: 7 6;
  animation: wire-flow 0.5s linear infinite;
}

.circuit-svg .sw.on .contact,
.schematic-diagram .gate.on,
.circuit-svg .cell.on,
.datapath .node.on {
  filter: drop-shadow(0 0 3px rgba(43, 189, 136, 0.55));
}

.circuit-svg .part {
  fill: none;
  stroke: var(--text);
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.circuit-svg .contact {
  fill: var(--wire);
  transition: fill 180ms ease;
}

.circuit-svg .contact.on {
  fill: var(--electron);
}

.circuit-svg .sw .lever {
  stroke: var(--muted);
  stroke-width: 3.5;
  stroke-linecap: round;
  transition: stroke 180ms ease;
}

.circuit-svg .sw .gate {
  stroke: var(--border);
  stroke-width: 2;
}

.circuit-svg .sw .lever-closed {
  opacity: 0;
}

.circuit-svg .sw.on .lever-open {
  opacity: 0;
}

.circuit-svg .sw.on .lever-closed {
  opacity: 1;
}

.circuit-svg .sw.on .lever {
  stroke: var(--electron);
}

.circuit-svg .sw.on .contact {
  fill: var(--electron);
}

.circuit-svg .lbl {
  fill: var(--text);
  font-size: 12px;
  font-weight: 800;
}

.circuit-svg .lbl-sm {
  fill: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.circuit-svg .val {
  fill: var(--text);
  font-size: 17px;
  font-weight: 900;
}

.circuit-svg .val.on {
  fill: var(--success);
}

.schematic-diagram {
  display: block;
  width: 100%;
  max-width: 460px;
  height: auto;
  margin: 4px auto 0;
}

.schematic-diagram .wire {
  fill: none;
  stroke: var(--wire);
  stroke-width: 2.5;
  transition: stroke 160ms ease;
}

.schematic-diagram .wire.on {
  stroke: var(--electron);
}

.schematic-diagram .gate {
  fill: var(--surface);
  stroke: var(--text);
  stroke-width: 2.5;
  stroke-linejoin: round;
  transition: stroke 160ms ease;
}

.schematic-diagram .gate.on {
  stroke: var(--electron);
}

.schematic-diagram .dot {
  fill: var(--wire);
  transition: fill 160ms ease;
}

.schematic-diagram .dot.on {
  fill: var(--electron);
}

.schematic-diagram .lbl {
  fill: var(--text);
  font-size: 13px;
  font-weight: 800;
}

.schematic-diagram .lbl-sm {
  fill: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.datapath {
  display: block;
  width: 100%;
  max-width: 420px;
  height: auto;
  margin: 0 auto;
}

.datapath .node {
  fill: var(--surface);
  stroke: var(--border);
  stroke-width: 2;
  transition:
    fill 200ms ease,
    stroke 200ms ease;
}

.datapath .node.on {
  fill: var(--electron-soft);
  stroke: var(--electron);
}

.datapath .wire {
  fill: none;
  stroke: var(--wire);
  stroke-width: 2.5;
  transition: stroke 200ms ease;
}

.datapath .wire.on {
  stroke: var(--electron);
}

.datapath .wire-arrow {
  fill: var(--wire);
  stroke: none;
  transition: fill 200ms ease;
}

.datapath .wire-arrow.on {
  fill: var(--electron);
}

/* კომპონენტის ყუთი (მაგ. მეხსიერების უჯრედი logic-row-ში) */
.unit-chip {
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 2px;
  min-height: 74px;
  padding: 12px 16px;
  border: 2px solid var(--accent);
  border-radius: 8px;
  background: var(--surface);
  color: var(--accent);
  text-align: center;
}

.unit-chip-title {
  font-weight: 900;
}

.unit-chip-sub {
  font-size: 0.82rem;
  font-weight: 700;
}

.datapath .node-label {
  fill: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.datapath .node-val {
  fill: var(--text);
  font-size: 22px;
  font-weight: 900;
}

.datapath .node.on .node-val {
  fill: var(--success);
}

.part-legend {
  display: grid;
  gap: 10px;
  margin-bottom: 6px;
}

.part-legend-item {
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--soft);
}

.part-legend-item strong {
  display: block;
  margin-bottom: 4px;
  color: var(--accent);
}

.part-legend-item p {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.diff-list {
  margin: 4px 0 10px;
  padding-left: 20px;
  color: var(--muted);
  line-height: 1.6;
}

.diff-list li {
  margin-bottom: 4px;
}

/* ALU */
.alu-controls {
  display: grid;
  gap: 16px;
}

.alu-inputs {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
}

.stepper {
  display: inline-grid;
  gap: 8px;
}

.stepper-row {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.stepper-btn {
  width: 42px;
  height: 42px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font-weight: 900;
  font-size: 1.3rem;
  line-height: 1;
}

.stepper-btn:hover,
.stepper-btn:focus-visible {
  border-color: var(--accent);
}

.stepper-value {
  display: grid;
  place-items: center;
  min-width: 52px;
  height: 42px;
  border-radius: 8px;
  background: var(--surface-strong);
  font-weight: 900;
  font-size: 1.35rem;
}

.op-selector {
  display: grid;
  gap: 8px;
}

.op-button-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.op-button {
  min-width: 58px;
  min-height: 44px;
  padding: 8px 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font-weight: 900;
}

.op-button:hover,
.op-button:focus-visible {
  border-color: var(--accent);
}

.op-button.is-active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.alu-result {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--soft);
}

.alu-result-label,
.alu-result-bin-label {
  color: var(--muted);
  font-weight: 800;
}

.alu-result-decimal {
  font-size: 2rem;
  font-weight: 900;
  color: var(--success);
  line-height: 1;
}

.alu-result-binary {
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  font-size: 1.2rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  color: var(--accent);
}

.op-units {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(90px, 1fr));
  gap: 10px;
}

.op-unit {
  display: grid;
  justify-items: center;
  gap: 6px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  transition:
    border-color 160ms ease,
    background 160ms ease;
}

.op-unit.is-active {
  border-color: var(--electron);
  background: var(--electron-soft);
}

.op-unit-name {
  color: var(--muted);
  font-weight: 900;
}

.op-unit.is-active .op-unit-name {
  color: var(--success);
}

.op-unit-value {
  font-size: 1.4rem;
  font-weight: 900;
}

/* ქეშ მეხსიერების იერარქია */
.cache-hierarchy {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: stretch;
  margin-bottom: 14px;
}

.cache-level {
  flex: 1 1 130px;
  min-width: 120px;
  display: grid;
  gap: 3px;
  align-content: start;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  text-align: center;
  transition:
    border-color 180ms ease,
    background 180ms ease,
    box-shadow 180ms ease;
}

.cache-cpu {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
}

.cache-level.searching {
  border-color: var(--lamp);
  background: var(--lamp-soft);
}

.cache-level.miss {
  border-color: var(--danger);
  background: var(--danger-soft);
}

.cache-level.hit {
  border-color: var(--electron);
  background: var(--electron-soft);
}

.cache-level.has-data {
  box-shadow: inset 0 0 0 2px rgba(22, 163, 111, 0.28);
}

.cache-level-name {
  font-weight: 900;
}

.cache-level-meta {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 700;
}

.cache-badge {
  display: none;
  margin-top: 4px;
  padding: 3px 6px;
  border-radius: 6px;
  background: var(--electron-soft);
  color: var(--success);
  font-size: 0.72rem;
  font-weight: 800;
}

.cache-badge.show {
  display: inline-block;
}

/* მეხსიერების უჯრედი (SVG) */
.circuit-svg .cell {
  fill: var(--surface);
  stroke: var(--text);
  stroke-width: 2.5;
  transition:
    fill 180ms ease,
    stroke 180ms ease;
}

.circuit-svg .cell.on {
  fill: var(--electron-soft);
  stroke: var(--electron);
}

.circuit-svg .cell-label {
  fill: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

/* პროგრამა და საათი */
.program-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr);
  gap: 16px;
}

.program-code h4,
.program-state h4 {
  margin: 0 0 10px;
  font-size: 1rem;
}

.instr-list {
  display: grid;
  gap: 8px;
}

.instr-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  font-weight: 800;
  transition:
    border-color 160ms ease,
    background 160ms ease;
}

.instr-row.is-current {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.instr-row.is-current::after {
  content: "◀ PC";
  margin-left: auto;
  color: var(--accent);
  font-size: 0.75rem;
  font-weight: 900;
  letter-spacing: 0.04em;
}

.instr-row.is-done {
  opacity: 0.6;
}

.instr-num {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 6px;
  background: var(--surface-strong);
  color: var(--muted);
  font-size: 0.85rem;
}

.instr-row.is-current .instr-num {
  background: var(--accent);
  color: #fff;
}

.phase-badges {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.phase-arrow {
  color: var(--muted);
  font-weight: 900;
}

.phase-badge {
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-weight: 800;
}

.phase-badge.is-active {
  border-color: var(--electron);
  background: var(--electron-soft);
  color: var(--success);
}

.reg-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.reg-box {
  display: grid;
  justify-items: center;
  gap: 4px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  transition:
    border-color 160ms ease,
    background 160ms ease;
}

.reg-box.is-filled {
  border-color: var(--electron);
  background: var(--electron-soft);
}

.reg-label {
  color: var(--muted);
  font-weight: 800;
  font-size: 0.82rem;
  text-align: center;
}

.reg-value {
  font-size: 1.6rem;
  font-weight: 900;
}

/* რეკაპის ფენები */
.recap-stack {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
}

.recap-layer {
  display: grid;
  grid-template-columns: 34px 1fr auto;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  text-align: left;
  transition:
    border-color 160ms ease,
    background 160ms ease,
    transform 160ms ease;
}

.recap-layer:hover,
.recap-layer:focus-visible {
  border-color: var(--accent);
  background: var(--accent-soft);
  transform: translateX(3px);
}

.recap-layer::before {
  content: "";
  grid-column: 1;
  grid-row: 1;
  align-self: stretch;
  justify-self: start;
  width: 3px;
  margin-left: -14px;
  border-radius: 3px;
  background: var(--accent);
  opacity: 0.35;
}

.recap-layer:hover::before,
.recap-layer:focus-visible::before {
  opacity: 1;
}

.recap-layer-num {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: var(--surface-strong);
  color: var(--accent);
  font-weight: 900;
}

.recap-layer-body {
  display: grid;
  gap: 2px;
}

.recap-layer-title {
  font-weight: 900;
}

.recap-layer-desc {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 600;
}

.recap-layer-arrow {
  color: var(--muted);
  font-weight: 900;
}

@media (max-width: 640px) {
  .program-layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .inverter-layout {
    grid-template-columns: 1fr;
  }
}

.electron-track {
  position: relative;
  width: min(390px, 100%);
  height: 34px;
}

.electron-track.vertical {
  width: 34px;
  height: 126px;
}

.wire-line {
  position: absolute;
  background: var(--wire);
  border-radius: 8px;
}

.electron-track:not(.vertical) .wire-line {
  left: 0;
  right: 0;
  top: 14px;
  height: 6px;
}

.electron-track.vertical .wire-line {
  top: 0;
  bottom: 0;
  left: 14px;
  width: 6px;
}

.electron {
  position: absolute;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--electron);
  opacity: 0;
  box-shadow: 0 0 0 5px rgba(22, 163, 111, 0.14);
}

.electron-track:not(.vertical) .electron {
  top: 11px;
  left: 0;
}

.electron-track.vertical .electron {
  top: 0;
  left: 11px;
}

.electron-track.is-flowing .electron {
  opacity: 1;
}

.electron-track:not(.vertical).is-flowing .electron {
  animation: electron-horizontal 1.25s linear infinite;
}

.electron-track.vertical.is-flowing .electron {
  animation: electron-vertical 1.25s linear infinite;
}

.electron:nth-child(3) {
  animation-delay: 0.25s;
}

.electron:nth-child(4) {
  animation-delay: 0.5s;
}

.electron:nth-child(5) {
  animation-delay: 0.75s;
}

@keyframes electron-horizontal {
  from {
    left: 0;
  }
  to {
    left: calc(100% - 11px);
  }
}

@keyframes electron-vertical {
  from {
    top: 0;
  }
  to {
    top: calc(100% - 11px);
  }
}

.lamp-widget {
  display: inline-grid;
  justify-items: center;
  gap: 8px;
  min-width: 110px;
}

.lamp-bulb {
  display: grid;
  place-items: center;
  width: 70px;
  height: 70px;
  border: 2px solid var(--border);
  border-radius: 50%;
  background: var(--surface-strong);
  color: var(--muted);
  font-size: 2rem;
  transition:
    background 180ms ease,
    border-color 180ms ease,
    box-shadow 180ms ease,
    color 180ms ease;
}

.lamp-bulb.is-on {
  background: var(--lamp-soft);
  border-color: var(--lamp);
  color: #9b6400;
  box-shadow: 0 0 26px rgba(247, 183, 49, 0.7);
}

.lamp-caption {
  color: var(--muted);
  font-weight: 800;
}

.logic-row {
  display: grid;
  grid-template-columns: minmax(130px, 0.8fr) minmax(170px, 1fr) minmax(120px, 0.8fr);
  gap: 12px;
  align-items: center;
}

.logic-inputs {
  display: grid;
  gap: 12px;
}

.logic-output {
  display: grid;
  justify-items: center;
  gap: 8px;
}

.output-digit {
  display: grid;
  place-items: center;
  width: 72px;
  height: 72px;
  border: 2px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  font-size: 2.6rem;
  font-weight: 900;
}

.output-digit.is-one {
  border-color: var(--electron);
  background: var(--electron-soft);
  color: var(--success);
}

.truth-table {
  width: 100%;
  border-collapse: collapse;
  overflow: hidden;
  border-radius: 8px;
  border: 1px solid var(--border);
}

.truth-table th,
.truth-table td {
  padding: 10px;
  border-bottom: 1px solid var(--border);
  text-align: center;
}

.truth-table th {
  background: var(--surface-strong);
  color: var(--muted);
}

.truth-table tr:last-child td {
  border-bottom: 0;
}

.truth-table tr.is-active td {
  background: var(--electron-soft);
  color: var(--success);
  font-weight: 900;
}

.cpu-log {
  min-height: 44px;
  margin: 0;
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--surface-strong);
  color: var(--muted);
  line-height: 1.45;
}

@media (max-width: 900px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .lesson-sidebar {
    position: static;
  }

  .lesson-list {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 4px;
  }

  .lesson-list li {
    flex: 0 0 210px;
  }

  .explanation-grid,
  .simulation-layout,
  .adder-grid {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }

  .electron-track.is-flowing .electron {
    opacity: 1;
  }

  .circuit-svg .wire,
  .schematic-diagram .wire,
  .datapath .wire {
    stroke-dasharray: none !important;
  }
}

@media (max-width: 640px) {
  .top-bar {
    align-items: flex-start;
    flex-direction: column;
  }

  .section-band,
  .lesson-heading,
  .sim-card,
  .challenge-box {
    padding: 16px;
  }

  .logic-row,
  .cpu-row,
  .cpu-registers {
    grid-template-columns: 1fr;
  }

  .cpu-arrow {
    min-height: 28px;
  }

  .lesson-actions {
    flex-direction: column;
  }
}

/* ==================== პლატფორმა: ნავიგაცია + ლეიაუთი ==================== */

.brand {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1px;
  padding: 4px 8px;
  border: none;
  background: transparent;
  line-height: 1.05;
  border-radius: 8px;
}
.brand:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.brand-mark {
  font-weight: 900;
  font-size: 1.15rem;
  letter-spacing: 0.5px;
  color: var(--accent);
}
.brand-sub {
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.top-nav {
  display: flex;
  gap: 6px;
  flex: 1;
  justify-content: center;
  flex-wrap: wrap;
}
.top-nav-item {
  padding: 9px 16px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-weight: 700;
  font-size: 0.95rem;
}
.top-nav-item:hover,
.top-nav-item:focus-visible {
  color: var(--text);
  background: var(--surface-strong);
}
.top-nav-item.is-active {
  color: #fff;
  background: var(--accent);
  border-color: var(--accent);
}
@media (prefers-color-scheme: dark) {
  .top-nav-item.is-active {
    color: #0f141c;
  }
}

body:not([data-authed]) .top-bar {
  display: none;
}

.app-main {
  width: min(1240px, 100%);
  margin: 0 auto;
  padding: 24px clamp(14px, 3vw, 34px) 48px;
}
body:not([data-authed]) .app-main {
  display: none;
}

/* --- ორ სვეტიანი ლეიაუთი (კურსი / დავალებები) --- */
.platform-layout {
  display: grid;
  grid-template-columns: minmax(240px, 300px) minmax(0, 1fr);
  gap: 26px;
  align-items: start;
}
.platform-content {
  min-width: 0;
}

.chapter-sidebar {
  align-self: start;
  position: sticky;
  top: 18px;
}
.chapter-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: none;
}
.chapter-item {
  display: block;
}
.chapter-head {
  width: 100%;
  display: grid;
  grid-template-columns: 30px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  text-align: left;
}
.chapter-head:hover,
.chapter-head:focus-visible {
  border-color: var(--accent);
}
.chapter-head.is-active {
  background: var(--accent-soft);
  border-color: var(--accent);
}
.chapter-head.is-locked {
  opacity: 0.72;
}
.chapter-num {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: var(--surface-strong);
  color: var(--muted);
  font-weight: 800;
}
.chapter-head.is-active .chapter-num {
  background: var(--accent);
  color: #fff;
}
.chapter-name {
  font-weight: 700;
  line-height: 1.2;
}
.chapter-lock {
  font-size: 0.68rem;
  font-weight: 800;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  background: var(--surface-strong);
  padding: 2px 7px;
  border-radius: 999px;
}

.lesson-sublist {
  list-style: none;
  margin: 6px 0 4px;
  padding: 0 0 0 8px;
  display: grid;
  gap: 4px;
  border-left: 2px solid var(--border);
  margin-left: 14px;
}
.lesson-subitem {
  width: 100%;
  display: grid;
  grid-template-columns: 24px 1fr auto;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  text-align: left;
  font-size: 0.9rem;
}
.lesson-subitem:hover,
.lesson-subitem:focus-visible {
  background: var(--surface-strong);
}
.lesson-subitem.is-active {
  background: var(--accent-soft);
  border-color: var(--accent);
  font-weight: 700;
}
.lesson-subnum {
  color: var(--muted);
  font-weight: 800;
  font-size: 0.8rem;
  text-align: center;
}
.lesson-subitem.is-active .lesson-subnum {
  color: var(--accent);
}
.lesson-subtitle {
  line-height: 1.2;
}
.lesson-subcheck {
  color: var(--success);
  font-weight: 900;
}
.lesson-subitem.is-done .lesson-subnum {
  color: var(--success);
}

/* --- placeholder / overview --- */
.chapter-placeholder .primary-button,
.chapter-overview .primary-button {
  margin-top: 12px;
}

/* ==================== მთავარი (Home) ==================== */
.home-view {
  display: grid;
  gap: 34px;
}
.home-hero {
  padding: clamp(24px, 5vw, 48px);
  border: 1px solid var(--border);
  border-radius: 18px;
  background: linear-gradient(135deg, var(--accent-soft), var(--surface));
}
.home-hero h1 {
  margin: 6px 0 12px;
  font-size: clamp(1.8rem, 4vw, 3rem);
}
.home-lead {
  margin: 0 0 22px;
  max-width: 60ch;
  color: var(--muted);
  font-size: 1.05rem;
  line-height: 1.6;
}
.home-cta {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}
.home-section h2 {
  margin: 0 0 16px;
}
.home-chapters {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 14px;
}
.home-chapter {
  display: grid;
  gap: 6px;
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  text-align: left;
}
.home-chapter:hover,
.home-chapter:focus-visible {
  border-color: var(--accent);
  transform: translateY(-2px);
  transition: transform 160ms ease;
}
.home-chapter.is-locked {
  opacity: 0.7;
}
.home-chapter-num {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 900;
  font-size: 1.2rem;
}
.home-chapter-title {
  font-weight: 800;
  font-size: 1.1rem;
}
.home-chapter-meta {
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 700;
}

/* ==================== რესურსები ==================== */
.resources-view {
  display: grid;
  gap: 20px;
}
.resource-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px;
}
.resource-card {
  position: relative;
  display: grid;
  gap: 6px;
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
}
.resource-card:hover,
.resource-card:focus-visible {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.resource-card strong {
  font-size: 1.05rem;
}
.resource-desc {
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.4;
}
.resource-arrow {
  position: absolute;
  top: 16px;
  right: 18px;
  color: var(--accent);
  font-weight: 900;
}

/* ==================== დავალებები (Exercises) ==================== */
.exercise-panel {
  display: grid;
  gap: 20px;
}
.exercise-list {
  display: grid;
  gap: 12px;
  margin: 14px 0 0;
  padding: 0;
  list-style: none;
  counter-reset: ex;
}
.exercise-item {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: start;
  gap: 12px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
}
.exercise-level {
  white-space: nowrap;
  font-size: 0.78rem;
  font-weight: 800;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--surface-strong);
}
.exercise-text {
  line-height: 1.5;
}
.exercise-answers {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 16px;
  background: var(--surface-strong);
}
.exercise-answers summary {
  cursor: pointer;
  font-weight: 800;
  color: var(--accent);
}
.answer-list {
  margin: 12px 0 0;
  padding-left: 20px;
  display: grid;
  gap: 8px;
  color: var(--muted);
  line-height: 1.5;
}

/* ==================== რესპონსივი ==================== */
@media (max-width: 820px) {
  .platform-layout {
    grid-template-columns: 1fr;
  }
  .chapter-sidebar {
    position: static;
  }
  .top-nav {
    justify-content: flex-start;
  }
}

/* ==================== ხიდ-გაკვეთილი: ორი მდგომარეობა ==================== */
.twostate-layout {
  display: flex;
  flex-wrap: wrap;
  gap: 26px;
  align-items: center;
}
.twostate-controls {
  display: grid;
  gap: 14px;
  min-width: 220px;
  flex: 1;
}
.control-label {
  font-weight: 700;
  color: var(--muted);
}
.voltage-slider {
  width: 100%;
  accent-color: var(--accent);
}
.twostate-meter-wrap {
  display: flex;
  align-items: center;
  gap: 18px;
}
.voltage-meter {
  position: relative;
  width: 46px;
  height: 170px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-strong);
  overflow: hidden;
}
.vm-fill {
  position: absolute;
  left: 0;
  bottom: 0;
  width: 100%;
  height: 80%;
  background: linear-gradient(180deg, var(--muted), var(--border));
  transition: height 90ms linear;
}
.vm-fill.is-high {
  background: linear-gradient(180deg, var(--electron), var(--accent));
}
.vm-threshold {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 50%;
  height: 0;
  border-top: 2px dashed var(--danger);
  z-index: 2;
}

/* ==================== ხიდ-გაკვეთილი: მრავალბიტიანი ==================== */
.mb-adder,
.mb-register {
  display: grid;
  gap: 12px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
}
.mb-register {
  margin-top: 16px;
}
.mb-adder h4,
.mb-register h4 {
  margin: 0;
}
.mb-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.mb-row-label {
  min-width: 68px;
  font-weight: 800;
  color: var(--muted);
}
.mb-bits,
.mb-chain {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

/* ==================== გამდიდრება: ვიზუალი, მაგალითები, რესურსები ==================== */
.visual-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 18px;
  align-items: start;
}
.lesson-illustration {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-strong);
}
.lesson-illustration svg {
  width: 100%;
  height: auto;
  max-height: 260px;
}
.lesson-photo {
  margin: 0;
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  background: var(--surface-strong);
}
.lesson-photo-img {
  display: block;
  width: 100%;
  height: 200px;
  object-fit: cover;
}
.lesson-photo-cap {
  display: grid;
  gap: 3px;
  padding: 10px 12px;
  font-size: 0.86rem;
  color: var(--muted);
}
.photo-credit {
  font-size: 0.74rem;
}
.photo-credit a {
  color: var(--muted);
}
.extras-block {
  margin-top: 12px;
}
.extras-block h4 {
  margin: 0 0 8px;
}
.examples-list {
  margin: 0;
  padding-left: 20px;
  display: grid;
  gap: 8px;
  line-height: 1.5;
}
.resource-links {
  margin: 0;
  padding-left: 20px;
  display: grid;
  gap: 8px;
}
.resource-links a {
  color: var(--accent);
  font-weight: 600;
}

/* ==================== დამატებითი რესურსების სექცია + recap CTA ==================== */
.res-group {
  margin-bottom: 22px;
}
.res-group h4 {
  margin: 0 0 10px;
  font-size: 1rem;
}
.recap-next {
  margin-top: 20px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--accent-soft);
  display: grid;
  gap: 8px;
  justify-items: start;
}
.recap-next h4 {
  margin: 0;
}

/* ==================== HTML თავი: ცოცხალი კოდის პლეიგრაუნდი ==================== */
.playground {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 14px;
}
.playground-pane {
  display: grid;
  gap: 6px;
  min-width: 0;
}
.playground-label {
  font-size: 0.8rem;
  font-weight: 800;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.code-editor {
  width: 100%;
  min-height: 240px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-strong);
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.86rem;
  line-height: 1.55;
  resize: vertical;
  tab-size: 2;
}
.code-editor:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
.code-preview {
  width: 100%;
  min-height: 240px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
}
.tag-table code,
.code-inline {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.88em;
  background: var(--surface-strong);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 1px 5px;
}

/* ==================== CSS თავი: სამპანელიანი პლეიგრაუნდი ==================== */
.playground-css {
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
}
.markup-view {
  margin: 0;
  min-height: 120px;
  max-height: 240px;
  overflow: auto;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-strong);
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.8rem;
  line-height: 1.5;
  white-space: pre-wrap;
}

/* ==================== JS თავი: გამშვები ==================== */
.js-playground {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 14px;
}
.js-playground .control-row {
  grid-column: 1 / -1;
}
.js-output {
  margin: 0;
  min-height: 240px;
  max-height: 340px;
  overflow: auto;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #0f141c;
  color: #b8f5c8;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.84rem;
  line-height: 1.55;
  white-space: pre-wrap;
}
/* გამშვები უხილავია, მაგრამ დახატული — display:none ბრაუზერს ტაიმერებს ახშობინებს */
.js-runner {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  border: 0;
  pointer-events: none;
}

/* ==================== SCSS თავი: SCSS → CSS პლეიგრაუნდი ==================== */
.playground-scss {
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
}
.scss-output {
  margin: 0;
  min-height: 200px;
  max-height: 300px;
  overflow: auto;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #0f141c;
  color: #d6c8f5;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.82rem;
  line-height: 1.55;
  white-space: pre-wrap;
  tab-size: 2;
}
.scss-output.has-error {
  color: #ffb4b4;
  background: #2a1416;
}
/* SCSS დაყენების გაკვეთილი — checklist */
.setup-steps { display: flex; flex-direction: column; gap: 12px; margin: 8px 0 18px; }
.setup-step { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; }
.setup-step input { margin-top: 5px; flex: none; }
.setup-step-t { display: block; margin-bottom: 6px; }
.setup-step .markup-view { margin: 0; min-height: 0; }
.js-playground {
  position: relative;
}

/* ==================== დასრულების ბარი (გაკვეთილი / დავალება) ==================== */
.done-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.done-status {
  display: flex;
  align-items: center;
  gap: 12px;
}
.done-icon {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 2px solid var(--border);
  color: var(--muted);
  font-weight: 900;
  font-size: 0.95rem;
  flex: none;
}
.done-text {
  font-weight: 700;
  color: var(--muted);
}
.done-bar.is-done {
  border-color: var(--success);
  background: var(--electron-soft);
}
.done-bar.is-done .done-icon {
  border-color: var(--success);
  background: var(--success);
  color: #fff;
}
.done-bar.is-done .done-text {
  color: var(--success);
}
.done-bar .primary-button,
.done-bar .secondary-button {
  flex: none;
}
