:root {
  color-scheme: dark;
  --bg: #0f141a;
  --surface: #151b22;
  --surface-2: #1b222c;
  --text: #e7edf3;
  --muted: #93a4b8;
  --border: rgba(255,255,255,.08);
  --primary: #8ab4f8;
  --primary-2: #6aa6ff;
  --success: #7ad67a;
  --danger: #ff7d7d;
  --warn: #ffd36b;
  --radius: 20px;
  --radius-sm: 14px;
  --shadow: 0 10px 30px rgba(0,0,0,.28);
  --nav-h: 74px;
}

[data-theme="light"] {
  color-scheme: light;
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-2: #edf2f8;
  --text: #102030;
  --muted: #5e6b7c;
  --border: rgba(16,32,48,.08);
  --primary: #2f6bff;
  --primary-2: #1f5af2;
  --success: #1b9a4a;
  --danger: #d64545;
  --warn: #a57b00;
  --shadow: 0 10px 28px rgba(20,32,48,.08);
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button, input, textarea, select {
  font: inherit;
}

#app {
  min-height: 100vh;
  padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom));
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 18px 16px 14px;
  background: linear-gradient(to bottom, rgba(15,20,26,.98), rgba(15,20,26,.88));
  backdrop-filter: blur(18px);
  border-bottom: 1px solid var(--border);
}

[data-theme="light"] .topbar {
  background: linear-gradient(to bottom, rgba(245,247,251,.98), rgba(245,247,251,.88));
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--primary);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: 20px;
  line-height: 1.2;
}

.content {
  padding: 16px;
  display: grid;
  gap: 14px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
}

.card h2, .card h3 {
  margin: 0 0 12px;
  font-size: 16px;
}

.subtle {
  color: var(--muted);
  font-size: 13px;
}

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

.grid-2 {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}

@media (min-width: 768px) {
  .content {
    max-width: 960px;
    margin: 0 auto;
    padding: 18px 20px 24px;
  }
  .grid-2 { grid-template-columns: 1fr 1fr; }
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
}

.btn, .icon-btn, .nav-btn, .task-btn, .preset-btn {
  border: 0;
  border-radius: 16px;
  min-height: 48px;
  padding: 0 14px;
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
  transition: transform .08s ease, background .15s ease, opacity .15s ease;
}

.btn:active, .icon-btn:active, .nav-btn:active, .task-btn:active, .preset-btn:active {
  transform: scale(.98);
}

.btn.primary {
  background: linear-gradient(180deg, var(--primary), var(--primary-2));
  color: white;
}

.btn.danger {
  background: rgba(255,125,125,.14);
  color: var(--danger);
}

.btn.small {
  min-height: 40px;
  border-radius: 14px;
  padding: 0 12px;
}

.icon-btn {
  width: 48px;
  padding: 0;
  font-size: 18px;
}

.nav-btn {
  flex: 1;
  min-height: 58px;
  border-radius: 18px;
  font-size: 13px;
  font-weight: 600;
  background: transparent;
}

.nav-btn.active {
  background: rgba(138,180,248,.15);
  color: var(--primary);
}

.bottom-nav {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  background: rgba(15,20,26,.92);
  backdrop-filter: blur(16px);
  border-top: 1px solid var(--border);
}

[data-theme="light"] .bottom-nav {
  background: rgba(245,247,251,.92);
}

.input, textarea, select {
  width: 100%;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 14px 14px;
  outline: none;
}

textarea { min-height: 110px; resize: vertical; }

.list {
  display: grid;
  gap: 10px;
}

.item {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 12px;
}

.item-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.item-title {
  font-weight: 700;
  margin: 0;
}

.item-meta {
  color: var(--muted);
  font-size: 12px;
  margin-top: 4px;
}

.checkline {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(255,255,255,.02);
  border: 1px solid var(--border);
}

.checkline input[type="checkbox"] {
  width: 20px;
  height: 20px;
}

.progress {
  width: 100%;
  height: 12px;
  border-radius: 999px;
  background: var(--surface-2);
  overflow: hidden;
  border: 1px solid var(--border);
}

.progress > div {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), #7ad67a);
  width: 0%;
}

.timer-display {
  font-size: 54px;
  font-weight: 800;
  letter-spacing: -0.04em;
  text-align: center;
  margin: 8px 0 12px;
}

.mini-stat {
  display: grid;
  gap: 4px;
}
.mini-stat strong { font-size: 18px; }

.hidden { display: none !important; }