:root {
  --bg: #0f0f1e;
  --bg-2: #1a1a2e;
  --fg: #e8e8f0;
  --fg-dim: #9090a8;
  --accent: #d4a373;
  --accent-2: #fefae0;
  --user: #2d3748;
  --bot: #1e3a5f;
  --danger: #c44;
  --ok: #4c8;
  --r: 18px;
  --safe-bottom: env(safe-area-inset-bottom, 0);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  background: var(--bg);
  color: var(--fg);
  font-family: -apple-system, "SF Pro Display", "Segoe UI", "David", system-ui, sans-serif;
  font-size: 18px;
  -webkit-font-smoothing: antialiased;
}
/* Chat shell — fixed height, no body scroll */
body {
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  /* Use visual viewport on mobile (handles keyboard properly) */
  height: 100vh;
  height: 100dvh;
  height: var(--app-height, 100dvh);
  overflow: hidden;
}

/* Topbar */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px max(12px, env(safe-area-inset-right)) 10px max(12px, env(safe-area-inset-left));
  background: var(--bg-2); border-bottom: 1px solid #2a2a44;
  gap: 8px;
  min-width: 0;
}
.brand { display: flex; align-items: center; gap: 8px; min-width: 0; flex-shrink: 1; overflow: hidden; }
.brand h1 { font-size: 18px; font-weight: 600; letter-spacing: 0.5px; white-space: nowrap; }
.brand .sub { color: var(--fg-dim); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 10px var(--ok); flex-shrink: 0; }

