:root {
  --azul: #1a3a6b;
  --laranja: #fb923c;
  --amarelo: #facc15;
  --verde: #22c55e;
  --vermelho: #ef4444;
  --gold: #b5860d;

  --bg: #f5f4f0;
  --card: #ffffff;
  --surface2: #f0ede6;
  --border: #d4cfc5;
  --border2: #e8e4dc;
  --text: #1a1814;
  --text-muted: #7a756e;
  --sidebar-w: 236px;
  --header-h: 67px;

  --mono: 'IBM Plex Mono', monospace;
  --display: 'Playfair Display', serif;
}

/* ── BASE ── */
*, *::before, *::after { box-sizing: border-box; }
button, select, input, textarea { font-family: 'IBM Plex Sans', sans-serif; }

body {
  margin: 0;
  font-family: 'IBM Plex Sans', sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

/* ── LAYOUT ── */
.app {
  display: flex;
  min-height: calc(100vh - var(--header-h));
  align-items: flex-start;
}

/* ── SIDEBAR ── */
.sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  height: calc(100vh - var(--header-h));
  position: sticky;
  top: var(--header-h);
  overflow-y: auto;
  background: var(--card);
  border-right: 1px solid var(--border);
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  scrollbar-width: thin;
}

.sidebar-brand {
  display: none;
}

.sidebar-logo {
  width: 32px;
  height: 32px;
  object-fit: contain;
  flex-shrink: 0;
}

.sidebar-brand-text { min-width: 0; }

.sidebar-brand-text h2 {
  margin: 0;
  color: var(--azul);
  font-size: 17px;
}

.sidebar-scroll-btn {
  position: absolute;
  right: 8px;
  bottom: 8px;
  width: 26px;
  height: 26px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--card);
  color: var(--text-muted);
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  transition: background 0.15s, color 0.15s;
}
.sidebar-scroll-btn:hover { background: var(--azul); color: white; border-color: var(--azul); }

.sidebar-spacer { height: 48px; flex-shrink: 0; }
.sidebar-hint { font-size: 12px; color: var(--text-muted); margin: 0; }

.section {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}
.section:last-of-type { border-bottom: none; }

.section h3 {
  margin: 0 0 2px 0;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* Sidebar buttons */
.sidebar button {
  background: var(--azul);
  color: white;
  border: none;
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 13px;
  font-family: 'IBM Plex Sans', sans-serif;
  font-weight: 500;
  cursor: pointer;
  transition: opacity 0.15s;
  text-align: center;
}
.sidebar button:hover { opacity: 0.88; }

.btn-add-object {
  background: var(--azul) !important;
  font-weight: 600 !important;
}

.btn-danger {
  background: linear-gradient(135deg, #ef4444, #b91c1c) !important;
}

/* Sim controls */
.sim-controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 5px;
}

.speed-row {
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.speed-row label { font-size: 12px; color: var(--text-muted); }
.speed-row input { width: 100%; }

/* Scenario grid */
.scenario-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 5px;
}
.scenario-grid button {
  text-align: center !important;
  font-size: 12px !important;
  padding: 5px 6px !important;
}

/* Viz toggles */
.viz-toggles { display: flex; flex-direction: column; gap: 4px; }
.viz-toggles label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 5px;
  background: #faf9f7;
  transition: background 0.15s;
  user-select: none;
}
.viz-toggles label:hover { background: #f0ede6; }
.viz-toggles input[type="checkbox"] { width: auto; margin: 0; }

/* Collapsible sidebar sections */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  user-select: none;
  margin: -2px -4px;
  padding: 2px 4px;
  border-radius: 4px;
}
.section-header:hover { background: #f0ede6; }
.section-header h3 { margin: 0; pointer-events: none; }
.section-chevron {
  font-size: 9px;
  color: #9a9088;
  transition: transform 0.18s ease;
  pointer-events: none;
  flex-shrink: 0;
}
.section-collapsible.section-collapsed .section-chevron { transform: rotate(-90deg); }
.section-collapsible.section-collapsed .section-body { display: none; }
.section-body { display: flex; flex-direction: column; gap: 5px; padding-top: 4px; }

/* Table column chip selector */
.table-col-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  min-height: 24px;
  margin-bottom: 4px;
}
.table-col-tag {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  background: #f0ede6;
  border: 1px solid #d4cfc5;
  color: #1a3a6b;
  border-radius: 4px;
  padding: 2px 4px 2px 7px;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}
