/* ===== Theme tokens ===== */
:root {
  --bg: #f7f7f5;
  --bg-elev: #ffffff;
  --bg-soft: #f0f0ed;
  --line: #e7e5e1;
  --line-strong: #d8d6d1;
  --text: #1a1a1a;
  --text-muted: #6b6b6b;
  --text-faint: #9a9a9a;
  --accent: #ff6b3d;
  --accent-2: #ff9a3d;
  --accent-soft: #fff1ec;
  --success: #2bb673;
  --danger: #e2483b;
  --shadow-sm: 0 1px 2px rgba(20,20,20,.04);
  --shadow-md: 0 4px 24px rgba(20,20,20,.06), 0 1px 2px rgba(20,20,20,.04);
  --shadow-lg: 0 12px 40px rgba(20,20,20,.10);
  --radius-sm: 8px;
  --radius: 14px;
  --radius-lg: 22px;
  --ease: cubic-bezier(.2,.7,.2,1);
}

[data-theme="dark"] {
  --bg: #0e0e10;
  --bg-elev: #161618;
  --bg-soft: #1c1c1f;
  --line: #2a2a2e;
  --line-strong: #353539;
  --text: #f1f1f1;
  --text-muted: #a4a4a8;
  --text-faint: #6a6a70;
  --accent: #ff7a4d;
  --accent-2: #ffb070;
  --accent-soft: #2a1c16;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.4);
  --shadow-md: 0 6px 24px rgba(0,0,0,.5), 0 1px 2px rgba(0,0,0,.3);
  --shadow-lg: 0 16px 48px rgba(0,0,0,.55);
}

/* ===== Reset ===== */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: clamp(24px, 5vh, 64px) clamp(16px, 5vw, 56px);
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  transition: background-color .35s var(--ease), color .25s var(--ease);
}
button { font-family: inherit; cursor: pointer; border: 0; background: none; color: inherit; }
input { font-family: inherit; }
ul { list-style: none; padding: 0; margin: 0; }
kbd {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 11px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 1px 6px;
  color: var(--text-muted);
}

/* ===== Background grain (subtle texture) ===== */
.bg-grain {
  position: fixed; inset: 0;
  pointer-events: none;
  background-image:
    radial-gradient(1200px 600px at 20% -10%, color-mix(in srgb, var(--accent) 6%, transparent), transparent 60%),
    radial-gradient(900px 600px at 110% 110%, color-mix(in srgb, var(--accent-2) 5%, transparent), transparent 60%);
  z-index: 0;
}

/* ===== Layout ===== */
.app {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  padding: 0;
  background: transparent;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

.app__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 22px;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand__dot {
  width: 10px; height: 10px;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 18%, transparent);
}
.brand__name {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -.01em;
}

/* ===== Icon button ===== */
.icon-btn {
  width: 36px; height: 36px;
  display: inline-grid; place-items: center;
  border-radius: 10px;
  color: var(--text-muted);
  border: 1px solid var(--line);
  background: var(--bg-elev);
  transition: all .2s var(--ease);
}
.icon-btn:hover { color: var(--text); border-color: var(--line-strong); transform: translateY(-1px); }
.icon-btn .i-moon { display: none; }
[data-theme="dark"] .icon-btn .i-sun { display: none; }
[data-theme="dark"] .icon-btn .i-moon { display: block; }

/* ===== Tabs ===== */
.tabs {
  position: relative;
  display: inline-flex;
  background: var(--bg-soft);
  padding: 4px;
  border-radius: 12px;
  margin-bottom: 22px;
  border: 1px solid var(--line);
}
.tab {
  position: relative;
  z-index: 1;
  padding: 8px 18px;
  border-radius: 9px;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text-muted);
  transition: color .2s var(--ease);
}
.tab.is-active { color: var(--text); }
.tabs__indicator {
  position: absolute;
  top: 4px;
  left: 4px;
  height: calc(100% - 8px);
  background: var(--bg-elev);
  border-radius: 9px;
  box-shadow: var(--shadow-sm);
  transition: transform .35s var(--ease), width .35s var(--ease);
  z-index: 0;
}

