:root {
  color-scheme: light;
  --ink: #171511;
  --muted: #62706b;
  --line: #d4dfda;
  --paper: #f3f7f5;
  --panel: #ffffff;
  --panel-strong: #e9f0ed;
  --accent: #d95f2d;
  --accent-dark: #9e3f22;
  --green: #3d7b57;
  --blue: #355c8c;
  --gold: #b4832c;
  --red: #b84632;
  --shadow: 0 24px 80px rgba(37, 31, 23, 0.12);
  --radius: 8px;
  --font-sans: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --font-mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-sans);
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 320px;
  background:
    radial-gradient(circle at 12% 8%, rgba(53, 92, 140, 0.1), transparent 28%),
    linear-gradient(135deg, #f7faf9 0%, #edf4f1 48%, #f6eee6 100%);
}

button,
a,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
}

a {
  color: inherit;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

img {
  display: block;
  max-width: 100%;
}

.skip-link {
  background: var(--ink);
  color: var(--paper);
  left: 16px;
  padding: 10px 14px;
  position: fixed;
  top: -80px;
  z-index: 20;
}

.skip-link:focus {
  top: 16px;
}

.app-shell {
  min-height: 100vh;
  padding: 18px;
}

.topbar {
  align-items: center;
  backdrop-filter: blur(16px);
  background: rgba(255, 255, 255, 0.86);
  border: 1px solid rgba(212, 223, 218, 0.92);
  border-radius: var(--radius);
  display: flex;
  justify-content: space-between;
  margin: 0 auto 16px;
  max-width: 1480px;
  padding: 12px;
  position: sticky;
  top: 12px;
  z-index: 10;
}

.brand-lockup {
  align-items: center;
  display: flex;
  gap: 12px;
  min-width: 0;
}

.brand-mark {
  align-items: center;
  background: var(--ink);
  border-radius: 8px;
  color: var(--paper);
  display: inline-flex;
  flex: 0 0 auto;
  font-family: var(--font-mono);
  font-size: 20px;
  font-weight: 800;
  height: 42px;
  justify-content: center;
  width: 42px;
}

.brand-lockup h1,
.brand-lockup p,
.panel-heading h2,
.panel-heading h3,
.review-card h2,
.radar-card h2,
.source-card h2,
.lesson-hero h2 {
  margin: 0;
}

.brand-lockup h1 {
  font-size: 20px;
  line-height: 1.1;
}

.eyebrow,
.section-kicker {
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 760;
  letter-spacing: 0;
  line-height: 1.35;
  margin: 0 0 6px;
  text-transform: uppercase;
}

.top-actions,
.status-actions,
.completion-actions,
.task-variants {
  display: flex;
  gap: 8px;
}

.icon-button,
.plain-button,
.ghost-button,
.primary-button {
  align-items: center;
  border-radius: 8px;
  display: inline-flex;
  justify-content: center;
  min-height: 40px;
  transition: transform 140ms ease, background 140ms ease, border-color 140ms ease, box-shadow 140ms ease;
}

.icon-button {
  background: #ffffff;
  border: 1px solid var(--line);
  color: var(--ink);
  min-width: 40px;
  padding: 0 10px;
  position: relative;
  text-decoration: none;
}

.icon-button::after {
  background: var(--ink);
  border-radius: 6px;
  bottom: -36px;
  color: var(--paper);
  content: attr(data-tooltip);
  font-size: 12px;
  left: 50%;
  opacity: 0;
  padding: 6px 8px;
  pointer-events: none;
  position: absolute;
  transform: translateX(-50%) translateY(-4px);
  transition: opacity 140ms ease, transform 140ms ease;
  white-space: nowrap;
  z-index: 30;
}

.icon-button:hover::after,
.icon-button:focus-visible::after {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.primary-button,
.ghost-button,
.plain-button {
  border: 1px solid transparent;
  padding: 0 14px;
}

.primary-button {
  background: var(--ink);
  color: var(--paper);
  text-decoration: none;
}

.primary-button:disabled {
  background: #c8c0b2;
  color: #ffffff;
}

.ghost-button {
  background: #ffffff;
  border-color: var(--line);
  color: var(--ink);
}

.plain-button {
  background: transparent;
  color: var(--accent-dark);
}

.small {
  min-height: 34px;
  padding: 0 10px;
}

.icon-button:hover,
.primary-button:hover:not(:disabled),
.ghost-button:hover,
.plain-button:hover {
  transform: translateY(-1px);
}

.icon-button:focus-visible,
.primary-button:focus-visible,
.ghost-button:focus-visible,
.plain-button:focus-visible,
.check-item input:focus-visible + span {
  box-shadow: 0 0 0 3px rgba(217, 95, 45, 0.28);
  outline: none;
}

.workspace {
  display: grid;
  gap: 16px;
  grid-template-columns: minmax(230px, 280px) minmax(0, 1fr) minmax(260px, 320px);
  margin: 0 auto;
  max-width: 1480px;
}

.sidebar,
.insight-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.status-card,
.lesson-list-panel,
.lesson-card,
.task-card,
.check-card,
.review-card,
.radar-card,
.source-card {
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(212, 223, 218, 0.94);
  border-radius: var(--radius);
  box-shadow: 0 14px 50px rgba(37, 31, 23, 0.06);
}

.status-card,
.lesson-list-panel,
.review-card,
.radar-card,
.source-card,
.task-card,
.check-card {
  padding: 16px;
}

.status-card h2,
.review-card h2,
.radar-card h2,
.source-card h2 {
  font-size: 18px;
}

.status-card p,
.source-card p,
.radar-card p,
.lesson-copy p,
.review-list p {
  color: var(--muted);
  line-height: 1.72;
}

.progress-meter {
  background: var(--panel-strong);
  border-radius: 99px;
  height: 8px;
  margin: 16px 0 8px;
  overflow: hidden;
}

.progress-meter span {
  background: linear-gradient(90deg, var(--accent), var(--gold));
  display: block;
  height: 100%;
  width: 0;
}

.progress-copy {
  font-size: 13px;
  margin: 0 0 14px;
}

.panel-heading {
  align-items: flex-start;
  display: flex;
  gap: 12px;
  justify-content: space-between;
}

.lesson-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.lesson-button {
  align-items: flex-start;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 6px;
  grid-template-columns: 28px 1fr;
  padding: 12px;
  text-align: left;
  width: 100%;
}

.lesson-button[aria-current="true"] {
  background: #fff1e8;
  border-color: rgba(217, 95, 45, 0.55);
}

.lesson-number {
  align-items: center;
  background: var(--panel-strong);
  border-radius: 6px;
  display: inline-flex;
  font-family: var(--font-mono);
  font-size: 12px;
  height: 28px;
  justify-content: center;
  width: 28px;
}

.lesson-button strong,
.lesson-button span {
  display: block;
}

.lesson-button span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.lesson-button.done .lesson-number {
  background: var(--green);
  color: white;
}

.lesson-button.skipped .lesson-number {
  background: var(--gold);
  color: white;
}

.lesson-stage {
  min-width: 0;
}

.lesson-hero {
  align-items: stretch;
  background: var(--panel);
  border: 1px solid rgba(212, 223, 218, 0.94);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: grid;
  gap: 18px;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 36%);
  margin-bottom: 16px;
  overflow: hidden;
  padding: 18px;
}

.hero-copy {
  align-self: center;
  min-width: 0;
}

.lesson-hero h2 {
  font-size: clamp(28px, 4vw, 58px);
  line-height: 1.05;
  margin-bottom: 14px;
}

.lesson-hero p {
  color: var(--muted);
  font-size: 17px;
  line-height: 1.72;
  margin: 0;
}

.source-row {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 18px;
}

.source-row span,
.source-row a {
  background: var(--panel-strong);
  border-radius: 6px;
  color: var(--ink);
  font-size: 12px;
  padding: 6px 8px;
}

.hero-visual {
  background: #f3f7f5;
  border-radius: 8px;
  margin: 0;
  min-height: 260px;
  overflow: hidden;
}

.hero-visual img {
  height: 100%;
  object-fit: contain;
  width: 100%;
}

.content-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: minmax(0, 1fr) minmax(270px, 33%);
}

