/* ─────────────────────────────────────────────────────────────────────────
   4S Ops — calm, mobile-first productivity UI.
   One accent, generous touch targets, no decoration for its own sake.
   ───────────────────────────────────────────────────────────────────────── */
:root {
  --bg: #f6f6f4;
  --surface: #ffffff;
  --surface-2: #f1f0ed;
  --ink: #1c1b19;
  --ink-soft: #57534e;
  --muted: #8d887f;
  --line: #e7e4df;
  --line-strong: #d8d4cd;

  --accent: #4f46e5;
  --accent-ink: #ffffff;
  --accent-soft: #ececfb;

  --p1: #dc2626;
  --p1-soft: #fdeded;
  --p3: #9a958d;

  --ok: #15803d;
  --ok-soft: #e9f7ee;
  --warn: #b45309;
  --danger: #dc2626;

  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(28, 27, 25, .05), 0 1px 3px rgba(28, 27, 25, .04);
  --tabbar-h: 64px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #181715;
    --surface: #211f1d;
    --surface-2: #2a2825;
    --ink: #f4f2ef;
    --ink-soft: #c7c2ba;
    --muted: #948f86;
    --line: #34312d;
    --line-strong: #423e39;

    --accent: #8b85f5;
    --accent-ink: #16151c;
    --accent-soft: #2a2745;

    --p1: #f87171;
    --p1-soft: #3a2020;
    --p3: #8a857c;

    --ok: #4ade80;
    --ok-soft: #1c2a20;
    --warn: #fbbf24;
    --danger: #f87171;

    --shadow: 0 1px 2px rgba(0, 0, 0, .3);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
h1, h2, h3 { line-height: 1.25; }

/* visible focus everywhere */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 6px;
}

/* ── app bar ─────────────────────────────────────────────────────────── */
.appbar {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  -webkit-backdrop-filter: saturate(160%) blur(10px);
  backdrop-filter: saturate(160%) blur(10px);
  border-bottom: 1px solid var(--line);
  padding-top: env(safe-area-inset-top);
}
.appbar-inner {
  max-width: 720px; margin: 0 auto;
  display: flex; align-items: center; justify-content: space-between;
  gap: .5rem; padding: .7rem 1rem;
}
.brand { color: var(--ink); font-weight: 700; font-size: 1.05rem; letter-spacing: -.01em; }
.brand .dot { color: var(--accent); }
.appbar-right { display: flex; align-items: center; gap: .7rem; }
.who { font-size: .85rem; color: var(--ink-soft); }
.btn-link {
  background: none; border: 0; color: var(--muted); cursor: pointer;
  font: inherit; font-size: .85rem; padding: .3rem; min-height: 36px;
}
.btn-link:hover { color: var(--ink); }
.inline { display: inline; }

/* ── layout ──────────────────────────────────────────────────────────── */
.container {
  max-width: 720px; margin: 0 auto;
  padding: 1rem 1rem calc(var(--tabbar-h) + 1.5rem + env(safe-area-inset-bottom));
}
.page-head { margin: .2rem 0 1.1rem; }
.page-head h1 { font-size: 1.5rem; margin: 0; letter-spacing: -.02em; }
.page-head .subtitle { color: var(--muted); margin: .25rem 0 0; font-size: .92rem; }
.muted { color: var(--muted); }
.small { font-size: .8rem; }

/* ── banners ─────────────────────────────────────────────────────────── */
.banner {
  padding: .7rem .9rem; border-radius: var(--radius-sm);
  margin-bottom: 1rem; font-size: .9rem; border: 1px solid transparent;
}
.banner.ok { background: var(--ok-soft); color: var(--ok); border-color: color-mix(in srgb, var(--ok) 25%, transparent); }
.banner.err { background: var(--p1-soft); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 25%, transparent); }

/* ── task list ───────────────────────────────────────────────────────── */
.tasklist { display: flex; flex-direction: column; gap: .55rem; }
.task {
  display: block; background: var(--surface); color: var(--ink);
  border: 1px solid var(--line); border-left: 3px solid var(--line-strong);
  border-radius: var(--radius); padding: .85rem .95rem;
  box-shadow: var(--shadow); transition: border-color .12s, transform .04s;
}
.task:active { transform: scale(.995); }
.task.p-P1 { border-left-color: var(--p1); }
.task.p-P2 { border-left-color: var(--accent); }
.task.p-P3 { border-left-color: var(--p3); }
.task.is-closed { opacity: .82; }

