:root {
  color-scheme: dark;
  --bg: #020711;
  --bg-soft: #07101d;
  --panel: rgba(8, 15, 28, 0.84);
  --panel-strong: rgba(12, 19, 35, 0.94);
  --line: rgba(93, 135, 210, 0.24);
  --line-strong: rgba(78, 141, 255, 0.44);
  --ink: #f7fbff;
  --muted: #a8b5cb;
  --soft: #7a879b;
  --blue: #1874d9;
  --blue-strong: #0d5fc7;
  --cyan: #56a7ff;
  --shadow: rgba(12, 52, 120, 0.26);
  --font: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
}

body {
  min-width: 320px;
  height: 100vh;
  margin: 0;
  overflow: hidden;
  font-family: var(--font);
  color: var(--ink);
  background:
    linear-gradient(180deg, #01060f 0%, #020914 54%, #020813 100%);
}

body::before {
  position: fixed;
  inset: 0;
  z-index: -2;
  pointer-events: none;
  content: "";
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.02) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.015) 1px, transparent 1px);
  background-size: 88px 88px;
  mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.48), transparent 70%);
}

button,
input,
textarea,
select {
  font: inherit;
}

button {
  color: inherit;
}

button:disabled {
  cursor: progress;
  opacity: 0.72;
}

a {
  color: inherit;
  text-decoration: none;
}

svg {
  display: block;
  fill: currentColor;
}

.creator-shell {
  display: flex;
  flex-direction: column;
  width: min(100% - 42px, 1600px);
  height: calc(100vh - 20px);
  min-height: 0;
  margin: 10px auto;
}

.config-banner {
  display: flex;
  gap: 14px;
  align-items: center;
  border: 1px solid rgba(75, 104, 165, 0.28);
  border-radius: 16px;
  padding: 12px 16px;
  margin-bottom: 12px;
  color: #d9e7fb;
  background: rgba(8, 15, 28, 0.82);
}

.config-banner[hidden] {
  display: none;
}

.config-banner svg {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  color: #63a6ff;
}

.config-banner strong {
  display: block;
  color: #f4f8ff;
  font-size: 14px;
}

.config-banner p {
  margin: 3px 0 0;
  color: #bfd0e6;
  font-size: 13px;
  line-height: 1.4;
}

.config-banner code {
  padding: 1px 6px;
  border-radius: 5px;
  background: rgba(0, 0, 0, 0.38);
  font-size: 12px;
}

.config-banner a {
  color: #8bc2ff;
  text-decoration: underline;
}

/* Signed-in users switch theme from inside the profile menu; the standalone
   header toggle is hidden for them and replaced by this switch row. */
body.is-authenticated .theme-toggle {
  display: none !important;
}

.theme-switch {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
}

.theme-switch-label {
  flex: 1;
  text-align: left;
}

.theme-switch-track {
  position: relative;
  flex: 0 0 auto;
  width: 38px;
  height: 20px;
  border-radius: 999px;
  background: rgba(120, 132, 156, 0.45);
  transition: background 180ms ease;
}

.theme-switch-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
  transition: transform 180ms ease;
}

.theme-switch[aria-pressed="true"] .theme-switch-track {
  background: var(--blue);
}

.theme-switch[aria-pressed="true"] .theme-switch-thumb {
  transform: translateX(18px);
}

/* ───────── Верхняя единая панель ───────── */
.app-bar {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 24px;
  min-height: 56px;
  padding: 4px 18px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(8, 15, 28, 0.84);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.28);
}

.brand {
  display: inline-flex;
  align-items: center;
}

.brand-logo {
  display: block;
  width: auto;
  height: 44px;
}

.project-title {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 14px;
  justify-content: center;
}

.project-title input {
  width: min(100%, 280px);
  border: 0;
  padding: 4px 10px;
  border-radius: 8px;
  color: #f7f8ff;
  background: transparent;
  outline: none;
  font-size: 16px;
  font-weight: 800;
  text-align: center;
  transition: background 160ms ease;
}

.project-title input:hover,
.project-title input:focus {
  background: rgba(255, 255, 255, 0.04);
}

.page-status {
  display: inline-flex;
  min-height: 30px;
  align-items: center;
  border: 1px solid rgba(86, 167, 255, 0.28);
  border-radius: 999px;
  padding: 0 12px;
  color: #d9ecff;
  background:
    linear-gradient(180deg, rgba(24, 116, 217, 0.22), rgba(8, 18, 36, 0.92)),
    rgba(13, 25, 46, 0.9);
  font-size: 13px;
  white-space: nowrap;
}

.account-bar {
  display: flex;
  align-items: center;
  gap: 8px;
}

.credit-pill,
.create-comic-icon,
.icon-action,
.avatar-button,
.tool-button,
.button-gradient {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 34px;
  border: 1px solid rgba(83, 144, 255, 0.2);
  border-radius: 10px;
  background: rgba(12, 22, 42, 0.82);
  cursor: pointer;
  transition:
    transform 160ms ease,
    border-color 160ms ease,
    background 160ms ease,
    box-shadow 160ms ease;
}

.credit-pill {
  padding: 0 14px;
  color: #f2f3ff;
  font-weight: 700;
  font-size: 13px;
}

.create-comic-icon {
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  padding: 0;
}

.create-comic-icon img {
  display: block;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  object-fit: cover;
}

.login-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  min-width: 120px;
  padding: 0 28px;
  border: 1px solid rgba(87, 155, 255, 0.45);
  border-radius: 10px;
  color: #f2f3ff;
  font-weight: 700;
  font-size: 15px;
  line-height: 1;
  background: linear-gradient(180deg, rgba(24, 116, 217, 0.55), rgba(11, 26, 50, 0.92));
  cursor: pointer;
  transition:
    transform 160ms ease,
    border-color 160ms ease,
    box-shadow 160ms ease;
}

.login-button:hover {
  transform: translateY(-1px);
  border-color: rgba(120, 178, 255, 0.7);
  box-shadow: 0 6px 18px rgba(25, 111, 237, 0.28);
}

.login-button[hidden],
.create-comic-icon[hidden],
.credit-pill[hidden],
.profile-wrap[hidden],
.burger-wrap[hidden] {
  display: none;
}

.credit-pill svg {
  width: 16px;
  height: 16px;
  color: #63a6ff;
}

.icon-action {
  width: 34px;
  height: 34px;
  padding: 0;
}

.icon-action.small {
  width: 32px;
  height: 32px;
  min-height: 32px;
}

.header-tools {
  display: flex;
  align-items: center;
  gap: 8px;
}

.header-tools[hidden] {
  display: none;
}

.icon-action.is-active {
  color: #ffffff;
  border-color: transparent;
  background: linear-gradient(180deg, #1d86ee, #0f5fbe);
}

.icon-action.is-active:hover {
  color: #ffffff;
}

.icon-action svg,
.tool-button svg,
.button-gradient svg {
  width: 18px;
  height: 18px;
}

.avatar-button {
  width: 34px;
  height: 34px;
  padding: 0;
  border-color: rgba(83, 144, 255, 0.34);
  background:
    linear-gradient(180deg, rgba(24, 116, 217, 0.3), rgba(11, 26, 50, 0.92)),
    #121833;
}

.avatar {
  display: grid;
  width: 100%;
  height: 100%;
  place-items: center;
  color: #ffe1c2;
  font-weight: 900;
  font-size: 14px;
}

.credit-pill:hover,
.create-comic-icon:hover,
.icon-action:hover,
.avatar-button:hover,
.tool-button:hover,
.button-gradient:hover {
  transform: translateY(-1px);
  border-color: rgba(87, 155, 255, 0.5);
}

/* ───────── Поповеры (профиль/бургер) ───────── */
.profile-wrap,
.burger-wrap {
  position: relative;
}

.popover {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  z-index: 20;
  display: grid;
  min-width: 240px;
  border: 1px solid rgba(75, 104, 165, 0.26);
  border-radius: 16px;
  padding: 6px;
  background: rgba(8, 15, 28, 0.98);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
}

.popover[hidden] {
  display: none;
}

.popover-header {
  display: grid;
  gap: 2px;
  padding: 10px 12px 12px;
  border-bottom: 1px solid rgba(75, 104, 165, 0.16);
  margin-bottom: 4px;
}

.popover-header strong {
  font-size: 14px;
  color: #f7fbff;
}

.popover-header span {
  color: var(--muted);
  font-size: 12px;
}

.save-status {
  min-width: 94px;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.save-status.is-saving {
  color: #8bc2ff;
}

.save-status.is-saved {
  color: #7bdc9b;
}

.save-status.is-error {
  color: #ff9b9b;
}

.popover button,
.popover-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 40px;
  padding: 0 12px;
  border: 0;
  border-radius: 8px;
  color: #e8eaff;
  background: transparent;
  cursor: pointer;
  text-align: left;
  font-size: 13px;
  font-weight: 600;
}

.popover button svg,
.popover-row svg {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  color: #63a6ff;
}

.popover button:hover,
.popover-row:hover {
  background: rgba(20, 41, 74, 0.72);
}

/* Ссылка на галерею мерцает так же, как в шапке остальных страниц сайта. */
.popover-row[href="/gallery"],
.popover-row[href="/gallery"]:hover {
  background: linear-gradient(
    90deg,
    var(--cyan) 0%,
    #d8ecff 25%,
    var(--blue) 50%,
    #d8ecff 75%,
    var(--cyan) 100%
  );
  background-size: 200% auto;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
  animation: nav-gallery-shimmer 2.8s linear infinite;
}

@keyframes nav-gallery-shimmer {
  to {
    background-position: 200% center;
  }
}

@media (prefers-reduced-motion: reduce) {
  .popover-row[href="/gallery"] {
    animation: none;
  }
}

.popover button[disabled] {
  color: var(--soft);
  cursor: not-allowed;
  opacity: 0.5;
}

.popover button[disabled]:hover {
  background: transparent;
}

.popover-divider {
  height: 1px;
  margin: 4px 6px;
  background: rgba(75, 104, 165, 0.16);
}

.popover-row span {
  flex: 1;
}

.popover-row select {
  min-height: 28px;
  width: 80px;
  padding: 0 6px;
  font-size: 12px;
}

/* ───────── Рабочая область ───────── */
.workspace {
  --preview-height: 100%;
  --comic-page-ratio: 2 / 3;
  --right-panel-reserve: 144px;

  display: grid;
  grid-template-columns: 440px minmax(640px, 1fr) 480px;
  align-items: stretch;
  flex: 1 1 auto;
  gap: 16px;
  height: 100%;
  min-height: 0;
  margin-top: 14px;
}

.right-stack {
  --side-pad: 18px;
  --side-control-gap: 12px;

  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  gap: 12px;
  align-self: stretch;
  min-width: 0;
  height: 100%;
  max-height: none;
  min-height: 0;
}

.side-panel {
  --side-pad: 18px;
  --side-control-gap: 12px;

  display: flex;
  flex-direction: column;
  align-self: stretch;
  min-height: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(8, 15, 28, 0.82);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.28);
}

