/*
 * Final viewport stabilisation for wide notebook screens and modern iPhones.
 * Loaded last so these device contracts stay independent from view styling.
 */

html {
  width: 100%;
  height: 100%;
  overflow: hidden;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  touch-action: pan-x pan-y;
}

body {
  width: 100%;
  height: 100%;
  min-height: 0;
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: pan-x pan-y;
}

button,
a,
input,
textarea,
select,
summary {
  touch-action: manipulation;
}

#messages,
#recipe-content,
#library-list,
.library-preview-transcript {
  touch-action: pan-y;
}

.library-scenario-filters,
.library-tabs,
.library-filters {
  touch-action: pan-x;
}

/* Generated WebP icon system. Masks keep the authored state colour while the
 * silhouette stays identical across platforms and fonts. */
:is(.mic-icon, .home-mic, .hero-mic) {
  border: 0 !important;
  border-radius: 0 !important;
  background: currentColor !important;
  box-shadow: none !important;
  -webkit-mask: url("/assets/icons/microphone.webp") center / 100% 100% no-repeat;
  mask: url("/assets/icons/microphone.webp") center / 100% 100% no-repeat;
}

:is(.mic-icon, .home-mic, .hero-mic)::before,
:is(.mic-icon, .home-mic, .hero-mic)::after {
  display: none !important;
}

.ingredient-orbit .plate .hero-mic {
  width: 58px;
  height: 72px;
}

.hero-plate .hero-mic {
  width: 46px;
  height: 60px;
}

.home-primary-action .home-mic {
  width: 24px;
  height: 28px;
}

:is(
  #composer-voice-button,
  body[data-view="recipe"] .recipe-voice-button,
  body[data-view="library"] .library-mobile-new,
  body[data-view="library"] .library-preview-actions button
) .mic-icon {
  width: 30px;
  height: 36px;
}

:is(
  #sidebar-new-dialogue,
  #recipe-sidebar-new,
  #library-sidebar-new
) > span:first-child {
  width: 26px;
  height: 26px;
  display: inline-block;
  flex: 0 0 26px;
  overflow: hidden;
  color: transparent;
  background: url("/assets/icons/plus-white.webp") center / contain no-repeat;
  font-size: 0;
}

body[data-view="chat"] .composer-plus {
  color: transparent;
  background-color: #e8f4ea;
  background-image: url("/assets/icons/plus.webp");
  background-position: center;
  background-repeat: no-repeat;
  background-size: 25px 25px;
  font-size: 0;
}

body[data-view="chat"] .composer-plus:empty::before {
  display: none;
}

body[data-view="chat"] .message-speaker {
  overflow: hidden;
  color: transparent;
  background: url("/assets/icons/speaker.webp") center / 23px 23px no-repeat;
  font-size: 0;
}

body[data-view="chat"] .message-copy {
  min-width: 0;
  overflow-wrap: anywhere;
  white-space: normal;
}

body[data-view="recipe"] :is(.recipe-step, .recipe-steps > li, .steps-card ol > li)::after {
  content: none;
  display: none;
}

body[data-view="recipe"] :is(.recipe-source, .recipe-source-line)::before {
  content: "";
  width: 20px;
  height: 20px;
  flex: 0 0 20px;
  background: currentColor;
  -webkit-mask: url("/assets/icons/recipe-note.webp") center / contain no-repeat;
  mask: url("/assets/icons/recipe-note.webp") center / contain no-repeat;
}

body[data-view="recipe"] .recipe-text-question > span:first-child {
  width: 21px;
  height: 21px;
  display: inline-block;
  overflow: hidden;
  color: transparent;
  background: url("/assets/icons/message.webp") center / contain no-repeat;
  font-size: 0;
}

body[data-view="library"] .library-search > span:first-child {
  background: url("/assets/icons/search.webp") center / 23px 23px no-repeat;
}

body[data-view="library"] .library-search > span:first-child::before,
body[data-view="library"] .library-search > span:first-child::after {
  display: none;
}

:is(.chat-back, body[data-view="recipe"] .recipe-back, body[data-view="library"] .recipe-back) {
  color: transparent;
  background-image: url("/assets/icons/back.webp");
  background-position: left center;
  background-repeat: no-repeat;
  background-size: 27px 27px;
  font-size: 0;
}

body[data-view="library"] .library-toolbar .recipe-back,
body[data-view="recipe"] .recipe-toolbar .recipe-back {
  width: 32px;
  min-width: 32px;
  color: transparent !important;
  background: url("/assets/icons/back.webp") center / 27px 27px no-repeat !important;
  font-size: 0 !important;
}

:is(.chat-head-overflow, .recipe-toolbar-overflow) > summary {
  color: transparent;
  background: url("/assets/icons/more.webp") center / 24px 24px no-repeat;
  font-size: 0;
}

body[data-view="chat"] #chat-head-history {
  color: transparent;
  background-image: url("/assets/icons/history-black.webp");
  background-position: center;
  background-repeat: no-repeat;
  background-size: 23px 23px;
  font-size: 0;
}

body[data-view="chat"] #chat-head-notes {
  color: transparent;
  background-image: url("/assets/icons/recipe-note-black.webp");
  background-position: center;
  background-repeat: no-repeat;
  background-size: 23px 23px;
  font-size: 0;
}

:is(#sidebar-open-library, #recipe-sidebar-history, #library-sidebar-history) > span:first-child {
  color: transparent;
  background: url("/assets/icons/history-black.webp") center / 23px 23px no-repeat;
  font-size: 0;
}

:is(#sidebar-open-notes, #recipe-sidebar-notes, #library-sidebar-notes) > span:first-child {
  color: transparent;
  background: url("/assets/icons/recipe-note-black.webp") center / 23px 23px no-repeat;
  font-size: 0;
}

:is(
  #recipe-sidebar-history,
  #recipe-sidebar-notes,
  #library-sidebar-history,
  #library-sidebar-notes
) > span:first-child {
  width: 34px;
  height: 34px;
  display: grid;
  flex: 0 0 34px;
  place-items: center;
  overflow: hidden;
}

body[data-view="recipe"] .recipe-saved-status > i,
body[data-view="library"] .dialogue-note-count::before,
body[data-view="library"] .library-card-favorite::before {
  content: "" !important;
  border: 0 !important;
  clip-path: none !important;
  color: transparent !important;
  background: url("/assets/icons/bookmark-saved.webp") center / contain no-repeat !important;
  font-size: 0 !important;
}

body[data-view="library"] .library-card-latest::before {
  content: "" !important;
  border: 0 !important;
  clip-path: none !important;
  background: url("/assets/icons/bookmark-outline.webp") center / contain no-repeat !important;
  font-size: 0 !important;
}

body[data-view="library"] .library-card-latest::before {
  width: 17px !important;
  height: 22px !important;
  flex: 0 0 17px;
}

body[data-view="library"] .library-card-favorite::before {
  width: 24px !important;
  height: 30px !important;
}

/* The home artboard stays intentionally capped. Chat and recipe own their
 * wide-screen geometry in chat-v2/workspace-v2; do not re-cap them here. */
@media (min-width: 1600px) {
  body.app-active[data-view="home"] .app-shell {
    width: min(1536px, 100%);
    max-width: 1536px;
    padding-inline: 38px;
  }
}

/* Keep the persistent library rail on the same desktop measure as chat and
 * recipe, including high-specificity library state variants upstream. */
@media (min-width: 1200px) {
  body[data-view="library"] .library-shell {
    grid-template-columns: var(--workspace-rail-width, 350px) minmax(0, 1fr) !important;
  }

  body[data-view="library"] .workspace-sidebar {
    background: #fff;
  }
}

/* Long runtime content must stay reachable without moving the SPA viewport. */
@media (min-width: 701px) {
  body[data-view="recipe"] .recipe-section-grid,
  body[data-view="recipe"] .recipe-section-grid > .recipe-section-card {
    min-height: 0;
  }

  body[data-view="recipe"] .recipe-section-grid > .recipe-section-card {
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: none;
  }

  body[data-view="recipe"] .recipe-section-grid > .recipe-section-card::-webkit-scrollbar {
    display: none;
  }

  body[data-view="chat"] .message-row.user .message-bubble {
    width: max-content;
    max-width: 540px;
    flex-wrap: nowrap;
    white-space: normal;
    overflow-wrap: anywhere;
  }
}

@media (min-width: 1200px) {
  body[data-view="library"] #library-screen[data-tab="history"]
    .library-history-group[data-period="yesterday"] .dialogue-history-card:nth-child(n + 2) {
    display: grid;
  }

  body[data-view="library"] #library-screen[data-tab="history"] #library-preview {
    display: grid;
    grid-template-rows: auto minmax(140px, 1fr) auto auto;
    gap: 18px;
    overflow: hidden;
  }

  body[data-view="library"] #library-screen[data-tab="history"] .library-preview-transcript {
    position: static;
    inset: auto;
    width: auto;
    height: auto;
    min-height: 0;
    display: flex;
    gap: 24px;
    margin: 0;
    padding: 8px 12px 12px;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
  }

  body[data-view="library"] #library-screen[data-tab="history"] .library-preview-message {
    position: relative;
    inset: auto;
    top: auto !important;
    min-height: 0;
  }

  body[data-view="library"] #library-screen[data-tab="history"] .library-preview-bubble {
    width: auto !important;
    min-width: 0 !important;
    max-width: min(78%, 620px);
    overflow-wrap: anywhere;
  }

  body[data-view="library"] #library-screen[data-tab="history"] .library-preview-recipe-card {
    position: static;
    inset: auto;
    width: 100%;
    min-height: 150px;
    height: auto;
    margin: 0;
  }

  body[data-view="library"] #library-screen[data-tab="history"] .library-preview-actions {
    position: static;
    inset: auto;
    margin: 0;
    padding: 0;
  }
}

body[data-view="chat"] .chat-overflow {
  position: relative;
}

body[data-view="chat"] .chat-overflow > div {
  position: absolute;
  z-index: 40;
  top: calc(100% + 8px);
  right: 0;
  min-width: 196px;
  display: grid;
  gap: 4px;
  padding: 8px;
  border: 1px solid #e0e3e0;
  border-radius: 16px;
  background: rgba(255, 255, 255, .98);
  box-shadow: 0 16px 40px rgba(22, 41, 28, .16);
}

body[data-view="chat"] .chat-overflow > div button {
  min-height: 42px;
  padding: 0 12px;
  border: 0;
  border-radius: 10px;
  color: #151816;
  background: transparent;
  text-align: left;
}

body[data-view="chat"] .chat-overflow > div button:hover {
  background: #f0f5f1;
}

