:root {
  --bg: #f4f6f8;
  --card: #ffffff;
  --ink: #1d2733;
  --muted: #67788c;
  --line: #e3e9ef;
  --accent: #1b2a3a;
  --primary: #2f6fb2;
  --danger: #b23a3a;
  --ok: #2e8b6e;
  --radius: 12px;
  font-size: 16px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12181f;
    --card: #1b232d;
    --ink: #e8edf2;
    --muted: #8fa1b3;
    --line: #2a3542;
    --accent: #0e141b;
  }
}
* { box-sizing: border-box; margin: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
  -webkit-tap-highlight-color: transparent;
}
.hidden { display: none !important; }
button {
  font: inherit; cursor: pointer; border: 1px solid var(--line);
  background: var(--card); color: var(--ink); border-radius: 8px; padding: 8px 14px;
}
button.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
button.danger { color: var(--danger); border-color: var(--danger); background: transparent; }
button.round { border-radius: 50%; width: 40px; height: 40px; padding: 0; font-size: 22px; line-height: 1; }
input, select, textarea {
  font: inherit; color: var(--ink); background: var(--card);
  border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; width: 100%;
}
textarea { min-height: 80px; resize: vertical; }
.error { color: var(--danger); min-height: 1.2em; margin-top: 8px; font-size: 0.9rem; }

/* ---- login ---- */
#login-screen {
  position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  background: var(--accent);
}
.login-card {
  background: var(--card); padding: 32px; border-radius: 16px; width: min(90vw, 340px);
  display: flex; flex-direction: column; gap: 12px; text-align: center;
}
.login-card p { color: var(--muted); font-size: 0.9rem; }

/* ---- layout ---- */
header {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(env(safe-area-inset-top) + 12px) 16px 12px;
  background: var(--accent); color: #fff;
}
.header-title { font-size: 1.25rem; font-weight: 700; }
.header-actions { display: flex; gap: 10px; }
#capture-btn { background: rgba(255,255,255,.12); border-color: transparent; color: #fff; }
.capture-row { margin-bottom: 12px; }
.capture-row .c-title { margin-bottom: 6px; }
.capture-row .field-row { align-items: center; }
main {
  padding: 16px 16px calc(env(safe-area-inset-bottom) + 84px);
  max-width: 720px; margin: 0 auto;
}
nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 5;
  display: flex; background: var(--card); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
nav button {
  flex: 1; border: none; border-radius: 0; background: none; color: var(--muted);
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 8px 0 6px; font-size: 0.72rem;
}
nav button.active { color: var(--primary); font-weight: 600; }
nav .ico { font-size: 1.25rem; }

/* ---- timer bar ---- */
#timer-bar {
  position: sticky; top: 0; z-index: 4;
  display: flex; align-items: center; gap: 10px;
  background: var(--ok); color: #fff; padding: 8px 16px; font-size: 0.9rem;
}
#timer-elapsed { margin-left: auto; font-variant-numeric: tabular-nums; font-weight: 700; }
#timer-bar button { background: rgba(255,255,255,.18); border: none; color: #fff; padding: 4px 12px; }

/* ---- cards & lists ---- */
.section-label {
  font-size: 0.78rem; text-transform: uppercase; letter-spacing: .06em;
  color: var(--muted); margin: 18px 4px 8px; font-weight: 700;
}
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden;
}
.row {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}
.row:last-child { border-bottom: none; }
.row .grow { flex: 1; min-width: 0; }
.row .title { font-weight: 500; overflow-wrap: anywhere; }
.row .sub { font-size: 0.8rem; color: var(--muted); margin-top: 2px; }
.row.done .title { text-decoration: line-through; color: var(--muted); }
.overdue { color: var(--danger); font-weight: 600; }
.check {
  width: 24px; height: 24px; min-width: 24px; border-radius: 50%;
  border: 2px solid var(--muted); background: none; padding: 0; font-size: 14px; line-height: 1;
}
.check.on { background: var(--ok); border-color: var(--ok); color: #fff; }
.dot { width: 10px; height: 10px; min-width: 10px; border-radius: 50%; }
.pill {
  font-size: 0.72rem; padding: 2px 8px; border-radius: 999px;
  background: var(--bg); color: var(--muted); white-space: nowrap;
}
.pill.due { background: var(--danger); color: #fff; }
.empty { color: var(--muted); text-align: center; padding: 28px 12px; font-size: 0.9rem; }
.tap { cursor: pointer; }

/* domain header rows in Projects tab */
.domain-head {
  display: flex; align-items: center; gap: 10px; padding: 12px 14px;
  font-weight: 700; border-bottom: 1px solid var(--line);
}
.domain-head .count { margin-left: auto; font-weight: 400; color: var(--muted); font-size: 0.85rem; }
.proj-row { padding-left: 34px; }

/* time bars */
.bar-track { background: var(--bg); border-radius: 6px; height: 10px; overflow: hidden; flex: 1; }
.bar-fill { height: 100%; border-radius: 6px; }
.time-row { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.time-row:last-child { border-bottom: none; }
.time-row .name { width: 110px; font-size: 0.85rem; }
.time-row .mins { width: 60px; text-align: right; font-variant-numeric: tabular-nums; font-size: 0.85rem; }

/* ---- modal ---- */
#modal-backdrop {
  position: fixed; inset: 0; z-index: 20; background: rgba(0,0,0,.45);
  display: flex; align-items: flex-end; justify-content: center;
}
#modal {
  background: var(--card); width: min(100vw, 560px); max-height: 88vh; overflow-y: auto;
  border-radius: 16px 16px 0 0; padding: 20px 20px calc(env(safe-area-inset-bottom) + 20px);
}
@media (min-width: 600px) {
  #modal-backdrop { align-items: center; }
  #modal { border-radius: 16px; }
}
#modal h2 { font-size: 1.1rem; margin-bottom: 14px; }
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 0.8rem; color: var(--muted); margin-bottom: 4px; }
.field-row { display: flex; gap: 10px; }
.field-row .field { flex: 1; }
.modal-actions { display: flex; gap: 10px; margin-top: 16px; }
.modal-actions .primary { flex: 1; }
.toolbar { display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.toolbar button.on { background: var(--primary); color: #fff; border-color: var(--primary); }
