/* ===== 色彩與設計變數 ===== */
:root {
  /* 奶油米 × 鼠尾草灰綠的中性底 */
  --ink: #1D1C1A;
  --ink-2: #5F5C56;
  --ink-3: #9C988F;
  --bg-a: #F4EFE8;
  --bg-b: #E6E7DD;
  --line: rgba(29, 28, 26, .07);

  /* 液態玻璃 */
  --glass: linear-gradient(150deg, rgba(255, 255, 255, .66) 0%, rgba(255, 255, 255, .30) 55%, rgba(255, 255, 255, .44) 100%);
  --glass-solid: rgba(255, 255, 255, .72);
  --glass-soft: rgba(255, 255, 255, .42);
  --rim: rgba(255, 255, 255, .78);
  --rim-shadow:
    inset 0 1.5px 0 rgba(255, 255, 255, .95),
    inset 0 -1px 0 rgba(255, 255, 255, .45),
    inset 1px 0 0 rgba(255, 255, 255, .35),
    inset -1px 0 0 rgba(255, 255, 255, .2);
  --inner-glow:
    inset 0 18px 28px -22px rgba(255, 255, 255, .95),
    inset 0 -22px 30px -24px rgba(255, 255, 255, .8);
  --drop: 0 28px 50px -30px rgba(74, 62, 44, .38), 0 4px 12px -6px rgba(74, 62, 44, .10);
  --drop-sm: 0 10px 22px -12px rgba(74, 62, 44, .35), 0 2px 5px -2px rgba(74, 62, 44, .12);
  --well: inset 0 2px 5px rgba(74, 62, 44, .10), inset 0 -1px 0 rgba(255, 255, 255, .7);

  /* 黑色膠囊按鈕 */
  --solid: #1E1D1B;
  --on-solid: #FFFFFF;

  /* 每個階段各自的光球色 */
  --orb-a: #FF7A2E;
  --orb-b: #FFC89A;
  --accent: #F07A36;
  --accent-deep: #B8541A;
  --tint: rgba(255, 146, 84, .20);
  --blob1: #FFD9BC;
  --blob2: #DDE4D2;
  --blob3: #F4D9D4;
  --blob4: #F8E7C8;

  --danger: #C8574F;
  --radius-lg: 30px;
  --radius: 22px;
  --radius-sm: 16px;
  --font: 'Noto Sans TC', -apple-system, 'PingFang TC', 'Microsoft JhengHei', system-ui, sans-serif;
  --num: 'Outfit', 'Noto Sans TC', system-ui, sans-serif;
  color-scheme: light;
}
body[data-phase="short"] {
  --orb-a: #F6D92E; --orb-b: #FFF1A0;
  --accent: #E3C21F; --accent-deep: #857010;
  --tint: rgba(254, 233, 81, .26);
  --blob1: #FBF0B8; --blob4: #E9EFD8;
}
body[data-phase="long"] {
  --orb-a: #4FBEAA; --orb-b: #BDEDE2;
  --accent: #58B8A5; --accent-deep: #2A8070;
  --tint: rgba(110, 205, 186, .24);
  --blob1: #CDEDE3; --blob4: #F3DCD8;
}

