/* ==========================================================================
   Life Dashboard — warm, personal, low-friction. One accent (teal), semantic
   colour (ok/warn/crit) reserved for status only.
   ========================================================================== */

:root {
  color-scheme: dark;

  --font-ui: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, system-ui, sans-serif;
  --font-mono: ui-monospace, "SF Mono", SFMono-Regular, "JetBrains Mono", Menlo, Consolas, monospace;

  --ground: #0b0f14;
  --surface: #12181f;
  --surface-2: #171f28;
  --sunken: #0a0e13;
  --line: #232c36;
  --line-soft: #1a222b;

  --text: #eef2f6;
  --text-2: #9aa7b4;
  --text-3: #67737f;

  --accent: #2dd4bf;
  --accent-ink: #06201c;
  --accent-wash: #12302c;
  --accent-line: #1f4a44;

  --ok: #3fc38c;
  --ok-wash: #10281f;
  --warn: #e0a444;
  --warn-wash: #2a2010;
  --crit: #f0736a;
  --crit-wash: #2c1512;

  --pink: #f472b6;
  --pink-wash: #2c1523;

  --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-2: 0 12px 34px -12px rgba(0, 0, 0, 0.6);

  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 16px;
}

@media (prefers-color-scheme: light) {
  :root {
    color-scheme: light;
    --ground: #f4f2ee;
    --surface: #ffffff;
    --surface-2: #faf8f4;
    --sunken: #ece8e1;
    --line: #e2ddd3;
    --line-soft: #ece8e1;

    --text: #211d17;
    --text-2: #5c564c;
    --text-3: #8a8375;

    --accent: #0f9d8d;
    --accent-ink: #ffffff;
    --accent-wash: #e2f5f2;
    --accent-line: #bfe6e0;

    --ok: #0f7a52;
    --ok-wash: #e2f4ec;
    --warn: #a76406;
    --warn-wash: #fbeed6;
    --crit: #bf2f27;
    --crit-wash: #fbe5e3;

    --pink: #c2255c;
    --pink-wash: #fbe3ee;

    --shadow-1: 0 1px 2px rgba(30, 20, 10, 0.08);
    --shadow-2: 0 12px 34px -12px rgba(30, 20, 10, 0.25);
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--ground);
  color: var(--text);
  font-family: var(--font-ui);
  -webkit-font-smoothing: antialiased;
}
button, input, textarea, select { font-family: inherit; color: inherit; }
h1, h2, h3, p { margin: 0; }

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

/* --------------------------------------------------------------- topbar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 5;
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; letter-spacing: -0.01em; }
.brand-mark { color: var(--accent); }
.topbar-date { color: var(--text-2); font-size: 13px; font-variant-numeric: tabular-nums; }

/* --------------------------------------------------------------- main */
.main {
  flex: 1;
  padding: 16px 16px 96px;
  max-width: 760px;
  width: 100%;
  margin: 0 auto;
}

/* --------------------------------------------------------------- tabbar */
.tabbar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  background: var(--surface);
  border-top: 1px solid var(--line);
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
  z-index: 10;
}
.tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  background: none;
  border: none;
  color: var(--text-3);
  padding: 6px 2px;
  border-radius: var(--r-sm);
  cursor: pointer;
  font-size: 11px;
}
.tab-ico { font-size: 15px; line-height: 1; }
.tab.active { color: var(--accent); }

@media (min-width: 720px) {
  .tabbar {
    position: sticky;
    top: 53px;
    bottom: auto;
    justify-content: center;
    gap: 6px;
    border-top: none;
    border-bottom: 1px solid var(--line);
    padding: 8px 16px;
  }
  .tab { flex: none; flex-direction: row; padding: 8px 14px; }
  .main { padding-bottom: 40px; }
}

/* --------------------------------------------------------------- cards */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 16px;
  margin-bottom: 14px;
  box-shadow: var(--shadow-1);
}
.card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 12px;
}
.card-title { font-size: 14px; font-weight: 700; }
.card-sub { color: var(--text-2); font-size: 12px; }
.section-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-3);
  margin: 22px 0 8px;
}
.section-label:first-child { margin-top: 0; }

/* --------------------------------------------------------------- grid of stat tiles */
.tiles { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
@media (min-width: 480px) { .tiles { grid-template-columns: repeat(4, 1fr); } }
.tile {
  background: var(--surface-2);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-md);
  padding: 12px;
}
.tile-label { font-size: 11px; color: var(--text-2); margin-bottom: 4px; }
.tile-value { font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; }
.tile-value.ok { color: var(--ok); }
.tile-value.warn { color: var(--warn); }
.tile-value.crit { color: var(--crit); }

/* --------------------------------------------------------------- progress */
.progress { height: 8px; border-radius: 99px; background: var(--sunken); overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--accent); border-radius: 99px; transition: width 0.3s; }
.progress.ok > span { background: var(--ok); }
.progress.warn > span { background: var(--warn); }
.progress.crit > span { background: var(--crit); }

