:root {
  --paper: #f3eee6; --card: #fffdf9; --ink: #2d2a26; --muted: #6a645c; --line: #e2d8c8;
  --clay: #a4553a; --clay-dk: #7a3b26; --sage: #7c9a86; --sage-dk: #4f6b58; --gold: #e6b45a; --rust: #b5452f;
  --radius: 14px; --shadow: 0 1px 0 rgba(45,42,38,.04), 0 6px 18px rgba(45,42,38,.07);
  --hand: "Caveat", "Segoe Print", "Bradley Hand", cursive;
  --serif: Georgia, "Iowan Old Style", "Times New Roman", serif;
  color-scheme: light;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 16px/1.5 "Source Sans 3", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif; color: var(--ink);
  background: var(--paper) radial-gradient(circle at 6% 0%, rgba(164,85,58,.12), transparent 42%), radial-gradient(circle at 94% 30%, rgba(124,154,134,.16), transparent 46%); }
button, input, select { font: inherit; color: inherit; }
a { color: var(--clay-dk); }
[hidden] { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.muted { color: var(--muted); }
.small { font-size: .86rem; }
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; max-width: 1100px; margin: 0 auto; padding: 18px 18px 6px; }
.brand { display: flex; align-items: center; gap: 12px; }
.brand h1 { margin: 0; font-size: 1.5rem; letter-spacing: -.01em; font-family: var(--serif); }
.sub { margin: 0; color: var(--muted); font-size: .92rem; }
.top-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
main { max-width: 1100px; margin: 0 auto; padding: 6px 18px 24px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; }
main > *, .two > * { min-width: 0; }
.two { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 14px; align-items: start; }
@media (max-width: 860px) { .two { grid-template-columns: minmax(0, 1fr); } }
button { cursor: pointer; border-radius: 10px; border: 1px solid transparent; padding: 9px 14px; min-height: 42px; background: none; }
button:focus-visible, input:focus-visible, select:focus-visible, summary:focus-visible { outline: 3px solid rgba(164,85,58,.35); outline-offset: 2px; }
.ghost { background: transparent; border-color: var(--line); }
.ghost:hover { background: #ece3d5; }
.solid { background: var(--clay); color: #fff; font-weight: 600; }
.solid:hover { background: var(--clay-dk); }
.sm { min-height: 34px; padding: 3px 10px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 12px; align-items: center; }
.row.tight { margin-top: 6px; gap: 6px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 18px; }
h2 { font-family: var(--serif); font-size: 1.12rem; margin: 0; }
.hand { font-family: var(--hand); font-size: 2rem; color: var(--clay-dk); font-weight: 700; margin: 0; line-height: 1.1; }
.hand.big { font-size: 2.7rem; margin-top: 8px; }
.hand.big.no { color: var(--rust); }
.step-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.step-aside, .hint { color: var(--muted); font-size: .88rem; }
.hint { margin: 0 0 6px; }
input, select { border: 1px solid var(--line); border-radius: 9px; background: #fff; padding: 6px 9px; min-height: 38px; max-width: 100%; }
input.len { width: 7.2em; font-weight: 600; }
input.len.inline { width: 5.6em; min-height: 32px; padding: 3px 7px; }
input.bad { border-color: var(--rust); background: #fbeee9; }
input[type=number] { width: 4.6em; text-align: center; font-weight: 600; }
.banner { margin: 10px 0 0; padding: 10px 14px; border-radius: 12px; font-size: .93rem; }
.banner.bad { background: #f6dcd2; color: #8e2f1a; }

.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: #fff; }
.seg button { border-radius: 0; min-height: 36px; padding: 4px 12px; border: 0; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button[aria-pressed=true] { background: var(--clay); color: #fff; font-weight: 600; }

.hero { background: linear-gradient(160deg, #fffdf9, #f2ece1); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow); padding: 18px 20px 20px; }
.lede { max-width: 64ch; margin: 8px 0 4px; }
.kicker { margin: 0; color: var(--muted); font-size: .92rem; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.chip { display: inline-block; padding: 3px 11px; border-radius: 12px; font-size: .88rem; font-weight: 600; background: #ece3d5; max-width: 100%; }
.chip.ok { background: #dfe9e2; color: var(--sage-dk); }
.chip.bad { background: #f6dcd2; color: #8e2f1a; }
.chip.warn { background: #fbefc8; color: #7a5410; }
.preset { background: #f1e4dc; color: var(--clay-dk); border: 1px solid #e6cfc2; font-weight: 600; }
.preset:hover { background: #ead6ca; }

.wallbox { margin-top: 14px; background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 8px; }
#wall { display: block; width: 100%; height: auto; max-height: 560px; margin: 0 auto; }
#wall .wallbg { fill: #f6f1e8; stroke: #cfc3b0; stroke-width: 1.5; }
#wall .floor { fill: #d9c8ad; }
#wall .eye { stroke: var(--sage); stroke-dasharray: 6 5; stroke-width: 1.2; }
#wall .eyelbl, #wall .dimlbl { font: 600 12px "Source Sans 3", sans-serif; fill: var(--muted); }
#wall .furn { fill: #c9b89d; stroke: #a89573; }
#wall .frame { fill: #fff; filter: drop-shadow(0 2px 2px rgba(45,42,38,.18)); stroke: #3b352e; stroke-width: 3; cursor: pointer; }
#wall .mat { fill: #e8eee9; cursor: pointer; }
#wall .frame-g.sel .frame { stroke: var(--clay); }
#wall .flbl { font: 600 13px "Source Sans 3", sans-serif; fill: #4a443c; pointer-events: none; }
#wall .wire { stroke: #8c8478; stroke-width: 1.2; fill: none; }
#wall .nail { fill: var(--clay); stroke: #fff; stroke-width: 1.5; }
#wall .nailno { font: 700 12px "Source Sans 3", sans-serif; fill: #fff; pointer-events: none; }
#wall .dim { stroke: var(--clay-dk); stroke-width: 1; }
#wall .dimtxt { font: 700 13px "Source Sans 3", sans-serif; fill: var(--clay-dk); }
#wall .ledge { fill: #8b6b4a; }
#wall .over { fill: rgba(181,69,47,.12); stroke: var(--rust); stroke-dasharray: 4 3; }

.steps { margin: 14px 0 0; padding: 0; list-style: none; display: grid; gap: 8px; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.steps li { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px 10px 48px; position: relative; }
.steps li::before { content: attr(data-n); position: absolute; left: 12px; top: 10px; width: 26px; height: 26px; border-radius: 50%; background: var(--clay); color: #fff; font-weight: 700; text-align: center; line-height: 26px; font-size: .9rem; }
.steps li.ledge::before { content: "—"; background: #8b6b4a; }
.steps .what { font-weight: 700; }
.steps .where { font-family: var(--serif); font-size: 1.1rem; }
.steps .rel { color: var(--muted); font-size: .86rem; }

.frame-row { display: grid; grid-template-columns: minmax(0, 1.3fr) repeat(2, minmax(0, .8fr)) auto; gap: 6px 8px; align-items: end; padding: 10px 0; border-bottom: 1px dashed var(--line); }
.frame-row:first-child { padding-top: 0; }
.frame-row .f-hang { grid-column: 1 / 2; }
.frame-row .f-sub { grid-column: 2 / 4; display: flex; gap: 8px; }
.frame-row label { display: block; font-size: .8rem; color: var(--muted); font-weight: 600; }
.frame-row input, .frame-row select { width: 100%; }
.frame-row .tools { display: flex; gap: 2px; grid-row: 1; grid-column: 4; }
.frame-row .tools button { min-height: 34px; padding: 2px 8px; color: var(--muted); }
.frame-row .tools button:hover { background: #ece3d5; }
.frame-row.sel { background: linear-gradient(90deg, rgba(164,85,58,.07), transparent); }
.swatch { display: inline-block; width: 12px; height: 12px; border-radius: 3px; border: 2px solid #3b352e; vertical-align: -1px; margin-right: 4px; }
@media (max-width: 520px) {
  .frame-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto; }
  .frame-row .f-name { grid-column: 1 / 3; }
  .frame-row .tools { grid-column: 3; }
  .frame-row .f-hang { grid-column: 1 / 4; }
  .frame-row .f-sub { grid-column: 1 / 4; }
}
.how { margin-top: 12px; border-top: 1px dashed var(--line); padding-top: 8px; font-size: .93rem; }
.how summary { cursor: pointer; font-weight: 600; color: var(--clay-dk); }
.how p { margin: 6px 0; }
.arr { display: flex; flex-wrap: wrap; gap: 4px 16px; margin-top: 12px; border-top: 1px dashed var(--line); padding-top: 12px; }
.field { margin-bottom: 10px; }
.field > label, .field > .lbl { display: block; font-weight: 600; font-size: .93rem; margin-bottom: 3px; }
.pair { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 0 12px; }
.toggles { border: 0; padding: 0; margin: 4px 0 8px; }
.toggles legend { font-weight: 600; font-size: .93rem; padding: 0; margin-bottom: 4px; }
.toggles label { display: flex; gap: 8px; align-items: center; padding: 3px 0; font-size: .95rem; flex-wrap: wrap; }
.toggles input[type=radio] { width: 18px; height: 18px; min-height: 0; accent-color: var(--clay); }
.unit-note { font-size: .85rem; }

.level { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; margin: 8px 0 0; }
.vial { position: relative; width: 220px; max-width: 70%; height: 34px; border-radius: 17px; background: linear-gradient(180deg, #e8f0c8, #cfdc96); border: 2px solid #8b8a5e; overflow: hidden; }
.bubble { position: absolute; top: 5px; left: 50%; width: 40px; height: 20px; margin-left: -20px; border-radius: 10px; background: radial-gradient(circle at 40% 35%, #fff, #f2f6dc 60%, #d9e2a8); box-shadow: inset 0 0 0 1px rgba(0,0,0,.12); transition: transform .08s linear; }
.tick { position: absolute; top: 0; bottom: 0; width: 2px; background: #6f6e48; }
.tick.l { left: calc(50% - 24px); } .tick.r { left: calc(50% + 22px); }
.level.ok .vial { border-color: var(--sage-dk); }
.saved-list { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.saved-list li { display: inline-flex; align-items: center; background: #ece3d5; border-radius: 999px; padding-left: 4px; }
.saved-list button { min-height: 30px; padding: 2px 8px; font-size: .9rem; }
.saved-list .x { color: var(--muted); padding: 2px 8px 2px 2px; }
#save-name { flex: 1 1 180px; min-width: 0; }
.foot { max-width: 82ch; margin: 4px 2px 0; }

@media print {
  body { background: #fff; }
  .top-actions, .noprint, #h-frames ~ *, .card, .foot { display: none !important; }
  .hero { box-shadow: none; border: 0; padding: 0; }
  .steps li { break-inside: avoid; }
}
.link-ish { background: none; border: 0; color: var(--ink); font-weight: 600; }
