/* ==========================================================================
   components.css — 元件樣式（可攜，與展示牆無關）
   --------------------------------------------------------------------------
   規則：
   - 顏色只讀 tokens.css 的語意變數（--bg --fg --hi --on-hi 與衍生的灰階）。
   - 狀態一律用 class 或 attribute 表示（.is-open、aria-checked、data-state…），
     JS 只負責切換狀態，動畫全部寫在這裡。
   - 位置類的數值用 CSS 變數傳入（--v --p --x --y …）。
   ========================================================================== */

/* ---- 基礎 ---------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
button { margin: 0; padding: 0; border: 0; background: none; font: inherit; color: inherit; cursor: pointer; }
:focus-visible { outline: 2px solid var(--hi); outline-offset: 2px; }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

/* ---- 表面：白（預設）／黑／強調色 ---------------------------------------- */
/* 灰階全部由文字色加透明度而來，所以三種表面都不需要額外的顏色 */
:root, .surface {
  --muted: color-mix(in srgb, var(--fg) 56%, transparent);   /* 次要文字 */
  --faint: color-mix(in srgb, var(--fg) 30%, transparent);   /* 佔位字、停用 */
  --line: color-mix(in srgb, var(--fg) 12%, transparent);    /* 分隔線、外框 */
  --fill: color-mix(in srgb, var(--fg) 6%, transparent);     /* 淺底 */
  --fill-2: color-mix(in srgb, var(--fg) 12%, transparent);  /* 軌道、未選取 */
  --halo: color-mix(in srgb, var(--hi) 26%, transparent);    /* 聚焦光暈 */
  --soft: color-mix(in srgb, var(--fg) 10%, var(--bg));      /* 不透明的淺底 */
}
.surface { background: var(--bg); color: var(--fg); }
.surface--ink {
  --bg: var(--ink);
  --fg: var(--paper);
  --line: color-mix(in srgb, var(--fg) 18%, transparent);
  --fill: color-mix(in srgb, var(--fg) 10%, transparent);
  --fill-2: color-mix(in srgb, var(--fg) 20%, transparent);
}
.surface--accent {
  --bg: var(--accent);
  --fg: var(--on-accent);
  --hi: var(--on-accent);
  --on-hi: var(--accent);
}

/* ---- 小零件 -------------------------------------------------------------- */
.icon {
  flex: none; width: 1.25em; height: 1.25em; overflow: visible;
  fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}
.icon--solid { fill: currentColor; stroke-width: 1.5; }

.caption { margin: 0; font-size: var(--text-sm); color: var(--muted); }
.caption b { font-weight: 600; color: var(--fg); }
.stack { display: grid; gap: var(--stack, 14px); }
.stack--center { justify-items: center; text-align: center; }

/* 可按的東西：按下瞬間縮、放開用彈簧回彈 */
.pressable {
  transition: scale var(--dur-spring) var(--spring), background-color var(--dur) var(--ease-out),
              color var(--dur) var(--ease-out), opacity var(--dur);
}

/* 數字／文字滾動：.roll 是一個視窗，舊字滾出、新字彈入；--dir 決定方向 */
.roll { display: inline-grid; vertical-align: top; clip-path: inset(-.12em -.5em); }
.roll > * { grid-area: 1 / 1; white-space: nowrap; }
.roll > .is-in { animation: roll-in var(--dur-spring) var(--spring) var(--delay, 0ms) backwards; }
.roll > .is-out { animation: roll-out .2s var(--ease-in) var(--delay, 0ms) forwards; }
.roll--center { justify-items: center; }                     /* 置中情境用：新舊字寬不同時不會左右跳 */
.roll--x { clip-path: none; }
.roll--x > .is-in { animation-name: slide-in; }
.roll--x > .is-out { animation-name: slide-out; }
.rolls { display: inline-flex; font-variant-numeric: tabular-nums; }

/* 內容替換：舊的上滑淡出、新的自下方彈入 */
.swap { transition: opacity var(--dur), translate var(--dur-spring) var(--spring); }
.swap.is-leaving { opacity: 0; translate: 0 -12px; transition: opacity .2s, translate .24s var(--ease-in); }
.swap.is-entering { opacity: 0; translate: 0 16px; }
.swap.is-entering, .swap.is-entering * { transition: none !important; }   /* 換內容的瞬間不要有過場 */

/* 打字游標 */
.caret {
  display: inline-block; width: 2px; height: 1.15em; margin-left: 1px; border-radius: 1px;
  background: var(--hi); vertical-align: -.18em; animation: blink 1.1s steps(1) infinite;
}

/* 輸入框外觀（搜尋、密碼、聊天輸入共用） */
.field {
  display: flex; align-items: center; gap: 10px; min-width: 0; height: 48px; padding: 0 16px;
  border-radius: var(--radius-full); background: var(--fill); font-size: var(--text-md);
  box-shadow: inset 0 0 0 1.5px transparent, 0 0 0 0 transparent;
  transition: background-color var(--dur), box-shadow var(--dur) var(--ease-out);
}
.field:hover, .field.is-hover { background: var(--fill-2); }
.field:focus-within, .field.is-focus { background: var(--bg); box-shadow: inset 0 0 0 1.5px var(--fg), 0 0 0 4px var(--halo); }
.field > .icon { color: var(--muted); transition: color var(--dur); }
.field:focus-within > .icon, .field.is-focus > .icon { color: var(--fg); }
/* 真正的輸入欄位：外觀全部交給外層的 .field */
.field__input {
  flex: 1; min-width: 0; height: 100%; margin: 0; padding: 0; border: 0; outline: 0; background: none;
  font: inherit; color: inherit; caret-color: var(--hi); appearance: none;
}
.field__input::placeholder { color: var(--faint); opacity: 1; }
.field__input::-webkit-search-cancel-button { display: none; }
@media (pointer: coarse) { .field__input { font-size: 16px; } }   /* 觸控裝置至少 16px，iOS 才不會在聚焦時自動放大畫面 */
/* 示範打字用的替身（player.js 的 ctx.ghost）：暫時蓋掉真的輸入欄位，顯示逐字出現的文字與游標 */
.field.has-ghost .field__input { display: none; }
.field__ghost { flex: 1; min-width: 0; overflow: hidden; white-space: nowrap; }
.field__placeholder { display: none; color: var(--faint); }
.type:empty ~ .field__placeholder { display: inline; }
.field:not(.is-focus) .caret { display: none; }

.kbd {
  flex: none; padding: 2px 6px; border-radius: 6px; box-shadow: inset 0 0 0 1px var(--line);
  font: 600 var(--text-xs) / 1.4 var(--font); color: var(--muted);
}

.chip {
  display: inline-flex; align-items: center; gap: 3px; height: 24px; padding: 0 9px 0 6px;
  border-radius: var(--radius-full); background: var(--hi); color: var(--on-hi);
  font-size: 12px; font-weight: 700; transition: background-color var(--dur), color var(--dur);
}
.chip .icon { width: 14px; height: 14px; stroke-width: 2.6; transition: rotate var(--dur-spring) var(--spring); }
.chip.is-down { background: var(--fill-2); color: var(--fg); }
.chip.is-down .icon { rotate: 90deg; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; flex: none;
  height: 38px; min-width: 80px; padding: 0 16px; border-radius: var(--radius-full);
  background: var(--fg); color: var(--bg); font-size: var(--text-sm); font-weight: 700;
}
.btn.is-on { background: var(--hi); color: var(--on-hi); }

