/*
 * citeproof app shell.
 *
 * Reuses the marketing site's token vocabulary (docs/site-redesign-plan.md) so
 * the product feels continuous with the landing page. The semantic status colours
 * are the load-bearing part: --ok / --warn / --stale carry product meaning
 * (cited / gap / invalidated) and must stay visually distinct from one another,
 * especially --warn and --stale, which are both "needs attention" but mean very
 * different things.
 */

:root {
  --accent-1: #2f5fe0;
  --accent-2: #8b5cf6;

  --ok: #16a34a;
  --ok-bg: #dcfce7;
  --warn: #d97706;
  --warn-bg: #fef3c7;
  --stale: #e11d48;
  --stale-bg: #ffe4e6;

  --bg: #ffffff;
  --bg-alt: #f6f7f9;
  --surface: #ffffff;
  --text: #0f172a;
  --text-muted: #64748b;
  --border: #e2e8f0;

  --radius: 10px;
  --radius-lg: 16px;
  --radius-pill: 999px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
  --shadow: 0 4px 16px rgba(15, 23, 42, 0.08);

  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --accent-1: #6ea8fe;
    --accent-2: #b18cfe;
    --ok: #4ade80;
    --ok-bg: #052e16;
    --warn: #fbbf24;
    --warn-bg: #3d2a04;
    --stale: #fb7185;
    --stale-bg: #4c0519;
    --bg: #08090b;
    --bg-alt: #101216;
    --surface: #14171c;
    --text: #e8eaed;
    --text-muted: #98a1ae;
    --border: #262b33;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

.wrap { max-width: 1080px; margin: 0 auto; padding: 0 20px; }

/* ---------- nav ---------- */
.nav {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.nav-inner { display: flex; align-items: center; gap: 16px; height: 60px; }
.logo { font-weight: 700; letter-spacing: -0.02em; text-decoration: none; color: var(--text); }
.logo-dot { background: linear-gradient(90deg, var(--accent-1), var(--accent-2)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.nav-spacer { flex: 1; }
.who { color: var(--text-muted); font-size: 0.85rem; }

/* ---------- layout ---------- */
main { padding: 28px 0 80px; }
h1 { font-size: clamp(1.5rem, 3vw, 2rem); letter-spacing: -0.02em; margin: 0 0 6px; }
h2 { font-size: 1.05rem; margin: 0 0 12px; letter-spacing: -0.01em; }
.sub { color: var(--text-muted); margin: 0 0 24px; }

.grid { display: grid; gap: 16px; grid-template-columns: 1fr 1fr; }
@media (max-width: 860px) { .grid { grid-template-columns: 1fr; } }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px;
  box-shadow: var(--shadow-sm);
}

/* ---------- controls ---------- */
button {
  font: inherit; font-weight: 600; cursor: pointer;
  border-radius: var(--radius); border: 1px solid transparent;
  padding: 9px 15px; transition: opacity .15s, background .15s;
}
button:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: linear-gradient(90deg, var(--accent-1), var(--accent-2)); color: #fff; }
.btn-primary:hover:not(:disabled) { opacity: .9; }
.btn-ghost { background: transparent; border-color: var(--border); color: var(--text); }
.btn-ghost:hover:not(:disabled) { background: var(--bg-alt); }
.btn-sm { padding: 5px 10px; font-size: .82rem; }

input[type=text], input[type=file], textarea, select {
  font: inherit; width: 100%; padding: 9px 11px;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--bg); color: var(--text);
}
textarea { min-height: 130px; resize: vertical; font-size: .9rem; }
label { display: block; font-size: .82rem; font-weight: 600; color: var(--text-muted); margin: 12px 0 5px; }

/* ---------- status pills ---------- */
.pill {
  display: inline-flex; align-items: center; gap: 5px;
  border-radius: var(--radius-pill); padding: 2px 10px;
  font-size: .72rem; font-weight: 700; letter-spacing: .03em; text-transform: uppercase;
}
.pill-green { background: var(--ok-bg); color: var(--ok); }
.pill-yellow { background: var(--warn-bg); color: var(--warn); }
.pill-red { background: var(--stale-bg); color: var(--stale); }
.pill-stale { background: var(--stale-bg); color: var(--stale); }
.pill-muted { background: var(--bg-alt); color: var(--text-muted); }

/* ---------- answers ---------- */
.qa { border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; margin-bottom: 10px; background: var(--surface); }
.qa-stale { border-color: var(--stale); box-shadow: 0 0 0 1px var(--stale) inset; }
.qa-head { display: flex; align-items: flex-start; gap: 10px; }
.qa-q { font-weight: 600; flex: 1; }
.qa-a { margin: 10px 0 0; color: var(--text); }
.qa-meta { margin-top: 8px; font-size: .8rem; color: var(--text-muted); }

.stale-banner {
  margin-top: 10px; padding: 9px 12px;
  background: var(--stale-bg); color: var(--stale);
  border-radius: var(--radius); font-size: .85rem; font-weight: 600;
}

details.cites { margin-top: 10px; }
details.cites summary { cursor: pointer; font-size: .82rem; color: var(--accent-1); font-weight: 600; }
.cite {
  margin-top: 8px; padding: 10px 12px;
  background: var(--bg-alt); border-left: 3px solid var(--ok);
  border-radius: 0 var(--radius) var(--radius) 0; font-size: .85rem;
}
.cite-src { font-size: .74rem; color: var(--text-muted); margin-bottom: 4px; font-family: ui-monospace, monospace; }

/* ---------- misc ---------- */
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.list-item { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--border); font-size: .9rem; }
.list-item:last-child { border-bottom: 0; }
.muted { color: var(--text-muted); }
.grow { flex: 1; }
.hidden { display: none !important; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .8rem; }

.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 11px 16px; box-shadow: var(--shadow);
  z-index: 50; max-width: 90vw;
}
.toast-error { border-color: var(--stale); color: var(--stale); }

.empty { text-align: center; padding: 40px 20px; color: var(--text-muted); }

.spinner {
  width: 15px; height: 15px; border: 2px solid var(--border);
  border-top-color: var(--accent-1); border-radius: 50%;
  animation: spin .7s linear infinite; display: inline-block; vertical-align: -2px;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation: none; } * { transition: none !important; } }

.gate { max-width: 460px; margin: 80px auto; text-align: center; }
