:root {
  color-scheme: dark;
  --bg: #0a0b0f;
  --panel: #101116;
  --panel-2: #17181f;
  --panel-3: #20212a;
  --line: rgba(255, 255, 255, .075);
  --line-strong: rgba(255, 255, 255, .14);
  --text: #f3f3f5;
  --muted: #9b9da7;
  --muted-2: #6d707a;
  --accent: #7c5cff;
  --accent-bright: #927cff;
  --accent-soft: rgba(124, 102, 255, .14);
  --green: #4ed7a8;
  --danger: #ff6b7d;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  overflow: hidden;
  background:
    radial-gradient(circle at 69% 28%, rgba(82, 63, 196, .09), transparent 33%),
    radial-gradient(circle at 100% 0%, rgba(44, 72, 139, .08), transparent 27%),
    var(--bg);
  color: var(--text);
}

button, textarea, input, select { font: inherit; }
button { color: inherit; }

.app-shell {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  height: 100%;
  min-height: 0;
}

.auth-pending .app-shell { visibility: hidden; }

.sidebar {
  position: relative;
  z-index: 20;
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 20px 16px 14px;
  border-right: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(17, 18, 24, .97), rgba(13, 14, 18, .97));
  backdrop-filter: blur(24px);
}

.brand-row {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 2px 3px 22px;
}