@media (prefers-color-scheme: dark) {
  :root {
    --ink: #F3EFE8;
    --ink-2: #B7B1A7;
    --ink-3: #7E796F;
    --bg-a: #1B1916;
    --bg-b: #151714;
    --line: rgba(255, 255, 255, .08);
    --glass: linear-gradient(150deg, rgba(255, 255, 255, .11) 0%, rgba(255, 255, 255, .04) 55%, rgba(255, 255, 255, .07) 100%);
    --glass-solid: rgba(255, 255, 255, .10);
    --glass-soft: rgba(255, 255, 255, .06);
    --rim: rgba(255, 255, 255, .12);
    --rim-shadow:
      inset 0 1px 0 rgba(255, 255, 255, .22),
      inset 0 -1px 0 rgba(255, 255, 255, .05),
      inset 1px 0 0 rgba(255, 255, 255, .06),
      inset -1px 0 0 rgba(255, 255, 255, .04);
    --inner-glow:
      inset 0 18px 28px -22px rgba(255, 255, 255, .14),
      inset 0 -22px 30px -24px rgba(255, 255, 255, .08);
    --drop: 0 28px 50px -30px rgba(0, 0, 0, .8), 0 4px 12px -6px rgba(0, 0, 0, .4);
    --drop-sm: 0 10px 22px -12px rgba(0, 0, 0, .7);
    --well: inset 0 2px 6px rgba(0, 0, 0, .35), inset 0 -1px 0 rgba(255, 255, 255, .05);
    --solid: #F3EEE6;
    --on-solid: #1D1C1A;
    --blob1: #5A3120;
    --blob2: #26302A;
    --blob3: #3A2A2A;
    --blob4: #3A3222;
    --tint: rgba(255, 130, 60, .14);
    color-scheme: dark;
  }
  body[data-phase="short"] { --blob1: #4F4618; --blob4: #283024; --tint: rgba(246, 217, 46, .12); }
  body[data-phase="long"] { --blob1: #173F37; --blob4: #3A2A2A; --tint: rgba(79, 190, 170, .14); }
}

/* ===== 基礎 ===== */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg-b);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
button:disabled { opacity: .3; cursor: default; }
svg { display: block; }
[hidden] { display: none !important; }
h2, h3, p { margin: 0; }

.bg {
  position: fixed; inset: 0; z-index: -1; overflow: hidden; pointer-events: none;
  background: linear-gradient(165deg, var(--bg-a) 10%, var(--bg-b) 90%);
}
.blob {
  position: absolute; border-radius: 50%; filter: blur(90px);
  transition: background 1.4s ease;
}
.b1 { width: 50vmax; height: 50vmax; top: -16vmax; right: -12vmax; background: var(--blob1); opacity: .95; }
.b2 { width: 48vmax; height: 48vmax; bottom: -18vmax; left: -14vmax; background: var(--blob2); }
.b3 { width: 26vmax; height: 26vmax; bottom: 6%; right: 8%; background: var(--blob3); opacity: .8; }
.b4 { width: 30vmax; height: 30vmax; top: 30%; left: 18%; background: var(--blob4); opacity: .7; }

.app {
  max-width: 1120px;
  margin: 0 auto;
  padding: max(22px, env(safe-area-inset-top)) 16px calc(112px + env(safe-area-inset-bottom));
}

/* ===== 液態玻璃：卡片共用 ===== */
.card, .tabs, .sheet-inner, .toast, .date-nav {
  position: relative;
  isolation: isolate;
  background: var(--glass);
  border: 1px solid var(--rim);
  box-shadow: var(--rim-shadow), var(--inner-glow), var(--drop);
  backdrop-filter: blur(26px) saturate(170%);
  -webkit-backdrop-filter: blur(26px) saturate(170%);
}
/* 左上的鏡面反光 + 右下透出的色光 */
.card::before, .card::after {
  content: ''; position: absolute; inset: 0; border-radius: inherit; pointer-events: none; z-index: -1;
}
.card::before {
  background: radial-gradient(120% 70% at 15% -10%, rgba(255, 255, 255, .55), transparent 55%);
}
.card::after {
  background: radial-gradient(70% 60% at 95% 105%, var(--tint), transparent 70%);
  transition: background 1.2s;
}
@media (prefers-color-scheme: dark) {
  .card::before { background: radial-gradient(120% 70% at 15% -10%, rgba(255, 255, 255, .08), transparent 55%); }
}

/* ===== 頂部 ===== */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  margin-bottom: 22px;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark { width: 42px; height: 42px; border-radius: 13px; box-shadow: var(--drop-sm); }
.brand strong { display: block; font-family: var(--num); font-weight: 500; font-size: 19px; letter-spacing: -.2px; }
.brand small { color: var(--ink-3); font-size: 12px; }

.tabs { display: flex; gap: 4px; padding: 5px; border-radius: 999px; }
.tabs button {
  display: flex; align-items: center; gap: 6px;
  padding: 9px 18px; border-radius: 999px;
  font-size: 14px; font-weight: 500; color: var(--ink-2);
  transition: background .25s, color .25s, box-shadow .25s;
}
.tabs button svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.tabs button.active { background: var(--solid); color: var(--on-solid); box-shadow: var(--drop-sm); }

/* ===== 卡片內容 ===== */
.card { border-radius: var(--radius-lg); padding: 22px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.card-head.spaced { margin-top: 26px; }
.card-head h2 { font-size: 15px; font-weight: 500; letter-spacing: .3px; }
.card-head small, .muted { color: var(--ink-3); font-size: 12px; }
.eyebrow { font-size: 11px; letter-spacing: 1.6px; font-weight: 500; color: var(--ink-3); text-transform: uppercase; }

.view { display: none; animation: rise .5s cubic-bezier(.2, .8, .2, 1); }
.view.active { display: block; }
@keyframes rise { from { opacity: 0; transform: translateY(12px); } }

/* ===== 按鈕 ===== */
.main-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 14px;
  min-width: 170px; padding: 17px 32px; border-radius: 999px;
  font-size: 16px; font-weight: 500; letter-spacing: .5px;
  background: var(--solid); color: var(--on-solid);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .18), 0 18px 30px -16px rgba(20, 18, 14, .6);
  transition: transform .15s, background .3s, color .3s, box-shadow .3s;
}
.main-btn:active { transform: scale(.97); }
.main-btn.with-icon { padding: 8px 8px 8px 30px; }
.btn-icon {
  display: grid; place-items: center; width: 46px; height: 46px; border-radius: 50%;
  background: rgba(255, 255, 255, .16); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .25);
}
@media (prefers-color-scheme: dark) { .btn-icon { background: rgba(0, 0, 0, .08); } }
.btn-icon svg { width: 20px; height: 20px; fill: currentColor; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.btn-icon .i-pause { display: none; fill: none; }
.main-btn.is-running {
  background: var(--glass-solid); color: var(--ink);
  box-shadow: var(--rim-shadow), var(--drop-sm);
}
.main-btn.is-running .btn-icon { background: var(--solid); color: var(--on-solid); }
.main-btn.is-running .i-play { display: none; }
.main-btn.is-running .i-pause { display: block; }
.main-btn.small { min-width: 0; padding: 11px 22px; font-size: 14px; }

.icon-btn {
  display: grid; place-items: center; flex: none;
  width: 54px; height: 54px; border-radius: 50%;
  background: var(--glass); border: 1px solid var(--rim);
  box-shadow: var(--rim-shadow), var(--inner-glow), var(--drop-sm);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  color: var(--ink-2); transition: transform .15s, color .2s;
}
.icon-btn:hover { color: var(--ink); }
.icon-btn:active { transform: scale(.94); }
.icon-btn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn.small { width: 34px; height: 34px; background: transparent; border-color: transparent; box-shadow: none; backdrop-filter: none; -webkit-backdrop-filter: none; }
.icon-btn.small svg { width: 16px; height: 16px; }

.ghost-btn {
  padding: 10px 18px; border-radius: 999px; font-size: 14px; font-weight: 500;
  background: var(--glass-solid); border: 1px solid var(--rim); color: var(--ink);
  box-shadow: var(--rim-shadow), var(--drop-sm);
  transition: transform .15s;
}
.ghost-btn:active { transform: scale(.97); }
.ghost-btn.small { padding: 7px 15px; font-size: 13px; }
.ghost-btn.danger, .text-btn.danger { color: var(--danger); }
.text-btn { font-size: 13px; font-weight: 500; color: var(--ink-2); padding: 4px 2px; text-decoration: underline; text-decoration-color: var(--line); text-underline-offset: 4px; }
.btn-group { display: flex; gap: 8px; }
.btn-group.wrap { flex-wrap: wrap; }

/* ===== 分段控制（液態玻璃凹槽 + 浮起的玻璃鈕） ===== */
.phase-switch, .seg {
  display: flex; gap: 4px; padding: 5px; border-radius: 999px;
  background: var(--glass-soft); box-shadow: var(--well);
}
.phase-switch button, .seg button {
  flex: 1; padding: 8px 18px; border-radius: 999px; font-size: 13px; font-weight: 500; color: var(--ink-2);
  white-space: nowrap;
  transition: background .3s, color .3s, box-shadow .3s;
}
.phase-switch button.active, .seg button.active {
  color: var(--ink);
  background: linear-gradient(180deg, rgba(255, 255, 255, .98), rgba(255, 255, 255, .7));
  box-shadow: inset 0 1px 0 #fff, inset 0 -2px 4px rgba(74, 62, 44, .06), var(--drop-sm);
}
.phase-switch button.active::before {
  content: ''; display: inline-block; width: 7px; height: 7px; margin-right: 7px; border-radius: 50%;
  background: var(--orb-a); box-shadow: 0 0 8px var(--orb-a); vertical-align: 1px;
}
@media (prefers-color-scheme: dark) {
  .phase-switch button.active, .seg button.active {
    background: linear-gradient(180deg, rgba(255, 255, 255, .2), rgba(255, 255, 255, .1));
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, .25), var(--drop-sm);
  }
}

