/* ============================================================
   Seismic Lab — dark geoscience workspace
   ============================================================ */
:root {
  --bg: #070b12;
  --bg-2: #0a0f19;
  --panel: #0d1420;
  --panel-2: #111a29;
  --panel-3: #162133;
  --line: #1d2b40;
  --line-2: #263a55;
  --text: #dbe6f3;
  --text-2: #8fa3ba;
  --text-3: #5f7590;
  --accent: #5bd1ff;
  --accent-2: #2b9ed1;
  --warm: #ffb454;
  --danger: #ff6b6b;
  --ok: #4ade80;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 8px 26px rgba(0, 0, 0, .35);
  --font: "Segoe UI", "Inter", system-ui, -apple-system, Roboto, Arial, sans-serif;
  --mono: "Cascadia Mono", "SF Mono", Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { color-scheme: dark; }
html[data-theme="light"] { color-scheme: light; }
html, body { margin: 0; padding: 0; }
body {
  background:
    radial-gradient(1200px 600px at 18% -10%, rgba(40, 110, 170, .17), transparent 60%),
    radial-gradient(900px 500px at 100% 0%, rgba(120, 80, 200, .10), transparent 55%),
    var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.45;
  overflow: auto;
}
button, input, select { font-family: inherit; color: inherit; }
h1, h2, h3, p { margin: 0; }
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
sub, sup { font-size: .72em; }

.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  min-height: 900px;
  padding: 0 14px;
}

/* ---------------- header ---------------- */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 11px 2px 9px;
}
.brand { display: flex; align-items: center; gap: 11px; min-width: 0; }
.brand-mark { width: 40px; height: 40px; flex: none; filter: drop-shadow(0 3px 10px rgba(91, 209, 255, .18)); }
.brand-text h1 {
  font-size: 21px; font-weight: 700; letter-spacing: .2px; line-height: 1.05;
}
.brand-text h1 span { color: var(--accent); }
.brand-text p { font-size: 11px; color: var(--text-3); letter-spacing: .5px; text-transform: uppercase; margin-top: 2px; }

