/* ================================================================
   DESIGN SYSTEM — Modern Scientific Dashboard
   ================================================================ */
:root {
  --bg-0: #fafbfc; --bg-1: #ffffff; --bg-2: #f4f5f7; --bg-3: #e8eaed;
  --fg-0: #1a1d23; --fg-1: #3d4250; --fg-2: #6b7080; --fg-3: #9aa0ad;
  --border: #dfe1e6;
  --accent: #2563eb; --accent-light: #dbeafe; --accent-dark: #1d4ed8;
  --red: #dc2626; --red-bg: #fef2f2;
  --green: #16a34a; --green-bg: #f0fdf4;
  --amber: #d97706; --amber-bg: #fffbeb;
  --blue: #2563eb; --blue-bg: #eff6ff;
  --purple: #7c3aed; --purple-bg: #f5f3ff;
  --teal: #0d9488; --teal-bg: #f0fdfa;
  --node-cfg: #dae8fc; --node-cfg-s: #6c8ebf; --node-cfg-t: #1a3a5c;
  --node-pop: #d5e8d4; --node-pop-s: #82b366; --node-pop-t: #2d5a2d;
  --node-bt: #e1d5e7; --node-bt-s: #9673a6; --node-bt-t: #5c3d6e;
  --node-gl: #fff2cc; --node-gl-s: #d6b656; --node-gl-t: #6e5a20;
  --node-bel: #f8cecc; --node-bel-s: #b85450; --node-bel-t: #6e2a28;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.05);
  --shadow-md: 0 4px 12px rgba(0,0,0,.07);
  --shadow-lg: 0 8px 24px rgba(0,0,0,.09);
  --radius: 10px; --radius-sm: 6px; --radius-lg: 14px;
  --ease: cubic-bezier(.4,0,.2,1);
}
[data-theme="dark"] {
  --bg-0: #0d1117; --bg-1: #161b22; --bg-2: #1c2129; --bg-3: #272d38;
  --fg-0: #e6edf3; --fg-1: #c9d1d9; --fg-2: #8b949e; --fg-3: #6e7681;
  --border: #30363d;
  --accent-light: #1e3a5f;
  --node-cfg: #1a2540; --node-cfg-s: #3d6eaf; --node-cfg-t: #8ab4f8;
  --node-pop: #1a2e1a; --node-pop-s: #5a9a50; --node-pop-t: #7dca75;
  --node-bt: #231a35; --node-bt-s: #8060a8; --node-bt-t: #c4a8e0;
  --node-gl: #2d2614; --node-gl-s: #b8962e; --node-gl-t: #e8cc6a;
  --node-bel: #2d1b1b; --node-bel-s: #c06060; --node-bel-t: #f0a8a8;
  --shadow-sm: 0 1px 3px rgba(0,0,0,.3);
  --shadow-md: 0 4px 14px rgba(0,0,0,.35);
  --shadow-lg: 0 8px 28px rgba(0,0,0,.4);
  --red-bg: #2d1b1b; --green-bg: #1a2e1a; --amber-bg: #2d2614;
  --blue-bg: #1a2540; --purple-bg: #231a35; --teal-bg: #142925;
}
@media (prefers-color-scheme: dark) {
  [data-theme="auto"] {
    --bg-0: #0d1117; --bg-1: #161b22; --bg-2: #1c2129; --bg-3: #272d38;
    --fg-0: #e6edf3; --fg-1: #c9d1d9; --fg-2: #8b949e; --fg-3: #6e7681;
    --border: #30363d; --accent-light: #1e3a5f;
    --node-cfg: #1a2540; --node-cfg-s: #3d6eaf; --node-cfg-t: #8ab4f8;
    --node-pop: #1a2e1a; --node-pop-s: #5a9a50; --node-pop-t: #7dca75;
    --node-bt: #231a35; --node-bt-s: #8060a8; --node-bt-t: #c4a8e0;
    --node-gl: #2d2614; --node-gl-s: #b8962e; --node-gl-t: #e8cc6a;
    --node-bel: #2d1b1b; --node-bel-s: #c06060; --node-bel-t: #f0a8a8;
    --shadow-sm: 0 1px 3px rgba(0,0,0,.3); --shadow-md: 0 4px 14px rgba(0,0,0,.35);
    --shadow-lg: 0 8px 28px rgba(0,0,0,.4);
    --red-bg: #2d1b1b; --green-bg: #1a2e1a; --amber-bg: #2d2614;
    --blue-bg: #1a2540; --purple-bg: #231a35; --teal-bg: #142925;
  }
}

