:root {
  color-scheme: light;
  --table: #e3e6ea;
  --paper: #f6f7f8;
  --ink: #1b2330;
  --muted: #3e4a55;
  --line: #d0d5db;
  --line-strong: #8b95a1;
  --indigo: #3e5274;
  --indigo-deep: #2c3c58;
  --chalk: #c46a2e;
  --cloth: #3e5274;
  --lining: #e7dcc8;
  --web: #f3e6cf;
  --header: 118px;
  --font: "Noto Sans CJK KR", "NanumGothic", "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  --display: "NanumMyeongjo", "Noto Serif CJK KR", serif;
}

* { box-sizing: border-box; }

html { scroll-padding-top: calc(var(--header) + 12px); }

body {
  margin: 0;
  background: var(--table);
  color: var(--ink);
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.65;
  word-break: keep-all;
}

img { max-width: 100%; display: block; }

a { color: inherit; }

button, input { font: inherit; }

:focus { outline: none; }

a:focus-visible,
button:focus-visible,
input:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 3px;
}

.skip {
  position: absolute;
  left: 12px;
  top: -40px;
  background: var(--paper);
  padding: 8px 12px;
  z-index: 5;
}

.skip:focus { top: 12px; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 4;
  width: 100%;
  max-width: 100%;
  overflow-x: clip;
  background: color-mix(in srgb, var(--table) 92%, white);
  border-bottom: 1px solid var(--line);
}

.bar {
  display: flex;
  align-items: baseline;
  gap: 16px;
  max-width: 1120px;
  margin: 0 auto;
  padding: 14px 20px 0;
}

.mark {
  font-family: var(--display);
  font-size: 26px;
  line-height: 1.2;
  text-decoration: none;
  letter-spacing: -0.03em;
}

.pattern {
  margin: 0;
  color: var(--muted);
}

.count {
  margin: 0 0 0 auto;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
}

.rail {
  max-width: min(1120px, 100%);
  margin: 0 auto;
  padding: 8px 0 0;
  overflow-x: auto;
  overscroll-behavior-x: contain;
}

.rail ol {
  display: flex;
  gap: 0;
  list-style: none;
  width: max-content;
  min-width: 100%;
  margin: 0;
  padding: 0 20px 0 8px;
  overflow-x: visible;
  scroll-snap-type: x proximity;
}

.rail li { scroll-snap-align: start; }

.rail a {
  display: flex;
  flex: 0 0 auto;
  flex-direction: column;
  justify-content: flex-end;
  min-width: 96px;
  min-height: 52px;
  padding: 8px 12px 10px;
  white-space: nowrap;
  text-decoration: none;
  border-top: 3px dashed var(--line-strong);
  color: var(--muted);
}

.rail a[data-stitched="true"] {
  border-top-style: solid;
  border-top-color: var(--indigo);
  color: var(--ink);
}

.rail a[aria-current="page"] {
  border-top: 3px solid var(--ink);
  color: var(--ink);
  font-weight: 500;
}

