/* ============================================================
   Anthropic Academy 学习站 — app layer over TP Design
   Foundation (_ds/tp/colors_and_type.css) supplies the tokens:
   --fg1/2/3, --card, --bg, --divider, --shadow-card/pop, --r-*,
   --font-ui/display/mono/cjk, type classes, dark-mode remap.
   Here we (1) set the Omada-green accent, (2) bridge the legacy
   variable names app.js + activities.* rely on to TP tokens, and
   (3) style every component in the TP iOS-web idiom.
   ============================================================ */

:root {
  /* ---- accent: Omada green (tweakable to other brand modes) ---- */
  --accent:        #00A870;
  --accent-strong: color-mix(in oklab, var(--accent), #06251a 32%);
  --accent-soft:   color-mix(in oklab, var(--accent), transparent 90%);
  --accent-16:     color-mix(in oklab, var(--accent), transparent 84%);
  --accent-line:   color-mix(in oklab, var(--accent), transparent 68%);

  /* ---- bridge legacy names → TP tokens (so app.js/activities work) ---- */
  --ink:     var(--fg1);                 /* #1d2529 primary label */
  --ink-2:   #454d51;                    /* body mid */
  --muted:   var(--fg2);                 /* secondary 50% */
  --muted-2: var(--fg3);                 /* tertiary 32% */
  --surface:   var(--card);              /* #fff grouped card */
  --surface-2: #eef2f4;                  /* mist / inset */
  --track:     #e6edef;                  /* progress track */
  --line:    #e4e9ec;
  --line-2:  #d3dadd;

  --good:      var(--success);           /* #34c759 */
  --good-soft: color-mix(in oklab, var(--success), transparent 86%);
  --bad:       var(--danger);            /* #ff3b30 */
  --bad-soft:  color-mix(in oklab, var(--danger), transparent 90%);

  /* aliases the original activities base css references */
  --navy: var(--ink); --navy-dark: #0f1518; --navy-light: #3a4347;
  --orange: var(--accent); --orange-light: color-mix(in oklab,var(--accent),#fff 24%);
  --green: var(--good); --red: var(--bad);

  /* ---- type ---- */
  --font-sans:    var(--font-ui);
  --font-display: "Hanken Grotesk", var(--font-ui);   /* big display only */
  --font-serif:   var(--font-ui);        /* legacy alias → SF Pro now */

  /* ---- shape ---- */
  --radius:    14px;
  --radius-sm: 10px;
  --radius-lg: 18px;
  --btn-radius: 10px;
  --shadow-1: var(--shadow-card);
  --shadow-2: var(--shadow-pop);
  --ease: cubic-bezier(.32,.72,.36,1);

  /* ---- density ---- */
  --gap:   16px;
  --pad-x: clamp(18px, 4.5vw, 40px);
  --maxw:  1140px;
}

[data-theme="dark"] {
  --accent:        #1fc285;
  --ink-2:         rgba(255,255,255,.72);
  --surface-2:     #1a2228;
  --track:         #2a343a;
  --line:          rgba(255,255,255,.10);
  --line-2:        rgba(255,255,255,.17);
}
/* softer dark canvas than DS pure-black, for long-form reading */
:root[data-theme="dark"] { --bg: #0d1417; }

[data-density="compact"] { --gap: 11px; --radius: 11px; }

* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: var(--font-ui);
  background: var(--bg);
  color: var(--ink);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  letter-spacing: -.01em;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; }
::selection { background: var(--accent-16); }
#app { position: relative; }
.mono { font-family: var(--font-mono); }

/* ============================================================
   Top bar
   ============================================================ */
.topbar {
  position: sticky; top: 0; z-index: 40;
  background: color-mix(in oklab, var(--bg), transparent 12%);
  -webkit-backdrop-filter: blur(18px) saturate(160%);
  backdrop-filter: blur(18px) saturate(160%);
  border-bottom: 1px solid var(--line);
}
.topbar-inner {
  max-width: var(--maxw); margin: 0 auto;
  padding: 0 var(--pad-x); height: 60px;
  display: flex; align-items: center; gap: 16px; justify-content: space-between;
}
.brand { display: flex; align-items: center; gap: 11px; }
.brand-mark {
  width: 30px; height: 30px; border-radius: 8px; flex-shrink: 0;
  background: var(--accent); color: #fff;
  display: grid; place-items: center; font-size: 16px; font-weight: 700;
  letter-spacing: 0;
}
.brand-name { font-size: 15px; font-weight: 600; display: flex; align-items: baseline; gap: 8px; letter-spacing: -.02em; }
.brand-name .en { font-weight: 700; }
.brand-sub {
  font-family: var(--font-mono); font-size: 10.5px; font-weight: 500;
  color: var(--muted); letter-spacing: .04em; text-transform: uppercase;
  border-left: 1px solid var(--line-2); padding-left: 8px;
}
.topbar-right { display: flex; align-items: center; gap: 12px; flex-shrink: 0; }
.back-pill {
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
  font-size: 12.5px; color: var(--muted); font-weight: 500;
  padding: 7px 13px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface);
  transition: color .15s, border-color .15s;
}
.back-pill:hover { color: var(--ink); border-color: var(--muted-2); }

.prog-chip { display: inline-flex; align-items: center; gap: 9px; }
.ring { display: block; }
.ring .ring-track { stroke: var(--track); }
.ring .ring-fill  { stroke: var(--accent); stroke-linecap: round; transition: stroke-dashoffset .9s var(--ease); }
.prog-chip-txt { white-space: nowrap; }
.prog-chip-txt b { font-family: var(--font-mono); font-size: 13px; font-weight: 700; display: block; line-height: 1.1; font-variant-numeric: tabular-nums; }
.prog-chip-txt span { font-size: 10.5px; color: var(--muted); white-space: nowrap; }

/* ============================================================
   HOME
   ============================================================ */
.home-main { max-width: var(--maxw); margin: 0 auto; padding: 0 var(--pad-x) 80px; }

.hero {
  display: grid; grid-template-columns: 1.45fr 1fr; gap: 36px; align-items: end;
  padding: 52px 0 36px;
}
.eyebrow {
  display: inline-flex; align-items: center; gap: 8px;
  font-family: var(--font-mono); font-size: 11.5px; font-weight: 600;
  letter-spacing: .04em; color: var(--accent-strong);
  background: var(--accent-soft); padding: 5px 11px; border-radius: 7px; margin-bottom: 20px;
}
.hero h1 {
  font-family: var(--font-display); font-weight: 800;
  font-size: clamp(34px, 5vw, 56px); line-height: 1.02; letter-spacing: -.03em;
  color: var(--ink);
}
.hero h1 .soft { color: var(--muted-2); }
.hero-desc { margin-top: 18px; font-size: 17px; color: var(--ink-2); max-width: 46ch; line-height: 1.5; }
.hero-desc b { color: var(--ink); font-weight: 600; }
.hero-stats { display: flex; gap: 28px; margin-top: 26px; }
.hero-stat b {
  font-family: var(--font-display); font-size: 30px; font-weight: 800; display: block; line-height: 1;
  letter-spacing: -.02em; font-variant-numeric: tabular-nums;
}
.hero-stat span { font-size: 12px; color: var(--muted); margin-top: 5px; display: block; }

/* resume card */
.resume {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg);
  padding: 22px; box-shadow: var(--shadow-1); position: relative; overflow: hidden;
}
.resume::after {
  content: ""; position: absolute; right: -50px; top: -50px; width: 150px; height: 150px;
  background: radial-gradient(circle, var(--accent-soft), transparent 70%);
}
.resume-label {
  font-family: var(--font-mono); font-size: 10.5px; font-weight: 700; letter-spacing: .08em;
  text-transform: uppercase; color: var(--accent-strong);
}
.resume-course { font-size: 12.5px; color: var(--muted); margin-top: 14px; }
.resume-lesson { font-size: 21px; font-weight: 700; margin-top: 4px; line-height: 1.22; letter-spacing: -.02em; }
.resume-bar { height: 6px; background: var(--track); border-radius: 3px; margin-top: 16px; overflow: hidden; }
.resume-bar > div { height: 100%; background: var(--accent); border-radius: 3px; }
.resume-cta {
  display: inline-flex; align-items: center; gap: 7px; margin-top: 18px;
  background: var(--accent); color: #fff; padding: 11px 18px; border-radius: var(--btn-radius);
  font-size: 14px; font-weight: 600; transition: background .15s, transform .15s var(--ease);
}
.resume-cta:hover { background: var(--accent-strong); transform: translateY(-1px); }

