/* =========================================================
   Сказано — layout & features
   Tokens / buttons / path-cards / icons: see theme.css
   ========================================================= */

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html {
  overflow-x: hidden;
  overflow-x: clip;
}

html, body {
  margin: 0;
  width: 100%;
  max-width: 100%;
  height: 100%;
  height: 100dvh;
  overflow: hidden;
  font-family: var(--font-sans);
  font-size: var(--fs-base);
  background: var(--bg);
  color: var(--ink);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body {
  overflow-x: hidden;
  overflow-x: clip;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, h4 { margin: 0; font-weight: 600; color: var(--ink); letter-spacing: -0.01em; }
h1 { font-family: var(--font-serif); font-weight: 600; letter-spacing: -0.015em; }
.serif { font-family: var(--font-serif); }
p { margin: 0; }

button { font-family: inherit; }

::selection { background: var(--accent-soft); color: var(--accent-ink); }

/* =========================================================
   App shell
   ========================================================= */
.app {
  display: flex;
  width: 100%;
  max-width: 100%;
  height: 100%;
  min-height: 100%;
  overflow: hidden;
  overflow-x: clip;
}

/* ---------- Sidebar ---------- */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: var(--sp-4);
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100dvh;
  overflow-y: auto;
  z-index: 40;
}
.sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-2);
  padding: var(--sp-1) var(--sp-1) var(--sp-2);
}
.sidebar-close { display: none; }
.brand {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  font-family: var(--font-serif);
  font-size: var(--fs-xl);
  font-weight: 600;
  color: var(--ink);
  letter-spacing: -0.02em;
  text-decoration: none;
}
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 30px;
  height: 30px;
  border-radius: var(--r-md);
  background: var(--accent);
  color: #fffdf8;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: 16px;
  flex-shrink: 0;
}
.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  margin-top: var(--sp-2);
}
.nav-section-label {
  margin: var(--sp-4) 0 var(--sp-1) var(--sp-2);
  font-size: var(--fs-xs);
  color: var(--faint);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.nav-section-label--first { margin-top: 0; }
.nav-book-title {
  margin: 0 var(--sp-2) var(--sp-2);
  color: var(--ink);
  font-size: var(--fs-sm);
  font-weight: 600;
  line-height: 1.35;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--r-md);
  color: var(--ink);
  text-decoration: none;
  min-height: var(--touch);
  font-size: var(--fs-base);
  font-weight: 500;
  transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.nav-item:hover { background: var(--hover); text-decoration: none; }
.nav-item.active {
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-weight: 600;
}
.nav-item--create {
  color: var(--accent-ink);
  font-weight: 600;
}
.nav-item--create .ic { color: var(--accent); }
.nav-item .ic { color: var(--muted); flex-shrink: 0; }
.nav-item.active .ic { color: var(--accent); }
.nav-back { margin-top: var(--sp-2); color: var(--muted); }
.nav-back .ic { color: var(--muted); }

.sidebar-foot {
  border-top: 1px solid var(--border);
  padding-top: var(--sp-3);
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}
.sidebar-hint {
  font-size: var(--fs-xs);
  color: var(--faint);
  line-height: 1.4;
  padding: 0 var(--sp-1);
}
.sidebar-user {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-2);
  border-radius: var(--r-md);
  color: var(--muted);
  font-size: var(--fs-sm);
}
.sidebar-user .avatar {
  width: 32px;
  height: 32px;
  border-radius: var(--r-pill);
  background: var(--accent-soft);
  color: var(--accent-ink);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: var(--fs-sm);
  flex-shrink: 0;
}
.sidebar-user .who { display: flex; flex-direction: column; min-width: 0; }
.sidebar-user .who b { color: var(--ink); font-weight: 600; font-size: var(--fs-sm); }
.sidebar-user .who span { font-size: var(--fs-xs); color: var(--faint); }

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(17, 24, 39, 0.35);
  z-index: 35;
}

/* ---------- Main column ---------- */
.main-wrap {
  flex: 1;
  min-width: 0;
  min-height: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ---------- Topbar ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-5);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 30;
  min-height: 60px;
}
.topbar-menu { display: none; }
.topbar-menu.book-structure { display: inline-flex; }
.topbar-title--nav { cursor: pointer; }
.topbar-title--nav .topbar-crumb { text-decoration: underline dotted; text-underline-offset: 3px; }
.topbar--page-head {
  align-items: flex-start;
  padding-block: var(--sp-4);
}
.topbar-page-head {
  flex: 1;
  min-width: 0;
}
.topbar-page-head h1 {
  font-size: var(--fs-2xl);
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}
@media (min-width: 768px) {
  .topbar-page-head h1 { font-size: var(--fs-3xl); }
}
.topbar--page-head .topbar-title {
  align-items: flex-start;
  flex-direction: column;
  gap: var(--sp-1);
}
.settings-section-head {
  margin: var(--sp-8) 0 var(--sp-4);
}
.settings-section-head h2 {
  font-size: var(--fs-xl);
  font-weight: 600;
}
.settings-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-1);
  border-bottom: 1px solid var(--border);
  margin-bottom: var(--sp-5);
  overflow-x: auto;
  overflow-y: hidden;
}
.settings-tab {
  background: none;
  border: none;
  cursor: pointer;
  padding: var(--sp-2) var(--sp-3);
  font: inherit;
  color: var(--muted);
  border-bottom: 2px solid transparent;
  white-space: nowrap;
  margin-bottom: -1px;
}
.settings-tab:hover { color: var(--ink); }
.settings-tab.active {
  color: var(--ink);
  border-bottom-color: var(--accent);
  font-weight: 600;
}
.settings-panel[hidden] { display: none !important; }
.settings-panel + .settings-panel { margin-top: 0; }
.heroes-list {
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
  margin-bottom: var(--sp-4);
}
.hero-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: var(--sp-4);
}
.hero-card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--sp-3);
  margin-bottom: var(--sp-3);
}
.hero-card-head input {
  flex: 1;
  font-size: var(--fs-lg);
  font-weight: 600;
}
.hero-card-fields {
  display: grid;
  gap: var(--sp-3);
}
.hero-card-fields label {
  font-weight: 500;
}
.hero-card-actions {
  display: flex;
  gap: var(--sp-2);
  margin-top: var(--sp-3);
  flex-wrap: wrap;
}
.heroes-empty {
  color: var(--muted);
  font-size: var(--fs-sm);
  margin-bottom: var(--sp-4);
}
.topbar-title {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: baseline;
  gap: var(--sp-3);
  flex-wrap: wrap;
}
.topbar-crumb {
  font-size: var(--fs-lg);
  font-weight: 600;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}
.topbar-crumb a { color: var(--muted); font-weight: 500; }
.topbar-crumb a:hover { color: var(--accent); text-decoration: none; }
.topbar-sep { color: var(--faint); }
.topbar-actions {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  flex-wrap: wrap;
}
.save-status {
  font-size: 0;
  color: transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 12px;
  height: 12px;
  flex-shrink: 0;
}
.save-status::before {
  content: "";
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--save-dot-ok);
  box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.25);
}
.save-status.saving::before {
  background: var(--save-dot-pending);
  box-shadow: 0 0 0 2px rgba(234, 179, 8, 0.35), 0 0 8px 1px rgba(234, 179, 8, 0.45);
  animation: save-pulse 1s ease-in-out infinite;
}
.save-status.error::before {
  background: var(--save-dot-error);
  box-shadow: 0 0 0 2px rgba(248, 113, 113, 0.35), 0 0 8px 1px rgba(248, 113, 113, 0.4);
}
.save-status.ok::before {
  background: var(--save-dot-ok);
  box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.3), 0 0 8px 1px rgba(34, 197, 94, 0.45);
}
@keyframes save-pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.25); opacity: 0.7; }
}

