@property --head {
  syntax: '<percentage>';
  inherits: false;
  initial-value: 0%;
}

*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scrollbar-color: var(--rule-strong) var(--ground-deep);
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-family: var(--font-word);
  font-size: var(--step-0);
  line-height: 1.6;
  color: var(--ink);
  background-color: var(--ground);
  background-image: url('/lattice.svg');
  background-size: 240px 64px;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

:lang(ja) body, body:lang(ja) { font-family: var(--font-word-ja); line-height: 1.75; }

::selection { background: var(--lattice); color: var(--ink); }

p, li, figcaption { text-wrap: pretty; }

a { color: var(--ink); text-decoration-thickness: 1px; text-underline-offset: 0.2em; text-decoration-color: var(--rule-strong); }
a:hover { text-decoration-color: currentColor; }

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

.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;
}

.skip {
  position: absolute; left: var(--space-3); top: -4rem; z-index: 10;
  padding: var(--space-2) var(--space-4); background: var(--paper); color: var(--ink);
  border: 2px solid var(--ink); border-radius: var(--radius); font-weight: 700;
}
.skip:focus { top: var(--space-3); }

.shell { width: 100%; max-width: 46rem; margin-inline: auto; padding-inline: var(--space-4); }

main { flex: 1 0 auto; }

.fig {
  font-family: var(--font-fig);
  font-weight: 760;
  font-variation-settings: 'ROND' 100;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
}

.band {
  background: var(--band);
  color: var(--band-ink);
  border-bottom: 3px solid var(--band-deep);
}

.band__row {
  display: flex; align-items: center; flex-wrap: wrap;
  gap: var(--space-2) var(--space-4);
  min-height: 3.75rem; padding-block: var(--space-2);
}

.mark {
  display: inline-flex; align-items: center; gap: var(--space-2);
  color: var(--band-ink); text-decoration: none; margin-inline-end: auto;
}
.mark__seal {
  display: inline-grid; place-items: center;
  width: 2.1rem; height: 2.1rem; border-radius: 50%;
  background: var(--seal); color: var(--seal-ink);
  box-shadow: inset 0 0 0 2px var(--seal), inset 0 0 0 3.5px var(--seal-ink);
  font-family: var(--font-fig); font-weight: 900; font-size: 0.95rem;
  font-variation-settings: 'ROND' 100; letter-spacing: 0.02em;
}
.mark__word { font-size: 1.2rem; font-weight: 500; letter-spacing: -0.01em; }
.mark__word b { font-weight: 800; }

.band__nav { display: flex; gap: var(--space-1); }
.band__link {
  color: var(--band-ink-2); text-decoration: none;
  padding: var(--space-2) var(--space-3); border-radius: var(--radius);
  font-size: var(--step--1); font-weight: 600;
}
.band__link:hover { color: var(--band-ink); background: var(--band-deep); }
.band__link[aria-current='page'] { color: var(--band-ink); box-shadow: inset 0 -2px 0 var(--band-ink); border-radius: 0; }

.lang { position: relative; }
.lang__toggle {
  list-style: none; cursor: pointer;
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--band-ink-2); border-radius: var(--radius);
  color: var(--band-ink); font-size: var(--step--1); font-weight: 600;
}
.lang__toggle::-webkit-details-marker { display: none; }
.lang__toggle::after { content: ''; display: inline-block; width: 0.4em; height: 0.4em; margin-inline-start: 0.5em; border: solid currentColor; border-width: 0 1.5px 1.5px 0; transform: translateY(-0.2em) rotate(45deg); }
.lang[open] .lang__toggle { background: var(--band-deep); }
.lang__list {
  position: absolute; inset-inline-end: 0; top: calc(100% + 6px); z-index: 5;
  margin: 0; padding: var(--space-1); list-style: none; min-width: 10rem;
  background: var(--paper); border: 1px solid var(--rule-strong); border-radius: var(--radius);
  box-shadow: var(--shadow-page);
}
.lang__link { display: block; padding: var(--space-2) var(--space-3); color: var(--ink); text-decoration: none; border-radius: 4px; }
.lang__link:hover { background: var(--paper-shade); }
.lang__link[aria-current='true'] { font-weight: 750; }

.intake { padding-block: var(--space-6) var(--space-5); }

.intake__title {
  margin: 0;
  font-size: var(--step-3); line-height: 1.04;
  font-weight: 780; letter-spacing: -0.022em;
  text-wrap: balance;
}

.intake__lede { margin: var(--space-3) 0 0; max-width: var(--measure); color: var(--ink-2); text-wrap: pretty; }

