:root {
  --bg: #0b0e14;
  --card: #12161f;
  --border: #232a38;
  --text: #e6e9f0;
  --muted: #8b94a7;
  --accent: #7c6cff;
  --accent-2: #a78bfa;
  --danger: #f87171;
  --success: #34d399;
}

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

body {
  background:
    radial-gradient(900px 500px at 80% -10%, rgba(124, 108, 255, 0.14), transparent 60%),
    radial-gradient(700px 400px at 10% 110%, rgba(167, 139, 250, 0.08), transparent 60%),
    var(--bg);
  color: var(--text);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  min-height: 100vh;
  display: flex;
  justify-content: center;
}

.page {
  position: relative;
  width: 100%;
  max-width: 720px;
  padding: 64px 20px 40px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

/* Hero */
.hero { text-align: center; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--accent-2);
  background: rgba(124, 108, 255, 0.1);
  border: 1px solid rgba(124, 108, 255, 0.28);
  padding: 6px 14px;
  border-radius: 999px;
  margin-bottom: 20px;
}

.hero h1 {
  font-size: clamp(30px, 5vw, 42px);
  font-weight: 800;
  letter-spacing: -0.02em;
}

.accent {
  background: linear-gradient(120deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.pitch {
  margin-top: 12px;
  color: var(--muted);
  font-size: 15.5px;
  line-height: 1.55;
  max-width: 480px;
  margin-left: auto;
  margin-right: auto;
}

/* Card */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 28px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.35);
}

/* Dropzone */
#dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 34px 20px;
  border: 1.5px dashed var(--border);
  border-radius: 14px;
  cursor: pointer;
  text-align: center;
  transition: border-color 0.15s ease, background 0.15s ease;
}

#dropzone:hover, #dropzone.dragover {
  border-color: var(--accent);
  background: rgba(124, 108, 255, 0.06);
}

#dropzone.has-file { border-style: solid; border-color: var(--accent); }

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

.dz-icon { color: var(--accent-2); }

.dz-text { font-size: 14.5px; font-weight: 500; }

.dz-browse { color: var(--accent-2); font-weight: 600; }

.dz-hint { font-size: 12.5px; color: var(--muted); }

/* Fields */
.fields {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  margin-top: 22px;
}

.field { flex: 1; display: flex; flex-direction: column; gap: 7px; }

.field label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.field input,
.field select {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-size: 14.5px;
  padding: 11px 14px;
  outline: none;
  transition: border-color 0.15s ease;
  width: 100%;
}

.field input:focus,
.field select:focus { border-color: var(--accent); }

.field select {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%238b94a7' stroke-width='2.5' 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;
  padding-right: 38px;
  cursor: pointer;
  font-family: inherit;
}

.field select option {
  background: var(--card);
  color: var(--text);
}

.arrow { color: var(--muted); flex-shrink: 0; margin-bottom: 11px; }

/* Checkbox */
.checkbox {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 18px;
  font-size: 14px;
  color: var(--muted);
  cursor: pointer;
}

.checkbox input { accent-color: var(--accent); width: 16px; height: 16px; cursor: pointer; }

/* Submit */
.submit {
  width: 100%;
  margin-top: 22px;
  padding: 13px;
  font-size: 15px;
  font-weight: 700;
  font-family: inherit;
  color: #fff;
  background: linear-gradient(120deg, var(--accent), var(--accent-2));
  border: none;
  border-radius: 11px;
  cursor: pointer;
  transition: opacity 0.15s ease, transform 0.1s ease;
}

.submit:hover { opacity: 0.9; }
.submit:active { transform: scale(0.99); }

/* Status */
.status {
  margin-top: 24px;
  padding: 18px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg);
}

.status-row { display: flex; align-items: center; gap: 10px; }

.status-title { font-size: 14.5px; font-weight: 600; word-break: break-all; }

.status-sub { margin-top: 10px; font-size: 13px; color: var(--muted); }

.status.done { border-color: rgba(52, 211, 153, 0.4); }
.status.done .status-row { color: var(--success); }

