/* ============================================================
   Uropapers — sistema de diseño "clínico premium"
   Claro por defecto · modo oscuro con toggle
   ============================================================ */

/* ---------- Tokens ---------- */
:root {
  /* superficies */
  --bg: #eef2f7;
  --bg-tint: #e7edf5;
  --surface: #ffffff;
  --surface-sunken: #f2f5f9;
  --border: #e3e9f1;
  --border-strong: #d3dbe6;

  /* texto */
  --text: #101c2e;
  --text-2: #55647a;
  --text-3: #8593a5;

  /* marca (teal clínico) */
  --accent: #0f766e;
  --accent-hover: #0c5f58;
  --accent-text: #0f766e;
  --accent-soft: #e7f4f2;
  --accent-border: #c2e4de;
  --on-accent: #ffffff;

  /* aviso / grounding */
  --warn: #b45309;
  --warn-soft: #fbf1e3;
  --warn-border: #efd8b4;

  /* efectos */
  --ring: rgba(15, 118, 110, 0.16);
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.05);
  --shadow-md: 0 6px 16px -6px rgba(16, 24, 40, 0.12), 0 2px 6px -2px rgba(16, 24, 40, 0.06);
  --shadow-lg: 0 24px 48px -16px rgba(16, 24, 40, 0.22);

  --radius-lg: 18px;
  --radius: 13px;
  --radius-sm: 9px;
  --maxw: 940px;
  --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

:root[data-theme="dark"] {
  --bg: #090e18;
  --bg-tint: #0c1220;
  --surface: #121a29;
  --surface-sunken: #0d1420;
  --border: #212d42;
  --border-strong: #2d3b54;

  --text: #e9eef6;
  --text-2: #9dadc1;
  --text-3: #66768d;

  --accent: #0d9488;
  --accent-hover: #14b8a6;
  --accent-text: #2dd4bf;
  --accent-soft: rgba(45, 212, 191, 0.12);
  --accent-border: rgba(45, 212, 191, 0.26);
  --on-accent: #ffffff;

  --warn: #f0b45f;
  --warn-soft: rgba(240, 180, 95, 0.12);
  --warn-border: rgba(240, 180, 95, 0.28);

  --ring: rgba(45, 212, 191, 0.22);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 8px 22px -8px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 28px 56px -18px rgba(0, 0, 0, 0.6);
}

/* ---------- Base ---------- */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
/* El atributo `hidden` debe mandar siempre (si no, display:flex/grid lo anula). */
[hidden] { display: none !important; }

body {
  background:
    radial-gradient(1100px 620px at 50% -8%, var(--bg-tint), transparent 60%),
    var(--bg);
  color: var(--text);
  font-family: var(--font);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  min-height: 100vh;
}

h1, h2, h3 { letter-spacing: -0.02em; }
a { color: var(--accent-text); }
::selection { background: var(--accent-soft); }

.brand-mark {
  color: var(--accent-text);
  font-size: 1.3em;
  line-height: 1;
}

/* ---------- Topbar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--surface) 82%, transparent);
  backdrop-filter: saturate(1.4) blur(12px);
}
.topbar-inner {
  max-width: var(--maxw); margin: 0 auto; padding: 11px 22px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
}
.topbar .mode-row { margin-bottom: 0; }
.logo { display: flex; align-items: center; gap: 11px; }
.logo .brand-mark {
  display: grid; place-items: center;
  width: 34px; height: 34px; border-radius: 10px;
  background: linear-gradient(155deg, var(--accent), color-mix(in srgb, var(--accent) 70%, #2dd4bf));
  color: #fff; font-size: 1.15rem;
  box-shadow: var(--shadow-sm), inset 0 1px 0 rgba(255,255,255,0.22);
}
.logo strong { display: block; font-size: 1.06rem; letter-spacing: -0.02em; }
.logo em {
  display: block; font-style: normal; font-size: 0.68rem; color: var(--text-3);
  text-transform: uppercase; letter-spacing: 0.12em; margin-top: 1px;
}
.topbar-right { display: flex; align-items: center; gap: 10px; }
.specialty-select {
  appearance: none;
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%238593a5' d='M6 8L2 4h8z'/%3E%3C/svg%3E") no-repeat right 11px center;
  color: var(--text); border: 1px solid var(--border-strong);
  border-radius: 10px; padding: 8px 30px 8px 13px; font-size: 0.88rem;
  font-family: inherit; cursor: pointer; transition: border-color 0.15s, box-shadow 0.15s;
}
.specialty-select:hover { border-color: var(--accent-border); }
.specialty-select:focus-visible { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--ring); }
.icon-btn {
  display: grid; place-items: center;
  background: var(--surface); color: var(--accent-text);
  border: 1px solid var(--border-strong); border-radius: 10px;
  width: 38px; height: 38px; cursor: pointer; font-size: 1rem;
  transition: border-color 0.15s, transform 0.1s, background 0.15s;
}
.icon-btn:hover { border-color: var(--accent-border); background: var(--accent-soft); }
.icon-btn:active { transform: scale(0.94); }

/* ---------- Shell + Sidebar ---------- */
.app-shell { display: flex; min-height: 100vh; }
.main-area {
  flex: 1; min-width: 0; height: 100vh; overflow: hidden;
  display: flex; flex-direction: column;
  background: var(--surface);   /* casi blanco, como OrthoConsult */
}

