:root {
  --bg: #0d0e10;
  --panel: #121315;
  --panel-2: #17181b;
  --panel-3: #1d1f22;
  --hover: #222428;
  --border: #292b30;
  --border-soft: #212327;
  --text: #f1f1ed;
  --text-2: #b9bab5;
  --muted: #7e807b;
  --accent: #f4f4ef;
  --accent-ink: #111214;
  --green: #78d5a1;
  --amber: #e8b86b;
  --red: #ef857d;
  --blue: #8eb8ff;
  --radius: 12px;
  --sidebar: 268px;
  --inspector: 340px;
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; margin: 0; overflow: hidden; background: var(--bg); color: var(--text); }
body { min-width: 320px; }
button, input, textarea, select { font: inherit; }
button { color: inherit; }
button, a, select { -webkit-tap-highlight-color: transparent; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.hidden { display: none !important; }
.muted { color: var(--muted); }

.app-shell { display: grid; grid-template-columns: var(--sidebar) minmax(0, 1fr) var(--inspector); height: 100dvh; background: var(--bg); opacity: 1; transition: opacity .2s ease; }
.app-shell.is-booting { opacity: 0; }
.app-shell.inspector-hidden { grid-template-columns: var(--sidebar) minmax(0, 1fr) 0; }
.app-shell.inspector-hidden .inspector { opacity: 0; pointer-events: none; transform: translateX(20px); }

.sidebar { position: relative; z-index: 20; display: flex; flex-direction: column; min-width: 0; border-right: 1px solid var(--border-soft); background: #101113; padding: 13px 11px 10px; }
.brand-row { height: 40px; display: flex; align-items: center; justify-content: space-between; padding: 0 7px 0 5px; }
.brand { display: flex; align-items: center; gap: 9px; color: var(--text); text-decoration: none; font-size: 16px; font-weight: 640; letter-spacing: -.02em; }
.brand-mark { width: 25px; height: 25px; display: grid; place-items: center; }
.brand-mark svg { width: 25px; height: 25px; stroke-width: 1.65; }
.brand-mark.large, .brand-mark.large svg { width: 31px; height: 31px; }
.brand-mark svg path:first-child, .welcome-mark svg path:first-child { opacity: .45; }

.icon-button { border: 0; background: transparent; width: 34px; height: 34px; border-radius: 8px; display: grid; place-items: center; padding: 0; color: var(--text-2); cursor: pointer; transition: background .14s, color .14s; }
.icon-button:hover { background: var(--hover); color: var(--text); }
.icon-button:disabled { opacity: .35; cursor: not-allowed; }
.sidebar-close, .mobile-menu, .inspector-close { display: none; }

.new-task-button { height: 39px; border: 1px solid var(--border); background: #181a1d; border-radius: 9px; display: flex; align-items: center; gap: 9px; padding: 0 10px; margin: 14px 2px 10px; color: var(--text); cursor: pointer; box-shadow: inset 0 1px 0 rgba(255,255,255,.025); transition: background .14s, border-color .14s; }
.new-task-button:hover { background: #202226; border-color: #3a3c41; }
.new-task-button svg { width: 17px; height: 17px; }
.new-task-button span { flex: 1; text-align: left; font-size: 13px; font-weight: 560; }
kbd { border: 0; background: transparent; color: #666963; font: 11px ui-monospace, SFMono-Regular, Menlo, monospace; }

.search-box { display: flex; align-items: center; height: 34px; border-radius: 8px; gap: 7px; padding: 0 9px; color: var(--muted); transition: background .15s; }
.search-box:focus-within { background: #181a1d; color: var(--text-2); }
.search-box svg { width: 16px; height: 16px; }
.search-box input { width: 100%; min-width: 0; outline: none; border: 0; background: transparent; color: var(--text); font-size: 12.5px; }
.search-box input::placeholder { color: #70726e; }
.sidebar-section-heading { display: flex; align-items: center; justify-content: space-between; padding: 17px 9px 7px; color: #8e908b; text-transform: uppercase; font-size: 10px; letter-spacing: .09em; font-weight: 650; }
.thread-list { min-height: 0; flex: 1; overflow: auto; scrollbar-width: thin; scrollbar-color: #34363a transparent; }
.thread-item { position: relative; width: 100%; min-height: 56px; padding: 9px 36px 8px 10px; margin-bottom: 2px; border: 0; border-radius: 8px; background: transparent; text-align: left; color: var(--text-2); cursor: pointer; display: flex; flex-direction: column; gap: 4px; }
.thread-item:hover { background: #18191c; }
.thread-item.active { background: #202225; color: var(--text); }
.thread-item strong { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12.5px; font-weight: 540; }
.thread-item small { display: flex; align-items: center; gap: 5px; color: #71736f; font-size: 10.5px; }
.thread-item .thread-state { position: absolute; right: 10px; top: 14px; width: 6px; height: 6px; border-radius: 50%; background: #555; }
.thread-item .thread-state.active { background: var(--green); box-shadow: 0 0 0 3px rgba(120,213,161,.1); }
.thread-empty { padding: 22px 12px; color: var(--muted); text-align: center; font-size: 12px; line-height: 1.6; }
.thread-skeleton { display: grid; gap: 7px; padding: 5px; }
.thread-skeleton i { height: 46px; border-radius: 8px; background: linear-gradient(100deg,#151619 20%,#1d1f22 45%,#151619 70%); background-size: 300% 100%; animation: shimmer 1.5s infinite; }
@keyframes shimmer { to { background-position: -150% 0; } }

.sidebar-footer { border-top: 1px solid var(--border-soft); padding-top: 9px; }
.quota-card { padding: 8px 9px 10px; }
.quota-top { display: flex; justify-content: space-between; color: #8b8d88; font-size: 10.5px; margin-bottom: 7px; }
.progress-track { height: 3px; border-radius: 2px; background: #292b2f; overflow: hidden; }
.progress-track span { display: block; width: 0; height: 100%; border-radius: inherit; background: #8c9089; transition: width .4s ease, background .2s; }
.account-button { width: 100%; display: flex; align-items: center; gap: 9px; padding: 7px 7px; border: 0; border-radius: 9px; background: transparent; text-align: left; cursor: pointer; }
.account-button:hover { background: var(--hover); }
.avatar { flex: 0 0 auto; width: 29px; height: 29px; border-radius: 8px; display: grid; place-items: center; color: #171819; background: linear-gradient(145deg,#f0e9dc,#aaa79f); font-size: 12px; font-weight: 750; }
.avatar.large { width: 42px; height: 42px; border-radius: 12px; font-size: 16px; }
.account-copy { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 2px; }
.account-copy strong { font-size: 12px; font-weight: 590; overflow: hidden; text-overflow: ellipsis; }
.account-copy small { color: var(--muted); font-size: 10px; text-transform: capitalize; }
.account-button > svg { width: 15px; height: 15px; color: #62645f; }

.workspace { min-width: 0; position: relative; display: grid; grid-template-rows: 58px minmax(0, 1fr) auto; background: var(--bg); }
.topbar { height: 58px; border-bottom: 1px solid var(--border-soft); display: flex; align-items: center; justify-content: space-between; padding: 0 15px 0 20px; background: rgba(13,14,16,.86); backdrop-filter: blur(14px); z-index: 5; }
.topbar-leading, .topbar-actions { display: flex; align-items: center; gap: 7px; min-width: 0; }
.title-block { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.title-block h1 { margin: 0; max-width: 540px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 13px; font-weight: 580; letter-spacing: -.01em; }
.workspace-path { display: flex; align-items: center; gap: 4px; color: #696b67; font: 9.5px ui-monospace, SFMono-Regular, Menlo, monospace; }
.workspace-path svg { width: 11px; height: 11px; }
.connection-pill { height: 25px; padding: 0 9px; display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--border); border-radius: 999px; color: #898b86; font-size: 10px; }
.connection-pill i { width: 5px; height: 5px; border-radius: 50%; background: var(--amber); }
.connection-pill.online i { background: var(--green); }
.connection-pill.offline i { background: var(--red); }

.conversation { min-height: 0; overflow-y: auto; scrollbar-width: thin; scrollbar-color: #33363a transparent; scroll-behavior: smooth; }
.welcome { min-height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 46px 30px 120px; }
.welcome-mark { width: 54px; height: 54px; display: grid; place-items: center; margin-bottom: 21px; color: #d7d8d2; }
.welcome-mark svg { width: 52px; height: 52px; stroke-width: 1.35; }
.welcome h2 { margin: 0; font-size: 23px; line-height: 1.2; font-weight: 590; letter-spacing: -.035em; }
.welcome > p { margin: 9px 0 29px; color: var(--muted); font-size: 12.5px; }
.suggestions { width: min(650px, 100%); display: grid; grid-template-columns: repeat(3,1fr); gap: 8px; }
.suggestions button { min-width: 0; height: 74px; padding: 12px; display: flex; align-items: flex-start; gap: 10px; border: 1px solid var(--border); border-radius: 10px; background: #131416; color: var(--text-2); text-align: left; cursor: pointer; transition: transform .15s, background .15s, border-color .15s; }
.suggestions button:hover { transform: translateY(-1px); background: #191a1d; border-color: #3a3c40; }
.suggestions svg { flex: 0 0 auto; width: 17px; height: 17px; margin-top: 1px; color: #8e908b; }
.suggestions span { min-width: 0; display: flex; flex-direction: column; gap: 5px; }
.suggestions strong { font-size: 11.5px; font-weight: 570; color: #d9dad5; }
.suggestions small { color: #6e706c; font-size: 10px; line-height: 1.35; }

.messages { display: none; width: min(820px, calc(100% - 44px)); margin: 0 auto; padding: 31px 0 120px; }
.conversation.has-messages .welcome { display: none; }
.conversation.has-messages .messages { display: block; }
.message { position: relative; display: grid; grid-template-columns: 27px minmax(0,1fr); gap: 12px; margin-bottom: 27px; }
.message-avatar { width: 27px; height: 27px; border: 1px solid #303238; border-radius: 8px; display: grid; place-items: center; color: #9b9d98; background: #17191c; font-size: 10px; font-weight: 700; }
.message.user .message-avatar { color: #171819; background: #d7d2c9; border-color: transparent; }
.message-body { min-width: 0; padding-top: 2px; }
.message-meta { display: flex; align-items: center; gap: 7px; margin-bottom: 7px; }
.message-meta strong { font-size: 11.5px; font-weight: 600; }
.message-meta time { color: #5f615d; font-size: 9.5px; }
.message-content { color: #d2d3ce; font-size: 13px; line-height: 1.68; overflow-wrap: anywhere; }
.message.user .message-content { color: #e3e3df; }
.message-content p { margin: 0 0 10px; }
.message-content p:last-child { margin-bottom: 0; }
.message-content pre { position: relative; overflow: auto; margin: 13px 0; padding: 13px 15px; border: 1px solid var(--border); border-radius: 9px; background: #0a0b0c; color: #c8cac4; font: 11.5px/1.55 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.message-content code:not(pre code) { padding: 1px 4px; border-radius: 4px; background: #24262a; color: #dddeda; font: .9em ui-monospace, SFMono-Regular, Menlo, monospace; }
.message.streaming .message-content::after { content: ""; display: inline-block; width: 6px; height: 13px; margin-left: 3px; vertical-align: -2px; background: #9b9d98; animation: blink 1s steps(2,end) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.message-error { border-left: 2px solid var(--red); padding-left: 10px; color: #dda29d; }
.tool-card { margin: 8px 0 22px 39px; border: 1px solid var(--border-soft); border-radius: 9px; background: #111214; overflow: hidden; }
.tool-card summary { list-style: none; min-height: 38px; padding: 8px 11px; display: flex; align-items: center; gap: 8px; color: #9ea09b; font-size: 11px; cursor: pointer; }
.tool-card summary::-webkit-details-marker { display: none; }
.tool-card summary svg { width: 15px; height: 15px; }
.tool-card summary strong { color: #c8c9c5; font-weight: 540; }
.tool-card .tool-output { max-height: 280px; overflow: auto; margin: 0; padding: 11px 13px; border-top: 1px solid var(--border-soft); background: #0a0b0d; color: #9ea19a; white-space: pre-wrap; font: 10.5px/1.55 ui-monospace, SFMono-Regular, Menlo, monospace; }

.composer-wrap { position: absolute; left: 0; right: 0; bottom: 0; z-index: 6; padding: 0 22px max(12px, env(safe-area-inset-bottom)); background: linear-gradient(0deg,var(--bg) 58%,rgba(13,14,16,0)); pointer-events: none; }
.composer { pointer-events: auto; width: min(820px,100%); margin: 0 auto; border: 1px solid #35373b; border-radius: 13px; background: #191b1e; box-shadow: 0 16px 45px rgba(0,0,0,.36), inset 0 1px 0 rgba(255,255,255,.025); transition: border-color .15s, box-shadow .15s; }
.composer:focus-within { border-color: #4a4c51; box-shadow: 0 16px 50px rgba(0,0,0,.43), inset 0 1px 0 rgba(255,255,255,.035); }
.composer textarea { display: block; resize: none; width: 100%; max-height: 210px; min-height: 48px; padding: 14px 15px 6px; border: 0; outline: 0; background: transparent; color: var(--text); font-size: 13px; line-height: 1.5; }
.composer textarea::placeholder { color: #72746f; }
.composer-toolbar { min-height: 39px; display: flex; align-items: center; justify-content: space-between; padding: 3px 7px 7px 9px; gap: 10px; }
.composer-options, .composer-actions { display: flex; align-items: center; gap: 5px; min-width: 0; }
.select-chip { position: relative; height: 26px; display: inline-flex; align-items: center; gap: 5px; padding: 0 7px; border-radius: 7px; color: #8d8f8a; background: transparent; }
.select-chip:hover { background: #24262a; }
.select-chip select { max-width: 135px; appearance: none; border: 0; outline: 0; background: transparent; color: #a9aba5; font-size: 10px; cursor: pointer; padding: 0; }
.select-chip svg { width: 12px; height: 12px; pointer-events: none; }
.dot-model { width: 6px; height: 6px; border: 1px solid #aeb0aa; border-radius: 50%; }
.queue-hint { max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--amber); font-size: 9.5px; }
.send-button, .stop-button { width: 30px; height: 30px; display: grid; place-items: center; padding: 0; border: 0; border-radius: 8px; color: var(--accent-ink); background: var(--accent); cursor: pointer; transition: transform .12s, opacity .12s; }
.send-button:hover, .stop-button:hover { transform: scale(1.04); }
.send-button:disabled { opacity: .28; cursor: not-allowed; transform: none; }
.send-button svg { width: 16px; height: 16px; stroke-width: 2; }
.stop-button { background: #2a2c30; border: 1px solid #3b3d42; }
.stop-button span { width: 8px; height: 8px; border-radius: 2px; background: #d3d4d0; }
.composer-note { pointer-events: auto; margin: 6px auto 0; text-align: center; color: #555752; font-size: 8.5px; }

.terminal-drawer { position: absolute; z-index: 8; left: 12px; right: 12px; bottom: 111px; height: min(330px, calc(100dvh - 190px)); display: none; grid-template-rows: 38px minmax(0,1fr) 38px; border: 1px solid #35373c; border-radius: 10px; background: #0a0b0c; box-shadow: 0 22px 70px rgba(0,0,0,.58); overflow: hidden; }
.terminal-drawer.open { display: grid; animation: terminal-in .17s ease-out; }
@keyframes terminal-in { from { opacity: 0; transform: translateY(8px); } }
.terminal-header { display: flex; align-items: center; justify-content: space-between; padding: 0 7px 0 12px; border-bottom: 1px solid #24262a; background: #151619; }
.terminal-header > div { display: flex; align-items: center; gap: 9px; }
.terminal-header strong { color: #92948f; font: 9.5px ui-monospace, SFMono-Regular, Menlo, monospace; font-weight: 500; }
.terminal-header .icon-button { width: 27px; height: 27px; }
.terminal-dots { display: flex; gap: 4px; }
.terminal-dots i { width: 6px; height: 6px; border-radius: 50%; background: #545651; }
.terminal-dots i:first-child { background: #bc6f69; }
.terminal-dots i:nth-child(2) { background: #ad8a58; }
.terminal-dots i:last-child { background: #5f9270; }
.terminal-output { min-height: 0; overflow: auto; margin: 0; padding: 12px 14px; background: #090a0b; color: #abb0a8; white-space: pre-wrap; word-break: break-word; font: 11px/1.55 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; scrollbar-width: thin; scrollbar-color: #34363a transparent; }
.terminal-form { display: grid; grid-template-columns: auto minmax(0,1fr) auto; align-items: center; gap: 7px; padding: 0 8px 0 13px; border-top: 1px solid #24262a; background: #111214; color: var(--green); font: 11px ui-monospace, SFMono-Regular, Menlo, monospace; }
.terminal-form input { min-width: 0; border: 0; outline: 0; background: transparent; color: #d3d5cf; font: inherit; }
.terminal-form button { border: 0; border-radius: 5px; padding: 4px 8px; background: #292b2f; color: #aaaCA6; font-size: 9px; cursor: pointer; }
.terminal-form.busy { opacity: .6; pointer-events: none; }

.inspector { min-width: 0; z-index: 10; border-left: 1px solid var(--border-soft); background: #101113; transition: opacity .2s, transform .2s; overflow: hidden; }
.inspector-header { height: 58px; display: flex; align-items: center; justify-content: space-between; padding: 0 10px 0 14px; border-bottom: 1px solid var(--border-soft); }
.inspector-tabs { height: 100%; display: flex; align-items: stretch; gap: 19px; }
.inspector-tabs button { position: relative; border: 0; padding: 2px 0 0; background: transparent; color: #737570; font-size: 11px; cursor: pointer; }
.inspector-tabs button.active { color: #d6d7d2; }
.inspector-tabs button.active::after { content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 1px; background: #d8d9d4; }
.inspector-tabs span { display: inline-grid; place-items: center; min-width: 17px; height: 15px; margin-left: 3px; padding: 0 4px; border-radius: 6px; background: #27292d; font-size: 8px; }
.inspector-body { display: none; height: calc(100dvh - 58px); overflow-y: auto; padding: 15px 13px; scrollbar-width: thin; scrollbar-color: #33363a transparent; }
.inspector-body.active { display: block; }
.status-section { padding: 3px 2px 18px; border-bottom: 1px solid var(--border-soft); margin-bottom: 14px; }
.section-title { height: 25px; display: flex; align-items: flex-start; justify-content: space-between; color: #c1c2bd; font-size: 10.5px; font-weight: 560; }
.status-label { color: #737570; font-weight: 450; }
.text-button { border: 0; background: none; padding: 0; color: #6e706c; font-size: 9px; cursor: pointer; }
.text-button:hover { color: var(--text-2); }
.empty-small { margin: 4px 0; color: #666864; font-size: 10.5px; line-height: 1.55; }
.plan-list { display: grid; gap: 8px; }
.plan-step { display: grid; grid-template-columns: 14px 1fr; gap: 7px; align-items: start; color: #999b96; font-size: 10.5px; line-height: 1.45; }
.plan-step i { width: 12px; height: 12px; margin-top: 1px; border: 1px solid #4a4c50; border-radius: 50%; }
.plan-step.inProgress i { border-color: var(--amber); border-top-color: transparent; animation: spin .9s linear infinite; }
.plan-step.completed i { border-color: #5f9e78; background: #5f9e78; box-shadow: inset 0 0 0 3px #101113; }
@keyframes spin { to { transform: rotate(360deg); } }
.activity-list { display: grid; gap: 3px; }
.activity-entry { display: grid; grid-template-columns: 18px 1fr auto; gap: 6px; align-items: start; padding: 6px 4px; border-radius: 6px; color: #8c8e89; font-size: 10px; line-height: 1.35; }
.activity-entry:hover { background: #17181b; }
.activity-entry svg { width: 13px; height: 13px; margin-top: 1px; color: #696b66; }
.activity-entry strong { display: block; max-width: 210px; color: #aeb0aa; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.activity-entry time { color: #545651; font-size: 8.5px; }
.system-card { padding: 6px 9px; border: 1px solid var(--border-soft); border-radius: 8px; background: #131416; }
.system-row { min-height: 31px; display: flex; align-items: center; justify-content: space-between; color: #797b76; font-size: 9.5px; }
.system-row + .system-row { border-top: 1px solid #202226; }
.system-row span { display: flex; align-items: center; gap: 6px; }
.system-row strong { color: #a3a59f; font-weight: 520; }
.status-dot { width: 5px; height: 5px; border-radius: 50%; background: var(--green); }
.diff-header { min-height: 31px; display: flex; justify-content: space-between; gap: 8px; color: #7b7d78; font-size: 9.5px; }
.diff-view { min-height: 260px; overflow: auto; margin: 0; padding: 11px; border: 1px solid var(--border-soft); border-radius: 7px; background: #0a0b0c; color: #a3a69f; white-space: pre; font: 9.5px/1.55 ui-monospace, SFMono-Regular, Menlo, monospace; }
.files-toolbar { height: 35px; display: grid; grid-template-columns: 29px minmax(0,1fr) 29px; align-items: center; gap: 4px; padding: 0 2px 7px; border-bottom: 1px solid var(--border-soft); }
.files-toolbar .icon-button { width: 28px; height: 28px; }
.files-toolbar .icon-button svg { width: 14px; height: 14px; }
.files-toolbar > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #898b86; font: 9.5px ui-monospace, SFMono-Regular, Menlo, monospace; }
.file-list { padding-top: 6px; }
.file-row { width: 100%; height: 31px; display: grid; grid-template-columns: 18px minmax(0,1fr) auto; align-items: center; gap: 6px; padding: 0 7px; border: 0; border-radius: 6px; background: transparent; color: #a3a59f; text-align: left; cursor: pointer; }
.file-row:hover { background: #1a1b1e; color: #d0d1cc; }
.file-row svg { width: 14px; height: 14px; color: #71736e; }
.file-row span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 10.5px; }
.file-row small { color: #5f615d; font-size: 8.5px; }

.login-screen { position: fixed; z-index: 100; inset: 0; display: grid; place-items: center; overflow: hidden; background: #0b0c0e; transition: opacity .25s, visibility .25s; }
.login-screen.hidden-login { opacity: 0; visibility: hidden; pointer-events: none; }
.login-glow { position: absolute; width: 700px; height: 500px; left: 50%; top: -360px; transform: translateX(-50%); border-radius: 50%; background: rgba(255,255,255,.07); filter: blur(100px); }
.login-card { position: relative; width: min(378px, calc(100vw - 34px)); padding: 29px; border: 1px solid #292b2f; border-radius: 16px; background: rgba(19,20,23,.88); box-shadow: 0 30px 90px rgba(0,0,0,.45); backdrop-filter: blur(20px); }
.login-logo { display: flex; align-items: center; justify-content: center; gap: 10px; margin-bottom: 29px; font-weight: 650; letter-spacing: -.025em; }
.login-heading { margin-bottom: 24px; text-align: center; }
.login-heading h2 { margin: 0; font-size: 21px; font-weight: 580; letter-spacing: -.035em; }
.login-heading p { margin: 7px 0 0; color: var(--muted); font-size: 11px; }
.login-card > label { display: grid; gap: 7px; margin-bottom: 14px; color: #a5a7a1; font-size: 10.5px; }
.login-card input, .password-form input { width: 100%; height: 40px; outline: 0; border: 1px solid #303237; border-radius: 8px; background: #101113; color: var(--text); padding: 0 11px; transition: border-color .15s; }
.login-card input:focus, .password-form input:focus { border-color: #57595d; }
.form-error { min-height: 16px; margin: 0 0 8px; color: var(--red); font-size: 10px; }
.primary-button { height: 40px; width: 100%; display: flex; align-items: center; justify-content: center; gap: 8px; border: 0; border-radius: 8px; background: var(--accent); color: var(--accent-ink); text-decoration: none; font-size: 11.5px; font-weight: 650; cursor: pointer; }
.primary-button:hover { background: #fff; }
.primary-button svg { width: 15px; height: 15px; stroke-width: 2; }
.primary-button.compact { width: auto; height: 34px; padding: 0 15px; }
.login-security { margin-top: 19px; display: flex; align-items: center; justify-content: center; gap: 6px; color: #62645f; font-size: 9.5px; }
.login-security svg { width: 13px; height: 13px; }

.modal { width: min(480px, calc(100vw - 28px)); max-height: min(680px, calc(100dvh - 32px)); border: 1px solid #37393e; border-radius: 14px; padding: 0; color: var(--text); background: #17181b; box-shadow: 0 30px 100px rgba(0,0,0,.6); }
.modal::backdrop { background: rgba(0,0,0,.58); backdrop-filter: blur(3px); }
.modal[open] { animation: modal-in .17s ease-out; }
@keyframes modal-in { from { opacity: 0; transform: translateY(8px) scale(.985); } }
.modal-header { min-height: 66px; padding: 16px 17px; display: flex; align-items: flex-start; justify-content: space-between; border-bottom: 1px solid var(--border); }
.modal-header h3 { margin: 0; font-size: 14px; font-weight: 600; letter-spacing: -.02em; }
.modal-header p { margin: 4px 0 0; color: var(--muted); font-size: 10px; }
.modal-body { padding: 16px; overflow-y: auto; }
.identity-card { display: flex; align-items: center; gap: 11px; padding: 4px 2px 18px; }
.identity-card > div { flex: 1; display: flex; flex-direction: column; gap: 3px; }
.identity-card strong { font-size: 13px; }
.identity-card small { color: var(--muted); font-size: 10px; text-transform: capitalize; }
.ghost-button { min-height: 32px; padding: 0 11px; border: 1px solid #37393e; border-radius: 7px; background: #202226; color: #c4c5c1; font-size: 10.5px; cursor: pointer; }
.ghost-button:hover { background: #282a2e; border-color: #47494e; }
.ghost-button.danger { color: #d68c86; }
.settings-group { padding: 15px; margin-bottom: 10px; border: 1px solid var(--border); border-radius: 10px; background: #131416; }
.setting-row { display: flex; justify-content: space-between; gap: 10px; }
.setting-row strong, .password-form > strong { font-size: 11px; font-weight: 580; }
.setting-row p { margin: 5px 0 0; color: var(--muted); font-size: 9.5px; }
.badge { height: 21px; display: inline-flex; align-items: center; padding: 0 7px; border: 1px solid #36383c; border-radius: 999px; color: #969893; font-size: 8.5px; }
.badge.success { border-color: rgba(120,213,161,.25); color: var(--green); background: rgba(120,213,161,.06); }
.setting-actions { display: flex; gap: 7px; margin-top: 14px; }
.password-form { display: grid; gap: 9px; }
.password-form input { height: 36px; font-size: 10.5px; }
.password-form .form-error { margin: 0; }
.password-form button { justify-self: start; }
.approval-modal, .device-modal { padding: 20px; }
.approval-modal .modal-header, .device-modal .modal-header { padding: 0 0 16px; border: 0; }
.approval-icon { width: 36px; height: 36px; display: grid; place-items: center; margin-bottom: 13px; border-radius: 9px; background: rgba(232,184,107,.09); color: var(--amber); }
.approval-command { max-height: 190px; overflow: auto; padding: 12px; border: 1px solid #303237; border-radius: 8px; background: #0c0d0f; color: #babcb6; white-space: pre-wrap; word-break: break-word; font: 10.5px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; }
.approval-actions { display: flex; justify-content: flex-end; gap: 7px; margin-top: 17px; }
.device-code { margin: 10px 0 18px; text-align: center; color: #f0f0eb; font: 26px/1.2 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .15em; }
.device-note { margin: 13px 0 0; text-align: center; color: var(--muted); font-size: 9.5px; line-height: 1.5; }
.editor-modal { width: min(900px, calc(100vw - 28px)); height: min(720px, calc(100dvh - 28px)); overflow: hidden; }
.editor-modal[open] { display: grid; grid-template-rows: auto minmax(0,1fr) auto; }
.editor-modal textarea { width: 100%; height: 100%; resize: none; border: 0; outline: 0; padding: 16px 18px; background: #0a0b0d; color: #c7cac3; tab-size: 2; white-space: pre; overflow: auto; font: 12px/1.58 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.editor-footer { min-height: 51px; padding: 8px 12px; display: flex; align-items: center; justify-content: space-between; border-top: 1px solid var(--border); background: #151619; }
.editor-footer > span { color: var(--muted); font-size: 9.5px; }
.editor-footer > div { display: flex; gap: 7px; }
.editor-footer .primary-button { width: auto; }
.toast-stack { position: fixed; z-index: 200; right: 17px; bottom: 17px; display: grid; gap: 8px; pointer-events: none; }
.toast { min-width: 220px; max-width: 360px; padding: 10px 12px; border: 1px solid #383a3f; border-radius: 8px; background: #202226; color: #d5d6d1; box-shadow: 0 15px 50px rgba(0,0,0,.38); font-size: 10.5px; animation: toast-in .2s ease-out; }
.toast.error { border-color: rgba(239,133,125,.34); color: #e4aaa5; }
@keyframes toast-in { from { opacity: 0; transform: translateY(5px); } }
.mobile-scrim { display: none; }

.theme-button { flex: 0 0 auto; }
.login-theme-button { position: absolute; z-index: 2; top: max(16px, env(safe-area-inset-top)); right: max(16px, env(safe-area-inset-right)); border: 1px solid var(--border); background: rgba(18,19,21,.72); backdrop-filter: blur(12px); }
.theme-options { display: grid; grid-template-columns: repeat(3,1fr); gap: 4px; margin-top: 13px; padding: 3px; border: 1px solid var(--border); border-radius: 9px; background: #101113; }
.theme-options button { min-height: 30px; border: 0; border-radius: 6px; background: transparent; color: var(--muted); cursor: pointer; font-size: 10px; }
.theme-options button:hover { color: var(--text-2); }
.theme-options button.active { color: var(--text); background: #24262a; box-shadow: 0 1px 4px rgba(0,0,0,.18); }

.composer.dragging { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(142,184,255,.12), 0 16px 50px rgba(0,0,0,.43); }
.composer-tool-button { height: 26px; display: inline-flex; align-items: center; gap: 5px; padding: 0 7px; border: 0; border-radius: 7px; background: transparent; color: #8d8f8a; cursor: pointer; font-size: 10px; }
.composer-tool-button:hover { background: #24262a; color: var(--text-2); }
.composer-tool-button svg { width: 13px; height: 13px; }
.attachment-list { display: none; gap: 7px; max-height: 190px; overflow: auto; padding: 4px 10px 7px; scrollbar-width: thin; scrollbar-color: #34363a transparent; }
.attachment-list.visible { display: flex; flex-wrap: wrap; }
.attachment-card, .attachment-uploading { position: relative; min-width: 210px; max-width: 100%; min-height: 52px; display: grid; grid-template-columns: 40px minmax(80px,1fr) auto; align-items: center; gap: 8px; padding: 5px 6px; border: 1px solid var(--border); border-radius: 9px; background: #131416; }
.attachment-card > img { width: 40px; height: 40px; object-fit: cover; border-radius: 6px; background: #0a0b0c; }
.attachment-card > svg { width: 24px; height: 24px; margin: 8px; color: var(--muted); }
.attachment-copy { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.attachment-copy strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-2); font-size: 10px; font-weight: 570; }
.attachment-copy small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: 8.5px; }
.attachment-actions { display: flex; align-items: center; gap: 3px; }
.attachment-actions button, .attachment-actions a { min-height: 24px; display: inline-flex; align-items: center; border: 0; border-radius: 5px; padding: 0 6px; background: #24262a; color: var(--text-2); text-decoration: none; cursor: pointer; font-size: 8.5px; white-space: nowrap; }
.attachment-actions button:hover, .attachment-actions a:hover { background: #2a2c30; color: var(--text); }
.attachment-actions .attachment-remove { width: 24px; padding: 0; justify-content: center; background: transparent; color: var(--muted); font-size: 16px; }
.attachment-card.processing { opacity: .78; pointer-events: none; }
.attachment-uploading { grid-template-columns: 18px 1fr; min-width: 190px; padding: 10px; color: var(--muted); }
.attachment-uploading span { width: 13px; height: 13px; border: 1px solid var(--muted); border-top-color: transparent; border-radius: 50%; animation: spin .8s linear infinite; }
.attachment-uploading strong { font-size: 9.5px; font-weight: 500; }
.message-attachments { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 10px; }
.message-attachment { max-width: min(240px,100%); display: flex; align-items: center; gap: 7px; padding: 6px 8px; border: 1px solid var(--border); border-radius: 8px; background: #131416; color: var(--text-2); text-decoration: none; font-size: 9.5px; }
.message-attachment.image { display: grid; padding: 4px; }
.message-attachment img { display: block; width: min(220px,100%); max-height: 220px; object-fit: contain; border-radius: 5px; }
.message-attachment.image span { padding: 1px 3px 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.message-attachment svg { width: 18px; height: 18px; color: var(--muted); }
.agent-card { margin: 8px 0 18px 39px; display: flex; align-items: center; gap: 9px; padding: 9px 11px; border: 1px solid var(--border); border-radius: 9px; background: #131416; }
.agent-card-icon { width: 25px; height: 25px; display: grid; place-items: center; border-radius: 7px; background: #24262a; color: var(--text-2); font-size: 9px; font-weight: 700; }
.agent-card > div { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.agent-card strong { color: var(--text-2); font-size: 10px; font-weight: 570; }
.agent-card small { color: var(--muted); font-size: 8.5px; }
.generated-image-card { width: min(560px,calc(100% - 39px)); margin: 8px 0 22px 39px; padding: 6px; border: 1px solid var(--border); border-radius: 10px; background: #111214; }
.generated-image-card img { display: block; width: 100%; max-height: 620px; object-fit: contain; border-radius: 6px; }
.generated-image-card figcaption { padding: 7px 4px 2px; color: var(--muted); font-size: 9.5px; }

html[data-theme="light"] {
  --bg: #f5f6f8;
  --panel: #ffffff;
  --panel-2: #f7f8fa;
  --panel-3: #edf0f3;
  --hover: #eceff2;
  --border: #d9dde3;
  --border-soft: #e6e8ec;
  --text: #17191d;
  --text-2: #3f454d;
  --muted: #747b84;
  --accent: #1d2025;
  --accent-ink: #ffffff;
  --green: #218153;
  --amber: #a96818;
  --red: #c94f47;
  --blue: #3977d4;
  color-scheme: light;
}
html[data-theme="light"] .sidebar,
html[data-theme="light"] .inspector { background: #fafafa; }
html[data-theme="light"] .topbar { background: rgba(245,246,248,.88); }
html[data-theme="light"] .new-task-button,
html[data-theme="light"] .search-box:focus-within,
html[data-theme="light"] .suggestions button,
html[data-theme="light"] .settings-group,
html[data-theme="light"] .system-card,
html[data-theme="light"] .attachment-card,
html[data-theme="light"] .attachment-uploading,
html[data-theme="light"] .message-attachment { background: #ffffff; }
html[data-theme="light"] .agent-card,
html[data-theme="light"] .generated-image-card { background: #ffffff; }
html[data-theme="light"] .agent-card-icon { background: #edf0f3; }
html[data-theme="light"] .new-task-button:hover,
html[data-theme="light"] .thread-item.active,
html[data-theme="light"] .suggestions button:hover,
html[data-theme="light"] .activity-entry:hover,
html[data-theme="light"] .file-row:hover { background: #eceff2; border-color: #cbd0d7; }
html[data-theme="light"] .thread-item:hover { background: #f0f2f4; }
html[data-theme="light"] .thread-skeleton i { background: linear-gradient(100deg,#f0f1f3 20%,#e5e8eb 45%,#f0f1f3 70%); background-size: 300% 100%; }
html[data-theme="light"] .progress-track { background: #e1e4e8; }
html[data-theme="light"] .topbar .workspace-path,
html[data-theme="light"] .thread-item small,
html[data-theme="light"] .message-meta time,
html[data-theme="light"] .file-row small,
html[data-theme="light"] .composer-note { color: #858c95; }
html[data-theme="light"] .welcome-mark { color: #343a42; }
html[data-theme="light"] .suggestions strong,
html[data-theme="light"] .message-content,
html[data-theme="light"] .message.user .message-content,
html[data-theme="light"] .inspector-tabs button.active,
html[data-theme="light"] .section-title { color: var(--text); }
html[data-theme="light"] .suggestions small,
html[data-theme="light"] .empty-small,
html[data-theme="light"] .activity-entry,
html[data-theme="light"] .status-label,
html[data-theme="light"] .inspector-tabs button { color: var(--muted); }
html[data-theme="light"] .message-avatar { border-color: #d9dde3; color: #4c535c; background: #ffffff; }
html[data-theme="light"] .message.user .message-avatar { color: #ffffff; background: #353b43; }
html[data-theme="light"] .message-content pre,
html[data-theme="light"] .tool-card .tool-output,
html[data-theme="light"] .diff-view,
html[data-theme="light"] .approval-command,
html[data-theme="light"] .editor-modal textarea { background: #f7f8fa; color: #30363d; }
html[data-theme="light"] .message-content code:not(pre code) { background: #e9edf1; color: #27313c; }
html[data-theme="light"] .tool-card { background: #ffffff; }
html[data-theme="light"] .tool-card summary,
html[data-theme="light"] .tool-card .tool-output,
html[data-theme="light"] .diff-view { color: #4b535d; }
html[data-theme="light"] .tool-card summary strong { color: #30363d; }
html[data-theme="light"] .composer-wrap { background: linear-gradient(0deg,var(--bg) 58%,rgba(245,246,248,0)); }
html[data-theme="light"] .composer { border-color: #cfd4da; background: #ffffff; box-shadow: 0 15px 42px rgba(25,31,38,.12), inset 0 1px 0 rgba(255,255,255,.8); }
html[data-theme="light"] .composer:focus-within { border-color: #a8afb8; box-shadow: 0 15px 46px rgba(25,31,38,.16); }
html[data-theme="light"] .select-chip,
html[data-theme="light"] .composer-tool-button { color: #626a74; }
html[data-theme="light"] .select-chip:hover,
html[data-theme="light"] .composer-tool-button:hover,
html[data-theme="light"] .attachment-actions button,
html[data-theme="light"] .attachment-actions a { background: #edf0f3; }
html[data-theme="light"] .select-chip select { color: #4d545d; }
html[data-theme="light"] .stop-button { background: #eceff2; border-color: #d3d7dd; }
html[data-theme="light"] .stop-button span { background: #4d545d; }
html[data-theme="light"] .terminal-drawer { border-color: #cfd4da; background: #ffffff; box-shadow: 0 20px 65px rgba(25,31,38,.2); }
html[data-theme="light"] .terminal-header,
html[data-theme="light"] .terminal-form,
html[data-theme="light"] .editor-footer { border-color: var(--border); background: #f5f6f8; }
html[data-theme="light"] .terminal-output { background: #ffffff; color: #35404a; }
html[data-theme="light"] .terminal-form input { color: #252b32; }
html[data-theme="light"] .terminal-form button { background: #e5e8ec; color: #4b535d; }
html[data-theme="light"] .plan-step.completed i { box-shadow: inset 0 0 0 3px #fafafa; }
html[data-theme="light"] .inspector-tabs span { background: #e7eaee; }
html[data-theme="light"] .file-row { color: #4c535c; }
html[data-theme="light"] .login-screen { background: #f3f5f7; }
html[data-theme="light"] .login-glow { background: rgba(83,101,124,.12); }
html[data-theme="light"] .login-card { border-color: #d8dce2; background: rgba(255,255,255,.9); box-shadow: 0 28px 85px rgba(31,40,51,.16); }
html[data-theme="light"] .login-theme-button { background: rgba(255,255,255,.76); }
html[data-theme="light"] .login-card > label { color: #535b65; }
html[data-theme="light"] .login-card input,
html[data-theme="light"] .password-form input,
html[data-theme="light"] .theme-options { border-color: #d6dae0; background: #ffffff; }
html[data-theme="light"] .primary-button:hover { background: #000000; }
html[data-theme="light"] .login-security { color: #777f88; }
html[data-theme="light"] .modal { border-color: #d2d6dc; background: #ffffff; box-shadow: 0 28px 90px rgba(25,31,38,.22); }
html[data-theme="light"] .modal::backdrop { background: rgba(42,48,56,.32); }
html[data-theme="light"] .ghost-button { border-color: #d4d8de; background: #f1f3f5; color: #424952; }
html[data-theme="light"] .ghost-button:hover { background: #e7eaee; border-color: #c5cad1; }
html[data-theme="light"] .badge { border-color: #d3d7dd; color: #68717b; }
html[data-theme="light"] .theme-options button.active { background: #e7eaee; color: var(--text); box-shadow: none; }
html[data-theme="light"] .device-code { color: #1e2329; }
html[data-theme="light"] .toast { border-color: #d2d6dc; background: #ffffff; color: #333a42; box-shadow: 0 14px 45px rgba(25,31,38,.16); }
html[data-theme="light"] .attachment-card > img { background: #f0f2f4; }

@media (max-width: 1180px) {
  .app-shell { grid-template-columns: var(--sidebar) minmax(0, 1fr); }
  .inspector { position: fixed; top: 0; right: 0; bottom: 0; width: min(var(--inspector),calc(100vw - 40px)); box-shadow: -20px 0 60px rgba(0,0,0,.45); transform: translateX(100%); opacity: 0; pointer-events: none; }
  .app-shell.inspector-open .inspector { transform: translateX(0); opacity: 1; pointer-events: auto; }
  .app-shell.inspector-hidden { grid-template-columns: var(--sidebar) minmax(0,1fr); }
  .inspector-close { display: grid; }
}

@media (max-width: 760px) {
  :root { --sidebar: 282px; }
  .app-shell, .app-shell.inspector-hidden { display: block; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: min(var(--sidebar), calc(100vw - 42px)); transform: translateX(-102%); transition: transform .2s ease; box-shadow: 20px 0 60px rgba(0,0,0,.46); }
  .app-shell.sidebar-open .sidebar { transform: translateX(0); }
  .mobile-scrim { position: fixed; z-index: 15; inset: 0; background: rgba(0,0,0,.55); opacity: 0; pointer-events: none; display: block; transition: opacity .2s; }
  .app-shell.sidebar-open .mobile-scrim, .app-shell.inspector-open .mobile-scrim { opacity: 1; pointer-events: auto; }
  .sidebar-close, .mobile-menu { display: grid; }
  .workspace { height: 100dvh; grid-template-rows: 54px minmax(0,1fr) auto; }
  .topbar { height: 54px; padding: 0 10px 0 8px; }
  .title-block h1 { max-width: 45vw; }
  .connection-pill span { display: none; }
  .connection-pill { width: 25px; padding: 0; justify-content: center; }
  .inspector { width: min(360px,calc(100vw - 25px)); }
  .inspector-header { height: 54px; }
  .inspector-body { height: calc(100dvh - 54px); }
  .welcome { padding: 42px 20px 135px; }
  .welcome h2 { font-size: 21px; }
  .suggestions { grid-template-columns: 1fr; width: min(360px,100%); }
  .suggestions button { height: 59px; align-items: center; }
  .messages { width: calc(100% - 28px); padding-top: 23px; }
  .composer-wrap { padding: 0 9px max(8px, env(safe-area-inset-bottom)); }
  .composer-note { display: none; }
  .composer-options .select-chip:last-of-type { display: none; }
  .composer-tool-button span { display: none; }
  .attachment-list { max-height: 225px; padding-inline: 7px; }
  .attachment-card { width: 100%; min-width: 0; }
  .attachment-actions button:not(.attachment-remove), .attachment-actions a { font-size: 0; width: 27px; padding: 0; justify-content: center; }
  .attachment-actions button:not(.attachment-remove)::after { content: "A4"; font-size: 8px; }
  .attachment-actions a::after { content: "PDF"; font-size: 8px; }
  .queue-hint { max-width: 100px; }
  .message { grid-template-columns: 24px minmax(0,1fr); gap: 9px; }
  .message-avatar { width: 24px; height: 24px; border-radius: 7px; }
  .message-content { font-size: 12.5px; }
  .tool-card { margin-left: 33px; }
  .approval-actions { flex-wrap: wrap; }
  .approval-actions button { flex: 1; }
  .terminal-drawer { left: 6px; right: 6px; bottom: 98px; height: min(310px, calc(100dvh - 170px)); }
  .editor-modal { width: calc(100vw - 12px); height: calc(100dvh - 12px); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
