/* Veraya — calm, premium, sovereignty-focused design */

/* Tokens come from veraya-tokens.css (HEW-65); this file keeps structural styles. */

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

html { font-size: 16px; -webkit-font-smoothing: antialiased; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

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

/* Layout */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 260px;
  background: var(--bg-card);
  border-right: 1px solid var(--border);
  padding: 2rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 2rem;
  position: fixed;
  height: 100vh;
  overflow-y: auto;
}

.sidebar-brand { display: inline-flex; align-items: center; gap: var(--veraya-space-1, 8px); font-family: var(--font-display); font-size: 1.25rem; font-weight: var(--weight-heading, 600); letter-spacing: -0.01em; color: var(--text); text-decoration: none; }
.sidebar-brand:hover { text-decoration: none; }
.sidebar-brand-mark { width: 24px; height: 24px; display: block; flex-shrink: 0; }

.sidebar-nav { display: flex; flex-direction: column; gap: 0.25rem; }

.sidebar-nav a {
  display: block;
  padding: 0.6rem 0.75rem;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 0.9rem;
  transition: all 0.15s;
}

.sidebar-nav a:hover, .sidebar-nav a.active {
  background: var(--accent-light);
  color: var(--accent);
  text-decoration: none;
}

.main-content {
  flex: 1;
  margin-left: 260px;
  padding: 2.5rem 3rem;
  max-width: 1100px;
}

.page-header { margin-bottom: 2rem; }

.page-header h1 { font-family: var(--font-display); font-size: 1.75rem; font-weight: var(--weight-heading); letter-spacing: -0.01em; margin-bottom: 0.5rem; }

.page-header p { color: var(--text-muted); font-size: 1rem; max-width: 600px; }

/* Cards */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
}

.stat-card .label { font-size: 0.8rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; }
.stat-card .value { font-size: 2rem; font-weight: 600; margin-top: 0.25rem; color: var(--text); }

/* Flow diagram */
.flow-diagram {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  padding: 1.5rem;
  background: var(--bg-subtle);
  border-radius: var(--radius);
  margin: 2rem 0;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.flow-step {
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: 0.5rem 1rem;
  border-radius: var(--radius-sm);
  white-space: nowrap;
}

.flow-arrow { color: var(--text-soft); }

/* Film cards */
.film-list { display: flex; flex-direction: column; gap: 1rem; }

.film-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 1rem;
  transition: border-color 0.15s;
}

.film-card:hover { border-color: var(--border-strong); }

.film-title { font-size: 1.15rem; font-weight: 600; margin-bottom: 0.25rem; }

.film-meta { font-size: 0.85rem; color: var(--text-muted); display: flex; flex-wrap: wrap; gap: 1rem; margin-top: 0.5rem; }

.badge {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 500;
}

.badge-strong { background: var(--accent-light); color: var(--accent); }
.badge-moderate { background: var(--bg-subtle); color: var(--text-muted); }
.badge-private { background: var(--danger-bg); color: var(--danger); }
.badge-shareable { background: var(--accent-light); color: var(--success); }
.badge-revoked { background: var(--danger-bg); color: var(--danger); }
.badge-active { background: var(--accent-light); color: var(--success); }
.badge-denied { background: var(--danger-bg); color: var(--danger); }

.film-actions { display: flex; flex-direction: column; gap: 0.5rem; align-items: flex-end; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 1.1rem;
  border-radius: var(--radius-pill);
  font-size: 0.875rem;
  font-weight: var(--weight-heading);
  border: none;
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
}

.btn-primary { background: var(--accent); color: var(--text-on-accent); }
.btn-primary:hover { background: var(--accent-hover); transform: translateY(-0.5px); }

.btn-secondary {
  background: var(--bg-subtle);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--bg-hover); border-color: var(--border-strong); }

.btn-ghost { background: transparent; color: var(--text-muted); }
.btn-ghost:hover { background: var(--bg-subtle); color: var(--text); }

.btn-danger { background: var(--danger-solid); color: var(--text); border: 1px solid transparent; }
.btn-danger:hover { background: var(--danger-solid-hover); }

.btn-sm { padding: 0.35rem 0.75rem; font-size: 0.8rem; }

/* Tables */
.data-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.data-table th { text-align: left; padding: 0.75rem 1rem; border-bottom: 1px solid var(--border); color: var(--text-muted); font-weight: 500; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.04em; }
.data-table td { padding: 0.75rem 1rem; border-bottom: 1px solid var(--border); }

/* Forms */
.form-group { margin-bottom: 1.25rem; }
.form-group label { display: block; font-size: 0.85rem; font-weight: 500; margin-bottom: 0.4rem; color: var(--text); }
.form-group input, .form-group select, .form-group textarea {
  width: 100%;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  color: var(--text);
  font-family: inherit;
  font-size: 0.9rem;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
}

.checkbox-group { display: flex; flex-direction: column; gap: 0.5rem; }
.checkbox-group label { display: flex; align-items: center; gap: 0.5rem; font-weight: 400; cursor: pointer; }

/* Modal / Panel */
.panel-overlay {
  position: fixed;
  inset: 0;
  background: var(--scrim);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 2rem;
}

.panel-overlay.open { display: flex; }

.panel {
  background: var(--bg-card);
  border-radius: var(--radius);
  max-width: 640px;
  width: 100%;
  max-height: 80vh;
  overflow-y: auto;
  padding: 2rem;
  box-shadow: var(--shadow-panel);
}

.panel h2 { font-family: var(--font-display); font-weight: var(--weight-heading); font-size: 1.4rem; margin-bottom: 1rem; }

.provenance-item {
  padding: 1rem;
  background: var(--bg-subtle);
  border-radius: var(--radius-sm);
  margin-bottom: 0.75rem;
  font-size: 0.85rem;
}

.provenance-item .excerpt { font-style: italic; color: var(--text); margin: 0.5rem 0; }
.provenance-item .source-meta { color: var(--text-muted); font-size: 0.8rem; }

/* JSON preview */
.json-preview {
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1rem;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  overflow-x: auto;
  white-space: pre-wrap;
  color: var(--text);
}

/* Summary box */
.summary-box {
  background: var(--accent-light);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin: 1.5rem 0;
}

