/* Workspace hierarchy and shared interaction rules. */
body .intro h1 { font-weight: 650; line-height: 1.2; letter-spacing: -.8px; }
body .intro p { line-height: 1.7; }
body .workspace-card, body .results-panel, body .result-library { min-width: 0; }
body .section-heading { flex-wrap: wrap; gap: 10px; }
body .section-heading h2 { font-weight: 600; }
body .step-complete .step, body .step-ready .step { background: #2d4a35; color: #fff; }
body .dropzone:not(.has-files) { min-height: 144px; }
body .drop-copy { min-width: 0; }
body .drop-copy strong { line-height: 1.5; }
body .dropzone:focus-within { outline: 3px solid #809c71; outline-offset: 4px; }
body .dropzone:has(input:disabled) { cursor: wait; opacity: .65; }
.mode-help { font-size: 13px; line-height: 1.65; color: #5b6d5d; margin: -4px 0 18px; }
body .tab .mode-copy small { display: block; margin-top: 4px; font-size: 11px; font-weight: 400; color: #61715f; }
body .workspace-disclosure { border: 1px solid #e2e9de; border-radius: 12px; padding: 0 14px; background: #fafcf8; }
body .workspace-disclosure > summary { font-weight: 600; }
body .workspace-disclosure .scenario-box { margin-bottom: 14px; }
body .scenario-actions button { min-height: 40px; padding: 9px 12px; }
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 #e9eee5; }
body .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; }
body input, body select, body textarea { accent-color: #385b42; }
body .request-prompt, 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 .topbar nav { min-width: 0; }
body .topbar nav a { flex-shrink: 0; white-space: nowrap; }
body .toast { bottom: max(22px, env(safe-area-inset-bottom)); max-width: calc(100vw - 28px); overflow-wrap: anywhere; }
body summary:focus-visible { outline: 3px solid #809c71; outline-offset: 3px; }
body dialog { overscroll-behavior: contain; }
@media (min-width: 951px) {
  body .results-panel { position: sticky; top: 88px; }
}
@media (max-width: 950px) {
  body .topbar nav { mask-image: none; -webkit-mask-image: none; scrollbar-width: thin; scrollbar-color: #cedbc4 transparent; }
  body .topbar nav::-webkit-scrollbar { display: block; height: 3px; }
  body .topbar nav::-webkit-scrollbar-thumb { background: #cedbc4; border-radius: 3px; }
}
@media (max-width: 550px) {
  body .topbar { position: static; }
  body .intro h1 { font-size: 28px; }
  body .intro p { font-size: 14px; }
  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) { min-height: 170px; text-align: center; justify-content: center; }
  body .dropzone .drop-copy { width: 100%; }
  body .dropzone .drop-copy > span { display: block; margin-top: 8px; }
  body .dropzone .choose-button { display: inline-flex; min-height: 44px; margin: 0 auto; }
  body .dropzone { flex-direction: column; align-items: stretch; }
  body .dropzone .drop-copy { flex: none; }
  body .dropzone .choose-button { align-self: center; flex: none; }
  body .tab { padding: 10px 5px; min-height: 48px; }
  body .tab .mode-copy small { display: none; }
  body .mode-help { font-size: 12px; margin-bottom: 14px; }
  body .workspace-disclosure { padding: 0 12px; }
  body .scenario-actions button { min-height: 44px; font-size: 12px; }
  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-statuses > button { min-height: 44px; font-size: 12px; }
  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; }
  body .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; }
  body .slider-wrap .param-slider { min-width: 80px; }
  body .submit-row .primary { width: 100%; }
  body .submit-row strong { font-size: 14px; }
  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; }
}

/* Self-hosted wordmark font */
@font-face {
  font-family: 'Montserrat';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('/assets/fonts/montserrat-700-latin.woff2') format('woff2');
}

/* Unified design tokens & elevation */
:root {
  --surface: #ffffff;
  --surface-subtle: #f9fbf7;
  --surface-tint: #eef4e6;
  --border-soft: #dfe6dc;
  --border-strong: #bdd0af;
  --brand-forest: #2d4a35;
  --brand-forest-hover: #385b42;
  --brand-sage: #526b49;
  --shadow-card: 0 1px 2px rgba(28, 43, 32, 0.04), 0 8px 24px -6px rgba(28, 43, 32, 0.05);
  --shadow-hover: 0 4px 14px -2px rgba(34, 56, 38, 0.09);
}

/* Sticky, crisp topbar */
.topbar,
.account-body .topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-soft);
}

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

.topbar nav a:hover {
  background: #f1f5ec;
  color: #1f3124;
}

.topbar nav .nav-active,
.account-body .topbar nav a[aria-current="page"] {
  background: #e8f0e1;
  color: #243d29;
  font-weight: 600;
}

.counter {
  border-radius: 999px;
  padding: 2px 7px;
  font-weight: 600;
  background: #e2ebd8;
  color: #3f5a36;
}

.account-pill {
  transition: background-color 0.15s ease, border-color 0.15s ease, transform 0.12s ease;
  background: #fbfcf9;
}

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

/* Cards & surfaces */
.workspace-card,
.results-panel,
.result-library,
.account-card,
.request-card,
.drive-card {
  border-color: var(--border-soft);
  box-shadow: var(--shadow-card);
}

/* Dropzone refinement */
.dropzone {
  border: 1.5px dashed #b7c8ae;
  background: linear-gradient(180deg, #fbfdf9 0%, #f5f9f1 100%);
  border-radius: 14px;
  padding: 24px 20px;
  transition: border-color 0.16s ease, background 0.16s ease, box-shadow 0.16s ease, transform 0.12s ease;
}

.dropzone:hover,
.dropzone.dragging {
  border-color: #6b9153;
  background: #eff6e7;
  box-shadow: 0 0 0 4px rgba(130, 168, 95, 0.14);
}

.dropzone .choose-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 12px;
  padding: 9px 14px;
  border-radius: 9px;
  background: #fff;
  color: #2f4b33;
  border: 1px solid #cedbc4;
  box-shadow: 0 1px 2px rgba(34, 53, 35, 0.05);
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

.dropzone:hover .choose-button {
  background: #2f4b33;
  border-color: #2f4b33;
  color: #f6faef;
}

.dropzone.has-files {
  padding: 13px 16px;
  background: #f9fbf7;
}

.dropzone.has-files .upload-icon {
  display: grid;
  width: 32px;
  height: 32px;
  font-size: 18px;
  border-radius: 9px;
}

/* Mode tabs: keep icons visible on desktop for instant scannability */
.tabs {
  background: #eef2ea;
  border-radius: 12px;
  padding: 4px;
  gap: 4px;
}

.tab {
  min-height: 46px;
  border-radius: 9px;
  gap: 8px;
  color: #546552;
  transition: background-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

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

.tab.selected {
  background: #fff;
  color: #233b28;
  box-shadow: 0 1px 4px rgba(26, 43, 29, 0.08);
}

/* Disclosures (summary rows) */
.workspace-disclosure > summary,
.category-disclosure > summary,
.save-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: #485d44;
  border-radius: 8px;
  padding: 10px 4px;
  min-height: 40px;
  transition: color 0.15s ease, background-color 0.15s ease;
}

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

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

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

.workspace-disclosure > summary:hover,
.category-disclosure > summary:hover,
.save-disclosure > summary:hover,
.optional-settings > summary:hover,
.history-disclosure > summary:hover {
  color: #243b27;
}

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

.slider-wrap .param-slider {
  display: block;
  flex: 1;
  min-width: 90px;
}

.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: #f6f9f2;
  border: 1px dashed #cedbc4;
  border-radius: 10px;
  color: #53684d;
  font-size: 13px;
  margin: 4px 0 12px;
}

.action-gate::before {
  content: "↑";
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 6px;
  background: #e7f0de;
  color: #3f5d36;
  font-weight: 700;
  font-size: 12px;
  flex-shrink: 0;
}

/* Buttons consistency across Workspace, Results, Drive, and Account */
.primary,
.account-card .primary {
  background: var(--brand-forest);
  border: 1px solid var(--brand-forest);
  color: #f6faef;
  font-weight: 600;
  border-radius: 10px;
  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: #e4ebe0;
  border-color: #d8e2d2;
  color: #7c8b76;
  opacity: 1;
}

.secondary,
.account-card .secondary {
  border-radius: 9px;
  font-weight: 500;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.eyebrow {
  display: block;
}

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

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

.account-grid > .account-card .account-features {
  flex: 1;
}

/* Drive view layout & cards */
.drive-statuses {
  flex-wrap: wrap;
  gap: 8px;
}

.drive-statuses select {
  width: auto;
  min-width: 170px;
  max-width: 240px;
  min-height: 36px;
  padding: 6px 30px 6px 12px;
  font-size: 12px;
  background: #fafcf7;
}

.drive-new-folder {
  min-height: 36px;
  padding: 6px 12px;
  font-size: 12px;
}

.drive-empty {
  grid-column: 1 / -1;
}

.drive-file-head {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.drive-file-meta {
  min-width: 0;
  flex: 1;
}

.drive-item-title {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.4;
  color: #243829;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.drive-file-meta .muted {
  margin: 3px 0 0;
  font-size: 12px;
}

.drive-card .drive-card-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  padding-top: 12px;
  border-top: 1px solid #edf2e8;
}

.drive-card .drive-card-actions .primary {
  min-height: 34px;
  padding: 6px 13px;
  font-size: 12px;
}

.drive-card .drive-card-actions .danger {
  margin-left: auto;
}

/* Requests view inside unified library card */
.requests-surface .request-toolbar {
  margin: 0;
}

.requests-surface .request-meta-bar {
  padding-top: 12px;
  padding-bottom: 14px;
  border-bottom: 1px solid #ecf1e6;
}

.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: 950px) {
  .topbar {
    padding: 12px 18px;
    gap: 10px 14px;
  }

  .topbar nav {
    scrollbar-width: none;
    -ms-overflow-style: none;
    padding-bottom: 2px;
    mask-image: linear-gradient(to right, #000 92%, transparent 100%);
    -webkit-mask-image: linear-gradient(to right, #000 92%, transparent 100%);
  }

  .topbar nav::-webkit-scrollbar {
    display: none;
  }
}

@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 {
    padding: 7px 12px;
    font-size: 12px;
  }

  .dropzone .choose-button {
    display: none;
  }

  .tab .mode-icon {
    display: none;
  }

  .drive-statuses select {
    flex: 1 1 160px;
    max-width: none;
  }

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