:root {
  --bg: #0f1117;
  --panel: #171a22;
  --panel-2: #1f2430;
  --border: rgba(255, 255, 255, 0.08);
  --text: #eef2ff;
  --muted: #9aa4bf;
  --primary: #7c5cff;
  --primary-hover: #9278ff;
  --success: #34d399;
  --danger: #f87171;
  --shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
  --scrollbar-size: 8px;
  --scrollbar-track: transparent;
  --scrollbar-thumb: rgba(154, 164, 191, 0.22);
  --scrollbar-thumb-hover: rgba(124, 92, 255, 0.55);
}

* {
  box-sizing: border-box;
}

.messages,
.sidebar,
.modal-wide,
.table-wrap,
.page-shell {
  scrollbar-width: thin;
  scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track);
}

.messages::-webkit-scrollbar,
.sidebar::-webkit-scrollbar,
.modal-wide::-webkit-scrollbar,
.table-wrap::-webkit-scrollbar,
.page-shell::-webkit-scrollbar {
  width: var(--scrollbar-size);
  height: var(--scrollbar-size);
}

.messages::-webkit-scrollbar-track,
.sidebar::-webkit-scrollbar-track,
.modal-wide::-webkit-scrollbar-track,
.table-wrap::-webkit-scrollbar-track,
.page-shell::-webkit-scrollbar-track {
  background: var(--scrollbar-track);
}

.messages::-webkit-scrollbar-thumb,
.sidebar::-webkit-scrollbar-thumb,
.modal-wide::-webkit-scrollbar-thumb,
.table-wrap::-webkit-scrollbar-thumb,
.page-shell::-webkit-scrollbar-thumb {
  background-color: var(--scrollbar-thumb);
  border-radius: 999px;
  border: 2px solid transparent;
  background-clip: padding-box;
}

.messages::-webkit-scrollbar-thumb:hover,
.sidebar::-webkit-scrollbar-thumb:hover,
.modal-wide::-webkit-scrollbar-thumb:hover,
.table-wrap::-webkit-scrollbar-thumb:hover,
.page-shell::-webkit-scrollbar-thumb:hover {
  background-color: var(--scrollbar-thumb-hover);
}

.messages::-webkit-scrollbar-corner,
.sidebar::-webkit-scrollbar-corner,
.modal-wide::-webkit-scrollbar-corner,
.table-wrap::-webkit-scrollbar-corner,
.page-shell::-webkit-scrollbar-corner {
  background: transparent;
}

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: radial-gradient(circle at top, #1a1630 0%, var(--bg) 45%);
  color: var(--text);
}

body {
  min-height: 100vh;
}

.app {
  display: grid;
  grid-template-columns: 320px 1fr;
  height: 100vh;
  overflow: hidden;
}

