/* =========================================================
 *  vLLM WebUI - 精致版样式
 * ========================================================= */

:root {
  /* Light theme */
  --bg:            #fafafa;
  --bg-alt:        #f2f3f5;
  --bg-elev:       #ffffff;
  --sidebar-bg:    #f6f7f9;
  --sidebar-hover: #eceef2;
  --text:          #1a1a1a;
  --text-soft:     #3a3a3a;
  --text-muted:    #6b7280;
  --border:        #e5e7eb;
  --border-soft:   #eef0f3;
  --border-strong: #d1d5db;

  --accent:        #10a37f;
  --accent-soft:   #e6f7f1;
  --accent-hover:  #0d8a6b;
  --danger:        #ef4444;
  --danger-hover:  #dc2626;

  --user-bubble:   linear-gradient(135deg, #dcf0e7 0%, #e8f2ec 100%);
  --user-bubble-border: #c9e6d7;
  --user-avatar:   linear-gradient(135deg, #10a37f 0%, #2ec4b6 100%);
  --ai-avatar:     linear-gradient(135deg, #7c3aed 0%, #db2777 100%);

  --code-bg:       #f6f8fa;
  --code-border:   #e5e7eb;

  --shadow-sm:     0 1px 2px rgba(16,24,40,0.04);
  --shadow-md:     0 4px 14px rgba(16,24,40,0.06), 0 1px 2px rgba(16,24,40,0.04);
  --shadow-lg:     0 12px 40px rgba(16,24,40,0.10), 0 2px 6px rgba(16,24,40,0.05);
  --shadow-focus:  0 0 0 3px rgba(16,163,127,0.18);

  --radius-sm:  6px;
  --radius:     10px;
  --radius-lg:  16px;
  --radius-xl:  20px;

  --sidebar-width: 272px;
}

[data-theme="dark"] {
  --bg:            #0f1012;
  --bg-alt:        #17191c;
  --bg-elev:       #1c1e22;
  --sidebar-bg:    #111215;
  --sidebar-hover: #1d1f23;
  --text:          #ececec;
  --text-soft:     #c9cbd0;
  --text-muted:    #8a8f99;
  --border:        #26282d;
  --border-soft:   #1f2024;
  --border-strong: #3a3d44;

  --accent:        #10b98c;
  --accent-soft:   rgba(16,185,140,0.12);
  --accent-hover:  #22c99d;
  --danger:        #f87171;
  --danger-hover:  #ef4444;

  --user-bubble:   linear-gradient(135deg, rgba(16,185,140,0.14) 0%, rgba(46,196,182,0.10) 100%);
  --user-bubble-border: rgba(16,185,140,0.25);
  --user-avatar:   linear-gradient(135deg, #10b98c 0%, #2ec4b6 100%);
  --ai-avatar:     linear-gradient(135deg, #a78bfa 0%, #f472b6 100%);

  --code-bg:       #0b0c0e;
  --code-border:   #26282d;

  --shadow-sm:     0 1px 2px rgba(0,0,0,0.3);
  --shadow-md:     0 4px 14px rgba(0,0,0,0.35), 0 1px 2px rgba(0,0,0,0.25);
  --shadow-lg:     0 12px 40px rgba(0,0,0,0.5), 0 2px 6px rgba(0,0,0,0.3);
  --shadow-focus:  0 0 0 3px rgba(16,185,140,0.25);
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  padding: 0;
}

body {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
               "Helvetica Neue", "PingFang SC", "Hiragino Sans GB",
               "Microsoft YaHei", sans-serif;
  font-size: 15px;
  line-height: 1.65;
  color: var(--text);
  background: var(--bg);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  font-feature-settings: "cv02", "cv03", "cv04", "cv11";
}

code, pre, .mono {
  font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

/* ========== Layout ========== */
#app {
  display: flex;
  height: 100vh;
  width: 100vw;
}

/* ========== Sidebar ========== */
#sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border-soft);
  display: flex;
  flex-direction: column;
  transition: margin-left 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}
#sidebar.collapsed {
  margin-left: calc(var(--sidebar-width) * -1);
}

.sidebar-header {
  padding: 14px;
  display: flex;
  gap: 8px;
  align-items: center;
}
.sidebar-header .btn-primary { flex: 1; }

.conversation-list {
  flex: 1;
  overflow-y: auto;
  padding: 4px 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.conv-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius);
  cursor: pointer;
  color: var(--text-soft);
  font-size: 14px;
  transition: background 0.15s, color 0.15s;
  position: relative;
  border: 1px solid transparent;
}
.conv-item:hover {
  background: var(--sidebar-hover);
  color: var(--text);
}
.conv-item.active {
  background: var(--bg-elev);
  color: var(--text);
  border-color: var(--border);
  box-shadow: var(--shadow-sm);
}
.conv-item svg { flex-shrink: 0; color: var(--text-muted); }
.conv-item.active svg { color: var(--accent); }
.conv-item .title {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.conv-item .delete {
  opacity: 0;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
  display: flex;
  transition: opacity 0.15s, color 0.15s, background 0.15s;
}
.conv-item:hover .delete,
.conv-item.active .delete { opacity: 1; }
.conv-item .delete:hover {
  color: var(--danger);
  background: rgba(239,68,68,0.1);
}

.sidebar-footer {
  padding: 10px;
  border-top: 1px solid var(--border-soft);
  display: flex;
  gap: 4px;
}
.sidebar-footer .btn-ghost { flex: 1; justify-content: flex-start; }
.sidebar-footer .btn-ghost:last-child { flex: 0 0 auto; justify-content: center; }

/* ========== Main ========== */
#main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--bg);
  position: relative;
}

#topbar {
  height: 56px;
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 12px;
  flex-shrink: 0;
  background: rgba(250,250,250,0.75);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--border-soft);
  position: relative;
  z-index: 10;
}
[data-theme="dark"] #topbar {
  background: rgba(15,16,18,0.7);
}
.topbar-title {
  flex: 1;
  font-weight: 600;
  font-size: 15px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}