.header-actions { display: flex; align-items: center; gap: 8px; flex: none; }
.theme-switch {
  display: inline-flex; align-items: center; gap: 2px; flex: none;
  padding: 2px; border: 1px solid var(--line); border-radius: 7px;
  background: #0a111c;
}
.theme-switch button {
  display: inline-flex; align-items: center; gap: 4px;
  border: 0; border-radius: 5px; background: transparent;
  color: var(--text-3); font-size: 10.5px; font-weight: 600;
  padding: 4px 7px; cursor: pointer; white-space: nowrap;
}
.theme-switch button svg { width: 12px; height: 12px; }
.theme-switch button:hover { color: var(--text-2); }
.theme-switch button.active { background: #1a2a3f; color: var(--text); }
.method-pill {
  display: flex; align-items: center; gap: 7px;
  font-size: 11px; color: var(--text-2);
  border: 1px solid var(--line);
  background: rgba(13, 20, 32, .7);
  border-radius: 100px;
  padding: 6px 11px;
  white-space: nowrap;
}
.method-pill .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 8px rgba(74, 222, 128, .8); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 36px; padding: 0 14px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: transparent;
  font-size: 13px; font-weight: 600;
  cursor: pointer;
  transition: background .15s, border-color .15s, transform .1s, color .15s;
  white-space: nowrap;
  user-select: none;
}
.btn:active { transform: translateY(1px); }
.btn svg { width: 17px; height: 17px; }
.btn-primary {
  background: linear-gradient(180deg, #38b8e8, #1d8fbe);
  color: #04121c; border-color: #6adcff;
  box-shadow: 0 4px 18px rgba(45, 170, 220, .25), inset 0 1px rgba(255, 255, 255, .25);
}
.btn-primary:hover { background: linear-gradient(180deg, #5bd1ff, #2aa5d4); }
.btn-danger { background: #3a1620; border-color: #6d2837; color: #ffc3cb; }
.btn-danger:hover { background: #4a1c28; }
.btn-ghost { border-color: var(--line); background: rgba(17, 26, 41, .65); color: var(--text-2); }
.btn-ghost:hover { border-color: var(--line-2); color: var(--text); background: var(--panel-2); }
.btn-mini { height: 29px; padding: 0 9px; font-size: 12px; border-color: var(--line); background: rgba(13, 20, 32, .6); color: var(--text-2); }
.btn-mini:hover { color: var(--text); border-color: var(--line-2); }
.btn-mini:disabled { opacity: .35; cursor: default; }
.btn-mini.round { border-radius: 50%; width: 30px; padding: 0; }
.btn-block { width: 100%; margin-top: 10px; }
.icon-only { width: 36px; padding: 0; }

.export-wrap { position: relative; }
.menu {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 60;
  min-width: 205px; padding: 5px;
  background: #0f1826; border: 1px solid var(--line-2);
  border-radius: 9px; box-shadow: var(--shadow);
}
.menu button {
  display: block; width: 100%; text-align: left;
  padding: 8px 10px; border: 0; border-radius: 6px;
  background: none; font-size: 12.5px; color: var(--text-2); cursor: pointer;
}
.menu button:hover { background: var(--panel-3); color: var(--text); }

/* ---------------- statusbar ---------------- */
.statusbar {
  display: flex; align-items: center; gap: 14px;
  min-height: 33px; padding: 0 2px 7px;
  font-size: 11.5px; color: var(--text-2);
}
.status-left { display: flex; align-items: center; gap: 9px; min-width: 0; flex: 1; }
.status-left #statusText { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pill {
  flex: none; display: inline-flex; align-items: center; gap: 6px;
  height: 21px; padding: 0 9px; border-radius: 100px;
  background: #122031; border: 1px solid var(--line);
  font-size: 10.5px; font-weight: 700; letter-spacing: .55px; text-transform: uppercase;
  color: var(--text-2);
}
.pill.running { color: var(--accent); border-color: #1d5673; background: #0b2433; }
.pill.done { color: var(--ok); border-color: #1e5136; background: #0a2418; }
.pill.stale { color: var(--warm); border-color: #5a4320; background: #261d0d; }
.pill.error { color: var(--danger); border-color: #5a2530; background: #2a1016; }
.progress { width: 220px; height: 4px; border-radius: 100px; background: #142033; overflow: hidden; flex: none; }
#progressBar { width: 0%; height: 100%; border-radius: 100px; background: linear-gradient(90deg, #2b9ed1, #5bd1ff); transition: width .12s linear; }
.status-right { flex: none; font-family: var(--mono); font-size: 10.5px; color: var(--text-3); letter-spacing: .2px; }

/* ---------------- workspace ---------------- */
.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 384px;
  grid-template-rows: minmax(380px, 1fr) 372px;
  gap: 12px;
  flex: 1;
  min-height: 0;
}
.panel {
  background: linear-gradient(180deg, rgba(18, 28, 44, .72), rgba(11, 17, 27, .88));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 10px 30px rgba(0, 0, 0, .22);
  min-width: 0; min-height: 0;
  display: flex; flex-direction: column;
  overflow: hidden;
}
.model-panel { grid-column: 1; grid-row: 1; }
.results-panel { grid-column: 1; grid-row: 2; }
.sidebar { grid-column: 2; grid-row: 1 / span 2; }

.panel-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 8px 13px 7px;
  border-bottom: 1px solid rgba(29, 43, 64, .7);
  flex: none;
}
.panel-title { min-width: 0; }
.panel-title h2 { font-size: 13px; font-weight: 700; letter-spacing: .2px; }
.panel-title p { font-size: 10.5px; color: var(--text-3); margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.segmented {
  display: inline-flex; padding: 2px; gap: 2px;
  background: #0a111c; border: 1px solid var(--line);
  border-radius: 7px; flex: none;
}
.segmented button {
  border: 0; background: transparent; color: var(--text-3);
  font-size: 10.5px; font-weight: 600; padding: 4px 8px;
  border-radius: 5px; cursor: pointer; white-space: nowrap;
  display: inline-flex; align-items: center; gap: 5px;
}
.segmented button svg { width: 13px; height: 13px; }
.segmented button:hover { color: var(--text-2); }
.segmented button.active { background: #1a2a3f; color: var(--text); box-shadow: inset 0 1px rgba(255, 255, 255, .04); }

/* ---------------- model panel ---------------- */
.canvas-holder { position: relative; flex: 1; min-height: 0; overflow: hidden; }
/* Absolute fill keeps the canvas matched to the holder when the panel height
   comes from min-height (the stacked mobile layout) rather than a grid row. */
#modelCanvas, #dataCanvas { display: block; position: absolute; inset: 0; width: 100%; height: 100%; }
#modelCanvas { cursor: crosshair; touch-action: none; }
#dataCanvas { touch-action: none; }

/* Zoom / pan control pinned to each plot. Kept compact so it barely covers data. */
.zoom-tool {
  position: absolute; top: 8px; right: 8px; z-index: 20;
  display: inline-flex; align-items: center; gap: 1px;
  padding: 2px; border: 1px solid #263a55; border-radius: 7px;
  background: rgba(8, 15, 26, .88); box-shadow: 0 4px 14px rgba(0, 0, 0, .38);
  backdrop-filter: blur(6px); opacity: .92;
  transition: opacity .15s, border-color .15s;
}
.zoom-tool:hover, .zoom-tool:focus-within { opacity: 1; border-color: #385a78; }
.zoom-tool button {
  width: 24px; height: 22px; padding: 0; border: 0; border-radius: 4px;
  display: inline-flex; align-items: center; justify-content: center;
  background: transparent; color: var(--text-2);
  font-size: 14px; line-height: 1; cursor: pointer;
}
.zoom-tool button:hover:not(:disabled) { background: #1a2a3f; color: var(--text); }
.zoom-tool button:disabled { opacity: .3; cursor: default; }
.zoom-tool svg { width: 13px; height: 13px; }
.zoom-tool .zoom-level {
  min-width: 38px; padding: 0 3px; text-align: center;
  font-family: var(--mono); font-size: 9.5px; color: var(--text-2);
  font-variant-numeric: tabular-nums;
}
/* The model's surplus right margin is narrow beside the 1-D log, so stack its
   controls vertically instead of covering the log header. */
.zoom-tool.vertical { flex-direction: column; width: 30px; padding: 3px 2px; gap: 1px; }
.zoom-tool.vertical .zoom-level { min-width: 0; width: 100%; padding: 2px 0; font-size: 8.5px; }
.stale-badge {
  display: inline-flex; align-items: center; gap: 5px;
  background: rgba(45, 33, 13, .94); border: 1px solid #6a4c1d;
  color: #ffc978; font-size: 10px; font-weight: 600;
  padding: 3px 9px; border-radius: 100px; white-space: nowrap;
  flex: none;
}
.stale-badge::before {
  content: ""; width: 5px; height: 5px; border-radius: 50%;
  background: #ffb454; box-shadow: 0 0 6px rgba(255, 180, 84, .7);
}

.model-controls {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 4px 12px; border-top: 1px solid rgba(29, 43, 64, .7);
  background: rgba(9, 14, 23, .55);
  flex: none;
}
.tools button { font-size: 11px; }
.range-control { display: flex; align-items: center; gap: 7px; font-size: 10.5px; color: var(--text-3); }
.range-control input { width: 96px; }
.range-control output { font-family: var(--mono); font-size: 10px; color: var(--text-2); min-width: 40px; }
.tool-buttons { display: flex; gap: 4px; margin-left: auto; }

input[type="range"] {
  -webkit-appearance: none; appearance: none;
  height: 4px; border-radius: 100px; background: #1c2a3e; outline: none;
  accent-color: var(--accent);
  cursor: pointer;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none; width: 12px; height: 12px;
  border-radius: 50%; background: #8ee3ff; border: 2px solid #15354a;
  box-shadow: 0 0 7px rgba(91, 209, 255, .5); cursor: grab;
}
input[type="range"]::-moz-range-thumb {
  width: 11px; height: 11px; border-radius: 50%; background: #8ee3ff;
  border: 2px solid #15354a; cursor: grab;
}

.palette {
  display: flex; gap: 5px; flex-wrap: nowrap;
  padding: 4px 12px; border-top: 1px solid rgba(29, 43, 64, .55);
  overflow-x: auto; overflow-y: hidden; flex: none;
  background: rgba(9, 14, 23, .3);
  scrollbar-width: thin;
  scrollbar-color: #22344c transparent;
}
.palette::-webkit-scrollbar { height: 6px; }
.palette::-webkit-scrollbar-track { background: transparent; }
.palette::-webkit-scrollbar-thumb { background: #22344c; border-radius: 8px; }
.rock-chip {
  display: inline-flex; align-items: center; gap: 6px;
  height: 25px; padding: 0 8px 0 5px;
  border-radius: 100px; border: 1px solid var(--line);
  background: #0e1725; color: var(--text-2);
  font-size: 10.5px; font-weight: 600; cursor: pointer;
  transition: border-color .15s, color .15s, background .15s;
}
.rock-chip:hover { color: var(--text); border-color: var(--line-2); }
.rock-chip.active { border-color: #4ec4ef; color: var(--text); background: #122b3a; box-shadow: 0 0 0 1px rgba(91, 209, 255, .18); }
.rock-chip .sw { width: 12px; height: 12px; border-radius: 4px; border: 1px solid rgba(255, 255, 255, .22); flex: none; }
.rock-chip .v { font-family: var(--mono); font-size: 9px; color: var(--text-3); font-weight: 400; }

.model-foot {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  padding: 4px 12px 5px; border-top: 1px solid rgba(29, 43, 64, .6);
  flex: none; min-height: 26px; flex-wrap: wrap;
}
.legend { display: flex; gap: 9px; flex-wrap: wrap; overflow: hidden; max-height: 22px; }
.legend-item { display: inline-flex; align-items: center; gap: 4px; font-size: 9.5px; color: var(--text-3); white-space: nowrap; }
.legend-item i { width: 7px; height: 7px; border-radius: 2px; display: inline-block; }
.shot-readout { font-family: var(--mono); font-size: 9.5px; color: var(--text-3); white-space: nowrap; flex: none; }

/* ---------------- sidebar ---------------- */
.sidebar { overflow: hidden; }
.sidebar-tabs {
  display: grid; grid-template-columns: repeat(4, 1fr);
  border-bottom: 1px solid var(--line); flex: none;
  background: rgba(8, 13, 22, .6);
}
.tab-btn {
  border: 0; background: transparent; color: var(--text-3);
  font-size: 11.5px; font-weight: 600; padding: 10px 4px 9px;
  border-bottom: 2px solid transparent; cursor: pointer;
}
.tab-btn:hover { color: var(--text-2); }
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); background: rgba(30, 60, 85, .15); }
.sidebar-body { flex: 1; overflow-y: auto; padding: 12px; scrollbar-width: thin; scrollbar-color: #263a55 transparent; }
.sidebar-body::-webkit-scrollbar { width: 8px; }
.sidebar-body::-webkit-scrollbar-thumb { background: #22344c; border-radius: 8px; border: 2px solid transparent; background-clip: padding-box; }
.tab-pane { display: none; }
.tab-pane.active { display: block; animation: fade .18s ease; }
@keyframes fade { from { opacity: .4; transform: translateY(2px); } to { opacity: 1; transform: none; } }

.section-head { margin: 16px 0 8px; }
.section-head:first-child { margin-top: 2px; }
.section-head h3 { font-size: 11px; text-transform: uppercase; letter-spacing: .7px; color: var(--text-2); font-weight: 700; }
.section-head p { font-size: 10.5px; color: var(--text-3); margin-top: 3px; line-height: 1.4; }

.preset-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.preset-card {
  text-align: left; border: 1px solid var(--line); background: #0b1320;
  border-radius: 8px; padding: 7px 7px 6px; cursor: pointer;
  transition: border-color .15s, background .15s;
  min-width: 0;
}
.preset-card:hover { border-color: #2d4a68; background: #101b2b; }
.preset-card.active { border-color: #2f7d9f; background: #0f2230; box-shadow: inset 0 0 0 1px rgba(91, 209, 255, .12); }
.preset-card .name { display: block; font-size: 10.5px; font-weight: 700; color: var(--text-2); margin-bottom: 5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.preset-card.active .name { color: var(--text); }
.preset-swatch { display: flex; height: 12px; border-radius: 3px; overflow: hidden; border: 1px solid rgba(255, 255, 255, .12); background: #0a1119; }
.preset-swatch i { display: block; height: 100%; }

.layer-table { border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: #0a111c; }
.layer-row { border-bottom: 1px solid rgba(29, 43, 64, .55); padding: 7px 8px 8px; }
.layer-row:last-child { border-bottom: 0; }
.layer-row.selected { background: rgba(30, 60, 85, .12); }
.layer-top { display: flex; align-items: center; gap: 6px; }
.layer-color { width: 9px; height: 24px; border-radius: 3px; flex: none; border: 1px solid rgba(255, 255, 255, .16); }
.layer-name { flex: 1; min-width: 0; background: transparent; border: 0; padding: 2px 1px; font-size: 11.5px; font-weight: 600; color: var(--text); }
.layer-name:focus { outline: none; border-bottom: 1px solid var(--accent-2); }
.layer-rock {
  width: 118px; flex: none; height: 24px; background: #0e1928; border: 1px solid var(--line);
  border-radius: 5px; font-size: 10.5px; color: var(--text-2); padding: 0 3px;
}
.layer-del {
  width: 20px; height: 20px; flex: none; border: 0; background: transparent;
  color: var(--text-3); font-size: 14px; line-height: 1; cursor: pointer; border-radius: 4px;
}
.layer-del:hover { color: var(--danger); background: rgba(255, 107, 107, .08); }
.layer-del:disabled { opacity: .2; cursor: default; }
.layer-fields { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)) 46px; gap: 6px; align-items: end; margin-top: 6px; }
.layer-fields label, .layer-rc { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.layer-field-label {
  display: flex; align-items: baseline; gap: 3px; min-width: 0; white-space: nowrap;
  font-size: 9.5px; font-weight: 600; line-height: 1; color: #7189a4; letter-spacing: .1px;
}
.layer-field-label .field-unit { font-family: var(--mono); font-size: 8.5px; font-weight: 400; color: #55708d; letter-spacing: 0; }
.layer-fields input {
  width: 100%; min-width: 0; height: 25px; background: #0b1421; border: 1px solid #19283d;
  border-radius: 4px; padding: 0 6px; font-family: var(--mono); font-size: 10.5px; color: var(--text-2);
  appearance: textfield; -moz-appearance: textfield;
}
.layer-fields input::-webkit-outer-spin-button,
.layer-fields input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.layer-fields input:focus { outline: none; border-color: #2f6f8c; color: var(--text); }
.layer-fields input:disabled { color: var(--text-3); background: #0a1019; }
.r-badge {
  height: 25px; display: flex; align-items: center; justify-content: center;
  border-radius: 4px; font-family: var(--mono); font-size: 9.5px;
  border: 1px solid #1b2b3f; background: #0b1421; white-space: nowrap;
}
.r-badge.pos { color: #ff9b9b; border-color: #48252b; background: #1b1013; }
.r-badge.neg { color: #7fbcff; border-color: #1d344f; background: #0b1624; }
.r-badge.zero { color: var(--text-3); }

.field { display: block; margin-bottom: 9px; }
.field-label { display: flex; justify-content: space-between; align-items: baseline; font-size: 10.5px; color: var(--text-2); margin-bottom: 4px; }
.field-label output { font-family: var(--mono); font-size: 10px; color: var(--accent); }
.field-label .unit { color: var(--text-3); font-size: 9px; margin-left: 2px; }
.field input[type="number"], .field select, .field > input[type="text"] {
  width: 100%; height: 29px; background: #0a1320; border: 1px solid #1a2a40;
  border-radius: 5px; padding: 0 7px; font-family: var(--mono); font-size: 11px; color: var(--text);
}
.field select { font-family: var(--font); font-size: 11.5px; }
.field input:focus, .field select:focus { outline: none; border-color: #2f6f8c; }
.field input[type="range"] { width: 100%; }
.field-grid { display: grid; gap: 7px; }
.field-grid.two { grid-template-columns: 1fr 1fr; }
.check { display: flex; align-items: flex-start; gap: 7px; font-size: 10.5px; color: var(--text-2); margin: 7px 0; cursor: pointer; line-height: 1.35; }
.check input { margin: 1px 0 0; accent-color: var(--accent-2); width: 13px; height: 13px; flex: none; }

.engine-stats {
  margin-top: 12px; padding: 8px 9px; border-radius: 6px;
  border: 1px dashed #24374e; background: #0a1320;
  font-family: var(--mono); font-size: 9.5px; color: var(--text-3); line-height: 1.6;
}
.engine-stats b { color: var(--text-2); font-weight: 500; }

.callout {
  margin-top: 14px; padding: 9px 10px; border-radius: 7px;
  background: rgba(28, 58, 80, .18); border: 1px solid #1e3850;
  font-size: 10.5px; color: var(--text-2); line-height: 1.45;
}
.callout strong { color: var(--accent); }
.callout.subtle { background: rgba(20, 30, 45, .4); border-color: var(--line); color: var(--text-3); }
.size-warning { margin-top: 8px; font-family: var(--mono); font-size: 9.5px; line-height: 1.6; }
.size-warning b { color: var(--text-2); font-weight: 500; }
.size-warning.warn {
  background: rgba(92, 63, 16, .22); border-color: #6b4c1d; color: #e0bd7f;
}
.size-warning.warn b { color: #ffd48f; }
.size-warning.error {
  background: rgba(102, 28, 34, .22); border-color: #6e2a30; color: #f2a7a7;
}
.size-warning.error b { color: #ffbdbd; }
.button-row { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.button-row .btn { height: 31px; font-size: 11px; padding: 0 8px; }

.prose { font-size: 11px; color: var(--text-2); line-height: 1.55; }
.prose p { margin-bottom: 8px; }
.prose ul { margin: 0 0 8px; padding-left: 16px; }
.prose li { margin-bottom: 3px; color: var(--text-3); }
.prose em { color: var(--text); font-style: normal; font-weight: 600; }
.formula {
  font-family: var(--mono); font-size: 11px; color: var(--accent);
  background: #0a1723; border: 1px solid #17354a; border-radius: 5px;
  padding: 7px 9px; margin: 6px 0 10px; text-align: center; letter-spacing: .3px;
}
.rock-table { border: 1px solid var(--line); border-radius: 7px; overflow: hidden; font-size: 9.5px; }
.rock-table-row { display: grid; grid-template-columns: 1fr 52px 42px; gap: 5px; padding: 5px 8px; border-bottom: 1px solid rgba(29, 43, 64, .5); align-items: center; }
.rock-table-row:last-child { border-bottom: 0; }
.rock-table-row.head { background: #0e1826; color: var(--text-3); text-transform: uppercase; letter-spacing: .4px; font-size: 8.5px; }
.rock-table-row span:nth-child(2), .rock-table-row span:nth-child(3) { text-align: right; font-family: var(--mono); color: var(--text-2); }
.rock-table-name { display: flex; align-items: center; gap: 6px; color: var(--text-2); }
.rock-table-name i { width: 8px; height: 8px; border-radius: 2px; flex: none; }

/* ---------------- results ---------------- */
.results-panel .panel-head { padding-top: 9px; padding-bottom: 8px; }
.data-holder { background: #060a11; }
.results-foot {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 6px 12px; border-top: 1px solid rgba(29, 43, 64, .7);
  min-height: 34px; flex: none; background: rgba(9, 14, 23, .5);
}
.readout { font-size: 9.5px; color: var(--text-3); flex: 1; min-width: 160px; }
.result-legend { display: flex; gap: 10px; font-size: 9px; color: var(--text-3); flex: none; }
.result-legend span { display: inline-flex; align-items: center; gap: 4px; }
.result-legend i { width: 12px; height: 3px; border-radius: 2px; }
.playback { display: flex; align-items: center; gap: 7px; flex: none; }
.playback input { width: 150px; }
.playback span { font-size: 9.5px; color: var(--text-2); min-width: 44px; }

.empty-state {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 8px;
  color: var(--text-3); pointer-events: none;
}
.empty-state svg { width: 70px; height: 70px; stroke-width: 2; opacity: .35; }
.empty-state p { font-size: 11.5px; }

/* ---------------- tooltip ---------------- */
.tip {
  position: absolute; z-index: 40; pointer-events: none;
  background: rgba(8, 15, 26, .96); border: 1px solid #2a425c;
  border-radius: 6px; padding: 6px 8px; font-size: 10px; color: var(--text-2);
  box-shadow: 0 6px 18px rgba(0, 0, 0, .45); max-width: 230px;
  line-height: 1.45;
}
.tip b { color: var(--text); font-weight: 600; }
.tip .row { display: flex; justify-content: space-between; gap: 12px; }
.tip .row span:last-child { font-family: var(--mono); color: var(--text); }
.tip .swatch { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 4px; }

/* ---------------- modal ---------------- */
.modal {
  position: fixed; inset: 0; z-index: 100; display: flex;
  align-items: center; justify-content: center; padding: 24px;
  background: rgba(3, 7, 13, .78); backdrop-filter: blur(4px);
}
.modal-card {
  width: min(920px, 100%); max-height: 88vh; display: flex; flex-direction: column;
  background: #0c1420; border: 1px solid #293d56; border-radius: 14px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, .6); overflow: hidden;
}
.modal-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 16px;
  padding: 16px 18px 12px; border-bottom: 1px solid var(--line);
}
.modal-head h2 { font-size: 17px; }
.modal-head p { font-size: 11px; color: var(--text-3); margin-top: 2px; }
.modal-body { overflow-y: auto; padding: 16px 18px 20px; }
.help-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px 26px; }
.help-grid h3 { font-size: 12px; color: var(--accent); margin-bottom: 6px; }
.help-grid p { font-size: 11.5px; color: var(--text-2); line-height: 1.6; margin-bottom: 8px; }
.help-grid strong { color: var(--text); }
.help-more {
  display: flex; align-items: baseline; flex-wrap: wrap; gap: 6px 10px;
  margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--line);
  font-size: 9.5px; color: var(--text-3);
}
.help-theme-note {
  margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line);
  font-size: 10.5px; line-height: 1.5; color: var(--text-3);
}
.help-theme-note strong { color: var(--text-2); }
.link-btn {
  padding: 0; border: 0; background: none; color: var(--accent);
  font-size: 11px; font-weight: 700; cursor: pointer; text-align: left;
}
.link-btn:hover { color: #9ce6ff; text-decoration: underline; }
.help-keys { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); font-size: 10px; color: var(--text-3); }
kbd {
  display: inline-block; padding: 1px 5px; border-radius: 4px;
  background: #152234; border: 1px solid #2a4059; border-bottom-width: 2px;
  font-family: var(--mono); font-size: 9px; color: var(--text-2);
}

/* ---------------- glossary ---------------- */
.glossary-card { width: min(1080px, 100%); max-height: 90vh; }
.glossary-card .modal-head { padding-bottom: 13px; }
.glossary-tools {
  display: flex; flex: none; align-items: center; gap: 12px;
  padding: 10px 18px 8px;
}
.glossary-search { position: relative; flex: 1; min-width: 0; }
.glossary-search svg {
  position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
  width: 14px; height: 14px; color: var(--text-3); pointer-events: none;
}
.glossary-search input {
  width: 100%; height: 34px; border: 1px solid var(--line);
  border-radius: 7px; background: #0a121e; color: var(--text);
  padding: 0 34px 0 32px; font-size: 12px;
}
.glossary-search input::placeholder { color: #526a85; }
.glossary-search input:focus { outline: none; border-color: #2f6f8c; box-shadow: 0 0 0 2px rgba(47, 111, 140, .12); }
.glossary-search input::-webkit-search-cancel-button { -webkit-appearance: none; }
.glossary-clear {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  width: 22px; height: 22px; border: 0; border-radius: 50%;
  background: #162539; color: var(--text-3); font-size: 10px;
  display: flex; align-items: center; justify-content: center; cursor: pointer;
}
.glossary-clear:hover { color: var(--text); background: #1e3149; }
.glossary-count { flex: none; font-family: var(--mono); font-size: 9.5px; color: var(--text-3); }
.glossary-cats {
  display: flex; flex: none; flex-wrap: wrap; gap: 5px;
  padding: 0 18px 10px; border-bottom: 1px solid var(--line);
}
.glossary-chip {
  height: 23px; padding: 0 8px; border-radius: 100px;
  border: 1px solid var(--line); background: rgba(17, 26, 41, .65);
  color: var(--text-3); font-size: 9px; font-weight: 600; cursor: pointer;
  white-space: nowrap;
}
.glossary-chip:hover { color: var(--text-2); border-color: var(--line-2); }
.glossary-chip.active { color: #06121b; background: #5bd1ff; border-color: #8ae1ff; }
.glossary-chip .n { margin-left: 5px; font-family: var(--mono); font-size: 8px; opacity: .7; }
.glossary-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 0 18px 8px; }
.glossary-list { column-count: 2; column-gap: 28px; }
.glossary-item {
  break-inside: avoid; padding: 8px 0 9px;
  border-bottom: 1px solid rgba(29, 43, 64, .55);
}
.glossary-term { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 3px; }
.glossary-term strong { font-size: 11.5px; color: var(--text); line-height: 1.3; }
.glossary-cat {
  flex: none; max-width: 48%; text-align: right;
  font-size: 7px; letter-spacing: .25px; text-transform: uppercase;
  color: #53708f; line-height: 1.25;
}
.glossary-def { font-size: 10.5px; line-height: 1.48; color: var(--text-2); }
.glossary-empty {
  display: flex; flex-direction: column; align-items: center; gap: 5px;
  padding: 54px 18px; text-align: center; color: var(--text-3);
  font-size: 11px;
}
.glossary-empty strong { color: var(--text-2); font-size: 12px; }
.glossary-foot {
  display: flex; flex: none; align-items: center; justify-content: space-between; gap: 12px;
  padding: 8px 18px 9px; border-top: 1px solid var(--line);
  font-size: 9px; color: #4c627b; background: #0a111c;
}
.glossary-foot span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ============================================================
   LIGHT THEME
   The seismic plots stay dark on purpose: they are data surfaces.
   Everything around them, including dialogs and controls, follows
   the light palette.
   ============================================================ */
html[data-theme="light"] {
  color-scheme: light;
  --bg: #eef3f8;
  --bg-2: #e7eef6;
  --panel: #ffffff;
  --panel-2: #f5f8fc;
  --panel-3: #e9f0f7;
  --line: #cbd7e4;
  --line-2: #a9bdd1;
  --text: #16273a;
  --text-2: #40566d;
  --text-3: #5f748a;
  --accent: #087ca6;
  --accent-2: #0b6f96;
  --warm: #a95d00;
  --danger: #b3263a;
  --ok: #167a45;
  --shadow: 0 12px 30px rgba(35, 60, 90, .12);
}
html[data-theme="light"] body {
  background:
    radial-gradient(1200px 600px at 18% -10%, rgba(30, 120, 180, .10), transparent 60%),
    radial-gradient(900px 500px at 100% 0%, rgba(120, 90, 190, .07), transparent 55%),
    var(--bg);
}
html[data-theme="light"] .brand-mark { filter: drop-shadow(0 3px 10px rgba(30, 100, 150, .16)); }
html[data-theme="light"] .method-pill { background: rgba(255, 255, 255, .72); }
html[data-theme="light"] .theme-switch { background: #e9f0f7; }
html[data-theme="light"] .theme-switch button.active {
  background: #ffffff; color: var(--text);
  box-shadow: 0 1px 3px rgba(35, 60, 90, .14);
}
html[data-theme="light"] .btn-ghost { background: rgba(255, 255, 255, .72); }
html[data-theme="light"] .btn-mini { background: #ffffff; }
html[data-theme="light"] .btn-danger { background: #fdecee; border-color: #e5a4ad; color: #a11e31; }
html[data-theme="light"] .btn-danger:hover { background: #fbdde1; }
html[data-theme="light"] .btn-primary {
  box-shadow: 0 4px 18px rgba(30, 140, 185, .20), inset 0 1px rgba(255, 255, 255, .3);
}
html[data-theme="light"] .menu { background: #ffffff; border-color: var(--line); }
html[data-theme="light"] .pill { background: #eef4fa; }
html[data-theme="light"] .pill.running { color: #0b6f96; border-color: #9bcfe4; background: #e4f4fb; }
html[data-theme="light"] .pill.done { color: #167a45; border-color: #9bd3b3; background: #e9f7ef; }
html[data-theme="light"] .pill.stale { color: #8b5200; border-color: #e2bd7b; background: #fff4df; }
html[data-theme="light"] .pill.error { color: #a11e31; border-color: #e5a4ad; background: #fdecee; }
html[data-theme="light"] .progress { background: #dbe5ef; }
html[data-theme="light"] .panel {
  background: linear-gradient(180deg, #ffffff, #f8fbfd);
  box-shadow: 0 12px 30px rgba(35, 60, 90, .08);
}
html[data-theme="light"] .panel-head { border-bottom-color: rgba(180, 198, 216, .72); }
html[data-theme="light"] .segmented { background: #eef3f8; }
html[data-theme="light"] .segmented button.active {
  background: #ffffff; color: var(--text);
  box-shadow: 0 1px 3px rgba(35, 60, 90, .12);
}
html[data-theme="light"] .zoom-tool { background: rgba(8, 15, 26, .88); border-color: #263a55; }
html[data-theme="light"] .zoom-tool button { color: #a9bdd1; }
html[data-theme="light"] .zoom-tool button:hover:not(:disabled) { background: #1a2a3f; color: #eaf2fb; }
html[data-theme="light"] .zoom-tool .zoom-level { color: #a9bdd1; }
html[data-theme="light"] .stale-badge {
  background: #fff4df; border-color: #e2bd7b; color: #7c4b00;
}
html[data-theme="light"] .stale-badge::before { background: #c57a00; box-shadow: 0 0 6px rgba(197, 122, 0, .45); }
html[data-theme="light"] .model-controls,
html[data-theme="light"] .palette,
html[data-theme="light"] .results-foot {
  background: #f7fafd; border-color: rgba(180, 198, 216, .68);
}
html[data-theme="light"] .model-foot { border-top-color: rgba(180, 198, 216, .68); }
html[data-theme="light"] input[type="range"] { background: #d6e1ec; }
html[data-theme="light"] input[type="range"]::-webkit-slider-thumb {
  background: #2b9ed1; border-color: #ffffff; box-shadow: 0 0 0 1px #9fc8db;
}
html[data-theme="light"] input[type="range"]::-moz-range-thumb {
  background: #2b9ed1; border-color: #ffffff;
}
html[data-theme="light"] .palette { scrollbar-color: #b8c9d8 transparent; }
html[data-theme="light"] .palette::-webkit-scrollbar-thumb { background: #b8c9d8; }
html[data-theme="light"] .rock-chip { background: #ffffff; }
html[data-theme="light"] .rock-chip .sw { border-color: rgba(20, 40, 60, .22); }
html[data-theme="light"] .rock-chip.active { background: #e7f5fb; border-color: #57b5d4; }
html[data-theme="light"] .sidebar-tabs { background: #f3f7fb; border-bottom-color: var(--line); }
html[data-theme="light"] .tab-btn.active { background: #e7f3f9; }
html[data-theme="light"] .sidebar-body { scrollbar-color: #b8c9d8 transparent; }
html[data-theme="light"] .sidebar-body::-webkit-scrollbar-thumb { background: #b8c9d8; }
html[data-theme="light"] .preset-card { background: #ffffff; }
html[data-theme="light"] .preset-card:hover { background: #f6fafd; border-color: #9fb8cd; }
html[data-theme="light"] .preset-card.active { background: #eaf6fb; border-color: #5eb0ca; }
html[data-theme="light"] .preset-swatch { background: #f4f8fb; border-color: rgba(20, 40, 60, .12); }
html[data-theme="light"] .layer-table { background: #ffffff; }
html[data-theme="light"] .layer-row { border-bottom-color: rgba(180, 198, 216, .55); }
html[data-theme="light"] .layer-row.selected { background: #edf6fb; }
html[data-theme="light"] .layer-color { border-color: rgba(20, 40, 60, .18); }
html[data-theme="light"] .layer-rock { background: #ffffff; }
html[data-theme="light"] .layer-del:hover { background: #fdecee; }
html[data-theme="light"] .layer-field-label { color: #5b7188; }
html[data-theme="light"] .layer-field-label .field-unit { color: #60768c; }
html[data-theme="light"] .layer-fields input { background: #ffffff; border-color: #c3d2e0; }
html[data-theme="light"] .layer-fields input:disabled { background: #f1f5f9; }
html[data-theme="light"] .r-badge { background: #f8fbfe; border-color: #c8d7e4; }
html[data-theme="light"] .r-badge.pos { color: #a11e31; border-color: #e5b6be; background: #fdf0f2; }
html[data-theme="light"] .r-badge.neg { color: #175c9b; border-color: #b8d1e7; background: #eef6fd; }
html[data-theme="light"] .field input[type="number"],
html[data-theme="light"] .field select,
html[data-theme="light"] .field > input[type="text"] {
  background: #ffffff; border-color: #c3d2e0;
}
html[data-theme="light"] .check input { accent-color: var(--accent); }
html[data-theme="light"] .engine-stats { background: #f7fafd; border-color: #b8c9d8; }
html[data-theme="light"] .callout { background: #eef7fb; border-color: #b9dbe8; }
html[data-theme="light"] .callout.subtle { background: #f5f8fb; border-color: var(--line); }
html[data-theme="light"] .size-warning.warn { background: #fff4df; border-color: #e0b56a; color: #7a5616; }
html[data-theme="light"] .size-warning.warn b { color: #5c3f0d; }
html[data-theme="light"] .size-warning.error { background: #fdeeee; border-color: #dda0a5; color: #8a2f36; }
html[data-theme="light"] .size-warning.error b { color: #6d1f25; }
html[data-theme="light"] .formula { background: #edf7fb; border-color: #b9dbe8; }
html[data-theme="light"] .rock-table-row { border-bottom-color: rgba(180, 198, 216, .55); }
html[data-theme="light"] .rock-table-row.head { background: #f1f6fb; }
html[data-theme="light"] .empty-state { color: #7f93a8; }
html[data-theme="light"] .tip {
  background: rgba(8, 15, 26, .96); border-color: #2a425c; color: #b6c6d8;
  box-shadow: 0 8px 22px rgba(15, 30, 45, .28);
}
html[data-theme="light"] .tip b,
html[data-theme="light"] .tip .row span:last-child { color: #eaf2fb; }
html[data-theme="light"] .modal { background: rgba(30, 45, 60, .35); }
html[data-theme="light"] .modal-card {
  background: #ffffff; border-color: var(--line);
  box-shadow: 0 30px 80px rgba(25, 45, 65, .25);
}
html[data-theme="light"] .modal-head { border-bottom-color: var(--line); }
html[data-theme="light"] .link-btn:hover { color: #075f80; }
html[data-theme="light"] kbd { background: #eef3f8; border-color: #c3d2e0; }
html[data-theme="light"] .glossary-search input { background: #fbfdff; border-color: var(--line); }
html[data-theme="light"] .glossary-search input::placeholder { color: #70859a; }
html[data-theme="light"] .glossary-clear { background: #e9f0f7; }
html[data-theme="light"] .glossary-clear:hover { background: #dde8f2; }
html[data-theme="light"] .glossary-chip { background: #ffffff; }
html[data-theme="light"] .glossary-chip.active { color: #ffffff; background: var(--accent); border-color: var(--accent); }
html[data-theme="light"] .glossary-item { border-bottom-color: rgba(180, 198, 216, .55); }
html[data-theme="light"] .glossary-foot { background: #f5f9fc; color: var(--text-3); }
html[data-theme="light"] .glossary-cat { color: #5b7188; }

/* ---------------- responsive ---------------- */
@media (max-width: 1180px) {
  .workspace { grid-template-columns: minmax(0, 1fr) 340px; }
  .method-pill { display: none; }
  .status-right { display: none; }
}
@media (max-width: 1000px) {
  .brand-sub, .brand-sep { display: none; }
}
@media (max-height: 899px) and (min-width: 921px) {
  .app { height: 100vh; min-height: 0; }
  .app-header { padding: 5px 2px; }
  .brand-mark { width: 32px; height: 32px; }
  .brand-text h1 { font-size: 18px; }
  .statusbar { min-height: 27px; padding-bottom: 5px; }
  .workspace { grid-template-rows: minmax(300px, 1fr) 302px; gap: 8px; }
  .panel-head { padding: 7px 12px 6px; }
  .model-controls { padding: 3px 12px; }
  .palette { padding: 2px 12px; }
  .rock-chip { height: 22px; }
  .model-foot { padding: 2px 12px 3px; min-height: 22px; }
  .results-foot { padding: 4px 10px; min-height: 28px; }
}
@media (max-width: 920px) {
  body { overflow: auto; }
  .app { height: auto; min-height: 100vh; padding: 0 10px; }
  .workspace { display: flex; flex-direction: column; }
  #modelZoomTool { left: 8px; right: auto; }
  .model-panel { min-height: 460px; }
  .results-panel { min-height: 360px; }
  .sidebar { min-height: 520px; }
  .sidebar-body { max-height: 720px; }
  .header-actions .btn-ghost span { display: none; }
  .app-header { flex-wrap: wrap; }
  .help-grid { grid-template-columns: 1fr; }
  .progress { width: 120px; }
  .glossary-card { max-height: 94vh; }
  .glossary-list { column-count: 1; }
}
@media (max-width: 560px) {
  .brand-text p { display: none; }
  .method-pill { display: none; }
  .header-actions { width: 100%; justify-content: flex-end; flex-wrap: wrap; gap: 6px; }
  .statusbar { flex-wrap: wrap; }
  .status-text { display: none; }
  .segmented button { padding: 4px 5px; font-size: 9.5px; }
  .tool-buttons { margin-left: 0; }
  .modal { padding: 10px; }
  .glossary-tools { flex-wrap: wrap; gap: 6px; padding: 8px 12px 6px; }
  .glossary-count { width: 100%; padding-left: 2px; }
  .glossary-cats { padding: 0 12px 8px; max-height: 160px; overflow-y: auto; }
  .glossary-body { padding: 0 12px 6px; }
  .glossary-foot { padding: 7px 12px 8px; }
  .glossary-foot span:last-child { display: none; }
  .help-more { display: block; }
  .help-more span { display: block; margin-top: 4px; }
}

