:root {
  --bg: #f6f6f3;
  --panel: #ffffff;
  --ink: #1c1d1f;
  --ink-2: #55585e;
  --ink-3: #8a8d93;
  --line: #e4e3de;
  --line-2: #efeee9;
  --accent: #2f5d50;
  --accent-ink: #ffffff;
  --accent-soft: #e5eeea;
  --late: #b4372f;
  --late-soft: #fbeceb;
  --soon: #9a6400;
  --soon-soft: #fbf2df;
  --ok: #2f6b3a;
  --mark: #fff1a8;
  --shadow: 0 1px 2px rgba(20, 20, 20, .04);
  --radius: 10px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #141517; --panel: #1c1d20; --ink: #ececea; --ink-2: #b2b3b0; --ink-3: #85878a;
    --line: #2c2d31; --line-2: #25262a; --accent: #7fbca9; --accent-ink: #10201b; --accent-soft: #1f2f2a;
    --late: #f08a80; --late-soft: #3a2220; --soon: #e5b45a; --soon-soft: #342a17; --ok: #8fd19b;
    --mark: #5a4d12; --shadow: none; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #141517; --panel: #1c1d20; --ink: #ececea; --ink-2: #b2b3b0; --ink-3: #85878a;
  --line: #2c2d31; --line-2: #25262a; --accent: #7fbca9; --accent-ink: #10201b; --accent-soft: #1f2f2a;
  --late: #f08a80; --late-soft: #3a2220; --soon: #e5b45a; --soon-soft: #342a17; --ok: #8fd19b;
  --mark: #5a4d12; --shadow: none; color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--ink);
  font: 15px/1.5 ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -.01em; }
h1 { font-size: 26px; }
h2 { font-size: 15px; }
button, input, select { font: inherit; color: inherit; }

/* top bar + shell */
.topbar {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 16px;
  height: 56px; padding: 0 20px; background: var(--panel); border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; color: var(--ink); letter-spacing: -.01em; white-space: nowrap; }
.search { flex: 1; max-width: 520px; }
.search input {
  width: 100%; height: 36px; padding: 0 12px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--bg);
}
.who { margin-left: auto; display: flex; align-items: center; gap: 10px; white-space: nowrap; }
.who form { margin: 0; }
.avatar {
  width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center;
  background: var(--accent); color: var(--accent-ink); font-size: 13px; font-weight: 700;
}
.linkbtn { background: none; border: 0; padding: 0; color: var(--ink-2); cursor: pointer; }
.linkbtn:hover { color: var(--ink); text-decoration: underline; }

.shell { display: grid; grid-template-columns: 210px minmax(0, 1fr); min-height: calc(100vh - 56px); }
.side { padding: 18px 12px; border-right: 1px solid var(--line); display: flex; flex-direction: column; gap: 2px; }
.side a { padding: 7px 10px; border-radius: 7px; color: var(--ink-2); display: flex; justify-content: space-between; align-items: center; }
.side a:hover { background: var(--line-2); color: var(--ink); text-decoration: none; }
.side a.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.side-h { margin: 16px 10px 4px; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3); }
.main { padding: 26px 32px 60px; max-width: 1280px; width: 100%; }
.solo { min-height: 100vh; display: grid; place-items: center; padding: 16px; }

.pagehead { margin-bottom: 20px; }
.pagehead .sub { margin: 4px 0 0; color: var(--ink-2); }
.crumbs { font-size: 13px; color: var(--ink-3); margin-bottom: 8px; }
.badges { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }

