/* LifeTrack — design tokens & base styles */
:root {
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --bg: #f7f7f8;
  --bg-elev: #ffffff;
  --bg-sunken: #f0f0f2;
  --bg-hover: rgba(0, 0, 0, 0.04);
  --bg-active: rgba(0, 0, 0, 0.07);
  --border: #e4e4e7;
  --border-strong: #d4d4d8;
  --text: #18181b;
  --text-2: #52525b;
  --text-3: #8b8b94;
  --accent: #6366f1;
  --accent-strong: #4f46e5;
  --accent-soft: rgba(99, 102, 241, 0.12);
  --on-accent: #ffffff;
  --success: #16a34a;
  --success-soft: rgba(22, 163, 74, 0.14);
  --warning: #d97706;
  --warning-soft: rgba(217, 119, 6, 0.14);
  --danger: #dc2626;
  --danger-soft: rgba(220, 38, 38, 0.12);
  --info: #0284c7;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow: 0 4px 16px rgba(0, 0, 0, 0.08), 0 1px 3px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 20px 60px rgba(0, 0, 0, 0.18), 0 4px 12px rgba(0, 0, 0, 0.08);
  --radius: 10px;
  --radius-sm: 6px;
  --radius-lg: 14px;
  --sidebar-w: 236px;
  --topbar-h: 56px;
  --focus: 0 0 0 3px rgba(99, 102, 241, 0.4);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111114;
    --bg-elev: #1b1b20;
    --bg-sunken: #0c0c0f;
    --bg-hover: rgba(255, 255, 255, 0.06);
    --bg-active: rgba(255, 255, 255, 0.1);
    --border: #2a2a31;
    --border-strong: #3a3a44;
    --text: #f4f4f5;
    --text-2: #b4b4bd;
    --text-3: #7b7b86;
    --accent: #818cf8;
    --accent-strong: #a5b4fc;
    --accent-soft: rgba(129, 140, 248, 0.18);
    --on-accent: #0f0f14;
    --success: #4ade80;
    --success-soft: rgba(74, 222, 128, 0.16);
    --warning: #fbbf24;
    --warning-soft: rgba(251, 191, 36, 0.16);
    --danger: #f87171;
    --danger-soft: rgba(248, 113, 113, 0.16);
    --info: #38bdf8;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow: 0 4px 16px rgba(0, 0, 0, 0.5), 0 1px 3px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 20px 60px rgba(0, 0, 0, 0.7), 0 4px 12px rgba(0, 0, 0, 0.5);
    --focus: 0 0 0 3px rgba(129, 140, 248, 0.45);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #111114;
  --bg-elev: #1b1b20;
  --bg-sunken: #0c0c0f;
  --bg-hover: rgba(255, 255, 255, 0.06);
  --bg-active: rgba(255, 255, 255, 0.1);
  --border: #2a2a31;
  --border-strong: #3a3a44;
  --text: #f4f4f5;
  --text-2: #b4b4bd;
  --text-3: #7b7b86;
  --accent: #818cf8;
  --accent-strong: #a5b4fc;
  --accent-soft: rgba(129, 140, 248, 0.18);
  --on-accent: #0f0f14;
  --success: #4ade80;
  --success-soft: rgba(74, 222, 128, 0.16);
  --warning: #fbbf24;
  --warning-soft: rgba(251, 191, 36, 0.16);
  --danger: #f87171;
  --danger-soft: rgba(248, 113, 113, 0.16);
  --info: #38bdf8;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow: 0 4px 16px rgba(0, 0, 0, 0.5), 0 1px 3px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 20px 60px rgba(0, 0, 0, 0.7), 0 4px 12px rgba(0, 0, 0, 0.5);
  --focus: 0 0 0 3px rgba(129, 140, 248, 0.45);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.45;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}
