:root {
  --coder-bg: #090a0c;
  --coder-panel: #111317;
  --coder-panel-2: #16191e;
  --coder-line: rgba(255,255,255,.085);
  --coder-text: #f5f2eb;
  --coder-muted: #96989f;
  --coder-orange: #ff9e2c;
  --coder-orange-strong: #ff7a18;
  --coder-green: #45d69b;
  --coder-red: #ff6171;
  --coder-blue: #6aa9ff;
  --mono: "JetBrains Mono", "Cascadia Code", Consolas, monospace;
  --sans: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--coder-bg); color: var(--coder-text); font-family: var(--sans); }
body { overflow: hidden; }
[hidden] { display: none !important; }
button, textarea, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.coder-shell { height: 100vh; display: grid; grid-template-rows: 60px 1fr; background: radial-gradient(circle at 45% -20%, rgba(255,142,35,.075), transparent 34%), var(--coder-bg); }
.topbar { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 20px; padding: 0 18px; border-bottom: 1px solid var(--coder-line); background: rgba(9,10,12,.92); backdrop-filter: blur(18px); }
.brand { color: var(--coder-text); text-decoration: none; display: inline-flex; align-items: center; gap: 10px; width: max-content; letter-spacing: -.02em; }
.brand-mark { display: grid; place-items: center; width: 30px; height: 30px; color: #0d0e10; font-weight: 900; background: linear-gradient(135deg, #ffd29a, var(--coder-orange)); border-radius: 9px; box-shadow: 0 0 28px rgba(255,158,44,.22); }
.brand em { color: var(--coder-orange); font-style: normal; font-size: .72rem; letter-spacing: .08em; text-transform: uppercase; margin-left: 5px; }
.topbar-status { display: flex; align-items: center; gap: 8px; color: var(--coder-muted); font-size: .78rem; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: #777; box-shadow: 0 0 0 4px rgba(255,255,255,.035); }
.status-dot.ready { background: var(--coder-green); box-shadow: 0 0 12px rgba(69,214,155,.55); }
.status-dot.locked { background: var(--coder-orange); box-shadow: 0 0 12px rgba(255,158,44,.4); }
.status-dot.error { background: var(--coder-red); }
.topbar-actions { justify-self: end; display: flex; gap: 8px; }
.button, .icon-button, .text-button, .send-button { border: 0; cursor: pointer; color: var(--coder-text); transition: border-color .18s, background .18s, transform .18s, opacity .18s; }
.button { min-height: 38px; padding: 0 14px; border: 1px solid var(--coder-line); background: rgba(255,255,255,.035); border-radius: 10px; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; font-weight: 600; font-size: .8rem; }
.button:hover:not(:disabled) { border-color: rgba(255,158,44,.4); background: rgba(255,158,44,.08); }
.button:active:not(:disabled) { transform: translateY(1px); }
.button.primary { color: #12100d; background: linear-gradient(135deg, #ffc067, var(--coder-orange-strong)); border-color: transparent; box-shadow: 0 8px 30px rgba(255,126,24,.14); }
.button.primary:hover:not(:disabled) { background: linear-gradient(135deg, #ffd09a, var(--coder-orange)); }
.button.ghost { background: transparent; }
.button.danger { border-color: rgba(255,97,113,.25); color: #ff9ba5; background: rgba(255,97,113,.07); }
.button.compact { min-height: 30px; padding: 0 10px; border-radius: 8px; font-size: .72rem; }
.button:disabled, .icon-button:disabled, .send-button:disabled { cursor: not-allowed; opacity: .35; }
.workspace-grid { min-height: 0; display: grid; grid-template-columns: minmax(220px, 17vw) minmax(350px, 33vw) minmax(480px, 1fr); gap: 1px; background: var(--coder-line); }
.panel { min-width: 0; min-height: 0; background: var(--coder-panel); }
.files-panel, .agent-panel { display: flex; flex-direction: column; }
.panel-heading { min-height: 76px; padding: 16px 18px; display: flex; align-items: center; justify-content: space-between; gap: 12px; border-bottom: 1px solid var(--coder-line); }
.panel-heading h1, .panel-heading h2, .review-header h2 { margin: 4px 0 0; font-size: .96rem; line-height: 1.25; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.eyebrow { color: var(--coder-orange); font: 600 .62rem/1 var(--mono); letter-spacing: .13em; text-transform: uppercase; }
.icon-button { width: 30px; height: 30px; border-radius: 8px; background: rgba(255,255,255,.045); font-size: 1rem; }
.icon-button:hover:not(:disabled) { background: rgba(255,158,44,.12); color: var(--coder-orange); }
.connect-button { margin: 14px 14px 8px; }
.local-note { margin: 0 18px 12px; color: var(--coder-muted); font-size: .69rem; line-height: 1.5; }
.local-note span { color: var(--coder-green); font-size: .52rem; margin-right: 4px; }
.file-toolbar { display: flex; gap: 7px; padding: 0 14px 12px; border-bottom: 1px solid var(--coder-line); }
.file-tree { flex: 1; min-height: 0; overflow: auto; padding: 10px 8px 18px; font: .76rem/1.4 var(--mono); scrollbar-color: #373a40 transparent; }
.empty-files, .empty-result { color: var(--coder-muted); font-size: .78rem; line-height: 1.6; padding: 24px 16px; text-align: center; }
.tree-directory > summary, .tree-file { min-height: 31px; width: 100%; display: flex; align-items: center; gap: 6px; padding: 4px 8px; border: 0; border-radius: 7px; color: #c9cbd0; background: transparent; text-align: left; cursor: pointer; list-style: none; }
.tree-directory > summary::before { content: '›'; color: #71747b; width: 11px; transition: transform .15s; }
.tree-directory[open] > summary::before { transform: rotate(90deg); }
.tree-directory > summary::after { content: '/'; color: #5f6268; }
.tree-directory > summary:hover, .tree-file:hover:not(:disabled) { background: rgba(255,255,255,.045); color: #fff; }
.tree-children { padding-left: 12px; }
.tree-file::before { content: '·'; color: #696c73; width: 11px; }
.tree-file.selected { background: rgba(255,158,44,.11); color: #ffd099; }
.tree-file.sensitive { opacity: .38; cursor: not-allowed; }
.workspace-foot { padding: 12px 14px; border-top: 1px solid var(--coder-line); display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.permission-badge { color: var(--coder-muted); font-size: .66rem; }
.permission-badge.granted { color: var(--coder-green); }
.text-button { color: var(--coder-muted); background: transparent; font-size: .68rem; }
.text-button:hover:not(:disabled) { color: var(--coder-orange); }
.agent-heading { flex: 0 0 auto; }
.conversation { flex: 1; min-height: 0; overflow-y: auto; padding: 22px 20px; scrollbar-color: #373a40 transparent; }
.welcome-card { min-height: 100%; display: grid; place-content: center; text-align: center; max-width: 520px; margin: auto; padding: 40px 16px; }
.welcome-icon { display: grid; place-items: center; width: 52px; height: 52px; margin: 0 auto 18px; border: 1px solid rgba(255,158,44,.3); border-radius: 16px; color: var(--coder-orange); font-size: 1.8rem; background: radial-gradient(circle, rgba(255,158,44,.12), transparent 70%); }
.welcome-card h2 { margin: 0; font-size: clamp(1.25rem, 2vw, 1.8rem); letter-spacing: -.045em; }
.welcome-card p { max-width: 470px; margin: 13px auto 18px; color: var(--coder-muted); font-size: .83rem; line-height: 1.65; }
.trust-row { display: flex; flex-wrap: wrap; justify-content: center; gap: 7px; }
.trust-row span { padding: 6px 9px; border: 1px solid var(--coder-line); border-radius: 99px; color: #b9bbc1; font-size: .62rem; }
.message { margin: 0 0 18px; border: 1px solid var(--coder-line); border-radius: 13px; overflow: hidden; }
.message.user { margin-left: 16%; background: rgba(255,158,44,.075); border-color: rgba(255,158,44,.16); }
.message.assistant { margin-right: 6%; background: rgba(255,255,255,.025); }
.message-head { padding: 9px 12px; border-bottom: 1px solid var(--coder-line); color: var(--coder-orange); font: 600 .65rem/1 var(--mono); text-transform: uppercase; letter-spacing: .08em; }
.message-body { padding: 13px; color: #d8d9dd; white-space: pre-wrap; font-size: .8rem; line-height: 1.65; }
.message-body p { margin: 0 0 .7em; }
.message-body p:last-child { margin-bottom: 0; }
.message-body h1, .message-body h2, .message-body h3 { margin: 1em 0 .45em; color: #f4f1eb; letter-spacing: -.02em; }
.message-body h2 { font-size: 1rem; }
.message-body h3 { font-size: .9rem; }
.message-body ul, .message-body ol { margin: .45em 0 .8em; padding-left: 1.35rem; }
.message-body pre { overflow: auto; margin: .75em 0; padding: 12px; border: 1px solid var(--coder-line); border-radius: 9px; background: #080a0d; }
.message-body code { font-family: var(--mono); color: #ffd09a; }
.message-body a { color: var(--coder-orange); }
.composer { flex: 0 0 auto; margin: 0 16px 16px; border: 1px solid rgba(255,255,255,.13); background: #0d0f12; border-radius: 15px; overflow: hidden; box-shadow: 0 12px 40px rgba(0,0,0,.23); }
.composer:focus-within { border-color: rgba(255,158,44,.45); box-shadow: 0 0 0 3px rgba(255,158,44,.06), 0 12px 40px rgba(0,0,0,.23); }
.composer textarea { width: 100%; min-height: 92px; resize: none; border: 0; outline: 0; padding: 15px; color: var(--coder-text); background: transparent; font-size: .85rem; line-height: 1.55; }
.composer textarea::placeholder { color: #686a70; }
.composer-meta { min-height: 42px; padding: 7px 8px 7px 14px; display: flex; align-items: center; justify-content: space-between; gap: 10px; border-top: 1px solid var(--coder-line); color: var(--coder-muted); font-size: .65rem; }
.send-button { width: 32px; height: 32px; border-radius: 9px; color: #111; background: var(--coder-orange); font-weight: 900; font-size: 1rem; }
.result-panel { position: relative; display: grid; grid-template-rows: 48px 1fr; background: #0d0f12; }
.tabs { display: flex; gap: 2px; padding: 7px 8px 0; border-bottom: 1px solid var(--coder-line); overflow-x: auto; }
.tab { position: relative; min-width: max-content; padding: 0 11px 10px; border: 0; color: #777a81; background: transparent; cursor: pointer; font-size: .72rem; font-weight: 600; }
.tab::after { content: ''; position: absolute; left: 10px; right: 10px; bottom: -1px; height: 2px; background: transparent; border-radius: 2px; }
.tab.active { color: #f4f1ea; }
.tab.active::after { background: var(--coder-orange); box-shadow: 0 0 10px rgba(255,158,44,.4); }
.tab-count { min-width: 18px; height: 17px; display: inline-grid; place-items: center; padding: 0 4px; margin-left: 3px; border-radius: 99px; background: rgba(255,255,255,.06); color: #adafb5; font: .6rem var(--mono); }
.tab-view { min-height: 0; overflow: auto; }
#tab-diff { display: grid; grid-template-rows: auto auto minmax(160px, 38%) 1fr; }
.review-header { padding: 15px 17px; display: flex; align-items: center; justify-content: space-between; gap: 12px; border-bottom: 1px solid var(--coder-line); }
.editor-bar { min-height: 38px; padding: 5px 9px 5px 15px; display: flex; align-items: center; justify-content: space-between; gap: 12px; background: #121419; color: #b5b7bd; font: .67rem var(--mono); border-bottom: 1px solid var(--coder-line); }
.code-editor { width: 100%; min-height: 0; resize: none; border: 0; outline: 0; padding: 14px 16px; color: #d9dadd; background: #090b0e; font: 12px/1.65 var(--mono); tab-size: 2; border-bottom: 1px solid var(--coder-line); }
.change-list { min-height: 0; overflow: auto; padding: 12px; }
.change-card { margin-bottom: 10px; border: 1px solid var(--coder-line); background: #121419; border-radius: 11px; overflow: hidden; }
.change-card.risk-high { border-color: rgba(255,97,113,.32); }
.change-card header { min-height: 44px; padding: 8px 9px 8px 12px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.change-card header > div { min-width: 0; display: flex; align-items: center; gap: 9px; }
.change-card strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font: 600 .7rem var(--mono); }
.change-verb { padding: 4px 6px; border-radius: 5px; color: #ffbd72; background: rgba(255,158,44,.1); font: 600 .58rem var(--mono); text-transform: uppercase; }
.change-reason { margin: 0; padding: 0 12px 10px; color: var(--coder-muted); font-size: .7rem; }
.diff-view { max-height: 300px; overflow: auto; border-top: 1px solid var(--coder-line); background: #080a0d; font: 11px/1.5 var(--mono); }
.diff-line { min-height: 18px; padding: 1px 9px; white-space: pre-wrap; overflow-wrap: anywhere; }
.diff-line.context { color: #85888f; }
.diff-line.added { color: #bdf4d9; background: rgba(45,180,117,.12); }
.diff-line.removed { color: #ffc2c8; background: rgba(220,69,86,.12); }
.diff-error { padding: 12px; color: #ff9aa5; }
.preview-toolbar { min-height: 45px; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 7px 12px; border-bottom: 1px solid var(--coder-line); color: var(--coder-muted); font-size: .68rem; }
.preview-frame { width: 100%; height: calc(100% - 45px); min-height: 500px; border: 0; background: white; }
.event-log { height: 100%; overflow: auto; padding: 10px 14px; font: 11px/1.55 var(--mono); }
.log-row { display: grid; grid-template-columns: 70px 1fr; gap: 12px; padding: 8px 4px; border-bottom: 1px solid rgba(255,255,255,.045); }
.log-row time { color: #62656d; }
.log-row span { color: #c4c6cb; }
.gate-card { max-width: 560px; margin: 10vh auto; padding: 28px; border: 1px solid rgba(255,158,44,.2); border-radius: 16px; background: radial-gradient(circle at top right, rgba(255,158,44,.09), transparent 45%), #121419; }
.gate-badge { color: var(--coder-orange); font: 600 .62rem var(--mono); letter-spacing: .1em; }
.gate-card h2 { margin: 12px 0 10px; font-size: 1.25rem; }
.gate-card p { color: var(--coder-muted); font-size: .8rem; line-height: 1.65; }
.problem-list { padding: 13px; }
.problem-item { display: grid; grid-template-columns: 26px 1fr; gap: 9px; align-items: start; margin-bottom: 9px; padding: 12px; border: 1px solid rgba(255,97,113,.18); border-radius: 9px; background: rgba(255,97,113,.055); }
.problem-item span { width: 22px; height: 22px; display: grid; place-items: center; color: #120b0c; background: var(--coder-red); border-radius: 50%; font-weight: 800; }
.problem-item p { margin: 2px 0 0; color: #f0c6cb; font-size: .76rem; line-height: 1.5; }
dialog { color: var(--coder-text); }
dialog::backdrop { background: rgba(0,0,0,.74); backdrop-filter: blur(5px); }
.consent-dialog, .info-dialog { width: min(680px, calc(100vw - 28px)); max-height: calc(100vh - 32px); overflow: auto; padding: 0; border: 1px solid rgba(255,255,255,.13); border-radius: 18px; background: #121419; box-shadow: 0 35px 100px rgba(0,0,0,.55); }
.consent-dialog form, .info-dialog { padding: 24px; }
.dialog-head h2 { margin: 7px 0 8px; font-size: 1.35rem; }
.dialog-head p, .dialog-footnote { margin: 0; color: var(--coder-muted); font-size: .75rem; line-height: 1.55; }
.privacy-promise { margin: 20px 0 15px; padding: 14px; border-left: 3px solid var(--coder-orange); background: rgba(255,158,44,.06); color: #ded9d0; font-size: .76rem; line-height: 1.6; }
.consent-line { display: grid; grid-template-columns: 20px 1fr; gap: 10px; align-items: start; padding: 11px 0; border-bottom: 1px solid var(--coder-line); color: #d6d7da; font-size: .78rem; line-height: 1.5; }
.consent-line input { width: 17px; height: 17px; margin: 1px 0 0; accent-color: var(--coder-orange); }
.consent-line a { color: var(--coder-orange); }
.dialog-footnote { margin-top: 14px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }
.status-list { margin: 22px 0; border: 1px solid var(--coder-line); border-radius: 12px; overflow: hidden; }
.status-list > div { display: grid; grid-template-columns: 140px 1fr; gap: 16px; padding: 11px 13px; border-bottom: 1px solid var(--coder-line); }
.status-list > div:last-child { border-bottom: 0; }
.status-list dt { color: var(--coder-muted); font-size: .72rem; }
.status-list dd { margin: 0; text-align: right; font-size: .74rem; }
.danger-zone { padding: 14px; border: 1px solid rgba(255,97,113,.18); border-radius: 12px; background: rgba(255,97,113,.04); }
.danger-zone p, .gate-warning { margin: 9px 0 0; color: var(--coder-muted); font-size: .7rem; line-height: 1.5; }
.requirements { padding-left: 20px; color: #d2d3d7; font-size: .78rem; line-height: 1.7; }
.gate-warning { padding: 12px; border-radius: 9px; color: #ffd09a; background: rgba(255,158,44,.07); }
.toast-region { position: fixed; z-index: 100; right: 16px; bottom: 16px; display: grid; gap: 8px; width: min(390px, calc(100vw - 32px)); pointer-events: none; }
.toast { padding: 12px 14px; border: 1px solid var(--coder-line); border-radius: 10px; color: #e7e7e9; background: #1a1d22; box-shadow: 0 14px 50px rgba(0,0,0,.38); font-size: .75rem; line-height: 1.45; animation: toast-in .2s ease-out; }
.toast.success { border-color: rgba(69,214,155,.28); }
.toast.error { border-color: rgba(255,97,113,.3); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

@media (max-width: 1180px) {
  .workspace-grid { grid-template-columns: 230px minmax(340px, .9fr) minmax(420px, 1.15fr); }
  .topbar-status { display: none; }
  .topbar { grid-template-columns: 1fr auto; }
}
@media (max-width: 900px) {
  body { overflow: auto; }
  .coder-shell { height: auto; min-height: 100vh; }
  .workspace-grid { display: grid; grid-template-columns: 230px minmax(0, 1fr); grid-template-rows: minmax(680px, calc(100vh - 60px)) minmax(700px, auto); }
  .files-panel { grid-column: 1; grid-row: 1; }
  .agent-panel { grid-column: 2; grid-row: 1; }
  .result-panel { grid-column: 1 / -1; grid-row: 2; min-height: 700px; border-top: 1px solid var(--coder-line); }
}
@media (max-width: 640px) {
  .coder-shell { display: block; }
  .topbar { min-height: 58px; padding: 0 12px; position: sticky; top: 0; z-index: 20; }
  .topbar-actions .button:first-child { display: none; }
  .workspace-grid { display: block; background: var(--coder-bg); }
  .files-panel, .agent-panel, .result-panel { min-height: auto; border-bottom: 1px solid var(--coder-line); }
  .files-panel { height: 360px; }
  .agent-panel { height: 650px; }
  .result-panel { height: 760px; }
  .message.user { margin-left: 5%; }
  .tabs { padding-left: 3px; }
  .review-header { align-items: flex-start; }
}