.lesson-card {
  min-width: 0;
  padding: 26px;
}

.lesson-copy h3 {
  font-size: 22px;
  margin: 26px 0 10px;
}

.lesson-copy h3:first-child {
  margin-top: 0;
}

.lesson-copy p {
  font-size: 16px;
  margin: 0 0 14px;
}

.lesson-copy ul {
  display: grid;
  gap: 8px;
  margin: 12px 0 18px;
  padding-left: 20px;
}

.lesson-copy li {
  line-height: 1.65;
}

.guide-panel,
.tips-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  display: grid;
  gap: 10px;
  margin: 20px 0;
  padding: 16px;
}

.guide-panel {
  background: #f6faf8;
}

.tips-panel {
  background: #fff7ed;
  border-color: rgba(217, 95, 45, 0.24);
}

.guide-panel h3,
.tips-panel h3 {
  margin: 0;
}

.guide-panel ol,
.tips-panel ul {
  display: grid;
  gap: 8px;
  margin: 0;
  padding-left: 22px;
}

.command-panel {
  background: #f6faf8;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  display: grid;
  gap: 10px;
  margin: 20px 0;
  padding: 14px;
}

.command-panel h3 {
  margin: 0 0 4px;
}

.command-row {
  display: grid;
  gap: 6px;
}

