:root {
  color-scheme: light;
  --bg: #f2f4f7;
  --bg-alt: #eaecf0;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --text: #101828;
  --muted: #667085;
  --primary: #2563eb;
  --primary-strong: #1d4ed8;
  --accent: #0f766e;
  --danger: #b42318;
  --warning: #b54708;
  --success: #067647;
  --border: #d0d5dd;
  --border-strong: #98a2b3;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.08);
  --sidebar-bg: #171a21;
  --sidebar-bg-2: #171a21;
  --sidebar-text: #f2f4f7;
  --sidebar-muted: #98a2b3;
  --line-strong: #475467;
  --grid-line: rgba(91, 116, 139, 0.28);
  --model-bg: #eef2f6;
  --model-vertical: #506679;
  --model-horizontal: #8ca2b7;
  --model-brace: #c99325;
  --model-deck: #d3b34c;
  --frame-main: #24438f;
  --frame-horizontal: #3157ad;
  --frame-brace: #3552a4;
  --frame-pin: #dc5a3f;
  --model-grid-major: #98aebe;
  --model-grid-minor: #d4dee8;
  --radius: 4px;
  --sidebar-width: 220px;
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0d1117;
  --bg-alt: #11161d;
  --surface: #161b22;
  --surface-soft: #1c2128;
  --text: #f0f3f6;
  --muted: #9da7b3;
  --primary: #4c82fb;
  --primary-strong: #316dca;
  --accent: #2dd4bf;
  --danger: #ff7b72;
  --warning: #d29922;
  --success: #3fb950;
  --border: #30363d;
  --border-strong: #57606a;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
  --sidebar-bg: #11151b;
  --sidebar-bg-2: #11151b;
  --sidebar-text: #f0f3f6;
  --sidebar-muted: #8b949e;
  --line-strong: #b1bac4;
  --grid-line: rgba(154, 178, 196, 0.24);
  --model-bg: #101d2b;
  --model-vertical: #a9b9c8;
  --model-horizontal: #708ba2;
  --model-brace: #dcb253;
  --model-deck: #c6a940;
  --frame-main: #6f91e8;
  --frame-horizontal: #88a7f0;
  --frame-brace: #748fdc;
  --frame-pin: #ff8068;
  --model-grid-major: #3d596f;
  --model-grid-minor: #22394c;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
  overflow-x: hidden;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background: var(--bg);
  font-family: "Leelawadee UI", "Noto Sans Thai", Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
  line-height: 1.45;
  overflow-x: hidden;
  transition: background-color 180ms ease, color 180ms ease;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
a:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--primary) 55%, transparent);
  outline-offset: 2px;
}

button[aria-busy="true"] {
  cursor: wait;
  opacity: 0.74;
}

[hidden] {
  display: none !important;
}

.skip-link {
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 100;
  transform: translateY(-160%);
  padding: 10px 14px;
  border-radius: var(--radius);
  color: var(--surface);
  background: var(--primary-strong);
  text-decoration: none;
}

.skip-link:focus {
  transform: translateY(0);
}

.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  height: 100vh;
  padding: 18px 14px;
  color: var(--sidebar-text);
  background: var(--sidebar-bg);
  border-right: 1px solid rgba(255, 255, 255, 0.09);
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  min-height: 52px;
  margin-bottom: 18px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: var(--radius);
  color: #0d2d4d;
  background: var(--primary);
  font-weight: 900;
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  font-size: 14px;
}

.brand small {
  color: var(--sidebar-muted);
  font-size: 12px;
}

.nav-list {
  display: grid;
  gap: 5px;
}

.nav-item {
  display: grid;
  grid-template-columns: 30px 1fr;
  align-items: center;
  width: 100%;
  min-height: 38px;
  padding: 7px 8px;
  border: 0;
  border-radius: var(--radius);
  color: var(--sidebar-text);
  background: transparent;
  text-align: left;
  transition: background-color 160ms ease, transform 160ms ease;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.1);
}

