/* Thompson Method AI Chat — Single CSS file */

:root {
  /* Brand palette pulled from thethompsonmethod.com (Kajabi theme +
     MessageMind widget): soft pink primary, charcoal, mint accent. */
  --pink: #F77895;
  --pink-light: #FDEDF1;
  --pink-hover: #EF5F7F;
  --charcoal: #2C3E50;
  --white: #FFFFFF;
  --page-bg: var(--gray-50);
  --surface: #FFFFFF;
  --body-text: var(--gray-900);
  --gray-50: #F9FAFB;
  --gray-100: #F3F4F6;
  --gray-200: #E5E7EB;
  --gray-300: #D1D5DB;
  --gray-500: #6B7280;
  --gray-700: #374151;
  --gray-900: #111827;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.1), 0 1px 2px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --radius: 12px;
  --radius-sm: 8px;
}

/* ─── Embedded-in-app theme (My Milk Map earthy palette) ─────────────
   Activated only when the chat is opened inside the My Milk Map app
   (app.js sets <html class="embed-app"> from the #app= SSO handoff).
   Standalone (Kajabi / chat.thethompsonmethod.com) is untouched — pink.
   We remap the pink variables (which cascades to buttons, header, badge,
   links, focus rings, bubbles, disclaimer, etc.) plus the neutral
   surface/background so containers read as warm cream + stone. */
html.embed-app {
  --pink: #BC6C4E;        /* terracotta — primary accent / buttons */
  --pink-light: #ECE3D6;  /* pale stone tint — soft accent backgrounds */
  --pink-hover: #A65C41;  /* darker terracotta — button hover */
  --page-bg: #F6F1E9;     /* warm cream — page background */
  --surface: #FCFAF5;     /* near-cream card/container surface */
  --body-text: #3C463D;   /* deep forest — body text */
}

html.embed-app body {
  background: var(--page-bg);
  color: var(--body-text);
}

/* Containers/cards: warm cream surface instead of stark white */
html.embed-app .chat-container,
html.embed-app .chat-header,
html.embed-app .chat-input-bar,
html.embed-app .chat-legal-footer,
html.embed-app .card {
  background: var(--surface);
}

/* Assistant bubble + system/typing chrome → stone tones */
html.embed-app .message-assistant {
  background: #DCD9CB;          /* pale stone */
  color: var(--body-text);
}

html.embed-app .typing-dots {
  background: #DCD9CB;
}

/* Sign-out outline focus ring inherits --pink automatically.
   Input focus ring uses the terracotta tint. */
html.embed-app input:focus {
  box-shadow: 0 0 0 3px rgba(188, 108, 78, 0.15);
}

/* Embed keeps its quiet cream header — undo the standalone pink-bar
   treatment (white title/buttons) that ships in the base theme. */
html.embed-app .chat-header {
  border-bottom: 1px solid #DCD9CB;
}

html.embed-app .chat-header h1 {
  color: var(--pink);
}

html.embed-app .header-status {
  color: var(--body-text);
}

html.embed-app .chat-header .btn-outline {
  color: var(--pink);
  border-color: var(--pink);
}

html.embed-app .chat-header .btn-outline:hover:not(:disabled) {
  background: var(--pink-light);
}

html.embed-app .chat-header .badge-member {
  background: var(--pink-light);
  color: var(--pink);
}

