/* The analyst (/dashboards/nueva, /dashboards/a/{id}): the draft canvas and
 * the conversation beside it. Below 900 px the conversation goes under the
 * canvas, the composer stays at hand at the bottom. */

.dva-page { padding-bottom: 0; }
.dva {
  display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 18px; align-items: start;
  /* The visible height under the top bar, in the shell's zoomed px. */
  --dva-h: calc(100dvh / var(--zoom) - var(--topbar-h) - 36px);
}
.dva-stage { min-width: 0; position: relative; min-height: max(420px, var(--dva-h)); display: flex; flex-direction: column; }
.dva-empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; text-align: center;
  flex: 1; min-height: 420px; padding: 32px; border: 1px dashed var(--border); border-radius: 14px; color: var(--muted);
}
.dva-empty b { color: var(--text); font-size: 15px; }
.dva-empty p { margin: 0; max-width: 380px; font-size: 13px; line-height: 1.5; }
.dva-empty-icon { color: var(--primary); }

.dv-board .dv-block { cursor: pointer; transition: box-shadow 120ms ease-out, border-color 120ms ease-out; }
.dv-board .dv-block.is-picked { border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 22%, transparent); }
.dv-block.is-entering { animation: dva-enter 520ms var(--ease-out-cubic) both; }
@keyframes dva-enter {
  0% { opacity: 0; transform: translateY(10px) scale(.985); box-shadow: 0 0 0 0 color-mix(in srgb, var(--primary) 40%, transparent); }
  60% { opacity: 1; transform: none; box-shadow: 0 0 0 4px color-mix(in srgb, var(--primary) 18%, transparent); }
  100% { box-shadow: 0 0 0 0 transparent; }
}
@media (prefers-reduced-motion: reduce) { .dv-block.is-entering { animation: none; } }

.dva-chat {
  /* Sticky at the page's own top padding, so it sits where it started
     however far the canvas scrolls, and as tall as the rest of the screen. */
  position: sticky; top: 0; display: flex; flex-direction: column; gap: 10px;
  height: var(--dva-h); min-height: 460px; padding: 16px 16px 14px;
  background: var(--card); border: 1px solid var(--border); border-radius: 14px;
}
.dva-log { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; padding: 4px 2px; }
.dva-msg { max-width: 92%; padding: 9px 12px; border-radius: 12px; font-size: 13.5px; line-height: 1.5; overflow-wrap: anywhere; }
/* Only the text keeps its line breaks: the markup around it is indented. */
.dva-msg > .dva-text { white-space: pre-wrap; }
.dva-msg.is-me { align-self: flex-end; background: var(--text); color: var(--bg); border-bottom-right-radius: 4px; }
.dva-msg.is-ai { align-self: flex-start; padding: 12px 14px; background: var(--surface-light); color: var(--text); border-bottom-left-radius: 4px; }
.dva-msg.is-ai:empty { display: none; }

.dva-chips { display: flex; flex-direction: column; gap: 6px; }
.dva-chip { display: inline-flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text-2); animation: dv-in 200ms ease-out both; }
.dva-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--primary); animation: dva-pulse 1s ease-in-out infinite; flex: none; }
.dva-chip.is-done { color: var(--muted); }
.dva-chip.is-done .dva-dot { animation: none; background: var(--success); }
@keyframes dva-pulse { 50% { opacity: .3; transform: scale(.7); } }
@media (prefers-reduced-motion: reduce) { .dva-dot { animation: none; } }
.dva-error { margin: 0; padding: 8px 10px; border-radius: 8px; font-size: 12.5px; color: var(--error); background: color-mix(in srgb, var(--error) 8%, var(--card)); }

.dva-suggest { display: flex; flex-direction: column; gap: 6px; border-top: 1px solid var(--border); padding-top: 8px; }
.dva-suggest-list { display: flex; flex-direction: column; gap: 6px; max-height: 40vh; overflow-y: auto; }
/* The label folds the list down to one line (analyst.js, fold()). */
.dva-suggest-label {
  display: flex; align-items: center; gap: 6px; min-height: 28px; width: 100%; text-align: left;
  font-size: 11px; font-weight: 600; letter-spacing: .3px; text-transform: uppercase; color: var(--muted);
}
.dva-suggest-label small { font-weight: 500; text-transform: none; letter-spacing: 0; }
.dva-suggest-label .ic { margin-left: auto; transition: transform 160ms var(--ease-out-cubic); }
.dva-suggest.is-folded .dva-suggest-label .ic { transform: rotate(-90deg); }
.dva-suggest-label:hover { color: var(--text); }

/* The analyst's words, as markdown (analyst.js, md()). */
.dva-md { white-space: normal; }
.dva-md p { margin: 0 0 8px; }
.dva-md p:last-child, .dva-md ul:last-child, .dva-md ol:last-child { margin-bottom: 0; }
.dva-md ul, .dva-md ol { margin: 0 0 8px; padding-left: 18px; }
.dva-md li { margin: 2px 0; }
.dva-md b { font-weight: 700; }
.dva-md code { font: 12px ui-monospace, SFMono-Regular, Menlo, monospace; padding: 1px 4px; border-radius: 4px; background: var(--hover); }
.dva-md .dva-h { font-weight: 700; margin-top: 4px; }