/* ===== 計時頁 ===== */
.timer-grid { display: grid; grid-template-columns: 1.1fr 1fr; gap: 22px; align-items: start; }
.side { display: grid; gap: 22px; }

.timer-card { display: flex; flex-direction: column; align-items: center; padding: 26px 20px 24px; overflow: hidden; }

.ring-wrap { position: relative; width: min(78vw, 340px); aspect-ratio: 1; margin: 30px 0 22px; }

/* 柔霧光球 */
.orb {
  position: absolute; width: 62%; aspect-ratio: 1; right: -4%; bottom: 2%; border-radius: 50%;
  background: radial-gradient(circle at 38% 36%, var(--orb-b) 0%, var(--orb-a) 58%, transparent 72%);
  filter: blur(18px); opacity: .9;
  transition: background 1.2s, transform 1.2s;
}
body[data-status="running"] .orb { animation: breathe 5s ease-in-out infinite; }
@keyframes breathe {
  0%, 100% { transform: scale(1) translate(0, 0); }
  50% { transform: scale(1.08) translate(-3%, -2%); }
}

.ring { position: relative; width: 100%; height: 100%; transform: rotate(-90deg); }
.ring circle { fill: none; }
.ring-track { stroke: var(--line); stroke-width: 2; }
.ring-bar {
  stroke: var(--ink); stroke-width: 3; stroke-linecap: round;
  stroke-dasharray: 678.58; stroke-dashoffset: 0;
  transition: stroke-dashoffset .3s linear;
}
.ring-center {
  position: absolute; inset: 11%; border-radius: 50%;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: linear-gradient(150deg, rgba(255, 255, 255, .62), rgba(255, 255, 255, .18) 60%, rgba(255, 255, 255, .35));
  border: 1px solid var(--rim);
  box-shadow:
    inset 0 2px 1px rgba(255, 255, 255, .9),
    inset 0 -10px 24px -8px rgba(255, 255, 255, .7),
    inset 10px 0 30px -18px rgba(255, 255, 255, .8),
    0 30px 50px -30px rgba(74, 62, 44, .45);
  backdrop-filter: blur(14px) saturate(160%);
  -webkit-backdrop-filter: blur(14px) saturate(160%);
}
.ring-center::before {
  content: ''; position: absolute; top: 7%; left: 18%; width: 46%; height: 22%; border-radius: 50%;
  background: radial-gradient(closest-side, rgba(255, 255, 255, .75), transparent);
  transform: rotate(-24deg); pointer-events: none;
}
@media (prefers-color-scheme: dark) {
  .ring-center {
    background: linear-gradient(150deg, rgba(255, 255, 255, .12), rgba(255, 255, 255, .03) 60%, rgba(255, 255, 255, .06));
    box-shadow: inset 0 1px 1px rgba(255, 255, 255, .25), inset 0 -10px 24px -8px rgba(255, 255, 255, .06), 0 30px 50px -30px #000;
  }
  .ring-center::before { opacity: .15; }
}
.time {
  position: relative;
  font-family: var(--num); font-weight: 200; font-size: clamp(58px, 17vw, 82px);
  letter-spacing: -2px; font-variant-numeric: tabular-nums; line-height: 1;
}
.phase-label { position: relative; margin-top: 12px; font-size: 13px; color: var(--ink-2); max-width: 80%; text-align: center; }