h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
h1 { font-size: 22px; }
h2 { font-size: 16px; }
h3 { font-size: 14px; }
p { margin: 0; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: none; box-shadow: var(--focus); }
::selection { background: var(--accent-soft); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.skip-link { position: absolute; left: -999px; top: 8px; z-index: 500; background: var(--accent); color: var(--on-accent); padding: 8px 12px; border-radius: var(--radius-sm); }
.skip-link:focus { left: 8px; }
.noscript { padding: 40px; text-align: center; font-size: 16px; }
.muted { color: var(--text-2); }
.faint { color: var(--text-3); }
.small { font-size: 12px; }
.mono { font-family: var(--mono); }
.nowrap { white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.flex { display: flex; align-items: center; gap: 8px; }
.flex-1 { flex: 1; min-width: 0; }
.wrap { flex-wrap: wrap; }
.gap-4 { gap: 4px; } .gap-12 { gap: 12px; } .gap-16 { gap: 16px; }
.mt-8 { margin-top: 8px; } .mt-12 { margin-top: 12px; } .mt-16 { margin-top: 16px; } .mt-24 { margin-top: 24px; }
.mb-8 { margin-bottom: 8px; } .mb-12 { margin-bottom: 12px; } .mb-16 { margin-bottom: 16px; }
.right { margin-left: auto; }
.center { text-align: center; }
.strike { text-decoration: line-through; color: var(--text-3); }
.danger-text { color: var(--danger); }
.success-text { color: var(--success); }
.warning-text { color: var(--warning); }

/* ---- Splash ---- */
.splash { min-height: 100vh; display: grid; place-items: center; align-content: center; gap: 12px; color: var(--text-2); }
.splash-logo { font-size: 40px; color: var(--accent); }

/* ---- Layout ---- */
.shell { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  background: var(--bg-elev); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; padding: 14px 10px;
  padding-top: max(14px, env(safe-area-inset-top));
}
.brand { display: flex; align-items: center; gap: 10px; padding: 6px 10px 14px; font-weight: 700; font-size: 16px; letter-spacing: -0.02em; }
.brand-logo { width: 26px; height: 26px; border-radius: 8px; background: var(--accent); color: white; display: grid; place-items: center; font-size: 15px; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--radius-sm);
  color: var(--text-2); font-weight: 500; border: 0; background: transparent; text-align: left; width: 100%;
}
.nav-item:hover { background: var(--bg-hover); color: var(--text); text-decoration: none; }
.nav-item.active { background: var(--accent-soft); color: var(--accent-strong); }
.nav-item .icon { width: 18px; height: 18px; flex: none; }
.nav-item .badge { margin-left: auto; }
.nav-item .kbd { margin-left: auto; opacity: 0.6; }
.nav-section { font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-3); padding: 14px 10px 6px; font-weight: 600; }
.sidebar-foot { margin-top: auto; padding: 10px; font-size: 12px; color: var(--text-3); display: flex; flex-direction: column; gap: 6px; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20; height: var(--topbar-h);
  display: flex; align-items: center; gap: 10px; padding: 0 20px;
  background: color-mix(in srgb, var(--bg) 85%, transparent); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.topbar h1 { font-size: 17px; }
.topbar .menu-btn { display: none; }
.content { padding: 24px 20px 90px; max-width: 1180px; width: 100%; margin: 0 auto; }
.content.narrow { max-width: 820px; }

/* ---- Buttons ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 7px 12px; border-radius: var(--radius-sm); border: 1px solid var(--border-strong);
  background: var(--bg-elev); color: var(--text); font-weight: 500; line-height: 1.2; white-space: nowrap;
  transition: background 0.12s, border-color 0.12s, transform 0.05s;
}
.btn:hover { background: var(--bg-hover); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); }
.btn.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, transparent); }
.btn.danger:hover { background: var(--danger-soft); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--text-2); }
.btn.ghost:hover { background: var(--bg-hover); color: var(--text); }
.btn.sm { padding: 4px 8px; font-size: 12.5px; }
.btn.icon { padding: 6px; width: 32px; height: 32px; }
.btn.icon.sm { width: 26px; height: 26px; padding: 3px; }
.btn .icon { width: 16px; height: 16px; }
.icon { width: 18px; height: 18px; display: inline-block; vertical-align: -3px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.icon.sm { width: 14px; height: 14px; }

.kbd {
  display: inline-block; font-family: var(--mono); font-size: 11px; padding: 1px 5px; border-radius: 4px;
  border: 1px solid var(--border-strong); background: var(--bg-sunken); color: var(--text-2); line-height: 1.4;
}

/* ---- Inputs ---- */
.input, .select, .textarea {
  width: 100%; padding: 7px 10px; border-radius: var(--radius-sm); border: 1px solid var(--border-strong);
  background: var(--bg-elev); color: var(--text); min-height: 34px;
}
.input::placeholder, .textarea::placeholder { color: var(--text-3); }
.input:focus, .select:focus, .textarea:focus { border-color: var(--accent); box-shadow: var(--focus); outline: none; }
.textarea { resize: vertical; min-height: 72px; line-height: 1.5; }
.select { appearance: none; -webkit-appearance: none; padding-right: 28px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238b8b94' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; }
input[type="date"], input[type="time"] { min-width: 0; }
input[type="range"] { width: 100%; accent-color: var(--accent); }
input[type="color"] { width: 34px; height: 34px; padding: 2px; border-radius: var(--radius-sm); border: 1px solid var(--border-strong); background: var(--bg-elev); }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field > label, .label { font-size: 12px; font-weight: 600; color: var(--text-2); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field-row.three { grid-template-columns: 1fr 1fr 1fr; }
.form { display: flex; flex-direction: column; gap: 14px; }
.hint { font-size: 12px; color: var(--text-3); }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.check input { accent-color: var(--accent); width: 16px; height: 16px; margin: 0; }

/* Day-of-week picker */
.daypick { display: flex; gap: 4px; }
.daypick button {
  width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--border-strong); background: var(--bg-elev);
  color: var(--text-2); font-weight: 600; font-size: 12px;
}
.daypick button[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }

/* Segmented control */
.seg { display: inline-flex; background: var(--bg-sunken); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 2px; gap: 2px; }
.seg button { border: 0; background: transparent; padding: 5px 10px; border-radius: 4px; color: var(--text-2); font-weight: 500; font-size: 13px; white-space: nowrap; }
.seg button[aria-pressed="true"] { background: var(--bg-elev); color: var(--text); box-shadow: var(--shadow-sm); }

/* Emoji picker (simple) */
.emoji-grid { display: flex; flex-wrap: wrap; gap: 4px; }
.emoji-grid button { width: 32px; height: 32px; border-radius: var(--radius-sm); border: 1px solid transparent; background: transparent; font-size: 18px; }
.emoji-grid button:hover { background: var(--bg-hover); }
.emoji-grid button[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); }

/* ---- Cards & lists ---- */
.card { background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.card-head { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--border); }
.card-head h2 { font-size: 14px; }
.card-body { padding: 12px 14px; }
.card-body.flush { padding: 0; }
.grid { display: grid; gap: 16px; }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(min(340px, 100%), 1fr)); }
.grid.split-3-2 { grid-template-columns: minmax(0, 3fr) minmax(min(280px, 100%), 2fr); }
.grid.split-2-1 { grid-template-columns: minmax(0, 2fr) minmax(min(280px, 100%), 1fr); }
.grid.three { grid-template-columns: repeat(auto-fill, minmax(min(280px, 100%), 1fr)); }
.grid.four { grid-template-columns: repeat(auto-fill, minmax(min(200px, 100%), 1fr)); }
.section-title { display: flex; align-items: center; gap: 10px; margin: 0 0 10px; }
.section-title h2 { font-size: 15px; }
.page-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head h1 { font-size: 22px; }
.page-head .sub { color: var(--text-2); }
.toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }

.list { display: flex; flex-direction: column; }
.list-item {
  display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-bottom: 1px solid var(--border);
  min-height: 44px;
}
.list-item:last-child { border-bottom: 0; }
.list-item:hover { background: var(--bg-hover); }
.list-item .title { font-weight: 500; }
.meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 12px; color: var(--text-3); margin-top: 2px; }
.list-item .actions { display: flex; gap: 2px; opacity: 0; transition: opacity 0.12s; }
.list-item:hover .actions, .list-item:focus-within .actions { opacity: 1; }
.list-item.done .title { text-decoration: line-through; color: var(--text-3); }
.list-item.clickable { cursor: pointer; }
.drag-handle { color: var(--text-3); cursor: grab; }
.list-item.dragging { opacity: 0.4; }
.list-item.drag-over { box-shadow: inset 0 2px 0 var(--accent); }

.checkbox {
  width: 20px; height: 20px; border-radius: 6px; border: 1.5px solid var(--border-strong); background: var(--bg-elev);
  display: inline-grid; place-items: center; flex: none; color: transparent; transition: all 0.12s; padding: 0;
}
.checkbox:hover { border-color: var(--accent); }
.checkbox[aria-checked="true"] { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.checkbox.round { border-radius: 50%; }
.checkbox.lg { width: 26px; height: 26px; }
.checkbox .icon { width: 13px; height: 13px; stroke-width: 3; }
.checkbox.lg .icon { width: 15px; height: 15px; }
.checkbox.partial { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-strong); }
.checkbox .count { font-size: 10px; font-weight: 700; }

