:root {
  color-scheme: dark;
  --sidebar-bg: #0c111d;
  --main-bg: #141925;
  --card-bg: rgba(255, 255, 255, 0.03);
  --card-border: rgba(255, 255, 255, 0.08);
  --border-weak: rgba(255, 255, 255, 0.08);
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 12px;
  --accent: #7c6cff;
  --accent-2: #3f8cff;
  --text-subtle: rgba(226, 232, 240, 0.6);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--main-bg);
  color: #f4f7ff;
  font-family: 'Inter', 'Noto Sans SC', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 15px;
  line-height: 1.76;
  font-weight: 400;
}

.app-shell {
  background: var(--main-bg);
}

.app-layout {
  position: relative;
  display: flex;
  height: 100vh;
  overflow: hidden;
}

.app-sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 30;
  width: 280px;
  min-width: 220px;
  max-width: 460px;
  transform: translateX(-100%);
  border-right: 1px solid rgba(148, 163, 184, 0.28);
  box-shadow: 10px 0 30px rgba(2, 6, 23, 0.45), 1px 0 0 rgba(124, 108, 255, 0.36);
  background: var(--sidebar-bg);
  padding: 16px;
  transition: transform 180ms ease;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.sidebar-history {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding-top: 8px;
}

.sidebar-fixed-top {
  position: sticky;
  top: 0;
  z-index: 2;
  padding-bottom: 12px;
  background: linear-gradient(to bottom, rgba(12, 17, 29, 0.98), rgba(12, 17, 29, 0.9));
  border-bottom: 1px solid rgba(148, 163, 184, 0.18);
}

.sidebar-fixed-bottom {
  position: sticky;
  bottom: 0;
  z-index: 2;
  padding-top: 10px;
  background: linear-gradient(to top, rgba(12, 17, 29, 0.98), rgba(12, 17, 29, 0.9));
  border-top: 1px solid rgba(148, 163, 184, 0.18);
}

.sidebar-account {
  border: 1px solid rgba(148, 163, 184, 0.26);
  border-radius: 12px;
  background: rgba(15, 23, 42, 0.4);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
}

.sidebar-account-avatar {
  width: 28px;
  height: 28px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(124, 108, 255, 0.55);
  background: rgba(124, 108, 255, 0.2);
  color: #eef2ff;
  font-size: 12px;
  font-weight: 700;
}

.sidebar-account-meta {
  display: flex;
  flex-direction: column;
  line-height: 1.3;
}

.sidebar-account-meta strong {
  font-size: 13px;
  font-weight: 600;
}

.sidebar-account-meta span {
  color: rgba(203, 213, 225, 0.68);
  font-size: 12px;
}

.app-sidebar.is-open {
  transform: translateX(0);
}

.sidebar-resize-handle {
  display: none;
  width: 6px;
  cursor: col-resize;
  background: linear-gradient(to right, rgba(124, 108, 255, 0.35), transparent);
}

.app-main {
  min-width: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  background: radial-gradient(1200px 500px at 50% -20%, rgba(124, 108, 255, 0.1), transparent), var(--main-bg);
}

.app-header {
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.15);
  background: rgba(15, 20, 32, 0.92);
  padding: 10px 14px;
  backdrop-filter: blur(8px);
}

.header-brand {
  display: inline-flex;
  align-items: center;
  border: 1px solid rgba(148, 163, 184, 0.24);
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.45);
  padding: 3px 10px;
  font-size: 13px;
  color: #dbeafe;
}

.model-badge {
  margin-left: auto;
  border: 1px solid var(--border-weak);
  background: linear-gradient(120deg, rgba(124, 108, 255, 0.16), rgba(63, 140, 255, 0.12));
  border-radius: var(--radius-sm);
  padding: 4px 12px;
  font-size: 12px;
  color: #dbeafe;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}

.model-badge:hover {
  border-color: rgba(124, 108, 255, 0.6);
  box-shadow: 0 0 0 2px rgba(124, 108, 255, 0.16);
}

.model-badge-prefix {
  color: rgba(203, 213, 225, 0.75);
  font-size: 11px;
}

.field-label {
  margin-bottom: 6px;
  display: block;
  font-size: 11px;
  color: rgba(203, 213, 225, 0.55);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 500;
}

.field-input {
  width: 100%;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-weak);
  background: rgba(15, 23, 42, 0.4);
  color: #edf2ff;
  padding: 8px 10px;
  outline: none;
  transition: border-color 150ms ease, box-shadow 150ms ease;
}

