@font-face {
  font-family: "YS Text";
  src: url("https://yastatic.net/s3/home/fonts/ys/4/text-regular.woff2") format("woff2"),
       url("https://yastatic.net/s3/home/fonts/ys/4/text-regular.woff") format("woff");
  font-weight: 400;
  font-style: normal;
  font-stretch: normal;
  font-display: swap;
}

@font-face {
  font-family: "YS Text";
  src: url("https://yastatic.net/s3/home/fonts/ys/4/text-medium.woff2") format("woff2"),
       url("https://yastatic.net/s3/home/fonts/ys/4/text-medium.woff") format("woff");
  font-weight: 500;
  font-style: normal;
  font-stretch: normal;
  font-display: swap;
}

@font-face {
  font-family: "YS Display";
  src: url("https://yastatic.net/s3/home/fonts/ys/1/display-heavy.woff") format("woff");
  font-weight: 900;
  font-style: normal;
  font-stretch: normal;
  font-display: swap;
}

@font-face {
  font-family: "YS Text Cond";
  src: url("https://yastatic.net/s3/home/fonts/ys/4/text-cond-heavy.woff2") format("woff2"),
       url("https://yastatic.net/s3/home/fonts/ys/4/text-cond-heavy.woff") format("woff");
  font-weight: 800;
  font-style: normal;
  font-stretch: normal;
  font-display: swap;
}

:root {
  --bg-main: #0f141e;
  --bg-card: #191e28;
  --purple: #3700f0;
  --purple-hover: #1900D2;
  --gray-1: #6e82aa;
  --gray-3: #c3cde1;
  --gray-5: #556996;
  --gray-input: #324164;
  --text-primary: #ffffff;
  --text-secondary: #a0afc8;
  --text-placeholder: rgba(71, 90, 128, 0.5);
  --outline-hover: #8CA0C3;
  --azure-2: #b4d7ff;
  --radius: 12px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  width: 100%;
  max-width: 100%;
  height: 100%;
  /* Без этого WebView/Office панель иногда даёт сдвиг влево-вправо и «съедает» рёбра. */
  overflow-x: hidden;
  scrollbar-width: none;
}

html::-webkit-scrollbar,
body::-webkit-scrollbar {
  display: none;
}

body {
  background: var(--bg-main);
  font-family: "YS Text", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-weight: 400;
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ═══════════════ SCREENS ═══════════════ */

.screen {
  display: none;
}

.screen.active {
  display: block;
}

.container {
  background: var(--bg-main);
  padding: 24px;
  min-height: 100vh;
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
}

#libraryScreen .library-content {
  min-width: 0;
  max-width: 100%;
}

#libraryPhotosContent {
  display: block;
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

*::-webkit-scrollbar {
  display: none;
}

* {
  scrollbar-width: none;
}

/* ═══════════════ HOME — SECTIONS ═══════════════ */

.section {
  margin-bottom: 28px;
}

.section:last-child {
  margin-bottom: 0;
}

.home-footer-links {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--bg-main);
  padding: 16px 24px 16px 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 10;
}

#homeScreen .container {
  padding-bottom: 100px;
}

.home-link {
  font-family: "YS Text", sans-serif;
  font-weight: 400;
  font-size: 14px;
  color: var(--gray-1);
  line-height: 1.3;
  text-decoration: none;
  cursor: pointer;
  transition: color 0.2s ease;
}

.home-link:hover {
  color: var(--outline-hover);
  text-decoration: underline;
}

/* Отступы; размер шрифта задаётся ниже после .gen-label, чтобы не перебивался */
.alpha-disclaimer {
  margin: 0px 0 0;
  text-align: center;
}

.text-chat-alpha-note {
  flex-shrink: 0;
  margin: 2px 0 0;
  text-align: center;
}

.section-title {
  font-family: "YS Text Cond", sans-serif;
  font-weight: 800;
  font-size: 14px;
  text-transform: uppercase;
  color: var(--gray-1);
  text-align: center;
  margin-bottom: 12px;
}

/* ═══════════════ HOME — FEATURE CARDS ═══════════════ */

.features-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.feature-card {
  width: calc(50% - 3px);
  aspect-ratio: 309 / 260;
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 14px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  cursor: pointer;
  transition: background 0.2s ease;
  position: relative;
}

.feature-card.primary {
  background: var(--purple);
}

.feature-card.primary:hover {
  background: var(--purple-hover);
}

.feature-card.disabled {
  cursor: default;
}

.feature-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.feature-icon svg {
  width: 100%;
  height: 100%;
  display: block;
}

.feature-status-check {
  display: none;
  position: absolute;
  right: 14px;
  top: 14px;
  width: 20px;
  height: 20px;
  background-color: transparent;
  background-image: var(--feature-status-check-icon);
  background-position: center;
  background-size: contain;
  background-repeat: no-repeat;
}

.feature-card.has-status-check .feature-status-check {
  display: block;
}

.feature-card.has-status-loader .feature-status-check {
  display: block;
  background: transparent;
  background-image: none;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #00faff;
  border-radius: 50%;
  box-sizing: border-box;
  mask: none;
  -webkit-mask: none;
  animation: genSpinnerSpin 1s linear infinite;
}

.feature-text {
  font-family: "YS Text", sans-serif;
  font-weight: 500;
  font-size: 13px;
  line-height: 1.25;
  color: var(--text-primary);
}

.feature-card.disabled .feature-text {
  color: var(--gray-5);
}

/* ═══════════════ HOME — LIBRARY SECTION ═══════════════ */

.library-tabs {
  display: flex;
  flex-wrap: nowrap;
  gap: 0;
  margin-bottom: 12px;
  overflow-x: auto;
}

.library-tabs::-webkit-scrollbar {
  display: none;
}

.library-tab {
  background: transparent;
  border: none;
  padding: 8px 6px;
  margin-right: 6px;
  font-family: "YS Text", sans-serif;
  font-weight: 400;
  font-size: 13px;
  color: var(--gray-5);
  cursor: pointer;
  transition: color 0.2s ease;
  outline: none;
  flex-shrink: 0;
  white-space: nowrap;
}

.library-tab:hover:not(.disabled) {
  color: var(--gray-3);
}

.library-tab.active {
  color: var(--text-primary);
  font-weight: 500;
}

.library-tab.active:hover {
  color: var(--text-primary);
}

.library-tab.disabled {
  color: var(--gray-5);
  cursor: default;
}