.left-panel {
  position: relative;
  z-index: 18;
  flex: 1;
  height: 100%;
  min-height: 0;
  overflow: visible;
}

/* ───────── Левая панель: верхние выпадающие кнопки ───────── */
.left-panel-head {
  position: relative;
  z-index: 12;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 14px var(--side-pad) 12px;
  border-bottom: 1px solid var(--line);
}

.dropdown {
  position: relative;
  min-width: 0;
}

.dropdown-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 44px;
  padding: 0 14px;
  border: 1px solid rgba(83, 144, 255, 0.24);
  border-radius: 12px;
  background: rgba(12, 22, 42, 0.82);
  color: #e8eaff;
  cursor: pointer;
  font: inherit;
  text-align: left;
  transition: border-color 160ms ease, background 160ms ease;
}

.dropdown-toggle:hover {
  border-color: rgba(87, 155, 255, 0.5);
  background: rgba(15, 28, 50, 0.92);
}

.dropdown-toggle[aria-expanded="true"] {
  border-color: rgba(87, 155, 255, 0.78);
  background: rgba(16, 44, 82, 0.54);
  box-shadow: 0 0 24px rgba(24, 116, 217, 0.16);
}

.dropdown-label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.dropdown-value {
  flex: 1;
  overflow: hidden;
  color: #f5f6ff;
  font-size: 13px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dropdown-caret {
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  color: #8aa1c6;
  transition: transform 160ms ease;
}

.dropdown-toggle[aria-expanded="true"] .dropdown-caret {
  transform: rotate(180deg);
}

.dropdown-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  z-index: 30;
  display: grid;
  gap: 4px;
  padding: 6px;
  border: 1px solid rgba(75, 104, 165, 0.32);
  border-radius: 14px;
  background: rgba(8, 15, 28, 0.98);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
}

.dropdown-menu.wide {
  right: auto;
  min-width: 100%;
  width: max(100%, 280px);
  gap: 6px;
}

.dropdown-menu[hidden] {
  display: none;
}

.dropdown-item {
  display: flex;
  align-items: center;
  min-height: 38px;
  padding: 0 12px;
  border: 1px solid transparent;
  border-radius: 8px;
  color: #e8eaff;
  background: transparent;
  cursor: pointer;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  text-align: left;
  transition: background 160ms ease, border-color 160ms ease;
}

.dropdown-item:hover {
  background: rgba(20, 41, 74, 0.72);
}

.dropdown-item.is-selected {
  border-color: rgba(87, 155, 255, 0.6);
  color: #ffffff;
  background: rgba(17, 57, 113, 0.52);
}

.style-option {
  min-height: 62px;
  gap: 10px;
  padding: 7px 10px;
}

.style-option img {
  width: 48px;
  height: 48px;
  flex: 0 0 48px;
  border-radius: 8px;
  object-fit: cover;
  border: 1px solid rgba(124, 164, 232, 0.28);
  background: rgba(255, 255, 255, 0.06);
}

.style-option span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.model-option {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid rgba(75, 104, 165, 0.22);
  border-radius: 12px;
  background: rgba(12, 22, 42, 0.82);
  color: #cdd1df;
  cursor: pointer;
  font: inherit;
  text-align: left;
  transition: border-color 160ms ease, background 160ms ease;
}

.model-option:hover {
  border-color: rgba(87, 155, 255, 0.5);
  background: rgba(15, 28, 50, 0.92);
}

.model-option.is-selected {
  border-color: rgba(87, 155, 255, 0.78);
  background: rgba(16, 44, 82, 0.54);
  box-shadow: 0 0 24px rgba(24, 116, 217, 0.16);
}

.model-option-head {
  display: flex;
  align-items: center;
  gap: 10px;
}

.model-icon {
  display: grid;
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  place-items: center;
  border: 1px solid rgba(124, 164, 232, 0.24);
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.06);
}

.model-icon img {
  width: 24px;
  height: 24px;
  object-fit: contain;
}

.seedream-icon {
  background: linear-gradient(135deg, rgba(43, 137, 255, 0.28), rgba(34, 209, 167, 0.16));
}

.google-icon {
  background: #ffffff;
}

.openai-icon {
  background: #ffffff;
}

.model-name-stack {
  display: grid;
  min-width: 0;
  gap: 2px;
}

.model-option-head strong {
  color: #f5f6ff;
  font-size: 14px;
  line-height: 1.1;
}

.model-option-head em {
  color: var(--muted);
  font-style: normal;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* ───────── Левая панель: история и AI-кнопка ───────── */
.story-area {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  gap: 8px;
  padding: var(--side-pad);
}

.story-wrap {
  position: relative;
  flex: 1;
  min-height: 0;
}

.story-wrap textarea {
  display: block;
  height: 100%;
  min-height: 180px;
  width: 100%;
  resize: none;
}

.story-enhance {
  position: absolute;
  right: 10px;
  bottom: 10px;
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border: 1px solid rgba(83, 144, 255, 0.34);
  border-radius: 50%;
  background: var(--blue);
  box-shadow:
    0 12px 28px rgba(14, 78, 171, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.18);
  color: #ffffff;
  cursor: pointer;
  overflow: hidden;
  transition:
    border-color 180ms ease,
    box-shadow 180ms ease,
    filter 180ms ease;
}

.story-enhance:hover {
  border-color: rgba(172, 217, 255, 0.7);
  box-shadow:
    0 16px 34px rgba(49, 123, 255, 0.42),
    0 0 0 4px rgba(82, 157, 255, 0.12),
    inset 0 1px 0 rgba(255, 255, 255, 0.32);
  filter: saturate(1.1);
}

.story-enhance:active {
  border-color: rgba(211, 235, 255, 0.82);
  box-shadow:
    0 10px 24px rgba(49, 123, 255, 0.36),
    0 0 0 5px rgba(82, 157, 255, 0.14),
    inset 0 2px 8px rgba(5, 12, 32, 0.32);
}

.story-enhance:disabled {
  opacity: 1;
}

.story-enhance.is-busy {
  position: absolute;
  right: 10px;
  bottom: 10px;
  opacity: 1;
  box-shadow:
    0 14px 34px rgba(49, 123, 255, 0.38),
    0 0 0 4px rgba(82, 157, 255, 0.12),
    inset 0 1px 0 rgba(255, 255, 255, 0.28);
}

.story-enhance.is-busy::after {
  content: none;
}

.story-enhance.is-busy svg {
  opacity: 1;
  transform: none;
}

.story-enhance svg {
  position: relative;
  z-index: 1;
  width: 18px;
  height: 18px;
  filter: drop-shadow(0 1px 4px rgba(2, 8, 18, 0.28));
  transform-origin: 50% 50%;
  transition: opacity 150ms ease, transform 180ms ease;
}

.field-label {
  display: block;
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

textarea,
input,
select {
  width: 100%;
  border: 1px solid rgba(75, 104, 165, 0.2);
  border-radius: 12px;
  color: #f5f6ff;
  background: rgba(5, 11, 22, 0.88);
  outline: none;
}

textarea {
  resize: vertical;
  padding: 14px 16px;
  line-height: 1.55;
}

select,
input {
  min-height: 42px;
  padding: 0 12px;
}

textarea:focus,
input:focus,
select:focus {
  border-color: rgba(87, 155, 255, 0.72);
  box-shadow: 0 0 0 3px rgba(24, 116, 217, 0.12);
}

.counter-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 10px 0 16px;
  padding: 6px 10px;
  color: var(--muted);
  font-size: 12px;
}

.counter-row .is-over-limit {
  color: #e5484d;
  font-weight: 600;
}

.model-specs {
  display: grid;
  gap: 4px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.model-specs li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 12px;
}

.model-price {
  color: #f5f6ff;
  font-weight: 800;
}

.spec-bar {
  display: inline-flex;
  gap: 3px;
  align-items: center;
}

.spec-bar i {
  width: 16px;
  height: 6px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.1);
  transition: background 0.2s ease, box-shadow 0.2s ease;
}