/* iPhone 12 Pro and phones with the same compact portrait proportions. */
@media (max-width: 700px) {
  input,
  textarea,
  select {
    font-size: 16px !important;
  }

  .scenario-card {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr) 27px 36px;
  }

  .scenario-card strong,
  .scenario-card small {
    grid-column: 1;
    min-width: 0;
    margin-right: 43px;
  }

  .scenario-card strong {
    margin-top: 10px;
    font-size: 12.5px;
    line-height: 1.08;
    letter-spacing: -.035em;
    white-space: nowrap;
  }

  .scenario-card small {
    margin-top: 3px;
    margin-bottom: 8px;
    overflow: hidden;
    font-size: 10px;
    line-height: 1.12;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .scenario-card > b {
    position: absolute;
    right: 8px;
    bottom: 10px;
    width: 34px;
    height: 34px;
    margin: 0;
    font-size: 18px;
  }

  body[data-view="chat"] .message-row.user {
    padding-right: 10px;
  }

  body[data-view="chat"] .assistant .message-bubble {
    max-width: calc(100vw - 82px);
  }

  body[data-view="chat"] .message-row.assistant .message-stack {
    max-width: calc(100% - 66px);
  }

  body[data-view="chat"] .message-row.assistant .message-stack:has(.message-article-card) {
    width: min(calc(100% - 54px), 310px);
    max-width: 310px;
  }

  body[data-view="chat"] .message-article-card {
    width: min(100%, 270px);
    gap: 8px;
    padding: 11px;
    border-radius: 22px;
  }

  body[data-view="chat"] .message-article-card > span:first-child {
    padding: 6px 9px;
    font-size: 12px;
  }

  body[data-view="chat"] .message-article-image {
    height: 145px;
    border-radius: 14px;
  }

  body[data-view="chat"] .message-article-info strong {
    font-size: 21px;
  }

  body[data-view="chat"] .message-article-meta {
    margin-top: 4px;
  }

  body[data-view="chat"] .message-article-ingredients,
  body[data-view="chat"] .message-article-info .ingredients {
    margin-top: 8px;
    padding-left: 25px;
    font-size: 12px;
  }

  body[data-view="chat"] .message-article-info b {
    min-height: 38px;
    margin-top: 9px;
  }

  body[data-view="chat"] .voice-mode-controls {
    flex-basis: 45px;
    min-height: 45px;
    margin-top: 4px;
    margin-bottom: 8px;
    padding-block: 2px;
  }

  body[data-view="chat"] .voice-speaker {
    width: 37px;
    height: 37px;
  }

  body[data-view="chat"] .composer {
    flex-basis: 67px;
    min-height: 67px;
  }

  body[data-view="chat"] .composer:has(.composer-plus) {
    grid-template-columns: 44px minmax(0, 1fr) 48px;
    gap: 8px;
    padding: 8px 10px 8px 8px;
  }

  body[data-view="chat"] .composer-plus {
    width: 44px;
    min-width: 44px;
    height: 44px;
  }

  body[data-view="chat"] #composer-voice-button,
  body[data-view="chat"] .composer .send-button {
    width: 48px;
    min-width: 48px;
    height: 48px;
  }

  body[data-view="chat"] .composer textarea {
    height: 48px !important;
    min-height: 48px;
    max-height: 48px;
    padding: 12px 13px;
  }

  body[data-view="chat"] #app-screen {
    height: 100dvh;
    min-height: 0;
  }

  body[data-view="chat"] .chat-screen,
  body[data-view="chat"] .chat-layout,
  body[data-view="chat"] .conversation-card {
    height: 100%;
    min-height: 0;
  }

  body[data-view="chat"] .chat-screen {
    padding-bottom: max(14px, env(safe-area-inset-bottom));
  }

  body[data-view="chat"] .message-speaker {
    width: 20px;
    min-width: 20px;
    height: 20px;
    flex-basis: 20px;
    margin: -4px 0 -4px 4px;
    background-size: 18px 18px;
  }

  body[data-view="chat"] .assistant .message-bubble {
    gap: 6px;
  }

  body[data-view="chat"] .message-row.assistant .message-stack:has(.message-article-card) > .message-bubble {
    gap: 4px;
    padding-inline: 8px;
    font-size: 13px;
  }

  :is(
    #home-voice-button .home-mic,
    #composer-voice-button .mic-icon,
    body[data-view="recipe"] .recipe-voice-button .mic-icon,
    body[data-view="library"] .library-mobile-new .mic-icon
  ) {
    width: 30px;
    height: 34px;
  }

  .ingredient-orbit .plate .hero-mic {
    width: 42px;
    height: 54px;
  }

  .home-screen[data-state="fresh"] .hero-plate .hero-mic {
    width: 38px;
    height: 48px;
  }

  body[data-view="recipe"] .recipe-workspace {
    grid-template-rows:
      calc(55px + env(safe-area-inset-top))
      minmax(0, 1fr)
      calc(82px + env(safe-area-inset-bottom));
  }

  body[data-view="recipe"] .recipe-toolbar {
    min-height: calc(55px + env(safe-area-inset-top));
    height: calc(55px + env(safe-area-inset-top));
    padding: env(safe-area-inset-top) 18px 0;
  }

  body[data-view="recipe"] .recipe-back {
    min-height: 54px;
  }

  body[data-view="recipe"] .recipe-hero {
    min-height: 307px;
    height: 307px;
  }

  body[data-view="recipe"] .recipe-hero-image {
    height: 203px;
  }

  body[data-view="recipe"] .recipe-hero-copy {
    min-height: 104px;
    height: 104px;
    padding: 12px 18px 10px;
  }

  body[data-view="recipe"] .recipe-hero-copy h1 {
    height: 29px;
    flex-basis: 29px;
    font-size: 28px;
  }

  body[data-view="recipe"] .recipe-hero-meta,
  body[data-view="recipe"] .recipe-hero-copy > p:not(.eyebrow) {
    margin-top: 5px;
    font-size: 14px;
  }

  body[data-view="recipe"] :is(.recipe-source, .recipe-source-line) {
    min-height: 18px;
    height: 18px;
    flex-basis: 18px;
    margin-top: 5px;
    font-size: 13px;
    line-height: 18px;
  }

  body[data-view="recipe"] :is(.recipe-mobile-tabs, .recipe-mobile-segments) {
    min-height: 42px;
    height: 42px;
    margin: 0 18px 13px;
    padding: 4px;
  }

  body[data-view="recipe"] :is(.recipe-mobile-tabs, .recipe-mobile-segments) button {
    font-size: 15px;
  }

  body[data-view="recipe"] .recipe-section-grid {
    padding: 0 18px 14px;
  }

  body[data-view="recipe"] .recipe-section-card,
  body[data-view="recipe"] .recipe-section-card:first-child:not(.ingredients-card),
  body[data-view="recipe"] .recipe-section-card:not(.ingredients-card):first-child:last-child,
  body[data-view="recipe"] .recipe-section-card.recipe-steps-card,
  body[data-view="recipe"] .recipe-section-card.steps-card {
    margin-bottom: 11px;
  }

  body[data-view="recipe"] .recipe-section-card h2,
  body[data-view="recipe"] .recipe-section-card h3 {
    margin-bottom: 8px;
    font-size: 20px;
  }

  body[data-view="recipe"] .recipe-checklist label,
  body[data-view="recipe"] .recipe-checklist li {
    min-height: 29px;
  }

  body[data-view="recipe"] .recipe-checklist label {
    gap: 12px;
    font-size: 15px;
  }

  body[data-view="recipe"] :is(.recipe-step, .recipe-steps > li, .steps-card ol > li),
  body[data-view="recipe"] .steps-card ol > li.current {
    min-height: 44px;
    grid-template-columns: 28px minmax(0, 1fr) auto;
    gap: 6px;
    padding: 3px 0;
    font-size: 13px;
  }

  body[data-view="recipe"] :is(.recipe-step, .recipe-steps > li, .steps-card ol > li)::before {
    width: 28px;
    height: 28px;
  }

  body[data-view="recipe"] .recipe-step-mobile-copy {
    grid-column: 2;
    padding: 0 !important;
    font-size: 13px;
  }

  body[data-view="recipe"] .steps-card ol > li.current .recipe-step-current-label {
    position: static;
    right: auto;
    grid-column: 3;
    margin: 0;
  }

  body[data-view="recipe"] .recipe-step-current-label {
    min-height: 22px;
    padding-inline: 6px;
    font-size: 10px;
  }

  body[data-view="recipe"] .recipe-bottom-voice {
    min-height: calc(76px + env(safe-area-inset-bottom));
    height: calc(76px + env(safe-area-inset-bottom));
    grid-template-columns: 96px minmax(0, 1fr) 64px;
    gap: 8px;
    margin: 0 5px 6px;
    padding: 7px 10px calc(7px + env(safe-area-inset-bottom));
  }

  body[data-view="recipe"] .recipe-bottom-wave {
    width: 96px;
  }

  body[data-view="recipe"] .recipe-bottom-voice > span:nth-child(2) {
    left: 18px;
    bottom: calc(5px + env(safe-area-inset-bottom));
  }

  body[data-view="recipe"] .recipe-bottom-voice .recipe-voice-button,
  body[data-view="recipe"] :is(.recipe-question-action, .recipe-text-question) {
    min-height: 60px;
    height: 60px;
  }

  body[data-view="library"] #library-screen[data-tab="history"]
    :is(.dialogue-history-card, .history-card) {
    min-height: 114px;
    grid-template-columns: 78px minmax(0, 1fr);
    gap: 14px;
    padding: 14px;
  }

  body[data-view="library"] #library-screen[data-tab="history"]
    :is(.dialogue-history-card, .history-card) > img {
    width: 78px;
    height: 78px;
  }

  body[data-view="library"] #library-screen[data-tab="history"]
    :is(.dialogue-history-card, .history-card) > span:not(.dialogue-history-trailing) {
    min-width: 0;
    padding-right: 60px;
  }

  body[data-view="library"] #library-screen[data-tab="history"] .dialogue-history-trailing {
    padding-right: 0;
  }

  body[data-view="library"] .library-filter-controls,
  body[data-view="library"] .library-filter-controls .library-scenario-filters {
    overflow-x: auto;
    overflow-y: hidden;
    overscroll-behavior-inline: contain;
    scrollbar-width: none;
  }

  body[data-view="library"] .library-filter-controls .library-scenario-filters {
    gap: 6px;
  }

  body[data-view="library"] .library-filter-controls .library-scenario-filters button {
    padding-inline: 10px;
  }

  body[data-view="library"] .library-filter-controls::-webkit-scrollbar,
  body[data-view="library"] .library-filter-controls .library-scenario-filters::-webkit-scrollbar {
    display: none;
  }

  body[data-view="library"] #library-screen[data-tab="history"] .library-toolbar::after {
    content: "";
    width: 30px;
    height: 30px;
    background: url("/assets/icons/search.webp") center / 27px 27px no-repeat;
  }

  body[data-view="library"] #library-screen[data-tab="favorites"] .library-toolbar::after {
    content: "";
    width: 70px;
    height: 30px;
    background:
      url("/assets/icons/sort.webp") left center / 27px 27px no-repeat,
      url("/assets/icons/edit.webp") right center / 27px 27px no-repeat;
    font-size: 0;
    letter-spacing: 0;
  }
}

@media (max-width: 700px) and (min-height: 780px) and (max-height: 900px) {
  .login-shell {
    grid-template-rows: 74px minmax(0, 1fr);
    padding: 20px 20px 36px;
  }

  .login-intro {
    height: 52%;
  }

  .ingredient-orbit {
    top: 20px;
  }

  .login-intro-copy {
    bottom: 17px;
  }

  .login-intro h1 {
    font-size: 28px;
  }

  .login-intro .eyebrow {
    font-size: 29px;
  }

  .login-lead {
    margin-top: 16px;
  }

  .login-card {
    height: 48%;
    padding: 8px 17px;
  }

  .login-card h2 {
    margin-bottom: 11px;
  }

  .login-card .primary-action {
    min-height: 58px;
    height: 58px;
  }

  .login-features {
    margin-top: 8px;
  }

  .login-features span {
    min-height: 61px;
  }

  .home-screen[data-state="fresh"] {
    grid-template-rows: minmax(0, 1fr) 64px;
    gap: 18px;
    padding-bottom: 11px;
  }

  .home-screen[data-state="fresh"] .home-layout {
    grid-template-rows: 211px minmax(0, 1fr);
    gap: 23px;
  }

  .home-screen[data-state="fresh"] .hero-copy {
    inset: 132px 16px auto;
    grid-template-columns: minmax(0, 1fr) 160px;
  }

  .home-screen[data-state="fresh"] .hero-copy h1 {
    font-size: 20px;
    white-space: nowrap;
  }

  .home-screen[data-state="fresh"] .home-primary-action {
    width: 160px;
    white-space: nowrap;
  }

  .home-screen[data-state="fresh"] .scenario-section {
    grid-template-rows: 47px minmax(0, 1fr);
  }

  .home-screen[data-state="active"] {
    grid-template-rows: minmax(0, 1fr) 64px;
    gap: 31px;
    padding-bottom: 17px;
  }

  .home-screen[data-state="active"] .home-layout {
    grid-template-rows: 172px minmax(0, 1fr);
    gap: 23px;
  }

  .home-screen[data-state="active"] .scenario-section {
    grid-template-rows: 47px minmax(0, 1fr);
  }

  .home-screen[data-state="active"] .hero-card.active-conversation .hero-actions {
    top: 77px;
    gap: 4px;
  }

  .home-screen[data-state="fresh"] .scenario-grid,
  .home-screen[data-state="active"] .scenario-grid {
    grid-template-rows: repeat(2, minmax(0, 1fr));
    overflow: hidden;
  }

  .home-composer {
    grid-template-columns: minmax(0, 1fr) 48px;
    gap: 8px;
    padding: 7px;
  }
}

