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

:root {
  --bg:        #0d0d0d;
  --surface:   #161616;
  --surface2:  #1e1e1e;
  --border:    #2a2a2a;
  --accent:    #3b82f6;
  --accent-dim:#1d4ed8;
  --success:   #22c55e;
  --warning:   #f59e0b;
  --danger:    #ef4444;
  --text:      #e8e8e8;
  --muted:     #6b7280;
  --radius:    8px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  font-size: 14px;
  line-height: 1.5;
}

/* ── Header ─────────────────────────────────── */
header {
  position: sticky; top: 0; z-index: 100;
  display: flex; align-items: center; gap: 24px;
  padding: 0 24px; height: 52px;
  background: var(--surface); border-bottom: 1px solid var(--border);
}
.logo { font-size: 16px; font-weight: 700; letter-spacing: -0.5px; color: var(--text); flex-shrink: 0; }

nav { display: flex; gap: 2px; }
nav button {
  background: none; border: none; color: var(--muted); cursor: pointer;
  padding: 6px 12px; border-radius: 6px; font-size: 13px; font-weight: 500;
  transition: color .15s, background .15s;
}
nav button:hover { color: var(--text); background: var(--surface2); }
nav button.active { color: var(--text); background: var(--surface2); }

.header-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
#clock { color: var(--muted); font-variant-numeric: tabular-nums; font-size: 13px; }
#focus-badge {
  font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: 100px;
  background: #1a2e1a; color: var(--success); display: none;
}
#focus-badge.visible { display: block; }

/* ── Layout ─────────────────────────────────── */
main { padding: 24px; max-width: 1200px; margin: 0 auto; }

.view-title {
  font-size: 20px; font-weight: 700; margin-bottom: 20px; letter-spacing: -0.3px;
}

/* ── Cards ───────────────────────────────────── */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px;
}
.card-title {
  font-size: 11px; font-weight: 700; letter-spacing: .08em;
  text-transform: uppercase; color: var(--muted); margin-bottom: 14px;
}

/* ── Dashboard grid ──────────────────────────── */
.dash-grid {
  display: grid;
  grid-template-columns: 1fr 240px 220px;
  gap: 16px;
  margin-bottom: 16px;
}
@media (max-width: 900px) {
  .dash-grid { grid-template-columns: 1fr; }
}

/* ── Agenda list ─────────────────────────────── */
.agenda-empty { color: var(--muted); font-size: 13px; padding: 8px 0; }

.agenda-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 0; border-bottom: 1px solid var(--border);
}
.agenda-item:last-child { border-bottom: none; }
.agenda-time { color: var(--muted); font-variant-numeric: tabular-nums; font-size: 12px; min-width: 42px; }
.agenda-title { flex: 1; font-size: 13px; }
.agenda-priority { width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; }
.priority-high   { background: var(--danger); }
.priority-medium { background: var(--warning); }
.priority-low    { background: var(--muted); }

/* ── Focus card ──────────────────────────────── */
.focus-card { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 12px; }

.focus-timer {
  font-size: 42px; font-weight: 700; font-variant-numeric: tabular-nums;
  letter-spacing: -2px; color: var(--text); line-height: 1;
}
.focus-label { font-size: 12px; color: var(--muted); min-height: 16px; }
.focus-idle { color: var(--muted); font-size: 13px; margin-top: 4px; }

/* ── Habits list ─────────────────────────────── */
.habit-row {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 0; border-bottom: 1px solid var(--border);
}
.habit-row:last-child { border-bottom: none; }
.habit-name { flex: 1; font-size: 13px; }
.habit-streak { font-size: 11px; color: var(--muted); }
.habit-check {
  width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--border);
  background: none; cursor: pointer; color: transparent; font-size: 12px;
  transition: all .15s; flex-shrink: 0; display: flex; align-items: center; justify-content: center;
}
.habit-check.done { background: var(--success); border-color: var(--success); color: #fff; }
.habit-check:not(.done):hover { border-color: var(--success); }

/* ── Upcoming strip ──────────────────────────── */
.upcoming-list { display: flex; flex-direction: column; gap: 8px; }
.upcoming-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px; background: var(--surface2); border-radius: 6px;
  border: 1px solid var(--border);
}
.upcoming-delta { font-size: 11px; color: var(--muted); min-width: 56px; font-variant-numeric: tabular-nums; }
.upcoming-title { flex: 1; font-size: 13px; }
.upcoming-date  { font-size: 11px; color: var(--muted); }

/* ── Buttons ─────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px; border-radius: 6px; border: none;
  font-size: 13px; font-weight: 500; cursor: pointer; transition: opacity .15s;
  font-family: inherit;
}
.btn:hover { opacity: .85; }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn-primary  { background: var(--accent); color: #fff; }
.btn-success  { background: var(--success); color: #fff; }
.btn-danger   { background: var(--danger); color: #fff; }
.btn-ghost    { background: var(--surface2); color: var(--text); border: 1px solid var(--border); }
.btn-sm       { padding: 4px 10px; font-size: 12px; }
.btn-icon     { padding: 5px 8px; font-size: 14px; }

/* ── Forms ───────────────────────────────────── */
.form-row { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.form-row:last-child { margin-bottom: 0; }

input[type="text"], input[type="email"], input[type="tel"],
input[type="datetime-local"], input[type="date"],
select, textarea {
  background: var(--surface2); border: 1px solid var(--border);
  color: var(--text); border-radius: 6px; padding: 7px 10px;
  font-size: 13px; font-family: inherit;
  transition: border-color .15s;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent);
}
input::placeholder, textarea::placeholder { color: var(--muted); }
textarea { resize: vertical; min-height: 72px; }
.input-grow { flex: 1; min-width: 0; }

