[hidden] { display: none !important; }
/* Layout: one column, phone first. Header (date + greeting, search, menu), view switch (按日期 / 按事件 / 急的).
   Date view: today is the hero card (late tasks folded in on top), then compact summary rows for the other ranges that expand in place.
   Event view: one section per event with progress and its next tasks. Add box docked at the bottom with its settings shown as chips above the input.
   Colour roles: terracotta = actions and links, fountain-pen blue = 重要, red = 晚了, green = 做完. Warm paper, with a warm night variant. */
:root {
  color-scheme: light;
  --bg: #F4EFE6; --press: rgba(43,33,24,.08); --bg-fade: rgba(244,239,230,0); --surface: #FFFDF8; --surface-2: #EDE6D8; --text: #2B2118; --muted: #6B5E4E; --faint: #736655; --border: #E2D9C8;
  --primary: #9C4E1B; --on-primary: #FFFFFF; --late-bg: #F6EAD3; --late-fg: #7E4312; --late-line: #E8CFA3; --hot: #B23A3A;
  --done: #3F7A52; --imp: #2D5BA3; --imp-soft: #E2EAF6; --sel-on: #F1E2D3; --scrim: rgba(20,16,12,.4); --shadow: rgba(43,33,24,.14);
  --toast-bg: #2B2118; --toast-fg: #FFFDF8; --toast-link: #F1C9A0; --shine: rgba(255,255,255,.6);
  --ring: #85715A; --ring-low: #8F7D63; --seg-on: #FFFFFF; --raised: #FFFFFF; --raised-line: #918370; --field-line: #918370; --raised-shadow: rgba(43,33,24,.28);
  --f-display: "Noto Serif TC", "Songti TC", Georgia, serif;
  --f-body: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", sans-serif;
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) {
  color-scheme: dark;
  --bg: #1B1612; --press: rgba(241,232,218,.09); --bg-fade: rgba(27,22,18,0); --surface: #251E18; --surface-2: #30271F; --text: #F1E8DA; --muted: #B5A690; --faint: #A39480; --border: #3B3027;
  --primary: #E39C5E; --on-primary: #1B1612; --late-bg: #352616; --late-fg: #F2BC80; --late-line: #57401F; --hot: #F08A7A;
  --done: #7CC08F; --imp: #8FB4F2; --imp-soft: #23314A; --sel-on: #4D3726; --scrim: rgba(0,0,0,.55); --shadow: rgba(0,0,0,.45);
  --toast-bg: #F1E8DA; --toast-fg: #1B1612; --toast-link: #9C4E1B; --shine: rgba(255,255,255,.35);
  --ring: #B3A28A; --ring-low: #9A8A74; --seg-on: #46382C; --raised: #3A2F26; --raised-line: #80705D; --field-line: #80705D; --raised-shadow: rgba(0,0,0,.7);
} }
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #1B1612; --press: rgba(241,232,218,.09); --bg-fade: rgba(27,22,18,0); --surface: #251E18; --surface-2: #30271F; --text: #F1E8DA; --muted: #B5A690; --faint: #A39480; --border: #3B3027;
  --primary: #E39C5E; --on-primary: #1B1612; --late-bg: #352616; --late-fg: #F2BC80; --late-line: #57401F; --hot: #F08A7A;
  --done: #7CC08F; --imp: #8FB4F2; --imp-soft: #23314A; --sel-on: #4D3726; --scrim: rgba(0,0,0,.55); --shadow: rgba(0,0,0,.45);
  --toast-bg: #F1E8DA; --toast-fg: #1B1612; --toast-link: #9C4E1B; --shine: rgba(255,255,255,.35);
  --ring: #B3A28A; --ring-low: #9A8A74; --seg-on: #46382C; --raised: #3A2F26; --raised-line: #80705D; --field-line: #80705D; --raised-shadow: rgba(0,0,0,.7);
}
* { box-sizing: border-box; }
html { scrollbar-color: var(--border) transparent; }
body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--f-body); font-size: 15px; line-height: 1.5;
  padding-top: calc(28px + env(safe-area-inset-top, 0px)); padding-bottom: 140px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px));
  caret-color: var(--primary); accent-color: var(--primary); -webkit-tap-highlight-color: transparent; }
::selection { background: var(--sel-on); color: var(--text); }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; }
svg { flex: none; }
.screen { max-width: 440px; margin: 0 auto; display: flex; flex-direction: column; gap: var(--s4); }

/* header */
.top { display: flex; align-items: center; gap: var(--s1); }
.top .hi { flex: 1; min-width: 0; }
.date { margin: 0; font-size: 14px; font-weight: 500; letter-spacing: .02em; color: var(--text); opacity: .78; }
h1.hello { font-size: 21px; font-weight: 500; margin: 0; line-height: 1.4; }
.iconbtn { width: 44px; height: 44px; border-radius: 12px; border: 0; background: none; display: grid; place-items: center; color: var(--muted); padding: 0; }
.iconbtn[aria-expanded="true"] { background: var(--surface-2); color: var(--text); }