.sidebar {
  padding: 24px;
  border-right: 1px solid var(--border);
  background: rgba(15, 17, 23, 0.85);
  backdrop-filter: blur(12px);
  display: flex;
  flex-direction: column;
  gap: 18px;
  height: 100vh;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.brand {
  display: flex;
  gap: 14px;
  align-items: center;
}

.brand-icon {
  width: 52px;
  height: 52px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  font-size: 24px;
  background: linear-gradient(135deg, rgba(124, 92, 255, 0.35), rgba(52, 211, 153, 0.25));
  border: 1px solid var(--border);
}

.brand h1,
.chat-header h2 {
  margin: 0;
  font-size: 20px;
}

.brand p,
.status,
.hint,
.tips li {
  color: var(--muted);
  font-size: 13px;
}

.panel {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.panel label,
.tips h3 {
  font-size: 13px;
  color: var(--muted);
}

.panel select,
.panel input,
.composer textarea {
  width: 100%;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  border-radius: 12px;
  padding: 12px 14px;
  font: inherit;
}

.panel select:focus,
.panel input:focus,
.composer textarea:focus {
  outline: 2px solid rgba(124, 92, 255, 0.35);
  border-color: rgba(124, 92, 255, 0.5);
}

.tips {
  margin-top: auto;
  padding: 16px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
}

.tips ul {
  margin: 10px 0 0;
  padding-left: 18px;
}

.ghost-btn,
.composer button {
  border: none;
  cursor: pointer;
  font: inherit;
  border-radius: 12px;
  transition: 0.2s ease;
}

.ghost-btn {
  padding: 12px 16px;
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
}

.ghost-btn:hover {
  color: var(--text);
  border-color: rgba(255, 255, 255, 0.18);
}

.primary-btn,
.composer button[type="submit"] {
  background: linear-gradient(135deg, var(--primary), #5b8cff);
  color: #fff;
  font-weight: 600;
}

.primary-btn {
  width: 100%;
  padding: 12px 16px;
  border: none;
  cursor: pointer;
  font: inherit;
  border-radius: 12px;
  transition: 0.2s ease;
}

.primary-btn:hover {
  filter: brightness(1.08);
}

.primary-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.new-chat-btn {
  flex-shrink: 0;
}

.conversation-panel {
  min-height: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.conversation-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
  min-height: 120px;
  max-height: min(360px, 40vh);
  overflow-y: auto;
}

.conversation-empty {
  color: var(--muted);
  font-size: 13px;
  padding: 12px;
  text-align: center;
  border: 1px dashed var(--border);
  border-radius: 12px;
}

.conversation-item {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--panel-2);
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.conversation-item:hover {
  border-color: rgba(56, 189, 148, 0.45);
  background: #273044;
}

.conversation-item.active {
  border-color: rgba(56, 189, 148, 0.75);
  background: rgba(56, 189, 148, 0.12);
}

.conversation-item-title {
  font-size: 14px;
  font-weight: 600;
  width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.conversation-item-preview {
  font-size: 12px;
  color: var(--muted);
  width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.conversation-item-meta {
  font-size: 11px;
  color: #64748b;
}

.bubble-text.streaming::after {
  content: "▍";
  display: inline-block;
  margin-left: 2px;
  color: #6ee7b7;
  animation: blink 1s step-end infinite;
}

@keyframes blink {
  50% { opacity: 0; }
}

.chat {
  display: flex;
  flex-direction: column;
  height: 100vh;
  min-height: 0;
  overflow: hidden;
}

.chat-header {
  padding: 20px 28px;
  border-bottom: 1px solid var(--border);
  background: rgba(15, 17, 23, 0.55);
  flex-shrink: 0;
}

.chat-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.llm-model-bar,
.llm-composer-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.llm-model-bar label,
.llm-composer-bar label {
  color: #cbd5e1;
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
}

.model-panel {
  padding: 14px;
  border-radius: 16px;
  background: rgba(56, 189, 148, 0.06);
  border: 1px solid rgba(56, 189, 148, 0.28);
}

.model-panel label {
  color: #a7f3d0;
  font-size: 14px;
  font-weight: 600;
}

.model-picker {
  position: relative;
  width: 100%;
}

.model-picker-compact {
  min-width: 220px;
}

.model-picker-trigger {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 13px 16px;
  border-radius: 12px;
  border: 1px solid rgba(148, 163, 184, 0.45);
  background: #2a3347;
  color: #f8fbff;
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
  transition: border-color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
}

.model-picker-trigger:hover,
.model-picker.open .model-picker-trigger {
  border-color: rgba(56, 189, 148, 0.75);
  background: #313b52;
}

.model-picker-trigger:focus {
  outline: none;
  border-color: rgba(56, 189, 148, 0.85);
  box-shadow: 0 0 0 3px rgba(56, 189, 148, 0.18);
}

.model-picker-value {
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.model-picker-chevron {
  color: #6ee7b7;
  font-size: 18px;
  line-height: 1;
  flex-shrink: 0;
  transition: transform 0.2s ease;
}

.model-picker.open .model-picker-chevron {
  transform: rotate(180deg);
}

.model-picker-menu {
  position: fixed;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px;
  border-radius: 14px;
  border: 1px solid rgba(148, 163, 184, 0.35);
  background: #1a2030;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.45);
  max-height: 280px;
  overflow-y: auto;
}

.model-picker-menu[hidden] {
  display: none;
}

.model-picker-option {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  padding: 12px 14px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: #242b3d;
  color: #f8fbff;
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.model-picker-option:hover {
  background: #2f3950;
  border-color: rgba(56, 189, 148, 0.35);
}

.model-picker-option.active {
  background: rgba(56, 189, 148, 0.16);
  border-color: rgba(56, 189, 148, 0.65);
}

.model-picker-option-label {
  font-size: 15px;
  font-weight: 600;
  color: #ffffff;
}

.model-picker-option-id {
  font-size: 12px;
  color: #94a3b8;
}

.llm-composer-bar {
  padding: 10px 16px 0;
  border-top: 1px solid var(--border);
  background: rgba(15, 17, 23, 0.35);
}

.current-model-hint {
  color: #cbd5e1;
  font-size: 13px;
}

@media (max-width: 960px) {
  .llm-model-bar {
    width: 100%;
  }

  .model-picker-compact {
    flex: 1;
    min-width: 0;
  }

  .current-model-hint {
    width: 100%;
  }
}

.status.ok {
  color: var(--success);
}

.status.error {
  color: var(--danger);
}

.messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 28px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.message {
  display: flex;
  gap: 12px;
  max-width: 900px;
}

.message.user {
  margin-left: auto;
  flex-direction: row-reverse;
}

.avatar {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 700;
  background: var(--panel-2);
  border: 1px solid var(--border);
  flex-shrink: 0;
}

.message.assistant .avatar {
  background: rgba(124, 92, 255, 0.18);
}

.message.user .avatar {
  background: rgba(52, 211, 153, 0.18);
}

.bubble {
  padding: 14px 16px;
  border-radius: 18px;
  line-height: 1.6;
  background: var(--panel);
  border: 1px solid var(--border);
  white-space: pre-wrap;
  word-break: break-word;
}

.message.user .bubble {
  background: linear-gradient(135deg, rgba(124, 92, 255, 0.22), rgba(124, 92, 255, 0.12));
}

.image-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
  margin-top: 12px;
}

.image-card {
  overflow: hidden;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: #0b0d12;
  box-shadow: var(--shadow);
}

.image-card img {
  display: block;
  width: 100%;
  height: auto;
}

.image-actions {
  display: flex;
  justify-content: space-between;
  padding: 10px 12px;
  font-size: 12px;
  color: var(--muted);
}

.image-actions a {
  color: var(--primary-hover);
  text-decoration: none;
}

.composer {
  padding: 10px 16px 12px;
  border-top: 1px solid var(--border);
  background: rgba(15, 17, 23, 0.75);
  flex-shrink: 0;
}

.composer-main {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}

.composer textarea {
  flex: 1;
  min-width: 0;
  resize: none;
  min-height: 44px;
  max-height: 96px;
  padding: 10px 12px;
  line-height: 1.45;
}

.composer-action-buttons {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.composer-footer {
  margin-top: 6px;
}

.composer--img2img .composer-footer .hint {
  font-size: 12px;
}

.composer--img2img.dragover,
.composer.dragover {
  outline: 1px dashed rgba(124, 92, 255, 0.45);
  outline-offset: -1px;
  background: rgba(124, 92, 255, 0.06);
}

.chat.dragover-document .messages {
  outline: 1px dashed rgba(124, 92, 255, 0.25);
  outline-offset: -4px;
  background: rgba(124, 92, 255, 0.03);
}

.upload-clear-btn {
  padding: 8px 10px;
  font-size: 12px;
}

.composer button[type="submit"] {
  padding: 10px 16px;
  background: linear-gradient(135deg, var(--primary), #5b8cff);
  color: white;
  min-width: 88px;
  white-space: nowrap;
}

.composer button:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

.document-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
}

.document-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: 100%;
  padding: 6px 8px 6px 10px;
  border: 1px solid rgba(124, 92, 255, 0.35);
  border-radius: 999px;
  background: rgba(124, 92, 255, 0.1);
  font-size: 12px;
}

.document-chip-name {
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text);
}

.document-chip-meta {
  color: var(--muted);
  white-space: nowrap;
}

.document-chip-remove {
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  padding: 0 2px;
}

.document-chip-remove:hover {
  color: #ff8a8a;
}

.upload-doc-btn {
  min-width: 40px;
  padding: 10px 12px;
  font-size: 16px;
  line-height: 1;
}

.typing {
  display: inline-flex;
  gap: 6px;
  align-items: center;
}

.typing span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted);
  animation: pulse 1.2s infinite ease-in-out;
}

.typing span:nth-child(2) { animation-delay: 0.15s; }
.typing span:nth-child(3) { animation-delay: 0.3s; }

@keyframes pulse {
  0%, 80%, 100% { transform: scale(0.7); opacity: 0.5; }
  40% { transform: scale(1); opacity: 1; }
}

@media (max-width: 960px) {
  .app {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
  }

  .sidebar {
    height: auto;
    max-height: 42vh;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .chat {
    min-height: 0;
  }
}

.user-panel {
  padding: 14px;
  border-radius: 16px;
  background: rgba(124, 92, 255, 0.08);
  border: 1px solid var(--border);
}

.user-meta {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 12px;
}

.user-meta strong {
  font-size: 15px;
}

.user-meta span,
.user-actions .ghost-btn {
  font-size: 13px;
}

.user-actions {
  display: flex;
  gap: 8px;
}

.user-actions .ghost-btn {
  flex: 1;
  text-align: center;
  text-decoration: none;
}

.admin-link {
  border-color: rgba(52, 211, 153, 0.35);
  color: var(--success);
}

.mode-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.mode-tab {
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--muted);
  border-radius: 12px;
  padding: 10px 12px;
  font: inherit;
  cursor: pointer;
  min-width: 0;
}

.nav-link-chat,
.nav-link-paint {
  border-color: rgba(56, 189, 148, 0.35);
  color: #a7f3d0;
}

.brand-icon-chat {
  background: rgba(56, 189, 148, 0.15);
}

.inline-link {
  color: #a7f3d0;
  text-decoration: none;
}

.inline-link:hover {
  text-decoration: underline;
}

.version-tag {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 6px;
  vertical-align: middle;
  margin-left: 4px;
  color: #a7f3d0;
  background: rgba(56, 189, 148, 0.15);
  border: 1px solid rgba(56, 189, 148, 0.35);
}

.mode-panel {
  flex-shrink: 0;
}

.mode-tab.active {
  color: var(--text);
  border-color: rgba(124, 92, 255, 0.45);
  background: rgba(124, 92, 255, 0.12);
}

.upload-panel {
  flex-shrink: 0;
}

.upload-slot {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 52px;
  height: 52px;
  border: 1px dashed var(--border);
  border-radius: 10px;
  color: var(--muted);
  cursor: pointer;
  overflow: hidden;
  transition: border-color 0.2s ease, background 0.2s ease, color 0.2s ease;
}

.upload-slot:hover {
  border-color: rgba(124, 92, 255, 0.45);
  background: rgba(124, 92, 255, 0.06);
  color: var(--primary-hover);
}

.upload-slot-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
}

.upload-slot-icon {
  width: 26px;
  height: 26px;
  display: block;
}

.upload-slot-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.upload-slot.dragover {
  border-color: rgba(124, 92, 255, 0.65);
  background: rgba(124, 92, 255, 0.08);
  color: var(--primary-hover);
}

.upload-slot.has-file {
  border-style: solid;
}

.auth-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.auth-card {
  width: min(100%, 420px);
  padding: 28px;
  border-radius: 20px;
  background: rgba(23, 26, 34, 0.92);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.auth-brand {
  margin-bottom: 24px;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.auth-form label {
  font-size: 13px;
  color: var(--muted);
}

.auth-form input,
.auth-form button {
  width: 100%;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  border-radius: 12px;
  padding: 12px 14px;
  font: inherit;
}

.auth-form button {
  margin-top: 8px;
  border: none;
  cursor: pointer;
  background: linear-gradient(135deg, var(--primary), #5b8cff);
  color: #fff;
}

.form-error {
  color: var(--danger);
  font-size: 13px;
  margin: 0;
}

.auth-switch {
  margin: 18px 0 0;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
}

.auth-switch a {
  color: var(--primary-hover);
  text-decoration: none;
}

.page-shell {
  max-width: 980px;
  margin: 0 auto;
  padding: 28px 20px 48px;
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 28px;
}

.page-header h1 {
  margin: 0 0 6px;
}

.page-header p {
  margin: 0;
  color: var(--muted);
}

.page-actions {
  display: flex;
  gap: 10px;
}

.recharge-section {
  margin-bottom: 28px;
}

.recharge-section h2 {
  margin: 0 0 14px;
  font-size: 18px;
}

.package-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
}

.package-card {
  padding: 18px;
  border-radius: 16px;
  background: var(--panel);
  border: 1px solid var(--border);
}

.package-card h3 {
  margin: 0 0 8px;
}

.package-price {
  margin: 0;
  font-size: 28px;
  font-weight: 700;
}

.package-credits {
  margin: 0 0 14px;
  color: var(--muted);
}

.package-card button {
  width: 100%;
  border: none;
  border-radius: 12px;
  padding: 10px 12px;
  font: inherit;
  cursor: pointer;
  color: #fff;
  background: linear-gradient(135deg, var(--primary), #5b8cff);
}

.record-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.record-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-radius: 14px;
  background: var(--panel);
  border: 1px solid var(--border);
}

.record-item p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.record-item button {
  border: none;
  border-radius: 10px;
  padding: 8px 12px;
  cursor: pointer;
  color: #fff;
  background: var(--primary);
  font: inherit;
}

.record-tag {
  color: var(--muted);
  font-size: 12px;
}

.record-empty,
.tips-list {
  color: var(--muted);
}

.tips-list {
  margin: 0;
  padding-left: 18px;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: grid;
  place-items: center;
  padding: 20px;
}

.modal[hidden] {
  display: none !important;
}

.modal-card {
  width: min(100%, 420px);
  padding: 24px;
  border-radius: 18px;
  background: var(--panel);
  border: 1px solid var(--border);
}

.modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 16px;
}

.modal-actions .ghost-btn,
.modal-actions button:last-child {
  flex: 1;
}

.modal-actions button:last-child {
  border: none;
  border-radius: 12px;
  padding: 12px;
  cursor: pointer;
  color: #fff;
  background: linear-gradient(135deg, var(--primary), #5b8cff);
  font: inherit;
}

.admin-shell .stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 14px;
  margin-bottom: 28px;
}

.stat-card {
  padding: 18px;
  border-radius: 16px;
  background: var(--panel);
  border: 1px solid var(--border);
}

.stat-card span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 8px;
}

.stat-card strong {
  font-size: 24px;
}

.admin-settings-section {
  margin-bottom: 28px;
}

.section-subtitle {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.settings-status {
  align-self: center;
  border-radius: 999px;
  padding: 8px 12px;
  background: rgba(239, 68, 68, 0.12);
  color: #dc2626;
  font-size: 13px;
  font-weight: 700;
}

.settings-status.ok {
  background: rgba(34, 197, 94, 0.12);
  color: #16a34a;
}

.settings-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-top: 18px;
}

.settings-form label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.settings-form input,
.settings-form textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.86);
  color: var(--text);
  font: inherit;
}

