/* Workspace hierarchy and shared interaction rules. */
body .intro h1 { font-weight: 500; line-height: 1.2; letter-spacing: -.8px; font-size: clamp(22px, 2.5vw, 30px); margin-bottom: 4px; }
body .intro p { line-height: 1.7; font-size: 14px; color: var(--text-primary); margin: 0; }
body .workspace-card, body .results-panel, body .result-library { min-width: 0; border-radius: var(--radius-lg); }
body .section-heading { flex-wrap: wrap; gap: 10px; }
body .section-heading h2 { font-weight: 600; letter-spacing: -.2px; display: flex; align-items: center; }
body .step-complete .step, body .step-ready .step { background: var(--brand-primary); color: var(--fg-inverse); }
body .drop-copy strong { line-height: 1.5; }
body .dropzone:focus-within { outline: 3px solid var(--brand-accent); outline-offset: 4px; }
body .dropzone:has(input:disabled) { cursor: wait; opacity: .65; }
.mode-help { line-height: 1.65; margin: -4px 0 18px; }
body .tab .mode-copy small { display: block;   font-weight: 400; font-size: 12px; color: var(--text-secondary); margin-top: 2px;  }
body .scenario-actions button { min-height: 40px; }
body .results-panel .result-filters { display: flex; flex-wrap: wrap; gap: 5px; margin: 16px 0 8px; }
body .results-panel .result-filters button { min-height: 36px; font-size: 12px; padding: 7px 9px; }
body .results-panel:not(:has(.job)) .result-filters { display: none; }
body .history-disclosure { border-bottom: 1px solid var(--border-default); }
.history-disclosure .panel-bulk-actions { margin-top: 4px; }
#offline-banner { margin: 20px 0 0; line-height: 1.6; }
#message { scroll-margin-top: 100px; }
body .notice, #submit-summary { overflow-wrap: anywhere; }
body .submit-row { gap: 16px; }
body .submit-row > div { min-width: 0; }
body .submit-row .primary { flex-shrink: 0; }
body .file-name { display: block; }
body #file-list .file-controls button { min-width: 36px; min-height: 40px; }
body #file-list .file-controls button:disabled { opacity: .35; }
input, select, textarea { accent-color: var(--text-secondary); }
body .request-reply,
body .detail-facts dd { overflow-wrap: anywhere; }
body .request-pages { display: flex; align-items: center; justify-content: center; gap: 14px; }
h1[tabindex='-1']:focus { outline: none; }
body :is(.shell, .account-shell, .api-layout, .api-footer-shell) {
  width: 100%;
  max-width: var(--site-width);
  padding-inline: var(--site-gutter);
}
body .topbar {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;

  padding: 10px max(var(--site-gutter), calc((100% - var(--site-width)) / 2 + var(--site-gutter)));
  position: sticky;
  top: 0;
  z-index: 30;
  min-height: 68px;
  height: auto;
  gap: 8px 20px;
  view-transition-name: site-header;
}
body .topbar nav {
  min-width: 0;
  flex-wrap: wrap;

}
body .topbar nav a { flex-shrink: 0; white-space: nowrap; display: inline-flex; align-items: center; gap: 6px; padding: 9px 13px; font-size: 14px; line-height: 1.3; border-radius: var(--radius-md); }
.topbar .header-actions {
  min-width: 0;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;

}
.topbar .account-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 90px;
}
.topbar .account-avatar { flex-shrink: 0; }
.topbar :is(.account-pill, .account-quota) { min-height: 36px; }
.header-actions .site-language {
  inline-size: 108px;
  min-height: 36px;
  padding: 0 10px;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  background: var(--bg-subtle);
  color: var(--text-primary);
  font: 500 13px/1.25 var(--font-sans);
  cursor: pointer;
  flex-shrink: 0;
}
.header-actions .site-language:hover {
  background-color: var(--bg-muted);
  border-color: var(--border-strong);
}
body .topbar .site-language:focus-visible {
  outline: 2px solid var(--brand-accent);
  outline-offset: 2px;
  box-shadow: none;
}

@supports (appearance: base-select) and selector(::picker(select)) {
  .header-actions .site-language,
  .header-actions .site-language::picker(select) { appearance: base-select; }

  .header-actions .site-language { align-items: center; gap: 10px; }
  .header-actions .site-language:open { border-color: var(--brand-tint-border); }
  .header-actions .site-language::picker-icon {
    content: "";
    inline-size: 7px;
    block-size: 7px;
    margin-inline-start: auto;
    margin-inline-end: 2px;
    border: solid var(--text-secondary);
    border-width: 0 1.5px 1.5px 0;
    transform: translateY(-2px) rotate(45deg);
  }
  .header-actions .site-language:open::picker-icon { transform: translateY(2px) rotate(225deg); }

  .header-actions .site-language::picker(select) {
    min-inline-size: 144px;
    margin-block: 6px;
    padding: 4px;
    border: 1px solid var(--border-default);
    border-radius: var(--radius-lg);
    background: var(--bg-surface);
    color: var(--text-primary);
    box-shadow: var(--shadow-pop);
  }
  .header-actions .site-language option {
    display: flex;
    align-items: center;
    gap: 12px;
    min-block-size: 38px;
    padding: 6px 10px;
    border-radius: var(--radius-md);
    cursor: pointer;
  }
  .header-actions .site-language option:hover { background: var(--bg-muted); }
  .header-actions .site-language option:checked {
    background: var(--brand-tint);
    color: var(--brand-tint-fg);
    font-weight: 600;
  }
  .header-actions .site-language option:focus-visible {
    outline: 2px solid var(--brand-accent);
    outline-offset: -2px;
  }
  .header-actions .site-language option::checkmark {
    order: 1;
    margin-inline-start: auto;
  }
  @media (pointer: coarse) {
    .header-actions .site-language option { min-block-size: 44px; }
  }
}

body .toast {
  bottom: max(22px, env(safe-area-inset-bottom));
  max-width: calc(100vw - 28px);
  overflow-wrap: anywhere;
  background: var(--bg-surface);
  border: 1px solid var(--border-strong);
  color: var(--text-primary);
  box-shadow: var(--shadow-pop);
  gap: 12px;
}
body .toast button {
  color: var(--brand-tint-fg);
  font-weight: 600;
}
body .toast button:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}
body .toast #toast-close,
body .toast #account-toast-close {
  color: var(--text-secondary);
  font-weight: 400;
  text-decoration: none;
}
body .toast #toast-close:hover,
body .toast #account-toast-close:hover {
  color: var(--text-primary);
  text-decoration: none;
}
body summary:focus-visible { outline: 3px solid var(--brand-accent); outline-offset: 3px; }
@media (min-width: 951px) {
  body .results-panel { position: sticky; top: 88px; }
}
@media (min-width: 1151px) {
  html { scroll-padding-top: 88px; }
}
@media (max-width: 1150px) {
  :root { --site-gutter: 24px; }
  body .topbar {
    grid-template-columns: auto minmax(0, 1fr);
  }
  body .topbar nav {
    order: 3;
    grid-column: 1 / -1;
    margin-left: 0;
    overflow: visible;
  }
  .topbar .header-actions { margin-left: 0; }
}
@media (max-width: 550px) {
  :root { --site-gutter: 14px; }
  .topbar { column-gap: 10px; }
  .topbar .account-quota, .topbar .connection { order: 1; }
  body .topbar .account-name { max-width: 68px; }
  body .section-heading { align-items: flex-start; }
  body .section-heading > .muted { margin-left: 34px; width: 100%; max-width: none; text-align: left; font-size: 12px; }
  body .dropzone:not(.has-files) { text-align: center; justify-content: center; }
  body .dropzone .drop-copy { width: 100%; flex: none; }
  body .dropzone .drop-copy > span { display: block; margin-top: 8px; }
  body .dropzone .choose-button { display: inline-flex; margin: 0 auto; align-self: center; flex: none; }
  body .dropzone { flex-direction: column; align-items: stretch; }
  body .tab .mode-copy small { display: none; }
  body .mode-help { margin-bottom: 14px; }
  body .scenario-actions button { min-height: 44px; }
  body .results-panel .result-filters button { min-height: 44px; }
  body .library-controls input, body .library-controls select, body .parameters input, body .parameters select, body #tool-search, body .account-card input, body .account-card select { font-size: 16px; min-height: 48px; }
  body .library-file-copy small, body .state-pill, body .row-size, body .library-pagination > .muted { font-size: 12px; }
  body .library-pagination .secondary, body .row-actions button { min-height: 44px; }
  body .row-actions { flex-wrap: wrap; justify-content: flex-end; }
  .library-row { grid-template-columns: 28px minmax(0,1fr) 80px; }
  body .library-search, body .library-controls select { width: 100%; min-width: 0; }
  body #file-list .file-controls button { min-width: 32px; min-height: 44px; }
  body .optional-settings-grid { gap: 18px; }
  body .slider-wrap { flex-wrap: wrap; }
  .slider-wrap .param-slider { min-width: 80px; }
  body .submit-row .primary { width: 100%; }
  body .storage-policy, body footer, body .library-note { font-size: 12px; line-height: 1.7; }
  body .toast { left: 14px; right: 14px; width: auto; transform: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}

/* Legacy aliases of the design tokens (design.css) */

/* Sticky, crisp topbar */
.topbar,
.account-body .topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  background: color-mix(in srgb, var(--bg-surface) 92%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-soft);
}

.topbar nav a {
  font-weight: 500;
  transition: background-color 0.15s ease, color 0.15s ease;
}

/* Hover only for inactive links: `a:hover` (0,2,2) used to outrank `.nav-active` (0,2,1),
   so pointing at the current page wiped its highlight. */
.topbar nav a:not(.nav-active):not([aria-current="page"]):hover {
  background: color-mix(in srgb, var(--bg-muted) 45%, transparent);
  color: var(--text-primary);
}

.topbar nav a.nav-active,
.topbar nav a.nav-active:hover,
.account-body .topbar nav a[aria-current="page"],
.account-body .topbar nav a[aria-current="page"]:hover {
  background: var(--bg-muted);
  color: var(--text-primary);
  font-weight: 500;
}

.counter {
  border-radius: var(--radius-sm);
  padding: 2px 7px;
  font-weight: 600;
  background: var(--bg-muted);
  color: var(--text-secondary);
}

