/* ===========================================================================
   Tokens.
   ========================================================================== */

/*
 * Every theme is a complete set of the same names, so no component ever needs to
 * know which one is active. The choice is applied as `data-theme` on the root
 * element, and "system" is resolved to a concrete one before the first paint
 * rather than left to a media query — that way an explicitly chosen theme cannot
 * be overridden by the operating system, and each palette is written once.
 *
 * `data-tone` says light or dark for the handful of rules that need to know
 * without caring which palette it is.
 *
 * :root carries the default dark set, so a page that somehow renders before the
 * attribute is set is still legible rather than unstyled.
 */
:root,
[data-theme="dark"] {
  --bg: #0c0d11;
  --surface: #131519;
  --surface-2: #181b21;
  --surface-3: #1e222a;
  --border: #23262f;
  --border-strong: #2f3441;

  --text: #e8eaee;
  --text-muted: #8a909c;
  --text-subtle: #5f6673;

  --accent: #6470ff;
  --accent-hover: #7783ff;
  --accent-fg: #ffffff;
  --accent-soft: #6470ff26;

  --danger: #f2555a;
  --danger-soft: #f2555a1f;
  --success: #35c88a;
  --warning: #e2a03c;

  --type-story: #35c88a;
  --type-task: #5b9bff;
  --type-bug: #f2555a;
  --type-spike: #b078f0;
  --type-chore: #7b8394;

  --shadow-sm: 0 1px 2px rgb(0 0 0 / 35%);
  --shadow-md: 0 4px 16px rgb(0 0 0 / 40%);
  --shadow-lg: 0 16px 48px rgb(0 0 0 / 55%);

  color-scheme: dark;
}

[data-theme="light"] {
  --bg: #f7f8fa;
  --surface: #ffffff;
  --surface-2: #f1f2f5;
  --surface-3: #e8eaef;
  --border: #e3e5ea;
  --border-strong: #d0d4dc;

  --text: #16181d;
  --text-muted: #676d7a;
  --text-subtle: #949aa6;

  --accent: #4a53e0;
  --accent-hover: #3f47cc;
  --accent-fg: #ffffff;
  --accent-soft: #4a53e014;

  --danger: #d3323a;
  --danger-soft: #d3323a14;
  --success: #16a06a;
  --warning: #b57614;

  --type-story: #16a06a;
  --type-task: #2f6fdb;
  --type-bug: #d3323a;
  --type-spike: #8b4ed8;
  --type-chore: #6b7280;

  --shadow-sm: 0 1px 2px rgb(16 24 40 / 6%);
  --shadow-md: 0 4px 14px rgb(16 24 40 / 8%);
  --shadow-lg: 0 20px 50px rgb(16 24 40 / 16%);

  color-scheme: light;
}

/*
 * Raspberry — a magenta on a pale ice-blue canvas, white cards floating on it.
 * The red used for danger is pulled towards brick so it cannot be mistaken for
 * the accent, which is the one risk a pink accent brings.
 */
[data-theme="raspberry"] {
  --bg: #e0f2fe;
  --surface: #ffffff;
  --surface-2: #f2f9fe;
  --surface-3: #e6f2fb;
  --border: #c7e0f1;
  --border-strong: #a4cbe4;

  --text: #0f2b3d;
  --text-muted: #4a6c81;
  --text-subtle: #7b9aad;

  --accent: #c2185b;
  --accent-hover: #a31549;
  --accent-fg: #ffffff;
  --accent-soft: #c2185b1a;

  --danger: #b3261e;
  --danger-soft: #b3261e14;
  --success: #0f7b4f;
  --warning: #a65f00;

  --type-story: #0f7b4f;
  --type-task: #1d6fb8;
  --type-bug: #b3261e;
  --type-spike: #7b3fbf;
  --type-chore: #5c6b7a;

  --shadow-sm: 0 1px 2px rgb(12 44 66 / 8%);
  --shadow-md: 0 4px 14px rgb(12 44 66 / 10%);
  --shadow-lg: 0 20px 50px rgb(12 44 66 / 20%);

  color-scheme: light;
}

/*
 * Lime — charcoal with an acid highlight. The accent is bright enough that
 * white on it would be unreadable, so accent-fg goes dark; success moves to a
 * teal-green so it does not read as a dimmer version of the accent.
 */
[data-theme="lime"] {
  --bg: #15181c;
  --surface: #1f2329;
  --surface-2: #262b32;
  --surface-3: #2e343c;
  --border: #31373f;
  --border-strong: #434a54;

  --text: #e8edf2;
  --text-muted: #98a1ac;
  --text-subtle: #6c757f;

  --accent: #b6ff2e;
  --accent-hover: #c8ff5c;
  --accent-fg: #14180f;
  --accent-soft: #b6ff2e1f;

  --danger: #ff5c5c;
  --danger-soft: #ff5c5c1f;
  --success: #2ed3a7;
  --warning: #ffb020;

  --type-story: #2ed3a7;
  --type-task: #58a6ff;
  --type-bug: #ff5c5c;
  --type-spike: #c08bff;
  --type-chore: #8b949e;

  --shadow-sm: 0 1px 2px rgb(0 0 0 / 40%);
  --shadow-md: 0 4px 16px rgb(0 0 0 / 45%);
  --shadow-lg: 0 16px 48px rgb(0 0 0 / 60%);

  color-scheme: dark;
}

/*
 * Paper — warm off-white and ink, with a deep teal accent. Low blue light and
 * high text contrast, for reading a board all day.
 */
[data-theme="paper"] {
  --bg: #faf6ef;
  --surface: #fffdf9;
  --surface-2: #f3eee4;
  --surface-3: #eae3d6;
  --border: #e4dccd;
  --border-strong: #cdc2ad;

  --text: #2a2622;
  --text-muted: #6b6155;
  --text-subtle: #988c7c;

  --accent: #0f766e;
  --accent-hover: #0b5e58;
  --accent-fg: #ffffff;
  --accent-soft: #0f766e14;

  --danger: #b4342b;
  --danger-soft: #b4342b14;
  --success: #2f7d4f;
  --warning: #a96a0b;

  --type-story: #2f7d4f;
  --type-task: #2563a8;
  --type-bug: #b4342b;
  --type-spike: #7a4bae;
  --type-chore: #7a7267;

  --shadow-sm: 0 1px 2px rgb(60 48 30 / 8%);
  --shadow-md: 0 4px 14px rgb(60 48 30 / 10%);
  --shadow-lg: 0 20px 50px rgb(60 48 30 / 18%);

  color-scheme: light;
}

/* Midnight — navy rather than neutral black, with a soft cyan. */
[data-theme="midnight"] {
  --bg: #070d18;
  --surface: #0d1524;
  --surface-2: #131d30;
  --surface-3: #1a263d;
  --border: #1e2b42;
  --border-strong: #2c3c58;

  --text: #e6edf7;
  --text-muted: #8b9ab3;
  --text-subtle: #61708a;

  --accent: #38bdf8;
  --accent-hover: #5cccfb;
  --accent-fg: #04121c;
  --accent-soft: #38bdf81f;

  --danger: #f87171;
  --danger-soft: #f871711f;
  --success: #34d399;
  --warning: #fbbf24;

  --type-story: #34d399;
  --type-task: #60a5fa;
  --type-bug: #f87171;
  --type-spike: #a78bfa;
  --type-chore: #7c8aa1;

  --shadow-sm: 0 1px 2px rgb(0 0 0 / 45%);
  --shadow-md: 0 4px 16px rgb(2 6 16 / 55%);
  --shadow-lg: 0 16px 48px rgb(2 6 16 / 70%);

  color-scheme: dark;
}

