:root {
  color-scheme: dark;
  --ink: #eef0ea;
  --muted: #aeb6b3;
  --night: #0e1822;
  --night-deep: #091017;
  --panel: rgba(21, 32, 42, 0.88);
  --panel-soft: rgba(255, 255, 255, 0.055);
  --line: rgba(221, 230, 225, 0.18);
  --warm: #f0c77a;
  --warm-strong: #f7d795;
  --leaf: #77977d;
  --danger: #f1a7a0;
  --success: #b8d7b2;
  --radius: 22px;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.24);
  --sky-a: #07111c;
  --sky-b: #172838;
  --sky-c: #101d29;
  --sky-glow: rgba(247, 215, 149, 0.09);
}

:root.time-morning {
  --sky-a: #7e91a1;
  --sky-b: #d0aa83;
  --sky-c: #8aa2ad;
  --sky-glow: rgba(255, 224, 169, 0.42);
}

:root.time-day {
  --sky-a: #6f9fbd;
  --sky-b: #b8cfdb;
  --sky-c: #82adbf;
  --sky-glow: rgba(255, 244, 207, 0.54);
}

:root.time-evening {
  --sky-a: #42536d;
  --sky-b: #b87968;
  --sky-c: #5e4f62;
  --sky-glow: rgba(255, 191, 132, 0.34);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  background: var(--night-deep);
}

body {
  margin: 0;
  min-width: 300px;
  overflow-x: hidden;
  color: var(--ink);
  background:
    radial-gradient(circle at 84% 5%, rgba(90, 112, 124, 0.18), transparent 34rem),
    linear-gradient(180deg, var(--night) 0%, #111b24 52%, #0c141b 100%);
  font-family: "Hiragino Sans", "Yu Gothic", "Noto Sans JP", system-ui, -apple-system, sans-serif;
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
}

button,
input,
textarea,
select {
  font: inherit;
}

a {
  color: inherit;
}

.skip-link {
  position: fixed;
  left: 1rem;
  top: -6rem;
  z-index: 20;
  padding: 0.7rem 1rem;
  color: #111;
  background: var(--warm-strong);
  border-radius: 999px;
}

.skip-link:focus {
  top: 1rem;
}

.hero,
.section,
footer {
  width: min(1120px, calc(100% - 40px));
  margin-inline: auto;
}

.hero {
  min-height: min(760px, 92svh);
  padding: max(20px, env(safe-area-inset-top)) 0 72px;
}

.site-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 58px;
}

.wordmark {
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-decoration: none;
}

.quiet-link {
  color: var(--muted);
  font-size: 0.85rem;
  text-underline-offset: 0.25em;
}

.hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(320px, 0.92fr);
  gap: clamp(44px, 8vw, 104px);
  align-items: center;
  min-height: 620px;
}

.eyebrow {
  margin: 0 0 1rem;
  color: var(--warm);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.72rem;
  letter-spacing: 0.18em;
}

h1,
h2,
h3,
p {
  overflow-wrap: anywhere;
}

h1 {
  margin: 0;
  font-family: "Yu Mincho", "Hiragino Mincho ProN", serif;
  font-size: clamp(3.4rem, 9vw, 7rem);
  font-weight: 500;
  letter-spacing: 0.08em;
  line-height: 1.05;
}

h2 {
  margin: 0;
  font-family: "Yu Mincho", "Hiragino Mincho ProN", serif;
  font-size: clamp(2rem, 5vw, 3.4rem);
  font-weight: 500;
  line-height: 1.32;
}

h3 {
  margin: 0;
  font-size: 1.18rem;
}

.lead {
  max-width: 34rem;
  margin: 1.6rem 0 2rem;
  color: #d5dbd7;
  font-size: clamp(1rem, 2vw, 1.25rem);
}

.about-window {
  max-width: 38rem;
  margin: -0.7rem 0 2rem;
  color: #d5dbd7;
}

.about-window > summary {
  width: fit-content;
  color: var(--warm-strong);
  cursor: pointer;
  font-size: 0.9rem;
  text-decoration: underline;
  text-underline-offset: 0.3em;
}