.field-input:focus {
  border-color: rgba(124, 108, 255, 0.9);
  box-shadow: 0 0 0 2px rgba(124, 108, 255, 0.35);
}

.history-search-input {
  border-color: rgba(148, 163, 184, 0.38);
  background: rgba(15, 23, 42, 0.58);
}

.history-search-input:focus {
  border-color: rgba(124, 108, 255, 0.92);
  box-shadow: 0 0 0 3px rgba(124, 108, 255, 0.22);
}

.model-switch {
  position: relative;
}

.model-switch-btn {
  width: 100%;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-weak);
  background: rgba(15, 23, 42, 0.4);
  color: #edf2ff;
  height: 36px;
  padding: 6px 10px;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  cursor: pointer;
}

.model-switch-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.model-switch-btn:hover {
  border-color: rgba(124, 108, 255, 0.56);
}

.model-switch-btn[aria-expanded='true'] {
  border-color: rgba(124, 108, 255, 0.9);
  box-shadow: 0 0 0 2px rgba(124, 108, 255, 0.25);
}

.model-switch-caret {
  color: rgba(203, 213, 225, 0.8);
  font-size: 12px;
}

.model-switch-menu {
  position: absolute;
  z-index: 40;
  left: 0;
  right: 0;
  top: calc(100% + 6px);
  border: 1px solid var(--border-weak);
  border-radius: var(--radius-md);
  background: rgba(15, 23, 42, 0.98);
  box-shadow: 0 10px 24px rgba(2, 6, 23, 0.55);
  max-height: 260px;
  overflow: auto;
  padding: 6px;
}

.model-switch-group + .model-switch-group {
  margin-top: 8px;
  border-top: 1px solid rgba(148, 163, 184, 0.16);
  padding-top: 6px;
}

.model-switch-group-label {
  font-size: 11px;
  color: rgba(203, 213, 225, 0.62);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 2px 4px 4px;
}

.model-switch-option {
  width: 100%;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: #e2e8f0;
  text-align: left;
  font-size: 13px;
  padding: 6px 8px;
  cursor: pointer;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.model-switch-option:hover {
  background: rgba(124, 108, 255, 0.18);
}

.model-switch-option.active {
  border-color: rgba(124, 108, 255, 0.56);
  background: rgba(124, 108, 255, 0.2);
  color: #f8fafc;
}

.new-chat-btn,
.ghost-btn,
.send-btn,
.msg-action-btn,
.copy-code-btn,
.code-lang-chip,
.history-item-btn,
.scroll-bottom-btn {
  transition: all 150ms ease;
}

.new-chat-btn {
  margin-top: 0;
  border: 1px solid var(--border-weak);
  border-radius: var(--radius-sm);
  background: rgba(15, 23, 42, 0.45);
  color: #eef2ff;
  padding: 9px 12px;
  font-size: 14px;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  line-height: 1;
}

.new-chat-btn:hover {
  transform: translateY(-1px);
  border-color: rgba(124, 108, 255, 0.65);
  background: rgba(124, 108, 255, 0.16);
}

.new-chat-icon {
  width: 18px;
  height: 18px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-weak);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  margin-top: -1px;
  font-size: 12px;
}

.ghost-btn,
.ghost-link {
  border: 1px solid var(--border-weak);
  border-radius: var(--radius-sm);
  background: rgba(15, 23, 42, 0.35);
  color: #dbeafe;
  padding: 4px 8px;
  font-size: 12px;
}

.ghost-link {
  border: 0;
  background: transparent;
  padding: 0;
  color: #fcd34d;
}

.ghost-btn:hover,
.ghost-link:hover {
  color: #ffffff;
}