.spec-bar.level-1 i:nth-child(1),
.spec-bar.level-2 i:nth-child(-n + 2),
.spec-bar.level-3 i {
  background: var(--bar-color, rgba(255, 255, 255, 0.5));
}

.spec-bar.good {
  --bar-color: #42d686;
}

.spec-bar.good.level-3 i {
  box-shadow: 0 0 6px rgba(66, 214, 134, 0.45);
}

.spec-bar.mid {
  --bar-color: #ffc24e;
}

.spec-bar.bad {
  --bar-color: #ff6b6b;
}

.model-summary {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

/* ───────── Закреплённая CTA ───────── */
.cta-footer {
  margin-top: auto;
  padding: var(--side-pad);
  border-top: 1px solid var(--line);
  background: rgba(6, 12, 24, 0.58);
}

.button-gradient {
  border-color: transparent;
  color: #ffffff;
  background:
    linear-gradient(135deg, #1c7ae6, #0f5fc7),
    rgba(20, 24, 48, 0.9);
  box-shadow: 0 18px 40px rgba(14, 78, 171, 0.28);
  font-weight: 800;
  font-size: 14px;
}

.button-gradient.full {
  width: 100%;
  min-height: 48px;
}

.button-gradient.ghost-gradient {
  background:
    linear-gradient(135deg, rgba(28, 122, 230, 0.22), rgba(15, 95, 199, 0.2)),
    rgba(20, 24, 48, 0.9);
  box-shadow: none;
  border-color: rgba(83, 144, 255, 0.26);
}

.continue-button {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 10px;
  padding: 11px 16px;
  border: 1px solid rgba(83, 144, 255, 0.32);
  border-radius: 12px;
  background: rgba(12, 22, 42, 0.82);
  color: #cfe2ff;
  font: inherit;
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  transition: border-color 160ms ease, background 160ms ease, color 160ms ease, opacity 160ms ease;
}

.continue-button:hover:not(:disabled) {
  border-color: rgba(86, 167, 255, 0.6);
  color: #ffffff;
  background: rgba(20, 40, 76, 0.88);
}

.continue-button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.continue-button svg {
  width: 16px;
  height: 16px;
  fill: currentColor;
}

.cost-note {
  margin: 10px 0 0;
  color: #9fa5ba;
  text-align: center;
  font-size: 12px;
}

/* ───────── Холст и страницы ───────── */
.comic-stage {
  display: grid;
  align-self: stretch;
  min-height: 0;
  min-width: 0;
  place-items: center;
}

/* Стрелки перелистывания страниц: только на мобильной раскладке. */
.page-nav-arrow {
  display: none;
}

/* ───────── Оценка комикса (сворачиваемая плашка со звёздами, только ПК) ───────── */
/* Оценка комикса: палец вверх/вниз внутри общей плашки действий. */
.comic-rating {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.comic-rating[hidden] {
  display: none;
}

.comic-rating-thumbs {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.comic-rating-thumb {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 3px;
  border: none;
  background: none;
  cursor: pointer;
  color: rgba(122, 135, 155, 0.65);
  transition: color 120ms ease, transform 120ms ease;
}

.comic-rating-thumb svg {
  width: 17px;
  height: 17px;
  fill: currentColor;
}

.comic-rating-thumb:hover {
  transform: scale(1.12);
  color: #e8eaff;
}

.comic-rating-thumb.is-active {
  color: var(--cyan);
}

.comic-rating-thumb.is-down.is-active {
  color: #ff7a7a;
}

.comic-rating-thumb:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 2px;
  border-radius: 4px;
}

.comic-rating-hint {
  font-size: 12px;
  font-weight: 700;
  color: var(--cyan);
  white-space: nowrap;
}

.comic-rating-hint[hidden] {
  display: none;
}

/* Переключатель публикации: чекбокс с подписью внутри общей плашки. */
.comic-publish-panel {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  white-space: nowrap;
}

.comic-publish-panel.is-locked {
  cursor: not-allowed;
}

.comic-publish-check {
  position: relative;
  display: inline-grid;
  width: 26px;
  height: 26px;
  place-items: center;
}

.comic-publish-check input {
  position: absolute;
  inset: 0;
  margin: 0;
  opacity: 0;
  cursor: inherit;
}

.comic-publish-check span {
  display: inline-grid;
  width: 24px;
  height: 24px;
  border: 1px solid rgba(113, 137, 176, 0.7);
  border-radius: 8px;
  place-items: center;
  background: rgba(4, 10, 20, 0.9);
  color: transparent;
  transition:
    border-color 160ms ease,
    background 160ms ease,
    color 160ms ease;
}

.comic-publish-check svg {
  width: 17px;
  height: 17px;
  fill: currentColor;
}

.comic-publish-check input:checked + span {
  border-color: rgba(86, 167, 255, 0.9);
  background: linear-gradient(180deg, #2f8bff, #1874d9);
  color: #ffffff;
}

.comic-publish-check input:focus-visible + span {
  outline: 2px solid var(--cyan);
  outline-offset: 3px;
}

.comic-publish-title {
  color: #f4f7ff;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.2;
}

.comic-actions {
  position: absolute;
  left: 50%;
  bottom: 6px;
  z-index: 3;
  display: flex;
  flex-direction: column;
  align-items: center;
  max-width: calc(100% - 32px);
  pointer-events: none;
  transform: translateX(-50%);
}

.comic-actions[hidden] {
  display: none;
}

/* Единая компактная плашка: публикация и оценка в одну строку. */
.comic-actions-panel {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 32px; /* приподнята над язычком */
  padding: 7px 16px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(8, 15, 28, 0.9);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.42);
  transition:
    transform 300ms cubic-bezier(0.22, 1, 0.36, 1),
    opacity 220ms ease;
}

/* Свёрнуто: плашка плавно уезжает вниз за кромку превью. */
.comic-actions.is-collapsed .comic-actions-panel {
  transform: translateY(150%);
  opacity: 0;
  pointer-events: none;
}

.comic-actions-divider {
  width: 1px;
  height: 20px;
  background: var(--line);
}

.comic-actions-tab {
  pointer-events: auto;
  position: absolute;
  left: 50%;
  bottom: 0;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 22px;
  padding: 2px 11px;
  border: 1px solid rgba(86, 167, 255, 0.28);
  border-radius: 999px;
  background: rgba(8, 15, 28, 0.92);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  transform: translateX(-50%);
  transition:
    color 160ms ease,
    background 160ms ease;
}

.comic-actions-tab:hover {
  color: #e8eaff;
  background: rgba(20, 41, 74, 0.92);
}

.comic-actions-tab:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 2px;
}

.comic-actions-tab svg {
  width: 14px;
  height: 14px;
  fill: currentColor;
  transition: transform 280ms cubic-bezier(0.22, 1, 0.36, 1);
}

.comic-actions.is-collapsed .comic-actions-tab svg {
  transform: rotate(180deg);
}

@media (prefers-reduced-motion: reduce) {
  .comic-actions-panel,
  .comic-actions-tab svg {
    transition: none;
  }
}

.comic-canvas {
  position: relative;
  display: grid;
  overflow: hidden;
  width: auto;
  max-width: 100%;
  height: 100%;
  max-height: 100%;
  aspect-ratio: var(--comic-page-ratio);
  margin: 0 auto;
  border: 1px solid var(--line);
  border-radius: 14px;
  place-items: center;
  background:
    linear-gradient(180deg, rgba(24, 116, 217, 0.12), transparent 40%),
    #040a14;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.34);
  transition: width 180ms ease;
}

.comic-canvas img {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
  border-radius: inherit;
  background: #07101d;
}

/* Когда показываем плашку действий, прижимаем комикс к верху холста, чтобы
   под ним оставалось свободное поле. */
.comic-canvas.has-rating img,
.comic-canvas.has-publication img {
  object-position: center top;
}

.comic-loading,
.comic-empty {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: grid;
  place-items: center;
  background: rgba(3, 5, 13, 0.76);
  text-align: center;
}

.comic-loading[hidden],
.comic-empty[hidden],
.auth-overlay[hidden],
.coins-overlay[hidden],
.toast[hidden] {
  display: none !important;
}

.comic-loading span {
  width: 54px;
  height: 54px;
  border: 3px solid rgba(255, 255, 255, 0.16);
  border-top-color: #2f8cff;
  border-radius: 50%;
  animation: spin 900ms linear infinite;
}

.comic-loading strong {
  margin-top: 88px;
  color: #e8e9ff;
}

.comic-empty {
  padding: 30px;
  color: var(--muted);
}

.comic-empty svg {
  width: 48px;
  height: 48px;
  color: #63a6ff;
}

/* Полноэкранный просмотр страницы — доступен и на десктопе, и на мобильных. */
.comic-lightbox {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: grid;
  /* Определённые размеры ячейки, чтобы max-width/max-height: 100% у картинки
     считались от экрана и страница была видна целиком, без обрезки. */
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
  place-items: center;
  padding: calc(16px + env(safe-area-inset-top)) 12px calc(16px + env(safe-area-inset-bottom));
  background: rgba(2, 6, 15, 0.97);
  backdrop-filter: blur(16px);
}

.comic-lightbox[hidden] {
  display: none !important;
}

.comic-lightbox img {
  display: block;
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 10px;
  box-shadow:
    0 24px 80px rgba(0, 0, 0, 0.58),
    0 0 42px rgba(24, 116, 217, 0.18);
}

.comic-lightbox-close {
  position: absolute;
  top: calc(12px + env(safe-area-inset-top));
  right: 12px;
  z-index: 2;
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 1px solid rgba(124, 169, 255, 0.28);
  border-radius: 12px;
  color: #f7fbff;
  background: rgba(8, 15, 28, 0.84);
  box-shadow: 0 16px 38px rgba(0, 0, 0, 0.34);
  cursor: pointer;
}

.comic-lightbox-close svg {
  width: 22px;
  height: 22px;
  fill: currentColor;
}

body.comic-lightbox-open {
  overflow: hidden;
  touch-action: none;
}

.comic-canvas.is-zoomable {
  cursor: zoom-in;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.page-strip {
  display: flex;
  align-items: flex-start;
  gap: var(--side-control-gap);
  margin: 0;
  padding: 10px;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 14px;
  background:
    linear-gradient(180deg, rgba(13, 25, 46, 0.86), rgba(6, 12, 24, 0.96)),
    rgba(8, 10, 24, 0.9);
  box-shadow: 0 16px 42px rgba(0, 0, 0, 0.22);
}

.page-thumb-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.page-thumb-remove {
  display: grid;
  place-items: center;
  width: 28px;
  height: 22px;
  padding: 0;
  border: 1px solid rgba(255, 99, 99, 0.32);
  border-radius: 8px;
  background: rgba(40, 12, 14, 0.72);
  color: #ff8a8a;
  cursor: pointer;
  transition: border-color 160ms ease, background 160ms ease, color 160ms ease, transform 160ms ease;
}

.page-thumb-remove:hover {
  border-color: rgba(255, 99, 99, 0.7);
  background: rgba(82, 18, 22, 0.88);
  color: #ffd2d2;
  transform: translateY(-1px);
}

.page-thumb-remove svg {
  width: 12px;
  height: 12px;
  fill: currentColor;
}

.page-thumb,
.add-page {
  position: relative;
  display: grid;
  width: 66px;
  min-width: 66px;
  aspect-ratio: 0.82;
  place-items: center;
  border: 1px solid rgba(83, 144, 255, 0.22);
  border-radius: 12px;
  background: rgba(8, 15, 28, 0.88);
  cursor: pointer;
  overflow: hidden;
  transition: transform 160ms, border-color 160ms, box-shadow 160ms;
}

.page-thumb:hover,
.add-page:hover {
  transform: translateY(-1px);
  border-color: rgba(87, 155, 255, 0.54);
}

.page-thumb img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #07101d;
}

.page-thumb span {
  position: absolute;
  bottom: 4px;
  left: 50%;
  display: grid;
  width: 20px;
  height: 20px;
  place-items: center;
  border-radius: 6px;
  border: 1px solid rgba(139, 194, 255, 0.32);
  background:
    linear-gradient(180deg, rgba(24, 116, 217, 0.92), rgba(13, 95, 199, 0.88)),
    rgba(3, 5, 13, 0.76);
  color: #f7fbff;
  box-shadow: 0 8px 18px rgba(12, 52, 120, 0.28);
  transform: translateX(-50%);
  font-size: 11px;
  font-weight: 800;
}

.page-thumb.is-active {
  border-color: rgba(87, 155, 255, 0.92);
  box-shadow: 0 0 26px rgba(18, 116, 217, 0.26);
}

/* Обложка в ленте страниц: вместо номера — компактный бейдж. */
.page-thumb.is-cover span {
  width: auto;
  height: 18px;
  padding: 0 7px;
  background:
    linear-gradient(180deg, rgba(122, 84, 255, 0.92), rgba(84, 56, 214, 0.88)),
    rgba(3, 5, 13, 0.76);
  border-color: rgba(178, 148, 255, 0.4);
  box-shadow: 0 8px 18px rgba(64, 32, 150, 0.3);
  font-size: 9px;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.add-page svg {
  width: 24px;
  height: 24px;
  color: #d8d9e7;
}

/* ───────── Правая панель — табы ───────── */
.right-panel {
  flex: 1;
  max-height: none;
  min-height: 0;
}

.right-panel-head {
  padding: 14px var(--side-pad) 12px;
  border-bottom: 1px solid var(--line);
}

.right-panel-head h2 {
  margin: 0;
  color: #f5f6ff;
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 0.01em;
}

.settings-tabs {
  display: flex;
  flex: 1;
  min-height: 0;
  flex-direction: column;
}

.settings-tab-radio {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  opacity: 0;
  pointer-events: none;
}

.settings-tab-list {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 4px;
  padding: 8px var(--side-pad);
  border-bottom: 1px solid var(--line);
  background: rgba(4, 10, 22, 0.38);
}

.settings-tab {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  min-height: 34px;
  padding: 0 8px;
  border: 1px solid transparent;
  border-radius: 8px;
  color: #9eacc9;
  cursor: pointer;
  font-size: 12px;
  font-weight: 800;
  line-height: 1.1;
  text-align: center;
  user-select: none;
  transition: background 160ms ease, border-color 160ms ease, color 160ms ease;
}

.settings-tab:hover {
  background: rgba(20, 41, 74, 0.32);
  color: #f0f3ff;
}

#settingsTabScenes:checked ~ label[for="settingsTabScenes"],
#settingsTabCharacters:checked ~ label[for="settingsTabCharacters"],
#settingsTabPages:checked ~ label[for="settingsTabPages"],
#settingsTabCover:checked ~ label[for="settingsTabCover"] {
  border-color: rgba(83, 144, 255, 0.42);
  background: linear-gradient(135deg, rgba(70, 108, 255, 0.28), rgba(117, 71, 255, 0.2));
  color: #ffffff;
  box-shadow: 0 10px 22px rgba(24, 46, 96, 0.2);
}

.settings-tab-panels {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}

.settings-tab-panel {
  display: none;
  gap: 12px;
  padding: 14px var(--side-pad) 16px;
}

.settings-tabs:has(#settingsTabScenes:checked) #settingsPanelScenes,
.settings-tabs:has(#settingsTabCharacters:checked) #settingsPanelCharacters,
.settings-tabs:has(#settingsTabPages:checked) #settingsPanelPages,
.settings-tabs:has(#settingsTabCover:checked) #settingsPanelCover {
  display: grid;
}

.settings-tab-panel .hint {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.language-dropdown {
  width: 100%;
}

.language-toggle {
  min-height: 52px;
}

.language-menu {
  right: 0;
  gap: 2px;
  padding: 5px;
}

.language-option {
  justify-content: flex-start;
  min-height: 36px;
  padding: 0 14px;
  font-size: 14px;
}

.language-field {
  margin-top: 4px;
}

/* ───────── Обложка ───────── */
#settingsPanelCover .field-label {
  margin-bottom: 0;
}

#settingsPanelCover .field-label span {
  margin-left: 6px;
  color: #77809b;
  font-weight: 600;
  text-transform: none;
  letter-spacing: 0;
}

.cover-generate {
  min-height: 44px;
}

.cover-generate:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.cover-cost-note {
  margin: 0;
}

.scene-toolbar {
  display: grid;
  gap: var(--side-control-gap);
}

.full-width {
  width: 100%;
}

.tool-button {
  min-width: 56px;
  padding: 0 16px;
  font-size: 13px;
  font-weight: 700;
}

.tool-button.ghost {
  border-color: rgba(83, 144, 255, 0.24);
  background: rgba(12, 22, 42, 0.82);
}

.scene-list {
  display: grid;
  gap: var(--side-control-gap);
}

.scene-list:empty {
  display: none;
}

/* ───────── Персонажи ───────── */
.character-list {
  display: grid;
  gap: var(--side-control-gap);
}

.character-list:empty {
  display: none;
}

.character-card {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid rgba(83, 144, 255, 0.18);
  border-radius: 12px;
  background: rgba(8, 15, 28, 0.62);
}

.character-card-head {
  display: flex;
  align-items: center;
  gap: 8px;
}

.character-card-head input {
  flex: 1;
  min-height: 38px;
}

.character-card textarea {
  min-height: 60px;
  resize: vertical;
}

.character-reference {
  display: grid;
  grid-template-columns: 48px 1fr auto;
  gap: 8px;
  align-items: center;
}

.character-reference-note {
  margin: 0;
  padding: 8px 10px;
  border: 1px solid rgba(83, 144, 255, 0.18);
  border-radius: 8px;
  background: rgba(6, 12, 24, 0.55);
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.character-reference-preview {
  display: grid;
  width: 48px;
  height: 48px;
  overflow: hidden;
  place-items: center;
  border: 1px solid rgba(83, 144, 255, 0.22);
  border-radius: 8px;
  background: rgba(6, 12, 24, 0.72);
}

.character-reference-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.character-reference-preview svg {
  width: 22px;
  height: 22px;
  color: var(--muted);
}

.character-reference-upload input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.character-reference-upload span,
.character-reference-clear {
  display: grid;
  min-height: 34px;
  place-items: center;
  border: 1px solid rgba(83, 144, 255, 0.22);
  border-radius: 8px;
  background: rgba(12, 22, 42, 0.82);
  color: #f5f6ff;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}

.character-reference-clear {
  padding: 0 10px;
}

.character-reference-upload span:hover,
.character-reference-clear:hover {
  border-color: rgba(87, 155, 255, 0.5);
}

.character-remove {
  display: grid;
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  place-items: center;
  border: 1px solid rgba(255, 107, 107, 0.24);
  border-radius: 8px;
  background: rgba(40, 14, 14, 0.42);
  color: #ffb5b5;
  cursor: pointer;
  transition: background 160ms ease, border-color 160ms ease;
}

.character-remove:hover {
  border-color: rgba(255, 107, 107, 0.6);
  background: rgba(60, 18, 18, 0.6);
}

.character-remove svg {
  width: 16px;
  height: 16px;
}

/* ───────── Кол-во страниц ───────── */
.page-count-control {
  display: flex;
  align-items: center;
  gap: 10px;
  width: max-content;
}

.step-btn {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border: 1px solid rgba(83, 144, 255, 0.24);
  border-radius: 10px;
  background: rgba(12, 22, 42, 0.82);
  color: #f5f6ff;
  cursor: pointer;
  font-size: 18px;
  font-weight: 800;
  line-height: 1;
  transition: border-color 160ms ease, background 160ms ease;
}

.step-btn:hover {
  border-color: rgba(87, 155, 255, 0.5);
  background: rgba(15, 28, 50, 0.92);
}

#pageCountInput {
  width: 64px;
  text-align: center;
  font-weight: 800;
  font-size: 16px;
  appearance: textfield;
  -moz-appearance: textfield;
}

#pageCountInput::-webkit-outer-spin-button,
#pageCountInput::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.scene-empty {
  border: 1px dashed rgba(83, 144, 255, 0.28);
  border-radius: 12px;
  padding: 16px;
  color: var(--muted);
  background: rgba(6, 12, 24, 0.52);
  font-size: 13px;
  line-height: 1.45;
}

.scene-item {
  display: grid;
  grid-template-columns: 64px 1fr 32px;
  gap: 10px;
  align-items: center;
  border: 1px solid rgba(83, 144, 255, 0.1);
  border-radius: 12px;
  padding: 8px;
  background: rgba(8, 15, 28, 0.62);
  cursor: pointer;
  transition: background 160ms, border-color 160ms;
}

.scene-item:hover {
  background: rgba(14, 27, 49, 0.78);
  border-color: rgba(83, 144, 255, 0.24);
}

.scene-item.is-selected {
  border-color: rgba(87, 155, 255, 0.84);
  background: rgba(17, 57, 113, 0.26);
}

.scene-item img {
  width: 64px;
  height: 48px;
  border-radius: 6px;
  object-fit: cover;
}

.scene-item h2 {
  margin: 0 0 3px;
  font-size: 13px;
}

.scene-item p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.3;
}

.scene-delete {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  padding: 0;
  border: 1px solid rgba(255, 99, 99, 0.32);
  border-radius: 9px;
  background: rgba(40, 12, 14, 0.72);
  color: #ff8a8a;
  cursor: pointer;
  transition: border-color 160ms ease, background 160ms ease, color 160ms ease, transform 160ms ease;
}

.scene-delete:hover {
  border-color: rgba(255, 99, 99, 0.7);
  background: rgba(82, 18, 22, 0.88);
  color: #ffd2d2;
  transform: translateY(-1px);
}

.scene-delete svg {
  width: 14px;
  height: 14px;
  fill: currentColor;
}

.selected-scene {
  display: grid;
  gap: 8px;
  padding: 14px 0 0;
  margin-top: 4px;
  border-top: 1px solid var(--line);
}

.selected-scene[hidden] {
  display: none;
}

.selected-scene header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.selected-scene h3 {
  margin: 0;
  color: #f5f6ff;
  font-size: 14px;
  font-weight: 800;
}

.selected-scene header span,
.selected-scene label span {
  color: var(--muted);
  font-size: 12px;
}

.selected-scene label {
  display: block;
  margin: 6px 0 0;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.inline-field {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: var(--side-control-gap);
}

.selected-scene .button-gradient.full {
  margin-top: var(--side-control-gap);
}

.inline-field textarea {
  min-height: 72px;
}

/* ───────── Индикация загрузки кнопки ───────── */
.is-busy {
  position: relative;
  opacity: 0.72;
  pointer-events: none;
}

.is-busy::after {
  content: "";
  position: absolute;
  right: 12px;
  top: 50%;
  width: 14px;
  height: 14px;
  margin-top: -7px;
  border: 2px solid rgba(255, 255, 255, 0.25);
  border-top-color: #ffffff;
  border-radius: 50%;
  animation: spin 900ms linear infinite;
}

/* ───────── Тост ───────── */
.toast {
  position: fixed;
  right: 28px;
  bottom: 28px;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: 420px;
  border: 1px solid rgba(83, 144, 255, 0.32);
  border-radius: 14px;
  padding: 10px 10px 10px 16px;
  color: #f5f6ff;
  background: rgba(8, 15, 28, 0.96);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.42);
  font-size: 13px;
  opacity: 1;
  transform: translateY(0);
  transition:
    opacity 200ms ease,
    transform 200ms ease;
}

.toast.is-hiding {
  opacity: 0;
  transform: translateY(-8px);
  pointer-events: none;
}

.toast [data-toast-message] {
  min-width: 0;
  flex: 1;
}

.toast-close {
  display: grid;
  width: 30px;
  height: 30px;
  flex: 0 0 30px;
  place-items: center;
  border: 1px solid rgba(83, 144, 255, 0.22);
  border-radius: 9px;
  color: #b9c9e7;
  background: rgba(12, 22, 42, 0.74);
  cursor: pointer;
  transition:
    border-color 160ms ease,
    background 160ms ease,
    color 160ms ease;
}

.toast-close:hover {
  border-color: rgba(87, 155, 255, 0.5);
  color: #ffffff;
  background: rgba(16, 44, 82, 0.54);
}

.toast-close svg {
  width: 14px;
  height: 14px;
}

.auth-overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  padding: 24px;
  place-items: center;
  align-content: center;
  gap: 14px;
  background: rgba(3, 7, 15, 0.78);
  backdrop-filter: blur(8px);
}

.auth-overlay .auth-consent {
  max-width: 460px;
  margin: 0;
  color: #aebbd1;
  font-size: 12px;
  line-height: 1.5;
  text-align: center;
}

.auth-overlay .auth-consent a {
  color: #8bc2ff;
  text-decoration: underline;
}

.auth-panel {
  position: relative;
  isolation: isolate;
  display: block;
  width: min(100%, 620px);
  aspect-ratio: 1084 / 756;
  border: 0;
  border-radius: 34px;
  padding: 0;
  color: #f7fbff;
  overflow: hidden;
  background: transparent;
  box-shadow:
    0 34px 100px rgba(0, 0, 0, 0.62),
    0 0 72px rgba(25, 111, 237, 0.22);
  text-align: center;
}

.auth-panel::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: url("assets/auth-modal-panel.webp") center / 100% 100% no-repeat;
  pointer-events: none;
}

.auth-mark {
  display: none;
  width: 46px;
  height: 46px;
  margin: 0 auto;
  border: 1px solid rgba(83, 144, 255, 0.28);
  border-radius: 12px;
  place-items: center;
  background: rgba(24, 116, 217, 0.16);
  color: #8bc2ff;
}

.auth-mark svg {
  width: 24px;
  height: 24px;
  fill: currentColor;
}

.auth-panel h2 {
  position: absolute;
  top: 164px;
  left: 50%;
  max-width: 360px;
  margin: 0;
  transform: translateX(-50%);
  color: #f8fbff;
  font-size: 28px;
  line-height: 1.12;
  letter-spacing: 0;
  text-wrap: balance;
  text-shadow: 0 2px 18px rgba(12, 64, 136, 0.32);
}

.auth-panel p {
  position: absolute;
  top: 258px;
  left: 50%;
  max-width: 390px;
  margin: 0;
  transform: translateX(-50%);
  color: #aebbd1;
  font-size: 16px;
  line-height: 1.45;
  text-wrap: balance;
}

.auth-actions {
  position: absolute;
  right: 29px;
  bottom: 51px;
  left: 34px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  height: 84px;
}

.auth-button {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 0;
  height: 100%;
  border: 0;
  border-radius: 22px;
  color: #f7fbff;
  background: transparent;
  box-shadow: none;
  font-size: 18px;
  font-weight: 800;
  text-decoration: none;
  transition:
    transform 160ms ease,
    box-shadow 160ms ease,
    background 160ms ease;
}

.auth-button > span {
  transform: translate(-6px, 11px);
}

.auth-button:hover {
  transform: translateY(-1px);
  background: transparent;
  box-shadow: none;
}

.auth-button.is-disabled {
  cursor: not-allowed;
  color: rgba(247, 251, 255, 0.68);
  background: transparent;
  box-shadow: none;
}

.auth-button.is-disabled:hover {
  transform: none;
  box-shadow: none;
}

.auth-button--soon {
  pointer-events: none;
}

.auth-button--soon > span:not(.soon-badge) {
  filter: blur(1.4px);
  opacity: 0.58;
}

.auth-provider-icon {
  display: grid;
  width: 28px;
  height: 28px;
  flex: 0 0 28px;
  place-items: center;
  border-radius: 50%;
}

.auth-provider-icon img {
  width: 22px;
  height: 22px;
  object-fit: contain;
}

.google-auth-icon {
  background: #ffffff;
}

.yandex-auth-icon {
  color: #ffffff;
  background: #fc3f1d;
  font-size: 17px;
  font-weight: 900;
  line-height: 1;
}

.auth-button--soon .soon-badge {
  position: absolute;
  top: 20px;
  right: 18px;
  z-index: 2;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  padding: 4px 9px;
  color: #f8fbff;
  background: rgba(12, 21, 39, 0.72);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.28);
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  transform: none;
  backdrop-filter: blur(8px);
}