.table-col-remove {
  background: none;
  border: none;
  color: #9a9088;
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
  padding: 0 2px;
  display: flex;
  align-items: center;
}
.table-col-remove:hover { color: #ef4444; }
.table-col-add-select {
  width: 100%;
  font-size: 13px;
  padding: 4px 6px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #faf9f7;
  color: var(--text);
  cursor: pointer;
}
.table-col-empty { font-size: 12px; color: #9a9088; font-style: italic; }
.col-user-badge {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--azul);
  background: #ede9e1;
  border: 1px solid #d4cfc5;
  padding: 1px 4px;
  border-radius: 3px;
  vertical-align: middle;
}

/* Graph series in sidebar */
.sidebar .graph-series {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 5px;
  padding: 7px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #faf9f7;
  margin-bottom: 5px;
}
.sidebar .graph-series label {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 11px;
  color: var(--text-muted);
}
.sidebar .graph-series select,
.sidebar .graph-series input {
  width: 100%;
  padding: 3px 5px;
  border-radius: 4px;
  border: 1px solid #c8c2b8;
  background: white;
  color: var(--text);
  font-size: 12px;
  box-sizing: border-box;
}
.sidebar .inline-check {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  cursor: pointer;
  margin-bottom: 5px;
}
.sidebar .inline-check input[type="checkbox"] { width: auto; }
.sidebar .graph-time-controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  margin-bottom: 5px;
}
.sidebar .graph-time-controls label {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 11px;
  color: var(--text-muted);
}
.sidebar .graph-time-controls input {
  width: 100%;
  padding: 3px 4px;
  border-radius: 4px;
  border: 1px solid #c8c2b8;
  box-sizing: border-box;
  font-size: 12px;
}

.time-readout {
  background: #f0ede6;
  color: #1a3a6b;
  border: 1px solid #d4cfc5;
  border-radius: 5px;
  padding: 5px 8px;
  font-size: 14px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  text-align: center;
}

/* ── MAIN ── */
.main {
  flex: 1;
  padding: 16px;
  min-width: 0;
}

/* ── PAGE HEADER ── */
.page-header {
  background: var(--card);
  border-bottom: 3px solid var(--gold);
  padding: 4px 20px;
  position: sticky;
  top: 0;
  z-index: 200;
}
.page-header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.page-header-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}
.logo-link { display: inline-flex; line-height: 0; }
.logo-link::after { display: none !important; }
.header-logo {
  width: 62px;
  height: 62px;
  object-fit: contain;
  flex-shrink: 0;
}
.page-header-brand-text {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}
.page-header-name-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.page-header-sep {
  color: var(--border);
  font-size: 16px;
  font-weight: 300;
  flex-shrink: 0;
}
.page-header h1 {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
  color: var(--azul);
  line-height: 1.2;
  font-family: var(--display);
}
.page-tagline {
  margin: 0;
  font-size: 12px;
  color: var(--text-muted);
}
.page-header-badges { display: flex; gap: 6px; flex-shrink: 0; align-items: center; }

.badge-link {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  background: none !important;
  background-clip: unset !important;
  -webkit-background-clip: unset !important;
  -webkit-text-fill-color: unset !important;
  color: var(--text-muted) !important;
  border: 1px solid var(--border);
  text-decoration: none;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  white-space: nowrap;
}
.badge-link:hover {
  background: var(--surface2) !important;
  -webkit-text-fill-color: var(--azul) !important;
  color: var(--azul) !important;
  border-color: var(--azul);
}
.badge-link::after { display: none !important; }
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  background: var(--azul);
  color: white;
}

