/* Layout: a slim project bar, the project's title, a toolbar, then the project's columns (To do,
   In progress, Waiting, Done and any of its own) side by side, scrolling sideways when they do
   not fit, folding to two and then one as the window narrows. */
:root {
  --bg: #f1f3f6;
  --surface: #ffffff;
  --sunken: #e6e9ee;
  --fg: #19212c;
  --muted: #5b6676;
  --line: #d4d9e1;
  --accent: #2d5b97;
  --accent-fg: #ffffff;
  --danger: #b42318;
  --st-todo: #6b7585;
  --st-doing: #2d5b97;
  --st-waiting: #a4630d;
  --st-done: #2e7a4d;
  --c-blue: #2d5b97;
  --c-violet: #6a4aa0;
  --c-amber: #98570f;
  --c-teal: #17756d;
  --c-rose: #a83a5b;
  --c-green: #2e7a4d;
  --c-slate: #556274;
  --shadow: 0 1px 2px rgb(16 24 40 / 0.08);
  --overlay: rgb(12 17 24 / 0.45);
  --font-ui: system-ui, -apple-system, 'Segoe UI', Roboto, 'Fira Sans', Ubuntu, sans-serif;
  --font-mono: ui-monospace, 'Fira Mono', 'JetBrains Mono', 'DejaVu Sans Mono', Menlo, Consolas,
    monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1318;
    --surface: #1b222c;
    --sunken: #151a21;
    --fg: #e2e7ee;
    --muted: #9aa5b4;
    --line: #2b3441;
    --accent: #82aae4;
    --accent-fg: #0d1520;
    --danger: #f2867c;
    --st-todo: #98a3b3;
    --st-doing: #82aae4;
    --st-waiting: #e2a95c;
    --st-done: #6dc192;
    --c-blue: #82aae4;
    --c-violet: #b39ce2;
    --c-amber: #e2a95c;
    --c-teal: #5fc3b8;
    --c-rose: #ec8fa9;
    --c-green: #6dc192;
    --c-slate: #a3afbf;
    --shadow: none;
    --overlay: rgb(0 0 0 / 0.6);
    color-scheme: dark;
  }
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
}

body {
  font-family: var(--font-ui);
  font-size: 14px;
  line-height: 1.45;
}

.wrap {
  max-width: 1500px;
  margin-inline: auto;
  padding-inline: 16px;
}

.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.spacer {
  flex: 1;
}

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

.small {
  font-size: 12.5px;
}

/* Controls */

.btn,
input,
select,
textarea {
  font: inherit;
  color: var(--fg);
}

.btn {
  font-size: 13px;
  padding: 5px 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  cursor: pointer;
  white-space: nowrap;
}

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

.btn:disabled {
  opacity: 0.4;
  cursor: default;
}

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

.btn.danger {
  color: var(--danger);
}

.btn.danger.solid {
  background: var(--danger);
  border-color: var(--danger);
  color: var(--surface);
}

.btn.icon {
  padding: 2px 9px;
  font-size: 18px;
  line-height: 1.2;
  border-color: transparent;
  background: transparent;
  color: var(--muted);
}

input,
select,
textarea {
  font-size: 13.5px;
  padding: 6px 9px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  min-width: 0;
}

textarea {
  font-family: var(--font-mono);
  font-size: 12.5px;
  line-height: 1.5;
  resize: vertical;
}

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

input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline-offset: 0;
}

/* Project bar */

.bar {
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.bar-inner {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding-block: 8px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-weight: 600;
  letter-spacing: 0.01em;
}

#project {
  font-weight: 500;
  max-width: 100%;
}

/* Intro */

.intro {
  padding-block: 18px 6px;
  display: grid;
  gap: 4px;
}

.intro h1 {
  margin: 0;
  font-size: 22px;
  line-height: 1.25;
  font-weight: 650;
  letter-spacing: -0.01em;
  text-wrap: balance;
}

.desc {
  margin: 0;
  max-width: 80ch;
  color: var(--muted);
}