.icon-btn {
  display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; background: var(--fill);
}
.icon-btn .icon { width: 18px; height: 18px; }

.progress { height: 8px; overflow: hidden; border-radius: var(--radius-full); background: var(--fill-2); }
.progress__bar {
  height: 100%; border-radius: inherit; background: var(--hi);
  transform: translateX(calc((var(--p, 0) - 1) * 100%));   /* --p: 0–1 */
  transition: transform .5s var(--ease-out);
}

/* ---- 01 日曆 ------------------------------------------------------------- */
.calendar { display: flex; flex-direction: column; gap: 6px; height: 100%; }
.calendar__bar { display: flex; align-items: center; justify-content: space-between; }
.calendar__title {
  display: flex; align-items: baseline; gap: .25em;
  font-size: var(--text-lg); font-weight: 700; letter-spacing: -.01em; font-variant-numeric: tabular-nums;
}
.calendar__nav { display: flex; gap: 6px; }
.calendar__week, .calendar__grid { display: grid; grid-template-columns: repeat(7, 1fr); text-align: center; }
.calendar__week { padding: 6px 0 2px; font-size: var(--text-xs); color: var(--muted); }
.calendar__grid {
  position: relative; flex: 1; min-height: 0; grid-template-rows: repeat(6, 1fr);
  transition: opacity var(--dur), transform var(--dur-spring) var(--spring-soft);
}
.calendar__grid.is-swapping {
  opacity: 0; transform: translateX(calc(var(--dir, 1) * -18px));
  transition: opacity .16s, transform .18s var(--ease-in);
}
.calendar__day {
  position: relative; z-index: 1; display: grid; place-items: center;
  font-size: 14px; font-weight: 500; font-variant-numeric: tabular-nums; transition: color var(--dur);
}
.calendar__day:not(.is-selected):is(:hover, .is-hover)::before {
  content: ""; position: absolute; left: 50%; top: 50%; z-index: -1; width: 36px; height: 36px; margin: -18px 0 0 -18px;
  border-radius: 50%; background: var(--fill);
}
.calendar__day.is-out { color: var(--faint); }
.calendar__day.is-today::after {
  content: ""; position: absolute; left: 50%; bottom: 9%; width: 4px; height: 4px; margin-left: -2px;
  border-radius: 50%; background: var(--hi); transition: background-color var(--dur);
}
.calendar__day.is-selected { color: var(--on-hi); font-weight: 700; }
.calendar__day.is-selected::after { background: var(--on-hi); }
/* 選取指示：同一顆圓在日期之間彈跳移動（--x --y --s 由 JS 量測後傳入） */
.calendar__mark {
  position: absolute; left: 0; top: 0; width: var(--s, 36px); height: var(--s, 36px);
  border-radius: 50%; background: var(--hi);
  transform: translate(var(--x, 0px), var(--y, 0px)) scale(var(--k, 1));
  transition: transform var(--dur-spring) var(--spring), opacity var(--dur-fast);
}
.calendar__mark.is-hidden { --k: .3; opacity: 0; }

/* ---- 02 分頁切換 --------------------------------------------------------- */
.tabs {
  position: relative; display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
  padding: 4px; border-radius: var(--radius-full); background: var(--fill);
}
.tabs__thumb {
  position: absolute; top: 4px; bottom: 4px; left: 0; width: var(--w, 0px);
  border-radius: inherit; background: var(--fg); transform: translateX(var(--x, 4px));
  transition: transform var(--dur-spring) var(--spring), width var(--dur-spring) var(--spring);
}
.tabs__tab {
  position: relative; z-index: 1; height: 36px; border-radius: inherit;
  font-size: var(--text-sm); font-weight: 600; color: var(--muted); transition: color var(--dur);
}
.tabs__tab.is-active { color: var(--bg); }
.tabs--sm { display: inline-grid; }
.tabs--sm .tabs__tab { height: 30px; padding: 0 16px; font-size: var(--text-xs); }
.tab-panel { display: grid; justify-items: start; gap: 2px; min-height: 54px; padding: 0 6px; }   /* 上下排：換字時彼此不會推擠 */
.tab-panel__value { font-size: var(--text-xl); line-height: 1.1; font-weight: 700; letter-spacing: -.02em; }

/* ---- 03 數字加減 --------------------------------------------------------- */
.stepper { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; height: 100%; }
.stepper__value {
  font-size: 64px; line-height: 1; font-weight: 700; letter-spacing: -.03em; font-variant-numeric: tabular-nums;
}
.stepper__btns { display: flex; gap: 8px; }
.stepper__btn {
  display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%;
  background: var(--fg); color: var(--bg);
}
.stepper__btn:disabled { opacity: .3; cursor: not-allowed; }

/* ---- 04 開關 ------------------------------------------------------------- */
.switch {
  --w: 52px; --h: 32px; --inset: 3px;
  position: relative; flex: none; width: var(--w); height: var(--h);
  border-radius: var(--radius-full); background: var(--fill-2);
  transition: background-color var(--dur) var(--ease-out);
}
.switch__thumb {
  position: absolute; top: var(--inset); left: var(--inset);
  width: calc(var(--h) - 2 * var(--inset)); height: calc(var(--h) - 2 * var(--inset));
  border-radius: calc(var(--radius-full) - var(--inset)); background: var(--paper); box-shadow: 0 2px 8px rgb(0 0 0 / .22);
  transition: transform var(--dur-spring) var(--spring);
}
.switch[aria-checked="true"] { background: var(--hi); }
.switch[aria-checked="true"] .switch__thumb { transform: translateX(calc(var(--w) - var(--h))); }
.switch::before { content: ""; position: absolute; inset: -6px; border-radius: inherit; }   /* 觸動範圍比外觀大一圈，至少 44px */
.switch:hover, .switch.is-hover { background: color-mix(in srgb, var(--fg) 22%, transparent); }
.switch[aria-checked="true"]:hover, .switch[aria-checked="true"].is-hover { background: color-mix(in srgb, var(--hi) 84%, var(--fg)); }
.switch.is-focus { outline: 2px solid var(--hi); outline-offset: 2px; }
.switch:disabled, .switch.is-disabled { opacity: .4; cursor: not-allowed; }
.switch--sm { --w: 40px; --h: 24px; --inset: 2px; }
.switch--xl { --w: 104px; --h: 60px; --inset: 5px; }

/* ---- 05 進度圈 ----------------------------------------------------------- */
.ring { position: relative; height: 100%; max-height: 132px; aspect-ratio: 1; margin: auto; }
.ring > svg { display: block; width: 100%; height: 100%; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 10; }
.ring__track { stroke: var(--fill-2); }
.ring__bar {
  stroke: var(--hi); stroke-linecap: round; stroke-dasharray: 100;
  stroke-dashoffset: calc(100 - var(--p, 0));               /* --p: 0–100 */
  transition: stroke-dashoffset 1.1s var(--spring-soft);
}
.ring__label { position: absolute; inset: 0; display: grid; grid-template: minmax(0, 1fr) / minmax(0, 1fr); place-items: center; }
.ring__label > * { grid-area: 1 / 1; }
.ring__num {
  font-size: 30px; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums;
  transition: opacity var(--dur-fast), scale var(--dur) var(--ease-out);
}
.ring__num small { margin-left: 1px; font-size: 14px; font-weight: 600; color: var(--muted); }
.ring__check {
  width: 44%; height: 44%; color: var(--hi); stroke-width: 2.8; opacity: 0;
  stroke-dasharray: 1; stroke-dashoffset: 1.02;
  transition: opacity .15s, stroke-dashoffset 0s .2s;        /* 收回：先淡出，再把筆畫歸零 */
}
.ring.is-done .ring__num { opacity: 0; scale: .8; }
/* 完成：數字淡出後，勾勾一筆畫下去（慢起、過轉角加速、收尾放慢），不縮放也不彈跳 */
.ring.is-done .ring__check {
  opacity: 1; stroke-dashoffset: 0;
  transition: opacity .1s .12s, stroke-dashoffset .6s var(--ease-in-out) .18s;
}