html.embed-app .chat-header .badge-non-member {
  background: #DCD9CB;
  color: var(--body-text);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Karla', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  color: var(--gray-900);
  background: var(--gray-50);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ─── Utilities ──────────────────────────────────────────────────── */

.hidden { display: none !important; }

.error {
  color: #DC2626;
  font-size: 0.875rem;
  margin-top: 0.5rem;
}

.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.badge-member {
  background: var(--pink-light);
  color: var(--pink);
}

.badge-non-member {
  background: var(--gray-100);
  color: var(--gray-500);
}

.badge-handoff {
  background: #FEF3C7;
  color: #92400E;
}

.badge-pii {
  background: #FEE2E2;
  color: #991B1B;
}

.badge-reviewed {
  background: #DCFCE7;
  color: #166534;
}

/* QC / reviewer stamp row in the session detail header. The long
   "Reviewed by X on DATE" badge reads better un-uppercased. */
.detail-review {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 8px;
}

.detail-review .badge-reviewed {
  text-transform: none;
  letter-spacing: normal;
}

/* ─── Password Toggle ────────────────────────────────────────────── */

.input-with-toggle {
  position: relative;
  width: 100%;
}

.input-with-toggle input {
  padding-right: 44px;
}

.toggle-password {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  color: var(--gray-500);
  padding: 4px;
  display: flex;
  align-items: center;
}

.toggle-password:hover {
  color: var(--gray-700);
}

/* ─── Buttons ────────────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.9375rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--pink);
  color: var(--white);
}

.btn-primary:hover:not(:disabled) {
  background: var(--pink-hover);
}

.btn-secondary {
  background: var(--white);
  color: var(--gray-700);
  border: 1px solid var(--gray-300);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--gray-50);
}

.btn-outline {
  background: transparent;
  color: var(--pink);
  border: 1px solid var(--pink);
  font-size: 0.8125rem;
  padding: 6px 14px;
}

.btn-outline:hover:not(:disabled) {
  background: var(--pink-light);
}

.btn-group {
  display: flex;
  gap: 12px;
}

.btn-group .btn {
  flex: 1;
}

.btn-block {
  width: 100%;
  padding: 12px 20px;
  font-size: 1rem;
}

/* ─── Card ───────────────────────────────────────────────────────── */

.card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 32px;
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 440px;
}

/* ─── Forms ──────────────────────────────────────────────────────── */

input[type="text"],
input[type="email"],
input[type="password"] {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius-sm);
  font-size: 0.9375rem;
  outline: none;
  transition: border-color 0.15s;
  font-family: inherit;
}

input:focus {
  border-color: var(--pink);
  box-shadow: 0 0 0 3px rgba(247, 120, 149, 0.18);
}

form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* ─── Landing Page ───────────────────────────────────────────────── */

.landing {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.screen {
  display: none;
}

.screen.active {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
}

.logo {
  text-align: center;
  margin-bottom: 24px;
}

.logo h1 {
  font-size: 1.5rem;
  color: var(--pink);
  font-weight: 700;
}

.subtitle {
  color: var(--gray-500);
  font-size: 0.875rem;
  margin-top: 4px;
}

.description {
  text-align: center;
  color: var(--gray-500);
  margin-bottom: 20px;
  font-size: 0.9375rem;
}

.hint {
  text-align: center;
  color: var(--gray-500);
  font-size: 0.8125rem;
  margin-top: 16px;
  line-height: 1.5;
}

/* ─── Chat Page ──────────────────────────────────────────────────── */

.chat-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  /* iOS Safari: 100vh ignores the collapsing toolbar, hiding the input
     bar behind it. dvh tracks the real visible viewport. */
  height: 100dvh;
  max-width: 800px;
  margin: 0 auto;
  background: var(--white);
}

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  background: var(--pink);
  flex-shrink: 0;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.header-title {
  display: flex;
  flex-direction: column;
}

.chat-header h1 {
  font-size: 1.125rem;
  color: var(--white);
  font-weight: 700;
}

.header-status {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.9);
}

.header-status::before {
  content: '';
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #8CE2C8;
}

/* Header buttons sit on the pink bar → white outline treatment */
.chat-header .btn-outline {
  color: var(--white);
  border-color: rgba(255, 255, 255, 0.7);
}

.chat-header .btn-outline:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.15);
}

.chat-header .badge-member {
  background: rgba(255, 255, 255, 0.9);
  color: var(--pink);
}

.chat-header .badge-non-member {
  background: rgba(255, 255, 255, 0.25);
  color: var(--white);
}

/* Disclaimer */

.disclaimer {
  padding: 16px 20px;
  background: var(--pink-light);
  border-bottom: 1px solid var(--gray-200);
  flex-shrink: 0;
}