.library-content .tags-section,
.photos-tags-section,
.icons-tags-section,
.flags-tags-section,
.logos-tags-section {
  margin-bottom: 12px;
}

.action-bar-library {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 10;
}

/* Icons library — цвет внутри раскрываемой панели «Теги» */
.icons-color-swatches {
  display: flex;
  gap: 14px;
  align-items: center;
}

.icons-color-swatches--in-tags {
  padding: 0 8px 4px;
}

.icons-color-tags-category .tags-category-title {
  margin-bottom: 10px;
}

.icon-color-swatch {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  border: none;
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
  box-sizing: border-box;
  outline: none;
  outline-offset: 0;
  transition: outline 0.15s ease, outline-offset 0.15s ease;
}

/* Наведение: светло-серая обводка, та же толщина, что у выбранного */
.icon-color-swatch:hover:not(.active) {
  outline: 2px solid #a8adb8;
  outline-offset: 3px;
}

/* Выбран: более заметная серая обводка, чуть толще */
.icon-color-swatch.active {
  outline: 2px solid #6f7684;
  outline-offset: 3px;
}

.icon-color-swatch:focus-visible:not(.active) {
  outline: 2px solid #a8adb8;
  outline-offset: 3px;
}

.icon-color-swatch.active:focus-visible {
  outline: 2px solid #6f7684;
  outline-offset: 3px;
}

.slide-theme-swatches {
  display: flex;
  gap: 14px;
  align-items: center;
  padding: 0 8px 4px;
}

.slide-theme-tags-category .tags-category-title {
  margin-bottom: 10px;
}

.slide-theme-swatch {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  border: none;
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
  box-sizing: border-box;
  outline: none;
  outline-offset: 0;
  transition: outline 0.15s ease, outline-offset 0.15s ease;
}

.slide-theme-swatch[data-theme="light"] {
  border: 1px solid #324164;
}

.slide-theme-swatch:hover:not(.active) {
  outline: 2px solid #a8adb8;
  outline-offset: 3px;
}

.slide-theme-swatch.active,
.slide-theme-swatch.active:focus-visible {
  outline: 2px solid #6f7684;
  outline-offset: 3px;
}

.slide-theme-swatch:focus-visible:not(.active) {
  outline: 2px solid #a8adb8;
  outline-offset: 3px;
}

.icons-gallery {
  display: grid;
  /* minmax(0,1fr) — иначе min-content ячеек раздувает сетку шире панели */
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  padding-bottom: 180px;
  min-width: 0;
}

.icon-card {
  position: relative;
  border-radius: 12px;
  overflow: hidden;
  cursor: pointer;
  background: #191E28;
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  min-width: 0;
}

.icon-card .icon-svg-wrapper {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.2s ease;
}

.icon-card:hover .icon-svg-wrapper {
  opacity: 0.85;
}

.icon-card .icon-svg-wrapper img,
.icon-card .icon-svg-wrapper svg {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  display: block;
}

.icon-card.selected .icon-svg-wrapper {
  opacity: 0.5;
}

.icon-card .selectionCircle {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #4B3CFF;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.icon-card.selected .selectionCircle {
  opacity: 1;
}

.icon-card .selectionCircle svg {
  width: 8px;
  height: 8px;
}

/* ═══════════════ FLAGS GALLERY ═══════════════ */

.flags-gallery {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  padding-bottom: 180px;
  min-width: 0;
}

.flag-card {
  position: relative;
  cursor: pointer;
  background: transparent;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 0;
}

.flag-card .flag-img-wrapper {
  position: relative;
  width: 100%;
  min-width: 0;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  border: 8px solid #191E28;
  box-sizing: border-box;
}

.flag-card .flag-img {
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  object-fit: cover;
  object-position: center;
  transition: opacity 0.2s ease;
}

.flag-card .flag-img-error {
  background: var(--gray-input);
}

.flag-card:hover .flag-img {
  opacity: 0.85;
}

.flag-card.selected .flag-img {
  opacity: 0.5;
}

.flag-card .flag-label {
  padding: 6px 4px 0;
  font-size: 10px;
  line-height: 1.2;
  color: #6E82AA;
  text-align: center;
  background: transparent;
}

.flag-card .selectionCircle {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #4B3CFF;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.flag-card.selected .selectionCircle {
  opacity: 1;
}

.flag-card .selectionCircle svg {
  width: 8px;
  height: 8px;
}

/* ═══════════════ LOGOS GALLERY (как флаги: сетка 4, серая плитка) ═══════════════ */

.logos-gallery {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  padding-bottom: 180px;
  min-width: 0;
}

.logo-card {
  position: relative;
  cursor: pointer;
  background: transparent;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 0;
}

.logo-card .logo-img-wrapper {
  position: relative;
  width: 100%;
  min-width: 0;
  aspect-ratio: 1;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  background: #191E28;
  box-sizing: border-box;
  padding: 10px;
}

.logo-card.logo-card--light-tile .logo-img-wrapper {
  background: #ffffff;
}

.logo-card .logo-img {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  min-width: 0;
  min-height: 0;
  object-fit: contain;
  object-position: center;
  transition: opacity 0.2s ease;
}

.logo-card .logo-img-error {
  background: #242933;
  width: 100%;
  height: 100%;
}

.logo-card:hover .logo-img {
  opacity: 0.88;
}

.logo-card.selected .logo-img {
  opacity: 0.55;
}

.logo-card .logo-label {
  padding: 6px 2px 0;
  font-size: 10px;
  line-height: 1.2;
  color: #6e82aa;
  text-align: center;
  width: 100%;
}

.logo-card .selectionCircle {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #4b3cff;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.logo-card.selected .selectionCircle {
  opacity: 1;
}

.logo-card .selectionCircle svg {
  width: 8px;
  height: 8px;
}

/* ═══════════════ HEADER WITH BACK BUTTON ═══════════════ */

.page-header {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  margin-bottom: 24px;
}

.library-search-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.library-search-row .search-wrapper {
  flex: 1;
  margin-bottom: 0;
  min-width: 0;
}

#libraryScreen .library-sticky-header {
  position: sticky;
  top: 24px;
  z-index: 10;
  background: var(--bg-main);
  padding-bottom: 12px;
  margin-bottom: 12px;
  /* Расширяем контейнер в зону padding, чтобы контент не просвечивал по бокам */
  margin-left: -24px;
  margin-right: -24px;
  padding-left: 24px;
  padding-right: 24px;
}

