:root {
  --ink: #1a1c1e;
  --panel: #23262a;
  --paper: #f7f4ef;
  --line: #1a1c1e;
  --accent: #c45c26;
  --muted: #8a8f98;
  --soft: #2c3036;
  --font: "Square 721", "Square 721 BT", "Square721 BT", Eurostile, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  background: var(--ink);
  color: #e8eaed;
  font-family: var(--font);
}

body, .btn, .form-control, .form-select, .nav-link, .navbar-brand, .modal, .table {
  font-family: var(--font);
}

.bg-ink { background: var(--ink) !important; }
.bg-panel { background: var(--panel) !important; }

.brand-mark {
  display: inline-block;
  background: var(--accent);
  color: #fff;
  padding: 0.1rem 0.35rem;
  border-radius: 3px;
  margin-right: 0.25rem;
  font-size: 0.85em;
}

.brand-logo {
  height: 32px;
  width: auto;
  max-width: 7.5rem;
  display: block;
  object-fit: contain;
  /* logo artwork is black; invert for dark navbar */
  filter: invert(1);
}

.btn-accent {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.btn-accent:hover {
  background: #a84c1f;
  border-color: #a84c1f;
  color: #fff;
}

.app-shell {
  height: calc(100vh - 56px);
  overflow: hidden;
}

.panel-params {
  background: var(--panel);
  height: 100%;
  overflow-y: auto;
}

.tiny {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin-bottom: 0.2rem;
}

.card-soft {
  background: var(--soft);
  border: 1px solid #3a3f46;
  color: inherit;
}
.card-soft .card-header {
  background: transparent;
  border-bottom: 1px solid #3a3f46;
  padding: 0.4rem 0.75rem;
  color: #cfd3d8;
}

.nav-tabs {
  border-bottom-color: #3a3f46;
}
.nav-tabs .nav-link {
  color: var(--muted);
  border: none;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  padding: 0.4rem 0.25rem;
}
.nav-tabs .nav-link.active {
  background: transparent;
  color: #fff;
  border-bottom-color: var(--accent);
}

.form-control, .form-select {
  background: #1a1c1e;
  border-color: #3a3f46;
  color: #e8eaed;
}
.form-control::placeholder,
.form-select::placeholder {
  color: #9aa0a6;
  opacity: 1;
}
.form-control:focus, .form-select:focus {
  background: #1a1c1e;
  border-color: var(--accent);
  color: #e8eaed;
  box-shadow: 0 0 0 0.15rem rgba(196, 92, 38, 0.25);
}

.stats-bar {
  background: #1e2125;
}
.stat {
  display: flex;
  align-items: baseline;
  gap: 0.35rem;
}
.stat-label {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}
.stat-value {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  font-size: 1.05rem;
}
.stat-value.stat-ok {
  color: #3dd68c;
}
.stat-value.stat-over {
  color: #f07178;
}
.stat-unit {
  font-size: 0.7rem;
  color: var(--muted);
}

.drawing-stage {
  background: #3a3d42;
  overflow: auto;
  position: relative;
  cursor: grab;
}
.drawing-stage.dragging { cursor: grabbing; }

.a4-workspace {
  min-height: 100%;
  min-width: 100%;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 28px 24px 48px;
  box-sizing: border-box;
}

.a4-page {
  --a4-w: 210mm;
  --a4-h: 297mm;
  width: min(100%, calc((100vh - 160px) * 210 / 297), 720px);
  aspect-ratio: 210 / 297;
  height: auto;
  background: var(--paper, #fff);
  box-shadow:
    0 1px 2px rgba(0, 0, 0, 0.2),
    0 12px 40px rgba(0, 0, 0, 0.35);
  position: relative;
  flex-shrink: 0;
  transform-origin: center top;
  border: 1px solid rgba(0, 0, 0, 0.12);
}

.a4-page.theme-blueprint {
  background-image:
    linear-gradient(rgba(255,255,255,0.12) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.12) 1px, transparent 1px);
  background-size: 12px 12px;
}

.a4-safe {
  position: absolute;
  left: 30mm;
  right: 30mm;
  top: 8mm;
  bottom: 8mm;
  border: 1px dashed rgba(0, 0, 0, 0.12);
  box-sizing: border-box;
  overflow: hidden;
}
.a4-page.is-dark .a4-safe {
  border-color: rgba(255, 255, 255, 0.18);
}

#planSvg {
  display: block;
  width: 100%;
  height: 100%;
  background: transparent;
}

