/* Golgi — always-dark, phone-first. Amber is reserved for "personal / goes to
 * Claude" states and primary actions; red for overdue and errors; grey elsewhere. */

:root {
  color-scheme: dark;
  --bg: #0f1115;
  --surface: #161922;
  --surface-2: #1d212c;
  --border: #272c39;
  --border-strong: #363d4d;
  --text: #e8eaf0;
  --muted: #8b93a3;
  --faint: #80899b;             /* ≥ 4.5:1 on every surface (was #5d6576, 3.2:1) */
  --amber: #f5a524;
  --amber-soft: rgba(245, 165, 36, 0.16);
  --red: #f0524f;
  --red-soft: rgba(240, 82, 79, 0.16);
  --ink: #0f1115;               /* text on amber */
  --radius: 14px;
  --tap: 44px;
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --tabs-h: 58px;
}

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

html, body {
  height: 100%;
  margin: 0;
  overscroll-behavior: none;
  background: var(--bg);
  color: var(--text);
}
html { font-size: 17px; -webkit-text-size-adjust: 100%; }
body {
  position: fixed;               /* the body never scrolls; #view does */
  inset: 0;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", system-ui, sans-serif;
  line-height: 1.4;
}

a { color: inherit; text-decoration: none; }
h1, h2, h3, p { margin: 0; }
button { font: inherit; color: inherit; cursor: pointer; }
input, textarea, select { font: inherit; color: inherit; }
[hidden] { display: none !important; }

/* ---------------------------------------------------------------- layout */
/* Rows are assigned explicitly so the away banner (row 2) collapses to nothing while hidden. */
#app { display: grid; grid-template-rows: auto auto 1fr auto; height: 100%; }
#header { grid-row: 1; }
#away { grid-row: 2; }
#view { grid-row: 3; }
#tabs { grid-row: 4; }

#header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: calc(var(--sat) + 6px) 8px 6px 8px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  user-select: none;
  -webkit-user-select: none;
}
#title {
  flex: 1;
  font-size: 21px;
  font-weight: 700;
  letter-spacing: -0.01em;
  padding-left: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#back:not([hidden]) + #title { padding-left: 0; }
.icon-btn {
  width: var(--tap);
  height: var(--tap);
  display: grid;
  place-items: center;
  border: none;
  background: none;
  border-radius: 12px;
  color: var(--muted);
}
.icon-btn svg { width: 26px; height: 26px; }
.icon-btn:active { background: var(--surface-2); color: var(--text); }

#view {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding: 12px 12px 96px;
}

#tabs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  padding: 4px 4px calc(var(--sab) + 4px);
  background: var(--surface);
  border-top: 1px solid var(--border);
  user-select: none;
  -webkit-user-select: none;
}
#tabs a {
  position: relative;
  min-height: 50px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  border-radius: 12px;
}
#tabs a.active { color: var(--text); }
#tabs a:active { background: var(--surface-2); }
#tabs svg { width: 24px; height: 24px; }
#tabs .badge-unsent {
  position: absolute;
  top: 3px;
  left: calc(50% + 6px);
  min-width: 18px;
  padding: 3px 5px;
  text-align: center;
}

.badge-unsent {
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  color: var(--ink);
  background: var(--red);
  border-radius: 999px;
  padding: 4px 8px;
  white-space: nowrap;
}

/* ---------------------------------------------------------------- shared */
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 13px; }
.red { color: var(--red); }
.amber { color: var(--amber); }
.center { text-align: center; padding: 24px 12px; }
.stack > * + * { margin-top: 10px; }
.row { display: flex; align-items: center; gap: 8px; }
.row-wrap { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.grow { flex: 1; min-width: 0; }
.section-title {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 18px 4px 8px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
}

.badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  line-height: 1;
  padding: 5px 8px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  color: var(--muted);
  background: var(--surface-2);
  white-space: nowrap;
}
.badge-personal { color: var(--amber); border-color: var(--amber); background: var(--amber-soft); }
.badge-work { color: var(--muted); }
.badge-failed { color: var(--red); border-color: var(--red); background: var(--red-soft); }
.badge-processed { color: var(--text); }
.badge-processing, .badge-captured { color: var(--amber); }