.task-top { display: flex; align-items: flex-start; gap: .6rem; }
.task-title { font-weight: 600; font-size: 1rem; flex: 1; word-break: break-word; }
.task.is-closed .task-title { text-decoration: line-through; text-decoration-color: var(--muted); }

.task-meta { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; margin-top: .5rem; }
.task-meta:empty { display: none; }

/* pills / chips */
.pill {
  font-size: .72rem; font-weight: 600; letter-spacing: .01em;
  padding: .18rem .5rem; border-radius: 999px;
  background: var(--surface-2); color: var(--ink-soft);
  display: inline-flex; align-items: center; gap: .3rem; white-space: nowrap;
}
.pill.prio-P1 { background: var(--p1-soft); color: var(--p1); }
.pill.prio-P2 { background: var(--accent-soft); color: var(--accent); }
.pill.prio-P3 { background: var(--surface-2); color: var(--muted); }
.pill.assignee { background: var(--surface-2); color: var(--ink-soft); }
.pill.status-done { background: var(--ok-soft); color: var(--ok); }
.pill.status-archived { background: var(--surface-2); color: var(--muted); }

.due { font-size: .78rem; font-weight: 600; display: inline-flex; align-items: center; gap: .25rem; color: var(--ink-soft); }
.due.due-overdue { color: var(--danger); }
.due.due-today { color: var(--accent); }
.due.due-tomorrow { color: var(--warn); }
.due svg { width: 13px; height: 13px; }
.count { color: var(--muted); font-size: .78rem; display: inline-flex; align-items: center; gap: .25rem; }
.count svg { width: 14px; height: 14px; }

/* ── empty state ─────────────────────────────────────────────────────── */
.empty {
  text-align: center; color: var(--muted); padding: 3rem 1rem;
  border: 1px dashed var(--line-strong); border-radius: var(--radius);
}

/* ── cards / sections ────────────────────────────────────────────────── */
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 1.1rem; box-shadow: var(--shadow);
}
.section { margin-top: 1.6rem; }
.section h2 { font-size: .85rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 0 0 .7rem; }

/* ── detail ──────────────────────────────────────────────────────────── */
.detail-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; }
.detail-head h1 { font-size: 1.4rem; margin: 0; letter-spacing: -.02em; }
.detail-meta { display: flex; flex-wrap: wrap; gap: .45rem; margin-top: .7rem; }
.notes { white-space: pre-wrap; margin: 0; color: var(--ink-soft); line-height: 1.6; }
.detail-info { margin: .9rem 0 0; font-size: .82rem; color: var(--muted); }

.actions { display: flex; flex-wrap: wrap; gap: .6rem; margin-top: 1.2rem; }

/* ── buttons ─────────────────────────────────────────────────────────── */
.btn {
  appearance: none; display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  min-height: 48px; padding: 0 1.1rem; border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink);
  font: inherit; font-size: .95rem; font-weight: 600; cursor: pointer;
  transition: background .12s, border-color .12s;
}
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.primary:hover { filter: brightness(1.05); }
.btn.ok { background: var(--ok); color: #fff; border-color: var(--ok); }
.btn.block { width: 100%; }
.btn.lg { min-height: 56px; font-size: 1.05rem; }
.btn-text { background: none; border: 0; color: var(--muted); font: inherit; font-size: .85rem; cursor: pointer; padding: .4rem .2rem; min-height: 40px; }
.btn-text.danger { color: var(--danger); }
.btn-text:hover { text-decoration: underline; }

/* ── forms ───────────────────────────────────────────────────────────── */
.form { display: flex; flex-direction: column; gap: 1.1rem; }
.field { display: flex; flex-direction: column; gap: .4rem; }
.field > .label { font-size: .82rem; font-weight: 600; color: var(--ink-soft); }
.field .hint { font-size: .76rem; color: var(--muted); }
.input, .textarea, .select {
  width: 100%; padding: .8rem .85rem; font: inherit; font-size: 1rem;
  color: var(--ink); background: var(--surface);
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
}
.input:focus, .textarea:focus, .select:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: var(--accent); }
.input.title-input { font-size: 1.2rem; font-weight: 600; padding: .85rem; }
.textarea { resize: vertical; min-height: 90px; line-height: 1.5; }

