/* ============================================================================================
   Themes. Every colour in this file comes from these variables; a theme only changes the values.
   <html data-theme="light|dark|midnight|auto"> is set from the user's Settings.
   ============================================================================================ */
:root, :root[data-theme="light"] {
  color-scheme: light;
  --page: #f4f3ef;
  --panel: #ffffff;
  --column: #e9e8e3;
  --ink: #1d232a;
  --muted: #5d636a;
  --note: #3d444b;
  --line: #dddbd4;
  --line-strong: #c6c3b9;
  --line-soft: #efeee9;
  --field: #fbfbf9;
  --dashed: #c9c6bd;
  --accent: #1f4e79;          /* links, headings */
  --accent-bg: #1f4e79;       /* header rule, selected tab */
  --accent-on: #ffffff;       /* text on --accent-bg */
  --pill-bg: #eef3f8;
  --hover-row: #faf9f6;
  --soft: #f4f3ef;
  --drop-bg: #e4ebf2;
  --drop-edge: #9db4cc;
  --due-bg: #fff7dc;
  --due-edge: #e6b52a;
  --due-ink: #6b5200;
  --due-row: #fffbea;
  --due-note: #8a6a00;
  --shadow: rgba(0, 0, 0, .08);
  --shadow-strong: rgba(0, 0, 0, .22);
  --backdrop: rgba(20, 24, 30, .45);
  --primary: #ffcc33;
  --primary-edge: #e6b52a;
  --primary-hover: #ffd54f;
  --primary-ink: #2a2200;
  --high: #d64545;
  --med: #e0a100;
  --low: #3f9a4f;
  --danger: #b42318;
  --radius: 10px;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #14171b;
  --panel: #1e2228;
  --column: #272c34;
  --ink: #e7e9ec;
  --muted: #9aa3ad;
  --note: #c3c9d0;
  --line: #363c46;
  --line-strong: #4a515c;
  --line-soft: #2b3038;
  --field: #171a1f;
  --dashed: #4a515c;
  --accent: #7fb2e5;
  --accent-bg: #2f6aa3;
  --accent-on: #ffffff;
  --pill-bg: #23344a;
  --hover-row: #242930;
  --soft: #262b33;
  --drop-bg: #233042;
  --drop-edge: #4d7bab;
  --due-bg: #3a2f10;
  --due-edge: #c99a1a;
  --due-ink: #f2d27a;
  --due-row: #2e2712;
  --due-note: #e0b84a;
  --shadow: rgba(0, 0, 0, .35);
  --shadow-strong: rgba(0, 0, 0, .55);
  --backdrop: rgba(0, 0, 0, .6);
  --high: #e05d5d;
  --med: #e3a82b;
  --low: #4fb062;
  --danger: #f07167;
}

@media (prefers-color-scheme: dark) {
  :root[data-theme="auto"] {
    color-scheme: dark;
    --page: #14171b;
    --panel: #1e2228;
    --column: #272c34;
    --ink: #e7e9ec;
    --muted: #9aa3ad;
    --note: #c3c9d0;
    --line: #363c46;
    --line-strong: #4a515c;
    --line-soft: #2b3038;
    --field: #171a1f;
    --dashed: #4a515c;
    --accent: #7fb2e5;
    --accent-bg: #2f6aa3;
    --accent-on: #ffffff;
    --pill-bg: #23344a;
    --hover-row: #242930;
    --soft: #262b33;
    --drop-bg: #233042;
    --drop-edge: #4d7bab;
    --due-bg: #3a2f10;
    --due-edge: #c99a1a;
    --due-ink: #f2d27a;
    --due-row: #2e2712;
    --due-note: #e0b84a;
    --shadow: rgba(0, 0, 0, .35);
    --shadow-strong: rgba(0, 0, 0, .55);
    --backdrop: rgba(0, 0, 0, .6);
    --high: #e05d5d;
    --med: #e3a82b;
    --low: #4fb062;
    --danger: #f07167;
  }
}

/* Midnight: the navy and orange of the IdeaLuma logo. */
:root[data-theme="midnight"] {
  color-scheme: dark;
  --page: #0a1830;
  --panel: #10234a;
  --column: #16305c;
  --ink: #eef2f9;
  --muted: #9fb1cc;
  --note: #c9d5e8;
  --line: #26447a;
  --line-strong: #3a5c96;
  --line-soft: #1a3260;
  --field: #0c1d3d;
  --dashed: #3a5c96;
  --accent: #ffb04a;
  --accent-bg: #ff9a1f;
  --accent-on: #1d1200;
  --pill-bg: #1f3a6b;
  --hover-row: #15305a;
  --soft: #16305c;
  --drop-bg: #1d3c70;
  --drop-edge: #ffb04a;
  --due-bg: #3d2c0a;
  --due-edge: #ffb04a;
  --due-ink: #ffd28a;
  --due-row: #2c2410;
  --due-note: #ffc061;
  --shadow: rgba(0, 0, 0, .4);
  --shadow-strong: rgba(0, 0, 0, .6);
  --backdrop: rgba(2, 8, 20, .65);
  --high: #ff6b6b;
  --med: #ffc233;
  --low: #5cc977;
  --danger: #ff8a7a;
}

/* ============================================================================================ */

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font: 14px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, Ubuntu, sans-serif;
}
[hidden] { display: none !important; }
a { color: var(--accent); }

