/* ============================================================
   English-Urdu Companion — Responsive Mobile-First Stylesheet
   Style: Flat Design (Touch-First) + Minimalism
   Breakpoints: 320 / 375 / 414 / 768 / 1024 / 1440
   ============================================================ */

/* ---------- Design Tokens ---------- */
:root {
  /* Brand colors — Learning indigo + progress green */
  --color-primary: #4F46E5;
  --color-primary-dark: #4338CA;
  --color-primary-light: #818CF8;
  --color-secondary: #10B981;
  --color-accent: #16A34A;
  --color-danger: #EF4444;
  --color-warning: #F59E0B;

  /* Surfaces — light mode */
  --color-bg: #F3F4F6;
  --color-surface: #FFFFFF;
  --color-surface-alt: #F9FAFB;
  --color-text: #111827;
  --color-text-secondary: #6B7280;
  --color-text-light: #9CA3AF;
  --color-border: #E5E7EB;
  --color-border-strong: #D1D5DB;

  /* Chat */
  --color-user-msg: #4F46E5;
  --color-user-msg-text: #FFFFFF;
  --color-bot-msg: #FFFFFF;
  --color-bot-msg-text: #111827;

  /* Correction */
  --color-correction-bg: #FEF3C7;
  --color-correction-border: #F59E0B;
  --color-correction-correct: #16A34A;
  --color-correction-wrong: #9CA3AF;
  --color-urdu: #7C3AED;

  /* Spacing — 4px base rhythm */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;

  /* Radius */
  --radius-sm: 0.375rem;
  --radius-md: 0.5rem;
  --radius-lg: 0.75rem;
  --radius-xl: 1rem;
  --radius-2xl: 1.5rem;
  --radius-full: 9999px;

  /* Touch target */
  --touch-min: 44px;

  /* Shadows — minimal (flat design) */
  --shadow-xs: 0 1px 2px 0 rgba(0,0,0,0.05);
  --shadow-sm: 0 1px 3px 0 rgba(0,0,0,0.08);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.08);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.10);

  /* Layout */
  --header-h: 56px;
  --input-h: 64px;
  --max-w: 768px;

  /* Motion */
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --dur-fast: 150ms;
  --dur-base: 200ms;
  --dur-slow: 300ms;
}

/* ---------- Dark Mode ---------- */
@media (prefers-color-scheme: dark) {
  :root {
    --color-bg: #0F172A;
    --color-surface: #1E293B;
    --color-surface-alt: #334155;
    --color-text: #F1F5F9;
    --color-text-secondary: #94A3B8;
    --color-text-light: #64748B;
    --color-border: #334155;
    --color-border-strong: #475569;
    --color-bot-msg: #1E293B;
    --color-bot-msg-text: #F1F5F9;
    --color-correction-bg: #422006;
    --color-correction-border: #F59E0B;
    --color-correction-wrong: #64748B;
    --shadow-xs: 0 1px 2px 0 rgba(0,0,0,0.3);
    --shadow-sm: 0 1px 3px 0 rgba(0,0,0,0.4);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.4);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.5);
  }
}

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

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.5;
  /* dvh handles mobile browser chrome; fallback to vh */
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ---------- App Shell ---------- */
#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  max-width: var(--max-w);
  margin: 0 auto;
  background: var(--color-bg);
  /* Safe area insets for notched devices */
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}

/* ---------- Header ---------- */
.header {
  flex-shrink: 0;
  height: var(--header-h);
  min-height: var(--touch-min);
  background: var(--color-primary);
  color: #fff;
  padding: var(--space-2) var(--space-3);
  padding-top: env(safe-area-inset-top);
  box-shadow: var(--shadow-sm);
  z-index: 100;
}

.header-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  height: 100%;
}

.logo { display: flex; align-items: center; gap: var(--space-2); min-width: 0; }

.logo-icon {
  flex-shrink: 0;
  width: 36px; height: 36px;
  display: grid; place-items: center;
  color: #fff;
}

.logo-text { min-width: 0; }

