:root {
  --paper: #f7f1e6;
  --paper-2: #efe6d6;
  --ink: #221c17;
  --ink-2: #5d534a;
  --line: #d9cdb9;
  --accent: #b5462f;
  --accent-ink: #fff7ec;
  --ok: #4f6b3a;
  --bad: #a3321f;
  --S: #c8822b;
  --H: #b5462f;
  --A: #2f6b8a;
  --P: #4f7a4a;
  --B: #6b4f8a;
  --E: #6b4f8a;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --radius: 10px;
  --maxw: 44rem;
}
html:lang(ja) {
  --serif: "Hiragino Mincho ProN", "Yu Mincho", YuMincho, "Noto Serif JP", "Noto Serif CJK JP", "Iowan Old Style", Georgia, serif;
  --sans: system-ui, -apple-system, "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic", YuGothic, Meiryo, "Noto Sans JP", "Noto Sans CJK JP", sans-serif;
}
html:lang(ja) body { line-height: 1.7; }
html:lang(ja) .tag { letter-spacing: 0; text-transform: none; }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 1.0625rem;
  line-height: 1.5;
}
h1, h2, h3 { font-family: var(--serif); font-weight: 700; line-height: 1.15; margin: 0; }
h1 { font-size: clamp(1.9rem, 5vw, 2.6rem); }
h2 { font-size: 1.45rem; margin: 2.25rem 0 0.75rem; }
h3 { font-size: 1.2rem; margin: 1.25rem 0 0.4rem; }
h4 { font-size: 0.95rem; margin: 0 0 0.3rem; color: var(--ink-2); font-weight: 600; }
p { margin: 0 0 0.9rem; }
a { color: var(--accent); }
button { font: inherit; cursor: pointer; }

.app { max-width: var(--maxw); margin: 0 auto; padding: 1.25rem 1rem 4rem; }
.lede { font-size: 1.1rem; color: var(--ink-2); }
.hint { color: var(--ink-2); font-size: 0.95rem; }
.note { font-size: 0.9rem; color: var(--ink-2); border-left: 3px solid var(--line); padding-left: 0.75rem; }
.empty { color: var(--ink-2); font-style: italic; }
.incomplete { background: var(--paper-2); padding: 0.75rem 1rem; border-radius: var(--radius); }
.no-print {}

/* nav */
.nav {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  background: color-mix(in srgb, var(--paper) 92%, white);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(6px);
}
.nav a { text-decoration: none; color: var(--ink); }
.nav-home { font-family: var(--serif); font-weight: 700; letter-spacing: 0.02em; white-space: nowrap; }
.nav-sections { display: flex; gap: 0.25rem; margin: 0 auto; }
.nav-item {
  display: flex; flex-direction: column; align-items: center;
  min-width: 2.6rem; padding: 0.2rem 0.3rem; border-radius: 8px;
  border: 1px solid transparent;
}
.nav-letter { font-family: var(--serif); font-weight: 700; font-size: 1.15rem; line-height: 1; }
.nav-count { font-size: 0.62rem; color: var(--ink-2); line-height: 1.2; margin-top: 2px; }
.nav-item.partial .nav-letter { color: var(--accent); }
.nav-item.done .nav-letter { color: var(--ok); }
.nav-item.done .nav-count::before { content: "✓ "; color: var(--ok); }
.nav a.current { background: var(--paper-2); border-color: var(--line); }
.nav-summary { font-size: 0.9rem; padding: 0.3rem 0.6rem; border-radius: 8px; border: 1px solid transparent; white-space: nowrap; }
.lang-toggle {
  font-size: 0.8rem; padding: 0.3rem 0.7rem; border-radius: 99px; white-space: nowrap;
  background: white; color: var(--ink-2); border: 1px solid var(--line);
}
.lang-toggle:hover { color: var(--ink); border-color: var(--ink-2); }
@media (max-width: 420px) {
  .nav-home { font-size: 0.85rem; }
  .nav-summary { font-size: 0.8rem; padding: 0.25rem 0.4rem; }
  .nav-item { min-width: 2.2rem; }
}

