/* Layout: a calm two-pane desk. Projects on the left, one project's checklist on the right. */
:root {
  --bg: #f8f6ff;
  --panel: #ffffff;
  --sunk: #f6f3ff;
  --ink: #211a3a;
  --soft: #6e6790;
  --faint: #aaa3c4;
  --line: #ebe6f7;
  --brand: #5b2bc4;
  --brand-ink: #ffffff;
  --brand-wash: #eee7ff;
  --gold: #e89a1c;
  --gold-wash: #fff2dc;
  --good: #1f9d6a;
  --good-wash: #e3f6ee;
  --bad: #d6455d;
  --bad-wash: #fde8ec;
  --shadow: 0 1px 2px rgba(91, 43, 196, 0.04), 0 10px 30px -16px rgba(91, 43, 196, 0.22);
  --display: "Bricolage Grotesque", "Inter", system-ui, sans-serif;
  --body: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, Menlo, monospace;
  --r: 14px;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.55 var(--body); -webkit-font-smoothing: antialiased; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 8px; }
[hidden] { display: none !important; }
h1, h2, h3 { font-family: var(--display); letter-spacing: -0.02em; text-wrap: balance; margin: 0; }
.muted { color: var(--soft); }
.tiny { font-size: 12px; }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: 300px 1fr; height: 100%; }
.side { background: var(--panel); border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.brand { display: flex; align-items: center; gap: 10px; padding: 20px 18px 14px; }
.brand svg { width: 30px; height: 30px; flex: none; }
.brand b { font: 700 17px/1 var(--display); letter-spacing: -0.02em; }
.brand small { display: block; font: 500 11px var(--body); color: var(--soft); margin-top: 3px; letter-spacing: .02em; }
.side-tools { padding: 0 14px 10px; display: grid; gap: 8px; }
.search { width: 100%; border: 1px solid var(--line); background: var(--sunk); border-radius: 10px; padding: 9px 12px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; padding: 2px 14px 10px; }
.chip { border: 1px solid var(--line); background: transparent; border-radius: 99px; padding: 3px 10px; font-size: 12px; color: var(--soft); }
.chip[aria-pressed="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.plist { list-style: none; margin: 0; padding: 4px 8px 12px; overflow: auto; flex: 1; min-height: 0; }
.pitem { display: block; width: 100%; text-align: left; border: 0; background: transparent; border-radius: 12px; padding: 11px 12px; margin-bottom: 2px; }
.pitem:hover { background: var(--sunk); }
.pitem[aria-current="true"] { background: var(--brand-wash); }
.pitem .top { display: flex; align-items: center; gap: 8px; }
.pitem .nm { font-weight: 600; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pitem .sub { font-size: 12.5px; color: var(--soft); display: flex; justify-content: space-between; gap: 8px; margin-top: 2px; }
.bar { height: 4px; border-radius: 4px; background: var(--line); margin-top: 8px; overflow: hidden; }
.bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--brand), var(--gold)); border-radius: 4px; transition: width .4s ease; }
.side-foot { border-top: 1px solid var(--line); padding: 10px 12px; display: flex; align-items: center; gap: 6px; }
.side-foot .me { flex: 1; min-width: 0; font-size: 13px; color: var(--soft); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.empty-list { padding: 24px 14px; color: var(--soft); font-size: 14px; text-align: center; }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; border: 1px solid var(--line); background: var(--panel); border-radius: 10px; padding: 8px 14px; font-weight: 600; font-size: 14px; transition: background .15s, transform .1s; }
.btn:hover { background: var(--sunk); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--brand); color: var(--brand-ink); border-color: transparent; }
.btn.primary:hover { filter: brightness(1.07); }
.btn.danger { color: var(--bad); }
.btn.danger.solid { background: var(--bad); color: #fff; border-color: transparent; }
.btn.ghost { border-color: transparent; background: transparent; color: var(--soft); }
.btn.ghost:hover { background: var(--sunk); color: var(--ink); }
.btn.sm { padding: 5px 10px; font-size: 13px; border-radius: 8px; }
.icon { width: 16px; height: 16px; flex: none; }

/* ---------- main ---------- */
.main { overflow: auto; min-width: 0; }
.wrap { max-width: 920px; margin: 0 auto; padding: 28px 32px 80px; }
.back { display: none; }
.head { display: flex; gap: 20px; align-items: flex-start; }
.head-text { flex: 1; min-width: 0; }
.title-input { font: 700 30px/1.15 var(--display); letter-spacing: -0.03em; border: 0; background: transparent; width: 100%; padding: 2px 0; border-radius: 8px; }
.title-input:hover { background: var(--sunk); }
.meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; margin-top: 8px; color: var(--soft); font-size: 14px; }
.status-select { appearance: none; border: 0; border-radius: 99px; padding: 4px 26px 4px 12px; font-size: 13px; font-weight: 600; background: var(--brand-wash) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%23888' stroke-width='1.5'/%3E%3C/svg%3E") no-repeat right 10px center; color: var(--brand); }
.ring { position: relative; width: 74px; height: 74px; flex: none; }
.ring svg { width: 74px; height: 74px; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 7; }
.ring .track { stroke: var(--line); }
.ring .val { stroke: url(#ringGrad); stroke-linecap: round; transition: stroke-dashoffset .5s ease; }
.ring span { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; font: 700 15px/1.05 var(--display); }
.ring span small { display: block; font: 500 10px var(--body); color: var(--soft); }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin: 22px 0 20px; overflow-x: auto; }
.tab { border: 0; background: transparent; padding: 10px 14px; font-weight: 600; color: var(--soft); border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tab[aria-selected="true"] { color: var(--ink); border-color: var(--brand); }
.tab .count { font: 500 11px var(--mono); color: var(--faint); margin-left: 4px; }

/* ---------- checklist ---------- */
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 16px; }
.toolbar .spacer { flex: 1; }
.section { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); margin-bottom: 14px; box-shadow: var(--shadow); overflow: hidden; }
.sec-head { display: flex; align-items: center; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.sec-num { font: 600 12px var(--mono); color: var(--brand); background: var(--brand-wash); border-radius: 8px; padding: 3px 7px; }
.sec-head h3 { font-size: 16px; flex: 1; }
.sec-head .mini { font: 500 12px var(--mono); color: var(--soft); }
.q { display: grid; grid-template-columns: 28px 1fr; gap: 12px; padding: 14px 18px; border-top: 1px solid var(--line); }
.q:first-of-type { border-top: 0; }
.check { width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--faint); background: transparent; display: grid; place-items: center; padding: 0; margin-top: 1px; transition: all .18s; }
.check:hover { border-color: var(--brand); }
.check svg { width: 13px; height: 13px; opacity: 0; transform: scale(.6); transition: all .18s; }
.q.done .check { background: var(--good); border-color: var(--good); color: #fff; }
.q.done .check svg { opacity: 1; transform: none; }
.q-text { font-weight: 600; }
.q.done .q-text { color: var(--soft); }
.q-hint { font-size: 13px; color: var(--soft); margin-top: 2px; }
.q-body { min-width: 0; }
.answer { width: 100%; margin-top: 8px; border: 1px solid transparent; background: var(--sunk); border-radius: 10px; padding: 9px 12px; resize: none; min-height: 40px; line-height: 1.5; transition: border-color .15s, background .15s; }
.answer:focus { outline: none; border-color: var(--brand); background: var(--panel); }
.answer::placeholder { color: var(--faint); }
.q-foot { display: flex; gap: 10px; align-items: center; margin-top: 5px; font-size: 12px; color: var(--faint); min-height: 18px; }
.q-foot .del { margin-left: auto; }
.add-q { display: flex; gap: 8px; padding: 12px 18px 16px; border-top: 1px dashed var(--line); }
.add-q input { flex: 1; min-width: 0; border: 1px solid var(--line); background: transparent; border-radius: 10px; padding: 7px 12px; }
.hide-done .q.done { display: none; }

/* ---------- forms / details ---------- */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 20px; box-shadow: var(--shadow); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 16px; }
.field label { display: block; font-size: 12px; font-weight: 600; color: var(--soft); letter-spacing: .03em; text-transform: uppercase; margin-bottom: 5px; }
.field input, .field select, .field textarea { width: 100%; border: 1px solid var(--line); background: var(--sunk); border-radius: 10px; padding: 9px 12px; }
.field textarea { min-height: 110px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--brand); background: var(--panel); }
.full { grid-column: 1 / -1; }
.danger-zone { margin-top: 22px; display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; border: 1px solid var(--bad-wash); background: var(--bad-wash); border-radius: var(--r); padding: 14px 18px; }