/* ================================================================ Reset */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { font-size: 15px; -webkit-font-smoothing: antialiased; scroll-behavior: smooth; }
body { font-family: 'Inter', system-ui, -apple-system, sans-serif; background: var(--bg-0); color: var(--fg-0); line-height: 1.5; min-height: 100vh; }

/* ================================================================ Navbar */
.navbar {
  position: sticky; top: 0; z-index: 100;
  display: flex; align-items: center; gap: 16px;
  padding: 0 24px; height: 52px;
  background: var(--bg-1); border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}
.nav-brand {
  font-size: 1rem; font-weight: 700; letter-spacing: -.02em;
  background: linear-gradient(135deg, var(--accent), var(--purple));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
  white-space: nowrap; margin-right: 8px;
}
.nav-tabs { display: flex; gap: 2px; flex: 1; }
.nav-tab {
  padding: 14px 16px; font-size: .8rem; font-weight: 500; color: var(--fg-2);
  border: none; background: none; cursor: pointer; position: relative;
  font-family: inherit; transition: color .15s;
}
.nav-tab:hover { color: var(--fg-0); }
.nav-tab.active { color: var(--accent); font-weight: 600; }
.nav-tab.active::after {
  content: ''; position: absolute; bottom: 0; left: 8px; right: 8px;
  height: 2px; background: var(--accent); border-radius: 1px;
}
.nav-tools { display: flex; align-items: center; gap: 10px; }
.nav-tools select {
  font-family: inherit; font-size: .78rem; font-weight: 500;
  background: var(--bg-2); color: var(--fg-0); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 0 22px 0 8px; height: 30px;
  outline: none; cursor: pointer; width: auto;
  -webkit-appearance: none; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath fill='none' stroke='%239aa0ad' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round' d='M1 1l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 6px center;
}
.nav-menu { display: flex; align-items: center; gap: 16px; margin-left: auto; }
.nav-hamburger { display: none; }
.mobile-toggle {
  display: none; align-items: center; justify-content: center;
  width: 30px; height: 30px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--bg-2); color: var(--fg-1);
  cursor: pointer; padding: 0; transition: all .2s var(--ease);
}
.mobile-toggle:hover { background: var(--bg-3); border-color: var(--accent); }
.mobile-toggle svg { width: 16px; height: 16px; }
.theme-btn {
  width: 30px; height: 30px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--bg-2); color: var(--fg-1);
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: all .2s var(--ease); padding: 0;
}
.theme-btn:hover { background: var(--bg-3); border-color: var(--accent); }
.theme-btn svg { width: 16px; height: 16px; transition: transform .3s var(--ease); }
.theme-btn:hover svg { transform: rotate(20deg); }
.theme-btn .sun { display: none; }
.theme-btn .moon { display: block; }
[data-theme="dark"] .theme-btn .sun { display: block; }
[data-theme="dark"] .theme-btn .moon { display: none; }
@media (prefers-color-scheme: dark) {
  [data-theme="auto"] .theme-btn .sun { display: block; }
  [data-theme="auto"] .theme-btn .moon { display: none; }
}

/* ================================================================ Tab content */
.tab-content { display: none; }
.tab-content.active { display: block; }

/* ================================================================ Experiment tab layout */
.app-layout {
  display: grid; grid-template-columns: 310px 1fr;
  max-width: 1520px; margin: 0 auto;
  min-height: calc(100vh - 52px);
}

