/* Phone layout (Dear Socrates).
 * Every rule lives inside max-width: 700px, so the desktop layout is never touched.
 * Loaded last so it can override the per-feature stylesheets at equal specificity. */
@media (max-width: 700px) {

  /* Typing: 16px stops iOS Safari from zooming the page when a field is focused. */
  input, textarea, select { font-size: 16px !important; }

  /* Bigger touch area for small text buttons, without moving anything. */
  .ag-crumb button, .ag-alt, .sd-back, .sd-share, .ag-link, .story-read { position: relative; }
  .ag-crumb button::after, .ag-alt::after, .sd-back::after, .sd-share::after, .ag-link::after, .story-read::after {
    content: ''; position: absolute; inset: -14px -8px;
  }

  /* ── Home ── fill the first screen; the figures sit under the question box, not behind it. */
  body:not(.subpage-mode):not(.people-mode):not(.result-mode) .home-hero { min-height: 100svh; }
  body:not(.subpage-mode):not(.people-mode):not(.result-mode) .home-figures { top: auto; bottom: 0; height: min(300px, 36svh); }

  /* ── One-on-one chat ── a slim header (back · name · portrait) and the whole screen for the conversation. */
  .person-chat, .person-chat.has-life {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr);
  }
  .person-chat .person-chat-side, .person-chat.has-life .person-chat-side {
    display: flex; align-items: center; gap: 12px;
    padding: max(12px, env(safe-area-inset-top)) 16px 12px;
    border-right: 0; border-bottom: 1px solid rgba(255,255,255,0.08);
    overflow: visible;
  }
  .person-chat .person-chat-back {
    flex: none; width: 38px; height: 38px; padding: 0; border-radius: 50%;
    font-size: 0; letter-spacing: 0; display: grid; place-items: center;
  }
  .person-chat .person-chat-back::before { content: '←'; font-size: 16px; line-height: 1; }
  .person-chat .person-chat-info { flex: 1; min-width: 0; margin-top: 0; }
  .person-chat .person-chat-name { font-size: 1.2rem; line-height: 1.15; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .person-chat .person-chat-meta { margin-top: 3px; line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .person-chat .person-chat-portrait {
    position: static; flex: none; width: 42px; height: 42px; border-radius: 50%;
    object-fit: cover; object-position: center top; transform: none; filter: none;
    background: rgba(255,255,255,0.06);
  }
  .person-chat .advisor-life { display: none; }
  .person-chat .person-chat-main { min-height: 0; }
  .person-chat .person-chat-form { padding-bottom: max(12px, env(safe-area-inset-bottom)); }

  /* ── Themes ── the list first, the motion of the week under it; nothing overlaps. */
  #themesPage.site-page { height: auto; min-height: calc(100svh - var(--site-header-height, 101px)); overflow: visible; }
  #themesPage .theme-menu {
    height: auto; min-height: calc(100svh - var(--site-header-height, 101px));
    display: flex; flex-direction: column; padding: 30px 24px 44px;
  }
  #themesPage .theme-index {
    position: relative; inset: auto; order: 1;
    padding: 0 40px 0 0; justify-content: flex-start;
  }
  #themesPage .theme-title { font-size: clamp(40px, 12.4vw, 56px); line-height: 1; }
  #themesPage .theme-aside {
    position: relative; left: auto; top: auto; order: 2;
    width: 100% !important; margin-top: 40px; padding-top: 26px;
    border-top: 1px solid rgba(212,175,123,0.16);
  }
  #themesPage .theme-aside-kicker br { display: none; }
  #themesPage .theme-aside-title { margin-top: 14px; }
  #themesPage .ag-aside { margin-top: 26px; }
  #themesPage .ag-aside-motion { font-size: 24px; line-height: 1.18; margin-top: 16px; }

  /* ── Debate floor ── seats share the width; the question field gets its own line. */
  .ag-debate--v7 .ag-debate-main { padding-left: 16px; padding-right: 16px; }
  .ag-debate--v7 .ag-seat-row { gap: 8px; }
  .ag-debate--v7 .ag-seat-col { flex: 1 1 0; min-width: 0; max-width: 76px; }
  .ag-debate--v7 .ag-seat-col .ag-niche { width: 100% !important; max-width: 62px; }
  .ag-debate--v7 .ag-seat-col .ag-niche-plate { max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
  .ag-debate--v7 .ag-seat-col .ag-slot--sm { width: 100%; max-width: 58px; height: 80px; }
  .ag-debate--v7 .ag-composer { flex-wrap: wrap; border-radius: 20px; padding: 8px 10px 10px 14px; gap: 8px; }
  .ag-debate--v7 .ag-composer input { flex: 1 1 calc(100% - 52px); }
  .ag-debate--v7 .ag-comp-sep { display: none; }
  .ag-debate--v7 .ag-comp-act { flex: 1 1 0; padding: 9px 4px; text-align: center; white-space: nowrap; }
  .ag-debate--v7 .ag-stage-motion { font-size: 19px; }

  /* ── Stories ── the intro copy uses the room it has; the footnote is readable. */
  .story-intro-copy { flex: 1 1 0; min-width: 0; }
  .story-stats { flex: none; }
  .story-stats-note { font-size: 9px; }

  /* ── Story detail ── */
  .sd-q { font-size: 24px; }
  .sd-bubble { max-width: 100%; }

  /* ── Cards ── a real fanned deck that fits the screen, larger cards, a readable back. */
  .card, .cards-stage .card {
    --mcard-w: min(76vw, 300px);
    width: var(--mcard-w); flex: 0 0 var(--mcard-w); min-height: 0;
  }
  .cards-stage.stack-mode .card,
  body.result-mode .cards-stage.stack-mode.few-cards .card { margin-left: calc(28px - var(--mcard-w)); }
  .cards-stage.stack-mode .card:first-child,
  body.result-mode .cards-stage.stack-mode.few-cards .card:first-child { margin-left: 0; }
  .cards-stage.stack-mode .cards-track { justify-content: center; padding-left: 6px; padding-right: 6px; }
  .back-name-row { padding-right: 72px; }
  .back-answer-section { padding-right: 0; }
  .back-answer-section::before, .back-answer-section::after { content: none; }
  .back-answer { font-size: 0.92rem; line-height: 1.7; }

  /* ── Roundtable ── */
  .roundtable-speaker-name { font-size: 0.62rem; }
}
