/* Board dashboard — mobile-first, system fonts, light/dark via prefers-color-scheme */
:root {
  color-scheme: light dark;
  --bg: #f6f8fa;
  --panel: #ffffff;
  --panel-2: #eef1f5;
  --fg: #111418;
  --muted: #59636e;
  --line: #d0d7de;
  --accent: #1f6feb;
  --accent-fg: #ffffff;
  --ok: #1a7f37;
  --warn: #9a6700;
  --danger: #cf222e;
  --ping: #fff3c2;
  --ping-line: #d4a72c;
  --radius: 10px;
  --tap: 44px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d1117;
    --panel: #161b22;
    --panel-2: #21262d;
    --fg: #e6edf3;
    --muted: #9198a1;
    --line: #30363d;
    --accent: #4493f8;
    --accent-fg: #0d1117;
    --ok: #3fb950;
    --warn: #d29922;
    --danger: #f85149;
    --ping: #3a2e0a;
    --ping-line: #9e6a03;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font: 15px/1.4 var(--font);
  background: var(--bg);
  color: var(--fg);
  -webkit-text-size-adjust: 100%;
}
#app, .app { height: 100%; }
.app { display: flex; flex-direction: column; min-height: 100dvh; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }

/* ---------- controls ---------- */
.btn {
  min-height: var(--tap);
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--fg);
  cursor: pointer;
  touch-action: manipulation;
}
.btn:disabled { opacity: .5; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); font-weight: 600; }
.btn.warn { color: var(--warn); }
.btn.sm { min-height: 36px; padding: 0 10px; font-size: 13px; }
.btn.link { border: 0; background: none; color: var(--accent); padding: 0 6px; }
.field, select.field, textarea.field {
  min-height: var(--tap);
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
}
textarea.field { resize: vertical; min-height: 56px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row > .grow { flex: 1 1 120px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.err { color: var(--danger); margin: 8px 0 0; }

/* ---------- sign in ---------- */
.signin { margin: auto; width: min(420px, 100% - 32px); padding: 24px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; }
.signin h1 { margin: 0 0 12px; font-size: 22px; }
.signin form { display: grid; gap: 10px; }

/* ---------- header ---------- */
.hdr {
  position: sticky; top: 0; z-index: 5;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  padding: 8px 12px 0;
  padding-top: max(8px, env(safe-area-inset-top));
}
.hdr .top { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.brand { font-weight: 700; font-size: 17px; letter-spacing: .2px; }
.hdr select { max-width: 200px; flex: 1 1 120px; }
.who { margin-left: auto; font-size: 13px; color: var(--muted); white-space: nowrap; }
.who b { color: var(--fg); }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); opacity: .6; display: inline-block; flex: none; }
.dot.on { background: var(--ok); opacity: 1; box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 25%, transparent); }
.holders { font-size: 12px; color: var(--muted); padding: 6px 0 2px; overflow-x: auto; white-space: nowrap; }
.holders b { color: var(--fg); font-weight: 600; }
.nav { display: flex; gap: 4px; margin-top: 4px; }
.nav button { flex: 1; min-height: var(--tap); border: 0; background: none; color: var(--muted); border-bottom: 3px solid transparent; font-weight: 600; cursor: pointer; }
.nav button.active { color: var(--fg); border-bottom-color: var(--accent); }

/* ---------- main ---------- */
.main { flex: 1; min-height: 0; overflow: auto; padding: 12px; padding-bottom: max(12px, env(safe-area-inset-bottom)); }
.main.thread-mode { overflow: hidden; padding: 0; display: flex; flex-direction: column; }
.empty { color: var(--muted); text-align: center; padding: 32px 12px; }