/* ================================================================ Sidebar */
.sidebar {
  background: var(--bg-1); border-right: 1px solid var(--border);
  padding: 20px 18px 30px; overflow-y: auto; -webkit-overflow-scrolling: touch;
  display: flex; flex-direction: column; gap: 6px;
  max-height: calc(100vh - 52px); max-height: calc(100dvh - 52px);
  position: sticky; top: 52px;
}
.panel { border-radius: var(--radius); overflow: hidden; flex-shrink: 0; }
.panel-header {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 14px; background: var(--bg-2);
  cursor: pointer; user-select: none;
  border-radius: var(--radius-sm); transition: background .15s var(--ease);
}
.panel-header:hover { background: var(--bg-3); }
.panel-header .icon { font-size: 1rem; width: 20px; text-align: center; }
.panel-header h3 {
  font-size: .78rem; font-weight: 600; text-transform: uppercase;
  letter-spacing: .06em; color: var(--fg-1); flex: 1;
}
.panel-header .chevron { color: var(--fg-3); font-size: .7rem; transition: transform .2s var(--ease); }
.panel.collapsed .panel-body { display: none; }
.panel.collapsed .chevron { transform: rotate(-90deg); }
.panel-body { padding: 12px 14px 16px; }

/* Form controls */
.form-group { margin-bottom: 10px; }
.form-label {
  display: flex; justify-content: space-between; align-items: baseline;
  font-size: .76rem; font-weight: 500; color: var(--fg-1); margin-bottom: 4px;
}
.form-label .unit { font-weight: 600; color: var(--accent); font-family: 'JetBrains Mono', monospace; font-size: .75rem; }
.form-hint { font-size: .68rem; color: var(--fg-3); margin-top: 2px; }
.form-section { margin-top: 10px; }
.form-section-title {
  font-size: .72rem; font-weight: 600; color: var(--fg-2);
  text-transform: uppercase; letter-spacing: .04em; margin-bottom: 2px;
}
.form-row { display: flex; gap: 6px; }
.form-row > select, .form-row > input { flex: 1; min-width: 0; }
input[type=range] {
  -webkit-appearance: none; appearance: none; width: 100%; height: 5px;
  border-radius: 3px; background: var(--bg-3); outline: none; margin: 6px 0 2px; transition: background .15s;
}
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none; width: 16px; height: 16px;
  border-radius: 50%; background: var(--accent); border: 2px solid var(--bg-1);
  box-shadow: var(--shadow-sm); cursor: pointer; transition: transform .12s var(--ease);
}
input[type=range]::-webkit-slider-thumb:hover { transform: scale(1.2); }
input[type=range]:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
select {
  font-family: inherit; font-size: .82rem; font-weight: 500;
  background: var(--bg-2); color: var(--fg-0); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 7px 10px; width: 100%; outline: none; transition: border-color .15s;
}
select:focus { border-color: var(--accent); }