.iconbtn {
  background: transparent; color: var(--fg);
  width: 34px; height: 34px; border-radius: 50%; border: 1px solid #2a2a44;
  font-size: 18px; line-height: 1; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  padding: 0;
}
.iconbtn:active { background: #2a2a44; }
.iconbtn.alt { color: var(--danger); border-color: #4a2020; }

/* Chat */
.chat {
  overflow-y: auto;
  overflow-x: hidden;
  padding: 16px max(14px, env(safe-area-inset-right)) 8px max(14px, env(safe-area-inset-left));
  scroll-behavior: smooth;
  display: flex; flex-direction: column; gap: 10px;
  width: 100%;
  min-width: 0;
}
.bubble {
  max-width: 78%;
  width: fit-content;
  padding: 10px 14px;
  border-radius: 16px;
  line-height: 1.5;
  word-wrap: break-word;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
  font-size: 16px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.18);
}
.bubble p + p { margin-top: 6px; }
.bubble .hint { color: var(--fg-dim); font-size: 14px; }
.bubble.system { align-self: center; background: #1a1a2e; color: var(--fg-dim); text-align: center; max-width: 92%; }
.bubble.user { margin-inline-start: auto; background: var(--user); border-bottom-right-radius: 4px; }
.bubble.bot { margin-inline-end: auto; background: var(--bot); border-bottom-left-radius: 4px; }
.bubble.thinking { margin-inline-end: auto; background: var(--bot); opacity: 0.7; }
.bubble.thinking::after { content: "..."; animation: blink 1s steps(3) infinite; }
@keyframes blink { 0%{opacity:.3} 50%{opacity:1} 100%{opacity:.3} }

/* Dock */
.dock {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 12px 16px calc(12px + var(--safe-bottom));
  background: var(--bg-2); border-top: 1px solid #2a2a44;
  gap: 12px;
}
.status {
  color: var(--fg-dim);
  font-size: 14px;
  text-align: right;
  padding-right: 4px;
}
.status.live { color: var(--ok); animation: pulse 1.5s infinite; }
.status.error { color: var(--danger); }
@keyframes pulse { 0%{opacity:.6} 50%{opacity:1} 100%{opacity:.6} }

.ptt {
  background: linear-gradient(135deg, var(--accent), #b8865c);
  color: var(--bg);
  border: none;
  width: 96px; height: 96px;
  border-radius: 50%;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 4px;
  font-weight: 700; font-size: 14px;
  box-shadow: 0 4px 24px rgba(212, 163, 115, 0.35);
  cursor: pointer;
  transition: transform 0.1s;
  -webkit-tap-highlight-color: transparent;
}
.ptt .lbl { font-size: 13px; }
.ptt:active { transform: scale(0.95); }
.ptt.recording {
  background: linear-gradient(135deg, var(--danger), #903030);
  color: white;
  animation: recpulse 0.8s infinite;
}
@keyframes recpulse {
  0%{box-shadow: 0 4px 24px rgba(204,68,68,0.4)}
  50%{box-shadow: 0 4px 36px rgba(204,68,68,0.85)}
  100%{box-shadow: 0 4px 24px rgba(204,68,68,0.4)}
}
.ptt:disabled { opacity: 0.4; cursor: not-allowed; }

/* === Text input + model selector additions === */

.topbar-actions { display: flex; align-items: center; gap: 4px; flex-shrink: 0; }
.model-select {
  background: var(--bg);
  color: var(--fg);
  border: 1px solid #2a2a44;
  border-radius: 8px;
  padding: 4px 6px;
  font-size: 11px;
  max-width: 90px;
  -webkit-appearance: none;
  cursor: pointer;
  flex-shrink: 0;
}
.model-select:focus { outline: none; border-color: var(--accent); }

/* Dock layout overhaul: 2 rows (text + voice) */
.dock {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 10px 14px calc(12px + var(--safe-bottom));
}

.text-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}
#textInput {
  flex: 1;
  background: var(--bg);
  color: var(--fg);
  border: 1.5px solid var(--border);
  border-radius: 14px;
  padding: 12px 14px;
  font-size: 16px;
  font-family: inherit;
  resize: none;
  max-height: 120px;
  overflow-y: auto;
  -webkit-appearance: none;
  line-height: 1.4;
}
#textInput:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(212,163,115,0.2); }

.send-btn {
  background: linear-gradient(135deg, var(--accent), #b8865c);
  color: var(--bg);
  border: none;
  width: 46px; height: 46px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: transform 0.1s;
  -webkit-tap-highlight-color: transparent;
}
.send-btn:active { transform: scale(0.92); }
.send-btn:disabled { opacity: 0.4; cursor: not-allowed; }

.voice-row {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
  padding-top: 4px;
}
.voice-row .ptt { width: 80px; height: 80px; }

/* === WhatsApp-style single-row input === */
.dock {
  display: block;
  /* Generous side padding + safe-area for notches/round screens */
  padding-top: 10px;
  padding-bottom: calc(12px + var(--safe-bottom));
  padding-left: max(16px, env(safe-area-inset-left, 0));
  padding-right: max(16px, env(safe-area-inset-right, 0));
  background: var(--bg-2);
  border-top: 1px solid var(--border);
  position: relative;
  z-index: 5;
  width: 100%;
  box-sizing: border-box;
}
.input-row {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  width: 100%;
  box-sizing: border-box;
}
#textInput {
  flex: 1 1 auto;
  min-width: 0; /* allow flex shrink — critical for RTL not to push button off-screen */
  background: var(--bg);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 12px 18px;
  font-size: 16px;
  font-family: inherit;
  resize: none;
  max-height: 120px;
  overflow-y: auto;
  -webkit-appearance: none;
  line-height: 1.4;
  min-height: 48px;
  box-sizing: border-box;
}
#textInput:focus { outline: none; border-color: var(--accent); }

.action-btn {
  /* Fixed size — never shrinks, never grows. Critical: button stays visible. */
  flex: 0 0 52px;
  width: 52px; height: 52px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, var(--accent), #b8865c);
  color: var(--bg);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: transform 0.1s, background 0.2s;
  -webkit-tap-highlight-color: transparent;
  position: relative;
  box-shadow: 0 2px 8px rgba(212,163,115,0.3);
  /* Force visibility of icon */
  z-index: 1;
}
.action-btn svg {
  display: block;
  pointer-events: none;
  /* Explicit color — currentColor on var(--bg) which is dark navy on gold gradient */
  color: var(--bg);
}
.action-btn:active { transform: scale(0.92); }
.action-btn .ic-send { display: none; }
.action-btn.mode-send .ic-mic { display: none; }
.action-btn.mode-send .ic-send { display: block; }
.action-btn.recording {
  background: linear-gradient(135deg, var(--danger), #903030);
  color: white;
  animation: recpulse 0.8s infinite;
}

/* Status bar (separate, slim) */
.status-bar {
  background: var(--bg-2);
  border-bottom: 1px solid var(--border);
  padding: 4px 16px;
  font-size: 12px;
  color: var(--fg-dim);
  text-align: right;
  min-height: 22px;
}
.status-bar #status.live { color: var(--ok); }
.status-bar #status.error { color: var(--danger); }

/* Override old voice-row / text-row */
.voice-row, .text-row { display: none !important; }

/* ====================================================================
   DRAWER (side menu) + MODAL
   ==================================================================== */
#menuBtn { margin-inline-end: 4px; }

.drawer {
  position: fixed;
  top: 0; right: 0;
  height: 100%; height: 100dvh;
  width: min(320px, 86vw);
  background: var(--bg-2);
  border-left: 1px solid #2a2a44;
  box-shadow: -8px 0 32px rgba(0,0,0,0.4);
  transform: translateX(100%);
  transition: transform 0.25s ease;
  z-index: 200;
  overflow-y: auto;
  display: flex; flex-direction: column;
  padding-top: env(safe-area-inset-top, 0);
  padding-bottom: env(safe-area-inset-bottom, 0);
}
body.drawer-open .drawer { transform: translateX(0); }

.drawer-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 199;
  opacity: 0;
  transition: opacity 0.25s ease;
  pointer-events: none;
}
body.drawer-open .drawer-overlay {
  opacity: 1;
  pointer-events: auto;
}

.drawer-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px;
  border-bottom: 1px solid #2a2a44;
  gap: 12px;
}
.drawer-user {
  display: flex; align-items: center; gap: 12px; min-width: 0;
  background: transparent; border: none; padding: 8px;
  margin: -8px; border-radius: 12px;
  cursor: pointer; flex: 1;
  text-align: right; color: var(--fg);
  font-family: inherit;
  transition: background 0.15s;
}
.drawer-user:active { background: rgba(212,163,115,0.12); }
.drawer-user:hover { background: rgba(212,163,115,0.08); }
.drawer-avatar {
  width: 48px; height: 48px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), #b8865c);
  color: var(--bg);
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; font-weight: 700;
  overflow: hidden;
  flex-shrink: 0;
  position: relative;
}
.drawer-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.drawer-user-info { min-width: 0; }
.drawer-user-name { font-size: 16px; font-weight: 600; color: var(--fg); }
.drawer-user-sub { font-size: 12px; color: var(--fg-dim); margin-top: 2px; }

