  /* ── SITE TOKENS (matched to onlinecstutor.com) ─────── */
  :root {
    --green:           #4fc431;
    --green-dark:      #3aad1f;
    --bg:              #0f1620;
    --bg2:             #18202e;
    --bg3:             #222c3c;
    --text:            #e8edf4;
    --text-muted:      #8fa0b8;
    --border:          #2a3547;
    --radius:          16px;
    --mono:            'JetBrains Mono', monospace;
    --sans:            'DM Sans', sans-serif;
    /* Syntax diagram generator */
    --nt:              #5aa9ff;
    --nt-fill:         #10233d;
    --term:            #f5c542;
    --term-fill:       #2e2610;
    --accent:          #00ff88;
    --idle-fill:       #1a2436;
    --idle-stroke:     #2a3547;
    --output-fill:     #12300e;
    --output-stroke:   #4fc431;
    --top-fill:        #003b22;
    --top-stroke:      #00ff88;
    --discard:         #ff6b6b;
    --discard-fill:    #331414;
  }

  [data-theme="light"] {
    --bg:              #dde4ef;
    --bg2:             #eaf0f8;
    --bg3:             #d0d9e8;
    --text:            #0f1a2e;
    --text-muted:      #3d5070;
    --border:          #b0bdd0;
    --idle-fill:       #c8d4e8;
    --idle-stroke:     #8fa0b8;
    --nt:              #1d5fb8;
    --nt-fill:         #d6e6fb;
    --term:            #8a6400;
    --term-fill:       #f6ebc8;
    --top-fill:        #c9f0db;
    --accent:          #0a8a4e;
    --output-fill:     #d4f0cc;
    --discard-fill:    #f8dcdc;
    --discard:         #c0392b;
  }

  * { margin: 0; padding: 0; box-sizing: border-box; }
  html { scroll-behavior: smooth; }

  body {
    background: var(--bg);
    color: var(--text);
    font-family: var(--sans);
    font-size: 16px;
    line-height: 1.7;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
  }

  /* ── NAV ───────────────────────────────────────────── */
  nav {
    position: sticky;
    top: env(safe-area-inset-top, 0px);
    z-index: 100;
    background: rgba(15,22,32,0.92);
    border-bottom: 1px solid var(--border);
    padding: 0 32px;
    display: flex;
    align-items: center;
    height: 64px;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    gap: 16px;
    flex-shrink: 0;
  }
  [data-theme="light"] nav { background: rgba(234,240,248,0.95); }

  .nav-back {
    display: flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    color: var(--text-muted);
    font-size: 0.875rem;
    font-weight: 500;
    padding: 8px 14px;
    border-radius: 8px;
    border: 1px solid var(--border);
    transition: color 0.2s, border-color 0.2s;
    white-space: nowrap;
  }
  .nav-back:hover { color: var(--green); border-color: var(--green); }

  .nav-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
  }
  .nav-logo img { height: 32px; width: auto; }
  .nav-brand {
    font-family: var(--mono);
    font-size: 0.82rem;
    color: var(--green);
    font-weight: 700;
  }
  .nav-title {
    margin-left: auto;
    font-family: var(--mono);
    font-size: 0.75rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .theme-btn {
    background: var(--bg3);
    border: 1px solid var(--border);
    color: var(--text-muted);
    cursor: pointer;
    padding: 6px 10px;
    border-radius: 8px;
    font-size: 0.85rem;
    transition: 0.2s;
    line-height: 1;
    flex-shrink: 0;
  }
  .theme-btn:hover { color: var(--text); }

  /* ── PAGE CONTENT ──────────────────────────────────── */
  .page-wrap {
    width: 100%;
    max-width: 960px;
    margin: 0 auto;
    padding: 40px 24px 56px;
    flex: 1;
  }

  .page-label {
    font-family: var(--mono);
    font-size: 0.73rem;
    color: var(--green);
    text-transform: uppercase;
    letter-spacing: 0.12em;
    margin-bottom: 10px;
  }

  h1 {
    font-family: var(--mono);
    font-size: clamp(1.3rem, 3vw, 1.8rem);
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.02em;
    margin-bottom: 10px;
    line-height: 1.2;
  }
  h1 .accent { color: var(--accent); }

  .subtitle {
    color: var(--text-muted);
    font-size: 0.95rem;
    margin-bottom: 28px;
    max-width: 680px;
    line-height: 1.7;
  }

  /* ── (message styles kept for consistency) ── ─────────────────────────────────────────── */
  .msg {
    min-height: 52px;
    font-size: 0.95rem;
    line-height: 1.6;
    padding: 14px 18px;
    background: var(--bg2);
    border: 1px solid var(--border);
    border-left: 3px solid var(--accent);
    border-radius: 0 var(--radius) var(--radius) 0;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
  }
  .msg b { color: var(--text); }

  .order-row {
    display: flex;
    align-items: baseline;
    gap: 10px;
    flex-wrap: wrap;
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-bottom: 20px;
    padding: 0 4px;
  }
  .order-row code { font-family: var(--mono); color: var(--accent); font-size: 0.9rem; }

  /* ── CONTROLS ────────────────────────────────────────── */
  .controls {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 12px;
  }
  button {
    font-family: var(--sans);
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text);
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 9px 18px;
    cursor: pointer;
    transition: border-color 0.15s, color 0.15s, background 0.15s;
  }
  button:hover { border-color: var(--accent); color: var(--accent); }
  button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
  button.play-active { background: var(--top-fill); border-color: var(--accent); color: var(--accent); }

  .step-lbl {
    margin-left: auto;
    font-family: var(--mono);
    font-size: 0.8rem;
    color: var(--text-muted);
  }

  .speed-ctl {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.8rem;
    color: var(--text-muted);
  }
  .speed-ctl input[type="range"] {
    -webkit-appearance: none; appearance: none;
    width: 110px; height: 4px;
    background: var(--border);
    border-radius: 2px;
    outline: none; cursor: pointer;
  }
  .speed-ctl input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none; appearance: none;
    width: 16px; height: 16px;
    border-radius: 50%;
    background: var(--accent); border: none;
  }
  .speed-ctl input[type="range"]::-moz-range-thumb {
    width: 16px; height: 16px;
    border-radius: 50%;
    background: var(--accent); border: none;
  }
  .speed-val { font-family: var(--mono); color: var(--text); min-width: 78px; }

  .hint { margin-top: 16px; font-size: 0.78rem; color: var(--text-muted); text-align: center; }
  kbd {
    font-family: var(--mono);
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 1px 6px;
    font-size: 0.75rem;
  }

  /* ── FOOTER ──────────────────────────────────────────── */
  footer {
    background: var(--bg2);
    border-top: 1px solid var(--border);
    padding: 28px 32px;
    padding-bottom: calc(28px + env(safe-area-inset-bottom, 0px));
    text-align: center;
    flex-shrink: 0;
  }
  footer p { font-family: var(--mono); font-size: 0.78rem; color: var(--text-muted); }
  footer span { color: var(--green); }

  @media (max-width: 520px) {
    .step-lbl { margin-left: 0; width: 100%; text-align: center; }
    nav { padding: 0 16px; }
    .nav-title { display: none; }
  }


  /* ── SYNTAX DIAGRAM GENERATOR ───────────────────────── */
  .page-wrap { max-width: 1180px; }
  .sd-layout { display: grid; grid-template-columns: minmax(300px, 400px) 1fr; gap: 16px; align-items: start; }
  @media (max-width: 900px) { .sd-layout { grid-template-columns: 1fr; } }
  .sd-layout > * { min-width: 0; }

  .panel {
    background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 16px 18px; min-width: 0;
  }
  .panel h2 {
    font-family: var(--mono); font-size: 0.7rem; font-weight: 600; color: var(--green);
    text-transform: uppercase; letter-spacing: 0.1em; margin-bottom: 12px;
  }
  .editor-panel { position: sticky; top: 80px; }
  @media (max-width: 900px) { .editor-panel { position: static; } }

  .row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; }
  .row label { font-size: 0.82rem; color: var(--text-muted); }
  select {
    font-family: var(--sans); font-size: 0.85rem; color: var(--text);
    background: var(--bg); border: 1px solid var(--border); border-radius: 10px; padding: 7px 10px;
    flex: 1; min-width: 0;
  }
  textarea {
    width: 100%; min-height: 230px; resize: vertical;
    font-family: var(--mono); font-size: 0.88rem; line-height: 1.7;
    color: var(--text); background: var(--bg); border: 1px solid var(--border); border-radius: 10px;
    padding: 12px 14px; tab-size: 2; white-space: pre; overflow-x: auto;
  }
  textarea:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
  .check { display: flex; gap: 8px; align-items: flex-start; font-size: 0.85rem; color: var(--text); margin: 12px 0 4px; cursor: pointer; }
  .check input { margin-top: 4px; accent-color: var(--green); }
  .check small { display: block; color: var(--text-muted); font-size: 0.76rem; }

  .issues { margin-top: 12px; display: flex; flex-direction: column; gap: 6px; }
  .issues:empty { display: none; }
  .issue { font-size: 0.8rem; line-height: 1.5; padding: 7px 10px; border-radius: 8px; }
  .issue.err { background: var(--discard-fill); color: var(--discard); }
  .issue.warn { background: var(--bg3); color: var(--text-muted); }
  .issue code { font-family: var(--mono); }

  .help { margin-top: 14px; font-size: 0.78rem; color: var(--text-muted); line-height: 1.65; }
  .help code { font-family: var(--mono); color: var(--text); background: var(--bg3); padding: 1px 5px; border-radius: 5px; }

  .diagrams { display: flex; flex-direction: column; gap: 16px; }
  .diagram-card { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px 16px; }
  .diagram-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
  .diagram-head .name { font-family: var(--mono); font-size: 0.95rem; font-weight: 700; color: var(--nt); }
  .diagram-head .bnf { font-family: var(--mono); font-size: 0.76rem; color: var(--text-muted); flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .diagram-head button { padding: 5px 11px; font-size: 0.76rem; }
  .diagram-note { font-size: 0.76rem; color: var(--text-muted); margin-top: 8px; }
  .svg-wrap { overflow-x: auto; padding: 4px 0; }
  .svg-wrap svg { display: block; }
  .empty-state { color: var(--text-muted); font-size: 0.9rem; padding: 30px; text-align: center; border: 1px dashed var(--border); border-radius: var(--radius); }

  .key { display: flex; gap: 14px; flex-wrap: wrap; margin: 0 0 14px; font-size: 0.78rem; color: var(--text-muted); }
  .key i { display: inline-block; width: 22px; height: 13px; margin-right: 6px; vertical-align: -2px; border: 1.5px solid; }
  .key .k-nt { border-color: var(--nt); background: var(--nt-fill); }
  .key .k-t { border-color: var(--term); background: var(--term-fill); border-radius: 7px; }
  .all-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; align-items: center; }
  .all-actions .spacer { flex: 1; }
