:root {
  --bg: #F4F0E7;
  --ink: #263238;
  --paper: #FFFEF8;
  --accent: #B45E45;
  --green: #638477;
  --dark: #263B3D;
  --line: #D7D2C7;
  --mute: #737B78;
  --found: #C6DED0;
  --select: #E8C58D;
  --serif: Georgia, "Times New Roman", serif;
  --sans: "Segoe UI", system-ui, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", Consolas, monospace;
  --max: 1260px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  color: var(--ink);
  font-family: var(--sans);
  line-height: 1.55;
  background-color: var(--bg);
  background-image:
    url("../svg/paper-grain.svg"),
    repeating-linear-gradient(
      to bottom,
      transparent 0,
      transparent 27px,
      rgba(38, 50, 56, 0.035) 28px
    );
  background-attachment: fixed;
}

body::before,
body::after {
  content: "";
  position: fixed;
  width: 16px;
  height: 16px;
  background: url("../svg/registration-cross.svg") center / 16px 16px no-repeat;
  opacity: 0.18;
  pointer-events: none;
  z-index: 0;
}

body::before { top: 12px; left: 12px; }
body::after { bottom: 18px; right: 16px; content: "p. 01"; font-family: var(--mono); font-size: 10px; letter-spacing: 0.12em; color: var(--mute); background: none; width: auto; height: auto; }

img { max-width: 100%; }