.settings-form textarea {
  resize: vertical;
}

.settings-form-wide,
.settings-actions {
  grid-column: 1 / -1;
}

.settings-toggle {
  display: flex !important;
  grid-column: 1 / -1;
  flex-direction: row;
  align-items: center;
  gap: 10px;
}

.settings-toggle input {
  width: auto;
}

.settings-actions {
  display: flex;
  align-items: center;
  gap: 14px;
}

.settings-actions button {
  border: 0;
  border-radius: 16px;
  padding: 12px 18px;
  background: linear-gradient(135deg, var(--primary), #5b8cff);
  color: white;
  font-weight: 800;
  cursor: pointer;
}

.settings-actions button:disabled {
  cursor: wait;
  opacity: 0.7;
}

.settings-message {
  color: var(--muted);
  font-weight: 700;
}

.settings-message.ok {
  color: #16a34a;
}

.settings-message.error {
  color: #dc2626;
}

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.search-bar {
  display: flex;
  gap: 8px;
}

.search-bar input {
  min-width: 220px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  border-radius: 12px;
  padding: 10px 12px;
  font: inherit;
}

.search-bar button,
.data-table button {
  border: none;
  border-radius: 10px;
  padding: 10px 14px;
  cursor: pointer;
  color: #fff;
  background: var(--primary);
  font: inherit;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 16px;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--panel);
}

