/* The document owns scrolling. Dense rosters expand in place; full detail
   text is measured into pages inside the viewport, never a scroll pane. */
body.science-mode { background: #101516; color: #f0f2eb; }
.science-mode #topography { display: none; }
.science-shell {
  --bg: #101516; --panel: #192021; --edge: #354140; --text: #f0f2eb;
  --muted: #b2bdb8; --green: #c8ecaa; --amber: #efce86; --red: #ffb3aa; --blue: #a8d8ed;
  color-scheme: dark; max-width: 1600px; margin: auto; padding: 0 32px 40px;
  color: var(--text); font: 14px/1.5 system-ui, -apple-system, sans-serif;
}
.science-shell *, .science-shell *::before, .science-shell *::after { box-sizing: border-box; min-width: 0; }
.science-shell [hidden] { display: none !important; }
.science-shell h1, .science-shell h2, .science-shell h3, .science-shell p { margin: 0; }
.science-shell h1 { font-size: 36px; font-weight: 520; letter-spacing: -1.3px; line-height: 1.2; }
.science-shell h2 { font-size: 19px; font-weight: 550; }
.science-shell h3 { font-size: 16px; }
.science-shell p, .science-shell small, .science-shell h2, .science-shell h3 { overflow-wrap: anywhere; }
.science-shell small, .science-shell .note { color: var(--muted); font-size: 12px; }
.science-shell button, .science-shell select {
  font: inherit; color: inherit; background: #222c2c; border: 1px solid var(--edge);
  border-radius: 8px; padding: 9px 13px; cursor: pointer; min-height: 44px; max-width: 100%;
  white-space: normal; overflow-wrap: anywhere; box-shadow: none;
}
.science-shell button:hover { border-color: var(--green); transform: none; }
.science-shell :is(button, select, a, [tabindex]):focus-visible { outline: 2px solid var(--green); outline-offset: 3px; }
.science-shell button:disabled { opacity: .6; cursor: default; }
.science-shell .loop-topbar {
  min-height: 77px; display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid var(--edge); gap: 16px; flex-wrap: wrap; padding-block: 12px;
}
.science-shell .loop-brand { font-size: 19px; letter-spacing: -.6px; color: var(--green); text-decoration: none; }
.science-shell .top-right { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.science-shell .eyebrow { font-size: 11px; letter-spacing: 1.8px; font-weight: 650; text-transform: uppercase; color: var(--muted); }
.science-shell .pill { display: inline-flex; border: 1px solid var(--edge); border-radius: 30px; padding: 5px 10px; font-size: 12px; max-width: 100%; overflow-wrap: anywhere; }
.science-shell .pill.good { color: var(--green); }
.science-shell .pill.bad { color: var(--red); border-color: #a8645c; background: #342320; }
.science-shell .hero { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; padding: 27px 0 20px; }
.science-shell .hero p { color: var(--muted); margin-top: 8px; }
.science-shell .hero h1 { margin-top: 6px; }
.science-shell .stats { text-align: right; flex: 0 1 360px; }
.science-shell .stats strong { color: var(--green); font-size: 24px; font-weight: 450; }
.science-shell .snapshot-status { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 16px; }
.science-shell .loop-notice { color: var(--muted); font-size: 12px; }
.science-shell .snapshot-status button { flex: none; }
.science-shell .panel { background: var(--panel); border: 1px solid var(--edge); border-radius: 14px; }
.science-shell .panelhead { display: flex; align-items: center; justify-content: space-between; padding: 17px 20px; gap: 12px; flex-wrap: wrap; border-bottom: 1px solid var(--edge); }
.science-shell .panelhead > div { max-width: 100%; }
.science-shell .loop { position: relative; padding: 20px; isolation: isolate; }
.science-shell .engine-track-token {
  position: absolute; left: 0; top: 0; width: 23px; height: 23px; display: grid; place-items: center;
  background: var(--green); color: #1d3022; border: 2px solid var(--bg); border-radius: 50%;
  z-index: 2; offset-distance: 0%; animation: science-lap 28s linear infinite; font-size: 15px; pointer-events: none;
}
@keyframes science-lap { to { offset-distance: 100%; } }
.science-shell.motion-stopped .engine-track-token, .science-shell.motion-stopped .orbit-dot { animation-play-state: paused; }
.science-shell .loopgrid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 14px; position: relative; z-index: 1; align-items: stretch; }
.science-shell .station { min-height: 187px; background: #1d2726; border: 1px solid #41504a; border-radius: 10px; padding: 12px; }
.science-shell .stationhead { display: flex; align-items: start; justify-content: space-between; gap: 4px; }
.science-shell .stationhead strong { font-size: 11px; letter-spacing: .6px; overflow-wrap: anywhere; }
.science-shell .stationhead span { font: 12px ui-monospace, monospace; color: var(--muted); flex: none; }
.science-shell .station > p { font-size: 12px; color: var(--muted); margin: 6px 0; min-height: 36px; }
.science-shell .station.measure { border-color: #6f8b9a; }
.science-shell .station.judge { border-color: #8d7c54; }
.science-shell .station.decide { border-color: #6d875d; }
.science-shell .roster-count { display: block; margin-bottom: 7px; font-size: 11px; }
.science-shell .tokens { display: flex; gap: 6px; flex-wrap: wrap; align-content: start; padding: 3px; }
.science-shell .token { width: fit-content; max-width: 100%; display: flex; align-items: center; gap: 5px; padding: 3px 6px 3px 3px; background: #2c3834; border: 1px solid #526253; border-radius: 24px; min-height: 44px; font-size: 11px; flex: 0 1 auto; }
.science-shell .token.lane { border-radius: 6px; background: #2b363c; border-color: #4e6a78; }
.science-shell .token.blocked { border-color: var(--amber); box-shadow: inset 0 0 0 1px var(--amber); }
.science-shell .token.invalid { border-style: dashed; }
.science-shell .token span { white-space: nowrap; text-overflow: ellipsis; overflow: hidden; }
.science-shell .token .token-copy { display: flex; flex-direction: column; min-width: 0; text-align: left; white-space: normal; }
.science-shell .stage-provenance { white-space: normal; overflow-wrap: anywhere; font-size: 10px; color: var(--muted); }
.science-shell .avatar { width: 27px; height: 31px; flex: none; }
.science-shell .return-rail { height: 28px; border: 1px dashed #6a815d; border-top: 0; border-radius: 0 0 12px 12px; margin: 0 15px 18px; position: relative; }
.science-shell .return-rail::before { content: '▴'; position: absolute; top: -8px; left: -4px; color: #6a815d; }
.science-shell .loopfoot { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.science-shell .enginebox { display: flex; align-items: center; gap: 12px; }
.science-shell .orbital { width: 40px; height: 40px; flex: none; position: relative; display: grid; place-items: center; border: 1px dashed #829271; border-radius: 50%; }
.science-shell .orbit-dot { position: absolute; inset: -3px; animation: science-orbit 12s linear infinite; }
.science-shell .orbit-dot::after { content: ''; display: block; width: 7px; height: 7px; background: var(--green); border-radius: 50%; margin: auto; }
.science-shell .engine-mark { font-size: 20px; color: var(--green); }
@keyframes science-orbit { to { transform: rotate(360deg); } }
.science-shell .legend { display: flex; gap: 14px; color: var(--muted); font-size: 12px; flex-wrap: wrap; }
.science-shell .legend i { display: inline-block; width: 9px; height: 9px; border: 1px solid var(--green); border-radius: 50%; margin-right: 5px; }
.science-shell .legend i.square { border-color: var(--blue); border-radius: 2px; }
.science-shell .unknown-tray { margin-top: 18px; padding-top: 15px; border-top: 1px dashed var(--edge); }
.science-shell .unknown-tray .tokens { margin-top: 8px; }
.science-shell .workspace { display: grid; grid-template-columns: minmax(0, 1fr) 322px; gap: 22px; margin-top: 26px; align-items: start; }
.science-shell .sectionhead { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 13px; flex-wrap: wrap; }
.science-shell .cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.science-shell .card { padding: 15px; display: flex; flex-direction: column; gap: 11px; min-height: 281px; }
.science-shell .cardhead { display: flex; gap: 9px; align-items: center; }
.science-shell .cardhead > div { flex: 1; }
.science-shell .cardhead h3 { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.science-shell .cardhead small { font-size: 11px; }
.science-shell .stage-label { font-size: 10px; letter-spacing: .7px; text-transform: uppercase; color: var(--green); overflow-wrap: anywhere; }
.science-shell .mini-track { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 4px; }
.science-shell .mini-track i { height: 3px; background: #3a4840; border-radius: 2px; }
.science-shell .mini-track .current { background: var(--green); }
.science-shell .digest { display: grid; gap: 8px; font-size: 12px; }
.science-shell .digest p { overflow-wrap: anywhere; }
.science-shell .card .digest p > span { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; overflow: hidden; }
.science-shell .digest b { font-size: 10px; letter-spacing: .6px; color: var(--muted); font-weight: 650; display: block; }
.science-shell .chips { display: flex; flex-wrap: wrap; gap: 5px; max-width: 100%; padding: 3px 0 5px; }
.science-shell .chips .chip { display: block; flex: 0 1 auto; max-width: 100%; min-height: 32px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 10px; border: 1px solid var(--edge); padding: 3px 7px; border-radius: 5px; color: var(--muted); }
.science-shell .cardfoot { display: flex; justify-content: space-between; align-items: center; gap: 6px; margin-top: auto; flex-wrap: wrap; }
.science-shell .cardfoot small { font-size: 11px; }
.science-shell .detail-button { font-size: 11px; padding: 6px 10px; }
.science-shell .blocked-note { color: var(--amber); font-size: 12px; }
.science-shell .error-note { color: var(--red); font-size: 12px; }
.science-shell .digest-status { font-size: 10px; }
.science-shell .journal { padding: 18px; }
.science-shell .entry { border-left: 1px solid #586b4f; padding-left: 13px; margin-bottom: 23px; }
.science-shell .entry time { color: var(--green); font: 10px/1.5 ui-monospace, monospace; overflow-wrap: anywhere; }
.science-shell .entry h3 { font-size: 13px; margin: 7px 0; }
.science-shell .loop-footer { display: flex; gap: 14px; justify-content: space-between; flex-wrap: wrap; padding-top: 24px; color: var(--muted); font-size: 11px; }
.science-shell .loop-tooltip { position: fixed; z-index: 20; pointer-events: none; width: min(330px, calc(100vw - 16px));  padding: 15px; background: #24302b; border: 1px solid #6b805d; border-radius: 10px; box-shadow: 0 10px 30px #0009; }
.science-shell .loop-tooltip h3 { margin-bottom: 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.science-shell .loop-tooltip .digest span { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; }
.science-shell .loop-dialog { background: var(--panel); color: var(--text); border: 1px solid #728366; border-radius: 15px; padding: 0; width: min(760px, calc(100vw - 24px)); max-width: calc(100vw - 24px); height: min(760px, calc(100dvh - 24px)); max-height: none; overflow: visible; margin: auto; }
.science-shell .loop-dialog::backdrop { background: #06100cbd; backdrop-filter: blur(4px); }
.science-shell .loop-dialog[open] { display: flex; flex-direction: column; container-type: size; }
.science-shell .loop-dialog .panelhead { flex: none; padding: 12px 16px; }
.science-shell .loop-dialog .panelhead > div { flex: 1; }
.science-shell .loop-dialog .panelhead button { flex: none; }
.science-shell #loop-detail-title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.science-shell .dialog-body { display: flex; flex-direction: column; flex: 1; min-height: 0; padding: 12px 16px; overflow-wrap: anywhere; }
.science-shell .detail-tabs { display: flex; flex-wrap: wrap; gap: 4px; padding: 8px 16px; flex: none; }
.science-shell .detail-tabs button { flex: 1 0 auto; padding: 5px; font-size: 12px; }
.science-shell .detail-tabs [aria-pressed="true"] { color: var(--green); border-color: var(--green); }
.science-shell .text-pager { display: flex; flex-direction: column; flex: 1; min-height: calc(21px + 52px); gap: 8px; }
.science-shell .pager-text { display: block; flex: 1; min-height: 21px; margin: 0; padding: 0; width: 100%; max-width: 100%; white-space: pre-wrap; overflow-wrap: anywhere; overflow: visible; font: 13px/1.6 system-ui, sans-serif; }
.science-shell .page-controls { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex: none; }
.science-shell .page-controls button { font-size: 12px; padding: 8px; }
.science-shell .tail-panel { display: flex; flex-direction: column; flex: 1; min-height: 0; gap: 8px; }
.science-shell .token-stack { width: 100%; border-style: dashed; color: var(--green); font-size: 12px; }
.science-shell .top-right a { color: var(--green); }
.science-shell .tail-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.science-shell .tail-tools select { flex: 1 1 0; }
.science-shell .tail-tools label { display: inline-flex; gap: 8px; align-items: center; }
.science-shell .loop-log { font-family: ui-monospace, monospace; }
.science-shell .transition-ghost { position: fixed; z-index: 10; pointer-events: none; }
@media (min-width: 1440px) { .science-shell { padding-inline: 40px; } .science-shell .station { min-height: 192px; } }
@media (max-width: 1439px) {
  .science-shell .workspace { grid-template-columns: minmax(0, 1fr) 290px; }
  .science-shell .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .science-shell .loopgrid { gap: 8px; } .science-shell .station { padding: 10px; }
}
@media (max-width: 1179px) {
  .science-shell .workspace { grid-template-columns: minmax(0, 1fr); }
  .science-shell .cards { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .science-shell .loopgrid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .science-shell .station { min-height: 155px; }
  .science-shell .hero { align-items: start; } .science-shell .stats { flex-basis: 250px; }
}
@media (max-width: 819px) {
  .science-shell { padding-inline: 16px; }
  .science-shell .hero { display: block; } .science-shell h1 { font-size: 30px; }
  .science-shell .stats { text-align: left; margin-top: 13px; } .science-shell .stats strong { font-size: 18px; }
  .science-shell .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .science-shell .loopgrid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .science-shell .loop { padding: 14px; } .science-shell .panelhead { padding: 14px; }
}
@media (max-width: 519px) {
  .science-shell { padding-inline: 12px; }
  .science-shell .cards { grid-template-columns: minmax(0, 1fr); }
  .science-shell .station { padding: 8px; min-height: 180px; }
  .science-shell .stationhead strong { font-size: 10px; letter-spacing: 0; }
  .science-shell .snapshot-status { flex-wrap: wrap; }
  .science-shell .dialog-body { padding: 14px; }
}
@media (prefers-reduced-motion: reduce) {
  .science-shell *, .science-shell *::before, .science-shell *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

@media (max-height: 600px) {
  .science-shell .loop-dialog .panelhead { padding: 6px 10px; }
  .science-shell .detail-tabs { padding: 4px 10px; }
  .science-shell .dialog-body { padding: 6px 10px; }
  .science-shell .tail-status { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
}

/* Query the actual dialog size so CSS zoom and browser zoom both leave room
   for a complete text line plus pagination, without adding a scroll pane. */
@container (max-height: 420px) {
  .science-shell .loop-dialog .panelhead { padding: 4px 8px; }
  .science-shell .loop-dialog button, .science-shell .loop-dialog select { min-height: 32px; padding: 4px; }
  .science-shell .detail-tabs { padding: 4px 8px; }
  .science-shell .dialog-body { padding: 4px 8px; }
  .science-shell .tail-panel, .science-shell .text-pager { gap: 4px; }
  .science-shell .text-pager { min-height: calc(21px + 36px); }
  .science-shell .tail-tools { gap: 4px; }
  .science-shell .tail-status { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
}

/* Research history grows with the document, including narrow layouts. */
.science-shell .pane-stream { grid-column: 1 / -1; height: auto; max-height: none; overflow: visible; }
.science-shell .pane-stream .pane-body { height: auto; max-height: none; overflow: visible; overflow-anchor: none; }
.science-shell .stream-row { overflow-anchor: none; }
.science-shell .pane-stream .new-events { position: sticky; bottom: 12px; display: block; opacity: 1; pointer-events: auto; }
.science-shell .badge-attention.stuck { color: var(--red); }
