/* UI089: presentation only; existing controllers retain state, DOM and theme ownership.
   Load after palette-studio. Sidebar width is deliberately owned by its controller. */
body.yf-ui-soft {
  --yf-soft-reading-width: 740px;
  --yf-soft-composer-radius: 23px;
  --yf-soft-shadow: 0 5px 22px color-mix(in srgb, var(--yf-text) 3%, transparent), 0 1px 2px color-mix(in srgb, var(--yf-text) 2%, transparent);
}

/* Shared navigation: preserve width, collapsed state, resizer and route visibility. */
body.yf-ui-soft .topbar { border-right-color: color-mix(in srgb, var(--yf-border) 70%, transparent); }
body.yf-ui-soft .primary-nav { gap: 4px; }
body.yf-ui-soft .primary-nav > a { min-height: 40px; padding-block: 9px; border-radius: 11px; font-size: 14px; line-height: 20px; letter-spacing: 0; }
body.yf-ui-soft .primary-nav > a:not(.is-active):hover { background: color-mix(in srgb, var(--yf-primary-soft) 65%, transparent); color: var(--yf-text); border-left-color: transparent; }
body.yf-ui-soft .primary-nav > a.is-active { background: var(--yf-primary-soft); color: var(--yf-text); }
body.yf-ui-soft .conversation-action { border-radius: 10px; font-size: 13px; line-height: 1.5; }
body.yf-ui-soft :is(.theme-toggle, .login-btn, .access-trigger, .user-menu-button) { border-radius: 10px; }
body.yf-ui-soft .primary-nav > a:focus-visible,
body.yf-ui-soft .account-nav :is(button, a):focus-visible { outline: 2px solid var(--yf-primary); outline-offset: 3px; }

/* Both landing and conversation use the live palette, never a second light/dark palette. */
body.yf-ui-soft[data-yf-soft-route="home"] #home { color: var(--yf-text); }
body.yf-ui-soft[data-yf-soft-route="home"] #home .hero-stage { width: min(var(--yf-soft-reading-width), 100%); max-width: 100%; }
body.yf-ui-soft[data-yf-soft-route="home"] #home .hero-copy h1 { font-weight: 550; line-height: 1.4; letter-spacing: -.025em; }
body.yf-ui-soft[data-yf-soft-route="home"] #home #searchForm.composer {
  width: 100%; min-width: 0; box-sizing: border-box; padding: 12px 16px 10px;
  border-radius: var(--yf-soft-composer-radius); border-color: var(--yf-border);
  background: var(--yf-surface-fill, var(--yf-surface)); box-shadow: var(--yf-soft-shadow);
}
body.yf-ui-soft[data-yf-soft-route="home"] #home #searchForm.composer:focus-within { border-color: color-mix(in srgb, var(--yf-primary) 60%, var(--yf-border)); box-shadow: var(--yf-soft-shadow), 0 0 0 2px color-mix(in srgb, var(--yf-primary) 5%, transparent); }
body.yf-ui-soft[data-yf-soft-route="home"] #home #chatInput.assistant-input { min-width: 0; min-height: 56px; max-height: 180px; padding: 4px 1px 8px; font-size: 16px; line-height: 24px; color: var(--yf-text); }
body.yf-ui-soft[data-yf-soft-route="home"] #home .composer-tools { min-height: 40px; margin-top: 5px; gap: 8px; }
body.yf-ui-soft[data-yf-soft-route="home"] #home :is(#chatModelBtn, #uploadMoreBtn) { min-height: 36px; border-radius: 10px; font-size: 13px; }
body.yf-ui-soft[data-yf-soft-route="home"] #home #chatActionBtn { border-radius: 12px; min-height: 40px; font-size: 14px; }
body.yf-ui-soft[data-yf-soft-route="home"] #home #chatActionBtn:disabled { opacity: .46; cursor: default; }
body.yf-ui-soft[data-yf-soft-route="home"] #home :is(#uploadMenu.upload-menu, #chatModelMenu.mode-menu) { border-radius: 15px; border-color: var(--yf-border); background: var(--yf-surface); box-shadow: 0 10px 30px color-mix(in srgb, var(--yf-text) 8%, transparent); }
body.yf-ui-soft[data-yf-soft-route="home"] #home #chatModelMenu.mode-menu button { min-height: 40px; padding: 9px 12px; font-size: 14px; line-height: 1.5; }
body.yf-ui-soft[data-yf-soft-route="home"] #home #chatModelMenu.mode-menu button:not(:disabled):hover,
body.yf-ui-soft[data-yf-soft-route="home"] #home #chatModelMenu.mode-menu button.is-selected,
body.yf-ui-soft[data-yf-soft-route="home"] #home #chatModelMenu.mode-menu button[aria-selected="true"] { background: var(--yf-primary-soft); color: var(--yf-text); }
body.yf-ui-soft[data-yf-soft-route="home"] #home :is(button, a, summary, input, textarea, select):focus-visible { outline: 2px solid var(--yf-primary); outline-offset: 3px; }