/* toolbar */
.toolbar {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 13px 0; margin-bottom: 4px;
  position: sticky; top: 60px; z-index: 30;
  background: color-mix(in oklab, var(--bg), transparent 8%);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
}
.search {
  display: flex; align-items: center; gap: 9px; flex: 1; min-width: 220px; max-width: 400px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 999px;
  padding: 0 15px; height: 42px; transition: border-color .15s, box-shadow .15s;
}
.search:focus-within { border-color: var(--accent-line); box-shadow: 0 0 0 4px var(--accent-soft); }
.search svg { flex-shrink: 0; color: var(--muted); }
.search input { flex: 1; border: 0; background: transparent; outline: none; font-size: 15px; color: var(--ink); font-family: inherit; }
.search input::placeholder { color: var(--muted-2); }

.filters { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  border: 1px solid var(--line); background: var(--surface); color: var(--ink-2);
  padding: 9px 15px; border-radius: 999px; font-size: 13px; font-weight: 500; white-space: nowrap;
  cursor: pointer; transition: all .15s var(--ease);
}
.chip:hover { border-color: var(--muted-2); }
.chip.active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* catalog */
.cat { margin-top: 40px; }
.cat.hidden { display: none; }
.cat-head { display: flex; align-items: baseline; gap: 11px; margin-bottom: 18px; }
.cat-head h2 { font-size: 22px; font-weight: 700; letter-spacing: -.02em; }
.cat-zh { font-size: 13.5px; color: var(--muted); }
.cat-count { margin-left: auto; font-family: var(--font-mono); font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; }

