:root {
  --background: 0 0% 10%;
  --secondary-bg: 0 0% 15%;
  --foreground: 0 0% 95%;
  --muted: 0 0% 20%;
  --muted-foreground: 0 0% 65%;
  --border: 0 0% 25%;
  --separator: 0 0% 18%;
  --accent: 211 100% 50%;
  --accent-foreground: 0 0% 100%;
  --success: 142 76% 45%;
  --destructive: 0 84% 60%;
  --warning: 32 95% 50%;
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --radius-full: 9999px;
  --sidebar-width: 195px;
  --aside-width: 340px;
  --ease-ios: cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease-smooth: cubic-bezier(0.4, 0.0, 0.2, 1);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  background: hsl(var(--background));
  color: hsl(var(--foreground));
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Helvetica Neue", sans-serif;
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.hidden { display: none !important; }

#login-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(40px) saturate(150%);
  -webkit-backdrop-filter: blur(40px) saturate(150%);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 100;
}

.login-panel {
  width: 420px;
  padding: 32px;
  background: rgba(25, 25, 30, 0.75);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 20px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.6), inset 0 1px 0 rgba(255,255,255,0.06);
  backdrop-filter: blur(50px) saturate(150%);
  -webkit-backdrop-filter: blur(50px) saturate(150%);
  text-align: center;
  animation: apple-scale-in 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes apple-scale-in {
  from { opacity: 0; transform: scale(0.96); }
  to { opacity: 1; transform: scale(1); }
}

.login-panel h1 {
  font-size: clamp(1.5rem, 3.5vw, 2rem);
  font-weight: 600;
  letter-spacing: -0.02em;
  margin-bottom: 8px;
  color: hsl(var(--foreground));
}

.login-panel .subtitle {
  color: hsl(var(--muted-foreground));
  margin-bottom: 24px;
  font-size: 14px;
}

.login-panel input {
  width: 100%;
  padding: 14px 16px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.08);
  background: rgba(255,255,255,0.06);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  font-size: 15px;
  outline: none;
  transition: all 0.2s cubic-bezier(0.4, 0.0, 0.2, 1);
  color: hsl(var(--foreground));
}
.login-panel input:focus {
  border-color: hsl(var(--accent));
  box-shadow: 0 0 0 4px hsl(var(--accent)/0.2);
  background: rgba(255,255,255,0.1);
}
.login-panel input::placeholder {
  color: hsl(var(--muted-foreground));
}

.login-panel button {
  background: hsl(var(--accent));
  color: hsl(var(--accent-foreground));
  border: none;
  padding: 14px;
  margin-top: 16px;
  border-radius: 12px;
  font-weight: 600;
  font-size: 15px;
  width: 100%;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.login-panel button:hover {
  transform: scale(1.02);
  box-shadow: 0 4px 24px hsl(var(--accent)/0.3);
}

#login-status {
  margin-top: 12px;
  font-size: 13px;
  color: hsl(var(--muted-foreground));
}

#app {
  display: flex;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
  background: hsl(var(--background));
}

#sidebar {
  width: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  padding: 16px;
  border-right: 1px solid rgba(255,255,255,0.06);
  background: rgba(20, 20, 25, 0.6);
  backdrop-filter: blur(30px) saturate(140%);
  -webkit-backdrop-filter: blur(30px) saturate(140%);
  flex-shrink: 0;
  height: 100vh;
}

.sidebar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}
.sidebar-header h2 {
  font-size: clamp(1rem, 2vw, 1.25rem);
  font-weight: 600;
  letter-spacing: -0.01em;
  color: hsl(var(--foreground));
}

.icon-btn {
  width: 34px;
  height: 34px;
  border-radius: 9999px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.06);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 16px;
  color: hsl(var(--foreground));
  transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.icon-btn:hover {
  background: rgba(255,255,255,0.12);
  transform: scale(1.05);
}

#chat-list {
  flex: 1;
  overflow-y: auto;
  padding-right: 4px;
}

::-webkit-scrollbar {
  width: 4px;
  height: 4px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.15);
  border-radius: 9999px;
  transition: all 0.2s cubic-bezier(0.4, 0.0, 0.2, 1);
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(255,255,255,0.3);
}

* {
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.15) transparent;
}