.auth-panel .auth-error {
  position: absolute;
  top: 302px;
  left: 50%;
  max-width: 390px;
  margin: 0;
  transform: translateX(-50%);
  color: #ffb3b3;
  font-size: 13px;
  line-height: 1.35;
  text-align: center;
}

.coins-overlay {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(3, 7, 15, 0.78);
  backdrop-filter: blur(8px);
}

.coins-panel {
  position: relative;
  width: min(100%, 420px);
  border: 1px solid rgba(83, 144, 255, 0.26);
  border-radius: 24px;
  padding: 46px 32px 32px;
  color: #f7fbff;
  background: linear-gradient(180deg, rgba(21, 33, 60, 0.98), rgba(9, 15, 30, 0.98));
  box-shadow:
    0 34px 100px rgba(0, 0, 0, 0.62),
    0 0 72px rgba(25, 111, 237, 0.22);
  text-align: center;
}

.auth-close {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 1;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: none;
  border-radius: 12px;
  color: #aebbd1;
  background: transparent;
  cursor: pointer;
  transition: color 160ms ease;
}

.auth-close:hover {
  color: #f7fbff;
}

.auth-close svg {
  width: 16px;
  height: 16px;
  fill: currentColor;
}

.coins-close {
  position: absolute;
  top: 14px;
  right: 14px;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: none;
  border-radius: 12px;
  color: #aebbd1;
  background: transparent;
  cursor: pointer;
  transition: color 160ms ease;
}