/* --------------------------------------------------------------- routine list */
.routine-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line-soft);
}
.routine-row:last-child { border-bottom: none; }
.routine-row.now { background: var(--accent-wash); margin: 0 -12px; padding: 10px 12px; border-radius: var(--r-md); border-bottom: none; }
.routine-check {
  width: 22px; height: 22px; border-radius: 6px;
  border: 2px solid var(--line);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; flex-shrink: 0; background: var(--surface);
}
.routine-check.checked { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.routine-time { font-size: 11px; color: var(--text-3); font-variant-numeric: tabular-nums; width: 42px; flex-shrink: 0; }
.routine-label { flex: 1; font-size: 14px; }
.routine-row.checked .routine-label { color: var(--text-3); text-decoration: line-through; }
.dot { width: 7px; height: 7px; border-radius: 99px; flex-shrink: 0; }
.dot.routine { background: var(--text-3); }
.dot.fitness { background: var(--accent); }
.dot.work { background: var(--warn); }
.dot.relationships { background: var(--pink); }
.dot.mental { background: #8878ff; }

/* --------------------------------------------------------------- forms */
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 12px; color: var(--text-2); margin-bottom: 5px; }
.field input, .field textarea, .field select {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: 9px 10px;
  font-size: 14px;
}
.field textarea { min-height: 80px; resize: vertical; }
.row { display: flex; gap: 10px; }
.row > .field { flex: 1; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  background: var(--accent); color: var(--accent-ink);
  border: none; border-radius: var(--r-sm);
  padding: 9px 16px; font-size: 13px; font-weight: 600;
  cursor: pointer;
}
.btn.ghost { background: var(--surface-2); color: var(--text); border: 1px solid var(--line); }
.btn.danger { background: var(--crit-wash); color: var(--crit); }
.btn.sm { padding: 6px 10px; font-size: 12px; }
.btn:disabled { opacity: 0.5; cursor: default; }

.chip-row { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  border: 1px solid var(--line); background: var(--surface-2);
  border-radius: 99px; padding: 8px 14px; font-size: 13px; cursor: pointer;
}
.chip.active { background: var(--accent-wash); border-color: var(--accent-line); color: var(--accent); font-weight: 700; }

.stepper { display: flex; align-items: center; gap: 10px; }
.stepper button {
  width: 32px; height: 32px; border-radius: 99px; border: 1px solid var(--line);
  background: var(--surface-2); font-size: 16px; cursor: pointer;
}
.stepper .val { font-size: 16px; font-weight: 700; min-width: 24px; text-align: center; font-variant-numeric: tabular-nums; }

/* --------------------------------------------------------------- lists */
.list-row {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 0; border-bottom: 1px solid var(--line-soft);
}
.list-row:last-child { border-bottom: none; }
.list-row .grow { flex: 1; min-width: 0; }
.list-row .name { font-size: 14px; font-weight: 600; }
.list-row .meta { font-size: 12px; color: var(--text-2); }
.tag {
  font-size: 10px; text-transform: uppercase; letter-spacing: 0.04em;
  padding: 2px 7px; border-radius: 99px; background: var(--surface-2); color: var(--text-2);
  border: 1px solid var(--line);
}
.tag.warn { color: var(--warn); background: var(--warn-wash); border-color: transparent; }
.tag.crit { color: var(--crit); background: var(--crit-wash); border-color: transparent; }
.tag.ok { color: var(--ok); background: var(--ok-wash); border-color: transparent; }

.empty { color: var(--text-3); font-size: 13px; padding: 12px 0; }

.sparkline { display: flex; align-items: flex-end; gap: 3px; height: 40px; }
.sparkline .bar { flex: 1; background: var(--accent-wash); border-radius: 2px 2px 0 0; min-height: 3px; }
.sparkline .bar.filled { background: var(--accent); }

.icon-btn {
  background: none; border: none; color: var(--text-3); cursor: pointer;
  font-size: 16px; padding: 4px 8px;
}
.icon-btn:hover { color: var(--crit); }

.mood-row { display: flex; gap: 8px; }
.mood-btn {
  flex: 1; font-size: 24px; padding: 10px 0; border-radius: var(--r-md);
  border: 1px solid var(--line); background: var(--surface-2); cursor: pointer;
}
.mood-btn.active { border-color: var(--accent); background: var(--accent-wash); }

.toast {
  position: fixed; left: 50%; bottom: 84px; transform: translate(-50%, 8px);
  background: var(--surface); border: 1px solid var(--line); color: var(--text);
  padding: 9px 16px; border-radius: 99px; font-size: 13px; box-shadow: var(--shadow-2);
  opacity: 0; pointer-events: none; transition: opacity 0.2s, transform 0.2s;
  z-index: 20;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.login-wrap { display: flex; justify-content: center; padding-top: 15vh; }
.login-card { width: 100%; max-width: 320px; }
.login-error { color: var(--crit); font-size: 13px; margin-bottom: 12px; }

.settings-block { margin-bottom: 22px; }
.link-out {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px; background: var(--surface-2); border: 1px solid var(--line);
  border-radius: var(--r-md); text-decoration: none; color: var(--text);
}
