:root {
  --bg: #f4f0f8;
  --ink: #2a2433;
  --muted: #5c5468;
  --faint: #7a7188;
  --accent: #624882;
  --accent-deep: #4e396c;
  --soft: #efe7f7;
  --blush: #f8eaf2;
  --card: rgba(255, 255, 255, 0.9);
  --line: rgba(98, 72, 130, 0.16);
  --shadow: 0 16px 40px rgba(78, 57, 108, 0.08);
  --warn: #8a4d46;
  --good: #3e6b56;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: "Avenir Next", "Segoe UI", sans-serif;
  --radius: 22px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100dvh;
  color: var(--ink);
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.5;
  background: var(--bg);
}
.sky {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(circle at 14% 12%, rgba(255,255,255,.95) 0 1px, transparent 1.6px),
    radial-gradient(circle at 78% 8%, rgba(176, 150, 206, .8) 0 1.2px, transparent 2px),
    radial-gradient(circle at 88% 28%, rgba(255,255,255,.8) 0 1px, transparent 1.5px),
    radial-gradient(circle at 22% 70%, rgba(196, 168, 214, .7) 0 1px, transparent 1.8px),
    radial-gradient(900px 520px at 100% -10%, #e7d8f4, transparent 60%),
    radial-gradient(700px 480px at -10% 10%, #f8e7f0, transparent 55%),
    var(--bg);
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
::selection { background: #e4d4f3; }

.app {
  width: min(720px, 100%);
  margin: 0 auto;
  padding: 20px 18px calc(28px + env(safe-area-inset-bottom));
}
.topbar {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 12px;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 5;
  margin: -8px -8px 16px;
  padding: 10px 8px 12px;
  background: linear-gradient(to bottom, rgba(244,240,248,.96), rgba(244,240,248,.88) 70%, transparent);
  backdrop-filter: blur(8px);
}
.topbar h1, .hero h1, .q-card h2, .block-title {
  font-family: var(--serif);
  font-weight: 500;
  letter-spacing: -0.02em;
  line-height: 1.2;
  margin: 0;
}
.topbar h1 { font-size: 1.35rem; }
.eyebrow {
  margin: 0 0 2px;
  color: var(--accent);
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
.save, .quiet, .hint, .voice, .meta { color: var(--muted); }
.save { margin: 0; font-size: 0.75rem; text-align: right; max-width: 7.2rem; }
.icon-btn, .btn, .chip, .text-btn {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 999px;
}
.icon-btn {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  color: var(--accent-deep);
}
.btn, .text-btn {
  min-height: 48px;
  padding: 12px 18px;
}
.btn { width: 100%; }
.btn-primary {
  background: var(--accent);
  color: #fff;
  border-color: transparent;
}
.btn-ghost { background: transparent; }
.btn-danger { background: transparent; color: var(--warn); border-color: rgba(138, 77, 70, .35); }
.text-btn {
  width: auto;
  background: transparent;
  color: var(--accent-deep);
  min-height: 40px;
}
.btn-row, .export-bar, .opt-row, .prec, .chips { display: flex; flex-wrap: wrap; gap: 8px; }
.export-bar {
  position: fixed;
  z-index: 6;
  left: 50%;
  transform: translateX(-50%);
  bottom: 0;
  width: min(720px, 100%);
  margin: 0;
  padding: 12px 18px calc(12px + env(safe-area-inset-bottom));
  background: linear-gradient(to top, rgba(244,240,248,.98), rgba(244,240,248,.92));
}
.spacer { height: 96px; }
.export-bar .btn { width: auto; flex: 1; }

.hero { padding: 12px 0 8px; }
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--accent-deep);
}
.brand svg { width: 28px; height: 28px; }
.brand p { margin: 0; letter-spacing: 0.16em; text-transform: uppercase; font-size: 0.78rem; }
.hero h1 { font-size: clamp(1.7rem, 7vw, 2.6rem); margin: 10px 0 6px; }
.hero h1 span { display: block; white-space: nowrap; }
.mast { margin: 0; color: var(--muted); }
.lead { margin: 8px 0 0; }
.hero-row {
  display: flex;
  gap: 16px;
  align-items: center;
  margin: 22px 0;
}
.ring { width: 84px; height: 84px; flex: none; }
.ring-track { fill: none; stroke: #e4dced; stroke-width: 6; }
.ring-value {
  fill: none;
  stroke: var(--accent);
  stroke-width: 6;
  stroke-linecap: round;
  transform: rotate(-90deg);
  transform-origin: 42px 42px;
}
.hero-row strong { display: block; font-family: var(--serif); font-size: 1.8rem; font-weight: 500; }
.hero-row p { margin: 0; color: var(--muted); }

.section-list { display: grid; gap: 12px; }
.card, .q-card, .item, .person, .panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card {
  width: 100%;
  text-align: left;
  padding: 16px 16px 14px;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 12px;
  align-items: center;
}
.card svg, .brand svg { width: 28px; height: 28px; color: var(--accent); }
.card h2 { font-family: var(--serif); font-size: 1.35rem; font-weight: 500; margin: 0; }
.card p { margin: 2px 0 8px; color: var(--muted); font-size: 0.92rem; }
.meter { height: 4px; border-radius: 99px; background: #ece4f3; overflow: hidden; }
.meter span { display: block; height: 100%; background: linear-gradient(90deg, #b89fd4, var(--accent)); }
.links { display: flex; flex-wrap: wrap; gap: 8px 14px; margin-top: 16px; }
.links button { background: none; border: 0; color: var(--accent-deep); padding: 8px 0; text-decoration: underline; text-underline-offset: 3px; }

.guide, .voice, .banner {
  border-radius: 16px;
  padding: 12px 14px;
  margin: 0 0 14px;
}
.guide { background: var(--blush); }
.voice { background: var(--soft); }
.banner { background: #fff; border: 1px solid var(--line); }
.guide p, .voice p, .banner p { margin: 0; }
.q-card, .panel { padding: 18px 16px 16px; margin: 0 0 14px; }
.q-card { scroll-margin-top: 88px; }
.q-card h2, .block-title { font-size: 1.28rem; margin-bottom: 8px; }
.hint { margin: 0 0 8px; font-size: 0.95rem; }
.field { display: block; margin: 0 0 12px; }
.field-label, legend, .item-kicker {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 0.92rem;
}
input[type="text"], input[type="time"], input[type="number"], textarea, select {
  width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 14px;
  padding: 12px 14px;
  min-height: 48px;
}
textarea { min-height: 120px; resize: vertical; line-height: 1.45; }
input:focus, textarea:focus, select:focus, button:focus-visible {
  outline: 2px solid #c9b3e4;
  outline-offset: 2px;
}
.date-editor {
  border: 0;
  margin: 0 0 12px;
  padding: 0;
}
.date-grid { display: grid; grid-template-columns: 0.7fr 1.2fr 0.9fr; gap: 8px; }
.chip {
  min-height: 40px;
  padding: 8px 12px;
  background: #fff;
}
.chip.is-on, .chip[aria-pressed="true"] {
  background: var(--accent);
  color: #fff;
  border-color: transparent;
}
.item, .person { padding: 14px; margin: 10px 0; box-shadow: none; }
.item-head, .person-head {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
}
.checkline {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  margin: 8px 0 12px;
}
.checkline input { width: 22px; height: 22px; margin-top: 2px; flex: none; }
.date-preview { min-height: 1.2em; margin: 8px 0 0; color: var(--accent-deep); }
.warn { color: var(--warn); margin: 6px 0 0; }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li {
  position: relative;
  padding: 0 0 16px 18px;
  border-left: 1px solid #ddcfe8;
}
.timeline li:last-child { border-left-color: transparent; }
.when { display: block; color: var(--accent); font-size: 0.88rem; }
.timeline h3, .read h3 { font-family: var(--serif); font-weight: 500; margin: 0 0 4px; font-size: 1.15rem; }
.timeline button, .edit-link {
  background: none;
  border: 0;
  padding: 0;
  color: var(--accent-deep);
  text-decoration: underline;
  text-underline-offset: 3px;
}
.answer {
  white-space: pre-wrap;
  margin: 8px 0 0;
  padding: 10px 12px;
  background: #faf7fc;
  border-radius: 14px;
}
.answer small { display: block; color: var(--faint); }
.modal {
  position: fixed;
  inset: 0;
  background: rgba(42, 36, 51, .35);
  display: grid;
  place-items: end center;
  z-index: 20;
  padding: 18px;
}
.modal-card {
  width: min(520px, 100%);
  background: #fff;
  border-radius: 24px;
  padding: 22px 18px;
  box-shadow: var(--shadow);
}
.modal-card h2 { font-family: var(--serif); font-weight: 500; margin: 0 0 8px; }
.modal-card .btn { margin-top: 8px; }
.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  background: var(--ink);
  color: #fff;
  border-radius: 999px;
  padding: 10px 16px;
  z-index: 30;
  max-width: min(90vw, 420px);
}
.noscript { padding: 24px; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

@media print {
  .sky, .app, .toast, .noscript { display: none !important; }
  #print-sheet { display: block !important; }
  body { background: #fff; color: #241e2c; }
  .print-doc { font-family: "Palatino Linotype", Palatino, Georgia, serif; }
  .print-cover { margin-bottom: 18px; }
  .print-kicker { letter-spacing: .16em; text-transform: uppercase; color: #624882; font-family: "Segoe UI", sans-serif; font-size: 11px; }
  .print-doc h1 { font-size: 32px; font-weight: 500; margin: 6px 0; }
  .print-doc h2 { font-size: 20px; font-weight: 500; margin: 22px 0 8px; break-after: avoid; }
  .print-q { break-inside: avoid; margin: 0 0 12px; }
  .print-q h3 { font-size: 16px; margin: 0 0 4px; break-after: avoid; }
  .print-hint { margin: 0 0 4px; color: #5c5468; font-size: 13px; }
  .print-answer { margin: 6px 0 0; white-space: pre-wrap; }
  .print-meta { color: #5c5468; font-size: 13px; }
  .print-time { list-style: none; padding: 0; }
  .print-time li { margin: 0 0 8px; }
}
