/*
 * app.css — design tokens plus component styles, in one file.
 *
 * No build step, so there is no preprocessor: everything is custom properties and
 * plain selectors. Dark mode is a token swap under prefers-color-scheme, or a
 * data-theme attribute when the user picks explicitly, so nothing needs a second
 * ruleset to change colour.
 */

:root {
  color-scheme: light;

  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --border: #dfe3e8;
  --border-strong: #c4cbd4;
  --text: #16191d;
  --text-dim: #5b6472;
  --text-faint: #8b95a3;

  --accent: #2f6feb;
  --accent-text: #ffffff;
  --accent-soft: #e7efff;

  --danger: #c8322f;
  --danger-soft: #fdecec;
  --warn: #9a6400;
  --warn-soft: #fdf3e0;
  --good: #1a7f4b;
  --good-soft: #e6f5ec;

  --radius: 8px;
  --radius-lg: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .1);
  --shadow-lg: 0 8px 28px rgba(16, 24, 40, .18);
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #14171c;
    --surface: #1c2027;
    --surface-2: #22272f;
    --border: #2e343d;
    --border-strong: #414a56;
    --text: #e8eaed;
    --text-dim: #a3adba;
    --text-faint: #78828f;
    --accent: #4b86f0;
    --accent-soft: #1e2a41;
    --danger: #f07d7a;
    --danger-soft: #3a1f1f;
    --warn: #e0aa4e;
    --warn-soft: #382c14;
    --good: #5fbf88;
    --good-soft: #16301f;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3);
    --shadow-lg: 0 8px 28px rgba(0, 0, 0, .5);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #14171c;
  --surface: #1c2027;
  --surface-2: #22272f;
  --border: #2e343d;
  --border-strong: #414a56;
  --text: #e8eaed;
  --text-dim: #a3adba;
  --text-faint: #78828f;
  --accent: #4b86f0;
  --accent-soft: #1e2a41;
  --danger: #f07d7a;
  --danger-soft: #3a1f1f;
  --warn: #e0aa4e;
  --warn-soft: #382c14;
  --good: #5fbf88;
  --good-soft: #16301f;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3);
  --shadow-lg: 0 8px 28px rgba(0, 0, 0, .5);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { margin: 0; font-weight: 600; line-height: 1.25; }
a { color: var(--accent); }
[hidden] { display: none !important; }

/* ---------- controls ----------------------------------------------------- */

button, .btn {
  font: inherit;
  font-weight: 500;
  padding: 7px 13px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
button:hover:not(:disabled) { background: var(--surface-2); }
button:disabled { opacity: .5; cursor: not-allowed; }
button:focus-visible, [tabindex]:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
button.primary:hover:not(:disabled) { filter: brightness(1.08); }
button.danger { color: var(--danger); border-color: var(--border-strong); }
button.danger:hover:not(:disabled) { background: var(--danger-soft); }
button.ghost { border-color: transparent; background: transparent; }
button.ghost:hover:not(:disabled) { background: var(--surface-2); }
button.icon { padding: 6px 8px; }

input[type="text"], input[type="password"], input[type="date"], textarea, select {
  font: inherit;
  width: 100%;
  padding: 8px 10px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
}
textarea { resize: vertical; min-height: 90px; }
label { display: block; font-weight: 500; margin-bottom: 4px; }
.field { margin-bottom: 14px; }
.field .hint { color: var(--text-dim); font-size: 12.5px; margin-top: 4px; font-weight: 400; }
.row { display: flex; gap: 10px; flex-wrap: wrap; }
.row > * { flex: 1 1 140px; min-width: 0; }
/* A row whose children size to their own content. For a toggle pair or an action bar,
   where stretching every button across the width reads as several primary actions. */
.row.tight > * { flex: 0 1 auto; }
.row.tight > .spacer { flex: 1 1 auto; }
.check { display: flex; gap: 8px; align-items: flex-start; font-weight: 400; }
.check input { width: auto; margin-top: 2px; flex: none; }
/* Marks the option we think most people should take, next to its label. */
.pill-rec {
  display: inline-block;
  margin-left: 7px;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--good-soft);
  color: var(--good);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .02em;
  vertical-align: 1px;
}

/* ---------- layout ------------------------------------------------------- */