.cycle { display: flex; align-items: center; gap: 8px; margin-bottom: 24px; }
.cycle span {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--glass-soft); box-shadow: var(--well); transition: all .35s;
}
.cycle span.done { background: var(--ink); box-shadow: none; }
.cycle span.now { width: 26px; border-radius: 99px; background: radial-gradient(circle at 40% 40%, var(--orb-b), var(--orb-a)); box-shadow: 0 0 10px var(--orb-a); }
.cycle small { margin-left: 8px; font-size: 12px; color: var(--ink-3); font-family: var(--num); }

.controls { display: flex; align-items: center; gap: 16px; }
.hint { margin-top: 18px; font-size: 11px; color: var(--ink-3); }

/* 任務膠囊 */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 9px 16px; border-radius: 999px; font-size: 14px;
  background: var(--glass-solid); border: 1px solid var(--rim); color: var(--ink-2);
  box-shadow: var(--rim-shadow);
  transition: all .25s;
}
.chip.active { background: var(--solid); color: var(--on-solid); border-color: transparent; box-shadow: var(--drop-sm); }
.dot { width: 9px; height: 9px; border-radius: 50%; flex: none; box-shadow: 0 0 0 2px rgba(255, 255, 255, .5); }
.chip.active .dot { box-shadow: 0 0 8px currentColor; }