.brand-mark, .welcome-orb {
  display: grid;
  place-items: center;
  background: linear-gradient(145deg, #8e79ff, #5941de 70%, #35259c);
  box-shadow: inset 0 1px 1px rgba(255,255,255,.35), 0 8px 24px rgba(88, 61, 225, .25);
}

.brand-mark {
  width: 35px;
  height: 35px;
  border-radius: 11px;
  font-weight: 750;
  letter-spacing: -.04em;
}

.brand-name { font-size: 15px; font-weight: 700; letter-spacing: .01em; }
.brand-caption { margin-top: 2px; color: var(--muted-2); font-size: 11px; }

.icon-button {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.icon-button:hover { border-color: var(--line); background: var(--panel-2); color: var(--text); }
.brand-row .icon-button { margin-left: auto; }

.new-chat {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  min-height: 46px;
  padding: 10px 13px;
  border: 1px solid rgba(162, 143, 255, .62);
  border-radius: 12px;
  background: linear-gradient(135deg, #7554f6, #6542e3);
  box-shadow: inset 0 1px rgba(255,255,255,.16), 0 10px 25px rgba(75, 48, 190, .18);
  color: white;
  font-size: 13px;
  font-weight: 650;
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease;
}

.new-chat:hover { background: linear-gradient(135deg, #8265fa, #7050e9); border-color: rgba(188,174,255,.76); transform: translateY(-1px); }
.new-chat > span { font-size: 20px; font-weight: 300; line-height: 1; }
.new-chat kbd {
  margin-left: auto;
  padding: 2px 5px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: rgba(18,10,61,.2);
  color: rgba(255,255,255,.78);
  font-size: 10px;
}

.conversation-search {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 9px;
  min-height: 42px;
  margin-top: 12px;
  padding: 0 11px;
  border: 1px solid var(--line-strong);
  border-radius: 11px;
  background: rgba(255,255,255,.018);
  color: var(--muted-2);
  transition: border-color .15s ease, background .15s ease, box-shadow .15s ease;
}
.conversation-search:focus-within { border-color: rgba(124,92,255,.55); background: rgba(255,255,255,.028); box-shadow: 0 0 0 3px rgba(124,92,255,.07); }
.conversation-search > span { font-size: 20px; line-height: 1; transform: rotate(-18deg); }
.conversation-search input { min-width: 0; border: 0; outline: 0; background: transparent; color: var(--text); font-size: 11px; }
.conversation-search input::placeholder { color: var(--muted-2); }
.conversation-search input::-webkit-search-cancel-button { filter: invert(.6); }
.conversation-search kbd { padding: 2px 5px; border: 1px solid var(--line); border-radius: 5px; background: rgba(0,0,0,.16); color: var(--muted-2); font-size: 9px; }

.knowledge-button {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  margin-top: 5px;
  padding: 9px 10px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: #c3c4ca;
  font-size: 12px;
  cursor: pointer;
}
.knowledge-button:hover { background: rgba(255,255,255,.055); color: var(--text); }
.knowledge-button > span { color: #aa9cff; font-size: 16px; }
.knowledge-button small { margin-left: auto; color: var(--muted-2); font-size: 9px; }

.section-heading { display: flex; align-items: center; padding: 22px 4px 7px 9px; }
.section-label {
  padding: 0;
  color: var(--muted-2);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
}
.conversation-filter { margin-left: auto; width: 28px; height: 28px; border: 0; border-radius: 7px; background: transparent; color: var(--muted-2); cursor: pointer; }
.conversation-filter:hover, .conversation-filter[aria-pressed="true"] { background: rgba(255,255,255,.055); color: #c8c1ff; }

.conversation-list { min-height: 76px; overflow-y: auto; scrollbar-width: thin; }
.conversation-empty { padding: 22px 12px; color: var(--muted-2); font-size: 10px; line-height: 1.7; text-align: center; }

.conversation-item {
  position: relative;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  width: 100%;
  margin: 2px 0;
  min-height: 42px;
  padding: 6px 6px 6px 10px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: #c3c4ca;
  cursor: pointer;
  text-align: left;
}

.conversation-item:hover, .conversation-item.active { background: rgba(255,255,255,.055); color: var(--text); }
.conversation-item.active::before {
  content: "";
  position: absolute;
  left: 0;
  width: 2px;
  height: 16px;
  border-radius: 2px;
  background: var(--accent);
}
.conversation-item .conversation-status { width: 6px; height: 6px; border-radius: 50%; background: #4a4c57; box-shadow: none; }
.conversation-item.active .conversation-status, .conversation-item.has-messages .conversation-status { background: var(--green); box-shadow: 0 0 9px rgba(78,215,168,.32); }
.conversation-main { min-width: 0; }
.conversation-main span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conversation-main .item-title { font-size: 11px; font-weight: 540; }
.conversation-main .item-meta { margin-top: 3px; color: var(--muted-2); font-size: 8px; }
.conversation-item.pinned .item-title::before { content: "置顶 · "; color: #a99cff; font-size: 8px; font-weight: 650; }
.conversation-more {
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: transparent;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
}
.conversation-item:hover .conversation-more, .conversation-item.active .conversation-more { color: var(--muted-2); }
.conversation-more:hover, .conversation-more[aria-expanded="true"] { background: rgba(255,255,255,.075); color: var(--text) !important; }

.sidebar-footer { position: relative; margin-top: auto; padding-top: 12px; border-top: 1px solid var(--line); }
.runtime-card { display: flex; align-items: center; gap: 9px; padding: 10px 11px; border: 1px solid var(--line); border-radius: 10px; background: rgba(255,255,255,.014); }
.runtime-card > div { min-width: 0; }
.runtime-card strong, .runtime-card span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.runtime-card strong { font-size: 11px; font-weight: 600; }
.runtime-card div span { margin-top: 3px; color: var(--muted-2); font-size: 10px; }
.status-dot, .live-dot { display: inline-block; border-radius: 50%; background: var(--green); box-shadow: 0 0 9px rgba(78,215,168,.5); }
.status-dot { flex: 0 0 auto; width: 7px; height: 7px; }
.status-dot.offline { background: var(--danger); box-shadow: none; }
.roadmap-mini { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 8px; padding: 12px 8px 2px; color: var(--muted-2); font-size: 9px; }
.roadmap-mini div { height: 2px; overflow: hidden; border-radius: 2px; background: var(--panel-3); }
.roadmap-mini i { display: block; width: 55%; height: 100%; background: var(--accent); }

.main-panel {
  display: grid;
  grid-template-rows: 72px minmax(0, 1fr) auto;
  min-width: 0;
  min-height: 0;
  height: 100%;
}
.topbar {
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 24px;
  border-bottom: 1px solid var(--line);
  background: rgba(11,12,15,.68);
  backdrop-filter: blur(20px);
}
.conversation-heading { min-width: 0; margin-right: auto; }
.conversation-heading strong, .conversation-heading > span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conversation-heading strong { font-size: 13px; font-weight: 620; }
.conversation-heading > span { margin-top: 4px; color: var(--muted-2); font-size: 9px; letter-spacing: .05em; text-transform: uppercase; }
.conversation-title-row { display: flex; align-items: center; gap: 6px; min-width: 0; }
.conversation-title-row[hidden] { display: none; }
.conversation-title-row strong { max-width: min(420px, 42vw); outline: 0; }
.conversation-title-row strong:focus-visible { border-radius: 4px; box-shadow: 0 0 0 3px rgba(124,92,255,.16); }
.title-edit-button { width: 25px; height: 25px; border: 1px solid transparent; border-radius: 7px; background: transparent; color: var(--muted-2); cursor: pointer; opacity: .72; }
.conversation-title-row:hover .title-edit-button, .title-edit-button:focus-visible { border-color: var(--line); background: rgba(255,255,255,.04); color: var(--text); opacity: 1; }
.conversation-rename-form { display: flex; align-items: center; gap: 4px; margin-bottom: 1px; }
.conversation-rename-form[hidden] { display: none; }
.conversation-rename-form input { width: min(360px, 40vw); height: 30px; padding: 0 9px; border: 1px solid rgba(124,92,255,.58); border-radius: 7px; outline: 0; background: rgba(255,255,255,.045); color: var(--text); font-size: 12px; box-shadow: 0 0 0 3px rgba(124,92,255,.08); }
.conversation-rename-form button { width: 27px; height: 27px; border: 0; border-radius: 7px; background: transparent; color: var(--muted); cursor: pointer; }
.conversation-rename-form button:hover { background: rgba(255,255,255,.055); color: var(--text); }
.live-dot { width: 4px; height: 4px; margin-right: 4px; vertical-align: 1px; }
.model-picker { display: flex; align-items: center; gap: 7px; color: var(--muted-2); font-size: 9px; }
.model-picker select { max-width: 190px; padding: 6px 28px 6px 9px; border: 1px solid var(--line); border-radius: 8px; outline: 0; background: var(--panel-2); color: var(--text); font: inherit; cursor: pointer; }
.model-picker select:focus { border-color: rgba(124,102,255,.55); }
.model-picker select:disabled { cursor: default; opacity: .72; }

.chat-scroll {
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  scroll-behavior: smooth;
  scrollbar-width: thin;
}
.chat-scroll.streaming { scroll-behavior: auto; }
.chat-column { width: min(900px, calc(100% - 40px)); min-height: 100%; margin: 0 auto; padding: 50px 0 44px; }

.welcome { padding-top: min(6vh, 64px); text-align: center; animation: fade-up .35s ease both; }
.welcome-orb {
  width: 64px;
  height: 64px;
  margin: 0 auto 24px;
  border-radius: 21px;
  transform: rotate(-7deg);
}
.welcome-orb span { transform: rotate(7deg); font-size: 26px; font-weight: 760; }
.welcome h1 { margin: 0; font-size: clamp(25px, 4vw, 36px); font-weight: 650; letter-spacing: -.04em; }
.welcome > p { max-width: 560px; margin: 14px auto 34px; color: var(--muted); font-size: 13px; line-height: 1.8; }
.suggestion-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; text-align: left; }
.suggestion {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 13px;
  min-height: 108px;
  padding: 18px 20px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: rgba(255,255,255,.025);
  cursor: pointer;
  transition: transform .18s ease, background .18s ease, border-color .18s ease;
}
.suggestion:first-child { border-color: rgba(124,92,255,.48); box-shadow: inset 0 0 28px rgba(124,92,255,.05), 0 0 0 1px rgba(124,92,255,.05); }
.suggestion:hover { transform: translateY(-2px); background: rgba(255,255,255,.045); border-color: rgba(124,92,255,.52); box-shadow: 0 14px 32px rgba(0,0,0,.18), 0 0 25px rgba(124,92,255,.06); }
.suggestion strong, .suggestion small { display: block; }
.suggestion strong { font-size: 12px; }
.suggestion small { margin-top: 5px; color: var(--muted-2); font-size: 10px; }
.suggestion-icon { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 11px; font-size: 17px; }
.suggestion-icon.purple { color: #aa9cff; background: rgba(124,102,255,.13); }
.suggestion-icon.blue { color: #78b8ff; background: rgba(65,145,255,.13); }
.suggestion-icon.green { color: #63dcb4; background: rgba(61,205,158,.13); }
.suggestion-icon.amber { color: #f0b768; background: rgba(230,151,54,.13); }
.suggestion-arrow { color: var(--muted); font-size: 20px; transition: transform .16s ease, color .16s ease; }
.suggestion:hover .suggestion-arrow { color: #c9c1ff; transform: translateX(3px); }

.message { display: grid; grid-template-columns: 32px minmax(0, 1fr); gap: 13px; margin-bottom: 32px; animation: fade-up .22s ease both; }
.message.user { grid-template-columns: minmax(0, 1fr); justify-items: end; }
.avatar {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: linear-gradient(145deg, #7663e6, #4936b7);
  font-size: 11px;
  font-weight: 700;
}
.message-content { min-width: 0; }
.message-meta { margin: 1px 0 8px; color: var(--muted-2); font-size: 10px; }
.message.user .message-content { max-width: min(650px, 88%); }
.message.user .message-meta { text-align: right; }
.bubble { font-size: 14px; line-height: 1.8; overflow-wrap: anywhere; }
.message.user .bubble { padding: 10px 15px; border: 1px solid var(--line); border-radius: 17px 17px 4px 17px; background: var(--panel-3); }
.bubble p { margin: 0 0 10px; }
.bubble p:last-child { margin-bottom: 0; }
.bubble h1, .bubble h2, .bubble h3, .bubble h4, .bubble h5, .bubble h6 { margin: 18px 0 8px; color: #f0f0f4; line-height: 1.4; }
.bubble h1:first-child, .bubble h2:first-child, .bubble h3:first-child { margin-top: 0; }
.bubble h1 { font-size: 1.35em; }
.bubble h2 { font-size: 1.22em; }
.bubble h3 { font-size: 1.1em; }
.bubble h4, .bubble h5, .bubble h6 { font-size: 1em; }
.bubble strong { color: #f0f0f4; font-weight: 680; }
.bubble ul, .bubble ol { margin: 8px 0 12px; padding-left: 24px; }
.bubble li { margin: 4px 0; padding-left: 2px; }
.bubble blockquote { margin: 12px 0; padding: 8px 12px; border-left: 3px solid rgba(124,102,255,.65); background: rgba(124,102,255,.055); color: var(--muted); }
.bubble hr { height: 1px; margin: 16px 0; border: 0; background: var(--line); }
.bubble del { color: var(--muted-2); }
.bubble code { padding: 2px 5px; border: 1px solid var(--line); border-radius: 5px; background: rgba(0,0,0,.25); color: #d7d0ff; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .88em; }
.bubble pre { margin: 12px 0; padding: 14px; overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; background: #08090b; }
.bubble pre code { padding: 0; border: 0; background: none; color: #d8dae0; }
.cursor { display: inline-block; width: 6px; height: 15px; margin-left: 2px; border-radius: 2px; background: var(--accent); animation: blink .8s steps(2) infinite; vertical-align: -2px; }
.message-feedback { display: flex; align-items: center; gap: 6px; margin-top: 9px; color: var(--muted-2); font-size: 10px; }
.message-feedback button { padding: 4px 8px; border: 1px solid var(--line); border-radius: 8px; background: transparent; color: var(--muted-2); font: inherit; cursor: pointer; }
.message-feedback button:hover, .message-feedback button.active { border-color: rgba(124,102,255,.55); background: rgba(124,102,255,.1); color: #d7d0ff; }
.message-feedback button:disabled { opacity: .5; cursor: wait; }
.message-feedback span { max-width: 360px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.trace-list { display: grid; gap: 7px; margin: 0 0 14px; }
.trace-item { overflow: hidden; border: 1px solid var(--line); border-radius: 11px; background: rgba(255,255,255,.02); }
.trace-item summary { display: flex; align-items: center; gap: 8px; padding: 9px 11px; color: #c4c5cc; font-size: 11px; cursor: pointer; list-style: none; }
.trace-item summary::-webkit-details-marker { display: none; }
.trace-item summary::before { content: "⌁"; color: var(--accent); font-size: 14px; }
.trace-item.done summary::before { content: "✓"; color: var(--green); }
.trace-item summary span { margin-left: auto; color: var(--muted-2); font-size: 9px; }
.trace-body { padding: 9px 11px 11px; border-top: 1px solid var(--line); color: var(--muted); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 10px; line-height: 1.6; white-space: pre-wrap; }
.approval-slot:empty { display: none; }
.approval-card { margin: 0 0 14px; padding: 13px 14px; border: 1px solid rgba(255,190,92,.3); border-radius: 12px; background: rgba(255,174,68,.07); }
.approval-card strong, .approval-card p, .approval-card small { display: block; }
.approval-card strong { color: #f0d29e; font-size: 12px; }
.approval-card p { margin: 6px 0 0; color: var(--muted); font-size: 10px; line-height: 1.6; }
.approval-card small { margin-top: 7px; color: var(--muted-2); font-size: 9px; }
.approval-card.approved { border-color: rgba(75,211,159,.28); background: rgba(75,211,159,.06); }
.approval-card.approved strong { color: var(--green); }
.approval-card.rejected, .approval-card.expired { border-color: rgba(255,107,125,.25); background: rgba(255,107,125,.06); }
.approval-card.rejected strong, .approval-card.expired strong { color: var(--danger); }
.approval-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 11px; }
.approval-actions button { padding: 7px 11px; border: 0; border-radius: 8px; background: var(--accent); color: white; font-size: 10px; cursor: pointer; }
.approval-actions button.secondary { border: 1px solid var(--line-strong); background: transparent; color: var(--muted); }
.approval-actions button:disabled { opacity: .5; cursor: wait; }

.composer-wrap { z-index: 6; padding: 12px max(20px, calc((100% - 900px) / 2)) 13px; background: linear-gradient(transparent, var(--bg) 28%); }
.composer { position: relative; padding: 13px 14px 10px 16px; border: 1px solid var(--line-strong); border-radius: 18px; background: rgba(27,28,35,.96); box-shadow: 0 16px 50px rgba(0,0,0,.25); transition: border-color .15s ease, box-shadow .15s ease; }
.composer:focus-within { border-color: rgba(124,102,255,.48); box-shadow: 0 16px 55px rgba(0,0,0,.3), 0 0 0 3px rgba(124,102,255,.07); }
.composer textarea { display: block; width: 100%; max-height: 180px; padding: 2px 2px 9px; resize: none; border: 0; outline: 0; background: transparent; color: var(--text); font-size: 13px; line-height: 1.55; }
.composer textarea::placeholder { color: #70727b; }
.composer-bottom { display: flex; align-items: center; gap: 12px; }
.composer-actions { display: flex; align-items: center; gap: 5px; }
.composer-actions button { display: grid; place-items: center; width: 30px; height: 30px; padding: 0; border: 1px solid var(--line); border-radius: 8px; background: rgba(0,0,0,.1); color: var(--muted); cursor: pointer; }
.composer-actions button:hover, .composer-actions button[aria-expanded="true"] { border-color: rgba(124,92,255,.38); background: var(--accent-soft); color: #d0c9ff; }
.composer-meta { display: flex; align-items: center; gap: 12px; margin-right: auto; color: var(--muted-2); font-size: 9px; }
.tool-badge { color: #aaa2da; }
.tool-badge i { display: inline-block; width: 5px; height: 5px; margin-right: 4px; border-radius: 50%; background: var(--accent); }
.send-button { display: grid; place-items: center; flex: 0 0 auto; width: 38px; height: 38px; border: 0; border-radius: 12px; background: linear-gradient(145deg, var(--accent-bright), #6441df); box-shadow: 0 8px 20px rgba(86,54,213,.3); color: white; font-size: 18px; font-weight: 650; cursor: pointer; transition: transform .14s ease, opacity .14s ease; }
.send-button:hover { transform: translateY(-1px); }
.send-button:disabled { opacity: .28; cursor: default; transform: none; }
.send-button.running { background: #f0ecff; }
.send-button.running span { width: 9px; height: 9px; border-radius: 2px; background: #2d254f; font-size: 0; }
.disclaimer { margin: 8px 0 0; color: #5f616a; font-size: 9px; text-align: center; }

.tool-menu { position: absolute; z-index: 20; left: 12px; bottom: 58px; display: grid; width: 260px; padding: 8px; border: 1px solid var(--line-strong); border-radius: 13px; background: rgba(27,28,35,.98); box-shadow: 0 20px 55px rgba(0,0,0,.42); }
.tool-menu[hidden] { display: none; }
.tool-menu > span { padding: 5px 7px 8px; color: var(--muted-2); font-size: 9px; font-weight: 650; letter-spacing: .08em; }
.tool-menu button { display: grid; grid-template-columns: 28px minmax(0, 1fr); align-items: center; gap: 9px; padding: 8px; border: 0; border-radius: 9px; background: transparent; color: var(--text); text-align: left; cursor: pointer; }
.tool-menu button:hover { background: rgba(255,255,255,.055); }
.tool-menu button b { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 8px; background: var(--accent-soft); color: #b8adff; font-weight: 500; }
.tool-menu button span, .tool-menu button small { display: block; }
.tool-menu button span { font-size: 10px; }
.tool-menu button small { margin-top: 2px; color: var(--muted-2); font-size: 8px; }

.conversation-menu, .account-menu { position: fixed; z-index: 70; padding: 7px; border: 1px solid var(--line-strong); border-radius: 12px; background: rgba(28,29,35,.98); box-shadow: 0 22px 60px rgba(0,0,0,.46); animation: fade-up .13s ease both; }
.conversation-menu[hidden], .account-menu[hidden] { display: none; }
.conversation-menu { width: 164px; }
.conversation-menu button, .account-menu button { display: flex; align-items: center; gap: 9px; width: 100%; padding: 9px 10px; border: 0; border-radius: 8px; background: transparent; color: #d6d7dc; font-size: 10px; text-align: left; cursor: pointer; }
.conversation-menu button:hover, .account-menu button:hover { background: rgba(255,255,255,.06); color: white; }
.conversation-menu button > span:first-child { width: 16px; color: var(--muted); text-align: center; }
.conversation-menu button.danger, .conversation-menu button.danger > span { color: var(--danger); }
.conversation-menu hr, .account-menu hr { height: 1px; margin: 5px 3px; border: 0; background: var(--line); }
.account-menu { width: 250px; }
.account-menu > div { padding: 9px 10px; }
.account-menu strong, .account-menu span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-menu strong { font-size: 11px; }
.account-menu span { margin-top: 4px; color: var(--muted-2); font-size: 9px; }
.account-menu button { color: var(--danger); }

.toast { position: fixed; z-index: 50; left: 50%; bottom: 118px; max-width: min(440px, calc(100% - 32px)); padding: 10px 14px; border: 1px solid var(--line-strong); border-radius: 10px; background: #222329; box-shadow: 0 12px 35px rgba(0,0,0,.35); color: #dedee2; font-size: 11px; opacity: 0; pointer-events: none; transform: translate(-50%, 10px); transition: opacity .18s ease, transform .18s ease; }
.toast.visible { opacity: 1; transform: translate(-50%, 0); }
.knowledge-dialog {
  width: min(620px, calc(100% - 28px));
  max-height: min(720px, calc(100vh - 40px));
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: 18px;
  background: #17181d;
  box-shadow: 0 30px 90px rgba(0,0,0,.55);
  color: var(--text);
}
.knowledge-dialog::backdrop { background: rgba(3,4,7,.7); backdrop-filter: blur(5px); }
.dialog-heading { display: flex; align-items: center; padding: 18px 20px 14px; border-bottom: 1px solid var(--line); }
.dialog-heading > div { min-width: 0; margin-right: auto; }
.dialog-heading strong, .dialog-heading span { display: block; }
.dialog-heading strong { font-size: 15px; }
.dialog-heading span { margin-top: 4px; color: var(--muted-2); font-size: 9px; }
.dialog-description { margin: 0; padding: 15px 20px 5px; color: var(--muted); font-size: 11px; line-height: 1.7; }
.upload-form { display: flex; align-items: stretch; gap: 9px; padding: 12px 20px 18px; }
.file-picker { display: flex; align-items: center; min-width: 0; flex: 1; padding: 10px 12px; border: 1px dashed var(--line-strong); border-radius: 11px; cursor: pointer; }
.file-picker:hover { border-color: rgba(124,102,255,.55); background: var(--accent-soft); }
.file-picker input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.file-picker span { flex: 0 0 auto; color: #cfc9ff; font-size: 11px; }
.file-picker small { min-width: 0; margin-left: 10px; overflow: hidden; color: var(--muted-2); font-size: 9px; text-overflow: ellipsis; white-space: nowrap; }
.visibility-picker { display: flex; flex-direction: column; justify-content: center; gap: 4px; padding: 6px 10px; border: 1px solid var(--line-strong); border-radius: 10px; }
.visibility-picker span { color: var(--muted-2); font-size: 8px; }
.visibility-picker select { border: 0; outline: 0; background: transparent; color: var(--text); font: inherit; font-size: 10px; }
.upload-form > button { padding: 0 14px; border: 0; border-radius: 10px; background: var(--accent); color: white; font-size: 11px; cursor: pointer; }
.upload-form > button:disabled { opacity: .55; cursor: wait; }
.document-list { max-height: 390px; padding: 0 20px 20px; overflow-y: auto; }
.document-empty { padding: 30px 14px; border: 1px solid var(--line); border-radius: 12px; color: var(--muted-2); font-size: 11px; text-align: center; }
.document-item { display: flex; align-items: center; gap: 12px; padding: 12px 13px; border-top: 1px solid var(--line); }
.document-item > div { min-width: 0; margin-right: auto; }
.document-item strong, .document-item span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.document-item strong { font-size: 11px; font-weight: 600; }
.document-item span { margin-top: 5px; color: var(--muted-2); font-size: 9px; }
.document-item button { padding: 5px 8px; border: 0; border-radius: 7px; background: transparent; color: var(--muted-2); font-size: 9px; cursor: pointer; }
.document-item button:hover { background: rgba(255,107,125,.12); color: var(--danger); }
.memory-form { display: grid; gap: 12px; padding: 12px 20px 18px; border-bottom: 1px solid var(--line); }
.memory-form-row { display: grid; grid-template-columns: minmax(0, 1fr) 140px; gap: 10px; }
.memory-form label { display: grid; gap: 6px; color: var(--muted); font-size: 10px; }
.memory-form input, .memory-form select, .memory-form textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  outline: 0;
  background: rgba(0,0,0,.2);
  color: var(--text);
}
.memory-form input, .memory-form select { min-height: 36px; padding: 7px 9px; }
.memory-form textarea { min-height: 76px; padding: 9px 10px; resize: vertical; line-height: 1.6; }
.memory-form input:focus, .memory-form select:focus, .memory-form textarea:focus { border-color: rgba(124,102,255,.55); }
.memory-form-actions { display: flex; justify-content: flex-end; gap: 8px; }
.memory-form-actions button { min-height: 34px; padding: 0 12px; border: 0; border-radius: 9px; cursor: pointer; font-size: 10px; }
.memory-form-actions button[type="button"] { background: var(--panel-3); color: var(--muted); }
.memory-form-actions button[type="submit"] { background: var(--accent); color: white; }
.memory-form-actions button:disabled { opacity: .55; cursor: wait; }
.memory-list { max-height: 330px; padding: 14px 20px 20px; overflow-y: auto; }
.memory-item { position: relative; padding: 13px; border: 1px solid var(--line); border-radius: 12px; background: rgba(255,255,255,.018); }
.memory-item + .memory-item { margin-top: 9px; }
.memory-item.expired { opacity: .58; }
.memory-item-heading { display: flex; align-items: center; gap: 8px; }
.memory-item-heading strong { padding: 3px 7px; border-radius: 6px; background: var(--accent-soft); color: #cfc9ff; font-size: 9px; text-transform: uppercase; }
.memory-item-heading span { margin-left: auto; color: var(--muted-2); font-size: 9px; }
.memory-item p { margin: 10px 0 8px; color: #d8d9de; font-size: 11px; line-height: 1.65; white-space: pre-wrap; overflow-wrap: anywhere; }
.memory-item small { color: var(--muted-2); font-size: 9px; }
.memory-item-actions { display: flex; gap: 5px; margin-top: 9px; }
.memory-item-actions button { padding: 5px 8px; border: 0; border-radius: 7px; background: var(--panel-3); color: var(--muted); font-size: 9px; cursor: pointer; }
.memory-item-actions button:hover { color: var(--text); }
.memory-item-actions button:last-child:hover { background: rgba(255,107,125,.12); color: var(--danger); }
.office-draft-list { max-height: 510px; padding: 14px 20px 20px; overflow-y: auto; }
.office-draft-item { padding: 14px; border: 1px solid var(--line); border-radius: 12px; background: rgba(255,255,255,.018); }
.office-draft-item + .office-draft-item { margin-top: 10px; }
.office-draft-heading { display: flex; align-items: center; gap: 8px; }
.office-draft-heading strong { padding: 3px 7px; border-radius: 6px; background: var(--accent-soft); color: #cfc9ff; font-size: 9px; }
.office-draft-heading span { margin-left: auto; color: #77d9b1; font-size: 9px; }
.office-draft-heading .status-pending_confirmation { color: #f2c66d; }
.office-draft-heading .status-approved { color: #77d9b1; }
.office-draft-heading .status-rejected, .office-draft-heading .status-failed { color: var(--danger); }
.office-draft-item h3 { margin: 10px 0 8px; font-size: 12px; }
.office-draft-item pre { max-height: 190px; margin: 0 0 9px; overflow: auto; color: #d8d9de; font: inherit; font-size: 10px; line-height: 1.65; white-space: pre-wrap; overflow-wrap: anywhere; }
.office-draft-item small { color: var(--muted-2); font-size: 9px; }
.office-draft-safety { margin: 9px 0 0; color: var(--muted); font-size: 9px; line-height: 1.5; }
.office-draft-actions { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; margin-top: 10px; }
.office-draft-actions button { padding: 6px 9px; border: 0; border-radius: 7px; background: var(--panel-3); color: var(--muted); font-size: 9px; cursor: pointer; }
.office-draft-actions button:hover { background: rgba(255,107,125,.12); color: var(--danger); }
.office-draft-actions button.primary { background: var(--accent-soft); color: #d5d0ff; }
.office-draft-actions button.primary:hover { background: rgba(124,102,255,.24); color: white; }
.office-draft-actions button.danger:hover { background: rgba(255,107,125,.12); color: var(--danger); }
.office-draft-events { margin: 12px 0 0; padding: 10px 10px 10px 26px; border-radius: 9px; background: rgba(0,0,0,.16); color: var(--muted); font-size: 9px; line-height: 1.7; }
.message-metrics { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 9px; color: var(--muted-2); font-size: 9px; }
.message-metrics span { padding: 3px 6px; border: 1px solid var(--line); border-radius: 6px; background: rgba(255,255,255,.018); }
.run-metrics-list { max-height: 520px; padding: 14px 20px 20px; overflow-y: auto; }
.run-metrics-item { padding: 13px; border: 1px solid var(--line); border-radius: 12px; background: rgba(255,255,255,.018); }
.run-metrics-item + .run-metrics-item { margin-top: 9px; }
.run-metrics-heading { display: flex; align-items: center; gap: 8px; }
.run-metrics-heading strong { padding: 3px 7px; border-radius: 6px; background: var(--accent-soft); color: #cfc9ff; font-size: 9px; }
.run-metrics-heading .status-failed, .run-metrics-heading .status-cancelled, .run-metrics-heading .status-rejected { color: var(--danger); }
.run-metrics-heading span:last-child { margin-left: auto; color: var(--muted-2); font-size: 9px; }
.run-metrics-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 7px; margin-top: 11px; }
.run-metric { padding: 8px; border-radius: 8px; background: rgba(0,0,0,.16); }
.run-metric span, .run-metric strong { display: block; }
.run-metric span { color: var(--muted-2); font-size: 8px; }
.run-metric strong { margin-top: 4px; color: #dedee2; font-size: 11px; overflow-wrap: anywhere; }
.run-metrics-meta { margin-top: 9px; color: var(--muted-2); font-size: 8px; line-height: 1.6; overflow-wrap: anywhere; }
.mobile-only { display: none; }
.sidebar-scrim { display: none; }

.auth-gate { position: fixed; z-index: 100; inset: 0; display: grid; place-items: center; padding: 24px; background: radial-gradient(circle at 50% 30%, rgba(124,102,255,.12), transparent 34%), var(--bg); }
.auth-gate[hidden] { display: none; }
.auth-card { width: min(390px, 100%); padding: 34px; border: 1px solid var(--line-strong); border-radius: 22px; background: rgba(23,24,29,.96); box-shadow: 0 30px 90px rgba(0,0,0,.45); text-align: center; }
.auth-card .welcome-orb { margin: 0 auto 22px; }
.auth-card h1 { margin: 0; font-size: 24px; }
.auth-card p { margin: 12px 0 24px; color: var(--muted); font-size: 12px; line-height: 1.7; }
.auth-card small { display: block; margin-top: 16px; color: var(--muted-2); font-size: 9px; }
.github-login { display: flex; align-items: center; justify-content: center; gap: 9px; padding: 12px 16px; border-radius: 11px; background: #f2f2f4; color: #17181d; font-size: 12px; font-weight: 650; text-decoration: none; }
.github-login span { display: grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: #17181d; color: white; font-size: 8px; letter-spacing: -.03em; }
.github-login:hover { background: white; transform: translateY(-1px); }
.auth-required .app-shell { visibility: hidden; }
.user-card { display: grid; grid-template-columns: 38px minmax(0,1fr) auto; align-items: center; gap: 10px; min-height: 64px; margin-bottom: 10px; padding: 10px 11px; border: 1px solid var(--line-strong); border-radius: 12px; outline: 0; background: rgba(255,255,255,.02); cursor: pointer; transition: border-color .15s ease, background .15s ease, box-shadow .15s ease, transform .15s ease; }
.user-card:hover, .user-card:focus-visible, .user-card[aria-expanded="true"] { border-color: rgba(124,92,255,.55); background: rgba(124,92,255,.055); box-shadow: 0 0 24px rgba(124,92,255,.07); transform: translateY(-1px); }
.user-card.logged-out { border-color: rgba(124,92,255,.62); box-shadow: inset 0 0 28px rgba(124,92,255,.035); }
.user-card[hidden] { display: none; }
.user-card img { width: 38px; height: 38px; border-radius: 50%; background: var(--panel-3); }
.user-avatar-fallback { display: grid; place-items: center; width: 38px; height: 38px; border: 1px solid var(--line-strong); border-radius: 50%; background: rgba(255,255,255,.025); color: #ded9ff; font-size: 18px; font-weight: 500; }
.user-avatar-fallback[hidden] { display: none; }
.user-card div { min-width: 0; }
.user-card strong, .user-card span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-card strong { font-size: 11px; }
.user-card span { margin-top: 4px; color: var(--muted-2); font-size: 8px; }
.user-card .user-card-chevron { margin: 0; color: var(--muted); font-size: 20px; }

@keyframes fade-up { from { opacity: 0; transform: translateY(7px); } to { opacity: 1; transform: none; } }
@keyframes blink { 50% { opacity: .2; } }

@media (max-width: 760px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: min(290px, 86vw); transform: translateX(-102%); transition: transform .22s ease; }
  .sidebar.open { transform: none; }
  .sidebar-scrim { position: fixed; z-index: 15; inset: 0; display: block; background: rgba(0,0,0,.55); opacity: 0; pointer-events: none; transition: opacity .22s ease; }
  .sidebar.open + .sidebar-scrim { opacity: 1; pointer-events: auto; }
  .mobile-only { display: grid; }
  .topbar { padding: 0 13px; }
  .topbar-action { display: none; }
  .model-picker > span { display: none; }
  .model-picker select { max-width: 120px; }
  .chat-column { width: calc(100% - 28px); padding-top: 35px; }
  .suggestion-grid { grid-template-columns: 1fr; }
  .suggestion { min-height: 84px; }
  .welcome { padding-top: 25px; }
  .welcome > p { margin-bottom: 23px; }
  .composer-wrap { padding-inline: 12px; }
  .composer-actions button:nth-child(3) { display: none; }
  .composer-meta > span:last-child { display: none; }
  .message { grid-template-columns: 28px minmax(0, 1fr); gap: 10px; }
  .upload-form { flex-direction: column; }
  .upload-form > button { min-height: 38px; }
  .memory-form-row { grid-template-columns: 1fr; }
  .run-metrics-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

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