/* ---------- notes ---------- */
.composer { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 12px; box-shadow: var(--shadow); margin-bottom: 18px; }
.composer textarea { width: 100%; border: 0; background: transparent; resize: none; min-height: 64px; padding: 6px 6px; }
.composer textarea:focus { outline: none; }
.composer .row { display: flex; gap: 8px; align-items: center; justify-content: flex-end; flex-wrap: wrap; }
.composer .row .kinds { margin-right: auto; display: flex; gap: 6px; }
.notes { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr)); gap: 12px; }
.note { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px 10px; display: flex; flex-direction: column; min-width: 0; }
.note.pinned { background: var(--gold-wash); border-color: transparent; }
.note .txt { white-space: pre-wrap; word-break: break-word; flex: 1; }
.note .foot { display: flex; align-items: center; gap: 4px; margin-top: 10px; font-size: 12px; color: var(--soft); }
.note .foot .who { flex: 1; min-width: 0; }
.note textarea { width: 100%; min-height: 90px; border: 1px solid var(--brand); border-radius: 10px; padding: 8px 10px; background: var(--panel); resize: vertical; }

/* ---------- timeline ---------- */
.tl { list-style: none; margin: 0; padding: 0; position: relative; }
.tl::before { content: ""; position: absolute; left: 15px; top: 6px; bottom: 6px; width: 2px; background: var(--line); }
.tl li { position: relative; display: grid; grid-template-columns: 32px 1fr; gap: 12px; padding: 8px 0; }
.dot { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; background: var(--panel); border: 2px solid var(--line); z-index: 1; }
.dot svg { width: 15px; height: 15px; }
.k-call .dot { border-color: var(--good); color: var(--good); }
.k-meeting .dot { border-color: var(--brand); color: var(--brand); }
.k-update .dot { border-color: var(--gold); color: var(--gold); }
.k-auto .dot { width: 14px; height: 14px; margin: 9px; border-width: 0; background: var(--line); }
.tl .body { min-width: 0; padding-top: 4px; }
.tl .k-auto .body { padding-top: 6px; color: var(--soft); font-size: 14px; }
.tl .txt { white-space: pre-wrap; word-break: break-word; }
.tl .when { font-size: 12px; color: var(--faint); margin-top: 2px; display: flex; gap: 8px; align-items: center; }
.tl .proj { color: var(--brand); font-weight: 600; border: 0; background: none; padding: 0; font-size: 12px; }
.kind { border: 1px solid var(--line); background: transparent; border-radius: 99px; padding: 4px 12px; font-size: 13px; font-weight: 600; color: var(--soft); }
.kind[aria-pressed="true"] { background: var(--brand-wash); color: var(--brand); border-color: transparent; }

