:root {
  color-scheme: light dark;
  --bg: #0f172a;
  --panel: rgba(15, 23, 42, 0.82);
  --panel-border: rgba(148, 163, 184, 0.16);
  --text: #e2e8f0;
  --muted: #94a3b8;
  --accent: #38bdf8;
  --accent-strong: #0ea5e9;
  --success: #34d399;
  --danger: #f87171;
  --font: "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  font-family: var(--font);
  background: radial-gradient(circle at top left, #1e293b, #020617);
  color: var(--text);
}

body {
  display: flex;
  justify-content: center;
}

.hidden {
  display: none !important;
}

.page {
  width: min(1200px, 94vw);
  padding: 3rem 0 6rem;
  display: grid;
  gap: 2rem;
}

.hero {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 2rem;
}

.hero h1 {
  margin: 0 0 0.75rem;
  font-size: clamp(2.25rem, 3vw, 3rem);
  font-weight: 700;
}

.hero p {
  margin: 0;
  max-width: 620px;
  line-height: 1.7;
  color: var(--muted);
  font-size: 1.05rem;
}

.hero-actions {
  display: grid;
  gap: 0.75rem;
  align-items: start;
  justify-items: end;
}

.hero-actions .status-badge {
  justify-self: end;
}

.status-badge {
  padding: 0.5rem 0.9rem;
  border-radius: 999px;
  background: rgba(56, 189, 248, 0.18);
  color: var(--accent);
  font-weight: 600;
  font-size: 0.9rem;
  align-self: center;
  white-space: nowrap;
}

.stepper {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
}

.step {
  padding: 1rem;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 1rem;
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  min-height: 110px;
  transition: transform 0.2s ease, border-color 0.2s ease;
}

.step.active {
  border-color: rgba(14, 165, 233, 0.5);
  transform: translateY(-4px);
}

.step.completed .step-index {
  background: var(--success);
}

.step-index {
  display: inline-flex;
  width: 2.4rem;
  height: 2.4rem;
  border-radius: 999px;
  align-items: center;
  justify-content: center;
  background: rgba(148, 163, 184, 0.2);
  font-weight: 700;
}

.step-info h2 {
  margin: 0;
  font-size: 1.1rem;
}

.step-info p {
  margin: 0.35rem 0 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.panels {
  display: grid;
  gap: 2rem;
}

.workflow {
  display: grid;
  gap: 2rem;
}

.workflow.hidden {
  display: none;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 1.5rem;
  padding: 1.8rem;
  display: grid;
  gap: 1.25rem;
}

.panel h3 {
  margin: 0;
  font-size: 1.4rem;
}

.panel-subtitle {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.dropzone {
  border: 1.5px dashed rgba(148, 163, 184, 0.4);
  border-radius: 1.1rem;
  padding: 2.5rem 1rem;
  display: grid;
  place-items: center;
  text-align: center;
  gap: 0.5rem;
  color: var(--muted);
  cursor: pointer;
  transition: border-color 0.2s ease, color 0.2s ease, background 0.2s ease;
}

.dropzone.compact {
  padding: 1.5rem 1rem;
}

.dropzone:hover {
  border-color: rgba(56, 189, 248, 0.7);
  color: var(--text);
  background: rgba(15, 118, 188, 0.08);
}

.dropzone.dragover {
  border-color: rgba(56, 189, 248, 0.85);
  background: rgba(15, 118, 188, 0.12);
  color: var(--text);
}

.dropzone input[type="file"] {
  display: none;
}

.dropzone-icon {
  font-size: 2rem;
}

.dropzone-text .accent {
  color: var(--accent);
  font-weight: 600;
}

.dropzone-hint {
  font-size: 0.85rem;
  color: rgba(148, 163, 184, 0.7);
}

.divider {
  display: grid;
  place-items: center;
  position: relative;
  text-transform: uppercase;
  font-size: 0.7rem;
  letter-spacing: 0.15em;
  color: rgba(148, 163, 184, 0.6);
  margin: 0.5rem 0;
}

.divider.prominent {
  margin: 1.25rem 0;
}

.divider::before {
  content: "";
  position: absolute;
  width: 100%;
  height: 1px;
  background: rgba(148, 163, 184, 0.2);
  top: 50%;
  left: 0;
  transform: translateY(-50%);
  z-index: 0;
}

.divider.prominent::before {
  height: 3px;
  background: linear-gradient(90deg, transparent, rgba(56, 189, 248, 0.5), transparent);
  box-shadow: 0 0 10px rgba(56, 189, 248, 0.3);
}

.divider span {
  padding: 0.25rem 0.75rem;
  background: var(--panel);
  position: relative;
  z-index: 1;
}

.divider.prominent span {
  font-size: 1.1rem;
  font-weight: 800;
  letter-spacing: 0.25em;
  color: #38bdf8;
  padding: 0.6rem 2rem;
  border-radius: 999px;
  background: linear-gradient(135deg, rgba(15, 23, 42, 0.98), rgba(30, 41, 59, 0.98));
  border: 2px solid rgba(56, 189, 248, 0.5);
  box-shadow: 0 0 20px rgba(56, 189, 248, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.1);
  text-shadow: 0 0 10px rgba(56, 189, 248, 0.5);
}

.inline-form {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  align-items: end;
}

.inline-form.compact {
  gap: 0.75rem;
}

.compact-upload-form {
  display: grid;
  gap: 0.75rem;
}

.field {
  display: grid;
  gap: 0.4rem;
  font-size: 0.95rem;
}

.field span {
  color: rgba(226, 232, 240, 0.85);
}

.field-help {
  font-size: 0.8rem;
  font-weight: 400;
  color: rgba(148, 163, 184, 0.75);
  font-style: italic;
}

.field-hint {
  font-size: 0.75rem;
  color: rgba(148, 163, 184, 0.65);
  line-height: 1.4;
  margin-top: -0.2rem;
}

.field-value {
  font-weight: 700;
  color: var(--accent);
  font-size: 0.95rem;
  margin-left: 0.5rem;
  font-style: normal;
}

.field input,
.field textarea {
  border: 1px solid rgba(148, 163, 184, 0.25);
  background: rgba(15, 23, 42, 0.5);
  color: var(--text);
  border-radius: 0.75rem;
  padding: 0.75rem 1rem;
  font: inherit;
  resize: none;
  transition: border 0.2s ease, background 0.2s ease;
}

/* Slider styles */
.slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 8px;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(56, 189, 248, 0.2), rgba(56, 189, 248, 0.5));
  outline: none;
  padding: 0;
  border: 1px solid rgba(56, 189, 248, 0.3);
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.3);
}

