:root {
  --bg: #f7f7f5; --surface: #ffffff; --text: #1d1d1f; --muted: #6b6b70; --border: #e3e3e0;
  --accent: #3b6ef5; --green: #1f9d55; --amber: #c27c0e; --red: #d64545; --done: #6b7fa8;
  --radius: 10px; --gap: 1rem;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #141416; --surface: #1d1d20; --text: #ececee; --muted: #9a9aa2; --border: #2e2e33;
          --accent: #7b9cff; --green: #4cc38a; --amber: #f0b44c; --red: #f07070; --done: #8fa0c8; }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); line-height: 1.5; }
a { color: var(--accent); text-decoration: none; }
h1, h2 { line-height: 1.2; margin: 0 0 .25rem; }
h1 { font-size: 1.6rem; } h2 { font-size: 1.1rem; }
.container { max-width: 1100px; margin: 0 auto; padding: 1.5rem 1rem 4rem; }
.container.narrow { max-width: 560px; }
.topbar { background: var(--surface); border-bottom: 1px solid var(--border); }
.topbar-inner { display: flex; align-items: center; gap: 1.5rem; max-width: 1100px; margin: 0 auto; padding: .75rem 1rem; }
.brand { font-weight: 700; color: var(--text); }
.nav { display: flex; gap: 1rem; flex: 1; }
.muted { color: var(--muted); font-size: .9rem; }
.empty { color: var(--muted); padding: 2rem 0; text-align: center; }
.flash { padding: .6rem .9rem; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border); }
.flash-alert, .errors { color: var(--red); }
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: var(--gap); margin-bottom: 1rem; flex-wrap: wrap; }
.actions { display: flex; gap: .5rem; align-items: center; }
.button, input[type=submit], button { font: inherit; cursor: pointer; border: 1px solid var(--accent); background: var(--accent); color: #fff; padding: .4rem .9rem; border-radius: 8px; }
.button.secondary { background: transparent; color: var(--accent); }
.button.danger, button.danger { background: transparent; border-color: var(--red); color: var(--red); margin-top: 1rem; }
button.link, .link { background: none; border: none; color: var(--accent); padding: 0; }
input, textarea, select { max-width: 100%; font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: .4rem .6rem; }
.stack { display: grid; grid-template-columns: minmax(0, 1fr); gap: .4rem; }
.stack input:not([type=submit]):not([type=checkbox]), .stack textarea, .stack select { width: 100%; }
.stack input[type=submit] { justify-self: start; margin-top: .5rem; }
.inline-form { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: .5rem; }
/* Rails sets size= from maxlength, which makes text inputs huge; let flexbox size them instead. */
.inline-form input[type=text] { flex: 1 1 12rem; width: 0; min-width: 12rem; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: var(--gap); }
.card { display: block; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; color: var(--text); }
.card:hover { border-color: var(--accent); }
.card-head { display: flex; justify-content: space-between; gap: .5rem; align-items: flex-start; }
.status { font-size: .75rem; font-weight: 600; padding: .15rem .55rem; border-radius: 999px; white-space: nowrap; }
.status-on_track { color: var(--green); background: color-mix(in srgb, var(--green) 14%, transparent); }
.status-at_risk { color: var(--amber); background: color-mix(in srgb, var(--amber) 16%, transparent); }
.status-done { color: var(--done); background: color-mix(in srgb, var(--done) 16%, transparent); }
.progress-row { display: flex; align-items: center; gap: .6rem; margin: .5rem 0; }
.progress { flex: 1; height: 8px; background: var(--border); border-radius: 999px; overflow: hidden; }
.progress span { display: block; height: 100%; background: var(--accent); border-radius: 999px; transition: width .3s; }
.progress-label { font-size: .85rem; color: var(--muted); min-width: 3ch; text-align: right; }
.layout { display: grid; grid-template-columns: minmax(0, 1fr) 260px; gap: 1.5rem; margin-top: 1.5rem; }
@media (max-width: 760px) { .layout { grid-template-columns: minmax(0, 1fr); } }
.goal { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; margin-bottom: var(--gap); }
.goal-head { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; }
.goal-head h2 { margin: 0; flex: 1; }
.tasks { list-style: none; margin: .5rem 0 0; padding: 0; }
.task { display: flex; align-items: center; gap: .6rem; padding: .4rem .25rem; border-bottom: 1px solid var(--border); }
.task:last-child { border-bottom: none; }
.task .handle { cursor: grab; color: var(--muted); user-select: none; }
.task .task-title { flex: 1; color: var(--text); }
.task.is-done .task-title { color: var(--muted); text-decoration: line-through; }
.task.is-overdue time { color: var(--red); font-weight: 600; }
.task form { margin: 0; }
.check { width: 1.3rem; height: 1.3rem; padding: 0; border-radius: 6px; background: transparent; border: 2px solid var(--muted); color: var(--green); line-height: 1; font-size: .8rem; }
.task.is-done .check { border-color: var(--green); }
.pill { font-size: .75rem; padding: .1rem .5rem; border-radius: 999px; background: var(--bg); border: 1px solid var(--border); color: var(--muted); }
.activity h2 { font-size: 1rem; }
.activity-item { font-size: .88rem; margin: 0 0 .6rem; }
.agenda-section { margin-bottom: 1.5rem; }
.count { font-size: .8rem; color: var(--muted); font-weight: 400; }
.plain { list-style: none; padding: 0; margin: 0 0 .75rem; }
.plain li { display: flex; flex-wrap: wrap; gap: .4rem; align-items: baseline; margin-bottom: .4rem; font-size: .9rem; }
.sharing { margin-bottom: 1.5rem; }
span.check { display: inline-grid; place-items: center; }
.thread { margin-top: .5rem; flex-basis: 100%; }
.thread summary { cursor: pointer; font-size: .85rem; }
.comment { border-left: 3px solid var(--border); padding: .2rem .7rem; margin: .5rem 0; font-size: .92rem; }
.comment p { margin: .2rem 0 0; }
.thread textarea { flex: 1; min-width: 12rem; }
.task { flex-wrap: wrap; }
.table { width: 100%; border-collapse: collapse; margin-top: 1rem; font-size: .92rem; }
.table th, .table td { text-align: left; padding: .45rem .4rem; border-bottom: 1px solid var(--border); }
code.token { display: inline-block; padding: .5rem .75rem; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; user-select: all; word-break: break-all; }
.repeat { color: var(--muted); font-size: .9rem; }
