:root {
  color-scheme: light;
  --paper: #f3ecdf;
  --wash: #fffaf3;
  --card: #fffaf3;
  --ink: #241c16;
  --muted: #655b50;
  --line: #e0d3c0;
  --cut: #c4381a;
  --mountain: #1f6b45;
  --valley: #1d4e89;
  --serif: Georgia, "Iowan Old Style", "Palatino Linotype", Palatino, serif;
  --sans: system-ui, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --paper: #14110f;
    --wash: #1c1815;
    --card: #221c18;
    --ink: #f6efe4;
    --muted: #c4b6a4;
    --line: #3d342c;
  }
  .swatch { border-color: rgba(246, 239, 228, 0.5); }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100dvh;
  color: var(--ink);
  background:
    linear-gradient(180deg, var(--wash), transparent 320px),
    var(--paper);
  font-family: var(--sans);
  font-size: 1rem;
  line-height: 1.5;
}

body::before {
  content: "";
  display: block;
  height: 6px;
  background: linear-gradient(90deg, var(--cut), var(--ink) 46%, var(--mountain));
}

button, input { font: inherit; color: inherit; }

button {
  cursor: pointer;
  border: 1px solid transparent;
  background: var(--ink);
  color: var(--paper);
  border-radius: 999px;
  padding: 0.65rem 1.05rem;
  min-height: 44px;
}

button.ghost {
  background: transparent;
  color: var(--ink);
  border-color: var(--line);
}

button:disabled { opacity: 0.38; cursor: not-allowed; }

button:hover:not(:disabled) { filter: brightness(1.08); }

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

.skip {
  position: absolute;
  left: 0.75rem;
  top: -4rem;
  background: var(--card);
  color: var(--ink);
  padding: 0.4rem 0.7rem;
  border-radius: 0.5rem;
  z-index: 5;
}

.skip:focus { top: 0.75rem; }

.frame {
  max-width: 1120px;
  margin: 0 auto;
  padding: 0.85rem 1.4rem 2rem;
}

.top {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.mark {
  margin: 0;
  font-family: var(--serif);
  font-size: 1.35rem;
  letter-spacing: -0.02em;
}

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

.tag { margin: 0.15rem 0 0; }

.count {
  display: inline-block;
  min-width: 1.4rem;
  margin-left: 0.35rem;
  padding: 0.05rem 0.4rem;
  border-radius: 999px;
  background: var(--paper);
  color: var(--ink);
  font-size: 0.8rem;
}

button.ghost .count { background: var(--ink); color: var(--paper); }

.banner {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  align-items: center;
  margin: 0 0 1rem;
  padding: 0.7rem 0.9rem;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 0.9rem;
}

.layout {
  display: grid;
  grid-template-columns: 11rem minmax(0, 1fr);
  gap: 1.5rem;
  align-items: start;
}

.steps {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  position: sticky;
  top: 0.75rem;
}

.steps button {
  background: transparent;
  color: var(--ink);
  border: 1px solid transparent;
  border-radius: 0.8rem;
  text-align: left;
  padding: 0.55rem 0.75rem;
}

.steps button[aria-current="step"] {
  background: var(--card);
  border-color: var(--line);
  font-weight: 650;
}

h1 {
  margin: 0 0 0.35rem;
  font-family: var(--serif);
  font-size: clamp(1.7rem, 3vw, 2.6rem);
  font-weight: 600;
  letter-spacing: -0.03em;
  line-height: 1.12;
  text-wrap: balance;
}

.lede { margin: 0 0 1.1rem; max-width: 40rem; color: var(--muted); }

.pet-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.85rem;
}

.pet-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.2rem;
  width: 100%;
  background: var(--card);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 1.15rem;
  padding: 0.7rem 0.75rem 0.9rem;
  text-align: left;
  box-shadow: 0 1px 0 rgba(36, 28, 22, 0.04);
  transition: transform 160ms ease;
}

.pet-card svg {
  width: auto;
  height: 108px;
  max-width: 100%;
  align-self: center;
}

.pet-card strong {
  font-family: var(--serif);
  font-size: 1.18rem;
  font-weight: 600;
}

.pet-card .blurb { color: var(--muted); font-size: 0.9rem; }

.pet-card[data-on="true"] {
  border-color: var(--ink);
  box-shadow: inset 0 0 0 1px var(--ink);
}

.pet-card:hover:not(:disabled) { transform: translateY(-2px); }

.pill {
  font-size: 0.7rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.12rem 0.45rem;
  color: var(--muted);
}

.style-grid {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) minmax(260px, 420px);
  gap: 1.5rem;
  align-items: start;
}

.hero-card, .controls, .guide-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 1.15rem;
  padding: 1rem;
}

.hero-card { text-align: center; }

.hero-card svg { width: min(100%, 280px); height: auto; }

.hero-card .thumb-svg { width: 100%; margin-top: 0.8rem; }

.hero-name {
  margin: 0.2rem 0 0;
  font-family: var(--serif);
  font-size: 2rem;
  letter-spacing: -0.03em;
}

.field, fieldset { border: 0; margin: 0 0 0.9rem; padding: 0; }

.field { display: flex; flex-direction: column; gap: 0.3rem; font-weight: 600; }