.model-tooltip {
  margin-top: 8px;
  border-radius: 10px;
  border: 1px solid rgba(148, 163, 184, 0.3);
  background: rgba(15, 23, 42, 0.7);
  color: #dbeafe;
  font-size: 12px;
  padding: 7px 9px;
  white-space: pre-line;
}

.history-list {
  margin: 0;
  padding: 0 0 6px;
  list-style: none;
  overflow: auto;
  min-height: 0;
  flex: 1 1 auto;
}

.history-item {
  position: relative;
  margin-bottom: 6px;
}

.history-item-row {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
}

.history-group-label {
  margin: 12px 2px 8px;
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(203, 213, 225, 0.52);
}

.history-item-btn {
  width: 100%;
  text-align: left;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-weak);
  background: rgba(255, 255, 255, 0.02);
  color: #f1f5f9;
  padding: 9px 10px;
  font-size: 14px;
  font-weight: 500;
}

.history-item-rename-input {
  width: 100%;
  border-radius: var(--radius-md);
  border: 1px solid rgba(124, 108, 255, 0.7);
  background: rgba(15, 23, 42, 0.5);
  color: #eef2ff;
  padding: 9px 10px;
  font-size: 14px;
  outline: none;
  box-shadow: 0 0 0 2px rgba(124, 108, 255, 0.2);
}

.history-item-menu-wrap {
  position: relative;
  flex: 0 0 auto;
}

.history-item-menu-btn {
  width: 28px;
  height: 28px;
  border: 1px solid var(--border-weak);
  border-radius: var(--radius-sm);
  background: rgba(15, 23, 42, 0.35);
  color: #cbd5e1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0;
  transition: opacity 150ms ease, border-color 150ms ease, background-color 150ms ease, color 150ms ease;
}

.history-item:hover .history-item-menu-btn,
.history-item:focus-within .history-item-menu-btn,
.history-item-menu-wrap.open .history-item-menu-btn {
  opacity: 1;
}

.history-item-menu-btn:hover {
  border-color: rgba(124, 108, 255, 0.5);
  background: rgba(124, 108, 255, 0.16);
  color: #f8fafc;
}

.history-item-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  min-width: 110px;
  border: 1px solid rgba(148, 163, 184, 0.3);
  border-radius: 10px;
  background: rgba(15, 23, 42, 0.95);
  box-shadow: 0 10px 24px rgba(2, 6, 23, 0.55);
  padding: 4px;
  z-index: 20;
}

.history-item-menu button {
  width: 100%;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #e2e8f0;
  text-align: left;
  font-size: 13px;
  padding: 6px 8px;
  cursor: pointer;
}

.history-item-menu button:hover {
  background: rgba(124, 108, 255, 0.2);
}

.history-item-btn:hover {
  border-color: rgba(99, 102, 241, 0.45);
  background: linear-gradient(90deg, rgba(124, 108, 255, 0.16), rgba(63, 140, 255, 0.09));
}

.history-item.active .history-item-btn {
  border-color: rgba(124, 108, 255, 0.55);
  background: rgba(124, 108, 255, 0.14);
}

.history-item.active::before {
  content: '';
  position: absolute;
  left: -2px;
  top: 8px;
  bottom: 8px;
  width: 2px;
  background: linear-gradient(to bottom, var(--accent), var(--accent-2));
  border-radius: 999px;
}

