/* === Reset & Base === */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --color-primary: #4a90d9;
  --color-primary-dark: #3570b0;
  --color-danger: #d9534f;
  --color-danger-bg: rgba(217, 83, 79, 0.1);
  --color-bg: #f5f7fa;
  --color-surface: #ffffff;
  --color-text: #2c3e50;
  --color-text-light: #6c7a89;
  --color-border: #e1e8ed;
  --color-student-bubble: #e8f4fd;
  --color-anjana-bubble: #ffffff;
  --color-banner: #fff3cd;
  --color-banner-text: #856404;
  --color-input-bg: #ffffff;
  --color-error: #d9534f;
  --banner-height: 36px;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.12);
  --transition: 0.2s ease;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --color-bg: #1a1d23;
    --color-surface: #2a2d35;
    --color-text: #e4e6ea;
    --color-text-light: #9ca3af;
    --color-border: #3a3d45;
    --color-student-bubble: #2a3a4a;
    --color-anjana-bubble: #2a2d35;
    --color-banner: #3d3520;
    --color-banner-text: #ffc107;
    --color-input-bg: #2a2d35;
    --color-primary: #5a9fe6;
    --color-primary-dark: #4a90d9;
    --color-danger-bg: rgba(217, 83, 79, 0.15);
  }
}

html, body {
  height: 100%;
  overflow: hidden;
}

body {
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  color: var(--color-text);
  background: var(--color-bg);
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
  touch-action: manipulation;
}

/* === AI Disclosure Banner === */
.ai-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  padding: 8px 16px;
  background: var(--color-banner);
  color: var(--color-banner-text);
  text-align: center;
  font-size: 13px;
  font-weight: 500;
  height: var(--banner-height);
}

/* === Screens === */
.screen {
  display: none;
  position: fixed;
  top: var(--banner-height);
  left: 0;
  right: 0;
  bottom: 0;
  overflow-y: auto;
}

.screen.active {
  display: flex;
  flex-direction: column;
}

.screen-content {
  max-width: 480px;
  width: 100%;
  margin: 0 auto;
  padding: 32px 24px;
}

/* === Logo Area === */
.logo-area {
  text-align: center;
  margin-bottom: 32px;
}

.logo {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  margin-bottom: 12px;
}

.logo-area h1 {
  font-size: 28px;
  font-weight: 700;
  color: var(--color-text);
}

.subtitle {
  color: var(--color-text-light);
  font-size: 15px;
}

/* === Student List === */
.student-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
}

.student-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  cursor: pointer;
  min-height: 56px;
  transition: box-shadow var(--transition), transform var(--transition);
}

.student-card:hover,
.student-card:focus-visible {
  box-shadow: var(--shadow);
  transform: translateY(-1px);
}

.student-card:active {
  transform: translateY(0);
}

.student-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--color-primary);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 18px;
  flex-shrink: 0;
}

.student-card-name {
  font-size: 17px;
  font-weight: 500;
}

.student-card.face-match {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary);
}

.student-list-empty {
  text-align: center;
  padding: 24px;
  color: var(--color-text-light);
  font-size: 15px;
}

/* === App Version Label === */
.app-version {
  display: block;
  text-align: center;
  margin-top: 24px;
  font-size: 12px;
  color: var(--color-text-light);
  opacity: 0.6;
}

/* === Forms === */
form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

label {
  font-size: 14px;
  font-weight: 500;
  color: var(--color-text-light);
}

input[type="text"],
input[type="number"],
input[type="password"] {
  width: 100%;
  padding: 14px 16px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: 16px;
  font-family: var(--font);
  background: var(--color-input-bg);
  color: var(--color-text);
  transition: border-color var(--transition);
  min-height: 48px;
}

input:focus {
  outline: none;
  border-color: var(--color-primary);
}

.consent-box {
  margin-top: 8px;
  padding: 16px;
  background: var(--color-bg);
  border-radius: var(--radius-sm);
}

.checkbox-label {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  cursor: pointer;
  font-size: 14px;
  line-height: 1.4;
  color: var(--color-text);
}

.checkbox-label input[type="checkbox"] {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  margin-top: 2px;
  accent-color: var(--color-primary);
}

.form-actions {
  display: flex;
  gap: 12px;
  margin-top: 8px;
}

.form-actions .btn {
  flex: 1;
}

.error-text {
  color: var(--color-error);
  font-size: 14px;
  min-height: 20px;
}