.coins-close:hover {
  color: #f7fbff;
}

.coins-close svg {
  width: 16px;
  height: 16px;
  fill: currentColor;
}

.coins-mark {
  display: grid;
  place-items: center;
  width: 112px;
  height: 112px;
  margin: 0 auto 12px;
}

.coins-mark img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.coins-panel h2 {
  margin: 0 0 10px;
  font-size: 24px;
  line-height: 1.2;
  text-wrap: balance;
}

.coins-panel p {
  margin: 0 0 22px;
  color: #aebbd1;
  font-size: 15px;
  line-height: 1.5;
  text-wrap: balance;
}

.coins-panel--plans {
  width: min(100%, 680px);
  padding: 46px 36px 28px;
}

.coins-plans {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin: 6px 0 18px;
}

.coins-plan {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 22px 12px 16px;
  border: 1px solid rgba(83, 144, 255, 0.22);
  border-radius: 18px;
  background: rgba(13, 22, 42, 0.7);
}

.coins-plan--featured {
  border-color: rgba(28, 122, 230, 0.6);
  background: rgba(20, 40, 78, 0.8);
  box-shadow:
    0 0 0 1px rgba(28, 122, 230, 0.25),
    0 18px 40px rgba(14, 78, 171, 0.25);
}

.coins-plan-badge {
  position: absolute;
  top: -10px;
  left: 50%;
  transform: translateX(-50%);
  padding: 3px 12px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  color: #ffffff;
  background: linear-gradient(135deg, #1c7ae6, #0f5fc7);
  white-space: nowrap;
}

.coins-plan-icon {
  width: 54px;
  height: 54px;
  object-fit: contain;
}

.coins-plan-label {
  font-size: 13px;
  font-weight: 600;
  color: #aebbd1;
}

.coins-plan-price {
  font-size: 22px;
  font-weight: 800;
  color: #f7fbff;
}

.coins-plan-coins {
  font-size: 13px;
  font-weight: 600;
  color: #ffc759;
}

.coins-plan-button {
  width: 100%;
  margin-top: 8px;
  min-height: 42px;
  border: none;
  border-radius: 12px;
  color: #ffffff;
  background: linear-gradient(135deg, #1c7ae6, #0f5fc7);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 160ms ease, box-shadow 160ms ease, opacity 160ms ease;
}

.coins-plan-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 14px 30px rgba(14, 78, 171, 0.35);
}

.coins-plan-button:disabled {
  opacity: 0.6;
  cursor: progress;
  transform: none;
  box-shadow: none;
}

.coins-panel .coins-error {
  margin: -8px 0 14px;
  color: #ffb3b3;
  font-size: 13px;
}

.coins-panel .coins-consent {
  margin: 0 0 14px;
  color: #8595ad;
  font-size: 12px;
  line-height: 1.45;
}

.coins-panel .coins-consent a {
  color: #aebbd1;
}

.coins-shop-link {
  display: inline-block;
  color: #6fa8ff;
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
}

.coins-shop-link:hover {
  text-decoration: underline;
}

@media (max-width: 720px) {
  .coins-overlay {
    padding: 16px;
    align-items: center;
    overflow-y: auto;
  }

  .coins-panel {
    max-width: 360px;
    border-radius: 20px;
    padding: 50px 20px 22px;
  }

  .coins-panel--plans {
    padding: 48px 18px 22px;
  }

  .coins-plans {
    grid-template-columns: 1fr;
    gap: 8px;
    margin: 4px 0 14px;
  }

  .coins-plan {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    column-gap: 14px;
    row-gap: 0;
    padding: 12px 14px;
    text-align: left;
  }

  .coins-plan-icon {
    display: none;
  }

  .coins-plan-label {
    grid-column: 1;
    grid-row: 1;
  }

  .coins-plan-price {
    grid-column: 1;
    grid-row: 2;
    font-size: 19px;
  }

  .coins-plan-coins {
    grid-column: 1;
    grid-row: 3;
  }

  .coins-plan-button {
    grid-column: 2;
    grid-row: 1 / 4;
    align-self: center;
    width: auto;
    min-width: 118px;
    margin-top: 0;
    padding: 0 18px;
  }

  .coins-plan-badge {
    top: -9px;
    left: 16px;
    transform: none;
  }

  .coins-close {
    top: 12px;
    right: 12px;
    width: 34px;
    height: 34px;
  }

  .coins-mark {
    width: 96px;
    height: 96px;
    margin-bottom: 10px;
  }

  .coins-panel h2 {
    font-size: 20px;
  }

  .coins-panel p {
    margin-bottom: 18px;
    font-size: 14px;
  }
}

.mobile-create-dock,
.mobile-editor-sheet,
.mobile-composer-top {
  display: none;
}

.creator-footer {
  flex: 0 0 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 4px 14px;
  margin: 10px 0 0;
  border-top: 1px solid var(--line);
  padding: 7px 2px 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.25;
  text-align: center;
}

.creator-footer p {
  margin: 0;
  color: #7f8a9e;
}

.creator-footer .footer-consent {
  color: #657189;
  font-size: 11px;
}

.creator-footer .footer-consent a {
  color: #8093ad;
  text-decoration: underline;
}

.creator-footer .footer-consent a:hover {
  color: #ffffff;
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 4px 10px;
  color: #c7d0df;
  font-weight: 600;
}

.footer-links a {
  color: inherit;
  transition: color 160ms ease;
}

.footer-links a:hover {
  color: #ffffff;
}

.footer-links span {
  color: #657189;
}

/* ───────── Адаптив ───────── */
@media (max-width: 1640px) {
  .workspace {
    --preview-height: 100%;
    --right-panel-reserve: 144px;
    grid-template-columns: 410px minmax(0, 1fr) 450px;
  }
}

@media (max-width: 1380px) {
  .workspace {
    --preview-height: 100%;
    --right-panel-reserve: 144px;
    grid-template-columns: 360px minmax(0, 1fr) 390px;
  }
}

@media (max-width: 1280px) {
  .workspace {
    grid-template-columns: 350px minmax(0, 1fr) 380px;
    gap: 12px;
  }
}

@media (max-width: 1140px) {
  body {
    height: auto;
    min-height: 100vh;
    overflow-x: hidden;
    overflow-y: auto;
  }

  .creator-shell {
    height: auto;
    min-height: 0;
  }

  .app-bar {
    grid-template-columns: auto auto;
    row-gap: 10px;
    padding: 12px 16px;
  }

  .project-title {
    grid-column: 1 / -1;
    order: 3;
    justify-content: flex-start;
  }

  .workspace {
    grid-template-columns: 1fr;
    height: auto;
  }

  .comic-stage {
    order: -1;
    place-items: center;
  }

  /* Оценка комикса пока только на ПК. */
  .comic-rating {
    display: none !important;
  }

  .comic-actions {
    bottom: 14px;
    max-width: calc(100% - 20px);
  }

  .comic-actions-panel {
    margin-bottom: 30px;
  }

  .comic-publish-title {
    font-size: 12px;
  }

  .comic-canvas {
    width: min(100%, 620px);
    height: auto;
    aspect-ratio: var(--comic-page-ratio);
    margin: 0 auto;
  }

  .side-panel {
    height: auto;
    max-height: none;
    overflow: visible;
  }

  .right-stack {
    height: auto;
    max-height: none;
    overflow: visible;
  }

  .right-panel {
    max-height: none;
  }

  .settings-tab-panels {
    overflow-y: visible;
  }
}

@media (max-width: 720px) {
  html {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
    -webkit-text-size-adjust: 100%;
  }

  .auth-overlay {
    top: 0;
    left: 0;
    width: 100vw;
    height: 100dvh;
    min-height: 0;
    box-sizing: border-box;
    padding: 16px 14px;
    align-items: center;
    justify-items: center;
    overflow: hidden;
  }

  body {
    position: relative;
    width: 100%;
    max-width: 100%;
    height: auto;
    min-height: var(--mobile-viewport-height, 100dvh);
    overflow-x: hidden;
    overflow-y: auto;
    padding-bottom: 0;
    overscroll-behavior-x: none;
    overscroll-behavior-y: none;
  }

  input,
  textarea,
  select {
    font-size: 16px;
  }

  .comic-actions {
    display: none !important;
  }

  .comic-canvas.has-publication img {
    object-position: center;
  }

  .creator-shell {
    width: 100%;
    min-height: var(--mobile-viewport-height, 100dvh);
    height: auto;
    margin-block: 0;
    padding-top: 0;
    padding-bottom: 0;
  }

  .creator-shell::after {
    display: block;
    flex: 0 0 calc(230px + env(safe-area-inset-bottom));
    content: "";
  }

  .app-bar {
    position: relative;
    top: auto;
    z-index: 25;
    width: min(calc(100vw - 18px), 640px);
    min-height: 50px;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px 10px;
    margin: 8px auto 14px;
    border: 0;
    border-radius: 0;
    padding: 6px 8px 6px 10px;
    background: transparent;
    box-shadow: none;
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }

  .brand {
    min-width: 0;
  }

  .brand-logo {
    height: 48px;
  }

  .account-bar {
    grid-column: 2;
    grid-row: 1;
    justify-content: flex-end;
    min-width: 0;
    gap: 6px;
  }

  .credit-pill {
    max-width: 144px;
    min-height: 40px;
    padding: 0 10px;
    overflow: hidden;
    border-radius: 10px;
    font-size: 12px;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .avatar-button,
  .create-comic-icon,
  .icon-action {
    width: 40px;
    height: 40px;
    min-height: 40px;
    border-radius: 12px;
  }

  .create-comic-icon img {
    width: 34px;
    height: 34px;
  }

  .project-title {
    display: none;
  }

  .project-title input {
    width: 100%;
    font-size: 16px;
    text-align: left;
  }

  .save-status {
    width: 100%;
  }

  .auth-actions {
    grid-template-columns: 1fr 1fr;
  }

  .auth-panel {
    width: min(calc(100vw - 28px), 390px, calc((100dvh - 32px) * 1084 / 756));
    height: auto;
    aspect-ratio: 1084 / 756;
    border-radius: clamp(18px, 7vw, 28px);
  }

  .auth-panel h2 {
    top: 34%;
    left: 50%;
    max-width: 80%;
    transform: translateX(-50%);
    text-align: center;
    font-size: clamp(17px, 4.9vw, 20px);
    line-height: 1.12;
  }

  .auth-panel p {
    top: 58%;
    max-width: 72%;
    font-size: clamp(11px, 3.4vw, 13px);
    line-height: 1.35;
  }

  .auth-actions {
    right: 4.9%;
    bottom: 9%;
    left: 4.9%;
    gap: 2.8%;
    height: 19.6%;
  }

  .auth-button {
    gap: 7px;
    padding: 0 10px;
    border-radius: 15px;
    font-size: clamp(13px, 3.8vw, 14px);
    line-height: 1;
  }

  .auth-button > span {
    transform: translateY(1px);
  }

  .auth-button--soon {
    justify-content: flex-start;
    padding-right: 42px;
    padding-left: 13%;
  }

  .auth-button--soon .soon-badge {
    top: 50%;
    right: 9px;
    padding: 3px 6px;
    font-size: 8px;
    transform: translateY(-50%);
  }

  .auth-button--soon .auth-label {
    max-width: 62px;
    overflow: hidden;
    text-align: left;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .auth-panel .auth-error {
    top: 68%;
    max-width: 72%;
    font-size: 11px;
  }

  .auth-provider-icon {
    width: 22px;
    height: 22px;
    flex-basis: 22px;
  }

  .auth-provider-icon img {
    width: 17px;
    height: 17px;
  }

  .soon-badge {
    padding: 1px 5px;
    font-size: 8px;
  }

  .comic-canvas {
    display: block;
    width: min(calc(100vw - 32px), 360px);
    height: auto;
    max-height: none;
    aspect-ratio: 5 / 7;
    border-color: rgba(86, 167, 255, 0.46);
    border-radius: 16px;
    background: #07101d;
    box-shadow:
      0 18px 48px rgba(0, 0, 0, 0.36),
      0 0 34px rgba(24, 116, 217, 0.14);
  }

  .comic-canvas img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    border-radius: inherit;
  }


  .workspace {
    flex: 0 0 auto;
    height: auto;
    min-height: 0;
    gap: 10px;
    overflow: visible;
    margin-top: 14px;
  }

  .comic-stage {
    position: relative;
    order: -2;
    align-items: start;
    justify-items: center;
    padding-bottom: 12px;
  }

  /* Минималистичные шевроны по бокам холста — листают страницы комикса. */
  .page-nav-arrow {
    position: absolute;
    top: 50%;
    z-index: 3;
    display: grid;
    width: 44px;
    height: 72px;
    border: none;
    padding: 0;
    background: none;
    color: rgba(233, 240, 252, 0.72);
    transform: translateY(-50%);
    cursor: pointer;
    place-items: center;
    -webkit-tap-highlight-color: transparent;
    transition: color 140ms ease, opacity 140ms ease;
  }

  .page-nav-arrow.is-prev {
    left: 0;
  }

  .page-nav-arrow.is-next {
    right: 0;
  }

  .page-nav-arrow:active {
    color: #ffffff;
  }

  .page-nav-arrow[hidden] {
    display: none;
  }

  .page-nav-arrow svg {
    position: relative;
    width: 28px;
    height: 28px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2.2;
    stroke-linecap: round;
    stroke-linejoin: round;
    filter: drop-shadow(0 1px 4px rgba(3, 8, 18, 0.85));
  }

  /* Холст почти во всю ширину — шеврон ложится на рисунок: тёмная подложка,
     чтобы стрелка читалась и на светлом арте. */
  .page-nav-arrow.is-overlay {
    color: rgba(245, 249, 255, 0.92);
  }

  .page-nav-arrow.is-overlay::before {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: rgba(6, 12, 24, 0.52);
    transform: translate(-50%, -50%);
    backdrop-filter: blur(3px);
  }

  .right-stack {
    display: contents;
  }

  .right-panel {
    display: none;
  }

  .left-panel {
    position: fixed;
    right: 8px;
    bottom: calc(8px + env(safe-area-inset-bottom));
    left: 8px;
    z-index: 34;
    display: grid;
    grid-template-rows: auto auto auto;
    grid-template-areas:
      "selectors"
      "story"
      "cta";
    gap: 8px;
    min-height: 178px;
    max-height: min(238px, 38vh);
    height: auto;
    border: 1px solid rgba(78, 141, 255, 0.28);
    border-radius: 18px;
    padding: 14px 10px 10px;
    overflow: visible;
    background:
      linear-gradient(180deg, rgba(12, 19, 35, 0.97) 0%, rgba(7, 13, 25, 0.98) 100%);
    box-shadow:
      0 18px 58px rgba(0, 0, 0, 0.42),
      0 0 38px rgba(24, 116, 217, 0.12);
    backdrop-filter: blur(16px);
    transition:
      max-height 220ms ease,
      min-height 220ms ease,
      box-shadow 180ms ease,
      border-color 180ms ease;
  }

  @supports (height: 100svh) {
    body,
    .creator-shell {
      min-height: var(--mobile-viewport-height, 100svh);
    }

    .comic-canvas {
      width: min(calc(100vw - 32px), 360px, max(232px, calc((var(--mobile-viewport-height, 100svh) - 344px) * 0.72)));
    }
  }

  .left-panel.is-advanced-mode {
    grid-template-rows: auto minmax(0, 1fr);
    grid-template-areas:
      "editor";
    min-height: min(470px, 58vh);
    max-height: min(470px, 58vh);
    border-color: rgba(86, 167, 255, 0.34);
    box-shadow:
      0 20px 64px rgba(0, 0, 0, 0.48),
      0 0 42px rgba(24, 116, 217, 0.16);
  }

  .left-panel.is-advanced-mode .story-area,
  .left-panel.is-advanced-mode .left-panel-head,
  .left-panel.is-advanced-mode .cta-footer {
    display: none;
  }

  .creator-footer {
    display: none;
  }

  .mobile-create-dock {
    display: none;
  }

  .mobile-composer-top {
    position: absolute;
    left: 10px;
    bottom: calc(100% + 8px);
    z-index: 2;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
  }

  /* Инструменты (скачать/поделиться) на мобильном переезжают из хедера вниз —
     зеркалят пилюли Промпт/Настройки, но в правом углу над нижним листом. */
  .left-panel > .header-tools {
    position: absolute;
    right: 10px;
    bottom: calc(100% + 8px);
    z-index: 2;
    gap: 6px;
    margin: 0;
  }

  .left-panel > .header-tools .icon-action {
    width: 34px;
    height: 30px;
    min-height: 30px;
    border-radius: 9px;
  }

  .mobile-mode-pill,
  .mobile-advanced-pill {
    display: inline-flex;
    min-height: 30px;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(93, 135, 210, 0.34);
    border-radius: 9px;
    padding: 0 11px;
    color: #d5e4ff;
    background: rgba(14, 26, 48, 0.9);
    font-size: 12px;
    font-weight: 800;
    cursor: pointer;
    transition:
      border-color 160ms ease,
      background 160ms ease,
      color 160ms ease,
      box-shadow 160ms ease;
  }

  .mobile-mode-pill.is-active,
  .mobile-advanced-pill.is-active {
    border-color: rgba(87, 155, 255, 0.78);
    color: #ffffff;
    background: rgba(16, 44, 82, 0.54);
    box-shadow: 0 0 24px rgba(24, 116, 217, 0.16);
  }

  .mobile-advanced-pill {
    gap: 7px;
    color: #e7f0ff;
    background: rgba(12, 21, 38, 0.94);
  }

  .mobile-advanced-pill.is-active {
    border-color: rgba(86, 167, 255, 0.78);
  }

  .mobile-sheet-handle {
    display: none;
  }

  .left-panel .left-panel-head {
    grid-area: selectors;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr);
    gap: 8px;
    border: 0;
    padding: 0;
  }

  .left-panel .dropdown-toggle {
    min-height: 34px;
    border-color: rgba(93, 135, 210, 0.28);
    border-radius: 9px;
    padding: 0 10px;
    background: rgba(8, 15, 28, 0.88);
  }

  .left-panel .dropdown-toggle[aria-expanded="true"] {
    border-color: rgba(87, 155, 255, 0.78);
    background: rgba(16, 44, 82, 0.54);
    box-shadow: 0 0 24px rgba(24, 116, 217, 0.16);
  }

  .left-panel .dropdown-label {
    display: none;
  }

  .left-panel .dropdown-value {
    font-size: 13px;
  }

  .left-panel .dropdown-menu {
    bottom: calc(100% + 6px);
    top: auto;
  }

  .left-panel [data-dropdown="model"] .dropdown-menu.wide {
    left: auto;
    right: 0;
    width: min(280px, calc(100vw - 32px));
    min-width: min(100%, calc(100vw - 32px));
  }

  .left-panel .story-area {
    grid-area: story;
    min-height: 0;
    padding: 0;
  }

  .left-panel .field-label,
  .left-panel .counter-row,
  .left-panel .cost-note {
    display: none;
  }

  .left-panel .story-wrap {
    min-height: 0;
    border-radius: 11px;
    transition:
      filter 160ms ease,
      transform 160ms ease;
  }

  .left-panel .story-wrap textarea {
    height: 54px;
    min-height: 54px;
    max-height: 118px;
    overflow: hidden;
    border-color: rgba(93, 135, 210, 0.34);
    border-radius: 10px;
    padding: 12px 52px 10px 14px;
    background: rgba(3, 8, 17, 0.82);
    color: var(--ink);
    font-size: 16px;
    line-height: 1.35;
    resize: none;
    transition:
      min-height 180ms ease,
      height 180ms ease,
      border-color 160ms ease,
      background 160ms ease,
      box-shadow 160ms ease;
  }

  .left-panel .story-wrap.has-text {
    filter: saturate(1.08);
  }

  .left-panel .story-wrap textarea:focus {
    border-color: rgba(93, 135, 210, 0.34);
    background: rgba(3, 8, 17, 0.82);
    box-shadow: none;
  }

  .left-panel .story-wrap.has-text textarea,
  .left-panel .story-wrap.has-text textarea:focus,
  .left-panel.has-active-prompt #storyInput,
  .left-panel.has-active-prompt #storyInput:focus {
    border-color: var(--cyan) !important;
    background: rgba(5, 13, 27, 0.98) !important;
    box-shadow:
      0 0 0 2px rgba(86, 167, 255, 0.18),
      0 0 34px rgba(24, 116, 217, 0.26) !important;
  }

  .left-panel .story-enhance {
    right: 8px;
    bottom: 8px;
    width: 34px;
    height: 34px;
  }

  .left-panel .cta-footer {
    grid-area: cta;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 8px;
    border: 0;
    padding: 0;
    background: transparent;
  }

  .left-panel .button-gradient.full,
  .left-panel .continue-button {
    width: 100%;
    min-width: 0;
    min-height: 40px;
    border-radius: 9px;
    border-color: rgba(83, 144, 255, 0.24);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
    font-size: clamp(10px, 3.15vw, 12px);
    line-height: 1.08;
    transition:
      background 180ms ease,
      color 180ms ease,
      box-shadow 180ms ease,
      transform 180ms ease;
  }

  .left-panel .button-gradient.full {
    color: #aebdd5;
    background: rgba(12, 22, 42, 0.82);
  }

  .left-panel .continue-button {
    display: flex;
    gap: 6px;
    margin-top: 0;
    padding: 6px 8px;
  }

  .left-panel .continue-button span {
    min-width: 0;
    overflow-wrap: anywhere;
  }

  .left-panel .continue-button svg {
    flex: 0 0 14px;
    width: 14px;
    height: 14px;
  }

  .left-panel .button-gradient.full:hover,
  .left-panel .continue-button:hover:not(:disabled) {
    transform: none;
    border-color: rgba(83, 144, 255, 0.24);
  }

  .left-panel.has-active-prompt .button-gradient.full {
    color: #f7fbff;
    border-color: rgba(87, 155, 255, 0.78);
    background: rgba(16, 44, 82, 0.72);
    box-shadow:
      0 0 24px rgba(24, 116, 217, 0.18),
      0 14px 30px rgba(0, 0, 0, 0.18);
  }

  .left-panel.has-active-prompt .button-gradient.full:hover {
    transform: translateY(-1px);
    border-color: rgba(87, 155, 255, 0.78);
  }

  .mobile-editor-sheet {
    grid-area: editor;
    position: static;
    z-index: auto;
    display: none;
    min-height: 0;
    height: 100%;
    max-height: none;
    overflow: hidden;
    border: 0;
    border-top: 1px solid rgba(93, 135, 210, 0.22);
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    opacity: 1;
    pointer-events: auto;
    transform: none;
    transition:
      opacity 180ms ease,
      transform 180ms ease;
  }

  .left-panel.is-advanced-mode .mobile-editor-sheet,
  .mobile-editor-sheet.is-open {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
  }

  .mobile-editor-tabs {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 4px;
    padding: 6px 6px 4px;
    border-bottom: 1px solid rgba(93, 135, 210, 0.22);
  }

  .mobile-editor-tabs button {
    min-height: 30px;
    border: 0;
    border-radius: 10px;
    color: #8fa3c3;
    background: transparent;
    cursor: pointer;
    font-size: 10px;
    font-weight: 700;
  }

  .mobile-editor-tabs button.is-active {
    color: #f7fbff;
    background: rgba(16, 44, 82, 0.54);
    box-shadow: 0 0 24px rgba(24, 116, 217, 0.16);
  }

  .mobile-editor-panel {
    display: none;
    overflow-y: auto;
    min-height: 0;
    padding: 8px 4px 2px;
    scrollbar-width: thin;
  }

  .mobile-editor-panel.is-active {
    display: block;
  }

  .mobile-editor-panel .settings-tab-panel {
    display: grid;
    gap: 10px;
    padding: 0;
  }

  /* Страницы: отступ между счётчиком страниц и лентой страниц */
  .mobile-pages-slot {
    display: grid;
    gap: 12px;
  }

  /* Язык: список открывается вниз в потоке панели и не вылезает за экран */
  .mobile-editor-panel .language-dropdown .dropdown-menu {
    position: static;
    top: auto;
    bottom: auto;
    margin-top: 6px;
    max-height: 240px;
    overflow-y: auto;
  }

  .mobile-editor-panel .side-panel {
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
  }

  .mobile-editor-panel .left-panel-head,
  .mobile-editor-panel .story-area,
  .mobile-editor-panel .cta-footer,
  .mobile-editor-panel .accordion-body,
  .mobile-editor-panel .accordion > summary {
    padding-inline: 0;
  }

  .mobile-editor-panel .cta-footer {
    padding-bottom: 0;
    background: transparent;
  }

  .mobile-settings-stack {
    display: grid;
  }

  .mobile-editor-panel .accordion {
    border-bottom: 0;
  }

  .mobile-editor-panel .accordion + .accordion {
    border-top: 1px solid var(--line);
  }

  .mobile-editor-panel .accordion[open] {
    background: transparent;
  }

  .scene-item {
    grid-template-columns: 56px 1fr 30px;
  }

  .toast {
    top: 116px;
    left: 12px;
    right: 12px;
    bottom: auto;
    max-width: none;
    z-index: 33;
    padding: 10px 8px 10px 14px;
    border-color: rgba(83, 144, 255, 0.38);
    background: rgba(8, 15, 28, 0.98);
    box-shadow:
      0 18px 46px rgba(0, 0, 0, 0.38),
      0 0 26px rgba(24, 116, 217, 0.1);
    transform: translateY(0);
  }

  .toast.is-hiding {
    transform: translateY(-10px);
  }

  .creator-footer {
    justify-content: flex-start;
    text-align: left;
  }

  .footer-links {
    justify-content: flex-start;
  }
}