.history-skeleton {
  height: 38px;
  border-radius: 12px;
  background: linear-gradient(90deg, rgba(51, 65, 85, 0.35), rgba(100, 116, 139, 0.35), rgba(51, 65, 85, 0.35));
  background-size: 220% 100%;
  animation: shimmer 1.2s linear infinite;
  margin-bottom: 8px;
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.messages {
  flex: 1;
  min-height: 0;
  overflow: auto;
  width: 100%;
  max-width: 1020px;
  margin: 0 auto;
  padding: 18px 18px 100px;
  scroll-behavior: smooth;
}

.message-row {
  margin-bottom: 16px;
  display: flex;
}

.message-row.user {
  justify-content: flex-end;
}

.message-row.assistant,
.message-row.system {
  justify-content: flex-start;
}

.message-bubble {
  max-width: min(860px, 90%);
  border-radius: var(--radius-md);
  border: 1px solid var(--card-border);
  background: var(--card-bg);
  padding: 11px 13px;
}

.message-row.user .message-bubble {
  background: linear-gradient(120deg, rgba(81, 95, 255, 0.38), rgba(42, 117, 255, 0.34));
  border-color: rgba(147, 197, 253, 0.34);
}

.inline-message-editor {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.inline-message-editor-input {
  width: 100%;
  resize: vertical;
  min-height: 88px;
  border-radius: 10px;
  border: 1px solid rgba(147, 197, 253, 0.5);
  background: rgba(15, 23, 42, 0.45);
  color: #eef2ff;
  padding: 8px 10px;
  outline: none;
}

.inline-message-editor-input:focus {
  border-color: rgba(124, 108, 255, 0.85);
  box-shadow: 0 0 0 2px rgba(124, 108, 255, 0.25);
}

.inline-message-editor-controls {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.inline-message-editor-confirm,
.inline-message-editor-cancel {
  border-radius: 8px;
  padding: 5px 10px;
  font-size: 12px;
  cursor: pointer;
  transition: all 150ms ease;
}

.inline-message-editor-confirm {
  border: 1px solid rgba(124, 108, 255, 0.6);
  background: rgba(124, 108, 255, 0.2);
  color: #f8fafc;
}

.inline-message-editor-confirm:hover {
  background: rgba(124, 108, 255, 0.3);
}

.inline-message-editor-cancel {
  border: 1px solid rgba(148, 163, 184, 0.5);
  background: rgba(15, 23, 42, 0.45);
  color: #e2e8f0;
}

.inline-message-editor-cancel:hover {
  border-color: rgba(203, 213, 225, 0.7);
  color: #ffffff;
}

.assistant-wrap {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  width: min(900px, 94%);
}

.ai-avatar {
  width: 22px;
  height: 22px;
  border-radius: 999px;
  background: linear-gradient(135deg, rgba(124, 108, 255, 0.32), rgba(63, 140, 255, 0.24));
  border: 1px solid rgba(124, 108, 255, 0.5);
  margin-top: 4px;
  position: relative;
}

.ai-avatar::before {
  content: '✦';
  position: absolute;
  inset: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  color: #eef2ff;
}

.message-panel {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.assistant-panel {
  width: min(860px, 90%);
}

.assistant-panel.is-error .message-actions {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.user-panel {
  width: min(860px, 90%);
  align-items: flex-end;
}

.assistant-content {
  min-width: 0;
  border-radius: var(--radius-md);
  border: 0;
  background: transparent;
  padding: 2px 2px 4px;
}

.assistant-content-error {
  border: 1px solid rgba(248, 113, 113, 0.35);
  background: rgba(127, 29, 29, 0.14);
  padding: 8px 10px;
}

.assistant-text {
  word-break: break-word;
  padding-top: 2px;
}

.assistant-error-text {
  color: #fecaca;
  white-space: pre-wrap;
}

.assistant-text-streaming {
  white-space: pre-wrap;
}

.assistant-thinking-dots {
  display: inline-flex;
  gap: 4px;
  margin-right: 4px;
}

.assistant-thinking-dots i {
  width: 5px;
  height: 5px;
  border-radius: 999px;
  background: rgba(226, 232, 240, 0.75);
  animation: thinking-dot 1.1s ease-in-out infinite;
}

.assistant-thinking-dots i:nth-child(2) { animation-delay: 120ms; }
.assistant-thinking-dots i:nth-child(3) { animation-delay: 240ms; }

@keyframes thinking-dot {
  0%, 80%, 100% { opacity: 0.35; transform: translateY(0); }
  40% { opacity: 1; transform: translateY(-2px); }
}

.assistant-markdown {
  word-break: break-word;
}

.markdown-body {
  line-height: 1.72;
  word-break: break-word;
}

.markdown-body > :first-child { margin-top: 0; }
.markdown-body > :last-child { margin-bottom: 0; }
.markdown-body p { margin: 0.72em 0; }
.markdown-body ul,
.markdown-body ol { margin: 0.55em 0 0.85em; padding-left: 1.35em; }
.markdown-body li + li { margin-top: 0.28em; }
.markdown-body h1,
.markdown-body h2,
.markdown-body h3 {
  margin: 1em 0 0.55em;
  line-height: 1.45;
  font-weight: 500;
}
.markdown-body blockquote {
  margin: 0.6em 0;
  border-left: 3px solid rgba(124, 108, 255, 0.55);
  background: rgba(124, 108, 255, 0.08);
  padding: 0.45em 0.7em;
  border-radius: 0 8px 8px 0;
  color: #dbeafe;
}
.markdown-body a {
  color: #93c5fd;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.markdown-body a:hover {
  color: #bfdbfe;
}

.markdown-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 0.8em 0;
  font-size: 13px;
  line-height: 1.7;
}

.markdown-body thead tr {
  background: rgba(255, 255, 255, 0.05);
}

.markdown-body th,
.markdown-body td {
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 8px 10px;
  text-align: left;
  vertical-align: top;
}

.markdown-body pre {
  margin: 0.8em 0;
  border-radius: 10px;
  border: 1px solid rgba(148, 163, 184, 0.25);
  background: rgba(2, 6, 23, 0.78);
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
}

.code-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.2);
  padding: 6px 8px;
  background: rgba(30, 41, 59, 0.6);
}

.code-lang-chip {
  border: 1px solid rgba(148, 163, 184, 0.35);
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.65);
  color: #e2e8f0;
  font-size: 11px;
  padding: 2px 8px;
}

.copy-code-btn {
  border: 1px solid rgba(148, 163, 184, 0.45);
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.75);
  color: #e2e8f0;
  font-size: 11px;
  padding: 2px 8px;
  cursor: pointer;
}

