/* Light, professional theme is the default. Dark theme lives under
   [data-theme="dark"] and is toggled by the header button (see app.js). */
:root {
  --bg: #f4f6fb;
  --bg-2: #eaeef5;
  --panel: #ffffff;
  --panel-2: #f2f4f9;
  --border: #e1e6ef;
  --text: #1c2333;
  --muted: #667085;
  --accent: #4a63ee;
  --accent-2: #8b5cf6;
  --green: #12915a;
  --amber: #b3760f;
  --red: #d92d2d;
  --radius: 14px;
  --shadow: 0 10px 30px rgba(28, 35, 51, 0.08);

  --bg-tint-1: rgba(74, 99, 238, 0.06);
  --bg-tint-2: rgba(139, 92, 246, 0.06);
  --input-bg: rgba(28, 35, 51, 0.03);
  --input-bg-focus: rgba(28, 35, 51, 0.045);
  --input-border: rgba(28, 35, 51, 0.14);
  --input-border-hover: rgba(28, 35, 51, 0.24);
  --overlay-bg: rgba(28, 35, 51, 0.45);
  --topbar-bg: rgba(255, 255, 255, 0.82);
  --error-bg: rgba(217, 45, 45, 0.08);
  --error-text: #b32424;
  --accent-soft: rgba(74, 99, 238, 0.1);
  --term-bg: #0d1220;
  --term-text: #b9c4dc;
  --term-sep: #33405e;
}

html[data-theme="dark"] {
  --bg: #0b0e14;
  --bg-2: #11151f;
  --panel: #151b28;
  --panel-2: #1b2333;
  --border: #232c40;
  --text: #e6eaf2;
  --muted: #8b95ab;
  --accent: #6c8cff;
  --accent-2: #9a6cff;
  --green: #3fd08a;
  --amber: #f5b73d;
  --red: #ff6b6b;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);

  --bg-tint-1: rgba(108, 140, 255, 0.1);
  --bg-tint-2: rgba(154, 108, 255, 0.1);
  --input-bg: rgba(255, 255, 255, 0.03);
  --input-bg-focus: rgba(255, 255, 255, 0.05);
  --input-border: rgba(255, 255, 255, 0.14);
  --input-border-hover: rgba(255, 255, 255, 0.26);
  --overlay-bg: rgba(4, 6, 10, 0.7);
  --topbar-bg: rgba(17, 21, 31, 0.7);
  --error-bg: rgba(255, 107, 107, 0.12);
  --error-text: #ffb3b3;
  --accent-soft: rgba(108, 140, 255, 0.15);
  --term-bg: #06090f;
  --term-text: #b9c4dc;
  --term-sep: #33405e;
}

* { box-sizing: border-box; }

/* Reset native OS/browser chrome on form controls (most visible on macOS
   Safari) so our own padding/border/radius actually renders instead of
   being overridden by -webkit-appearance defaults. Checkboxes/radios/selects
   are excluded — they still rely on native rendering (checkmark / dropdown
   arrow) that we haven't replaced with a custom equivalent. */
button, textarea,
input:not([type=checkbox]):not([type=radio]) {
  font: inherit;
  -webkit-appearance: none;
  appearance: none;
}

html, body {
  margin: 0;
  height: 100%;
  background: radial-gradient(1200px 600px at 80% -10%, var(--bg-tint-1), transparent 60%),
              radial-gradient(900px 500px at -10% 110%, var(--bg-tint-2), transparent 60%),
              var(--bg);
  color: var(--text);
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  font-size: 15px;
  transition: background-color 0.2s ease, color 0.2s ease;
}

.app { display: flex; flex-direction: column; min-height: 100vh; }

