:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #f0f1f4;
  --text: #1b1d22;
  --muted: #697080;
  --border: #e3e5ea;
  --accent: #5b5bd6;
  --danger: #dc3a3a;
  --warning: #c27c0e;
  --info: #1f75cb;
  --ok: #108548;
  --radius: 14px;
  --radius-small: 9px;
  --shadow: 0 1px 2px rgb(16 18 24 / 6%), 0 4px 16px rgb(16 18 24 / 6%);
  --shadow-raised: 0 2px 6px rgb(16 18 24 / 8%), 0 18px 48px rgb(16 18 24 / 16%);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1015;
    --surface: #171a21;
    --surface-2: #1f232c;
    --text: #e8eaef;
    --muted: #9198a6;
    --border: #2a2f3a;
    --accent: #8b8cf6;
    --danger: #f06a6a;
    --warning: #e3a63b;
    --info: #5aa2ee;
    --ok: #3fbf74;
    --shadow: 0 1px 2px rgb(0 0 0 / 40%), 0 4px 16px rgb(0 0 0 / 25%);
    --shadow-raised: 0 2px 6px rgb(0 0 0 / 50%), 0 18px 48px rgb(0 0 0 / 50%);
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { margin: 0; line-height: 1.2; }
h1 { font-size: 1.6rem; font-weight: 700; letter-spacing: -0.02em; }
h2 { font-size: 1.05rem; font-weight: 650; }
a { color: inherit; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
.spacer { flex: 1; }

svg {
  width: 18px;
  height: 18px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Buttons */

button, .button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 36px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: 550;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.1s, box-shadow 0.15s;
}
button:hover, .button:hover { border-color: color-mix(in srgb, var(--text) 25%, var(--border)); }
button:active, .button:active { transform: scale(0.97); }
button:focus-visible, .button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, summary:focus-visible, a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
button:disabled { cursor: default; opacity: 0.55; transform: none; }

.primary {
  border-color: transparent;
  background: var(--accent);
  color: #fff;
  box-shadow: 0 1px 2px color-mix(in srgb, var(--accent) 40%, transparent);
}
.primary:hover { border-color: transparent; background: color-mix(in srgb, var(--accent) 88%, #000); }
.ghost { border-color: transparent; background: transparent; }
.ghost:hover { background: var(--surface-2); border-color: transparent; }
.danger { color: var(--danger); }
.small { min-height: 30px; padding: 0 11px; font-size: 0.9rem; }
.large { min-height: 46px; padding: 0 24px; font-size: 1.02rem; }
.icon {
  width: 36px;
  min-height: 36px;
  padding: 0;
  border-color: transparent;
  background: transparent;
  color: var(--muted);
}
.icon:hover { background: var(--surface-2); color: var(--text); border-color: transparent; }
.icon.small { width: 30px; min-height: 30px; }

/* Layout */

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px max(16px, calc((100vw - 980px) / 2));
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(160%) blur(12px);
  border-bottom: 1px solid color-mix(in srgb, var(--border) 60%, transparent);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; text-decoration: none; letter-spacing: -0.01em; }
.me { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.me-name { color: var(--muted); font-size: 0.92rem; }

.container { max-width: 980px; margin: 0 auto; padding: 28px 16px 96px; }

.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 22px; }

.avatar {
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--accent) 16%, var(--surface));
  color: color-mix(in srgb, var(--accent) 80%, var(--text));
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  border: 2px solid var(--bg);
}
.avatars { display: flex; }
.avatars .avatar + .avatar { margin-left: -5px; }

/* Shell: sidebar and breadcrumbs */

.shell { --side-w: 248px; display: grid; grid-template-columns: var(--side-w) minmax(0, 1fr); }
.shell-main { min-width: 0; }
.shell .container { max-width: 1180px; padding: 18px 32px 96px; }

.sidebar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  gap: 4px;
  height: 100vh;
  padding: 12px 10px;
  overflow-y: auto;
  border-right: 1px solid var(--border);
  background: var(--surface);
}
.side-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 2px 4px 10px; }
.side-collapse svg { transition: transform 0.15s; }