.account-pill {
  transition: background-color 0.15s ease, border-color 0.15s ease, transform 0.12s ease;
  background: var(--bg-subtle);
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 11px 5px 7px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  color: var(--text-primary);
}

.account-pill:hover {
  background: var(--bg-muted);
  border-color: var(--border-strong);
}

/* Cards & surfaces */
.workspace-card,
.result-library,
.account-card {
  border-color: var(--border-soft);
  box-shadow: var(--shadow-card);
  background: var(--bg-surface);
}

/* Visually separate the right-hand Session Results sidebar from the main white workspace canvas */
.results-panel {
  background: var(--bg-muted);
  border: 1px solid var(--border-default);
  box-shadow: var(--shadow-card);
  align-self: start;
  margin-top: 0;
}

body .results-panel .results-heading .eyebrow {
  display: block;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 1.4px;
  color: var(--text-secondary);
  margin-bottom: 2px;
}

/* Dropzone refinement: compact height so main action stays above the fold */
body .dropzone:not(.has-files) {
  min-height: 92px;
  padding-top: 18px;
  padding-bottom: 18px;
  gap: 16px;

}

.dropzone {
  border: 1.5px dashed var(--brand-accent);
  background: var(--bg-subtle);
  padding: 13px 18px;
}

.dropzone:hover,
.dropzone.dragging {
  border-color: var(--brand-primary);
  background: var(--bg-page);
  box-shadow: var(--shadow-card);
}

.drop-actions {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
  flex-wrap: wrap;
}

.dropzone .choose-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  border: 1px solid var(--brand-forest);
  white-space: nowrap;
  transition: background-color 0.15s ease, border-color 0.15s ease, transform 0.12s ease, box-shadow 0.15s ease;
}

.dropzone:hover .choose-button {
  transform: translateY(-1px);
}

.paste-shortcut {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-weight: 500;
  background: var(--bg-surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  padding: 5px 9px;
  box-shadow: var(--shadow-card);
  white-space: nowrap;
}

.paste-shortcut kbd {
  display: inline-block;
  padding: 2px 6px;
  font-family: var(--font-mono);
  font-size: 11.5px;
  font-weight: 600;
  line-height: 1.2;
  color: var(--text-primary);
  background: var(--bg-page);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-card);
}

.paste-shortcut .key-plus {
  font-weight: 600;
  color: var(--text-secondary);
  padding: 0 1px;
}

.dropzone.has-files {
  padding: 10px 14px;
  background: var(--bg-subtle);
  border-color: var(--border-strong);
}

.dropzone.has-files .paste-shortcut {
  display: none;
}

.dropzone.has-files .upload-icon {
  display: grid;
  width: 30px;
  height: 30px;
  font-size: 16px;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
}

/* Compact hero for returning users */
body .intro {
  padding: 12px 0 8px;
}



.intro.intro-compact {
  padding: 4px 0 6px;
}

body .intro.intro-compact h1 {
  font-size: 20px;
  margin: 0;
}

/* Attention highlight when user clicks disabled submit button before adding files */
@keyframes attention-pulse {
  0%, 100% { box-shadow: var(--shadow-card); }
  25%, 75% { box-shadow: var(--shadow-card); border-color: var(--brand-primary); }
  50% { box-shadow: var(--shadow-card); border-color: var(--brand-primary); }
}

.files-section.highlight-attention {
  border-radius: var(--radius-lg);
  background: var(--bg-subtle);
  transition: background-color 0.25s ease;
}

.dropzone.highlight-attention,
.ai-composer.highlight-attention {
  border-color: var(--brand-primary) !important;
  background: var(--bg-muted) !important;
  animation: attention-pulse 1.2s ease-in-out 2;
}

/* Mode tabs: Active tab is high-contrast forest green, inactive tabs are light & clean */
body .tabs {
  align-items: stretch;

}

body .tab {
  min-height: 50px;
  border-radius: var(--radius-md);
  gap: 8px;

  border: 1px solid var(--border-default);

  font-weight: 500;
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}


.tab:hover:not(:disabled):not(.selected) {
  background: var(--bg-subtle);
  border-color: var(--border-strong);
  color: var(--text-primary);
}

body .tab .mode-icon {
  display: inline-block;
  font-size: 15px;
  opacity: 0.95;
}

body .tab.selected,
body .tab[aria-pressed="true"] {

  font-weight: 500;

}

body .tab.selected .mode-copy b,
body .tab[aria-pressed="true"] .mode-copy b {
  color: var(--fg-inverse);

}

body .tab.selected .mode-copy small,
body .tab[aria-pressed="true"] .mode-copy small {
  color: var(--text-muted);

}

/* Unified Chat Composer with file chips, styled template button, and prominent send arrow */
.ai-composer-sticky {
  bottom: 0;
  z-index: 12;
  background: linear-gradient(180deg, transparent 0%, var(--bg-surface) 18%, var(--bg-surface) 100%);
}

body .ai-composer {
  border: 1.5px solid var(--brand-accent);
  border-radius: var(--radius-lg);
  background: var(--bg-surface);
  padding: 10px 12px 8px 14px;
  box-shadow: var(--shadow-card);
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
}

body .ai-composer:focus-within {
  border-color: var(--brand-forest);
  box-shadow: var(--shadow-card);
}

.composer-files {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  border-bottom: 1px solid var(--border-default);
}

.composer-input-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}


#ai-prompt::placeholder {
  color: var(--text-secondary);
  opacity: 1;

}

.composer-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid var(--border-default);
}

.composer-tools-left,
.composer-tools-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.composer-tool-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 32px;
  padding: 5px 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--bg-subtle);
  font-size: 12.5px;
  font-weight: 500;
  line-height: 1.2;
  transition: background-color 0.14s ease, border-color 0.14s ease, color 0.14s ease, transform 0.1s ease;
}

.composer-tool-btn:hover:not(:disabled) {
  background: var(--bg-muted);
  border-color: var(--brand-accent);
  color: var(--text-primary);
  transform: translateY(-1px);
}

.composer-shortcut-hint,
.prompt-counter,
.draft-badge {
  font-weight: 500;
}

.composer-send-btn {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  min-width: 36px;
  min-height: 36px;
  padding: 0;
  border-radius: var(--radius-md);
  border: 1px solid var(--brand-forest);
  background: var(--brand-forest);
  color: var(--fg-inverse);

  font-weight: 500;
  line-height: 1;
  box-shadow: var(--shadow-card);
  transition: background-color 0.15s ease, transform 0.12s ease, box-shadow 0.15s ease, opacity 0.15s ease;
  font-size: 20px;
}

.composer-send-btn:hover:not(:disabled) {
  background: var(--brand-forest-hover);
  border-color: var(--brand-forest-hover);
  transform: translateY(-1px);
  box-shadow: var(--shadow-card);
}

.composer-send-btn:disabled {

  box-shadow: none;
  cursor: not-allowed;
  background: var(--bg-muted);
  border-color: var(--border-strong);
  color: var(--text-secondary);
}

/* Unified Presets Hub: Tabs "Примеры задач" & "Мои шаблоны" + "Показать все" */
.scenario-box#presets-hub {
  margin-top: 10px;
  padding: 12px 14px;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  background: var(--bg-subtle);
}

.presets-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-default);
}

.presets-tabs {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.presets-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 32px;
  padding: 5px 12px;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  transition: background-color 0.14s ease, color 0.14s ease, border-color 0.14s ease;
}

.presets-tab:hover {
  background: var(--bg-page);
  color: var(--text-primary);
}

.presets-tab.active,
.presets-tab[aria-selected="true"] {
  background: var(--bg-surface);
  border-color: var(--border-strong);
  color: var(--text-primary);
  box-shadow: var(--shadow-card);
}

.presets-more-btn {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-primary);
  padding: 4px 8px;
  min-height: 28px;
}

.presets-empty {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  width: 100%;
  padding: 4px 2px;
  font-size: 13px;
}

/* Unified Plan Card & Result Card inside Assistant Chat Bubble */
.ai-message.has-card .message-text {
  display: block;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 10px;
}

.chat-plan-card {
  border-radius: var(--radius-lg);
}

.chat-plan-steps {
  margin: 0;
  padding-left: 20px;
  display: grid;
  gap: 10px;
}

.chat-plan-steps li {
  line-height: 1.5;
}

.chat-plan-steps strong {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: 0;
  margin: 0 0 2px;
}

.chat-plan-steps small {
  display: block;
  font-size: 11.5px;
  color: var(--text-secondary);
  line-height: 1.45;
}

.chat-plan-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--border-default);
}

.chat-plan-actions .primary {
  min-height: 38px;
  padding: 8px 18px;
  font-size: 13px;
}

.chat-plan-actions .secondary {
  min-height: 38px;
  padding: 8px 14px;
  font-size: 12.5px;
}

.chat-plan-status {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-top: 12px;
  padding-top: 11px;
  border-top: 1px solid var(--border-default);
  font-size: 12.5px;
  font-weight: 600;
}

.chat-plan-status.running {
  color: var(--text-secondary);
}

.chat-plan-status.completed {
  color: var(--brand-tint-fg);
}

.chat-plan-status .status-badge {
  display: inline-grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--brand-tint);
  color: var(--brand-tint-fg);
  font-size: 12px;
  font-weight: 600;
}

.chat-plan-status.cancelled {
  color: var(--text-secondary);
  font-weight: 500;
}

.chat-plan-status.failed {
  color: var(--danger);
}

.chat-result-list {
  display: grid;
}


