/* ============================================================
   Winston AI — UnderHost chat interface
   Standalone (full-page messenger) + Embedded (iframe widget)
   Light conversation · navy console shell · cyan accents
   ============================================================ */

:root {
  /* Brand */
  --uh-primary: #00D4FF;
  --uh-primary-dark: #0091D6;
  --uh-primary-deep: #0078B8;

  --uh-navy-base: #0A1220;
  --uh-navy-mid:  #0D1B30;
  --uh-navy-panel:#0F2040;
  --uh-navy-deep: #071428;

  --uh-ink: #16202E;
  --uh-ink-soft: #475569;
  --uh-ink-faint: #8A99AB;

  --uh-surface: #FFFFFF;
  --uh-canvas: #EEF3F9;        /* page backdrop */
  --uh-thread: #F5F8FC;        /* messages area */
  --uh-border: #E4EBF3;
  --uh-border-soft: #EDF2F8;

  --uh-success: #19B36B;
  --uh-success-soft: #E5F7EF;
  --uh-warning: #D9920B;
  --uh-error: #E0364B;

  --uh-grad-cyan: linear-gradient(135deg, #00D4FF 0%, #0091D6 100%);
  --uh-grad-navy: linear-gradient(180deg, #0A1220 0%, #0D1B30 52%, #112548 100%);
  --uh-grad-user: linear-gradient(135deg, #143058 0%, #0F2040 100%);

  --uh-shadow-sm: 0 1px 2px rgba(15,32,64,.06), 0 1px 3px rgba(15,32,64,.05);
  --uh-shadow-md: 0 8px 24px rgba(15,32,64,.10);
  --uh-shadow-lg: 0 24px 60px rgba(8,16,32,.22);
  --uh-glow: 0 6px 22px rgba(0,145,214,.40);

  --uh-r-sm: 10px;
  --uh-r-md: 14px;
  --uh-r-lg: 18px;
  --uh-r-xl: 22px;

  --uh-font: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --uh-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Consolas, monospace;

  --uh-header-h: 68px;
  --uh-sidebar-w: 296px;
  --uh-ease: cubic-bezier(.22,1,.36,1);
  --uh-dur: .26s;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  font-family: var(--uh-font);
  font-size: 15px;
  color: var(--uh-ink);
  background: var(--uh-canvas);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow: hidden;
}

/* ============================================================
   APP SHELL
   ============================================================ */
.uh-app {
  display: grid;
  grid-template-columns: var(--uh-sidebar-w) 1fr;
  height: 100vh;
  height: 100dvh;
  width: 100%;
  background: var(--uh-canvas);
  overflow: hidden;
}

/* ---------- Sidebar (standalone desktop) ---------- */
.uh-sidebar {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 22px;
  padding: 26px 22px 20px;
  background: var(--uh-grad-navy);
  color: rgba(255,255,255,.82);
  overflow-y: auto;
  border-right: 1px solid rgba(255,255,255,.06);
}
.uh-sidebar::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(120% 50% at 0% 0%, rgba(0,212,255,.16), transparent 60%);
  pointer-events: none;
}
.uh-sidebar > * { position: relative; z-index: 1; }

.uh-side-logo img {
  height: 34px;
  width: auto;
  display: block;
}

.uh-status-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 14px;
  border-radius: var(--uh-r-md);
  background: rgba(255,255,255,.05);
  border: 1px solid rgba(255,255,255,.09);
  color: inherit;
  text-decoration: none !important;
}
.uh-status-card:hover,
.uh-status-card:focus,
.uh-status-card:active,
.uh-status-card:visited {
  color: inherit;
  text-decoration: none !important;
}
.uh-status-card *,
.uh-status-card:hover *,
.uh-status-card:focus *,
.uh-status-card:active *,
.uh-status-card:visited * {
  text-decoration: none !important;
}
.uh-status-led {
  position: relative;
  flex: none;
  width: 11px; height: 11px;
  border-radius: 50%;
  background: var(--uh-success);
  box-shadow: 0 0 0 0 rgba(25,179,107,.55);
  animation: uh-pulse 2.4s var(--uh-ease) infinite;
}
@keyframes uh-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(25,179,107,.5); }
  70%  { box-shadow: 0 0 0 7px rgba(25,179,107,0); }
  100% { box-shadow: 0 0 0 0 rgba(25,179,107,0); }
}
.uh-status-tt { font-size: 13px; font-weight: 700; color: #fff; line-height: 1.2; }
.uh-status-st { font-size: 11.5px; color: rgba(255,255,255,.55); margin-top: 2px; }

.uh-side-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: rgba(255,255,255,.42);
  margin-bottom: 11px;
}
.uh-topics { display: flex; flex-direction: column; gap: 8px; }
.uh-topic {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  text-align: left;
  padding: 11px 13px;
  border-radius: var(--uh-r-sm);
  background: rgba(255,255,255,.04);
  border: 1px solid rgba(255,255,255,.07);
  color: rgba(255,255,255,.88);
  font: inherit;
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--uh-dur), border-color var(--uh-dur), transform var(--uh-dur);
}
.uh-topic i { color: var(--uh-primary); font-size: 14px; width: 16px; text-align: center; }
.uh-topic:hover {
  background: rgba(0,212,255,.10);
  border-color: rgba(0,212,255,.32);
  transform: translateX(2px);
}