/* Fallback line styles (SVG also embeds theme CSS for PDF). --line-scale from Line slider. */
#planSvg .outline { fill: none; stroke: var(--draw-line, #1a1c1e); stroke-width: calc(1.4 * var(--line-scale, 1)); }
#planSvg .structure { fill: none; stroke: var(--draw-line, #1a1c1e); stroke-width: calc(0.7 * var(--line-scale, 1)); stroke-dasharray: 3 2; }
#planSvg .dim { fill: none; stroke: var(--draw-line, #1a1c1e); stroke-width: calc(0.5 * var(--line-scale, 1)); }
#planSvg .dim-text { fill: var(--draw-line, #1a1c1e); font-family: var(--font); font-size: 11px; }
#planSvg .title-text {
  fill: var(--draw-line, #1a1c1e);
  font-family: var(--font);
  font-style: normal;
  font-weight: 700;
}
#planSvg .label-text { fill: var(--draw-muted, #1a1c1e); font-family: var(--font); font-size: 2.4px; }
#planSvg .data-block-text { fill: var(--draw-line, #1a1c1e); font-family: var(--font); font-size: 3.5px; }
#planSvg .dim-text { fill: var(--draw-line, #1a1c1e); font-family: var(--font); font-size: 2.6px; }
#planSvg #planInner .dim-text { font-size: 11px; }
#planSvg #planInner .label-text { font-size: 10px; }
#planSvg .xpt { fill: none; stroke: var(--draw-line, #1a1c1e); stroke-linecap: round; stroke-linejoin: round; }
#planSvg .hatch { fill: none; stroke: var(--draw-line, #1a1c1e); stroke-width: calc(0.4 * var(--line-scale, 1)); }
#planSvg .fill-foam { fill: var(--draw-fill, #e8e4dc); stroke: var(--draw-line, #1a1c1e); stroke-width: calc(0.6 * var(--line-scale, 1)); }
#planSvg .fill-carbon90 { fill: url(#carbon90Fill); stroke: none; opacity: 0.92; }
#planSvg .fill-carbon45 { fill: url(#carbon45Fill); stroke: none; opacity: 0.92; }
#planSvg .fill-carbonHatch { fill: url(#carbonHatchFill); stroke: none; opacity: 0.85; }
#planSvg .fill-carbonTow { fill: url(#carbonTowFill); stroke: none; opacity: 0.92; }
#planSvg .fill-wingCarbon { fill: url(#wingCarbonFill); stroke: none; opacity: 0.9; }
#planSvg .spar-fill { fill: var(--draw-line, #1a1c1e); }

.profile-card {
  background: var(--soft);
  border: 1px solid #3a3f46;
  border-radius: 0.35rem;
  padding: 0.6rem 0.75rem;
  margin-bottom: 0.5rem;
}
.profile-card .thumb {
  width: 64px;
  height: 36px;
  object-fit: contain;
  background: var(--paper);
  border-radius: 2px;
}

.nose-thumb {
  width: 120px;
  height: 48px;
  object-fit: contain;
  background: var(--paper);
  border-radius: 3px;
  border: 1px solid #3a3f46;
  flex-shrink: 0;
}

#libraryTable {
  --bs-table-bg: transparent;
  --bs-table-color: #e8eaed;
  --bs-table-border-color: #3a3f46;
}
#libraryTable tbody tr:hover {
  background: rgba(255, 255, 255, 0.04);
}

.profile-canvas-wrap {
  background: var(--paper);
  border: 1px solid #3a3f46;
  border-radius: 0.35rem;
  overflow: auto;
  max-height: 420px;
}
#profCanvas {
  display: block;
  max-width: 100%;
  cursor: crosshair;
}

.panel-row {
  background: var(--soft);
  border: 1px solid #3a3f46;
  border-radius: 0.35rem;
  padding: 0.5rem 0.65rem;
  margin-bottom: 0.4rem;
}

.navbar-more-menu {
  min-width: 12.5rem;
}
.navbar-more-menu .form-range {
  accent-color: var(--accent);
}

@media (max-width: 991px) {
  .app-shell { height: auto; overflow: visible; }
  .panel-params { height: auto; max-height: 50vh; }
  .drawing-stage { min-height: 60vh; }
}