.conn-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-muted);
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--bg-alt);
  border: 1px solid var(--border-soft);
}
.conn-status .dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: #9ca3af;
  box-shadow: 0 0 0 0 rgba(156,163,175,0.4);
}
.conn-status.ok .dot {
  background: var(--accent);
  animation: pulse-dot 2s infinite;
}
.conn-status.err .dot { background: var(--danger); }
@keyframes pulse-dot {
  0%   { box-shadow: 0 0 0 0 rgba(16,163,127,0.5); }
  70%  { box-shadow: 0 0 0 6px rgba(16,163,127,0); }
  100% { box-shadow: 0 0 0 0 rgba(16,163,127,0); }
}
.model-select {
  background: var(--bg-alt);
  border: 1px solid var(--border-soft);
  color: var(--text);
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 12.5px;
  max-width: 240px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.model-select:hover { border-color: var(--border-strong); }

/* ========== Chat ========== */
.chat-container {
  flex: 1;
  overflow-y: auto;
  padding: 28px 0 10px;
  scroll-behavior: smooth;
}
.messages {
  max-width: 780px;
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

/* ---- Welcome ---- */
.welcome {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 72px 20px 40px;
  text-align: center;
  animation: fade-up 0.45s cubic-bezier(0.2, 0.8, 0.2, 1);
}
@keyframes fade-up {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* 极光背景 */
.welcome-aurora {
  position: absolute;
  inset: -40px 0 20% 0;
  z-index: 0;
  pointer-events: none;
  filter: blur(60px);
  opacity: 0.55;
  background:
    radial-gradient(40% 55% at 25% 30%, rgba(16,163,127,0.45) 0%, transparent 60%),
    radial-gradient(40% 55% at 75% 25%, rgba(124,58,237,0.35) 0%, transparent 60%),
    radial-gradient(35% 50% at 55% 70%, rgba(219,39,119,0.30) 0%, transparent 60%);
  animation: aurora-shift 12s ease-in-out infinite alternate;
}
[data-theme="dark"] .welcome-aurora { opacity: 0.4; }
@keyframes aurora-shift {
  0%   { transform: translate3d(-2%, -1%, 0) scale(1); }
  50%  { transform: translate3d(2%, 1%, 0) scale(1.05); }
  100% { transform: translate3d(-1%, 2%, 0) scale(1); }
}

.welcome > *:not(.welcome-aurora) { position: relative; z-index: 1; }

.welcome-logo {
  width: 62px;
  height: 62px;
  border-radius: 18px;
  background: linear-gradient(135deg, #10a37f 0%, #7c3aed 60%, #db2777 100%);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 20px;
  box-shadow: 0 10px 30px rgba(124,58,237,0.25), 0 4px 10px rgba(16,163,127,0.2);
  position: relative;
}
.welcome-logo::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(180deg, rgba(255,255,255,0.25), rgba(255,255,255,0));
  pointer-events: none;
}
.welcome-title {
  margin: 0;
  font-size: 28px;
  font-weight: 600;
  letter-spacing: -0.02em;
}
.welcome-title span {
  background: linear-gradient(135deg, #10a37f 0%, #7c3aed 55%, #db2777 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.welcome-sub {
  margin: 10px 0 32px;
  color: var(--text-muted);
  font-size: 13.5px;
}
.welcome-sub code {
  background: var(--bg-alt);
  padding: 2px 7px;
  border-radius: 5px;
  font-size: 12px;
  border: 1px solid var(--border-soft);
}
.welcome-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  max-width: 580px;
  width: 100%;
}
.suggest {
  display: flex;
  align-items: center;
  gap: 12px;
  text-align: left;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  cursor: pointer;
  transition: transform 0.2s cubic-bezier(0.2, 0.8, 0.2, 1),
              border-color 0.15s, box-shadow 0.2s, background 0.15s;
  font-family: inherit;
  color: var(--text);
}
.suggest:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}
.suggest-icon {
  width: 34px;
  height: 34px;
  flex-shrink: 0;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent-soft);
  color: var(--accent);
  transition: background 0.15s, color 0.15s;
}
.suggest:hover .suggest-icon {
  background: var(--accent);
  color: #fff;
}
.suggest-text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.suggest-title {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text);
}
.suggest-desc {
  font-size: 12.5px;
  color: var(--text-muted);
  line-height: 1.45;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
}