/* ---------- board ---------- */
.tabs { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 8px; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs button { flex: none; min-height: 40px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--panel); color: var(--muted); cursor: pointer; }
.tabs button.active { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); font-weight: 600; }
.tabs .n { opacity: .8; margin-left: 4px; font-variant-numeric: tabular-nums; }
.columns { display: block; }
.col { display: none; }
.col.active { display: block; }
.col h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); margin: 4px 0 8px; }
.col h2 .n { font-weight: 400; margin-left: 6px; }
.cards { display: grid; gap: 8px; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; }
.card.blocked { border-left: 4px solid var(--danger); }
.card.done { opacity: .75; }
.card .title { font-weight: 600; margin: 0 0 4px; overflow-wrap: anywhere; }
.card .meta { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; font-size: 12px; color: var(--muted); }
.card .note { margin: 6px 0 0; font-size: 13px; color: var(--fg); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card .reason { margin: 6px 0 0; font-size: 13px; color: var(--danger); }
.card .actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.pri { font-size: 11px; font-weight: 700; text-transform: uppercase; padding: 1px 6px; border-radius: 4px; border: 1px solid var(--line); }
.pri.high { color: var(--danger); border-color: var(--danger); }
.pri.normal { color: var(--muted); }
.pri.low { color: var(--muted); opacity: .7; }

/* key + importance/urgency badges, timestamps grid, description */
.head { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin-bottom: 4px; }
.key { font: 600 12px/1 var(--mono); color: var(--muted); letter-spacing: .2px; }
/* level 1–5 only changes the tint strength; text stays --fg on a panel-based mix, readable in both themes */
.iu { font: 700 11px/1 var(--mono); padding: 3px 5px; border-radius: 4px; border: 1px solid var(--line); color: var(--fg); background: color-mix(in srgb, var(--tint) var(--mix, 32%), var(--panel-2)); }
.iu.i { --tint: var(--accent); }
.iu.u { --tint: var(--warn); }
.iu.c { --tint: var(--danger); }
.iu.l1 { --mix: 8%; } .iu.l2 { --mix: 20%; } .iu.l3 { --mix: 32%; } .iu.l4 { --mix: 46%; } .iu.l5 { --mix: 60%; }
.times { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 2px 10px; margin-top: 6px; font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.times span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.desc { margin: 0 0 4px; padding-left: 16px; font-size: 13px; color: var(--muted); overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.desc li { margin: 0; }
.desc.full { display: block; -webkit-line-clamp: unset; color: var(--fg); }

/* ---------- topics ---------- */
.topics { display: grid; gap: 8px; }
.topic { display: flex; align-items: center; gap: 10px; min-height: 56px; width: 100%; text-align: left; padding: 10px 12px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); cursor: pointer; }
.topic:disabled { opacity: .55; cursor: default; }
.topic .t { flex: 1; min-width: 0; }
.topic .t b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topic .t span { font-size: 12px; color: var(--muted); }
.topic .count { font-variant-numeric: tabular-nums; font-size: 13px; color: var(--muted); }

.topic.task { margin-left: 16px; width: calc(100% - 16px); min-height: 44px; padding: 6px 12px; }
.topic.task .t b { font-weight: 500; }

/* ---------- thread ---------- */
.thread { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.thread-bar { display: flex; gap: 8px; align-items: center; padding: 6px 8px; border-bottom: 1px solid var(--line); background: var(--panel); }
.thread-bar h2 { font-size: 15px; margin: 0; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.messages { flex: 1; min-height: 0; overflow-y: auto; padding: 12px; display: grid; gap: 8px; align-content: start; }
.msg { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 12px; }
.msg .from { font-size: 12px; color: var(--muted); display: flex; gap: 8px; }
.msg .from b { color: var(--fg); }
.msg .body { white-space: pre-wrap; overflow-wrap: anywhere; margin-top: 2px; }
.msg.system { background: none; border: 0; padding: 2px 12px; font-size: 12px; color: var(--muted); text-align: center; }
.msg.system .body { margin: 0; display: inline; }
.msg.ping { background: var(--ping); border-color: var(--ping-line); }
.msg.mine { border-color: var(--accent); }
.thread-forms { flex: none; border-top: 1px solid var(--line); background: var(--panel); padding: 8px 12px; padding-bottom: max(8px, env(safe-area-inset-bottom)); display: grid; gap: 6px; }
.compose { display: flex; gap: 8px; align-items: flex-end; }
.compose textarea { flex: 1; }
.task-head { flex: none; padding: 8px 12px; border-bottom: 1px solid var(--line); background: var(--panel); font-size: 13px; }
.task-head .head { margin-bottom: 2px; }
.task-head .st { font-weight: 600; }
.task-head .label { margin: 0 0 4px; font: 12px/1.3 var(--mono); color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.iu-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: 6px; }
.scale { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.scale .field { flex: none; width: auto; min-width: 64px; min-height: 36px; padding: 4px 8px; }
.hint { flex-basis: 100%; font-size: 12px; color: var(--muted); }
details form .field.wide { flex-basis: 100%; }
details summary { cursor: pointer; min-height: 32px; display: flex; align-items: center; font-size: 13px; color: var(--accent); font-weight: 600; }
details form { display: flex; gap: 8px; flex-wrap: wrap; padding: 4px 0 8px; }
details form .field { flex: 1 1 140px; width: auto; }

/* ---------- toasts ---------- */
.toasts { position: fixed; left: 12px; right: 12px; bottom: max(12px, env(safe-area-inset-bottom)); display: grid; gap: 6px; z-index: 20; pointer-events: none; }
.toast { background: var(--fg); color: var(--bg); padding: 10px 14px; border-radius: var(--radius); font-size: 14px; box-shadow: 0 4px 16px rgba(0,0,0,.25); }
.toast.error { background: var(--danger); color: #fff; }
.toast.ok { background: var(--ok); color: #fff; }

/* ---------- wider screens ---------- */
@media (min-width: 900px) {
  .tabs { display: none; }
  .columns { display: grid; grid-template-columns: repeat(6, minmax(200px, 1fr)); gap: 12px; align-items: start; }
  .col { display: block; }
  .main { padding: 16px; }
  .hdr { padding-left: 16px; padding-right: 16px; }
  .nav { width: 320px; }
  .thread { max-width: 900px; width: 100%; margin: 0 auto; }
  .toasts { left: auto; right: 16px; width: 360px; }
}
