:root {
  --primary: #4CAF50;
  --secondary: #FF9800;
  --accent: #2196F3;
  --light-bg: #f9f7f0;
  --white: #ffffff;
  --dark: #333333;
  --border: #d8dee9;
  --muted: #64748b;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

body {
  background-color: var(--light-bg);
  padding: 16px 12px 50px;
  color: var(--dark);
}

/* Верхняя панель в стиле оригинала */
.top-bar {
  max-width: 1420px;
  margin: 0 auto 14px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: nowrap;
  gap: 8px 16px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.09);
  border-radius: 12px;
  padding: 8px 14px;
}

.author-signature {
  color: #fff;
  font-size: 14px;
  background: linear-gradient(135deg, #1e1b4b 0%, #312e81 48%, #4f46e5 100%);
  padding: 7px 14px;
  border-radius: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 10px;
  line-height: 1.25;
  box-shadow: 0 4px 14px rgba(30, 27, 75, 0.25);
}

.logo-mark {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.16);
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.logo-text {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  text-align: left;
}

.logo-sub {
  font-size: 12.5px;
  font-weight: 600;
  opacity: 0.96;
}

.logo-k {
  display: inline-block;
  font-weight: 900;
  font-size: 1.22em;
  background: linear-gradient(135deg, #fde047 0%, #fb923c 50%, #f472b6 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.45));
  letter-spacing: 0.02em;
}

.action-buttons {
  display: flex;
  flex-wrap: wrap;
  flex-wrap: balance;
  gap: 6px;
  align-items: center;
  justify-content: flex-start;
  flex: 1 1 0%;
  min-width: 0;
  padding-top: 4px;
}

.action-buttons .nav-btn {
  background: #f1f5f9;
  color: #334155;
  border: 1px solid #cbd5e1;
  border-radius: 999px;
  padding: 6px 12px;
  font-weight: 600;
  font-size: 12.5px;
  white-space: nowrap;
  flex-shrink: 0;
  transition: all 0.15s ease;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.action-buttons .nav-btn:hover {
  background: #e2e8f0;
  color: #0f172a;
  border-color: #94a3b8;
  transform: translateY(-1px);
}

.action-buttons .nav-btn.active {
  background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
  color: #ffffff;
  border-color: #1d4ed8;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.3);
  outline: none;
}

.action-buttons .nav-btn-external {
  background: #ffffff;
  color: #475569;
  border: 1px dashed #94a3b8;
}

.action-buttons .nav-btn-external:hover {
  background: #eff6ff;
  color: #1d4ed8;
  border-color: #60a5fa;
  border-style: solid;
}

.nav-divider {
  width: 1px;
  height: 20px;
  background: #cbd5e1;
  margin: 0 2px;
  flex-shrink: 0;
}

/* Доступный фокус (:focus-visible) по modern-web-guidance */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid #2563eb;
  outline-offset: 2px;
}

/* Плавные аккордеоны (details/summary) */
details summary {
  transition: color 0.15s ease;
}
details[open] summary {
  color: #1d4ed8;
}

/* Анимация кнопок копирования при клике */
.btn-act.copied {
  background: #15803d !important;
  color: #ffffff !important;
  transition: all 0.2s ease;
}

/* Современная Drag-and-Drop зона для загрузки PDF */
.file-dropzone {
  border: 2px dashed #93c5fd;
  border-radius: 14px;
  background: #eff6ff;
  padding: 24px 16px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
}

.file-dropzone:hover, .file-dropzone.dragover {
  border-color: #2563eb;
  background: #dbeafe;
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.12);
}

.file-dropzone-icon {
  font-size: 32px;
  margin-bottom: 6px;
}

.file-dropzone-title {
  font-size: 14px;
  font-weight: 700;
  color: #1e3a8a;
  margin-bottom: 2px;
}

.file-dropzone-sub {
  font-size: 12px;
  color: #64748b;
}

.file-dropzone input[type="file"] {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.file-dropzone-chosen {
  margin-top: 8px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  background: #dcfce7;
  border: 1px solid #86efac;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  color: #166534;
}

/* Глобальная панель выбора учебника */
.context-bar {
  max-width: 1420px;
  margin: 0 auto 16px;
  background: #ffffff;
  border-radius: 14px;
  padding: 12px 16px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.context-bar label {
  margin: 0;
  font-size: 13px;
  font-weight: 700;
  color: #475569;
}

.context-field {
  display: flex;
  align-items: center;
  gap: 6px;
}

.context-field.grow {
  flex: 1;
  min-width: 240px;
}

.context-bar select {
  padding: 8px 10px;
  font-size: 14px;
  border-radius: 8px;
  border: 1.5px solid #cbd5e1;
  background: #f8fafc;
}

#ctxSubject {
  min-width: 300px;
  max-width: 350px;
}

.context-field.grow select {
  width: 100%;
}

.pill-btn {
  padding: 7px 12px;
  border-radius: 8px;
  border: 1.5px solid #cbd5e1;
  background: #f8fafc;
  color: #1e293b;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.pill-btn:hover { border-color: #3b82f6; background: #eff6ff; color: #1d4ed8; }

/* Двухколоночная рабочая зона */
.workspace {
  max-width: 1420px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(340px, 0.92fr) minmax(420px, 1.15fr);
  gap: 18px;
  align-items: start;
  transition: max-width 0.2s ease;
}

.workspace.reader-hidden {
  grid-template-columns: 1fr;
  max-width: 1560px;
  width: calc(100% - 32px);
  margin: 0 auto;
}

.workspace.reader-hidden #readerPanel {
  display: none;
}

/* Кнопка "Развернуть учебник" рядом с названием раздела (видна только когда панель свёрнута) */
.reader-toggle-studio-btn {
  display: none;
  align-items: center;
  gap: 5px;
  padding: 4px 12px;
  font-size: 12px;
  font-weight: 700;
  border-radius: 999px;
  border: 1.5px solid #3b82f6;
  background: #eff6ff;
  color: #1d4ed8;
  cursor: pointer;
  transition: all 0.15s ease;
  line-height: 1.2;
  white-space: nowrap;
  flex-shrink: 0;
  box-shadow: 0 1px 4px rgba(37, 99, 235, 0.2);
  margin-left: 6px;
  vertical-align: middle;
}

.reader-toggle-studio-btn:hover {
  background: #dbeafe;
  border-color: #2563eb;
  color: #1e40af;
}

.workspace.reader-hidden .reader-toggle-studio-btn {
  display: inline-flex;
}

.reader-toggle-studio-btn .reader-toggle-icon {
  font-size: 12.5px;
}

/* Компактная статусная панель раздела и ИИ */
.studio-status-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 12px;
  padding: 8px 14px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
}

.studio-tab-title {
  font-size: 15px;
  font-weight: 800;
  color: #1e293b;
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  letter-spacing: -0.01em;
}

.studio-ai-controls {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  font-size: 12.5px;
}

.studio-ai-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #15803d;
  font-weight: 600;
}