.summary-box.cannot-see {
  background: var(--bg-subtle);
}

.summary-box h3 { font-size: 0.9rem; margin-bottom: 0.5rem; }
.summary-box p { font-size: 0.85rem; color: var(--text-muted); }

/* Theme toggle */
.theme-toggle {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 50;
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 3rem;
  color: var(--text-muted);
}

.empty-state p { margin-bottom: 1rem; }

/* Section */
.section { margin-bottom: 2.5rem; }
.section h2 { font-size: 1.1rem; font-weight: 600; margin-bottom: 1rem; color: var(--text); }

.toolbar { display: flex; gap: 0.75rem; margin-bottom: 1.5rem; flex-wrap: wrap; }

/* P1 — automation & principles */
.automation-note {
  font-size: 0.9rem;
  color: var(--text-muted);
  font-style: italic;
  padding: 0.75rem 1rem;
  background: var(--accent-light);
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--accent);
}

.automation-badge {
  display: inline-block;
  font-size: 0.7rem;
  padding: 0.15rem 0.5rem;
  margin-left: 0.5rem;
  background: var(--accent-light);
  color: var(--accent);
  border-radius: 4px;
}

.role-badge {
  display: inline-block;
  font-size: 0.75rem;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  text-transform: capitalize;
}
.role-user { background: var(--accent-light); color: var(--accent); }
.role-assistant { background: var(--bg-subtle); color: var(--text-muted); }

.principle-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.75rem;
  margin-bottom: 1.25rem;
  box-shadow: var(--shadow);
}

.principle-statement {
  font-family: var(--font-display);
  font-size: 1.25rem;
  line-height: 1.5;
  margin-bottom: 1rem;
  color: var(--text);
  border: none;
  padding: 0;
}

.principle-meta, .inclusion-reason {
  font-size: 0.85rem;
  color: var(--text-muted);
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  margin-bottom: 0.5rem;
}

.inclusion-reason { margin-top: 0.75rem; }

@media (max-width: 768px) {
  .sidebar { display: none; }
  .main-content { margin-left: 0; padding: 1.5rem; }
  .main-content-wide { max-width: none; }
  .chat-main { padding: 1rem; }
  .trust-actions { grid-template-columns: 1fr; }
  .connection-grid { grid-template-columns: 1fr; }
}

/* === Veraya Shell === */

.sidebar-tagline {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-style: italic;
  margin-top: -1rem;
}

.main-content-wide { max-width: 900px; }

