:root {
  --paper: #c9e0e6;
  --panel: #f4fbfc;
  --ink: #1e3344;
  --sea: #2a6b78;
  --pain: #c13b48;
  --ok: #2f8a68;
  --gold: #d9a441;
  --mute: #4d6472;
  --line: #9bbbc3;
  --body: #e7f3f5;
  --radius: 1.25rem;
  --dock: 4.5rem;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: ui-rounded, "Hiragino Maru Gothic ProN", "Segoe UI", system-ui, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(1200px 600px at 10% -10%, #dff0f3 0%, transparent 50%),
    linear-gradient(180deg, var(--paper), #b7d3db);
  line-height: 1.45;
}
.skip {
  position: absolute;
  left: -999px;
}
.skip:focus { left: 1rem; top: 1rem; background: var(--panel); padding: 0.5rem; }
.wordmark {
  font-family: Palatino, "Palatino Linotype", "Iowan Old Style", Georgia, serif;
  font-style: italic;
  font-size: 1.35rem;
  margin: 0;
}
.top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.25rem 0.5rem;
}
.main {
  padding: 0 1.25rem calc(var(--dock) + 1.5rem);
  max-width: 40rem;
  margin: 0 auto;
}
h1, h2 {
  font-family: Palatino, "Palatino Linotype", Georgia, serif;
  font-weight: 600;
  letter-spacing: -0.02em;
}
h1 { font-size: 2rem; line-height: 1.15; margin: 0.4rem 0 0.75rem; }
h2 { font-size: 1.2rem; margin: 1.5rem 0 0.6rem; }
.lede, .hint { color: var(--mute); }
.hint { font-size: 0.95rem; }
.stack, .gate { display: grid; gap: 1rem; }
.gate { padding-top: 1rem; }
label { display: grid; gap: 0.4rem; font-weight: 600; }
input[type="password"],
input[type="date"],
textarea {
  font: inherit;
  padding: 0.9rem 1rem;
  border: 1px solid var(--line);
  border-radius: 0.9rem;
  background: var(--panel);
  color: var(--ink);
  min-height: 3rem;
}
textarea { resize: vertical; }
.btn, .chip, .dock-link, .type-pill span, .type-chip, .scale button {
  min-height: 2.75rem;
  min-width: 2.75rem;
}
.btn {
  font: inherit;
  font-weight: 700;
  border: 0;
  border-radius: 999px;
  padding: 0.85rem 1.25rem;
  background: #d5e8ec;
  color: var(--ink);
  cursor: pointer;
}
.btn.primary { background: var(--sea); color: #f4fbfc; }
.btn.ghost { background: transparent; border: 1px solid var(--line); }
.actions { display: grid; gap: 0.75rem; margin-top: 1.25rem; }
.banner {
  padding: 0.85rem 1rem;
  border-radius: 0.9rem;
}
.banner.error { background: #f8d7da; }
.banner.ok { background: #d8efe4; }
.view-toggle, .figure-toggle { display: flex; gap: 0.5rem; margin: 0.75rem 0; }
.figure-toggle { margin-bottom: 0.15rem; }
.figure-form { flex: 1; margin: 0; }
.figure-form .chip { width: 100%; }
.chip {
  flex: 1;
  border: 1px solid var(--line);
  background: transparent;
  border-radius: 999px;
  font: inherit;
  cursor: pointer;
}
.chip.is-on { background: var(--ink); color: var(--panel); border-color: var(--ink); }
.map-stage {
  background: #eef7f8;
  border-radius: var(--radius);
  padding: 0.5rem 0.75rem 1rem;
  box-shadow: inset 0 0 0 1px #d5ebef;
}
.body-svg { width: 100%; height: auto; max-height: 72vh; display: block; }
.region {
  fill: #c4a48a;
  stroke: #3d2c24;
  stroke-width: 1.15;
  stroke-linejoin: round;
  cursor: pointer;
}
.region:focus { outline: 3px solid var(--gold); }
.figure-guides {
  pointer-events: none;
  fill: none;
  stroke: #3d2c24;
  stroke-width: 1.05;
  opacity: 0.32;
}
.figure-guides .soft { opacity: 0.2; }
.side-label {
  fill: var(--mute);
  font-size: 15px;
  font-family: ui-rounded, system-ui, sans-serif;
}
.region[data-level="1"] { fill: #f6e7a1; }
.region[data-level="2"] { fill: #f3d37a; }
.region[data-level="3"] { fill: #efc05c; }
.region[data-level="4"] { fill: #e8a24d; }
.region[data-level="5"] { fill: #e08848; }
.region[data-level="6"] { fill: #d66c45; }
.region[data-level="7"] { fill: #ce5246; }
.region[data-level="8"] { fill: #c44543; }
.region[data-level="9"] { fill: #b4333d; }
.region[data-level="10"] { fill: #9b1b2e; }
.heatmap-map .region { cursor: default; }
.heatmap-map .region[data-level] { cursor: pointer; }
.heat-legend {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  margin: 0.65rem 0 0.25rem;
  color: var(--mute);
  font-size: 0.9rem;
}
.heat-swatch {
  width: 1.15rem;
  height: 0.7rem;
  border-radius: 999px;
  box-shadow: inset 0 0 0 1px #3d2c2433;
}
.heat-swatch.lv-1 { background: #f6e7a1; }
.heat-swatch.lv-4 { background: #e8a24d; }
.heat-swatch.lv-7 { background: #ce5246; }
.heat-swatch.lv-10 { background: #9b1b2e; }
.picked { list-style: none; padding: 0; display: grid; gap: 0.5rem; }
.picked li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  background: var(--panel);
  padding: 0.75rem 1rem;
  border-radius: 0.9rem;
  cursor: pointer;
}
.types { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.type-pill input { position: absolute; opacity: 0; pointer-events: none; }
.type-pill span,
.type-chip {
  display: inline-flex;
  align-items: center;
  padding: 0.55rem 0.9rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--panel);
  font: inherit;
  cursor: pointer;
}
.type-chip.is-on,
.type-pill input:checked + span {
  background: var(--sea);
  color: var(--panel);
  border-color: var(--sea);
}
.type-pill input:focus-visible + span,
.type-chip:focus-visible { outline: 3px solid var(--gold); }
.picked li span { text-align: left; }
.sheet-label {
  margin: 0.2rem 0 0;
  font-weight: 700;
}
.dock {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  background: #f4fbfce6;
  backdrop-filter: blur(10px);
  padding: 0.4rem 0.6rem calc(0.4rem + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
}
.dock-link {
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  color: var(--mute);
  font-weight: 700;
}
.dock-link.is-on { color: var(--sea); }
.cal-head {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 0.5rem;
  align-items: center;
}
.cal-head h1 { font-size: 1.4rem; text-align: center; margin: 0; }
.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 0.35rem;
  margin-top: 1rem;
}
.cal-dow { text-align: center; color: var(--mute); font-size: 0.8rem; }
.cal-day {
  min-height: 3.2rem;
  border-radius: 0.8rem;
  background: var(--panel);
  text-decoration: none;
  color: inherit;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.2rem;
}
.cal-day.is-empty { background: transparent; }
.cal-day.is-today { box-shadow: inset 0 0 0 2px var(--sea); }
.dot {
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 50%;
  background: var(--ok);
}
.cal-day.has-pain .dot { background: var(--pain); }
.cal-day[data-level="1"] .dot, .cal-day[data-level="2"] .dot, .cal-day[data-level="3"] .dot { background: var(--gold); }
.cal-day[data-level="0"] .dot { background: var(--ok); }
.entry {
  background: var(--panel);
  border-radius: var(--radius);
  padding: 1rem;
  margin: 1rem 0;
}
.stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem 1.25rem;
  margin: 0;
}
.stats div { border-top: 1px solid var(--line); padding-top: 0.5rem; }
.stats dt { color: var(--mute); font-size: 0.9rem; }
.stats dd { margin: 0.15rem 0 0; font-size: 1.7rem; font-family: Palatino, Georgia, serif; }
.stats small { font-size: 0.9rem; color: var(--mute); }
.spark {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 3.5rem;
  background: var(--panel);
  padding: 0.4rem;
  border-radius: 0.8rem;
}
.bar {
  flex: 1;
  min-width: 2px;
  border-radius: 2px 2px 0 0;
  background: var(--line);
  height: 4px;
}
.bar.is-clear { background: var(--ok); }
.bar.is-pain { background: var(--pain); }
.bar.lv-0 { height: 6px; }
.bar.lv-1 { height: 8px; }
.bar.lv-2 { height: 12px; }
.bar.lv-3 { height: 16px; }
.bar.lv-4 { height: 20px; }
.bar.lv-5 { height: 24px; }
.bar.lv-6 { height: 28px; }
.bar.lv-7 { height: 32px; }
.bar.lv-8 { height: 36px; }
.bar.lv-9 { height: 42px; }
.bar.lv-10 { height: 48px; }
.rank, .plain { padding-left: 1.2rem; }
.export-row { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.range { display: grid; gap: 0.6rem; }
.logout-form { margin: 0; }
.text-btn {
  background: none;
  border: 0;
  font: inherit;
  color: var(--sea);
  min-height: 2.75rem;
  cursor: pointer;
}
.sheet {
  position: fixed;
  inset: 0;
  background: #1e334466;
  display: flex;
  align-items: flex-end;
  z-index: 5;
}
.sheet[hidden],
.map-pane[hidden] {
  display: none !important;
}
.sheet-card {
  background: var(--panel);
  width: 100%;
  max-height: min(92vh, 44rem);
  overflow: auto;
  border-radius: 1.4rem 1.4rem 0 0;
  padding: 1.25rem 1.25rem calc(1.25rem + env(safe-area-inset-bottom));
  display: grid;
  gap: 0.75rem;
}
.scale { display: grid; grid-template-columns: repeat(5, 1fr); gap: 0.45rem; }
.scale button {
  font: inherit;
  font-weight: 700;
  border: 1px solid var(--line);
  border-radius: 0.8rem;
  background: var(--body);
  cursor: pointer;
}
.scale button.is-on { background: var(--pain); color: white; border-color: var(--pain); }
@media (min-width: 720px) {
  .actions { grid-template-columns: 1fr 1fr; }
  .range { grid-template-columns: 1fr 1fr auto; align-items: end; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