/* Composition indicator */
.comp-bar { display: flex; height: 22px; border-radius: 4px; overflow: hidden; margin: 8px 0 6px; gap: 1px; }
.comp-bar .seg { transition: flex .3s var(--ease); border-radius: 2px; display: flex; align-items: center; justify-content: center; min-width: 0; }
.comp-bar .seg span { font-size: .62rem; font-weight: 700; color: #fff; text-shadow: 0 1px 2px rgba(0,0,0,.4); white-space: nowrap; overflow: hidden; }

/* Run button */
.sidebar-footer {
  position: sticky; bottom: 0; z-index: 2; margin-top: auto;
  padding: 10px 0 0; background: var(--bg-1); flex-shrink: 0;
}
.btn-run {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; padding: 12px; background: var(--accent); color: #fff;
  border: none; border-radius: var(--radius);
  font-family: inherit; font-size: .88rem; font-weight: 600;
  cursor: pointer; transition: all .15s var(--ease); box-shadow: var(--shadow-sm);
}
.btn-run:hover { background: var(--accent-dark); box-shadow: var(--shadow-md); transform: translateY(-1px); }
.btn-run:active { transform: translateY(0); }
.btn-run:disabled { opacity: .6; cursor: wait; }
.btn-run .spinner { display: none; width: 16px; height: 16px; border: 2px solid rgba(255,255,255,.3); border-top-color: #fff; border-radius: 50%; animation: spin .6s linear infinite; }
.btn-run.loading .spinner { display: block; }
.btn-run.loading .label { display: none; }
@keyframes spin { to { transform: rotate(360deg); } }

/* V2-specific styles → v2/css/v2.css */

/* Rich game log — AI mode prompt/response details */
.log-entries details.log-entry {
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  margin-bottom: 4px; overflow: hidden;
}
.log-entries details.log-entry summary {
  padding: 6px 10px; cursor: pointer; display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
  font-size: .72rem; transition: background .15s;
}
.log-entries details.log-entry summary:hover { background: var(--bg-2); }
.log-entries details.log-entry[open] summary { background: var(--bg-2); border-bottom: 1px solid var(--border); }
.log-entries .log-detail { padding: 8px 10px; }
.log-entries .log-section { margin-bottom: 8px; }
.log-entries .log-section strong { font-size: .7rem; color: var(--fg-1); }
.log-entries .log-section pre {
  font-size: .68rem; line-height: 1.5; color: var(--fg-2);
  background: var(--bg-2); padding: 8px 10px; border-radius: var(--radius-sm);
  margin-top: 4px; white-space: pre-wrap; word-break: break-word; max-height: 200px; overflow-y: auto;
}
.log-entries .log-error { color: var(--red); }
/* Paradigm switch (navbar) */
.paradigm-switch {
  display: flex; gap: 2px; background: var(--bg-2); border-radius: 8px;
  padding: 2px;
}
.paradigm-btn {
  display: flex; align-items: center; gap: 4px;
  padding: 4px 10px; border: none; border-radius: 6px;
  background: transparent; color: var(--fg-3); font-family: inherit;
  font-size: .72rem; font-weight: 600; cursor: pointer; transition: all .2s var(--ease);
}
.paradigm-btn:hover { color: var(--fg-1); }
.paradigm-btn.active { background: var(--bg-1); color: var(--fg-0); box-shadow: var(--shadow-sm); }
.paradigm-icon { font-size: .82rem; }
.paradigm-label { white-space: nowrap; }

/* ---- View toggle (Chart / Game) ---- */
.view-toggle {
  display: flex; gap: 2px; background: var(--bg-2); border-radius: 8px;
  padding: 2px; margin: 12px 0;
}
.view-toggle-btn {
  display: flex; align-items: center; gap: 4px;
  padding: 6px 14px; border: none; border-radius: 6px;
  background: transparent; color: var(--fg-3); font-family: inherit;
  font-size: .74rem; font-weight: 600; cursor: pointer; transition: all .2s var(--ease);
}
.view-toggle-btn:hover { color: var(--fg-1); }
.view-toggle-btn.active { background: var(--bg-1); color: var(--fg-0); box-shadow: var(--shadow-sm); }

/* ================================================================ Main area */
.main-area { padding: 22px 26px 40px; overflow-y: auto; }

/* KPI cards */
.kpi-row { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; margin-bottom: 22px; }
.kpi {
  background: var(--bg-1); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow-sm);
  transition: box-shadow .15s, transform .15s;
}
.kpi:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.kpi .value { font-size: 1.65rem; font-weight: 700; font-family: 'JetBrains Mono', monospace; line-height: 1.1; }
.kpi .label { font-size: .7rem; font-weight: 500; color: var(--fg-2); text-transform: uppercase; letter-spacing: .05em; margin-top: 4px; }
.kpi .bar { height: 3px; border-radius: 2px; margin-top: 8px; opacity: .6; }

/* Chart grid */
.chart-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.chart-card {
  background: var(--bg-1); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 20px; box-shadow: var(--shadow-sm); transition: box-shadow .2s;
}
.chart-card:hover { box-shadow: var(--shadow-md); }
.chart-card h4 { font-size: .82rem; font-weight: 600; color: var(--fg-1); margin-bottom: 12px; display: flex; align-items: center; gap: 6px; }
.chart-card h4 .dot { width: 8px; height: 8px; border-radius: 50%; }
.chart-dl {
  margin-left: auto; border: 1px solid var(--border); background: var(--bg-2);
  color: var(--fg-3); cursor: pointer; padding: 4px; border-radius: var(--radius-sm);
  line-height: 0; transition: all .15s var(--ease); flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}
.chart-dl:hover { color: var(--accent); border-color: var(--accent); background: var(--accent-light); }
.chart-card .js-plotly-plot { width: 100%; border-radius: var(--radius-sm); }
.chart-card.wide { grid-column: 1 / -1; }
.chart-note { font-size: .68rem; line-height: 1.65; color: var(--fg-3); margin: 0; padding: 10px 12px 0; border-top: 1px solid var(--border); margin-top: 12px; }
.chart-note strong { color: var(--fg-2); }
.note-label { display: inline-flex; align-items: center; gap: 4px; font-weight: 600; font-size: .66rem; margin: 0 1px; }
.note-label::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--c); flex-shrink: 0; }

