/* Start Tasks (PWA). Mobile-first (390px). Every colour comes from css/tokens.css — the same
   tokens as Start, checked by test/unit/contrast.test.ts (which also fails on any colour literal
   in this file). Touch targets are at least 44px. */
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--ink); font: 400 16px/1.45 var(--body); -webkit-font-smoothing: antialiased; min-height: 100vh;
  -webkit-text-size-adjust: 100%; padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
h1, h2, h3 { font-family: var(--head); margin: 0; letter-spacing: -.01em; }
button, input, select { font: inherit; color: inherit; }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
::placeholder { color: var(--placeholder); opacity: 1; }
.hint { margin: 0; color: var(--ink-2); font-size: 14px; }
.hint.err { color: var(--danger); }
.hint:empty { display: none; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.spacer { flex: 1; }
.card { background: var(--card); border: 1px solid var(--card-border); border-radius: var(--radius); box-shadow: var(--shadow); }

/* Buttons + fields */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 0 16px; border-radius: 12px;
  border: 1px solid var(--card-border); background: var(--card); color: var(--ink); font-weight: 500; cursor: pointer; white-space: nowrap;
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.danger { color: var(--danger); }
.btn.icon { width: 44px; padding: 0; }
.btn.wide { width: 100%; }
.btn:disabled { opacity: .6; }
.link { background: none; border: 0; padding: 0 4px; min-height: 44px; color: inherit; font-weight: 600; text-decoration: underline; cursor: pointer; }
.field { display: flex; flex-direction: column; gap: 6px; border: 0; padding: 0; margin: 0; min-width: 0; }
.field > span, .field legend { font-weight: 500; font-size: 14px; color: var(--ink-2); padding: 0; }
.field input, .field select {
  height: 48px; padding: 0 12px; width: 100%; min-width: 0; background: var(--input-bg); border: 1px solid var(--input-border); border-radius: 12px; color: var(--ink);
  font-size: 16px; /* 16px stops iOS zooming into the field */
}
.check { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; color: var(--ink-2); font-size: 14px; cursor: pointer; }
.check input { width: 22px; height: 22px; accent-color: var(--accent); margin: 0; }

/* Sign-in */
.signin { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.signin-card { width: min(420px, 100%); padding: 24px; display: flex; flex-direction: column; gap: 16px; }
.signin-card h1 { font-size: 28px; font-weight: 600; }

/* App */
.app { max-width: 900px; margin: 0 auto; padding: 16px 16px 112px; }
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.top h1 { font-size: 28px; font-weight: 600; }
.sub { margin: 2px 0 0; color: var(--ink-2); font-size: 15px; font-variant-numeric: tabular-nums; }
.sync-line { margin: 8px 0 12px; color: var(--muted); font-size: 13px; min-height: 18px; }
.bar { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }
.bar-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.filter { display: flex; gap: 6px; overflow-x: auto; padding: 2px 2px 4px; scrollbar-width: none; }
.filter::-webkit-scrollbar { display: none; }
.chip {
  display: inline-flex; align-items: center; gap: 7px; min-height: 44px; padding: 0 14px; border-radius: 999px; cursor: pointer; flex: none;
  background: var(--chip-bg); border: 1px solid var(--chip-border); color: var(--ink); font-weight: 500; font-size: 15px;
}
.chip[aria-pressed="true"] { background: color-mix(in srgb, var(--accent) 14%, var(--card)); border-color: var(--accent); }
.chip .n { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.layout-switch { display: inline-flex; background: var(--hover); border: 1px solid var(--card-border); border-radius: 12px; padding: 3px; gap: 2px; }
.layout-switch button { min-height: 40px; padding: 0 14px; border: 0; border-radius: 9px; background: none; color: var(--ink-2); font-weight: 500; cursor: pointer; }
.layout-switch button[aria-checked="true"] { background: var(--card); color: var(--ink); box-shadow: var(--shadow); }

/* Board (shared row component from src/task-view.ts) */
.task-board.cards { columns: 400px; column-gap: 16px; }
.task-board.cards > * { break-inside: avoid; margin: 0 0 16px; }
.task-card { display: block; overflow: hidden; }
.task-onelist { overflow: hidden; padding: 4px 0; }
.swatch { width: 10px; height: 10px; border-radius: 50%; background: var(--c, var(--accent)); flex: none; }
.space-head, .task-cat-row {
  display: flex; align-items: center; gap: 8px; min-height: 48px; padding: 8px 14px;
  background: color-mix(in srgb, var(--c) 6%, var(--card)); border-bottom: 1px solid var(--divider);
}
.task-cat-row { border-top: 1px solid var(--divider); }
.task-group:first-child .task-cat-row { border-top: 0; }
.space-head h2, .task-cat-row h3 { font-size: 16px; font-weight: 600; flex: 1; min-width: 0; overflow-wrap: anywhere; }
.count { color: var(--muted); font-size: 13px; white-space: nowrap; }
.task-empty { margin: 0; padding: 14px; color: var(--muted); }
.task-list { list-style: none; margin: 0; padding: 2px 4px 4px; }
/* Row: [44px tick] [text, wraps] [96px pill column] */
.task { display: grid; grid-template-columns: 44px minmax(0, 1fr) 96px; gap: 4px; align-items: start; padding: 0 6px 0 0; border-radius: 10px; }
.task-tick {
  appearance: none; -webkit-appearance: none; position: relative; width: 44px; height: 44px; margin: 0; border: 0; background: none; cursor: pointer; border-radius: 10px;
}
.task-tick::before {
  content: ""; position: absolute; left: 11px; top: 11px; width: 22px; height: 22px; border-radius: 6px;
  border: 2px solid var(--input-border); background: var(--input-bg);
}
.task-tick:checked::before { background: var(--accent); border-color: var(--accent); }
.task-tick:checked::after {
  content: ""; position: absolute; left: 19px; top: 14px; width: 6px; height: 12px;
  border: solid var(--accent-ink); border-width: 0 2.5px 2.5px 0; transform: rotate(45deg);
}
.task-text {
  display: block; width: 100%; min-height: 44px; padding: 11px 0; border: 0; background: none; color: var(--ink); cursor: text;
  text-align: left; white-space: normal; overflow-wrap: anywhere; line-height: 1.4; font-size: 16px; border-radius: 6px;
}
.task.done .task-text { text-decoration: line-through; color: var(--muted); }
.task-edit { width: 100%; height: 44px; margin: 0; padding: 0 10px; background: var(--input-bg); border: 1px solid var(--input-border); border-radius: 10px; color: var(--ink); font-size: 16px; }
.tf-col { display: flex; align-items: center; min-height: 44px; }
.tf-pill {
  display: inline-flex; align-items: center; justify-content: center; min-height: 44px; width: 96px; padding: 0 6px; cursor: pointer; white-space: nowrap; overflow: hidden;
  background: none; border: 0; color: var(--ink-2); font: 500 13px/1 var(--body); position: relative;
}
/* The visible pill is 30px tall; the button around it is the 44px touch target. */
.tf-pill::before { content: ""; position: absolute; inset: 7px 0; border-radius: 999px; background: var(--chip-bg); border: 1px solid var(--chip-border); z-index: -1; }
.tf-pill { z-index: 0; }
.task.overdue .tf-pill { color: var(--overdue); font-weight: 600; }
.task.overdue .tf-pill::before { border-color: var(--overdue); background: color-mix(in srgb, var(--overdue) 8%, var(--card)); }
.task.done .tf-pill { color: var(--muted); }

/* Floating add button */
.fab {
  position: fixed; right: calc(16px + env(safe-area-inset-right)); bottom: calc(20px + env(safe-area-inset-bottom)); width: 60px; height: 60px; border-radius: 50%;
  border: 0; background: var(--accent); color: var(--accent-ink); box-shadow: var(--shadow-lift); display: flex; align-items: center; justify-content: center; cursor: pointer;
}
.fab svg { width: 28px; height: 28px; }

/* Bottom sheets */
.sheet {
  margin: auto 0 0; width: 100%; max-width: 100%; max-height: 90vh; padding: 0; border: 1px solid var(--card-border); border-bottom: 0;
  border-radius: 20px 20px 0 0; background: var(--card); color: var(--ink); box-shadow: var(--shadow-lift);
}
.sheet::backdrop { background: color-mix(in srgb, var(--ink) 45%, transparent); }
.sheet form { padding: 20px 16px calc(16px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 14px; }
.sheet h2 { font-size: 20px; overflow-wrap: anywhere; }
.sheet p { margin: 0; }
.sheet-foot { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.when-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.when-btn { min-height: 44px; border-radius: 12px; border: 1px solid var(--chip-border); background: var(--chip-bg); color: var(--ink); font-weight: 500; cursor: pointer; }
.when-btn[aria-checked="true"] { background: color-mix(in srgb, var(--accent) 14%, var(--card)); border-color: var(--accent); font-weight: 600; }
@media (min-width: 640px) {
  .sheet { margin: auto; width: min(520px, calc(100vw - 32px)); border-radius: 20px; border-bottom: 1px solid var(--card-border); }
}

.toast {
  position: fixed; left: 50%; bottom: calc(92px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 60; background: var(--ink); color: var(--bg);
  padding: 4px 16px; min-height: 48px; border-radius: 12px; box-shadow: var(--shadow-lift); display: flex; gap: 10px; align-items: center; font-size: 14px;
  width: max-content; max-width: calc(100vw - 32px);
}