/* Regression guard: bitmap icons always keep their authored proportions. */
.home-composer {
  grid-template-columns: minmax(0, 1fr) auto;
}

.home-composer button {
  width: auto;
  height: 100%;
  aspect-ratio: 1 / 1;
  justify-self: end;
}

:is(.mic-icon, .home-mic, .hero-mic) {
  --mic-size: 32px;
  width: var(--mic-size) !important;
  height: var(--mic-size) !important;
  flex: 0 0 var(--mic-size);
  aspect-ratio: 1 / 1;
  -webkit-mask-size: contain;
  mask-size: contain;
}

.ingredient-orbit .plate .hero-mic { --mic-size: 72px; }
.hero-plate .hero-mic { --mic-size: 60px; }
.home-primary-action .home-mic { --mic-size: 36px; }
#home-voice-button .home-mic { --mic-size: 42px; }

:is(
  #composer-voice-button,
  body[data-view="recipe"] .recipe-voice-button,
  body[data-view="library"] .library-mobile-new,
  body[data-view="library"] .library-preview-actions button
) .mic-icon {
  --mic-size: 32px;
}

.login-card .primary-action i::before {
  width: 34px;
  height: 34px;
  aspect-ratio: 1 / 1;
}

body[data-view="chat"] .message-row.voice-only .message-avatar {
  background-size: contain;
}

body[data-view="chat"] .message-avatar::before {
  width: 28px;
  height: 28px;
  background-size: contain;
}

body[data-view="chat"] .voice-waveform,
body[data-view="chat"] .voice-mode-controls::after,
body[data-view="library"] .library-preview-waveform,
.home-screen[data-state="active"] .hero-active-waveform {
  background-size: auto 100% !important;
}

.login-features span:nth-child(1)::before {
  background-size: 28px auto;
}

body[data-view="recipe"] .recipe-bottom-wave {
  background-size: contain;
}

body[data-view="recipe"] .recipe-bottom-wave::after {
  width: 28px;
  height: 28px;
  background-size: contain;
}

body[data-view="recipe"] .recipe-bottom-voice > span:nth-child(2)::after {
  background-size: auto 100%;
}

body[data-view="library"] .library-preview-actions .mic-icon {
  transform: none !important;
}

body[data-view="library"] .library-card-latest::before {
  width: 20px !important;
  height: 20px !important;
  flex-basis: 20px;
}

body[data-view="library"] .library-card-favorite::before {
  width: 24px !important;
  height: 24px !important;
}

.mobile-nav summary > span {
  width: clamp(22px, 2vw, 30px);
  height: clamp(22px, 2vw, 30px);
  display: block;
  color: transparent;
  background: url("/assets/icons/settings.webp") center / contain no-repeat;
  font-size: 0;
}

.scenario-card > b {
  color: transparent;
  background-color: #edf5ef;
  background-image: url("/assets/icons/arrow-right.webp");
  background-position: center;
  background-repeat: no-repeat;
  background-size: clamp(28px, 2.4vw, 36px) clamp(28px, 2.4vw, 36px);
  font-size: 0;
}

.scenario-card[data-scenario="partner"] > b {
  background-image: url("/assets/icons/external-link.webp");
}

@media (min-width: 701px) {
  .home-screen[data-state="active"] .hero-card.active-conversation .home-primary-action::before {
    content: "";
    width: 36px;
    height: 36px;
    flex: 0 0 36px;
    background: var(--green);
    -webkit-mask: url("/assets/icons/arrow-right.webp") center / contain no-repeat;
    mask: url("/assets/icons/arrow-right.webp") center / contain no-repeat;
  }
}

/* Chrome's usable viewport at 1920x1080 is about 944px high. Keep both
 * desktop hero states inside that real content area rather than the monitor
 * resolution printed on the box. */
@media (min-width: 1200px) and (max-height: 1050px) {
  .home-screen[data-state="fresh"] .hero-plate {
    top: 45px;
    width: 120px;
    height: 120px;
  }

  .home-screen[data-state="fresh"] .hero-wave {
    top: 78px;
    width: 64px;
    height: 54px;
  }

  .home-screen[data-state="fresh"] .hero-wave-left { left: 58px; }
  .home-screen[data-state="fresh"] .hero-wave-right { right: 58px; }

  .home-screen[data-state="fresh"] .hero-dialogue-user {
    top: 170px;
    min-height: 76px;
  }

  .home-screen[data-state="fresh"] .hero-dialogue-chef {
    top: 262px;
    min-height: 76px;
  }

}

/* A portrait desktop/tablet window must not pour all surplus height into the
 * hero and the four food photos. The working composition scales from width;
 * the text composer remains anchored to the SPA bottom edge. */
@media (min-width: 701px) and (max-width: 1199px) and (orientation: portrait) {
  body.app-active[data-view="home"] .home-layout {
    block-size: min(100%, clamp(550px, 55vw, 640px));
    align-self: start;
  }
}

/* Short landscape notebooks need a denser hero than the 4:3 render. */
@media (min-width: 1200px) and (max-height: 930px) {
  .home-screen[data-state="fresh"] .hero-dialogue-bubble {
    display: none;
  }
}

@media (min-width: 1200px) and (max-height: 850px) {
  .home-screen[data-state="fresh"] .hero-plate {
    top: 28px;
    width: 104px;
    height: 104px;
  }

  .home-screen[data-state="fresh"] .hero-wave {
    top: 55px;
    width: 56px;
    height: 46px;
  }

  .home-screen[data-state="fresh"] .hero-copy {
    left: 46px;
    right: 46px;
    bottom: 22px;
  }

  .home-screen[data-state="fresh"] .hero-copy h1 {
    font-size: 32px;
  }

  .home-screen[data-state="fresh"] .hero-copy > p:not(.eyebrow) {
    margin-top: 8px;
    font-size: 16px;
    line-height: 1.35;
  }

  .home-screen[data-state="fresh"] .hero-actions {
    margin-top: 12px;
  }

  .home-screen[data-state="fresh"] .home-primary-action {
    min-height: 58px;
    height: 58px;
    font-size: 18px;
  }

  .home-screen[data-state="fresh"] .home-hero-status {
    margin-top: 12px;
    font-size: 13px;
  }

}

/* Desktop home follows the 1448x1086 artboard as a single composition. On a
 * browser-short 16:9 display the shell width is derived from usable height, so
 * the photo cards keep their authored proportions instead of being flattened. */