.uh-side-spacer { flex: 1 1 auto; }

.uh-side-links { display: flex; flex-direction: column; gap: 2px; }
.uh-side-links a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--uh-r-sm);
  color: rgba(255,255,255,.74);
  text-decoration: none;
  font-size: 13.5px;
  transition: background var(--uh-dur), color var(--uh-dur);
}
.uh-side-links a i { width: 16px; text-align: center; color: rgba(255,255,255,.5); }
.uh-side-links a:hover { background: rgba(255,255,255,.06); color: #fff; }
.uh-side-links a:hover i { color: var(--uh-primary); }

.uh-side-foot {
  font-size: 11.5px;
  color: rgba(255,255,255,.4);
  padding-top: 14px;
  border-top: 1px solid rgba(255,255,255,.08);
  display: flex; align-items: center; gap: 7px;
}
.uh-side-foot strong { color: rgba(255,255,255,.7); font-weight: 700; }

/* ============================================================
   CONVERSATION COLUMN
   ============================================================ */
.uh-conversation {
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--uh-surface);
  height: 100vh;
  height: 100dvh;
}

/* ---------- Header ---------- */
.uh-conv-header {
  flex: none;
  display: flex;
  align-items: center;
  gap: 12px;
  height: var(--uh-header-h);
  padding: 0 18px;
  background: var(--uh-surface);
  border-bottom: 1px solid var(--uh-border);
  z-index: 5;
}
.uh-menu-btn {
  display: none;
  width: 40px; height: 40px;
  border: none; background: transparent;
  color: var(--uh-ink); font-size: 18px;
  border-radius: 10px; cursor: pointer;
}
.uh-menu-btn:hover { background: var(--uh-thread); }

.uh-conv-id { display: flex; align-items: center; gap: 12px; min-width: 0; }
.uh-avatar {
  position: relative;
  flex: none;
  width: 42px; height: 42px;
  border-radius: 50%;
  background: transparent;
}
.uh-avatar img { width: 100%; height: 100%; object-fit: contain; display: block; }
.uh-avatar.is-online::after {
  content: "";
  position: absolute;
  right: -1px; bottom: -1px;
  width: 12px; height: 12px;
  border-radius: 50%;
  background: var(--uh-success);
  border: 2.5px solid var(--uh-surface);
}
.uh-conv-meta { min-width: 0; }
.uh-conv-title {
  font-size: 15px; font-weight: 700; color: var(--uh-ink);
  display: flex; align-items: center; gap: 7px; line-height: 1.2;
}
.uh-verified { color: var(--uh-primary-dark); font-size: 13px; }
.uh-conv-sub { font-size: 12px; color: var(--uh-ink-faint); margin-top: 1px; }

.uh-conv-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.uh-online {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 12px; font-weight: 600; color: var(--uh-success);
  padding: 6px 11px; border-radius: 999px;
  background: var(--uh-success-soft);
}
.uh-online::before {
  content: ""; width: 7px; height: 7px; border-radius: 50%;
  background: var(--uh-success);
}
.uh-iconbtn {
  width: 40px; height: 40px;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--uh-border);
  background: var(--uh-surface);
  color: var(--uh-ink-soft);
  border-radius: 10px; cursor: pointer; font-size: 15px;
  transition: background var(--uh-dur), color var(--uh-dur), border-color var(--uh-dur);
}
.uh-iconbtn:hover { background: var(--uh-thread); color: var(--uh-primary-dark); border-color: var(--uh-border); }