.course-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(296px, 1fr)); gap: var(--gap); }

.course-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px; display: flex; flex-direction: column; gap: 11px; min-height: 184px;
  box-shadow: var(--shadow-1); cursor: pointer; position: relative;
  transition: transform .18s var(--ease), box-shadow .18s var(--ease), border-color .18s;
}
.course-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-2); border-color: var(--accent-line); }
.course-card.hidden { display: none; }

.cc-top { display: flex; align-items: center; justify-content: space-between; }
.cc-badge {
  font-family: var(--font-mono); font-size: 10px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
  color: var(--accent-strong); background: var(--accent-soft); padding: 4px 9px; border-radius: 6px;
}
.course-card.is-done .cc-badge { color: var(--good); background: var(--good-soft); }
.cc-pct { font-family: var(--font-mono); font-size: 12px; font-weight: 700; color: var(--muted); font-variant-numeric: tabular-nums; }
.course-card.is-done .cc-pct { color: var(--good); }
.cc-title { font-size: 17px; font-weight: 600; letter-spacing: -.02em; line-height: 1.28; }
.cc-title .en { font-weight: 700; }
.cc-zh { font-size: 13px; color: var(--muted); line-height: 1.5; flex: 1; }
.cc-foot { margin-top: auto; }
.cc-bar { height: 5px; background: var(--track); border-radius: 3px; overflow: hidden; }
.cc-bar > div { height: 100%; background: var(--accent); border-radius: 3px; transition: width .5s var(--ease); }
.course-card.is-done .cc-bar > div { background: var(--good); }
.cc-meta { display: flex; align-items: center; gap: 8px; margin-top: 10px; font-size: 12px; color: var(--muted); }
.cc-meta .dot { width: 3px; height: 3px; border-radius: 50%; background: var(--muted-2); }
.cc-meta .cc-status { margin-left: auto; font-family: var(--font-mono); font-weight: 600; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.course-card.is-done .cc-status { color: var(--good); }

.empty-state { text-align: center; color: var(--muted); padding: 72px 0; font-size: 15px; }

/* ============================================================
   COURSE
   ============================================================ */
.course-shell {
  max-width: var(--maxw); margin: 0 auto; padding: 24px var(--pad-x) 110px;
  display: grid; grid-template-columns: 320px 1fr; gap: 34px; align-items: start;
}
.sidebar { position: sticky; top: 84px; align-self: start; }
.course-head { margin-bottom: 16px; }
.course-head h2 { font-size: 21px; font-weight: 700; line-height: 1.22; letter-spacing: -.02em; }
.course-zh { font-size: 13px; color: var(--muted); margin-top: 6px; line-height: 1.5; }
.course-prog { display: flex; align-items: center; gap: 11px; margin-top: 15px; }
.course-prog .cp-txt { font-size: 12.5px; color: var(--muted); }
.course-prog .cp-txt b { color: var(--ink); font-weight: 700; font-family: var(--font-mono); }

.lesson-filter {
  display: flex; align-items: center; gap: 9px; margin: 13px 0;
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
  padding: 0 12px; height: 40px;
}
.lesson-filter svg { color: var(--muted); flex-shrink: 0; }
.lesson-filter input { flex: 1; border: 0; background: transparent; outline: none; font-size: 14px; color: var(--ink); font-family: inherit; }
.lesson-filter input::placeholder { color: var(--muted-2); }

.lesson-list {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 7px; box-shadow: var(--shadow-1);
  max-height: calc(100vh - 220px); overflow-y: auto;
  scrollbar-width: thin; scrollbar-color: var(--line-2) transparent;
}
.lesson-sec {
  font-family: var(--font-mono); font-size: 10px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  color: var(--muted); padding: 12px 11px 7px;
}
.lesson-sec:first-child { padding-top: 7px; }
.lesson-item {
  display: grid; grid-template-columns: 20px 24px 1fr auto; align-items: center; gap: 9px;
  width: 100%; text-align: left; border: 0; background: transparent; cursor: pointer;
  padding: 10px 11px; border-radius: 9px; font-size: 13px; color: var(--ink-2);
  transition: background .14s;
}
.lesson-item:hover { background: var(--surface-2); }
.lesson-item.active { background: var(--accent); color: #fff; }
.lesson-item.active .li-num, .lesson-item.active .li-type { color: rgba(255,255,255,.66); }
.li-check {
  width: 19px; height: 19px; border-radius: 50%; border: 2px solid var(--muted-2);
  display: grid; place-items: center; font-size: 10px; color: #fff; flex-shrink: 0;
}
.li-check.on { background: var(--good); border-color: var(--good); }
.lesson-item.active .li-check:not(.on) { border-color: rgba(255,255,255,.55); }
.li-num { font-family: var(--font-mono); font-size: 11px; font-variant-numeric: tabular-nums; color: var(--muted); font-weight: 600; }
.li-title { line-height: 1.34; }
.li-type { font-size: 11px; color: var(--muted); flex-shrink: 0; }

/* lesson main */
.lesson-main { min-width: 0; }
.crumb { font-family: var(--font-mono); font-size: 11.5px; color: var(--muted); margin-bottom: 9px; letter-spacing: .01em; }
.crumb .sep { margin: 0 7px; opacity: .55; }
.lesson-title {
  font-size: clamp(25px, 3.2vw, 33px); font-weight: 700;
  line-height: 1.18; letter-spacing: -.03em; color: var(--ink); margin-bottom: 22px;
}
.lesson-title .li-num-big { font-family: var(--font-mono); color: var(--accent); font-weight: 700; }

.videobox {
  position: relative; width: 100%; padding-top: 56.25%; background: #000;
  border-radius: var(--radius); overflow: hidden; margin-bottom: 24px; box-shadow: var(--shadow-1);
}
.videobox iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }

/* content cards */
.card-surface {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 26px 30px; margin-bottom: 20px; box-shadow: var(--shadow-1);
}
.note h3 {
  font-size: 18px; font-weight: 700; color: var(--ink); letter-spacing: -.02em;
  margin: 24px 0 10px; display: flex; align-items: center; gap: 9px;
}
.note h3::before { content: ""; width: 6px; height: 18px; border-radius: 3px; background: var(--accent); }
.note h3:first-child { margin-top: 0; }
.note p { margin: 10px 0; font-size: 15px; color: var(--ink-2); line-height: 1.62; }
.note ul { padding-left: 2px; margin: 10px 0; list-style: none; }
.note li { position: relative; padding-left: 22px; margin: 9px 0; font-size: 15px; color: var(--ink-2); line-height: 1.6; }
.note li::before {
  content: ""; position: absolute; left: 3px; top: 9px; width: 7px; height: 7px;
  border-radius: 50%; border: 2px solid var(--accent-line);
}
.note code {
  font-family: var(--font-mono); font-size: 13px; background: var(--surface-2);
  border: 1px solid var(--line); padding: 1px 6px; border-radius: 5px; color: var(--accent-strong);
}
.note strong { color: var(--ink); font-weight: 600; }

.callout {
  display: flex; gap: 11px; padding: 15px 17px; border-radius: var(--radius-sm);
  background: var(--accent-soft); font-size: 14px; color: var(--ink-2); line-height: 1.55;
}
.callout.muted { background: var(--surface-2); }
.callout a { color: var(--accent-strong); font-weight: 600; text-decoration: underline; text-underline-offset: 2px; }
.callout .pending { font-style: normal; color: var(--muted); }

.section-eyebrow {
  display: flex; align-items: center; gap: 10px; margin: 4px 0 15px;
  font-family: var(--font-mono); font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted);
}
.section-eyebrow::after { content: ""; flex: 1; height: 1px; background: var(--line); }