.drawer-nav { display: flex; flex-direction: column; padding: 8px 0; gap: 2px; flex: 1; }
.drawer-item {
  display: flex; align-items: center; gap: 14px;
  background: transparent;
  border: none;
  color: var(--fg);
  padding: 14px 18px;
  font-size: 15px;
  font-family: inherit;
  text-align: right;
  cursor: pointer;
  width: 100%;
  border-radius: 0;
  transition: background 0.15s;
}
.drawer-item:active { background: #2a2a44; }
.drawer-item:hover { background: rgba(212,163,115,0.08); }
.drawer-item svg { color: var(--accent); flex-shrink: 0; }
.drawer-item span { flex: 1; }
.drawer-item-danger { color: var(--danger); }
.drawer-item-danger svg { color: var(--danger); }
.drawer-item[data-action="install"][hidden] { display: none; }

.drawer-divider { height: 1px; background: #2a2a44; margin: 8px 16px; }

.drawer-footer {
  padding: 16px;
  border-top: 1px solid #2a2a44;
  font-size: 12px;
  color: var(--fg-dim);
  text-align: center;
}
.drawer-version { margin-top: 4px; opacity: 0.7; }

/* Modal */
.modal {
  background: var(--bg-2);
  color: var(--fg);
  border: 1px solid #2a2a44;
  border-radius: 16px;
  padding: 0;
  max-width: min(440px, 92vw);
  max-height: 85vh;
  width: 100%;
  overflow: hidden;
  box-shadow: 0 16px 64px rgba(0,0,0,0.6);
}
.modal::backdrop { background: rgba(0,0,0,0.6); }
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid #2a2a44;
}
.modal-header h2 { font-size: 18px; font-weight: 600; }
.modal-body {
  padding: 18px 20px 22px;
  overflow-y: auto;
  max-height: calc(85vh - 60px);
  font-size: 15px;
  line-height: 1.6;
}
.modal-body h3 { font-size: 16px; margin: 14px 0 6px; color: var(--accent); }
.modal-body p { margin-bottom: 10px; }
.modal-body ul, .modal-body ol { padding-inline-start: 22px; margin-bottom: 10px; }
.modal-body li { margin-bottom: 6px; }
.modal-body code { background: var(--bg); padding: 2px 6px; border-radius: 4px; font-size: 13px; }

/* Profile form */
.profile-form { display: flex; flex-direction: column; gap: 14px; }
.profile-avatar-large {
  width: 100px; height: 100px;
  margin: 0 auto;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), #b8865c);
  color: var(--bg);
  display: flex; align-items: center; justify-content: center;
  font-size: 42px; font-weight: 700;
  overflow: hidden;
  position: relative;
  cursor: pointer;
  border: 3px solid #2a2a44;
  transition: transform 0.1s;
}
.profile-avatar-large:active { transform: scale(0.96); }
.profile-avatar-large img { width: 100%; height: 100%; object-fit: cover; display: block; }
.profile-avatar-large .edit-overlay {
  position: absolute; inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex; align-items: center; justify-content: center;
  opacity: 0;
  transition: opacity 0.15s;
  font-size: 16px;
  color: white;
}
.profile-avatar-large:hover .edit-overlay { opacity: 1; }
.profile-photo-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 6px; }
.profile-photo-actions button {
  background: var(--bg);
  color: var(--fg);
  border: 1px solid #2a2a44;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 13px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 6px;
  font-family: inherit;
}
.profile-photo-actions button:active { background: #2a2a44; }
.profile-field { display: flex; flex-direction: column; gap: 4px; }
.profile-field label { font-size: 13px; color: var(--fg-dim); }
.profile-field input {
  background: var(--bg);
  color: var(--fg);
  border: 1px solid #2a2a44;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 15px;
  font-family: inherit;
  -webkit-appearance: none;
  width: 100%;
}
.profile-field input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(212,163,115,0.18); }
.profile-actions { display: flex; gap: 8px; margin-top: 10px; }
.profile-actions button {
  flex: 1;
  border-radius: 10px;
  padding: 12px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  border: none;
}
.profile-actions .save-btn-primary {
  background: linear-gradient(135deg, var(--accent), #b8865c);
  color: var(--bg);
}
.profile-actions .cancel-btn {
  background: transparent;
  color: var(--fg-dim);
  border: 1px solid #2a2a44;
}

/* Cropper */
.cropper { display: flex; flex-direction: column; gap: 12px; align-items: center; }
.cropper-stage {
  position: relative;
  margin: 0 auto;
  background: #0f0f1e;
  border-radius: 14px;
  overflow: hidden;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  cursor: grab;
}
.cropper-stage:active { cursor: grabbing; }
.cropper-stage canvas { display: block; }
.cropper-mask {
  position: absolute; inset: 0;
  pointer-events: none;
  background: radial-gradient(circle at center, transparent 0, transparent 47%, rgba(0,0,0,0.55) 49%);
  border-radius: 14px;
}
.cropper-mask::before {
  content: '';
  position: absolute;
  top: 50%; left: 50%;
  width: calc(95% * 1);
  aspect-ratio: 1;
  max-width: 94%;
  border: 2px solid var(--accent);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  box-shadow: 0 0 0 1px rgba(0,0,0,0.4);
}
.cropper-hint { font-size: 13px; color: var(--fg-dim); text-align: center; }
.cropper-zoom { display: flex; align-items: center; gap: 10px; width: 100%; max-width: 280px; }
.cropper-zoom button {
  background: var(--bg);
  color: var(--fg);
  border: 1px solid #2a2a44;
  width: 36px; height: 36px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 14px;
  display: flex; align-items: center; justify-content: center;
}
.cropper-zoom button:active { background: #2a2a44; }
.cropper-zoom input[type="range"] {
  flex: 1;
  accent-color: var(--accent);
  height: 4px;
}

/* ====================================================================
   DRIVE MODE — toggle button + active state
   ==================================================================== */
.drive-toggle.active {
  background: var(--accent);
  color: var(--bg);
  border-color: var(--accent);
}
.drive-toggle.active svg { color: var(--bg); }

/* When drive mode active — make hit targets bigger, status more visible */
html.drive-mode .ptt,
html.drive-mode .action-btn {
  width: 64px; height: 64px;
}
html.drive-mode .status-bar {
  padding: 8px 16px;
  font-size: 14px;
  font-weight: 600;
}
html.drive-mode .status-bar #status.live {
  color: var(--accent);
}
html.drive-mode body {
  /* Subtle pulse to remind user it's in drive mode */
  background: linear-gradient(180deg, var(--bg) 0%, #1a1a3e 100%);
}
html.drive-mode .topbar {
  background: linear-gradient(135deg, var(--bg-2), #1d1d3f);
}

/* Hide accessibility floating button on chat page (overlaps action button).
   It still works on login + legal pages. */
body:has(#chatbox) .a11y-button,
body:has(#chatbox) .a11y-panel {
  display: none !important;
}

/* ====================================================================
   FOOTER (all pages)
   ==================================================================== */
.page-footer {
  padding: 18px 16px calc(16px + var(--safe-bottom));
  text-align: center;
  background: var(--bg-2);
  border-top: 1px solid var(--border);
  font-size: 13px;
  color: var(--fg-dim);
}
.page-footer .legal-links { margin-bottom: 8px; }
.page-footer .legal-links a {
  color: var(--fg-dim);
  text-decoration: none;
  padding: 0 4px;
}
.page-footer .legal-links a:hover,
.page-footer .legal-links a:focus { color: var(--accent); text-decoration: underline; }
.page-footer .credit {
  display: inline-block;
  font-size: 11px;
  color: var(--fg-dim);
  text-decoration: none;
  opacity: 0.7;
}
.page-footer .credit:hover { color: var(--accent); opacity: 1; }

/* ====================================================================
   LEGAL PAGES (privacy, terms, accessibility)
   ==================================================================== */
body.legal-page {
  display: block;
  height: auto;
  min-height: 100dvh;
  overflow: visible;
  padding: 0;
  background: var(--bg);
}
/* And the html element — let it scroll on legal pages (selector :has supported in modern browsers) */
html:has(body.legal-page) {
  height: auto;
  overflow: auto;
}

.legal-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  background: var(--bg-2);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}
.legal-topbar h1 {
  font-size: 18px;
  font-weight: 600;
  color: var(--fg);
}
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--fg-dim);
  text-decoration: none;
  font-size: 14px;
  padding: 6px 10px;
  border-radius: 8px;
  transition: background 0.15s, color 0.15s;
}
.back-link:hover, .back-link:focus { background: var(--bg); color: var(--fg); }
.back-link svg { transform: scaleX(-1); /* RTL: arrow points right (back) */ }

.legal-content {
  max-width: 720px;
  margin: 0 auto;
  padding: 24px 20px 40px;
  line-height: 1.75;
  color: var(--fg);
}
.legal-content .legal-meta {
  color: var(--fg-dim);
  font-size: 13px;
  margin-bottom: 24px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}
.legal-content h2 {
  font-size: 22px;
  margin: 32px 0 12px;
  color: var(--accent);
}
.legal-content h3 {
  font-size: 17px;
  margin: 20px 0 8px;
  color: var(--fg);
}
.legal-content p { margin: 8px 0; }
.legal-content ul {
  margin: 8px 24px 16px 0;
  padding-right: 0;
}
.legal-content ul ul { margin: 4px 24px 4px 0; }
.legal-content li { margin: 4px 0; }
.legal-content a {
  color: var(--accent);
  text-decoration: underline;
}
.legal-content a:hover { color: var(--accent-2); }
.legal-content code {
  background: var(--bg-2);
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 90%;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
}
.legal-content strong { color: var(--accent-2); }

/* ====================================================================
   ACCESSIBILITY WIDGET
   ==================================================================== */
.a11y-button {
  position: fixed;
  bottom: calc(20px + var(--safe-bottom));
  left: 16px;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--bg);
  border: 2px solid var(--bg-2);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 1000;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
  transition: transform 0.15s, box-shadow 0.15s;
}
.a11y-button:hover { transform: scale(1.05); box-shadow: 0 6px 24px rgba(0, 0, 0, 0.5); }
.a11y-button:focus { outline: 3px solid var(--accent-2); outline-offset: 2px; }