.chat-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  margin-bottom: 4px;
  border-radius: 12px;
  background: rgba(255,255,255,0.04);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  cursor: pointer;
  font-size: 13px;
  color: hsl(var(--foreground));
  transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.chat-item:hover {
  background: rgba(255,255,255,0.1);
  transform: translateX(2px);
}
.chat-item.active {
  background: rgba(255,255,255,0.12);
  backdrop-filter: blur(15px);
  -webkit-backdrop-filter: blur(15px);
  font-weight: 600;
  box-shadow: 0 1px 8px rgba(0,0,0,0.1);
}
.chat-item span {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.chat-item .delete-btn {
  background: transparent;
  border: none;
  color: rgba(255,255,255,0.2);
  cursor: pointer;
  font-size: 14px;
  padding: 0 4px;
  transition: all 0.2s;
}
.chat-item .delete-btn:hover {
  color: hsl(var(--destructive));
  transform: scale(1.2);
}

.sidebar-footer {
  border-top: 1px solid rgba(255,255,255,0.06);
  padding-top: 16px;
  margin-top: 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 80px;
}
.sidebar-footer span {
  font-size: 12px;
  color: hsl(var(--muted-foreground));
}
.logout-btn {
  background: rgba(255,59,48,0.12);
  color: hsl(var(--destructive));
  border: 1px solid rgba(255,59,48,0.2);
  padding: 6px 14px;
  border-radius: 9999px;
  font-size: 12px;
  cursor: pointer;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.logout-btn:hover {
  background: rgba(255,59,48,0.2);
  transform: scale(1.05);
}

#main-chat {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100vh;
  position: relative;
  min-width: 0;
  overflow: hidden;
  margin-right: var(--aside-width);
}

#messages {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  padding: 24px 16px 140px 24px;
  scroll-behavior: smooth;
}

.message-wrapper {
  display: flex;
  flex-direction: column;
  width: fit-content;
  max-width: 70%;
  margin-bottom: 8px;
}

.message-wrapper.user {
  margin-left: auto;
  align-items: flex-end;
}

.message-wrapper.bot {
  margin-right: auto;
  align-items: flex-start;
}

.message-wrapper.system {
  margin: 0 auto;
  align-items: center;
}

.message {
  padding: 12px 18px;
  border-radius: 18px;
  width: fit-content;
  line-height: 1.5;
  font-size: 15px;
  word-wrap: break-word;
  backdrop-filter: blur(30px) saturate(180%);
  -webkit-backdrop-filter: blur(30px) saturate(180%);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15), 0 1px 0 rgba(255, 255, 255, 0.08) inset, 0 -1px 0 rgba(0, 0, 0, 0.1) inset;
  border: 0.5px solid rgba(255, 255, 255, 0.08);
  transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.message.user {
  background: rgba(0, 122, 255, 0.65);
  color: #ffffff;
  border-bottom-right-radius: 6px;
  border-top-right-radius: 18px;
  border-bottom-left-radius: 18px;
  border-top-left-radius: 18px;
  box-shadow: 0 4px 24px rgba(0, 122, 255, 0.3), 0 1px 0 rgba(255, 255, 255, 0.15) inset, 0 -1px 0 rgba(0, 0, 0, 0.08) inset;
  border-color: rgba(255, 255, 255, 0.15);
}

.message.bot {
  background: rgba(60, 60, 70, 0.5);
  color: hsl(var(--foreground));
  border-bottom-left-radius: 6px;
  border-top-left-radius: 18px;
  border-bottom-right-radius: 18px;
  border-top-right-radius: 18px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.25), 0 1px 0 rgba(255, 255, 255, 0.06) inset, 0 -1px 0 rgba(0, 0, 0, 0.15) inset;
  border-color: rgba(255, 255, 255, 0.06);
}

.message.system {
  align-self: center;
  background: rgba(255, 255, 255, 0.06);
  backdrop-filter: blur(20px) saturate(150%);
  -webkit-backdrop-filter: blur(20px) saturate(150%);
  color: hsl(var(--muted-foreground));
  font-size: 12.5px;
  padding: 6px 16px;
  border-radius: 20px;
  border: 0.5px solid rgba(255, 255, 255, 0.04);
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
  max-width: 80%;
  text-align: center;
}

