/* One page owns vertical scrolling. Keep each diagram with its readings. */
body { height:auto; overflow:auto; }
.workspace { height:auto; align-items:start; }
.right-column { display:flex; flex-direction:column; height:auto; min-height:0; overflow:visible; gap:12px; }
.experiment-panel { height:auto; min-height:0; flex:none; overflow:visible; }
.view-tabs { height:auto; min-height:36px; flex:none; border-radius:var(--radius) var(--radius) 0 0; }
.view-tabs button { padding:9px 11px; }
.reference-view:not([hidden]) { height:auto; max-height:none; min-height:0; flex:none; overflow:visible; padding:12px; }
.reference-heading { margin-bottom:7px; min-width:0; flex-wrap:wrap; }
.reference-heading h2 { font-size:25px; }
.reference-choice { margin:5px 0 9px; }
.reference-notes { margin-top:8px; }
.reference-notes > summary { padding:3px 0; font-size:11px; line-height:1.3; color:var(--muted); }
.reference-notes .reference-caption { margin:3px 0 8px; }
.atom-reference-layout { grid-template-columns:minmax(120px,.6fr) minmax(0,1.4fr); gap:10px; align-items:start; }
.atom-reference-layout .atom-visual { width:100%; height:190px; min-height:0; margin:0; }
.atom-reference-layout .atom-visual svg { width:100%; height:100%; }
.photon-reference { margin:0; }
.photon-reference-facts { gap:7px 10px; }
.photon-fact small { font-size:10px; line-height:1.3; }
.photon-fact-detail,.photon-population-labels { font-size:10px; }
.photon-population { margin-top:9px; }
.photon-reference-caption { line-height:1.45; }
.photon-clock-note { padding-top:6px; margin-top:6px; border-top:1px solid var(--line); }
.configuration-large { margin:4px 0 10px; font-size:19px; }
.ground-state-details { margin-top:12px; }
.ground-state-details > summary { padding:11px 0; }
.orbital-diagram { max-height:none; overflow:visible; }
.details-panel { display:block; height:auto; max-height:none; min-height:0; min-width:0; max-width:100%; overflow:visible; padding:15px; }
.element-summary { display:block !important; white-space:normal; overflow:visible; text-overflow:clip; -webkit-line-clamp:unset !important; margin:9px 0; }
.element-context { line-height:1.5; }
.element-facts { margin:11px 0; gap:10px 16px; }
.details-panel > details > summary { padding:11px 0; white-space:normal; }
.comparison-content { min-width:0; max-width:100%; overflow-x:auto; overscroll-behavior-x:contain; }
.comparison-content:focus-visible { outline:2px solid var(--green-dark); outline-offset:3px; border-radius:4px; }
.comparison-table { min-width:340px; }
.photon-controls { padding:11px 12px; border-radius:0 0 var(--radius) var(--radius); }
.gun-title { gap:8px; margin-bottom:8px; }
.gun-title strong { font-size:13px; }
.em-scale { margin-bottom:6px; }
.wavelength-controls { grid-template-columns:12px minmax(80px,1fr) 62px auto; gap:6px; margin-bottom:7px; }
.wavelength-controls input,.wavelength-controls select { height:32px; font-size:12px; padding:5px 7px; }
.wavelength-controls select { padding-right:20px; }
.wavelength-controls button { min-height:32px; }
.beam-power { min-height:30px; }
.beam-power output { font-size:11px; }
.photon-controls .thermal-strip { flex-wrap:wrap; gap:7px; margin:7px 0; }
.thermal-strip span { font-size:11px; }
.thermal-strip button { min-height:30px; font-size:11px; }
.photon-controls .beam-power { height:auto; }
.beam-notes { margin-top:8px; }
.beam-notes > summary { padding:6px 0; font-size:11px; }
.beam-notes[open] { position:static; inset:auto; width:auto; max-height:none; overflow:visible; padding:0; border:0; border-radius:0; box-shadow:none; }
.experiment-panel[data-active-view="crucible"] .photon-controls > #excitation-status,
.experiment-panel:not([data-active-view="crucible"]) .photon-controls > #heating-status { display:none; }
.experiment-panel[data-active-view="crucible"] #sample-thermal-mini { display:none; }
.experiment-panel[data-active-view="crucible"] #wall-thermal-mini,
.experiment-panel[data-active-view="crucible"] #reset-atomic,
.playback #reset { display:none; }
.table-guide .guide-title { display:none; }
.table-guide p:last-child { display:block; font-size:11px; }
.table-toolbar { margin-bottom:6px; }
.table-filters { display:flex; flex-wrap:wrap; align-items:center; gap:5px 10px; margin:0 0 8px; flex:none; }
.table-filters > label { display:flex; align-items:center; gap:5px; color:var(--muted); font-size:11px; }
.table-filters select { width:57px; height:28px; min-height:28px; padding:3px 20px 3px 6px; font-size:11px; }
.table-filters > button { min-height:28px; padding:4px 8px; font-size:11px; }
.table-filter-status { flex:1; min-width:120px; margin:0; color:var(--muted); font-size:10px; line-height:1.4; }
.table-filter-note { margin:0 0 8px; color:var(--muted); font-size:10px; line-height:1.4; }
.grid-filter { min-width:0; width:100%; height:100%; padding:0; border:1px solid transparent; border-radius:4px; background:transparent; font:inherit; font-size:10px; color:var(--muted); cursor:pointer; }
.grid-filter:hover { border-color:var(--line); background:var(--soft); }
.grid-filter[aria-pressed="true"] { background:var(--green); color:var(--paper); font-weight:700; border-color:var(--green-dark); }
.grid-filter:focus-visible { outline:2px solid var(--green-dark); outline-offset:1px; z-index:4; }
.element.dimmed.selected { opacity:.55; }
.element[aria-disabled="true"] { cursor:default; }
.element[aria-disabled="true"]:hover { transform:none; box-shadow:none; }
.list-element[aria-pressed="true"] { outline:2px solid var(--green-dark); outline-offset:-2px; }
@media(max-width:420px) {
  .table-filters { gap:5px 8px; }
  .table-filter-status { flex-basis:100%; }
  .table-filters select,.table-filters > button { height:32px; min-height:32px; }
}
.state-key-items { gap:5px 10px; }
#beam-settings { border-top:1px solid var(--line); margin-top:9px; font-size:11px; color:var(--muted); }
#beam-settings > summary { padding:8px 0; font-size:11px; }
#beam-settings #resonance-select { width:100%; max-width:100%; height:auto; min-height:34px; font-size:12px; padding:6px 26px 6px 9px; }
#beam-settings .exact-heat { margin:10px 0 4px; }
#beam-settings p { line-height:1.5; }
#wavelength-edit-note { margin:4px 0 7px; font-size:10px; color:var(--muted); }
#account-slot { display:flex; align-items:center; min-width:0; }
#account-slot:empty { display:none; }
#account-slot .sn-account-link { display:flex !important; align-items:center; min-width:0; position:static !important; inset:auto !important; z-index:auto !important; max-width:180px !important; padding:8px 10px !important; border:1px solid var(--line) !important; border-radius:8px !important; box-shadow:none !important; background:var(--soft) !important; color:var(--ink) !important; font:600 11px/1.4 "Segoe UI",sans-serif !important; text-decoration:none; text-overflow:ellipsis; overflow:hidden; }
.app-header #save-setup { display:none; }
.app-footer { height:auto; min-height:30px; padding:14px 22px 20px; }
.app-footer > span:last-child { display:inline; }