.logo-text h1 {
  font-size: 0.95rem;
  font-weight: 700;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.subtitle {
  font-size: 0.7rem;
  opacity: 0.85;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header-actions { display: flex; gap: var(--space-1); flex-shrink: 0; }

.icon-btn {
  width: var(--touch-min);
  height: var(--touch-min);
  min-width: var(--touch-min);
  min-height: var(--touch-min);
  border: none;
  background: rgba(255,255,255,0.15);
  color: #fff;
  border-radius: var(--radius-md);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: background var(--dur-base) var(--ease), transform var(--dur-fast) var(--ease);
}
.icon-btn:hover { background: rgba(255,255,255,0.25); }
.icon-btn:active { transform: scale(0.94); }
.icon-btn:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }

/* ---------- Chat Container ---------- */
.chat-container {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  position: relative;
}

/* ---------- Welcome Screen ---------- */
.welcome-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100%;
  padding: var(--space-6) var(--space-4);
  text-align: center;
}

.welcome-content { max-width: 420px; width: 100%; }

.welcome-icon {
  color: var(--color-primary);
  margin-bottom: var(--space-5);
  animation: float 3s var(--ease) infinite;
}
@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

.welcome-content h2 {
  font-size: 1.4rem;
  font-weight: 700;
  margin-bottom: var(--space-3);
  line-height: 1.3;
}

.welcome-text {
  color: var(--color-text-secondary);
  font-size: 0.95rem;
  margin-bottom: var(--space-3);
}

.welcome-text.urdu {
  font-family: 'Noto Nastaliq Urdu', serif;
  direction: rtl;
  color: var(--color-urdu);
  font-size: 1.05rem;
  line-height: 2;
  margin-bottom: var(--space-5);
}

/* ---------- Features Grid ---------- */
.features {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-2);
  margin-bottom: var(--space-6);
}

.feature {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  background: var(--color-surface);
  padding: var(--space-3);
  border-radius: var(--radius-lg);
  border: 1px solid var(--color-border);
  font-size: 0.8rem;
  font-weight: 500;
  text-align: left;
}

.feature-icon {
  flex-shrink: 0;
  width: 32px; height: 32px;
  display: grid; place-items: center;
  background: var(--color-primary);
  color: #fff;
  border-radius: var(--radius-md);
}

/* ---------- Chat Messages ---------- */
.chat-messages {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-3);
  padding-bottom: calc(var(--space-4) + env(safe-area-inset-bottom));
  min-height: 100%;
}

.message {
  display: flex;
  gap: var(--space-2);
  max-width: 88%;
  animation: msgIn var(--dur-slow) var(--ease);
}
@keyframes msgIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.message.user { flex-direction: row-reverse; margin-left: auto; }

.message-avatar {
  flex-shrink: 0;
  width: 32px; height: 32px;
  border-radius: var(--radius-full);
  display: grid; place-items: center;
  font-size: 0.75rem;
  font-weight: 700;
  color: #fff;
}
.message.user .message-avatar { background: var(--color-primary-light); }
.message.bot .message-avatar { background: var(--color-secondary); }

.message-content {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  min-width: 0;
}

.message-bubble {
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-xl);
  word-wrap: break-word;
  overflow-wrap: break-word;
  word-break: break-word;
  font-size: 0.95rem;
  line-height: 1.5;
  box-shadow: var(--shadow-xs);
}

.message.user .message-bubble {
  background: var(--color-user-msg);
  color: var(--color-user-msg-text);
  border-bottom-right-radius: var(--radius-sm);
}
.message.bot .message-bubble {
  background: var(--color-bot-msg);
  color: var(--color-bot-msg-text);
  border-bottom-left-radius: var(--radius-sm);
}

.message-time {
  font-size: 0.68rem;
  color: var(--color-text-light);
  padding: 0 var(--space-1);
}
.message.user .message-time { text-align: right; }

/* ---------- Correction Box ---------- */
.correction-box {
  background: var(--color-correction-bg);
  border-left: 3px solid var(--color-correction-border);
  padding: var(--space-3);
  border-radius: var(--radius-md);
  margin-top: var(--space-2);
  font-size: 0.88rem;
}

.correction-label {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  font-weight: 700;
  color: var(--color-warning);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: var(--space-2);
}
.correction-label svg { width: 14px; height: 14px; }

.correction-text {
  color: var(--color-correction-wrong);
  text-decoration: line-through;
}
.correction-arrow { margin: 0 var(--space-1); color: var(--color-warning); }
.correction-corrected { color: var(--color-correction-correct); font-weight: 600; }

