/* /public/styles.css — mobile-first responsive design */

/* ── Custom properties ────────────────────────────────────── */
:root {
  --bg: #101b2b;
  --surface: #172538;
  --surface2:  #263348;
  --border: #3b5069;
  --text: #f0f5fa;
  --text-dim: #b9c9d9;
  --text-hint: #a6b8ca;
  --accent: #85c5ff;
  --accent-h: #b0d9ff;
  --pass:      #22c55e;
  --warn:      #f59e0b;
  --fail:      #ef4444;
  --radius: 9px;
  --radius-lg: 14px;
  --gap: 10px;
  --gap-lg: 18px;
  --top-bar-h: 60px;
  --sheet-h:   auto;
  --panel-w: 350px;
  --rail-w: 68px;
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  color-scheme: dark;
}

/* ── Reset ────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overflow: hidden; }
body {
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

/* ── App shell ────────────────────────────────────────────── */
#app {
  display: grid;
  grid-template:
    "bar"    var(--top-bar-h)
    "layout" 1fr
    "sheet"  min-content
    / 1fr;
  height: 100dvh;
  overflow: hidden;
}

/* ── Top bar ──────────────────────────────────────────────── */
#top-bar {
  grid-area: bar;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 max(12px, env(safe-area-inset-left));
  padding-inline-end: max(12px, env(safe-area-inset-right));
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  scrollbar-width: none;
  flex-shrink: 0;
}
#top-bar::-webkit-scrollbar { display: none; }

.top-bar-left  { display: flex; align-items: center; gap: 7px; flex-shrink: 0; }
.top-bar-center {
  display: flex; align-items: center; gap: 4px;
  flex: 1; justify-content: center; overflow: hidden;
}
.top-bar-right { display: flex; align-items: center; gap: 4px; flex-shrink: 0; margin-left: auto; }

.app-logo svg { display: block; }
.app-name {
  font-weight: 600; font-size: 15px; letter-spacing: -0.01em;
  color: var(--text); white-space: nowrap;
}

.step-indicator {
  font-size: 12px; color: var(--text-dim);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 200px;
}

.step-nav-btn {
  background: none; border: none; color: var(--text-dim);
  font-size: 18px; cursor: pointer; padding: 4px 6px; line-height: 1;
  border-radius: var(--radius); transition: color 0.15s;
  min-width: 44px; min-height: 44px;
}
.step-nav-btn:hover { color: var(--accent); }
.step-nav-btn:disabled { opacity: 0.3; cursor: default; }

.icon-btn {
  background: none; border: 1px solid var(--border); color: var(--text-dim);
  font-size: 11px; font-weight: 500; letter-spacing: 0.03em;
  cursor: pointer; padding: 5px 9px; border-radius: var(--radius);
  white-space: nowrap; transition: color 0.15s, border-color 0.15s, background 0.15s;
  min-height: 44px; min-width: 44px;
}
.icon-btn:hover:not(:disabled) { color: var(--text); border-color: var(--accent); }
.icon-btn:disabled { opacity: 0.3; cursor: default; }

/* ── Loading bar ──────────────────────────────────────────── */
#loading-bar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 999;
  background: var(--surface);
  display: flex; align-items: center; gap: 8px; padding: 6px 12px;
}
.loading-track {
  flex: 1; height: 3px; background: var(--border); border-radius: 2px; overflow: hidden;
}
.loading-fill {
  height: 100%; width: 40%; background: var(--accent); border-radius: 2px;
  animation: loadingSlide 1.4s ease-in-out infinite;
}
@keyframes loadingSlide {
  0%   { transform: translateX(-100%); }
  100% { transform: translateX(350%); }
}
.loading-label { font-size: 12px; color: var(--text-dim); white-space: nowrap; }

/* ── Layout ───────────────────────────────────────────────── */
#layout {
  grid-area: layout;
  display: grid;
  grid-template: "canvas" 1fr / 1fr;
  overflow: hidden;
  min-height: 0;
}

#tool-rail  { display: none; }
#side-panel { display: none; }