.studio-ai-status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.2);
}

.studio-ai-provider-wrap {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #475569;
  font-weight: 600;
  border-left: 1px solid #cbd5e1;
  padding-left: 10px;
}

/* Кнопки переключения типа урока (вместо select) */
.lesson-type-card {
  background: #f8fafc;
  border: 1.5px solid #cbd5e1;
  border-radius: 12px;
  padding: 10px 14px;
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.03);
}

.lesson-type-title {
  font-size: 14.5px;
  font-weight: 800;
  color: #0f172a;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  letter-spacing: -0.01em;
  white-space: nowrap;
}

.lesson-type-group {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.lesson-type-btn {
  border: 1px solid #cbd5e1;
  background: #ffffff;
  color: #334155;
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
  white-space: nowrap;
}

.lesson-type-btn:hover {
  border-color: #93c5fd;
  background: #eff6ff;
  color: #1d4ed8;
}

.lesson-type-btn.active {
  background: #2563eb;
  border-color: #2563eb;
  color: #ffffff;
  font-weight: 700;
  box-shadow: 0 2px 6px rgba(37, 99, 235, 0.3);
}

/* Студийная компоновка (Форма ⇄ Результат / Split-View) */
.studio-layout {
  display: block;
  width: 100%;
}

@media (min-width: 1080px) {
  .workspace.reader-hidden .studio-layout {
    display: grid;
    grid-template-columns: minmax(440px, 1.05fr) minmax(460px, 1.25fr);
    gap: 22px;
    align-items: start;
  }

  .workspace.reader-hidden .studio-col-form {
    min-width: 0;
  }

  .workspace.reader-hidden .studio-col-result {
    min-width: 0;
    position: sticky;
    top: 14px;
    max-height: calc(100vh - 28px);
    overflow-y: auto;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding-right: 6px;
  }

  .workspace.reader-hidden .studio-col-result .prompt-box {
    flex: 0 0 auto;
    width: 100%;
    box-sizing: border-box;
    margin-bottom: 0;
  }

  .workspace.reader-hidden .studio-col-result .output-panel {
    margin-top: 0;
    flex: 0 0 auto;
    width: 100%;
    box-sizing: border-box;
  }

  .workspace.reader-hidden .studio-col-result .result-editor {
    box-sizing: border-box;
    min-height: 380px;
    max-height: calc(100vh - 220px);
    resize: vertical;
  }

  .workspace.reader-hidden .studio-col-result .preview-panel,
  .workspace.reader-hidden .studio-col-result .preview-viewport {
    margin-top: 0;
    width: 100%;
    box-sizing: border-box;
  }

  .workspace.reader-hidden .studio-col-result iframe {
    max-height: calc(100vh - 220px);
  }
}

/* Панель учебника */
.reader-panel {
  background: var(--white);
  border-radius: 20px;
  box-shadow: 0 6px 20px rgba(0,0,0,0.09);
  overflow: hidden;
  position: sticky;
  top: 12px;
  max-height: calc(100vh - 30px);
  display: flex;
  flex-direction: column;
}

.reader-header {
  padding: 0;
  background: #f1f5f9;
  border-bottom: 1px solid #e2e8f0;
  display: flex;
  flex-direction: column;
}

.reader-header-main {
  min-height: 46px;
  padding: 8px 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  width: 100%;
  box-sizing: border-box;
}

#readerModeBtn {
  min-width: 130px;
  text-align: center;
  white-space: nowrap;
  flex-shrink: 0;
  cursor: pointer;
  transition: all 0.15s ease;
}

#readerModeBtn.active {
  background: #eff6ff;
  border-color: #3b82f6;
  color: #1d4ed8;
  font-weight: 700;
}

.reader-title-group {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.reader-page-badge {
  font-size: 12px;
  background: #dbeafe;
  color: #1d4ed8;
  padding: 2px 8px;
  border-radius: 999px;
  font-weight: 700;
}

.reader-mode-toggle {
  display: inline-flex;
  background: #e2e8f0;
  padding: 3px;
  border-radius: 9px;
  gap: 2px;
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.06);
  flex-shrink: 0;
}

