/* ==========================================================================
   唉 · 嘆氣計數器
   風格：黃昏日記。深藍夜色、琥珀燈光、宋體標題、直排標籤。
   ========================================================================== */

/* ---------- 色票與字型 ---------- */
:root {
  --font-ui: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", system-ui, sans-serif;
  --font-serif: "Noto Serif TC", "Songti TC", "PMingLiU", "Noto Serif CJK TC", serif;
  --font-num: "Fraunces", "Noto Serif TC", Georgia, serif;

  --bg-0: #0d1120;
  --bg-1: #131829;
  --bg-2: #1a2036;
  --bg-3: #242b46;
  --ink: #f1e9da;
  --ink-2: #b8b2a7;
  --ink-3: #85838f;
  --line: rgba(241, 233, 218, 0.1);
  --line-strong: rgba(241, 233, 218, 0.22);
  --amber: #f0b365;
  --amber-2: #e0903c;
  --amber-ink: #2b1a08;
  --amber-glow: rgba(240, 179, 101, 0.32);
  --amber-soft: rgba(240, 179, 101, 0.1);
  --rose: #e2a1a1;
  --glow-a: rgba(240, 179, 101, 0.2);
  --glow-b: rgba(106, 74, 140, 0.5);
  --grain-opacity: 0.08;
  --card-shadow: 0 30px 60px -36px rgba(0, 0, 0, 0.75);
  --toast-bg: #f1e9da;
  --toast-ink: #0d1120;
  --radius: 22px;
  color-scheme: dark;
}

:root[data-theme="light"] {
  --bg-0: #f4eee3;
  --bg-1: #ece4d6;
  --bg-2: #fbf6ec;
  --bg-3: #ffffff;
  --ink: #1d1a2b;
  --ink-2: #5a5666;
  --ink-3: #8a8694;
  --line: rgba(29, 26, 43, 0.1);
  --line-strong: rgba(29, 26, 43, 0.22);
  --amber: #e29a3f;
  --amber-2: #c9722a;
  --amber-ink: #2b1a08;
  --amber-glow: rgba(226, 154, 63, 0.3);
  --amber-soft: rgba(226, 154, 63, 0.14);
  --rose: #c25e5e;
  --glow-a: rgba(240, 179, 101, 0.4);
  --glow-b: rgba(183, 155, 214, 0.45);
  --grain-opacity: 0.06;
  --card-shadow: 0 24px 50px -34px rgba(60, 40, 20, 0.35);
  --toast-bg: #1d1a2b;
  --toast-ink: #f4eee3;
  color-scheme: light;
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg-0: #f4eee3;
    --bg-1: #ece4d6;
    --bg-2: #fbf6ec;
    --bg-3: #ffffff;
    --ink: #1d1a2b;
    --ink-2: #5a5666;
    --ink-3: #8a8694;
    --line: rgba(29, 26, 43, 0.1);
    --line-strong: rgba(29, 26, 43, 0.22);
    --amber: #e29a3f;
    --amber-2: #c9722a;
    --amber-ink: #2b1a08;
    --amber-glow: rgba(226, 154, 63, 0.3);
    --amber-soft: rgba(226, 154, 63, 0.14);
    --rose: #c25e5e;
    --glow-a: rgba(240, 179, 101, 0.4);
    --glow-b: rgba(183, 155, 214, 0.45);
    --grain-opacity: 0.06;
    --card-shadow: 0 24px 50px -34px rgba(60, 40, 20, 0.35);
    --toast-bg: #1d1a2b;
    --toast-ink: #f4eee3;
    color-scheme: light;
  }
}