/* ===========================================================================
   Type. Each grouping is a pairing rather than a single face: what the
   interface is set in, what a title is set in, and what a key or a code is set
   in. Only families already on the machine — a board should not wait on a font
   server to become readable.
   ========================================================================== */

:root,
[data-font="neutral"] {
  --font: ui-sans-serif, -apple-system, "Segoe UI", Inter, Roboto, sans-serif;
  --font-display: var(--font);
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  --display-weight: 600;
  --display-tracking: -0.01em;
}

/* A serif for the things you read, a sans for the things you operate. */
[data-font="editorial"] {
  --font: ui-sans-serif, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-display: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --mono: ui-monospace, Menlo, Consolas, monospace;
  --display-weight: 600;
  --display-tracking: 0;
}

/* Circular, drawn shapes — architectural, and a little cooler. */
[data-font="geometric"] {
  --font: "Avenir Next", Avenir, Futura, "Century Gothic", "Trebuchet MS", ui-sans-serif, sans-serif;
  --font-display: var(--font);
  --mono: "SF Mono", ui-monospace, Consolas, "Roboto Mono", monospace;
  --display-weight: 600;
  --display-tracking: 0;
}

/* Calligraphic stems and open counters — warmer, and easier at small sizes. */
[data-font="humanist"] {
  --font: Optima, Candara, "Gill Sans", "Gill Sans MT", "Segoe UI", ui-sans-serif, sans-serif;
  --font-display: var(--font);
  --mono: Consolas, Menlo, ui-monospace, monospace;
  --display-weight: 620;
  --display-tracking: 0.005em;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

/*
 * An author `display` rule outranks the user agent's `[hidden] { display: none }`,
 * so any element given a display value below would ignore the hidden attribute
 * and stay on screen. This keeps `hidden` authoritative everywhere.
 */
[hidden] {
  display: none !important;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 13.5px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--accent);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

.icon {
  width: 15px;
  height: 15px;
  flex: none;
}

.app {
  display: flex;
  flex-direction: column;
  /* `vh` first as the fallback, then the dynamic unit. On a phone `100vh` is the
     viewport with the browser's own chrome retracted, so the last stretch of the
     board sits underneath the URL bar until you scroll it away. */
  height: 100vh;
  height: 100dvh;
  min-height: 0;
}

/* ------------------------------------------------------------------ topbar */

.topbar {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 12px;
  height: 48px;
  flex: none;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

/*
 * The board controls give way; the actions do not. Without this the two groups
 * keep their full widths and simply overlap once the window is narrower than
 * their sum — the search box ends up printed underneath the stats readout.
 */
.topbar-group {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}
/* One height across the row: the mark, the board name, the filter, the
   selects and the buttons all line up rather than nearly lining up. */
.topbar .select {
  height: 28px;
}
.topbar-group:first-child {
  flex: 1 1 auto;
}
.topbar-group:last-child {
  flex: none;
}

/*
 * Wide: a plain strip of icon buttons, indistinguishable from having no
 * container at all. Narrow: the same nodes become the "More" dropdown — see the
 * small-screen block at the end of this file.
 */
.topbar-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}
/* The dropdown needs these; the strip is icons only. */
.btn-label {
  display: none;
}
#btn-more {
  display: none;
}

.brand {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: var(--accent-fg);
  margin-right: 2px;
  cursor: pointer;
  transition: background 0.12s ease;
}
.brand:hover { background: var(--accent-hover); }
.brand:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--accent-soft);
}

/* Reads as the board's name rather than as a control, until you go near it. */
.board-name {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 28px;
  max-width: 30vw;
  padding: 0 8px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: none;
  color: var(--text);
  font: inherit;
  font-size: 13px;
  font-weight: 560;
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease;
}
.board-name:hover { background: var(--surface-2); }
.board-name:focus-visible {
  outline: none;
  border-color: var(--accent);
}
#board-name-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.board-name .icon {
  width: 13px;
  height: 13px;
  color: var(--text-subtle);
}
.brand svg {
  width: 15px;
  height: 15px;
}

.divider {
  width: 1px;
  height: 18px;
  background: var(--border);
  margin: 0 4px;
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  padding-left: 2px;
  min-width: 0;
}

.who {
  color: var(--text-muted);
  font-size: 12.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 130px;
}

/* Progress readout in the topbar. */
.stats {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-muted);
  font-size: 12px;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.stats-bar {
  width: 54px;
  height: 4px;
  border-radius: 999px;
  background: var(--surface-3);
  overflow: hidden;
}
.stats-bar span {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: var(--success);
  transition: width 0.25s ease;
}

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

.select,
input,
textarea {
  font: inherit;
  font-size: 13px;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 5px 8px;
  transition: border-color 0.12s ease, background 0.12s ease;
}

.select {
  appearance: none;
  padding-right: 24px;
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%),
    linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: right 11px top 50%, right 7px top 50%;
  background-size: 4px 4px, 4px 4px;
  background-repeat: no-repeat;
  color: var(--text-muted);
  cursor: pointer;
  max-width: 190px;
}
.select:hover {
  background-color: var(--surface-3);
  color: var(--text);
}
.select-strong {
  color: var(--text);
  font-weight: 560;
}

input,
textarea {
  border-color: var(--border);
  background: var(--surface-2);
}
input:focus,
textarea:focus,
.select:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
input::placeholder,
textarea::placeholder {
  color: var(--text-subtle);
}
textarea {
  resize: vertical;
  line-height: 1.55;
}

/* ------------------------------------------------------------------ buttons */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font: inherit;
  font-size: 12.5px;
  font-weight: 520;
  height: 28px;
  padding: 0 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}
.btn:hover {
  background: var(--surface-3);
  border-color: var(--border-strong);
}
.btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-fg);
}
.btn-primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.btn-icon {
  width: 28px;
  padding: 0;
  background: transparent;
  border-color: transparent;
  color: var(--text-muted);
}
.btn-icon:hover {
  background: var(--surface-2);
  border-color: transparent;
  color: var(--text);
}

.btn-danger {
  background: transparent;
  border-color: transparent;
  color: var(--danger);
}
.btn-danger:hover {
  background: var(--danger-soft);
  border-color: transparent;
}

.btn-block {
  width: 100%;
  height: 34px;
}

.icon-btn {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  background: none;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 15px;
  cursor: pointer;
}
.icon-btn:hover {
  background: var(--surface-2);
  color: var(--text);
}

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

.board {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: stretch;
  gap: 10px;
  padding: 12px;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: thin;
}

