/* KGC Board - one design language across iPhone, iPad, Android and desktop.
 *
 * Every colour is a token, defined once here for dark and once for light, so
 * neither theme is the special case. The board follows the device unless
 * someone picks a side, which is remembered per device.
 */
:root {
  color-scheme: dark;
  --bg: #0e1116;
  --panel: #161b22;
  --panel-2: #1c232d;
  --line: #2a3441;
  --ink: #e7edf5;
  --ink-dim: #93a1b3;
  --ink-faint: #64748b;
  --accent: #4c9aff;
  --on-accent: #08131f;
  --ok: #34d399;
  --warn: #fbbf24;
  --bad: #f87171;
  --shadow: 0 1px 2px rgba(0,0,0,.4);

  --c-neutral: #64748b;
  --c-blue: #4c9aff;
  --c-green: #34d399;
  --c-amber: #fbbf24;
  --c-red: #f87171;
  --c-purple: #a78bfa;

  --pad: 16px;
  --radius: 12px;
  /* Phones with a notch or a home bar. Zero everywhere else. */
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --bottom-nav-h: 0px;
}

/* Light, for a device that asks for it - unless the person chose dark. */
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    color-scheme: light;
    --bg: #f4f6f9;
    --panel: #ffffff;
    --panel-2: #eef1f6;
    --line: #d4dae4;
    --ink: #10151c;
    --ink-dim: #4a5566;
    --ink-faint: #6b7686;
    --accent: #1f6feb;
    --on-accent: #ffffff;
    --ok: #0f7b4f;
    --warn: #9a6400;
    --bad: #c0362c;
    --shadow: 0 1px 2px rgba(16,21,28,.10);

    --c-neutral: #6b7686;
    --c-blue: #1f6feb;
    --c-green: #0f7b4f;
    --c-amber: #9a6400;
    --c-red: #c0362c;
    --c-purple: #6d45c9;
  }
}

/* ...and the same palette when the person picks light explicitly. */
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f4f6f9;
  --panel: #ffffff;
  --panel-2: #eef1f6;
  --line: #d4dae4;
  --ink: #10151c;
  --ink-dim: #4a5566;
  --ink-faint: #6b7686;
  --accent: #1f6feb;
  --on-accent: #ffffff;
  --ok: #0f7b4f;
  --warn: #9a6400;
  --bad: #c0362c;
  --shadow: 0 1px 2px rgba(16,21,28,.10);

  --c-neutral: #6b7686;
  --c-blue: #1f6feb;
  --c-green: #0f7b4f;
  --c-amber: #9a6400;
  --c-red: #c0362c;
  --c-purple: #6d45c9;
}

* { box-sizing: border-box; }

/* Author rules that set `display` (like .field below) otherwise beat the
   browser's own [hidden] rule, and elements we hide in JS stay on screen. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.45 "Segoe UI", system-ui, -apple-system, sans-serif;
}

/* ---------- header ---------- */
header.bar {
  position: sticky;
  top: 0;
  padding-top: calc(12px + var(--safe-top));
  z-index: 10;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  padding: 12px var(--pad);
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}
.brand { font-size: 19px; font-weight: 700; letter-spacing: .3px; }
.brand small { display: block; font-size: 11px; font-weight: 500; color: var(--ink-faint); letter-spacing: .12em; text-transform: uppercase; }

.tally { display: flex; gap: 8px; flex-wrap: wrap; }
.pill {
  padding: 4px 11px;
  border-radius: 999px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  font-size: 13px;
  color: var(--ink-dim);
  white-space: nowrap;
}
.pill b { color: var(--ink); font-variant-numeric: tabular-nums; }
.pill.active b { color: var(--accent); }
.pill.done b { color: var(--ok); }

.spacer { flex: 1 1 auto; }

input.search {
  flex: 1 1 240px;
  min-width: 160px;
  max-width: 420px;
  padding: 9px 12px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
}
input.search:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

.status { display: flex; align-items: center; gap: 7px; font-size: 13px; color: var(--ink-dim); white-space: nowrap; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--ink-faint); }
.status.live .dot { background: var(--ok); box-shadow: 0 0 0 3px rgba(52, 211, 153, .18); }
.status.down .dot { background: var(--bad); box-shadow: 0 0 0 3px rgba(248, 113, 113, .18); }
.status.down { color: var(--bad); }

a.link { color: var(--accent); text-decoration: none; font-size: 13px; }
a.link:hover { text-decoration: underline; }

