/* Weydom UI polish v1: layout and appearance only. */
:root {
  --weydom-chat-font: "Segoe UI", -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
  --weydom-ui-surface: #fff;
  --weydom-ui-soft: #f5f8f6;
  --weydom-ui-line: #dce5df;
  --weydom-ui-ink: #263c33;
  --weydom-ui-muted: #64766c;
}
html[data-theme="dark"] {
  --weydom-ui-surface: #1c2822;
  --weydom-ui-soft: #233129;
  --weydom-ui-line: #3b4e42;
  --weydom-ui-ink: #e4eee7;
  --weydom-ui-muted: #b5c8bb;
}

/* The composer has its own flex space; it never floats over the last answer. */
html body .shell .main {
  display: flex !important;
  flex-direction: column !important;
  min-width: 0 !important;
  height: 100vh !important;
  height: 100dvh !important;
  overflow: hidden !important;
}
html body .main > .top-navbar { flex: 0 0 auto !important; }
html body .main #messages {
  flex: 1 1 0 !important;
  min-height: 0 !important;
  overflow-y: auto !important;
  overflow-x: hidden !important;
  padding: 26px clamp(18px, 5vw, 80px) 28px !important;
  gap: 26px !important;
  scroll-padding-bottom: 24px;
}
html body .main .composer-area {
  position: relative !important;
  inset: auto !important;
  flex: 0 0 auto !important;
  width: 100% !important;
  min-width: 0 !important;
  padding: 12px clamp(16px, 4vw, 48px) max(10px, env(safe-area-inset-bottom)) !important;
  border-top: 1px solid var(--weydom-ui-line) !important;
  background: var(--cream, #faf9f5) !important;
  box-sizing: border-box !important;
  z-index: 5 !important;
}
html body .main .composer-area .composer-form,
html body .main .composer-area .composer-meta,
html body .main .composer-area #weydomEvidenceSettings {
  width: min(980px, 100%) !important;
  max-width: 100% !important;
  box-sizing: border-box !important;
  margin-left: auto !important;
  margin-right: auto !important;
}
html body .main .composer-area .composer-form {
  border: 1px solid #b7cfc2 !important;
  border-radius: 24px !important;
  padding: 7px 8px 7px 18px !important;
  min-height: 62px !important;
  background: var(--weydom-ui-surface) !important;
  box-shadow: 0 5px 22px rgb(25 67 48 / 5%) !important;
  gap: 8px !important;
}
html body .main .composer-area .composer-form:focus-within {
  border-color: #47876c !important;
  box-shadow: 0 0 0 3px rgb(71 135 108 / 10%) !important;
}
html body .main .composer-area textarea,
html body .main .composer-area select,
html body .main .composer-area button,
html body .main .composer-area .composer-meta {
  font-family: var(--weydom-chat-font) !important;
}
html body .main .composer-area textarea { font-size: 16px !important; line-height: 1.55 !important; max-height: 110px !important; }
html body .main .composer-area .send-btn,
html body .main .composer-area .stop-btn { height: 42px !important; border-radius: 16px !important; padding: 0 19px !important; font-size: 13px !important; }
html body .main .composer-meta { font-size: 11px !important; line-height: 1.5 !important; gap: 8px 20px !important; margin-top: 7px !important; flex-wrap: wrap !important; }

/* A compact comparison control, aligned with and separate from the message box. */
html body .main .composer-area #weydomEvidenceSettings {
  position: relative !important;
  inset: auto !important;
  display: block;
  margin-top: 0 !important;
  margin-bottom: 10px !important;
  padding: 10px 14px !important;
  border: 1px solid var(--weydom-ui-line) !important;
  border-radius: 16px !important;
  background: var(--weydom-ui-surface) !important;
  color: var(--weydom-ui-ink) !important;
  font: 13px/1.55 var(--weydom-chat-font) !important;
  max-height: min(240px, 28dvh);
  overflow-y: auto;
}
html body .main .composer-area #weydomEvidenceSettings[hidden] { display: none !important; }
html body .main #weydomEvidenceSettings summary { font: 600 13px/1.5 var(--weydom-chat-font) !important; cursor: pointer; }
html body .main #weydomEvidenceSettings > label { display: flex; align-items: center; gap: 8px; margin-top: 12px; }
html body .main #weydomEvidenceSettings input[type="checkbox"] { width: 16px; height: 16px; margin: 0; accent-color: #1b664b; }
html body .main #weydomEvidenceSettings .weydom-evidence-options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-top: 12px; }
html body .main #weydomEvidenceSettings .weydom-evidence-options label { min-width: 0; gap: 5px; font-size: 12px; }
html body .main #weydomEvidenceSettings select { border-radius: 10px; background: var(--weydom-ui-soft); border-color: var(--weydom-ui-line); padding: 8px 10px; min-height: 37px; font-size: 13px; }
html body .main #weydomEvidenceSettings p { font: 12px/1.5 var(--weydom-chat-font) !important; margin: 9px 0 0 !important; }