.slider:hover {
  background: linear-gradient(90deg, rgba(56, 189, 248, 0.3), rgba(56, 189, 248, 0.6));
}

.slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: linear-gradient(135deg, #38bdf8, #0ea5e9);
  cursor: pointer;
  border: 2px solid rgba(255, 255, 255, 0.3);
  box-shadow: 0 2px 8px rgba(56, 189, 248, 0.4);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.slider::-webkit-slider-thumb:hover {
  transform: scale(1.1);
  box-shadow: 0 4px 12px rgba(56, 189, 248, 0.6);
}

.slider::-moz-range-thumb {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: linear-gradient(135deg, #38bdf8, #0ea5e9);
  cursor: pointer;
  border: 2px solid rgba(255, 255, 255, 0.3);
  box-shadow: 0 2px 8px rgba(56, 189, 248, 0.4);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.slider::-moz-range-thumb:hover {
  transform: scale(1.1);
  box-shadow: 0 4px 12px rgba(56, 189, 248, 0.6);
}

.field input:focus,
.field textarea:focus {
  outline: none;
  border-color: rgba(56, 189, 248, 0.6);
  background: rgba(15, 118, 188, 0.15);
}

.field.compact input {
  max-width: 120px;
}

.btn {
  border: none;
  border-radius: 999px;
  padding: 0.75rem 1.5rem;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  background: rgba(148, 163, 184, 0.18);
  color: var(--text);
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.2s ease;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
}

.btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.25);
}

.btn.primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  color: #0b1120;
}

.btn.ghost {
  background: rgba(148, 163, 184, 0.08);
}

.file-table-wrap {
  overflow: auto;
  border-radius: 1rem;
  border: 1px solid rgba(148, 163, 184, 0.12);
}

.file-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 600px;
}

.file-table thead {
  background: rgba(15, 23, 42, 0.75);
}

.file-table th,
.file-table td {
  padding: 0.85rem 1rem;
  text-align: left;
  border-bottom: 1px solid rgba(148, 163, 184, 0.08);
}

.file-table tbody tr:hover {
  background: rgba(30, 41, 59, 0.6);
}

.file-table .badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.badge.ready {
  background: rgba(52, 211, 153, 0.18);
  color: var(--success);
}

.badge.processing {
  background: rgba(234, 179, 8, 0.18);
  color: #facc15;
}