/* ── Canvas ───────────────────────────────────────────────── */
#canvas-area {
  grid-area: canvas;
  position: relative;
  overflow: hidden;
  min-height: 0;
}
#view {
  display: block; width: 100%; height: 100%;
  touch-action: none; outline: none;
}
#view:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.kbd-hints { display: none; }

/* ── Bottom sheet (mobile) ────────────────────────────────── */
#bottom-sheet {
  grid-area: sheet;
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex; flex-direction: column; overflow: hidden;
  max-height: 45dvh;
  padding-bottom: max(8px, env(safe-area-inset-bottom));
}
#bottom-sheet-handle {
  width: 40px; height: 4px; background: var(--border);
  border-radius: 2px; margin: 8px auto; flex-shrink: 0;
}
#bottom-sheet-content {
  flex: 1; overflow-y: auto; padding: 0 12px 8px;
  scrollbar-width: thin; scrollbar-color: var(--border) transparent;
}

/* ── Validation badge ─────────────────────────────────────── */
.valid-badge {
  font-size: 11px; font-weight: 600;
  padding: 3px 7px; border-radius: 10px; white-space: nowrap;
}
.badge-error { background: var(--fail); color: #fff; }
.badge-warn  { background: var(--warn); color: #000; }

/* ── Context menu ─────────────────────────────────────────── */
.context-menu {
  position: fixed; z-index: 500;
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 4px;
  list-style: none; box-shadow: 0 8px 32px rgba(0,0,0,0.5);
  top: 50%; left: 50%; transform: translate(-50%, -50%);
  min-width: 160px;
}
.context-menu.hidden { display: none; }
.ctx-btn {
  display: block; width: 100%; background: none; border: none;
  color: var(--text); padding: 10px 20px; text-align: left;
  cursor: pointer; font-size: 14px; border-radius: var(--radius);
  white-space: nowrap; transition: background 0.1s; min-height: 44px;
}
.ctx-btn:hover { background: var(--surface); }

/* ── Toast ────────────────────────────────────────────────── */
.toast-area {
  position: fixed; bottom: 12px; left: 50%; transform: translateX(-50%);
  display: flex; flex-direction: column; gap: 6px; z-index: 400;
  pointer-events: none; max-width: min(90vw, 420px);
}
.toast {
  padding: 10px 16px; border-radius: var(--radius-lg);
  font-size: 13px; font-weight: 500; transition: opacity 0.4s;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
}
.toast-info  { background: var(--surface2); color: var(--text); border: 1px solid var(--border); }
.toast-warn  { background: #78350f; color: #fef3c7; }
.toast-error { background: #7f1d1d; color: #fee2e2; }
.toast-out   { opacity: 0; }

/* ── Step content ─────────────────────────────────────────── */
.step-content { display: flex; flex-direction: column; gap: var(--gap-lg); padding: 4px 0 16px; }
.step-title   { font-size: 16px; font-weight: 600; color: var(--text); line-height: 1.3; }
.step-hint, .hint-text { font-size: 12px; color: var(--text-hint); line-height: 1.5; }
.subsection-title {
  font-size: 11px; font-weight: 700; color: var(--text-dim);
  letter-spacing: 0.06em; text-transform: uppercase; margin-bottom: -6px;
}

/* ── Buttons ──────────────────────────────────────────────── */
.btn-primary, .btn-secondary, .btn-tool, .btn-sm {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 5px; border-radius: var(--radius); font-size: 13px; font-weight: 500;
  cursor: pointer; transition: background 0.15s, opacity 0.15s;
  border: none; line-height: 1; white-space: nowrap; font-family: inherit;
}
.btn-primary {
  background: var(--accent); color: #fff; padding: 10px 18px; min-height: 44px; min-width: 80px;
}
.btn-primary:hover:not(:disabled)   { background: var(--accent-h); }
.btn-primary:disabled                { opacity: 0.4; cursor: default; }

.btn-secondary {
  background: var(--surface2); color: var(--text);
  padding: 9px 14px; border: 1px solid var(--border); min-height: 44px;
}
.btn-secondary:hover:not(:disabled) { background: var(--border); }
.btn-secondary:disabled              { opacity: 0.4; cursor: default; }

.btn-tool {
  background: var(--surface2); color: var(--text-dim);
  padding: 8px 12px; border: 1px solid var(--border); min-height: 44px;
}
.btn-tool:hover:not(:disabled) { color: var(--text); border-color: var(--accent); }
.btn-tool:disabled              { opacity: 0.4; cursor: default; }

.btn-sm {
  background: var(--surface2); color: var(--text-dim);
  padding: 5px 10px; border: 1px solid var(--border); font-size: 12px; min-height: 44px;
}
.btn-sm:hover:not(:disabled) { color: var(--text); }
.btn-danger { color: var(--fail); border-color: var(--fail); }
.btn-danger:hover:not(:disabled) { background: rgba(239,68,68,0.15); }

.btn-analyze-big { font-size: 15px; padding: 12px 28px; min-height: 44px; }
.btn-row { display: flex; flex-wrap: wrap; gap: var(--gap); }
.toolbar-row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }

/* ── Form ─────────────────────────────────────────────────── */
.field-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.field-label { font-size: 12px; color: var(--text-dim); flex-shrink: 0; min-width: 80px; }

.num-input, .select-field, .select-sm, .coord-input {
  background: var(--bg); border: 1px solid var(--border);
  color: var(--text); border-radius: var(--radius);
  font-size: 13px; font-family: inherit; transition: border-color 0.15s;
}
.num-input, .select-field { padding: 7px 10px; min-height: 36px; flex: 1; min-width: 80px; }
.select-sm   { padding: 5px 8px; min-height: 32px; }
.coord-input { padding: 5px 6px; width: 70px; min-height: 32px; }
.num-input:focus, .select-field:focus, .select-sm:focus, .coord-input:focus {
  outline: none; border-color: var(--accent);
}

.coord-group  { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.coord-label  { font-size: 11px; color: var(--text-hint); min-width: 32px; flex-shrink: 0; }
.coord-wrap   { display: flex; align-items: center; gap: 3px; }
.coord-axis   { font-size: 10px; color: var(--text-hint); font-weight: 700; }

.snap-toggle {
  display: flex; align-items: center; gap: 5px;
  font-size: 12px; color: var(--text-dim); cursor: pointer;
  padding: 5px 8px; border: 1px solid var(--border);
  border-radius: var(--radius); user-select: none;
}
.snap-toggle input { accent-color: var(--accent); cursor: pointer; }

/* ── Step nav ─────────────────────────────────────────────── */
.step-nav {
  display: flex; gap: var(--gap); flex-wrap: wrap;
  padding-top: 8px; border-top: 1px solid var(--border);
}
.analyze-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }

/* ── Preset grid ──────────────────────────────────────────── */
.preset-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--gap); }
.preset-card {
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 12px; text-align: left;
  cursor: pointer; color: var(--text);
  transition: border-color 0.15s, background 0.15s;
  display: flex; flex-direction: column; gap: 4px; min-height: 70px;
}
.preset-card:hover { border-color: var(--accent); background: var(--surface); }
.preset-card strong { font-size: 13px; font-weight: 600; }
.preset-desc { font-size: 11px; color: var(--text-dim); line-height: 1.4; }

/* ── Profile grid ─────────────────────────────────────────── */
.profile-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 5px; }
.profile-card {
  background: var(--surface2); border: 2px solid transparent;
  border-radius: var(--radius); padding: 8px 4px 6px;
  text-align: center; cursor: pointer; color: var(--text);
  transition: border-color 0.15s, background 0.15s;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  position: relative;
}
.profile-card:hover    { border-color: var(--accent); }
.profile-card.selected { border-color: var(--accent); background: rgba(96,165,250,0.08); }
.profile-svg  { width: 36px; height: 36px; }
.profile-name { font-size: 11px; color: var(--text-dim); font-weight: 500; }
.est-badge    {
  position: absolute; top: 4px; right: 4px;
  font-size: 10px; color: var(--warn); font-weight: 700;
}
.mat-note { font-size: 11px; color: var(--text-dim); font-style: italic; line-height: 1.5; }

