:root {
  /* The Workspace Hero brand */
  --navy: #14213d;
  --teal: #12899f;
  --light: #e5e5e5;
  --white: #ffffff;
  --black: #000000;

  --bg: #f2f4f5;
  --panel: #ffffff;
  --ink: #14213d;
  --muted: #5c6b7a;
  --accent: var(--teal);
  --wood: #c9a06b;
  --plastic: #2e3a44;
  --danger: #c0483d;
  --radius: 12px;
  font-size: 15px;
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: "Nunito Sans", "Segoe UI", system-ui, sans-serif;
}
button {
  font: inherit; border: 1px solid #d0d6da; background: #fff; color: var(--ink);
  border-radius: 8px; padding: 6px 12px; cursor: pointer;
}
button:hover { border-color: var(--accent); color: var(--accent); }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.primary:hover { filter: brightness(1.08); color: #fff; }
button.danger { color: var(--danger); border-color: #e3b7b2; }
select, input[type="number"] {
  font: inherit; padding: 5px 8px; border: 1px solid #d0d6da; border-radius: 8px; background: #fff;
  max-width: 100%;
}
label { display: block; margin: 6px 0; }
.spacer { flex: 1; }

/* ============ hero ============ */
.hero {
  background: linear-gradient(160deg, var(--navy) 0%, #0d1930 70%, #123 100%);
  color: var(--white); text-align: center; padding: 40px 20px 34px;
}
.hero-logo { height: 74px; transition: opacity 0.12s; }
.hero a:hover .hero-logo { opacity: 0.8; }
.hero h1 { margin: 8px 0 6px; font-size: 2rem; letter-spacing: 0.01em; color: var(--white); }
.beta-pill {
  display: inline-block; vertical-align: middle; margin-left: 6px;
  background: var(--teal); color: #fff;
  font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.09em;
  padding: 3px 10px; border-radius: 999px; transform: translateY(-3px);
}
.hero-tag { color: #c9d4e2; max-width: 620px; margin: 0 auto 24px; font-size: 1.05rem; }
.steps { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; max-width: 980px; margin: 0 auto; }
.step {
  background: rgba(255,255,255,0.07); border: 1px solid rgba(255,255,255,0.14);
  border-radius: var(--radius); padding: 16px 18px; width: 290px; text-align: left;
}
.step p { color: #b9c6d6; margin: 6px 0 0; font-size: 0.88rem; line-height: 1.45; }
.step-n {
  display: inline-flex; align-items: center; justify-content: center;
  width: 26px; height: 26px; border-radius: 50%; background: var(--teal); color: #fff;
  font-weight: 700; margin-right: 8px;
}
.hero-note { color: #93a5bb; font-size: 0.85rem; max-width: 640px; margin: 22px auto 0; }

/* ============ setup ============ */
.setup { max-width: 720px; margin: 22px auto 0; }
.builder-head.setup-title { max-width: 748px; margin: 22px auto 0; display: flex; justify-content: center; }
.setup-head { display: flex; align-items: center; justify-content: flex-end; margin-bottom: 4px; }
.setup-row {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 10px 4px; border-bottom: 1px solid #edf0f2;
}
.setup-row:last-child { border-bottom: none; }
.setup-label { font-weight: 600; }
.setup-row input[type="number"] { width: 84px; }
.stat-row { background: #f4fafb; border-radius: 8px; padding: 10px; }
.setup-error {
  background: #fdeceb; border: 1.5px solid #e0685c; color: #8f2318;
  border-radius: 8px; padding: 7px 11px; margin: 8px 0 2px; font-size: 0.88rem; font-weight: 600;
}
input.invalid { border-color: #d33627 !important; background: #fdf2f1; }
.unit-suffix { color: var(--muted); font-size: 0.85rem; }
.unit-toggle { display: inline-flex; border: 1px solid #d0d6da; border-radius: 8px; overflow: hidden; }
.unit-toggle button { border: none; border-radius: 0; padding: 5px 12px; }
.unit-toggle button.on { background: var(--accent); color: #fff; }

/* tooltips */
.tip { position: relative; cursor: help; border-bottom: 1px dotted var(--teal); }
.tip::after {
  content: attr(data-tip);
  position: absolute; left: 0; top: calc(100% + 6px); z-index: 30;
  background: var(--navy); color: #fff; padding: 8px 11px; border-radius: 8px;
  width: 280px; font-size: 0.82rem; font-weight: 400; line-height: 1.4;
  opacity: 0; pointer-events: none; transition: opacity 0.15s;
}
.tip:hover::after { opacity: 1; }

/* ============ builder ============ */
.builder-head {
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 10px;
  max-width: 1500px; margin: 26px auto 0; padding: 0 14px;
}
.builder-head h2 { margin: 0; }
.head-title { display: inline-flex; align-items: center; gap: 12px; justify-self: center; }
.head-actions { display: inline-flex; align-items: center; gap: 8px; justify-self: end; flex-wrap: wrap; justify-content: flex-end; }
@media (max-width: 860px) {
  .builder-head { grid-template-columns: 1fr; }
  .head-title, .head-actions { justify-self: center; }
}
.step-badge {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; border-radius: 50%; flex: none;
  background: var(--teal); color: #fff; font-weight: 700; font-size: 1rem;
  box-shadow: 0 2px 5px rgba(18, 137, 159, 0.35);
}
.parts-head { justify-content: flex-start; }
.parts-head .step-badge { margin-right: 2px; }

#help-btn {
  width: 28px; height: 28px; border-radius: 50%; padding: 0; font-weight: 700;
  color: var(--teal); border-color: var(--teal);
}
#help-btn:hover { background: var(--teal); color: #fff; }

/* buy CTA */
.cta {
  display: inline-block; background: var(--teal); color: #fff !important;
  border-radius: 8px; padding: 7px 14px; font-weight: 700; font-size: 0.9rem;
  text-decoration: none; border: 1px solid var(--teal);
  transition: filter 0.12s;
}
.cta:hover { filter: brightness(1.1); }
.cta.big { font-size: 1rem; padding: 10px 20px; }

/* help modal */
#help-overlay {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(20, 33, 61, 0.55);
  display: flex; align-items: center; justify-content: center; padding: 18px;
}
#help-overlay[hidden] { display: none; }
.help-card {
  background: #fff; border-radius: 14px; max-width: 520px; width: 100%;
  padding: 24px 26px; position: relative; box-shadow: 0 12px 40px rgba(0, 0, 0, 0.3);
}
.help-card h3 { margin: 0 0 12px; font-size: 1.15rem; }
.help-card ol { margin: 0 0 16px; padding-left: 20px; }
.help-card li { margin: 8px 0; line-height: 1.45; font-size: 0.92rem; }
#help-close {
  position: absolute; top: 10px; right: 10px; border: none; background: none;
  font-size: 1.1rem; color: var(--muted); padding: 6px;
}

/* add-ons teaser strip */
.addons-teaser {
  max-width: 1472px; margin: 0 auto 14px;
  background: #eaf5f6; border: 1px solid #cfe3e6; border-radius: 10px;
  padding: 12px 18px; font-size: 0.95rem; color: var(--navy);
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
}
.addons-teaser span { flex: 1 1 380px; }
.addons-teaser a { color: var(--teal); font-weight: 700; text-decoration: none; white-space: nowrap; }
.addons-teaser a:hover { text-decoration: underline; }

/* parts list header + closing CTA */
.parts-head { display: flex; align-items: center; justify-content: flex-start; gap: 12px; flex-wrap: wrap; margin-bottom: 4px; }
.parts-cta {
  margin-top: 18px; padding: 14px 16px; background: #f0f7f8; border: 1px solid #cfe3e6;
  border-radius: 10px; display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  font-size: 0.95rem;
}
.parts-cta .cta { margin-left: auto; }
.parts-cta > span { flex: 1 1 320px; }
.save-tip {
  margin-top: 16px; padding: 10px 14px; font-size: 0.92rem; color: var(--navy);
  background: #fdf8ec; border: 1px solid #ecdfc0; border-radius: 10px;
}
.printer-cta { margin-top: 10px; font-size: 0.9rem; color: var(--muted); }
.printer-cta a, .printer-link { color: var(--teal); font-weight: 600; text-decoration: none; }
.printer-cta a:hover, .printer-link:hover { text-decoration: underline; }
.help-card .printer-link { display: inline-block; margin-left: 14px; font-size: 0.88rem; }
.builder-logo { height: 40px; }

.layout { padding: 14px; max-width: 1500px; margin: 0 auto; }
.palette-bar {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 9px 14px; margin-bottom: 14px;
}
.palette-label { font-weight: 700; font-size: 0.95rem; }
.palette-bar #palette { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.palette-bar #palette h3, .palette-bar #palette .hint { display: none; }
.palette-bar .pal-item { width: auto; margin: 0; padding: 6px 11px; font-size: 0.88rem; }
.inspector-bar {
  display: flex; align-items: center; gap: 18px; flex-wrap: wrap;
  padding: 8px 14px; min-height: 46px;
}
.inspector-bar label { display: inline-flex; align-items: center; gap: 6px; margin: 0; }
.inspector-bar input[type="number"] { width: 76px; }
.inspector-bar .hint { margin: 0; }
.inspector-bar #insp-dup { margin-left: auto; }
button:disabled { opacity: 0.45; cursor: default; }
button:disabled:hover { border-color: #d0d6da; color: var(--ink); }
.panel {
  background: var(--panel); border: 1px solid #e3e7ea; border-radius: var(--radius);
  padding: 14px;
}
.palette-panel, .right .panel { max-height: 82vh; overflow-y: auto; }
.panel h2 { font-size: 0.95rem; margin: 0 0 8px; }
.panel h3 { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); margin: 14px 0 6px; }

.pal-item { display: block; width: 100%; margin: 4px 0; text-align: left; padding: 7px 10px; }
.extra-item { font-size: 0.88rem; margin: 5px 0; }

.center { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.canvas-wrap {
  background: var(--panel); border: 1px solid #e3e7ea; border-radius: var(--radius);
  padding: 8px; overflow-x: hidden;
}
.canvas-wrap svg { display: block; width: 100%; height: auto; }
.canvas-wrap.zoomed { overflow-x: auto; }
.canvas-wrap.zoomed svg { width: auto; min-width: 1400px; }
.view-label {
  font-size: 1rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.12em;
  color: var(--navy); text-align: center; padding: 6px 6px 8px;
}

.canvas-wrap { position: relative; }
#warnings { margin-top: 2px; }
#warnings:empty { display: none; }
.canvas-scroll { overflow: auto; -webkit-overflow-scrolling: touch; max-height: 78vh; }
.zoom-btn {
  position: absolute; top: 8px; right: 10px; z-index: 5;
  width: 36px; height: 36px; padding: 0; border-radius: 8px;
  display: inline-flex; align-items: center; justify-content: center;
  background: #fff; border: 1px solid #d0d6da; color: #5c6b7a;
}
.zoom-btn:hover { border-color: var(--teal); color: var(--teal); }
.zoom-btn.on { border-color: var(--teal); color: var(--teal); background: #f0f8f9; }
@media (min-width: 1101px) { .zoom-btn { display: none; } } /* desktop fits everything already */
.canvas-scroll.grabbing { cursor: grabbing; }
.fat-hit, .handle-fat { fill: transparent; stroke: none; }
svg { -webkit-tap-highlight-color: transparent; }
button, .pal-item { touch-action: manipulation; }
.warn {
  background: #fdeceb; border: 1.5px solid #e0685c; color: #8f2318;
  border-radius: 8px; padding: 6px 11px; margin: 4px 0; font-size: 0.86rem; font-weight: 600;
  box-shadow: 0 1px 4px rgba(143, 35, 24, 0.15);
}
.warn.caution {
  background: #fdf6e3; border-color: #ddb64f; color: #7a5c10;
  box-shadow: 0 1px 4px rgba(122, 92, 16, 0.12);
}
.hint { color: var(--muted); font-size: 0.85rem; }

/* ============ canvas drawing ============ */
.desk-slab { fill: #e6dcc8; stroke: #cbbd9d; }
.desk-slab-top { fill: #efe8d8; stroke: #cbbd9d; }
.desk-text { fill: #8d7c58; font-size: 12px; font-weight: 600; }
.dowel { fill: var(--wood); }
.dowel-dashed { fill: none; stroke: var(--wood); stroke-width: 1.5; stroke-dasharray: 4.5 3.5; stroke-linecap: round; opacity: 0.55; }
.leg { fill: #3d4a55; stroke: #28323b; stroke-width: 1; }
.wall { fill: #56656f; stroke: #3b474f; stroke-width: 1; }
.deck { fill: #14181d; stroke: #8fb7bf; stroke-width: 1.4; }
.deck-label { fill: #cfe3e8; font-size: 11px; font-weight: 700; }
.shelf { fill: var(--plastic); opacity: 0.9; }
.seam-line { stroke: #fff; stroke-width: 1.5; }
.deco rect { fill: #fbfaf7; stroke: #b9c2c9; stroke-width: 1.2; }
.deco .deco-detail { fill: none; stroke: #d6dde1; stroke-width: 1; }
.under-part { fill: #384552; stroke: #26313a; stroke-width: 1.2; } /* shelves: match front-view dark */
.under-drawer { fill: #46545f; stroke: #2e3a44; } /* match the drawer's front-view color */
#warnings .warn-toggle {
  font-size: 0.85rem; font-weight: 700;
  border: 1.5px solid #e0685c; background: #fdeceb; color: #8f2318;
  border-radius: 8px; padding: 6px 12px; margin: 4px 0;
}
#warnings .warn-toggle:hover { filter: brightness(0.97); }
.pillar { fill: #4a5a66; }
.drawer { fill: #46545f; }
.drawer-pull { fill: #d7dde2; }
.ghost { fill: none; stroke: var(--teal); stroke-width: 1.4; stroke-dasharray: 5 4; opacity: 0.65; }
.dim { stroke: var(--muted); stroke-width: 1; }
.dim-label { fill: var(--muted); font-size: 11px; }
.piece { cursor: grab; }
.part-fill { fill: #7d8c98; stroke: #5d6c78; stroke-width: 1; }
.part-detail { fill: #e8edf0; }
.hit-area { fill: transparent; }
.addon-top { fill: rgba(125, 140, 152, 0.85); stroke: #5d6c78; }
.clamp { fill: none; stroke: #e8edf0; stroke-width: 1.6; }
.addon-label { font-size: 9.5px; fill: #fff; font-weight: 600; }
.piece.selected .part-fill, .piece.selected .leg, .piece.selected .deck,
.piece.selected .shelf, .piece.selected .drawer, .piece.selected .wall,
.piece.selected .under-part { stroke: var(--teal); stroke-width: 2.5; }
.piece.error .part-fill, .piece.error .leg, .piece.error .deck,
.piece.error .shelf, .piece.error .drawer, .piece.error .wall,
.piece.error .under-part { stroke: #d33627 !important; stroke-width: 3 !important; }
.dowel-piece { cursor: grab; }
.dowel-piece .dowel { stroke: #a8834f; stroke-width: 0.8; }
.dowel-piece.selected .dowel, .piece.selected .dowel { stroke: var(--teal) !important; stroke-width: 2.5; }
.dowel-handle { fill: var(--teal); stroke: #fff; stroke-width: 1.2; cursor: ew-resize; }
.dowel-piece.caution .dowel, .piece.caution .part-fill, .piece.caution .leg,
.piece.caution .deck, .piece.caution .under-part { stroke: #d9a514 !important; stroke-width: 2.5 !important; }
.dowel-piece.error .dowel { stroke: #d33627 !important; stroke-width: 3 !important; }

/* groove ticks */
.groove-tick { stroke: #97a6b1; stroke-width: 1; }

/* parts list — clean white graph-paper pad, same width as the configurator */
.parts-section {
  max-width: 1472px; margin: 0 auto 34px;
  background: #ffffff;
  background-image:
    repeating-linear-gradient(to bottom, transparent 0 23px, rgba(120, 160, 200, 0.16) 23px 24px),
    repeating-linear-gradient(to right, transparent 0 23px, rgba(120, 160, 200, 0.16) 23px 24px);
  border: 1px solid #e0e5e9; border-radius: 6px;
  box-shadow: 0 3px 10px rgba(40, 55, 70, 0.1), 0 1px 2px rgba(40, 55, 70, 0.08);
  padding: 20px 28px 26px 28px;
}
.parts-section h2 { font-size: 1.25rem; margin: 0 0 10px; }
#parts { columns: 2 420px; column-gap: 46px; }
#parts h3 { font-size: 0.82rem; color: #3f5060; margin: 12px 0 4px; }
#parts td { border-bottom: none; }
#parts .sub { padding-left: 26px; }
#parts .sub td { border-bottom: none; padding: 1.5px 4px; color: #4d5c6a; font-size: 0.82rem; }
#parts .sub .qty { color: #86959f; font-weight: 600; }
.parts-group { break-inside: avoid; margin-bottom: 10px; }
#parts table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
#parts td { padding: 4px; border-bottom: 1px solid #f0f2f4; vertical-align: top; }
#parts .qty { white-space: nowrap; color: var(--accent); font-weight: 700; width: 30px; }
#parts .path { color: var(--muted); font-size: 0.75rem; word-break: break-all; }

/* the hero/intro lives on the blog page (blog-intro-snippet.html), not in the app */
.setup { margin-top: 16px; }

/* touch: dragging pieces must not scroll the page */
#canvas .piece, #canvas-top .piece, .dowel-handle { touch-action: none; }

/* ---- typography polish: one cohesive heading system ---- */
h1, h2, h3 { color: var(--navy); }
.builder-head h2 { font-size: 1.35rem; font-weight: 700; letter-spacing: 0.01em; }
.parts-section h2 { font-size: 1.15rem; font-weight: 700; letter-spacing: 0.01em; margin: 0; }
.palette-label, .panel h2 { font-size: 0.95rem; font-weight: 700; color: var(--navy); }
.panel h3, #parts h3 {
  font-size: 0.78rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.08em; color: #51606e;
}
.help-card h3 { text-transform: none; letter-spacing: 0.01em; font-size: 1.1rem; color: var(--navy); }
.setup-label { font-weight: 600; color: var(--ink); }
body { line-height: 1.45; }

@media (max-width: 1100px) {
  .layout { grid-template-columns: 1fr; }
  .palette-panel, .right .panel { max-height: none; }
  /* palette becomes a compact chip row above the canvases on small screens */
  .palette-panel { position: static; }
  #palette { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
  #palette h3 { width: 100%; margin: 8px 0 2px; }
  #palette .pal-item { width: auto; margin: 0; padding: 6px 10px; font-size: 0.85rem; }
  #palette .hint { width: 100%; }
  .inspector-bar { gap: 10px; }
}
@media print {
  .hero, .setup .unit-toggle, .builder-head button, .palette-panel, #inspector { display: none !important; }
  .layout { display: block; }
  .panel, .canvas-wrap { border: none; max-height: none; overflow: visible; }
  body { background: #fff; }
}