/*
 * Columns share the width evenly and grow to fill it. `min-width` is the floor:
 * once the columns cannot shrink further the flex line overflows and the board
 * scrolls sideways, rather than squeezing them down to nothing.
 */
.column {
  display: flex;
  flex-direction: column;
  flex: 1 1 0;
  /* Low enough that five columns still fit a 1280px laptop without scrolling,
     high enough that a card title stays readable. */
  min-width: 240px;
  min-height: 0;
  max-height: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  transition: border-color 0.12s ease, background 0.12s ease;
}
.column.drag-over {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.column-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px 8px;
  flex: none;
}
.column-name {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.column-count {
  margin-left: auto;
  min-width: 20px;
  text-align: center;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-subtle);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}
.column-count.over-limit {
  background: var(--danger-soft);
  color: var(--danger);
  font-weight: 600;
}

/* Quiet until hovered or in use, so five of these across the board do not read
   as five buttons demanding attention. */
.column-menu-btn {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: none;
  color: var(--text-subtle);
  cursor: pointer;
  opacity: 0.55;
  transition: opacity 0.12s ease, color 0.12s ease, background 0.12s ease;
}
.column-menu-btn svg {
  width: 14px;
  height: 14px;
}
.column:hover .column-menu-btn,
.column-menu-btn:focus-visible {
  opacity: 1;
}
.column-menu-btn:hover {
  opacity: 1;
  color: var(--text);
  background: var(--surface-2);
}
.column-menu-btn:focus-visible {
  outline: none;
  border-color: var(--accent);
}
/* A column whose view has been changed says so even when nothing is hovered —
   otherwise a filtered column looks like an empty one. */
.column-menu-btn.is-active {
  opacity: 1;
  color: var(--accent);
  background: var(--accent-soft);
}

.column-menu {
  position: fixed;
  z-index: 40;
  width: 208px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
}
.column-menu label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--text-subtle);
}
.column-menu .select {
  width: 100%;
  height: 28px;
  text-transform: none;
  letter-spacing: 0;
  font-weight: 400;
  color: var(--text);
}
.column-menu p {
  margin: 0;
  line-height: 1.4;
}

.column-cards {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 0 8px 10px;
  overflow-y: auto;
  min-height: 48px;
  scrollbar-width: thin;
}

/* Groups bring their own spacing, so the list stops adding its own between them
   — the gap belongs under the header, with the cards it introduces. */
.column-cards.is-grouped {
  gap: 2px;
}

.day-group {
  display: flex;
  flex-direction: column;
}

.day-head {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  padding: 5px 6px;
  border: none;
  border-radius: var(--radius-sm);
  background: none;
  color: var(--text-muted);
  font: inherit;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-align: left;
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease;
}
.day-head:hover {
  background: var(--surface-2);
  color: var(--text);
}
.day-head:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px var(--accent-soft);
}

.day-chevron {
  flex: none;
  width: 12px;
  height: 12px;
  color: var(--text-subtle);
  transition: transform 0.14s ease;
}
.day-group.is-open .day-chevron {
  transform: rotate(90deg);
}

.day-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.day-count {
  margin-left: auto;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-subtle);
  font-size: 10px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}
.day-head:hover .day-count {
  background: var(--surface);
}

.day-cards {
  display: none;
  flex-direction: column;
  gap: 6px;
  padding: 2px 0 8px;
}
.day-group.is-open .day-cards {
  display: flex;
}

.column-empty {
  margin: 4px 0;
  padding: 14px 0;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  text-align: center;
  color: var(--text-subtle);
  font-size: 12px;
}

/* -------------------------------------------------------------------- card */

.card {
  background: var(--surface-2);
  border: 1px solid transparent;
  border-radius: var(--radius);
  padding: 9px 10px;
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease, transform 0.08s ease;
}
.card:hover {
  background: var(--surface-3);
  border-color: var(--border-strong);
}
.card:active {
  transform: scale(0.995);
}
.card.dragging {
  opacity: 0.4;
}

/*
 * A card that arrived since the last look — usually an agent's — announces
 * itself and then settles into the column like any other. Long enough to catch
 * the eye if you are looking elsewhere on the board, short enough not to linger.
 */
.card.is-new {
  animation: card-arrived 2.4s ease-out;
}
@keyframes card-arrived {
  0% {
    background: var(--accent-soft);
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
  }
  60% {
    background: var(--accent-soft);
    border-color: var(--accent);
    box-shadow: 0 0 0 0 transparent;
  }
  100% {
    background: var(--surface-2);
    border-color: transparent;
    box-shadow: 0 0 0 0 transparent;
  }
}
@media (prefers-reduced-motion: reduce) {
  .card.is-new {
    animation: none;
    border-color: var(--accent);
  }
}

.card-top {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 5px;
}

/* A small dot carries the card type — quieter than a coloured pill, and it
   keeps the row height uniform down a busy column. */
.type-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex: none;
  background: var(--type-task);
}
.type-story { background: var(--type-story); }
.type-task { background: var(--type-task); }
.type-bug { background: var(--type-bug); }
.type-spike { background: var(--type-spike); }
.type-chore { background: var(--type-chore); }

.card-key {
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.02em;
  color: var(--text-subtle);
}

.card-flag {
  margin-left: auto;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--text-subtle);
}
.card-flag.high { color: var(--warning); }
.card-flag.critical { color: var(--danger); }

/* The title is the one piece of a card you read rather than scan, so it takes
   the chosen grouping's display face. */
.card-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 450;
  line-height: 1.4;
  color: var(--text);
  overflow-wrap: anywhere;
}

.card-bottom {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 8px;
  min-height: 20px;
}

.label {
  padding: 1px 6px;
  border-radius: var(--radius-sm);
  background: var(--surface-3);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 10.5px;
  white-space: nowrap;
}

.points {
  padding: 1px 6px;
  border-radius: var(--radius-sm);
  background: var(--surface-3);
  color: var(--text-muted);
  font-size: 10.5px;
  font-variant-numeric: tabular-nums;
}

.avatar {
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-fg);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.02em;
  flex: none;
}
.card-bottom .avatar {
  margin-left: auto;
}
.avatar-sm {
  width: 20px;
  height: 20px;
  font-size: 8.5px;
}

/* ------------------------------------------------------------------ banner */

.banner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex: none;
  padding: 7px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 12.5px;
}
.banner .icon {
  color: var(--warning);
}

/* ------------------------------------------------------------------- login */

.login-view {
  display: grid;
  place-items: center;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 24px;
  background: var(--bg);
}

.login-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: min(352px, 100%);
  padding: 28px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
}

.login-mark {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: var(--radius);
  background: var(--accent);
  color: var(--accent-fg);
  margin-bottom: 2px;
}
.login-mark svg {
  width: 19px;
  height: 19px;
}

.login-card h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: var(--display-weight);
  letter-spacing: var(--display-tracking);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.field > span,
.login-card label > span {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
}
.login-card input {
  height: 34px;
}

.muted { color: var(--text-muted); margin: 0; }
.small { font-size: 12px; }
.center { text-align: center; }
.error {
  margin: 0;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 12.5px;
}

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

