:root {
  color-scheme: light;
  --ink: #17211b;
  --muted: #647068;
  --paper: #f4f0e7;
  --surface: #fffdf7;
  --line: #cec6b7;
  --forest: #173f33;
  --forest-soft: #dfe8df;
  --rust: #a0442b;
  --rust-soft: #f0ddd4;
  --shadow: 0 22px 70px rgb(28 40 31 / 10%);
  font: 16px/1.55 Inter, "Segoe UI", ui-sans-serif, system-ui, sans-serif;
  color: var(--ink);
  background: var(--paper);
  text-rendering: optimizeLegibility;
}

* { box-sizing: border-box; }

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(circle at 82% 8%, rgb(160 68 43 / 9%), transparent 26rem),
    linear-gradient(90deg, transparent 49.9%, rgb(23 63 51 / 3%) 50%, transparent 50.1%),
    var(--paper);
}

button, input, textarea, select { font: inherit; }
button, .file-button { -webkit-tap-highlight-color: transparent; }
button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible, .file-button:focus-within {
  outline: 3px solid #dd8e65;
  outline-offset: 2px;
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 76px;
  padding: 14px clamp(20px, 4vw, 56px);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: inline-flex;
  gap: 12px;
  align-items: center;
  color: inherit;
  font: 800 1.08rem/1 "Segoe UI", sans-serif;
  letter-spacing: -.02em;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 50%;
  background: var(--forest);
  color: white;
  font-size: .72rem;
  letter-spacing: .08em;
}

.privacy-note {
  margin: 0;
  color: var(--muted);
  font-size: .78rem;
  font-weight: 700;
  letter-spacing: .04em;
}