.a11y-panel {
  position: fixed;
  bottom: calc(76px + var(--safe-bottom));
  left: 16px;
  width: 280px;
  max-width: calc(100vw - 32px);
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6);
  z-index: 1001;
  padding: 16px;
  color: var(--fg);
}
.a11y-panel-head {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}
.a11y-panel-head h2 { font-size: 17px; font-weight: 600; }
.a11y-close {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--fg);
  width: 28px; height: 28px;
  border-radius: 50%;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}
.a11y-close:hover { background: var(--bg); }

.a11y-row { margin-bottom: 10px; }
.a11y-label { display: block; font-size: 13px; color: var(--fg-dim); margin-bottom: 6px; }

.a11y-buttons { display: flex; gap: 4px; }
.a11y-buttons button {
  flex: 1;
  padding: 8px 4px;
  background: var(--bg);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  cursor: pointer;
}
.a11y-buttons button.active {
  background: var(--accent);
  color: var(--bg);
  border-color: var(--accent);
  font-weight: 600;
}

.a11y-toggle, .a11y-reset {
  width: 100%;
  padding: 10px 12px;
  background: var(--bg);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  cursor: pointer;
  text-align: right;
  font-family: inherit;
}
.a11y-toggle:hover, .a11y-reset:hover { background: #161628; }
.a11y-toggle.active {
  background: var(--accent);
  color: var(--bg);
  border-color: var(--accent);
  font-weight: 600;
}
.a11y-reset { color: var(--fg-dim); margin-top: 8px; }

.a11y-footer {
  margin-top: 14px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  text-align: center;
  font-size: 12px;
}
.a11y-footer a { color: var(--accent); text-decoration: none; }
.a11y-footer a:hover { text-decoration: underline; }

/* === Accessibility prefs (applied to <html>) === */
html.a11y-contrast {
  --bg: #000;
  --bg-2: #0a0a0a;
  --fg: #fff;
  --fg-dim: #ddd;
  --accent: #ffd700;
  --accent-2: #ffe680;
  --border: #fff;
}
html.a11y-greyscale {
  filter: grayscale(100%);
}
html.a11y-link-emph a {
  text-decoration: underline !important;
  font-weight: 700 !important;
  color: var(--accent) !important;
}
html.a11y-reduce-motion *,
html.a11y-reduce-motion *::before,
html.a11y-reduce-motion *::after {
  animation-duration: 0s !important;
  transition-duration: 0s !important;
}

/* Respect system pref */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0s !important;
    transition-duration: 0s !important;
  }
}

