:root {
  --theme: #2E7D4F;           /* set from the birth-day colour */
  --on-theme: #FFFFFF;        /* white or dark ink, whichever reads on --theme */
  --tint: color-mix(in srgb, var(--theme) 12%, #FFFFFF);
  --tint-strong: color-mix(in srgb, var(--theme) 22%, #FFFFFF);
  --ink: #17201A;
  --muted: #4A564E;
  --line: #DCE3DE;
  --bg: #F5F7F5;
  --card: #FFFFFF;
  --good: #1F6B3F;
  --good-bg: #DDF1E3;
  --caution: #8A4B00;
  --caution-bg: #FDE9CC;
  --normal-bg: #FFFFFF;
  --base: 16px;
  --radius: 16px;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font-family: "Sarabun", system-ui, sans-serif; font-size: var(--base); }
body { padding-bottom: calc(76px + env(safe-area-inset-bottom)); -webkit-text-size-adjust: 100%; }
body.age-senior { --base: 19px; }
body.age-young { --base: 16px; }
button, a { font: inherit; }
a { color: inherit; }
main { max-width: 520px; margin: 0 auto; }
[hidden] { display: none !important; }

.loading { min-height: 70vh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; color: var(--muted); }
.spinner { width: 36px; height: 36px; border-radius: 50%; border: 4px solid var(--line); border-top-color: var(--theme); animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation: none; } }

.top { background: var(--theme); color: var(--on-theme); padding: 16px 20px; display: flex; align-items: center; gap: 12px; }
.top .who { display: flex; flex-direction: column; min-width: 0; }
.top .small { font-size: .8rem; opacity: .9; }
.top .name { font-weight: 700; font-size: 1.05rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.avatar { width: 44px; height: 44px; border-radius: 50%; object-fit: cover; background: var(--tint-strong); flex: none; display: flex; align-items: center; justify-content: center; font-weight: 700; color: var(--ink); }
.avatar.lg { width: 96px; height: 96px; font-size: 1.6rem; }
.top .badge { margin-left: auto; font-size: .78rem; padding: 4px 10px; border-radius: 999px; background: color-mix(in srgb, var(--on-theme) 18%, transparent); white-space: nowrap; }

.page { padding: 18px 16px; display: flex; flex-direction: column; gap: 14px; }
h1 { font-size: 1.35rem; margin: 0; }
h2 { font-size: 1.05rem; margin: 0; }
p { margin: 0; line-height: 1.55; }
.muted { color: var(--muted); }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; display: flex; flex-direction: column; gap: 10px; }

.today { border-width: 2px; }
.today.good { background: var(--good-bg); border-color: var(--good); }
.today.caution { background: var(--caution-bg); border-color: var(--caution); }
.status { display: flex; align-items: center; gap: 12px; }
.status svg { width: 44px; height: 44px; flex: none; }
.status .word { font-size: 2rem; font-weight: 700; line-height: 1.1; }
.today.good .word { color: var(--good); }
.today.caution .word { color: var(--caution); }
.stamp { font-size: .82rem; font-weight: 600; color: var(--muted); }
.stamp.ok { color: var(--good); }
.message { font-size: 1.05rem; }

.colors { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.swatch { display: flex; align-items: center; gap: 10px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px; }
.swatch i { width: 30px; height: 30px; border-radius: 8px; flex: none; border: 1px solid rgba(0,0,0,.15); }
.swatch .k { font-size: .8rem; color: var(--muted); }
.swatch .v { font-weight: 700; }
body.age-senior .colors { grid-template-columns: 1fr; }
body.age-senior .extra { display: none; }

.actions { display: flex; flex-direction: column; gap: 10px; }
.btn { display: flex; align-items: center; justify-content: center; min-height: 52px; padding: 0 18px; border-radius: 14px; border: 2px solid var(--theme); background: var(--theme); color: var(--on-theme); font-weight: 700; text-decoration: none; cursor: pointer; }
.btn.ghost { background: var(--card); color: var(--ink); border-color: var(--ink); }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
body.age-senior .btn { min-height: 64px; font-size: 1.15rem; }

.cal-head { display: flex; align-items: center; justify-content: space-between; }
.cal-head button { width: 48px; height: 48px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); font-size: 1.4rem; cursor: pointer; }
.grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.dow { text-align: center; font-size: .78rem; color: var(--muted); }
.day { min-height: 46px; border-radius: 10px; border: 1px solid var(--line); background: var(--normal-bg); display: flex; flex-direction: column; align-items: center; justify-content: center; font-weight: 600; cursor: pointer; padding: 0; color: var(--ink); }
.day.good { background: var(--good-bg); border-color: var(--good); }
.day.caution { background: var(--caution-bg); border-color: var(--caution); }
.day.today { outline: 2px solid var(--ink); outline-offset: 1px; }
.day.sel { box-shadow: inset 0 0 0 2px var(--theme); }
.day .dot { width: 5px; height: 5px; border-radius: 50%; background: var(--theme); margin-top: 2px; }
.nite { font-size: .62rem; font-weight: 700; line-height: 1; margin-top: 2px; }
.nite.good { color: var(--good); }
.nite.caution { color: var(--caution); }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: .82rem; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 12px; height: 12px; border-radius: 3px; border: 1px solid; }

.rows { display: flex; flex-direction: column; }
.row { display: flex; justify-content: space-between; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.row:last-child { border-bottom: none; }
.row b { white-space: nowrap; }

.center { text-align: center; align-items: center; }
.check { display: flex; gap: 10px; align-items: flex-start; line-height: 1.5; }
.check input { width: 22px; height: 22px; margin: 2px 0 0; flex: none; accent-color: var(--theme); }
.notice { background: var(--tint); border-radius: 12px; padding: 12px 14px; font-size: .9rem; }
.error { background: var(--caution-bg); color: var(--caution); border-radius: 12px; padding: 12px 14px; }

.tabs { position: fixed; left: 0; right: 0; bottom: 0; display: grid; grid-template-columns: repeat(3, 1fr); background: var(--card); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
.tabs a { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 0 10px; text-decoration: none; color: var(--muted); font-size: .78rem; min-height: 56px; }
.tabs svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linejoin: round; stroke-linecap: round; }
.tabs a[aria-current="page"] { color: var(--ink); font-weight: 700; }
.tabs a[aria-current="page"] svg { stroke: var(--theme); }
.demo-banner { background: #FFF4C2; color: #5A4300; text-align: center; font-size: .82rem; padding: 6px; }