/* ---------- board grid ---------- */
main {
  padding: var(--pad);
  /* clear the bottom nav and the home bar on a phone */
  padding-bottom: calc(var(--pad) + var(--bottom-nav-h) + var(--safe-bottom));
}
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 14px;
  align-items: start;
}

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.card > h2 {
  margin: 0;
  padding: 11px 14px;
  background: var(--panel-2);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
}
.who { font-size: 16px; font-weight: 700; }
.where { font-size: 13px; color: var(--ink-dim); }
.where.none { color: var(--ink-faint); font-style: italic; }
.counts { margin-left: auto; font-size: 12px; color: var(--ink-dim); font-variant-numeric: tabular-nums; }
.counts b { color: var(--accent); }

ul.items { list-style: none; margin: 0; padding: 0; }
li.item {
  display: flex;
  gap: 10px;
  padding: 10px 14px;
  border-top: 1px solid var(--line);
  border-left: 4px solid var(--c-neutral);
}
li.item:first-child { border-top: 0; }
li.item[data-color="blue"]   { border-left-color: var(--c-blue); }
li.item[data-color="green"]  { border-left-color: var(--c-green); }
li.item[data-color="amber"]  { border-left-color: var(--c-amber); }
li.item[data-color="red"]    { border-left-color: var(--c-red); }
li.item[data-color="purple"] { border-left-color: var(--c-purple); }

li.item input[type="checkbox"] {
  width: 19px; height: 19px;
  margin: 2px 0 0;
  accent-color: var(--ok);
  cursor: pointer;
  flex: none;
}
.body { min-width: 0; flex: 1; }
.text { white-space: pre-wrap; overflow-wrap: anywhere; }
.when { margin-top: 3px; font-size: 12px; color: var(--ink-faint); font-variant-numeric: tabular-nums; }

li.item.is-done { opacity: .5; }
li.item.is-done .text { text-decoration: line-through; }

details.drawer { border-top: 1px solid var(--line); }
details.drawer > summary {
  padding: 8px 14px;
  cursor: pointer;
  font-size: 13px;
  color: var(--ink-dim);
  user-select: none;
}
details.drawer > summary:hover { color: var(--ink); }

.empty { padding: 48px 16px; text-align: center; color: var(--ink-faint); }

/* ---------- send page ---------- */
.sheet {
  max-width: 560px;
  margin: 0 auto;
  padding: var(--pad);
  display: grid;
  gap: 14px;
}
.field { display: grid; gap: 6px; }
.field label { font-size: 13px; color: var(--ink-dim); display: flex; }
.count { margin-left: auto; font-variant-numeric: tabular-nums; color: var(--ink-faint); }
.count.warn { color: var(--warn); }
.count.bad { color: var(--bad); }

.field input, .field textarea {
  width: 100%;
  padding: 11px 12px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  font: inherit;
}
.field textarea { min-height: 130px; resize: vertical; }
.field input:focus, .field textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

.swatches { display: flex; gap: 10px; flex-wrap: wrap; }
.swatch {
  width: 36px; height: 36px;
  border-radius: 50%;
  border: 2px solid var(--line);
  cursor: pointer;
  padding: 0;
}
.swatch[aria-pressed="true"] { border-color: var(--ink); box-shadow: 0 0 0 3px rgba(231, 237, 245, .18); }

button.send {
  padding: 14px;
  border: 0;
  border-radius: 10px;
  background: var(--accent);
  color: var(--on-accent);
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
}
button.send:disabled { opacity: .45; cursor: not-allowed; }

.hint { font-size: 12px; color: var(--ink-faint); text-align: center; }
.toast {
  padding: 11px 13px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: var(--panel);
  font-size: 14px;
}
.toast.ok { border-color: var(--ok); color: var(--ok); }
.toast.bad { border-color: var(--bad); color: var(--bad); }

/* ---------- block-contributed UI (badges, actions, banners) ---------- */
.meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 5px; }
.meta:empty { display: none; }

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .02em;
  border: 1px solid;
}
.badge.tone-neutral { color: var(--c-neutral); border-color: var(--c-neutral); }
.badge.tone-blue    { color: var(--c-blue);    border-color: var(--c-blue); }
.badge.tone-green   { color: var(--c-green);   border-color: var(--c-green); }
.badge.tone-amber   { color: var(--c-amber);   border-color: var(--c-amber); }
.badge.tone-red     { color: var(--c-red);     border-color: var(--c-red); }
.badge.tone-purple  { color: var(--c-purple);  border-color: var(--c-purple); }