label { font-size: 12px; color: var(--muted); margin-bottom: 4px; display: block; }

/* ── Tasks view ──────────────────────────────── */
.tasks-toolbar { display: flex; gap: 8px; margin-bottom: 16px; }
.task-list { display: flex; flex-direction: column; gap: 6px; }
.task-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius);
}
.task-check-btn {
  width: 18px; height: 18px; border-radius: 4px; border: 2px solid var(--border);
  background: none; cursor: pointer; flex-shrink: 0; transition: all .15s;
}
.task-check-btn:hover { border-color: var(--success); background: #1a2e1a; }
.task-info { flex: 1; min-width: 0; }
.task-title-text { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.task-meta { font-size: 11px; color: var(--muted); margin-top: 2px; }
.task-due-soon { color: var(--warning); }
.task-overdue  { color: var(--danger); }
.task-pill {
  font-size: 10px; font-weight: 600; padding: 2px 7px; border-radius: 100px;
  background: var(--surface2); color: var(--muted); flex-shrink: 0;
}

/* ── Add task form ───────────────────────────── */
.add-task-form {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px; margin-bottom: 16px;
}
.add-task-form h3 { font-size: 13px; font-weight: 600; margin-bottom: 12px; }

/* ── Journal ─────────────────────────────────── */
.journal-entry {
  padding: 14px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); margin-bottom: 8px;
}
.journal-entry-time { font-size: 11px; color: var(--muted); margin-bottom: 6px; }
.journal-entry-content { font-size: 13px; line-height: 1.6; white-space: pre-wrap; }
.journal-tags { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.tag-chip {
  font-size: 10px; font-weight: 500; padding: 2px 8px;
  border-radius: 100px; background: var(--surface2); color: var(--muted);
  border: 1px solid var(--border);
}

/* ── Contacts ────────────────────────────────── */
.contact-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px;
}
.contact-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; cursor: pointer; transition: border-color .15s;
}
.contact-card:hover { border-color: var(--accent); }
.contact-name { font-size: 14px; font-weight: 600; margin-bottom: 4px; }
.contact-detail { font-size: 12px; color: var(--muted); }

/* ── Habits view ─────────────────────────────── */
.habits-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.habit-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; display: flex; flex-direction: column; gap: 10px;
}
.habit-card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.habit-card-name { font-size: 14px; font-weight: 600; }
.habit-card-freq { font-size: 11px; color: var(--muted); }
.streak-count { font-size: 28px; font-weight: 700; color: var(--warning); line-height: 1; }
.streak-label { font-size: 11px; color: var(--muted); }

/* ── Modal ───────────────────────────────────── */
#modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,.7);
  display: flex; align-items: center; justify-content: center; z-index: 1000;
}
#modal-backdrop.hidden { display: none; }
#modal-box {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 24px; width: 480px; max-width: calc(100vw - 32px);
  position: relative; max-height: 80vh; overflow-y: auto;
}
.modal-close {
  position: absolute; top: 16px; right: 16px;
  background: none; border: none; color: var(--muted); cursor: pointer; font-size: 16px;
}
#modal-box h2 { font-size: 16px; font-weight: 700; margin-bottom: 16px; }

/* ── Auth gate ───────────────────────────────── */
#auth-gate {
  position: fixed; inset: 0; background: var(--bg);
  display: flex; align-items: center; justify-content: center; z-index: 2000;
}
.auth-box {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 32px; width: 400px; max-width: calc(100vw - 32px);
  text-align: center;
}
.auth-box h2 { font-size: 22px; font-weight: 700; margin-bottom: 8px; }
.auth-box p  { color: var(--muted); font-size: 13px; margin-bottom: 20px; }

/* ── Misc ────────────────────────────────────── */
.divider { border: none; border-top: 1px solid var(--border); margin: 16px 0; }
.empty { color: var(--muted); font-size: 13px; padding: 24px 0; text-align: center; }
.error-msg { color: var(--danger); font-size: 12px; margin-top: 4px; }

.section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.section-title { font-size: 14px; font-weight: 600; }

/* subtask indentation */
.task-item + .task-item[style*='margin-left'] { margin-top: 4px; }

/* inline edit button — appears on hover */
.edit-inline-btn {
  background: none; border: none; color: var(--muted); cursor: pointer;
  font-size: 11px; opacity: 0; transition: opacity .15s; vertical-align: middle; padding: 0 2px;
}
.task-item:hover .edit-inline-btn,
.habit-card:hover .edit-inline-btn { opacity: 1; }

/* completed tasks */
.task-check-done {
  width: 18px; height: 18px; border-radius: 4px; background: var(--success);
  color: #fff; font-size: 11px; display: flex; align-items: center;
  justify-content: center; flex-shrink: 0;
}