/* Slim header for embedded mode (hidden by default) */
.uh-open-full {
  display: none;
  align-items: center; gap: 6px;
  font-size: 12px; font-weight: 600;
  color: var(--uh-primary-dark);
  text-decoration: none;
  padding: 6px 10px; border-radius: 8px;
}
.uh-open-full:hover { background: rgba(0,145,214,.08); }

/* ---------- Dev notice strip ---------- */
#devNotice {
  flex: none;
  display: flex; align-items: center; gap: 10px;
  padding: 9px 18px;
  font-size: 12.5px; color: #0c5c3f;
  background: var(--uh-success-soft);
  border-bottom: 1px solid #d4efe2;
}
#devNotice .uh-notice-ico { color: var(--uh-success); }
#devNotice p { margin: 0; }
#devNotice a { color: #0a6b8f; font-weight: 600; }
.uh-notice-wrap { flex: none; position: relative; }
.uh-notice-head { display: none; }

/* ============================================================
   CHAT CONTAINER · MESSAGES · INPUT
   ============================================================ */
.chat-container {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--uh-thread);
}

.chat-messages {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;
  padding: 24px clamp(16px, 4vw, 40px) 20px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  background:
    radial-gradient(120% 60% at 50% -10%, rgba(0,145,214,.05), transparent 60%),
    var(--uh-thread);
}
.chat-messages::-webkit-scrollbar { width: 9px; }
.chat-messages::-webkit-scrollbar-thumb {
  background: #cdd9e6; border-radius: 999px; border: 2px solid var(--uh-thread);
}
.chat-messages::-webkit-scrollbar-thumb:hover { background: #b6c6d6; }

/* ---------- Message rows ---------- */
.message {
  display: flex;
  gap: 11px;
  max-width: 760px;
  width: 100%;
  margin: 0 auto;
  align-items: flex-end;
  animation: uh-msg-in .34s var(--uh-ease) both;
}
@keyframes uh-msg-in {
  from { transform: translateY(9px); }
  to   { transform: translateY(0); }
}
.message.user { flex-direction: row-reverse; }

.msg-avatar {
  flex: none;
  width: 34px; height: 34px;
  border-radius: 50%;
  background: transparent;
  align-self: flex-end;
}
.msg-avatar img { width: 100%; height: 100%; object-fit: contain; display: block; }

.msg-col {
  display: flex;
  flex-direction: column;
  min-width: 0;
  max-width: min(78%, 580px);
}
.message.user .msg-col { align-items: flex-end; }

.msg-bubble {
  position: relative;
  padding: 12px 16px;
  border-radius: 16px;
  font-size: 14.5px;
  line-height: 1.62;
  word-wrap: break-word;
  overflow-wrap: anywhere;
}
.message.ai .msg-bubble {
  background: var(--uh-surface);
  color: var(--uh-ink);
  border: 1px solid var(--uh-border);
  border-bottom-left-radius: 5px;
  box-shadow: var(--uh-shadow-sm);
}
.message.user .msg-bubble {
  background: var(--uh-grad-user);
  color: #fff;
  border-bottom-right-radius: 5px;
  box-shadow: 0 4px 14px rgba(15,32,64,.20);
}

/* sender label */
.msg-bubble > strong {
  display: block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  margin-bottom: 4px;
}
.message.ai .msg-bubble > strong { color: var(--uh-primary-dark); }
.message.user .msg-bubble > strong { color: rgba(255,255,255,.62); }

/* meta row */
.msg-meta {
  display: flex; align-items: center; gap: 8px;
  margin-top: 5px; padding: 0 4px;
  height: 16px;
}
.message.user .msg-meta { flex-direction: row-reverse; }
.msg-time { font-size: 11px; color: var(--uh-ink-faint); font-variant-numeric: tabular-nums; }
.msg-copy {
  border: none; background: transparent;
  color: var(--uh-ink-faint); cursor: pointer;
  font-size: 11.5px; padding: 2px 5px; border-radius: 6px;
  opacity: 0; transition: opacity var(--uh-dur), background var(--uh-dur), color var(--uh-dur);
}
.message:hover .msg-copy { opacity: 1; }
.msg-copy:hover { background: var(--uh-border-soft); color: var(--uh-primary-dark); }
.msg-copy.ok { color: var(--uh-success); opacity: 1; }

/* ---------- Markdown content inside bubbles ---------- */
.msg-bubble p { margin: 0 0 10px; }
.msg-bubble p:last-child { margin-bottom: 0; }
.msg-bubble h1, .msg-bubble h2, .msg-bubble h3 {
  font-size: 15px; font-weight: 700; margin: 12px 0 6px; color: inherit;
}
.message.ai .msg-bubble h1, .message.ai .msg-bubble h2, .message.ai .msg-bubble h3 { color: var(--uh-navy-panel); }
.msg-bubble ul, .msg-bubble ol { padding-left: 20px; margin: 8px 0; }
.msg-bubble li { margin-bottom: 4px; }
.msg-bubble hr { border: none; border-top: 1px solid var(--uh-border); margin: 12px 0; }
.message.user .msg-bubble hr { border-top-color: rgba(255,255,255,.18); }
.msg-bubble blockquote {
  margin: 10px 0; padding: 4px 0 4px 13px;
  border-left: 3px solid var(--uh-primary-dark); color: var(--uh-ink-soft);
}
.msg-bubble strong { font-weight: 700; }

.chat-link {
  color: var(--uh-primary-dark);
  text-decoration: none;
  border-bottom: 1px solid rgba(0,145,214,.4);
  font-weight: 600;
  transition: color var(--uh-dur), border-color var(--uh-dur);
}
.chat-link:hover { color: var(--uh-primary-deep); border-bottom-color: var(--uh-primary-deep); }
.message.user .chat-link { color: #aee9ff; border-bottom-color: rgba(174,233,255,.45); }

.msg-bubble pre, .msg-bubble code {
  font-family: var(--uh-mono);
  font-size: 12.5px;
}
.msg-bubble code {
  background: #eef2f7; color: #0d3b66;
  padding: 1px 6px; border-radius: 6px;
}
.message.user .msg-bubble code { background: rgba(255,255,255,.14); color: #dff3ff; }
.msg-bubble pre {
  background: #0d1b30; color: #e6edf6;
  padding: 14px 16px; border-radius: 12px;
  overflow-x: auto; margin: 10px 0;
  white-space: pre; line-height: 1.55;
}
.msg-bubble pre code { background: transparent; color: inherit; padding: 0; }

/* ---------- Typing indicator ---------- */
.message.typing .msg-bubble.typing-bubble { padding: 14px 18px; }
.typing-indicator { display: flex; align-items: center; gap: 5px; height: 12px; }
.typing-indicator .dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--uh-primary-dark); opacity: .35;
  animation: uh-bounce 1.3s infinite ease-in-out;
}
.typing-indicator .dot:nth-child(2) { animation-delay: .18s; }
.typing-indicator .dot:nth-child(3) { animation-delay: .36s; }
@keyframes uh-bounce {
  0%, 80%, 100% { transform: translateY(0); opacity: .35; }
  40% { transform: translateY(-5px); opacity: 1; }
}

/* ============================================================
   INPUT AREA
   ============================================================ */
.chat-input {
  flex: none;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 10px;
  padding: 14px clamp(14px, 4vw, 32px);
  padding-bottom: max(14px, env(safe-area-inset-bottom));
  background: var(--uh-surface);
  border-top: 1px solid var(--uh-border);
}
.chat-input::before {
  /* attach point so the composer sits in a soft pill */
  content: none;
}
.chat-input textarea {
  flex: 1 1 auto;
  width: 100%;
  min-height: 50px;
  max-height: 150px;
  padding: 14px 18px;
  border: 1.5px solid var(--uh-border);
  border-radius: var(--uh-r-lg);
  resize: none;
  font-family: var(--uh-font);
  font-size: 15px;
  line-height: 1.5;
  color: var(--uh-ink);
  background: var(--uh-thread);
  outline: none;
  transition: border-color var(--uh-dur), box-shadow var(--uh-dur), background var(--uh-dur);
}
.chat-input textarea::placeholder { color: var(--uh-ink-faint); }
.chat-input textarea:focus {
  border-color: var(--uh-primary-dark);
  background: var(--uh-surface);
  box-shadow: 0 0 0 4px rgba(0,145,214,.12);
}
.attach-button {
  flex: none;
  width: 46px;
  height: 46px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--uh-border);
  border-radius: var(--uh-r-md);
  background: var(--uh-surface);
  color: var(--uh-primary-dark);
  cursor: pointer;
  transition: border-color var(--uh-dur), box-shadow var(--uh-dur), transform var(--uh-dur);
}
.attach-button:hover { transform: translateY(-1px); border-color: var(--uh-primary-dark); box-shadow: 0 8px 20px rgba(15,36,67,.10); }
.attach-button:disabled { opacity: .55; cursor: not-allowed; transform: none; }
.attachment-tray {
  flex: 1 0 100%;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 2px;
}
.attachment-tray[hidden] { display: none; }
.attachment-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: min(100%, 360px);
  padding: 7px 9px;
  border: 1px solid var(--uh-border);
  border-radius: var(--uh-r-sm);
  background: #f8fbff;
  color: var(--uh-ink);
  font-size: 12px;
  box-shadow: 0 4px 12px rgba(7,23,45,.05);
}
.attachment-chip img {
  width: 34px;
  height: 34px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--uh-border);
}
.attachment-chip strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.attachment-chip button {
  border: 0;
  background: transparent;
  color: var(--uh-ink-soft);
  cursor: pointer;
  padding: 2px;
}
.analysis-privacy-notice {
  flex: 1 0 100%;
  margin: 0 0 2px;
  color: var(--uh-ink-soft);
  font-size: 12px;
  line-height: 1.35;
}
.analysis-privacy-notice[hidden] { display: none; }
.chat-input.is-dragging {
  box-shadow: inset 0 0 0 2px rgba(0,189,242,.45);
  background: #f5fbff;
}
.chat-input button#sendButton {
  flex: none;
  width: 50px; height: 50px;
  display: inline-flex; align-items: center; justify-content: center;
  gap: 0;
  background: var(--uh-grad-cyan);
  color: #fff;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  font-size: 16px;
  box-shadow: var(--uh-glow);
  transition: transform var(--uh-dur), box-shadow var(--uh-dur), opacity var(--uh-dur);
}
.chat-input button#sendButton span { display: none; }
.chat-input button#sendButton i { margin: 0; }
.chat-input button#sendButton:hover { transform: translateY(-2px) scale(1.03); box-shadow: 0 10px 26px rgba(0,145,214,.5); }
.chat-input button#sendButton:active { transform: translateY(0) scale(.97); }
.chat-input button#sendButton:disabled {
  background: #cbd6e2; box-shadow: none; cursor: not-allowed; transform: none;
}