/* Header is a projection of real identity/save state. Hidden stays hidden. */
body.yf-ui-soft[data-yf-soft-route="home"] #home > .yf-soft-header:not([hidden]) { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex: 0 0 auto; width: min(var(--yf-soft-reading-width), 100%); min-width: 0; min-height: 34px; margin: 0 auto 14px; }
body.yf-ui-soft[data-yf-soft-route="home"] #home .yf-soft-identity { display: inline-flex; align-items: center; gap: 10px; min-width: 0; font-size: 16px; line-height: 24px; font-weight: 600; color: var(--yf-text); }
body.yf-ui-soft[data-yf-soft-route="home"] #home .yf-soft-save { min-width: 0; max-width: 55%; font-size: 12px; line-height: 20px; overflow-wrap: anywhere; text-align: right; }

/* Existing conversation shell owns the viewport; only the transcript scrolls.
   No body/html overflow or non-home layout override is introduced. */
body.yf-ui-soft[data-yf-soft-route="home"].route-mode.is-conversation-mode main > #home.hero {
  height: 100dvh; min-height: 0; padding: 20px 28px max(22px, env(safe-area-inset-bottom));
  flex-direction: column; align-items: center; justify-content: flex-start;
}
body.yf-ui-soft[data-yf-soft-route="home"].is-conversation-mode #home .hero-stage.is-chat-active { flex: 1 1 0; height: auto; min-height: 0; padding: 0; margin: 0 auto; gap: 12px; }
body.yf-ui-soft[data-yf-soft-route="home"].is-conversation-mode #home #chatArea.chat-area.is-conversation { flex: 1 1 auto; min-height: 0; max-height: none; min-width: 0; width: 100%; padding: 12px 0 22px; overflow-y: auto; overscroll-behavior-y: contain; scrollbar-width: thin; scrollbar-gutter: stable; scrollbar-color: var(--yf-border) transparent; scroll-padding-block: 16px 24px; }
body.yf-ui-soft[data-yf-soft-route="home"].is-conversation-mode #home .hero-stage.is-chat-active #searchForm.composer.is-conversation-composer { flex: 0 0 auto; position: relative; bottom: auto; transform: none; border-radius: var(--yf-soft-composer-radius); }
body.yf-ui-soft[data-yf-soft-route="home"].is-conversation-mode #home #chatInput.assistant-input { height: 64px; min-height: 48px; }
body.yf-ui-soft[data-yf-soft-route="home"] #home .chat-turn { min-width: 0; width: 100%; gap: 20px; margin-bottom: 24px; grid-template-columns: minmax(0, 1fr); }
body.yf-ui-soft[data-yf-soft-route="home"] #home .chat-message-assistant { width: 100%; max-width: 100%; padding: 0; border: 0; border-radius: 0; background: transparent; box-shadow: none; }
body.yf-ui-soft[data-yf-soft-route="home"] #home .chat-message-assistant > .chat-message-label { margin: 0 0 18px; font-size: 14px; line-height: 22px; font-weight: 550; }
body.yf-ui-soft[data-yf-soft-route="home"] #home .chat-message-user { max-width: min(90%, 430px); padding: 10px 14px 12px; border: 0; border-radius: 15px; background: color-mix(in srgb, var(--yf-primary-soft) 75%, var(--yf-surface)); }
body.yf-ui-soft[data-yf-soft-route="home"] #home .chat-message-user > .chat-message-body { font-size: 14px; line-height: 24px; }
body.yf-ui-soft[data-yf-soft-route="home"] #home .chat-message-assistant > .chat-message-body { min-width: 0; max-width: 100%; font-size: 16px; line-height: 28px; color: var(--yf-text); }
body.yf-ui-soft[data-yf-soft-route="home"] #home .chat-message-body :is(h2, h3, h4, .yf-ui-answer-heading) { margin: 25px 0 9px; font-size: 19px; line-height: 1.45; font-weight: 600; letter-spacing: .1px; }
body.yf-ui-soft[data-yf-soft-route="home"] #home .chat-message-body :is(p, ul, ol) { margin-block: 10px; }
body.yf-ui-soft[data-yf-soft-route="home"] #home .chat-message-body > :first-child { margin-top: 0; }
body.yf-ui-soft[data-yf-soft-route="home"] #home .chat-message-body :is(.crm-formula-display, .katex-display, mjx-container[display="true"]) { max-width: 100%; min-width: 0; overflow-x: auto; overflow-y: hidden; margin-block: 16px; padding-block: 4px; }
body.yf-ui-soft[data-yf-soft-route="home"] #home .chat-message-body :is(table, .answer-table) { max-width: 100%; font-size: 14px; line-height: 1.65; }
body.yf-ui-soft[data-yf-soft-route="home"] #home .chat-message-body :is(th, td) { padding: 10px 12px; border-color: var(--yf-border); }