.copy-code-btn:hover { filter: brightness(1.1); }

.markdown-body pre code {
  display: block;
  padding: 10px 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New', monospace;
  font-size: 13px;
  white-space: pre;
  min-width: max-content;
}

.message-actions {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
  opacity: 0;
  transform: translateY(2px);
  pointer-events: none;
  transition: opacity 140ms ease, transform 140ms ease;
}

.assistant-actions {
  padding-left: 2px;
}

.user-actions {
  justify-content: flex-end;
}

.message-row:hover .message-actions,
.message-row:focus-within .message-actions,
.message-actions.persistent {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.msg-action-btn {
  border: 1px solid var(--border-weak);
  border-radius: var(--radius-sm);
  background: rgba(15, 23, 42, 0.32);
  color: rgba(255, 255, 255, 0.45);
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  cursor: pointer;
}

.msg-action-btn:hover {
  color: rgba(255, 255, 255, 0.85);
  border-color: rgba(147, 197, 253, 0.5);
  background: rgba(30, 41, 59, 0.42);
}

.msg-action-icon {
  width: 15px;
  height: 15px;
  display: inline-flex;
}

.msg-action-icon svg {
  width: 100%;
  height: 100%;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.msg-action-btn.active {
  color: #ffffff;
  border-color: rgba(124, 108, 255, 0.7);
  background: rgba(124, 108, 255, 0.25);
}

@media (hover: none) {
  .message-actions {
    opacity: 1;
    transform: none;
    pointer-events: auto;
  }
}

.streaming-cursor {
  display: inline-block;
  width: 8px;
  margin-left: 2px;
  opacity: 0.9;
  animation: blink 0.95s steps(1, start) infinite;
}

@keyframes blink {
  0%, 49% { opacity: 1; }
  50%, 100% { opacity: 0; }
}

.empty-state {
  width: min(700px, 92%);
  margin: 58px auto 0;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-weak);
  background: linear-gradient(160deg, rgba(15, 23, 42, 0.62), rgba(15, 23, 42, 0.38));
  box-shadow: 0 22px 38px rgba(2, 6, 23, 0.32);
  color: #cbd5e1;
  padding: 22px;
}

.empty-state-title {
  margin: 0;
  font-size: 24px;
  line-height: 1.3;
}

.empty-state-desc {
  margin: 8px 0 14px;
  color: var(--text-subtle);
}

.empty-quick-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.empty-quick-btn {
  border: 1px solid rgba(148, 163, 184, 0.45);
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.78);
  color: #f1f5f9;
  font-size: 13px;
  font-weight: 520;
  padding: 7px 12px;
  cursor: pointer;
  transition: all 150ms ease;
}