/* ---------- 基礎 ---------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg-0);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) 0 env(safe-area-inset-left);
}

a {
  color: var(--amber);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

button {
  font-family: inherit;
}

:focus-visible {
  outline: 2px solid var(--amber);
  outline-offset: 3px;
}

/* 任何元素只要有 hidden 屬性就一定藏起來，不讓 .btn 之類的 display 蓋過 */
[hidden] {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.muted {
  color: var(--ink-3);
}

/* ---------- 氛圍：光暈與顆粒 ---------- */
.atmosphere {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}

.glow {
  position: absolute;
  border-radius: 50%;
}

.glow-a {
  width: 90vmax;
  height: 90vmax;
  left: -38vmax;
  bottom: -45vmax;
  background: radial-gradient(circle, var(--glow-a) 0%, transparent 62%);
}

.glow-b {
  width: 80vmax;
  height: 80vmax;
  right: -30vmax;
  top: -40vmax;
  background: radial-gradient(circle, var(--glow-b) 0%, transparent 62%);
}

.grain {
  position: absolute;
  inset: 0;
  opacity: var(--grain-opacity);
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0.6 0 0 0 0 0.6 0 0 0 0 0.6 0 0 0 1 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ---------- 頁首 ---------- */
.top {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 20px;
  max-width: 1180px;
  margin: 0 auto;
  padding: 22px clamp(18px, 4vw, 40px) 6px;
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-right: auto;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  font-family: var(--font-serif);
  font-size: 30px;
  font-weight: 600;
  letter-spacing: 0.02em;
  line-height: 1;
}

.brand-sub {
  font-size: 12px;
  letter-spacing: 0.3em;
  color: var(--ink-3);
}

.tabs {
  display: flex;
  gap: 2px;
}

.tabs [role="tab"] {
  appearance: none;
  position: relative;
  border: 0;
  background: none;
  color: var(--ink-2);
  font-size: 15px;
  letter-spacing: 0.1em;
  padding: 8px 12px;
  border-radius: 10px;
  cursor: pointer;
  transition: color 0.2s;
}

.tabs [role="tab"]::after {
  content: "";
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 3px;
  height: 2px;
  border-radius: 2px;
  background: var(--amber);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.25s cubic-bezier(0.2, 0.7, 0.2, 1);
}

.tabs [role="tab"]:hover {
  color: var(--ink);
}

.tabs [role="tab"][aria-selected="true"] {
  color: var(--ink);
}

.tabs [role="tab"][aria-selected="true"]::after {
  transform: scaleX(1);
}

.icon-btn {
  appearance: none;
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  background: transparent;
  color: var(--ink-2);
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s, transform 0.2s;
}

.icon-btn:hover {
  color: var(--ink);
  border-color: var(--ink-2);
  transform: rotate(-12deg);
}

.icon-btn .icon-sun,
.icon-btn[data-mode="light"] .icon-moon {
  display: none;
}

.icon-btn[data-mode="light"] .icon-sun {
  display: block;
}

/* ---------- 版面 ---------- */
.page {
  position: relative;
  z-index: 1;
  max-width: 1180px;
  margin: 0 auto;
  padding: 6px clamp(18px, 4vw, 40px) 64px;
  /* 按鈕的擴散光環會暫時超出畫面，只裁掉水平方向，不影響垂直捲動 */
  overflow-x: clip;
}

.view[hidden] {
  display: none;
}

/* ---------- 記錄：主視覺 ---------- */
.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.85fr);
  align-items: center;
  gap: clamp(24px, 4vw, 56px);
  min-height: 50vh;
  padding: 24px 0 8px;
}

.hero-count {
  position: relative;
  padding-left: 36px;
}

.vertical-label {
  position: absolute;
  left: 0;
  top: 10px;
  writing-mode: vertical-rl;
  font-family: var(--font-serif);
  font-size: 13px;
  letter-spacing: 0.45em;
  color: var(--ink-3);
}

.vertical-label::before {
  content: "";
  position: absolute;
  left: 50%;
  top: calc(100% + 12px);
  width: 1px;
  height: 44px;
  background: var(--line-strong);
}

.today-date {
  margin: 0 0 4px;
  font-size: 13px;
  letter-spacing: 0.14em;
  color: var(--ink-3);
}

.count-wrap {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin: 0;
}

.count {
  font-family: var(--font-num);
  font-variation-settings: "opsz" 144, "SOFT" 80, "WONK" 1;
  font-weight: 300;
  font-size: clamp(120px, 22vw, 236px);
  line-height: 0.88;
  letter-spacing: -0.045em;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  display: inline-block;
}