.field { margin-top: var(--space-5); }
.field__label { display: block; font-weight: 700; font-size: var(--step--1); margin-bottom: var(--space-2); }
.field__row { display: flex; gap: var(--space-2); }
.field__box {
  flex: 1 1 auto; min-width: 0; display: flex; align-items: center;
  background: var(--paper); border: 2px solid var(--ink); border-radius: var(--radius);
}
.field__box:focus-within { outline: 3px solid var(--focus); outline-offset: 2px; }
.field__input {
  flex: 1 1 auto; min-width: 0; height: 3.25rem; padding: 0 var(--space-3);
  border: 0; background: transparent; color: var(--ink);
  font: inherit; font-size: 1rem;
}
.field__input::placeholder { color: var(--ink-3); opacity: 1; }
.field__input:focus { outline: none; }
.field__paste {
  flex: none; height: 2.5rem; margin-inline-end: 0.375rem; padding: 0 var(--space-3);
  border: 1px solid var(--rule-strong); border-radius: 4px; background: var(--paper-shade);
  color: var(--ink-2); font: inherit; font-size: var(--step--1); font-weight: 650; cursor: pointer;
}
.field__paste:hover { border-color: var(--ink-2); color: var(--ink); }
.field__read {
  flex: none; height: 3.25rem; min-width: 5.5rem; padding: 0 var(--space-5);
  border: 0; border-radius: var(--radius);
  background: var(--seal); color: var(--seal-ink);
  font: inherit; font-weight: 780; letter-spacing: 0.01em; cursor: pointer;
  box-shadow: 0 8px 16px -10px oklch(40% 0.16 30 / 0.75);
}
.field__read:hover { background: var(--seal-deep); }
.field__read:active { box-shadow: 0 3px 8px -6px oklch(40% 0.16 30 / 0.75); transform: translateY(1px); }
.field__read:disabled { cursor: progress; background: var(--seal-deep); }

.field__message { margin-top: var(--space-3); }
.alert {
  display: flex; gap: var(--space-3); align-items: flex-start; margin: 0;
  padding: var(--space-3) var(--space-4);
  background: var(--paper); border: 1.5px solid var(--ink); border-radius: var(--radius);
  box-shadow: var(--shadow-page);
  color: var(--ink); font-weight: 600;
}
.alert__icon { flex: none; width: 1.25rem; height: 1.25rem; margin-top: 0.2em; color: var(--ink); }

.book {
  margin-bottom: var(--space-7);
  background: var(--paper);
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow-page);
  overflow: hidden;
}

.book__head {
  display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between;
  gap: var(--space-2) var(--space-4);
  padding: var(--space-3) var(--space-4);
  background: var(--paper-shade);
  border-bottom: 1px solid var(--rule);
}
.book__label { margin: 0; font-weight: 750; font-size: var(--step--1); color: var(--ink-2); }
.book__facts { display: flex; flex-wrap: wrap; gap: var(--space-1) var(--space-4); margin: 0; }
.book__facts div { display: flex; gap: var(--space-2); align-items: baseline; }
.book__facts dt { font-size: 0.8125rem; color: var(--ink-3); }
.book__facts dd { margin: 0; font-size: 1.125rem; line-height: 1.2; color: var(--ink); }

.book__title {
  margin: 0; padding: var(--space-4) var(--space-4) var(--space-3);
  font-weight: 720; font-size: var(--step-1); line-height: 1.3;
  overflow-wrap: anywhere;
}
.book[data-state='blank'] .book__title { font-weight: 500; font-size: var(--step-0); color: var(--ink-3); }

.ledger { width: 100%; border-collapse: collapse; table-layout: fixed; }
.ledger thead th {
  padding: var(--space-2) var(--space-4);
  font-size: 0.8125rem; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase;
  color: var(--ink-3); text-align: start;
  border-bottom: 2px solid var(--ink);
}
.ledger thead th:nth-child(1) { width: 42%; }
.ledger thead th:nth-child(3) { width: 8.5rem; }
.ledger thead th:nth-child(3) { text-align: end; }

.line {
  height: var(--line-h);
  transition: opacity 220ms var(--ease-out), box-shadow 220ms var(--ease-out), transform 220ms var(--ease-out);
}
.line th, .line td {
  padding: var(--space-2) var(--space-4);
  vertical-align: middle; text-align: start; font-weight: 400;
  border-bottom: 1px solid var(--rule);
}
.line--instant th, .line--instant td { border-bottom: 1.5px solid var(--rule-strong); }
.line--joined th, .line--joined td { border-bottom: 1.5px dashed var(--rule-strong); }
.line--blank th, .line--blank td { border-bottom: 1px dotted var(--rule); color: var(--rule-strong); }

