*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:      #0f172a;
  --surface: #1e293b;
  --surf2:   #334155;
  --primary: #6366f1;
  --red:     #ef4444;
  --orange:  #f97316;
  --blue:    #3b82f6;
  --green:   #22c55e;
  --text:    #f1f5f9;
  --muted:   #64748b;
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  user-select: none;
}

#app {
  height: 100vh;
  height: -webkit-fill-available;
  display: flex;
  flex-direction: column;
  max-width: 500px;
  margin: 0 auto;
}

/* ── Header ─────────────────────────────── */
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px 10px;
  padding-top: max(14px, calc(14px + env(safe-area-inset-top)));
  flex-shrink: 0;
}

header h1 {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.hdr-btns { display: flex; gap: 8px; }

.icon-btn {
  background: var(--surface);
  border: none;
  border-radius: 50%;
  width: 40px; height: 40px;
  font-size: 18px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: var(--text);
  transition: background 0.15s;
}
.icon-btn:active { background: var(--surf2); }

/* ── Stats ───────────────────────────────── */
#stats {
  display: flex;
  gap: 10px;
  padding: 0 20px 14px;
  flex-shrink: 0;
}

.stat {
  flex: 1;
  background: var(--surface);
  border-radius: 14px;
  padding: 12px 8px;
  text-align: center;
  cursor: pointer;
  transition: transform 0.1s;
}
.stat:active { transform: scale(0.96); }

.stat-num {
  font-size: 30px;
  font-weight: 700;
  line-height: 1;
}
.stat-lbl {
  font-size: 10px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  margin-top: 4px;
}

.stat-red    .stat-num { color: var(--red); }
.stat-orange .stat-num { color: var(--orange); }
.stat-blue   .stat-num { color: var(--blue); }

/* ── Tabs ────────────────────────────────── */
#tabs {
  display: flex;
  gap: 8px;
  padding: 0 20px 10px;
  overflow-x: auto;
  flex-shrink: 0;
  scrollbar-width: none;
}
#tabs::-webkit-scrollbar { display: none; }

.tab {
  background: var(--surface);
  border: none;
  border-radius: 20px;
  padding: 7px 16px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  display: flex; align-items: center; gap: 5px;
  transition: background 0.15s, color 0.15s;
}
.tab.active { background: var(--primary); color: #fff; }

.tab-cnt {
  font-size: 11px;
  background: rgba(255,255,255,0.22);
  border-radius: 9px;
  padding: 1px 5px;
  display: none;
}
.tab-cnt.has-count { display: inline; }

/* ── Error ───────────────────────────────── */
#error-bar {
  display: none;
  margin: 0 20px 8px;
  padding: 10px 14px;
  background: rgba(239,68,68,0.15);
  border: 1px solid rgba(239,68,68,0.4);
  border-radius: 10px;
  font-size: 13px;
  color: #fca5a5;
  flex-shrink: 0;
}

/* ── Task list ───────────────────────────── */
#list {
  flex: 1;
  overflow-y: auto;
  padding: 4px 20px;
  padding-bottom: calc(88px + env(safe-area-inset-bottom));
  -webkit-overflow-scrolling: touch;
}