.tile {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: var(--c, var(--accent));
  color: var(--on-c, #fff);
  font-size: 0.82rem;
  font-weight: 700;
}

.switcher { position: relative; margin-bottom: 6px; }
.switcher summary {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-small);
  font-weight: 650;
  cursor: pointer;
  list-style: none;
}
.switcher summary::-webkit-details-marker { display: none; }
.switcher summary:hover { background: var(--surface-2); }
.switcher summary span.label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.switcher summary svg { color: var(--muted); transition: transform 0.15s; }
.switcher[open] summary svg { transform: rotate(180deg); }
.switcher-menu {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-top: 6px;
  padding: 6px;
  max-height: 50vh;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-small);
  background: var(--surface);
  box-shadow: var(--shadow-raised);
}
.switcher-menu a { display: flex; align-items: center; gap: 10px; min-height: 36px; padding: 4px 8px; border-radius: 8px; font-size: 0.92rem; text-decoration: none; }
.switcher-menu a span:last-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.switcher-menu a:hover, .switcher-menu a[aria-current] { background: var(--surface-2); }
.switcher-menu .all { margin-top: 4px; padding-top: 8px; border-top: 1px solid var(--border); border-radius: 0; color: var(--muted); }

.side-nav { display: flex; flex-direction: column; gap: 2px; }
.side-nav a, .side-nav button {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 12px;
  width: 100%;
  min-height: 38px;
  padding: 0 10px;
  border: 0;
  border-radius: var(--radius-small);
  background: transparent;
  color: var(--muted);
  font-size: 0.93rem;
  font-weight: 600;
  text-decoration: none;
}
.side-nav a:hover, .side-nav button:hover { background: var(--surface-2); color: var(--text); }
.side-nav button:active { transform: none; }
.side-nav .on { background: color-mix(in srgb, var(--accent) 12%, var(--surface)); color: var(--text); }
.side-nav .on svg { color: var(--accent); }
.side-nav .label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-nav .tile { width: 22px; height: 22px; border-radius: 6px; font-size: 0.7rem; }
.side-secondary { margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--border); }
.side-me { display: flex; align-items: center; gap: 10px; padding: 10px 4px 0; border-top: 1px solid var(--border); }
.side-me .me-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); font-size: 0.9rem; }

/* Collapsed to icons; only on wide screens, the drawer below always shows labels. */
@media (min-width: 861px) {
  .side-collapsed { --side-w: 64px; }
  .side-collapsed .sidebar { padding: 12px 8px; }
  .side-collapsed .label { display: none; }
  .side-collapsed .side-top { flex-direction: column; padding-bottom: 6px; }
  .side-collapsed .side-collapse svg { transform: rotate(180deg); }
  .side-collapsed .switcher summary { justify-content: center; padding: 6px; }
  .side-collapsed .switcher-menu { position: absolute; top: 0; left: calc(100% + 10px); width: 240px; margin: 0; }
  .side-collapsed .side-nav a, .side-collapsed .side-nav button { justify-content: center; padding: 0; }
  .side-collapsed .side-me { flex-direction: column; }
}

.mobilebar, .nav-scrim { display: none; }

@media (max-width: 860px) {
  .shell { display: block; }
  /* Hidden once off screen, so keyboard focus cannot land in the closed drawer. */
  .sidebar { position: fixed; inset: 0 auto 0 0; z-index: 40; width: min(280px, 86vw); visibility: hidden; transform: translateX(-102%); transition: transform 0.2s ease-out, visibility 0s 0.2s; box-shadow: var(--shadow-raised); }
  .nav-open .sidebar { visibility: visible; transform: none; transition: transform 0.2s ease-out; }
  .nav-open .nav-scrim { display: block; position: fixed; inset: 0; z-index: 35; background: rgb(10 12 18 / 40%); }
  .side-collapse { display: none; }
  .mobilebar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    border-bottom: 1px solid color-mix(in srgb, var(--border) 60%, transparent);
    background: color-mix(in srgb, var(--bg) 85%, transparent);
    backdrop-filter: saturate(160%) blur(12px);
  }
  .shell .container { padding: 14px 14px 96px; }
}

.crumbs ol { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; margin: 0 0 16px; padding: 0; list-style: none; color: var(--muted); font-size: 0.86rem; }
.crumbs li { display: flex; align-items: center; gap: 6px; min-width: 0; }
.crumbs li + li::before { content: "/"; color: color-mix(in srgb, var(--muted) 55%, transparent); }
.crumbs a { color: var(--muted); text-decoration: none; overflow-wrap: anywhere; }
.crumbs a:hover { color: var(--accent); text-decoration: underline; }
.crumbs [aria-current] { color: var(--text); font-weight: 600; overflow-wrap: anywhere; }

/* Sign-in */

.signin { min-height: 70vh; display: grid; place-items: center; }
.signin-card {
  max-width: 400px;
  padding: 44px 36px;
  border-radius: 24px;
  background: var(--surface);
  box-shadow: var(--shadow-raised);
  text-align: center;
}
.signin-card h1 { margin: 18px 0 8px; }
.signin-card p { margin: 0 0 28px; }
.signin-logo { filter: drop-shadow(0 8px 20px rgb(99 102 241 / 35%)); }
.signin-page .topbar { display: none; }