/* cards + layout */
.grid2 { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 20px; align-items: start; }
.col { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 18px; box-shadow: var(--shadow); min-width: 0;
}
.card-h { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.more { font-size: 13px; color: var(--ink-3); }
a.more { color: var(--accent); }
.more-row { margin: 8px 0 0; font-size: 13px; }
.empty { color: var(--ink-3); margin: 4px 0; }
.muted { color: var(--ink-3); }
.count {
  display: inline-block; min-width: 20px; padding: 0 6px; border-radius: 10px; font-size: 12px; line-height: 18px;
  text-align: center; background: var(--line-2); color: var(--ink-2); font-weight: 600;
}
.side a.on .count { background: var(--accent); color: var(--accent-ink); }

.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 20px; }
.stat {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px;
  color: var(--ink); display: flex; flex-direction: column; box-shadow: var(--shadow);
}
.stat:hover { text-decoration: none; border-color: var(--ink-3); }
.stat b { font-size: 26px; line-height: 1.1; }
.stat span { color: var(--ink-2); font-size: 13px; }
.stat.bad b { color: var(--late); }
.stat.warn b { color: var(--soon); }

/* lists + tables */
ul.plain { list-style: none; margin: 0; padding: 0; }
ul.plain li { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; border-top: 1px solid var(--line-2); }
ul.plain li:first-child { border-top: 0; }
ul.plain.stack li { font-size: 14px; }
ul.plain li .muted { white-space: nowrap; font-size: 13px; }

.tablewrap { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th { text-align: left; font-weight: 600; color: var(--ink-3); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.tbl th a { color: inherit; }
.tbl th a.on { color: var(--accent); }
.tbl td { padding: 9px 10px; border-top: 1px solid var(--line-2); vertical-align: top; }
.tbl tr:first-child td { border-top: 0; }
.tablewrap .tbl th:first-child, .tablewrap .tbl td:first-child { padding-left: 16px; }
.card .tbl th:first-child, .card .tbl td:first-child { padding-left: 0; }
.c-date { white-space: nowrap; width: 1%; }
.c-owner { width: 1%; white-space: nowrap; }
.c-who { white-space: nowrap; }
.strong { font-weight: 600; color: var(--ink); }
.late { color: var(--late); font-weight: 600; }
.soon { color: var(--soon); font-weight: 600; }
.own { font-size: 12px; padding: 1px 7px; border-radius: 9px; background: var(--line-2); color: var(--ink-2); }
.own-me { background: var(--accent-soft); color: var(--accent); }
.own-doug { background: var(--soon-soft); color: var(--soon); }

.pill {
  display: inline-block; font-size: 12px; padding: 1px 8px; border-radius: 9px;
  border: 1px solid var(--line); color: var(--ink-2); background: var(--panel); white-space: nowrap;
}
.pill.soft { border-color: transparent; background: var(--line-2); }
.st-active { color: var(--ok); }
.st-prospect { color: var(--soon); }
.st-paused, .st-dormant, .st-done, .st-dropped, .st-archived { color: var(--ink-3); }
.vis-private { color: var(--ink-3); }
.vis-team { color: var(--accent); border-color: var(--accent); }
.tag { display: inline-block; font-size: 12px; padding: 1px 7px; margin: 0 4px 4px 0; border-radius: 6px; background: var(--line-2); color: var(--ink-2); }

/* filters + tabs */
.filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.filters input, .filters select, .filters button {
  height: 34px; padding: 0 10px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel);
}
.filters input[type="search"] { flex: 1 1 220px; }
.filters button { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); cursor: pointer; font-weight: 600; }
.tabs { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 16px; border-bottom: 1px solid var(--line); }
.tabs a { padding: 8px 12px; color: var(--ink-2); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a:hover { color: var(--ink); text-decoration: none; }
.tabs a.on { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }

/* project tiles */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.tile {
  display: flex; flex-direction: column; gap: 8px; background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px; color: var(--ink); box-shadow: var(--shadow);
}
.tile:hover { text-decoration: none; border-color: var(--ink-3); }
.tile-h { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; }
.tile p { margin: 0; color: var(--ink-2); font-size: 14px; }
.tile-f { margin-top: auto; display: flex; flex-direction: column; gap: 2px; font-size: 13px; color: var(--ink-2); }

/* prose from Markdown */
.prose { font-size: 14.5px; overflow-wrap: anywhere; }
.prose p { margin: 0 0 8px; }
.prose ul { margin: 0 0 8px; padding-left: 18px; }
.prose li { margin: 3px 0; }
.prose li.todo, .prose li.done { list-style: none; margin-left: -18px; }
.prose li.done { color: var(--ink-3); text-decoration: line-through; }
.prose .box { color: var(--ink-3); }
.prose h3, .prose h4, .prose h5, .prose h6 { font-size: 14px; margin: 14px 0 6px; color: var(--ink-2); text-transform: uppercase; letter-spacing: .04em; }
.prose h3:first-child, .prose h4:first-child { margin-top: 0; }
.prose code { font-size: 13px; background: var(--line-2); padding: 0 4px; border-radius: 4px; }
.prose .trow { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 10px; padding: 5px 0; border-top: 1px solid var(--line-2); font-size: 13.5px; }
.src { color: var(--ink-3); font-size: 12px; }
.private { color: var(--ink-3); font-style: italic; }
.nolink { color: var(--ink); }
.wl { font-weight: 500; }
mark { background: var(--mark); color: inherit; padding: 0 1px; border-radius: 2px; }

details.older summary { cursor: pointer; color: var(--accent); font-size: 14px; margin: 6px 0; }
details.card.older summary { margin: 0; }
details.card.older[open] summary { margin-bottom: 10px; }

.facts dl, .facts-inline { margin: 0; display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 6px 14px; font-size: 14px; }
.facts dt, .facts-inline dt { color: var(--ink-3); }
.facts dd, .facts-inline dd { margin: 0; overflow-wrap: anywhere; }

/* search results */
.result { display: block; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 16px; margin-bottom: 10px; color: var(--ink); }
.result:hover { text-decoration: none; border-color: var(--ink-3); }
.result p { margin: 4px 0 0; color: var(--ink-2); font-size: 14px; }

/* login */
.login { width: 100%; max-width: 420px; padding: 28px; }
.login h1 { margin-bottom: 6px; }
.login .sub { color: var(--ink-2); margin: 0 0 18px; }
.stack-form { display: flex; flex-direction: column; gap: 8px; }
.choice {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px; text-align: left; cursor: pointer;
  padding: 12px 14px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel);
}
.choice:hover { border-color: var(--accent); }
.choice span { color: var(--ink-3); font-size: 13px; }