.line__quality .fig { display: block; font-size: 1.4rem; line-height: 1.1; font-weight: 900; color: var(--ink); }
.line--blank .line__quality .fig { color: var(--rule-strong); }
.line__kind { display: block; margin-top: 2px; font-size: 0.78rem; line-height: 1.25; color: var(--ink-3); }
.line--joined .line__kind::before {
  content: ''; display: inline-block; width: 1.1em; margin-inline-end: 0.35em; vertical-align: middle;
  border-top: 1.5px dashed currentColor;
}
.line--instant .line__kind::before {
  content: ''; display: inline-block; width: 1.1em; margin-inline-end: 0.35em; vertical-align: middle;
  border-top: 1.5px solid currentColor;
}

.line__size .fig { display: block; font-size: 1.125rem; line-height: 1.2; font-weight: 900; color: var(--ink); white-space: nowrap; }
.line__gauge { display: flex; align-items: center; gap: var(--space-2); height: 1.15rem; margin-top: 3px; }
.line__est { flex: none; font-size: 0.8125rem; line-height: 1; color: var(--ink-3); }
.meter { display: block; flex: 1 1 auto; height: 4px; max-width: 9rem; background: var(--rule-faint); border-radius: 2px; overflow: hidden; }
.meter span { display: block; height: 100%; width: var(--w, 0%); background: var(--ink-2); }
.line--joined .meter span { background: repeating-linear-gradient(90deg, var(--ink-2) 0 6px, transparent 6px 9px); }

.line__save { text-align: end; }

.save {
  min-width: 5.5rem; height: 2.75rem; padding: 0 var(--space-3);
  border: 1.5px solid var(--ink); border-radius: var(--radius);
  background: var(--paper); color: var(--ink);
  font: inherit; font-weight: 750; cursor: pointer;
  font-variant-numeric: tabular-nums;
}
.save:hover { background: var(--ink); color: var(--paper); }
.save:disabled { cursor: progress; background: var(--paper-shade); color: var(--ink); border-style: dashed; }
.line[data-state='failed'] .save { padding-inline: var(--space-2); border-style: double; border-width: 4px; font-size: 0.875rem; line-height: 1.1; }

.slot {
  display: inline-block; vertical-align: middle;
  width: 5.5rem; height: 2.75rem;
  border: 1.5px dotted var(--rule-strong); border-radius: var(--radius);
}

.seal {
  display: inline-grid; place-items: center;
  min-width: 5.5rem; height: 2.75rem; padding: 0 var(--space-2);
  border: 2.5px solid var(--seal); border-radius: 50% / 46%;
  color: var(--seal); font-weight: 850; font-size: 0.85rem; letter-spacing: 0.06em; text-transform: uppercase;
  box-shadow: inset 0 0 0 1.5px var(--paper), inset 0 0 0 2.5px var(--seal);
  transform: rotate(-7deg);
  animation: seal-land 160ms var(--ease-out) both;
}
@keyframes seal-land {
  from { transform: rotate(-7deg) scale(1.35); opacity: 0; }
  to { transform: rotate(-7deg) scale(1); opacity: 1; }
}

.ledger[data-saving] .line:not(.is-active) { opacity: 0.5; }
.line.is-active { position: relative; background: var(--paper); box-shadow: var(--shadow-lift); transform: translateY(-1px); }

.line.is-printing {
  background-image: linear-gradient(90deg, transparent 0 calc(var(--head) - 3px), oklch(26% 0.058 258 / 0.5) calc(var(--head) - 3px) var(--head), transparent var(--head));
  animation: print-head calc(var(--print-step) * 2.4) linear both;
  animation-delay: calc(var(--i, 0) * var(--print-step));
}
.line.is-printing > * {
  animation: print-in calc(var(--print-step) * 2.4) steps(12, end) both;
  animation-delay: calc(var(--i, 0) * var(--print-step));
}
@keyframes print-head { from { --head: 0%; } to { --head: 100%; } }
@keyframes print-in {
  from { clip-path: inset(0 100% 0 0); }
  to { clip-path: inset(0 0 0 0); }
}

.book__note { margin: 0; padding: var(--space-3) var(--space-4) var(--space-4); max-width: 38em; font-size: 0.875rem; color: var(--ink-3); }