.nav-item.is-active {
  background: rgba(37, 99, 235, 0.2);
  box-shadow: none;
}

.nav-item span {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 6px;
  color: #dff6ff;
  background: rgba(255, 255, 255, 0.09);
  font-size: 10px;
  font-weight: 800;
}

.nav-item b {
  overflow: hidden;
  font-size: 13px;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-footer {
  display: grid;
  gap: 12px;
  margin-top: auto;
}

.theme-switcher,
.segmented {
  display: inline-grid;
  grid-auto-flow: column;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-soft);
}

.sidebar .theme-switcher {
  border-color: rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.08);
}

.theme-switcher button,
.segmented button {
  min-height: 30px;
  padding: 4px 10px;
  border: 0;
  border-radius: 6px;
  color: var(--muted);
  background: transparent;
  font-size: 12px;
  font-weight: 700;
}

.sidebar .theme-switcher button {
  color: var(--sidebar-muted);
}

.theme-switcher button.is-active,
.segmented button.is-active {
  color: #ffffff;
  background: var(--primary-strong);
}

.top-theme {
  display: none;
}

.primary-action,
.secondary-action,
.export-button {
  min-height: 38px;
  padding: 9px 13px;
  border-radius: var(--radius);
  font-weight: 750;
  transition: transform 160ms ease, box-shadow 160ms ease, background-color 160ms ease;
}

.primary-action {
  border: 0;
  color: #ffffff;
  background: var(--primary-strong);
  box-shadow: none;
}

.secondary-action {
  border: 1px solid var(--border);
  color: var(--text);
  background: var(--surface);
}

.primary-action:hover,
.secondary-action:hover,
.export-button:hover {
  transform: none;
}

.main {
  min-width: 0;
  padding: 22px;
}

.topbar {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) auto auto;
  gap: 16px;
  align-items: center;
  margin-bottom: 14px;
}

.topbar > *,
.page-heading > * {
  min-width: 0;
}

.eyebrow {
  margin: 0 0 3px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 850;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
  overflow-wrap: anywhere;
}

h1 {
  margin-bottom: 0;
  font-size: 28px;
  line-height: 1.15;
}

h2 {
  margin-bottom: 0;
  font-size: 22px;
  line-height: 1.2;
}

h3 {
  margin-bottom: 14px;
  font-size: 15px;
}

.topbar-meta {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  max-width: 720px;
}

.topbar-meta span,
.source-pill {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 5px 9px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--muted);
  background: color-mix(in srgb, var(--surface) 86%, transparent);
  font-size: 12px;
  font-weight: 700;
  overflow-wrap: anywhere;
  white-space: normal;
}

.safety-banner {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  align-items: start;
  margin-bottom: 14px;
  padding: 13px 15px;
  border: 1px solid color-mix(in srgb, var(--warning) 38%, var(--border));
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--warning) 10%, var(--surface));
}

.safety-banner strong {
  display: block;
  margin-bottom: 3px;
  color: var(--warning);
}

.safety-banner p {
  margin: 0;
  color: var(--text);
  font-size: 13px;
  word-break: break-word;
}

.page {
  display: none;
}

.page.is-active {
  display: block;
}

.page-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: 10px 0 14px;
}

.action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.panel {
  min-width: 0;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  box-shadow: var(--shadow);
}

.panel-heading {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 10px;
}

.dashboard-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(280px, 0.9fr) minmax(260px, 0.65fr);
  gap: 14px;
  align-items: start;
}

.project-overview {
  display: grid;
  gap: 14px;
}

.overview-title {
  display: grid;
  grid-template-columns: 1.3fr 0.8fr;
  gap: 10px;
}

.overview-title span,
.metric-card span,
label span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.overview-title strong {
  display: block;
  margin-top: 2px;
  font-size: 18px;
}

.summary-list {
  display: grid;
  gap: 8px;
  margin: 0;
}