.dialog {
  width: min(660px, 94vw);
  max-height: 88vh;
  max-height: 88dvh;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}
/*
 * The card detail opens as a panel pinned to the right edge rather than a
 * centred box, so the board stays visible beside it while reading a card.
 */
.dialog-side {
  position: fixed;
  inset: 0 0 0 auto;
  width: min(460px, 100vw);
  max-width: 100vw;
  height: 100%;
  max-height: 100%;
  margin: 0;
  border: none;
  border-left: 1px solid var(--border);
  border-radius: 0;
  animation: slide-in 0.16s cubic-bezier(0.32, 0.72, 0, 1);
}
/* Element-qualified for the same reason as the backdrop above: `.dialog > form`
   caps at 88vh, and at equal specificity the later rule would win — leaving the
   full-height panel with dead space and a scrollbar it does not need. */
dialog.dialog-side > form,
dialog.dialog-side > .dialog-body {
  max-height: 100%;
}
/*
 * In a height-constrained column every child is shrinkable by default, which
 * flattens the description box and the comment list to nothing. Pinning them at
 * their natural height makes the panel scroll instead.
 */
.dialog > form > *,
.dialog > .dialog-body > * {
  flex: none;
}
/*
 * Lighter than a centred modal's — this is a preview, the board behind it is
 * still part of what you are looking at.
 *
 * Qualified with the element so it outranks `.dialog::backdrop` regardless of
 * source order; at equal specificity the later rule would win and reinstate the
 * blur this is meant to drop.
 */
dialog.dialog-side::backdrop {
  background: rgb(0 0 0 / 28%);
  backdrop-filter: none;
}

@keyframes slide-in {
  from { transform: translateX(100%); }
  to { transform: none; }
}
@media (prefers-reduced-motion: reduce) {
  .dialog-side { animation: none; }
}

.dialog::backdrop {
  background: rgb(0 0 0 / 55%);
  backdrop-filter: blur(2px);
}
.dialog > form,
.dialog > .dialog-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 0 20px 18px;
  max-height: 88vh;
  max-height: 88dvh;
  overflow-y: auto;
}

.dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px 14px 20px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--surface);
  z-index: 1;
}
.dialog-head h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: var(--display-weight);
  letter-spacing: var(--display-tracking);
}
.dialog > form > .dialog-head,
.dialog > .dialog-body > .dialog-head {
  margin: 0 -20px 4px;
}

.dialog-foot {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-top: 14px;
  margin-top: 2px;
  border-top: 1px solid var(--border);
}
/* The status sits between Delete and the buttons and gives up its width first,
   so a long error message can never push Close off the end of the row. */
.dialog-foot .save-status { flex: 0 1 auto; min-width: 0; }
.spacer { flex: 1 1 auto; }

.card-key-lg {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-muted);
}

.input-title {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: var(--display-weight);
  padding: 8px 10px;
}
.input-desc {
  font-size: 13px;
  padding: 8px 10px;
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(148px, 1fr));
  gap: 10px;
}
.field-grid label,
.dialog label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
}
.dialog label .select,
.dialog label input {
  /* background-color, not the shorthand — the shorthand would wipe the select's
     chevron, which is drawn with background-image. */
  background-color: var(--surface-2);
  border-color: var(--border);
  color: var(--text);
  max-width: none;
  height: 30px;
}

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

.launcher-search {
  display: flex;
  gap: 8px;
  align-items: center;
}
.launcher-search input {
  flex: 1;
  min-width: 0;
  height: 32px;
}
.launcher-search .btn { flex: none; height: 32px; }

.board-groups {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-top: 4px;
}
.board-group-title {
  margin: 0 0 6px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-subtle);
}

.board-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.board-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: none;
  color: var(--text);
  font: inherit;
  font-size: 13px;
  text-align: left;
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease;
}
.board-item:hover { background: var(--surface-2); }
.board-item:focus-visible {
  outline: none;
  border-color: var(--accent);
}
/* The one you are already looking at, so the list says where you are as well as
   where you could go. */
.board-item.is-current {
  background: var(--accent-soft);
  border-color: var(--accent);
}

.board-item-key {
  flex: none;
  min-width: 54px;
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--text-subtle);
}
.board-item-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.board-item-tag {
  flex: none;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-subtle);
  font-size: 10.5px;
}

/* A label that reads as a sentence, with its field sitting inside the line
   rather than stacked under it. */
.sentence {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  margin: 8px 0 4px;
  font-size: 13px;
  font-weight: 400;
  color: var(--text);
}
.sentence input {
  width: 68px;
  height: 30px;
  text-align: center;
}

/* ---------------------------------------------------------- autosave status */

.save-status {
  font-size: 12px;
  color: var(--text-subtle);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: color 0.12s ease;
}
.save-status.is-saving { color: var(--text-muted); }
.save-status.is-saved { color: var(--success); }
.save-status.is-error {
  color: var(--danger);
  /* The one state worth reading in full, so it may take the row's slack. */
  white-space: normal;
}

/* A heading for the description, now that it no longer sits directly under the
   title where its own placeholder was enough to identify it. */
.desc-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 2px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
}
.desc-head .btn {
  margin-left: auto;
  height: 24px;
  padding: 0 9px;
  font-size: 12px;
}

/*
 * Reading, not a control. It used to be a button so that clicking it started an
 * edit, which meant you could not select a line of it to copy — the commonest
 * thing anyone does with a description they did not write.
 */
#desc-view {
  min-height: 22px;
  cursor: text;
  user-select: text;
}
#desc-view .dim { color: var(--text-subtle); }

/* ---------------------------------------------------------------- comments */

.comments {
  border-top: 1px solid var(--border);
  padding-top: 14px;
}
.comments h3 {
  margin: 0 0 8px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.comment {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 9px 0;
  border-bottom: 1px solid var(--border);
}
.comment:last-child { border-bottom: none; }
/* The face keeps its size; the words take whatever is left, and wrap inside it
   rather than pushing the row wider. */
.comment > .avatar { margin-top: 1px; }
.comment-content { flex: 1; min-width: 0; }
.comment-head {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 11.5px;
  color: var(--text-subtle);
}
.comment-head strong {
  color: var(--text);
  font-weight: 550;
  font-size: 12px;
}
.comment-body {
  margin: 3px 0 0;
  white-space: pre-wrap;
  font-size: 13px;
  overflow-wrap: anywhere;
}
.comment-compose {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  margin-top: 10px;
}
.comment-compose textarea { flex: 1; }

/* ---------------------------------------------------------------- settings */

/*
 * Settings is the one dialog long enough to need sections, and stacked in one
 * scroll they read as a wall. Tabs put each group on its own page, which also
 * means the header and the tab strip stay put while the group scrolls under
 * them — so the panel is the scroller here, not the dialog body.
 */
#settings-dialog > .dialog-body {
  gap: 0;
  padding: 0;
  overflow: hidden;
}
#settings-dialog > .dialog-body > .dialog-head {
  position: static;
  margin: 0;
}