.reader-toggle-btn {
  border: none;
  background: transparent;
  color: #475569;
  font-size: 12.5px;
  font-weight: 700;
  padding: 5px 12px;
  border-radius: 7px;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.reader-toggle-btn:hover {
  color: #0f172a;
}

.reader-toggle-btn.active {
  background: #ffffff;
  color: #1d4ed8;
  box-shadow: 0 1px 4px rgba(0,0,0,0.12);
}

.reader-pdf-subbar {
  padding: 6px 14px;
  background: #f8fafc;
  border-top: 1px solid #e2e8f0;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: space-between;
  font-size: 12px;
  box-sizing: border-box;
}

.reader-subbar-group {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.pill-btn.sub-btn {
  padding: 3px 8px;
  font-size: 11px;
  line-height: 1.1;
  background: #ffffff;
}

.reader-body {
  padding: 18px 20px;
  overflow-y: auto;
  line-height: 1.65;
  font-size: 15px;
}

.book-meta {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin-bottom: 4px;
}

.reader-body .book-title {
  font-size: 19px;
  font-weight: 800;
  color: #0f172a;
  margin-bottom: 12px;
}

.book-text p { margin-bottom: 12px; }

.rule-box {
  background: #fefce8;
  border-left: 4px solid #f59e0b;
  padding: 12px 14px;
  border-radius: 0 10px 10px 0;
  margin: 12px 0;
  font-size: 14px;
}

.rule-box strong { color: #92400e; display: block; margin-bottom: 4px; }

.questions-box {
  background: #f8fafc;
  border: 1px dashed #cbd5e1;
  padding: 12px 14px;
  border-radius: 10px;
  margin-top: 12px;
  font-size: 14px;
}

.questions-box ul { padding-left: 18px; margin-top: 6px; }
.questions-box li { margin-bottom: 4px; }

.reader-footer {
  padding: 10px 16px;
  border-top: 1px solid #e2e8f0;
  background: #f8fafc;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 12.5px;
  color: var(--muted);
}

.pdf-pages-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.pdf-pages-list img {
  width: 100%;
  border-radius: 8px;
  border: 1px solid #cbd5e1;
}

/* Основная карточка генератора — спокойный современный Slate-дизайн */
.container {
  background: var(--white);
  border-radius: 18px;
  padding: 22px;
  border: 1px solid #e2e8f0;
  box-shadow: 0 4px 16px rgba(15, 23, 42, 0.05);
}

h1 {
  text-align: center;
  color: #0f172a;
  margin-bottom: 14px;
  font-size: 21px;
  font-weight: 800;
  line-height: 1.3;
}

h2 {
  margin: 18px 0 10px;
  color: #1e293b;
  font-size: 16.5px;
  font-weight: 700;
}

.field-group {
  margin-bottom: 12px;
}

label.field-label {
  display: block;
  margin: 8px 0 5px;
  font-weight: 600;
  font-size: 13.5px;
  color: #334155;
}

input[type="text"],
input[type="number"],
input[type="password"],
select,
textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1.5px solid #cbd5e1;
  border-radius: 10px;
  font-size: max(1rem, 15px);
  background: #ffffff;
  color: #0f172a;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input[type="text"]:focus,
input[type="number"]:focus,
input[type="password"]:focus,
select:focus,
textarea:focus {
  border-color: #3b82f6;
  outline: none;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.12);
}

input:focus-visible,
select:focus-visible,
textarea:focus-visible,
button:focus-visible {
  outline: 2px solid #2563eb;
  outline-offset: 2px;
}

input:user-invalid,
textarea:user-invalid {
  border-color: #dc2626;
}

textarea {
  min-height: 86px;
  resize: vertical;
}

fieldset.param-fieldset {
  border: none;
  margin: 10px 0;
}

fieldset.param-fieldset legend {
  font-weight: 700;
  font-size: 14px;
  margin-bottom: 8px;
  color: #1e293b;
}

.checkbox-group, .radio-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 6px;
}

.checkbox-item, .radio-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  padding: 6px 11px;
  border-radius: 10px;
  font-size: 13px;
  color: #334155;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.checkbox-item:hover, .radio-item:hover {
  background: #eff6ff;
  border-color: #bfdbfe;
}

.params-container {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin: 12px 0;
}

.params-section {
  border-radius: 12px;
  padding: 13px 14px;
  border: 1px solid #e2e8f0;
  border-left: 4px solid #16a34a;
  background: #f8fafc;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
}