.summary-list div {
  display: grid;
  grid-template-columns: minmax(120px, 0.7fr) minmax(0, 1fr);
  gap: 10px;
  padding: 9px 0;
  border-bottom: 1px solid var(--border);
}

.summary-list div:last-child {
  border-bottom: 0;
}

.summary-list dt {
  color: var(--muted);
  font-weight: 700;
}

.summary-list dd {
  margin: 0;
  font-weight: 800;
}

.metric-grid {
  display: grid;
  gap: 10px;
}

.metric-grid.wide {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.metric-grid.tight {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.metric-card {
  min-height: 80px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-soft);
}

.metric-card strong {
  display: block;
  margin-top: 5px;
  color: var(--text);
  font-size: 21px;
  line-height: 1.1;
  overflow-wrap: anywhere;
}

.metric-card small {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 11px;
}

.form-grid,
.settings-form {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  align-items: start;
}

.settings-form {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.form-section {
  display: grid;
  gap: 12px;
}

.form-section label,
.compact-inputs label,
.settings-form label {
  display: grid;
  gap: 6px;
}

.two-column,
.service-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

input,
select,
textarea {
  width: 100%;
  min-height: 38px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  background: var(--surface);
  transition: border-color 160ms ease, box-shadow 160ms ease, background-color 160ms ease;
}

textarea {
  resize: vertical;
}

input:hover,
select:hover,
textarea:hover {
  border-color: var(--border-strong);
}

.check-row {
  grid-template-columns: 18px 1fr;
  align-items: center;
  min-height: 34px;
}

.check-row input {
  width: 18px;
  min-height: 18px;
  accent-color: var(--primary);
}

.form-warning {
  margin: 0;
  padding: 10px;
  border: 1px solid color-mix(in srgb, var(--danger) 40%, var(--border));
  border-radius: var(--radius);
  color: var(--danger);
  background: color-mix(in srgb, var(--danger) 10%, var(--surface));
  font-size: 13px;
}

.workspace-grid {
  display: grid;
  grid-template-columns: 270px minmax(0, 1fr);
  grid-template-areas:
    "inputs preview"
    "summary summary";
  gap: 14px;
  align-items: start;
}

.compact-inputs {
  grid-area: inputs;
  display: grid;
  align-content: start;
  gap: 10px;
}

.scaffold-color-field {
  display: grid;
  gap: 8px;
  min-width: 0;
  padding: 0;
  border: 0;
}

.scaffold-color-field legend {
  padding: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.color-picker-row {
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
}

input[type="color"] {
  width: 46px;
  height: 38px;
  min-height: 38px;
  padding: 3px;
  cursor: pointer;
}

.color-picker-row output {
  min-width: 0;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  background: var(--surface-soft);
  font-size: 12px;
  font-weight: 800;
  line-height: 20px;
}

.color-swatches {
  display: grid;
  grid-template-columns: repeat(7, 28px);
  gap: 7px;
  align-items: center;
}

.color-swatch {
  width: 28px;
  height: 28px;
  padding: 0;
  border: 2px solid var(--surface);
  border-radius: 50%;
  background: var(--swatch);
  box-shadow: 0 0 0 1px var(--border-strong);
}

.color-swatch[aria-pressed="true"] {
  box-shadow: 0 0 0 3px var(--primary);
}

.preview-panel {
  grid-area: preview;
  display: grid;
  grid-template-rows: auto minmax(520px, 1fr);
  min-height: 700px;
}

.schematic-canvas,
.weight-chart,
.fallback-model {
  display: block;
  width: 100%;
  min-height: 280px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.schematic-canvas.large {
  min-height: 520px;
}

.model-view,
.full-model {
  position: relative;
  width: 100%;
  height: clamp(560px, 68vh, 760px);
  min-height: 600px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--model-bg);
}

.model-view canvas,
.full-model canvas {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  cursor: grab;
  touch-action: none;
  user-select: none;
}

.model-view canvas.is-dragging,
.full-model canvas.is-dragging {
  cursor: grabbing;
}

.model-view .fallback-model,
.full-model .fallback-model {
  min-height: 0;
  border: 0;
}

.full-model {
  height: calc(100vh - 230px);
  min-height: calc(100vh - 230px);
}

.empty-cell {
  padding: 28px 12px;
  color: var(--muted);
  text-align: center;
}

button:disabled,
button[aria-disabled="true"] {
  cursor: not-allowed;
  opacity: 0.48;
}

.model-loading {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-weight: 800;
}

.model-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.model-controls button {
  display: grid;
  place-items: center;
  min-width: 34px;
  min-height: 34px;
  padding: 6px 9px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  background: var(--surface);
  font-size: 12px;
  font-weight: 850;
}

.summary-panel {
  grid-area: summary;
  display: grid;
  align-content: start;
  gap: 12px;
}

.summary-panel .metric-grid.tight {
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
}

.status-list {
  display: grid;
  gap: 8px;
  padding: 0;
  margin: 0;
  list-style: none;
}

.status-line {
  display: grid;
  grid-template-columns: 12px 1fr;
  gap: 8px;
  align-items: start;
  padding: 9px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-soft);
}

.status-line span {
  width: 9px;
  height: 9px;
  margin-top: 6px;
  border-radius: 999px;
  background: var(--warning);
}

.status-line p {
  margin: 0;
  font-size: 13px;
}

.status-line.success span {
  background: var(--success);
}

.status-line.danger span {
  background: var(--danger);
}

.status-line.warning span {
  background: var(--warning);
}

.calculation-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.formula-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding-left: 20px;
}

.formula-list li {
  padding-left: 2px;
}

.materials-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 14px;
  align-items: start;
}