.message h1, .message h2, .message h3 {
  margin: 0.6em 0 0.4em 0;
  font-weight: 600;
  line-height: 1.3;
}
.message h1 { font-size: 1.3em; }
.message h2 { font-size: 1.15em; }
.message h3 { font-size: 1.05em; }
.message p { margin: 0.4em 0; }
.message ul, .message ol {
  padding-left: 1.2em;
  margin: 0.4em 0;
}
.message pre {
  background: rgba(0, 0, 0, 0.3);
  padding: 8px 14px;
  border-radius: 12px;
  overflow-x: auto;
  margin: 0.4em 0;
  border: 0.5px solid rgba(255, 255, 255, 0.06);
  font-size: 0.85em;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
.message code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.9em;
}
.message img {
  max-width: 100%;
  max-height: 400px;
  border-radius: 14px;
  box-shadow: 0 2px 16px rgba(0, 0, 0, 0.2);
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
  margin-top: 4px;
}
.message img:hover {
  transform: scale(1.02);
}

.image-actions {
  margin-top: 4px;
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}
.image-actions a {
  display: inline-block;
  font-size: 12px;
  color: hsl(var(--accent));
  text-decoration: none;
  border: 1px solid rgba(255,255,255,0.06);
  padding: 4px 10px;
  border-radius: 9999px;
  background: rgba(255,255,255,0.04);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.image-actions a:hover {
  background: rgba(255,255,255,0.1);
  transform: scale(1.05);
}

.message pre {
  background: transparent !important;
  padding: 0 !important;
  border-radius: 8px;
  overflow: auto;
  margin: 0.4em 0;
  border: none;
}
.message pre code {
  display: block;
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 0.85em;
  line-height: 1.5;
  overflow: auto;
  background: #1e1e1e !important;
  color: #d4d4d4 !important;
}
.message code {
  background: rgba(255, 255, 255, 0.08);
  padding: 2px 6px;
  border-radius: 8px;
}

.message table {
  border-collapse: collapse;
  width: 100%;
  margin: 0.4em 0;
  font-size: 0.9em;
}
.message table th, .message table td {
  border: 1px solid rgba(255, 255, 255, 0.12);
  padding: 6px 12px;
  text-align: left;
}
.message table th {
  background: rgba(255, 255, 255, 0.06);
  font-weight: 600;
}
.message table tr:nth-child(even) {
  background: rgba(255, 255, 255, 0.03);
}

.message input[type="checkbox"] {
  margin-right: 6px;
  vertical-align: middle;
}

.message blockquote {
  border-left: 3px solid hsl(var(--accent));
  margin: 0.4em 0;
  padding: 4px 12px;
  background: rgba(255, 255, 255, 0.04);
  border-radius: 8px;
  color: hsl(var(--muted-foreground));
}

.code-buttons {
  position: absolute;
  bottom: 8px;
  right: 8px;
  display: flex;
  gap: 4px;
  z-index: 10;
}
.code-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #ccc;
  padding: 4px 10px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
  transition: all 0.2s;
}
.code-btn:hover {
  background: rgba(255, 255, 255, 0.15);
}
.code-btn.run-btn {
  background: rgba(0, 122, 255, 0.2);
  border-color: rgba(0, 122, 255, 0.3);
}
.code-btn.run-btn:hover {
  background: rgba(0, 122, 255, 0.3);
}

.message-copy-btn {
  display: inline-block;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #aaa;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 11px;
  cursor: pointer;
  transition: all 0.2s;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  opacity: 0.7;
  margin-top: 4px;
  user-select: none;
  width: auto;
  flex-shrink: 0;
}
.message-copy-btn:hover {
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  opacity: 1;
}

.custom-select-wrapper {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.custom-select-trigger {
  all: unset;
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(255,255,255,0.08);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 9999px;
  padding: 4px 12px;
  font-size: 12px;
  font-weight: 500;
  color: #fff;
  cursor: pointer;
  min-width: 80px;
  max-width: 140px;
  height: 30px;
  transition: all 0.2s ease;
  user-select: none;
}

.custom-select-trigger:hover {
  background: rgba(255,255,255,0.12);
}

.custom-select-dropdown {
  position: absolute;
  left: 0;
  right: 0;
  z-index: 1000;
  background: rgba(25, 25, 30, 0.85);
  backdrop-filter: blur(50px) saturate(150%);
  -webkit-backdrop-filter: blur(50px) saturate(150%);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 12px;
  padding: 4px 0;
  display: none;
  max-height: 200px;
  overflow-y: auto;
  box-shadow: 0 8px 40px rgba(0,0,0,0.6);
  min-width: 120px;
}

.custom-select-option {
  padding: 8px 14px;
  font-size: 12px;
  color: #fff;
  cursor: pointer;
  transition: background 0.15s ease;
  white-space: nowrap;
}

.custom-select-option:hover {
  background: rgba(255,255,255,0.1);
}

.custom-select-option:active {
  background: rgba(255,255,255,0.15);
}

.custom-select-dropdown::-webkit-scrollbar {
  width: 4px;
}
.custom-select-dropdown::-webkit-scrollbar-track {
  background: transparent;
}
.custom-select-dropdown::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.15);
  border-radius: 9999px;
}
.custom-select-dropdown::-webkit-scrollbar-thumb:hover {
  background: rgba(255,255,255,0.25);
}

