:root {
  --bg: #e6ecf1;
  --surface: #ffffff;
  --ink: #1c2733;
  --muted: #5b6876;
  --line: #c9d3dc;
  --accent: #1f5f8b;
  --accent-ink: #ffffff;
  --alert: #b23a3a;
  --warn: #9a6512;

  --s-working: #2f7d5b;
  --s-idle: #6f7d8b;
  --s-waiting_permission: #b7791f;
  --s-blocked: #b23a3a;
  --s-paused: #5355c9;
  --s-unreachable: #9b3fa8;
  --s-offline: #a3abb3;

  --radius-strip: 4px;
  --radius-control: 6px;
  --font: 'IBM Plex Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-name: 'IBM Plex Sans Condensed', 'Arial Narrow', system-ui, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121a22;
    --surface: #1b2631;
    --ink: #e3eaf0;
    --muted: #9aa8b5;
    --line: #2f3d4a;
    --accent: #6fb0e0;
    --accent-ink: #0d1a24;
    --alert: #f07a7a;
    --warn: #e0b060;
    --s-working: #4fb486;
    --s-idle: #8593a1;
    --s-waiting_permission: #e0a640;
    --s-blocked: #e86464;
    --s-paused: #8e90f0;
    --s-unreachable: #cf7ddb;
    --s-offline: #5d6873;
    color-scheme: dark;
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 var(--font);
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

/* ---------- top bar ---------- */

.bar {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 16px;
  padding: 10px 16px;
  background: var(--ink);
  color: var(--bg);
}

.brand {
  font: 700 22px/1 var(--font-name);
  letter-spacing: 0.02em;
}

.tabs {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  flex: 1 1 auto;
}

.tabs button {
  border: 0;
  background: transparent;
  color: inherit;
  padding: 6px 10px;
  border-radius: var(--radius-control);
  opacity: 0.75;
  cursor: pointer;
  white-space: nowrap;
}

.tabs button[aria-current='page'] {
  opacity: 1;
  background: color-mix(in srgb, var(--bg) 18%, transparent);
}

.count:not(:empty) {
  display: inline-block;
  min-width: 1.6em;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--s-waiting_permission);
  color: #1c2733;
  font-weight: 600;
  text-align: center;
}

.live {
  font-size: 13px;
  opacity: 0.7;
}

@media (max-width: 640px) {
  .live {
    margin-left: auto;
  }
  .tabs {
    order: 3;
    flex-basis: 100%;
  }
}

.live.on::before {
  content: '';
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 6px;
  border-radius: 50%;
  background: var(--s-working);
}

.signed-out .tabs,
.signed-out .live {
  visibility: hidden;
}

main {
  max-width: 1180px;
  margin: 0 auto;
  padding: 16px;
  outline: none;
}

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

.waiting {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 12px;
  width: 100%;
  margin-bottom: 16px;
  padding: 12px 16px;
  border: 0;
  border-left: 8px solid var(--s-waiting_permission);
  border-radius: var(--radius-strip);
  background: var(--surface);
  text-align: left;
  font-size: 18px;
  cursor: pointer;
}

.waiting-n {
  font: 700 44px/1 var(--font-name);
}

.waiting-b {
  color: var(--alert);
  font-weight: 600;
}

.strips {
  display: grid;
  gap: 8px;
}

@media (min-width: 960px) {
  .strips {
    grid-template-columns: 1fr 1fr;
  }
}

.strip {
  display: grid;
  grid-template-columns: 92px 1fr;
  width: 100%;
  min-height: 96px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-strip);
  background: var(--surface);
  text-align: left;
  cursor: pointer;
  overflow: hidden;
}

.strip:hover {
  border-color: var(--muted);
}

.band {
  display: flex;
  align-items: flex-end;
  padding: 8px;
  background: var(--band);
  color: #fff;
  font: 600 13px/1.2 var(--font-name);
}

.s-offline .band,
.s-idle .band {
  color: #10171e;
}

.strip-body {
  display: grid;
  align-content: start;
  gap: 2px;
  padding: 8px 12px;
  min-width: 0;
}

.strip-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 10px;
}

.name {
  font: 700 22px/1.1 var(--font-name);
}

.name.small {
  font-size: 18px;
  min-width: 6em;
}

.role {
  color: var(--muted);
  font-size: 14px;
}

.role.lead {
  color: var(--accent);
  font-weight: 600;
}

.meta {
  color: var(--muted);
  font-size: 13px;
}

.doing,
.qbody {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.doing {
  max-height: 4.5em;
  overflow: hidden;
}

.blocker {
  color: var(--alert);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  margin: 0;
}

.task-line {
  font-size: 14px;
  color: var(--muted);
}

.flags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 4px;
}

