:root {
  --bg: #e7e1d6;
  --surface: #fbf8f3;
  --ink: #1a1916;
  --muted: #6f6a62;
  --line: #ddd4c6;
  --rail: #1e2421;
  --rail-ink: #f3efe6;
  --rail-muted: #a7aea4;
  --brass: #d6b25e;
  --moss: #2f6f4e;
  --danger: #8d3428;
  --sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", sans-serif;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --rail-w: 272px;
  --shadow: 0 1px 2px rgba(28, 25, 23, 0.04), 0 12px 32px rgba(28, 25, 23, 0.06);
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html { color-scheme: light; }

html, body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(900px 420px at 100% -10%, rgba(166, 132, 61, 0.1), transparent 55%),
    var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
}

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

button { cursor: pointer; }

input, textarea, select {
  background: #fff;
  color: var(--ink);
  caret-color: var(--ink);
  -webkit-text-fill-color: var(--ink);
}

:focus { outline: none; }

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

::selection { background: #e4efc8; }

.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.brand {
  font-family: var(--serif);
  font-size: 32px;
  line-height: 1;
  margin: 0;
  letter-spacing: -0.03em;
}

.app {
  display: grid;
  grid-template-columns: var(--rail-w) minmax(0, 1fr);
  min-height: 100vh;
  min-height: 100dvh;
}

.rail {
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 28px 18px 16px;
  background: var(--rail);
  color: var(--rail-ink);
}

.rail .brand { color: var(--rail-ink); padding: 0 6px 8px; }

.rail input {
  width: 100%;
  background: rgba(255, 255, 255, 0.06);
  color: var(--rail-ink);
  caret-color: var(--rail-ink);
  -webkit-text-fill-color: var(--rail-ink);
  border: 1px solid transparent;
  border-radius: 12px;
  padding: 12px 12px;
}

.rail input::placeholder { color: var(--rail-muted); -webkit-text-fill-color: var(--rail-muted); }

.rail input:focus {
  border-color: rgba(214, 178, 94, 0.7);
  background: rgba(255, 255, 255, 0.09);
}

.hint, .rail-foot, .rail-label {
  color: var(--rail-muted);
  font-size: 12px;
}

.hint { margin: 0 6px 10px; }

#nav, #rail-projects { display: flex; flex-direction: column; gap: 2px; }

#nav { margin-bottom: 16px; }

#nav button, .proj, .rail-foot button, .rail-label button {
  background: transparent;
  color: var(--rail-ink);
  border: 0;
  border-radius: 10px;
  text-align: left;
}

#nav button {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 9px 10px;
  color: var(--rail-muted);
}

#nav button.is-on {
  background: rgba(255, 255, 255, 0.08);
  color: var(--rail-ink);
}

.count {
  min-width: 1.2em;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.rail-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 6px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.rail-label button {
  width: 28px;
  height: 28px;
  text-align: center;
  color: var(--rail-ink);
  font-size: 18px;
  padding: 0;
}

#rail-projects {
  overflow: auto;
  flex: 1;
  min-height: 0;
  padding-bottom: 8px;
}

.proj {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 7px 8px;
  color: var(--rail-muted);
}

.proj.is-on { color: var(--rail-ink); background: rgba(255, 255, 255, 0.06); }

.dot {
  width: 8px;
  height: 8px;
  border-radius: 99px;
  flex: none;
  background: var(--moss);
}

