﻿:root {
  --bg: #fbf4e7;
  --panel: #fffaf0;
  --ink: #17201d;
  --muted: #4d5953;
  --line: #d9cfbd;
  --sky: #bdf3ed;
  --layer-1: #8bc79a;
  --layer-2: #6fac70;
  --layer-3: #9b7a61;
  --red: #6d1d17;
  --magenta: #8d3a31;
  --blue: #355f65;
  --accent: #6d1d17;
  --accent-dark: #43130f;
  --shadow: 0 18px 45px rgba(55, 45, 30, 0.12);
  --radius: 8px;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: linear-gradient(180deg, rgba(109, 29, 23, 0.08), rgba(251, 244, 231, 0) 340px), var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
.app-shell { width: min(1520px, 100%); margin: 0 auto; padding: 22px; }
.app-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.app-hero { background: linear-gradient(135deg, rgba(109, 29, 23, 0.10), rgba(109, 29, 23, 0) 48%), #fffdf8; border: 1px solid var(--line); border-top: 6px solid var(--accent); border-radius: var(--radius); box-shadow: var(--shadow); padding: clamp(1.5rem, 4vw, 2.3rem) clamp(1.2rem, 4vw, 2.25rem); }
.eyebrow { margin: 0 0 .55rem; color: var(--accent-dark); font-size: .78rem; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; }
h1, h2 { margin: 0; letter-spacing: 0; }
h1 { font-size: clamp(1.85rem, 4vw, 3.2rem); line-height: 1.02; }
h2 { font-size: 1rem; }
.header-actions, .data-actions { display: flex; align-items: center; gap: 8px; }
.command-button {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--ink);
  padding: 0 13px;
  box-shadow: 0 7px 20px rgba(24,37,33,.08);
  font-size: .9rem;
  font-weight: 850;
}
.command-button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.workspace { display: grid; grid-template-columns: minmax(0, 1fr) 370px; gap: 18px; align-items: start; }
.visual-stack { display: grid; gap: 18px; min-width: 0; }
.panel, .controls-panel, .data-panel { border: 1px solid var(--line); border-radius: var(--radius); background: rgba(255,250,240,.94); box-shadow: var(--shadow); }
.panel { overflow: hidden; }
.panel-header { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 15px 16px 12px; border-bottom: 1px solid var(--line); }
.readout-pill { min-width: max-content; border: 1px solid var(--line); border-radius: 999px; padding: 6px 10px; color: var(--accent-dark); background: #fffdf8; font-size: .82rem; font-weight: 800; }
canvas { display: block; width: 100%; touch-action: none; }
#modelCanvas { height: clamp(290px, 31vw, 390px); }
#plotCanvas { height: clamp(430px, 44vw, 610px); }
.controls-panel { position: sticky; top: 16px; display: grid; gap: 15px; padding: 16px; }
.control-group { display: grid; gap: 13px; padding-bottom: 15px; border-bottom: 1px solid var(--line); }
.group-title { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.group-title span { color: var(--muted); font-size: .78rem; font-weight: 800; text-transform: uppercase; }
.range-control, .select-control { display: grid; gap: 8px; }
.range-control > span, .select-control > span { display: flex; justify-content: space-between; gap: 12px; color: #36413d; font-size: .9rem; font-weight: 750; }
output { color: var(--accent-dark); font-variant-numeric: tabular-nums; }
input[type="range"] { width: 100%; accent-color: var(--accent); }
select, textarea { width: 100%; border: 1px solid var(--line); border-radius: var(--radius); background: #fffdf8; color: var(--ink); }
select { min-height: 40px; padding: 0 10px; }
.stats-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.stats-grid div { min-width: 0; border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; background: #fffdf8; }
.stats-grid span, .stats-grid strong { display: block; overflow-wrap: anywhere; }
.stats-grid span { margin-bottom: 3px; color: var(--muted); font-size: .74rem; font-weight: 800; text-transform: uppercase; }
.stats-grid strong { color: var(--ink); font-size: .96rem; font-variant-numeric: tabular-nums; }
.data-panel { display: grid; gap: 10px; padding: 14px; box-shadow: none; }
textarea { min-height: 230px; resize: vertical; padding: 10px; font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace; font-size: .86rem; line-height: 1.38; }
.data-actions { justify-content: flex-end; }
.data-status { min-height: 1.2em; margin: 0; color: var(--muted); font-size: .84rem; }
@media (max-width: 1060px) {
  .workspace { grid-template-columns: 1fr; }
  .controls-panel { position: static; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }
  .data-panel, .stats-grid { grid-column: 1 / -1; }
  .stats-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
  .app-shell { padding: 14px; }
  .app-header, .panel-header { align-items: flex-start; }
  .app-header { gap: 10px; }
  .panel-header { flex-direction: column; }
  .controls-panel { grid-template-columns: 1fr; padding: 14px; }
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  #modelCanvas { height: 320px; }
  #plotCanvas { height: 500px; }
}
@media print {
  body { background: #fff; }
  .app-shell { padding: 0; }
  .controls-panel, .header-actions { display: none; }
  .workspace { display: block; }
  .panel { margin-bottom: 12px; box-shadow: none; break-inside: avoid; }
}