header.top {
  position: sticky;
  top: env(safe-area-inset-top, 0px);
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 10px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.brand { font-weight: 650; letter-spacing: -.01em; display: flex; align-items: center; gap: 8px; }
.brand .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--good); flex: none; }
.brand .dot.offline { background: var(--text-faint); }
.repo-chip {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-dim);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px 10px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 42vw;
}
.repo-chip .lock { color: var(--warn); }
.spacer { flex: 1 1 auto; }

nav.tabs { display: flex; gap: 2px; padding: 0 10px; background: var(--surface); border-bottom: 1px solid var(--border); overflow-x: auto; }
nav.tabs button {
  border: none;
  background: none;
  border-radius: 0;
  border-bottom: 2px solid transparent;
  color: var(--text-dim);
  padding: 10px 12px;
  white-space: nowrap;
}
nav.tabs button[aria-selected="true"] { color: var(--accent); border-bottom-color: var(--accent); }
nav.tabs button.open::before { content: '\25CF'; font-size: 8px; vertical-align: 2px; margin-right: 5px; }
.nav-hint { align-self: center; color: var(--text-faint); font-size: 11.5px; padding-right: 8px; white-space: nowrap; }

/* Where AI requests go, permanently visible. Colour carries the meaning: neutral
   when off, green when it never leaves the machine, amber when it does. */
.ai-chip { font-size: 12px; border-radius: 999px; padding: 3px 10px; white-space: nowrap; }
.ai-chip.mode-off { color: var(--text-faint); }
.ai-chip.mode-local { color: var(--good); border-color: var(--good); background: var(--good-soft); }
.ai-chip.mode-hf, .ai-chip.mode-api { color: var(--warn); border-color: var(--warn); background: var(--warn-soft); }

main { padding: 16px; padding-bottom: calc(24px + env(safe-area-inset-bottom, 0px)); }
.view { max-width: 1400px; margin: 0 auto; }
.view-narrow { max-width: 820px; margin: 0 auto; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  box-shadow: var(--shadow);
}
.card + .card { margin-top: 14px; }
.card h2 { font-size: 15px; margin-bottom: 4px; }
.card .sub { color: var(--text-dim); font-size: 12.5px; }

.pending-badge {
  background: var(--warn-soft);
  color: var(--warn);
  border: 1px solid currentColor;
  border-radius: 999px;
  padding: 2px 9px;
  font-size: 12px;
  font-weight: 600;
  /* It is a button now, so it has to look like one you can press. */
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
}
.pending-badge:hover { background: var(--warn); color: var(--surface); }

ul.pending-list {
  list-style: none;
  margin: 10px 0 0;
  padding: 0;
  max-height: 300px;
  overflow-y: auto;
  font-size: 13px;
}
ul.pending-list li {
  display: flex;
  gap: 9px;
  padding: 6px 0;
  border-top: 1px solid var(--border);
}
ul.pending-list .when { font-family: var(--mono); font-size: 11px; color: var(--text-dim); flex: none; padding-top: 1px; }

/* ---------- board -------------------------------------------------------- */

.board { display: flex; gap: 12px; align-items: flex-start; overflow-x: auto; padding-bottom: 8px; }
.column {
  flex: 1 0 235px;
  max-width: 320px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 10px;
  min-height: 120px;
}
.column.drag-over { border-color: var(--accent); background: var(--accent-soft); }
.column > h3 {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-dim);
  display: flex;
  justify-content: space-between;
  margin-bottom: 10px;
}
.column .count { color: var(--text-faint); }
.column .empty { color: var(--text-faint); font-size: 12.5px; text-align: center; padding: 14px 4px; }

.task {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 9px 10px;
  margin-bottom: 8px;
  cursor: grab;
  box-shadow: var(--shadow);
}
.task:hover { border-color: var(--border-strong); }
.task.dragging { opacity: .4; }
.task.p-high { border-left-color: var(--warn); }
.task.p-urgent { border-left-color: var(--danger); }
.task.p-low { border-left-color: var(--border); }
.task .title { font-weight: 500; word-break: break-word; }
.task .meta { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-top: 6px; font-size: 11.5px; color: var(--text-faint); }
.task .id { font-family: var(--mono); }
.tag {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 6px;
  font-size: 11px;
  color: var(--text-dim);
}
.tag.private { background: var(--warn-soft); color: var(--warn); border-color: currentColor; }
.task.flash { animation: flash 1.4s ease-out; }
@keyframes flash { from { box-shadow: 0 0 0 3px var(--accent); } to { box-shadow: var(--shadow); } }

