/* ==========================================================================
   Local Chat — 极简、克制、跟随系统的浅/深色样式
   ========================================================================== */

:root {
  --bg: #ffffff;
  --bg-subtle: #f6f7f9;
  --bg-elevated: #ffffff;
  --bg-hover: #eef0f4;
  --bg-active: #e5e9f0;
  --bg-user-bubble: #eff3fa;
  --bg-code: #f4f6f9;
  --bg-code-header: #ebeff5;

  --text: #14181f;
  --text-secondary: #525d6e;
  --text-muted: #7c8799;

  --border: #e5e8ee;
  --border-strong: #d2d7e0;

  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-soft: rgba(37, 99, 235, 0.1);
  --accent-text: #ffffff;

  --ok: #16a34a;
  --warn: #d97706;
  --danger: #dc2626;
  --danger-soft: rgba(220, 38, 38, 0.1);

  --tok-comment: #6e7781;
  --tok-string: #0a7a42;
  --tok-keyword: #8250df;
  --tok-number: #0550ae;

  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow-md: 0 8px 28px rgba(15, 23, 42, 0.08);
  --shadow-drawer: -12px 0 36px rgba(15, 23, 42, 0.12);

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;

  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  --font-mono: "JetBrains Mono", "Fira Code", ui-monospace, SFMono-Regular,
    Menlo, Monaco, Consolas, monospace;

  --topbar-h: 56px;
  --content-max: 780px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111317;
    --bg-subtle: #181b21;
    --bg-elevated: #1c2028;
    --bg-hover: #242934;
    --bg-active: #2d3340;
    --bg-user-bubble: #1e2636;
    --bg-code: #161920;
    --bg-code-header: #1e222b;

    --text: #eceff4;
    --text-secondary: #a5b0c2;
    --text-muted: #768296;

    --border: #262b36;
    --border-strong: #373e4d;

    --accent: #3b82f6;
    --accent-hover: #60a5fa;
    --accent-soft: rgba(59, 130, 246, 0.16);
    --accent-text: #ffffff;

    --ok: #22c55e;
    --warn: #f59e0b;
    --danger: #f87171;
    --danger-soft: rgba(248, 113, 113, 0.14);

    --tok-comment: #7f8ca3;
    --tok-string: #7ee787;
    --tok-keyword: #d2a8ff;
    --tok-number: #79c0ff;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.25);
    --shadow-md: 0 10px 32px rgba(0, 0, 0, 0.35);
    --shadow-drawer: -12px 0 40px rgba(0, 0, 0, 0.45);
  }
}

:root[data-theme="dark"] {
  --bg: #111317;
  --bg-subtle: #181b21;
  --bg-elevated: #1c2028;
  --bg-hover: #242934;
  --bg-active: #2d3340;
  --bg-user-bubble: #1e2636;
  --bg-code: #161920;
  --bg-code-header: #1e222b;

  --text: #eceff4;
  --text-secondary: #a5b0c2;
  --text-muted: #768296;

  --border: #262b36;
  --border-strong: #373e4d;

  --accent: #3b82f6;
  --accent-hover: #60a5fa;
  --accent-soft: rgba(59, 130, 246, 0.16);
  --accent-text: #ffffff;

  --ok: #22c55e;
  --warn: #f59e0b;
  --danger: #f87171;
  --danger-soft: rgba(248, 113, 113, 0.14);

  --tok-comment: #7f8ca3;
  --tok-string: #7ee787;
  --tok-keyword: #d2a8ff;
  --tok-number: #79c0ff;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.25);
  --shadow-md: 0 10px 32px rgba(0, 0, 0, 0.35);
  --shadow-drawer: -12px 0 40px rgba(0, 0, 0, 0.45);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

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

[hidden] {
  display: none !important;
}

/* ==========================================================================
   App Shell & Topbar
   ========================================================================== */

.app-shell {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  overflow: hidden;
}

.topbar {
  height: var(--topbar-h);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 16px;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  z-index: 20;
}

.topbar-left,
.topbar-right {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.model-picker {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--text-muted);
  transition: background 0.2s ease, box-shadow 0.2s ease;
}

.status-dot.is-ok {
  background: var(--ok);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 20%, transparent);
}