#input-area {
  position: absolute !important;
  left: 0;
  right: 0;
  bottom: 18px;
  width: 100%;
  max-width: 860px;
  margin: 0 auto;
  z-index: 100;
  padding: 0 20px;
  background: transparent !important;
  pointer-events: none;
}
#input-area.drag-over {
  border-color: hsl(var(--accent));
  box-shadow: 0 0 0 2px hsl(var(--accent)/0.3);
}

#file-display-area {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 8px;
  padding: 4px 16px;
  min-height: 0;
}

.file-attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
  padding: 4px;
}
.file-attachment-card {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
  cursor: pointer;
  max-width: 200px;
  position: relative;
  overflow: visible;
}
.file-attachment-card:hover {
  background: rgba(255, 255, 255, 0.12);
  transform: translateY(-1px);
}
.file-attachment-card .file-icon {
  font-size: 20px;
  flex-shrink: 0;
}
.file-attachment-card .file-info {
  flex: 1;
  min-width: 0;
}
.file-attachment-card .file-name {
  font-size: 12px;
  font-weight: 500;
  color: hsl(var(--foreground));
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.file-attachment-card .file-meta {
  font-size: 10px;
  color: hsl(var(--muted-foreground));
  display: flex;
  gap: 6px;
}
.file-attachment-card .remove-file-btn {
  position: absolute;
  top: -8px;
  right: -8px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #ff3b30;
  color: white;
  border: 2px solid #1a1a1f;
  font-size: 14px;
  font-weight: bold;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
  padding: 0;
  line-height: 1;
  pointer-events: auto;
  transition: all 0.2s ease;
}
.file-attachment-card .remove-file-btn:hover {
  background: #d32f2f;
  transform: scale(1.1);
}
.file-attachment-card.image-attachment {
  padding: 6px;
  max-width: 120px;
  max-height: 120px;
  overflow: visible;
}
.file-attachment-card.image-attachment .file-thumbnail {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 8px;
}
.file-attachment-card.image-attachment .file-info,
.file-attachment-card.image-attachment .file-icon {
  display: none;
}

.file-preview-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(50px);
  -webkit-backdrop-filter: blur(50px);
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 2000;
}
.file-preview-modal.show {
  display: flex;
}
.file-preview-modal .preview-content {
  max-width: 95vw;
  max-height: 92vh;
  width: 90vw;
  height: 85vh;
  background: rgba(30, 30, 35, 0.95);
  border-radius: 20px;
  padding: 30px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6);
  position: relative;
  overflow: auto;
}
.file-preview-modal .preview-content img {
  max-width: 100%;
  max-height: 75vh;
  border-radius: 12px;
  display: block;
  margin: 0 auto;
}
.file-preview-modal .preview-content .code-viewer {
  max-height: 70vh;
  overflow: auto;
  background: rgba(0, 0, 0, 0.4);
  border-radius: 12px;
  padding: 20px;
  font-family: monospace;
  font-size: 14px;
  color: hsl(var(--foreground));
  white-space: pre-wrap;
  line-height: 1.6;
}
.file-preview-modal .preview-content embed {
  width: 100%;
  height: 75vh;
  border-radius: 12px;
}
.file-preview-modal .close-preview-btn {
  position: fixed;
  top: 20px;
  right: 20px;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: rgba(255, 59, 48, 0.9);
  border: none;
  color: white;
  font-size: 24px;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
  box-shadow: 0 4px 20px rgba(255, 59, 48, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2001;
}
.file-preview-modal .close-preview-btn:hover {
  transform: scale(1.1);
  background: rgba(255, 59, 48, 1);
}

.run-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(20px);
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 3000;
}
.run-modal.show {
  display: flex;
}
.run-modal-content {
  background: rgba(30, 30, 35, 0.95);
  border-radius: 16px;
  padding: 24px;
  width: 90%;
  max-width: 900px;
  height: 80%;
  position: relative;
  border: 1px solid rgba(255, 255, 255, 0.08);
}
.run-modal-content .close-run-btn {
  position: absolute;
  top: 12px;
  right: 16px;
  background: transparent;
  border: none;
  color: hsl(var(--foreground));
  font-size: 24px;
  cursor: pointer;
}
#run-output {
  height: calc(100% - 40px);
  overflow: auto;
  margin-top: 10px;
}
#run-output iframe {
  width: 100%;
  height: 100%;
  border: none;
}
#run-output pre {
  background: #1e1e1e;
  padding: 16px;
  border-radius: 8px;
  color: #d4d4d4;
  overflow: auto;
  white-space: pre-wrap;
}

