:root { color-scheme: light dark; --bg: #f4f4f5; --surface: #fff; --text: #27272a; --muted: #62626b; --line: #e4e4e7; --ink: #18181b; --on-ink: #fff; --brand: #e8a33c; --brand-down: #d9922c; --on-brand: #1d1a17;
  --danger-bg: #fdebec; --danger: #9f2f2d; --danger-down: #f9d7d9; --shadow: rgba(24,24,27,.08);
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1); --ease-drawer: cubic-bezier(0.32, 0.72, 0, 1); }
/* Dark: same zinc family, amber stays the one accent (owner 2026-10-13). */
@media (prefers-color-scheme: dark) {
  :root { --bg: #18181b; --surface: #232327; --text: #e4e4e7; --muted: #a1a1aa; --line: #34343a; --ink: #f4f4f5; --on-ink: #18181b;
    --danger-bg: #3a1d1f; --danger: #f2a6a8; --danger-down: #4a2427; --shadow: rgba(0,0,0,.4); }
}
/* UI title in Kanit, the default style's own face (same file, no extra download). */
@font-face { font-family: Kanit; src: url(/fonts/kanit-700.woff2); font-weight: 700; font-display: swap; }
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font: 15px/1.4 -apple-system, "SF Pro Text", "Helvetica Neue", sans-serif; -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
main { max-width: 480px; margin: 0 auto; height: 100dvh; display: flex; flex-direction: column; padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); gap: 10px; }
button, label { font: inherit; color: inherit; cursor: pointer; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }

/* Screens: year (grid) | month (edit) | view (full-screen flip). */
body[data-mode="year"] .not-year, body:not([data-mode="year"]) .year-only { display: none; }
.bar { position: relative; display: flex; align-items: center; justify-content: center; min-height: 44px; flex: none; }
.back { position: absolute; left: 0; }
.bar-end { position: absolute; right: 0; }
.tools { min-height: 44px; }
.lead { margin: -6px 0 0; text-align: center; font-size: 13px; color: var(--muted); }
.grid-wrap { flex: 1 1 0; min-height: 0; container-type: size; display: grid; place-items: center; }
/* Poster 2×2 at top-left, then 12 months, 4 per row, as large as both the width and the height allow. */
/* Column gap c, row gap c·16/9 − 20px: the 2×2 Full year tile's bottom lines up with Mar/Apr (label 16px + 4px gap). */
.grid { --c: 16px; --g: calc(var(--c) * 16 / 9 - 20px); --tw: min(calc((100cqw - 3 * var(--c)) / 4), calc(((100cqh - 3 * var(--g)) / 4 - 20px) * 9 / 16)); display: grid; grid-template-columns: repeat(4, var(--tw)); gap: var(--g) var(--c); }
.thumb { position: relative; display: grid; gap: 4px; padding: 0; border: 0; background: none; color: var(--muted); font-size: 12px; line-height: 16px; transition: transform 160ms var(--ease-out); }
.thumb:active { transform: scale(.97); }
.thumb.poster { grid-column: span 2; grid-row: span 2; align-content: start; }
.thumb.poster[data-empty]::after { top: calc((var(--tw) * 2 + var(--c)) * 8 / 9); }
.thumb canvas { width: 100%; height: auto; border-radius: 8px; background: var(--line); touch-action: manipulation; }
.thumb[data-empty]::after { content: "+"; position: absolute; left: 50%; top: calc(var(--tw) * 8 / 9); width: 28px; height: 28px; margin: -14px 0 0 -14px; border-radius: 50%; background: rgba(255,255,255,.92); color: #18181b; font-size: 20px; line-height: 27px; }
.actions { display: grid; grid-template-columns: 1fr 2fr; gap: 8px; }
.actions > * { min-height: 48px; }
/* Main action in the app's own amber (favicon / default accent): lively without the weight of black. */
.brand, body[data-empty] #add-photos { border: 0; border-radius: 8px; background: var(--brand); color: var(--on-brand); font-weight: 600; box-shadow: inset 0 -2px 0 rgba(0,0,0,.12); transition: transform 160ms var(--ease-out), background-color 160ms ease; }
.brand:active, body[data-empty] #add-photos:active { transform: scale(.97); background: var(--brand-down); }
/* Before the first photo, Add photos is the main action and View calendar steps back. */
body[data-empty] #view { background: var(--surface); color: var(--text); border: 1px solid var(--line); box-shadow: none; font-weight: 400; }
.danger { background: var(--danger-bg); color: var(--danger); }
.danger:active { background: var(--danger-down); }
/* Month screen: two fingers spreading apart, shown once per visit on the first month with a photo. */
.pinch-hint { display: none; position: absolute; z-index: 2; left: 50%; top: 36%; transform: translate(-50%, -50%); flex-direction: column; align-items: center; gap: 10px; pointer-events: none; }
.stage[data-pinch] .pinch-hint { display: flex; }
body[data-mode="view"] .pinch-hint { display: none; }
.pinch-hint span { display: flex; gap: 8px; }
.pinch-hint i { width: 26px; height: 26px; border-radius: 50%; background: rgba(255,255,255,.9); box-shadow: 0 2px 10px rgba(0,0,0,.35); animation: spread 1.4s cubic-bezier(0.77, 0, 0.175, 1) infinite; } /* loops until the page is touched (owner 2026-10-13) */
.pinch-hint i + i { animation-name: spread-r; }
@keyframes spread { 0%, 100% { transform: translateX(10px); } 50% { transform: translateX(-16px); } }
@keyframes spread-r { 0%, 100% { transform: translateX(-10px); } 50% { transform: translateX(16px); } }
.pinch-hint { width: calc(min(100cqw, 100cqh * 9 / 16) * .88); } /* inside the page, not the stage */
.pinch-hint b { max-width: 100%; padding: 6px 12px; border-radius: 8px; background: rgba(0,0,0,.55); color: #fff; font-size: 13px; font-weight: 500; text-align: center; }
.stage { position: relative; flex: 1 1 0; min-height: 0; display: grid; place-items: center; container-type: size; }
.stage > canvas { grid-area: 1 / 1; }
/* Flip overlay stays composited (opacity 0 when idle) so iOS doesn't rebuild the layer on every turn. */
#canvas { transform-origin: 0 0; }
#ghost { position: fixed; z-index: 4; transform-origin: 0 0; pointer-events: none; border: 0; border-radius: 8px; }
#flip { z-index: 1; pointer-events: none; opacity: 0; transform-origin: top center; backface-visibility: hidden; will-change: transform; }
canvas { width: min(100cqw, 100cqh * 9 / 16); height: auto; touch-action: none; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); }

.primary { display: flex; align-items: center; justify-content: center; min-height: 48px; border: 0; border-radius: 8px; background: var(--ink); color: var(--on-ink); font-weight: 600; transition: transform 160ms var(--ease-out), background-color 160ms ease; }
.primary:active { transform: scale(.97); opacity: .88; }
.ghost { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 0 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); transition: transform 160ms var(--ease-out); }
.ghost:active { transform: scale(.97); }
.ghost:disabled { opacity: .4; cursor: default; transform: none; }
#share { width: 100%; }
#share span { transition: filter 200ms ease, opacity 200ms ease; }
#title { margin: 0; line-height: 44px; text-align: center; font: 700 19px Kanit, sans-serif; color: var(--ink); }
.add { flex-direction: column; gap: 2px; min-height: 56px; position: absolute; top: 40%; left: 50%; transform: translate(-50%, -50%); padding: 0 22px; transition: opacity 150ms ease, transform 150ms var(--ease-out); }
.add small { font-size: 12px; font-weight: 400; opacity: .7; }
.add:active { transform: translate(-50%, -50%) scale(.97); }
.add[data-gone] { opacity: 0; transform: translate(-50%, -50%) scale(.97); pointer-events: none; }

.month-row { display: flex; align-items: center; justify-content: center; gap: 8px; font-weight: 500; }
#month { position: relative; min-width: 9em; text-align: center; }
.icon { width: 44px; height: 44px; border: 0; border-radius: 8px; background: none; font-size: 22px; color: var(--muted); transition: transform 160ms var(--ease-out), background-color 160ms ease; }
.icon:active { transform: scale(.95); background: var(--line); }
.icon:disabled { opacity: .3; cursor: default; transform: none; background: none; }
/* Month ‹ ›: same small white round button as the style row's, inside a 44px tap area. */
.month-row .icon { position: relative; width: 36px; height: 36px; margin: 4px; padding: 0; border: 1px solid var(--line); border-radius: 50%; background: var(--surface); color: var(--text); font-size: 20px; line-height: 32px; box-shadow: 0 1px 3px var(--shadow); }
.month-row .icon::after { content: ""; position: absolute; inset: -4px; }
.month-row .icon:disabled { background: var(--surface); }