/* Settings remain legible on a narrow screen and closable after scrolling. */
#settings-dialog { scroll-padding-top:80px; scroll-padding-bottom:16px; }
#settings-dialog .dialog-heading { position:sticky; top:0; z-index:2; background:var(--panel); padding:4px 0 8px; margin-bottom:12px; }
#settings-dialog .settings-group { min-inline-size:0; border:0; padding:0; margin:12px 0; }
#settings-dialog .settings-group > legend { padding:0; color:var(--green-dark); font-size:12px; font-weight:650; }
#settings-dialog .settings-group + .settings-group { border-top:1px solid var(--line); padding-top:12px; margin-top:15px; }
#settings-dialog .settings-row { margin:10px 0; }
#settings-dialog .settings-notes > summary { color:var(--muted); font-size:11px; padding:5px 0; }
@media(max-width:420px) {
  #settings-dialog .settings-row { display:grid; grid-template-columns:minmax(65px,.8fr) minmax(0,2fr); gap:10px; }
  #settings-dialog .settings-row select { width:100%; max-width:none; font-size:12px; padding:7px 22px 7px 8px; }
  .element-identity { display:grid; grid-template-columns:49px minmax(0,1fr) auto; gap:8px 11px; }
  .element-identity .identity-tile { grid-column:1; grid-row:1; }
  .element-identity > div:nth-child(2) { grid-column:2/-1; grid-row:1; min-width:0; }
  .element-identity h2 { overflow-wrap:anywhere; }
  .element-identity .photo-open,.element-identity .photo-unavailable { grid-column:2; grid-row:2; justify-self:start; margin:0; max-width:100%; }
  .element-identity > .icon-button { grid-column:3; grid-row:2; }
}