/* Header: one slim bar, pinned to the top. Left: logo | team / board. Middle: search. Right: actions + avatar. */
.topbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; gap: 16px;
  min-height: 60px; padding: 8px 20px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 1px 3px var(--shadow);
}
.topbar-left { display: flex; align-items: center; gap: 14px; min-width: 0; }
.brand { display: flex; align-items: center; flex: none; }
.brand img { display: block; height: 34px; width: auto; }
.topbar-divider { width: 1px; height: 26px; background: var(--line); flex: none; }
.icon { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* Two copies of the logo: navy "Idea" for light themes, white "Idea" for dark ones. */
.logo-on-dark { display: none !important; }
:root[data-theme="dark"] .logo-on-light, :root[data-theme="midnight"] .logo-on-light { display: none !important; }
:root[data-theme="dark"] .logo-on-dark, :root[data-theme="midnight"] .logo-on-dark { display: block !important; }
@media (prefers-color-scheme: dark) {
  :root[data-theme="auto"] .logo-on-light { display: none !important; }
  :root[data-theme="auto"] .logo-on-dark { display: block !important; }
}
.search-box {
  flex: 1 1 260px; max-width: 440px; margin: 0 auto;
  display: flex; align-items: center; gap: 8px;
  padding: 0 10px; height: 38px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--field); color: var(--muted);
  transition: border-color .12s, box-shadow .12s, background-color .12s;
}
.search-box:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--pill-bg); background: var(--panel); }
.search-box input { flex: 1; min-width: 0; border: none; outline: none; background: transparent; font: inherit; color: var(--ink); }
.search-box input::-webkit-search-cancel-button { cursor: pointer; }
.key-hint {
  font: 11px/1 ui-monospace, monospace; color: var(--muted);
  border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 4px; padding: 2px 6px;
}
.search-box:focus-within .key-hint { display: none; }
.topbar-right { display: flex; align-items: center; gap: 8px; flex: none; }
.save-status { color: var(--muted); font-size: 12px; white-space: nowrap; margin-right: 4px; }

/* Ghost (icon) buttons and the yellow Add button */
.btn-ghost {
  display: inline-flex; align-items: center; gap: 6px;
  border-color: transparent; background: transparent; color: var(--muted); padding: 7px 10px;
}
.btn-ghost:hover:not(:disabled) { background: var(--hover-row); color: var(--ink); border-color: transparent; }
.btn-add { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 10px; box-shadow: 0 1px 2px var(--shadow); }
.btn-add .icon { stroke-width: 2.6; }

/* The avatar: your initials in a circle; opens a small account menu */
.avatar {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--accent-bg); color: var(--accent-on);
  font-weight: 700; font-size: 13px; letter-spacing: .02em; user-select: none;
}
.user-menu summary.avatar { list-style: none; cursor: pointer; border: 2px solid transparent; transition: box-shadow .12s; }
.user-menu summary.avatar::-webkit-details-marker { display: none; }
.user-menu summary.avatar:hover, .user-menu[open] summary.avatar { box-shadow: 0 0 0 3px var(--pill-bg); }
.user-menu summary.avatar:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.avatar-lg { width: 40px; height: 40px; font-size: 15px; flex: none; }
.board-menu .menu.menu-right { left: auto; right: 0; min-width: 240px; }
.user-card { display: flex; align-items: center; gap: 10px; padding: 8px 8px 10px; }
.user-text { min-width: 0; display: flex; flex-direction: column; }
.user-text strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-text span { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-menu .menu-actions { margin-top: 0; }

/* Buttons */
.btn {
  font: inherit; cursor: pointer;
  padding: 7px 12px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--panel); color: var(--ink);
}
.btn:hover:not(:disabled) { border-color: var(--line-strong); }
.btn:disabled { opacity: .5; cursor: default; }
.btn-primary { background: var(--primary); border-color: var(--primary-edge); color: var(--primary-ink); font-weight: 700; }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); border-color: var(--primary-edge); }
.btn-link { border: none; background: none; color: var(--accent); padding-left: 0; margin-right: auto; }
.btn-danger { border-color: transparent; background: none; color: var(--danger); margin-right: auto; padding-left: 0; }
.btn-danger.confirming { color: #fff; background: var(--danger); padding-left: 12px; }
.btn-small { padding: 3px 10px; font-size: 12px; }
.btn:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 1px;
}

/* Legend: a quiet row under the header. Hint on the left, priority chips on the right. */
.legend { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 14px 20px 0; color: var(--muted); font-size: 13px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; background: var(--panel); border: 1px solid var(--line); font-size: 12px; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; }
.dot-high { background: var(--high); } .dot-med { background: var(--med); } .dot-low { background: var(--low); }

main { padding: 12px 20px 32px; }

/* Stage icons */
.stage-icon { flex: none; vertical-align: -5px; }

/* Board */
.board {
  display: grid;
  grid-template-columns: repeat(4, minmax(200px, 1fr));
  gap: 12px;
  overflow-x: auto;
  padding-bottom: 4px;
}
.column { background: var(--column); border-radius: var(--radius); padding: 10px; min-height: 140px; transition: background-color .12s, box-shadow .12s; }
.column h2 { margin: 0 0 8px; font-size: 14px; display: flex; align-items: center; gap: 6px; }
.column h2 .stage-icon { margin-right: 2px; }
.column h2 .plain { color: var(--muted); font-weight: 400; }
.column h2 .count { margin-left: auto; color: var(--muted); font-weight: 600; }
.column .empty { color: var(--muted); text-align: center; padding: 18px 0; border: 1px dashed var(--dashed); border-radius: 8px; }
.see-all { display: block; margin-top: 6px; font-size: 12px; color: var(--accent); }