.badge {
  display: inline-flex; align-items: center; gap: 4px; padding: 1px 7px; border-radius: 99px; font-size: 11.5px; font-weight: 500;
  background: var(--bg-sunken); color: var(--text-2); border: 1px solid var(--border); white-space: nowrap;
}
.badge.accent { background: var(--accent-soft); color: var(--accent-strong); border-color: transparent; }
.badge.success { background: var(--success-soft); color: var(--success); border-color: transparent; }
.badge.warning { background: var(--warning-soft); color: var(--warning); border-color: transparent; }
.badge.danger { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.badge.count { min-width: 20px; justify-content: center; padding: 0 6px; }
.area-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex: none; }
.area-badge { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; color: var(--text-2); }
.prio { width: 4px; height: 18px; border-radius: 2px; background: transparent; flex: none; }
.prio.p1 { background: var(--info); } .prio.p2 { background: var(--warning); } .prio.p3 { background: var(--danger); }
.due { font-size: 12px; }
.due.overdue { color: var(--danger); font-weight: 600; }
.due.today { color: var(--accent-strong); font-weight: 600; }

.progress { height: 6px; border-radius: 99px; background: var(--bg-sunken); overflow: hidden; border: 1px solid var(--border); }
.progress > div { height: 100%; background: var(--accent); border-radius: 99px; transition: width 0.25s; }
.progress.success > div { background: var(--success); }

.empty { padding: 28px 16px; text-align: center; color: var(--text-3); display: flex; flex-direction: column; align-items: center; gap: 8px; }
.empty .icon { width: 28px; height: 28px; color: var(--text-3); opacity: 0.7; }
.empty strong { color: var(--text-2); font-weight: 600; }

/* ---- Stats ---- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; }
.stat { background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; }
.stat .value { font-size: 24px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.1; }
.stat .label { font-size: 12px; color: var(--text-3); margin-top: 4px; font-weight: 500; }
.stat .delta { font-size: 12px; margin-top: 4px; }
.ring { width: 44px; height: 44px; }
.ring circle { fill: none; stroke-width: 4; }
.ring .track { stroke: var(--bg-sunken); }
.ring .bar { stroke: var(--accent); stroke-linecap: round; transition: stroke-dashoffset 0.4s; }

/* ---- Habit grid ---- */
.habit-grid { width: 100%; border-collapse: collapse; }
.habit-grid th, .habit-grid td { padding: 6px 4px; text-align: center; font-size: 11px; color: var(--text-3); }
.habit-grid th.name, .habit-grid td.name { text-align: left; padding-left: 12px; width: 40%; }
.habit-grid th.today { color: var(--accent-strong); font-weight: 700; }
.habit-grid td.today { background: var(--accent-soft); }
.habit-grid tr:hover td { background: var(--bg-hover); }
.habit-grid tr:hover td.today { background: color-mix(in srgb, var(--accent-soft) 70%, var(--bg-hover)); }
.cell {
  width: 22px; height: 22px; border-radius: 6px; border: 1px solid var(--border); background: var(--bg-elev);
  display: inline-grid; place-items: center; padding: 0; color: transparent; font-size: 10px; font-weight: 700;
}
.cell:hover { border-color: var(--accent); }
.cell.done { background: var(--success); border-color: var(--success); color: white; }
.cell.partial { background: var(--success-soft); border-color: var(--success); color: var(--success); }
.cell.off { opacity: 0.35; }
.cell.off:hover { opacity: 0.8; }
.cell.missed { background: var(--danger-soft); border-color: transparent; }
.cell.skipped { background: var(--bg-sunken); border-style: dashed; color: var(--text-3); }
.list-item.skipped .title { color: var(--text-3); }
.task-group.drop-target { background: var(--accent-soft); }
.subtasks { display: flex; flex-direction: column; gap: 6px; }
.subtask { display: flex; align-items: center; gap: 8px; }
.subtask .sub-check { width: 16px; height: 16px; margin: 0 4px; accent-color: var(--accent); flex: none; }
.subtask .input { min-height: 30px; padding: 4px 8px; }
.streak { display: inline-flex; align-items: center; gap: 3px; font-size: 12px; font-weight: 600; color: var(--warning); }