/* ============================================================
   PRE-SCREEN / WELCOME FORM
   ============================================================ */
.prescreen-form { display: none; }
.chat-container.with-prescreen .chat-messages,
.chat-container.with-prescreen .chat-input,
.chat-container.with-prescreen .empty-state,
.chat-container.with-prescreen .typing-indicator,
.chat-container.with-prescreen .error-banner { display: none; }
.chat-container.with-prescreen .prescreen-form { display: block; }
.chat-container.with-prescreen { overflow-y: auto; background: var(--uh-thread); }

.prescreen-form {
  max-width: 460px;
  margin: 0 auto;
  padding: 34px clamp(20px, 5vw, 38px) 38px;
  width: 100%;
}
.uh-welcome-hero { text-align: center; margin-bottom: 26px; }
.uh-welcome-hero .uh-avatar {
  width: 76px; height: 76px; margin: 0 auto 16px;
}
.uh-welcome-hero h3 {
  margin: 0 0 6px; font-size: 22px; font-weight: 800;
  color: var(--uh-navy-panel); letter-spacing: -.01em;
}
.uh-welcome-hero p {
  margin: 0; font-size: 14px; color: var(--uh-ink-soft); line-height: 1.6;
}
.prescreen-form > p {
  margin: 0 0 22px; font-size: 13.5px; color: var(--uh-ink-soft);
  text-align: center; line-height: 1.6;
}

