:root {
  --bg: #0b0e12;
  --bg-raised: #12161c;
  --bg-inset: #171c23;
  --border: #2f3947;
  --border-strong: #4a5563;
  --text: #e7ecf1;
  --text-muted: #97a3b0;
  --text-faint: #8a95a3;
  --accent: #4fd8c8;
  --accent-strong: #7fe8dc;
  --accent-ink: #04211d;
  --danger: #f87171;
  --danger-bg: #2a1417;
  --warn: #f2b84b;
  --warn-bg: #2a2013;
  --ok: #6ee787;
  --ok-bg: #12271a;
  --neutral: #9aa5b1;
  --neutral-bg: #1b212a;
  --radius-sm: 3px;
  --radius-md: 6px;
  --focus: 0 0 0 2px var(--bg), 0 0 0 4px var(--accent);
  --font-sans: -apple-system, "Segoe UI", "Helvetica Neue", Arial, ui-sans-serif, sans-serif;
  --font-mono: ui-monospace, "SFMono-Regular", "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }

html {
  color-scheme: dark;
  overflow-x: hidden;
}

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

body {
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}

h1, h2 { margin: 0; text-wrap: balance; }

button, input, select {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
  touch-action: manipulation;
}

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

:focus-visible {
  outline: none;
  box-shadow: var(--focus);
  border-radius: var(--radius-sm);
}

.skip-link {
  position: absolute;
  left: 12px;
  top: 12px;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 600;
  font-size: 13px;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  z-index: 100;
  transform: translateY(-140%);
}

.skip-link:focus {
  transform: translateY(0);
}

@media (prefers-reduced-motion: no-preference) {
  .skip-link { transition: transform 0.15s ease; }
}

/* ---------- layout ---------- */

.app {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: var(--bg-raised);
  border-right: 1px solid var(--border);
  padding: 24px 20px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.brand-mark {
  font-family: var(--font-mono);
  color: var(--accent);
  font-size: 16px;
}

.brand-name {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 20px;
  letter-spacing: 0.08em;
}

.brand-tagline {
  margin: 2px 0 28px;
  color: var(--text-faint);
  font-size: 12px;
  font-family: var(--font-mono);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.status-nav-wrap { flex: 1; }

.status-nav {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.status-nav-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  padding: 8px 10px;
  cursor: pointer;
  text-align: left;
  font-size: 13.5px;
}

.status-nav-btn:hover {
  background: var(--bg-inset);
  color: var(--text);
}

.status-nav-btn[aria-pressed="true"] {
  background: var(--bg-inset);
  border-color: var(--border-strong);
  color: var(--text);
}

.status-nav-btn:active { background: var(--bg-inset); }

.status-nav-btn .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex: none;
}

.status-nav-btn .label { flex: 1; display: flex; align-items: center; gap: 8px; }

.status-nav-btn .count {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-faint);
  font-variant-numeric: tabular-nums;
}

.status-nav-btn[aria-pressed="true"] .count { color: var(--accent); }

.sidebar-footnote {
  font-size: 11.5px;
  color: var(--text-faint);
  line-height: 1.4;
  margin: 24px 0 0;
}

.main {
  padding: 32px 40px 60px;
  max-width: 1000px;
}

.topbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  flex-wrap: wrap;
  margin-bottom: 24px;
}

.topbar-heading h1 {
  font-size: 25px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.topbar-sub {
  margin: 6px 0 0;
  color: var(--text-muted);
  font-size: 13px;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

.controls {
  display: flex;
  gap: 12px;
  align-items: flex-end;
  flex-wrap: wrap;
}

.field { display: flex; flex-direction: column; gap: 6px; }

.field label {
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-faint);
  font-family: var(--font-mono);
}

.search-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.field-icon {
  position: absolute;
  left: 10px;
  color: var(--text-faint);
  pointer-events: none;
}

#search-input {
  background: var(--bg-inset);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 12px 9px 32px;
  width: 240px;
  color: var(--text);
  appearance: none;
  -webkit-appearance: none;
}

#search-input::-webkit-search-cancel-button { display: none; }

#search-input::placeholder { color: var(--text-faint); }

#search-input:focus-visible { box-shadow: var(--focus); }

.filter-field select,
.status-field select {
  background: var(--bg-inset);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  color: var(--text);
  min-width: 168px;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%2397a3b0' stroke-width='1.4' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 30px;
}

/* ---------- item list ---------- */

.item-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.item { }

.item-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  cursor: pointer;
  text-align: left;
}

.item-btn:hover {
  border-color: var(--border-strong);
  background: var(--bg-inset);
}

.item-btn:active {
  background: var(--bg-inset);
  border-color: var(--accent);
}

.item-status-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex: none;
}

