/* Family AI Lab — minimal: white paper, black ink, one blue for "on". Home = a 3 × 3 deck of lessons; course = one reading column, labs full width. */
:root {
  --bg: #FFFFFF;
  --ink: #16181C;
  --muted: #737985;
  --line: #E5E7EB;
  --hover: #F4F5F7;
  --faint: #C5CAD2;
  --accent: #2C5BFF;
  --soft: #E9EEFF;
  --neg: #F08A4B;
  --shadow: 0 30px 80px rgba(22, 24, 28, 0.14);
  --font: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Segoe UI", "Noto Sans SC", "Noto Sans", Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --radius: 18px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0F1013; --ink: #ECEDEF; --muted: #8D939D; --line: #24272D; --hover: #1A1C21; --faint: #3A3E46;
    --accent: #7E9BFF; --soft: #1B2240; --neg: #F0A06E; --shadow: 0 30px 80px rgba(0, 0, 0, 0.5);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0F1013; --ink: #ECEDEF; --muted: #8D939D; --line: #24272D; --hover: #1A1C21; --faint: #3A3E46;
  --accent: #7E9BFF; --soft: #1B2240; --neg: #F0A06E; --shadow: 0 30px 80px rgba(0, 0, 0, 0.5);
  color-scheme: dark;
}

/* one language at a time (both stay in the page for search engines) */
html[data-lang="zh"] .en, html[data-lang="en"] .zh { display: none !important; }

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font); font-size: 17px; line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}
body.locked { overflow: hidden; }
a { color: inherit; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 8px; }
.vh { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); }
code { font-family: var(--mono); font-size: 0.88em; background: var(--hover); padding: 0.08em 0.38em; border-radius: 5px; }

/* ---------- top bar ---------- */
.bar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 30; display: flex; justify-content: space-between; align-items: center;
  padding: max(10px, env(safe-area-inset-top, 0px)) max(12px, env(safe-area-inset-right, 0px)) 10px max(12px, env(safe-area-inset-left, 0px));
  pointer-events: none;
}
.bar > * { pointer-events: auto; }
.tools { display: flex; gap: 4px; }
.icon {
  display: inline-flex; align-items: center; justify-content: center; gap: 4px; min-width: 44px; height: 44px; padding: 0 10px;
  border: 0; border-radius: 12px; background: transparent; color: var(--ink); cursor: pointer; text-decoration: none;
  transition: background 0.2s;
}
.icon:hover { background: var(--hover); }
.icon svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
a.icon svg circle { fill: currentColor; stroke: none; }
.langtag { font-size: 12px; font-weight: 600; letter-spacing: 0.02em; }
.course .bar { position: sticky; background: color-mix(in srgb, var(--bg) 86%, transparent); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); }