#libraryScreen .library-sticky-header::before {
  content: "";
  position: absolute;
  top: -24px;
  left: -24px;
  right: -24px;
  height: 24px;
  background: var(--bg-main);
  pointer-events: none;
}

.library-tags-pane {
  margin-top: 0;
  margin-bottom: 12px;
}

#libraryScreen .library-sticky-header .tags-container {
  background: var(--bg-main);
}

.back-btn {
  background: none;
  border: none;
  padding: 0;
  margin: 0;
  cursor: pointer;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.15s ease;
  width: 20px;
  height: 20px;
}

.back-btn:hover svg path {
  fill: #8CA0C3;
}

.back-btn svg {
  display: block;
  width: 20px;
  height: 20px;
}

.back-btn svg path {
  transition: fill 0.15s ease;
}

.header-text {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.page-title {
  font-family: "YS Text Cond", sans-serif;
  font-weight: 800;
  font-size: 18px;
  text-transform: uppercase;
  color: var(--text-primary);
  line-height: 1.2;
}

.page-subtitle {
  font-family: "YS Text", sans-serif;
  font-weight: 400;
  font-size: 14px;
  color: var(--gray-1);
  line-height: 1.3;
}

/* ═══════════════ TEXT CHAT SCREEN ═══════════════ */

#textChatScreen.active {
  display: flex;
  flex-direction: column;
  min-height: 100%;
}

.text-chat-layout {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  padding: 0 24px 24px;
  box-sizing: border-box;
}

.text-chat-layout .page-header {
  flex-shrink: 0;
  padding-top: 24px;
}

.text-chat-messages {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
  margin-bottom: 16px;
}

.text-chat-input-wrapper {
  padding: 12px 0 10px;
  flex-shrink: 0;
}

.text-chat-input-inner {
  position: relative;
  display: flex;
  align-items: flex-end;
}

.text-chat-input {
  width: 100%;
  min-height: 120px;
  padding: 14px 68px 14px 14px;
  background: #ffffff;
  border: none;
  border-radius: var(--radius);
  font-family: "YS Text", sans-serif;
  font-weight: 400;
  font-size: 14px;
  line-height: 1.4;
  color: var(--bg-card);
  outline: none;
  resize: vertical;
  box-sizing: border-box;
}

.text-chat-input::placeholder {
  color: var(--text-placeholder);
}

.text-chat-send-btn {
  position: absolute;
  right: 14px;
  bottom: 14px;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--purple);
  border: none;
  border-radius: 10px;
  cursor: pointer;
  color: white;
  transition: background 0.2s ease;
}

.text-chat-send-btn:hover {
  background: var(--purple-hover);
}

.text-chat-send-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.text-chat-send-btn svg {
  display: block;
}

.text-chat-msg {
  margin-bottom: 12px;
  max-width: 90%;
}

.text-chat-msg.user {
  margin-left: auto;
  display: flex;
  justify-content: flex-end;
}

.text-chat-msg.assistant {
  margin-right: auto;
}

.text-chat-msg-text {
  padding: 10px 14px;
  border-radius: var(--radius);
  font-family: "YS Text", sans-serif;
  font-size: 14px;
  line-height: 1.4;
  white-space: pre-wrap;
  word-break: break-word;
}

.text-chat-msg.user .text-chat-msg-text {
  background: var(--purple);
  color: white;
}

.text-chat-msg.assistant .text-chat-msg-text {
  background: var(--bg-card);
  color: var(--text-primary);
}

.text-chat-page-header {
  flex-wrap: wrap;
  align-items: flex-start;
  row-gap: 10px;
}

.text-chat-page-header .header-text {
  flex: 1;
  min-width: 140px;
}

.text-chat-clear-btn {
  flex-shrink: 0;
  align-self: center;
  padding: 8px 12px;
  font-family: "YS Text", sans-serif;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  background: var(--bg-card);
  border: 1px solid var(--gray-3, #3d4f6f);
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.15s ease, opacity 0.15s ease;
}

.text-chat-clear-btn:hover {
  background: rgba(255, 255, 255, 0.06);
}

.text-chat-clear-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.text-chat-compare-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
  padding-left: 2px;
}

.text-chat-compare-btn {
  padding: 8px 14px;
  font-family: "YS Text", sans-serif;
  font-size: 13px;
  font-weight: 500;
  border-radius: 10px;
  cursor: pointer;
  border: 1px solid var(--gray-3, #3d4f6f);
  background: transparent;
  color: var(--text-primary);
  transition: background 0.15s ease, opacity 0.15s ease;
}

.text-chat-compare-btn.primary {
  background: var(--purple);
  border-color: var(--purple);
  color: white;
}

.text-chat-compare-btn:hover:not(:disabled) {
  opacity: 0.92;
}

.text-chat-compare-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ═══════════════ GENERATE — CONTENT ═══════════════ */

.gen-content {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.gen-input-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Экраны генерации: поле ввода и чипы ближе друг к другу */
#genPromptSection.gen-input-section {
  gap: 6px;
}

#illustrationGenerateScreen .gen-content {
  gap: 8px;
}

.gen-label {
  font-family: "YS Text", sans-serif;
  font-weight: 400;
  font-size: 14px;
  color: var(--gray-1);
  line-height: 1.3;
}

.gen-label.alpha-disclaimer {
  font-size: 11px;
  line-height: 1.3;
  text-align: center;
}

.format-hint {
  font-family: "YS Text", sans-serif;
  font-weight: 400;
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.4;
}

.format-message {
  font-family: "YS Text", sans-serif;
  font-size: 14px;
  line-height: 1.4;
  padding: 10px 14px;
  border-radius: var(--radius);
}

.format-message.success {
  color: var(--azure-2);
  background: rgba(180, 215, 255, 0.15);
}

.format-message.error {
  color: #ff6b6b;
  background: rgba(255, 107, 107, 0.15);
}

.gen-textarea {
  width: 100%;
  min-height: 68px;
  background: #ffffff;
  border: none;
  border-radius: var(--radius);
  padding: 14px;
  font-family: "YS Text", sans-serif;
  font-weight: 400;
  font-size: 14px;
  line-height: 1.4;
  color: var(--bg-card);
  resize: none;
  outline: none;
  overflow: hidden;
  display: block;
  box-sizing: border-box;
  transition: background 0.3s ease, color 0.3s ease;
}

.gen-textarea::placeholder {
  color: var(--text-placeholder);
}

