:root {
  --bg-app: #070b14;
  --bg-panel: #0f172a;
  --bg-card: #131c31;
  --bg-input: #1e293b;
  --border-color: #26334d;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --accent-primary: #3b82f6;
  --accent-hover: #2563eb;
  --color-red: #ef4444;
  --color-cyan: #06b6d4;
  --color-amber: #f59e0b;
  --color-rose: #f43f5e;
  --color-blue: #60a5fa;
  --color-green: #10b981;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background-color: var(--bg-app);
  color: var(--text-main);
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  font-size: 13px;
}

/* Header */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 18px;
  background-color: var(--bg-panel);
  border-bottom: 1px solid var(--border-color);
  gap: 14px;
  flex-shrink: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-icon {
  font-size: 24px;
}

.brand h1 {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.subtitle {
  font-size: 11.5px;
  color: var(--text-muted);
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.preset-group {
  display: flex;
  align-items: center;
  gap: 6px;
}

.preset-group label {
  font-weight: 600;
  color: var(--text-muted);
  font-size: 12px;
}

/* Buttons & Inputs */
.btn {
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  color: var(--text-main);
  background: var(--bg-input);
}

.btn-xs {
  padding: 4px 8px;
  font-size: 11px;
}

.btn-primary {
  background: var(--accent-primary);
  border-color: #60a5fa;
}

.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-accent {
  background: rgba(16, 185, 129, 0.18);
  border-color: rgba(16, 185, 129, 0.55);
  color: #34d399;
}

.btn-accent:hover {
  background: rgba(16, 185, 129, 0.3);
}

.btn-secondary {
  background: #1e293b;
  border-color: #334155;
}

.btn-secondary:hover {
  background: #334155;
}

.btn-ghost {
  background: transparent;
  border-color: #334155;
  color: #cbd5e1;
}

.btn-ghost:hover {
  background: rgba(255, 255, 255, 0.06);
}

.btn-reset-all {
  background: rgba(239, 68, 68, 0.14);
  border-color: rgba(239, 68, 68, 0.45);
  color: #fca5a5;
}

.btn-reset-all:hover {
  background: rgba(239, 68, 68, 0.26);
  border-color: rgba(239, 68, 68, 0.7);
  color: #fecaca;
}

.btn-link {
  background: none;
  border: none;
  color: var(--color-blue);
  font-size: 11px;
  cursor: pointer;
  font-weight: 600;
}

.btn-link:hover {
  text-decoration: underline;
}

.select-input,
.text-input {
  background: var(--bg-input);
  color: var(--text-main);
  border: 1px solid #334155;
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 12px;
}

.full-width {
  width: 100%;
}

/* Main Workstation Grid */
.workstation {
  display: grid;
  grid-template-columns: 300px 1fr 345px;
  flex: 1;
  min-height: 0;
  gap: 10px;
  padding: 10px;
}

/* Full-Window Graph Focus Mode */
body.graph-fullscreen .app-header,
body.graph-fullscreen .sidebar {
  display: none !important;
}

body.graph-fullscreen .workstation {
  grid-template-columns: 1fr;
  padding: 0;
  gap: 0;
}

body.graph-fullscreen .center-stage {
  border-radius: 0;
  border: none;
}

#btn-toggle-fullscreen.active {
  background: rgba(245, 158, 11, 0.22);
  border-color: rgba(245, 158, 11, 0.75);
  color: #fde68a;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow-y: auto;
  padding-right: 2px;
}

.panel-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.card-header h2 {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 13px;
  font-weight: 700;
  color: #f1f5f9;
  white-space: nowrap;
}

.badge {
  font-size: 10.5px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 99px;
  background: #1e293b;
  color: #cbd5e1;
  border: 1px solid #334155;
  white-space: nowrap;
  flex-shrink: 0;
}

.badge-amber {
  background: rgba(245, 158, 11, 0.16);
  color: #fbbf24;
  border-color: rgba(245, 158, 11, 0.4);
}

.helper-text {
  font-size: 11.5px;
  color: var(--text-muted);
  line-height: 1.4;
}

/* Parcel Controls */
.parcel-mode-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.mode-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  background: var(--bg-input);
  color: #cbd5e1;
  border: 1px solid #334155;
  border-radius: 6px;
  padding: 6px 5px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  transition: all 0.12s;
}

.mode-btn:hover {
  border-color: #64748b;
}

.mode-btn.active {
  background: rgba(245, 158, 11, 0.18);
  color: #fbbf24;
  border-color: #f59e0b;
}

.control-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.label-row {
  display: flex;
  justify-content: space-between;
  font-size: 11.5px;
  color: #cbd5e1;
}

.mono-val {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-weight: 600;
  color: #f8fafc;
}

input[type="range"] {
  width: 100%;
  accent-color: #f59e0b;
  cursor: pointer;
}

.divider {
  border: none;
  border-top: 1px solid var(--border-color);
  margin: 2px 0;
}

.sub-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
}

.segmented-control {
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: #0b1120;
  padding: 3px;
  border-radius: 6px;
  border: 1px solid var(--border-color);
}