.flag {
  padding: 1px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 13px;
}

.flag.warn {
  border-color: var(--warn);
  color: var(--warn);
}

.flag.alert {
  border-color: var(--alert);
  color: var(--alert);
}

.s-working { --band: var(--s-working); }
.s-idle { --band: var(--s-idle); }
.s-waiting_permission { --band: var(--s-waiting_permission); }
.s-blocked { --band: var(--s-blocked); }
.s-paused { --band: var(--s-paused); }
.s-unreachable { --band: var(--s-unreachable); }
.s-offline { --band: var(--s-offline); }

.pill {
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--band);
  color: #fff;
  font-size: 13px;
}

/* ---------- panels, forms ---------- */

.panel,
.question,
.task {
  margin-bottom: 12px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-strip);
  background: var(--surface);
}

.panel {
  display: grid;
  gap: 10px;
}

h1,
h2,
h3 {
  margin: 0;
  font-family: var(--font-name);
  font-weight: 600;
}

h2 {
  font-size: 20px;
}

h3 {
  font-size: 17px;
  margin-top: 16px;
}

.tasks > div > h2 {
  margin: 20px 0 8px;
}

input,
select,
textarea {
  width: 100%;
  min-width: 0;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-control);
  background: var(--bg);
}

.row select,
.row input {
  width: auto;
  flex: 1 1 140px;
}

.row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

button {
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-control);
  background: var(--surface);
  cursor: pointer;
}

button.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 600;
}

button.warn {
  border-color: var(--warn);
  color: var(--warn);
}

button.quiet {
  border-color: transparent;
  background: transparent;
  color: var(--muted);
}

button.armed {
  border-color: var(--alert);
  background: var(--alert);
  color: #fff;
}

button:disabled {
  opacity: 0.6;
  cursor: progress;
}

.plain {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
}

.empty {
  color: var(--muted);
}

/* ---------- questions ---------- */

.question header {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 12px;
}

.question.blocking {
  border-left: 6px solid var(--s-waiting_permission);
}

.question.overdue {
  border-left-color: var(--alert);
}

.qid {
  font: 700 18px/1 var(--font-name);
}

.answer {
  display: grid;
  gap: 8px;
}

.choices {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.choice {
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 600;
}

.answered {
  color: var(--muted);
  white-space: pre-wrap;
}

.history {
  margin-top: 20px;
}

.history summary {
  cursor: pointer;
  margin-bottom: 8px;
  color: var(--muted);
}

/* ---------- tasks ---------- */

.task-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.task-title {
  display: flex;
  gap: 10px;
  align-items: baseline;
}

/* ---------- detail dialog ---------- */

dialog {
  width: min(680px, 100vw - 32px);
  max-height: calc(100vh - 32px);
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-strip);
  background: var(--surface);
  color: var(--ink);
}

dialog::backdrop {
  background: rgb(10 16 22 / 0.55);
}

.detail {
  display: grid;
  gap: 10px;
  padding: 16px;
}

.detail-head {
  display: flex;
  align-items: center;
  gap: 10px;
}

.detail-head .close {
  margin-left: auto;
}

.send {
  display: grid;
  gap: 8px;
}

.timeline {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 6px;
}

.timeline li {
  display: grid;
  grid-template-columns: 88px 1fr;
  gap: 8px;
  font-size: 14px;
  overflow-wrap: anywhere;
}

.timeline time {
  color: var(--muted);
}

/* ---------- login, toast ---------- */

.login {
  display: grid;
  gap: 10px;
  max-width: 360px;
  margin: 12vh auto 0;
}

.login h1 {
  font-size: 32px;
  margin-bottom: 8px;
}

.error-text {
  color: var(--alert);
  min-height: 1.5em;
}

.token {
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px dashed var(--warn);
  border-radius: var(--radius-control);
}

.toast {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: 16px;
  max-width: 520px;
  margin: 0 auto;
  padding: 10px 14px;
  border-radius: var(--radius-control);
  background: var(--ink);
  color: var(--bg);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.2s, transform 0.2s;
  pointer-events: none;
}

.toast.show {
  opacity: 1;
  transform: none;
}

.toast.error {
  background: var(--alert);
  color: #fff;
}

@media (max-width: 420px) {
  .strip {
    grid-template-columns: 72px 1fr;
  }
  .name {
    font-size: 20px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .toast {
    transition: none;
  }
}

.project {
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 13px;
}

.project-pick {
  display: flex;
  gap: 6px;
  align-items: center;
  color: var(--muted);
  font-size: 14px;
}