/* keep legacy mobile-bar ids alive but hidden; topbar replaces them */
.mobile-bar { display: none !important; }

/* Save dot is shown on all breakpoints (single indicator, right side) */
@media (min-width: 1100px) {
  #mobile-primary-btn { display: none; }
}

/* =========================================================
   Views & headers
   ========================================================= */
.view {
  padding: var(--sp-6) var(--sp-8);
  flex: 1;
  min-height: 0;
  width: 100%;
  overflow: auto;
}
.view-narrow {
  max-width: 44rem;
  margin-inline: auto;
}
/* List / board screens: stretch the main panel to the remaining viewport */
.view--fill {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
/* Books list grows with cards — scroll the view, not a fixed panel */
#view-books.view--fill {
  overflow: auto;
}
.view-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-4);
  margin-bottom: var(--sp-6);
}
.view-head--toolbar {
  justify-content: flex-end;
  margin-bottom: var(--sp-4);
  flex-shrink: 0;
}
.view-head h1 {
  font-size: var(--fs-2xl);
  font-weight: 600;
}
.view-subtitle {
  color: var(--muted);
  font-size: var(--fs-base);
  margin-top: var(--sp-1);
}

/* =========================================================
   Buttons → theme.css (.btn, .btn-primary, .path-card, …)
   ========================================================= */

/* =========================================================
   Forms
   ========================================================= */
.stack { display: flex; flex-direction: column; gap: var(--sp-4); }
.stack label,
.form-card label,
.meta-label {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  font-size: var(--fs-sm);
  font-weight: 500;
  color: var(--ink);
}
.stack input,
.stack textarea,
.form-card input,
.form-card textarea,
.title-input,
.editor-textarea,
.meta-label textarea,
select {
  width: 100%;
  font: inherit;
  font-weight: 400;
  font-size: var(--fs-base);
  padding: var(--sp-2) var(--sp-3);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
  color: var(--ink);
  transition: border-color var(--t-fast) var(--ease),
    box-shadow var(--t-fast) var(--ease);
}
.stack input:focus,
.stack textarea:focus,
.form-card input:focus,
.form-card textarea:focus,
.title-input:focus,
.editor-textarea:focus,
.meta-label textarea:focus,
select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.stack input::placeholder,
textarea::placeholder { color: var(--faint); }

.editor-textarea,
#transcript,
#transcript-single {
  line-height: 1.6;
  resize: vertical;
  min-height: 12rem;
}
.title-input {
  font-size: var(--fs-lg);
  font-weight: 600;
  font-family: var(--font-serif);
  border: none;
  background: transparent;
  padding: var(--sp-1) 0;
  border-radius: 0;
}
@media (max-width: 767px) {
  .title-input {
    font-size: var(--fs-md);
  }
}
.title-input:focus {
  outline: none;
  box-shadow: none;
  border-bottom: 2px solid var(--accent);
  padding-bottom: var(--sp-1);
}

.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
  align-items: center;
}
.row-actions.wrap { margin-top: var(--sp-3); }

/* =========================================================
   Wizard actions — onboarding / new book navigation
   Primary CTA full-width, secondary actions as a link row.
   ========================================================= */
.wizard-actions {
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  margin-top: var(--sp-5);
}
.wizard-actions .btn-block { width: 100%; }

.wizard-actions__links {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: var(--sp-1) var(--sp-2);
  margin-top: var(--sp-1);
}
.wizard-actions__sep {
  width: 1px;
  height: 14px;
  background: var(--border-strong);
  flex-shrink: 0;
}
/* Hide separators whose neighbouring link is hidden (no JS needed):
   a separator is hidden if it has no visible flex sibling before/after.
   Simplest robust approach: hide separators when the row is sparse. */
.wizard-actions__links > .btn-link[hidden] + .wizard-actions__sep,
.wizard-actions__sep:has(+ .btn-link[hidden]) {
  display: none;
}

/* .btn-link → theme.css */

/* =========================================================
   Global scratch notes — sticky-note board
   ========================================================= */
/* Shared surface that fills remaining height in .view--fill */
.fill-panel {
  flex: 1 1 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: auto;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  box-shadow: var(--sh-sm);
}

.scratch-board-wrap {
  position: relative;
  background:
    radial-gradient(circle at 12% 18%, rgba(120, 90, 50, 0.05) 0 2px, transparent 3px),
    radial-gradient(circle at 78% 62%, rgba(120, 90, 50, 0.05) 0 2px, transparent 3px),
    radial-gradient(circle at 42% 88%, rgba(120, 90, 50, 0.04) 0 2px, transparent 3px),
    var(--surface-2);
  padding: var(--sp-6);
}
.scratch-board {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(220px, 100%), 1fr));
  gap: var(--sp-6) var(--sp-5);
  align-items: start;
}

/* A single sticky note */
.sticky-note {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  min-height: 180px;
  padding: var(--sp-4) var(--sp-4) var(--sp-5);
  border: none;
  border-radius: 2px 2px 4px 4px;
  background: var(--sticky-bg, #fff9b1);
  color: var(--sticky-ink, #4a3f1a);
  box-shadow:
    0 1px 1px rgba(0, 0, 0, 0.08),
    0 10px 18px rgba(60, 50, 35, 0.18),
    inset 0 0 0 1px rgba(0, 0, 0, 0.03);
  cursor: pointer;
  font: inherit;
  text-align: left;
  transform: rotate(var(--sticky-rot, 0deg));
  transform-origin: center top;
  transition: transform var(--t-base) var(--ease),
    box-shadow var(--t-base) var(--ease);
  overflow: hidden;
}
/* Paper tape at the top */
.sticky-note::before {
  content: "";
  position: absolute;
  top: -10px;
  left: 50%;
  width: 64px;
  height: 20px;
  background: rgba(180, 180, 180, 0.42);
  border-left: 1px dashed rgba(0, 0, 0, 0.08);
  border-right: 1px dashed rgba(0, 0, 0, 0.08);
  transform: translateX(-50%) rotate(-2deg);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}
/* Subtle paper grain */
.sticky-note::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.18) 0%, transparent 40%),
    radial-gradient(circle at 80% 90%, rgba(0, 0, 0, 0.05) 0%, transparent 60%);
  pointer-events: none;
  border-radius: inherit;
}
.sticky-note:hover {
  transform: rotate(0deg) translateY(-4px) scale(1.02);
  box-shadow:
    0 4px 8px rgba(0, 0, 0, 0.10),
    0 18px 30px rgba(60, 50, 35, 0.22);
  z-index: 2;
}
.sticky-note.active {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
  z-index: 3;
}
.sticky-title {
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: var(--fs-md);
  line-height: 1.3;
  word-break: break-word;
  position: relative;
  z-index: 1;
}
.sticky-body {
  font-size: var(--fs-sm);
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
  flex: 1 1 auto;
  position: relative;
  z-index: 1;
  display: -webkit-box;
  -webkit-line-clamp: 7;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.sticky-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-2);
  margin-top: auto;
  font-size: var(--fs-xs);
  opacity: 0.75;
  position: relative;
  z-index: 1;
}
.sticky-date { font-style: italic; }
.sticky-pin {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--sticky-pin, #b91c1c);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3), inset -2px -2px 3px rgba(0, 0, 0, 0.25);
  flex: 0 0 auto;
}

/* Empty state */
.scratch-empty {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--sp-3);
  text-align: center;
  padding: var(--sp-8) var(--sp-4);
  color: var(--muted);
}
.scratch-empty h2 { font-family: var(--font-serif); font-size: var(--fs-xl); color: var(--ink); }
.scratch-empty p { margin: 0; }