@supports (-webkit-background-clip: text) or (background-clip: text) {
  .count {
    background: linear-gradient(180deg, var(--ink) 35%, var(--amber) 140%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
  }
}

.count.is-big {
  font-size: clamp(88px, 16vw, 168px);
}

.count.bump {
  animation: bump 0.55s cubic-bezier(0.2, 0.8, 0.2, 1);
}

@keyframes bump {
  0% {
    transform: scale(1);
  }
  30% {
    transform: scale(1.07) translateY(-4px);
  }
  100% {
    transform: scale(1);
  }
}

.unit {
  font-family: var(--font-serif);
  font-size: clamp(22px, 3vw, 34px);
  color: var(--ink-2);
}

.quote {
  position: relative;
  max-width: 34ch;
  min-height: 3.4em;
  margin: 20px 0 0;
  font-family: var(--font-serif);
  font-size: clamp(16px, 1.6vw, 19px);
  line-height: 1.8;
  color: var(--ink-2);
}

.quote::before {
  content: "「";
  position: absolute;
  left: -1em;
  color: var(--ink-3);
}

.quote::after {
  content: "」";
  color: var(--ink-3);
}

/* 大按鈕 */
.hero-action {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-self: center;
  margin-top: 10px;
}

.sigh-stage {
  position: relative;
  width: min(60vw, 250px);
  aspect-ratio: 1;
  display: grid;
  place-items: center;
}

.halo {
  position: absolute;
  inset: -12%;
  border-radius: 50%;
  background: radial-gradient(circle, var(--amber-glow) 0%, transparent 62%);
  animation: breathe 5.5s ease-in-out infinite;
}

@keyframes breathe {
  0%,
  100% {
    transform: scale(1);
    opacity: 0.8;
  }
  50% {
    transform: scale(1.12);
    opacity: 1;
  }
}

.sigh-btn {
  position: relative;
  z-index: 2;
  width: 100%;
  height: 100%;
  padding: 0;
  border: 0;
  border-radius: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  color: var(--amber-ink);
  font-family: var(--font-serif);
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  background: radial-gradient(circle at 36% 30%, #ffdcab 0%, var(--amber) 42%, var(--amber-2) 100%);
  box-shadow:
    0 0 0 12px var(--amber-soft),
    0 26px 60px -18px rgba(240, 179, 101, 0.55),
    0 0 90px var(--amber-glow),
    inset 0 -18px 34px rgba(110, 55, 0, 0.28),
    inset 0 14px 28px rgba(255, 255, 255, 0.32);
  transition: transform 0.16s cubic-bezier(0.2, 0.8, 0.2, 1), box-shadow 0.35s ease;
}

.sigh-btn:hover {
  box-shadow:
    0 0 0 16px var(--amber-soft),
    0 30px 70px -18px rgba(240, 179, 101, 0.65),
    0 0 120px var(--amber-glow),
    inset 0 -18px 34px rgba(110, 55, 0, 0.28),
    inset 0 14px 28px rgba(255, 255, 255, 0.36);
}

.sigh-btn:active,
.sigh-btn.is-pressed {
  transform: scale(0.93);
}

.sigh-glyph {
  font-size: clamp(56px, 10vw, 86px);
  font-weight: 600;
  line-height: 1;
  letter-spacing: 0.02em;
}

.sigh-reason {
  font-family: var(--font-ui);
  font-size: 12px;
  letter-spacing: 0.22em;
  opacity: 0.78;
}

.ring {
  position: absolute;
  inset: 0;
  z-index: 1;
  border-radius: 50%;
  border: 2px solid var(--amber);
  opacity: 0;
  pointer-events: none;
  animation: ring 1.1s cubic-bezier(0.2, 0.7, 0.2, 1) forwards;
}

@keyframes ring {
  0% {
    transform: scale(1);
    opacity: 0.9;
  }
  100% {
    transform: scale(1.9);
    opacity: 0;
  }
}

.float-layer {
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  overflow: visible;
}

.float {
  position: absolute;
  left: 50%;
  top: 20%;
  font-family: var(--font-serif);
  font-size: 30px;
  color: var(--ink);
  text-shadow: 0 2px 18px rgba(0, 0, 0, 0.35);
  animation: float-up 1.7s cubic-bezier(0.2, 0.6, 0.2, 1) forwards;
}

@keyframes float-up {
  0% {
    transform: translate(-50%, 0) rotate(0deg);
    opacity: 0;
  }
  12% {
    opacity: 1;
  }
  100% {
    transform: translate(calc(-50% + var(--dx, 0px)), -180px) rotate(var(--rot, 0deg));
    opacity: 0;
  }
}

.under-btn {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 22px;
  font-size: 13px;
  color: var(--ink-3);
}

.link-btn {
  appearance: none;
  border: 0;
  background: none;
  padding: 4px 2px;
  color: var(--ink-2);
  font-size: 13px;
  cursor: pointer;
  text-decoration: underline;
  text-decoration-color: var(--line-strong);
  text-underline-offset: 4px;
  transition: color 0.2s;
}

.link-btn:hover {
  color: var(--ink);
}

.link-btn:disabled {
  opacity: 0.4;
  cursor: default;
  text-decoration: none;
}

kbd {
  font: inherit;
  font-size: 12px;
  padding: 1px 6px;
  border: 1px solid var(--line-strong);
  border-bottom-width: 2px;
  border-radius: 6px;
}

/* 原因 */
.reasons-block {
  margin-top: 26px;
}

.reasons-title {
  margin: 0 0 10px;
  font-family: var(--font-serif);
  font-size: 14px;
  letter-spacing: 0.2em;
  color: var(--ink-3);
}

.reasons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  appearance: none;
  border: 1px solid var(--line-strong);
  background: transparent;
  color: var(--ink-2);
  font-size: 13.5px;
  letter-spacing: 0.08em;
  padding: 7px 15px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.2s, color 0.2s, border-color 0.2s, transform 0.15s;
}

.chip:hover {
  border-color: var(--ink-2);
  color: var(--ink);
}

.chip:active {
  transform: scale(0.96);
}

.chip[aria-pressed="true"] {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--bg-0);
}

/* ---------- 卡片 ---------- */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 16px;
  margin-top: 30px;
}

.card {
  position: relative;
  min-width: 0;
  padding: 20px 22px 22px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(165deg, var(--bg-2), var(--bg-1));
  box-shadow: var(--card-shadow);
}

.card h3 {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 12px;
  font-family: var(--font-serif);
  font-weight: 400;
  font-size: 13px;
  letter-spacing: 0.32em;
  color: var(--ink-3);
}

.tag {
  font-family: var(--font-ui);
  font-size: 10px;
  letter-spacing: 0.16em;
  padding: 1px 7px;
  border: 1px solid var(--amber-glow);
  border-radius: 6px;
  color: var(--amber);
}

.sub {
  margin: 0;
  font-size: 13px;
  color: var(--ink-3);
}

.big-num {
  font-family: var(--font-num);
  font-variation-settings: "opsz" 72, "SOFT" 50;
  font-size: 38px;
  font-weight: 400;
  line-height: 1.1;
  letter-spacing: -0.02em;
}

