/* Basecamp-style chat replica, styled to match the reference screenshot. */

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
}

body {
  background: #f3f4f6;
  color: #272e34;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  /* room for the fixed top navbar; --header-h is set from its measured height */
  padding-top: var(--header-h, 49px);
}

/* Signed-out pages (login) have no chrome — kill the reserved header space. */
body.signed-out {
  padding-top: 0;
}

main {
  flex: 1;
  display: block;
  width: 100%;
  background: #f3f4f6;
}

/* Keep anchored chat turns clear of the sticky page header. */
[id^="turn-"] {
  scroll-margin-top: 180px;
}

a {
  color: inherit;
  text-decoration: none;
}

/* ---------- Date divider ---------- */

.date-divider {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 22px 0;
  color: #6b7280; /* gray-500: 4.8:1 on white (was #9aa0a5 at 2.5:1) */
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .04em;
}

.date-divider::before,
.date-divider::after {
  content: "";
  flex: 1;
  border-top: 1px solid #f3f4f6;
}

/* Navbars / chatbox / drawers (Tailwind utility classes; preflight is off).
   :where() keeps the reset at zero specificity so utility classes (bg-*, p-*, border-*)
   always win — otherwise the reset stomps e.g. the Assign/Label/Due date pill backgrounds. */
:where(body > header button,
footer button,
main button,
.chat-center button,
.chatbar button,
el-dialog button) {
  appearance: none;
  background: transparent;
  border: 0;
  padding: 0;
  font: inherit;
  color: inherit;
  cursor: pointer;
}

/* Chat input strip: top divider via hand-written CSS. */
.chatbar {
  border-top: 1px solid #f3f4f6;
}

/* Tailwind CDN border-* utilities are generated but never actually apply in this
   app (CDN quirk) — redefine the ones the views use as real CSS borders. */
