:root {
  --bg: #f6f6f4; --panel: #ffffff; --ink: #1d1f23; --muted: #6b6f76; --line: #e2e2de;
  --accent: #3b5bdb; --accent-ink: #fff; --ok: #2f9e44; --warn: #e67700; --bad: #c92a2a;
  --vault: #7048e8; --chip: #eef0f3; --radius: 8px;
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14161a; --panel: #1c1f24; --ink: #e6e7e9; --muted: #9096a0; --line: #2c3036;
    --accent: #748ffc; --accent-ink: #0b0d10; --chip: #262a30; --vault: #9775fa;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
.muted { color: var(--muted); }
.center { text-align: center; margin-top: 20vh; }
.small { font-size: 13px; }
.mono { font-family: ui-monospace, "JetBrains Mono", monospace; font-size: 13px; }

/* layout */
.shell { display: grid; grid-template-columns: 260px minmax(0, 1fr); min-height: 100vh; }
.side { background: var(--panel); border-right: 1px solid var(--line); padding: 14px; display: flex;
        flex-direction: column; gap: 4px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.side .brand { font-weight: 700; font-size: 17px; margin: 2px 6px 10px; display: flex; justify-content: space-between; }
.side h4 { margin: 14px 6px 4px; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.navitem { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 6px; cursor: pointer;
           border: 0; background: none; text-align: left; width: 100%; }
.navitem:hover { background: var(--chip); }
.navitem.active { background: var(--accent); color: var(--accent-ink); }
.navitem .count { margin-left: auto; font-size: 12px; opacity: .7; }
.main { padding: 22px 28px; max-width: 1100px; width: 100%; }
.menu-btn { display: none; }
@media (max-width: 760px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .side { position: fixed; inset: 0 30% 0 0; z-index: 10; transform: translateX(-102%); transition: transform .15s; }
  .side.open { transform: none; box-shadow: 0 0 0 100vw rgba(0,0,0,.35); }
  .main { padding: 14px 16px; }
  .menu-btn { display: inline-block; }
}

/* elements */
.btn { border: 1px solid var(--line); background: var(--panel); padding: 6px 12px; border-radius: 6px; cursor: pointer; }
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.danger { color: var(--bad); }
.btn.sm { padding: 2px 8px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: default; }
input[type=text], input[type=password], input[type=number], input[type=url], select, textarea {
  border: 1px solid var(--line); background: var(--bg); border-radius: 6px; padding: 7px 9px; width: 100%; }
textarea { min-height: 90px; resize: vertical; }
label { display: block; font-size: 13px; color: var(--muted); margin: 10px 0 4px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row > .grow { flex: 1; min-width: 160px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 14px; }
.header { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.header h2 { margin: 0; font-size: 22px; }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; }
.tab { border: 0; background: none; padding: 8px 12px; cursor: pointer; border-bottom: 2px solid transparent; color: var(--muted); white-space: nowrap; }
.tab.active { color: var(--ink); border-color: var(--accent); }
.chip { display: inline-block; background: var(--chip); border-radius: 99px; padding: 1px 8px; font-size: 12px; }
.chip.vault { background: var(--vault); color: #fff; }
.chip.agent { background: #e7f5ff; color: #1864ab; }
@media (prefers-color-scheme: dark) { .chip.agent { background: #1c3a5a; color: #a5d8ff; } }
.err { color: var(--bad); margin: 8px 0; min-height: 1em; }
.ok { color: var(--ok); }
table { width: 100%; border-collapse: collapse; }
td, th { text-align: left; padding: 7px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; color: var(--muted); font-weight: 600; }

/* tasks */
.quickadd { display: flex; gap: 8px; margin-bottom: 12px; }
.group h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 18px 0 6px; }
.task { display: flex; align-items: flex-start; gap: 10px; padding: 8px 10px; border: 1px solid var(--line);
        background: var(--panel); border-radius: 6px; margin-bottom: 6px; cursor: pointer; }
.task:hover { border-color: var(--muted); }
.task.done .title { text-decoration: line-through; color: var(--muted); }
.task input[type=checkbox] { margin-top: 3px; width: 17px; height: 17px; cursor: pointer; }
.task .title { flex: 1; }
.task .meta { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 3px; font-size: 12px; color: var(--muted); }
.prio { width: 8px; height: 8px; border-radius: 50%; display: inline-block; margin-top: 7px; flex-shrink: 0; }
.p0 { background: var(--bad); } .p1 { background: var(--warn); } .p2 { background: var(--accent); }
.p3 { background: var(--muted); } .p4 { background: var(--line); }
.claim { color: var(--ok); }

/* drawer */
.drawer-bg { position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 20; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(560px, 100vw); background: var(--panel);
          z-index: 21; overflow-y: auto; padding: 18px 20px; border-left: 1px solid var(--line); }
.note { border-left: 3px solid var(--line); padding: 4px 10px; margin: 8px 0; white-space: pre-wrap; }
.note.handoff { border-color: var(--warn); }
.note.decision { border-color: var(--vault); }
.note .by { font-size: 12px; color: var(--muted); }
.secret { background: var(--chip); padding: 10px; border-radius: 6px; word-break: break-all; user-select: all; }
.login { max-width: 360px; margin: 14vh auto; }
.empty { color: var(--muted); padding: 24px; text-align: center; border: 1px dashed var(--line); border-radius: var(--radius); }
.body-text { white-space: pre-wrap; }

/* questions */
.badge { background: var(--warn); color: #fff; border-radius: 99px; padding: 0 7px; opacity: 1; }
.question.open { border-left: 3px solid var(--warn); }
.q-text { font-size: 16px; margin: 6px 0; white-space: pre-wrap; }
.answer { margin-top: 8px; white-space: pre-wrap; }

a.navitem { text-decoration: none; color: inherit; }

/* task list: drag, inline priority, subtasks */
.drag-handle { cursor: grab; color: var(--muted); padding: 0 2px; touch-action: none; user-select: none; line-height: 1.6; }
.task.dragging { opacity: .4; }
.task.drop-before { box-shadow: inset 0 3px 0 var(--accent); }
.task.drop-after { box-shadow: inset 0 -3px 0 var(--accent); }
.task.drop-into { outline: 2px dashed var(--accent); outline-offset: -2px; }
.prio-btn { border: 0; background: none; padding: 4px; margin: -1px 0 0; cursor: pointer; line-height: 0; border-radius: 50%; }
.prio-btn:hover { background: var(--chip); }
.prio-btn .prio { margin-top: 0; }
.prio-pop { position: absolute; z-index: 30; display: flex; flex-direction: column; gap: 2px; background: var(--panel);
            border: 1px solid var(--line); border-radius: 8px; padding: 6px; box-shadow: 0 6px 20px rgba(0,0,0,.25); }
.prio-pop .btn { text-align: left; display: flex; align-items: center; gap: 6px; }
.row-action { opacity: 0; transition: opacity .1s; align-self: center; }
.task:hover .row-action, .row-action:focus { opacity: 1; }
@media (hover: none) { .row-action { opacity: .7; } }
.subadd { margin-bottom: 8px; }

/* agents at work */
.working-strip { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 13px; margin-bottom: 10px; }
.status-working { background: var(--ok); color: #fff; }
.status-active { background: var(--accent); color: var(--accent-ink); }
ul.plain { list-style: none; padding: 0; margin: 8px 0; }
ul.plain li { padding: 3px 0; }

/* rendered markdown */
.md h2, .md h3, .md h4 { margin: 1em 0 .4em; }
.md p { margin: .5em 0; }
.md pre { background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 10px; overflow-x: auto; }
.md code { font-family: ui-monospace, monospace; font-size: 13px; background: var(--chip); padding: 0 4px; border-radius: 4px; }
.md pre code { background: none; padding: 0; }
.md blockquote { border-left: 3px solid var(--line); margin: .5em 0; padding-left: 12px; color: var(--muted); }
.md ul, .md ol { padding-left: 1.4em; }

/* docs */
.docs { display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: 20px; }
.docs-nav { display: flex; flex-direction: column; gap: 2px; }
.docs-nav .navitem { text-decoration: none; color: inherit; }
.doc-body { margin-top: 10px; }
.pending-box { border-color: var(--warn); font-size: 13px; }
.count.pending { color: var(--warn); opacity: 1; }
@media (max-width: 760px) { .docs { grid-template-columns: minmax(0, 1fr); } .docs-nav { flex-direction: row; flex-wrap: wrap; } }

.md li:has(> input[type=checkbox]) { list-style: none; margin-left: -1.2em; }
a.btn { text-decoration: none; color: inherit; display: inline-block; }
.tabs { scrollbar-width: thin; }

/* agents page */
.key-reveal { border-color: var(--warn); }
.key-row { padding: 10px 0; border-top: 1px solid var(--line); }
code.key { background: var(--chip); padding: 3px 8px; border-radius: 4px; font-size: 13px; }
.inline-form { background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 10px; margin: 10px 0; }
h4.subhead { margin: 14px 0 4px; font-size: 13px; color: var(--muted); font-weight: 600; }
.access-table td { padding: 4px 6px; }
.access-table select { max-width: 160px; }
select.granted { border-color: var(--ok); }
.disabled-card { opacity: .6; }
.copy-fallback { width: 100%; font-size: 12px; }
.chip.for-you { background: var(--warn); color: #fff; }
img.qr { width: 220px; height: 220px; image-rendering: pixelated; border-radius: 6px; margin: 6px 0 10px; }

/* ux pass */
.title-input { flex: 1; font-size: 18px; font-weight: 600; border-color: transparent; background: transparent; padding: 4px 6px; }
.title-input:hover, .title-input:focus { border-color: var(--line); background: var(--bg); }
.saved-flag { min-width: 5em; text-align: right; }
details.more { margin-top: 12px; }
details.more > summary { cursor: pointer; color: var(--muted); font-size: 13px; }
.btn.armed { background: var(--bad); color: #fff; border-color: var(--bad); }
a.chip.privacy { text-decoration: none; color: inherit; }
.danger-zone { border-color: color-mix(in srgb, var(--bad) 40%, var(--line)); }
pre.secret { white-space: pre-wrap; overflow-wrap: anywhere; }

/* discussions */
a.thread-row { text-decoration: none; color: inherit; align-items: center; }
.thread-row.unread .title > div:first-child { font-weight: 600; }
.messages { display: flex; flex-direction: column; gap: 10px; margin: 12px 0; }
.msg { border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; background: var(--panel); }
.msg.from-person { border-left: 3px solid var(--accent); }
.msg.from-agent { border-left: 3px solid var(--muted); }
.msg .by { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.msg .md p:first-child { margin-top: 0; }
.msg .md p:last-child { margin-bottom: 0; }

#update-banner { position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); z-index: 50; display: flex; gap: 8px;
  align-items: center; background: var(--panel); border: 1px solid var(--accent); border-radius: 8px; padding: 8px 12px;
  box-shadow: 0 6px 20px rgba(0,0,0,.3); font-size: 14px; max-width: calc(100vw - 32px); }

/* copyable code */
.code-block { position: relative; margin: .6em 0; }
.code-block pre { margin: 0; padding-right: 64px; }
.copy-btn { position: absolute; top: 6px; right: 6px; font-size: 12px; padding: 2px 8px; border-radius: 5px;
            border: 1px solid var(--line); background: var(--panel); color: var(--ink); cursor: pointer; opacity: .85; }
.copy-btn:hover { opacity: 1; border-color: var(--muted); }
.md code.copyable { cursor: copy; }
.md code.copyable:hover { outline: 1px solid var(--line); }
.copy-note { font-size: 11px; color: var(--ok); margin-left: 4px; }

.task-body { border: 1px solid var(--line); border-radius: 6px; padding: 4px 12px; margin-top: 4px; min-height: 2em; }
.note .md p { margin: .2em 0; }
.note { white-space: normal; }
.q-context { color: var(--muted); }
.q-context .md p { margin: .3em 0; }