.chart-box {
  margin: 6px 0 8px;
}

.reveal {
  animation: rise 0.8s cubic-bezier(0.2, 0.7, 0.2, 1) both;
  animation-delay: calc(var(--i, 0) * 90ms);
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* 平靜卡 */
.calm-row {
  margin-bottom: 12px;
}

.mini-stats {
  display: flex;
  gap: 24px;
  margin: 0 0 14px;
}

.mini-stats div {
  min-width: 0;
}

.mini-stats dt {
  font-size: 12px;
  letter-spacing: 0.14em;
  color: var(--ink-3);
}

.mini-stats dd {
  margin: 0;
  font-family: var(--font-num);
  font-variation-settings: "opsz" 24;
  font-size: 18px;
}

/* 麥克風卡 */
.mic-head {
  display: flex;
  align-items: flex-start;
  gap: 16px;
}

.mic-head .sub {
  flex: 1;
}

#card-mic.is-on {
  border-color: var(--amber-glow);
}

.meter {
  height: 6px;
  margin: 14px 0 8px;
  border-radius: 3px;
  background: var(--bg-3);
  overflow: hidden;
}

.meter i {
  display: block;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, var(--ink-3), var(--amber));
  transform-origin: left;
  transform: scaleX(0);
  transition: transform 0.06s linear;
}

.meter i.is-active {
  background: linear-gradient(90deg, var(--amber), var(--rose));
}

.mic-status {
  margin: 0 0 10px;
  font-family: var(--font-serif);
  font-size: 15px;
}

.range-row {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
  color: var(--ink-2);
}

.range-row input {
  flex: 1;
}

input[type="range"] {
  accent-color: var(--amber);
}

.mic-last {
  margin-top: 8px;
  min-height: 1.4em;
}

/* 最近 */
.recent-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.recent-item {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px 10px;
  padding: 8px 0;
  border-top: 1px solid var(--line);
}

.recent-item:first-child {
  border-top: 0;
  padding-top: 2px;
}

.recent-time {
  min-width: 5.5ch;
  font-family: var(--font-num);
  font-variation-settings: "opsz" 14;
  font-size: 15px;
  font-variant-numeric: tabular-nums;
}

.select,
.recent-reason {
  appearance: none;
  -webkit-appearance: none;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink-2);
  font-family: inherit;
  font-size: 13px;
  padding: 3px 24px 3px 10px;
  border-radius: 999px;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%2385838f' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 9px center;
}

.recent-auto {
  font-size: 11px;
  letter-spacing: 0.12em;
  padding: 1px 6px;
  border: 1px solid var(--amber-glow);
  border-radius: 6px;
  color: var(--amber);
}

.recent-del {
  appearance: none;
  margin-left: auto;
  border: 0;
  background: none;
  padding: 2px 8px;
  border-radius: 8px;
  color: var(--ink-3);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  transition: color 0.2s, background 0.2s;
}

.recent-del:hover {
  color: var(--rose);
  background: rgba(226, 161, 161, 0.12);
}

/* ---------- 圖表 ---------- */
.chart {
  display: block;
  width: 100%;
  overflow: visible;
}

.chart .axis {
  stroke: var(--line-strong);
  stroke-width: 1;
}

.chart .bar {
  fill: var(--amber);
  opacity: 0.42;
  transform-box: fill-box;
  transform-origin: bottom;
  animation: grow 0.7s cubic-bezier(0.2, 0.7, 0.2, 1) both;
  animation-delay: calc(var(--i, 0) * 22ms);
}

.chart .bar.is-hi {
  opacity: 1;
}

.chart .bar.is-zero {
  opacity: 0.16;
}

.chart .bar.is-zero,
.chart.no-anim .bar {
  animation: none;
}

.chart .lbl {
  fill: var(--ink-3);
  font-family: var(--font-ui);
  font-size: 11px;
  letter-spacing: 0.04em;
}

.chart .val {
  fill: var(--ink-2);
  font-family: var(--font-num);
  font-size: 11px;
}

@keyframes grow {
  from {
    transform: scaleY(0);
  }
  to {
    transform: scaleY(1);
  }
}

/* ---------- 統計 ---------- */
.view-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
  margin: 20px 0 18px;
}

.view-head h2 {
  margin: 0;
  font-family: var(--font-serif);
  font-weight: 600;
  font-size: 28px;
  letter-spacing: 0.06em;
}

.seg {
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
}

.seg button {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--ink-2);
  font-size: 13px;
  letter-spacing: 0.06em;
  padding: 5px 14px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}

.seg button[aria-pressed="true"] {
  background: var(--ink);
  color: var(--bg-0);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 16px;
}

.stats-grid .card {
  grid-column: span 12;
}

@media (min-width: 760px) {
  .stats-grid .card-days {
    grid-column: span 8;
  }
  .stats-grid .card-hours {
    grid-column: span 4;
  }
  .stats-grid .card-year {
    grid-column: span 12;
  }
  .stats-grid .card-grid {
    grid-column: span 5;
  }
  .stats-grid .card-reasons {
    grid-column: span 7;
  }
  .stats-grid .card-records {
    grid-column: span 7;
  }
  .stats-grid .card-insights {
    grid-column: span 5;
  }
  .stats-grid .card-report {
    grid-column: span 6;
  }
  .stats-grid .card-notes {
    grid-column: span 6;
  }
}