textarea, input.plain {
  width: 100%; border: 1px solid transparent; outline: none;
  background: var(--glass-soft); border-radius: var(--radius-sm);
  box-shadow: var(--well);
  padding: 13px 15px; font-size: 14px; line-height: 1.65;
  transition: border-color .2s, box-shadow .2s, background .2s;
}
textarea { resize: vertical; min-height: 104px; }
textarea:focus, input.plain:focus { background: var(--glass-solid); border-color: var(--rim); box-shadow: var(--rim-shadow), 0 0 0 4px var(--tint); }
::placeholder { color: var(--ink-3); }

/* 休息提醒卡 */
.tip-card {
  display: grid; grid-template-columns: auto 1fr; gap: 14px 18px; align-items: center;
  animation: rise .6s cubic-bezier(.2, .8, .2, 1);
}
.tip-card::after { background: radial-gradient(90% 90% at 0% 50%, var(--tint), transparent 70%); }
.tip-icon {
  position: relative; display: grid; place-items: center; width: 64px; height: 64px; border-radius: 50%;
  font-size: 28px;
  background: radial-gradient(circle at 35% 30%, rgba(255, 255, 255, .95), rgba(255, 255, 255, .35) 60%), radial-gradient(circle at 60% 70%, var(--orb-a), transparent 70%);
  box-shadow: inset 0 -6px 12px -4px rgba(255, 255, 255, .8), 0 12px 24px -12px var(--orb-a);
}
.tip-body h3 { font-size: 18px; font-weight: 500; margin: 4px 0; }
.tip-body p { font-size: 13px; color: var(--ink-2); line-height: 1.65; }
.tip-card .ghost-btn { grid-column: 1 / -1; justify-self: end; }