.gen-textarea.generating {
  background: var(--gray-input);
  color: var(--gray-3);
}

.gen-prompt-label {
  display: flex;
  align-items: center;
  gap: 6px;
}

.gen-prompt-back-btn {
  display: none;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  padding: 0;
  background: transparent;
  border: none;
  color: var(--gray-1);
  cursor: pointer;
  transition: color 0.15s ease;
  outline: none;
  flex-shrink: 0;
}

.gen-prompt-back-btn.visible {
  display: inline-flex;
}

.gen-prompt-back-btn:hover,
.gen-prompt-back-btn:focus-visible {
  color: #ffffff;
}

.gen-prompt-back-btn svg {
  display: block;
}

.gen-textarea-wrapper {
  position: relative;
  display: block;
}

.gen-textarea.has-inline-action {
  min-height: 110px;
  padding-bottom: 56px;
}

.gen-inline-send-btn {
  position: absolute;
  right: 10px;
  bottom: 10px;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  background: var(--purple);
  border: none;
  border-radius: 10px;
  color: #ffffff;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease, opacity 0.2s ease;
}

.gen-inline-send-btn:hover {
  background: var(--purple-hover);
}

.gen-inline-send-btn.disabled,
.gen-inline-send-btn.disabled:hover {
  background: var(--purple);
  opacity: 0.45;
  cursor: default;
}

.gen-inline-send-btn.active {
  background: var(--purple);
  opacity: 1;
  cursor: pointer;
}

.gen-inline-send-btn.active:hover {
  background: var(--purple-hover);
}

.gen-inline-send-btn.generating,
.gen-inline-send-btn.generating:hover {
  background: var(--gray-5);
  color: var(--gray-3);
  opacity: 1;
  cursor: default;
}

.gen-inline-send-btn.generating.gen-inline-send-btn--cancel,
.gen-inline-send-btn.generating.gen-inline-send-btn--cancel:hover {
  cursor: pointer;
  background: rgba(100, 104, 120, 0.95);
  color: #ffffff;
  opacity: 1;
}

.gen-inline-send-btn.generating.gen-inline-send-btn--cancel:hover {
  background: rgba(160, 70, 80, 0.9);
}

.gen-inline-send-btn:disabled {
  cursor: default;
}

.gen-inline-send-icon {
  display: block;
}

.ill-ref-hint {
  display: none;
  margin: 0 0 10px;
  font-family: "YS Text", sans-serif;
  font-size: 12px;
  line-height: 1.4;
}

.ill-ref-hint.ill-ref-hint-error {
  display: block;
  color: #ff8a8a;
}

.ill-ref-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}

.ill-ref-actions .gen-result-btn {
  flex: 1;
  min-width: 100px;
}

.ill-ref-actions-two .gen-result-btn {
  flex: 1 1 calc(50% - 4px);
  min-width: 0;
}

.ill-ref-file-input {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.ill-ref-preview-wrap {
  position: relative;
  margin-bottom: 12px;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.2);
  max-height: 140px;
  background: rgba(0, 0, 0, 0.2);
}

.ill-ref-preview-img {
  display: block;
  width: 100%;
  max-height: 140px;
  object-fit: contain;
}

.ill-ref-preview-clear {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 28px;
  height: 28px;
  padding: 0;
  margin: 0;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35);
  opacity: 0;
  pointer-events: none;
  transition:
    opacity 0.15s ease,
    background-color 0.15s ease,
    transform 0.15s ease;
}

.ill-ref-preview-wrap:hover .ill-ref-preview-clear:not(:disabled) {
  opacity: 1;
  pointer-events: auto;
}

.ill-ref-preview-clear:hover:not(:disabled) {
  background: var(--gray-input);
  color: var(--gray-3);
  transform: scale(1.05);
}

.ill-ref-preview-clear:focus-visible:not(:disabled) {
  opacity: 1;
  pointer-events: auto;
  outline: 2px solid var(--accent, #6b9fff);
  outline-offset: 2px;
}

.ill-ref-preview-clear:disabled {
  opacity: 0;
  cursor: default;
}

/* Устройства без hover (тач): крестик остаётся видимым */
@media (hover: none) {
  .ill-ref-preview-clear:not(:disabled) {
    opacity: 0.92;
    pointer-events: auto;
  }
}

.ill-ref-preview-clear-icon {
  position: relative;
  width: 12px;
  height: 12px;
  display: block;
}

.ill-ref-preview-clear-icon::before,
.ill-ref-preview-clear-icon::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 12px;
  height: 1.5px;
  background: currentColor;
  border-radius: 1px;
}

.ill-ref-preview-clear-icon::before {
  transform: translate(-50%, -50%) rotate(45deg);
}

.ill-ref-preview-clear-icon::after {
  transform: translate(-50%, -50%) rotate(-45deg);
}

/* ═══════════════ ИЛЛЮСТРАЦИИ: chip-кнопки и поповеры ═══════════════ */

.ill-settings-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  /* Отступ сверху не используем: расстояние до поля задаёт gap у .gen-input-section / .gen-content */
  margin-top: 0;
}

.ill-chip-with-popover {
  position: relative;
  display: inline-flex;
}

.ill-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 36px;
  padding: 0 14px;
  border-radius: 18px;
  background: #191E28;
  border: 0;
  color: var(--text-primary);
  font-family: "YS Text", sans-serif;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
  white-space: nowrap;
}

.ill-chip:hover:not(:disabled) {
  background: #2E4267;
}

.ill-chip:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.ill-chip.active {
  background: #3700F0;
  color: #ffffff;
}

.ill-chip.active:hover:not(:disabled) {
  background: #3700F0;
}

.ill-chip-icon-only {
  width: 36px;
  padding: 0;
  justify-content: center;
}

.ill-chip-icon {
  width: 18px;
  height: 18px;
  display: inline-block;
  flex-shrink: 0;
  background-position: center;
  background-repeat: no-repeat;
  background-size: contain;
}

.ill-chip-label {
  line-height: 1;
}

/* ───────────── Поповеры (единый вид) ───────────── */

.ill-popover {
  position: absolute;
  z-index: 40;
  background: #191e28;
  border: none;
  border-radius: 12px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.45);
  padding: 12px;
}

.ill-popover[hidden] {
  display: none;
}

.ill-popover-title {
  padding: 0 4px 8px;
  margin: 0;
  color: #6e82aa;
  font-family: "YS Text", sans-serif;
  font-size: 12px;
  font-weight: 500;
}

