/* Conversation layout: keep controls in flow so text zoom and small screens fit. */
.aira-page .aira-history-panel { font: 400 1rem/1.5 var(--sans); padding: 24px; border: 1px solid #b9cabe; border-radius: 16px; width: min(600px, calc(100vw - 32px)); max-height: calc(100dvh - 48px); overflow: auto; box-sizing: border-box; color: #244638; background: var(--paper); margin: auto; }
.aira-page .aira-history-panel::backdrop { background: rgb(15 35 25 / .45); }
.aira-page .aira-settings-heading { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 12px; }
.aira-page .aira-settings-heading h2 { margin: 0; font-size: 1.5rem; }
.aira-page .aira-settings-button { order: -1; align-self: flex-end; min-height: 44px; padding: 8px 12px; font: 500 .875rem var(--sans); color: #244638; background: transparent; border: 1px solid #829a89; border-radius: 10px; cursor: pointer; }
.aira-page .aira-settings-button:focus-visible { outline: 3px solid #527e66; outline-offset: 3px; }
.aira-page .aira-history-panel summary { cursor: pointer; min-height: 32px; font-weight: 600; }
.aira-page .aira-history-panel button, .aira-page .aira-history-panel a { min-height: 44px; padding: 10px 14px; font: inherit; border: 1px solid #829a89; border-radius: 10px; color: #244638; background: var(--surface-input); cursor: pointer; }
.aira-page .aira-history-panel button:focus-visible, .aira-page .aira-history-panel summary:focus-visible { outline: 3px solid #527e66; outline-offset: 3px; }
.aira-page .aira-history-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.aira-page .aira-history-panel [hidden] { display: none !important; }
.aira-page .aira-history-panel p { margin: 10px 0; overflow-wrap: anywhere; }
.aira-page .aira-history-panel li { margin: 12px 0; }
.aira-page .skip-link:not(:focus) { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
.aira-page .skip-link:focus { position: fixed; top: 8px; left: 8px; z-index: 100; padding: 12px; background: var(--surface-input); color: #244638; }
.aira-page .aira-workspace { width: min(820px, 100%); padding: 0 24px 24px; }
.aira-page .aira-chat-card { min-height: calc(100dvh - 94px); padding: 24px 0 0; gap: 24px; }
.aira-page .aira-chat-top { display: flex; flex-direction: column-reverse; align-items: stretch; gap: 24px; }
.aira-page .aira-quiet-button { position: static; align-self: flex-end; min-height: 44px; padding: 10px 14px; font: 500 .875rem var(--sans); letter-spacing: 0; text-transform: none; color: #355647; }
.aira-page .aira-chat-top h2 { font-size: clamp(36px, 5vw, 52px); letter-spacing: -1.5px; }
.aira-page .aira-chat-top p { font-size: 1rem; }
.aira-page .aira-chat-controls { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; width: 100%; margin: 12px auto 24px; }
.aira-page .aira-voice-button { width: 164px; height: 164px; margin: 0 auto; font: 600 1rem/1.35 var(--sans); }
.aira-page .aira-voice-button:focus-visible, .aira-page .aira-quiet-button:focus-visible { outline: 3px solid #527e66; outline-offset: 5px; }
.aira-page .aira-status { max-width: 520px; margin: 0; color: #506558; font-size: .875rem; line-height: 1.5; }
.aira-page .aira-message-welcome { display: none; }
.aira-page .aira-conversation { width: 100%; max-height: none; margin: 0; overflow: visible; }
.aira-page .aira-message { font-size: 1rem; line-height: 1.6; overflow-wrap: anywhere; }
.aira-page .aira-form { order: 5; position: sticky; inset: auto; bottom: 12px; width: 100%; margin-top: auto; padding: 10px 12px 10px 20px; box-sizing: border-box; }
.aira-page .aira-form:focus-within { border-color: #527e66; box-shadow: 0 0 0 3px rgba(82,126,102,.16); }
.aira-page .aira-form textarea { font-size: 1rem; min-width: 0; }
.aira-page .aira-form .button { min-width: 48px; min-height: 48px; font-size: .875rem; }
.aira-page .aira-input-note { order: 6; position: static; padding: 0 12px; color: #506558; font-size: .875rem; line-height: 1.5; margin: -10px 0 0; }
.aira-page.aira-has-started .aira-chat-top { gap: 0; }
.aira-page.aira-has-started .aira-conversation { order: 2; max-height: none; margin: 0; }
.aira-page.aira-has-started .aira-chat-controls { order: 4; margin: 0 auto; }
.aira-page.aira-has-started .aira-voice-button { width: auto; height: auto; min-height: 52px; padding: 12px 24px; display: flex; gap: 12px; box-shadow: none; }
.aira-page.aira-has-started .aira-voice-button::before { font-size: 24px; margin: 0; }
.aira-page .aira-urgent-card { order: 3; margin-top: 0; scroll-margin-top: 0; }
@media (max-width: 600px) {
  .aira-page .aira-workspace { padding: 0 16px 20px; }
  .aira-page .aira-chat-card { padding-top: 12px; gap: 18px; }
  .aira-page .aira-chat-controls { margin: 0 auto 12px; }
  .aira-page .aira-form { padding-left: 14px; bottom: max(8px, env(safe-area-inset-bottom)); }
  .aira-page .aira-input-note { padding: 0; }
  /* Keep the composer in document flow on phones: a bottom-sticky form can
     overlap the fixed tab bar before its normal flow position is reached. */
  .aira-page .aira-form { position: static; margin-top: 0; }
  .aira-page .aira-form textarea { scroll-margin-block: 100px; }
}
@media (prefers-reduced-motion: reduce) { .aira-page .aira-voice-button { transition: none; } .aira-page .aira-voice-button:hover { transform: none; } }

/* AIRA's original colour-shifting voice orb; movement does not imply listening. */
.aira-page .aira-voice-button,
.aira-page.aira-has-started .aira-voice-button {
  position: relative; display: flex; flex-direction: column; justify-content: flex-end;
  align-items: center; width: 204px; height: 226px; padding: 0 4px 4px;
  border-radius: 24px; background: transparent; color: #244638; box-shadow: none;
  font: 600 1rem/1.4 var(--sans); isolation: isolate;
}
.aira-page .aira-voice-button::before,
.aira-page.aira-has-started .aira-voice-button::before {
  content: ''; position: absolute; top: 8px; left: 12px; width: 180px; height: 180px;
  margin: 0; border-radius: 50%;
  background: radial-gradient(circle at 28% 25%, #e7ffe7 0%, transparent 39%),
    radial-gradient(circle at 76% 72%, #246346 0%, transparent 48%),
    linear-gradient(135deg, #a7e6b7, #48a77a 48%, #b7db91 80%, #367f58);
  background-size: 160% 160%;
  box-shadow: inset 0 0 24px rgba(255,255,255,.65), inset -16px -20px 35px rgba(27,75,43,.18), 0 16px 36px rgba(43,92,57,.16);
  animation: aira-orb-colour 9s ease-in-out infinite alternate;
}
.aira-page .aira-voice-button:hover { transform: none; box-shadow: none; }
.aira-page .aira-voice-button:hover::before { box-shadow: inset 0 0 24px rgba(255,255,255,.7), 0 16px 42px rgba(56,100,97,.27); }
.aira-page .aira-voice-button[aria-pressed='true']::before { outline: 3px solid #527e66; outline-offset: 6px; animation-duration: 3s; }
.aira-page .aira-voice-button:disabled::before { animation-play-state: paused; opacity: .65; }
.aira-page.aira-has-started .aira-voice-button { width: 190px; height: 142px; }
.aira-page.aira-has-started .aira-voice-button::before { width: 96px; height: 96px; left: 47px; }
@keyframes aira-orb-colour { from { background-position: 0% 10%; } to { background-position: 100% 90%; } }
@media (prefers-reduced-motion: reduce) { .aira-page .aira-voice-button::before { animation: none; } }

/* Keep both conversation entry points reachable on shorter laptop windows. */
.aira-page .aira-unified-launcher { display: none; }
.aira-page:not(.aira-has-started) .aira-conversation { display: none; }
.aira-page.aira-has-started .aira-chat-top { display: none; }
.aira-page .aira-chat-card { gap: 16px; }
@media (max-height: 800px) {
  .aira-page .aira-chat-card { padding-top: 12px; gap: 12px; }
  .aira-page .aira-chat-top h2 { font-size: 36px; }
  .aira-page .aira-chat-top p { margin-top: 8px; line-height: 1.45; }
  .aira-page .aira-chat-top .eyebrow { margin-bottom: 8px; }
  .aira-page .aira-chat-controls { margin: 0 auto 8px; gap: 8px; }
  .aira-page:not(.aira-has-started) .aira-voice-button { width: 164px; height: 166px; }
  .aira-page:not(.aira-has-started) .aira-voice-button::before { width: 128px; height: 128px; left: 18px; }
}

/* Settings are a focused preference sheet, with one truthful storage switch. */
/* Bound multi-turn history without moving the page or stealing a reader's place. */
.aira-page.aira-has-started .aira-conversation {
  max-height: max(160px, 38dvh);
  overflow-y: auto;
  overscroll-behavior-y: contain;
  scrollbar-gutter: stable;
  scroll-margin-top: 80px;
}
.aira-page .aira-conversation:focus-visible { outline: 3px solid #527e66; outline-offset: 3px; }
@media (max-width: 600px) and (max-height: 650px) {
  .aira-page.aira-has-started .aira-conversation { max-height: max(80px, calc(100dvh - 480px)); }
}
.aira-page.aira-has-started .aira-voice-button { width: 190px; height: 72px; padding-left: 68px; justify-content: center; }
.aira-page.aira-has-started .aira-voice-button::before { width: 52px; height: 52px; top: 10px; left: 8px; }
.aira-page .aira-history-panel { width: min(640px, calc(100vw - 32px)); padding: 0; border-color: #d0c8ba; border-radius: 24px; box-shadow: 0 28px 90px rgba(24,53,42,.2); text-align: left; }
.aira-page .aira-preferences-section { max-height: none; margin: 0 auto 88px; background: #fff !important; }
.aira-page .aira-settings-heading { display: flex; align-items: center; justify-content: space-between; padding: 24px 28px; background: #fff; }
.aira-page .aira-settings-heading .aira-settings-eyebrow { margin: 0 0 6px; font: 500 .75rem/1.4 var(--mono); letter-spacing: .1em; color: #506558; }
.aira-page .aira-settings-heading h2 { font: 500 1.8rem/1.2 var(--serif); letter-spacing: -.04em; }
.aira-page .aira-history-panel .aira-settings-close { display: grid; place-items: center; width: 44px; height: 44px; min-height: 44px; padding: 0; border: 1px solid #d0c8ba; border-radius: 50%; background: transparent; font: 400 1.8rem/1 var(--sans); }
.aira-page .aira-preferences-content { border-top: 1px solid #ddd4c5; background: #fff; }
.aira-page .aira-preferences-shell { overflow: hidden; }
.aira-page .aira-preferences-shell>.aira-settings-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; cursor: pointer; list-style: none; }
.aira-page .aira-preferences-shell>.aira-settings-heading::-webkit-details-marker { display: none; }
.aira-page .aira-preferences-disclosure { flex: 0 0 auto; width: 42px; height: 42px; display: grid; place-items: center; border: 1px solid #d0c8ba; border-radius: 50%; background: #fff; color: #244638; font-size: 1.3rem; transition: transform .18s ease; }
.aira-page .aira-preferences-shell:not([open]) .aira-preferences-disclosure { transform: rotate(180deg); }
.aira-page .aira-settings-section { padding: 0; border-bottom: 1px solid #ddd4c5; background: #fff !important; }
.aira-page .aira-settings-section:last-child { border-bottom: 0; }
.aira-page .aira-settings-section summary { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 20px 28px; list-style: none; color: #244638; }
.aira-page .aira-settings-section summary::-webkit-details-marker { display: none; }
.aira-page .aira-settings-section summary > span:first-child { display: grid; gap: 4px; }
.aira-page .aira-settings-section summary strong { font: 600 1rem/1.35 var(--sans); }
.aira-page .aira-settings-section summary span span { color: #506558; font-size: .875rem; line-height: 1.45; }
.aira-page .aira-settings-section summary > span:last-child { font-size: 1.35rem; line-height: 1; transition: transform .18s ease; }
.aira-page .aira-settings-section[open] summary > span:last-child { transform: rotate(45deg); }
.aira-page .aira-settings-section > :not(summary) { margin-left: 28px; margin-right: 28px; }
.aira-page .aira-settings-section > .aira-setting-row { margin-top: 4px; }
.aira-page .aira-settings-section > .aira-setting-hint:last-child, .aira-page .aira-settings-section > [role='status']:last-child { margin-bottom: 24px; }
.aira-page .aira-setting-row { display: flex; align-items: center; gap: 24px; justify-content: space-between; }
.aira-page .aira-setting-row > div { flex: 1; min-width: 0; }
.aira-page .aira-setting-row h3 { margin: 0 0 6px; font: 600 1rem/1.4 var(--sans); }
.aira-page .aira-setting-row p, .aira-page .aira-settings-section .aira-setting-hint { margin: 0; color: #506558; font-size: .875rem; line-height: 1.55; }
.aira-page .aira-settings-section .aira-setting-hint { margin-top: 14px; }
.aira-page .aira-history-panel .aira-setting-switch { display: flex; flex: 0 0 auto; flex-direction: column; align-items: center; gap: 5px; min-width: 60px; min-height: 64px; padding: 4px; background: transparent; border: 0; border-radius: 12px; font-size: .875rem; font-weight: 600; }
.aira-page .aira-switch-track { display: block; width: 52px; height: 30px; padding: 3px; border-radius: 99px; background: #ddd5c8; border: 1px solid #829182; }
.aira-page .aira-switch-track::after { content: ''; display: block; width: 22px; height: 22px; border-radius: 50%; background: var(--surface-input); box-shadow: 0 1px 3px rgba(24,53,42,.22); transition: transform .18s ease; }
.aira-page .aira-setting-switch[aria-checked='true'] .aira-switch-track { background: var(--ink); border-color: var(--ink); }
.aira-page .aira-setting-switch[aria-checked='true'] .aira-switch-track::after { transform: translateX(22px); }
.aira-page .aira-setting-switch:disabled { cursor: progress; }
.aira-page .aira-settings-status { margin-top: 16px; padding: 12px 14px; border-radius: 12px; background: var(--surface-muted); }
.aira-page .aira-settings-badge { display: block; font-size: .875rem; font-weight: 600; }
.aira-page .aira-settings-status p { margin: 5px 0 0; font-size: .875rem; line-height: 1.5; color: #506558; }
.aira-page .aira-settings-follow-up { margin-top: 16px; padding: 16px; border: 1px solid #b9cabe; border-radius: 12px; background: var(--surface-input); }
.aira-page .aira-settings-follow-up p { font-size: .875rem; line-height: 1.55; color: #506558; }
.aira-page .aira-storage-consent { display: flex; align-items: flex-start; gap: 10px; font-size: .9375rem; line-height: 1.55; cursor: pointer; }
.aira-page .aira-storage-consent input { flex: 0 0 auto; width: 20px; height: 20px; margin: 2px 0 0; accent-color: var(--ink); }
.aira-page .aira-history-panel .aira-settings-primary { display: inline-flex; align-items: center; justify-content: center; gap: 10px; margin-top: 8px; border-color: var(--ink); background: var(--ink); color: var(--paper); font-size: .875rem; font-weight: 600; text-decoration: none; }
.aira-page .aira-history-panel .aira-settings-secondary { flex: 0 0 auto; position: static; inset: auto; margin: 0; border-color: #829182; background: transparent; font-size: .875rem; font-weight: 500; white-space: normal; }
.aira-page .aira-history-panel .aira-settings-text-action { margin-top: 12px; padding: 8px 0; background: transparent; border: 0; text-decoration: underline; text-underline-offset: 4px; font-size: .875rem; }
.aira-page .aira-history-panel :is(button, a, input):focus-visible { outline: 3px solid #527e66; outline-offset: 3px; }
.aira-page .aira-saved-list { list-style: none; margin: 0; padding: 0; }
.aira-page .aira-saved-list li { display: flex; justify-content: space-between; gap: 8px; padding-top: 12px; border-top: 1px solid #ddd4c5; }
.aira-page .aira-saved-list button { text-align: left; font-size: .875rem; }
.aira-page .aira-saved-detail:not(:empty) { max-height: 280px; overflow: auto; margin-top: 16px; padding: 16px; border-radius: 12px; background: var(--surface-muted); }
@media (max-width: 480px) {
  .aira-page .aira-history-panel { width: calc(100vw - 20px); max-height: calc(100dvh - 20px); border-radius: 18px; }
  .aira-page .aira-settings-heading { padding: 20px; align-items: flex-start; }
  .aira-page .aira-preferences-disclosure { width: 38px; height: 38px; }
  .aira-page .aira-settings-section summary { padding: 18px 20px; }
  .aira-page .aira-settings-section > :not(summary) { margin-left: 20px; margin-right: 20px; }
  .aira-page .aira-setting-row { gap: 14px; align-items: flex-start; }
  .aira-page .aira-setting-row:has(.aira-settings-secondary) { flex-wrap: wrap; }
  .aira-page .aira-setting-row:has(.aira-settings-secondary) > div { flex-basis: 100%; }
  .aira-page .aira-saved-list li { flex-wrap: wrap; }
}
@media (prefers-reduced-motion: reduce) { .aira-page .aira-switch-track::after { transition: none; } }

/* Short landscape windows keep the primary controls beside the conversation. */
@media (min-width: 601px) and (max-height: 500px) {
  .aira-page .aira-chat-card { display: grid; grid-template-columns: minmax(0, 1fr) minmax(220px, 1fr); gap: 8px 24px; padding-top: 8px; min-height: 0; align-items: center; }
  .aira-page .aira-chat-top, .aira-page.aira-has-started .aira-conversation { grid-column: 1; grid-row: 2; }
  .aira-page .aira-chat-top h2 { font-size: 28px; }
  .aira-page .aira-chat-top .eyebrow { font-size: .75rem; }
  .aira-page .aira-chat-top p { margin-top: 6px; font-size: .875rem; }
  .aira-page .aira-chat-controls, .aira-page.aira-has-started .aira-chat-controls { grid-column: 2; grid-row: 2; margin: 0; gap: 4px; }
  .aira-page:not(.aira-has-started) .aira-voice-button { width: 132px; height: 114px; }
  .aira-page:not(.aira-has-started) .aira-voice-button::before { width: 76px; height: 76px; left: 28px; top: 4px; }
  .aira-page.aira-has-started .aira-conversation { max-height: 150px; }
  .aira-page .aira-urgent-card, .aira-page .aira-form, .aira-page .aira-input-note { grid-column: 1 / -1; }
  .aira-page .aira-form { position: static; margin: 0; }
  .aira-page .aira-form textarea { height: 44px; min-height: 44px; }
  .aira-page .aira-input-note { margin: 0; }
}
