:root {
  --bg: #f6f7f9; --card: #ffffff; --text: #1d232b; --muted: #66707c; --line: #dde1e6;
  --accent: #1f6feb; --ok: #1a7f37; --warn: #9a6700; --bad: #cf222e;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0f1216; --card: #171b21; --text: #e3e7ec; --muted: #8b949e; --line: #2b313a;
          --accent: #58a6ff; --ok: #3fb950; --warn: #d29922; --bad: #f85149; }
}
* { box-sizing: border-box; }
body { margin: 0; font: 15px/1.5 system-ui, "Segoe UI", sans-serif; background: var(--bg); color: var(--text); }
a { color: var(--accent); }
header.top { display: flex; align-items: center; justify-content: space-between; gap: 16px;
             padding: 10px 20px; background: var(--card); border-bottom: 1px solid var(--line); }
.brand { font-weight: 700; text-decoration: none; color: var(--text); }
nav { display: flex; align-items: center; gap: 16px; }
.who { color: var(--muted); }
main { padding: 20px; max-width: 1400px; margin: 0 auto; }
h1 { margin: 0 0 12px; font-size: 1.5rem; } h2 { font-size: 1.05rem; margin: 18px 0 8px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 16px 20px; margin: 16px 0; }
.narrow { max-width: 440px; margin: 40px auto; }
label { display: flex; flex-direction: column; gap: 4px; margin: 10px 0; font-weight: 500; }
input, select, textarea { font: inherit; padding: 7px 9px; border: 1px solid var(--line); border-radius: 6px;
                background: var(--bg); color: var(--text); }
