/* ============================================================
   Demo — RFI Answer Pack Builder
   BPS-04 responder console inside the Asite CDE chrome.
   A real, preparation agent turns an open RFI into an answer pack:
   the question restated, the drawings / specs / prior RFIs gathered
   (each openable), a grounded draft response and the open points to
   confirm. It prepares; issuing the answer is the human's step.
   References + the RFI preview open via the shared U.sampleDoc.
   Selectors prefixed `rap-`. Builds on main.css.
   ============================================================ */

.rap-app {
  position: relative;
  min-height: 520px;
  --rap: #0891B2;
  --rap-d: #0E7490;
  --rap-l: #E0F3FA;
}

/* ---- CDE shell ---- */
.rap-cde {
  position: relative;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: #fff;
  box-shadow: var(--sh-1);
  overflow: hidden;
  font-size: 12.5px;
}

/* ---- dark top bar ---- */
.rap-top {
  display: flex; align-items: center; gap: 14px;
  height: 46px; padding: 0 14px; color: #fff;
  background: linear-gradient(90deg, #2a6db5, #15375f);
}
.rap-brand { display: flex; align-items: center; gap: 8px; font-weight: 800; }
.rap-logo {
  width: 26px; height: 26px; border-radius: 6px; background: #fff;
  display: flex; align-items: center; justify-content: center;
}
.rap-brandtx { letter-spacing: .04em; font-size: 14px; }
.rap-topsearch {
  display: flex; align-items: center; gap: 8px;
  width: 220px; height: 28px; padding: 0 11px; border-radius: 6px;
  background: rgba(255,255,255,.92); color: var(--text-3); font-size: 12.5px;
}
.rap-proj { display: flex; align-items: center; gap: 6px; opacity: .96; }
.rap-proj strong { font-weight: 700; }
.rap-tools { margin-left: auto; display: flex; align-items: center; gap: 11px; }
.rap-ic { opacity: .9; display: inline-flex; }
.rap-ava {
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  width: 24px; height: 24px; border-radius: 50%; font-size: 9.5px; font-weight: 800;
  color: #fff; background: var(--rap-d);
}

/* ---- nav tabs ---- */
.rap-tabs {
  display: flex; align-items: center; gap: 2px; padding: 0 12px;
  border-bottom: 1px solid var(--line); background: #fff; overflow-x: auto;
}
.rap-tab {
  padding: 11px 12px; font-size: 12.5px; font-weight: 600; white-space: nowrap;
  color: var(--text-2); border-bottom: 2px solid transparent;
}
.rap-tab.active { color: var(--rap-d); border-bottom-color: var(--rap); font-weight: 700; }

/* ---- body ---- */
.rap-body { padding: 16px; background: #fafbfc; }

/* ---- head ---- */
.rap-head { display: flex; align-items: center; gap: 14px; margin-bottom: 16px; }
.rap-head-id { display: flex; align-items: center; gap: 11px; }
.rap-head-orb {
  width: 38px; height: 38px; flex: none; display: flex; align-items: center; justify-content: center;
  border-radius: 10px; color: #fff; background: linear-gradient(120deg, var(--rap), var(--rap-d));
  box-shadow: 0 6px 14px -6px rgba(0,0,0,.32);
}
.rap-head-name { font-size: 16px; font-weight: 800; color: var(--text); letter-spacing: -.01em; }
.rap-head-sub { font-size: 12px; color: var(--text-3); font-weight: 600; }
.rap-head .rap-btn { margin-left: auto; }

/* ---- buttons ---- */
.rap-btn {
  --rap: #0891B2; --rap-d: #0E7490; --rap-l: #E0F3FA;
  display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 14px;
  border-radius: 7px; font-size: 12.5px; font-weight: 600; cursor: pointer; border: 1px solid transparent;
  transition: filter .14s ease, background .14s ease, transform .12s ease;
}
.rap-btn.ghost { background: #fff; border-color: var(--line-strong); color: var(--text-2); }
.rap-btn.ghost:hover { border-color: var(--rap); color: var(--rap-d); }
.rap-btn.primary {
  background: linear-gradient(120deg, var(--rap), var(--rap-d)); color: #fff;
  box-shadow: 0 6px 14px -6px rgba(0,0,0,.32);
}
.rap-btn.primary:hover { filter: brightness(1.07); }
.rap-btn.primary:active { transform: translateY(1px); }
.rap-btn:disabled { opacity: .5; cursor: default; filter: none; box-shadow: none; }

/* ---- idle state ---- */
.rap-idle {
  border: 1px solid var(--line); border-radius: var(--r-sm); background: #fff; box-shadow: var(--sh-1);
  padding: 34px 28px 30px; text-align: center;
}
.rap-idle-t { font-size: 18px; font-weight: 800; color: var(--text); margin: 0 0 8px; letter-spacing: -.01em; }
.rap-idle-p { font-size: 13px; line-height: 1.6; color: var(--text-2); margin: 0 auto 22px; max-width: 62ch; }

/* RFI picker */
.rap-picks {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px;
  margin: 0 auto 22px; max-width: 720px; text-align: left;
}
.rap-pick {
  display: flex; flex-direction: column; gap: 7px; padding: 13px 14px; cursor: pointer;
  border: 1px solid var(--line-strong); border-radius: 11px; background: #fff;
  transition: border-color .14s ease, box-shadow .14s ease, transform .12s ease;
}
.rap-pick:hover { border-color: var(--rap); transform: translateY(-1px); box-shadow: var(--sh-1); }
.rap-pick.selected { border-color: var(--rap); box-shadow: 0 0 0 2px var(--rap-l); background: #fbfeff; }
.rap-pick-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.rap-pick-id { font-size: 12.5px; font-weight: 800; letter-spacing: .03em; font-variant-numeric: tabular-nums; color: var(--rap-d); }
.rap-pick-title { font-size: 13px; font-weight: 700; color: var(--text); line-height: 1.35; }
.rap-pick-meta { display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--text-3); font-weight: 600; flex-wrap: wrap; }
.rap-pick-meta .ico { opacity: .8; }

.rap-gen {
  display: inline-flex; align-items: center; gap: 8px; height: 40px; padding: 0 18px; border: none;
  border-radius: 9px; background: linear-gradient(120deg, var(--rap), var(--rap-d)); color: #fff;
  font-size: 13.5px; font-weight: 700; cursor: pointer;
  box-shadow: 0 8px 18px -10px rgba(0,0,0,.45); transition: filter .14s ease, transform .12s ease;
}
.rap-gen:hover { filter: brightness(1.07); }
.rap-gen:active { transform: translateY(1px); }
.rap-idle-hint {
  display: flex; align-items: flex-start; justify-content: center; gap: 7px; margin: 14px auto 0;
  font-size: 11.5px; line-height: 1.5; color: var(--text-3); max-width: 58ch;
}
.rap-idle-hint .ico { color: var(--rap); flex: none; margin-top: 1px; }

/* ---- loading ---- */
.rap-loading {
  border: 1px solid var(--line); border-radius: var(--r-sm); background: #fff; box-shadow: var(--sh-1);
  padding: 22px 20px;
}
.rap-loading-t { font-size: 13px; font-weight: 700; color: var(--text); margin-bottom: 16px; }
.rap-cklist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 13px; }
.rap-ck { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--text-3); }
.rap-ck.active { color: var(--text); font-weight: 600; }
.rap-ck.done { color: var(--text-2); }
.rap-ck-mark { display: inline-flex; }
.rap-ck-mark.ok { color: var(--ok); }
.rap-dot { width: 13px; height: 13px; border-radius: 50%; border: 2px solid var(--line-strong); display: inline-block; }
.rap-spin {
  width: 15px; height: 15px; border-radius: 50%;
  border: 2px solid rgba(0,0,0,.14); border-top-color: var(--rap);
  display: inline-block; animation: rap-spin .65s linear infinite;
}
.rap-spin.sm { width: 13px; height: 13px; }
@keyframes rap-spin { to { transform: rotate(360deg); } }

/* ---- report ---- */
.rap-report { display: flex; flex-direction: column; gap: 14px; animation: rap-fade .4s ease; }
@keyframes rap-fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---- RAG chip ---- */
.rap-chip {
  font-size: 10.5px; font-weight: 800; letter-spacing: .03em; text-transform: uppercase;
  padding: 3px 9px; border-radius: 999px; white-space: nowrap;
}
.rap-chip-warn { background: var(--warn-bg); color: var(--warn); }
.rap-chip-ok { background: var(--ok-bg); color: var(--ok); }

/* ---- question card ---- */
.rap-question {
  border: 1px solid var(--line); border-left: 4px solid var(--rap); border-radius: var(--r-sm);
  background: #fff; box-shadow: var(--sh-1); padding: 16px 18px;
}
.rap-question-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.rap-question-rfi { font-size: 13px; font-weight: 800; color: var(--text-2); letter-spacing: .01em; }
.rap-question-summary { margin: 10px 0 12px; font-size: 14px; line-height: 1.55; font-weight: 600; color: var(--text); }
.rap-question-meta { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.rap-meta-pill {
  display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 700;
  color: var(--rap-d); background: var(--rap-l); padding: 4px 10px; border-radius: 999px;
}
.rap-meta-pill .ico { opacity: .85; }

/* ---- generic section ---- */
.rap-sec { border: 1px solid var(--line); border-radius: var(--r-sm); background: #fff; box-shadow: var(--sh-1); overflow: hidden; }
.rap-sec-head { display: flex; align-items: center; gap: 9px; padding: 11px 14px; border-bottom: 1px solid var(--line); background: var(--bg-sunken); }
.rap-sec-ic { display: inline-flex; width: 26px; height: 26px; align-items: center; justify-content: center; border-radius: 7px; color: var(--rap-d); background: var(--rap-l); }
.rap-sec-ic-draft { color: var(--rap-d); background: var(--rap-l); }
.rap-sec-ic-open { color: var(--warn); background: var(--warn-bg); }
.rap-sec-title { margin: 0; font-size: 13.5px; font-weight: 700; color: var(--text); }
.rap-sec-count { font-size: 11px; font-weight: 700; color: var(--text-3); padding: 1px 8px; border-radius: 999px; background: #eef2f7; }
.rap-sec-note { margin-left: auto; display: inline-flex; align-items: center; gap: 5px; font-size: 11px; font-weight: 600; color: var(--text-3); }
.rap-sec-note .ico { opacity: .8; }

/* ---- references ---- */
.rap-reflist { list-style: none; margin: 0; padding: 0; }
.rap-ref { display: flex; gap: 11px; align-items: flex-start; padding: 12px 14px; border-bottom: 1px solid var(--line-soft); }
.rap-ref:last-child { border-bottom: none; }
.rap-ref-link {
  cursor: pointer; width: 100%; text-align: left; font: inherit; color: inherit;
  transition: background .12s ease;
}
.rap-ref-link:hover { background: var(--rap-l); }
.rap-ref-ic {
  flex: none; width: 30px; height: 30px; border-radius: 8px; margin-top: 1px;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--rap-d); background: var(--rap-l);
}
.rap-ref-main { flex: 1; min-width: 0; }
.rap-ref-top { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.rap-ref-type {
  font-size: 9.5px; font-weight: 800; letter-spacing: .05em; text-transform: uppercase;
  color: var(--rap-d); background: var(--rap-l); padding: 2px 7px; border-radius: 999px;
}
.rap-ref-id { font-size: 12.5px; font-weight: 800; letter-spacing: .02em; font-variant-numeric: tabular-nums; color: var(--text); }
.rap-ref-title { font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.rap-ref-rel { margin: 5px 0 0; font-size: 12px; line-height: 1.5; color: var(--text-2); }
.rap-ref-open { flex: none; color: var(--text-3); margin-top: 4px; }
.rap-ref-link:hover .rap-ref-open { color: var(--rap-d); }

/* ---- citation chip ---- */
.rap-cite {
  display: inline-flex; align-items: center; gap: 4px; font-size: 11px; font-weight: 700;
  color: var(--rap-d); background: var(--rap-l); padding: 3px 9px 3px 7px; border-radius: 6px;
}
.rap-cite .ico { opacity: .8; }
.rap-cite-link {
  border: 0; cursor: pointer; font-family: inherit; line-height: 1.4;
  transition: background .12s ease, color .12s ease;
}
.rap-cite-link:hover { background: var(--rap-d); color: #fff; }
.rap-cite-link:hover .ico { opacity: 1; }
.rap-cite-link:focus-visible { outline: 2px solid var(--rap); outline-offset: 2px; }

/* ---- draft response ---- */
.rap-draft-flag {
  margin-left: auto; display: inline-flex; align-items: center; gap: 5px;
  font-size: 10.5px; font-weight: 800; letter-spacing: .02em; text-transform: uppercase;
  color: var(--warn); background: var(--warn-bg); padding: 3px 10px; border-radius: 999px;
}
.rap-draft-flag .ico { opacity: .9; }
.rap-draft { padding: 14px 16px; }
.rap-draft-tx {
  margin: 0; font-size: 13.5px; line-height: 1.65; color: var(--text);
  padding: 13px 15px; border-radius: 9px; background: var(--bg-sunken);
  border: 1px dashed var(--line-strong);
}

/* ---- open points ---- */
.rap-oplist { list-style: none; margin: 0; padding: 6px 4px; }
.rap-op { display: flex; gap: 11px; padding: 9px 12px; align-items: flex-start; font-size: 13px; line-height: 1.5; color: var(--text); }
.rap-op-ic {
  flex: none; width: 20px; height: 20px; border-radius: 50%; margin-top: 1px;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--warn); background: var(--warn-bg);
}

/* ---- action bar ---- */
.rap-action {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  border: 1px solid var(--line); border-radius: var(--r-sm); background: #fff; box-shadow: var(--sh-1);
  padding: 13px 16px;
}
.rap-action-tx { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 220px; font-size: 12px; font-weight: 600; color: var(--text-2); }
.rap-action-ic { display: inline-flex; color: var(--rap-d); flex: none; }
.rap-action-actions { display: flex; align-items: center; gap: 9px; margin-left: auto; }

/* ---- responsive ---- */
@media (max-width: 720px) {
  .rap-topsearch { display: none; }
  .rap-picks { grid-template-columns: 1fr; }
  .rap-action-actions { margin-left: 0; flex-wrap: wrap; }
}