.desc:empty {
  display: none;
}

.stats {
  margin: 0;
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  font-size: 12.5px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.stats span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

/* Toolbar */

.toolbar {
  position: sticky;
  top: 0;
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding-block: 10px;
  background: var(--bg);
}

#q {
  width: min(280px, 100%);
}

.chips {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.chip {
  font: inherit;
  font-size: 12.5px;
  padding: 3px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--fg);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.chip[aria-pressed='true'] {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 14%, var(--surface));
}

.chip .n {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* Board */

.board {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(190px, 1fr);
  gap: 12px;
  align-items: start;
  padding-block: 4px 40px;
  overflow-x: auto;
}

@media (max-width: 1050px) {
  .board {
    grid-auto-flow: row;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 620px) {
  .board {
    grid-template-columns: minmax(0, 1fr);
  }
}

.col {
  background: var(--sunken);
  border-radius: 10px;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
  border: 1px solid transparent;
}

.col.over {
  border-color: var(--accent);
}

.col-head {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  column-gap: 8px;
  padding: 2px 4px 0;
}

.col-name {
  font-weight: 600;
  font-size: 13.5px;
}

.col-count {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.col-note {
  grid-column: 2 / 4;
  font-size: 11.5px;
  color: var(--muted);
}

.dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--dot);
}

.dot.todo {
  --dot: var(--st-todo);
}
.dot.doing {
  --dot: var(--st-doing);
}
.dot.waiting {
  --dot: var(--st-waiting);
}
.dot.done {
  --dot: var(--st-done);
}
.dot.custom {
  --dot: var(--c-violet);
}

.list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 44px;
}

.list-empty {
  font-size: 12.5px;
  color: var(--muted);
  padding: 10px 6px;
  text-align: center;
  border: 1px dashed var(--line);
  border-radius: 8px;
}

.marker {
  height: 3px;
  border-radius: 2px;
  background: var(--accent);
  margin-block: -4.5px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px 9px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  box-shadow: var(--shadow);
  cursor: pointer;
  min-width: 0;
}

.card:hover {
  border-color: color-mix(in srgb, var(--accent) 45%, var(--line));
}

.card.dragging {
  opacity: 0.4;
}

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

.key {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.tag {
  font-size: 11px;
  font-weight: 500;
  padding: 1px 7px;
  border-radius: 999px;
  color: var(--tc);
  background: color-mix(in srgb, var(--tc) 14%, transparent);
  white-space: nowrap;
}

.c-blue {
  --tc: var(--c-blue);
}
.c-violet {
  --tc: var(--c-violet);
}
.c-amber {
  --tc: var(--c-amber);
}
.c-teal {
  --tc: var(--c-teal);
}
.c-rose {
  --tc: var(--c-rose);
}
.c-green {
  --tc: var(--c-green);
}
.c-slate {
  --tc: var(--c-slate);
}

.swatch {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--tc);
}