.item-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.item-title {
  font-weight: 600;
  font-size: 15px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.item-meta {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-faint);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.item-badges {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: none;
}

.badge {
  font-size: 11px;
  font-family: var(--font-mono);
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  color: var(--text-muted);
  white-space: nowrap;
}

.badge.status-todo { color: var(--neutral); background: var(--neutral-bg); border-color: transparent; }
.badge.status-in-progress { color: var(--accent-strong); background: rgba(79,216,200,0.14); border-color: transparent; }
.badge.status-blocked { color: var(--danger); background: var(--danger-bg); border-color: transparent; }
.badge.status-done { color: var(--ok); background: var(--ok-bg); border-color: transparent; }

.badge.priority-high { color: var(--danger); }
.badge.priority-medium { color: var(--warn); }
.badge.priority-low { color: var(--text-faint); }

.dot.status-todo, .item-status-dot.status-todo { background: var(--neutral); }
.dot.status-in-progress, .item-status-dot.status-in-progress { background: var(--accent); }
.dot.status-blocked, .item-status-dot.status-blocked { background: var(--danger); }
.dot.status-done, .item-status-dot.status-done { background: var(--ok); }
.dot.status-all { background: var(--text-muted); }

/* ---------- empty state ---------- */

.empty-state {
  text-align: center;
  padding: 64px 24px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-md);
  margin-top: 8px;
}

.empty-title { font-weight: 700; font-size: 16px; margin: 0 0 6px; }
.empty-body { color: var(--text-muted); margin: 0 0 18px; }

.btn {
  font-family: var(--font-mono);
  font-size: 13px;
  border-radius: var(--radius-sm);
  padding: 9px 16px;
  cursor: pointer;
  border: 1px solid var(--border-strong);
  background: var(--bg-inset);
  color: var(--text);
}

.btn:hover { border-color: var(--accent); }
.btn:active { background: var(--bg-raised); }

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

.btn-primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); }

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

.dialog-overlay {
  position: fixed;
  inset: 0;
  background: rgba(4, 6, 9, 0.6);
  display: flex;
  justify-content: flex-end;
  z-index: 50;
}

.dialog-overlay[hidden] { display: none; }

.dialog {
  width: 440px;
  max-width: 100%;
  height: 100%;
  background: var(--bg-raised);
  border-left: 1px solid var(--border-strong);
  padding: 24px 28px 40px;
  padding-right: max(28px, env(safe-area-inset-right));
  padding-bottom: max(40px, env(safe-area-inset-bottom));
  overflow-y: auto;
  overscroll-behavior: contain;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.dialog-eyebrow {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-faint);
  letter-spacing: 0.04em;
}

.close-btn {
  background: var(--bg-inset);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.close-btn:hover { color: var(--text); border-color: var(--border-strong); }
.close-btn:active { border-color: var(--accent); color: var(--text); }

#detail-title {
  font-size: 20px;
  line-height: 1.3;
  font-weight: 700;
}

.detail-meta {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 6px 14px;
  margin: 0;
  font-size: 13px;
}

.detail-meta dt {
  color: var(--text-faint);
  font-family: var(--font-mono);
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  align-self: center;
}

.detail-meta dd {
  margin: 0;
  color: var(--text);
  align-self: center;
}

.status-field {
  background: var(--bg-inset);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px;
  gap: 8px;
}

.status-field select { width: 100%; }

.status-feedback {
  margin: 0;
  font-size: 12.5px;
  color: var(--accent-strong);
  min-height: 1.4em;
}

.detail-body {
  font-size: 14.5px;
  color: var(--text-muted);
  line-height: 1.65;
}

.detail-body p { margin: 0 0 12px; }
.detail-body p:last-child { margin-bottom: 0; }

.detail-tags {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.detail-tags li {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--text-muted);
  background: var(--bg-inset);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 10px;
}

/* ---------- responsive ---------- */

@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }

  .sidebar {
    border-right: none;
    border-bottom: 1px solid var(--border);
    padding: 16px 20px;
  }

  .brand-tagline { margin-bottom: 14px; }

  .status-nav {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 8px;
  }

  .status-nav-btn { width: auto; padding: 6px 10px; }

  .sidebar-footnote { display: none; }

  .main { padding: 24px 20px 48px; }

  .topbar { flex-direction: column; align-items: stretch; }

  .controls { flex-direction: column; align-items: stretch; }

  #search-input { width: 100%; }

  .filter-field select { width: 100%; }

  .item-btn { flex-wrap: wrap; }

  .item-badges { order: 3; flex: 1 0 100%; margin-top: 4px; }

  .dialog { width: 100%; }
}

/* ---------- reduced motion ---------- */

@media (prefers-reduced-motion: no-preference) {
  .item-btn, .status-nav-btn, .btn, .close-btn { transition: background-color 0.12s ease, border-color 0.12s ease, color 0.12s ease; }
}
