/* Keep the HTML hidden attribute effective when a component uses grid or flex. */
[hidden] { display: none !important; }

:root {
  color-scheme: dark;
  --bg: #071018;
  --panel: #0b1721;
  --panel-raised: #101e29;
  --line: rgba(178, 203, 218, 0.14);
  --line-strong: rgba(178, 203, 218, 0.25);
  --text: #f8fafc;
  --muted: #cbd5e1;
  --cyan: #4fe2d0;
  --cyan-strong: #79f5e5;
  --orange: #ffb458;
  --danger: #ff7d73;
  --shadow: 0 18px 48px rgba(0, 0, 0, 0.28);
  --text-soft: #e2e8f0;
  --subtle: #b0bdcb;
  --disabled-text: #a9b8c7;
  --disabled-bg: #14222e;
  --button-hover: #142733;
  --control-bg: #07131c;
  --overlay: rgba(9, 22, 31, 0.92);
  --overlay-strong: rgba(7, 18, 27, 0.98);
  --surface-soft: rgba(15, 35, 47, 0.72);
  --surface-hover: rgba(19, 47, 58, 0.9);
  --accent-text: #d9fffb;
  --accent-soft: rgba(79, 226, 208, 0.16);
  --accent-line: rgba(79, 226, 208, 0.4);
  --range-track: #233742;
  --danger-text: #ffd7d3;
  --danger-bg: rgba(74, 24, 24, 0.94);
  --success-text: #c7fff7;
  --success-bg: rgba(12, 55, 51, 0.95);
  --viewport-bg: #000000;
  --primary-text: #06201e;
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f4f8fb;
  --panel: #ffffff;
  --panel-raised: #eaf2f7;
  --line: rgba(34, 69, 88, 0.13);
  --line-strong: rgba(34, 69, 88, 0.27);
  --text: #0f172a;
  --text-soft: #243545;
  --muted: #334155;
  --subtle: #475569;
  --disabled-text: #475569;
  --disabled-bg: #eaf0f5;
  --cyan: #076d79;
  --cyan-strong: #066c78;
  --orange: #e99329;
  --danger: #c93e35;
  --shadow: 0 12px 36px rgba(34, 69, 88, 0.12);
  --button-hover: #deedf4;
  --control-bg: #f6fafc;
  --overlay: rgba(255, 255, 255, 0.94);
  --overlay-strong: rgba(255, 255, 255, 0.98);
  --surface-soft: #f0f6fa;
  --surface-hover: #e3f0f5;
  --accent-text: #075b64;
  --accent-soft: rgba(8, 127, 140, 0.12);
  --accent-line: rgba(8, 127, 140, 0.4);
  --range-track: #cadce5;
  --danger-text: #982c24;
  --danger-bg: #fff0ed;
  --success-text: #176353;
  --success-bg: #e5f7f0;
  --viewport-bg: #ffffff;
  --primary-text: #ffffff;
}

* { box-sizing: border-box; }

html, body { width: 100%; min-width: 320px; min-height: 100%; margin: 0; }

body {
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}

button, input, select { font: inherit; }
button, select, input[type="range"], input[type="color"] { cursor: pointer; }
button:focus-visible, input:focus-visible, select:focus-visible, canvas:focus-visible, .sidebar-resizer:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 2px;
}

.app-shell { min-height: 100vh; background: var(--bg); }

.topbar {
  height: 72px;
  display: grid;
  grid-template-columns: minmax(190px, 1fr) auto minmax(max-content, 1fr);
  align-items: center;
  gap: 24px;
  padding: 0 24px;
  border-bottom: 1px solid var(--line);
  background: var(--bg);
  position: relative;
  z-index: 5;
}

.brand { display: inline-flex; width: max-content; gap: 12px; align-items: center; color: inherit; text-decoration: none; }
.brand-logo { display: block; width: 190px; height: auto; }
.header-tools { justify-self: end; display: flex; align-items: center; gap: 12px; }
.project-links { display: flex; align-items: center; gap: 16px; }
.project-links a { display: inline-flex; align-items: center; gap: 7px; min-height: 36px; border-radius: 4px; color: var(--text-soft); text-decoration: none; white-space: nowrap; font-size: 14px; font-weight: 600; }
.project-links a:hover { color: var(--cyan); text-decoration: underline; }
.project-links a:focus-visible { outline: 2px solid var(--cyan); outline-offset: 4px; }
.project-link-icon { flex: 0 0 auto; width: 18px; height: 18px; }
.project-link-external { width: 16px; height: 16px; }
.compute-theme-controls { display: flex; align-items: center; gap: 8px; }
.theme-switch { display: flex; padding: 3px; gap: 2px; border: 1px solid var(--line-strong); border-radius: 7px; background: var(--panel); }
.theme-switch button { display: flex; align-items: center; gap: 5px; min-height: 30px; padding: 0 9px; border: 0; border-radius: 4px; background: transparent; color: var(--muted); font-size: 11px; }
.theme-switch button:hover { color: var(--text); }
.theme-switch button[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent-text); }
.theme-switch button span { font-size: 15px; }
.gpu-switch { display: inline-flex; align-items: center; gap: 7px; min-height: 38px; padding: 0 9px; border: 1px solid var(--line-strong); border-radius: 7px; background: var(--panel); color: var(--muted); white-space: nowrap; font-size: 11px; }
.gpu-switch:hover { border-color: var(--cyan); color: var(--text); }
.gpu-switch[aria-pressed="true"] { border-color: var(--cyan); background: var(--accent-soft); color: var(--accent-text); }
.gpu-switch-indicator { position: relative; flex: 0 0 auto; width: 28px; height: 16px; border-radius: 999px; background: var(--line-strong); }
.gpu-switch-indicator::after { content: ""; position: absolute; top: 3px; left: 3px; width: 10px; height: 10px; border-radius: 50%; background: var(--muted); transition: transform 120ms ease, background 120ms ease; }
.gpu-switch[aria-pressed="true"] .gpu-switch-indicator { background: var(--cyan); }
.gpu-switch[aria-pressed="true"] .gpu-switch-indicator::after { transform: translateX(12px); background: var(--primary-text); }

.file-actions { display: flex; align-items: center; gap: 8px; }
.button {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  padding: 0 14px;
  background: var(--panel-raised);
  color: var(--text);
  transition: border-color 120ms ease, background 120ms ease, transform 120ms ease;
}
.button:hover:not(:disabled) { border-color: rgba(79, 226, 208, 0.55); background: var(--button-hover); }
.button:active:not(:disabled) { transform: translateY(1px); }
.button:disabled { cursor: not-allowed; color: var(--disabled-text); background: var(--disabled-bg); border-color: var(--line-strong); }
.button-primary { background: var(--cyan); color: var(--primary-text); border-color: var(--cyan); font-weight: 750; }
.button-primary:hover:not(:disabled) { background: var(--cyan-strong); border-color: var(--cyan-strong); }
.button-accent { background: var(--orange); border-color: var(--orange); color: #291708; font-weight: 750; }
.button-accent:hover:not(:disabled) { background: #ffc478; border-color: #ffc478; }
.button-large { min-height: 46px; padding: 0 22px; }

.privacy-badge { justify-self: end; display: flex; align-items: center; gap: 10px; color: var(--muted); }
.privacy-badge strong, .privacy-badge small { display: block; }
.privacy-badge strong { color: var(--text-soft); font-size: 12px; font-weight: 650; }
.privacy-badge small { font-size: 10px; margin-top: 2px; }
.privacy-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--cyan); box-shadow: 0 0 0 4px rgba(79,226,208,.1), 0 0 16px rgba(79,226,208,.5); }
@media (min-width: 921px) and (max-width: 1360px) { .privacy-badge { display: none; } }
@media (min-width: 921px) and (max-width: 1200px) {
  .compute-theme-controls { flex-direction: column; align-items: flex-end; gap: 3px; }
  .gpu-switch { min-height: 26px; }
}

.workspace { height: calc(100vh - 72px); display: grid; grid-template-columns: minmax(0, 1fr) 8px var(--sidebar-width, 342px); }
.sidebar-resizer { position: relative; z-index: 4; cursor: col-resize; touch-action: none; background: var(--panel); }
.sidebar-resizer::after { content: ""; position: absolute; top: 0; bottom: 0; left: 3px; width: 2px; background: var(--line-strong); transition: background 120ms ease; }
.sidebar-resizer:hover::after, .sidebar-resizer:focus-visible::after, .is-resizing-sidebar .sidebar-resizer::after { background: var(--cyan); }
.is-resizing-sidebar, .is-resizing-sidebar * { cursor: col-resize !important; user-select: none !important; }
.viewport-panel { position: relative; min-width: 0; overflow: hidden; background: var(--viewport-bg); }
#viewport { width: 100%; height: 100%; display: block; touch-action: none; }
.viewport-panel::before {
  content: "";
  pointer-events: none;
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 50% 44%, transparent 0, transparent 30%, rgba(0, 0, 0, 0.28) 100%);
}
:root[data-theme="light"] .viewport-panel::before { background: none; }