.table-wrap {
  width: 100%;
  margin-top: 14px;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

table {
  width: 100%;
  min-width: 860px;
  border-collapse: collapse;
  background: var(--surface);
}

.compact-table table {
  min-width: 520px;
}

th,
td {
  padding: 10px 11px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}

thead th {
  color: var(--muted);
  background: var(--surface-soft);
  font-size: 12px;
  font-weight: 850;
}

tbody th {
  font-weight: 780;
}

tbody tr:hover {
  background: color-mix(in srgb, var(--primary) 6%, transparent);
}

.chart-panel {
  display: grid;
  gap: 12px;
}

.chart-legend {
  display: grid;
  gap: 7px;
  padding: 0;
  margin: 0;
  list-style: none;
}

.chart-legend li {
  display: grid;
  grid-template-columns: 12px minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  font-size: 13px;
}

.chart-legend span {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--swatch);
}

.chart-legend em {
  color: var(--muted);
  font-style: normal;
  font-weight: 800;
}

.export-layout {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}

.export-actions {
  display: grid;
  gap: 10px;
}

.export-button {
  min-height: 52px;
  border: 0;
  color: #ffffff;
}

.export-button.pdf {
  background: #d64b41;
}

.export-button.excel {
  background: #148a55;
}

.export-button.json {
  background: #344154;
}