.tabs {
  display: flex;
  gap: 2px;
  flex: none;
  padding: 0 12px;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar {
  display: none;
}

.tab {
  position: relative;
  padding: 9px 10px;
  border: none;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  background: none;
  color: var(--text-muted);
  font: inherit;
  font-size: 12.5px;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  transition: color 0.12s ease, background 0.12s ease;
}
.tab:hover {
  color: var(--text);
  background: var(--surface-2);
}
.tab:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px var(--accent-soft);
}
.tab.is-active {
  color: var(--text);
  font-weight: 600;
}
/* Sits on the strip's own border, so the active tab reads as joined to its
   panel rather than as a button that happens to be darker. */
.tab.is-active::after {
  content: '';
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: -1px;
  height: 2px;
  border-radius: 2px;
  background: var(--accent);
}

/*
 * Carries the id so it outranks `.dialog > .dialog-body > *`, which pins every
 * child at its own height. The panel is the one part that has to give: without
 * this it keeps its full content height, overflows the dialog and is clipped —
 * visibly missing, with no scrollbar offering a way to the rest.
 */
#settings-dialog .tab-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex: 1 1 auto;
  min-height: 0;
  padding: 14px 20px 18px;
  overflow-y: auto;
}
#settings-dialog .tab-panel > * {
  flex: none;
}
/* An author `display` outranks the `[hidden]` default, so hiding is explicit. */
#settings-dialog .tab-panel[hidden] {
  display: none;
}

.settings-section {
  border-top: 1px solid var(--border);
  padding-top: 16px;
}
.settings-section:first-of-type {
  border-top: none;
  padding-top: 4px;
}
.settings-section h3 {
  margin: 0 0 4px;
  font-size: 13px;
  font-weight: 600;
}
/* A textarea with no label around it gets none of the column layout's width. */
.settings-section > textarea {
  width: 100%;
  margin: 8px 0;
  border-color: var(--border);
}
/* Scoped to beat `.dialog label`, which stacks its children in a column. */
.dialog label.sentence,
.dialog label.check,
.check {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  margin: 8px 0 4px;
  font-size: 13px;
  font-weight: 400;
  color: var(--text);
  cursor: pointer;
}
.check input {
  width: 15px;
  height: 15px;
  flex: none;
  margin: 0;
}
.check input { accent-color: var(--accent); }

code {
  font-family: var(--mono);
  font-size: 11.5px;
  padding: 1px 5px;
  border-radius: 4px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-muted);
}

.inline-form {
  display: flex;
  gap: 6px;
  margin: 10px 0;
  flex-wrap: wrap;
}
.inline-form input {
  flex: 1;
  min-width: 132px;
  height: 30px;
}
.inline-form .select { height: 30px; }

/* ----------------------------------------------------------------- sharing */

/* A picture fills the same circle the initials do, so nothing around it has to
   know which of the two it got. */
.avatar-photo {
  object-fit: cover;
  padding: 0;
  background: var(--surface-3);
}

/* Not people, and not pretending to be: an agent and the board itself get a
   mark rather than a face, so a photograph never signs something a human did
   not write. */
.avatar-agent,
.avatar-system {
  background: var(--surface-3);
  color: var(--text-muted);
}
.avatar-agent svg,
.avatar-system svg {
  width: 13px;
  height: 13px;
}

.member-list,
.invite-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin: 6px 0;
}
.member-row {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 6px 2px;
  border-bottom: 1px solid var(--border);
}
.member-row:last-child {
  border-bottom: none;
}
.member-who {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
  line-height: 1.3;
}
.member-who span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.member-row .select {
  height: 28px;
}
.member-row .btn,
.invite-row .btn {
  padding: 3px 9px;
  font-size: 12px;
}

.invite-row {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 6px 2px;
}
.invite-code {
  padding: 3px 8px;
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-family: var(--mono);
  font-size: 13px;
  letter-spacing: 0.06em;
  color: var(--text);
  cursor: pointer;
}
.invite-code:hover {
  border-color: var(--accent);
}
.invite-row .muted {
  flex: 1;
  min-width: 0;
}