/* Game log */

.log-card { background: var(--bg-1); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; margin-top: 16px; margin-bottom: 16px; }
.log-card > summary { display: flex; align-items: center; cursor: pointer; list-style: none; user-select: none; }
.log-card > summary::-webkit-details-marker { display: none; }
.log-card > summary::before { content: '\25B6'; font-size: .6rem; color: var(--fg-3); margin-right: 8px; transition: transform .2s; }
.log-card[open] > summary::before { transform: rotate(90deg); }
.log-card > summary h4 { font-size: .78rem; font-weight: 600; color: var(--fg-1); margin: 0; }
.log-toggle-hint { font-size: .65rem; color: var(--fg-3); margin-left: auto; font-weight: 400; }
.log-card[open] .log-toggle-hint { display: none; }
.log-card h4 { font-size: .78rem; font-weight: 600; color: var(--fg-1); margin-bottom: 8px; }
/* Log view tabs */
.log-view-tabs { display: flex; gap: 2px; margin-top: 10px; padding-bottom: 0; }
.log-view-btn {
  padding: 5px 14px; font-size: .65rem; font-weight: 600;
  font-family: 'JetBrains Mono', monospace; text-transform: uppercase; letter-spacing: .06em;
  border: 1px solid var(--border); border-bottom: none; border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  background: var(--bg-2); color: var(--fg-3); cursor: pointer; transition: color .15s, background .15s;
}
.log-view-btn.active { background: var(--bg-1); color: var(--fg-1); border-bottom: 1px solid var(--bg-1); margin-bottom: -1px; position: relative; z-index: 1; }
.log-view-btn:hover:not(.active) { color: var(--fg-2); background: var(--bg-3); }
#log-view-txt { margin-top: 0; border-top: 1px solid var(--border); padding-top: 10px; }
#log-view-3d { border-top: 1px solid var(--border); padding-top: 4px; }
#c-pointcloud { height: 600px; }
.log-entries {
  max-height: 600px; overflow-y: auto; font-family: 'JetBrains Mono', monospace;
  font-size: .72rem; color: var(--fg-2); line-height: 1.7;
}
.log-entries .lie { color: var(--red); }
.log-entries .truth { color: var(--green); }
.log-entries .tag { display: inline-block; font-size: .62rem; font-weight: 600; padding: 1px 5px; border-radius: 3px; vertical-align: middle; }
.log-entries .tag-lie { background: var(--red-bg); color: var(--red); }
.log-entries .tag-truth { background: var(--green-bg); color: var(--green); }
.log-entries .tag-dec { background: var(--amber-bg); color: var(--amber); }
.log-entries .tag-mc { background: var(--purple-bg); color: var(--purple); }

