:root {
  --paper: #fafaf8;
  --surface: #ffffff;
  --ink: #111111;
  --muted: #5c5c58;
  --rule: #d9d8d3;
  --signal: #e63312;
  --sans: "Helvetica Neue", Helvetica, Arial, "Liberation Sans", system-ui, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --s-1: 4px;
  --s-2: 8px;
  --s-3: 12px;
  --s-4: 16px;
  --s-5: 24px;
  --s-6: 32px;
  --s-7: 48px;
  --s-8: 64px;
  --radius: 0;
}

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

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

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.55;
  overflow-x: clip;
}

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: 2px solid var(--signal);
  outline-offset: 2px;
}

.wrap {
  max-width: 1200px;
  margin-inline: auto;
  padding-inline: 20px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.eyebrow {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

/* Header: inverted band */
.masthead {
  background: var(--ink);
  color: var(--paper);
  padding-block: 40px 48px;
}

.masthead .eyebrow {
  color: #bdbdb8;
}

.brand {
  margin-top: var(--s-2);
  font-size: clamp(3rem, 8vw, 6.5rem);
  font-weight: 700;
  letter-spacing: -0.04em;
  line-height: 0.95;
}

.masthead-lede {
  margin-top: var(--s-4);
  max-width: 52ch;
  color: #d6d6d1;
  font-size: 17px;
}

/* Workspace */
.workspace {
  padding-block: 48px 96px;
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 220px;
  gap: var(--s-4);
  align-items: end;
  padding-bottom: var(--s-5);
  border-bottom: 2px solid var(--ink);
}

.field {
  display: grid;
  gap: var(--s-2);
  min-width: 0;
}

.field-label {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.control {
  width: 100%;
  min-height: 48px;
  padding: 10px 14px;
  border: 1px solid var(--ink);
  border-radius: var(--radius);
  background: var(--surface);
  font-size: 16px;
  transition: background-color 150ms var(--ease), border-color 150ms var(--ease);
}

.control:focus-visible {
  outline: 2px solid var(--signal);
  outline-offset: 2px;
}

.toolbar-meta {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: baseline;
  gap: var(--s-3) var(--s-5);
  padding-block: var(--s-4);
  border-bottom: 1px solid var(--rule);
}

.summary {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-2) var(--s-4);
  font-family: var(--mono);
  font-size: 13px;
}

.summary-item {
  display: inline-flex;
  gap: var(--s-2);
  align-items: baseline;
}

.summary-item + .summary-item {
  padding-left: var(--s-4);
  border-left: 1px solid var(--rule);
}

.summary-item dd {
  font-weight: 700;
}

.result-count {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--muted);
}

/* Task list */
.tasks {
  border-bottom: 1px solid var(--rule);
}

.task {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 170px 110px 130px;
  gap: var(--s-4);
  align-items: center;
  padding-block: var(--s-4);
  border-top: 1px solid var(--rule);
  transition: background-color 200ms var(--ease);
}

.task-main {
  min-width: 0;
}

.task-open {
  display: block;
  max-width: 100%;
  padding: 10px 0;
  margin: -10px 0;
  border: 0;
  background: none;
  text-align: left;
  font-size: 18px;
  font-weight: 600;
  line-height: 1.3;
  cursor: pointer;
  overflow-wrap: anywhere;
  text-decoration: underline;
  text-decoration-color: transparent;
  text-underline-offset: 4px;
  transition: text-decoration-color 150ms var(--ease);
}

.task-open:active {
  transform: scale(0.97);
}

.task-project {
  margin-top: var(--s-1);
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
}

.task-cell {
  font-size: 14px;
  color: var(--muted);
  min-width: 0;
  overflow-wrap: anywhere;
}

.task-cell-label {
  display: none;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.pill {
  justify-self: start;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}

.pill::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
}

.pill-todo {
  background: #e9e9e5;
  color: var(--ink);
}

.pill-in-progress {
  background: #f3e7b5;
  color: #4a3800;
}

.pill-blocked {
  background: #fbe3dc;
  color: #9e2309;
}

.pill-done {
  background: #ddefe3;
  color: #1f5a34;
}

.empty-state {
  padding-block: var(--s-7);
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
}

.empty-state h2 {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.empty-state p {
  margin-top: var(--s-2);
  color: var(--muted);
}

[hidden] {
  display: none !important;
}

/* Buttons */
.btn {
  min-height: 44px;
  padding: 10px 20px;
  border: 1px solid var(--ink);
  border-radius: var(--radius);
  background: var(--ink);
  color: var(--paper);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 150ms var(--ease), color 150ms var(--ease);
}

.btn:active {
  transform: scale(0.97);
}

.btn-ghost {
  background: transparent;
  color: var(--ink);
}

@media (hover: hover) and (pointer: fine) {
  .task:hover {
    background-color: var(--surface);
  }

  .control:hover {
    background-color: #f1f1ed;
  }

  .task-open:hover {
    text-decoration-color: currentColor;
  }

  .btn:hover {
    background: #333333;
    border-color: #333333;
  }

  .btn-ghost:hover {
    background: var(--ink);
    color: var(--paper);
  }
}

/* Detail dialog */
.detail {
  width: min(720px, calc(100vw - 32px));
  max-height: calc(100dvh - 32px);
  margin: auto;
  padding: 0;
  border: 2px solid var(--ink);
  background: var(--surface);
  color: var(--ink);
  overflow-y: auto;
}

.detail[open] {
  animation: detail-in 200ms var(--ease);
}

.detail::backdrop {
  background: rgba(17, 17, 17, 0.55);
}

.detail-inner {
  padding: var(--s-6);
}

.detail-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--s-4);
}

.detail-id {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--muted);
}

.detail-title {
  margin-top: var(--s-4);
  font-size: clamp(1.6rem, 4vw, 2.25rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.12;
  overflow-wrap: anywhere;
}

.detail-meta {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--s-4) var(--s-5);
  margin-block: var(--s-6);
  padding-block: var(--s-5);
  border-block: 1px solid var(--rule);
}

.detail-meta dt {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}

.detail-meta dd {
  margin-top: 2px;
  font-size: 15px;
  overflow-wrap: anywhere;
}

.status-panel {
  display: grid;
  gap: var(--s-2);
  max-width: 320px;
}

.status-feedback {
  min-height: 1.5em;
  font-size: 14px;
  color: var(--muted);
}

.status-feedback[data-tone="success"] {
  color: #1f5a34;
  font-weight: 600;
}

.detail-body {
  margin-top: var(--s-6);
  font-size: 17px;
  line-height: 1.65;
  max-width: 62ch;
}

.detail-body p + p {
  margin-top: var(--s-4);
}

.detail-footer {
  margin-top: var(--s-7);
  display: flex;
  justify-content: flex-end;
}

/* Responsive */
@media (max-width: 760px) {
  .masthead {
    padding-block: 28px 36px;
  }

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

  .task {
    grid-template-columns: minmax(0, 1fr);
    gap: var(--s-2);
  }

  .task-cell {
    display: flex;
    gap: var(--s-3);
    align-items: baseline;
  }

  .task-cell-label {
    display: inline;
    flex: 0 0 72px;
  }

  .task-status {
    margin-top: var(--s-1);
  }

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

  .detail-inner {
    padding: var(--s-5);
  }

  .detail-footer .btn {
    width: 100%;
  }
}

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

  .task-open:active,
  .btn:active {
    transform: none;
  }
}

@keyframes detail-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }

  to {
    opacity: 1;
    transform: none;
  }
}
