:root {
  --bg: #f7f6f2;
  --sidebar: #eeede8;
  --panel: #ffffff;
  --panel-soft: #f3f2ed;
  --text: #171714;
  --muted: #7c7a72;
  --line: #deddd6;
  --line-strong: #c9c7bd;
  --accent: #1f1f1c;
  --accent-text: #ffffff;
  --green: #1e9b61;
  --red: #d64949;
  --amber: #a56b13;
  --blue: #3766b4;
  --shadow: 0 18px 50px rgba(26, 25, 21, .13);
  --radius: 18px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  overflow: hidden;
}
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { opacity: .45; cursor: default; }
pre, code { font-family: "SFMono-Regular", "Cascadia Code", Menlo, Consolas, monospace; }

.app-shell { display: flex; height: 100dvh; overflow: hidden; }
.sidebar {
  width: 300px;
  flex: 0 0 300px;
  display: flex;
  flex-direction: column;
  background: var(--sidebar);
  border-right: 1px solid var(--line);
  padding: 14px 12px 12px;
  min-height: 0;
}
.brand-row { display: flex; align-items: center; justify-content: space-between; padding: 2px 4px 12px; }
.brand { display: flex; align-items: center; gap: 9px; font-size: 17px; font-weight: 700; letter-spacing: -.2px; }
.brand-mark {
  width: 28px; height: 28px; border-radius: 9px;
  display: inline-flex; align-items: center; justify-content: center;
  background: #1b1b18; color: #fff; font-size: 14px; font-weight: 800;
}
.brand-pill {
  font-size: 10px; font-weight: 600; color: #66645d;
  border: 1px solid var(--line-strong); border-radius: 999px; padding: 3px 7px;
}
.icon-button {
  width: 34px; height: 34px; border-radius: 999px;
  border: 1px solid var(--line); background: rgba(255,255,255,.7);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 17px; line-height: 1; transition: background .15s, transform .15s;
}
.icon-button:hover { background: #fff; }
.icon-button:active { transform: scale(.96); }
.close-sidebar { display: none; }

.new-chat-button {
  width: 100%; border: 0; border-radius: 14px; background: var(--accent); color: var(--accent-text);
  display: flex; align-items: center; gap: 10px; padding: 11px 13px; font-weight: 650;
  box-shadow: 0 5px 16px rgba(20,20,17,.12); margin-bottom: 10px;
}
.new-chat-button:hover { background: #2a2a25; }
.new-chat-button .plus { font-size: 20px; line-height: 1; font-weight: 400; }
.search-box {
  display: flex; align-items: center; gap: 8px; height: 38px;
  border: 1px solid var(--line); border-radius: 12px; background: rgba(255,255,255,.72);
  padding: 0 11px; color: var(--muted); margin-bottom: 15px;
}
.search-box input { width: 100%; border: 0; outline: 0; background: transparent; font-size: 13px; }
.sidebar-section-title {
  display: flex; justify-content: space-between; align-items: center;
  padding: 0 5px 7px; color: var(--muted); font-size: 11px; font-weight: 700;
  letter-spacing: .6px; text-transform: uppercase;
}
.text-button { border: 0; background: transparent; color: var(--muted); font-size: 11px; padding: 2px; }
.text-button:hover { color: var(--text); }
.thread-list { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; min-height: 0; padding: 0 1px 8px; }
.project-list { display: flex; flex-direction: column; gap: 4px; max-height: 220px; overflow-y: auto; padding: 0 1px 9px; }
.project-item {
  border: 1px solid transparent; border-radius: 10px; background: transparent;
  display: flex; align-items: center; gap: 8px; width: 100%; padding: 7px 9px;
  text-align: left; color: #55534c; font-size: 11.5px;
}
.project-item:hover { background: rgba(255,255,255,.6); border-color: var(--line); }
.project-item { flex: 0 0 auto; }
.project-item.active { background: #fff; border-color: var(--line-strong); color: var(--text); font-weight: 650; }
.project-icon { width: 18px; height: 18px; border-radius: 6px; background: var(--panel-soft); display: inline-flex; align-items: center; justify-content: center; font-size: 10px; flex: 0 0 auto; }
.project-item-copy { min-width: 0; flex: 1; }
.project-item-name { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.project-item-path { display: block; color: var(--muted); font-size: 9.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 1px; }
.thread-item {
  border: 1px solid transparent; border-radius: 14px; background: rgba(255,255,255,.52);
  padding: 10px 11px; cursor: pointer; transition: background .15s, border-color .15s, transform .15s;
}
.thread-item:hover { background: #fff; border-color: var(--line); }
.thread-item.active { background: #fff; border-color: var(--line-strong); box-shadow: 0 4px 14px rgba(20,20,17,.06); }
.thread-item-title { display: flex; align-items: center; gap: 7px; font-size: 13px; font-weight: 650; }
.thread-item-title span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.thread-source-dot { width: 6px; height: 6px; border-radius: 50%; background: #aaa; flex: 0 0 auto; }
.thread-item.active .thread-source-dot { background: var(--green); }
.thread-item-preview { color: var(--muted); font-size: 11.5px; line-height: 1.45; margin-top: 4px; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.thread-item-meta { display: flex; justify-content: space-between; gap: 8px; color: #9a988f; font-size: 10.5px; margin-top: 6px; }
.thread-item-meta span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.thread-empty { color: var(--muted); text-align: center; padding: 28px 12px; font-size: 12px; line-height: 1.6; }
.sidebar-footer { border-top: 1px solid var(--line); padding-top: 10px; }
.connection-line { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 11.5px; padding: 2px 5px 8px; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--red); }
.status-dot.on { background: var(--green); }
.footer-actions { display: flex; gap: 7px; }
.soft-button {
  border: 1px solid var(--line); border-radius: 999px; background: rgba(255,255,255,.72);
  padding: 7px 12px; font-size: 12px; font-weight: 600; color: #4d4b45;
}
.soft-button:hover { background: #fff; border-color: var(--line-strong); }
.primary-button {
  border: 1px solid var(--accent); border-radius: 999px; background: var(--accent);
  color: var(--accent-text); padding: 8px 15px; font-size: 12.5px; font-weight: 650;
}
.primary-button:hover { background: #2b2b26; }
.full-width { width: 100%; padding: 10px 16px; }

.main-panel { flex: 1; min-width: 0; display: flex; flex-direction: column; position: relative; background: var(--bg); }
.topbar {
  min-height: 58px; display: flex; align-items: center; gap: 12px;
  padding: 9px 18px; border-bottom: 1px solid var(--line);
  background: rgba(247,246,242,.9); backdrop-filter: blur(14px); z-index: 4;
}
.menu-button { display: none; flex: 0 0 auto; }
.thread-heading { min-width: 0; flex: 1; }
.thread-heading h1 { font-size: 15px; line-height: 1.25; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.thread-meta { color: var(--muted); font-size: 11px; margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-actions { display: flex; align-items: center; gap: 7px; flex: 0 0 auto; }
.model-chip {
  border: 1px solid var(--line); border-radius: 999px; background: rgba(255,255,255,.68);
  color: #5b5952; padding: 5px 9px; font-size: 10.5px; max-width: 220px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.project-select {
  border: 1px solid var(--line); border-radius: 999px; background: rgba(255,255,255,.68);
  color: #5b5952; padding: 5px 8px; font-size: 10.5px; max-width: 150px; outline: none;
}

.conversation { flex: 1; overflow-y: auto; min-height: 0; scroll-behavior: smooth; }
.turn-list { width: min(860px, 100%); margin: 0 auto; padding: 22px 20px 130px; display: flex; flex-direction: column; gap: 16px; }
.empty-state { min-height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 48px 20px 120px; }
.empty-icon { width: 58px; height: 58px; border-radius: 19px; border: 1px solid var(--line); background: #fff; display: flex; align-items: center; justify-content: center; font-size: 27px; box-shadow: 0 12px 35px rgba(20,20,17,.08); }
.empty-state h2 { margin: 20px 0 7px; font-size: 20px; letter-spacing: -.4px; }
.empty-state p { margin: 0; color: var(--muted); max-width: 450px; line-height: 1.65; font-size: 12.5px; }
.empty-actions { display: flex; gap: 8px; margin-top: 18px; }
.recent-strip { display: flex; flex-wrap: wrap; justify-content: center; gap: 7px; margin-top: 25px; max-width: 660px; }
.recent-chip { border: 1px solid var(--line); background: rgba(255,255,255,.65); border-radius: 999px; padding: 6px 10px; font-size: 11px; color: #57554f; max-width: 210px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.recent-chip:hover { background: #fff; border-color: var(--line-strong); }

.turn { display: flex; flex-direction: column; gap: 10px; }
.turn + .turn { margin-top: 6px; }
.turn-divider { height: 1px; background: linear-gradient(90deg, transparent, var(--line), transparent); margin: 10px 0 6px; }
.message-row { display: flex; flex-direction: column; }
.message-row.user { align-items: flex-end; }
.message-row.assistant { align-items: flex-start; }
.message-bubble {
  max-width: min(780px, 92%); border: 1px solid var(--line); border-radius: 18px;
  padding: 11px 14px; background: var(--panel); line-height: 1.66; white-space: pre-wrap;
  overflow-wrap: anywhere; font-size: 13.5px;
}
.message-row.user .message-bubble { background: #1f1f1c; color: #fff; border-color: #1f1f1c; border-bottom-right-radius: 6px; }
.message-row.assistant .message-bubble { border-bottom-left-radius: 6px; box-shadow: 0 3px 14px rgba(20,20,17,.035); }
.message-label { color: var(--muted); font-size: 10.5px; margin: 0 5px 5px; }
.message-row.user .message-label { text-align: right; }
.message-bubble.streaming::after { content: "▍"; color: var(--muted); animation: blink 1s steps(2,end) infinite; }
@keyframes blink { 50% { opacity: 0; } }

.tool-card { border: 1px solid var(--line); border-radius: 15px; background: rgba(255,255,255,.76); overflow: hidden; max-width: min(820px, 96%); }
.tool-card-header { display: flex; align-items: center; gap: 8px; padding: 9px 12px; border-bottom: 1px solid var(--line); color: #5f5d56; font-size: 11.5px; font-weight: 650; }
.tool-icon { width: 21px; height: 21px; border-radius: 7px; background: var(--panel-soft); display: inline-flex; align-items: center; justify-content: center; font-size: 11px; }
.tool-status { margin-left: auto; font-size: 10px; color: var(--muted); font-weight: 500; }
.tool-status.completed { color: var(--green); }
.tool-status.failed { color: var(--red); }
.tool-card pre { margin: 0; padding: 10px 12px; background: #171714; color: #d7e7d5; font-size: 11px; line-height: 1.55; white-space: pre-wrap; overflow-wrap: anywhere; max-height: 330px; overflow-y: auto; }
.tool-card .tool-body { padding: 10px 12px; font-size: 12px; color: #56544e; line-height: 1.55; white-space: pre-wrap; overflow-wrap: anywhere; }
.tool-image { display: block; width: 100%; max-height: 560px; object-fit: contain; border-radius: 10px; background: #e9e8e2; }
.tool-card details { padding: 8px 12px 10px; }
.tool-card summary { cursor: pointer; color: var(--muted); font-size: 11px; }
.tool-card details pre { margin-top: 8px; border-radius: 10px; max-height: 260px; }
.plan-card { border-left: 3px solid #8b877c; background: #fff; }
.reasoning-card { opacity: .78; }
.reasoning-card .tool-body { font-size: 11.5px; color: #6c6a63; }
.diff-card .tool-body { font-family: "SFMono-Regular", Menlo, monospace; font-size: 11px; background: #f6f5f0; }

.composer-wrap { position: absolute; left: 0; right: 0; bottom: 0; padding: 12px 20px 10px; background: linear-gradient(to top, var(--bg) 72%, rgba(247,246,242,0)); z-index: 5; pointer-events: none; }
.composer { width: min(860px, 100%); margin: 0 auto; border: 1px solid var(--line-strong); border-radius: 20px; background: #fff; box-shadow: 0 12px 34px rgba(20,20,17,.09); padding: 11px 12px 8px; pointer-events: auto; }
.composer:focus-within { border-color: #9d9a90; box-shadow: 0 13px 38px rgba(20,20,17,.12); }
.composer textarea { width: 100%; min-height: 25px; max-height: 170px; resize: none; border: 0; outline: 0; background: transparent; line-height: 1.55; padding: 2px 4px 5px; font-size: 13.5px; }
.composer-bar { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.composer-context { display: flex; align-items: center; gap: 8px; min-width: 0; }
.context-chip { border: 1px solid var(--line); background: var(--panel-soft); color: #66635c; border-radius: 999px; padding: 4px 8px; font-size: 10.5px; max-width: 280px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.composer-select { border: 1px solid var(--line); background: var(--panel-soft); color: #5c5a53; border-radius: 999px; padding: 4px 7px; font-size: 10.5px; max-width: 190px; outline: none; }
.provider-select { max-width: 175px; }
.composer-select:disabled { opacity: .55; }
.composer-note { color: var(--muted); font-size: 10.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.composer-buttons { display: flex; gap: 6px; flex: 0 0 auto; }
.send-button { width: 32px; height: 32px; border-radius: 50%; border: 0; background: var(--accent); color: var(--accent-text); font-size: 18px; display: flex; align-items: center; justify-content: center; }
.stop-button { border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 5px 10px; font-size: 11px; }
.composer-hint { width: min(860px, 100%); margin: 5px auto 0; text-align: center; color: #a19f96; font-size: 9.5px; pointer-events: none; }

.modal-backdrop, .drawer-backdrop {
  position: fixed; inset: 0; background: rgba(23,23,20,.3); backdrop-filter: blur(3px);
  display: none; align-items: center; justify-content: center; padding: 18px; z-index: 50;
}
.modal-backdrop.show, .drawer-backdrop.show { display: flex; }
.modal { width: min(470px, 100%); border: 1px solid var(--line); border-radius: 22px; background: #fff; padding: 22px; box-shadow: var(--shadow); }
.login-modal { max-width: 420px; }
.modal-brand { display: flex; align-items: center; gap: 9px; font-weight: 700; margin-bottom: 18px; }
.modal h2 { margin: 0 0 7px; font-size: 19px; letter-spacing: -.35px; }
.muted { color: var(--muted); line-height: 1.6; font-size: 12px; }
.field-label { display: block; font-size: 11px; font-weight: 650; margin: 16px 0 6px; color: #5e5c55; }
.field { width: 100%; border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; outline: 0; background: #fbfbf8; }
.field:focus { border-color: #8e8b81; background: #fff; }
.form-error { color: var(--red); font-size: 11px; min-height: 17px; margin: 6px 0 8px; }
.modal-kicker { color: var(--muted); font-size: 10px; text-transform: uppercase; letter-spacing: .8px; font-weight: 700; margin-bottom: 8px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 7px; margin-top: 18px; flex-wrap: wrap; }
.approval-modal { max-width: 620px; }
.approval-code { margin: 12px 0 0; border-radius: 12px; background: #171714; color: #dce8d9; padding: 12px; max-height: 310px; overflow: auto; font-size: 11px; line-height: 1.5; white-space: pre-wrap; overflow-wrap: anywhere; }

.drawer-backdrop { justify-content: flex-end; padding: 0; align-items: stretch; }
.drawer { width: min(430px, 100%); height: 100%; background: var(--bg); border-left: 1px solid var(--line); box-shadow: -20px 0 50px rgba(20,20,17,.12); display: flex; flex-direction: column; animation: slideIn .18s ease-out; }
.wide-drawer { width: min(560px, 100%); }
@keyframes slideIn { from { transform: translateX(20px); opacity: .5; } to { transform: translateX(0); opacity: 1; } }
.drawer-header { display: flex; justify-content: space-between; gap: 12px; padding: 18px 18px 14px; border-bottom: 1px solid var(--line); background: rgba(255,255,255,.55); }
.drawer-header h2 { margin: 0 0 3px; font-size: 17px; }
.drawer-content { padding: 16px; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; }
.info-card { border: 1px solid var(--line); border-radius: 15px; background: #fff; padding: 13px 14px; }
.info-card h3 { margin: 0 0 9px; font-size: 12px; }
.kv-row { display: flex; justify-content: space-between; gap: 15px; padding: 6px 0; border-top: 1px solid #efeee9; font-size: 11.5px; }
.kv-row:first-of-type { border-top: 0; }
.kv-row span:first-child { color: var(--muted); flex: 0 0 auto; }
.kv-row span:last-child { text-align: right; overflow-wrap: anywhere; }
.plugin-row { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-top: 1px solid #efeee9; }
.plugin-row:first-child { border-top: 0; }
.plugin-badge { width: 28px; height: 28px; border-radius: 9px; background: var(--panel-soft); display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; flex: 0 0 auto; }
.plugin-copy { min-width: 0; flex: 1; }
.plugin-name { font-size: 12px; font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.plugin-desc { color: var(--muted); font-size: 10.5px; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.enabled-pill { border-radius: 999px; padding: 3px 7px; background: #e7f5ed; color: #167746; font-size: 9.5px; font-weight: 650; }
.disabled-pill { border-radius: 999px; padding: 3px 7px; background: #f0efea; color: #7b7971; font-size: 9.5px; }
.question-block { border: 1px solid var(--line); border-radius: 13px; padding: 12px; margin-bottom: 9px; }
.question-block h3 { margin: 0 0 4px; font-size: 13px; }
.question-block p { margin: 0 0 8px; color: var(--muted); font-size: 11.5px; line-height: 1.5; }
.option-list { display: flex; flex-direction: column; gap: 6px; }
.option-label { display: flex; gap: 8px; border: 1px solid var(--line); border-radius: 10px; padding: 8px; font-size: 11.5px; }
.question-input { width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 8px 9px; outline: 0; }

.toast { position: fixed; left: 50%; bottom: 96px; transform: translate(-50%, 20px); opacity: 0; background: #1f1f1c; color: #fff; border-radius: 999px; padding: 8px 14px; font-size: 11.5px; z-index: 100; pointer-events: none; transition: .2s; max-width: 80vw; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: #9e3434; }

.working-indicator { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 11px; padding: 3px 5px; }
.working-dots { display: inline-flex; gap: 3px; }
.working-dots span { width: 4px; height: 4px; border-radius: 50%; background: #8f8c82; animation: dotPulse 1.2s infinite; }
.working-dots span:nth-child(2) { animation-delay: .15s; }
.working-dots span:nth-child(3) { animation-delay: .3s; }
@keyframes dotPulse { 0%, 60%, 100% { opacity: .25; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-2px); } }

@media (max-width: 840px) {
  .sidebar { position: fixed; inset: 0 auto 0 0; z-index: 30; transform: translateX(-102%); transition: transform .2s ease; box-shadow: 18px 0 45px rgba(20,20,17,.16); }
  .sidebar.open { transform: translateX(0); }
  .close-sidebar, .menu-button { display: inline-flex; }
  .topbar { padding: 8px 12px; }
  .turn-list { padding: 16px 12px 128px; }
  .composer-wrap { padding: 10px 10px 7px; }
  .model-chip { display: none; }
  .message-bubble { max-width: 96%; }
  .tool-card { max-width: 100%; }
  .empty-state { padding: 34px 16px 120px; }
  .composer-hint { display: none; }
  .composer-context { flex-wrap: wrap; }
  .composer-select { max-width: 145px; }
  .drawer { width: 100%; }
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #171714;
    --sidebar: #1e1e1a;
    --panel: #24241f;
    --panel-soft: #2b2b25;
    --text: #efeee8;
    --muted: #aaa79d;
    --line: #34342d;
    --line-strong: #48483f;
    --accent: #efeee8;
    --accent-text: #171714;
    --shadow: 0 18px 50px rgba(0,0,0,.35);
  }
  body { background: var(--bg); }
  .topbar { background: rgba(23,23,20,.9); }
  .thread-item { background: rgba(255,255,255,.025); }
  .thread-item:hover, .thread-item.active, .project-item.active { background: #24241f; }
  .project-item:hover { background: rgba(255,255,255,.04); }
  .search-box, .model-chip, .soft-button, .icon-button { background: rgba(255,255,255,.035); }
  .icon-button:hover, .soft-button:hover { background: #2b2b25; }
  .composer, .modal, .drawer, .info-card { background: #20201c; }
  .drawer-header { background: rgba(32,32,28,.88); }
  .field, .question-input { background: #191916; }
  .message-row.assistant .message-bubble { background: #24241f; }
  .message-row.user .message-bubble { background: #efeee8; color: #171714; border-color: #efeee8; }
  .tool-card { background: rgba(255,255,255,.035); }
  .tool-card pre { background: #0f0f0d; }
  .enabled-pill { background: #173b2a; color: #86d9ab; }
  .disabled-pill { background: #2c2c27; color: #aaa79d; }
  .context-chip { background: #292923; }
  .composer-wrap { background: linear-gradient(to top, var(--bg) 72%, rgba(23,23,20,0)); }
  .empty-icon { background: #24241f; }
  .recent-chip { background: rgba(255,255,255,.035); }
  .recent-chip:hover { background: #292923; }
  .kv-row, .plugin-row { border-color: #303029; }
}

/* Codex Remote 2.0 */
.version-badge {
  border-radius: 999px; background: #1f1f1c; color: #fff; padding: 2px 6px;
  font-size: 9px; font-weight: 700; letter-spacing: .2px;
}
.section-actions { display: inline-flex; align-items: center; gap: 7px; }
.section-actions .text-button.active { color: var(--text); font-weight: 700; }

.thread-item { padding: 0; display: flex; align-items: stretch; overflow: hidden; flex: 0 0 auto; min-height: 72px; }
.thread-main {
  min-width: 0; flex: 1; border: 0; background: transparent; text-align: left;
  padding: 10px 5px 10px 11px; cursor: pointer;
}
.thread-menu-trigger {
  flex: 0 0 31px; border: 0; background: transparent; color: var(--muted);
  font-size: 17px; opacity: 0; transition: opacity .15s, background .15s;
}
.thread-item:hover .thread-menu-trigger, .thread-menu-trigger:focus-visible { opacity: 1; }
.thread-menu-trigger:hover { background: var(--panel-soft); color: var(--text); }
.thread-pin { color: var(--amber); font-size: 10px; }
.context-menu {
  position: fixed; z-index: 80; min-width: 178px; padding: 6px;
  border: 1px solid var(--line-strong); border-radius: 13px; background: var(--panel);
  box-shadow: var(--shadow);
}
.context-menu button {
  width: 100%; border: 0; background: transparent; border-radius: 9px; text-align: left;
  padding: 8px 10px; font-size: 12px;
}
.context-menu button:hover { background: var(--panel-soft); }
.context-menu button.danger { color: var(--red); }
.context-menu hr { border: 0; border-top: 1px solid var(--line); margin: 5px 3px; }

.composer-tool {
  width: 28px; height: 28px; border: 1px solid var(--line); border-radius: 50%;
  background: var(--panel-soft); color: #5c5a53; font-size: 15px; line-height: 1;
  display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto;
}
.composer-tool:hover { background: #fff; border-color: var(--line-strong); }
.attach-tool { width: auto; padding: 0 9px; border-radius: 999px; gap: 4px; }
.attach-tool .tool-label { font-size: 10.5px; font-weight: 650; }
.mode-select { max-width: 84px; }
.attachment-tray, .queue-tray {
  display: flex; flex-wrap: wrap; gap: 6px; margin: 0 2px 8px;
}
.attachment-chip, .queue-chip {
  display: inline-flex; align-items: center; gap: 6px; max-width: 100%;
  border: 1px solid var(--line); border-radius: 11px; background: var(--panel-soft);
  padding: 5px 7px; font-size: 10.5px; color: #5d5b54;
}
.attachment-chip img { width: 30px; height: 30px; border-radius: 7px; object-fit: cover; }
.attachment-chip-name, .queue-chip-text { max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip-remove, .queue-chip button { border: 0; background: transparent; color: var(--muted); padding: 0 2px; }
.queue-tray { border-top: 1px dashed var(--line); padding-top: 7px; }
.queue-tray:empty { display: none; }
.queue-chip { background: #fff8e8; border-color: #ead6a7; }
.queue-chip-label { color: var(--amber); font-weight: 700; }
.queue-chip button:hover, .chip-remove:hover { color: var(--red); }
.composer-suggestions {
  position: absolute; left: 12px; right: 12px; bottom: calc(100% + 7px); z-index: 12;
  border: 1px solid var(--line-strong); border-radius: 14px; background: var(--panel);
  box-shadow: var(--shadow); overflow: hidden; max-height: 260px; overflow-y: auto;
}
.composer-suggestions button {
  width: 100%; border: 0; border-top: 1px solid var(--line); background: transparent;
  text-align: left; padding: 9px 11px; display: flex; justify-content: space-between; gap: 12px;
}
.composer-suggestions button:first-child { border-top: 0; }
.composer-suggestions button:hover { background: var(--panel-soft); }
.suggestion-name { font-weight: 650; font-size: 11.5px; }
.suggestion-meta { color: var(--muted); font-size: 10px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.provider-gate-modal { max-width: 640px; }
.provider-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-top: 15px; max-height: 320px; overflow-y: auto; }
.provider-card {
  border: 1px solid var(--line); border-radius: 13px; background: var(--panel-soft);
  padding: 10px; text-align: left; min-width: 0;
}
.provider-card:hover { border-color: var(--line-strong); background: #fff; }
.provider-card.selected { border-color: var(--accent); box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 12%, transparent); }
.provider-card.disabled { opacity: .58; }
.provider-card-name { font-size: 12px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.provider-card-meta { margin-top: 4px; color: var(--muted); font-size: 10px; line-height: 1.45; }

.message-media { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 7px; }
.message-media img { max-width: min(420px, 100%); max-height: 330px; border-radius: 11px; object-fit: contain; background: rgba(0,0,0,.08); }
.message-ref { display: inline-flex; margin: 3px 4px 0 0; border: 1px solid currentColor; border-radius: 999px; padding: 2px 7px; font-size: 10.5px; opacity: .75; }
.error-card { border-color: #e6bcbc; background: #fff6f6; }
.error-card .tool-card-header { color: var(--red); }
.error-card .tool-body { color: #7b3333; }
.turn-status { color: var(--muted); font-size: 10.5px; padding: 3px 5px; }
.turn-status.failed, .turn-status.interrupted { color: var(--red); }

@media (max-width: 840px) {
  .provider-grid { grid-template-columns: 1fr; }
  .thread-menu-trigger { opacity: 1; }
  .composer-context { gap: 5px; }
  .mode-select { max-width: 72px; }
  .composer-tool { width: 27px; height: 27px; }
}
.composer { position: relative; }
.composer.dragging { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(55,102,180,.13); }
.danger-button { background: var(--red); border-color: var(--red); }
.danger-button:hover { background: #b93838; }
@media (max-width: 840px) {
  .attach-tool { width: auto; }
}

.studio-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}
