:root {
  --ink: #0e1217;
  --panel: #161c24;
  --panel-raised: #1d2530;
  --line: #2c3645;
  --text: #e9eef4;
  --muted: #9aa8b8;
  --accent: #f2b441;
  --accent-ink: #1a1305;
  --focus: #7fd1ff;

  --todo: #a9b6c6;
  --in-progress: #7fb8ff;
  --blocked: #ff8a7a;
  --done: #7fd9a0;

  --radius: 10px;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  background: var(--ink);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
}

h1,
h2,
h3,
p,
dl,
dd,
ul {
  margin: 0;
}

ul {
  padding: 0;
  list-style: none;
}

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

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

.skip-link {
  position: absolute;
  left: 12px;
  top: -60px;
  background: var(--accent);
  color: var(--accent-ink);
  padding: 8px 12px;
  border-radius: 6px;
  z-index: 10;
}

.skip-link:focus {
  top: 12px;
}

/* Top bar */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 28px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  position: sticky;
  top: 0;
  z-index: 5;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  letter-spacing: 0.02em;
  font-size: 1.05rem;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: var(--accent);
  color: var(--accent-ink);
}

.topbar-meta {
  font-family: var(--mono);
  font-size: 0.85rem;
  color: var(--muted);
}

/* Layout */

.layout {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  min-height: calc(100vh - 66px);
}

.layout.has-detail {
  grid-template-columns: 220px minmax(0, 1fr) minmax(360px, 440px);
}

.sidebar {
  padding: 24px 18px;
  border-right: 1px solid var(--line);
  background: var(--panel);
}

.side-heading {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
  margin-bottom: 12px;
}

.status-summary {
  display: grid;
  gap: 6px;
}

.status-summary button {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 9px 10px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: none;
  cursor: pointer;
  text-align: left;
}

.status-summary button:hover {
  background: var(--panel-raised);
}

.status-summary button[aria-pressed="true"] {
  border-color: var(--line);
  background: var(--panel-raised);
}

.count {
  font-family: var(--mono);
  font-size: 0.85rem;
  color: var(--muted);
}

.dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  margin-right: 8px;
  background: currentColor;
}

.workspace {
  padding: 24px 28px 48px;
  min-width: 0;
}

.workspace:focus {
  outline: none;
}

/* Toolbar */

.toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 220px;
  gap: 12px;
}

.field {
  display: grid;
  gap: 6px;
}

.field label,
.status-row label {
  font-size: 0.85rem;
  color: var(--muted);
}

.field input,
.field select,
.status-row select {
  height: 44px;
  padding: 0 12px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--panel);
  width: 100%;
}

.field input::placeholder {
  color: #66768a;
}

.result-line {
  margin: 14px 0 10px;
  font-size: 0.9rem;
  color: var(--muted);
}

/* Task list */

.task-list {
  display: grid;
  gap: 10px;
}

.task {
  display: grid;
  grid-template-columns: 6px minmax(0, 1fr) auto;
  gap: 14px;
  align-items: stretch;
  padding: 16px 16px 16px 0;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  transition: border-color 0.15s ease;
}

.task:hover {
  border-color: #3d4a5c;
}

.task.is-selected {
  border-color: var(--accent);
}

.task-bar {
  border-radius: 0 4px 4px 0;
  background: var(--bar, var(--todo));
}

.task-main {
  min-width: 0;
  display: grid;
  gap: 6px;
}

.task-title {
  font-weight: 600;
  font-size: 1.02rem;
  overflow-wrap: anywhere;
}

.task-sub {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  font-size: 0.87rem;
  color: var(--muted);
}

.task-side {
  display: grid;
  justify-items: end;
  align-content: center;
  gap: 10px;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--status-color, var(--todo));
  border: 1px solid currentColor;
  white-space: nowrap;
}

.badge .dot {
  margin-right: 6px;
}

.open-item {
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--panel-raised);
  cursor: pointer;
  white-space: nowrap;
}

.open-item:hover {
  border-color: var(--accent);
}

/* Empty state */

.empty-state {
  margin-top: 24px;
  padding: 28px;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  text-align: center;
  display: grid;
  gap: 12px;
  justify-items: center;
}

.empty-state h2 {
  font-size: 1.2rem;
}

.empty-state p {
  color: var(--muted);
  max-width: 44ch;
}

[hidden] {
  display: none !important;
}

/* Buttons */

.btn {
  min-height: 44px;
  padding: 0 16px;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
}

.btn-secondary {
  background: var(--accent);
  color: var(--accent-ink);
  border: 1px solid var(--accent);
}

.btn-ghost {
  background: none;
  border: 1px solid transparent;
  color: var(--text);
}

.btn-ghost:hover {
  border-color: var(--line);
  background: var(--panel-raised);
}

/* Detail */

.detail {
  border-left: 1px solid var(--line);
  background: var(--panel);
  overflow-y: auto;
  min-width: 0;
}

.detail-head {
  position: sticky;
  top: 0;
  padding: 12px 20px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  z-index: 1;
}

.detail-head .btn {
  padding-left: 4px;
}

.detail-body {
  padding: 24px 24px 48px;
  display: grid;
  gap: 20px;
}

.eyebrow {
  font-family: var(--mono);
  font-size: 0.85rem;
  color: var(--muted);
}

.detail-title {
  font-size: 1.5rem;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.meta-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px 18px;
}

.meta-grid dt {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 2px;
}

.meta-grid dd {
  overflow-wrap: anywhere;
}

.status-row {
  display: grid;
  gap: 6px;
  padding: 14px;
  border-radius: var(--radius);
  background: var(--panel-raised);
  border: 1px solid var(--line);
}

.status-row select {
  max-width: 260px;
}

.status-feedback {
  min-height: 1.5em;
  font-size: 0.9rem;
  color: var(--done);
}

.status-feedback.is-error {
  color: var(--blocked);
}

.detail-text {
  white-space: pre-line;
  line-height: 1.65;
  overflow-wrap: anywhere;
}

/* Status colors */

[data-status="todo"] {
  --status-color: var(--todo);
}

[data-status="in-progress"] {
  --status-color: var(--in-progress);
}

[data-status="blocked"] {
  --status-color: var(--blocked);
}

[data-status="done"] {
  --status-color: var(--done);
}

.task[data-status] {
  --bar: var(--status-color);
}

.status-summary button {
  color: var(--status-color, var(--text));
}

.status-summary .count {
  margin-left: auto;
  color: var(--muted);
}

.status-summary button[data-value="all"] {
  color: var(--text);
}

/* Responsive */

@media (max-width: 1100px) {
  .layout.has-detail {
    grid-template-columns: 200px minmax(0, 1fr) minmax(320px, 380px);
  }
}

@media (max-width: 860px) {
  .layout,
  .layout.has-detail {
    grid-template-columns: minmax(0, 1fr);
  }

  .sidebar {
    display: none;
  }

  .detail {
    position: fixed;
    inset: 0;
    z-index: 30;
    border-left: none;
  }
}

@media (max-width: 560px) {
  .topbar {
    padding: 12px 16px;
  }

  .workspace {
    padding: 16px 16px 40px;
  }

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

  .task {
    grid-template-columns: 6px minmax(0, 1fr);
    padding-right: 14px;
  }

  .task-bar {
    grid-row: 1 / span 2;
  }

  .task-side {
    grid-column: 2;
    justify-items: start;
    grid-template-columns: auto auto;
    justify-content: space-between;
    align-items: center;
  }

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

  .status-row select {
    max-width: none;
  }
}

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