.data-table th,
.data-table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  font-size: 14px;
}

.data-table th {
  color: var(--muted);
  font-weight: 600;
}

.table-empty {
  text-align: center;
  color: var(--muted);
}

.pager {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
  margin-top: 16px;
}

.modal-wide {
  width: min(100%, 760px);
  max-height: 90vh;
  overflow-y: auto;
}

.detail-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 8px 16px;
  margin-bottom: 18px;
}

.detail-summary p {
  margin: 0;
}

.adjust-form {
  display: grid;
  grid-template-columns: 160px 1fr auto;
  gap: 10px;
  margin-top: 10px;
}

.adjust-form input,
.adjust-form button {
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  border-radius: 12px;
  padding: 10px 12px;
  font: inherit;
}

.adjust-form button {
  border: none;
  color: #fff;
  background: linear-gradient(135deg, var(--primary), #5b8cff);
  cursor: pointer;
}

@media (max-width: 760px) {
  .settings-form {
    grid-template-columns: 1fr;
  }

  .section-head,
  .adjust-form {
    grid-template-columns: 1fr;
    flex-direction: column;
    align-items: stretch;
  }
}

.brand-icon-ppt {
  background: linear-gradient(135deg, #2563eb, #7c3aed);
}

.ppt-main .chat-header {
  border-bottom: 1px solid var(--border);
}

.ppt-workspace {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px 28px;
}

.ppt-form label {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 13px;
}

.ppt-form textarea {
  width: 100%;
  min-height: 120px;
  resize: vertical;
  margin-bottom: 16px;
}

.ppt-form-actions {
  display: flex;
  gap: 12px;
}

.ppt-reference-panel {
  margin-top: 14px;
  padding: 14px;
  border: 1px dashed var(--border);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.02);
}

.ppt-reference-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.ppt-reference-head label {
  margin: 0;
}

.ppt-reference-tip {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.ppt-reference-docs {
  margin-top: 10px;
}

.ppt-progress-panel,
.ppt-result-panel,
.ppt-error-panel {
  margin-top: 24px;
  padding: 18px 20px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.02);
}

.ppt-progress-head,
.ppt-result-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.ppt-result-actions,
.ppt-outline-actions,
.ppt-error-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.ppt-outline-actions {
  justify-content: flex-end;
  margin-top: 18px;
}

.ppt-progress-bar {
  height: 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

.ppt-progress-fill {
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--primary), #5b8cff);
  transition: width 0.35s ease;
}

.ppt-progress-message,
.ppt-result-meta {
  margin-top: 10px;
  color: var(--muted);
  font-size: 13px;
}

.ppt-progress-error {
  margin: 10px 0 0;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid rgba(255, 180, 72, 0.35);
  background: rgba(255, 180, 72, 0.1);
  color: #ffd27d;
  font-size: 13px;
  line-height: 1.55;
}

.ppt-progress-meta-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 12px;
}