.border { border: 1px solid; }
.border-0 { border: 0; }
.border-t { border-top: 1px solid; }
.border-r { border-right: 1px solid; }
.border-b { border-bottom: 1px solid; }
.border-l { border-left: 1px solid; }
.border-b-2 { border-bottom: 2px solid; }
.border-l-4 { border-left: 4px solid; }
.border-gray-200 { border-color: #e5e7eb; }
.border-gray-100 { border-color: #f3f4f6; }
.border-gray-300 { border-color: #d1d5db; }
.border-red-600 { border-color: #dc2626; }
.border-transparent { border-color: transparent; }

/* focus-within variant used on the chat input underline (CDN variants are dead too) */
[class*="focus-within:border-b-2"]:focus-within {
  border-bottom-width: 2px;
  border-bottom-color: #dc2626;
  padding-bottom: 0;
}

/* dialog::backdrop for the Settings drawer: dim + blur (CDN backdrop utilities are
   unreliable, so this is hand-written). */
#drawer-settings::backdrop {
  background: rgb(17 24 39 / 0.5);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

/* divide-* utilities are border-based and dead the same way — redefine. */
.divide-y > :not([hidden]) ~ :not([hidden]) { border-top: 1px solid; }
.divide-gray-200 > :not([hidden]) ~ :not([hidden]) { border-color: #e5e7eb; }
.divide-gray-300 > :not([hidden]) ~ :not([hidden]) { border-color: #d1d5db; }

/* border-style utilities are dead in the CDN the same way — the dashed upload box
   needs this after the .border shorthand (which sets style: solid). */
.border-dashed { border-style: dashed; }

/* Without preflight, fieldset/legend keep native borders and padding — strip them. */
fieldset {
  border: 0;
  margin: 0;
  padding: 0;
}

/* Preflight parity: UA margins on text elements (utility mt-*/mb-* still win —
   they come later in the cascade from the CDN stylesheet). */
p, h1, h2, h3, h4 {
  margin: 0;
}

/* Lists used as layout grids (role="list"): without preflight the UA shows
   disc markers and indents them — the agents grid and standup feed render a
   stray bullet beside every card/row until this is reset. */
ul[role="list"],
ol[role="list"] {
  list-style: none;
  margin: 0;
  padding: 0;
}

legend {
  padding: 0;
}

/* Submit inputs are <input>, not <button> — reset their native chrome too
   (zero specificity so utility classes like bg-red-50 still win). */
:where(input[type="submit"], input[type="button"]) {
  appearance: none;
  background: transparent;
  border: 0;
  padding: 0;
  font: inherit;
  color: inherit;
  cursor: pointer;
}

/* Chatbar fields: without preflight, Safari draws native field chrome (hairline borders)
   around the textarea inside the chat input — strip it. */
.chatbar input:not([type="submit"]),
.chatbar textarea {
  appearance: none;
  -webkit-appearance: none;
  background: transparent;
  border: none;
}

/* Native popover reset (Tailwind preflight is off; without this, [popover] menus get UA borders/padding) */
[popover] {
  margin: 0;
  padding: 0;
  border: none;
  background: transparent;
}

/* Code panels for LLM responses (ChatGPT/Gemini-style, hand-written because
   some CDN utilities don't apply in this setup). */
.code-panel {
  margin: 1rem 0;
  overflow: hidden;
  border-radius: 0.75rem;
  background: #111827;
}

.code-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 1.25rem;
  background: #1f2937;
  color: #d1d5db; /* 9.8:1 on the #1f2937 header band (was #9ca3af at 5.7:1) */
  font-size: 13px;
  font-family: ui-monospace, SFMono-Regular, SF Mono, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  letter-spacing: 0.05em;
}

.copy-code-btn {
  background: transparent;
  border: none;
  padding: 0;
  cursor: pointer;
  color: #d1d5db;
  font: inherit;
  letter-spacing: normal;
}

.copy-code-btn:hover {
  color: #ffffff;
}

.code-panel pre {
  margin: 0;
  padding: 1rem 1.25rem;
  overflow-x: auto;
  color: #f9fafb; /* 16.1:1 on the #111827 panel (was #e5e7eb at 14.1:1) */
  background: transparent;
  font-size: 15px;
  line-height: 1.7;
  font-family: ui-monospace, SFMono-Regular, SF Mono, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  white-space: pre;
}

.inline-code {
  background: #f3f4f6;
  border: 1px solid #e5e7eb;
  border-radius: 0.375rem;
  padding: 0.1rem 0.35rem;
  font-size: 15px;
  color: #1f2937; /* near-black on the light chip: 14.9:1 */
  font-family: ui-monospace, SFMono-Regular, SF Mono, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}

/* Fast-navigation lip docked to the right edge of the chat column. */
.nav-lip {
  position: fixed;
  /* sits in the gray gutter, just OUTSIDE the white chat column */
  right: max(0.75rem, calc((100vw - var(--content-w, 80rem)) / 2 - 3.25rem));
  top: 50%;
  /* no transform: fixed+transform compositing glitched sticky headers in Safari */
  margin-top: -76px;
  z-index: 30;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 0.35rem 0.3rem;
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 9999px;
  box-shadow: 0 2px 8px rgb(0 0 0 / 0.08);
}

.nav-lip-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.1rem;
  height: 2.1rem;
  padding: 0;
  border: none;
  border-radius: 9999px;
  background: transparent;
  color: #9ca3af;
  cursor: pointer;
}

.nav-lip-btn:hover {
  background: #f3f4f6;
  color: #374151;
}

.nav-lip-divider {
  width: 1.25rem;
  border-top: 1px solid #e5e7eb;
}

/* Brief red flash on the turn Copy button after copying. */
.turn-action-copied {
  color: #dc2626 !important;
}

/* Chatbar controls: agent picker, chips, menus, think pill, send/stop. */
.cb-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 12px;
  font-weight: 500;
  color: #4b5563;
  background: #f3f4f6;
  border-radius: 9999px;
  padding: 0.3rem 0.7rem;
  white-space: nowrap;
}

.cb-chip-btn {
  cursor: pointer;
  border: none;
  font: inherit;
}

.cb-chip-btn:hover {
  background: #e5e7eb;
}

.cb-agent-avatar {
  width: 1.25rem;
  height: 1.25rem;
  border-radius: 9999px;
  object-fit: cover;
}

.cb-agent-initials {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.25rem;
  height: 1.25rem;
  border-radius: 9999px;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  flex: none;
}

.cb-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  padding: 0;
  border: none;
  border-radius: 9999px;
  background: transparent;
  color: #9ca3af;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}

.cb-icon-btn:hover {
  background: #f3f4f6;
  color: #374151;
}

.cb-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 12px;
  font-weight: 600;
  color: #6b7280;
  background: #f3f4f6;
  border: none;
  border-radius: 9999px;
  padding: 0.35rem 0.75rem;
  cursor: pointer;
  white-space: nowrap;
}

.cb-pill:hover {
  background: #e5e7eb;
}

.cb-pill-on,
.cb-pill-on:hover {
  background: #fee2e2;
  color: #dc2626;
}

.cb-menu {
  position: absolute;
  bottom: calc(100% + 10px);
  left: 1.5rem;
  display: none;
  min-width: 17rem;
  max-height: 18rem;
  overflow-y: auto;
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 0.75rem;
  box-shadow: 0 10px 25px rgb(0 0 0 / 0.12);
  padding: 0.35rem;
  z-index: 50;
}

.cb-menu.open {
  display: block;
}

.cb-menu-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  width: 100%;
  text-align: left;
  font-size: 13px;
  color: #374151;
  background: transparent;
  border: none;
  border-radius: 0.5rem;
  padding: 0.45rem 0.6rem;
  cursor: pointer;
}