/* === Buttons === */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 14px 24px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 16px;
  font-weight: 500;
  font-family: var(--font);
  cursor: pointer;
  min-height: 48px;
  transition: background var(--transition), opacity var(--transition);
}

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

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

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

.btn-secondary {
  background: var(--color-surface);
  color: var(--color-primary);
  border: 1px solid var(--color-border);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--color-bg);
}

.btn-ghost {
  background: transparent;
  color: var(--color-text-light);
}

.btn-ghost:hover:not(:disabled) {
  background: var(--color-bg);
  color: var(--color-text);
}

.btn-danger {
  background: transparent;
  color: var(--color-danger);
}

.btn-danger:hover:not(:disabled) {
  background: var(--color-danger-bg);
}

.btn-icon {
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 8px;
  color: white;
  min-width: 40px;
  min-height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
}

.btn-icon:hover {
  background: rgba(255, 255, 255, 0.15);
}

/* === Chat Screen (class-based for consistent specificity) === */
.screen-chat {
  display: none;
  flex-direction: column;
}

.screen-chat.active {
  display: flex;
}

.chat-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: var(--color-primary);
  color: white;
  flex-shrink: 0;
}

.chat-header-info {
  display: flex;
  flex-direction: column;
}

.chat-header-name {
  font-weight: 600;
  font-size: 17px;
}

.chat-header-status {
  font-size: 12px;
  opacity: 0.85;
}

/* === Chat Messages === */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.message {
  max-width: 85%;
  padding: 12px 16px;
  border-radius: 18px;
  font-size: 15px;
  line-height: 1.5;
  word-wrap: break-word;
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

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

.message-anjana {
  align-self: flex-start;
  background: var(--color-anjana-bubble);
  border: 1px solid var(--color-border);
  border-bottom-left-radius: 4px;
}

.message-system {
  align-self: center;
  background: transparent;
  color: var(--color-text-light);
  font-size: 13px;
  text-align: center;
  max-width: 100%;
}

/* History separator */
.history-separator {
  align-self: center;
  color: var(--color-text-light);
  font-size: 12px;
  text-align: center;
  padding: 8px 0;
  width: 100%;
  opacity: 0.7;
}

/* Typing indicator */
.typing-indicator {
  display: inline-flex;
  gap: 4px;
  padding: 12px 16px;
  align-self: flex-start;
  background: var(--color-anjana-bubble);
  border: 1px solid var(--color-border);
  border-radius: 18px;
  border-bottom-left-radius: 4px;
}

.typing-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--color-text-light);
  animation: typingBounce 1.2s infinite;
}

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

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

/* === Chat Input === */
.chat-input-area {
  padding: 8px 12px;
  border-top: 1px solid var(--color-border);
  background: var(--color-surface);
  flex-shrink: 0;
}

.chat-input-form {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  flex-direction: row;
}

#input-message {
  flex: 1;
  border: 1px solid var(--color-border);
  border-radius: 24px;
  padding: 12px 18px;
  font-size: 16px;
  font-family: var(--font);
  resize: none;
  max-height: 120px;
  min-height: 48px;
  line-height: 1.4;
  background: var(--color-input-bg);
  color: var(--color-text);
  overflow-y: auto;
}

#input-message:focus {
  outline: none;
  border-color: var(--color-primary);
}

.btn-send {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: none;
  background: var(--color-primary);
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background var(--transition);
}

.btn-send:hover:not(:disabled) {
  background: var(--color-primary-dark);
}

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

/* === Voice Button (mic) === */
.btn-voice {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: none;
  background: var(--color-surface);
  color: var(--color-text-light);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background var(--transition), color var(--transition), box-shadow var(--transition);
  border: 1px solid var(--color-border);
}

.btn-voice:hover:not(:disabled) {
  background: var(--color-bg);
  color: var(--color-text);
}

.btn-voice--listening {
  background: #d9534f;
  color: white;
  border-color: #d9534f;
  animation: voicePulse 1.5s ease-in-out infinite;
}

.btn-voice--listening:hover {
  background: #c9302c;
  color: white;
}

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

@keyframes voicePulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(217, 83, 79, 0.4); }
  50% { box-shadow: 0 0 0 8px rgba(217, 83, 79, 0); }
}

/* === Voice Toggle (header) === */
.voice-toggle {
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 8px;
  color: rgba(255, 255, 255, 0.5);
  min-width: 40px;
  min-height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  margin-left: auto;
  transition: color var(--transition), background var(--transition);
}