/* tablet + phone */
@media (max-width: 1020px) {
  .grid2 { grid-template-columns: minmax(0, 1fr); }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
  .topbar { padding: 0 16px; gap: 10px; }
  .who-name { display: none; }
  .shell { grid-template-columns: minmax(0, 1fr); }
  .side { flex-direction: row; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--line); padding: 8px 12px; gap: 4px; }
  .side a { white-space: nowrap; }
  .side-h { display: none; }
  .main { padding: 18px 16px 48px; }
  h1 { font-size: 22px; }
  .hide-s { display: none; }
  .tbl.fu thead { display: none; }
  .tbl.fu tr { display: grid; grid-template-columns: auto auto minmax(0, 1fr); gap: 2px 10px; padding: 10px 0; border-top: 1px solid var(--line-2); }
  .tbl.fu tr:first-child { border-top: 0; }
  .tbl.fu td { border: 0; padding: 0 !important; width: auto; }
  .tbl.fu td.c-who { text-align: right; white-space: normal; }
  .tbl.fu td.task { grid-column: 1 / -1; grid-row: 2; }
  .stats { gap: 8px; }
  .search input { min-width: 0; }
}
.tbl td.task { overflow-wrap: anywhere; }

/* ---------- editing ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 14px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--panel); color: var(--ink); font-weight: 600; font-size: 14px;
  cursor: pointer; white-space: nowrap; list-style: none;
}
.btn::-webkit-details-marker { display: none; }
.btn:hover { border-color: var(--ink-3); text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.05); }
.btn.ghost { background: transparent; color: var(--ink-2); }
.mini {
  height: 28px; padding: 0 9px; border-radius: 6px; border: 1px solid var(--line); background: var(--panel);
  font-size: 12.5px; color: var(--ink-2); cursor: pointer;
}
.mini:hover { border-color: var(--ink-3); color: var(--ink); }
.mini.ok { color: var(--ok); }
input.mini { width: 132px; padding: 0 6px; }

.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; align-items: flex-start; }
details.act { position: relative; }
details.act[open] > summary { box-shadow: 0 0 0 3px var(--accent-soft); }
details.act .act-panel {
  position: absolute; z-index: 4; top: 42px; left: 0; width: min(560px, calc(100vw - 32px));
  box-shadow: 0 10px 30px rgba(0, 0, 0, .12);
}
details.act.block { margin-bottom: 16px; }
details.act.block .act-panel { position: static; margin-top: 10px; box-shadow: var(--shadow); }

.form { display: flex; flex-direction: column; gap: 12px; }
.form label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; font-weight: 600; color: var(--ink-2); }
.form label.small { font-weight: 500; }
.form input[type="text"], .form input[type="date"], .form select, .form textarea, .form input[type="file"] {
  font: inherit; font-size: 14.5px; font-weight: 400; color: var(--ink); background: var(--bg);
  border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; width: 100%;
}
.form textarea { resize: vertical; line-height: 1.45; }
.form input:focus, .form select:focus, .form textarea:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: var(--accent); }
.form .row { display: flex; flex-wrap: wrap; gap: 10px; }
.form .row > label { flex: 1 1 140px; }
.form .row > label.grow { flex: 3 1 240px; }
.form fieldset { border: 1px dashed var(--line); border-radius: 8px; padding: 10px 12px 12px; margin: 0; }
.form legend { font-size: 13px; color: var(--ink-3); padding: 0 4px; }
.form .hint, .hint { font-size: 12.5px; color: var(--ink-3); font-weight: 400; margin: 0; }
.form-f { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; }
.form-f.sticky { position: sticky; bottom: 0; padding: 12px 0; background: linear-gradient(transparent, var(--bg) 35%); }
.narrow-form { max-width: 640px; }
.edit .card { margin-bottom: 16px; }
.edit textarea { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; }
.fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.fields .wide { grid-column: 1 / -1; }

.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; font-size: 14px; border: 1px solid var(--line); background: var(--panel); }
.flash.ok { border-color: var(--ok); color: var(--ok); }
.flash.wait { border-color: var(--soon); color: var(--soon); background: var(--soon-soft); }
.flash.error { border-color: var(--late); color: var(--late); background: var(--late-soft); }
.wait-pill { color: var(--soon); border-color: var(--soon); margin: 10px 0 0; }
.review-item.decided { opacity: .8; }
.review-form { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line-2); }
.queued { margin-bottom: 16px; border-color: var(--soon); }

.c-act { width: 1%; white-space: nowrap; text-align: right; }
.fu-act, form.inline { display: inline-flex; gap: 4px; align-items: center; margin: 0; }
.fu-act input[type="date"] { display: none; }
tr:hover .fu-act input[type="date"], .fu-act:focus-within input[type="date"] { display: inline-block; }
@media (max-width: 760px) {
  .hide-xs { display: none; }
  .tbl.fu td.c-act { grid-column: 1 / -1; grid-row: 3; text-align: left; }
  .fu-act input[type="date"] { display: inline-block; }
  details.act[open] { flex-basis: 100%; }
  details.act .act-panel { position: static; width: 100%; margin-top: 8px; box-shadow: var(--shadow); }
}

.mt { margin-top: 12px; }
.btn.google { width: 100%; justify-content: center; height: 42px; margin-bottom: 8px; }

/* After a save that keeps your place on the page, show the message as a toast. */
.kept-place .flash[role="status"] {
  position: fixed; left: 50%; bottom: 16px; transform: translateX(-50%); z-index: 50;
  max-width: calc(100% - 32px); margin: 0; box-shadow: 0 4px 16px rgba(0, 0, 0, .15);
}
.kept-place .flash.ok[role="status"] { animation: toast-out 4s ease forwards; }
@keyframes toast-out { 0%, 75% { opacity: 1; visibility: visible; } 100% { opacity: 0; visibility: hidden; } }
@media (prefers-reduced-motion: reduce) { .kept-place .flash.ok[role="status"] { animation: none; } }