/* search panel */
.searchp { display: flex; flex-direction: column; gap: var(--s2); }
.sbox { display: flex; align-items: center; gap: var(--s2); border: 1px solid var(--field-line); background: var(--surface); border-radius: 12px; padding: 0 var(--s3); min-height: 44px; color: var(--muted); }
.sbox input { flex: 1; min-width: 0; border: 0; background: none; font-size: 16px; padding: 8px 0; color: var(--text); }
.sbox input:focus { outline: none; }
.sbox:focus-within { border-color: var(--primary); }
.srow { display: flex; gap: var(--s2); align-items: center; }
.srow .selw { flex: 1; }
.sbox .sx { width: 44px; height: 44px; margin-right: -10px; border: 0; background: none; color: var(--muted); display: grid; place-items: center; border-radius: 50%; flex: none; }
.linkbtn { border: 0; background: none; color: var(--primary); font-size: 14px; min-height: 44px; padding: 0 4px; white-space: nowrap; }

/* view switch */
.seg { display: flex; background: var(--surface-2); border-radius: 12px; padding: 3px; gap: 2px; }
.seg button { flex: 1; border: 0; background: none; color: var(--muted); border-radius: 9px; min-height: 44px; font-size: 15px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.seg button[aria-pressed="true"] { background: var(--seg-on); color: var(--text); font-weight: 700; box-shadow: 0 1px 2px var(--shadow), 0 0 0 1px var(--field-line); }

/* today hero */
.hero { background: var(--surface); border: 1px solid var(--border); border-radius: 20px; padding: var(--s4) var(--s4) var(--s2); box-shadow: 0 2px 10px var(--shadow); }
.hero-h { display: flex; align-items: baseline; gap: var(--s3); }
.hero-h h2 { font-family: var(--f-display); font-size: 26px; margin: 0; line-height: 1.2; }
.hero-h .prog { margin-left: auto; font-size: 14px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.hero-h .prog b { color: var(--done); font-size: 17px; }
.pbar { height: 4px; border-radius: 4px; background: var(--surface-2); overflow: hidden; margin: var(--s3) 0 var(--s1); }
.pbar i { display: block; height: 100%; background: var(--done); border-radius: 4px; transition: width .35s cubic-bezier(.2,.8,.2,1); }
.task.leaving { overflow: hidden; transition: height .22s ease, opacity .22s ease; }
.task.gone { opacity: 0; }
.lateact { display: flex; align-items: center; gap: var(--s2); padding: var(--s2) 0 var(--s2); border-top: 1px solid var(--late-line); margin-top: var(--s1); }
.lpill { position: relative; flex: 1; min-width: 0; display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 0 12px;
  border: 1px solid var(--late-line); border-radius: 999px; background: var(--surface); color: var(--late-fg); font-size: 14px; font-weight: 700; white-space: nowrap; }
.lpill select { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; font-size: 16px; cursor: pointer; }
.lpill:focus-within, .lpill:focus-visible { outline: 3px solid var(--primary); outline-offset: 1px; }
.lpill:active { background: var(--late-bg); }
.lateband .newrow { margin-bottom: var(--s2); }
.resched { position: relative; height: 44px; flex: none; display: inline-flex; align-items: center; gap: 4px; align-self: center; margin-right: -6px; padding: 0 8px; color: var(--late-fg); border-radius: 12px; font-size: 13.5px; font-weight: 600; white-space: nowrap; }
.resched select { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; font-size: 16px; cursor: pointer; }
.resched:focus-within { outline: 3px solid var(--primary); outline-offset: -2px; }
.seg .hotdot { width: 8px; height: 8px; border-radius: 50%; background: var(--hot); }
.seg .hotdot.imp { background: var(--imp); }
.toastl { position: fixed; left: 0; right: 0; bottom: 120px; z-index: 30; display: flex; justify-content: center; pointer-events: none; padding: 0 16px; }
.toastl.top { bottom: auto !important; top: calc(env(safe-area-inset-top, 0px) + 16px); }
.toastl .toast { pointer-events: auto; max-width: 100%; }
/* just after a toast goes: a strip where it was swallows a late tap */
.toastl.grace::before { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 56px; pointer-events: auto; }
.toast span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* late tasks: a tinted strip running edge to edge inside the today card, not a card of its own */
.lateband { background: var(--late-bg); border-block: 1px solid var(--late-line); padding: var(--s2) var(--s4) var(--s1); margin: var(--s3) calc(-1 * var(--s4)) var(--s1); }
.hotlist .lateband { margin: 0; border: 1px solid var(--late-line); border-radius: 16px; }
.lateband h3 { margin: 0; font-size: 14px; color: var(--late-fg); font-weight: 700; }
.lateband .task + .task { border-top-color: var(--late-line); }
.empty { color: var(--muted); font-size: 14px; margin: var(--s2) 0 var(--s3); }
.morebtn { border: 0; background: none; color: var(--primary); font-size: 14px; font-weight: 700; min-height: 44px; padding: 0; }
/* 快到了: repeating things coming up soon, a quiet strip under today's list */
.meta .soon { color: var(--muted); font-weight: 600; font-variant-numeric: tabular-nums; }
.rnote { margin: var(--s2) 0 0; font-size: 13.5px; color: var(--muted); }
/* 更多設定 in the add box: the two extra repeat settings, folded, with what they are set to */
.moreset { display: flex; align-items: center; gap: var(--s2); width: 100%; min-height: 44px; border: 0; background: none; padding: 0; color: var(--primary); font-weight: 700; font-size: 14px; text-align: left; }
.moreset small { flex: 1; min-width: 0; color: var(--muted); font-weight: 400; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.moreset .chev { color: var(--muted); }
/* the edit sheet keeps its buttons in reach however long it gets */
.sheet > .btnrow:last-child { position: sticky; bottom: calc(-20px - env(safe-area-inset-bottom, 0px)); margin: 0 -20px calc(-20px - env(safe-area-inset-bottom, 0px)); padding: var(--s3) 20px calc(20px + env(safe-area-inset-bottom, 0px)); background: var(--surface); border-top: 1px solid var(--border); z-index: 1; }
/* 快到了: its own quiet list between today and 接下來 */
.soonsec { margin-top: var(--s5); display: flex; flex-direction: column; gap: var(--s2); }
.soonbox { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 0 var(--s4); }
.evempty { padding: var(--s2) var(--s1); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
/* the week look-back, at the foot of the today card */
.herofoot .weekbtn { margin-left: auto; display: inline-flex; align-items: center; gap: 2px; }
.herofoot .weekbtn + .weekbtn { margin-left: 0; }
.herofoot .weekbtn .chev { width: 14px; height: 14px; }
.herofoot { display: flex; flex-wrap: wrap; align-items: center; gap: 0 var(--s3); border-top: 1px solid var(--border); margin-top: var(--s1); }
.herofoot .donebtn { color: var(--done); display: inline-flex; align-items: center; gap: 2px; }
.herofoot .donebtn .chev { width: 14px; height: 14px; transform: rotate(90deg); }
.herofoot .donebtn[aria-expanded="true"] .chev { transform: rotate(-90deg); }

/* task row */
.task { display: flex; align-items: flex-start; gap: var(--s1); border-top: 1px solid var(--border); }
.task:first-child, h3 + .task, h4 + .task, .lateband + .task { border-top: 0; }
.ck { width: 44px; height: 44px; margin-left: -10px; margin-top: 2px; flex: none; border: 0; background: none; padding: 0; display: grid; place-items: center; color: var(--on-primary); }
.ck i { width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--ring); display: grid; place-items: center; }
.ck.p-high i { border-color: var(--imp); }
.imp.ti { margin-right: 6px; font-size: 13px; vertical-align: 1px; }
.task.low .txt strong { color: var(--muted); }
/* countdown rows that are only there to be noticed: keep the column, drop the ring */
.ck.none { color: var(--ring-low); }
.ck.none svg { width: 18px; height: 18px; }
.ck.done i { background: var(--done); border: 2px solid var(--done); box-shadow: none; }
.ring { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--ring); display: inline-block; flex: none; }
.ring.p-high { border-color: var(--imp); }
.ring.p-low { border-color: var(--ring-low); }
.tbody { flex: 1; min-width: 0; display: flex; flex-direction: column; padding: 0; }
.txt { text-align: left; background: none; border: 0; padding: 11px 0; min-height: 44px; display: flex; flex-direction: column; justify-content: center; gap: 4px; }
.txt strong { font-weight: 600; line-height: 1.45; overflow-wrap: anywhere; }
.task.done .txt strong { color: var(--muted); text-decoration: line-through; }
/* a missed repeating turn (沒勾): faded, not crossed out, empty ring */
.task.missed .txt strong { color: var(--muted); }
.task.missed .ck i { border-style: dashed; border-color: var(--ring-low); }
/* plain words, not a chip: the tag only says what happened (the dashed ring is the 沒勾 mark) */
.missedtag { color: var(--muted); font-weight: 700; }
.misshint { color: var(--muted); }
.meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; font-size: 13.5px; color: var(--muted); }
.meta.g2 { column-gap: 14px; }
/* on one line the two groups are different sizes: line them up on the text, not the middle */
.meta.g2:not(.stack) { align-items: baseline; }
/* four or more things: the time on one line, where it belongs on the next */
.meta.stack { flex-direction: column; align-items: flex-start; row-gap: 3px; }
.meta .mg { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; min-width: 0; max-width: 100%; }
.meta .hot { color: var(--hot); font-weight: 700; }
/* event and category: a small mark and the name, the same way the repeat rule is written.
   where it belongs matters least, so it sits a step back: a size smaller and a shade lighter than the time */
.evtag, .cattag { display: inline-flex; align-items: center; gap: 3px; min-width: 0; max-width: 100%; font-size: 12px; color: var(--faint); }
.evtag svg, .cattag svg { width: 11.5px; height: 11.5px; }
.evtag svg, .cattag svg { flex: none; }
/* long names end in … instead of folding the row; the full name is still read out and shown when the task is opened */
.evtag .cn, .cattag .cn { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.evtag .cn { max-width: 11em; }
.cattag .cn { max-width: 8em; }
/* the event + category group stays on one line; both names shorten together, each keeping about four characters */
.meta .mg.own { flex-wrap: nowrap; }
.mg.own > .evtag, .mg.own > .cattag { flex: 0 1 auto; min-width: calc(15px + 5em); }
.imp { background: var(--imp-soft); color: var(--imp); border-radius: 6px; padding: 0 7px; line-height: 1.7; font-weight: 700; }
.lowtxt { color: var(--muted); }
.hint { display: flex; align-items: center; gap: var(--s2); background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: var(--s2) var(--s2) var(--s2) var(--s4); font-size: 14px; }
.hint p { flex: 1; margin: 0; min-width: 0; }
.hint .linkbtn { font-weight: 700; }
.hint .hx { width: 44px; height: 44px; flex: none; border: 0; background: none; color: var(--muted); display: grid; place-items: center; border-radius: 50%; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 1px solid var(--border); background: var(--surface-2); color: var(--muted); border-radius: 999px; min-height: 44px; padding: 0 14px; }
.chip[aria-pressed="true"] { background: var(--sel-on); color: var(--primary); border-color: var(--primary); font-weight: 700; }
.dpanel .ok { align-self: flex-end; border: 1px solid var(--field-line); background: none; color: var(--text); font-weight: 500; border-radius: 12px; min-height: 44px; padding: 0 20px; }
.icons { gap: 2px; }
.icons .ib { flex: none; min-width: 48px; height: 48px; padding: 0 6px; gap: 4px; border-radius: 10px; }
.icons .ib svg { width: 18px; height: 18px; }
.icons .ib small { font-size: 12px; font-weight: 500; }
.repm { display: inline-flex; align-items: center; gap: 3px; }
.pri3.days button { padding: 0; min-width: 0; }
.field:has(.pri3.days) { grid-template-columns: 1fr; gap: var(--s2); }
/* the edit sheet's day chips get the full width, label above, so they sit in one or two rows instead of three */
.sheet .field:has(> .fc > .chips) { grid-template-columns: 1fr; gap: var(--s2); }
.dpanel .field { align-items: start; }
.dpanel .field .fl { padding-top: 13px; }
.dpanel .field:has(.pri3.days) .fl { padding-top: 0; }

/* other ranges: summary rows */
.nextsec { margin-top: var(--s5); display: flex; flex-direction: column; gap: var(--s2); }
.sech { margin: 0 var(--s1); font-size: 17px; font-weight: 700; color: var(--muted); }
.ranges { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; overflow: hidden; }
.range + .range { border-top: 1px solid var(--border); }
.rhead { width: 100%; display: flex; align-items: center; gap: var(--s3); border: 0; background: none; text-align: left; min-height: 60px; padding: 0 var(--s3) 0 var(--s4); }
.rhead .rl { font-weight: 700; flex: none; min-width: 5.2em; }
.rhead .rc { color: var(--muted); font-size: 14px; flex: none; font-variant-numeric: tabular-nums; }
.rhead .rp { flex: 1; min-width: 0; color: var(--muted); font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rhead .chev { color: var(--muted); } /* turned by GSAP when a fold opens or closes; a CSS transition here would drag behind it */
.rhead[aria-expanded="true"] .chev { transform: rotate(90deg); }
.rhead:disabled { cursor: default; }
.rbody { padding: 0 var(--s4) var(--s1); border-top: 1px dashed var(--border); }

/* event view */
.evlist, .hotlist { display: flex; flex-direction: column; gap: var(--s5); }
.evlist { gap: var(--s6); }
.hotlist { gap: var(--s4); }
.hotlist .lead { font-size: 13.5px; color: var(--muted); margin: 0 var(--s1); }
.evsec { display: flex; flex-direction: column; gap: var(--s2); }
.evh { display: flex; align-items: center; gap: var(--s2); padding: 0 var(--s1); }
.evh h2 { font-family: var(--f-display); font-size: 19px; margin: 0; line-height: 1.3; flex: 1; min-width: 0; overflow-wrap: anywhere; }
.evh h2.plain { font-family: var(--f-body); font-size: 16px; color: var(--muted); }
.evh .cnt { font-size: 14px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.evh .iconbtn { color: var(--primary); }
/* an event's progress line: the count, then its bar taking the rest of the width. The count reads the same with or
   without something done; once there is, it is a link (the accent colour, like 更多 links) to the record */
/* the progress line sits close under its title (it is the event's own status), then the box */
.evprog { display: flex; align-items: center; gap: var(--s3); padding: 0 var(--s1); min-height: 24px; margin-top: calc(-1 * var(--s2)); }
.evprog + .evbox { margin-top: var(--s1); }
.evprog .cnt { font-size: 14px; font-weight: 700; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.evprog .pbar { flex: 1; margin: 0; }
.evprog .cntbtn { border: 0; background: none; padding: 0; min-height: 44px; margin: -10px 0; display: inline-flex; align-items: center; gap: 2px; color: var(--primary); }
.evprog .cnt + .cntbtn { margin-left: calc(-1 * var(--s1)); }
.evprog .cnt + .cntbtn::before { content: "·"; color: var(--muted); margin-right: var(--s2); font-weight: 400; }
/* 做完的事件: finished events as small cards to look back on */
.memos { display: flex; flex-direction: column; gap: var(--s2); }
.memo { display: grid; grid-template-columns: 1fr auto; align-items: center; column-gap: var(--s2); width: 100%; text-align: left; border: 1px solid var(--border); background: var(--surface); border-radius: 16px; padding: var(--s3) var(--s3) var(--s3) var(--s4); min-height: 64px; }
.memo .mt { display: flex; align-items: center; gap: var(--s2); min-width: 0; color: var(--done); }
.memo .mn { font-family: var(--f-display); font-size: 17px; font-weight: 700; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.memo .ms { grid-column: 1; font-size: 13.5px; color: var(--muted); font-variant-numeric: tabular-nums; padding-left: 24px; }
.memo .chev { grid-column: 2; grid-row: 1 / span 2; color: var(--muted); }
.evprog .cntbtn .chev { width: 14px; height: 14px; }

.evbox { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 0 var(--s4); }
.evbox .empty { margin: var(--s3) 0; }
.hday { font-size: 13.5px; font-weight: 700; color: var(--muted); margin: var(--s3) 0 0; }

/* native dropdowns, one style everywhere */
.selw { position: relative; min-width: 0; display: block; }
.selw > svg { position: absolute; top: 50%; transform: translateY(-50%); pointer-events: none; color: var(--muted); }
.selw > .chv { right: 11px; }
.selw > .lead { left: 12px; }
.sel { appearance: none; -webkit-appearance: none; width: 100%; min-width: 0; min-height: 44px; border: 1px solid transparent; border-radius: 12px; padding: 0 30px 0 12px; font-size: 16px;
  background: var(--surface-2); color: var(--muted); text-overflow: ellipsis; white-space: nowrap; overflow: hidden; }
.sel.on { color: var(--text); font-weight: 500; }
.selw.hasicon .sel { padding-left: 36px; }
.sel.on ~ .lead { color: var(--text); }
.datein, .newrow input { width: 100%; min-width: 0; min-height: 44px; border: 1px solid var(--field-line); border-radius: 12px; padding: 0 12px; font-size: 16px; background: var(--surface); }
.datein:focus, .newrow input:focus { outline: none; border-color: var(--primary); }
.newrow { display: flex; gap: 6px; }
.newrow input { flex: 1; }
.newrow button { border: 0; border-radius: 12px; min-height: 44px; padding: 0 12px; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.newrow button.go { background: var(--primary); color: var(--on-primary); font-weight: 700; }

/* bottom dock */
.dock { position: fixed; left: 0; right: 0; bottom: 0; z-index: 5;
  padding: 20px max(16px, env(safe-area-inset-right, 0px)) calc(12px + env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px));
  background: linear-gradient(to bottom, var(--bg-fade), var(--bg) 20px); pointer-events: none; }
.dock-in { max-width: 440px; margin: 0 auto; display: flex; flex-direction: column; gap: var(--s2); pointer-events: auto; }
.dpanel { background: var(--raised); border: 1px solid var(--raised-line); border-radius: 14px; padding: var(--s3); display: flex; flex-direction: column; gap: var(--s2); box-shadow: 0 6px 22px var(--raised-shadow); }
/* never taller than about half the screen: with the phone keyboard up, the top of the panel must stay reachable, so it scrolls inside */
.dpanel { max-height: min(52dvh, 460px); overflow-y: auto; overscroll-behavior: contain; }
.dpanel .datein, .dpanel .notein, .dpanel .newrow input { background: var(--surface); }
.dpanel .lab, .sheet .lab { margin: 0; font-size: 13.5px; color: var(--muted); }
.add { background: var(--raised); border: 1px solid var(--raised-line); border-radius: 16px; padding: 6px; box-shadow: 0 6px 22px var(--raised-shadow); }
.add:focus-within { border-color: var(--primary); }
/* row 1: the input on its own, full width. row 2 (only while adding): four labelled settings + 加入 */
.addrow { display: flex; padding: 0 var(--s2); }
.addrow input { flex: 1; min-width: 0; border: 0; background: none; font-size: 16px; padding: 10px 0; min-height: 44px; }
.addrow input:focus { outline: none; }
.dtools { display: flex; align-items: center; gap: var(--s2); margin-top: 2px; padding-top: 4px; border-top: 1px solid var(--raised-line); }
.icons { display: flex; align-items: center; gap: 0; flex: 1; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.icons::-webkit-scrollbar { display: none; }
.ib { position: relative; min-width: 44px; height: 52px; padding: 0 2px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; color: var(--muted); border-radius: 10px; flex: none; }
.ib small { font-size: 13px; line-height: 1; white-space: nowrap; }
button.ib { border: 0; background: none; font: inherit; cursor: pointer; }
@media (max-width: 360px) { .ib { min-width: 40px; } }
.notein { flex: none; width: 100%; min-height: 76px; border: 1px solid var(--field-line); border-radius: 12px; padding: 10px 12px; font-size: 16px; line-height: 1.5;
  background: var(--surface); color: var(--text); resize: vertical; font-family: inherit; }
.notein:focus { outline: none; border-color: var(--primary); }
.notein::placeholder, .ttl::placeholder, #newText::placeholder, .sbox input::placeholder { color: var(--muted); opacity: 1; }
.sbox input::-webkit-search-cancel-button { -webkit-appearance: none; appearance: none; display: none; }
/* note preview: one muted line under the title, cut with … when long */
.npv { display: flex; align-items: center; gap: 5px; min-width: 0; font-size: 13.5px; color: var(--muted); }
.npv svg { flex: none; }
.npv span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.meta .tm { color: var(--text); font-weight: 500; font-variant-numeric: tabular-nums; }
.ib input[type="time"] { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; font-size: 16px; cursor: pointer; }
.timerow { display: flex; gap: 6px; }
.timerow .datein { flex: 1; }
.timerow button { border: 0; border-radius: 12px; min-height: 44px; padding: 0 12px; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.ib select { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; font-size: 16px; cursor: pointer; }
.ib:focus-within { outline: 3px solid var(--primary); outline-offset: -3px; }
.ib.on { color: var(--primary); background: var(--sel-on); }
.ib.imp { color: var(--imp); background: var(--imp-soft); }
.csum { display: flex; align-items: center; gap: var(--s2); margin-top: 4px; padding: 0 0 0 var(--s3); border-top: 1px solid var(--raised-line); font-size: 13.5px; color: var(--text); }
.csum span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.csum button { width: 44px; height: 44px; flex: none; border: 0; background: none; color: var(--muted); display: grid; place-items: center; }
.dtools button[type="submit"] { border: 0; background: var(--primary); color: var(--on-primary); font-weight: 700; font-size: 14px; border-radius: 10px; min-height: 44px; padding: 0 14px; flex: none; }
.toast { align-self: center; margin: 0; display: flex; align-items: center; gap: 4px; background: var(--toast-bg); color: var(--toast-fg); border-radius: 999px; padding: 0 6px 0 18px; min-height: 44px; font-size: 14px; box-shadow: 0 4px 14px var(--shadow); }
.toast:not(:has(button)) { padding-right: 18px; }
.toast button { border: 0; background: none; color: var(--toast-link); font-weight: 700; min-height: 44px; padding: 0 12px; }

/* sheets */
.scrim { position: fixed; inset: 0; background: var(--scrim); z-index: 20; }
.sheet { position: fixed; left: 50%; bottom: 0; transform: translateX(-50%); width: min(520px, 100%); z-index: 21; background: var(--surface); border-radius: 20px 20px 0 0;
  padding: var(--s5) 20px calc(20px + env(safe-area-inset-bottom, 0px)); display: flex; flex-direction: column; gap: var(--s4); max-height: 88vh; overflow-y: auto; box-shadow: 0 -6px 30px var(--shadow); }
.sheet:focus { outline: none; }
.sheet { overscroll-behavior: contain; }
.sheet.tall { height: 85vh; padding-top: 0; }
.shead { position: sticky; top: 0; z-index: 1; display: flex; align-items: center; justify-content: space-between; gap: var(--s3); background: var(--surface); padding: 20px 0 var(--s3); border-bottom: 1px solid var(--border); }
.shead .ok { border: 0; background: var(--primary); color: var(--on-primary); font-weight: 700; border-radius: 12px; min-height: 44px; padding: 0 20px; flex: none; }
.shead .note { margin-top: 2px; }
.shead.col { flex-direction: column; align-items: stretch; gap: var(--s2); }
.shrow { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); }
.hfil { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s2); }
html.locked, html.locked body { overflow: hidden; }
.sheet h3 { font-family: var(--f-display); font-size: 19px; margin: 0; }
.sheet h3.menulogo { display: flex; justify-content: center; padding: 10px 0 18px; margin-bottom: 4px; border-bottom: 1px solid var(--border); }
.menulogo img { display: block; height: 60px; width: auto; max-width: 100%; }
.sheet .ttl { width: 100%; border: 0; border-bottom: 1px solid var(--field-line); background: none; font-size: 18px; padding: 6px 0 10px; }
.sheet .ttl:focus { outline: none; border-bottom-color: var(--primary); }
.sheet .note { font-size: 13.5px; color: var(--muted); margin: 0; }
.field { display: grid; grid-template-columns: 5em 1fr; align-items: center; gap: var(--s3); }
.field .fl { font-size: 14px; color: var(--muted); }
.field .fc { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.pri3 { display: flex; background: var(--surface-2); border-radius: 12px; padding: 3px; gap: 2px; }
.pri3 button { flex: 1; border: 0; background: none; border-radius: 9px; color: var(--muted); min-height: 44px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 0 4px; white-space: nowrap; }
.pri3 button[aria-pressed="true"] { background: var(--seg-on); color: var(--text); font-weight: 700; box-shadow: 0 1px 2px var(--shadow), 0 0 0 1px var(--field-line); }
.pri3 button[aria-pressed="true"][data-v="high"] { color: var(--imp); }
.pri3 button[aria-pressed="true"] .ring.p-high { box-shadow: inset 0 0 0 2.5px var(--seg-on); }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 13.5px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend.gl { flex-direction: column; gap: 6px; }
.legend.gl span { align-items: flex-start; }
.legend.gl svg { flex: none; margin-top: 4px; }
.menu { border: 1px solid var(--border); border-radius: 14px; overflow: hidden; }
.menu > * { width: 100%; display: flex; align-items: center; gap: 10px; border: 0; background: none; text-align: left; min-height: 52px; padding: 0 var(--s4); }
.menu > * + * { border-top: 1px solid var(--border); }
.menu span { flex: 1; }
.menu small { color: var(--muted); font-size: 13px; }
.mgsec { display: flex; flex-direction: column; gap: var(--s2); }
.mgsec h4 { margin: 0; font-size: 14px; color: var(--muted); font-weight: 700; display: flex; align-items: center; gap: 5px; }
.mgrow { display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap; }
.mgrow input { flex: 1; min-width: 0; border: 1px solid var(--field-line); border-radius: 10px; min-height: 44px; padding: 0 10px; font-size: 16px; background: var(--surface); }
.mgrow input:focus { outline: none; border-color: var(--primary); }
.mgrow .cnt { font-size: 13.5px; color: var(--muted); white-space: nowrap; }
/* 刪除 stays grey in the list; only the 確定刪除 that follows is red */
.mgrow .x { border: 0; background: none; color: var(--muted); min-height: 44px; padding: 0 12px; font-size: 14px; }
.mgrow .x[data-mdel] { color: var(--hot); font-weight: 700; }
.mgrow .x.soft { color: var(--muted); }
.mgrow .warn { flex-basis: 100%; font-size: 13.5px; color: var(--hot); margin: 0; }
.mgadd { align-self: flex-start; border: 1px dashed var(--field-line); background: none; color: var(--muted); border-radius: 999px; min-height: 44px; padding: 0 14px; font-size: 14px; }
.btnrow { display: flex; align-items: center; gap: var(--s2); }
.btnrow .del { border: 0; background: none; color: var(--hot); min-height: 44px; padding: 0 12px; }
.btnrow .cancel { margin-left: auto; border: 1px solid var(--field-line); background: none; border-radius: 12px; min-height: 44px; padding: 0 16px; color: var(--muted); }
.btnrow .cancel[data-delone] { margin-left: 0; }
.btnrow .ok { border: 0; background: var(--primary); color: var(--on-primary); font-weight: 700; border-radius: 12px; min-height: 44px; padding: 0 20px; }
.btnrow .ok:only-child, .btnrow .del + .ok { margin-left: auto; }
/* 只改這次 / 以後都改: asked when a repeating task is moved off its rule in the edit sheet */
.dateask { display: grid; gap: var(--s2); background: var(--surface-2); border-radius: 14px; padding: var(--s3); }
.dateask .btnrow { flex-wrap: wrap; }
.dateask .btnrow button { margin-left: 0; flex: 1 1 auto; }
.dateask .btnrow .ok { flex-basis: 100%; }
/* tap feedback: the pressed thing darkens (a tint laid over its own colour); small buttons also sink a little.
   text-only buttons with no padding fade instead. the tint shows at once and fades out on release */
button, .ck i { transition: transform .15s ease, box-shadow .15s ease, opacity .15s ease, background-color .15s ease; }
/* rows are moved by GSAP Flip, so a CSS transform transition on them would drag behind it */
.task { transition: box-shadow .15s ease, opacity .15s ease, background-color .15s ease; }
button:active { opacity: .6; transition-duration: 0s; }
.iconbtn:active, .seg button:active, .lpill:active, .chip:active, .ib:active, .rhead:active, .menu > button:active, .newrow button:active,
.timerow button:active, .btnrow .cancel:active, .btnrow .ok:active, .pri3 button:active, .dpanel .ok:active, .mgadd:active, .task:has(> .tbody:active) {
  opacity: 1; box-shadow: inset 0 0 0 999px var(--press); transition-duration: 0s; }
.iconbtn:active, .seg button:active, .lpill:active, .chip:active, .ib:active, .newrow button:active, .timerow button:active,
.btnrow .cancel:active, .btnrow .ok:active, .pri3 button:active, .dpanel .ok:active, .mgadd:active { transform: scale(.97); }
.ib:has(select:active), .ib:has(input:active) { box-shadow: inset 0 0 0 999px var(--press); transform: scale(.97); transition-duration: 0s; }
.selw:has(select:active) .sel { box-shadow: inset 0 0 0 999px var(--press); }
.ck:active, .tbody:active { opacity: 1; }
.ck:active i { transform: scale(.86); transition-duration: 0s; }
/* a task row is inset by the box's 16px padding: two side shadows carry the tint out to the box edges */
.task:has(> .tbody:active) { box-shadow: inset 0 0 0 999px var(--press), -16px 0 0 0 var(--press), 16px 0 0 0 var(--press); }
@media (prefers-reduced-motion: reduce) { button:active, .ck:active i, .ib:has(select:active) { transform: none !important; } }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; scroll-behavior: auto !important; } }

/* ---- motion: short (≤ .35s), never in the way of the next tap; all off under reduced motion ---- */
/* a tick: the ring swells a little and the check is drawn */
.ck.pop i { animation: ck-pop .32s cubic-bezier(.3, 1.6, .5, 1); }
.ck.pop path { stroke-dasharray: 14; stroke-dashoffset: 14; animation: ck-draw .26s ease-out .06s forwards; }
@keyframes ck-pop { 0% { transform: scale(.86); } 60% { transform: scale(1.12); } 100% { transform: scale(1); } }
@keyframes ck-draw { to { stroke-dashoffset: 0; } }
/* the bar grows, then gives a small nod; when today is all done a light passes over it once */
.pbar.bump, .pbar.full { animation: pbar-bump .4s ease .12s; }
@keyframes pbar-bump { 50% { transform: scaleY(1.75); } }
.pbar.full i { position: relative; overflow: hidden; }
.pbar.full i::after { content: ""; position: absolute; inset: 0; background: linear-gradient(100deg, transparent 15%, var(--shine) 50%, transparent 85%); transform: translateX(-100%); animation: pbar-shine .7s ease-out .25s forwards; }
@keyframes pbar-shine { to { transform: translateX(100%); } }
.hero-h .prog b.pop { display: inline-block; animation: num-pop .3s cubic-bezier(.3, 1.6, .5, 1); }
@keyframes num-pop { 50% { transform: scale(1.3); } }
/* sheets rise from the bottom over a fading-in scrim, and drop back down when closed */
.sheet:not([hidden]) { animation: sheet-in .3s cubic-bezier(.2, .8, .2, 1); }
.scrim:not([hidden]) { animation: fade-in .25s ease; }
.sheet.closing { animation: sheet-out .2s ease-in forwards; pointer-events: none; }
.scrim.closing { animation: fade-out .2s ease-in forwards; }
@keyframes sheet-in { from { transform: translate(-50%, 100%); } }
@keyframes sheet-out { to { transform: translate(-50%, 100%); } }
@keyframes fade-in { from { opacity: 0; } }
@keyframes fade-out { to { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .ck.pop i, .ck.pop path, .pbar, .pbar i::after, .hero-h .prog b, .sheet, .scrim { animation: none !important; } .ck.pop path { stroke-dashoffset: 0; } }
