:root {
  --bg: #0d0f11;
  --surface: #131619;
  --surface-2: #191d21;
  --surface-3: #20252a;
  --border: #2b3036;
  --border-strong: #3b424a;
  --text: #f1f2f3;
  --muted: #9da3aa;
  --dim: #6f767e;
  --accent: #e6a23c;
  --accent-strong: #f3b654;
  --danger: #ef6b73;
  --ok: #6fca98;
  --radius: 10px;
  font-family: "IBM Plex Sans", "Segoe UI", system-ui, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; min-height: 100%; }
body { min-height: 100dvh; background: var(--bg); color: var(--text); }
button, input, textarea, select { font: inherit; }
button { color: inherit; }
button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
button:disabled { cursor: not-allowed; opacity: .45; }
.skip-link { position: fixed; top: 8px; left: 8px; z-index: 100; transform: translateY(-150%); padding: 10px 14px; background: var(--accent); color: #17110a; font-weight: 750; }
.skip-link:focus { transform: none; }

.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; min-height: 62px; padding: 10px 18px; border-bottom: 1px solid var(--border); background: rgba(13, 15, 17, .96); }
.brand { display: inline-flex; align-items: center; gap: 8px; color: var(--text); text-decoration: none; font-size: 15px; letter-spacing: -.02em; }
.brand strong { color: var(--muted); font-weight: 600; }
.brand-mark { display: grid; place-items: center; width: 30px; height: 30px; border: 1px solid #6e5126; border-radius: 7px; background: #261d10; color: var(--accent-strong); font: 800 14px/1 ui-monospace, monospace; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.health { display: inline-flex; align-items: center; gap: 8px; margin-right: 6px; color: var(--muted); font-size: 12px; }
.health > span { width: 7px; height: 7px; border-radius: 50%; background: var(--danger); }
.health.ok > span { background: var(--ok); box-shadow: 0 0 0 3px rgba(111, 202, 152, .12); }

.button, .icon-button, .view-button { min-height: 40px; border: 1px solid var(--border-strong); border-radius: 8px; background: var(--surface-2); cursor: pointer; font-size: 13px; font-weight: 700; }
.button { padding: 9px 14px; }
.button:hover, .icon-button:hover, .view-button:hover { border-color: #555e67; background: var(--surface-3); }
.button.primary { border-color: #9d6b25; background: var(--accent); color: #181108; }
.button.primary:hover { border-color: var(--accent-strong); background: var(--accent-strong); }
.button.secondary { background: transparent; }
.icon-button { padding: 8px 11px; color: var(--muted); }

.workspace { display: grid; grid-template-columns: 236px minmax(0, 1fr); min-height: calc(100dvh - 62px); }
.sidebar { position: sticky; top: 62px; display: flex; flex-direction: column; height: calc(100dvh - 62px); border-right: 1px solid var(--border); background: var(--surface); }
.sidebar-heading { display: flex; justify-content: space-between; align-items: center; padding: 18px 16px 10px; color: var(--muted); font-size: 11px; font-weight: 800; letter-spacing: .09em; text-transform: uppercase; }
.count { display: grid; min-width: 22px; height: 22px; place-items: center; border: 1px solid var(--border); border-radius: 7px; font: 11px/1 ui-monospace, monospace; }
.sidebar-tools { display: flex; align-items: center; gap: 6px; }
.sidebar-tools button { min-height: 28px; padding: 4px 7px; border: 1px solid var(--border); border-radius: 7px; background: transparent; color: var(--muted); cursor: pointer; font-size: 10px; font-weight: 800; text-transform: uppercase; }
.sidebar-tools button:hover { border-color: var(--border-strong); color: var(--text); }
.project-list { display: grid; gap: 3px; padding: 4px 8px; overflow-y: auto; }
.project-button { display: grid; grid-template-columns: 34px minmax(0, 1fr); gap: 10px; align-items: center; width: 100%; min-height: 50px; padding: 7px 8px; border: 1px solid transparent; border-radius: 8px; background: transparent; text-align: left; cursor: pointer; }
.project-button:hover { background: var(--surface-2); }
.project-button.active { border-color: #564121; background: #211a10; }
.project-mark { display: grid; width: 32px; height: 32px; place-items: center; border: 1px solid var(--border-strong); border-radius: 7px; color: var(--muted); font: 700 11px/1 ui-monospace, monospace; }
.project-button.active .project-mark { border-color: #765629; color: var(--accent); }
.project-button strong, .project-button small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.project-button strong { font-size: 13px; }
.project-button small { margin-top: 2px; color: var(--dim); font-size: 11px; }
.sidebar-footer { margin-top: auto; padding: 16px; border-top: 1px solid var(--border); color: var(--dim); font: 10px/1.6 ui-monospace, monospace; text-transform: uppercase; }
.sidebar-footer p { margin: 0; }

.content { min-width: 0; overflow: hidden; }
.project-header { display: flex; align-items: end; justify-content: space-between; gap: 24px; min-height: 142px; padding: 28px 28px 22px; border-bottom: 1px solid var(--border); }
.overline { margin: 0 0 7px; color: var(--accent); font: 700 11px/1.3 ui-monospace, monospace; letter-spacing: .08em; text-transform: uppercase; }
h1, h2, h3, p { overflow-wrap: anywhere; }
h1 { margin: 0; font-size: clamp(25px, 3vw, 36px); line-height: 1.1; letter-spacing: -.035em; }
.project-repos { margin: 9px 0 0; color: var(--muted); font: 12px/1.5 ui-monospace, monospace; }
.view-actions { display: flex; gap: 2px; padding: 3px; border: 1px solid var(--border); border-radius: 9px; background: var(--surface); }
.view-button { min-height: 34px; padding: 6px 10px; border-color: transparent; background: transparent; color: var(--muted); }
.view-button.active { background: var(--surface-3); color: var(--text); }

.board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(250px, 1fr); gap: 1px; min-height: calc(100dvh - 205px); overflow-x: auto; background: var(--border); scroll-snap-type: x proximity; }
.column { min-width: 0; background: var(--bg); scroll-snap-align: start; }
.column > header { display: flex; align-items: center; justify-content: space-between; min-height: 51px; padding: 10px 12px; border-bottom: 1px solid var(--border); background: var(--surface); }
.column h2 { margin: 0; font-size: 12px; letter-spacing: .02em; }
.column header span { color: var(--dim); font: 11px/1 ui-monospace, monospace; }
.card-list { display: grid; align-content: start; gap: 8px; min-height: 180px; padding: 10px; }
.column-empty { margin: 8px 2px; color: #555c63; font-size: 12px; }
.task-card { position: relative; display: grid; gap: 10px; width: 100%; padding: 12px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); text-align: left; cursor: pointer; }
.task-card::before { position: absolute; inset: 0 auto 0 0; width: 2px; border-radius: var(--radius) 0 0 var(--radius); background: #687079; content: ""; }
.task-card.priority-high::before, .task-card.priority-critical::before { background: var(--accent); }
.task-card.priority-critical::before { background: var(--danger); }
.task-card:hover { border-color: var(--border-strong); background: var(--surface-2); transform: translateY(-1px); }
.card-topline { display: flex; justify-content: space-between; gap: 12px; color: var(--dim); font: 10px/1.3 ui-monospace, monospace; text-transform: uppercase; }
.task-card > strong { font-size: 13px; line-height: 1.4; }
.task-card > small { color: var(--muted); font: 10px/1.3 ui-monospace, monospace; }
.blocked { width: fit-content; padding: 3px 6px; border: 1px solid #703d43; border-radius: 5px; color: #ff9299; font-size: 10px; font-weight: 750; text-transform: uppercase; }

.empty-state { width: min(560px, calc(100% - 40px)); margin: 11vh auto; padding: 38px 0; border-top: 1px solid var(--border-strong); border-bottom: 1px solid var(--border); }
.empty-index { color: var(--dim); font: 12px/1 ui-monospace, monospace; }
.empty-state h2 { margin: 34px 0 12px; font-size: clamp(28px, 5vw, 48px); letter-spacing: -.045em; }
.empty-state p { max-width: 52ch; margin: 0 0 24px; color: var(--muted); line-height: 1.65; }
.loading-board { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1px; height: calc(100dvh - 205px); background: var(--border); }
.loading-board div { background: linear-gradient(100deg, var(--bg) 25%, var(--surface) 50%, var(--bg) 75%); background-size: 200% 100%; animation: load 1.2s linear infinite; }
@keyframes load { to { background-position: -200% 0; } }

.frontier { padding: 32px 28px; }
.frontier-heading { max-width: 680px; padding-bottom: 24px; border-bottom: 1px solid var(--border); }
.frontier-heading h2 { margin: 8px 0; font-size: 26px; }
.frontier-heading > p:last-child, .frontier-empty { color: var(--muted); }
.frontier-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 10px; margin-top: 22px; }
.frontier-empty { padding: 28px 0; }

.dialog { width: min(560px, calc(100vw - 28px)); max-height: calc(100dvh - 40px); padding: 0; border: 1px solid var(--border-strong); border-radius: 12px; background: var(--surface); color: var(--text); box-shadow: 0 26px 90px rgba(0, 0, 0, .58); }
.dialog::backdrop { background: rgba(2, 3, 4, .76); backdrop-filter: blur(3px); }
.dialog form { display: grid; gap: 17px; padding: 22px; }
.dialog-heading { display: flex; justify-content: space-between; gap: 20px; align-items: start; padding-bottom: 16px; border-bottom: 1px solid var(--border); }
.dialog h2 { margin: 0; font-size: 23px; letter-spacing: -.025em; }
.dialog h3 { margin: 0; font-size: 13px; }
.dialog-copy, .gate-copy { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.6; }
.dialog label { display: grid; gap: 7px; color: var(--muted); font-size: 12px; font-weight: 700; }
.dialog input, .dialog textarea, .dialog select { width: 100%; min-height: 42px; padding: 10px 11px; border: 1px solid var(--border-strong); border-radius: 8px; background: var(--bg); color: var(--text); }
.dialog textarea { resize: vertical; }
.dialog small { color: var(--dim); font-weight: 500; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; padding-top: 4px; }
.dialog-actions.left { justify-content: flex-start; flex-wrap: wrap; }
.detail-meta { display: grid; grid-template-columns: repeat(4, 1fr); margin: 0; border: 1px solid var(--border); border-radius: 8px; }
.detail-meta div { min-width: 0; padding: 10px; border-right: 1px solid var(--border); }
.detail-meta div:last-child { border: 0; }
.detail-meta dt { color: var(--dim); font: 9px/1.3 ui-monospace, monospace; text-transform: uppercase; }
.detail-meta dd { margin: 5px 0 0; overflow: hidden; color: var(--text); font-size: 12px; text-overflow: ellipsis; }
.detail-section { display: grid; gap: 11px; padding-top: 16px; border-top: 1px solid var(--border); }
.inline-form { display: grid; grid-template-columns: 1fr auto; gap: 8px; }

.toasts { position: fixed; right: 16px; bottom: 16px; z-index: 100; display: grid; gap: 8px; width: min(360px, calc(100vw - 32px)); pointer-events: none; }
.toast { display: grid; grid-template-columns: 1fr auto; gap: 14px; align-items: center; min-height: 48px; padding: 11px 12px; border: 1px solid #385b49; border-radius: 9px; background: #14231b; color: #cce8d8; box-shadow: 0 16px 50px rgba(0, 0, 0, .4); pointer-events: auto; font-size: 12px; }
.toast.error { border-color: #673c41; background: #29171a; color: #ffc2c6; }
.toast button { border: 0; background: transparent; color: inherit; cursor: pointer; font-size: 10px; font-weight: 800; text-transform: uppercase; }

@media (max-width: 800px) {
  .topbar { align-items: flex-start; }
  .health, #new-project { display: none; }
  .workspace { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; border-right: 0; border-bottom: 1px solid var(--border); }
  .project-list { grid-auto-flow: column; grid-auto-columns: minmax(170px, 1fr); overflow-x: auto; }
  .sidebar-footer { display: none; }
  .project-header { min-height: 124px; padding: 20px 16px; }
  .project-repos { max-width: 50vw; }
  .board { grid-auto-columns: minmax(245px, 78vw); min-height: calc(100dvh - 260px); }
  .frontier { padding: 24px 16px; }
}

@media (max-width: 520px) {
  .brand strong { display: none; }
  .topbar-actions { gap: 5px; }
  .button, .icon-button { min-height: 44px; }
  #new-task { padding-inline: 11px; }
  .project-header { display: grid; gap: 16px; }
  .project-repos { max-width: 90vw; }
  .view-actions { width: fit-content; }
  .form-grid, .detail-meta { grid-template-columns: 1fr 1fr; }
  .detail-meta div:nth-child(2) { border-right: 0; }
  .detail-meta div:nth-child(-n+2) { border-bottom: 1px solid var(--border); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

.login-screen {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: grid;
  place-items: center;
  padding: 24px;
  background: color-mix(in srgb, var(--bg) 94%, transparent);
}
.login-card {
  display: grid;
  justify-items: center;
  width: min(100%, 380px);
  padding: 46px 36px;
  border: 1px solid var(--border-strong);
  border-radius: calc(var(--radius) * 2);
  background: var(--surface);
  box-shadow: 0 28px 80px color-mix(in srgb, var(--bg) 75%, transparent);
  text-align: center;
}
.login-card h1 { margin-bottom: 28px; }
.login-mark {
  display: grid;
  width: 58px;
  height: 58px;
  margin-bottom: 24px;
  place-items: center;
  border: 1px solid var(--border-strong);
  border-radius: 16px;
  background: var(--surface-2);
  color: var(--accent-strong);
  font: 800 24px/1 ui-monospace, monospace;
}