.status.error { border-color: rgba(248, 113, 113, 0.4); }
.status.error .status-row { color: var(--danger); }

.status.busy { border-color: rgba(124, 108, 255, 0.4); }
.status.busy .status-row { color: var(--accent-2); }

/* Progress */
.progress {
  margin-top: 14px;
  height: 8px;
  border-radius: 999px;
  background: var(--border);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width 0.6s ease;
}

/* Spinner */
.spinner {
  width: 17px;
  height: 17px;
  flex-shrink: 0;
  border: 2.5px solid rgba(124, 108, 255, 0.25);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* Download */
.download {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
  padding: 11px 18px;
  font-size: 14px;
  font-weight: 700;
  color: #fff;
  text-decoration: none;
  background: linear-gradient(120deg, var(--success), #6ee7b7);
  border-radius: 10px;
  transition: opacity 0.15s ease;
}

.download:hover { opacity: 0.9; }

/* Footer */
.footer {
  text-align: center;
  font-size: 12.5px;
  color: var(--muted);
  line-height: 1.7;
}

@media (max-width: 520px) {
  .fields { flex-direction: column; align-items: stretch; }
  .arrow { display: none; }
  .connection-fields { gap: 14px; }
}

/* Panels */
.panel[hidden] { display: none; }

/* Tabs — segmented control */
.tabs {
  display: flex;
  justify-content: center;
  gap: 4px;
  padding: 4px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  max-width: 280px;
  margin: 0 auto;
}

.tab {
  flex: 1;
  padding: 9px 20px;
  font-size: 13.5px;
  font-weight: 600;
  font-family: inherit;
  color: var(--muted);
  background: transparent;
  border: none;
  border-radius: 9px;
  cursor: pointer;
  transition: color 0.15s ease, background 0.15s ease;
}

.tab:hover { color: var(--text); }

.tab.active {
  color: #fff;
  background: linear-gradient(120deg, var(--accent), var(--accent-2));
  box-shadow: 0 2px 8px rgba(124, 108, 255, 0.3);
}

a.tab {
  text-decoration: none;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Connection section */
.connection {
  background: rgba(124, 108, 255, 0.04);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 22px;
}

.connection-title {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 14px;
}

.connection-fields {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.connection-hint {
  margin-top: 12px;
  font-size: 12.5px;
  color: var(--muted);
  line-height: 1.5;
}

/* Self-host card */
.selfhost-card { padding: 32px 28px; }

.selfhost-heading {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin-bottom: 8px;
}

.selfhost-intro {
  font-size: 14.5px;
  color: var(--muted);
  line-height: 1.55;
  margin-bottom: 28px;
}

.steps {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.step {
  display: flex;
  gap: 16px;
  align-items: flex-start;
}

.step-badge {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(120deg, var(--accent), var(--accent-2));
  border-radius: 50%;
  margin-top: 2px;
}

.step-body { flex: 1; min-width: 0; }

.step-text {
  font-size: 14.5px;
  color: var(--text);
  line-height: 1.55;
  margin-bottom: 10px;
}

.step-text a {
  color: var(--accent-2);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.step-text a:hover { color: var(--accent); }

.code-block {
  position: relative;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}

.code-block pre {
  padding: 14px 70px 14px 16px;
  overflow-x: auto;
  margin: 0;
}

.code-block code {
  font-family: "SF Mono", "Fira Code", "Fira Mono", Menlo, Consolas, monospace;
  font-size: 13px;
  color: var(--accent-2);
  white-space: pre;
}

.copy-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 600;
  font-family: inherit;
  color: var(--muted);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 7px;
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease;
}

.copy-btn:hover {
  color: var(--text);
  border-color: var(--accent);
}

.copy-btn.copied {
  color: var(--success);
  border-color: var(--success);
}

/* ------------------------------------------------------------------ */
/*  Info button                                                        */
/* ------------------------------------------------------------------ */

#info-btn {
  position: absolute;
  top: 20px;
  right: 20px;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 50%;
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
  z-index: 2;
}

#info-btn:hover {
  color: var(--accent-2);
  border-color: var(--accent);
  background: rgba(124, 108, 255, 0.08);
}

/* ------------------------------------------------------------------ */
/*  Modal                                                              */
/* ------------------------------------------------------------------ */

.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal[hidden] { display: none; }

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
}

.modal-card {
  position: relative;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 32px 28px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
  max-width: 640px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  z-index: 1;
}

.modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease;
}

.modal-close:hover {
  color: var(--text);
  border-color: var(--muted);
}

.selfhost-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 28px;
  padding: 12px 22px;
  font-size: 14px;
  font-weight: 700;
  color: #fff;
  text-decoration: none;
  background: linear-gradient(120deg, var(--accent), var(--accent-2));
  border-radius: 10px;
  transition: opacity 0.15s ease;
}

