:root {
  --bg: #eef1f3; --surface: #ffffff; --surface-2: #fafbfc; --sunken: #e2e2e2;
  --line: #d8d8d8; --line-strong: #c2c2c2;
  --ink: #101820; --ink-2: #4b5560; --ink-3: #7a828b;
  --accent: #1b76bc; --accent-ink: #ffffff; --accent-soft: #e9f2f9; --accent-line: #b5d5ed;
  --green: #1f7a4d; --green-soft: #e6f4ec; --green-line: #b7ddc7;
  --amber: #9a6b12; --amber-soft: #fbf1de; --amber-line: #ecd6a4;
  --red: #a33228; --red-soft: #fbeceb; --red-line: #eec3bf;
  --purple: #5b3d9e; --purple-soft: #efeaf9; --purple-line: #cfc2ea;
  --teal: #0f7c76; --teal-soft: #e3f3f2; --teal-line: #aeded9;
  --radius: 12px; --radius-lg: 18px;
  --shadow-sm: 0 1px 2px rgba(16,24,32,.07), 0 1px 1px rgba(16,24,32,.04);
  --shadow-md: 0 4px 20px rgba(16,24,32,.10), 0 1px 3px rgba(16,24,32,.05);
  --sans: 'Open Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --serif: 'Libre Baskerville', Georgia, 'Times New Roman', serif;
  --side-w: 236px;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { font-family: var(--sans); background: var(--bg); color: var(--ink); -webkit-font-smoothing: antialiased; line-height: 1.5; }
[hidden] { display: none !important; }
button, input, textarea, select { font-family: var(--sans); font-size: 14px; color: var(--ink); }
button { cursor: pointer; }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: var(--side-w) 1fr; min-height: 100vh; }
.side { background: var(--surface); border-right: 1px solid var(--line); padding: 20px 14px; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 18px; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 10px; padding: 0 8px; }
.brand-mark { width: 38px; height: 38px; }
.brand-name { font-weight: 700; letter-spacing: .05em; font-size: 11.5px; text-transform: uppercase; color: var(--ink-3); line-height: 1.2; }
.brand-sub { font-family: var(--serif); font-size: 17px; line-height: 1.2; }
.menu { display: flex; flex-direction: column; gap: 14px; flex: 1; }
.menu-group { display: flex; flex-direction: column; gap: 2px; }
.menu-label { font-size: 10.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); padding: 0 10px 4px; }
.menu-item { display: flex; align-items: center; gap: 8px; width: 100%; text-align: left; border: none; background: none; border-radius: 9px; padding: 8px 10px; font-size: 13.5px; font-weight: 600; color: var(--ink-2); }
.menu-item:hover { background: var(--surface-2); color: var(--ink); }
.menu-item.active { background: var(--ink); color: #fff; }
.menu-item .count { margin-left: auto; font-size: 11.5px; color: var(--ink-3); background: var(--sunken); border-radius: 999px; padding: 0 7px; min-width: 20px; text-align: center; }
.menu-item .count:empty { display: none; }
.menu-item.active .count { background: rgba(255,255,255,.18); color: #fff; }
.menu-item.attention .count { background: var(--amber-soft); color: var(--amber); }
.menu-item.active.attention .count { background: rgba(255,255,255,.18); color: #fff; }
.dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.dot.t-project { background: var(--purple); } .dot.t-task { background: var(--accent); } .dot.t-communicate { background: var(--green); } .dot.t-delegate { background: var(--amber); } .dot.t-idea { background: var(--teal); }
.side-foot { display: flex; align-items: center; gap: 10px; padding: 0 8px; }
.foot-mark { width: 30px; height: 30px; opacity: .85; }
.side-link { font-size: 12.5px; font-weight: 600; color: var(--ink-2); text-decoration: none; }
.side-link:hover { color: var(--ink); text-decoration: underline; }

.main { padding: 20px 28px calc(60px + env(safe-area-inset-bottom)); max-width: 860px; width: 100%; }

/* ---------- capture ---------- */
.capture { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); padding: 12px; margin-bottom: 22px; }
.capture textarea { width: 100%; border: none; resize: none; font-size: 16px; line-height: 1.45; padding: 6px 4px; background: transparent; min-height: 54px; }
.capture textarea:focus { outline: none; }
.capture-row { display: flex; align-items: center; gap: 10px; margin-top: 4px; }
.capture-hint { flex: 1; font-size: 12px; color: var(--ink-3); }
.btn { border: 1px solid var(--line-strong); background: var(--surface); border-radius: 9px; padding: 9px 16px; font-weight: 600; font-size: 13.5px; }
.btn:hover { background: var(--surface-2); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { filter: brightness(1.08); background: var(--accent); }
.btn-danger { color: var(--red); border-color: var(--red-line); }
.btn-danger:hover { background: var(--red-soft); }
.btn-sm { padding: 6px 11px; font-size: 12.5px; }

/* ---------- view head ---------- */
.view-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 12px; }
.view-title { font-family: var(--serif); font-weight: 400; font-size: 24px; margin: 0; line-height: 1.2; }
.view-blurb { font-size: 13px; color: var(--ink-2); margin: 4px 0 0; }
.search { width: 220px; border: 1px solid var(--line); border-radius: 999px; padding: 8px 14px; background: var(--surface); font-size: 13.5px; flex: none; }
.search:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.filter-bar { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; font-size: 12.5px; color: var(--ink-2); }
.filter-bar .chip { min-height: 28px; padding: 3px 10px; }

/* ---------- list / cards ---------- */
.list { display: flex; flex-direction: column; gap: 8px; }
.empty { text-align: center; color: var(--ink-3); padding: 36px 16px 44px; font-size: 14px; }
.empty img { width: 72px; height: 72px; display: block; margin: 0 auto 12px; }
.empty b { display: block; font-family: var(--serif); font-weight: 400; font-size: 18px; color: var(--ink-2); margin-bottom: 6px; }
.card { background: var(--surface); border: 1px solid var(--line); border-left-width: 4px; border-left-color: var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); padding: 10px 12px 10px 11px; outline: none; }
.card:focus-visible { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.card.p-high { border-left-color: var(--red); }
.card.p-low { border-left-color: var(--line-strong); }
.card.p-low .card-text { color: var(--ink-2); }
.card.done { opacity: .6; }
.card.child { margin-left: 26px; }
.card-head { display: flex; align-items: flex-start; gap: 10px; }
.check { flex: none; width: 22px; height: 22px; margin-top: 2px; border: 1.5px solid var(--line-strong); border-radius: 50%; background: var(--surface); display: grid; place-items: center; padding: 0; }
.check:hover { border-color: var(--green); }
.check.on { background: var(--green); border-color: var(--green); color: #fff; }
.check svg { width: 12px; height: 12px; }
.card-main { flex: 1; min-width: 0; }
.card-text { font-size: 15px; line-height: 1.4; word-wrap: break-word; cursor: text; border-radius: 6px; padding: 1px 4px; margin: 0 -4px; }
.card-text:hover { background: var(--surface-2); }
.card-text[contenteditable="true"] { background: var(--surface-2); outline: 2px solid var(--accent-line); }
.card.done .card-text { text-decoration: line-through; color: var(--ink-3); }
.card-sub { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; margin-top: 5px; font-size: 12px; color: var(--ink-3); }
.card-sub .crumb { color: var(--ink-2); }
.card-sub .crumb::before { content: "in "; color: var(--ink-3); }
.missing { color: var(--amber); font-weight: 600; }
.missing::before { content: "needs: "; font-weight: 400; }
.expand { flex: none; border: none; background: none; color: var(--ink-3); width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; margin: -3px -6px 0 0; }
.expand:hover { background: var(--sunken); color: var(--ink); }
.expand svg { width: 16px; height: 16px; transition: transform .15s; }
.card.open .expand svg { transform: rotate(180deg); }

/* badges + chips */
.badge { display: inline-flex; align-items: center; font-size: 11px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; padding: 1px 8px; border-radius: 999px; border: 1px solid; }
.t-project { color: var(--purple); background: var(--purple-soft); border-color: var(--purple-line); }
.t-task { color: var(--accent); background: var(--accent-soft); border-color: var(--accent-line); }
.t-communicate { color: var(--green); background: var(--green-soft); border-color: var(--green-line); }
.t-delegate { color: var(--amber); background: var(--amber-soft); border-color: var(--amber-line); }
.t-idea { color: var(--teal); background: var(--teal-soft); border-color: var(--teal-line); }
.s-waiting { color: var(--ink-2); background: var(--sunken); border-color: var(--line-strong); }
.p-badge-high { color: var(--red); background: var(--red-soft); border-color: var(--red-line); }
.area-chip { background: none; border: 1px solid var(--line); border-radius: 999px; padding: 0 8px; font-size: 11.5px; font-weight: 600; color: var(--ink-2); line-height: 18px; }
.area-chip:hover { border-color: var(--ink-3); color: var(--ink); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chip { border: 1px solid var(--line); background: var(--surface-2); border-radius: 999px; padding: 6px 12px; font-size: 12.5px; font-weight: 600; color: var(--ink-2); min-height: 32px; }
.chip:hover { border-color: var(--line-strong); background: var(--surface); }
.chip.on { background: var(--ink); border-color: var(--ink); color: #fff; }
.chip kbd { font-family: inherit; font-size: 10.5px; color: var(--ink-3); margin-left: 5px; border: 1px solid var(--line); border-radius: 4px; padding: 0 4px; }
.chip.on kbd { color: rgba(255,255,255,.7); border-color: rgba(255,255,255,.3); }
.chip.t-project.on { background: var(--purple); border-color: var(--purple); }
.chip.t-task.on { background: var(--accent); border-color: var(--accent); }
.chip.t-communicate.on { background: var(--green); border-color: var(--green); }
.chip.t-delegate.on { background: var(--amber); border-color: var(--amber); }
.chip.t-idea.on { background: var(--teal); border-color: var(--teal); }
.chip.pr-high.on { background: var(--red); border-color: var(--red); }

/* details */
.details { margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--line); display: grid; gap: 10px; }
.field { display: grid; gap: 4px; }
.field label { font-size: 11.5px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--ink-3); }
.field label .req { color: var(--amber); font-weight: 400; text-transform: none; letter-spacing: 0; margin-left: 6px; }
.field input, .field textarea, .field select { width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 9px 10px; background: var(--surface-2); font-size: 14px; }
.field input:focus, .field textarea:focus, .field select:focus { outline: none; border-color: var(--accent); background: var(--surface); box-shadow: 0 0 0 3px var(--accent-soft); }
.field textarea { resize: vertical; min-height: 60px; }
.field .chips { margin-top: 0; }
.field-row { display: grid; gap: 10px; grid-template-columns: 1fr 1fr; }
.details-foot { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.details-foot .spacer { flex: 1; }
.meta { font-size: 11.5px; color: var(--ink-3); }

/* project view */
.project-block { display: flex; flex-direction: column; gap: 8px; }
.project-progress { height: 4px; background: var(--sunken); border-radius: 2px; margin-top: 8px; overflow: hidden; }
.project-progress i { display: block; height: 100%; background: var(--purple); }
.add-child { margin-left: 26px; display: flex; gap: 8px; }
.add-child input { flex: 1; border: 1px dashed var(--line-strong); border-radius: 9px; padding: 8px 12px; background: transparent; font-size: 14px; }
.add-child input:focus { outline: none; border-style: solid; border-color: var(--accent); background: var(--surface); }

.toast { position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 13px; box-shadow: var(--shadow-md); z-index: 50; max-width: calc(100vw - 32px); display: flex; align-items: center; gap: 10px; }
.toast img { width: 22px; height: 22px; }

/* ---------- phone ---------- */
@media (max-width: 800px) {
  .shell { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .side { position: sticky; top: 0; height: auto; z-index: 20; padding: 10px 12px; padding-top: max(10px, env(safe-area-inset-top)); gap: 8px; border-right: none; border-bottom: 1px solid var(--line); background: rgba(255,255,255,.95); backdrop-filter: blur(8px); }
  .brand { display: none; }
  .side-foot { display: none; }
  .menu { flex: none; flex-direction: row; align-items: center; gap: 6px; overflow-x: auto; scrollbar-width: none; margin: 0 -12px; padding: 0 12px; }
  .menu::-webkit-scrollbar { display: none; }
  .menu-group { flex-direction: row; align-items: center; gap: 6px; }
  .menu-group + .menu-group::before { content: ""; width: 1px; height: 22px; background: var(--line); margin: 0 2px; }
  .menu-label { display: none; }
  .menu-item { width: auto; flex: none; border: 1px solid var(--line); border-radius: 999px; padding: 6px 12px; font-size: 13px; white-space: nowrap; }
  .menu-item.active { border-color: var(--ink); }
  .menu-item .count { margin-left: 0; }
  .main { padding: 14px 14px calc(60px + env(safe-area-inset-bottom)); }
  .capture { margin-bottom: 14px; }
  .view-head { flex-direction: column; gap: 8px; }
  .view-title { font-size: 20px; }
  .search { width: 100%; }
  .field-row { grid-template-columns: 1fr; }
  .chip kbd { display: none; }
  .card.child { margin-left: 14px; }
  .add-child { margin-left: 14px; }
}