.reason-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 9px;
}

.reason-list li {
  display: grid;
  grid-template-columns: 4.5em minmax(0, 1fr) 3ch;
  align-items: center;
  gap: 10px;
  font-size: 14px;
}

.reason-bar {
  height: 8px;
  border-radius: 4px;
  background: var(--bg-3);
  overflow: hidden;
}

.reason-bar i {
  display: block;
  height: 100%;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--amber-2), var(--amber));
  transform-origin: left;
  animation: grow-x 0.7s cubic-bezier(0.2, 0.7, 0.2, 1) both;
  animation-delay: calc(var(--i, 0) * 60ms);
}

@keyframes grow-x {
  from {
    transform: scaleX(0);
  }
  to {
    transform: scaleX(1);
  }
}

.reason-n {
  font-family: var(--font-num);
  text-align: right;
  color: var(--ink-2);
}

.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 16px 18px;
}

.t-label {
  font-size: 12px;
  letter-spacing: 0.14em;
  color: var(--ink-3);
}

.t-val {
  margin-top: 2px;
  font-family: var(--font-num);
  font-variation-settings: "opsz" 72, "SOFT" 50;
  font-size: 30px;
  line-height: 1.15;
  word-break: keep-all;
}

.t-val small {
  margin-left: 5px;
  font-family: var(--font-ui);
  font-size: 12px;
  letter-spacing: 0.06em;
  color: var(--ink-3);
}

.insight-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 10px;
  font-family: var(--font-serif);
  font-size: 16px;
  line-height: 1.7;
}

.insight-list li {
  position: relative;
  padding-left: 1.4em;
  animation: rise 0.6s cubic-bezier(0.2, 0.7, 0.2, 1) both;
  animation-delay: calc(var(--i, 0) * 70ms);
}

.insight-list li::before {
  content: "—";
  position: absolute;
  left: 0;
  color: var(--amber);
}

/* ---------- 設定 ---------- */
.settings-card {
  max-width: 760px;
  padding-top: 6px;
  padding-bottom: 6px;
}

.settings-card + .settings-card {
  margin-top: 16px;
}

.settings-card h3 {
  margin: 16px 0 0;
}

.settings-card h3 + .setting {
  border-top: 0;
}

.quick-url {
  display: block;
  margin-top: 10px;
  padding: 7px 11px;
  border-radius: 9px;
  background: var(--bg-3);
  color: var(--ink);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12.5px;
  line-height: 1.5;
  word-break: break-all;
  user-select: all;
  -webkit-user-select: all;
}

.setting {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 14px 24px;
  padding: 18px 0;
  border-top: 1px solid var(--line);
}

.setting:first-child {
  border-top: 0;
}

.setting-text strong {
  display: block;
  font-weight: 500;
  letter-spacing: 0.06em;
}

.setting-text span {
  display: block;
  max-width: 46ch;
  margin-top: 2px;
  font-size: 13px;
  color: var(--ink-3);
}

.btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line-strong);
  background: transparent;
  color: var(--ink);
  font-family: inherit;
  font-size: 14px;
  letter-spacing: 0.06em;
  padding: 8px 16px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, transform 0.15s;
}

.btn:hover {
  background: var(--bg-3);
  border-color: var(--ink-3);
}

.btn:active {
  transform: scale(0.97);
}

.btn-sm {
  font-size: 13px;
  padding: 6px 14px;
}

.btn.danger {
  color: var(--rose);
  border-color: rgba(226, 161, 161, 0.4);
}

.btn.danger:hover {
  background: rgba(226, 161, 161, 0.12);
}

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.file-btn input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.file-btn:focus-within {
  outline: 2px solid var(--amber);
  outline-offset: 3px;
}

.about {
  max-width: 760px;
  margin-top: 22px;
  padding: 0 4px;
  font-family: var(--font-serif);
  font-size: 15px;
  line-height: 1.9;
  color: var(--ink-2);
}

/* 開關 */
.switch {
  position: relative;
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
  cursor: pointer;
}

.switch input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.switch .track {
  position: relative;
  width: 46px;
  height: 27px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: var(--bg-3);
  transition: background 0.2s, border-color 0.2s;
}

.switch .track::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 19px;
  height: 19px;
  border-radius: 50%;
  background: var(--ink-2);
  transition: transform 0.22s cubic-bezier(0.2, 0.8, 0.2, 1), background 0.2s;
}

.switch input:checked + .track {
  background: var(--amber);
  border-color: var(--amber);
}

.switch input:checked + .track::after {
  transform: translateX(19px);
  background: var(--amber-ink);
}

.switch input:focus-visible + .track {
  outline: 2px solid var(--amber);
  outline-offset: 3px;
}