/* ---------- Chat ---------- */
.chat { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.transcript { flex: 1; min-height: 0; overflow-y: auto; }
.messages {
  max-width: 820px; margin: 0 auto; padding: 26px 22px 12px;
  display: flex; flex-direction: column; gap: 22px;
}
.user-msg { display: flex; justify-content: flex-end; }
.user-bubble {
  background: var(--surface-sunken); color: var(--text); border: 1px solid var(--border);
  padding: 10px 15px; border-radius: 14px; max-width: 80%;
  font-size: 0.96rem; line-height: 1.5; white-space: pre-wrap;
}
.answer { display: grid; gap: 16px; animation: rise 0.3s ease both; }
.loading-msg { display: flex; align-items: center; gap: 12px; color: var(--text-2); padding: 4px 2px; }
.loading-msg .spinner { width: 22px; height: 22px; margin: 0; border-width: 2.5px; }
.answer-foot { color: var(--text-3); font-size: 0.74rem; margin: 0; }

/* Cursor mientras el modelo escribe */
.stream-cursor {
  display: inline-block; width: 7px; height: 1.05em; margin-left: 1px;
  background: var(--accent-text); vertical-align: text-bottom; border-radius: 1px;
  animation: blink 1.1s steps(2, start) infinite;
}
@keyframes blink { to { visibility: hidden; } }
@media (prefers-reduced-motion: reduce) { .stream-cursor { animation: none; opacity: 0.55; } }

/* Marca de respuesta terminada */
.answer-done {
  display: flex; align-items: center; gap: 7px;
  color: var(--text-3); font-size: 0.78rem; padding-top: 2px;
}
.done-check {
  display: grid; place-items: center; width: 16px; height: 16px; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent-text); font-size: 0.62rem; font-weight: 700;
}
.answer-error {
  color: var(--warn); background: var(--warn-soft); border: 1px solid var(--warn-border);
  padding: 12px 14px; border-radius: var(--radius);
}
.answer li.flash, #references li.flash { animation: refflash 1.3s ease; border-radius: 6px; }
@keyframes refflash { 30% { background: var(--accent-soft); } }

.welcome { max-width: 760px; margin: 0 auto; padding: 30px 22px 10px; }
.welcome .examples { justify-content: center; }

/* Composer (input inferior) */
.composer { flex: none; background: var(--surface); padding: 14px 22px 12px; }
.composer-inner {
  max-width: 820px; margin: 0 auto; display: flex; align-items: flex-end; gap: 10px;
  background: var(--surface-sunken); border: 1px solid var(--border-strong);
  border-radius: 16px; padding: 7px 7px 7px 16px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.composer-inner:focus-within { border-color: var(--accent); box-shadow: 0 0 0 4px var(--ring); }
.composer textarea#question {
  flex: 1; border: none; background: transparent; resize: none; color: var(--text);
  font-family: inherit; font-size: 1rem; line-height: 1.5; padding: 8px 0; max-height: 160px;
}
.composer textarea#question:focus { outline: none; }
.composer textarea#question::placeholder { color: var(--text-3); }
.send-btn {
  flex: none; width: 38px; height: 38px; border-radius: 11px;
  background: var(--accent); color: var(--on-accent); border: none; cursor: pointer;
  display: grid; place-items: center; transition: background 0.15s, transform 0.08s;
}
.send-btn:hover:not(:disabled) { background: var(--accent-hover); }
.send-btn:active:not(:disabled) { transform: scale(0.94); }
.send-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.send-btn svg { width: 18px; height: 18px; }
.composer-note { max-width: 820px; margin: 8px auto 0; text-align: center; font-size: 0.72rem; color: var(--text-3); }

