:root {
  color-scheme: dark;
  --surface: #0e1521;
  --sidebar: #0a101a;
  --raised: #141e2c;
  --hover: #192638;
  --line: #263349;
  --soft-line: #1c283a;
  --text: #edf3fc;
  --muted: #a1aec2;
  --quiet: #8b9ab1;
  --accent: #89dcf7;
  --accent-ink: #0a2735;
  --sidebar-width: 252px;
  --content-width: 768px;
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  background: var(--surface);
  color: var(--text);
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }
button, input, textarea, select { font: inherit; }
button, select { cursor: pointer; }
button { color: inherit; }
button:disabled, select:disabled { cursor: default; }
button, input, textarea, select, a { -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
a { color: var(--accent); }
::selection { color: #fff; background: #2b566f; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.workspace {
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  height: 100vh;
  height: 100dvh;
  min-height: 320px;
}

.sidebar {
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 27px 18px 20px;
  background: var(--sidebar);
  border-right: 1px solid var(--soft-line);
}

.brand { display: flex; align-items: center; gap: 12px; padding: 0 5px; }
.brand-mark, .local-icon, .prompt-icon, .assistant-avatar {
  display: grid;
  place-items: center;
  flex: none;
  border: 1px solid #263f54;
  border-radius: 11px;
  background: #142739;
  color: var(--accent);
}
.brand-mark {
  width: 41px;
  height: 41px;
  font-size: 24px;
  color: #beedff;
  background: linear-gradient(145deg, #25506b, #132739 79%);
  border-color: #3a647b;
  box-shadow: 0 3px 16px #02070f70, inset 0 1px #a4e5ff24;
}
.brand strong { display: block; font-size: 21px; letter-spacing: -.45px; line-height: 1.12; }
.brand div > span { display: block; margin-top: 4px; font-size: 11px; color: var(--muted); }

.new-chat {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  margin-top: 31px;
  padding: 0 11px;
  border: 1px solid #345067;
  border-radius: 10px;
  background: #132334;
  color: #d4f4ff;
  font-size: 13px;
  font-weight: 600;
  text-align: left;
}
.new-chat > span { color: var(--accent); font-size: 17px; line-height: 1; }
.new-chat:hover { background: #1b3046; border-color: #496a81; }

.history { display: flex; flex: 1; flex-direction: column; min-height: 0; padding-top: 24px; }
.history-heading { display: flex; align-items: center; justify-content: space-between; padding-left: 7px; margin-bottom: 5px; }
.history-heading h2 { margin: 0; color: var(--quiet); font-size: 12px; font-weight: 600; }
.icon-button {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--quiet);
  font-size: 20px;
}
.icon-button:hover { background: var(--hover); color: var(--text); }
.icon { display: inline-block; position: relative; flex: none; vertical-align: middle; }
.icon-search { width: 12px; height: 12px; border: 1.5px solid currentColor; border-radius: 50%; margin-top: -3px; margin-left: -3px; }
.icon-search::after { content: ''; position: absolute; width: 6px; height: 1.5px; right: -5px; bottom: -2px; background: currentColor; transform: rotate(46deg); }
.icon-device { width: 15px; height: 11px; border: 1.5px solid currentColor; border-radius: 3px; }
.icon-device::after { content: ''; position: absolute; width: 8px; height: 1.5px; left: 2px; bottom: -5px; background: currentColor; border-radius: 2px; }
.icon-menu { width: 16px; height: 12px; border-block: 1.5px solid currentColor; }
.icon-menu::after { content: ''; position: absolute; top: 4px; left: 0; width: 12px; height: 1.5px; background: currentColor; }
.icon-list { width: 15px; height: 13px; border-block: 1.5px solid currentColor; }
.icon-list::after { content: ''; position: absolute; top: 4px; left: 0; width: 10px; height: 1.5px; background: currentColor; }
.history-search {
  min-width: 0;
  margin: 0 0 7px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
}
.history-list { min-height: 0; overflow: auto; padding: 3px 3px 8px; }
.history-empty { margin: 0; padding: 8px 4px; color: var(--quiet); font-size: 12px; line-height: 1.6; }
.history-item { display: flex; align-items: center; margin: 2px 0; border-radius: 8px; }
.history-item:hover, .history-item:focus-within, .history-item.is-active { background: var(--raised); }
.history-item.is-active { box-shadow: inset 2px 0 var(--accent); }
.history-select {
  flex: 1;
  min-width: 0;
  padding: 10px 8px;
  overflow: hidden;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.is-active .history-select { color: var(--text); }
.history-delete { flex: none; width: 28px; height: 28px; margin-right: 4px; opacity: 0; }
.history-item:hover .history-delete, .history-item:focus-within .history-delete, .history-item.is-active .history-delete { opacity: 1; }
.local-info { display: flex; align-items: center; gap: 10px; padding: 15px 5px 0; border-top: 1px solid var(--soft-line); }
.local-icon { width: 33px; height: 33px; padding-bottom: 3px; color: var(--muted); background: #141d2b; border-color: var(--soft-line); border-radius: 9px; }
.local-info strong, .local-info div > span { display: block; }
.local-info strong { font-size: 12px; font-weight: 600; }
.local-info div > span { margin-top: 3px; color: var(--quiet); font-size: 11px; }
.sidebar-shade, .mobile-menu { display: none; }

.main {
  display: grid;
  grid-template-rows: 66px minmax(0, 1fr) auto;
  min-width: 0;
  min-height: 0;
  background: radial-gradient(ellipse at 73% 23%, #14243a 0%, transparent 48%), var(--surface);
}
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 0 27px;
  border-bottom: 1px solid var(--soft-line);
  background: #0e1521d6;
}
.toolbar-start { display: flex; align-items: center; gap: 15px; min-width: 0; }
.toolbar-title { min-width: 0; max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; font-weight: 600; }
.model-control, .connection {
  display: flex;
  align-items: center;
  height: 35px;
  min-width: 0;
  gap: 7px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #121c2a;
  color: var(--muted);
  font-size: 12px;
}
.model-control:focus-within, .connection:hover { border-color: #42617a; color: var(--text); }
.icon-model { color: var(--accent); font-family: system-ui, sans-serif; font-size: 16px; line-height: 1; }
.model-control select, .effort-control select {
  width: auto;
  min-width: 0;
  max-width: 235px;
  border: 0;
  background: transparent;
  color: inherit;
  text-overflow: ellipsis;
}
select option { background: var(--raised); color: var(--text); }
.model-control select:disabled { opacity: 1; }
.connection { flex: none; font-weight: 600; white-space: nowrap; }
.connection-dot { width: 7px; height: 7px; border-radius: 50%; background: #8290a5; }
.connection.is-connected { color: #d1f5ff; border-color: #2f5066; background: #14293a; }
.connection.is-connected .connection-dot { background: var(--accent); box-shadow: 0 0 9px #89dcf773; }

.conversation { overflow: auto; overscroll-behavior: contain; scrollbar-color: #38465a transparent; }
.content-width { width: min(var(--content-width), calc(100% - 64px)); margin-inline: auto; }
.welcome { min-height: 100%; display: flex; flex-direction: column; justify-content: center; padding: 20px 0 32px; }
.welcome-intro { display: grid; grid-template-columns: minmax(0, 1fr) minmax(200px, 40%); align-items: center; min-height: 210px; }
.welcome-copy { position: relative; z-index: 1; }
.welcome h1 { margin: 0; font-size: clamp(34px, 4.15vw, 56px); line-height: 1.2; font-weight: 700; letter-spacing: -.06em; }
.welcome h1 span { color: var(--accent); }
.welcome p { margin: 14px 0 0; color: var(--muted); font-size: 15px; line-height: 1.7; }

.orbit-art { position: relative; aspect-ratio: 1.5; isolation: isolate; }
.orbit-grid {
  position: absolute;
  inset: -10% -4%;
  border-radius: 50%;
  background: radial-gradient(circle, #7cb0d54d 1px, transparent 1.4px) 0 0 / 15px 15px;
  mask-image: radial-gradient(ellipse, #000 14%, #0008 47%, transparent 72%);
}
.orbit-ring { position: absolute; left: 50%; top: 50%; width: 78%; height: 55%; border: 1px solid #749fbe64; border-radius: 50%; transform: translate(-50%, -50%) rotate(-24deg); }
.ring-one { box-shadow: 0 0 23px #89dcf714, inset 0 0 20px #89dcf70b; }
.ring-two { width: 83%; height: 40%; transform: translate(-50%, -50%) rotate(24deg); border-color: #749fbe46; }
.ring-three { width: 72%; height: 73%; border-color: #749fbe25; }
.orbit-core {
  display: grid;
  place-items: center;
  position: absolute;
  top: 50%;
  left: 50%;
  width: 71px;
  height: 71px;
  transform: translate(-50%, -50%);
  border: 1px solid #97e5ff78;
  border-radius: 50%;
  background: radial-gradient(circle at 39% 31%, #335d75, #142d46 72%);
  color: #d2f6ff;
  font-size: 39px;
  box-shadow: 0 0 34px #7fd3ff48, inset 0 0 19px #93e3ff22;
}
.orbit-node { position: absolute; display: block; width: 6px; height: 6px; border-radius: 50%; background: #b9eeff; box-shadow: 0 0 12px var(--accent); }
.node-one { top: 21%; left: 79%; }
.node-two { top: 78%; left: 27%; width: 5px; height: 5px; }
.node-three { top: 55%; left: 88%; width: 4px; height: 4px; opacity: .74; }

.prompts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 11px; }
.prompt {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  min-height: 76px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #141e2ce8;
  text-align: left;
}
.prompt:hover { background: var(--hover); border-color: #40617b; }
.prompt-icon { width: 40px; height: 40px; border-radius: 9px; font-size: 20px; }
.code-icon { font-family: Consolas, monospace; font-size: 14px; }
.prompt strong, .prompt small { display: block; }
.prompt strong { font-size: 13px; font-weight: 600; }
.prompt small { margin-top: 4px; color: var(--quiet); font-size: 12px; line-height: 1.4; }
.prompt-arrow { color: var(--quiet); font-size: 17px; }
.prompt:hover .prompt-arrow { color: var(--accent); }

.composer-area { padding: 14px 0 max(19px, env(safe-area-inset-bottom)); background: #0e1521db; }
.composer-notice { margin: 0 0 9px; color: var(--accent); font-size: 13px; }
.composer { padding: 12px 12px 9px; border: 1px solid #35475f; border-radius: 16px; background: #141e2c; box-shadow: 0 7px 25px #02071057; }
.composer:focus-within { border-color: #547899; }
.composer textarea {
  display: block;
  width: 100%;
  min-height: 47px;
  max-height: 160px;
  padding: 5px 5px 7px;
  resize: none;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font-size: 15px;
  line-height: 1.55;
  scrollbar-color: #38465a transparent;
}
.composer textarea::placeholder, input::placeholder { color: var(--quiet); opacity: 1; }
.composer-controls { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.effort-control { display: inline-flex; align-items: center; gap: 8px; min-height: 32px; padding: 0 8px; border: 1px solid var(--line); border-radius: 8px; background: #101a27; color: var(--muted); font-size: 12px; }
.effort-control select { color: var(--text); }
.effort-icon { display: flex; align-items: end; gap: 2px; height: 11px; color: var(--accent); }
.effort-icon i { width: 2px; height: 4px; border-radius: 1px; background: currentColor; }
.effort-icon i:nth-child(2) { height: 7px; }
.effort-icon i:nth-child(3) { height: 10px; }
.send-button { display: grid; place-items: center; width: 37px; height: 37px; padding: 0; border: 0; border-radius: 9px; background: var(--accent); color: var(--accent-ink); }
.send-button:disabled { background: #26394c; color: #a3b6c8; }
.send-button:not(:disabled):hover { background: #b3ebff; }
.send-glyph { position: relative; width: 2px; height: 13px; border-radius: 2px; background: currentColor; }
.send-glyph::before { content: ''; position: absolute; left: -4px; top: 0; width: 10px; height: 10px; border-top: 2px solid currentColor; border-left: 2px solid currentColor; transform: rotate(45deg); }
.stop-button > span { width: 11px; height: 11px; border-radius: 2px; background: currentColor; }
.composer-help { display: flex; justify-content: space-between; gap: 10px; margin: 10px 2px 0; color: var(--quiet); font-size: 11px; line-height: 1.45; }
.composer-help kbd { font: inherit; color: var(--muted); }
.help-dot { margin: 0 3px; }

.messages { padding: 31px 0 20px; }
.turn { margin-bottom: 28px; }
.user-message { width: fit-content; max-width: min(88%, 620px); margin: 0 0 25px auto; padding: 11px 15px; border: 1px solid #325065; border-radius: 13px; background: #1a3043; color: #eaf7ff; font-size: 15px; line-height: 1.65; white-space: pre-wrap; overflow-wrap: anywhere; }
.assistant-message { display: grid; grid-template-columns: 33px minmax(0, 1fr); gap: 11px; }
.assistant-avatar { align-self: start; width: 33px; height: 33px; border-radius: 9px; font-size: 17px; }
.assistant-model { margin: 0 0 6px; padding-top: 4px; color: var(--muted); font-size: 12px; font-weight: 600; overflow-wrap: anywhere; }
.answer-text { font-size: 15px; line-height: 1.7; overflow-wrap: anywhere; }
.answer-text.is-streaming { white-space: pre-wrap; }
.answer-text > :first-child { margin-top: 0; }
.answer-text > :last-child { margin-bottom: 0; }
.answer-text p, .answer-text ul, .answer-text ol, .answer-text blockquote, .code-block { margin: 0 0 12px; }
.answer-text p { white-space: pre-wrap; }
.answer-text h3, .answer-text h4, .answer-text h5 { margin: 18px 0 8px; line-height: 1.4; }
.answer-text ul, .answer-text ol { padding-left: 24px; }
.answer-text blockquote { padding-left: 12px; border-left: 2px solid #45617b; color: var(--muted); white-space: pre-wrap; }
.answer-text code { font-family: Consolas, "SFMono-Regular", monospace; font-size: .9em; }
.answer-text :not(pre) > code { padding: 2px 4px; border-radius: 4px; background: #202e40; color: #d3eefa; }
.code-block { overflow: hidden; border: 1px solid var(--line); border-radius: 10px; background: #0b121d; }
.code-caption { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 5px 10px; background: var(--raised); color: var(--muted); font-size: 12px; }
.code-block pre { margin: 0; padding: 11px 13px; overflow: auto; scrollbar-color: #38465a transparent; }
.answer-status { margin: 8px 0 0; color: var(--muted); font-size: 13px; line-height: 1.55; overflow-wrap: anywhere; }
.answer-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.text-button { padding: 5px 7px; border: 0; border-radius: 7px; background: transparent; color: var(--muted); font-size: 12px; white-space: nowrap; }
.text-button:hover { background: var(--hover); color: var(--text); }
.text-button:disabled { opacity: .65; }

.settings {
  width: min(465px, calc(100% - 32px));
  max-height: calc(100% - 32px);
  margin: auto;
  padding: 0;
  overflow: auto;
  border: 1px solid #38536d;
  border-radius: 16px;
  background: #131d2b;
  color: var(--text);
  box-shadow: 0 24px 84px #060d19b8;
}
.settings::backdrop { background: #040912b8; }
.settings-fields { padding: 24px 24px 12px; }
.settings-header { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; margin-bottom: 22px; }
.settings-header h2 { margin: 0; font-size: 22px; }
.settings-header p, .field-hint { color: var(--muted); font-size: 13px; line-height: 1.6; }
.settings-header p { margin: 6px 0 0; }
.provider-picker { display: flex; gap: 8px; margin-bottom: 16px; }
.provider-fields { min-width: 0; margin: 0; padding: 0; border: 0; }
.provider-name { margin-bottom: 14px; }
.provider-control { max-width: min(27vw, 180px); }
.provider-control select { max-width: 100%; }
.field { display: block; margin-bottom: 7px; font-size: 13px; font-weight: 600; }
.field-input { width: 100%; min-width: 0; height: 40px; padding: 0 11px; border: 1px solid #35455b; border-radius: 8px; background: #0d1521; color: var(--text); font-size: 14px; }
.field-hint { margin: 6px 0 17px; }
.key-field { display: flex; gap: 6px; }
.key-field .text-button { padding-inline: 9px; }
.remember-key { display: flex; align-items: center; gap: 7px; margin-top: 13px; color: var(--muted); font-size: 13px; }
.remember-key input { accent-color: var(--accent); }
.settings-status { margin: 0 0 12px; color: var(--accent); font-size: 13px; line-height: 1.55; overflow-wrap: anywhere; }
.settings-status:empty { margin: 0; }
.settings-status[data-state="error"] { color: #ffb5ad; }
.settings-footer { position: sticky; bottom: 0; padding: 12px 24px 20px; background: #131d2b; }
.settings-actions { display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: 8px; }
.settings-actions:has(#start-chat:not([hidden])) #connect { background: var(--raised); color: var(--text); }
.settings-actions:has(#start-chat:not([hidden])) #connect:hover { background: var(--hover); }
.disconnect { margin-right: auto; }
.primary-button { min-height: 38px; padding: 0 14px; border: 0; border-radius: 8px; background: var(--accent); color: var(--accent-ink); font-size: 13px; font-weight: 700; white-space: nowrap; }
.primary-button:hover { background: #b3ebff; }
.primary-button:disabled { opacity: .75; }

@media (max-width: 940px) {
  :root { --sidebar-width: 212px; }
  .content-width { width: min(var(--content-width), calc(100% - 42px)); }
  .toolbar { padding-inline: 21px; }
  .welcome-intro { min-height: 175px; }
}

@media (max-width: 700px) {
  .workspace { grid-template-columns: minmax(0, 1fr); }
  .main { grid-template-rows: 56px minmax(0, 1fr) auto; }
  .sidebar { display: none; position: fixed; inset: 0 auto 0 0; width: min(264px, 83vw); z-index: 3; }
  .sidebar.is-open { display: flex; }
  .sidebar-shade { display: block; position: fixed; inset: 0; z-index: 2; padding: 0; border: 0; background: #040912a8; }
  .mobile-menu { display: grid; flex: none; }
  .toolbar { padding-inline: 12px; gap: 6px; }
  .toolbar-start { gap: 6px; }
  .toolbar-title { display: none; }
  .model-control { max-width: min(48vw, 270px); }
  .provider-control { max-width: 25vw; }
  .content-width { width: calc(100% - 30px); }
  .welcome { padding: 16px 0 22px; }
  .welcome-intro { grid-template-columns: minmax(0, 1fr) minmax(92px, 31%); min-height: 126px; }
  .welcome h1 { font-size: clamp(25px, 6.4vw, 44px); }
  .welcome p { margin-top: 9px; font-size: 13px; }
  .orbit-core { width: 35%; height: auto; aspect-ratio: 1; font-size: clamp(14px, 4.6vw, 24px); }
  .orbit-grid { background-size: 10px 10px; }
  .orbit-node { width: 4px; height: 4px; }
  .prompt { min-height: 65px; gap: 8px; padding: 8px; }
  .prompt-icon { width: 31px; height: 31px; font-size: 16px; }
  .code-icon { font-size: 12px; }
  .prompt small { font-size: 11px; }
  .prompt-arrow { display: none; }
  .composer-area { padding-top: 10px; padding-bottom: max(12px, env(safe-area-inset-bottom)); }
  .composer textarea, .field-input { font-size: 16px; }
  .messages { padding-top: 22px; }
}

@media (max-width: 360px) {
  .prompt { grid-template-columns: minmax(0, 1fr); }
  .prompt-icon { display: none; }
  .composer-help { font-size: 10px; }
}

@media (hover: none) { .history-delete { opacity: 1; } }
@media (min-width: 701px) { .sidebar-shade { display: none !important; } }