@media (min-width: 1200px) {
  body.app-active[data-view="home"] .app-shell {
    width: min(1536px, 133.3333dvh, 100%);
    max-width: 1536px;
    padding-inline: clamp(24px, 3.5dvh, 38px);
  }

  body.app-active[data-view="home"] .topbar {
    min-height: clamp(72px, 9.4dvh, 102px);
  }

  body.app-active[data-view="home"] .app-shell > .topbar .brand strong {
    font-size: clamp(30px, 4.33dvh, 47px);
  }

  body.app-active[data-view="home"] .mobile-nav summary {
    width: clamp(43px, 5.34dvh, 58px);
    height: clamp(43px, 5.34dvh, 58px);
  }

  body.app-active[data-view="home"] .home-screen {
    grid-template-rows: minmax(0, 1fr) clamp(76px, 11.8dvh, 128px);
    gap: clamp(18px, 2.95dvh, 32px);
    padding-bottom: clamp(16px, 2.58dvh, 28px);
  }

  body.app-active[data-view="home"] .home-screen[data-state="active"] {
    gap: clamp(18px, 2.95dvh, 32px);
    padding-bottom: clamp(16px, 2.4dvh, 26px);
  }

  body.app-active[data-view="home"] .home-layout {
    gap: clamp(30px, 4.25dvh, 46px);
  }

  body.app-active[data-view="home"] .home-screen[data-state="active"] .home-layout {
    gap: clamp(30px, 4.7dvh, 51px);
  }

  body.app-active[data-view="home"] .section-heading {
    min-height: clamp(50px, 7.27dvh, 79px);
    padding-left: clamp(18px, 2.58dvh, 28px);
  }

  body.app-active[data-view="home"] .section-heading h2 {
    font-size: clamp(24px, 3.04dvh, 33px);
  }

  body.app-active[data-view="home"] .section-heading p {
    margin-top: clamp(5px, .83dvh, 9px);
    font-size: clamp(13px, 1.75dvh, 19px);
  }

  body.app-active[data-view="home"] .scenario-grid {
    gap: clamp(12px, 2.12dvh, 23px) clamp(14px, 2.58dvh, 28px);
  }

  body.app-active[data-view="home"] .scenario-card {
    border-radius: clamp(20px, 2.58dvh, 28px);
  }

  body.app-active[data-view="home"] .scenario-card strong {
    margin-top: clamp(14px, 2.03dvh, 22px);
    margin-left: clamp(16px, 2.21dvh, 24px);
    font-size: clamp(16px, 2.03dvh, 22px);
  }

  body.app-active[data-view="home"] .scenario-card small {
    margin-top: clamp(4px, .64dvh, 7px);
    margin-bottom: clamp(14px, 2.03dvh, 22px);
    margin-left: clamp(16px, 2.21dvh, 24px);
    font-size: clamp(11px, 1.47dvh, 16px);
  }

  body.app-active[data-view="home"] .scenario-card > b {
    width: clamp(40px, 5.25dvh, 57px);
    height: clamp(40px, 5.25dvh, 57px);
    margin: clamp(8px, 1.1dvh, 12px) clamp(11px, 1.93dvh, 21px) clamp(8px, 1.1dvh, 12px) 8px;
    background-size: clamp(24px, 3.31dvh, 36px) clamp(24px, 3.31dvh, 36px);
  }

  body.app-active[data-view="home"] .home-composer {
    gap: clamp(8px, 2dvh, 22px);
    padding: clamp(8px, 1.55dvh, 17px);
    border-radius: clamp(25px, 2.95dvh, 32px);
  }

  body.app-active[data-view="home"] .home-composer input {
    padding-inline: clamp(16px, 3.04dvh, 33px);
    font-size: clamp(14px, 2.12dvh, 23px);
  }

  body.app-active[data-view="home"] #home-voice-button .home-mic {
    --mic-size: clamp(30px, 3.87dvh, 42px);
  }

  body.app-active[data-view="home"] .home-screen[data-state="active"] .guide-column {
    padding-top: clamp(32px, 5.52dvh, 60px);
  }

  body.app-active[data-view="home"] .home-screen[data-state="active"] .hero-card.active-conversation {
    --active-card-pad-x: clamp(22px, 3.22dvh, 35px);
    --active-card-art-height: clamp(176px, 27.16dvh, 295px);
    padding-top: clamp(22px, 3.96dvh, 43px);
    padding-bottom: clamp(7px, .92dvh, 10px);
    border-radius: clamp(25px, 2.95dvh, 32px);
  }

  body.app-active[data-view="home"] .home-screen[data-state="active"] .hero-card.active-conversation .hero-copy h1 {
    font-size: clamp(24px, 3.13dvh, 34px);
  }

  body.app-active[data-view="home"] .home-screen[data-state="active"] .hero-card.active-conversation .hero-copy > .eyebrow {
    gap: clamp(7px, 1.01dvh, 11px);
    font-size: clamp(13px, 1.66dvh, 18px);
  }

  body.app-active[data-view="home"] .home-screen[data-state="active"] .hero-card.active-conversation .hero-copy > .eyebrow::before {
    width: clamp(8px, 1.1dvh, 12px);
    height: clamp(8px, 1.1dvh, 12px);
  }

  body.app-active[data-view="home"] .home-screen[data-state="active"] .hero-card.active-conversation .hero-active-visual {
    grid-template-rows: minmax(0, 1fr) clamp(24px, 3.68dvh, 40px);
    gap: clamp(12px, 2.49dvh, 27px);
  }

  body.app-active[data-view="home"] .home-screen[data-state="active"] .hero-card.active-conversation .hero-active-waveform {
    height: clamp(24px, 3.68dvh, 40px);
    background-image: url("/assets/icons/voice-waveform.webp") !important;
    background-position: left center !important;
    background-size: auto 100% !important;
    background-repeat: repeat-x !important;
  }

  body.app-active[data-view="home"] .home-screen[data-state="active"] .hero-card.active-conversation .home-active-summary {
    gap: clamp(4px, .64dvh, 7px);
    min-width: 0;
  }

  body.app-active[data-view="home"] .home-screen[data-state="active"] .hero-card.active-conversation .home-active-summary strong {
    overflow: hidden;
    font-size: clamp(18px, 2.3dvh, 25px);
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  body.app-active[data-view="home"] .home-screen[data-state="active"] .hero-card.active-conversation .home-active-summary small {
    overflow: hidden;
    font-size: clamp(13px, 1.66dvh, 18px);
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  body.app-active[data-view="home"] .home-screen[data-state="active"] .hero-card.active-conversation .hero-copy > p:not(.eyebrow) {
    overflow: hidden;
    font-size: clamp(14px, 1.66dvh, 18px);
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  body.app-active[data-view="home"] .home-screen[data-state="active"] .hero-card.active-conversation .hero-actions {
    gap: clamp(4px, 1.29dvh, 14px);
  }

  body.app-active[data-view="home"] .home-screen[data-state="active"] .hero-card.active-conversation .home-primary-action {
    min-height: clamp(48px, 6.17dvh, 67px);
    height: clamp(48px, 6.17dvh, 67px);
    padding-inline: clamp(14px, 2.21dvh, 24px);
    font-size: clamp(15px, 1.84dvh, 20px);
  }

  body.app-active[data-view="home"] .home-screen[data-state="active"] .hero-card.active-conversation .home-primary-action::before {
    width: clamp(26px, 3.31dvh, 36px);
    height: clamp(26px, 3.31dvh, 36px);
    flex-basis: clamp(26px, 3.31dvh, 36px);
  }

  body.app-active[data-view="home"] .home-screen[data-state="active"] .hero-card.active-conversation .home-new-action {
    min-height: clamp(24px, 2.85dvh, 31px);
    height: clamp(24px, 2.85dvh, 31px);
    font-size: clamp(13px, 1.66dvh, 18px);
  }

  body.app-active[data-view="home"] .home-screen[data-state="fresh"] .hero-plate {
    top: clamp(28px, 6.9dvh, 75px);
    width: clamp(104px, 12.9dvh, 140px);
    height: clamp(104px, 12.9dvh, 140px);
  }

  body.app-active[data-view="home"] .home-screen[data-state="fresh"] .hero-wave {
    top: clamp(55px, 10.59dvh, 115px);
    width: clamp(56px, 6.63dvh, 72px);
    height: clamp(46px, 5.89dvh, 64px);
  }

  body.app-active[data-view="home"] .home-screen[data-state="fresh"] .hero-wave-left {
    left: clamp(42px, 6.45dvh, 70px);
  }

  body.app-active[data-view="home"] .home-screen[data-state="fresh"] .hero-wave-right {
    right: clamp(42px, 6.45dvh, 70px);
  }

  body.app-active[data-view="home"] .home-screen[data-state="fresh"] .hero-dialogue-bubble {
    padding: clamp(13px, 1.66dvh, 18px) clamp(16px, 2.03dvh, 22px);
    font-size: clamp(14px, 1.66dvh, 18px);
  }

  body.app-active[data-view="home"] .home-screen[data-state="fresh"] .hero-dialogue-user {
    left: clamp(40px, 5.62dvh, 61px);
    top: clamp(170px, 25.32dvh, 275px);
    width: clamp(190px, 22.65dvh, 246px);
    min-height: clamp(66px, 7.92dvh, 86px);
  }

  body.app-active[data-view="home"] .home-screen[data-state="fresh"] .hero-dialogue-chef {
    left: clamp(86px, 11.42dvh, 124px);
    top: clamp(250px, 34.35dvh, 373px);
    width: clamp(186px, 22.38dvh, 243px);
    min-height: clamp(66px, 8.1dvh, 88px);
  }

  body.app-active[data-view="home"] .home-screen[data-state="fresh"] .hero-copy {
    left: clamp(38px, 5.16dvh, 56px);
    right: clamp(38px, 5.16dvh, 56px);
    bottom: clamp(20px, 2.58dvh, 28px);
  }

  body.app-active[data-view="home"] .home-screen[data-state="fresh"] .hero-copy h1 {
    font-size: clamp(28px, 3.68dvh, 40px);
  }

  body.app-active[data-view="home"] .home-screen[data-state="fresh"] .hero-copy > p:not(.eyebrow) {
    font-size: clamp(14px, 1.84dvh, 20px);
  }

  body.app-active[data-view="home"] .home-screen[data-state="fresh"] .home-primary-action {
    min-height: clamp(48px, 7.37dvh, 80px);
    height: clamp(48px, 7.37dvh, 80px);
    font-size: clamp(15px, 2.03dvh, 22px);
  }
}

/* At the narrow edge of tablet portrait keep the two-column scenario focus,
 * but simplify the assistant card before text can wrap into itself. */
@media (min-width: 701px) and (max-width: 820px) and (orientation: portrait) {
  .home-screen[data-state="fresh"] .hero-dialogue-bubble {
    display: none;
  }

  .home-screen[data-state="fresh"] .hero-plate {
    width: 82px;
    height: 82px;
  }

  .home-screen[data-state="fresh"] .hero-copy {
    padding: 16px 18px 18px;
  }

  .home-screen[data-state="fresh"] .hero-copy h1 {
    font-size: 22px;
  }

  .home-screen[data-state="fresh"] .hero-copy > p:not(.eyebrow) {
    font-size: 13px;
  }

  .home-screen[data-state="fresh"] .home-primary-action {
    min-height: 48px;
    padding-inline: 12px;
    font-size: 14px;
  }

  .home-screen[data-state="fresh"] .home-hero-status {
    font-size: 10px;
  }

  .home-screen[data-state="active"] .guide-column {
    padding-top: 0;
  }

  .home-screen[data-state="active"] .hero-card.active-conversation .hero-copy h1 {
    left: 18px;
    top: 24px;
    font-size: 22px;
    white-space: nowrap;
  }

  .home-screen[data-state="active"] .hero-card.active-conversation .hero-copy > .eyebrow {
    left: 18px;
    top: 58px;
    gap: 6px;
    font-size: 11px;
    white-space: nowrap;
  }

  .home-screen[data-state="active"] .hero-card.active-conversation .hero-copy > .eyebrow::before {
    width: 7px;
    height: 7px;
  }

  .home-screen[data-state="active"] .hero-card.active-conversation .hero-art {
    inset: 90px 18px auto;
    height: 170px;
  }

  .home-screen[data-state="active"] .hero-card.active-conversation .hero-active-visual {
    grid-template-rows: 132px 24px;
    gap: 12px;
  }

  .home-screen[data-state="active"] .hero-card.active-conversation .hero-active-visual img {
    height: 132px;
  }

  .home-screen[data-state="active"] .hero-card.active-conversation .home-active-summary {
    left: 18px;
    right: 18px;
    top: 275px;
  }

  .home-screen[data-state="active"] .hero-card.active-conversation .home-active-summary strong {
    font-size: 17px;
  }

  .home-screen[data-state="active"] .hero-card.active-conversation .home-active-summary small {
    overflow: hidden;
    font-size: 11px;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .home-screen[data-state="active"] .hero-card.active-conversation .hero-copy > p:not(.eyebrow) {
    display: none;
  }

  .home-screen[data-state="active"] .hero-card.active-conversation .hero-actions {
    left: 18px;
    right: 18px;
    top: 360px;
    gap: 8px;
  }

  .home-screen[data-state="active"] .hero-card.active-conversation .home-primary-action {
    min-height: 47px;
    height: 47px;
    padding-inline: 10px;
    font-size: 14px;
  }

  .home-screen[data-state="active"] .hero-card.active-conversation .home-primary-action::before {
    width: 26px;
    height: 26px;
    flex-basis: 26px;
  }

  .home-screen[data-state="active"] .hero-card.active-conversation .home-new-action {
    font-size: 13px;
  }
}

/* Portrait tablets keep the navigation rail, while the conversation uses the
 * same readable one-column recipe note as the phone instead of squeezing the
 * desktop two-column card into the remaining space. */
@media (min-width: 701px) and (max-width: 900px) {
  body[data-view="chat"] #app-screen {
    position: fixed;
    top: var(--app-vv-top, 0px);
    right: 0;
    bottom: auto;
    left: 0;
    width: 100%;
    height: var(--app-vv-height, 100dvh);
  }

  body[data-view="chat"] .chat-layout {
    grid-template-columns: 280px minmax(0, 1fr);
  }

  body[data-view="chat"] .chat-sidebar {
    padding: 26px 18px 20px;
  }

  body[data-view="chat"] .sidebar-brand {
    padding-inline: 10px;
  }

  body[data-view="chat"] .sidebar-brand strong {
    font-size: 33px;
  }

  body[data-view="chat"] .sidebar-new-dialogue {
    box-sizing: border-box;
    max-width: 100%;
    gap: 12px;
    padding-inline: 20px;
  }

  body[data-view="chat"] .message-row.user {
    padding-left: 18%;
  }

  body[data-view="chat"] .message-row.user .message-bubble {
    width: fit-content;
    max-width: 100%;
  }

  body[data-view="chat"] .message-row.assistant {
    padding-right: 0;
  }

  body[data-view="chat"] .message-row.assistant .message-stack:has(.message-article-card) {
    width: auto;
    max-width: 336px;
    flex: 1 1 0;
  }

  body[data-view="chat"] .message-article-card {
    width: 100%;
    min-height: 0;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto 154px auto;
    gap: 10px;
    padding: 13px;
  }

  body[data-view="chat"] .message-article-card > span:first-child,
  body[data-view="chat"] .message-article-image,
  body[data-view="chat"] .message-article-info {
    grid-column: 1;
  }

  body[data-view="chat"] .message-article-card > span:first-child {
    grid-row: 1;
  }

  body[data-view="chat"] .message-article-image {
    grid-row: 2;
    height: 154px;
  }

  body[data-view="chat"] .message-article-info {
    grid-row: 3;
  }

  body[data-view="chat"] .voice-mode-controls {
    grid-template-columns: 52px minmax(0, 1fr) 52px;
    gap: 10px;
    padding-inline: 10px;
  }

  body[data-view="chat"] .voice-mode-waveform,
  body[data-view="chat"] .text-mode-button {
    display: none !important;
  }

  body[data-view="chat"] .voice-mode-speaker {
    grid-column: 3;
  }

  body[data-view="recipe"] .recipe-workspace {
    grid-template-rows: 98px minmax(0, 1fr) 86px;
  }

  body[data-view="recipe"] .recipe-bottom-voice {
    width: auto;
    min-height: 76px;
    height: 76px;
    grid-template-columns: 58px minmax(0, 1fr) 54px;
    grid-template-rows: 62px;
    gap: 8px;
    margin: 5px 16px;
    padding: 7px 9px;
    overflow: hidden;
  }

  body[data-view="recipe"] .recipe-bottom-voice::before {
    display: none;
  }

  body[data-view="recipe"] .recipe-bottom-wave {
    width: 56px;
    height: 56px;
    grid-column: 1;
    grid-row: 1;
    transform: none;
  }

  body[data-view="recipe"] .recipe-bottom-voice > span:nth-child(2) {
    display: none;
  }

  body[data-view="recipe"] .recipe-bottom-voice .recipe-voice-button,
  body[data-view="recipe"] .recipe-text-question {
    min-width: 0;
    min-height: 58px;
    height: 58px;
    grid-row: 1;
    transform: none;
  }

  body[data-view="recipe"] .recipe-bottom-voice .recipe-voice-button {
    grid-column: 2;
    padding-inline: 12px;
    font-size: 14px;
  }

  body[data-view="recipe"] .recipe-text-question {
    width: 54px;
    grid-column: 3;
    padding: 0;
    font-size: 0;
  }

  body[data-view="recipe"] .recipe-voice-status {
    right: 16px;
    bottom: 94px;
    left: 16px;
  }

  body[data-view="library"] .library-shell {
    grid-template-columns: 230px minmax(0, 1fr) !important;
  }

  body[data-view="library"] #library-screen[data-tab="history"] .library-workspace {
    grid-template-columns: minmax(0, 1fr);
  }

  body[data-view="library"] #library-screen[data-tab="history"] #library-preview {
    display: none;
  }

  body[data-view="library"] #library-screen[data-tab="favorites"] .library-workspace,
  body[data-view="library"] #library-screen[data-tab="cookings"] .library-workspace {
    padding-right: 24px;
    padding-left: 24px;
  }

  body[data-view="library"] #library-screen[data-tab="favorites"] .library-toolbar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 42px;
    gap: 10px;
  }

  body[data-view="library"] #library-screen[data-tab="favorites"] .library-toolbar > div {
    grid-column: 1;
  }

  body[data-view="library"] #library-screen[data-tab="favorites"] .library-mobile-sort {
    width: 42px;
    height: 42px;
    display: grid;
    grid-column: 2;
    place-items: center;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: url("/assets/icons/sort.webp") center / 27px 27px no-repeat;
  }

  body[data-view="library"] #library-screen[data-tab="favorites"] .library-filter-controls .library-sort {
    display: none;
  }

  body[data-view="library"] #library-screen[data-tab="favorites"] .library-filter-controls .library-scenario-filters {
    padding-right: 0;
  }

  body[data-view="library"] #library-screen[data-tab="favorites"] #library-list,
  body[data-view="library"] #library-screen[data-tab="cookings"] #library-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
  }

  body[data-view="library"] #library-screen[data-tab="favorites"] :is(.library-card.featured, .library-card.is-latest, .library-list.notes-mode .library-card:first-of-type) {
    min-height: 340px;
    height: auto;
    grid-column: 1 / -1;
    grid-template-rows: 210px minmax(130px, auto);
  }

  body[data-view="library"] #library-screen[data-tab="favorites"] :is(.library-card.featured, .library-card.is-latest, .library-list.notes-mode .library-card:first-of-type) .library-card-photo {
    height: 210px;
  }
}