.correction-explanation {
  margin-top: var(--space-2);
  padding-top: var(--space-2);
  border-top: 1px dashed var(--color-correction-border);
  font-size: 0.82rem;
  color: var(--color-text-secondary);
}
.correction-explanation.urdu {
  font-family: 'Noto Nastaliq Urdu', serif;
  direction: rtl;
  color: var(--color-urdu);
  line-height: 1.8;
}

/* ---------- Urdu Translation ---------- */
.urdu-translation {
  font-family: 'Noto Nastaliq Urdu', serif;
  direction: rtl;
  color: var(--color-urdu);
  font-size: 0.92rem;
  margin-top: var(--space-2);
  padding-top: var(--space-2);
  border-top: 1px solid var(--color-border);
  line-height: 1.9;
}

/* ---------- Typing Indicator ---------- */
.typing-indicator { padding: var(--space-2) var(--space-3); }

.typing-bubble {
  background: var(--color-bot-msg);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-xl);
  border-bottom-left-radius: var(--radius-sm);
  box-shadow: var(--shadow-xs);
  display: flex;
  gap: var(--space-1);
  align-items: center;
  width: fit-content;
}

.typing-bubble span {
  width: 8px; height: 8px;
  background: var(--color-text-light);
  border-radius: var(--radius-full);
  animation: typing 1.4s var(--ease) infinite;
}
.typing-bubble span:nth-child(2) { animation-delay: 0.2s; }
.typing-bubble span:nth-child(3) { animation-delay: 0.4s; }
@keyframes typing {
  0%, 100% { transform: translateY(0); opacity: 0.5; }
  50% { transform: translateY(-6px); opacity: 1; }
}

/* ---------- Input Area ---------- */
.input-area {
  flex-shrink: 0;
  background: var(--color-surface);
  border-top: 1px solid var(--color-border);
  padding: var(--space-2) var(--space-3);
  padding-bottom: calc(var(--space-2) + env(safe-area-inset-bottom));
}

.input-container {
  display: flex;
  align-items: flex-end;
  gap: var(--space-2);
  max-width: var(--max-w);
  margin: 0 auto;
}

.text-input-wrapper {
  flex: 1;
  position: relative;
  min-width: 0;
}

.message-input {
  width: 100%;
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-xl);
  padding: var(--space-3) var(--space-4);
  padding-right: calc(var(--space-4) + 56px);
  font-size: 16px; /* 16px prevents iOS zoom */
  font-family: inherit;
  resize: none;
  min-height: 44px;
  max-height: 120px;
  background: var(--color-surface-alt);
  color: var(--color-text);
  transition: border-color var(--dur-base) var(--ease), box-shadow var(--dur-base) var(--ease);
}
.message-input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(79,70,229,0.12);
}
.message-input::placeholder { color: var(--color-text-light); }

.char-count {
  position: absolute;
  right: var(--space-3);
  bottom: 50%;
  transform: translateY(50%);
  font-size: 0.68rem;
  color: var(--color-text-light);
  pointer-events: none;
}

.input-btn {
  width: 44px; height: 44px;
  min-width: 44px; min-height: 44px;
  border: none;
  border-radius: var(--radius-full);
  display: grid; place-items: center;
  cursor: pointer;
  transition: background var(--dur-base) var(--ease), transform var(--dur-fast) var(--ease);
  flex-shrink: 0;
}
.input-btn:active { transform: scale(0.92); }
.input-btn:focus-visible { outline: 2px solid var(--color-primary); outline-offset: 2px; }

.send-btn {
  background: var(--color-primary);
  color: #fff;
}
.send-btn:hover { background: var(--color-primary-dark); }
.send-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.voice-btn {
  background: var(--color-surface);
  border: 2px solid var(--color-primary);
  color: var(--color-primary);
}
.voice-btn:hover { background: var(--color-primary); color: #fff; }
.voice-btn.recording {
  background: var(--color-danger);
  border-color: var(--color-danger);
  color: #fff;
  animation: pulse 1.5s var(--ease) infinite;
}
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239,68,68,0.4); }
  50% { box-shadow: 0 0 0 12px rgba(239,68,68,0); }
}

/* ---------- Voice Wave ---------- */
.voice-wave {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 3px;
  height: 32px;
  margin-top: var(--space-2);
}