.chat-result-card .download {
  background: var(--brand-forest);
  border-color: var(--brand-forest);
  color: var(--fg-inverse);
  font-weight: 600;
  font-size: 12.5px;
  min-height: 38px;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

.chat-result-card .download:hover {
  background: var(--brand-forest-hover);
  border-color: var(--brand-forest-hover);
}

/* High-contrast clickable template & suggestion chips */
body .scenario-actions button,
body .suggestions button,
body .quick-actions button {
  background: var(--bg-surface);
  border: 1px solid var(--border-strong);
  color: var(--text-primary);
  font-weight: 500;
  font-size: 12px;
  border-radius: var(--radius-md);
  padding: 8px 13px;
  box-shadow: var(--shadow-card);
  transition: background-color 0.14s ease, border-color 0.14s ease, color 0.14s ease, transform 0.1s ease, box-shadow 0.14s ease;
}

body .scenario-actions button:hover:not(:disabled),
body .suggestions button:hover:not(:disabled),
body .quick-actions button:hover:not(:disabled) {
  background: var(--bg-muted);
  border-color: var(--brand-primary);
  color: var(--text-primary);
  transform: translateY(-1px);
  box-shadow: var(--shadow-card);
}

body .quick-actions button[aria-pressed="true"] {

  font-weight: 500;
}

/* Allow clicking disabled submit wrapper to trigger Step 1 highlight */
.submit-wrap {
  display: inline-flex;
  flex-shrink: 0;
}

.submit-wrap > button:disabled {
  pointer-events: none;
}

/* Instant custom hover/focus tooltips for result card action icons */
[data-tooltip] {
  position: relative;
}

[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 7px);
  right: 0;
  background: var(--bg-inverse);
  color: var(--fg-inverse);
  font-size: 11px;
  font-weight: 500;
  line-height: 1.35;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.14s ease, transform 0.14s ease;
  box-shadow: var(--shadow-card);
  z-index: 40;
}

[data-tooltip]:hover::after,
[data-tooltip]:focus-visible::after {
  opacity: 1;
  transform: translateY(0);
}

/* Disclosures (summary rows) */
.category-disclosure > summary,
.optional-settings > summary,
.history-disclosure > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  list-style: none;
  font-weight: 500;
  color: var(--text-secondary);
  border-radius: var(--radius-md);
  padding: 10px 4px;
  min-height: 40px;
  transition: color 0.15s ease, background-color 0.15s ease;
}

.category-disclosure > summary::-webkit-details-marker,
.optional-settings > summary::-webkit-details-marker,
.history-disclosure > summary::-webkit-details-marker {
  display: none;
}

.category-disclosure > summary::after,
.optional-settings > summary::after,
.history-disclosure > summary::after {
  content: "⌄";
  font-size: 15px;
  line-height: 1;
  color: var(--text-muted);
  transform: rotate(-90deg);
  transition: transform 0.16s ease;
}

details[open].category-disclosure > summary::after,
details[open].optional-settings > summary::after,
details[open].history-disclosure > summary::after {
  transform: rotate(0deg);
}

.category-disclosure > summary:hover,
.optional-settings > summary:hover,
.history-disclosure > summary:hover {
  color: var(--text-primary);
}

/* Keep interactive sliders alongside number inputs for tactile adjustment */
.slider-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
}


.slider-wrap input[type="number"] {
  width: 92px;
  flex: 0 0 92px;
  text-align: center;
}

/* Action gate notice when no files are selected */
.action-gate {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  background: var(--bg-subtle);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: 13px;
  margin: 4px 0 12px;
}

.action-gate::before {
  content: "↑";
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: var(--radius-sm);
  background: var(--bg-muted);
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 12px;
  flex-shrink: 0;
}

/* Buttons consistency across Workspace, Results and Account */
.primary,
.account-card .primary {
  background: var(--brand-forest);
  border: 1px solid var(--brand-forest);
  color: var(--fg-inverse);
  font-weight: 600;
  border-radius: var(--radius-md);
  transition: background-color 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
}

.primary:hover:not(:disabled),
.account-card .primary:hover:not(:disabled) {
  background: var(--brand-forest-hover);
  border-color: var(--brand-forest-hover);
}

.primary:disabled,
.account-card .primary:disabled {
  background: var(--bg-muted);
  border-color: var(--border-strong);
  color: var(--text-primary);
  opacity: 1;
}

.secondary,
.account-card .secondary {
  border-radius: var(--radius-md);
  font-weight: 500;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.eyebrow {
  display: block;
}

.account-back + .eyebrow {
  margin-top: 2px;
}

.account-grid > .account-card {
  display: flex;
  flex-direction: column;
}

.account-grid > .account-card .plan-list-block {
  flex: 1;
}

.pricing-limit-link {
  font-weight: 500;
  color: var(--brand-tint-fg) !important;
  text-decoration: underline;
  text-underline-offset: 3px;
  white-space: nowrap;
}

/* Requests view inside unified library card */

.requests-surface .request-list {
  padding: 18px 23px;
}

.requests-surface .request-list:has(> .library-empty) {
  padding: 0;
}

.requests-surface .request-pages {
  margin: 0;
  padding: 0 23px 20px;
}

/* Mobile navigation & layout polish */

@media (max-width: 550px) {
  /* Keep "Обработка" visible in mobile nav so users can always return to workspace */
  .topbar nav a:first-child {
    display: inline-flex;
  }

  /* Compact connection dot without awkward text collision */
  .connection {
    font-size: 0;
    gap: 0;
    padding: 4px;
  }

  .connection::before {
    width: 8px;
    height: 8px;
  }

  .account-pill {
    font-size: 12px;
  }



  .requests-surface .request-list {
    padding: 14px;
  }
}
/* Results: cards filter the current library tab. */
#results-view .results-metrics strong { font-weight: 600; color: var(--text-primary); }
#results-view .results-metrics button:focus-visible { outline: 2px solid var(--brand-accent); outline-offset: 3px; }
#results-view .library-match-count { margin: 0; padding: 14px 24px; font-size: 12px; }
#results-view .library-columns input { appearance: auto; accent-color: var(--brand-accent); width: 16px; height: 16px; min-height: 16px; margin: 0; padding: 0; }
@media (max-width: 550px) {
  #results-view .library-match-count { padding: 12px 16px; }
  #results-view .library-columns:not([hidden]) { display: flex; padding: 10px 16px; }
  #results-view .library-columns > span:not(:first-child) { display: none; }
  #results-view .library-columns > span:first-child { display: flex; align-items: center; gap: 10px; }
  #results-view .library-columns > span:first-child::after { content: "Выбрать завершённые на странице"; }
  :lang(en) #results-view .library-columns > span:first-child::after { content: "Select finished jobs on this page"; }
}
/* Compact assistant request history & unified layout. */
#results-view { width: 100%; min-width: 0; }
#results-view .results-intro p { max-width: 660px; color: var(--text-primary); font-size: 14px; }
#results-view [hidden] { display: none !important; }
#results-view .request-list { display: block; padding: 0; }

.disk-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  background: var(--bg-page);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  margin: 0 0 16px;
  font-size: 13px;
  color: var(--text-primary);
  line-height: 1.5;
}
.disk-banner-icon { font-size: 18px; flex-shrink: 0; }
.disk-banner-text { flex: 1; }
.disk-banner-close {
  min-width: 28px;
  min-height: 28px;
  border: 0;
  background: transparent;
  color: var(--text-secondary);
  font-size: 18px;
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.disk-banner-close:hover { background: var(--bg-muted); color: var(--text-primary); }

.request-toolbar-unified {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  padding: 16px 20px;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-default);
}
.request-toolbar-actions {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-shrink: 0;
}
.hide-incomplete-btn {
  font-size: 12px;
  padding: 7px 12px;
  min-height: 34px;
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  color: var(--text-primary);
  font-weight: 500;
  cursor: pointer;
}
.hide-incomplete-btn:hover { background: var(--bg-page); border-color: var(--border-strong); }
.history-meta-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 20px;
  background: var(--bg-subtle);
  border-bottom: 1px solid var(--border-default);
  font-size: 12px;
  color: var(--text-primary);
}
.history-select-all-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-weight: 500;
}
.history-select-all-label input, #results-view .history-select {
  appearance: auto;
  accent-color: var(--brand-tint-fg);
  width: 16px;
  height: 16px;
  min-height: 16px;
  cursor: pointer;
}

#results-view .request-filters { display: flex; flex-wrap: wrap; gap: 7px; }
#results-view .request-filters button { min-height: 36px; padding: 6px 13px; font-size: 12px; border-radius: var(--radius-sm); }
#results-view .request-filters button[aria-pressed=true] { color: var(--text-primary); border-color: var(--brand-accent); background: var(--bg-muted); font-weight: 500; }
#results-view .request-filters button.zero-count { opacity: 0.55; }
#results-view .request-summary { font-size: 12px; color: var(--text-secondary); margin: 0; }
#results-view .request-day-title { font-size: 13px; font-weight: 500; color: var(--text-primary); margin: 0; padding: 10px 20px; background: var(--bg-page); border-block: 1px solid var(--border-default); }

#results-view .request-entry {
  display: grid;

  gap: 14px;
  padding: 10px 20px;
  border-bottom: 1px solid var(--border-default);
  grid-template-columns: 20px minmax(0, 1fr) 190px;
  align-items: start;
}
#results-view .request-entry:hover { background: var(--bg-subtle); }
#results-view .history-select { margin: 0; align-self: center; }

#results-view .request-details { min-width: 0; }
#results-view .request-row-summary {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) 20px;
  align-items: center;
  gap: 14px;
  cursor: pointer;
  list-style: none;
  border-radius: var(--radius-sm);
  padding: 2px 0;
}
#results-view summary::-webkit-details-marker { display: none; }
#results-view .request-row-summary::marker { content: ''; }
#results-view .request-row-copy { display: grid; gap: 3px; }

#results-view .request-row-line1 {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
}
#results-view .request-title {

  line-height: 1.4;
  flex: 1 1 auto;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);

}
#results-view .request-title::after { content: none; }
#results-view .request-time {
  color: var(--text-secondary);
  font-size: 12px;
  white-space: nowrap;
  flex-shrink: 0;
}

#results-view .request-row-line2 {

  gap: 6px;

  line-height: 1.4;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#results-view .request-filename {

  flex-shrink: 0;
  white-space: nowrap;
  color: var(--text-secondary);
  font-weight: 400;
  max-width: 60%;
  overflow: hidden;
  text-overflow: ellipsis;

}

#results-view .request-row-line3 {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 2px;
}
#results-view .request-outcome {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  line-height: 1.4;
  border-radius: var(--radius-sm);
  padding: 2px 8px;
  font-weight: 600;

}
#results-view .request-outcome.status-incomplete,
#results-view .request-outcome.status-cancelled { background: var(--bg-muted); color: var(--text-secondary); }
#results-view .request-outcome-meta { color: inherit; opacity: 0.9; font-weight: 400; }