/* ── Member list ──────────────────────────────────────────── */
.member-list { display: flex; flex-direction: column; gap: 4px; }
.member-row {
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden;
}
.member-row.member-sel { border-color: var(--accent); }
.member-summary {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 12px; cursor: pointer; list-style: none; user-select: none; gap: 8px;
}
.member-summary::-webkit-details-marker { display: none; }
.member-name { font-size: 13px; font-weight: 600; color: var(--text); }
.member-info { font-size: 11px; color: var(--text-dim); }
.member-detail {
  padding: 8px 12px 12px; border-top: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 8px;
}
.member-btns { flex-wrap: wrap; }

/* ── Validation list ──────────────────────────────────────── */
.validation-list {
  list-style: none; display: flex; flex-direction: column; gap: 4px;
  padding: 8px 10px; background: var(--surface2);
  border-radius: var(--radius); border: 1px solid var(--border);
}
.issue-error { font-size: 12px; color: var(--fail); }
.issue-warn  { font-size: 12px; color: var(--warn); }

/* ── Joint list ───────────────────────────────────────────── */
.joint-list { display: flex; flex-direction: column; gap: 4px; }
.joint-row {
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 8px 10px;
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
.joint-row.joint-sel { border-color: var(--accent); }
.joint-id      { font-size: 12px; font-weight: 600; color: var(--text); flex-shrink: 0; }
.joint-members { font-size: 11px; color: var(--text-dim); flex: 1; }
.joint-header  { display: flex; flex-direction: column; gap: 2px; flex: 1; }

/* ── Support & load lists ─────────────────────────────────── */
.support-list, .load-list { display: flex; flex-direction: column; gap: 4px; }
.support-row, .load-row {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 8px 10px;
}
.support-id, .load-id  { font-size: 12px; font-weight: 600; color: var(--text); flex-shrink: 0; }
.support-pos, .load-info { font-size: 11px; color: var(--text-dim); flex: 1; }
.load-type { font-size: 10px; font-weight: 700; color: var(--text-hint); text-transform: uppercase; }

/* ── Add panel ────────────────────────────────────────────── */
.add-panel { border: 1px dashed var(--border); border-radius: var(--radius); overflow: hidden; }
.add-panel-title {
  padding: 8px 12px; cursor: pointer; font-size: 12px;
  color: var(--accent); user-select: none; list-style: none;
}
.add-panel-title::-webkit-details-marker { display: none; }
.add-form {
  padding: 10px 12px 12px; border-top: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 8px; background: var(--surface2);
}

/* ── Results ──────────────────────────────────────────────── */
.results-box   { display: flex; flex-direction: column; gap: 10px; }
.results-summary {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
  padding: 10px 12px; border-radius: var(--radius); font-size: 12px; border: 2px solid;
}
.result-pass { border-color: var(--pass); background: rgba(34,197,94,0.07); }
.result-fail { border-color: var(--fail); background: rgba(239,68,68,0.07); }
.result-warn { border-color: var(--warn); background: rgba(245,158,11,0.07); }

.pass-badge { font-size: 13px; font-weight: 700; padding: 3px 8px; border-radius: 4px; margin-right: 4px; }
.result-pass .pass-badge { background: var(--pass); color: #052e16; }
.result-fail .pass-badge { background: var(--fail); color: #fff; }

.governing-line { font-size: 12px; color: var(--text-dim); }
.governing-line strong { color: var(--text); }

.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); }
.result-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.result-table th {
  background: var(--surface2); color: var(--text-dim); font-weight: 600;
  font-size: 11px; letter-spacing: 0.03em; padding: 6px 8px; text-align: left; white-space: nowrap;
}
.result-table td { padding: 6px 8px; border-top: 1px solid var(--border); }
.result-row.result-pass td:last-child { color: var(--pass); }
.result-row.result-fail td:last-child { color: var(--fail); }
.result-row.result-warn td:last-child { color: var(--warn); }
.result-row.result-fail { background: rgba(239,68,68,0.05); }
.result-row.result-warn { background: rgba(245,158,11,0.05); }

.disclaimer {
  font-size: 11px; color: var(--text-hint); font-style: italic; line-height: 1.6;
  padding: 8px 10px; background: var(--surface2); border-radius: var(--radius);
  border-left: 3px solid var(--border);
}
.results-empty { padding: 24px 12px; }

/* ── Suggestions ──────────────────────────────────────────── */
.suggestions-panel { display: flex; flex-direction: column; gap: 6px; }
.suggestion-item {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 8px 10px; background: var(--surface2);
  border: 1px solid var(--border); border-radius: var(--radius);
}
.suggestion-text { font-size: 12px; color: var(--text); flex: 1; line-height: 1.5; }

/* ── Selection header ─────────────────────────────────────── */
.selection-header {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  font-size: 13px; color: var(--text-dim); padding: 8px 10px;
  background: var(--surface2); border-radius: var(--radius); border: 1px solid var(--accent);
}
.selection-header strong { color: var(--accent); }

/* ── ============================================================
   TABLET  768px+
   ============================================================ */
@media (min-width: 768px) {
  #app {
    grid-template:
      "bar    bar"    var(--top-bar-h)
      "layout layout" 1fr
      / 1fr 1fr;
  }
  #layout {
    grid-template: "canvas panel" 1fr / 1fr var(--panel-w);
  }
  #side-panel {
    grid-area: panel;
    display: flex; flex-direction: column;
    background: var(--surface); border-left: 1px solid var(--border);
    overflow: hidden;
  }
  #side-panel-inner {
    flex: 1; overflow-y: auto; padding: 12px;
    scrollbar-width: thin; scrollbar-color: var(--border) transparent;
  }
  #results-panel { display: block; flex: 1; overflow-y: auto; padding: 12px; border-top: 1px solid var(--border); }
  #bottom-sheet  { display: none; }
  .toast-area    { bottom: 12px; }
}