/* Editor dialog (sticky-note style) */
.scratch-dialog {
  max-width: 42rem;
  width: calc(100% - 2rem);
  padding: 0;
  border: none;
  border-radius: var(--r-xl);
  box-shadow: var(--sh-lg);
  background: var(--surface);
  color: var(--ink);
}
.scratch-dialog::backdrop { background: rgba(40, 35, 25, 0.45); backdrop-filter: blur(3px); }
.scratch-dialog-inner {
  padding: var(--sp-5);
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
}
.scratch-dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
}
.scratch-dialog-head h3 { font-family: var(--font-serif); font-size: var(--fs-xl); font-weight: 600; margin: 0; }
.scratch-dialog .dictation-bar { margin-bottom: var(--sp-2); }
.scratch-dialog .stack { margin-bottom: var(--sp-2); }

/* =========================================================
   Books grid — Bookshop.org-inspired shelf
   ========================================================= */
.books-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(220px, 100%), 1fr));
  gap: var(--sp-6) var(--sp-5);
  align-items: stretch;
}
.book-card {
  background: transparent;
  border: none;
  border-radius: 0;
  padding: 0;
  text-align: left;
  cursor: pointer;
  display: grid;
  grid-template-rows: auto minmax(2.6em, 2.6em) auto auto 5px;
  gap: var(--sp-2);
  position: relative;
  height: 100%;
  box-shadow: none;
  transition: transform var(--t-base) var(--ease);
}
.book-card:hover,
.book-card:focus-visible {
  outline: none;
  transform: translateY(-3px);
}
.book-cover {
  width: 100%;
  aspect-ratio: 3 / 4.3;
  border-radius: 2px 7px 7px 2px;
  margin-bottom: var(--sp-2);
  flex-shrink: 0;
  position: relative;
  overflow: hidden;
  isolation: isolate;
  box-shadow: 1px 2px 0 rgba(74, 62, 46, 0.16), 5px 10px 20px rgba(60, 50, 35, 0.19), 0 2px 5px rgba(60, 50, 35, 0.12);
  background: var(--accent);
  border: 1px solid rgba(60, 50, 35, 0.12);
  transition: box-shadow var(--t-base) var(--ease), transform var(--t-base) var(--ease);
}
.book-card:hover .book-cover,
.book-card:focus-visible .book-cover {
  transform: perspective(900px) rotateY(-2deg);
  box-shadow: 2px 3px 0 rgba(74, 62, 46, 0.14), 8px 16px 30px rgba(60, 50, 35, 0.25), 0 4px 10px rgba(60, 50, 35, 0.12);
}
/* Spine on the left edge */
.book-cover::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 12px;
  background: rgba(0, 0, 0, 0.16);
  border-right: 1px solid rgba(255, 255, 255, 0.18);
  box-shadow: inset -3px 0 4px rgba(255, 255, 255, 0.08);
  z-index: 2;
}
/* Page-edge on the right */
.book-cover::after {
  content: "";
  position: absolute;
  right: 0;
  top: 2px;
  bottom: 2px;
  width: 5px;
  background: #f4ece0;
  border-left: 1px solid #e3d8c2;
  z-index: 2;
  border-radius: 0 4px 4px 0;
}
.book-cover-title {
  position: absolute;
  inset: 0;
  padding: 22px 21px 20px 27px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 8px;
  color: #fffdf8;
  font-family: var(--font-serif);
  z-index: 1;
}
.book-cover-title::before {
  content: "";
  position: absolute;
  inset: 15px 13px 15px 19px;
  border: 1px solid rgba(255, 253, 248, 0.38);
  box-shadow: inset 0 0 0 3px rgba(255, 253, 248, 0.05);
  pointer-events: none;
}
.book-cover-title .bc-title,
.book-cover-title .bc-genre {
  position: relative;
  z-index: 1;
}
.book-cover-title .bc-title {
  font-size: var(--fs-xl);
  font-weight: 600;
  line-height: 1.15;
  text-shadow: 0 1px 2px rgba(0,0,0,0.25);
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.book-cover-title .bc-genre {
  font-size: 10px;
  font-family: var(--font-sans);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  line-height: 1.3;
  opacity: 0.72;
}
/* Cover color variants — warm literary palette */
.book-cover.c-cream { background: #e9dcc4; color: #4a3f30; }
.book-cover.c-cream .book-cover-title { color: #4a3f30; text-shadow: none; }
.book-cover.c-cream .book-cover-title::before { border-color: rgba(74, 63, 48, 0.28); box-shadow: inset 0 0 0 3px rgba(74, 63, 48, 0.04); }
.book-cover.c-forest { background: #2f5d50; }
.book-cover.c-wine { background: #6b3a4e; }
.book-cover.c-ink { background: #2b3a44; }
.book-cover.c-ochre { background: #b8843a; }
.book-cover.c-slate { background: #5a5f6b; }
.book-cover.c-rust { background: #9c4a2e; }

.book-card h3 {
  font-family: var(--font-serif);
  font-size: var(--fs-lg);
  font-weight: 600;
  padding-right: 2rem;
  line-height: 1.3;
  color: var(--ink);
  overflow-wrap: anywhere;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
}
.book-meta {
  font-size: var(--fs-xs);
  color: var(--muted);
  line-height: 1.4;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.progress {
  height: 5px;
  background: var(--surface-2);
  border-radius: var(--r-pill);
  overflow: hidden;
  margin-top: 0;
}
.progress > span {
  display: block;
  height: 100%;
  background: var(--accent);
  border-radius: var(--r-pill);
  transition: width var(--t-base) var(--ease);
}
.book-menu-btn {
  position: absolute;
  top: 0;
  right: 0;
  width: 32px;
  height: 32px;
  border: none;
  background: var(--surface);
  border-radius: var(--r-pill);
  cursor: pointer;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--sh-sm);
  opacity: 0;
  transition: opacity var(--t-fast) var(--ease), background var(--t-fast) var(--ease);
}
.book-card:hover .book-menu-btn,
.book-card:focus-within .book-menu-btn { opacity: 1; }
.book-menu-btn:hover { background: var(--hover); color: var(--ink); }
.book-menu {
  position: absolute;
  right: 0;
  top: 2.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  min-width: 11rem;
  z-index: 5;
  box-shadow: var(--sh-md);
  display: flex;
  flex-direction: column;
  padding: var(--sp-1);
}
.book-menu button {
  background: transparent;
  border: none;
  text-align: left;
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--r-sm);
  cursor: pointer;
  font: inherit;
  font-size: var(--fs-base);
  min-height: 40px;
  color: var(--ink);
}
.book-menu button:hover { background: var(--hover); }
.book-menu button.danger { color: var(--danger); }
.book-menu button.danger:hover { background: var(--danger-bg); }

/* =========================================================
   State boxes (empty / error)
   ========================================================= */
.state-box {
  text-align: center;
  padding: var(--sp-10) var(--sp-4);
  color: var(--muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-3);
  max-width: 32rem;
  margin-inline: auto;
}
.state-box.compact { padding: var(--sp-8) var(--sp-4); }
.state-box.fill-panel {
  max-width: none;
  width: 100%;
  margin-inline: 0;
  justify-content: center;
  padding: var(--sp-8) var(--sp-6);
}
.state-box h2 { color: var(--ink); font-size: var(--fs-lg); }
.state-box p { font-size: var(--fs-base); line-height: 1.5; }
/* .state-ill → theme.css */

.welcome-record-btn {
  width: 72px;
  height: 72px;
  border: none;
  border-radius: var(--r-lg);
  background: var(--accent);
  color: var(--mic-gold);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: var(--sp-1);
  cursor: pointer;
  box-shadow: var(--sh-sm, 0 1px 2px rgba(0, 0, 0, 0.08));
  transition: transform var(--t-fast) var(--ease), background var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
}
.welcome-record-btn:hover {
  background: var(--accent-hover);
  color: var(--mic-gold-hover);
  transform: translateY(-1px);
  box-shadow: var(--sh-md, 0 4px 12px rgba(0, 0, 0, 0.12));
}
.welcome-record-btn:active {
  transform: scale(0.98);
}
.welcome-record-btn svg,
.welcome-record-btn svg path {
  stroke: currentColor;
}
.welcome-record-btn .stop-icon { display: none; }
.welcome-record-btn.is-recording .mic-icon { display: none; }
.welcome-record-btn.is-recording .stop-icon { display: inline-flex; }
.welcome-record-btn.is-recording {
  background: var(--recording);
  color: #fff;
}
.welcome-record-btn.is-recording svg,
.welcome-record-btn.is-recording svg path {
  stroke: #fff;
}
.welcome-record-label {
  margin: 0;
  font-size: var(--fs-md);
  font-weight: 600;
  color: var(--ink);
}
#welcome-back-choice-btn {
  margin-top: var(--sp-2);
}

/* =========================================================
   Skeletons
   ========================================================= */
.skeleton {
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--hover) 37%, var(--surface-2) 63%);
  background-size: 400% 100%;
  animation: shimmer 1.4s ease infinite;
  border-radius: var(--r-lg);
}
.card-skel { height: 220px; }
.skeleton-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(220px, 100%), 1fr));
  gap: var(--sp-6) var(--sp-5);
}
.line-skel { height: 14px; border-radius: var(--r-sm); margin-bottom: var(--sp-2); }
.line-skel.short { width: 60%; }
@keyframes shimmer {
  0% { background-position: 100% 0; }
  100% { background-position: -100% 0; }
}

/* =========================================================
   Create book — path cards → theme.css (.path-card, .create-paths)
   ========================================================= */
.create-cancel {
  display: flex;
  justify-content: center;
  margin-top: var(--sp-2);
}
.create-cancel .btn-link {
  min-height: 40px;
  padding: var(--sp-2) var(--sp-4);
  font-size: var(--fs-base);
}

.onboarding-passport {
  margin: 0;
  display: grid;
  gap: var(--sp-3);
}
.onboarding-passport div {
  border-bottom: 1px solid var(--border);
  padding-bottom: var(--sp-3);
}
.onboarding-passport dt { color: var(--muted); font-size: var(--fs-sm); }
.onboarding-passport dd { margin: var(--sp-1) 0 0; white-space: pre-wrap; }
.choice-row { display: flex; gap: var(--sp-2); align-items: center; }

/* =========================================================
   Workspace
   ========================================================= */
.workspace-top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  margin-bottom: var(--sp-4);
}
.workspace-top h1 { font-size: var(--fs-xl); font-weight: 600; }
.workspace-top-left {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  flex-wrap: wrap;
  min-width: 0;
}
.workspace-top-left .btn svg {
  flex-shrink: 0;
}
#toggle-structure-btn.is-active {
  background: var(--accent-soft);
  color: var(--accent-ink);
}
.inbox-head {
  padding: 0 var(--sp-1) var(--sp-2);
  margin: 0;
}
.inbox-head h3 {
  margin: 0;
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--muted);
  text-transform: none;
}
.inbox-list li {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.workspace-top-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
  align-items: center;
}
.chapter-title-row {
  width: 100%;
}
.chapter-title-row .title-input {
  width: 100%;
  min-width: 0;
}