.acts { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
button.act {
  padding: 4px 11px;
  border-radius: 7px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--ink);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
button.act:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
button.act:disabled { opacity: .45; cursor: not-allowed; }

button.danger {
  padding: 8px 13px;
  border-radius: 8px;
  border: 1px solid var(--bad);
  background: transparent;
  color: var(--bad);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
button.danger:hover { background: rgba(248, 113, 113, .12); }
button.danger.small { padding: 4px 10px; font-size: 12px; }

/* keeps text aligned for viewers who may not complete items */
.box-placeholder { width: 19px; flex: none; }

.banner {
  margin: 0;
  padding: 12px var(--pad);
  font-size: 15px;
  font-weight: 600;
  border-bottom: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--ink);
}
.banner.ok  { background: rgba(52, 211, 153, .14); color: var(--ok); }
.banner.bad { background: rgba(248, 113, 113, .14); color: var(--bad); }

/* ---------- login / admin ---------- */
.sheet.wide { max-width: 940px; }
.notice {
  padding: 12px 13px;
  border-radius: 9px;
  border: 1px solid var(--warn);
  background: rgba(251, 191, 36, .1);
  color: var(--ink);
  font-size: 14px;
}
.field .fixed {
  padding: 11px 12px;
  border-radius: 9px;
  border: 1px dashed var(--line);
  background: var(--panel-2);
  color: var(--ink);
  font-weight: 600;
}
.field select {
  width: 100%;
  padding: 11px 12px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  font: inherit;
}
.row-form { display: grid; gap: 12px; }
label.checkline {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 5px 0;
  font-size: 14px;
  color: var(--ink);
  cursor: pointer;
}
label.checkline input { width: 17px; height: 17px; accent-color: var(--accent); }
.row-form button.danger { justify-self: start; }
h3.section {
  margin: 10px 0 0;
  font-size: 13px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--ink-faint);
}
h3.danger-head { color: var(--bad); }

.grid-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.grid-table th {
  text-align: left;
  padding: 8px 10px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--ink-faint);
  border-bottom: 1px solid var(--line);
}
.grid-table td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.grid-table tr.dim { opacity: .5; }
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; }
code.code {
  font-size: 12px;
  color: var(--ink-dim);
  overflow-wrap: anywhere;
}

@media (max-width: 720px) {
  .grid-table, .grid-table tbody, .grid-table tr, .grid-table td { display: block; width: 100%; }
  .grid-table thead { display: none; }
  .grid-table tr { border: 1px solid var(--line); border-radius: 10px; margin-bottom: 10px; padding: 6px; }
  .grid-table td { border: 0; padding: 5px 8px; }
}

/* readiness report - it sits in a .hint, which centres text; a list of
   findings has to read left-aligned. */
#readiness { text-align: left; font-size: 13px; }
#readiness .badge { margin-right: 4px; }
.readiness-group { margin-top: 10px; }
.readiness-group ul { margin: 4px 0 0; padding-left: 20px; }
.readiness-group li { margin: 3px 0; color: var(--ink-dim); }
.danger-text { color: var(--bad); }
.warn-text { color: var(--warn); }

/* ---------- settings surface ---------- */
.settings-intro { text-align: left; margin-bottom: 4px; }
a.settings-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  margin-bottom: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  text-decoration: none;
  color: var(--ink);
}
a.settings-row:hover { border-color: var(--accent); }
.settings-label { font-weight: 600; flex: none; }
.settings-hint { color: var(--ink-dim); font-size: 13px; }
.settings-go { margin-left: auto; color: var(--ink-faint); font-size: 22px; line-height: 1; }
@media (max-width: 620px) {
  a.settings-row { flex-wrap: wrap; }
  .settings-go { display: none; }
}

/* ---------- Q&A ---------- */
.qa-filters {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: center;
}
.qa-filters select {
  padding: 9px 12px; border-radius: 9px; border: 1px solid var(--line);
  background: var(--panel); color: var(--ink); font: inherit;
}
.qa-filters .checkline { font-size: 13px; color: var(--ink-dim); }
button.qa-ask-toggle { margin-left: auto; padding: 9px 16px; font-size: 14px; }