.about-window-body {
  margin-top: 1rem;
  padding: 1rem 1.1rem;
  background: rgba(4, 11, 17, 0.34);
  border: 1px solid var(--line);
  border-radius: 16px;
  font-size: 0.9rem;
}

.about-window-body p {
  margin: 0 0 1rem;
}

.about-window-body p:last-child {
  margin-bottom: 0;
}

.about-window-body ul {
  margin: -0.3rem 0 1rem;
  padding-left: 1.4rem;
}

.primary-button,
.secondary-button,
.text-button {
  border: 0;
  cursor: pointer;
  transition: transform 160ms ease, background-color 160ms ease, opacity 160ms ease;
}

.primary-button {
  display: inline-flex;
  min-height: 52px;
  align-items: center;
  justify-content: center;
  padding: 0.78rem 1.35rem;
  color: #16202a;
  background: var(--warm-strong);
  border-radius: 999px;
  font-weight: 700;
  text-decoration: none;
  box-shadow: 0 12px 34px rgba(240, 199, 122, 0.13);
}

.primary-button:hover,
.secondary-button:hover,
.text-button:hover {
  transform: translateY(-1px);
}

.primary-button:focus-visible,
.secondary-button:focus-visible,
.text-button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible,
a:focus-visible {
  outline: 3px solid rgba(247, 215, 149, 0.75);
  outline-offset: 4px;
}

.primary-button:disabled {
  cursor: wait;
  opacity: 0.58;
}

.window-scene {
  position: relative;
  max-width: 440px;
  margin-inline: auto;
}

.night {
  position: relative;
  aspect-ratio: 0.9;
  overflow: hidden;
  border: 12px solid #293039;
  border-bottom-width: 16px;
  background:
    radial-gradient(circle at 72% 24%, var(--sky-glow), transparent 25%),
    linear-gradient(150deg, var(--sky-a), var(--sky-b) 70%, var(--sky-c));
  border-radius: 210px 210px 18px 18px;
  box-shadow: inset 0 0 60px rgba(0, 0, 0, 0.28), var(--shadow);
}

.night,
.star,
.light {
  transition: background-color 800ms ease, opacity 800ms ease, box-shadow 800ms ease;
}

.time-morning .star,
.time-day .star {
  opacity: 0;
}

.time-evening .star {
  opacity: 0.22;
}

.time-morning .light,
.time-day .light {
  box-shadow: 0 0 12px rgba(240, 199, 122, 0.32);
  opacity: 0.42;
}

.night::before,
.night::after {
  position: absolute;
  content: "";
  background: #293039;
}

.night::before {
  width: 12px;
  height: 100%;
  left: calc(50% - 6px);
}

.night::after {
  width: 100%;
  height: 12px;
  top: 51%;
}

.star {
  position: absolute;
  width: 3px;
  height: 3px;
  background: #f5f2dc;
  border-radius: 50%;
  opacity: 0.72;
}

.star-a { left: 20%; top: 29%; }
.star-b { left: 72%; top: 17%; }
.star-c { left: 81%; top: 40%; }

.lights {
  position: absolute;
  inset: 0;
}

.light {
  position: absolute;
  width: 10px;
  height: 13px;
  background: var(--warm);
  border-radius: 2px;
  box-shadow: 0 0 18px rgba(240, 199, 122, 0.74);
  opacity: 0.75;
  animation: breathe 4.5s ease-in-out infinite alternate;
}

@keyframes breathe {
  to { opacity: 0.42; }
}