/* ── ============================================================
   DESKTOP  1024px+
   ============================================================ */
@media (min-width: 1024px) {
  #layout {
    grid-template: "rail canvas panel" 1fr / var(--rail-w) 1fr var(--panel-w);
  }
  #tool-rail {
    grid-area: rail;
    display: flex; flex-direction: column;
    background: var(--surface); border-right: 1px solid var(--border);
    overflow: hidden;
  }
  .rail-tools { display: flex; flex-direction: column; padding: 8px 0; gap: 2px; }
  .rail-btn {
    display: flex; flex-direction: column; align-items: center; gap: 2px;
    background: none; border: none; color: var(--text-dim); padding: 10px 4px;
    cursor: pointer; width: 100%; font-size: 10px; font-family: inherit;
    border-radius: 0; transition: color 0.15s, background 0.15s;
  }
  .rail-btn:hover:not(:disabled) { color: var(--accent); background: var(--surface2); }
  .rail-btn:disabled { opacity: 0.35; cursor: default; }
  .rail-label { line-height: 1; }

  #side-panel { --panel-w: 340px; }
  #side-panel-inner { flex: 0 0 auto; max-height: 55%; border-bottom: 1px solid var(--border); }
  #results-panel {
    display: block; flex: 1; overflow-y: auto; padding: 12px;
    scrollbar-width: thin; scrollbar-color: var(--border) transparent;
  }

  .kbd-hints {
    display: flex; flex-wrap: wrap; gap: 6px;
    position: absolute; bottom: 10px; left: 50%; transform: translateX(-50%);
    pointer-events: none;
  }
  .kbd-hints span {
    font-size: 10px; color: var(--text-hint);
    background: rgba(15,23,42,0.75); padding: 3px 6px;
    border-radius: 3px; white-space: nowrap;
  }
  .preset-grid { grid-template-columns: 1fr; }
}