/* ================================================================ Architecture tab */
.arch-wrap { max-width: 1200px; margin: 0 auto; padding: 30px 28px 50px; }
.arch-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.arch-header h2 { font-size: 1.3rem; font-weight: 700; color: var(--fg-0); }
.arch-header p { font-size: .82rem; color: var(--fg-2); margin-top: 4px; }
.btn-drawio {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px; background: var(--bg-2); color: var(--fg-0);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-family: inherit; font-size: .8rem; font-weight: 500;
  cursor: pointer; text-decoration: none; transition: all .15s var(--ease);
}
.btn-drawio:hover { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-drawio svg { width: 16px; height: 16px; }
.arch-svg-container {
  background: var(--bg-1); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 28px; overflow-x: auto; box-shadow: var(--shadow-sm);
}
.arch-svg-container svg { width: 100%; height: auto; display: block; }
.arch-svg-container text { font-family: 'Inter', sans-serif; }

/* ================================================================ Glossary tab */
.glossary-wrap { max-width: 1000px; margin: 0 auto; padding: 30px 28px 50px; }
.glossary-wrap h2 { font-size: 1.3rem; font-weight: 700; margin-bottom: 24px; color: var(--fg-0); }
.gloss-section { margin-bottom: 32px; }
.gloss-section h3 {
  font-size: .9rem; font-weight: 600; color: var(--accent);
  text-transform: uppercase; letter-spacing: .04em;
  padding-bottom: 8px; border-bottom: 2px solid var(--accent-light); margin-bottom: 14px;
}
.gloss-table { width: 100%; border-collapse: collapse; }
.gloss-table th {
  text-align: left; font-size: .72rem; font-weight: 600; color: var(--fg-2);
  text-transform: uppercase; letter-spacing: .05em; padding: 8px 12px;
  border-bottom: 1px solid var(--border); background: var(--bg-2);
}
.gloss-table td {
  padding: 9px 12px; font-size: .82rem; color: var(--fg-1);
  border-bottom: 1px solid var(--border); vertical-align: top;
}
.gloss-table tr:hover td { background: var(--bg-2); }
.gloss-table .term {
  font-family: 'JetBrains Mono', monospace; font-weight: 600; font-size: .8rem;
  color: var(--fg-0); white-space: nowrap;
}
.gloss-table .math {
  font-family: 'JetBrains Mono', monospace; font-size: .78rem; color: var(--purple);
}
.plot-desc { display: flex; gap: 16px; align-items: flex-start; margin-bottom: 16px; }
.plot-desc .plot-icon {
  flex-shrink: 0; width: 48px; height: 36px; border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  font-size: .7rem; font-weight: 700; color: #fff;
}
.plot-desc .plot-info h4 { font-size: .85rem; font-weight: 600; color: var(--fg-0); margin-bottom: 2px; }
.plot-desc .plot-info p { font-size: .78rem; color: var(--fg-2); line-height: 1.55; }

/* ================================================================ Export buttons */
.export-row { display: flex; gap: 8px; margin-bottom: 16px; }
.btn-export {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px; background: var(--bg-2); color: var(--fg-1);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-family: inherit; font-size: .78rem; font-weight: 500;
  cursor: pointer; transition: all .15s var(--ease);
}
.btn-export:hover { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-export svg { width: 14px; height: 14px; }

/* Architecture version toggle */

/* ================================================================ Architecture definitions */
.arch-defs {
  margin-top: 28px;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px;
}
.arch-def-card {
  background: var(--bg-1); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow-sm);
  transition: box-shadow .15s;
}
.arch-def-card:hover { box-shadow: var(--shadow-md); }
.arch-def-card h4 { font-size: .82rem; font-weight: 600; color: var(--accent); margin-bottom: 6px; }
.arch-def-card p { font-size: .78rem; color: var(--fg-2); line-height: 1.55; }
.arch-def-card .formula {
  font-family: 'JetBrains Mono', monospace; font-size: .76rem;
  color: var(--purple); margin-top: 8px; padding: 6px 10px;
  background: var(--bg-2); border-radius: var(--radius-sm);
}

/* ================================================================ Sidebar backdrop */
.sidebar-backdrop { display: none; }

/* ================================================================ Responsive */
@media (max-width: 1100px) { .chart-grid { grid-template-columns: 1fr; } }
@media (max-width: 900px) {
  .app-layout { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; top: 52px; left: 0; bottom: 0; width: 310px;
    z-index: 90; transform: translateX(-100%);
    transition: transform .3s var(--ease);
    border-right: 1px solid var(--border); border-bottom: none;
    background: var(--bg-1); max-height: calc(100vh - 52px); max-height: calc(100dvh - 52px);
    overflow-y: auto; -webkit-overflow-scrolling: touch;
    box-shadow: none; padding-bottom: 60px;
  }
  .sidebar.open { transform: translateX(0); box-shadow: var(--shadow-lg); }
  .sidebar-backdrop.visible {
    display: block; position: fixed; inset: 0; top: 52px;
    background: rgba(0,0,0,.35); z-index: 89; cursor: pointer;
  }
  .mobile-toggle { display: flex; }
  .kpi-row { grid-template-columns: repeat(3, 1fr); }
  .nav-brand { display: none; }
  .nav-hamburger {
    display: flex; align-items: center; justify-content: center;
    width: 30px; height: 30px; border-radius: var(--radius-sm);
    border: 1px solid var(--border); background: var(--bg-2); color: var(--fg-1);
    cursor: pointer; padding: 0; margin-left: auto;
  }
  .nav-hamburger:hover { background: var(--bg-3); border-color: var(--accent); }
  .nav-hamburger svg { width: 16px; height: 16px; }
  .nav-menu.open ~ .nav-hamburger { background: var(--bg-3); border-color: var(--accent); }
  .nav-menu {
    display: none; position: absolute; top: 52px; right: 0;
    flex-direction: column; gap: 12px;
    background: var(--bg-1); border: 1px solid var(--border); border-top: none;
    border-radius: 0 0 var(--radius) var(--radius);
    box-shadow: var(--shadow-md); padding: 14px 16px;
    min-width: 180px; z-index: 99;
  }
  .nav-menu.open { display: flex; }
  .sidebar .panel-body { padding: 10px 12px 12px; }
  .sidebar .form-group { margin-bottom: 8px; }
  .sidebar .form-label { font-size: .74rem; }
  .sidebar .form-hint { font-size: .64rem; }
  .sidebar select { font-size: .74rem; padding: 5px 8px; }
  .sidebar .form-section-title { font-size: .66rem; }
  .sidebar .btn-run { padding: 10px; font-size: .82rem; }
  .arch-defs { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
  .arch-header { flex-direction: column; align-items: flex-start; gap: 12px; }
  .arch-svg-container { padding: 12px; }
  .arch-svg-container svg { width: 100%; min-width: 700px; }
  .gloss-table th, .gloss-table td { padding: 6px 8px; font-size: .76rem; }
}
@media (max-width: 550px) {
  .kpi-row { grid-template-columns: repeat(2, 1fr); }
  .navbar { padding: 0 10px; gap: 8px; }
  .nav-tab { padding: 14px 8px; font-size: .72rem; }
  .main-area { padding: 16px 14px 30px; }
  .view-toggle { margin: 8px 0; }
  .view-toggle-btn { padding: 5px 10px; font-size: .68rem; }
  .arch-wrap { padding: 16px 10px 30px; }
  .glossary-wrap { padding: 16px 10px 30px; }
  .arch-defs { grid-template-columns: 1fr; }
  .arch-header h2 { font-size: 1.1rem; }
  .arch-header p { font-size: .75rem; }
  .arch-svg-container { padding: 8px; }
  .arch-svg-container svg { min-width: 600px; }
  .arch-def-card { padding: 12px 14px; }
  .arch-def-card h4 { font-size: .76rem; }
  .arch-def-card p { font-size: .72rem; }
  .arch-def-card .formula { font-size: .7rem; padding: 4px 8px; }
  .btn-drawio { padding: 6px 12px; font-size: .74rem; }
  .paradigm-switch { gap: 1px; }
  .paradigm-btn { padding: 5px 10px; font-size: .7rem; }
  .paradigm-icon { font-size: .72rem; }
}