a {
  color: var(--accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

a:hover { color: var(--dark); }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.skip {
  position: absolute;
  left: -999px;
  top: 8px;
}

.skip:focus {
  left: 8px;
  z-index: 20;
  background: var(--paper);
  padding: 8px 12px;
}

.wrap {
  width: min(var(--max), calc(100% - 32px));
  margin: 0 auto;
  position: relative;
  z-index: 1;
}

.site-header {
  height: 68px;
  border-bottom: 1px solid var(--line);
  background: rgba(244, 240, 231, 0.94);
  position: sticky;
  top: 0;
  z-index: 10;
}

.site-header .wrap {
  height: 68px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.wordmark {
  display: flex;
  flex-direction: column;
  line-height: 1.05;
  color: var(--ink);
  text-decoration: none;
  font-family: var(--serif);
  font-weight: 700;
  letter-spacing: 0.08em;
}

.wordmark span:first-child { font-size: 13px; }
.wordmark span:last-child { font-size: 16px; }

.site-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 14px 18px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.site-nav a {
  color: var(--ink);
  text-decoration: none;
  border-bottom: 1px solid transparent;
}

.site-nav a:hover,
.site-nav a[aria-current="page"] {
  border-bottom-color: var(--accent);
}

[data-nav-toggle] {
  display: none;
}

.kicker {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--mute);
  margin: 0 0 8px;
}

h1, h2, h3 {
  font-family: var(--serif);
  font-weight: 700;
  line-height: 1.15;
  margin: 0 0 12px;
}

h1 { font-size: clamp(28px, 4vw, 42px); }
h2 { font-size: clamp(22px, 3vw, 32px); }
h3 { font-size: 20px; }

.lede {
  max-width: 62ch;
  margin: 0 0 20px;
  color: var(--ink);
}

.section {
  padding: 42px 0;
  border-top: 1px solid var(--line);
}

.section-tight { padding: 28px 0; }

.workshop {
  display: grid;
  grid-template-columns: 4fr 8fr;
  gap: 28px;
  align-items: start;
}

.desk,
.paper-stage,
.ledger,
.print-station,
.set-card,
.tip,
.faq details {
  background: transparent;
  border: 0;
  border-top: 1px solid var(--line);
  padding-top: 16px;
}

label,
.lbl {
  display: block;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin: 12px 0 6px;
}

textarea,
input[type="text"],
input[type="number"],
select {
  width: 100%;
  font: 15px/1.4 var(--sans);
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--line);
  padding: 8px 10px;
  border-radius: 0;
}

textarea {
  min-height: 220px;
  font-family: var(--mono);
  letter-spacing: 0.04em;
  resize: vertical;
}

.checks {
  display: grid;
  gap: 8px;
  margin: 12px 0;
}

.checks label {
  display: flex;
  gap: 8px;
  align-items: center;
  text-transform: none;
  letter-spacing: 0;
  font-family: var(--sans);
  font-size: 14px;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
}

.btn,
button.btn,
a.btn {
  appearance: none;
  border: 1px solid var(--dark);
  background: var(--dark);
  color: var(--paper);
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 10px 12px;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
}

.btn-ghost,
a.btn-ghost {
  background: transparent;
  color: var(--ink);
  border-color: var(--line);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.note-err { color: var(--accent); margin: 6px 0; font-size: 14px; }
.note-ok { color: var(--green); margin: 6px 0; font-size: 14px; }

.diff-label {
  font-family: var(--mono);
  letter-spacing: 0.14em;
  font-size: 12px;
  color: var(--accent);
}

.paper-stage {
  background: var(--paper);
  border: 1px solid var(--line);
  padding: 18px;
}

.grid-toolbar {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 12px;
}

.grid-scroll {
  overflow: auto;
  max-width: 100%;
}

.grid {
  display: grid;
  gap: 0;
  background: var(--paper);
  width: max-content;
  margin: 0 auto;
  user-select: none;
  touch-action: none;
}

.cell {
  width: 100%;
  height: 100%;
  border: 1px solid #ece8df;
  background: var(--paper);
  color: #263238;
  font-family: var(--mono);
  font-weight: 700;
  padding: 0;
  margin: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.cell.is-found { background: var(--found); }
.cell.is-select { background: var(--select); }
.cell.is-answer { box-shadow: inset 0 0 0 2px var(--accent); }
.cell.is-hint { outline: 2px dashed var(--accent); outline-offset: -3px; }
.cell.is-found.is-select { background: #d5d4b4; }

.ledger {
  margin-top: 18px;
}

.word-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px 18px;
  list-style: none;
  padding: 0;
  margin: 0;
}

.word-list li {
  display: flex;
  gap: 8px;
  align-items: baseline;
  font-size: 15px;
}

.word-list li.is-found {
  text-decoration: line-through;
  color: var(--green);
}

.check {
  font-family: var(--mono);
  width: 1.2em;
}

.progress {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.08em;
  margin: 8px 0 16px;
}

.complete-banner {
  border-top: 1px solid var(--green);
  padding-top: 12px;
  margin-top: 12px;
}

.keyboard-solve {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px 12px;
  margin-top: 16px;
}

.answer-row {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px solid var(--line);
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.04em;
}

.shelf-grid,
.set-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 22px 28px;
}

.set-meta,
.set-words {
  color: var(--mute);
  font-size: 14px;
}

.set-words {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.03em;
}

.diff-cols {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
}

.diff-cols article {
  border-top: 2px solid var(--dark);
  padding-top: 12px;
}

.vocab-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.vocab-table th,
.vocab-table td {
  text-align: left;
  border-bottom: 1px solid var(--line);
  padding: 8px 6px;
  font-variant-numeric: tabular-nums;
}

.vocab-table th {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.12em;
}

.tips {
  display: grid;
  gap: 28px;
}

.mini-grid {
  display: grid;
  grid-template-columns: repeat(5, 28px);
  grid-template-rows: repeat(5, 28px);
  margin: 12px 0;
  background: var(--paper);
  width: max-content;
}

.mini-grid span {
  border: 1px solid #ece8df;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--mono);
  font-weight: 700;
  font-size: 13px;
}

.mini-grid span.on {
  background: var(--found);
  box-shadow: inset 0 0 0 2px var(--accent);
}

.activity-row {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 20px;
  padding: 18px 0;
  border-top: 1px solid var(--line);
}

.article-index {
  display: grid;
  gap: 18px;
}

.article-body {
  max-width: 68ch;
}

.article-body h2 { margin-top: 28px; }
.article-body p { margin: 0 0 14px; }

.faq details {
  padding: 10px 0;
}

.faq summary {
  cursor: pointer;
  font-weight: 700;
  font-family: var(--serif);
}

.site-footer {
  border-top: 1px solid var(--line);
  padding: 22px 0 40px;
  font-size: 14px;
}

.site-footer nav {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  margin: 10px 0;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.site-footer a { color: var(--ink); text-decoration: none; }
.site-footer a:hover { color: var(--accent); }

.print-paper {
  background: #fff;
  color: #000;
  border: 1px solid var(--line);
  padding: 18px;
  overflow: auto;
}

.print-grid {
  border-collapse: collapse;
  margin: 12px auto;
}

.print-grid td {
  width: 28px;
  height: 28px;
  border: 1px solid #333;
  text-align: center;
  font-family: var(--mono);
  font-weight: 700;
}

.print-grid td.is-path {
  outline: 2px solid #000;
  outline-offset: -3px;
  background: repeating-linear-gradient(-45deg, #fff, #fff 3px, #ccc 3px, #ccc 6px);
}

.live {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

.related {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
}

.address {
  font-style: normal;
  line-height: 1.6;
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { transition: none !important; animation: none !important; }
}

@media (max-width: 760px) {
  .site-header { height: auto; }
  .site-header .wrap {
    height: auto;
    min-height: 68px;
    padding: 10px 0;
  }
  [data-nav-toggle] { display: inline-block; }
  .site-nav {
    display: none;
    width: 100%;
    flex-direction: column;
    padding: 8px 0 12px;
  }
  .site-nav.is-open { display: flex; }
  .workshop,
  .diff-cols,
  .shelf-grid,
  .set-grid,
  .word-list,
  .activity-row,
  .keyboard-solve {
    grid-template-columns: 1fr;
  }
  textarea { min-height: 160px; }
  .wrap { width: min(var(--max), calc(100% - 20px)); }
}

@media (max-width: 360px) {
  .cell { min-width: 18px; }
  .btn { width: 100%; text-align: center; }
}
