@layer reset, tokens, base, layout, components, views, responsive;

@layer reset {
  *, *::before, *::after { box-sizing: border-box; }
  html { color-scheme: dark; }
  body, h1, h2, h3, p, figure { margin: 0; }
  button, input, textarea, select { font: inherit; color: inherit; }
  button { border: 0; cursor: pointer; }
  svg { display: block; }
}

@layer tokens {
  :root {
    --display: "Songti SC", "STSong", serif;
    --sans: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    --mono: "SFMono-Regular", "Cascadia Code", "Liberation Mono", monospace;
    --ease: cubic-bezier(.22, 1, .36, 1);
    --rail-w: 104px;
    --top-h: 74px;
    --content-x: clamp(24px, 4vw, 72px);
    --radius: 6px;
  }

  body[data-theme="atelier"] {
    --bg: #0b0f10;
    --bg-elev: #101516;
    --panel: #141a1b;
    --panel-2: #1a2122;
    --ink: #f4f0e7;
    --ink-soft: #d5d2c9;
    --muted: #8f9a99;
    --line: #2b3535;
    --line-strong: #3b4847;
    --accent: #e9c86c;
    --accent-ink: #171409;
    --accent-soft: #282516;
    --signal: #66ddbd;
    --signal-soft: #102a25;
    --danger: #ff7d6d;
    --shadow: rgba(0, 0, 0, .28);
  }

  body[data-theme="ledger"] {
    color-scheme: light;
    --bg: #ece9df;
    --bg-elev: #f4f1e8;
    --panel: #faf7ef;
    --panel-2: #e5e1d7;
    --ink: #1c201e;
    --ink-soft: #353c39;
    --muted: #6f7772;
    --line: #c9c6bd;
    --line-strong: #999c94;
    --accent: #cc5b3c;
    --accent-ink: #fff8ef;
    --accent-soft: #f2dcd2;
    --signal: #167766;
    --signal-soft: #d9ebe4;
    --danger: #b83931;
    --shadow: rgba(46, 39, 25, .12);
    --radius: 2px;
  }

  body[data-theme="terminal"] {
    --bg: #06111b;
    --bg-elev: #081725;
    --panel: #0b1c2b;
    --panel-2: #0e2639;
    --ink: #e4f2f3;
    --ink-soft: #bed0d4;
    --muted: #7896a0;
    --line: #173a4b;
    --line-strong: #276078;
    --accent: #5ff0cf;
    --accent-ink: #03130f;
    --accent-soft: #0b302e;
    --signal: #6aa8ff;
    --signal-soft: #0f2848;
    --danger: #ff657a;
    --shadow: rgba(0, 0, 0, .32);
    --radius: 0px;
  }
}

@layer base {
  html, body { min-height: 100%; }
  body {
    min-width: 320px;
    background: var(--bg);
    color: var(--ink);
    font-family: var(--sans);
    font-size: 15px;
    transition: background .35s var(--ease), color .35s var(--ease);
  }
  body::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    opacity: .32;
    background-image: repeating-linear-gradient(90deg, transparent 0, transparent 79px, color-mix(in oklab, var(--line) 28%, transparent) 80px);
  }
  body[data-theme="ledger"]::before {
    opacity: .17;
    background-image:
      repeating-linear-gradient(0deg, transparent 0, transparent 23px, color-mix(in oklab, var(--line) 42%, transparent) 24px),
      repeating-linear-gradient(90deg, transparent 0, transparent 95px, color-mix(in oklab, var(--line) 24%, transparent) 96px);
  }
  body[data-theme="terminal"]::before {
    opacity: .35;
    background-image:
      linear-gradient(color-mix(in oklab, var(--signal) 5%, transparent) 1px, transparent 1px),
      linear-gradient(90deg, color-mix(in oklab, var(--signal) 5%, transparent) 1px, transparent 1px);
    background-size: 24px 24px;
  }
  ::selection { background: var(--accent); color: var(--accent-ink); }
  :focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
  .micro-label {
    color: var(--signal);
    font-family: var(--mono);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .14em;
  }
  .mono { font-family: var(--mono); }
  .muted { color: var(--muted); }
  .accent { color: var(--accent); }
  [hidden] { display: none !important; }
}