/* A report the analyst wrote, on the stage (analyst.js, showReport()). */
/* (Not .dva-report: that is the report's card in the conversation.) */
.dva-paper {
  flex: 1; display: flex; flex-direction: column; text-align: left; overflow: hidden;
  border-radius: 16px; background: var(--surface); border: 1px solid var(--border);
  box-shadow: 0 1px 2px rgba(0, 0, 0, .04);
}
.dva-paper-bar {
  display: flex; align-items: center; gap: 12px; padding: 12px 20px 12px 24px;
  border-bottom: 1px solid var(--border); background: var(--card); font-size: 12.5px;
}
.dva-paper-tag { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; color: var(--primary); }
.dva-paper-bar a {
  margin-left: auto; display: inline-flex; align-items: center; gap: 6px; min-height: 32px; padding: 0 10px;
  border-radius: 8px; color: var(--text-2); font-weight: 600;
}
.dva-paper-bar a:hover { background: var(--hover); color: var(--text); }
.dva-paper-body { padding: 8px 36px 36px; }
.dva-paper-body .rp { max-width: 760px; gap: 32px; }
.dva-paper-body .rp-question { font-size: clamp(22px, 2.3vw, 27px); }
.dva-paper-body .rp-lede { padding: 20px 22px; }
.dva-paper-body .rp-lede-text { font-size: 16.5px; }
.dva-paper-body .rp-section.is-side, .dva-paper-body .rp-section.is-side.is-flip { grid-template-columns: minmax(0, 1fr); }
.dva-paper-body .rp-section.is-side.is-flip .rp-copy { order: 0; }
.dva-paper-body .rp-fig { position: static; }
@media (max-width: 720px) { .dva-paper-body { padding: 4px 16px 20px; } .dva-paper-bar { padding: 10px 12px 10px 16px; } }
.dva-sugg {
  text-align: left; padding: 8px 11px; min-height: 40px; border-radius: 10px; font-size: 12.5px; line-height: 1.4; color: var(--text);
  border: 1px solid color-mix(in srgb, var(--primary) 28%, var(--border)); background: color-mix(in srgb, var(--primary) 5%, var(--card));
}
.dva-sugg:hover:not(:disabled) { background: color-mix(in srgb, var(--primary) 11%, var(--card)); }
.dva-sugg:disabled { opacity: .5; }

.dva-composer { position: relative; display: flex; flex-direction: column; gap: 6px; }
.dva-composer textarea {
  width: 100%; resize: none; padding: 10px 48px 10px 12px; border-radius: 12px; font: inherit; font-size: 16px; line-height: 1.4;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
}
.dva-composer textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 18%, transparent); }
.dva-send {
  position: absolute; right: 8px; bottom: 8px; display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%;
  background: var(--primary); color: #fff;
}
.dva-send:disabled { opacity: .4; }
.dva-spin { width: 14px; height: 14px; border: 2px solid rgba(255, 255, 255, .45); border-top-color: #fff; border-radius: 50%; animation: dva-rot .8s linear infinite; }
@keyframes dva-rot { to { transform: rotate(360deg); } }
.dva-focus {
  display: flex; align-items: center; gap: 6px; padding: 5px 6px 5px 10px; border-radius: 8px; font-size: 12px;
  background: color-mix(in srgb, var(--primary) 10%, var(--card)); color: var(--text);
}
.dva-focus span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dva-focus-x { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 6px; color: var(--muted); }
.dva-foot { margin: 0; font-size: 11px; color: var(--muted); line-height: 1.4; }

@media (max-width: 1100px) { .dva { grid-template-columns: minmax(0, 1fr) 320px; } }
@media (max-width: 900px) {
  .dva { grid-template-columns: minmax(0, 1fr); }
  .dva-stage { min-height: 0; }
  .dva-empty { min-height: 160px; padding: 20px; }
  .dva-chat { position: static; height: auto; min-height: 0; }
  .dva-log { max-height: 50vh; }
  .dva-composer { position: sticky; bottom: 0; padding: 8px 0 12px; background: var(--card); }
  .dva-send { width: 44px; height: 44px; bottom: 18px; }
  .dva-composer textarea { padding-right: 56px; min-height: 60px; }
}

/* A report the analyst wrote: its link, as a card in the conversation. */
.dva-msg.is-report { align-self: stretch; max-width: 100%; padding: 0; background: none; white-space: normal; }
.dva-report {
  display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 10px 12px; border-radius: 12px;
  border: 1px solid color-mix(in srgb, var(--primary) 40%, var(--border)); background: var(--card); color: var(--text); text-decoration: none;
}
.dva-report:hover { border-color: var(--primary); }
.dva-report > span { display: flex; flex-direction: column; min-width: 0; }
.dva-report small { font-size: 11px; color: var(--muted); }
.dva-report b { font-weight: 600; }
.dva-report .ic { flex: none; color: var(--primary); }
