:root {
  --bg: #0f172a;
  --surface: #1e293b;
  --text: #f1f5f9;
  --muted: #94a3b8;
  --accent: #38bdf8;
  --danger: #f87171;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: env(safe-area-inset-top, 12px) 16px 12px;
  background: var(--surface);
}

.brand { font-weight: 600; }

.topbar-actions { display: flex; gap: 14px; align-items: center; }

.link-btn {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 0.9rem;
  text-decoration: none;
  cursor: pointer;
}

.chat-form {
  display: flex;
  gap: 8px;
  margin: 12px 0;
}

.chat-form input[type="text"] {
  flex: 1;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.12);
  background: var(--surface);
  color: var(--text);
  font-size: 1rem;
}

.chat-form button {
  padding: 10px 16px;
  border-radius: 10px;
  border: none;
  background: var(--accent);
  color: #05202e;
  font-weight: 600;
}

.chat-log { margin-bottom: 16px; }

.chat-turn { margin-bottom: 8px; }

.chat-user { color: var(--muted); font-size: 0.9rem; margin: 4px 0 2px; }
.chat-assistant { margin: 0 0 4px; }

.day {
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.day h2 {
  font-size: 0.95rem;
  color: var(--muted);
  margin: 0 0 6px;
  font-weight: 600;
}

.todo-list { list-style: none; padding: 0; margin: 0; }

.todo {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 0;
  gap: 8px;
}

.todo-done span:first-child { text-decoration: line-through; color: var(--muted); }
.todo-cancelled { display: none; }

.todo-actions { display: flex; gap: 6px; }
.todo-actions form { display: inline; }
.todo-actions button {
  font-size: 0.75rem;
  padding: 4px 8px;
  border-radius: 6px;
  border: 1px solid rgba(255,255,255,0.12);
  background: transparent;
  color: var(--text);
}

.page {
  padding: 16px;
  padding-bottom: calc(72px + env(safe-area-inset-bottom, 0px));
  max-width: 640px;
  margin: 0 auto;
}

h1 { font-size: 1.4rem; margin: 8px 0 16px; }
.muted { color: var(--muted); }

.tabbar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  background: var(--surface);
  border-top: 1px solid rgba(255,255,255,0.08);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

.tab {
  flex: 1;
  text-align: center;
  padding: 12px 4px;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.75rem;
}

.tab.active { color: var(--accent); }

.login-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 70vh;
  text-align: center;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  max-width: 280px;
}

.login-form input,
.login-form button {
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.12);
  font-size: 1rem;
}

.login-form input {
  background: var(--surface);
  color: var(--text);
}

.login-form button {
  background: var(--accent);
  color: #05202e;
  font-weight: 600;
  border: none;
}

.error { color: var(--danger); font-size: 0.9rem; }