.status-dot.is-loading {
  background: var(--warn);
  animation: pulse 1.3s ease-in-out infinite;
}

.status-dot.is-error {
  background: var(--danger);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--danger) 20%, transparent);
}

.model-select {
  appearance: none;
  -webkit-appearance: none;
  background-color: var(--bg-subtle);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%237c8799' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 30px 6px 11px;
  font-size: 13.5px;
  font-weight: 500;
  max-width: 260px;
  text-overflow: ellipsis;
  cursor: pointer;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

.model-select:hover {
  border-color: var(--border-strong);
  background-color: var(--bg-hover);
}

.model-select:focus {
  outline: none;
  border-color: var(--accent);
}

.icon-btn,
.ghost-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 34px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.icon-btn {
  width: 34px;
  padding: 0;
}

.ghost-btn {
  padding: 0 11px;
  font-size: 13.5px;
  font-weight: 500;
}

.icon-btn:hover,
.ghost-btn:hover {
  background: var(--bg-hover);
  color: var(--text);
}

.icon-btn:active,
.ghost-btn:active {
  background: var(--bg-active);
}

.icon-btn.is-spinning svg {
  animation: spin 0.8s linear infinite;
}

.settings-trigger {
  position: relative;
}

.badge-dot {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
}

.theme-icon-slot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* ==========================================================================
   Main Chat Stream
   ========================================================================== */

.chat-container {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior-y: contain;
  scroll-behavior: auto;
}

.chat-inner {
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 24px 18px 28px;
  min-height: 100%;
  display: flex;
  flex-direction: column;
}

/* Empty State */
.empty-state {
  margin: auto;
  text-align: center;
  max-width: 460px;
  padding: 36px 12px 48px;
}

.empty-logo {
  width: 52px;
  height: 52px;
  margin: 0 auto 16px;
  border-radius: 15px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent-soft);
  color: var(--accent);
}

.empty-title {
  margin: 0;
  font-size: 22px;
  font-weight: 650;
  letter-spacing: -0.02em;
}

.empty-subtitle {
  margin: 8px 0 18px;
  font-size: 14px;
  color: var(--text-secondary);
}

.empty-chips {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}

.info-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-subtle);
  color: var(--text-secondary);
  font-size: 12.5px;
}

.info-chip.is-interactive {
  cursor: pointer;
  color: var(--accent);
  border-color: color-mix(in srgb, var(--accent) 30%, var(--border));
  background: var(--accent-soft);
}

.info-chip.is-interactive:hover {
  filter: brightness(0.97);
}

.inline-alert {
  margin-top: 20px;
  padding: 13px 15px;
  border-radius: var(--radius-md);
  border: 1px solid color-mix(in srgb, var(--danger) 30%, var(--border));
  background: var(--danger-soft);
  text-align: left;
  font-size: 13px;
  color: var(--text);
}

.inline-alert p {
  margin: 0 0 10px;
}

.inline-alert-actions {
  display: flex;
  gap: 8px;
}

.small-btn {
  padding: 5px 11px;
  border-radius: 7px;
  border: 1px solid var(--border-strong);
  background: var(--bg-elevated);
  color: var(--text);
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
}

.small-btn:hover {
  background: var(--bg-hover);
}

.small-btn.is-secondary {
  background: transparent;
}

/* Message List */
.message-list {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.msg-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.msg-row.is-user {
  align-items: flex-end;
}

.msg-row.is-assistant {
  align-items: flex-start;
}

.user-bubble {
  max-width: min(86%, 640px);
  padding: 11px 16px;
  border-radius: 18px 18px 5px 18px;
  background: var(--bg-user-bubble);
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 15px;
  line-height: 1.6;
}

.assistant-block {
  width: 100%;
  min-width: 0;
}

.assistant-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.assistant-badge {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.01em;
}

/* Thinking Block */
.thinking-block {
  margin: 0 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-subtle);
  overflow: hidden;
}