.ppt-progress-meta {
  color: var(--muted);
  font-size: 12px;
}

.ppt-progress-detail {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.ppt-activity-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}

.ppt-activity-badge.running {
  color: #7dffb2;
  background: rgba(72, 199, 142, 0.12);
}

.ppt-activity-badge.running::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #48c78e;
  animation: ppt-pulse 1.2s ease-in-out infinite;
}

.ppt-activity-badge.waiting {
  color: #9ec5ff;
  background: rgba(91, 140, 255, 0.12);
}

.ppt-activity-badge.stalled {
  color: #ffd27d;
  background: rgba(255, 180, 72, 0.12);
}

@keyframes ppt-pulse {
  0%,
  100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.45;
    transform: scale(0.85);
  }
}

.ppt-slide-progress-list {
  list-style: none;
  margin: 14px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ppt-slide-progress-item {
  display: grid;
  grid-template-columns: 12px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.03);
  font-size: 12px;
}

.ppt-slide-progress-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.25);
}

.ppt-slide-progress-item.done .ppt-slide-progress-dot {
  background: #48c78e;
}

.ppt-slide-progress-item.active .ppt-slide-progress-dot {
  background: #5b8cff;
  animation: ppt-pulse 1.2s ease-in-out infinite;
}

.ppt-slide-progress-item.queued .ppt-slide-progress-dot {
  background: #ffd27d;
}