.privacy-note span { color: #36805f; }

.app-shell {
  display: grid;
  grid-template-columns: minmax(220px, 280px) minmax(0, 1fr);
  min-height: calc(100vh - 76px);
}

.rail {
  display: flex;
  flex-direction: column;
  padding: 44px 28px 28px clamp(20px, 4vw, 56px);
  border-right: 1px solid var(--line);
}

.rail-intro { max-width: 26ch; }
.rail-intro > p:last-child { margin: 8px 0 0; color: var(--muted); }

.kicker {
  margin: 0;
  color: var(--rust);
  font-size: .72rem;
  font-weight: 850;
  letter-spacing: .14em;
  text-transform: uppercase;
}

.mode-switcher {
  display: grid;
  gap: 8px;
  margin: 42px 0;
}

.mode-button {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 13px 14px;
  border: 1px solid transparent;
  border-radius: 10px;
  color: var(--muted);
  background: transparent;
  font-weight: 800;
  text-align: left;
  cursor: pointer;
}

.mode-button:hover { background: rgb(255 253 247 / 65%); }
.mode-button.active { border-color: #b8c7bc; color: var(--forest); background: var(--forest-soft); }
.mode-number { font-size: .68rem; letter-spacing: .1em; }

.tool-stack { display: grid; gap: 5px; }

.text-button, .file-button {
  display: block;
  width: 100%;
  padding: 9px 0;
  border: 0;
  color: var(--ink);
  background: transparent;
  font-weight: 700;
  text-align: left;
  cursor: pointer;
}

.text-button:hover, .file-button:hover { color: var(--rust); }
.file-button input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.rail-footnote { margin: auto 0 0; padding-top: 42px; color: var(--muted); font-size: .78rem; }

.workspace {
  width: min(1120px, 100%);
  padding: clamp(36px, 6vw, 80px);
}

.project-header {
  display: flex;
  gap: 28px;
  align-items: flex-start;
  justify-content: space-between;
}

.project-header h1 {
  max-width: 18ch;
  margin: 9px 0 12px;
  font: 700 clamp(2.6rem, 7vw, 5.8rem)/.92 Georgia, "Times New Roman", serif;
  letter-spacing: -.055em;
}

.project-notes { max-width: 65ch; margin: 0; color: var(--muted); white-space: pre-wrap; }

.quiet-button, .primary-button, .icon-button {
  border-radius: 999px;
  font-weight: 800;
  cursor: pointer;
}

.quiet-button {
  padding: 9px 15px;
  border: 1px solid var(--line);
  color: var(--ink);
  background: var(--surface);
}

.quiet-button:hover { border-color: var(--forest); }
.quiet-button:disabled, .primary-button:disabled { opacity: .45; cursor: not-allowed; }

.primary-button {
  padding: 11px 18px;
  border: 1px solid var(--forest);
  color: white;
  background: var(--forest);
  box-shadow: 0 8px 18px rgb(23 63 51 / 16%);
}

.primary-button:hover { background: #205a48; }

.project-meter {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  margin: 46px 0 72px;
  border-block: 1px solid var(--line);
}

.project-meter > div { display: grid; gap: 2px; padding: 20px 20px 20px 0; }
.project-meter > div + div { padding-left: 20px; border-left: 1px solid var(--line); }
.meter-value { font: 700 1.65rem/1 Georgia, serif; }
.progress-value { font-size: 1.18rem; }
.meter-label { color: var(--muted); font-size: .72rem; font-weight: 750; letter-spacing: .08em; text-transform: uppercase; }

.section-heading {
  display: flex;
  gap: 24px;
  align-items: end;
  justify-content: space-between;
  margin-bottom: 26px;
}

.section-heading h2 { max-width: 24ch; margin: 6px 0 0; font: 700 clamp(1.7rem, 4vw, 2.7rem)/1.05 Georgia, serif; letter-spacing: -.035em; }
.lock-note { padding: 12px 16px; border-left: 3px solid var(--rust); color: #6d2b1b; background: var(--rust-soft); }

.step-list, .reassembly-list { display: grid; gap: 16px; margin: 0; padding: 0; list-style: none; }

.step-card {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr) auto;
  gap: 20px;
  align-items: start;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgb(255 253 247 / 82%);
  box-shadow: 0 8px 24px rgb(40 45 39 / 4%);
}

.step-index {
  display: grid;
  width: 52px;
  height: 52px;
  place-items: center;
  border: 1px solid #abb9af;
  border-radius: 50%;
  color: var(--forest);
  font: 700 1.2rem/1 Georgia, serif;
}

.step-body h3 { margin: 1px 0 6px; font: 700 1.45rem/1.12 Georgia, serif; }
.step-body > p { margin: 0 0 14px; color: var(--muted); white-space: pre-wrap; }
.step-photo { display: block; width: min(100%, 460px); max-height: 320px; margin: 16px 0; border-radius: 10px; object-fit: cover; }
.part-pills { display: flex; flex-wrap: wrap; gap: 8px; margin: 0; padding: 0; list-style: none; }
.part-pills li { padding: 6px 9px; border-radius: 6px; background: var(--forest-soft); font-size: .78rem; font-weight: 700; }
.step-actions { display: flex; gap: 6px; }
.step-actions button { padding: 6px 9px; border: 0; border-radius: 6px; color: var(--muted); background: transparent; font-size: .78rem; font-weight: 750; cursor: pointer; }
.step-actions button:hover { color: var(--rust); background: var(--rust-soft); }
.step-actions button:disabled { opacity: .4; cursor: not-allowed; }

.empty-state { padding: 64px 28px; border: 1px dashed #aaa294; border-radius: 16px; text-align: center; }
.empty-state[hidden] { display: none; }
.empty-state h3 { margin: 8px 0; font: 700 1.55rem/1.1 Georgia, serif; }
.empty-state p { max-width: 48ch; margin: 0 auto; color: var(--muted); }
.empty-glyph { color: var(--rust); font: 700 2.5rem/1 Georgia, serif; }

.next-banner { margin-bottom: 22px; padding: 18px 20px; border-radius: 12px; color: white; background: var(--forest); font: 700 1.08rem/1.2 Georgia, serif; }
.reassembly-card { display: grid; grid-template-columns: 52px minmax(0, 1fr) auto; gap: 18px; align-items: center; padding: 19px 20px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }
.reassembly-card.completed { opacity: .58; }
.reassembly-card.next { border-color: var(--rust); box-shadow: 0 0 0 3px var(--rust-soft); }
.reassembly-card h3 { margin: 0 0 5px; font: 700 1.2rem/1.15 Georgia, serif; }
.reassembly-card p { margin: 0; color: var(--muted); font-size: .85rem; }

.status { min-height: 24px; margin: 28px 0 0; color: var(--forest); font-weight: 750; }
.status.error { color: #9d241d; }

.editor-dialog {
  width: min(600px, calc(100% - 28px));
  max-height: calc(100vh - 28px);
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.step-dialog { width: min(860px, calc(100% - 28px)); }
.editor-dialog::backdrop { background: rgb(18 28 22 / 52%); backdrop-filter: blur(3px); }
.editor-dialog form { display: grid; gap: 20px; padding: clamp(22px, 5vw, 38px); }
.dialog-heading, .parts-heading { display: flex; gap: 20px; align-items: start; justify-content: space-between; }
.dialog-heading h2 { margin: 5px 0 0; font: 700 2rem/1 Georgia, serif; }
.icon-button { width: 36px; height: 36px; border: 1px solid var(--line); color: var(--ink); background: transparent; font-size: 1.35rem; }
.editor-dialog label { display: grid; gap: 7px; color: var(--muted); font-size: .78rem; font-weight: 800; letter-spacing: .04em; }
.editor-dialog input, .editor-dialog textarea, .editor-dialog select { width: 100%; padding: 10px 11px; border: 1px solid #aaa294; border-radius: 8px; color: var(--ink); background: white; }
.field-grid { display: grid; gap: 16px; }
.photo-field { padding: 16px; border: 1px dashed #aaa294; border-radius: 10px; }
.photo-field > p { margin: 3px 0 12px; color: var(--muted); font-size: .8rem; }
.photo-preview { display: flex; gap: 14px; align-items: center; margin-top: 14px; }
.photo-preview img { width: 100px; height: 76px; border-radius: 8px; object-fit: cover; }
.parts-heading { align-items: end; margin-top: 8px; }
.parts-heading h3 { margin: 3px 0 0; font: 700 1.45rem/1 Georgia, serif; }
.parts-editor { display: grid; gap: 10px; }
.part-row { display: grid; grid-template-columns: 1.6fr 1fr .65fr 1fr auto; gap: 10px; align-items: end; margin: 0; padding: 14px; border: 1px solid var(--line); border-radius: 10px; }
.part-row legend { padding: 0 5px; color: var(--muted); font-size: .72rem; font-weight: 800; text-transform: uppercase; }
.part-notes-field { grid-column: 1 / -2; }
.remove-part { padding: 8px; border: 0; color: var(--rust); background: transparent; font-size: .76rem; font-weight: 800; cursor: pointer; }
.dialog-actions { display: flex; gap: 10px; justify-content: flex-end; padding-top: 10px; border-top: 1px solid var(--line); }

@media (max-width: 820px) {
  .app-shell { display: block; }
  .rail { padding: 24px 20px; border-right: 0; border-bottom: 1px solid var(--line); }
  .rail-intro, .rail-footnote { display: none; }
  .mode-switcher { grid-template-columns: 1fr 1fr; margin: 0 0 16px; }
  .tool-stack { grid-template-columns: repeat(3, 1fr); }
  .text-button, .file-button { padding: 8px; text-align: center; }
  .workspace { padding: 42px 20px 64px; }
  .project-meter { margin-bottom: 48px; }
  .step-card { grid-template-columns: 46px minmax(0, 1fr); }
  .step-actions { grid-column: 2; }
  .part-row { grid-template-columns: 1fr 1fr; }
  .part-notes-field { grid-column: 1; }
}

@media (max-width: 540px) {
  .privacy-note { display: none; }
  .tool-stack { grid-template-columns: 1fr 1fr; }
  .project-header, .section-heading { align-items: flex-start; flex-direction: column; }
  .project-meter { grid-template-columns: 1fr; }
  .project-meter > div + div { padding-left: 0; border-top: 1px solid var(--line); border-left: 0; }
  .step-card, .reassembly-card { grid-template-columns: 42px minmax(0, 1fr); gap: 12px; padding: 16px; }
  .step-index { width: 40px; height: 40px; }
  .reassembly-card button { grid-column: 2; justify-self: start; }
  .part-row { grid-template-columns: 1fr; }
  .part-notes-field { grid-column: 1; }
}

@media (prefers-reduced-motion: no-preference) {
  .step-card, .reassembly-card { animation: arrive .32s ease both; }
  @keyframes arrive { from { opacity: 0; transform: translateY(8px); } }
}