.disclaimer-content {
  font-size: 0.8125rem;
  color: var(--gray-700);
  line-height: 1.6;
}

.disclaimer-content p {
  margin-bottom: 8px;
}

.disclaimer-content p:last-child {
  margin-bottom: 0;
}

.disclaimer-content .btn {
  margin-top: 10px;
}

/* Messages */

.messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.message {
  max-width: 80%;
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 0.9375rem;
  line-height: 1.6;
  word-wrap: break-word;
}

.message a {
  color: var(--pink);
  text-decoration: underline;
}

.message-user {
  align-self: flex-end;
  background: var(--pink);
  color: var(--white);
  border-bottom-right-radius: 4px;
}

.message-user a {
  color: var(--white);
}

.message-assistant {
  align-self: flex-start;
  background: var(--gray-100);
  color: var(--gray-900);
  border-bottom-left-radius: 4px;
}

.message-system {
  align-self: center;
  background: var(--pink-light);
  color: var(--gray-700);
  font-size: 0.8125rem;
  text-align: center;
  max-width: 90%;
}

/* Formatted content inside assistant messages */

.message-assistant p {
  margin: 0 0 8px 0;
}

.message-assistant p:last-child {
  margin-bottom: 0;
}

.message-assistant ul,
.message-assistant ol {
  margin: 4px 0 8px 0;
  padding-left: 20px;
}

.message-assistant ul:last-child,
.message-assistant ol:last-child {
  margin-bottom: 0;
}

.message-assistant li {
  margin-bottom: 4px;
}

.message-assistant strong {
  font-weight: 600;
}

/* Typing indicator */

.typing {
  padding: 8px 20px;
  flex-shrink: 0;
}

.typing-dots {
  display: inline-flex;
  gap: 4px;
  padding: 10px 16px;
  background: var(--gray-100);
  border-radius: var(--radius);
}

.typing-dots span {
  width: 8px;
  height: 8px;
  background: var(--gray-300);
  border-radius: 50%;
  animation: typing 1.4s infinite;
}

.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-4px); opacity: 1; }
}

/* Input bar */

.chat-input-bar {
  padding: 12px 20px;
  border-top: 1px solid var(--gray-200);
  background: var(--white);
  flex-shrink: 0;
}

.chat-input-bar form {
  flex-direction: row;
  gap: 8px;
}

.chat-input-bar input {
  flex: 1;
  border-radius: 999px;
  padding: 10px 18px;
}

.btn-send {
  flex-shrink: 0;
  padding: 10px 24px;
  border-radius: 999px;
}

/* ─── History Page ───────────────────────────────────────────────── */

.history-container {
  max-width: 800px;
  margin: 0 auto;
  padding: 24px;
}

.history-header {
  text-align: center;
  margin-bottom: 24px;
}

.history-header h1 {
  color: var(--pink);
  font-size: 1.5rem;
}

.history-notice {
  background: #FEF3C7;
  border: 1px solid #FCD34D;
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  margin-bottom: 20px;
  font-size: 0.8125rem;
  color: #92400E;
}

.history-results {
  margin-top: 24px;
}

.session-card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 16px;
  overflow: hidden;
}

.session-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  cursor: pointer;
  transition: background 0.15s;
  gap: 8px;
  flex-wrap: wrap;
}

.session-card-header:hover {
  background: var(--gray-50);
}

.session-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 0.875rem;
  color: var(--gray-500);
}

.session-summary {
  width: 100%;
  font-size: 0.8125rem;
  color: var(--gray-500);
  line-height: 1.4;
  margin-top: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
}

.session-summary.expanded {
  white-space: normal;
  text-overflow: unset;
}

.session-messages {
  display: none;
  border-top: 1px solid var(--gray-200);
  padding: 16px 20px;
}

.session-messages.open {
  display: block;
}

.session-message {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  font-size: 0.875rem;
}

.session-message:last-child {
  margin-bottom: 0;
}