.sill {
  position: relative;
  height: 58px;
  margin: -4px -24px 0;
  background: linear-gradient(#46505a, #2c333a);
  border-radius: 5px 5px 14px 14px;
  box-shadow: 0 16px 22px rgba(0, 0, 0, 0.28);
}

.envelopes {
  position: absolute;
  left: 34px;
  bottom: 48px;
  display: flex;
  align-items: flex-end;
}

.envelope {
  width: 48px;
  height: 32px;
  margin-left: -18px;
  background: #d8d2bf;
  border: 1px solid #aaa38f;
  border-radius: 3px;
  box-shadow: 0 3px 9px rgba(0, 0, 0, 0.2);
  transform: rotate(var(--tilt, 0deg));
}

.envelope::after {
  display: block;
  width: 31px;
  height: 31px;
  margin: -16px auto 0;
  content: "";
  border-right: 1px solid #aaa38f;
  border-bottom: 1px solid #aaa38f;
  transform: rotate(45deg);
}

.plant {
  position: absolute;
  right: 36px;
  bottom: 42px;
  width: 62px;
  height: 44px;
  background: #8d715f;
  border-radius: 6px 6px 24px 24px;
}

.leaf {
  position: absolute;
  left: 29px;
  bottom: 35px;
  width: 18px;
  height: 38px;
  background: var(--leaf);
  border-radius: 100% 0 100% 0;
  transform-origin: bottom center;
}

.window-state {
  margin: 1.4rem 0 0;
  color: var(--muted);
  font-size: 0.9rem;
  text-align: center;
}

.reply-arrival {
  margin: 0 0 1rem;
  color: var(--success);
  font-weight: 700;
}

.section {
  padding: 96px 0;
  border-top: 1px solid var(--line);
}

.section-heading {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 0.7fr);
  gap: 40px;
  align-items: end;
  margin-bottom: 40px;
}

.section-heading > p {
  margin: 0;
  color: var(--muted);
}

.section-heading.compact {
  grid-template-columns: 1fr auto;
}

.cards {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
}

.card,
.resident-card,
.receipt,
.letter-detail {
  border: 1px solid var(--line);
  background: var(--panel-soft);
  border-radius: var(--radius);
}

.card {
  min-height: 230px;
  padding: 26px;
}

.card-kicker,
.card-date {
  color: var(--muted);
  font-size: 0.78rem;
}

.card h3 {
  margin: 0.4rem 0 1rem;
}

.card p {
  margin: 0;
}

.card a {
  display: inline-block;
  margin-top: 1.4rem;
  color: var(--warm-strong);
  text-underline-offset: 0.28em;
}

.card .public-work-image-link {
  display: block;
  margin: -10px -10px 1.25rem;
}

.public-work-image {
  display: block;
  width: 100%;
  max-height: 320px;
  object-fit: contain;
  background: rgba(0, 0, 0, 0.18);
  border: 1px solid var(--line);
  border-radius: 14px;
}

.card .card-author {
  margin-top: 0.85rem;
  color: var(--muted);
  font-size: 0.82rem;
}

.public-content {
  margin-top: 1.1rem;
  border-top: 1px solid var(--line);
  padding-top: 0.9rem;
}

.public-toggle {
  min-height: 44px;
  margin-top: 1rem;
  padding: 0.35rem 0;
  color: var(--warm-strong);
  background: transparent;
  border: 0;
  cursor: pointer;
  font: inherit;
  text-decoration: underline;
  text-underline-offset: 0.3em;
}

.public-content p {
  margin-top: 0.9rem;
  color: #d5dbd7;
  white-space: pre-wrap;
}

.public-unavailable {
  margin-top: 1rem !important;
  color: var(--muted);
  font-size: 0.84rem;
}

.letter-section {
  display: grid;
  grid-template-columns: minmax(260px, 0.78fr) minmax(0, 1.22fr);
  gap: clamp(36px, 7vw, 90px);
  align-items: start;
}

.letter-intro > p:not(.eyebrow) {
  color: #d1d7d3;
}

.boundary-note {
  padding-left: 1rem;
  border-left: 2px solid var(--warm);
  color: var(--muted) !important;
  font-size: 0.9rem;
}

.letter-form {
  padding: clamp(22px, 5vw, 38px);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.field + .field {
  margin-top: 1.25rem;
}

.field label {
  display: flex;
  justify-content: space-between;
  margin-bottom: 0.45rem;
  font-weight: 700;
}

.field label span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 400;
}

input[type="text"],
textarea,
select {
  width: 100%;
  color: var(--ink);
  background: rgba(3, 10, 16, 0.58);
  border: 1px solid rgba(238, 240, 234, 0.2);
  border-radius: 12px;
}