/* section head + letters */
.section-head { display: flex; align-items: center; gap: 0.9rem; margin: 0.5rem 0 1rem; }
.big-letter {
  display: inline-grid; place-items: center;
  width: 3rem; height: 3rem; border-radius: 12px;
  font-family: var(--serif); font-weight: 700; font-size: 1.75rem;
  color: var(--accent-ink); background: var(--accent);
  flex: none;
}
.big-letter.sm { width: 2rem; height: 2rem; font-size: 1.15rem; border-radius: 8px; vertical-align: -0.35rem; margin-right: 0.3rem; }
[data-letter="S"] { --accent: var(--S); }
[data-letter="H"] { --accent: var(--H); }
[data-letter="A"] { --accent: var(--A); }
[data-letter="P"] { --accent: var(--P); }
[data-letter="E"] { --accent: var(--E); }

/* intro */
.hero { padding-top: 1.5rem; }
.hero-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; margin-bottom: 1.25rem; }
.hero-letters { display: flex; gap: 0.4rem; }
.hero-letters .big-letter { transform: rotate(var(--r, 0deg)); }
.hero-letters .big-letter:nth-child(1) { --r: -4deg; }
.hero-letters .big-letter:nth-child(2) { --r: 3deg; }
.hero-letters .big-letter:nth-child(3) { --r: -2deg; }
.hero-letters .big-letter:nth-child(4) { --r: 4deg; }
.hero-letters .big-letter:nth-child(5) { --r: -3deg; }
.hero h1 { margin-bottom: 0.75rem; }
.shape-list { list-style: none; padding: 0; margin: 1rem 0 1.5rem; display: grid; gap: 0.35rem; }
.shape-list a { text-decoration: none; color: var(--ink); display: flex; gap: 0.6rem; align-items: baseline; }
.shape-list b { font-family: var(--serif); font-size: 1.3rem; width: 1.4rem; color: var(--accent); }
.hero-actions { display: flex; gap: 0.75rem; flex-wrap: wrap; margin-bottom: 1.5rem; }

/* buttons */
.btn {
  display: inline-block; padding: 0.6rem 1.1rem; border-radius: var(--radius);
  border: 1px solid var(--line); background: white; color: var(--ink);
  text-decoration: none; font-weight: 600;
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 40%, var(--line)); }
.btn.big { font-size: 1.15rem; padding: 0.8rem 1.6rem; }
.pager { display: flex; justify-content: space-between; gap: 0.75rem; margin-top: 2.5rem; padding-top: 1.25rem; border-top: 1px solid var(--line); }
.actions { display: flex; gap: 0.5rem; flex-wrap: wrap; margin: 0 0 1.5rem; }

/* gifts */
.scale-key { display: flex; flex-wrap: wrap; gap: 0.4rem 1rem; font-size: 0.9rem; color: var(--ink-2); margin-bottom: 1.25rem; }
.scale-key b { color: var(--ink); }
.statements { list-style: none; padding: 0; margin: 0; }
.statement { padding: 1rem 0; border-top: 1px solid var(--line); }
.statement-text { margin-bottom: 0.6rem; }
.n { font-family: var(--serif); font-weight: 700; color: var(--ink-2); margin-right: 0.2rem; }
.rating { display: grid; grid-template-columns: repeat(5, 1fr); gap: 0.35rem; }
.rate {
  display: flex; flex-direction: column; align-items: center; gap: 0.1rem;
  padding: 0.45rem 0.2rem; border-radius: 8px; border: 1px solid var(--line);
  background: white; color: var(--ink); min-height: 3.2rem;
}
.rate-n { font-family: var(--serif); font-weight: 700; font-size: 1.15rem; line-height: 1; }
.rate-l { font-size: 0.62rem; color: var(--ink-2); line-height: 1.1; text-align: center; }
.rate.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.rate.on .rate-l { color: var(--accent-ink); }
.statement .rate.on, .statement .rate.on .rate-l { --accent: var(--S); }