/* ── Reduced motion ───────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .loading-fill { animation: none; width: 60%; }
  .toast { transition: none; }
}

/* ── Print ────────────────────────────────────────────────── */
@media print {
  #top-bar, #tool-rail, #side-panel, #bottom-sheet, .toast-area { display: none !important; }
  #canvas-area { width: 100vw; height: 100vh; }
}

/* Design system: clear hierarchy, generous controls and a quiet workspace. */

[hidden] { display: none !important; }
body { line-height: 1.5; }
#top-bar { gap: 12px; box-shadow: 0 4px 20px #07111e40; z-index: 2; }
.app-name { font-size: 16px; font-weight: 700; letter-spacing: -.03em; }
.app-logo { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 10px; background: #315278; }
.step-indicator { font-size: 13px; font-weight: 600; color: var(--text); }
.icon-btn, .step-nav-btn, .rail-btn, .btn-primary, .btn-secondary, .btn-tool, .btn-sm, .ctx-btn, .add-panel-title, .member-summary {
  min-height: 44px; min-width: 44px;
}
.icon-btn { padding-inline: 11px; font-size: 12px; }
.step-nav-btn { font-size: 24px; }
button, summary, select { -webkit-tap-highlight-color: transparent; }
button:focus-visible, summary:focus-visible, input:focus-visible, select:focus-visible, a:focus-visible, .table-wrap:focus-visible {
  outline: 3px solid var(--accent); outline-offset: 2px;
}
button:not(:disabled), summary { transition: transform .16s ease, background-color .16s ease, border-color .16s ease, color .16s ease; }
button:not(:disabled):active { transform: scale(.97); }
#canvas-area { background: radial-gradient(ellipse at 50% 35%, #283e58, #101b2b 75%); }
#bottom-sheet { border-radius: 20px 20px 0 0; box-shadow: 0 -12px 36px #07111e55; }
#bottom-sheet-content, #side-panel-inner { overscroll-behavior: contain; }
.step-content { gap: 16px; }
.step-title { font-size: 22px; font-weight: 700; letter-spacing: -.03em; line-height: 1.2; }
.step-hint, .hint-text { font-size: 13px; line-height: 1.55; }
.subsection-title { font-size: 11px; letter-spacing: .09em; }
.btn-primary, .btn-secondary, .btn-tool, .btn-sm { font-size: 13px; font-weight: 600; }
.btn-primary { color: #092138; }
.num-input, .select-field, .select-sm, .coord-input { min-height: 44px; font-size: 16px; }
.preset-grid { gap: 10px; }
.preset-card { padding: 16px; min-height: 100px; border-radius: 12px; }
.preset-card strong { font-size: 14px; }
.preset-desc { font-size: 12px; }
.profile-card { min-height: 76px; border-radius: 10px; }
.member-row, .joint-row, .support-row, .load-row, .add-panel { border-radius: 10px; }
.results-box { gap: 14px; }
.results-summary { gap: 10px; padding: 14px; border-radius: 12px; font-variant-numeric: tabular-nums; }
.pass-badge { font-size: 13px; letter-spacing: .04em; }
.governing-line { font-size: 13px; line-height: 1.5; padding: 12px; background: var(--surface2); border-radius: 9px; }
.result-table { font-size: 13px; font-variant-numeric: tabular-nums; }
.result-table th, .result-table td { padding: 10px; white-space: nowrap; }
.disclaimer { line-height: 1.55; }
.suggestion-item { padding: 12px; border-radius: 10px; }
.toast-area { bottom: max(16px, env(safe-area-inset-bottom)); }
@media (max-width: 767px) {
  #top-bar { gap: 6px; padding-inline: 10px; }
  .app-name { display: none; }
  .top-bar-center { flex: 0 0 auto; }
  .step-indicator { max-width: 130px; }
  #bottom-sheet { max-height: 52dvh; }
  #bottom-sheet-content { padding-inline: 16px; }
  .preset-grid { grid-template-columns: 1fr 1fr; }
}
@media (min-width: 768px) {
  #side-panel-inner { padding: 20px; }
  .num-input, .select-field, .select-sm, .coord-input { font-size: 14px; }
}
@media (prefers-color-scheme: light) {
  :root { color-scheme: light; --bg: #eaf0f6; --surface: #f7f9fc; --surface2: #e2eaf3; --border: #bdcbd9; --text: #14263b; --text-dim: #405971; --text-hint: #526a80; --accent: #075caa; --accent-h: #004c8e; }
  .btn-primary { color: #fff; }
  .app-logo { background: #dcecfb; }
  .result-pass { background: #e7f6ed; } .result-fail { background: #fff0ef; } .result-warn { background: #fff5dd; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}

#result-strip:not([hidden]) { position: fixed; z-index: 30; left: 0; right: 0; bottom: 52dvh; padding: .5rem 1rem; background: var(--surface); color: var(--text); }
@media (min-width: 768px) { #result-strip:not([hidden]) { bottom: 0; } }

#mobile-results { overflow: auto; max-height: 42%; padding: 0 12px; }
@media (min-width: 768px) { #mobile-results { display: none; } #result-strip:not([hidden]) { left: auto; right: 0; width: var(--panel-w); } }
@media (max-width: 767px) {
 #top-bar { overflow: hidden; gap: 2px; padding-inline: 4px; }
 .app-logo { display: none; } .top-bar-left { min-width: 0; flex-shrink: 1; } .top-bar-center { flex: 1 1 0; min-width: 0; } .step-indicator { max-width: 90px; }
 #bottom-sheet { height: 52dvh; max-height: 90dvh; overflow: visible; position: relative; }
 #bottom-sheet[data-level="2"] { height: 85dvh; }
 #bottom-sheet-handle { min-height: 44px; width: 48px; border: 0; cursor: ns-resize; touch-action: none; }
 #result-strip:not([hidden]) { bottom: var(--mobile-sheet-height, 52dvh); }
 #bottom-sheet-content { min-height: 0; }
}

@media (max-width: 767px) { .top-bar-right { gap: 0; } #top-bar .icon-btn, #top-bar .step-nav-btn { padding-inline: 3px; font-size: 10px; } #top-bar .step-nav-btn { font-size: 20px; } }

/* Sheet sizing */
@media (max-width: 767px) { #top-bar { gap: 8px; overflow-x: auto; } #top-bar .icon-btn, #top-bar .step-nav-btn { min-width: 44px; min-height: 44px; flex-shrink: 0; } #bottom-sheet { min-height: 0; max-height: none; overflow: hidden; height: 52dvh; } #bottom-sheet[data-level="1"] { height: 52dvh; } #bottom-sheet[data-level="2"] { height: 85dvh; } #bottom-sheet-handle { min-height: 44px; } #bottom-sheet-content, #mobile-results { min-height: 0; overflow: auto; } }
@media (min-width: 768px) { #results-panel { padding-bottom: 5rem; } }

@media (max-width: 767px) { #bottom-sheet { display: flex; flex-direction: column; } #bottom-sheet-handle, .persistent-tools { flex: 0 0 auto; } #bottom-sheet-content { flex: 1 1 0; } }

#measure-readout { position: fixed; z-index: 60; left: 1rem; top: calc(var(--top-bar-h) + 8px); background: var(--surface); color: var(--text); padding: .5rem; }
#measure-readout button, .persistent-tools button { min-height: 44px; min-width: 44px; }
@media (max-width: 767px) {
  :root { --top-bar-h: 104px; }
  #top-bar { flex-wrap: wrap; overflow: visible; align-content: center; }
  .top-bar-left { display: none; }
  .top-bar-center { flex: 1 0 100%; height: 44px; }
  .top-bar-right { width: 100%; justify-content: center; }
  #bottom-sheet[data-level="0"] { height: calc(113px + env(safe-area-inset-bottom)); }
  #bottom-sheet[data-level="0"].has-results { height: 38dvh; }
  #bottom-sheet[data-level="0"].has-results #bottom-sheet-content { display: none; }
  #mobile-results { flex: 0 1 42%; max-height: 42%; min-height: 0; overflow: auto; }
  #bottom-sheet[data-level="0"] #mobile-results { flex: 1 1 auto; max-height: none; }
}

input[type=file][data-action=import-json] { position: absolute; width: 1px; height: 1px; opacity: 0; }
#canvas-area { background: radial-gradient(ellipse at center, var(--surface2), var(--bg) 75%); }
@media (min-width: 768px) { #results-panel { padding-bottom: calc(var(--result-strip-height, 0px) + 12px); } }

.skip-link { position: fixed; left: -9999px; z-index: 100; } .skip-link:focus { left: 1rem; top: 1rem; background: var(--surface); padding: .75rem; }
@media (max-width: 767px) { #result-strip:not([hidden]) { position: fixed; } }

.joint-guide figure { display:flex; align-items:center; gap:.6rem; margin:.5rem 0; } .joint-guide svg { flex:none; width:60px; height:40px; fill:none; stroke:var(--accent); stroke-width:3; }
