/* 阿嬤的囡仔 — 版面：直式手機、單手操作；紙張、花布、木頭的老家質感
   調色盤來自企劃：奶油黃、豆沙粉、鼠尾草綠、木質棕、天空藍。
   這是刻意只有一種氛圍的「阿嬤家」世界，夜晚由場景光線表現，不另做深色主題。 */
:root {
  --paper: #FBF5E4;
  --cream: #F6EBD0;
  --bean: #D9A39A;
  --bean-deep: #A9665B;
  --sage: #9DB08A;
  --sage-deep: #5F7D4F;
  --wood: #8A5A3B;
  --wood-deep: #5E3B26;
  --sky: #A8C8DD;
  --ink: #4A3428;
  --ink-soft: #7B6352;
  --line: rgba(94, 59, 38, .18);
  --shadow: 0 10px 30px rgba(74, 52, 40, .18);
  --outside: #E6D8BC;
  --font-hand: "LXGW WenKai TC", "Kaiti TC", "STKaiti", "BiauKai", "DFKai-SB", serif;
  --font-round: "Huninn", "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", sans-serif;
  --nav-h: 64px;
  color-scheme: light;
}
[hidden] { display: none !important; }
html { height: 100%; box-sizing: border-box; }
*, *::before, *::after { box-sizing: inherit; }
body {
  height: 100%; margin: 0; overflow: hidden;
  background: var(--outside);
  background-image: radial-gradient(rgba(138, 90, 59, .08) 1px, transparent 1.2px);
  background-size: 14px 14px;
  color: var(--ink); font-family: var(--font-round); font-size: 15px;
  -webkit-tap-highlight-color: transparent; -webkit-user-select: none; user-select: none;
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; cursor: pointer; }
input { font: inherit; -webkit-user-select: text; user-select: text; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 2.5px dashed var(--bean-deep); outline-offset: 3px; }
.small { font-size: 13px; color: var(--ink-soft); line-height: 1.6; }
.center { text-align: center; }
.tw { font-family: var(--font-hand); }

#app {
  position: relative; width: 100%; max-width: 440px; height: 100%; margin: 0 auto;
  overflow: hidden; background: var(--cream); box-shadow: 0 0 60px rgba(74, 52, 40, .22);
}
.defs { position: absolute; width: 0; height: 0; }
.scene-svg { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.scene-svg text { font-family: var(--font-round); }
#scene { position: absolute; inset: 0 0 var(--nav-h) 0; overflow: hidden; }
#scene [data-hot] { cursor: pointer; }
#fx { position: absolute; inset: 0 0 var(--nav-h) 0; width: 100%; height: calc(100% - var(--nav-h)); pointer-events: none; z-index: 4; }
.grain {
  position: absolute; inset: 0; pointer-events: none; z-index: 3; opacity: .5; mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='180' height='180'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 .36  0 0 0 0 .25  0 0 0 0 .15  0 0 0 .1 0'/></filter><rect width='180' height='180' filter='url(%23n)'/></svg>");
}
.actor.talking .mouth { animation: talk .2s ease-in-out infinite alternate; transform-box: fill-box; transform-origin: center; }
.eye-dot { animation: blink 4.6s infinite; transform-box: fill-box; transform-origin: center; }
@keyframes talk { from { transform: scaleY(1); } to { transform: scaleY(.45); } }
@keyframes blink { 0%, 95%, 100% { transform: scaleY(1); } 97% { transform: scaleY(.12); } }

/* ---------- 上方 ---------- */
#topbar {
  position: absolute; top: 0; left: 0; right: 0; z-index: 6;
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  padding: 12px 14px; pointer-events: none;
}
#topbar > * { pointer-events: auto; }
.daypill {
  display: flex; align-items: baseline; gap: 8px; padding: 7px 14px 7px 13px;
  background: rgba(251, 245, 228, .92); border: 1px solid var(--line); border-radius: 999px;
  box-shadow: 0 2px 10px rgba(74, 52, 40, .1);
}
.daypill b { font-family: var(--font-hand); font-size: 18px; letter-spacing: .04em; }
.daypill span { font-size: 12.5px; color: var(--ink-soft); letter-spacing: .08em; }
.top-actions { display: flex; gap: 8px; }
.iconbtn {
  position: relative; width: 42px; height: 42px; display: grid; place-items: center;
  border-radius: 50%; border: 1px solid var(--line); background: rgba(251, 245, 228, .94);
  box-shadow: 0 2px 10px rgba(74, 52, 40, .1); color: var(--wood-deep); padding: 0;
}
.iconbtn:active { transform: scale(.94); }
.ic { width: 22px; height: 22px; flex: none; }
.dot { position: absolute; top: 6px; right: 6px; width: 10px; height: 10px; border-radius: 50%; background: #D9584A; border: 2px solid var(--paper); }

/* ---------- 今仔日 ---------- */
#today { position: absolute; left: 0; right: 0; bottom: var(--nav-h); z-index: 6; padding-bottom: 10px; }
.today-head {
  display: inline-flex; align-items: baseline; flex-wrap: wrap; gap: 0 8px; margin: 0 16px 7px; padding: 4px 12px 5px;
  border-radius: 999px; background: rgba(74, 52, 40, .7); color: var(--paper);
  font-family: var(--font-hand); font-size: 14.5px;
}
.today-head span { font-family: var(--font-round); font-size: 11.5px; opacity: .85; }
.today-head.done { padding: 7px 14px; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 16px 4px; scrollbar-width: none; scroll-snap-type: x proximity; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; display: inline-flex; align-items: center; gap: 6px; padding: 9px 14px 9px 11px;
  border-radius: 999px; border: 1px solid var(--line); background: rgba(251, 245, 228, .95);
  font-size: 13.5px; box-shadow: 0 3px 10px rgba(74, 52, 40, .15); scroll-snap-align: start; color: var(--ink);
}
.chip .ic { width: 18px; height: 18px; color: var(--sage-deep); }
.chip.hl { background: var(--bean-deep); color: var(--paper); border-color: transparent; }
.chip.hl .ic { color: var(--paper); }
.chip:active { transform: scale(.96); }

/* ---------- 下方導覽 ---------- */
#nav {
  position: absolute; left: 0; right: 0; bottom: 0; height: var(--nav-h); z-index: 7;
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: var(--paper); border-top: 1px solid var(--line);
  box-shadow: 0 -4px 16px rgba(74, 52, 40, .08);
}
#nav button {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  border: 0; background: none; font-size: 12px; color: var(--ink-soft); position: relative; letter-spacing: .1em;
}
#nav button .ic { width: 24px; height: 24px; }
#nav button.on { color: var(--bean-deep); }
#nav button.on::before {
  content: ""; position: absolute; top: 7px; width: 44px; height: 30px; border-radius: 16px;
  background: rgba(217, 163, 154, .28); z-index: -1;
}