#results-view .request-chevron {
  color: var(--text-secondary);
  display: inline-block;
  text-align: center;
  justify-self: end;
}
#results-view .request-details[open] .request-chevron {
  transform: rotate(180deg);
}

#results-view .request-preview {
  width: 44px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border-radius: var(--radius-md);
  background: var(--bg-page);
  font-size: 11px;
}
#results-view .request-preview img { width: 100%; height: 100%; object-fit: cover; }
#results-view .request-preview svg { max-width: 28px; max-height: 32px; }

#results-view .file-history-icon:has(img) .file-format {
  display: none !important;
}

#results-view .request-row-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  justify-content: flex-end;
  width: 190px;
}
#results-view .request-row-actions .primary {
  min-height: 34px;
  padding: 6px 14px;
  font-size: 12px;
  border-radius: var(--radius-md);
}
#results-view .request-repeat-btn {
  font-size: 12px;
  color: var(--text-primary);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  background: var(--bg-page);
  border: 1px solid transparent;
  cursor: pointer;
  font-weight: 500;
}
#results-view .request-repeat-btn:hover { background: var(--bg-muted); color: var(--text-primary); text-decoration: none; }

#results-view .row-more-btn {
  opacity: 0.45;
  transition: opacity .15s ease;
  min-width: 32px;
  min-height: 32px;
  font-size: 16px;
  border-radius: var(--radius-sm);
}
#results-view .request-entry:hover .row-more-btn,
#results-view .request-entry:focus-within .row-more-btn,
#results-view .row-more-btn:focus-visible { opacity: 1; }

#results-view .request-expanded { margin: 12px 0 0 58px;  font-size: 13px; color: var(--text-primary); overflow-wrap: anywhere; display: grid; gap: 18px; padding: 6px 0 4px; }
#results-view .request-expanded h3 { font-size: 12px; margin: 12px 0 6px; color: var(--text-primary); }
#results-view .request-expanded p { line-height: 1.6; margin: 5px 0; }
#results-view .request-answer { white-space: pre-wrap; }

#results-view .request-job { border-top: 1px solid var(--border-default); margin-top: 12px; padding-top: 12px; }
#results-view .request-job > a { display: inline-flex; margin-top: 8px; }

#results-view .request-menu { position: relative; }
#results-view .request-menu > summary { cursor: pointer; list-style: none; font-size: 18px !important; }
#results-view .request-menu-items { position: absolute; z-index: 10; right: 0; top: calc(100% + 6px); width: min(260px,75vw); padding: 6px; border: 1px solid var(--border-default); border-radius: var(--radius-lg); background: var(--bg-surface); box-shadow: var(--shadow-card); display: grid; }
#results-view .request-menu-items button { padding: 9px 12px; font-size: 13px; text-align: left; min-height: 38px; }
#results-view .request-menu-items button:hover { background: var(--bg-page); }
#results-view .request-row-summary:focus-visible, #results-view .request-menu > summary:focus-visible { outline: 2px solid var(--brand-accent); outline-offset: 4px; }
#results-view .request-pages:not([hidden]) { padding-top: 20px; color: var(--text-primary); font-size: 13px; display: flex; align-items: center; justify-content: center; gap: 14px; }
#results-view .pages-more-btn { margin-left: 14px; }

#results-view .request-skeleton { display: flex; gap: 14px; padding: 18px 20px; border-top: 1px solid var(--border-default); }
#results-view .request-skeleton span { background: var(--bg-muted); border-radius: var(--radius-md); width: 44px; height: 48px; }
#results-view .request-skeleton span + span { width: 70%; height: 48px; }

@media(max-width: 850px) {
  #results-view .request-entry {  gap: 10px; }
  #results-view .request-row-actions { grid-column: 2; padding-left: 58px; margin-top: 4px; }
}
@media(max-width: 550px) {
  #results-view .request-entry { padding: 10px 14px; }
  #results-view .request-row-summary { grid-template-columns: 36px minmax(0,1fr) 18px; gap: 10px; }
  #results-view .request-row-line1 { flex-direction: column; gap: 2px; }
  #results-view .request-row-actions { padding-left: 0; grid-column: 1 / -1; }
  
  #results-view .request-preview { width: 36px; height: 40px; }
  #results-view .request-expanded { margin-left: 0; }
  #results-view .request-day-title, #results-view .history-meta-row { padding-inline: 14px; }
}

#results-view .history-hidden-toggle { display: inline-flex; align-items: center; gap: 6px; color: var(--text-primary); font-size: 12px; cursor: pointer; }
#results-view .selection-bar { flex-wrap: wrap; gap: 10px; }
#results-view .requests-surface { overflow: visible; }
#results-view .history-live { font-size: 12px; color: var(--text-secondary); white-space: nowrap; }

/* Header: hide normal connection status, style account avatar, quota pill, and help button */
.connection[hidden] {
  display: none !important;
}

.connection.offline {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-page);
  border: 1px solid var(--danger);
  color: var(--danger);
  font-weight: 600;
  font-size: 12px;
  padding: 5px 10px;
  border-radius: var(--radius-md);
}

.account-quota {
  display: inline-flex;
  align-items: center;
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  background: var(--bg-page);
  border: 1px solid var(--border-strong);
  color: var(--text-primary);
  font-weight: 600;
  white-space: nowrap;
}

.account-quota.is-pro {
  background: var(--brand-primary);
  border-color: var(--brand-primary);
  color: var(--fg-inverse);
}


.account-avatar {
  display: inline-grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--brand-forest);
  color: var(--fg-inverse);
  font-size: 12px;
  font-weight: 600;
}
img.account-avatar-photo { display: block; object-fit: cover; background: var(--bg-muted); }

.help-pill-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  width: auto !important;
  min-width: 36px;
  height: 36px;
  padding: 0 11px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--bg-subtle);
  color: var(--text-primary);
  font-size: 12.5px;
  font-weight: 500;
}

.help-pill-btn:hover {
  background: var(--bg-page);
  border-color: var(--border-strong);
}

.help-icon-symbol {
  display: inline-grid;
  place-items: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--bg-muted);
  color: var(--text-primary);
  font-size: 11.5px;
  font-weight: 600;
}

/* Result Cards: high-contrast download button, size comparison badge, larger thumbnail */
body .job .job-symbol {
  width: 48px;
  height: 48px;
  min-width: 48px;
  border-radius: var(--radius-md);
}

body .job .job-title {
  font-weight: 600;
  color: var(--text-primary);
  text-align: left;
}

body .job .job-subtitle {
  font-size: 12.5px;
  color: var(--text-primary);
}

body .job-status {
  display: flex;
  align-items: center;

  gap: 8px;
  font-size: 12.5px;
  flex-wrap: wrap;
}

.job-size-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  background: var(--bg-page);
  border: 1px solid var(--border-default);
  color: var(--text-primary);
}

.job-size-badge.savings {
  background: var(--brand-tint);
  border-color: var(--brand-accent);
  color: var(--brand-tint-fg);
}

body .job .download,
body .job .download.primary-download {
  background: var(--brand-forest);
  border: 1px solid var(--brand-forest);
  color: var(--fg-inverse);
  font-weight: 600;
  font-size: 13px;
  padding: 8px 14px;
  min-height: 38px;
  border-radius: var(--radius-md);
  white-space: nowrap;
  box-shadow: var(--shadow-card);
}

body .job .download:hover:not(:disabled),
body .job .download.primary-download:hover:not(:disabled) {
  background: var(--brand-forest-hover);
  border-color: var(--brand-forest-hover);
  color: var(--fg-inverse);
}

body .job .job-dismiss {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-primary);
  background: var(--bg-subtle);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  padding: 6px 10px;
  min-height: 34px;
  white-space: nowrap;
}

.job .job-dismiss:hover:not(:disabled) {
  background: var(--bg-muted);
  border-color: var(--brand-accent);
  color: var(--text-primary);
}

/* Before / After toggle bar in preview dialog */
.compare-toggle-bar {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 8px 0 12px;
  padding: 4px;
  border-radius: var(--radius-md);
  background: var(--bg-page);
  border: 1px solid var(--border-default);
}

.compare-toggle-bar button {
  min-height: 32px;
  padding: 5px 12px;
  font-size: 12.5px;
  font-weight: 500;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-primary);
}

.compare-toggle-bar button.active,
.compare-toggle-bar button[aria-pressed="true"] {
  background: var(--brand-forest);
  color: var(--fg-inverse);
}

/* WCAG AA Contrast & Minimum 12.5px-13px Typography for small/muted text */
body .muted,
body #limit,
body .operation-hint,
body .mode-help,
body .storage-policy {
  font-size: 13px;
  color: var(--text-primary);
}

/* Keyboard accessibility: visible focus ring on all interactive elements */
button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
summary:focus-visible {
  outline: 2.5px solid var(--brand-forest);
  outline-offset: 2px;
}

#ai-prompt:focus-visible {
  outline: none;
}

/* Mobile Sticky Results Bar */
.mobile-results-bar {
  display: none;
}

@media (max-width: 900px) {
  .mobile-results-bar:not([hidden]) {
    position: fixed;
    bottom: max(14px, env(safe-area-inset-bottom));
    right: 16px;
    z-index: 28;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    border-radius: 999px;
    background: var(--brand-forest);
    border: 1px solid var(--brand-primary);
    color: var(--fg-inverse);
    font-size: 13px;
    font-weight: 600;
    box-shadow: var(--shadow-card);
  }

  .mobile-results-bar .counter {
    background: var(--bg-surface);
    color: var(--brand-tint-fg);
  }
}