.chip {
  display: inline-block;
  font-size: 12px;
  line-height: 1.2;
  padding: 3px 9px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--muted);
  white-space: nowrap;
  max-width: 45%;
  overflow: hidden;
  text-overflow: ellipsis;
}

.btn {
  min-height: var(--tap);
  padding: 0 16px;
  border-radius: 12px;
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  color: var(--text);
  font-size: 16px;
  font-weight: 600;
  user-select: none;
  -webkit-user-select: none;
  white-space: nowrap;
}
.btn:active { filter: brightness(1.25); }
.btn:disabled { opacity: 0.5; }
.btn-primary { background: var(--amber); border-color: var(--amber); color: var(--ink); }
.btn-danger { background: var(--red-soft); border-color: var(--red); color: var(--red); }
.btn-ghost { background: transparent; border-color: var(--border); color: var(--muted); }
.btn-block { width: 100%; }
.btn-sm { font-size: 14px; padding: 0 12px; }

input[type="text"], input[type="search"], input[type="password"], input[type="number"], input[type="date"], input[type="datetime-local"], select.select, textarea {
  width: 100%;
  min-height: var(--tap);
  font-size: 17px;             /* 16px+ keeps iOS from zooming the page */
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  color: var(--text);
  -webkit-appearance: none;
  appearance: none;
  outline: none;
}
input:focus, textarea:focus { border-color: var(--muted); }
textarea { resize: vertical; line-height: 1.45; }
input[type="date"], input[type="datetime-local"] { display: block; }
select.select { -webkit-appearance: menulist-button; appearance: auto; }
input::placeholder, textarea::placeholder { color: var(--faint); }
input[type="search"]::-webkit-search-cancel-button { -webkit-appearance: none; }
label.field { display: block; }
label.field > span, .field-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  margin: 0 2px 5px;
}
.field + .field { margin-top: 12px; }

/* segmented control (also used as filter chips) */
.seg {
  display: flex;
  gap: 2px;
  padding: 2px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  user-select: none;
  -webkit-user-select: none;
}
.seg-btn {
  flex: 1;
  min-height: var(--tap);
  border: none;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  font-size: 15px;
  font-weight: 600;
}
.seg-btn.on { background: var(--border-strong); color: var(--text); }
.seg-btn[data-value="personal"].on { background: var(--amber); color: var(--ink); }
/* Away mode: the capture control is a single amber Personal pill; no choice to make. */
.seg.locked { border-color: var(--amber); }
.seg.locked .seg-btn.on { cursor: default; }

/* Away-mode banner: sits between the header and the view on every route (see #app rows). */
.away-banner {
  padding: 7px 14px;
  background: var(--amber-soft);
  border-bottom: 1px solid var(--amber);
  color: var(--amber);
  font-size: 14px;
  font-weight: 600;
  line-height: 1.3;
  text-align: center;
}
.seg-status .seg-btn[data-value="done"].on,
.seg-status .seg-btn[data-value="dropped"].on { background: var(--border-strong); color: var(--text); }

.stepper {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  background: var(--surface-2);
  overflow: hidden;
}
.stepper button {
  width: var(--tap);
  height: var(--tap);
  border: none;
  background: transparent;
  font-size: 22px;
  color: var(--text);
}
.stepper button:active { background: var(--border-strong); }
.stepper output { min-width: 32px; text-align: center; font-weight: 700; font-size: 18px; }

.toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: var(--tap);
  gap: 12px;
}
.switch {
  position: relative;
  width: 52px;
  height: 32px;
  border-radius: 999px;
  border: none;
  background: var(--border-strong);
  transition: background 0.15s;
  flex: none;
}
.switch::before { content: ""; position: absolute; inset: -6px; }   /* 44px-tall hit area */
.switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.15s;
}
.switch[aria-checked="true"] { background: var(--amber); }
.switch[aria-checked="true"]::after { transform: translateX(20px); }