/* ---------- 頁尾、提示 ---------- */
.foot {
  position: relative;
  z-index: 1;
  display: flex;
  justify-content: center;
  gap: 16px;
  padding: 10px 20px calc(28px + env(safe-area-inset-bottom));
  font-size: 12px;
  letter-spacing: 0.1em;
  color: var(--ink-3);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(26px + env(safe-area-inset-bottom));
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: min(92vw, 480px);
  padding: 10px 18px;
  border-radius: 14px;
  background: var(--toast-bg);
  color: var(--toast-ink);
  font-size: 14px;
  text-align: center;
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.35);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 14px);
  transition: opacity 0.25s, transform 0.25s;
}

.toast.is-on {
  opacity: 1;
  pointer-events: auto;
  transform: translate(-50%, 0);
}

.toast-actions {
  display: flex;
  gap: 6px;
}

.toast-actions:empty {
  display: none;
}

.toast-btn {
  appearance: none;
  border: 1px solid currentColor;
  background: transparent;
  color: inherit;
  font: inherit;
  font-size: 13px;
  padding: 3px 11px;
  border-radius: 999px;
  cursor: pointer;
  opacity: 0.85;
  white-space: nowrap;
}

.toast-btn:hover {
  opacity: 1;
}

.noscript {
  position: relative;
  z-index: 1;
  text-align: center;
  padding: 20px;
}

/* ---------- 手機 ---------- */
@media (max-width: 800px) {
  .hero {
    grid-template-columns: 1fr;
    min-height: 0;
    gap: 8px;
    padding-top: 12px;
    text-align: center;
  }

  .hero-count {
    padding-left: 0;
  }

  .vertical-label {
    position: static;
    display: block;
    writing-mode: horizontal-tb;
    margin-bottom: 2px;
  }

  .vertical-label::before {
    display: none;
  }

  .count-wrap {
    justify-content: center;
  }

  .quote {
    margin: 10px auto 0;
    min-height: 0;
  }

  .quote::before {
    position: static;
    margin-left: 0;
  }

  .hero-action {
    margin-top: 18px;
  }

  .reasons {
    justify-content: center;
  }

  .reasons-title {
    text-align: center;
  }
}

@media (max-width: 640px) {
  .top {
    padding-top: 18px;
  }

  .brand-mark {
    font-size: 26px;
  }

  .brand-sub {
    display: none;
  }

  .tabs {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 5;
    justify-content: space-around;
    padding: 8px 12px calc(8px + env(safe-area-inset-bottom));
    border-top: 1px solid var(--line);
    background: var(--bg-1);
    background: color-mix(in srgb, var(--bg-1) 86%, transparent);
    -webkit-backdrop-filter: blur(16px);
    backdrop-filter: blur(16px);
  }

  .tabs [role="tab"] {
    flex: 1;
    padding: 10px 6px;
    text-align: center;
  }

  .tabs [role="tab"]::after {
    left: 30%;
    right: 30%;
  }

  .page {
    padding-bottom: 96px;
  }

  .foot {
    padding-bottom: calc(84px + env(safe-area-inset-bottom));
  }

  .toast {
    bottom: calc(84px + env(safe-area-inset-bottom));
  }

  .card {
    padding: 18px 18px 20px;
  }
}

/* ---------- 減少動態效果 ---------- */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }

  html {
    scroll-behavior: auto;
  }
}

/* ==========================================================================
   第二批功能：筆記、熱力圖、週報、標籤管理、時段、同步、呼吸、快速頁
   ========================================================================== */

/* 文字輸入 */
.text-input {
  width: 100%;
  min-width: 0;
  font: inherit;
  font-size: 14px;
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid var(--line-strong);
  background: var(--bg-3);
  color: var(--ink);
}

.text-input::placeholder {
  color: var(--ink-3);
}

/* 最近清單裡的筆記 */
.recent-note {
  flex-basis: 100%;
  min-width: 0;
}

.note-edit {
  appearance: none;
  border: 0;
  background: none;
  padding: 0;
  color: var(--ink-3);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  text-align: left;
}

.note-edit:hover {
  color: var(--ink-2);
}

.note-edit.has-note {
  color: var(--ink-2);
  font-family: var(--font-serif);
  font-size: 14px;
}

.note-input {
  width: 100%;
  font: inherit;
  font-size: 14px;
  padding: 6px 10px;
  border-radius: 10px;
  border: 1px solid var(--line-strong);
  background: var(--bg-3);
  color: var(--ink);
}

/* 深呼吸邀請 */
.breath-prompt {
  max-width: 340px;
  margin-top: 16px;
  padding: 12px 16px 14px;
  border: 1px solid var(--amber-glow);
  border-radius: 14px;
  background: var(--amber-soft);
  font-size: 14px;
  text-align: center;
  animation: rise 0.5s cubic-bezier(0.2, 0.7, 0.2, 1) both;
}

.breath-prompt p {
  margin: 0 0 10px;
  font-family: var(--font-serif);
}

.breath-prompt .btn-row {
  justify-content: center;
  align-items: center;
}

/* 全螢幕覆蓋（快速記錄、呼吸） */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 24px;
  background: var(--bg-0);
  background: color-mix(in srgb, var(--bg-0) 92%, transparent);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
}

.overlay[hidden] {
  display: none;
}

.quick-card {
  text-align: center;
}

.quick-title {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 30px;
  letter-spacing: 0.1em;
}