/* ===== Panels ===== */
.panel { display: none; animation: fadeIn .3s var(--ease); }
.panel.is-active { display: block; }
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ===== Todo form ===== */
.todo__form {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
}
.todo__input {
  flex: 1;
  padding: 13px 16px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--text);
  font-size: 14.5px;
  outline: none;
  transition: border-color .2s var(--ease), background-color .2s var(--ease), box-shadow .2s var(--ease);
}
.todo__input::placeholder { color: var(--text-faint); }
.todo__input:focus {
  border-color: var(--accent);
  background: var(--bg-elev);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 14%, transparent);
}

/* ===== Buttons ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 6px;
  padding: 11px 18px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 500;
  transition: all .2s var(--ease);
  white-space: nowrap;
}
.btn--primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: white;
  box-shadow: 0 4px 14px color-mix(in srgb, var(--accent) 35%, transparent);
}
.btn--primary:hover { transform: translateY(-1px); box-shadow: 0 6px 18px color-mix(in srgb, var(--accent) 45%, transparent); }
.btn--primary:active { transform: translateY(0); }
.btn--ghost {
  background: var(--bg-soft);
  border: 1px solid var(--line);
  color: var(--text-muted);
}
.btn--ghost:hover { color: var(--text); border-color: var(--line-strong); }
.btn--lg { padding: 13px 30px; font-size: 14.5px; }

/* ===== Filter chips ===== */
.todo__filters {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-muted);
  background: var(--bg-soft);
  border: 1px solid transparent;
  transition: all .2s var(--ease);
}
.chip:hover { color: var(--text); }
.chip.is-active { color: var(--text); background: var(--bg-elev); border-color: var(--line); box-shadow: var(--shadow-sm); }
.chip__count {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 11px;
  color: var(--text-faint);
  background: color-mix(in srgb, var(--text) 6%, transparent);
  padding: 0 6px;
  border-radius: 6px;
  min-width: 18px;
  text-align: center;
}
.chip--ghost { margin-left: auto; }

/* ===== Todo list ===== */
.todo__list { display: flex; flex-direction: column; gap: 4px; }
.todo-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 12px;
  border-radius: 12px;
  transition: background-color .2s var(--ease);
  animation: slideIn .25s var(--ease);
}
@keyframes slideIn {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}
.todo-item:hover { background: var(--bg-soft); }
.todo-item.is-leaving { animation: slideOut .25s var(--ease) forwards; }
@keyframes slideOut {
  to { opacity: 0; transform: translateX(8px); height: 0; padding-top: 0; padding-bottom: 0; margin: 0; }
}

.tcheck {
  position: relative;
  width: 20px; height: 20px;
  flex-shrink: 0;
  border: 1.5px solid var(--line-strong);
  border-radius: 7px;
  background: transparent;
  transition: all .2s var(--ease);
}
.tcheck:hover { border-color: var(--accent); }
.tcheck::after {
  content: "";
  position: absolute;
  top: 4px; left: 7px;
  width: 4px; height: 9px;
  border: solid white;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg) scale(0);
  transition: transform .2s var(--ease);
}
.todo-item.is-done .tcheck {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border-color: transparent;
}
.todo-item.is-done .tcheck::after { transform: rotate(45deg) scale(1); }

.tlabel {
  flex: 1;
  font-size: 14.5px;
  color: var(--text);
  outline: none;
  cursor: text;
  word-break: break-word;
  transition: color .2s var(--ease);
}
.todo-item.is-done .tlabel {
  color: var(--text-faint);
  text-decoration: line-through;
  text-decoration-color: var(--text-faint);
  text-decoration-thickness: 1px;
}
.tdel {
  width: 28px; height: 28px;
  display: grid; place-items: center;
  border-radius: 8px;
  color: var(--text-faint);
  opacity: 0;
  transition: all .2s var(--ease);
}
.todo-item:hover .tdel { opacity: 1; }
.tdel:hover { color: var(--danger); background: color-mix(in srgb, var(--danger) 10%, transparent); }

/* ===== Empty state ===== */
.empty {
  display: none;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 40px 20px 24px;
  color: var(--text-muted);
}
.empty.is-shown { display: flex; }
.empty__icon {
  width: 56px; height: 56px;
  display: grid; place-items: center;
  border-radius: 16px;
  background: var(--bg-soft);
  color: var(--accent);
  margin-bottom: 12px;
}
.empty__title { margin: 4px 0 2px; font-weight: 600; color: var(--text); font-size: 14.5px; }
.empty__hint { margin: 0; font-size: 13px; color: var(--text-faint); }

