:root {
  --bg: #0f172a;
  --surface: #1e293b;
  --surface-2: #273449;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --accent: #38bdf8;
  --danger: #f87171;
  --radius: 14px;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.35);
}

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

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  display: flex;
  justify-content: center;
}

.app {
  width: 100%;
  max-width: 640px;
  padding: 1rem 1rem calc(1rem + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 1rem;
  min-height: 100dvh;
}

.topbar {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
}

.topbar h1 {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.status {
  font-size: 0.8rem;
  color: var(--muted);
}

.status.listening { color: var(--danger); font-weight: 600; }
.status.offline { color: var(--danger); }

.composer {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  background: var(--surface);
  border-radius: var(--radius);
  padding: 0.5rem;
  box-shadow: var(--shadow);
}

.composer:focus-within { outline: 2px solid var(--accent); }

.composer-row {
  display: flex;
  gap: 0.5rem;
}

.composer-row.secondary input {
  flex: 1;
  min-width: 0;
  background: var(--bg);
  border: none;
  border-radius: 10px;
  outline: none;
  color: var(--text);
  font-size: 0.9rem;
  padding: 0.5rem 0.75rem;
  color-scheme: dark;
}

.composer-row.secondary input::placeholder { color: var(--muted); }

#new-todo {
  flex: 1;
  min-width: 0;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text);
  font-size: 1rem;
  padding: 0.5rem 0.75rem;
}

#new-todo::placeholder { color: var(--muted); }

button {
  font: inherit;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  color: var(--text);
  background: var(--surface-2);
  min-width: 44px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

button:active { transform: scale(0.95); }

.mic.listening { background: var(--danger); animation: pulse 1.2s ease-in-out infinite; }

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(248, 113, 113, 0.5); }
  50% { box-shadow: 0 0 0 10px rgba(248, 113, 113, 0); }
}

.add {
  background: var(--accent);
  color: #082f49;
  font-size: 1.4rem;
  font-weight: 700;
  padding: 0 0.9rem;
}

.dictation {
  font-size: 0.95rem;
  color: var(--accent);
  padding: 0 0.5rem;
  min-height: 1.4em;
  font-style: italic;
}

.todos {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  flex: 1;
}

.todo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: var(--surface);
  border-radius: var(--radius);
  padding: 0.75rem 0.9rem;
  box-shadow: var(--shadow);
}

.todo .check {
  flex: none;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 2px solid var(--muted);
  background: transparent;
  min-width: 26px;
  min-height: 26px;
  padding: 0;
}

.todo.done .check {
  background: var(--accent);
  border-color: var(--accent);
  color: #082f49;
}

.todo .label {
  flex: 1;
  min-width: 0;
  font-size: 1rem;
  overflow-wrap: anywhere;
  background: transparent;
  border: none;
  color: var(--text);
  font: inherit;
  outline: none;
  padding: 0.15rem 0;
}

.todo.done .label { color: var(--muted); text-decoration: line-through; }

.todo .label[readonly] { cursor: default; }

.todo .del {
  flex: none;
  background: transparent;
  color: var(--muted);
  font-size: 1.1rem;
  min-width: 36px;
  min-height: 36px;
}

.todo .del:hover { color: var(--danger); }

.empty {
  color: var(--muted);
  text-align: center;
  padding: 2rem 1rem;
  font-size: 0.95rem;
}

.footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--muted);
  font-size: 0.8rem;
  padding-bottom: 0.5rem;
}

.link {
  background: none;
  min-height: 0;
  color: var(--muted);
  text-decoration: underline;
  font-size: 0.8rem;
}

.link:hover { color: var(--danger); }

.login-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 10;
}

.login-overlay[hidden] { display: none; }

.login-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  width: 100%;
  max-width: 320px;
}

.login-card h2 { font-size: 1.2rem; }

.login-card input {
  background: var(--bg);
  border: none;
  border-radius: 10px;
  outline: none;
  color: var(--text);
  font-size: 1rem;
  padding: 0.7rem 0.9rem;
}

.login-card input:focus { outline: 2px solid var(--accent); }

.login-card button[type="submit"] {
  background: var(--accent);
  color: #082f49;
  font-weight: 700;
  padding: 0.7rem;
}

.login-error { color: var(--danger); font-size: 0.85rem; text-align: center; }

@media (min-width: 768px) {
  .app { max-width: 720px; padding-top: 3rem; gap: 1.25rem; }
  .topbar h1 { font-size: 2rem; }
  #new-todo { font-size: 1.1rem; }
  .todo { padding: 1rem 1.1rem; }
  .todo .label { font-size: 1.05rem; }
  .composer-row.secondary input { font-size: 1rem; }
}