input[type="text"] {
  min-height: 50px;
  padding: 0.7rem 0.9rem;
}

textarea {
  min-height: 190px;
  padding: 0.9rem;
  resize: vertical;
}

select {
  width: 100%;
  min-height: 50px;
  padding: 0.7rem 0.9rem;
}

.character-count {
  margin: 0.25rem 0 0;
  color: var(--muted);
  font-size: 0.76rem;
  text-align: right;
}

.honeypot {
  position: absolute !important;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(1px, 1px, 1px, 1px);
  white-space: nowrap;
}

.consent-row {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.65rem;
  align-items: start;
  margin: 1.35rem 0;
  color: var(--muted);
  font-size: 0.86rem;
}

.consent-row input {
  width: 18px;
  height: 18px;
  margin-top: 0.28rem;
  accent-color: var(--warm);
}

.submit-button {
  width: 100%;
}

.form-status {
  min-height: 1.6rem;
  margin: 0.8rem 0 0;
  font-size: 0.85rem;
}

.form-status.error { color: var(--danger); }
.form-status.success { color: var(--success); }

.receipt {
  grid-column: 2;
  padding: 28px;
}

.receipt p {
  color: var(--muted);
}

.letter-id {
  color: var(--ink) !important;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-weight: 700;
}

.receipt-actions {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
}

.secondary-button {
  min-height: 46px;
  padding: 0.65rem 1rem;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid var(--line);
  border-radius: 999px;
}

.text-button {
  min-height: 44px;
  padding: 0.4rem;
  color: var(--warm-strong);
  background: transparent;
  text-decoration: underline;
  text-underline-offset: 0.25em;
}

.letter-detail {
  padding: clamp(24px, 5vw, 44px);
}

.letter-meta {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  color: var(--muted);
  font-size: 0.8rem;
}

.letter-body,
.reply-body {
  white-space: pre-wrap;
}

.letter-body {
  margin: 1.6rem 0 2.3rem;
  font-family: "Yu Mincho", "Hiragino Mincho ProN", serif;
  font-size: 1.15rem;
}

.reply-heading {
  margin: 0 0 1rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--line);
  font-size: 1rem;
}

.reply {
  padding: 1.2rem 0;
}

.reply + .reply {
  border-top: 1px dashed var(--line);
}

.reply-from {
  margin: 0 0 0.4rem;
  color: var(--warm-strong);
  font-weight: 700;
}

.reply-body,
.empty-reply {
  margin: 0;
  color: #d7ddd8;
}

.resident-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.resident-card {
  padding: 22px;
}

.resident-card h3 {
  margin-bottom: 0.25rem;
}