.form-group { margin-bottom: 16px; }
.form-group label {
  display: block; margin-bottom: 7px;
  font-size: 12px; font-weight: 700; letter-spacing: .04em;
  text-transform: uppercase; color: var(--uh-ink-soft);
}
.form-group input[type="text"],
.form-group input[type="email"] {
  width: 100%;
  padding: 14px 16px;
  border: 1.5px solid var(--uh-border);
  border-radius: var(--uh-r-md);
  font-family: var(--uh-font);
  font-size: 15px;
  color: var(--uh-ink);
  background: var(--uh-surface);
  transition: border-color var(--uh-dur), box-shadow var(--uh-dur);
}
.form-group input::placeholder { color: var(--uh-ink-faint); }
.form-group input:focus {
  outline: none;
  border-color: var(--uh-primary-dark);
  box-shadow: 0 0 0 4px rgba(0,145,214,.12);
}

.customer-status { margin-bottom: 22px; }
.customer-status > label {
  display: block; margin-bottom: 9px;
  font-size: 12px; font-weight: 700; letter-spacing: .04em;
  text-transform: uppercase; color: var(--uh-ink-soft);
}
.toggle-container {
  display: flex; gap: 6px;
  padding: 5px;
  background: var(--uh-thread);
  border: 1px solid var(--uh-border);
  border-radius: 999px;
}
.toggle-option {
  flex: 1;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 14px;
  border-radius: 999px;
  font-size: 14px; font-weight: 600;
  color: var(--uh-ink-soft);
  background: transparent; border: none; cursor: pointer;
  transition: background var(--uh-dur), color var(--uh-dur), box-shadow var(--uh-dur);
}
.toggle-option i { font-size: 15px; }
.toggle-option.active {
  background: var(--uh-surface);
  color: var(--uh-primary-dark);
  box-shadow: var(--uh-shadow-sm);
}
.toggle-option input[type="radio"] { display: none; }