/* Chat */
.chat-page .main-content { max-width: none; padding: 0; display: flex; flex-direction: column; height: 100vh; }
.chat-main { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.chat-header {
  display: flex; justify-content: space-between; align-items: flex-start;
  padding: 1.5rem 2rem; border-bottom: 1px solid var(--border);
}
.chat-header h1 { font-family: var(--font-display); font-size: 1.25rem; font-weight: var(--weight-heading); }
.chat-subtitle { font-size: 0.85rem; color: var(--text-muted); margin-top: 0.25rem; }
.chat-messages {
  flex: 1; overflow-y: auto; padding: 1.5rem 2rem;
  display: flex; flex-direction: column; gap: 1rem;
}
.chat-bubble { position: relative; max-width: 680px; padding: 1rem 1.25rem 2rem; border-radius: var(--radius-lg); font-size: var(--veraya-text-chat, 16px); }
.chat-bubble-user { align-self: flex-end; background: var(--accent-light); }
.chat-bubble-assistant { align-self: flex-start; background: var(--bg-card); border: 1px solid var(--border); }
.chat-bubble-meta {
  display: flex; align-items: baseline; justify-content: space-between; gap: 0.75rem;
  margin-bottom: 0.35rem;
}
.chat-role { font-size: 0.75rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; }
.chat-time { font-size: 0.72rem; color: var(--text-soft); white-space: nowrap; }
.chat-text { line-height: 1.55; }
.chat-tool-note {
  margin: 0.65rem 0 0;
  font-size: 0.75rem;
  letter-spacing: 0.02em;
  color: var(--text-muted);
}
.chat-generated-image {
  display: block;
  max-width: 100%;
  margin-top: 0.75rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg);
}
.chat-sources {
  margin: 0.75rem 0 0;
  padding-left: 1.15rem;
  font-size: 0.8rem;
  line-height: 1.4;
}
.chat-sources a { color: var(--text-muted); text-decoration: underline; text-underline-offset: 2px; }
.chat-markdown { white-space: normal; word-break: break-word; }
.chat-markdown .md-content { text-align: left; }
.chat-markdown .md-p { margin: 0; line-height: 1.55; }
.chat-markdown .md-block-spaced { margin-top: 0.5rem; }
.chat-markdown .md-h { margin: 0; line-height: 1.35; font-weight: 600; }
.chat-markdown .md-h1, .chat-markdown .md-h2 { font-size: 1rem; }
.chat-markdown .md-h3, .chat-markdown .md-h4 { font-size: 0.95rem; }
.chat-markdown .md-h5, .chat-markdown .md-h6 { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.04em; }
.chat-markdown .md-ul, .chat-markdown .md-ol { margin: 0.35rem 0 0; padding-left: 1.25rem; }
.chat-markdown .md-ul li, .chat-markdown .md-ol li { margin: 0.2rem 0; }
.chat-markdown .md-bq { margin: 0.35rem 0 0; padding-left: 0.75rem; border-left: 2px solid var(--border); font-style: italic; color: var(--text-muted); }
.chat-markdown .md-bq-line { margin: 0; }
.chat-markdown .md-bq-line-spaced { margin-top: 0.25rem; }
.chat-markdown .md-pre { margin: 0.35rem 0 0; padding: 0.65rem 0.75rem; border-radius: var(--radius-sm); overflow-x: auto; font-family: var(--font-mono); font-size: 0.8rem; line-height: 1.45; }
.chat-bubble-assistant .chat-markdown .md-pre { background: var(--bg-subtle); }
.chat-bubble-user .chat-markdown .md-pre { background: var(--bg-subtle); }
.chat-markdown .md-inline-code { padding: 0.1rem 0.3rem; border-radius: 0.25rem; font-family: var(--font-mono); font-size: 0.88em; }
.chat-bubble-assistant .chat-markdown .md-inline-code { background: var(--bg-subtle); }
.chat-bubble-user .chat-markdown .md-inline-code { background: var(--bg-subtle); }
.chat-markdown .md-link { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }
.chat-markdown .md-link:hover { opacity: 0.85; }
.chat-copy-btn {
  position: absolute; right: 0.5rem; bottom: 0.45rem;
  display: inline-flex; align-items: center; justify-content: center;
  width: 1.5rem; height: 1.5rem; padding: 0; border: none; border-radius: 0.25rem;
  background: transparent; color: var(--text-soft); cursor: pointer;
  opacity: 0.65; transition: opacity 0.15s, background 0.15s, color 0.15s;
}
.chat-copy-btn:hover { opacity: 1; background: var(--accent-light); color: var(--text-muted); }
.chat-bubble-user .chat-copy-btn:hover { background: var(--veraya-fill-quiet-2); color: var(--text); }
.chat-copy-btn svg { width: 0.875rem; height: 0.875rem; display: block; }
.chat-copy-check { display: none; }
.chat-copy-btn.copied { opacity: 1; color: var(--accent); }
.chat-copy-btn.copied .chat-copy-icon:not(.chat-copy-check) { display: none; }
.chat-copy-btn.copied .chat-copy-check { display: block; }
.chat-composer {
  display: flex; align-items: flex-end; gap: 0.75rem;
  padding: 1rem 2rem 0.5rem; border-top: 1px solid var(--border); background: var(--bg-card);
}
.chat-composer-field {
  flex: 1; min-width: 0; display: flex; flex-direction: column;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--bg); overflow: hidden;
}
.chat-composer-field:focus-within {
  border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent);
}
.chat-composer-toolbar-row {
  display: flex; align-items: center; justify-content: space-between; gap: 0.5rem;
  border-bottom: 1px solid var(--border); background: var(--bg-subtle);
}
.chat-markdown-toolbar {
  display: flex; flex-wrap: wrap; gap: 0.125rem; padding: 0.25rem 0.375rem; flex: 1; min-width: 0;
}
.chat-markdown-toolbar[hidden] { display: none; }
.chat-markdown-toolbar md-bold,
.chat-markdown-toolbar md-italic,
.chat-markdown-toolbar md-link,
.chat-markdown-toolbar md-code,
.chat-markdown-toolbar md-unordered-list,
.chat-markdown-toolbar md-ordered-list,
.chat-markdown-toolbar md-quote {
  display: inline-flex; align-items: center; justify-content: center;
  width: 1.75rem; height: 1.75rem; border: 0; border-radius: 0.375rem;
  background: transparent; color: var(--text-muted); cursor: pointer; padding: 0;
}
.chat-markdown-toolbar md-bold:hover,
.chat-markdown-toolbar md-italic:hover,
.chat-markdown-toolbar md-link:hover,
.chat-markdown-toolbar md-code:hover,
.chat-markdown-toolbar md-unordered-list:hover,
.chat-markdown-toolbar md-ordered-list:hover,
.chat-markdown-toolbar md-quote:hover {
  background: var(--bg-card); color: var(--text);
}
.chat-markdown-toolbar svg { width: 0.875rem; height: 0.875rem; }
.chat-preview-btn {
  flex-shrink: 0; margin-right: 0.5rem; border: 0; border-radius: 0.25rem;
  padding: 0.25rem 0.5rem; font-size: 0.7rem; font-weight: 600;
  color: var(--text-muted); background: transparent; cursor: pointer;
}
.chat-preview-btn:hover:not(:disabled) { background: var(--bg-card); color: var(--text); }
.chat-preview-btn.active { background: var(--accent-light); color: var(--accent); }
.chat-preview-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.chat-composer textarea {
  width: 100%; resize: none; padding: 0.65rem 0.85rem; border: 0;
  font-family: var(--font); font-size: 0.95rem; background: transparent;
  color: var(--text); min-height: 5.5rem; line-height: 1.55;
}
.chat-composer textarea:focus { outline: none; }
.chat-composer textarea[hidden] { display: none; }
.chat-composer-preview {
  min-height: 5.5rem; max-height: 15rem; overflow-y: auto;
  padding: 0.65rem 0.85rem; font-size: 0.95rem; line-height: 1.55;
}
.chat-preview-empty { margin: 0; color: var(--text-soft); }
.chat-send-btn { flex-shrink: 0; align-self: flex-end; margin-bottom: 0.15rem; }
.chat-composer-hint {
  margin: 0; padding: 0.35rem 2rem 1rem; font-size: 0.7rem; color: var(--text-soft);
  border-top: 0; background: var(--bg-card);
}