/* ---------- summary ------------------------------------------------------ */

.summary .headline { font-size: 18px; font-weight: 600; margin-bottom: 12px; letter-spacing: -.01em; }
.summary ul { margin: 0 0 4px; padding-left: 20px; }
.summary li { margin-bottom: 5px; }
.summary .section-label { font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--text-dim); margin: 14px 0 5px; }
.summary .risks li { color: var(--danger); }
.taskref {
  font-family: var(--mono);
  font-size: 11px;
  background: var(--accent-soft);
  color: var(--accent);
  border: none;
  border-radius: 4px;
  padding: 1px 5px;
  margin-left: 4px;
  cursor: pointer;
}
.stale { background: var(--warn-soft); color: var(--warn); border: 1px solid currentColor; border-radius: var(--radius); padding: 8px 11px; font-size: 12.5px; margin-bottom: 12px; }

/* ---------- proposals ---------------------------------------------------- */

.proposal { display: flex; gap: 10px; align-items: flex-start; padding: 11px 0; border-top: 1px solid var(--border); }
.proposal:first-of-type { border-top: none; }
.proposal input[type="checkbox"] { width: auto; flex: none; margin-top: 3px; }
.proposal .body { flex: 1; min-width: 0; }
.proposal .what { font-weight: 500; word-break: break-word; }
.proposal .why { color: var(--text-dim); font-size: 12.5px; margin-top: 2px; }
.op-badge {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: .04em;
  font-weight: 700;
  border-radius: 4px;
  padding: 2px 6px;
  margin-right: 6px;
  background: var(--surface-2);
  color: var(--text-dim);
}
.op-create { background: var(--good-soft); color: var(--good); }
.op-status { background: var(--accent-soft); color: var(--accent); }
.op-note { background: var(--surface-2); color: var(--text-dim); }
.op-edit { background: var(--warn-soft); color: var(--warn); }

/* ---------- dialogs ------------------------------------------------------ */

dialog {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  color: var(--text);
  padding: 0;
  box-shadow: var(--shadow-lg);
  width: min(620px, calc(100vw - 24px));
  max-height: min(86vh, 900px);
  overflow: auto;
}
dialog::backdrop { background: rgba(10, 14, 20, .55); }
dialog .dlg-head { padding: 16px 18px 0; }
dialog .dlg-head h2 { font-size: 16px; }
dialog .dlg-body { padding: 14px 18px; }
dialog .dlg-foot {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  flex-wrap: wrap;
  padding: 12px 18px;
  background: var(--surface-2);
  border-top: 1px solid var(--border);
  position: sticky;
  bottom: 0;
}
dialog .dlg-foot .spacer { flex: 1 1 auto; }

/* Same treatment for anything shown verbatim before it is sent or committed. */
pre.commit-preview,
pre.payload {
  font-family: var(--mono);
  font-size: 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 11px;
  margin: 0;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 260px;
  overflow-y: auto;
}
ul.file-list { list-style: none; margin: 8px 0 0; padding: 0; font-family: var(--mono); font-size: 12px; color: var(--text-dim); }
ul.file-list li::before { content: "M "; color: var(--good); }

/* The report you are about to paste somewhere. Monospaced for the same reason the
   commit preview is: what you see has to be exactly what gets copied, including the
   blank lines, and a proportional font hides trailing whitespace. */
textarea.mono {
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.55;
  min-height: 220px;
  /* Wrapped, not scrolled: a note written as a paragraph is normal here, and the
     wrap is only visual -- what gets copied is the value, newlines unchanged. */
  white-space: pre-wrap;
}


/* ---------- panes ---------------------------------------------------------
   Side-by-side views. `count-N` rather than auto-fit because each pane wants a
   different minimum: the board is happiest widest, so it takes the extra room. */