.export-button.print {
  background: #2774c9;
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 80;
  max-width: min(420px, calc(100vw - 32px));
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  background: var(--surface);
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(16px);
  pointer-events: none;
  transition: opacity 180ms ease, transform 180ms ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.toast[data-type="success"] {
  border-color: color-mix(in srgb, var(--success) 45%, var(--border));
}

.toast[data-type="warning"] {
  border-color: color-mix(in srgb, var(--warning) 45%, var(--border));
}

/* Commercial engineering workbench */
.icon-sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

.ui-icon {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.sidebar {
  padding: 0 12px 14px;
  background: var(--sidebar-bg);
  border-right-color: #252a33;
}

.brand {
  min-height: 70px;
  margin: 0 0 12px;
  padding: 0 6px;
  border-bottom: 1px solid #2d333d;
}

.brand-mark {
  width: 36px;
  height: 36px;
  border: 1px solid #4b5563;
  border-radius: 3px;
  color: #ffffff;
  background: #2563eb;
  font-size: 12px;
  letter-spacing: 0;
}

.brand strong {
  font-size: 13px;
  font-weight: 750;
}

.brand small {
  margin-top: 1px;
  font-size: 10px;
  letter-spacing: 0;
  text-transform: uppercase;
}

.nav-list {
  gap: 2px;
}

.nav-item {
  position: relative;
  grid-template-columns: 22px minmax(0, 1fr);
  gap: 9px;
  min-height: 40px;
  padding: 8px 10px;
  border: 1px solid transparent;
  border-radius: 3px;
  color: #b8c0cc;
  transition: color 120ms ease, background-color 120ms ease, border-color 120ms ease;
}

.nav-item:hover {
  color: #ffffff;
  background: #20252e;
  border-color: #303743;
}

.nav-item.is-active {
  color: #ffffff;
  background: #263247;
  border-color: #34496a;
  box-shadow: inset 3px 0 0 #4c82fb;
}

.nav-item b {
  font-size: 12px;
  font-weight: 650;
}

.sidebar-footer {
  gap: 10px;
  padding-top: 14px;
  border-top: 1px solid #2d333d;
}

.theme-switcher,
.segmented {
  gap: 2px;
  padding: 2px;
  border-radius: 3px;
}

.sidebar .theme-switcher {
  grid-template-columns: repeat(3, 1fr);
  border-color: #343b46;
  background: #20252d;
}

.theme-switcher button,
.segmented button {
  display: grid;
  place-items: center;
  min-width: 32px;
  min-height: 30px;
  padding: 4px 9px;
  border-radius: 2px;
  font-size: 11px;
}

.theme-switcher button.is-active,
.segmented button.is-active {
  color: #ffffff;
  background: var(--primary-strong);
  box-shadow: none;
}

.primary-action,
.secondary-action,
.export-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 36px;
  padding: 7px 12px;
  border-radius: 3px;
  font-size: 13px;
  font-weight: 700;
  transition: background-color 120ms ease, border-color 120ms ease, color 120ms ease;
}

.primary-action {
  border: 1px solid var(--primary-strong);
  background: var(--primary-strong);
  box-shadow: none;
}

.primary-action:hover {
  background: color-mix(in srgb, var(--primary-strong) 88%, #000000);
}

.secondary-action {
  border-color: var(--border);
  background: var(--surface);
}

.secondary-action:hover {
  border-color: var(--border-strong);
  background: var(--surface-soft);
}

.primary-action:hover,
.secondary-action:hover,
.export-button:hover {
  transform: none;
}

.main {
  padding: 0 24px 32px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 60;
  grid-template-columns: minmax(230px, 0.75fr) minmax(460px, 1.25fr) auto;
  gap: 18px;
  min-height: 72px;
  margin: 0 -24px 14px;
  padding: 10px 24px;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface) 96%, transparent);
  backdrop-filter: blur(12px);
}

.topbar-title {
  min-width: 0;
}

.eyebrow {
  margin-bottom: 2px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 750;
  letter-spacing: 0;
}

h1 {
  font-size: 20px;
  font-weight: 750;
  line-height: 1.2;
}

h2 {
  font-size: 19px;
  font-weight: 750;
}

h3 {
  font-size: 13px;
  font-weight: 750;
}

.topbar-meta {
  display: grid;
  grid-template-columns: minmax(130px, 1fr) minmax(150px, 1fr) minmax(115px, auto) auto;
  gap: 0;
  width: 100%;
  max-width: 780px;
  border: 1px solid var(--border);
  border-radius: 3px;
  background: var(--surface-soft);
}