.tabs-wrap { position: relative; }
.tabs { --fl: #000; --fr: #000; -webkit-mask-image: linear-gradient(to right, var(--fl), #000 56px, #000 calc(100% - 56px), var(--fr)); mask-image: linear-gradient(to right, var(--fl), #000 56px, #000 calc(100% - 56px), var(--fr)); }
.tabs-wrap[data-less] .tabs { --fl: transparent; }
.tabs-wrap[data-more] .tabs { --fr: transparent; }
.tabs-more { position: absolute; right: 2px; top: 10px; width: 24px; height: 24px; padding: 0; border: 1px solid var(--line); border-radius: 50%; background: var(--surface); font-size: 16px; line-height: 21px; color: var(--text); box-shadow: 0 1px 3px var(--shadow); opacity: 0; pointer-events: none; transition: opacity 150ms ease, transform 120ms var(--ease-out); }
.tabs-more::after { content: ""; position: absolute; inset: -10px; } /* 44px tap target */
.tabs-wrap[data-more] #tabs-more, .tabs-wrap[data-less] #tabs-less { opacity: 1; pointer-events: auto; }
.tabs-less { right: auto; left: 2px; }
.tabs-more:active { transform: scale(.94); }
.tabs { position: relative; display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; flex: none; border-bottom: 1px solid var(--line); }
/* 1px bar scaled to the active tab's width; slides between tabs with transform only. */
.tab-ink { position: absolute; left: 0; bottom: 0; width: 1px; height: 2px; background: var(--ink); transform-origin: left; transition: transform 200ms var(--ease-out); }
.tabs::-webkit-scrollbar { display: none; }
.tabs button { flex: none; min-height: 44px; padding: 0 10px; border: 0; background: none; color: var(--muted); font-size: 14px; transition: color 150ms ease, transform 160ms var(--ease-out); }
.tabs button:active { color: var(--text); transform: scale(.96); }
.tabs button[aria-pressed="true"] { color: var(--ink); font-weight: 600; }

.tools { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.spacer { flex: 1; }
.swatch { position: relative; gap: 8px; padding: 0 10px 0 8px; }
.swatch .dot { width: 20px; height: 20px; border-radius: 50%; box-shadow: inset 0 0 0 1px rgba(0,0,0,.12), 0 0 0 2px var(--surface), 0 0 0 3px var(--line); }
.swatch input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; border: 0; padding: 0; cursor: pointer; }
.swatch:has(input:focus-visible) { outline: 2px solid var(--ink); outline-offset: 2px; }
/* TH | EN segmented control: the white thumb slides to the selected side. */
.seg { position: relative; display: grid; grid-template-columns: 1fr 1fr; padding: 2px; border-radius: 8px; background: var(--line); }
.seg::before { content: ""; position: absolute; top: 2px; left: 2px; width: calc(50% - 2px); height: calc(100% - 4px); border-radius: 6px; background: var(--surface); box-shadow: 0 1px 2px var(--shadow); transition: transform 200ms var(--ease-out); }
.seg[data-value="en"]::before { transform: translateX(100%); }
.seg button { position: relative; min-width: 48px; min-height: 40px; border: 0; background: none; color: var(--muted); font-size: 14px; font-weight: 500; transition: color 150ms ease; }
.seg button[aria-checked="true"] { color: var(--ink); }

/* Share sheet: slides up from the bottom; exit is faster than enter. */
.sheet { position: fixed; inset: 0; z-index: 10; }
.sheet[hidden] { display: none; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(17,17,17,.32); opacity: 0; transition: opacity 200ms ease; }
.sheet-panel { position: absolute; left: 0; right: 0; bottom: 0; max-width: 480px; margin: 0 auto; display: grid; gap: 4px; padding: 8px 16px calc(16px + env(safe-area-inset-bottom)); border-radius: 12px 12px 0 0; background: var(--surface); transform: translateY(100%); transition: transform 200ms var(--ease-out); }
.sheet-panel:focus-visible { outline: none; } /* focused by script for Esc/screen readers; not a control, so no ring (iOS drew it as a line above the sheet) */
.sheet[data-open] .sheet-backdrop { opacity: 1; }
.sheet[data-open] .sheet-panel { transform: translateY(0); transition: transform 320ms var(--ease-drawer); }
.sheet-item { display: grid; gap: 2px; text-align: left; padding: 14px 4px; border: 0; border-bottom: 1px solid var(--line); background: none; transition: background-color 150ms ease, opacity 150ms ease; }
.sheet-item:active { background: var(--bg); }
.sheet-item:disabled { opacity: .5; cursor: default; }
.sheet-item b { font-weight: 600; color: var(--ink); }
.sheet-item span { font-size: 13px; color: var(--muted); }
.sheet-cancel { min-height: 48px; margin-top: 8px; }
.ask-text { margin: 8px 4px 12px; font-weight: 600; color: var(--ink); }
.emojis { display: grid; grid-template-columns: repeat(6, 1fr); max-height: 338px; overflow-y: auto; overscroll-behavior: contain; margin-bottom: 4px; } /* 6.5 rows of 52px: the half row shows it scrolls */
.emojis { mask-image: linear-gradient(var(--fade-top, #000), #000 40px, #000 calc(100% - 40px), var(--fade-bottom, transparent)); }
.emojis[data-scrolled] { --fade-top: transparent; }
.emojis[data-end] { --fade-bottom: #000; }
.emojis button { min-height: 52px; border: 0; border-radius: 8px; background: none; font-size: 28px; transition: transform 120ms var(--ease-out); }
.emojis button:active { transform: scale(.9); }
.emojis button:active, .emojis [aria-pressed="true"] { background: var(--bg); }

/* View: the page fills the screen; tap shows ×, the tip teaches the swipe until the first turn. */
body[data-mode="view"] { background: #000; overscroll-behavior: none; }
body[data-mode="view"] main > :not(.stage), body[data-mode="view"] #add { display: none; }
body[data-mode="view"] .stage { position: fixed; inset: 0; z-index: 5; padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom); background: #000; touch-action: none; }
body[data-mode="view"] canvas { border: 0; }
.view-hint, .view-close { display: none; position: absolute; z-index: 2; color: #fff; background: rgba(0,0,0,.55); }
.view-hint { background: none; opacity: .9; transition: opacity 200ms ease; }
.view-hint b { display: none; font-weight: 600; }
.stage[data-hint] .view-hint { background: #fff; color: #18181b; opacity: 1; box-shadow: 0 4px 24px rgba(0,0,0,.4); }
.stage[data-hint] .view-hint b { display: block; }
.view-hint { left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%); margin: 0; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 8px; font-size: 14px; white-space: nowrap; pointer-events: none; }
.view-hint span { font-size: 18px; line-height: 1; animation: nudge 1.4s cubic-bezier(0.77, 0, 0.175, 1) infinite; }
@keyframes nudge { 0%, 100% { transform: translateY(3px); } 50% { transform: translateY(-4px); } }
body[data-mode="view"] .view-hint { display: flex; }
body[data-mode="view"] .view-close { display: block; }
.view-close { top: calc(12px + env(safe-area-inset-top)); right: 12px; width: 44px; height: 44px; border: 0; border-radius: 50%; background: rgba(255,255,255,.94); color: #18181b; box-shadow: 0 4px 16px rgba(0,0,0,.4); font-size: 26px; line-height: 1; opacity: 0; pointer-events: none; transition: opacity 150ms ease; }
.stage[data-chrome] .view-close { opacity: 1; pointer-events: auto; }

#toast { position: fixed; z-index: 20; left: 50%; top: calc(64px + env(safe-area-inset-top)); max-width: calc(100% - 32px); text-align: center; background: var(--ink); color: var(--on-ink); padding: 10px 16px; border-radius: 8px; font-size: 14px; opacity: 0; transform: translate(-50%, -8px); transition: opacity 150ms ease, transform 150ms var(--ease-out); pointer-events: none; }
#toast.show { opacity: 1; transform: translate(-50%, 0); transition-duration: 250ms; }

@media (prefers-reduced-motion: reduce) {
  .seg::before, .tab-ink, .add, #toast, .sheet-panel, .sheet[data-open] .sheet-panel { transition-property: opacity; }
  .sheet-panel { transform: none; opacity: 0; }
  .sheet[data-open] .sheet-panel { opacity: 1; }
  .view-hint span, .pinch-hint i { animation: none; }
}
@media (max-width: 379px) { .swatch-text { display: none; } .swatch { padding: 0 11px; } }