/* ── WORKSPACE ── */
.workspace {
  position: relative;
  min-height: calc(100vh - var(--header-h) - 32px);
  border: 1px solid var(--border);
  border-radius: 14px;
  background:
    linear-gradient(rgba(212,207,197,0.5) 1px, transparent 1px),
    linear-gradient(90deg, rgba(212,207,197,0.5) 1px, transparent 1px),
    #f5f4f0;
  background-size: 28px 28px, 28px 28px, auto;
  overflow-x: hidden;
  overflow-y: auto;
}

/* ── WINDOW PANELS ── */
.window-panel {
  position: absolute;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 4px 16px rgba(15,23,42,0.08), 0 1px 4px rgba(15,23,42,0.04);
  display: flex;
  flex-direction: column;
  min-width: 260px;
  min-height: 200px;
  overflow: hidden;
  backdrop-filter: blur(6px);
  transition: box-shadow 0.15s;
}
.window-panel.active-window {
  box-shadow: 0 8px 32px rgba(26,58,107,0.16), 0 2px 8px rgba(26,58,107,0.08);
  border-color: rgba(26,58,107,0.3);
}

.panel-canvas  { left: 20px; top: 20px; width: calc(100% - 420px); height: 600px; }
.panel-info    { right: 20px; top: 20px; width: 370px; height: 600px; }
.panel-data    { left: 20px; top: 640px; width: calc(100% - 420px); height: 300px; }
.panel-graph   { right: 20px; top: 640px; width: 370px; height: 300px; }

.window-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--card);
  cursor: move;
  user-select: none;
  flex-shrink: 0;
}
.window-header h3 {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
  color: #1a1814;
}
.panel-header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}
.panel-hint {
  font-size: 11px;
  color: #9a9088;
  white-space: nowrap;
}

.collapse-toggle {
  background: none;
  border: none;
  cursor: pointer;
  padding: 3px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
  color: var(--text-muted);
}
.collapse-toggle:hover { background: rgba(0,0,0,0.06); }

.collapse-icon {
  display: inline-block;
  font-size: 12px;
  transition: transform 0.25s ease;
}
.panel-data.collapsed .window-body { display: none; }
.panel-data.collapsed { min-height: 0 !important; height: auto !important; }
.panel-data.collapsed .window-header { border-bottom: none; }
.panel-data.collapsed .collapse-icon { transform: rotate(-90deg); }
.panel-data.collapsed .resize-handle { display: none; }

.panel-graph.collapsed .window-body { display: none; }
.panel-graph.collapsed { min-height: 0 !important; height: auto !important; }
.panel-graph.collapsed .window-header { border-bottom: none; }
.panel-graph.collapsed .collapse-icon { transform: rotate(-90deg); }
.panel-graph.collapsed .resize-handle { display: none; }

.btn-icon {
  background: #f0ede6 !important;
  color: var(--text) !important;
  border: 1px solid var(--border) !important;
  padding: 3px 8px !important;
  border-radius: 5px !important;
  font-size: 12px !important;
  font-weight: 600 !important;
  cursor: pointer;
  transition: background 0.15s !important;
}
.btn-icon:hover { background: #d4cfc5 !important; }

.window-body {
  flex: 1;
  padding: 12px;
  overflow: auto;
  min-height: 0;
}

/* ── CANVAS ── */
.canvas-container {
  width: 100%;
  height: 100%;
  min-height: 200px;
  background: #ffffff;
  border-radius: 8px;
  border: 1px solid var(--border);
}
canvas { width: 100%; height: 100%; display: block; }
#graphCanvas {
  width: 100%;
  min-height: 200px;
  height: calc(100% - 8px);
  border: 1px solid var(--border);
  border-radius: 8px;
  display: block;
}

/* ── ZOOM CONTROLS ── */
.zoom-controls {
  display: flex;
  align-items: center;
  gap: 4px;
  background: #f0ede6;
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 2px 6px;
}