/* ===== Pomodoro ===== */
.pomo { display: flex; flex-direction: column; align-items: center; }
.pomo__modes {
  display: inline-flex;
  background: var(--bg-soft);
  padding: 4px;
  border-radius: 12px;
  border: 1px solid var(--line);
  margin-bottom: 28px;
}
.pmode {
  padding: 7px 14px;
  border-radius: 9px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-muted);
  transition: all .2s var(--ease);
}
.pmode:hover { color: var(--text); }
.pmode.is-active {
  background: var(--bg-elev);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

.pomo__ring {
  position: relative;
  width: 240px;
  height: 240px;
  margin-bottom: 28px;
}
.ring { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring__bg {
  stroke: var(--line);
  stroke-width: 8;
}
.ring__fg {
  stroke-width: 10;
  stroke-linecap: round;
  stroke-dasharray: 628.3;
  stroke-dashoffset: 0;
  transition: stroke-dashoffset 1s linear;
  filter: drop-shadow(0 0 8px color-mix(in srgb, var(--accent) 40%, transparent));
}
.pomo__time {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}
.pomo__digits {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 52px;
  font-weight: 500;
  letter-spacing: -.02em;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.pomo__label {
  font-size: 12.5px;
  color: var(--text-muted);
  margin-top: 4px;
  text-transform: uppercase;
  letter-spacing: .08em;
}

.pomo__controls {
  display: flex;
  gap: 10px;
  margin-bottom: 26px;
}

.pomo__stats {
  display: flex;
  gap: 32px;
  margin-bottom: 18px;
}
.stat { text-align: center; }
.stat__value {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 22px;
  font-weight: 600;
  color: var(--text);
}
.stat__label {
  font-size: 11px;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: .1em;
  margin-top: 2px;
}

.pomo__settings {
  width: 100%;
  border-top: 1px solid var(--line);
  padding-top: 14px;
  margin-top: 6px;
}
.pomo__settings summary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  color: var(--text-muted);
  cursor: pointer;
  list-style: none;
  user-select: none;
  padding: 4px 8px;
  border-radius: 8px;
  transition: color .2s var(--ease);
}
.pomo__settings summary:hover { color: var(--text); }
.pomo__settings summary::-webkit-details-marker { display: none; }
.settings {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-top: 14px;
}
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 11.5px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .06em;
}
.field input[type="number"] {
  padding: 9px 10px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 9px;
  color: var(--text);
  font-size: 13.5px;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  outline: none;
  transition: border-color .2s var(--ease);
  text-transform: none;
}
.field input[type="number"]:focus { border-color: var(--accent); }
.field--switch {
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  grid-column: span 3;
  text-transform: none;
  letter-spacing: 0;
  font-size: 13px;
  color: var(--text);
  padding: 8px 2px;
}
.field--switch input[type="checkbox"] {
  appearance: none;
  width: 36px; height: 20px;
  background: var(--line-strong);
  border-radius: 999px;
  position: relative;
  cursor: pointer;
  transition: background-color .2s var(--ease);
}
.field--switch input[type="checkbox"]::after {
  content: "";
  position: absolute;
  top: 2px; left: 2px;
  width: 16px; height: 16px;
  background: white;
  border-radius: 999px;
  transition: transform .2s var(--ease);
  box-shadow: 0 1px 2px rgba(0,0,0,.2);
}
.field--switch input[type="checkbox"]:checked { background: var(--accent); }
.field--switch input[type="checkbox"]:checked::after { transform: translateX(16px); }

/* ===== Footer ===== */
.app__foot {
  margin-top: 32px;
  text-align: center;
  font-size: 11.5px;
  color: var(--text-faint);
}

/* ===== Responsive ===== */
@media (max-width: 480px) {
  .pomo__digits { font-size: 44px; }
  .pomo__ring { width: 200px; height: 200px; }
  .settings { grid-template-columns: 1fr 1fr; }
  .field--switch { grid-column: span 2; }
}

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