/* =============================================================================
   POLICY & PROCEDURE COPILOT — STYLES
   Visual language inherited from sixthwave-cockpit (Fraunces · DM Sans · Mono).
   ============================================================================ */

:root {
  --bg:       #0a0d15;
  --bg2:      #0c1019;
  --panel:    #10141f;
  --panel2:   #141a28;
  --line:     #1e2638;
  --line2:    #2a3550;
  --text:     #e8edf6;
  --dim:      #8a97b0;
  --faint:    #5c6883;
  --teal:     #2dd4bf;
  --gold:     #e0b94d;
  --rose:     #fb7185;

  --mono:    'JetBrains Mono', ui-monospace, monospace;
  --display: 'Fraunces', Georgia, serif;
  --body:    'DM Sans', system-ui, sans-serif;
}

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

html, body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--body);
  letter-spacing: -0.01em;
  min-height: 100vh;
}

button { font-family: inherit; color: inherit; cursor: pointer; background: none; border: none; }

::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: var(--line2); border-radius: 9px; }
::-webkit-scrollbar-track { background: transparent; }

@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes spin { to { transform: rotate(360deg); } }

/* ────────────────────────────────────────────────────────── TOPBAR */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 32px;
  border-bottom: 1px solid var(--line);
  background: var(--bg2);
  position: sticky; top: 0; z-index: 20;
}
.brand { display: flex; align-items: center; gap: 14px; }
.brand-mark {
  width: 46px; height: 46px; border-radius: 11px; flex-shrink: 0;
  background: linear-gradient(135deg, var(--teal), #0e7a6e);
  display: grid; place-items: center;
  box-shadow: 0 4px 18px rgba(45, 212, 191, 0.32);
}
.brand-mark span { font-family: var(--mono); font-weight: 600; font-size: 14px; color: #04201c; letter-spacing: -0.02em; }
.brand-name { font-family: var(--display); font-size: 19px; font-weight: 600; line-height: 1.1; }
.brand-tag  { font-family: var(--mono); font-size: 9.5px; letter-spacing: 0.22em; color: var(--gold); margin-top: 5px; }

.link-back {
  color: var(--dim); text-decoration: none;
  font-family: var(--mono); font-size: 11px; letter-spacing: 0.12em;
  padding: 8px 14px; border-radius: 7px; border: 1px solid var(--line2);
  transition: all 0.15s;
}
.link-back:hover { color: var(--teal); border-color: var(--teal); }

/* ────────────────────────────────────────────────────────── MAIN */
main {
  max-width: 980px;
  margin: 0 auto;
  padding: 36px 32px 64px;
  animation: rise 0.4s ease both;
}

.label {
  display: block;
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--faint);
  margin-bottom: 12px;
}

/* ────────────────────────────────────────────────────────── HERO */
.hero { margin-bottom: 32px; }

h1 {
  font-family: var(--display);
  font-size: 38px;
  font-weight: 600;
  line-height: 1.05;
  letter-spacing: -0.02em;
  margin-bottom: 14px;
}

.lede {
  color: var(--dim);
  font-size: 15.5px;
  max-width: 720px;
  line-height: 1.6;
  margin-bottom: 24px;
}

.examples {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
  margin-bottom: 12px;
}
.ex-label {
  font-family: var(--mono);
  font-size: 10px; letter-spacing: 0.14em;
  text-transform: uppercase; color: var(--faint);
  margin-right: 4px;
}
.ex-btn {
  padding: 8px 13px; border-radius: 8px;
  background: var(--panel); border: 1px solid var(--line);
  font-size: 12.5px; color: var(--dim);
  transition: all 0.12s;
}
.ex-btn:hover { color: var(--text); border-color: var(--teal); background: var(--panel2); }

/* ────────────────────────────────────────────────────────── ASK FORM */
.ask-row { margin-bottom: 30px; }
#ask-form {
  display: flex; gap: 10px; align-items: stretch;
  background: var(--panel);
  border: 1px solid var(--line2);
  border-radius: 12px;
  padding: 7px;
  transition: border-color 0.15s;
}
#ask-form:focus-within { border-color: var(--teal); }

#question {
  flex: 1; min-width: 0;
  background: transparent;
  border: none; outline: none;
  font-family: var(--body);
  font-size: 16px;
  color: var(--text);
  padding: 12px 14px;
}
#question::placeholder { color: var(--faint); }

#ask-btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 12px 22px;
  border-radius: 8px;
  background: var(--teal);
  color: #04201c;
  font-weight: 600;
  font-family: var(--body);
  font-size: 14px;
  letter-spacing: 0.02em;
  transition: background 0.12s, transform 0.08s;
}
#ask-btn:hover { background: #5ee5d3; }
#ask-btn:active { transform: scale(0.97); }
#ask-btn[disabled] { opacity: 0.55; cursor: not-allowed; }