.command-row span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.command-row code {
  background: #171511;
  border-radius: 8px;
  color: #fff7e8;
  display: block;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.55;
  overflow-wrap: anywhere;
  padding: 10px 12px;
  white-space: pre-wrap;
}

.callout {
  background: #f7f1e4;
  border-left: 3px solid var(--accent);
  border-radius: 8px;
  margin: 18px 0;
  padding: 14px 16px;
}

.practice-rail {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}

.task-card pre {
  background: #171511;
  border-radius: 8px;
  color: #fff7e8;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.64;
  margin: 14px 0;
  max-height: 280px;
  overflow: auto;
  padding: 14px;
  white-space: pre-wrap;
  word-break: break-word;
}

.task-variants {
  flex-wrap: wrap;
}

.checklist {
  display: grid;
  gap: 8px;
  margin: 14px 0;
}

.check-item {
  align-items: flex-start;
  display: grid;
  gap: 10px;
  grid-template-columns: 22px 1fr;
}

.check-item input {
  height: 20px;
  margin: 2px 0 0;
  width: 20px;
}

.check-item span {
  color: var(--muted);
  line-height: 1.6;
}

.check-count {
  background: #e7f3eb;
  border-radius: 6px;
  color: var(--green);
  font-family: var(--font-mono);
  font-size: 12px;
  padding: 6px 8px;
}

.completion-actions {
  flex-wrap: wrap;
}

.review-stats {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(2, 1fr);
  margin: 16px 0;
}

.review-stats div {
  background: var(--panel-strong);
  border-radius: 8px;
  padding: 14px;
}

.review-stats strong {
  display: block;
  font-family: var(--font-mono);
  font-size: 28px;
}

.review-stats span {
  color: var(--muted);
  font-size: 12px;
}

.review-list {
  display: grid;
  gap: 10px;
}

.review-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}

.review-item strong {
  display: block;
  margin-bottom: 4px;
}

.risk-steps {
  display: grid;
  gap: 8px;
  margin: 16px 0;
}

.risk-step {
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: flex;
  gap: 10px;
  padding: 10px;
}

.risk-dot {
  border-radius: 99px;
  height: 10px;
  width: 10px;
}

.risk-step.active {
  background: #fff1e8;
  border-color: rgba(217, 95, 45, 0.55);
}

.risk-read {
  background: var(--green);
}

.risk-edit {
  background: var(--gold);
}