/* The chamber uses an intrinsic canvas height; opening details extends the page. */
#view-crucible:not([hidden]) { display:grid; height:auto; min-height:0; flex:none; grid-template-columns:155px minmax(0,1fr); grid-template-rows:auto clamp(210px,30dvh,330px) auto auto auto; }
.scene-heading { grid-column:1/-1; grid-row:auto; padding:10px 13px; }
.scene-heading { flex-wrap:wrap; }
.sample-state-banner { --state-accent:var(--green-dark); display:flex; align-items:center; gap:10px; flex:1 0 100%; width:100%; min-width:0; margin-top:3px; padding:8px 10px; border:1px solid var(--line); border-left:4px solid var(--state-accent); border-radius:7px; background:var(--soft); }
.sample-state-banner[hidden] { display:none; }
.sample-state-banner > div { flex:1; min-width:0; }
.sample-state-banner strong { display:block; font-size:16px; line-height:1.25; color:var(--state-accent); }
.sample-state-banner span { display:block; color:var(--muted); font-size:10px; line-height:1.4; margin-top:2px; }
.sample-state-banner button { flex:none; padding:5px 7px; font-size:10px; min-height:30px; }
.sample-state-banner[data-state="liquid-like"] { --state-accent:#2861a8; }
.sample-state-banner[data-state="gas-like"] { --state-accent:#ad3c47; }
.sample-state-banner[data-state="unknown"],.sample-state-banner[data-state="condensed"] { --state-accent:var(--ink); }
html[data-app-theme="dark"] .sample-state-banner[data-state="liquid-like"] { --state-accent:#a2c6f5; }
html[data-app-theme="dark"] .sample-state-banner[data-state="gas-like"] { --state-accent:#f2a5ae; }
.sample-state-dialog { width:min(520px,calc(100vw - 28px)); max-height:calc(100dvh - 48px); overflow:auto; color:var(--ink); background:var(--panel); border:1px solid var(--line); border-radius:14px; }
.sample-state-dialog p,.sample-state-dialog li { font-size:13px; line-height:1.55; }
.photon-controls #sample-thermal-mini,.photon-controls #wall-thermal-mini { display:none; }
.bulk-reference-reading { margin:7px 0; }
.bulk-reference-reading #bulk-phase { display:inline-block; margin:0; font-size:10px; }
.scene-heading h2 { font-size:24px; }
.chamber-stage { grid-column:1/-1; grid-row:auto; height:auto; min-height:0; }
.playback { grid-column:1; grid-row:auto; padding:8px; }
.readings { grid-column:2; grid-row:auto; grid-template-columns:1fr 1fr; padding:6px 12px 6px 0; gap:8px; }
.readings > div:nth-child(2) { grid-column:2; grid-row:auto; }
.readings strong { font-size:25px; }
.reading-label { font-size:10px; white-space:normal; }
.advanced-controls,.chart-details { grid-row:auto; }
.advanced-controls { grid-column:1; }
.chart-details { grid-column:2; }
.advanced-controls > summary,.chart-details > summary { height:auto; min-height:36px; padding:9px 12px; }
.advanced-controls[open],.chart-details[open] { position:static; inset:auto; grid-column:1/-1; width:auto; max-height:none; overflow:visible; border:0; border-radius:0; box-shadow:none; }
.advanced-controls[open] > summary,.chart-details[open] > summary { position:static; height:auto; font-size:12px; padding:10px 12px; }
.model-caption { grid-column:1/-1; grid-row:auto; padding:7px 12px; white-space:normal; overflow:visible; }

@media(min-width:721px) {
  #view-atom:not([hidden]) { display:grid; grid-template-columns:minmax(0,1fr) auto; gap:10px; }
  #view-atom .reference-heading,#view-atom .reference-choice { margin:0; }
  #view-atom .reference-choice { gap:7px; }
  #view-atom .atom-reference-layout,#view-atom .reference-notes { grid-column:1/-1; }
}

@media(min-width:1060px) {
  .workspace { grid-template-columns:minmax(0,1.15fr) minmax(440px,1fr); gap:14px; padding-bottom:18px; }
  .table-panel { position:sticky; top:12px; height:calc(100dvh - 112px); min-height:550px; display:flex; flex-direction:column; }
  .table-viewport { flex:1; min-height:0; }
  .periodic-grid { height:100%; max-height:calc(72cqw + 20px); min-width:0; }
  .element-list { flex:1; max-height:none; }
  .right-column { grid-template-rows:none; }
  .reference-view:not([hidden]) { padding:12px; }
  .photon-host .photon-reference-facts { grid-template-columns:repeat(4,minmax(0,1fr)); }
  .element-facts > div:nth-child(n+3) { display:block; }
  .photon-controls { padding:7px 12px; }
  .gun-title { margin-bottom:5px; }
  .em-scale { height:34px; margin-bottom:3px; }
  .wavelength-controls { margin-bottom:4px; }
  .wavelength-controls input,.wavelength-controls select,.wavelength-controls button { height:29px; min-height:29px; }
  .beam-power { min-height:26px; }
  .photon-controls .thermal-strip { margin:4px 0; }
  .thermal-strip button { min-height:26px; }
  #beam-settings { margin-top:6px; }
  #beam-settings > summary { padding:6px 0; }
}

@media(min-width:1060px) and (max-height:649px) {
  .table-panel { position:relative; top:auto; height:auto; min-height:0; }
  .table-viewport { display:block; }
  .periodic-grid { height:auto; max-height:none; }
}

@media(min-width:1060px) and (min-height:650px) and (max-height:750px) {
  .view-tabs button { padding:7px 10px; }
  .reference-view:not([hidden]) { padding:10px; }
  #view-atom:not([hidden]) { gap:8px; }
  #view-atom .reference-notes { margin:0; }
  .photon-reference { padding-top:8px; padding-bottom:7px; }
  .photon-population { margin-top:7px; }
  .photon-controls { padding-top:5px; padding-bottom:5px; }
  .em-scale { height:32px; }
  .wavelength-controls { margin-bottom:3px; }
  .photon-controls .thermal-strip { margin:3px 0; }
  #beam-settings > summary { padding-top:4px; padding-bottom:4px; }
}

@media(max-width:1059px) {
  .workspace { display:block; padding:0 12px 16px; }
  .mobile-navigation { display:flex; position:sticky; top:0; z-index:30; padding-top:5px; background:var(--paper); margin:0 14px 12px; border-bottom:1px solid var(--line); gap:16px; }
  .mobile-navigation button { background:none; padding:10px 8px; font-size:12px; color:var(--muted); border-bottom:2px solid transparent; }
  .mobile-navigation button[aria-pressed="true"] { border-bottom-color:var(--green); color:var(--green-dark); font-weight:600; }
  .workspace[data-mobile-view="table"] > .right-column,
  .workspace[data-mobile-view="experiment"] > .table-panel,
  .workspace[data-mobile-view="details"] > .table-panel,
  .workspace[data-mobile-view="experiment"] .details-panel,
  .workspace[data-mobile-view="details"] .experiment-panel { display:none; }
  .table-panel { position:relative; top:auto; height:auto; min-height:0; }
  .experiment-panel,.details-panel,.table-panel { scroll-margin-top:58px; }
  .right-column { grid-template-columns:none; }
  .atom-reference-layout { grid-template-columns:minmax(160px,.65fr) minmax(0,1.35fr); }
}

@media(max-width:720px) {
  .app-header { display:grid; grid-template-columns:35px minmax(0,1fr) auto; gap:8px 10px; padding:10px 12px; }
  .app-header .brand-mark { grid-column:1; grid-row:1; }
  .app-header .heading { grid-column:2; grid-row:1; }
  .header-actions { display:contents; }
  .header-actions #open-settings { grid-column:3; grid-row:1; }
  #account-slot { grid-column:2/-1; grid-row:2; justify-self:end; }
  .app-header h1 { font-size:25px; }
  .view-tabs { padding:0 7px; gap:0; }
  .view-tabs button { font-size:12px; padding:11px 8px; }
  .reference-view:not([hidden]) { padding:12px; }
  .reference-heading h2 { font-size:25px; }
  .reference-badge { font-size:9px; white-space:normal; text-align:right; max-width:110px; }
  .atom-reference-layout { grid-template-columns:minmax(0,1fr); gap:10px; }
  .atom-reference-layout .atom-visual { height:120px; }
  .photon-reference { padding:10px; }
  .photon-reference svg { max-height:none; }
  .photon-reference-heading { align-items:start; }
  .photon-reference-caption,.photon-clock-note { font-size:10px; }
  .photon-host .photon-reference-facts { grid-template-columns:repeat(2,minmax(0,1fr)); }
  .photon-population-labels { gap:5px; }
  .photon-controls { padding:12px; }
  .gun-title { gap:6px; }
  .gun-title strong { gap:5px; }
  .gun-title svg { width:27px; }
  #beam-band { font-size:9px; }
  .atomic-reset { padding:4px 5px; }
  .wavelength-controls { grid-template-columns:10px minmax(0,1fr) 61px 43px; gap:5px; }
  .wavelength-controls input,.wavelength-controls select,.wavelength-controls button { min-height:36px; height:36px; }
  .wavelength-controls select { padding-right:19px; }
  .thermal-strip { align-items:center; }
  .thermal-strip #bulk-phase { margin-right:0; }
  .thermal-strip button { min-height:36px; }
  .beam-power { grid-template-columns:47px minmax(0,1fr) auto; gap:6px; }
  .beam-power output { font-size:10px; }
  #view-crucible:not([hidden]) { display:block; }
  .scene-heading { gap:7px; }
  .scene-heading h2 { font-size:25px; }
  .sample-count { font-size:10px; }
  .model-badge { max-width:110px; white-space:normal; text-align:right; }
  .chamber-stage { height:clamp(210px,32dvh,310px); }
  .playback { padding:9px 12px; }
  .readings { padding:0 13px 10px; }
  .readings strong { font-size:25px; }
  .model-caption { display:block; font-size:10px; line-height:1.5; }
  .model-caption .text-button { display:block; margin-top:5px; }
  .table-guide { max-width:230px; }
  .table-guide p:last-child { font-size:11px; }
  .details-panel { padding:15px; }
  .element-summary { font-size:13px; }
  .app-footer { padding-bottom:36px; }
}

/* Keep the Sources destination clear of the sticky workspace navigation. */
@media(max-width:1059px) { #sources-details > summary { scroll-margin-top:64px; } }

.state-facts { display:grid; grid-template-columns:minmax(100px,1.2fr) minmax(0,1fr); gap:8px 12px; margin:16px 0; font-size:12px; }
.state-facts dt { color:var(--muted); }
.state-facts dd { margin:0; overflow-wrap:anywhere; }
.sample-state-dialog a { font-size:12px; }

.sample-state-dialog { scroll-padding-top:80px; scroll-padding-bottom:16px; }
.sample-state-dialog > .dialog-heading { position:sticky; top:0; z-index:2; background:var(--panel); padding:4px 0 8px; margin-bottom:12px; }

/* Match feedback to the active reference rather than mixing both clocks. */
.experiment-panel[data-active-view="crucible"] :is(#excitation-status,#atomic-caveat),
.experiment-panel:not([data-active-view="crucible"]) :is(#heating-status,#phase-transition-note,#model-range-note) { display:none; }