.voice-toggle:hover {
  background: rgba(255, 255, 255, 0.15);
  color: rgba(255, 255, 255, 0.8);
}

.voice-toggle--active {
  color: white;
}

.voice-toggle--active:hover {
  color: white;
}

/* === Camera Toggle (header) === */
.camera-toggle {
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 8px;
  color: rgba(255, 255, 255, 0.5);
  min-width: 40px;
  min-height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: color var(--transition), background var(--transition);
}

.camera-toggle:hover {
  background: rgba(255, 255, 255, 0.15);
  color: rgba(255, 255, 255, 0.8);
}

.camera-toggle--active {
  color: white;
}

/* === Camera PiP Preview === */
.camera-pip {
  position: fixed;
  bottom: 80px;
  right: 12px;
  width: 120px;
  height: 90px;
  border-radius: 8px;
  overflow: hidden;
  z-index: 40;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.3);
  border: 2px solid rgba(255, 255, 255, 0.2);
}

.camera-pip video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(-1);
}

.pip-close {
  position: absolute;
  top: 2px;
  right: 4px;
  background: rgba(0, 0, 0, 0.5);
  border: none;
  color: white;
  font-size: 16px;
  line-height: 1;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.camera-dot {
  position: absolute;
  bottom: 4px;
  left: 6px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.camera-dot--loading {
  background: #f0ad4e;
  animation: cameraPulse 1.5s infinite;
}

.camera-dot--active {
  background: #5cb85c;
}

.camera-dot--error {
  background: #d9534f;
}

/* Floating dot when PiP is hidden but camera is active */
.camera-dot-floating {
  position: fixed;
  bottom: 80px;
  right: 16px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #5cb85c;
  z-index: 40;
  animation: cameraPulse 2s infinite;
  cursor: pointer;
}

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

/* === Face Enrollment Screen === */
.enroll-content {
  max-width: 420px;
}

.enroll-instruction {
  font-size: 16px;
  color: var(--text-secondary);
  min-height: 24px;
  margin-bottom: 12px;
  text-align: center;
}

.enroll-camera-area {
  position: relative;
  width: 100%;
  max-width: 320px;
  margin: 0 auto 16px;
  border-radius: 12px;
  overflow: hidden;
  background: #1a1d23;
  aspect-ratio: 4/3;
}

.enroll-camera-area video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(-1);
}

.enroll-camera-area canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.enroll-face-status {
  position: absolute;
  bottom: 8px;
  left: 50%;
  transform: translateX(-50%);
  padding: 4px 12px;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 500;
  background: rgba(0,0,0,0.6);
  color: #fff;
}

.enroll-face-status.detected {
  background: rgba(34,139,34,0.8);
}

.enroll-face-status.no-face {
  background: rgba(180,60,60,0.8);
}

.enroll-progress {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-bottom: 16px;
}

.enroll-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--border);
  transition: background 0.3s;
}

.enroll-dot.captured {
  background: var(--primary);
}

.enroll-dot.active {
  background: var(--primary);
  animation: cameraPulse 1s infinite;
}

/* === Side Menu === */
.side-menu {
  display: none;
  position: fixed;
  top: var(--banner-height);
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 50;
}

.side-menu.open {
  display: block;
}

.side-menu-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
}

.side-menu-panel {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 280px;
  background: var(--color-surface);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  animation: slideIn 0.2s ease;
}

@keyframes slideIn {
  from { transform: translateX(-100%); }
  to { transform: translateX(0); }
}

.side-menu-header {
  padding: 20px;
  font-size: 18px;
  font-weight: 600;
  border-bottom: 1px solid var(--color-border);
}

.menu-item {
  width: 100%;
  text-align: left;
  padding: 16px 20px;
  border-radius: 0;
  font-size: 15px;
}

.menu-divider {
  height: 1px;
  background: var(--color-border);
  margin: 8px 20px;
}

.menu-item-danger {
  color: var(--color-danger);
  font-weight: 500;
}

.menu-item-danger::before {
  content: "\26A0\FE0F";
  margin-right: 8px;
}

.menu-item-danger:hover:not(:disabled),
.menu-item-danger:focus-visible {
  background: var(--color-danger-bg);
  color: var(--color-danger);
}

/* Language row inside side menu */
.lang-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  gap: 12px;
  border-bottom: 1px solid var(--color-border);
}

