:root { --bg: #f7f6f3; --surface: #ffffff; --text: #2f3437; --muted: #787774; --line: #eaeaea; --ink: #111111;
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1); --ease-drawer: cubic-bezier(0.32, 0.72, 0, 1); }
* { box-sizing: border-box; }
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; }
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; }

.stage { position: relative; flex: 1 1 0; min-height: 0; display: grid; place-items: center; container-type: size; }
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: 6px; background: var(--ink); color: #fff; font-weight: 600; transition: transform 160ms var(--ease-out), background-color 160ms ease; }
.primary:active { transform: scale(.97); background: #333; }
.ghost { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 0 14px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); transition: transform 160ms var(--ease-out); }
.ghost:active { transform: scale(.97); }
#share { width: 100%; }
.add { position: absolute; top: 40%; left: 50%; transform: translate(-50%, -50%); padding: 0 22px; }
.add:active { transform: translate(-50%, -50%) scale(.98); }
.add[hidden] { display: none; }

.month-row { display: flex; align-items: center; justify-content: center; gap: 8px; font-weight: 500; }
#month { min-width: 9em; text-align: center; }
.icon { width: 44px; height: 44px; border: 0; border-radius: 6px; background: none; font-size: 22px; color: var(--muted); transition: transform 160ms var(--ease-out), background-color 160ms ease; }
.icon:active { transform: scale(.92); background: var(--line); }

.tabs { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; flex: none; border-bottom: 1px solid var(--line); }
.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; }
.tabs button:active { color: var(--text); }
.tabs button[aria-pressed="true"] { color: var(--ink); font-weight: 600; box-shadow: inset 0 -2px 0 var(--ink); }

.tools { display: flex; align-items: center; gap: 8px; }
.spacer { flex: 1; }
#accent { width: 44px; height: 44px; padding: 8px; border: 0; background: none; }
#accent::-webkit-color-swatch-wrapper { padding: 0; }
#accent::-webkit-color-swatch { border: 1px solid var(--line); border-radius: 50%; }
/* 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 rgba(0,0,0,.08); 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: 8px; 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[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; }
.sheet-item:active { background: var(--bg); }
.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: 4px; }

#toast { position: fixed; z-index: 20; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 6px; 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) {
  .sheet-panel, .sheet[data-open] .sheet-panel, .seg::before, #toast { transition-property: opacity; }
  .sheet-panel { transform: none; opacity: 0; }
  .sheet[data-open] .sheet-panel { opacity: 1; }
}