.badge.failed {
  background: rgba(248, 113, 113, 0.18);
  color: var(--danger);
}

.file-table .empty {
  text-align: center;
  color: var(--muted);
  padding: 2.2rem 1rem;
}

.chat-panel {
  min-height: 640px;
  display: grid;
  gap: 1.35rem;
}

.chat-window {
  border-radius: 1.2rem;
  border: 1px solid rgba(148, 163, 184, 0.12);
  background: rgba(15, 23, 42, 0.55);
  padding: 1.25rem;
  display: grid;
  gap: 1rem;
  min-height: 320px;
  max-height: 520px;
  overflow-y: auto;
  box-shadow: inset 0 0 26px rgba(2, 6, 23, 0.35);
}

.chat-window:empty::before {
  content: "Conversation history will appear here after you ask a question.";
  color: rgba(148, 163, 184, 0.8);
  text-align: center;
  font-size: 0.95rem;
  line-height: 1.6;
}

.message {
  padding: 1rem;
  border-radius: 1rem;
  background: rgba(15, 23, 42, 0.55);
  border: 1px solid rgba(148, 163, 184, 0.12);
  display: grid;
  gap: 0.75rem;
}

.message header {
  display: flex;
  justify-content: space-between;
  color: rgba(148, 163, 184, 0.75);
  font-size: 0.85rem;
}

.message .role {
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.message .content {
  margin: 0;
  white-space: pre-wrap;
  line-height: 1.7;
}

.message .citations {
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.6rem;
  color: var(--accent);
}

.message .citations li {
  list-style: none;
  padding: 0.75rem 0.9rem;
  border-radius: 0.85rem;
  border: 1px solid rgba(148, 163, 184, 0.14);
  background: rgba(15, 23, 42, 0.45);
  display: grid;
  gap: 0.35rem;
}

.message .citations .citation-title {
  font-weight: 600;
  color: var(--text);
}

.message .citations .citation-title a {
  color: inherit;
  text-decoration: underline;
}

.message .citations .citation-meta {
  font-size: 0.75rem;
  color: var(--muted);
  word-break: break-all;
}

.message .citations .snippet {
  margin-top: 0.2rem;
  color: rgba(148, 163, 184, 0.85);
  font-size: 0.85rem;
  white-space: pre-wrap;
}

.message .citations .citation-error {
  font-size: 0.75rem;
  color: var(--danger);
}

.chat-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.chat-input-row {
  display: flex;
  gap: 0.75rem;
  align-items: flex-end;
}

.chat-input-row textarea {
  flex: 1;
  min-height: 160px;
  border-radius: 1rem;
  border: 1px solid rgba(148, 163, 184, 0.35);
  background: #ffffff;
  color: #0f172a;
  padding: 1.15rem 1.25rem;
  font-size: 1.05rem;
  line-height: 1.7;
  resize: vertical;
  box-shadow: inset 0 0 18px rgba(15, 23, 42, 0.15);
}

.chat-input-row textarea:focus {
  outline: none;
  border-color: rgba(56, 189, 248, 0.65);
  box-shadow: inset 0 0 20px rgba(15, 118, 188, 0.12);
}

.chat-input-row textarea::placeholder {
  color: rgba(15, 23, 42, 0.55);
}

.chat-input-row .btn {
  min-width: 170px;
  padding: 0.95rem 1.5rem;
  font-size: 1rem;
  border-radius: 999px;
  align-self: flex-end;
  display: flex;
  align-items: center;
  justify-content: center;
}

.chat-controls {
  display: flex;
  gap: 1.2rem;
  flex-wrap: wrap;
}

.chat-controls .field {
  flex: 1;
  min-width: 160px;
}

@media (max-width: 768px) {
  .chat-input-row {
    flex-direction: column;
  }
  .chat-input-row .btn {
    align-self: stretch;
    width: 100%;
  }
  .chat-controls {
    flex-direction: column;
  }
}

#toast {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  min-width: 270px;
  padding: 1rem 1.25rem;
  border-radius: 1rem;
  background: rgba(15, 23, 42, 0.92);
  border: 1px solid rgba(56, 189, 248, 0.45);
  color: var(--text);
  font-weight: 500;
  box-shadow: 0 10px 40px rgba(15, 23, 42, 0.35);
  opacity: 0;
  pointer-events: none;
  transform: translateY(20px);
  transition: opacity 0.3s ease, transform 0.3s ease;
}

#toast.visible {
  opacity: 1;
  transform: translateY(0);
}