.empty-quick-btn:hover {
  border-color: rgba(124, 108, 255, 0.6);
  background: rgba(124, 108, 255, 0.24);
}

.composer-wrap {
  background: transparent;
  padding: 10px 14px 14px;
}

.settings-drawer-overlay {
  position: fixed;
  inset: 0;
  z-index: 44;
  background: rgba(2, 6, 23, 0.55);
}

.settings-drawer {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 45;
  width: min(360px, 92vw);
  height: 100vh;
  border-left: 1px solid var(--border-weak);
  border-radius: var(--radius-lg) 0 0 var(--radius-lg);
  background: #0f1624;
  box-shadow: -16px 0 36px rgba(2, 6, 23, 0.55);
  transform: translateX(100%);
  transition: transform 220ms ease;
  display: flex;
  flex-direction: column;
}

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

.settings-drawer-header {
  border-bottom: 1px solid var(--border-weak);
  padding: 10px 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.settings-drawer-header strong {
  font-size: 13px;
  font-weight: 600;
  color: #e2e8f0;
}

.settings-drawer-body {
  overflow: auto;
  padding: 10px 12px 14px;
}

.settings-group + .settings-group {
  margin-top: 10px;
}

.settings-group-title {
  margin: 0 0 8px;
  font-size: 12px;
  font-weight: 600;
  color: #cbd5e1;
}

.session-prompt-input {
  border-color: var(--border-weak);
  background: rgba(2, 6, 23, 0.42);
  padding: 10px 12px;
}

.api-config-section {
  border-top: 1px solid var(--border-weak);
  padding: 0;
}

.api-config-title {
  margin: 0 0 8px;
  font-size: 12px;
  font-weight: 600;
  color: #cbd5e1;
}

.api-source-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 10px;
}