.code-input {
  font-family: var(--mono);
  font-size: 16px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

/* ----------------------------------------------------------------- profile */

/*
 * A fixed palette rather than a free picker. The avatar is how you tell
 * assignees apart down a column, so the choices have to stay distinguishable
 * from each other and readable in both themes — which a colour wheel does not
 * guarantee. Each pairs a muted fill with a saturated text colour so the
 * initials stay legible.
 */
.avatar-slate  { background: #64748b2e; color: #94a3b8; }
.avatar-indigo { background: #6470ff2e; color: #8b95ff; }
.avatar-teal   { background: #14b8a62e; color: #2dd4bf; }
.avatar-amber  { background: #e2a03c2e; color: #e2a03c; }
.avatar-rose   { background: #f2555a2e; color: #fb7185; }
.avatar-violet { background: #b078f02e; color: #c4a0f5; }
.avatar-green  { background: #35c88a2e; color: #35c88a; }

/* Keyed off the tone rather than a named theme, so every light palette — the
   ones here now and any added later — gets the darker ink automatically. */
[data-tone="light"] .avatar-slate  { color: #475569; }
[data-tone="light"] .avatar-indigo { color: #4a53e0; }
[data-tone="light"] .avatar-teal   { color: #0d9488; }
[data-tone="light"] .avatar-amber  { color: #b57614; }
[data-tone="light"] .avatar-rose   { color: #d3323a; }
[data-tone="light"] .avatar-violet { color: #8b4ed8; }
[data-tone="light"] .avatar-green  { color: #16a06a; }

/* The chip is a button now, but should still read as an identity, not a control. */
.user-chip {
  border: 1px solid transparent;
  background: none;
  font: inherit;
  cursor: pointer;
  border-radius: var(--radius);
  padding: 2px 6px 2px 2px;
  transition: background 0.12s ease;
}
.user-chip:hover {
  background: var(--surface-2);
}
.user-chip:focus-visible {
  outline: none;
  border-color: var(--accent);
}

.avatar-lg {
  width: 46px;
  height: 46px;
  font-size: 16px;
  flex: none;
}

.profile-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-bottom: 4px;
}
.profile-identity {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.color-row {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}
.swatch {
  width: 26px;
  height: 26px;
  padding: 0;
  border: 2px solid transparent;
  border-radius: 50%;
  cursor: pointer;
  transition: transform 0.1s ease, border-color 0.12s ease;
}
.swatch:hover {
  transform: scale(1.12);
}
.swatch.is-chosen {
  border-color: var(--text);
}
.swatch:focus-visible {
  outline: none;
  border-color: var(--accent);
}
/* "No colour" — the default grey avatar, shown as an outline so it reads as an
   option rather than as an empty slot. */
.swatch-none {
  background: var(--surface-2);
  box-shadow: inset 0 0 0 1px var(--border-strong);
}

/* ----------------------------------------------------------------- archive */

/* Quieter than the due flag: leaving the board is scheduled housekeeping, not
   something anyone needs to act on. */
.archive-flag {
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--surface-3);
  color: var(--text-subtle);
  font-size: 11px;
  white-space: nowrap;
}

.card-dates {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin: 0;
  padding-top: 2px;
  color: var(--text-subtle);
  font-size: 11.5px;
}
.card-dates time {
  cursor: help;
}
.card-dates-archive {
  color: var(--text-muted);
}

.archive-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 60vh;
  overflow-y: auto;
  scrollbar-width: thin;
}
.archive-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 4px;
  border-bottom: 1px solid var(--border);
}
.archive-row:last-child {
  border-bottom: none;
}
.archive-title {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.archive-row .btn {
  padding: 3px 9px;
  font-size: 12px;
}

.inline-label {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--text-muted);
  font-size: 12.5px;
}
.inline-label input {
  width: 68px;
  height: 30px;
  padding: 0 9px;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 13px;
}

/* -------------------------------------------------------------- automation */

.trigger-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 4px 0 8px;
}
.trigger {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 9px 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.trigger-top {
  display: flex;
  gap: 6px;
  align-items: center;
}
.trigger-top .select {
  flex: 0 0 42%;
  height: 30px;
}
.trigger-label {
  flex: 1;
  min-width: 0;
}
.trigger input {
  height: 30px;
  padding: 0 9px;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  font-family: inherit;
}
.trigger input:focus-visible {
  outline: none;
  border-color: var(--accent);
}

/* Reuses the read-only banner's shape, boxed to sit inside a settings panel. */
.banner-inline {
  margin: 8px 0;
  padding: 8px 10px;
  justify-content: flex-start;
  border: 1px solid var(--warning);
  border-radius: var(--radius);
  background: none;
  color: var(--warning);
  font-size: 12.5px;
}

.token-reveal {
  margin: 0 0 10px;
  padding: 10px 12px;
  border-radius: var(--radius);
  background: var(--accent-soft);
  border: 1px solid var(--accent);
  font-family: var(--mono);
  font-size: 11.5px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-all;
  color: var(--text);
}

/* Five columns will not fit a phone. Scrolling the table sideways inside its own
   box is the one thing that does not push the whole dialog off screen. */
.table-wrap {
  overflow-x: auto;
  scrollbar-width: thin;
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}
.table th {
  text-align: left;
  padding: 0 6px 6px;
  border-bottom: 1px solid var(--border);
  color: var(--text-subtle);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}
.table td {
  padding: 8px 6px;
  border-bottom: 1px solid var(--border);
  color: var(--text-muted);
}
.table td:first-child { color: var(--text); }
.table tr:last-child td { border-bottom: none; }
.table .revoked td { color: var(--text-subtle); text-decoration: line-through; }
.table .mono { font-family: var(--mono); font-size: 11.5px; }

/* Reads as text until focused, so the table does not look like a form. */
.token-name-input {
  width: 100%;
  padding: 3px 6px;
  font-size: 12.5px;
  background: transparent;
  border-color: transparent;
}
.token-name-input:hover { border-color: var(--border); }
.token-name-input:focus { background: var(--surface-2); }

/* ---------------------------------------------------------------- markdown */

.markdown {
  font-size: 13px;
  line-height: 1.6;
  color: var(--text);
  overflow-wrap: anywhere;
}
.markdown > :first-child { margin-top: 0; }
.markdown > :last-child { margin-bottom: 0; }

.markdown p { margin: 0 0 8px; }
.markdown h3,
.markdown h4,
.markdown h5,
.markdown h6 {
  margin: 14px 0 6px;
  font-weight: 600;
  line-height: 1.3;
}
.markdown h3 { font-size: 14.5px; }
.markdown h4 { font-size: 13.5px; }
.markdown h5,
.markdown h6 { font-size: 13px; color: var(--text-muted); }

.markdown ul,
.markdown ol { margin: 0 0 8px; padding-left: 20px; }
.markdown li { margin: 2px 0; }
.markdown li.task { list-style: none; margin-left: -18px; display: flex; gap: 7px; align-items: baseline; }
.markdown li.task input { accent-color: var(--accent); margin: 0; }
.markdown li.task .done { color: var(--text-subtle); text-decoration: line-through; }

.markdown a { text-decoration: underline; text-underline-offset: 2px; }

/* A table is the one block wider than its container, and the card panel is
   narrow. It scrolls inside this rather than stretching the panel. */
.md-table-wrap {
  margin: 0 0 8px;
  overflow-x: auto;
  scrollbar-width: thin;
}
.md-table {
  border-collapse: collapse;
  font-size: 12.5px;
  /* Not 100%: a two-column table should not stretch across the panel, and a
     wide one should be allowed to overflow into the scroller. */
  min-width: min(100%, 220px);
}
.md-table th,
.md-table td {
  padding: 5px 10px;
  border: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}
.md-table th {
  background: var(--surface-2);
  font-weight: 600;
  white-space: nowrap;
}
.md-table tbody tr:nth-child(even) td { background: var(--surface-2); }
.md-table .ta-left { text-align: left; }
.md-table .ta-center { text-align: center; }
.md-table .ta-right { text-align: right; }
.md-table code { background: var(--surface-3); }

.markdown code {
  font-family: var(--mono);
  font-size: 11.5px;
  padding: 1px 5px;
  border-radius: 4px;
  background: var(--surface-3);
  border: 1px solid var(--border);
  color: var(--text);
}
.markdown pre {
  margin: 0 0 8px;
  padding: 10px 12px;
  border-radius: var(--radius);
  background: var(--surface-3);
  border: 1px solid var(--border);
  overflow-x: auto;
}
.markdown pre code {
  padding: 0;
  border: none;
  background: none;
  font-size: 11.5px;
  line-height: 1.55;
  white-space: pre;
}

.markdown blockquote {
  margin: 0 0 8px;
  padding: 2px 0 2px 11px;
  border-left: 2px solid var(--border-strong);
  color: var(--text-muted);
}

.markdown hr {
  margin: 12px 0;
  border: none;
  border-top: 1px solid var(--border);
}

.markdown table { border-collapse: collapse; font-size: 12.5px; }
.markdown .dim { color: var(--text-subtle); }

/* The description doubles as the click target that opens its editor. */
#desc-view {
  min-height: 62px;
  padding: 8px 10px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  cursor: text;
}
#desc-view:hover { border-color: var(--border); }
#desc-view:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

/* ------------------------------------------------------------ dependencies */

.dep-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 6px;
}

.dep {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  font-size: 12.5px;
  cursor: pointer;
}
.dep:hover { border-color: var(--border-strong); }
.dep .card-key { flex: none; }
.dep .dep-title {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text);
}
.dep .dep-state {
  flex: none;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
.dep.is-open .dep-state { color: var(--warning); }
.dep.is-done .dep-state { color: var(--success); }
.dep.is-missing { border-style: dashed; }
.dep.is-missing .dep-state { color: var(--danger); }

.dep-remove {
  flex: none;
  background: none;
  border: none;
  color: var(--text-subtle);
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  padding: 0 2px;
}
.dep-remove:hover { color: var(--danger); }

/* Due-date marker, in the same quiet register as the blocked one. */
.due-flag {
  padding: 0 5px;
  border-radius: 3px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.due-flag.is-soon {
  background: color-mix(in srgb, var(--warning) 15%, transparent);
  color: var(--warning);
}
.due-flag.is-overdue {
  background: color-mix(in srgb, var(--danger) 16%, transparent);
  color: var(--danger);
}
.card.is-overdue { border-color: color-mix(in srgb, var(--danger) 42%, transparent); }

/* Card-face marker: a card whose dependencies are not all done. */
.blocked-flag {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 0 5px;
  border-radius: 3px;
  background: color-mix(in srgb, var(--warning) 16%, transparent);
  color: var(--warning);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.02em;
}
.blocked-flag svg { width: 10px; height: 10px; }

.card.is-blocked { border-color: color-mix(in srgb, var(--warning) 40%, transparent); }

.dep-empty {
  color: var(--text-subtle);
  font-size: 12px;
  padding: 2px 0;
}

/* Search field in the topbar. */
.search {
  flex: 1 1 160px;
  /* A floor, not zero: as a flex item with nothing to stop it the search box
     shrinks away entirely on a tablet, leaving the one control that finds a
     card on a board too wide to scan as an invisible sliver. */
  min-width: 104px;
  max-width: 160px;
  /* The same height as the buttons it sits between. */
  height: 28px;
  font-size: 12.5px;
  background: var(--surface-2);
  border-color: transparent;
  transition: max-width 0.15s ease, border-color 0.12s ease;
}
.search:hover { border-color: var(--border); }
.search:focus { max-width: 230px; }

/* Where a dragged card would land. */
.drop-line {
  height: 2px;
  margin: 1px 2px;
  border-radius: 2px;
  background: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
  pointer-events: none;
}

/* --------------------------------------------------------------- theming */

.theme-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(132px, 1fr));
  gap: 8px;
  margin: 10px 0 4px;
}

.theme-swatch {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  font-size: 12px;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.12s ease, background 0.12s ease;
}
.theme-swatch:hover { border-color: var(--border-strong); }
.theme-swatch:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--accent-soft);
  border-color: var(--accent);
}
.theme-swatch.is-active {
  border-color: var(--accent);
  background: var(--accent-soft);
}

/*
 * The preview paints itself in the theme it is offering rather than in the one
 * currently applied — a swatch that showed the running theme's colours would be
 * telling you nothing. Its colours are set inline from the same table the
 * stylesheet is built from.
 */
.theme-preview {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  height: 46px;
  padding: 6px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  overflow: hidden;
}
.theme-preview i {
  display: block;
  flex: 1;
  border-radius: 2px;
}
.theme-preview i:nth-child(1) { height: 100%; }
.theme-preview i:nth-child(2) { height: 68%; }
.theme-preview i:nth-child(3) { height: 40%; }

.theme-name {
  display: flex;
  align-items: center;
  gap: 5px;
  font-weight: 550;
}
.theme-name .tick {
  margin-left: auto;
  color: var(--accent);
}

.custom-theme {
  margin-top: 10px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
}
.custom-theme input[type='color'] {
  width: 100%;
  height: 32px;
  padding: 2px;
  cursor: pointer;
}

.sentence input[type='range'] {
  width: 160px;
  height: auto;
  padding: 0;
  accent-color: var(--accent);
  cursor: pointer;
}

/* The setting drawn in the shapes it is describing — a number of pixels means
   nothing until you can see what it does to a card. */
.corner-preview {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
}
.corner-card {
  display: grid;
  place-items: center;
  width: 84px;
  height: 44px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface-2);
  font-size: 12px;
  color: var(--text-muted);
}
.corner-btn {
  display: grid;
  place-items: center;
  height: 28px;
  padding: 0 12px;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: var(--accent-fg);
  font-size: 12px;
}
.corner-chip {
  padding: 2px 9px;
  border-radius: var(--radius-lg);
  background: var(--surface-3);
  color: var(--text-subtle);
  font-size: 11px;
}

/* Set in the face it is describing, because a list of font names in one font
   tells you nothing about any of them. */
.font-sample {
  margin: 10px 0 0;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
}
.font-sample-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: var(--display-weight);
  letter-spacing: var(--display-tracking);
  color: var(--text);
}
.font-sample-body {
  margin: 4px 0 0;
  font-family: var(--font);
  font-size: 13px;
  color: var(--text-muted);
}
.font-sample-mono {
  margin: 8px 0 0;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-subtle);
}

/* ---------------------------------------------------------- column settings */

.column-admin {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 4px;
}
.column-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 0;
  border-bottom: 1px solid var(--border);
}
.column-row:last-child { border-bottom: none; }
.column-name-input {
  flex: 1;
  min-width: 0;
  height: 28px;
  font-size: 12.5px;
  background: transparent;
  border-color: transparent;
}
.column-name-input:hover { border-color: var(--border); }
.column-name-input:focus { background: var(--surface-2); }
.column-wip {
  width: 62px;
  height: 28px;
  font-size: 12.5px;
  text-align: center;
}
.column-done {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  color: var(--text-muted);
  white-space: nowrap;
  cursor: pointer;
}
.column-done input { accent-color: var(--accent); margin: 0; }
.column-row .btn:disabled { opacity: 0.35; cursor: default; }
.column-row .btn:disabled:hover { background: transparent; }

.sprint-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.sprint-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.sprint-row:last-child { border-bottom: none; }
.sprint-row .name { flex: 1; min-width: 0; }
.sprint-row .meta {
  color: var(--text-subtle);
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
}
.sprint-row .select { height: 26px; font-size: 12px; }

/* ---------------------------------------------------------------- activity */

.activity-list {
  display: flex;
  flex-direction: column;
}
.activity-row {
  display: flex;
  align-items: baseline;
  gap: 9px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 12.5px;
  color: var(--text-muted);
}
.activity-row:last-child { border-bottom: none; }
.activity-row time {
  flex: none;
  width: 62px;
  color: var(--text-subtle);
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
}
.activity-row .actor { color: var(--text); font-weight: 500; }
.activity-row .ref { font-family: var(--mono); font-size: 11.5px; color: var(--text-muted); }

.badge-agent {
  flex: none;
  padding: 0 5px;
  border-radius: 3px;
  background: var(--accent-soft);
  border: 1px solid var(--accent);
  color: var(--accent);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  line-height: 15px;
}

/* ------------------------------------------------------------------- misc */

/*
 * Shown as a popover, which puts it in the browser's top layer — the same layer
 * a modal dialog and its backdrop are painted in. Nothing in the ordinary
 * stacking order can rise above a modal however high its z-index, so a "Saved"
 * raised from inside a dialog used to appear behind the blur.
 *
 * That means undoing the popover defaults: the UA centres one with `inset: 0`
 * and `margin: auto`, and gives it a border and its own colours.
 */
.toast {
  position: fixed;
  inset: auto;
  left: 50%;
  bottom: 22px;
  margin: 0;
  transform: translateX(-50%);
  z-index: 200;
  align-items: center;
  gap: 8px;
  padding: 9px 14px;
  border-radius: var(--radius);
  background: var(--surface-3);
  border: 1px solid var(--border-strong);
  color: var(--text);
  font-size: 12.5px;
  box-shadow: var(--shadow-md);
  overflow: visible;
  /* Purely informational, and it sits where a dialog's buttons are. */
  pointer-events: none;
}
/*
 * Deliberately the only `display` this rule set declares. Leaving it off the
 * base rule lets the UA's `[popover]:not(:popover-open) { display: none }` do
 * the hiding — an author `display: flex` there would outrank it and pin the
 * toast to the screen permanently.
 */
.toast:popover-open {
  display: flex;
}
.toast.is-error {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
}

.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin: auto;
  padding: 40px;
  text-align: center;
  color: var(--text-muted);
}
.empty h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: var(--display-weight);
  color: var(--text);
}
.empty p { margin: 0; font-size: 13px; max-width: 320px; }

::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 999px;
  border: 2px solid transparent;
  background-clip: content-box;
}
::-webkit-scrollbar-thumb:hover { background: var(--text-subtle); background-clip: content-box; }

