/* The same bookmark state is used in the recipe toolbar and recipe list. */
body[data-view="recipe"] #recipe-toolbar #recipe-favorite {
  flex: 0 0 44px; width: 44px; height: 44px; min-height: 44px; padding: 0;
  display: grid; place-items: center; border-radius: 50%; cursor: pointer;
  background: linear-gradient(145deg, #f5faf0, #e0edd9);
}
body[data-view="recipe"] #recipe-toolbar #recipe-favorite[hidden] { display: none; }
#recipe-favorite::before,
body[data-view="library"] #library-screen .library-card-bookmark::before {
  content: "" !important; width: 24px !important; height: 24px !important;
  border: 0 !important; clip-path: none !important;
  background: url("/assets/icons/bookmark-empty.svg") center / contain no-repeat !important;
}
#recipe-favorite[aria-pressed="true"]::before,
body[data-view="library"] #library-screen .library-card-bookmark[aria-pressed="true"]::before {
  background-image: url("/assets/icons/bookmark-saved.webp") !important;
}
#recipe-favorite[aria-busy="true"], .library-card-bookmark[aria-busy="true"] { opacity: .55; cursor: wait; }
.library-scenario-filters button[hidden] { display: none !important; }
body[data-view="library"] #library-screen[data-tab="favorites"] .library-card-actions { margin-left: auto; }
@media (min-width: 701px) and (max-width: 1199px) {
  body[data-view="recipe"] #recipe-toolbar { gap: 12px; }
  body[data-view="recipe"] #recipe-toolbar .recipe-toolbar-actions { gap: 12px; }
  body[data-view="recipe"] #recipe-toolbar :is(.recipe-saved-status, .recipe-return-dialogue) { display: none; }
}

/* Admin-authored scenarios. Chat retains its original responsive sidebar grid. */