.quick-count-wrap {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 10px;
  margin: 6px 0 22px;
}

.quick-count {
  font-family: var(--font-num);
  font-variation-settings: "opsz" 144, "SOFT" 80;
  font-size: 128px;
  font-weight: 300;
  line-height: 0.9;
  color: var(--amber);
}

.quick-card .btn-row {
  justify-content: center;
}

.breath-stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  text-align: center;
}

.breath-circle {
  width: min(62vw, 260px);
  aspect-ratio: 1;
  border-radius: 50%;
  background: radial-gradient(circle at 40% 35%, #ffdcab 0%, var(--amber) 45%, var(--amber-2) 100%);
  box-shadow: 0 0 90px var(--amber-glow), inset 0 -16px 30px rgba(110, 55, 0, 0.25);
  transform: scale(0.55);
  transition-property: transform;
  transition-timing-function: cubic-bezier(0.45, 0, 0.3, 1);
}

.breath-phase {
  margin: 12px 0 0;
  font-family: var(--font-serif);
  font-size: 30px;
  letter-spacing: 0.2em;
}

.breath-stage .sub {
  margin-top: -10px;
}

/* 熱力圖 */
.heat-scroll {
  overflow-x: auto;
  padding: 4px 0 8px;
  -webkit-overflow-scrolling: touch;
}

.heat {
  display: block;
}

.heat .cell {
  fill: var(--bg-3);
}

.heat .l1 {
  fill: var(--amber);
  opacity: 0.3;
}

.heat .l2 {
  fill: var(--amber);
  opacity: 0.52;
}

.heat .l3 {
  fill: var(--amber);
  opacity: 0.76;
}

.heat .l4 {
  fill: var(--amber);
  opacity: 1;
}

.heat .future {
  fill: transparent;
  stroke: var(--line);
}

.heat .today {
  stroke: var(--ink);
  stroke-width: 1.2;
}

.heat text {
  fill: var(--ink-3);
  font-family: var(--font-ui);
  font-size: 10px;
}

.heat-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.heat-legend {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 11px;
  color: var(--ink-3);
}

.heat-legend i {
  width: 11px;
  height: 11px;
  border-radius: 3px;
  background: var(--bg-3);
}

.heat-legend .l1 {
  background: var(--amber);
  opacity: 0.3;
}

.heat-legend .l2 {
  background: var(--amber);
  opacity: 0.52;
}

.heat-legend .l3 {
  background: var(--amber);
  opacity: 0.76;
}

.heat-legend .l4 {
  background: var(--amber);
}

/* 星期 × 時段 */
.wp-grid {
  display: grid;
  grid-template-columns: 2.4em repeat(5, minmax(0, 1fr));
  gap: 4px;
  margin-bottom: 10px;
  font-size: 12px;
}

.wp-head {
  padding-bottom: 2px;
  text-align: center;
  color: var(--ink-3);
  letter-spacing: 0.06em;
}

.wp-row-label {
  display: flex;
  align-items: center;
  color: var(--ink-3);
}

.wp-cell {
  padding: 7px 0;
  border-radius: 7px;
  text-align: center;
  font-family: var(--font-num);
  font-size: 13px;
  color: var(--ink);
  background: rgba(240, 179, 101, var(--a, 0.1));
}

:root[data-theme="light"] .wp-cell {
  color: #1d1a2b;
}

.wp-cell.is-zero {
  background: var(--bg-3);
}

/* 筆記 */
.note-list {
  list-style: none;
  margin: 12px 0 0;
  padding: 0;
}

.note-list li {
  display: grid;
  grid-template-columns: auto auto minmax(0, 1fr);
  align-items: baseline;
  gap: 10px;
  padding: 8px 0;
  border-top: 1px solid var(--line);
  font-size: 14px;
}

.note-list li:first-child {
  border-top: 0;
}

.note-when {
  font-family: var(--font-num);
  font-variation-settings: "opsz" 14;
  font-variant-numeric: tabular-nums;
  color: var(--ink-3);
  white-space: nowrap;
}

.note-reason {
  font-size: 11px;
  letter-spacing: 0.08em;
  padding: 1px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink-2);
  white-space: nowrap;
}

.note-text {
  font-family: var(--font-serif);
  line-height: 1.6;
  overflow-wrap: anywhere;
}

.card-notes .sub {
  margin-top: 10px;
}

/* 週報 */
.report-actions {
  align-items: center;
}

#report-img {
  display: block;
  width: 100%;
  max-width: 360px;
  margin: 14px 0 12px;
  border-radius: 14px;
  box-shadow: var(--card-shadow);
}

/* 標籤管理 */
.settings-card h3 + .setting {
  padding-top: 8px;
}

.rm-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.rm-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 0;
  border-top: 1px solid var(--line);
}

.rm-label small {
  margin-left: 8px;
  font-size: 11px;
  letter-spacing: 0.1em;
  color: var(--ink-3);
}

.rm-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.icon-mini {
  appearance: none;
  border: 1px solid var(--line-strong);
  background: transparent;
  color: var(--ink-2);
  font: inherit;
  font-size: 12px;
  padding: 3px 9px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}