@layer layout {
  .app-shell { min-height: 100vh; display: grid; grid-template-columns: var(--rail-w) 1fr; }
  .rail {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 20;
    width: var(--rail-w);
    display: flex;
    flex-direction: column;
    align-items: center;
    border-right: 1px solid var(--line);
    background: color-mix(in oklab, var(--bg-elev) 92%, transparent);
    backdrop-filter: blur(18px);
  }
  .main-area { grid-column: 2; min-width: 0; }
  .topbar {
    position: sticky;
    top: 0;
    z-index: 15;
    height: var(--top-h);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 var(--content-x);
    border-bottom: 1px solid var(--line);
    background: color-mix(in oklab, var(--bg) 88%, transparent);
    backdrop-filter: blur(18px);
  }
  .view { padding: clamp(32px, 5vw, 74px) var(--content-x) 80px; }
  .page { max-width: 1500px; margin: 0 auto; animation: page-in .42s var(--ease); }
  .page-head { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 32px; align-items: end; margin-bottom: 44px; }
  .page-head-copy { max-width: 820px; }
  .page-head h1 {
    margin-top: 12px;
    font-family: var(--display);
    font-size: clamp(42px, 5vw, 68px);
    font-weight: 700;
    line-height: .98;
    letter-spacing: -.045em;
    text-wrap: balance;
  }
  .page-head p { margin-top: 18px; max-width: 720px; color: var(--muted); font-size: 17px; line-height: 1.8; text-wrap: pretty; }
  .grid-12 { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 20px; }
  .span-12 { grid-column: span 12; }
  .span-8 { grid-column: span 8; }
  .span-7 { grid-column: span 7; }
  .span-6 { grid-column: span 6; }
  .span-5 { grid-column: span 5; }
  .span-4 { grid-column: span 4; }
}