/* ---- 06 滑桿 ------------------------------------------------------------- */
.slider { display: grid; gap: 24px; padding-top: 38px; }      /* 上方留給數值泡泡、下方讓出拖曳光暈；--v: 0–1 */
.slider__track { position: relative; height: 10px; margin: 0 14px; container-type: inline-size; cursor: pointer; touch-action: none; }
.slider__track::before { content: ""; position: absolute; inset: -17px -14px; }             /* 觸動範圍：上下各多 17px，共 44px 高 */
.slider__rail { position: absolute; inset: 0; overflow: hidden; border-radius: var(--radius-full); background: var(--fill-2); }
.slider__fill {
  position: absolute; inset: 0; border-radius: inherit; background: var(--hi);
  transform: translateX(calc((var(--v, 0) - 1) * 100%));
  transition: transform var(--dur-spring) var(--spring-soft);
}
.slider__thumb {
  position: absolute; top: 50%; left: 0; width: 28px; height: 28px; margin: -14px 0 0 -14px;
  border-radius: 50%; background: var(--bg);
  box-shadow: inset 0 0 0 2.5px var(--fg), 0 4px 10px -2px rgb(0 0 0 / .3), 0 0 0 0 var(--halo);
  transform: translateX(calc(var(--v, 0) * 100cqw));
  transition: transform var(--dur-spring) var(--spring-soft), scale var(--dur-spring) var(--spring), box-shadow var(--dur);
}
.slider.is-dragging .slider__thumb {
  scale: 1.14;
  box-shadow: inset 0 0 0 2.5px var(--fg), 0 6px 14px -2px rgb(0 0 0 / .3), 0 0 0 8px var(--halo);
}
.slider__bubble {
  position: absolute; left: 50%; bottom: calc(100% + 9px); min-width: 36px; padding: 4px 8px;
  border-radius: var(--radius-sm); background: var(--fg); color: var(--bg);
  font-size: 12px; font-weight: 700; text-align: center; font-variant-numeric: tabular-nums;
  translate: -50% 0; transform-origin: 50% 140%;
  transition: scale var(--dur-spring) var(--spring-pop), translate var(--dur-spring) var(--spring);
}
.slider__bubble::after {
  content: ""; position: absolute; left: 50%; bottom: -3px; width: 8px; height: 8px; margin-left: -4px;
  border-radius: 2px; background: inherit; rotate: 45deg;
}
.slider.is-dragging .slider__bubble { scale: 1.12; translate: -50% -3px; }
/* 手指拖曳時要跟手：位移不走彈簧 */
.slider.is-tracking .slider__thumb { transition: transform .06s linear, scale var(--dur-spring) var(--spring), box-shadow var(--dur); }
.slider.is-tracking .slider__fill { transition: transform .06s linear; }
.slider__thumb:is(:focus-visible, .is-focus) { outline: 0; box-shadow: inset 0 0 0 2.5px var(--fg), 0 4px 10px -2px rgb(0 0 0 / .3), 0 0 0 6px var(--halo); }
.slider__scale { display: flex; justify-content: space-between; margin: 0 14px; font-size: var(--text-xs); color: var(--muted); }

/* ---- 07 星星評分 --------------------------------------------------------- */
.rating { display: grid; gap: 12px; justify-items: center; }
.rating__stars { display: flex; justify-content: center; align-items: center; gap: 3px; width: 100%; border-radius: var(--radius-sm); }
.rating__btn { flex: 0 1 28px; min-width: 0; }                                              /* 窄卡片時等比縮小 */
.rating__star {
  display: block; width: 100%; height: auto; aspect-ratio: 1; stroke: none; fill: var(--fill-2);
  transition: fill var(--dur-fast) calc(var(--i, 0) * 70ms), scale var(--dur-spring) var(--spring);
}
.rating__btn:is(:hover, .is-hover) .rating__star { scale: 1.14; }
.rating__star.is-on { fill: var(--hi); animation: star-pop var(--dur-spring) var(--spring-pop) calc(var(--i, 0) * 70ms) backwards; }
.rating__text { display: flex; align-items: baseline; gap: 6px; font-size: var(--text-sm); color: var(--muted); }
.rating__text b { font-size: var(--text-md); color: var(--fg); }

/* ---- 08 單選清單 --------------------------------------------------------- */
.radio-list { position: relative; display: grid; gap: 6px; }
.radio-list::before {                                         /* 滑動的選取底（--y --h 由 JS 量測） */
  content: ""; position: absolute; inset: 0 0 auto; height: var(--h, 0px);
  border-radius: var(--radius-lg); background: var(--fill); box-shadow: inset 0 0 0 1.5px var(--fg);
  transform: translateY(var(--y, 0px));
  transition: transform var(--dur-spring) var(--spring), height var(--dur);
}
.radio { position: relative; display: flex; align-items: center; gap: 10px; min-height: 62px; padding: 8px 12px; }
.radio__dot {
  flex: none; display: grid; place-items: center; width: 20px; height: 20px; border-radius: 50%;
  box-shadow: inset 0 0 0 1.5px var(--faint); transition: background-color var(--dur), box-shadow var(--dur);
}
.radio__dot::after {
  content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--on-hi);
  scale: 0; transition: scale var(--dur-spring) var(--spring-pop);
}
.radio.is-checked .radio__dot { background: var(--hi); box-shadow: inset 0 0 0 1.5px var(--hi); }
.radio.is-checked .radio__dot::after { scale: 1; }
.radio__text { display: grid; min-width: 0; line-height: 1.3; }
.radio__text b { font-size: 14px; font-weight: 600; }
.radio__text small { font-size: 12px; color: var(--muted); }