/* ===========================================================================
   Small screens and touch. Three separate questions, kept apart on purpose:
   how much room there is, whether the pointer is a fingertip, and whether the
   window is short. A touch laptop is wide but still needs targets you can hit;
   a narrow desktop window needs the layout but not the bigger controls.
   ========================================================================== */

/* ---- Tablet and narrow windows ---- */

@media (max-width: 900px) {
  .topbar { gap: 8px; padding: 0 8px; }
  .board { gap: 8px; padding: 8px; }
  /* Both are worth trading for the search box, which is the control you cannot
     do without once more than a couple of columns are off screen. */
  .stats { display: none; }
  .who { display: none; }

  /*
   * The secondary actions stop being a strip and become a dropdown. A portrait
   * tablet is under the same pressure as a phone here: five unlabelled icons
   * cost more width than the one button that holds them, and as labelled rows
   * they are both legible and big enough to hit.
   */
  #btn-more { display: inline-flex; }
  .topbar-actions {
    display: none;
    position: absolute;
    z-index: 30;
    top: calc(100% + 4px);
    right: 8px;
    left: auto;
    width: max-content;
    min-width: 184px;
    max-width: calc(100vw - 16px);
    flex-direction: column;
    align-items: stretch;
    gap: 2px;
    padding: 6px;
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
  }
  .topbar-actions.is-open { display: flex; }
  .topbar-actions .btn {
    width: auto;
    height: 40px;
    justify-content: flex-start;
    gap: 10px;
    padding: 0 10px;
    color: var(--text);
  }
  .topbar-actions .btn-label { display: inline; font-size: 13.5px; }
}

