:root {
  --bg: #f8f8f8;
  --surface: #fff;
  --border: #e0e0e0;
  --text: #222;
  --muted: #666;
  --accent: #0d9488;
  --accent-hover: #0f766e;
  --highlight: #f5f5f5;
  --radius: 4px;
}

/* Страница редактора: не применять max-width и padding от standalone (они только у body.shared-view) */
body.editor-page {
  max-width: none;
  margin-left: 0;
  margin-right: 0;
  padding: 0;
}

/* Плавная загрузка: до первого рендера контента — минималистичный экран */
body.editor-page.editor-loading .split-row {
  opacity: 0;
  transition: opacity 0.25s ease-out;
}
body.editor-page:not(.editor-loading) .split-row {
  opacity: 1;
}
body.editor-page.editor-loading .toolbar {
  opacity: 0.4;
}
body.editor-page.editor-loading::after {
  content: '';
  position: fixed;
  top: 50%;
  left: 50%;
  width: 24px;
  height: 24px;
  margin: -12px 0 0 -12px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: editor-loading-spin 0.7s linear infinite;
  pointer-events: none;
}
@keyframes editor-loading-spin {
  to { transform: rotate(360deg); }
}

/* Unified toast for editor feedback */
.editor-toast {
  position: fixed;
  bottom: 16px;
  right: 16px;
  padding: 10px 18px;
  border-radius: 8px;
  font-size: 13px;
  z-index: 9999;
  max-width: 360px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.2);
  transition: opacity 0.2s;
}
.editor-toast[hidden] { display: none !important; }
.editor-toast:not([hidden]) { display: block; }
.editor-toast.success { background: #2e7d32; color: #fff; }
.editor-toast.error { background: #c62828; color: #fff; }
.editor-toast.neutral { background: var(--accent); color: #fff; }

/* Button feedback: active and focus-visible for editor buttons and modal controls */
button:active { opacity: 0.92; }
button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.design-save-btn:active { background: var(--accent-hover); }
.design-save-btn-ghost:active { background: #eee; }
.design-save-btn-danger:active { background: #800; }
.design-modal-close:focus-visible,
.modal-close:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.design-theme-btn:active { background: #e8e8e8; }
.design-theme-btn.active:active { background: var(--accent-hover); }
.input-like:focus-visible,
.design-input:focus-visible,
input[type="text"]:focus-visible,
input[type="password"]:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: system-ui, -apple-system, Segoe UI, sans-serif;
  font-size: 16px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
}
.app {
  max-width: 100%;
  height: 100%;
  margin: 0;
  padding: 16px;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.split-row {
  display: flex;
  gap: 16px;
  align-items: stretch;
  flex: 1;
  min-height: 0;
}
.split-pane {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.split-pane .panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  margin-bottom: 0;
  min-height: 0;
}
.split-pane .panel-header { flex-shrink: 0; }

/* Unified Header for both panels */
.unified-header {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 44px;
}
.header-title {
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  font-size: 12px;
}
.panel-header-title {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.header-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  min-width: 0;
  flex-wrap: nowrap;
}
.editor-prototype-nav {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
}
.editor-prototype-nav .editor-nav-btn {
  flex-shrink: 0;
  width: 24px;
  height: 28px;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--text, #222);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.editor-prototype-nav .editor-nav-btn:hover:not(:disabled) {
  background: var(--highlight, #f0f0f0);
  color: var(--accent, #0d9488);
}
.editor-prototype-nav .editor-nav-btn:disabled {
  opacity: 0.35;
  cursor: default;
}
.editor-prototype-nav .editor-nav-btn[hidden] {
  display: none;
}
.editor-prototype-title {
  font-family: system-ui, -apple-system, Segoe UI, sans-serif;
  font-weight: 600;
  color: var(--text, #222);
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 240px;
  min-width: 0;
  flex-shrink: 1;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
.editor-prototype-title-editable { cursor: pointer; }
.editor-prototype-title-editable:hover { text-decoration: underline; }
.editor-prototype-title-input {
  font-family: system-ui, -apple-system, Segoe UI, sans-serif;
  font-weight: 600;
  font-size: 14px;
  color: var(--text, #222);
  background: var(--bg, #fff);
  border: 1px solid var(--border, #ccc);
  border-radius: 4px;
  padding: 2px 6px;
  max-width: 240px;
  width: 100%;
  min-width: 120px;
  box-sizing: border-box;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
.editor-prototype-title-input:focus { outline: none; border-color: var(--accent, #0d9488); }
.editor-title-rename-confirm {
  flex-shrink: 0;
  min-width: 28px;
  padding: 0 8px;
  font-size: 16px;
  border: 1px solid var(--border, #ccc);
  border-radius: 4px;
  background: var(--accent, #0d9488);
  color: #fff;
  cursor: pointer;
}
.editor-title-rename-confirm:hover { filter: brightness(1.05); }
body.editor-title-renaming #editor-panel .editor-prototype-nav .editor-nav-btn,
body.editor-title-renaming #editor-panel #saveMaterialBtn,
body.editor-title-renaming #editor-panel .add-block-dropdown,
body.editor-title-renaming #editor-panel .ai-dropdown,
body.editor-title-renaming #editor-panel .header-toggle { display: none !important; }

/* Единая высота и пропорции кнопок в заголовке панели */
.unified-header .header-btn,
.unified-header .header-toggle button,
.unified-header .design-preset-row .design-theme-btn {
  height: 28px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  padding-top: 0;
  padding-bottom: 0;
}

.header-toggle {
  display: flex;
  margin-left: auto;
}
.header-toggle button {
  padding: 4px 10px;
  font-size: 11px;
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  color: var(--muted);
  text-transform: none;
  letter-spacing: normal;
}
.header-toggle button:first-child {
  border-radius: var(--radius) 0 0 var(--radius);
}
.header-toggle button:nth-child(2) {
  border-left: none;
}
.header-toggle .pravki-dropdown .pravki-btn {
  border-radius: 0 var(--radius) var(--radius) 0;
  border-left: none;
}
.header-toggle button:hover:not(.active):not(.pravki-btn-disabled) {
  background: var(--highlight);
}
.header-toggle button.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

/* Header button (for Add Block, etc.) */
.header-btn {
  padding: 4px 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  border-radius: var(--radius);
  font-size: 11px;
  color: var(--muted);
  text-transform: none;
  letter-spacing: normal;
}
.header-btn .header-btn-short,
.header-toggle .header-btn-short { display: none; }
.header-btn .header-btn-full,
.header-toggle .header-btn-full { display: inline; }
.header-btn:hover {
  background: var(--bg);
  color: var(--text);
}
.header-btn.ai-btn {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.header-btn.ai-btn:hover {
  background: var(--accent-hover, #0f766e);
  color: #fff;
}
.header-btn.ai-btn-rework {
  background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
  border-color: #f5576c;
}
.header-btn.ai-btn-validate {
  background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
  border-color: #4facfe;
}
.header-btn.ai-btn-advise {
  background: linear-gradient(135deg, #a8e063 0%, #56ab2f 100%);
  border-color: #56ab2f;
}

/* Add Block Dropdown */
.add-block-dropdown {
  position: relative;
}
.add-block-menu {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  margin-top: 4px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
  z-index: 1000;
  padding: 18px;
  width: max-content;
  max-height: 520px;
  overflow-y: auto;
}
.add-block-menu.active {
  display: grid;
  grid-template-columns: repeat(2, auto);
  gap: 12px 28px;
}
.add-block-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.add-block-section-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  padding: 0 4px;
}
.add-block-section-items {
  display: flex;
  gap: 6px;
}
.add-block-menu button {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 10px 8px;
  border: 1px solid transparent;
  background: none;
  font-size: 13px;
  color: var(--muted);
  cursor: pointer;
  border-radius: var(--radius);
  min-width: 70px;
}
.add-block-menu button:hover {
  background: var(--highlight);
  border-color: var(--border);
  color: var(--text);
}
.block-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  font-size: 18px;
  color: var(--muted);
  background: var(--bg);
  border-radius: 4px;
  flex-shrink: 0;
}
.add-block-menu button:hover .block-icon {
  color: var(--accent);
}
@media (max-width: 1200px) {
  .add-block-menu {
    max-width: calc(100vw - 32px);
    left: 0;
    right: auto;
  }
  .add-block-menu.active {
    grid-template-columns: 1fr;
    gap: 12px;
    padding: 12px;
  }
  .add-block-section-items {
    flex-wrap: wrap;
  }
  .add-block-menu button {
    min-width: 60px;
    padding: 8px 6px;
    font-size: 12px;
  }
  .block-icon {
    width: 28px;
    height: 28px;
    font-size: 14px;
  }
}

/* AI Dropdown */
.ai-dropdown {
  position: relative;
}
.ai-dropdown-trigger {
  background: var(--accent) !important;
  color: #fff !important;
  border-color: var(--accent) !important;
}
.ai-dropdown-trigger:hover {
  background: var(--accent-hover, #0f766e) !important;
}
.ai-dropdown-trigger.ai-dropdown-trigger--disabled {
  opacity: 0.5;
  pointer-events: none;
  cursor: not-allowed;
}
.ai-dropdown-menu {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  margin-top: 4px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.15);
  z-index: 1000;
  padding: 8px;
  white-space: nowrap;
  text-transform: none;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-family: system-ui, -apple-system, Segoe UI, sans-serif;
}
.ai-dropdown-menu.active {
  display: block;
}
.ai-menu-notice {
  margin: 0 0 8px 0;
  padding: 10px 12px;
  font-size: 12px;
  line-height: 1.4;
  color: var(--text);
  background: var(--highlight);
  border-radius: 6px;
  border-left: 3px solid var(--accent);
  white-space: normal;
}
.ai-menu-notice strong {
  font-weight: 600;
}
.ai-menu-item {
  display: grid;
  grid-template-columns: 28px 110px 1fr;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 10px 12px;
  border: none;
  background: transparent;
  cursor: pointer;
  border-radius: 6px;
  text-align: left;
  transition: background 0.15s;
}
.ai-menu-item:hover {
  background: var(--highlight);
}
.ai-menu-icon {
  font-size: 16px;
  text-align: center;
}
.ai-menu-label {
  font-weight: 600;
  font-size: 13px;
  color: var(--text);
}
.ai-menu-desc {
  font-size: 12px;
  color: var(--muted);
}
.ai-menu-divider {
  height: 1px;
  background: var(--border);
  margin: 6px 0;
}
.ai-menu-settings {
  opacity: 0.85;
}
.ai-menu-settings:hover {
  opacity: 1;
}

/* Editor content area */
.editor-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 200px;
}
.editor-content textarea.import {
  flex: 1;
  min-height: 200px;
  resize: none;
}

/* Blocks container */
.blocks-container {
  padding: 12px;
  overflow-y: auto;
}

/* Panel footer with counters */
.panel-footer {
  flex-shrink: 0;
  padding: 6px 14px;
  border-top: 1px solid var(--border);
  font-size: 11px;
  color: var(--muted);
}
.panel-counter {
  font-variant-numeric: tabular-nums;
}

.split-pane .panel-body { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.split-pane textarea.import,
.split-pane textarea.html-source { flex: 1; min-height: 200px; resize: none; }
.split-pane .view { flex: 1; min-height: 200px; overflow: auto; }
textarea.html-source {
  font-family: ui-monospace, monospace;
  font-size: 12px;
  padding: 14px;
  border: none;
}
/* Превью: отличия от панели редактора (конструктора)
   Выберите один из вариантов — раскомментируйте нужный блок.

   Вариант A: светлый фон + левая рамка (текущий)
   Вариант B: «страница» — белая область с тенью и рамкой
   Вариант C: тёплый фон + полная рамка
   Вариант D: акцентная левая полоса + нейтральный фон
*/

/*
Вариант A: светлый фон + левая рамка
.right-panel .panel {
  background: #f8f9fa;
  border-left: 4px solid #dee2e6;
}
*/

/*
Вариант B: «страница» — раскомментируйте блок ниже и закомментируйте блок «Вариант C»
.right-panel .panel {
  background: #fff;
  border: 1px solid #e0e0e0;
  box-shadow: inset 0 0 0 1px #f0f0f0, 2px 4px 12px rgba(0,0,0,0.06);
  border-radius: 6px;
}
*/

/* --- Вариант C: тёплый фон + полная рамка --- */
.right-panel .panel {
  background: #faf8f5;
  border: 2px solid #e8e4de;
  border-radius: 6px;
}

/*
Вариант D: акцентная полоса + нейтральный фон
.right-panel .panel {
  background: #f5f5f5;
  border-left: 6px solid #0066cc;
  box-shadow: 1px 0 0 0 rgba(0,0,0,0.05);
}
*/
.right-panel .view-wrap,
.right-panel .html-wrap { flex: 1; min-height: 0; display: none; }
.right-panel .view-wrap.active,
.right-panel .html-wrap.active { display: flex; flex-direction: column; }
.right-panel .view-theme {
  border-radius: 0 3px 3px 0;
}
/* Longread theme controls (Variant C) */
.design-controls { display: flex; align-items: center; }
.design-preset-row { display: flex; align-items: center; gap: 0; }
.design-preset-row .design-theme-btn {
  padding: 4px 10px;
  font-size: 11px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  border-radius: 0;
  font-weight: inherit;
  text-transform: none;
  letter-spacing: normal;
  cursor: pointer;
}
.design-preset-row .design-theme-btn:not(:last-child) { border-right: none; }
.design-preset-row .design-theme-btn:first-child { border-radius: var(--radius) 0 0 var(--radius); }
.design-preset-row .design-theme-btn:last-child { border-radius: 0 var(--radius) var(--radius) 0; }
.design-preset-row .design-theme-btn:hover:not(.active) { background: var(--highlight); }
.design-preset-row .design-theme-btn.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.design-preset-row .design-theme-btn.active + .design-theme-btn { border-left-color: var(--accent); }

/* Unified modal base: one overlay + dialog style for all modals in Editor */
.modal-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.4);
  z-index: 200;
  align-items: center;
  justify-content: center;
  padding: 20px;
  box-sizing: border-box;
}
.modal-overlay[aria-hidden="false"] { display: flex; }
.modal-dialog {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.25);
  max-width: 90%;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.modal-title {
  font-size: 18px;
  font-weight: 600;
  margin: 0;
  color: var(--text);
}
.modal-close {
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  color: var(--muted);
}
.modal-close:hover { color: var(--text); }
.modal-body {
  padding: 16px 20px;
  overflow: auto;
  flex: 1;
  min-height: 0;
}
.modal-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.design-modal-overlay {
  z-index: 1500;
}
.design-modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: system-ui, -apple-system, Segoe UI, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  box-shadow: 0 20px 60px rgba(0,0,0,0.25);
  max-width: 1200px;
  width: 90%;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.design-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.design-modal-title {
  font-size: 18px;
  font-weight: 600;
  margin: 0;
  color: var(--text);
}
.design-modal-close {
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  color: var(--muted);
}
.design-modal-close:hover { color: var(--text); }
.design-modal-body {
  display: grid;
  grid-template-columns: 340px minmax(520px, 1fr);
  gap: 24px;
  padding: 10px 20px 20px;
  min-height: 0;
}
@media (max-width: 900px) {
  .design-modal-body { grid-template-columns: 1fr; }
  .design-preview-wrap { max-height: 180px; }
}
@media (max-width: 1200px) {
  .design-color-block { gap: 4px; }
  .design-color-row { gap: 4px; grid-template-columns: minmax(80px, 1fr) 22px; }
  .design-hex { font-size: 11px; padding: 4px 6px; }
  .design-hex-preview { width: 20px; height: 20px; border-radius: 4px; }
}
@media (max-width: 1100px) {
  .toolbar-project-name { display: none !important; }
}
@media (max-width: 1000px) {
  .toolbar-import-full { display: none !important; }
  .toolbar-import-short { display: inline !important; }
  .toolbar-lk-full { display: none !important; }
  .toolbar-lk-short { display: inline !important; }
  .toolbar-btn-full { display: none !important; }
  .toolbar-btn-emoji { display: inline !important; }
  .design-preset-row .design-theme-full { display: none !important; }
  .design-preset-row .design-theme-short { display: inline !important; }
  .design-preset-row .design-theme-custom-text { display: none !important; }
}
.design-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
  overflow: visible;
  min-height: 0;
}
.design-theme-tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}
.design-preview-source-tabs {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.design-preview-source-btn {
  padding: 8px 10px;
  border: 1px solid #ddd;
  border-radius: 4px;
  background: #fff;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  text-align: center;
  white-space: normal;
}
.design-preview-source-btn:hover { background: #f5f5f5; border-color: #bbb; }
.design-preview-source-btn.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.design-preview-empty-hint { color: #888; font-size: 13px; margin: 0; }
.design-theme-btn {
  padding: 8px 10px;
  border: 1px solid #ddd;
  border-radius: 4px;
  background: #fff;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  text-align: center;
  white-space: normal;
}
.design-theme-btn.icon-only { padding: 8px 0; }
.design-theme-btn .palette-icon { width: 16px; height: 16px; display: block; margin: 0 auto; }
.design-theme-btn:hover { background: #f5f5f5; border-color: #bbb; }
.design-theme-btn.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.design-field { display: flex; flex-direction: column; gap: 6px; }
.design-field-label {
  font-size: 12px;
  font-weight: 600;
  color: #444;
}
.design-input {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 13px;
  font-family: inherit;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
.design-hex-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 14px;
  margin-top: 8px;
}
.design-copy-paste-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  margin-top: 10px;
}
.design-copy-paste-row .design-save-btn {
  width: 100%;
}
.design-color-block {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.design-color-row {
  display: grid;
  grid-template-columns: minmax(90px, 1fr) 28px;
  gap: 6px;
  align-items: center;
}
.design-modal-footer {
  margin-top: 12px;
  padding-top: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: flex-start;
}
.design-save-theme-block {
  margin-top: 12px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}
.design-save-theme-name {
  flex: 1;
  min-width: 0;
  max-width: 140px;
  padding: 4px 8px;
  font-size: 12px;
  border: 1px solid #ddd;
  border-radius: 4px;
}
.design-icon-btn {
  width: 32px;
  height: 32px;
  padding: 0;
  font-size: 16px;
  line-height: 1;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: #fff;
  cursor: pointer;
  flex-shrink: 0;
}
.design-icon-btn:hover { background: #f5f5f5; border-color: #bbb; }
.design-my-themes-search-wrap {
  width: 100%;
  flex-basis: 100%;
  padding-top: 4px;
}
.design-my-themes-search-wrap:not([hidden]) {
  display: block;
}
.design-my-themes-search {
  width: 100%;
  padding: 6px 8px;
  font-size: 12px;
  border: 1px solid #ddd;
  border-radius: 4px;
  box-sizing: border-box;
}
.design-my-themes-block {
  margin-top: 10px;
  min-height: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.design-my-themes-list {
  max-height: 160px;
  overflow-y: auto;
  overflow-x: hidden;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  min-height: 0;
  align-content: start;
}
/* Стиль как у кнопок пресетов Минимум/Черновик/Тёмная (idle, hover, active), размеры по контенту сохраняются */
.design-saved-theme-btn {
  padding: 8px 10px;
  font-size: 12px;
  font-weight: 500;
  text-align: center;
  border: 1px solid #ddd;
  border-radius: 4px;
  background: #fff;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
.design-saved-theme-btn:hover { background: #f5f5f5; border-color: #bbb; }
.design-saved-theme-btn.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.design-save-btn {
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 600;
  background: #0d9488;
  color: #fff;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
}
.design-save-btn:hover { background: #0f766e; }
.design-save-btn-ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}
.design-save-btn-ghost:hover { background: #f5f5f5; border-color: #bbb; }
.design-save-btn-danger { background: #c00; color: #fff; }
.design-save-btn-danger:hover { background: #a00; }
.design-modal-wide { max-width: 640px; }
.design-modal-sm { max-width: 380px; }
.design-modal-sm .design-modal-body {
  display: flex;
  flex-direction: column;
  grid-template-columns: unset;
  gap: 0;
  min-height: 0;
}
.design-modal-sm .design-modal-footer {
  flex-shrink: 0;
  margin-top: 16px;
}

/* Модалка «Вставить тему» — субмодалка поверх настроек дизайна (design-modal-overlay 1500) */
.design-paste-modal-overlay {
  display: none;
  align-items: center;
  justify-content: center;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 10000;
}
.design-paste-modal-overlay[aria-hidden="false"] {
  display: flex;
}
.design-paste-modal {
  max-width: 480px;
  width: 90%;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
}
.design-paste-modal .design-modal-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
}
.design-paste-modal-label {
  font-size: 12px;
  font-weight: 600;
  color: #444;
}
.design-paste-modal-input {
  width: 100%;
  box-sizing: border-box;
  padding: 8px 10px;
  font-size: 12px;
  font-family: ui-monospace, monospace;
  border: 1px solid #ddd;
  border-radius: 4px;
  resize: vertical;
  min-height: 120px;
}
.design-paste-modal-status {
  font-size: 12px;
  min-height: 1.4em;
}
.design-paste-modal-status.status-ok { color: #0d9488; font-weight: 500; }
.design-paste-modal-status.status-err { color: #c00; }
.design-paste-modal-actions {
  flex-shrink: 0;
}

/* Модалка «Новый прототип» — компактная */
.design-modal-new-material {
  max-width: 400px;
  width: 100%;
}
.design-modal-new-material .design-modal-header {
  padding: 10px 16px;
}
.design-modal-new-material .design-modal-title {
  font-size: 16px;
}
.design-modal-new-material .design-modal-body {
  display: flex;
  flex-direction: column;
  grid-template-columns: unset;
  gap: 0;
  padding: 12px 16px 16px;
  min-height: 0;
}
.design-modal-new-material .design-form {
  gap: 10px;
}
.design-modal-new-material .design-modal-footer {
  margin-top: 8px;
  padding-top: 0;
}

.design-modal-overlay[aria-hidden="false"] { display: flex; }
.materials-delete-confirm-text { margin: 0 0 12px; font-size: 14px; color: #333; }
.design-modal-footer { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }
/* Модалки настроек (прототип, проект, раздел) и подтверждение удаления — поверх модалки «Прототипы» */
#materialSettingsModalOverlay[aria-hidden="false"],
#projectSettingsModalOverlay[aria-hidden="false"],
#sectionSettingsModalOverlay[aria-hidden="false"],
#materialsDeleteConfirmOverlay[aria-hidden="false"] { z-index: 1600; }
/* Подтверждения (удаление в настройках, снять с публикации) — поверх остальных модалок */
#appConfirmOverlay[aria-hidden="false"] { z-index: 1700; }

/* Поделиться (Отправить): компактная модалка в стиле проекта */
.design-modal-share { max-width: 420px; width: 90%; }
/* Настройки + Поделиться: две колонки (если понадобится снова) */
.design-modal-settings-share { max-width: 720px; min-width: 560px; }
.design-modal-body-two-cols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  align-items: start;
}
.settings-share-col {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}
.settings-share-col-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #888;
  margin: 0 0 4px;
}
.design-field-hint-compact { margin: 0 0 4px; font-size: 13px; color: #666; }
.design-field-checkbox-inline {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: nowrap;
}
.design-field-checkbox-inline .design-field-hint-compact { margin: 0; }
.design-field-checkbox-row {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  flex-wrap: nowrap;
}
.settings-share-col .design-field-checkbox-row { align-self: stretch; }
.design-field-checkbox-row .design-field-checkbox-label { margin: 0; white-space: nowrap; cursor: pointer; font-size: 12px; color: #444; }
.design-field-checkbox-row .design-input[type="checkbox"] {
  width: auto;
  flex-shrink: 0;
  margin-left: 0;
}
.design-modal-footer-buttons-row { flex-wrap: nowrap; }
.section-link-type-toggle .design-theme-btn,
.project-link-type-toggle .design-theme-btn { min-width: 0; }
.design-modal-body-section-settings { gap: 20px; }
.design-modal-body-section-settings .settings-share-col { gap: 8px; }
.design-modal-footer-settings { flex-direction: row; gap: 8px; }
.settings-btn-delete { color: #c00; }
.settings-btn-delete:hover { color: #a00; }
@media (max-width: 640px) {
  .design-modal-body-two-cols { grid-template-columns: 1fr; }
}

/* Прототипы: крупная модалка, постраничная навигация, карточки */
.design-modal-materials { max-width: 960px; min-width: 680px; }
.materials-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 20px;
  border-bottom: 1px solid #e5e5e5;
}
.materials-modal-header .materials-toolbar-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
}
.materials-modal-header .materials-toolbar-row .design-save-btn { flex-shrink: 0; }
.materials-modal-header .design-save-btn.materials-btn-add {
  background: var(--accent);
  color: #fff;
  border: none;
}
.materials-modal-header .design-save-btn.materials-btn-add:hover {
  background: var(--accent-hover);
}
.materials-modal-header .design-save-btn.materials-btn-add:active {
  background: var(--accent-hover);
}
.materials-modal-header .design-modal-close { flex-shrink: 0; }
.materials-modal-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 480px;
}
.materials-btn-add { flex-shrink: 0; font-size: 13px; }
.materials-two-cols {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 24px;
  flex: 1;
  min-height: 0;
}
.materials-panel-left {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-right: 8px;
  border-right: 1px solid #eee;
  min-height: 0;
}
.materials-panel-right {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
  min-width: 0;
}
.materials-nav-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
.materials-nav-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
.materials-nav-danger {
  margin-left: auto;
  flex-shrink: 0;
  border-left: 1px solid #ddd;
  padding-left: 10px;
}
.materials-nav-danger:empty { border: none; padding: 0; }
.materials-nav-group[hidden] { display: none; }
.materials-btn-icon {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2em;
  line-height: 1;
}
.materials-btn-delete {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2em;
  line-height: 1;
  color: #c00;
}
.materials-btn-delete:hover { color: #a00; }
.materials-breadcrumb {
  font-size: 13px;
  color: var(--muted, #666);
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.materials-search-inline {
  width: 140px;
  min-width: 100px;
  flex-shrink: 0;
  padding: 6px 10px;
  font-size: 13px;
}
.materials-list-add-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.materials-add-wrap { position: relative; flex-shrink: 0; }
.materials-add-dropdown {
  display: flex;
  gap: 4px;
  position: absolute;
  top: 100%;
  left: 0;
  margin-top: 4px;
  z-index: 10;
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 4px;
  padding: 4px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}
.materials-add-dropdown[hidden] { display: none; }
.materials-add-dropdown button { padding: 6px 10px; font-size: 12px; border: 1px solid #ddd; border-radius: 4px; background: #fff; cursor: pointer; }
.materials-add-dropdown button:hover { background: #f5f5f5; }
/* Левая панель — только один столбец (дерево), без двух колонок внутри списка */
.materials-panel-left .materials-tree {
  display: block;
}
.materials-panel-left .materials-tree > li {
  display: block;
}
.materials-panel-left .materials-tree-children {
  display: block;
}
.materials-panel-left .materials-tree-children > li {
  display: block;
}
.materials-tree {
  list-style: none;
  margin: 0;
  padding: 0;
  flex: 1;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  border: 1px solid #e5e5e5;
  border-radius: 6px;
  background: #fafafa;
}
.materials-tree-item {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  cursor: pointer;
  font-size: 13px;
  border: none;
  background: none;
  width: 100%;
  min-width: 0;
  text-align: left;
  font-family: inherit;
  color: #333;
  border-radius: 4px;
  margin: 1px 3px;
  box-sizing: border-box;
}
.materials-tree-item {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
.materials-tree-item:hover { background: #eee; }
.materials-tree-item[aria-selected="true"] { background: rgba(13,148,136,0.06); color: var(--accent); }
.materials-tree-toggle {
  flex-shrink: 0;
  width: 1.1em;
  height: 1.1em;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 0.75em;
  line-height: 1;
  color: #666;
  user-select: none;
}
.materials-tree-toggle:hover { color: var(--accent); }
.materials-tree-item.collapsed .materials-tree-children { display: none; }
.materials-tree-icon { font-size: 1.1em; flex-shrink: 0; color: var(--accent); }
.materials-tree-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.materials-tree-children { padding-left: 8px; }
.materials-tree-children .materials-tree-children { padding-left: 8px; }
/* Список структуры — строго один столбец, без grid */
.materials-tree,
.materials-tree-children {
  display: block;
}
.materials-tree > li,
.materials-tree-children > li {
  display: block;
}
.materials-cards-wrap {
  position: relative;
  flex: 1;
  min-height: 0;
  min-width: 0;
}
.materials-insertion-line {
  display: none;
  position: absolute;
  width: 3px;
  background: var(--accent, #0d9488);
  border-radius: 2px;
  pointer-events: none;
  z-index: 10;
  top: 0;
  bottom: 0;
}
.materials-insertion-line.visible {
  display: block;
}
.materials-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 16px;
  flex: 1;
  min-height: 0;
  min-width: 0;
  overflow-x: hidden;
  overflow-y: auto;
  align-content: start;
}
.materials-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  min-height: 144px;
  height: 144px;
  padding: 16px;
  padding-top: 36px;
  border: 1px solid #e5e5e5;
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
  text-align: center;
  box-sizing: border-box;
  overflow: hidden;
}
.materials-card:hover { background: #f5f5f5; border-color: #ccc; }
.materials-card-icon {
  font-size: 2rem;
  line-height: 1;
  margin-bottom: 6px;
  width: 48px;
  height: 48px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
}
.materials-card-title {
  font-size: 13px;
  font-weight: 500;
  word-break: break-word;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  line-height: 1.3;
  height: 2.6em;
  flex-shrink: 0;
}
.materials-card-date {
  font-size: 10px;
  color: #999;
  margin-top: 2px;
  flex-shrink: 0;
  line-height: 1.2;
  max-height: 1.4em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.materials-card-actions { margin-top: auto; flex-shrink: 0; }
.materials-card-settings {
  position: absolute;
  top: 6px;
  left: 6px;
  width: 28px;
  height: 28px;
  padding: 0;
  font-size: 14px;
  color: #666;
  background: none;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  opacity: 0.7;
  z-index: 2;
}
.materials-card-settings:hover { color: var(--accent); opacity: 1; background: rgba(13,148,136,0.08); }
.materials-card-delete {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 28px;
  height: 28px;
  padding: 0;
  font-size: 14px;
  color: #c00;
  background: none;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  z-index: 2;
  transition: opacity 0.15s ease;
}
.materials-card:hover .materials-card-delete { opacity: 1; }
.materials-card-delete:hover { color: #a00; background: rgba(200,0,0,0.1); }
.materials-tree-children { list-style: none; margin: 0; padding-left: 8px; }
.materials-tree-children .materials-tree-item { margin: 1px 3px; }
.materials-tree-item.materials-tree-drop-valid {
  background: rgba(13,148,136,0.08);
  outline: 2px solid var(--accent, #0d9488);
  outline-offset: -2px;
}
.materials-card.materials-card-drop-valid {
  background: rgba(13,148,136,0.08);
  outline: 2px solid var(--accent, #0d9488);
  outline-offset: -2px;
}
.materials-card-dragging { opacity: 0.6; }
.materials-cards-empty { grid-column: 1 / -1; color: #999; text-align: center; padding: 24px; }
.materials-date { font-size: 11px; color: #999; white-space: nowrap; }
@media (max-width: 960px) {
  .materials-cards-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 768px) {
  .materials-modal-body { grid-template-columns: 1fr; }
  .materials-panel-left { border-right: none; border-bottom: 1px solid #eee; padding-right: 0; padding-bottom: 16px; }
  .materials-actions { flex-direction: row; flex-wrap: wrap; }
  .materials-action-main { width: auto; }
}
.pravki-dropdown { position: relative; }
.pravki-dropdown-menu {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 4px;
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  z-index: 100;
  min-width: 200px;
  max-height: 320px;
  overflow-y: auto;
  padding: 4px 0;
}
.pravki-dropdown-item { display: block; width: 100%; padding: 8px 12px; text-align: left; border: none; background: none; cursor: pointer; font-size: 13px; }
.pravki-dropdown-item:hover { background: #f5f5f5; }
.pravki-btn-disabled { opacity: 0.5; pointer-events: none; cursor: default; }
.toolbar-export-dropdown { position: relative; }
.toolbar-export-menu {
  position: absolute;
  top: 100%;
  left: 0;
  margin-top: 4px;
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  z-index: 100;
  min-width: 180px;
  padding: 4px 0;
}
.toolbar-export-menu button { display: block; width: 100%; padding: 8px 12px; text-align: center; border: none; background: none; cursor: pointer; font-size: 13px; font-family: system-ui, -apple-system, Segoe UI, sans-serif; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }
.toolbar-export-menu button:hover { background: #f5f5f5; }
.share-state p { margin: 0 0 12px; }
.share-link-block { margin-bottom: 16px; }
.share-link-block .design-field-label { display: block; margin-bottom: 6px; }
.share-link-wrap .share-link-no { margin-bottom: 0; }
.share-link-wrap .share-link-yes .share-link-field-wrap { margin-bottom: 4px; }
.share-links-list { display: flex; flex-direction: column; gap: 12px; margin-bottom: 16px; }
.share-links-list .design-field { margin-bottom: 8px; }
.share-link-field-wrap { position: relative; }
.share-link-input { padding-right: 40px; }
.share-copy-btn {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 28px;
  height: 28px;
  padding: 0;
  border: 1px solid var(--border, #e0e0e0);
  background: #fff;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}
.share-copy-btn:hover { background: #f5f5f5; }
.share-auto-update-row { display: block; width: 100%; margin-top: 8px; }
.share-auto-update-wrap { display: block; font-size: 12px; color: var(--muted, #666); cursor: pointer; }
.share-auto-update-wrap input { margin-right: 6px; vertical-align: middle; }
/* Бесплатный тариф: поле «С комментариями» и «Пароль» — бледные, только для отображения */
.settings-share-col.free-tier-share .share-link-input--disabled,
.settings-share-col.free-tier-share .share-input-free-tier {
  opacity: 0.7;
  background: var(--highlight, #f5f5f5);
  cursor: not-allowed;
  pointer-events: none;
}
.settings-share-col.free-tier-share .share-field-free-tier .design-field-label {
  color: var(--muted, #666);
}
.design-form .design-color-row {
  grid-template-columns: minmax(90px, 1fr) 28px;
}
.design-swatch {
  width: 100%;
  height: 26px;
  border-radius: 5px;
  border: 2px solid transparent;
  cursor: pointer;
  padding: 0;
}
.design-swatch:hover { border-color: #999; }
.design-swatch.selected {
  border-color: #333;
  box-shadow: 0 0 0 1px #fff inset;
}
.design-hex {
  width: 100%;
  font-size: 12px;
  padding: 5px 8px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-family: ui-monospace, monospace;
}
.design-hex-preview {
  width: 24px;
  height: 24px;
  border-radius: 5px;
  border: 1px solid #ccc;
  background: #fff;
  cursor: pointer;
}
.design-preview-wrap {
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.design-preview-scroll {
  flex: 1;
  min-height: 0;
  border: 1px solid #e0e0e0;
  border-radius: 6px;
  background: #f6f6f6;
  overflow: auto;
}
.design-preview-theme {
  width: 100%;
  min-height: 100%;
  padding: 12px;
  box-sizing: border-box;
}
.design-preview-theme .view {
  padding: 12px;
  min-height: 0;
  word-wrap: break-word;
}
.view-theme { flex: 1; min-height: 0; display: flex; flex-direction: column; overflow: auto; position: relative; }
.view-theme .view { flex: 1; min-height: 0; }
.view-theme { background: var(--longread-bg, var(--bg)); color: var(--longread-text, var(--text)); --text: var(--longread-text, #222); --highlight: var(--longread-surface, #f5f5f5); --surface: var(--longread-surface, #fff); --accent: var(--longread-accent, #1f3249); }
.view-theme h1, .view-theme h2, .view-theme h3, .view-theme h4, .view-theme h5, .view-theme h6 { color: var(--longread-headings, var(--text)); }
.view-theme pre {
  background: var(--longread-important-bg, var(--longread-surface, var(--highlight)));
  border: 1px solid var(--longread-accent, var(--border));
  color: var(--longread-text, var(--text));
  padding: 0.75em 1em;
  border-radius: var(--radius);
  overflow-x: auto;
  margin: 0.75em 0;
  font-size: 0.9em;
  font-family: ui-monospace, monospace;
}
.view-theme pre code { background: transparent; padding: 0; }
.view-theme .accordion, .view-theme .accordion-head,
.view-theme .tabs-headers, .view-theme .flip-front, .view-theme .flip-back,
.view-theme .block.btn a { background: var(--longread-surface, var(--highlight)); }
.view-theme .block.important { background: var(--longread-important-bg, var(--longread-surface, var(--highlight))); }
.view-theme .tabs-headers button.active { background: var(--longread-surface, var(--surface)); }
/* Акцент только для мелких элементов: рамки, иконки, подчёркивание */
/* Черта цитаты, разделитель, иконка «Внимание» — всегда соответствуют акцентному цвету (--longread-accent / --longread-accent-pale) */
.view-theme .block.important { margin-left: 5%; margin-right: 5%; border: 1px solid var(--longread-accent-pale, var(--border)); padding-left: 40px; position: relative; border-radius: var(--radius); }
/* Комментарии — как на «Ссылке для комментариев» (синхронно с standalone-content.css) */
.view-theme .comments-block {
  margin-left: 5%;
  margin-right: 5%;
  margin-top: 1em;
  margin-bottom: 2em;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--longread-accent-pale, var(--border));
  border-left: 3px solid var(--longread-accent, var(--accent));
  border-radius: var(--radius);
  background: var(--longread-important-bg, var(--highlight));
  color: var(--longread-text, inherit);
}
.view-theme .comments-toggle {
  width: 100%;
  padding: 12px 16px;
  text-align: left;
  font: inherit;
  font-size: 0.9em;
  font-weight: normal;
  font-style: italic;
  background: var(--longread-important-bg, rgba(0, 0, 0, 0.03));
  border: none;
  cursor: pointer;
  color: var(--longread-text, inherit);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.view-theme .comments-toggle::after { content: "+"; font-size: 1.1em; font-style: normal; color: var(--longread-accent-pale, var(--muted)); flex-shrink: 0; margin-left: 8px; }
.view-theme .comments-toggle[aria-expanded="true"]::after { content: "−"; }
.view-theme .comments-toggle:hover { background: var(--longread-surface, #eee); }
.view-theme .comments-body {
  padding: 12px 16px;
  background: var(--longread-important-bg, rgba(0, 0, 0, 0.03));
  border-top: 1px solid var(--longread-accent-pale, var(--border, #e0e0e0));
  color: var(--longread-text, inherit);
}
.view-theme .comments-block .comment-meta,
.view-theme .comment-meta { font-size: 0.75em; color: var(--longread-accent, #1f3249); display: block; margin-bottom: 0.25em; }
.view-theme .comment-item { margin-bottom: 0.75em; }
.view-theme .comment-item:last-child { margin-bottom: 0; }
.view-theme .comment-quote { font-size: 1em; color: var(--longread-text, inherit); margin: 0.25em 0 0.4em; padding-left: 0.5em; border-left: 3px solid var(--longread-accent-pale, #ddd); max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.view-theme .comment-text { font-size: 0.95em; }
.view-theme .block.tmp {
  width: 100%;
  max-width: 100%;
  margin: 1.5em 0;
  display: block;
}
.view-theme .block.tmp .placeholder-16x9-wrap {
  width: 100%;
  aspect-ratio: 16 / 9;
  display: block;
  overflow: hidden;
  line-height: 0;
}
.view-theme .block.tmp .placeholder-16x9-svg { width: 100%; height: 100%; display: block; }
.view-theme .block.tmp .placeholder-16x9-bg { fill: var(--longread-important-bg, var(--longread-surface, var(--highlight))); }
.view-theme .block.tmp .placeholder-16x9-border { stroke: var(--longread-accent-pale, var(--border)); stroke-width: 0.2; fill: none; }
.view-theme .block.img .placeholder-16x9-bg { fill: var(--longread-important-bg, var(--longread-surface, var(--highlight))); }
.view-theme .block.img .placeholder-16x9-border { stroke: var(--longread-accent-pale, var(--border)); stroke-width: 0.2; fill: none; }
.view-theme .block.important::before { content: "\2139"; position: absolute; left: 12px; top: 50%; transform: translateY(-50%); font-size: 1.35em; font-weight: 600; color: var(--longread-accent, #1f3249); line-height: 1; }
/* Бледный акцент для аккордеона, вкладок, карточек */
.view-theme .accordion { border-color: var(--longread-accent-pale, var(--border)); }
.view-theme .accordion-item { border-bottom-color: var(--longread-accent-pale, var(--border)); }
.view-theme .accordion-head::after { color: var(--longread-accent-pale, var(--muted)); }
.view-theme .tabs-headers button.active { border-bottom-color: var(--longread-accent-pale, var(--border)); }
.view-theme .flip-front, .view-theme .flip-back { border-color: var(--longread-accent-pale, var(--border)); }
.view-theme .flip-card .flip-toggle { border-color: var(--longread-accent-pale, var(--border)); color: var(--longread-accent, var(--muted)); }
/* Таблица и вкладки — те же границы, что у карточек и блока «Внимание» */
.view-theme .tabs-block { border-color: var(--longread-accent-pale, var(--border)); }
.view-theme .tabs-headers { border-bottom-color: var(--longread-accent-pale, var(--border)); }
.view-theme .accordion-body { border-top-color: var(--longread-accent-pale, var(--border)); }
.view-theme th, .view-theme td { border-color: var(--longread-accent-pale, var(--border)); }
.view-theme .block.btn a { border-color: var(--longread-accent, #1f3249); }
.view-theme .block.btn a:hover { background: var(--longread-accent, #1f3249); color: var(--longread-surface, #fff); }
.view-theme blockquote, .view-theme .block.quote { border-left-color: var(--longread-accent, #1f3249); }
/* Цвет текста интерактивов: заголовки аккордеона, вкладки, тело аккордеона/вкладок/карточек */
.view-theme .accordion-head, .view-theme .tabs-headers button { color: var(--longread-surface-text, var(--longread-text)); font-weight: 500; }
.view-theme .tabs-headers button:hover,
.view-theme .tabs-headers button.active { color: var(--longread-surface-text, var(--longread-text)); }
.view-theme .accordion-body, .view-theme .tabs-panels, .view-theme .flip-front, .view-theme .flip-back { color: var(--longread-surface-text, var(--longread-text)); }
.view-theme .flip-front { font-weight: 500; }
/* Скрыты до применения фич из админки (applyPlanRestrictions по EDITOR_FEATURES) */
.editor-feature-gated { display: none; }

/* Заблокированные премиум-кнопки на тарифе «Черновик»: бледные, курсор «стоп», клик открывает оверлей «Купить» */
.plan-locked {
  opacity: 0.55;
  cursor: not-allowed !important;
  pointer-events: auto;
}

.toolbar {
  flex-shrink: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}
.toolbar button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 8px 14px;
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  font-size: 13px;
  white-space: nowrap;
  border-radius: var(--radius);
  box-sizing: border-box;
}
.toolbar button:hover { background: var(--highlight); }
.toolbar button.toolbar-btn-files {
  color: var(--accent, #0d9488);
  border: 1px solid var(--accent, #0d9488);
  font-weight: normal;
  background: var(--surface);
}
.toolbar button.toolbar-btn-files:hover {
  color: #0f766e;
  border-color: #0f766e;
  background: var(--highlight);
}
.toolbar-right-group {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}
.toolbar-project-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  text-decoration: none;
  padding: 0 4px;
  white-space: nowrap;
}
.toolbar-project-name:hover { color: var(--muted); }
.toolbar-lk-short { display: none; }
.toolbar-import-short { display: none; }
.toolbar-btn-emoji { display: none; }
.design-preset-row .design-theme-short { display: none; }
.toolbar-btn-link {
  display: inline-flex;
  align-items: center;
  padding: 8px 14px;
  font-size: 13px;
  color: var(--text);
  text-decoration: none;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius);
  cursor: pointer;
}
.toolbar-btn-link:hover { background: var(--highlight); color: var(--text); }
.toolbar button.toolbar-upgrade-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  min-height: 36px;
  padding: 8px 14px;
  font-family: system-ui, -apple-system, Segoe UI, sans-serif;
  font-size: 13px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-weight: 500;
  line-height: 1.25;
  white-space: nowrap;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  border-radius: var(--radius);
}
.toolbar button.toolbar-upgrade-btn:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: #fff; }
.toolbar button.toolbar-upgrade-btn:disabled { opacity: 0.6; cursor: not-allowed; }
.toolbar-feedback-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  min-width: 36px;
  height: 36px;
  min-height: 36px;
  padding: 0;
  font-size: 1.1rem;
  color: var(--text);
  text-decoration: none;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius);
  cursor: pointer;
  box-sizing: border-box;
  flex-shrink: 0;
}
.toolbar-feedback-icon:hover { background: var(--highlight); }
.toolbar-lk-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  min-height: 36px;
  padding: 8px 14px;
  font-family: system-ui, -apple-system, Segoe UI, sans-serif;
  font-size: 13px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-weight: 500;
  line-height: 1.25;
  white-space: nowrap;
  color: #fff;
  text-decoration: none;
  border: 1px solid #0d9488;
  background: #0d9488;
  border-radius: var(--radius);
  cursor: pointer;
}
.toolbar-lk-btn:hover { background: #0f766e; border-color: #0f766e; color: #fff; }

.upgrade-overlay { z-index: 1100; }
.upgrade-dialog {
  max-width: 420px;
  width: 100%;
  font-family: system-ui, -apple-system, Segoe UI, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
.upgrade-header { display: flex; justify-content: space-between; align-items: center; padding: 12px 14px; border-bottom: 1px solid var(--border); }
.upgrade-header span { font-weight: 600; }
.upgrade-close { background: none; border: none; font-size: 1.5rem; cursor: pointer; color: var(--muted); padding: 0 4px; line-height: 1; }
.upgrade-close:hover { color: var(--text); }
.upgrade-body { padding: 1rem 14px; }
.upgrade-benefits { margin: 0 0 1rem; padding-left: 1.25rem; }
.upgrade-benefits li { margin-bottom: 0.35rem; }
.upgrade-price-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; flex-wrap: wrap; }
.upgrade-price-row .upgrade-price-note { margin: 0; }
.upgrade-price-row .upgrade-promo-input { margin: 0; flex: 0 1 auto; width: 10rem; max-width: 14rem; }
.upgrade-promo-input { padding: 0.4rem 0.6rem; font-size: 0.95rem; border: 1px solid var(--border); border-radius: var(--radius); font-family: inherit; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }
.upgrade-footer { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.upgrade-trial-btn { padding: 8px 16px; background: transparent; color: var(--text); border: 1px solid var(--border); border-radius: var(--radius); cursor: pointer; font-size: 14px; font-weight: 600; }
.upgrade-trial-btn:hover { background: var(--border); }
.upgrade-buy-btn { padding: 8px 16px; background: #0d9488; color: #fff; border: none; border-radius: var(--radius); cursor: pointer; font-size: 14px; }
.upgrade-buy-btn:hover { background: #0f766e; }
.upgrade-price-note { font-size: 0.9rem; color: var(--muted); }

.mobile-stub { display: none; }
.mobile-mode-switcher { display: none; }
@media (max-width: 700px) {
  .app { padding: 8px; }
  .mobile-mode-switcher {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    margin-top: 2px;
    margin-bottom: 6px;
    flex-shrink: 0;
  }
  .mobile-mode-switcher .mobile-mode-btn {
    flex: 1;
    max-width: 140px;
    padding: 6px 10px;
    font-size: 12px;
    font-weight: 500;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    cursor: pointer;
    border-radius: var(--radius);
    font-family: inherit;
    min-height: 32px;
  }
  .mobile-mode-switcher .mobile-mode-btn:first-child { border-right-width: 0; border-radius: var(--radius) 0 0 var(--radius); }
  .mobile-mode-switcher .mobile-mode-btn:last-child { border-radius: 0 var(--radius) var(--radius) 0; }
  .mobile-mode-switcher .mobile-mode-btn.active {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
  }
  .header-btn .header-btn-full,
  .header-toggle .header-btn-full { display: none !important; }
  .header-btn .header-btn-short,
  .header-toggle .header-btn-short { display: inline !important; }
  .split-row { flex-direction: column; gap: 8px; }
  .app[data-mobile-mode="editor"] .split-pane.right-panel { display: none; }
  .app[data-mobile-mode="preview"] .split-pane:not(.right-panel) { display: none; }
  .toolbar-btn-full { display: none !important; }
  .toolbar-btn-emoji { display: inline !important; }
  .design-preset-row .design-theme-full { display: none !important; }
  .design-preset-row .design-theme-short { display: inline !important; }
  .design-preset-row .design-theme-custom-text { display: none !important; }
  .right-panel .panel-body {
    padding-bottom: env(safe-area-inset-bottom, 20px);
  }
  .right-panel .view-theme {
    padding-bottom: env(safe-area-inset-bottom, 20px);
  }
  .materials-nav-row { flex-wrap: wrap; gap: 8px; min-width: 0; }
  .materials-nav-actions { flex-wrap: wrap; min-width: 0; }
  .materials-panel-right { min-width: 0; overflow: hidden; }
  .materials-cards-wrap { min-width: 0; overflow-x: hidden; }
  .materials-cards-grid { min-width: 0; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .materials-search-inline { min-width: 0; flex: 1 1 80px; }
  .materials-modal-body .materials-two-cols { min-width: 0; }

  /* Modals: full width, scrollable body */
  .modal-overlay,
  .design-modal-overlay { padding: 12px; align-items: stretch; }
  .design-modal,
  .design-modal-wide,
  .design-modal-sm,
  .design-modal-settings-share,
  .design-modal-materials,
  .design-modal-new-material,
  .design-modal-share {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
  }
  .design-modal-body,
  .modal-body { overflow-y: auto; flex: 1; min-height: 0; }
  .design-modal-settings-share { min-width: 0; }
  .design-modal-materials { min-width: 0; }
  .materials-modal-body { min-height: 320px; }
  .materials-two-cols { grid-template-columns: 1fr; }
  .materials-panel-left { border-right: none; border-bottom: 1px solid var(--border); padding-right: 0; padding-bottom: 12px; }
  .modal-dialog {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
  }
  .api-key-dialog,
  .diff-dialog,
  .prompt-dialog,
  .upgrade-dialog,
  .feedback-dialog { width: 100%; max-width: 100%; min-width: 0; }
}

.feedback-overlay { z-index: 1100; }
.feedback-dialog {
  max-width: 420px;
  width: 100%;
  font-family: system-ui, -apple-system, Segoe UI, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
.feedback-header { display: flex; justify-content: space-between; align-items: center; padding: 12px 14px; border-bottom: 1px solid var(--border); }
.feedback-header span { font-weight: 600; }
.feedback-close { background: none; border: none; font-size: 1.5rem; cursor: pointer; color: var(--muted); padding: 0 4px; line-height: 1; }
.feedback-close:hover { color: var(--text); }
.feedback-body, .feedback-confirm { padding: 1rem 14px; }
.feedback-category-label, .feedback-text-label { margin: 0 0 0.5rem; font-size: 0.9rem; }
.feedback-categories { display: flex; flex-wrap: wrap; gap: 0.5rem 1rem; margin-bottom: 1rem; }
.feedback-categories label { display: flex; align-items: center; gap: 0.35rem; cursor: pointer; font-size: 0.9rem; }
.feedback-body textarea { width: 100%; padding: 8px; border: 1px solid var(--border); border-radius: var(--radius); font-family: inherit; resize: vertical; margin-bottom: 0.5rem; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }
.feedback-error { color: #b91c1c; font-size: 0.9rem; margin: 0 0 0.5rem; }
.feedback-submit { padding: 8px 16px; background: var(--accent); color: #fff; border: none; border-radius: var(--radius); cursor: pointer; font-size: 14px; }
.feedback-submit:hover { opacity: 0.9; }
.feedback-confirm p { margin: 0; font-size: 1rem; }

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 16px;
}
.panel-header {
  padding: 10px 14px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
}
textarea.import {
  width: 100%;
  min-height: 140px;
  padding: 14px;
  border: none;
  font-family: inherit;
  font-size: 16px;
  resize: vertical;
}
textarea.import:focus { outline: none; }
.view {
  padding: 24px;
  min-height: 200px;
  line-height: 1.65;
}
@media (max-width: 640px) {
  .view { padding: 20px 16px; }
  .tabs-headers button { flex: 1 1 33.333%; }
}
.block { margin-bottom: 1.35em; }
.block:last-child { margin-bottom: 0; }
h1.block, .block.h1 { font-size: 1.75rem; font-weight: 700; margin: 1.5em 0 0.4em; }
h2.block, .block.h2 { font-size: 1.35rem; font-weight: 600; margin: 1.3em 0 0.35em; }
h3.block, .block.h3 { font-size: 1.15rem; font-weight: 600; margin: 1.1em 0 0.3em; }
.block.p { margin: 0.5em 0; }
.view code { background: var(--highlight); padding: 0.15em 0.4em; border-radius: 3px; font-size: 0.9em; font-family: ui-monospace, monospace; }
.view p a,
.view li a,
.view td a,
.view h1 a, .view h2 a, .view h3 a, .view h4 a, .view h5 a, .view h6 a {
  color: var(--accent, #1f3249);
  text-decoration: underline;
}
.view p a:hover, .view li a:hover, .view td a:hover { text-decoration-thickness: 2px; }
.view-theme p a,
.view-theme li a,
.view-theme td a,
.view-theme h1 a, .view-theme h2 a, .view-theme h3 a, .view-theme h4 a, .view-theme h5 a, .view-theme h6 a {
  color: var(--longread-accent, var(--accent, #1f3249));
  text-decoration: underline;
}
.view-theme p a:hover, .view-theme li a:hover, .view-theme td a:hover { text-decoration-thickness: 2px; }
.view pre {
  background: var(--highlight);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.75em 1em;
  border-radius: var(--radius);
  overflow-x: auto;
  margin: 0.75em 0;
  font-size: 0.9em;
  font-family: ui-monospace, monospace;
}
.view pre code { background: transparent; padding: 0; }
.view-theme code { background: var(--longread-important-bg, var(--highlight)); padding: 0.15em 0.4em; border-radius: 3px; font-size: 0.9em; font-family: ui-monospace, monospace; }
.view .sys-cmd, .view-theme .sys-cmd { color: #888; font-style: italic; }
.block.quote,
.view blockquote {
  border-left: 4px solid var(--border);
  margin: 2.25em 0;
  padding-left: 0.75em;
  font-size: 1.2em;
  color: var(--muted);
  font-style: italic;
}
.view-theme blockquote,
.view-theme .block.quote {
  border-left: 4px solid var(--border);
  margin: 2.25em 0;
  padding-left: 0.75em;
  font-size: 1.2em;
  color: var(--longread-text, var(--text));
  font-style: italic;
}
.view blockquote p,
.view-theme blockquote p { margin: 0; }
.block.important {
  margin-left: 5%;
  margin-right: 5%;
  background: var(--highlight);
  border: 1px solid var(--border);
  padding: 12px 16px;
  border-radius: var(--radius);
}
.block.sep,
.view .block.sep,
.view .block-separator {
  height: 0;
  border: none;
  border-top: 1px solid var(--border);
  margin: 1.5em auto;
  width: 80%;
}
.view-theme .block.sep,
.view-theme .block-separator {
  height: 0;
  border: none;
  border-top: 1px solid var(--longread-accent-pale, var(--border));
  margin: 1.5em auto;
  width: 80%;
}
.block.img { margin: 1.5em 0; text-align: center; }
.block.img img { max-width: 100%; height: auto; display: inline-block; border-radius: var(--radius); vertical-align: middle; }
.block.img figcaption { margin-top: 0.5em; font-size: 0.9em; color: var(--muted); }
.block.btn { margin: 1em 0; text-align: center; }
.block.btn a {
  display: inline-block;
  padding: 10px 18px;
  border: 1px solid var(--accent);
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
  font-size: 14px;
  border-radius: var(--radius);
}
.block.btn a:hover { background: var(--accent); color: var(--surface); }
.block.embed { margin: 1.5em 0; display: flex; justify-content: center; flex-wrap: wrap; }
.block.draft-preview {
  margin: 1em 0;
  padding: 12px 16px;
  background: var(--highlight, #f5f5f5);
  border: 1px dashed var(--border, #ccc);
  border-radius: var(--radius);
  font-style: italic;
  color: var(--muted, #666);
}
.block.embed .embed-wrap { position: relative; max-width: 100%; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--border); background: var(--highlight); }
.block.embed .embed-wrap iframe { display: block; max-width: 100%; border: none; }
.block.embed .embed-placeholder { margin: 0; padding: 12px 16px; color: var(--muted); font-size: 0.95em; background: var(--highlight); border: 1px dashed var(--border); border-radius: var(--radius); }
.view-theme .block.embed .embed-wrap { border-color: var(--longread-accent-pale, var(--border)); }
.view-theme .block.embed .embed-placeholder { border-color: var(--longread-accent-pale, var(--border)); }
.view ul, .view-theme ul { margin: 0.75em 0; padding-left: 1.5em; list-style-type: disc; }
.view ol, .view-theme ol { margin: 0.75em 0; padding-left: 1.75em; list-style-type: decimal; }
.view li, .view-theme li { margin: 0.25em 0; }
.view ul ul, .view ol ul, .view ul ol, .view ol ol,
.view-theme ul ul, .view-theme ol ul, .view-theme ul ol, .view-theme ol ol { margin: 0.25em 0; }
.view table, .view-theme table { width: 100%; border-collapse: collapse; margin: 1em 0; font-size: 0.95em; }
.view th, .view td { border: 1px solid var(--border); padding: 8px 12px; text-align: left; }
.view-theme table { border: 1px solid var(--longread-accent-pale, var(--border)); }
.view-theme th, .view-theme td { border: 1px solid var(--longread-accent-pale, var(--border)); padding: 8px 12px; text-align: left; }
.view thead th { background: var(--highlight); font-weight: 400; }
.view tbody tr:nth-child(even) { background: var(--highlight); }
.view-theme thead th { background: var(--longread-bg, var(--bg)); color: var(--longread-accent, var(--text)); font-weight: 500; font-size: calc(1em + 2px); }
.view-theme tbody td { background: var(--longread-bg, var(--bg)); color: var(--longread-text, var(--text)); }
.view-theme tbody tr:nth-child(even) td { background: var(--longread-bg, var(--bg)); }
.accordion { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.accordion-item { border-bottom: 1px solid var(--border); }
.accordion-item:last-child { border-bottom: none; }
.accordion-head {
  width: 100%;
  padding: 12px 16px;
  text-align: left;
  font: inherit;
  font-weight: 500;
  background: var(--surface);
  border: none;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.accordion-head:hover { background: var(--highlight); }
.accordion-head::after { content: "+"; font-size: 1.2em; color: var(--muted); }
.accordion-item.open .accordion-head::after { content: "−"; }
.accordion-body {
  display: none;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  background: var(--surface);
}
.accordion-item.open .accordion-body { display: block; }
.tabs-block { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.tabs-headers {
  display: flex;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--border);
  background: var(--highlight);
}
.tabs-headers button {
  flex: 1 1 25%;
  min-width: 0;
  padding: 10px 8px;
  border: none;
  background: none;
  font: inherit;
  cursor: pointer;
  color: var(--muted);
  border-bottom: 2px solid transparent;
  text-align: center;
}
.tabs-headers button:hover { color: var(--text); }
.tabs-headers button.active { color: var(--text); border-bottom-color: var(--accent); background: var(--surface); }
.tabs-panels { padding: 16px; background: var(--surface); }
.tabs-panel { display: none; }
.tabs-panel.active { display: block; }
.flip-cards { display: flex; flex-wrap: wrap; justify-content: center; gap: 20px; margin: 1.25em 0; width: 100%; }
.flip-card { flex: 1 1 calc((100% - 40px) / 3); max-width: calc((100% - 40px) / 3); min-width: 200px; display: grid; perspective: 600px; cursor: pointer; min-height: 120px; }
/* 1 карточка — 50% ширины контейнера по центру */
.flip-cards .flip-card:only-child {
  flex: 0 1 50%;
  max-width: 50%;
  margin-left: auto;
  margin-right: auto;
}
/* 2 карточки — занимают всю ширину страницы поровну */
.flip-cards .flip-card:nth-last-child(2):first-child,
.flip-cards .flip-card:nth-last-child(2):first-child ~ .flip-card {
  flex: 1 1 calc(50% - 10px);
  max-width: none;
}
.flip-inner {
  grid-area: 1/1;
  display: grid;
  grid-template-areas: "a";
  transition: transform 0.5s;
  transform-style: preserve-3d;
}
.flip-card.flipped .flip-inner { transform: rotateY(180deg); }
.flip-front, .flip-back {
  grid-area: a;
  min-height: 100px;
  position: relative;
  backface-visibility: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  padding-bottom: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  background: var(--surface);
  box-sizing: border-box;
}
.flip-back { transform: rotateY(180deg); background: var(--highlight); }
.flip-card .flip-toggle {
  position: absolute;
  bottom: 8px;
  right: 8px;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  border-radius: 50%;
  font-size: 14px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}
.test-questions { margin: 1em 0; }
.test-questions > .test-block { margin-bottom: 1em; }
.test-questions > .test-block:last-child { margin-bottom: 0; }
.test-block { border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; margin: 1em 0; }
.test-block .test-number { font-size: 11px; color: var(--muted); margin-bottom: 4px; }
.test-block h4 { margin: 0 0 10px; font-size: 1rem; font-weight: 600; }
.test-block .test-submit { margin-top: 12px; text-align: center; }
.test-block .test-submit button,
.test-block .test-answer-btn { padding: 10px 20px; font-size: 14px; font-weight: 600; border: 1px solid var(--accent); background: var(--accent); color: var(--surface); cursor: pointer; border-radius: var(--radius); }
.test-block .test-submit button:hover,
.test-block .test-answer-btn:hover { background: var(--text); border-color: var(--text); }
.view-theme .test-block { border-color: var(--longread-accent-pale, var(--border)); }
.view-theme .test-block .test-submit button,
.view-theme .test-block .test-answer-btn { border-color: var(--longread-accent-pale, var(--border)); background: var(--longread-accent-pale, var(--border)); color: var(--longread-surface-text, var(--longread-text)); }
.view-theme .test-block .test-submit button:hover,
.view-theme .test-block .test-answer-btn:hover { background: var(--longread-accent, var(--accent)); border-color: var(--longread-accent, var(--accent)); color: var(--longread-surface, var(--surface)); }
.test-options, .view .test-options, .view-theme .test-options { list-style: none !important; padding: 0 !important; margin: 0; }
.test-options li, .view .test-options li, .view-theme .test-options li { margin: 6px 0; list-style: none !important; }
.test-options label { cursor: pointer; display: flex; align-items: center; gap: 8px; }
.test-options input { margin: 0; }
.test-feedback { margin-top: 12px; padding: 10px; border-radius: var(--radius); font-size: 14px; display: none; }
.test-feedback.correct { display: block; background: #e8f5e9; border: 1px solid #c8e6c9; color: #2e7d32; }
.test-feedback.incorrect { display: block; background: #ffebee; border: 1px solid #ffcdd2; color: #c62828; }
.test-feedback.neutral { display: block; background: #f5f5f5; border: 1px solid #e0e0e0; color: #666; }
/* API Key: base from .modal-overlay + .modal-dialog */
.api-key-dialog { max-width: 420px; width: 100%; }
.api-key-dialog .api-key-header { padding: 12px 16px; border-bottom: 1px solid var(--border); font-weight: 600; }
.api-key-dialog .api-key-body { padding: 16px; }
.api-key-dialog .api-key-hint { font-size: 12px; color: var(--muted); margin: 0 0 8px; }
.api-key-dialog input { width: 100%; padding: 8px 12px; font-size: 14px; border: 1px solid var(--border); border-radius: var(--radius); box-sizing: border-box; }
.api-model-selector { margin-top: 16px; }
.api-model-selector label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.model-toggle { display: flex; gap: 8px; }
.model-btn { flex: 1; padding: 8px 12px; font-size: 13px; border: 1px solid var(--border); background: var(--surface); cursor: pointer; border-radius: var(--radius); transition: all 0.2s; }
.model-btn:hover { background: var(--highlight); }
.model-btn.active { background: var(--accent); color: var(--surface); border-color: var(--accent); }
.api-key-dialog .api-key-footer { padding: 12px 16px; border-top: 1px solid var(--border); display: flex; gap: 8px; }
.api-key-dialog .api-key-footer button { padding: 8px 16px; font-size: 13px; border: 1px solid var(--border); background: var(--surface); cursor: pointer; border-radius: var(--radius); }
.api-key-dialog .api-key-footer button:hover { background: var(--highlight); }
.api-key-dialog .api-key-footer button.primary { background: var(--accent); color: var(--surface); border-color: var(--accent); }

/* Diff: base from .modal-overlay + .modal-dialog */
.diff-dialog { max-width: 1100px; width: 95%; height: 80vh; }

/* AI Loading Spinner */
.ai-loading-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 250; display: none; align-items: center; justify-content: center; flex-direction: column; gap: 24px; }
.ai-loading-overlay.visible { display: flex; }
.ai-spinner-wrap { position: relative; width: 88px; height: 88px; flex-shrink: 0; }
.ai-spinner { position: absolute; inset: 0; border: 5px solid rgba(255,255,255,0.3); border-top-color: #667eea; border-radius: 50%; animation: ai-spin 1s linear infinite; }
@keyframes ai-spin { to { transform: rotate(360deg); } }
.ai-loading-timer { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); color: #fff; font-size: 24px; font-variant-numeric: tabular-nums; font-weight: 600; pointer-events: none; }
.ai-loading-text { color: #fff; font-size: 17px; font-weight: 500; }
.ai-loading-hint { color: rgba(255,255,255,0.8); font-size: 13px; margin: 0; max-width: 320px; text-align: center; }
.diff-dialog {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  max-width: 1100px;
  width: 95%;
  height: 80vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 8px 24px rgba(0,0,0,0.2);
  font-family: system-ui, -apple-system, Segoe UI, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
.diff-dialog .diff-header { padding: 12px 16px; border-bottom: 1px solid var(--border); font-weight: 600; }
.diff-dialog .diff-body { padding: 16px; overflow: hidden; flex: 1; display: flex; flex-direction: column; }
.diff-dialog .diff-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; flex: 1; min-height: 0; }
.diff-dialog .diff-col { display: flex; flex-direction: column; gap: 4px; min-height: 0; }
.diff-dialog .diff-label { font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase; flex-shrink: 0; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.diff-dialog .diff-counter { font-weight: 400; font-size: 10px; font-variant-numeric: tabular-nums; }
.diff-dialog .diff-body textarea { width: 100%; flex: 1; padding: 12px; font-size: 13px; font-family: inherit; line-height: 1.5; border: 1px solid var(--border); border-radius: var(--radius); resize: none; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }
.diff-dialog .diff-footer { padding: 12px 16px; border-top: 1px solid var(--border); display: flex; gap: 8px; }
.diff-dialog .diff-footer button { padding: 8px 16px; font-size: 13px; border: 1px solid var(--border); background: var(--surface); cursor: pointer; border-radius: var(--radius); }
.diff-dialog .diff-footer button:hover { background: var(--highlight); }
.diff-dialog .diff-footer button.primary { background: var(--accent); color: var(--surface); border-color: var(--accent); }

/* Prompt: base from .modal-overlay + .modal-dialog */
.prompt-dialog {
  max-width: 640px;
  width: 100%;
  max-height: 85vh;
  font-family: system-ui, -apple-system, Segoe UI, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
.prompt-dialog .prompt-header { padding: 12px 16px; border-bottom: 1px solid var(--border); font-weight: 600; display: flex; align-items: center; justify-content: space-between; flex-shrink: 0; gap: 12px; }
.prompt-toggle { display: flex; gap: 4px; }
.prompt-tab { padding: 6px 12px; font-size: 12px; border: 1px solid var(--border); background: var(--surface); color: var(--muted); cursor: pointer; border-radius: var(--radius); font-weight: 500; }
.prompt-tab:hover { background: var(--highlight); color: var(--text); }
.prompt-tab.active { background: var(--accent); color: var(--surface); border-color: var(--accent); }
.prompt-dialog .prompt-body { padding: 16px; overflow: auto; flex: 1; min-height: 0; white-space: pre-wrap; font-size: 13px; line-height: 1.5; font-family: inherit; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }
.prompt-dialog .prompt-footer { padding: 12px 16px; border-top: 1px solid var(--border); flex-shrink: 0; }
.prompt-dialog .prompt-footer button { padding: 8px 16px; font-size: 13px; border: 1px solid var(--border); background: var(--surface); cursor: pointer; border-radius: var(--radius); }
.prompt-dialog .prompt-footer button:hover { background: var(--highlight); }
.prompt-dialog .prompt-footer button.primary { background: var(--accent); color: var(--surface); border-color: var(--accent); }
.prompt-dialog .prompt-footer button.primary:hover { background: var(--text); }

/* Сноски: блок внизу скрыт, по клику — поповер; оформление как блок «Внимание» */
.footnotes { display: none !important; }
.footnote-popover-root { position: fixed; z-index: 300; pointer-events: none; }
.footnote-popover-root .footnote-popover {
  pointer-events: auto; max-width: 360px; padding: 12px 16px;
  background: var(--longread-important-bg, var(--longread-surface, var(--highlight)));
  border: 1px solid var(--longread-accent-pale, var(--border));
  border-radius: var(--radius);
  box-shadow: 0 4px 16px rgba(0,0,0,0.15);
  font-size: 14px; line-height: 1.45;
  color: var(--longread-text, var(--text));
}
.footnote-popover-root .footnote-popover code { background: var(--longread-important-bg, var(--highlight)); }
.view-theme .footnote-popover-root .footnote-popover { margin: 0; }
.footnote-popover-root.footnote-popover-visible .footnote-popover { display: block; }
.footnote-popover-root:not(.footnote-popover-visible) .footnote-popover { display: none; }
a[href^="#footnote-"], [data-footnote-ref] { cursor: pointer; text-decoration: underline; text-decoration-style: dotted; }
/* Подсказки [слово](^ "текст"): пунктир, без вида ссылки, по клику — тот же поповер */
a[href="^"], a[href='^'] {
  color: inherit;
  text-decoration: underline;
  text-decoration-style: dotted;
  cursor: pointer;
}
a[href="^"]:hover, a[href='^']:hover { color: inherit; }
/* Экспорт PDF/Word: слово с верхним индексом номера и пунктиром */
.content-hint-export { text-decoration: underline; text-decoration-style: dotted; }
.hint-export-list { font-size: 0.9em; color: var(--muted, #666); margin-top: 0.25em; padding-left: 1em; }