/* Rounded answer cards with an even reading rhythm. */
html body #messages .msg { min-width: 0; flex: 0 0 auto; }
html body #messages .assistant-row { padding-right: clamp(0px, 5vw, 90px) !important; }
html body #messages .bubble {
  font: 400 16px/1.75 var(--weydom-chat-font) !important;
  letter-spacing: 0 !important;
  border-radius: 22px !important;
  border-width: 1px !important;
  border-color: var(--weydom-ui-line) !important;
  padding: 22px 24px !important;
  box-shadow: 0 4px 20px rgb(25 67 48 / 4%) !important;
  overflow-wrap: anywhere !important;
  max-width: 100% !important;
}
html body #messages .assistant-row .bubble { width: min(980px, 100%) !important; background: var(--weydom-ui-surface) !important; color: var(--weydom-ui-ink) !important; }
html body #messages .speaker-label { font: 600 11px/1.5 var(--weydom-chat-font) !important; letter-spacing: .045em !important; margin: 0 8px 8px !important; }
html body #messages .bubble p { font-family: inherit !important; font-size: inherit !important; line-height: inherit !important; margin: 0 0 12px !important; }
html body #messages .bubble p:last-child { margin-bottom: 0 !important; }
html body #messages .bubble h1,
html body #messages .bubble h2,
html body #messages .bubble h3,
html body #messages .bubble h4 { font-family: inherit !important; font-weight: 650 !important; line-height: 1.45 !important; letter-spacing: -.015em !important; margin: 20px 0 10px !important; }
html body #messages .bubble h1 { font-size: 23px !important; }
html body #messages .bubble h2 { font-size: 21px !important; }
html body #messages .bubble h3 { font-size: 17px !important; }
html body #messages .bubble h4 { font-size: 16px !important; margin-top: 0 !important; }
html body #messages .bubble ul,
html body #messages .bubble ol { margin: 8px 0 14px !important; padding-left: 23px !important; }
html body #messages .bubble li { margin: 5px 0 !important; padding-left: 2px !important; line-height: 1.7 !important; }
html body #messages .bubble pre { overflow-x: auto; max-width: 100%; }
html body #messages .bubble code { font-family: ui-monospace, Consolas, monospace !important; }
html body #messages .weydom-evidence-view { font: inherit !important; }
html body #messages .weydom-evidence-review-note { font-size: 12px !important; line-height: 1.6 !important; color: var(--weydom-ui-muted); padding: 10px 12px; border-radius: 12px; background: var(--weydom-ui-soft); opacity: 1; }
html body #messages .weydom-evidence-columns { gap: 14px; align-items: stretch; }
html body #messages .weydom-evidence-card { border: 1px solid var(--weydom-ui-line); border-radius: 16px; padding: 16px; background: var(--weydom-ui-soft); }
html body #messages .weydom-evidence-card > ul:empty { display: none; }
html body #messages .weydom-evidence-card p { font-size: 14px !important; line-height: 1.7 !important; }
html body #messages .weydom-evidence-view > h3 { padding-top: 5px; }
html body #messages .weydom-evidence-passages details { padding: 12px 0; border-color: var(--weydom-ui-line); }
html body #messages .weydom-evidence-passages summary { font-size: 13px; line-height: 1.65; }
html body #messages .weydom-evidence-passages blockquote { font: 14px/1.75 var(--weydom-chat-font); border-radius: 0 12px 12px 0; background: var(--weydom-ui-soft); }
html body #messages .weydom-evidence-export { border: 1px solid var(--weydom-ui-line); border-radius: 12px; padding: 9px 13px; font: 600 12px/1.5 var(--weydom-chat-font); background: var(--weydom-ui-soft); }