.chat-threads { margin-top: 1rem; padding-top: 1rem; border-top: 1px solid var(--border); }
.thread-label { font-size: 0.75rem; color: var(--text-soft); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 0.5rem; }
.thread-btn {
  display: block; width: 100%; text-align: left; padding: 0.55rem 0.6rem;
  border: none; background: none; color: var(--text-muted); font-size: 0.8rem;
  border-radius: var(--radius-sm); cursor: pointer; font-family: var(--font);
}
.thread-btn:hover, .thread-btn.active { background: var(--accent-light); color: var(--accent); }
.thread-name { display: block; font-size: 0.82rem; font-weight: 600; color: var(--text); line-height: 1.3; }
.thread-btn.active .thread-name { color: var(--accent); }
.thread-preview {
  display: block; margin-top: 0.15rem; font-size: 0.72rem; line-height: 1.35;
  color: var(--text-soft); overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.thread-meta { display: block; margin-top: 0.2rem; font-size: 0.68rem; color: var(--text-soft); }
.chat-today {
  display: flex; gap: 1rem; align-items: center; padding: 0.5rem 2rem;
  font-size: 0.8rem; color: var(--text-muted); border-bottom: 1px solid var(--border);
  background: var(--bg-subtle);
}
.chat-today a { font-size: 0.8rem; }
.chat-status { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.workspace-status { padding: 0.5rem 2rem 0; flex-shrink: 0; }
.workspace-status[data-collapsed="true"] { padding: 0.35rem 2rem; }
.ws-compact {
  display: flex; align-items: center; gap: 0.6rem; width: 100%;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--bg-subtle); padding: 0.45rem 0.75rem;
  font-size: 0.8rem; color: var(--text-muted); cursor: pointer;
  font-family: var(--font); text-align: left;
}
.ws-compact:hover { border-color: var(--accent); background: var(--accent-light); }
.ws-dot { width: 0.55rem; height: 0.55rem; border-radius: 50%; flex-shrink: 0; }
.ws-dot-ok { background: var(--success); }
.ws-dot-warn { background: var(--warning); }
.ws-dot-error { background: var(--danger); }
.ws-compact-title { font-weight: 600; color: var(--text); white-space: nowrap; }
.ws-compact-meta { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ws-chevron { color: var(--text-soft); font-size: 0.75rem; }
.ws-panel {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.75rem 1rem;
  background: var(--bg-subtle);
  font-size: 0.82rem;
  max-height: min(42vh, 320px);
  overflow-y: auto;
}
.ws-panel-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.5rem; }
.ws-collapse-btn {
  border: none; background: none; color: var(--accent); font-size: 0.75rem;
  cursor: pointer; font-family: var(--font); padding: 0.15rem 0.35rem;
}
.ws-collapse-btn:hover { text-decoration: underline; }
.ws-section-label {
  font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--text-soft); margin: 0.65rem 0 0.25rem; font-weight: 600;
}
.ws-panel-warn { border-color: var(--danger); background: var(--danger-bg); }
.ws-title { font-weight: 600; margin: 0; color: var(--text); font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.05em; }
.ws-row { display: flex; justify-content: space-between; gap: 1rem; padding: 0.2rem 0; align-items: center; }
body.workspace-collapsed .workspace-status { padding-bottom: 0.15rem; }
body.workspace-collapsed .chat-messages { flex: 1; }

/* Passport */
.passport-section { margin-bottom: 2.5rem; }
.passport-section-header { display: flex; align-items: center; gap: 1rem; margin-bottom: 1rem; }
.passport-section-header h2 { font-size: 1.1rem; font-weight: 600; }
.passport-items { display: flex; flex-direction: column; gap: 0.75rem; }
.passport-item {
  padding: 1.25rem; background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); cursor: pointer; transition: border-color 0.15s;
}
.passport-item:hover { border-color: var(--accent); }
.passport-item-statement { font-size: 1rem; margin-bottom: 0.5rem; }
.passport-item-meta { display: flex; gap: 0.75rem; font-size: 0.8rem; color: var(--text-muted); flex-wrap: wrap; }

/* Ledger */
.ledger-list { display: flex; flex-direction: column; gap: 0; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.ledger-row {
  display: flex; gap: 1rem; padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border); cursor: pointer;
  background: var(--bg-card); transition: background 0.12s;
}
.ledger-row:last-child { border-bottom: none; }
.ledger-row:hover { background: var(--bg-subtle); }
.ledger-icon { font-size: 1.25rem; width: 2rem; text-align: center; flex-shrink: 0; }
.ledger-summary { font-size: 0.95rem; margin-bottom: 0.35rem; }
.ledger-meta { display: flex; gap: 1rem; font-size: 0.8rem; color: var(--text-muted); flex-wrap: wrap; align-items: center; }
.ledger-detail-summary { font-size: 1.1rem; margin-bottom: 1.25rem; }
.detail-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1rem; margin-bottom: 1.5rem; font-size: 0.9rem; }
.code-block {
  background: var(--bg-subtle); padding: 1rem; border-radius: var(--radius-sm);
  font-size: 0.8rem; overflow-x: auto; font-family: var(--font-mono);
}
.trust-note { font-size: 0.85rem; color: var(--text-muted); font-style: italic; margin-top: 0.5rem; }

/* Drawer */
.drawer-backdrop {
  position: fixed; inset: 0; background: var(--scrim);
  opacity: 0; pointer-events: none; transition: opacity 0.2s; z-index: 90;
}
.drawer-backdrop.open { opacity: 1; pointer-events: auto; }
.drawer {
  position: fixed; top: 0; right: 0; width: 480px; max-width: 100%;
  height: 100vh; background: var(--bg-card); border-left: 1px solid var(--border);
  transform: translateX(100%); transition: transform 0.25s ease;
  z-index: 100; overflow-y: auto; padding: 2rem;
  box-shadow: var(--shadow-panel);
}
.drawer.open { transform: translateX(0); }
.drawer-close { position: absolute; top: 1rem; right: 1rem; font-size: 1.5rem; }

/* OAuth permissions */
.oauth-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.5rem; margin-bottom: 1rem;
}
.oauth-card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.75rem; }
.oauth-card-header h2 { font-size: 1.1rem; }
.oauth-desc { color: var(--text-muted); font-size: 0.9rem; margin-bottom: 1rem; }
.oauth-scopes { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; margin-bottom: 1rem; font-size: 0.85rem; }
.oauth-allowed strong { color: var(--success); }
.oauth-denied strong { color: var(--danger); }
.oauth-scopes ul { margin-top: 0.5rem; padding-left: 1.25rem; color: var(--text-muted); }

/* Connections */
.connection-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 1rem; }
.connection-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.25rem;
}
.connection-card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.5rem; }
.connection-card h3 { font-size: 1rem; }
.connection-meta { font-size: 0.8rem; color: var(--text-soft); text-transform: capitalize; }

/* Settings trust */
.trust-section { margin-bottom: 2.5rem; }
.trust-intro { color: var(--text-muted); margin-bottom: 1.5rem; }
.trust-actions { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1rem; }
.trust-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.5rem;
}
.trust-card h3 { font-size: 1rem; margin-bottom: 0.5rem; }
.trust-card p { font-size: 0.85rem; color: var(--text-muted); margin-bottom: 1rem; }
.trust-danger { border-color: var(--border-strong); }
.placeholder-feature { opacity: 0.7; }

/* HEW-48 space switcher */
.space-switcher { display: flex; flex-direction: column; gap: 0.35rem; margin: 0.5rem 0 1rem; }
.space-switcher select { padding: 0.35rem 0.75rem; border-radius: var(--radius-pill); }
.space-toggle { font-size: 0.8rem; color: var(--text-muted); display: flex; gap: 0.35rem; align-items: flex-start; }