.dot[data-hue="moss"] { background: #6fbf93; }
.dot[data-hue="brass"] { background: #d6b25e; }
.dot[data-hue="clay"] { background: #d07a62; }
.dot[data-hue="sea"] { background: #7eb0bc; }
.dot[data-hue="plum"] { background: #c49bb4; }
.dot[data-hue="ink"] { background: #d9d3c8; }

.rail-foot {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 10px;
  align-items: center;
  padding-top: 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.rail-foot button { padding: 4px 0; color: var(--rail-muted); }

#status { margin-right: auto; }

.main-col {
  padding: 0 32px 72px;
  min-width: 0;
}

.top {
  position: sticky;
  top: 0;
  z-index: 4;
  padding: 22px 0 12px;
  background: var(--bg);
}

.top-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
}

h1 {
  font-family: var(--serif);
  font-size: 34px;
  font-weight: 500;
  letter-spacing: -0.03em;
  margin: 0 0 12px;
}

#search {
  width: min(420px, 100%);
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.55);
  border-radius: 999px;
  padding: 10px 14px;
}

.status-mobile { display: none; color: var(--muted); font-size: 12px; }

.top-actions { display: flex; align-items: center; gap: 12px; }

.account-mobile {
  display: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 4px 0;
}

.page { max-width: 740px; }

.date-line, .filter-banner, .empty p, .nudge, .drop-hint, .meta-quiet {
  color: var(--muted);
}

.filter-banner {
  display: flex;
  gap: 10px;
  align-items: center;
  margin: 0 0 16px;
  font-size: 14px;
}

.block { margin: 8px 0 28px; }

.block h2, .column header h2, .checks h3 {
  margin: 0;
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
}

.stack, .column-body { display: flex; flex-direction: column; gap: 8px; }

.board {
  display: grid;
  grid-template-columns: repeat(4, minmax(210px, 1fr));
  gap: 12px;
  align-items: start;
}

.column {
  display: flex;
  flex-direction: column;
  background: rgba(255, 255, 255, 0.38);
  border-radius: 16px;
  padding: 10px;
  min-width: 0;
  min-height: 280px;
}

.column[data-stage="doing"] { background: #e5f0e9; }
.column[data-stage="waiting"] { background: #f3eee2; }

.column header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 6px 8px;
}

.column-body {
  flex: 1;
  min-height: 120px;
  max-height: calc(100vh - 210px);
  overflow: auto;
}

.column.drop { outline: 2px solid var(--brass); outline-offset: -2px; }

.nudge { margin: 0 6px 8px; font-size: 13px; color: #6d5424; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 1px 0 rgba(28, 25, 23, 0.03);
}

.card.is-open { border-color: var(--moss); box-shadow: 0 0 0 1px var(--moss); }
.card.is-cursor { border-color: #1e2421; }

.card-open {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  border: 0;
  padding: 12px 12px 10px;
}

.card-title {
  display: block;
  font-size: 15px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.is-inbox .card-title { font-size: 17px; }

.card-meta, .card-open .wait {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
}

.card-open .wait { display: block; }

.chip {
  border-radius: 999px;
  padding: 2px 7px;
  background: #ece7dc;
  color: var(--ink);
}

.chip[data-hue="moss"] { background: #e5f2ea; color: #1e5a3c; }
.chip[data-hue="brass"] { background: #f6efdc; color: #6d5424; }
.chip[data-hue="clay"] { background: #f8e8e2; color: #7a392c; }
.chip[data-hue="sea"] { background: #e5f1f4; color: #1e4d58; }
.chip[data-hue="plum"] { background: #f6eaf1; color: #643552; }
.chip[data-hue="ink"] { background: #eceae6; color: #2c3338; }

.due.overdue { color: var(--danger); font-weight: 600; }

.promote {
  display: flex;
  gap: 6px;
  padding: 0 12px 12px;
}

.promote button, .text-btn, .archive-link {
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 10px;
  color: var(--ink);
  font-size: 13px;
}

.promote button:first-child {
  background: #1e2421;
  color: var(--rail-ink);
  -webkit-text-fill-color: var(--rail-ink);
  border-color: #1e2421;
}

.empty { padding: 28px 0; max-width: 420px; }
.empty p { margin: 0 0 8px; font-size: 16px; }
.empty p:first-child { color: var(--ink); font-family: var(--serif); font-size: 22px; }

.project-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
}

.project-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  min-height: 132px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.project-card input {
  border: 0;
  background: transparent;
  font-family: var(--serif);
  font-size: 22px;
  padding: 0;
  width: 100%;
}

.project-card .counts { color: var(--muted); font-size: 13px; margin: 0; }

.card-actions, .project-card .row-actions { display: flex; gap: 8px; margin-top: auto; }

.sheet {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(560px, 100%);
  background: var(--surface);
  border-left: 1px solid var(--line);
  box-shadow: -18px 0 50px rgba(28, 25, 23, 0.08);
  z-index: 20;
  display: flex;
  flex-direction: column;
}

.sheet[hidden] { display: none; }

.sheet-bar {
  display: flex;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
}

.sheet-bar button, .danger-text, .icon-x {
  background: transparent;
  border: 0;
  color: var(--muted);
  padding: 4px 0;
}

.sheet-body {
  overflow: auto;
  padding: 22px 22px 48px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.sheet .title {
  width: 100%;
  border: 0;
  background: transparent;
  font-family: var(--serif);
  font-size: 32px;
  line-height: 1.15;
  letter-spacing: -0.03em;
  padding: 0;
}

.stages {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  background: #efeae1;
  padding: 3px;
  border-radius: 14px;
}

.stages button {
  flex: 1 1 18%;
  border: 0;
  background: transparent;
  border-radius: 11px;
  padding: 7px 8px;
  font-size: 12px;
  color: var(--muted);
}

.stages button.is-on {
  background: var(--rail);
  color: var(--rail-ink);
  -webkit-text-fill-color: var(--rail-ink);
}

.sheet-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.sheet-grid label, .wait-label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.sheet-grid select, .sheet-grid input, .wait-label input, #check-new, #new-project-name, #inline-project-name {
  text-transform: none;
  letter-spacing: 0;
  font-size: 15px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 10px;
  color: var(--ink);
}

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

.check { display: grid; grid-template-columns: 28px 1fr 28px; gap: 6px; align-items: center; }

.tick {
  width: 22px;
  height: 22px;
  border-radius: 99px;
  border: 1.5px solid #b7b0a4;
  background: #fff;
  padding: 0;
}

.check.is-done .tick { background: var(--moss); border-color: var(--moss); box-shadow: inset 0 0 0 3px #fff; }

.check input {
  border: 0;
  background: transparent;
  padding: 6px 0;
}

.check.is-done input { color: var(--muted); text-decoration: line-through; }

.writing textarea, .md {
  width: 100%;
  min-height: 240px;
  border: 0;
  background: transparent;
  font-family: var(--serif);
  font-size: 18px;
  line-height: 1.55;
  padding: 0;
  resize: vertical;
}

.md p { margin: 0 0 0.8em; }
.md ul, .md ol { margin: 0 0 0.8em; padding-left: 1.2em; }
.md h3, .md h4, .md h5 { font-family: var(--serif); font-weight: 500; margin: 1em 0 0.4em; line-height: 1.2; }
.md h3 { font-size: 1.4em; }
.md h4 { font-size: 1.2em; }
.md h5 { font-size: 1em; }
.md code { font-family: ui-monospace, Menlo, monospace; font-size: 0.85em; background: #efeae1; padding: 1px 5px; border-radius: 5px; }
.md li.task { list-style: none; margin-left: -1.2em; }
.md li.task::before { content: "\25CB  "; color: var(--muted); }
.md li.task.is-done { color: var(--muted); text-decoration: line-through; }
.md li.task.is-done::before { content: "\25CF  "; color: var(--moss); }
.sheet-bar span { display: flex; gap: 18px; }
.history-list small { color: var(--muted); }
.history-list button { color: var(--ink); }
.more-menu > button { display: block; width: 100%; text-align: left; margin-bottom: 8px; }
.trash-row { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px dashed var(--line); border-radius: 12px; }
.trash-row .card-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }
.md a { color: #1e4d58; }

.danger-text { color: var(--danger); text-align: left; margin-top: 12px; }

.mobile-capture, .tabbar { display: none; }

#toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  background: var(--rail);
  color: var(--rail-ink);
  padding: 10px 12px 10px 16px;
  border-radius: 999px;
  display: none;
  z-index: 40;
  gap: 12px;
  align-items: center;
  box-shadow: var(--shadow);
}

#toast.show { display: flex; }

#toast button {
  background: transparent;
  border: 0;
  color: var(--brass);
  -webkit-text-fill-color: var(--brass);
  padding: 4px 6px;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(28, 25, 23, 0.35);
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 24px;
}

.modal[hidden] { display: none; }

.dialog {
  width: min(420px, 100%);
  background: var(--surface);
  border-radius: 16px;
  padding: 22px;
  box-shadow: var(--shadow);
}

.dialog p, .dialog li { color: var(--ink); }

.dialog h2 { font-family: var(--serif); font-weight: 500; margin: 0 0 12px; }

.help ul { list-style: none; padding: 0; margin: 0 0 16px; }

.help li, .device-list li { display: flex; justify-content: space-between; gap: 16px; padding: 7px 0; border-bottom: 1px solid var(--line); align-items: center; }

.device-list { list-style: none; padding: 0; margin: 0 0 8px; }

.device-list button { border: 0; background: transparent; color: var(--danger); padding: 4px 0; }

kbd {
  font-family: var(--sans);
  font-size: 12px;
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 6px;
  padding: 1px 6px;
  background: #fff;
}

.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

.dialog-actions button, .dialog > button {
  border-radius: 999px;
  padding: 8px 14px;
  border: 1px solid var(--line);
  background: #fff;
}

.dialog-actions .danger, button.danger {
  background: var(--danger);
  color: white;
  -webkit-text-fill-color: white;
  border-color: var(--danger);
}

.gate {
  position: fixed;
  inset: 0;
  z-index: 70;
  background: var(--rail);
  display: grid;
  place-items: center;
  padding: 24px;
}

.gate[hidden] { display: none; }

.gate-card {
  width: min(360px, 100%);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.gate .brand { color: var(--rail-ink); margin-bottom: 4px; }

.gate-lead { color: var(--rail-muted); margin: 0 0 8px; font-size: 14px; line-height: 1.4; }

.gate label { color: var(--rail-muted); font-size: 12px; letter-spacing: 0.06em; text-transform: uppercase; }

.gate label.remember {
  text-transform: none;
  letter-spacing: 0;
  font-size: 14px;
  color: var(--rail-ink);
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
}

.gate input {
  background: rgba(255, 255, 255, 0.06);
  color: var(--rail-ink);
  caret-color: var(--rail-ink);
  -webkit-text-fill-color: var(--rail-ink);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  padding: 12px;
}

.gate input[type="checkbox"] {
  width: 18px;
  height: 18px;
  padding: 0;
  margin: 0;
  accent-color: var(--brass);
  border-radius: 4px;
}

.gate button {
  margin-top: 8px;
  background: var(--brass);
  color: #1e2421;
  -webkit-text-fill-color: #1e2421;
  border: 0;
  border-radius: 999px;
  padding: 12px;
}

.gate-error { min-height: 1.2em; color: #e7b2a8; margin: 0; }

.pills { display: flex; gap: 6px; overflow: auto; padding-bottom: 10px; }

.pill {
  border: 1px solid var(--line);
  background: transparent;
  border-radius: 999px;
  padding: 7px 12px;
  color: var(--muted);
  white-space: nowrap;
}

.pill.is-on { background: var(--rail); color: var(--rail-ink); -webkit-text-fill-color: var(--rail-ink); border-color: var(--rail); }

@media (min-width: 761px) {
  body.sheet-open .main-col { padding-right: 560px; }
  body.sheet-open .board { overflow-x: auto; }
}

@media (max-width: 1100px) and (min-width: 761px) {
  .board {
    grid-template-columns: repeat(4, 240px);
    overflow-x: auto;
    padding-bottom: 12px;
  }
}

@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; }
  .rail { display: none; }
  .main-col { padding: 0 16px 150px; }
  .top { padding-top: calc(14px + env(safe-area-inset-top)); }
  h1 { font-size: 28px; }
  .status-mobile { display: inline; }
  body.signed-in .account-mobile { display: inline; }
  .sheet { width: 100%; border-left: 0; }
  .sheet-bar { padding: calc(10px + env(safe-area-inset-top)) 16px 10px; }
  .sheet-bar button { min-height: 44px; padding: 0 4px; font-size: 16px; }
  .sheet-body { padding-bottom: calc(48px + env(safe-area-inset-bottom)); -webkit-overflow-scrolling: touch; }
  .stages button { padding: 11px 6px; font-size: 13px; }
  .check { grid-template-columns: 40px 1fr 40px; }
  .tick { width: 28px; height: 28px; }
  .icon-x { min-height: 40px; font-size: 20px; }
  .modal { align-items: end; padding: 12px 12px calc(12px + env(safe-area-inset-bottom)); }
  .more-menu > button, .dialog-actions button { min-height: 44px; }
  .sheet .title { font-size: 26px; }
  .sheet-grid { grid-template-columns: 1fr; }
  input, select, textarea { font-size: 16px; }
  .mobile-capture, .tabbar { display: flex; }
  .mobile-capture {
    position: fixed;
    left: 12px;
    right: 12px;
    bottom: calc(62px + env(safe-area-inset-bottom));
    z-index: 16;
  }
  .mobile-capture input {
    width: 100%;
    border: 0;
    border-radius: 14px;
    padding: 14px 14px;
    background: #fff;
    box-shadow: var(--shadow);
  }
  .tabbar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    height: calc(56px + env(safe-area-inset-bottom));
    padding: 0 8px env(safe-area-inset-bottom);
    background: var(--rail);
    z-index: 15;
    justify-content: space-around;
  }
  .tabbar button {
    flex: 1;
    background: transparent;
    border: 0;
    color: var(--rail-muted);
    -webkit-text-fill-color: var(--rail-muted);
    font-size: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    min-height: 44px;
  }
  .tabbar button.is-on { color: var(--rail-ink); -webkit-text-fill-color: var(--rail-ink); }
  #toast { bottom: calc(128px + env(safe-area-inset-bottom)); }
  body.sheet-open .mobile-capture,
  body.sheet-open .tabbar { display: none; }
  body.sheet-open .main-col { padding-bottom: 24px; }
}

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