.session-message-user {
  background: var(--pink-light);
  border-left: 3px solid var(--pink);
}

.session-message-assistant {
  background: var(--gray-50);
  border-left: 3px solid var(--gray-300);
}

.session-message-system {
  background: #FEF3C7;
  border-left: 3px solid #FCD34D;
}

.session-message .role {
  font-weight: 600;
  text-transform: capitalize;
  font-size: 0.75rem;
  margin-bottom: 4px;
}

.session-message .role-user { color: var(--pink); }
.session-message .role-assistant { color: var(--gray-700); }
.session-message .role-system { color: #92400E; }

.session-message .content {
  margin-top: 4px;
  line-height: 1.6;
}

.session-message-user .content {
  white-space: pre-wrap;
}

/* Formatted content inside history assistant messages */

.session-message-assistant .content p {
  margin: 0 0 6px 0;
}

.session-message-assistant .content p:last-child {
  margin-bottom: 0;
}

.session-message-assistant .content ul,
.session-message-assistant .content ol {
  margin: 4px 0 6px 0;
  padding-left: 20px;
}

.session-message-assistant .content li {
  margin-bottom: 3px;
}

.session-message .timestamp {
  font-size: 0.6875rem;
  color: var(--gray-300);
  margin-top: 4px;
}

.btn-copy-link {
  flex-shrink: 0;
  font-size: 0.75rem;
  padding: 4px 10px;
}

/* ─── History Toolbar ───────────────────────────────────────────── */

.history-toolbar {
  margin-bottom: 16px;
}

.toolbar-row {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.toolbar-search {
  flex: 1;
  min-width: 200px;
}

.toolbar-select {
  padding: 10px 14px;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  background: var(--white);
  cursor: pointer;
}

.label-filters {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 10px;
}

.label-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 500;
  cursor: pointer;
  border: 2px solid transparent;
  transition: all 0.15s;
  color: var(--white);
}

.label-chip.active {
  border-color: var(--gray-900);
  box-shadow: 0 0 0 1px var(--white), 0 0 0 3px var(--gray-900);
}

/* Session label badges */

.session-labels {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.session-label-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--white);
}

/* Label picker dropdown */

.label-picker {
  position: relative;
  display: inline-block;
}

.label-picker-btn {
  background: var(--gray-100);
  border: 1px dashed var(--gray-300);
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 0.6875rem;
  cursor: pointer;
  color: var(--gray-500);
}

.label-picker-btn:hover {
  background: var(--gray-200);
}

.label-picker-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  z-index: 50;
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  padding: 8px 0;
  min-width: 180px;
  margin-top: 4px;
}

.label-picker-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  cursor: pointer;
  font-size: 0.8125rem;
  transition: background 0.1s;
}

.label-picker-item:hover {
  background: var(--gray-50);
}

.label-picker-item .color-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
}

.label-picker-item .check {
  margin-left: auto;
  color: var(--pink);
  font-weight: 700;
}

/* ─── Modal ─────────────────────────────────────────────────────── */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 24px;
}

.modal-content {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 480px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--gray-200);
}

.modal-header h3 {
  font-size: 1.125rem;
  font-weight: 600;
}

.btn-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--gray-500);
  padding: 0 4px;
  line-height: 1;
}

.btn-close:hover {
  color: var(--gray-900);
}

.label-list {
  flex: 1;
  overflow-y: auto;
  padding: 12px 20px;
}

.label-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 0;
  border-bottom: 1px solid var(--gray-100);
}

.label-row:last-child {
  border-bottom: none;
}

.label-row .color-swatch {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  cursor: pointer;
  border: 1px solid var(--gray-200);
  flex-shrink: 0;
}

.label-row .label-name-input {
  flex: 1;
  border: 1px solid transparent;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 0.875rem;
}

.label-row .label-name-input:focus {
  border-color: var(--pink);
}

.label-row .label-archived {
  opacity: 0.4;
  text-decoration: line-through;
}

