:root {
  --sidebar-width: 280px;
  --bg: #fafaf9;
  --surface: #ffffff;
  --border: #e7e5e4;
  --border-strong: #d6d3d1;
  --text: #1c1917;
  --text-secondary: #57534e;
  --text-muted: #a8a29e;
  --accent: #0d9488;
  --accent-hover: #0f766e;
  --accent-light: #ccfbf1;
  --danger: #dc2626;
  --radius-sm: 0.375rem;
  --radius-md: 0.5rem;
  --radius-lg: 0.75rem;
  --radius-xl: 1rem;
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.04);
  --shadow-md:
    0 4px 6px -1px rgb(0 0 0 / 0.06), 0 2px 4px -2px rgb(0 0 0 / 0.04);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  height: 100%;
  overflow: hidden;
}

body {
  font-family:
    'Source Sans 3',
    -apple-system,
    BlinkMacSystemFont,
    'Segoe UI',
    Roboto,
    sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1,
h2,
h3,
h4,
h5,
h6 {
  font-family: 'Outfit', sans-serif;
  font-weight: 600;
  line-height: 1.3;
}

/* Layout */
.anyllm-app {
  display: flex;
  height: 100vh;
  width: 100vw;
}

/* Sidebar */
.anyllm-sidebar {
  width: var(--sidebar-width);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  transition: transform 0.3s ease;
}

.anyllm-sidebar-header {
  padding: 1.25rem;
  border-bottom: 1px solid var(--border);
}

.anyllm-sidebar-header h2 {
  font-size: 1.125rem;
  margin-bottom: 0.75rem;
  color: var(--text);
}

.anyllm-new-chat-btn {
  width: 100%;
  padding: 0.625rem 1rem;
  border: 1px dashed var(--border-strong);
  background: transparent;
  border-radius: var(--radius-md);
  cursor: pointer;
  font-family: inherit;
  font-weight: 500;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  transition: all 0.15s ease;
}

.anyllm-new-chat-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-light);
}

.anyllm-chat-list {
  list-style: none;
  flex: 1;
  overflow-y: auto;
  padding: 0.5rem;
}

.anyllm-chat-list li {
  margin-bottom: 0.125rem;
  display: flex;
  align-items: center;
  gap: 0.125rem;
  border-radius: var(--radius-md);
  transition: background 0.15s ease;
}

.anyllm-chat-list li:hover {
  background: var(--bg);
}

.anyllm-chat-list li.active {
  background: var(--accent-light);
}

.anyllm-chat-list a {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex: 1;
  min-width: 0;
  padding: 0.5rem 0.375rem 0.5rem 0.75rem;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
  transition: color 0.15s ease;
}

.anyllm-chat-list li:hover a {
  color: var(--text);
}

.anyllm-chat-list li.active a {
  color: var(--accent);
}

.anyllm-chat-title {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.anyllm-chat-date {
  font-size: 0.75rem;
  font-weight: 400;
  color: var(--text-muted);
  white-space: nowrap;
  margin-left: 0.5rem;
  flex-shrink: 0;
}

.anyllm-chat-list li.active .anyllm-chat-date {
  color: var(--accent);
  opacity: 0.6;
}

.anyllm-delete-btn {
  opacity: 0;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.375rem;
  margin-right: 0.25rem;
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  transition:
    opacity 0.15s ease,
    color 0.15s ease,
    background 0.15s ease;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.anyllm-chat-list li:hover .anyllm-delete-btn {
  opacity: 1;
}

.anyllm-delete-btn:hover {
  color: var(--danger);
  background: rgba(0, 0, 0, 0.05);
}

.anyllm-chat-empty {
  padding: 0.625rem 0.875rem;
  color: var(--text-muted);
  font-size: 0.875rem;
}

.anyllm-sidebar-footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--border);
  font-size: 0.75rem;
  color: var(--text-muted);
  text-align: center;
}

/* Main */
.anyllm-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--bg);
}

.anyllm-main-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.875rem 1.5rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.anyllm-main-header h1 {
  font-size: 1rem;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.anyllm-mobile-toggle {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.375rem;
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
}

.anyllm-mobile-toggle:hover {
  background: var(--bg);
}

/* Messages */
.anyllm-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  scroll-behavior: smooth;
}

.anyllm-message-wrapper {
  position: relative;
  max-width: 800px;
  margin: 0 auto 1.25rem;
  padding-left: calc(2rem + 0.875rem);
  animation: messageIn 0.3s ease-out;
}