#input-row {
  pointer-events: auto;
  display: flex;
  gap: 8px;
  align-items: flex-end;
  background: rgba(25, 25, 30, 0.58);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 20px;
  padding: 8px 16px;
  backdrop-filter: blur(24px) saturate(160%);
  -webkit-backdrop-filter: blur(24px) saturate(160%);
  box-shadow: 0 8px 30px rgba(0,0,0,0.28), inset 0 1px 1px rgba(255,255,255,0.05);
  transition: all .25s ease;
}
#input-row:focus-within {
  border-color: rgba(255,255,255,0.12);
  box-shadow: 0 10px 36px rgba(0,0,0,0.34), 0 0 0 1px rgba(255,255,255,0.04);
}
#input-row textarea {
  flex: 1;
  min-width: 80px;
  border: none;
  background: transparent !important;
  outline: none;
  font-size: 15px;
  color: hsl(var(--foreground));
  font-family: inherit;
  padding: 8px 0;
  line-height: 1.5;
  resize: none;
  overflow-y: auto;
  max-height: calc(1.5em * 30);
  transition: height 0.15s cubic-bezier(0.4, 0.0, 0.2, 1);
}
#input-row textarea::placeholder {
  color: hsl(var(--muted-foreground));
  opacity: 0.6;
}
#input-row textarea::-webkit-scrollbar {
  width: 3px;
}
#input-row textarea::-webkit-scrollbar-track {
  background: transparent;
}
#input-row textarea::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.15);
  border-radius: 9999px;
}
#input-row textarea::-webkit-scrollbar-thumb:hover {
  background: rgba(255,255,255,0.25);
}

#input-actions {
  display: flex;
  gap: 4px;
  align-items: center;
  flex-shrink: 0;
  padding-bottom: 4px;
}

.action-btn {
  width: 34px;
  height: 34px;
  border-radius: 9999px;
  border: 1px solid rgba(255,255,255,0.08);
  background: rgba(255,255,255,0.06);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
  flex-shrink: 0;
  color: hsl(var(--foreground));
}
.action-btn:hover {
  background: rgba(255,255,255,0.14);
  transform: scale(1.05);
  box-shadow: 0 2px 12px rgba(0,0,0,0.2);
}
#web-search-btn.active {
  background: hsl(var(--accent));
  color: white;
  border-color: hsl(var(--accent));
  box-shadow: 0 0 0 3px hsl(var(--accent)/0.2);
}
#send-btn {
  width: 34px;
  height: 34px;
  border-radius: 9999px;
  border: none;
  background: hsl(var(--accent));
  color: hsl(var(--accent-foreground));
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
  flex-shrink: 0;
}
#send-btn:hover {
  transform: scale(1.1);
  box-shadow: 0 4px 20px hsl(var(--accent)/0.5);
}

#aside-panel {
  position: fixed;
  right: 0;
  top: 0;
  bottom: 0;
  width: var(--aside-width);
  display: flex;
  flex-direction: column;
  padding: 16px;
  background: rgba(20, 20, 25, 0.3);
  backdrop-filter: blur(30px) saturate(140%);
  -webkit-backdrop-filter: blur(30px) saturate(140%);
  gap: 8px;
  overflow-y: auto;
  height: 100vh;
  z-index: 50;
  border-left: 1px solid rgba(255,255,255,0.06);
}

.widget {
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
  padding: 0 !important;
  margin-bottom: 8px;
  width: 100%;
  height: auto;
}