.ppt-slide-progress-title {
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ppt-slide-progress-state {
  color: var(--muted);
  flex-shrink: 0;
}

.ppt-slide-progress-item.active .ppt-slide-progress-state {
  color: #9ec5ff;
}

.ppt-slide-progress-item.done .ppt-slide-progress-state {
  color: #7dffb2;
}

.ppt-progress-actions {
  display: flex;
  gap: 10px;
  margin-top: 14px;
}

.status.warn {
  color: #ffd27d;
}

.ppt-slide-preview {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
  margin-top: 18px;
}

.ppt-slide-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.02);
}

.ppt-slide-card-image {
  aspect-ratio: 16 / 9;
  background: rgba(255, 255, 255, 0.04);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 12px;
}

.ppt-slide-card-image.regenerating {
  flex-direction: column;
  gap: 8px;
  background: rgba(124, 92, 255, 0.08);
}

.ppt-slide-regen-loading {
  color: #9ec5ff;
  font-size: 13px;
  animation: ppt-pulse 1.2s ease-in-out infinite;
}

.ppt-slide-card-actions {
  display: flex;
  justify-content: flex-end;
  padding: 0 14px 14px;
}

.ppt-slide-regen-btn {
  font-size: 12px;
  padding: 6px 10px;
}

.ppt-slide-regen-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.ppt-slide-card-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.ppt-slide-card-body {
  padding: 12px 14px 14px;
}