/* ---------- drawings ---------- */
.thumb { display: grid; place-items: center; min-width: 0; min-height: 0; }
.thumb svg { width: 100%; height: 100%; max-width: 100%; display: block; }
svg .ink { fill: var(--ink); }
svg .acc { fill: var(--accent); }
svg .box { fill: none; stroke: var(--faint); stroke-width: 1; }
svg .faint { fill: var(--faint); }
svg .soft { fill: var(--soft); }
svg .neg { fill: var(--neg); }
svg .bg { fill: var(--bg); }
svg .stroke { fill: none; stroke: var(--ink); stroke-width: 1.4; stroke-linecap: round; }
svg .faintline { stroke: var(--faint); }
svg .thick { fill: none; stroke: var(--ink); stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
svg .dash { fill: none; stroke: var(--faint); stroke-dasharray: 2 2; }
svg .accline { stroke: var(--accent); stroke-width: 3; stroke-linecap: round; }
svg .txt, svg .acctxt, svg .bgtxt { font-family: var(--mono); font-weight: 700; }
svg .txt { fill: var(--ink); }
svg .acctxt { fill: var(--accent); }
svg .bgtxt { fill: var(--bg); }

/* ---------- home: the 3 × 3 deck ---------- */
.home main {
  min-height: 100dvh; display: grid; place-items: center;
  padding: 72px max(16px, env(safe-area-inset-right, 0px)) 40px max(16px, env(safe-area-inset-left, 0px));
}
.deck {
  width: min(100%, 740px, calc(100dvh - 130px)); min-width: min(100%, 300px);
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: clamp(8px, 1.8vw, 18px);
}
html:not(.js) .deck .card:nth-child(n + 10) { display: none; }
.card {
  position: relative; aspect-ratio: 1; min-width: 0; display: grid; grid-template-rows: minmax(0, 1fr) auto; gap: 6px;
  padding: 11% 11% 9%; border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg);
  text-decoration: none; color: var(--ink);
  transition: transform 0.35s cubic-bezier(0.2, 0.8, 0.2, 1), border-color 0.35s, box-shadow 0.35s;
}
.card:hover { transform: translateY(-4px); border-color: var(--faint); box-shadow: 0 14px 40px rgba(22, 24, 28, 0.08); }
.card .thumb { padding: 4% 6%; }
.meta { display: grid; gap: 1px; min-width: 0; }
.lv { font-size: 11px; letter-spacing: 0.06em; color: var(--muted); }
.card .name { font-size: clamp(13px, 1.5vw, 15px); font-weight: 600; line-height: 1.3; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.deck.ready:not(.settled) .card { animation: rise 0.7s cubic-bezier(0.2, 0.8, 0.2, 1) both; animation-delay: var(--d, 0ms); }
@keyframes rise { from { opacity: 0; transform: translateY(14px) scale(0.96); } to { opacity: 1; transform: none; } }

/* ---------- home: the zoom-in card ---------- */
.modal { position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; padding: 16px; }
.scrim { position: absolute; inset: 0; background: color-mix(in srgb, var(--bg) 62%, transparent); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
.sheet {
  position: relative; width: min(540px, 100%); max-height: calc(100dvh - 32px); overflow: auto;
  background: var(--bg); border: 1px solid var(--line); border-radius: 28px; box-shadow: var(--shadow);
  transform-origin: center;
}
.sheet .close { position: absolute; top: 12px; right: 12px; z-index: 1; }
.m-thumb { height: min(280px, 38dvh); padding: 36px; display: grid; place-items: center; border-bottom: 1px solid var(--line); }
.m-thumb svg { width: auto; height: 100%; }
.m-body { padding: 24px 30px 30px; display: grid; gap: 10px; }
.m-level { margin: 0; font-size: 12px; letter-spacing: 0.06em; color: var(--muted); }
#mTitle { margin: 0; font-size: clamp(22px, 4vw, 28px); line-height: 1.2; font-weight: 650; letter-spacing: -0.01em; text-wrap: balance; }
.m-sum { margin: 0; color: var(--muted); }
.m-badges { margin: 2px 0 6px; display: flex; flex-wrap: wrap; gap: 6px; }
.enter {
  justify-self: start; display: inline-flex; align-items: center; gap: 4px; padding: 12px 24px; border-radius: 999px;
  background: var(--ink); color: var(--bg); font-weight: 600; text-decoration: none; transition: transform 0.2s;
}
.enter:hover { transform: translateX(3px); }

.badge { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; padding: 1px 10px; font-size: 12px; line-height: 1.6; color: var(--muted); }
.badge.lab { border-color: var(--accent); color: var(--accent); }

/* ---------- course menu ---------- */
.drawer { position: fixed; inset: 0; z-index: 50; }
.drawer .scrim { background: rgba(15, 16, 19, 0.18); backdrop-filter: none; -webkit-backdrop-filter: none; }
.panel {
  position: absolute; top: 0; right: 0; bottom: 0; width: min(390px, 100%); overflow: auto;
  padding: max(64px, calc(env(safe-area-inset-top, 0px) + 56px)) max(28px, env(safe-area-inset-right, 0px)) 40px 28px;
  background: var(--bg); border-left: 1px solid var(--line); display: grid; align-content: start; gap: 26px;
  animation: slide 0.35s cubic-bezier(0.2, 0.8, 0.2, 1);
}
@keyframes slide { from { transform: translateX(40px); opacity: 0; } to { transform: none; opacity: 1; } }
.panel .close { position: absolute; top: max(12px, env(safe-area-inset-top, 0px)); right: 12px; }
.panel h2 { margin: 0 0 6px; display: flex; gap: 10px; align-items: baseline; font-size: 13px; font-weight: 600; letter-spacing: 0.06em; color: var(--muted); }
.lvnum { font-family: var(--mono); color: var(--faint); }
.panel ul { list-style: none; margin: 0; padding: 0; }
.panel li a { display: block; padding: 6px 0; text-decoration: none; font-size: 16px; line-height: 1.4; }
.panel li a:hover, .panel li a[aria-current="page"] { color: var(--accent); }
.panel li a[aria-current="page"] { font-weight: 600; }
.soon { margin: 0; color: var(--faint); font-size: 15px; }

/* ---------- course page ---------- */
.course main { padding: 8px max(16px, env(safe-area-inset-right, 0px)) 96px max(16px, env(safe-area-inset-left, 0px)); }
.read { width: min(720px, 100%); margin-inline: auto; }
.hero { display: grid; gap: 12px; padding: 20px 0 8px; }
.hero .thumb { width: 84px; height: 84px; margin-bottom: 8px; }
.eyebrow { margin: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.eyebrow .lv { font-size: 13px; margin-right: 4px; }
h1 { margin: 0; font-size: clamp(30px, 5.2vw, 46px); line-height: 1.14; font-weight: 650; letter-spacing: -0.02em; text-wrap: balance; }
.lead { margin: 0; font-size: 19px; color: var(--muted); max-width: 40em; }
.tabs { display: flex; gap: 24px; margin-top: 32px; border-bottom: 1px solid var(--line); }
.tabs button {
  border: 0; background: none; padding: 12px 0; margin-bottom: -1px; border-bottom: 2px solid transparent;
  color: var(--muted); font-size: 16px; cursor: pointer;
}
.tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--ink); font-weight: 600; }
.intro { margin: 36px 0 0; font-size: 20px; line-height: 1.6; text-wrap: pretty; }
.note { margin: 32px 0 0; padding: 12px 16px; border-radius: 12px; background: var(--soft); font-size: 15px; }
.block { margin-top: 44px; }
.block h2 { margin: 0 0 14px; font-size: 13px; font-weight: 600; letter-spacing: 0.06em; color: var(--muted); }
.block p { margin: 0; }
.block p.muted { font-size: 15px; }
.steps, .points { margin: 0; padding-left: 1.4em; display: grid; gap: 10px; }
.steps li::marker { color: var(--muted); font-family: var(--mono); font-size: 0.85em; }
.points li::marker { color: var(--accent); }
.pages { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(150px, 42%), 1fr)); gap: 18px; margin-top: 16px; }
.pages figure { margin: 0; }
.pages img { display: block; width: 100%; height: auto; border: 1px solid var(--line); border-radius: 8px; background: #FFFFFF; transition: transform 0.3s; }
.pages a:hover img { transform: translateY(-3px); }
.pages figcaption { margin-top: 6px; font-size: 13px; color: var(--muted); line-height: 1.4; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 20px !important; }
.btn {
  display: inline-flex; align-items: center; gap: 8px; padding: 10px 18px; border-radius: 999px; border: 1px solid var(--ink);
  background: var(--ink); color: var(--bg); font-size: 15px; font-weight: 600; text-decoration: none; line-height: 1.3;
}
.btn.ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn.ghost:hover { border-color: var(--ink); }
.btn svg { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.links { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.links a { text-decoration: underline; text-decoration-color: var(--faint); text-underline-offset: 3px; overflow-wrap: anywhere; }
.links a:hover { text-decoration-color: var(--ink); }
.links .muted { font-size: 14px; }
.minis { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(210px, 100%), 1fr)); gap: 12px; }
.mini {
  display: grid; grid-template-columns: 52px minmax(0, 1fr); gap: 12px; align-items: center; padding: 10px 14px 10px 10px;
  border: 1px solid var(--line); border-radius: 14px; text-decoration: none; transition: border-color 0.2s;
}
.mini:hover { border-color: var(--faint); }
.mini .thumb { width: 52px; height: 52px; }
.mini .lv { display: block; font-size: 11px; }
.mini .name { display: block; font-size: 15px; font-weight: 600; line-height: 1.35; }

.labpane { margin: 20px auto 0; max-width: 1600px; }
.labbar { display: flex; flex-wrap: wrap; gap: 12px 20px; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.labbar p { margin: 0; font-size: 15px; flex: 1 1 320px; }
.labpane iframe {
  display: block; width: 100%; height: calc(100dvh - 140px); min-height: 560px;
  border: 1px solid var(--line); border-radius: 16px; background: #FFFFFF;
}

@media (max-width: 560px) {
  .card { padding: 14%; }
  .card .meta { display: none; }
  .m-body { padding: 20px 22px 24px; }
  .intro { font-size: 18px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
