/* Advisor page — CSP is default-src 'self', so styling lives here, never inline. */

:root {
  --bg: #030711;
  --card: #071324;
  --edge: #122a44;
  --text: #d2e4f2;
  --dim: #5c778f;
  --accent: #2fe3e0;
  --error: #ff4a55;
}

/* Design system: sharp corners, enforced not remembered. See documentation/theme.md */
* { border-radius: 0 !important; }

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.6 system-ui, sans-serif;
}

main {
  max-width: 720px;
  margin: 0 auto;
  padding: 2rem 1rem 4rem;
}

header h1 {
  margin: 0;
  font-size: 1.7rem;
  letter-spacing: 0.02em;
}

.tagline {
  margin: 0.2rem 0 1.5rem;
  color: var(--dim);
}

#ask-form textarea {
  width: 100%;
  resize: vertical;
  background: var(--card);
  color: var(--text);
  border: 2px solid var(--edge);
  border-radius: 8px;
  padding: 0.7rem 0.9rem;
  font: inherit;
}

.ask-row {
  display: flex;
  gap: 0.6rem;
  margin-top: 0.6rem;
}

#passphrase {
  flex: 1;
  background: var(--card);
  color: var(--text);
  border: 2px solid var(--edge);
  border-radius: 8px;
  padding: 0.5rem 0.9rem;
  font: inherit;
}

#ask-button {
  background: var(--accent);
  color: var(--bg);
  border: none;
  border-radius: 8px;
  padding: 0.5rem 1.4rem;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

#ask-button:disabled {
  opacity: 0.5;
  cursor: wait;
}

#status {
  min-height: 1.4rem;
  margin: 0.5rem 0 0;
  color: var(--dim);
}

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

.card {
  background: var(--card);
  border: 2px solid var(--edge);
  border-radius: 10px;
  padding: 1rem 1.2rem;
  margin-top: 1.2rem;
}

.card h2 {
  margin: 0;
  font-size: 1.05rem;
}

.card time {
  display: block;
  color: var(--dim);
  font-size: 0.8rem;
  margin: 0.15rem 0 0.6rem;
}

/* The tile row now lives *under* the answer and only holds pages that were
   searched but never cited — cited pages appear inline, next to their claim. */
.links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-bottom: 0.6rem;
}

.links-note {
  margin: 1rem 0 0.5rem;
  color: var(--dim);
  font-size: 0.8rem;
}

.link-tile {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  max-width: 100%;
  background: var(--bg);
  border: 2px solid var(--edge);
  border-radius: 8px;
  padding: 0.35rem 0.7rem;
  color: var(--accent);
  text-decoration: none;
  font-size: 0.85rem;
}

.link-tile:hover { border-color: var(--accent); }

.link-tile img {
  width: 48px;
  height: 32px;
  object-fit: cover;
  border-radius: 4px;
  flex-shrink: 0;
}

.link-tile span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 16rem;
}

.answer p { margin: 0.5rem 0 0; }

.working {
  margin: 0.4rem 0 0;
  color: var(--accent);
  font-size: 0.9rem;
}

/* Pulse rather than spin: cheap, and it keeps working with reduced motion off. */
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.45; } }
.working { animation: pulse 1.8s ease-in-out infinite; }

@media (prefers-reduced-motion: reduce) {
  .working { animation: none; }
}

.failed {
  margin: 0.4rem 0 0;
  color: var(--error);
  font-size: 0.9rem;
}

/* --- provenance: how much of an answer traces back to a cited page --- */

.provenance {
  margin: 0.9rem 0 0.2rem;
  padding: 0.6rem 0.75rem;
  border: 2px solid var(--edge);
  border-left: 3px solid var(--band);
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.18);
}

/* Mostly sourced → calm; mostly the model's own words → look twice. The band
   is set on the CARD, not on the box, because the answer's unsourced runs are
   tinted with the same colour — bar and prose must move together. */
.card.low { --band: #4ee88a; }
.card.mid { --band: #ff8f1f; }
.card.high { --band: var(--error); }

.prov-bar {
  height: 5px;
  border-radius: 3px;
  background: var(--band);
  overflow: hidden;
}

/* The filled portion is the *sourced* share, so a long bar reads as good. */
.prov-sourced {
  display: block;
  height: 100%;
  background: var(--accent);
}

.prov-label {
  margin: 0.45rem 0 0;
  color: var(--dim);
  font-size: 0.82rem;
  line-height: 1.45;
}

/* Runs Claude wrote itself, tinted with the card's band colour — the same
   colour as the bar above them, so "how much of this is unsourced" and "which
   words those are" are one visual idea instead of two. No italics: the colour
   carries it, and italicising a third of an answer just makes it hard to read.
   The fallback keeps old rows (no band on the card) legible. */
.answer .uncited {
  color: var(--band, var(--dim));
}

/* Direct quotes — the source's own words, not a paraphrase. */
.answer .quote {
  font-weight: 600;
}

/* --- inline sources: the page a sentence came from, right after it --- */

/* Sits in the text flow, so it must not stretch the line. white-space: nowrap
   keeps a chip from breaking across lines mid-hostname; the group itself still
   wraps between chips. */
.cites {
  display: inline;
  margin-left: 0.3rem;
}

.cite {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  vertical-align: baseline;
  margin: 0 0.15rem;
  padding: 0.05rem 0.4rem;
  border: 2px solid var(--edge);
  border-radius: 999px;
  background: var(--bg);
  color: var(--accent);
  text-decoration: none;
  font-size: 0.72rem;
  line-height: 1.5;
  white-space: nowrap;
}

.cite:hover {
  border-color: var(--accent);
  text-decoration: underline;
}

/* Small enough to sit inside a line of prose without changing its height. */
.cite img {
  width: 26px;
  height: 16px;
  object-fit: cover;
  border-radius: 3px;
  flex-shrink: 0;
}

.cite span {
  max-width: 12rem;
  overflow: hidden;
  text-overflow: ellipsis;
}