.btn-start {
  width: 100%;
  display: flex; align-items: center; justify-content: center; gap: 10px;
  padding: 16px 24px;
  background: var(--uh-grad-cyan);
  color: #fff; border: none;
  border-radius: var(--uh-r-lg);
  font-family: var(--uh-font); font-size: 15px; font-weight: 700;
  cursor: pointer;
  box-shadow: var(--uh-glow);
  transition: transform var(--uh-dur), box-shadow var(--uh-dur);
}
.btn-start:hover { transform: translateY(-2px); box-shadow: 0 12px 30px rgba(0,145,214,.5); }
.btn-start:active { transform: translateY(0); }
.btn-start i { transition: transform var(--uh-dur); }
.btn-start:hover i { transform: translateX(4px); }
#_nameErr, #_emailErr { display: none; color: var(--uh-error); font-size: 12px; margin-top: 5px; }

/* ============================================================
   OFFLINE / RECONNECT BANNER
   ============================================================ */
.uh-offline-bar {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  top: calc(var(--uh-header-h) + 10px);
  z-index: 30;
  display: none;
  align-items: center; gap: 10px;
  padding: 9px 16px;
  background: var(--uh-navy-panel);
  color: #fff;
  border-radius: 999px;
  font-size: 13px; font-weight: 500;
  box-shadow: var(--uh-shadow-md);
}
.uh-offline-bar i { color: var(--uh-warning); }
.uh-offline-bar.show { display: flex; animation: uh-msg-in .3s var(--uh-ease); }

/* mobile drawer scrim */
.uh-scrim {
  position: fixed; inset: 0;
  background: rgba(7,16,32,.5);
  opacity: 0; visibility: hidden;
  transition: opacity var(--uh-dur), visibility var(--uh-dur);
  z-index: 40;
}

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

/* ============================================================
   EMBEDDED (iframe widget) MODE
   ============================================================ */
html.uh-chat-embedded body { background: var(--uh-surface); }
html.uh-chat-embedded .uh-app { grid-template-columns: 1fr; }
html.uh-chat-embedded .uh-sidebar { display: none; }
html.uh-chat-embedded #devNotice { display: none; }
html.uh-chat-embedded .uh-conversation { box-shadow: none; }

/* slim header: smaller, online status only, no new-chat clutter, show open-full */
html.uh-chat-embedded .uh-conv-header {
  height: 56px;
  padding: 0 14px;
  background: var(--uh-surface);
}
html.uh-chat-embedded .uh-avatar { width: 34px; height: 34px; }
html.uh-chat-embedded .uh-conv-title { font-size: 14px; }
html.uh-chat-embedded .uh-conv-sub { display: none; }
html.uh-chat-embedded .uh-online { display: none; }
html.uh-chat-embedded .uh-conv-meta .uh-online-text {
  display: block; font-size: 12px; color: var(--uh-success); margin-top: 1px; font-weight: 600;
}
html.uh-chat-embedded #uhNewChat { display: none; }
html.uh-chat-embedded .uh-open-full { display: inline-flex; }
html.uh-chat-embedded .chat-messages { padding: 18px 16px; gap: 14px; }
html.uh-chat-embedded .message { max-width: 100%; }
html.uh-chat-embedded .msg-col { max-width: 84%; }
html.uh-chat-embedded .chat-input { padding: 12px 14px; padding-bottom: max(12px, env(safe-area-inset-bottom)); }
html.uh-chat-embedded .chat-input textarea { min-height: 46px; font-size: 14.5px; }
html.uh-chat-embedded .prescreen-form { padding: 26px 20px 30px; }