.btn-spin {
  width: 12px; height: 12px;
  border: 2px solid rgba(4, 32, 28, 0.3);
  border-top-color: #04201c;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* ────────────────────────────────────────────────────────── ANSWER */
.answer-block {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 22px 24px;
  margin-bottom: 22px;
  position: relative;
  overflow: hidden;
}
.answer-block::before {
  content: ''; position: absolute; top: 0; left: 0; width: 100%; height: 2px;
  background: linear-gradient(90deg, var(--teal), transparent);
}

.answer-head {
  display: flex; align-items: baseline; justify-content: space-between; gap: 18px;
  flex-wrap: wrap; margin-bottom: 14px;
}
.answer-head .label { margin: 0; }
.grounded {
  font-family: var(--mono); font-size: 10px; color: var(--teal);
  letter-spacing: 0.14em; text-transform: uppercase;
}

.answer-text {
  font-size: 15.5px;
  line-height: 1.65;
  color: var(--text);
  white-space: pre-wrap;
}
.answer-text .cite {
  display: inline-block;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--teal);
  background: rgba(45, 212, 191, 0.12);
  border: 1px solid rgba(45, 212, 191, 0.32);
  padding: 0 6px;
  border-radius: 5px;
  margin: 0 2px;
  cursor: pointer;
  vertical-align: 1px;
  transition: background 0.1s;
}
.answer-text .cite:hover { background: rgba(45, 212, 191, 0.25); }

/* ────────────────────────────────────────────────────────── CITATIONS */
.citations-block { margin-bottom: 32px; }
.citation-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 11px;
}
.citation-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 15px 16px;
  position: relative;
  transition: border-color 0.12s;
}
.citation-card.hl { border-color: var(--teal); box-shadow: 0 0 0 1px var(--teal) inset; }

.citation-card .num {
  position: absolute; top: -10px; left: 14px;
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--teal); color: #04201c;
  display: grid; place-items: center;
  font-family: var(--mono); font-size: 11px; font-weight: 700;
}
.citation-card .doc {
  font-family: var(--display); font-size: 14px; font-weight: 600;
  margin: 4px 0 4px;
}
.citation-card .meta {
  font-family: var(--mono); font-size: 9.5px; letter-spacing: 0.06em;
  color: var(--faint); margin-bottom: 10px;
}
.citation-card .section {
  font-size: 12px; color: var(--gold);
  margin-bottom: 6px; font-weight: 500;
}
.citation-card .text {
  font-size: 12.8px; color: var(--dim); line-height: 1.55;
}

/* ────────────────────────────────────────────────────────── ERROR */
.error-block {
  background: rgba(251, 113, 133, 0.06);
  border: 1px solid rgba(251, 113, 133, 0.3);
  border-radius: 12px;
  padding: 16px 18px;
  margin-bottom: 22px;
}
.error-text {
  font-family: var(--mono);
  font-size: 12px;
  color: #fda4af;
  line-height: 1.55;
  white-space: pre-wrap;
}

/* ────────────────────────────────────────────────────────── CORPUS */
.corpus-block { margin-top: 40px; padding-top: 28px; border-top: 1px solid var(--line); }
.corpus-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
}
.corpus-item {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 12px 14px;
}
.corpus-item .t { font-family: var(--display); font-size: 13.5px; font-weight: 600; margin-bottom: 4px; }
.corpus-item .o { font-family: var(--mono); font-size: 9.5px; letter-spacing: 0.08em; color: var(--faint); }
.corpus-item .o .pipe { color: var(--line2); margin: 0 6px; }

/* ────────────────────────────────────────────────────────── FOOTER */
footer {
  border-top: 1px solid var(--line);
  padding: 18px 32px;
  font-family: var(--mono); font-size: 10.5px; color: var(--faint);
  display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px;
  max-width: 980px; margin: 0 auto;
}

/* ────────────────────────────────────────────────────────── 375px MOBILE */
@media (max-width: 700px) {
  .topbar { padding: 14px 16px; }
  .brand-mark { width: 38px; height: 38px; border-radius: 9px; }
  .brand-mark span { font-size: 12px; }
  .brand-name { font-size: 16px; }
  .brand-tag { font-size: 8.5px; }

  main { padding: 24px 16px 40px; }
  h1 { font-size: 24px; }
  .lede { font-size: 13.5px; }

  #ask-form { flex-direction: column; padding: 6px; }
  #question { padding: 12px 12px; font-size: 15px; }
  #ask-btn { padding: 11px 14px; width: 100%; justify-content: center; }

  .examples { gap: 6px; }
  .ex-btn { font-size: 11.5px; padding: 6px 10px; }
  .ex-label { width: 100%; margin-bottom: 4px; }

  .citation-grid, .corpus-grid { grid-template-columns: 1fr; }
  footer { padding: 14px 16px; font-size: 9.5px; }
}
