:root {
  color-scheme: dark;
  --bg: #101112;
  --panel: #17191a;
  --panel-raised: #1d2021;
  --border: #2b2e2f;
  --text: #eceeed;
  --muted: #94999a;
  --subtle: #6e7475;
  --accent: #dcf59b;
  --accent-ink: #17200c;
  --danger: #f09b8f;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

* { box-sizing: border-box; }
html, body { margin: 0; width: 100%; min-height: 100%; }
body { min-height: 100vh; background: var(--bg); color: var(--text); }
button, input, textarea, select { font: inherit; }
button { color: inherit; }
button:disabled { cursor: not-allowed; opacity: .48; }
.hidden { display: none !important; }
.muted { color: var(--muted); line-height: 1.65; }
.hint { color: var(--subtle); font-size: 12px; line-height: 1.6; }
.eyebrow { color: var(--subtle); font: 500 10px/1.4 var(--mono); letter-spacing: .16em; text-transform: uppercase; }

.app-shell { display: flex; width: 100%; min-height: 100vh; }
.sidebar { position: fixed; z-index: 20; inset: 0 auto 0 0; display: flex; flex-direction: column; width: 272px; padding: 18px 14px 12px; background: #151718; border-right: 1px solid #252829; }
.side-top { display: flex; align-items: center; justify-content: space-between; height: 35px; margin: 0 3px 20px; }
.brand { display: inline-flex; align-items: center; gap: 9px; color: var(--text); text-decoration: none; font-size: 16px; font-weight: 700; letter-spacing: -.045em; }
.brand-dot { width: 5px; height: 5px; margin: 11px 0 0 -7px; border-radius: 50%; background: var(--accent); }
.brand-mark { display: grid; width: 42px; height: 42px; place-items: center; border: 1px solid #596746; border-radius: 13px; background: linear-gradient(145deg,#dff7a2,#a9d277); color: #1b2412; font-size: 22px; font-weight: 700; letter-spacing: -.08em; box-shadow: 0 5px 28px #b9df7e24; }
.brand-mark.small { width: 27px; height: 27px; border-radius: 8px; font-size: 15px; }
.icon-button { display: inline-grid; place-items: center; width: 32px; height: 32px; border: 0; border-radius: 8px; color: #9ca1a2; background: transparent; font-size: 18px; cursor: pointer; }
.icon-button:hover { color: var(--text); background: #ffffff0b; }
.sidebar-toggle, .mobile-menu { display: none; }
.button { display: inline-flex; align-items: center; justify-content: center; gap: 10px; min-height: 40px; padding: 0 14px; border: 1px solid var(--border); border-radius: 10px; color: var(--text); background: var(--panel-raised); cursor: pointer; transition: background .15s ease, transform .15s ease, border-color .15s ease; }
.button:hover:not(:disabled) { transform: translateY(-1px); border-color: #494e4f; background: #252829; }
.button-primary { border-color: transparent; color: var(--accent-ink); background: var(--accent); font-weight: 700; }
.button-primary:hover:not(:disabled) { background: #e7f8bd; }
.button-secondary { background: transparent; }
.button span { font-size: 16px; }
.new-chat-button { justify-content: flex-start; width: 100%; min-height: 40px; padding: 0 11px; border-color: #393d3e; color: #e0e2e1; background: #1d2021; font-size: 13px; }
.new-chat-button .plus { color: var(--accent); font-size: 19px; line-height: 1; }
.new-chat-button kbd { margin-left: auto; padding: 2px 5px; border: 1px solid #393d3e; border-radius: 5px; color: #777d7d; font: 10px var(--mono); }
.side-section-head { display: flex; align-items: center; justify-content: space-between; margin: 25px 3px 7px 7px; color: #858b8b; font-size: 11px; font-weight: 600; letter-spacing: .035em; }
.side-section-head .icon-button { width: 24px; height: 24px; font-size: 18px; }
.project-list, .thread-list { display: grid; gap: 2px; }
.project-row, .thread-row { display: flex; align-items: center; width: 100%; min-height: 34px; padding: 5px 8px; border: 0; border-radius: 8px; color: #aeb3b3; background: transparent; text-align: left; cursor: pointer; }
.project-row:hover, .thread-row:hover { background: #ffffff08; color: var(--text); }
.project-row.selected, .thread-row.selected { color: var(--text); background: #ffffff0c; }
.project-glyph { display: grid; flex: 0 0 21px; width: 21px; height: 21px; place-items: center; margin-right: 9px; border-radius: 6px; color: #cad7b3; background: #59674755; font-size: 11px; font-weight: 700; }
.project-name, .thread-row { overflow: hidden; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.thread-list { overflow: auto; min-height: 30px; }
.thread-row { display: block; min-height: 31px; padding-left: 12px; }
.empty-side { margin: 5px 8px; color: #676e6e; font-size: 11px; line-height: 1.6; }
.side-bottom { margin-top: auto; padding-top: 12px; border-top: 1px solid #282b2c; }
.account-line { display: flex; align-items: center; gap: 8px; padding: 8px 7px 9px; color: #a8adad; font-size: 11px; }
.status-dot { display: inline-block; width: 7px; height: 7px; flex: 0 0 7px; border-radius: 99px; background: #d5a86e; }
.status-dot.good { background: #a7db78; box-shadow: 0 0 12px #a7db7840; }
.status-dot.pulse { animation: pulse 1.7s infinite ease-in-out; }
@keyframes pulse { 50% { opacity: .38; } }
.side-link { display: flex; justify-content: space-between; width: 100%; padding: 8px 7px; border: 0; color: #707676; background: transparent; text-align: left; font-size: 11px; cursor: pointer; }
.side-link:hover { color: var(--text); }

.main-panel { display: flex; flex-direction: column; width: calc(100% - 272px); min-height: 100vh; margin-left: 272px; }
.topbar { position: sticky; z-index: 5; top: 0; display: flex; align-items: center; justify-content: space-between; width: 100%; height: 61px; padding: 0 24px; border-bottom: 1px solid #252829; background: #101112eF; backdrop-filter: blur(16px); }
.breadcrumb { display: flex; min-width: 0; align-items: center; gap: 10px; color: #bfc3c2; font-size: 12px; }
.breadcrumb span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.breadcrumb .slash { color: #5d6263; }
.top-actions { display: flex; align-items: center; gap: 7px; }
.model-picker, .effort-picker { max-width: 185px; height: 32px; padding: 0 26px 0 9px; border: 1px solid #2c3031; border-radius: 8px; outline: 0; color: #c8cccb; background: #191c1d; font-size: 11px; }
.effort-picker { max-width: 130px; }
.model-picker:focus, .effort-picker:focus { border-color: #727f5e; }
.workspace { display: flex; flex: 1; flex-direction: column; width: min(100%, 1100px); min-height: calc(100vh - 61px); margin: 0 auto; padding: 22px clamp(18px, 5vw, 64px) 26px; }
.welcome-state { display: flex; flex: 1; flex-direction: column; align-items: center; justify-content: center; padding: 32px 0 12vh; text-align: center; }
.welcome-symbol { position: relative; display: grid; width: 86px; height: 86px; place-items: center; margin-bottom: 27px; border: 1px solid #41483a; border-radius: 27px; color: var(--accent); background: radial-gradient(circle at 30% 20%,#353f2c,#202421 72%); box-shadow: 0 18px 80px #d7f59b0b; font-size: 45px; font-weight: 700; letter-spacing: -.1em; }
.symbol-spark { position: absolute; top: 9px; right: 11px; color: #f0c778; font-size: 13px; }
.welcome-state .eyebrow { margin: 0 0 12px; }
.welcome-state h1, .connect-state h1 { margin: 0; color: #ecedeb; font-size: clamp(25px, 3vw, 34px); font-weight: 500; letter-spacing: -.045em; }
.welcome-state .muted { max-width: 460px; margin: 10px 0 22px; font-size: 13px; }
.connect-state { display: flex; flex: 1; flex-direction: column; align-items: center; justify-content: center; padding: 40px 20px 80px; text-align: center; }
.connect-orbit { display: grid; width: 102px; height: 102px; place-items: center; margin-bottom: 26px; border: 1px solid #333a2b; border-radius: 50%; background: radial-gradient(circle,#242a20,#141615 72%); }
.connect-state .eyebrow { margin: 0 0 10px; }
.connect-copy { max-width: 430px; margin: 11px 0 24px; font-size: 13px; }
.device-code { display: grid; justify-items: center; gap: 11px; max-width: 360px; margin-top: 23px; padding: 17px 20px; border: 1px solid #303536; border-radius: 14px; background: #171a1b; }
.device-code p { margin: 0; color: #a9afae; font-size: 12px; }
.device-code a { color: var(--accent); font-size: 12px; text-decoration: none; }
.device-code a:hover { text-decoration: underline; }
.code-copy { display: flex; align-items: center; gap: 14px; padding: 9px 12px; border: 1px solid #343a3b; border-radius: 8px; color: var(--text); background: #111314; cursor: pointer; }
.code-copy span:first-child { font: 500 18px var(--mono); letter-spacing: .06em; }
.code-copy span:last-child { color: var(--muted); font-size: 10px; }

.conversation { display: flex; flex: 1; flex-direction: column; width: 100%; min-height: calc(100vh - 110px); }
.messages { display: flex; flex: 1; flex-direction: column; gap: 18px; overflow: visible; padding: 22px 0 25px; }
.message { display: flex; gap: 12px; max-width: 100%; align-items: flex-start; }
.message.user { align-self: flex-end; flex-direction: row-reverse; max-width: min(88%, 760px); }
.message.assistant { align-self: stretch; }
.message-head { display: flex; flex: 0 0 28px; flex-direction: column; align-items: center; gap: 5px; padding-top: 2px; }
.message-head time { color: #606666; font: 9px var(--mono); }
.message-head > span:nth-child(2) { display: none; }
.message-avatar { display: grid; width: 27px; height: 27px; place-items: center; border: 1px solid #383e3f; border-radius: 9px; color: #cbd2c8; background: #202524; font-size: 12px; font-weight: 600; }
.message-avatar.assistant { border-color: #586545; color: #1c2614; background: var(--accent); }
.message.user .message-head { flex-direction: column; }
.message-body { min-width: 0; max-width: 100%; padding: 2px 0; color: #dfe2e0; font-size: 13px; line-height: 1.7; overflow-wrap: anywhere; }
.message.user .message-body { padding: 10px 14px; border: 1px solid #313536; border-radius: 15px 4px 15px 15px; background: #1d2021; }
.message-text { white-space: normal; }
.message.user .message-text { white-space: pre-wrap; }
.markdown-paragraph { margin: 0 0 11px; }
.markdown-paragraph:last-child { margin-bottom: 0; }
.message-text code, .activity-content code { padding: 1px 5px; border-radius: 4px; color: #d7e7b6; background: #ffffff0d; font: .92em var(--mono); }
.markdown-code { overflow: auto; max-width: 100%; margin: 10px 0; padding: 13px 15px; border: 1px solid #2e3334; border-radius: 10px; color: #d2d9cc; background: #141617; font: 11px/1.65 var(--mono); white-space: pre; }
.markdown-code code { padding: 0; background: none; }
.message-image { display: block; max-width: min(100%, 460px); max-height: 360px; margin: 7px 0; border: 1px solid #3a3e3e; border-radius: 10px; object-fit: contain; }
.activity-card, .file-change-card { align-self: stretch; margin-left: 39px; border: 1px solid #2c3031; border-radius: 11px; background: #151819; }
.activity-head { display: flex; align-items: center; gap: 9px; padding: 10px 12px 8px; color: #bcc3bd; font-size: 11px; }
.activity-icon { color: var(--accent); font: 12px var(--mono); }
.activity-status { margin-left: auto; color: #7e8780; font-size: 10px; }
.activity-content { overflow: auto; max-height: 310px; margin: 0; padding: 9px 12px 12px 34px; border-top: 1px solid #282c2d; color: #a9b1ad; font: 10px/1.6 var(--mono); white-space: pre-wrap; }
.file-change-card { padding: 0; color: #cbd0cc; }
.file-change-card summary { display: flex; gap: 9px; align-items: center; padding: 12px; cursor: pointer; list-style: none; font-size: 11px; }
.file-change-card summary::-webkit-details-marker { display: none; }
.file-change-card summary > span:first-child { color: var(--accent); }
.diff-entry { border-top: 1px solid #2c3031; }
.diff-filename { padding: 8px 12px; color: #9eaaa0; font: 10px var(--mono); }
.diff-entry pre { overflow: auto; max-height: 300px; margin: 0; padding: 8px 12px; color: #bfc9bc; background: #111314; font: 10px/1.6 var(--mono); white-space: pre-wrap; }
.pending-approvals { display: grid; gap: 10px; margin: 0 0 13px 39px; }
.approval-card { padding: 14px; border: 1px solid #665a3d; border-radius: 12px; background: #211f18; }
.approval-card .eyebrow { margin: 0 0 6px; color: #d6b66d; }
.approval-card h3 { margin: 0 0 8px; color: #ebe6d7; font-size: 13px; font-weight: 600; }
.approval-card .muted { margin: 4px 0 9px; font-size: 11px; }
.approval-command { overflow: auto; margin: 9px 0; padding: 9px; border-radius: 7px; color: #e5decb; background: #101112; font: 10px/1.6 var(--mono); white-space: pre-wrap; }
.approval-path { color: #929489; font: 10px var(--mono); }
.approval-actions { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 12px; }
.approval-actions .button { min-height: 33px; font-size: 10px; }
.approval-accept { min-height: 34px; font-size: 11px; }
.danger-text { color: var(--danger) !important; }
.question-field { margin: 10px 0; padding: 0; border: 0; }
.question-field legend { margin-bottom: 6px; color: #d8d8cd; font-size: 11px; }
.question-field input, .question-field select { width: 100%; height: 34px; padding: 0 9px; border: 1px solid #454438; border-radius: 7px; color: var(--text); background: #151613; font-size: 11px; }
.active-indicator { display: flex; align-items: center; gap: 8px; margin: 0 0 9px 39px; color: #9da69d; font-size: 11px; }
.text-button { padding: 4px 7px; border: 0; color: #a9b38d; background: transparent; font-size: 11px; cursor: pointer; }
.text-button:hover { color: var(--accent); }
.composer { position: sticky; bottom: 0; z-index: 4; display: flex; flex-direction: column; gap: 0; margin: auto 0 0 39px; padding: 12px 13px 7px; border: 1px solid #343839; border-radius: 15px; background: #1a1d1e; box-shadow: 0 9px 32px #0005; }
.composer:focus-within { border-color: #59664a; }
.composer textarea { width: 100%; min-height: 34px; max-height: 240px; resize: none; border: 0; outline: 0; color: var(--text); background: transparent; font-size: 13px; line-height: 1.55; }
.composer textarea::placeholder { color: #707777; }
.composer-bottom { display: flex; align-items: center; justify-content: space-between; padding-top: 8px; }
.composer-tools { display: flex; align-items: center; gap: 12px; }
.attach-button { display: inline-flex; align-items: center; gap: 5px; color: #aeb4b3; font-size: 11px; cursor: pointer; }
.attach-button:hover { color: var(--accent); }
.attach-button:first-letter { color: var(--accent); font-size: 16px; }
.composer-hint { color: #666d6d; font-size: 9px; }
.send-button { display: grid; width: 32px; height: 32px; place-items: center; border: 0; border-radius: 9px; color: var(--accent-ink); background: var(--accent); font-size: 20px; font-weight: 700; cursor: pointer; }
.send-button:disabled { color: #7a8174; background: #323630; opacity: 1; }
.send-button.stop-style { color: #f3d7d2; background: #74453f; font-size: 13px; }
.composer-footnote { margin: 6px 0 0; color: #626868; font-size: 9px; text-align: center; }
.composer-attachments { display: flex; flex-wrap: wrap; gap: 7px; padding: 0 0 8px; }
.attachment-chip { display: flex; align-items: center; gap: 6px; min-width: 0; max-width: 190px; padding: 4px 6px; border: 1px solid #363b3c; border-radius: 8px; color: #b6bdbc; background: #141617; font-size: 10px; }
.attachment-chip img { width: 28px; height: 28px; border-radius: 5px; object-fit: cover; }
.attachment-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attachment-chip button { display: grid; flex: 0 0 20px; width: 20px; height: 20px; place-items: center; border: 0; border-radius: 5px; color: #8c9291; background: transparent; cursor: pointer; }
.attachment-chip button:hover { color: var(--danger); }
.toast { position: fixed; z-index: 60; right: 24px; bottom: 22px; max-width: min(420px, calc(100vw - 30px)); padding: 11px 14px; border: 1px solid #3c4440; border-radius: 10px; color: #dbe6d6; background: #202722; box-shadow: 0 12px 40px #0008; font-size: 12px; }
.toast.error { border-color: #68453f; color: #f2c5be; background: #2b1f1d; }

.modal { width: min(430px, calc(100vw - 30px)); padding: 22px; border: 1px solid #363b3c; border-radius: 16px; color: var(--text); background: #191c1d; box-shadow: 0 25px 100px #000a; }
.modal::backdrop { background: #050606b8; backdrop-filter: blur(4px); }
.modal form { display: flex; flex-direction: column; gap: 11px; }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 6px; }
.modal-head .eyebrow { margin: 0 0 5px; }
.modal-head h2 { margin: 0; font-size: 19px; letter-spacing: -.03em; }
.modal label, .gate-form label { color: #adb3b0; font-size: 11px; }
.modal input, .gate-form input { width: 100%; height: 42px; padding: 0 12px; border: 1px solid #373c3d; border-radius: 9px; outline: 0; color: var(--text); background: #111314; font-size: 13px; }
.modal input:focus, .gate-form input:focus { border-color: #8ba66d; box-shadow: 0 0 0 3px #a9d27717; }
.modal .hint { margin: 0; }
.modal .button { margin-top: 5px; }

.gate-page { display: grid; min-height: 100vh; place-items: center; padding: 24px; background: radial-gradient(ellipse at 50% 12%,#1e241b 0,#101112 55%); }
.gate-card { width: min(410px, 100%); padding: 34px; border: 1px solid #303535; border-radius: 19px; background: #171a1b; box-shadow: 0 25px 100px #0005; }
.gate-card-wide { width: min(450px, 100%); }
.gate-card .brand-mark { margin-bottom: 21px; }
.gate-card .eyebrow { margin: 0 0 9px; }
.gate-card h1 { margin: 0; color: #edeeeb; font-size: 25px; font-weight: 500; letter-spacing: -.045em; }
.gate-card > .muted { margin: 7px 0 23px; font-size: 12px; }
.gate-form { display: flex; flex-direction: column; gap: 10px; }
.gate-form .button { width: 100%; margin-top: 6px; }
.form-error { min-height: 17px; margin: 0; color: #f2a297; font-size: 11px; }

@media (max-width: 760px) {
  .sidebar { transform: translateX(-102%); transition: transform .22s ease; box-shadow: 20px 0 50px #0007; }
  .sidebar.open { transform: translateX(0); }
  .sidebar-toggle, .mobile-menu { display: inline-grid; }
  .main-panel { width: 100%; margin-left: 0; }
  .topbar { height: 55px; gap: 7px; padding: 0 10px; }
  .breadcrumb { gap: 6px; font-size: 10px; }
  .top-actions { gap: 4px; }
  .model-picker { max-width: 112px; font-size: 10px; }
  .effort-picker { max-width: 92px; font-size: 10px; }
  #theme-indicator { display: none; }
  .workspace { min-height: calc(100vh - 55px); padding: 12px 12px 16px; }
  .conversation { min-height: calc(100vh - 75px); }
  .messages { gap: 14px; padding-top: 14px; }
  .message { gap: 8px; }
  .message.user { max-width: 94%; }
  .activity-card, .file-change-card, .pending-approvals, .active-indicator, .composer { margin-left: 34px; }
  .composer { padding: 10px 10px 6px; }
  .composer-hint { display: none; }
  .gate-card { padding: 26px 22px; }
}

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