.card-title {
  font-size: 13.5px;
  font-weight: 500;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.card-group {
  font-size: 12px;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.col.done .card-title {
  color: var(--muted);
}

.card.warn {
  border-color: color-mix(in srgb, var(--danger) 55%, var(--line));
}

.warn-pill {
  font-size: 11px;
  font-weight: 500;
  padding: 1px 7px;
  border-radius: 999px;
  color: var(--danger);
  background: color-mix(in srgb, var(--danger) 13%, transparent);
  white-space: nowrap;
}

/* File problems */

.notice {
  display: grid;
  gap: 6px;
  padding: 10px 14px;
  border: 1px solid color-mix(in srgb, var(--danger) 45%, var(--line));
  border-radius: 10px;
  background: color-mix(in srgb, var(--danger) 7%, var(--surface));
  min-width: 0;
  overflow-wrap: anywhere;
}

main > .notice {
  margin-block: 8px 2px;
}

.notice strong {
  color: var(--danger);
  font-weight: 600;
}

.notice ul {
  margin: 0;
  padding-left: 1.2em;
}

.notice-cards {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 10px;
}

.link-btn {
  font: inherit;
  font-family: var(--font-mono);
  font-size: 12.5px;
  padding: 0;
  border: none;
  background: none;
  color: var(--accent);
  text-decoration: underline;
  cursor: pointer;
}

.more {
  align-self: center;
}

.empty {
  grid-column: 1 / -1;
  padding: 40px 16px;
  text-align: center;
  color: var(--muted);
}

.empty strong {
  display: block;
  color: var(--fg);
  font-size: 15px;
  margin-bottom: 4px;
}

/* Dialog */

dialog {
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  color: var(--fg);
  width: min(760px, calc(100vw - 32px));
  max-height: calc(100dvh - 48px);
  box-shadow: 0 24px 60px rgb(0 0 0 / 0.28);
}

dialog::backdrop {
  background: var(--overlay);
}

.dlg {
  display: flex;
  flex-direction: column;
  max-height: calc(100dvh - 50px);
}

.dlg-head {
  padding: 12px 16px 12px 18px;
  border-bottom: 1px solid var(--line);
  display: grid;
  gap: 6px;
}

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

.dlg-head h2 {
  margin: 0;
  font-size: 18px;
  line-height: 1.3;
  font-weight: 600;
  text-wrap: balance;
  overflow-wrap: anywhere;
}

.dlg-head p {
  margin: 0;
}

.dlg-body {
  padding: 14px 18px 18px;
  overflow: auto;
  min-height: 0;
  display: grid;
  gap: 12px;
  align-content: start;
}

.dlg-foot {
  padding: 10px 16px 10px 18px;
  border-top: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.field {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.field > span {
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  letter-spacing: 0.02em;
}

.field-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

@media (max-width: 560px) {
  .field-row {
    grid-template-columns: minmax(0, 1fr);
  }
}

.hint {
  font-size: 12px;
  color: var(--muted);
}

.path {
  font-family: var(--font-mono);
  font-size: 12px;
  overflow-wrap: anywhere;
  user-select: all;
}

.tag-rows {
  display: grid;
  gap: 6px;
}

.tag-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  gap: 8px;
  align-items: center;
}

.column-rows {
  display: grid;
  gap: 6px;
}

.column-row {
  display: grid;
  grid-template-columns: auto minmax(0, 2fr) minmax(0, 3fr) auto auto 5.5em;
  gap: 6px 8px;
  align-items: center;
  min-height: 32px;
}

.column-fixed {
  grid-column: span 2;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 2px 10px;
  padding-inline: 9px;
}

.column-kind {
  text-align: center;
}

.column-row.removing {
  display: flex;
  flex-wrap: wrap;
}

.column-row.removing select {
  max-width: 14em;
}

.column-add {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 12px;
}

@media (max-width: 560px) {
  .column-row {
    grid-template-columns: auto minmax(0, 1fr) auto auto 5.5em;
  }

  .column-row > input + input {
    grid-column: 2 / -1;
    grid-row: 2;
  }

  .column-fixed {
    grid-column: auto;
  }
}

/* Environment variables */

.mono {
  font-family: var(--font-mono);
  font-size: 12.5px;
}

.env-rows {
  display: grid;
  gap: 6px;
}

.env-row {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 3fr) auto auto auto;
  gap: 8px;
  align-items: start;
}

.env-value {
  field-sizing: content;
  min-height: 0;
  max-height: 16em;
}

.env-mask {
  padding: 6px 9px;
  border: 1px dashed var(--line);
  border-radius: 7px;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 12.5px;
  overflow: hidden;
  white-space: nowrap;
}

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

/* Vault */

.btn.attention {
  border-color: var(--danger);
  color: var(--danger);
}

.vault-tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--line);
}

.tab {
  font: inherit;
  font-size: 13px;
  padding: 6px 12px;
  margin-bottom: -1px;
  border: 1px solid transparent;
  border-radius: 7px 7px 0 0;
  background: none;
  color: var(--muted);
  cursor: pointer;
  display: inline-flex;
  gap: 6px;
}