/* quiz */
.quizbox h3 { font-size: 18px; font-weight: 700; margin-bottom: 6px; letter-spacing: -.02em; }
.fq-score {
  font-family: var(--font-mono); font-weight: 600; color: var(--accent-strong); margin: 4px 0 16px; font-size: 13.5px;
  min-height: 1.2em; font-variant-numeric: tabular-nums;
}
.qitem { margin-bottom: 22px; }
.qitem:last-child { margin-bottom: 0; }
.qtext { font-weight: 600; font-size: 15px; margin-bottom: 11px; color: var(--ink); line-height: 1.45; }
.qtext .qn { font-family: var(--font-mono); color: var(--accent); margin-right: 6px; }
.qopt {
  display: block; width: 100%; text-align: left; padding: 12px 15px; margin: 8px 0;
  border: 1.5px solid var(--line); border-radius: var(--radius-sm); background: var(--surface);
  cursor: pointer; font-size: 14px; color: var(--ink-2); transition: all .15s var(--ease); font-family: inherit;
}
.qopt:hover:not(:disabled) { border-color: var(--accent-line); background: var(--accent-soft); }
.qopt.correct { border-color: var(--good); background: var(--good-soft); color: var(--ink); font-weight: 500; }
.qopt.wrong { border-color: var(--bad); background: var(--bad-soft); color: var(--ink); }
.qopt:disabled { cursor: default; }
.qexplain {
  margin-top: 10px; padding: 12px 15px; font-size: 13.5px; color: var(--ink-2); line-height: 1.55;
  background: var(--surface-2); border-left: 3px solid var(--accent); border-radius: 0 8px 8px 0;
  display: none;
}
.qexplain.show { display: block; }