@media (max-width: 550px) {
  .composer-shortcut-hint {
    display: none;
  }

  .help-pill-btn {
    padding: 0 8px;
  }
}
/* Workspace conversation and result cards: readable at sidebar widths. */
body .tab { align-items: center; }
body .mode-copy { display: flex; flex-direction: column; justify-content: center; gap: 6px; min-width: 0; }
body .mode-copy small { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
body .account-quota { text-decoration: none; font-size: 12px; line-height: 1.5; }
#ai-reset { min-height: 38px; padding: 8px 12px; font-size: 13px; color: var(--text-primary); }
body #ai-messages { display: flex; flex-direction: column; gap: 12px; height: auto;  overflow: visible; max-height: clamp(13rem, 54dvh, 36rem); overflow-y: auto; overflow-x: hidden; padding: 10px 8px 14px 2px; scrollbar-gutter: stable; overscroll-behavior-y: contain; scroll-padding-block: 10px;  }
body #ai-messages .ai-message { flex: none; margin: 0; min-width: 0; max-width: 100%; width: fit-content; line-height: 1.65; font-size: 14px; }
#ai-messages .ai-message.user { align-self: flex-end; background: var(--bg-muted); max-width: 85%; padding: 10px 14px; }
#ai-messages .ai-message.assistant { align-self: flex-start; background: var(--bg-surface); border: 1px solid var(--border-default); position: relative; padding-left: 35px; }
#ai-messages .ai-message.has-card { width: 100%; }
body #ai-messages .message-head:empty { display: none; }
body #ai-messages .message-head { margin-bottom: 5px; }
#ai-messages .assistant-icon { color: var(--text-secondary); }
body .copy-msg-btn { opacity: 0; transition: opacity .15s; }
.ai-message:hover .copy-msg-btn, .ai-message:focus-within .copy-msg-btn { opacity: 1; }
body .chat-quick-replies { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
body .chat-quick-replies button { min-height: 40px; font-size: 13px; }
body.ai-mode .workspace-card, body.ai-mode .action-section, body.ai-mode #job-form, body.ai-mode #operation-fields { overflow: visible; }
body.ai-mode #submit-row, body.ai-mode #ai-context { display: none; }
body .composer-tool-btn { color: var(--text-primary); }
body .composer-shortcut-hint, body .draft-badge, body .results-heading .eyebrow, body #results-summary { color: var(--text-secondary); font-size: 12px; }
body #history .result-filters { flex-wrap: nowrap; gap: 3px; overflow-x: auto; }
body #history .result-filters button { flex: 0 0 auto; font-size: 11px; padding: 7px 8px; white-space: nowrap; }
body #history[data-single=true] .result-filters, body #history[data-single=true] .history-disclosure, body #history[data-single=true] .panel-bulk-actions { display: none; }
body #history .recent-download {
  width: 100%; min-height: 40px; margin: 8px 0 4px;
  background: var(--bg-muted); border-color: var(--border-strong); color: var(--text-primary); font-weight: 500;
}
#history .recent-download:hover:not(:disabled) { background: var(--brand-tint); border-color: var(--border-strong); }
body #history .job, body .chat-result-card { min-width: 0; overflow: visible; }
body #history .job-top, body .chat-result-card .job-top { display: grid; grid-template-columns: 42px minmax(0,1fr); align-items: center; gap: 10px; }
body #history .job-copy, body .chat-result-card .job-copy { min-width: 0; }
body #history .job-title, body .chat-result-card .job-title { display: block; min-width: 0; max-width: 100%; white-space: normal; word-break: normal; overflow-wrap: break-word; line-height: 1.5; }
body #history .job-copy small, body .chat-result-card .job-copy small { white-space: normal; word-break: normal; overflow-wrap: normal; color: var(--text-secondary); line-height: 1.6; font-size: 12px; }
body #history .job-actions, body .chat-result-card .job-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 7px; width: 100%; min-width: 0; }
body #history .job-actions > .primary-download, body .chat-result-card .job-actions > .primary-download { flex: 1 1 120px; width: auto; min-width: 0; white-space: nowrap; min-height: 40px; overflow: visible; text-overflow: clip; }
body #history .job-actions > .job-preview, body .chat-result-card .job-actions > .job-preview { flex: 0 0 40px; width: 40px; min-width: 0; min-height: 40px; padding: 8px; }
body .job-more { position: relative; flex: 0 0 40px; margin: 0; padding: 0; border: 0; }
body .job-more > summary { display: grid; place-items: center; width: 40px; min-height: 40px; cursor: pointer; list-style: none; padding: 8px; }
body .job-more > summary::-webkit-details-marker { display: none; }
body .job-more-items { position: absolute; right: 0; top: calc(100% + 5px); z-index: 20; display: grid; width: min(240px,70vw); padding: 5px; background: var(--bg-surface); border: 1px solid var(--border-default); border-radius: var(--radius-md); box-shadow: var(--shadow-card); }
body .job-more-items button { font-size: 12px; text-align: left; padding: 10px; min-height: 40px; }
body .job-retention { margin: 6px 0 10px; font-size: 12px;  line-height: 1.5; color: var(--text-primary); display: flex; align-items: center; gap: 6px; padding: 0; background: none; border: 0; }
body .job-retention.expiring { color: var(--warning); font-weight: 600; }
body .job-retention.expired { color: var(--danger); }
body .job-size-badge { white-space: normal; font-size: 12px; }
#history { overflow: visible; }
@media(max-width:550px) {
 .ai-composer-sticky { bottom: env(safe-area-inset-bottom,0px); }
 body #history .job-actions > .primary-download, body .chat-result-card .job-actions > .primary-download { min-height: 44px; }
 body .copy-msg-btn { opacity: 1; }
 body .account-quota { max-width: 160px; font-size: 10px; }
}
body .topbar #nav-count { display: none; }
#history[data-single=true] #results-summary { display: none; }
#history #jobs .job.completed .job-status.completed::before,
#ai-messages .chat-result-card.completed .job-status.completed::before { content: none; }

/* UX pass: locked step 2, single format picker, quieter history, readable disabled/small text */
.awaiting-files { pointer-events: none; user-select: none; }
body .action-gate:not([hidden]) { color: var(--text-primary); font-size: 14px; font-weight: 500; background: var(--bg-page); border-color: var(--brand-accent); }
.results-panel .results-heading { margin-top: 0; }
body .job .download, body .job .primary-download { font-weight: 600; }
body .primary:disabled, body .submit-wrap > button:disabled { background: var(--bg-muted); border-color: var(--border-strong); color: var(--text-primary); }
body .muted,
body #limit,
body .operation-hint,
body .mode-help,
body .mode-copy small,
body #drop-description { color: var(--text-primary); font-size: 13px; }

/* Tabs read as a segmented control, not as call-to-action buttons */
body .tabs { background: var(--bg-muted); border: 1px solid var(--border-default); border-radius: var(--radius-lg); padding: 4px; gap: 2px; }
body .tab { background: transparent; border-color: transparent; box-shadow: none; color: var(--text-primary); }

/* Status text must not look like a button */
.job-retention:not(.expiring):not(.expired)::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--brand-accent); flex: none; }

/* Dropzone breathing room, composer legibility */
.composer-send-btn.ready:not(:disabled) { background: var(--brand-forest); color: var(--fg-inverse); }

/* Single canonical header for every page (overrides per-page style.css/workspace.css/simple.css values) */
.topbar .brand { font-size: 26px; letter-spacing: -1px; }
body .topbar nav { display: flex; align-items: center; gap: 4px; font-size: 14px; }

/* History rows: fixed actions column, text never pushes buttons around */
#results-view .request-row-copy, #results-view .request-row-line1, #results-view .request-row-line2, #results-view .request-title { min-width: 0; }