@media (max-width: 700px) {
  :is(.mic-icon, .home-mic, .hero-mic) { --mic-size: 26px; }
  .ingredient-orbit .plate .hero-mic { --mic-size: 54px; }
  .home-screen[data-state="fresh"] .hero-plate .hero-mic { --mic-size: 44px; }
  .home-primary-action .home-mic { --mic-size: 24px; }
  #home-voice-button .home-mic { --mic-size: 30px; }

  :is(
    #composer-voice-button,
    body[data-view="recipe"] .recipe-voice-button,
    body[data-view="library"] .library-mobile-new,
    body[data-view="library"] .library-preview-actions button
  ) .mic-icon {
    --mic-size: 26px;
  }

  .login-card .primary-action i::before {
    width: 34px;
    height: 34px;
  }

  .hero-card.active-conversation .home-new-action::after {
    content: "";
    width: 22px;
    height: 22px;
    margin-left: 10px;
    display: inline-block;
    background: url("/assets/icons/chevron-right.webp") center / contain no-repeat;
    vertical-align: middle;
  }

  .scenario-card {
    --scenario-footer-height: 63px;
    position: relative;
    grid-template-rows: minmax(0, 1fr) 27px 36px;
    background: #fff;
  }

  .scenario-card-image {
    position: absolute;
    inset: 0 0 auto;
    width: 100%;
    height: calc(100% - var(--scenario-footer-height));
    min-width: 0;
    min-height: 0;
    display: block;
    object-fit: cover;
  }

  .scenario-card strong {
    grid-row: 2;
    position: relative;
    z-index: 1;
  }

  .scenario-card small {
    grid-row: 3;
    position: relative;
    z-index: 1;
  }

  .scenario-card > b {
    z-index: 2;
    background-size: 26px 26px;
  }
}

/* Interaction-state guards found during real-device QA. */
.scenario-card.selected {
  box-shadow: var(--shadow-soft);
}

.scenario-card.selected::after {
  content: "";
  position: absolute;
  z-index: 4;
  inset: 0;
  border: 2px solid var(--green);
  border-radius: inherit;
  display: none;
  pointer-events: none;
}

body.app-active[data-view="home"] .scenario-card.selected:is(:active, :focus-visible)::after {
  display: block;
}

body:has(#mobile-nav[open])::before {
  content: "";
  position: fixed;
  z-index: 40;
  inset: 0;
  background: rgba(14, 25, 18, .24);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
}

#mobile-nav[open] > summary > span {
  background-image: url("/assets/icons/close.webp");
  background-size: 18px 18px;
}

body[data-view="chat"] .empty-mark {
  display: none;
}

body[data-view="chat"] .empty-conversation {
  flex: 1 1 auto;
  min-height: 0;
}

body[data-view="chat"] .conversation-head > div:first-of-type::before {
  background-image: var(--chat-avatar-image, url("/assets/scenarios/quick-v2.webp"));
}

@media (max-width: 700px) {
  .home-screen[data-state="active"] .hero-card.active-conversation .hero-copy {
    --active-actions-width: clamp(132px, 39vw, 146px);
  }

  .home-screen[data-state="active"] .hero-card.active-conversation .home-active-summary {
    padding: 11px calc(var(--active-actions-width) + 8px) 0 0;
    overflow: hidden;
  }

  .home-screen[data-state="active"] .hero-card.active-conversation .home-active-summary strong {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .home-screen[data-state="active"] .hero-card.active-conversation .home-active-summary small {
    min-width: 0;
    display: -webkit-box;
    overflow: hidden;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
  }

  .home-screen[data-state="active"] .hero-card.active-conversation .hero-actions {
    width: var(--active-actions-width);
  }

  body[data-view="chat"] #app-screen {
    position: fixed;
    inset-inline: 0;
    top: var(--app-vv-top, 0px);
    width: 100%;
    height: var(--app-vv-height, 100dvh);
    max-height: var(--app-vv-height, 100dvh);
  }
}