@keyframes messageIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.anyllm-message-wrapper.user {
  padding-left: 0;
  padding-right: calc(2rem + 0.875rem);
}

.anyllm-avatar {
  position: absolute;
  top: 0;
  left: 0;
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  font-family: 'Outfit', sans-serif;
}

.anyllm-message-wrapper.user .anyllm-avatar {
  left: auto;
  right: 0;
}

.anyllm-avatar.user {
  background: var(--accent);
  color: #fff;
}

.anyllm-avatar.assistant {
  background: #f5f5f4;
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.anyllm-avatar.tool {
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #fde68a;
}

.anyllm-message-meta {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  margin-bottom: 0.25rem;
}

.anyllm-message-wrapper.user .anyllm-message-meta {
  justify-content: flex-end;
}

.anyllm-message-wrapper.user .anyllm-message-body {
  text-align: right;
}

.anyllm-message-role {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text);
  font-family: 'Outfit', sans-serif;
}

.anyllm-message-time {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.anyllm-message {
  padding: 0.875rem 1.125rem;
  border-radius: var(--radius-lg);
  line-height: 1.6;
  word-break: break-word;
  font-size: 0.9375rem;
}

.anyllm-message > *:first-child {
  margin-top: 0 !important;
}
.anyllm-message > *:last-child {
  margin-bottom: 0 !important;
}

.anyllm-message p {
  margin: 0.5em 0;
}

.anyllm-message ul,
.anyllm-message ol {
  margin: 0.5em 0;
  padding-left: 1.5em;
}

.anyllm-message li {
  margin: 0.25em 0;
}

.anyllm-message code {
  background: rgba(0, 0, 0, 0.05);
  padding: 0.125em 0.375em;
  border-radius: 0.25em;
  font-family:
    ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, monospace;
  font-size: 0.875em;
}

.anyllm-message pre {
  background: #f5f5f4;
  padding: 0.75em 1em;
  border-radius: var(--radius-md);
  overflow-x: auto;
  margin: 0.5em 0;
}

.anyllm-message pre code {
  background: transparent;
  padding: 0;
  font-size: 0.8125em;
}

.anyllm-message blockquote {
  border-left: 3px solid var(--border-strong);
  margin: 0.5em 0;
  padding-left: 1em;
  color: var(--text-secondary);
}

.anyllm-message a {
  color: var(--accent);
  text-decoration: underline;
}

.anyllm-message h1,
.anyllm-message h2,
.anyllm-message h3,
.anyllm-message h4 {
  font-family: 'Outfit', sans-serif;
  font-weight: 600;
  margin: 0.75em 0 0.5em;
  line-height: 1.3;
}

.anyllm-message h1 {
  font-size: 1.25em;
}
.anyllm-message h2 {
  font-size: 1.15em;
}
.anyllm-message h3 {
  font-size: 1.05em;
}
.anyllm-message h4 {
  font-size: 1em;
}

.anyllm-message.user {
  background: var(--accent);
  color: #fff;
  border-bottom-right-radius: 0.25rem;
  display: inline-block;
  text-align: left;
  max-width: 100%;
}

.anyllm-message.user p {
  margin: 0;
}

.anyllm-message-wrapper:has(.anyllm-message:empty) {
  display: none;
}

.anyllm-message.assistant {
  background: var(--surface);
  border: 1px solid var(--border);
  border-bottom-left-radius: 0.25rem;
  box-shadow: var(--shadow-sm);
}

.anyllm-message.tool {
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-bottom-left-radius: 0.25rem;
  font-size: 0.875rem;
  color: #78350f;
}

.anyllm-message .content {
  overflow-wrap: break-word;
}

/* Reasoning */
.anyllm-reasoning {
  margin-bottom: 0.625rem;
  padding: 0.625rem 0.875rem;
  background: #f5f5f4;
  border-radius: var(--radius-md);
  border-left: 3px solid var(--text-muted);
}

.anyllm-reasoning-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.25rem;
  font-family: 'Outfit', sans-serif;
}

.anyllm-reasoning-content {
  font-size: 0.875rem;
  color: var(--text-secondary);
  font-style: italic;
  white-space: pre-wrap;
}