#results-view .request-job:first-of-type { border-top: 0; }
@media (max-width: 850px) { #results-view .request-entry { grid-template-columns: 20px minmax(0,1fr); } #results-view .request-row-actions { width: auto; } }

/* Smart suggestion caption */
.quick-caption { margin: 0 0 8px; font-size: 12.5px; font-weight: 500; color: var(--text-primary); }

/* ===== Visual polish pass ===== */

/* One content width on every route, aligned with the header */
main.shell, body.results-route main.shell { max-width: var(--site-width) !important; margin-inline: auto; min-height: calc(100vh - 68px); }
#results-view, #requests-view { max-width: none; margin-inline: 0; }

/* Step badges: active step is dark, finished step shows a check, locked step is muted */
body .files-section:not(.step-complete) .step { background: var(--brand-primary); color: var(--fg-inverse); }
body .files-section.step-complete .step { background: var(--brand-tint); color: var(--text-primary); font-size: 0; display: inline-grid; place-items: center; }
.files-section.step-complete .step::after { content: "✓"; font-size: 13px; }
body .action-section.step-locked .step { background: var(--bg-muted); color: var(--text-secondary); }
body .step { transition: background-color .2s var(--ease), color .2s var(--ease); }

/* Locked step 2: calmer, no leftover clutter */
body .action-section.step-locked .template-actions, body .action-section.step-locked .operation-hint { display: none; }
body .action-section.step-locked .quick-actions button {  border-color: var(--border-default);  }

/* Chips */
body .quick-actions button { border-radius: var(--radius-md); transition: background-color .15s var(--ease), border-color .15s var(--ease), transform .1s var(--ease), box-shadow .15s var(--ease); }
body .quick-actions button:active:not(:disabled), body .primary:active:not(:disabled) { transform: translateY(1px); }

/* Dropzone feedback */
body .dropzone { transition: border-color .2s var(--ease), background-color .2s var(--ease), box-shadow .2s var(--ease); }
body .dropzone:hover:not(:has(input:disabled)), body .dropzone.dragover, body .dropzone.dragging { border-color: var(--brand-accent); background: var(--bg-page); box-shadow: var(--shadow-card); }

/* Cards and panels */
.workspace-card { box-shadow: var(--shadow-card); }

/* Submit row: a clear, calm call to action */
body .submit-row { border-top: 1px solid var(--border-default); padding-top: 16px; }
body .submit-row strong { font-size: 14px; color: var(--text-primary); }
body .submit-row span { font-size: 12.5px; color: var(--text-secondary); }
body #submit:not(:disabled) { box-shadow: var(--shadow-card); }

/* Sidebar cards */
body #history .job { border-radius: var(--radius-lg); border: 1px solid var(--border-default); background: var(--bg-surface); box-shadow: var(--shadow-card); transition: box-shadow .15s var(--ease), border-color .15s var(--ease); }
body #history .job:hover { border-color: var(--border-strong); box-shadow: var(--shadow-card); }

/* Page headings + toolbars on History */
#results-view h1 { letter-spacing: -.8px; }
#results-view .request-entry, #results-view .library-row { transition: background-color .15s var(--ease); }
.result-library, .requests-surface { box-shadow: var(--shadow-card); }

/* Smooth page entrance, respects reduced motion */
@media (prefers-reduced-motion: no-preference) {
  main.shell > * { animation: pipeid-rise .35s var(--ease) both; }
  @keyframes pipeid-rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
}
main.shell { display: flex; flex-direction: column; }
body main.shell > .storage-policy { margin-top: 24px; margin-bottom: 36px; }

/* Mobile: compact header, one-row scrolling nav, tabs that fit */
@media (max-width: 550px) {
  body .topbar { padding: 8px 14px; gap: 6px 10px; }
  .topbar .brand { font-size: 22px; }
  body .topbar nav { grid-column: 1 / -1; order: 3; flex-wrap: wrap; gap: 2px; overflow: visible; margin: 0; padding: 0; }
  body .topbar nav a { padding: 7px 8px; font-size: 13px; }
  body .topbar .account-quota { display: none; }
  body .tab { flex-direction: column; gap: 2px; padding: 8px 4px; text-align: center; }
  body .tab .mode-icon { display: none; }
  body .tab .mode-copy { align-items: center; }
  body .tab .mode-copy b { font-size: 13px; white-space: nowrap; }
}

/* Conversation and recent results */
body.ai-conversation #workspace-intro,
body.ai-conversation #mode-help,
body.ai-conversation .action-section > .section-heading,
body.ai-conversation .mode-copy small { display: none; }
body.ai-mode:not(.has-ai-files) .action-section .step { background: var(--bg-muted); color: var(--text-secondary); }
body.ai-mode.has-ai-files .action-section .step { background: var(--brand-primary); color: var(--fg-inverse); }
body.ai-conversation #workspace-grid { padding-top: 18px; }
body.ai-conversation .action-section { border-top: 0; padding-top: 16px; }
body.ai-conversation .tabs { margin-bottom: 12px; }
body.ai-conversation .tab { min-height: 36px; padding-block: 6px; }
body.ai-conversation .ai-heading { justify-content: flex-end; margin-bottom: 6px; }
body.ai-conversation #ai-reset { min-height: 34px; }
body #ai-messages:empty { display: none; }
body .ai-composer-sticky { position: static; padding: 6px 0 10px; }
body .chat-follow { position: static; margin: 4px 0 6px auto; min-height: 36px; }
#ai-messages .ai-message.assistant .assistant-icon { position: absolute; left: 13px; top: 12px; }
body #ai-messages .message-head { justify-content: flex-end; margin: 0; min-height: 0; }
#ai-messages .message-head:has(.copy-msg-btn) { margin-bottom: 3px; }
body .composer-files { padding-bottom: 5px; margin-bottom: 4px; }
body .chat-plan-card { padding: 0; margin-top: 6px; border: 0; box-shadow: none; background: transparent; }
.chat-plan-batch > summary { cursor: pointer; font-weight: 600; }
.chat-plan-batch[open] > summary { margin-bottom: 8px; }
.chat-plan-note { margin: 10px 0 0; color: var(--text-secondary); font-size: 12px; }
.chat-plan-note + .chat-plan-actions { margin-top: 6px; }
.chat-results-summary { margin: 0; color: var(--text-primary); font-size: 14px; line-height: 1.4; }
.chat-results-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chat-results-actions > button { width: auto; min-height: 38px; padding: 6px 11px; font-size: 12px; white-space: normal; }
body .chat-result-list { gap: 5px; margin-top: 8px; }
.chat-results > .job-retention { margin: 8px 0 0; }
body #history .jobs { gap: 5px; grid-template-columns: minmax(0,1fr); overflow: visible; max-height: none; }
.recent-group-label { margin: 6px 0 0; color: var(--text-secondary); font-size: 12px; }
.jobs-preview-note a { text-decoration: underline; }
body #history .job.compact, body .chat-result-card.job {
  display: grid; grid-template-columns: minmax(0,1fr) auto; align-items: center;
  gap: 2px 6px; margin: 0; padding: 7px 8px;
  background: var(--bg-subtle); border: 1px solid var(--border-default); border-radius: var(--radius-md); box-shadow: none;
}
:is(#history .job.compact, .chat-result-card) .job-top {
  grid-column: 1; grid-row: 1; grid-template-columns: 30px minmax(0,1fr); gap: 7px;
}
:is(#history .job.compact, .chat-result-card) .job-symbol { width: 30px; height: 30px; min-width: 0; }
:is(#history .job.compact, .chat-result-card) .file-format { display: none; }
:is(#history .job.compact, .chat-result-card) .job-title {
  display: block; width: 100%; text-align: left; font-size: 13px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
#history .job.compact :is(.job-subtitle, .job-retention, .pipeline) { display: none; }
:is(#history .job.compact, .chat-result-card) .job-status {
  grid-column: 1 / -1; grid-row: 2; margin: 0; padding: 0 0 0 37px;
  min-height: 0; font-size: 11px; border: 0; background: none;
}
:is(#history .job.compact, .chat-result-card) .job-size-badge {
  padding: 0; border: 0; background: none; font-size: 11px; color: var(--text-secondary);
}
body #history .job.compact { grid-template-columns: minmax(0,1fr); gap: 4px; }
#history .job.completed > .job-top { grid-template-columns: auto minmax(0,1fr) auto; }
#history .job.completed > .job-top .job-more > summary { width: 34px; min-height: 34px; padding: 0; }
#history .job.compact .job-actions { margin: 3px 0 0; gap: 6px; }
#history .job.compact .job-actions > :is(.download,.job-hide) { min-height: 40px; padding: 6px 10px; }
body .chat-result-card .job-actions {
  grid-column: 2; grid-row: 1; width: auto; margin: 0; gap: 3px; flex-wrap: nowrap;
}
body .chat-result-card .job-actions :is(.download,.job-preview,.job-more,.job-more > summary) {
  width: 36px; min-width: 36px; min-height: 36px; flex: 0 0 36px; padding: 0;
}
body .chat-result-card .job-actions .download { font-size: 0; }
body .chat-result-card .job-actions .download::before { content: "↓"; font-size: 17px; }
.chat-result-card .job-actions .download[aria-busy=true]::before { content: "…"; }
body .chat-result-card .pipeline { grid-column: 1 / -1; }
@media (max-width: 550px) {
  body.ai-conversation #workspace-grid { padding-top: 10px; }
  body #ai-messages { max-height: clamp(12rem, 46dvh, 28rem); padding-right: 4px; }
  #ai-messages .ai-message.assistant { padding-left: 25px; }
  #ai-messages .ai-message.assistant .assistant-icon { left: 8px; }
  .composer-toolbar, .composer-tools-left, .composer-tools-right { gap: 5px; }
  #composer-attach { padding-inline: 7px; }
  #save-template { min-width: 38px; justify-content: center; padding: 4px; }
  #save-template > span:last-child, #draft-status { display: none; }
  #composer-attach, #save-template, #ai-send-btn { min-height: 38px; }
  body .chat-result-card.job { gap: 1px 3px; padding: 5px; }
  body .chat-result-card .job-actions :is(.download,.job-preview,.job-more,.job-more > summary) {
    width: 32px; min-width: 32px; min-height: 38px; flex-basis: 32px;
  }
}

/* ── Design pass: consistency & comfort ─────────────────────────── */
/* Title dot must stay on the heading line (mobile rule makes h1 spans block). */
h1 .title-dot { display: inline !important; }

/* Ctrl+V hint is useless on touch screens. */
@media (hover: none) and (pointer: coarse) {
  body .paste-shortcut { display: none !important; }
}
@media (max-width: 550px) {
  .dropzone .drop-actions { justify-content: center; }
}

/* Retention banner: calm inline icon instead of an emoji. */
body .disk-banner-icon { display: grid; place-items: center; width: 30px; height: 30px; border-radius: var(--radius-md); background: var(--bg-muted); color: var(--brand-tint-fg); }

/* History: chevron reads as a control, not a stray glyph. */
body #results-view .request-chevron {
  width: 28px; height: 28px; line-height: 26px; border-radius: 50%;
  border: 1px solid var(--border-default); background: var(--bg-surface); font-size: 13px; align-self: center;
  transition: transform .2s var(--ease), background-color .15s var(--ease), border-color .15s var(--ease);
}
#results-view .request-row-summary:hover .request-chevron { background: var(--bg-page); border-color: var(--border-strong); }

/* History toolbar on phones: compact, left-aligned, no dead space. */
@media (max-width: 550px) {
  body #results-view .request-toolbar-unified { padding: 12px 14px; gap: 8px; flex-direction: row; flex-wrap: wrap; align-items: center; justify-content: flex-start; }
  #results-view .request-toolbar-unified .library-search { flex: 1 1 100%; }
  body #results-view .request-filters { flex: 1 1 auto; justify-content: flex-start; flex-wrap: wrap; gap: 6px; }
  body #results-view .request-toolbar-actions { margin-left: auto; }
  body #results-view .results-intro { gap: 14px; padding: 20px 0 16px; }
  body #results-view .request-chevron { width: 24px; height: 24px; line-height: 22px; }
}

/* ── Desktop pass ───────────────────────────────────────────────── */
/* Zero counters are noise. */
body .counter.is-zero { display: none; }

/* Consistent account pill on every page (API page has no account.css). */
body .topbar .account-pill { border: 1px solid var(--border-strong); font-size: 13px; white-space: nowrap; }

/* Section headings: badge and title share one centre line, whatever the badge shows. */
body .section-heading h2 .step { flex: none; }
@media (max-width: 550px) { body.ai-mode #limit { margin-left: 0; } }

/* Workspace hero: room to breathe between header, title and card. */
@media (min-width: 900px) {
  #workspace-intro { padding: 30px 0 22px; }
  #workspace-intro p { margin-top: 6px; }
}

/* Dropzone: title on one line, paste hint as quiet secondary text under the button. */
@media (min-width: 900px) {
  body .dropzone:not(.has-files) { padding: 22px 22px; gap: 18px; }
  body .dropzone:not(.has-files) .drop-actions { display: flex; flex-direction: column; align-items: center; gap: 6px; }
  body .dropzone:not(.has-files) .paste-shortcut { background: transparent; border: 0; box-shadow: none; padding: 0; font-size: 12px; color: var(--text-secondary); }
  body .dropzone:not(.has-files) .paste-shortcut kbd { font-size: 10.5px; padding: 1px 5px; }
  body .dropzone .upload-icon { width: 44px; height: 44px; border-radius: var(--radius-lg); font-size: 22px; color: var(--brand-tint-fg); }
}

/* Locked quick formats: readable preview, clearly not yet active. */
body .action-section.step-locked .quick-actions button { color: var(--text-secondary); background: var(--bg-subtle); border-style: dashed; cursor: default; }

/* Disclosures: crisp chevron instead of a rotated glyph; solid quiet border. */
:is(.workspace-disclosure, .category-disclosure, .save-disclosure, .optional-settings, .history-disclosure, .presets-disclosure) > summary { cursor: pointer; }
:is(.workspace-disclosure, .category-disclosure, .save-disclosure, .optional-settings, .history-disclosure, .presets-disclosure) > summary::after {
  content: ""; display: block; flex: none; width: 7px; height: 7px; margin: 0 5px 3px 0;
  border-right: 1.8px solid var(--border-strong); border-bottom: 1.8px solid var(--border-strong); border-radius: 1px;
  transform: rotate(-45deg); transition: transform .16s ease;
}
details[open]:is(.workspace-disclosure, .category-disclosure, .save-disclosure, .optional-settings, .history-disclosure, .presets-disclosure) > summary::after { transform: rotate(45deg); margin-bottom: 4px; }
:is(.workspace-disclosure, .category-disclosure, .save-disclosure, .optional-settings, .history-disclosure, .presets-disclosure) > summary:hover { color: var(--text-primary); }

/* AI mode: the card keeps its bottom padding so the last block is not glued to the edge. */
body.ai-mode .action-section { padding-bottom: 22px; }
body.ai-mode .mode-help + * { margin-top: 0; }

/* Results sidebar: compact empty state, no dead area. */
body .results-panel .empty { padding: 26px 8px 22px; }
body .results-panel .empty p { max-width: 260px; color: var(--text-secondary); font-size: 13px; }

/* Help dialog: keys in an aligned column. */
body .shortcuts-list li { display: grid; grid-template-columns: 116px 1fr; align-items: center; gap: 12px; justify-items: start; }
body .shortcuts-list li > span { color: var(--text-primary); }
body .shortcuts-list .keys { display: inline-flex; align-items: center; gap: 4px; color: var(--text-secondary); }

/* Page headers on History. */
@media (min-width: 900px) {
  body #results-view .results-intro { padding: 32px 0 20px; }
  body #results-view .results-intro h1 { font-size: 36px; margin: 0 0 6px; line-height: 1.15; }
  body #results-view .results-intro p { font-size: 14px; }
}

/* History toolbar: filters sit next to search, options at the far right. */
@media (min-width: 851px) {
  body #results-view .request-toolbar-unified { justify-content: flex-start; gap: 12px 14px; }
  #results-view .request-toolbar-unified .library-search { flex: 0 1 440px; }
  body #results-view .request-filters { margin-right: auto; }
}
#results-view .requests-surface:has(.library-empty) .history-meta-row { display: none; }
body #results-view .library-empty p { color: var(--text-secondary); }

/* Login: card fits its form, badge does not touch the title. */
body .auth-layout { align-items: center; }
body .account-card > .account-badge + h2 { margin-top: 14px; }

/* Unified full-bleed footer across Workspace, History, Templates, Account, Pricing, Auth and API. */
body { overflow-x: clip; }
body footer.site-footer {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px 20px;
  margin-top: auto;
  padding: 20px 0 24px;
  border-top: 0;
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-muted);
}
body footer.site-footer::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 100vw;
  transform: translateX(-50%);
  background: var(--bg-page);
  border-top: 1px solid var(--border-default);
  z-index: -1;
  pointer-events: none;
}
body footer.site-footer .site-footer-brand {
  color: var(--text-secondary);
  font-weight: 500;
  max-width: none;
}
body footer.site-footer .footer-divider {
  color: var(--text-muted);
  margin: 0 7px;
}

/* API docs: show where you are. */
body .api-sidebar nav a { padding: 7px 10px; margin-left: -10px; border-radius: var(--radius-md); transition: background-color .15s, color .15s; }
body .api-sidebar nav a:hover { text-decoration: none; background: var(--bg-page); color: var(--text-primary); }
body .api-sidebar nav a[aria-current] { background: var(--bg-muted); color: var(--text-primary); font-weight: 500; }
/* Formats before files are added: a readable preview, not a ghost. */
body .awaiting-files { opacity: .78; filter: none; }
/* Empty results sidebar: readable copy. */
body .results-panel .empty strong { color: var(--text-primary); }

/* Keep the layout from shifting when page height changes between modes. */
html { scrollbar-gutter: stable; }

/* Account pill and quota stay hidden until the real account state is known. */
.header-actions:not(.account-ready) #account-quota, .header-actions:not(.account-ready) #media-account-link, .header-actions:not(.account-ready) #account-link { visibility: hidden; }

/* The header appears once its text is translated; the animation is a fallback if scripts fail. */
/* Whole page, not just the header: otherwise the untranslated Russian text flashes before the English one replaces it. */
html:not(.pipeid-translated) body { visibility: hidden; animation: pipeid-header-fallback 0s 1.5s forwards; }
@keyframes pipeid-header-fallback { to { visibility: visible; } }

/* Expanded request: separate blocks for the prompt, the reply, the plan and the files. */
#results-view .request-block { display: grid; gap: 8px; min-width: 0; }
#results-view .request-expanded .request-overline {
  display: flex; align-items: center; gap: 8px; margin: 0;
    letter-spacing: 1.1px; text-transform: uppercase;
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 11px;
}
#results-view .request-bubble {
  max-width: 680px; padding: 12px 16px; border-radius: 4px var(--radius-lg) var(--radius-lg) var(--radius-lg);
  background: var(--bg-page); border: 1px solid var(--border-default); color: var(--text-primary);
  font-size: 14px; line-height: 1.6; white-space: pre-wrap; overflow-wrap: anywhere;
}
#results-view .request-block.user + .request-block.user .request-bubble { background: var(--bg-subtle); }
#results-view .request-reply { display: grid; gap: 10px; max-width: 720px; color: var(--text-primary); font-size: 14px; line-height: 1.65; }
#results-view .request-reply p { margin: 0; }
#results-view .request-list-items { margin: 0; padding-left: 0; list-style: none; display: grid; gap: 8px; counter-reset: request-item; }
#results-view .request-list-items li {
  position: relative; padding: 9px 12px 9px 40px; border-radius: var(--radius-md);
  background: var(--bg-subtle); border: 1px solid var(--border-default);
}
#results-view ol.request-list-items li { counter-increment: request-item; }
#results-view ol.request-list-items li::before {
  content: counter(request-item); position: absolute; left: 11px; top: 9px;
  display: grid; place-items: center; width: 20px; height: 20px; border-radius: 50%;
  background: var(--brand-primary); color: var(--fg-inverse); font-size: 11px; font-weight: 600; line-height: 1;
}
#results-view ul.request-list-items li::before {
  content: ''; position: absolute; left: 17px; top: 18px; width: 7px; height: 7px; border-radius: 50%; background: var(--brand-accent);
}
#results-view .request-plan {
  display: grid; gap: 6px; padding: 12px 16px; border-radius: var(--radius-lg);
  background: var(--bg-subtle); border: 1px solid var(--border-default); border-left: 3px solid var(--brand-accent);
}
#results-view .request-plan p { margin: 0; line-height: 1.9; }
#results-view .request-format {
  display: inline-block; padding: 0 6px; border-radius: var(--radius-sm); background: var(--bg-surface); border: 1px solid var(--border-default);
  font-size: 11.5px; font-weight: 600; letter-spacing: .3px; color: var(--text-primary); line-height: 1.6;
}
#results-view .request-arrow { color: var(--brand-accent); font-weight: 600; }
#results-view .request-turn-status {
  display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px; border-radius: var(--radius-sm);
  background: var(--warning-tint); border: 1px solid var(--warning-border); color: var(--warning); font-size: 10px; letter-spacing: .4px;
}
#results-view .request-turn-status::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: var(--warning); }
#results-view .request-file-chips { display: flex; flex-wrap: wrap; gap: 8px; }
#results-view .request-file-chip {
  display: inline-flex; align-items: center; gap: 8px; max-width: 280px; min-width: 0;
  padding: 5px 12px 5px 5px; border-radius: var(--radius-sm); background: var(--bg-surface); border: 1px solid var(--border-default);
  font-size: 12.5px; color: var(--text-primary);
}
#results-view .request-file-chip .request-chip-icon { width: 26px; height: 26px; flex: 0 0 26px; border-radius: 50%; overflow: hidden; }
#results-view .request-chip-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#results-view .request-expanded > .request-overline { margin-bottom: -10px; }
@media (max-width: 640px) {
  #results-view .request-file-chip { max-width: 100%; }
  #results-view .request-bubble { border-radius: 4px var(--radius-lg) var(--radius-lg) var(--radius-lg); }
}