/* Final real-device polish: note, library, materials, and admin screens. */
body[data-view="admin"] .section-heading > span {
  min-height: 28px;
  display: inline-flex;
  align-items: center;
  padding: 0 10px;
  border-radius: 999px;
  color: #4f5a53;
  background: #eef3ef;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

body[data-view="admin"] .admin-layout {
  min-height: 0;
  overflow: visible;
}

body[data-view="admin"] :is(.admin-list-panel, .admin-editor-panel) {
  min-width: 0;
  min-height: 0;
  overflow-x: clip;
  overflow-y: visible;
  overscroll-behavior: auto;
  scrollbar-width: thin;
}

body[data-view="admin"] .admin-scenario-card {
  min-width: 0;
  grid-template-columns: 52px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 11px 12px;
  border: 1px solid transparent;
  background: #f5f8f5;
}

body[data-view="admin"] .admin-scenario-card.selected {
  border-color: var(--green);
  background: #f0f8f1;
  box-shadow: 0 8px 22px rgba(28, 91, 43, .09);
}

body[data-view="admin"] .admin-scenario-card-image,
body[data-view="admin"] .admin-scenario-card:not(:has(.admin-scenario-card-image))::before {
  width: 52px;
  height: 52px;
  grid-column: 1;
  grid-row: 1;
  border-radius: 14px;
  object-fit: cover;
}

body[data-view="admin"] .admin-scenario-card:not(:has(.admin-scenario-card-image))::before {
  content: "";
  background: radial-gradient(circle at 35% 30%, #7cd989, #30aa4d 72%);
}

body[data-view="admin"] .admin-scenario-card-copy {
  min-width: 0;
  grid-column: 2;
  display: grid;
  gap: 6px;
}

body[data-view="admin"] .admin-scenario-card-title {
  overflow: hidden;
  color: #101310;
  font-size: 15px;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

body[data-view="admin"] .admin-scenario-card-meta {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 7px;
  color: #6e7771;
  font-size: 11px;
}

body[data-view="admin"] .admin-scenario-card-id {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

body[data-view="admin"] .admin-scenario-card-status {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: #737b76;
}

body[data-view="admin"] .admin-scenario-card-status::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #aeb5b0;
}

body[data-view="admin"] .admin-scenario-card-status.active {
  color: var(--green-dark);
}

body[data-view="admin"] .admin-scenario-card-status.active::before {
  background: var(--green);
}

body[data-view="admin"] .admin-scenario-card-order {
  grid-column: 3;
  display: grid;
  justify-items: end;
  gap: 2px;
  color: #171a18;
}

body[data-view="admin"] .admin-scenario-card-order-label {
  color: #89908b;
  font-size: 9px;
  font-weight: 600;
}

body[data-view="admin"] .admin-scenario-card-order-value {
  font-size: 14px;
}

body[data-view="admin"] .admin-editor-back {
  min-height: 38px;
  align-items: center;
  gap: 8px;
  margin: -5px 0 12px;
  padding: 0 4px;
  color: var(--green-dark);
  background: transparent;
  font-size: 14px;
  font-weight: 700;
}

body[data-view="admin"] .admin-editor-back:not([hidden]) {
  display: inline-flex;
}

body[data-view="admin"] .admin-form :is(input, textarea, select) {
  min-height: 48px;
  color: #171a18;
  border-color: #dbe1dc;
  background: #fbfcfb;
  font-size: 15px;
  line-height: 1.4;
}

body[data-view="admin"] .admin-form :is(input, textarea, select):focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(46, 170, 74, .12);
}

body[data-view="admin"] .admin-form textarea {
  min-height: 86px;
  overflow: hidden;
  resize: none;
}

body[data-view="admin"] #admin-scenario-prompt {
  min-height: 230px;
}

body[data-view="admin"] .admin-image-field {
  display: grid;
  gap: 7px;
  color: #565d58;
  font-size: 13px;
  font-weight: 700;
}

body[data-view="admin"] .admin-image-input.sr-only {
  position: absolute;
  width: 1px;
  min-width: 1px;
  height: 1px;
  min-height: 0;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  border: 0;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

body[data-view="admin"] .admin-image-field .admin-image-label {
  color: #565d58;
  font-size: 13px;
  font-weight: 700;
}

body[data-view="admin"] .admin-image-picker {
  min-width: 0;
  min-height: 52px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  padding: 7px 12px;
  border: 1px solid #dbe1dc;
  border-radius: 13px;
  background: #fbfcfb;
  cursor: pointer;
}

body[data-view="admin"] .admin-image-field .admin-image-select {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  padding: 0 12px;
  border-radius: 10px;
  color: #172019;
  background: #e8f2e9;
  font-size: 12px;
  font-weight: 750;
  white-space: nowrap;
}

body[data-view="admin"] .admin-image-field .admin-image-name {
  min-width: 0;
  overflow: hidden;
  color: #4e5851;
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

body[data-view="admin"] .admin-image-field .admin-image-help {
  color: #7c847e;
  font-size: 11px;
  font-weight: 500;
}

body[data-view="admin"] .admin-active {
  gap: 10px;
}

body[data-view="admin"] .admin-active input {
  width: 22px;
  height: 22px;
  flex: 0 0 22px;
  padding: 0;
  accent-color: var(--green);
}

body[data-view="admin"] .prompt-improver {
  display: grid;
  gap: 10px;
  padding: 16px;
  border: 1px solid rgba(46, 170, 74, .12);
}

body[data-view="admin"] .admin-form-actions :is(button, .primary-action) {
  min-height: 48px;
  white-space: nowrap;
}

.article-drawer-card {
  position: relative;
  padding-right: 48px;
  border: 1px solid rgba(31, 78, 43, .06);
}

.article-drawer-card::after {
  content: "→";
  position: absolute;
  right: 17px;
  top: 50%;
  color: var(--green-dark);
  font-size: 19px;
  transform: translateY(-50%);
}

.article-drawer-card small {
  color: #626c65;
}

.library-mobile-sort {
  display: none;
}

body[data-view="recipe"] .recipe-hero-saved {
  display: none;
}

:is(.recipe-hero-image, .message-article-image, .library-card-photo)[src*="/assets/recipes/placeholder.svg"] {
  padding: 0;
  object-fit: cover;
  object-position: center;
  background: #eef4ef;
}

@media (max-width: 700px) {
  .home-new-label-long {
    display: none;
  }

  body[data-view="chat"] :is(.conversation-head, .composer),
  body[data-view="recipe"] :is(.recipe-toolbar, .recipe-bottom-voice),
  body[data-view="library"] .library-toolbar {
    background-color: #fff;
  }

  #mobile-nav[open] .mobile-nav-panel {
    z-index: 2;
  }

  #mobile-nav[open] > summary {
    position: relative;
    z-index: 3;
  }

  .mobile-nav-panel #mobile-logout {
    min-height: 54px;
    margin-top: 5px;
    border-top: 1px solid #e6eae7;
    border-radius: 0 0 13px 13px;
  }

  .home-screen[data-state="fresh"] .hero-copy > p:not(.eyebrow) {
    color: #39423c;
    font-size: 11.5px;
    line-height: 1.3;
  }

  .home-screen[data-state="fresh"] .home-hero-status {
    color: #616b64;
    font-size: 9.5px;
  }

  body[data-view="recipe"] .recipe-workspace {
    grid-template-rows:
      calc(61px + env(safe-area-inset-top))
      minmax(0, 1fr)
      calc(72px + env(safe-area-inset-bottom));
  }

  body[data-view="recipe"] .recipe-toolbar {
    min-height: calc(61px + env(safe-area-inset-top));
    height: calc(61px + env(safe-area-inset-top));
    padding-top: env(safe-area-inset-top);
  }

  body[data-view="recipe"] .recipe-hero-saved {
    display: none;
  }

  body[data-view="recipe"] #recipe-content {
    scroll-padding-bottom: 30px;
  }

  body[data-view="recipe"] .recipe-section-grid {
    padding-bottom: 34px;
  }

  body[data-view="recipe"] .recipe-bottom-voice {
    width: auto;
    min-height: calc(66px + env(safe-area-inset-bottom));
    height: calc(66px + env(safe-area-inset-bottom));
    grid-template-columns: 74px minmax(0, 1fr) 54px;
    gap: 8px;
    margin: 0 5px 4px;
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
    border-radius: 18px;
    box-shadow: 0 -4px 15px rgba(25, 56, 35, .055);
  }

  body[data-view="recipe"] .recipe-bottom-wave {
    width: 70px;
    height: 31px;
    background-size: 78px 28px;
  }

  body[data-view="recipe"] .recipe-bottom-voice > span:nth-child(2) {
    display: none;
  }

  body[data-view="recipe"] .recipe-bottom-voice .recipe-voice-button,
  body[data-view="recipe"] :is(.recipe-question-action, .recipe-text-question) {
    min-height: 54px;
    height: 54px;
  }

  body[data-view="recipe"] .recipe-bottom-voice .recipe-voice-button {
    padding-inline: 12px;
    font-size: 13px;
  }

  body[data-view="recipe"] .recipe-text-question {
    width: 54px;
    min-width: 54px;
    padding: 0;
    font-size: 0;
  }

  body[data-view="recipe"] .recipe-text-question > span {
    width: 25px;
    height: 25px;
    display: block;
    overflow: hidden;
    color: transparent;
    background: url("/assets/icons/chat-bubble.webp") center / contain no-repeat;
    font-size: 0;
  }

  body[data-view="recipe"] .recipe-voice-status {
    bottom: calc(76px + env(safe-area-inset-bottom));
  }

  body[data-view="library"] .library-filter-controls {
    overflow: hidden;
  }

  body[data-view="library"] .library-filter-controls .library-scenario-filters {
    box-sizing: border-box;
    overflow-x: auto;
    overflow-y: hidden;
    padding-right: 22px;
    scroll-padding-inline: 0 22px;
    scroll-snap-type: x proximity;
    scrollbar-width: none;
  }

  body[data-view="library"] .library-filter-controls .library-scenario-filters::-webkit-scrollbar {
    display: none;
  }

  body[data-view="library"] .library-filter-controls .library-scenario-filters button {
    flex: 0 0 auto;
    scroll-snap-align: start;
  }

  body[data-view="library"] #library-screen[data-tab="history"] .library-toolbar::after {
    visibility: hidden;
    background: none;
  }

  body[data-view="library"] #library-screen[data-tab="favorites"] .library-toolbar::after {
    content: none;
  }

  body[data-view="library"] #library-screen[data-tab="favorites"] .library-toolbar {
    grid-template-columns: 39px minmax(0, 1fr) 42px;
  }

  body[data-view="library"] #library-screen[data-tab="favorites"] .library-mobile-sort {
    width: 42px;
    height: 42px;
    display: grid;
    grid-column: 3;
    place-items: center;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: url("/assets/icons/sort.webp") center / 27px 27px no-repeat;
  }

  body[data-view="library"] #library-screen[data-tab="history"] :is(.dialogue-history-card, .history-card) {
    min-height: 136px;
  }

  body[data-view="library"] #library-screen[data-tab="history"] :is(.dialogue-history-card, .history-card) > span strong {
    padding-right: 48px;
    display: -webkit-box;
    overflow: hidden;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    line-height: 1.18;
    text-overflow: ellipsis;
    white-space: normal;
  }

  body[data-view="library"] #library-screen[data-tab="favorites"] :is(.library-card.featured, .library-card.is-latest, .library-list.notes-mode .library-card:first-of-type) {
    min-height: 284px;
    height: auto;
    grid-template-rows: 168px minmax(116px, auto);
  }

  body[data-view="library"] #library-screen[data-tab="favorites"] .library-card.featured .library-card-body {
    min-height: 116px;
    padding: 12px 13px 11px;
  }

  body[data-view="library"] #library-screen[data-tab="favorites"] .library-card.featured .library-card-body h2 {
    min-height: 50px;
    padding-right: 50px;
    display: -webkit-box;
    overflow: hidden;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    line-height: 1.06;
    text-overflow: ellipsis;
    white-space: normal;
  }

  body[data-view="library"] #library-screen[data-tab="favorites"] .library-card.featured .library-card-meta {
    margin-top: 3px;
  }

  body[data-view="library"] #library-screen[data-tab="favorites"] .library-card.featured .library-card-source {
    padding-right: 50px;
  }

  body[data-view="admin"] .admin-screen {
    height: 100%;
    display: block;
    padding: 0 12px calc(12px + env(safe-area-inset-bottom));
    overflow-y: auto;
  }

  body[data-view="admin"] .admin-screen > .library-toolbar {
    min-width: 0;
    min-height: calc(108px + env(safe-area-inset-top));
    height: calc(108px + env(safe-area-inset-top));
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    grid-template-rows: 52px 46px;
    align-items: center;
    gap: 10px;
    padding: env(safe-area-inset-top) 2px 0;
    flex-wrap: nowrap;
  }

  body[data-view="admin"] .admin-screen > .library-toolbar > div {
    min-width: 0;
    grid-column: 2;
    grid-row: 1;
  }

  body[data-view="admin"] .admin-screen > .library-toolbar .eyebrow {
    display: none;
  }

  body[data-view="admin"] .admin-screen > .library-toolbar h1 {
    margin: 0;
    overflow: hidden;
    font-size: clamp(22px, 7vw, 29px);
    line-height: 1;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  body[data-view="admin"] #admin-back {
    grid-column: 1;
    grid-row: 1;
    min-height: 42px;
    padding: 0 3px;
    white-space: nowrap;
  }

  body[data-view="admin"] #admin-new-scenario {
    grid-column: 1 / -1;
    grid-row: 2;
    justify-self: start;
    min-width: 184px;
    min-height: 42px;
    height: 42px;
    padding: 0 14px;
    font-size: 13px;
    white-space: nowrap;
  }

  body[data-view="admin"] .admin-layout {
    height: auto;
    display: block;
    overflow: visible;
    overscroll-behavior: contain;
    scroll-behavior: smooth;
    scrollbar-width: none;
  }

  body[data-view="admin"] .admin-layout::-webkit-scrollbar {
    display: none;
  }

  body[data-view="admin"] :is(.admin-list-panel, .admin-editor-panel) {
    min-height: 100%;
    padding: 20px 16px;
    overflow: visible;
    border-radius: 24px;
  }

  body[data-view="admin"] .admin-editor-panel {
    margin-top: 12px;
  }

  body[data-view="admin"] .admin-list-panel .section-heading,
  body[data-view="admin"] .admin-editor-panel .section-heading {
    margin-bottom: 14px;
  }

  body[data-view="admin"] .admin-list-panel h2,
  body[data-view="admin"] .admin-editor-panel h2 {
    font-size: 24px;
  }

  body[data-view="admin"] .admin-scenario-card {
    grid-template-columns: 48px minmax(0, 1fr) auto;
    min-height: 76px;
  }

  body[data-view="admin"] .admin-scenario-card-image,
  body[data-view="admin"] .admin-scenario-card:not(:has(.admin-scenario-card-image))::before {
    width: 48px;
    height: 48px;
    border-radius: 13px;
  }

  body[data-view="admin"] .admin-scenario-card-title {
    font-size: 16px;
  }

  body[data-view="admin"] .admin-form {
    gap: 14px;
  }

  body[data-view="admin"] .admin-form-row {
    grid-template-columns: minmax(0, 1fr) 92px;
    gap: 10px;
  }

  body[data-view="admin"] #admin-scenario-prompt {
    min-height: 260px;
  }

  body[data-view="admin"] .prompt-improver {
    margin-top: 2px;
  }

  body[data-view="admin"] .admin-form-actions {
    position: static;
    display: grid;
    grid-template-columns: minmax(0, .7fr) minmax(0, 1.3fr);
    gap: 10px;
    margin: 8px 0 0;
    padding: 0 0 max(4px, env(safe-area-inset-bottom));
    background: transparent;
  }

  body[data-view="admin"] .admin-form-actions :is(button, .primary-action) {
    min-width: 0;
    padding-inline: 10px;
    font-size: 14px;
    line-height: 1.15;
  }

  .article-drawer {
    padding: max(24px, env(safe-area-inset-top)) 20px max(24px, env(safe-area-inset-bottom));
  }
}

@media (max-width: 360px) {
  body[data-view="recipe"] .recipe-bottom-voice {
    grid-template-columns: 52px minmax(0, 1fr) 48px;
    gap: 6px;
  }

  body[data-view="recipe"] .recipe-bottom-wave {
    width: 50px;
    background-size: 58px 24px;
  }

  body[data-view="recipe"] .recipe-text-question {
    width: 48px;
    min-width: 48px;
  }

  body[data-view="recipe"] .recipe-bottom-voice .recipe-voice-button {
    gap: 7px;
    padding-inline: 8px;
    font-size: 12px;
  }

  body[data-view="admin"] #admin-back > span {
    display: none;
  }

  body[data-view="admin"] #admin-new-scenario {
    padding-inline: 11px;
    font-size: 12px;
  }
}

@media (max-width: 700px) {
  body[data-view="admin"] .admin-screen:not([data-mobile-panel="editor"]) .admin-editor-panel,
  body[data-view="admin"] .admin-screen[data-mobile-panel="editor"] .admin-list-panel {
    display: none;
  }

  body[data-view="admin"] .admin-editor-panel {
    margin-top: 0;
  }

  body[data-view="admin"] #admin-editor-mode {
    display: none;
  }

}

