:root {
    color-scheme: dark;
    --bg: #0d1117;
    --panel: #161b22;
    --panel-2: #1f2630;
    --line: #30363d;
    --text: #e6edf3;
    --muted: #8b949e;
    --accent: #58a6ff;
    --accent-2: #1f6feb;
    --danger: #f85149;
    --success: #3fb950;
    --warning: #d29922;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: var(--bg); color: var(--text); }
button, input, textarea, select { font: inherit; }
button, .button {
    border: 1px solid var(--line); background: var(--panel-2); color: var(--text); border-radius: 8px;
    padding: 9px 13px; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; justify-content: center;
}
button:hover, .button:hover { border-color: #6e7681; }
button:disabled { opacity: .55; cursor: wait; }
button.primary { background: var(--accent-2); border-color: var(--accent-2); }
button.danger { background: #8e1519; border-color: #b62324; }
button.danger-outline { color: #ff7b72; }
input, textarea, select {
    width: 100%; color: var(--text); background: #0d1117; border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px;
}
textarea { resize: vertical; min-height: 90px; }
label { display: block; margin-bottom: 7px; font-weight: 600; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.tiny { font-size: 12px; }
.brand { font-size: 18px; font-weight: 750; letter-spacing: .2px; }
.center-card { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.card, .panel { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; }
.login-card { width: min(420px, 100%); padding: 28px; }
.login-card input { margin-bottom: 14px; }
.login-card button { width: 100%; }
.error-text { color: #ff7b72; min-height: 20px; margin-top: 12px; }
.app { min-height: 100vh; }
.topbar { min-height: 68px; padding: 12px 20px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 18px; position: sticky; top: 0; background: rgba(13,17,23,.95); backdrop-filter: blur(10px); z-index: 10; }
.top-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.top-actions select { width: auto; min-width: 190px; }
.workspace { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(340px, .8fr); gap: 16px; padding: 16px; align-items: start; }
.panel { overflow: hidden; }
.panel-header { padding: 16px 18px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.panel-header.compact { padding: 12px 14px; }
h1, h2 { margin: 0; }
h1 { font-size: 19px; }
h2 { font-size: 15px; }
.badge { border: 1px solid var(--line); background: var(--panel-2); border-radius: 999px; padding: 4px 9px; font-size: 12px; white-space: nowrap; }
.messages { height: calc(100vh - 300px); min-height: 380px; overflow-y: auto; padding: 18px; display: flex; flex-direction: column; gap: 12px; }
.message { max-width: 88%; padding: 11px 13px; border-radius: 12px; white-space: pre-wrap; line-height: 1.45; }
.message.user { margin-left: auto; background: #1f6feb; }
.message.assistant { background: var(--panel-2); border: 1px solid var(--line); }
.message.error { background: #3d1515; border: 1px solid #6e2222; }
.tool-events { padding: 0 18px; color: var(--muted); font-size: 12px; max-height: 90px; overflow-y: auto; }
.tool-event { padding: 3px 0; }
.tool-event.ok::before { content: "✓ "; color: var(--success); }
.tool-event.fail::before { content: "! "; color: var(--danger); }
.composer { padding: 14px 18px 18px; border-top: 1px solid var(--line); }
.composer-actions { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 9px; }
.side-column { display: grid; gap: 16px; }
.code-block { margin: 0; padding: 14px; background: #0d1117; color: #c9d1d9; overflow: auto; white-space: pre-wrap; }
.code-block.small { min-height: 52px; max-height: 190px; font-size: 12px; }
.proposal-list, .file-list { max-height: 360px; overflow-y: auto; }
.proposal { padding: 12px 14px; border-bottom: 1px solid var(--line); }
.proposal:last-child { border-bottom: 0; }
.proposal-title { font-weight: 650; word-break: break-word; }
.proposal-meta { font-size: 12px; color: var(--muted); margin: 5px 0 9px; }
.proposal-actions { display: flex; gap: 7px; flex-wrap: wrap; }
.proposal-actions button { padding: 6px 9px; font-size: 12px; }
.status-pending { color: var(--warning); }
.status-applied { color: var(--success); }
.status-rejected { color: var(--muted); }
.file-controls { display: grid; grid-template-columns: 1fr auto; gap: 8px; padding: 12px; }
.file-item { padding: 8px 12px; border-top: 1px solid var(--line); font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 12px; cursor: pointer; overflow-wrap: anywhere; }
.file-item:hover { background: var(--panel-2); }
dialog { width: min(1100px, 94vw); max-height: 88vh; background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 12px; padding: 0; }
dialog::backdrop { background: rgba(0,0,0,.72); }
.dialog-header { padding: 14px 16px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; }
.diff { margin: 0; padding: 16px; background: #0d1117; overflow: auto; min-height: 300px; max-height: 62vh; white-space: pre; font-size: 12px; }
.dialog-actions { padding: 12px 16px; display: flex; justify-content: flex-end; gap: 8px; }
#deploymentPanel p { padding: 0 14px; }
#deploymentPanel > button { margin: 0 14px 14px; }
@media (max-width: 980px) {
    .workspace { grid-template-columns: 1fr; }
    .messages { height: 55vh; }
}
@media (max-width: 650px) {
    .topbar { align-items: flex-start; flex-direction: column; }
    .top-actions { width: 100%; }
    .top-actions select { flex: 1; min-width: 140px; }
    .workspace { padding: 9px; }
    .message { max-width: 96%; }
}