.thinking-summary {
  list-style: none;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  user-select: none;
}

.thinking-summary::-webkit-details-marker {
  display: none;
}

.thinking-chevron {
  transition: transform 0.16s ease;
  color: var(--text-muted);
  flex-shrink: 0;
}

.thinking-block[open] .thinking-chevron {
  transform: rotate(90deg);
}

.thinking-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  animation: pulse 1.1s ease-in-out infinite;
  flex-shrink: 0;
}

.thinking-content {
  padding: 2px 14px 12px;
  border-top: 1px solid var(--border);
  font-size: 13.5px;
  line-height: 1.65;
  color: var(--text-secondary);
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 360px;
  overflow-y: auto;
}

/* Markdown Body */
.md-body {
  font-size: 15px;
  line-height: 1.72;
  color: var(--text);
  word-break: break-word;
}

.md-body > *:first-child {
  margin-top: 0;
}

.md-body > *:last-child {
  margin-bottom: 0;
}

.md-body p {
  margin: 0 0 0.85em;
}

.md-body h1,
.md-body h2,
.md-body h3,
.md-body h4 {
  margin: 1.25em 0 0.55em;
  line-height: 1.35;
  font-weight: 650;
  letter-spacing: -0.015em;
}

.md-body h1 {
  font-size: 1.35em;
}
.md-body h2 {
  font-size: 1.2em;
}
.md-body h3 {
  font-size: 1.07em;
}
.md-body h4 {
  font-size: 1em;
}

.md-body ul,
.md-body ol {
  margin: 0.45em 0 0.9em;
  padding-left: 1.5em;
}

.md-body li {
  margin: 0.25em 0;
}

.md-body blockquote {
  margin: 0.8em 0;
  padding: 6px 14px;
  border-left: 3px solid var(--border-strong);
  color: var(--text-secondary);
  background: var(--bg-subtle);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.md-body hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 1.2em 0;
}

.md-body a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.md-body .inline-code {
  font-family: var(--font-mono);
  font-size: 0.88em;
  padding: 2px 5px;
  border-radius: 5px;
  background: var(--bg-code);
  border: 1px solid var(--border);
}

/* Code Blocks */
.code-block {
  margin: 0.9em 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-code);
  overflow: hidden;
}

.code-block-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 12px;
  background: var(--bg-code-header);
  border-bottom: 1px solid var(--border);
  font-size: 12px;
}

.code-lang {
  font-family: var(--font-mono);
  color: var(--text-secondary);
  text-transform: lowercase;
}

.code-copy-btn {
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 12px;
  padding: 2px 7px;
  border-radius: 5px;
  cursor: pointer;
}

.code-copy-btn:hover {
  background: var(--bg-hover);
  color: var(--text);
}

.code-block pre {
  margin: 0;
  padding: 12px 14px;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.58;
}

.code-block code {
  font-family: inherit;
}

.tok-comment {
  color: var(--tok-comment);
  font-style: italic;
}
.tok-string {
  color: var(--tok-string);
}
.tok-keyword {
  color: var(--tok-keyword);
  font-weight: 500;
}
.tok-number {
  color: var(--tok-number);
}

/* Tables */
.md-table-wrap {
  margin: 0.9em 0;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.md-body table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

.md-body th,
.md-body td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  text-align: left;
}

.md-body th {
  background: var(--bg-subtle);
  font-weight: 600;
}

.md-body tr:last-child td {
  border-bottom: none;
}

/* Typing Cursor / Error */
.streaming-indicator {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--text-muted);
  font-size: 13.5px;
  padding: 2px 0;
}

.streaming-dots {
  display: inline-flex;
  gap: 4px;
}

.streaming-dots span {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--text-muted);
  animation: bounceDot 1.2s infinite ease-in-out;
}

.streaming-dots span:nth-child(2) {
  animation-delay: 0.16s;
}

.streaming-dots span:nth-child(3) {
  animation-delay: 0.32s;
}

