/* One shared composer and speech switch for conversation and recipe. */
.legacy-chat-heading, .recipe-bottom-voice[hidden], #composer-hint { display: none !important; }
body[data-view="chat"] .chat-screen { padding: 0; }
body[data-view="chat"] #chat-screen .conversation-card { max-width: none; }
body[data-view="chat"] .conversation-head {
  position: absolute; inset: max(12px, env(safe-area-inset-top)) 16px auto;
  z-index: 5; display: flex; justify-content: space-between; align-items: center;
  width: auto; height: 48px; min-height: 48px; margin: 0; padding: 0;
  border: 0; background: none; box-shadow: none;
}
body[data-view="chat"] .conversation-head::before,
body[data-view="chat"] .conversation-head::after { display: none; }
#chat-back, #composer-speaker-button {
  position: relative; inset: auto; display: grid !important; place-items: center;
  width: 48px; height: 48px; min-width: 48px; min-height: 48px; padding: 0;
  border: 1px solid #e0e8df; border-radius: 50%; background: linear-gradient(145deg, #f5faf3, #dcebd8);
  color: #267e3a; box-shadow: 0 3px 12px #2237220c; cursor: pointer;
}
#composer-speaker-button[data-enabled="false"] { background: linear-gradient(145deg, #f6f7f6, #dfe5e0); }
#chat-back { font-size: 0; background: url("/assets/icons/back.webp") center / 27px 27px no-repeat, linear-gradient(145deg, #f5faf3, #dcebd8); }
#composer-speaker-button[data-enabled="false"] .speaker-toggle-icon { filter: grayscale(1); opacity: .65; }
#composer-speaker-button[data-enabled="false"]::after {
  content: ""; position: absolute; width: 26px; height: 2px; background: #59625a;
  transform: rotate(-45deg); box-shadow: 0 0 0 2px #edf0ee;
}
body[data-view="chat"] #messages {
  position: absolute; inset: 0; width: 100%; height: 100%; box-sizing: border-box;
  margin: 0; padding: 80px 17px calc(var(--shared-composer-height, 144px) + var(--request-status-height, 0px) + 40px);
  scroll-padding-block: 80px calc(var(--shared-composer-height, 144px) + var(--request-status-height, 0px) + 40px);
  mask-image: none !important; -webkit-mask-image: none !important;
}
body[data-view="chat"] #messages .message-row.assistant { gap: 0; padding-inline: 0; }
body[data-view="chat"] #messages .message-row.assistant .message-stack { width: 100%; max-width: 100%; }
body[data-view="chat"] #messages .assistant .message-bubble { max-width: min(88%, 700px); }
body[data-view="chat"] #messages .user .message-stack { width: max-content; }
body[data-view="chat"] #messages .user .message-bubble { box-sizing: border-box; max-width: 100%; }
body[data-view="chat"] #messages .message-avatar { display: none !important; }
body[data-view="chat"] .empty-conversation { padding-top: 76px; padding-bottom: 180px; }
body[data-view="chat"] #chat-composer-slot {
  position: absolute; z-index: 5;
  inset: auto max(15px, env(safe-area-inset-right)) max(15px, env(safe-area-inset-bottom)) max(15px, env(safe-area-inset-left));
  width: auto; max-width: none; margin: 0;
}
body[data-view="chat"] .chat-toast-region {
  position: absolute; z-index: 6;
  inset: auto 18px calc(var(--shared-composer-height, 144px) + 28px) auto;
  width: min(380px, calc(100% - 36px)); height: auto;
  display: grid; align-content: start; gap: 10px;
  pointer-events: none;
}
body[data-view="chat"] #request-status:not([hidden]) {
  display: flex; align-items: center; gap: 12px; box-sizing: border-box;
  padding: 12px 16px; border: 1px solid #bdd9bd; border-radius: 18px;
  color: #244c2b; background: #f4fff2; box-shadow: 0 4px 18px #17301b24;
  pointer-events: auto;
}
#request-status #retry { color: #244c2b; background: #fff; border: 1px solid #bdd9bd; }
#request-status-text { flex: 1; min-width: 0; }
#request-status .status-loader {
  order: 2; margin-left: auto;
  display: block; flex: 0 0 18px; width: 18px; height: 18px; box-sizing: border-box;
  border: 2px solid currentColor; border-top-color: transparent; border-radius: 50%;
  animation: voice-control-spin .8s linear infinite;
}
#request-status.error .status-loader { display: none; }
#composer {
  --composer-control: 48px; --composer-gap: 8px;
  --composer-green: linear-gradient(145deg, #51d45e, #24973d);
  position: relative; inset: auto; display: grid !important;
  grid-template-columns: minmax(0, 1fr) repeat(2, var(--composer-control));
  grid-template-rows: var(--composer-control);
  gap: var(--composer-gap); width: 100%; max-width: none; min-height: 0; height: auto;
  margin: 0; padding: 8px; box-sizing: border-box; border-radius: 24px;
  border: 1px solid #e2e8df; background: #f8faf5; box-shadow: 0 6px 24px #1f371515;
  overflow: hidden; flex: 0 0 auto;
}
#composer .composer-text-field {
  display: block !important; position: relative; grid-column: 1; grid-row: 1;
  min-width: 0; align-self: stretch;
}
#composer .composer-text-field textarea {
  display: block; box-sizing: border-box; width: 100%; min-height: 48px;
  max-height: 240px; padding: 11px 14px; margin: 0;
  border: 1px solid #e4e8e1; border-radius: 16px; background: #fff;
  font: inherit; font-size: 16px; line-height: 1.45; resize: none;
  white-space: pre-wrap; overflow-wrap: anywhere; overflow-y: hidden;
}
#composer[data-has-text="true"] {
  grid-template-columns: minmax(0, 1fr) var(--composer-control);
  grid-template-rows: var(--composer-control) minmax(var(--composer-control), auto);
}
#composer[data-has-text="true"] .composer-text-field { grid-row: 1 / 3; }
#composer[data-has-text="true"] .composer-text-field textarea { min-height: 104px; padding: 14px 48px 14px 14px; }
#composer .composer-inline-send {
  position: absolute; top: auto; bottom: 8px; right: 7px; transform: none;
  width: 36px; height: 36px; min-width: 36px; min-height: 36px; padding: 0;
  border: 0; border-radius: 50%; color: #fff; background: linear-gradient(145deg, #171918, #0d0f0e); place-items: center;
  display: none !important;
}
#composer[data-has-text="true"] .composer-inline-send { display: grid !important; }
#composer .composer-inline-send .send-icon { width: 22px; height: 22px; }
#home-send-button { background: linear-gradient(145deg, #171918, #0d0f0e); }
#composer :is(#composer-voice-button, #composer-continuous-button, #composer-stop-button) {
  display: grid !important; place-items: center; grid-column: 2 !important; align-self: start;
  width: var(--composer-control); height: var(--composer-control);
  min-width: var(--composer-control); min-height: var(--composer-control);
  padding: 0; border: 0; border-radius: 50%; cursor: pointer;
}
#composer #composer-voice-button { grid-row: 1; background: var(--composer-green); color: white; }
#composer #composer-continuous-button {
  grid-column: 3 !important; grid-row: 1; position: relative;
  background: linear-gradient(145deg, #61457b, #30203f); color: white;
}
#composer[data-has-text="true"] #composer-voice-button { grid-row: 2; }
#composer[data-has-text="true"] #composer-continuous-button { grid-column: 2 !important; }
#composer[data-continuous-voice="true"] #composer-continuous-button { background: linear-gradient(145deg, #ed6868, #b72f3b); }
#composer #composer-stop-button { display: none !important; }
#composer #composer-continuous-button[aria-busy="true"] { opacity: 1; cursor: wait; }
#composer #composer-continuous-button[aria-busy="true"] .continuous-wave-icon { visibility: hidden; }
#composer #composer-continuous-button .stop-square-icon { display: none; }
#composer #composer-continuous-button[aria-pressed="true"]:not([aria-busy="true"]) .continuous-wave-icon { display: none; }
#composer #composer-continuous-button[aria-pressed="true"]:not([aria-busy="true"]) .stop-square-icon { display: block; }
#composer #composer-continuous-button[aria-busy="true"]::after {
  content: ""; position: absolute; width: 22px; height: 22px; box-sizing: border-box;
  border: 3px solid #ffffff55; border-top-color: white; border-radius: 50%;
  animation: voice-control-spin .75s linear infinite;
}
@keyframes voice-control-spin { to { transform: rotate(360deg); } }
#composer :is(.composer-text-chat-button, .composer-active-voice, .composer-recording) { display: none !important; }
#composer[data-composer-state="recording"] .composer-text-field { visibility: hidden; }
#composer[data-composer-state="recording"] .composer-recording {
  display: flex !important; grid-column: 1; grid-row: 1; align-items: center; justify-content: center;
  gap: 12px; color: #267e3a; min-width: 0;
}
#composer[data-has-text="true"][data-composer-state="recording"] .composer-recording { grid-row: 1 / 3; }
#composer-recording-time { font-variant-numeric: tabular-nums; white-space: nowrap; }
#composer .recording-indicator {
  flex: 0 0 8px; width: 8px; height: 8px; border-radius: 50%; background: #dc3545;
  animation: recording-blink 1s ease-in-out infinite;
}
@keyframes recording-blink { 50% { opacity: .25; } }
body[data-view="chat"] #messages .empty-conversation {
  position: static; inset: auto; width: 100%; max-width: none; min-height: 0; height: auto;
  margin: 0 0 20px; padding: 0; transform: none; align-self: stretch;
}
body[data-view="chat"] #messages .empty-conversation .empty-mark,
body[data-view="chat"] #messages .empty-conversation-copy { display: none; }
body[data-view="chat"] #messages .empty-conversation[hidden] { display: none; }
.admin-quick-panel { min-width: 0; padding-top: 24px; border-top: 1px solid #dbe7d8; margin-top: 24px; }
.admin-quick-panel h2 { font-size: 20px; margin: 0 0 16px; }
.admin-quick-table { width: 100%; border-collapse: collapse; table-layout: fixed; }
.admin-quick-table th { text-align: left; color: #4f5852; font-size: 12px; font-weight: 600; padding: 0 8px 8px 0; }
.admin-quick-table th:last-child { width: 82px; }
.admin-quick-table td { vertical-align: top; padding: 8px 8px 8px 0; border-top: 1px solid #e2e8df; }
.admin-quick-table td:last-child { padding-right: 0; }
.admin-quick-table :is(input, textarea) { width: 100%; min-width: 0; box-sizing: border-box; }
@media (max-width: 700px) {
  .admin-quick-table thead { display: none; }
  .admin-quick-table tr { display: grid; gap: 8px; padding-block: 12px; border-top: 1px solid #dbe7d8; }
  .admin-quick-table td { border: 0; padding: 0; }
  .admin-quick-table td:first-child::before { content: "Короткая реплика"; }
  .admin-quick-table td:nth-child(2)::before { content: "Расширенная реплика (необязательно)"; }
  .admin-quick-table td::before { display: block; margin-bottom: 6px; color: #4f5852; font-size: 12px; }
}
@media (prefers-reduced-motion: reduce) {
  #composer .recording-indicator, #request-status .status-loader { animation: none; }
}
#composer[data-composer-state="recording"] #composer-voice-button { background: var(--composer-green); }
#recipe-composer-slot {
  padding: 12px max(15px, env(safe-area-inset-right)) max(15px, env(safe-area-inset-bottom)) max(15px, env(safe-area-inset-left));
  min-width: 0;
}
body[data-view="recipe"] .recipe-workspace { grid-template-rows: auto minmax(0, 1fr) auto; }
body[data-view="recipe"] .recipe-layout { min-height: 0; }
body[data-view="recipe"] #recipe-toolbar #composer-speaker-button { flex-shrink: 0; margin-left: 8px; }
.message-article-actions { display: flex; gap: 10px; align-items: center; margin-top: 14px; }
.message-article-actions :is(button, a) {
  display: inline-flex; align-items: center; justify-content: center; min-height: 40px;
  padding: 9px 16px; border: 1px solid #cbdcc7; border-radius: 20px;
  color: #235f32; background: linear-gradient(145deg, #f5faf0, #e0edd9); font: inherit; font-size: 14px; text-decoration: none; cursor: pointer;
}
.message-article-actions .message-article-open {
  flex: 0 0 40px; width: 40px; height: 40px; padding: 0; margin-left: auto;
  box-sizing: border-box; border-radius: 50%;
  background: url("/assets/icons/arrow-right.webp") center / 20px 20px no-repeat, linear-gradient(145deg, #f5faf0, #e0edd9);
}
body[data-view="chat"] #messages .message-article-card { width: 100%; max-width: 100%; box-sizing: border-box; cursor: default; transform: none; }
body[data-view="chat"] #messages { --message-padding: 14px 16px; }
body[data-view="chat"] #messages .assistant .message-bubble { padding: var(--message-padding); }
body[data-view="chat"] #messages .message-article-card.expanded {
  width: 100%; max-width: 100%; padding: var(--message-padding);
}
body[data-view="chat"] #messages .inline-recipe-document {
  grid-column: 1 / -1; width: 100%; max-width: none; height: auto; min-height: 0;
  max-height: none; overflow: visible; margin: 0; padding: 0; box-sizing: border-box;
  white-space: normal; overflow-wrap: anywhere; border: 0; box-shadow: none;
}
.inline-recipe-document[hidden] { display: none !important; }
.inline-recipe-document :is(p, li) { white-space: normal; overflow: visible; line-height: 1.6; }
.inline-recipe-document .recipe-checklist { list-style: none; padding-inline: 0; }
.inline-recipe-document .recipe-checklist li { list-style: none; }
.inline-recipe-document .recipe-checklist label { display: flex; align-items: baseline; gap: 10px; }
.inline-recipe-document .recipe-checklist input { flex: 0 0 auto; }
.inline-recipe-document :is(h1, h2, h3) { line-height: 1.25; margin-block: 1em .5em; }
.inline-recipe-document > :first-child { margin-top: 0; }
.message-article-collapse { grid-column: 1 / -1; margin: 0; }
.message-article-collapse[hidden] { display: none; }
.inline-recipe-document img { width: 100%; max-height: 420px; object-fit: cover; border-radius: 16px; }
img[data-asset-state]:not([data-asset-state="ready"]) {
  object-fit: contain !important; padding: clamp(24px, 7%, 72px); box-sizing: border-box;
  filter: grayscale(1); opacity: .48; background: #eceee8;
}
body.app-active[data-view="home"] .home-screen[data-state="fresh"] .hero-card {
  display: grid; grid-template-rows: minmax(0, 1fr) auto; grid-template-columns: 1fr;
}
body.app-active[data-view="home"] .home-screen[data-state="fresh"] .hero-art {
  position: relative; inset: auto; grid-row: 1; width: 100%; height: 100%; min-height: 0;
  transform: none; margin: 0;
}
body.app-active[data-view="home"] .home-screen[data-state="fresh"] .hero-copy {
  position: relative; inset: auto; grid-row: 2; width: auto;
}
body.app-active[data-view="home"] .home-screen[data-state="fresh"] .hero-plate {
  position: absolute; left: 50%; top: 50% !important; bottom: auto; right: auto;
  margin: 0; transform: translate(-50%, -50%);
}
@media (min-width: 701px) {
  body.app-active[data-view="home"] .home-screen[data-state="fresh"] .hero-plate {
    top: calc(clamp(28px, 6.9dvh, 75px) + clamp(104px, 12.9dvh, 140px) / 2) !important;
  }
  body.app-active[data-view="home"] .home-screen[data-state="fresh"] .hero-copy {
    margin: 0 clamp(24px, 3.6vw, 52px) 26px; padding: 0;
  }
}
@media (max-width: 700px) {
  body[data-view="recipe"] .recipe-saved-status { display: none; }
  body[data-view="chat"] #messages { padding-inline: 12px; --message-padding: 12px 14px; }
  body.app-active[data-view="home"] .home-screen[data-state="fresh"] .hero-plate { left: 25%; }
}