/* sticky action bar */
.lesson-nav {
  position: sticky; bottom: 18px; z-index: 20; margin-top: 28px;
  display: flex; align-items: center; gap: 12px; justify-content: space-between;
  background: color-mix(in oklab, var(--surface), transparent 14%);
  -webkit-backdrop-filter: blur(16px) saturate(160%); backdrop-filter: blur(16px) saturate(160%);
  border: 1px solid var(--line); border-radius: 999px; padding: 9px 11px; box-shadow: var(--shadow-2);
}
.btn {
  display: inline-flex; align-items: center; gap: 7px; padding: 11px 19px;
  border-radius: 999px; border: 0; font-size: 14px; font-weight: 600; cursor: pointer;
  transition: all .15s var(--ease); white-space: nowrap; font-family: inherit;
}
.btn:disabled { opacity: .34; cursor: default; }
.btn-ghost { background: transparent; color: var(--ink-2); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-2); }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--accent-strong); transform: translateY(-1px); }
.btn-done { background: var(--good); color: #fff; }
.btn-done:hover:not(:disabled) { filter: brightness(.95); }

.sidebar-toggle { display: none; }

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 1080px) { .course-shell { grid-template-columns: 288px 1fr; gap: 24px; } }
@media (max-width: 880px) {
  .hero { grid-template-columns: 1fr; gap: 26px; padding: 36px 0 28px; }
  .course-shell { grid-template-columns: 1fr; }
  .sidebar { position: static; }
  .lesson-list { max-height: 52vh; }
  .lesson-list.collapsed { display: none; }
  .sidebar-toggle {
    display: flex; align-items: center; justify-content: space-between; width: 100%;
    margin-top: 12px; padding: 13px 15px; border: 1px solid var(--line); border-radius: 11px;
    background: var(--surface); font-size: 14px; font-weight: 600; cursor: pointer; color: var(--ink);
  }
  .sidebar-toggle span { font-family: var(--font-mono); font-size: 11px; color: var(--muted); }
  .lesson-nav { bottom: 12px; }
  .btn span.lbl { display: none; }
  .btn-primary span.lbl, .btn-done span.lbl { display: inline; }
}
@media (max-width: 560px) {
  .topbar-inner { height: 56px; }
  .brand-sub { display: none; }
  .card-surface { padding: 20px 18px; }
  .hero-stats { gap: 18px; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; scroll-behavior: auto !important; }
}