.rail-n {
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.wrap {
  max-width: 1120px;
  margin: 0 auto;
  padding: 28px 20px 64px;
}

.overview {
  display: grid;
  gap: 28px;
  grid-template-areas:
    "lesson"
    "photo"
    "phases"
    "cta";
}

.lesson { grid-area: lesson; max-width: 38rem; }
.hero-photo { grid-area: photo; margin: 0; }
.phases-block { grid-area: phases; }
.cta { grid-area: cta; }

h1 {
  margin: 0 0 12px;
  font-size: clamp(32px, 4vw, 48px);
  font-weight: 500;
  line-height: 1.25;
  letter-spacing: -0.03em;
}

.why {
  margin: 0 0 12px;
}

.why p { margin: 0 0 6px; }

.spec {
  margin: 0;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.hero-photo img {
  width: 100%;
  aspect-ratio: 3 / 2;
  object-fit: cover;
  background: #d5d8dc;
  border: 1px solid var(--line);
}

.measure {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 16px;
  align-items: center;
  margin-top: 12px;
}

.measure svg { width: 180px; height: auto; }

.measure p { margin: 0; color: var(--muted); }

.swatches {
  display: flex;
  flex-wrap: wrap;
  gap: 14px 18px;
  list-style: none;
  margin: 12px 0 0;
  padding: 0;
}

.swatches li {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 32px;
}

.swatches i {
  width: 18px;
  height: 18px;
  border: 1px solid var(--line-strong);
  display: block;
}

.swatch-cloth { background: var(--cloth); }
.swatch-lining { background: var(--lining); }
.swatch-web { background: var(--web); }

.before {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: baseline;
  margin: 0 0 18px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.before a { font-weight: 500; }

.phases {
  list-style: none;
  margin: 0;
  padding: 4px 0 0 4px;
  border-left: 2px dashed var(--line-strong);
}

.phases > li {
  position: relative;
  padding: 0 0 26px 22px;
}

.phases > li::before {
  content: "";
  width: 11px;
  height: 11px;
  border: 2px solid var(--indigo-deep);
  background: var(--table);
  border-radius: 50%;
  position: absolute;
  left: -7px;
  top: 6px;
}

.phases > li.is-done::before { background: var(--indigo); }

.phases h2 {
  margin: 0;
  font-size: 22px;
  font-weight: 500;
  letter-spacing: -0.02em;
  line-height: 1.3;
}

.phase-num {
  font-variant-numeric: tabular-nums;
  margin-right: 8px;
}

.phases .summary {
  margin: 4px 0 0;
  color: var(--muted);
}

.phases ol {
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
}

.phases a.step-link {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  min-height: 44px;
  text-decoration: none;
  border-bottom: 1px solid transparent;
}

.phases a.step-link:hover { border-bottom-color: var(--ink); }

.meta {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.step-state:empty { display: none; }

.step-state:not(:empty)::after { content: " · "; }

.cta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 8px 0 0;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 16px;
  border-radius: 4px;
  border: 1px solid var(--line-strong);
  background: transparent;
  color: var(--ink);
  text-decoration: none;
  cursor: pointer;
}

.btn-primary {
  background: var(--indigo-deep);
  border-color: var(--indigo-deep);
  color: white;
}

.btn-primary:hover { background: #24344e; }

.btn-quiet:hover { background: color-mix(in srgb, var(--ink) 6%, transparent); }

.done-btn[aria-pressed="true"] {
  background: var(--paper);
  border-color: var(--indigo);
}

.needs-js { display: none; }

html.js .needs-js { display: inline-flex; }

html.js .needs-js[hidden] { display: none; }

.step {
  display: grid;
  gap: 20px 32px;
  grid-template-areas:
    "head"
    "photo"
    "body"
    "diagram";
  scroll-margin-top: calc(var(--header) + 12px);
}

.step + .step { margin-top: 56px; }

html.js body:not(.show-all) .step { display: none; }

html.js body.is-stepping .overview { display: none; }

html.js body.is-stepping .step.is-active {
  display: grid;
}

html.js body:not(.show-all):not(.is-stepping) .step { display: none; }

.step-head { grid-area: head; max-width: 40rem; }

.phase-name {
  margin: 0 0 4px;
  color: var(--muted);
}

.step h2 {
  margin: 0 0 8px;
  font-size: clamp(28px, 3vw, 36px);
  font-weight: 500;
  letter-spacing: -0.02em;
  line-height: 1.3;
}

.lead { margin: 0; max-width: 38rem; }

.step-photo { grid-area: photo; margin: 0; }

.step-photo img {
  width: 100%;
  aspect-ratio: 3 / 2;
  object-fit: cover;
  background: #d5d8dc;
  border: 1px solid var(--line);
}

.step-photo figcaption,
.diagram figcaption,
.hero-photo figcaption {
  margin-top: 8px;
  color: var(--muted);
}

figure.is-missing img { display: none; }

figure.is-missing figcaption::before {
  content: "사진을 찾지 못했다. 아래 그림의 치수로 박는다. ";
}

.step-body { grid-area: body; }

.diagram { grid-area: diagram; margin: 0; }

.sheet {
  background: var(--paper);
  border: 1px solid var(--line);
  padding: 12px 12px 4px;
}

.sheet svg { width: 100%; height: auto; display: block; }

.sheet text,
.measure text {
  font-family: var(--font);
  fill: var(--ink);
  font-size: 14px;
}

.sheet .dim { fill: var(--muted); font-size: 13px; }

.layers {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 16px;
  margin: 0 0 8px;
}

.layers label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  cursor: pointer;
}

.layers input { width: 18px; height: 18px; accent-color: var(--indigo-deep); }

.layers label:has(input:not(:checked)) { color: var(--muted); }

.diagram:has(input[data-layer="now"]:not(:checked)) .layer-now,
.diagram:has(input[data-layer="seam"]:not(:checked)) .layer-seam,
.diagram:has(input[data-layer="done"]:not(:checked)) .layer-done,
.diagram:has(input[data-layer="interfacing"]:not(:checked)) .layer-interfacing {
  display: none;
}

.actions {
  margin: 16px 0 0;
  padding-left: 1.3rem;
}

.actions li { padding: 8px 0; }

.actions li::marker { font-weight: 500; font-variant-numeric: tabular-nums; }

.caution { margin: 12px 0 0; }

.caution strong { font-weight: 500; }

.checks {
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
}

.checks label {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  min-height: 44px;
  padding: 10px 0;
  border-top: 1px solid var(--line);
  cursor: pointer;
}

.checks input {
  width: 18px;
  height: 18px;
  margin-top: 4px;
  accent-color: var(--indigo-deep);
  flex: none;
}

.step-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
}

.step-nav .btn-primary { margin-left: auto; }

.cut {
  width: 100%;
  border-collapse: collapse;
  margin: 16px 0;
  font-variant-numeric: tabular-nums;
}

.cut th,
.cut td {
  text-align: left;
  padding: 10px 8px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

.cut th { font-weight: 500; }

.cut caption {
  caption-side: top;
  text-align: left;
  font-weight: 500;
  padding: 0 0 8px;
}

.tools {
  display: grid;
  gap: 10px;
  margin: 0;
}

.tools div {
  display: grid;
  grid-template-columns: 72px 1fr;
  gap: 12px;
}

.tools dt { font-weight: 500; }

.tools dd { margin: 0; }

.site-foot {
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 20px 40px;
  color: var(--muted);
}

.site-foot p { margin: 0; }

@media (max-width: 520px) {
  .measure { grid-template-columns: 1fr; }
}

@media (max-width: 899px) {
  .step-nav .btn-primary,
  .step-nav .done-btn { margin-left: 0; }

  .step-nav {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .step-nav .done-btn,
  .step-nav .btn-primary { grid-column: 1 / -1; }
}

@media (min-width: 900px) {
  .overview {
    grid-template-columns: minmax(0, 1.12fr) minmax(300px, 0.88fr);
    column-gap: 48px;
    align-items: start;
    grid-template-areas:
      "photo lesson"
      "photo phases"
      "photo cta";
  }

  .step:not(.no-photo) {
    grid-template-columns: minmax(0, 1.15fr) minmax(280px, 0.85fr);
    grid-template-areas:
      "head head"
      "photo body"
      "diagram body";
    align-items: start;
  }

  .step.no-photo {
    grid-template-columns: minmax(0, 1.15fr) minmax(280px, 0.85fr);
    grid-template-areas:
      "head head"
      "diagram body";
    align-items: start;
  }

  #prep {
    grid-template-areas:
      "head head"
      "diagram diagram"
      "body body";
  }

}

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; }
}

@media print {
  .site-header, .step-nav, .cta, .layers, .needs-js { display: none !important; }
  .step, .overview { display: block !important; }
  .step { break-inside: avoid; margin-top: 24px; }
  body { background: white; }
}