/* Topbar */
.topbar {
  display: flex; align-items: center; gap: 18px;
  padding: 14px 26px;
  border-bottom: 1px solid var(--border);
  background: var(--topbar-bg);
  backdrop-filter: blur(10px);
  position: sticky; top: 0; z-index: 20;
}
.brand { display: flex; align-items: center; gap: 10px; font-size: 18px; cursor: pointer; }
.brand b { font-weight: 700; }
.brand .logo {
  font-size: 22px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.crumbs { flex: 1; color: var(--muted); font-size: 14px; }
.crumbs span.sep { margin: 0 8px; opacity: 0.5; }
.crumbs .crumb-current { color: var(--text); }
.crumbs .crumb-link { cursor: pointer; transition: color 0.15s; border-radius: 4px; }
.crumbs .crumb-link:hover { color: var(--accent); text-decoration: underline; }

/* Buttons */
.btn {
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  padding: 9px 16px;
  border-radius: 10px;
  font-size: 14px; font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
}
.btn:hover { border-color: var(--accent); transform: translateY(-1px); }
.btn.primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border: none; color: white; font-weight: 600;
}
.btn.primary:hover { box-shadow: 0 6px 18px rgba(108, 140, 255, 0.4); }
.btn.danger:hover { border-color: var(--red); color: var(--red); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.icon-btn {
  background: transparent; border: none; color: var(--muted);
  font-size: 18px; cursor: pointer; padding: 4px 8px; border-radius: 8px;
}
.icon-btn:hover { color: var(--text); background: var(--panel-2); }

/* Theme toggle */
.theme-toggle {
  display: inline-flex; align-items: center; justify-content: center;
  width: 38px; height: 38px; padding: 0; font-size: 17px; flex-shrink: 0;
}
.theme-toggle .icon-dark { display: none; }
.theme-toggle .icon-light { display: inline; }
html[data-theme="dark"] .theme-toggle .icon-dark { display: inline; }
html[data-theme="dark"] .theme-toggle .icon-light { display: none; }

/* Footer */
.app-footer {
  text-align: center;
  padding: 14px 26px;
  font-size: 13px;
  color: var(--muted);
  border-top: 1px solid var(--border);
}
.app-footer b { color: var(--text); font-weight: 600; }

/* Views */
.view { padding: 30px 26px; max-width: 1200px; width: 100%; margin: 0 auto; flex: 1; }
.view-head { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 24px; gap: 16px; }
h1 { font-size: 26px; margin: 0 0 4px; }
.muted { color: var(--muted); margin: 0; }
.small { font-size: 12px; }

/* Cards */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 18px; }
.card {
  background: linear-gradient(180deg, var(--panel), var(--bg-2));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex; flex-direction: column; gap: 12px;
  transition: all 0.18s ease;
  position: relative; overflow: hidden;
}
.card::before {
  content: ""; position: absolute; inset: 0 0 auto 0; height: 3px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  opacity: 0; transition: opacity 0.18s;
}
.card:hover { transform: translateY(-3px); border-color: var(--accent); box-shadow: var(--shadow); }
.card:hover::before { opacity: 1; }
.card h3 { margin: 0; font-size: 17px; }
.card .desc { color: var(--muted); font-size: 13px; min-height: 18px; }
.card .meta { display: flex; gap: 14px; color: var(--muted); font-size: 12px; flex-wrap: wrap; }
.card .actions { display: flex; flex-direction: column; gap: 8px; margin-top: auto; }
.card .actions-primary { display: flex; gap: 8px; }
.card .actions-primary .btn { padding: 7px 12px; font-size: 13px; flex: 1; }
.card .actions-icons { display: flex; gap: 6px; }
.card .actions-icons .btn { padding: 6px 10px; font-size: 13px; }

.files-body { padding: 22px; }
.filelist.download li { justify-content: flex-start; gap: 10px; }
.filelist.download li a { color: var(--accent); text-decoration: none; font-size: 13px; margin-left: auto; }
.filelist.download li a:hover { text-decoration: underline; }

.badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 600; padding: 4px 10px; border-radius: 20px;
  border: 1px solid var(--border);
}
.badge .dot { width: 7px; height: 7px; border-radius: 50%; }
.badge.ready { color: var(--green); } .badge.ready .dot { background: var(--green); }
.badge.building { color: var(--amber); } .badge.building .dot { background: var(--amber); animation: pulse 1s infinite; }
.badge.error { color: var(--red); } .badge.error .dot { background: var(--red); }
.badge.new { color: var(--muted); } .badge.new .dot { background: var(--muted); }
/* Stopped on purpose — not a failure, so it reads neutral rather than red. */
.badge.cancelled { color: var(--muted); } .badge.cancelled .dot { background: var(--muted); }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.3; } }

/* Empty state */
.empty { text-align: center; padding: 80px 20px; }
.empty-icon { font-size: 54px; background: linear-gradient(135deg, var(--accent), var(--accent-2)); -webkit-background-clip: text; background-clip: text; color: transparent; margin-bottom: 12px; }
.empty h2 { margin: 8px 0; }
.empty .btn { margin-top: 18px; }

/* Terminal */
.build-status { }
.terminal {
  background: var(--term-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px; line-height: 1.65;
  height: 58vh; overflow-y: auto;
  white-space: pre-wrap; word-break: break-word;
}
.terminal .ln { color: var(--term-text); }
.terminal .ln.sep { color: var(--term-sep); }
.terminal .ln.ok { color: var(--green); }
.terminal .ln.err { color: var(--red); }
.terminal .ln.step { color: var(--accent); }
.terminal .cursor { color: var(--accent); animation: blink 1s step-end infinite; }
@keyframes blink { 50% { opacity: 0; } }
.build-actions { display: flex; justify-content: space-between; margin-top: 18px; }

/* Chat */
.chat-view { display: flex; flex-direction: column; height: calc(100vh - 60px); }
.chat-view[hidden] { display: none; }
.chat-controls select {
  background: var(--panel-2); color: var(--text);
  border: 1px solid var(--border); border-radius: 8px; padding: 6px 8px; margin-left: 8px;
}
.chat-controls label { color: var(--muted); font-size: 13px; }
.messages { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 16px; padding: 8px 2px 20px; }
.msg { max-width: 82%; padding: 14px 16px; border-radius: 14px; line-height: 1.6; white-space: pre-wrap; }
.msg.user { align-self: flex-end; background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: white; border-bottom-right-radius: 4px; }
.msg.bot { align-self: flex-start; background: var(--panel); border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.msg.bot.loading { color: var(--muted); font-style: italic; }
.msg .who { font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; opacity: 0.7; margin-bottom: 6px; }
/* Rendered markdown answer. The bubble keeps `pre-wrap` for plain text, which
   would double every gap once real block elements exist — so opt out here. */
.msg .md { white-space: normal; }
.msg .md > :first-child { margin-top: 0; }
.msg .md > :last-child { margin-bottom: 0; }
.msg .md p { margin: 0 0 10px; }
.msg .md h4 {
  margin: 16px 0 8px; font-size: 12px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.05em; color: var(--accent);
}
.msg .md ul, .msg .md ol { margin: 0 0 10px; padding-left: 20px; }
.msg .md li { margin-bottom: 6px; }
.msg .md li::marker { color: var(--accent); }
.msg .md strong { font-weight: 650; }
/* Structured answers need more room than a one-line reply. */
.msg.bot:has(.md) { max-width: 92%; }
.method-tag {
  display: inline-block; margin-left: 8px; padding: 1px 8px; border-radius: 10px;
  background: var(--accent-soft); color: var(--accent);
  font-size: 10px; text-transform: none; letter-spacing: 0; font-weight: 600;
}
/* Opening question offered before the user has typed anything. Centred and
   pill-shaped rather than bubble-shaped: nobody in the conversation said it, so
   it should read as an action rather than as a message from either side. */
.suggestion {
  align-self: center; max-width: 82%;
  display: flex; flex-direction: column; align-items: center; gap: 7px;
}
.suggestion-label {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--muted);
}
.suggestion-chip {
  cursor: pointer;
  padding: 10px 18px; border-radius: 999px;
  border: 1px solid var(--accent-soft); background: var(--accent-soft);
  color: var(--accent); font: inherit; font-size: 13.5px; font-weight: 550;
  line-height: 1.5; text-align: center; white-space: normal;
  transition: border-color 0.15s ease, transform 0.15s ease;
}
.suggestion-chip:hover { border-color: var(--accent); transform: translateY(-1px); }
.suggestion-chip:active { transform: none; }
.composer { display: flex; gap: 10px; padding-top: 14px; border-top: 1px solid var(--border); }
.composer textarea {
  flex: 1; resize: none; background: var(--panel); color: var(--text);
  border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px;
  font-family: inherit; font-size: 15px; max-height: 160px;
}
.composer textarea:focus { outline: none; border-color: var(--accent); }

/* Modal */
.modal-backdrop {
  position: fixed; inset: 0; background: var(--overlay-bg);
  backdrop-filter: blur(4px); display: flex; align-items: center; justify-content: center;
  z-index: 50; padding: 20px;
}
/* Author rules beat the browser's default [hidden]{display:none}, so it must
   be restated here explicitly or the modal stays visible even when hidden. */
.modal-backdrop[hidden] { display: none; }
.modal {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  width: 100%; max-width: 520px; box-shadow: var(--shadow); overflow: hidden;
  transition: background-color 0.2s ease, border-color 0.2s ease;
  display: flex; flex-direction: column; max-height: 90vh;
}
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 18px 22px; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.modal-head h2 { margin: 0; font-size: 18px; }
.modal-form { padding: 22px; display: flex; flex-direction: column; min-height: 0; overflow-y: auto; }
.field { display: block; margin-bottom: 18px; }
/* Same trap as .modal-backdrop above: the display rules on .field / .checkbox
   are author rules, so they beat the browser's [hidden]{display:none} and the
   engine-specific fields would stay visible when hidden. */
.field[hidden], .checkbox[hidden] { display: none; }
.field > span { display: block; font-size: 13px; font-weight: 500; margin-bottom: 7px; }
.field em { color: var(--muted); font-style: normal; }
.field input[type=text] {
  width: 100%; background: var(--input-bg); border: 1px solid var(--input-border);
  color: var(--text); border-radius: 10px; padding: 11px 13px; font-size: 14px; font-family: inherit;
  transition: border-color 0.15s, background 0.15s;
}
.field input[type=text]::placeholder { color: var(--muted); }
.field input[type=text]:hover { border-color: var(--input-border-hover); }
.field input:focus { outline: none; border-color: var(--accent); background: var(--input-bg-focus); }

/* Engine chooser (GraphRAG vs HippoRAG) */
.engine-choice { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.engine-option { display: block; cursor: pointer; }
.engine-option input { position: absolute; opacity: 0; pointer-events: none; }
.engine-card {
  display: flex; flex-direction: column; gap: 5px; height: 100%;
  background: var(--bg-2); border: 1.5px solid var(--border); border-radius: 12px;
  padding: 12px 13px; transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
}
.engine-option:hover .engine-card { border-color: var(--input-border-hover); }
.engine-option input:checked + .engine-card {
  border-color: var(--accent); background: var(--accent-soft);
  box-shadow: 0 0 0 1px var(--accent) inset;
}
.engine-option input:focus-visible + .engine-card { border-color: var(--accent); }
.engine-name { font-size: 14px; font-weight: 600; color: var(--text); }
.engine-desc { font-size: 12px; line-height: 1.45; color: var(--muted); }
.engine-hint {
  margin: 10px 0 0; padding: 9px 11px; border-radius: 9px;
  font-size: 12px; line-height: 1.5; color: var(--amber);
  background: rgba(179,118,15,0.08); border: 1px solid var(--amber);
}
.engine-hint b { font-weight: 600; }

/* Per-engine settings block (Advanced RAG Corpus connection details) */
.engine-config {
  display: flex; flex-direction: column; gap: 12px;
  background: var(--bg-2); border: 1px solid var(--border);
  border-radius: 12px; padding: 14px;
}
/* The flex gap does all the spacing here, so drop the margins these two
   inherit from .field > span and .field-help. */
.engine-config > span, .engine-config > .field-help { margin: 0; }
.subfield { display: block; }
.subfield > span {
  display: block; font-size: 12px; font-weight: 500; color: var(--muted);
  margin-bottom: 6px;
}
/* Columns that have to line up, so spacing comes from the grid gap alone: an
   adjacent-sibling margin would push every column except the first one down. */
.subfield-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px; align-items: start;
}

/* Engine tag on cards + chat header */
.engine-tag {
  display: inline-flex; align-items: center; gap: 5px; font-size: 11px; font-weight: 600;
  padding: 3px 9px; border-radius: 20px; border: 1px solid var(--border);
  color: var(--muted); background: var(--bg-2); text-transform: none; letter-spacing: 0.2px;
}
.engine-tag.hipporag { color: var(--accent-2); border-color: var(--accent-2); background: rgba(139,92,246,0.08); }
.engine-tag.graphrag { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }
.engine-tag.fullcontext { color: var(--green); border-color: var(--green); background: rgba(18,145,90,0.08); }
.engine-tag.vertexrag { color: var(--amber); border-color: var(--amber); background: rgba(179,118,15,0.08); }

.domain-tag {
  display: inline-flex; align-items: center; gap: 4px; font-size: 11px; font-weight: 500;
  padding: 3px 9px; border-radius: 20px; border: 1px solid var(--border);
  color: var(--text); background: var(--bg-2); max-width: 180px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.field select {
  width: 100%; background: var(--input-bg); border: 1px solid var(--input-border);
  color: var(--text); border-radius: 10px; padding: 11px 13px; font-size: 14px;
  font-family: inherit; appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 18px) calc(50% - 3px), calc(100% - 12px) calc(50% - 3px);
  background-size: 6px 6px, 6px 6px; background-repeat: no-repeat;
  transition: border-color 0.15s, background-color 0.15s;
}
.field select:hover { border-color: var(--input-border-hover); }
.field select:focus { outline: none; border-color: var(--accent); background-color: var(--input-bg-focus); }
.field-help {
  display: block; margin-top: 7px; font-size: 12px; line-height: 1.45; color: var(--muted);
}

.categories-modal { width: min(640px, 94vw); }
.categories-body { padding: 18px 22px 22px; display: flex; flex-direction: column; gap: 14px; max-height: 70vh; overflow-y: auto; }
.categories-list { display: flex; flex-direction: column; gap: 10px; }
.category-row {
  display: flex; justify-content: space-between; gap: 14px; align-items: flex-start;
  padding: 12px 14px; border: 1px solid var(--border); border-radius: 12px; background: var(--bg-2);
}
.category-row.inactive { opacity: 0.65; }
.category-row p { margin: 6px 0 0; font-size: 13px; color: var(--muted); line-height: 1.45; }
.category-version { margin-left: 8px; font-size: 11px; color: var(--muted); font-weight: 500; }
.category-row-actions { display: flex; flex-direction: column; gap: 6px; flex-shrink: 0; }
.category-form { border-top: 1px solid var(--border); padding-top: 14px; }
.category-actions { display: flex; justify-content: flex-end; gap: 8px; }
.category-form textarea {
  width: 100%; background: var(--input-bg); border: 1px solid var(--input-border);
  color: var(--text); border-radius: 10px; padding: 11px 13px; font-size: 14px;
  font-family: inherit; resize: vertical; min-height: 110px;
  transition: border-color 0.15s, background 0.15s;
}
.category-form textarea:hover { border-color: var(--input-border-hover); }
.category-form textarea:focus { outline: none; border-color: var(--accent); background: var(--input-bg-focus); }

@media (max-width: 720px) {
  .topbar .btn#manageCategoriesBtn { display: none; }
  .category-row { flex-direction: column; }
  .category-row-actions { flex-direction: row; }
  .domain-tag { max-width: 140px; }
}

.dropzone {
  border: 1.5px dashed var(--border); border-radius: 12px; padding: 26px;
  text-align: center; cursor: pointer; transition: all 0.15s; background: var(--bg-2);
}
.dropzone:hover, .dropzone.drag { border-color: var(--accent); background: rgba(108,140,255,0.06); }
.dz-icon { font-size: 26px; color: var(--accent); }
.dz-inner p { margin: 6px 0 0; }
.filelist { list-style: none; padding: 0; margin: 10px 0 0; display: flex; flex-direction: column; gap: 6px; max-height: 200px; overflow-y: auto; }
.filelist li {
  display: flex; justify-content: space-between; align-items: center;
  background: var(--bg-2); border: 1px solid var(--border); border-radius: 8px;
  padding: 7px 12px; font-size: 13px;
}
.filelist li .fname { display: flex; align-items: center; gap: 6px; min-width: 0; }
.filelist li .fname .tick {
  display: inline-flex; align-items: center; justify-content: center;
  width: 16px; height: 16px; border-radius: 50%; flex-shrink: 0;
  background: var(--green, #1db954); color: #fff; font-size: 10px; font-weight: 700;
}
.filelist li .rm {
  color: var(--muted); cursor: pointer; flex-shrink: 0; margin-left: 10px;
  opacity: 0; transition: opacity 0.15s;
}
.filelist li:hover .rm, .filelist li:focus-within .rm { opacity: 1; }
.filelist li .rm:hover { color: var(--red); }

.form-error {
  background: var(--error-bg); border: 1px solid var(--red);
  color: var(--error-text); border-radius: 10px; padding: 10px 13px; margin-bottom: 16px;
  font-size: 13px; line-height: 1.5;
}
.modal-foot {
  display: flex; justify-content: space-between; align-items: center;
  margin-top: 6px; position: sticky; bottom: -22px; flex-shrink: 0;
  background: var(--panel); padding: 16px 0 0; margin-bottom: -22px;
  padding-bottom: 22px;
}
.checkbox { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }

/* Toast */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--panel-2); border: 1px solid var(--border); color: var(--text);
  padding: 12px 20px; border-radius: 10px; box-shadow: var(--shadow); z-index: 100;
  font-size: 14px; max-width: 90%;
}
.toast.err { border-color: var(--red); color: var(--red); }
.toast.ok { border-color: var(--green); }