.workspace-grid {
  display: grid;
  grid-template-columns: var(--structure-w) minmax(0, 1fr) 0;
  gap: var(--sp-4);
  align-items: stretch;
  min-height: 0;
}
.workspace-grid.ai-open {
  grid-template-columns: var(--structure-w) minmax(0, 1fr) var(--ai-w);
}

.structure-panel,
.ai-panel,
.editor-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--sp-4);
  box-shadow: var(--sh-xs);
}
.structure-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
}
.editor-panel { min-width: 0; }

#view-workspace .editor-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
}
#view-workspace .editor-panel > * {
  width: 100%;
  max-width: var(--editor-max);
}
#view-workspace .editor-textarea,
#view-workspace #transcript-single,
#view-workspace #transcript {
  text-align: justify;
  text-align-last: left;
  hyphens: auto;
}
.structure-panel .panel-head {
  flex-shrink: 0;
}
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-2);
  margin-bottom: var(--sp-3);
}
.panel-head h2 { font-size: var(--fs-base); font-weight: 600; }
.panel-head h3 { font-size: var(--fs-sm); font-weight: 600; color: var(--muted); }

/* ---------- Structure tree ---------- */
.structure-tree {
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
  flex: 1;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}
.chapter-node {
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: var(--sp-1);
  background: var(--surface);
}
.chapter-node.drag-over {
  border-color: var(--accent);
  outline: 2px dashed var(--accent);
  outline-offset: 1px;
}
.chapter-node.selected,
.scene-row.selected,
.inbox-list li.selected {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.chapter-head {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-1);
  cursor: pointer;
  min-height: 40px;
  padding: var(--sp-1);
}
.chapter-head-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.chapter-head .name {
  font-weight: 600;
  font-size: var(--fs-sm);
  line-height: 1.35;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  overflow: hidden;
}
.chapter-meta {
  font-size: var(--fs-xs);
  color: var(--faint);
  line-height: 1.25;
}
.chapter-head-actions {
  display: flex;
  flex-shrink: 0;
  align-items: center;
  gap: 0;
}
.scene-list {
  list-style: none;
  margin: var(--sp-1) 0 0;
  padding: 0 0 0 var(--sp-2);
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-height: 0.5rem;
}
.scene-list:empty {
  min-height: 1.75rem;
  border-radius: var(--r-sm);
}
.scene-list.drag-over:empty {
  outline: 2px dashed var(--accent);
  outline-offset: 2px;
}
.scene-row {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-1);
  padding: var(--sp-2) var(--sp-2);
  border-radius: var(--r-sm);
  border: 1px solid transparent;
  cursor: grab;
  min-height: 40px;
  font-size: var(--fs-sm);
  touch-action: pan-y;
  user-select: none;
  -webkit-user-select: none;
  -webkit-user-drag: element;
}
.scene-row:active {
  cursor: grabbing;
}
.scene-row .name {
  flex: 1;
  min-width: 0;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  overflow: hidden;
}
.scene-row.scene-press {
  background: var(--hover);
}
.scene-row.dragging {
  opacity: 0.45;
  cursor: grabbing;
  touch-action: none;
}
.scene-row.drop-before {
  box-shadow: inset 0 2px 0 var(--accent);
}
.scene-row.drop-after {
  box-shadow: inset 0 -2px 0 var(--accent);
}
.scene-list.scene-drop-append {
  box-shadow: inset 0 -2px 0 var(--accent);
}
.scene-row:hover { background: var(--hover); }
.scene-row-actions {
  display: flex;
  flex-shrink: 0;
  align-items: center;
  gap: 2px;
}
.scene-status-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: var(--r-sm);
  flex-shrink: 0;
  color: var(--muted);
}
.scene-status-badge.is-draft {
  color: var(--muted);
}
.scene-status-badge.is-ready {
  color: var(--accent);
  background: var(--accent-soft);
}
.icon-tiny {
  border: none;
  background: transparent;
  cursor: pointer;
  color: var(--faint);
  width: 32px;
  height: 32px;
  border-radius: var(--r-sm);
  font: inherit;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.icon-tiny:hover { background: var(--hover); color: var(--ink); }
.icon-tiny:disabled { opacity: 0.4; cursor: not-allowed; }
.icon-tiny.danger:hover {
  background: var(--danger-bg);
  color: var(--danger);
}

.inbox-section {
  margin-top: var(--sp-4);
  border-top: 1px solid var(--border);
  padding-top: var(--sp-3);
}
.archive-scene-row {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-2);
  cursor: pointer;
}
.archive-scene-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.archive-scene-main strong {
  font-size: var(--fs-sm);
  font-weight: 600;
  line-height: 1.35;
}
.inbox-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
  max-height: 30vh;
  overflow: auto;
}
.inbox-list li {
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: var(--sp-2) var(--sp-3);
  cursor: pointer;
  background: var(--surface);
  min-height: 44px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  touch-action: pan-y;
  user-select: none;
  -webkit-user-select: none;
  -webkit-user-drag: element;
}
.inbox-list li.note-press { background: var(--hover); }
.inbox-list li.dragging {
  opacity: 0.45;
  cursor: grabbing;
  touch-action: none;
}
.inbox-list li:hover { background: var(--hover); }
.inbox-list li strong { font-size: var(--fs-sm); font-weight: 600; }
.inbox-list li .meta { font-size: var(--fs-xs); color: var(--faint); }
.inbox-list li.placeholder {
  border-style: dashed;
  cursor: default;
  background: transparent;
  color: var(--faint);
  font-size: var(--fs-xs);
  text-align: center;
}
.inbox-list li.placeholder:hover { background: transparent; }

