/* Tracking — dark-only by design: this is a one-person app used mostly at night. */

:root {
  --bg:        #12141a;
  --surface:   #1a1d26;
  --surface-2: #222633;
  --line:      #2a2f3a;
  --text:      #e8eaf0;
  --muted:     #8b93a7;
  --accent:    #f5a524;
  --good:      #30a46c;
  --bad:       #e5484d;
  --radius: 16px;
  --tap: 48px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  overscroll-behavior-y: contain;
}

body { padding-bottom: calc(72px + env(safe-area-inset-bottom)); }

h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -0.01em; }
button { font: inherit; color: inherit; cursor: pointer; }
code { font-size: .85em; color: var(--muted); }

.muted  { color: var(--muted); }
.small  { font-size: .82rem; }
.center { text-align: center; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }

/* ── app bar ──────────────────────────────────────────────────────────────── */

.appbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.appbar h1 { font-size: 1.25rem; }
.appbar-right { display: flex; align-items: center; gap: 8px; }

.icon-btn {
  width: 40px; height: 40px;
  display: grid; place-items: center;
  background: transparent; border: 0; border-radius: 12px;
  font-size: 1.15rem; color: var(--muted);
}
.icon-btn:active { background: var(--surface-2); }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 10px;
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 999px; font-size: .8rem;
}
.chip.warn { border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); color: var(--accent); }
.spin { display: inline-block; animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .35; } }

main { padding: 16px; max-width: 640px; margin: 0 auto; }
.view { display: none; }
.view.is-active { display: block; animation: fade .18s ease-out; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } }

/* ── activity cards ───────────────────────────────────────────────────────── */

.cards { display: grid; gap: 12px; }

.card {
  position: relative;
  display: grid; grid-template-columns: 76px 1fr auto;
  align-items: center; gap: 14px;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  transition: transform .12s ease, background .12s ease;
  user-select: none;
}
.card:active { transform: scale(.985); background: var(--surface-2); }
.card.flash { animation: flash .5s ease-out; }
@keyframes flash { 0% { box-shadow: 0 0 0 0 var(--ring-color); } 100% { box-shadow: 0 0 0 14px transparent; } }

.card .ring { width: 76px; height: 76px; }
.card .ring text { fill: var(--text); font-weight: 700; }
.card .ring .sub { fill: var(--muted); font-weight: 500; }

.card .label { font-size: 1.05rem; font-weight: 600; }
.card .meta  { color: var(--muted); font-size: .84rem; margin-top: 2px; }
.card .emoji { font-size: 1.1rem; margin-right: 6px; }

.card .more {
  width: var(--tap); height: var(--tap);
  display: grid; place-items: center;
  background: transparent; border: 0; border-radius: 12px;
  color: var(--muted); font-size: 1.2rem;
}
.card .more:active { background: var(--line); }

.card.pending::after {
  content: "⏳";
  position: absolute; top: 8px; right: 8px;
  font-size: .7rem; opacity: .8;
}

/* ── chips row (activity picker) ──────────────────────────────────────────── */

.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 12px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chips button {
  flex: 0 0 auto;
  padding: 8px 14px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 999px; color: var(--muted); font-size: .88rem;
}
.chips button.is-active { background: var(--surface-2); color: var(--text); border-color: var(--accent); }

/* ── calendar ─────────────────────────────────────────────────────────────── */

.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.cal-head h2 { font-size: 1.05rem; text-transform: capitalize; }

.cal-dow, .cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cal-dow { color: var(--muted); font-size: .72rem; text-align: center; margin-bottom: 6px; }

.cal-cell {
  aspect-ratio: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px;
  background: var(--surface); border: 1px solid transparent;
  border-radius: 12px; font-size: .78rem; color: var(--muted);
}
.cal-cell.empty { background: transparent; }
.cal-cell .n { font-size: .95rem; font-weight: 700; color: var(--text); }
.cal-cell.is-today { border-color: var(--accent); }
.cal-cell.is-sel   { outline: 2px solid var(--text); outline-offset: -2px; }
.cal-cell.lvl0 { opacity: .45; }

.cal-foot { display: flex; justify-content: space-between; gap: 12px; margin-top: 14px; color: var(--muted); font-size: .84rem; }

.day-detail { margin-top: 16px; }
.day-detail:empty { display: none; }

/* ── lists ────────────────────────────────────────────────────────────────── */

.section-title { font-size: .95rem; color: var(--muted); font-weight: 600; margin: 18px 0 10px; }

