/* LifeOS — Dashboard-first, dark theme, iPhone-optimized */
:root {
  --bg: #0f172a;
  --bg-card: #1e293b;
  --bg-input: #334155;
  --bg-elevated: #1a2332;
  --text: #e2e8f0;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  --accent: #38bdf8;
  --accent-hover: #7dd3fc;
  --green: #4ade80;
  --orange: #fb923c;
  --red: #f87171;
  --purple: #a78bfa;
  --pink: #f472b6;
  --yellow: #fbbf24;
  --teal: #2dd4bf;
  --border: #1e293b;
  --border-subtle: #162032;
  --radius: 12px;
  --radius-sm: 8px;

  /* Category colors */
  --cat-islam: #4ade80;
  --cat-idea: #a78bfa;
  --cat-action: #fb923c;
  --cat-task: #fb923c;
  --cat-tech: #38bdf8;
  --cat-career: #2dd4bf;
  --cat-finance: #fbbf24;
  --cat-entertainment: #f472b6;
  --cat-link: #64748b;
  --cat-health: #4ade80;
  --cat-family: #f472b6;
  --cat-uncategorized: #475569;
}

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

html, body {
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

body {
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

/* ===== NAVIGATION ===== */
.nav {
  display: flex;
  justify-content: space-around;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(15, 23, 42, 0.95);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
  padding: 6px 0 calc(6px + env(safe-area-inset-bottom));
  z-index: 100;
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 4px 12px;
  color: var(--text-dim);
  text-decoration: none;
  font-size: 10px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  background: none;
  transition: color 0.15s;
}

.nav-item.active { color: var(--accent); }
.nav-item svg { width: 22px; height: 22px; }

/* ===== VIEWS ===== */
.view { display: none; padding: 16px; padding-bottom: 80px; min-height: 100vh; }
.view.active { display: block; }

/* ===== DASHBOARD ===== */
.dash-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 24px;
  padding-top: 8px;
}

.dash-greeting {
  font-size: 14px;
  color: var(--text-muted);
  font-weight: 500;
}

.dash-date {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  margin-top: 2px;
}

.dash-stats {
  display: flex;
  gap: 12px;
}

.stat-pill {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 6px 10px;
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.stat-pill .stat-num {
  font-size: 18px;
  font-weight: 700;
  color: var(--accent);
  line-height: 1;
}

.stat-pill .stat-label {
  font-size: 10px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: 2px;
}

/* Dashboard sections */
.dash-section {
  margin-bottom: 24px;
}

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

.section-header h2 {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.8px;
}

.section-count {
  font-size: 12px;
  color: var(--text-dim);
  background: var(--bg-card);
  padding: 1px 8px;
  border-radius: 10px;
}

/* Dashboard task items */
.dash-task {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  margin-bottom: 6px;
  border-left: 3px solid var(--cat-action);
}

.dash-task input[type="checkbox"] {
  margin-top: 3px;
  accent-color: var(--accent);
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.dash-task-content {
  flex: 1;
  min-width: 0;
}

.dash-task-text {
  font-size: 14px;
  color: var(--text);
  line-height: 1.4;
}

.dash-task-meta {
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 3px;
}

/* Carry forward tasks */
.cf-task {
  border-left-color: var(--orange);
  opacity: 0.85;
}

/* Project cards on dashboard */
.dash-project {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 14px;
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  margin-bottom: 6px;
  border-left: 3px solid var(--purple);
  cursor: pointer;
}

.dash-project-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.dash-project-meta {
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 2px;
}

/* Category group in inbox */
.cat-group {
  margin-bottom: 16px;
}

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

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

.cat-label {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.cat-count {
  font-size: 11px;
  color: var(--text-dim);
}

.cat-item {
  padding: 10px 14px;
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  margin-bottom: 4px;
  font-size: 14px;
  color: var(--text);
  line-height: 1.4;
  border-left: 3px solid var(--cat-uncategorized);
}

.cat-item a { color: var(--accent); text-decoration: none; word-break: break-all; }
.cat-item a:hover { text-decoration: underline; }

/* Chip row for recent pages */
.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip {
  display: inline-block;
  padding: 6px 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 13px;
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.15s;
}

.chip:active { background: var(--bg-input); }

/* Empty state */
.empty-state {
  text-align: center;
  padding: 24px 16px;
  color: var(--text-dim);
  font-size: 14px;
}

/* ===== CAPTURE ===== */
.capture-area {
  width: 100%;
  min-height: 200px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 16px;
  padding: 16px;
  resize: vertical;
  font-family: inherit;
  line-height: 1.5;
}

.capture-area:focus { outline: none; border-color: var(--accent); }
.capture-area::placeholder { color: var(--text-dim); }

.tag-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.tag {
  padding: 6px 14px;
  border-radius: 20px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 13px;
  cursor: pointer;
}

.tag.selected { background: var(--accent); color: var(--bg); border-color: var(--accent); }

.btn {
  display: block;
  width: 100%;
  padding: 14px;
  margin-top: 16px;
  background: var(--accent);
  color: var(--bg);
  border: none;
  border-radius: var(--radius);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
}

.btn:active { background: var(--accent-hover); }
.btn:disabled { opacity: 0.5; cursor: default; }

/* ===== HEADER ===== */
.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.header h1 { font-size: 24px; font-weight: 700; }

/* ===== CARDS ===== */
.card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
  border: 1px solid var(--border);
}

.card-title { font-weight: 600; margin-bottom: 4px; }
.card-meta { font-size: 13px; color: var(--text-muted); }

/* ===== SEARCH ===== */
.search-input {
  width: 100%;
  padding: 12px 16px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 16px;
  margin-bottom: 16px;
}

.search-input:focus { outline: none; border-color: var(--accent); }

/* ===== GRAPH ===== */
#graph-canvas {
  width: 100%;
  height: calc(100vh - 140px);
  background: var(--bg);
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

/* ===== BADGES ===== */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
}

.badge-active { background: rgba(74, 222, 128, 0.15); color: var(--green); }
.badge-idea { background: rgba(167, 139, 250, 0.15); color: var(--purple); }
.badge-paused { background: rgba(251, 146, 60, 0.15); color: var(--orange); }
.badge-warning { background: rgba(251, 146, 60, 0.15); color: var(--orange); }

/* ===== TOAST ===== */
.toast {
  position: fixed;
  top: calc(20px + env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  background: var(--green);
  color: var(--bg);
  padding: 10px 24px;
  border-radius: 20px;
  font-weight: 600;
  font-size: 14px;
  opacity: 0;
  transition: opacity 0.3s;
  z-index: 200;
}

.toast.show { opacity: 1; }

/* ===== PAGE LIST ===== */
.page-list { list-style: none; }
.page-list li {
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}
.page-list li:last-child { border-bottom: none; }

/* Wiki link styling */
.wiki-link { color: var(--accent); text-decoration: none; cursor: pointer; }
.wiki-link:hover { text-decoration: underline; }

/* ===== LOGIN ===== */
.login-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: var(--bg);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.login-overlay.hidden { display: none; }
.login-box {
  text-align: center;
  width: 100%;
  max-width: 320px;
}
.login-input {
  width: 100%;
  padding: 14px 16px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 18px;
  text-align: center;
  letter-spacing: 2px;
}
.login-input:focus { outline: none; border-color: var(--accent); }
.login-error {
  color: var(--red);
  font-size: 14px;
  min-height: 24px;
  margin-top: 8px;
}
.login-btn { margin-top: 8px; }