/* segmented control (CSS-only radios) */
.segmented { display: flex; gap: .5rem; }
.segmented.grow > * { flex: 1; }
.segmented input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.segmented label {
  display: flex; align-items: center; justify-content: center;
  min-height: 50px; padding: 0 .6rem; cursor: pointer; text-align: center;
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--ink-soft); font-weight: 600; font-size: .95rem;
  transition: background .12s, border-color .12s, color .12s;
}
.segmented input:checked + label { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.segmented input:focus-visible + label { outline: 2px solid var(--accent); outline-offset: 2px; }
.segmented label .sub { font-size: .72rem; font-weight: 500; color: var(--muted); margin-left: .35rem; }
.segmented input:checked + label .sub { color: var(--accent); }

.form-actions { display: flex; gap: .7rem; margin-top: .3rem; }
.form-actions .btn { flex: 1; }
[hidden] { display: none !important; }

/* ── comments ────────────────────────────────────────────────────────── */
.comments { list-style: none; padding: 0; margin: 0 0 1rem; display: flex; flex-direction: column; gap: .6rem; }
.comment { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: .7rem .85rem; }
.comment-head { display: flex; gap: .5rem; align-items: baseline; font-size: .82rem; }
.comment-head b { font-weight: 600; }
.comment-body { white-space: pre-wrap; margin-top: .3rem; line-height: 1.5; }

/* ── recurring list ──────────────────────────────────────────────────── */
.recur { display: flex; flex-direction: column; gap: .6rem; }
.recur-item {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: .9rem; box-shadow: var(--shadow);
}
.recur-item.inactive { opacity: .6; }
.recur-row { display: flex; align-items: flex-start; justify-content: space-between; gap: .8rem; }
.recur-title { font-weight: 600; }
.recur-sub { color: var(--muted); font-size: .82rem; margin-top: .25rem; }
.recur-meta { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .6rem; align-items: center; }
.recur-actions { display: flex; gap: .5rem; align-items: center; flex-shrink: 0; }
.toolbar { display: flex; gap: .6rem; margin-bottom: 1.1rem; flex-wrap: wrap; }
.toolbar .btn { flex: 1; }

/* ── login ───────────────────────────────────────────────────────────── */
.login { max-width: 380px; margin: 12vh auto 0; padding: 0 1.2rem; }
.login .brand-big { font-size: 2rem; font-weight: 700; letter-spacing: -.02em; text-align: center; }
.login .brand-big .dot { color: var(--accent); }
.login .tagline { text-align: center; color: var(--muted); margin: .3rem 0 1.6rem; }

/* ── bottom tab bar ──────────────────────────────────────────────────── */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  -webkit-backdrop-filter: saturate(160%) blur(12px);
  backdrop-filter: saturate(160%) blur(12px);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbar-inner {
  max-width: 720px; margin: 0 auto; height: var(--tabbar-h);
  display: grid; grid-template-columns: repeat(5, 1fr); align-items: stretch;
}
.tab {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .15rem;
  color: var(--muted); font-size: .68rem; font-weight: 600; letter-spacing: .01em;
}
.tab svg { width: 22px; height: 22px; }
.tab.active { color: var(--accent); }
.tab.add { color: var(--ink-soft); }
.tab.add .tab-add-icon {
  width: 40px; height: 40px; border-radius: 50%; background: var(--accent); color: var(--accent-ink);
  display: flex; align-items: center; justify-content: center; margin-top: -14px;
  box-shadow: 0 4px 12px color-mix(in srgb, var(--accent) 45%, transparent);
}
.tab.add .tab-add-icon svg { width: 24px; height: 24px; }
.tab.add.active { color: var(--accent); }

.back { display: inline-flex; align-items: center; gap: .35rem; color: var(--muted); margin-top: 1.6rem; font-size: .9rem; }
.back:hover { color: var(--ink); }