.entry {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 12px; margin-bottom: 8px;
}
.entry .time { font-variant-numeric: tabular-nums; font-weight: 600; }
.entry .grow { flex: 1; min-width: 0; }
.entry .note { color: var(--muted); font-size: .82rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.entry .del {
  width: 38px; height: 38px; display: grid; place-items: center;
  background: transparent; border: 0; border-radius: 10px; color: var(--muted);
}
.entry .del:active { background: var(--line); color: var(--bad); }
.entry.pending { opacity: .7; border-style: dashed; }

.day-group { margin-bottom: 18px; }
.day-group > h3 { font-size: .82rem; color: var(--muted); font-weight: 600; margin-bottom: 8px; }

/* ── stats ────────────────────────────────────────────────────────────────── */

.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-bottom: 18px; }
.stat {
  padding: 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
}
.stat .k { color: var(--muted); font-size: .78rem; }
.stat .v { font-size: 1.5rem; font-weight: 700; margin-top: 4px; font-variant-numeric: tabular-nums; }
.stat .v small { font-size: .8rem; font-weight: 500; color: var(--muted); }
.stat .v.up   { color: var(--bad); }
.stat .v.down { color: var(--good); }

.panel {
  padding: 14px; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); margin-bottom: 14px;
}
.panel > h3 { font-size: .88rem; color: var(--muted); font-weight: 600; margin-bottom: 12px; }
.panel svg { display: block; width: 100%; height: auto; overflow: visible; }
.panel svg text { fill: var(--muted); font-size: 9px; }

/* ── tab bar ──────────────────────────────────────────────────────────────── */

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: grid; grid-template-columns: repeat(4, 1fr);
  padding-bottom: env(safe-area-inset-bottom);
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
}
.tabbar button {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 10px 4px; min-height: 60px;
  background: transparent; border: 0; color: var(--muted); font-size: .68rem;
}
.tabbar button span { font-size: 1rem; line-height: 1; }
.tabbar button.is-active { color: var(--accent); }

/* ── toast ────────────────────────────────────────────────────────────────── */

.toast {
  position: fixed; left: 50%; bottom: calc(80px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 40;
  display: flex; align-items: center; gap: 14px;
  max-width: calc(100vw - 32px);
  padding: 12px 16px;
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 999px; box-shadow: 0 10px 30px #0008;
  animation: rise .2s ease-out;
}
@keyframes rise { from { opacity: 0; transform: translate(-50%, 8px); } }
.toast button { background: transparent; border: 0; color: var(--accent); font-weight: 600; }

/* ── setup + dialogs ──────────────────────────────────────────────────────── */

.setup { min-height: 100dvh; display: grid; place-items: center; padding: 24px; }
.setup-card { width: 100%; max-width: 380px; text-align: center; }
.setup-logo { display: block; width: 72px; height: 72px; margin: 0 auto 18px; border-radius: 20px; }
.setup h1 { font-size: 1.5rem; margin-bottom: 6px; }
.setup p { margin: 0 0 22px; }
.setup-msg:empty { display: none; }
.setup-msg { margin-top: 14px; font-size: .85rem; }
.setup-msg.err { color: var(--bad); }
.setup-msg.ok  { color: var(--good); }

label { display: block; text-align: left; color: var(--muted); font-size: .82rem; margin-bottom: 14px; }
input, select {
  width: 100%; margin-top: 6px;
  padding: 12px 14px; min-height: var(--tap);
  background: var(--surface); color: var(--text);
  border: 1px solid var(--line); border-radius: 12px;
  font: inherit;
}
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

/* Visual masking without a type="password" field — see the note in index.html. */
input.mask { -webkit-text-security: disc; text-security: disc; letter-spacing: .08em; }

.primary, .ghost {
  width: 100%; min-height: var(--tap);
  padding: 12px 18px; border-radius: 12px; font-weight: 600;
  border: 1px solid var(--line); background: var(--surface-2);
}
.primary { background: var(--accent); border-color: var(--accent); color: #1b1200; }
.ghost.small { width: auto; min-height: 36px; padding: 6px 12px; font-size: .8rem; font-weight: 500; }
.link { background: none; border: 0; color: var(--muted); text-decoration: underline; padding: 12px; width: 100%; }
.link.danger { color: var(--bad); }

dialog {
  width: min(520px, calc(100vw - 24px));
  margin: auto;
  padding: 0;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--line); border-radius: 20px;
}
dialog::backdrop { background: #000b; backdrop-filter: blur(2px); }
.dlg { padding: 20px; max-height: 80dvh; overflow-y: auto; }
.dlg h2 { font-size: 1.15rem; margin-bottom: 16px; }
.dlg h3 { font-size: .85rem; color: var(--muted); margin: 20px 0 10px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.sel select { min-height: var(--tap); }
menu { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; padding: 0; margin: 20px 0 0; }

.switch-row {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  margin-bottom: 8px; color: var(--text); font-size: .95rem;
}
.switch-row input { width: 52px; height: 30px; margin: 0; flex: 0 0 auto; accent-color: var(--accent); }

.act-row {
  padding: 12px; margin-bottom: 10px;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px;
}
.act-row > .t { display: flex; align-items: center; gap: 8px; font-weight: 600; margin-bottom: 10px; }
.act-row .grid2 label { margin-bottom: 0; }

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