/* ---- 09 聊天泡泡 --------------------------------------------------------- */
.chat { display: flex; flex-direction: column; gap: 12px; height: 100%; }
.chat__log {
  flex: 1; min-height: 0; display: flex; flex-direction: column; justify-content: flex-end; overflow: hidden;
  -webkit-mask-image: linear-gradient(to bottom, transparent, #000 32px);
          mask-image: linear-gradient(to bottom, transparent, #000 32px);
  transition: opacity var(--dur);
}
.chat__log.is-clearing { opacity: 0; }
.msg { flex: none; display: flex; align-items: flex-end; height: 0; transition: height .5s var(--spring-soft); }
.msg--out { justify-content: flex-end; }
.bubble {
  max-width: 84%; padding: 10px 14px; border-radius: 20px; background: var(--fill);
  font-size: 14px; line-height: 1.45; transform-origin: 0 100%;
  animation: bubble-in var(--dur-spring) var(--spring) backwards;
}
.msg--in .bubble { border-bottom-left-radius: 6px; }
.msg--out .bubble { border-bottom-right-radius: 6px; background: var(--hi); color: var(--on-hi); transform-origin: 100% 100%; }
.bubble.is-swap { animation-name: bubble-swap; }
.bubble--typing { display: flex; align-items: center; gap: 4px; height: 40px; }
.bubble--typing i { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); animation: typing-dot 1.1s var(--ease-out) infinite; }
.bubble--typing i:nth-child(2) { animation-delay: .14s; }
.bubble--typing i:nth-child(3) { animation-delay: .28s; }
.chat__composer { padding-right: 6px; }
.chat__send {
  flex: none; display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%;
  background: var(--fg); color: var(--bg);
}
.chat__send .icon { width: 18px; height: 18px; stroke-width: 2.4; }
.chat__composer:not(.has-ghost):has(.field__input:placeholder-shown) .chat__send,
.chat__composer.has-ghost:has(.type:empty) .chat__send { opacity: .25; }

/* ---- 10 驗證碼輸入 ------------------------------------------------------- */
.otp { display: grid; gap: 12px; }
.otp__boxes { position: relative; display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 8px; }
.otp__input {                                                 /* 真正接收輸入的欄位：透明、蓋滿六個格子 */
  position: absolute; inset: 0; z-index: 2; width: 100%; height: 100%; margin: 0; padding: 0; border: 0;
  opacity: 0; font-size: 16px; cursor: text; appearance: none;
}
.otp__box {
  position: relative; display: grid; place-items: center; height: 56px;
  border-radius: 14px; background: var(--fill);
  font-size: 24px; font-weight: 700; font-variant-numeric: tabular-nums;
  box-shadow: inset 0 0 0 1.5px transparent, 0 0 0 0 transparent;
  transition: background-color var(--dur), color var(--dur), box-shadow var(--dur) var(--ease-out);
}
.otp__box.is-active { background: var(--bg); box-shadow: inset 0 0 0 1.5px var(--fg), 0 0 0 4px var(--halo); }
.otp__box.is-active:empty::after {
  content: ""; width: 2px; height: 24px; border-radius: 1px; background: var(--hi);
  animation: blink 1.1s steps(1) infinite;
}
.otp__box b { animation: pop-in var(--dur-spring) var(--spring-pop) backwards; }
.otp__box b.is-out { animation: pop-out .22s var(--ease-in) calc(var(--i, 0) * 40ms) forwards; }
.otp[data-state="success"] .otp__box {
  background: var(--hi); color: var(--on-hi);
  animation: hop .7s var(--ease-out) calc(var(--i, 0) * 60ms);
  transition-delay: calc(var(--i, 0) * 60ms);
}
.otp[data-state="error"] .otp__boxes { animation: shake .5s var(--ease-out); }
.otp[data-state="error"] .otp__box { box-shadow: inset 0 0 0 1.5px var(--fg); }

/* ---- 11 送出按鈕 --------------------------------------------------------- */
.submit {
  position: relative; display: grid; place-items: center; width: 100%; height: 52px; margin: auto; overflow: hidden;
  grid-template-columns: minmax(0, 1fr);   /* 軌道跟著按鈕寬度走，縮成圓形時載入圈才會在正中央（否則會被隱藏的文字撐寬而偏右） */
  border-radius: var(--radius-full); background: var(--fg); color: var(--bg);
  font-size: var(--text-md); font-weight: 700;
  transition: width var(--dur-spring) var(--spring), scale var(--dur-spring) var(--spring),
              background-color var(--dur), color var(--dur);
}
/* 三層內容疊在同一格：離場的先快速淡出，進場的稍後才彈入，兩段文字不會疊在一起 */
.submit > * { grid-area: 1 / 1; white-space: nowrap; opacity: 0; scale: .6; transition: opacity .1s, scale .2s var(--ease-out); }
.submit[data-state="idle"] .submit__label,
.submit[data-state="loading"] .submit__spinner,
.submit[data-state="success"] .submit__ok {
  opacity: 1; scale: 1;
  transition: opacity var(--dur-fast) .1s, scale var(--dur-spring) var(--spring) .1s;
}
.submit:hover, .submit.is-hover { background: color-mix(in srgb, var(--fg) 80%, var(--bg)); }
.submit.is-focus { outline: 2px solid var(--hi); outline-offset: 2px; }
.submit[data-state="loading"] { width: 52px; cursor: progress; }
.submit[data-state="success"] { background: var(--hi); color: var(--on-hi); }
/* 種類：次要（外框） */
.submit--outline { background: transparent; color: var(--fg); box-shadow: inset 0 0 0 1.5px var(--fg); }
.submit--outline:hover, .submit--outline.is-hover { background: var(--fill); }
.submit--outline[data-state="success"] { box-shadow: none; }
/* 尺寸：小 */
.submit--sm { height: 40px; font-size: var(--text-sm); }
.submit--sm[data-state="loading"] { width: 40px; }
.submit--sm .submit__spinner { width: 18px; height: 18px; border-width: 2px; }
/* 寬度：依內容（載入中維持原寬，不縮成圓形） */
.submit--fit, .submit--fit[data-state="loading"] { width: auto; min-width: 128px; padding: 0 28px; }
/* 停用 */
.submit:disabled, .submit.is-disabled { background: var(--fill-2); color: var(--faint); box-shadow: none; cursor: not-allowed; scale: 1; }
.submit__spinner {
  width: 22px; height: 22px; border-radius: 50%;
  border: 2.5px solid color-mix(in srgb, currentColor 25%, transparent); border-top-color: currentColor;
  animation: spin .7s linear infinite;
}
.submit__ok { display: inline-flex; align-items: center; gap: 6px; }
.submit__ok .icon { stroke-width: 2.8; stroke-dasharray: 1; stroke-dashoffset: 1.02; transition: stroke-dashoffset .4s var(--ease-out) .22s; }
.submit[data-state="success"] .submit__ok .icon { stroke-dashoffset: 0; }

/* ---- 12 語音波形播放 ----------------------------------------------------- */
.audio { display: flex; align-items: center; gap: 16px; height: 100%; }
.audio__btn {
  position: relative; flex: none; display: grid; place-items: center; width: 56px; height: 56px;
  border-radius: 50%; background: var(--hi); color: var(--on-hi);
}
.audio__btn .icon {
  grid-area: 1 / 1; width: 22px; height: 22px;
  transition: opacity var(--dur-fast), scale var(--dur-spring) var(--spring-pop), rotate var(--dur-spring) var(--spring);
}
.audio__btn [data-icon="play"] { translate: 1px 0; }
.audio__btn[data-state="paused"] [data-icon="pause"],
.audio__btn[data-state="playing"] [data-icon="play"] { opacity: 0; scale: .3; rotate: -90deg; }
.audio__main { flex: 1; min-width: 0; display: grid; gap: 8px; }
.audio__wave { display: flex; align-items: center; gap: 2px; height: 52px; }
.audio__wave i {
  flex: 1; min-width: 0; height: calc(var(--h, .5) * 100%); min-height: 4px; border-radius: 99px;
  background: var(--faint); transition: background-color var(--dur);
}
.audio__wave i.is-played { background: var(--hi); animation: bar-pop .7s var(--spring); }
.audio__meta { display: flex; justify-content: space-between; font-size: var(--text-xs); color: var(--muted); font-variant-numeric: tabular-nums; }

/* ---- 13 頭像群組 --------------------------------------------------------- */
.avatar {
  flex: none; display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%;
  background: var(--soft); color: var(--fg); box-shadow: 0 0 0 2.5px var(--bg);
  font-size: 14px; font-weight: 700;
}
.avatar[data-tone="ink"] { background: var(--fg); color: var(--bg); }
.avatar[data-tone="hi"] { background: var(--hi); color: var(--on-hi); }
.avatar--lg { width: 56px; height: 56px; font-size: 20px; }
.avatars { display: grid; gap: 14px; justify-items: center; }
.avatars__stack { display: flex; justify-content: center; padding-left: 10px; }
.avatars__stack .avatar {
  margin-left: -10px;
  transition: margin var(--dur-spring) var(--spring-soft), scale .3s var(--ease-in), opacity .3s;
  animation: avatar-in var(--dur-spring) var(--spring) backwards;
}
.avatars__stack .avatar.is-out { margin-left: -40px; scale: 0; opacity: 0; }
.avatars__count { display: flex; align-items: center; gap: 6px; font-size: var(--text-sm); color: var(--muted); }
.avatars__count b { color: var(--fg); }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--hi); animation: pulse 1.6s var(--ease-out) infinite; }

