:root {
  --accent: #3d8f80;
  --accent-soft: rgba(61,143,128,0.12);
  --warm: #f29a66;
  --bg: #f2f2f6;
  --card: #ffffff;
  --text: #1c1c1e;
  --muted: #6b6b70;
  --radius: 24px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121214;
    --card: #1e1e21;
    --text: #f2f2f2;
    --muted: #9a9a9e;
    --accent-soft: rgba(61,143,128,0.22);
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; overflow-x: hidden; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang TC", "Noto Sans TC", "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

#app { max-width: 480px; margin: 0 auto; padding-bottom: 40px; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 20px 8px;
}
.brand { font-size: 20px; font-weight: 700; margin: 0; }
.icon-btn {
  width: 44px; height: 44px; border-radius: 50%; border: none;
  background: var(--card); font-size: 18px; cursor: pointer;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  display: flex; align-items: center; justify-content: center;
}
.icon-btn:hover { opacity: 0.85; }

.view { padding: 8px 20px 20px; }
.hidden { display: none !important; }

.hero { padding: 16px 4px 20px; }
.hero h2 { font-size: 26px; font-weight: 800; margin: 0 0 8px; }
.muted { color: var(--muted); margin: 0; }
.muted.small { font-size: 13px; }
.center { text-align: center; }

.card {
  background: var(--card); border-radius: var(--radius);
  padding: 20px; box-shadow: 0 4px 20px rgba(0,0,0,0.06);
}
.input-card { margin-bottom: 24px; }
#task-input {
  width: 100%; border: none; background: var(--bg); border-radius: 14px;
  padding: 14px; font-size: 16px; font-family: inherit; color: var(--text);
  resize: none; margin-bottom: 14px;
}
#task-input:focus { outline: 2px solid var(--accent); }

.btn-primary {
  width: 100%; background: var(--accent); color: white; border: none;
  border-radius: 999px; padding: 14px; font-size: 16px; font-weight: 700;
  cursor: pointer;
}
.btn-primary:disabled { opacity: 0.4; cursor: default; }
.btn-primary.full, .btn-secondary.full { width: 100%; }
.btn-secondary {
  background: var(--bg); color: var(--text); border: none;
  border-radius: 999px; padding: 12px; font-size: 14px; font-weight: 600;
  cursor: pointer;
}
.btn-secondary:disabled { opacity: 0.4; cursor: default; }

#quota-note { text-align: center; margin-top: 12px; }

.chips-section { margin-bottom: 20px; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 4px 0; -webkit-overflow-scrolling: touch; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto; background: var(--accent-soft); color: var(--accent);
  border: none; border-radius: 999px; padding: 8px 16px; font-size: 14px;
  white-space: nowrap; cursor: pointer;
}

.stats-strip { display: flex; align-items: center; padding: 16px 0; }
.stat-block { flex: 1; text-align: center; }
.stat-num { font-size: 32px; font-weight: 800; color: var(--accent); font-variant-numeric: tabular-nums; }
.stat-label { font-size: 12px; color: var(--muted); margin-top: 4px; }
.divider { width: 1px; height: 40px; background: rgba(128,128,128,0.2); }

.breakdown-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 0 20px;
}
.breakdown-header h2 { margin: 0; font-size: 18px; }
.task-title { font-size: 18px; font-weight: 700; text-align: center; margin: 0 0 6px; }

.step-cards { position: relative; min-height: 380px; margin-top: 20px; }
.step-card {
  background: var(--card); border-radius: var(--radius); padding: 28px 24px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.06); display: none; flex-direction: column;
  min-height: 380px;
}
.step-card.active { display: flex; }
.step-card .step-meta { display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); }
.step-card .rebroken-badge { color: var(--warm); font-size: 12px; }
.step-card .step-action {
  flex: 1; display: flex; align-items: center; justify-content: center;
  font-size: 22px; font-weight: 700; text-align: center; line-height: 1.5; padding: 20px 0;
}
.step-card.completed .step-action { color: var(--muted); text-decoration: line-through; }
.step-card .step-time { text-align: center; color: var(--muted); font-size: 14px; margin-bottom: 20px; }
.step-card .step-actions { display: flex; flex-direction: column; gap: 10px; align-items: center; }
.link-btn { background: none; border: none; color: var(--muted); font-size: 14px; cursor: pointer; }
.done-badge { text-align: center; color: var(--accent); font-weight: 700; }

.dots { display: flex; justify-content: center; gap: 8px; margin-top: 16px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: rgba(128,128,128,0.3); }
.dot.active { background: var(--accent); width: 20px; border-radius: 4px; }

.overlay {
  position: fixed; inset: 0; background: var(--bg); z-index: 50;
  display: flex; flex-direction: column; align-items: center;
  padding: 20px; overflow: hidden;
}
.timer-top { width: 100%; max-width: 480px; }
.timer-action { font-size: 19px; font-weight: 700; text-align: center; max-width: 340px; margin: 20px 0; }
.ring-wrap { position: relative; width: 260px; height: 260px; margin: 20px 0; }
.ring { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring-bg { fill: none; stroke: var(--accent-soft); stroke-width: 14; }
.ring-fg { fill: none; stroke: var(--accent); stroke-width: 14; stroke-linecap: round;
  stroke-dasharray: 660; stroke-dashoffset: 0; transition: stroke-dashoffset 1s linear; }
.timer-display {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-size: 44px; font-weight: 800; font-variant-numeric: tabular-nums;
}
.timer-actions { width: 100%; max-width: 340px; margin-top: auto; display: flex; flex-direction: column; gap: 12px; padding-bottom: 20px; }
.row-2 { display: flex; gap: 10px; }
.row-2 > * { flex: 1; }

#view-celebration { justify-content: center; }
.celebration-content { text-align: center; z-index: 2; }
.celebration-emoji { font-size: 56px; }
#confetti { position: absolute; inset: 0; width: 100%; height: 100%; }

.stats-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 20px; }
.stat-tile { text-align: center; padding: 16px 8px; }

.settings-section { margin-top: 24px; }
.section-label { font-size: 13px; color: var(--muted); margin: 0 0 8px 4px; }
.row-between { display: flex; align-items: center; justify-content: space-between; margin: 0; }
.link { color: var(--accent); text-decoration: none; font-size: 14px; }