.error-box {
  border: 1px solid var(--red);
  background: var(--red-soft);
  border-radius: var(--radius);
  padding: 12px;
  color: var(--text);
}
.error-box .btn { margin-top: 10px; }
.notice {
  border: 1px solid var(--amber);
  background: var(--amber-soft);
  border-radius: var(--radius);
  padding: 10px 12px;
  font-size: 15px;
  margin-bottom: 12px;
}

.processing-dots::after {
  content: "…";
  animation: dots 1.2s steps(4, end) infinite;
}
@keyframes dots {
  0% { content: ""; } 25% { content: "."; } 50% { content: ".."; } 75% { content: "..."; }
}

/* ---------------------------------------------------------------- today */
.banner {
  display: block;
  margin: -4px 0 10px;
  padding: 8px 12px;
  border-radius: 10px;
  background: var(--red-soft);
  border: 1px solid var(--red);
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
}
.banner .arrow { float: right; color: var(--muted); }

.filter-row { display: flex; gap: 8px; align-items: center; margin-bottom: 10px; }
/* Done log (#/done): the link on Today, muted rows, a filled check that reopens. */
.filter-row .link-done { margin-left: auto; display: flex; align-items: center; min-height: var(--tap); padding: 0 6px; color: var(--muted); font-size: 14px; font-weight: 600; }
.task-row.done .task-title { color: var(--muted); font-weight: 500; }
.task-meta .done-at { white-space: nowrap; }
.check.done::before { display: none; }
.check-glyph { width: 24px; height: 24px; border-radius: 50%; background: var(--border-strong); color: var(--text); display: grid; place-items: center; }
.check-glyph svg { width: 14px; height: 14px; }
.check.done:active .check-glyph { background: var(--muted); }
/* Projects (§15) and reminders (§16) */
.links-row { display: flex; justify-content: flex-end; gap: 4px; margin: -6px 0 6px; }
.links-row .link-done { margin-left: 0; }
.chip-project { background: transparent; border-color: var(--border-strong); color: var(--text); }
.task-meta .remind { display: inline-flex; align-items: center; gap: 3px; white-space: nowrap; color: var(--muted); }
.task-meta .remind .bell { width: 13px; height: 13px; color: var(--amber); }
.project-row { display: block; }
.project-name { font-weight: 600; font-size: 17px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.project-detail { margin-top: 4px; }
/* §17: the other person's rows and shared rows */
.chip-owner { border-style: dashed; }
.chip-shared { color: var(--amber); border-color: var(--amber); background: var(--amber-soft); }
.filter-row .seg { flex: 1; }

.task-list { display: flex; flex-direction: column; gap: 8px; }

.task-row {
  position: relative;
  overflow: hidden;
  border-radius: 12px;
  border: 1px solid var(--border);
  border-left: 4px solid var(--border);
  background: var(--amber);
  user-select: none;
  -webkit-user-select: none;
  touch-action: pan-y;
}
.task-row.overdue { border-left-color: var(--red); }
.task-bg {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  padding-left: 18px;
  color: var(--ink);
  font-weight: 800;
  letter-spacing: 0.04em;
  background: var(--amber);
  opacity: 0.55;
}
.task-row.past .task-bg { opacity: 1; }
.task-fg {
  position: relative;
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 62px;
  padding: 6px 12px 6px 2px;
  background: var(--surface);
  transition: transform 0.18s ease-out;
  will-change: transform;
}
.check {
  flex: none;
  width: var(--tap);
  height: var(--tap);
  display: grid;
  place-items: center;
  border: none;
  background: none;
  padding: 0;
}
.check::before {
  content: "";
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid var(--muted);
  box-sizing: border-box;
}
.check:active::before { background: var(--amber); border-color: var(--amber); }
.task-main { flex: 1; min-width: 0; padding: 2px 0; }
.task-title {
  font-size: 17px;
  font-weight: 600;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
}
.task-title .pin { display: inline-block; width: 15px; height: 15px; vertical-align: -2px; margin-right: 4px; color: var(--amber); }
.task-title .rank {
  display: inline-block;
  font-size: 12px;
  font-weight: 800;
  color: var(--ink);
  background: var(--text);
  border-radius: 6px;
  padding: 1px 5px;
  margin-right: 6px;
  vertical-align: 1px;
}
.task-meta { display: flex; align-items: center; gap: 8px; margin-top: 3px; font-size: 13px; color: var(--muted); min-height: 18px; }
.task-meta .due { font-weight: 600; white-space: nowrap; }
.task-row.overdue .due { color: var(--red); }
.mode-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--faint); flex: none; }
.mode-dot.mode-personal { background: var(--amber); }

