/* Consult thread — a calm, centered conversation on the Al-Narjis dark canvas.
   Assistant replies read as text. Visitor turns sit on the opposite side.
   Accent stays vermilion #FF5A36. No foreign chat brand. */

body.consult-thread {
  --ct-bg: #060607;
  --ct-ink: #f6f5f4;
  --ct-muted: #b9b8c0;
  --ct-faint: #8e8d96;
  --ct-line: rgba(246, 245, 244, 0.12);
  --ct-user: #141419;
  --ct-accent: #ff5a36;
  min-height: 100dvh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background-color: var(--ct-bg);
  background-image: radial-gradient(880px 420px at 50% -12%, rgba(255, 90, 54, 0.1), transparent 62%);
  background-attachment: fixed;
  color: var(--ct-ink);
  font-family: Cairo, sans-serif;
}

html:has(body.consult-thread) {
  height: 100%;
  overflow: hidden;
}

.ct-sr {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.ct-top {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  min-width: 0;
  padding: 12px 20px;
  border-bottom: 1px solid rgba(246, 245, 244, 0.08);
  background: rgba(6, 6, 7, 0.88);
  backdrop-filter: blur(16px);
  z-index: 30;
}

.ct-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  color: inherit;
  text-decoration: none;
}

.ct-brand img {
  width: 36px;
  height: 36px;
  flex: none;
}

.ct-brand-name {
  font-weight: 700;
  font-size: 1.05rem;
  line-height: 1.2;
  letter-spacing: -0.02em;
}

.ct-accent { color: var(--ct-accent); }

.ct-brand-sub {
  color: var(--ct-faint);
  font-size: 0.75rem;
  letter-spacing: 0.04em;
}

.ct-tools {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: none;
}

.ct-home {
  padding: 8px 14px;
  min-height: 40px;
  font-size: 0.85rem;
}

.ct-stage {
  flex: 1 1 auto;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.ct-column {
  width: min(760px, 100%);
  margin-inline: auto;
  padding-inline: 20px;
}

.ct-intro {
  text-align: center;
  padding: 36px 8px 8px;
}

.ct-intro h1 {
  margin: 0 0 8px;
  font-size: clamp(1.7rem, 3.4vw, 2.35rem);
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: -0.03em;
}

.ct-intro p {
  margin: 0 auto;
  max-width: 38rem;
  color: var(--ct-muted);
  font-size: 1rem;
  line-height: 1.7;
}

.ct-log {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 4px;
  padding: 18px 0 28px;
}

/* Assistant: open reading text, not a chat bubble. */
body.consult-thread .ct-log .cmsg.ai {
  align-self: stretch;
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr);
  gap: 12px;
  width: 100%;
  max-width: none;
  margin: 10px 0 6px;
  padding: 4px 0 8px;
  background: transparent;
  color: var(--ct-ink);
  border: 0;
  border-radius: 0;
  border-start-start-radius: 0;
  border-start-end-radius: 0;
  border-end-start-radius: 0;
  border-end-end-radius: 0;
  box-shadow: none;
}

body.consult-thread .ct-avatar {
  width: 32px;
  height: 32px;
  margin-top: 2px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: #101014;
  border: 1px solid var(--ct-line);
  overflow: hidden;
}

body.consult-thread .ct-avatar img {
  width: 26px;
  height: 26px;
  display: block;
}

body.consult-thread .ct-body { min-width: 0; }

body.consult-thread .ct-prose {
  font-size: 1.0625rem;
  line-height: 1.75;
  overflow-wrap: anywhere;
}

body.consult-thread .cmsg.ai .ct-prose { color: var(--ct-ink); }

body.consult-thread .ct-prose p { margin: 0 0 0.85em; }
body.consult-thread .ct-prose p:last-child { margin-bottom: 0; }
body.consult-thread .ct-prose ul,
body.consult-thread .ct-prose ol {
  margin: 0 0 0.85em;
  padding-inline-start: 1.4em;
}
body.consult-thread .ct-prose ul { list-style: disc; }
body.consult-thread .ct-prose ol { list-style: decimal; }
body.consult-thread .ct-prose li { margin: 0.2em 0; }
body.consult-thread .ct-prose strong { font-weight: 700; }
body.consult-thread .ct-prose code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.92em;
  background: rgba(246, 245, 244, 0.08);
  padding: 0.05em 0.35em;
  border-radius: 6px;
}

body.consult-thread .ct-copy {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  padding: 4px 8px;
  min-height: 32px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--ct-faint);
  font: 600 0.78rem/1 Cairo, sans-serif;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s ease, background 0.15s ease, color 0.15s ease;
}

body.consult-thread .cmsg.ai:hover .ct-copy,
body.consult-thread .cmsg.ai:focus-within .ct-copy,
body.consult-thread .ct-copy.is-copied {
  opacity: 1;
}

body.consult-thread .ct-copy:hover,
body.consult-thread .ct-copy:focus-visible {
  background: rgba(246, 245, 244, 0.06);
  color: var(--ct-ink);
}

body.consult-thread .ct-copy svg { width: 14px; height: 14px; flex: none; }

body.consult-thread .ct-copy.is-copied { color: var(--ct-accent); }

@media (hover: none) {
  body.consult-thread .ct-copy { opacity: 0.9; }
}

/* Visitor turns: a quiet rounded plate on the opposite side. */
body.consult-thread .ct-log .cmsg.me {
  align-self: flex-end;
  max-width: min(78%, 520px);
  margin: 8px 0;
  padding: 10px 16px;
  background: var(--ct-user);
  color: var(--ct-ink);
  border: 0;
  border-radius: 22px;
  border-start-start-radius: 22px;
  border-start-end-radius: 22px;
  border-end-start-radius: 22px;
  border-end-end-radius: 22px;
  box-shadow: none;
}