legend { font-weight: 650; margin-bottom: 0.4rem; padding: 0; }

input[type="text"] {
  min-height: 44px;
  border-radius: 0.8rem;
  border: 1px solid var(--line);
  background: var(--paper);
  padding: 0.55rem 0.75rem;
  font-weight: 500;
}

.swatches { display: flex; flex-wrap: wrap; gap: 0.45rem; align-items: center; }

.swatch {
  width: 2.75rem;
  height: 2.75rem;
  padding: 0;
  border-radius: 999px;
  border: 1px solid rgba(36, 28, 22, 0.25);
}

.swatch[aria-pressed="true"] {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}

.custom { display: inline-flex; align-items: center; gap: 0.35rem; font-size: 0.85rem; font-weight: 500; }

input[type="color"] {
  width: 2.75rem;
  height: 2.75rem;
  padding: 0;
  border: 1px solid var(--line);
  background: transparent;
  border-radius: 999px;
}

.seg {
  display: flex;
  width: fit-content;
  border: 1px solid var(--line);
  border-radius: 999px;
  overflow: hidden;
}

.seg button {
  background: transparent;
  color: var(--ink);
  border-radius: 0;
  min-width: 6.5rem;
}

.seg button[aria-pressed="true"] { background: var(--ink); color: var(--paper); }

.hint { margin: 0.35rem 0 0; color: var(--muted); font-size: 0.85rem; }

.bar { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.4rem; }

.controls .bar {
  position: sticky;
  bottom: 0;
  background: var(--card);
  padding-top: 0.75rem;
}

.thumb-svg, .sheet-svg { display: block; background: #fffaf3; }

.thumb-svg {
  width: 100%;
  height: auto;
  border: 1px solid var(--line);
  border-radius: 0.8rem;
}

.sheet-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 1rem;
  margin-bottom: 0.8rem;
}

.sheet-top .lede { margin-bottom: 0; }

.sheet-top h1 { font-size: clamp(1.6rem, 2vw, 2.1rem); }

.sheet-top .bar { margin-top: 0; justify-content: flex-end; }

.sheet-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  gap: 1rem;
  align-items: start;
}

.sheet-card {
  width: min(100%, calc(64vh * 210 / 297));
  margin-inline: auto;
  background: #fffaf3;
  color: #241c16;
  padding: 0.45rem;
  border-radius: 0.35rem;
  box-shadow: 0 18px 50px rgba(36, 28, 22, 0.12);
}

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

.guide-card h2 {
  margin: 0 0 0.6rem;
  font-family: var(--serif);
  font-size: 1.35rem;
}

.guide { margin: 0; padding-left: 1.15rem; display: flex; flex-direction: column; gap: 0.55rem; }

.guide strong { font-family: var(--serif); }

.fine {
  margin: 1.25rem 0 0;
  color: var(--muted);
  font-size: 0.85rem;
}

dialog {
  border: 1px solid var(--line);
  border-radius: 1.1rem;
  background: var(--card);
  color: var(--ink);
  padding: 0;
  width: min(520px, calc(100% - 1.5rem));
}

dialog::backdrop { background: rgba(20, 16, 12, 0.5); }

.shelf-head, .shelf-body { padding: 1rem 1rem 0.2rem; }

.shelf-head { display: flex; justify-content: space-between; align-items: center; }

.shelf-head h2 { margin: 0; font-family: var(--serif); font-size: 1.5rem; }

.shelf-list { list-style: none; margin: 0; padding: 0 0 1rem; display: flex; flex-direction: column; gap: 0.4rem; }

.shelf-row { display: flex; gap: 0.4rem; align-items: center; }

.shelf-open {
  flex: 1;
  display: flex;
  gap: 0.6rem;
  align-items: center;
  background: transparent;
  color: var(--ink);
  border-radius: 0.9rem;
  text-align: left;
  padding: 0.3rem 0.45rem;
}

.shelf-open svg { width: 76px; height: auto; flex: none; }

.shelf-open small { display: block; color: var(--muted); }

.empty { color: var(--muted); margin-top: 0.2rem; }

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

@media (max-width: 800px) {
  .layout, .style-grid, .sheet-layout, .sheet-top { grid-template-columns: 1fr; }
  .sheet-top { flex-direction: column; align-items: stretch; }
  .sheet-top .bar { justify-content: flex-start; }
  .sheet-card { width: min(100%, 420px); }
  .steps { position: static; flex-direction: row; }
  .steps button { flex: 1; text-align: center; padding-inline: 0.3rem; }
  .pet-grid { grid-template-columns: 1fr 1fr; }
  .top { align-items: flex-start; }
}

@media (max-width: 420px) {
  .frame { padding-inline: 0.8rem; }
  .pet-grid { gap: 0.55rem; }
  .pet-card .blurb { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition: none !important;
    animation: none !important;
  }
  .pet-card:hover { transform: none; }
}

@media print {
  body { background: white; }
  body::before, .no-print { display: none !important; }
  .frame, .layout, .stage { display: block; max-width: none; padding: 0; }
  .sheet-card { box-shadow: none; padding: 0; }
  .sheet-layout { display: block; }
  .sheet-svg { width: 190mm; max-height: none; }
  .guide-card {
    break-before: page;
    border: 0;
    background: white;
    color: black;
  }
}