.qa-item {
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--panel); padding: 14px; margin-top: 12px;
}
.qa-head { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.qa-q { font-size: 16px; font-weight: 600; white-space: pre-wrap; overflow-wrap: anywhere; }
.qa-a {
  margin-top: 10px; padding: 11px 13px;
  border-left: 3px solid var(--ok); border-radius: 0 9px 9px 0;
  background: var(--panel-2); white-space: pre-wrap; overflow-wrap: anywhere;
}
.qa-meta { margin-top: 5px; font-size: 12px; color: var(--ink-faint); }
form.qa-answer { margin-top: 12px; }
form.qa-answer textarea { min-height: 90px; }

/* ---------- RFIQ ---------- */
.filter-input {
  padding: 9px 12px; border-radius: 9px; border: 1px solid var(--line);
  background: var(--panel); color: var(--ink); font: inherit;
  max-width: 180px;
}
.rfiq-ref {
  font-weight: 700; letter-spacing: .04em; font-size: 13px;
  color: var(--accent); font-variant-numeric: tabular-nums;
}

/* ---------- two-factor ---------- */
.qr-box {
  background: #fff; padding: 12px; border-radius: var(--radius);
  max-width: 260px; margin: 0 auto;
}
.qr-box svg { width: 100%; height: auto; display: block; }
.backup-note { border-color: var(--accent); background: rgba(76, 154, 255, .08); }
.backup-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 8px; margin-top: 10px;
}
code.backup-code {
  display: block; padding: 7px 9px; text-align: center;
  background: var(--bg); border: 1px solid var(--line); border-radius: 7px;
  font-size: 14px; letter-spacing: .06em; color: var(--ink);
}


/* ===========================================================================
   Bottom navigation - phones and tablets
   ===========================================================================
   The plan caps this at five destinations. The board uses three, and this is
   deliberately NOT a plug-in point: a block can only add an entry to
   Settings, so the cap cannot be exceeded by adding a feature. On desktop
   the same destinations live in the header instead.
   ------------------------------------------------------------------------ */
nav.bottom { display: none; }

/* Phones always. Tablets too - an iPad in portrait is 768px wide and is
   still a thumb-driven device, so it gets the tab bar rather than a desktop
   header. A narrow window on a desktop does NOT, which is why this keys off
   a coarse pointer and not width alone. */
@media (max-width: 760px), (pointer: coarse) and (max-width: 1180px) {
  :root { --bottom-nav-h: 58px; }

  nav.bottom {
    display: flex;
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 30;
    background: var(--panel);
    border-top: 1px solid var(--line);
    padding-bottom: var(--safe-bottom);
  }
  nav.bottom a {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    /* 44px is the smallest comfortable touch target on both platforms. */
    min-height: 56px;
    padding: 7px 4px;
    text-decoration: none;
    color: var(--ink-faint);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .02em;
    -webkit-tap-highlight-color: transparent;
  }
  nav.bottom a .ico { font-size: 19px; line-height: 1; }
  nav.bottom a[aria-current="page"] { color: var(--accent); }
  /* Android convention: a visible press ripple-ish state. iOS just dims. */
  nav.bottom a:active { background: var(--panel-2); }

  /* The header keeps the title and the live indicator; the destinations
     move to the thumb. */
  header.bar .desktop-nav { display: none; }
}

/* Phone-sized tightening only - a tablet has room for the full header. */
@media (max-width: 760px) {
  header.bar { gap: 8px; padding-left: 12px; padding-right: 12px; }
  .brand { font-size: 17px; }
  input.search { order: 10; flex-basis: 100%; max-width: none; }
  .sheet, .sheet.wide { padding-left: 14px; padding-right: 14px; }
}

/* A tablet has room for more board at once than a phone, and less than a
   desktop. The grid does this on its own; this just tightens the minimum. */
@media (min-width: 761px) and (max-width: 1100px) {
  .grid { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
}

/* Pointer devices get hover; touch devices must not inherit a stuck state. */
@media (hover: hover) {
  .card:hover { box-shadow: var(--shadow); }
}

/* theme toggle */
button.theme {
  background: none;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink-dim);
  cursor: pointer;
  font-size: 13px;
  padding: 5px 11px;
  line-height: 1.3;
}
button.theme:hover { color: var(--ink); border-color: var(--accent); }

/* Respect a person who has asked for less movement. */
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}

/* ---- Cloud Board additions (sign-in, install page) ---- */
.page-title { font-size: 19px; margin: 0; }
a.send.button-link {
  display: block; text-align: center; text-decoration: none;
  padding: 14px; border-radius: 10px;
  background: var(--accent); color: var(--on-accent);
  font-size: 16px; font-weight: 700;
}
.steps { margin: 0; padding-left: 20px; display: grid; gap: 6px; color: var(--ink); }
.install-box { display: grid; gap: 10px; padding: 14px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel-2); }
.install-box h2 { font-size: 15px; margin: 0; }
.install-box[hidden] { display: none; }