/* ---------- 對話框 ---------- */
#dlg { position: absolute; inset: 0; z-index: 20; display: flex; flex-direction: column; justify-content: flex-end; padding: 0 12px 14px; }
.dlg-box {
  position: relative; padding: 22px 20px 18px; min-height: 132px;
  background: var(--paper); border-radius: 22px; border: 1.5px solid rgba(138, 90, 59, .3);
  box-shadow: var(--shadow); animation: rise .28s ease-out;
}
.dlg-box::before { content: ""; position: absolute; inset: 7px; border: 1.5px dashed rgba(138, 90, 59, .22); border-radius: 16px; pointer-events: none; }
#dlg-name {
  position: absolute; top: -15px; left: 18px; padding: 4px 16px 5px;
  background: var(--bean-deep); color: var(--paper); border-radius: 999px;
  font-family: var(--font-hand); font-weight: 700; font-size: 16px; letter-spacing: .12em;
  box-shadow: 0 3px 8px rgba(74, 52, 40, .2);
}
#dlg[data-who="me"] #dlg-name { left: auto; right: 18px; background: var(--sage-deep); }
#dlg[data-who="owner"] #dlg-name, #dlg[data-who="azhu"] #dlg-name { background: var(--wood); }
#dlg[data-who="young"] #dlg-name { background: #5E7FA0; }
#dlg-text { margin: 0; font-family: var(--font-hand); font-size: 18.5px; line-height: 1.7; min-height: 3.4em; letter-spacing: .02em; -webkit-user-select: text; user-select: text; }
#dlg[data-who="narr"] #dlg-text { color: var(--ink-soft); font-size: 17px; }
#dlg[data-who="me"] #dlg-text { color: #3E5636; }
#dlg-next { position: absolute; right: 22px; bottom: 12px; width: 0; height: 0; border-left: 7px solid transparent; border-right: 7px solid transparent; border-top: 9px solid var(--bean-deep); animation: bob 1s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(4px); } }
@keyframes rise { from { transform: translateY(14px); opacity: 0; } }
#dlg.choosing #dlg-text { min-height: 0; margin-bottom: 10px; }
#dlg.choosing #dlg-text:empty { display: none; }
#dlg-choices { display: grid; gap: 8px; margin-top: 4px; }
#dlg-choices:empty { display: none; }
.choice {
  text-align: left; padding: 12px 16px; border-radius: 14px;
  background: #FFF9EA; border: 1.5px solid rgba(138, 90, 59, .32);
  font-family: var(--font-hand); font-size: 17px; color: var(--ink); line-height: 1.45;
}
.choice:active { transform: scale(.98); background: #F6E2D6; }
#dlg-choices.mood-grid { grid-template-columns: repeat(3, 1fr); gap: 8px; }
.mood-grid .choice { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 10px 4px 9px; text-align: center; font-size: 14px; }
.mood-grid .choice svg { width: 46px; height: 46px; }
.mood-grid .choice .skip { margin: auto 0; color: var(--ink-soft); font-size: 15px; }
#dlg-choices.name-form { margin-top: 8px; }
#name-form { display: flex; gap: 8px; }
#name-form input, .set input {
  flex: 1; min-width: 0; padding: 11px 14px; border-radius: 12px; border: 1.5px solid rgba(138, 90, 59, .35);
  background: #fff; font-family: var(--font-hand); font-size: 18px; color: var(--ink);
}
.name-tip { margin: 6px 2px 0; font-size: 12.5px; color: var(--ink-soft); }