.cb-menu-item:hover {
  background: #f3f4f6;
}

.cb-menu-hint {
  color: #9ca3af;
  font-size: 12px;
}

.cb-menu-strong {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-weight: 600;
  color: #dc2626;
}

.send-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  border: none;
  border-radius: 9999px;
  background: #dc2626;
  color: #ffffff;
  cursor: pointer;
  flex: none;
}

.send-btn:hover {
  background: #b91c1c;
}

#chat-form.is-sending .send-icon {
  display: none;
}

#chat-form.is-sending .stop-icon {
  display: block !important;
}

.cb-mic-on,
.cb-mic-on:hover {
  background: #fee2e2 !important;
  color: #dc2626 !important;
}

/* Typewriter caret while a reply streams in. */
.streaming-caret {
  display: inline-block;
  width: 0.55em;
  height: 1.05em;
  margin-left: 2px;
  vertical-align: text-bottom;
  background: #dc2626;
  animation: streaming-blink 0.9s steps(2, start) infinite;
}

@keyframes streaming-blink {
  to {
    visibility: hidden;
  }
}

/* Per-turn divider: one quiet hairline by default; actions + run metadata
   fade in on hover/focus. Touch devices (no hover) always show them. */
.turn-divider {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 2.5rem;
}

.turn-divider .hairline {
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  border-top: 1px solid #e5e7eb;
}

.turn-action-group {
  position: relative;
  background: #ffffff;
  padding: 0 0.75rem;
  transition: opacity 0.15s ease;
}

@media (hover: hover) and (pointer: fine) {
  .turn-action-group {
    opacity: 0;
  }

  [id^="turn-"]:hover .turn-action-group,
  [id^="turn-"]:focus-within .turn-action-group {
    opacity: 1;
  }
}

/* User-turn hover actions sit in the card's top-right corner (no divider). */
.user-turn-actions {
  position: absolute;
  top: -0.65rem;
  right: 0.75rem;
  padding: 0;
  background: transparent;
  z-index: 10;
}

/* Toggle switch (hand-rolled; the CDN can't be trusted for has-[:checked] variants). */
.k-switch {
  position: relative;
  display: inline-flex;
  width: 2.75rem;
  height: 1.5rem;
  flex-shrink: 0;
  border-radius: 9999px;
  background: #e5e7eb;
  padding: 2px;
  transition: background 0.2s ease-in-out;
  box-shadow: inset 0 0 0 1px rgb(17 24 39 / 0.05);
}

.k-switch input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.k-switch .knob {
  width: 1.25rem;
  height: 1.25rem;
  border-radius: 9999px;
  background: #ffffff;
  box-shadow: 0 1px 2px rgb(0 0 0 / 0.12), 0 0 0 1px rgb(17 24 39 / 0.05);
  transition: transform 0.2s ease-in-out;
  pointer-events: none;
}

.k-switch:has(input:checked) {
  background: #dc2626;
}

.k-switch input:checked ~ .knob {
  transform: translateX(1.25rem);
}

.k-switch input:focus-visible ~ .knob {
  outline: 2px solid #dc2626;
  outline-offset: 2px;
}