/* ---- Calendar ---- */
.cal { display: grid; grid-template-columns: repeat(7, 1fr); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: var(--border); gap: 1px; }
.cal-head { background: var(--bg-elev); padding: 8px 6px; text-align: center; font-size: 11px; font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.06em; }
.cal-day { background: var(--bg-elev); min-height: 108px; padding: 6px; display: flex; flex-direction: column; gap: 3px; cursor: pointer; }
.cal-day:hover { background: var(--bg-hover); }
.cal-day.other { color: var(--text-3); background: var(--bg-sunken); }
.cal-day.today .daynum { background: var(--accent); color: var(--on-accent); }
.cal-day.selected { box-shadow: inset 0 0 0 2px var(--accent); }
.daynum { width: 24px; height: 24px; border-radius: 50%; display: inline-grid; place-items: center; font-size: 12px; font-weight: 600; }
.cal-item { font-size: 11px; padding: 2px 5px; border-radius: 4px; background: var(--bg-sunken); border-left: 2px solid var(--accent); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal-item.event { border-color: var(--accent); }
.cal-item.workout { border-color: var(--danger); }
.cal-item.task { border-color: var(--text-3); }
.cal-item.done { text-decoration: line-through; opacity: 0.6; }
.cal-more { font-size: 10.5px; color: var(--text-3); padding-left: 5px; }
.week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 10px; }
.week-day { background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px; min-height: 160px; }
.week-day.today { border-color: var(--accent); }
.week-day h3 { font-size: 12px; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.06em; }
.week-day .daynum { font-size: 18px; width: auto; height: auto; }

/* ---- Modal ---- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 100; background: rgba(0, 0, 0, 0.45);
  display: grid; place-items: center; padding: 20px; animation: fade 0.12s ease-out;
}
.modal {
  width: min(560px, 100%); max-height: min(88vh, 900px); overflow: auto; background: var(--bg-elev); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg); border: 1px solid var(--border); animation: rise 0.14s ease-out;
}
.modal.wide { width: min(760px, 100%); }
.modal-head { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--bg-elev); z-index: 1; }
.modal-head h2 { font-size: 16px; flex: 1; }
.modal-body { padding: 18px; }
.modal-foot { display: flex; align-items: center; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--border); position: sticky; bottom: 0; background: var(--bg-elev); }
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { transform: translateY(8px); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* ---- Command palette ---- */
.palette { width: min(620px, 100%); align-self: start; margin-top: 8vh; }
.palette-input { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.palette-input input { flex: 1; border: 0; background: transparent; font-size: 16px; outline: none; }
.palette-list { max-height: 50vh; overflow: auto; padding: 6px; }
.palette-item { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: var(--radius-sm); cursor: pointer; }
.palette-item[aria-selected="true"] { background: var(--accent-soft); }
.palette-item .hint { margin-left: auto; }
.palette-section { font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-3); padding: 8px 10px 4px; font-weight: 600; }
.palette-foot { display: flex; gap: 14px; padding: 8px 16px; border-top: 1px solid var(--border); font-size: 12px; color: var(--text-3); }

