:root {
  --paper: #f4ebd8;
  --ivory: #fbf6ea;
  --gall: #241c16;
  --rule: #b9a88a;
  --wax: #7a2a28;
  --wax-soft: #9a3d36;
  --slate: #2f3d3a;
  --twine: #b8924a;
  --leaf: #6b7a62;
  --shadow: 0 18px 40px rgba(36, 28, 22, 0.12);
  --sans: "Source Sans 3", "Helvetica Neue", sans-serif;
  --serif: "Source Serif 4", "Iowan Old Style", serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--gall);
  font-family: var(--sans);
  line-height: 1.5;
}
img { max-width: 100%; display: block; }
button, input { font: inherit; }
a { color: inherit; }

.intro-pending body { overflow: hidden; }
.intro[hidden], [hidden] { display: none !important; }

.intro {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 22px 28px 28px;
  background: var(--paper);
}
.intro-bar, .intro-caption {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--leaf);
}
.intro-stage {
  display: grid;
  place-items: center;
  gap: 28px;
}
.intro-svg { width: min(420px, 72vw); }
.intro-paper { fill: var(--ivory); stroke: var(--slate); stroke-width: 1.4; }
.intro-flap { fill: none; stroke: var(--slate); stroke-width: 1.4; stroke-dasharray: 220; stroke-dashoffset: 220; }
.intro-twine { fill: none; stroke: var(--twine); stroke-width: 3; stroke-linecap: round; stroke-dasharray: 180; stroke-dashoffset: 180; }
.intro-wax { fill: var(--wax); transform-origin: 140px 86px; transform: scale(0); }
.intro-knot { stroke: var(--ivory); stroke-width: 1.6; opacity: 0; }
.intro-type { text-align: center; opacity: 0; }
.intro-kicker { margin: 0 0 8px; letter-spacing: 0.16em; text-transform: uppercase; font-size: 12px; color: var(--leaf); }
.intro h1 { margin: 0; font-family: var(--serif); font-size: clamp(42px, 8vw, 72px); font-weight: 600; }
.intro-line { margin: 8px 0 0; color: var(--slate); }

.intro.is-playing .intro-flap { animation: draw 2.2s 0.4s ease forwards; }
.intro.is-playing .intro-twine { animation: draw 2.4s 1.6s ease forwards; }
.intro.is-playing .intro-wax { animation: stamp 0.7s 4.2s cubic-bezier(.2,1.4,.3,1) forwards; }
.intro.is-playing .intro-knot { animation: fade 0.4s 4.6s ease forwards; }
.intro.is-playing .intro-type { animation: fade 0.8s 6.2s ease forwards; }

@keyframes draw { to { stroke-dashoffset: 0; } }
@keyframes stamp { to { transform: scale(1); } }
@keyframes fade { to { opacity: 1; } }

.nav {
  position: sticky;
  top: 14px;
  z-index: 20;
  margin: 14px auto 0;
  width: min(1120px, calc(100% - 28px));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 16px;
  background: var(--slate);
  color: var(--ivory);
  border-radius: 18px;
  box-shadow: var(--shadow);
}
.nav-brand { display: flex; align-items: center; gap: 10px; text-decoration: none; font-weight: 600; }
.nav-brand img { background: var(--ivory); border-radius: 50%; }
.nav nav { display: flex; gap: 22px; font-size: 14px; }
.nav nav a { text-decoration: none; opacity: 0.86; }
.nav-actions { display: flex; align-items: center; gap: 14px; }
.text-btn, #skip-intro {
  background: none;
  border: 0;
  color: inherit;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.nav-cta, .wax-btn, .slate-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 0 16px;
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  text-decoration: none;
  font-weight: 600;
}
.nav-cta, .wax-btn { background: var(--wax); color: var(--ivory); }
.slate-btn { background: var(--slate); color: var(--ivory); margin-top: 28px; }