/* ---------- 按鈕 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 12px 22px; border-radius: 999px; border: 0;
  background: var(--wood); color: var(--paper); font-size: 16px; letter-spacing: .08em;
  box-shadow: 0 3px 0 var(--wood-deep);
}
.btn:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--wood-deep); }
.btn.ghost { background: transparent; color: var(--wood); box-shadow: inset 0 0 0 1.5px rgba(138, 90, 59, .55); }
.btn.big { font-size: 18px; padding: 14px 34px; background: var(--bean-deep); box-shadow: 0 4px 0 #7E4A41; }
.btn.small { font-size: 14px; padding: 8px 16px; }
.btn:disabled { opacity: .5; box-shadow: none; }
.linkbtn { border: 0; background: none; padding: 6px 4px; color: var(--wood); text-decoration: underline; text-underline-offset: 3px; font-size: 14px; }

/* ---------- 卡片 ---------- */
#modal { position: absolute; inset: 0; z-index: 25; display: grid; place-items: center; padding: 20px 16px; background: rgba(60, 40, 25, .45); overflow-y: auto; }
.card {
  width: min(360px, 100%); padding: 24px 20px 18px; text-align: center;
  background: var(--paper); border-radius: 24px; box-shadow: 0 18px 50px rgba(40, 25, 15, .35);
  animation: pop .32s cubic-bezier(.2, .9, .3, 1.2);
}
@keyframes pop { from { transform: scale(.9) translateY(10px); opacity: 0; } }
.card-art { width: 132px; height: 132px; margin: 0 auto 6px; display: grid; place-items: center; border-radius: 50%; background: radial-gradient(circle, #FFF8E4 0%, #F3E4C2 70%); }
.card-art > svg { width: 104px; height: 104px; }
.card-kicker { margin: 4px 0 2px; font-size: 12.5px; letter-spacing: .2em; color: var(--bean-deep); }
.card-title { margin: 2px 0 10px; font-family: var(--font-hand); font-size: 25px; letter-spacing: .06em; text-wrap: balance; }
.card-body { text-align: left; font-size: 15px; line-height: 1.75; }
.card-body p { margin: 0 0 10px; }
.card-body .tw { font-size: 17px; color: var(--wood-deep); }
.ama-line { padding: 10px 12px; background: rgba(217, 163, 154, .16); border-radius: 12px; }
.card-actions { display: flex; gap: 10px; justify-content: center; margin-top: 16px; flex-wrap: wrap; }
.package-card .card-art { width: 100%; height: auto; border-radius: 18px; padding: 10px 0; }
.pkg-row { display: flex; justify-content: center; gap: 4px; }
.pkg-row svg { width: 84px; height: 84px; }
.note-card { background: #FDF7E6; background-image: repeating-linear-gradient(transparent 0 46px, rgba(138, 90, 59, .18) 46px 47px); transform: rotate(-1.2deg); padding-top: 36px; }
.hand-note { font-family: var(--font-hand); font-size: 30px; line-height: 47px; text-align: center; color: #3B2A20; margin: 0 0 6px; }
.quote-card { background: radial-gradient(circle at 15% 10%, rgba(217, 163, 154, .25), transparent 45%), radial-gradient(circle at 90% 90%, rgba(157, 176, 138, .3), transparent 50%), var(--paper); }
.quote-tw { font-family: var(--font-hand); font-size: 31px; font-weight: 700; line-height: 1.45; text-align: center; margin: 14px 0 10px !important; text-wrap: balance; }
.quote-zh { text-align: center; color: var(--ink-soft); font-size: 14.5px; }
.quote-sign { text-align: right; font-family: var(--font-hand); color: var(--bean-deep); font-size: 17px; }
.quote-sign::before { content: "—— "; }
.pc-img { width: 100%; border-radius: 12px; box-shadow: 0 6px 20px rgba(74, 52, 40, .2); display: block; margin: 0 auto 10px; -webkit-user-select: auto; user-select: auto; -webkit-touch-callout: default; }
.teaser-card { background: #2F3550; color: #F6EBD0; }
.teaser-card .card-title { font-size: 28px; }
.teaser-card .card-kicker { color: #F2B5A8; }
.teaser-card .card-body { text-align: center; font-family: var(--font-hand); font-size: 18px; }
.letter-card { background: #FDF7E6; transform: rotate(.8deg); }
.letter { font-family: var(--font-hand); font-size: 19px; line-height: 44px; background-image: repeating-linear-gradient(transparent 0 43px, rgba(138, 90, 59, .2) 43px 44px); color: #3B2A20; padding-top: 2px; }
.letter p { margin: 0 !important; }
.letter .sign { text-align: right; padding-right: 10px; }
.poke-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; padding: 10px; background: #F7F1E0; border: 3px solid #B48A3E; border-radius: 10px; }
.poke-cell { aspect-ratio: 4/5; border: 0; border-radius: 4px; padding: 0; display: grid; place-items: center; }
.poke-cell.c0 { background: #F2A0B4; } .poke-cell.c1 { background: #9FC3E0; } .poke-cell.c2 { background: #F4CF7E; } .poke-cell.c3 { background: #A8D5A2; }
.poke-cell.open { background: #FFFDF5; box-shadow: inset 0 0 0 2px #D9C9A8; animation: pop .3s; }
.poke-cell svg { width: 100%; height: 100%; }

.leftover-card .card-art { background: radial-gradient(circle, #FFF8E4 0%, #F2E0C6 70%); }
.slip { margin: 4px auto 0; max-width: 250px; padding: 14px 16px 10px; background: #FFFDF5; border: 1px solid rgba(138, 90, 59, .25); transform: rotate(-1.5deg); box-shadow: 0 4px 12px rgba(74, 52, 40, .12); font-family: var(--font-hand); }
.slip p { margin: 0 !important; font-size: 20px; line-height: 1.6; text-align: center; color: #3B2A20; }
.slip .sign { text-align: right; font-size: 16px; color: var(--bean-deep); }
.slip .sign::before { content: "—— "; }
.letter-form { display: grid; gap: 8px; margin-bottom: 18px; }
.letter-form textarea {
  width: 100%; padding: 14px 16px; border-radius: 14px; border: 1.5px solid rgba(138, 90, 59, .35); resize: vertical;
  background: #FFFDF5 repeating-linear-gradient(transparent 0 33px, rgba(138, 90, 59, .14) 33px 34px); background-attachment: local;
  font-family: var(--font-hand); font-size: 18px; line-height: 34px; color: var(--ink); -webkit-user-select: text; user-select: text;
}
.letter-form .row { display: flex; justify-content: space-between; align-items: center; }
.sub { margin: 6px 0 10px; font-family: var(--font-hand); font-size: 18px; }
.letters { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.letters li { padding: 12px 14px; border-radius: 14px; background: #FFF9EA; border: 1px solid var(--line); }
.letters p { margin: 0 0 6px; line-height: 1.7; }
.letters .tw { font-size: 17px; }
.letters .reply { color: var(--bean-deep); font-size: 16px; margin: 4px 0 0; }

/* ---------- 提示 ---------- */
#toast { position: absolute; top: 66px; left: 16px; right: 16px; z-index: 30; display: flex; flex-direction: column; align-items: center; gap: 6px; pointer-events: none; }
.toast-item {
  display: flex; align-items: center; gap: 8px; max-width: 100%; padding: 8px 16px 8px 12px;
  background: rgba(74, 52, 40, .92); color: var(--paper); border-radius: 999px; font-size: 13.5px;
  box-shadow: 0 6px 18px rgba(40, 25, 15, .25); animation: rise .25s ease-out; transition: opacity .4s, transform .4s;
}
.toast-item.out { opacity: 0; transform: translateY(-8px); }
.toast-art { display: grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; background: var(--paper); color: var(--wood); }
.toast-art svg { width: 22px; height: 22px; }

#cover { position: absolute; inset: 0; z-index: 40; background: var(--paper); opacity: 0; pointer-events: none; transition: opacity .4s ease; }
#cover.on { opacity: 1; pointer-events: auto; }

/* ---------- 舞台（故事、牽掛） ---------- */
#stage { position: absolute; inset: 0; z-index: 10; background: #2B2420; overflow: hidden; }
.stage-bg, .stage-fg { position: absolute; inset: 0; transition: opacity .36s ease; }
.stage-bg.fading { opacity: 0; }
.stage-bg.blur .scene-svg { filter: blur(3px) saturate(.85) brightness(.9); transform: scale(1.04); }
.stage-bg.sepia .scene-svg { filter: sepia(.75) saturate(.75) contrast(.95) brightness(1.04); }
.stage-bg.sepia::after { content: ""; position: absolute; inset: 0; background: radial-gradient(ellipse at center, transparent 45%, rgba(60, 40, 20, .55)); pointer-events: none; }
.stage-fg .scene-svg { pointer-events: none; }
.chapter {
  position: absolute; left: 24px; right: 24px; top: 26%; z-index: 12; text-align: center;
  padding: 22px 18px; background: rgba(251, 245, 228, .94); border-radius: 22px; box-shadow: var(--shadow);
  animation: rise .5s ease-out; transition: opacity .6s, transform .6s;
}
.chapter.out { opacity: 0; transform: translateY(-10px); pointer-events: none; }
.chapter p { margin: 0 0 4px; font-size: 13px; letter-spacing: .3em; color: var(--bean-deep); }
.chapter h2 { margin: 0; font-family: var(--font-hand); font-size: 32px; letter-spacing: .08em; }
.quiet { position: absolute; left: 0; right: 0; bottom: 18%; z-index: 12; margin: 0; text-align: center; color: var(--paper); font-family: var(--font-hand); font-size: 17px; line-height: 1.8; opacity: 0; transition: opacity 1.2s; text-shadow: 0 1px 6px rgba(0, 0, 0, .4); }
.quiet.ready { opacity: .9; }
.notes { position: absolute; left: 0; right: 0; top: 30%; z-index: 12; display: flex; justify-content: center; gap: 30px; pointer-events: none; }
.notes i { font-style: normal; font-size: 30px; color: var(--paper); text-shadow: 0 2px 6px rgba(0, 0, 0, .35); animation: float 3.4s ease-out forwards; opacity: 0; }
.notes i:nth-child(2) { animation-delay: .6s; } .notes i:nth-child(3) { animation-delay: 1.2s; }
@keyframes float { 15% { opacity: 1; } to { opacity: 0; transform: translateY(-80px) rotate(12deg); } }
.breathe { position: absolute; inset: 0; z-index: 12; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 22px; background: rgba(40, 30, 25, .35); }
.b-ring { width: 120px; height: 120px; border-radius: 50%; border: 2px solid rgba(251, 245, 228, .6); display: grid; place-items: center; transition: transform 4s ease-in-out; }
.breathe.in .b-ring { transform: scale(1.7); }
.breathe.out .b-ring { transform: scale(1); transition-duration: 6s; }
.b-dot { width: 64px; height: 64px; border-radius: 50%; background: radial-gradient(circle, #FBE3D6, #D9A39A); }
.b-text { margin: 30px 0 0; color: var(--paper); font-family: var(--font-hand); font-size: 22px; letter-spacing: .2em; }
.breathe .linkbtn { color: var(--paper); }

/* ---------- 料理 ---------- */
#cook {
  position: absolute; inset: 0; z-index: 12; display: flex; flex-direction: column; gap: 8px; padding: 12px 14px 16px;
  background: #E7DCC5;
  background-image: linear-gradient(rgba(255, 255, 255, .45) 1.5px, transparent 1.5px), linear-gradient(90deg, rgba(255, 255, 255, .45) 1.5px, transparent 1.5px);
  background-size: 34px 34px;
}
.cook-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.cook-head h2 { margin: 0; flex: 1; font-family: var(--font-hand); font-size: 22px; letter-spacing: .06em; }
.cook-head h2 small { font-size: 14px; color: var(--ink-soft); margin-left: 8px; letter-spacing: .1em; }
.cook-dots { display: flex; gap: 5px; width: 100%; }
.cook-dots i { flex: 1; height: 5px; border-radius: 3px; background: rgba(138, 90, 59, .2); }
.cook-dots i.done { background: var(--sage); }
.cook-dots i.cur { background: var(--bean-deep); }
.cook-tip { display: flex; align-items: center; gap: 10px; }
.tip-face { flex: none; width: 56px; height: 56px; border-radius: 50%; background: var(--paper); border: 2px solid rgba(138, 90, 59, .3); overflow: hidden; }
.tip-face svg { width: 100%; height: 100%; }
.tip-text { position: relative; flex: 1; margin: 0; padding: 10px 14px; background: var(--paper); border-radius: 16px; font-family: var(--font-hand); font-size: 17px; line-height: 1.5; box-shadow: 0 3px 10px rgba(74, 52, 40, .1); }
.tip-text::before { content: ""; position: absolute; left: -7px; top: 50%; margin-top: -7px; border: 7px solid transparent; border-left: 0; border-right-color: var(--paper); }
.cook-stage { position: relative; flex: 1; min-height: 0; display: grid; place-items: center; }
.cook-svg { width: min(100%, 52vh, 420px); aspect-ratio: 1; touch-action: none; display: block; }
.cook-svg .tapme { cursor: pointer; }
.cook-svg .knife.chopping { animation: chop .18s; }
.cook-svg #content.flipping { animation: flip .38s ease-in-out; transform-box: fill-box; transform-origin: center; }
@keyframes chop { 50% { transform: translate(var(--x, 0), 50px); } }
@keyframes flip { 50% { transform: scaleY(.05); } }
.cook-prog { position: absolute; left: 20%; right: 20%; bottom: 0; height: 8px; border-radius: 4px; background: rgba(94, 59, 38, .2); overflow: hidden; }
.cook-prog i { display: block; height: 100%; width: 0; background: var(--bean-deep); border-radius: 4px; transition: width .15s; }
.cook-hint { margin: 0; min-height: 1.4em; text-align: center; font-size: 14.5px; color: var(--wood-deep); letter-spacing: .04em; }
.cook-done { display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center; animation: pop .4s; padding: 0 8px; }
.cook-done .dish { width: min(250px, 38vh); aspect-ratio: 1; }
.cook-done .dish svg { width: 100%; height: 100%; }
.cook-kicker { margin: 4px 0 0; font-size: 13px; letter-spacing: .3em; color: var(--bean-deep); }
.cook-done h3 { margin: 0; font-family: var(--font-hand); font-size: 28px; }
.cook-memo { margin: 2px 0 12px; max-width: 30em; font-size: 14.5px; line-height: 1.7; color: var(--ink-soft); }

/* ---------- 抽屜頁（相簿、料理簿、設定） ---------- */
#sheet { position: absolute; inset: 0 0 var(--nav-h) 0; z-index: 14; display: flex; flex-direction: column; background: var(--paper); animation: rise .25s ease-out; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 14px 10px 18px; border-bottom: 1px solid var(--line); }
.sheet-head h2 { margin: 0; font-family: var(--font-hand); font-size: 24px; letter-spacing: .1em; }
.sheet-head .iconbtn { box-shadow: none; }
.sheet-body { flex: 1; overflow-y: auto; padding: 14px 16px 24px; -webkit-overflow-scrolling: touch; }
.sheet-lede { margin: 0 0 14px; color: var(--ink-soft); font-size: 14px; line-height: 1.7; }
.tabs { display: flex; gap: 4px; padding: 4px; margin-bottom: 14px; background: rgba(138, 90, 59, .1); border-radius: 999px; }
.tabs button { flex: 1; border: 0; background: none; padding: 8px 4px; border-radius: 999px; font-size: 13.5px; color: var(--ink-soft); white-space: nowrap; }
.tabs button[aria-selected="true"] { background: var(--paper); color: var(--ink); box-shadow: 0 2px 6px rgba(74, 52, 40, .12); }
.mem-grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 10px; }
.mem { width: 100%; aspect-ratio: 4/5; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; padding: 8px; border-radius: 16px; border: 1.5px dashed rgba(138, 90, 59, .3); background: rgba(246, 235, 208, .6); }
.mem.got { border-style: solid; background: #FFF9EA; }
.mem svg { width: 70%; height: auto; }
.mem span { font-family: var(--font-hand); font-size: 15px; }
.mem .q { font-size: 30px; color: rgba(138, 90, 59, .4); }
.mem .small { font-family: var(--font-round); font-size: 11.5px; text-align: center; }
.recipes { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.rc { display: flex; gap: 12px; padding: 12px; border-radius: 18px; background: #FFF9EA; border: 1px solid var(--line); }
.rc-art { flex: none; width: 92px; height: 92px; display: grid; place-items: center; }
.rc-art svg { width: 100%; height: 100%; }
.rc.locked { opacity: .7; background: rgba(246, 235, 208, .5); border-style: dashed; }
.rc.locked .rc-art span { width: 76px; height: 76px; display: grid; place-items: center; border-radius: 50%; border: 2px dashed rgba(138, 90, 59, .35); font-size: 28px; color: rgba(138, 90, 59, .45); }
.rc-txt { min-width: 0; flex: 1; }
.rc-txt h3 { margin: 2px 0 4px; font-family: var(--font-hand); font-size: 20px; }
.rc-txt h3 small { font-size: 13px; color: var(--ink-soft); margin-left: 6px; }
.rc-txt p { margin: 0 0 6px; font-size: 13.5px; line-height: 1.65; }
.rc-txt .tip { color: var(--sage-deep); font-size: 14.5px; }
.quotes { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.qt { width: 100%; text-align: left; display: flex; flex-direction: column; gap: 2px; padding: 12px 14px; border-radius: 14px; border: 1px solid var(--line); background: #FFF9EA; }
.qt .tw { font-size: 19px; }
.basket { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.basket li { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-radius: 16px; background: #FFF9EA; border: 1px solid var(--line); }
.basket li > svg { width: 64px; height: 64px; flex: none; }
.basket h3 { margin: 0 0 6px; font-family: var(--font-hand); font-size: 19px; }
.basket h3 small { font-family: var(--font-round); font-size: 13px; color: var(--ink-soft); margin-left: 6px; }
.set { padding: 14px 0; border-bottom: 1px dashed var(--line); }
.set h3 { margin: 0 0 8px; font-family: var(--font-hand); font-size: 18px; }
.set .row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.set .small { margin: 0 0 8px; }
.seg { display: inline-flex; flex-wrap: wrap; gap: 4px; padding: 3px; border-radius: 14px; background: rgba(138, 90, 59, .1); }
.seg button { border: 0; background: none; padding: 7px 12px; border-radius: 11px; font-size: 13.5px; color: var(--ink-soft); }
.seg button[aria-checked="true"] { background: var(--paper); color: var(--ink); box-shadow: 0 2px 6px rgba(74, 52, 40, .12); }
.warn { color: #9A3A2C !important; margin-top: 8px !important; }
.about p { font-size: 14px; line-height: 1.75; margin: 0 0 8px; }

/* ---------- 標題 ---------- */
#title { position: absolute; inset: 0; z-index: 50; background: var(--cream); }
.title-art { position: absolute; inset: 0; }
.title-card {
  position: absolute; left: 16px; right: 16px; bottom: 24px; padding: 24px 22px 20px; text-align: center;
  background: rgba(251, 245, 228, .95); border-radius: 28px; box-shadow: var(--shadow);
  animation: rise .7s ease-out;
}
.title-kicker { margin: 0; font-size: 12.5px; letter-spacing: .32em; color: var(--bean-deep); }
.title-card h1 { margin: 6px 0 0; font-family: var(--font-hand); font-weight: 700; font-size: 46px; letter-spacing: .14em; line-height: 1.15; }
.title-en { margin: 2px 0 10px; font-size: 12px; letter-spacing: .28em; text-transform: uppercase; color: var(--ink-soft); }
.title-line { margin: 0 0 16px; font-family: var(--font-hand); font-size: 17px; color: var(--wood-deep); line-height: 1.6; text-wrap: balance; }
.title-note { margin: 12px 0 0; font-size: 12.5px; color: var(--ink-soft); }

@media (min-width: 480px) {
  #app { border-radius: 0; }
}
@media (max-height: 640px) {
  :root { --nav-h: 58px; }
  .title-card h1 { font-size: 38px; }
  #dlg-text { font-size: 17px; }
  .dlg-box { min-height: 112px; padding: 20px 18px 14px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

/* ---------- 華語字幕 ---------- */
#dlg-zh { margin: 4px 0 0; font-family: var(--font-round); font-size: 13.5px; line-height: 1.55; color: var(--ink-soft); animation: rise .25s ease-out; }
.zh { display: block; margin-top: 4px; font-family: var(--font-round); font-size: 13px; line-height: 1.55; color: var(--ink-soft); font-weight: 400; }
.letter-form .seg { justify-self: start; }

/* ---------- 故事暫停、寫批分類、匯出、料理「好矣」 ---------- */
.story-pause { position: absolute; top: calc(env(safe-area-inset-top, 0px) + 12px); right: 12px; z-index: 22; padding: 7px 14px; border-radius: 999px; border: 1px solid rgba(251, 245, 228, .5); background: rgba(40, 30, 25, .45); color: var(--paper); font-size: 13px; letter-spacing: .06em; }
.kinds { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.kinds .small { margin-right: 2px; }
.kinds button { border: 1px solid var(--line); background: #FFF9EA; border-radius: 999px; padding: 6px 12px; font-size: 13px; color: var(--ink-soft); }
.kinds button[aria-checked="true"] { background: var(--bean-deep); color: var(--paper); border-color: transparent; }
.row.between { display: flex; justify-content: space-between; align-items: center; }
.export { width: 100%; min-height: 120px; margin-bottom: 10px; padding: 10px; border-radius: 10px; border: 1px solid var(--line); font-size: 13px; -webkit-user-select: text; user-select: text; }
.cook-ok { position: absolute; left: 50%; bottom: 18px; transform: translateX(-50%); }
.tip-text .zh { margin-top: 2px; font-size: 12.5px; }

/* ---------- 我家的回憶 ---------- */
#sheet.top { z-index: 60; inset: 0; }
.fam { padding: 14px 0; border-bottom: 1px dashed var(--line); }
.fam h3 { margin: 0 0 8px; font-family: var(--font-hand); font-size: 19px; }
.fam .row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.fam-form { display: grid; gap: 10px; }
.fam-form label { display: grid; gap: 4px; font-size: 13.5px; color: var(--ink-soft); }
.fam-form input:not([type]), .fam-form input[maxlength], .fam-form textarea, .fam .row input {
  width: 100%; min-width: 0; padding: 10px 12px; border-radius: 12px; border: 1.5px solid rgba(138, 90, 59, .3); background: #FFFDF5;
  font-family: var(--font-hand); font-size: 17px; color: var(--ink); -webkit-user-select: text; user-select: text;
}
.fam .row input { flex: 1; }
.fam-form label.file { display: inline-flex; align-items: center; gap: 8px; justify-self: start; padding: 9px 16px; border-radius: 999px; background: #FFF9EA; border: 1.5px dashed rgba(138, 90, 59, .45); color: var(--wood); cursor: pointer; }
.fam-form label.file input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.fam-form label.check { display: flex; align-items: center; gap: 8px; color: var(--ink); }
.fam-form input[type="range"] { width: 100%; accent-color: var(--bean-deep); }
.fam .preview { margin: 0; padding: 8px 12px; border-radius: 12px; background: rgba(157, 176, 138, .18); color: var(--sage-deep); font-size: 13.5px; line-height: 1.6; }
.fam .preview:empty { display: none; }
.fam-have { margin-bottom: 10px; padding: 10px 12px; border-radius: 14px; background: #FFF9EA; border: 1px solid var(--line); }
.fam-have p { margin: 0 0 4px; }
.fam-have .tw { font-size: 18px; }
.fam-have small { font-family: var(--font-round); font-size: 12.5px; color: var(--ink-soft); }
.fam-photo { display: block; max-width: 100%; max-height: 220px; margin: 0 auto 8px; border-radius: 4px; box-shadow: 0 4px 14px rgba(74, 52, 40, .2); }
.fam-photo.big { max-height: 46vh; }
.badge { display: inline-block; margin-left: 8px; padding: 2px 8px; border-radius: 999px; background: rgba(169, 102, 91, .14); color: var(--bean-deep); font-family: var(--font-round); font-size: 11.5px; letter-spacing: .08em; vertical-align: middle; }
.fam-rc { background: #FDF3E7; border-color: rgba(169, 102, 91, .3); }
.title-card .linkbtn { margin-top: 6px; font-size: 13px; }
.title-card .linkbtn { display: block; margin: 4px auto 0; }
.dining li.paid { opacity: .92; background: #FBF7EE; border-style: dashed; }
.dining h3 .badge { font-size: 11px; }

/* ---------- 防誤觸、輸入時對話框移到上方 ---------- */
#dlg-choices.arming .choice, .card-actions.arming .btn { opacity: .55; pointer-events: none; }
#dlg-choices .choice, .card-actions .btn { transition: opacity .25s; }
#dlg.typing { justify-content: flex-start; padding-top: 84px; }
#dlg.typing .dlg-box { animation: none; }

/* ---------- 放到手機桌面 ---------- */
.install-hint {
  position: absolute; left: 14px; right: 14px; top: calc(env(safe-area-inset-top, 0px) + 14px); z-index: 2;
  display: grid; grid-template-columns: 44px 1fr; gap: 6px 12px; align-items: center;
  padding: 12px 14px 8px; background: rgba(251, 245, 228, .97); border-radius: 20px; box-shadow: var(--shadow);
  animation: rise .7s ease-out .4s both;
}
.install-hint img { border-radius: 11px; box-shadow: 0 1px 3px rgba(74, 52, 40, .25); }
.install-hint b { font-family: var(--font-hand); font-size: 17px; letter-spacing: .06em; color: var(--ink); }
.install-hint p { margin: 2px 0 0; font-size: 13px; line-height: 1.55; color: var(--ink-soft); }
.install-hint .ih-act { grid-column: 1 / -1; display: flex; justify-content: flex-end; align-items: center; gap: 6px; }
.install-hint .ih-act .linkbtn { font-size: 13px; }
.about h4 { margin: 12px 0 6px; font-size: 14px; color: var(--bean-deep); letter-spacing: .08em; }
.about .howto { margin: 0; padding-left: 1.2em; font-size: 14px; line-height: 1.75; }
.about .howto li { margin-bottom: 4px; }

/* ---------- 批箱 ---------- */
.today-quote { margin: 4px 0 14px; padding: 14px 16px 8px; border-radius: 18px; background: radial-gradient(circle at 12% 10%, rgba(217, 163, 154, .22), transparent 45%), radial-gradient(circle at 92% 92%, rgba(157, 176, 138, .26), transparent 50%), #FFF9EA; border: 1px solid var(--line); }
.today-quote .tq-kicker { margin: 0; font-size: 12.5px; letter-spacing: .12em; color: var(--bean-deep); }
.today-quote .quote-tw { font-size: 26px; margin: 8px 0 6px !important; }
.row.end { display: flex; justify-content: flex-end; }
.qt.unread { border-color: var(--bean); background: #FFF3E6; }
.qt .new { display: inline-block; margin-left: 6px; padding: 0 6px; border-radius: 8px; background: var(--bean-deep); color: #fff; font-size: 11px; font-weight: 700; line-height: 18px; }
.slip-card .letter { font-size: 18px; }

/* 名字輸入框：格線欄位允許縮小，輸入框和「好」按鈕都留在對話框裡 */
#dlg-choices { grid-template-columns: minmax(0, 1fr); }
#name-form { min-width: 0; }
#name-form input { width: 100%; }
#name-form .btn { flex: none; padding-left: 18px; padding-right: 18px; }
.card .steps, .modal-card .steps { margin: 10px 0 0; padding-left: 1.3em; text-align: left; line-height: 1.75; font-size: 15px; }
.install-hint .ih-act .btn { padding: 10px 22px; }

/* ---------- 阿嬤的拜託（左上角便條） ---------- */
.favor-note {
  position: absolute; top: calc(env(safe-area-inset-top, 0px) + 62px); left: 12px; z-index: 6; max-width: 172px;
  padding: 8px 12px 9px; text-align: left; font-size: 12.5px; line-height: 1.55; color: var(--ink);
  background: #FFF8E2; border: 1px solid rgba(138, 90, 59, .25); border-radius: 4px 14px 14px 14px;
  box-shadow: 0 3px 8px rgba(74, 52, 40, .15); transform: rotate(-1.5deg);
}
.favor-note b { display: block; margin-bottom: 2px; font-family: var(--font-hand); font-size: 14px; color: var(--bean-deep); }
.favor-note ul { margin: 0; padding: 0; list-style: none; }
.favor-note li::before { content: "□ "; }
.favor-note li.done { text-decoration: line-through; opacity: .6; }
.favor-note li.done::before { content: "☑ "; }
.favor-note .find { margin: 3px 0 0; color: #8A6234; font-size: 12px; }
.favors { list-style: none; padding: 0; margin: 0 0 12px; display: grid; gap: 8px; }
.favors li { display: flex; gap: 10px; align-items: center; justify-content: space-between; padding: 10px 12px; border-radius: 14px; background: #FFF9EA; border: 1px solid var(--line); }
.favors li.done { opacity: .6; }
.favors h3 { margin: 0; font-size: 15px; }
.favors h3 small { margin-left: 6px; color: #6F8A5F; font-size: 12px; }
.favors p { margin: 2px 0 0; }

/* ---------- 回憶首頁 ---------- */
.hub { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.hub-tile { width: 100%; height: 100%; display: grid; grid-template-columns: 48px minmax(0, 1fr); column-gap: 10px; align-content: center; text-align: left; padding: 10px 10px; border-radius: 16px; border: 1px solid var(--line); background: #FFF9EA; color: var(--ink); }
.hub-ic { grid-row: 1 / span 3; width: 48px; height: 48px; align-self: center; }
.hub-ic svg { width: 100%; height: 100%; }
.hub-tile b { font-family: var(--font-hand); font-size: 16px; }
.hub-val { font-size: 13px; color: var(--bean-deep); }
.hub-sub { font-size: 11.5px; color: var(--ink-soft); line-height: 1.35; }
.back-hub { display: inline-block; margin: 0 0 6px; }
.qt.locked { opacity: .55; }
.cal-head { display: flex; justify-content: space-between; align-items: center; margin: 4px 0 8px; }
.cal-head b { font-family: var(--font-hand); font-size: 17px; }
.cal { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.cal li { position: relative; aspect-ratio: 1; padding: 2px 4px; border-radius: 8px; background: #FFF9EA; border: 1px solid var(--line); font-size: 11px; color: var(--ink-soft); }
.cal li.wd { aspect-ratio: auto; background: none; border: 0; text-align: center; font-weight: 700; }
.cal li:empty { background: none; border: 0; }
.cal li.today { border: 2px solid var(--bean-deep); }
.stp { position: absolute; inset: 12px 0 0 0; display: grid; place-items: center; font-style: normal; font-family: var(--font-hand); font-size: 15px; color: #C9554A; }
.stp.t { color: #E87A9A; font-size: 18px; }
.stp.f { color: #C98A2A; }
.cal-pic { display: flex; gap: 12px; align-items: center; margin-top: 12px; padding: 10px; border-radius: 14px; background: #FFF9EA; border: 1px dashed var(--line); }
.cal-pic svg { width: 64px; height: 64px; flex: none; filter: grayscale(1); opacity: .35; }
.cal-pic.got svg { filter: none; opacity: 1; }
.cal-pic p { margin: 0; font-size: 13px; }
.progress { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.progress > li { display: flex; flex-direction: column; gap: 4px; padding: 12px 14px; border-radius: 14px; background: #FFF9EA; border: 1px solid var(--line); }
.progress b { font-family: var(--font-hand); font-size: 16px; }
.progress span { font-size: 13.5px; }
.progress small { font-size: 12px; color: var(--ink-soft); }
.tricks, .crops { display: flex; flex-wrap: wrap; gap: 6px; list-style: none; padding: 0; margin: 4px 0 0; }
.tricks i, .crops li { font-style: normal; padding: 2px 10px; border-radius: 999px; background: #EEE6D4; color: var(--ink-soft); font-size: 12.5px; }
.tricks i.got { background: var(--bean); color: #fff; }
.crops li.got { background: #9DB08A; color: #fff; }
.crops small { margin-left: 4px; opacity: .85; }

.lesson { margin: 4px 0 14px; padding: 12px 14px; border-radius: 16px; background: #FFF3E0; border: 1px solid rgba(201, 138, 42, .35); }
.lesson b { display: block; font-family: var(--font-hand); font-size: 19px; }
.lesson b small { margin-left: 8px; font-size: 13px; color: var(--ink-soft); }
.lesson p { margin: 4px 0 8px; }