.resident-card p {
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.savings-action {
  display: inline-flex;
  margin-top: 1rem;
}

.savings-action[aria-disabled="true"] {
  cursor: default;
  color: var(--muted);
  text-decoration: none;
}

.loading-card {
  color: var(--muted);
}

.loading-line {
  display: block;
  width: 100%;
  height: 0.75rem;
  margin-bottom: 0.8rem;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  animation: loading-pulse 1.2s ease-in-out infinite alternate;
}

.loading-line.short {
  width: 58%;
}

@keyframes loading-pulse {
  to { opacity: 0.38; }
}

.hidden {
  display: none !important;
}

footer {
  padding: 54px 0 max(54px, env(safe-area-inset-bottom));
  color: var(--muted);
  border-top: 1px solid var(--line);
  text-align: center;
}

footer p {
  margin: 0.25rem 0;
}

.small {
  font-size: 0.78rem;
}

@media (max-width: 820px) {
  .hero,
  .section,
  footer {
    width: min(100% - 30px, 680px);
  }

  .hero {
    min-height: auto;
    padding-bottom: 58px;
  }

  .hero-grid {
    grid-template-columns: 1fr;
    gap: 46px;
    min-height: auto;
    padding-top: 52px;
  }

  .hero-copy {
    text-align: left;
  }

  .window-scene {
    width: min(84vw, 360px);
  }

  .section {
    padding: 70px 0;
  }

  .section-heading,
  .letter-section {
    grid-template-columns: 1fr;
    gap: 26px;
  }

  .cards,
  .resident-grid {
    grid-template-columns: 1fr;
  }

  .card {
    min-height: 0;
  }

  .receipt {
    grid-column: 1;
  }

  .history-item {
    grid-template-columns: 1fr;
    gap: 0.55rem;
  }

  .history-item .secondary-button {
    width: fit-content;
  }
}

@media (max-width: 460px) {
  .hero,
  .section,
  footer {
    width: calc(100% - 24px);
  }

  .site-nav {
    min-height: 50px;
  }

  .quiet-link {
    font-size: 0.76rem;
  }

  .hero-grid {
    padding-top: 34px;
  }

  h1 {
    font-size: clamp(3.35rem, 20vw, 5.4rem);
  }

  .lead {
    margin-top: 1.2rem;
  }

  .window-scene {
    width: min(82vw, 310px);
  }

  .letter-form {
    padding: 20px 16px;
  }

  .letter-meta,
  .receipt-actions {
    flex-direction: column;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

.nav-links,
.hero-actions,
.history-toolbar {
  display: flex;
  gap: 1rem;
  align-items: center;
  flex-wrap: wrap;
}

.nav-links a,
.text-link {
  color: var(--muted);
  font-size: 0.85rem;
  text-underline-offset: 0.25em;
}

.hero-actions .secondary-button {
  text-decoration: none;
}

.recipient-fieldset {
  margin: 0 0 1.25rem;
  padding: 0;
  border: 0;
}

.recipient-fieldset legend {
  margin-bottom: 0.55rem;
  font-weight: 700;
}

.choice-row {
  display: inline-flex;
  gap: 0.5rem;
  align-items: center;
  margin: 0 1rem 0.6rem 0;
}

.choice-row input {
  width: 18px;
  height: 18px;
  accent-color: var(--warm);
}

.resident-choice {
  margin-top: 0.65rem;
}

.field-help {
  margin: 0.55rem 0 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.history-toolbar {
  justify-content: space-between;
  margin-bottom: 1rem;
}

.history-list {
  display: grid;
  gap: 0.8rem;
}

.history-item {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(220px, 1.2fr) auto auto;
  gap: 1rem;
  align-items: center;
  padding: 1rem 1.2rem;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel-soft);
}

.history-item p { margin: 0; }
.history-meta { color: var(--muted); font-size: 0.86rem; }
.status-replied { color: var(--success); font-weight: 700; }
.status-waiting { color: var(--muted); }
.recipient-line { color: var(--warm-strong); }

details.resident-card {
  padding: 0;
}

.resident-card summary {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.25rem;
  cursor: pointer;
  list-style: none;
}

.resident-card summary::-webkit-details-marker { display: none; }
.resident-name { font-size: 1.25rem; font-weight: 700; }
.profile-hint { color: var(--muted); font-size: 0.8rem; }
.resident-profile { padding: 0 1.25rem 1.25rem; }
.profile-field { padding: 1rem 0; border-top: 1px solid var(--line); }
.profile-field h3 { color: var(--warm-strong); font-size: 0.85rem; }
.profile-field p { margin: 0.35rem 0 0; }

.savings-card {
  margin-top: 1rem;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.12);
}

.savings-card h3 { font-size: 0.95rem; }
.savings-card p { margin: 0.35rem 0; color: var(--muted); font-size: 0.82rem; }
.savings-card .balance { color: var(--ink); font-weight: 700; }
.small-disabled { margin-top: 0.5rem; padding: 0.5rem 0.75rem; color: var(--muted); background: transparent; border: 1px solid var(--line); border-radius: 999px; }

@media (max-width: 820px) {
  .history-item { grid-template-columns: 1fr auto; }
  .history-meta { grid-column: 1 / -1; }
}

@media (max-width: 600px) {
  .nav-links { display: none; }
  .hero-actions { align-items: stretch; flex-direction: column; }
  .hero-actions > * { text-align: center; }
  .history-item { grid-template-columns: 1fr; }
  .history-meta { grid-column: auto; }
}
