:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --panel: #ffffff;
  --panel-soft: #f8fafc;
  --line: #e5e7eb;
  --line-strong: #d1d5db;
  --text: #1f2937;
  --muted: #6b7280;
  --blue: #2563eb;
  --blue-soft: #eff6ff;
  --green: #15803d;
  --green-soft: #f0fdf4;
  --danger: #dc2626;
  --sans: "Noto Sans SC", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; min-width: 320px; background: var(--bg); color: var(--text); font-family: var(--sans); font-size: 16px; }
button, select { font: inherit; }
button { color: inherit; }
button:focus-visible, select:focus-visible, [tabindex]:focus-visible { outline: 3px solid rgba(37, 99, 235, .25); outline-offset: 2px; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 224px minmax(0, 1fr); }
.sidebar { position: fixed; inset: 0 auto 0 0; z-index: 20; width: 224px; display: flex; flex-direction: column; padding: 24px 16px; border-right: 1px solid var(--line); background: #fff; }
.brand { display: flex; align-items: center; gap: 11px; color: var(--text); text-decoration: none; padding: 0 8px 32px; }
.brand-mark { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 9px; color: #fff; background: var(--blue); font-size: 13px; font-weight: 700; }
.brand b { display: block; font-size: 16px; }
.brand small { display: block; margin-top: 1px; color: var(--muted); font-size: 12px; }
.main-nav { display: grid; gap: 4px; }
.nav-item { display: flex; align-items: center; width: 100%; padding: 11px 13px; border: 0; border-radius: 8px; background: transparent; color: #4b5563; text-align: left; cursor: pointer; transition: .15s ease; }
.nav-item span { display: none; }
.nav-item:hover { background: #f3f4f6; color: var(--text); }
.nav-item.active { background: var(--blue-soft); color: var(--blue); font-weight: 600; }
.sidebar-spacer { flex: 1; }
.level-card { display: flex; align-items: center; gap: 12px; padding: 16px 8px; border-top: 1px solid var(--line); }
.level-ring { display: grid; place-items: center; width: 42px; aspect-ratio: 1; border-radius: 50%; color: var(--blue); background: var(--blue-soft); font-weight: 700; }
.level-card small { display: block; color: var(--muted); font-size: 12px; }
.level-card b { font-size: 14px; }
.reset-btn { border: 0; background: none; color: #9ca3af; font-size: 12px; text-align: left; padding: 8px; cursor: pointer; }
.reset-btn:hover { color: var(--danger); }

.workspace { grid-column: 2; min-width: 0; }
.topbar { min-height: 76px; position: sticky; top: 0; z-index: 15; display: flex; align-items: center; justify-content: space-between; padding: 14px 32px; border-bottom: 1px solid var(--line); background: rgba(255,255,255,.94); backdrop-filter: blur(12px); }
.topbar h1 { margin: 2px 0 0; font-size: 20px; line-height: 1.2; }
.eyebrow, .section-kicker { margin: 0; color: var(--blue); font-size: 12px; font-weight: 600; }
.topbar-actions { display: flex; align-items: center; gap: 16px; }
.overall-progress { width: 170px; }
.overall-progress span { display: flex; justify-content: space-between; color: var(--muted); font-size: 12px; }
.overall-progress b { color: var(--text); }
.progress-track { height: 5px; margin-top: 7px; border-radius: 99px; background: #e5e7eb; overflow: hidden; }
.progress-track i { display: block; width: 0; height: 100%; border-radius: 99px; background: var(--blue); transition: width .3s ease; }
.icon-btn, .mobile-menu { width: 36px; height: 36px; border: 1px solid var(--line); border-radius: 8px; background: #fff; cursor: pointer; }
.icon-btn:hover, .mobile-menu:hover { background: #f9fafb; }
.mobile-menu { display: none; }

main { max-width: 1500px; padding: 32px; }
.view { display: none; }
.view.active-view { display: block; animation: fade .2s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(3px); } }
.view-intro { display: flex; align-items: end; justify-content: space-between; gap: 24px; margin-bottom: 24px; }
.view-intro h2 { max-width: 720px; margin: 6px 0 5px; font-size: clamp(24px, 3vw, 34px); letter-spacing: -.025em; line-height: 1.3; }
.view-intro p:last-child { max-width: 680px; margin: 0; color: var(--muted); line-height: 1.7; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; color: var(--muted); font-size: 13px; }
.legend span { display: flex; align-items: center; gap: 6px; }
.dot { width: 8px; height: 8px; border-radius: 50%; }
.dot.ready { background: var(--blue); }
.dot.done { background: var(--green); }
.dot.locked { background: #cbd5e1; }

.next-mission { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 16px; padding: 16px 18px; margin-bottom: 18px; border: 1px solid #bfdbfe; border-radius: 10px; background: var(--blue-soft); }
.mission-index { padding: 4px 8px; border-radius: 99px; background: #dbeafe; color: #1d4ed8; font-size: 12px; font-weight: 600; }
.next-mission b { display: block; font-size: 15px; }
.next-mission p { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.next-mission button, .session-summary button, .diagnosis-panel button { border: 0; border-radius: 7px; background: var(--blue); color: #fff; font-weight: 600; padding: 10px 15px; cursor: pointer; }
.next-mission button:hover, .session-summary button:hover, .diagnosis-panel button:hover { background: #1d4ed8; }

.skill-map-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; background: #fff; scrollbar-color: #cbd5e1 #f8fafc; }
.skill-map { min-width: 1100px; display: grid; grid-template-columns: repeat(7, minmax(138px, 1fr)); gap: 16px; padding: 20px; }
.stage { min-width: 0; position: relative; }
.stage-head { min-height: 64px; margin-bottom: 14px; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.stage-number { color: var(--muted); font-size: 12px; }
.stage-head h3 { margin: 4px 0 0; font-size: 15px; }
.stage-head p { display: none; }
.stage-nodes { display: grid; gap: 10px; }
.skill-node { position: relative; min-height: 94px; width: 100%; padding: 13px; border: 1px solid var(--line); border-radius: 9px; background: var(--panel-soft); color: #6b7280; text-align: left; cursor: pointer; transition: transform .15s ease, border-color .15s ease, box-shadow .15s ease; }
.skill-node:hover { transform: translateY(-1px); border-color: #9ca3af; box-shadow: 0 4px 12px rgba(15,23,42,.06); }
.skill-node .node-top { display: flex; justify-content: space-between; gap: 8px; }
.skill-node .node-icon { font-size: 15px; }
.skill-node .node-state { font-size: 11px; }
.skill-node b { display: block; margin: 12px 0 2px; color: inherit; font-size: 14px; }
.skill-node small { display: block; font-size: 12px; color: #9ca3af; }
.skill-node.ready { border-color: #93c5fd; background: var(--blue-soft); color: #1e3a8a; }
.skill-node.ready .node-state, .skill-node.ready .node-icon { color: var(--blue); }
.skill-node.progress { border-color: #fbbf24; background: #fffbeb; color: #78350f; }
.skill-node.progress .node-state, .skill-node.progress .node-icon { color: #b45309; }
.skill-node.done { border-color: #86efac; background: var(--green-soft); color: #14532d; }
.skill-node.done .node-state, .skill-node.done .node-icon { color: var(--green); }
.skill-node.locked { opacity: .7; }
.skill-node.selected { outline: 2px solid var(--blue); outline-offset: 2px; }
.node-mastery { display: grid; grid-template-columns: repeat(4, 1fr); gap: 3px; margin-top: 10px; }
.node-mastery i { height: 3px; border-radius: 9px; background: #e5e7eb; }
.node-mastery i.filled { background: currentColor; opacity: .7; }

.detail-panel { position: fixed; z-index: 35; top: 0; right: 0; width: min(440px, 100vw); height: 100vh; overflow-y: auto; padding: 28px; border-left: 1px solid var(--line); background: #fff; box-shadow: -12px 0 36px rgba(15,23,42,.12); transform: translateX(105%); transition: transform .22s ease; }
.detail-panel.open { transform: none; }
.close-detail, .modal-close { float: right; border: 0; background: none; color: var(--muted); font-size: 28px; cursor: pointer; }
.detail-hero { padding: 28px 0 22px; border-bottom: 1px solid var(--line); }
.detail-code { color: var(--blue); font-size: 12px; font-weight: 600; }
.detail-hero h2 { margin: 7px 0; font-size: 28px; }
.detail-hero p { color: var(--muted); line-height: 1.7; }
.status-pill { display: inline-flex; padding: 5px 9px; border-radius: 99px; background: var(--blue-soft); color: var(--blue); font-size: 12px; font-weight: 600; }
.detail-section { padding: 22px 0 0; }
.detail-section h3 { margin: 0 0 12px; font-size: 14px; }
.prereq-list, .drill-list, .missing-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.prereq-list li, .drill-list label { display: flex; align-items: flex-start; gap: 9px; padding: 11px; border: 1px solid var(--line); border-radius: 7px; background: #fff; color: #374151; font-size: 13px; }
.prereq-list i { color: var(--green); font-style: normal; }
.prereq-list .not-done i { color: #9ca3af; }
.prereq-list small { display: block; margin-top: 2px; color: var(--muted); }
.drill-list input { accent-color: var(--blue); margin-top: 3px; }
.drill-list small { display: block; color: var(--muted); margin-top: 2px; }
.mechanism-card { padding: 15px; border: 1px solid #bfdbfe; border-radius: 9px; background: var(--blue-soft); }
.mechanism-card b { color: var(--blue); font-size: 12px; }
.mechanism-card p { margin: 6px 0 0; color: #1e3a8a; font-size: 14px; line-height: 1.65; }
.mastery-ladder { display: grid; gap: 7px; }
.mastery-step { display: grid; grid-template-columns: 38px 1fr 18px; gap: 10px; align-items: start; padding: 10px; border: 1px solid var(--line); border-radius: 8px; color: #9ca3af; }
.mastery-step > span { display: grid; place-items: center; height: 28px; border-radius: 6px; background: #f3f4f6; font-size: 12px; font-weight: 700; }
.mastery-step b { display: block; color: #6b7280; font-size: 13px; }
.mastery-step small { display: block; margin-top: 2px; line-height: 1.45; }
.mastery-step i { color: var(--green); font-style: normal; }
.mastery-step.reached { border-color: #bbf7d0; background: var(--green-soft); color: #4b5563; }
.mastery-step.reached b { color: #166534; }
.mastery-step.current { border-color: #93c5fd; background: var(--blue-soft); color: #374151; }
.mastery-step.current > span { background: #dbeafe; color: var(--blue); }
.mastery-step.current b { color: #1e40af; }
.unlock-note { margin: 9px 0 0; color: var(--muted); font-size: 12px; line-height: 1.6; }
.quality-section > p { margin: -4px 0 10px; color: var(--muted); font-size: 13px; line-height: 1.6; }
.quality-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.quality-item { padding: 9px; border: 1px solid var(--line); border-radius: 7px; background: var(--panel-soft); }
.quality-item b { display: block; font-size: 12px; }
.quality-item span { display: block; margin-top: 2px; color: var(--muted); font-size: 11px; line-height: 1.4; }
.detail-cta { width: 100%; margin-top: 24px; border: 0; border-radius: 8px; padding: 13px; background: var(--blue); color: #fff; font-weight: 600; cursor: pointer; }
.detail-cta:hover { background: #1d4ed8; }
.detail-cta[disabled] { background: #e5e7eb; color: #9ca3af; cursor: not-allowed; }

.session-summary { display: grid; grid-template-columns: auto 1fr auto; gap: 16px; align-items: center; padding: 22px; border: 1px solid #bfdbfe; border-radius: 10px; background: var(--blue-soft); margin-bottom: 16px; }
.session-summary > span { display: grid; place-items: center; width: 48px; height: 48px; border-radius: 10px; background: #dbeafe; color: var(--blue); font-size: 20px; font-weight: 700; }
.session-summary b { font-size: 18px; }
.session-summary p { margin: 3px 0 0; color: var(--muted); font-size: 13px; }
.training-list { display: grid; gap: 10px; }
.training-card { display: grid; grid-template-columns: 56px 1fr auto; gap: 16px; align-items: center; padding: 16px; border: 1px solid var(--line); border-radius: 10px; background: #fff; cursor: pointer; }
.training-card:hover { border-color: #93c5fd; box-shadow: 0 4px 12px rgba(15,23,42,.05); }
.training-card .time { display: grid; place-items: center; height: 52px; border-radius: 8px; background: var(--blue-soft); color: var(--blue); font-size: 12px; font-weight: 600; }
.training-card h3 { margin: 0; font-size: 15px; }
.training-card p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.training-card .arrow { color: #9ca3af; font-size: 22px; }

.diagnosis-panel { display: grid; grid-template-columns: 1fr auto; gap: 10px; max-width: 760px; padding: 20px; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.diagnosis-panel label { grid-column: 1 / -1; color: var(--muted); font-size: 13px; }
.diagnosis-panel select { min-width: 0; padding: 11px; border: 1px solid var(--line-strong); border-radius: 7px; background: #fff; color: var(--text); }
.diagnosis-result { max-width: 760px; margin-top: 14px; }
.result-card { padding: 24px; border: 1px solid #bfdbfe; border-radius: 10px; background: var(--blue-soft); }
.result-card h3 { margin: 6px 0; font-size: 24px; }
.result-card p { color: var(--muted); }
.missing-list li { padding: 11px; border-left: 3px solid #f59e0b; border-radius: 0 7px 7px 0; background: #fff; font-size: 13px; }
.result-clear { border-color: #bbf7d0; background: var(--green-soft); }

.modal-backdrop { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 20px; background: rgba(15,23,42,.36); backdrop-filter: blur(3px); }
.modal-backdrop[hidden] { display: none; }
.modal { width: min(530px, 100%); max-height: 90vh; overflow-y: auto; padding: 28px; border-radius: 12px; background: #fff; box-shadow: 0 24px 70px rgba(15,23,42,.2); }
.modal h2 { margin: 8px 0; font-size: 28px; }
.modal > p:not(.section-kicker) { color: var(--muted); line-height: 1.65; }
.test-check { display: flex; gap: 11px; align-items: flex-start; padding: 13px; margin: 8px 0; border: 1px solid var(--line); border-radius: 8px; background: #fff; cursor: pointer; }
.test-check input { margin-top: 4px; accent-color: var(--blue); }
.test-check span { line-height: 1.55; }
.primary-btn { width: 100%; margin-top: 18px; padding: 13px; border: 0; border-radius: 8px; background: var(--blue); color: #fff; font-weight: 600; cursor: pointer; }
.primary-btn[disabled] { opacity: .45; cursor: not-allowed; }
.help-modal blockquote { margin: 20px 0; padding: 18px; border-left: 3px solid var(--blue); background: var(--blue-soft); font-weight: 600; line-height: 1.7; }
.help-modal li { margin: 9px 0; color: var(--muted); line-height: 1.6; }
.toast { position: fixed; z-index: 80; left: 50%; bottom: 25px; transform: translate(-50%, 30px); padding: 11px 15px; border-radius: 8px; background: #1f2937; color: #fff; font-size: 13px; opacity: 0; pointer-events: none; transition: .2s ease; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 820px) {
  .app-shell { display: block; }
  .sidebar { transform: translateX(-105%); transition: transform .2s ease; box-shadow: 16px 0 40px rgba(15,23,42,.14); }
  .sidebar.open { transform: none; }
  .workspace { width: 100%; }
  .mobile-menu { display: grid; place-items: center; margin-right: 12px; }
  .topbar { min-height: 68px; padding: 10px 16px; justify-content: flex-start; }
  .topbar-actions { margin-left: auto; }
  .topbar h1 { font-size: 17px; }
  .overall-progress { display: none; }
  main { padding: 24px 16px 48px; }
  .view-intro { display: block; }
  .legend { margin-top: 16px; }
  .next-mission { grid-template-columns: auto 1fr; }
  .next-mission button { grid-column: 1 / -1; }
  .skill-map { min-width: 1040px; padding: 16px; }
  .session-summary { grid-template-columns: auto 1fr; }
  .session-summary button { grid-column: 1 / -1; }
  .diagnosis-panel { grid-template-columns: 1fr; }
  .diagnosis-panel label { grid-column: auto; }
}

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