/* FocusFlow — 360px-first, system theme, accent via [data-theme]. */
* { box-sizing: border-box; }
:root {
  --accent: #0d9488;
  --accent-ink: #ffffff;
  --focus: #0d9488;
  --short: #16a34a;
  --long: #7c3aed;
}
html[data-theme="sunset"] { --accent: #ea580c; --focus: #ea580c; }
html[data-theme="forest"] { --accent: #16a34a; --focus: #16a34a; }
html[data-theme="lavender"] { --accent: #7c3aed; --focus: #7c3aed; }
html[data-theme="ocean"] { --accent: #0284c7; --focus: #0284c7; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: #f0fdfa;
  color: #0f172a;
  color-scheme: light dark;
  -webkit-tap-highlight-color: transparent;
}
.app { max-width: 560px; margin: 0 auto; padding: 16px 16px calc(24px + var(--banner-h, 0px)); }

.heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.title { margin: 0; font-size: 30px; line-height: 1.1; letter-spacing: -0.5px; }
.subtitle { margin: 4px 0 0; color: #64748b; font-size: 14px; }
.header-actions { display: flex; gap: 8px; }
.icon-button {
  width: 44px; height: 44px; border-radius: 12px; border: 1px solid #cbd5e1;
  background: #ffffff; font-size: 20px; cursor: pointer; color: #0f172a;
  display: inline-flex; align-items: center; justify-content: center;
}
.icon-button:active { transform: scale(0.96); }

/* Schedule strip */
.schedule-strip {
  display: flex; gap: 6px; overflow-x: auto; margin: 16px 0 12px;
  padding-bottom: 4px; scrollbar-width: none;
}
.schedule-strip::-webkit-scrollbar { display: none; }
.schedule-chip {
  flex: 0 0 auto; font-size: 12px; font-weight: 600; padding: 6px 10px;
  border-radius: 999px; color: #fff; background: var(--chip, #64748b);
  opacity: 0.55; white-space: nowrap;
}
.schedule-chip.current { opacity: 1; box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--chip, #64748b); }
.schedule-chip.done { opacity: 0.3; text-decoration: line-through; }

/* Timer card */
.timer-card {
  background: #ffffff; border: 1px solid #e2e8f0; border-radius: 20px;
  padding: 20px 16px 16px; text-align: center;
  box-shadow: 0 4px 16px rgba(15, 23, 42, 0.06);
}
.section-label { margin: 0; font-size: 15px; font-weight: 700; text-transform: uppercase; letter-spacing: 1.5px; color: var(--accent); }
.display-switch { display: inline-flex; gap: 4px; margin: 12px 0 4px; background: #f1f5f9; border-radius: 999px; padding: 3px; }
.display-switch button {
  border: 0; background: transparent; font: inherit; font-size: 13px; font-weight: 600;
  color: #64748b; padding: 6px 12px; border-radius: 999px; cursor: pointer;
}
.display-switch button.active { background: #fff; color: #0f172a; box-shadow: 0 1px 3px rgba(15, 23, 42, 0.2); }
.time-display { margin: 4px 0 8px; font-size: 76px; line-height: 1; font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: -2px; }
.time-display.small { font-size: 44px; letter-spacing: -1px; }
.overtime { margin: 0 0 8px; font-size: 14px; font-weight: 700; color: #b45309; }
.progress-track { height: 8px; border-radius: 999px; background: #e2e8f0; overflow: hidden; margin: 8px 0 16px; }
.progress-fill { height: 100%; width: 0%; background: var(--accent); border-radius: 999px; transition: width 0.3s linear; }
.controls { display: flex; gap: 8px; justify-content: center; }
.btn {
  font: inherit; font-size: 16px; font-weight: 700; padding: 12px 18px;
  border-radius: 12px; border: 1px solid #cbd5e1; background: #fff; color: #0f172a; cursor: pointer;
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); min-width: 110px; }
.btn.small { padding: 9px 14px; font-size: 14px; }
.btn.danger { border-color: #fecaca; color: #b91c1c; background: #fff; }
.btn:active { transform: scale(0.97); }
.hint { margin: 12px 0 0; font-size: 12px; color: #94a3b8; }
.timer-card.completed { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }

.stats-line { text-align: center; color: #64748b; font-size: 14px; margin: 14px 0; }

/* To-do */
.todo-panel { background: #fff; border: 1px solid #e2e8f0; border-radius: 20px; padding: 16px; }
.todo-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.todo-head h2 { margin: 0; font-size: 18px; }
.todo-filter { display: inline-flex; gap: 4px; background: #f1f5f9; border-radius: 999px; padding: 3px; }
.todo-filter button { border: 0; background: transparent; font: inherit; font-size: 12px; font-weight: 600; color: #64748b; padding: 5px 10px; border-radius: 999px; cursor: pointer; }
.todo-filter button.active { background: #fff; color: #0f172a; box-shadow: 0 1px 3px rgba(15, 23, 42, 0.2); }
.todo-add { display: flex; gap: 8px; margin: 12px 0; }
.todo-add input[type="text"] {
  flex: 1; min-width: 0; font: inherit; font-size: 15px; padding: 10px 12px;
  border: 1px solid #cbd5e1; border-radius: 10px; background: #fff; color: #0f172a;
}
.todo-add select {
  font: inherit; font-size: 13px; padding: 8px; border: 1px solid #cbd5e1;
  border-radius: 10px; background: #fff; color: #0f172a; max-width: 108px;
}
.todo-list { list-style: none; margin: 0; padding: 0; }
.todo-item {
  display: flex; align-items: center; gap: 10px; padding: 10px 4px;
  border-top: 1px solid #f1f5f9;
}
.todo-item input[type="checkbox"] { width: 22px; height: 22px; flex: 0 0 auto; accent-color: var(--accent); }
.todo-item .task-title { flex: 1; min-width: 0; font-size: 15px; overflow-wrap: anywhere; }
.todo-item.done .task-title { text-decoration: line-through; color: #94a3b8; }
.todo-item .task-tag {
  flex: 0 0 auto; font-size: 11px; font-weight: 700; padding: 3px 8px; border-radius: 999px;
  color: #fff; background: var(--tag, #64748b);
}
.todo-item .mini-btn {
  flex: 0 0 auto; border: 0; background: transparent; font-size: 16px; cursor: pointer;
  color: #94a3b8; padding: 4px 6px; line-height: 1;
}
.todo-empty { color: #94a3b8; font-size: 14px; margin: 8px 0 0; }

.howto { margin-top: 20px; }
.howto h2, .todo-head h2 { font-size: 18px; }
.howto p, .howto li { font-size: 14px; line-height: 1.55; color: #475569; }
.about { margin-top: 20px; border-top: 1px solid #e2e8f0; padding-top: 12px; }
.about p { font-size: 13px; line-height: 1.5; color: #64748b; margin: 6px 0; }

/* Settings sheet */
.sheet-backdrop {
  position: fixed; inset: 0; background: rgba(15, 23, 42, 0.45); z-index: 40;
}
.settings-sheet {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(420px, 100%);
  background: #fff; color: #0f172a; z-index: 41; overflow-y: auto;
  padding: 16px 18px calc(24px + env(safe-area-inset-bottom)); box-shadow: -8px 0 32px rgba(15, 23, 42, 0.25);
}
.sheet-head { display: flex; justify-content: space-between; align-items: center; }
.sheet-head h2 { margin: 0; font-size: 22px; }
.settings-sheet h3 { margin: 22px 0 8px; font-size: 14px; text-transform: uppercase; letter-spacing: 1px; color: #64748b; }
.preset-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.preset-grid button, .theme-grid button {
  font: inherit; font-size: 15px; font-weight: 700; padding: 12px; border-radius: 12px;
  border: 1px solid #cbd5e1; background: #fff; color: #0f172a; cursor: pointer;
}
.preset-grid button span { font-size: 12px; font-weight: 500; color: #64748b; }
.preset-grid button.active, .theme-grid button.active { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }
.length-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.length-grid label { font-size: 14px; font-weight: 600; color: #334155; display: flex; flex-direction: column; gap: 4px; }
.length-grid label.inline-label { display: block; }
.length-grid label.inline-label input { display: inline-block; width: 72px; vertical-align: middle; margin: 0 2px; }
.length-grid input {
  font: inherit; font-size: 16px; padding: 9px 10px; border: 1px solid #cbd5e1;
  border-radius: 10px; background: #fff; color: #0f172a; width: 100%;
}
.field-note { font-size: 12px; color: #94a3b8; margin: 8px 0 0; }
.check-row { display: flex; align-items: center; gap: 10px; font-size: 15px; padding: 8px 0; cursor: pointer; }
.check-row input { width: 20px; height: 20px; accent-color: var(--accent); }
.theme-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.theme-grid button { padding: 10px 4px; font-size: 12px; border-top: 6px solid var(--sw); }
.about-text { font-size: 14px; line-height: 1.55; color: #475569; }

/* Onboarding */
.onboard {
  position: fixed; inset: 0; z-index: 50; background: rgba(15, 23, 42, 0.55);
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.onboard-card { background: #fff; color: #0f172a; border-radius: 20px; padding: 24px; max-width: 420px; width: 100%; }
.onboard-card h2 { margin: 0 0 8px; font-size: 22px; }
.onboard-card p, .onboard-card li { font-size: 15px; line-height: 1.55; color: #475569; }
.onboard-card .btn { width: 100%; margin-top: 8px; }

[hidden] { display: none !important; }

/* Dark theme follows the OS setting */
@media (prefers-color-scheme: dark) {
  body { background: #0f172a; color: #f1f5f9; }
  .title, .btn, .icon-button, .settings-sheet, .onboard-card { color: #f1f5f9; }
  .subtitle, .stats-line, .hint, .todo-empty, .about p { color: #94a3b8; }
  .icon-button, .btn, .todo-add input[type="text"], .todo-add select,
  .length-grid input { background: #1e293b; border-color: #334155; color: #f1f5f9; }
  .timer-card, .todo-panel, .onboard-card, .settings-sheet { background: #1e293b; border-color: #334155; }
  .display-switch, .todo-filter { background: #0f172a; }
  .display-switch button.active, .todo-filter button.active { background: #334155; color: #f1f5f9; }
  .display-switch button, .todo-filter button { color: #94a3b8; }
  .progress-track { background: #334155; }
  .todo-item { border-top-color: #334155; }
  .howto p, .howto li, .about-text, .onboard-card p, .onboard-card li { color: #cbd5e1; }
  .about { border-top-color: #334155; }
  .preset-grid button, .theme-grid button { background: #1e293b; border-color: #334155; color: #f1f5f9; }
  .preset-grid button span { color: #94a3b8; }
  .length-grid label, .settings-sheet h3 { color: #94a3b8; }
  .check-row { color: #e2e8f0; }
  .btn.danger { background: #1e293b; border-color: #7f1d1d; color: #fca5a5; }
  .schedule-chip.current { box-shadow: 0 0 0 2px #1e293b, 0 0 0 4px var(--chip, #64748b); }
  .todo-add input[type="text"]::placeholder { color: #64748b; }
}