.score { display: flex; gap: 2px; align-items: flex-end; height: 16px; flex: none; margin-left: 4px; }
.score i { width: 4px; border-radius: 1px; background: var(--border-strong); }
.score i:nth-child(1) { height: 6px; }
.score i:nth-child(2) { height: 9px; }
.score i:nth-child(3) { height: 12px; }
.score i:nth-child(4) { height: 15px; }
.score.l1 i:nth-child(-n+1), .score.l2 i:nth-child(-n+2),
.score.l3 i:nth-child(-n+3), .score.l4 i { background: var(--text); }

.fab {
  position: fixed;
  right: 16px;
  bottom: calc(var(--sab) + var(--tabs-h) + 16px);
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--amber);
  color: var(--ink);
  display: grid;
  place-items: center;
  font-size: 32px;
  font-weight: 500;
  line-height: 1;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.45);
  user-select: none;
  -webkit-user-select: none;
}
.fab:active { filter: brightness(1.15); }

/* ---------------------------------------------------------------- capture */
.capture-card {
  border: 2px solid var(--border-strong);
  border-radius: 18px;
  background: var(--surface);
  padding: 12px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.capture-card.personal {
  border-color: var(--amber);
  box-shadow: 0 0 0 4px var(--amber-soft);
}
.mode-label {
  margin: 12px 2px 8px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.01em;
  color: var(--muted);
}
.capture-card.personal .mode-label { color: var(--amber); }
.capture-text { min-height: 40vh; font-size: 18px; }
.btn-submit {
  margin-top: 12px;
  min-height: 54px;
  font-size: 18px;
  background: var(--border-strong);
  border-color: var(--border-strong);
}
.capture-card.personal .btn-submit { background: var(--amber); border-color: var(--amber); color: var(--ink); }
.unsent-line { margin-top: 10px; font-size: 14px; color: var(--red); font-weight: 600; }

/* ---------------------------------------------------------------- notes */
.note-list { display: flex; flex-direction: column; gap: 10px; }
.note-card { padding: 12px; }
.note-card.mode-personal { border-color: rgba(245, 165, 36, 0.35); }
.note-head { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; }
.note-time { margin: -10px -4px -10px auto; padding: 0 4px; font-size: 13px; color: var(--muted); min-height: var(--tap); display: inline-flex; align-items: center; }
.note-raw {
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.45;
  user-select: text;
  -webkit-user-select: text;
}
.note-raw.clamp {
  display: -webkit-box;
  -webkit-line-clamp: 6;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.note-status { margin-top: 8px; font-size: 14px; }
.note-marker {
  display: inline-block;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--muted);
  border: 1px dashed var(--border-strong);
  border-radius: 8px;
  padding: 4px 8px;
}
.segment { margin-top: 10px; padding: 8px 10px; border-left: 3px solid var(--border-strong); background: var(--surface-2); border-radius: 0 10px 10px 0; }
.segment-title { font-weight: 700; font-size: 15px; }
.segment-body { font-size: 15px; color: var(--muted); white-space: pre-wrap; margin-top: 2px; user-select: text; -webkit-user-select: text; }
.note-tasks { list-style: none; margin: 8px 0 0; padding: 0; }
.note-tasks li a { display: flex; align-items: center; gap: 8px; min-height: var(--tap); padding: 4px 0; font-size: 15px; }
.note-tasks .status { font-size: 11px; font-weight: 700; text-transform: uppercase; color: var(--muted); }
.note-tasks .status-open { color: var(--amber); }
.note-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.note-actions .btn { flex: 1; }

.link-list, .run-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.link-row { display: block; padding: 10px 12px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--border); }
.link-rel { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
.link-peer { margin-top: 3px; font-weight: 600; }
.link-excerpt { font-size: 14px; color: var(--muted); }
.link-reason { margin-top: 4px; font-size: 14px; font-style: italic; color: var(--text); }
.run-row { padding: 8px 12px; font-size: 14px; color: var(--muted); background: var(--surface-2); border-radius: 10px; }

/* ---------------------------------------------------------------- search */
.search-head { position: sticky; top: -12px; padding: 4px 0 8px; background: var(--bg); z-index: 1; }
.search-head .seg { margin-top: 8px; }
.result {
  display: block;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  margin-bottom: 8px;
}
.result-head { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.result-title { font-weight: 700; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.snippet { font-size: 15px; color: var(--muted); line-height: 1.4; user-select: text; -webkit-user-select: text; }
.snippet b { color: var(--amber); font-weight: 700; }

/* ---------------------------------------------------------------- task detail */
.detail-meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 13px; color: var(--muted); margin-bottom: 12px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field-inline { display: flex; align-items: center; justify-content: space-between; min-height: var(--tap); gap: 12px; }
.field-inline > span { font-size: 15px; font-weight: 600; }
.date-row { display: flex; gap: 8px; align-items: center; }
.date-row input { flex: 1; }
.prov-excerpt { font-size: 15px; color: var(--muted); margin-top: 6px; display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; white-space: pre-wrap; }
.locked-note { font-size: 13px; color: var(--muted); margin-top: 8px; }

/* ---------------------------------------------------------------- settings */
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; font-size: 15px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; word-break: break-word; }
.status-lines { list-style: none; margin: 0; padding: 0; font-size: 15px; }
.status-lines li { padding: 6px 0; border-bottom: 1px solid var(--border); }
.status-lines li:last-child { border-bottom: none; }
.attention-list { list-style: none; margin: 8px 0 0; padding: 0; }
.attention-list li a { display: block; padding: 8px 0; min-height: var(--tap); }

/* ---------------------------------------------------------------- toast + modal */
#toast {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: calc(var(--sab) + var(--tabs-h) + 14px);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 8px 8px 16px;
  border-radius: 14px;
  background: #262b37;
  color: var(--text);
  border: 1px solid var(--border-strong);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  z-index: 20;
  font-size: 15px;
  animation: rise 0.18s ease-out;
}
#toast.toast-error { border-color: var(--red); }
#app:has(.fab) #toast { right: 84px; }   /* stay clear of the + button (Today) */
#toast .toast-msg { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
#toast .toast-action {
  flex: none;
  min-height: var(--tap);
  padding: 0 14px;
  border: none;
  border-radius: 10px;
  background: var(--amber);
  color: var(--ink);
  font-weight: 700;
}
@keyframes rise { from { transform: translateY(10px); opacity: 0; } to { transform: none; opacity: 1; } }

#modal {
  position: fixed;
  inset: 0;
  z-index: 30;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.sheet {
  width: 100%;
  max-height: 88%;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background: var(--surface);
  border-radius: 18px 18px 0 0;
  border-top: 1px solid var(--border-strong);
  padding: 16px 16px calc(var(--sab) + 16px);
  animation: rise 0.18s ease-out;
}
.sheet h2 { font-size: 19px; margin-bottom: 10px; }
.sheet-body { margin-bottom: 14px; }
.sheet-actions { display: flex; gap: 10px; }
.sheet-actions .btn { flex: 1; }
.warn-amber {
  border: 1px solid var(--amber);
  background: var(--amber-soft);
  color: var(--amber);
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 10px;
}
