:root {
  color-scheme: dark;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --bg: #212121;
  --panel: #2f2f2f;
  --panel-soft: #292929;
  --panel-hover: #3a3a3a;
  --border: #474747;
  --text: #ececec;
  --muted: #a7a7a7;
  --blue: #10a37f;
  --blue-hover: #16b893;
  --danger: #e25c5c;
  --drawer-width: min(86vw, 330px);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; overflow: hidden; background: var(--bg); color: var(--text); }
button, input, select, textarea { font: inherit; }
button { color: inherit; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, summary:focus-visible { outline: 2px solid #7edac4; outline-offset: 2px; }

.app-shell { height: 100%; min-height: 100dvh; display: flex; position: relative; overflow: hidden; }
.main-shell { width: 100%; height: 100%; min-width: 0; display: flex; flex-direction: column; }
.topbar { height: 58px; flex: 0 0 58px; display: flex; align-items: center; gap: 10px; padding: 0 14px; border-bottom: 1px solid rgba(255,255,255,.08); background: rgba(33,33,33,.96); z-index: 2; }
.icon-button { width: 38px; height: 38px; flex: 0 0 38px; border: 0; border-radius: 9px; background: transparent; color: #e8e8e8; font-size: 22px; line-height: 1; cursor: pointer; }
.icon-button:hover { background: var(--panel-hover); }
.topbar-title { min-width: 0; flex: 1; text-align: center; }
.current-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 15px; font-weight: 600; }
.current-subtitle { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: 11px; margin-top: 2px; }
.connection-pill { min-width: 48px; display: flex; justify-content: flex-end; align-items: center; gap: 5px; color: var(--muted); font-size: 11px; }
.connection-pill .pill-led, .status-dot::before { width: 7px; height: 7px; display: inline-block; border-radius: 50%; background: #777; content: ""; }
.connection-pill.online .pill-led, .status-dot.online::before { background: #39c38f; box-shadow: 0 0 0 3px rgba(57,195,143,.12); }
.connection-pill.busy .pill-led { background: #e2b34c; box-shadow: 0 0 0 3px rgba(226,179,76,.12); }

.chat-scroll { width: 100%; max-width: 900px; margin: 0 auto; flex: 1 1 auto; overflow-y: auto; overscroll-behavior: contain; padding: 24px max(16px, calc((100% - 760px) / 2)) 152px; scroll-behavior: smooth; }
.empty-state { min-height: min(58vh, 520px); display: flex; flex-direction: column; align-items: center; justify-content: center; color: var(--muted); text-align: center; padding: 24px; }
.empty-mark { width: 55px; height: 55px; display: grid; place-items: center; margin-bottom: 18px; border: 1px solid #515151; border-radius: 18px; color: #d8d8d8; font-size: 27px; }
.empty-state h1 { margin: 0; color: var(--text); font-size: clamp(22px, 6vw, 30px); font-weight: 600; }
.empty-state p { max-width: 320px; margin: 10px 0 18px; font-size: 13px; line-height: 1.6; }
.message-list { display: flex; flex-direction: column; gap: 24px; }
.chat-message { display: flex; align-items: flex-start; gap: 11px; min-width: 0; }
.chat-message.user { flex-direction: row-reverse; }
.avatar { width: 28px; height: 28px; flex: 0 0 28px; display: grid; place-items: center; border-radius: 8px; font-size: 14px; }
.assistant-avatar { background: #10a37f; color: white; }
.user-avatar { background: #6f6f6f; color: white; font-size: 12px; }
.message-body { min-width: 0; max-width: calc(100% - 40px); }
.user .message-body { display: flex; flex-direction: column; align-items: flex-end; }
.message-role { margin: 1px 0 5px; color: #bdbdbd; font-size: 12px; }
.message-text { color: var(--text); font-size: 15px; line-height: 1.65; white-space: pre-wrap; overflow-wrap: anywhere; }
.user .message-text { max-width: 100%; padding: 10px 13px; border-radius: 17px 17px 4px 17px; background: #343434; }
.assistant .message-text { padding-right: 4px; }
.streaming { margin-top: 24px; }
.typing-indicator { display: flex; gap: 4px; margin-top: 8px; }
.typing-indicator i { width: 5px; height: 5px; border-radius: 50%; background: #a8a8a8; animation: blink 1.2s infinite ease-in-out; }
.typing-indicator i:nth-child(2) { animation-delay: .16s; }.typing-indicator i:nth-child(3) { animation-delay: .32s; }
@keyframes blink { 0%, 70%, 100% { opacity: .28; } 35% { opacity: 1; } }

.composer-area { position: absolute; right: 0; bottom: 0; left: 0; z-index: 3; padding: 8px 14px max(10px, env(safe-area-inset-bottom)); background: linear-gradient(transparent, var(--bg) 21%); }
.composer-card { width: min(900px, 100%); margin: 0 auto; padding: 10px 10px 8px 13px; border: 1px solid #555; border-radius: 17px; background: #2f2f2f; box-shadow: 0 5px 25px rgba(0,0,0,.2); }
#prompt { width: 100%; min-height: 27px; max-height: 160px; display: block; padding: 1px 0 8px; border: 0; outline: 0; resize: none; overflow-y: auto; background: transparent; color: var(--text); font-size: 15px; line-height: 1.5; }
#prompt::placeholder { color: #989898; }
.composer-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.composer-left, .composer-right { min-width: 0; display: flex; align-items: center; gap: 6px; }
.toolbar-button { width: 29px; height: 29px; flex: 0 0 29px; border: 1px solid #666; border-radius: 50%; background: transparent; color: #ddd; font-size: 21px; line-height: 20px; cursor: pointer; }
.toolbar-button:hover { background: var(--panel-hover); }
.compact-select { min-width: 0; max-width: 118px; padding: 6px 19px 6px 7px; border: 0; border-radius: 7px; background: transparent; color: #bfbfbf; font-size: 11px; cursor: pointer; }
.compact-select:hover { background: var(--panel-hover); color: var(--text); }
.effort-select { max-width: 83px; }
.send-button { width: 32px; height: 32px; border: 0; border-radius: 50%; background: var(--text); color: #262626; font-size: 22px; line-height: 1; font-weight: 700; cursor: pointer; }
.send-button:hover { background: white; }
.send-button:disabled { opacity: .35; cursor: not-allowed; }
.stop-button { padding: 6px 9px; border: 1px solid #6b4343; border-radius: 8px; background: #4a2d2d; color: #f0b4b4; font-size: 11px; cursor: pointer; }
.status-line { width: min(900px, 100%); min-height: 15px; margin: 4px auto 0; padding: 0 4px; color: #888; font-size: 10px; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.status-line.error { color: #f19191; }
.attachment-list { width: min(900px, 100%); display: flex; gap: 7px; margin: 0 auto 5px; overflow-x: auto; padding: 0 2px; }
.attachment-chip { max-width: 190px; display: flex; align-items: center; gap: 5px; padding: 5px 8px; border: 1px solid #555; border-radius: 8px; background: #333; color: #d4d4d4; font-size: 11px; white-space: nowrap; }
.attachment-chip span { overflow: hidden; text-overflow: ellipsis; }.attachment-chip button { border: 0; padding: 0 2px; background: transparent; color: #aaa; cursor: pointer; }

.drawer { position: fixed; inset: 0 auto 0 0; z-index: 10; width: var(--drawer-width); display: flex; flex-direction: column; transform: translateX(-102%); border-right: 1px solid #484848; background: #171717; box-shadow: 8px 0 32px rgba(0,0,0,.26); transition: transform .2s ease; }
.drawer.open { transform: translateX(0); }
.drawer-backdrop { position: fixed; inset: 0; z-index: 9; background: rgba(0,0,0,.58); }.drawer-backdrop:not([hidden]) { display: block; }
.drawer-head { height: 58px; flex: 0 0 58px; display: flex; align-items: center; justify-content: space-between; padding: 0 13px 0 17px; border-bottom: 1px solid #303030; }
.brand { display: flex; align-items: center; gap: 9px; color: #e8e8e8; font-size: 15px; font-weight: 600; }.brand-mark { color: #10a37f; font-size: 20px; }
.drawer-scroll { flex: 1; overflow-y: auto; overscroll-behavior: contain; }.drawer-section { padding: 15px 15px 16px; border-bottom: 1px solid #303030; }.connection-section { padding-top: 13px; }
.section-title-row { display: flex; align-items: center; justify-content: space-between; gap: 7px; margin-bottom: 9px; }.section-title-row h2 { margin: 0; color: #d1d1d1; font-size: 12px; font-weight: 600; }.section-icon { color: #777; font-size: 15px; }
.status-dot { display: flex; align-items: center; gap: 5px; color: #888; font-size: 10px; }.status-dot.online { color: #70d0af; }.status-dot.offline { color: #888; }
.helper-text { color: #898989; font-size: 11px; line-height: 1.5; white-space: pre-wrap; overflow-wrap: anywhere; }.error { color: #f19191 !important; }
label { display: block; margin: 10px 0 5px; color: #999; font-size: 10px; }
input, select { width: 100%; min-height: 35px; padding: 7px 9px; border: 1px solid #4b4b4b; border-radius: 8px; background: #242424; color: #e7e7e7; font-size: 12px; }
input::placeholder { color: #707070; } select { cursor: pointer; }
button.primary-button, button.secondary-button { min-height: 34px; padding: 7px 10px; border: 1px solid transparent; border-radius: 8px; font-size: 12px; cursor: pointer; }.primary-button { background: var(--blue); color: white; }.primary-button:hover { background: var(--blue-hover); }.secondary-button { border-color: #505050 !important; background: #303030; color: #d1d1d1; }.secondary-button:hover { background: #3b3b3b; }
.connection-actions, .git-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; margin-top: 10px; }.git-actions { grid-template-columns: 1fr 1fr 1fr; }.inline-form { display: flex; gap: 7px; }.inline-form > *:first-child { min-width: 0; flex: 1; }.inline-form button { flex: 0 0 auto; }
.advanced-settings { margin-top: 12px; }.advanced-settings summary, details > summary { color: #888; font-size: 11px; cursor: pointer; }.advanced-settings input { margin-top: 7px; font-size: 10px; }
.small-action { border: 0; padding: 3px 5px; border-radius: 5px; background: transparent; color: #78cfb4; font-size: 11px; cursor: pointer; }.small-action:hover { background: #303030; }
.thread-list { display: flex; flex-direction: column; gap: 2px; max-height: 290px; overflow-y: auto; }.thread-item { width: 100%; display: flex; align-items: center; gap: 8px; padding: 8px 9px; border: 0; border-radius: 7px; background: transparent; color: #bfbfbf; text-align: left; font-size: 12px; cursor: pointer; }.thread-item:hover { background: #2c2c2c; }.thread-item.selected { background: #393939; color: white; }.thread-item .thread-icon { color: #8b8b8b; }.thread-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }.empty-list { padding: 8px 2px; color: #777; font-size: 11px; }
.new-thread-form { margin-top: 9px; padding: 10px; border: 1px solid #444; border-radius: 9px; background: #222; }.new-thread-form label { margin-top: 8px; }.new-thread-form label:first-child { margin-top: 0; }.new-thread-form .inline-form { margin-top: 10px; }
.git-files { max-height: 180px; margin-top: 7px; overflow-y: auto; border: 1px solid #3d3d3d; border-radius: 7px; background: #222; }.git-file { display: flex; align-items: flex-start; gap: 6px; padding: 6px 7px; border-bottom: 1px solid #353535; color: #bdbdbd; font-size: 10px; cursor: pointer; }.git-file:last-child { border-bottom: 0; }.git-file input { width: 13px; min-height: 13px; flex: 0 0 13px; margin: 1px 0 0; accent-color: var(--blue); }.git-file code { overflow-wrap: anywhere; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; }.git-status { flex: 0 0 18px; color: #dab467; font-family: ui-monospace, monospace; }.git-output { max-height: 130px; margin: 8px 0 0; overflow: auto; padding: 7px; border: 1px solid #3d3d3d; border-radius: 7px; background: #1e1e1e; color: #aaa; font: 10px/1.45 ui-monospace, monospace; white-space: pre-wrap; overflow-wrap: anywhere; }
.debug-section details { padding-top: 0; }.events { max-height: 220px; margin-top: 8px; overflow: auto; }.event { padding: 6px 0; border-top: 1px solid #333; color: #999; font: 10px/1.45 ui-monospace, monospace; white-space: pre-wrap; overflow-wrap: anywhere; }.event strong { color: #7ecdb6; }
.drawer-foot { flex: 0 0 auto; padding: 10px 15px max(10px, env(safe-area-inset-bottom)); color: #666; font-size: 10px; line-height: 1.4; }
.visually-hidden { position: absolute !important; width: 1px !important; height: 1px !important; padding: 0 !important; margin: -1px !important; overflow: hidden !important; clip: rect(0,0,0,0) !important; white-space: nowrap !important; border: 0 !important; }

@media (min-width: 760px) {
  .drawer { width: 300px; box-shadow: none; }
  .drawer-backdrop { display: none !important; }
  .main-shell { margin-left: 0; }
  .chat-scroll { padding-left: max(24px, calc((100% - 760px) / 2)); padding-right: max(24px, calc((100% - 760px) / 2)); }
}
@media (max-width: 390px) {
  .topbar { padding-left: 9px; padding-right: 9px; }.chat-scroll { padding-right: 12px; padding-left: 12px; }.composer-area { padding-right: 8px; padding-left: 8px; }.compact-select { max-width: 98px; }.effort-select { max-width: 69px; }.current-title { font-size: 14px; }
}