.label-row .btn-archive {
  background: none;
  border: none;
  font-size: 0.75rem;
  cursor: pointer;
  color: var(--gray-500);
  padding: 2px 6px;
}

.label-row .btn-archive:hover {
  color: var(--pink);
}

.modal-footer {
  display: flex;
  gap: 8px;
  padding: 12px 20px;
  border-top: 1px solid var(--gray-200);
  align-items: center;
}

.modal-footer input[type="text"] {
  flex: 1;
}

.modal-footer input[type="color"] {
  width: 36px;
  height: 36px;
  padding: 2px;
  border: 1px solid var(--gray-300);
  border-radius: 6px;
  cursor: pointer;
}

/* ─── Usage Page ─────────────────────────────────────────────────── */

.usage-status-card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 20px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}

.usage-status-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 0.9375rem;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}

.status-dot.green { background: #22C55E; }
.status-dot.yellow { background: #EAB308; }
.status-dot.red { background: #EF4444; }

.usage-reset {
  font-size: 0.8125rem;
  color: var(--gray-500);
}

.usage-card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 16px;
}

.usage-card h3 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 12px;
  color: var(--gray-700);
}

.usage-stat-row {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}

.usage-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
  min-width: 80px;
}

.usage-stat-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--pink);
}

.usage-stat-label {
  font-size: 0.75rem;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: 2px;
}

.usage-bar-container {
  background: var(--gray-100);
  border-radius: 999px;
  height: 12px;
  margin-top: 16px;
  overflow: hidden;
}

.usage-bar {
  height: 100%;
  border-radius: 999px;
  background: var(--pink);
  transition: width 0.5s ease;
  width: 0%;
}