/* Long unbreakable tokens (URLs, identifiers) must not blow up narrow layouts. */
.turn-prose,
.inline-code {
  overflow-wrap: anywhere;
}

/* Choices UI: rendered only when an LLM turn offers options to pick from. */
.choices-panel {
  margin-top: 1rem;
  border: 1px solid #d1d5db;
  border-radius: 0.5rem;
  background: #ffffff;
  overflow: hidden;
}

.choices-panel table {
  width: 100%;
  border-collapse: collapse;
}

.choices-panel td {
  padding: 0.9rem 1rem;
  font-size: 0.875rem;
  vertical-align: middle;
}

.choices-panel tbody tr + tr td {
  border-top: 1px solid #e5e7eb;
}

.choices-panel .choice-main {
  width: 100%;
}

.choices-panel .choice-title {
  font-weight: 500;
  color: #111827;
}

.choices-panel .choice-desc {
  margin-top: 0.15rem;
  color: #6b7280;
}

.choices-panel .choice-action {
  white-space: nowrap;
  text-align: right;
}

.choice-select {
  display: inline-flex;
  align-items: center;
  border-radius: 0.375rem;
  background: #ffffff;
  padding: 0.4rem 0.7rem;
  font-size: 0.875rem;
  font-weight: 600;
  color: #111827;
  border: 1px solid #d1d5db;
  box-shadow: 0 1px 2px rgb(0 0 0 / 0.05);
  cursor: pointer;
}

.choice-select:hover {
  background: #f9fafb;
  color: #dc2626;
  border-color: #dc2626;
}

/* Reading typography for LLM prose (iA-style: larger text, comfortable measure). */
.turn-prose {
  font-size: 17px;
  line-height: 1.8;
  color: #374151;
  overflow-wrap: anywhere;
}

/* Bold must render black, not the gray-700 body tone. */
.turn-prose strong,
.turn-prose b {
  color: #111827;
}

/* User turns share the answer type scale: same 17px/1.8, near-black text.
   The two-class selector out-specifies stray Tailwind text-sm/text-gray-500
   utilities on the element. */
.turn-prose.user-turn-prose {
  font-size: 17px;
  line-height: 1.8;
  color: #1f2937;
}

.turn-prose .md-p {
  margin: 0 0 1em;
  white-space: pre-wrap;
}

.turn-prose .md-p:last-child {
  margin-bottom: 0;
}

.turn-prose .md-h {
  margin: 1.4em 0 0.5em;
  color: #111827;
  letter-spacing: -0.01em;
}

.turn-prose .md-h:first-child {
  margin-top: 0;
}

.turn-prose .md-h2 {
  font-size: 1.3em;
  font-weight: 650;
}

.turn-prose .md-h3 {
  font-size: 1.12em;
  font-weight: 600;
}

.turn-prose .md-h4 {
  font-size: 1em;
  font-weight: 600;
}

.turn-prose .md-list {
  margin: 0.3em 0 1em;
  padding-left: 1.4em;
}

.turn-prose .md-list li {
  margin: 0.25em 0;
}

.turn-prose .md-link {
  color: #dc2626;
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-color: #fca5a5;
}