.uh-online-text { display: none; }

/* ============================================================
   MOBILE  (standalone + embedded share most rules)
   ============================================================ */
html.uh-chat-mobile .uh-app { grid-template-columns: 1fr; }

/* Sidebar becomes off-canvas drawer (standalone mobile only) */
html.uh-chat-standalone.uh-chat-mobile .uh-sidebar {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: min(82vw, 320px);
  z-index: 50;
  transform: translateX(-105%);
  transition: transform var(--uh-dur) var(--uh-ease);
  padding-top: max(26px, env(safe-area-inset-top));
}
html.uh-chat-standalone.uh-chat-mobile .uh-sidebar.open { transform: translateX(0); }
html.uh-chat-standalone.uh-chat-mobile .uh-scrim.show { opacity: 1; visibility: visible; }
html.uh-chat-standalone.uh-chat-mobile .uh-menu-btn { display: inline-flex; align-items: center; justify-content: center; }
html.uh-chat-embedded .uh-menu-btn { display: none !important; }

/* Full-screen conversation, fixed header + input, scrolling messages */
html.uh-chat-mobile .uh-conversation { height: 100vh; height: 100dvh; }
html.uh-chat-mobile .uh-conv-header {
  padding-top: env(safe-area-inset-top);
  height: calc(56px + env(safe-area-inset-top));
}
html.uh-chat-mobile .uh-conv-sub { display: none; }
html.uh-chat-mobile .uh-online {
  padding: 5px 9px; font-size: 11px;
}
html.uh-chat-mobile .chat-messages { padding: 16px 14px 12px; gap: 13px; }
html.uh-chat-mobile .msg-col { max-width: 86%; }
html.uh-chat-mobile .msg-bubble { font-size: 15px; }
html.uh-chat-mobile .chat-input { padding: 10px 12px; padding-bottom: max(10px, env(safe-area-inset-bottom)); }
html.uh-chat-mobile #devNotice { display: none; }
html.uh-chat-mobile .uh-iconbtn { display: none; }
html.uh-chat-standalone.uh-chat-mobile #uhNewChat { display: inline-flex; }

/* keep desktop sidebar drawer button hidden on desktop */
html.uh-chat-desktop .uh-menu-btn { display: none; }
html.uh-chat-desktop .uh-scrim { display: none; }

/* ============================================================
   FOCUS / ACCESSIBILITY
   ============================================================ */
a:focus-visible, button:focus-visible,
input:focus-visible, textarea:focus-visible, [tabindex]:focus-visible {
  outline: 3px solid rgba(0,212,255,.5);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition-duration: .001ms !important;
    scroll-behavior: auto !important;
  }
}

/* ============================================================
   DEV APP COMPATIBILITY LAYER
   Keeps the new /dev runtime markup aligned with the current chat design.
   ============================================================ */
.uh-side-foot {
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
}
.uh-side-foot-brand,
.uh-side-foot-link {
  display: flex;
  align-items: center;
  gap: 8px;
}
.uh-side-foot-link {
  color: rgba(255,255,255,.72);
  text-decoration: none;
}
.uh-side-foot-link:hover { color: #fff; }
.uh-notice-x {
  margin-left: auto;
  border: 0;
  background: transparent;
  color: #0c5c3f;
  cursor: pointer;
  border-radius: 8px;
  width: 30px;
  height: 30px;
}
.uh-notice-x:hover { background: rgba(12,92,63,.08); }
#introBanner.is-collapsed { display: none; }
.header-action {
  width: 40px;
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--uh-border);
  background: var(--uh-surface);
  color: var(--uh-ink-soft);
  border-radius: 10px;
  cursor: pointer;
  font-size: 15px;
}
.header-action:hover {
  background: var(--uh-thread);
  color: var(--uh-primary-dark);
}
html.uh-chat-embedded #clearConversationBtn,
html.uh-chat-embedded #feedbackBtn {
  display: none;
}
html.uh-chat-standalone.uh-chat-mobile #clearConversationBtn {
  display: inline-flex;
}