.seg-btn {
  background: transparent;
  color: var(--text-muted);
  border: none;
  padding: 5px 6px;
  font-size: 11px;
  font-weight: 600;
  border-radius: 4px;
  white-space: nowrap;
  cursor: pointer;
}

.seg-btn.active {
  background: #1e293b;
  color: #f8fafc;
}

.micro-hint {
  font-size: 10.5px;
  color: #94a3b8;
  background: rgba(11, 17, 32, 0.55);
  border: 1px solid rgba(51, 65, 85, 0.35);
  border-radius: 5px;
  padding: 4px 7px;
  line-height: 1.35;
}

/* Layer Toggles */
.layer-group-title {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin-top: 4px;
}

.layer-list {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.layer-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: #e2e8f0;
  cursor: pointer;
  user-select: none;
  padding: 2px 4px;
  border-radius: 4px;
  transition: background 0.12s;
}

.layer-toggle:hover {
  background: rgba(255, 255, 255, 0.04);
}

.layer-label-text {
  flex: 1;
}

.info-icon,
.info-icon-inline {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  color: #64748b;
  cursor: help;
  transition: color 0.15s;
  margin-left: 2px;
}

.layer-toggle:hover .info-icon,
.info-icon:hover,
.mode-btn:hover .info-icon-inline {
  color: #38bdf8;
}

/* Instant Floating UI Tooltip */
.ui-tooltip {
  position: fixed;
  z-index: 9999;
  max-width: 325px;
  background: rgba(15, 23, 42, 0.97);
  color: #f1f5f9;
  border: 1px solid #38bdf8;
  border-radius: 7px;
  padding: 8px 11px;
  font-size: 11.5px;
  line-height: 1.45;
  white-space: pre-line;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.65);
  pointer-events: none;
}

.layer-toggle input {
  accent-color: var(--accent-primary);
}

.swatch {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  display: inline-block;
  flex-shrink: 0;
}

/* Center Stage (Canvas) */
.center-stage {
  display: flex;
  flex-direction: column;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  overflow: hidden;
  min-width: 0;
}

.stage-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border-color);
  gap: 12px;
}

.sounding-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.meta-station {
  background: rgba(59, 130, 246, 0.2);
  color: #60a5fa;
  border: 1px solid rgba(59, 130, 246, 0.4);
  font-weight: 700;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 4px;
  white-space: nowrap;
}

.meta-desc {
  color: var(--text-muted);
  font-size: 11.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stage-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.canvas-container {
  flex: 1;
  position: relative;
  min-height: 0;
  width: 100%;
}

#stuve-canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.stage-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 6px 12px;
  background: var(--bg-panel);
  border-top: 1px solid var(--border-color);
  font-size: 11.5px;
  color: #cbd5e1;
  flex-wrap: wrap;
}

/* Right Panel Inspector & Metrics */
.inspector-grid {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 11.5px;
}

.highlight-row {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  background: #0b1120;
  padding: 6px 9px;
  border-radius: 5px;
  border: 1px solid var(--border-color);
  overflow: hidden;
}

.inspector-subhead {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-top: 2px;
}

.inspector-two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  background: rgba(15, 23, 42, 0.6);
  padding: 6px;
  border-radius: 6px;
  border: 1px solid rgba(51, 65, 85, 0.5);
}

.insp-cell {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  background: rgba(11, 17, 32, 0.65);
  border: 1px solid rgba(51, 65, 85, 0.35);
  border-radius: 5px;
  padding: 5px 7px;
  min-width: 0;
}

.insp-cell.insp-inline {
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
}

.insp-label {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 10.5px;
  font-weight: 500;
  color: var(--text-muted);
  white-space: nowrap;
}

.insp-val {
  font-size: 12px;
  font-weight: 700;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  white-space: nowrap;
}

.col-span-2 {
  grid-column: span 2;
}

.text-red { color: var(--color-red); }
.text-cyan { color: var(--color-cyan); }
.text-amber { color: var(--color-amber); }
.text-rose { color: var(--color-rose); }
.text-blue { color: var(--color-blue); }
.text-green { color: var(--color-green); }

.metrics-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
}

.metric-box {
  background: #0b1120;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 7px 9px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.metric-label {
  font-size: 10.5px;
  color: var(--text-muted);
  font-weight: 600;
}

.metric-value {
  font-size: 13px;
  font-weight: 700;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.metric-sub {
  font-size: 10.5px;
  color: #94a3b8;
}

/* Inversions & Stability Indices */
.sub-section {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.sub-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
}

.tag-list {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.inv-item {
  background: rgba(245, 158, 11, 0.12);
  border: 1px solid rgba(245, 158, 11, 0.35);
  border-radius: 6px;
  padding: 6px 8px;
  font-size: 11.5px;
  cursor: pointer;
  transition: background 0.15s;
}

.inv-item:hover {
  background: rgba(245, 158, 11, 0.22);
}

.inv-item strong {
  color: #fbbf24;
  display: block;
}

.indices-table {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px 10px;
  background: #0b1120;
  padding: 8px;
  border-radius: 6px;
  border: 1px solid var(--border-color);
  font-size: 11.5px;
}

.idx-row {
  display: flex;
  justify-content: space-between;
  padding: 2px 0;
  border-bottom: 1px solid rgba(51, 65, 85, 0.35);
}

.idx-row span {
  color: var(--text-muted);
}

/* Modals */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, 0.78);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
}