/* =========================================================
   Editor
   ========================================================= */
.editor-block { display: flex; flex-direction: column; gap: var(--sp-3); }
.editor-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--sp-2);
  padding-bottom: var(--sp-2);
  border-bottom: 1px solid var(--border);
}
.editor-context {
  font-size: var(--fs-xs);
  color: var(--faint);
  margin-bottom: var(--sp-1);
}
.editor-wrap {
  width: 100%;
}
.editor-textarea {
  font-size: var(--fs-editor);
  font-family: var(--font-editor);
  line-height: var(--lh-editor);
  border: none;
  background: transparent;
  padding: var(--sp-3) 0;
  min-height: 18rem;
}
.editor-textarea:focus {
  outline: none;
  box-shadow: none;
  border: none;
}
.counts { font-size: var(--fs-xs); color: var(--faint); margin-left: auto; }
.editor-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  padding-top: var(--sp-2);
  border-top: 1px solid var(--border);
  font-size: var(--fs-xs);
  color: var(--faint);
}
.meta-label { font-size: var(--fs-sm); }
.meta-label textarea { font-size: var(--fs-base); }

/* =========================================================
   Dictation
   ========================================================= */
.dictation-bar {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
  align-items: center;
  padding: var(--sp-3);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  container-type: inline-size;
}
.dictation-mic-btn {
  width: var(--touch);
  min-width: var(--touch);
  padding: 0;
  flex-shrink: 0;
}
.dictation-mic-btn svg {
  flex-shrink: 0;
}
.dictation-mic-label {
  display: none;
  font-size: var(--fs-sm);
  font-weight: 600;
}
@container (min-width: 26rem) {
  .dictation-mic-btn {
    width: auto;
    min-width: 0;
    padding: var(--sp-2) var(--sp-4);
  }
  .dictation-mic-label {
    display: inline;
  }
}
.dictation-bar.recording {
  border-color: #f3c5c5;
  background: var(--danger-bg);
}
.dictation-cancel-row {
  display: flex;
  justify-content: center;
  margin-top: var(--sp-2);
}
.rec-indicator {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--recording);
}
.rec-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--recording);
  animation: pulse 1.2s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.85); }
}
.rec-timer {
  font-variant-numeric: tabular-nums;
  font-size: var(--fs-sm);
  color: var(--ink);
  font-weight: 600;
}
.status-text { font-size: var(--fs-sm); color: var(--muted); }
.error-text { color: var(--danger); font-size: var(--fs-sm); }
.hint { font-size: var(--fs-sm); color: var(--muted); line-height: 1.5; }

.transcript-dual {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-3);
}
.transcript-dual label { font-size: var(--fs-xs); color: var(--muted); font-weight: 600; }

/* =========================================================
   AI panel
   ========================================================= */
.ai-panel {
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  min-height: 0;
}
#view-workspace .ai-panel {
  position: sticky;
  top: var(--sp-4);
  align-self: start;
  max-height: calc(100vh - 7rem);
  overflow: hidden;
}
.ai-panel.ai-mode-result .ai-menu,
.ai-panel.ai-mode-result .ai-history-block { display: none; }
.ai-menu { display: flex; flex-direction: column; gap: var(--sp-3); min-height: 0; overflow: auto; }
.ai-result {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  flex: 1;
  min-height: 0;
  overflow: hidden;
}
.ai-result[hidden] { display: none !important; }
.ai-back-btn { align-self: flex-start; margin: calc(var(--sp-1) * -1) 0 0; }
.ai-subtitle { font-size: var(--fs-sm); color: var(--muted); margin-top: calc(var(--sp-1) * -1); }
.ai-commands { display: flex; flex-direction: column; gap: var(--sp-1); }
.ai-cmd {
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: var(--sp-3);
  cursor: pointer;
  font: inherit;
  display: flex;
  align-items: flex-start;
  gap: var(--sp-3);
  transition: border-color var(--t-fast) var(--ease), background var(--t-fast) var(--ease);
}
.ai-cmd:hover:not(:disabled) {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.ai-cmd:disabled { opacity: 0.55; cursor: not-allowed; }
.ai-cmd .ai-cmd-ic {
  width: 32px;
  height: 32px;
  border-radius: var(--r-md);
  background: var(--accent-soft);
  color: var(--accent);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.ai-cmd .ai-cmd-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.ai-cmd .ai-cmd-title { font-size: var(--fs-sm); font-weight: 600; color: var(--ink); }
.ai-cmd .ai-cmd-desc { font-size: var(--fs-xs); color: var(--muted); line-height: 1.4; }

.ai-loading {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-3);
  color: var(--muted);
  font-size: var(--fs-sm);
}
.ai-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.ai-preview {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  flex: 1;
  min-height: 0;
  overflow: hidden;
}
.ai-preview[hidden] { display: none !important; }
.ai-preview h3 { font-size: var(--fs-sm); font-weight: 600; flex-shrink: 0; }
.ai-preview pre {
  white-space: pre-wrap;
  font-family: inherit;
  font-size: var(--fs-sm);
  line-height: 1.6;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: var(--sp-3);
  flex: 1;
  min-height: 6rem;
  max-height: none;
  overflow: auto;
  margin: 0;
}
.ai-preview-actions {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  padding-top: var(--sp-2);
  border-top: 1px solid var(--border);
  background: var(--surface);
}
.ai-preview-actions .ai-retry-btn { margin-top: 0; }
.illustration-prompt-editor {
  display: flex;
  flex: 1;
  min-height: 0;
  flex-direction: column;
  gap: var(--sp-2);
  overflow: auto;
  overscroll-behavior: contain;
}
.illustration-style {
  margin: 0;
  padding: var(--sp-2);
  border-radius: var(--r-sm);
  background: var(--accent-soft);
  font-size: var(--fs-xs);
}
.illustration-blocks { display: flex; flex-direction: column; gap: var(--sp-2); }
.illustration-block {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: var(--fs-xs);
  font-weight: 600;
  color: var(--muted);
}
.illustration-block textarea {
  resize: vertical;
  font: inherit;
  font-size: var(--fs-sm);
  font-weight: 400;
  color: var(--ink);
}
.illustration-generate-actions {
  position: sticky;
  bottom: 0;
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  margin: var(--sp-1) calc(var(--sp-1) * -1) calc(var(--sp-1) * -1);
  padding: var(--sp-3) var(--sp-1) var(--sp-1);
  background: linear-gradient(to bottom, color-mix(in srgb, var(--surface) 88%, transparent), var(--surface) 22%);
  border-top: 1px solid var(--border);
}
.illustration-photo-source {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-2);
  padding: var(--sp-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface-2);
}
.illustration-photo-copy {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 2px;
  font-size: var(--fs-xs);
  font-weight: 600;
  color: var(--ink);
}
.illustration-photo-copy small {
  font-size: var(--fs-xs);
  font-weight: 400;
  line-height: 1.35;
  color: var(--muted);
}
.illustration-photo-input {
  display: flex;
  flex: 0 0 auto;
  cursor: pointer;
  color: var(--accent);
  font-size: var(--fs-xs);
  font-weight: 600;
}
.illustration-photo-input > span {
  padding: 6px 8px;
  border: 1px solid currentColor;
  border-radius: var(--r-sm);
  white-space: nowrap;
}
.illustration-photo-input input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}
.illustration-photo-input:focus-within > span {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.scene-illustration {
  margin-top: var(--sp-3);
  padding-top: var(--sp-3);
  border-top: 1px solid var(--border);
}
.scene-illustration h3 { margin: 0 0 var(--sp-2); font-size: var(--fs-sm); }
.scene-illustration img {
  display: block;
  width: min(100%, 640px);
  max-height: 520px;
  object-fit: contain;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface-2);
}
.illustration-reference-card h2 {
  margin: 0;
  font-size: var(--fs-md);
}
.illustration-reference-card img {
  display: block;
  width: min(100%, 360px);
  max-height: 300px;
  object-fit: contain;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface-2);
}