/* ---- Phones ---- */

@media (max-width: 640px) {
  .topbar {
    height: auto;
    min-height: 48px;
    padding: 7px 8px;
    flex-wrap: wrap;
  }
  .topbar-group:first-child { flex: 1 1 100%; }
  .topbar-group:last-child { flex: 1 1 100%; justify-content: flex-end; }
  .divider { display: none; }
  .search { flex: 1 1 auto; max-width: none; }
  .search:focus { max-width: none; }
  #board-select { flex: 0 1 auto; min-width: 0; }
  #sprint-filter { flex: 0 1 auto; min-width: 0; }

  /* One column at a time, with the next one showing enough to say it is there.
     Snapping stops a swipe leaving you between two of them. */
  .board {
    scroll-snap-type: x mandatory;
    padding: 8px;
  }
  .column {
    min-width: 84vw;
    scroll-snap-align: center;
  }
  /* Scrolling a column should not drag the board sideways underneath it. */
  .column-cards { overscroll-behavior: contain; }

  /*
   * Dialogs become bottom sheets: anchored to the edge your thumb is nearest,
   * full width, and never taller than the visible viewport.
   */
  .dialog {
    width: 100vw;
    max-width: 100vw;
    margin: auto auto 0;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    border-bottom: none;
    max-height: 92vh;
    max-height: 92dvh;
  }
  .dialog > form,
  .dialog > .dialog-body {
    padding: 0 14px 14px;
    max-height: 92vh;
    max-height: 92dvh;
  }
  .dialog > form > .dialog-head,
  .dialog > .dialog-body > .dialog-head {
    margin: 0 -14px 4px;
  }
  #settings-dialog .tab-panel { padding: 12px 14px 16px; }

  /*
   * The card panel takes the whole screen — it is a form to work in, not a
   * preview, once there is no board left beside it to preview against.
   *
   * Element-qualified for the same reason the base file does it: `.dialog-side`
   * ties with the `.dialog` rule above and would lose on source order, leaving
   * the panel a bottom sheet with the board's topbar showing above it.
   */
  dialog.dialog-side {
    width: 100vw;
    max-width: 100vw;
    height: 100vh;
    height: 100dvh;
    max-height: 100vh;
    max-height: 100dvh;
    margin: 0;
    border-radius: 0;
  }
  dialog.dialog-side > form,
  dialog.dialog-side > .dialog-body {
    max-height: 100%;
  }

  /* Save has to stay reachable without scrolling a long form to its end. */
  .dialog-foot {
    position: sticky;
    bottom: 0;
    padding: 12px 14px;
    margin: 2px -14px 0;
    background: var(--surface);
  }

  /* A sheet occupies the bottom of the screen, which is exactly where the toast
     was landing — on top of the thing it is reporting about. */
  .toast {
    top: 12px;
    bottom: auto;
    max-width: calc(100vw - 24px);
  }

  .column-menu { width: min(260px, calc(100vw - 16px)); }
  .login-card { padding: 22px; }
  .banner { padding: 7px 10px; text-align: center; }
}

/* ---- Touch ---- */

@media (pointer: coarse) {
  /*
   * iOS zooms the page in when you focus a control whose text is under 16px,
   * and never zooms back out. Every control on this board was 13px.
   */
  .select,
  input,
  textarea {
    font-size: 16px;
  }
  .search { font-size: 16px; }
  .dialog label .select,
  .dialog label input,
  .inline-form input,
  .inline-form .select { height: 38px; }

  .btn { height: 36px; padding: 0 12px; }
  .btn-icon { width: 36px; }
  .icon-btn { width: 36px; height: 36px; }
  /* Not a .btn — it is an avatar and a name — but it is still something you tap. */
  .user-chip { min-height: 36px; padding: 0 4px 0 2px; }
  .btn-block { height: 40px; }
  .tab { padding: 12px 12px; }

  /* Cards are the main target on the board, and a comfortable one to hit. */
  .card { padding: 11px 12px; }

  /*
   * There is no hover on a touch screen, so the rule that reveals this button
   * never fires — it would sit at 55% opacity forever, looking disabled.
   */
  .column-menu-btn {
    width: 30px;
    height: 30px;
    opacity: 1;
  }
  .column-menu-btn svg { width: 16px; height: 16px; }
  .day-head { padding: 9px 6px; }
}

/* ---- Short windows ---- */

/* A phone in landscape is wide enough for the board and much too short for a
   bottom sheet with a 92% cap, so dialogs get the whole height there. */
@media (max-height: 480px) {
  .dialog {
    max-height: 100vh;
    max-height: 100dvh;
    margin: 0 auto;
    border-radius: 0;
  }
  .dialog > form,
  .dialog > .dialog-body {
    max-height: 100vh;
    max-height: 100dvh;
  }
}