@media (min-width: 701px) {
  .home-new-label-short {
    display: none;
  }
}

@media (max-width: 430px) {
  body[data-view="admin"] #admin-back > span {
    display: none;
  }

  body[data-view="admin"] .admin-screen > .library-toolbar h1 {
    font-size: clamp(21px, 5.8vw, 24px);
  }
}

/* The decorative side waves are square icons, not stretched snippets of the
 * long playback waveform. Keep their source and rendered geometry 1:1. */
body.app-active[data-view="home"] .home-screen[data-state="fresh"] .hero-wave {
  overflow: hidden;
  color: transparent;
  background: url("/assets/icons/voice-wave.webp") center / contain no-repeat;
  font-size: 0;
  letter-spacing: 0;
}

@media (max-width: 1199px) {
  body.app-active[data-view="home"] .home-screen[data-state="active"] .hero-active-waveform {
    overflow: hidden;
    color: transparent;
    background: url("/assets/icons/voice-waveform.webp") left center / auto 100% repeat-x !important;
    font-size: 0;
    letter-spacing: 0;
  }
}

@media (min-width: 701px) and (max-width: 1199px) {
  body.app-active[data-view="home"] .home-screen[data-state="fresh"] .hero-wave {
    width: 64px;
    height: 54px;
  }
}

@media (max-width: 700px) {
  body.app-active[data-view="home"] .home-screen[data-state="fresh"] .hero-wave {
    width: 42px;
    height: 42px;
  }

  body.app-active[data-view="home"] .home-screen[data-state="fresh"] .hero-wave-right {
    left: 119px;
  }
}

/* The obsolete visual voice strip stays hidden. Status announcements remain
 * available through their sr-only live regions. */
body[data-view="chat"] .voice-mode-controls {
  display: none !important;
}

body[data-view="chat"] .composer[data-input-mode="voice"] #composer-voice-button {
  display: grid !important;
}

body[data-view="chat"] .composer[data-input-mode="voice"] .send-button,
body[data-view="chat"] .composer[data-input-mode="text"] #composer-voice-button {
  display: none !important;
}

body[data-view="chat"] .composer[data-input-mode="text"] .send-button {
  grid-column: 3;
  display: grid !important;
}

.home-composer[data-input-mode="voice"] #home-voice-button {
  display: grid !important;
}

.home-composer[data-input-mode="voice"] .home-send-button,
.home-composer[data-input-mode="text"] #home-voice-button {
  display: none !important;
}

.home-composer[data-input-mode="text"] .home-send-button {
  display: grid !important;
}

:is(#send-button, #home-send-button) .send-icon {
  width: 30px;
  height: 30px;
  display: block;
  flex: 0 0 30px;
  aspect-ratio: 1 / 1;
  background: url("/assets/icons/send-white.webp") center / contain no-repeat;
}

/* Four-state hybrid chat composer: text, hold-to-record, continuous voice,
 * and continuous voice with a non-destructive text entry. */
body[data-view="chat"] .composer {
  --composer-control: 58px;
  --composer-gap: 12px;
  min-height: 82px;
  height: auto;
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: var(--composer-control) minmax(0, 1fr) var(--composer-control) var(--composer-control);
  grid-auto-rows: minmax(var(--composer-control), auto);
  gap: var(--composer-gap);
  padding: 12px;
  touch-action: manipulation;
}

body[data-view="chat"] .composer .composer-speaker-button,
body[data-view="chat"] .composer #composer-voice-button,
body[data-view="chat"] .composer .composer-continuous-button,
body[data-view="chat"] .composer .composer-text-chat-button,
body[data-view="chat"] .composer .composer-stop-button {
  width: var(--composer-control);
  min-width: var(--composer-control);
  height: var(--composer-control);
  min-height: var(--composer-control);
  aspect-ratio: 1 / 1;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 50%;
  cursor: pointer;
}

body[data-view="chat"] .composer[data-composer-state="ordinary"] #composer-voice-button {
  display: grid !important;
}

body[data-view="chat"] .composer[data-composer-state="ordinary"] :is(
  .composer-recording,
  .composer-active-voice,
  .composer-text-chat-button,
  .composer-stop-button
) {
  display: none !important;
}

body[data-view="chat"] .composer .composer-speaker-button {
  grid-column: 1;
  color: #237f3a;
  background: #e8f4ea;
  box-shadow: inset 0 0 0 1px rgba(35, 142, 61, .07);
}

.speaker-toggle-icon {
  position: relative;
  width: 28px;
  height: 28px;
  display: block;
  background: url("/assets/icons/speaker.webp") center / contain no-repeat;
  pointer-events: none;
}

body[data-view="chat"] .composer-speaker-button[data-enabled="false"] {
  color: #6e7771;
  background: #edf0ee;
}

body[data-view="chat"] .composer-speaker-button[data-enabled="false"] .speaker-toggle-icon {
  filter: grayscale(1);
  opacity: .68;
}

body[data-view="chat"] .composer-speaker-button[data-enabled="false"] .speaker-toggle-icon::after {
  content: "";
  position: absolute;
  left: 3px;
  top: 13px;
  width: 23px;
  height: 2px;
  border-radius: 2px;
  background: #4f5752;
  box-shadow: 0 0 0 2px #edf0ee;
  transform: rotate(-45deg);
}

body[data-view="chat"] .composer-text-field {
  position: relative;
  min-width: 0;
  grid-column: 2;
  display: block;
}

body[data-view="chat"] .composer .composer-text-field textarea {
  width: 100%;
  height: var(--composer-control) !important;
  min-height: var(--composer-control);
  max-height: 138px;
  display: block;
  padding: 16px 56px 16px 20px;
  border-radius: 20px;
  line-height: 1.35;
  white-space: nowrap;
}

body[data-view="chat"] .composer .composer-inline-send {
  position: absolute;
  top: 50%;
  right: 8px;
  width: 42px;
  min-width: 42px;
  height: 42px;
  min-height: 42px;
  display: none !important;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 50%;
  color: #fff;
  background: #111412;
  box-shadow: 0 5px 14px rgba(15, 20, 17, .16);
  transform: translateY(-50%);
}

body[data-view="chat"] .composer[data-has-text="true"] .composer-inline-send {
  display: grid !important;
}

body[data-view="chat"] .composer .composer-inline-send .send-icon {
  width: 24px;
  height: 24px;
  flex-basis: 24px;
}

body[data-view="chat"] .composer #composer-voice-button {
  grid-column: 3;
  color: #fff;
  background: linear-gradient(145deg, #55d365, #24943e);
  box-shadow: 0 7px 18px rgba(36, 145, 58, .2);
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

body[data-view="chat"] .composer .composer-continuous-button {
  grid-column: 4;
  color: #fff;
  background: #111412;
  box-shadow: 0 7px 18px rgba(15, 20, 17, .16);
}

.continuous-wave-icon,
.text-chat-icon,
.stop-square-icon {
  width: 28px;
  height: 28px;
  display: block;
  pointer-events: none;
}

.continuous-wave-icon {
  background: url("/assets/icons/voice-wave-white.webp") center / contain no-repeat;
}

.text-chat-icon {
  background: url("/assets/icons/chat-bubble.webp") center / contain no-repeat;
}

.stop-square-icon {
  position: relative;
}

.stop-square-icon::before {
  content: "";
  position: absolute;
  inset: 7px;
  border-radius: 3px;
  background: #fff;
}

body[data-view="chat"] .composer-recording,
body[data-view="chat"] .composer-active-voice {
  min-width: 0;
  display: none;
  align-items: center;
}

body[data-view="chat"] .composer-recording {
  grid-column: 2 / 4;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  height: var(--composer-control);
  padding: 8px 18px;
  border: 1px solid #d8deda;
  border-radius: 20px;
  background: #fff;
}

.voice-waveform-icon {
  min-width: 0;
  height: 32px;
  display: block;
  overflow: hidden;
  background: url("/assets/icons/voice-waveform.webp") left center / auto 32px repeat-x;
}

body[data-view="chat"] .composer-recording time {
  min-width: 42px;
  color: #26302a;
  font-size: 15px;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  text-align: right;
}

body[data-view="chat"] .composer[data-composer-state="recording"] .composer-recording {
  display: grid;
  grid-column: 2;
}

/* Connection/permission is not an active microphone. Keep the normal input
   visible and offer cancellation at the continuous voice control's position. */
body[data-view="chat"] .composer[data-voice-connecting="true"] .composer-continuous-button {
  display: none !important;
}

body[data-view="chat"] .composer[data-voice-connecting="true"] .composer-stop-button {
  display: grid !important;
  grid-column: 4;
}

body[data-view="chat"] .composer[data-composer-state="recording"] .composer-speaker-button {
  display: grid !important;
  grid-column: 1;
}

body[data-view="chat"] .composer[data-composer-state="recording"] #composer-voice-button {
  display: grid !important;
  grid-column: 3;
  animation: composer-recording-pulse 1.2s ease-in-out infinite;
}

body[data-view="chat"] .composer[data-composer-state="recording"] :is(
  .composer-text-field,
  .composer-text-chat-button,
  .composer-stop-button
) {
  display: none !important;
}

body[data-view="chat"] .composer-active-voice {
  grid-column: 1;
  grid-template-columns: minmax(86px, 150px) minmax(120px, 1fr);
  gap: 14px;
  height: var(--composer-control);
  padding: 8px 18px;
  border: 1px solid rgba(48, 164, 72, .16);
  border-radius: 20px;
  background: linear-gradient(90deg, rgba(228, 242, 231, .94), rgba(240, 247, 241, .96));
}

body[data-view="chat"] .composer-active-voice strong {
  overflow: hidden;
  color: #18351f;
  font-size: 15px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

body[data-view="chat"] .composer .composer-text-chat-button {
  grid-column: 2;
  background: #e8f4ea;
}

body[data-view="chat"] .composer .composer-text-chat-button[aria-pressed="true"] {
  background: #cfead5;
  box-shadow: inset 0 0 0 2px rgba(35, 142, 61, .28);
}

body[data-view="chat"] .composer .composer-stop-button {
  grid-column: 3;
  color: #fff;
  background: #db3d3d;
  box-shadow: 0 7px 18px rgba(185, 40, 40, .22);
}

body[data-view="chat"] .composer[data-composer-state="voice-active"],
body[data-view="chat"] .composer[data-composer-state="voice-text"] {
  grid-template-columns: minmax(0, 1fr) var(--composer-control) var(--composer-control);
}

body[data-view="chat"] .composer[data-composer-state^="voice-"] :is(
  .composer-speaker-button,
  #composer-voice-button,
  .composer-continuous-button
) {
  display: none !important;
}

body[data-view="chat"] .composer[data-composer-state^="voice-"] .composer-active-voice,
body[data-view="chat"] .composer[data-composer-state^="voice-"] .composer-text-chat-button,
body[data-view="chat"] .composer[data-composer-state^="voice-"] .composer-stop-button {
  display: grid !important;
}

body[data-view="chat"] .composer[data-composer-state="voice-active"] .composer-text-field {
  display: none;
}

body[data-view="chat"] .composer[data-composer-state="voice-text"] .composer-active-voice {
  grid-column: 1;
  grid-row: 1;
}

body[data-view="chat"] .composer[data-composer-state="voice-text"] .composer-text-chat-button,
body[data-view="chat"] .composer[data-composer-state="voice-text"] .composer-stop-button {
  grid-row: 1;
}

body[data-view="chat"] .composer[data-composer-state="voice-text"] .composer-text-field {
  grid-column: 1 / -1;
  grid-row: 2;
  display: block;
}

@keyframes composer-recording-pulse {
  50% { box-shadow: 0 0 0 8px rgba(43, 164, 68, .12), 0 7px 18px rgba(36, 145, 58, .2); }
}

@media (max-width: 700px) {
  body[data-view="chat"] .composer {
    --composer-control: 50px;
    --composer-gap: 8px;
    grid-template-columns: 44px minmax(0, 1fr) var(--composer-control) var(--composer-control);
    padding: 10px;
    border-radius: 22px;
  }

  body[data-view="chat"] .composer .composer-speaker-button {
    width: 44px;
    min-width: 44px;
    height: 44px;
    min-height: 44px;
  }

  body[data-view="chat"] .composer .composer-text-field textarea {
    height: var(--composer-control) !important;
    min-height: var(--composer-control);
    padding: 14px 48px 14px 14px;
    font-size: 15px;
  }

  body[data-view="chat"] .composer .composer-inline-send {
    right: 6px;
    width: 38px;
    min-width: 38px;
    height: 38px;
    min-height: 38px;
  }

  body[data-view="chat"] .composer-recording {
    gap: 8px;
    padding-inline: 12px;
  }

  body[data-view="chat"] .composer-active-voice {
    grid-template-columns: 72px minmax(0, 1fr);
    gap: 8px;
    padding-inline: 12px;
  }

  body[data-view="chat"] .composer-active-voice strong {
    font-size: 13px;
  }
}

@media (max-width: 380px) {
  body[data-view="chat"] .composer {
    --composer-control: 46px;
    --composer-gap: 6px;
    grid-template-columns: 40px minmax(0, 1fr) var(--composer-control) var(--composer-control);
    padding-inline: 7px;
  }

  body[data-view="chat"] .composer .composer-speaker-button {
    width: 40px;
    min-width: 40px;
    height: 40px;
    min-height: 40px;
  }

  body[data-view="chat"] .composer-active-voice {
    grid-template-columns: 58px minmax(0, 1fr);
    padding-inline: 9px;
  }

  body[data-view="chat"] .composer-recording-waveform {
    background-size: auto 26px;
  }
}

@media (prefers-reduced-motion: reduce) {
  body[data-view="chat"] .composer[data-composer-state="recording"] #composer-voice-button {
    animation: none;
  }
}