.field-actions { margin-top: calc(var(--sp-2) * -1); margin-bottom: var(--sp-3); }
.meta-label + .field-actions { margin-top: var(--sp-2); }
.chapter-scenes-block { margin: var(--sp-4) 0 var(--sp-3); }
.chapter-scenes-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-2);
  flex-wrap: wrap;
  margin-bottom: var(--sp-2);
}
.chapter-scenes-heading {
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--muted);
  margin: 0;
}
.chapter-scenes-hint { margin-bottom: var(--sp-3); }
.chapter-scenes-list { display: flex; flex-direction: column; gap: var(--sp-2); }
.chapter-scene-title-row {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}
.chapter-scene-title-input {
  flex: 1;
  min-width: 0;
  font: inherit;
  font-size: var(--fs-sm);
  padding: var(--sp-2) var(--sp-3);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
}
.chapter-scene-title-input::placeholder { color: var(--faint); }
.editor-inline-preview {
  margin-bottom: var(--sp-3);
  padding: var(--sp-3);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface-2);
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}
.editor-inline-preview[hidden] { display: none !important; }
.editor-inline-preview h4 { font-size: var(--fs-sm); font-weight: 600; margin: 0; }
.editor-inline-preview pre {
  white-space: pre-wrap;
  font-family: inherit;
  font-size: var(--fs-sm);
  line-height: 1.55;
  margin: 0;
  max-height: 14rem;
  overflow: auto;
}
.editor-inline-preview .error-text { margin: 0; }

/* =========================================================
   Dropdown
   ========================================================= */
.add-wrap { position: relative; }
.dropdown {
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  z-index: 20;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  min-width: 13rem;
  padding: var(--sp-1);
  box-shadow: var(--sh-md);
  display: flex;
  flex-direction: column;
}
.dropdown[hidden] { display: none !important; }
.dropdown button {
  background: transparent;
  border: none;
  text-align: left;
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--r-sm);
  cursor: pointer;
  font: inherit;
  font-size: var(--fs-base);
  min-height: 40px;
  color: var(--ink);
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}
.dropdown button:hover { background: var(--hover); }

.chapter-section-grid {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}
.chapter-section-grid .btn { justify-content: flex-start; text-align: left; }

/* =========================================================
   Modal dialogs
   ========================================================= */
.modal {
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  padding: 0;
  max-width: 30rem;
  width: calc(100% - 2rem);
  box-shadow: var(--sh-lg);
  color: var(--ink);
}
.modal::backdrop { background: rgba(17, 24, 39, 0.4); backdrop-filter: blur(2px); }
.modal.modal--history { max-width: min(52rem, calc(100% - 2rem)); }
.modal-inner { padding: var(--sp-5); display: flex; flex-direction: column; gap: var(--sp-3); }
.modal-inner h3 { font-size: var(--fs-lg); font-weight: 600; }
.modal-inner p { color: var(--muted); font-size: var(--fs-base); line-height: 1.5; }
.modal-inner label { font-size: var(--fs-sm); }
.history-list {
  list-style: none;
  padding: 0;
  margin: 0;
  max-height: 60vh;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
}
.history-list li:empty { display: none; }
.history-entry {
  padding: var(--sp-3);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  background: var(--surface);
}
.history-entry--empty {
  color: var(--muted);
  font-size: var(--fs-sm);
  text-align: center;
}
.history-entry-meta {
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--ink);
}
.history-diff {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-2);
}
@media (max-width: 640px) {
  .history-diff { grid-template-columns: 1fr; }
}
.history-diff-label {
  font-size: var(--fs-xs);
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: var(--sp-1);
}
.history-diff-text {
  margin: 0;
  padding: var(--sp-2);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  font-family: inherit;
  font-size: var(--fs-sm);
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 14rem;
  overflow: auto;
}
.history-issues {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}
.history-issue {
  padding: var(--sp-2) var(--sp-3);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--surface-2);
}
.history-issue-sev {
  display: inline-block;
  font-size: var(--fs-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-bottom: var(--sp-1);
  padding: 0.1rem 0.45rem;
  border-radius: var(--r-pill);
  background: var(--hover);
  color: var(--muted);
}
.history-issue-sev--medium { background: #fef3c7; color: #92400e; }
.history-issue-sev--high { background: #fee2e2; color: #991b1b; }
.history-issue-desc {
  margin: 0;
  font-size: var(--fs-sm);
  color: var(--ink);
  line-height: 1.45;
}
.history-issue-hint {
  margin: var(--sp-1) 0 0;
  font-size: var(--fs-sm);
  color: var(--muted);
  line-height: 1.4;
}

/* =========================================================
   Dictation result modal — note dialog
   ========================================================= */
.note-dialog {
  max-width: min(40rem, calc(100% - 2rem));
  width: calc(100% - 2rem);
  padding: 0;
  border: none;
  border-radius: var(--r-xl);
  box-shadow: var(--sh-lg);
  background: var(--bg);
  color: var(--ink);
  margin: auto;
}
.note-dialog::backdrop { background: rgba(40, 35, 25, 0.45); backdrop-filter: blur(4px); }
.note-dialog-inner {
  display: flex;
  flex-direction: column;
  max-height: 90vh;
  overflow: hidden;
  background: var(--bg);
}
.note-dialog-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--sp-3);
  padding: var(--sp-5) var(--sp-5) var(--sp-3);
  border-bottom: 1px solid var(--border);
  background: transparent;
}
.note-dialog-titles { min-width: 0; }
.note-dialog-head h3 {
  font-family: var(--font-serif);
  font-size: var(--fs-xl);
  font-weight: 600;
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}
.note-dialog-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--sp-2);
  margin-top: var(--sp-1);
}
.note-badge {
  font-size: var(--fs-xs);
  font-weight: 600;
  color: var(--danger);
  background: var(--danger-bg);
  padding: 2px 8px;
  border-radius: var(--r-pill);
}
.note-badge:empty { display: none; }
.note-meta-counts { font-size: var(--fs-xs); color: var(--faint); }
.note-meta-counts:empty { display: none; }