.task-card {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  background: var(--surface);
  border-radius: 14px;
  padding: 14px 12px 14px 14px;
  margin-bottom: 9px;
  border-left: 4px solid transparent;
  animation: fadeUp 0.2s ease;
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.task-overdue { border-left-color: var(--red); }
.task-today   { border-left-color: var(--orange); }
.task-soon    { border-left-color: var(--blue); }
.task-done    { opacity: 0.45; }

.chk {
  width: 26px; height: 26px;
  border-radius: 50%;
  border: 2px solid var(--surf2);
  background: none;
  cursor: pointer;
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  margin-top: 1px;
  transition: background 0.15s, border-color 0.15s;
}
.chk.checked { background: var(--green); border-color: var(--green); }

.task-body { flex: 1; min-width: 0; }

.task-title {
  font-size: 15px;
  font-weight: 500;
  line-height: 1.35;
  word-break: break-word;
}
.task-title.struck {
  text-decoration: line-through;
  color: var(--muted);
}

.task-notes {
  font-size: 12px;
  color: var(--muted);
  margin-top: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.due-tag {
  display: inline-block;
  margin-top: 6px;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 9px;
  border-radius: 10px;
  letter-spacing: 0.2px;
}
.due-overdue { background: rgba(239,68,68,0.18);  color: #fca5a5; }
.due-today   { background: rgba(249,115,22,0.18); color: #fdba74; }
.due-soon    { background: rgba(59,130,246,0.18);  color: #93c5fd; }
.due-later   { background: var(--surf2); color: var(--muted); }
.due-done    { background: rgba(34,197,94,0.18);  color: #86efac; }

.del-btn {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 22px;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
  flex-shrink: 0;
  transition: color 0.15s;
}
.del-btn:active { color: var(--red); }

/* ── Empty ───────────────────────────────── */
.empty {
  text-align: center;
  padding: 64px 20px;
}
.empty-icon { font-size: 52px; margin-bottom: 14px; }
.empty p { color: var(--muted); font-size: 15px; }

/* ── FAB ─────────────────────────────────── */
#fab {
  position: fixed;
  bottom: calc(22px + env(safe-area-inset-bottom));
  right: 22px;
  width: 58px; height: 58px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-size: 30px;
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 24px rgba(99,102,241,0.5);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
  line-height: 1;
  transition: transform 0.15s;
}
#fab:active { transform: scale(0.93); }

/* ── Modals ──────────────────────────────── */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.65);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 200;
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
}

.sheet {
  background: var(--surface);
  border-radius: 24px 24px 0 0;
  padding: 24px;
  padding-bottom: max(24px, calc(24px + env(safe-area-inset-bottom)));
  width: 100%;
  max-width: 500px;
  animation: up 0.25s cubic-bezier(0.32, 0.72, 0, 1);
}

@keyframes up {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}

.sheet-hdr {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 20px;
}
.sheet-hdr h2 { font-size: 20px; font-weight: 600; }

.close-btn {
  background: var(--surf2);
  border: none; border-radius: 50%;
  width: 32px; height: 32px;
  color: var(--text); font-size: 15px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}

/* Setup modal — centered */
#setup-modal { align-items: center; }
#setup-modal .sheet {
  border-radius: 22px;
  text-align: center;
  padding-bottom: 24px;
  max-width: 340px;
  margin: 16px;
}
.setup-emoji { font-size: 54px; margin-bottom: 14px; }
#setup-modal h2 { margin-bottom: 8px; }
#setup-modal p { font-size: 14px; color: var(--muted); margin-bottom: 20px; line-height: 1.5; }

/* ── Forms ───────────────────────────────── */
.fgroup { margin-bottom: 13px; }
.fgroup label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.4px; }

.row { display: flex; gap: 8px; }

input, textarea {
  width: 100%;
  background: var(--surf2);
  border: none;
  border-radius: 12px;
  padding: 13px 14px;
  color: var(--text);
  font-size: 16px;
  font-family: inherit;
  outline: none;
  transition: box-shadow 0.15s;
}
input:focus, textarea:focus { box-shadow: 0 0 0 2px var(--primary); }
textarea { resize: none; }
input[type="date"] { color-scheme: dark; }

#mic-btn {
  background: var(--surf2);
  border: none;
  border-radius: 12px;
  padding: 0 16px;
  font-size: 20px;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s;
}
#mic-btn.listening {
  background: rgba(239,68,68,0.25);
  animation: blink 0.9s infinite;
}
@keyframes blink {
  0%,100% { opacity: 1; }
  50%      { opacity: 0.55; }
}

.btn-primary {
  width: 100%;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 14px;
  padding: 15px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  margin-top: 6px;
  transition: opacity 0.15s;
}
.btn-primary:disabled { opacity: 0.5; }
.btn-primary:active   { opacity: 0.85; }

/* ── Loading spinner ─────────────────────── */
.spinner {
  text-align: center;
  padding: 60px;
  color: var(--muted);
  font-size: 14px;
}