.api-source-item {
  border: 1px solid var(--border-weak);
  background: rgba(15, 23, 42, 0.45);
  border-radius: var(--radius-md);
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.api-source-item.active {
  border-color: rgba(124, 108, 255, 0.7);
  box-shadow: 0 0 0 2px rgba(124, 108, 255, 0.18);
}

.api-source-item strong {
  font-size: 12px;
  font-weight: 500;
}

.api-source-item span {
  font-size: 11px;
  color: rgba(203, 213, 225, 0.75);
}

.api-source-item-actions {
  margin-top: 4px;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.api-config-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.api-config-actions {
  display: flex;
  gap: 8px;
}

.vm-command-section {
  border-top: 1px solid var(--border-weak);
  padding: 8px 0 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.vm-command-desc {
  margin: 0;
  font-size: 12px;
  color: rgba(203, 213, 225, 0.76);
}

.vm-command-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.vm-command-status {
  font-size: 12px;
  color: rgba(203, 213, 225, 0.76);
}

.vm-command-status.status-pending {
  color: #93c5fd;
}

.vm-command-status.status-ok {
  color: #86efac;
}

.vm-command-status.status-warn {
  color: #fcd34d;
}

.vm-command-status.status-deny {
  color: #fca5a5;
}

.vm-approval-panel {
  border: 1px solid rgba(251, 191, 36, 0.35);
  background: rgba(120, 53, 15, 0.16);
  border-radius: var(--radius-md);
  padding: 8px 10px;
}

.vm-approval-reason {
  margin: 0 0 8px;
  font-size: 12px;
  color: #fde68a;
}

.vm-approval-actions {
  display: flex;
  gap: 8px;
}

.vm-command-output {
  margin: 0;
  max-height: 180px;
  overflow: auto;
  border: 1px solid var(--border-weak);
  border-radius: var(--radius-md);
  background: rgba(2, 6, 23, 0.6);
  color: #cbd5e1;
  padding: 8px 10px;
  font-size: 12px;
  line-height: 1.5;
  white-space: pre-wrap;
}

.composer-box {
  position: relative;
  max-width: 1100px;
  margin: 0 auto;
  border: 1px solid var(--border-weak);
  border-radius: var(--radius-lg);
  background: rgba(15, 23, 42, 0.68);
  box-shadow: 0 16px 28px rgba(2, 6, 23, 0.35);
  padding: 6px;
}

.composer-input {
  width: 100%;
  min-height: 64px;
  resize: none;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  background: transparent;
  color: #eef2ff;
  padding: 10px 88px 40px 12px;
  outline: none;
  transition: border-color 150ms ease, box-shadow 150ms ease;
}

.composer-input:focus {
  border-color: rgba(124, 108, 255, 0.72);
  box-shadow: 0 0 0 2px rgba(124, 108, 255, 0.22);
}

.composer-input::placeholder {
  color: rgba(203, 213, 225, 0.76);
}

.composer-settings-btn {
  position: absolute;
  right: 48px;
  bottom: 10px;
  width: 28px;
  height: 28px;
  border: 1px solid var(--border-weak);
  border-radius: var(--radius-sm);
  background: rgba(15, 23, 42, 0.52);
  color: #dbeafe;
  cursor: pointer;
}

.composer-settings-btn:hover,
.composer-settings-btn.active {
  border-color: rgba(124, 108, 255, 0.7);
  background: rgba(124, 108, 255, 0.22);
}

.composer-settings-btn.has-prompt::after {
  content: '';
  position: absolute;
  top: 5px;
  right: 5px;
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: #60a5fa;
}

.send-btn {
  position: absolute;
  right: 10px;
  bottom: 10px;
  width: 30px;
  height: 30px;
  border: 1px solid rgba(124, 108, 255, 0.52);
  border-radius: var(--radius-sm);
  background: linear-gradient(120deg, rgba(124, 108, 255, 0.85), rgba(63, 140, 255, 0.85));
  color: #ffffff;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.send-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 16px rgba(124, 108, 255, 0.36);
}

.send-btn:disabled {
  cursor: not-allowed;
  opacity: 0.45;
  box-shadow: none;
}

.send-btn svg {
  width: 15px;
  height: 15px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.composer-meta {
  position: absolute;
  left: 10px;
  right: 88px;
  bottom: 8px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0;
  pointer-events: none;
}

.hint-text,
.counter-text {
  font-size: 12px;
  color: var(--text-subtle);
}

.counter-text {
  margin-left: auto;
}

.composer-meta .ghost-link {
  pointer-events: auto;
}

.counter-text.over {
  color: #f87171;
}

.scroll-bottom-btn {
  position: absolute;
  right: 24px;
  bottom: 120px;
  border: 1px solid rgba(147, 197, 253, 0.45);
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.85);
  color: #e2e8f0;
  width: 34px;
  height: 34px;
  padding: 0;
  font-size: 15px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 12;
}

.scroll-bottom-btn:hover {
  border-color: rgba(124, 108, 255, 0.75);
  color: #ffffff;
}

.context-menu {
  position: fixed;
  z-index: 60;
  min-width: 130px;
  border-radius: 10px;
  border: 1px solid rgba(148, 163, 184, 0.35);
  background: rgba(15, 23, 42, 0.95);
  box-shadow: 0 10px 26px rgba(2, 6, 23, 0.65);
  padding: 4px;
}

.context-menu button {
  width: 100%;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #e2e8f0;
  text-align: left;
  font-size: 13px;
  padding: 6px 8px;
}

.context-menu button:hover {
  background: rgba(124, 108, 255, 0.25);
}

.hidden { display: none !important; }

@media (min-width: 768px) {
  .app-sidebar {
    position: static;
    transform: translateX(0);
    flex: 0 0 auto;
  }

  .sidebar-resize-handle {
    display: block;
  }
}