/* Project cards */

.cards { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; }
.card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 118px;
  padding: 18px 18px 16px 22px;
  overflow: hidden;
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  text-decoration: none;
  transition: transform 0.15s, box-shadow 0.15s;
}
.card:hover { transform: translateY(-2px); box-shadow: var(--shadow-raised); }
.card-accent { position: absolute; inset: 0 auto 0 0; width: 5px; background: var(--c, var(--accent)); }
.card::after {
  content: "";
  position: absolute;
  inset: auto -30% -60% auto;
  width: 160px;
  height: 160px;
  border-radius: 50%;
  background: radial-gradient(circle, color-mix(in srgb, var(--c, var(--accent)) 22%, transparent), transparent 70%);
  pointer-events: none;
}
.card-title { font-size: 1.08rem; font-weight: 650; }
.card-meta { margin-top: auto; display: flex; flex-wrap: wrap; gap: 6px 12px; color: var(--muted); font-size: 0.86rem; }
.card-meta .overdue { color: var(--danger); font-weight: 600; }

.empty-state { display: grid; justify-items: center; gap: 10px; padding: 64px 16px; text-align: center; }
.empty-state svg { width: 40px; height: 40px; color: var(--muted); }
.empty-state p { margin: 0 0 8px; }

/* Board */

.board { --accent: var(--c, #5b5bd6); }
.project-head { display: flex; align-items: center; gap: 10px; margin-bottom: 18px; flex-wrap: wrap; }
.project-head h1 { overflow-wrap: anywhere; }
.dot { width: 14px; height: 14px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 20%, transparent); }
.badge { padding: 2px 9px; border-radius: 999px; background: var(--surface-2); color: var(--muted); font-size: 0.78rem; font-weight: 600; text-transform: capitalize; }

.filters { display: flex; flex-wrap: wrap; gap: 8px; margin: -4px 0 18px; }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 28px;
  padding: 0 11px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: color-mix(in srgb, var(--c, var(--accent)) 14%, var(--surface));
  color: color-mix(in srgb, var(--c, var(--accent)) var(--c-ink, 72%), var(--text));
  font-size: 0.85rem;
  font-weight: 600;
  white-space: nowrap;
  transition: none;
}
.pill.small { min-height: 22px; padding: 0 8px; font-size: 0.76rem; }
button.pill:hover { border-color: color-mix(in srgb, var(--c) 45%, transparent); }
button.pill.active { background: var(--c); color: var(--on-c, #fff); box-shadow: 0 2px 10px color-mix(in srgb, var(--c) 35%, transparent); }

.section {
  margin-bottom: 16px;
  padding: 8px 8px 6px;
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}
.section h2 { display: flex; align-items: center; gap: 8px; padding: 10px 12px 6px; }
.count { padding: 1px 8px; border-radius: 999px; background: var(--surface-2); color: var(--muted); font-size: 0.75rem; font-weight: 600; }

.tasks { list-style: none; margin: 0; padding: 0; }
.task { display: flex; align-items: flex-start; gap: 4px; padding: 2px 4px; border-radius: var(--radius-small); }
.task:hover { background: var(--surface-2); }

.check {
  width: 22px;
  min-height: 22px;
  height: 22px;
  margin: 11px 8px 0 6px;
  padding: 0;
  border: 2px solid color-mix(in srgb, var(--accent) 55%, var(--border));
  border-radius: 50%;
  background: transparent;
  color: transparent;
  transition: none;
}
.check svg { width: 14px; height: 14px; stroke-width: 3; }
.check:hover:not(:disabled) { background: color-mix(in srgb, var(--accent) 12%, transparent); color: color-mix(in srgb, var(--accent) 60%, transparent); }
.check:disabled { opacity: 0.45; }
.is-done .check { border-color: var(--accent); background: var(--accent); color: #fff; }
.task.is-toggling .check { animation: pop 0.35s ease-out; border-color: var(--accent); background: var(--accent); color: #fff; }

.task-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  min-width: 0;
  min-height: 44px;
  padding: 10px 8px;
  border: 0;
  border-radius: var(--radius-small);
  background: transparent;
  text-align: left;
  font-weight: 450;
}
.task-main:hover { border: 0; }
.task-main:active { transform: none; }
.task-title { overflow-wrap: anywhere; }
.is-done .task-title { color: var(--muted); text-decoration: line-through; text-decoration-color: color-mix(in srgb, var(--muted) 60%, transparent); }
.task-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; }
.due { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); font-size: 0.8rem; font-weight: 550; }
.due svg { width: 14px; height: 14px; }
.due.today { color: var(--accent); }
.due.overdue { color: var(--danger); }
.notes-mark { display: inline-flex; color: var(--muted); }
.notes-mark svg { width: 14px; height: 14px; }

.quick-add { display: flex; align-items: center; gap: 10px; margin: 2px 4px; padding: 0 10px; border-radius: var(--radius-small); color: var(--muted); }
.quick-add:focus-within { background: var(--surface-2); color: var(--accent); }
.quick-add input { flex: 1; min-height: 42px; border: 0; background: transparent; color: var(--text); font: inherit; outline: none; }
.quick-add input::placeholder { color: var(--muted); }

.done { margin: 4px 4px 6px; }
.done summary { padding: 8px 10px; border-radius: var(--radius-small); color: var(--muted); font-size: 0.86rem; font-weight: 600; cursor: pointer; list-style: none; }
.done summary::-webkit-details-marker { display: none; }
.done summary::before { content: "›"; display: inline-block; margin-right: 8px; transition: transform 0.15s; }
.done[open] summary::before { transform: rotate(90deg); }
.done summary:hover { background: var(--surface-2); }

/* Dialogs */

dialog.sheet {
  width: min(560px, calc(100vw - 24px));
  max-height: calc(100vh - 48px);
  padding: 0;
  border: 0;
  border-radius: 20px;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-raised);
}
dialog.sheet.wide { width: min(680px, calc(100vw - 24px)); }
dialog.sheet[open] { animation: rise 0.18s ease-out; }
dialog::backdrop { background: rgb(10 12 18 / 40%); backdrop-filter: blur(3px); }
.sheet > form, .sheet-inner { display: flex; flex-direction: column; gap: 14px; padding: 20px 22px 22px; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.sheet-foot { display: flex; align-items: center; gap: 8px; margin-top: 4px; }
.sheet-foot .primary { min-width: 96px; }

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; margin: 0; padding: 0; border: 0; }
.field > span, .field > legend { color: var(--muted); font-size: 0.82rem; font-weight: 600; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
input, select, textarea {
  width: 100%;
  min-height: 40px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-small);
  background: var(--surface);
  color: var(--text);
  font: inherit;
}
textarea { resize: vertical; min-height: 96px; line-height: 1.5; }
input:disabled, select:disabled, textarea:disabled { background: var(--surface-2); opacity: 1; }
.due-input { display: flex; align-items: center; gap: 4px; }
.label-picker { display: flex; flex-wrap: wrap; gap: 8px; }
.label-picker label { cursor: pointer; }
.label-picker input { position: absolute; opacity: 0; width: 1px; height: 1px; pointer-events: none; }
.label-picker .pill { opacity: 0.55; border-color: transparent; }
.label-picker .pill:has(input:checked) { opacity: 1; background: var(--c); color: var(--on-c, #fff); }
.label-picker .pill:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.task-meta.muted, p.task-meta { margin: 0; font-size: 0.82rem; }

.settings-block { display: flex; flex-direction: column; gap: 10px; padding-top: 14px; border-top: 1px solid var(--border); }
.settings-block:first-child { padding-top: 0; border-top: 0; }
.subhead { color: var(--muted); font-size: 0.8rem; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; }
.inline-row { display: flex; align-items: center; gap: 8px; }
.inline-row input:not([type="color"]) { flex: 1; }
input[type="color"] { width: 42px; min-height: 40px; padding: 4px; cursor: pointer; }

.swatches { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.swatch {
  width: 28px;
  min-height: 28px;
  height: 28px;
  padding: 0;
  border: 2px solid var(--surface);
  border-radius: 50%;
  background: var(--c);
  box-shadow: 0 0 0 1px var(--border);
}
.swatch.selected { box-shadow: 0 0 0 2px var(--c); }
.swatch-custom { width: 36px; min-height: 32px; border-radius: 999px; }

.people { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.person { display: flex; align-items: center; gap: 10px; padding: 6px 4px; border-radius: var(--radius-small); }
.person-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.person-text .email { color: var(--muted); font-size: 0.82rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.person select { width: auto; min-height: 32px; padding: 4px 8px; }
.person .badge { margin-right: 4px; }


/* Status icons, shared by workflow pages and task rows */

.st {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 18px;
  height: 18px;
  border: 2px solid currentColor;
  border-radius: 50%;
}
.st svg { width: 10px; height: 10px; stroke-width: 3.2; }
.st-done { color: var(--ok); background: color-mix(in srgb, var(--ok) 14%, var(--surface)); }
.st-skipped { color: var(--muted); }
.st-skipped::after { content: ""; width: 8px; height: 2px; background: currentColor; border-radius: 1px; }
.st-active { color: var(--info); background: conic-gradient(var(--info) 0 50%, transparent 50% 100%); background-clip: content-box; padding: 2px; }
.st-late { color: var(--danger); background: color-mix(in srgb, var(--danger) 14%, var(--surface)); }
.st-waiting { color: var(--muted); border-style: dashed; }

/* Workflow list */

.toolbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.tabs { display: flex; gap: 4px; flex-wrap: wrap; }
.tab { min-height: 32px; padding: 0 12px; border-color: transparent; background: transparent; color: var(--muted); font-size: 0.9rem; }
.tab:hover { background: var(--surface-2); border-color: transparent; }
a.tab { display: inline-flex; align-items: center; gap: 6px; border: 1px solid transparent; border-radius: 999px; font-weight: 550; text-decoration: none; }
.tab.on { background: var(--surface); border-color: var(--border); color: var(--text); box-shadow: var(--shadow); }
.n { padding: 1px 7px; border-radius: 999px; background: var(--surface-2); color: var(--muted); font-size: 0.75rem; font-variant-numeric: tabular-nums; }

.wf-rows { list-style: none; margin: 0; padding: 0; border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); overflow: hidden; }
.wf-row {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(0, 1.2fr) 150px 40px;
  gap: 16px;
  align-items: center;
  padding: 14px 18px;
  border-top: 1px solid var(--border);
}
.wf-row:first-child { border-top: 0; }
.wf-row:hover { background: color-mix(in srgb, var(--surface-2) 60%, var(--surface)); }
.wf-name { display: flex; flex-direction: column; gap: 3px; min-width: 0; font-weight: 650; text-decoration: none; }
.wf-name:hover span { color: var(--accent); }
.wf-name small { color: var(--muted); font-weight: 450; font-size: 0.84rem; }
.wf-name .late, .late-pill { color: var(--danger); }
.mini { display: flex; align-items: center; flex-wrap: wrap; row-gap: 4px; }
.mini .st { width: 16px; height: 16px; }
.mini .link { width: 14px; height: 2px; background: var(--border); }
.mini .link.ok { background: var(--ok); }
.wf-percent { display: flex; flex-direction: column; gap: 6px; font-size: 0.8rem; color: var(--muted); }
.wf-owner { display: flex; justify-content: flex-end; }
.mono { font-family: ui-monospace, "SFMono-Regular", Menlo, monospace; font-variant-numeric: tabular-nums; }
.empty-filter { padding: 24px; text-align: center; }

progress {
  width: 100%;
  height: 8px;
  border: 0;
  border-radius: 999px;
  background: var(--surface-2);
  overflow: hidden;
  appearance: none;
}
progress::-webkit-progress-bar { background: var(--surface-2); border-radius: 999px; }
progress::-webkit-progress-value { background: var(--ok); border-radius: 999px; }
progress::-moz-progress-bar { background: var(--ok); border-radius: 999px; }

/* Workflow page */

.wf-title { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.wf-title h1 { font-size: 1.3rem; overflow-wrap: anywhere; }
.status-badge { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px 4px 5px; border-radius: 999px; font-size: 0.8rem; font-weight: 650; }
.status-badge .st { width: 16px; height: 16px; }
.status-running { color: var(--info); background: color-mix(in srgb, var(--info) 13%, var(--surface)); }
.status-not_started { color: var(--muted); background: var(--surface-2); }
.status-done, .status-finished { color: var(--ok); background: color-mix(in srgb, var(--ok) 13%, var(--surface)); }
.wf-progress-line { display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; align-items: center; margin-bottom: 18px; font-size: 0.92rem; }
.wf-progress-line progress { grid-column: 1 / -1; }

.wf-layout { display: grid; grid-template-columns: minmax(0, 1fr) 240px; gap: 20px; align-items: start; }
.pipeline {
  display: flex;
  gap: 28px;
  padding: 16px;
  overflow-x: auto;
  border-radius: var(--radius);
  background: var(--surface-2);
}
/* Stages share the width; beyond what fits (about four), the pipeline scrolls sideways. */
.stage { position: relative; display: flex; flex-direction: column; gap: 10px; flex: 1 1 190px; min-width: 190px; }
.stage + .stage::before {
  content: "";
  position: absolute;
  top: 9px;
  left: -28px;
  width: 28px;
  height: 2px;
  background: var(--border);
}
.stage-done + .stage::before, .stage-done + .stage-active::before { background: var(--ok); }
.stage-name { display: flex; align-items: center; gap: 8px; font-size: 0.78rem; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; color: var(--muted); }
.stage-name .count { margin-left: auto; padding: 1px 7px; border-radius: 999px; background: var(--surface); font-size: 0.72rem; letter-spacing: 0; font-variant-numeric: tabular-nums; }
.jobs { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.job {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px 3px 3px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface);
}
.job-active, .job-late { border-color: color-mix(in srgb, var(--info) 45%, var(--border)); box-shadow: 0 0 0 3px color-mix(in srgb, var(--info) 12%, transparent); }
.job-late { border-color: color-mix(in srgb, var(--danger) 45%, var(--border)); box-shadow: 0 0 0 3px color-mix(in srgb, var(--danger) 10%, transparent); }
.job-status { width: 30px; min-height: 30px; padding: 0; border: 0; background: transparent; }
.job-status:hover:not(:disabled) { background: var(--surface-2); }
.job-status:disabled { opacity: 1; }
/* The title comes first; the due time goes on its own line so it never squeezes the title. */
.job-main { flex: 1; min-width: 0; min-height: 30px; flex-direction: column; align-items: flex-start; justify-content: center; gap: 1px; padding: 4px; border: 0; background: transparent; font-weight: 500; font-size: 0.9rem; text-align: left; }
.job-main:hover { border: 0; color: var(--accent); }
.job-main:active { transform: none; }
.job-title { overflow-wrap: anywhere; line-height: 1.3; }
.job-skipped .job-title, .job-done .job-title { color: var(--muted); }
.job-skipped .job-title { text-decoration: line-through; }
.job .due { font-size: 0.74rem; white-space: nowrap; }
.job .avatar { width: 24px; height: 24px; font-size: 0.62rem; flex: none; }
.stage .quick-add { margin: 0; border: 1px dashed var(--border); border-radius: 999px; background: color-mix(in srgb, var(--surface) 50%, transparent); }
.stage .quick-add input { min-height: 34px; font-size: 0.88rem; }
.job.is-toggling .st { animation: pop 0.35s ease-out; }

.wf-panel { display: flex; flex-direction: column; gap: 14px; padding: 16px; border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); font-size: 0.9rem; }
.kv { display: flex; flex-direction: column; gap: 4px; }
.kv > span:first-child { color: var(--muted); font-size: 0.78rem; font-weight: 650; }
.who-line { display: flex; align-items: center; gap: 8px; }
.stepper { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; }
.stepper .chev { color: var(--muted); }
.step-done { color: var(--ok); }
.step-active { color: var(--info); font-weight: 700; }
.step-waiting { color: var(--muted); }
.late-pill { display: inline-block; padding: 2px 9px; border-radius: 999px; background: color-mix(in srgb, var(--danger) 13%, var(--surface)); font-weight: 650; font-size: 0.8rem; }
.wf-description { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }

/* Board additions */

.flow-chip { display: inline-flex; align-items: center; gap: 4px; padding: 1px 8px 1px 6px; border-radius: 999px; background: color-mix(in srgb, var(--info) 11%, var(--surface)); color: color-mix(in srgb, var(--info) 80%, var(--text)); font-size: 0.75rem; font-weight: 600; }
.flow-chip svg { width: 13px; height: 13px; }
.skipped-mark { color: var(--muted); font-size: 0.75rem; font-weight: 650; text-transform: uppercase; letter-spacing: 0.04em; }
.is-skipped .task-title { text-decoration-style: dashed; }
.task-assignee { width: 26px; height: 26px; margin: 10px 6px 0 0; font-size: 0.62rem; flex: none; }

/* Stage editor */

.stage-list { margin: 0; padding: 0 0 0 22px; display: flex; flex-direction: column; gap: 8px; }
.stage-edit { display: flex; align-items: center; gap: 4px; }
.stage-edit input { flex: 1; }
.hint { margin: 0; font-size: 0.86rem; }

@media (max-width: 760px) {
  .wf-layout { grid-template-columns: 1fr; }
  .wf-row { grid-template-columns: minmax(0, 1fr) auto; }
  .wf-percent, .wf-owner { display: none; }
  .pipeline { flex-direction: column; gap: 22px; }
  .stage { flex: none; }
  .stage + .stage::before { top: -22px; left: 8px; width: 2px; height: 22px; }
}

/* Task list */

.filter-bar { display: flex; flex-direction: column; gap: 10px; margin-bottom: 14px; padding: 12px; border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.filter-box {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  min-height: 42px;
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-small);
  background: var(--bg);
}
.filter-box:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); }
.filter-box > svg { color: var(--muted); }
.filter-box input { flex: 1; min-width: 160px; min-height: 32px; padding: 0 4px; border: 0; background: transparent; }
.filter-box input:focus-visible { outline: none; }
.token { display: inline-flex; align-items: stretch; overflow: hidden; border-radius: 7px; font-size: 0.8rem; font-weight: 600; }
.token-key { padding: 3px 7px; background: var(--surface-2); color: var(--muted); }
.token-value, .token a { background: color-mix(in srgb, var(--c, var(--info)) 14%, var(--surface)); color: color-mix(in srgb, var(--c, var(--info)) var(--c-ink, 72%), var(--text)); }
.token-value { padding: 3px 4px 3px 7px; max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.token a { display: grid; place-items: center; padding: 0 6px 0 3px; }
.token a:hover { color: var(--danger); }
.token svg { width: 13px; height: 13px; }
.filter-picks { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.filter-picks select { width: auto; max-width: 170px; min-height: 32px; padding: 3px 10px; border-radius: 999px; color: var(--muted); font-size: 0.86rem; font-weight: 600; cursor: pointer; }
.filter-picks select:hover { border-color: color-mix(in srgb, var(--text) 25%, var(--border)); }
.sort { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 0.86rem; font-weight: 600; }
.clear { color: var(--accent); font-size: 0.86rem; font-weight: 600; text-decoration: none; }
.clear:hover { text-decoration: underline; }

.issues { list-style: none; margin: 0; padding: 0; overflow: hidden; border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.issue { display: flex; align-items: flex-start; gap: 8px; padding: 10px 16px 10px 10px; border-top: 1px solid var(--border); }
.issue:first-child { border-top: 0; }
.issue:hover { background: color-mix(in srgb, var(--surface-2) 55%, var(--surface)); }
span.job-status { display: inline-grid; place-items: center; flex: none; width: 30px; height: 30px; }
.issue-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; padding-top: 4px; }
.issue-line { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.issue-title { font-weight: 600; text-decoration: none; overflow-wrap: anywhere; }
.issue-title:hover { color: var(--accent); text-decoration: underline; }
.issue.is-done .issue-title { color: var(--muted); }
.issue.is-skipped .issue-title { text-decoration: line-through; }
.issue-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; color: var(--muted); font-size: 0.8rem; }
.issue-side { display: flex; align-items: center; gap: 10px; flex: none; padding-top: 2px; color: var(--muted); font-size: 0.78rem; }
.issue-side .avatar { width: 26px; height: 26px; font-size: 0.62rem; }
.issue.issue-add { padding: 4px 8px; }
.issue-add .quick-add { flex: 1; margin: 0; }
.issue-add:hover { background: transparent; }

/* Task page */

.issue-head { display: flex; flex-direction: column; gap: 10px; margin-bottom: 18px; padding-bottom: 16px; border-bottom: 1px solid var(--border); }
.issue-head-line { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; font-size: 0.9rem; }
.issue-heading { font-size: 1.55rem; overflow-wrap: anywhere; }
.status-open { color: var(--info); background: color-mix(in srgb, var(--info) 13%, var(--surface)); }
.status-late { color: var(--danger); background: color-mix(in srgb, var(--danger) 12%, var(--surface)); }
.status-skipped { color: var(--muted); background: var(--surface-2); }
.issue-body { display: flex; flex-direction: column; gap: 10px; min-height: 140px; padding: 18px 20px; border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.notes { margin: 0; line-height: 1.6; white-space: pre-wrap; overflow-wrap: anywhere; }
.pills { display: flex; flex-wrap: wrap; gap: 6px; }
.wf-panel a { color: var(--accent); font-weight: 600; text-decoration: none; }
.wf-panel a:hover { text-decoration: underline; }

@media (max-width: 640px) {
  .updated { display: none; }
  .issue-heading { font-size: 1.3rem; }
}

/* Needs */

.pipeline { position: relative; }
.pipeline .stage { z-index: 1; }
/* Overrides the icon size every svg gets; the script sets the real size. */
.needs-lines { position: absolute; top: 0; left: 0; z-index: 0; width: auto; height: auto; overflow: visible; pointer-events: none; stroke: none; }
.need-line { fill: none; stroke: color-mix(in srgb, var(--info) 55%, var(--border)); stroke-width: 2; transition: opacity 0.15s; }
.pipeline.focusing .need-line { opacity: 0.2; }
.pipeline.focusing .need-line.hl { opacity: 1; stroke: var(--info); stroke-width: 2.5; }
.pipeline.focusing .job:not(.related) { opacity: 0.55; }
.job { transition: opacity 0.15s; }
.needs-chip { color: color-mix(in srgb, var(--info) 80%, var(--text)); font-size: 0.72rem; font-weight: 600; }
.task-links { display: flex; flex-direction: column; gap: 4px; }
.task-links a.closed { color: var(--muted); text-decoration: line-through; }
.needs-picker { display: flex; flex-direction: column; gap: 2px; max-height: 190px; overflow-y: auto; }
.need-option { display: flex; align-items: center; gap: 8px; padding: 4px 2px; font-size: 0.9rem; cursor: pointer; }
.need-option input { width: auto; min-height: 0; }

/* Templates */

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

/* Devices */

.lead { max-width: 640px; margin: -8px 0 18px; }
.devices .issue { align-items: center; }
.devices .issue-title { font-weight: 600; }
.side-me a.icon { display: inline-grid; place-items: center; border-radius: 999px; }
.side-me a.icon.on { color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, var(--surface)); }

/* Your work */

.page-title { margin-bottom: 18px; }
.work-section { margin-bottom: 22px; }
.work-head { display: flex; align-items: center; gap: 8px; margin: 0 0 10px; font-size: 1rem; }
.work-late .work-head { color: var(--danger); }
.work-project { display: inline-flex; align-items: center; gap: 6px; color: var(--text); font-weight: 600; text-decoration: none; }
.work-project:hover { color: var(--accent); }
.work-project .tile { width: 18px; height: 18px; border-radius: 5px; font-size: 0.6rem; }
a.flow-chip { text-decoration: none; }
a.flow-chip:hover { text-decoration: underline; }
.waits { font-style: italic; }
.side-badge { margin-left: auto; min-width: 22px; padding: 1px 7px; border-radius: 999px; background: var(--accent); color: #fff; font-size: 0.72rem; font-weight: 700; text-align: center; font-variant-numeric: tabular-nums; }
@media (min-width: 861px) {
  .side-collapsed .side-nav a { position: relative; }
  .side-collapsed .side-badge { position: absolute; top: 2px; right: 4px; min-width: 16px; padding: 0 4px; font-size: 0.62rem; }
}

/* Activity */

.feed { list-style: none; margin: 0; padding: 4px 18px; border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.feed .day { padding: 14px 0 6px; color: var(--muted); font-size: 0.78rem; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; }
.feed .day:first-child { padding-top: 10px; }
.event { position: relative; display: flex; align-items: flex-start; gap: 12px; padding: 8px 0 8px 18px; }
/* A line through the markers, as on a timeline. */
.event::before { content: ""; position: absolute; top: 0; bottom: 0; left: 4px; width: 2px; background: var(--border); }
.event::after { content: ""; position: absolute; top: 16px; left: 0; width: 10px; height: 10px; border: 2px solid var(--surface); border-radius: 50%; background: var(--tone, var(--muted)); }
.ev-create { --tone: var(--accent); }
.ev-done { --tone: var(--ok); }
.ev-edit { --tone: var(--muted); }
.ev-flow { --tone: var(--info); }
.ev-people { --tone: var(--warning); }
.ev-remove { --tone: var(--danger); }
.event .avatar { width: 28px; height: 28px; flex: none; font-size: 0.66rem; }
.ev-text { margin: 4px 0 0; min-width: 0; overflow-wrap: anywhere; font-size: 0.92rem; }
.ev-text a { color: var(--accent); font-weight: 600; text-decoration: none; }
.ev-text a:hover { text-decoration: underline; }
.ev-object { font-weight: 600; }
.ev-time { margin-left: 4px; color: var(--muted); font-size: 0.82rem; white-space: nowrap; }
.feed-pages { display: flex; align-items: center; gap: 8px; margin-top: 14px; }
.feed.compact { padding: 4px 16px; box-shadow: none; background: transparent; }
.issue-col { display: flex; flex-direction: column; gap: 18px; min-width: 0; }
.timeline .subhead { margin: 0 0 4px; }

/* Toast */

.toast {
  position: fixed;
  inset: auto auto 24px 50%;
  margin: 0;
  max-width: calc(100vw - 32px);
  padding: 12px 18px;
  border: 0;
  border-radius: 12px;
  background: #1f2330;
  color: #fff;
  box-shadow: var(--shadow-raised);
  font-weight: 550;
  transform: translateX(-50%);
  animation: rise 0.2s ease-out;
}
.toast.error { background: var(--danger); }

@keyframes rise { from { opacity: 0; transform: translateY(10px) scale(0.98); } }
@keyframes pop { 40% { transform: scale(1.25); } }

@media (max-width: 640px) {
  h1 { font-size: 1.35rem; }
  .container { padding-top: 18px; }
  .me-name { display: none; }
  .field-row { grid-template-columns: 1fr; }
  .avatars { display: none; }
  dialog.sheet { margin: auto auto 0; width: 100vw; max-width: 100vw; border-radius: 20px 20px 0 0; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