.dot-loader {
  display: inline-flex;
  gap: 4px;
  align-items: center;
}
.dot {
  width: 5px;
  height: 5px;
  background: rgba(255,255,255,0.2);
  border-radius: 50%;
  animation: bounce 1.4s cubic-bezier(0.34, 1.56, 0.64, 1) infinite both;
}
.dot:nth-child(1) { animation-delay: -0.32s; }
.dot:nth-child(2) { animation-delay: -0.16s; }
.dot:nth-child(3) { animation-delay: 0s; }
@keyframes bounce {
  0%, 80%, 100% { transform: scale(0); }
  40% { transform: scale(1); }
}

/* ===== 消息区域滚动条隐藏（悬停时显示） ===== */
#messages::-webkit-scrollbar { width: 3px; }
#messages::-webkit-scrollbar-track { background: transparent; }
#messages::-webkit-scrollbar-thumb { background: transparent; border-radius: 9999px; transition: background 0.25s ease; }
#messages:hover::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.2); }
#messages::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.35); }
#messages { scrollbar-width: thin; scrollbar-color: transparent transparent; transition: scrollbar-color 0.25s ease; }
#messages:hover { scrollbar-color: rgba(255, 255, 255, 0.2) transparent; }

/* ===== 资源搜索样式 ===== */
.resource-search-results { animation: slideIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) forwards; margin: 12px 0; padding: 12px 16px; background: rgba(30, 30, 35, 0.6); border-radius: 16px; backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); border: 1px solid rgba(255, 255, 255, 0.06); max-width: 85%; width: auto; min-width: 280px; }
@keyframes slideIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
.resource-search-header { display: flex; justify-content: space-between; align-items: center; padding: 4px 0 8px 0; border-bottom: 1px solid rgba(255, 255, 255, 0.06); margin-bottom: 12px; }
.resource-search-title { font-weight: 600; font-size: 13px; color: hsl(var(--foreground)); }
.resource-search-info { font-size: 11px; color: hsl(var(--muted-foreground)); }
.resource-card { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 12px; background: rgba(255, 255, 255, 0.04); border-radius: 12px; margin-bottom: 8px; transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1); cursor: pointer; border: 1px solid rgba(255, 255, 255, 0.04); }
.resource-card:hover { background: rgba(255, 255, 255, 0.08); transform: translateX(3px); }
.resource-card-number { font-size: 12px; color: hsl(var(--muted-foreground)); min-width: 26px; font-weight: 500; }
.resource-card-title { flex: 1; font-size: 13px; color: hsl(var(--foreground)); font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.resource-card-tag { padding: 2px 8px; border-radius: 12px; font-size: 10px; font-weight: 500; flex-shrink: 0; white-space: nowrap; }
.resource-card-tag.quark { background: rgba(33, 150, 243, 0.2); color: #64b5f6; }
.resource-card-tag.baidu { background: rgba(0, 150, 200, 0.2); color: #4fc3f7; }
.resource-card-tag.aliyun { background: rgba(255, 105, 180, 0.2); color: #f48fb1; }
.resource-card-tag.default { background: rgba(255, 255, 255, 0.08); color: hsl(var(--muted-foreground)); }
.resource-open-btn { padding: 4px 12px; border-radius: 16px; border: 1px solid rgba(255, 255, 255, 0.1); background: rgba(0, 122, 255, 0.15); color: hsl(var(--accent)); font-size: 11px; cursor: pointer; transition: all 0.2s ease; flex-shrink: 0; font-weight: 500; }
.resource-open-btn:hover { background: rgba(0, 122, 255, 0.3); transform: scale(1.02); }
.resource-pagination { display: flex; justify-content: center; align-items: center; gap: 6px; margin-top: 12px; padding-top: 10px; border-top: 1px solid rgba(255, 255, 255, 0.06); flex-wrap: wrap; }
.resource-page-btn { padding: 4px 10px; border-radius: 8px; border: none; background: rgba(255, 255, 255, 0.06); color: hsl(var(--foreground)); font-size: 12px; cursor: pointer; transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1); min-width: 32px; height: 28px; display: flex; align-items: center; justify-content: center; }
.resource-page-btn.active { background: hsl(var(--accent)); color: hsl(var(--accent-foreground)); font-weight: 600; }
.resource-page-btn:hover:not(.active) { background: rgba(255, 255, 255, 0.12); }
.resource-empty { padding: 20px; text-align: center; color: hsl(var(--muted-foreground)); font-size: 13px; }

/* ==================================================== */
/* ===== 专属移动端及平板端（<= 1024px）响应式优化 ===== */
/* ==================================================== */
@media (max-width: 1024px) {
  /* 唤出左上角汉堡菜单按钮 */
  #mobile-menu-btn { display: flex; }
  
  /* 给主聊天区域顶部留白，防消息顶到菜单按钮 */
  #messages {
    padding-top: calc(env(safe-area-inset-top, 16px) + 64px) !important;
    padding-bottom: 140px !important;
  }

  /* ===== 侧边栏：变身丝滑抽屉 ===== */
  #sidebar {
    display: flex !important;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 280px;
    max-width: 85vw;
    z-index: 2000;
    transform: translateX(-100%);
    background: rgba(20, 20, 25, 0.95);
    backdrop-filter: blur(40px) saturate(150%);
    -webkit-backdrop-filter: blur(40px) saturate(150%);
    border-right: 1px solid rgba(255, 255, 255, 0.1);
    transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
    padding: calc(env(safe-area-inset-top, 16px) + 20px) 16px 20px 16px; 
  }
  
  #sidebar.show {
    transform: translateX(0);
    box-shadow: 10px 0 50px rgba(0,0,0,0.6);
  }

  /* 彻底隐藏右侧边栏面板 */
  #aside-panel { display: none !important; }
  
  /* 聊天主界面全屏占比 */
  #main-chat { padding-right: 0 !important; margin-right: 0 !important; width: 100vw; }
  .message { max-width: 92% !important; font-size: 14.5px; padding: 12px 16px; }
  
  /* ===== 搜索卡片深度优化：去掉按钮，放大文字，容纳更多信息 ===== */
  .resource-search-results {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important; 
    padding: 12px 14px !important;
    margin: 8px 0 !important;
  }
  
  /* 隐藏打开按钮，腾出宝贵横向空间 */
  .resource-card .resource-open-btn {
    display: none !important;
  }
  
  .resource-card {
    padding: 10px !important;
    gap: 8px !important;
    align-items: flex-start !important; /* 顶部对齐，方便多行文字显示 */
  }

  .resource-card-number {
    min-width: 20px !important;
    margin-top: 2px;
  }
  
  /* 允许标题换行显示，展示更多搜索结果信息 */
  .resource-card-title {
    font-size: 13.5px !important;
    font-weight: 500;
    line-height: 1.4 !important;
    white-space: normal !important; /* 允许换行 */
    display: -webkit-box !important;
    -webkit-line-clamp: 2 !important; /* 最多显示2行 */
    -webkit-box-orient: vertical !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    flex: 1 1 auto; 
  }
  
  .resource-card-tag {
    padding: 3px 8px !important;
    font-size: 10px;
    margin-top: 2px;
  }
  
  /* ===== 底部输入框 ===== */
  #input-area {
    position: fixed !important;
    bottom: 0 !important;
    left: 0;
    right: 0;
    width: 100%;
    max-width: 100%;
    padding: 8px 12px calc(8px + env(safe-area-inset-bottom, 0px)) 12px !important;
    background: transparent !important; 
  }
  
  #input-row {
    flex-direction: column;
    align-items: stretch;
    padding: 10px 12px;
    border-radius: 20px;
  }
  
  #input-row textarea { width: 100%; min-height: 24px; padding: 0 4px 10px 4px; }
  
  #input-actions {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    gap: 8px;
    width: 100%;
    overflow-x: auto;
    scrollbar-width: none; 
    -ms-overflow-style: none; 
  }
  #input-actions::-webkit-scrollbar { display: none; }
  
  .custom-select-trigger, #input-actions .action-btn { flex-shrink: 0; }
  #send-btn { margin-left: auto !important; flex-shrink: 0; }
  
  /* 模型选择框防裁剪 & 体积缩小 */
  .custom-select-dropdown {
    position: fixed !important;
    bottom: calc(85px + env(safe-area-inset-bottom, 0px)) !important; 
    top: auto !important;
    left: 16px !important;
    right: auto !important; /* 重点：解除全屏宽度限制 */
    width: max-content !important;
    min-width: 180px !important;
    max-width: 75vw !important;
    max-height: 40vh !important;
    border-radius: 16px !important;
    padding: 6px 0 !important;
    box-shadow: 0 8px 32px rgba(0,0,0,0.6), 0 0 0 1px rgba(255,255,255,0.06) !important;
  }
  
  .custom-select-option {
    padding: 12px 18px !important;
    font-size: 14px !important;
  }
}