.params-section.s-green { background: #f0fdf4; border-color: #dcfce7; border-left: 4px solid #16a34a; }
.params-section.s-blue  { background: #eff6ff; border-color: #dbeafe; border-left: 4px solid #2563eb; }
.params-section.s-amber { background: #fffbeb; border-color: #fef3c7; border-left: 4px solid #d97706; }

.params-section h3 {
  margin-bottom: 10px;
  font-size: 14.5px;
  font-weight: 700;
  color: #0f172a;
  padding-bottom: 6px;
  border-bottom: 1px solid rgba(15, 23, 42, 0.08);
}

.params-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 8px;
}

.tip-box {
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-left: 4px solid #f59e0b;
  color: #78350f;
  padding: 10px 14px;
  border-radius: 10px;
  margin: 10px 0;
  font-size: 13px;
  font-weight: 600;
}

.suggestions-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 8px 0 14px;
}

.chip-btn {
  padding: 6px 12px;
  border-radius: 999px;
  border: 1.5px solid #cbd5e1;
  background: #ffffff;
  color: #334155;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.chip-btn:hover { border-color: #3b82f6; background: #eff6ff; color: #1d4ed8; }
.chip-btn.active { background: #dbeafe; border-color: #2563eb; color: #1d4ed8; font-weight: 700; }

.button-group {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 16px;
}

.btn-act {
  flex: 1;
  min-width: 140px;
  padding: 10px 14px;
  font-size: 13.5px;
  border-radius: 10px;
  font-weight: 700;
  cursor: pointer;
  border: 1.5px solid transparent;
  color: #1e293b;
  background: #f1f5f9;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all 0.15s ease;
}

.btn-act:hover:not(:disabled) { transform: translateY(-1px); }
.btn-act:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-ai {
  background: linear-gradient(135deg, #4f46e5, #7c3aed);
  color: #ffffff;
  border-color: transparent;
  flex: 2 1 240px;
  min-width: 210px;
  padding: 10px 16px;
  box-shadow: 0 2px 8px rgba(79, 70, 229, 0.28);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
  line-height: 1.25;
}
.btn-ai-label {
  white-space: nowrap;
  font-weight: 700;
}
.btn-prompt { background: #eff6ff; color: #1d4ed8; border-color: #93c5fd; }
.btn-prompt:hover:not(:disabled) { background: #dbeafe; border-color: #60a5fa; }
.btn-copy   { background: #f0fdf4; color: #15803d; border-color: #86efac; }
.btn-copy:hover:not(:disabled) { background: #dcfce7; border-color: #4ade80; }
.btn-qwen   { background: #faf5ff; color: #7e22ce; border-color: #d8b4fe; }
.btn-qwen:hover:not(:disabled) { background: #f3e8ff; border-color: #c084fc; }
.btn-save   { background: #f0fdfa; color: #0f766e; border-color: #5eead4; }
.btn-save:hover:not(:disabled) { background: #ccfbf1; border-color: #2dd4bf; }
.btn-export { background: #fff7ed; color: #c2410c; border-color: #fdba74; }
.btn-export:hover:not(:disabled) { background: #ffedd5; border-color: #fb923c; }

/* Блок промпта (с возможностью редактирования) */
.prompt-box {
  background: #eff6ff;
  border: 2px dashed #60a5fa;
  border-radius: 12px;
  padding: 12px 14px;
  box-sizing: border-box;
  width: 100%;
  max-width: 100%;
  margin-top: 14px;
}

.prompt-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
}

.prompt-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  background: #dbeafe;
  color: #1d4ed8;
  display: inline-block;
  transition: all 0.15s ease;
}

.prompt-badge.edited {
  background: #fef3c7;
  color: #b45309;
  border: 1px solid #f59e0b;
}

.prompt-editor {
  width: 100%;
  box-sizing: border-box;
  min-height: 120px;
  max-height: 240px;
  overflow-y: auto;
  resize: vertical;
  font-family: Consolas, 'Courier New', monospace;
  font-size: 12.5px;
  line-height: 1.45;
  color: #1e293b;
  background: #ffffff;
  border: 1px solid #93c5fd;
  border-radius: 8px;
  padding: 10px 12px;
}

.prompt-editor:focus {
  border-color: #2563eb;
  outline: none;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.output-panel {
  box-sizing: border-box;
  width: 100%;
  max-width: 100%;
  margin-top: 16px;
  border: 2px dashed #93c5fd;
  background: #f8fafc;
  border-radius: 12px;
  padding: 14px;
}

.output-panel pre, .result-editor {
  width: 100%;
  box-sizing: border-box;
  min-height: 150px;
  font-family: Consolas, monospace;
  font-size: 13px;
  white-space: pre-wrap;
  background: #fff;
  padding: 12px;
  border-radius: 8px;
  border: 1px solid #cbd5e1;
}

.preview-viewport {
  width: 100%;
  position: relative;
  overflow: hidden;
  border: 2px solid #cbd5e1;
  border-radius: 12px;
  background: #ffffff;
  margin-top: 10px;
}

.preview-frame-scaled {
  position: absolute;
  top: 0;
  left: 0;
  border: none;
  transform-origin: top left;
  background: #ffffff;
}

/* Шаги мастера интерактива */
.step { display: none; }
.step.active { display: block; }
.step-indicator {
  display: flex;
  justify-content: flex-start;
  flex-wrap: wrap;
  gap: 6px;
  margin: 12px 0 14px;
}
.step-dot {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 10px;
  border-radius: 999px;
  border: 1px solid #cbd5e1;
  background: #f8fafc;
  color: #475569;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
}
.step-dot:hover {
  background: #eff6ff;
  border-color: #93c5fd;
  color: #1d4ed8;
}
.step-dot.active {
  background: #2563eb;
  border-color: #1d4ed8;
  color: #ffffff;
  font-weight: 700;
  box-shadow: 0 2px 6px rgba(37, 99, 235, 0.25);
}
.step-dot.completed {
  background: #dcfce7;
  border-color: #86efac;
  color: #166534;
}
.step-navigation { display: flex; justify-content: space-between; margin-top: 14px; gap: 10px; }

/* Таблицы и карточки архива/учебников — современная адаптивная сетка */
.card-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 16px;
  margin-top: 14px;
}

/* Карточка учебника в сетке */
.book-grid-card {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 14px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}
.book-grid-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.08);
  border-color: #93c5fd;
}
.book-card-top {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}
.book-icon-badge {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: #eff6ff;
  color: #2563eb;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
  box-shadow: inset 0 0 0 1px rgba(37, 99, 235, 0.12);
}
.book-title-wrap {
  flex: 1;
  min-width: 0;
}
.book-grid-card .book-title {
  font-size: 14.5px;
  font-weight: 700;
  color: #0f172a;
  line-height: 1.35;
  margin-bottom: 6px;
  word-break: break-word;
}
.book-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  align-items: center;
}
.meta-tag {
  font-size: 11.5px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 6px;
  background: #f1f5f9;
  color: #475569;
}
.meta-tag.grade {
  background: #eff6ff;
  color: #1d4ed8;
  font-weight: 700;
}
.meta-tag.subject {
  background: #f0fdf4;
  color: #166534;
}
.meta-tag.lang {
  background: #fdf2f8;
  color: #9d174d;
}
.meta-tag.pages {
  background: #f8fafc;
  color: #64748b;
  border: 1px solid #e2e8f0;
}
.book-card-middle {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 12px;
  background: #f8fafc;
  border-radius: 10px;
  border: 1px solid #f1f5f9;
}
.book-pref-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 6px;
  font-size: 12px;
  color: #475569;
}
.book-offset-row {
  font-size: 11.5px;
  color: #64748b;
  display: flex;
  align-items: center;
  gap: 4px;
}
.book-card-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  padding-top: 4px;
}
.book-card-actions .pill-btn {
  flex: 1;
  text-align: center;
  justify-content: center;
  padding: 7px 10px;
  font-size: 12.5px;
}
.book-card-actions .btn-open {
  background: #2563eb;
  color: #ffffff;
  border-color: #2563eb;
  font-weight: 700;
}
.book-card-actions .btn-open:hover {
  background: #1d4ed8;
  border-color: #1d4ed8;
  color: #ffffff;
}
.book-card-actions .btn-pdf {
  background: #f0fdf4;
  border-color: #86efac;
  color: #15803d;
  font-weight: 600;
  text-decoration: none;
}
.book-card-actions .btn-pdf:hover {
  background: #dcfce7;
}
.book-card-actions .btn-del {
  flex: 0 0 auto;
  color: #b91c1c;
  padding: 7px 10px;
}
.book-card-actions .btn-del:hover {
  background: #fef2f2;
  border-color: #fca5a5;
}

/* Карточка сохранённого материала в архиве */
.material-grid-card {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 12px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}
.material-grid-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.08);
  border-color: #93c5fd;
}
.material-card-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.material-kind-pill {
  font-size: 12px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.material-kind-pill.lesson { background: #dbeafe; color: #1e40af; }
.material-kind-pill.worksheet { background: #dcfce7; color: #166534; }
.material-kind-pill.visual { background: #fef3c7; color: #92400e; }
.material-kind-pill.interactive { background: #f3e8ff; color: #6b21a8; }

.material-status-pill {
  font-size: 11.5px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.15s ease;
}
.material-status-pill.pub {
  background: #f0fdf4;
  border-color: #86efac;
  color: #166534;
}
.material-status-pill.pub:hover {
  background: #dcfce7;
}
.material-status-pill.priv {
  background: #f1f5f9;
  border-color: #cbd5e1;
  color: #475569;
}
.material-status-pill.priv:hover {
  background: #e2e8f0;
}
.material-status-pill .status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  display: inline-block;
}
.material-status-pill.pub .status-dot {
  background: #22c55e;
  box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.25);
}
.material-status-pill.priv .status-dot {
  background: #94a3b8;
}

.material-card-title {
  font-size: 15.5px;
  font-weight: 700;
  color: #0f172a;
  line-height: 1.35;
  margin: 2px 0 6px;
  word-break: break-word;
}
.material-card-meta {
  font-size: 12px;
  color: #64748b;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.material-card-actions {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
  padding-top: 8px;
  border-top: 1px solid #f1f5f9;
}
.material-card-actions .pill-btn {
  flex: 1;
  text-align: center;
  justify-content: center;
  padding: 6px 10px;
  font-size: 12px;
  white-space: nowrap;
}
.material-card-actions .btn-open {
  background: #2563eb;
  color: #ffffff;
  border-color: #2563eb;
  font-weight: 700;
}
.material-card-actions .btn-open:hover {
  background: #1d4ed8;
  border-color: #1d4ed8;
  color: #ffffff;
}
.material-card-actions .btn-window {
  background: #eff6ff;
  color: #1d4ed8;
  border-color: #bfdbfe;
  text-decoration: none;
}
.material-card-actions .btn-qr {
  flex: 0 0 auto;
  background: #f5f3ff;
  color: #6d28d9;
  border-color: #ddd6fe;
}
.material-card-actions .btn-del {
  flex: 0 0 auto;
  color: #b91c1c;
}
.material-card-actions .btn-del:hover {
  background: #fef2f2;
  border-color: #fca5a5;
}

/* Баннеры и тулбары разделов библиотеки и архива */
.section-banner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid #e2e8f0;
}
.section-banner-title {
  font-size: 18px;
  font-weight: 800;
  color: #0f172a;
  display: flex;
  align-items: center;
  gap: 8px;
}
.section-banner-subtitle {
  font-size: 13px;
  color: #64748b;
  margin-top: 2px;
  font-weight: normal;
}
.section-toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 10px 16px;
  margin-bottom: 16px;
}
.toolbar-group {
  display: flex;
  align-items: center;
  gap: 6px;
}
.toolbar-badge {
  margin-left: auto;
  font-size: 12.5px;
  font-weight: 700;
  color: #1d4ed8;
  background: #dbeafe;
  padding: 3px 10px;
  border-radius: 999px;
}

/* Форма загрузки учебника */
.book-upload-card {
  max-width: 1080px;
  margin: 32px 0 16px;
  background: #f0fdf4;
  border: 2px dashed #86efac;
  border-radius: 16px;
  padding: 20px 24px;
  box-sizing: border-box;
}
.book-upload-card h3 {
  margin-top: 0;
  margin-bottom: 8px;
  color: #166534;
  font-size: 16px;
}

/* Пустое состояние */
.empty-state-box {
  grid-column: 1 / -1;
  text-align: center;
  padding: 36px 20px;
  background: #f8fafc;
  border: 1px dashed #cbd5e1;
  border-radius: 14px;
  color: #64748b;
}
.empty-state-icon {
  font-size: 32px;
  margin-bottom: 8px;
}
.empty-state-title {
  font-size: 15px;
  font-weight: 700;
  color: #334155;
  margin-bottom: 4px;
}
.empty-state-text {
  margin: 0;
  font-size: 13px;
  color: #64748b;
}

/* Совместимость со старыми item-card */
.item-card {
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  padding: 14px 16px;
  background: #ffffff;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.tab-pane { display: none; }
.tab-pane.active { display: block; }
.hidden { display: none !important; }

.status-toast {
  position: fixed;
  bottom: 18px;
  right: 18px;
  z-index: 2000;
  background: #1e293b;
  color: #fff;
  padding: 12px 18px;
  border-radius: 10px;
  font-weight: 600;
  box-shadow: 0 8px 25px rgba(0,0,0,0.25);
  max-width: 380px;
}
.status-toast.ok { background: #15803d; }
.status-toast.err { background: #b91c1c; }

/* Нативный dialog согласно modern-web-guidance */
dialog:modal {
  overscroll-behavior: contain;
  margin: auto;
  border: none;
  border-radius: 18px;
  padding: 22px;
  max-width: 520px;
  width: calc(100% - 24px);
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

dialog.wide-modal:modal {
  max-width: 1120px;
  width: calc(100% - 24px);
}

dialog::backdrop {
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(2px);
  overflow: hidden;
  overscroll-behavior: contain;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}

.modal-header h1, .modal-header h2 {
  margin: 0;
  font-size: 19px;
  text-align: left;
  color: #0f172a;
}

@media (max-width: 1020px) {
  .workspace { grid-template-columns: 1fr; }
  .reader-panel { position: static; max-height: 440px; }
}

/* Мобильная адаптация панели выбора учебника (Контекст-бар) и шапки */
@media (max-width: 860px) {
  .context-bar {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    gap: 10px 12px !important;
    padding: 12px 14px !important;
    border-radius: 14px !important;
    align-items: stretch !important;
  }

  .context-field {
    display: flex;
    flex-direction: column !important;
    align-items: stretch !important;
    width: 100% !important;
    min-width: 0 !important;
    gap: 4px !important;
  }

  /* Если поле скрыто (например, "Книга / часть", когда у предмета только 1 часть или нет других книг) — скрываем его */
  #ctxBookField[style*="display: none"],
  #ctxBookField[style*="display:none"],
  .context-field[style*="display: none"],
  .context-field[style*="display:none"],
  .context-field.hidden,
  .context-field[hidden] {
    display: none !important;
  }

  .context-field label {
    font-size: 11px !important;
    font-weight: 700 !important;
    color: #64748b !important;
    text-transform: uppercase !important;
    letter-spacing: 0.04em !important;
    margin: 0 !important;
    display: block !important;
    line-height: 1.2 !important;
  }

  .context-field select {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
    height: 42px !important;
    padding: 8px 10px !important;
    font-size: 16px !important;
    border-radius: 8px !important;
    border: 1.5px solid #cbd5e1 !important;
    background-color: #f8fafc !important;
    color: #0f172a !important;
  }

  /* Ряд 1: Класс (50%) и Язык (50%) аккуратно рядом */
  #ctxGradeField {
    order: 1 !important;
    grid-column: 1 / 2 !important;
  }

  #ctxLangField {
    order: 2 !important;
    grid-column: 2 / 3 !important;
  }

  /* Ряд 2: Предмет — 100% на всю ширину (максимум места для длинных названий) */
  #ctxSubjectField {
    order: 3 !important;
    grid-column: 1 / -1 !important;
    width: 100% !important;
  }

  #ctxSubject {
    min-width: 0 !important;
    max-width: 100% !important;
    width: 100% !important;
  }

  /* Ряд 3: Книга / часть (если есть) — 100% на всю ширину */
  #ctxBookField {
    order: 4 !important;
    grid-column: 1 / -1 !important;
    width: 100% !important;
  }

  #ctxBook {
    max-width: 100% !important;
    width: 100% !important;
  }

  /* Ряд 4: Тема урока из учебника — 100% на всю ширину */
  #ctxChapterField {
    order: 5 !important;
    grid-column: 1 / -1 !important;
    min-width: 0 !important;
    width: 100% !important;
  }

  #ctxChapter {
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
  }

  /* Адаптация плашки студии и заголовка */
  .studio-status-bar {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 8px !important;
  }

  .studio-tab-title {
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    width: 100% !important;
  }

  .studio-ai-controls {
    justify-content: space-between !important;
    width: 100% !important;
    border-top: 1px solid #e2e8f0 !important;
    padding-top: 6px !important;
  }
}

/* Подвал сайта */
.app-footer {
  max-width: 1420px;
  margin: 36px auto 0;
  padding: 18px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  border-top: 1px solid #e2e8f0;
  font-size: 13px;
  color: #64748b;
}

.footer-author {
  display: inline-flex;
  align-items: center;
  padding: 6px 16px;
  border-radius: 999px;
  background: radial-gradient(circle at 0% 50%, rgba(37, 99, 235, 0.22), transparent 60%),
              radial-gradient(circle at 100% 50%, rgba(249, 115, 22, 0.22), transparent 60%),
              #090d16;
  border: 1px solid rgba(255, 255, 255, 0.14);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.25);
}

.footer-gradient-text {
  font-size: 13.5px;
  font-weight: 800;
  letter-spacing: 0.03em;
  background: linear-gradient(90deg, #38bdf8 0%, #60a5fa 32%, #fb923c 72%, #f97316 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  -webkit-text-fill-color: transparent;
  display: inline-block;
}

/* Школьный Rich-Text редактор и загрузка фото */
.rich-editor-wrap {
  border: 2px solid #cbd5e1;
  border-radius: 12px;
  overflow: hidden;
  background: #ffffff;
}
.rich-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  padding: 6px 8px;
  background: #f1f5f9;
  border-bottom: 1px solid #cbd5e1;
}
.rich-btn {
  padding: 4px 8px;
  border-radius: 6px;
  border: 1px solid #cbd5e1;
  background: #ffffff;
  color: #1e293b;
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
  line-height: 1.2;
}
.rich-btn:hover { background: #eff6ff; border-color: #3b82f6; }
.rich-btn-stress {
  background: #fef3c7;
  border-color: #f59e0b;
  color: #92400e;
}
.rich-btn-color {
  width: 24px;
  height: 24px;
  padding: 0;
  border-radius: 999px;
  border: 2px solid #ffffff;
  box-shadow: 0 0 0 1px #cbd5e1;
  cursor: pointer;
}
.rich-btn-color:hover { transform: scale(1.12); }
.rich-sep {
  width: 1px;
  height: 20px;
  background: #cbd5e1;
  margin: 0 3px;
}
.rich-surface {
  min-height: 170px;
  max-height: 320px;
  overflow-y: auto;
  padding: 12px 14px;
  font-size: 15px;
  line-height: 1.65;
  color: #0f172a;
  outline: none;
}
.rich-surface:empty::before {
  content: attr(data-placeholder);
  color: #94a3b8;
  pointer-events: none;
}
.rich-surface p { margin: 0 0 8px; }
.rich-surface ul, .rich-surface ol { padding-left: 22px; margin: 4px 0 8px; }

.photo-dropzone {
  border: 2px dashed #94a3b8;
  border-radius: 12px;
  padding: 12px;
  background: #f8fafc;
  transition: border-color 0.15s, background 0.15s;
}
.photo-dropzone.dragover {
  border-color: #3b82f6;
  background: #eff6ff;
}
.photo-drop-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: #475569;
}
.photo-thumbs-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(145px, 1fr));
  gap: 10px;
  margin-top: 10px;
}
.photo-thumb-card {
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  background: #ffffff;
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.photo-thumb-card img {
  width: 100%;
  height: 110px;
  object-fit: cover;
  border-radius: 6px;
  background: #e2e8f0;
  cursor: pointer;
}
.photo-thumb-meta {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
}
.photo-thumb-meta input {
  padding: 3px 6px;
  font-size: 12px;
  border-radius: 6px;
  border: 1px solid #cbd5e1;
}
.photo-thumb-controls {
  display: flex;
  justify-content: space-between;
  gap: 4px;
}
.photo-thumb-controls button {
  padding: 2px 6px;
  font-size: 11px;
  border-radius: 5px;
  border: 1px solid #cbd5e1;
  background: #f8fafc;
  cursor: pointer;
}

.mode-switch-group {
  display: inline-flex;
  align-items: center;
  background: #e2e8f0;
  border-radius: 8px;
  padding: 2px;
  gap: 2px;
}
.mode-switch-btn {
  border: none;
  background: transparent;
  color: #475569;
  font-size: 11.5px;
  font-weight: 700;
  padding: 4px 8px;
  border-radius: 6px;
  cursor: pointer;
}
.mode-switch-btn.active {
  background: #ffffff;
  color: #0f172a;
  box-shadow: 0 1px 3px rgba(0,0,0,0.12);
}

.manual-page-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  background: #fef3c7;
  color: #92400e;
  padding: 2px 8px;
  border-radius: 6px;
  margin-bottom: 4px;
}