/* ---- 侧栏时间分组 ---- */
.conv-group {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 14px 12px 4px;
  user-select: none;
}
.conv-group:first-child { padding-top: 6px; }

/* ---- Messages ---- */
.msg {
  display: flex;
  gap: 14px;
  animation: fade-up 0.25s ease;
}
.msg .avatar {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}
.msg .avatar::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(255,255,255,0.22), rgba(255,255,255,0) 55%);
  pointer-events: none;
}
.msg.user .avatar { background: var(--user-avatar); }
.msg.assistant .avatar { background: var(--ai-avatar); }

.msg .body {
  flex: 1;
  min-width: 0;
  padding-top: 4px;
}
.msg .role {
  font-size: 12.5px;
  color: var(--text-muted);
  margin-bottom: 4px;
  font-weight: 600;
  letter-spacing: 0.01em;
}
.msg .content {
  word-wrap: break-word;
  overflow-wrap: break-word;
  font-size: 15px;
  line-height: 1.7;
  color: var(--text-soft);
}
.msg.user .content {
  background: var(--user-bubble);
  border: 1px solid var(--user-bubble-border);
  padding: 10px 14px;
  border-radius: 14px 14px 14px 4px;
  display: inline-block;
  max-width: 100%;
  color: var(--text);
}

/* Typing dots */
.typing-dots {
  display: inline-flex;
  gap: 5px;
  padding: 6px 2px;
}
.typing-dots span {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--text-muted);
  animation: dot-bounce 1.2s infinite ease-in-out;
}
.typing-dots span:nth-child(2) { animation-delay: 0.15s; }
.typing-dots span:nth-child(3) { animation-delay: 0.3s; }
@keyframes dot-bounce {
  0%,60%,100% { transform: translateY(0); opacity: 0.5; }
  30%         { transform: translateY(-5px); opacity: 1; }
}

.msg .actions {
  margin-top: 8px;
  display: flex;
  gap: 4px;
  opacity: 0;
  transition: opacity 0.2s;
}
.msg:hover .actions { opacity: 1; }
.msg .actions button {
  background: var(--bg-elev);
  border: 1px solid var(--border-soft);
  color: var(--text-muted);
  padding: 4px 9px;
  font-size: 12px;
  border-radius: 7px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: background 0.12s, color 0.12s, border-color 0.12s, transform 0.1s;
  font-family: inherit;
}
.msg .actions button:hover {
  background: var(--bg-alt);
  color: var(--text);
  border-color: var(--border);
}
.msg .actions button:active { transform: scale(0.96); }
.msg .actions button svg { opacity: 0.85; }
.msg .stats {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 6px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  opacity: 0.8;
}

.cursor::after {
  content: "▍";
  display: inline-block;
  animation: blink 1.1s infinite;
  color: var(--accent);
  margin-left: 2px;
  font-weight: 300;
}
@keyframes blink {
  0%, 49% { opacity: 1; }
  50%, 100% { opacity: 0; }
}