/* ---- 14 長條圖 ----------------------------------------------------------- */
.chart { display: flex; flex-direction: column; gap: 14px; height: 100%; }
.chart__head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.chart__total { display: flex; align-items: baseline; font-size: var(--text-xl); line-height: 1.1; font-weight: 700; letter-spacing: -.02em; }
.chart__total small { margin-right: 2px; font-size: .6em; font-weight: 600; color: var(--muted); }
.chart__bars { flex: 1; min-height: 0; display: flex; gap: 10px; }
.chart__col { flex: 1; min-width: 0; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 8px; }
.chart__bar {
  position: relative; flex: none; width: 100%; min-height: 8px; border-radius: 10px; background: var(--fill-2);
  height: calc(var(--v, 0) * (100% - 52px));                 /* --v: 0–1；52px 留給提示泡泡與 x 軸標籤 */
  transition: height var(--dur-spring) var(--spring) calc(var(--i, 0) * 45ms), background-color var(--dur);
}
.chart__col.is-peak .chart__bar { background: var(--hi); }
.chart__tip {
  position: absolute; left: 50%; bottom: calc(100% + 6px); padding: 3px 7px; border-radius: var(--radius-sm);
  background: var(--fg); color: var(--bg); font-size: 11px; font-weight: 700; white-space: nowrap;
  translate: -50% 0; transform-origin: 50% 100%; opacity: 0; scale: .5;
  transition: opacity .15s, scale .2s var(--ease-in);
}
.chart__col.is-peak .chart__tip {
  opacity: 1; scale: 1;
  transition: opacity var(--dur-fast) .45s, scale var(--dur-spring) var(--spring-pop) .45s;
}
.chart__x { flex: none; font-size: var(--text-xs); line-height: 16px; color: var(--muted); }

/* ---- 15 標籤多選 --------------------------------------------------------- */
.tags { display: flex; flex-wrap: wrap; gap: 8px; }
.tag {
  display: inline-flex; align-items: center; gap: 5px; height: 36px; padding: 0 14px 0 10px;
  border-radius: var(--radius-full); background: var(--fill); font-size: var(--text-sm); font-weight: 600;
}
.tag.is-on { background: var(--fg); color: var(--bg); }
.tag__icon { position: relative; width: 16px; height: 16px; }
.tag__icon .icon {
  position: absolute; inset: 0; width: 100%; height: 100%; stroke-width: 2.4;
  transition: opacity var(--dur-fast), scale var(--dur-spring) var(--spring-pop), rotate var(--dur-spring) var(--spring);
}
.tag__icon .icon:first-child { color: var(--muted); }
.tag__icon .icon:last-child { color: var(--hi); stroke-width: 3; opacity: 0; scale: .2; rotate: -60deg; }
.tag.is-on .tag__icon .icon:first-child { opacity: 0; scale: .2; rotate: 90deg; }
.tag.is-on .tag__icon .icon:last-child { opacity: 1; scale: 1; rotate: 0deg; }

/* ---- 16 下拉選單 --------------------------------------------------------- */
.select { position: relative; height: 100%; }
.select__trigger {
  display: flex; align-items: center; justify-content: space-between; gap: 8px; width: 100%; height: 46px;
  padding: 0 12px 0 16px; border-radius: var(--radius-full); background: var(--fill);
  font-size: 14px; font-weight: 600; box-shadow: inset 0 0 0 1.5px transparent;
  transition: scale var(--dur-spring) var(--spring), background-color var(--dur), box-shadow var(--dur);
}
.select.is-open .select__trigger { background: var(--bg); box-shadow: inset 0 0 0 1.5px var(--fg); }
.select__chev { width: 18px; height: 18px; transition: rotate var(--dur-spring) var(--spring); }
.select.is-open .select__chev { rotate: 180deg; }
.select__menu {
  --row: 38px;
  position: absolute; z-index: 2; top: 54px; left: 0; right: 0; margin: 0; padding: 4px; list-style: none;
  border-radius: var(--radius-lg); background: var(--bg);
  box-shadow: 0 0 0 1px var(--line), 0 18px 32px -14px rgb(0 0 0 / .35);
  transform-origin: 50% 0; opacity: 0; transform: translateY(-8px) scale(.92); pointer-events: none;
  transition: opacity .16s, transform .2s var(--ease-in);
}
.select.is-open .select__menu {
  opacity: 1; transform: none; pointer-events: auto;
  transition: opacity .16s, transform var(--dur-spring) var(--spring);
}
.select__menu::before {                                       /* 滑動的 hover 底（--hl: 第幾列） */
  content: ""; position: absolute; left: 4px; right: 4px; top: 4px; height: var(--row);
  border-radius: 14px; background: var(--fill);
  transform: translateY(calc(var(--hl, 0) * var(--row)));
  transition: transform .6s var(--spring);
}
.select__opt {
  position: relative; display: flex; align-items: center; justify-content: space-between; height: var(--row);
  padding: 0 10px 0 12px; font-size: var(--text-sm); font-weight: 500;
  opacity: 0; transform: translateY(-6px); transition: opacity .12s, transform .16s;
}
.select.is-open .select__opt {
  opacity: 1; transform: none;
  transition: opacity var(--dur-fast) calc(var(--i, 0) * 35ms + 50ms),
              transform var(--dur-spring) var(--spring) calc(var(--i, 0) * 35ms + 50ms);
}
.select__opt .icon { width: 16px; height: 16px; color: var(--hi); stroke-width: 3; scale: 0; transition: scale var(--dur-spring) var(--spring-pop); }
.select__opt.is-selected .icon { scale: 1; }
/* 選單下方的清單：排序改變時各列彈到新位置（--pos: 第幾列） */
.sort-list { position: absolute; top: 62px; left: 0; right: 0; }
.sort-row {
  position: absolute; top: 0; left: 0; right: 0; display: flex; align-items: center; gap: 10px; height: 44px;
  transform: translateY(calc(var(--pos, 0) * 54px));
  transition: transform var(--dur-spring) var(--spring) calc(var(--pos, 0) * 45ms);
}
.sort-row__thumb {
  flex: none; display: grid; place-items: center; width: 44px; height: 44px; border-radius: var(--radius-md);
  background: var(--fill); font-size: var(--text-sm); font-weight: 700;
}
.sort-row__lines { flex: 1; display: grid; gap: 7px; }
.sort-row__lines i { height: 7px; border-radius: 99px; background: var(--fill-2); }
.sort-row__lines i:first-child { width: var(--w1, 80%); }
.sort-row__lines i:last-child { width: var(--w2, 50%); background: var(--fill); }