button { font: inherit; padding: 7px 14px; border: 0; border-radius: 6px; background: var(--accent); color: #fff; cursor: pointer; }
button.small { padding: 3px 9px; font-size: .9em; }
button.link { background: none; color: var(--accent); padding: 0 2px; }
form.inline { display: inline-flex; align-items: center; gap: 6px; margin: 2px 0; }
form.row { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; }
form.row label { margin: 0; }
.chip { background: var(--bg); border: 1px solid var(--line); border-radius: 12px; padding: 0 8px; margin-right: 4px; }
.muted { color: var(--muted); }
.notice { background: var(--card); border-left: 4px solid var(--accent); padding: 8px 12px; }
.error { color: var(--bad); } .ok { color: var(--ok); } .warn { color: var(--warn); }
p.error { background: var(--card); border-left: 4px solid var(--bad); padding: 8px 12px; }
ul.papers { list-style: none; padding: 0; } ul.papers li { padding: 8px 0; border-bottom: 1px solid var(--line); }
table.users { width: 100%; border-collapse: collapse; background: var(--card); }
table.users th, table.users td { text-align: left; vertical-align: top; padding: 8px; border-bottom: 1px solid var(--line); }
tr.disabled { opacity: .55; }
.workspace { display: grid; grid-template-columns: 250px minmax(0, 1fr) minmax(0, 1fr); gap: 16px;
             height: calc(100vh - 100px); }
.workspace > * { min-height: 0; }
.side { overflow: auto; }
.editor { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.editor-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.editor form.save { display: flex; flex-direction: column; flex: 1; gap: 8px; min-height: 0; }
textarea.code { flex: 1; width: 100%; min-height: 300px; resize: none; padding: 10px; tab-size: 2;
                font: 13px/1.45 ui-monospace, "Cascadia Mono", Consolas, monospace; border: 1px solid var(--line);
                border-radius: 8px; background: var(--card); color: var(--text); }
textarea.draft { flex: 0 0 160px; min-height: 160px; border-color: var(--warn); }
.save-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.save-bar input { flex: 1; min-width: 200px; }
button.secondary { background: transparent; color: var(--accent); border: 1px solid var(--accent); }
.pdf { background: var(--card); border: 1px solid var(--line); border-radius: 8px; display: flex; min-width: 0; }
.pdf iframe { flex: 1; border: 0; border-radius: 8px; }
.pdf p { margin: auto; }
ul.files li.current a { font-weight: 700; color: var(--text); }
ul.files li { padding: 2px 0; word-break: break-all; }
ul.files, ul.commits { list-style: none; padding: 0; font-size: .92em; }
ul.commits li { padding: 4px 0; border-bottom: 1px solid var(--line); }
pre.log { white-space: pre-wrap; font-size: .82em; max-height: 280px; overflow: auto; background: var(--bg);
          border: 1px solid var(--line); border-radius: 6px; padding: 8px; }
@media (max-width: 1100px) { .workspace { grid-template-columns: 1fr; height: auto; }
  .pdf iframe { min-height: 80vh; } }

.links a.current, .task-list a.current { font-weight: 700; color: var(--text); }
.task-list { display: flex; flex-direction: column; gap: 2px; margin: 8px 0 12px; }
.task-list a { padding: 3px 6px; border-radius: 4px; text-decoration: none; }
.task-list a.current { background: var(--card); border: 1px solid var(--line); }
.task-form label { margin: 8px 0; }
.task-form textarea, .task-form input:not([type=checkbox]):not([type=radio]), .task-form select { width: 100%; }
.task-form .row { display: flex; gap: 8px; } .task-form .row label { flex: 1; }
.inline-choice { flex-direction: row; align-items: center; gap: 6px; font-weight: 400; }
fieldset.modes { border: 0; padding: 0; margin: 0 0 6px; display: flex; flex-wrap: wrap; gap: 12px; }
.small { font-size: .85em; }
.log-pane { display: flex; flex-direction: column; gap: 8px; min-width: 0; min-height: 0; }
.log-head { display: flex; align-items: center; gap: 12px; }
.log { flex: 1; overflow: auto; background: var(--card); border: 1px solid var(--line); border-radius: 8px;
       padding: 8px; font: 12.5px/1.45 ui-monospace, Consolas, monospace; min-height: 200px; }
.log .entry { white-space: pre-wrap; word-break: break-word; }
.log .time { color: var(--muted); }
.log .thought .text { color: var(--muted); font-style: italic; }
.log .warning .text, .log .approval_request .text { color: var(--warn); }
.log .error .text { color: var(--bad); } .log .success .text, .log .decision .text { color: var(--ok); }
.log .tool_call .text { color: var(--accent); }
#approvals { overflow: auto; max-height: 55%; }
.approval h3 { margin: 0 0 4px; font-size: 1rem; }
pre.diff { font: 12px/1.4 ui-monospace, Consolas, monospace; background: var(--bg); border: 1px solid var(--line);
           border-radius: 6px; padding: 8px; overflow: auto; max-height: 360px; white-space: pre; }
pre.diff .add { color: var(--ok); } pre.diff .del { color: var(--bad); } pre.diff .hunk { color: var(--accent); }
pre.diff .file { color: var(--muted); }
.card.done { border-left: 4px solid var(--ok); } .card.failed { border-left: 4px solid var(--bad); }
.pdf { flex-direction: column; }
.pdf-head { padding: 6px 10px; border-bottom: 1px solid var(--line); }
.report table { border-collapse: collapse; } .report th, .report td { border: 1px solid var(--line); padding: 4px 8px; }
.report blockquote { border-left: 3px solid var(--line); margin: 0; padding-left: 12px; color: var(--muted); }
ul.todos { list-style: none; padding: 0; }
ul.todos li { display: flex; align-items: center; gap: 10px; padding: 6px 0; border-bottom: 1px solid var(--line); }
ul.todos li.done .text { text-decoration: line-through; color: var(--muted); }
ul.todos li.overdue .text { color: var(--bad); }
.workspace.tasks { grid-template-columns: 330px minmax(0, 1.1fr) minmax(0, 1fr); }
.side h1 a { color: var(--text); text-decoration: none; }

a.button { display: inline-block; padding: 7px 14px; border-radius: 6px; background: var(--accent); color: #fff;
           text-decoration: none; }
.status { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: .85em; border: 1px solid var(--line); }
.status.received { border-color: var(--accent); color: var(--accent); }
.status.in-progress, .status.in-review { border-color: var(--warn); color: var(--warn); }
.status.delivered { border-color: var(--ok); color: var(--ok); }
.status.declined { border-color: var(--bad); color: var(--bad); }
.two-col { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; }
@media (max-width: 900px) { .two-col { grid-template-columns: 1fr; } }
ul.messages { list-style: none; padding: 0; max-height: 420px; overflow: auto; }
ul.messages li { padding: 8px 10px; margin: 6px 0; border-radius: 8px; background: var(--bg); white-space: pre-wrap; }
ul.messages li.mine { border-left: 3px solid var(--accent); }
ul.messages li.theirs { border-left: 3px solid var(--ok); }
.card textarea { width: 100%; }
.order-form { max-width: 760px; }
.order-form input:not([type=checkbox]), .order-form select, .order-form textarea { width: 100%; }
fieldset.declarations { border: 1px solid var(--line); border-radius: 8px; margin: 14px 0; padding: 8px 14px; }
fieldset.declarations label { align-items: flex-start; }
.pre { white-space: pre-wrap; }
.steps ol li { margin: 8px 0; }
footer.legal { text-align: center; padding: 16px; display: flex; gap: 16px; justify-content: center; }
footer.legal a { color: var(--muted); }
