:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --text: #1f2328;
  --muted: #656d76;
  --border: #d8dee4;
  --accent: #2f6feb;
  --accent-text: #ffffff;
  --danger: #cf222e;
  --waiting: #9a6700;
  --waiting-bg: #fff8c5;
  --project: #6b7280;
  color-scheme: light dark;
}
/* Theme: data-theme on <html> forces light or dark; without it the system decides.
   The two dark blocks must stay identical. */
:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] {
  --bg: #0d1117;
  --surface: #161b22;
  --text: #e6edf3;
  --muted: #8d96a0;
  --border: #30363d;
  --accent: #4493f8;
  --accent-text: #0d1117;
  --danger: #f85149;
  --waiting: #e3b341;
  --waiting-bg: #3b2e0a;
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d1117;
    --surface: #161b22;
    --text: #e6edf3;
    --muted: #8d96a0;
    --border: #30363d;
    --accent: #4493f8;
    --accent-text: #0d1117;
    --danger: #f85149;
    --waiting: #e3b341;
    --waiting-bg: #3b2e0a;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
/* display: none on the sprite would break <use> in some browsers, and [hidden] does not apply to SVG. */
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--accent); }
h1 { font-size: 1.5rem; margin: .25rem 0 1rem; }
h2 { font-size: 1rem; margin: 0; }
.muted { color: var(--muted); }
.error { color: var(--danger); font-size: .9rem; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; padding: .6rem 1rem;
  background: var(--surface); border-bottom: 1px solid var(--border);
}
.brand { font-weight: 700; color: var(--text); text-decoration: none; }
.topbar-actions { display: flex; gap: .5rem; align-items: center; }
.topbar-actions form { margin: 0; }
.topbar-actions .theme { min-width: 7.5rem; }

.button {
  display: inline-block; padding: .4rem .8rem; border-radius: 6px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  font: inherit; text-decoration: none; cursor: pointer; white-space: nowrap;
}
.button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }

.layout { display: flex; align-items: flex-start; min-height: calc(100vh - 50px); }
.sidebar { flex: 0 0 200px; padding: 1rem; position: sticky; top: 0; }
.sidebar > summary { display: none; }
.sidebar nav { display: flex; flex-direction: column; gap: .15rem; }
.side-heading-row { display: flex; align-items: center; margin: 1rem 0 .25rem; padding: 0 .5rem; }
.side-heading { font-size: .75rem; text-transform: uppercase; color: var(--muted); }
.add-project { margin-left: auto; padding: .25rem .5rem; font-size: 1.1rem; line-height: 1; text-decoration: none; }
.help { font-size: .8rem; }
input[type="color"] { width: 4rem; height: 2.25rem; padding: .15rem; }
.side-link {
  display: flex; align-items: center; gap: .5rem; padding: .35rem .5rem;
  border-radius: 6px; color: var(--text); text-decoration: none;
}
.side-link:hover { background: var(--surface); }
.side-link.active { background: var(--surface); font-weight: 600; box-shadow: inset 3px 0 var(--accent); }
.side-link .count { margin-left: auto; }
.dot { width: .65rem; height: .65rem; border-radius: 50%; background: var(--project); border: 1px solid var(--border); flex: none; }
.count { color: var(--muted); font-size: .85rem; font-variant-numeric: tabular-nums; }

.board {
  flex: 1; min-width: 0; display: flex; gap: .75rem;
  padding: 1rem; overflow-x: auto; align-items: flex-start;
}
.column {
  flex: 1 0 200px; max-width: 340px; background: var(--surface);
  border: 1px solid var(--border); border-radius: 8px; padding: .6rem;
}
.column-head { display: flex; align-items: center; gap: .5rem; padding: 0 .2rem .5rem; }
.column-head .add { margin-left: auto; text-decoration: none; font-size: 1.2rem; line-height: 1; }
.cards { display: flex; flex-direction: column; gap: .5rem; min-height: 3rem; }
.more { width: 100%; margin-top: .5rem; }
.more { padding: .35rem; border: 1px dashed var(--border); border-radius: 6px; background: none; color: var(--muted); font: inherit; cursor: pointer; }

.card {
  background: var(--bg); border: 1px solid var(--border); border-left: 4px solid var(--project);
  border-radius: 6px; padding: .5rem .6rem; cursor: grab; user-select: none;
}
.card.sortable-ghost { opacity: .4; }
.card.sortable-chosen { box-shadow: 0 4px 12px rgb(0 0 0 / .15); }
.card-meta, .card-foot { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; font-size: .8rem; color: var(--muted); }
.card-foot:empty { display: none; }
.card-title { display: block; margin: .2rem 0; color: var(--text); text-decoration: none; font-weight: 500; overflow-wrap: anywhere; }
.card-title:hover { text-decoration: underline; }
.key { font-variant-numeric: tabular-nums; color: var(--muted); }
.type-icon { width: 1rem; height: 1rem; flex: none; }
.type-bug { color: var(--danger); }
.type-feature { color: var(--accent); }
.type-idea { color: var(--waiting); }
.priority { font-weight: 600; }
.priority-1 { color: var(--danger); }
.badge { padding: 0 .35rem; border-radius: 4px; font-size: .75rem; }
.badge.waiting { color: var(--waiting); background: var(--waiting-bg); }
.source { margin-left: auto; white-space: nowrap; }

.page { max-width: 800px; margin: 0 auto; padding: 1rem; }
.page.narrow { max-width: 480px; }
.item-head { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; border-left: 4px solid var(--project); padding-left: .75rem; }
.item-head h1 { flex-basis: 100%; margin: 0; }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: .2rem 1rem; color: var(--muted); font-size: .9rem; }
.facts dd { margin: 0; overflow-wrap: anywhere; }
.summary, .note, .edit { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: .75rem 1rem; margin: 1rem 0; overflow-wrap: anywhere; }
.edit > summary { cursor: pointer; font-weight: 600; }
.edit[open] > summary { margin-bottom: .75rem; }
.notes h2 { margin-top: 1.5rem; }
.note { margin: .5rem 0; }
.note header { font-size: .85rem; color: var(--muted); margin-bottom: .25rem; }
.note-claude { border-left: 3px solid var(--accent); }

.stack { display: flex; flex-direction: column; gap: .75rem; }
.stack > .button { align-self: flex-start; }
.row { display: flex; gap: .75rem; flex-wrap: wrap; }
.row > .field { flex: 1 1 140px; }
.field, .stack > label { display: flex; flex-direction: column; gap: .25rem; font-size: .9rem; }
.stack > .check { flex-direction: row; align-items: center; gap: .5rem; }
input, select, textarea {
  font: inherit; color: var(--text); background: var(--bg);
  border: 1px solid var(--border); border-radius: 6px; padding: .4rem .5rem; width: 100%;
}
input[type="checkbox"] { width: auto; }
.field.invalid input, .field.invalid select, .field.invalid textarea { border-color: var(--danger); }

@media (max-width: 767px) {
  .topbar { padding: .5rem .75rem; gap: .5rem; }
  .topbar-actions { gap: .35rem; }
  .topbar-actions .button { padding: .35rem .55rem; }
  .topbar-actions .theme { min-width: 0; }
  .layout { flex-direction: column; align-items: stretch; }
  .sidebar { position: static; flex: none; padding: .5rem 1rem 0; }
  .sidebar > summary { display: list-item; cursor: pointer; font-weight: 600; padding: .25rem 0; }
  .board { scroll-snap-type: x mandatory; padding: .75rem 1rem; }
  .column { flex: 0 0 85vw; max-width: none; scroll-snap-align: start; }
}