/* ---- Markdown ---- */
.content h1, .content h2, .content h3, .content h4 {
  margin: 1em 0 0.4em;
  line-height: 1.3;
  font-weight: 600;
  color: var(--text);
}
.content h1 { font-size: 1.5em; }
.content h2 { font-size: 1.3em; }
.content h3 { font-size: 1.15em; }
.content p { margin: 0.55em 0; }
.content ul, .content ol { padding-left: 1.6em; margin: 0.55em 0; }
.content li { margin: 0.2em 0; }
.content blockquote {
  border-left: 3px solid var(--accent);
  padding: 4px 14px;
  color: var(--text-muted);
  margin: 0.6em 0;
  background: var(--accent-soft);
  border-radius: 0 6px 6px 0;
}
.content code {
  background: var(--code-bg);
  border: 1px solid var(--code-border);
  padding: 1px 6px;
  border-radius: 5px;
  font-size: 0.88em;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  color: var(--text);
}
.content pre {
  background: var(--code-bg);
  border: 1px solid var(--code-border);
  border-radius: 10px;
  padding: 14px 16px;
  overflow-x: auto;
  position: relative;
  margin: 0.8em 0;
  line-height: 1.55;
}
.content pre code {
  background: transparent;
  border: none;
  padding: 0;
  border-radius: 0;
  font-size: 13px;
}
.content pre .copy-code {
  position: absolute;
  top: 8px;
  right: 8px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 3px 10px;
  border-radius: 6px;
  font-size: 11px;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s, color 0.15s, border-color 0.15s;
  font-family: inherit;
}
.content pre:hover .copy-code { opacity: 1; }
.content pre .copy-code:hover {
  color: var(--text);
  border-color: var(--border-strong);
}
.content table {
  border-collapse: collapse;
  margin: 0.6em 0;
  display: block;
  overflow-x: auto;
  border-radius: 8px;
}
.content th, .content td {
  border: 1px solid var(--border);
  padding: 7px 11px;
}
.content th { background: var(--bg-alt); font-weight: 600; }
.content a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color 0.15s;
}
.content a:hover { border-bottom-color: var(--accent); }
.content hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 1.2em 0;
}