.empty-state {
  flex: none;
  padding: 28px clamp(16px, 4vw, 40px) 0;
  background: var(--uh-thread);
}
.empty-state.is-hidden,
.empty-state[hidden] {
  display: none;
}
.empty-state .uh-welcome-hero {
  max-width: 680px;
  margin: 0 auto 16px;
  text-align: center;
}
.empty-state .uh-welcome-hero .uh-avatar {
  width: 72px;
  height: 72px;
  margin: 0 auto 12px;
}
.empty-state h3 {
  margin: 0 0 6px;
  font-size: 20px;
  color: var(--uh-ink);
}
.empty-state p {
  margin: 0;
  color: var(--uh-ink-soft);
  line-height: 1.55;
}
.prompt-grid {
  max-width: 780px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.prompt-chip {
  border: 1px solid var(--uh-border);
  background: var(--uh-surface);
  color: var(--uh-ink);
  border-radius: 12px;
  padding: 11px 13px;
  text-align: left;
  font: inherit;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: var(--uh-shadow-sm);
  transition: transform var(--uh-dur), border-color var(--uh-dur), color var(--uh-dur);
}
.prompt-chip:hover {
  transform: translateY(-1px);
  border-color: rgba(0,145,214,.42);
  color: var(--uh-primary-dark);
}

.msg {
  display: flex;
  width: 100%;
  animation: uh-msg-in .22s var(--uh-ease);
}
.msg-assistant { justify-content: flex-start; }
.msg-user { justify-content: flex-end; }
.msg-row {
  display: flex;
  align-items: flex-end;
  gap: 11px;
  max-width: 760px;
}
.msg-body {
  display: flex;
  flex-direction: column;
  min-width: 0;
  max-width: min(78vw, 580px);
}
.msg-assistant .msg-bubble {
  background: var(--uh-surface);
  color: var(--uh-ink);
  border: 1px solid var(--uh-border);
  border-bottom-left-radius: 5px;
  box-shadow: var(--uh-shadow-sm);
}
.msg-user .msg-bubble {
  max-width: min(78vw, 580px);
  background: var(--uh-grad-user);
  color: #fff;
  border-bottom-right-radius: 5px;
  box-shadow: var(--uh-shadow-sm);
}
.msg-actions {
  display: flex;
  gap: 6px;
  margin-top: 5px;
  padding: 0 4px;
}
.mini-btn {
  border: 0;
  background: transparent;
  color: var(--uh-ink-faint);
  cursor: pointer;
  font-size: 12px;
  padding: 4px 6px;
  border-radius: 7px;
}
.mini-btn:hover {
  background: var(--uh-border-soft);
  color: var(--uh-primary-dark);
}
.msg-welcome-minimized {
  opacity: .62;
}

#typingIndicator {
  display: none;
  align-items: center;
  gap: 6px;
  flex: none;
  margin: 0 clamp(16px, 4vw, 40px) 12px;
  padding: 10px 14px;
  width: fit-content;
  max-width: calc(100% - 32px);
  background: var(--uh-surface);
  border: 1px solid var(--uh-border);
  border-radius: 999px;
  box-shadow: var(--uh-shadow-sm);
}
#typingIndicator strong {
  margin-left: 4px;
  font-size: 12px;
  color: var(--uh-ink-faint);
}
#typingIndicator span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--uh-primary-dark);
  opacity: .35;
  animation: uh-bounce 1.3s infinite ease-in-out;
}
#typingIndicator span:nth-child(2) { animation-delay: .18s; }
#typingIndicator span:nth-child(3) { animation-delay: .36s; }

.error-banner {
  max-width: 780px;
  margin: 0 auto 10px;
  border: 1px solid var(--uh-border);
  border-radius: 14px;
  background: var(--uh-surface);
  box-shadow: var(--uh-shadow-sm);
}
.error-banner {
  padding: 10px 12px;
  color: #8a1f2d;
  background: #fff1f3;
  border-color: #ffd1d8;
  font-weight: 600;
  font-size: 13px;
}
.action-link-button {
  display: inline-flex;
  margin-top: 6px;
  padding: 8px 12px;
  border-radius: 10px;
  background: var(--uh-grad-cyan);
  color: #fff !important;
  text-decoration: none;
  font-weight: 700;
  box-shadow: var(--uh-glow);
}

@media (max-width: 768px) {
  .prompt-grid { grid-template-columns: 1fr; }
  .empty-state { padding: 18px 14px 0; }
  .msg-row { max-width: 100%; }
  .msg-body,
  .msg-user .msg-bubble { max-width: 86vw; }
  #typingIndicator { margin-left: 14px; margin-right: 14px; }
}