.spinner {
  display: inline-block; width: 13px; height: 13px; border: 2px solid var(--muted);
  border-top-color: transparent; border-radius: 50%; animation: spin 0.7s linear infinite;
  vertical-align: middle; margin-right: 6px;
}
.spinner-lg {
  width: 28px; height: 28px; border-width: 3px; margin-right: 0;
  border-color: var(--accent-soft); border-top-color: var(--accent);
}
@keyframes spin { to { transform: rotate(360deg); } }

.cards-loading {
  grid-column: 1 / -1;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 14px; padding: 80px 20px; color: var(--muted); font-size: 14px;
}

/* Login */
.login-view {
  min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px;
  position: relative;
}
.login-theme-toggle { position: absolute; top: 20px; right: 20px; }
.login-view[hidden] { display: none; }
.login-footer { position: absolute; bottom: 16px; left: 0; right: 0; border-top: none; }
.login-card {
  background: linear-gradient(180deg, var(--panel), var(--bg-2));
  border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 32px; width: 100%; max-width: 380px;
}
.login-brand { display: flex; align-items: center; gap: 10px; font-size: 20px; margin-bottom: 6px; }
.login-brand .logo {
  font-size: 24px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.login-card .muted { margin-bottom: 22px; font-size: 13px; }
.login-card .field input {
  width: 100%; background: var(--input-bg); border: 1px solid var(--input-border);
  color: var(--text); border-radius: 10px; padding: 11px 13px; font-size: 14px; font-family: inherit;
  transition: border-color 0.15s, background 0.15s;
}
.login-card .field input:focus { outline: none; border-color: var(--accent); background: var(--input-bg-focus); }
.login-card .btn.primary { margin-top: 6px; }

/* User menu */
.user-menu { display: flex; align-items: center; gap: 10px; }
.user-chip {
  display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted);
  background: var(--panel-2); border: 1px solid var(--border); border-radius: 20px; padding: 6px 12px;
}
.user-chip::before { content: "👤"; font-size: 12px; }