.msg-error {
  margin-top: 8px;
  padding: 10px 13px;
  border-radius: var(--radius-sm);
  border: 1px solid color-mix(in srgb, var(--danger) 35%, var(--border));
  background: var(--danger-soft);
  color: var(--text);
  font-size: 13.5px;
}

/* Message Actions */
.msg-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 4px;
  opacity: 0;
  transition: opacity 0.15s ease;
}

.msg-row:hover .msg-actions,
.msg-row:focus-within .msg-actions,
.msg-actions.is-visible {
  opacity: 1;
}

@media (hover: none) {
  .msg-actions {
    opacity: 1;
  }
}

.action-btn {
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 12px;
  padding: 3px 8px;
  border-radius: 6px;
  cursor: pointer;
}

.action-btn:hover {
  background: var(--bg-hover);
  color: var(--text);
}

.msg-stat {
  margin-left: 6px;
  font-size: 11.5px;
  color: var(--text-muted);
}

/* ==========================================================================
   Bottom Composer
   ========================================================================== */

.composer-wrap {
  flex-shrink: 0;
  padding: 8px 16px max(14px, env(safe-area-inset-bottom));
  background: linear-gradient(
    to top,
    var(--bg) 78%,
    color-mix(in srgb, var(--bg) 0%, transparent)
  );
}

.composer-inner {
  max-width: var(--content-max);
  margin: 0 auto;
}

.composer-card {
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  background: var(--bg-elevated);
  box-shadow: var(--shadow-sm);
  padding: 10px 12px 9px 15px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.composer-card:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.composer-textarea {
  display: block;
  width: 100%;
  border: none;
  outline: none;
  resize: none;
  background: transparent;
  color: var(--text);
  font-size: 15px;
  line-height: 1.55;
  max-height: 180px;
  overflow-y: auto;
  padding: 2px 0 6px;
}

.composer-textarea::placeholder {
  color: var(--text-muted);
}

.composer-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-top: 4px;
}

.composer-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.pill-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-subtle);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
}

.pill-toggle:hover {
  border-color: var(--border-strong);
}

.pill-toggle .pill-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-muted);
}

.pill-toggle.is-active {
  color: var(--accent);
  border-color: color-mix(in srgb, var(--accent) 40%, var(--border));
  background: var(--accent-soft);
}

.pill-toggle.is-active .pill-dot {
  background: var(--accent);
}

.shortcut-hint {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
}

.send-btn {
  width: 34px;
  height: 34px;
  border: none;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--accent);
  color: var(--accent-text);
  cursor: pointer;
  flex-shrink: 0;
  transition: background-color 0.15s ease, opacity 0.15s ease, transform 0.1s ease;
}

.send-btn:hover:not(:disabled) {
  background: var(--accent-hover);
}

.send-btn:active:not(:disabled) {
  transform: scale(0.96);
}

.send-btn:disabled {
  opacity: 0.38;
  cursor: not-allowed;
}

.send-btn.is-stop {
  background: var(--text);
  color: var(--bg);
}

/* ==========================================================================
   Settings Drawer
   ========================================================================== */

.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.36);
  backdrop-filter: blur(2px);
  z-index: 40;
}

.settings-drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(390px, 100vw);
  background: var(--bg-elevated);
  border-left: 1px solid var(--border);
  box-shadow: var(--shadow-drawer);
  display: flex;
  flex-direction: column;
  z-index: 50;
  transform: translateX(100%);
  transition: transform 0.22s cubic-bezier(0.22, 1, 0.36, 1);
}

.settings-drawer.is-open {
  transform: translateX(0);
}

.drawer-header {
  height: var(--topbar-h);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px 0 20px;
  border-bottom: 1px solid var(--border);
}

.drawer-header h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 650;
}

.drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 18px 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.setting-group {
  display: flex;
  flex-direction: column;
  gap: 13px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}