/* ---- UX audit pass: hierarchy, tab state, contrast, consent tooltip, empty sidebar ---- */

/* 1. Primary call to action: the strongest element of step 1. */
body .dropzone .choose-button {
  min-height: 44px;
  padding: 11px 24px;
  font-size: 15px;
  font-weight: 500;
  letter-spacing: .1px;
  background: var(--brand-primary);
  border-color: var(--brand-accent);
  color: var(--fg-inverse);
  box-shadow: var(--shadow-card);
}
body .dropzone:hover .choose-button,
body .dropzone:focus-within .choose-button {
  background: var(--brand-primary);
  border-color: var(--brand-primary);
  color: var(--fg-inverse);
  box-shadow: var(--shadow-card);
}
body .dropzone.has-files .choose-button {
  min-height: 36px;
  padding: 7px 14px;
  font-size: 13px;
  font-weight: 500;
  background: var(--bg-surface);
  border-color: var(--border-strong);
  color: var(--text-primary);
  box-shadow: none;
}
body .dropzone.has-files:hover .choose-button,
body .dropzone.has-files:focus-within .choose-button {
  background: var(--bg-muted);
  border-color: var(--text-muted);
  color: var(--text-primary);
  box-shadow: none;
  transform: none;
}

/* 2. Mode tabs: the active one is filled with the brand colour, the others recede. */
body .tab:not(.selected):not([aria-pressed="true"]) { color: var(--text-secondary); }
body .tab:not(.selected):not([aria-pressed="true"]) .mode-copy small { color: var(--text-secondary); }
.tab:not(.selected):not([aria-pressed="true"]) .mode-icon { color: var(--text-muted); }
body .tab.selected,
body .tab[aria-pressed="true"] {
  background: var(--brand-forest);
  border-color: var(--brand-forest);
  color: var(--fg-inverse);
  box-shadow: var(--shadow-card);
}
body .tab.selected .mode-icon,
body .tab[aria-pressed="true"] .mode-icon { color: var(--fg-inverse); }
/* Keep the active tab filled on hover/focus so its white text stays readable. */
body .tab.selected:hover:not(:disabled),
body .tab[aria-pressed="true"]:hover:not(:disabled),
body .tab.selected:focus-visible,
body .tab[aria-pressed="true"]:focus-visible {
  background: var(--brand-forest);
  border-color: var(--brand-forest);
  color: var(--fg-inverse);
}