/* Поповер формата: плашки — скруглённый прямоугольник в точных пропорциях, подпись внутри (как в Figma) */
.ill-popover-aspect {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  padding: 12px;
  flex-wrap: nowrap;
  box-sizing: border-box;
}

.ill-aspect-card {
  box-sizing: border-box;
  flex: 0 0 auto;
  background: transparent;
  border: none;
  border-radius: 0;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  color: #6e82aa;
  transition: color 0.15s ease;
}

.ill-aspect-card:hover {
  color: #a0afc8;
}

.ill-aspect-card.active,
.ill-aspect-card.active:hover {
  color: #ffffff;
}

.ill-aspect-plaque {
  display: flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  border: 2px solid currentColor;
  border-radius: 8px;
  flex-shrink: 0;
  padding: 1px;
  min-width: 0;
}

/* Одна высота плашки; ширина по пропорции (высота 56px — чтобы «9:16» читалось в узкой плашке) */
.ill-aspect-plaque[data-ratio="1:1"] {
  width: 56px;
  height: 56px;
}

.ill-aspect-plaque[data-ratio="16:9"] {
  height: 56px;
  width: calc(56px * 16 / 9);
}

.ill-aspect-plaque[data-ratio="9:16"] {
  height: 56px;
  width: calc(56px * 9 / 16);
}

.ill-aspect-plaque-text {
  font-family: "YS Text", sans-serif;
  font-size: 11px;
  font-weight: 500;
  line-height: 1;
  text-align: center;
  white-space: nowrap;
}

.ill-aspect-plaque[data-ratio="9:16"] .ill-aspect-plaque-text {
  font-size: 9px;
  letter-spacing: -0.02em;
}

/* Поповер разрешения: radio-кнопки */
.ill-popover-reso {
  min-width: 140px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 12px;
}

.ill-radio-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  background: transparent;
  border: none;
  border-radius: 8px;
  color: #6e82aa;
  font-family: "YS Text", sans-serif;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  transition: color 0.15s ease, background 0.15s ease;
}

.ill-radio-row:hover {
  color: #a0afc8;
  background: transparent;
}

.ill-radio-row.active {
  color: #ffffff;
}

.ill-radio-row.active:hover {
  color: #ffffff;
}

.ill-radio-mark {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 1.5px solid currentColor;
  opacity: 0.85;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  position: relative;
  transition: border-color 0.15s ease, opacity 0.15s ease;
}

.ill-radio-row.active .ill-radio-mark {
  opacity: 1;
}

.ill-radio-row.active .ill-radio-mark::after {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #ffffff;
}

/* Поповер референса: кнопки + встроенное превью */
.ill-popover-attach {
  min-width: 180px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
}

.ill-attach-btn {
  width: 100%;
  height: 36px;
  background: transparent;
  border: 1px solid #2e4267;
  border-radius: 12px;
  box-sizing: border-box;
  color: #ffffff;
  font-family: "YS Text", sans-serif;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.ill-attach-btn:hover {
  color: #ffffff;
  border-color: #2e4267;
  background: rgba(46, 66, 103, 0.25);
}

.ill-attach-preview {
  position: relative;
  width: 80px;
  height: 80px;
  border-radius: 8px;
  overflow: hidden;
  background: rgba(0, 0, 0, 0.25);
  border: 2px solid #324164;
  box-sizing: border-box;
  margin-top: 4px;
}

.ill-attach-preview-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.ill-attach-preview-clear {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.7);
  border: none;
  cursor: pointer;
  padding: 0;
  display: none;
  align-items: center;
  justify-content: center;
  color: #ffffff;
}

.ill-attach-preview:hover .ill-attach-preview-clear,
.ill-attach-preview-clear:focus-visible {
  display: inline-flex;
}

.ill-attach-preview-clear-icon {
  position: relative;
  display: inline-block;
  width: 9px;
  height: 9px;
}

.ill-attach-preview-clear-icon::before,
.ill-attach-preview-clear-icon::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 9px;
  height: 1.5px;
  background: currentColor;
  border-radius: 1px;
}

.ill-attach-preview-clear-icon::before { transform: translate(-50%, -50%) rotate(45deg); }
.ill-attach-preview-clear-icon::after  { transform: translate(-50%, -50%) rotate(-45deg); }

/* ───────────── Панель выбора стиля (горизонтальная лента) ───────────── */

/* Якорь: панель стилей накладывается поверх блока «Предыдущие генерации». */
.ill-history-style-stack {
  position: relative;
  margin-top: 24px;
}

#illHistorySection.gen-history-section {
  margin-top: 0;
}

.ill-style-panel {
  margin: 0;
  padding: 12px 16px;
  display: none;
  flex-direction: column;
  gap: 10px;
  box-sizing: border-box;
  position: absolute;
  z-index: 40;
  background: #191e28;
  border-radius: 12px;
  border: none;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.45);
}

.ill-style-panel:not([hidden]) {
  display: flex;
}

.ill-style-panel[hidden] {
  display: none !important;
}

.ill-style-strip {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 2px 0 6px;
  scrollbar-width: thin;
  -webkit-overflow-scrolling: touch;
}

.ill-style-strip::-webkit-scrollbar {
  height: 6px;
}

.ill-style-strip::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 3px;
}

.ill-style-card {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 4px;
  padding: 0;
  background: transparent;
  border: none;
  cursor: pointer;
  text-align: center;
  width: 58px;
}

.ill-style-card-thumb {
  width: 58px;
  height: 58px;
  background-color: rgba(0, 0, 0, 0.3);
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  border-radius: 10px;
  border: 2px solid #324164;
  box-sizing: border-box;
  transition: border-color 0.15s ease;
}

.ill-style-card:hover:not(.active) .ill-style-card-thumb {
  border-color: #6e82aa;
}

.ill-style-card.active .ill-style-card-thumb,
.ill-style-card.active:hover .ill-style-card-thumb {
  border-color: #3700f0;
}

.ill-style-card-name {
  color: var(--text-secondary);
  font-family: "YS Text", sans-serif;
  font-size: 10px;
  font-weight: 500;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ill-style-card.active .ill-style-card-name {
  color: var(--text-primary);
}

/* Чтобы поповеры позиционировались абсолютно относительно экрана */
#illustrationGenerateScreen.active {
  position: relative;
}