.sidebar {
  width: 272px; flex: none; position: sticky; top: 0; align-self: flex-start;
  height: 100vh; overflow-y: auto;
  background: var(--surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; padding: 18px 15px;
}
.sidebar-brand { display: flex; align-items: center; gap: 11px; padding: 4px 6px 18px; }
.sidebar-brand .brand-mark {
  display: grid; place-items: center;
  width: 34px; height: 34px; border-radius: 10px;
  background: linear-gradient(155deg, var(--accent), color-mix(in srgb, var(--accent) 70%, #2dd4bf));
  color: #fff; font-size: 1.15rem;
  box-shadow: var(--shadow-sm), inset 0 1px 0 rgba(255,255,255,0.22);
}
.sidebar-brand strong { display: block; font-size: 1.04rem; letter-spacing: -0.02em; }
.sidebar-brand em {
  display: block; font-style: normal; font-size: 0.66rem; color: var(--text-3);
  text-transform: uppercase; letter-spacing: 0.11em; margin-top: 1px;
}
.btn-new {
  display: flex; align-items: center; justify-content: center; gap: 7px;
  width: 100%; padding: 11px; margin-bottom: 22px;
  background: var(--accent); color: var(--on-accent); border: none;
  border-radius: var(--radius); font-size: 0.9rem; font-weight: 600;
  font-family: inherit; cursor: pointer;
  box-shadow: var(--shadow-sm), inset 0 1px 0 rgba(255,255,255,0.18);
  transition: background 0.15s;
}
.btn-new:hover { background: var(--accent-hover); }
.btn-new span { font-size: 1.15rem; line-height: 0; }

.history-section { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.history-section h4 {
  margin: 0 0 10px; padding: 0 6px; font-size: 0.7rem; text-transform: uppercase;
  letter-spacing: 0.09em; color: var(--text-3); font-weight: 650;
}
.history-list { display: flex; flex-direction: column; gap: 3px; overflow-y: auto; }
.history-empty { color: var(--text-3); font-size: 0.83rem; padding: 6px; line-height: 1.5; margin: 0; }
.history-item {
  display: flex; flex-direction: column; gap: 2px; text-align: left;
  background: transparent; border: none; border-radius: 9px; padding: 9px 10px;
  cursor: pointer; font-family: inherit; transition: background 0.12s;
}
.history-item:hover { background: var(--surface-sunken); }
.history-item.active { background: var(--accent-soft); }
.history-q {
  font-size: 0.85rem; color: var(--text); font-weight: 500; line-height: 1.35;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.history-item.active .history-q { color: var(--accent-text); }
.history-meta { font-size: 0.72rem; color: var(--text-3); display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.hist-tag {
  background: var(--accent-soft); color: var(--accent-text);
  border-radius: 5px; padding: 1px 6px; font-size: 0.68rem; font-weight: 550;
}
.sidebar-foot {
  padding: 14px 6px 4px; margin-top: 12px; font-size: 0.72rem;
  color: var(--text-3); border-top: 1px solid var(--border);
}

/* ---------- Layout ---------- */
.container { max-width: var(--maxw); margin: 0 auto; padding: 32px 22px 72px; width: 100%; }

/* ---------- Hero ---------- */
.hero { text-align: center; padding: 44px 0 32px; position: relative; }
.hero::before {
  content: ""; position: absolute; top: 0; left: 50%; transform: translateX(-50%);
  width: min(440px, 92%); height: 250px; z-index: 0; pointer-events: none;
  background: radial-gradient(58% 58% at 50% 38%, var(--accent-soft), transparent 72%);
  opacity: 0.9;
}
.hero > * { position: relative; z-index: 1; }
.hero-emblem {
  width: 74px; height: 74px; margin: 0 auto 22px; border-radius: 20px;
  display: grid; place-items: center;
  background: linear-gradient(155deg, var(--accent), color-mix(in srgb, var(--accent) 52%, #2dd4bf));
  color: #fff;
  box-shadow: var(--shadow-md), 0 0 0 7px var(--accent-soft), inset 0 1px 0 rgba(255,255,255,0.28);
}
.hero-emblem svg { width: 36px; height: 36px; }
.hero-eyebrow {
  display: inline-block; margin-bottom: 14px;
  font-size: 0.72rem; font-weight: 650; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--accent-text);
  background: var(--accent-soft); border: 1px solid var(--accent-border);
  padding: 5px 13px; border-radius: 999px;
}
.hero h1 {
  font-size: clamp(1.75rem, 4.2vw, 2.55rem); line-height: 1.15;
  margin: 0; font-weight: 700; letter-spacing: -0.025em;
}
.hero-accent {
  background: linear-gradient(115deg, var(--accent), color-mix(in srgb, var(--accent) 42%, #2dd4bf));
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent; color: transparent;
}

/* ---------- Ask card ---------- */
.ask-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 20px; box-shadow: var(--shadow-md);
}
.mode-row {
  display: inline-flex; gap: 3px; background: var(--surface-sunken);
  border: 1px solid var(--border); border-radius: 11px; padding: 4px; margin-bottom: 15px;
}
.mode-btn {
  background: transparent; color: var(--text-2); border: none;
  padding: 8px 16px; border-radius: 8px; cursor: pointer;
  font-size: 0.87rem; font-weight: 550; font-family: inherit;
  transition: background 0.18s, color 0.18s, box-shadow 0.18s;
}
.mode-btn:hover { color: var(--text); }
.mode-btn.active {
  background: var(--surface); color: var(--accent-text);
  box-shadow: var(--shadow-sm); font-weight: 600;
}
:root[data-theme="dark"] .mode-btn.active { background: var(--accent-soft); }

/* Icono de info por modo + tooltip */
.mode-opt { display: flex; align-items: center; gap: 3px; padding-right: 3px; }
.mode-info {
  position: relative;
  display: inline-grid; place-items: center; flex: none;
  width: 17px; height: 17px; border-radius: 50%; padding: 0; line-height: 1;
  background: transparent; border: 1px solid var(--border-strong);
  color: var(--text-3); font-size: 0.66rem; font-weight: 700;
  font-family: Georgia, "Times New Roman", serif; font-style: italic;
  cursor: help; transition: border-color 0.12s, color 0.12s;
}
.mode-info:hover, .mode-info:focus-visible {
  border-color: var(--accent); color: var(--accent-text); outline: none;
}
.mode-info::after {
  content: attr(data-tip);
  position: absolute; top: calc(100% + 11px); left: 50%;
  width: 248px; max-width: 72vw;
  background: var(--text); color: var(--surface);
  padding: 11px 13px; border-radius: 10px;
  font-size: 0.8rem; font-weight: 400; font-style: normal; line-height: 1.45;
  text-align: left; box-shadow: var(--shadow-lg); pointer-events: none; z-index: 40;
  opacity: 0; visibility: hidden;
  transform: translateX(-50%) translateY(-4px);
  transition: opacity 0.15s, transform 0.15s;
}
.mode-info::before {
  content: ""; position: absolute; top: calc(100% + 5px); left: 50%;
  margin-left: -6px; border: 6px solid transparent; border-bottom-color: var(--text);
  opacity: 0; visibility: hidden; transition: opacity 0.15s; pointer-events: none; z-index: 40;
}
.mode-info:hover::after, .mode-info.tip-open::after {
  opacity: 1; visibility: visible; transform: translateX(-50%) translateY(0);
}
.mode-info:hover::before, .mode-info.tip-open::before { opacity: 1; visibility: visible; }

textarea#question {
  width: 100%; resize: vertical; min-height: 82px;
  background: var(--surface-sunken); color: var(--text);
  border: 1px solid var(--border-strong); border-radius: var(--radius);
  padding: 14px 15px; font-size: 1.02rem; font-family: inherit; line-height: 1.5;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}
textarea#question::placeholder { color: var(--text-3); }
textarea#question:focus {
  outline: none; background: var(--surface);
  border-color: var(--accent); box-shadow: 0 0 0 4px var(--ring);
}
.ask-actions {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-top: 14px;
}
.hint { color: var(--text-3); font-size: 0.82rem; }
.btn-primary {
  background: var(--accent); color: var(--on-accent); border: none;
  border-radius: var(--radius); padding: 12px 24px; font-size: 0.95rem;
  font-weight: 600; font-family: inherit; cursor: pointer;
  box-shadow: var(--shadow-sm), inset 0 1px 0 rgba(255,255,255,0.18);
  transition: background 0.15s, transform 0.08s, box-shadow 0.15s;
}
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn-primary:active:not(:disabled) { transform: translateY(1px); }
.btn-primary:disabled { opacity: 0.55; cursor: not-allowed; }

.examples { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.example-chip {
  background: var(--surface-sunken); border: 1px solid var(--border);
  color: var(--text-2); border-radius: 999px; padding: 7px 14px;
  font-size: 0.82rem; font-family: inherit; cursor: pointer; text-align: left;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}
.example-chip:hover { border-color: var(--accent-border); color: var(--text); background: var(--accent-soft); }

/* ---------- Status / loading ---------- */
.status { text-align: center; padding: 48px 0; color: var(--text-2); font-size: 0.95rem; }
.spinner {
  width: 36px; height: 36px; margin: 0 auto 16px;
  border: 3px solid var(--border-strong); border-top-color: var(--accent);
  border-radius: 50%; animation: spin 0.75s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.status.error { color: var(--warn); }

/* ---------- Result ---------- */
.result { margin-top: 30px; display: grid; gap: 18px; animation: rise 0.35s ease both; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* Respuesta plana tipo documento (sin tarjetas), como OrthoConsult */
.answer-card, .refs-card {
  background: transparent; border: none; border-radius: 0; padding: 0; box-shadow: none;
}
.refs-card { border-top: 1px solid var(--border); padding-top: 18px; margin-top: 4px; }
.answer-title {
  margin: 0 0 14px; font-size: 1.12rem; font-weight: 700;
  letter-spacing: -0.015em; line-height: 1.35; color: var(--text);
}
.answer-head { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 0.71rem; font-weight: 650; letter-spacing: 0.04em;
  padding: 5px 11px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent-text);
  border: 1px solid var(--accent-border); text-transform: uppercase;
}
.badge.grounded { background: var(--surface-sunken); color: var(--text-2); border-color: var(--border-strong); }

.block { padding: 22px 0 0; }
.block:first-of-type { padding-top: 2px; }
.block h3 {
  margin: 0 0 10px; font-size: 1rem; font-weight: 700;
  letter-spacing: -0.01em; color: var(--text);
}
.overview { font-size: 1.05rem; line-height: 1.72; margin: 0; color: var(--text); }
.take-home {
  margin: 0; font-size: 1.02rem; line-height: 1.68; font-weight: 600; color: var(--text);
}
.block ul { margin: 0; padding: 0; list-style: none; display: grid; gap: 10px; }
.block li { position: relative; padding-left: 19px; line-height: 1.7; color: var(--text); }
.block li::before {
  content: ""; position: absolute; left: 2px; top: 0.78em;
  width: 5px; height: 5px; border-radius: 50%;
  background: var(--accent-text); opacity: 0.6;
}
.block.caveats p {
  margin: 0; font-size: 0.97rem; line-height: 1.7; color: var(--text-2);
}

/* Citas [n] */
.cite {
  color: var(--accent-text); font-weight: 650; text-decoration: none;
  font-size: 0.72em; vertical-align: super;
  padding: 1px 3px; border-radius: 5px; transition: background 0.12s;
}
.cite:hover { background: var(--accent-soft); }

/* ---------- Referencias ---------- */
.refs-card h3 { margin: 0 0 4px; font-size: 1rem; font-weight: 700; color: var(--text); display: flex; align-items: baseline; gap: 8px; }
.count { color: var(--text-3); font-weight: 400; font-size: 0.85rem; }
#references { margin: 16px 0 0; padding: 0; list-style: none; counter-reset: ref; display: grid; gap: 16px; }
#references li {
  position: relative; padding-left: 26px; counter-increment: ref; line-height: 1.5;
}
#references li::before {
  content: counter(ref) "."; position: absolute; left: 0; top: 0;
  color: var(--text-3); font-size: 0.92rem; font-weight: 600;
}
#references li.cited::before { color: var(--accent-text); }
.ref-title { color: var(--accent-text); text-decoration: none; font-weight: 550; line-height: 1.45; }
.ref-title:hover { text-decoration: underline; }
.ref-meta { color: var(--text-3); font-size: 0.83rem; margin-top: 3px; }
.ref-cited-tag {
  color: var(--accent-text); font-size: 0.66rem; font-weight: 700;
  letter-spacing: 0.05em; margin-left: 8px; vertical-align: middle;
  border: 1px solid var(--accent-border); border-radius: 999px; padding: 1px 7px;
}
.ref-evidence {
  display: inline-block; font-size: 0.66rem; font-weight: 650;
  letter-spacing: 0.02em; margin-left: 8px; vertical-align: middle;
  color: var(--text-3); background: var(--surface);
  border: 1px solid var(--border-strong); border-radius: 999px; padding: 1px 8px;
}
.ref-evidence.high {
  color: var(--accent-text); background: var(--accent-soft);
  border-color: var(--accent-border);
}

.disclaimer { color: var(--text-3); font-size: 0.82rem; text-align: center; padding: 6px 20px; margin: 8px 0 0; line-height: 1.5; }
.model-note { color: var(--text-3); font-size: 0.74rem; text-align: center; margin: 2px 0 0; opacity: 0.8; }

/* ---------- Footer ---------- */
.footer {
  max-width: var(--maxw); margin: 0 auto; padding: 26px 22px;
  display: flex; justify-content: space-between; gap: 12px;
  color: var(--text-3); font-size: 0.8rem; border-top: 1px solid var(--border);
}

/* ---------- Gate ---------- */
.gate {
  position: fixed; inset: 0; z-index: 100;
  background: color-mix(in srgb, var(--bg) 55%, rgba(6, 12, 22, 0.72));
  backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center; padding: 22px;
  animation: rise 0.25s ease both;
}
.gate-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 34px; max-width: 470px;
  text-align: center; box-shadow: var(--shadow-lg);
}
.gate-card .brand-mark {
  display: grid; place-items: center; margin: 0 auto 4px;
  width: 56px; height: 56px; border-radius: 16px;
  background: linear-gradient(155deg, var(--accent), color-mix(in srgb, var(--accent) 65%, #2dd4bf));
  color: #fff; font-size: 1.9rem; box-shadow: var(--shadow-md);
}
.gate-card h2 { margin: 16px 0 8px; font-size: 1.32rem; }
.gate-card p { color: var(--text-2); font-size: 0.96rem; margin: 0; }
.attest {
  display: flex; gap: 11px; text-align: left; font-size: 0.88rem;
  color: var(--text-2); margin: 20px 0; cursor: pointer;
  background: var(--surface-sunken); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 13px 15px;
}
.attest input { margin-top: 2px; width: 17px; height: 17px; accent-color: var(--accent); flex: none; cursor: pointer; }
.gate-card .btn-primary { width: 100%; padding: 13px; }
.key-input {
  width: 100%; margin-bottom: 14px; padding: 11px 13px;
  background: var(--surface-sunken); color: var(--text);
  border: 1px solid var(--border-strong); border-radius: var(--radius);
  font-family: inherit; font-size: 0.95rem;
}
.key-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--ring); }
.key-error { color: var(--warn); font-size: 0.85rem; margin: -8px 0 12px; text-align: left; }

/* ---------- Responsive ---------- */
@media (max-width: 860px) {
  .sidebar { display: none; }
}
@media (max-width: 620px) {
  .container { padding: 28px 16px 56px; }
  .answer-card, .refs-card { padding: 20px 18px; }
  .footer { flex-direction: column; gap: 4px; text-align: center; }
  .topbar-inner { padding: 12px 16px; }
}
