:root {
  --bg: #0f0f0f;
  --surface: #1a1a1a;
  --border: #2a2a2a;
  --text: #e8e8e8;
  --muted: #888;
  --accent: #4f8ef7;
  --accent-dim: #1e3a6e;
  --danger: #e05;
  --success: #2d9;
  --radius: 10px;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100%;
}

/* Nav */
.nav {
  display: flex;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
}
.nav-btn {
  flex: 1;
  padding: 14px;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: color 0.15s;
  border-bottom: 2px solid transparent;
}
.nav-btn.active { color: var(--accent); border-bottom-color: var(--accent); }

/* Views */
.view { display: none; flex-direction: column; flex: 1; overflow: hidden; }
.view.active { display: flex; }

.view-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.view-header h2 { font-size: 16px; font-weight: 600; }

/* Chat */
.messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.message {
  max-width: 82%;
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 15px;
  line-height: 1.5;
  white-space: pre-wrap;
}
.message.user {
  align-self: flex-end;
  background: var(--accent-dim);
  color: var(--text);
  border-bottom-right-radius: 3px;
}
.message.assistant {
  align-self: flex-start;
  background: var(--surface);
  border: 1px solid var(--border);
  border-bottom-left-radius: 3px;
}
.message.thinking {
  align-self: flex-start;
  background: var(--surface);
  border: 1px solid var(--border);
  border-bottom-left-radius: 3px;
  color: var(--muted);
  font-style: italic;
}

.input-bar {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
  align-items: flex-end;
}
.input-bar textarea {
  flex: 1;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  padding: 10px 14px;
  resize: none;
  max-height: 120px;
  overflow-y: auto;
  line-height: 1.4;
}
.input-bar textarea:focus { outline: none; border-color: var(--accent); }
.input-bar button {
  background: var(--accent);
  border: none;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  color: white;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: opacity 0.15s;
}
.input-bar button:disabled { opacity: 0.4; cursor: default; }

/* Todos */
.todo-list {
  flex: 1;
  overflow-y: auto;
  padding: 12px 16px;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.todo-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}
.todo-item input[type=checkbox] {
  margin-top: 2px;
  accent-color: var(--accent);
  width: 16px;
  height: 16px;
  cursor: pointer;
  flex-shrink: 0;
}
.todo-body { flex: 1; min-width: 0; }
.todo-title { font-size: 15px; line-height: 1.4; }
.todo-meta { font-size: 12px; color: var(--muted); margin-top: 3px; }
.priority-high { border-left: 3px solid var(--danger); }
.priority-normal { border-left: 3px solid var(--border); }
.priority-low { border-left: 3px solid var(--muted); }

/* Dashboard */
.dashboard {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.dash-section h3 {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 10px;
}

.dash-stat-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.dash-stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  text-align: center;
}
.dash-stat .value { font-size: 24px; font-weight: 600; }
.dash-stat .label { font-size: 12px; color: var(--muted); margin-top: 2px; }

.habit-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 6px;
}
.habit-bar-bg {
  width: 80px;
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
}
.habit-bar-fill { height: 100%; background: var(--accent); border-radius: 3px; }

.icon-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 6px;
  padding: 6px 10px;
  cursor: pointer;
  font-size: 16px;
}
.icon-btn:hover { border-color: var(--accent); color: var(--accent); }

/* Scrollbar */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
