:root {
  color-scheme: light;
  --paper: #fffdf7;
  --cream: #f8f4e7;
  --ink: #352a1f;
  --muted: #665d4b;
  --leaf: #416534;
  --leaf-light: #eaf0dd;
  --border: #ded4bb;
  --shadow: 0 5px 18px #513d1e0d;
  font-family: "Hiragino Sans", "Yu Gothic", "Noto Sans CJK JP", system-ui, sans-serif;
  background: var(--cream);
  color: var(--ink);
  font-size: 16px;
  line-height: 1.6;
}
*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: clamp(1.5rem, 2.9vw, 2.1rem); }
h2 { font-size: 1.13rem; }
h3 { font-size: 1rem; }
a { color: var(--leaf); }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; color: inherit; }
button:disabled { opacity: .55; cursor: default; }
button:focus-visible, a:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible, [tabindex]:focus-visible {
  outline: 3px solid #5f8266;
  outline-offset: 3px;
}
input:not([type=checkbox], [type=range]), select, textarea {
  max-width: 100%;
  background: #fffefa;
  color: var(--ink);
  border: 1px solid #c8bca2;
  border-radius: 9px;
  padding: 8px 11px;
}
textarea { resize: vertical; }
input[type=range], input[type=checkbox] { accent-color: var(--leaf); }
.primary, .secondary, .danger, .garden-skip {
  border: 1px solid var(--border);
  background: var(--paper);
  min-height: 42px;
  padding: 7px 14px;
  border-radius: 11px;
  font-weight: 650;
}
.primary { color: white; background: var(--leaf); border-color: var(--leaf); }
.danger { color: #8c392b; }
.secondary:hover, .garden-skip:hover { background: #f4eedf; }
.primary:hover { background: #35542a; }
.text-button { border: 0; background: transparent; text-decoration: underline; color: var(--leaf); padding: 6px; }
.actions { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; }
.top {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  position: sticky; top: 0; z-index: 5;
  min-height: 64px; padding: 10px clamp(14px, 4vw, 44px);
  border-bottom: 1px solid var(--border); background: #fbf7ec;
}
.wordmark, .account-button { min-height: 42px; border-radius: 12px; border: 1px solid transparent; background: transparent; }
.wordmark { padding: 5px 0; font-size: 1.24rem; font-weight: 750; letter-spacing: .04em; }
.account-button { border-color: var(--border); padding: 6px 12px; overflow: hidden; max-width: 65%; text-overflow: ellipsis; white-space: nowrap; }
.layout { display: grid; grid-template-columns: 168px minmax(0, 1fr); width: min(1510px, 100%); margin: 0 auto; }
.navigation {
  position: sticky; top: 90px; align-self: start; display: grid; gap: 7px;
  padding: 25px 10px 10px 17px;
}
.navigation button {
  display: flex; align-items: center; gap: 10px; justify-content: flex-start;
  border: 0; border-radius: 10px; min-height: 50px; padding: 5px 11px;
  background: transparent; font-weight: 650;
}
.navigation button span { font-size: 1.17rem; color: var(--leaf); width: 22px; }
.navigation button[aria-current=page] { background: var(--leaf-light); color: #2c4b23; }
.navigation button:hover { background: #eee8d8; }
main { min-width: 0; padding: 23px clamp(14px, 3vw, 32px) 55px 16px; }
.home-page, .album-page { display: grid; gap: 16px; }
.home-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(245px, 330px); gap: 15px; align-items: start; }
.home-main, .home-side { display: grid; gap: 14px; }
.card {
  display: grid; gap: 12px; padding: 17px;
  border: 1px solid var(--border); border-radius: 18px; background: var(--paper); box-shadow: var(--shadow);
}
.empty, .muted { color: var(--muted); }
.garden { position: relative; display: block; overflow: hidden; padding: 0; border-color: #cfc9a9; }
.subscribers {
  display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; align-items: baseline;
  padding: 8px 12px; position: relative; z-index: 1; background: #fffbeb;
}
.subscribers strong { font-size: 1.28rem; }
.garden-scene {
  /* The roots sit on the open grass immediately before the first stepping stone. */
  --tree-base: 28%;
  --tree-headroom: 4%;
  position: relative;
  isolation: isolate;
  overflow: hidden;
  height: 0;
  padding-bottom: 68%;
  background: linear-gradient(#73b6e3, #d4ecf1 66%, #b8d38a);
}
@supports (aspect-ratio: 1) {
  .garden-scene { height: auto; padding-bottom: 0; aspect-ratio: 1.47; }
}
.garden-sky, .garden-landscape, .garden-growth, .garden-wildlife {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  pointer-events: none;
}
.garden-sky {
  z-index: 0;
  overflow: hidden;
  background: url('./assets/sky.webp') center / cover no-repeat;
}
.garden-cloud {
  position: absolute;
  top: var(--cloud-y, 13%);
  left: var(--cloud-rest, 18%);
  width: var(--cloud-size, 25%);
  max-width: 235px;
  height: auto;
  opacity: var(--cloud-opacity, .86);
  animation: garden-cloud-drift var(--cloud-duration, 58s) linear var(--cloud-delay, -12s) infinite;
}
.garden-cloud--1 { --cloud-y: 5%; --cloud-size: 30%; --cloud-rest: 12%; --cloud-duration: 58s; --cloud-delay: -17s; }
.garden-cloud--2 { --cloud-y: 16%; --cloud-size: 21%; --cloud-rest: 57%; --cloud-duration: 67s; --cloud-delay: -42s; --cloud-opacity: .74; }
.garden-cloud--3 { --cloud-y: 26%; --cloud-size: 16%; --cloud-rest: 80%; --cloud-duration: 76s; --cloud-delay: -58s; --cloud-opacity: .62; }
.garden-cloud--4 { --cloud-y: 8%; --cloud-size: 17%; --cloud-rest: 38%; --cloud-duration: 52s; --cloud-delay: -27s; --cloud-opacity: .68; }
@keyframes garden-cloud-drift {
  from { left: -37%; transform: translateY(0); }
  50% { transform: translateY(6px); }
  to { left: 108%; transform: translateY(0); }
}
.garden-landscape {
  z-index: 1;
  background: url('./assets/garden-landscape.webp') center bottom / cover no-repeat;
}
.garden-growth { z-index: 2; }
.garden-tree {
  position: absolute;
  bottom: var(--tree-base);
  left: 50%;
  display: block;
  width: auto;
  height: auto;
  max-width: 88%;
  max-height: calc(100% - var(--tree-base) - var(--tree-headroom));
  /* Every growth sprite has the same canvas and roughly 26px below its roots. */
  transform: translate(-50%, 4.48%);
  opacity: 0;
  transition: opacity 260ms ease-in-out;
}
.garden-tree.is-visible { opacity: 1; }
.garden-skip {
  position: absolute;
  right: 11px;
  bottom: 10px;
  z-index: 2;
  font-size: .85rem;
}
.garden-wildlife { z-index: 3; contain: layout paint; }
.garden-flyer {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  transform: var(--flight-rest);
}
.garden-flyer-art {
  display: grid;
  width: 7%;
  min-width: 28px;
  max-width: 60px;
  transform: var(--flight-facing);
  --wing-period: 520ms;
}
.garden-flyer--butterfly .garden-flyer-art {
  width: 5%;
  min-width: 21px;
  max-width: 43px;
  --wing-period: 430ms;
}
.garden-wing { grid-area: 1 / 1; width: 100%; height: auto; display: block; }
.garden-wing--down { opacity: 0; }
.has-wing-frames .garden-wing--up { animation: garden-wings var(--wing-period) ease-in-out var(--wing-delay) infinite; }
.has-wing-frames .garden-wing--down {
  animation: garden-wings var(--wing-period) ease-in-out calc(var(--wing-delay) - var(--wing-period) / 2) infinite;
}
@keyframes garden-wings { 0%, 100% { opacity: 1; } 50% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) {
  .garden-cloud, .garden-wing { animation: none !important; }
  .garden-flyer { transform: var(--flight-rest) !important; }
  .garden-flyer-art { transform: var(--flight-facing) !important; }
  .garden-tree { transition: none; }
}
.metrics { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0; text-align: center; padding: 12px; }
.metrics > div { display: grid; gap: 3px; }
.metrics > div + div { border-left: 1px solid var(--border); }
.metrics strong { font-size: 1.19rem; }
.metrics-note { grid-column: 1/-1; margin-top: 7px; font-size: .85rem; color: var(--muted); }
.countdown { font-size: clamp(2.1rem, 5vw, 3rem); font-variant-numeric: tabular-nums; line-height: 1.05; letter-spacing: .03em; }
.timer-options { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.timer-options input { width: 90px; }
.home-album, .album-list { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 10px; }
.heading-row { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; }
.album-page { max-width: 1000px; }
.album-book {
  display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 20px;
  padding: clamp(13px, 4vw, 32px); margin-inline: auto; width: min(100%, 740px);
  border: 3px double #b3895d; border-radius: 13px;
  background: linear-gradient(90deg,#f7edcf 0%,#fffae6 45%,#d1b896 50%,#f9f1d4 52%,#fffae6 97%);
  box-shadow: 0 5px #bd9a72, 0 9px 14px #5939192b;
  animation: page-turn 320ms both;
}
@keyframes page-turn { from { transform: perspective(900px) rotateY(-5deg); opacity: .76; } }
.album-tile {
  display: grid; align-content: start; gap: 4px; min-width: 0; overflow: hidden;
  border-radius: 9px; padding: 8px; background: #fffdf7; border: 1px solid var(--border);
}
.album-tile[role=button] { cursor: pointer; }
.album-tile strong { overflow-wrap: anywhere; }
.album-tile img, .album-placeholder { width: 100%; aspect-ratio: 16 / 10; border-radius: 6px; object-fit: cover; }
.album-placeholder { display: grid; place-items: center; background: #e7ecd4; font-size: 1.6rem; color: var(--leaf); }
.album-controls { display: flex; gap: 9px; align-items: center; justify-content: center; flex-wrap: wrap; }
.album-dialog {
  width: min(calc(100% - 24px), 520px); max-height: 88vh; padding: 21px;
  border: 1px solid var(--border); background: var(--paper); color: var(--ink); border-radius: 16px;
}
.album-dialog::backdrop { background: #231d15a0; }
.album-dialog form, .field { display: grid; gap: 8px; }
.field { font-weight: 650; }
.field input, .field textarea, .field select { width: 100%; font-weight: 400; }
#toast {
  position: fixed; z-index: 20; left: 50%; bottom: max(22px, env(safe-area-inset-bottom)); transform: translateX(-50%);
  width: min(90vw, 540px); background: #243b24; color: white; border-radius: 12px; padding: 12px 19px; box-shadow: var(--shadow);
}
@media (max-width: 1050px) {
  .layout { grid-template-columns: 127px minmax(0, 1fr); }
  .navigation { padding-left: 9px; }
  .navigation button { gap: 4px; padding-inline: 6px; }
}
@media (max-width: 850px) {
  .home-grid { grid-template-columns: 1fr; }
  .home-side { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .timer-card { grid-row: span 2; }
}
@media (max-width: 640px) {
  .top { min-height: 57px; padding: 6px 13px; }
  .layout { display: block; }
  .navigation {
    position: fixed; z-index: 6; top: auto; bottom: 0; left: 0; width: 100%; display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 4px;
    padding: 4px 5px calc(5px + env(safe-area-inset-bottom)); background: #fffaf0; border-top: 1px solid var(--border);
  }
  .navigation button { justify-content: center; flex-direction: column; gap: 0; padding: 3px 2px; font-size: .85rem; }
  .navigation button span { line-height: 1.2; text-align: center; }
  main { padding: 12px 12px calc(82px + env(safe-area-inset-bottom)); }
  .home-side { grid-template-columns: minmax(0, 1fr); }
  .timer-card { grid-row: auto; }
  .card { padding: 13px; }
  .garden { padding: 0; }
  #toast { bottom: calc(66px + env(safe-area-inset-bottom)); }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; } }
@media print {
  .top, .navigation, #toast { display: none !important; }
  body, :root { background: white; }
  main { padding: 0; }
  .layout { display: block; }
}
progress { width: 100%; accent-color: var(--leaf); }