/* ---------- empty / welcome ---------- */
.welcome { max-width: 520px; margin: 12vh auto 0; text-align: center; padding: 0 24px; }
.welcome h1 { font-size: 34px; line-height: 1.1; }
.welcome p { color: var(--soft); }
.stats { display: flex; justify-content: center; gap: 28px; margin: 26px 0; }
.stats b { display: block; font: 700 28px var(--display); }
.stats span { font-size: 12px; color: var(--soft); text-transform: uppercase; letter-spacing: .05em; }

/* ---------- dialog / toast ---------- */
.scrim { position: fixed; inset: 0; background: rgba(20, 14, 36, .45); display: grid; place-items: center; padding: 16px; z-index: 50; animation: fade .15s ease; }
.dialog { background: var(--panel); border-radius: 18px; padding: 24px; width: min(480px, 100%); box-shadow: 0 30px 80px -20px rgba(0,0,0,.4); }
.dialog h2 { font-size: 22px; margin-bottom: 6px; }
.dialog .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }
.toast { position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-size: 14px; font-weight: 500; z-index: 60; box-shadow: var(--shadow); animation: up .2s ease; max-width: calc(100% - 32px); }
.toast.err { background: var(--bad); color: #fff; }
@keyframes fade { from { opacity: 0; } }
@keyframes up { from { opacity: 0; transform: translate(-50%, 8px); } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* ---------- phone ---------- */
@media (max-width: 820px) {
  .shell { grid-template-columns: 1fr; }
  .shell.has-main .side { display: none; }
  .shell:not(.has-main) .main { display: none; }
  .side { border-right: 0; min-height: 100%; padding-top: env(safe-area-inset-top, 0px); }
  .wrap { padding: 16px max(16px, env(safe-area-inset-right, 0px)) 80px max(16px, env(safe-area-inset-left, 0px)); }
  .back { display: inline-flex; margin-bottom: 10px; }
  .title-input { font-size: 24px; }
  .ring, .ring svg { width: 60px; height: 60px; }
  .grid2 { grid-template-columns: 1fr; }
  .q { padding: 12px 14px; }
  .sec-head { padding: 12px 14px; }
}

/* ---------- brighter look ---------- */
body { background: radial-gradient(1200px 600px at 100% -10%, #efe7ff 0%, transparent 55%), radial-gradient(900px 500px at -10% 110%, #fff1db 0%, transparent 55%), var(--bg); background-attachment: fixed; }
.side { background: rgba(255,255,255,.78); backdrop-filter: blur(14px); }
.search { background: #fff; }
.pitem { border: 1px solid transparent; }
.pitem:hover { background: #fff; border-color: var(--line); box-shadow: var(--shadow); }
.pitem[aria-current="true"] { background: #fff; border-color: #d9cdfb; box-shadow: 0 8px 24px -14px rgba(91,43,196,.45); }
.btn.primary { background: linear-gradient(135deg, #6d3df0, #5126b8); box-shadow: 0 6px 16px -8px rgba(91,43,196,.7); }
.head { background: #fff; border: 1px solid var(--line); border-radius: 20px; padding: 22px 24px; box-shadow: var(--shadow); position: relative; overflow: hidden; }
.head::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 4px; background: linear-gradient(90deg, #7c4dff, #c084fc, #f2a93b); }
.title-input:hover { background: var(--sunk); }
.section { border-color: var(--line); }
.sec-head { background: linear-gradient(180deg, #faf8ff, #fff); }
.sec-num { background: linear-gradient(135deg, #7c4dff, #a78bfa); color: #fff; }
.answer { background: #fff; border-color: var(--line); }
.answer:hover { border-color: #d9cdfb; }
.q { transition: background .2s; }
.q:hover { background: #fdfcff; }
.q.done { background: linear-gradient(90deg, #f1fbf6, #fff 60%); }
.check { width: 26px; height: 26px; border-color: #cfc6e6; }
.q.done .check { box-shadow: 0 4px 10px -4px rgba(31,157,106,.6); animation: pop .3s ease; }
@keyframes pop { 50% { transform: scale(1.18); } }
.tab[aria-selected="true"] { color: var(--brand); }
.card, .composer { border-color: var(--line); }
.note { box-shadow: var(--shadow); }
.note.pinned { background: linear-gradient(135deg, #fff6e5, #fff); border: 1px solid #f6dcaa; }
.welcome h1 { background: linear-gradient(90deg, #4a1fb0, #7c4dff 60%, #d4892a); -webkit-background-clip: text; background-clip: text; color: transparent; }
.stats > div { background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 14px 22px; box-shadow: var(--shadow); }

/* status colours */
.st { display: inline-block; border-radius: 99px; padding: 2px 9px; font-size: 11.5px; font-weight: 600; }
.st-lead { background: #eef2ff; color: #4f5bd5; }
.st-discovery { background: #f1eaff; color: #6d3df0; }
.st-proposal { background: #fff3dc; color: #b7700b; }
.st-building { background: #e5f2ff; color: #1f6fd1; }
.st-live { background: #e3f7ee; color: #17885b; }
.st-on-hold { background: #f0eef5; color: #6e6790; }
.st-lost { background: #fde8ec; color: #c43a52; }
.status-select.st-lead { background-color: #eef2ff; color: #4f5bd5; }
.status-select.st-discovery { background-color: #f1eaff; color: #6d3df0; }
.status-select.st-proposal { background-color: #fff3dc; color: #b7700b; }
.status-select.st-building { background-color: #e5f2ff; color: #1f6fd1; }
.status-select.st-live { background-color: #e3f7ee; color: #17885b; }
.status-select.st-on-hold { background-color: #f0eef5; color: #6e6790; }
.status-select.st-lost { background-color: #fde8ec; color: #c43a52; }
@media (max-width: 820px) { .head { padding: 16px; border-radius: 16px; } .side { background: #fff; } }