.panes { display: grid; gap: 14px; align-items: start; max-width: 1900px; margin: 0 auto; }
.panes.count-1 { grid-template-columns: 1fr; }
.panes.count-2 { grid-template-columns: 1.25fr 1fr; }
.panes.count-3 { grid-template-columns: 1.35fr 1fr 1fr; }
.panes.count-4 { grid-template-columns: 1.4fr 1fr 1fr 1fr; }

.pane { min-width: 0; }                     /* lets a pane shrink instead of overflowing */
.pane > .view-narrow, .pane > .view { max-width: none; margin: 0; }
.panes:not(.count-1) .pane { border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--bg); padding: 10px; }
.panes:not(.count-1) .pane.focused { border-color: var(--border-strong); }
.panes:not(.count-1) .card { box-shadow: none; }
.pane-head { display: flex; align-items: center; gap: 6px; padding: 0 2px 8px; }
.pane-title { font-size: 12px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--text-faint); }
/* A pane is narrow, so board columns stop competing for width and scroll instead. */
.panes:not(.count-1) .column { flex: 0 0 210px; max-width: 210px; }

/* ---------- wiki ---------------------------------------------------------- */

.wiki-tabs { display: flex; gap: 6px; margin-bottom: 12px; }
.wiki-tabs button.on { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.wiki-group { margin-bottom: 14px; }
.wiki-list { list-style: none; padding: 0; margin: 0; }
.wiki-list li { padding: 5px 0; border-top: 1px solid var(--border); line-height: 1.45; }
.wiki-list li:first-child { border-top: none; }
.wiki-meta { color: var(--text-faint); font-size: 11.5px; }
.wiki-link {
  background: none; border: none; padding: 0; color: var(--accent);
  font: inherit; text-align: left; cursor: pointer; border-radius: 2px;
}
.wiki-link:hover { text-decoration: underline; }
.wiki-link.inline { font-family: var(--mono); font-size: .92em; }
.wiki-article h2 { margin: 10px 0 4px; }
.wiki-facts { display: flex; flex-wrap: wrap; gap: 4px 18px; margin: 8px 0 12px; }
.wiki-fact { display: flex; flex-direction: column; }
.wiki-note { border-left: 2px solid var(--border-strong); padding: 4px 0 4px 10px; margin: 8px 0; }
.tag-cloud { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0 12px; }

/* ---------- notices ------------------------------------------------------ */

.notice { border: 1px solid var(--border); border-left-width: 3px; border-radius: var(--radius); padding: 10px 12px; font-size: 13px; margin-bottom: 12px; }
.notice.info { background: var(--accent-soft); border-left-color: var(--accent); }
.notice.warn { background: var(--warn-soft); border-left-color: var(--warn); color: var(--warn); }
.notice.error { background: var(--danger-soft); border-left-color: var(--danger); color: var(--danger); }
.notice.good { background: var(--good-soft); border-left-color: var(--good); color: var(--good); }

#toasts { position: fixed; bottom: calc(16px + env(safe-area-inset-bottom, 0px)); left: 50%; transform: translateX(-50%); z-index: 50; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast { background: var(--text); color: var(--bg); padding: 9px 15px; border-radius: 999px; box-shadow: var(--shadow-lg); font-size: 13px; max-width: min(520px, 92vw); }
.toast.error { background: var(--danger); color: #fff; }

.spinner { width: 14px; height: 14px; border: 2px solid var(--border-strong); border-top-color: var(--accent); border-radius: 50%; animation: spin .7s linear infinite; display: inline-block; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading { display: flex; align-items: center; gap: 9px; color: var(--text-dim); }

.notes-list { list-style: none; padding: 0; margin: 0; }
.notes-list li { border-top: 1px solid var(--border); padding: 8px 0; }
.notes-list time { color: var(--text-faint); font-size: 11.5px; display: block; }

@media (max-width: 620px) {
  header.top { padding: 9px 12px; gap: 8px; }
  main { padding: 12px; }
  .repo-chip { max-width: 100%; order: 5; flex: 1 1 100%; max-width: none; }
  .column { flex: 0 0 84vw; max-width: 84vw; }
  .nav-hint { display: none; }
  .panes { gap: 10px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* Earlier years are in the repo but not downloaded; the wiki offers them. */
.wiki-more { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--border); }
