@import url("https://fonts.googleapis.com/css2?family=DM+Mono:wght@400;500&family=Manrope:wght@400;500;600;700;800&family=Playfair+Display:wght@600;700&display=swap");

:root {
  --ink: #102c2d;
  --ink-soft: #173d3b;
  --rail: #103331;
  --rail-deep: #0c2929;
  --paper: #f4f2ea;
  --surface: #fbfaf4;
  --surface-green: #eff4e7;
  --line: #d4d5ca;
  --muted: #69736e;
  --green: #2a7554;
  --lime: #d6f34f;
  --lime-soft: #f0f8c7;
  --danger: #9c4c3f;
  --shadow: rgba(16, 44, 45, .09);
  font-family: "Manrope", Arial, sans-serif;
  color: var(--ink);
  background: var(--paper);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; min-width: 320px; background: var(--paper); }
button, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
button:disabled { cursor: wait; opacity: .58; }
a { color: inherit; }
svg { fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.7; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.skip-link { position: fixed; z-index: 100; top: 10px; left: 10px; transform: translateY(-150%); padding: 10px 14px; background: var(--lime); color: var(--ink); font-size: 12px; font-weight: 800; text-decoration: none; }
.skip-link:focus { transform: none; }

.lms-shell { min-height: 100vh; display: grid; grid-template-columns: 220px minmax(0, 1fr); }
.side-rail { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; overflow: auto; background: linear-gradient(160deg, var(--rail) 0%, var(--rail-deep) 100%); color: #f4f3e9; }
.rail-brand { min-height: 72px; display: flex; align-items: center; gap: 11px; padding: 0 20px; border-bottom: 1px solid rgba(255,255,255,.13); color: #fff; text-decoration: none; }
.brand-sign { width: 38px; height: 38px; display: grid; place-items: center; flex: 0 0 auto; border: 1px solid var(--lime); border-radius: 50%; color: var(--lime); font: 500 22px/1 "DM Mono", monospace; }
.rail-brand strong { font-size: 14px; letter-spacing: -.3px; }

.rail-progress { padding: 34px 22px 25px; text-align: center; }
.rail-progress > p, .week-summary > p { margin: 0 0 13px; color: var(--lime); font: 500 9px/1.2 "DM Mono", monospace; letter-spacing: .12em; text-transform: uppercase; text-align: left; }
.progress-ring { position: relative; width: 91px; height: 91px; margin: 0 auto 12px; }
.progress-ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.progress-ring circle { fill: none; stroke-width: 6; }
.ring-track { stroke: rgba(255,255,255,.16); }
.ring-value { stroke: var(--lime); stroke-dasharray: 213.63; stroke-dashoffset: 213.63; transition: stroke-dashoffset .35s ease; }
.progress-ring strong { position: absolute; inset: 0; display: grid; place-items: center; color: #fff; font: 600 20px "DM Mono", monospace; }
.rail-progress > span { color: #d8dfda; font-size: 11px; }

.week-summary { margin: 0 22px; padding: 22px 0 27px; border-top: 1px solid rgba(255,255,255,.13); }
.week-summary strong, .week-summary span { display: block; }
.week-summary strong { color: #fff; font: 500 20px/1.2 "DM Mono", monospace; }
.week-summary span { margin-top: 7px; color: #d8dfda; font-size: 11px; }
.week-summary i { display: block; height: 5px; margin-top: 15px; overflow: hidden; background: rgba(255,255,255,.15); border-radius: 5px; }
.week-summary i b { display: block; width: 0; height: 100%; background: var(--lime); transition: width .3s ease; }

.rail-nav { display: grid; gap: 3px; padding: 9px 10px; }
.rail-nav a, .rail-nav button, .rail-settings { min-height: 47px; display: flex; align-items: center; gap: 14px; padding: 0 14px; border: 0; border-radius: 2px; background: transparent; color: #e6ebe7; font-size: 12px; text-align: left; text-decoration: none; }
.rail-nav a:hover, .rail-nav button:hover, .rail-settings:hover { background: rgba(255,255,255,.07); }
.rail-nav .active, .rail-nav button.active { background: rgba(214,243,79,.12); color: var(--lime); }
.rail-nav svg, .rail-settings svg { width: 21px; height: 21px; flex: 0 0 auto; stroke-width: 1.6; }
.rail-settings { margin: auto 18px 20px; border: 1px solid rgba(255,255,255,.27); }

.page-shell { min-width: 0; }
.topbar { position: sticky; z-index: 20; top: 0; height: 72px; display: flex; align-items: center; justify-content: space-between; padding: 0 30px 0 38px; border-bottom: 1px solid var(--line); background: rgba(244,242,234,.96); backdrop-filter: blur(12px); }
.topbar nav { height: 100%; display: flex; gap: 34px; }
.topbar nav a { position: relative; display: grid; place-items: center; color: var(--ink); font-size: 13px; text-decoration: none; }
.topbar nav a::after { content: ""; position: absolute; right: 0; bottom: -1px; left: 0; height: 2px; transform: scaleX(0); background: var(--green); transition: transform .15s ease; }
.topbar nav a:hover::after, .topbar nav a.active::after { transform: scaleX(1); }
.topbar nav a.active { font-weight: 800; }
.topbar-actions { display: flex; align-items: center; gap: 17px; }
.topbar-actions > span { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 9px; }
.topbar-actions > span i { width: 7px; height: 7px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 4px rgba(42,117,84,.1); }
.topbar-actions > span.saving i { background: #d6aa3e; }
.topbar-actions > span.error i { background: var(--danger); }
.topbar-actions a { width: 34px; height: 34px; display: grid; place-items: center; border: 1px solid var(--line); text-decoration: none; }
.topbar-actions svg { width: 18px; height: 18px; }
.mobile-brand { display: none; align-items: center; gap: 9px; text-decoration: none; }
.mobile-brand .brand-sign { width: 33px; height: 33px; background: var(--ink); font-size: 18px; }
.mobile-brand strong { font-size: 13px; }

.course-layout { display: grid; grid-template-columns: minmax(560px, 1fr) 410px; min-height: calc(100vh - 72px); }
.course-main { min-width: 0; padding: 36px 36px 70px; border-right: 1px solid var(--lime); }
.route-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; }
.route-heading h1 { margin: 0; font: 700 clamp(38px, 3.4vw, 54px)/.98 "Playfair Display", Georgia, serif; letter-spacing: -.045em; }
.route-heading p { margin: 10px 0 0; color: var(--muted); font-size: 13px; }
.route-heading > span { margin-bottom: 4px; color: var(--green); font: 500 9px "DM Mono", monospace; letter-spacing: .08em; text-transform: uppercase; }

.continue-band { min-height: 168px; margin-top: 28px; border: 1px solid var(--line); background: rgba(251,250,244,.54); }
.continue-grid { min-height: 166px; display: grid; grid-template-columns: minmax(0, 1fr) 220px; align-items: center; gap: 26px; padding: 24px; }
.continue-copy > p { margin: 0 0 15px; color: var(--green); font: 500 9px "DM Mono", monospace; letter-spacing: .12em; text-transform: uppercase; }
.continue-copy h2 { margin: 0; font: 700 28px/1.07 "Playfair Display", Georgia, serif; letter-spacing: -.035em; }
.continue-progress { display: flex; align-items: center; gap: 15px; margin-top: 23px; }
.continue-progress span { color: var(--ink); font-size: 11px; }
.continue-progress i { width: min(230px, 45%); height: 3px; overflow: hidden; background: #ddddd3; }
.continue-progress b { display: block; height: 100%; background: var(--lime); }
.continue-actions { display: grid; gap: 8px; }
.primary-action, .secondary-action { min-height: 44px; display: flex; align-items: center; justify-content: center; gap: 10px; border: 1px solid var(--ink); border-radius: 2px; font-size: 11px; font-weight: 800; }
.primary-action { background: var(--lime); color: var(--ink); }
.primary-action:hover { background: #e2f986; }
.secondary-action { background: var(--ink); color: #fff; }
.secondary-action:hover { background: var(--ink-soft); }
.primary-action svg, .secondary-action svg { width: 17px; height: 17px; }
.skip-link-button { min-height: 30px; border: 0; background: transparent; color: var(--ink); font-size: 10px; text-align: right; }
.skip-link-button:hover { color: var(--green); text-decoration: underline; }
.loading-line, .detail-loading { padding: 30px; color: var(--muted); font-size: 12px; }

.course-map { margin-top: 34px; scroll-margin-top: 90px; }
.map-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; }
.map-heading h2 { margin: 0; font: 700 24px/1.1 "Playfair Display", Georgia, serif; letter-spacing: -.035em; }
.map-heading p { margin: 7px 0 0; color: var(--muted); font-size: 10px; }
.topic-search { width: 190px; min-height: 38px; display: flex; align-items: center; gap: 8px; padding: 0 10px; border: 1px solid var(--line); background: var(--surface); }
.topic-search:focus-within { border-color: var(--green); box-shadow: 0 0 0 3px rgba(42,117,84,.09); }
.topic-search svg { width: 16px; height: 16px; color: var(--green); }
.topic-search input { min-width: 0; width: 100%; border: 0; outline: 0; background: transparent; color: var(--ink); font-size: 10px; }
.topic-search input::placeholder { color: #939a95; }

.filter-row { display: flex; align-items: center; gap: 8px; margin: 19px 0 14px; }
.filter-row button { min-height: 34px; padding: 0 13px; border: 1px solid var(--line); border-radius: 2px; background: transparent; color: var(--ink); font-size: 10px; }
.filter-row button:hover { border-color: var(--green); }
.filter-row button.active { border-color: var(--ink); background: var(--ink); color: var(--lime); }
.filter-row span { margin-left: auto; color: var(--muted); font-size: 9px; }

.module-list { display: grid; gap: 9px; }
.course-module { border: 1px solid var(--line); background: rgba(251,250,244,.45); }
.module-toggle { width: 100%; min-height: 57px; display: grid; grid-template-columns: 28px 28px minmax(0,1fr) auto 21px; align-items: center; gap: 8px; padding: 0 15px; border: 0; background: transparent; color: var(--ink); text-align: left; }
.module-toggle:hover { background: rgba(255,255,255,.4); }
.module-chevron { width: 17px; height: 17px; transition: transform .16s ease; }
.course-module.open .module-chevron { transform: rotate(90deg); }
.module-week { color: var(--green); font: 500 10px "DM Mono", monospace; }
.module-toggle strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }
.module-meta { color: var(--muted); font-size: 9px; white-space: nowrap; }
.module-percent { color: var(--green); font: 500 10px "DM Mono", monospace; }
.topic-list { border-top: 1px solid var(--line); }
.topic-list[hidden] { display: none; }
.topic-row { position: relative; width: 100%; min-height: 51px; display: grid; grid-template-columns: 25px 38px minmax(170px,1fr) 38px 72px 76px 18px; align-items: center; gap: 7px; padding: 0 15px; border: 0; border-bottom: 1px solid var(--line); background: rgba(255,255,255,.25); color: var(--ink); text-align: left; }
.topic-row:last-child { border-bottom: 0; }
.topic-row:hover { background: #f8f9ef; }
.topic-row.selected { background: linear-gradient(90deg, var(--lime-soft), rgba(240,248,199,.42)); box-shadow: inset 0 0 0 1px #87a82a; }
.status-mark { width: 16px; height: 16px; display: grid; place-items: center; border: 1px solid #cad0c3; border-radius: 50%; color: #fff; font-size: 9px; }
.status-mark.active { border-color: var(--green); background: var(--green); box-shadow: 0 0 0 3px rgba(42,117,84,.09); }
.status-mark.completed { border-color: var(--green); background: var(--green); }
.status-mark.skipped { color: var(--muted); background: #ebece3; }
.topic-index, .topic-stage { font: 500 9px "DM Mono", monospace; }
.topic-index { color: var(--muted); }
.topic-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 10.5px; }
.topic-frequency, .topic-status { color: var(--muted); font-size: 9px; }
.topic-status.completed { color: var(--green); }
.topic-status.skipped { color: #7d7c77; }
.row-arrow { width: 15px; height: 15px; color: var(--green); }
.empty-results { padding: 30px 20px; border: 1px solid var(--line); color: var(--muted); font-size: 11px; line-height: 1.6; }

.topic-detail { position: sticky; top: 72px; align-self: start; height: calc(100vh - 72px); overflow-y: auto; padding: 35px 30px 42px; background: #f8f6ef; }
.detail-close { display: none; position: absolute; top: 14px; right: 14px; width: 36px; height: 36px; place-items: center; border: 1px solid var(--line); background: var(--surface); }
.detail-close svg { width: 17px; height: 17px; }
.detail-head { padding-bottom: 26px; border-bottom: 1px solid var(--line); }
.detail-title-line { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.detail-title-line h2 { margin: 0; font: 700 24px/1.08 "Playfair Display", Georgia, serif; letter-spacing: -.03em; }
.detail-title-line b { flex: 0 0 auto; font: 500 11px "DM Mono", monospace; }
.detail-meta { display: flex; gap: 9px; margin-top: 10px; color: var(--muted); font-size: 9px; }
.detail-meta span + span::before { content: "•"; margin-right: 9px; }
.theory-progress { margin-top: 17px; }
.theory-progress > div { display: flex; justify-content: space-between; color: var(--muted); font-size: 9px; }
.theory-progress i { display: grid; grid-template-columns: repeat(4,1fr); gap: 4px; margin-top: 8px; }
.theory-progress i b { height: 3px; background: #dadbd2; }
.theory-progress i b.on { background: var(--lime); }
.detail-section { padding: 25px 0; border-bottom: 1px solid var(--line); }
.detail-section h3 { margin: 0 0 13px; font-size: 13px; letter-spacing: -.25px; }
.detail-section p, .detail-section li { color: #3f4f4b; font-size: 10.5px; line-height: 1.6; }
.detail-section p { margin: 0; }
.detail-section ul { margin: 0; padding-left: 18px; }
.detail-section li + li { margin-top: 6px; }
.theory-done { width: 100%; min-height: 38px; margin-top: 16px; border: 1px solid var(--green); background: transparent; color: var(--green); font-size: 10px; font-weight: 800; }
.theory-done:hover { background: var(--surface-green); }
.adaptive-start-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; margin-top: 16px; }
.adaptive-start-actions button { min-height: 40px; margin: 0; border: 1px solid var(--ink); background: transparent; color: var(--ink); font-size: 9px; font-weight: 800; }
.adaptive-start-actions .theory-done { border-color: var(--lime); background: var(--lime); color: var(--ink); }
.adaptive-start-actions button:hover { border-color: var(--green); background: var(--surface-green); color: var(--green); }
.practice-section { padding-top: 25px; }
.practice-section h3 { margin: 0 0 13px; font-size: 13px; }
.practice-list { display: grid; gap: 7px; }
.practice-row { min-height: 49px; display: grid; grid-template-columns: minmax(0,1fr) 34px 70px; align-items: center; gap: 9px; padding: 0 10px; border: 1px solid var(--line); background: rgba(255,255,255,.28); }
.practice-row div strong, .practice-row div small { display: block; }
.practice-row div strong { font-size: 10px; }
.practice-row div small { margin-top: 2px; color: var(--muted); font-size: 8px; }
.practice-row > span { font: 500 9px "DM Mono", monospace; }
.practice-row button { min-height: 30px; border: 1px solid var(--ink); background: transparent; color: var(--ink); font-size: 9px; font-weight: 700; }
.practice-row button:hover { background: var(--ink); color: var(--lime); }
.detail-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; margin-top: 27px; }
.detail-actions button { min-height: 43px; padding: 0 10px; border: 1px solid var(--line); background: transparent; color: var(--ink); font-size: 9px; font-weight: 700; }
.detail-actions button:hover { border-color: var(--green); color: var(--green); }
.detail-actions button.primary { border-color: var(--ink); background: var(--ink); color: #fff; }
.detail-actions button.primary:hover { color: var(--lime); }
.detail-actions button.full { grid-column: 1/-1; }
.detail-actions button.danger { color: var(--danger); }

.mobile-nav { display: none; }
.skip-dialog { width: min(470px, calc(100% - 32px)); padding: 0; border: 1px solid var(--ink); background: var(--surface); color: var(--ink); box-shadow: 0 20px 80px rgba(0,0,0,.22); }
.skip-dialog::backdrop { background: rgba(8,28,29,.62); backdrop-filter: blur(2px); }
.skip-dialog form { position: relative; padding: 31px; }
.dialog-close { position: absolute; top: 12px; right: 12px; width: 34px; height: 34px; display: grid; place-items: center; border: 0; background: transparent; }
.dialog-close svg { width: 17px; height: 17px; }
.skip-dialog form > p { margin: 0 0 15px; color: var(--green); font: 500 9px "DM Mono", monospace; letter-spacing: .11em; text-transform: uppercase; }
.skip-dialog h2 { margin: 0; font: 700 25px/1.14 "Playfair Display", Georgia, serif; letter-spacing: -.03em; }
.skip-dialog form > div:not(.dialog-actions) { margin-top: 16px; color: var(--muted); font-size: 11px; line-height: 1.65; }
.dialog-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 26px; }
.dialog-actions button { min-height: 43px; border-radius: 2px; font-size: 10px; font-weight: 800; }
.dialog-actions .secondary { border: 1px solid var(--line); background: transparent; color: var(--ink); }
.dialog-actions .primary { border: 1px solid var(--ink); background: var(--ink); color: var(--lime); }

.toast { position: fixed; z-index: 80; right: 24px; bottom: 24px; min-width: 300px; max-width: calc(100% - 48px); min-height: 52px; display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 0 15px; transform: translateY(20px); border: 1px solid #6d8262; background: var(--ink); color: #fff; box-shadow: 0 10px 35px rgba(0,0,0,.2); opacity: 0; visibility: hidden; pointer-events: none; transition: transform .22s ease, opacity .22s ease, visibility .22s ease; }
.toast.show { transform: none; opacity: 1; visibility: visible; pointer-events: auto; }
.toast span { font-size: 10px; }
.toast button { border: 0; background: transparent; color: var(--lime); font-size: 9px; font-weight: 800; text-decoration: underline; }
.toast button:empty, .toast button[hidden] { display: none; }

@media (max-width: 1180px) {
  .lms-shell { grid-template-columns: 190px minmax(0,1fr); }
  .rail-brand { padding: 0 15px; }
  .rail-progress { padding-right: 17px; padding-left: 17px; }
  .week-summary { margin-right: 17px; margin-left: 17px; }
  .course-layout { grid-template-columns: minmax(500px,1fr) 350px; }
  .course-main { padding-right: 26px; padding-left: 26px; }
  .topic-detail { padding-right: 24px; padding-left: 24px; }
  .topic-row { grid-template-columns: 23px 34px minmax(150px,1fr) 34px 58px 65px 16px; padding: 0 12px; }
}

@media (max-width: 960px) {
  body { padding-bottom: 58px; }
  .lms-shell { display: block; }
  .side-rail { display: none; }
  .topbar { padding: 0 20px; }
  .topbar nav { gap: 24px; }
  .mobile-brand { display: flex; }
  .course-layout { display: block; }
  .course-main { padding: 32px 28px 65px; border-right: 0; }
  .topic-detail { position: fixed; z-index: 60; top: 0; right: 0; bottom: 0; width: min(470px, 100%); height: 100vh; padding-top: 54px; transform: translateX(105%); border-left: 1px solid var(--lime); box-shadow: -20px 0 60px rgba(0,0,0,.18); transition: transform .2s ease; }
  .topic-detail.open { transform: none; }
  .detail-close { display: grid; }
  .mobile-nav { position: fixed; z-index: 40; right: 0; bottom: 0; left: 0; height: 58px; display: grid; grid-template-columns: repeat(4,1fr); border-top: 1px solid var(--line); background: rgba(244,242,234,.98); }
  .mobile-nav a { position: relative; display: grid; place-items: center; color: var(--muted); font-size: 9px; font-weight: 700; text-decoration: none; }
  .mobile-nav a.active { color: var(--ink); }
  .mobile-nav a.active::before { content: ""; position: absolute; top: 0; right: 20%; left: 20%; height: 2px; background: var(--green); }
}

@media (max-width: 680px) {
  .topbar { height: 64px; padding: 0 16px; }
  .topbar nav, .topbar-actions > span { display: none; }
  .course-main { padding: 25px 16px 52px; }
  .route-heading { align-items: flex-start; }
  .route-heading h1 { font-size: 39px; }
  .route-heading > span { margin-top: 5px; font-size: 8px; }
  .continue-band { margin-top: 23px; }
  .continue-grid { display: block; padding: 21px; }
  .continue-copy h2 { font-size: 25px; }
  .continue-actions { margin-top: 23px; }
  .skip-link-button { text-align: center; }
  .map-heading { display: block; }
  .topic-search { width: 100%; margin-top: 15px; }
  .filter-row { flex-wrap: wrap; }
  .filter-row button { flex: 1 1 auto; padding: 0 9px; }
  .filter-row span { width: 100%; margin: 3px 0 0; text-align: right; }
  .module-toggle { grid-template-columns: 24px 24px minmax(0,1fr) auto 18px; min-height: 55px; padding: 0 10px; }
  .module-toggle strong { font-size: 10.5px; }
  .module-meta { display: none; }
  .topic-row { grid-template-columns: 21px 31px minmax(0,1fr) 30px 62px 14px; min-height: 50px; padding: 0 9px; }
  .topic-frequency { display: none; }
  .topic-status { text-align: right; }
  .topic-detail { width: 100%; padding: 52px 20px 70px; }
  .detail-title-line h2 { font-size: 25px; }
  .dialog-actions { grid-template-columns: 1fr; }
  .dialog-actions .primary { grid-row: 1; }
  .toast { right: 12px; bottom: 70px; left: 12px; min-width: 0; max-width: none; }
}

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