.hidden {
  display: none !important;
}

.modal-dialog {
  background: var(--bg-card);
  border: 1px solid #334155;
  border-radius: 10px;
  width: 100%;
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6);
}

.modal-lg { max-width: 760px; }
.modal-xl { max-width: 1060px; }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-color);
}

.modal-header h3 {
  font-size: 15px;
  font-weight: 700;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 22px;
  cursor: pointer;
}

.modal-body {
  padding: 16px 18px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.modal-footer {
  padding: 12px 18px;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
}

.ingest-box {
  background: #0b1120;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ingest-box h4 {
  font-size: 13px;
  color: #f1f5f9;
}

.live-fetch-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.flex-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.code-textarea {
  width: 100%;
  background: #070b14;
  color: #e2e8f0;
  border: 1px solid #334155;
  border-radius: 6px;
  padding: 10px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  line-height: 1.45;
  resize: vertical;
}

.status-msg {
  font-size: 12px;
  padding: 6px 10px;
  border-radius: 5px;
  background: rgba(59, 130, 246, 0.15);
  color: #93c5fd;
}

.status-msg.error {
  background: rgba(239, 68, 68, 0.18);
  color: #fca5a5;
}

/* Digitizer Layout */
.digitizer-layout {
  display: grid;
  grid-template-columns: 310px 1fr;
  gap: 14px;
}

.digitizer-controls {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.calib-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.calib-grid label {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 3px;
}

.calib-grid input {
  width: 100%;
}

.btn-stack {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.btn-row {
  display: flex;
  gap: 6px;
}

.digitizer-canvas-wrap {
  background: #070b14;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
  overflow: auto;
}

#digitizer-canvas {
  max-width: 100%;
  border-radius: 4px;
  cursor: crosshair;
}

/* Guide Modal */
.guide-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.guide-card {
  background: #0b1120;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 12px;
}

.guide-card h4 {
  color: #fbbf24;
  margin-bottom: 6px;
  font-size: 13px;
}

.guide-card p {
  color: #cbd5e1;
  line-height: 1.5;
  font-size: 12px;
}

/* Glossary Modal */
.glossary-toolbar {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--bg-card);
  padding-bottom: 6px;
}

.glossary-sections {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.glossary-category-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #60a5fa;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 5px;
  margin-bottom: 8px;
}

.glossary-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.glossary-item {
  background: #0b1120;
  border: 1px solid var(--border-color);
  border-radius: 7px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.glossary-item-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.glossary-term {
  font-size: 12.5px;
  font-weight: 700;
  color: #f8fafc;
}

.glossary-symbol {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  font-weight: 700;
  color: #fbbf24;
  background: rgba(245, 158, 11, 0.15);
  border: 1px solid rgba(245, 158, 11, 0.35);
  padding: 1px 6px;
  border-radius: 4px;
  white-space: nowrap;
}

.glossary-def {
  font-size: 11.5px;
  color: #cbd5e1;
  line-height: 1.45;
}

/* Guided Walkthrough Mode */
.btn-walkthrough {
  background: rgba(168, 85, 247, 0.22);
  border-color: rgba(192, 132, 252, 0.6);
  color: #e9d5ff;
}

.btn-walkthrough:hover,
.btn-walkthrough.active {
  background: rgba(168, 85, 247, 0.4);
  border-color: #c084fc;
  color: #ffffff;
}

.walkthrough-drawer {
  background: linear-gradient(180deg, #161834 0%, #0f172a 100%);
  border-bottom: 2px solid #a855f7;
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex-shrink: 0;
}

.wt-top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.wt-case-picker {
  display: flex;
  align-items: center;
  gap: 8px;
}

.wt-badge {
  font-size: 11.5px;
  font-weight: 700;
  color: #d8b4fe;
  white-space: nowrap;
}

.wt-nav {
  display: flex;
  align-items: center;
  gap: 8px;
}

.wt-step-dots {
  display: flex;
  align-items: center;
  gap: 5px;
}

.wt-dot {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1px solid #475569;
  background: #1e293b;
  color: #94a3b8;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}

.wt-dot:hover {
  border-color: #c084fc;
  color: #f8fafc;
}

.wt-dot.active {
  background: #a855f7;
  border-color: #e9d5ff;
  color: #ffffff;
}

.wt-body {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.wt-step-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.wt-step-header h3 {
  font-size: 13.5px;
  font-weight: 700;
  color: #fef08a;
}

.wt-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.wt-col {
  background: rgba(11, 17, 32, 0.72);
  border: 1px solid rgba(168, 85, 247, 0.3);
  border-radius: 6px;
  padding: 8px 10px;
}

.wt-col-label {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: #c084fc;
  margin-bottom: 3px;
}

.wt-col p {
  font-size: 11.5px;
  color: #e2e8f0;
  line-height: 1.42;
}