/* ========================================================
   Авторизация, роли (RBAC) и панель управления
   ======================================================== */

.top-bar-left {
  display: inline-flex;
  flex-direction: column;
  align-items: stretch;
  gap: 5px;
  flex-shrink: 0;
}

.auth-bar {
  display: flex;
  align-items: center;
  width: 100%;
  gap: 6px;
}

.auth-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 4px 12px;
  font-size: 12px;
  font-weight: 600;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.15s ease;
  border: none;
  line-height: 1.2;
}

.login-header-btn {
  width: 100%;
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  color: #ffffff;
  box-shadow: 0 2px 6px rgba(37, 99, 235, 0.25);
}

.login-header-btn:hover {
  background: linear-gradient(135deg, #1d4ed8, #1e40af);
  transform: translateY(-1px);
  box-shadow: 0 4px 10px rgba(37, 99, 235, 0.35);
}

.user-badge-wrap {
  width: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  background: #f8fafc;
  border: 1px solid #cbd5e1;
  padding: 2px 5px 2px 9px;
  border-radius: 999px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.user-info {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: #1e293b;
  font-weight: 600;
  min-width: 0;
}

.user-icon {
  font-size: 13.5px;
  line-height: 1;
}

.user-name {
  max-width: 135px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-role-pill {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  background: #e0f2fe;
  color: #0369a1;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.user-role-pill.admin {
  background: #fef3c7;
  color: #b45309;
}

.user-quota-pill {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  background: #f1f5f9;
  color: #475569;
  border: 1px solid #e2e8f0;
}

.user-quota-pill.warning {
  background: #fee2e2;
  color: #b91c1c;
  border-color: #fca5a5;
}

.admin-header-btn {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  background: #f1f5f9;
  color: #334155;
  border: 1px solid #cbd5e1;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 600;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.15s ease;
  line-height: 1.2;
}

.admin-header-btn:hover {
  background: #e2e8f0;
  color: #0f172a;
  border-color: #94a3b8;
}

.logout-header-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1px solid #cbd5e1;
  background: #ffffff;
  color: #64748b;
  cursor: pointer;
  padding: 0;
  transition: all 0.15s ease;
  line-height: 1;
  flex-shrink: 0;
}

.logout-header-btn svg {
  display: block;
}

.logout-header-btn:hover {
  background: #fee2e2;
  border-color: #fca5a5;
  color: #dc2626;
  transform: scale(1.08);
}

/* Гостевая заглушка в читалке */
.guest-reader-notice {
  text-align: center;
  padding: 36px 20px;
  background: #f8fafc;
  border: 1.5px dashed #cbd5e1;
  border-radius: 16px;
  margin: 16px 0;
}

.guest-notice-icon {
  font-size: 42px;
  margin-bottom: 12px;
}

.guest-reader-notice h3 {
  font-size: 17px;
  color: #1e293b;
  margin: 0 0 8px;
  font-weight: 700;
}

.guest-reader-notice p {
  font-size: 13.5px;
  color: #64748b;
  line-height: 1.5;
  max-width: 480px;
  margin: 0 auto 10px;
}

.guest-reader-notice .guest-notice-tip {
  font-size: 12.5px;
  color: #1d4ed8;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  padding: 8px 14px;
  border-radius: 8px;
  margin: 12px auto 16px;
  display: inline-block;
  text-align: left;
}

/* Панель администратора (модальное окно) */
.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  text-align: left;
}

.admin-table th {
  background: #f8fafc;
  color: #475569;
  font-weight: 700;
  border-bottom: 2px solid #e2e8f0;
  padding: 10px 12px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.admin-table td {
  padding: 10px 12px;
  border-bottom: 1px solid #f1f5f9;
  vertical-align: middle;
}

.admin-table tr:hover td {
  background: #f8fafc;
}

.status-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
}

.status-badge.active {
  background: #dcfce7;
  color: #15803d;
}

.status-badge.blocked {
  background: #fee2e2;
  color: #b91c1c;
}

.btn-table-action {
  padding: 3px 8px;
  font-size: 11.5px;
  font-weight: 600;
  border-radius: 6px;
  border: 1px solid #cbd5e1;
  background: #ffffff;
  color: #334155;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-table-action:hover {
  background: #f1f5f9;
  border-color: #94a3b8;
}

.btn-table-action.danger:hover {
  background: #fee2e2;
  border-color: #fca5a5;
  color: #b91c1c;
}

@media (max-width: 820px) {
  .top-bar {
    flex-wrap: wrap;
    padding: 10px 14px;
    gap: 10px;
  }
  .top-bar-left {
    flex-direction: row;
    width: 100%;
    justify-content: space-between;
    align-items: center;
    flex-wrap: nowrap;
  }
  .auth-bar {
    width: auto;
    flex-shrink: 0;
  }
  .login-header-btn,
  .user-badge-wrap {
    width: auto;
  }
  .action-buttons {
    flex: 1 1 100%;
    width: 100%;
    justify-content: center;
    flex-wrap: wrap;
    flex-wrap: balance;
    gap: 6px;
    padding-top: 0;
    padding-bottom: 0;
  }
  .nav-divider {
    display: none;
  }
}

@media (max-width: 640px) {
  .top-bar {
    padding: 8px 10px;
    gap: 8px;
  }
  .top-bar-left {
    width: 100%;
    justify-content: space-between;
    align-items: center;
    flex-wrap: nowrap;
    gap: 8px;
  }
  .action-buttons {
    width: 100%;
    justify-content: center;
    flex-wrap: wrap;
    flex-wrap: balance;
    gap: 5px;
  }
  .action-buttons .nav-btn {
    padding: 5px 10px !important;
    font-size: 12px !important;
  }
  .btn-act.btn-ai {
    flex: 1 1 100%;
    width: 100%;
    min-width: 0;
  }
  .author-signature {
    padding: 6px 10px;
    gap: 8px;
  }
  .logo-mark {
    width: 28px;
    height: 28px;
  }
  .logo-mark svg {
    width: 18px;
    height: 18px;
  }
  .logo-text {
    font-size: 13px;
  }
  .logo-sub {
    font-size: 11px;
  }
  .auth-bar {
    width: auto;
    flex-shrink: 0;
  }
  .user-badge-wrap {
    padding: 3px 8px;
    gap: 6px;
  }
  .user-name {
    max-width: 120px;
    font-size: 12px;
  }
}

@media (max-width: 420px) {
  .action-buttons {
    gap: 4px;
  }
  .action-buttons .nav-btn {
    padding: 4px 8px !important;
    font-size: 11px !important;
  }
  .author-signature {
    padding: 5px 8px;
    gap: 6px;
  }
  .logo-text {
    font-size: 12px;
  }
  .logo-sub {
    font-size: 10px;
  }
  .user-name {
    max-width: 95px;
    font-size: 11.5px;
  }
  .auth-btn {
    padding: 5px 10px;
    font-size: 12px;
  }
}

/* ========================================================
   Заглушки закрытых разделов и компактные кнопки квоты
   ======================================================== */

.nav-lock-icon {
  font-size: 11px;
  margin-left: 2px;
  opacity: 0.85;
}

.btn-quota-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 11px;
  opacity: 0.96;
  font-weight: 700;
  margin-left: 6px;
  background: rgba(0, 0, 0, 0.24);
  padding: 2px 8px;
  border-radius: 999px;
  letter-spacing: 0.02em;
  white-space: nowrap;
  flex-shrink: 0;
  vertical-align: middle;
}

.guest-locked-section {
  text-align: center;
  padding: 48px 24px;
  background: #ffffff;
  border: 1.5px dashed #cbd5e1;
  border-radius: 16px;
  max-width: 660px;
  margin: 30px auto;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.03);
}

.guest-locked-icon {
  font-size: 46px;
  margin-bottom: 12px;
}

.guest-locked-section h3 {
  font-size: 18px;
  font-weight: 700;
  color: #1e293b;
  margin: 0 0 10px;
}

.guest-locked-section p {
  font-size: 14px;
  color: #64748b;
  line-height: 1.55;
  margin: 0 0 16px;
}

.guest-locked-tip {
  font-size: 12.5px;
  color: #1d4ed8;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  padding: 8px 14px;
  border-radius: 8px;
  margin: 0 auto 22px;
  max-width: 500px;
  line-height: 1.45;
}