.lang-label {
  font-size: 14px;
  color: var(--color-text-muted, #888);
  white-space: nowrap;
}

.lang-switch {
  display: flex;
  border: 1px solid var(--color-border);
  border-radius: 20px;
  overflow: hidden;
  flex-shrink: 0;
}

.lang-btn {
  padding: 4px 14px;
  font-size: 13px;
  font-weight: 600;
  border: none;
  background: transparent;
  color: var(--color-text-muted, #888);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  line-height: 1.6;
}

.lang-btn.active {
  background: var(--color-primary);
  color: #fff;
  border-radius: 20px;
}

.lang-btn:hover:not(.active) {
  background: var(--color-surface-alt, rgba(0, 0, 0, 0.05));
  color: var(--color-text);
}

/* Language selector in create-student form */
#input-language {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-surface);
  color: var(--color-text);
  font-size: 16px;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  cursor: pointer;
}

#input-language:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(74, 144, 217, 0.15);
}

/* === Modal === */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(0, 0, 0, 0.5);
  align-items: center;
  justify-content: center;
}

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

.modal-box {
  background: var(--color-surface);
  border-radius: var(--radius);
  padding: 24px;
  max-width: 360px;
  width: 90%;
  box-shadow: var(--shadow-lg);
}

.modal-box h3 {
  margin-bottom: 8px;
  font-size: 18px;
}

.modal-box p {
  color: var(--color-text-light);
  font-size: 14px;
  margin-bottom: 16px;
  line-height: 1.4;
}

.modal-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  margin-top: 16px;
}

/* === Visual Aids: Rendered Markdown in Messages === */

.message-anjana p {
  margin: 0.4em 0;
}
.message-anjana p:first-child {
  margin-top: 0;
}
.message-anjana p:last-child {
  margin-bottom: 0;
}

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

.message-anjana ul,
.message-anjana ol {
  margin: 0.4em 0;
  padding-left: 1.5em;
}

.message-anjana li {
  margin: 0.2em 0;
}