.sheet { padding-block: var(--space-6); border-top: 1px solid var(--rule); }
.sheet:first-of-type { border-top: 0; }
.sheet__title { margin: 0 0 var(--space-4); font-size: var(--step-2); line-height: 1.2; font-weight: 760; letter-spacing: -0.012em; text-wrap: balance; }
.sheet__more { margin: var(--space-5) 0 0; font-weight: 700; }

.steps { counter-reset: step; list-style: none; margin: 0; padding: 0; display: grid; gap: var(--space-4); }
.steps__item {
  counter-increment: step;
  display: grid; grid-template-columns: 3rem 1fr; column-gap: var(--space-3);
  max-width: var(--measure);
}
.steps__item::before {
  content: counter(step, decimal-leading-zero);
  grid-row: span 2;
  font-family: var(--font-fig); font-weight: 900; font-variation-settings: 'ROND' 100;
  font-size: 1.9rem; line-height: 1; color: var(--band);
}
.steps__name { margin: 0; font-size: var(--step-1); line-height: 1.3; }
.steps__item p { margin: var(--space-1) 0 0; color: var(--ink-2); }

.demo { margin: var(--space-6) 0 0; max-width: 420px; }
.demo img { display: block; width: 100%; height: auto; border: 1px solid var(--rule-strong); border-radius: var(--radius); box-shadow: var(--shadow-page); background: var(--paper); }
.demo figcaption { margin-top: var(--space-2); font-size: 0.875rem; color: var(--ink-3); }

.prose > * { max-width: var(--measure); }
.prose p { margin: 0 0 var(--space-4); color: var(--ink-2); }
.prose p:last-child { margin-bottom: 0; }
.prose strong { color: var(--ink); font-weight: 750; }
.prose h2 { margin: var(--space-6) 0 var(--space-3); font-size: var(--step-1); line-height: 1.3; }
.prose h2:first-of-type { margin-top: var(--space-5); }
.prose ul, .prose ol { margin: 0 0 var(--space-4); padding-inline-start: 1.25rem; color: var(--ink-2); }
.prose li { margin-bottom: var(--space-2); }
.prose code { font-size: 0.9em; padding: 0 0.25em; background: var(--paper-shade); border-radius: 3px; }

.qa { max-width: var(--measure); padding-block: var(--space-4); border-bottom: 1px dashed var(--rule); }
.qa:last-of-type { border-bottom: 0; }
.qa__q { margin: 0 0 var(--space-2); font-size: var(--step-1); line-height: 1.3; font-weight: 720; }
.qa p { margin: 0; color: var(--ink-2); }

.sheet--page { border-top: 0; padding-top: var(--space-6); padding-bottom: var(--space-8); }
.sheet__h1 { margin: 0 0 var(--space-3); font-size: var(--step-3); line-height: 1.05; font-weight: 780; letter-spacing: -0.022em; }

.colophon {
  margin-top: auto; padding-block: var(--space-6) var(--space-7);
  background: var(--ground-deep); border-top: 1px solid var(--rule);
  font-size: var(--step--1); color: var(--ink-2);
}
.colophon__links { display: flex; flex-wrap: wrap; gap: var(--space-1) var(--space-4); margin-bottom: var(--space-4); }
.colophon__links a { color: var(--ink); padding-block: var(--space-2); }
.colophon__age { display: flex; gap: var(--space-2); align-items: baseline; margin: 0 0 var(--space-2); }
.colophon__badge { flex: none; padding: 0 var(--space-2); border: 1.5px solid var(--ink); border-radius: 4px; font-weight: 800; color: var(--ink); }
.colophon__note { margin: 0 0 var(--space-2); max-width: var(--measure); }

@media (max-width: 30rem) {
  .band__nav { order: 3; width: 100%; margin-inline-start: -0.75rem; }
  .field__row { flex-direction: column; }
  .field__read { width: 100%; }
  .ledger thead th, .line th, .line td { padding-inline: var(--space-3); }
  .ledger thead th:nth-child(3) { width: 6.25rem; }
  .save, .seal { min-width: 5rem; }
  .slot { width: 5rem; }
  .book__facts { gap: var(--space-1) var(--space-3); }
  .book[data-state='blank'] .book__facts, .book[data-state='blank'] .book__title { display: none; }
  .intake { padding-block: var(--space-5) var(--space-4); }
  .field { margin-top: var(--space-4); }
  :root { --line-h: 4.75rem; }
}

@media (prefers-reduced-motion: reduce) {
  .line.is-printing, .line.is-printing > *, .seal { animation: none; }
  .line.is-printing { background-image: none; }
  .line.is-active { transform: none; }
  .line { transition: none; }
}
