:root {
      --bg-void: #090e1a;
      --bg-elevated: #111827;
      --card-paper: #fbf9f5;
      --card-paper-alt: #f3efe6;
      --ink-paper: #141923;
      --ink-paper-muted: #525d73;
      --ink-dark: #f8fafc;
      --ink-dark-muted: #94a3b8;
      --gold: #d4af6a;
      --gold-soft: rgba(212, 175, 106, 0.14);
      --gold-border: rgba(212, 175, 106, 0.35);
      --line-dark: rgba(148, 163, 184, 0.16);
      --line-paper: rgba(20, 25, 35, 0.10);

      --easy-bg: #dcfce7;
      --easy-fg: #166534;
      --med-bg: #fef3c7;
      --med-fg: #92400e;
      --hard-bg: #fee2e2;
      --hard-fg: #991b1b;

      --font-serif: "Newsreader", Georgia, "Times New Roman", serif;
      --font-sans: "Plus Jakarta Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
      --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;

      --radius-xl: 22px;
      --radius-lg: 16px;
      --radius-md: 11px;
      --radius-sm: 8px;
    }

    * { box-sizing: border-box; margin: 0; padding: 0; }

    body {
      font-family: var(--font-sans);
      background-color: var(--bg-void);
      background-image:
        radial-gradient(ellipse 900px 520px at 15% -5%, rgba(212, 175, 106, 0.12), transparent 65%),
        radial-gradient(ellipse 750px 480px at 88% 8%, rgba(56, 189, 248, 0.08), transparent 60%);
      color: var(--ink-dark);
      line-height: 1.65;
      min-height: 100vh;
      -webkit-font-smoothing: antialiased;
    }

    /* Glass Topbar */
    .topbar {
      position: sticky;
      top: 0;
      z-index: 40;
      background: rgba(9, 14, 26, 0.78);
      backdrop-filter: blur(16px);
      -webkit-backdrop-filter: blur(16px);
      border-bottom: 1px solid var(--line-dark);
    }
    .topbar-inner {
      max-width: 1140px;
      margin: 0 auto;
      padding: 0.95rem 1.5rem;
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 1rem;
      flex-wrap: wrap;
    }
    .brand {
      display: flex;
      align-items: center;
      gap: 0.85rem;
      text-decoration: none;
      color: var(--ink-dark);
    }
    .brand-mark {
      width: 38px;
      height: 38px;
      border-radius: 11px;
      background: linear-gradient(145deg, #e5c382, #b68b3e);
      color: #090e1a;
      display: grid;
      place-items: center;
      font-family: var(--font-serif);
      font-weight: 700;
      font-size: 1.25rem;
      box-shadow: 0 4px 16px rgba(212, 175, 106, 0.25);
    }
    .brand-title {
      font-family: var(--font-serif);
      font-weight: 700;
      font-size: 1.22rem;
      letter-spacing: -0.01em;
    }
    .brand-sub {
      font-size: 0.75rem;
      color: var(--ink-dark-muted);
      letter-spacing: 0.02em;
    }

    .header-actions {
      display: flex;
      align-items: center;
      gap: 0.7rem;
      flex-wrap: wrap;
    }
    .pill-stat {
      font-family: var(--font-mono);
      background: rgba(255, 255, 255, 0.04);
      border: 1px solid var(--line-dark);
      padding: 0.36rem 0.78rem;
      border-radius: 999px;
      font-size: 0.76rem;
      color: var(--ink-dark-muted);
    }
    .header-actions .article-nav-link {
      display: inline-flex;
      align-items: center;
      min-height: 40px;
      background: #7548ca;
      border-color: #7548ca;
      color: #fff;
      font: 800 0.82rem var(--font-sans);
      text-decoration: none;
      white-space: nowrap;
    }
    .header-actions .article-nav-link:hover { background: #6037b3; border-color: #6037b3; color: #fff; }
    .header-actions .article-nav-link:focus-visible { outline: 3px solid #f3bb4c; outline-offset: 3px; }
    .study-nav-link { background: #fff0c7; border-color: #e9c978; color: #72510a; }
    .header-actions .study-nav-link:hover { background: #ffe4a1; border-color: #ddb95d; color: #72510a; }
    .study-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; }
    .study-card {
      display: flex;
      flex-direction: column;
      min-height: 220px;
      padding: 1.15rem;
      border: 2px solid #eceaf4;
      border-radius: 22px;
      background: #fff;
      box-shadow: 0 5px 0 #d4dcdd;
      color: #30264f;
      text-decoration: none;
      transition: transform .18s ease, border-color .18s ease, box-shadow .18s ease;
    }
    .study-card:hover { transform: translateY(-3px); border-color: #cbbbef; box-shadow: 0 8px 0 #d0d9da; }
    .study-card-icon {
      display: grid;
      place-items: center;
      height: 86px;
      margin-bottom: .9rem;
      border-radius: 16px;
      background: #eef8fa;
      font-size: 2.7rem;
    }
    .study-card:nth-child(6n+1) .study-card-icon { background: #eef8fa; color: #1c6b77; }
    .study-card:nth-child(6n+2) .study-card-icon { background: #f3effb; color: #6236b5; }
    .study-card:nth-child(6n+3) .study-card-icon { background: #fff4d9; color: #9c6c0b; }
    .study-card:nth-child(6n+4) .study-card-icon { background: #fdf0ed; color: #ba4737; }
    .study-card:nth-child(6n+5) .study-card-icon { background: #edf8f2; color: #1f7a4d; }
    .study-card:nth-child(6n+6) .study-card-icon { background: #edf4fe; color: #225cb2; }
    .study-button.active { background: #512da8; border-color: #512da8; color: #fff; }
    .study-card h3 { font-size: 1.08rem; margin-bottom: .35rem; }
    .study-card p { color: #747185; font-size: .88rem; line-height: 1.55; }
    .study-card .card-link-label { margin-top: auto; padding-top: .8rem; color: #7147c6; font-weight: 800; font-size: .84rem; }
    
    .study-filter-bar {
      display: flex;
      flex-wrap: wrap;
      align-items: center;
      justify-content: space-between;
      gap: .75rem;
      margin-bottom: 1.5rem;
    }
    .study-pills { display: flex; flex-wrap: wrap; gap: .45rem; }
    .study-pill {
      display: inline-flex;
      align-items: center;
      padding: .45rem .85rem;
      border: 2px solid #eae7f1;
      border-radius: 999px;
      background: #fff;
      color: #51466a;
      font: 800 .82rem var(--font-sans);
      cursor: pointer;
      transition: all .15s ease;
    }
    .study-pill:hover, .study-pill.active {
      background: #7548ca;
      border-color: #7548ca;
      color: #fff;
    }
    .study-search {
      padding: .5rem 1rem;
      border: 2px solid #eae7f1;
      border-radius: 999px;
      font: 600 .86rem var(--font-sans);
      color: #30264f;
      min-width: 220px;
    }
    .study-search:focus { outline: none; border-color: #7548ca; }
    .study-card-badge {
      display: inline-block;
      align-self: flex-start;
      margin-bottom: .45rem;
      padding: .2rem .55rem;
      border-radius: 8px;
      background: #f4effc;
      color: #7047c1;
      font-size: .72rem;
      font-weight: 800;
      text-transform: uppercase;
      letter-spacing: .03em;
    }

    .study-stage {
      margin: 1rem 0;
      border: 2px solid #eae7f1;
      border-radius: 22px;
      background: linear-gradient(180deg, #fbfdff, #f4f9fa);
      overflow: hidden;
    }
    .study-stage svg { width: 100%; height: auto; display: block; }
    .study-controls { display: flex; flex-wrap: wrap; align-items: center; gap: .65rem; margin: .75rem 0; }
    .study-controls label { font-weight: 800; color: #51466a; }
    .study-controls input[type="range"] { flex: 1; min-width: 180px; accent-color: #7548ca; }
    .study-button {
      min-height: 44px;
      padding: .65rem 1rem;
      border: 2px solid #7548ca;
      border-radius: 999px;
      background: #7548ca;
      color: #fff;
      font: 800 .86rem var(--font-sans);
      cursor: pointer;
    }
    .study-button.secondary { background: #fff; color: #7047c1; }
    .study-readout {
      min-height: 48px;
      margin-top: .7rem;
      padding: .75rem 1rem;
      border-radius: 14px;
      background: #f4effc;
      color: #51466a;
      font-weight: 750;
    }
    .fraction-choice { min-width: 86px; }
    @keyframes studyPop {
      from { opacity: 0; transform: scale(.72); transform-origin: center; }
      to { opacity: 1; transform: scale(1); transform-origin: center; }
    }

    /* Editorial Hero */
    .hero {
      max-width: 1140px;
      margin: 2.2rem auto 1.4rem;
      padding: 0 1.5rem;
      display: grid;
      grid-template-columns: 1.4fr 0.6fr;
      gap: 1.5rem;
      align-items: end;
    }
    @media (max-width: 820px) {
      .hero { grid-template-columns: 1fr; margin-top: 1.5rem; }
    }
    .eyebrow {
      display: inline-flex;
      align-items: center;
      gap: 0.45rem;
      font-size: 0.76rem;
      font-weight: 700;
      text-transform: uppercase;
      letter-spacing: 0.12em;
      color: var(--gold);
      margin-bottom: 0.65rem;
    }
    .hero h1 {
      font-family: var(--font-serif);
      font-size: clamp(1.95rem, 3.6vw, 2.85rem);
      font-weight: 700;
      line-height: 1.15;
      letter-spacing: -0.02em;
      color: var(--ink-dark);
      margin-bottom: 0.65rem;
    }
    .hero p {
      color: var(--ink-dark-muted);
      font-size: 0.98rem;
      max-width: 660px;
    }
    .hero-meta-box {
      background: var(--bg-elevated);
      border: 1px solid var(--line-dark);
      border-radius: var(--radius-lg);
      padding: 1rem 1.15rem;
    }
    .hero-meta-label {
      font-size: 0.72rem;
      text-transform: uppercase;
      letter-spacing: 0.1em;
      color: var(--ink-dark-muted);
      margin-bottom: 0.35rem;
    }
    .url-preview {
      font-family: var(--font-mono);
      font-size: 0.78rem;
      color: var(--gold);
      word-break: break-all;
    }

    /* Main Layout */
    .container {
      max-width: 1140px;
      margin: 0 auto 4.5rem;
      padding: 0 1.5rem;
    }

    /* Grade Pills */
    .grade-nav {
      display: grid;
      grid-template-columns: repeat(auto-fit, minmax(156px, 1fr));
      gap: 0.7rem;
      margin-bottom: 1.35rem;
    }
    .grade-tab {
      background: var(--bg-elevated);
      border: 1px solid var(--line-dark);
      border-radius: var(--radius-md);
      padding: 0.85rem 1rem;
      text-align: left;
      color: var(--ink-dark);
      cursor: pointer;
      transition: all 0.18s ease;
    }
    .grade-tab:hover {
      border-color: var(--gold-border);
      transform: translateY(-2px);
    }
    .grade-tab.active {
      background: linear-gradient(145deg, #e5c382, #c69949);
      border-color: transparent;
      color: #090e1a;
      box-shadow: 0 10px 28px rgba(212, 175, 106, 0.22);
    }
    .grade-tab .g-label {
      display: block;
      font-family: var(--font-serif);
      font-weight: 700;
      font-size: 1.06rem;
    }
    .grade-tab .g-meta {
      display: block;
      font-size: 0.76rem;
      opacity: 0.78;
      margin-top: 0.15rem;
    }

    /* Filter & Syllabus Bar */
    .toolbar {
      background: var(--bg-elevated);
      border: 1px solid var(--line-dark);
      border-radius: var(--radius-lg);
      padding: 1.2rem 1.35rem;
      margin-bottom: 1.75rem;
    }
    .syllabus-banner {
      background: var(--gold-soft);
      border: 1px solid var(--gold-border);
      color: #f3dfb6;
      border-radius: var(--radius-sm);
      padding: 0.72rem 1rem;
      font-size: 0.88rem;
      margin-bottom: 1rem;
    }
    .filter-row {
      display: flex;
      gap: 0.75rem;
      flex-wrap: wrap;
      align-items: center;
      justify-content: space-between;
    }
    .filter-controls {
      display: flex;
      gap: 0.75rem;
      flex-wrap: wrap;
      flex: 1;
    }
    select, .search-box {
      height: 42px;
      border: 1px solid var(--line-dark);
      border-radius: var(--radius-sm);
      padding: 0 0.9rem;
      font-family: var(--font-sans);
      font-size: 0.9rem;
      background: var(--bg-void);
      color: var(--ink-dark);
      outline: none;
      transition: border-color 0.15s ease;
    }
    select:focus, .search-box:focus { border-color: var(--gold); }
    .search-box { flex: 1; min-width: 220px; }
    .search-box::placeholder { color: var(--ink-dark-muted); }
    .page-indicator {
      font-family: var(--font-mono);
      font-size: 0.8rem;
      color: var(--ink-dark-muted);
      white-space: nowrap;
    }

    /* Protected Parchment Question Cards */
    .protected-zone {
      -webkit-user-select: none;
      -moz-user-select: none;
      -ms-user-select: none;
      user-select: none;
      -webkit-touch-callout: none;
    }

    .q-card {
      background: var(--card-paper);
      color: var(--ink-paper);
      border: 1px solid var(--line-paper);
      border-radius: var(--radius-xl);
      padding: 1.65rem 1.85rem;
      margin-bottom: 1.2rem;
      box-shadow: 0 14px 34px rgba(0, 0, 0, 0.28);
      transition: transform 0.18s ease, box-shadow 0.18s ease;
    }
    @media (max-width: 640px) {
      .q-card { padding: 1.25rem 1.2rem; border-radius: var(--radius-lg); }
    }
    .q-card:hover {
      transform: translateY(-2px);
      box-shadow: 0 20px 42px rgba(0, 0, 0, 0.36);
    }

    .q-top {
      display: flex;
      justify-content: space-between;
      align-items: center;
      gap: 0.75rem;
      margin-bottom: 1rem;
      flex-wrap: wrap;
    }
    .q-badges { display: flex; align-items: center; gap: 0.55rem; flex-wrap: wrap; }
    .q-num {
      font-family: var(--font-mono);
      font-weight: 600;
      font-size: 0.8rem;
      color: var(--ink-paper);
      background: var(--card-paper-alt);
      padding: 0.24rem 0.65rem;
      border-radius: 6px;
      border: 1px solid var(--line-paper);
    }
    .diff-tag {
      font-size: 0.74rem;
      font-weight: 700;
      letter-spacing: 0.03em;
      padding: 0.22rem 0.68rem;
      border-radius: 999px;
    }
    .diff-1 { background: var(--easy-bg); color: var(--easy-fg); }
    .diff-2 { background: var(--med-bg); color: var(--med-fg); }
    .diff-3 { background: var(--hard-bg); color: var(--hard-fg); }
    .q-topic {
      font-size: 0.82rem;
      font-weight: 600;
      color: var(--ink-paper-muted);
    }

    .q-stem {
      font-family: var(--font-serif);
      font-size: 1.32rem;
      font-weight: 600;
      color: var(--ink-paper);
      margin-bottom: 1.15rem;
      line-height: 1.48;
      border-left: 3px solid #c69949;
      padding-left: 0.95rem;
    }

    .q-visual {
      margin: 0.5rem 0 1.25rem;
      padding: 1rem;
      background: #ffffff;
      border: 1px solid var(--line-paper);
      border-radius: var(--radius-md);
      display: flex;
      justify-content: center;
      align-items: center;
    }
    .q-visual svg, .q-visual img {
      max-width: 100%;
      height: auto;
      pointer-events: none;
      -webkit-user-drag: none;
      user-drag: none;
    }

    .options-list {
      display: grid;
      grid-template-columns: repeat(2, minmax(0, 1fr));
      gap: 0.7rem;
      margin-bottom: 1.15rem;
    }
    @media (max-width: 600px) {
      .options-list { grid-template-columns: 1fr; }
    }
    .opt-btn {
      display: flex;
      align-items: center;
      padding: 0.78rem 1rem;
      border: 1px solid var(--line-paper);
      border-radius: var(--radius-md);
      background: #ffffff;
      color: var(--ink-paper);
      font-family: var(--font-sans);
      font-size: 0.96rem;
      font-weight: 600;
      text-align: left;
      cursor: pointer;
      transition: all 0.15s ease;
    }
    .opt-btn:hover {
      border-color: #b68b3e;
      background: #fdf8ee;
    }
    .opt-btn.correct {
      background: var(--easy-bg);
      border-color: #16a34a;
      color: var(--easy-fg);
    }
    .opt-btn.wrong {
      background: var(--hard-bg);
      border-color: #dc2626;
      color: var(--hard-fg);
    }

    .q-footer {
      display: flex;
      justify-content: space-between;
      align-items: center;
      padding-top: 0.7rem;
      border-top: 1px solid var(--line-paper);
    }
    .sol-btn {
      background: none;
      border: none;
      color: #8f641c;
      font-family: var(--font-sans);
      font-weight: 700;
      font-size: 0.88rem;
      cursor: pointer;
      padding: 0.2rem 0;
    }
    .sol-btn:hover { text-decoration: underline; }

    .sol-panel {
      display: none;
      margin-top: 0.95rem;
      padding: 1rem 1.2rem;
      background: var(--card-paper-alt);
      border-left: 3px solid #8f641c;
      border-radius: var(--radius-sm);
      font-size: 0.94rem;
      color: var(--ink-paper-muted);
    }
    .sol-panel.open { display: block; }
    .sol-ans {
      color: var(--ink-paper);
      font-weight: 700;
      margin-bottom: 0.35rem;
    }

    /* Pagination */
    .pagination-wrap {
      display: flex;
      justify-content: center;
      align-items: center;
      gap: 0.5rem;
      flex-wrap: wrap;
      margin-top: 2.2rem;
    }
    .pg-btn {
      min-width: 40px;
      height: 40px;
      padding: 0 0.8rem;
      border: 1px solid var(--line-dark);
      background: var(--bg-elevated);
      color: var(--ink-dark);
      border-radius: var(--radius-sm);
      font-family: var(--font-mono);
      font-size: 0.85rem;
      font-weight: 600;
      cursor: pointer;
      transition: all 0.15s ease;
    }
    .pg-btn:hover:not(:disabled) {
      border-color: var(--gold);
      color: var(--gold);
    }
    .pg-btn.active {
      background: linear-gradient(145deg, #e5c382, #c69949);
      border-color: transparent;
      color: #090e1a;
    }
    .pg-btn:disabled { opacity: 0.38; cursor: not-allowed; }

    .toast {
      position: fixed;
      bottom: 22px;
      right: 22px;
      background: var(--card-paper);
      color: var(--ink-paper);
      border: 1px solid var(--gold-border);
      padding: 0.7rem 1.05rem;
      border-radius: var(--radius-sm);
      font-size: 0.84rem;
      font-weight: 600;
      box-shadow: 0 14px 32px rgba(0, 0, 0, 0.45);
      opacity: 0;
      transform: translateY(8px);
      transition: all 0.2s ease;
      pointer-events: none;
      z-index: 100;
    }
    .toast.show { opacity: 1; transform: translateY(0); }
  


    :root {
      --bg-void: #dff2f4;
      --bg-elevated: #ffffff;
      --card-paper: #ffffff;
      --card-paper-alt: #f2f7f8;
      --ink-paper: #25213f;
      --ink-paper-muted: #66677d;
      --ink-dark: #30264f;
      --ink-dark-muted: #696a80;
      --gold: #7147c6;
      --gold-soft: #f1ebff;
      --gold-border: #c7b5ee;
      --line-dark: rgba(57, 57, 92, 0.12);
      --line-paper: rgba(57, 57, 92, 0.12);
      --easy-bg: #e4f7e9;
      --easy-fg: #24733b;
      --med-bg: #fff3d4;
      --med-fg: #94620c;
      --hard-bg: #ffe6e3;
      --hard-fg: #bd4137;
      --radius-xl: 27px;
      --radius-lg: 23px;
      --radius-md: 17px;
      --radius-sm: 13px;
    }

    body {
      background-color: var(--bg-void);
      background-image: radial-gradient(rgba(69, 107, 138, 0.11) 1.5px, transparent 1.5px);
      background-size: 24px 24px;
      color: var(--ink-dark);
    }
    .topbar {
      background: rgba(223, 242, 244, 0.92);
      border-bottom: 1px solid rgba(57, 57, 92, 0.08);
      backdrop-filter: blur(12px);
    }
    .topbar-inner { max-width: 1180px; padding: 0.8rem 1.35rem; }
    .brand { gap: 0.7rem; }
    .brand-mark {
      width: 46px;
      height: 46px;
      border: 3px solid #fff;
      border-radius: 16px;
      background: #ff5b50;
      color: #281e3d;
      font: 800 1.45rem/1 var(--font-sans);
      box-shadow: 0 4px 0 #c6d3d5;
    }
    .brand-title { font: 800 1.35rem/1.1 var(--font-sans); letter-spacing: -0.04em; }
    .brand-sub { color: var(--ink-dark-muted); font-weight: 600; }
    .header-actions { gap: 0.5rem; }
    .pill-stat {
      background: #fff;
      border: 2px solid #ded2f6;
      padding: 0.45rem 0.9rem;
      color: var(--ink-dark);
      font: 700 0.8rem var(--font-sans);
    }

    .hero {
      max-width: 1180px;
      margin: 2.4rem auto 1.6rem;
      padding: 0 1.35rem;
      grid-template-columns: minmax(0, 1fr) 260px;
      align-items: center;
      gap: 1.4rem;
    }
    .eyebrow {
      color: #7147c6;
      font-size: 0.78rem;
      letter-spacing: 0.09em;
      margin-bottom: 0.45rem;
    }
    .hero h1 {
      color: #30264f;
      font: 800 clamp(2rem, 4vw, 2.8rem)/1.12 var(--font-sans);
      letter-spacing: -0.045em;
      margin-bottom: 0.7rem;
    }
    .hero p { color: #62657b; font-size: 1rem; max-width: 720px; }
    .hero-meta-box {
      position: relative;
      overflow: hidden;
      background: #fff;
      border: 0;
      border-radius: 22px;
      padding: 1.2rem 1.3rem;
      box-shadow: 0 6px 0 #c7d4d7;
    }
    .hero-meta-box::after {
      content: "✓";
      position: absolute;
      right: 1rem;
      bottom: 0.35rem;
      color: #f2eaff;
      font-size: 4.5rem;
      font-weight: 800;
      line-height: 1;
    }
    .hero-meta-label { color: #77758b; font-weight: 700; }
    .url-preview { position: relative; z-index: 1; color: #7147c6; font: 700 0.95rem/1.5 var(--font-sans); }

    .container { max-width: 1180px; padding: 0 1.35rem; margin-bottom: 4rem; }
    .grade-nav {
      grid-template-columns: repeat(6, minmax(0, 1fr));
      gap: 0.8rem;
      margin-bottom: 1.35rem;
    }
    .grade-tab {
      min-height: 122px;
      display: flex;
      flex-direction: column;
      align-items: flex-start;
      justify-content: center;
      gap: 0.7rem;
      background: #fff;
      border: 2px solid transparent;
      border-radius: 21px;
      padding: 0.85rem 1rem;
      color: #30264f;
      box-shadow: 0 5px 0 #cbd7d9;
      text-align: left;
      transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
    }
    .grade-tab:hover { border-color: #c9b8ee; transform: translateY(-2px); }
    .grade-tab.active {
      background: #fff;
      border-color: #8056ce;
      color: #30264f;
      box-shadow: 0 5px 0 #c4b1e9;
    }
    .grade-icon {
      width: 43px;
      height: 43px;
      display: grid;
      place-items: center;
      border: 3px solid #fff;
      border-radius: 15px;
      background: var(--grade-accent, #ff5b50);
      color: #291f3f;
      box-shadow: 0 4px 0 #d6dcdd;
      font-size: 1.15rem;
      font-weight: 800;
    }
    .grade-tab:nth-child(2) .grade-icon,
    .grade-tab:nth-child(4) .grade-icon,
    .grade-tab:nth-child(5) .grade-icon,
    .grade-tab:nth-child(6) .grade-icon { color: #fff; }
    .grade-tab:nth-child(3) .grade-icon { color: #342844; }
    .grade-tab .g-label { font: 800 1.02rem/1.1 var(--font-sans); }
    .grade-tab .g-meta { margin-top: -0.5rem; color: #77758b; font-size: 0.72rem; font-weight: 600; }

    .toolbar {
      margin-bottom: 1.5rem;
      padding: 1.25rem 1.35rem;
      background: #fff;
      border: 0;
      border-radius: 22px;
      box-shadow: 0 5px 0 #cbd7d9;
    }
    .syllabus-banner {
      background: #f4efff;
      border: 1px solid #e5dcf7;
      border-radius: 13px;
      color: #53446f;
      padding: 0.72rem 0.95rem;
      font-size: 0.88rem;
      font-weight: 600;
    }
    select, .search-box {
      height: 46px;
      border: 2px solid #e3e1eb;
      border-radius: 13px;
      background: #fff;
      color: #30264f;
      font: 600 0.9rem var(--font-sans);
    }
    select:focus, .search-box:focus { border-color: #8056ce; }
    .search-box::placeholder { color: #8b8999; }
    .page-indicator { color: #6a6880; font: 700 0.82rem var(--font-sans); }

    .q-card {
      padding: 1.55rem 1.65rem;
      background: #fff;
      border: 0;
      border-radius: 24px;
      box-shadow: 0 5px 0 #cbd7d9;
      transition: transform 0.18s ease, box-shadow 0.18s ease;
    }
    .q-card:hover { transform: translateY(-2px); box-shadow: 0 7px 0 #c3d0d2; }
    .q-num { border: 0; border-radius: 9px; background: #f0ebfb; color: #5f4692; font-family: var(--font-sans); }
    .q-topic { color: #6b6a7c; }
    .q-stem {
      border-left: 0;
      padding: 0;
      margin-bottom: 1.2rem;
      color: #30264f;
      font: 800 clamp(1.2rem, 2vw, 1.5rem)/1.45 var(--font-sans);
      letter-spacing: -0.02em;
    }
    .q-visual { background: #f8fbfc; border: 1px solid #e8edef; border-radius: 16px; }
    .options-list { gap: 0.75rem; }
    .opt-btn {
      min-height: 54px;
      gap: 0.7rem;
      padding: 0.75rem 0.9rem;
      border: 2px solid #e7e5ed;
      border-radius: 15px;
      background: #fff;
      color: #30264f;
      font-weight: 700;
    }
    .opt-btn::before {
      content: counter(option);
      counter-increment: option;
      width: 27px;
      height: 27px;
      flex: 0 0 27px;
      display: grid;
      place-items: center;
      border-radius: 50%;
      background: #f1edfa;
      color: #7147c6;
      font-size: 0.78rem;
    }
    .options-list { counter-reset: option; }
    .opt-btn:hover { border-color: #8c67d3; background: #faf8ff; }
    .opt-btn.correct { background: #e6f7ea; border-color: #72c486; color: #216b36; }
    .opt-btn.wrong { background: #fff0ee; border-color: #ef8c81; color: #a53d33; }
    .opt-btn.correct::before { background: #c9efd2; color: #216b36; }
    .opt-btn.wrong::before { background: #ffd9d4; color: #a53d33; }
    .q-footer { border-top-color: #eceaf1; }
    .sol-btn { color: #7047c1; font-weight: 800; }
    .sol-panel { background: #f5f1fc; border-left-color: #8056ce; border-radius: 13px; color: #5d5c70; }
    .sol-ans { color: #30264f; }

    .pagination-wrap { margin-top: 1.8rem; }
    .pg-btn {
      min-width: 44px;
      height: 44px;
      border: 2px solid #ded9e9;
      border-radius: 14px;
      background: #fff;
      color: #393052;
      font: 700 0.86rem var(--font-sans);
      box-shadow: 0 3px 0 #cbd7d9;
    }
    .pg-btn:hover:not(:disabled) { border-color: #8056ce; color: #7047c1; }
    .pg-btn.active { background: #7548ca; border-color: #7548ca; color: #fff; box-shadow: 0 3px 0 #5734a2; }
    .pg-btn:disabled { box-shadow: none; }
    .toast { background: #30264f; border: 0; border-radius: 13px; color: #fff; }
    .library-mode .hero-meta-box { display: none; }

    .library-container {
      max-width: 1180px;
      margin: 0 auto 4rem;
      padding: 0 1.35rem;
    }
    .library-container[hidden], .practice-container[hidden] { display: none; }
    [hidden] { display: none !important; }
    .library-panel {
      padding: clamp(1.2rem, 3vw, 2rem);
      background: #fff;
      border-radius: 24px;
      box-shadow: 0 5px 0 #cbd7d9;
      margin-bottom: 1.25rem;
    }
    .library-section-title {
      display: flex;
      align-items: center;
      gap: 1rem;
      margin-bottom: 1.15rem;
      color: #30264f;
      font: 800 clamp(1.35rem, 3vw, 1.75rem)/1.2 var(--font-sans);
    }
    .library-section-title::after {
      content: "";
      height: 7px;
      flex: 1;
      min-width: 28px;
      background: repeating-linear-gradient(90deg, #c0a9eb 0 16px, transparent 16px 27px);
    }
    .library-breadcrumb {
      display: flex;
      flex-wrap: wrap;
      align-items: center;
      gap: 0.45rem;
      margin: 0.2rem 0 1rem;
      color: #747185;
      font-size: 0.88rem;
      font-weight: 700;
    }
    .library-breadcrumb a, .article-back-link {
      color: #7047c1;
      text-decoration: none;
    }
    .library-breadcrumb a:hover, .article-back-link:hover { text-decoration: underline; }
    .library-grid {
      display: grid;
      grid-template-columns: repeat(3, minmax(0, 1fr));
      gap: 1rem;
    }
    .library-card {
      position: relative;
      display: flex;
      flex-direction: column;
      align-items: flex-start;
      min-height: 170px;
      padding: 1.2rem;
      overflow: hidden;
      border: 2px solid #f0eef5;
      border-radius: 20px;
      background: #fff;
      box-shadow: 0 4px 0 #d2dcde;
      color: #30264f;
      text-decoration: none;
      transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
    }
    .library-card:hover { transform: translateY(-3px); border-color: #c9b8ee; box-shadow: 0 7px 0 #cbd7d9; }
    .library-card-icon {
      display: grid;
      place-items: center;
      width: 48px;
      height: 48px;
      margin-bottom: 0.8rem;
      border: 3px solid #fff;
      border-radius: 16px;
      background: #ff6558;
      box-shadow: 0 4px 0 #d6dcdd;
      color: #342844;
      font-size: 1.08rem;
      font-weight: 800;
    }
    .library-card:nth-child(3n + 2) .library-card-icon { background: #7548ca; color: #fff; }
    .library-card:nth-child(3n) .library-card-icon { background: #f3bb4c; }
    .library-card h3 { margin-bottom: 0.4rem; font-size: 1.08rem; line-height: 1.35; }
    .library-card p { color: #747185; font-size: 0.86rem; line-height: 1.55; }
    .library-card .card-link-label { margin-top: auto; padding-top: 0.8rem; color: #7147c6; font-size: 0.84rem; font-weight: 800; }
    .library-actions { display: flex; flex-wrap: wrap; gap: 0.7rem; margin-top: 1.1rem; }
    .article-index-links { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.65rem; }
    .article-index-link {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 0.75rem;
      padding: 0.85rem 1rem;
      border: 2px solid #f0eef5;
      border-radius: 14px;
      color: #4f3b78;
      font-weight: 750;
      line-height: 1.4;
      text-decoration: none;
    }
    .article-index-link:hover { border-color: #c9b8ee; background: #faf8ff; }
    .article-practice-callout {
      margin: 1.2rem 0;
      padding: 1.15rem;
      border: 2px solid #d6c9f2;
      border-radius: 18px;
      background: #f8f5ff;
    }
    .article-practice-callout h2 { margin: 0 0 0.35rem; color: #30264f; font-size: 1.15rem; }
    .article-practice-callout p { margin-bottom: 0.8rem; }
    .library-action {
      display: inline-flex;
      align-items: center;
      justify-content: center;
      min-height: 46px;
      padding: 0.65rem 1.05rem;
      border: 2px solid #7548ca;
      border-radius: 999px;
      background: #7548ca;
      color: #fff;
      text-decoration: none;
      font-weight: 800;
      transition: transform 0.16s ease, background 0.16s ease;
    }
    .library-action:hover { transform: translateY(-2px); background: #6037b3; }
    .library-action.secondary { background: #fff; color: #7047c1; }
    .library-action.secondary:hover { background: #f8f5ff; }
    .article-layout { display: grid; grid-template-columns: minmax(0, 1fr) 260px; gap: 1.2rem; align-items: start; }
    .article-copy { color: #4f4d63; font-size: 1rem; line-height: 1.8; }
    .article-copy h2 { margin: 1.5rem 0 0.55rem; color: #30264f; font-size: 1.3rem; line-height: 1.35; }
    .article-copy h2:first-child { margin-top: 0; }
    .article-copy p { margin: 0 0 0.8rem; }
    .article-copy ul { margin: 0 0 1rem 1.3rem; }
    .article-copy li { padding-left: 0.25rem; margin: 0.2rem 0; }
    .article-copy ol { margin: 0.2rem 0 1rem 1.3rem; }
    .article-copy ol li { padding-left: 0.25rem; margin: 0.3rem 0; }
    .article-lead { color: #51466a; font-size: 1.08rem; line-height: 1.75; }
    .article-toc {
      display: flex;
      flex-wrap: wrap;
      gap: 0.55rem;
      margin: 0.9rem 0 1.35rem;
    }
    .article-toc a {
      padding: 0.4rem 0.7rem;
      border-radius: 999px;
      background: #f4efff;
      color: #63489a;
      font-size: 0.82rem;
      font-weight: 700;
      text-decoration: none;
    }
    .article-callout {
      margin: 1rem 0;
      padding: 1rem 1.1rem;
      border: 1px solid #e6ddf7;
      border-radius: 14px;
      background: #faf8ff;
    }
    .article-callout strong { color: #30264f; }
    .math-example {
      margin: 1rem 0;
      padding: 1rem 1.1rem;
      border-left: 4px solid #8056ce;
      border-radius: 0 14px 14px 0;
      background: #f4efff;
      color: #44375f;
      font-weight: 700;
    }
    .article-aside {
      padding: 1.1rem;
      border-radius: 18px;
      background: #f4efff;
      color: #51466a;
    }
    .article-aside h2 { margin-bottom: 0.5rem; color: #30264f; font-size: 1rem; }
    .article-aside a { display: block; padding: 0.45rem 0; color: #7047c1; font-weight: 700; text-decoration: none; }
    .article-aside a:hover { text-decoration: underline; }
    .article-aside .article-action {
      display: inline-flex;
      margin-top: 0.75rem;
      padding: 0.55rem 0.8rem;
      border-radius: 999px;
      background: #7548ca;
      color: #fff;
    }
    .article-practice, .article-faq {
      margin-top: 1.4rem;
      padding-top: 1rem;
      border-top: 1px solid #eceaf1;
    }
    .article-practice details, .article-faq details {
      margin: 0.6rem 0;
      padding: 0.75rem 0.9rem;
      border: 1px solid #e8e4ef;
      border-radius: 13px;
      background: #fff;
    }
    .article-practice summary, .article-faq summary {
      color: #40345d;
      font-weight: 700;
      cursor: pointer;
    }
    .article-practice details p, .article-faq details p { margin: 0.6rem 0 0; }
    .article-footer {
      display: flex;
      justify-content: space-between;
      gap: 1rem;
      flex-wrap: wrap;
      margin-top: 1.4rem;
      padding-top: 1rem;
      border-top: 1px solid #eceaf1;
    }
    .number-line {
      display: flex;
      align-items: center;
      gap: 0.65rem;
      max-width: 100%;
      margin: 1.1rem 0;
      padding: 0.6rem 0.3rem 0.8rem;
      overflow-x: auto;
      overscroll-behavior-x: contain;
    }
    .number-line button {
      position: relative;
      z-index: 1;
      flex: 0 0 46px;
      min-height: 48px;
      border: 2px solid #e6e2ef;
      border-radius: 14px;
      background: #fff;
      color: #30264f;
      font: 800 1rem var(--font-sans);
      box-shadow: 0 3px 0 #d2dcde;
      cursor: pointer;
    }
    .number-line button:not(:last-child)::after {
      content: "";
      position: absolute;
      z-index: -1;
      top: 50%;
      left: 100%;
      width: 0.65rem;
      height: 3px;
      background: #c9b8ee;
    }
    .number-line button:hover { border-color: #8056ce; color: #7047c1; }
    .number-line button.correct { background: #e4f7e9; border-color: #72c486; color: #216b36; }
    .number-line button.wrong { background: #fff0ee; border-color: #ef8c81; color: #a53d33; }
    .number-line-feedback { min-height: 1.6em; color: #51466a; font-weight: 700; }

    @media (max-width: 820px) {
      .hero { grid-template-columns: 1fr; margin-top: 1.6rem; }
      .hero-meta-box { display: none; }
      .grade-nav { grid-template-columns: repeat(3, minmax(0, 1fr)); }
      .library-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
      .study-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
      .article-index-links { grid-template-columns: 1fr; }
      .article-layout { grid-template-columns: 1fr; }
    }
    @media (max-width: 600px) {
      .topbar-inner { padding: 0.65rem 1rem; }
      .brand-sub { font-size: 0.68rem; }
      .hero, .container { padding: 0 1rem; }
      .hero h1 { font-size: 2rem; }
      .grade-nav { gap: 0.55rem; }
      .grade-tab { min-height: 104px; padding: 0.7rem; border-radius: 17px; }
      .grade-tab .g-label { font-size: 0.88rem; }
      .grade-tab .g-meta { font-size: 0.66rem; }
      .toolbar { padding: 1rem; }
      .filter-controls { flex-direction: column; }
      select, .search-box { width: 100%; }
      .q-card { padding: 1.2rem; }
      .library-container { padding: 0 1rem; }
      .library-grid { grid-template-columns: 1fr; }
      .study-grid { grid-template-columns: 1fr; }
      .library-card { min-height: 145px; }
    }
    @media (prefers-reduced-motion: reduce) {
      *, *::before, *::after { scroll-behavior: auto !important; transition-duration: 0.01ms !important; }
    }

/* === Grades 1-13 Visual Study Enhancements === */
.study-grade-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 1rem;
  padding-bottom: 0.85rem;
  border-bottom: 2px solid #f0eef5;
}
.study-grade-title {
  font-size: 1.35rem;
  font-weight: 800;
  color: #30264f;
  margin: 0;
}
.study-grade-scope {
  color: #525d73;
  font-size: 0.92rem;
  margin: 0.25rem 0 0;
}
.study-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-bottom: 0.9rem;
}
.study-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.48rem 0.82rem;
  border-radius: 999px;
  border: 2px solid #e6e2ef;
  background: #ffffff;
  color: #40345d;
  font-size: 0.84rem;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.14s ease, border-color 0.14s ease, background 0.14s ease, color 0.14s ease;
}
.study-pill:hover {
  border-color: #7548ca;
  color: #7548ca;
  transform: translateY(-1px);
}
.study-pill.active {
  background: #7548ca;
  border-color: #7548ca;
  color: #ffffff;
  box-shadow: 0 3px 10px rgba(117, 72, 202, 0.28);
}
.study-pill-count {
  font-size: 0.76rem;
  opacity: 0.82;
}
.study-filter-bar {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}
.study-search-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}
.study-search {
  flex: 1 1 280px;
  max-width: 440px;
  padding: 0.65rem 1rem;
  border: 2px solid #e6e2ef;
  border-radius: 12px;
  font-size: 0.92rem;
  font-family: var(--font-sans);
  color: #141923;
  background: #ffffff;
}
.study-search:focus {
  outline: none;
  border-color: #7548ca;
}
.study-result-meta {
  font-size: 0.85rem;
  font-weight: 700;
  color: #525d73;
}
.study-card-svg-thumb {
  width: 100%;
  margin: 0.55rem 0 0.65rem;
  padding: 0.45rem;
  border-radius: 12px;
  background: #f8f6fc;
  border: 1px solid #ece8f6;
  color: #1e293b;
}
.study-card-svg-thumb svg {
  max-height: 120px;
  width: 100%;
  height: auto;
  display: block;
}
.study-card-formula {
  display: inline-block;
  margin-top: 0.35rem;
  padding: 0.25rem 0.55rem;
  border-radius: 8px;
  background: #f4efff;
  color: #3b2273;
  font-size: 0.85rem;
  font-weight: 600;
  max-width: 100%;
  overflow-x: auto;
}
.study-ref-diagram {
  margin: 1rem 0 1.25rem;
  padding: 1rem;
  border-radius: 16px;
  background: #fbf9f5;
  border: 2px solid #e6e2ef;
  color: #141923;
  text-align: center;
}
.study-ref-diagram svg {
  max-width: 420px;
  width: 100%;
  height: auto;
  display: block;
  margin: 0 auto;
}
.study-formula-banner {
  margin: 0.75rem 0 1rem;
  padding: 0.85rem 1.15rem;
  border-left: 4px solid #7548ca;
  border-radius: 0 12px 12px 0;
  background: #f4efff;
  color: #241942;
  font-size: 1.05rem;
  font-weight: 700;
  overflow-x: auto;
}
.study-loading {
  grid-column: 1 / -1;
  padding: 3rem 1rem;
  text-align: center;
  color: #525d73;
  font-weight: 700;
}

/* Global Print Watermark */
@media print {
  @page { size: auto; margin: 12mm; }
  body {
    background: #fff !important;
    color: #000 !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }
  body::before {
    content: "MathPath.study" !important;
    position: fixed !important;
    top: 50% !important;
    left: 50% !important;
    transform: translate(-50%, -50%) rotate(-28deg) !important;
    font-size: 4.2rem !important;
    font-weight: 800 !important;
    letter-spacing: 0.12em !important;
    color: rgba(148, 163, 184, 0.14) !important;
    white-space: nowrap !important;
    pointer-events: none !important;
    z-index: 9999 !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }
  .topbar, .no-print, .study-filter-bar, .pagination-wrap, .toast {
    display: none !important;
  }
}