/* ---- 17 步驟清單 --------------------------------------------------------- */
.steps { display: grid; grid-auto-rows: 1fr; height: 100%; margin: 0; padding: 0; list-style: none; }
.step { position: relative; display: flex; gap: 12px; }
.step::before, .step::after {                                 /* 連接線：底線＋填滿 */
  content: ""; position: absolute; left: 13px; top: 33px; bottom: 5px; width: 2px; border-radius: 2px;
}
.step::before { background: var(--line); }
.step::after { background: var(--hi); transform: scaleY(0); transform-origin: 50% 0; transition: transform .5s var(--ease-out); }
.step.is-done::after { transform: scaleY(1); }
.step:last-child::before, .step:last-child::after { display: none; }
.step__dot {
  flex: none; display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%;
  color: var(--on-hi); box-shadow: inset 0 0 0 2px var(--line);
  transition: background-color var(--dur), box-shadow var(--dur);
}
.step__dot > * { grid-area: 1 / 1; }
.step__dot i { width: 8px; height: 8px; border-radius: 50%; background: var(--hi); scale: 0; transition: scale var(--dur-spring) var(--spring-pop); }
.step__dot .icon {
  width: 16px; height: 16px; stroke-width: 3; stroke-dasharray: 1; stroke-dashoffset: 1.02;
  transition: stroke-dashoffset .4s var(--ease-out) .12s;
}
.step.is-current .step__dot { box-shadow: inset 0 0 0 2px var(--hi); }
.step.is-current .step__dot i { scale: 1; animation: pulse 1.4s var(--ease-out) infinite; }
.step.is-done .step__dot { background: var(--hi); box-shadow: inset 0 0 0 2px var(--hi); animation: pop var(--dur-spring) var(--spring-pop); }
.step.is-done .step__dot .icon { stroke-dashoffset: 0; }
.step__text { display: grid; align-content: start; gap: 2px; min-width: 0; padding-top: 4px; line-height: 1.3; }
.step__text b { font-size: 14px; font-weight: 600; color: var(--muted); transition: color var(--dur); }
.step.is-current .step__text b, .step.is-done .step__text b { color: var(--fg); }
.step__text small { font-size: 12px; color: var(--muted); }

/* ---- 18 上傳進度 --------------------------------------------------------- */
.upload { display: flex; align-items: center; gap: 14px; }   /* --p: 0–1 */
.upload__icon {
  flex: none; display: grid; place-items: center; width: 52px; height: 52px; border-radius: var(--radius-lg);
  background: var(--fill); transition: background-color var(--dur), color var(--dur);
}
.upload__icon .icon { width: 24px; height: 24px; stroke-width: 1.8; }
.upload[data-state="done"] .upload__icon { background: var(--fg); color: var(--bg); }
.upload__main { flex: 1; min-width: 0; display: grid; gap: 8px; }
.upload__row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.upload__name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: var(--text-md); font-weight: 600; }
.upload__status { flex: none; display: grid; justify-items: end; align-items: center; height: 22px; font-variant-numeric: tabular-nums; }
.upload__status > * { grid-area: 1 / 1; transition: opacity var(--dur-fast), scale var(--dur-spring) var(--spring-pop); }
.upload__pct { font-size: var(--text-sm); font-weight: 700; }
.upload__done {
  display: grid; place-items: center; width: 22px; height: 22px; border-radius: 50%;
  background: var(--hi); color: var(--on-hi); opacity: 0; scale: .2;
}
.upload__done .icon { width: 14px; height: 14px; stroke-width: 3; stroke-dasharray: 1; stroke-dashoffset: 1.02; transition: stroke-dashoffset .4s var(--ease-out) .15s; }
.upload[data-state="done"] .upload__pct { opacity: 0; scale: .5; }
.upload[data-state="done"] .upload__done { opacity: 1; scale: 1; }
.upload[data-state="done"] .upload__done .icon { stroke-dashoffset: 0; }
.upload__meta { font-size: var(--text-xs); color: var(--muted); font-variant-numeric: tabular-nums; }

/* ---- 19 倒數計時 --------------------------------------------------------- */
.countdown { display: flex; align-items: center; gap: 6px; }
.countdown__unit {
  flex: 1; min-width: 0; display: grid; justify-items: center; gap: 6px; padding: 14px 0 10px;
  border-radius: var(--radius-lg); background: var(--fill);
}
.countdown__num { font-size: 34px; line-height: 1; font-weight: 700; letter-spacing: -.02em; }
.countdown__unit:last-child .countdown__num { color: var(--hi); }
.countdown__unit small { font-size: var(--text-xs); color: var(--muted); }
.countdown__sep { flex: none; font-style: normal; font-size: 20px; font-weight: 700; color: var(--faint); animation: blink 1s steps(1) infinite; }

/* ---- 20 搜尋框 ----------------------------------------------------------- */
.search { display: flex; flex-direction: column; gap: 10px; height: 100%; }
.search__list { --row: 42px; position: relative; display: grid; gap: 2px; margin: 0; padding: 0; list-style: none; }
.search__list::before {                                       /* 滑動的選取底（--hl: 第幾列） */
  content: ""; position: absolute; inset: 0 0 auto; height: var(--row);
  border-radius: var(--radius-md); background: var(--fill); opacity: 0;
  transform: translateY(calc(var(--hl, 0) * (var(--row) + 2px)));
  transition: transform .6s var(--spring), opacity var(--dur-fast);
}
.search.has-hl .search__list::before { opacity: 1; }
.search:not(.is-open) .search__list { pointer-events: none; }
.search__item[hidden] { display: none; }
.search__item {
  position: relative; display: flex; align-items: center; gap: 10px; height: var(--row); padding: 0 12px;
  font-size: 14px; color: var(--muted); white-space: nowrap;
  opacity: 0; transform: translateY(12px); transition: opacity .14s, transform .18s;
}
.search.is-open .search__item {
  opacity: 1; transform: none;
  transition: opacity var(--dur-fast) calc(var(--i, 0) * 45ms), transform var(--dur-spring) var(--spring) calc(var(--i, 0) * 45ms);
}
.search__item b { font-weight: 600; color: var(--fg); }
.search__item .icon { width: 16px; height: 16px; color: var(--faint); }
.search__enter { margin-left: auto; font-size: var(--text-xs); font-weight: 600; opacity: 0; transition: opacity var(--dur-fast); }
.search__item.is-active .search__enter { opacity: 1; }