/* =====================================================================
 * HEW-65 reskin PR 2/3 — shared components (Held V kit mockups).
 * Uses only tokens from veraya-tokens.css. Overrides earlier rules.
 * ===================================================================== */

/* Buttons — pills (kit: Approve / Skip) */
.btn { min-height: 36px; padding: 0 var(--veraya-space-2); line-height: 1; border-radius: var(--radius-pill); font-weight: var(--weight-heading); transition: background 0.15s, border-color 0.15s, color 0.15s; }
.btn:focus-visible, .chip:focus-visible, .segmented-item:focus-visible, .thread-btn:focus-visible, .ws-pill:focus-visible { outline: 2px solid var(--border-strong); outline-offset: 2px; }
.btn-primary:hover { transform: none; }
.btn-secondary { background: transparent; color: var(--text); border: 1px solid var(--border-strong); }
.btn-secondary:hover { background: var(--accent-light); border-color: var(--border-strong); }
.btn-sm { min-height: 28px; padding: 0 0.75rem; font-size: 0.8rem; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* Chips (suggestions, small tags) */
.chip {
  display: inline-flex; align-items: center; min-height: 32px; padding: 0 0.85rem;
  border: 1px solid var(--border-strong); border-radius: var(--radius-pill);
  background: transparent; color: var(--text-muted); font-family: var(--font); font-size: 0.85rem;
  cursor: pointer; transition: background 0.15s, color 0.15s;
}
.chip:hover { background: var(--accent-light); color: var(--text); }

/* Inputs */
.form-group input, .form-group select, .form-group textarea, .space-switcher select {
  background: var(--bg-subtle); border: 1px solid var(--border); border-radius: var(--radius-sm); color: var(--text);
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus { border-color: var(--border-strong); box-shadow: 0 0 0 3px var(--accent-light); }

/* Toggles (switch style on checkboxes) */
.toggle { display: flex; align-items: center; gap: var(--veraya-space-1); cursor: pointer; }
.toggle input[type="checkbox"], .checkbox-group input[type="checkbox"] {
  appearance: none; -webkit-appearance: none; flex-shrink: 0;
  width: 30px; height: 18px; border-radius: var(--radius-pill);
  background: var(--accent-light); border: 1px solid var(--border-strong);
  position: relative; cursor: pointer; transition: background 0.15s;
}
.toggle input[type="checkbox"]::after, .checkbox-group input[type="checkbox"]::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 12px; height: 12px;
  border-radius: var(--radius-pill); background: var(--text-muted); transition: transform 0.15s, background 0.15s;
}
.toggle input[type="checkbox"]:checked, .checkbox-group input[type="checkbox"]:checked { background: var(--accent); border-color: var(--accent); }
.toggle input[type="checkbox"]:checked::after, .checkbox-group input[type="checkbox"]:checked::after { transform: translateX(12px); background: var(--text-on-accent); }
.toggle input[type="checkbox"]:focus-visible, .checkbox-group input[type="checkbox"]:focus-visible { outline: 2px solid var(--border-strong); outline-offset: 2px; }
.space-toggle { font-size: 0.8rem; color: var(--text-muted); align-items: center; margin-top: 0.35rem; }

/* Personal / Sam segmented switcher */
.space-switcher { gap: var(--veraya-space-1); margin: 0; }
.segmented { display: flex; padding: 3px; gap: 2px; background: var(--bg-subtle); border: 1px solid var(--border); border-radius: var(--radius-pill); }
.segmented-item {
  flex: 1; min-height: 30px; border: 0; border-radius: var(--radius-pill); background: transparent;
  color: var(--text-muted); font-family: var(--font); font-size: 0.85rem; font-weight: var(--weight-heading); cursor: pointer;
}
.segmented-item:hover:not(:disabled) { color: var(--text); }
.segmented-item.active { background: var(--accent); color: var(--text-on-accent); }
.segmented-item:disabled { cursor: default; }
.segmented-item.active:disabled { background: var(--accent-light); color: var(--text); }

/* Sidebar + thread list items */
.sidebar { gap: var(--veraya-space-3); padding: var(--veraya-space-3) var(--veraya-space-2); }
.sidebar-tagline { margin-top: calc(var(--veraya-space-2) * -1); font-style: normal; color: var(--text-soft); }
.sidebar-nav a { padding: 0.5rem 0.75rem; }
.sidebar-nav a.active { background: var(--accent-light); color: var(--text); }
.sidebar-nav a:hover { color: var(--text); }
.thread-label { font-size: 0.7rem; letter-spacing: 0.08em; color: var(--text-soft); }
.chat-threads { margin-top: 0; padding-top: var(--veraya-space-2); border-top: 1px solid var(--border-subtle); display: flex; flex-direction: column; gap: 2px; }
.thread-btn { padding: 0.5rem 0.75rem; border-radius: var(--radius-sm); }
.thread-btn:hover { background: var(--accent-light); color: var(--text-muted); }
.thread-btn.active { background: var(--accent-light); color: var(--text); box-shadow: inset 0 0 0 1px var(--border); }
.thread-btn.active .thread-name { color: var(--text); }
.thread-name { font-weight: var(--weight-regular); font-size: 0.875rem; }
.thread-btn.active .thread-name { font-weight: var(--weight-heading); }
.thread-meta { display: none; }

/* Chat shell */
.chat-header { padding: var(--veraya-space-2) var(--veraya-space-4); border-bottom: 1px solid var(--border-subtle); align-items: center; }
.chat-header h1 { font-size: 1.05rem; }
.chat-subtitle { margin-top: 0; color: var(--text-soft); }
.automation-badge { border-radius: var(--radius-pill); background: transparent; border: 1px solid var(--border); color: var(--text-muted); padding: 0.1rem 0.6rem; }
.chat-today { padding: 0.4rem var(--veraya-space-4); background: transparent; border-bottom: 1px solid var(--border-subtle); color: var(--text-soft); font-size: 0.78rem; }
.chat-today a { color: var(--text-muted); }
.chat-messages { padding: var(--veraya-space-3) var(--veraya-space-4); gap: var(--veraya-space-3); width: 100%; max-width: 820px; margin: 0 auto; align-self: stretch; }

/* Message bubbles: user = tinted slab, assistant = full-width markdown */
.chat-bubble { max-width: 100%; padding: 0; border-radius: var(--radius-lg); }
.chat-bubble-user { align-self: flex-end; max-width: min(560px, 85%); background: var(--bg-subtle); border: 1px solid var(--border-subtle); padding: 0.75rem 1rem 1.75rem; }
.chat-bubble-assistant { align-self: stretch; width: 100%; background: transparent; border: 0; padding: 0 0 1.75rem; }
.chat-bubble-meta { margin-bottom: 0.25rem; justify-content: flex-start; }
.chat-role { font-size: 0.72rem; letter-spacing: 0.06em; color: var(--text-soft); }
.chat-bubble-user .chat-bubble-meta { justify-content: flex-end; }
.chat-text { line-height: 1.6; }
.chat-markdown .md-p { line-height: 1.6; }
.chat-copy-btn { right: 0; bottom: 0; border-radius: var(--radius-pill); }
.chat-bubble-user .chat-copy-btn { right: 0.5rem; bottom: 0.4rem; }

/* Tool cards: web search sources + generated image */
.chat-tool-note {
  display: inline-flex; align-items: center; gap: 0.4rem; margin-top: 0.75rem; padding: 0.2rem 0.65rem;
  border: 1px solid var(--border); border-radius: var(--radius-pill); color: var(--text-muted); font-size: 0.75rem;
}
.chat-sources {
  list-style: none; counter-reset: src; margin-top: 0.75rem; padding: 0.5rem; display: grid; gap: 2px;
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
}
.chat-sources li { counter-increment: src; display: flex; gap: 0.5rem; padding: 0.35rem 0.5rem; border-radius: var(--radius-sm); }
.chat-sources li::before { content: counter(src); color: var(--text-soft); font-size: 0.75rem; min-width: 1rem; }
.chat-sources li:hover { background: var(--accent-light); }
.chat-sources a { color: var(--text-muted); text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-sources a:hover { color: var(--text); text-decoration: underline; }
.chat-attachments { margin-top: 0.75rem; padding: 0.5rem; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); display: inline-block; max-width: 100%; }
.chat-generated-image { margin-top: 0; border-radius: var(--radius-sm); border: 0; max-height: 480px; }

/* Composer (kit: "Ask Veraya…") */
.chat-composer { padding: var(--veraya-space-2) var(--veraya-space-4) var(--veraya-space-1); border-top: 0; background: transparent; width: 100%; max-width: 820px; margin: 0 auto; align-items: flex-end; }
.chat-composer-field { border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--bg-card); }
.chat-composer-field:focus-within { border-color: var(--border-strong); box-shadow: 0 0 0 3px var(--accent-light); }
.chat-composer-toolbar-row { background: transparent; border-bottom: 1px solid var(--border-subtle); }
.chat-markdown-toolbar md-bold:hover, .chat-markdown-toolbar md-italic:hover, .chat-markdown-toolbar md-link:hover,
.chat-markdown-toolbar md-code:hover, .chat-markdown-toolbar md-unordered-list:hover, .chat-markdown-toolbar md-ordered-list:hover,
.chat-markdown-toolbar md-quote:hover { background: var(--accent-light); }
.chat-preview-btn { border-radius: var(--radius-pill); padding: 0.2rem 0.65rem; }
.chat-preview-btn:hover:not(:disabled) { background: var(--accent-light); }
.chat-composer textarea { min-height: 4.5rem; font-size: var(--veraya-text-chat); padding: 0.75rem 1rem; }
.chat-composer textarea::placeholder { color: var(--text-soft); }
.chat-send-btn { margin-bottom: 0.25rem; }
.chat-composer-hint { background: transparent; text-align: center; padding: 0.25rem var(--veraya-space-4) var(--veraya-space-2); width: 100%; max-width: 820px; margin: 0 auto; }