.wave-bar {
  width: 3px;
  background: var(--color-primary);
  border-radius: var(--radius-full);
  animation: wave-bar 0.9s var(--ease) infinite;
}
.wave-bar:nth-child(1) { height: 20%; animation-delay: 0s; }
.wave-bar:nth-child(2) { height: 50%; animation-delay: 0.1s; }
.wave-bar:nth-child(3) { height: 80%; animation-delay: 0.2s; }
.wave-bar:nth-child(4) { height: 50%; animation-delay: 0.3s; }
.wave-bar:nth-child(5) { height: 20%; animation-delay: 0.4s; }
@keyframes wave-bar {
  0%, 100% { transform: scaleY(0.5); }
  50% { transform: scaleY(1); }
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-5);
  border-radius: var(--radius-md);
  font-size: 0.95rem;
  font-weight: 600;
  font-family: inherit;
  border: none;
  cursor: pointer;
  transition: background var(--dur-base) var(--ease), transform var(--dur-fast) var(--ease);
  min-height: var(--touch-min);
}
.btn:active { transform: scale(0.97); }
.btn:focus-visible { outline: 2px solid var(--color-primary); outline-offset: 2px; }

.btn-primary { background: var(--color-primary); color: #fff; }
.btn-primary:hover { background: var(--color-primary-dark); }

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

.btn-large { padding: var(--space-4) var(--space-8); font-size: 1.05rem; width: 100%; }

/* ---------- Modal ---------- */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 1000;
  padding: 0;
  animation: fadeIn var(--dur-base) var(--ease);
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal.hidden { display: none; }

.modal-content {
  background: var(--color-surface);
  border-radius: var(--radius-2xl) var(--radius-2xl) 0 0;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: slideUp var(--dur-slow) var(--ease);
  padding-bottom: env(safe-area-inset-bottom);
}
@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--color-border);
}
.modal-header h3 { font-size: 1.1rem; font-weight: 700; }

.modal-close {
  width: 32px; height: 32px;
  background: none; border: none; cursor: pointer;
  color: var(--color-text-secondary);
  display: grid; place-items: center;
  border-radius: var(--radius-md);
  transition: background var(--dur-base) var(--ease);
}
.modal-close:hover { background: var(--color-surface-alt); }

.modal-body { padding: var(--space-5); }

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-2);
  padding: var(--space-4) var(--space-5);
  border-top: 1px solid var(--color-border);
}

/* ---------- Settings ---------- */
.setting-group { margin-bottom: var(--space-5); }
.setting-group:last-child { margin-bottom: 0; }

.setting-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 600;
  font-size: 0.95rem;
  margin-bottom: var(--space-1);
}

.setting-description {
  font-size: 0.82rem;
  color: var(--color-text-secondary);
  margin-top: var(--space-1);
}

.setting-input, .setting-select {
  width: 100%;
  padding: var(--space-3) var(--space-3);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-md);
  font-size: 16px;
  font-family: inherit;
  background: var(--color-surface-alt);
  color: var(--color-text);
}
.setting-input:focus, .setting-select:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(79,70,229,0.12);
}

/* ---------- Toggle Switch ---------- */
.switch {
  position: relative;
  display: inline-block;
  width: 44px; height: 24px;
  flex-shrink: 0;
}
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: var(--color-border-strong);
  transition: var(--dur-base) var(--ease);
  border-radius: var(--radius-full);
}
.slider::before {
  position: absolute;
  content: "";
  height: 18px; width: 18px;
  left: 3px; bottom: 3px;
  background: #fff;
  transition: var(--dur-base) var(--ease);
  border-radius: 50%;
  box-shadow: var(--shadow-sm);
}
.switch input:checked + .slider { background: var(--color-primary); }
.switch input:checked + .slider::before { transform: translateX(20px); }
.switch input:focus-visible + .slider { outline: 2px solid var(--color-primary); outline-offset: 2px; }