/* The model's inline thinking while it streams. */
.streaming-thinking {
  margin-bottom: 0.9em;
  color: #6b7280; /* gray-500 */
  font-style: italic;
  font-size: 15px;
  line-height: 1.7;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

/* Data tables: markdown pipe tables rendered as generative UI. */
.data-table-wrap {
  margin: 1rem 0;
  overflow-x: auto;
  border: 1px solid #e5e7eb;
  border-radius: 0.5rem;
  background: #ffffff;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: inherit;
  line-height: 1.55;
}

.data-table .dt-th {
  text-align: left;
  padding: 0.7rem 1rem;
  font-weight: 600;
  color: #111827;
  background: #f9fafb;
  border-bottom: 1px solid #e5e7eb;
  white-space: nowrap;
}

.data-table .dt-td {
  padding: 0.8rem 1rem;
  color: #4b5563;
  vertical-align: top;
}

.data-table .dt-td-first {
  font-weight: 500;
  color: #111827;
  white-space: nowrap;
}

.data-table tbody tr + tr .dt-td {
  border-top: 1px solid #f3f4f6;
}

/* Raw-HTML deliverable bodies (html kind): keep the 17px reading standard
   even though stored LLM HTML ships its own Tailwind text-* classes.
   `.deliverable-body th/td` out-specifies a bare `.text-sm` utility. */
.deliverable-body {
  font-size: 17px;
  line-height: 1.8;
  color: #374151;
  overflow-wrap: anywhere;
}

.deliverable-body table {
  width: 100%;
  border-collapse: collapse;
  font-size: inherit;
  line-height: 1.55;
}

.deliverable-body th,
.deliverable-body td {
  padding: 0.7rem 1rem;
  font-size: 17px;
  text-align: left;
  vertical-align: top;
}

.deliverable-body th {
  font-weight: 600;
  color: #111827;
  background: #f9fafb;
  border-bottom: 1px solid #e5e7eb;
}

.deliverable-body td {
  color: #4b5563;
}

.deliverable-body tbody tr + tr td {
  border-top: 1px solid #f3f4f6;
}

/* Autonomous agent runs panel. */
.run-card {
  border: 1px solid #e5e7eb;
  border-radius: 0.5rem;
  padding: 0.9rem 1rem;
  margin-bottom: 0.75rem;
  background: #ffffff;
}

.run-badge {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  border-radius: 9999px;
  padding: 0.15rem 0.6rem;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.run-badge-queued    { background: #f3f4f6; color: #6b7280; }
.run-badge-planning  { background: #f3f4f6; color: #4b5563; }
.run-badge-executing { background: #e5e7eb; color: #374151; }
.run-badge-verifying { background: #f3f4f6; color: #4b5563; }
.run-badge-completed { background: #6b7280; color: #ffffff; }
.run-badge-failed    { background: #fef2f2; color: #dc2626; }
.run-badge-replying  { background: #fef2f2; color: #dc2626; }
.run-badge-awaiting_review { background: #fef2f2; color: #dc2626; }
.run-badge-canceled   { background: #f3f4f6; color: #9ca3af; }

.run-progress {
  margin-top: 0.6rem;
  height: 4px;
  border-radius: 9999px;
  background: #f3f4f6;
  overflow: hidden;
}

.run-progress span {
  display: block;
  height: 100%;
  border-radius: 9999px;
  background: #dc2626;
  transition: width 0.4s ease;
}

.run-logs {
  margin-top: 0.7rem;
  max-height: 220px;
  overflow-y: auto;
  border-radius: 0.375rem;
  background: #111827;
  padding: 0.6rem 0.8rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11.5px;
  line-height: 1.6;
  color: #d1d5db;
}

.run-log { display: flex; gap: 0.5rem; }
.run-log-level {
  flex-shrink: 0;
  width: 3.4rem;
  text-transform: uppercase;
  font-size: 10px;
  letter-spacing: 0.05em;
  color: #6b7280;
}

.run-log-plan    { color: #9ca3af; }
.run-log-step    { color: #e5e7eb; }
.run-log-verify  { color: #d1d5db; }
.run-log-warn    { color: #9ca3af; }
.run-log-error   { color: #dc2626; }

/* Run deliverable disclosure. */
.run-output {
  margin-top: 0.7rem;
}

.run-output summary {
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  color: #6b7280;
}

.run-output summary:hover {
  color: #dc2626;
}

.run-output[open] summary {
  color: #111827;
}

/* Deliverable doc: view toggle, edit, review — minimal action text. */
.dd-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.9rem;
}

.dd-toggle {
  display: inline-flex;
  gap: 2px;
  background: #f3f4f6;
  border-radius: 9999px;
  padding: 2px;
}

.dd-view-btn {
  border: none;
  background: transparent;
  border-radius: 9999px;
  padding: 0.2rem 0.7rem;
  font-size: 11px;
  font-weight: 600;
  color: #6b7280;
  cursor: pointer;
}

.dd-view-btn.dd-on {
  background: #ffffff;
  color: #111827;
  box-shadow: 0 1px 2px rgb(0 0 0 / 0.08);
}

.dd-action {
  background: transparent;
  border: none;
  padding: 0.15rem 0.1rem;
  font-size: 12px;
  font-weight: 500;
  color: #6b7280;
  cursor: pointer;
}

.dd-action:hover {
  color: #dc2626;
}

.dd-strong {
  color: #dc2626;
  font-weight: 600;
}

.dd-raw {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12.5px;
  line-height: 1.7;
  color: #374151;
}

.dd-editor {
  width: 100%;
  border: 1px solid #e5e7eb;
  border-radius: 0.5rem;
  padding: 0.75rem 0.9rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12.5px;
  line-height: 1.7;
  color: #1f2937;
  resize: vertical;
}

.dd-editor:focus {
  outline: 2px solid #dc2626;
  outline-offset: -1px;
  border-color: transparent;
}

.dd-review-input {
  width: 100%;
  border: 1px solid #e5e7eb;
  border-radius: 0.5rem;
  padding: 0.55rem 0.8rem;
  font-size: 13px;
  color: #1f2937;
}

.dd-review-input:focus {
  outline: 2px solid #dc2626;
  outline-offset: -1px;
  border-color: transparent;
}

.dd-subbar {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  margin-top: 0.6rem;
}

.dd-note {
  font-size: 12px;
  color: #9ca3af;
}

/* Deliverable notices in the chat timeline: red backdrop + open button. */
.deliverable-notice {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 0.75rem;
  padding: 1rem 1.1rem;
}

.dn-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #dc2626;
}

.dn-title {
  margin-top: 0.15rem;
  font-size: 15px;
  font-weight: 600;
  color: #111827;
}

.dn-open {
  flex-shrink: 0;
  border: 1px solid #fca5a5;
  border-radius: 0.375rem;
  background: #ffffff;
  color: #dc2626;
  font-size: 12px;
  font-weight: 600;
  padding: 0.4rem 0.8rem;
  cursor: pointer;
}

.dn-open:hover {
  background: #dc2626;
  border-color: #dc2626;
  color: #ffffff;
}

/* Review bodies inside the notice card: prose, not caption size — the
   two-class selector beats the text-sm utility on the element. */
.deliverable-notice .turn-prose {
  font-size: 15px;
  line-height: 1.7;
  color: #1f2937;
}

/* White column fills the viewport down to the footer on short pages. */
.page-fill {
  min-height: calc(100vh - var(--header-h, 49px) - 64px);
}

/* Inline LLM status while streaming. */
.stream-status {
  margin-top: 0.75rem;
}

.stream-bar-transition {
  transition: width 0.6s ease;
}

.stream-steps {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-top: 0.6rem;
  font-size: 12px;
  font-weight: 500;
  color: #6b7280;
}

.stream-step-center {
  text-align: center;
}

.stream-step-right {
  text-align: right;
}

.stream-step.stream-active {
  color: #dc2626;
}

/* Ultra-wide screens: let the white content column breathe (1760px cap past 2xl).
   --content-w keeps the floating buttons' gutter math in sync. */
:root {
  --content-w: 80rem;
}

@media (min-width: 1536px) {
  :root {
    --content-w: 110rem;
  }

  .max-w-7xl {
    max-width: 110rem !important;
  }
}

/* Deliverables side lip: vertical red tab, white text. */
.deliverables-lip {
  position: fixed;
  left: 0;
  top: 50%;
  margin-top: -70px;
  z-index: 30;
  background: #dc2626;
  color: #ffffff;
  border: none;
  border-radius: 0 0.5rem 0.5rem 0;
  padding: 1rem 0.4rem;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  writing-mode: vertical-rl;
  cursor: pointer;
  box-shadow: 2px 2px 12px rgb(0 0 0 / 0.2);
}

.deliverables-lip:hover {
  background: #b91c1c;
}

/* Queued state of the streaming turn: all-gray placeholder. The red-600
   accent appears only when the same node upgrades to the active stream. */
.stream-turn-queued #stream-status-text {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.stream-turn-queued #stream-status-text::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 9999px;
  background: #9ca3af;
}

/* While streaming, only the status component shows — the in-progress
   thinking and half-typed text stay hidden until the answer renders. */
.streaming-thinking,
#streaming-turn .turn-prose,
.stream-turn-queued .turn-prose {
  display: none !important;
}

/* Anchor targets clear the fixed navbar. */
#sprint-goals,
#wip {
  scroll-margin-top: calc(var(--header-h, 49px) + 12px);
}

/* Kind badge on deliverable cards (ring utilities are unreliable via CDN). */
.kind-badge {
  display: inline-flex;
  flex-shrink: 0;
  align-items: center;
  border-radius: 9999px;
  padding: 0.125rem 0.5rem;
  font-size: 11px;
  font-weight: 500;
  background: #f3f4f6;
  color: #6b7280;
  box-shadow: inset 0 0 0 1px rgb(229 231 235);
}

.kind-badge-red {
  background: #fee2e2;
  color: #b91c1c;
  box-shadow: inset 0 0 0 1px #fecaca;
}

/* Lip attaches to the chat column's right edge. */
.deliverables-lip {
  left: auto;
  right: max(0px, calc((100vw - var(--content-w, 80rem)) / 2));
  border-radius: 0.5rem 0 0 0.5rem;
}

/* Sources lip: black tab, white text, attaches to the chat column's LEFT edge.
   Must follow the right-edge rule above so its left/right win for this button. */
.sources-lip {
  background: #111827;
  color: #ffffff;
  left: max(0px, calc((100vw - var(--content-w, 80rem)) / 2));
  right: auto;
  border-radius: 0 0.5rem 0.5rem 0;
}

.sources-lip:hover {
  background: #000000;
}

/* Phones: the chat column is full-bleed, so the edge tabs would cover the
   first glyph of every line — slim them to just under the px-6 content
   padding. The floating nav pill shares the right edge with the deliverables
   tab (right: 0.75rem vs right: 0), so move it inboard to clear the tab. */
@media (max-width: 639px) {
  .deliverables-lip,
  .sources-lip {
    padding: 0.75rem 0.25rem;
    font-size: 10px;
  }

  .nav-lip {
    right: 2.5rem;
  }
}

/* Streaming stepper: TailUI "steps" component, red accent. Completed = filled
   red circle with check; current = red ring + red edge bar; upcoming = gray.
   Vertical stack on small screens, horizontal strip from lg up. */
.stream-steps-panel {
  margin-top: 0.75rem;
  border: 1px solid #e5e7eb;
  border-radius: 0.5rem;
  background: #ffffff;
  overflow: hidden;
}

.stream-steps-list {
  display: flex;
  flex-direction: column;
}

@media (min-width: 1024px) {
  .stream-steps-list {
    flex-direction: row;
  }
}

.sstep {
  position: relative;
  overflow: hidden;
  flex: 1;
}

.sstep-bar {
  position: absolute;
  left: 0;
  top: 0;
  height: 100%;
  width: 4px;
  background: transparent;
}

@media (min-width: 1024px) {
  .sstep-bar {
    bottom: 0;
    top: auto;
    height: 4px;
    width: 100%;
  }
}

.sstep-icon {
  display: flex;
  width: 2.25rem;
  height: 2.25rem;
  align-items: center;
  justify-content: center;
  border-radius: 9999px;
  border: 2px solid #d1d5db;
  background: #ffffff;
}

.sstep-num {
  font-size: 0.8rem;
  font-weight: 600;
  color: #6b7280;
}

.sstep-check {
  display: none;
  width: 1.1rem;
  height: 1.1rem;
  color: #ffffff;
}

.sstep-title {
  font-size: 0.875rem;
  font-weight: 500;
  color: #6b7280;
}

.sstep-desc {
  margin-top: 0.1rem;
  font-size: 0.78rem;
  font-weight: 400;
  color: #9ca3af;
  white-space: nowrap;
}

.sstep.sstep-current .sstep-icon {
  border-color: #dc2626;
}

.sstep.sstep-current .sstep-num {
  color: #dc2626;
}

.sstep.sstep-current .sstep-bar {
  background: #dc2626;
}

.sstep.sstep-current .sstep-title {
  color: #dc2626;
}

.sstep.sstep-done .sstep-icon {
  background: #dc2626;
  border-color: #dc2626;
}

.sstep.sstep-done .sstep-num {
  display: none;
}

.sstep.sstep-done .sstep-check {
  display: block;
}

.sstep.sstep-done .sstep-title {
  color: #111827;
}

/* Legacy progress bar + text steps: replaced by the stepper above. */
#streaming-turn .stream-steps,
.stream-turn-queued .stream-steps {
  display: none !important;
}

#streaming-turn .stream-status {
  margin-top: 1rem;
}