.card {
  background: var(--panel); border-radius: 8px; padding: 8px 10px; margin-bottom: 8px;
  box-shadow: 0 1px 2px var(--shadow);
  border-left: 5px solid var(--med);
  cursor: pointer; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
}
.card.p-high { border-left-color: var(--high); }
.card.p-low { border-left-color: var(--low); }
.card:hover { box-shadow: 0 2px 6px var(--shadow-strong); }
.card:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.card .title { font-weight: 700; overflow-wrap: anywhere; }
.card .note {
  color: var(--note); margin-top: 3px; white-space: pre-line; overflow-wrap: anywhere;
  display: -webkit-box; -webkit-line-clamp: 3; line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.card .foot { display: flex; align-items: center; gap: 6px; margin-top: 6px; font-size: 12px; color: var(--muted); }
.card .foot .date { margin-left: auto; white-space: nowrap; }
.pill { background: var(--pill-bg); color: var(--accent); border-radius: 999px; padding: 1px 8px; font-size: 12px; white-space: nowrap; }

/* Drag and drop: a full-strength copy follows the pointer, the card left behind is a faint dashed
   placeholder, and the target gets a soft edge. */
.drag-ghost {
  position: fixed; left: 0; top: 0; z-index: 1000; margin: 0;
  pointer-events: none; cursor: grabbing;
  box-shadow: 0 12px 28px var(--shadow-strong), 0 2px 6px var(--shadow);
}
body.dragging, body.dragging * { cursor: grabbing !important; }
.card.dragging-card { opacity: .3; box-shadow: none; outline: 2px dashed var(--dashed); outline-offset: -2px; }
.column.drop-over, .dimmed.drop-over .dimmed-toggle { background-color: var(--drop-bg); box-shadow: inset 0 0 0 2px var(--drop-edge); }

/* Dimmed line */
.dimmed { margin-top: 12px; }
.dimmed.is-empty { display: none; }
body.dragging .dimmed.is-empty { display: block; }
.dimmed-toggle {
  display: flex; align-items: center; gap: 4px;
  font: inherit; cursor: pointer; background: none; border: 1px dashed var(--dashed); border-radius: 8px;
  color: var(--muted); padding: 6px 12px; width: 100%; text-align: left;
  transition: background-color .12s, box-shadow .12s;
}
.dimmed.has-due .dimmed-toggle { border-style: solid; border-color: var(--due-edge); background: var(--due-bg); color: var(--due-ink); }
.dimmed-list { list-style: none; margin: 6px 0 0; padding: 0; }
.dimmed-list li { background: var(--panel); border-radius: 8px; padding: 6px 10px; margin-bottom: 4px; display: flex; align-items: center; gap: 10px; color: var(--muted); }
.dimmed-list li.due { background: var(--due-row); box-shadow: inset 3px 0 0 var(--due-edge); }
.dimmed-list li .title-link { cursor: pointer; color: var(--ink); background: none; border: none; padding: 0; font: inherit; font-weight: 700; text-align: left; }
.dimmed-list li .due-note { color: var(--due-note); font-size: 12px; white-space: nowrap; }
.dimmed-list li .date { margin-left: auto; white-space: nowrap; }

/* Record */
.panel { background: var(--panel); border-radius: var(--radius); padding: 14px 16px; margin-top: 20px; box-shadow: 0 1px 2px var(--shadow); }
.record-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.record h2 { margin: 0; font-size: 16px; color: var(--accent); }
.tabs { display: flex; margin-left: auto; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.tab { display: inline-flex; align-items: center; gap: 2px; font: inherit; cursor: pointer; border: none; background: var(--panel); color: var(--muted); padding: 5px 12px; }
.tab + .tab { border-left: 1px solid var(--line); }
.tab[aria-selected="true"] { background: var(--accent-bg); color: var(--accent-on); }
.tab .stage-icon { margin-right: 4px; }
.tab .n { opacity: .75; margin-left: 4px; }
.search-note { color: var(--muted); font-size: 13px; margin: 0 0 8px; }
.record table { width: 100%; border-collapse: collapse; }
.record th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; border-bottom: 1px solid var(--line); padding: 6px 8px; }
.record td { border-bottom: 1px solid var(--line-soft); padding: 7px 8px; vertical-align: top; }
.record tbody tr { cursor: pointer; }
.record tbody tr:hover td { background: var(--hover-row); }
.record tbody tr:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.record td.when { white-space: nowrap; color: var(--muted); }
.record td.actions { text-align: right; white-space: nowrap; }
.record td.reason { color: var(--note); }
.record td .note { color: var(--muted); font-size: 13px; white-space: pre-line; }
.record .empty { color: var(--muted); margin: 8px 0 0; }
.prio { border-radius: 999px; padding: 1px 8px; font-size: 12px; color: #fff; white-space: nowrap; }
.prio-high { background: var(--high); } .prio-med { background: var(--med); } .prio-low { background: var(--low); }

/* Dialogs */
/* Dialogs: the middle scrolls; the title stays pinned at the top and the buttons at the bottom,
   so Save is always visible however long the dialog gets. */
.dialog {
  border: 1px solid var(--line); border-radius: 16px; padding: 0 22px; width: min(540px, calc(100vw - 32px));
  max-height: min(88vh, 860px); overflow-y: auto; overscroll-behavior: contain;
  background: var(--panel); color: var(--ink);
  box-shadow: 0 24px 60px var(--shadow-strong), 0 2px 8px var(--shadow);
}
.dialog[open] { animation: dialog-in .16s ease-out; }
.dialog::backdrop { background: var(--backdrop); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); }
@keyframes dialog-in { from { opacity: 0; transform: translateY(8px) scale(.98); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .dialog[open] { animation: none; } }
.dialog h2 {
  position: sticky; top: 0; z-index: 2; margin: 0 -22px 12px; padding: 18px 56px 12px 22px;
  font-size: 18px; color: var(--accent); background: var(--panel);
}
.dialog > :last-child { margin-bottom: 0; }
.dialog > form > :last-child { margin-bottom: 0; }
.dialog-close {
  position: sticky; top: 14px; z-index: 3; float: right; margin: 14px -10px -44px 0;
  width: 32px; height: 32px; border: none; border-radius: 8px; background: transparent; color: var(--muted);
  font-size: 20px; line-height: 1; cursor: pointer;
}
.dialog-close:hover { background: var(--hover-row); color: var(--ink); }
.dialog-close:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.dialog label { display: block; font-weight: 600; font-size: 13px; margin-bottom: 10px; }
.dialog .opt { color: var(--muted); font-weight: 400; }
.dialog input, .dialog textarea, .dialog select {
  display: block; width: 100%; margin-top: 4px;
  font: inherit; font-weight: 400; padding: 7px 9px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--field); color: var(--ink);
}
/* Notes grow as you type (board.js autoGrow) up to max-height, then scroll; never wider than the dialog. */
.dialog textarea { resize: none; min-height: 64px; max-height: min(45vh, 360px); max-width: 100%; line-height: 1.4; }
.dialog .row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.dialog .row-auto { grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); }
.dialog .buttons {
  position: sticky; bottom: 0; z-index: 2; display: flex; justify-content: flex-end; gap: 8px;
  margin: 10px -22px 0; padding: 12px 22px 16px; background: var(--panel); border-top: 1px solid var(--line-soft);
}
.dialog-signin .buttons, .dialog-small .buttons { border-top: none; }
.form-error { color: var(--danger); min-height: 1.2em; margin: 0 0 6px; }
.meta { color: var(--muted); font-size: 12px; margin: 0 0 6px; }
.help { display: block; color: var(--muted); font-weight: 400; font-size: 12px; margin: 4px 0 0; }
.dialog > form > .help { margin: -4px 0 12px; font-size: 13px; }
.inline { display: flex; align-items: center; gap: 8px; margin-top: 4px; font-weight: 400; }
.dialog .inline input { width: 90px; margin-top: 0; }