.desk { width: min(1120px, calc(100% - 28px)); margin: 28px auto 0; }
.canvas {
  background: var(--ivory);
  border-radius: 28px;
  padding: 18px 18px 16px;
  box-shadow: var(--shadow);
  background-image: radial-gradient(circle at 12% 18%, rgba(107,122,98,0.08), transparent 36%);
}
.canvas-tag {
  margin: 0 0 10px;
  font-size: 12px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--leaf);
}
.canvas-stage {
  display: grid;
  grid-template-columns: 1fr minmax(240px, 300px);
  gap: 16px;
  min-height: 420px;
  align-items: stretch;
}
.envelope {
  margin: 0;
  position: relative;
  background: #efe3c8;
  border-radius: 20px;
  overflow: hidden;
  display: grid;
  place-items: center;
  perspective: 900px;
}
.envelope-art { width: min(100%, 520px); }
.env-body { fill: #f7efdc; stroke: var(--slate); stroke-width: 1.5; }
.env-flap { fill: #f3e6c9; stroke: var(--slate); stroke-width: 1.5; transform-box: fill-box; transform-origin: 50% 0%; transition: transform 0.7s ease; }
.env-inner { fill: #fff8ea; stroke: var(--rule); stroke-width: 1; opacity: 0; transition: opacity 0.4s ease; }
.env-twine { fill: none; stroke: var(--twine); stroke-width: 5; stroke-linecap: round; transition: opacity 0.4s ease, transform 0.6s ease; }
.env-wax { fill: var(--wax); transition: transform 0.45s ease, opacity 0.45s ease; transform-origin: 210px 132px; }
.env-knot { stroke: var(--ivory); stroke-width: 2; }
.envelope[data-state="untied"] .env-twine { opacity: 0.25; transform: translateY(8px); }
.envelope[data-state="untied"] .env-wax,
.envelope[data-state="open"] .env-wax { transform: scale(0.72) translateY(-8px); opacity: 0.55; }
.envelope[data-state="open"] .env-flap { transform: rotateX(180deg); }
.envelope[data-state="open"] .env-inner { opacity: 1; }
.envelope-caption {
  position: absolute;
  left: 16px;
  bottom: 14px;
  display: flex;
  gap: 10px;
  align-items: center;
  font-size: 13px;
}
#latch-chip {
  background: var(--slate);
  color: var(--ivory);
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 12px;
}

.inspect-card {
  background: var(--paper);
  border-radius: 18px;
  padding: 18px 18px 16px;
  box-shadow: 0 8px 20px rgba(36, 28, 22, 0.08);
}
.eyebrow {
  margin: 0 0 8px;
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--leaf);
}
.inspect-card h2, .editorial h2, .how h3 { font-family: var(--serif); font-weight: 600; }
.inspect-card h2 { margin: 0 0 8px; font-size: 28px; }
.inspect-card p { margin: 0 0 16px; color: #3b3228; }
.inspect-meta { display: grid; gap: 10px; margin: 0 0 16px; }
.inspect-meta div { display: flex; justify-content: space-between; gap: 12px; border-top: 1px solid var(--rule); padding-top: 8px; }
.inspect-meta dt { color: var(--leaf); font-size: 13px; }
.inspect-meta dd { margin: 0; font-family: var(--mono); font-size: 12px; }
.wax-btn { width: 100%; }

.canvas-tools {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: end;
  margin-top: 14px;
  flex-wrap: wrap;
}
.tool-cluster, .stamp-rail { display: flex; flex-wrap: wrap; gap: 8px; }
.pill, .chip {
  border: 1px solid var(--rule);
  background: var(--ivory);
  color: var(--gall);
  border-radius: 999px;
  min-height: 36px;
  padding: 0 14px;
  cursor: pointer;
}
.pill:disabled { opacity: 0.4; cursor: not-allowed; }
.pill.ghost { background: transparent; }
.chip.active { background: var(--slate); color: var(--ivory); border-color: var(--slate); }
.desk-clock { display: grid; gap: 4px; min-width: min(320px, 100%); font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--leaf); }
.desk-clock input { width: 100%; accent-color: var(--wax); }
.desk-clock output { font-family: var(--mono); color: var(--gall); letter-spacing: 0; text-transform: none; }

.timetable {
  list-style: none;
  margin: 22px 0 8px;
  padding: 0;
  display: grid;
  gap: 10px;
}
.timetable li {
  display: grid;
  grid-template-columns: 72px 1fr auto;
  gap: 16px;
  align-items: center;
  padding: 14px 16px;
  background: var(--ivory);
  border-radius: 16px;
  border: 1px solid transparent;
  cursor: pointer;
}
.timetable li.selected { border-color: var(--slate); }
.timetable time { font-family: var(--mono); font-size: 12px; color: var(--leaf); }
.timetable strong { display: block; font-family: var(--serif); font-size: 18px; }
.timetable small { color: #5a4e42; }
.latch-pill { font-size: 12px; border-radius: 999px; padding: 4px 10px; background: #e7dcc4; }
.latch-pill.releasing { background: #ead8b0; }
.latch-pill.open { background: #d7e0d4; }
.demo-note, .footer small, .editorial figcaption { color: #6a5c4c; font-size: 13px; }

.editorial {
  width: min(1120px, calc(100% - 28px));
  margin: 88px auto 0;
  display: grid;
  grid-template-columns: 1fr 1.1fr;
  gap: 48px;
  align-items: center;
}
.editorial h2 { margin: 0 0 16px; font-size: clamp(40px, 6vw, 68px); line-height: 1.02; }
.editorial p { font-size: 17px; max-width: 36ch; }
.text-link { color: var(--wax); font-weight: 600; text-underline-offset: 4px; }
.editorial-object { margin: 0; }
.editorial-object img {
  width: 100%;
  border-radius: 22px;
  box-shadow: var(--shadow);
  aspect-ratio: 4 / 3;
  object-fit: cover;
  background: #e8dcc4;
}
.editorial figcaption { margin-top: 10px; }

.how { width: min(1120px, calc(100% - 28px)); margin: 88px auto 64px; }
.how-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 28px; margin-top: 18px; }
.how article span { font-family: var(--mono); color: var(--wax); }
.how h3 { margin: 8px 0; font-size: 28px; }

.footer {
  width: min(1120px, calc(100% - 28px));
  margin: 0 auto 28px;
  padding-top: 22px;
  border-top: 1px solid var(--rule);
  display: grid;
  gap: 8px;
}
.footer a { color: var(--wax); }

dialog {
  width: min(480px, calc(100% - 32px));
  border: 0;
  border-radius: 20px;
  padding: 28px;
  background: var(--ivory);
  color: var(--gall);
  box-shadow: var(--shadow);
}
dialog::backdrop { background: rgba(36, 28, 22, 0.42); }
dialog h2 { font-family: var(--serif); font-size: 42px; margin: 0 0 10px; }
.dialog-close {
  position: absolute;
  top: 12px;
  right: 14px;
  border: 0;
  background: none;
  font-size: 28px;
  cursor: pointer;
}

@media (max-width: 860px) {
  .nav { flex-wrap: wrap; }
  .nav nav { display: none; }
  .canvas-stage, .editorial, .how-grid { grid-template-columns: 1fr; }
  .timetable li { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  .intro-flap, .intro-twine, .intro-wax, .intro-knot, .intro-type { animation: none; opacity: 1; stroke-dashoffset: 0; transform: none; }
  .env-flap, .env-inner, .env-twine, .env-wax { transition: none; }
}