/* Empty chat state (kit: chat shell) */
.chat-empty { margin: auto; text-align: left; max-width: 520px; width: 100%; padding: var(--veraya-space-4) 0; }
.chat-empty-mark { display: block; margin-bottom: var(--veraya-space-2); }
.chat-empty-greeting { font-size: 1.5rem; font-weight: var(--weight-heading); letter-spacing: -0.01em; color: var(--text); }
.chat-empty-prompt { color: var(--text-muted); margin-top: 0.25rem; }
.chat-suggestions { display: flex; flex-wrap: wrap; gap: var(--veraya-space-1); margin-top: var(--veraya-space-3); }

/* Workspace status: collapsed pill, muted banner when degraded */
.workspace-status, .workspace-status[data-collapsed="true"] { padding: var(--veraya-space-1) var(--veraya-space-4) 0; display: flex; flex-direction: column; align-items: flex-start; gap: var(--veraya-space-1); }
.ws-compact.ws-pill {
  width: auto; display: inline-flex; gap: 0.5rem; padding: 0.25rem 0.75rem; min-height: 28px;
  border: 1px solid var(--border); border-radius: var(--radius-pill); background: transparent;
  color: var(--text-muted); font-size: 0.78rem;
}
.ws-compact.ws-pill:hover { background: var(--accent-light); border-color: var(--border-strong); }
.ws-pill .ws-compact-title { font-weight: var(--weight-regular); color: var(--text-muted); }
.ws-pill-warn { border-color: var(--border-strong); }
.ws-pill-warn .ws-compact-title { color: var(--warning); }
.ws-dot { width: 0.45rem; height: 0.45rem; }
.ws-panel, .ws-panel-warn {
  width: 100%; max-width: 520px; border: 1px solid var(--border); background: var(--bg-card);
  border-radius: var(--radius); padding: var(--veraya-space-1) var(--veraya-space-2); font-size: 0.82rem;
  max-height: min(50vh, 420px);
}
.ws-panel-warn { border-color: var(--border-strong); }
.ws-row { padding: 0.35rem 0; border-bottom: 1px solid var(--border-subtle); }
.ws-row:last-child { border-bottom: 0; }
.ws-check { display: inline-flex; align-items: center; gap: 0.5rem; color: var(--text); }
.ws-detail { color: var(--text-muted); text-align: right; }
.ws-note { color: var(--text-muted); padding: 0.35rem 0; }
.ws-debug { margin-top: var(--veraya-space-1); padding-top: var(--veraya-space-1); border-top: 1px dashed var(--border); }
.ws-debug .ws-row { color: var(--text-muted); font-size: 0.78rem; }
.ws-state { font-size: 0.75rem; }
.ws-state-ok { color: var(--success); }
.ws-state-warn { color: var(--warning); }
.ws-state-muted { color: var(--text-soft); }

