:root {
      --bg: #fff7ed;
      --card: #ffffff;
      --text: #241407;
      --muted: #7c5b35;
      --primary: #d97706;
      --primary-dark: #92400e;
      --accent: #f59e0b;
      --soft: #ffedd5;
      --line: #fed7aa;
      --code-bg: #1f1308;
      --code-text: #fff7ed;
      --success: #15803d;
      --danger: #b91c1c;
      --info: #0369a1;
      --shadow: 0 18px 45px rgba(120, 53, 15, 0.14);
      --radius: 24px;
    }

    * {
      box-sizing: border-box;
    }

    html {
      scroll-behavior: smooth;
    }

    body {
      margin: 0;
      font-family: Arial, Helvetica, sans-serif;
      background:
        radial-gradient(circle at top left, #fed7aa 0, transparent 28%),
        radial-gradient(circle at top right, #fde68a 0, transparent 24%),
        var(--bg);
      color: var(--text);
      line-height: 1.7;
    }

    a {
      color: var(--primary-dark);
      font-weight: 800;
      text-decoration: none;
    }

    a:hover {
      text-decoration: underline;
    }

    .topbar {
      position: sticky;
      top: 0;
      z-index: 10;
      background: rgba(255, 247, 237, 0.94);
      backdrop-filter: blur(14px);
      border-bottom: 1px solid var(--line);
    }

    .topbar-inner {
      max-width: 1240px;
      margin: auto;
      padding: 14px 20px;
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 16px;
    }

    .brand {
      display: flex;
      align-items: center;
      gap: 12px;
      font-weight: 900;
      color: var(--primary-dark);
      line-height: 1.25;
    }

    .brand-icon {
      width: 44px;
      height: 44px;
      border-radius: 15px;
      background: linear-gradient(135deg, var(--primary), var(--accent));
      display: grid;
      place-items: center;
      color: white;
      font-weight: 900;
      box-shadow: 0 10px 22px rgba(217, 119, 6, 0.28);
    }

    .nav {
      display: flex;
      flex-wrap: wrap;
      gap: 10px;
      justify-content: flex-end;
    }

    .nav a {
      font-size: 14px;
      padding: 8px 12px;
      border: 1px solid var(--line);
      border-radius: 999px;
      background: #fff;
      color: var(--primary-dark);
    }

    .hero {
      max-width: 1240px;
      margin: 0 auto;
      padding: 56px 20px 28px;
    }

    .hero-card {
      background: linear-gradient(135deg, #fff, #ffedd5);
      border: 1px solid var(--line);
      border-radius: 34px;
      box-shadow: var(--shadow);
      padding: 44px;
      overflow: hidden;
      position: relative;
    }

    .badge {
      display: inline-flex;
      background: #fff7ed;
      border: 1px solid var(--line);
      color: var(--primary-dark);
      padding: 8px 14px;
      border-radius: 999px;
      font-weight: 800;
      margin-bottom: 18px;
    }

    h1 {
      font-size: clamp(34px, 6vw, 64px);
      line-height: 1.05;
      margin: 0 0 18px;
      color: var(--primary-dark);
      max-width: 950px;
    }

    .hero p {
      max-width: 880px;
      font-size: 20px;
      color: var(--muted);
      margin: 0 0 24px;
    }

    .hero-actions {
      display: flex;
      flex-wrap: wrap;
      gap: 14px;
      margin-top: 24px;
    }

    .btn {
      border: 0;
      cursor: pointer;
      display: inline-flex;
      align-items: center;
      justify-content: center;
      padding: 13px 18px;
      border-radius: 16px;
      font-weight: 900;
      font-size: 15px;
      text-decoration: none;
    }

    .btn-primary {
      background: var(--primary);
      color: #fff;
      box-shadow: 0 12px 24px rgba(217, 119, 6, 0.25);
    }

    .btn-secondary {
      background: #fff;
      color: var(--primary-dark);
      border: 1px solid var(--line);
    }

    .container {
      max-width: 1240px;
      margin: auto;
      padding: 22px 20px 70px;
      display: grid;
      grid-template-columns: 310px 1fr;
      gap: 24px;
      align-items: start;
    }

    .sidebar {
      position: sticky;
      top: 86px;
      background: rgba(255, 255, 255, 0.86);
      border: 1px solid var(--line);
      border-radius: var(--radius);
      padding: 18px;
      box-shadow: var(--shadow);
      max-height: calc(100vh - 110px);
      overflow: auto;
    }

    .sidebar h3 {
      margin: 0 0 12px;
      color: var(--primary-dark);
    }

    .sidebar a {
      display: block;
      padding: 9px 10px;
      border-radius: 12px;
      color: var(--muted);
      font-weight: 700;
      font-size: 14px;
    }

    .sidebar a:hover {
      background: var(--soft);
      text-decoration: none;
      color: var(--primary-dark);
    }

    .content {
      display: grid;
      gap: 22px;
    }

    section.lesson {
      background: rgba(255, 255, 255, 0.92);
      border: 1px solid var(--line);
      border-radius: var(--radius);
      padding: 28px;
      box-shadow: var(--shadow);
    }

    section.lesson h2 {
      margin: 0 0 12px;
      color: var(--primary-dark);
      font-size: 30px;
      line-height: 1.2;
    }

    section.lesson h3 {
      margin-top: 24px;
      color: var(--primary-dark);
    }

    .note {
      background: #fffbeb;
      border-left: 5px solid var(--accent);
      padding: 16px 18px;
      border-radius: 16px;
      margin: 18px 0;
    }

    .success {
      background: #f0fdf4;
      border-left: 5px solid var(--success);
      padding: 16px 18px;
      border-radius: 16px;
      margin: 18px 0;
    }

    .warning {
      background: #fef2f2;
      border-left: 5px solid var(--danger);
      padding: 16px 18px;
      border-radius: 16px;
      margin: 18px 0;
    }

    .info {
      background: #f0f9ff;
      border-left: 5px solid var(--info);
      padding: 16px 18px;
      border-radius: 16px;
      margin: 18px 0;
    }

    pre {
      position: relative;
      background: var(--code-bg);
      color: var(--code-text);
      padding: 18px;
      border-radius: 18px;
      overflow-x: auto;
      border: 1px solid #3b220f;
    }

    code {
      font-family: Consolas, Monaco, "Courier New", monospace;
      font-size: 14px;
    }

    .copy-btn {
      position: absolute;
      top: 10px;
      right: 10px;
      border: 1px solid rgba(255, 255, 255, 0.2);
      background: rgba(255, 255, 255, 0.08);
      color: #fff;
      border-radius: 10px;
      padding: 6px 9px;
      cursor: pointer;
      font-weight: 800;
      font-size: 12px;
    }

    .table-wrap {
      overflow-x: auto;
      border-radius: 18px;
      border: 1px solid var(--line);
      margin-top: 16px;
    }

    table {
      width: 100%;
      border-collapse: collapse;
      background: white;
      min-width: 850px;
    }

    th,
    td {
      padding: 14px;
      border-bottom: 1px solid var(--line);
      text-align: left;
      vertical-align: top;
    }

    th {
      background: var(--soft);
      color: var(--primary-dark);
    }

    .cards {
      display: grid;
      grid-template-columns: repeat(3, 1fr);
      gap: 14px;
      margin-top: 18px;
    }

    .card {
      background: #fff7ed;
      border: 1px solid var(--line);
      border-radius: 18px;
      padding: 16px;
    }

    .card strong {
      color: var(--primary-dark);
      display: block;
      margin-bottom: 6px;
    }

    .diagram {
      background: #fffaf3;
      border: 1px solid var(--line);
      border-radius: 24px;
      padding: 18px;
      margin: 22px 0;
      overflow-x: auto;
    }

    .diagram svg {
      width: 100%;
      min-width: 760px;
      height: auto;
      display: block;
    }

    .footer {
      max-width: 1240px;
      margin: 0 auto 36px;
      padding: 24px 20px;
      color: var(--muted);
      text-align: center;
    }

    @media (max-width: 980px) {
      .container {
        grid-template-columns: 1fr;
      }

      .sidebar {
        position: static;
        max-height: none;
      }

      .cards {
        grid-template-columns: 1fr;
      }

      .hero-card {
        padding: 28px;
      }
    }


    .checkpoint {
      margin-top: 22px;
      padding: 18px;
      border-radius: 20px;
      border: 1px solid #fed7aa;
      background: linear-gradient(135deg, #fff7ed, #fffbeb);
      box-shadow: 0 12px 26px rgba(120, 53, 15, 0.08);
    }

    .checkpoint h3 {
      margin: 0 0 10px;
      color: #92400e;
      font-size: 20px;
    }

    .checkpoint p {
      margin: 0 0 12px;
      color: #7c5b35;
      font-weight: 700;
    }

    .checkpoint-list {
      display: grid;
      gap: 9px;
      margin-top: 12px;
    }

    .checkpoint-item {
      display: flex;
      gap: 10px;
      align-items: flex-start;
      background: #ffffff;
      border: 1px solid #fed7aa;
      border-radius: 14px;
      padding: 10px 12px;
    }

    .checkpoint-item input {
      margin-top: 5px;
      transform: scale(1.2);
      accent-color: #d97706;
    }

    .checkpoint-continue {
      margin-top: 14px;
      display: inline-flex;
      align-items: center;
      justify-content: center;
      border: 0;
      border-radius: 14px;
      padding: 10px 14px;
      background: #d97706;
      color: white;
      font-weight: 900;
      cursor: pointer;
    }

    .checkpoint-continue:disabled {
      opacity: 0.45;
      cursor: not-allowed;
    }

    .checkpoint-status {
      margin-top: 10px;
      font-size: 14px;
      color: #7c5b35;
      font-weight: 800;
    }

    .speak-tag-label {
      display: inline-flex;
      margin-bottom: 10px;
      padding: 5px 10px;
      border-radius: 999px;
      background: #fff7ed;
      border: 1px solid #fed7aa;
      color: #92400e;
      font-size: 12px;
      font-weight: 900;
    }

    @media print {

      .topbar,
      .sidebar,
      .hero-actions,
      .copy-btn {
        display: none;
      }

      body {
        background: white;
      }

      .container {
        display: block;
      }

      section.lesson,
      .hero-card {
        box-shadow: none;
        break-inside: avoid;
      }
    }

/* Revision: stronger code-block styling so external scripts/search highlights cannot wash it out */
section.lesson pre {
  position: relative !important;
  display: block !important;
  background: #1f1308 !important;
  color: #fff7ed !important;
  padding: 52px 18px 18px !important;
  border-radius: 18px !important;
  overflow-x: auto !important;
  border: 1px solid #3b220f !important;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.06), 0 14px 28px rgba(120, 53, 15, 0.12) !important;
  min-height: auto !important;
  line-height: 1.65 !important;
}

section.lesson pre code {
  display: block !important;
  background: transparent !important;
  color: #fff7ed !important;
  white-space: pre !important;
  font-family: Consolas, Monaco, "Courier New", monospace !important;
  font-size: 14px !important;
  line-height: 1.65 !important;
}

section.lesson pre .copy-btn {
  position: absolute !important;
  top: 10px !important;
  right: 10px !important;
  z-index: 3 !important;
  border: 1px solid rgba(255, 247, 237, 0.35) !important;
  background: #92400e !important;
  color: #ffffff !important;
  border-radius: 10px !important;
  padding: 7px 11px !important;
  cursor: pointer !important;
  font-weight: 900 !important;
  font-size: 12px !important;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.22) !important;
}

section.lesson pre .copy-btn:hover {
  background: #d97706 !important;
}

section.lesson pre code::selection,
section.lesson pre::selection {
  background: #f59e0b !important;
  color: #1f1308 !important;
}

@media (max-width: 640px) {
  section.lesson pre {
    padding: 54px 14px 16px !important;
    border-radius: 16px !important;
  }

  section.lesson pre code {
    font-size: 13px !important;
  }
}