/* One readable, aligned toolbar for Copy / Rewrite / Redo / Share / voice. */
html body #messages .message-actions {
  position: relative !important;
  inset: auto !important;
  display: flex !important;
  align-items: center !important;
  flex-wrap: wrap !important;
  gap: 6px !important;
  margin: 10px 4px 0 !important;
  padding: 0 !important;
  min-height: 36px !important;
  opacity: 1 !important;
  isolation: isolate;
}
html body #messages .message-actions > button {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  flex: 0 0 36px !important;
  width: 36px !important;
  min-width: 36px !important;
  height: 36px !important;
  min-height: 36px !important;
  box-sizing: border-box !important;
  margin: 0 !important;
  padding: 8px !important;
  border: 1px solid var(--weydom-ui-line) !important;
  border-radius: 12px !important;
  color: var(--weydom-ui-muted) !important;
  background: var(--weydom-ui-surface) !important;
  box-shadow: none !important;
  line-height: 1 !important;
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease, color .15s ease;
}
html body #messages .message-actions > button:hover { background: var(--weydom-ui-soft) !important; border-color: #9cb9aa !important; color: var(--weydom-ui-ink) !important; }
html body #messages .message-actions > button:focus-visible { outline: 2px solid #47876c !important; outline-offset: 3px; }
html body #messages .message-actions > button:disabled { opacity: .5; cursor: default; }
html body #messages .message-actions button svg { width: 18px !important; height: 18px !important; flex: 0 0 18px !important; margin: 0 !important; display: block !important; fill: none !important; stroke: currentColor !important; stroke-width: 1.7 !important; }
html body #messages .response-time-badge { align-self: center; font: 11px/1.4 var(--weydom-chat-font) !important; color: var(--weydom-ui-muted); margin-left: 6px; }

@media (max-width: 640px) {
  html body .main #messages { padding: 18px 14px 22px !important; gap: 22px !important; }
  html body #messages .assistant-row { padding-right: 0 !important; }
  html body #messages .user-row,
  html body #messages .debate-right { padding-left: 22px !important; }
  html body #messages .bubble { padding: 17px 18px !important; border-radius: 19px !important; font-size: 15px !important; }
  html body #messages .weydom-evidence-columns { grid-template-columns: minmax(0, 1fr) !important; }
  html body .main .composer-area { padding: 10px 12px max(10px, env(safe-area-inset-bottom)) !important; }
  html body .main .composer-area .composer-form { display: flex !important; flex-wrap: wrap !important; gap: 6px !important; padding: 8px 10px !important; border-radius: 20px !important; }
  html body .main .composer-area .composer-form textarea { order: -2; flex: 1 0 100% !important; width: 100% !important; min-height: 38px !important; padding: 8px !important; }
  html body .main .composer-area .integrated-select-wrapper { flex: 1 1 100px !important; width: auto !important; min-width: 80px !important; padding: 0 6px !important; border: 0 !important; }
  html body .main .composer-area .composer-meta span:first-child { display: none; }
  html body .main .composer-area .composer-meta { font-size: 10px !important; }
  html body .main .site-copyright { font-size: 9px !important; }
  html body .main #weydomEvidenceSettings .weydom-evidence-options { gap: 8px; }
}
@media (prefers-reduced-motion: reduce) {
  html body #messages .message-actions > button { transition: none; }
}

/* Retry is a text action, not a fixed-width toolbar icon. */
html body #messages .bubble .message-retry-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: auto;
  min-width: 88px;
  min-height: 38px;
  margin-top: 14px;
  padding: 9px 16px;
  border: 1px solid var(--weydom-ui-line);
  border-radius: 12px;
  background: var(--weydom-ui-soft);
  color: var(--weydom-ui-ink);
  font: 600 13px/1.4 var(--weydom-chat-font);
  white-space: nowrap;
  word-break: normal;
  overflow-wrap: normal;
  cursor: pointer;
}
html body #messages .bubble .message-retry-button:focus-visible { outline: 2px solid #47876c; outline-offset: 3px; }