/* 今日小結：深色卡片 */
.card.mini {
  background: linear-gradient(150deg, rgba(34, 33, 30, .92), rgba(24, 23, 21, .86));
  border-color: rgba(255, 255, 255, .08);
  color: #F3EFE8;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .14), var(--drop);
}
.card.mini::before { background: radial-gradient(90% 60% at 10% -10%, rgba(255, 255, 255, .10), transparent 60%); }
.card.mini::after { background: radial-gradient(50% 70% at 100% 100%, var(--orb-a), transparent 70%); opacity: .35; }
.card.mini .card-head h2 { color: #F3EFE8; }
.card.mini .text-btn { color: rgba(243, 239, 232, .7); text-decoration-color: rgba(255, 255, 255, .2); }
@media (prefers-color-scheme: dark) {
  .card.mini { background: linear-gradient(150deg, rgba(255, 255, 255, .13), rgba(255, 255, 255, .05)); }
}
.mini-nums { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 16px; }
.mini-nums strong { display: block; font-family: var(--num); font-weight: 300; font-size: 26px; letter-spacing: -.5px; }
.mini-nums small { font-size: 12px; color: rgba(243, 239, 232, .55); }
.stack-bar { display: flex; gap: 3px; height: 8px; border-radius: 99px; overflow: hidden; }
.stack-bar i { display: block; min-width: 4px; border-radius: 99px; }
.stack-bar .bar-empty { flex: 1; background: rgba(255, 255, 255, .1); }

/* ===== 回顧頁 ===== */
.date-nav { display: flex; align-items: center; justify-content: space-between; padding: 12px; margin-bottom: 22px; border-radius: 999px; }
.date-nav .icon-btn { width: 46px; height: 46px; }
.date-label { text-align: center; }
.date-label strong { display: block; font-family: var(--num); font-size: 22px; font-weight: 300; letter-spacing: -.3px; }
.date-label small { font-size: 12px; color: var(--ink-3); }

.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 22px; }
.kpi { padding: 18px 20px; }
.kpi small { font-size: 12px; color: var(--ink-3); }
.kpi strong { display: block; margin-top: 8px; font-family: var(--num); font-size: 30px; font-weight: 200; letter-spacing: -1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi em { font-style: normal; font-size: 13px; color: var(--ink-2); letter-spacing: 0; }
.kpi-task { font-family: var(--font) !important; font-size: 20px !important; font-weight: 400 !important; letter-spacing: 0 !important; padding-top: 6px; }

.stats-grid { display: grid; grid-template-columns: 1fr 1.25fr; gap: 22px; align-items: start; }
.dist { display: grid; gap: 24px; }
.donut { position: relative; width: min(230px, 62vw); aspect-ratio: 1; margin: 0 auto; }
.donut svg { width: 100%; height: 100%; filter: drop-shadow(0 10px 16px rgba(74, 62, 44, .12)); }
.donut circle { fill: none; stroke-width: 16; }
.donut-track { stroke: var(--line); }
.donut-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.donut-center strong { font-family: var(--num); font-weight: 300; font-size: 22px; }
.donut-center small { font-size: 12px; color: var(--ink-3); }

.legend { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; }
.legend li { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 6px 10px; font-size: 14px; }
.legend-val { font-family: var(--num); font-weight: 400; }
.legend-val small { margin-left: 6px; color: var(--ink-3); font-weight: 300; }
.legend-bar { grid-column: 2 / -1; height: 6px; border-radius: 99px; background: var(--glass-soft); box-shadow: var(--well); overflow: hidden; }
.legend-bar i { display: block; height: 100%; border-radius: 99px; }

.timeline { padding-bottom: 22px; }
.timeline-track { position: relative; height: 40px; border-radius: 14px; background: var(--glass-soft); box-shadow: var(--well); overflow: hidden; }
.timeline-track i { position: absolute; top: 6px; bottom: 6px; min-width: 5px; border-radius: 8px; box-shadow: inset 0 1px 0 rgba(255, 255, 255, .5); }
.timeline-ticks { position: relative; height: 16px; margin-top: 8px; }
.timeline-ticks span { position: absolute; transform: translateX(-50%); font-size: 11px; color: var(--ink-3); font-family: var(--num); }
.timeline-ticks span:first-child { transform: none; }
.timeline-ticks span:last-child { transform: translateX(-100%); }

.sessions { display: grid; gap: 10px; }
.session {
  display: flex; gap: 12px; width: 100%; text-align: left;
  padding: 14px 16px; border-radius: var(--radius);
  background: var(--glass-solid); border: 1px solid var(--rim);
  box-shadow: var(--rim-shadow);
  transition: transform .15s;
}
.session:active { transform: scale(.99); }
.session-bar { width: 4px; border-radius: 99px; flex: none; }
.session-main { display: grid; gap: 4px; min-width: 0; flex: 1; }
.session-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 14px; }
.session-top strong { font-weight: 500; }
.session-time { margin-left: auto; font-family: var(--num); font-size: 12px; color: var(--ink-3); }
.session-note { font-size: 13px; color: var(--ink-2); line-height: 1.65; white-space: pre-wrap; overflow-wrap: anywhere; }
.session-note.empty { color: var(--ink-3); font-style: italic; }
.badge { font-size: 11px; padding: 2px 9px; border-radius: 99px; background: var(--glass-soft); box-shadow: var(--well); color: var(--ink-2); }

.empty-state { text-align: center; padding: 52px 20px; }
.empty-state h3 { font-size: 17px; font-weight: 500; margin-bottom: 6px; }
.empty-state p { font-size: 13px; color: var(--ink-3); }
.empty-art {
  width: 104px; height: 104px; margin: 0 auto 20px; border-radius: 50%;
  background: radial-gradient(circle at 38% 36%, var(--orb-b), var(--orb-a) 60%, transparent 72%);
  filter: blur(4px); opacity: .85;
}
.empty-art span { display: none; }

