:root {
  --bg: #f7f2e7;
  --surface: #fffdf8;
  --surface-2: #edf3f1;
  --ink: #173438;
  --muted: #687879;
  --teal: #0e4a52;
  --teal-2: #1d6870;
  --brick: #aa5c47;
  --gold: #d4a64c;
  --green: #5f8e73;
  --line: #d9ceb8;
  --danger: #a9423d;
  --shadow: 0 18px 55px rgba(27, 55, 58, .09);
  --radius: 24px;
  --max: 1240px;
  color-scheme: light;
}

[data-theme="dark"] {
  --bg: #09292e;
  --surface: #11383d;
  --surface-2: #173f44;
  --ink: #eef1e8;
  --muted: #b8c5c3;
  --teal: #7eb7bd;
  --teal-2: #8bc4ca;
  --brick: #e29174;
  --gold: #efc66d;
  --green: #8dbb9b;
  --line: #31565a;
  --danger: #f09891;
  --shadow: 0 20px 60px rgba(0, 0, 0, .25);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background:
    radial-gradient(circle at 90% 4%, rgba(212,166,76,.12), transparent 28rem),
    radial-gradient(circle at 5% 18%, rgba(29,104,112,.08), transparent 24rem),
    var(--bg);
  color: var(--ink);
  font-family: "Noto Sans CJK SC", "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

img { max-width: 100%; display: block; }
a { color: inherit; }
button, textarea { font: inherit; }
button { cursor: pointer; }

.skip-link {
  position: fixed; left: 1rem; top: -6rem; z-index: 999;
  padding: .7rem 1rem; background: var(--gold); color: #102e32; border-radius: 10px;
}
.skip-link:focus { top: 1rem; }

.topbar {
  position: sticky; top: 0; z-index: 100;
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 1.5rem;
  min-height: 74px; padding: .7rem max(1rem, calc((100vw - var(--max))/2));
  background: color-mix(in srgb, var(--bg) 84%, transparent);
  border-bottom: 1px solid color-mix(in srgb, var(--line) 70%, transparent);
  backdrop-filter: blur(18px);
}
.brand { display: flex; align-items: center; gap: .7rem; white-space: nowrap; }
.brand-mark {
  width: 42px; height: 42px; display: grid; place-items: center; border-radius: 13px;
  background: var(--teal); color: var(--bg); font-family: serif; font-size: 1.45rem; box-shadow: inset 0 0 0 1px rgba(255,255,255,.22);
}
.brand div { display: flex; flex-direction: column; line-height: 1.25; }
.brand strong { font-size: .98rem; }
.brand small { color: var(--muted); font-size: .72rem; }
.desktop-nav { display: flex; justify-content: center; gap: clamp(.7rem, 2vw, 1.7rem); }
.desktop-nav a { text-decoration: none; font-size: .88rem; color: var(--muted); transition: .2s; }
.desktop-nav a:hover { color: var(--brick); transform: translateY(-1px); }
.top-actions { display: flex; gap: .55rem; align-items: center; }

.primary-btn, .secondary-btn, .ghost-btn {
  border: 0; border-radius: 14px; padding: .74rem 1rem; text-decoration: none; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center; transition: transform .2s, box-shadow .2s, background .2s;
}
.primary-btn { background: var(--teal); color: #fffdf7; box-shadow: 0 10px 24px rgba(14,74,82,.20); }
.secondary-btn { background: var(--surface); color: var(--teal); border: 1px solid var(--line); }
.ghost-btn { background: transparent; color: var(--muted); border: 1px solid var(--line); }
.primary-btn:hover, .secondary-btn:hover, .ghost-btn:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.danger { color: var(--danger); }

.section-shell { width: min(var(--max), calc(100% - 2rem)); margin: 0 auto; padding: clamp(4.2rem, 7vw, 7rem) 0; }
.hero { min-height: calc(100vh - 74px); display: grid; grid-template-columns: 1.02fr .98fr; align-items: center; gap: clamp(2rem, 5vw, 5rem); padding-top: clamp(3rem, 7vw, 6rem); }
.eyebrow { display: inline-block; font-size: .78rem; letter-spacing: .16em; text-transform: uppercase; color: var(--brick); font-weight: 800; }
.hero h1 { margin: 1rem 0 1.2rem; font-family: "Noto Serif CJK SC", "Songti SC", serif; font-size: clamp(2.55rem, 5.2vw, 5.5rem); line-height: 1.12; letter-spacing: -.035em; }
.hero h1 em { font-style: normal; color: var(--brick); }
.hero-lead { max-width: 47rem; font-size: clamp(1rem, 1.5vw, 1.2rem); color: var(--muted); }
.hero-actions { display: flex; flex-wrap: wrap; gap: .8rem; margin: 2rem 0 1.4rem; }
.hero-tags { display: flex; gap: .5rem; flex-wrap: wrap; }
.hero-tags span { padding: .38rem .7rem; border-radius: 999px; background: var(--surface-2); color: var(--muted); font-size: .78rem; border: 1px solid color-mix(in srgb,var(--line) 65%, transparent); }
.hero-visual { position: relative; }
.hero-visual::before { content: ""; position: absolute; inset: -1.5rem 2rem 1.5rem -1.5rem; border-radius: 34px; background: var(--gold); opacity: .12; transform: rotate(-3deg); }
.hero-visual img { position: relative; border-radius: 28px; box-shadow: var(--shadow); border: 1px solid rgba(255,255,255,.16); }

.counter-band { width: min(var(--max), calc(100% - 2rem)); margin: 0 auto; padding: 1.5rem; border-radius: 28px; background: var(--teal); color: #fffdf7; box-shadow: var(--shadow); }
.counter-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; margin-bottom: 1.2rem; }
.counter-head h2 { margin: .25rem 0 0; font-size: clamp(1.3rem, 2.2vw, 2rem); font-family: serif; }
.counter-head .eyebrow { color: #efd594; }
.counter-mode { font-size: .78rem; color: #d9e5e4; border: 1px solid rgba(255,255,255,.2); padding: .35rem .6rem; border-radius: 999px; }
.counter-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: .85rem; }
.counter-grid article { background: rgba(255,255,255,.09); border: 1px solid rgba(255,255,255,.12); border-radius: 18px; padding: 1rem; display: flex; flex-direction: column; }
.counter-grid strong { font-size: clamp(1.7rem, 3vw, 2.5rem); line-height: 1.1; color: #ffe6a5; }
.counter-grid span { font-size: .8rem; color: #dce8e7; }
.micro-note { margin: .8rem 0 0; font-size: .73rem; color: #c9d8d7; }

.section-heading { max-width: 820px; margin-bottom: 2.2rem; }
.section-heading.wide { max-width: 1000px; }
.section-heading h2 { margin: .4rem 0 .65rem; font-family: "Noto Serif CJK SC", "Songti SC", serif; font-size: clamp(2rem, 4vw, 3.8rem); line-height: 1.2; letter-spacing: -.025em; }
.section-heading p { margin: 0; color: var(--muted); font-size: 1.02rem; }

.scale-grid { display: grid; grid-template-columns: repeat(4,1fr); gap: 1rem; }
.scale-card { position: relative; min-height: 330px; padding: 1.4rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 10px 30px rgba(22,52,56,.04); overflow: hidden; transition: .25s; }
.scale-card:hover { transform: translateY(-6px); box-shadow: var(--shadow); border-color: var(--teal-2); }
.scale-card::after { content: attr(data-index); position: absolute; right: .7rem; bottom: -.55rem; color: color-mix(in srgb, var(--teal) 10%, transparent); font-size: 8rem; font-weight: 900; line-height: 1; }
.scale-no { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; background: var(--brick); color: #fff; font-weight: 800; }
.scale-card:nth-child(2) .scale-no { background: var(--gold); color: #243b3e; }
.scale-card:nth-child(3) .scale-no { background: var(--teal-2); }
.scale-card:nth-child(4) .scale-no { background: var(--green); }
.scale-card h3 { font-family: serif; font-size: 2rem; margin: 1.4rem 0 .7rem; }
.scale-card p { color: var(--muted); }
.scale-card small { position: absolute; left: 1.4rem; bottom: 1.35rem; right: 1.4rem; border-top: 1px solid var(--line); padding-top: .8rem; color: var(--muted); }

.system-layout, .risk-layout { display: grid; grid-template-columns: 1.35fr .65fr; gap: 1.3rem; align-items: stretch; }
.card-panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: .6rem; box-shadow: var(--shadow); overflow: hidden; }
.card-panel img { border-radius: calc(var(--radius) - 7px); width: 100%; height: 100%; object-fit: contain; }
.system-copy { display: grid; gap: .8rem; }
.insight-card { display: grid; grid-template-columns: 52px 1fr; gap: .8rem; padding: 1rem; background: var(--surface); border: 1px solid var(--line); border-radius: 18px; }
.insight-card > span { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 13px; background: var(--surface-2); color: var(--brick); font-weight: 900; }
.insight-card h3 { margin: 0; font-size: 1rem; }
.insight-card p { margin: .3rem 0 0; color: var(--muted); font-size: .88rem; }

.thread-grid { display: grid; grid-template-columns: repeat(2,1fr); gap: 1rem; }
details { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 0 1rem; }
summary { list-style: none; padding: 1rem 0; font-weight: 800; cursor: pointer; display: flex; align-items: center; gap: .75rem; }
summary::-webkit-details-marker { display:none; }
summary::after { content: "+"; margin-left:auto; font-size:1.4rem; color:var(--muted); }
details[open] summary::after { content:"−"; }
summary span { width: 36px; height:36px; border-radius: 10px; display:grid; place-items:center; background:var(--surface-2); color:var(--brick); font-size:.8rem; }
details p { margin: 0 0 1rem 3.05rem; color: var(--muted); }

.risk-section { padding-top: 5rem; }
.formula-card { padding: 1.5rem; background: var(--teal); color: #fff; border-radius: var(--radius); box-shadow: var(--shadow); display: flex; flex-direction: column; justify-content: center; }
.formula-card > span { color: #f4d88c; font-size: .78rem; letter-spacing: .12em; }
.formula-card p { margin: 1.2rem 0 .2rem; }
.formula-card strong { color: #ffe8aa; font-size: clamp(1.3rem,2vw,2rem); line-height: 1.45; }
.formula-card b { font-size: 1.25rem; margin-top: .5rem; }
.formula-card hr { width:100%; border:0; border-top:1px solid rgba(255,255,255,.25); margin:1.4rem 0; }
.formula-card .small { color:#dbe8e7; font-size:.88rem; margin:0; }

.timeline { position: relative; display: grid; grid-template-columns: repeat(9,1fr); gap: .5rem; margin: 2.2rem 0 1rem; }
.timeline::before { content:""; position:absolute; left:4%; right:4%; top:25px; height:2px; background:var(--line); z-index:0; }
.timeline-node { position:relative; z-index:1; border:0; background:transparent; color:var(--muted); display:flex; flex-direction:column; align-items:center; gap:.45rem; padding:0 .15rem; }
.timeline-node b { width:52px; height:52px; display:grid; place-items:center; border-radius:50%; background:var(--surface); border:2px solid var(--line); transition:.2s; }
.timeline-node span { font-size:.72rem; text-align:center; line-height:1.35; }
.timeline-node:hover b, .timeline-node.active b { background:var(--brick); color:#fff; border-color:var(--brick); transform:scale(1.08); }
.timeline-node.active span { color:var(--ink); font-weight:700; }
.timeline-detail { min-height: 165px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.5rem; box-shadow: 0 10px 30px rgba(22,52,56,.04); }
.timeline-detail h3 { margin:0 0 .4rem; font-family:serif; color:var(--brick); font-size:1.6rem; }
.timeline-detail p { margin:.3rem 0; color:var(--muted); }
.timeline-detail ul { margin:.8rem 0 0; padding-left:1.2rem; }

.people-grid { display:grid; grid-template-columns:repeat(3,1fr); gap:1rem; }
.people-grid article { background:var(--surface); border:1px solid var(--line); border-radius:20px; padding:1.3rem; }
.role-icon { width:48px; height:48px; display:grid; place-items:center; border-radius:14px; background:var(--teal); color:white; font-family:serif; font-size:1.3rem; }
.people-grid h3 { margin:.9rem 0 .2rem; font-size:1.1rem; }
.people-grid b { color:var(--brick); font-size:.85rem; }
.people-grid p { color:var(--muted); font-size:.88rem; margin:.5rem 0 0; }

.ledger-tabs, .sandbox-tabs { display:flex; flex-wrap:wrap; gap:.55rem; margin-bottom:1rem; }
.ledger-tab, .sandbox-tab { border:1px solid var(--line); background:var(--surface); color:var(--muted); border-radius:999px; padding:.65rem .9rem; }
.ledger-tab.active, .sandbox-tab.active { background:var(--teal); color:#fff; border-color:var(--teal); }
.ledger-detail { min-height:210px; border-radius:var(--radius); padding:1.6rem; background:linear-gradient(135deg,var(--surface),var(--surface-2)); border:1px solid var(--line); }
.ledger-detail h3 { margin:0; font-family:serif; color:var(--brick); font-size:1.7rem; }
.ledger-detail .question-list { display:grid; grid-template-columns:repeat(2,1fr); gap:.7rem; margin-top:1rem; }
.ledger-detail .question-list span { background:var(--surface); border:1px solid var(--line); border-radius:14px; padding:.8rem; font-size:.88rem; }

.prompt-grid { display:grid; grid-template-columns:repeat(2,1fr); gap:1rem; }
.prompt-card { background:var(--surface); border:1px solid var(--line); border-radius:20px; padding:1.2rem; display:flex; flex-direction:column; }
.prompt-card header { display:flex; align-items:start; gap:.8rem; }
.prompt-card .prompt-index { width:38px;height:38px;display:grid;place-items:center;border-radius:11px;background:var(--surface-2);color:var(--brick);font-weight:800; }
.prompt-card h3 { margin:0; font-size:1rem; }
.prompt-card p { color:var(--muted); font-size:.82rem; margin:.25rem 0 0; }
.prompt-text { margin:1rem 0; padding:1rem; border-radius:14px; background:color-mix(in srgb,var(--surface-2) 75%, transparent); font-family:ui-monospace,SFMono-Regular,Menlo,monospace; font-size:.78rem; white-space:pre-wrap; flex:1; max-height:190px; overflow:auto; border:1px dashed var(--line); }
.copy-prompt { align-self:flex-end; }

.scenario-card { padding:1.2rem 1.35rem; background:var(--surface-2); border-left:5px solid var(--brick); border-radius:0 18px 18px 0; margin-bottom:1rem; }
.scenario-card h3 { margin:0; font-family:serif; font-size:1.4rem; }
.scenario-card p { margin:.35rem 0 0; color:var(--muted); }
.choice-grid { display:grid; grid-template-columns:repeat(4,1fr); gap:.8rem; }
.choice-card { text-align:left; border:1px solid var(--line); background:var(--surface); border-radius:18px; padding:1rem; color:var(--ink); transition:.2s; }
.choice-card:hover, .choice-card.selected { transform:translateY(-4px); border-color:var(--brick); box-shadow:var(--shadow); }
.choice-card b { display:block; color:var(--brick); margin-bottom:.4rem; }
.choice-card span { color:var(--muted); font-size:.82rem; }
.sandbox-result { margin-top:1rem; background:var(--teal); color:#fff; padding:1.2rem; border-radius:18px; }
.sandbox-result span { color:#f2d88d; font-weight:800; }
.sandbox-result p { margin:.35rem 0 0; color:#d9e7e6; }

.portfolio-layout { display:grid; grid-template-columns:1fr 340px; gap:1rem; }
.project-grid { display:grid; grid-template-columns:repeat(3,1fr); gap:.7rem; }
.project-card { position:relative; border:1px solid var(--line); background:var(--surface); border-radius:16px; padding:.9rem; min-height:120px; text-align:left; color:var(--ink); }
.project-card.selected { border-color:var(--teal); background:color-mix(in srgb,var(--teal) 9%,var(--surface)); box-shadow:0 8px 26px rgba(14,74,82,.12); }
.project-card h4 { margin:0 0 .35rem; }
.project-card p { color:var(--muted); font-size:.76rem; margin:0; }
.project-card .check { position:absolute; right:.65rem; top:.6rem; width:24px;height:24px;border-radius:50%;border:1px solid var(--line);display:grid;place-items:center;font-size:.7rem; }
.project-card.selected .check { background:var(--teal); color:#fff; border-color:var(--teal); }
.score-panel { position:sticky; top:92px; align-self:start; background:var(--surface); border:1px solid var(--line); border-radius:20px; padding:1.1rem; }
.score-panel h3 { margin-top:0; }
.score-row { display:grid; grid-template-columns:72px 1fr 28px; gap:.5rem; align-items:center; margin:.7rem 0; font-size:.78rem; }
progress { width:100%; height:10px; appearance:none; }
progress::-webkit-progress-bar { background:var(--surface-2); border-radius:999px; }
progress::-webkit-progress-value { background:var(--teal-2); border-radius:999px; }
.score-panel p { color:var(--muted); font-size:.82rem; }

.risk-control-grid { display:grid; grid-template-columns:repeat(3,1fr); gap:.75rem; }
.control-card { display:flex; align-items:flex-start; gap:.7rem; border:1px solid var(--line); background:var(--surface); border-radius:16px; padding:.9rem; }
.control-card input { margin-top:.3rem; accent-color:var(--teal); }
.control-card b { display:block; font-size:.9rem; }
.control-card span { display:block; color:var(--muted); font-size:.75rem; margin-top:.25rem; }
.risk-meter { margin-top:1rem; background:var(--surface); border:1px solid var(--line); border-radius:20px; padding:1.2rem; display:grid; grid-template-columns:180px 1fr; gap:1.2rem; align-items:center; }
.risk-gauge { width:160px;height:160px;border-radius:50%;position:relative;display:grid;place-items:center;background:conic-gradient(var(--danger) 0 35%,var(--gold) 35% 68%,var(--green) 68% 100%); }
.risk-gauge::after { content:""; position:absolute; inset:18px; border-radius:50%; background:var(--surface); }
.risk-gauge #riskNeedle { position:absolute; z-index:2; width:4px;height:62px;background:var(--ink);transform-origin:50% 100%;transform:translateY(-31px) rotate(65deg);border-radius:4px;transition:.5s; }
.risk-gauge span { z-index:3; font-size:2rem; font-weight:900; margin-top:.2rem; }
.risk-gauge small { position:absolute; z-index:3; bottom:38px; color:var(--muted); font-size:.7rem; }
.risk-meter h3 { margin:0; font-family:serif; font-size:1.5rem; }
.risk-meter p { color:var(--muted); }

.notebook-layout { display:grid; grid-template-columns:1fr 210px; gap:1rem; }
textarea { width:100%; resize:vertical; background:var(--surface); color:var(--ink); border:1px solid var(--line); border-radius:20px; padding:1.1rem; outline:none; }
textarea:focus { border-color:var(--teal); box-shadow:0 0 0 4px color-mix(in srgb,var(--teal) 14%,transparent); }
.notebook-actions { display:flex; flex-direction:column; gap:.7rem; }
.notebook-actions small { color:var(--muted); }

.source-grid { display:grid; grid-template-columns:repeat(3,1fr); gap:.8rem; }
.source-grid a { text-decoration:none; background:var(--surface); border:1px solid var(--line); border-radius:16px; padding:1rem; transition:.2s; }
.source-grid a:hover { transform:translateY(-3px); border-color:var(--teal); box-shadow:var(--shadow); }
.source-grid b { display:block; color:var(--brick); }
.source-grid span { color:var(--muted); font-size:.78rem; }
.source-note { color:var(--muted); font-size:.78rem; margin-top:1rem; }

footer { width:min(var(--max),calc(100% - 2rem)); margin:0 auto 1.5rem; padding:1.6rem; border-radius:24px; background:var(--teal); color:white; display:flex; justify-content:space-between; align-items:center; gap:1rem; }
footer div { display:flex; flex-direction:column; }
footer span, footer p { color:#d8e5e4; font-size:.8rem; margin:0; }
footer a { color:#ffe3a0; text-decoration:none; }

.toast { position:fixed; left:50%; bottom:calc(1.4rem + env(safe-area-inset-bottom)); transform:translate(-50%,120px); background:#102f34; color:#fff; padding:.75rem 1rem; border-radius:12px; box-shadow:var(--shadow); z-index:300; transition:.25s; opacity:0; pointer-events:none; }
.toast.show { transform:translate(-50%,0); opacity:1; }

@media (max-width: 1000px) {
  .desktop-nav { display:none; }
  .topbar { grid-template-columns:1fr auto; }
  .hero { grid-template-columns:1fr; min-height:auto; }
  .hero-visual { max-width:820px; }
  .scale-grid { grid-template-columns:repeat(2,1fr); }
  .system-layout, .risk-layout { grid-template-columns:1fr; }
  .people-grid { grid-template-columns:repeat(2,1fr); }
  .portfolio-layout { grid-template-columns:1fr; }
  .score-panel { position:static; }
  .source-grid { grid-template-columns:repeat(2,1fr); }
  .timeline { overflow-x:auto; grid-template-columns:repeat(9,minmax(100px,1fr)); padding-bottom:.6rem; }
  .choice-grid { grid-template-columns:repeat(2,1fr); }
}

@media (max-width: 680px) {
  .section-shell { width:min(100% - 1.2rem,var(--max)); padding:4rem 0; }
  .topbar { min-height:64px; padding:.55rem .65rem; gap:.5rem; }
  .brand-mark { width:38px;height:38px; }
  .brand small { display:none; }
  .install-btn { display:none!important; }
  .top-actions .ghost-btn { padding:.58rem .7rem; font-size:.78rem; }
  .hero { padding-top:2.5rem; gap:2rem; }
  .hero h1 { font-size:2.6rem; }
  .hero-lead { font-size:.98rem; }
  .hero-visual::before { inset:-.7rem .8rem .7rem -.7rem; }
  .counter-band { width:calc(100% - 1.2rem); padding:1rem; }
  .counter-head { align-items:flex-start; flex-direction:column; }
  .counter-grid { grid-template-columns:repeat(2,1fr); }
  .scale-grid, .thread-grid, .people-grid, .prompt-grid, .source-grid { grid-template-columns:1fr; }
  .scale-card { min-height:270px; }
  .ledger-detail .question-list { grid-template-columns:1fr; }
  .choice-grid, .project-grid, .risk-control-grid { grid-template-columns:1fr; }
  .notebook-layout { grid-template-columns:1fr; }
  .notebook-actions { flex-direction:row; flex-wrap:wrap; }
  .risk-meter { grid-template-columns:1fr; justify-items:center; text-align:center; }
  .timeline-detail { min-height:220px; }
  footer { flex-direction:column; align-items:flex-start; }
}

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