.note-dialog-body {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: var(--sp-4) var(--sp-5);
}
.note-edit-area {
  width: 100%;
  height: 100%;
  font-family: var(--font-editor);
  font-size: var(--fs-editor);
  line-height: var(--lh-editor);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--surface);
  padding: var(--sp-4);
  color: var(--ink);
  resize: none;
  min-height: 28rem;
  box-shadow: var(--sh-xs);
  transition: border-color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
}
.note-edit-area:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.note-format-preview {
  margin-top: var(--sp-4);
}

.note-dialog-foot {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
  align-items: center;
  justify-content: flex-end;
  padding: var(--sp-3) var(--sp-5) var(--sp-5);
  border-top: 1px solid var(--border);
  background: transparent;
}
.note-dialog-foot .btn { flex: 1 1 auto; }

@media (max-width: 767px) {
  .note-dialog {
    width: 100%;
    max-width: 100%;
    height: 100%;
    max-height: 100%;
    margin: 0;
    border-radius: 0;
    background: var(--bg);
  }
  .note-dialog-inner { max-height: 100%; height: 100%; background: var(--bg); }
  .note-dialog-body { padding: var(--sp-3) var(--sp-4); }
  .note-dialog-head { padding: var(--sp-4) var(--sp-4) var(--sp-3); border-bottom-color: transparent; }
  .note-dialog-foot {
    padding: var(--sp-3) var(--sp-4) calc(var(--sp-4) + env(safe-area-inset-bottom, 0px));
    background: var(--bg);
  }
  .note-dialog-foot .btn-primary { flex: 1 1 100%; order: -1; }
  .note-edit-area {
    min-height: 100%;
    background: var(--surface);
  }
}

/* =========================================================
   Toast
   ========================================================= */
.toast {
  position: fixed;
  bottom: var(--sp-6);
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: #fff;
  padding: var(--sp-2) var(--sp-4);
  border-radius: var(--r-pill);
  z-index: 100;
  font-size: var(--fs-sm);
  max-width: calc(100% - 2rem);
  box-shadow: var(--sh-lg);
  animation: toast-in var(--t-base) var(--ease);
}
@keyframes toast-in {
  from { opacity: 0; transform: translate(-50%, 8px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

/* =========================================================
   Misc
   ========================================================= */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  border: 0;
}
.drag-over { outline: 2px dashed var(--accent); outline-offset: 2px; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
  padding: 2px var(--sp-2);
  border-radius: var(--r-pill);
  font-size: var(--fs-xs);
  font-weight: 500;
  background: var(--hover);
  color: var(--muted);
}
.badge.success { background: var(--success-bg); color: var(--success); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.danger { background: var(--danger-bg); color: var(--danger); }
.badge.info { background: var(--info-bg); color: var(--info); }

/* tooltip via data-tooltip */
[data-tooltip] { position: relative; }
[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%) scale(0.96);
  background: var(--ink);
  color: #fff;
  padding: 4px 8px;
  border-radius: var(--r-sm);
  font-size: var(--fs-xs);
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--t-fast) var(--ease), transform var(--t-fast) var(--ease);
  z-index: 50;
}
[data-tooltip]:hover::after,
[data-tooltip]:focus-visible::after {
  opacity: 1;
  transform: translateX(-50%) scale(1);
}

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(28, 27, 25, 0.35);
  z-index: 35;
}

/* =========================================================
   Responsive
   ========================================================= */
/* Tablet & below: sidebar becomes drawer, panels become drawers */
@media (max-width: 1099px) {
  .sidebar-close { display: inline-flex; }
  /* Fixed drawer must not participate in flex width — otherwise main + sidebar overflow the viewport */
  .app {
    display: block;
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
    overflow-x: clip;
  }
  .main-wrap {
    width: 100%;
    max-width: 100%;
    height: 100%;
    min-height: 0;
  }
  .workspace-grid,
  .workspace-grid.ai-open {
    grid-template-columns: 1fr;
  }
  #view-workspace .ai-panel {
    position: fixed;
    top: 0;
    bottom: 0;
    max-height: none;
    align-self: auto;
  }
  .structure-panel,
  .ai-panel {
    position: fixed;
    z-index: 45;
    top: 0;
    bottom: 0;
    width: min(92vw, var(--structure-w));
    border-radius: 0;
    overflow-y: auto;
    box-shadow: var(--sh-lg);
  }
  .structure-panel {
    left: 0;
    transform: translateX(-105%);
    transition: transform var(--t-base) var(--ease);
  }
  .structure-panel.open { transform: translateX(0); }
  .ai-panel {
    right: 0;
    left: auto;
    transform: translateX(105%);
    transition: transform var(--t-base) var(--ease);
  }
  .ai-panel.open {
    transform: translateX(0);
    display: flex !important;
  }
  .ai-panel.ai-mode-result {
    overflow: hidden;
    flex-direction: column;
  }
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(92vw, var(--sidebar-w));
    height: 100vh;
    height: 100dvh;
    transform: translateX(-105%);
    transition: transform var(--t-base) var(--ease);
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-backdrop.open { display: block; }
  .topbar-menu { display: inline-flex; }
  .view { padding: var(--sp-5); }
}

@media (min-width: 1100px) {
  .topbar-menu.book-structure { display: inline-flex; }
  .ai-panel[hidden] { display: none !important; }

  #view-workspace .workspace-grid.with-structure {
    min-height: calc(100vh - 11rem);
  }
  #view-workspace .workspace-grid.with-structure .structure-panel {
    max-height: calc(100vh - 11rem);
  }

  .workspace-grid {
    grid-template-columns: minmax(0, 1fr) 0;
  }
  .workspace-grid.ai-open:not(.with-structure) {
    grid-template-columns: minmax(0, 1fr) var(--ai-w);
  }
  .workspace-grid.with-structure {
    grid-template-columns: var(--structure-w) minmax(0, 1fr) 0;
  }
  .workspace-grid.with-structure.ai-open {
    grid-template-columns: var(--structure-w) minmax(0, 1fr) var(--ai-w);
  }
  .workspace-grid:not(.with-structure) .structure-panel {
    display: none;
  }
}

