* { box-sizing: border-box; }
[hidden] { display: none !important; }

:root {
  --accent: #6366f1;
  --bg: #0e0e11;
  --card: #1b1b1f;
  --text: #f2f2f3;
  --text-muted: #9a9aa2;
  --border: #2e2e34;
  --danger: #f87171;
}

input[type="color"] {
  background: var(--card);
  border: 1px solid var(--border);
}

input[type="date"]::-webkit-calendar-picker-indicator {
  filter: invert(1);
}

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

#app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  padding-bottom: env(safe-area-inset-bottom);
}

header.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(12px + env(safe-area-inset-top)) 16px 12px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

header.topbar h1 {
  font-size: 20px;
  margin: 0;
}

main {
  flex: 1;
  padding: 16px;
  padding-bottom: 90px;
  overflow-y: auto;
}

button {
  font: inherit;
  cursor: pointer;
}

.btn {
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 10px;
  padding: 10px 16px;
  font-weight: 600;
}

.btn.secondary {
  background: var(--border);
  color: var(--text);
}

.btn.icon {
  background: transparent;
  color: var(--accent);
  padding: 6px;
}

input[type="text"], input[type="password"], input[type="date"], textarea, select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 16px;
  background: var(--card);
  color: var(--text);
}

/* Login screen */
#login-screen {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  padding: 24px;
  gap: 16px;
}

#login-screen h1 { margin-bottom: 8px; }
#login-screen .btn { text-decoration: none; text-align: center; }
#login-error { color: var(--danger); font-size: 14px; min-height: 18px; }

/* Bottom nav */
nav.tabbar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  background: var(--card);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
  z-index: 10;
}

nav.tabbar button {
  flex: 1;
  background: none;
  border: none;
  padding: 10px 4px;
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

nav.tabbar button.active { color: var(--accent); font-weight: 600; }
nav.tabbar button .emoji { font-size: 20px; }

/* Date nav */
.date-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.date-nav .label { font-weight: 600; font-size: 16px; text-transform: capitalize; }

/* Cards */
.card {
  background: var(--card);
  border-radius: 14px;
  padding: 14px;
  margin-bottom: 12px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}

.event-card .event-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.category-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.event-time { font-size: 13px; color: var(--text-muted); }
.event-title { font-weight: 600; flex: 1; }

.task-row, .habit-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-top: 1px solid var(--border);
}

.task-row:first-of-type, .habit-row:first-of-type { border-top: none; }

.task-row input[type="checkbox"], .habit-row input[type="checkbox"] {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.task-row span.done, .habit-row span.done { text-decoration: line-through; color: var(--text-muted); }

.inline-add {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.inline-add input { flex: 1; }

.empty-state {
  text-align: center;
  color: var(--text-muted);
  padding: 40px 20px;
}

.week-day-heading {
  font-weight: 700;
  font-size: 14px;
  color: var(--text-muted);
  margin: 20px 0 8px;
  text-transform: capitalize;
}

.week-day-heading:first-child { margin-top: 0; }

.note-body { white-space: pre-wrap; font-size: 14px; }
.note-meta { font-size: 12px; color: var(--text-muted); margin-top: 6px; display: flex; justify-content: space-between; }

.category-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  background: var(--border);
  margin-bottom: 8px;
}

.top-actions { display: flex; gap: 8px; }