.tab[aria-selected='true'] {
  color: var(--fg);
  border-color: var(--line);
  border-bottom-color: var(--surface);
  background: var(--surface);
  font-weight: 500;
}

.tab .n {
  color: var(--muted);
  font-weight: 400;
  font-variant-numeric: tabular-nums;
}

.pill {
  font-size: 11px;
  padding: 1px 7px;
  border-radius: 999px;
  color: var(--st-waiting);
  background: color-mix(in srgb, var(--st-waiting) 13%, transparent);
  white-space: nowrap;
}

.file-rows {
  display: grid;
}

.file-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto auto;
  gap: 12px;
  align-items: center;
  padding: 3px 0;
  border-bottom: 1px solid var(--line);
}

.file-name {
  justify-self: start;
  text-align: left;
  overflow-wrap: anywhere;
}

@media (max-width: 560px) {
  .file-row {
    grid-template-columns: minmax(0, 1fr) auto auto;
  }

  .file-row > :nth-child(3) {
    display: none;
  }

  .env-row {
    grid-template-columns: minmax(0, 1fr) auto auto auto;
  }

  .env-row > :first-child {
    grid-column: 1 / -1;
  }
}

/* Rendered Markdown */

.md {
  max-width: 72ch;
  overflow-wrap: anywhere;
}

.md > :first-child {
  margin-top: 0;
}

.md > :last-child {
  margin-bottom: 0;
}

.md p,
.md ul,
.md ol,
.md pre {
  margin-block: 0 10px;
}

.md ul,
.md ol {
  padding-left: 1.3em;
}

.md li {
  margin-block: 3px;
}

.md li > ul,
.md li > ol {
  margin-block: 3px 0;
}

.md h3,
.md h4,
.md h5,
.md h6 {
  font-size: 14px;
  margin-block: 14px 6px;
}

.md code {
  font-family: var(--font-mono);
  font-size: 0.9em;
  padding: 1px 4px;
  border-radius: 4px;
  background: var(--sunken);
}

.md pre {
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--sunken);
  overflow-x: auto;
}

.md pre code {
  padding: 0;
  background: none;
}

.md a {
  color: var(--accent);
}

.md .box {
  font-family: var(--font-mono);
  color: var(--muted);
}

/* Toast */

#toast {
  position: fixed;
  left: 50%;
  bottom: 20px;
  transform: translateX(-50%);
  z-index: 10;
  max-width: calc(100vw - 32px);
  padding: 8px 14px;
  border-radius: 8px;
  background: var(--fg);
  color: var(--bg);
  font-size: 13px;
  box-shadow: 0 8px 24px rgb(0 0 0 / 0.2);
}

@media (prefers-reduced-motion: no-preference) {
  .card {
    transition: border-color 120ms ease;
  }
}

/* The cloud version: signing in, the account and the admin. */
body.signed-out .intro,
body.signed-out .toolbar,
body.signed-out .board,
body.signed-out #notice,
body.signed-out .bar select,
body.signed-out .bar .btn {
  display: none;
}

.auth {
  display: flex;
  justify-content: center;
  padding: 48px 0;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: min(380px, 100%);
  padding: 24px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--shadow);
}

.auth-form h1 {
  margin: 0;
  font-size: 20px;
}

.auth-form p {
  margin: 0;
}

.auth-form .btn.primary {
  align-self: flex-start;
}

.auth-links {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
}

.auth-links .link-btn {
  font-family: var(--font-ui);
  font-size: 13px;
}

.token {
  display: block;
  padding: 8px 10px;
  font-family: var(--font-mono);
  font-size: 12.5px;
  background: var(--sunken);
  border-radius: 6px;
  overflow-wrap: anywhere;
  user-select: all;
}

.pill.attention {
  color: var(--danger);
  background: color-mix(in srgb, var(--danger) 13%, transparent);
}

.file-row select {
  max-width: 140px;
}

.error {
  color: var(--danger);
}

.error:empty {
  display: none;
}
