/* Fixed teaching workbench: loaded last so the home keeps one predictable map. */
:root{
  --home-rail-left:clamp(154px,13.4vw,232px);
  --home-rail-right:clamp(236px,18vw,310px);
  --home-gutter:clamp(14px,2vw,38px);
  --home-dock-height:132px;
  --home-right-top:clamp(12px,2vh,22px);
}

@media (min-width:701px){
  body[data-surface="home"]:not(.portal-home):not(.arrival-playing) .mainstage{
    overflow:clip!important;
  }

  /* The centre is reserved for the car and its scene labels. */
  body[data-surface="home"]:not(.portal-home):not(.arrival-playing) .hero-stage,
  body[data-surface="home"]:not(.portal-home):not(.arrival-playing).inspector-open .hero-stage,
  body[data-surface="home"]:not(.portal-home):not(.arrival-playing).tools-open .hero-stage,
  body[data-surface="home"]:not(.portal-home):not(.arrival-playing)[data-render-mode="section"] .hero-stage,
  body[data-surface="home"]:not(.portal-home):not(.arrival-playing)[data-camera-view="top"] .hero-stage{
    left:calc(var(--home-rail-left) + var(--home-gutter))!important;
    right:calc(var(--home-rail-right) + var(--home-gutter))!important;
    top:clamp(44px,8vh,96px)!important;
    bottom:calc(var(--home-dock-height) + 24px)!important;
  }

  body[data-surface="home"]:not(.portal-home):not(.arrival-playing) .stage-heading{
    left:calc(var(--home-rail-left) + 36px);
    right:calc(var(--home-rail-right) + 36px);
    top:12px;
  }
  /* The permanent system rail belongs to the page, not to the mode-specific energy panel. */
  body[data-surface="home"]:not(.portal-home):not(.arrival-playing) .side-left{
    position:fixed;
    z-index:28;
    left:var(--home-gutter);
    top:clamp(112px,16vh,164px);
    width:var(--home-rail-left);
    max-height:min(330px,calc(100dvh - 460px));
    display:flex!important;
    flex-direction:column;
    align-items:stretch;
    gap:4px;
    padding:8px;
    overflow:auto;
    border:1px solid rgba(178,202,220,.72);
    border-radius:16px;
    background:rgba(242,247,251,.86);
    box-shadow:0 10px 28px rgba(31,65,91,.12);
    backdrop-filter:blur(18px) saturate(1.08);
  }
  body[data-surface="home"]:not(.portal-home):not(.arrival-playing) .side-left :is(.system-tabs,.focus-list){
    display:flex!important;
    flex-direction:column;
    gap:4px;
  }
  body[data-surface="home"]:not(.portal-home):not(.arrival-playing) .side-left .system-tabs::before{
    content:"系统选择";
    padding:3px 5px 7px;
    color:#557188;
    font-size:9px;
    font-weight:700;
    letter-spacing:.14em;
  }
  body[data-surface="home"]:not(.portal-home):not(.arrival-playing) .side-left :is(.system-tabs,.focus-list) button{
    width:100%;
    min-height:30px;
    padding:7px 8px;
    border-radius:8px;
    color:#45647a;
    font-size:11px;
    line-height:1.15;
    text-align:left;
  }
  body[data-surface="home"]:not(.portal-home):not(.arrival-playing) .side-left :is(.system-tabs,.focus-list) button.active,
  body[data-surface="home"]:not(.portal-home):not(.arrival-playing) .side-left :is(.system-tabs,.focus-list) button[aria-pressed="true"]{
    color:#075fbd;
    background:#fff;
    box-shadow:inset 2px 0 #1885eb,0 1px 5px rgba(36,96,142,.12);
  }
  body[data-surface="home"]:not(.portal-home):not(.arrival-playing) .energy-workbench :is(.energy-teaching,.energy-systems,.energy-course-links){display:none!important}
  body[data-surface="home"]:not(.portal-home):not(.arrival-playing) .home-display-modes{
    left:calc(var(--home-rail-left) + var(--home-gutter));
    right:auto;
    top:10px;
    z-index:12;
  }
  body[data-surface="home"]:not(.portal-home):not(.arrival-playing) #inspector-toggle{
    position:fixed;
    left:var(--home-gutter);
    right:auto;
    top:calc(clamp(112px,16vh,164px) + min(330px,calc(100dvh - 460px)) + 12px);
    z-index:29;
  }

  /* Bottom has only mode and compact scenario / timing controls. */
  body[data-surface="home"]:not(.portal-home):not(.arrival-playing) .energy-dock{
    left:calc(var(--home-rail-left) + var(--home-gutter));
    right:calc(var(--home-rail-right) + var(--home-gutter));
    bottom:14px;
    width:auto!important;
    max-width:none;
    transform:none;
    padding:7px 9px;
    border-radius:16px;
    background:rgba(240,246,250,.92);
    box-shadow:0 9px 28px rgba(33,71,99,.14);
  }
  body[data-surface="home"]:not(.portal-home):not(.arrival-playing) .energy-modes{padding-bottom:5px}
  body[data-surface="home"]:not(.portal-home):not(.arrival-playing) .energy-modes button{min-height:31px;padding:7px 6px;font-size:11px}
  body[data-surface="home"]:not(.portal-home):not(.arrival-playing) .energy-controls{padding:5px 2px 0}
  body[data-surface="home"]:not(.portal-home):not(.arrival-playing) .energy-scenarios{display:inline-flex;max-width:46%;overflow:auto;vertical-align:middle}
  body[data-surface="home"]:not(.portal-home):not(.arrival-playing) .energy-scenarios button{padding:6px 8px;font-size:10px;white-space:nowrap}
  body[data-surface="home"]:not(.portal-home):not(.arrival-playing) .energy-run-controls{display:inline-flex;float:right;margin-top:0;gap:3px}
  body[data-surface="home"]:not(.portal-home):not(.arrival-playing) .energy-run-controls button{padding:5px 6px;font-size:9px}
  body[data-surface="home"]:not(.portal-home):not(.arrival-playing) .energy-run-controls label{margin-left:4px;font-size:9px}
  body[data-surface="home"]:not(.portal-home):not(.arrival-playing) .energy-run-controls input{width:min(76px,7vw)}
  body[data-surface="home"]:not(.portal-home):not(.arrival-playing) .energy-legend{display:none}
  body[data-surface="home"]:not(.portal-home):not(.arrival-playing) :is(.energy-reveal-controls,.energy-battery-story){clear:both;padding:4px 2px 0}
  body[data-surface="home"]:not(.portal-home):not(.arrival-playing) .energy-circuit-alert{top:56px}

  /* Existing disassembly controls remain available, but never cover the car. */
  body[data-surface="home"]:not(.portal-home):not(.arrival-playing) .teaching-dock{display:none!important}
  body[data-surface="home"]:not(.portal-home):not(.arrival-playing).tools-open .teaching-dock{
    display:block!important;
    left:calc(var(--home-rail-left) + var(--home-gutter));
    right:calc(var(--home-rail-right) + var(--home-gutter));
    bottom:calc(var(--home-dock-height) + 24px);
    width:auto;
    max-width:none;
    transform:none;
    padding:9px 12px;
    border-radius:14px;
    background:rgba(242,247,251,.94);
  }

  /* Right rail: cards stack in a bounded, scrollable column instead of covering one another. */
  body[data-surface="home"]:not(.portal-home):not(.arrival-playing) :is(.energy-data-card,.exhibit-card,.energy-history-panel,.energy-history,.energy-trend-card){
    right:var(--home-gutter)!important;
    width:var(--home-rail-right)!important;
    max-width:var(--home-rail-right)!important;
    border-color:rgba(191,211,226,.86);
    background:rgba(248,251,253,.92);
    box-shadow:0 9px 25px rgba(31,65,91,.13);
    backdrop-filter:blur(18px) saturate(1.06);
  }
  body[data-surface="home"]:not(.portal-home):not(.arrival-playing) .energy-data-card{
    top:var(--home-right-top)!important;
    max-height:190px;
    padding:11px 12px;
    overflow:auto;
  }
  body[data-surface="home"]:not(.portal-home):not(.arrival-playing) .energy-data-card>strong{margin-top:8px;font-size:16px}
  body[data-surface="home"]:not(.portal-home):not(.arrival-playing) .energy-data-card>p{min-height:0;margin:3px 0 8px;font-size:10px}
  body[data-surface="home"]:not(.portal-home):not(.arrival-playing)[data-teaching-mode="energy"] .energy-data-card>p{display:none}
  body[data-surface="home"]:not(.portal-home):not(.arrival-playing) .energy-data-card dl{gap:6px}
  body[data-surface="home"]:not(.portal-home):not(.arrival-playing) .energy-data-card dl div{padding-top:5px}
  body[data-surface="home"]:not(.portal-home):not(.arrival-playing) .energy-data-card dd b{font-size:14px}
  body[data-surface="home"]:not(.portal-home):not(.arrival-playing) .energy-data-card :is(.energy-flow-copy,.energy-provenance,.energy-clock){display:none}
  body[data-surface="home"]:not(.portal-home):not(.arrival-playing) .energy-workbench[data-structure="true"] .energy-data-card :is(dl,.energy-secondary,.energy-flow-copy,.energy-provenance,.energy-clock){display:none}
  body[data-surface="home"]:not(.portal-home):not(.arrival-playing) .energy-workbench[data-structure="true"] .energy-data-card{max-height:155px}
  body[data-surface="home"]:not(.portal-home):not(.arrival-playing) .energy-history-panel,
  body[data-surface="home"]:not(.portal-home):not(.arrival-playing) .energy-history,
  body[data-surface="home"]:not(.portal-home):not(.arrival-playing) .energy-trend-card{top:calc(var(--home-right-top) + 200px)!important;max-height:225px;overflow:auto}
  body[data-surface="home"]:not(.portal-home):not(.arrival-playing) .exhibit-card{top:var(--home-right-top)!important;max-height:244px;overflow:auto}
  body[data-surface="home"]:not(.portal-home):not(.arrival-playing) :is(.exhibit-card,.exhibit-caption){
    right:var(--home-gutter)!important;
    left:auto!important;
    top:var(--home-right-top)!important;
    bottom:auto!important;
    width:var(--home-rail-right)!important;
    max-width:var(--home-rail-right)!important;
    max-height:clamp(160px,26vh,244px);
    overflow:auto;
    border:1px solid rgba(191,211,226,.86);
    border-radius:16px;
    background:rgba(248,251,253,.92);
    box-shadow:0 9px 25px rgba(31,65,91,.13);
    backdrop-filter:blur(18px) saturate(1.06);
  }
  body[data-surface="home"]:not(.portal-home):not(.arrival-playing)[data-teaching-mode="energy"] .exhibit-card{display:block!important;top:calc(var(--home-right-top) + 435px)!important;max-height:calc(100% - 455px);padding:12px}
  body[data-surface="home"]:not(.portal-home):not(.arrival-playing):is([data-teaching-mode="exterior"],[data-teaching-mode="three-electric"],:not([data-teaching-mode])) .exhibit-card{
    top:var(--home-right-top)!important;
    bottom:auto!important;
    max-height:calc(100% - 36px)!important;
    padding:12px;
    overflow:auto;
  }
  body[data-surface="home"]:not(.portal-home):not(.arrival-playing) .exhibit-card :is(.object-breadcrumb,#object-parent){margin:0 0 5px;font-size:9px;line-height:1.25}
  body[data-surface="home"]:not(.portal-home):not(.arrival-playing) .exhibit-card :is(#exhibit-title,.object-title){margin:3px 0 5px;font-size:15px;line-height:1.2}
  body[data-surface="home"]:not(.portal-home):not(.arrival-playing) .exhibit-card .system-learning-actions{display:grid!important;grid-template-columns:1fr 1fr;gap:4px;margin:7px 0}
  body[data-surface="home"]:not(.portal-home):not(.arrival-playing) .exhibit-card .system-learning-actions :is(a,button){min-width:0;min-height:34px;padding:6px;font-size:9px;line-height:1.2;white-space:normal}
  body[data-surface="home"]:not(.portal-home):not(.arrival-playing) .exhibit-card #object-learning-scope{display:block;font-size:9px;line-height:1.35}
  body[data-surface="home"]:not(.portal-home):not(.arrival-playing) .exhibit-card .home-asset-catalog{margin-top:7px}
  body[data-surface="home"]:not(.portal-home):not(.arrival-playing) .exhibit-card #home-asset-list{max-height:180px;overflow:auto}
  body[data-surface="home"]:not(.portal-home):not(.arrival-playing) .exhibit-card #home-asset-list a{display:block;padding:4px 0;font-size:9px}
  body[data-surface="home"]:not(.portal-home):not(.arrival-playing).inspector-open .inspector{
    right:var(--home-gutter)!important;
    top:var(--home-right-top)!important;
    bottom:calc(var(--home-dock-height) + 20px)!important;
    width:var(--home-rail-right)!important;
    padding:12px;
    overflow:auto;
    background:rgba(248,251,253,.95);
  }
  body[data-surface="home"]:not(.portal-home):not(.arrival-playing).inspector-open :is(.energy-data-card,.energy-history-panel,.energy-history,.energy-trend-card){display:none!important}
}

@media (min-width:701px) and (max-width:1199px){
  :root{--home-rail-left:154px;--home-rail-right:228px;--home-gutter:14px;--home-dock-height:124px}
  body[data-surface="home"]:not(.portal-home):not(.arrival-playing) .stage-heading{display:none}
  body[data-surface="home"]:not(.portal-home):not(.arrival-playing) .energy-run-controls button:nth-of-type(2),
  body[data-surface="home"]:not(.portal-home):not(.arrival-playing) .energy-run-controls button:nth-of-type(3){display:none}
}

@media (min-width:1700px){
  :root{--home-rail-left:220px;--home-rail-right:300px;--home-gutter:34px;--home-dock-height:142px}
  body[data-surface="home"]:not(.portal-home):not(.arrival-playing) .side-left :is(.system-tabs,.focus-list) button{min-height:35px;font-size:12px}
}

/* Anchored power labels keep two-line text inside their own hit targets. */
.energy-workbench .energy-callout{width:156px;max-width:156px;white-space:normal!important;line-height:1.35!important;border-radius:10px!important}
body[data-surface="home"]:not(.portal-home):not(.arrival-playing) .home-scene-title{display:none}

@media(min-width:701px){
 body[data-surface="home"]:not(.portal-home):not(.arrival-playing):not(.inspector-open) .exhibit-card{display:block!important}
 body[data-surface="home"]:not(.portal-home):not(.arrival-playing).inspector-open .exhibit-card{display:none!important}
}

/* Keep a visible simulation clock/status when disassembly freezes the data. */
body[data-surface="home"]:not(.portal-home):not(.arrival-playing) .energy-workbench:not([data-structure="true"]) .energy-data-card .energy-clock{display:block;margin-top:7px;color:#60717e;font-size:10px}