.panel { background: var(--paper-2); border-radius: var(--radius); padding: 0.25rem 1rem 1rem; margin-top: 1.5rem; }
.panel h2 { margin-top: 1rem; }
.totals { list-style: none; padding: 0; margin: 0; display: grid; gap: 0.35rem; }
.totals li { display: grid; grid-template-columns: 1.6rem 1fr 2fr 2rem; align-items: center; gap: 0.5rem; }
.totals li.top .t-name { font-weight: 700; }
.totals li.top .t-bar > span { background: var(--accent); }
.totals li.top .t-num { color: var(--accent); font-weight: 700; }
.t-letter { font-family: var(--serif); font-weight: 700; color: var(--ink-2); }
.t-bar { height: 0.55rem; background: white; border-radius: 99px; overflow: hidden; }
.t-bar > span { display: block; height: 100%; background: var(--line); border-radius: 99px; transition: width 0.25s; }
.t-num { text-align: right; font-variant-numeric: tabular-nums; }
.totals.types li { grid-template-columns: 1.6rem 1fr 1.5fr 2rem; }
#gift-totals, [data-view="gifts"] .totals li.top { --accent: var(--S); }
#type-totals, [data-view="personality"] .totals li.top { --accent: var(--P); }

.defs { margin: 1.5rem 0; border: 1px solid var(--line); border-radius: var(--radius); padding: 0.5rem 1rem; }
.defs summary { cursor: pointer; font-weight: 600; padding: 0.4rem 0; }
.gift-def h3 .t-letter { margin-right: 0.3rem; }
.example { font-size: 0.95rem; color: var(--ink-2); }

/* references: Scripture + Teaching popups */
.refs { display: flex; flex-wrap: wrap; gap: 0.35rem; margin: 0 0 0.6rem; }
.section-refs { margin: -0.3rem 0 1.25rem; }
.ref {
  font-family: var(--sans); font-size: 0.8rem; font-weight: 600; color: var(--accent);
  background: white; border: 1px solid var(--line); border-radius: 99px; padding: 0.15rem 0.6rem;
}
.ref:hover, .ref:focus-visible { border-color: var(--accent); }
.print-refs { display: none; }
.ref-dialog {
  max-width: min(34rem, calc(100vw - 2rem)); padding: 1.25rem 1.5rem 1rem;
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper); color: var(--ink);
}
.ref-dialog::backdrop { background: rgba(34, 28, 23, 0.45); }
.ref-close-row { float: right; margin: -0.5rem -0.75rem 0 0; }
.ref-close { background: none; border: none; font-size: 1.1rem; color: var(--ink-2); padding: 0.4rem 0.6rem; }
.ref-dialog h3 { margin: 0 0 0.75rem; }
.ref-dialog blockquote { margin: 0 0 0.75rem; font-family: var(--serif); font-size: 1.1rem; line-height: 1.5; }
.ref-cite { font-size: 0.9rem; color: var(--ink-2); margin: 0; }

/* prompts */
.prompt { margin: 1.5rem 0; }
.prompt-label { display: block; font-weight: 600; margin-bottom: 0.4rem; }
textarea, input[type="text"] {
  width: 100%; font: inherit; color: var(--ink);
  padding: 0.6rem 0.75rem; border-radius: 8px; border: 1px solid var(--line); background: white;
  resize: vertical;
}
textarea { field-sizing: content; min-height: 3.5rem; }
textarea:focus, input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.list-row { display: flex; gap: 0.5rem; align-items: flex-start; margin-bottom: 0.5rem; }
.list-n { font-family: var(--serif); font-weight: 700; color: var(--ink-2); padding-top: 0.6rem; width: 1.2rem; }
.chips { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 0.4rem; }
.chips li { background: white; border: 1px solid var(--line); border-radius: 99px; padding: 0.25rem 0.7rem; font-size: 0.9rem; }