.gen-segmented {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

/* Как теги в библиотеке материалов (.tag-chip / .tag-chip.selected) */
.gen-segment {
  flex: 1;
  min-width: 0;
  padding: 10px 14px;
  border-radius: 9px;
  border: none;
  background: #191E28;
  color: var(--text-primary);
  font-family: "YS Text", sans-serif;
  font-size: 12px;
  font-weight: 400;
  cursor: pointer;
  transition: all 0.2s ease;
  outline: none;
}

.gen-segment:hover:not(.active) {
  background: #324164;
}

.gen-segment.active {
  background: #3700F0;
  color: #ffffff;
}

.gen-segment.active:hover {
  background: #1900D2;
}

.gen-segment:disabled {
  opacity: 0.45;
  cursor: default;
}

.gen-result-extra {
  display: none;
  flex-direction: column;
  gap: 10px;
}

.gen-result-extra.visible {
  display: flex;
}

.gen-edit-section {
  display: none;
  flex-direction: column;
  gap: 10px;
}

.gen-edit-section.visible {
  display: flex;
}

.gen-edit-apply {
  margin-top: 0;
}

/* ═══════════════ GENERATION BOX ═══════════════ */

.gen-box {
  display: none;
}

.gen-box.visible {
  display: block;
}

/*
  Inset box-shadow follows the exact square contour — as per Figma.
  Animation alternates dominance between purple (top) and cyan (bottom),
  creating a smooth iridescent tide that washes across the inner edges.
*/
.gen-box-loader {
  background: #191e28;
  border-radius: var(--radius);
  position: relative;
  overflow: hidden;
  animation: glowShimmer 3.5s ease-in-out infinite;
  margin-left: auto;
  margin-right: auto;
}

.gen-box-loader[data-aspect="horizontal"] {
  width: 100%;
  aspect-ratio: 16 / 9;
  max-height: min(40vh, 220px);
}

.gen-box-loader[data-aspect="vertical"] {
  width: min(100%, 220px);
  aspect-ratio: 9 / 16;
  max-height: min(55vh, 380px);
}

.gen-box-loader[data-aspect="square"],
.gen-box-loader:not([data-aspect]) {
  width: 100%;
  max-width: 280px;
  aspect-ratio: 1;
}

@keyframes glowShimmer {
  0%, 100% {
    box-shadow:
      inset 0px   20px  55px   0px rgba(75, 60, 255, 1),
      inset 0px  -20px  28px -10px rgba(0, 250, 255, 0.35);
  }
  50% {
    box-shadow:
      inset 0px   20px  55px   0px rgba(75, 60, 255, 0.3),
      inset 0px  -20px  28px -10px rgba(0, 250, 255, 1);
  }
}

.gen-box-image {
  width: 100%;
  border-radius: var(--radius);
  overflow: hidden;
  background: #191e28;
  display: flex;
  align-items: center;
  justify-content: center;
}

.gen-box-image img {
  display: block;
  max-width: 100%;
  max-height: min(65vh, 520px);
  width: auto;
  height: auto;
  object-fit: contain;
}

.gen-box-dual {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.gen-box-dual-item {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.gen-box-dual-label {
  font-size: 12px;
  line-height: 1.2;
  color: rgba(255, 255, 255, 0.6);
  font-weight: 500;
}

.gen-box-dual--inline {
  flex-direction: row;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 10px;
}

@media (max-width: 360px) {
  .gen-box-dual--inline {
    flex-direction: column;
  }
}

.gen-box-loader--compact {
  margin-left: 0;
  margin-right: 0;
  max-width: 100%;
}

.gen-box-loader--compact[data-aspect="horizontal"] {
  width: min(100%, 200px);
  aspect-ratio: 16 / 9;
  max-height: 100px;
}

.gen-box-loader--compact[data-aspect="vertical"] {
  width: min(100%, 100px);
  aspect-ratio: 9 / 16;
  max-height: 160px;
}

.gen-box-loader--compact[data-aspect="square"] {
  width: min(100%, 120px);
  max-width: 120px;
  aspect-ratio: 1;
  max-height: 120px;
}

.gen-box-image--compact img {
  max-height: min(30vh, 200px);
}

/* ───── Photo gen — 16:9 frame stack with hover overlay ───── */

.gen-box-stack {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.gen-box-frame {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: var(--radius);
  overflow: hidden;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.gen-box-frame.loading {
  background: #191e28;
  border-color: transparent;
  animation: glowShimmer 3.5s ease-in-out infinite;
}

.gen-box-loading-content {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--text-secondary);
  font-family: "YS Text", sans-serif;
  font-weight: 500;
  font-size: 14px;
  pointer-events: none;
  isolation: isolate;
}

.gen-box-frame.result img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.gen-result-overlay {
  position: absolute;
  inset: 0;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.gen-box-frame.result:hover .gen-result-overlay,
.gen-box-frame.result:focus-within .gen-result-overlay {
  opacity: 1;
  pointer-events: auto;
}

.gen-result-overlay-bg {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0) 35%, rgba(0, 0, 0, 0.6) 100%);
  pointer-events: none;
}

.gen-result-overlay-buttons-left {
  position: absolute;
  left: 10px;
  bottom: 10px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
}

.gen-result-overlay-buttons-right {
  position: absolute;
  right: 10px;
  bottom: 10px;
}

.gen-overlay-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  background: transparent;
  border: none;
  border-radius: 8px;
  color: #ffffff;
  font-family: "YS Text", sans-serif;
  font-weight: 500;
  font-size: 13px;
  line-height: 1.2;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
  outline: none;
}

.gen-overlay-btn:hover,
.gen-overlay-btn:focus-visible {
  background: var(--bg-main);
  color: #ffffff;
}

.gen-overlay-btn:disabled {
  opacity: 0.6;
  cursor: default;
}

.gen-overlay-btn svg {
  display: block;
  flex-shrink: 0;
  width: auto;
  height: 18px;
}

/* ═══════════════ GENERATE — MAIN BUTTON ═══════════════ */

.gen-main-btn {
  width: 100%;
  padding: 14px;
  border-radius: var(--radius);
  border: none;
  font-family: "YS Text", sans-serif;
  font-weight: 500;
  font-size: 14px;
  text-align: center;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease;
  outline: none;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.gen-main-btn.disabled {
  background: var(--bg-card);
  color: var(--gray-5);
  cursor: default;
}

.gen-main-btn.active {
  background: var(--purple);
  color: #ffffff;
}

.gen-main-btn.active:hover {
  background: var(--purple-hover);
}

.gen-main-btn.generating {
  background: var(--bg-card);
  color: var(--text-secondary);
  cursor: default;
}

/* Кольцо: строго квадратная коробка + свой слой композиции — без визуального «шатания» при rotate */
.spinner.spinner--ring {
  display: block;
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  box-sizing: border-box;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.14);
  border-top-color: currentColor;
  transform: translateZ(0);
  transform-origin: 50% 50%;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  will-change: transform;
  animation: genSpinnerSpin 0.85s linear infinite;
}

@keyframes genSpinnerSpin {
  from {
    transform: translateZ(0) rotate(0deg);
  }
  to {
    transform: translateZ(0) rotate(360deg);
  }
}

/* ═══════════════ GENERATE — RESULT BUTTONS ═══════════════ */

.gen-result-buttons {
  display: none;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 0;
  align-items: stretch;
}

.gen-result-buttons.visible {
  display: flex;
}

.gen-result-btn {
  flex: 1;
  padding: 14px;
  border-radius: var(--radius);
  font-family: "YS Text", sans-serif;
  font-weight: 500;
  font-size: 14px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s ease;
  outline: none;
}

.gen-result-btn.outline {
  background: transparent;
  border: 1px solid #ffffff;
  color: #ffffff;
}

.gen-result-btn.outline:hover {
  border-color: var(--outline-hover);
  color: var(--outline-hover);
}

.gen-result-btn.primary {
  background: var(--purple);
  border: 1px solid var(--purple);
  color: #ffffff;
}

.gen-result-btn.primary:hover {
  background: var(--purple-hover);
  border-color: var(--purple-hover);
}

.gen-result-btn:disabled {
  opacity: 0.6;
  cursor: default;
}

.gen-insert-single {
  flex: 1;
  min-width: 0;
  display: flex;
}

.gen-insert-single .gen-result-btn {
  width: 100%;
}

.gen-result-insert-dual {
  flex: 1 1 100%;
  min-width: 0;
  gap: 10px;
}

.gen-result-insert-dual .gen-result-btn {
  flex: 1;
  min-width: 0;
}

/* ═══════════════ HISTORY SECTION ═══════════════ */

.gen-history-section {
  margin-top: 24px;
  --history-gap: 8px;
}

.gen-history-section .gen-label {
  margin-bottom: 12px;
}

/* Две независимые колонки: без «дыр» от выравнивания по строкам сетки */
.history-grid {
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  gap: var(--history-gap);
}

.history-col {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: var(--history-gap);
}

.history-item {
  width: 100%;
  min-width: 0;
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: opacity 0.2s ease;
  background: #191e28;
}

.history-item:hover {
  opacity: 0.85;
}

.history-item img {
  width: 100%;
  height: auto;
  display: block;
  object-fit: contain;
}

.history-item--photo {
  position: relative;
  cursor: default;
}

.history-item--photo:hover {
  opacity: 1;
}

.history-overlay {
  position: absolute;
  inset: 0;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
}

.history-item--photo:hover .history-overlay,
.history-item--photo:focus-within .history-overlay {
  opacity: 1;
  pointer-events: auto;
}

.history-overlay-bg {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0) 35%, rgba(0, 0, 0, 0.6) 100%);
  pointer-events: none;
}