/* ========== Composer ========== */
#composer {
  padding: 10px 20px 18px;
  flex-shrink: 0;
  background: linear-gradient(to bottom, transparent 0%, var(--bg) 30%);
  position: relative;
}
.composer-inner {
  max-width: 780px;
  margin: 0 auto;
}
.composer-row {
  display: flex;
  gap: 8px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 10px 10px 10px 14px;
  align-items: flex-end;
  transition: border-color 0.15s, box-shadow 0.15s;
  box-shadow: var(--shadow-sm);
}
.composer-row:focus-within {
  border-color: var(--accent);
  box-shadow: var(--shadow-focus);
}
.composer-input {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text);
  font-family: inherit;
  font-size: 15px;
  line-height: 1.55;
  resize: none;
  max-height: 200px;
  min-height: 26px;
  outline: none;
  padding: 6px 2px;
}
.composer-input::placeholder { color: var(--text-muted); }
.btn-send {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.composer-hint {
  font-size: 11.5px;
  color: var(--text-muted);
  text-align: center;
  margin-top: 10px;
  min-height: 14px;
  letter-spacing: 0.01em;
}
.composer-hint kbd {
  display: inline-block;
  padding: 1px 6px;
  font-family: "JetBrains Mono", ui-monospace, Menlo, monospace;
  font-size: 10.5px;
  color: var(--text-soft);
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 5px;
  line-height: 1.3;
}

/* ========== Buttons ========== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid transparent;
  font-size: 14px;
  font-family: inherit;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s, transform 0.1s;
  background: transparent;
  color: var(--text);
  white-space: nowrap;
  user-select: none;
}
.btn:active:not(:disabled) { transform: scale(0.97); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  box-shadow: 0 1px 0 rgba(255,255,255,0.15) inset, var(--shadow-sm);
}
.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}
.btn-send.btn-primary {
  background: linear-gradient(135deg, var(--accent) 0%, #2ec4b6 100%);
  border: none;
}
.btn-send.btn-primary:hover:not(:disabled) {
  background: linear-gradient(135deg, var(--accent-hover) 0%, #28b4a6 100%);
}
.btn-secondary {
  background: var(--bg-alt);
  border-color: var(--border);
  color: var(--text);
}
.btn-secondary:hover:not(:disabled) {
  background: var(--bg-elev);
  border-color: var(--border-strong);
}
.btn-ghost { background: transparent; color: var(--text-soft); }
.btn-ghost:hover:not(:disabled) {
  background: var(--sidebar-hover);
  color: var(--text);
}
.btn-danger {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
}
.btn-danger:hover:not(:disabled) {
  background: var(--danger-hover);
  border-color: var(--danger-hover);
}
.btn-icon {
  padding: 0;
  width: 34px;
  height: 34px;
}

/* ========== Modal ========== */
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fade 0.15s ease;
}
.modal.hidden { display: none; }
@keyframes fade {
  from { opacity: 0; }
  to   { opacity: 1; }
}
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.45);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.modal-dialog {
  position: relative;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: min(680px, 94vw);
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  animation: slide-up 0.22s cubic-bezier(0.25, 1, 0.5, 1);
}
@keyframes slide-up {
  from { transform: translateY(14px); opacity: 0; }
  to   { transform: translateY(0); opacity: 1; }
}
.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-soft);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-header h3 { margin: 0; font-size: 16px; font-weight: 600; }
.modal-body {
  padding: 18px 20px;
  overflow-y: auto;
  flex: 1;
}
.modal-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border-soft);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* ========== Form ========== */
.form-group { margin-bottom: 16px; }
.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text-soft);
}
.form-group label .val {
  color: var(--accent);
  font-weight: 500;
  margin-left: 6px;
  font-family: ui-monospace, Menlo, monospace;
  font-size: 12px;
}
.form-group input[type="text"],
.form-group input[type="password"],
.form-group input[type="number"],
.form-group textarea,
.form-group select {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.form-group input:focus, .form-group textarea:focus {
  border-color: var(--accent);
  box-shadow: var(--shadow-focus);
}
.form-group textarea { resize: vertical; min-height: 84px; line-height: 1.55; }

.form-group input[type="range"] {
  width: 100%;
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  background: var(--border);
  border-radius: 999px;
  outline: none;
}
.form-group input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: transform 0.1s;
}
.form-group input[type="range"]::-webkit-slider-thumb:hover { transform: scale(1.15); }
.form-group input[type="range"]::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border: none;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
}

.form-group input[type="checkbox"] {
  width: 16px; height: 16px;
  accent-color: var(--accent);
  margin-right: 6px;
  vertical-align: -3px;
}

.form-group small {
  color: var(--text-muted);
  font-size: 12px;
  display: block;
  margin-top: 5px;
  line-height: 1.5;
}
.form-group code {
  font-size: 12px;
  background: var(--bg-alt);
  padding: 1px 5px;
  border-radius: 4px;
  border: 1px solid var(--border-soft);
}
.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.row-gap {
  display: flex;
  gap: 8px;
  align-items: center;
}
details {
  margin: 12px 0 16px;
  padding: 4px 0;
  border-top: 1px solid var(--border-soft);
}
details summary {
  cursor: pointer;
  padding: 10px 0;
  font-weight: 600;
  font-size: 13px;
  color: var(--text);
  user-select: none;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 6px;
}
details summary::before {
  content: "▸";
  transition: transform 0.15s;
  color: var(--text-muted);
  font-size: 10px;
}
details[open] summary::before { transform: rotate(90deg); }

/* ========== Toast ========== */
.toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-elev);
  border: 1px solid var(--border);
  padding: 10px 18px;
  border-radius: 999px;
  box-shadow: var(--shadow-lg);
  z-index: 200;
  font-size: 13.5px;
  animation: slide-up 0.2s ease;
}
.toast.hidden { display: none; }
.toast.error {
  border-color: var(--danger);
  color: var(--danger);
}

/* ========== Scrollbar ========== */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 999px;
  border: 2px solid transparent;
  background-clip: padding-box;
}
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); background-clip: padding-box; }

/* ========== Responsive ========== */
@media (max-width: 768px) {
  :root { --sidebar-width: 260px; }
  #sidebar {
    position: absolute;
    height: 100%;
    z-index: 50;
    box-shadow: var(--shadow-lg);
  }
  .topbar-actions .model-select { max-width: 120px; }
  .grid-2, .welcome-grid { grid-template-columns: 1fr; }
  .messages, .composer-inner { padding-left: 16px; padding-right: 16px; }
  .welcome { padding-top: 40px; }
  .welcome-title { font-size: 22px; }
}