.setting-group:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.setting-group-title {
  margin: 0;
  font-size: 12.5px;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

.setting-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.setting-field label,
.switch-label {
  font-size: 13.5px;
  font-weight: 550;
  color: var(--text);
}

.field-hint {
  margin: 0;
  font-size: 12px;
  line-height: 1.45;
  color: var(--text-muted);
}

.text-input,
.textarea-input {
  width: 100%;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  padding: 8px 10px;
  font-size: 13.5px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.textarea-input {
  resize: vertical;
  min-height: 88px;
  line-height: 1.55;
}

.text-input:focus,
.textarea-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.quick-url-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.mini-chip {
  border: 1px solid var(--border);
  background: var(--bg-subtle);
  color: var(--text-secondary);
  font-size: 11.5px;
  padding: 3px 9px;
  border-radius: 999px;
  cursor: pointer;
}

.mini-chip:hover {
  border-color: var(--border-strong);
  color: var(--text);
}

.mini-chip.is-active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}

.text-btn {
  border: none;
  background: transparent;
  color: var(--accent);
  font-size: 12.5px;
  font-weight: 500;
  padding: 2px 4px;
  cursor: pointer;
}

.text-btn:hover {
  text-decoration: underline;
}

.connection-test-msg {
  margin: 2px 0 0;
  font-size: 12px;
  line-height: 1.45;
}

.connection-test-msg.is-ok {
  color: var(--ok);
}

.connection-test-msg.is-error {
  color: var(--danger);
}

/* Segmented Controls */
.segmented {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  padding: 3px;
  border-radius: 10px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
}

.seg-btn {
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 12.5px;
  font-weight: 500;
  padding: 6px 6px;
  border-radius: 7px;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

.seg-btn:hover {
  color: var(--text);
}

.seg-btn.is-active {
  background: var(--bg-elevated);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

/* Switch */
.setting-row-switch {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.switch {
  position: relative;
  display: inline-flex;
  flex-shrink: 0;
  cursor: pointer;
}

.switch input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.switch-track {
  width: 38px;
  height: 22px;
  border-radius: 999px;
  background: var(--border-strong);
  position: relative;
  transition: background-color 0.18s ease;
}

.switch-track::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
  transition: transform 0.18s ease;
}

.switch input:checked + .switch-track {
  background: var(--accent);
}

.switch input:checked + .switch-track::after {
  transform: translateX(16px);
}

/* Range Slider */
.param-val {
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--text-secondary);
}

.range-input {
  width: 100%;
  accent-color: var(--accent);
  cursor: pointer;
  margin: 2px 0;
}

.drawer-footer {
  flex-shrink: 0;
  padding: 13px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: var(--bg-subtle);
}

.privacy-note {
  margin: 0;
  font-size: 11.5px;
  color: var(--text-muted);
}

.danger-ghost-btn {
  border: 1px solid color-mix(in srgb, var(--danger) 35%, var(--border));
  background: transparent;
  color: var(--danger);
  font-size: 12px;
  font-weight: 500;
  padding: 5px 10px;
  border-radius: 7px;
  cursor: pointer;
  white-space: nowrap;
}

.danger-ghost-btn:hover {
  background: var(--danger-soft);
}

/* ==========================================================================
   Toast
   ========================================================================== */

.toast {
  position: fixed;
  left: 50%;
  bottom: 92px;
  transform: translateX(-50%);
  padding: 8px 15px;
  border-radius: 999px;
  background: var(--text);
  color: var(--bg);
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow-md);
  z-index: 60;
  pointer-events: none;
}

/* ==========================================================================
   Animations & Responsive
   ========================================================================== */

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.35;
  }
}

@keyframes bounceDot {
  0%,
  80%,
  100% {
    transform: scale(0.65);
    opacity: 0.4;
  }
  40% {
    transform: scale(1);
    opacity: 1;
  }
}

@media (max-width: 640px) {
  .topbar {
    padding: 0 12px;
  }
  .model-select {
    max-width: 175px;
  }
  .ghost-btn .btn-label {
    display: none;
  }
  .ghost-btn {
    width: 34px;
    padding: 0;
  }
  .shortcut-hint {
    display: none;
  }
  .chat-inner {
    padding: 18px 14px 22px;
  }
  .user-bubble {
    max-width: 92%;
  }
}