#toast[data-variant="success"] {
  border-color: rgba(52, 211, 153, 0.6);
}

#toast[data-variant="error"] {
  border-color: rgba(248, 113, 113, 0.7);
}

#toast[data-variant="warning"] {
  border-color: rgba(234, 179, 8, 0.7);
}

.status-note {
  min-height: 1.2rem;
  font-size: 0.9rem;
  color: var(--muted);
}

.status-note.active {
  color: var(--accent);
}

.status-note.success {
  color: var(--success);
}

.status-note.error {
  color: var(--danger);
}

.selected-files {
  list-style: none;
  padding: 0;
  margin: 0.75rem 0 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.selected-files li {
  padding: 0.3rem 0.75rem;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.18);
  color: var(--text);
  font-size: 0.85rem;
  border: 1px solid rgba(148, 163, 184, 0.2);
}

.selected-files.hidden {
  display: none;
}

.status-list {
  margin-top: 0.75rem;
  display: grid;
  gap: 0.5rem;
  font-size: 0.9rem;
}

.status-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 0.75rem;
  border-radius: 0.75rem;
  border: 1px solid rgba(148, 163, 184, 0.14);
  background: rgba(15, 23, 42, 0.45);
}

.status-item.processing {
  border-color: rgba(56, 189, 248, 0.35);
}

.status-item.success {
  border-color: rgba(52, 211, 153, 0.35);
}

.status-item.error {
  border-color: rgba(248, 113, 113, 0.35);
}

.status-item .status-pill {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.2);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.status-item.processing .status-pill {
  background: rgba(56, 189, 248, 0.18);
  color: var(--accent);
}

.status-item.success .status-pill {
  background: rgba(52, 211, 153, 0.18);
  color: var(--success);
}

.status-item.error .status-pill {
  background: rgba(248, 113, 113, 0.18);
  color: var(--danger);
}

.model-hub {
  gap: 1.5rem;
}

.model-list {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
}

.model-card {
  padding: 1.25rem;
  border-radius: 1.1rem;
  border: 1px solid rgba(148, 163, 184, 0.18);
  background: rgba(15, 23, 42, 0.45);
  display: grid;
  gap: 0.45rem;
  text-align: left;
  cursor: pointer;
  transition: transform 0.18s ease, border-color 0.2s ease, background 0.2s ease;
}

.model-card:hover {
  transform: translateY(-2px);
  border-color: rgba(56, 189, 248, 0.35);
  background: rgba(15, 118, 188, 0.12);
}

.model-card.active {
  border-color: rgba(14, 165, 233, 0.5);
  background: rgba(14, 116, 144, 0.2);
}

.model-card .model-name {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text);
}

.model-card .model-meta {
  font-size: 0.85rem;
  color: var(--muted);
}

.model-card .model-updated {
  font-size: 0.8rem;
  color: rgba(148, 163, 184, 0.7);
}

.model-card.skeleton {
  position: relative;
  overflow: hidden;
}

.model-card.skeleton::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(120deg, transparent 0%, rgba(148, 163, 184, 0.1) 50%, transparent 100%);
  animation: shimmer 1.6s infinite;
}

.model-empty {
  padding: 2.5rem;
  border-radius: 1rem;
  border: 1px dashed rgba(148, 163, 184, 0.25);
  text-align: center;
  color: var(--muted);
  font-size: 0.95rem;
}

@keyframes shimmer {
  0% {
    transform: translateX(-100%);
  }
  100% {
    transform: translateX(100%);
  }
}

@media (max-width: 900px) {
  .hero {
    flex-direction: column;
  }
  .status-badge {
    align-self: flex-start;
  }
  .chat-window {
    max-height: 340px;
  }
}

@media (max-width: 640px) {
  .page {
    gap: 1.5rem;
    padding: 2rem 0 4rem;
  }
  .panel {
    padding: 1.35rem;
  }
  .chat-actions {
    flex-direction: column;
    align-items: stretch;
  }
  .field.compact input {
    max-width: 100%;
  }
  .btn {
    width: 100%;
  }
}

/* Modal */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1rem;
}

.modal.hidden {
  display: none;
}

.modal-content {
  background: var(--bg);
  border: 1px solid var(--panel-border);
  border-radius: 1rem;
  padding: 2rem;
  max-width: 500px;
  width: 100%;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.modal-content h3 {
  margin: 0 0 1.5rem;
  font-size: 1.5rem;
  color: var(--text);
}

.modal-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: flex-end;
  margin-top: 1.5rem;
}


