:root {
  --paper: #f4f0e6;
  --paper-2: #ebe4d4;
  --ink: #1c1915;
  --muted: #6d655c;
  --line: #ddd4c4;
  --mark: #9c3418;
  --pine: #1e4636;
  --pine-ink: #f7f3ea;
  --shadow: 0 18px 40px rgba(48, 36, 22, 0.08);
  color-scheme: light;
  font-family: "Atkinson Hyperlegible", "Iowan Old Style", Palatino, serif;
  background:
    radial-gradient(1200px 400px at 10% -10%, rgba(156, 52, 24, 0.08), transparent 50%),
    linear-gradient(180deg, #f7f3ea 0%, var(--paper) 220px);
  color: var(--ink);
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2 { font-family: Fraunces, "Iowan Old Style", Palatino, serif; font-weight: 560; letter-spacing: -0.03em; }
h1 { font-size: 2.4rem; line-height: 0.95; margin: 0; }
h2 { font-size: 1.4rem; margin: 0; }

.eyebrow {
  margin: 0 0 0.2rem;
  color: var(--mark);
  font-size: 0.78rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
.hint { color: var(--muted); font-size: 0.92rem; margin: 0.35rem 0 0; }
.error { color: var(--mark); min-height: 1.2em; }
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

.gate {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
}
.gate-card {
  width: min(420px, 100%);
  background: #fffdf8;
  border: 1px solid var(--line);
  padding: 1.6rem 1.5rem 1.3rem;
  box-shadow: var(--shadow);
}
.gate-card h1 { margin-bottom: 1rem; }
.gate-card label { display: block; margin-bottom: 0.35rem; }
.gate-card input, .capture input, .search input, .field input, .field textarea, .stage-add input, .link-row input, .step-add input {
  width: 100%;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  padding: 0.65rem 0;
  outline: none;
}
.gate-card input:focus, .capture input:focus, .search input:focus, .field input:focus, .field textarea:focus, .stage-add input:focus, .link-row input:focus, .step-add input:focus {
  border-bottom-color: var(--pine);
}
.gate-card button, .primary, .stage-add button, .link-row button, .step-add button {
  margin-top: 0.9rem;
  border: 0;
  background: var(--pine);
  color: var(--pine-ink);
  padding: 0.55rem 0.9rem;
}
.text-button, .chips button, .views button, .row-button, .mini {
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 0.35rem 0.2rem;
}
.chips button[aria-pressed="true"], .views button[aria-selected="true"] {
  color: var(--ink);
  box-shadow: inset 0 -2px 0 var(--mark);
}

#app { width: min(1100px, calc(100% - 2rem)); margin: 0 auto; padding: 1.4rem 0 3rem; }
.mast, .mast-actions, .capture-row, .views, .detail-head, .inline, .link-row, .step-line, .stage-line {
  display: flex;
  gap: 0.75rem;
  align-items: center;
}
.mast { justify-content: space-between; align-items: end; margin-bottom: 1.2rem; }
.mast-actions { align-items: center; }
.search input { width: 11rem; }
.capture {
  background: #fffdf8;
  border: 1px solid var(--line);
  padding: 0.8rem 1rem 0.7rem;
  box-shadow: var(--shadow);
}
.capture input { font-size: 1.25rem; }
.capture-row { justify-content: space-between; flex-wrap: wrap; }
.capture .primary { margin-top: 0; }
.views { flex-wrap: wrap; margin: 1rem 0 0.4rem; gap: 0.2rem 0.8rem; }
.views button { padding: 0.4rem 0; }

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 380px);
  gap: 1.5rem;
  align-items: start;
}
.list { list-style: none; margin: 0.4rem 0 0; padding: 0; }
.list li { border-top: 1px solid var(--line); }
.row-button {
  width: 100%;
  text-align: left;
  padding: 0.85rem 0.1rem;
  color: var(--ink);
}
.row-button strong { display: block; font-size: 1.05rem; font-weight: 700; }
.row-button small { display: block; color: var(--muted); margin-top: 0.15rem; }
.row-button .due { color: var(--mark); }
.row-button[aria-current="true"] { background: rgba(30, 70, 54, 0.06); }

.detail {
  position: sticky;
  top: 0.8rem;
  background: #fffdf8;
  border: 1px solid var(--line);
  padding: 1rem 1rem 1.2rem;
  max-height: calc(100vh - 1.6rem);
  overflow: auto;
}
.detail-head { justify-content: space-between; align-items: start; }
.detail-head h2 { font-size: 1.55rem; }
.field { margin-top: 0.85rem; }
.field span, .block-label { display: block; color: var(--muted); font-size: 0.82rem; letter-spacing: 0.04em; text-transform: uppercase; }
.field textarea { min-height: 6.5rem; resize: vertical; }
.steps, .links { margin: 0.4rem 0 0; padding: 0; list-style: none; }
.step-line, .link-row, .stage-line { justify-content: space-between; }
.step-line label { display: flex; gap: 0.5rem; align-items: flex-start; }
.mini { padding: 0.2rem; }
.danger { color: var(--mark); }
.tags { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-top: 0.4rem; }
.tags button {
  border: 1px solid var(--line);
  background: transparent;
  padding: 0.15rem 0.45rem;
  color: var(--ink);
}

dialog {
  width: min(520px, calc(100% - 1.5rem));
  border: 1px solid var(--line);
  background: #fffdf8;
  padding: 1rem 1.1rem 1.2rem;
}
dialog::backdrop { background: rgba(28, 25, 21, 0.35); }
.dialog-head { justify-content: space-between; margin-bottom: 0.4rem; }
.stage-line { padding: 0.45rem 0; border-top: 1px solid var(--line); }
.stage-line input[type="text"] { flex: 1; border: 0; border-bottom: 1px solid transparent; background: transparent; min-width: 0; }
.stage-line input[type="text"]:focus { border-bottom-color: var(--pine); outline: none; }
.stage-add { display: flex; gap: 0.6rem; align-items: center; margin-top: 0.8rem; }
.stage-add input { flex: 1; }
.stage-add button { margin-top: 0; }

@media (max-width: 800px) {
  h1 { font-size: 2rem; }
  .mast, .mast-actions { align-items: stretch; flex-direction: column; }
  .search input { width: 100%; }
  .workspace { grid-template-columns: 1fr; }
  .detail {
    position: fixed;
    inset: 0;
    max-height: none;
    z-index: 3;
    border: 0;
  }
}