/* Banners and toasts */
.banner, .automation-note {
  display: flex; gap: 0.5rem; align-items: flex-start; padding: 0.65rem var(--veraya-space-2);
  background: var(--bg-card); border: 1px solid var(--border); border-left: 1px solid var(--border);
  border-radius: var(--radius); color: var(--text-muted); font-size: 0.875rem; font-style: normal;
}
.banner-warn { border-color: var(--border-strong); color: var(--warning); }
.banner-danger { background: var(--danger-bg); border-color: transparent; color: var(--danger); }
.toast {
  position: fixed; left: 50%; bottom: var(--veraya-space-3); transform: translateX(-50%); z-index: 120;
  padding: 0.6rem var(--veraya-space-2); border-radius: var(--radius-pill);
  background: var(--accent); color: var(--text-on-accent); font-size: 0.875rem; box-shadow: var(--shadow-panel);
}

/* Badges: quiet outline */
.badge { border-radius: var(--radius-pill); font-weight: var(--weight-heading); }

/* Settings section cards (kit: access history row) */
.main-content { padding: var(--veraya-space-5) var(--veraya-space-6); }
.page-header h1 { font-size: 1.6rem; }
.section, .trust-section { margin-bottom: var(--veraya-space-5); }
.section h2, .trust-section h2 { font-size: 0.75rem; font-weight: var(--weight-heading); text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-soft); margin-bottom: var(--veraya-space-2); }
.card, .trust-card, .connection-card, .oauth-card, .stat-card {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: none; padding: var(--veraya-space-3);
}
.card p + p { margin-top: 0.25rem; }
.trust-card h3, .connection-card h3 { font-size: 1rem; font-weight: var(--weight-heading); }
.trust-card p { color: var(--text-muted); }
.trust-danger { border-color: var(--border); }
.connection-card .badge { margin: 0.35rem 0 0.5rem; }
.ledger-list { border-radius: var(--radius); }
.ledger-row { background: var(--bg-card); }
.ledger-row:hover { background: var(--bg-subtle); }

.theme-toggle { width: 36px; padding: 0; justify-content: center; }

@media (max-width: 768px) {
  .main-content { padding: var(--veraya-space-3) var(--veraya-space-2); }
  .chat-header, .chat-today, .workspace-status, .workspace-status[data-collapsed="true"], .chat-messages, .chat-composer, .chat-composer-hint { padding-left: var(--veraya-space-2); padding-right: var(--veraya-space-2); }
}

/* =====================================================================
 * HEW-65 reskin PR 3/3 — screen polish + HEW-70 error states.
 * Tokens only; monochrome (no accent hue).
 * ===================================================================== */

/* Typography scale */
.page-header h1, .chat-header h1 { font-weight: var(--weight-heading); letter-spacing: -0.01em; color: var(--text); }
.page-header p { color: var(--text-muted); margin-top: 0.35rem; max-width: 60ch; line-height: 1.5; }
.connection-desc { font-size: 0.85rem; color: var(--text-muted); line-height: 1.45; }

/* Focus: one consistent visible ring for every interactive control */
a:focus-visible, button:focus-visible, select:focus-visible, input:focus-visible, textarea:focus-visible,
.sidebar-nav a:focus-visible, .chat-copy-btn:focus-visible, .chat-preview-btn:focus-visible,
.mobile-nav-toggle:focus-visible, .theme-toggle:focus-visible, .passport-item:focus-visible, .ledger-row:focus-visible {
  outline: 2px solid var(--border-strong); outline-offset: 2px;
}
.chat-composer textarea:focus-visible { outline: none; }
.chat-copy-btn:focus-visible { opacity: 1; }

/* Chat header + thread list */
.chat-header { padding: var(--veraya-space-2) var(--veraya-space-4); align-items: center; }
.chat-subtitle { margin-top: 2px; }
.chat-status[hidden], .chat-today[hidden] { display: none; }
.thread-empty { font-size: 0.82rem; color: var(--text-soft); padding: 0.25rem 0.75rem; }
.thread-preview { max-width: 100%; }
.chat-messages { gap: var(--veraya-space-2); }
.chat-bubble { max-width: min(680px, 100%); }

/* HEW-70: chat error card + offline banner */
.chat-offline { margin: var(--veraya-space-1) var(--veraya-space-4) 0; }
.chat-offline[hidden] { display: none; }
.chat-error {
  align-self: flex-start; max-width: min(560px, 100%); padding: var(--veraya-space-2);
  background: var(--bg-card); border: 1px solid var(--border-strong); border-radius: var(--radius);
}
.chat-error-center { align-self: center; margin: auto; text-align: left; }
.chat-error-title { font-weight: var(--weight-heading); color: var(--text); }
.chat-error-message { margin-top: 0.25rem; color: var(--text-muted); font-size: 0.9rem; line-height: 1.5; }
.chat-error-actions { display: flex; gap: var(--veraya-space-1); margin-top: var(--veraya-space-2); }

/* Generic page error / empty states */
.error-state, .empty-state {
  padding: var(--veraya-space-3); border: 1px dashed var(--border); border-radius: var(--radius);
  color: var(--text-muted); background: transparent; text-align: left;
}
.error-state { border-style: solid; border-color: var(--border-strong); background: var(--bg-card); }
.error-state-title { color: var(--text); font-weight: var(--weight-heading); }
.error-state-message { margin-top: 0.25rem; font-size: 0.9rem; }
.error-state-retry { margin-top: var(--veraya-space-2); }
.toast[hidden] { display: none; }

