:root {
  --bg: #f4f2ee; --panel: #ffffff; --ink: #1d1d1f; --muted: #6b6b70; --line: #dcd9d3;
  --accent-ui: #b4472b; --warn: #b26a00; --bad: #c62828; --ok: #3a8a4a; --input: #fbfaf8;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #17171a; --panel: #212125; --ink: #ececef; --muted: #9a9aa2; --line: #34343a;
    --accent-ui: #e0795c; --warn: #f0a640; --bad: #ef6b6b; --ok: #6cc07c; --input: #1b1b1f;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 14px/1.4 system-ui, -apple-system, sans-serif; }
header { padding: 14px 20px; border-bottom: 1px solid var(--line); display: flex; gap: 16px; align-items: baseline; flex-wrap: wrap; }
header h1 { font-size: 17px; margin: 0; }
.embedded header { display: none; }
.dim { color: var(--muted); }
main { display: grid; grid-template-columns: 380px 1fr; min-height: 100vh; }
@media (max-width: 900px) { main { grid-template-columns: 1fr; } }
aside { background: var(--panel); border-right: 1px solid var(--line); padding: 14px 16px; overflow-y: auto; max-height: 100vh; }
@media (max-width: 900px) { aside { max-height: none; border-right: 0; } }
h2 { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 18px 0 8px; }
h2:first-child { margin-top: 0; }
label { display: block; font-size: 12px; color: var(--muted); }
input, select, button, textarea { font: inherit; color: var(--ink); }
input[type=text], input[type=email], input[type=password], input[type=number], select { width: 100%; padding: 5px 7px; border: 1px solid var(--line); border-radius: 6px; background: var(--input); }
button { border: 1px solid var(--line); background: var(--input); border-radius: 6px; padding: 5px 10px; cursor: pointer; }
button:hover { border-color: var(--accent-ui); }
button:disabled { opacity: .5; cursor: progress; }
button.primary { background: var(--accent-ui); color: #fff; border-color: var(--accent-ui); }
.row { display: flex; gap: 8px; align-items: end; margin-bottom: 8px; }
.row > * { flex: 1; min-width: 0; }
.row > .tight { flex: 0 0 auto; }
.check { display: flex; gap: 6px; align-items: center; font-size: 13px; color: var(--ink); }
.stage { padding: 24px; display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 18px; }
svg { width: 100%; height: auto; display: block; }
.msgs { list-style: none; padding: 0; margin: 0; }
.msgs li { padding: 6px 10px; border-left: 3px solid var(--warn); background: var(--panel); margin-bottom: 4px; border-radius: 0 6px 6px 0; }
.msgs li.bad { border-color: var(--bad); }
.msgs li.ok { border-color: var(--ok); }
.note { color: var(--muted); font-size: 12px; }
table.kv { border-collapse: collapse; width: 100%; font-size: 13px; }
table.kv td { padding: 4px 0; border-bottom: 1px solid var(--line); vertical-align: top; }
table.kv td:last-child { text-align: right; font-variant-numeric: tabular-nums; padding-left: 10px; }
pre { white-space: pre-wrap; font: 12px ui-monospace, monospace; background: var(--input); border: 1px solid var(--line); border-radius: 6px; padding: 10px; max-height: 360px; overflow: auto; }
a { color: var(--accent-ui); }

/* The hosted site (rdgen serve --public) has no OpenSCAD and no saved layouts: hide what needs them. */
.public .local-only { display: none !important; }

/* Phones and tablets: bigger touch targets, 16px inputs (iOS zooms the page on smaller ones), tighter gutters. */
@media (pointer: coarse) {
  input[type=text], input[type=email], input[type=password], input[type=number], select, textarea { font-size: 16px; padding: 8px 9px; }
  button { min-height: 40px; }
}
@media (max-width: 600px) {
  header { padding: 12px 16px; }
  aside { padding: 12px 16px; }
  .stage { padding: 12px; }
  .card { padding: 14px; }
  .row { flex-wrap: wrap; }
  .row > * { flex: 1 1 140px; }
}
/* Narrow screens: the preview comes first, the controls under it, so a change shows where you're looking. */
@media (max-width: 900px) { .stage { order: -1; } }