.topbar-meta .meta-item,
.topbar-meta .status-badge {
  display: grid;
  align-content: center;
  min-width: 0;
  min-height: 42px;
  padding: 5px 10px;
  border: 0;
  border-right: 1px solid var(--border);
  border-radius: 0;
  background: transparent;
  overflow: hidden;
}

.topbar-meta .meta-item small {
  color: var(--muted);
  font-size: 9px;
  font-weight: 700;
  line-height: 1.2;
  text-transform: uppercase;
}

.topbar-meta .meta-item strong {
  overflow: hidden;
  color: var(--text);
  font-size: 11px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar-meta .status-badge {
  grid-template-columns: 8px minmax(0, 1fr);
  gap: 7px;
  align-items: center;
  border-right: 0;
  color: var(--success);
}

.status-badge i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 0 3px color-mix(in srgb, currentColor 14%, transparent);
}

.status-badge strong {
  color: var(--text);
  font-size: 10px;
  white-space: nowrap;
}

.safety-banner {
  grid-template-columns: 20px minmax(0, 1fr) auto;
  gap: 10px;
  margin-bottom: 14px;
  padding: 10px 12px;
  border: 1px solid color-mix(in srgb, var(--warning) 42%, var(--border));
  border-left: 3px solid var(--warning);
  border-radius: 3px;
  background: color-mix(in srgb, var(--warning) 7%, var(--surface));
}

.safety-icon {
  width: 18px;
  height: 18px;
  margin-top: 1px;
  color: var(--warning);
}

.safety-banner strong {
  margin-bottom: 1px;
  color: var(--text);
  font-size: 12px;
}

.safety-banner p {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.4;
}

.source-pill {
  align-self: center;
  min-height: 24px;
  padding: 3px 7px;
  border-radius: 2px;
  font-size: 10px;
  font-weight: 650;
}

.page-heading {
  min-height: 50px;
  margin: 0 0 14px;
  padding: 8px 0 11px;
  border-bottom: 1px solid var(--border);
}

.page-heading .eyebrow {
  color: var(--primary);
}

.panel {
  padding: 14px;
  border-radius: 4px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.panel-heading {
  min-height: 36px;
  margin: -4px 0 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.panel-heading h3 {
  margin: 0;
}

.panel > h3:first-child,
.form-section > h3:first-child {
  margin: -14px -14px 12px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-soft);
  font-size: 11px;
  letter-spacing: 0;
  text-transform: uppercase;
}

.dashboard-layout,
.form-grid,
.calculation-grid,
.materials-layout,
.export-layout {
  gap: 12px;
}

.overview-title {
  gap: 0;
  border: 1px solid var(--border);
  border-radius: 3px;
}

.overview-title > div {
  padding: 9px 11px;
}

.overview-title > div + div {
  border-left: 1px solid var(--border);
}

.overview-title strong {
  font-size: 15px;
}

.metric-grid {
  gap: 8px;
}

.metric-card {
  min-height: 72px;
  padding: 10px 11px;
  border-radius: 3px;
  background: var(--surface);
  box-shadow: none;
}

.metric-card span,
.overview-title span,
label span {
  font-size: 11px;
  font-weight: 650;
}

.metric-card strong {
  margin-top: 4px;
  color: var(--text);
  font-size: 18px;
  font-variant-numeric: tabular-nums;
}

.metric-card small {
  font-size: 10px;
}

.form-section {
  gap: 10px;
}

.form-section label,
.compact-inputs label,
.settings-form label {
  gap: 4px;
}

input,
select,
textarea {
  min-height: 36px;
  padding: 7px 9px;
  border-radius: 3px;
  font-size: 13px;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--primary) 14%, transparent);
}

.check-row {
  min-height: 32px;
  padding: 4px 0;
}

.check-row input {
  width: 16px;
  min-height: 16px;
}

.workspace-grid {
  grid-template-columns: 290px minmax(0, 1fr);
  gap: 12px;
}

.compact-inputs {
  gap: 8px;
}

.scaffold-color-field {
  padding-top: 2px;
}