/* Presentation never decides error, cancellation, draft or history authority. */
body.yf-ui-soft[data-yf-soft-route="home"] #home :is(.chat-wait-status, .composer-status, .crm-reading-draft-notice, .crm-followup-feedback, .crm-attachment-draft-notice) { font-size: 12px; line-height: 1.75; overflow-wrap: anywhere; }
body.yf-ui-soft[data-yf-soft-route="home"] #home .crm-history-current-notice { min-width: 0; flex-shrink: 0; border-radius: 12px; }
body.yf-ui-soft[data-yf-soft-route="home"] #home .chat-selection-candidate { border-radius: 12px; }
body.yf-ui-soft[data-yf-soft-route="home"][data-yf-soft-busy="true"] #home #searchForm.composer { border-color: color-mix(in srgb, var(--yf-primary) 35%, var(--yf-border)); }

/* Native palette dialog sits beside #home. Keep its width/reserved-space protocol. */
body.yf-ui-soft > #paletteStudio.ps-studio .ps-panel { border-radius: 24px; box-shadow: 0 14px 45px color-mix(in srgb, var(--yf-text) 9%, transparent); }
body.yf-ui-soft > #paletteStudio.ps-studio .ps-header h2 { font-size: 20px; line-height: 1.45; }
body.yf-ui-soft > #paletteStudio.ps-studio :is(.ps-feedback, .ps-library-status, .ps-section-note) { font-size: 12px; line-height: 1.75; }
body.yf-ui-soft > #paletteStudio.ps-studio .ps-preset small { font-size: 12px; line-height: 1.6; }

@media (max-height: 700px) and (min-width: 721px) {
  body.yf-ui-soft[data-yf-soft-route="home"].route-mode.is-conversation-mode main > #home.hero { padding-block: 14px 16px; }
  body.yf-ui-soft[data-yf-soft-route="home"] #home > .yf-soft-header:not([hidden]) { margin-bottom: 8px; }
  body.yf-ui-soft[data-yf-soft-route="home"].is-conversation-mode #home #chatInput.assistant-input { height: 48px; }
}
@media (max-width: 720px) {
  body.yf-ui-soft[data-yf-soft-route="home"].route-mode.is-conversation-mode main > #home.hero { padding: 78px 14px max(12px, env(safe-area-inset-bottom)); }
  body.yf-ui-soft[data-yf-soft-route="home"] #home > .yf-soft-header:not([hidden]) { gap: 10px; margin-bottom: 8px; }
  body.yf-ui-soft[data-yf-soft-route="home"] #home .yf-soft-identity { font-size: 15px; }
  body.yf-ui-soft[data-yf-soft-route="home"] #home #searchForm.composer { padding: 10px 12px 9px; }
  body.yf-ui-soft[data-yf-soft-route="home"] #home .chat-turn { gap: 16px; margin-bottom: 18px; }
  body.yf-ui-soft[data-yf-soft-route="home"] #home .chat-message-user { max-width: 94%; }
  body.yf-ui-soft[data-yf-soft-route="home"] #home .chat-message-body :is(h2, h3, h4, .yf-ui-answer-heading) { font-size: 18px; margin-top: 22px; }
  body.yf-ui-soft[data-yf-soft-route="home"] #home #chatModelMenu.mode-menu { max-width: calc(100vw - 48px); }
}

/* Busy projection is aria-hidden in JS; retain the original live announcement.
   Only processing labels can be visually collapsed, never terminal errors. */
body.yf-ui-soft[data-yf-soft-route="home"] #home .yf-soft-turn-wait:not([hidden]) { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; min-width: 0; max-width: 100%; margin: 2px 0 10px; font-size: 12px; line-height: 1.75; color: var(--yf-muted); }
body.yf-ui-soft[data-yf-soft-route="home"] #home .yf-soft-wait-label { color: var(--yf-text); font-weight: 550; }
body.yf-ui-soft[data-yf-soft-route="home"] #home .yf-soft-wait-detail { font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
body.yf-ui-soft[data-yf-soft-route="home"] #home .chat-wait-status[data-yf-soft-wait-projected="true"][data-state="processing"] :is(.chat-wait-label, .chat-wait-detail),
body.yf-ui-soft[data-yf-soft-route="home"][data-yf-soft-busy="true"] #home .composer-status[data-yf-soft-redundant="true"]:not(.is-error):not(.is-warning) {
  position: absolute; width: 1px; height: 1px; min-width: 0; min-height: 0; max-width: 1px; max-height: 1px;
  padding: 0; margin: -1px; border: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap;
}
body.yf-ui-soft[data-yf-soft-route="home"] #home .chat-message-body table { display: block; overflow-x: auto; margin-block: 14px; }

/* Preserve palette-studio's real “reading surface” target, including custom fills. */
body.yf-ui-soft[data-yf-soft-route="home"] #home .chat-message-assistant { background: var(--yf-surface-fill, var(--yf-surface)); }

/* Keep the single composer depth choice readable, rather than icon-only. */
body.yf-ui-soft[data-yf-soft-route="home"] #home #chatModelBtn { width: auto; min-width: 44px; gap: 6px; padding-inline: 8px; }
body.yf-ui-soft[data-yf-soft-route="home"] #home #chatModelLabel { position: static; width: auto; height: auto; overflow: visible; clip: auto; white-space: nowrap; }

/* The active chat owns the viewport; the full site footer returns on other views. */
body.yf-ui-soft[data-yf-soft-route="home"].is-conversation-mode .page-shell > #footer { display: none; }