.history-overlay-topright {
  position: absolute;
  top: 6px;
  right: 6px;
}

.history-overlay-buttons-left {
  position: absolute;
  left: 6px;
  bottom: 6px;
  display: flex;
  flex-direction: column-reverse;
  gap: 2px;
}

.history-overlay-buttons-right {
  position: absolute;
  right: 6px;
  bottom: 6px;
}

/* Три действия слева у иллюстраций — на низких 16:9-превью уплотняем без потери кликабельности */
.history-item--ill-history .history-overlay-buttons-left {
  gap: 0;
  bottom: 4px;
  left: 4px;
}

.history-item--ill-history .history-overlay-buttons-right {
  right: 4px;
  bottom: 4px;
}

.history-item--ill-history .history-overlay-btn {
  width: 24px;
  height: 24px;
  border-radius: 5px;
}

.history-item--ill-history .history-overlay-btn svg {
  height: 13px;
}

.history-item--ill-history .history-overlay-topright {
  top: 4px;
  right: 4px;
}

.history-delete-icon {
  position: relative;
  width: 16px;
  height: 16px;
  display: block;
}

.history-delete-icon::before,
.history-delete-icon::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 16px;
  height: 1.5px;
  background: currentColor;
  border-radius: 1px;
}

.history-delete-icon::before {
  transform: translate(-50%, -50%) rotate(45deg);
}

.history-delete-icon::after {
  transform: translate(-50%, -50%) rotate(-45deg);
}

.history-overlay-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  background: transparent;
  border: none;
  border-radius: 6px;
  color: #ffffff;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
  outline: none;
}

.history-overlay-btn:hover,
.history-overlay-btn:focus-visible {
  background: var(--bg-main);
}

.history-overlay-btn:disabled {
  opacity: 0.6;
  cursor: default;
}

.history-overlay-btn svg {
  display: block;
  width: auto;
  height: 16px;
}

/* ═══════════════ ERROR ═══════════════ */

.error-text {
  color: #ff8a8a;
  font-size: 13px;
  text-align: center;
  padding: 16px 0;
}

/* ═══════════════ PHOTO SCREEN ═══════════════ */

.search-wrapper {
  position: relative;
  margin-bottom: 12px;
}

.search-input {
  width: 100%;
  padding: 12px 44px 12px 14px;
  border-radius: 12px;
  border: none;
  background: #ffffff;
  font-family: "YS Text", sans-serif;
  font-size: 14px;
  line-height: 1.35;
  color: var(--bg-card);
  outline: none;
}

.search-input::placeholder {
  color: rgba(25, 30, 40, 0.5);
}

.search-icon {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  width: 19px;
  height: 19px;
  pointer-events: none;
}

/* Две колонки: grid, а не multicol (column-count) — иначе верхние ряды визуально съезжают */
#gallery,
.library-photos-gallery {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  align-items: start;
  align-content: start;
  padding-bottom: 180px;
  min-width: 0;
  max-width: 100%;
  width: 100%;
  box-sizing: border-box;
}

