/* A quiet menu rail beside an open habitat; neural activity stays below it. */
:root {
    --paper: #eeede7; --panel: rgba(250,250,246,.78); --panel-solid: #fafaf6; --sand: #f7f6f1;
    --ink: #29312c; --muted: #697269; --hair: rgba(80,95,82,.2);
    --accent: #647b62; --accent-hover: #3d553c; --accent-subtle: rgba(100,123,98,.09);
    --bg: var(--paper); --surface: var(--panel-solid); --surface-alpha: var(--panel);
    --surface-hover: #e5e8df; --border: var(--hair); --text: var(--ink); --text-muted: var(--muted);
    --error: #a34b40; --success: #647b62; --radius: 4px;
    --display: 'Cormorant Garamond', 'Iowan Old Style', Georgia, serif;
    --body: 'DM Sans', sans-serif; --mono: 'IBM Plex Mono', monospace;
    --pad: clamp(24px, 3vw, 56px); --rail: 248px; --gap: 48px;
    /* The left menu and the open right-hand habitat share one column system. */
    --rail-in: calc(var(--pad) + var(--rail) + var(--gap));
    --main-left: var(--rail-in); --main-right: var(--pad);
    --content-top: 116px; --stage-top: 302px;
    --dock-bottom: 40px; --dock-bar-h: 54px; --dock-panel-h: 132px;
    --dock-h: calc(var(--dock-bar-h) + var(--dock-panel-h) + 2px);
    --dock-clear: calc(var(--dock-bottom) + var(--dock-h) + 16px);
}
* { box-sizing: border-box; }
body { background: var(--paper); color: var(--ink); font: 13px var(--body); }
button, a { -webkit-tap-highlight-color: transparent; }
button { font: inherit; color: inherit; cursor: pointer; }
a { color: inherit; }
button:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }
button:hover { background: var(--accent-subtle); }
[hidden] { display: none !important; }
#toolbar { position: fixed; inset: 0 var(--pad) auto; height: 88px; padding: 0; display: flex; align-items: center; gap: 24px; z-index: 35; background: transparent; border: 0; border-bottom: 1px solid var(--hair); box-shadow: none; justify-content: flex-start; }
.wordmark { font: 600 56px/.85 var(--display); letter-spacing: -2px; text-decoration: none; }
.wordmark span { color: var(--accent); }
.site-description { display: none; font-size: 11px; color: var(--muted); margin: 9px 0 0; }
.toolbar-right { display: flex; margin-left: auto; }
.text-button { background: none; border: 0; padding: 9px 4px; color: var(--muted); font-size: 11px; white-space: nowrap; }
.text-button:hover, .text-button.active { color: var(--ink); }
.lang-switch { display: flex; align-items: center; gap: 1px; }
.lang-switch .text-button { padding: 10px 7px; font-size: 11px; }
.lang-switch .text-button[aria-current="true"] { color: var(--ink); }
#canvas { position: fixed; inset: 0; z-index: 2; background: transparent; }
.habitat-heading { position: fixed; top: var(--content-top); left: var(--main-left); right: var(--main-right); z-index: 3; pointer-events: none; display: flex; flex-direction: column; align-items: center; text-align: center; gap: 18px; }
.habitat-heading .hero-title { font: 400 clamp(48px, 5.4vw, 78px)/1.04 var(--display); letter-spacing: -2px; margin: 0; }
.habitat-heading .hero-sub { max-width: 510px; font-size: 12px; line-height: 1.85; color: var(--muted); }
html[lang|="zh"] .hero-title { font-family: 'Songti SC', 'Noto Serif CJK SC', 'SimSun', serif; font-size: clamp(38px, 4.2vw, 60px); font-weight: 400; letter-spacing: 2px; }
#habitat-stage { position: fixed; top: var(--stage-top); bottom: calc(var(--dock-clear) + 52px); left: var(--main-left); right: var(--main-right); pointer-events: none; overflow: hidden; border: 0; background: transparent; }
.habitat { position: absolute; inset: 0; background: radial-gradient(ellipse at 50% 50%, #f9f9ef66, transparent 68%); }
.habitat-inner { position: absolute; inset: 3% 8%; opacity: .23; background-image: radial-gradient(#64735940 .6px, transparent .6px); background-size: 9px 9px; mask-image: radial-gradient(ellipse, #000 0%, transparent 68%); }
.fpanel { z-index: 10; }
#panelB { position: fixed; top: var(--content-top); bottom: var(--dock-bottom); left: var(--pad); right: auto; width: var(--rail); padding: 14px 24px 0 0; background: transparent; border: 0; border-right: 1px solid var(--hair); border-radius: 0; display: flex; flex-direction: column; overflow-y: auto; }
.panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.panel-heading h2 { margin: 0; font: 500 12px/1.4 var(--body); }
.source-label { font-size: 9px; color: var(--muted); }
.current-food { display: flex; align-items: center; gap: 14px; margin: 16px 0 12px; }
.current-food img { width: 56px; height: 56px; }
.current-food strong { display: block; font: 400 35px/1.1 var(--display); }
.current-food span { display: block; font-size: 10px; color: var(--muted); margin-top: 5px; }
.food-stock { display: flex; justify-content: space-between; font-size: 10px; color: var(--muted); }
#chainFruits { font-variant-numeric: tabular-nums; }
.queue-caption { color: var(--muted); font-size: 9px; line-height: 1.5; margin-top: 6px; }
.queue-caption:empty { display: none; }
.menu-volume { border-top: 1px solid var(--hair); padding-top: 15px; margin-top: 17px; }
.menu-volume > span, .menu-volume small { display: block; color: var(--muted); font-size: 9px; line-height: 1.6; }
.menu-volume strong { display: block; font: 500 19px/1.6 var(--body); font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.food-tiers { list-style: none; padding: 0; margin: 14px 0 0; }
.food-tiers li { display: grid; grid-template-columns: 26px 1fr auto; gap: 7px; align-items: center; min-height: 36px; color: var(--muted); border-bottom: 1px solid var(--hair); font-size: 11px; }
.food-tiers img { width: 24px; height: 24px; opacity: .4; filter: grayscale(.7); }
.food-tiers small { font: 9px var(--mono); }
.food-tiers .unlocked img { opacity: 1; filter: none; }
.food-tiers [aria-current] { color: var(--ink); background: var(--accent-subtle); font-weight: 500; }
progress { display: block; appearance: none; width: 100%; height: 3px; flex: 0 0 3px; margin: 12px 0 7px; border: 0; border-radius: 2px; background: var(--hair); accent-color: var(--accent); overflow: hidden; }
progress::-webkit-progress-bar { background: var(--hair); }
progress::-webkit-progress-value { background: var(--accent); border-radius: 2px; }
progress::-moz-progress-bar { background: var(--accent); border-radius: 2px; }
.menu-next { font-size: 10px; color: var(--muted); line-height: 1.5; margin: 0 0 16px; }
.feeding-progress { margin-top: auto; border-top: 1px solid var(--hair); padding-top: 14px; }
.progress-caption { font-size: 10px; color: var(--muted); line-height: 1.6; }
.progress-caption > span:first-child { display: none; }
.progress-caption b { color: var(--ink); font-weight: 500; }
.subtle-link { display: flex; justify-content: space-between; align-items: center; width: 100%; border: 0; padding: 7px 0; margin: 0; text-align: left; background: transparent; font-size: 10px; color: var(--accent); }
.menu-source { display: flex; justify-content: space-between; align-items: center; border-top: 1px solid var(--hair); padding-top: 12px; margin-top: 8px; }
.connection { display: flex; align-items: center; gap: 5px; font-size: 9px; color: var(--muted); white-space: nowrap; }
.fdot { width: 5px; height: 5px; border-radius: 50%; background: var(--muted); }
.fdot-live { background: var(--accent); }
.fdot-error { background: var(--error); }
/* The current state belongs beside the viewing controls, away from the headline. */
#panelD { position: fixed; left: var(--main-left); bottom: var(--dock-clear); height: 36px; display: flex; align-items: center; gap: 10px; max-width: calc(100vw - var(--main-left) - var(--main-right) - 225px); }
.state-label { font-size: 10px; color: var(--muted); }
#behaviorState { font: italic 400 25px/1 var(--display); color: var(--ink); text-transform: none; padding: 0; margin: 0; background: none; white-space: nowrap; }
#behaviorState::first-letter { text-transform: uppercase; }
.behavior-description { font-size: 10px; line-height: 1.5; color: var(--muted); margin: 0; }
.view-controls { position: fixed; z-index: 12; bottom: var(--dock-clear); right: var(--main-right); display: flex; align-items: center; gap: 8px; height: 36px; }
.view-button, .zoom-controls { border: 1px solid var(--hair); border-radius: 24px; background: var(--panel); }
.view-button { padding: 8px 12px; font: 10px var(--body); color: var(--muted); white-space: nowrap; height: 36px; }
.view-button span { margin-right: 4px; }
#zoom-controls { position: static; transform: none; display: flex; flex-direction: row; align-items: center; gap: 0; padding: 0 3px; }
.zoom-btn { border: 0; box-shadow: none; background: transparent; color: var(--muted); width: 26px; height: 34px; padding: 0; font-size: 16px; border-radius: 50%; }
#zoomReadout { font: 9px var(--mono); min-width: 26px; text-align: center; color: var(--muted); }
#brain-drawer { position: fixed; z-index: 30; left: var(--main-left); right: var(--main-right); bottom: var(--dock-bottom); width: auto; border: 0; border-top: 1px solid var(--hair); border-radius: 0; background: transparent; overflow: hidden; }
.brain-handle { display: flex; align-items: center; gap: 16px; min-height: var(--dock-bar-h); padding: 0; border: 0; }
.brain-summary { display: flex; align-items: baseline; gap: 12px; flex: 1; min-width: 0; }
.brain-summary strong { font: 400 22px var(--display); }
.brain-summary > span { font-size: 10px; color: var(--muted); }
.brain-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.brain-actions .text-button { min-height: 34px; padding: 7px 13px; border: 1px solid var(--hair); border-radius: 18px; background: var(--panel); font: 11px/1.2 var(--body); color: var(--ink); }
.brain-actions .text-button:hover { border-color: var(--accent); background: var(--accent-subtle); }
.brain-actions .text-button[aria-pressed="true"], .brain-actions .text-button[aria-expanded="true"] { background: var(--accent); border-color: var(--accent); color: var(--panel-solid); }
#left-panel { position: static; width: 100%; height: var(--dock-panel-h); min-height: 0; padding: 0 0 8px; display: flex; transform: none; box-sizing: border-box; border: 0; background: transparent; border-radius: 0; }
#left-panel::before { display: none; }
#connectome-panel { gap: 10px 20px; width: 100%; display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-rows: 23px minmax(0, 1fr); }
#neuro-renderer-wrap, #nodeHolder { grid-column: 1 / -1; grid-row: 2; }
.connectome-header { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.connectome-header { padding: 0; }
.connectome-label { font: 10px var(--body); color: var(--muted); }
.connectome-toggle-btn { font: 9px var(--body); border: 1px solid var(--hair); background: none; color: var(--muted); padding: 3px 7px; border-radius: 3px; }
#connectomeSubtitle { font: 9px/1.6 var(--mono); color: var(--muted); }
#neuro-renderer-wrap { border-radius: 3px; overflow: hidden; }
/* 四个分区改成画布外面的图例：画布只画数据，文字归排版管 */
.neuro-legend { list-style: none; display: flex; flex-wrap: wrap; gap: 7px 14px; margin: 0; padding: 0; }
.neuro-legend-item { display: flex; align-items: center; gap: 5px; font-size: 9px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); }
.neuro-legend-item i { width: 6px; height: 6px; border-radius: 1px; background: var(--type-color); }
.neuro-type-sensory { --type-color: #769295; }
.neuro-type-central { --type-color: #839175; }
.neuro-type-drives { --type-color: #b49b5e; }
.neuro-type-motor { --type-color: #b47760; }
#neuro-renderer-wrap { border: 0; border-radius: 0; background: var(--paper); }
#nodeHolder { border: 0; border-radius: 0; }
.source-credit { position: fixed; bottom: 15px; left: var(--pad); z-index: 10; color: var(--muted); font-size: 9px; text-decoration: none; }
.source-credit:hover { text-decoration: underline; }
.about-data { position: static; padding: 17px 0; margin: 0; width: auto; border: 0; border-top: 1px solid var(--hair); background: transparent; }
.about-data h3 { font: 500 12px var(--body); margin: 0; }
.trade-figure { display: flex; align-items: baseline; gap: 10px; margin: 12px 0; }
#chainVolume { font: 400 30px var(--display); }
#chainVolumeLabel, .trade-delta, .latest-trade, .session-note { font-size: 10px; color: var(--muted); line-height: 1.6; }
.latest-trade { margin: 12px 0; overflow-wrap: anywhere; }
.fmeta { display: block; }
.fhash { font: 10px var(--mono); }
.copy-pool { width: 100%; padding: 10px 0; border: 0; background: transparent; display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 10px; }
.copy-pool code { font: 10px var(--mono); }
#drive-meters { display: flex; width: auto; gap: 10px; border-left: 0; padding-left: 0; }
.drive-row { display: flex; justify-content: space-between; gap: 12px; }
.drive-label { font: 10px var(--body); }
.drive-num { font: 12px var(--mono); }
.model-note { margin: 0; font-size: 10px; color: var(--muted); }
.help-overlay { inset: 0; margin: auto; padding: 30px; width: min(530px, calc(100vw - 32px)); max-height: calc(100dvh - 40px); overflow-y: auto; background: var(--panel-solid); color: var(--ink); border: 1px solid var(--hair); border-radius: 8px; box-shadow: 0 24px 100px #202a2430; font-family: var(--body); }
.help-overlay::backdrop { background: #23312738; backdrop-filter: blur(6px); }
.help-overlay-header { position: sticky; top: 0; z-index: 2; background: var(--panel-solid); display: flex; align-items: center; justify-content: space-between; padding: 0; margin-bottom: 16px; border: 0; }
.help-overlay-header h2 { font: 500 35px/1.1 var(--display); margin: 0; }
.help-close-btn, .education-close-btn, .brain3d-close { border: 1px solid var(--hair); width: 32px; height: 32px; border-radius: 50%; color: var(--muted); background: transparent; font-size: 21px; line-height: 1; padding: 0; }
.about-lead { font: 400 22px/1.25 var(--display); margin: 18px 0 24px; color: var(--muted); }
.help-item { margin: 0; padding: 17px 0; border-top: 1px solid var(--hair); font: 12px/1.7 var(--body); color: var(--muted); }
.help-item h3 { font: 500 12px var(--body); color: var(--ink); margin: 0 0 7px; }
.help-item p { margin: 0; }
.about-sources { display: flex; gap: 20px; margin-top: 16px; font-size: 10px; color: var(--accent); }
.education-panel { top: 112px; bottom: var(--dock-clear); right: var(--pad); width: min(360px, calc(100vw - 32px)); height: auto; background: var(--panel-solid); color: var(--ink); border: 1px solid var(--hair); border-radius: 5px; box-shadow: 0 16px 40px #24352610; z-index: 32; }
.education-panel-header { padding: 18px 20px; border-bottom: 1px solid var(--hair); }
.education-panel-title { font: 500 28px var(--display); }
.education-content { padding: 18px 20px; }
.edu-text, .edu-list, .edu-analogy { font: 11px/1.75 var(--body); color: var(--muted); }
.edu-section-title { font: 500 13px var(--body); letter-spacing: 0; text-transform: none; color: var(--ink); }
.edu-column-header, .edu-region-card, .edu-neuron-tag, .edu-detail-panel, .edu-population { font-family: var(--body); border-radius: 3px; }
.edu-region-card { background: transparent; border-color: var(--hair); }
.edu-region-card:hover { background: var(--accent-subtle); }
.edu-detail-panel, .edu-neuron-tag { background: var(--accent-subtle); }
.edu-links a { color: var(--accent); }
body.learn-open .fpanel-tr, body.learn-open .fpanel-br { opacity: 0; pointer-events: none; }
#brain3d-overlay { position: fixed; z-index: 24; top: 112px; bottom: var(--dock-clear); left: calc(var(--rail-in) + 20px); right: calc(var(--main-right) + 20px); border: 1px solid var(--hair); border-radius: 6px; overflow: hidden; background: #e5e9df; }
.brain3d-close { position: absolute; top: 14px; right: 14px; z-index: 2; background: #f8faf4c9; color: #475444; }
.brain3d-caption { position: absolute; bottom: 18px; width: 100%; text-align: center; font-size: 10px; color: #536450; pointer-events: none; }
#brain3d-tooltip, .neuron-tooltip { background: var(--panel-solid); color: var(--ink); border: 1px solid var(--hair); box-shadow: 0 8px 25px #23312215; font-family: var(--body); }
.education-panel { top: var(--content-top); bottom: var(--dock-bottom); left: var(--pad); right: auto; width: var(--rail); }
#brain3d-overlay { top: var(--stage-top); bottom: calc(var(--dock-clear) + 48px); left: var(--main-left); right: var(--main-right); }
body.learn-open #panelD { opacity: 1; }
@media (max-width: 1260px) and (min-width: 801px) {
    :root { --rail: 220px; --gap: 30px; --stage-top: 285px; }
    .habitat-heading .hero-title { font-size: 58px; }
    .habitat-heading .hero-sub { font-size: 11px; }
    .behavior-description { display: none; }
    .brain-summary { display: grid; gap: 3px; }
    .brain-summary strong { font-size: 20px; }
    #panelB { padding-right: 18px; }
    .neuro-legend { gap: 7px; }
    .neuro-legend-item { font-size: 8px; }
}
@media (min-width: 801px) and (max-height: 800px) {
    :root { --content-top: 104px; --stage-top: 252px; --dock-panel-h: 108px; --dock-bottom: 32px; }
    .habitat-heading { gap: 14px; }
    .habitat-heading .hero-title { font-size: 60px; }
    html[lang|="zh"] .hero-title { font-size: 44px; }
    .current-food { margin: 12px 0 9px; }
    .current-food img { width: 45px; height: 45px; }
    .menu-volume { padding-top: 10px; margin-top: 12px; }
    .food-tiers { margin-top: 10px; }
    .food-tiers li { min-height: 30px; }
    .menu-next { margin-bottom: 12px; }
    .behavior-description { display: none; }
}
@media (max-width: 800px) {
    :root { --pad: 16px; --rail: calc((100vw - 44px) / 2); --gap: 12px; --content-top: 90px; --stage-top: 166px; --dock-bottom: 28px; --dock-panel-h: 142px; --dock-bar-h: 52px; --dock-clear: calc(var(--dock-bottom) + var(--dock-h) + 16px); }
    #toolbar { height: 72px; gap: 16px; }
    .wordmark { font-size: 36px; }
    .site-description { display: none; max-width: 150px; margin: 0; font: 18px/1.05 var(--display); color: var(--ink); }
    .habitat-heading { display: none; }
    .habitat-heading .hero-title, .habitat-heading .hero-sub { display: none; }
    #habitat-stage { left: var(--pad); right: var(--rail-in); bottom: calc(var(--dock-clear) + 48px); }
    #panelB { left: auto; right: var(--pad); bottom: auto; padding: 10px 0 10px 12px; border: 0; border-left: 1px solid var(--hair); }
    .panel-heading h2 { font-size: 10px; }
    .source-label { font-size: 8px; }
    .current-food { gap: 5px; margin: 9px 0; }
    .current-food img { width: 30px; height: 30px; }
    .current-food strong { font-size: 25px; }
    .current-food span { font-size: 8px; margin-top: 2px; }
    .food-stock { font-size: 8px; }
    .queue-caption { font-size: 8px; margin-top: 3px; }
    .menu-volume { padding-top: 7px; margin-top: 8px; }
    .menu-volume strong { font-size: 11px; }
    .menu-volume small, .menu-volume > span { font-size: 8px; }
    .food-tiers { margin-top: 7px; }
    .food-tiers li { grid-template-columns: 17px 1fr auto; min-height: 21px; gap: 3px; font-size: 9px; }
    .food-tiers img { width: 17px; height: 17px; }
    .food-tiers small { font-size: 7px; }
    .menu-next { font-size: 8px; margin-bottom: 0; }
    #menuProgress { margin: 7px 0 5px; }
    .feeding-progress, #feedingInfo { display: none; }
    .menu-source { margin-top: 8px; padding-top: 8px; }
    .connection { font-size: 0; gap: 0; }
    #panelD { top: var(--content-top); left: var(--pad); bottom: auto; max-width: var(--rail); height: auto; display: block; }
    .state-label { font-size: 9px; }
    #behaviorState { font-size: 29px; margin-top: 6px; }
    .behavior-description { display: none; }
    .view-controls { right: auto; left: var(--pad); height: 32px; gap: 5px; }
    #centerButton { display: inline-flex !important; align-items: center; }
    .view-button { height: 32px; padding: 7px 10px; font-size: 9px; }
    .zoom-btn { height: 30px; width: 24px; }
    #zoomReadout { min-width: 23px; }
    #brain-drawer { left: var(--pad); right: var(--pad); top: auto; bottom: var(--dock-bottom); width: auto; }
    .brain-handle { display: flex; align-items: center; min-height: var(--dock-bar-h); padding: 0; gap: 10px; }
    #left-panel { flex: none; height: var(--dock-panel-h); }
    .brain-handle { padding: 0; gap: 10px; }
    .brain-summary { display: grid; gap: 3px; }
    .brain-summary strong { font-size: 17px; }
    .brain-summary > span { font-size: 9px; }
    .brain-actions { gap: 6px; }
    .brain-actions .text-button { min-height: 32px; padding: 7px 9px; font-size: 10px; }
    #left-panel { padding: 0 0 8px; }
    #connectome-panel { display: flex; flex-direction: column; }
    .neuro-legend { gap: 7px 12px; }
    .source-credit { bottom: 9px; font-size: 8px; }
    .education-panel { width: calc(100vw - 32px); bottom: var(--dock-clear); }
    #brain3d-overlay { left: var(--pad); top: var(--content-top); right: var(--pad); bottom: var(--dock-clear); }
}
@media (max-width: 800px) and (max-height: 740px) {
    :root { --dock-panel-h: 110px; --stage-top: 156px; }
    .current-food span, .queue-caption, .menu-volume small { display: none; }
    .current-food { margin: 6px 0; }
    .food-tiers li { min-height: 19px; }
    .menu-source { padding-top: 6px; margin-top: 6px; }
}
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { transition: none !important; animation: none !important; }
}