.risk-command {
  background: var(--red);
}

.risk-cloud {
  background: var(--blue);
}

.source-card ul {
  margin: 14px 0;
  padding-left: 20px;
}

.source-card li {
  line-height: 1.8;
}

.site-footer {
  align-items: center;
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  font-size: 13px;
  gap: 14px;
  justify-content: center;
  margin: 28px auto 10px;
  max-width: 1480px;
}

.modal-layer[hidden],
.context-menu[hidden] {
  display: none;
}

.modal-layer {
  inset: 0;
  position: fixed;
  z-index: 40;
}

.modal-backdrop {
  background: rgba(23, 21, 17, 0.48);
  inset: 0;
  position: absolute;
}

.modal-panel {
  background: var(--panel);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  left: 50%;
  max-height: min(680px, calc(100vh - 32px));
  max-width: min(440px, calc(100vw - 32px));
  overflow: auto;
  padding: 24px;
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 100%;
}

.modal-close {
  position: absolute;
  right: 12px;
  top: 12px;
}

.modal-panel h2 {
  margin: 0 42px 14px 0;
}

.modal-panel p {
  color: var(--muted);
  line-height: 1.7;
}

.modal-qr {
  background: white;
  border: 1px solid var(--line);
  border-radius: 8px;
  margin: 14px auto;
  max-width: 260px;
  padding: 12px;
}

.modal-links {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
}

.context-menu {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  min-width: 220px;
  padding: 6px;
  position: fixed;
  z-index: 35;
}

.context-menu button {
  background: transparent;
  border: 0;
  border-radius: 6px;
  color: var(--ink);
  display: block;
  padding: 10px;
  text-align: left;
  width: 100%;
}

.context-menu button:hover,
.context-menu button:focus-visible {
  background: var(--panel-strong);
  outline: none;
}

.toast-stack {
  bottom: 18px;
  display: grid;
  gap: 10px;
  position: fixed;
  right: 18px;
  z-index: 50;
}

.toast {
  background: var(--ink);
  border-radius: 8px;
  box-shadow: var(--shadow);
  color: var(--paper);
  max-width: min(360px, calc(100vw - 36px));
  padding: 12px 14px;
}

.not-found-page {
  align-items: center;
  display: flex;
  justify-content: center;
  min-height: 100vh;
}

.not-found {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  max-width: 520px;
  padding: 28px;
}

.not-found h1 {
  margin: 0 0 12px;
}

.not-found p {
  color: var(--muted);
  line-height: 1.7;
}

@media (max-width: 1180px) {
  .workspace {
    grid-template-columns: minmax(210px, 260px) minmax(0, 1fr);
  }

  .insight-panel {
    grid-column: 1 / -1;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    display: grid;
  }
}

@media (max-width: 860px) {
  .app-shell {
    padding: 10px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
    gap: 12px;
    position: static;
  }

  .top-actions {
    width: 100%;
  }

  .workspace,
  .content-grid,
  .lesson-hero,
  .insight-panel {
    display: grid;
    grid-template-columns: 1fr;
  }

  .sidebar {
    order: 1;
  }

  .lesson-stage {
    order: 2;
  }

  .insight-panel {
    order: 3;
  }

  .lesson-hero h2 {
    font-size: 36px;
  }

  .hero-visual {
    min-height: 220px;
  }

  .lesson-card {
    padding: 18px;
  }
}

@media (max-width: 520px) {
  .brand-lockup {
    align-items: flex-start;
  }

  .brand-lockup h1 {
    font-size: 18px;
  }

  .top-actions {
    flex-wrap: wrap;
  }

  .status-actions,
  .completion-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .primary-button,
  .ghost-button {
    width: 100%;
  }

  .lesson-hero {
    padding: 14px;
  }

  .lesson-hero h2 {
    font-size: 32px;
  }

  .source-row {
    align-items: stretch;
    flex-direction: column;
  }

  .hero-visual {
    min-height: 180px;
  }

  .site-footer {
    justify-content: flex-start;
  }
}