/* ===== 設定頁 ===== */
.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; align-items: start; }
.span-2 { grid-column: 1 / -1; }
.row {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  padding: 13px 0; border-top: 1px solid var(--line);
}
.card-head + .row, .card-head + .list { border-top: 0; }
.row.col { flex-direction: column; align-items: stretch; }
.row-text { display: grid; gap: 3px; min-width: 0; }
.row-text strong { font-size: 14px; font-weight: 500; }
.row-text small { font-size: 12px; color: var(--ink-3); line-height: 1.55; }

.stepper {
  display: flex; align-items: center; gap: 2px; padding: 4px; border-radius: 999px; flex: none;
  background: var(--glass-soft); box-shadow: var(--well);
}
.stepper button {
  width: 34px; height: 34px; border-radius: 50%; font-size: 18px; color: var(--ink);
  background: linear-gradient(180deg, rgba(255, 255, 255, .95), rgba(255, 255, 255, .6));
  box-shadow: inset 0 1px 0 #fff, var(--drop-sm);
}
@media (prefers-color-scheme: dark) { .stepper button { background: rgba(255, 255, 255, .12); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .2); } }
.stepper button:active { transform: scale(.92); }
.stepper input {
  width: 46px; border: 0; background: none; text-align: center; outline: none;
  font-family: var(--num); font-size: 20px; font-weight: 300; -moz-appearance: textfield;
}
.stepper input::-webkit-inner-spin-button, .stepper input::-webkit-outer-spin-button { -webkit-appearance: none; }
.stepper span { font-size: 12px; color: var(--ink-3); margin-right: 6px; }

.seg button { padding: 9px 0; min-width: 40px; font-family: var(--num); font-size: 16px; }
.seg.small { padding: 4px; }
.seg.small button { padding: 5px 14px; font-family: var(--font); font-size: 13px; }

/* 開關：玻璃凹槽 + 光滑圓鈕，開啟時槽變深色 */
.switch {
  appearance: none; -webkit-appearance: none; flex: none; cursor: pointer; margin: 0;
  width: 54px; height: 32px; border-radius: 99px; position: relative;
  background: var(--glass-soft); box-shadow: var(--well);
  transition: background .3s;
}
.switch::after {
  content: ''; position: absolute; top: 3px; left: 3px; width: 26px; height: 26px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff, #F1EEE9 70%);
  box-shadow: inset 0 -2px 3px rgba(0, 0, 0, .06), 0 3px 8px rgba(40, 32, 20, .25);
  transition: transform .35s cubic-bezier(.3, 1.4, .5, 1);
}
.switch:checked { background: var(--solid); box-shadow: inset 0 1px 3px rgba(0, 0, 0, .3); }
.switch:checked::after { transform: translateX(22px); }

/* 音量：膠囊軌道 + 直條把手 */
.range {
  -webkit-appearance: none; appearance: none; width: 180px; height: 40px; margin: 0; cursor: pointer;
  border-radius: 14px; box-shadow: var(--well);
  background: linear-gradient(90deg, var(--glass-solid) 0 var(--val, 70%), var(--glass-soft) var(--val, 70%) 100%);
}
.range::-webkit-slider-thumb { -webkit-appearance: none; width: 4px; height: 20px; border-radius: 3px; background: var(--ink); }
.range::-moz-range-thumb { width: 4px; height: 20px; border: 0; border-radius: 3px; background: var(--ink); }
.range::-moz-range-track { background: transparent; }

.list { display: grid; }
.list-row { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-top: 1px solid var(--line); }
.list-row:first-child { border-top: 0; }
.list-row input.plain { padding: 9px 13px; }
.list-row .row-text { flex: 1; }
.swatch {
  -webkit-appearance: none; appearance: none; flex: none; cursor: pointer;
  width: 32px; height: 32px; border: 0; border-radius: 50%; padding: 0; background: none;
  box-shadow: inset 0 0 0 3px rgba(255, 255, 255, .7), 0 6px 12px -6px rgba(0, 0, 0, .35);
}
.swatch::-webkit-color-swatch-wrapper { padding: 0; }
.swatch::-webkit-color-swatch { border: 3px solid rgba(255, 255, 255, .75); border-radius: 50%; }
.swatch::-moz-color-swatch { border: 3px solid rgba(255, 255, 255, .75); border-radius: 50%; }
.tip-emoji {
  width: 42px; height: 42px; display: grid; place-items: center; font-size: 20px; border-radius: 50%; flex: none;
  background: radial-gradient(circle at 35% 30%, rgba(255, 255, 255, .95), rgba(255, 255, 255, .45));
  box-shadow: inset 0 -3px 6px -2px rgba(255, 255, 255, .8), var(--drop-sm);
}
@media (prefers-color-scheme: dark) { .tip-emoji { background: rgba(255, 255, 255, .1); } }