@layer components {
  .brand {
    width: 100%; height: 90px;
    display: grid; place-items: center;
    gap: 4px;
    background: transparent; color: var(--ink);
    border-bottom: 1px solid var(--line);
  }
  .brand-mark { position: relative; width: 36px; height: 24px; display: block; }
  .brand-mark i { position: absolute; display: block; height: 3px; background: var(--accent); transform-origin: left center; }
  .brand-mark i:nth-child(1) { width: 27px; left: 3px; top: 2px; transform: rotate(24deg); }
  .brand-mark i:nth-child(2) { width: 31px; left: 3px; top: 11px; transform: rotate(-18deg); }
  .brand-mark i:nth-child(3) { width: 18px; left: 13px; top: 20px; transform: rotate(-51deg); }
  .brand-word { font-family: var(--display); font-size: 16px; font-weight: 700; letter-spacing: .12em; }
  .rail-nav { width: 100%; padding: 22px 12px; display: grid; gap: 7px; }
  .nav-item {
    position: relative;
    min-height: 58px;
    display: grid;
    place-items: center;
    gap: 3px;
    background: transparent;
    color: var(--muted);
    border-radius: var(--radius);
    font-size: 11px;
    transition: color .2s ease, background .2s ease;
  }
  .nav-item:hover { color: var(--ink); background: var(--panel); }
  .nav-item.is-active { color: var(--ink); background: var(--panel-2); }
  .nav-item.is-active::after {
    content: ""; position: absolute; right: -12px; width: 3px; height: 26px; background: var(--accent);
  }
  .nav-icon, .nav-icon svg { width: 19px; height: 19px; }
  .rail-foot { margin-top: auto; padding: 18px 0 24px; }
  .avatar {
    width: 42px; height: 42px; border-radius: 50%; background: var(--signal-soft); color: var(--signal);
    border: 1px solid color-mix(in oklab, var(--signal) 40%, var(--line)); font-family: var(--mono); font-weight: 700;
  }
  .crumbs { display: flex; align-items: center; gap: 9px; color: var(--muted); font-size: 13px; }
  .crumbs b { color: var(--line-strong); }
  .crumbs strong { color: var(--ink-soft); font-weight: 600; }
  .top-actions { display: flex; align-items: center; gap: 10px; }
  .status-pill, .balance-pill, .design-button {
    min-height: 38px; display: flex; align-items: center; gap: 8px; padding: 0 13px;
    border: 1px solid var(--line); background: var(--bg-elev); color: var(--muted); border-radius: 999px; font-size: 12px;
  }
  .status-pill b { color: var(--signal); font-family: var(--mono); }
  .status-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--signal); box-shadow: 0 0 0 5px color-mix(in oklab, var(--signal) 13%, transparent); }
  .balance-pill strong { color: var(--ink); font-family: var(--mono); font-size: 14px; }
  .balance-pill .nav-icon { color: var(--accent); }
  .design-button { border-radius: var(--radius); color: var(--ink-soft); }
  .status-pill:hover, .balance-pill:hover, .design-button:hover { border-color: var(--line-strong); color: var(--ink); }
  .panel {
    position: relative;
    background: color-mix(in oklab, var(--panel) 96%, transparent);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: 0 18px 60px -42px var(--shadow);
  }
  .panel-pad { padding: clamp(22px, 3vw, 36px); }
  .panel-title { display: flex; align-items: start; justify-content: space-between; gap: 20px; margin-bottom: 24px; }
  .panel-title h2 { font-size: 20px; font-weight: 650; letter-spacing: -.02em; }
  .panel-title p { margin-top: 7px; color: var(--muted); font-size: 13px; line-height: 1.6; }
  .panel-index { color: var(--muted); font-family: var(--mono); font-size: 11px; }
  .primary-button, .secondary-button, .ghost-button {
    min-height: 46px; display: inline-flex; align-items: center; justify-content: center; gap: 10px;
    padding: 0 20px; border-radius: var(--radius); font-weight: 650; transition: transform .2s var(--ease), filter .2s ease, border-color .2s ease;
  }
  .primary-button { background: var(--accent); color: var(--accent-ink); box-shadow: 0 12px 30px -18px var(--accent); }
  .primary-button:hover { transform: translateY(-2px); filter: brightness(1.05); }
  .primary-button:disabled { opacity: .55; cursor: wait; transform: none; }
  button:disabled { cursor: wait; }
  .secondary-button { background: var(--signal-soft); color: var(--signal); border: 1px solid color-mix(in oklab, var(--signal) 30%, var(--line)); }
  .ghost-button { background: transparent; color: var(--ink-soft); border: 1px solid var(--line); }
  .ghost-button:hover, .secondary-button:hover { border-color: var(--line-strong); }
  .small-button { min-height: 36px; padding: 0 13px; font-size: 12px; }
  .head-actions { display: flex; align-items: center; justify-content: flex-end; gap: 10px; }
  .icon-button { width: 40px; height: 40px; display: grid; place-items: center; background: transparent; color: var(--muted); font-size: 24px; }
  .field { display: grid; gap: 9px; }
  .field + .field { margin-top: 22px; }
  .field label, .field-label { color: var(--ink-soft); font-size: 13px; font-weight: 600; }
  input, textarea, select {
    width: 100%; border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg-elev); outline: 0;
    transition: border-color .2s ease, box-shadow .2s ease;
  }
  input, select { height: 48px; padding: 0 15px; }
  textarea { min-height: 154px; padding: 16px; resize: vertical; line-height: 1.75; }
  input::placeholder, textarea::placeholder { color: color-mix(in oklab, var(--muted) 65%, transparent); }
  input:focus, textarea:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in oklab, var(--accent) 12%, transparent); }
  .field-note { color: var(--muted); font-size: 11px; line-height: 1.6; }
  .consent-check { display: flex; align-items: flex-start; gap: 10px; margin-top: 18px; color: var(--muted); font-size: 11px; line-height: 1.6; }
  .consent-check input { width: 16px; height: 16px; flex: 0 0 auto; margin-top: 1px; accent-color: var(--accent); }
  .source-picker { margin-top: 18px; }
  .provider-warning { display: flex; gap: 12px; margin: 18px 0; padding: 14px 16px; border: 1px solid color-mix(in oklab, var(--accent) 45%, var(--line)); background: color-mix(in oklab, var(--accent) 8%, transparent); color: var(--muted); font-size: 12px; line-height: 1.6; }
  .provider-warning b { flex: 0 0 auto; color: var(--accent); }
  .segmented { display: inline-flex; gap: 3px; padding: 3px; border: 1px solid var(--line); background: var(--bg-elev); border-radius: var(--radius); }
  .segmented button { min-height: 34px; padding: 0 12px; border-radius: calc(var(--radius) - 2px); background: transparent; color: var(--muted); font-size: 12px; }
  .segmented button.is-active { background: var(--panel-2); color: var(--ink); }
  .choice-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
  .choice {
    min-height: 58px; padding: 12px 14px; display: flex; flex-direction: column; align-items: start; justify-content: center;
    background: var(--bg-elev); color: var(--muted); border: 1px solid var(--line); border-radius: var(--radius); text-align: left;
  }
  .choice b { color: var(--ink-soft); font-size: 13px; }
  .choice small { margin-top: 3px; font-family: var(--mono); font-size: 10px; }
  .choice.is-active { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
  .choice.is-active b { color: var(--accent); }
  .chips { display: flex; flex-wrap: wrap; gap: 8px; }
  .chip { min-height: 36px; padding: 0 13px; border: 1px solid var(--line); border-radius: 999px; background: var(--bg-elev); color: var(--muted); font-size: 12px; }
  .chip.is-active { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }
  .tag { display: inline-flex; align-items: center; min-height: 25px; padding: 0 9px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); font-size: 10px; font-family: var(--mono); }
  .tag.good { color: var(--signal); background: var(--signal-soft); border-color: color-mix(in oklab, var(--signal) 30%, var(--line)); }
  .tag.gold { color: var(--accent); background: var(--accent-soft); border-color: color-mix(in oklab, var(--accent) 30%, var(--line)); }
  .divider { height: 1px; background: var(--line); }
  .empty-state { min-height: 310px; display: grid; place-items: center; text-align: center; padding: 48px; }
  .empty-state h3 { font-family: var(--display); font-size: 28px; }
  .empty-state p { margin: 10px auto 22px; max-width: 440px; color: var(--muted); line-height: 1.7; }
  .toast-region { position: fixed; right: 24px; bottom: 24px; z-index: 60; display: grid; gap: 10px; }
  .toast { min-width: 280px; padding: 15px 18px; background: var(--ink); color: var(--bg); border-radius: var(--radius); box-shadow: 0 18px 50px var(--shadow); animation: toast-in .3s var(--ease); }
  .toast b { display: block; font-size: 13px; }
  .toast span { display: block; margin-top: 3px; opacity: .72; font-size: 11px; }
  .tweaks-panel {
    position: fixed; top: 86px; right: 22px; z-index: 50; width: min(390px, calc(100vw - 32px));
    padding: 20px; border: 1px solid var(--line-strong); border-radius: var(--radius); background: var(--panel); box-shadow: 0 30px 90px var(--shadow);
    animation: panel-in .3s var(--ease);
  }
  .tweaks-head { display: flex; align-items: start; justify-content: space-between; margin-bottom: 18px; }
  .tweaks-head h2 { margin-top: 7px; font-size: 19px; }
  .theme-options { display: grid; gap: 8px; }
  .theme-option { min-height: 68px; display: grid; grid-template-columns: 46px 1fr; align-items: center; gap: 13px; padding: 10px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg-elev); text-align: left; }
  .theme-option b, .theme-option small { display: block; }
  .theme-option b { font-size: 13px; }
  .theme-option small { margin-top: 3px; color: var(--muted); font-size: 11px; }
  .theme-option.is-active { border-color: var(--accent); }
  .theme-swatch { width: 42px; height: 42px; border-radius: calc(var(--radius) + 1px); border: 1px solid rgba(255,255,255,.16); }
  .swatch-atelier { background: linear-gradient(135deg, #0b0f10 0 52%, #e9c86c 52% 72%, #66ddbd 72%); }
  .swatch-ledger { background: linear-gradient(135deg, #ece9df 0 52%, #cc5b3c 52% 72%, #167766 72%); }
  .swatch-terminal { background: linear-gradient(135deg, #06111b 0 52%, #5ff0cf 52% 72%, #6aa8ff 72%); }
  .density-control { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; color: var(--muted); font-size: 12px; }
  .modal-backdrop { position: fixed; inset: 0; z-index: 70; display: grid; place-items: center; padding: 20px; background: rgba(0, 0, 0, .65); backdrop-filter: blur(8px); }
  .modal { position: relative; width: min(580px, 100%); max-height: calc(100vh - 40px); overflow: auto; padding: 34px; border: 1px solid var(--line-strong); border-radius: var(--radius); background: var(--panel); box-shadow: 0 30px 100px rgba(0,0,0,.45); animation: modal-in .34s var(--ease); }
  .modal-close { position: absolute; right: 10px; top: 10px; }
  .modal h2 { font-family: var(--display); font-size: 32px; }
  .modal p { margin-top: 12px; color: var(--muted); line-height: 1.7; }
}

@layer views {
  body[data-auth="guest"] .rail,
  body[data-auth="guest"] .topbar { display: none; }
  body[data-auth="guest"] .app-shell { display: block; }
  body[data-auth="guest"] .main-area { min-height: 100vh; }
  body[data-auth="guest"] .view { padding: 0; }
  .auth-page { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(440px, .85fr); }
  .auth-story { position: relative; min-height: 100vh; padding: clamp(34px, 5vw, 76px); display: flex; flex-direction: column; justify-content: space-between; overflow: hidden; background: var(--panel); border-right: 1px solid var(--line); }
  .auth-story::before { content: ""; position: absolute; width: min(50vw, 650px); aspect-ratio: 1; right: -26%; top: 7%; border: 1px solid var(--line-strong); transform: rotate(22deg); box-shadow: inset 0 0 0 80px color-mix(in oklab, var(--accent) 4%, transparent), inset 0 0 0 160px color-mix(in oklab, var(--signal) 3%, transparent); }
  .auth-story::after { content: "流"; position: absolute; right: -3vw; bottom: -11vw; color: var(--accent); opacity: .055; font-family: var(--display); font-size: clamp(260px, 34vw, 590px); font-weight: 800; line-height: 1; }
  .auth-brand { position: relative; z-index: 1; display: flex; align-items: center; gap: 14px; font-family: var(--display); font-size: 18px; font-weight: 700; letter-spacing: .08em; }
  .auth-manifesto { position: relative; z-index: 1; max-width: 760px; }
  .auth-manifesto h1 { margin-top: 22px; font-family: var(--display); font-size: clamp(54px, 7vw, 112px); line-height: .94; letter-spacing: -.065em; }
  .auth-manifesto h1 em { color: var(--accent); font-style: normal; }
  .auth-manifesto p { max-width: 610px; margin-top: 32px; color: var(--muted); font-size: 17px; line-height: 1.9; }
  .auth-principles { position: relative; z-index: 1; display: flex; flex-wrap: wrap; gap: 10px 26px; color: var(--signal); font-family: var(--mono); font-size: 11px; }
  .auth-panel-wrap { min-height: 100vh; padding: clamp(28px, 6vw, 92px); display: grid; place-items: center; background: var(--bg); }
  .auth-card { width: min(480px, 100%); padding: clamp(28px, 4vw, 48px); }
  .auth-card h2 { margin-top: 13px; font-family: var(--display); font-size: clamp(34px, 4vw, 48px); letter-spacing: -.035em; }
  .auth-card > p { margin-top: 15px; color: var(--muted); line-height: 1.75; }
  .auth-tabs { width: 100%; margin: 28px 0 24px; }
  .auth-tabs button { flex: 1; }
  .auth-submit { width: 100%; margin-top: 26px; }
  .auth-safe-note { display: block; margin-top: 18px; color: var(--muted); font-size: 11px; line-height: 1.65; text-align: center; }
  .account-summary { margin: 26px 0; display: grid; grid-template-columns: repeat(3, 1fr); border: 1px solid var(--line); }
  .account-summary div { padding: 18px; border-left: 1px solid var(--line); }
  .account-summary div:first-child { border-left: 0; }
  .account-summary span { display: block; color: var(--muted); font-size: 11px; }
  .account-summary b { display: block; margin-top: 7px; font-family: var(--mono); font-size: 22px; }
  .account-logout { width: 100%; color: var(--danger); }
  .hero-grid { align-items: stretch; }
  .hero-copy { min-height: 430px; padding: clamp(32px, 5vw, 70px); display: flex; flex-direction: column; justify-content: space-between; overflow: hidden; }
  .hero-copy::after {
    content: ""; position: absolute; width: 240px; height: 240px; right: -76px; bottom: -80px; border: 1px solid var(--line-strong); transform: rotate(18deg);
  }
  .hero-copy h1 { max-width: 780px; font-family: var(--display); font-size: clamp(48px, 5vw, 76px); line-height: 1.02; letter-spacing: -.055em; text-wrap: balance; }
  .hero-copy h1 em { color: var(--accent); font-style: normal; }
  .hero-copy p { margin-top: 22px; max-width: 620px; color: var(--muted); font-size: 17px; line-height: 1.8; }
  .hero-cta { margin-top: 32px; display: flex; align-items: center; gap: 12px; }
  .hero-meta { display: flex; align-items: end; justify-content: space-between; gap: 30px; margin-top: 54px; padding-top: 20px; border-top: 1px solid var(--line); }
  .hero-meta small { color: var(--muted); line-height: 1.7; }
  .live-strip { display: inline-flex; align-items: center; gap: 9px; font-family: var(--mono); color: var(--signal); font-size: 11px; }
  .balance-block { min-height: 430px; display: flex; flex-direction: column; justify-content: space-between; padding: 32px; background: var(--accent); color: var(--accent-ink); overflow: hidden; }
  .balance-block::after { content: "绘点"; position: absolute; right: -10px; bottom: -28px; font-family: var(--display); font-size: 116px; font-weight: 800; opacity: .09; }
  .balance-block .micro-label { color: currentColor; opacity: .65; }
  .balance-amount { font-family: var(--mono); font-size: clamp(56px, 7vw, 92px); line-height: .9; letter-spacing: -.08em; }
  .balance-caption { display: flex; justify-content: space-between; gap: 20px; padding-top: 20px; border-top: 1px solid color-mix(in oklab, var(--accent-ink) 28%, transparent); font-size: 12px; }
  .balance-caption b { display: block; margin-top: 4px; font-family: var(--mono); font-size: 20px; }
  .flow-panel { padding: 30px; }
  .flow-track { position: relative; height: 54px; display: flex; overflow: hidden; border: 1px solid var(--line); background: var(--bg-elev); }
  .flow-supply, .flow-demand { display: flex; align-items: center; padding: 0 18px; font-family: var(--mono); font-size: 11px; transition: width .5s var(--ease); }
  .flow-supply { width: 62%; background: var(--signal-soft); color: var(--signal); }
  .flow-demand { width: 38%; justify-content: flex-end; background: var(--accent-soft); color: var(--accent); }
  .flow-legend { margin-top: 14px; display: flex; justify-content: space-between; color: var(--muted); font-size: 11px; }
  .task-list, .source-list, .ledger-list, .contribution-list { display: grid; }
  .task-row, .source-row, .ledger-row, .contribution-row { display: grid; align-items: center; gap: 16px; padding: 17px 0; border-top: 1px solid var(--line); }
  .task-row { grid-template-columns: 44px minmax(0, 1fr) auto; }
  .task-row:first-child, .source-row:first-child, .ledger-row:first-child, .contribution-row:first-child { border-top: 0; }
  .task-index { width: 40px; height: 40px; display: grid; place-items: center; background: var(--panel-2); color: var(--muted); font-family: var(--mono); font-size: 11px; }
  .task-info b, .source-info b, .ledger-info b { display: block; color: var(--ink-soft); font-size: 13px; }
  .task-info span, .source-info span, .ledger-info span { display: block; margin-top: 4px; color: var(--muted); font-size: 11px; }
  .task-cost, .ledger-value { font-family: var(--mono); font-size: 12px; }
  .security-note { min-height: 100%; padding: 30px; display: flex; flex-direction: column; justify-content: space-between; background: var(--signal-soft); border-color: color-mix(in oklab, var(--signal) 28%, var(--line)); }
  .security-note .lock-glyph { width: 54px; height: 54px; display: grid; place-items: center; border: 1px solid var(--signal); color: var(--signal); font-family: var(--mono); font-size: 20px; }
  .security-note h2 { margin-top: 46px; font-family: var(--display); font-size: 30px; }
  .security-note p { margin-top: 12px; color: color-mix(in oklab, var(--signal) 58%, var(--muted)); line-height: 1.7; }
  .security-points { margin-top: 24px; padding-top: 18px; border-top: 1px solid color-mix(in oklab, var(--signal) 20%, var(--line)); display: grid; gap: 9px; color: var(--signal); font-size: 11px; font-family: var(--mono); }
  .studio-panel { padding: clamp(24px, 4vw, 42px); }
  .studio-modes { margin-bottom: 28px; }
  .prompt-wrap { position: relative; }
  .prompt-wrap textarea { min-height: 210px; padding-bottom: 50px; font-family: var(--display); font-size: 21px; }
  .prompt-count { position: absolute; right: 14px; bottom: 14px; color: var(--muted); font-family: var(--mono); font-size: 10px; }
  .studio-section { margin-top: 30px; }
  .studio-section-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
  .studio-section-head span:last-child { color: var(--muted); font-size: 11px; }
  .receipt { min-height: 100%; padding: 30px; display: flex; flex-direction: column; }
  .receipt-top { display: flex; justify-content: space-between; padding-bottom: 22px; border-bottom: 1px dashed var(--line-strong); }
  .receipt-top h2 { font-family: var(--display); font-size: 27px; }
  .receipt-code { font-family: var(--mono); color: var(--muted); font-size: 10px; }
  .receipt-preview { flex: 1; min-height: 250px; display: grid; place-items: center; margin: 22px 0; border: 1px solid var(--line); background: var(--bg-elev); overflow: hidden; }
  .preview-empty { max-width: 250px; text-align: center; color: var(--muted); line-height: 1.7; }
  .preview-empty b { display: block; margin-bottom: 8px; color: var(--ink-soft); font-family: var(--display); font-size: 22px; }
  .rendering { width: 100%; height: 100%; min-height: 250px; display: grid; place-items: center; position: relative; overflow: hidden; }
  .rendering::before { content: ""; position: absolute; inset: -50%; background: repeating-linear-gradient(115deg, transparent 0 18px, color-mix(in oklab, var(--accent) 9%, transparent) 18px 19px); animation: scan 1.4s linear infinite; }
  .rendering span { position: relative; z-index: 1; font-family: var(--mono); color: var(--accent); }
  .render-result { width: 100%; height: 100%; min-height: 250px; display: flex; flex-direction: column; justify-content: flex-end; padding: 22px; position: relative; isolation: isolate; background: var(--panel-2); }
  .render-result::before { content: ""; position: absolute; inset: 0; z-index: -2; background: linear-gradient(135deg, color-mix(in oklab, var(--accent) 70%, var(--panel)) 0 28%, var(--panel-2) 28% 58%, color-mix(in oklab, var(--signal) 58%, var(--panel)) 58%); }
  .render-result::after { content: "原型占位 · 实际生成图将在此显示"; position: absolute; inset: 0; z-index: -1; display: grid; place-items: center; padding: 30px; background: color-mix(in oklab, var(--bg) 24%, transparent); color: color-mix(in oklab, var(--ink) 75%, transparent); font-family: var(--mono); font-size: 11px; letter-spacing: .08em; }
  .render-result b, .render-result span { position: relative; z-index: 1; width: fit-content; padding: 4px 7px; background: var(--bg); }
  .render-result span { margin-top: 4px; color: var(--muted); font-size: 10px; font-family: var(--mono); }
  .render-result.has-image { display: block; padding: 0; background: var(--bg-elev); }
  .render-result.has-image::before, .render-result.has-image::after { display: none; }
  .render-result.has-image img { width: 100%; height: 100%; min-height: 250px; object-fit: cover; display: block; }
  .result-caption { position: absolute; left: 18px; bottom: 18px; z-index: 2; display: grid; justify-items: start; }
  .receipt-lines { display: grid; gap: 11px; padding: 18px 0; border-top: 1px dashed var(--line-strong); border-bottom: 1px dashed var(--line-strong); }
  .receipt-line { display: flex; justify-content: space-between; color: var(--muted); font-size: 12px; }
  .receipt-line b { color: var(--ink-soft); font-family: var(--mono); }
  .receipt-total { margin: 18px 0; display: flex; justify-content: space-between; align-items: end; }
  .receipt-total span { color: var(--muted); font-size: 12px; }
  .receipt-total b { color: var(--accent); font-family: var(--mono); font-size: 31px; }
  .receipt .primary-button { width: 100%; }
  .history-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
  .work-card { overflow: hidden; }
  .work-visual { aspect-ratio: 4 / 3; position: relative; display: grid; place-items: center; overflow: hidden; border-bottom: 1px solid var(--line); background: var(--panel-2); }
  .work-visual::before { content: ""; width: 45%; aspect-ratio: 1; border: 1px solid var(--line-strong); transform: rotate(26deg); }
  .work-visual span { position: absolute; color: var(--muted); font-family: var(--mono); font-size: 10px; letter-spacing: .08em; }
  .work-visual img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
  .work-meta { padding: 18px; }
  .work-meta h3 { min-height: 45px; font-family: var(--display); font-size: 17px; line-height: 1.35; }
  .work-meta-foot { margin-top: 14px; display: flex; justify-content: space-between; color: var(--muted); font-family: var(--mono); font-size: 10px; }
  .wallet-hero { min-height: 300px; padding: clamp(30px, 5vw, 60px); display: flex; flex-direction: column; justify-content: space-between; background: var(--accent); color: var(--accent-ink); }
  .wallet-hero .micro-label { color: currentColor; opacity: .62; }
  .wallet-balance { font-family: var(--mono); font-size: clamp(68px, 10vw, 132px); letter-spacing: -.09em; line-height: .8; }
  .wallet-foot { display: flex; justify-content: space-between; gap: 20px; padding-top: 22px; border-top: 1px solid color-mix(in oklab, var(--accent-ink) 25%, transparent); font-size: 12px; }
  .ledger-row { grid-template-columns: 12px minmax(0, 1fr) auto; }
  .ledger-mark { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); }
  .ledger-row.positive .ledger-mark { background: var(--signal); }
  .ledger-row.positive .ledger-value { color: var(--signal); }
  .ledger-row.negative .ledger-mark { background: var(--accent); }
  .ledger-row.negative .ledger-value { color: var(--accent); }
  .principle-list { counter-reset: principles; display: grid; }
  .principle { counter-increment: principles; padding: 20px 0; border-top: 1px solid var(--line); display: grid; grid-template-columns: 36px 1fr; gap: 16px; }
  .principle:first-child { border-top: 0; }
  .principle::before { content: "0" counter(principles); font-family: var(--mono); color: var(--accent); font-size: 11px; }
  .principle b { display: block; font-size: 13px; }
  .principle span { display: block; margin-top: 5px; color: var(--muted); font-size: 12px; line-height: 1.65; }
  .source-summary { display: grid; grid-template-columns: repeat(3, 1fr); }
  .contribution-summary { display: grid; grid-template-columns: repeat(4, 1fr); }
  .source-stat { min-height: 130px; padding: 26px; border-left: 1px solid var(--line); }
  .source-stat:first-child { border-left: 0; }
  .source-stat span { color: var(--muted); font-size: 12px; }
  .source-stat b { display: block; margin-top: 14px; font-family: var(--mono); font-size: 31px; }
  .source-row { grid-template-columns: 10px minmax(0, 1fr) auto auto; }
  .contribution-row { grid-template-columns: 10px minmax(0, 1fr) auto auto auto auto; }
  .contribution-row.is-revoked { opacity: .52; }
  .empty-contributions { min-height: 180px; display: grid; place-items: center; align-content: center; gap: 9px; text-align: center; color: var(--muted); }
  .empty-contributions b { color: var(--ink-soft); font-family: var(--display); font-size: 22px; }
  .empty-contributions p { max-width: 520px; font-size: 12px; line-height: 1.7; }
  .empty-contributions .ghost-button { margin-top: 8px; }
  .source-light { width: 7px; height: 7px; border-radius: 50%; background: var(--signal); box-shadow: 0 0 0 5px color-mix(in oklab, var(--signal) 10%, transparent); }
  .source-light.is-muted { background: var(--muted); box-shadow: none; }
  .source-metric { text-align: right; }
  .source-metric span { display: block; color: var(--muted); font-size: 10px; }
  .source-metric b { display: block; margin-top: 3px; font-family: var(--mono); font-size: 12px; }
  .contribution-rule { padding: 28px; background: var(--accent-soft); border-color: color-mix(in oklab, var(--accent) 25%, var(--line)); }
  .contribution-rule h3 { font-family: var(--display); font-size: 24px; }
  .contribution-rule p { margin-top: 10px; color: var(--muted); line-height: 1.7; }
  .api-endpoint { padding: 28px; display: flex; align-items: center; justify-content: space-between; gap: 20px; background: var(--signal-soft); border-color: color-mix(in oklab, var(--signal) 28%, var(--line)); }
  .api-endpoint span { display: block; color: var(--signal); font-size: 11px; }
  .api-endpoint code { display: block; margin-top: 8px; color: var(--ink); font-family: var(--mono); font-size: clamp(13px, 2vw, 18px); }
  .code-block { min-height: 380px; padding: 26px; overflow: auto; background: #07100f; color: #b9d3ce; border: 1px solid #1c3d37; border-radius: var(--radius); }
  .code-tabs { display: flex; gap: 18px; padding-bottom: 18px; border-bottom: 1px solid #1c3d37; }
  .code-tabs button { padding: 0 0 8px; background: transparent; color: #78968f; font-size: 12px; border-bottom: 2px solid transparent; }
  .code-tabs button.is-active { color: #e9c86c; border-color: #e9c86c; }
  pre { margin: 24px 0 0; white-space: pre-wrap; font-family: var(--mono); font-size: 12px; line-height: 1.8; }
  .api-key-row { padding: 18px 0; display: flex; justify-content: space-between; gap: 20px; border-top: 1px solid var(--line); }
  .api-key-row:first-of-type { border-top: 0; }
  .api-key-row b { display: block; font-size: 13px; }
  .api-key-row code { display: block; margin-top: 5px; color: var(--muted); font-family: var(--mono); font-size: 11px; }
  .api-key-row span { color: var(--muted); font-size: 11px; }
  .key-display { margin: 22px 0; padding: 18px; border: 1px solid var(--accent); background: var(--accent-soft); color: var(--accent); font-family: var(--mono); word-break: break-all; }
  .empty-keys { min-height: 230px; display: grid; place-items: center; align-content: center; gap: 16px; color: var(--muted); text-align: center; }
  .history-grid > .empty-state { grid-column: 1 / -1; }
  .load-state { min-height: calc(100vh - var(--top-h) - 150px); }
  .load-state .rendering { min-height: 260px; }
  body[data-density="compact"] .view { padding-top: 34px; }
  body[data-density="compact"] .page-head { margin-bottom: 28px; }
  body[data-density="compact"] .panel-pad, body[data-density="compact"] .studio-panel { padding: 22px; }
  body[data-density="compact"] .hero-copy, body[data-density="compact"] .balance-block { min-height: 350px; }
}

@layer responsive {
  @media (max-width: 1100px) {
    :root { --rail-w: 86px; --content-x: 28px; }
    .brand-word { display: none; }
    .page-head { align-items: start; }
    .span-8, .span-7 { grid-column: span 12; }
    .span-5, .span-4 { grid-column: span 6; }
    .hero-copy, .balance-block { min-height: 360px; }
    .history-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .auth-page { grid-template-columns: minmax(0, 1fr) 440px; }
    .auth-manifesto h1 { font-size: clamp(54px, 7vw, 78px); }
  }
  @media (max-width: 760px) {
    :root { --rail-w: 0px; --top-h: 64px; --content-x: 16px; }
    .app-shell { display: block; padding-bottom: 72px; }
    .main-area { width: 100%; }
    .rail { inset: auto 0 0 0; width: 100%; height: 68px; flex-direction: row; border: 0; border-top: 1px solid var(--line); }
    .brand, .rail-foot { display: none; }
    .rail-nav { grid-template-columns: repeat(5, 1fr); gap: 0; padding: 6px; }
    .nav-item { min-height: 55px; }
    .nav-item.is-active::after { right: auto; top: -6px; width: 24px; height: 3px; }
    .topbar { padding: 0 16px; }
    .crumbs span, .crumbs b, .status-pill, .design-button { display: none; }
    .balance-pill { min-height: 34px; }
    .view { padding-top: 28px; padding-bottom: 30px; }
    .page-head { grid-template-columns: 1fr; gap: 18px; margin-bottom: 28px; }
    .page-head h1 { font-size: 42px; }
    .page-head p { font-size: 15px; }
    .grid-12 { gap: 12px; }
    .span-6, .span-5, .span-4 { grid-column: span 12; }
    .hero-copy { min-height: 430px; padding: 28px; }
    .hero-copy h1 { font-size: 46px; }
    .balance-block { min-height: 300px; }
    .hero-meta { align-items: start; flex-direction: column; }
    .choice-grid { grid-template-columns: 1fr 1fr; }
    .history-grid { grid-template-columns: 1fr; }
    .source-summary { grid-template-columns: 1fr; }
    .contribution-summary { grid-template-columns: 1fr 1fr; }
    .source-stat { min-height: 100px; border-left: 0; border-top: 1px solid var(--line); }
    .source-stat:first-child { border-top: 0; }
    .source-row { grid-template-columns: 10px minmax(0, 1fr) auto; }
    .source-row .source-metric:nth-last-child(2) { display: none; }
    .contribution-row { grid-template-columns: 10px minmax(0, 1fr) auto; }
    .contribution-row .source-metric { display: none; }
    .head-actions { align-items: stretch; flex-direction: column; }
    .api-endpoint { align-items: start; flex-direction: column; }
    .tweaks-panel { top: 72px; right: 16px; }
    .modal { padding: 28px 22px; }
    body[data-auth="guest"] .app-shell { padding-bottom: 0; }
    .auth-page { grid-template-columns: 1fr; }
    .auth-story { min-height: 330px; padding: 28px 22px; border-right: 0; border-bottom: 1px solid var(--line); }
    .auth-story::before { width: 340px; right: -32%; top: -20%; }
    .auth-story::after { right: -30px; bottom: -80px; font-size: 260px; }
    .auth-manifesto h1 { margin-top: 13px; font-size: 49px; }
    .auth-manifesto p { display: none; }
    .auth-principles { gap: 8px 15px; font-size: 9px; }
    .auth-panel-wrap { min-height: auto; padding: 24px 16px 42px; }
    .auth-card { padding: 28px 22px; }
    .account-summary div { padding: 13px; }
  }
  @media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; transition-duration: .01ms !important; }
  }
}

@keyframes page-in { from { opacity: 0; transform: translateY(12px); } }
@keyframes panel-in { from { opacity: 0; transform: translateY(-10px) scale(.98); } }
@keyframes modal-in { from { opacity: 0; transform: translateY(16px) scale(.98); } }
@keyframes toast-in { from { opacity: 0; transform: translateY(12px); } }
@keyframes scan { to { transform: translateX(60px); } }