.usage-bar.warn { background: #EAB308; }
.usage-bar.danger { background: #EF4444; }

.usage-bar-label {
  font-size: 0.75rem;
  color: var(--gray-500);
  margin-top: 6px;
  text-align: center;
}

.usage-reset-detail {
  font-size: 0.8125rem;
  color: var(--gray-700);
  text-align: center;
  margin-top: 10px;
  padding: 8px 12px;
  background: var(--gray-50);
  border-radius: var(--radius-sm);
}

.usage-days {
  display: flex;
  gap: 4px;
  align-items: flex-end;
  height: 80px;
}

.usage-day {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.usage-day-bar {
  width: 100%;
  background: var(--pink);
  border-radius: 4px 4px 0 0;
  min-height: 2px;
  transition: height 0.3s;
}

.usage-day-label {
  font-size: 0.625rem;
  color: var(--gray-500);
}

.usage-model-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid var(--gray-100);
  font-size: 0.875rem;
}

.usage-model-row:last-child {
  border-bottom: none;
}

.usage-model-name {
  font-weight: 500;
  color: var(--gray-700);
  word-break: break-all;
}

.usage-model-stats {
  display: flex;
  gap: 16px;
  color: var(--gray-500);
  font-size: 0.8125rem;
  flex-shrink: 0;
}

/* ─── Replay Comparison ──────────────────────────────────────────── */

.btn-replay {
  flex-shrink: 0;
  font-size: 0.75rem;
  padding: 4px 10px;
  background: transparent;
  color: #7C3AED;
  border: 1px solid #7C3AED;
}

.btn-replay:hover:not(:disabled) {
  background: #F5F3FF;
}

.btn-replay:disabled {
  opacity: 0.6;
  cursor: wait;
}

.replay-panel {
  border-top: 2px solid #7C3AED;
  padding: 16px 20px;
  background: #FAFAFE;
}

.replay-panel-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.replay-panel-header h4 {
  font-size: 0.9375rem;
  font-weight: 600;
  color: #7C3AED;
  margin: 0;
}

.replay-model-badge {
  background: #F5F3FF;
  color: #7C3AED;
  font-size: 0.6875rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid #DDD6FE;
}

.replay-progress {
  font-size: 0.8125rem;
  color: var(--gray-500);
  margin-bottom: 12px;
  padding: 8px 12px;
  background: var(--gray-100);
  border-radius: var(--radius-sm);
}

.replay-progress.done {
  background: #ECFDF5;
  color: #065F46;
}

.replay-progress.error {
  background: #FEF2F2;
  color: #991B1B;
}

.replay-comparison {
  margin-bottom: 16px;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.replay-comparison:last-child {
  margin-bottom: 0;
}

.replay-user {
  padding: 10px 14px;
  background: var(--pink-light);
  border-bottom: 1px solid var(--gray-200);
  font-size: 0.875rem;
  line-height: 1.5;
}

.replay-label {
  font-weight: 600;
  color: var(--pink);
  font-size: 0.75rem;
  text-transform: uppercase;
}

.replay-rag-info {
  padding: 4px 14px;
  background: var(--gray-50);
  border-bottom: 1px solid var(--gray-200);
  font-size: 0.6875rem;
  color: var(--gray-500);
}

.replay-side-by-side {
  display: grid;
  grid-template-columns: 1fr 1fr;
}

.replay-col {
  padding: 10px 14px;
  font-size: 0.8125rem;
  line-height: 1.6;
  min-width: 0;
  word-wrap: break-word;
}

.replay-col-original {
  background: var(--white);
  border-right: 1px solid var(--gray-200);
}

.replay-col-replay {
  background: #FEFCE8;
}

.replay-col-header {
  font-weight: 600;
  font-size: 0.6875rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 6px;
  color: var(--gray-500);
}

.replay-col-original .replay-col-header {
  color: var(--gray-700);
}

.replay-col-replay .replay-col-header {
  color: #7C3AED;
}

.replay-col p { margin: 0 0 6px 0; }
.replay-col p:last-child { margin-bottom: 0; }
.replay-col ul, .replay-col ol { margin: 4px 0 6px 0; padding-left: 18px; }
.replay-col li { margin-bottom: 3px; }

/* ─── Legal Pages (Privacy Policy / Terms of Use) ────────────────── */

.legal-page {
  max-width: 760px;
  margin: 0 auto;
  padding: 24px 24px 64px;
}

.legal-header {
  text-align: center;
  padding: 24px 0 8px;
}

.legal-header h1 {
  color: var(--pink);
  font-size: 1.75rem;
  font-weight: 700;
}

.legal-header .legal-subtitle {
  color: var(--gray-700);
  font-size: 1rem;
  margin-top: 4px;
}

.legal-header .legal-dates {
  color: var(--gray-500);
  font-size: 0.8125rem;
  margin-top: 8px;
}

.legal-callout {
  background: var(--pink-light);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-sm);
  padding: 16px 20px;
  margin: 24px 0;
  font-size: 0.9375rem;
  font-style: italic;
  color: var(--gray-700);
  line-height: 1.6;
}

.legal-content h2 {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--gray-900);
  margin: 32px 0 12px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--gray-200);
}

.legal-content h3 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--gray-900);
  margin: 20px 0 8px;
}

.legal-content p {
  margin: 0 0 12px;
  color: var(--gray-700);
}

.legal-content ul {
  margin: 0 0 12px;
  padding-left: 22px;
  color: var(--gray-700);
}

.legal-content li {
  margin-bottom: 6px;
}

.legal-content a {
  color: var(--pink);
  text-decoration: underline;
}

.legal-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 12px 0 16px;
  font-size: 0.875rem;
}

.legal-content th,
.legal-content td {
  border: 1px solid var(--gray-200);
  padding: 8px 12px;
  text-align: left;
  vertical-align: top;
  color: var(--gray-700);
}

.legal-content th {
  background: var(--gray-50);
  font-weight: 600;
  color: var(--gray-900);
}

.legal-footer {
  margin-top: 40px;
  padding-top: 16px;
  border-top: 1px solid var(--gray-200);
  font-size: 0.8125rem;
  color: var(--gray-500);
  text-align: center;
}

.legal-footer a {
  color: var(--pink);
  text-decoration: none;
  font-weight: 500;
}

.legal-footer a:hover {
  text-decoration: underline;
}