.color-picker-row output {
  border-radius: 3px;
  font-variant-numeric: tabular-nums;
}

.color-swatch {
  border-radius: 50%;
  box-shadow: 0 0 0 1px var(--border-strong);
}

.color-swatch[aria-pressed="true"] {
  box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--primary);
}

.preview-panel {
  min-height: 680px;
}

.schematic-canvas,
.weight-chart,
.fallback-model,
.model-view,
.full-model {
  border-radius: 3px;
}

.model-view,
.full-model {
  border-color: var(--border-strong);
}

.model-controls {
  gap: 4px;
}

.model-controls button {
  min-width: 32px;
  min-height: 32px;
  padding: 4px 8px;
  border-radius: 3px;
  font-size: 12px;
  font-weight: 750;
}

.model-controls button:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: color-mix(in srgb, var(--primary) 6%, var(--surface));
}

.summary-panel .metric-grid.tight {
  gap: 0;
  border: 1px solid var(--border);
  border-radius: 3px;
}

.summary-panel .metric-card {
  border: 0;
  border-right: 1px solid var(--border);
  border-radius: 0;
}

.summary-panel .metric-card:last-child {
  border-right: 0;
}

.status-list {
  gap: 5px;
}

.status-line {
  grid-template-columns: 8px 1fr;
  gap: 8px;
  padding: 7px 9px;
  border-radius: 3px;
  background: var(--surface);
}

.status-line span {
  width: 6px;
  height: 6px;
  margin-top: 6px;
}

.status-line p {
  font-size: 12px;
}

.table-wrap {
  border-radius: 3px;
}

th,
td {
  padding: 8px 10px;
  font-size: 12px;
}

thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  font-size: 10px;
  letter-spacing: 0;
  text-transform: uppercase;
}

tbody tr:nth-child(even) {
  background: color-mix(in srgb, var(--surface-soft) 58%, transparent);
}

.export-button {
  min-height: 44px;
  border: 1px solid transparent;
}

.toast {
  border-radius: 3px;
  box-shadow: 0 8px 24px rgba(16, 24, 40, 0.16);
}

@media (max-width: 1220px) {
  .dashboard-layout,
  .workspace-grid,
  .materials-layout,
  .export-layout {
    grid-template-columns: 1fr;
  }

  .preview-panel,
  .model-view {
    min-height: 520px;
  }

  .workspace-grid {
    grid-template-areas:
      "inputs"
      "preview"
      "summary";
  }

  .form-grid,
  .settings-form,
  .calculation-grid {
    grid-template-columns: 1fr;
  }
}