.message-anjana blockquote {
  margin: 0.5em 0;
  padding: 0.4em 0.8em;
  border-left: 3px solid var(--color-primary);
  background: var(--color-bg);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.message-anjana h1,
.message-anjana h2,
.message-anjana h3,
.message-anjana h4 {
  margin: 0.6em 0 0.3em;
  line-height: 1.3;
}
.message-anjana h1 { font-size: 1.2em; }
.message-anjana h2 { font-size: 1.1em; }
.message-anjana h3 { font-size: 1.05em; }
.message-anjana h4 { font-size: 1em; }

.message-anjana hr {
  border: none;
  border-top: 1px solid var(--color-border);
  margin: 0.8em 0;
}

/* Disabled links (child safety) */
.message-anjana .disabled-link {
  color: var(--color-primary);
  text-decoration: underline;
  cursor: default;
  pointer-events: none;
}

/* Tables -- wrapper approach for horizontal scroll without breaking border-collapse */
.message-anjana table {
  border-collapse: collapse;
  width: 100%;
  margin: 0.5em 0;
  font-size: 0.9em;
}

.message-anjana .table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.message-anjana th,
.message-anjana td {
  border: 1px solid var(--color-border);
  padding: 6px 10px;
  text-align: left;
}

.message-anjana th {
  background: var(--color-bg);
  font-weight: 600;
}

.message-anjana tr:nth-child(even) td {
  background: var(--color-bg);
}

/* === Visual Aids: KaTeX Math === */

.message-anjana .katex-display {
  margin: 0.6em 0;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 0.3em 0;
  -webkit-overflow-scrolling: touch;
}

.message-anjana .katex {
  font-size: 1.05em;
}

.message-anjana .katex-error {
  color: var(--color-danger);
  font-family: monospace;
  font-size: 0.85em;
  background: var(--color-danger-bg);
  padding: 2px 6px;
  border-radius: 4px;
}

/* === Visual Aids: Code Blocks (Prism.js) === */

.message-anjana pre {
  margin: 0.5em 0;
  border-radius: var(--radius-sm);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  max-height: 400px;
  overflow-y: auto;
  position: relative;
}

.message-anjana pre > code {
  display: block;
  padding: 12px 14px;
  font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', Consolas, monospace;
  font-size: 0.85em;
  line-height: 1.5;
  tab-size: 2;
  background: #f6f8fa;
  border-radius: var(--radius-sm);
}

.message-anjana code:not(pre code) {
  font-family: 'SF Mono', 'Fira Code', Consolas, monospace;
  font-size: 0.88em;
  background: rgba(0, 0, 0, 0.06);
  padding: 1px 5px;
  border-radius: 4px;
}

/* === Visual Aids: Mermaid Diagrams === */

.message-anjana .mermaid-rendered {
  margin: 0.6em 0;
  text-align: center;
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  touch-action: manipulation;
}

.message-anjana .mermaid-rendered svg {
  max-width: 100%;
  height: auto;
}

.message-anjana pre.mermaid-error {
  border: 1px dashed var(--color-danger);
  position: relative;
}

.message-anjana pre.mermaid-error::before {
  content: "Diagram could not be rendered";
  display: block;
  font-family: var(--font);
  font-size: 0.8em;
  color: var(--color-danger);
  margin-bottom: 4px;
}

/* === Visual Aids: AI-Generated Images === */

.ai-image-placeholder {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  margin: 0.6em 0;
  background: rgba(0, 0, 0, 0.04);
  border-radius: var(--radius-sm);
  color: var(--color-text-muted, #666);
  font-size: 0.9em;
}

.ai-image-spinner {
  width: 20px;
  height: 20px;
  border: 2px solid rgba(0, 0, 0, 0.1);
  border-top-color: var(--color-primary, #4a90d9);
  border-radius: 50%;
  animation: ai-spin 0.8s linear infinite;
}

@keyframes ai-spin {
  to { transform: rotate(360deg); }
}

.ai-image-loading-text {
  flex: 1;
}

.ai-image-ready {
  margin: 0.6em 0;
  text-align: center;
}

.ai-image-ready img {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius-sm);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
}

.ai-image-ready figcaption {
  margin-top: 6px;
  font-size: 0.85em;
  color: var(--color-text-muted, #666);
  font-style: italic;
}

.ai-image-error {
  margin: 0.6em 0;
  padding: 10px 14px;
  background: rgba(220, 53, 69, 0.08);
  border: 1px dashed var(--color-danger, #dc3545);
  border-radius: var(--radius-sm);
  color: var(--color-danger, #dc3545);
  font-size: 0.85em;
}

/* === Visual Aids: Dark Mode Overrides === */

@media (prefers-color-scheme: dark) {
  .message-anjana pre > code {
    background: #1e2128;
  }

  .message-anjana code:not(pre code) {
    background: rgba(255, 255, 255, 0.1);
  }

  .message-anjana blockquote {
    background: rgba(255, 255, 255, 0.04);
  }

  .message-anjana th {
    background: rgba(255, 255, 255, 0.06);
  }

  .message-anjana tr:nth-child(even) td {
    background: rgba(255, 255, 255, 0.03);
  }

  /* Prism dark theme overrides */
  .message-anjana pre > code[class*="language-"] {
    color: #e4e6ea;
  }
  .message-anjana .token.comment,
  .message-anjana .token.prolog,
  .message-anjana .token.doctype,
  .message-anjana .token.cdata {
    color: #7c8594;
  }
  .message-anjana .token.keyword {
    color: #c792ea;
  }
  .message-anjana .token.string,
  .message-anjana .token.attr-value {
    color: #c3e88d;
  }
  .message-anjana .token.number,
  .message-anjana .token.boolean {
    color: #f78c6c;
  }
  .message-anjana .token.function {
    color: #82aaff;
  }
  .message-anjana .token.operator {
    color: #89ddff;
  }
  .message-anjana .token.punctuation {
    color: #89ddff;
  }
  .message-anjana .token.class-name {
    color: #ffcb6b;
  }

  /* Mermaid dark theme */
  .message-anjana .mermaid-rendered text {
    fill: var(--color-text) !important;
  }

  /* AI image dark theme */
  .ai-image-placeholder {
    background: rgba(255, 255, 255, 0.06);
  }

  .ai-image-spinner {
    border-color: rgba(255, 255, 255, 0.15);
    border-top-color: var(--color-primary, #4a90d9);
  }

  .ai-image-ready img {
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
  }

  .ai-image-error {
    background: rgba(220, 53, 69, 0.12);
  }
}

/* === Responsive === */
@media (min-width: 768px) {
  .screen-content {
    padding: 48px 24px;
  }

  .message {
    max-width: 70%;
  }
}

@media (max-height: 500px) {
  .logo-area {
    margin-bottom: 16px;
  }
  .logo {
    width: 48px;
    height: 48px;
  }
}

/* === Reduced Motion === */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
  .btn-voice--listening {
    box-shadow: 0 0 0 3px rgba(217, 83, 79, 0.5);
    animation: none;
  }
}
