/* Deep Research */
.research-mode-chip { width: fit-content; display: inline-flex; align-items: center; gap: 7px; margin: 0 0 10px; padding: 5px 8px 5px 10px; border: 1px solid color-mix(in srgb, var(--accent) 30%, var(--border)); border-radius: var(--radius-full); background: var(--bg-secondary); font-size: 13px; font-weight: 650; }
.research-mode-chip.hidden { display: none; }
.research-mode-chip .research-mode-mark.hidden { display: none; }
.research-mode-chip button { border: 0; background: transparent; color: var(--text-secondary); cursor: pointer; padding: 0 2px; font: inherit; }
/* Research card: one soft sheet. Klui narrates while it runs; the finished card reads like a cover. */
.research-card { position: relative; width: min(760px, 100%); padding: 20px 22px 18px; border: 1px solid var(--border-light); border-radius: 18px; background: color-mix(in srgb, var(--bg) 86%, transparent); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); animation: research-card-in 380ms var(--ease-out) both; }
.research-card-heading { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 9px; margin-bottom: 10px; }
.research-card-icon { display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto; width: 18px; height: 18px; border-radius: 50%; color: var(--text-secondary); }
.research-card.is-active .research-card-icon { display: none; }
.research-card.is-complete .research-card-icon { background: var(--text); color: var(--bg); }
.research-card.is-complete .research-card-icon svg { width: 12px; height: 12px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.research-card.is-stopped .research-card-icon { width: 8px; height: 8px; margin-inline: 5px; background: var(--text-tertiary); }
@keyframes research-card-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.research-card-main { min-width: 0; }
.research-card-kicker { color: var(--text-secondary); font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; }
.research-card-meta { display: inline-flex; flex-wrap: wrap; gap: 4px 9px; color: var(--text-tertiary); font-size: 12px; }
.research-card-meta span::before { content: "·"; margin-right: 9px; }
.research-card-main .research-card-title { display: block; font-family: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif; font-size: 21px; font-weight: 650; line-height: 1.3; letter-spacing: -0.01em; }
.research-card-live { margin-top: 12px; }
.research-card-live .thinking-status.klui-bar { margin: 0; }
.research-card-main p { display: -webkit-box; margin: 10px 0 0; overflow: hidden; color: var(--text-secondary); font-size: 14.5px; line-height: 1.6; -webkit-box-orient: vertical; -webkit-line-clamp: 3; }
.research-card-progress { position: relative; height: 2px; margin-top: 16px; overflow: hidden; border-radius: var(--radius-full); background: var(--border-light); }
.research-card-progress span { position: relative; display: block; height: 100%; overflow: hidden; background: var(--text); transform: scaleX(var(--research-progress, 0)); transform-origin: left center; transition: transform 600ms var(--ease-out); }
.research-card-progress span::after { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--bg) 70%, transparent), transparent); animation: research-shimmer 1.6s linear infinite; }
@keyframes research-shimmer { from { transform: translateX(-100%); } to { transform: translateX(100%); } }
.research-card-footer { display: flex; align-items: center; justify-content: flex-end; gap: 16px; margin-top: 14px; }
.research-card.is-active .research-card-footer { margin-top: 8px; margin-bottom: -6px; }
.research-card-footer:not(:has(button)) { display: none; }
.research-card-actions { display: flex; flex: 0 0 auto; gap: 7px; }
.research-card-actions button.secondary { border-color: transparent; background: transparent; color: var(--text-secondary); }
.research-card-actions button.secondary:hover { color: var(--text); background: var(--bg-secondary); }
.research-card-actions button:not(.secondary) { border-radius: var(--radius-full); padding-inline: 16px; background: var(--text); color: var(--bg); border-color: var(--text); transition: transform 140ms var(--ease-out); }
.research-card-actions button:not(.secondary):hover { transform: translateX(2px); }
.research-card-actions button, .research-report-header button:not([role="menuitem"]):not([role="tab"]) { display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 36px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg); color: var(--text); padding: 7px 12px; font: inherit; font-size: 13px; font-weight: 650; cursor: pointer; }
.research-report-header #researchCopy.copy-flash { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); background: color-mix(in srgb, var(--accent) 10%, var(--bg)); }
.research-report-view { position: fixed; inset: 0; z-index: 100; overflow-y: auto; background: var(--bg); color: var(--text); }
.research-report-view.hidden { display: none; }
.research-report-header { position: sticky; top: 0; z-index: 2; min-height: 58px; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 16px; padding: max(10px, env(safe-area-inset-top)) max(18px, env(safe-area-inset-right)) 10px max(18px, env(safe-area-inset-left)); border-bottom: 1px solid var(--border); background: color-mix(in srgb, var(--bg) 94%, transparent); backdrop-filter: blur(14px); }
.research-report-back { justify-self: start; }
.research-report-tabs { display: flex; padding: 3px; border-radius: 8px; background: var(--bg-secondary); }
.research-report-header .research-report-tabs button { border: 0; border-radius: 8px; background: transparent; color: var(--text-secondary); box-shadow: none; min-height: 36px; padding: 7px 12px; font: inherit; font-size: 13px; font-weight: 650; cursor: pointer; }
.research-report-header .research-report-tabs button[aria-selected="true"] { background: var(--bg); color: var(--text); box-shadow: var(--shadow-sm); }
.research-report-actions { justify-self: end; display: flex; gap: 7px; }
.research-report-icon { display: none; }
.research-download-wrap { position: relative; }
.research-download-wrap .document-download-menu { left: auto; right: 0; }
.research-download-status {
  position: fixed;
  top: calc(max(10px, env(safe-area-inset-top)) + 52px);
  left: 50%;
  z-index: 5;
  width: max-content;
  max-width: calc(100% - 32px);
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  color: var(--text);
  box-shadow: var(--shadow-md);
  backdrop-filter: blur(12px);
  font-size: 13px;
  font-weight: 650;
  pointer-events: none;
  transform: translateX(-50%);
}
.research-report-header button:disabled { opacity: .55; cursor: default; }
.research-report-loading { max-width: 760px; margin: 20vh auto; padding: 24px; text-align: center; color: var(--text-secondary); }
.research-report-layout { width: min(1180px, calc(100% - 40px)); margin: 46px auto 100px; display: grid; grid-template-columns: 210px minmax(0, 760px); justify-content: center; gap: 52px; }
.research-report-layout.hidden { display: none; }
.research-report-toc { position: sticky; top: 92px; align-self: start; display: flex; flex-direction: column; gap: 7px; max-height: calc(100vh - 120px); overflow-y: auto; }
.research-report-toc a { color: var(--text-secondary); text-decoration: none; font-size: 13px; line-height: 1.35; }
.research-report-toc a.level-h3 { padding-left: 12px; color: var(--text-tertiary); }
.research-report-article { min-width: 0; font-size: 17px; line-height: 1.72; }
.research-report-article h1 { margin: 0 0 28px; font-size: 40px; line-height: 1.12; font-weight: 650; }
.research-report-article h2 { margin: 42px 0 14px; padding-top: 8px; font-size: 25px; }
.research-report-article h3 { margin: 28px 0 10px; font-size: 19px; }
.research-report-article img { display: none !important; }
.research-report-article a { color: color-mix(in srgb, var(--accent) 76%, #1677c8); text-underline-offset: 3px; }
.research-report-sources { grid-column: 2; margin-top: 30px; border-top: 1px solid var(--border); padding-top: 18px; }
.research-report-sources summary { cursor: pointer; font-weight: 700; }
.research-report-sources div { display: grid; gap: 8px; margin-top: 12px; }
.research-report-sources a { display: flex; flex-direction: column; padding: 10px 0; color: var(--text); text-decoration: none; border-bottom: 1px solid var(--border-light); }
.research-report-sources a span { color: var(--text-secondary); font-size: 13px; }
.research-report-view.text-only .research-report-layout { grid-template-columns: minmax(0, 760px); gap: 0; }
.research-report-view.text-only .research-report-toc { display: none; }
.research-report-view.text-only .research-report-sources { grid-column: 1; }
.research-report-view.text-only .research-report-article { font-size: 16px; line-height: 1.6; }

/* Visual report: editorial article treatment + topic themes.
   Accents adapt to light/dark and every app theme via color-mix with the
   live --text / --bg tokens, so one accent per theme covers all modes.
   Fonts are system stacks only (no web-font downloads = low render cost). */
.research-report-view {
  --report-serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, Cambria, "Times New Roman", serif;
  --report-sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --report-mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  --report-accent: #4f6d8f;
  --report-head-font: var(--report-serif);
  --report-body-font: var(--report-serif);
  --report-kicker-font: var(--report-sans);
}
.research-report-view[data-report-theme="commerce"] { --report-accent: #12936a; --report-head-font: var(--report-sans); --report-body-font: var(--report-serif); }
.research-report-view[data-report-theme="science"]  { --report-accent: #0e8f8a; --report-head-font: var(--report-sans); --report-body-font: var(--report-serif); }
.research-report-view[data-report-theme="tech"]     { --report-accent: #3068e6; --report-head-font: var(--report-sans); --report-body-font: var(--report-sans); --report-kicker-font: var(--report-mono); }
.research-report-view[data-report-theme="finance"]  { --report-accent: #1f7a4d; --report-head-font: var(--report-sans); --report-body-font: var(--report-serif); }
.research-report-view[data-report-theme="culture"]  { --report-accent: #b14a3c; --report-head-font: var(--report-serif); --report-body-font: var(--report-serif); }

.report-masthead { margin: 0 0 6px; padding-bottom: 30px; border-bottom: 1px solid var(--border); }
.report-kicker { margin: 0 0 18px; font-family: var(--report-kicker-font); font-size: 12px; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase; color: color-mix(in srgb, var(--report-accent) 76%, var(--text)); }
.report-title { margin: 0; font-family: var(--report-head-font); font-size: clamp(34px, 4.4vw, 52px); line-height: 1.08; letter-spacing: -0.02em; font-weight: 680; color: var(--text); }
.report-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 14px; margin-top: 22px; font-family: var(--report-sans); font-size: 13px; letter-spacing: 0.01em; color: var(--text-tertiary); }
.report-meta span:not(:first-child) { padding-left: 14px; border-left: 1px solid var(--border); }

.research-report-view:not(.text-only) .research-report-article { font-family: var(--report-body-font); font-size: 18px; line-height: 1.75; color: color-mix(in srgb, var(--text) 92%, var(--bg)); }
.research-report-view:not(.text-only) .research-report-article > h1 { display: none; }
.research-report-view:not(.text-only) .research-report-article h2 { font-family: var(--report-head-font); font-size: 27px; line-height: 1.2; letter-spacing: -0.01em; font-weight: 660; margin: 52px 0 16px; padding-top: 22px; border-top: 1px solid var(--border); }
.research-report-view:not(.text-only) .research-report-article h3 { font-family: var(--report-head-font); font-size: 20px; line-height: 1.3; margin: 32px 0 10px; }
.research-report-view:not(.text-only) .research-report-article p { margin: 0 0 20px; }
.research-report-view:not(.text-only) .research-report-article > p:first-of-type::first-letter { float: left; font-family: var(--report-head-font); font-size: 3.4em; line-height: 0.82; font-weight: 680; padding: 6px 10px 0 0; color: color-mix(in srgb, var(--report-accent) 72%, var(--text)); }
.research-report-view:not(.text-only) .research-report-article a { color: color-mix(in srgb, var(--report-accent) 72%, var(--text)); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; text-decoration-color: color-mix(in srgb, var(--report-accent) 42%, transparent); }
.research-report-view:not(.text-only) .research-report-article a:hover { text-decoration-color: currentColor; }
.research-report-view:not(.text-only) .research-report-article blockquote { margin: 28px 0; padding: 4px 0 4px 22px; border-left: 3px solid color-mix(in srgb, var(--report-accent) 58%, var(--border)); font-family: var(--report-head-font); font-size: 21px; line-height: 1.5; font-style: italic; color: var(--text); }
.research-report-view:not(.text-only) .research-report-article ul, .research-report-view:not(.text-only) .research-report-article ol { margin: 0 0 20px; padding-left: 1.3em; }
.research-report-view:not(.text-only) .research-report-article li { margin: 7px 0; }
.research-report-view:not(.text-only) .research-report-article li::marker { color: color-mix(in srgb, var(--report-accent) 60%, var(--text-tertiary)); }
.research-report-view:not(.text-only) .research-report-article hr { border: 0; border-top: 1px solid var(--border); margin: 40px 0; }
.research-report-view:not(.text-only) .research-report-article table { width: 100%; border-collapse: collapse; margin: 26px 0; font-family: var(--report-sans); font-size: 15px; }
.research-report-view:not(.text-only) .research-report-article th, .research-report-view:not(.text-only) .research-report-article td { text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: top; }
.research-report-view:not(.text-only) .research-report-article thead th { border-bottom: 2px solid color-mix(in srgb, var(--report-accent) 45%, var(--border)); font-weight: 700; }
.research-report-view:not(.text-only) .research-report-article tbody tr:nth-child(even) { background: color-mix(in srgb, var(--report-accent) 4%, var(--bg)); }
.research-report-view:not(.text-only) .research-report-article ::selection { background: color-mix(in srgb, var(--report-accent) 22%, var(--bg)); }
.research-report-view:not(.text-only) .research-report-toc a:hover { color: color-mix(in srgb, var(--report-accent) 70%, var(--text)); }

.research-report-view.text-only .report-masthead { padding-bottom: 18px; margin-bottom: 4px; }
.research-report-view.text-only .report-kicker { font-family: inherit; font-size: 11px; letter-spacing: 0.08em; margin-bottom: 10px; color: var(--text-tertiary); }
.research-report-view.text-only .report-title { font-family: inherit; font-size: 28px; font-weight: 700; letter-spacing: -0.01em; }
.research-report-view.text-only .report-meta { display: none; }

@media (prefers-reduced-motion: no-preference) {
  .research-report-view:not(.text-only) .report-masthead { animation: report-rise 0.5s var(--ease-out) both; }
}
@keyframes report-rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

@media (max-width: 720px) {
  .research-card { padding: 16px 16px 14px; border-radius: 16px; }
  .research-card-main .research-card-title { font-size: 18px; }
  .research-card-actions { width: 100%; }
  .research-card-actions button { flex: 1; }
  .research-report-header { gap: 8px; padding-left: max(10px, env(safe-area-inset-left)); padding-right: max(10px, env(safe-area-inset-right)); }
  .research-report-icon { display: block; }
  .research-report-back span,
  #researchCopy span,
  #researchDownload > span,
  .research-report-header .document-download-chevron { display: none; }
  .research-report-header button:not([role="menuitem"]):not([role="tab"]) { width: 36px; min-width: 36px; padding: 0; gap: 0; }
  .research-report-tabs { min-width: 0; }
  .research-report-header .research-report-tabs button { min-height: 32px; padding: 6px 8px; font-size: 12px; }
  .research-report-layout { width: min(100% - 28px, 760px); margin-top: 30px; display: block; }
  .research-report-toc { position: static; max-height: 160px; margin-bottom: 28px; padding: 12px; border: 1px solid var(--border); border-radius: 8px; }
  .research-report-article { font-size: 16px; line-height: 1.65; }
  .research-report-article h1 { font-size: 31px; }
  .research-report-sources { margin-top: 28px; }
  .research-report-view:not(.text-only) .research-report-article { font-size: 17px; line-height: 1.72; }
  .research-report-view:not(.text-only) .research-report-article h2 { font-size: 23px; margin-top: 40px; }
  .report-title { font-size: clamp(28px, 8vw, 36px); }
}
@media print {
  .research-report-header, .research-report-toc, .research-report-sources, .research-download-status { display: none !important; }
  .research-report-view { position: static; overflow: visible; }
  .research-report-layout { display: block; width: 100%; margin: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .research-card,
  .research-card-progress span::after { animation: none; }
  .composer-tool,
  .send-btn,
  .stop-btn,
  .composer-model-btn,
  .compare-btn,
  .sidebar-icon,
  .temporary-chat-toggle,
  .drawer-close,
  .profile-menu-item,
  .composer-action-menu-item,
  .model-option,
  .research-card-actions button,
  .research-report-header button,
  .confirm-actions button,
  .rename-actions button,
  .auth-dialog-close,
  .search-dialog-close {
    transform: none !important;
    transition-duration: 0.01ms;
  }
}