@media (min-width: 700px) and (max-width: 1220px) {
  .compact-inputs {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .compact-inputs h3,
  .compact-inputs .scaffold-color-field,
  .compact-inputs .primary-action,
  .compact-inputs .form-warning {
    grid-column: 1 / -1;
  }
}

@media (max-width: 1080px) {
  .app-shell {
    display: block;
    width: 100vw;
    overflow-x: hidden;
  }

  .sidebar {
    position: fixed;
    top: auto;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 70;
    display: block;
    height: auto;
    padding: 6px 8px;
    border-top: 1px solid #303641;
    border-right: 0;
  }

  .brand,
  .sidebar-footer {
    display: none;
  }

  .nav-list {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: minmax(74px, 1fr);
    gap: 2px;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scrollbar-width: none;
  }

  .nav-list::-webkit-scrollbar {
    display: none;
  }

  .nav-item {
    grid-template-columns: 1fr;
    justify-items: center;
    gap: 2px;
    min-height: 58px;
    padding: 5px 6px;
    text-align: center;
  }

  .nav-item .ui-icon {
    width: 19px;
    height: 19px;
  }

  .nav-item b {
    max-width: 72px;
    font-size: 11px;
  }

  .main {
    padding: 0 12px 92px;
    max-width: 100vw;
    overflow-x: hidden;
  }

  .topbar {
    position: relative;
    z-index: 1;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px 12px;
    min-height: 0;
    margin: 0 -12px 12px;
    padding: 10px 12px;
  }

  .topbar-title {
    grid-column: 1;
    grid-row: 1;
  }

  .topbar-meta {
    grid-column: 1 / -1;
    grid-row: 2;
    grid-template-columns: minmax(150px, 1fr) minmax(170px, 1fr) minmax(130px, auto) minmax(110px, auto);
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
  }

  .topbar-meta span,
  .source-pill {
    width: auto;
    max-width: none;
    justify-content: flex-start;
  }

  .top-theme {
    display: inline-grid;
    grid-column: 2;
    grid-row: 1;
    justify-self: end;
    align-self: center;
    width: auto;
    max-width: none;
  }

  h1 {
    font-size: 18px;
  }

  h2 {
    font-size: 18px;
  }

  .safety-banner,
  .overview-title,
  .page-heading {
    grid-template-columns: 1fr;
  }

  .safety-banner {
    display: grid;
    grid-template-columns: 20px minmax(0, 1fr);
  }

  .safety-banner .source-pill {
    grid-column: 2;
    justify-self: start;
  }

  .page-heading {
    align-items: center;
    flex-direction: row;
  }

  .page-heading > * {
    width: auto;
    max-width: 100%;
  }

  .page-heading > div:first-child {
    flex: 1 1 auto;
  }

  .page-heading .segmented {
    flex: 0 0 auto;
    min-width: 150px;
  }

  .metric-grid.wide,
  .two-column,
  .service-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .preview-panel {
    grid-template-rows: auto minmax(430px, 1fr);
    height: auto;
    min-height: 0;
  }

  .model-view,
  .full-model {
    height: 430px;
    min-height: 430px;
  }

  .schematic-canvas.large {
    min-height: 420px;
  }
}

@media (max-width: 520px) {
  body {
    font-size: 14px;
  }

  .sidebar {
    padding-inline: 4px;
  }

  .nav-list {
    grid-auto-flow: row;
    grid-auto-columns: auto;
    grid-template-columns: repeat(8, minmax(0, 1fr));
    gap: 0;
    overflow-x: hidden;
  }

  .nav-item {
    min-height: 52px;
    min-width: 0;
    padding: 4px 0;
    border-radius: 0;
  }

  .nav-item.is-active {
    box-shadow: inset 0 3px 0 #4c82fb;
  }

  .nav-item b {
    display: none;
  }

  .panel {
    padding: 12px;
  }

  .topbar-meta span {
    max-width: 100%;
  }

  .theme-switcher {
    grid-auto-flow: column;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    width: 100%;
  }

  .theme-switcher button {
    min-width: 0;
    padding-inline: 6px;
  }

  .top-theme {
    width: auto;
    max-width: none;
  }

  .topbar-title .eyebrow {
    display: none;
  }

  .topbar-meta {
    grid-template-columns: repeat(2, minmax(150px, 1fr));
  }

  .action-row,
  .model-controls {
    width: 100%;
    max-width: 366px;
  }

  .page-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .page-heading > *,
  .page-heading .segmented {
    width: 100%;
  }

  .preview-panel .panel-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .metric-grid.wide,
  .metric-grid.tight,
  .two-column,
  .service-grid {
    grid-template-columns: 1fr;
  }

  .safety-banner {
    grid-template-columns: 18px minmax(0, 1fr);
  }

  .model-controls {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }

  .action-row > *,
  .model-controls button {
    min-width: 0;
    flex: 1 1 auto;
  }

  .export-layout {
    grid-template-columns: 1fr;
  }
}

@media print {
  .sidebar,
  .topbar,
  .safety-banner,
  .page-heading,
  .toast {
    display: none !important;
  }

  .app-shell,
  .main,
  .page.is-active {
    display: block;
    padding: 0;
  }

  .panel {
    box-shadow: none;
    break-inside: avoid;
  }
}