.add-btn {
  width: 100%; margin-top: 12px; padding: 13px; border-radius: var(--radius-sm);
  border: 1.5px dashed var(--line); color: var(--ink-2); font-size: 14px; font-weight: 500;
  background: var(--glass-soft);
}
.add-btn:hover { color: var(--ink); }
.tip-form { display: grid; grid-template-columns: 58px 1fr 1.6fr auto; gap: 8px; margin-top: 16px; }
.emoji-input { text-align: center; }

/* ===== 對話框與提示 ===== */
dialog.sheet { border: 0; padding: 0; background: transparent; width: min(480px, calc(100% - 32px)); max-height: calc(100% - 32px); color: var(--ink); overflow: visible; }
dialog.sheet::backdrop { background: rgba(40, 32, 22, .22); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
dialog.sheet[open] { animation: pop .4s cubic-bezier(.2, .9, .3, 1.2); }
@keyframes pop { from { opacity: 0; transform: translateY(18px) scale(.97); } }
.sheet-inner {
  display: grid; gap: 10px; padding: 26px; border-radius: var(--radius-lg);
  background: linear-gradient(150deg, rgba(255, 255, 255, .88), rgba(255, 255, 255, .66));
}
@media (prefers-color-scheme: dark) { .sheet-inner { background: linear-gradient(150deg, rgba(48, 46, 42, .92), rgba(34, 33, 30, .9)); } }
.sheet-inner h2 { font-size: 21px; font-weight: 500; }
.field-label { font-size: 12px; font-weight: 500; color: var(--ink-3); margin-top: 8px; }
.sheet-actions { display: flex; align-items: center; gap: 8px; margin-top: 10px; }
.spacer { flex: 1; }

.toast {
  position: fixed; left: 50%; top: max(16px, env(safe-area-inset-top)); z-index: 50;
  transform: translate(-50%, -150%); opacity: 0;
  padding: 12px 22px; border-radius: 999px; font-size: 14px; font-weight: 500;
  background: linear-gradient(150deg, rgba(255, 255, 255, .9), rgba(255, 255, 255, .7));
  transition: transform .45s cubic-bezier(.2, .9, .3, 1.2), opacity .3s; pointer-events: none;
  max-width: calc(100% - 32px);
}
@media (prefers-color-scheme: dark) { .toast { background: rgba(48, 46, 42, .92); } }
.toast.show { transform: translate(-50%, 0); opacity: 1; }

/* ===== 手機版 ===== */
@media (max-width: 820px) {
  .timer-grid, .stats-grid, .settings-grid { grid-template-columns: 1fr; }
  .kpis { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 640px) {
  .app { padding-top: max(16px, env(safe-area-inset-top)); }
  .topbar { margin-bottom: 16px; }
  .tabs {
    position: fixed; z-index: 20; left: 16px; right: 16px;
    bottom: calc(12px + env(safe-area-inset-bottom));
    justify-content: space-around; padding: 6px;
    background: linear-gradient(150deg, rgba(255, 255, 255, .8), rgba(255, 255, 255, .55));
  }
  @media (prefers-color-scheme: dark) { .tabs { background: rgba(40, 38, 35, .85); } }
  .tabs button { flex: 1; flex-direction: column; gap: 2px; padding: 8px 0; font-size: 11px; }
  .tabs button svg { width: 22px; height: 22px; }
  .card { padding: 18px; border-radius: 26px; }
  .timer-grid, .side, .stats-grid, .settings-grid { gap: 14px; }
  .kpis { gap: 10px; margin-bottom: 14px; }
  .kpi strong { font-size: 26px; }
  .date-nav { margin-bottom: 14px; }
  .controls { gap: 12px; }
  .main-btn.with-icon { min-width: 160px; padding-left: 24px; }
  .hint { display: none; }
  .tip-form { grid-template-columns: 58px 1fr; }
  .tip-form .wide { grid-column: 1 / -1; }
  .tip-form .main-btn { grid-column: 1 / -1; }
  .range { width: 140px; }
  .session-time { margin-left: 0; width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