body.app-active[data-view="home"] .scenario-card {
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr) 80px;
  min-height: 0;
}
body.app-active[data-view="home"] .scenario-section {
  grid-template-rows: minmax(0, 1fr);
}
body.app-active[data-view="home"] .scenario-section .section-heading { display: none; }
body.app-active[data-view="home"] .scenario-card-caption {
  grid-row: 2;
  grid-column: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 28px;
  grid-template-rows: 18px 32px;
  gap: 6px 8px;
  padding: 12px;
  min-width: 0;
  background: #fff;
  align-content: start;
}
body.app-active[data-view="home"] .scenario-card-caption strong {
  grid-row: 1;
  grid-column: 1 / -1;
  min-width: 0;
  margin: 0;
  font-size: clamp(13px, 1.3vw, 18px);
  line-height: 18px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
body.app-active[data-view="home"] .scenario-card-caption small {
  grid-row: 2;
  grid-column: 1;
  min-width: 0;
  min-height: 32px;
  max-height: 32px;
  margin: 0;
  font: 13px/16px Arial, sans-serif;
  white-space: normal;
  overflow-wrap: anywhere;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
}
body.app-active[data-view="home"] .scenario-card-caption > b {
  grid-row: 2;
  grid-column: 2;
  width: 28px;
  height: 28px;
  margin: 0;
  border-radius: 50%;
  font-size: 0;
  background: #edf5ef url("/assets/icons/arrow-right.webp") center / 20px 20px no-repeat;
  align-self: end;
  justify-self: end;
}
body.app-active[data-view="home"] .scenario-card-caption > b.external {
  background-image: url("/assets/icons/external-link.webp");
}
.admin-description-preview { display: grid; gap: 8px; color: #656c67; font-size: 12px; }
.admin-description-preview small {
  display: block;
  width: 130px;
  font: 13px/18px Arial, sans-serif;
  white-space: normal;
  overflow-wrap: anywhere;
}
.admin-description-preview .invalid { color: #b52a25; }

.admin-dialogue-preview-label { margin: 28px 0 12px; font-size: 17px; }
.admin-dialogue-preview {
  width: 100%; max-width: 440px; min-width: 0; margin-inline: auto;
  border: 1px solid #d7e5d5; border-radius: 26px;
  background: linear-gradient(145deg, #f3f8e9, #e8f1df 55%, #f8f1e1);
  box-shadow: 0 8px 28px #20361b0c;
}
.admin-dialogue-preview header { display: flex; align-items: center; gap: 14px; padding: 20px 18px; }
.admin-dialogue-preview header strong { min-width: 0; overflow-wrap: anywhere; font-size: 16px; }
.admin-dialogue-preview header > span { color: #267e3a; font-size: 24px; }
.admin-dialogue-preview-messages { min-height: 250px; padding: 12px 18px 26px; }
.admin-dialogue-preview .empty-prompts { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 22px; }
.admin-dialogue-preview .empty-prompts button {
  max-width: 100%; padding: 10px 14px; border: 1px solid #bdd7b7; border-radius: 20px;
  background: #fff; color: #245330; font-size: 13px; line-height: 1.4; overflow-wrap: anywhere; cursor: default;
}
.admin-dialogue-preview-greeting { padding: 16px; border-radius: 4px 20px 20px; background: #ffffffed; color: #29332b; }
.admin-dialogue-preview-greeting strong { color: #267e3a; font-size: 12px; }
.admin-dialogue-preview-greeting p { margin: 8px 0 0; line-height: 1.55; font-size: 14px; overflow-wrap: anywhere; }
.admin-dialogue-preview-composer { display: flex; align-items: center; gap: 7px; margin: 0 12px 12px; padding: 7px; border-radius: 22px; background: #f8faf5; }
.admin-dialogue-preview-composer > span:first-child { flex: 1; min-width: 0; padding: 10px; border-radius: 14px; color: #7b857d; background: white; font-size: 12px; }
.admin-dialogue-preview-composer :is(.preview-microphone, .preview-voice) { display: grid; place-items: center; width: 38px; height: 38px; flex: 0 0 38px; border-radius: 50%; }
.admin-dialogue-preview-composer .preview-microphone { background: linear-gradient(145deg, #51d45e, #24973d); }
.admin-dialogue-preview-composer .preview-voice { background: linear-gradient(145deg, #61457b, #30203f); }
.admin-dialogue-preview-composer img { width: 23px; height: 23px; object-fit: contain; filter: brightness(0) invert(1); }
.admin-system-prompt-list { display: grid; gap: 10px; margin-bottom: 14px; }
body[data-view="admin"] .admin-system-prompt-list .admin-scenario-card {
  grid-template-columns: minmax(0, 1fr); text-align: left;
}
body[data-view="admin"] .admin-system-prompt-list .admin-scenario-card-copy { grid-column: 1 / -1; }
body[data-view="admin"] .admin-system-prompt-list .admin-scenario-card::before { content: none; display: none; }
body[data-view="admin"] .admin-system-prompt-list .admin-scenario-card-title {
  white-space: normal; overflow: visible; text-overflow: clip;
}
.admin-system-prompt-list .admin-system-prompt-scope { color: #607068; font-size: 12px; line-height: 1.5; }
.admin-scenario-details { display: grid; gap: 14px; min-width: 0; margin: 0; padding: 0; border: 0; }
body[data-view="admin"] #admin-scenario-details[disabled] ~ .admin-form-actions { grid-template-columns: minmax(0, 1fr); }

body.app-active[data-view="home"] .scenario-card-image {
  position: static;
  grid-row: 1;
  grid-column: 1 / -1;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
@media (max-width: 700px) {
  body.app-active[data-view="home"] .home-screen {
    grid-template-rows: minmax(0, 1fr) 64px;
    gap: 12px;
    padding-bottom: max(11px, env(safe-area-inset-bottom));
  }
  body.app-active[data-view="home"] .home-layout {
    grid-template-rows: 211px minmax(0, 1fr);
    gap: 12px;
  }
  body.app-active[data-view="home"] .home-screen[data-state="active"] .home-layout {
    grid-template-rows: 172px minmax(0, 1fr);
  }
  body.app-active[data-view="home"] .scenario-section {
    display: grid;
    grid-template-rows: minmax(0, 1fr);
  }
  body.app-active[data-view="home"] .scenario-section .section-heading { display: none; }
  body.app-active[data-view="home"] .scenario-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-rows: none;
    grid-auto-rows: minmax(0, 1fr);
    align-content: stretch;
    gap: 12px;
    align-items: stretch;
    overflow: clip;
  }
  body.app-active[data-view="home"] .scenario-card {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr) 72px;
    min-height: 0;
    background: #eaf1e7;
  }
  body.app-active[data-view="home"] .scenario-card-image {
    height: 100%;
    min-height: 0;
    aspect-ratio: auto;
    object-fit: cover;
    object-position: center;
  }
  body.app-active[data-view="home"] .scenario-card-caption {
    grid-row: 2;
    grid-column: 1;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 26px;
    grid-template-rows: 16px 32px;
    gap: 4px 6px;
    padding: 10px 8px;
    min-width: 0;
    background: #fff;
    align-content: start;
  }
  body.app-active[data-view="home"] .scenario-card-caption strong {
    grid-row: 1;
    grid-column: 1 / -1;
    align-self: center;
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: clamp(11px, 3vw, 13px);
    line-height: 16px;
    color: #101713;
  }
  body.app-active[data-view="home"] .scenario-card-caption small {
    grid-row: 2;
    grid-column: 1;
    margin: 0;
    min-height: 32px;
    max-height: 32px;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    overflow: hidden;
    font: 12px/16px Arial, sans-serif;
  }
  body.app-active[data-view="home"] .scenario-card-caption > b {
    position: static;
    grid-row: 2;
    grid-column: 2;
    width: 26px;
    height: 26px;
    margin: 0;
    border-radius: 50%;
    font-size: 0;
    background: #edf5ef url("/assets/icons/arrow-right.webp") center / 20px 20px no-repeat;
    align-self: end;
  }
  body.app-active[data-view="home"] .scenario-card-caption > b.external {
    background-image: url("/assets/icons/external-link.webp");
  }
  body.app-active[data-view="home"] .home-screen[data-state="fresh"] .hero-card {
    display: flex;
    flex-direction: column;
  }
  body.app-active[data-view="home"] .home-screen[data-state="fresh"] .hero-art {
    position: relative;
    inset: auto;
    flex: 1 1 0;
    min-height: 0;
    height: auto;
    margin: 12px 14px 0;
  }
  body.app-active[data-view="home"] .home-screen[data-state="fresh"] .hero-copy {
    position: relative;
    inset: auto;
    flex: 0 0 auto;
    grid-template-columns: minmax(0, 1fr) minmax(128px, .95fr);
    gap: 8px 10px;
    padding: 12px 16px;
  }
  body.app-active[data-view="home"] .home-screen[data-state="fresh"] .hero-copy h1 {
    font-size: clamp(18px, 5vw, 22px);
    line-height: 1.05;
    white-space: normal;
    align-self: center;
  }
  body.app-active[data-view="home"] .home-screen[data-state="fresh"] .hero-copy > p:not(.eyebrow) {
    grid-column: 1 / -1;
    margin: 0;
  }
  body.app-active[data-view="home"] .home-screen[data-state="fresh"] .hero-actions { grid-row: 1; }
  body.app-active[data-view="home"] .home-screen[data-state="fresh"] .home-primary-action {
    width: 100%;
    min-height: 44px;
    padding-inline: 8px;
    font-size: 13px;
  }
  body.app-active[data-view="home"] .home-screen[data-state="fresh"] .home-hero-status {
    position: static;
    inset: auto;
    width: auto;
    grid-column: 1 / -1;
    margin: 0;
  }
  body.app-active[data-view="home"] .home-screen[data-state="fresh"] .hero-plate {
    top: 45%;
    width: clamp(48px, 10dvh, 86px);
    height: clamp(48px, 10dvh, 86px);
  }
  body.app-active[data-view="home"] .home-screen[data-state="fresh"] .hero-wave { top: 45%; }
  body.app-active[data-view="home"] .home-screen[data-state="fresh"] .hero-dialogue-bubble {
    max-width: 52%;
    padding: 7px 9px;
    font-size: 9px;
    left: auto;
    right: 3%;
    width: auto;
    min-height: 0;
  }
  body.app-active[data-view="home"] .home-screen[data-state="fresh"] .hero-dialogue-user { top: 5%; bottom: auto; }
  body.app-active[data-view="home"] .home-screen[data-state="fresh"] .hero-dialogue-chef { top: auto; bottom: 5%; }
  body.app-active[data-view="home"] .home-screen[data-state="active"] .hero-card .hero-art {
    top: 12px;
    width: 48px;
    height: 48px;
  }
  body.app-active[data-view="home"] .home-screen[data-state="active"] .hero-card .hero-copy {
    position: relative;
    inset: auto;
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto auto minmax(0, 1fr) auto auto;
    gap: 6px;
    height: 100%;
    padding: 12px 16px;
  }
  body.app-active[data-view="home"] .home-screen[data-state="active"] .hero-card .hero-copy > .eyebrow {
    grid-row: 1;
    margin: 0;
    padding-left: 64px;
  }
  body.app-active[data-view="home"] .home-screen[data-state="active"] .hero-card .hero-copy > * { grid-column: 1; }
  body.app-active[data-view="home"] .home-screen[data-state="active"] .hero-card .hero-copy h1 {
    grid-row: 2;
    margin: 0;
    padding-left: 64px;
    font-size: clamp(18px, 5vw, 22px);
    line-height: 1.1;
  }
  body.app-active[data-view="home"] .home-screen[data-state="active"] .hero-card .home-active-summary {
    position: static;
    grid-row: 4;
    margin: 0;
    padding: 0;
    border: 0;
  }
  body.app-active[data-view="home"] .home-screen[data-state="active"] .hero-card .home-active-summary strong {
    display: block;
    font-size: 16px;
  }
  body.app-active[data-view="home"] .home-screen[data-state="active"] .hero-card .hero-actions {
    display: grid;
    position: static;
    grid-row: 5;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    width: 100%;
    margin: 0;
    gap: 8px;
  }
  body.app-active[data-view="home"] .home-screen[data-state="active"] .hero-card .hero-copy > p:not(.eyebrow) { display: none; }
  body.app-active[data-view="home"] .home-screen[data-state="active"] .hero-card .home-primary-action {
    width: 100%;
    min-height: 44px;
    font-size: 12px;
    white-space: normal;
  }
  body.app-active[data-view="home"] .home-screen[data-state="active"] .hero-card .home-new-action { min-height: 44px; }
  @media (max-height: 650px) {
    body.app-active[data-view="home"] .home-layout { grid-template-rows: 172px minmax(0, 1fr); }
    body.app-active[data-view="home"] .home-screen[data-state="fresh"] .hero-art { display: none; }
    body.app-active[data-view="home"] .home-screen[data-state="fresh"] .hero-card { justify-content: center; }
    body.app-active[data-view="home"] .home-screen[data-state="active"] .hero-card .hero-copy {
      grid-template-rows: auto minmax(0, 1fr) auto auto;
      gap: 6px;
      padding-block: 12px;
    }
    body.app-active[data-view="home"] .home-screen[data-state="active"] .hero-card .hero-copy > .eyebrow,
    body.app-active[data-view="home"] .home-screen[data-state="active"] .hero-card .hero-art { display: none; }
    body.app-active[data-view="home"] .home-screen[data-state="active"] .hero-card .hero-copy h1 { grid-row: 1; padding: 0; }
    body.app-active[data-view="home"] .home-screen[data-state="active"] .hero-card .home-active-summary { grid-row: 3; }
    body.app-active[data-view="home"] .home-screen[data-state="active"] .hero-card .hero-actions { grid-row: 4; }
  }
}
@media (min-width: 701px) {
  body.app-active[data-view="home"] .home-screen[data-state="active"] .guide-column { padding-top: 0; }
  body.app-active[data-view="home"] .hero-actions { position: relative; z-index: 2; }
  body.app-active[data-view="home"] #home-primary-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: auto;
    min-width: 200px;
    min-height: 58px;
    height: auto;
    padding: 12px 24px;
    gap: 12px;
    white-space: normal;
    line-height: 1.25;
  }
  body.app-active[data-view="home"] #home-primary-label { display: block; }
}
