:root {
  --ink: #17241f;
  --muted: #68756f;
  --paper: #f7f5ee;
  --panel: #fffdf7;
  --line: #dedbd0;
  --green: #176b4d;
  --green-soft: #dfeee6;
  --orange: #c8682d;
  --orange-soft: #f7e5d7;
  --blue: #2c5e87;
  --shadow: 0 18px 55px rgba(33, 48, 41, 0.1);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 8% 6%, rgba(236, 202, 130, 0.2), transparent 28rem),
    linear-gradient(180deg, #f4f1e7 0%, #faf9f4 42rem, #f5f3ec 100%);
  font-family: "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
  min-height: 100vh;
}

button, input, select { font: inherit; }
button { cursor: pointer; }

.topbar {
  min-height: 86px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 16px clamp(20px, 5vw, 72px);
  border-bottom: 1px solid rgba(23, 36, 31, 0.12);
  background: rgba(250, 248, 241, 0.82);
  backdrop-filter: blur(16px);
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand { display: flex; align-items: center; gap: 13px; }
.brand-mark {
  width: 44px; height: 44px; display: grid; place-items: center;
  border-radius: 13px; background: var(--green); color: white;
  font: 700 23px/1 Georgia, serif; box-shadow: 0 8px 20px rgba(23, 107, 77, 0.22);
}
.brand h1 { font-size: 19px; margin: 1px 0 0; letter-spacing: .04em; }
.eyebrow { margin: 0; font-size: 11px; font-weight: 800; letter-spacing: .18em; color: var(--green); }

.top-stats { display: flex; gap: clamp(16px, 3vw, 42px); }
.top-stats div { display: grid; text-align: right; }
.top-stats strong { font: 700 22px/1 Georgia, serif; }
.top-stats span { margin-top: 5px; font-size: 11px; color: var(--muted); }

.hero {
  display: flex; justify-content: space-between; align-items: end; gap: 40px;
  padding: 54px clamp(20px, 5vw, 72px) 42px;
  max-width: 1600px; margin: 0 auto;
}
.hero > div:first-child { max-width: 800px; }
.hero h2 { margin: 10px 0 14px; font: 700 clamp(30px, 4vw, 56px)/1.12 Georgia, "Songti SC", serif; letter-spacing: -.03em; }
.hero p:last-child { max-width: 660px; margin: 0; color: var(--muted); line-height: 1.8; }

.curriculum-switcher { display: grid; gap: 10px; min-width: min(100%, 360px); }
.curriculum-switcher > div { display: grid; grid-template-columns: 38px minmax(0, 1fr); align-items: center; gap: 8px; }
.curriculum-switcher > div > span { color: var(--muted); font-size: 11px; font-weight: 800; }
.choice-switch { display: flex; max-width: 100%; padding: 5px; gap: 4px; overflow-x: auto; background: #e9e5da; border-radius: 14px; }
.choice-button { flex: 0 0 auto; border: 0; border-radius: 10px; padding: 11px 18px; color: var(--muted); background: transparent; font-weight: 700; white-space: nowrap; }
.choice-button.active { color: white; background: var(--ink); box-shadow: 0 5px 14px rgba(23, 36, 31, .18); }

.workspace {
  max-width: 1600px; margin: 0 auto; padding: 0 clamp(20px, 5vw, 72px) 44px;
  display: grid; grid-template-columns: minmax(285px, 360px) 1fr; gap: 20px;
}

.sidebar, .detail {
  border: 1px solid var(--line); background: rgba(255, 253, 247, .92);
  border-radius: 20px; box-shadow: var(--shadow); overflow: hidden;
}
.sidebar { height: calc(100vh - 230px); min-height: 590px; display: flex; flex-direction: column; }
.filters { padding: 18px; display: grid; gap: 13px; border-bottom: 1px solid var(--line); }
.filters label { display: grid; gap: 7px; }
.filters label > span { font-size: 11px; font-weight: 800; letter-spacing: .08em; color: var(--muted); }
input, select {
  width: 100%; border: 1px solid #d6d4ca; border-radius: 10px; padding: 10px 11px;
  color: var(--ink); background: white; outline: none;
}
input:focus, select:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(23, 107, 77, .1); }
.list-heading { padding: 13px 18px 9px; display: flex; justify-content: space-between; color: var(--muted); font-size: 12px; }
.topic-list { overflow-y: auto; padding: 0 9px 12px; }
.topic-item {
  width: 100%; border: 0; border-left: 3px solid transparent; border-radius: 10px;
  padding: 12px 11px; margin: 2px 0; text-align: left; background: transparent; color: var(--ink);
}
.topic-item:hover { background: #f1eee5; }
.topic-item.active { background: var(--green-soft); border-left-color: var(--green); }
.topic-item small { display: block; color: var(--muted); margin-bottom: 5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topic-item strong { display: block; line-height: 1.45; }
.mobile-video-count, .mobile-lesson-label, .mobile-learning-actions { display: none; }
.topic-item .status-dot { float: right; width: 8px; height: 8px; border-radius: 50%; margin-top: 7px; background: #c9c7bf; }
.topic-item .status-dot.learning { background: #d48b39; }
.topic-item .status-dot.mastered { background: var(--green); }
.topic-item .status-dot.review { background: #bd4f48; }

.detail { min-height: 590px; padding: clamp(24px, 4vw, 54px); }
.empty-state { min-height: 480px; display: grid; place-content: center; text-align: center; color: var(--muted); }
.empty-state span { font-size: 44px; color: var(--green); }
.empty-state h2 { color: var(--ink); margin-bottom: 5px; }

.detail-header { padding-bottom: 28px; border-bottom: 1px solid var(--line); }
.mobile-back { display: none; }
.breadcrumbs { color: var(--green); font-size: 12px; font-weight: 800; letter-spacing: .04em; }
.detail-header h2 { margin: 12px 0; font: 700 clamp(28px, 3.4vw, 48px)/1.16 Georgia, "Songti SC", serif; }
.summary { font-size: 17px; line-height: 1.8; color: #46534d; max-width: 900px; }
.meta-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; }
.pill { display: inline-flex; align-items: center; gap: 6px; border-radius: 999px; padding: 7px 11px; background: #eeece4; color: #526059; font-size: 12px; }
.pill.high { color: #9b451c; background: var(--orange-soft); }

.status-control { margin-top: 22px; display: flex; align-items: center; gap: 12px; }
.status-control label { font-weight: 800; font-size: 13px; }
.status-control select { width: auto; min-width: 130px; }

.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin-top: 24px; }
.card { border: 1px solid var(--line); border-radius: 15px; padding: 20px; background: white; }
.card.wide { grid-column: 1 / -1; }
.card h3 { margin: 0 0 14px; font-size: 15px; }
.card ul { margin: 0; padding-left: 20px; color: #4d5954; line-height: 1.75; }
.card li + li { margin-top: 6px; }
.warning-card { background: #fff9f4; border-color: #ecd1bd; }
.prereq-list { display: flex; flex-wrap: wrap; gap: 8px; }
.prereq-button { border: 1px solid #cdded5; border-radius: 999px; background: var(--green-soft); color: var(--green); padding: 8px 11px; font-size: 12px; font-weight: 700; }
.prereq-button:hover { background: #cce4d7; }
.external-prereq { border-radius: 999px; background: #efede6; color: #59635f; padding: 8px 11px; font-size: 12px; }

.practice-columns { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.practice-level { padding: 15px; border-radius: 12px; background: #f6f4ed; }
.practice-level strong { display: block; color: var(--green); margin-bottom: 8px; }
.practice-level p { margin: 0; color: #58645e; line-height: 1.6; font-size: 14px; }

.video-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; }
.video-card { padding: 15px; border-radius: 12px; background: #17241f; color: white; }
.video-card span { display: block; color: #b9c9c1; font-size: 12px; margin-bottom: 8px; }
.video-card strong { display: block; line-height: 1.5; }
.video-card button { margin-top: 13px; border: 0; border-radius: 9px; background: #f0c77d; color: #2c261a; padding: 9px 13px; font-weight: 800; }
.video-player { width: 100%; margin-top: 16px; border-radius: 12px; background: #0e1512; }
.video-now-playing { margin-top: 16px; font-weight: 800; }
.video-status { margin-top: 6px; color: var(--muted); font-size: 13px; }

footer { max-width: 1600px; margin: 0 auto; padding: 0 clamp(20px, 5vw, 72px) 28px; display: flex; justify-content: space-between; color: var(--muted); font-size: 12px; }
footer a { color: var(--green); }

@media (max-width: 900px) {
  .top-stats { display: none; }
  .hero { align-items: start; flex-direction: column; }
  .workspace { grid-template-columns: 1fr; }
  .sidebar { height: auto; min-height: 0; max-height: 540px; }
  .detail-grid { grid-template-columns: 1fr; }
  .card.wide { grid-column: auto; }
  .practice-columns { grid-template-columns: 1fr; }
}

@media (max-width: 560px) {
  .topbar {
    min-height: 66px;
    padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  }
  .brand-mark { width: 38px; height: 38px; border-radius: 11px; font-size: 20px; }
  .brand h1 { font-size: 17px; }
  .hero { padding: 26px 16px 20px; gap: 22px; }
  .hero > div:first-child { display: none; }
  .curriculum-switcher { width: 100%; }
  .choice-button { min-height: 44px; }
  .workspace { padding: 0 10px 28px; }
  .sidebar, .detail { border-radius: 16px; }
  .sidebar { max-height: none; }
  .filters { display: block; padding: 14px; }
  .filters .search-box, .status-filter-box { display: none; }
  input, select { min-height: 44px; font-size: 16px; }
  .topic-list { overflow: visible; padding: 0 7px 10px; }
  .topic-item { min-height: 58px; padding: 12px 10px; }
  .topic-item small { padding-right: 34px; }
  .mobile-video-count {
    display: inline-block;
    margin-top: 9px;
    color: var(--green);
    font-size: 12px;
    font-weight: 800;
  }
  .detail { min-height: 0; padding: 18px 14px; }
  .detail-header { padding-bottom: 20px; }
  .mobile-back {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    margin: -5px 0 15px;
    padding: 0 13px;
    border: 1px solid #cdded5;
    border-radius: 999px;
    color: var(--green);
    background: var(--green-soft);
    font-weight: 800;
  }
  .detail-header h2 { font-size: 29px; }
  .breadcrumbs, .meta-row, .status-control { display: none; }
  .mobile-lesson-label {
    display: block;
    margin: 4px 0 5px;
    color: var(--green);
    font-size: 12px;
    font-weight: 800;
  }
  .summary { font-size: 15px; line-height: 1.7; }
  .detail-grid { gap: 12px; margin-top: 16px; }
  .card { padding: 16px; }
  .detail-grid > .card:not(.video-section) { display: none; }
  .video-section { display: flex; flex-direction: column; }
  .video-section h3 { order: 1; font-size: 18px; }
  #video-stage { order: 2; }
  .video-grid { order: 3; margin-top: 16px; }
  .mobile-learning-actions { order: 4; }
  .video-grid { grid-template-columns: 1fr; }
  .video-card { padding: 13px; }
  .video-card strong { overflow-wrap: anywhere; font-size: 14px; }
  .video-card button { min-height: 44px; width: 100%; }
  .video-player { max-height: calc(100dvh - 150px); margin-top: 10px; }
  .video-now-playing { margin-top: 0; font-size: 14px; }
  .mobile-learning-actions { display: block; margin-top: 20px; padding-top: 18px; border-top: 1px solid var(--line); }
  .mobile-learning-actions p { margin: 0 0 12px; color: var(--muted); font-size: 13px; }
  .mobile-learning-actions > div { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
  .mobile-learning-actions button {
    min-height: 46px;
    border: 1px solid #cdded5;
    border-radius: 11px;
    background: white;
    color: var(--green);
    font-weight: 800;
  }
  .mobile-learning-actions button.selected { background: var(--green-soft); border-color: var(--green); }
  .mobile-learning-actions .next-course { width: 100%; margin-top: 10px; color: white; background: var(--green); border-color: var(--green); }
  footer {
    padding: 0 16px calc(22px + env(safe-area-inset-bottom));
    flex-direction: column;
    gap: 8px;
  }

  body:not(.mobile-detail-open) .detail { display: none; }
  body.mobile-detail-open .hero { display: none; }
  body.mobile-detail-open .sidebar { display: none; }
  body.mobile-detail-open .workspace { padding-top: 12px; }
}