/* Files */
.anyllm-files {
  margin-top: 0.625rem;
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.anyllm-files img {
  max-height: 140px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.anyllm-file-link {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.375rem 0.75rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 0.8125rem;
  color: var(--text-secondary);
  text-decoration: none;
  transition: all 0.15s ease;
}

.anyllm-file-link:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* Input Area */
.anyllm-input-area {
  padding: 1rem 1.5rem 1.5rem;
  background: var(--surface);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.anyllm-input-wrapper {
  max-width: 800px;
  margin: 0 auto;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 0.75rem 1rem;
  transition:
    border-color 0.15s ease,
    box-shadow 0.15s ease;
}

.anyllm-input-wrapper:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.08);
}

.anyllm-input-area textarea {
  width: 100%;
  resize: none;
  border: none;
  background: transparent;
  font-family: inherit;
  font-size: 0.9375rem;
  line-height: 1.5;
  color: var(--text);
  outline: none;
  min-height: 24px;
  max-height: 200px;
}

.anyllm-input-area textarea::placeholder {
  color: var(--text-muted);
}

.anyllm-input-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 0.5rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--border);
}

.anyllm-input-left {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.anyllm-file-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border-radius: var(--radius-md);
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s ease;
}

.anyllm-file-btn:hover {
  background: var(--border);
  color: var(--text);
}

.anyllm-file-btn input[type='file'] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.anyllm-file-name {
  font-size: 0.75rem;
  color: var(--text-secondary);
  max-width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.anyllm-send-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
  padding: 0.5rem 1.125rem;
  border: none;
  background: var(--accent);
  color: #fff;
  border-radius: var(--radius-md);
  font-family: inherit;
  font-weight: 600;
  font-size: 0.875rem;
  cursor: pointer;
  transition: all 0.15s ease;
}

.anyllm-send-btn:hover {
  background: var(--accent-hover);
}
.anyllm-send-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.anyllm-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* Empty state */
.anyllm-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 2rem;
  color: var(--text-muted);
}

.anyllm-empty-icon {
  width: 64px;
  height: 64px;
  margin-bottom: 1.5rem;
  color: var(--border-strong);
}

.anyllm-empty h3 {
  font-size: 1.25rem;
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
}

.anyllm-empty p {
  font-size: 0.9375rem;
  max-width: 320px;
}

/* Streaming indicator */
.anyllm-streaming {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  margin-top: 0.5rem;
}

.anyllm-streaming-dot {
  width: 6px;
  height: 6px;
  background: var(--accent);
  border-radius: 50%;
  animation: streamingPulse 1.4s infinite ease-in-out both;
}

.anyllm-streaming-dot:nth-child(1) {
  animation-delay: -0.32s;
}
.anyllm-streaming-dot:nth-child(2) {
  animation-delay: -0.16s;
}

@keyframes streamingPulse {
  0%,
  80%,
  100% {
    transform: scale(0);
    opacity: 0.5;
  }
  40% {
    transform: scale(1);
    opacity: 1;
  }
}

/* Tool call display */
.anyllm-tool-call {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.875rem;
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: var(--radius-md);
  font-size: 0.8125rem;
  color: #92400e;
  margin-top: 0.5rem;
}

.anyllm-tool-result {
  margin-top: 0.375rem;
  padding: 0.5rem 0.875rem;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: var(--radius-md);
  font-size: 0.8125rem;
  color: #166534;
  font-family:
    ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, monospace;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 120px;
  overflow-y: auto;
}

/* Error display */
.anyllm-error {
  margin-top: 0.5rem;
  padding: 0.5rem 0.875rem;
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: var(--radius-md);
  font-size: 0.8125rem;
  color: #991b1b;
}

/* Mobile */
@media (max-width: 768px) {
  .anyllm-app.detail-page .anyllm-sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    z-index: 100;
    transform: translateX(-100%);
  }

  .anyllm-app.detail-page .anyllm-sidebar.open {
    transform: translateX(0);
  }

  .anyllm-sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.3);
    z-index: 99;
  }

  .anyllm-app.detail-page .anyllm-sidebar-overlay.open {
    display: block;
  }
  .anyllm-app.detail-page .anyllm-mobile-toggle {
    display: flex;
  }
}

.anyllm-app.list-page .anyllm-sidebar {
  transform: none;
  position: static;
}
.anyllm-app.list-page .anyllm-sidebar-overlay {
  display: none !important;
}
.anyllm-app.list-page .anyllm-mobile-toggle {
  display: none;
}

@media (max-width: 768px) {
  .anyllm-app.list-page .anyllm-sidebar {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  .anyllm-app.list-page {
    flex-direction: column;
  }
  .anyllm-app.list-page .anyllm-main {
    display: none;
  }
}

/* Scrollbar styling */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}
