/* Shared responsive layout — ask, voice-rag, alolama */

html {
  -webkit-text-size-adjust: 100%;
}

body {
  overflow-x: hidden;
}

/* —— Header & navigation (all pages) —— */
@media (max-width: 980px) {
  .top-header-inner {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    padding: 10px 14px;
  }

  .brand {
    width: 100%;
    min-width: 0;
  }

  .tabs {
    width: 100%;
    flex-wrap: wrap;
    justify-content: center;
    white-space: normal;
    overflow-x: visible;
    gap: 6px;
    padding: 6px;
  }

  .tabs .tab-btn {
    flex: 1 1 calc(33.333% - 6px);
    min-width: 0;
    white-space: normal;
    text-align: center;
    font-size: 12px;
    line-height: 1.35;
    padding: 8px 8px;
  }
}

@media (max-width: 720px) {
  .top-header {
    margin-bottom: 10px;
  }

  .top-header-inner {
    padding: 10px 12px;
  }

  .logo {
    width: 72px;
    height: 72px;
    flex-shrink: 0;
  }

  .brand-text h1 {
    font-size: 17px;
  }

  .brand-text p {
    font-size: 12px;
    max-width: none;
  }

  .container {
    padding: 10px 12px max(24px, env(safe-area-inset-bottom, 0px));
    box-sizing: border-box;
  }

  .tabs .tab-btn {
    flex: 1 1 calc(50% - 6px);
    font-size: 11px;
    padding: 7px 6px;
  }

  /* Ask page cards & forms */
  .chat-card,
  .ingest-card,
  .data-card,
  .answer-card,
  .sources-card,
  .resources-card,
  .eval-card {
    padding: 14px;
    margin-bottom: 12px;
  }

  .action-row,
  .eval-actions,
  .inline-actions {
    flex-direction: column;
    align-items: stretch;
    width: 100%;
  }

  .action-row button,
  .eval-actions button,
  .inline-actions button {
    width: 100%;
    box-sizing: border-box;
  }

  textarea,
  input[type="url"],
  input[type="password"],
  input[type="text"] {
    font-size: 16px; /* avoids iOS zoom on focus */
  }

  .fanar-voice-row {
    flex-direction: column;
    align-items: stretch;
  }

  .fanar-voice-actions {
    width: 100%;
    justify-content: flex-start;
  }

  .fanar-voice-actions button {
    flex: 1 1 auto;
  }

  .eval-result-q {
    min-width: 0;
    width: 100%;
  }

  .history-delete-btn {
    margin-inline-start: 0;
    align-self: flex-start;
  }

  .eval-result-card summary {
    flex-direction: column;
    align-items: flex-start;
  }

  .tts-settings-card {
    padding: 14px 16px;
  }

  .answer-audio-row {
    flex-direction: column;
    align-items: stretch;
  }

  .answer-audio-row audio {
    width: 100%;
    max-width: 100%;
  }

  /* Alolama scholars */
  .page-lead {
    font-size: 14px;
    margin-bottom: 16px;
  }

  .scholar-card-content {
    padding: 16px 14px 18px;
  }

  .scholar-hero {
    min-height: 140px;
    max-height: min(200px, 32vh);
    padding: 12px 14px 14px;
  }

  .record-item {
    padding: 12px;
  }

  .record-transcript {
    max-height: 240px;
  }
}

@media (max-width: 420px) {
  .tabs .tab-btn {
    flex: 1 1 100%;
  }

  .logo {
    width: 56px;
    height: 56px;
  }

  .brand {
    gap: 8px;
  }

  .brand-text h1 {
    font-size: 16px;
  }
}

@media (max-height: 640px) and (orientation: landscape) {
  .top-header-inner {
    flex-direction: row;
    flex-wrap: wrap;
    padding: 6px 12px;
    gap: 8px;
  }

  .tabs {
    flex: 1 1 100%;
  }

  .brand-text p {
    display: none;
  }

  .logo {
    width: 48px;
    height: 48px;
  }
}