/* ---- Toasts ---- */
.toasts { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; width: min(420px, calc(100% - 32px)); }
.toast {
  pointer-events: auto; display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-radius: var(--radius);
  background: var(--text); color: var(--bg); box-shadow: var(--shadow-lg); font-weight: 500; width: 100%; animation: rise 0.15s ease-out;
}
.toast button { background: transparent; border: 0; color: var(--accent); font-weight: 600; padding: 2px 6px; }
.toast button.close { color: inherit; opacity: 0.6; }
.toast.error { background: var(--danger); color: white; }
.toast.error button { color: white; }

/* ---- Focus widget ---- */
.focus-widget { position: fixed; right: 16px; bottom: 16px; z-index: 90; width: min(340px, calc(100% - 32px)); padding: 12px 14px; box-shadow: var(--shadow-lg); border-color: var(--accent); }
.focus-clock { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
@media (max-width: 860px) { .focus-widget { bottom: calc(74px + env(safe-area-inset-bottom)); right: 12px; } }
.cell:focus-visible, .checkbox:focus-visible, .mood-btn:focus-visible { box-shadow: var(--focus); outline: none; }
.habit-grid th[scope="col"] { font-weight: 600; }

/* ---- Quick add bar ---- */
.quick-add { display: flex; align-items: center; gap: 8px; padding: 6px 8px; background: var(--bg-elev); border: 1px dashed var(--border-strong); border-radius: var(--radius-sm); }
.quick-add input { flex: 1; border: 0; background: transparent; outline: none; padding: 4px; }
.quick-add:focus-within { border-style: solid; border-color: var(--accent); }

/* ---- Today ---- */
.today-hero { display: flex; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.today-hero h1 { font-size: 26px; }
.today-hero .date { color: var(--text-2); font-size: 15px; }
.mood-row { display: flex; gap: 6px; }
.mood-btn { width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--border-strong); background: var(--bg-elev); font-size: 18px; padding: 0; }
.mood-btn[aria-checked="true"] { border-color: var(--accent); background: var(--accent-soft); transform: scale(1.1); }
.timeline { display: flex; flex-direction: column; }
.timeline-item { display: grid; grid-template-columns: 64px 1fr; gap: 10px; padding: 8px 12px; border-bottom: 1px solid var(--border); align-items: start; }
.timeline-item:last-child { border-bottom: 0; }
.timeline-item .time { font-size: 12px; color: var(--text-3); font-variant-numeric: tabular-nums; padding-top: 2px; }

/* ---- Workouts ---- */
.exercise-row { display: grid; grid-template-columns: 1fr 64px 64px 84px 32px; gap: 6px; align-items: center; }
.exercise-row.log { grid-template-columns: 1fr 64px 64px 84px 40px; }
.exercise-head { font-size: 11px; color: var(--text-3); font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; }
.rating { display: flex; gap: 4px; }
.rating button { background: transparent; border: 0; font-size: 20px; padding: 0 2px; color: var(--border-strong); }
.rating button.on { color: var(--warning); }

/* ---- People ---- */
.person-card { display: flex; gap: 12px; align-items: flex-start; padding: 14px; }
.avatar { width: 40px; height: 40px; border-radius: 50%; background: var(--bg-sunken); border: 1px solid var(--border); display: grid; place-items: center; font-size: 20px; flex: none; }
.avatar.sm { width: 26px; height: 26px; font-size: 13px; }
.avatars { display: inline-flex; }
.avatars .avatar { margin-left: -6px; }
.avatars .avatar:first-child { margin-left: 0; }

/* ---- Journal ---- */
.journal-entry { padding: 14px; display: flex; flex-direction: column; gap: 8px; }
.journal-entry .text { white-space: pre-wrap; line-height: 1.55; }
.moods { display: flex; gap: 2px; align-items: flex-end; height: 40px; }
.moods span { flex: 1; background: var(--accent); border-radius: 3px 3px 0 0; opacity: 0.7; min-width: 6px; }

/* ---- Settings ---- */
.settings-section { margin-bottom: 26px; }
.settings-section h2 { margin-bottom: 10px; }
.area-row { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-bottom: 1px solid var(--border); }
.area-row:last-child { border-bottom: 0; }
.area-row input.input { max-width: 220px; }
.area-row .emoji-in { width: 44px; text-align: center; }

/* ---- Tabs ---- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; overflow-x: auto; }
.tab { padding: 8px 12px; border: 0; background: transparent; color: var(--text-2); font-weight: 500; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tab[aria-selected="true"] { color: var(--text); border-bottom-color: var(--accent); }

/* ---- Dropdown menu ---- */
.menu { position: relative; }
.menu-list { position: absolute; right: 0; top: calc(100% + 4px); min-width: 180px; background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 4px; z-index: 50; }
.menu-list button { display: flex; align-items: center; gap: 8px; width: 100%; text-align: left; border: 0; background: transparent; padding: 7px 10px; border-radius: var(--radius-sm); color: var(--text); }
.menu-list button:hover { background: var(--bg-hover); }
.menu-list button.danger { color: var(--danger); }
.menu-list hr { border: 0; border-top: 1px solid var(--border); margin: 4px 0; }

/* ---- Filter chips ---- */
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { padding: 4px 10px; border-radius: 99px; border: 1px solid var(--border-strong); background: var(--bg-elev); color: var(--text-2); font-size: 12.5px; font-weight: 500; display: inline-flex; align-items: center; gap: 5px; }
.chip:hover { background: var(--bg-hover); }
.chip[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-strong); }