/* personality */
.prows { list-style: none; padding: 0; margin: 0; }
.prow { padding: 0.9rem 0; border-top: 1px solid var(--line); }
.prow-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 0.5rem; }
.prow-status { font-size: 0.85rem; font-weight: 600; }
.prow.ok .prow-status { color: var(--ok); }
.prow.bad .prow-status { color: var(--bad); }
.prow.bad .words { outline: 2px solid color-mix(in srgb, var(--bad) 45%, transparent); outline-offset: 4px; border-radius: 6px; }
.words { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0.6rem; }
@media (min-width: 600px) { .words { grid-template-columns: repeat(4, 1fr); } }
.word { background: white; border: 1px solid var(--line); border-radius: 8px; padding: 0.5rem; display: flex; flex-direction: column; gap: 0.45rem; }
.word-text { font-size: 0.92rem; line-height: 1.25; min-height: 2.5em; }
.ranks { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.25rem; }
.rank {
  padding: 0.4rem 0; border-radius: 6px; border: 1px solid var(--line);
  background: var(--paper); color: var(--ink); font-weight: 700; font-family: var(--serif);
}
.rank.on { background: var(--P); border-color: var(--P); color: var(--accent-ink); }
.type-card { margin: 1rem 0; }
.type-card ul { margin: 0; padding-left: 1.1rem; font-size: 0.95rem; }
.two-col { display: grid; gap: 1rem; }
@media (min-width: 560px) { .two-col { grid-template-columns: 1fr 1fr; } }
.tag { font-family: var(--sans); font-size: 0.72rem; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--accent-ink); background: var(--P); padding: 0.15rem 0.5rem; border-radius: 99px; vertical-align: middle; }

/* summary */
.summary-head { justify-content: space-between; flex-wrap: wrap; }
.name-field { display: flex; align-items: center; gap: 0.5rem; }
.name-field label { font-size: 0.85rem; color: var(--ink-2); }
.name-field input { width: 14rem; }
.sum { margin-top: 2rem; padding-top: 0.5rem; border-top: 2px solid var(--line); }
.sum h2 { margin-top: 1rem; display: flex; align-items: center; }
.top-gifts { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-bottom: 0.5rem; }
.pill { background: var(--accent); color: var(--accent-ink); border-radius: 99px; padding: 0.3rem 0.8rem; font-weight: 600; font-size: 0.95rem; }
.answer { margin: 1rem 0; }
.answer p, .answer ol { white-space: pre-wrap; margin: 0; }
.answer ol { padding-left: 1.4rem; }

.foot { display: flex; justify-content: center; align-items: center; gap: 0.75rem; flex-wrap: wrap; font-size: 0.8rem; color: var(--ink-2); padding: 1rem; }

/* print */
@media print {
  .no-print, .pager, .nav, .foot { display: none !important; }
  body { background: white; font-size: 11pt; }
  .app { max-width: none; padding: 0; }
  .sum { break-inside: avoid-page; }
  .type-card, .gift-def { break-inside: avoid; }
  .refs { display: none; }
  .print-refs { display: block; font-size: 10pt; border-left: 2px solid #999; padding-left: 0.6rem; margin: 0.4rem 0 0.8rem; }
  .print-refs p { margin: 0 0 0.3rem; }
  .defs { border: none; padding: 0; }
  .defs[open] summary { display: none; }
  .defs:not([open]) { display: none; }
  .big-letter, .pill, .tag { print-color-adjust: exact; -webkit-print-color-adjust: exact; }
  .name-field input { border: none; border-bottom: 1px solid #000; border-radius: 0; }
}
