:root {
  --bg: #0f1115;
  --panel: #171a21;
  --border: #2a2f3a;
  --text: #e6e8ec;
  --muted: #8b93a3;
  --accent: #4f8cff;
}

* { box-sizing: border-box; }

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

.login-body {
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 32px;
  width: 280px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.login-card h1 { margin: 0 0 8px; font-size: 1.3rem; text-align: center; }

.login-card input,
.login-card button {
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  font-size: 1rem;
}

.login-card input { background: var(--bg); color: var(--text); }
.login-card button { background: var(--accent); color: white; border: none; cursor: pointer; }
.error { color: #ff6b6b; font-size: 0.85rem; margin: 0; }

.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
}

.tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
  padding-top: env(safe-area-inset-top);
}

.tab {
  flex: 1;
  padding: 14px;
  text-align: center;
  color: var(--muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
}

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

#views { flex: 1; min-height: 0; display: flex; }
.view { flex: 1; overflow-y: auto; display: none; padding: 12px; }
.view.active { display: flex; flex-direction: column; }

#chat-log {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-bottom: 12px;
}

.msg { max-width: 85%; padding: 10px 14px; border-radius: 14px; line-height: 1.4; white-space: pre-wrap; }
.msg.user { align-self: flex-end; background: var(--accent); color: white; }
.msg.assistant { align-self: flex-start; background: var(--panel); border: 1px solid var(--border); }

#chat-form {
  display: flex;
  gap: 8px;
  padding: 10px;
  padding-bottom: calc(10px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--border);
  background: var(--panel);
}

#chat-input {
  flex: 1;
  padding: 10px 14px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 1rem;
}

#chat-form button {
  border: none;
  background: var(--accent);
  color: white;
  border-radius: 20px;
  padding: 0 18px;
  cursor: pointer;
}

.todo-section-header {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  padding: 16px 4px 6px;
}

.todo-section-header:first-child { padding-top: 4px; }

.todo-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 4px;
  border-bottom: 1px solid var(--border);
  transition: opacity 0.2s ease;
}

.todo-item.completing { opacity: 0.35; }

.todo-check {
  flex: 0 0 auto;
  width: 24px;
  height: 24px;
  margin-top: 2px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: transparent;
  cursor: pointer;
  padding: 0;
}

.todo-check:active { background: var(--accent); border-color: var(--accent); }

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

.todo-title-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.todo-title-row .title { line-height: 1.35; }

.todo-meta-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
}

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

.priority-pill {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 1px 7px;
  border-radius: 8px;
  line-height: 1.5;
}

.priority-pill.priority-urgent { background: #4a1f22; color: #ff8a8a; }
.priority-pill.priority-high { background: #4a3a1f; color: #ffc477; }
.priority-pill.priority-low { background: #1f2a3a; color: #8fb3d9; }

.workspace-pill {
  font-size: 0.7rem;
  color: var(--muted);
  border: 1px solid var(--border);
  padding: 1px 7px;
  border-radius: 8px;
}

.todo-empty, .todo-loading {
  padding: 32px 12px;
  text-align: center;
  color: var(--muted);
  font-size: 0.9rem;
}

#todo-add {
  display: flex;
  gap: 8px;
  padding: 10px;
  padding-bottom: calc(10px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--border);
  background: var(--panel);
}

#todo-add input {
  flex: 1;
  padding: 10px 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
}

#todo-add button {
  border: none;
  background: var(--accent);
  color: white;
  border-radius: 8px;
  padding: 0 16px;
  cursor: pointer;
}

.settings-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 4px;
  border-bottom: 1px solid var(--border);
}