/* ---- 21 常見問題收合 ----------------------------------------------------- */
.faq { display: flex; flex-direction: column; }
.faq__item + .faq__item { border-top: 1px solid var(--line); }
.faq__q {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%; height: 52px;
  font-size: var(--text-md); font-weight: 600; text-align: left;
}
.faq__icon {
  position: relative; flex: none; width: 28px; height: 28px; border-radius: 50%;
  background: var(--fill); transition: background-color var(--dur), color var(--dur);
}
.faq__icon::before, .faq__icon::after {                       /* 兩條線疊成「＋」；展開時直的那條轉平，變成「－」 */
  content: ""; position: absolute; left: 50%; top: 50%; width: 12px; height: 2px; margin: -1px 0 0 -6px;
  border-radius: 1px; background: currentColor; transition: rotate var(--dur-spring) var(--spring-soft);   /* 用柔的彈簧：轉過頭太多會像剪刀 */
}
.faq__icon::after { rotate: 90deg; }
.faq__item.is-open .faq__icon { background: var(--hi); color: var(--on-hi); }
.faq__item.is-open .faq__icon::after { rotate: 0deg; }
.faq__a { display: grid; grid-template-rows: 0fr; transition: grid-template-rows .5s var(--ease-out); }
.faq__a > div { min-height: 0; overflow: hidden; }
.faq__a p {
  margin: 0; padding: 0 40px 16px 0; font-size: 14px; line-height: 1.6; color: var(--muted);
  opacity: 0; translate: 0 -8px; transition: opacity var(--dur-fast), translate var(--dur) var(--ease-out);
}
.faq__item.is-open .faq__a { grid-template-rows: 1fr; }
.faq__item.is-open .faq__a p { opacity: 1; translate: 0 0; transition: opacity var(--dur) .1s, translate var(--dur-spring) var(--spring-soft) .06s; }

/* ---- 22 通知 ------------------------------------------------------------- */
.toasts { position: relative; height: 100%; min-height: 84px; }
.toast {                                                      /* --n: 0 最新，數字越大越後面 */
  position: absolute; left: 0; right: 0; bottom: 0; z-index: calc(10 - var(--n, 0));
  display: flex; align-items: center; gap: 12px; height: 60px; padding: 0 14px;
  border-radius: var(--radius-lg); background: var(--fg); color: var(--bg);
  opacity: calc(1 - var(--n, 0) * .36);
  transform: translateY(calc(var(--n, 0) * -11px)) scale(calc(1 - var(--n, 0) * .06));
  transition: transform var(--dur-spring) var(--spring), opacity var(--dur);
  animation: toast-in var(--dur-spring) var(--spring) backwards;
}
.toast.is-out { opacity: 0; }
.toast__icon { flex: none; display: grid; place-items: center; width: 34px; height: 34px; border-radius: 11px; background: var(--hi); color: var(--on-hi); }
.toast__icon .icon { width: 18px; height: 18px; stroke-width: 2.4; }
.toast__text { display: grid; min-width: 0; line-height: 1.3; }
.toast__text b { font-size: 14px; font-weight: 600; }
.toast__text small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; color: color-mix(in srgb, currentColor 60%, transparent); }