#gallery .galleryCard,
.library-photos-gallery .galleryCard {
  position: relative;
  border-radius: 12px;
  overflow: hidden;
  cursor: pointer;
  background: var(--bg-card);
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

.galleryImage {
  width: 100%;
  height: auto;
  display: block;
  vertical-align: top;
  transition: opacity 0.2s ease;
}

.galleryCard:hover .galleryImage {
  opacity: 0.85;
}

.galleryCard.selected .galleryImage {
  opacity: 0.5;
}

.selectionCircle {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: none;
  background: #4B3CFF;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.galleryCard.selected .selectionCircle {
  opacity: 1;
}

.selectionCircle svg {
  width: 8px;
  height: 8px;
}

#actionBar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--bg-main);
  padding: 16px 24px 16px 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  border-top: none;
}

.action-btn {
  flex: 1;
  padding: 14px;
  border-radius: 12px;
  font-family: "YS Text", sans-serif;
  font-weight: 500;
  font-size: 14px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s ease;
  outline: none;
}

.action-btn.outline {
  background: transparent;
  border: 1px solid #ffffff;
  color: #ffffff;
}

.action-btn.outline:hover {
  border-color: var(--outline-hover);
  color: var(--outline-hover);
}

.action-btn.primary {
  background: var(--purple);
  border: 1px solid var(--purple);
  color: #ffffff;
}

.action-btn.primary:hover {
  background: var(--purple-hover);
  border-color: var(--purple-hover);
}

.action-btn.primary:disabled {
  background: var(--bg-card);
  border-color: var(--bg-card);
  color: var(--gray-5);
  cursor: default;
  pointer-events: none;
}

/* ═══════════════ SLIDES LIBRARY — TAGS SECTION ═══════════════ */

.tags-section {
  margin-bottom: 12px;
}

.tags-container {
  border: 1px solid #324164;
  border-radius: 16px;
  padding: 8px;
  background: transparent;
}

.tags-toggle-btn {
  width: 100%;
  background: transparent;
  border: none;
  border-radius: 0;
  padding: 8px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  outline: none;
}

.tags-header-left {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
}

.tags-toggle-text {
  font-family: "YS Text", sans-serif;
  font-weight: 400;
  font-size: 16px;
  color: var(--text-primary);
}

/* Библиотека: «Теги» — как у активной вкладки (Слайды / Фото и т.д.) */
#libraryScreen .tags-toggle-text {
  font-family: "YS Text", sans-serif;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
}

#libraryScreen .tags-toggle-btn:hover .tags-toggle-text {
  color: var(--text-primary);
}

/* Одинаковые отступы свёрнуто/развёрнуто — строка «Теги» не прыгает */
#libraryScreen .tags-container {
  padding: 4px 6px;
}

#libraryScreen .tags-toggle-btn {
  padding: 4px 8px;
}

.tags-badge {
  background: #4B3CFF;
  color: #ffffff;
  font-family: "YS Text", sans-serif;
  font-weight: 400;
  font-size: 10px;
  padding: 3px 7px;
  border-radius: 35px;
  min-width: 19px;
  height: 19px;
  display: none;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.tags-badge.visible {
  display: flex;
}

.tags-toggle-icons {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-shrink: 0;
}

.tags-icon-clear {
  width: 20px;
  height: 20px;
  display: none;
  cursor: pointer;
}

.tags-icon-clear.visible {
  display: block;
}

.tags-icon-chevron {
  width: 20px;
  height: 20px;
  display: block;
  transition: transform 0.2s ease;
}

.tags-container.expanded .tags-icon-chevron {
  transform: rotate(180deg);
}

.tags-icon-clear path {
  transition: fill 0.15s ease;
}

.tags-icon-clear:hover path {
  fill: #8CA0C3;
}

.tags-icon-chevron path {
  transition: fill 0.15s ease;
}

.tags-icon-chevron:hover path {
  fill: #8CA0C3;
}

.tags-panel {
  max-height: 0;
  overflow: hidden;
  padding-top: 0;
  transition: max-height 0.3s ease, padding-top 0.3s ease;
}

.tags-panel.expanded {
  max-height: 600px;
  overflow-y: auto;
  padding-top: 20px;
  padding-bottom: 8px;
}

.tags-category {
  margin-bottom: 24px;
}

.tags-category:last-child {
  margin-bottom: 0;
}

.tags-category-title {
  font-family: "YS Text", sans-serif;
  font-weight: 400;
  font-size: 12px;
  color: var(--gray-1);
  margin-bottom: 12px;
  padding: 0 8px;
}

.tags-list {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 4px;
}

.tag-chip {
  background: #191E28;
  border: none;
  border-radius: 9px;
  padding: 10px 14px;
  font-family: "YS Text", sans-serif;
  font-weight: 400;
  font-size: 12px;
  color: var(--text-primary);
  cursor: pointer;
  transition: all 0.2s ease;
  outline: none;
}

.tag-chip:hover {
  background: #324164;
}

.tag-chip.selected {
  background: #3700F0;
  color: #ffffff;
}

.tag-chip.selected:hover {
  background: #1900D2;
}

/* ═══════════════ SLIDES LIBRARY — GALLERY ═══════════════ */

.slides-gallery {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  padding-bottom: 180px;
  min-width: 0;
}

.slide-card {
  position: relative;
  box-sizing: border-box;
  border: 1px solid #324164;
  border-radius: 12px;
  overflow: hidden;
  cursor: pointer;
  background: var(--bg-card);
  aspect-ratio: 309 / 174;
}

.slide-preview {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: opacity 0.2s ease;
}

.slide-card:hover .slide-preview {
  opacity: 0.85;
}

.slide-card.selected .slide-preview {
  opacity: 0.5;
}

.slide-checkbox {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: none;
  background: #4B3CFF;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  transition: all 0.2s ease;
  opacity: 0;
}

.slide-card.selected .slide-checkbox {
  opacity: 1;
}

.slide-checkbox svg {
  width: 12px;
  height: 12px;
  display: block;
}

/* ═══════════════ SLIDES LIBRARY — ACTION BAR ═══════════════ */

.action-bar-slides {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--bg-main);
  padding: 16px 24px 16px 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  border-top: none;
}

.action-bar-disclaimer {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: var(--azure-2);
  border-radius: 8px;
}

.action-bar-disclaimer svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.action-bar-disclaimer span {
  font-family: "YS Text", sans-serif;
  font-weight: 400;
  font-size: 12px;
  color: #000000;
  line-height: 1.3;
  flex: 1;
}

.action-bar-buttons {
  display: flex;
  gap: 10px;
}