/* Card creator line */
.card .creator { color: var(--muted); font-size: 12px; }

/* API modal */
.api-modal { max-width: 620px; }
.api-body { padding: 22px; }
.api-endpoint {
  display: flex; align-items: center; gap: 10px; background: var(--bg-2); border: 1px solid var(--border);
  border-radius: 10px; padding: 10px 14px; font-family: 'JetBrains Mono', monospace; font-size: 13px;
  margin: 14px 0; overflow-x: auto; white-space: nowrap;
}
.api-method {
  background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: white;
  font-weight: 700; font-size: 11px; padding: 3px 9px; border-radius: 6px; letter-spacing: 0.03em;
}
.api-curl-wrap { position: relative; }
.api-curl {
  background: var(--term-bg); border: 1px solid var(--border); border-radius: 10px;
  padding: 16px; font-family: 'JetBrains Mono', monospace; font-size: 12.5px; line-height: 1.6;
  color: var(--term-text); white-space: pre-wrap; word-break: break-word; margin: 0; max-height: 220px; overflow-y: auto;
}
.api-curl-wrap .btn { margin-top: 12px; width: 100%; }

/* ---------- Page loader (3D intro animation) ---------- */
.app-loader {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(1200px 600px at 80% -10%, var(--bg-tint-1), transparent 60%),
              radial-gradient(900px 500px at -10% 110%, var(--bg-tint-2), transparent 60%),
              var(--bg);
  opacity: 1;
  transition: opacity 0.6s ease, visibility 0.6s ease;
}
.app-loader.is-hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}
.loader-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}
.loader-content {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  padding: 24px;
  text-align: center;
  pointer-events: none;
  animation: loaderFadeUp 0.8s ease both;
}
.loader-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 26px;
  letter-spacing: 0.01em;
  color: var(--text);
  text-shadow: 0 2px 24px var(--bg-tint-1);
}
.loader-brand b { font-weight: 700; }
.loader-brand .logo {
  font-size: 32px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: loaderLogoPulse 2.4s ease-in-out infinite;
}
.loader-bar {
  width: 220px;
  height: 4px;
  border-radius: 99px;
  background: var(--input-bg);
  overflow: hidden;
}
.loader-bar-fill {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  box-shadow: 0 0 12px var(--accent-soft);
  transition: width 0.15s linear;
}
.loader-caption {
  margin: 0;
  color: var(--muted);
  font-size: 13.5px;
  letter-spacing: 0.02em;
}
@keyframes loaderFadeUp {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes loaderLogoPulse {
  0%, 100% { transform: scale(1); filter: drop-shadow(0 0 0 transparent); }
  50% { transform: scale(1.12); filter: drop-shadow(0 0 10px var(--accent-soft)); }
}
@media (prefers-reduced-motion: reduce) {
  .loader-brand .logo { animation: none; }
}