body.consult-thread .cmsg.me .ct-prose {
  white-space: pre-wrap;
  font-size: 1rem;
  line-height: 1.65;
}

body.consult-thread .ct-turn {
  animation: ct-in 0.38s cubic-bezier(.16, 1, .3, 1);
}

@keyframes ct-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

body.consult-thread .ct-status {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 6px 0 0;
  color: var(--ct-faint);
  font-size: 0.95rem;
}

body.consult-thread .ct-dots {
  display: inline-flex;
  gap: 4px;
}

body.consult-thread .ct-dots i {
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: var(--ct-accent);
  animation: ct-dot 1s ease-in-out infinite;
}

body.consult-thread .ct-dots i:nth-child(2) { animation-delay: 0.15s; }
body.consult-thread .ct-dots i:nth-child(3) { animation-delay: 0.3s; }

@keyframes ct-dot {
  0%, 80%, 100% { opacity: 0.25; transform: translateY(0); }
  40% { opacity: 1; transform: translateY(-2px); }
}

.ct-dock {
  position: sticky;
  bottom: 0;
  z-index: 20;
  flex: none;
  padding: 18px 0 calc(12px + env(safe-area-inset-bottom));
  background: linear-gradient(180deg, rgba(6, 6, 7, 0) 0%, #060607 28px);
}

body.consult-thread .ct-chips {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin: 0 0 12px;
}

body.consult-thread .ct-chips.is-gone { display: none; }

body.consult-thread .chip {
  min-width: 0;
  max-width: 100%;
  white-space: normal;
  background: transparent;
  border: 1px solid var(--ct-line);
  color: var(--ct-ink);
  border-radius: 999px;
  padding: 8px 14px;
  font-weight: 600;
  line-height: 1.45;
  text-align: start;
}

body.consult-thread .chip:hover {
  background: rgba(255, 90, 54, 0.12);
  border-color: var(--ct-accent);
  color: var(--ct-ink);
}

body.consult-thread .ct-composer {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 8px 8px 8px 18px;
  border-radius: 28px;
  background: #101014;
  border: 1px solid var(--ct-line);
  box-shadow: 0 10px 32px rgba(0, 0, 0, 0.35);
}

body.consult-thread .ct-composer:focus-within {
  border-color: rgba(255, 90, 54, 0.7);
  box-shadow: 0 0 0 3px rgba(255, 90, 54, 0.22);
}

body.consult-thread .ct-composer textarea {
  flex: 1 1 auto;
  width: 100%;
  min-width: 0;
  min-height: 28px;
  max-height: 160px;
  margin: 0;
  padding: 10px 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  resize: none;
  color: var(--ct-ink);
  font: 400 1rem/1.5 Cairo, sans-serif;
}

body.consult-thread .ct-composer textarea:focus {
  outline: none;
  border: 0;
  box-shadow: none;
}

body.consult-thread .ct-send {
  width: 40px;
  height: 40px;
  flex: none;
  display: grid;
  place-items: center;
  margin-bottom: 2px;
  border: 0;
  border-radius: 999px;
  background: rgba(246, 245, 244, 0.1);
  color: var(--ct-faint);
  cursor: pointer;
}

body.consult-thread .ct-send svg { width: 18px; height: 18px; }

body.consult-thread .ct-send.is-ready {
  background: #ff5a36;
  color: #000000;
}

body.consult-thread .ct-send.is-ready:hover { background: #d93f1e; }

body.consult-thread .ct-send:disabled {
  cursor: default;
  background: rgba(246, 245, 244, 0.1);
  color: var(--ct-faint);
}

.ct-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px 16px;
  margin-top: 12px;
}

.ct-links a {
  color: var(--ct-muted);
  font-size: 0.85rem;
  font-weight: 600;
  text-decoration: none;
}

.ct-links a:hover { color: var(--ct-accent); }

.ct-legal {
  margin: 10px 0 0;
  text-align: center;
  color: var(--ct-faint);
  font-size: 0.72rem;
  line-height: 1.6;
  overflow-wrap: anywhere;
}

.ct-legal a { color: #ff5a36; text-decoration: none; }
.ct-legal a:hover { text-decoration: underline; }

body.consult-thread #cookieBar.ct-cookie {
  position: fixed;
  top: 72px;
  bottom: auto;
  inset-inline: 16px;
  max-width: 560px;
  margin-inline: auto;
  background: #101014;
  border: 1px solid var(--ct-line);
  border-radius: 18px;
  padding: 14px 18px;
  z-index: 50;
  box-shadow: 0 18px 46px rgba(0, 0, 0, 0.55);
}

body.consult-thread .nj-voice-launch {
  inset-inline-end: auto;
  inset-inline-start: 16px;
  bottom: calc(var(--ct-dock-h, 180px) + 16px + env(safe-area-inset-bottom));
  z-index: 40;
}

@media (max-width: 640px) {
  .ct-top { padding: 10px 12px; }
  .ct-column { padding-inline: 14px; }
  .ct-intro { padding-top: 22px; }
  .ct-brand-sub { display: none; }
  .ct-home { padding: 8px 10px; }
  body.consult-thread .ct-log .cmsg.me { max-width: 90%; }
  body.consult-thread .ct-composer { padding-inline-start: 14px; border-radius: 24px; }
  body.consult-thread .nj-voice-launch span {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
  }
  body.consult-thread .nj-voice-launch {
    padding: 12px;
    min-width: 48px;
    justify-content: center;
  }
}

@media (prefers-reduced-motion: reduce) {
  body.consult-thread .ct-turn,
  body.consult-thread .ct-dots i,
  body.consult-thread .ct-copy {
    animation: none;
    transition: none;
  }
}