/* 3. Secondary text: at least 12.5px and AA contrast. */
body .drop-copy span,
body .drop-copy #drop-description,
body .paste-shortcut,
body .section-heading .muted,
body #limit,
body .mode-help,
body #action-gate,
body .results-panel #results-summary,
body .composer-shortcut-hint,
body .prompt-counter,
body .draft-badge { color: var(--text-primary); font-size: 13px; }

/* 5. Send button: right arrow, tinted until there is something to send. */

/* 6. Results sidebar, empty state: a short guide and popular prompts instead of a blank column. */

/* 7. Retention note: a quiet notice banner instead of loose text. */
body main.shell > .storage-policy {
  display: flex;
  align-items: center;
  gap: 10px;
  width: fit-content;
  max-width: min(720px, 100%);
  margin: 24px auto 0;
  padding: 10px 16px;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  background: var(--bg-page);
  color: var(--text-primary);
  font-size: 13px;
  line-height: 1.5;
}
body main.shell > .storage-policy:empty { display: none; }
body main.shell > .storage-policy::before {
  content: "i";
  flex: none;
  display: inline-grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--brand-primary);
  color: var(--fg-inverse);
  font: italic 700 12px/1 Georgia, serif;
}

/* ---- History screen audit pass ---- */

/* Row layout: checkbox and actions stay on the header line when a row is expanded. */
#results-view .request-entry > .history-select { align-self: start; margin-top: 24px; }
#results-view .request-entry > .request-row-actions { align-self: start; min-height: 68px; }

/* Title is the request; the subtitle is the file (and operation), never a repeat of the prompt. */
#results-view .request-operation { color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
#results-view .request-operation::before { content: "·"; margin: 0 6px; }
#results-view .request-row-line2 { display: flex; align-items: baseline; min-width: 0; font-size: 12.5px; }

/* Status pills: standard icons and stronger semantic colours. */
#results-view .request-state { display: inline-flex; align-items: center; gap: 6px; }
#results-view .status-icon { display: inline-grid; place-items: center; width: 14px; height: 14px; flex: none; }
#results-view .status-icon svg { display: block; }
#results-view .status-icon-processing { border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; box-sizing: border-box; animation: request-spin .8s linear infinite; }
@keyframes request-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { #results-view .status-icon-processing { animation-duration: 2.4s; } }
#results-view .request-outcome.status-completed { background: var(--brand-tint); color: var(--brand-tint-fg); }
#results-view .request-outcome.status-processing { background: var(--bg-muted); color: var(--info); }
#results-view .request-outcome.status-waiting { background: var(--warning-tint); color: var(--warning); box-shadow: 0 0 0 1px var(--warning) inset; font-weight: 600; }
#results-view .request-outcome.status-error { background: var(--danger-tint); color: var(--danger); box-shadow: 0 0 0 1px var(--danger) inset; font-weight: 600; }
#results-view .request-entry.needs-attention.attention-waiting { background: var(--bg-subtle); box-shadow: inset 4px 0 0 var(--warning); }
#results-view .request-entry.needs-attention.attention-error { background: var(--bg-subtle); box-shadow: inset 4px 0 0 var(--danger); }
#results-view .request-entry.needs-attention:hover { filter: brightness(.985); }

/* Expanded labels: darker and bolder. */

/* Inline reply to the assistant. */
#results-view .request-reply-form { display: flex; align-items: flex-end; gap: 8px; max-width: 720px; padding: 8px 8px 8px 12px; border: 1.5px solid var(--brand-accent); border-radius: var(--radius-lg); background: var(--bg-surface); }
#results-view .request-reply-form:focus-within { border-color: var(--brand-primary); box-shadow: var(--shadow-card); }
#results-view .request-reply-input { flex: 1; min-width: 0; min-height: 44px; max-height: 160px; resize: vertical; border: 0; outline: 0; background: transparent; font: inherit; font-size: 14px; line-height: 1.5; color: var(--text-primary); box-shadow: none; padding: 4px 0; }
#results-view .request-reply-send { flex: none; display: grid; place-items: center; width: 36px; height: 36px; min-height: 36px; padding: 0; border-radius: var(--radius-md); border: 1px solid var(--border-strong); background: var(--bg-muted); color: var(--text-secondary); font-size: 20px; line-height: 1; cursor: not-allowed; }
#results-view .request-reply-send.ready { background: var(--brand-forest, var(--brand-primary)); border-color: var(--brand-forest, var(--brand-primary)); color: var(--fg-inverse); cursor: pointer; }
#results-view .request-reply-hint { margin: 0; font-size: 12px; color: var(--text-secondary); }

/* Full page loads (/api, /pricing, /login) cross-fade instead of flashing; the header stays put like in the single-page routes. */
@view-transition { navigation: auto; }
::view-transition-old(root), ::view-transition-new(root) { animation-duration: .12s; }
::view-transition-group(site-header) { animation-duration: 0s; }

.message-attachments { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 8px; }
.message-attachment {
  display: inline-block; max-width: min(100%, 300px); box-sizing: border-box; padding: 3px 10px; border-radius: var(--radius-md);
  background: color-mix(in srgb, var(--bg-surface) 70%, transparent); border: 1px solid var(--border-strong); font-size: 12px; font-weight: 500; line-height: 1.5; color: var(--text-primary);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: top;
}

/* Narrow phones: keep language, account, help and theme controls on one header row. */
@media (max-width: 420px) {
  body .topbar { gap: 8px; }
  .topbar .header-actions { flex-wrap: nowrap; gap: 6px; }
  body .topbar .header-actions > a,
  body .topbar .header-actions > button { padding-inline: 10px; }
  body .topbar .header-actions > .theme-toggle-header,
  body .topbar .header-actions > #help-open { width: 34px; min-width: 34px; padding-inline: 0; }
}

/* ---------- Phone: header and shared controls ---------- */
a.primary { justify-content: center; text-align: center; }
@media (max-width: 700px) {
  /* A two-row sticky header covers too much of a phone screen */
  body .topbar { position: static; }
  html { scroll-padding-top: 12px; }
  body .topbar nav { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin-inline: -4px; }
  body .topbar nav::-webkit-scrollbar { display: none; }
  body .topbar nav a { min-height: 40px; }
  body .topbar #help-open { display: none; }
  body footer.site-footer { flex-direction: column; align-items: flex-start; gap: 10px; padding: 18px 0 24px; }
}

/* Legal links in the footer (imprint and privacy notice must be reachable from every page). */
.legal-links { display: inline-flex; flex-wrap: wrap; gap: 6px 18px; align-items: center; }
.legal-links a { color: var(--text-secondary); font-size: 13px; font-weight: 400; text-decoration: none; text-underline-offset: 3px; transition: color .12s ease; }
.legal-links a:hover, .legal-links a:focus-visible { color: var(--text-primary); text-decoration: underline; }
.legal-note { margin-top: 10px; }
.legal-note a, .google-note a { color: inherit; text-underline-offset: 3px; }

/* Header controls sit at the very top of the page: their tooltips open downwards, not off-screen. */
.topbar [data-tooltip]::after {
  bottom: auto;
  top: calc(100% + 8px);
  transform: translateY(-4px);
}
.topbar [data-tooltip]:hover::after,
.topbar [data-tooltip]:focus-visible::after {
  transform: translateY(0);
}

/* Header pills. The page you are on is marked; the balance pill wears a ring that drains as credits
   run out: green, amber below 30%, red at 15% and less (--left is the share left, 0-100). */
@property --left { syntax: "<number>"; inherits: false; initial-value: 100; }
body .topbar .account-pill.is-current {
  background: var(--brand-tint);
  border-color: var(--brand-accent);
  color: var(--text-primary);
  box-shadow: var(--shadow-card);
}
.topbar .account-quota:not([data-level]):not(.is-pro) { background: var(--bg-surface); border-color: var(--border-default); }
.topbar .account-quota:not([data-level]).is-current { background: var(--brand-tint); border-color: var(--brand-accent); box-shadow: var(--shadow-card); }
body .topbar .account-quota[data-level] {
  --ring: var(--brand-accent); --track: var(--text-muted); --fill: var(--bg-surface); --left: 100;
  border: 2.5px solid transparent;
  color: var(--text-primary);
  background:
    linear-gradient(var(--fill), var(--fill)) padding-box,
    conic-gradient(from 0deg, var(--ring) calc(var(--left) * 1%), var(--track) 0) border-box;
  transition: --left .6s ease;
}
body .topbar .account-quota[data-level="warn"] { --ring: var(--warning); --fill: var(--bg-subtle); }
body .topbar .account-quota[data-level="low"] { --ring: var(--danger); --track: var(--danger); --fill: var(--bg-page); color: var(--danger); }
.topbar .account-quota[data-level].is-pro { --fill: var(--brand-primary); --track: rgba(255, 255, 255, .22); color: var(--fg-inverse); }
.topbar .account-quota[data-level].is-current { box-shadow: var(--shadow-card); }
body .topbar .account-quota[data-level="low"].is-current { box-shadow: var(--shadow-card); }
@media (prefers-reduced-motion: reduce) { body .topbar .account-quota[data-level] { transition: none; } }