.icon-mini:hover:not(:disabled) {
  background: var(--bg-3);
  color: var(--ink);
}

.icon-mini:disabled {
  opacity: 0.3;
  cursor: default;
}

.icon-mini.danger {
  color: var(--rose);
}

.rm-add {
  display: flex;
  gap: 8px;
  margin: 14px 0 10px;
}

.rm-add .text-input {
  flex: 1;
}

/* 時段預設 */
.period-list {
  padding-bottom: 8px;
}

.period-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 0;
  border-top: 1px solid var(--line);
  font-size: 14px;
}

.period-row small {
  display: block;
  font-size: 11px;
  letter-spacing: 0.06em;
  color: var(--ink-3);
}

.period-row .select {
  min-width: 9em;
}

/* 同步 */
#sync-setup .rm-add {
  margin-top: 4px;
}

.setting-text em {
  font-style: normal;
  color: var(--rose);
}

@media (max-width: 640px) {
  .note-list li {
    grid-template-columns: auto auto;
  }

  .note-list .note-text {
    grid-column: 1 / -1;
  }

  .toast {
    flex-wrap: wrap;
    justify-content: center;
  }
}

/* ==========================================================================
   第三批：長嘆、昨天回顧、復原、捷徑說明
   ========================================================================== */

.sigh-btn.is-long {
  transform: scale(1.06);
  box-shadow:
    0 0 0 22px var(--amber-soft),
    0 30px 70px -18px rgba(240, 179, 101, 0.7),
    0 0 140px var(--amber-glow),
    inset 0 -18px 34px rgba(110, 55, 0, 0.28),
    inset 0 14px 28px rgba(255, 255, 255, 0.4);
}

.float.big {
  font-size: 44px;
  letter-spacing: 0.04em;
}

.ring.long {
  border-width: 3px;
  animation-duration: 1.7s;
}

.recent-auto.is-long {
  color: var(--rose);
  border-color: rgba(226, 161, 161, 0.4);
}

.recent-auto.is-sc {
  color: var(--ink-2);
  border-color: var(--line-strong);
}

.review-card {
  margin: 8px 0 4px;
  border-color: var(--amber-glow);
  animation: rise 0.6s cubic-bezier(0.2, 0.7, 0.2, 1) both;
}

.review-main {
  margin: 0 0 10px;
  font-family: var(--font-serif);
  font-size: 17px;
  line-height: 1.7;
}

.review-notes {
  list-style: none;
  margin: 0 0 12px;
  padding: 0;
  font-family: var(--font-serif);
  color: var(--ink-2);
  line-height: 1.7;
}

.review-notes:empty {
  display: none;
}

.sc-help {
  margin: 4px 0 8px;
  padding: 4px 0;
  border-top: 1px solid var(--line);
}

.sc-help summary {
  padding: 12px 0;
  cursor: pointer;
  font-weight: 500;
  letter-spacing: 0.06em;
}

.sc-help .sub {
  margin-bottom: 8px;
}

.sc-steps {
  margin: 0 0 12px;
  padding-left: 1.4em;
  font-size: 14px;
  line-height: 1.8;
  color: var(--ink-2);
}

.sc-steps li {
  margin-bottom: 6px;
}

.sc-steps code:not(.quick-url) {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12.5px;
  padding: 1px 6px;
  border-radius: 6px;
  background: var(--bg-3);
  color: var(--ink);
}

.sc-steps .quick-url {
  margin: 8px 0;
}

.sc-steps .btn {
  margin-top: 4px;
}

/* 報告卡：種類切換與翻頁 */
.report-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.report-head h3 {
  margin-bottom: 8px;
}

.report-head .seg {
  margin-bottom: 8px;
}

.report-nav {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 10px 0 4px;
}

#report-label {
  min-width: 8.5em;
  text-align: center;
  font-family: var(--font-serif);
  font-size: 15px;
}

.report-nav .icon-mini {
  font-size: 16px;
  line-height: 1;
  padding: 3px 11px;
}

/* 版本與同步診斷 */
.foot .build {
  opacity: 0.7;
}

.sync-diag {
  display: block;
  margin-top: 6px;
  font-size: 12px;
  line-height: 1.6;
  color: var(--ink-3);
}

#sync-gist-link {
  display: inline-block;
  margin-top: 6px;
  font-size: 13px;
}

/* 收件匣清單 */
.inbox-list {
  list-style: none;
  margin: 10px 0 4px;
  padding: 0;
  font-size: 13px;
  line-height: 1.7;
}

.inbox-list li {
  padding: 6px 0;
  border-top: 1px solid var(--line);
  overflow-wrap: anywhere;
}

.inbox-body {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12.5px;
  padding: 1px 6px;
  border-radius: 6px;
  background: var(--bg-3);
}

.inbox-status {
  font-size: 11px;
  letter-spacing: 0.08em;
  padding: 1px 7px;
  border-radius: 6px;
  border: 1px solid var(--line-strong);
  color: var(--ink-2);
  white-space: nowrap;
}

.inbox-status.is-new {
  color: var(--amber);
  border-color: var(--amber-glow);
}