.empty-state { position: absolute; inset: 0; z-index: 2; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 32px; background-image: linear-gradient(rgba(79,226,208,.025) 1px, transparent 1px), linear-gradient(90deg, rgba(79,226,208,.025) 1px, transparent 1px); background-size: 48px 48px; }
.empty-state[hidden] { display: none; }
.empty-state h1 { font-family: Georgia, "Times New Roman", serif; font-size: clamp(38px, 5.3vw, 74px); line-height: .98; letter-spacing: -.04em; font-weight: 500; margin: 13px 0 20px; }
.eyebrow, .section-kicker { margin: 0; color: var(--cyan); font-size: 9px; line-height: 1.2; font-weight: 760; letter-spacing: .2em; }
.empty-copy { max-width: 510px; color: var(--muted); line-height: 1.7; margin: 0 0 24px; }
.format-note { color: var(--subtle); font-size: 11px; margin: 15px 0 0; }
.empty-logo { width: 132px; height: 132px; flex: 0 0 auto; margin-bottom: 20px; }
.empty-logo canvas, .empty-logo-fallback { display: block; width: 100%; height: 100%; object-fit: contain; }
.empty-logo [hidden] { display: none; }

.view-toolbar { position: absolute; z-index: 3; top: 18px; left: 18px; display: flex; gap: 3px; padding: 4px; border: 1px solid var(--line-strong); background: var(--overlay); backdrop-filter: blur(12px); border-radius: 8px; box-shadow: var(--shadow); }
.view-toolbar button { width: 36px; height: 34px; border: 0; border-radius: 5px; color: var(--text-soft); background: transparent; font-size: 17px; }
.view-toolbar button:hover { color: var(--cyan); background: rgba(79,226,208,.09); }
.view-toolbar span { width: 1px; margin: 6px 3px; background: var(--line-strong); }
.view-presets { position: absolute; z-index: 3; top: 18px; left: 50%; transform: translateX(-50%); display: flex; align-items: stretch; overflow: visible; border: 1px solid var(--line-strong); border-radius: 7px; background: var(--overlay); backdrop-filter: blur(12px); box-shadow: var(--shadow); }
.view-presets > button { min-width: 48px; height: 34px; padding: 0 9px; border: 0; border-right: 1px solid var(--line); color: var(--muted); background: transparent; font-size: 10px; }
.view-presets > button:hover:not(:disabled) { color: var(--cyan); background: rgba(79,226,208,.09); }
.view-presets button:disabled { cursor: not-allowed; color: var(--disabled-text); }
.projection-switch { flex: 0 0 auto; display: flex; border-left: 1px solid var(--line); }
.projection-switch button { min-width: 68px; height: 34px; padding: 0 10px; border: 0; border-right: 1px solid var(--line); color: var(--muted); background: transparent; font-size: 9px; }
.projection-switch button:last-child { min-width: 48px; }
.projection-switch button:hover:not(:disabled) { color: var(--text-soft); background: rgba(79,226,208,.07); }
.projection-switch button.active { color: var(--accent-text); background: var(--accent-soft); box-shadow: inset 0 -2px var(--cyan); }
.background-picker { position: relative; flex: 0 0 auto; border-left: 1px solid var(--line); color: var(--muted); font-size: 9px; }
.background-picker summary { height: 34px; display: flex; align-items: center; gap: 6px; padding: 0 9px; cursor: pointer; list-style: none; }
.background-picker summary::-webkit-details-marker { display: none; }
.background-picker summary i { width: 22px; height: 17px; border: 1px solid var(--line-strong); border-radius: 4px; background: var(--swatch); box-shadow: inset 0 0 0 1px rgba(255,255,255,.12); }
.background-picker[open] summary, .background-picker summary:hover { color: var(--text-soft); background: rgba(79,226,208,.07); }
.background-picker.is-disabled summary { cursor: not-allowed; color: var(--disabled-text); }
.background-menu { position: absolute; z-index: 8; top: 42px; right: -1px; width: 198px; padding: 12px; border: 1px solid var(--line-strong); border-radius: 8px; background: var(--overlay-strong); box-shadow: 0 18px 50px rgba(0,0,0,.52); }
.background-menu strong { display: block; margin-bottom: 10px; color: var(--text-soft); font-size: 10px; }
.background-swatches { display: grid; grid-template-columns: repeat(4, 1fr); gap: 7px; }
.background-swatches button { min-width: 0; width: 29px; height: 29px; padding: 0; border: 2px solid var(--line-strong); border-radius: 50%; background: var(--swatch); box-shadow: inset 0 0 0 1px rgba(255,255,255,.16); }
.background-swatches button:hover:not(:disabled) { transform: scale(1.08); border-color: var(--text-soft); }
.background-swatches button.active { border-color: var(--cyan); box-shadow: 0 0 0 2px rgba(79,226,208,.2), inset 0 0 0 1px rgba(255,255,255,.2); }
.background-custom { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 11px; padding-top: 10px; border-top: 1px solid var(--line); color: var(--muted); }
.background-custom input[type="color"] { width: 72px; height: 28px; padding: 2px; }
.viewport-toggle { min-height: 34px; flex: 0 0 auto; display: flex; align-items: center; gap: 5px; padding: 0 8px; border-left: 1px solid var(--line); color: var(--muted); font-size: 9px; cursor: pointer; }
.viewport-toggle input { width: 13px; height: 13px; margin: 0; accent-color: var(--cyan); }
.viewport-toggle:has(input:disabled) { cursor: not-allowed; color: var(--disabled-text); }
.axis-triad { position: absolute; z-index: 2; right: 18px; bottom: 17px; width: 128px; height: 128px; overflow: visible; pointer-events: none; border: 1px solid rgba(178,203,218,.2); border-radius: 50%; background: radial-gradient(circle at 42% 36%, rgba(41,63,73,.74), rgba(7,16,24,.76) 62%, rgba(2,8,12,.88)); box-shadow: inset -8px -10px 20px rgba(0,0,0,.42), inset 5px 5px 13px rgba(194,226,235,.07), 0 5px 18px rgba(0,0,0,.38); }
.axis-triad[hidden] { display: none; }
.axis-triad line { stroke-linecap: round; transition: stroke-width 100ms linear; }
.axis-triad text { font: 750 11px Inter, ui-sans-serif, sans-serif; text-anchor: middle; dominant-baseline: central; paint-order: stroke; stroke: #071018; stroke-width: 3.2px; filter: drop-shadow(0 1px 1px #000); }
.axis-triad .axis-x .axis-shaft { stroke: url(#axis-x-shaft-gradient); filter: drop-shadow(0 0 2px rgba(255,98,91,.62)); }
.axis-triad .axis-y .axis-shaft { stroke: url(#axis-y-shaft-gradient); filter: drop-shadow(0 0 2px rgba(93,224,120,.58)); }
.axis-triad .axis-z .axis-shaft { stroke: url(#axis-z-shaft-gradient); filter: drop-shadow(0 0 2px rgba(91,156,255,.62)); }
.axis-triad .axis-x text { fill: #ff746d; }
.axis-triad .axis-y text { fill: #70ea87; }
.axis-triad .axis-z text { fill: #70a9ff; }
.axis-triad .axis-x .axis-shadow, .axis-triad .axis-y .axis-shadow, .axis-triad .axis-z .axis-shadow { stroke: rgba(0,0,0,.72); filter: url(#axis-depth-shadow); }
.axis-shaft-highlight { stroke: rgba(255,255,255,.38); stroke-width: 1.15; filter: drop-shadow(0 0 1px rgba(255,255,255,.24)); }
.axis-cone { stroke: rgba(5,12,16,.72); stroke-width: .65; filter: url(#axis-depth-shadow); stroke-linejoin: round; }
.axis-x .axis-cone { fill: url(#axis-x-cone-gradient); }
.axis-y .axis-cone { fill: url(#axis-y-cone-gradient); }
.axis-z .axis-cone { fill: url(#axis-z-cone-gradient); }
.axis-cone-base { stroke: rgba(5,12,16,.72); stroke-width: .7; }
.axis-x .axis-cone-base { fill: #8f2d2e; }
.axis-y .axis-cone-base { fill: #247d3e; }
.axis-z .axis-cone-base { fill: #2b58a4; }
.axis-triad .view-aligned .axis-cone-base { fill: none; stroke-width: 2.2; filter: drop-shadow(0 0 2px currentColor); }
.axis-triad .axis-x.view-aligned { color: #ff625b; }
.axis-triad .axis-y.view-aligned { color: #5de078; }
.axis-triad .axis-z.view-aligned { color: #5b9cff; }
.axis-triad .axis-x.view-aligned .axis-cone-base { stroke: #ff625b; }
.axis-triad .axis-y.view-aligned .axis-cone-base { stroke: #5de078; }
.axis-triad .axis-z.view-aligned .axis-cone-base { stroke: #5b9cff; }
.axis-cone-highlight { stroke: rgba(255,255,255,.48); stroke-width: 1; stroke-linecap: round; filter: drop-shadow(0 0 1px rgba(255,255,255,.28)); }
.axis-origin { fill: url(#axis-origin-fill); stroke: #172831; stroke-width: 1.2; filter: url(#axis-depth-shadow); }
.axis-origin-highlight { fill: rgba(255,255,255,.82); stroke: none; }
.interaction-hint { position: absolute; z-index: 2; left: 50%; bottom: 17px; transform: translateX(-50%); color: var(--muted); font-size: 11px; background: var(--overlay); border: 1px solid var(--line); border-radius: 99px; padding: 7px 13px; opacity: 1; pointer-events: none; white-space: nowrap; transition: opacity 280ms ease; }
.interaction-hint[hidden] { display: none; }
.interaction-hint.is-hiding { opacity: 0; }

.trajectory-bar { position: absolute; z-index: 4; left: 50%; bottom: 16px; width: min(760px, calc(100% - 190px)); transform: translateX(-50%); padding: 10px 12px 8px; border: 1px solid var(--line-strong); border-radius: 9px; background: var(--overlay); backdrop-filter: blur(14px); box-shadow: var(--shadow); }
.trajectory-bar[hidden] { display: none; }
.trajectory-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 5px; color: var(--text-soft); font-size: 10px; }
.trajectory-header div { display: flex; gap: 11px; align-items: baseline; }
.trajectory-header span { color: var(--subtle); font-size: 9px; }
.trajectory-header output { color: var(--cyan); font: 700 10px var(--mono); }
.trajectory-controls { display: grid; grid-template-columns: 30px 30px 34px minmax(120px, 1fr) 30px 30px; gap: 5px; align-items: start; }
.trajectory-controls > button { width: 30px; height: 28px; padding: 0; border: 1px solid var(--line); border-radius: 5px; color: var(--text-soft); background: var(--surface-soft); font-size: 10px; }
.trajectory-controls > button:hover:not(:disabled) { color: var(--cyan); border-color: rgba(79,226,208,.42); }
.trajectory-controls > button:disabled { cursor: not-allowed; color: var(--disabled-text); background: var(--disabled-bg); }
.trajectory-controls > .frame-play { width: 34px; color: var(--accent-text); border-color: rgba(79,226,208,.34); }
.trajectory-controls > .frame-play.active { color: var(--primary-text); background: var(--cyan); border-color: var(--cyan); }
.frame-track { min-width: 0; padding: 1px 8px 0; }
.frame-track .range { margin: 6px 0 0; }
.frame-ticks { position: relative; height: 19px; margin: 1px 7px 0; color: var(--muted); font-size: 8px; }
.frame-tick { position: absolute; top: 5px; transform: translateX(-50%); white-space: nowrap; }
.frame-tick::before { content: ""; position: absolute; left: 50%; top: -6px; width: 1px; height: 4px; background: var(--subtle); }
.frame-tick:first-child { transform: none; }
.frame-tick:first-child::before { left: 0; }
.frame-tick:last-child { transform: translateX(-100%); }
.frame-tick:last-child::before { left: 100%; }
.viewport-panel.trajectory-visible .legend, .viewport-panel.trajectory-visible .axis-triad { bottom: 112px; }
.viewport-panel.trajectory-visible .interaction-hint { bottom: 108px; }

.legend { position: absolute; z-index: 3; left: 18px; bottom: 18px; min-width: 190px; max-width: 300px; border: 1px solid var(--line-strong); border-radius: 8px; padding: 12px; background: var(--overlay); backdrop-filter: blur(12px); box-shadow: var(--shadow); }
.legend[hidden] { display: none; }
.legend-property { display: grid; min-width: 0; gap: 4px; margin-bottom: 10px; color: var(--muted); font-size: 9px; }
.legend-property select { width: 100%; max-width: 100%; min-width: 0; height: 30px; padding: 0 7px; border: 1px solid var(--line-strong); border-radius: 5px; color: var(--text-soft); background: var(--control-bg); font-size: 11px; text-overflow: ellipsis; }
.legend-title { display: flex; justify-content: space-between; color: var(--text-soft); font-size: 11px; margin-bottom: 9px; }
.legend-title span { color: var(--muted); }
.legend-items { display: flex; flex-wrap: wrap; gap: 7px 12px; }
.legend-item { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 10px; }
.legend-swatch { width: 9px; height: 9px; border-radius: 50%; }
.legend-items.crystal-items { display: grid; gap: 7px; }
.crystal-items .legend-item { cursor: pointer; color: var(--text-soft); }
.crystal-items input { width: 13px; height: 13px; margin: 0; accent-color: var(--cyan); }
.crystal-items .legend-count { margin-left: auto; color: var(--muted); font-variant-numeric: tabular-nums; }
.crystal-items .is-hidden { opacity: .65; }
.legend-scale { position: relative; padding-top: 16px; cursor: crosshair; touch-action: pan-y; }
.legend-histogram { position: absolute; left: 0; right: 0; top: 0; width: 100%; height: 14px; overflow: visible; pointer-events: none; }
.legend-histogram path { fill: var(--muted); opacity: .45; }
.legend-gradient { height: 8px; border-radius: 99px; }
.legend-probe { position: absolute; top: 2px; bottom: -3px; width: 2px; margin-left: -1px; border-radius: 1px; background: var(--text-soft); box-shadow: 0 0 0 1px var(--overlay); pointer-events: none; }
.legend-probe-label { position: absolute; bottom: calc(100% + 4px); transform: translateX(-50%); padding: 3px 7px; border: 1px solid var(--line-strong); border-radius: 5px; background: var(--panel); color: var(--text-soft); font-size: 10px; font-variant-numeric: tabular-nums; white-space: nowrap; box-shadow: var(--shadow); pointer-events: none; }
.legend-probe[hidden], .legend-probe-label[hidden] { display: none; }
.legend-range { display: flex; justify-content: space-between; margin-top: 5px; color: var(--muted); font-size: 9px; }
.legend-controls { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); }
.legend-controls label { display: grid; gap: 4px; color: var(--muted); font-size: 9px; }
.legend-controls input { height: 28px; min-width: 0; padding: 0 7px; font-size: 10px; }
.legend-controls .legend-scheme { grid-column: 1 / -1; }
.legend-scheme select { height: 28px; min-width: 0; padding: 0 7px; border: 1px solid var(--line-strong); border-radius: 5px; color: var(--text-soft); background: var(--control-bg); font-size: 10px; }
.legend-controls .legend-visibility { grid-column: 1 / -1; display: flex; grid-template-columns: none; align-items: center; gap: 7px; color: var(--muted); cursor: pointer; }
.legend-visibility input { width: 13px; height: 13px; margin: 0; accent-color: var(--cyan); }
.legend-actions { grid-column: 1 / -1; display: flex; gap: 6px; }
.legend-actions button { flex: 1; height: 27px; border: 1px solid var(--line-strong); border-radius: 5px; color: var(--text-soft); background: var(--control-bg); font-size: 9px; }
.legend-actions button:hover:not(:disabled) { color: var(--cyan); border-color: var(--accent-line); }
.legend-actions .legend-auto.active { color: var(--primary-text); background: var(--cyan); border-color: var(--cyan); font-weight: 700; }
.legend-actions .legend-auto.active:hover { color: var(--primary-text); background: var(--cyan); border-color: var(--cyan); }
.legend-actions button:disabled { cursor: not-allowed; color: var(--disabled-text); background: var(--disabled-bg); }
.crystal-visibility { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
.crystal-visibility[hidden], .crystal-visibility-source[hidden], .crystal-visibility-source-name[hidden] { display: none; }
.crystal-visibility-title { display: block; margin-bottom: 9px; color: var(--text-soft); font-size: 11px; }
.crystal-visibility-source-name { margin-bottom: 7px; color: var(--muted); font-size: 10px; }
.crystal-visibility-help { margin: 0 0 9px; max-width: 260px; color: var(--muted); font-size: 10px; line-height: 1.5; }
.crystal-visibility-items { display: grid; gap: 7px; }
.crystal-visibility-item { display: flex; align-items: center; gap: 6px; color: var(--text-soft); font-size: 10px; cursor: pointer; }
.crystal-visibility-item input { flex: 0 0 auto; width: 13px; height: 13px; margin: 0; accent-color: var(--cyan); }
.crystal-visibility-item .legend-swatch { flex: 0 0 auto; }
.crystal-visibility-item.is-hidden { opacity: .55; }
.crystal-visibility-count { margin-left: auto; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.legend:has(.crystal-visibility:not([hidden])) { max-height: calc(100% - 36px); overflow-y: auto; }
.viewport-panel.trajectory-visible .legend:has(.crystal-visibility:not([hidden])) { max-height: calc(100% - 130px); }

.loading { position: absolute; z-index: 5; top: 68px; left: 50%; transform: translateX(-50%); display: flex; align-items: center; gap: 8px; max-width: calc(100% - 36px); padding: 8px 12px; border: 1px solid var(--line-strong); border-radius: 99px; background: var(--overlay); box-shadow: var(--shadow); color: var(--text-soft); font-size: 11px; white-space: nowrap; pointer-events: none; }
.loading[hidden], .toast[hidden] { display: none; }
.spinner { flex: 0 0 16px; width: 16px; height: 16px; border: 2px solid rgba(79,226,208,.18); border-top-color: var(--cyan); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(1turn); } }
.toast { position: absolute; z-index: 6; left: 50%; top: 20px; transform: translateX(-50%); max-width: min(560px, calc(100% - 40px)); border: 1px solid rgba(255,125,115,.45); border-radius: 8px; padding: 11px 14px; color: var(--danger-text); background: var(--danger-bg); box-shadow: var(--shadow); }
.toast.success { color: var(--success-text); background: var(--success-bg); border-color: var(--accent-line); }

.source-dialog { width: min(680px, calc(100vw - 32px)); max-height: min(720px, calc(100vh - 32px)); margin: auto; padding: 0; overflow: hidden; border: 1px solid var(--line-strong); border-radius: 12px; color: var(--text); background: var(--overlay-strong); box-shadow: 0 28px 90px rgba(0,0,0,.65); }
.source-dialog::backdrop { background: rgba(2,8,12,.72); backdrop-filter: blur(5px); }
.source-dialog-card { display: grid; gap: 14px; max-height: min(720px, calc(100vh - 32px)); padding: 20px; }
.source-dialog-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; }
.source-dialog-heading h2 { margin-top: 4px; font-size: 18px; }
.dialog-close { width: 30px; height: 30px; border: 1px solid var(--line); border-radius: 6px; color: var(--muted); background: transparent; font-size: 20px; line-height: 1; }
.dialog-close:hover { color: var(--text); border-color: var(--line-strong); }
.source-dialog-summary { color: var(--muted); font-size: 11px; line-height: 1.55; }
.source-options { display: grid; gap: 8px; max-height: min(520px, calc(100vh - 180px)); overflow: auto; padding-right: 3px; }
.source-option { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px 14px; width: 100%; padding: 12px 14px; text-align: left; border: 1px solid var(--line); border-radius: 8px; color: var(--text); background: var(--surface-soft); }
.source-option:hover { border-color: rgba(79,226,208,.45); background: var(--surface-hover); }
.source-option:disabled { cursor: default; color: var(--disabled-text); }
.source-option:disabled:hover { border-color: var(--line); background: var(--surface-soft); }
.source-option strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }
.source-option small { grid-column: 1 / -1; color: var(--muted); font-size: 10px; }
.source-option-kind { align-self: center; padding: 3px 6px; border: 1px solid rgba(79,226,208,.24); border-radius: 99px; color: var(--cyan); font: 700 8px/1 var(--mono); letter-spacing: .08em; text-transform: uppercase; }
.source-list-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin: 7px 2px 1px; color: var(--text); font-size: 11px; }
.source-list-heading:first-child { margin-top: 0; }
.source-list-heading small { color: var(--muted); font-size: 9px; font-weight: 400; }

.sidebar { display: flex; flex-direction: column; min-width: 0; overflow-y: auto; background: var(--panel); border-left: 1px solid var(--line); scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }
.sidebar > .side-section { flex: 0 0 auto; }
.sidebar-credits { flex: 0 0 auto; margin-top: auto; padding: 18px 22px 20px; color: var(--subtle); font-size: 11px; line-height: 1.7; }
.sidebar-credits p { margin: 0; }
.sidebar-credits p + p { margin-top: 8px; }
.sidebar-credits a { color: var(--text-soft); font-weight: 500; white-space: nowrap; text-decoration: underline; text-decoration-color: var(--line-strong); text-underline-offset: 3px; }
.sidebar-credits a:hover { color: var(--cyan); text-decoration-color: currentColor; }
.sidebar-credits a:focus-visible { outline: 2px solid var(--cyan); outline-offset: 3px; border-radius: 2px; }
.view-overlay, .legend-overlay { display: contents; }
.view-overlay[hidden], .legend-overlay[hidden] { display: none; }
.mobile-overlay-toggle { display: none; }
.atom-details-overlay { position: absolute; z-index: 4; top: 66px; right: 18px; display: flex; flex-direction: column; align-items: flex-end; gap: 8px; width: min(340px, calc(100% - 36px)); max-height: calc(100% - 180px); pointer-events: none; }
.atom-details-toggle { display: inline-flex; align-items: center; justify-content: center; gap: 6px; flex: 0 0 auto; min-height: 34px; padding: 0 12px; border: 1px solid var(--line-strong); border-radius: 7px; color: var(--text-soft); background: var(--overlay); backdrop-filter: blur(12px); box-shadow: var(--shadow); font-size: 11px; cursor: pointer; pointer-events: auto; }
.atom-details-toggle::after { content: "+"; color: var(--cyan); font-size: 15px; }
.atom-details-toggle[aria-expanded="true"]::after { content: "−"; }
.atom-details { flex: 0 1 auto; width: 100%; min-height: 0; padding: 14px; overflow-y: auto; overflow-x: hidden; overscroll-behavior: contain; touch-action: pan-y; border: 1px solid var(--line-strong); border-radius: 8px; color: var(--text); background: var(--overlay); backdrop-filter: blur(12px); box-shadow: var(--shadow); pointer-events: auto; }
.atom-details .selection-data { grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); font-size: 11px; }
.atom-details .selection-data dt { overflow-wrap: anywhere; }
.atom-details .measurement-data { display: block; }
.atom-details .measurement-data p { margin: 8px 0; overflow-wrap: anywhere; }
.tool-selector { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.tool-selector-heading, .tool-panel-toolbar { grid-column: 1 / -1; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.tool-selector-heading { margin-bottom: 5px; }
.tool-category-tabs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px; padding: 4px; margin: 12px 0 10px; border: 1px solid var(--line-strong); border-radius: 8px; background: var(--surface-soft); }
.tool-category-tabs button { min-width: 0; min-height: 42px; padding: 6px 7px; border: 1px solid transparent; border-radius: 5px; background: transparent; color: var(--muted); font-size: 11px; line-height: 1.35; cursor: pointer; touch-action: manipulation; }
.tool-category-tabs button:hover { color: var(--text); background: var(--button-hover); }
.tool-category-tabs button[aria-selected="true"] { border-color: var(--accent-line); background: var(--accent-soft); color: var(--accent-text); }
.tool-selector[data-tool-category-panel="modification"] { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.tool-selector button[data-tool-button] { position: relative; min-width: 0; min-height: 38px; padding: 7px 6px; border: 1px solid var(--line-strong); border-radius: 6px; background: var(--control-bg); color: var(--muted); font-size: 10px; cursor: pointer; }
.tool-selector button[data-tool-button]:hover { color: var(--text); background: var(--button-hover); border-color: var(--accent-line); }
.tool-selector button[data-tool-button].active { color: var(--accent-text); background: var(--accent-soft); border-color: var(--cyan); }
.tool-enabled-dot { position: absolute; top: 5px; right: 5px; width: 5px; height: 5px; border-radius: 50%; background: var(--cyan); opacity: 0; font-size: 0; }
.tool-selector button.enabled .tool-enabled-dot { opacity: 1; }
.replicate-controls { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 9px; }
.replicate-controls .field { min-width: 0; margin-top: 0; }
.replicate-controls input { min-width: 0; }
.replicate-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; margin-top: 13px; }
.side-section { padding: 21px 22px; border-bottom: 1px solid var(--line); }
.structure-summary { padding-top: 24px; background: linear-gradient(140deg, rgba(79,226,208,.055), transparent 60%); }
.filename-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-top: 11px; }
.filename-info { min-width: 0; flex: 1; }
.filename-actions { display: flex; align-items: center; gap: 7px; flex-shrink: 0; }
.close-file { display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; padding: 0; border: 1px solid var(--line-strong); border-radius: 6px; color: var(--text-soft); background: var(--surface-soft); font-size: 23px; line-height: 1; }
.close-file:hover { color: var(--cyan); border-color: var(--cyan); background: var(--surface-hover); }
.close-file[hidden] { display: none; }
.file-drop-overlay { position: fixed; inset: 12px; z-index: 100; display: flex; align-items: center; justify-content: center; border: 2px dashed var(--cyan); border-radius: 12px; background: var(--overlay); pointer-events: none; }
.file-drop-overlay[hidden] { display: none; }
.file-drop-overlay > div { padding: 24px; border: 1px solid var(--line-strong); border-radius: 10px; background: var(--overlay-strong); text-align: center; box-shadow: var(--shadow); }
.file-drop-overlay strong { display: block; color: var(--text); font-size: 18px; }
.file-drop-overlay span { display: block; margin-top: 8px; color: var(--muted); font-size: 12px; }
.filename-row h2 { max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-family: Georgia, "Times New Roman", serif; font-size: 20px; font-weight: 500; margin: 0; }
.filename-row p { color: var(--muted); font-size: 10px; margin: 5px 0 0; }
.chip { border: 1px solid rgba(79,226,208,.28); border-radius: 4px; color: var(--cyan); padding: 3px 6px; font-size: 9px; letter-spacing: .08em; }
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1px; margin-top: 18px; border: 1px solid var(--line); background: var(--line); border-radius: 7px; overflow: hidden; }
.stat-grid div { min-width: 0; padding: 10px; background: var(--control-bg); }
.stat-grid span, .stat-grid strong { display: block; overflow: hidden; text-overflow: ellipsis; }
.stat-grid span { color: var(--muted); font-size: 9px; margin-bottom: 4px; }.stat-grid strong { font-size: 12px; font-weight: 650; }

.section-heading { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; margin-bottom: 15px; }
.section-heading h3 { font-size: 14px; margin: 5px 0 0; font-weight: 650; }
.section-heading output { color: var(--muted); font-size: 11px; }
.field { display: grid; gap: 7px; margin-top: 13px; }
.field > span, .field label > span, .analysis-controls label > span { color: var(--muted); font-size: 10px; }
.range-field > span { display: flex; justify-content: space-between; }.range-field output { color: var(--cyan); }
select, input[type="number"], .slice-settings input[type="text"], .selection-groups-section input[type="text"] { width: 100%; height: 36px; border: 1px solid var(--line-strong); border-radius: 6px; background: var(--control-bg); color: var(--text-soft); padding: 0 10px; }
select:disabled, input:disabled { cursor: not-allowed; opacity: 1; }
select:disabled, input[type="number"]:disabled, .selection-groups-section input[type="text"]:disabled { color: var(--disabled-text); -webkit-text-fill-color: var(--disabled-text); background: var(--disabled-bg); }
input[type="color"] { width: 100%; height: 36px; border: 1px solid var(--line-strong); border-radius: 6px; background: var(--control-bg); padding: 4px; }
.background-custom input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
.background-custom input[type="color"]::-webkit-color-swatch { border: 0; border-radius: 3px; }
.background-custom input[type="color"]::-moz-color-swatch { border: 0; border-radius: 3px; }
.radius-field > span:first-child { display: flex; align-items: baseline; justify-content: space-between; }
.radius-field small { color: var(--subtle); font-size: 8px; font-weight: 400; }
.range-number-row { display: grid; grid-template-columns: minmax(0, 1fr) 82px; gap: 10px; align-items: center; }
.range-number-row .range { margin: 0; }
.percent-input input { height: 32px; padding-right: 24px; }
.percent-input i { top: 8px; }
.display-options { gap: 8px; }
.display-options label { display: flex; align-items: center; gap: 9px; min-height: 30px; color: var(--muted); font-size: 10px; cursor: pointer; }
.display-options input { width: 14px; height: 14px; margin: 0; accent-color: var(--cyan); }
.display-options label:has(input:disabled) { cursor: not-allowed; color: var(--disabled-text); }
.range { width: 100%; height: 4px; margin: 7px 0; appearance: none; border-radius: 99px; background: linear-gradient(90deg, var(--cyan) 0 var(--range-progress, 50%), var(--range-track) var(--range-progress, 50%) 100%); }
.range::-webkit-slider-thumb { appearance: none; width: 14px; height: 14px; border-radius: 50%; background: var(--accent-text); border: 3px solid var(--cyan); box-shadow: 0 0 0 3px rgba(79,226,208,.1); }
.range::-moz-range-thumb { width: 9px; height: 9px; border-radius: 50%; background: var(--accent-text); border: 3px solid var(--cyan); }
.inline-meta { display: flex; justify-content: space-between; color: var(--subtle); font-size: 9px; margin-top: 8px; }
.slice-row { grid-template-columns: 76px 1fr; align-items: center; margin: 0; }
.slice-list { display: grid; gap: 6px; max-height: 192px; overflow-y: auto; scrollbar-width: thin; margin-bottom: 10px; }
.slice-list:empty { display: none; }
.slice-list button { display: flex; align-items: center; gap: 8px; width: 100%; min-height: 34px; padding: 7px 10px; border: 1px solid var(--line-strong); border-radius: 6px; background: var(--control-bg); color: var(--muted); text-align: left; cursor: pointer; }
.slice-list button:hover { color: var(--text); border-color: var(--accent-line); }
.slice-list button[aria-pressed="true"] { color: var(--accent-text); background: var(--accent-soft); border-color: var(--cyan); }
.slice-list .slice-list-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11px; }
.slice-list .slice-list-state { flex: 0 0 auto; color: var(--subtle); font-size: 9px; }
.slice-list .slice-list-dot { flex: 0 0 auto; width: 6px; height: 6px; border-radius: 50%; border: 1px solid var(--subtle); }
.slice-list button.is-enabled .slice-list-dot { background: var(--cyan); border-color: var(--cyan); }
.slice-settings[hidden] { display: none; }
.slice-actions { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 14px; }
.slice-toggle { display: flex; align-items: center; gap: 7px; min-height: 30px; color: var(--muted); font-size: 10px; cursor: pointer; }
.slice-toggle input { width: 14px; height: 14px; margin: 0; accent-color: var(--cyan); }
.slice-gizmo-toggle { margin-top: 10px; }
.slice-normal-heading { display: flex; align-items: center; justify-content: space-between; gap: 8px; color: var(--muted); font-size: 10px; }
.slice-normal-presets { display: flex; gap: 4px; }
.slice-normal-presets button { width: 26px; height: 25px; padding: 0; border: 1px solid var(--line-strong); border-radius: 4px; background: var(--control-bg); color: var(--text-soft); font-size: 10px; cursor: pointer; }
.slice-normal-presets button:hover { color: var(--cyan); border-color: var(--cyan); }
.slice-normal-inputs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.slice-normal-inputs label { display: grid; gap: 5px; min-width: 0; color: var(--muted); font-size: 10px; }
.slice-normal-inputs input { min-width: 0; padding: 0 6px; }
.slice-settings input[aria-invalid="true"] { border-color: var(--danger-text); }
.configuration-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
#configuration-section .help { margin-top: 10px; }
.periodic-origin-controls .triple-fields, .slice-pick-actions { margin-top: 12px; }
.periodic-origin-actions, .slice-pick-actions, .vector-field-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.periodic-origin-actions { margin-top: 10px; }
.periodic-origin-actions .button, .slice-atom-controls .button, .vector-field-actions .button { min-width: 0; padding: 6px 8px; font-size: 10px; line-height: 1.3; }
.slice-from-atoms-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-top: 8px; }
.slice-from-atoms-actions #slice-to-atom { grid-column: 1 / -1; }
.slice-atom-controls { margin-bottom: 15px; }
.slice-pick-actions button[aria-pressed="true"] { border-color: var(--cyan); background: var(--accent-soft); color: var(--accent-text); }
.vector-field-controls { padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.vector-field-controls > .field:first-child { margin-top: 0; }
.vector-field-actions { margin-top: 8px; }
.vector-field-controls input[type="text"], .external-property-section input[type="text"] { min-width: 0; width: 100%; height: 36px; padding: 0 10px; border: 1px solid var(--line-strong); border-radius: 6px; color: var(--text-soft); background: var(--control-bg); }
.vector-field-controls input[type="text"]:disabled, .external-property-section input[type="text"]:disabled { color: var(--disabled-text); background: var(--disabled-bg); }
.external-property-list { display: grid; gap: 10px; margin-top: 14px; overflow-wrap: anywhere; }
.external-property-list:empty { display: none; }
.external-property-list .external-property-row { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; gap: 8px; }
.external-property-file-group { padding: 10px; border: 1px solid var(--line); border-radius: 6px; display: grid; gap: 8px; }
.external-property-file-group .hint { margin: 0; color: var(--muted); }
.external-property-file-group button { min-height: 36px; padding: 0 10px; border: 1px solid var(--line-strong); border-radius: 6px; background: var(--control-bg); color: var(--text-soft); cursor: pointer; }
.external-property-file-group button:hover { border-color: var(--cyan); color: var(--cyan); }
.external-property-file-group button:disabled { color: var(--disabled-text); background: var(--disabled-bg); cursor: default; }
@media (max-width: 380px) {
  .external-property-list .external-property-row { grid-template-columns: 1fr 1fr; }
  .external-property-list .external-property-row input { grid-column: 1 / -1; }
}
.external-property-list .external-property-row input { min-width: 0; }
.external-property-list .external-property-row button { min-height: 36px; }
.vector-size-fields label { min-width: 0; }
.vector-size-fields span { font-size: 10px; }
.help { color: var(--subtle); font-size: 9px; line-height: 1.5; margin: 10px 0 0; }

.analysis-controls { display: grid; grid-template-columns: 1fr 80px; gap: 9px; align-items: end; }
.analysis-state-controls { display: flex; flex-wrap: wrap; justify-content: flex-end; align-items: center; gap: 5px; }
.analysis-state-controls .text-button { font-size: 10px; }
.analysis-controls label { display: grid; gap: 7px; }
.analysis-controls label[hidden] { display: none; }
.analysis-controls:has(#run-cna) { grid-template-columns: minmax(0, 1fr) 116px; margin-top: 9px; }
.analysis-controls:has(#cna-cutoff-field[hidden]) #run-cna { grid-column: 1 / -1; }
.analysis-controls label > span:first-child { display: flex; align-items: baseline; justify-content: space-between; gap: 5px; }
.analysis-controls label small { color: var(--subtle); font-size: 8px; font-weight: 400; }
.template-options { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-top: 12px; }
.template-options label { display: flex; align-items: center; gap: 5px; color: var(--muted); font-size: 10px; cursor: pointer; }
.template-options input { width: 13px; height: 13px; margin: 0; accent-color: var(--cyan); }
.lattice-references { display: grid; gap: 12px; margin-top: 14px; }
.lattice-reference { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; padding: 10px; border: 1px solid var(--line); border-radius: 6px; }
.lattice-reference label { display: grid; gap: 5px; color: var(--muted); font-size: 10px; }
.lattice-reference label[hidden] { display: none; }
.lattice-reference select, .lattice-reference input { min-width: 0; padding: 0 6px; font-size: 11px; }
.strain-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; margin-top: 12px; }
.input-unit { position: relative; display: block; }.input-unit input { padding-right: 30px; }.input-unit i { position: absolute; right: 9px; top: 10px; color: var(--muted); font-size: 10px; font-style: normal; pointer-events: none; }
.state-pill { color: var(--muted); border: 1px solid var(--line-strong); border-radius: 99px; padding: 3px 7px; font-size: 9px; }
.state-pill.ready { color: var(--cyan); border-color: rgba(79,226,208,.33); background: rgba(79,226,208,.06); }
.text-button { border: 0; background: none; color: var(--cyan); padding: 0; font-size: 10px; }
.selection-empty { color: var(--subtle); font-size: 10px; line-height: 1.6; border: 1px dashed var(--line-strong); border-radius: 7px; padding: 13px; }
.selection-data { display: grid; grid-template-columns: auto 1fr; gap: 7px 14px; margin: 0; font-size: 10px; }
.selection-data dt { color: var(--muted); }.selection-data dd { margin: 0; color: var(--text-soft); text-align: right; word-break: break-word; }
.selection-group-list { display: grid; gap: 7px; }
.selection-group-list:empty { display: none; }
.selection-group-list button { display: grid; grid-template-columns: 12px minmax(0, 1fr) auto; align-items: center; gap: 8px; width: 100%; min-height: 42px; padding: 8px 10px; border: 1px solid var(--line-strong); border-radius: 6px; background: var(--control-bg); color: var(--text-soft); text-align: left; }
.selection-group-list button:hover:not(:disabled) { border-color: var(--cyan); background: var(--button-hover); }
.selection-group-list button[aria-pressed="true"] { border-color: var(--cyan); background: var(--accent-soft); color: var(--accent-text); }
.selection-group-swatch { width: 12px; height: 12px; border: 1px solid var(--line-strong); border-radius: 50%; background: var(--group-color); }
.selection-group-label { display: grid; gap: 3px; min-width: 0; }
.selection-group-label strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11px; font-weight: 600; }
.selection-group-label small, .selection-group-visibility { color: var(--muted); font-size: 10px; }
.selection-group-appearance { align-items: center; }
.selection-group-appearance .slice-toggle { margin-top: 14px; font-size: 10px; }
.selection-group-interaction .field { margin-top: 0; }
.selection-group-members textarea { width: 100%; min-height: 68px; resize: vertical; padding: 8px 9px; border: 1px solid var(--line-strong); border-radius: 6px; background: var(--control-bg); color: var(--text); font: inherit; font-size: 11px; }
.selection-group-members textarea:disabled { color: var(--disabled-text); background: var(--disabled-bg); }
.selection-group-member-preview { overflow-wrap: anywhere; }

.paired-fields, .paired-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
.paired-fields .field { min-width: 0; }
.paired-actions { margin-top: 12px; }
.triple-fields { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.triple-fields label { display: grid; gap: 7px; min-width: 0; color: var(--muted); font-size: 10px; }
.triple-fields input, .triple-fields select { min-width: 0; width: 100%; padding: 0 6px; }
.tool-run-button { width: 100%; margin-top: 12px; }
.tool-details { margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--line); }
.tool-details summary { color: var(--text-soft); font-size: 11px; cursor: pointer; }
.tool-details > div { margin-top: 12px; }
.export-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.export-actions button { min-width: 0; padding-inline: 8px; }
.export-series-range { margin-bottom: 10px; }
.element-style-controls, .bond-pair-cutoffs { display: grid; gap: 8px; }
.element-style-controls:empty, .bond-pair-cutoffs:empty { display: none; }
.element-style-row { display: grid; grid-template-columns: minmax(30px, 1fr) 36px minmax(52px, 1fr) 16px auto; align-items: center; gap: 7px; color: var(--muted); font-size: 10px; }
.element-style-row input, .bond-pair-cutoffs input { min-width: 0; width: 100%; padding-inline: 6px; }
.element-style-row input[type="checkbox"] { width: 14px; height: 14px; min-height: 0; margin: 0; accent-color: var(--cyan); }
.element-style-row input[type="color"], .paired-fields input[type="color"] { padding: 3px; cursor: pointer; }
.bond-pair-cutoff-row { display: grid; grid-template-columns: minmax(70px, 1fr) minmax(70px, 1fr); gap: 9px; align-items: center; color: var(--muted); font-size: 10px; }
.statistics-subheading { margin-top: 24px; }
.statistics-chart { margin-top: 12px; color: var(--muted); font-size: 10px; }
.statistics-chart:empty { display: none; }
.statistics-chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.statistics-chart .chart-axis { stroke: var(--line-strong); }
.statistics-chart .chart-line { stroke: var(--cyan); fill: none; stroke-width: 2; }
.statistics-chart .chart-bar { fill: var(--cyan); }
.statistics-chart text { fill: var(--muted); font-family: inherit; }
.statistics-chart table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.statistics-chart td { padding: 6px; border-bottom: 1px solid var(--line); text-align: right; }
.statistics-chart td:first-child { text-align: left; }
.advanced-analysis-heading { align-items: center; margin: 0; }
.advanced-analysis-heading h3 { margin-top: 0; }
.bond-statistics-section .paired-fields .field, .voronoi-face-filter-controls .field { min-width: 0; }
.analysis-backend-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 12px; color: var(--muted); font-size: 10px; }
.analysis-backend-row output { text-align: right; color: var(--text-soft); }
.analysis-progress { display: block; width: 100%; height: 6px; margin: 10px 0; border: 0; border-radius: 99px; overflow: hidden; accent-color: var(--cyan); background: var(--range-track); }
.analysis-progress::-webkit-progress-bar { border-radius: 99px; background: var(--range-track); }
.analysis-progress::-webkit-progress-value { border-radius: 99px; background: var(--cyan); }
.analysis-progress::-moz-progress-bar { border-radius: 99px; background: var(--cyan); }
.analysis-statistics-results { min-width: 0; margin-top: 16px; }
.statistics-result-heading { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 18px; }
.statistics-result-heading h4 { min-width: 0; margin: 0; color: var(--text-soft); font-size: 11px; font-weight: 650; }
.statistics-export-button { flex: 0 0 auto; min-height: 30px; padding: 4px 8px; font-size: 10px; }
.statistics-export-actions { margin-top: 12px; }
.statistics-export-actions .button { min-width: 0; padding: 7px 8px; font-size: 10px; }
.statistics-csv-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.statistics-csv-actions .button { min-width: 0; padding: 7px 8px; font-size: 10px; line-height: 1.35; }
.statistics-csv-all-atoms { grid-column: 1 / -1; }
.analysis-statistics-results .statistics-chart { max-width: 100%; overflow-x: auto; scrollbar-width: thin; }
.analysis-statistics-results .statistics-chart table { font-size: 10px; }
.statistics-chart th { padding: 6px; border-bottom: 1px solid var(--line-strong); color: var(--text-soft); font-size: 9px; font-weight: 650; text-align: right; }
.statistics-chart th:first-child { text-align: left; }
.statistics-chart caption { margin-bottom: 8px; color: var(--muted); font-size: 10px; text-align: left; }
.distribution-values { max-width: 100%; margin-top: 5px; overflow-x: auto; }
.distribution-values > summary { padding: 7px 0; color: var(--text-soft); font-size: 10px; cursor: pointer; }
.statistics-population-controls { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 10px; }
.statistics-population-controls .button { min-height: 32px; padding: 0 8px; font-size: 10px; }
.statistics-population-controls > span { color: var(--muted); font-size: 10px; }
.voronoi-stat-cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin: 12px 0; }
.voronoi-stat-card { display: flex; flex-direction: column; min-width: 0; gap: 5px; padding: 10px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface-soft); font-variant-numeric: tabular-nums; }
.voronoi-stat-label { color: var(--muted); font-size: 10px; }
.voronoi-stat-card strong { color: var(--text-soft); font-size: 13px; font-weight: 650; overflow-wrap: anywhere; }
.voronoi-stat-detail { color: var(--muted); font-size: 9px; line-height: 1.45; overflow-wrap: anywhere; }
.voronoi-color-quantities > p { margin: 14px 0 7px; }
.voronoi-color-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; }
.voronoi-color-actions .button { min-width: 0; min-height: 34px; padding: 6px; font-size: 10px; line-height: 1.4; }
.voronoi-color-actions .button:last-child { grid-column: 1 / -1; }
.voronoi-topology-populations { margin: 10px 0; }
.voronoi-topology-row + .voronoi-topology-row { margin-top: 10px; }
.voronoi-topology-heading { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 10px; color: var(--muted); font-size: 10px; font-variant-numeric: tabular-nums; }
.voronoi-topology-index { color: var(--text-soft); overflow-wrap: anywhere; }
.voronoi-topology-track { height: 5px; margin-top: 5px; overflow: hidden; border-radius: 99px; background: var(--range-track); }
.voronoi-topology-track > span { display: block; height: 100%; border-radius: inherit; background: var(--cyan); }
.chart-modes { display: flex; align-items: center; gap: 6px; margin-bottom: 6px; }
.chart-modes .button { min-height: 30px; padding: 4px 9px; font-size: 10px; }
.chart-modes .button[aria-pressed="true"] { color: var(--accent-text); background: var(--accent-soft); border-color: var(--cyan); }
.statistics-chart .chart-highlight, .statistics-chart .chart-crosshair { stroke: var(--text-soft); stroke-width: 1; vector-effect: non-scaling-stroke; pointer-events: none; }
.statistics-chart .chart-grid { stroke: var(--line); stroke-width: 1; vector-effect: non-scaling-stroke; }
.statistics-chart .chart-reference { stroke: var(--line-strong); stroke-width: 1; stroke-dasharray: 3 3; vector-effect: non-scaling-stroke; }
.statistics-chart .chart-marker { fill: var(--cyan); stroke: var(--panel); stroke-width: 1.5; pointer-events: none; }
.chart-inspect-control { display: flex; align-items: center; gap: 10px; margin: 3px 0 7px; color: var(--muted); font-size: 10px; }
.chart-inspect-control > span { flex-shrink: 0; }
.chart-inspect-slider { min-width: 0; flex: 1; accent-color: var(--cyan); }
.chart-readout { display: block; min-height: 28px; color: var(--text-soft); font-size: 10px; line-height: 1.6; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
#voronoi-cell-status { display: block; }
#voronoi-cell-display .paired-fields .field { min-width: 0; }
@media (max-width: 920px) {
  .statistics-export-button { min-height: 38px; }
  .statistics-population-controls .button { min-height: 38px; }
  .bond-statistics-section .tool-run-button, .voronoi-section .tool-run-button, .statistics-export-actions .button, .statistics-csv-actions .button { min-height: 42px; }
  .voronoi-color-actions .button, .chart-modes .button { min-height: 38px; }
  .chart-inspect-slider { min-height: 32px; }
}
.atom-search-row { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: end; gap: 7px; margin-bottom: 15px; }
.atom-search-row .field { min-width: 0; margin: 0; }
.atom-search-row button { padding-inline: 10px; }
.measurement-controls { margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--line); }
.measurement-data { margin: 12px 0; }
.comparison-view { position: absolute; z-index: 3; display: grid; grid-template-rows: auto auto minmax(0, 1fr); top: 56px; left: 12px; width: 42%; height: 42%; overflow: hidden; border: 1px solid var(--line-strong); border-radius: 8px; background: var(--panel); box-shadow: var(--shadow); }
.comparison-view:focus-within, .comparison-view.is-interacting { z-index: 6; }
.comparison-header { display: flex; align-items: center; justify-content: space-between; gap: 6px; min-width: 0; min-height: 34px; padding: 4px 6px 4px 9px; color: var(--text-soft); background: var(--overlay); border-bottom: 1px solid var(--line); cursor: grab; user-select: none; touch-action: none; }
.comparison-header:focus-visible, .comparison-resize:focus-visible { outline: 2px solid var(--cyan); outline-offset: -2px; }
.comparison-header strong { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11px; }
.comparison-actions { display: flex; align-items: center; flex: 0 0 auto; gap: 3px; }
.comparison-actions button { min-height: 25px; padding: 0 6px; border: 1px solid var(--line-strong); border-radius: 4px; background: var(--panel); color: var(--text-soft); font-size: 10px; cursor: pointer; }
.comparison-actions button:hover { background: var(--accent-soft); color: var(--accent-text); }
.comparison-surface { position: relative; min-width: 0; min-height: 0; overflow: hidden; }
.comparison-view canvas { display: block; width: 100%; height: 100%; touch-action: none; }
.comparison-view .comparison-label { position: absolute; left: 8px; bottom: 8px; z-index: 1; padding: 3px 6px; border-radius: 4px; background: var(--overlay); color: var(--text-soft); font-size: 10px; pointer-events: none; }
.comparison-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 2px; min-width: 0; padding: 3px; border-bottom: 1px solid var(--line-strong); background: var(--overlay); backdrop-filter: blur(12px); }
.comparison-toolbar button { min-height: 25px; padding: 0 7px; border: 0; border-radius: 3px; background: transparent; color: var(--text-soft); font-size: 10px; }
.comparison-toolbar button:hover, .comparison-toolbar button[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent-text); }
.comparison-view .comparison-close { width: 25px; padding: 0; font-size: 17px; line-height: 1; }
.comparison-resize { position: absolute; right: 1px; bottom: 1px; z-index: 2; width: 24px; height: 24px; min-height: 0; padding: 0; border: 0; border-radius: 3px; color: var(--text-soft); background: var(--overlay); cursor: nwse-resize; touch-action: none; user-select: none; font-size: 19px; line-height: 1; }

@media (max-width: 920px) {
  .comparison-toolbar { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: thin; }
  .comparison-toolbar button { flex: 0 0 auto; min-height: 30px; }
  .comparison-header { min-height: 36px; }
  .comparison-actions button { min-height: 29px; }
  .comparison-resize { width: 30px; height: 30px; }
  .element-style-row input, .bond-pair-cutoff-row input { min-height: 36px; }
  .selection-group-list button, .selection-groups-section .paired-actions button, .selection-groups-section .tool-run-button { min-height: 42px; }
  .selection-groups-section input, .selection-groups-section select { min-height: 36px; }
  .selection-groups-section .slice-toggle input { min-height: 0; width: 17px; height: 17px; }
  .selection-groups-section #add-selection-group { min-height: 38px; }
}

.performance-section details summary { display: flex; justify-content: space-between; cursor: pointer; list-style: none; color: var(--muted); font-size: 11px; }
.performance-section summary::-webkit-details-marker { display: none; }
.performance-section summary .section-kicker { display: block; margin-bottom: 5px; }
.perf-list { display: grid; gap: 8px; margin: 16px 0 0; }
.perf-list div { display: flex; justify-content: space-between; font-size: 10px; }.perf-list dt { color: var(--muted); }.perf-list dd { margin: 0; color: var(--text-soft); }

@media (max-width: 920px) {
  html, body { height: 100%; min-height: 0; overflow: hidden; overscroll-behavior: none; }
  .app-shell { height: 100vh; height: 100dvh; min-height: 0; display: flex; flex-direction: column; overflow: hidden; }
  .topbar { flex: 0 0 auto; grid-template-columns: minmax(0, 1fr) auto; height: auto; min-height: 0; gap: 8px 14px; padding: 10px 16px; }
  .file-actions { grid-column: 1 / -1; grid-row: 2; overflow-x: auto; padding-bottom: 0; }
  .privacy-badge { display: none; }
  .header-tools { display: contents; }
  .compute-theme-controls { display: contents; }
  .theme-switch { grid-column: 2; grid-row: 1; justify-self: end; }
  .gpu-switch { grid-column: 1; grid-row: 3; justify-self: start; min-height: 30px; }
  .gpu-switch-prefix { display: none; }
  .file-actions { grid-column: 1 / -1; width: max-content; max-width: calc(100% - 200px); }
  .project-links { grid-column: 2; grid-row: 2; justify-self: end; }
  .project-links { gap: 8px; }
  .project-links a { font-size: 12px; }
  .project-link-icon { width: 16px; height: 16px; }
  .project-link-external { width: 14px; height: 14px; }
  .workspace { flex: 1 1 0; height: auto; min-height: 0; grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 56fr) minmax(0, 44fr); }
  .viewport-panel { min-height: 0; }
  .atom-details-overlay { top: 60px; right: auto; left: 12px; width: min(340px, calc(100% - 24px)); max-height: calc(100% - 120px); align-items: flex-start; }
  .viewport-panel.trajectory-visible .atom-details-overlay { max-height: calc(100% - 216px); }
  .sidebar { min-height: 0; overflow-y: auto; overflow-x: hidden; border-left: 0; border-top: 1px solid var(--line); overscroll-behavior: contain; touch-action: pan-y; -webkit-overflow-scrolling: touch; padding-bottom: env(safe-area-inset-bottom, 0px); }
  .sidebar-resizer { display: none; }
  .sidebar-credits { padding-right: 16px; padding-left: 16px; }
  .interaction-hint { display: none; }
  .view-toolbar { top: 12px; left: 12px; }
  .view-overlay { position: absolute; z-index: 4; top: 12px; right: 12px; bottom: 12px; display: flex; flex-direction: column; align-items: flex-end; gap: 8px; width: min(340px, calc(100% - 24px)); pointer-events: none; }
  .mobile-overlay-toggle { display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto; gap: 6px; min-height: 38px; padding: 0 12px; border: 1px solid var(--line-strong); border-radius: 7px; color: var(--text-soft); background: var(--overlay); backdrop-filter: blur(12px); box-shadow: var(--shadow); font-size: 11px; pointer-events: auto; }
  .mobile-overlay-toggle::after { content: "+"; color: var(--cyan); font-size: 15px; }
  .mobile-overlay-toggle[aria-expanded="true"]::after { content: "−"; }
  .view-presets { position: static; display: none; flex: 0 1 auto; grid-template-columns: repeat(3, minmax(0, 1fr)); width: 100%; min-height: 0; max-width: none; transform: none; overflow-y: auto; overflow-x: hidden; pointer-events: auto; overscroll-behavior: contain; }
  .view-overlay.is-expanded .view-presets { display: grid; }
  .view-presets > button { min-width: 0; height: 38px; border-bottom: 1px solid var(--line); }
  .projection-switch { grid-column: 1 / -1; border-left: 0; }
  .projection-switch button { flex: 1; min-width: 0; height: 38px; border-bottom: 1px solid var(--line); }
  .projection-switch button:last-child { min-width: 0; border-right: 0; }
  .background-picker { grid-column: 1 / 3; border-left: 0; }
  .background-picker summary { height: 38px; }
  .background-menu { position: static; width: 100%; border-radius: 0; border-left: 0; border-bottom: 0; box-shadow: none; }
  .viewport-toggle { align-self: start; min-height: 38px; }
  .legend-overlay { position: absolute; z-index: 3; left: 12px; bottom: 12px; display: flex; flex-direction: column-reverse; align-items: flex-start; gap: 8px; max-width: min(300px, calc(100% - 24px)); max-height: calc(100% - 72px); pointer-events: none; }
  .legend-overlay .legend { position: static; display: none; flex: 0 1 auto; min-height: 0; min-width: min(190px, calc(100vw - 24px)); max-width: 100%; overflow-y: auto; pointer-events: auto; overscroll-behavior: contain; }
  .legend-overlay.is-expanded .legend { display: block; }
  .legend-overlay .legend[hidden], .view-overlay[hidden], .legend-overlay[hidden] { display: none; }
  .legend-items.crystal-items { gap: 3px; }
  .crystal-items .legend-item { min-height: 30px; font-size: 11px; }
  .crystal-items input { width: 16px; height: 16px; }
  .crystal-visibility-items { gap: 3px; }
  .crystal-visibility-item { min-height: 30px; font-size: 11px; }
  .crystal-visibility-item input { width: 16px; height: 16px; }
  .legend-controls input, .legend-scheme select, .legend-property select { height: 34px; }
  .tool-selector button[data-tool-button] { min-height: 42px; font-size: 11px; }
  .structure-summary { padding: 12px 16px; }
  .structure-summary .filename-row { margin-top: 5px; gap: 8px; }
  .structure-summary .filename-row h2 { font-size: 16px; }
  .structure-summary .filename-row p { margin-top: 3px; font-size: 9px; }
  .structure-summary .stat-grid { margin-top: 10px; }
  .structure-summary .stat-grid div { padding: 6px 8px; }
  .structure-summary .stat-grid strong { font-size: 11px; }
  .tool-section { padding: 14px 16px; }
  .tool-section .section-heading { margin-bottom: 10px; }
  .tool-section .section-heading h3 { display: none; }
  .trajectory-bar { width: calc(100% - 24px); }
  .axis-triad { right: 12px; bottom: 12px; width: 80px; height: 80px; }
  .viewport-panel.trajectory-visible .legend-overlay { bottom: 108px; max-height: calc(100% - 168px); }
  .viewport-panel.trajectory-visible .axis-triad { bottom: 108px; }
  .empty-state { padding: 18px 20px; }
  .empty-logo { width: 80px; height: 80px; margin-bottom: 10px; }
  .empty-state h1 { margin: 9px 0 12px; font-size: 38px; }
  .empty-copy { max-width: 480px; font-size: 11px; line-height: 1.5; margin-bottom: 16px; }
  .format-note { margin-top: 10px; font-size: 10px; }
}

@media (min-width: 361px) and (max-width: 920px) {
  .tool-selector { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .tool-selector button[data-tool-button] { font-size: 10px; }
}

@media (min-width: 521px) and (max-width: 920px) {
  .compute-theme-controls { display: flex; grid-column: 2; grid-row: 1; gap: 8px; }
}

@media (max-width: 520px) {
  .brand-logo { width: 155px; }
  .theme-switch button { padding: 0 6px; font-size: 10px; }
  .gpu-switch { padding: 0 7px; font-size: 10px; }
  .file-actions .button { white-space: nowrap; }
  .file-actions { max-width: 100%; }
  .project-links { grid-column: 2; grid-row: 3; justify-self: end; }
  .trajectory-bar { bottom: 8px; width: calc(100% - 16px); }
  .trajectory-controls { grid-template-columns: 27px 27px 29px minmax(80px, 1fr) 27px 27px; gap: 3px; }
  .trajectory-controls > button { width: 27px; }
  .trajectory-controls > .frame-play { width: 29px; }
  .viewport-panel.trajectory-visible .axis-triad { bottom: 108px; }
}

@media (max-width: 360px) {
  .project-links { gap: 6px; }
  .project-links a { font-size: 11px; }
}

@media (max-width: 920px) and (max-height: 520px) {
  .topbar { grid-template-columns: minmax(0, 1fr) auto auto; gap: 10px; padding: 7px 12px; }
  .brand-logo { width: 120px; }
  .file-actions { grid-column: auto; grid-row: auto; width: auto; max-width: none; }
  .header-tools { display: flex; gap: 9px; }
  .compute-theme-controls { display: flex; gap: 6px; }
  .theme-switch, .project-links { grid-column: auto; grid-row: auto; }
  .file-actions .button { min-height: 34px; padding: 0 10px; font-size: 11px; }
  .theme-switch button { font-size: 0; }
  .theme-switch button span { font-size: 15px; }
  .workspace { grid-template-rows: minmax(0, 60fr) minmax(0, 40fr); }
  .empty-logo, .empty-copy, .format-note { display: none; }
  .empty-state h1 { font-size: 30px; margin-bottom: 14px; }
  .empty-state .button-large { min-height: 38px; padding: 0 16px; font-size: 12px; }
}

@media (max-width: 640px) and (max-height: 520px) {
  .compute-theme-controls { flex-direction: column; align-items: flex-end; gap: 2px; }
  .project-links a span { display: none; }
  .project-links a { min-width: 24px; justify-content: center; }
}

@media (max-width: 920px) and (max-height: 700px) {
  .atom-details-overlay,
  .viewport-panel.trajectory-visible .atom-details-overlay { max-height: calc(100% - 72px); }
  .atom-details-overlay.is-expanded { z-index: 5; }
  .viewport-panel:has(.atom-details-overlay.is-expanded) .legend-overlay {
    top: 12px;
    bottom: auto;
    flex-direction: column;
    max-height: calc(100% - 72px);
  }
}

.legend-category-actions { display: flex; gap: 7px; margin-bottom: 10px; }
.legend-category-actions button { flex: 1; min-height: 28px; padding: 4px 8px; border: 1px solid var(--line-strong); border-radius: 5px; background: var(--panel-raised); color: var(--text-soft); font: inherit; font-size: 10px; cursor: pointer; }
.legend-category-actions button:hover { border-color: var(--cyan); color: var(--cyan); }
@media (max-width: 920px) {
  .legend-category-actions button { min-height: 34px; font-size: 11px; }
}