/* Mobile library and navigation hardening from the final device review. */
.mobile-nav-panel-head {
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 4px 4px 14px;
  border-bottom: 1px solid #e6eae7;
}

.mobile-nav-panel-head strong {
  font-size: 15px;
  font-weight: 760;
}

.mobile-nav-panel .mobile-nav-close {
  width: 44px;
  min-width: 44px;
  height: 44px;
  min-height: 44px;
  display: grid;
  place-items: center;
  padding: 0;
  border-radius: 50%;
  background: #f1f5f2;
}

.mobile-nav-close > span {
  width: 20px;
  height: 20px;
  display: block;
  background: url("/assets/icons/close.webp") center / contain no-repeat;
}

.mobile-nav-panel > button:not(.mobile-nav-close) {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid transparent;
}

.mobile-nav-panel > button:not(.mobile-nav-close)::after {
  content: "";
  width: 20px;
  height: 20px;
  flex: 0 0 20px;
  margin-left: auto;
  background: url("/assets/icons/chevron-right.webp") center / contain no-repeat;
  opacity: .58;
}

.mobile-nav-panel > button:is(:hover, :focus-visible),
.mobile-nav-panel > button.active,
.mobile-nav-panel > button[aria-current="page"] {
  border-color: rgba(40, 151, 65, .13);
  background: var(--green-soft);
}

.mobile-nav-panel > button.active,
.mobile-nav-panel > button[aria-current="page"] {
  color: var(--green-dark);
}

#mobile-article-count {
  min-width: 24px;
  min-height: 24px;
  display: inline-grid;
  place-items: center;
  padding: 0 7px;
  border-radius: 999px;
  color: var(--green-dark);
  background: #e2f1e5;
  font-size: 12px;
  font-weight: 780;
  line-height: 1;
}

.mobile-nav-panel #mobile-logout::after {
  content: none;
}

#mobile-nav[open] > summary {
  visibility: hidden;
  pointer-events: none;
}

@media (max-width: 700px) {
  .mobile-nav-panel {
    width: min(300px, calc(100vw - 28px));
    max-height: calc(100dvh - 86px - env(safe-area-inset-top));
    overflow-y: auto;
    padding: 9px;
    border-radius: 22px;
    overscroll-behavior: contain;
  }

  body[data-view="library"] .library-filter-controls {
    position: relative;
    overflow: hidden !important;
    isolation: isolate;
  }

  body[data-view="library"] .library-filter-controls .library-scenario-filters {
    width: 100% !important;
    max-width: 100%;
    min-width: 0;
    flex: 1 1 auto;
    box-sizing: border-box;
    padding-right: 42px !important;
    scroll-padding-inline: 0 42px;
    touch-action: pan-x;
  }

  body[data-view="library"] .library-filter-controls::before,
  body[data-view="library"] .library-filter-controls::after {
    content: "";
    position: absolute;
    z-index: 3;
    top: 4px;
    bottom: 4px;
    width: 46px;
    display: flex;
    align-items: center;
    box-sizing: border-box;
    color: #202521;
    background: linear-gradient(90deg, rgba(242, 247, 243, 0), #f2f7f3 55%);
    font-size: 24px;
    line-height: 1;
    opacity: 0;
    pointer-events: none;
    transition: opacity .16s ease;
  }

  body[data-view="library"] .library-filter-controls::before {
    left: 0;
    justify-content: flex-start;
    padding-left: 6px;
    background: linear-gradient(270deg, rgba(242, 247, 243, 0), #f2f7f3 55%);
  }

  body[data-view="library"] .library-filter-controls::after {
    right: 0;
    justify-content: flex-end;
    padding-right: 6px;
  }

  body[data-view="library"] .library-filter-controls[data-scrollable="true"][data-scroll-start="false"]::before {
    content: "‹";
    opacity: 1;
  }

  body[data-view="library"] .library-filter-controls[data-scrollable="true"][data-scroll-end="false"]::after {
    content: "›";
    opacity: 1;
  }

  body[data-view="library"] #library-list {
    padding-bottom: calc(108px + env(safe-area-inset-bottom)) !important;
    scroll-padding-bottom: calc(108px + env(safe-area-inset-bottom));
  }

  body[data-view="library"] .library-mobile-new {
    z-index: 12;
  }

  body[data-view="library"] #library-screen[data-tab="favorites"] .library-card {
    height: auto !important;
    min-height: 244px;
    grid-template-rows: 112px minmax(132px, auto);
  }

  body[data-view="library"] #library-screen[data-tab="favorites"] .library-card-body {
    min-height: 132px;
    padding: 11px 12px 12px;
  }

  body[data-view="library"] #library-screen[data-tab="favorites"] .library-card-body h2 {
    min-height: 0;
    display: -webkit-box;
    overflow: hidden;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 3;
    overflow-wrap: anywhere;
    line-height: 1.16;
    text-overflow: ellipsis;
    white-space: normal;
  }

  body[data-view="library"] #library-screen[data-tab="favorites"] .library-card-meta {
    display: -webkit-box;
    overflow: hidden;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    overflow-wrap: anywhere;
    line-height: 1.28;
    white-space: normal;
  }

  body[data-view="library"] #library-screen[data-tab="favorites"] .library-card-footer {
    min-height: 40px;
    padding-top: 8px;
  }

  body[data-view="library"] #library-screen[data-tab="favorites"] :is(
    .library-card.featured,
    .library-card.is-latest,
    .library-list.notes-mode .library-card:first-of-type
  ) {
    height: auto !important;
    min-height: 318px;
    grid-template-rows: 168px minmax(150px, auto);
  }

  body[data-view="library"] #library-screen[data-tab="favorites"] .library-card.featured .library-card-body {
    min-height: 150px;
    padding: 12px 13px 14px;
  }

  body[data-view="library"] #library-screen[data-tab="favorites"] .library-card.featured .library-card-body h2 {
    min-height: 0;
    -webkit-line-clamp: 3;
  }

  body[data-view="library"] #library-screen[data-tab="favorites"] .library-card-source {
    display: -webkit-box;
    overflow: hidden;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    overflow-wrap: anywhere;
    white-space: normal;
  }
}

@media (max-width: 350px) {
  body[data-view="library"] #library-screen[data-tab="favorites"] #library-list {
    grid-template-columns: minmax(0, 1fr);
  }

  body[data-view="library"] #library-screen[data-tab="favorites"] .library-card:not(.featured):not(.is-latest) {
    grid-template-rows: 148px minmax(116px, auto);
  }

  body[data-view="library"] #library-screen[data-tab="favorites"] .library-card:not(.featured):not(.is-latest) .library-card-photo {
    height: 148px;
  }
}

/* Useful, compact first-run state without positional voice instructions. */
body[data-view="chat"] .empty-conversation {
  width: min(100%, 720px);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-self: center;
  gap: 24px;
  padding: clamp(34px, 8vh, 92px) 12px 28px;
  transform: translateY(-3vh);
}

body[data-view="chat"] .empty-conversation-copy {
  display: grid;
  gap: 10px;
}

body[data-view="chat"] .empty-conversation-copy > span {
  color: var(--chat-green-dark);
  font-size: 12px;
  font-weight: 780;
  letter-spacing: .13em;
}

body[data-view="chat"] .empty-conversation h3,
body[data-view="chat"] .empty-conversation p {
  margin: 0;
}

body[data-view="chat"] .empty-conversation h3 {
  font-size: clamp(25px, 3vw, 34px);
  line-height: 1.08;
}

body[data-view="chat"] .empty-conversation p {
  max-width: 620px;
  color: #4f5852;
  font-size: clamp(15px, 1.6vw, 18px);
  line-height: 1.45;
}

body[data-view="chat"] .empty-prompts {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

body[data-view="chat"] .empty-prompts button {
  min-height: 44px;
  padding: 0 17px;
  border: 1px solid #d5dfd8;
  border-radius: 999px;
  color: #263029;
  background: rgba(255, 255, 255, .82);
  font-size: 14px;
  font-weight: 650;
  text-align: left;
  box-shadow: 0 5px 16px rgba(25, 72, 38, .045);
}

body[data-view="chat"] .empty-prompts button:is(:hover, :focus-visible) {
  border-color: rgba(40, 151, 65, .42);
  background: var(--chat-green-soft);
}

@media (max-width: 700px) {
  body[data-view="chat"] .empty-conversation {
    justify-content: flex-start;
    gap: 20px;
    padding: clamp(34px, 7vh, 68px) 7px 20px;
    transform: none;
  }

  body[data-view="chat"] .empty-conversation-copy {
    gap: 9px;
  }

  body[data-view="chat"] .empty-conversation-copy > span {
    font-size: 10px;
  }

  body[data-view="chat"] .empty-conversation h3 {
    font-size: 24px;
  }

  body[data-view="chat"] .empty-conversation p {
    font-size: 15px;
    line-height: 1.42;
  }

  body[data-view="chat"] .empty-prompts {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
  }

  body[data-view="chat"] .empty-prompts button {
    width: 100%;
    min-height: 46px;
    padding-inline: 15px 44px;
    background:
      url("/assets/icons/chevron-right.webp") right 14px center / 18px 18px no-repeat,
      rgba(255, 255, 255, .86);
  }
}
body[data-view="chat"] .message-quick-replies {
  margin-top: 10px;
  min-width: 0;
}

body[data-view="chat"] .message-quick-replies button {
  max-width: 100%;
  padding-block: 10px;
  white-space: normal;
  overflow-wrap: anywhere;
}

/* An optional image failure stays beside the recipe, outside dialogue errors. */
body[data-view="recipe"] .recipe-image-status:not([hidden]) {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 16px;
  margin: 8px 20px 16px;
  color: #70757c;
  font-size: 14px;
  line-height: 1.4;
}

body[data-view="recipe"] .recipe-image-status button:not([hidden]) {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  height: auto;
  margin: 0;
  padding: 8px 0;
  color: #244b8e;
  border: 0;
  background: transparent;
  font: inherit;
}
/* Optional routed clarification shares the existing message and button styles. */
.clarification-options {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.clarification-options button {
  min-height: 44px;
  white-space: normal;
  text-align: left;
}

.clarification-options small {
  flex-basis: 100%;
  color: #70757c;
}