/* ---- 23 密碼強度 --------------------------------------------------------- */
.password { display: grid; gap: 12px; }                       /* data-level: 0–4 */
.password .type.is-masked, .password .field__input[type="password"] { font-weight: 700; letter-spacing: .14em; }
.field__eye { flex: none; display: grid; place-items: center; width: 32px; height: 32px; margin-right: -8px; border-radius: 50%; color: var(--muted); }
.field__eye .icon { grid-area: 1 / 1; transition: opacity var(--dur-fast), scale var(--dur-spring) var(--spring-pop); }
.field__eye[data-state="off"] [data-icon="eye-off"],
.field__eye[data-state="on"] [data-icon="eye"] { opacity: 0; scale: .4; }
.field__eye[data-state="on"] { color: var(--fg); }
/* 強度條：已填滿的格子一起換色，弱＝綠 → 普通＝黃 → 強＝橙 → 非常強＝紅（狀態色見 tokens.css） */
.meter { --meter: var(--success); display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
[data-level="2"] .meter { --meter: var(--caution); }
[data-level="3"] .meter { --meter: var(--warning); }
[data-level="4"] .meter { --meter: var(--danger); }
.meter i { position: relative; height: 6px; overflow: hidden; border-radius: 99px; background: var(--fill-2); }
.meter i::after {
  content: ""; position: absolute; inset: 0; border-radius: inherit; background: var(--meter);
  transform: translateX(-101%); transition: transform .6s var(--ease-out), background-color var(--dur) var(--ease-out);
}
[data-level="1"] .meter i:nth-child(-n+1)::after,
[data-level="2"] .meter i:nth-child(-n+2)::after,
[data-level="3"] .meter i:nth-child(-n+3)::after,
[data-level="4"] .meter i:nth-child(-n+4)::after { transform: none; }
.password__hint { display: flex; gap: 2px; }
.password__hint b { color: var(--fg); }

/* ---- 24 骨架載入 --------------------------------------------------------- */
.sk { position: relative; }
.sk::before {
  content: ""; position: absolute; inset: 0; border-radius: var(--radius-sm); pointer-events: none;
  background: linear-gradient(100deg, var(--fill-2) 35%, var(--fill) 50%, var(--fill-2) 65%) 100% 0 / 300% 100%;
  animation: shimmer 1.5s linear infinite;
  transition: opacity var(--dur) calc(var(--i, 0) * 70ms);
}
.sk--circle::before { border-radius: 50%; }
.sk--pill::before { border-radius: var(--radius-full); }
.sk--line::before { inset: 20% auto 20% 0; width: var(--w, 100%); }
.sk > * {
  transition: opacity var(--dur) calc(var(--i, 0) * 70ms),
              translate var(--dur-spring) var(--spring-soft) calc(var(--i, 0) * 70ms);
}
[data-loaded="false"] .sk > * { opacity: 0; translate: 0 8px; }
[data-loaded="true"] .sk::before { opacity: 0; }
.profile { display: flex; align-items: center; gap: 14px; }
.profile__text { flex: 1; min-width: 0; display: grid; gap: 4px; }
.profile__text b { display: block; font-size: 17px; font-weight: 700; }
.profile__text small { display: block; font-size: var(--text-sm); color: var(--muted); white-space: nowrap; }

/* ---- 25 統計數字 --------------------------------------------------------- */
.stat { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; height: 100%; }
.stat__num { font-size: var(--text-2xl); line-height: 1; font-weight: 700; letter-spacing: -.03em; }
.stat__meta { display: flex; align-items: center; gap: 8px; margin-top: 12px; }
.spark { flex: none; width: 120px; height: 56px; overflow: visible; }
.spark__line {
  fill: none; stroke: var(--fg); stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round;
  stroke-dasharray: 1; stroke-dashoffset: 1.02;
}
.spark.is-drawn .spark__line { stroke-dashoffset: 0; transition: stroke-dashoffset 1.1s var(--ease-out); }
.spark__dot { fill: var(--fg); transform-box: fill-box; transform-origin: center; scale: 0; }
.spark.is-drawn .spark__dot { scale: 1; transition: scale var(--dur-spring) var(--spring-pop) .8s; }

/* ---- 26 輸入框 ----------------------------------------------------------- */
/* 標籤＋欄位＋輔助說明。data-state：default／error／success；.is-disabled 停用、.is-readonly 唯讀 */
.input { display: grid; gap: 6px; min-width: 0; }
.input__label { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; font-size: var(--text-sm); font-weight: 600; }
.input__count { font-size: var(--text-xs); font-weight: 500; color: var(--muted); font-variant-numeric: tabular-nums; }
.input__hint { min-height: 18px; font-size: var(--text-xs); line-height: 18px; color: var(--muted); transition: color var(--dur); }
/* 清除鈕：有內容而且正在輸入時才出現 */
.field__clear {
  flex: none; display: grid; place-items: center; width: 24px; height: 24px; margin-right: -4px; border-radius: 50%;
  background: var(--fill-2); color: var(--muted); opacity: 0; scale: .5; pointer-events: none;
  transition: opacity var(--dur-fast), scale var(--dur-spring) var(--spring-pop);
}
.field__clear .icon { width: 12px; height: 12px; stroke-width: 3; }
.input.has-value .field:focus-within .field__clear, .input.has-value .field.is-focus .field__clear { opacity: 1; scale: 1; pointer-events: auto; }
/* 驗證結果圖示 */
.input__status { display: none; width: 18px; height: 18px; stroke-width: 2.6; animation: pop-in var(--dur-spring) var(--spring-pop) backwards; }
.input[data-state="success"] .input__status[data-icon="ok"] { display: block; color: var(--success); }
.input[data-state="error"] .input__status[data-icon="error"] { display: block; color: var(--danger); }
/* 錯誤：紅框、淡紅底、說明文字變紅，並搖一下提醒 */
.input[data-state="error"] .field {
  background: color-mix(in srgb, var(--danger) 8%, var(--bg));
  box-shadow: inset 0 0 0 1.5px var(--danger), 0 0 0 0 transparent; animation: shake .45s var(--ease-out);
}
.input[data-state="error"] .field:focus-within, .input[data-state="error"] .field.is-focus {
  box-shadow: inset 0 0 0 1.5px var(--danger), 0 0 0 4px color-mix(in srgb, var(--danger) 22%, transparent);
}
.input[data-state="error"] .input__hint { color: var(--danger); }
/* 停用與唯讀 */
.input.is-disabled { opacity: .45; cursor: not-allowed; }
.input.is-disabled .field { pointer-events: none; }
.input.is-readonly .field { background: transparent; box-shadow: inset 0 0 0 1.5px var(--line); }
/* 尺寸：小 */
.input--sm .field { height: 40px; padding: 0 14px; font-size: var(--text-sm); }
.input--sm .input__label { font-size: var(--text-xs); }

/* ---- 變體與狀態補充（尺寸變體、滑過、停用） ------------------------------ */
/* .is-hover／.is-focus 是為了在規範裡展示而強制套用的；實際由滑鼠（:hover）與鍵盤（:focus-visible）觸發 */
:where(button, [role], [tabindex]).is-focus { outline: 2px solid var(--hi); outline-offset: 2px; }
.calendar__day:is(:focus-visible, .is-focus) { border-radius: var(--radius-md); outline-offset: -2px; }   /* 聚焦外框貼著格子內側、圓角 */
.calendar--compact .calendar__day { font-size: 13px; }
.calendar--compact .calendar__title { font-size: var(--text-md); }
.calendar--hide-out .calendar__day.is-out { visibility: hidden; pointer-events: none; }
.tabs__tab:not(.is-active):is(:hover, .is-hover) { color: var(--fg); }
.tabs__tab:disabled { opacity: .35; cursor: not-allowed; }
.stepper--sm .stepper__value { font-size: 40px; }
.stepper--sm .stepper__btn { width: 36px; height: 36px; }
.slider.is-disabled { opacity: .4; pointer-events: none; }
.rating--lg .rating__btn { flex-basis: 40px; }
.rating.is-readonly .rating__btn { pointer-events: none; }
.radio:not(.is-checked):is(:hover, .is-hover) .radio__dot { box-shadow: inset 0 0 0 1.5px var(--fg); }
.radio.is-disabled { opacity: .4; pointer-events: none; }
.msg--static { height: auto; padding-top: 8px; }              /* 寫在 HTML 裡的訊息：不需要從 0 長出來 */
.avatar--more { font-size: 12px; }
.avatar img { width: 100%; height: 100%; border-radius: inherit; object-fit: cover; }
.tags--sm .tag { height: 30px; padding: 0 12px 0 8px; font-size: 12px; }
.tag:not(.is-on):is(:hover, .is-hover) { background: var(--fill-2); }
.tag.is-on:is(:hover, .is-hover) { background: color-mix(in srgb, var(--fg) 82%, var(--bg)); }
.tag:disabled { opacity: .4; cursor: not-allowed; }
.select:not(.is-open) .select__trigger:is(:hover, .is-hover) { background: var(--fill-2); }
.select.is-disabled .select__trigger { opacity: .4; cursor: not-allowed; }
.faq__item:not(.is-open) .faq__q:is(:hover, .is-hover) .faq__icon { background: var(--fill-2); }

/* ---- 狀態：按下（放在最後，蓋過各元件自己的 transition 時間） ------------ */
.is-pressed, .pressable:active { scale: .9; transition-duration: .1s; transition-timing-function: ease-out; }
.submit.is-pressed, .submit:active, .select__trigger.is-pressed, .select__trigger:active { scale: .95; }
.radio, .select__opt, .step, .search__item, .audio__wave { cursor: pointer; }

/* ---- 關鍵影格 ------------------------------------------------------------ */
@keyframes roll-in { from { transform: translateY(calc(var(--dir, 1) * 85%)); opacity: 0; } }
@keyframes roll-out { to { transform: translateY(calc(var(--dir, 1) * -85%)); opacity: 0; } }
@keyframes slide-in { from { transform: translateX(calc(var(--dir, 1) * 20px)); opacity: 0; } }
@keyframes slide-out { to { transform: translateX(calc(var(--dir, 1) * -20px)); opacity: 0; } }
@keyframes blink { 50% { opacity: 0; } }
@keyframes spin { to { rotate: 360deg; } }
@keyframes pop { from { scale: .55; } }
@keyframes pop-in { from { scale: .2; opacity: 0; } }
@keyframes pop-out { to { scale: .2; opacity: 0; } }
@keyframes star-pop { from { scale: .2; rotate: -40deg; } }
@keyframes hop { 30% { translate: 0 -9px; } 60% { translate: 0 2px; } 100% { translate: 0 0; } }
@keyframes shake {
  0%, 100% { translate: 0 0; } 15% { translate: -9px 0; } 30% { translate: 8px 0; }
  45% { translate: -6px 0; } 60% { translate: 4px 0; } 80% { translate: -2px 0; }
}
@keyframes pulse {
  from { box-shadow: 0 0 0 0 color-mix(in srgb, var(--hi) 55%, transparent); }
  to { box-shadow: 0 0 0 9px transparent; }
}
@keyframes bubble-in { from { opacity: 0; transform: translateY(14px) scale(.55); } }
@keyframes bubble-swap { from { transform: scale(.88); } }
@keyframes typing-dot { 0%, 60%, 100% { translate: 0 0; opacity: .45; } 30% { translate: 0 -4px; opacity: 1; } }
@keyframes bar-pop { 0% { scale: 1 1; } 22% { scale: 1 1.55; } 100% { scale: 1 1; } }
@keyframes avatar-in { from { margin-left: -40px; scale: 0; opacity: 0; } }
@keyframes toast-in { from { transform: translateY(74px) scale(.9); opacity: 0; } }
@keyframes shimmer { to { background-position: 0 0; } }