/* ---------- Toast ---------- */
.toast-container {
  position: fixed;
  bottom: calc(var(--input-h) + var(--space-4) + env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  z-index: 1100;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  width: calc(100% - var(--space-8));
  max-width: 400px;
  pointer-events: none;
}

.toast {
  background: var(--color-text);
  color: #fff;
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  font-size: 0.88rem;
  text-align: center;
  animation: toastIn var(--dur-slow) var(--ease);
  pointer-events: auto;
}
.toast.success { background: var(--color-secondary); }
.toast.error { background: var(--color-danger); }
.toast.warning { background: var(--color-warning); }
@keyframes toastIn {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---------- Utility ---------- */
.hidden { display: none !important; }
svg { display: block; }

/* ============================================================
   BREAKPOINTS — Progressive Enhancement
   ============================================================ */

/* ---------- Extra small phones (<= 360px) ---------- */
@media (max-width: 360px) {
  .logo-text h1 { font-size: 0.85rem; }
  .subtitle { font-size: 0.65rem; }
  .welcome-content h2 { font-size: 1.2rem; }
  .features { grid-template-columns: 1fr; }
  .message { max-width: 94%; }
  .message-bubble { font-size: 0.9rem; }
  .btn-large { font-size: 0.95rem; padding: var(--space-3) var(--space-6); }
}

/* ---------- Small phones (361px - 414px) ---------- */
@media (min-width: 361px) and (max-width: 414px) {
  .message { max-width: 90%; }
}

/* ---------- Tablets (>= 600px) ---------- */
@media (min-width: 600px) {
  :root {
    --header-h: 64px;
    --max-w: 768px;
  }
  .header { padding: var(--space-3) var(--space-5); }
  .logo-icon { width: 40px; height: 40px; }
  .logo-text h1 { font-size: 1.1rem; }
  .subtitle { font-size: 0.8rem; }
  .icon-btn { width: 40px; height: 40px; }
  .chat-messages { padding: var(--space-5) var(--space-5); gap: var(--space-4); }
  .message { max-width: 75%; }
  .message-bubble { font-size: 1rem; }
  .welcome-content h2 { font-size: 1.6rem; }
  .welcome-text { font-size: 1rem; }
  .feature { font-size: 0.9rem; padding: var(--space-4); }
  .input-area { padding: var(--space-3) var(--space-5); }
  .input-btn { width: 48px; height: 48px; }
  .input-btn svg { width: 24px; height: 24px; }
}

/* ---------- Desktop (>= 1024px) — modal becomes centered ---------- */
@media (min-width: 1024px) {
  :root { --max-w: 896px; }
  .modal { align-items: center; padding: var(--space-4); }
  .modal-content {
    max-width: 480px;
    border-radius: var(--radius-2xl);
  }
  @keyframes slideUp {
    from { opacity: 0; transform: translateY(-20px) scale(0.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
  }
  .welcome-content { max-width: 520px; }
  .features { grid-template-columns: repeat(4, 1fr); }
}

/* ---------- Landscape orientation ---------- */
@media (orientation: landscape) and (max-height: 500px) {
  :root { --header-h: 48px; }
  .header { padding: var(--space-1) var(--space-3); }
  .logo-text { display: none; }
  .welcome-screen { padding: var(--space-3); }
  .welcome-icon { margin-bottom: var(--space-2); }
  .welcome-content h2 { font-size: 1.1rem; margin-bottom: var(--space-2); }
  .welcome-text { font-size: 0.85rem; margin-bottom: var(--space-2); }
  .features { margin-bottom: var(--space-3); }
  .feature { padding: var(--space-2); font-size: 0.75rem; }
  .feature-icon { width: 24px; height: 24px; }
  .input-area { padding: var(--space-1) var(--space-3); }
  .voice-wave { height: 20px; margin-top: var(--space-1); }
}

/* ---------- Large desktop (>= 1440px) ---------- */
@media (min-width: 1440px) {
  :root { --max-w: 960px; }
}

/* ---------- Print ---------- */
@media print {
  .header, .input-area, .modal, .toast-container { display: none !important; }
  .chat-container { overflow: visible; }
  .message-bubble { box-shadow: none; border: 1px solid #ccc; }
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .welcome-icon, .wave-bar, .typing-bubble span { animation: none !important; }
}

/* ---------- Touch device optimizations ---------- */
@media (hover: none) {
  .icon-btn:hover, .input-btn:hover, .btn:hover, .voice-btn:hover {
    background: inherit;
    transform: none;
  }
  .icon-btn:active { transform: scale(0.94); }
  .send-btn:active { transform: scale(0.92); }
}

/* ---------- High contrast ---------- */
@media (prefers-contrast: high) {
  :root {
    --color-border: #000000;
    --color-border-strong: #000000;
    --color-text-secondary: #000000;
  }
}

/* ---------- Selection ---------- */
::selection { background: var(--color-primary); color: #fff; }

/* ---------- Scrollbar (WebKit) ---------- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--color-border-strong); border-radius: var(--radius-full); }
::-webkit-scrollbar-thumb:hover { background: var(--color-text-light); }