.ppt-slide-card-index {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 6px;
}

.ppt-slide-card-body h4 {
  margin: 0 0 8px;
  font-size: 15px;
}

.ppt-slide-card-subtitle {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 13px;
}

.ppt-slide-card-summary {
  margin: 0 0 10px;
  color: var(--text);
  font-size: 13px;
  line-height: 1.55;
}

.ppt-slide-card-body ul {
  margin: 0;
  padding-left: 18px;
  color: var(--text);
  font-size: 13px;
}

.ppt-slide-card-body li + li {
  margin-top: 4px;
}

.ppt-error-panel {
  border-color: rgba(255, 107, 107, 0.35);
  background: rgba(255, 107, 107, 0.08);
}

.ppt-error-panel p {
  margin: 8px 0 0;
  color: #ffb4b4;
}

.ppt-history-panel {
  margin-top: auto;
}

.ppt-job-history {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 220px;
  overflow-y: auto;
}

.ppt-job-item {
  display: flex;
  align-items: stretch;
  gap: 0;
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.02);
  overflow: hidden;
}

.ppt-job-item.active,
.ppt-job-item:hover {
  border-color: rgba(124, 92, 255, 0.45);
  background: rgba(124, 92, 255, 0.08);
}

.ppt-job-item-main {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  padding: 10px 12px;
  border: none;
  background: transparent;
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.ppt-job-item-delete {
  flex-shrink: 0;
  width: 34px;
  border: none;
  border-left: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  transition: color 0.2s ease, background 0.2s ease;
}

.ppt-job-item-delete:hover {
  color: #ff8a8a;
  background: rgba(255, 107, 107, 0.12);
}

.ppt-job-item-title {
  font-size: 13px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ppt-job-item-meta {
  font-size: 12px;
  color: var(--muted);
}

.ppt-steps {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.ppt-step {
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 13px;
  background: rgba(255, 255, 255, 0.02);
}

.ppt-step.active {
  color: #fff;
  border-color: rgba(124, 92, 255, 0.55);
  background: rgba(124, 92, 255, 0.18);
}

.ppt-step.done {
  color: #b9c7ff;
  border-color: rgba(124, 92, 255, 0.25);
}

.ppt-outline-panel {
  margin-top: 8px;
  padding: 18px 20px;
  border: 1px solid rgba(124, 92, 255, 0.35);
  border-radius: 14px;
  background: rgba(124, 92, 255, 0.06);
}

.ppt-outline-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 14px;
}

.ppt-outline-head h3 {
  margin: 0 0 6px;
}

.ppt-outline-tip,
.ppt-outline-cost {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
}

.ppt-outline-cost {
  white-space: nowrap;
  color: #c4b5fd;
}

.ppt-outline-title {
  width: 100%;
  margin-bottom: 16px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(15, 17, 23, 0.55);
  color: var(--text);
}

.ppt-outline-slides {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.ppt-outline-card {
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(15, 17, 23, 0.45);
}

.ppt-outline-card label {
  display: block;
  margin: 10px 0 6px;
  font-size: 12px;
  color: var(--muted);
}

.ppt-outline-card label:first-of-type {
  margin-top: 0;
}

.ppt-outline-card input,
.ppt-outline-card textarea {
  width: 100%;
  padding: 9px 11px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
}

.ppt-outline-card select,
.ppt-outline-select {
  width: 100%;
  padding: 11px 40px 11px 14px;
  border-radius: 10px;
  border: 1px solid rgba(124, 92, 255, 0.45);
  background-color: var(--panel-2);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23d8ccff' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 16px;
  color: #f5f7ff;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.4;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  color-scheme: dark;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.ppt-outline-card select:hover,
.ppt-outline-select:hover {
  border-color: rgba(146, 120, 255, 0.75);
  background-color: #252b3a;
}

.ppt-outline-card select:focus,
.ppt-outline-select:focus {
  outline: none;
  border-color: rgba(146, 120, 255, 0.9);
  box-shadow: 0 0 0 3px rgba(124, 92, 255, 0.22);
}

.ppt-outline-card select option,
.ppt-outline-select option {
  background: #1f2430;
  color: #eef2ff;
  font-size: 14px;
  font-weight: 500;
  padding: 8px;
}

.ppt-outline-card label:has(+ .ppt-outline-select),
.ppt-outline-card label:has(+ .slide-layout) {
  color: #d8ccff;
  font-size: 13px;
  font-weight: 600;
}

.ppt-outline-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}

.ppt-outline-badge {
  display: inline-flex;
  padding: 3px 10px;
  border-radius: 999px;
  background: rgba(124, 92, 255, 0.18);
  color: #d8ccff;
  font-size: 12px;
}

.ppt-error-actions {
  margin-top: 14px;
}