/* Picker tiles: the stage picker in the card dialog and the theme picker in Settings.
   Real radio buttons underneath, so keyboard arrows and screen readers work as usual. */
.picker { border: 0; padding: 0; margin: 0 0 10px; min-width: 0; }
.picker legend { font-weight: 600; font-size: 13px; padding: 0; margin-bottom: 5px; }
.picker-options { display: grid; gap: 6px; }
.stage-picker .picker-options { grid-template-columns: repeat(6, 1fr); }
.theme-picker .picker-options { grid-template-columns: repeat(4, 1fr); }
.dialog label.pick { position: relative; margin: 0; font-weight: 400; cursor: pointer; }
.dialog label.pick input { position: absolute; opacity: 0; width: 1px; height: 1px; margin: 0; padding: 0; pointer-events: none; }
.tile {
  display: flex; flex-direction: column; align-items: center; gap: 3px; height: 100%;
  padding: 8px 4px 6px; border: 1px solid var(--line); border-radius: 10px; background: var(--field);
  text-align: center; transition: border-color .12s, background-color .12s, box-shadow .12s;
}
.tile .stage-icon { vertical-align: 0; }
.tile-name { font-weight: 700; font-size: 12px; color: var(--ink); line-height: 1.2; }
.tile-plain { font-size: 11px; color: var(--muted); line-height: 1.2; }
label.pick:hover .tile { border-color: var(--line-strong); }
label.pick input:checked + .tile { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); background: var(--pill-bg); }
label.pick input:focus-visible + .tile { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Stage setup in Settings: icon | name | plain word | hide */
.stage-rows { display: grid; grid-template-columns: 24px 1fr 1fr 40px; gap: 6px 8px; align-items: center; }
.stage-rows-head { font-size: 12px; color: var(--muted); font-weight: 600; }
.dialog .stage-rows input { margin-top: 0; padding: 5px 8px; }
.dialog .stage-rows input[type="checkbox"] { width: 18px; height: 18px; justify-self: center; accent-color: var(--accent-bg); }
.stage-setup .help { margin: 0 0 8px; }

/* Theme swatches: fixed colours, so each tile previews its theme whatever theme is active. */
.swatch { display: flex; width: 100%; height: 34px; border-radius: 6px; overflow: hidden; border: 1px solid var(--line); margin-bottom: 3px; }
.swatch span { flex: 1; }
.swatch-light span:nth-child(1) { background: #f4f3ef; } .swatch-light span:nth-child(2) { background: #ffffff; }
.swatch-light span:nth-child(3) { background: #1f4e79; } .swatch-light span:nth-child(4) { background: #ffcc33; }
.swatch-dark span:nth-child(1) { background: #14171b; } .swatch-dark span:nth-child(2) { background: #272c34; }
.swatch-dark span:nth-child(3) { background: #7fb2e5; } .swatch-dark span:nth-child(4) { background: #ffcc33; }
.swatch-midnight span:nth-child(1) { background: #0a1830; } .swatch-midnight span:nth-child(2) { background: #16305c; }
.swatch-midnight span:nth-child(3) { background: #ff9a1f; } .swatch-midnight span:nth-child(4) { background: #ffcc33; }
.swatch-auto { background: linear-gradient(135deg, #f4f3ef 0 50%, #14171b 50% 100%); }
.swatch-auto span { display: none; }

/* Sign-in */
.dialog-signin { width: min(380px, calc(100vw - 32px)); }
.signin-logo { display: block; width: 300px; max-width: 100%; height: auto; margin: 4px auto 18px; }

/* History in the edit dialog */
.history { margin: 0 0 8px; font-size: 12px; color: var(--muted); }
.history summary { cursor: pointer; }
.history ol { margin: 6px 0 0; padding-left: 18px; }
.history li { margin-bottom: 2px; }

/* Report dialog */
.dialog-report { width: min(680px, calc(100vw - 32px)); }
.report-controls { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.report-controls .tabs { margin-left: 0; }
.stepper { display: flex; gap: 6px; margin-left: auto; }
.stepper .btn { font-size: 16px; line-height: 1; padding: 4px 12px; }
.report-body { max-height: min(60vh, 520px); overflow-y: auto; padding-right: 4px; }
.report-summary { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 14px; padding: 0; list-style: none; }
.report-summary li { background: var(--soft); border-radius: 8px; padding: 6px 10px; font-size: 13px; }
.report-summary strong { font-size: 18px; display: block; color: var(--accent); }
.report-body h3 { display: flex; align-items: center; gap: 6px; font-size: 14px; margin: 14px 0 6px; color: var(--ink); }
.report-list { margin: 0; padding: 0; list-style: none; }
.report-list li { padding: 7px 0; border-bottom: 1px solid var(--line-soft); display: grid; grid-template-columns: 64px 1fr; gap: 8px; }
.report-list .when { color: var(--muted); font-size: 12px; padding-top: 2px; }
.report-list .who, .report-list .why { color: var(--muted); font-size: 12px; }
.report-list .note { color: var(--note); font-size: 13px; white-space: pre-line; }
.report-empty { color: var(--muted); margin: 4px 0 0; }
.copy-status { margin-right: auto; color: var(--low); font-size: 13px; align-self: center; }
.offscreen { position: fixed; left: -9999px; top: 0; width: 1px; height: 1px; opacity: 0; }

@media (max-width: 640px) {
  .topbar-right { margin-left: 0; }
  .hint { display: none; }
  .dialog .row { grid-template-columns: 1fr; gap: 0; }
  .stage-picker .picker-options { grid-template-columns: repeat(3, 1fr); }
  .theme-picker .picker-options { grid-template-columns: repeat(2, 1fr); }
  .record .optional { display: none; }
  .tabs { margin-left: 0; }
  .report-controls { flex-wrap: wrap; }
  .report-list li { grid-template-columns: 1fr; gap: 2px; }
}

/* Board switcher in the header */
.board-menu { position: relative; }
.board-menu summary {
  list-style: none; cursor: pointer; display: flex; align-items: center; gap: 6px;
  padding: 6px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--field);
  font-weight: 700; color: var(--ink); max-width: 260px;
}
.board-menu summary::-webkit-details-marker { display: none; }
.board-menu summary:hover { border-color: var(--line-strong); }
.board-menu summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.board-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.caret { color: var(--muted); font-size: 12px; }
/* Team / board breadcrumb: two small menus. The list scrolls; the actions stay pinned at the bottom. */
.crumbs { display: flex; align-items: center; gap: 6px; min-width: 0; }
.crumb-sep { color: var(--muted); }
#team-menu summary { font-weight: 500; color: var(--muted); max-width: 200px; background: transparent; border-color: transparent; }
#team-menu summary:hover { background: var(--hover-row); }
#board-menu summary { background: transparent; border-color: transparent; font-size: 15px; }
#board-menu summary:hover { background: var(--hover-row); }
.board-menu .menu {
  position: absolute; z-index: 50; top: calc(100% + 6px); left: 0; min-width: 240px; max-width: 320px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 6px;
  box-shadow: 0 10px 30px var(--shadow-strong); max-height: 70vh;
  display: flex; flex-direction: column;
}
.menu-scroll { overflow-y: auto; min-height: 0; flex: 1 1 auto; }
.menu-actions { flex: none; border-top: 1px solid var(--line); margin-top: 6px; padding-top: 6px; }
.menu-filter {
  flex: none; margin: 2px 2px 6px; padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px;
  font: inherit; background: var(--field); color: var(--ink);
}
.menu-label { font-size: 12px; color: var(--muted); padding: 4px 8px 6px; }
.menu-item {
  display: flex; align-items: center; gap: 8px; width: 100%; padding: 7px 8px; border-radius: 6px;
  font: inherit; color: var(--ink); text-decoration: none; background: none; border: none; text-align: left; cursor: pointer;
}
.menu-item:hover, .menu-item:focus-visible { background: var(--hover-row); outline: none; }
.menu-item.current { background: var(--pill-bg); font-weight: 700; }
.menu-text { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu-count { color: var(--muted); font-size: 12px; }
.menu-danger { color: var(--danger); }
.dialog-small { width: min(420px, calc(100vw - 32px)); }
.btn-danger-solid { background: var(--danger); border-color: var(--danger); color: #fff; font-weight: 700; }

/* Teams: menu tags, team dialog, sharing dialog, join page */
.menu-tag { font-size: 11px; color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: 0 6px; }
.dialog .radio-line { display: flex; align-items: center; gap: 8px; font-weight: 400; margin: 0 0 6px; cursor: pointer; }
.dialog .radio-line input, .dialog .check-list input { display: inline-block; width: auto; margin: 0; accent-color: var(--accent-bg); }
.team-head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.team-head h2 { margin-bottom: 4px; }
.usage { color: var(--muted); font-size: 13px; margin-left: auto; }
.usage.full { color: var(--due-note); font-weight: 600; }
.inline-form { display: flex; gap: 8px; margin: 0 0 10px; }
.dialog .inline-form input { margin-top: 0; }
.subhead { font-size: 14px; margin: 14px 0 6px; color: var(--ink); }
.people-list { list-style: none; margin: 0; padding: 0; }
.people-list li { display: flex; align-items: center; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--line-soft); }
.people-list .person { flex: 1; min-width: 0; }
.people-list .person strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.people-list .person span { color: var(--muted); font-size: 12px; }
.people-list .role { color: var(--muted); font-size: 12px; text-transform: capitalize; }
.dialog .people-list select { width: auto; margin-top: 0; padding: 4px 8px; font-size: 13px; }
.invite-row { display: flex; gap: 8px; margin: 6px 0; }
.dialog .invite-row input { margin-top: 0; font-family: ui-monospace, monospace; font-size: 12px; }
.invite-list li { font-size: 13px; color: var(--muted); }
.check-list li label { display: flex; align-items: center; gap: 10px; margin: 0; font-weight: 400; width: 100%; cursor: pointer; }
.check-list.disabled { opacity: .5; pointer-events: none; }
.invite-note { background: var(--pill-bg); border-radius: 8px; padding: 8px 10px; margin: 0 0 12px; font-size: 13px; }
.join-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.join-panel { max-width: 440px; width: 100%; margin: 0; padding: 20px 22px; }
.join-panel h2 { color: var(--accent); margin: 0 0 8px; font-size: 18px; }
.join-panel .buttons { display: flex; justify-content: flex-end; gap: 8px; margin-top: 12px; }
.join-panel a.btn { text-decoration: none; display: inline-block; }
.join-panel .form-error { color: var(--danger); min-height: 1.2em; }
@media (max-width: 640px) {
  #team-menu summary { max-width: 120px; }
  .board-menu summary { max-width: 160px; }
}
.archive-list .btn { flex: none; }
.btn-danger.btn-small { margin-right: 0; padding-left: 10px; }

/* Header on narrow screens: row 1 logo, menus, avatar; row 2 search and Add idea. Labels become icons. */
@media (max-width: 900px) {
  .btn-label { display: none; }
  .save-status { display: none; }
}
@media (max-width: 640px) {
  .topbar { flex-wrap: wrap; gap: 8px 10px; padding: 8px 12px; }
  .topbar-left { flex: 1 1 auto; gap: 8px; }
  .brand img { height: 28px; }
  .topbar-divider { display: none; }
  .topbar-right { order: 2; }
  .search-box { order: 3; flex: 1 1 100%; max-width: none; margin: 0; }
  .key-hint { display: none; }
  .btn-add span { display: none; }
  .btn-add { padding: 8px 10px; }
  .legend { padding: 10px 12px 0; }
  .legend .hint { display: none; }
  main { padding: 10px 12px 28px; }
}
.search-box input:focus-visible { outline: none; }   /* the whole box shows focus instead */

/* Reports menu: one ghost button opening Report / Export */
.reports-menu summary.btn { list-style: none; }
.reports-menu summary.btn::-webkit-details-marker { display: none; }
.reports-menu[open] summary.btn { background: var(--hover-row); color: var(--ink); }
.reports-menu .menu { min-width: 260px; }
.menu-actions-plain { border-top: none; margin-top: 0; padding-top: 0; }
.menu-item .menu-text small { display: block; color: var(--muted); font-size: 12px; font-weight: 400; }
.menu-item .icon { color: var(--muted); }
.menu-item:disabled { opacity: .55; cursor: default; }
.menu-item:disabled:hover { background: none; }

/* Phones: stage tabs above the board, one stage at a time. Desktop keeps the four columns. */
.stage-tabs { display: none; }
@media (max-width: 700px) {
  .stage-tabs {
    display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 6px;
    position: sticky; top: var(--header-h, 0px); z-index: 30;
    margin: 0 -20px 10px; padding: 8px 20px;      /* edge to edge (main has a 20 px gutter here) */
    background: var(--page); border-bottom: 1px solid var(--line);
  }
  .stage-tab {
    display: flex; flex-direction: column; align-items: center; gap: 3px;
    padding: 7px 2px 6px; border: 1px solid var(--line); border-radius: 12px;
    background: var(--panel); color: var(--muted); font: inherit; cursor: pointer;
    transition: border-color .12s, background-color .12s, box-shadow .12s, transform .12s;
    -webkit-tap-highlight-color: transparent;
  }
  .stage-tab .stage-icon { vertical-align: 0; }
  .stage-tab-label { display: flex; align-items: baseline; gap: 4px; font-size: 12px; line-height: 1.1; white-space: nowrap; }
  .stage-tab-count {
    min-width: 18px; padding: 0 5px; border-radius: 999px; background: var(--column);
    font-size: 11px; font-weight: 700; color: var(--ink); text-align: center;
  }
  .stage-tab.active { border-color: var(--accent); background: var(--pill-bg); color: var(--ink); box-shadow: inset 0 0 0 1px var(--accent); font-weight: 700; }
  .stage-tab.active .stage-tab-count { background: var(--accent-bg); color: var(--accent-on); }
  .stage-tab.drop-over { border-color: var(--drop-edge); background: var(--drop-bg); transform: scale(1.06); }
  .stage-tab.bump { animation: tab-bump .5s ease; }

  .board { display: block; overflow: visible; }
  .board .column { display: none; min-height: 50vh; }
  .board .column.active { display: block; }
  .board .column h2 { display: none; }            /* the active tab already names the stage */
  .board .column .empty { padding: 32px 0; }
}
@keyframes tab-bump { 0% { transform: scale(1); } 35% { transform: scale(1.12); } 100% { transform: scale(1); } }
@media (prefers-reduced-motion: reduce) { .stage-tab.bump { animation: none; } }
@media (max-width: 640px) {
  .stage-tabs { margin: 0 -12px 10px; padding: 8px 12px; }   /* main's gutter is 12 px on phones */
}

/* Sign-in: "Forgot password?" link and the confirmation note; reset page */
.link-button { background: none; border: none; padding: 0; margin: -4px 0 10px; font: inherit; font-size: 13px; color: var(--accent); cursor: pointer; }
.link-button:hover { text-decoration: underline; }
.form-note { background: var(--pill-bg); color: var(--ink); border-radius: 8px; padding: 8px 10px; font-size: 13px; margin: 0 0 10px; }
.reset-form label { display: block; font-weight: 600; font-size: 13px; margin-bottom: 10px; }
.reset-form .opt { color: var(--muted); font-weight: 400; }
.reset-form input {
  display: block; width: 100%; margin-top: 4px; font: inherit; font-weight: 400;
  padding: 7px 9px; border: 1px solid var(--line); border-radius: 8px; background: var(--field); color: var(--ink);
}
/* Dialogs whose first item isn't the title get top spacing of their own; the team dialog's title sits in a row. */
.dialog-signin, .dialog-report { padding-top: 18px; }
.dialog-signin h2, .dialog-report h2 { position: static; margin: 0 0 12px; padding: 0; }
.team-head { padding-top: 18px; }
.team-head h2 { position: static; margin: 0 0 4px; padding: 0 40px 0 0; }

/* Priority picker: three coloured buttons (real radio buttons underneath), matching the card edge colours. */
.priority-picker { margin-bottom: 10px; }
.priority-options { display: flex; gap: 6px; margin-top: 4px; }
.dialog label.prio-pick { position: relative; flex: 1; margin: 0; font-weight: 600; cursor: pointer; }
.dialog label.prio-pick input { position: absolute; opacity: 0; width: 1px; height: 1px; margin: 0; pointer-events: none; }
.prio-pick span {
  display: flex; align-items: center; justify-content: center; gap: 5px;
  padding: 7px 6px; border: 1px solid var(--line); border-radius: 10px; background: var(--field);
  font-size: 13px; color: var(--muted); transition: border-color .12s, background-color .12s, color .12s;
}
.prio-pick .icon { width: 16px; height: 16px; stroke-width: 2.4; }
.prio-pick-high .icon { color: var(--high); }
.prio-pick-med .icon { color: var(--med); }
.prio-pick-low .icon { color: var(--low); }
label.prio-pick:hover span { border-color: var(--line-strong); }
label.prio-pick input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.prio-pick-high input:checked + span { border-color: var(--high); box-shadow: inset 0 0 0 1px var(--high); color: var(--ink);
  background: color-mix(in srgb, var(--high) 12%, var(--field)); }
.prio-pick-med input:checked + span { border-color: var(--med); box-shadow: inset 0 0 0 1px var(--med); color: var(--ink);
  background: color-mix(in srgb, var(--med) 14%, var(--field)); }
.prio-pick-low input:checked + span { border-color: var(--low); box-shadow: inset 0 0 0 1px var(--low); color: var(--ink);
  background: color-mix(in srgb, var(--low) 12%, var(--field)); }

/* "+ Add idea" leads the board row on desktop (right above Spark); on phones it floats bottom-right. */
.legend .btn-add { margin-right: 4px; }
@media (max-width: 640px) {
  .legend .btn-add {
    position: fixed; right: 16px; bottom: calc(16px + env(safe-area-inset-bottom, 0px)); z-index: 45;
    width: 58px; height: 58px; padding: 0; border-radius: 50%; justify-content: center;
    box-shadow: 0 8px 20px var(--shadow-strong), 0 2px 6px var(--shadow);
  }
  .legend .btn-add .icon { width: 26px; height: 26px; }
  .legend .btn-add span { display: none; }
  main { padding-bottom: 96px; }        /* room so the floating button never covers the last card */
}
/* The avatar is a <summary> inside a .board-menu: undo the generic menu-button look so it's a solid badge. */
.board-menu.user-menu summary.avatar {
  width: 36px; height: 36px; padding: 0; max-width: none; gap: 0; justify-content: center;
  background: var(--accent-bg); color: var(--accent-on); border: 2px solid transparent; font-weight: 700;
}
.board-menu.user-menu summary.avatar:hover, .board-menu.user-menu[open] summary.avatar { box-shadow: 0 0 0 3px var(--pill-bg); }

/* Priority buttons use the same coloured circles as the legend chips. */
.prio-pick .dot { width: 10px; height: 10px; flex: none; }

/* Menu icons: a small line icon at the start of every menu item, muted until hovered. */
.menu-item > .icon { width: 17px; height: 17px; color: var(--muted); flex: none; }
.menu-item:hover > .icon, .menu-item.current > .icon { color: var(--accent); }
.menu-item.menu-danger > .icon { color: var(--danger); }
/* Clicking a menu button must not select (highlight) its text. */
.board-menu summary, .menu-item { user-select: none; -webkit-user-select: none; }

/* Small initials badges (cards, record, picker, filter) */
.avatar-xs { width: 22px; height: 22px; font-size: 10px; flex: none; letter-spacing: 0; }
.avatar-empty { background: var(--column); color: var(--muted); }
.card .foot .avatar-xs { margin-left: 4px; }
.card .foot .from { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.assignee-cell { white-space: nowrap; }
.assignee-cell .avatar-xs { margin-right: 6px; vertical-align: middle; }

/* "Assigned to" picker in the card dialog: Unassigned + one badge per person */
.assignee-picker { margin-bottom: 10px; }
.assignee-options { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.dialog label.assignee-pick { position: relative; margin: 0; font-weight: 400; cursor: pointer; }
.dialog label.assignee-pick input { position: absolute; opacity: 0; width: 1px; height: 1px; margin: 0; pointer-events: none; }
.assignee-tile {
  display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px 5px 5px;
  border: 1px solid var(--line); border-radius: 999px; background: var(--field); font-size: 13px; color: var(--ink);
  transition: border-color .12s, background-color .12s, box-shadow .12s;
}
label.assignee-pick:hover .assignee-tile { border-color: var(--line-strong); }
label.assignee-pick input:checked + .assignee-tile { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); background: var(--pill-bg); font-weight: 600; }
label.assignee-pick input:focus-visible + .assignee-tile { outline: 2px solid var(--accent); outline-offset: 2px; }
.assignee-name { max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Person filter above the board: Everyone / My cards / each person */
.person-filter { display: flex; gap: 4px; margin-left: auto; overflow-x: auto; max-width: 100%; }
.person-chip {
  display: inline-flex; align-items: center; gap: 5px; flex: none; padding: 3px 10px 3px 4px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--panel); color: var(--muted); font: inherit; font-size: 12px; cursor: pointer;
}
.person-chip:first-child { padding-left: 10px; }
.person-chip:hover { border-color: var(--line-strong); color: var(--ink); }
.person-chip[aria-pressed="true"] { background: var(--accent-bg); border-color: var(--accent-bg); color: var(--accent-on); font-weight: 600; }
.person-chip .avatar-xs { width: 18px; height: 18px; font-size: 9px; }
.person-chip[aria-pressed="true"] .avatar-xs { box-shadow: 0 0 0 1px var(--accent-on); }
.person-select { font: inherit; font-size: 12px; padding: 4px 8px; border: 1px solid var(--line); border-radius: 999px; background: var(--panel); color: var(--ink); }
@media (max-width: 640px) {
  .person-filter { order: 3; flex: 1 1 100%; margin-left: 0; }
}

/* Person filter: the "Person ▾" menu for bigger teams */
.person-menu { flex: none; }
.person-menu summary.person-chip { list-style: none; padding-left: 10px; }
.person-menu summary.person-chip::-webkit-details-marker { display: none; }
.person-menu summary.person-chip .avatar-xs { margin-left: -6px; }
.person-menu summary .caret { font-size: 10px; margin-left: 2px; }
.person-menu .menu { min-width: 220px; }
.person-menu .menu-item .avatar-xs { width: 22px; height: 22px; font-size: 10px; }
.person-filter { overflow: visible; }      /* let the menu drop down outside the row */
@media (max-width: 640px) { .person-filter { flex-wrap: wrap; overflow: visible; } .person-menu .menu { right: auto; left: 0; } }

/* Priority key: a quiet "Priority ● ● ●" (hover for the names); the colours also sit on every card's edge. */
.prio-key { position: relative; display: inline-flex; margin-left: auto; }
.prio-key-btn {
  display: inline-flex; align-items: center; gap: 5px; padding: 3px 8px; border: 1px solid transparent; border-radius: 999px;
  background: none; color: var(--muted); font: inherit; font-size: 12px; cursor: pointer;
}
.prio-key-btn:hover, .prio-key-btn[aria-expanded="true"] { background: var(--panel); border-color: var(--line); color: var(--ink); }
.prio-key-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
/* The pop-up: opens on hover (mouse) or click/tap/keyboard (aria-expanded), closes on leave or Esc. */
.prio-pop {
  position: absolute; z-index: 35; top: calc(100% + 8px); right: 0; width: 220px;
  display: flex; flex-direction: column; gap: 8px; padding: 12px 14px;
  background: var(--panel); color: var(--ink); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: 0 10px 30px var(--shadow-strong); font-size: 13px;
  opacity: 0; visibility: hidden; transform: translateY(-4px); transition: opacity .12s, transform .12s, visibility .12s;
}
.prio-key:hover .prio-pop, .prio-key-btn[aria-expanded="true"] + .prio-pop { opacity: 1; visibility: visible; transform: none; }
.prio-pop-title { color: var(--accent); font-size: 13px; }
.prio-pop-row { display: grid; grid-template-columns: 6px 1fr; align-items: center; gap: 10px; }
.prio-pop-row b { font-weight: 600; }
.prio-pop-edge { width: 6px; height: 22px; border-radius: 3px; }
.prio-pop-edge.prio-high { background: var(--high); } .prio-pop-edge.prio-med { background: var(--med); } .prio-pop-edge.prio-low { background: var(--low); }
.prio-pop-foot { color: var(--muted); font-size: 12px; border-top: 1px solid var(--line-soft); padding-top: 8px; }
.prio-key .dot { width: 8px; height: 8px; }
@media (max-width: 640px) { .prio-key { display: none; } }

/* The priority key always sits at the right edge; when the person filter is showing, the filter takes the
   right-hand position and the key follows it with a small gap. */
.legend .prio-key { margin-left: auto; }
.legend .person-filter:not([hidden]) + .prio-key { margin-left: 10px; }