@media (max-width: 480px) {
  .app-bar {
    width: calc(100vw - 16px);
    border-radius: 0;
    padding: 7px;
  }

  .brand-logo {
    height: 40px;
  }

  .credit-pill {
    max-width: 112px;
  }
}

/* Узкие телефоны: ужимаем кнопки и лого, чтобы они не наезжали друг на друга */
@media (max-width: 400px) {
  .brand-logo {
    height: 36px;
  }

  .app-bar {
    gap: 8px;
  }

  .account-bar {
    gap: 5px;
  }

  .header-tools {
    gap: 5px;
  }

  .credit-pill {
    max-width: 104px;
    padding: 0 8px;
    font-size: 11px;
  }

  .avatar-button,
  .create-comic-icon,
  .icon-action {
    width: 36px;
    height: 36px;
    min-height: 36px;
  }

  .create-comic-icon img {
    width: 30px;
    height: 30px;
  }
}

@media (max-width: 360px) {
  .brand-logo {
    height: 30px;
  }

  .account-bar {
    gap: 4px;
  }

  .header-tools {
    gap: 4px;
  }

  .credit-pill {
    max-width: 96px;
    padding: 0 6px;
  }

  .avatar-button,
  .create-comic-icon,
  .icon-action {
    width: 32px;
    height: 32px;
    min-height: 32px;
  }

  .create-comic-icon img {
    width: 26px;
    height: 26px;
  }
}