.legal-back {
  display: inline-block;
  margin-top: 16px;
  font-size: 0.875rem;
  color: var(--pink);
  text-decoration: none;
}

.legal-back:hover {
  text-decoration: underline;
}

/* Legal links shown under the landing email form and in the chat footer */

.legal-links {
  text-align: center;
  font-size: 0.8125rem;
  color: var(--gray-500);
  line-height: 1.5;
  margin-top: 16px;
}

.legal-links a {
  color: var(--pink);
  text-decoration: none;
}

.legal-links a:hover {
  text-decoration: underline;
}

.chat-legal-footer {
  flex-shrink: 0;
  padding: 8px 20px;
  padding-bottom: calc(8px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--gray-200);
  background: var(--white);
  text-align: center;
  font-size: 0.75rem;
  color: var(--gray-500);
}

.chat-legal-footer a {
  color: var(--gray-500);
  text-decoration: none;
}

.chat-legal-footer a:hover {
  color: var(--pink);
  text-decoration: underline;
}

/* Legal modal — Terms/Privacy shown in-page so chat state is preserved */

.legal-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(17, 24, 39, 0.5);
}

.legal-modal[hidden] {
  display: none;
}

.legal-modal-dialog {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 720px;
  max-height: 90vh;
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.legal-modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 1;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 50%;
  background: var(--gray-100);
  color: var(--gray-700);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
}

.legal-modal-close:hover {
  background: var(--gray-200);
}

.legal-modal-scroll {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.legal-modal-loading {
  padding: 48px 24px;
  text-align: center;
  color: var(--gray-500);
}

/* Contact-the-team consent modal (reuses .legal-modal overlay) */
.help-dialog {
  max-width: 460px;
  padding: 32px 28px 28px;
  gap: 16px;
}

.help-dialog h2 {
  font-size: 1.125rem;
  color: var(--gray-900);
}

.help-dialog p {
  color: var(--gray-700);
  font-size: 0.9375rem;
  line-height: 1.5;
}

.help-consent {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 0.875rem;
  color: var(--gray-800);
  line-height: 1.45;
  cursor: pointer;
}

.help-consent input {
  margin-top: 3px;
  flex-shrink: 0;
}

.help-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.help-status {
  font-size: 0.875rem;
  color: var(--gray-700);
}

.help-status.hidden,
.help-consent.hidden,
.help-actions.hidden {
  display: none;
}

/* Neutralize the standalone-page layout when embedded in the modal */
.legal-modal .legal-page {
  max-width: none;
  margin: 0;
  padding: 32px 32px 40px;
}

.legal-modal .legal-header {
  padding-top: 8px;
}

/* ─── Responsive ─────────────────────────────────────────────────── */

@media (max-width: 640px) {
  .card {
    padding: 24px;
    margin: 0 8px;
  }

  .btn-group {
    flex-direction: column;
  }

  .message {
    max-width: 90%;
  }

  /* Two clean rows: title + badge, then buttons right-aligned.
     Prevents the title wrapping into the badge / stacked buttons. */
  .chat-header {
    flex-wrap: wrap;
    row-gap: 8px;
    padding: 10px 14px;
  }

  .header-left {
    flex: 1 1 100%;
    min-width: 0;
  }

  .chat-header h1 {
    font-size: 1rem;
    white-space: nowrap;
  }

  .header-right {
    margin-left: auto;
    display: flex;
    gap: 8px;
  }

  .header-right .btn {
    font-size: 0.75rem;
    padding: 4px 10px;
  }

  .session-card-header {
    padding: 12px 16px;
  }

  .replay-side-by-side {
    grid-template-columns: 1fr;
  }

  .replay-col-original {
    border-right: none;
    border-bottom: 1px solid var(--gray-200);
  }

  .legal-modal {
    padding: 0;
  }

  .legal-modal-dialog {
    max-width: none;
    max-height: 100vh;
    height: 100%;
    border-radius: 0;
  }

  .legal-modal .legal-page {
    padding: 24px 20px 32px;
  }
}
