:root {
  color-scheme: light dark;
  --bg: #fbfaf7;
  --panel: #ffffff;
  --ink: #1c1b19;
  --muted: #5d5a54;
  --line: #ddd8ce;
  --accent: #9c3d12;
  --accent-ink: #ffffff;
  --sub: #4a4741;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16151a;
    --panel: #201f26;
    --ink: #f2f0ec;
    --muted: #b3aea6;
    --line: #3a3841;
    --accent: #ff9d5c;
    --accent-ink: #26160a;
    --sub: #cfc9c1;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.55 system-ui, -apple-system, "Segoe UI", sans-serif;
}

.hero, main, footer { max-width: 46rem; margin: 0 auto; padding: 0 1rem; }

.hero { padding-top: 1.5rem; padding-bottom: 0.5rem; }

.eyebrow {
  margin: 0 0 0.25rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.75rem;
  color: var(--accent);
  font-weight: 700;
}

h1 { margin: 0 0 0.4rem; font-size: 2rem; line-height: 1.1; }
h2 { font-size: 1.15rem; margin: 1.6rem 0 0.6rem; }
h3 { font-size: 1rem; margin: 1.2rem 0 0.4rem; }

.lead { margin: 0; color: var(--sub); }

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.75rem 1rem 1rem;
  margin-top: 1rem;
}

.grid { display: grid; gap: 0.75rem; grid-template-columns: 1fr; }

@media (min-width: 34rem) {
  .grid { grid-template-columns: 1fr 1fr; }
}

.field { display: flex; flex-direction: column; gap: 0.25rem; }

label { font-size: 0.85rem; font-weight: 600; color: var(--sub); }

.hint {
  margin: 0;
  font-size: 0.78rem;
  line-height: 1.4;
  color: var(--muted);
}

input, select, button, textarea {
  font: inherit;
  padding: 0.5rem 0.6rem;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--ink);
}

input, select { width: 100%; }

button { cursor: pointer; }

button.primary {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: var(--accent);
  font-weight: 700;
}

button:hover { border-color: var(--accent); }

.row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  margin-top: 0.9rem;
}

:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

.error { color: #b3261e; margin: 0.6rem 0 0; font-weight: 600; }
@media (prefers-color-scheme: dark) { .error { color: #ff8a80; } }

.muted { color: var(--muted); }

/* The one-line "start here" summary above the plan, filled in by firstup.js. */
.firstup {
  margin: 0.2rem 0 0.6rem;
  padding: 0.6rem 0.8rem;
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: 8px;
  background: var(--panel);
  color: var(--sub);
  font-size: 0.96rem;
}

/* The standing "read this before you post" note above the plan, shown by readthis.js. */
.readthis {
  margin: 0.2rem 0 0.8rem;
  padding: 0.7rem 0.9rem;
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: 8px;
  background: var(--bg);
  color: var(--sub);
  font-size: 0.94rem;
}

.readthis h3 { margin: 0 0 0.35rem; font-size: 0.95rem; color: var(--ink); }
.readthis ul { margin: 0; padding-left: 1.1rem; }
.readthis li { margin: 0.15rem 0; }

ul.plan { list-style: none; padding: 0; margin: 0.2rem 0 0; }

ul.plan li {
  padding: 0.3rem 0 0.3rem 0.9rem;
  border-left: 2px solid var(--line);
  margin-bottom: 0.2rem;
}

ul.plan li.sub {
  border-left-color: transparent;
  padding-left: 1.4rem;
  color: var(--sub);
  font-size: 0.94rem;
}

.textwrap {
  margin-top: 1rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--line);
}

.textwrap label { display: block; margin-bottom: 0.35rem; }

textarea#plantext {
  width: 100%;
  min-height: 16rem;
  white-space: pre;
  overflow: auto;
  font: 13px/1.45 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.keep {
  margin: 0.9rem 0 0;
  padding: 0.6rem 0.8rem;
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: 8px;
  background: var(--bg);
  color: var(--sub);
  font-size: 0.94rem;
}

.keep p { margin: 0; }
.keep .row { margin-top: 0.5rem; }

/* Flat list of worked-out lines, used by the run-cost panel (cost.js) and the
   last-order-date helper (cutoff.js); the one line that matters is marked out. */
.costout { margin-top: 0.6rem; }

.costout li.total {
  border-left-color: var(--accent);
  font-weight: 600;
}

.about { border-top: 1px solid var(--line); margin-top: 2rem; }

footer {
  padding: 1.5rem 1rem 2.5rem;
  color: var(--muted);
  font-size: 0.9rem;
}

a { color: var(--accent); }

/* Sticky build bar: phones only, and only once the script has shown it. */
.buildbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 5;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  justify-content: center;
  padding: 0.6rem 0.75rem;
  background: var(--panel);
  border-top: 1px solid var(--line);
  box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.12);
}

.buildbar.hidden { display: none; }

.buildbar-hint { font-size: 0.78rem; color: var(--muted); }

/* Secondary, smaller button so the quick build button stays the main action. */
.buildbar .barhide {
  padding: 0.4rem 0.6rem;
  font-size: 0.88rem;
  color: var(--muted);
}

/* On a narrow phone the hint is the first thing to go, so the bar stays one line. */
@media (max-width: 30rem) {
  .buildbar-hint { display: none; }
}

@media (max-width: 33.99rem) {
  body { padding-bottom: 5rem; }
}

@media (min-width: 34rem) {
  .buildbar { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* Printing the plan: hide the controls and the page furniture, keep the plan itself.
   #setup-hint is named here too: it has no "hint" class, so it would otherwise be
   printed on the sheet when the page is printed straight from the browser menu,
   before any plan has been built. #cutsec joins the list for the same reason as
   #costsec: its fields and button are controls, and its lines are on screen only. */
@media print {
  :root { color-scheme: light; }
  body { background: #fff; color: #000; font-size: 11.5pt; }
  .hero .eyebrow, .examples, .row, .hint, .textwrap, .buildbar, .about, footer, #error, #status, #keep, #costsec, #cutsec, #setup-hint {
    display: none;
  }
  .panel { border: 0; padding: 0; background: #fff; }
  .hero, main { max-width: none; padding: 0; }
  #output h3 { break-after: avoid; page-break-after: avoid; }
  ul.plan li { break-inside: avoid; page-break-inside: avoid; }
  ul.plan li { border-left-color: #bbb; }
  .firstup { background: #fff; border-color: #bbb; }
  .readthis { background: #fff; border-color: #bbb; break-inside: avoid; page-break-inside: avoid; }
}

/* Last rule on purpose: elements start hidden in markup and are revealed from JS by
   removing the "hidden" class, and this has to beat the equal-specificity display rules above. */
.hidden { display: none !important; }
