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

:root {
  --bg: #ffffff;
  --surface: #f5f5f4;
  --surface2: #eeecea;
  --border: #e2deda;
  --border-dark: #ccc8c2;
  --accent: #153d7b;
  --accent-light: #e8eef7;
  --text: #1c1917;
  --text-muted: #78716c;
  --text-dim: #b5b0aa;
  --user-bg: #153d7b;
  --user-text: #ffffff;
  --radius: 14px;
  --font: "IBM Plex Sans", sans-serif;
  --mono: "IBM Plex Mono", monospace;
  --danger: #ef4444;
  --danger-light: #fef2f2;
}

html,
body,
#root {
  height: 100%;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
}

#root {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
}

.header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  flex-shrink: 0;
}

.logo {
  width: 30px;
  height: 30px;
  background: #ffffff; /* intentional: logo SVG is black with transparent cutout — white background makes the arrow appear white-on-black. do NOT replace with var(--bg) or a theme variable */
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
}

.logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.header-title {
  font-size: 14px;
  font-weight: 500;
}
.header-sub {
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 1px;
}

.chat-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
}

.messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-height: 0;
}

.messages::-webkit-scrollbar {
  width: 3px;
}
.messages::-webkit-scrollbar-track {
  background: transparent;
}
.messages::-webkit-scrollbar-thumb {
  background: var(--border-dark);
  border-radius: 3px;
}

.msg-row {
  display: flex;
  flex-direction: column;
  width: 100%;
}
.msg-row.user {
  align-items: flex-end;
}
.msg-row.assistant {
  align-items: flex-start;
}

.bubble {
  padding: 9px 13px;
  border-radius: var(--radius);
  font-size: 13.5px;
  line-height: 1.6;
  max-width: min(78%, 480px);
  white-space: pre-wrap;
  word-break: break-word;
}

.msg-row.user .bubble {
  background: var(--user-bg);
  color: var(--user-text);
  border-bottom-right-radius: 4px;
}

.msg-row.assistant .bubble {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  border-bottom-left-radius: 4px;
}

.msg-row.assistant .bubble.streaming::after {
  content: "▋";
  display: inline;
  color: var(--accent);
  animation: blink 0.75s step-end infinite;
}

@keyframes blink {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0;
  }
}

.bubble.error {
  background: var(--danger-light);
  border-color: #fecaca !important;
  color: var(--danger);
}

.feedback-row {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 3px 2px 6px;
  opacity: 0;
  transition: opacity 0.15s;
  height: 26px;
}
.msg-row:hover .feedback-row,
.feedback-row.visible {
  opacity: 1;
}

.thumb-btn {
  background: none;
  border: 1px solid transparent;
  border-radius: 5px;
  padding: 2px 5px;
  font-size: 11px;
  cursor: pointer;
  transition: all 0.12s;
  color: var(--text-dim);
  line-height: 1;
}
.thumb-btn:hover {
  border-color: var(--border-dark);
  color: var(--text-muted);
}
.thumb-btn.active.up {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-light);
}
.thumb-btn.active.down {
  color: var(--danger);
  border-color: var(--danger);
  background: var(--danger-light);
}
.feedback-sent {
  font-size: 10px;
  color: #22c55e;
  margin-left: 2px;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
}

.modal {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px;
  width: min(340px, calc(100vw - 32px));
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
}

.modal h3 {
  font-size: 14px;
  font-weight: 500;
}

.modal textarea {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-family: var(--font);
  font-size: 13px;
  padding: 9px 11px;
  resize: none;
  outline: none;
  transition: border-color 0.15s;
  height: 80px;
}
.modal textarea:focus {
  border-color: var(--accent);
}
.modal textarea::placeholder {
  color: var(--text-dim);
}
.modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.btn-ghost {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 12px;
  font-family: var(--font);
  cursor: pointer;
  transition: all 0.12s;
}
.btn-ghost:hover {
  border-color: var(--border-dark);
  color: var(--text);
}

.btn-primary {
  background: var(--accent);
  border: none;
  color: #fff;
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 12px;
  font-family: var(--font);
  font-weight: 500;
  cursor: pointer;
  transition: opacity 0.12s;
}
.btn-primary:hover {
  opacity: 0.88;
}

.input-area {
  padding: 10px 12px 14px;
  border-top: 1px solid var(--border);
  background: var(--bg);
  flex-shrink: 0;
}

.input-wrap {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 10px;
  transition: border-color 0.15s;
}
.input-wrap:focus-within {
  border-color: var(--accent);
}

.input-wrap textarea {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  color: var(--text);
  font-family: var(--font);
  font-size: 13.5px;
  line-height: 1.5;
  resize: none;
  max-height: 120px;
  overflow-y: auto;
}
.input-wrap textarea::placeholder {
  color: var(--text-dim);
}

.send-btn {
  background: var(--accent);
  border: none;
  color: #fff;
  border-radius: 8px;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: opacity 0.12s;
  font-size: 13px;
}
.send-btn:disabled {
  opacity: 0.25;
  cursor: default;
}
.send-btn:not(:disabled):hover {
  opacity: 0.85;
}

.empty-state {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 6px;
  color: var(--text-dim);
  font-size: 13px;
  text-align: center;
}
.empty-icon {
  font-size: 26px;
  margin-bottom: 4px;
  opacity: 0.5;
}

/* ── Consent screen ─────────────────────────── */

.consent-screen {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  overflow-y: auto;
}

.consent-card {
  width: min(560px, 100%);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.08);
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 48px);
}

.consent-card-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.consent-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.consent-body a {
  color: var(--accent);
  text-decoration: none;
}
.consent-body a:hover {
  text-decoration: underline;
}

.consent-body h2 {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-top: 4px;
}

.consent-body p {
  font-size: 13px;
  line-height: 1.65;
  color: var(--text);
}

.consent-body::-webkit-scrollbar {
  width: 3px;
}
.consent-body::-webkit-scrollbar-track {
  background: transparent;
}
.consent-body::-webkit-scrollbar-thumb {
  background: var(--border-dark);
  border-radius: 3px;
}

.consent-footer {
  padding: 16px 20px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 14px;
  flex-shrink: 0;
}

.consent-checkbox {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--text-muted);
  cursor: pointer;
}

.consent-checkbox input[type="checkbox"] {
  margin-top: 2px;
  flex-shrink: 0;
  accent-color: var(--accent);
  width: 14px;
  height: 14px;
  cursor: pointer;
}

.consent-card--sm {
  max-height: none;
}

.consent-footer--row {
  flex-direction: row;
  justify-content: flex-end;
}

.consent-accept-btn {
  width: 100%;
  padding: 9px 16px;
  font-size: 13px;
}

.consent-footer--row .consent-accept-btn {
  width: auto;
}

.consent-accept-btn:disabled {
  opacity: 0.35;
  cursor: default;
}

.consent-note {
  font-size: 12px !important;
  color: var(--text-muted) !important;
  font-style: italic;
}

.consent-facts {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 6px 16px;
  font-size: 12.5px;
}

.consent-facts dt {
  color: var(--text-muted);
  font-weight: 500;
  white-space: nowrap;
}

.consent-facts dd {
  color: var(--text);
}

.consent-ack {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.5;
}

.consent-links {
  display: flex;
  gap: 16px;
  justify-content: center;
  padding-top: 4px;
  border-top: 1px solid var(--border);
}

.consent-links a {
  font-size: 11px;
  color: var(--text-dim);
  text-decoration: none;
}

.consent-links a:hover {
  color: var(--text-muted);
  text-decoration: underline;
}