.zoom-btn {
  background: none !important;
  border: none !important;
  padding: 0 4px !important;
  font-size: 17px !important;
  font-weight: 700 !important;
  color: var(--azul) !important;
  cursor: pointer;
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: background 0.12s !important;
  line-height: 1;
}
.zoom-btn:hover { background: #e8e4dc !important; }
.zoom-btn:disabled { color: #c8c2b8 !important; cursor: default; }

.zoom-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  min-width: 56px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

/* ── INFO PANEL ── */
.info-panel, .data-panel, .graph-panel { background: transparent; padding: 0; border: none; }

.empty-state { text-align: center; padding: 24px 16px; color: var(--text-muted); }
.empty-state p { margin: 0 0 12px; }
.empty-state-text { color: var(--text-muted); padding: 16px; margin: 0; }

.btn-add-object-inline {
  display: inline-block;
  background: var(--azul);
  color: white;
  border: none;
  padding: 7px 14px;
  border-radius: 7px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.object-info-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  margin-bottom: 10px;
  background: #faf9f7;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.object-info-card:last-child { margin-bottom: 0; }
.object-info-card.selecionado {
  border-color: var(--azul);
  box-shadow: 0 0 0 3px rgba(26,58,107,0.1);
  background: #ede9e1;
}

.object-info-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  gap: 6px;
}
.object-info-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 700;
  font-size: 14px;
  color: var(--text);
  min-width: 0;
  flex: 1;
}

.obj-color-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

.object-header-btns {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}
.object-header-btns button {
  border: 1px solid var(--border);
  border-radius: 5px;
  background: #faf9f7;
  color: var(--text-muted);
  font-size: 14px;
  width: 26px;
  height: 26px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.12s, color 0.12s;
  padding: 0;
}
.object-header-btns button:hover { background: #e8e4dc; color: var(--azul); border-color: var(--azul); }
.object-header-btns button.danger:hover { background: #fee2e2; color: #b91c1c; border-color: #fca5a5; }
.object-shape-badge {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  background: var(--azul);
  color: white;
  text-transform: capitalize;
}

/* Card collapse: body hidden when minimized */
.card-body {}
.object-info-card.card-minimized .card-body { display: none; }
.object-info-card.card-minimized { padding-bottom: 4px; }

/* Card toggle chevron */
.card-toggle-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  transition: transform 0.2s ease, color 0.12s;
}
.card-toggle-btn::before {
  content: "▼";
  font-size: 9px;
  line-height: 1;
  display: block;
}
.object-info-card.card-minimized .card-toggle-btn { transform: rotate(-90deg); }
.card-toggle-btn:hover { color: var(--azul); }

/* Kinematic section collapse */
.kinematic-section { margin-bottom: 4px; }
.object-info-card.kine-hidden .kinematic-section { display: none; }

/* Kine toggle button (≡) in header */
.kine-toggle-btn {
  border: 1px solid var(--border) !important;
  border-radius: 4px !important;
  background: #faf9f7 !important;
  color: var(--text-muted) !important;
  font-size: 14px !important;
  width: 26px !important;
  height: 26px !important;
  cursor: pointer !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  transition: background 0.12s, color 0.12s !important;
  padding: 0 !important;
}
.kine-toggle-btn:hover { background: #e8e4dc !important; color: var(--azul) !important; border-color: var(--azul) !important; }
.object-info-card.kine-hidden .kine-toggle-btn {
  background: #f0ede6 !important;
  color: var(--azul) !important;
  border-color: #d4cfc5 !important;
}

.kinematic-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 3px 6px;
  margin-bottom: 4px;
}
.kinematic-item {
  display: flex;
  flex-direction: column;
  gap: 0;
}
.kinematic-item .k-label {
  font-size: 10px;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.kinematic-item .k-value {
  font-size: 12px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}
.kinematic-item .k-value.velocity { color: #16a34a; }
.kinematic-item .k-value.acceleration { color: #dc2626; }

.equation-summary {
  margin: 6px 0;
  padding: 7px 9px;
  background: #f0ede6;
  border-radius: 6px;
  border: 1px solid #d4cfc5;
  font-size: 12px;
}
.equation-summary code {
  display: inline-block;
  color: #1a3a6b;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 12px;
  word-break: break-all;
}

.ec-row {
  font-size: 11px;
  color: var(--text-muted);
  margin: 2px 0 0;
  font-variant-numeric: tabular-nums;
}

/* ── WHITEBOARD ── */
.whiteboard-section {
  margin-top: 6px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.object-info-card.kine-hidden .whiteboard-section { margin-top: 0; }

.whiteboard-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
}

.wb-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
}

.wb-preset-btn {
  background: #f0ede6;
  color: var(--text);
  border: 1px solid var(--border);
  padding: 2px 8px;
  border-radius: 5px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
  line-height: 1.6;
}
.wb-preset-btn:hover { background: #e8e4dc; border-color: var(--azul); color: var(--azul); }

.whiteboard-textarea {
  width: 100%;
  min-height: 110px;
  max-height: 280px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 13px;
  line-height: 1.65;
  padding: 10px 12px;
  border: 1.5px solid #c8c2b8;
  border-radius: 8px;
  background: #ffffff;
  color: var(--text);
  resize: vertical;
  box-sizing: border-box;
  transition: border-color 0.15s, box-shadow 0.15s;
  white-space: pre;
  overflow-x: auto;
}
.whiteboard-textarea:focus {
  outline: none;
  border-color: var(--azul);
  box-shadow: 0 0 0 3px rgba(26,58,107,0.1);
}
.whiteboard-textarea::placeholder {
  color: #9a9088;
  font-style: italic;
}

.whiteboard-palette {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.wb-palette-btn {
  background: white;
  color: var(--text);
  border: 1px solid #c8c2b8;
  padding: 2px 7px;
  border-radius: 4px;
  font-size: 12px;
  font-family: 'IBM Plex Mono', monospace;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
  line-height: 1.6;
}
.wb-palette-btn:hover { background: #f0ede6; border-color: var(--azul); color: var(--azul); }

.whiteboard-footer {
  display: flex;
  align-items: center;
  gap: 8px;
}

.whiteboard-apply-btn {
  background: var(--azul);
  color: white;
  border: none;
  border-radius: 6px;
  padding: 5px 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
  flex-shrink: 0;
}
.whiteboard-apply-btn:hover { opacity: 0.88; }

.whiteboard-status {
  font-size: 12px;
  font-weight: 600;
  flex: 1;
  min-width: 0;
  word-break: break-word;
}
.whiteboard-status.status-ok { color: #16a34a; }
.whiteboard-status.status-error { color: #dc2626; }

/* Conditions section (EDO initial values) */
.whiteboard-conditions {
  background: #f0ede6;
  border: 1px solid #d4cfc5;
  border-radius: 8px;
  padding: 10px 12px;
}
.conditions-subblock {
  margin-bottom: 10px;
}
.conditions-subblock:last-child { margin-bottom: 0; }

.conditions-header {
  font-size: 11px;
  font-weight: 700;
  color: #1a3a6b;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 8px;
}
.conditions-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 16px;
}
.condition-label {
  display: flex;
  align-items: center;
  gap: 6px;
}
.condition-var {
  font-family: 'IBM Plex Mono', monospace;
  font-weight: 700;
  font-size: 13px;
  color: #1a3a6b;
  white-space: nowrap;
}
.condition-input {
  width: 72px;
  padding: 3px 6px;
  border: 1px solid #c8c2b8;
  border-radius: 5px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 13px;
  background: white;
  color: var(--text);
  box-sizing: border-box;
}
.condition-input:focus {
  outline: none;
  border-color: var(--azul);
  box-shadow: 0 0 0 2px rgba(26,58,107,0.12);
}

/* d/dt palette button */
.wb-palette-btn--deriv {
  background: #f0ede6 !important;
  border-color: #c8c2b8 !important;
  color: var(--azul) !important;
}
.wb-palette-btn--deriv:hover {
  background: #e8e4dc !important;
  border-color: var(--azul) !important;
  color: var(--azul) !important;
}

/* ── DATA TABLE ── */
.object-table-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 12px;
}
.object-table-card:last-child { margin-bottom: 0; }

.object-table-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: #faf9f7;
  border-bottom: 1px solid var(--border);
}
.object-table-header h4 {
  margin: 0;
  font-size: 13px;
  font-weight: 700;
}
.btn-csv {
  background: #f0ede6;
  color: var(--text);
  border: 1px solid var(--border);
  padding: 2px 8px;
  border-radius: 5px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}
.btn-csv:hover { background: #d4cfc5; }

.object-table-card table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  min-width: 560px;
}
.object-table-card { overflow-x: auto; }
.object-table-card th, .object-table-card td {
  padding: 6px 9px;
  text-align: right;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.object-table-card th {
  background: #f0ede6;
  color: var(--text-muted);
  font-weight: 700;
  font-size: 12px;
  position: sticky;
  top: 0;
}
.object-table-card tr:last-child td { border-bottom: none; }
.object-table-card tr:hover td { background: #faf9f7; }

/* ── RESIZE HANDLE ── */
.resize-handle {
  position: absolute;
  right: 6px;
  bottom: 6px;
  width: 20px;
  height: 20px;
  border: none;
  background:
    linear-gradient(135deg, transparent 40%, #9a9088 40% 52%, transparent 52%),
    linear-gradient(135deg, transparent 60%, #9a9088 60% 72%, transparent 72%);
  cursor: nwse-resize;
  opacity: 0.7;
}

/* ── TUTORIAL ── */
.tutorial-section {
  background: white;
  border-radius: 10px;
  border: 1px solid var(--border);
  overflow: hidden;
}
.tutorial-toggle {
  width: 100%;
  padding: 10px 14px;
  background: rgba(26,58,107,0.07);
  border: none;
  cursor: pointer;
  font-weight: 600;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  transition: background 0.15s;
}
.tutorial-toggle:hover { background: rgba(26,58,107,0.12); }
.tutorial-icon { font-size: 12px; transition: transform 0.25s; }
.tutorial-content { display: none; padding: 14px; }
.tutorial-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 10px;
}
.tutorial-card {
  background: #faf9f7;
  padding: 12px;
  border-radius: 8px;
  border-left: 3px solid var(--azul);
}
.tutorial-card h4 { margin: 0 0 6px; font-size: 14px; }
.tutorial-card p { margin: 4px 0; font-size: 13px; color: var(--text-muted); }
.tutorial-card code {
  background: #f0ede6;
  color: #1a3a6b;
  padding: 1px 4px;
  border-radius: 3px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 12px;
}

/* ── MODAL ── */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { transform: translateY(16px); opacity: 0; } to { transform: none; opacity: 1; } }

.modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,0.5);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.15s ease;
}
.modal.active { display: flex; }

.modal-content {
  background: white;
  border-radius: 16px;
  box-shadow: 0 24px 64px rgba(0,0,0,0.24);
  max-width: 780px;
  width: 94%;
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  animation: slideUp 0.2s ease;
}

.modal-appearance {
  max-width: 520px;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
}
.modal-header h2 { margin: 0; font-size: 18px; font-weight: 700; }

.modal-close {
  background: none;
  border: none;
  font-size: 27px;
  cursor: pointer;
  color: #9a9088;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  transition: background 0.15s, color 0.15s;
  padding: 0;
}
.modal-close:hover { background: #f0ede6; color: var(--text); }

.modal-body { padding: 20px 22px; overflow-y: auto; flex: 1; }

.modal-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 18px;
  border-bottom: 2px solid var(--border);
  padding-bottom: 0;
}
.modal-tab {
  padding: 7px 16px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  border-radius: 6px 6px 0 0;
  transition: color 0.15s, background 0.15s;
  margin-bottom: -2px;
  border-bottom: 2px solid transparent;
}
.modal-tab:hover { background: #f0ede6; color: var(--text); }
.modal-tab.active { color: var(--azul); border-bottom-color: var(--azul); background: transparent; }

.modal-footer {
  display: flex;
  gap: 10px;
  padding: 14px 22px;
  border-top: 1px solid var(--border);
  justify-content: flex-end;
}

.btn-secondary, .btn-primary {
  padding: 9px 20px;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  font-weight: 600;
  transition: opacity 0.15s, background 0.15s;
  font-size: 14px;
}
.btn-secondary { background: #f0ede6; color: var(--text); }
.btn-secondary:hover { background: #d4cfc5; }
.btn-primary { background: var(--azul); color: white; }
.btn-primary:hover { opacity: 0.9; }

/* ── APPEARANCE TAB ── */
.appearance-section { display: flex; flex-direction: column; gap: 18px; }

.appearance-top-row {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 12px;
  align-items: end;
}
.appearance-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.appearance-field label { font-size: 13px; font-weight: 600; color: var(--text); }
.appearance-field input[type="text"],
.appearance-field input[type="number"] {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 7px;
  font-size: 14px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.appearance-field input:focus {
  outline: none;
  border-color: var(--azul);
  box-shadow: 0 0 0 3px rgba(26,58,107,0.1);
}
.appearance-field--color input[type="color"] {
  width: 56px;
  height: 38px;
  padding: 2px 4px;
  border: 1px solid var(--border);
  border-radius: 7px;
  cursor: pointer;
  background: white;
}

.shape-picker { }
.shape-picker-label, .preset-picker-label {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 8px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.shape-options {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
}

.shape-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  padding: 10px 6px;
  border: 2px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  background: #faf9f7;
  font-size: 12px;
  font-weight: 500;
  text-align: center;
  user-select: none;
}
.shape-option:hover { border-color: #c8c2b8; background: #f0ede6; }
.shape-option input[type="radio"] { display: none; }
.shape-option:has(input:checked) {
  border-color: var(--azul);
  background: #f0ede6;
  color: var(--azul);
  font-weight: 700;
}
.shape-icon-wrap {
  font-size: 21px;
  line-height: 1;
}

.preset-picker { }
.preset-options {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}
.preset-btn {
  background: #f0ede6;
  color: var(--text);
  border: 1px solid var(--border);
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.preset-btn:hover { background: #e8e4dc; border-color: var(--azul); color: var(--azul); }

/* ── MATH PALETTE ── */
.math-palette {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  align-items: center;
  padding: 8px 10px;
  background: #faf9f7;
  border-radius: 8px;
  border: 1px solid var(--border);
  margin-bottom: 14px;
}
.palette-label { font-size: 12px; font-weight: 600; color: var(--text-muted); margin-right: 2px; }
.math-btn {
  background: white;
  color: var(--text);
  border: 1px solid #c8c2b8;
  padding: 3px 8px;
  border-radius: 5px;
  font-size: 13px;
  font-family: 'IBM Plex Mono', monospace;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
}
.math-btn:hover { background: #f0ede6; border-color: var(--azul); color: var(--azul); }

/* ── EQUATION ROWS ── */
.equation-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 0 0 10px;
}
.equation-row {
  display: grid;
  grid-template-columns: minmax(140px, 0.75fr) minmax(180px, 1.25fr) 30px;
  gap: 7px;
  align-items: center;
}
.equation-lhs {
  display: grid;
  grid-template-columns: auto minmax(50px, 1fr) auto;
  gap: 4px;
  align-items: center;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 14px;
  color: #374151;
  background: #faf9f7;
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 6px 8px;
}
.eq-prefix { color: var(--text-muted); }
.eq-suffix { color: var(--text-muted); white-space: nowrap; }

.equation-var-input {
  min-width: 0;
  border: none;
  background: transparent;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 14px;
  color: var(--azul);
  font-weight: 700;
  padding: 0;
  outline: none;
  text-align: center;
}
.equation-expression-input {
  min-width: 0;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 7px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 14px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.equation-expression-input:focus {
  outline: none;
  border-color: var(--azul);
  box-shadow: 0 0 0 3px rgba(26,58,107,0.1);
}
.equation-remove-btn {
  width: 30px;
  height: 30px;
  border: none;
  border-radius: 6px;
  background: #fee2e2;
  color: #b91c1c;
  font-size: 19px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}
.equation-remove-btn:hover { background: #fecaca; }

.equation-add-btn { align-self: flex-start; }

/* EDO Section */
.edo-section { display: flex; flex-direction: column; gap: 18px; }
.edo-block { }
.edo-block h4 {
  margin: 0 0 4px;
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
}
.edo-block-hint {
  font-size: 12px;
  font-weight: 400;
  color: var(--text-muted);
  font-style: italic;
}

.edo-hint {
  margin: 0 0 10px;
  font-size: 13px;
  color: var(--text-muted);
  font-style: italic;
  line-height: 1.5;
}
.edo-hint code {
  background: #f0ede6;
  color: #1a3a6b;
  padding: 1px 4px;
  border-radius: 3px;
  font-style: normal;
}
.edo-hint strong { color: var(--text); font-style: normal; }

.edo-variables {
  background: #faf9f7;
  border-radius: 8px;
  padding: 14px;
  border: 1px solid var(--border);
}
.edo-variables h4 { margin: 0 0 10px; font-size: 14px; font-weight: 700; }

.edo-constants-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 8px;
}
.edo-constant-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.edo-constant-row label {
  font-weight: 700;
  font-size: 14px;
  font-family: 'IBM Plex Mono', monospace;
  color: var(--text);
  white-space: nowrap;
}
.edo-constant-row input {
  flex: 1;
  min-width: 0;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 14px;
}
.edo-constant-row input:focus {
  outline: none;
  border-color: var(--azul);
  box-shadow: 0 0 0 3px rgba(26,58,107,0.1);
}

/* ── BRAND LINK ── */
img { height: 32px; display: block; }
a {
  font-size: 1.1rem;
  font-weight: 800;
  letter-spacing: 0.2px;
  background: linear-gradient(90deg, #facc15, #fb923c, #6a2fe8, #2f5bea);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  color: transparent;
  white-space: nowrap;
  text-decoration: none;
  position: relative;
  padding: 0.1rem 0;
}
a::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: -3px;
  width: 0;
  height: 2px;
  background: #6a2fe8;
  transition: width 0.22s ease;
}
a:hover::after { width: 100%; }

/* ── RESPONSIVE ── */
@media (max-width: 800px) {
  .app { flex-direction: column; }

  .sidebar {
    width: auto;
    min-width: 0;
    height: auto;
    position: static;
    overflow-y: visible;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  .scenario-grid { grid-template-columns: repeat(4, 1fr); }

  .main { padding: 10px; }

  .workspace {
    display: flex;
    flex-direction: column;
    min-height: 0;
    gap: 12px;
    background: transparent;
    border: none;
    overflow: visible;
  }
  .window-panel {
    position: static;
    width: 100% !important;
    height: auto !important;
    min-width: 0;
  }
  .window-header { cursor: default; }
  .resize-handle, .panel-hint { display: none; }
  .canvas-container { min-height: 280px; }
  .panel-canvas { height: 320px !important; }

  .shape-options { grid-template-columns: repeat(3, 1fr); }
  .appearance-top-row { grid-template-columns: 1fr 1fr; }
  .appearance-field--color { grid-column: span 1; }

  .page-header { padding: 8px 12px; }
  .page-header-badges { display: none; }
  .page-tagline { display: none; }
  .page-header-sep { display: none; }
  .page-header h1 { font-size: 15px; }
  .zoom-label { min-width: 44px; font-size: 11px; }
  .whiteboard-textarea { min-height: 70px; font-size: 12px; }
}