/* Mobile */
@media (max-width: 767px) {
  .view { padding: var(--sp-4); }
  .view-head { flex-direction: column; align-items: stretch; gap: var(--sp-3); }
  .view-head .btn { width: 100%; }
  .scratch-board-wrap { padding: var(--sp-4); }
  .scratch-board { grid-template-columns: repeat(auto-fill, minmax(min(160px, 100%), 1fr)); gap: var(--sp-5) var(--sp-4); }
  .sticky-note { min-height: 150px; }
  .books-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--sp-4) var(--sp-3);
  }
  .book-cover-title .bc-title { font-size: var(--fs-md); }
  .book-card h3 { font-size: var(--fs-md); }
  .topbar { padding: var(--sp-2) var(--sp-4); min-height: 56px; }
  .topbar-crumb { font-size: var(--fs-md); }
  /* On mobile the page-head subtitle is too verbose — keep only the title */
  .topbar--page-head { padding-block: var(--sp-3); }
  .topbar-page-head .view-subtitle { display: none; }
  .transcript-dual { grid-template-columns: 1fr; }
  .workspace-top-actions .btn { padding: var(--sp-2) var(--sp-3); }
  /* Bottom sheets — same pattern for structure and AI editor.
     #view-workspace .ai-panel (tablet) sets top:0/bottom:0; override with equal specificity. */
  .structure-panel,
  .ai-panel,
  #view-workspace .ai-panel {
    top: auto;
    bottom: 0;
    height: min(85vh, 640px);
    max-height: min(85vh, 640px);
    width: 100%;
    border-radius: var(--r-xl) var(--r-xl) 0 0;
    box-shadow: var(--sh-lg);
  }
  .structure-panel { transform: translateY(110%); left: 0; }
  .structure-panel.open { transform: translateY(0); }
  .ai-panel,
  #view-workspace .ai-panel {
    transform: translateY(110%);
    right: 0;
    left: 0;
    width: 100%;
  }
  .ai-panel.open,
  #view-workspace .ai-panel.open { transform: translateY(0); }
  .ai-panel,
  #view-workspace .ai-panel {
    gap: 0;
    padding: 0;
  }
  .ai-panel::before {
    content: "";
    width: 36px;
    height: 4px;
    margin: 9px auto 0;
    border-radius: var(--r-pill);
    background: var(--border);
  }
  .ai-panel .panel-head {
    margin: 0;
    padding: var(--sp-3) var(--sp-4);
    border-bottom: 1px solid var(--border);
  }
  .ai-panel .ai-result,
  .ai-panel .ai-menu {
    padding: var(--sp-3) var(--sp-4) var(--sp-4);
  }
  .ai-panel .ai-result {
    gap: var(--sp-3);
  }
  .ai-panel .ai-preview {
    gap: var(--sp-3);
  }
  .ai-panel .ai-preview-actions {
    margin: 0 calc(var(--sp-4) * -1) calc(var(--sp-4) * -1);
    padding: var(--sp-3) var(--sp-4);
  }
  .illustration-generate-actions {
    margin-inline: calc(var(--sp-1) * -1);
    padding-bottom: var(--sp-2);
  }
  .dictation-bar { position: sticky; bottom: 0; background: var(--surface); z-index: 2; }
  .modal { width: calc(100% - 1rem); max-width: calc(100% - 1rem); margin: auto; }
  .modal-inner { padding: var(--sp-4); }

  /* Wizard header stays as a row: title on the left, close icon on the right */
  .view-head--wizard {
    flex-direction: row;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--sp-3);
  }
  .view-head--wizard .btn { width: auto; }
  .view-head--wizard h1 { font-size: var(--fs-xl); }
  .view-head--wizard .hint { font-size: var(--fs-xs); }
}

/* Landscape phone — wizard must fit on screen */
@media (max-width: 900px) and (max-height: 480px) and (orientation: landscape) {
  .topbar { min-height: 48px; padding: var(--sp-1) var(--sp-3); }
  .topbar-crumb { font-size: var(--fs-base); }
  #view-onboarding .view { padding: var(--sp-2) var(--sp-4) var(--sp-4); }
  #view-onboarding .view-head { margin-bottom: var(--sp-2); }
  #view-onboarding .view-head--wizard h1 { font-size: var(--fs-lg); }
  #view-onboarding .form-card { padding: var(--sp-3); box-shadow: none; }
  #view-onboarding .form-card.stack { gap: var(--sp-2); }
  #view-onboarding .form-card .hint { margin: 0 0 var(--sp-1); font-size: var(--fs-xs); }
  #view-onboarding .form-card input,
  #view-onboarding .form-card textarea { min-height: 38px; }
  .wizard-actions { gap: var(--sp-2); margin-top: var(--sp-3); }
  .wizard-actions .btn { min-height: 40px; }
  .wizard-actions__links { gap: var(--sp-1); }
  .btn-link { min-height: 32px; padding: var(--sp-1); }
}

/* Small phones — keep 2 columns but tighter */
@media (max-width: 380px) {
  .books-grid { gap: var(--sp-3) var(--sp-2); }
  .book-cover-title { padding: 12px 10px 10px 16px; }
  .book-cover-title .bc-title { font-size: var(--fs-sm); }
}

/* Tablet — 3 columns of covers */
@media (min-width: 768px) and (max-width: 1099px) {
  .books-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (hover: hover) and (pointer: fine) {
  .touch-only { display: none; }
}
/* Touch devices: always show the book menu button (no hover) */
@media (hover: none) {
  .book-menu-btn { opacity: 1; }
}

/* Focus: strip UA blue ring, show accent only for keyboard */
:focus {
  outline: none;
}
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.btn:focus-visible,
.btn-link:focus-visible,
.path-card:focus-visible,
button:focus-visible,
a:focus-visible,
[role="button"]:focus-visible,
summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.btn-primary:focus-visible {
  outline-color: #fff;
  outline-offset: 2px;
  box-shadow: 0 0 0 3px var(--accent);
}

/* Dictation: green mic button, gold icon (workspace + scratch notes) */
button.dictation-mic-btn.btn-primary:not(:disabled) {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--mic-gold);
}
button.dictation-mic-btn.btn-primary:not(:disabled) .dictation-mic-label {
  color: var(--mic-gold);
}
button.dictation-mic-btn.btn-primary:not(:disabled):hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  color: var(--mic-gold-hover);
}
button.dictation-mic-btn.btn-primary:not(:disabled):hover .dictation-mic-label {
  color: var(--mic-gold-hover);
}
button.dictation-mic-btn.btn-primary:not(:disabled):active:not(:disabled) {
  transform: scale(0.98);
}
button.dictation-mic-btn.btn-primary:not(:disabled) svg,
button.dictation-mic-btn.btn-primary:not(:disabled) svg path {
  stroke: var(--mic-gold);
}
button.dictation-mic-btn.btn-primary:not(:disabled):hover svg,
button.dictation-mic-btn.btn-primary:not(:disabled):hover svg path {
  stroke: var(--mic-gold-hover);
}
.dictation-bar.recording button.dictation-mic-btn.btn-primary:disabled {
  opacity: 0.5;
  background: var(--accent);
  border-color: var(--accent);
}
.dictation-bar.recording button.dictation-mic-btn.btn-primary:disabled svg,
.dictation-bar.recording button.dictation-mic-btn.btn-primary:disabled svg path {
  stroke: var(--faint);
}

/* Toggle mic button — single control that morphs on recording.
   Idle: mic icon + "Начать диктовку". Recording: stop icon + "Остановить". */
.dictation-mic-btn .stop-icon { display: none; }
.dictation-mic-btn.is-recording .mic-icon { display: none; }
.dictation-mic-btn.is-recording .stop-icon { display: inline-flex; }
.dictation-mic-btn .label-rec { display: none; }
.dictation-mic-btn.is-recording .label-idle { display: none; }
@container (min-width: 26rem) {
  .dictation-mic-btn .label-idle { display: inline; }
  .dictation-mic-btn.is-recording .label-idle { display: none; }
  .dictation-mic-btn.is-recording .label-rec { display: inline; }
}

button.dictation-mic-btn.btn-primary.is-recording {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
  animation: rec-btn-pulse 1.4s ease-in-out infinite;
}
button.dictation-mic-btn.btn-primary.is-recording:hover {
  background: #a01717;
  border-color: #a01717;
}
button.dictation-mic-btn.btn-primary.is-recording .dictation-mic-label { color: #fff; }
button.dictation-mic-btn.btn-primary.is-recording svg,
button.dictation-mic-btn.btn-primary.is-recording svg path { stroke: #fff; }
@keyframes rec-btn-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(185, 28, 28, 0.45); }
  50% { box-shadow: 0 0 0 7px rgba(185, 28, 28, 0); }
}
