/* AI智能助理：独立会话、阅读与创作共用一个工作区。 */
body.assistant-open { overflow: hidden; }
#app-shell[data-current-view="assistant"] > .app-header,
#app-shell[data-current-view="assistant"] > .bottom-nav { display: none !important; }
.assistant-view[hidden] { display: none !important; }
.assistant-view {
  --assistant-height: 100dvh;
  position: fixed; top: var(--assistant-offset, 0px); left: 0; width: 100%; height: var(--assistant-height);
  z-index: 41; display: grid; grid-template-columns: minmax(0, 1fr);
  background: var(--ink-950); color: var(--text); isolation: isolate;
}
.assistant-view :is(button, a, summary, input, textarea):focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; }
.assistant-view ::selection { background: var(--rose-700); color: var(--text); }
.assistant-view textarea { caret-color: var(--rose-300); }
.assistant-view :is(input, textarea)::placeholder { color: var(--muted); opacity: 1; }
.assistant-view svg { width: 22px; height: 22px; flex: none; }
.assistant-view button { cursor: pointer; }
.assistant-view button:disabled { cursor: default; opacity: .6; }
.assistant-view.history-open { grid-template-columns: 264px minmax(0, 1fr); }
.assistant-sidebar {
  display: none; flex-direction: column; min-height: 0; padding: max(20px, env(safe-area-inset-top)) 12px 16px;
  background: var(--ink-850); border-right: 1px solid var(--line);
}
.history-open .assistant-sidebar { display: flex; }
.assistant-brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 22px; font-size: 17px; font-weight: 700; }
.assistant-brand img { width: 34px; height: 34px; object-fit: contain; }
.assistant-brand span { flex: 1; }
.assistant-brand .assistant-icon-button { margin-right: -8px; }
.assistant-new-chat { display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%; min-height: 48px; border: 1px solid var(--line-strong); border-radius: 12px; background: var(--ink-800); color: var(--text); font-size: 15px; }
.assistant-new-chat:hover { background: var(--ink-700); }
.assistant-search { display: block; margin: 20px 2px 8px; }
.assistant-search input { width: 100%; min-height: 44px; padding: 10px 12px; border: 1px solid var(--line); background: var(--ink-900); color: var(--text); font-size: 14px; }
.assistant-history-list { overflow-y: auto; min-height: 0; flex: 1; scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }
.assistant-history-list h3 { color: var(--muted); font-size: 12px; font-weight: 500; margin: 22px 12px 8px; }
.assistant-history-row { display: flex; align-items: center; border-radius: 8px; margin: 2px 0; position: relative; }
.assistant-history-row:hover { background: var(--ink-800); }
.assistant-history-row.is-selected { background: var(--rose-wash); }
.assistant-history-item { flex: 1; min-width: 0; min-height: 44px; text-align: left; padding: 10px 12px; color: var(--text-soft); background: transparent; border: 0; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; border-radius: 8px; }
.assistant-session-menu { flex: none; }
.assistant-session-menu summary { width: 44px; height: 44px; display: grid; place-items: center; cursor: pointer; list-style: none; color: var(--muted); }
.assistant-session-menu summary::-webkit-details-marker { display: none; }
.assistant-session-menu > div { position: absolute; z-index: 5; right: 6px; top: 38px; padding: 4px; background: var(--ink-700); border: 1px solid var(--line-strong); border-radius: 8px; }
.assistant-session-menu button { display: block; min-height: 44px; width: 120px; text-align: left; padding: 10px; background: transparent; border: 0; color: var(--text); border-radius: 8px; }
.assistant-session-menu button:hover { background: var(--ink-800); }
.assistant-history-empty { padding: 16px 12px; font-size: 14px; line-height: 1.7; color: var(--muted); }
.assistant-sidebar-footer { margin-top: 12px; border-top: 1px solid var(--line); padding-top: 10px; }
.assistant-sidebar-footer button { min-height: 44px; width: 100%; border: 0; color: var(--muted); background: transparent; display: flex; align-items: center; gap: 10px; padding: 10px; }
.assistant-stage { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.assistant-topbar { display: flex; align-items: center; gap: 8px; padding: max(12px, env(safe-area-inset-top)) 24px 12px; min-height: 68px; flex: none; }
.assistant-topbar h2 { flex: 1; min-width: 0; margin: 0; font-size: 16px; font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.assistant-icon-button { display: grid; place-items: center; width: 44px; height: 44px; padding: 0; color: var(--muted); background: transparent; border: 0; border-radius: 8px; text-decoration: none; }
.assistant-icon-button:hover { background: var(--ink-800); color: var(--text); }
.assistant-content { min-height: 0; flex: 1; position: relative; display: flex; flex-direction: column; overflow: hidden; }
.assistant-welcome { margin: auto; padding: 32px 24px; text-align: center; }
.assistant-welcome img { width: 70px; height: 70px; object-fit: contain; margin: 0 auto 20px; }
.assistant-welcome h3 { font-size: 28px; font-weight: 650; line-height: 1.4; margin: 0 0 12px; }
.assistant-welcome p { font-size: 15px; color: var(--muted); line-height: 1.7; margin: 0; }
.assistant-messages { overflow-y: auto; overscroll-behavior: contain; min-height: 0; height: 100%; padding: 24px max(24px, calc((100% - 760px) / 2)); scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }
.assistant-message { margin-bottom: 26px; overflow-wrap: anywhere; }
.assistant-user { display: flex; align-items: flex-end; flex-direction: column; margin-top: 16px; }
.assistant-user-bubble { max-width: 88%; background: var(--rose-wash); color: var(--text); padding: 12px 18px; border-radius: 12px; font-size: 16px; line-height: 1.75; }
.assistant-response-heading { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; margin-bottom: 12px; }
.assistant-response-heading img { width: 26px; height: 26px; object-fit: contain; }
.assistant-reply { color: var(--text-soft); font-size: 16px; line-height: 1.8; }
.assistant-reply p { margin: 0 0 14px; }
.assistant-reply h3 { font-size: 18px; margin: 24px 0 10px; font-weight: 650; }
.assistant-reply ul { padding-left: 22px; margin: 8px 0 16px; }
.assistant-reply li { margin: 6px 0; }
.assistant-reply strong { color: var(--text); font-weight: 650; }
.assistant-reply pre { white-space: pre; overflow-x: auto; background: var(--ink-850); border: 1px solid var(--line); border-radius: 8px; padding: 16px; font-size: 14px; }
.assistant-reply code { background: var(--ink-800); border-radius: 8px; padding: 2px 5px; }
.assistant-reply pre code { background: transparent; padding: 0; }
.assistant-table { overflow-x: auto; margin: 16px 0; }
.assistant-table table { border-collapse: collapse; width: 100%; font-size: 14px; }
.assistant-table :is(th, td) { border: 1px solid var(--line); padding: 10px; text-align: left; }
.assistant-table th { background: var(--ink-850); }
.assistant-reply-actions { display: flex; align-items: center; gap: 8px; margin: 4px 0 12px; }
.assistant-reply-actions button { display: flex; align-items: center; gap: 6px; min-height: 44px; border: 0; padding: 8px; background: transparent; color: var(--muted); font-size: 13px; }
.assistant-reply-actions button:hover { color: var(--text); }
.assistant-reply-actions svg { width: 17px; height: 17px; }
.assistant-thinking { color: var(--muted); }
.assistant-composer { flex: none; padding: 12px 24px max(14px, env(safe-area-inset-bottom)); width: 100%; max-width: 808px; margin: 0 auto; }
.assistant-input-shell { background: var(--ink-850); border: 1px solid var(--line); border-radius: 16px; padding: 12px 12px 8px; transition: border-color 160ms cubic-bezier(.16, 1, .3, 1), background-color 160ms cubic-bezier(.16, 1, .3, 1); }
.assistant-input-shell:focus-within { border-color: #9c8794; background: var(--ink-800); }
.assistant-input-shell textarea { display: block; width: 100%; min-height: 52px; max-height: 150px; resize: none; border: 0; outline: none; background: transparent; color: var(--text); font: inherit; font-size: 16px; line-height: 1.65; padding: 4px; border-radius: 0; }
.assistant-view .assistant-input-shell textarea:focus-visible { outline: none; box-shadow: none; }
/* Use the actual visible height: the iOS keyboard need not resize media queries. */
.assistant-view.is-compact .assistant-welcome { padding: 12px 16px; }
.assistant-view.is-compact .assistant-welcome :is(img, p) { display: none; }
.assistant-view.is-compact .assistant-welcome h3 { margin: 0; font-size: 20px; line-height: 1.5; }
.assistant-view.is-compact .assistant-input-shell textarea { max-height: 88px; }
.assistant-input-actions { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.assistant-input-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; min-width: 0; }
.assistant-search-toggle { display: inline-flex; align-items: center; justify-content: center; flex: none; gap: 6px; min-height: 44px; padding: 0 10px; border: 1px solid var(--line); border-radius: 8px; color: var(--muted); background: transparent; font: inherit; font-size: 12px; transition: background-color 140ms ease-out, color 140ms ease-out, border-color 140ms ease-out; }
.assistant-search-toggle svg { width: 18px; height: 18px; }
.assistant-search-toggle:hover:not(:disabled) { color: var(--text); background: var(--ink-800); }
.assistant-search-toggle[aria-pressed="true"] { color: var(--rose-300); border-color: var(--rose-300); background: var(--rose-wash); }
.assistant-search-toggle:active:not(:disabled) { transform: scale(.98); }
.assistant-input-actions .assistant-send { flex: none; align-self: flex-end; }
.assistant-reply a { color: var(--rose-300); text-underline-offset: 4px; }
.assistant-sources { margin: 8px 0 12px; color: var(--muted); font-size: 13px; }
.assistant-sources summary { min-height: 44px; padding: 10px 0; cursor: pointer; }
.assistant-sources ol { list-style: none; margin: 0; padding: 0; }
.assistant-sources li + li { border-top: 1px solid var(--line); }
.assistant-sources a { display: flex; gap: 10px; align-items: flex-start; min-height: 44px; padding: 10px 0; color: var(--text-soft); text-decoration: none; }
.assistant-sources a:hover strong { color: var(--rose-300); text-decoration: underline; text-underline-offset: 4px; }
.assistant-sources a > span:last-child { min-width: 0; }
.assistant-sources strong { display: block; font-weight: 500; line-height: 1.6; }
.assistant-sources small { display: block; margin-top: 4px; color: var(--muted); font-size: 12px; line-height: 1.5; }
.assistant-source-number { flex: none; min-width: 22px; text-align: center; color: var(--rose-300); font-variant-numeric: tabular-nums; line-height: 1.6; }
@media (prefers-reduced-motion: reduce) { .assistant-search-toggle { transition-duration: 100ms; } .assistant-search-toggle:active:not(:disabled) { transform: none; } }
.assistant-input-actions .assistant-upload-button { display: flex; gap: 8px; width: auto; padding: 0 8px; font-size: 12px; }
.assistant-input-actions .assistant-send { margin-left: auto; }
.assistant-send { display: grid; place-items: center; width: 44px; height: 44px; border: 0; border-radius: 12px; background: var(--rose-600); color: var(--text); }
.assistant-send:hover:not(:disabled) { background: var(--rose-700); }
.assistant-composer-note { color: var(--muted); text-align: center; font-size: 11px; line-height: 1.5; margin: 8px 0 0; }
.assistant-error { color: var(--danger); line-height: 1.7; font-size: 14px; margin: 0 0 10px; }
.assistant-attachments, .assistant-message-images { display: flex; flex-wrap: wrap; gap: 10px; margin: 6px 0 10px; }
.assistant-attachments > div { position: relative; }
.assistant-attachments img { display: block; width: 64px; height: 64px; object-fit: cover; border-radius: 8px; }
.assistant-attachments button { position: absolute; right: -10px; top: -10px; width: 44px; height: 44px; padding: 0; display: grid; place-items: center; color: var(--text); background: var(--ink-800); border: 1px solid var(--line-strong); border-radius: 8px; }
.assistant-message-images button { padding: 0; border: 0; background: transparent; }
.assistant-message-images img { width: 88px; height: 88px; border-radius: 8px; object-fit: cover; }
.assistant-confirmation { background: var(--ink-850); border: 1px solid var(--line); padding: 20px; border-radius: 12px; margin: 18px 0; }
.assistant-confirmation h3 { font-size: 17px; margin: 0 0 12px; }
.assistant-plan summary { min-height: 44px; cursor: pointer; display: flex; align-items: center; color: var(--muted); font-size: 14px; }
.assistant-plan > div { font-size: 14px; line-height: 1.8; max-height: 320px; overflow-y: auto; }
.assistant-plan p { margin: 8px 0; }
.assistant-price { display: flex; flex-wrap: wrap; gap: 20px 40px; margin: 16px 0 20px; }
.assistant-price dt { font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.assistant-price dd { margin: 0; font-size: 24px; font-weight: 650; font-variant-numeric: tabular-nums; }
.assistant-price dd span { font-size: 12px; font-weight: 400; color: var(--muted); }
.assistant-consent { display: flex; align-items: flex-start; gap: 10px; font-size: 13px; line-height: 1.6; margin-bottom: 16px; }
.assistant-consent input { width: 20px; height: 20px; margin: 0; flex: none; accent-color: var(--rose-500); }
.assistant-caption { color: var(--muted); font-size: 12px; line-height: 1.7; margin: 10px 0 0; }
.assistant-job { margin: 16px 0; }
.assistant-job-status { font-size: 14px; display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.assistant-job-status span { color: var(--muted); font-size: 12px; }
.assistant-picture { display: block; padding: 0; margin: 16px 0 10px; max-width: 100%; background: transparent; border: 0; }
.assistant-picture img { display: block; max-width: 100%; max-height: 520px; border-radius: 12px; object-fit: contain; }
.assistant-analysis-photo img { max-height: 140px; }
.assistant-download { display: inline-flex; align-items: center; min-height: 44px; color: var(--rose-300); font-size: 14px; text-underline-offset: 4px; }
.assistant-preview-dialog { padding: 16px; max-width: min(1000px, 96vw); width: fit-content; background: var(--ink-850); color: var(--text); border: 1px solid var(--line-strong); border-radius: 12px; }
.assistant-preview-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 24px; margin-bottom: 12px; }
.assistant-preview-dialog img { display: block; max-height: 76dvh; max-width: 100%; object-fit: contain; }
.home-chat-entries { width: 100%; max-width: 390px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.home-chat-entries .home-coach-action { min-width: 0; width: 100%; min-height: 68px; margin: 0; padding: 10px 12px; display: flex; gap: 10px; text-align: left; border-radius: 12px; box-shadow: none; background: var(--ink-800); border: 1px solid var(--line); animation: none; }
.home-chat-entries .home-coach-action::after { display: none; }
.home-chat-entries .home-coach-action span { display: flex; flex-direction: column; gap: 5px; }
.home-chat-entries .home-coach-action strong { font-size: 15px; font-weight: 650; }
.home-chat-entries .home-coach-action small { font-size: 11px; font-weight: 400; color: var(--muted); }
.home-chat-entries .home-assistant-action { background: var(--rose-600); border-color: var(--rose-600); }
.home-chat-entries .home-assistant-action small { color: var(--text-soft); }
@media (max-width: 760px) {
  .assistant-view, .assistant-view.history-open { grid-template-columns: minmax(0, 1fr); }
  .assistant-sidebar { display: flex; position: absolute; left: 0; top: 0; bottom: 0; z-index: 3; width: min(290px, 86vw); transform: translateX(-100%); visibility: hidden; transition: transform 180ms ease, visibility 180ms; }
  .history-open .assistant-sidebar { transform: translateX(0); visibility: visible; }
  .assistant-shade { position: absolute; inset: 0; z-index: 2; background: rgb(0 0 0 / 55%); border: 0; padding: 0; border-radius: 0; }
  .assistant-topbar { gap: 4px; padding: max(8px, env(safe-area-inset-top)) 8px 8px; min-height: 60px; }
  .assistant-topbar h2 { font-size: 15px; }
  .assistant-welcome h3 { font-size: 24px; }
  .assistant-messages { padding: 18px 16px; }
  .assistant-user-bubble { padding: 10px 14px; }
  .assistant-composer { padding: 8px 12px max(10px, env(safe-area-inset-bottom)); }
  .assistant-composer-note { font-size: 10px; }
  .assistant-confirmation { padding: 16px; }
  .assistant-input-actions .assistant-upload-button { font-size: 11px; }
  .assistant-preview-dialog { padding: 12px; }
}
@media (max-width: 350px) {
  .home-chat-entries .home-coach-action { padding: 10px 8px; gap: 6px; }
  .home-chat-entries .home-coach-action strong { font-size: 14px; }
  .home-chat-entries .home-coach-action svg { width: 20px; }
  .assistant-topbar { gap: 0; }
}
@media (prefers-reduced-motion: reduce) { .assistant-sidebar { transition: none; } .assistant-input-shell { transition-duration: 100ms; } }
/* The full-screen conversation owns its spacing, independently of workbench views. */
.view.assistant-view { padding: 0; }
.view.active.assistant-view > * { animation: none; }