.offline-banner { background: var(--warning-soft); color: var(--warning); text-align: center; padding: 6px; font-size: 12.5px; font-weight: 500; }
.update-banner { background: var(--accent-soft); color: var(--accent-strong); text-align: center; padding: 6px; font-size: 12.5px; font-weight: 500; }
.update-banner button { margin-left: 8px; }

/* ---- Mobile ---- */
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: min(300px, 85vw); z-index: 150; transform: translateX(-100%); transition: transform 0.18s ease-out; box-shadow: var(--shadow-lg); }
  .sidebar.open { transform: translateX(0); }
  .sidebar-scrim { position: fixed; inset: 0; z-index: 140; background: rgba(0, 0, 0, 0.4); }
  .topbar .menu-btn { display: inline-flex; }
  .content { padding: 16px 14px 100px; }
  .field-row, .field-row.three { grid-template-columns: 1fr; }
  .cal-day { min-height: 68px; padding: 4px; }
  .cal-item { display: none; }
  .cal-day .dots { display: flex; gap: 2px; flex-wrap: wrap; }
  .week { grid-template-columns: 1fr; }
  .exercise-row, .exercise-row.log { grid-template-columns: minmax(80px, 1fr) 48px 48px 64px 28px; gap: 4px; }
  .grid.split-3-2, .grid.split-2-1 { grid-template-columns: 1fr; }
  .list-item .actions { opacity: 1; }
  .list-item { flex-wrap: wrap; }
  .list-item > .flex-1 { flex-basis: 60%; }
  .bottom-nav { display: flex; }
  .today-hero h1 { font-size: 22px; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .toasts { bottom: calc(74px + env(safe-area-inset-bottom)); }
  .habit-grid th.name, .habit-grid td.name { width: auto; padding-left: 8px; }
  .habit-grid td.name .meta { display: none; }
  .habit-grid td.name .title { font-size: 12px; white-space: nowrap; max-width: 110px; overflow: hidden; text-overflow: ellipsis; }
  .habit-grid th, .habit-grid td { padding: 5px 2px; }
  .page-head h1 { font-size: 20px; }
  .page-head .btn { padding: 6px 10px; }
}
@media (min-width: 861px) { .cal-day .dots { display: none; } .bottom-nav { display: none; } }
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 30; background: var(--bg-elev); border-top: 1px solid var(--border);
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); justify-content: space-around;
}
.bottom-nav a { display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 10.5px; color: var(--text-3); padding: 4px 8px; border-radius: var(--radius-sm); min-width: 56px; }
.bottom-nav a.active { color: var(--accent-strong); }
.bottom-nav a:hover { text-decoration: none; }
.dot { width: 6px; height: 6px; border-radius: 50%; display: inline-block; }

@media print {
  .sidebar, .topbar, .bottom-nav, .toasts, .actions { display: none !important; }
  .shell { grid-template-columns: 1fr; }
  .content { padding: 0; max-width: none; }
}