.selfhost-link:hover { opacity: 0.9; }

body.modal-open { overflow: hidden; }

/* ------------------------------------------------------------------ */
/*  Back link                                                          */
/* ------------------------------------------------------------------ */

.back-link {
  font-size: 13.5px;
  font-weight: 500;
  color: var(--muted);
  text-decoration: none;
  transition: color 0.15s ease;
  align-self: flex-start;
}

.back-link:hover { color: var(--accent-2); }

/* GitHub popup (portfolio) */
.github-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  width: 100%;
  margin-top: 18px;
  padding: 13px;
  font-size: 15px;
  font-weight: 700;
  color: #fff;
  text-decoration: none;
  background: linear-gradient(120deg, var(--accent), var(--accent-2));
  border-radius: 11px;
  transition: opacity 0.15s ease;
}

.github-link:hover { opacity: 0.9; }

.github-sub {
  margin-top: 14px;
  font-size: 13px;
  color: var(--muted);
  text-align: center;
}

/* ------------------------------------------------------------------ */
/*  Card headings                                                      */
/* ------------------------------------------------------------------ */

.card-heading {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin-bottom: 20px;
}

/* ------------------------------------------------------------------ */
/*  Ollama status & retry                                              */
/* ------------------------------------------------------------------ */

#ollama-status {
  margin-bottom: 4px;
}

#ollama-status .status {
  margin-top: 0;
}

.status-detail {
  margin-top: 12px;
  font-size: 13.5px;
  color: var(--muted);
  line-height: 1.55;
}

.status-detail a {
  color: var(--accent-2);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.status-detail a:hover { color: var(--accent); }

.status-actions {
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.retry-btn {
  align-self: flex-start;
  padding: 8px 18px;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  color: var(--muted);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease;
}

.retry-btn:hover {
  color: var(--accent-2);
  border-color: var(--accent);
}

/* ------------------------------------------------------------------ */
/*  Model field (self-host form)                                       */
/* ------------------------------------------------------------------ */

.model-field {
  margin-bottom: 22px;
}

/* ------------------------------------------------------------------ */
/*  Guide card extras                                                  */
/* ------------------------------------------------------------------ */

.guide-card .steps {
  gap: 28px;
}

.step-heading {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 6px;
}

.step-note {
  margin-top: 10px;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.5;
}

.step-note code {
  font-family: "SF Mono", "Fira Code", "Fira Mono", Menlo, Consolas, monospace;
  font-size: 12px;
  color: var(--accent-2);
  background: rgba(124, 108, 255, 0.08);
  padding: 2px 6px;
  border-radius: 4px;
}

/* ------------------------------------------------------------------ */
/*  Footer link                                                        */
/* ------------------------------------------------------------------ */

.footer a {
  color: var(--accent-2);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.footer a:hover { color: var(--accent); }

/* ------------------------------------------------------------------ */
/*  Responsive                                                         */
/* ------------------------------------------------------------------ */

@media (max-width: 520px) {
  .modal { padding: 12px; }
  .modal-card { padding: 24px 20px; border-radius: 14px; }
  .modal-close { top: 12px; right: 12px; }
  #info-btn { top: 14px; right: 14px; width: 36px; height: 36px; }
  #info-btn svg { width: 18px; height: 18px; }
}