/* Mobile: menu button + sidebar drawer (hidden on desktop) */
.mobile-bar, .sidebar-scrim { display: none; }
.mobile-nav-toggle {
  display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px;
  border: 0; border-radius: var(--radius-pill); background: transparent; color: var(--text); cursor: pointer;
}
.mobile-nav-toggle:hover { background: var(--accent-light); }
.mobile-nav-toggle svg { width: 20px; height: 20px; }
.mobile-bar-brand { display: inline-flex; align-items: center; gap: 8px; color: var(--text); font-weight: var(--weight-heading); }
.mobile-bar-brand:hover { text-decoration: none; }
.mobile-bar-brand img { width: 20px; height: 20px; }

@media (max-width: 768px) {
  .mobile-bar {
    display: flex; align-items: center; gap: var(--veraya-space-1); position: sticky; top: 0; z-index: 60;
    height: 52px; padding: 0 var(--veraya-space-1); background: var(--bg); border-bottom: 1px solid var(--border-subtle);
  }
  .sidebar {
    display: flex; z-index: 80; width: min(300px, 86vw); transform: translateX(-100%);
    transition: transform 0.2s ease; box-shadow: none; visibility: hidden;
  }
  body.sidebar-open .sidebar { transform: none; box-shadow: var(--shadow-panel); visibility: visible; }
  body.sidebar-open .sidebar-scrim { display: block; position: fixed; inset: 0; z-index: 70; background: var(--scrim); }
  .app-shell { min-height: calc(100vh - 52px); }
  .chat-page .main-content { height: calc(100vh - 52px); height: calc(100dvh - 52px); }
  .chat-header { padding-top: var(--veraya-space-1); padding-bottom: var(--veraya-space-1); }
  .chat-header h1 { font-size: 1.1rem; }
  .chat-offline { margin-left: var(--veraya-space-2); margin-right: var(--veraya-space-2); }
  .chat-composer { gap: var(--veraya-space-1); }
  .chat-composer textarea { min-height: 3.25rem; }
  .chat-composer-hint { display: none; }
  .chat-bubble { padding: 0.85rem 1rem 1.9rem; }
  .chat-empty { padding: var(--veraya-space-2) 0; }
  .chat-empty-greeting { font-size: 1.3rem; }
  .chat-suggestions .chip { white-space: normal; text-align: left; min-height: 36px; padding: 0.4rem 0.85rem; }
  .page-header h1 { font-size: 1.35rem; }
  .card, .trust-card, .connection-card, .oauth-card, .stat-card { padding: var(--veraya-space-2); }
  /* Theme toggle sits in the mobile top bar so it never covers Send. */
  .theme-toggle { position: fixed; top: 8px; bottom: auto; right: 8px; z-index: 65; border-color: transparent; }
  .ws-panel, .ws-panel-warn { max-width: 100%; }
  .ws-row { gap: var(--veraya-space-1); }
  .oauth-scopes { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
  /* Keep the composer toolbar on one row at phone widths. */
  .chat-markdown-toolbar md-quote, .chat-markdown-toolbar md-code, .chat-markdown-toolbar md-ordered-list { display: none; }
  .chat-composer-toolbar-row { flex-wrap: nowrap; }
}

/* Legal pages (/veraya/terms, /veraya/privacy): public, signed-out reading view. */
body.legal-page { margin: 0; }
.legal-header { display: flex; align-items: center; justify-content: space-between; gap: var(--veraya-space-3); max-width: 760px; margin: 0 auto; padding: var(--veraya-space-4) var(--veraya-space-3) var(--veraya-space-2); }
.legal-brand img { display: block; height: 28px; width: auto; }
.legal-logo-light { display: none !important; }
[data-theme="light"] .legal-logo-light { display: block !important; }
[data-theme="light"] .legal-logo-dark { display: none !important; }
.legal-nav { color: var(--text-soft); font-size: 0.95rem; }
.legal-nav a { color: var(--text-muted); }
.legal-nav a[aria-current="page"] { color: var(--text); font-weight: var(--veraya-weight-semibold); }
.legal-doc { max-width: 760px; margin: 0 auto; padding: var(--veraya-space-2) var(--veraya-space-3) var(--veraya-space-6, 64px); color: var(--text); line-height: 1.6; }
.legal-doc h1 { font-size: 2rem; margin: var(--veraya-space-3) 0 var(--veraya-space-1); }
.legal-doc .legal-subtitle { color: var(--text-muted); font-size: 1.1rem; margin: 0 0 var(--veraya-space-3); }
.legal-doc h2 { font-size: 1.25rem; margin: var(--veraya-space-5) 0 var(--veraya-space-2); padding-top: var(--veraya-space-2); border-top: 1px solid var(--border); }
.legal-doc h3 { font-size: 1.05rem; margin: var(--veraya-space-3) 0 var(--veraya-space-1); }
.legal-doc p, .legal-doc li { color: var(--text); }
.legal-doc p { margin: 0 0 var(--veraya-space-2); }
.legal-doc ul { padding-left: 1.25rem; margin: 0 0 var(--veraya-space-2); }
.legal-doc li { margin-bottom: 0.5rem; }
.legal-doc a { color: var(--text); text-decoration: underline; text-decoration-color: var(--border-strong); text-underline-offset: 2px; overflow-wrap: anywhere; }
.legal-meta { display: grid; gap: 4px; margin: 0 0 var(--veraya-space-3); padding: var(--veraya-space-2) var(--veraya-space-3); background: var(--bg-subtle); border: 1px solid var(--border); border-radius: var(--veraya-radius-field); }
.legal-meta div { display: flex; gap: var(--veraya-space-2); flex-wrap: wrap; }
.legal-meta dt { color: var(--text-muted); min-width: 10rem; }
@media (max-width: 480px) { .legal-header { flex-wrap: wrap; } .legal-meta dt { min-width: 0; width: 100%; } .legal-doc h1 { font-size: 1.6rem; } }
.legal-meta dd { margin: 0; }
.legal-links { color: var(--text-soft); font-size: 0.85rem; text-align: center; margin: var(--veraya-space-2) 0 0; }
.legal-links a { color: var(--text-muted); }
