/* Design Tokens & Theme Variables matching study24.ai */
:root {
  /* Colors */
  --bg-main: #ffffff;
  --bg-sidebar: #f5f5f7;
  --bg-panel: #ffffff;
  --bg-card: #f9f9fb;
  --bg-input: #ffffff;
  
  --border-color: rgba(13, 13, 13, 0.08);
  --border-focus: #0a7cff;
  
  --text-primary: #0d0d0d;
  --text-secondary: rgba(13, 13, 13, 0.6);
  --text-muted: rgba(13, 13, 13, 0.35);
  
  --primary: #0a7cff;
  --primary-glow: rgba(10, 124, 255, 0.15);
  --primary-hover: #006ce6;
  --accent: #00c853;
  
  --success: #00c853;
  --danger: #ef4444;
  --warning: #f59e0b;

  --job-card-bg: rgba(255, 255, 255, 0.45);
  --job-card-border: rgba(15, 23, 42, 0.06);
  --job-card-bg-hover: rgba(255, 255, 255, 0.9);

  /* Typography */
  --font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;

  /* Spacing */
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 24px;
  --radius-pill: 9999px;
  
  --transition-fast: 0.15s ease-out;
  --transition-normal: 0.25s ease-out;
}

body.dark-theme {
  --bg-main: #0d0d0d;
  --bg-sidebar: #171717;
  --bg-panel: #171717;
  --bg-card: #212121;
  --bg-input: #212121;
  
  --border-color: rgba(255, 255, 255, 0.08);
  --border-focus: #0a7cff;
  
  --text-primary: #f5f5f7;
  --text-secondary: rgba(245, 245, 247, 0.6);
  --text-muted: rgba(245, 245, 247, 0.35);
  
  --primary-glow: rgba(10, 124, 255, 0.25);

  --job-card-bg: rgba(255, 255, 255, 0.05);
  --job-card-border: rgba(255, 255, 255, 0.08);
  --job-card-bg-hover: rgba(255, 255, 255, 0.12);
}

/* Base Styles */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-family);
  background-color: var(--bg-main);
  color: var(--text-primary);
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  display: flex;
}

/* Utility Classes */
.hidden {
  display: none !important;
}

.glass-panel {
  background: var(--bg-panel);
  border: 1px solid var(--border-color);
}

.glass-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
}

/* Scrollbar Styles */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.08);
  border-radius: var(--radius-pill);
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 0, 0, 0.15);
}

/* Buttons */
button {
  font-family: var(--font-family);
  cursor: pointer;
  border: none;
  outline: none;
  transition: all var(--transition-fast);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: transparent;
  color: inherit;
}

.primary-btn {
  background: var(--primary);
  color: #fff;
  padding: 10px 20px;
  border-radius: var(--radius-pill);
  font-weight: 500;
  font-size: 0.9rem;
}

.primary-btn:hover {
  background: var(--primary-hover);
}

.secondary-btn {
  background: rgba(0, 0, 0, 0.05);
  color: var(--text-primary);
  padding: 10px 20px;
  border-radius: var(--radius-pill);
  font-weight: 500;
}

.secondary-btn:hover {
  background: rgba(0, 0, 0, 0.08);
}

.ghost-btn {
  background: transparent;
  color: var(--text-secondary);
  padding: 8px 16px;
  border-radius: var(--radius-md);
}

.ghost-btn:hover {
  background: rgba(0, 0, 0, 0.04);
  color: var(--text-primary);
}

.icon-btn-text {
  background: transparent;
  color: var(--text-secondary);
  padding: 10px 14px;
  border-radius: var(--radius-md);
  font-weight: 500;
  font-size: 14px;
  width: 100%;
  justify-content: flex-start;
}

.icon-btn-text:hover {
  background: rgba(0, 0, 0, 0.04);
  color: var(--text-primary);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.85rem;
}

.text-danger {
  color: var(--danger) !important;
}

.text-danger:hover {
  background: rgba(239, 68, 68, 0.05) !important;
}

/* Auth Screens */
.auth-wrapper {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  height: 100%;
  padding: 20px;
  background-color: var(--bg-sidebar);
}

.auth-card {
  width: 100%;
  max-width: 400px;
  padding: 30px;
  border-radius: var(--radius-lg);
  background: var(--bg-panel);
  border: 1px solid var(--border-color);
  box-shadow: 0 4px 20px rgba(0,0,0,0.04);
  animation: fadeIn var(--transition-normal);
}

.auth-header {
  text-align: center;
  margin-bottom: 24px;
}

.logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 10px;
}

.logo-icon {
  font-size: 2rem;
  color: var(--primary);
}

.logo h1, .logo h2 {
  font-weight: 700;
  letter-spacing: -0.5px;
  color: var(--text-primary);
}

.auth-header p {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.input-group {
  margin-bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.input-group label {
  font-size: 0.8rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.input-group input {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 12px;
  border-radius: var(--radius-md);
  outline: none;
  font-family: var(--font-family);
  font-size: 0.95rem;
  transition: all var(--transition-fast);
}

.input-group input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-glow);
}

#auth-submit-btn {
  width: 100%;
  margin-top: 10px;
  background: var(--primary);
  border-radius: var(--radius-pill);
  padding: 12px;
}

.auth-footer {
  margin-top: 20px;
  text-align: center;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.auth-footer a {
  color: var(--primary);
  text-decoration: none;
  font-weight: 500;
}

.auth-footer a:hover {
  text-decoration: underline;
}

/* App Layout */
.main-wrapper {
  display: flex;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
}

/* Sidebar styling exactly matching study24.ai */
.sidebar {
  width: 260px;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  height: 100%;
  z-index: 10;
}

.sidebar-header {
  padding: 20px;
  border-bottom: 1px solid rgba(0,0,0,0.03);
  display: flex;
  flex-direction: column;
  gap: 16px;
  background: var(--bg-sidebar);
  z-index: 10;
  position: relative;
  flex-shrink: 0;
}

.sidebar-header .logo {
  justify-content: flex-start;
}

.sidebar-header h2 {
  font-size: 1.3rem;
}

#new-chat-btn {
  background: transparent;
  color: var(--text-secondary);
  border: none;
}

#new-chat-btn:hover {
  background: rgba(0, 0, 0, 0.04);
  color: var(--text-primary);
}

/* Chat List */
.chat-list {
  flex: none;
  height: auto;
  overflow: visible;
  padding: 12px 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.chat-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  transition: all var(--transition-fast);
  cursor: pointer;
}

.chat-item:hover {
  background: rgba(0, 0, 0, 0.03);
  color: var(--text-primary);
}

.chat-item.active {
  background: rgba(0, 0, 0, 0.06);
  color: var(--text-primary);
  font-weight: 500;
}

.chat-info {
  display: flex;
  align-items: center;
  gap: 10px;
  overflow: hidden;
  flex: 1;
}

.chat-title {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 0.85rem;
}

.delete-chat-btn {
  background: transparent;
  color: var(--text-muted);
  opacity: 0;
  padding: 2px;
  border-radius: var(--radius-sm);
}

.chat-item:hover .delete-chat-btn {
  opacity: 1;
}

.delete-chat-btn:hover {
  color: var(--danger);
  background: rgba(239, 68, 68, 0.08);
}

/* Sidebar Footer Profile Card */
.sidebar-footer {
  padding: 16px;
  border-top: 1px solid rgba(0,0,0,0.03);
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: auto;
  background: var(--bg-sidebar);
  z-index: 10;
  position: relative;
  flex-shrink: 0;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.avatar-icon {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: #0a7cff;
  color: #fff;
  padding: 8px;
}

.user-details {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  flex: 1;
}

.user-email {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-tier {
  font-size: 0.7rem;
  color: var(--text-secondary);
  font-weight: 400;
  margin-top: 1px;
}

.balance-display {
  display: none; /* In study24.ai, balance is in the header, not footer */
}

/* Chat Area - Light theme */
.chat-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  min-width: 0;
  position: relative;
  background-color: var(--bg-main);
}

.chat-header {
  padding: 14px 24px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 60px;
  position: sticky;
  top: 0;
  z-index: 20;
  background-color: var(--bg-main);
}

.model-info {
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--border-color);
  padding: 6px 14px;
  border-radius: var(--radius-pill);
  cursor: pointer;
  background: var(--bg-panel);
}

.model-info:hover {
  background: var(--bg-card);
}

.model-icon {
  width: 16px;
  height: 16px;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  justify-content: center;
}

.model-icon svg, 
.welcome-model-icon svg,
.message-avatar svg,
.dropdown-icon svg,
.net-card-icon svg {
  width: 100%;
  height: 100%;
  object-fit: contain;
}



.welcome-model-icon svg,
.model-icon svg,
.dropdown-icon svg,
.net-card-icon svg {
  color: currentColor;
}

.model-info h3 {
  font-size: 0.85rem;
  font-weight: 500;
}

.status-indicator {
  display: none; /* Hide in header */
}

/* Header balance and pricing button */
.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.header-balance {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(10, 124, 255, 0.08);
  border-radius: var(--radius-pill);
  padding: 0 14px;
  height: 32px;
  box-sizing: border-box;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--primary);
  position: relative;
  cursor: pointer;
}

.header-balance-icon {
  color: var(--primary);
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

.header-balance-icon-star {
  color: var(--primary);
  font-size: 1.1rem;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 14px;
  height: 14px;
}

/* Micro progress bar for the header badge */
.micro-progress-bar {
  width: 36px;
  height: 6px;
  background: rgba(10, 124, 255, 0.2);
  border-radius: var(--radius-pill);
  overflow: hidden;
  display: flex;
  flex-shrink: 0;
}

.micro-progress-bar-fill {
  height: 100%;
  background: var(--primary);
  border-radius: var(--radius-pill);
  transition: width 0.3s ease;
}

/* Base state: hidden popover */
.balance-popover {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 260px;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: var(--radius-md);
  padding: 16px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
  display: flex;
  flex-direction: column;
  gap: 12px;
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease, pointer-events 0.2s ease;
  transition-delay: 1.2s; /* 1.2 seconds delay to allow clicking on child elements before closing */
  z-index: 999;
  box-sizing: border-box;
}

body.dark-theme .balance-popover {
  background: rgba(33, 33, 33, 0.95);
  border-color: rgba(255, 255, 255, 0.08);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

/* Transparent bridge to prevent losing hover when crossing the gap */
.balance-popover::before {
  content: "";
  position: absolute;
  top: -12px;
  left: 0;
  width: 100%;
  height: 12px;
  background: transparent;
}

/* Hover trigger */
.header-balance:hover .balance-popover {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
  transition-delay: 0s; /* Show immediately on hover */
}

/* Popover Content Styling */
.popover-block {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  box-sizing: border-box;
  text-align: left;
}

.popover-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
}

.popover-block-title {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.popover-tokens-detail {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-primary);
}

.popover-balance-val {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--primary);
}

/* Progress bars inside popover */
.popover-progress-bg {
  width: 100%;
  height: 6px;
  background: rgba(0, 0, 0, 0.06);
  border-radius: var(--radius-pill);
  overflow: hidden;
}

body.dark-theme .popover-progress-bg {
  background: rgba(255, 255, 255, 0.1);
}

.popover-progress-fill {
  height: 100%;
  background: var(--primary);
  border-radius: var(--radius-pill);
  transition: width 0.3s ease;
}

.popover-divider {
  height: 1px;
  background: var(--border-color);
  width: 100%;
}

/* Dashed tariff connector block inside popover */
.popover-subscription-dashed {
  border: 1px dashed var(--border-color);
  border-radius: var(--radius-sm);
  padding: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-align: center;
  background: rgba(0, 0, 0, 0.01);
  box-sizing: border-box;
}

body.dark-theme .popover-subscription-dashed {
  background: rgba(255, 255, 255, 0.01);
}

.dashed-text {
  font-size: 0.75rem;
  color: var(--text-secondary);
  font-weight: 500;
}

/* Token packages inside the balance block */
.token-packages {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.token-packages:empty {
  display: none;
}

.token-packages-note {
  font-size: 0.75rem;
  color: var(--text-secondary);
  font-weight: 500;
}

/* Profile: package cards under the balance; swipe sideways on phones */
.profile-token-packages:empty,
.profile-token-packages .token-packages:empty {
  display: none;
}

.profile-token-packages {
  width: 100%;
  margin-top: 16px;
}

.profile-token-packages .token-packages {
  gap: 10px;
}

.profile-token-packages .token-packages-note {
  font-size: 0.85rem;
}

.token-package-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  padding-top: 10px; /* room for the ribbon */
}

.token-package-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  padding: 16px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--bg-card);
  box-sizing: border-box;
  min-width: 0;
}

.token-package-card.is-best {
  border-color: var(--primary);
  background: linear-gradient(180deg, rgba(10, 124, 255, 0.08), rgba(10, 124, 255, 0.02));
  box-shadow: 0 6px 20px var(--primary-glow);
}

.token-package-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-height: 22px;
  margin-bottom: 10px;
}

.token-package-badge {
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1;
  padding: 5px 8px;
  border-radius: var(--radius-pill);
  background: rgba(0, 200, 83, 0.12);
  color: #00873a;
}

/* Sits on the top border, so it never pushes the card content down. */
.token-package-ribbon {
  position: absolute;
  top: 0;
  left: 16px;
  transform: translateY(-50%);
  font-size: 0.7rem;
  font-weight: 700;
  line-height: 1;
  padding: 5px 10px;
  border-radius: var(--radius-pill);
  background: var(--primary);
  color: #fff;
  white-space: nowrap;
}

body.dark-theme .token-package-badge {
  color: #4ade80;
}

.token-package-price {
  font-size: 1.75rem;
  font-weight: 800;
  line-height: 1.1;
  color: var(--text-primary);
  white-space: nowrap;
  margin-bottom: 8px;
}

.token-package-amount {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
  margin-bottom: 14px;
}

.token-package-star {
  color: var(--primary);
}

.token-package-usage {
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: 100%;
  padding-top: 12px;
  margin-bottom: 14px;
  border-top: 1px solid var(--border-color);
}

.token-package-usage-title {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.token-package-usage-item {
  position: relative;
  padding-left: 22px;
  font-size: 0.82rem;
  color: var(--text-primary);
}

.token-package-usage-item::before {
  content: "✓";
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--success);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  line-height: 16px;
  text-align: center;
}

.token-package-usage-or {
  padding-left: 22px;
  font-size: 0.72rem;
  color: var(--text-muted);
}

.token-package-buy {
  margin-top: auto;
  width: 100%;
  border: none;
  border-radius: var(--radius-pill);
  padding: 10px 16px;
  font-family: var(--font-family);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  background: rgba(10, 124, 255, 0.1);
  color: var(--primary);
  transition: background var(--transition-fast), opacity var(--transition-fast);
}

.token-package-buy:hover {
  background: rgba(10, 124, 255, 0.16);
}

.token-package-card.is-best .token-package-buy {
  background: var(--primary);
  color: #fff;
}

.token-package-card.is-best .token-package-buy:hover {
  background: var(--primary-hover);
}

.token-package-buy:disabled {
  opacity: 0.6;
  cursor: progress;
}

@media (max-width: 600px) {
  .token-package-list {
    display: flex;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    /* The next card peeks in to hint that the row scrolls. */
    padding: 10px 0 8px;
  }

  .token-package-list::-webkit-scrollbar {
    display: none;
  }

  .token-package-card {
    flex: 0 0 72%;
    scroll-snap-align: start;
  }
}

/* /token window; the id outranks the shared .lightbox-content rules further down. */
#token-packages-modal .token-modal-content {
  max-width: 920px;
  padding: 28px;
  gap: 20px;
  box-sizing: border-box;
}

.token-modal-header h3 {
  margin: 0 40px 6px 0;
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text-primary);
}

.token-modal-subtitle {
  margin: 0 0 12px;
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.token-modal-limit {
  margin: 0 40px 12px 0;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: rgba(245, 158, 11, 0.12);
  color: var(--text-primary);
  font-size: 0.85rem;
  font-weight: 500;
  line-height: 1.4;
}

.token-modal-limit.hidden {
  display: none;
}

.token-modal-balance {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--primary);
  background: rgba(10, 124, 255, 0.08);
  padding: 6px 12px;
  border-radius: var(--radius-pill);
}

/* The window already says the tokens never expire. */
.token-modal-packages > .token-packages > .token-packages-note:first-child:not(:only-child) {
  display: none;
}

.token-modal-tariff-hint {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 16px;
  border: 1px dashed var(--border-color);
  border-radius: var(--radius-md);
}

.token-modal-tariff-hint.hidden {
  display: none;
}

.token-modal-tariff-badge {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: 14px;
  background: linear-gradient(135deg, #ff9500, #ff5e3a);
  color: #fff;
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  box-shadow: 0 6px 16px rgba(255, 94, 58, 0.3);
}

.token-modal-tariff-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex: 1;
}

.token-modal-tariff-title {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-primary);
}

.token-modal-tariff-desc {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.small-pale-btn.token-modal-tariff-btn {
  flex-shrink: 0;
  align-self: center;
  min-height: 44px;
  padding: 12px 20px;
  font-size: 0.875rem;
  white-space: nowrap;
}

@media (max-width: 600px) {
  /* Full screen on phones: more room for the cards. */
  #token-packages-modal {
    padding: 0;
  }

  /* The id outranks the shared .lightbox-content rules further down. */
  #token-packages-modal .token-modal-content {
    max-width: none;
    height: 100%;
    max-height: 100dvh;
    border: none;
    border-radius: 0;
    padding: calc(22px + env(safe-area-inset-top)) 18px calc(22px + env(safe-area-inset-bottom));
  }

  .token-modal-content .lightbox-close-btn {
    top: calc(14px + env(safe-area-inset-top));
  }

  /* Badge and text in one row, the button below them. */
  .token-modal-tariff-hint {
    flex-wrap: wrap;
    gap: 12px;
  }

  .token-modal-tariff-badge {
    width: 40px;
    height: 40px;
    font-size: 1rem;
  }

  .token-modal-tariff-text {
    flex-basis: calc(100% - 52px);
  }

  .token-modal-tariff-btn {
    flex-basis: 100%;
  }
}

/* Choose tariff button inside popover (small & pale) */
.small-pale-btn {
  background: rgba(10, 124, 255, 0.08);
  color: var(--primary);
  border: none;
  outline: none;
  font-family: var(--font-family);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition-fast), opacity var(--transition-fast);
  align-self: flex-start;
  opacity: 0.85;
}

.small-pale-btn:hover {
  background: rgba(10, 124, 255, 0.12);
  opacity: 1;
}

.choose-tariff-btn {
  background: var(--primary);
  color: #fff;
  border-radius: var(--radius-pill);
  padding: 0 16px;
  height: 32px;
  box-sizing: border-box;
  font-size: 0.85rem;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.choose-tariff-btn:hover {
  background: var(--primary-hover);
}

/* Chat History */
.chat-history {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* Welcome Center Screen */
.welcome-screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  width: 100%;
  max-width: 800px;
  margin: auto;
  gap: 12px;
  color: var(--text-secondary);
  box-sizing: border-box;
}

/* Welcome screen jobs grid and cards (Compact Wrapped Grid Layout) */
.welcome-jobs-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 10px;
  width: 100%;
  max-width: 800px;
  margin-top: 20px;
  padding: 0 16px;
  box-sizing: border-box;
  justify-content: center;
}

.welcome-jobs-grid.grid-4-cols {
  grid-template-columns: repeat(4, 1fr);
}

@media (max-width: 768px) {
  .welcome-jobs-grid.grid-4-cols {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 480px) {
  .welcome-jobs-grid.grid-4-cols {
    grid-template-columns: repeat(2, 1fr);
  }
}

.job-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  background: var(--job-card-bg);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--job-card-border);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  cursor: pointer;
  text-align: left;
  min-width: 0;
  box-sizing: border-box;
  transition: all var(--transition-fast);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.005);
}

.job-card:hover {
  transform: translateY(-3px);
  background: var(--job-card-bg-hover);
  box-shadow: 0 6px 18px var(--hover-shadow);
  border-color: var(--hover-border);
}

/* Custom themed glows for hover states */
.job-card:nth-child(1) {
  --hover-border: rgba(10, 124, 255, 0.3);
  --hover-shadow: rgba(10, 124, 255, 0.05);
}
.job-card:nth-child(2) {
  --hover-border: rgba(6, 182, 212, 0.3);
  --hover-shadow: rgba(6, 182, 212, 0.05);
}
.job-card:nth-child(3) {
  --hover-border: rgba(139, 92, 246, 0.3);
  --hover-shadow: rgba(139, 92, 246, 0.05);
}
.job-card:nth-child(4) {
  --hover-border: rgba(245, 158, 11, 0.3);
  --hover-shadow: rgba(245, 158, 11, 0.05);
}
.job-card:nth-child(5) {
  --hover-border: rgba(16, 185, 129, 0.3);
  --hover-shadow: rgba(16, 185, 129, 0.05);
}
.job-card:nth-child(6) {
  --hover-border: rgba(244, 63, 94, 0.3);
  --hover-shadow: rgba(244, 63, 94, 0.05);
}
.job-card:nth-child(7) {
  --hover-border: rgba(79, 70, 229, 0.3);
  --hover-shadow: rgba(79, 70, 229, 0.05);
}
.job-card:nth-child(8) {
  --hover-border: rgba(13, 148, 136, 0.3);
  --hover-shadow: rgba(13, 148, 136, 0.05);
}
.job-card:nth-child(9) {
  --hover-border: rgba(217, 70, 239, 0.3);
  --hover-shadow: rgba(217, 70, 239, 0.05);
}
.job-card:nth-child(10) {
  --hover-border: rgba(234, 88, 12, 0.3);
  --hover-shadow: rgba(234, 88, 12, 0.05);
}

.job-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  flex-shrink: 0;
}

.job-card:nth-child(10n + 1) .job-icon {
  background: rgba(10, 124, 255, 0.08);
  color: #0a7cff;
}
.job-card:nth-child(10n + 2) .job-icon {
  background: rgba(6, 182, 212, 0.08);
  color: #06b6d4;
}
.job-card:nth-child(10n + 3) .job-icon {
  background: rgba(139, 92, 246, 0.08);
  color: #8b5cf6;
}
.job-card:nth-child(10n + 4) .job-icon {
  background: rgba(245, 158, 11, 0.08);
  color: #f59e0b;
}
.job-card:nth-child(10n + 5) .job-icon {
  background: rgba(16, 185, 129, 0.08);
  color: #10b981;
}
.job-card:nth-child(10n + 6) .job-icon {
  background: rgba(244, 63, 94, 0.08);
  color: #f43f5e;
}
.job-card:nth-child(10n + 7) .job-icon {
  background: rgba(79, 70, 229, 0.08);
  color: #4f46e5;
}
.job-card:nth-child(10n + 8) .job-icon {
  background: rgba(13, 148, 136, 0.08);
  color: #0d9488;
}
.job-card:nth-child(10n + 9) .job-icon {
  background: rgba(217, 70, 239, 0.08);
  color: #d946ef;
}
.job-card:nth-child(10n + 10) .job-icon {
  background: rgba(234, 88, 12, 0.08);
  color: #ea580c;
}

.job-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  width: 100%;
  min-width: 0;
}

.job-info h4 {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  width: 100%;
}

.job-card .job-info p {
  font-size: 0.68rem;
  color: var(--text-secondary);
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: normal;
  width: 100%;
  height: 2.6em;
}


.welcome-icon {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--primary-glow);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 8px;
}

.welcome-screen h1, .welcome-screen .welcome-title {
  font-weight: 700;
  color: var(--text-primary);
  font-size: 2.2rem;
  letter-spacing: -0.02em;
  margin-bottom: 8px;
}

.welcome-screen > p {
  font-size: 1rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

.gradient-text {
  background: linear-gradient(90deg, #ff0000 0%, #9900ff 50%, #0000ff 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  color: transparent;
  display: inline-block;
}

/* Messages styling matching study24.ai */
.message-bubble {
  display: flex;
  gap: 12px;
  max-width: 760px;
  width: 100%;
  margin-left: auto;
  margin-right: auto;
}

.message-bubble.user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.message-bubble.assistant {
  align-self: flex-start;
}

/* Chat answers stay compact; the full picture opens in the viewer/editor.
   Limits are absolute: a percentage here lets the answer frame keep the
   picture's natural width (e.g. 1536px) while the picture itself shrinks. */
.generated-image-output {
  display: block;
  width: auto;
  height: auto;
  max-width: 360px;
  max-height: 420px;
  object-fit: contain;
  border-radius: 8px;
}

.generated-image-output.opens-editor {
  cursor: zoom-in;
}

@media (max-width: 768px) {
  .generated-image-output {
    max-width: 75vw;
    max-height: 55vh;
  }
}

.msg-avatar {
  display: none; /* Hide avatars in message list to match modern simple screenshot design */
}

.msg-content {
  padding: 12px 18px;
  border-radius: var(--radius-md);
  line-height: 1.5;
  font-size: 0.92rem;
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
}

.msg-content h1,
.msg-content h2,
.msg-content h3,
.msg-content h4,
.msg-content h5,
.msg-content h6 {
  margin-top: 14px;
  margin-bottom: 8px;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.3;
}

.msg-content h1 { font-size: 1.35rem; }
.msg-content h2 { font-size: 1.2rem; }
.msg-content h3 { font-size: 1.1rem; }
.msg-content h4 { font-size: 1.0rem; }
.msg-content h5 { font-size: 0.95rem; }
.msg-content h6 { font-size: 0.9rem; }

.msg-content h1:first-child,
.msg-content h2:first-child,
.msg-content h3:first-child,
.msg-content h4:first-child,
.msg-content h5:first-child,
.msg-content h6:first-child {
  margin-top: 0;
}

.message-bubble.user .msg-content {
  background: var(--bg-sidebar);
  color: var(--text-primary);
  border-bottom-right-radius: 4px;
}

.message-bubble.assistant .msg-content {
  background: var(--bg-panel);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  border-bottom-left-radius: 4px;
}

.msg-content code {
  background: rgba(0, 0, 0, 0.05);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: monospace;
  font-size: 0.85em;
  color: #c2185b;
}

.msg-content pre {
  background: #f9f9fb;
  padding: 14px;
  border-radius: var(--radius-sm);
  overflow-x: auto;
  margin: 10px 0;
  border: 1px solid var(--border-color);
}

.msg-content pre code {
  background: transparent;
  padding: 0;
  color: #0d0d0d;
}

/* Input area matching screenshots */
.chat-input-area {
  padding: 16px 24px 24px 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 760px;
  width: 100%;
  margin-left: auto;
  margin-right: auto;
  transition: all 0.3s ease-in-out;
  flex-shrink: 0;
}

.chat-composer-notice-slot.hidden { display: none; }
.chat-composer-notice {
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 104px;
  padding: 14px 62px 14px 20px;
  border: 1px solid rgba(245, 158, 11, .30);
  border-radius: 18px;
  background: linear-gradient(112deg, rgba(255, 250, 229, .98) 0%, rgba(255, 255, 255, .98) 58%, rgba(255, 247, 218, .96) 100%);
  box-shadow: 0 10px 28px rgba(180, 113, 13, .10), inset 0 1px 0 rgba(255, 255, 255, .9);
  color: var(--text-primary);
}
.chat-composer-notice::before {
  content: ''; position: absolute; width: 120px; height: 120px; right: -64px; top: -82px;
  border-radius: 50%; background: rgba(245, 158, 11, .13); filter: blur(2px); pointer-events: none;
}
.chat-composer-notice__icon {
  width: 38px; height: 38px; display: grid; place-items: center; flex: 0 0 38px;
  border-radius: 13px; background: linear-gradient(135deg, #1688ff, #0a6ded);
  color: #fff; font-size: 19px; font-weight: 700; box-shadow: 0 6px 15px rgba(10, 124, 255, .28);
}
.chat-composer-notice__copy { position: relative; z-index: 1; display: flex; flex: 1; flex-direction: column; gap: 3px; min-width: 0; }
.chat-composer-notice__copy strong { font-size: .93rem; letter-spacing: -.01em; }
.chat-composer-notice__copy span { color: var(--text-secondary); font-size: .82rem; line-height: 1.4; }
.chat-composer-notice__actions { position: static; z-index: 1; display: flex; align-items: center; gap: 6px; flex-shrink: 0; margin-right: 4px; }
.chat-composer-notice__primary {
  border: 0; border-radius: var(--radius-pill); padding: 10px 16px;
  background: var(--primary); color: #fff; font: inherit; font-size: .84rem;
  font-weight: 600; cursor: pointer; white-space: nowrap;
  transition: background var(--transition-fast);
}
.chat-composer-notice__primary:hover { background: var(--primary-hover); }
.chat-composer-notice__close {
  position: absolute; top: 11px; right: 11px;
  width: 26px; height: 26px; border: 0; border-radius: 50%; background: rgba(10, 124, 255, .07); color: var(--text-secondary);
  font-size: 20px; line-height: 1; cursor: pointer;
}
body.dark-theme .chat-composer-notice { background: linear-gradient(112deg, rgba(67, 48, 11, .98), rgba(44, 34, 14, .98)); border-color: rgba(245, 158, 11, .34); box-shadow: 0 10px 28px rgba(0, 0, 0, .24); }
body.dark-theme .chat-composer-notice__close { background: rgba(245, 180, 60, .14); }

#chat-screen.welcome-mode {
  overflow-y: auto;
}

#chat-screen.welcome-mode .chat-history {
  flex: none;
  padding-bottom: 0;
  margin-top: 10vh; /* Сдвиг сверху, чтобы заголовок был не в самом верху, но и не по центру */
}

#chat-screen.welcome-mode .chat-input-area {
  flex: none;
  margin-bottom: 24px;
}

/* Стили для скроллящегося списка моделей под инпутом на главной */
.welcome-models-container {
  margin-top: 16px;
  width: 100%;
}

.welcome-models-scroll {
  overflow-x: auto;
  padding-bottom: 8px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none; /* Firefox */
}

.welcome-models-scroll::-webkit-scrollbar {
  display: none; /* Chrome, Safari */
}

.welcome-tabs-container {
  display: flex;
  justify-content: center;
  margin-top: 16px;
  margin-bottom: 12px;
}

.welcome-tabs-bg {
  display: inline-flex;
  background: var(--bg-panel);
  padding: 4px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border-color);
}

.welcome-tab-btn {
  padding: 6px 16px;
  font-size: 0.85rem;
  font-weight: 500;
  border-radius: var(--radius-pill);
  color: var(--text-secondary);
  background: transparent;
  border: none;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.welcome-tab-btn:hover {
  background: rgba(0,0,0,0.03);
  color: var(--text-primary);
}

body.dark-theme .welcome-tab-btn:hover {
  background: rgba(255,255,255,0.03);
}

.welcome-tab-btn.active {
  background: rgba(10, 124, 255, 0.08);
  color: var(--primary);
  font-weight: 600;
}

.welcome-jobs-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  padding: 4px;
}

@media (max-width: 768px) {
  .welcome-tab-btn { padding: 6px 10px; font-size: .8rem; white-space: nowrap; }
}

@media (max-width: 768px) {
  .welcome-jobs-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.welcome-models-grid {
  display: flex;
  gap: 8px;
  padding: 4px;
  justify-content: center; /* Центрируем, если элементов мало */
  min-width: min-content;
}

.welcome-model-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  width: 90px;
  height: 84px;
  padding: 8px;
  box-sizing: border-box;
  border-radius: var(--radius-md);
  background: var(--job-card-bg);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--job-card-border);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.005);
  transition: all var(--transition-fast);
  flex-shrink: 0;
  color: var(--text-secondary);
}

.welcome-model-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  transition: filter 0.2s ease;
  filter: grayscale(100%);
}

.welcome-model-card[data-photo-tool-path] {
  height: 90px;
  font-family: inherit;
}

.welcome-model-card.active .welcome-model-icon {
  filter: grayscale(0%);
}

.welcome-model-card:hover {
  transform: translateY(-3px);
  background: var(--job-card-bg-hover);
  box-shadow: 0 6px 18px rgba(10, 124, 255, 0.15);
  border-color: rgba(10, 124, 255, 0.3);
  color: var(--text-primary);
}

body.dark-theme .welcome-model-card:hover {
  background: rgba(255,255,255,0.02);
}

.welcome-model-card.active {
  background: var(--job-card-bg);
  border-color: rgba(10, 124, 255, 0.3);
  color: var(--primary);
  font-weight: 600;
}

.welcome-model-icon {
  display: flex;
  align-items: center;
  justify-content: center;
}

.welcome-model-icon img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 4px;
}



.welcome-model-name {
  font-size: 0.75rem;
  font-weight: 500;
  text-align: center;
  line-height: 1.1;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  overflow-wrap: anywhere;
}

.welcome-model-card.active .welcome-model-name {
  font-weight: 600;
}

/* Инлайн-кнопки (Формат, Длительность) внутри инпута */
.image-opt-btn {
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  font-size: 0.85rem;
  padding: 0 12px;
  height: 34px;
  box-sizing: border-box;
  border-radius: 17px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.image-opt-btn:hover {
  background: var(--bg-surface-hover);
  border-color: var(--text-muted);
}


.input-container {
  display: flex;
  align-items: center;
  padding: 14px 20px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  background: var(--bg-input);
  box-shadow: 0 2px 8px rgba(0,0,0,0.02);
}

.input-container textarea {
  width: 100%;
  background: transparent;
  border: none;
  outline: none;
  resize: none;
  color: var(--text-primary);
  font-family: var(--font-family);
  font-size: 0.95rem;
  line-height: 1.4;
  max-height: 400px;
  padding-right: 12px;
}

/* Give the composer an extra line of comfortable writing/click space. */
#message-input {
  min-height: 2.8em;
}

#message-input::placeholder {
  color: var(--text-muted);
  font-size: 0.95rem;
  line-height: 1.4;
  opacity: 1;
}

.send-btn {
  background: var(--primary);
  color: #fff;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  flex-shrink: 0;
}

.send-btn:hover:not(:disabled) {
  background: var(--primary-hover);
}

.send-btn:disabled {
  background: rgba(0, 0, 0, 0.05);
  color: var(--text-muted);
  cursor: not-allowed;
}

.stop-btn {
  background: var(--danger);
  color: #fff;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.stop-btn:hover {
  background: #dc2626;
  transform: scale(1.05);
}

/* Blockquote */
.msg-content blockquote {
  border-left: 3px solid var(--primary);
  padding: 8px 12px;
  margin: 10px 0;
  color: var(--text-secondary);
  font-style: italic;
  background: rgba(10, 124, 255, 0.03);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

body.dark-theme .msg-content blockquote {
  background: rgba(10, 124, 255, 0.06);
}

/* Tables inside chat bubbles */
.table-container {
  width: 100%;
  overflow-x: auto;
  margin: 12px 0;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  -webkit-overflow-scrolling: touch;
}

.msg-content table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
  text-align: left;
}

.msg-content th {
  background: var(--bg-sidebar);
  color: var(--text-primary);
  font-size: 0.85rem;
  font-weight: 600;
  padding: 10px 14px;
  border-bottom: 2px solid var(--border-color);
  white-space: nowrap;
  min-width: 120px;
}

body.dark-theme .msg-content th {
  background: var(--bg-sidebar);
}

.msg-content td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-primary);
  min-width: 120px;
  word-break: break-word;
}

.msg-content tr:last-child td {
  border-bottom: none;
}

/* Table Caption / Signature styling with subtle color and minimal appearance */
.table-caption {
  font-size: 0.82rem;
  font-weight: 600;
  font-style: italic;
  color: var(--text-secondary);
  padding: 4px 0;
  margin: 6px 0;
  display: block;
  box-sizing: border-box;
}

.table-caption.above {
  margin-bottom: 6px;
}

.table-caption.below {
  margin-top: 6px;
}

/* Code block wrapper and header */
.code-block-wrapper {
  margin: 12px 0;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border-color);
  background: #f9f9fb;
}

body.dark-theme .code-block-wrapper {
  background: #1e1e1e;
}

.code-block-header {
  background: rgba(0, 0, 0, 0.03);
  padding: 6px 12px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border-color);
}

body.dark-theme .code-block-header {
  background: rgba(255, 255, 255, 0.03);
}

.code-block-wrapper pre {
  margin: 0 !important;
  border: none !important;
  border-radius: 0 !important;
  background: transparent !important;
}

/* Msg Actions & Copy/Feedback Buttons */
.msg-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 10px;
  padding-top: 6px;
  border-top: 1px solid rgba(0, 0, 0, 0.03);
}

body.dark-theme .msg-actions {
  border-top: 1px solid rgba(255, 255, 255, 0.03);
}

.msg-action-btn {
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px;
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
}

.msg-action-btn i, .msg-action-btn svg {
  width: 14px;
  height: 14px;
}

@media (max-width: 768px) {
  .msg-action-btn {
    padding: 8px;
  }
  .msg-action-btn i, .msg-action-btn svg {
    width: 20px;
    height: 20px;
  }
}

.msg-action-btn:hover {
  color: var(--text-secondary);
  background: rgba(0, 0, 0, 0.04);
}

body.dark-theme .msg-action-btn:hover {
  background: rgba(255, 255, 255, 0.04);
}

.msg-action-btn.active {
  color: var(--primary);
}

.msg-action-btn.copied {
  color: var(--success);
}

/* Suggestion Pills for continuation of dialogue */
.msg-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
  padding-top: 10px;
  border-top: 1px solid rgba(0, 0, 0, 0.03);
}

body.dark-theme .msg-suggestions {
  border-top: 1px solid rgba(255, 255, 255, 0.03);
}

.suggestion-pill {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  font-family: var(--font-family);
  font-size: 0.85rem;
  font-weight: 500;
  padding: 6px 14px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
  text-align: left;
}

.suggestion-pill:hover {
  background: var(--primary-glow);
  border-color: var(--primary);
  color: var(--primary);
  transform: translateY(-1px);
}

.suggestion-pill:active {
  transform: translateY(0);
}

.input-hint {
  font-size: 0.72rem;
  color: var(--text-muted);
  text-align: center;
}

/* Pricing Modal */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(4px);
  z-index: 100;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 20px;
}

.modal-card {
  width: 100%;
  max-width: 900px;
  border-radius: var(--radius-lg);
  padding: 30px;
  background: var(--bg-panel);
  border: 1px solid var(--border-color);
  box-shadow: 0 10px 40px rgba(0,0,0,0.1);
  position: relative;
}

.modal-header h2 {
  font-size: 1.8rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.modal-header p {
  color: var(--text-secondary);
  font-size: 0.95rem;
  margin-bottom: 24px;
}

.close-modal-btn {
  position: absolute;
  top: 20px;
  right: 20px;
  background: transparent;
  color: var(--text-muted);
  font-size: 1.8rem;
  line-height: 1;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.close-modal-btn:hover {
  color: var(--text-primary);
}

.pricing-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
}

.pricing-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 24px;
  display: flex;
  flex-direction: column;
  position: relative;
  transition: border-color var(--transition-fast);
}

.pricing-card:hover {
  border-color: rgba(10, 124, 255, 0.4);
}

.pricing-card.popular {
  border-color: var(--primary);
  background: rgba(10, 124, 255, 0.01);
}

.card-badge {
  position: absolute;
  top: 16px;
  right: 16px;
  background: rgba(0, 0, 0, 0.04);
  font-size: 0.7rem;
  padding: 3px 8px;
  border-radius: var(--radius-pill);
  color: var(--text-secondary);
  font-weight: 600;
}

.popular-badge {
  background: var(--primary);
  color: #fff;
}

.discount-badge {
  background: var(--success);
  color: #fff;
}

.pricing-card h3 {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 12px;
  color: var(--text-primary);
}

.price {
  font-size: 2rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.price span {
  font-size: 0.9rem;
  color: var(--text-secondary);
  font-weight: 400;
}

.old-price {
  font-size: 1rem;
  color: var(--text-muted);
  text-decoration: line-through;
  margin-left: 6px;
  font-weight: 400;
}

.tokens-badge {
  font-size: 0.8rem;
  color: var(--primary);
  font-weight: 600;
  background: rgba(10, 124, 255, 0.08);
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  display: inline-block;
  align-self: flex-start;
  margin-bottom: 20px;
}

.features {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 24px;
  flex: 1;
}

.features li {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.features li i {
  color: var(--success);
  width: 14px;
  height: 14px;
}

.pricing-btn {
  background: #ffffff;
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  padding: 10px;
  border-radius: var(--radius-pill);
  font-weight: 600;
  font-size: 0.88rem;
  width: 100%;
}

.pricing-btn:hover {
  background: rgba(0, 0, 0, 0.02);
  border-color: rgba(0, 0, 0, 0.15);
}

.popular .pricing-btn {
  background: var(--primary);
  color: #fff;
  border: none;
}

.popular .pricing-btn:hover {
  background: var(--primary-hover);
}

/* Animations */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Sidebar and Header Mobile Base Styles */
.sidebar-brand-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
}

.close-sidebar-btn {
  display: none !important;
}

.sidebar-menu-items {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 20px;
}

.sidebar-menu-items .icon-btn-text {
  padding: 10px 14px;
  margin: 3px 0;
  transition: background var(--transition-fast), color var(--transition-fast);
}

.sidebar-menu-items .icon-btn-text.active:not(#chat-history-accordion-btn) {
  background: rgba(10, 124, 255, 0.08);
  color: var(--primary);
}

#chat-history-accordion-btn.active #chat-history-chevron {
  transform: rotate(180deg);
}

.sidebar-menu-items .icon-btn-text.active:not(#chat-history-accordion-btn):hover {
  background: rgba(10, 124, 255, 0.12);
}

body.dark-theme .sidebar-menu-items .icon-btn-text.active:not(#chat-history-accordion-btn) {
  background: rgba(10, 124, 255, 0.15);
  color: #3b9cff;
}

body.dark-theme .sidebar-menu-items .icon-btn-text.active:not(#chat-history-accordion-btn):hover {
  background: rgba(10, 124, 255, 0.2);
}

.sidebar-section-title {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 12px 24px 4px 24px;
  letter-spacing: 0.5px;
}

.sidebar-tariff-btn {
  display: none !important;
}

.sidebar-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(13, 13, 13, 0.4);
  backdrop-filter: blur(2px);
  z-index: 999;
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--transition-normal), visibility var(--transition-normal);
}

.sidebar-backdrop.active {
  opacity: 1;
  visibility: visible;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  min-width: 0;
}

.mobile-menu-toggle {
  display: none !important;
}

/* Profile Dropdown Menu & Theme Switcher Styles */
.profile-container {
  position: relative;
  width: auto;
  margin: 0 -16px -16px -16px;
  padding: 16px 20px;
  cursor: pointer;
  transition: background var(--transition-fast);
}

.profile-container:hover {
  background: rgba(0, 0, 0, 0.03);
}

body.dark-theme .profile-container:hover {
  background: rgba(255, 255, 255, 0.05);
}

.profile-dropdown {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 4px;
  right: 4px;
  background: var(--bg-panel);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.08);
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  z-index: 110;
  animation: fadeInFast 0.15s ease-out;
}

@keyframes fadeInFast {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-primary);
  width: 100%;
  text-align: left;
  transition: background var(--transition-fast);
  background: transparent;
  border: none;
  cursor: pointer;
}

.dropdown-item:hover {
  background: rgba(0, 0, 0, 0.04);
}

body.dark-theme .dropdown-item:hover {
  background: rgba(255, 255, 255, 0.04);
}

.dropdown-item i {
  color: var(--text-secondary);
  flex-shrink: 0;
}

.dropdown-item.text-danger {
  color: var(--danger) !important;
}

.dropdown-item.text-danger i {
  color: var(--danger) !important;
}

.dropdown-divider {
  height: 1px;
  background: var(--border-color);
  margin: 6px 4px;
}

/* Theme Switcher Pill Container */
.theme-switcher {
  display: flex;
  background: var(--bg-sidebar);
  border-radius: var(--radius-pill);
  padding: 4px;
  margin: 4px 6px;
  justify-content: space-between;
  border: 1px solid var(--border-color);
}

.theme-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
  border-radius: var(--radius-pill);
  color: var(--text-secondary);
  transition: all var(--transition-fast);
  background: transparent;
  border: none;
  cursor: pointer;
}

.theme-btn:hover {
  color: var(--text-primary);
}

.theme-btn.active {
  background: var(--bg-panel);
  color: var(--text-primary);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

/* Profile Screen Styles */
.profile-scroll-container {
  flex: 1;
  overflow-y: auto;
  background: var(--bg-main);
  padding: 24px;
}

.profile-content-wrapper {
  max-width: 800px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.profile-cards-grid {
  display: grid;
  /* minmax(0, …): a sideways-scrolling row inside a card must not widen the column. */
  grid-template-columns: minmax(0, 1fr);
  gap: 16px;
}

@media (max-width: 768px) {
  .profile-cards-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

.profile-card {
  background: var(--bg-panel);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  padding: 28px;
  display: flex;
  flex-direction: column;
  box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.02);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

body.dark-theme .profile-card {
  box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.2);
}

.user-card {
  position: relative;
  overflow: hidden;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  background: linear-gradient(135deg, rgba(10, 124, 255, 0.07) 0%, rgba(91, 75, 255, 0.05) 100%);
  border: 1px solid rgba(10, 124, 255, 0.15);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  padding: 32px 28px;
}

body.dark-theme .user-card {
  background: linear-gradient(135deg, rgba(10, 124, 255, 0.12) 0%, rgba(91, 75, 255, 0.08) 100%);
  border-color: rgba(10, 124, 255, 0.25);
}

.user-avatar-row {
  display: flex;
  align-items: center;
  gap: 16px;
  position: relative;
  z-index: 1;
}

.profile-avatar-wrapper {
  width: 56px;
  height: 56px;
  background: rgba(10, 124, 255, 0.1);
  border: 1px solid rgba(10, 124, 255, 0.2);
  border-radius: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  flex-shrink: 0;
  color: var(--primary);
}

body.dark-theme .profile-avatar-wrapper {
  background: rgba(10, 124, 255, 0.18);
  border-color: rgba(10, 124, 255, 0.3);
}

.user-meta h2 {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
}

.user-meta p {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-top: 4px;
}

.profile-logout-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: rgba(239, 68, 68, 0.08);
  border: 1px solid rgba(239, 68, 68, 0.15);
  border-radius: var(--radius-pill);
  padding: 10px 20px;
  font-size: 0.88rem;
  font-weight: 600;
  color: #ef4444;
  cursor: pointer;
  transition: all var(--transition-fast);
  position: relative;
  z-index: 1;
}

.profile-logout-btn:hover {
  background: rgba(239, 68, 68, 0.15);
  border-color: rgba(239, 68, 68, 0.25);
}

.card-title {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
}

.profile-marketing-consent {
  padding: 14px 16px;
  border: 1px solid var(--border-color);
  border-radius: 12px;
  background: rgba(10, 124, 255, 0.035);
  font-size: 0.8rem;
  line-height: 1.5;
}

.profile-marketing-consent h4 {
  margin: 0 0 4px;
  color: var(--text-primary);
  font-size: 0.85rem;
  font-weight: 600;
}

.profile-marketing-consent p { margin: 0; }
.profile-marketing-consent a { color: var(--primary); text-underline-offset: 2px; }
.profile-marketing-choice { display: flex; align-items: flex-start; gap: 8px; margin-top: 12px; cursor: pointer; }
.profile-marketing-choice input { flex: 0 0 15px; width: 15px; height: 15px; margin: 3px 0 0; accent-color: var(--primary); cursor: pointer; }
.profile-marketing-actions { display: flex; align-items: center; gap: 12px; margin-top: 12px; }
.profile-marketing-actions span { color: var(--text-muted); font-size: 0.75rem; }
.profile-marketing-actions button {
  padding: 7px 14px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  background: var(--primary);
  color: #fff;
  font: inherit;
  font-weight: 500;
  cursor: pointer;
}
.profile-marketing-actions button:disabled { opacity: 0.45; cursor: default; }
#profile-marketing-error { margin-top: 8px; color: var(--danger); }

.profile-card-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}

.profile-card-icon-wrapper {
  width: 36px;
  height: 36px;
  background: rgba(10, 124, 255, 0.08);
  border: 1px solid rgba(10, 124, 255, 0.15);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--primary);
  flex-shrink: 0;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

body.dark-theme .profile-card-icon-wrapper {
  background: rgba(10, 124, 255, 0.15);
  border-color: rgba(10, 124, 255, 0.25);
  color: #3b9cff;
}

.tariff-info-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
}

.tariff-badge-container {
  display: flex;
  align-items: center;
  gap: 20px;
}

.tariff-name {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-primary);
}

.profile-tokens-count {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(10, 124, 255, 0.08);
  color: var(--primary);
  padding: 6px 16px;
  border-radius: var(--radius-pill);
  font-weight: 700;
  font-size: 0.95rem;
}

.profile-tokens-count.inactive-badge {
  font-size: 0.8rem;
  padding: 4px 12px;
  font-weight: 500;
  background: rgba(10, 124, 255, 0.06);
}

.profile-tokens-count.inactive-badge span:first-child {
  font-size: 0.9rem !important;
}

.continue-activation-btn {
  background: var(--primary);
  color: #fff;
  font-weight: 600;
  padding: 10px 20px;
  border-radius: var(--radius-pill);
  transition: background var(--transition-fast);
}

.continue-activation-btn:hover {
  background: var(--primary-hover);
}

.promocode-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
}

.promocode-text {
  font-size: 0.9rem;
  color: var(--text-secondary);
  max-width: 400px;
}

.promocode-input-group {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.promocode-input-group input {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  padding: 10px 16px;
  border-radius: var(--radius-pill);
  outline: none;
  font-size: 0.9rem;
  width: 240px;
  color: var(--text-primary);
}

.promocode-input-group input:focus {
  border-color: var(--primary);
}

.promocode-input-group button {
  background: var(--text-primary);
  color: var(--bg-panel);
  padding: 10px 20px;
  border-radius: var(--radius-pill);
  font-weight: 600;
  font-size: 0.9rem;
}

.promocode-input-group button:hover {
  opacity: 0.9;
}

#copy-referral-btn {
  background: var(--primary);
  color: #fff;
}

#copy-referral-btn:hover {
  background: var(--primary-hover);
  opacity: 1;
}

#referral-modal-copy-btn:hover {
  background: var(--primary-hover) !important;
}

.signin-methods-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.social-icon {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--border-color);
  object-fit: cover;
}

/* Toggle Switch */
.switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
}
.switch input { 
  opacity: 0;
  width: 0;
  height: 0;
}
.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #ccc;
  -webkit-transition: .4s;
  transition: .4s;
}
.slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  -webkit-transition: .4s;
  transition: .4s;
  border-radius: 50%;
}
input:checked + .slider {
  background-color: var(--primary);
}
input:checked + .slider:before {
  -webkit-transform: translateX(20px);
  -ms-transform: translateX(20px);
  transform: translateX(20px);
}
.slider.round {
  border-radius: 24px;
}

.social-icon {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  font-weight: 700;
  font-size: 1.1rem;
  cursor: not-allowed;
  background: rgba(0, 0, 0, 0.02);
}

body.dark-theme .social-icon {
  background: rgba(255, 255, 255, 0.02);
}

.email-method {
  display: flex;
  align-items: center;
  gap: 12px;
  border: 1px solid var(--border-color);
  padding: 8px 16px;
  border-radius: var(--radius-pill);
  background: var(--bg-card);
}

.email-method i {
  color: var(--text-secondary);
  width: 18px;
  height: 18px;
}

.email-method-details span {
  font-size: 0.75rem;
  color: var(--text-secondary);
  display: block;
}

.email-method-details p {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-primary);
}

.tabs-row {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 8px;
}

.tab-btn {
  padding: 8px 16px;
  font-size: 0.85rem;
  font-weight: 500;
  border-radius: var(--radius-pill);
  color: var(--text-secondary);
  transition: all var(--transition-fast);
  background: transparent;
  border: none;
  cursor: pointer;
}

.tab-btn.active {
  background: var(--bg-sidebar);
  color: var(--text-primary);
  font-weight: 600;
}

.transactions-list-container {
  display: flex;
  flex-direction: column;
}

.transactions-table-header {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  padding: 8px 12px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-color);
}

.transactions-list {
  display: flex;
  flex-direction: column;
}

.transaction-row-item {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  padding: 12px;
  font-size: 0.88rem;
  border-bottom: 1px solid rgba(0,0,0,0.03);
  align-items: center;
}

body.dark-theme .transaction-row-item {
  border-bottom: 1px solid rgba(255,255,255,0.03);
}

.transaction-desc {
  font-weight: 500;
  color: var(--text-primary);
}

.transaction-tokens {
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 4px;
}

.transaction-tokens.spend {
  color: var(--text-primary);
}

.transaction-tokens.refill {
  color: var(--success);
}

.transaction-date {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

/* Profile screen header action row and button styles */
.profile-top-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}

.back-to-chat-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-panel);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-pill);
  padding: 8px 18px;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.back-to-chat-btn:hover {
  background: var(--border-color);
}

.upgrade-tariff-btn {
  padding: 12px 28px;
  font-size: 0.95rem;
  font-weight: 600;
  border-radius: var(--radius-pill);
  border: none;
  cursor: pointer;
  transition: background var(--transition-fast);
}

.pale-primary-btn {
  background: rgba(10, 124, 255, 0.08);
  color: var(--primary);
}

.pale-primary-btn:hover {
  background: rgba(10, 124, 255, 0.12);
}

body.dark-theme .pale-primary-btn {
  background: rgba(10, 124, 255, 0.15);
}

body.dark-theme .pale-primary-btn:hover {
  background: rgba(10, 124, 255, 0.25);
}

#apply-promocode-btn {
  background: rgba(13, 13, 13, 0.06);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  font-weight: 500;
  transition: background var(--transition-fast), border-color var(--transition-fast);
}

body.dark-theme #apply-promocode-btn {
  background: rgba(255, 255, 255, 0.08);
}

#apply-promocode-btn:hover {
  background: rgba(13, 13, 13, 0.12);
  border-color: rgba(13, 13, 13, 0.18);
}

body.dark-theme #apply-promocode-btn:hover {
  background: rgba(255, 255, 255, 0.15);
  border-color: rgba(255, 255, 255, 0.18);
}

/* Model Selector */
.model-selector-container {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-panel);
  border: 1px solid var(--border-color);
  padding: 4px 8px;
  border-radius: var(--radius-pill);
}

.model-select {
  background: transparent;
  border: none;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  outline: none;
  cursor: pointer;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
}

/* Image Options */
.image-options {
  display: flex;
  gap: 8px;
}

/* Duplicate image-opt-btn removed to prevent overriding height: 34px defined earlier */

/* Custom Dropdown for Models */
.custom-dropdown {
  position: relative;
  display: inline-flex;
  max-width: 100%;
  min-width: 0;
}

.dropdown-trigger {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-panel);
  border: 1px solid var(--border-color);
  padding: 6px 14px;
  border-radius: var(--radius-pill);
  cursor: pointer;
  font-weight: 600;
  color: var(--text-primary);
  font-size: 0.95rem;
  transition: background var(--transition-fast);
  max-width: 100%;
  min-width: 0;
}

#selected-model-name, #sig-selected-model-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 180px;
  min-width: 0;
}

@media (max-width: 768px) {
  .dropdown-trigger {
    max-width: calc(50vw - 36px);
  }
  #selected-model-name, #sig-selected-model-name {
    max-width: none;
    flex: 0 1 auto;
    min-width: 0;
  }
}

.dropdown-trigger:hover {
  background: rgba(0, 0, 0, 0.02);
}

/* Compact model selector in the new-chat composer. The header dropdown has
   its own layout and remains the global model/job navigator. */
.composer-model-dropdown {
  flex-shrink: 0;
}

.composer-model-trigger {
  height: 34px;
  padding: 6px 10px;
  gap: 5px;
  font-size: 0.8rem;
  font-weight: 500;
  max-width: 180px;
  background: transparent;
}

.composer-model-trigger .dropdown-chevron {
  width: 12px;
  height: 12px;
}

#composer-selected-model-name {
  max-width: 110px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#composer-model-dropdown-menu {
  bottom: calc(100% + 8px);
  top: auto;
  width: 300px;
  max-height: min(70vh, 440px);
}

.composer-model-menu-title {
  padding: 8px 12px 12px;
  color: var(--text-secondary);
  font-size: 0.95rem;
  font-weight: 600;
}

.composer-model-divider {
  height: 1px;
  margin: 4px -6px 12px;
  background: var(--border-color);
}

.composer-model-section-title {
  padding: 0 12px;
  color: var(--text-primary);
  font-size: 0.95rem;
  font-weight: 700;
}

.composer-model-section-subtitle {
  padding: 3px 12px 8px;
  color: var(--text-muted);
  font-size: 0.82rem;
}

.dropdown-menu .composer-model-option {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr);
  align-items: center;
  column-gap: 10px;
  min-height: 54px;
  padding: 9px 12px;
}

.dropdown-menu .composer-model-option.active {
  grid-template-columns: 20px minmax(0, 1fr) 18px;
}

.composer-model-option-body {
  min-width: 0;
}

.composer-option-icon {
  width: 18px !important;
  height: 18px !important;
  min-width: 18px;
  min-height: 18px;
  display: block;
  flex-shrink: 0;
  color: var(--text-secondary);
}

.composer-option-icon svg {
  width: 18px !important;
  height: 18px !important;
  min-width: 18px;
  min-height: 18px;
  display: block;
}

.composer-model-option .option-header {
  min-width: 0;
}

.composer-model-option .option-name {
  font-size: 0.9rem;
  font-weight: 400;
  line-height: 1.25;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.composer-model-option .option-desc {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.composer-option-check {
  width: 18px;
  height: 18px;
  color: var(--text-primary);
}

.dropdown-menu .composer-auto-option {
  min-height: 66px;
  padding-top: 12px;
  padding-bottom: 12px;
}

.composer-auto-option .composer-option-icon {
  width: 18px !important;
  height: 18px !important;
}

.composer-auto-option .option-name {
  font-size: 0.9rem;
  font-weight: 400;
  line-height: 1.25;
}

body.dark-theme .dropdown-trigger:hover {
  background: rgba(255, 255, 255, 0.02);
}

.dropdown-chevron {
  width: 14px;
  height: 14px;
  color: var(--text-muted);
  transition: transform var(--transition-normal);
}

.custom-dropdown.active .dropdown-chevron {
  transform: rotate(180deg);
}

.dropdown-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  width: 320px;
  background: var(--bg-panel);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  z-index: 200;
  animation: fadeInFast 0.12s ease-out;
  max-height: 75vh;
  overflow-y: auto;
  overflow-x: hidden;
}

.dropdown-option {
  display: flex;
  flex-direction: column;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition-fast);
}

.dropdown-option:hover {
  background: rgba(0, 0, 0, 0.03);
}

body.dark-theme .dropdown-option:hover {
  background: rgba(255, 255, 255, 0.03);
}

.dropdown-option.active {
  background: rgba(10, 124, 255, 0.06);
}

.dropdown-all-models-btn {
  position: sticky;
  bottom: -6px;
  left: -6px;
  right: -6px;
  width: calc(100% + 12px);
  background-color: var(--bg-panel);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  border-top: 1px solid var(--border-color);
  font-weight: 500;
  color: var(--primary);
  z-index: 10;
  border-bottom-left-radius: var(--radius-md);
  border-bottom-right-radius: var(--radius-md);
  margin-top: 6px;
  transition: background-color var(--transition-fast);
}

.dropdown-all-models-btn:hover {
  background-color: var(--bg-card);
}

.option-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 2px;
}

.option-name {
  font-weight: 600;
  color: var(--text-primary);
  font-size: 0.95rem;
}

.option-cost {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--primary);
  background: rgba(10, 124, 255, 0.06);
  border: 1px solid rgba(10, 124, 255, 0.15);
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  flex-shrink: 0;
  white-space: nowrap;
}

body.dark-theme .option-cost {
  background: rgba(59, 156, 255, 0.12);
  color: #3b9cff;
  border-color: rgba(59, 156, 255, 0.22);
}

.option-desc {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* Aspect Ratio / Format & Resolution dropdown styling */
.format-dropdown-container {
  position: relative;
  display: inline-block;
}

.format-popup {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 0;
  z-index: 1000;
  width: 220px;
  background: var(--bg-panel);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 200;
  animation: fadeInFast 0.12s ease-out;
}

.format-popup-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border-color);
}

.format-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 8px;
  font-size: 0.9rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.format-option:hover {
  background: rgba(0, 0, 0, 0.03);
}

body.dark-theme .format-option:hover {
  background: rgba(255, 255, 255, 0.03);
}

.format-option.active {
  background: rgba(10, 124, 255, 0.08);
  font-weight: 600;
  color: var(--primary);
}

.format-preview-box {
  display: inline-block;
  border: 1.5px solid var(--text-secondary);
  border-radius: 2px;
  flex-shrink: 0;
}

.format-1-1 { width: 12px; height: 12px; }
.format-2-3 { width: 9px; height: 14px; }
.format-3-2 { width: 14px; height: 9px; }
.format-3-4 { width: 10px; height: 14px; }
.format-4-3 { width: 14px; height: 10px; }
.format-4-5 { width: 11px; height: 14px; }
.format-5-4 { width: 14px; height: 11px; }

.radio-circle {
  width: 18px;
  height: 18px;
  border: 2px solid var(--border-color);
  border-radius: 50%;
  margin-left: auto;
  position: relative;
  transition: all var(--transition-fast);
}

.format-option.active .radio-circle {
  border-color: var(--primary);
  background: var(--primary);
}

.format-option.active .radio-circle::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 6px;
  height: 6px;
  background: white;
  border-radius: 50%;
}

/* Welcome Model Title styling */
.welcome-model-title {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  font-size: 2.2rem;
  font-weight: 800;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.welcome-screen h1, .welcome-screen .welcome-title {
  display: flex;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
}

/* Responsive Mobile Layout (Under 768px) */
@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 290px;
    height: 100%;
    transform: translateX(-100%);
    transition: transform var(--transition-normal);
    z-index: 1005;
    background: var(--bg-sidebar);
    box-shadow: 4px 0 24px rgba(13, 13, 13, 0.15);
    border-right: 1px solid var(--border-color);
  }

  #chat-list-wrapper, .chat-list {
    min-height: auto !important;
    height: auto !important;
    overflow: visible !important;
    flex: none !important;
  }

  .sidebar.active {
    transform: translateX(0);
  }

  .close-sidebar-btn {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 8px;
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: background var(--transition-fast);
  }

  .close-sidebar-btn:hover {
    background: rgba(0, 0, 0, 0.04);
    color: var(--text-primary);
  }

  .mobile-menu-toggle {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    color: var(--text-primary);
    padding: 8px;
    cursor: pointer;
    border-radius: var(--radius-sm);
  }

  .choose-tariff-btn {
    display: none !important;
  }

  .sidebar-tariff-btn {
    display: block !important;
    background: var(--primary);
    color: #fff;
    border-radius: var(--radius-pill);
    padding: 10px 16px;
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 12px;
    width: 100%;
    text-align: center;
  }

  .sidebar-tariff-btn:hover {
    background: var(--primary-hover);
  }

  #model-dropdown {
    position: static;
  }

  #model-dropdown-menu {
    left: 16px;
    right: 16px;
    width: auto;
    max-width: none;
    max-height: 70vh;
    overflow-y: auto;
    overflow-x: hidden;
  }

  /* Chat area occupies full space on mobile */
  .chat-area {
    width: 100%;
    height: 100%;
    max-width: 100%;
  }

  .chat-header {
    padding: 10px 16px;
    height: 56px;
  }

  .chat-history {
    padding: 16px;
  }

  .message-bubble {
    max-width: 100%;
  }

  .chat-input-area {
    padding: 12px 16px 16px 16px;
  }

  .chat-composer-notice {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    align-items: start;
    gap: 8px 10px;
    min-height: 0;
    padding: 12px;
  }
  .chat-composer-notice__icon { width: 34px; height: 34px; flex-basis: 34px; border-radius: 11px; }
  .chat-composer-notice__copy { grid-column: 1; padding-right: 28px; }
  .chat-composer-notice__actions { grid-column: 1; justify-content: flex-start; gap: 4px; margin-right: 0; }
  .chat-composer-notice__primary { padding: 9px 13px; }

  .input-container {
    padding: 10px 14px;
    border-radius: var(--radius-md);
  }

  /* Pricing Modal Grid */
  .modal-card {
    padding: 24px 16px;
    max-height: 90vh;
    overflow-y: auto;
    border-radius: var(--radius-md);
  }

  .pricing-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  /* Auth Screens on mobile */
  .auth-card {
    padding: 24px 20px;
    margin: 16px;
    max-width: 100%;
  }

  /* Profile screen mobile adaptation */
  .profile-scroll-container {
    padding: 16px;
  }

  .user-card {
    flex-direction: column;
    align-items: flex-start;
    gap: 16px;
  }

  .profile-logout-btn {
    width: 100%;
    justify-content: flex-start;
  }

  .tariff-info-row,
  .promocode-row,
  .signin-methods-row {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }

  .promocode-input-group {
    flex-direction: column;
  }

  .promocode-input-group input {
    width: 100%;
  }

  .promocode-input-group button {
    width: 100%;
  }

  .continue-activation-btn {
    width: 100%;
  }

  .email-method {
    width: 100%;
    justify-content: flex-start;
  }

  /* Transaction table responsiveness */
  .transactions-table-header, .transaction-row-item {
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    padding: 10px;
  }

  .transactions-table-header span:nth-child(3),
  .transaction-row-item span:nth-child(3) {
    grid-column: span 2;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 2px;
  }
}

/* Visual Image Job Cards */
.welcome-jobs-grid.image-grid {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  max-width: 900px;
}

.job-card.image-card {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  padding: 0;
  overflow: hidden;
  border-radius: var(--radius-lg);
  background: var(--job-card-bg);
  border: 1px solid var(--job-card-border);
  transition: all var(--transition-normal);
  height: 100%;
}

.job-card.image-card:hover {
  transform: translateY(-4px);
  border-color: var(--primary-glow);
  box-shadow: 0 8px 24px rgba(10, 124, 255, 0.12);
}

.job-card-img-wrapper {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 10;
  overflow: hidden;
  border-bottom: 1px solid var(--border-color);
}

.job-card-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform var(--transition-normal) ease;
}

.job-card.image-card:hover .job-card-img {
  transform: scale(1.04);
}

.job-card-info-box {
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.job-card-info-box h4 {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.job-card-info-box p {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin: 0;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: normal;
  height: 2.6em;
}

/* Image Generation Skeleton */
.image-skeleton-container {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  max-width: 400px;
}

.image-skeleton-preview {
  width: 100%;
  border-radius: var(--radius-md);
  background: linear-gradient(90deg, var(--bg-sidebar) 25%, var(--border-color) 50%, var(--bg-sidebar) 75%);
  background-size: 200% 100%;
  animation: loading-shimmer 1.5s infinite linear;
  border: 1px solid var(--border-color);
}

.image-skeleton-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.spinner-icon {
  animation: spin 1s linear infinite;
  color: var(--primary);
}

@keyframes loading-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

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

/* Onboarding Gallery Tabs */
.gallery-tabs-row {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  margin: 16px 0 24px 0;
  flex-wrap: wrap;
  width: 100%;
}

.gallery-tab-btn {
  background: var(--bg-sidebar);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  padding: 8px 16px;
  border-radius: var(--radius-pill);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.gallery-tab-btn:hover {
  background: var(--bg-panel);
  color: var(--text-primary);
  border-color: rgba(10, 124, 255, 0.2);
}

.gallery-tab-btn.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  box-shadow: 0 4px 12px var(--primary-glow);
}

/* Pinterest-style Gallery Grid (3 columns count) */
.ideas-gallery-grid {
  display: block !important;
  column-count: 3;
  column-gap: 16px;
  width: 100%;
  max-width: 900px;
  margin-top: 10px;
  padding: 0 16px;
  box-sizing: border-box;
}

.gallery-image-card {
  position: relative;
  overflow: hidden;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  cursor: pointer;
  background: var(--bg-sidebar);
  transition: transform var(--transition-normal) ease, box-shadow var(--transition-normal) ease, border-color var(--transition-normal) ease;
  width: 100%;
  break-inside: avoid;
  margin-bottom: 16px;
  display: block;
}

.gallery-image-card img {
  width: 100%;
  height: auto;
  display: block;
  transition: transform var(--transition-normal) ease;
}

.gallery-image-card:hover {
  transform: translateY(-4px);
  border-color: var(--primary-glow);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
}

.gallery-image-card:hover img {
  transform: scale(1.03);
}

/* Hover Button Overlay */
.gallery-card-hover-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(13, 13, 13, 0.5);
  opacity: 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 16px;
  box-sizing: border-box;
  transition: opacity var(--transition-normal) ease;
  border-radius: var(--radius-lg);
}

.gallery-image-card:hover .gallery-card-hover-overlay {
  opacity: 1;
}

.gallery-card-hover-btn {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) translateY(8px);
  background: var(--primary);
  color: #fff;
  padding: 8px 20px;
  border-radius: var(--radius-pill);
  font-weight: 600;
  font-size: 0.85rem;
  border: none;
  cursor: pointer;
  transition: transform var(--transition-normal) cubic-bezier(0.16, 1, 0.3, 1), background var(--transition-fast) ease;
  box-shadow: 0 4px 12px var(--primary-glow);
  z-index: 2;
}

.gallery-card-hover-btn:hover {
  background: var(--primary-hover);
}

.gallery-image-card:hover .gallery-card-hover-btn {
  transform: translate(-50%, -50%) translateY(0);
}

.gallery-card-hover-info {
  width: 100%;
  max-width: 100%;
  text-align: left;
  transform: translateY(12px);
  transition: transform var(--transition-normal) cubic-bezier(0.16, 1, 0.3, 1);
  color: #ffffff;
  box-sizing: border-box;
  overflow: hidden;
}

.gallery-image-card:hover .gallery-card-hover-info {
  transform: translateY(0);
}

.gallery-card-hover-info h4 {
  margin: 0 0 2px 0;
  font-size: 0.9rem;
  font-weight: 600;
  color: #ffffff;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.gallery-card-hover-info p {
  margin: 0;
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.8);
  line-height: 1.2;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Detail Style Inspector Modal (Larger & More Premium) */
.style-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(10, 10, 11, 0.82);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  box-sizing: border-box;
  animation: fadeIn var(--transition-fast) ease-out;
}

.style-modal-content {
  width: 100%;
  max-width: 980px;
  background: var(--bg-panel);
  background-clip: padding-box;
  border-radius: 20px;
  border: none;
  overflow: hidden;
  display: flex;
  max-height: calc(100vh - 60px);
  animation: scaleIn 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 30px 70px rgba(0, 0, 0, 0.45);
}

body.dark-theme .style-modal-content {
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.style-modal-left {
  flex: 1.3;
  min-width: 0;
  background: #0a0a0b;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.style-modal-left img {
  max-width: 100%;
  max-height: 580px;
  object-fit: contain;
  display: block;
}

.style-modal-right {
  width: 390px;
  flex-shrink: 0;
  border-left: 1px solid var(--border-color);
  padding: 32px;
  background: var(--bg-panel);
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  gap: 24px;
  overflow-y: auto;
  max-height: 580px;
}

/* Custom Scrollbar for Modal Sidebar */
.style-modal-right::-webkit-scrollbar {
  width: 6px;
}
.style-modal-right::-webkit-scrollbar-track {
  background: transparent;
}
.style-modal-right::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 3px;
}
.style-modal-right::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

.style-modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.8) !important;
  border: none;
  padding: 0;
  color: #000 !important;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  transition: all var(--transition-fast);
  z-index: 20;
}

.style-modal-close svg {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  margin: 0 !important;
}

.style-modal-close:hover {
  transform: scale(1.05);
  background: rgba(255, 255, 255, 1) !important;
}

.modal-header-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
  color: var(--primary);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.modal-title-block h3 {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0 0 6px 0;
  letter-spacing: -0.3px;
}

.modal-title-block p {
  font-size: 0.88rem;
  color: var(--text-secondary);
  margin: 0;
  line-height: 1.45;
}

.modal-prompt-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.modal-prompt-title-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-prompt-title-row span {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-primary);
}

.copy-prompt-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--primary);
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  transition: background var(--transition-fast);
}

.copy-prompt-btn:hover {
  background: rgba(10, 124, 255, 0.05);
}

.prompt-box {
  background: var(--bg-sidebar);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px;
  font-size: 0.9rem;
  color: var(--text-primary);
  line-height: 1.5;
  word-break: break-word;
  max-height: 160px;
  overflow-y: auto;
}

/* Custom Scrollbar for Prompt Box */
.prompt-box::-webkit-scrollbar {
  width: 4px;
}
.prompt-box::-webkit-scrollbar-track {
  background: transparent;
}
.prompt-box::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 2px;
}

.chips-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.style-chip {
  background: rgba(10, 124, 255, 0.06);
  color: var(--primary);
  font-size: 0.8rem;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: var(--radius-pill);
  border: 1px solid rgba(10, 124, 255, 0.12);
}

.modal-primary-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--primary);
  color: #fff;
  font-weight: 600;
  font-size: 0.95rem;
  padding: 14px;
  border: none;
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: background var(--transition-fast);
  box-shadow: 0 4px 14px var(--primary-glow);
}

.modal-primary-btn:hover {
  background: var(--primary-hover);
}

.modal-sub-actions {
  display: flex;
  gap: 10px;
  width: 100%;
}

.modal-secondary-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--bg-panel);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  font-weight: 600;
  font-size: 0.85rem;
  padding: 12px;
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.modal-secondary-btn:hover {
  background: var(--bg-sidebar);
  border-color: var(--text-muted);
}

@keyframes scaleIn {
  from {
    opacity: 0;
    transform: scale(0.96);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* Responsiveness for Style Modal */
@media (max-width: 768px) {
  .style-modal-overlay {
    align-items: flex-start;
    overflow-y: auto;
    padding: 24px 16px;
  }

  .style-modal-content {
    flex-direction: column;
    max-height: none;
    margin: auto;
  }
  
  .style-modal-left {
    flex: none;
    height: 280px;
  }
  
  .style-modal-left img {
    height: 100%;
    object-fit: cover;
  }
  
  .style-modal-right {
    width: 100%;
    border-left: none;
    border-top: 1px solid var(--border-color);
    max-height: none;
    overflow-y: visible;
    padding: 20px;
    gap: 20px;
  }
  
  .ideas-gallery-grid {
    column-count: 2;
    column-gap: 12px;
  }
  
  .gallery-image-card {
    margin-bottom: 12px;
  }
}

@media (max-width: 480px) {
  .ideas-gallery-grid {
    column-count: 1;
  }
  .ideas-gallery-grid.vertical-cards {
    column-count: 2;
  }
}

/* Files Screen Styles */
.files-scroll-container {
  flex: 1;
  overflow-y: auto;
  background: var(--bg-main);
  padding: 24px;
  height: 100%;
}
.files-content-wrapper {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.files-top-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.files-header-title h2 {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
}
.files-header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  min-width: 0;
  justify-content: flex-end;
  margin-left: 16px;
}
.search-input-wrapper {
  position: relative;
  width: 100%;
  max-width: 250px;
}
@media (max-width: 600px) {
  .search-input-wrapper {
    max-width: 100%;
  }
}
.search-input-wrapper input {
  width: 100%;
  padding: 8px 12px 8px 34px;
  border-radius: 99px;
  border: 1px solid var(--border-color);
  background: var(--bg-panel);
  color: var(--text-primary);
  outline: none;
  font-size: 0.85rem;
  transition: border-color var(--transition-fast);
  -webkit-appearance: none;
  appearance: none;
}
.search-input-wrapper input:focus {
  border-color: var(--primary);
}
.search-input-wrapper i,
.search-input-wrapper svg {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 14px;
  height: 14px;
  color: var(--text-muted);
  pointer-events: none;
}

@media (max-width: 768px) {
  .search-input-wrapper input {
    font-size: 16px !important;
    padding-left: 36px !important;
  }
}
.files-view-toggle {
  display: flex;
  background: var(--bg-panel);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 3px;
}
.files-view-toggle .view-btn {
  border: none;
  background: transparent;
  padding: 6px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}
.files-view-toggle .view-btn.active {
  background: var(--bg-sidebar);
  color: var(--text-primary);
  box-shadow: 0 1px 4px rgba(0,0,0,0.05);
}

/* Tabs Bar */
.files-tabs-row {
  display: flex;
  gap: 8px;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 12px;
  overflow-x: auto;
}
.files-tab-btn {
  padding: 8px 18px;
  font-size: 0.9rem;
  font-weight: 500;
  border-radius: var(--radius-pill);
  color: var(--text-secondary);
  background: transparent;
  border: none;
  cursor: pointer;
  white-space: nowrap;
  transition: all var(--transition-fast);
}
.files-tab-btn:hover {
  color: var(--text-primary);
  background: rgba(0,0,0,0.02);
}
body.dark-theme .files-tab-btn:hover {
  background: rgba(255,255,255,0.02);
}
.files-tab-btn.active {
  background: rgba(10, 124, 255, 0.08);
  color: var(--primary);
  font-weight: 600;
}

/* Empty state */
.files-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 80px 20px;
  text-align: center;
  gap: 16px;
}
.files-empty-icon {
  font-size: 4rem;
  color: #f59e0b;
  animation: bounce 2s infinite;
}
.files-empty-state h3 {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-primary);
}
.files-empty-state p {
  font-size: 0.9rem;
  color: var(--text-secondary);
  max-width: 400px;
}

/* Group & Month sections */
.files-month-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 24px;
}
.files-month-title {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: capitalize;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border-color);
}

/* Cards Grid */
.files-grid-container {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
}
.file-card {
  background: var(--bg-panel);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  overflow: hidden;
  position: relative;
  display: flex;
  flex-direction: column;
  transition: transform var(--transition-fast), border-color var(--transition-fast), box-shadow var(--transition-fast);
  cursor: pointer;
}
.file-card:hover {
  transform: translateY(-2px);
  border-color: rgba(10, 124, 255, 0.4);
  box-shadow: 0 4px 12px rgba(0,0,0,0.04);
}
.file-card-preview {
  height: 180px;
  background: rgba(0,0,0,0.02);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}
.file-card-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease;
}
.file-card:hover .file-card-preview img {
  transform: scale(1.03);
}
.file-card-icon-fallback {
  width: 48px;
  height: 48px;
  color: var(--text-muted);
}
.file-card-info {
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  border-top: 1px solid var(--border-color);
}
.file-card-name-row {
  display: flex;
  align-items: center;
  gap: 6px;
}
.file-card-type-icon {
  width: 14px;
  height: 14px;
  color: var(--text-muted);
  flex-shrink: 0;
}
.file-card-name {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.file-card-date {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* List Table View */
.files-list-container {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  background: var(--bg-panel);
  overflow: hidden;
}
.files-list-header {
  display: grid;
  grid-template-columns: 3fr 1.5fr 1.5fr 1fr;
  padding: 12px 16px;
  background: rgba(0,0,0,0.01);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  border-bottom: 1px solid var(--border-color);
}
.file-list-row {
  display: grid;
  grid-template-columns: 3fr 1.5fr 1.5fr 1fr;
  padding: 12px 16px;
  align-items: center;
  font-size: 0.88rem;
  color: var(--text-primary);
  border-bottom: 1px solid rgba(0,0,0,0.03);
  cursor: pointer;
  transition: background var(--transition-fast);
}
.file-list-row:last-child {
  border-bottom: none;
}
.file-list-row:hover {
  background: rgba(10, 124, 255, 0.02);
}
.file-list-name-col {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.file-list-preview-mini {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  background: rgba(0,0,0,0.02);
}
.file-list-name {
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.file-list-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}
.file-action-btn {
  border: none;
  background: transparent;
  padding: 6px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition-fast);
}
.file-action-btn:hover {
  background: rgba(0,0,0,0.05);
  color: var(--text-primary);
}
body.dark-theme .file-action-btn:hover {
  background: rgba(255,255,255,0.05);
}

/* Lightbox Modal */
.lightbox-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.lightbox-modal.hidden {
  display: none !important;
}
.lightbox-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(13, 13, 13, 0.6);
  backdrop-filter: blur(4px);
}
.lightbox-content {
  background: var(--bg-panel);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  max-width: 800px;
  width: 100%;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  max-height: calc(100vh - 48px); /* Учитывает padding 24px * 2 у .lightbox-modal */
  position: relative;
  box-shadow: 0 10px 40px rgba(0,0,0,0.25);
  z-index: 10;
}
.lightbox-close-btn {
  position: absolute;
  top: 14px;
  right: 14px;
  border: none;
  background: rgba(255, 255, 255, 0.8);
  border-radius: 50%;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
  color: #000;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  transition: all var(--transition-fast);
  z-index: 20;
}
.lightbox-close-btn:hover {
  transform: scale(1.05);
  background: var(--border-color);
}
.lightbox-body {
  padding: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  max-height: 70vh;
  overflow: hidden;
  background: rgba(0,0,0,0.02);
}
.lightbox-body img {
  max-width: 100%;
  max-height: 60vh;
  object-fit: contain;
  border-radius: var(--radius-md);
  box-shadow: 0 4px 16px rgba(0,0,0,0.08);
}
.lightbox-footer {
  padding: 16px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
  border-top: 1px solid var(--border-color);
}
.lightbox-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.lightbox-filename {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
}
.lightbox-date {
  font-size: 0.8rem;
  color: var(--text-muted);
}
.lightbox-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
.lightbox-actions .primary-btn, .lightbox-actions .secondary-btn {
  padding: 8px 16px;
  font-size: 0.85rem;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.lightbox-actions .btn-link {
  text-decoration: none;
}

/* Attached file pill styles in message box */
.attached-artifact-container {
  display: flex;
  gap: 8px;
  padding: 6px 12px;
  border-bottom: 1px solid var(--border-color);
  background: rgba(0,0,0,0.01);
  align-items: center;
  flex-wrap: wrap;
}
body.dark-theme .attached-artifact-container {
  background: rgba(255, 255, 255, 0.01);
}
.attached-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-panel);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 4px 10px;
  font-size: 0.8rem;
  color: var(--text-primary);
  max-width: 240px;
  position: relative;
  animation: scaleIn 0.15s ease-out;
}
.attached-pill-preview {
  width: 24px;
  height: 24px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  background: rgba(0,0,0,0.02);
}
.attached-pill-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 500;
}
.attached-pill-remove {
  border: none;
  background: transparent;
  padding: 2px;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
}
.attached-pill-remove:hover {
  background: rgba(0,0,0,0.05);
  color: var(--danger);
}
body.dark-theme .attached-pill-remove:hover {
  background: rgba(255,255,255,0.05);
}

/* Custom styles for files page layout & mobile state */
.files-header {
  padding: 14px 24px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 60px;
  background: var(--bg-main);
  z-index: 10;
  box-sizing: border-box;
}
.files-header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}
.file-card-prompt {
  font-size: 0.75rem;
  color: var(--text-muted);
  line-height: 1.3;
  margin-top: 4px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  word-break: break-word;
  text-align: left;
}

@media (max-width: 768px) {
  .files-header {
    padding: 10px 16px;
    height: 56px;
    position: sticky;
    top: 0;
    width: 100%;
  }
  .files-header-title h2 {
    font-size: 0.85rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .files-scroll-container {
    padding: 16px;
  }
  /* Отображение на мобилке по 2 карточки в строчку */
  .files-grid-container {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 10px !important;
  }
  .file-card-preview {
    height: 120px !important;
  }
  .file-card-info {
    padding: 8px !important;
  }
  .file-card-name {
    font-size: 0.8rem !important;
  }
  .file-card-prompt {
    -webkit-line-clamp: 1 !important;
    font-size: 0.7rem !important;
  }

  /* Lightbox Mobile Adjustments */
  .lightbox-footer {
    padding: 12px 16px !important;
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 12px !important;
  }
  .lightbox-info {
    text-align: left !important;
    align-items: flex-start !important;
  }
  .lightbox-actions {
    justify-content: center !important;
    width: 100% !important;
    flex-wrap: wrap !important;
    gap: 8px !important;
  }
  .lightbox-actions button, .lightbox-actions a {
    flex: 1 1 calc(50% - 8px) !important;
    justify-content: center !important;
    font-size: 0.8rem !important;
    padding: 8px 10px !important;
  }
  #lightbox-chat-btn {
    flex-basis: 100% !important; /* Full width for the chat redirect button to look balanced */
  }
}

/* Custom User Job Cards */
.user-job-card {
  border-color: rgba(139, 92, 246, 0.25) !important;
}
body.dark-theme .user-job-card {
  border-color: rgba(139, 92, 246, 0.4) !important;
}
.user-job-card .job-icon {
  background: rgba(139, 92, 246, 0.08) !important;
  color: #8b5cf6 !important;
}
.user-job-tooltip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  color: #8b5cf6;
  background: rgba(139, 92, 246, 0.08);
  border: 1px solid rgba(139, 92, 246, 0.2);
  padding: 2px 6px;
  height: 18px;
  border-radius: var(--radius-pill);
  cursor: help;
  flex-shrink: 0;
  font-size: 0.68rem;
  font-weight: 500;
  transition: all var(--transition-fast);
}
.user-job-tooltip:hover {
  background: rgba(139, 92, 246, 0.15);
  border-color: rgba(139, 92, 246, 0.4);
}
body.dark-theme .user-job-tooltip {
  background: rgba(139, 92, 246, 0.15);
  color: #a78bfa;
  border-color: rgba(139, 92, 246, 0.3);
}

/* Prompt Screen & Cards Responsiveness */
.prompt-card {
  padding: 20px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 16px;
  min-height: 180px;
  box-sizing: border-box;
  cursor: default;
}
.prompt-card-body {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 100%;
}
.prompt-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  gap: 12px;
}
.prompt-card-title-group {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.prompt-card-icon {
  width: 16px;
  height: 16px;
  color: var(--primary);
  flex-shrink: 0;
}
.prompt-card-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}
.prompt-card-desc {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin: 0;
  text-align: left;
}
.prompt-card-content {
  font-size: 0.75rem;
  color: var(--text-muted);
  line-height: 1.4;
  margin-top: 6px;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  word-break: break-word;
  text-align: left;
}
.prompt-card .use-prompt-btn {
  padding: 8px 12px;
  font-size: 0.8rem;
  width: 100%;
  justify-content: center;
  border-radius: var(--radius-md);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

@media (max-width: 768px) {
  .prompt-card {
    padding: 12px !important;
    min-height: 160px !important;
    gap: 10px !important;
  }
  .prompt-card-title-group h4 {
    font-size: 0.85rem !important;
  }
  .prompt-card-desc {
    font-size: 0.75rem !important;
  }
  .prompt-card-content {
    font-size: 0.7rem !important;
    -webkit-line-clamp: 2 !important;
  }
  .prompt-card .use-prompt-btn {
    padding: 6px 10px !important;
    font-size: 0.75rem !important;
  }
}

@media (max-width: 600px) {
  .btn-text-responsive {
    display: none;
  }
  #share-chat-btn {
    padding: 0 !important;
    width: 32px !important;
    height: 32px !important;
    min-width: 32px !important;
    min-height: 32px !important;
    margin: 0 8px !important;
    flex-shrink: 0 !important;
  }
  #share-chat-btn-icon {
    margin: 0 !important;
  }
  #prompts-create-btn {
    padding: 0 !important;
    border-radius: 50% !important;
    width: 34px;
    height: 34px;
    min-width: 34px;
    min-height: 34px;
    flex-shrink: 0;
    justify-content: center;
  }
}

/* User Job Card top-left text badge */
.user-job-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(139, 92, 246, 0.08);
  color: #8b5cf6;
  border: 1px solid rgba(139, 92, 246, 0.2);
  padding: 4px 8px;
  font-size: 0.7rem;
  font-weight: 500;
  border-radius: 6px;
  line-height: 1;
  height: 22px;
  box-sizing: border-box;
}

body.dark-theme .user-job-badge {
  background: rgba(139, 92, 246, 0.15);
  color: #a78bfa;
  border-color: rgba(139, 92, 246, 0.3);
}

/* Guest Mode Styles */
body.guest-mode .sidebar {
  display: none !important;
}

body.guest-mode .chat-area {
  margin-left: 0 !important;
  width: 100% !important;
  max-width: 100% !important;
}

body.guest-mode .chat-header {
  padding-left: 16px !important;
  justify-content: space-between;
}

body.guest-mode .guest-only-logo {
  display: flex !important;
}

@media (max-width: 768px) {
  body.guest-mode .guest-only-logo h2 {
    display: none !important;
  }
}

body.guest-mode .mobile-menu-toggle,
body.guest-mode #mobile-menu-toggle {
  display: none !important;
}

body.guest-mode .choose-tariff-btn {
  display: none !important;
}

/* Natal Chart Guest Mode Overlay */
.natal-guest-blur {
  max-height: 400px;
  overflow: hidden;
  position: relative;
  mask-image: linear-gradient(to bottom, black 50%, transparent 100%);
  -webkit-mask-image: linear-gradient(to bottom, black 50%, transparent 100%);
}

/* Free users get a 2.5x larger preview than guests: 1000px vs 400px. */
.natal-free-blur {
  max-height: 1000px;
  overflow: hidden;
  position: relative;
  mask-image: linear-gradient(to bottom, black 70%, transparent 100%);
  -webkit-mask-image: linear-gradient(to bottom, black 70%, transparent 100%);
}

.natal-show-more-btn {
  margin-top: 12px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: var(--radius-pill);
  padding: 10px 20px;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  width: 100%;
  text-align: center;
  transition: background var(--transition-fast);
}

.natal-show-more-btn:hover {
  background: var(--primary-hover);
}

/* Human Design & Matrix Guest Mode Overlay */
.hd-guest-blur,
.matrix-guest-blur,
.matrix-compat-guest-blur {
  display: -webkit-box;
  -webkit-line-clamp: 10;
  -webkit-box-orient: vertical;
  overflow: hidden;
  position: relative;
  mask-image: linear-gradient(to bottom, black 60%, transparent 100%);
  -webkit-mask-image: linear-gradient(to bottom, black 60%, transparent 100%);
}

/* Free users get 25 lines instead of the guest preview's 10 lines. */
.hd-free-blur,
.matrix-free-blur {
  display: -webkit-box;
  -webkit-line-clamp: 25;
  -webkit-box-orient: vertical;
  overflow: hidden;
  position: relative;
  mask-image: linear-gradient(to bottom, black 75%, transparent 100%);
  -webkit-mask-image: linear-gradient(to bottom, black 75%, transparent 100%);
}

/* Sidebar Referral Button */
.sidebar-referral-promo-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  width: calc(100% - 40px);
  margin: 12px 20px 4px 20px;
  padding: 12px 16px;
  background: linear-gradient(135deg, rgba(10, 124, 255, 0.08) 0%, rgba(10, 124, 255, 0.02) 100%);
  border: 1px solid rgba(10, 124, 255, 0.15);
  border-radius: var(--radius-md);
  cursor: pointer;
  text-align: left;
  transition: transform var(--transition-fast), border-color var(--transition-fast), background var(--transition-fast);
}

.sidebar-referral-promo-btn:hover {
  background: linear-gradient(135deg, rgba(10, 124, 255, 0.12) 0%, rgba(10, 124, 255, 0.06) 100%);
  border-color: rgba(10, 124, 255, 0.3);
  transform: translateY(-1px);
}

.sidebar-referral-promo-btn:active {
  transform: translateY(0);
}

.sidebar-referral-promo-btn .promo-icon-box {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background: var(--primary);
  color: #fff;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}

.sidebar-referral-promo-btn .promo-icon-box i {
  width: 18px;
  height: 18px;
}

.sidebar-referral-promo-btn .promo-text-box {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidebar-referral-promo-btn .promo-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
}

.sidebar-referral-promo-btn .promo-desc {
  font-size: 0.72rem;
  font-weight: 400;
  color: var(--text-muted);
  line-height: 1.2;
}

body.dark-theme .sidebar-referral-promo-btn {
  background: linear-gradient(135deg, rgba(59, 156, 255, 0.1) 0%, rgba(59, 156, 255, 0.02) 100%);
  border-color: rgba(59, 156, 255, 0.2);
}
body.dark-theme .sidebar-referral-promo-btn:hover {
  background: linear-gradient(135deg, rgba(59, 156, 255, 0.15) 0%, rgba(59, 156, 255, 0.05) 100%);
  border-color: rgba(59, 156, 255, 0.35);
}

/* Referral Modal Styles */
.referral-modal-content {
  max-width: 480px;
  width: 100%;
  border-radius: 24px;
}

.referral-modal-body {
  padding: 24px 28px 28px 28px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.referral-hero {
  background: linear-gradient(135deg, rgba(10, 124, 255, 0.08) 0%, rgba(10, 124, 255, 0.02) 100%);
  border: 1px solid rgba(10, 124, 255, 0.1);
  border-radius: 18px;
  padding: 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  overflow: hidden;
  position: relative;
}

.referral-hero-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.referral-hero-content h2 {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
  line-height: 1.3;
  color: var(--text-primary);
}

.referral-hero-content p {
  margin: 0;
  font-size: 0.82rem;
  color: var(--text-secondary);
  line-height: 1.4;
}

.referral-hero-badge {
  background: var(--primary);
  color: #fff;
  font-size: 0.68rem;
  font-weight: 600;
  padding: 4px 8px;
  border-radius: 6px;
  width: fit-content;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.referral-hero-graphics {
  position: relative;
  width: 100px;
  height: 100px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.graphics-bubble {
  position: absolute;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.bubble-1 {
  width: 44px;
  height: 44px;
  background: linear-gradient(135deg, #ff416c, #ff4b2b);
  color: #fff;
  z-index: 2;
}

.bubble-2 {
  width: 28px;
  height: 28px;
  background: #ffb300;
  color: #fff;
  top: 0;
  left: 10px;
}

.bubble-3 {
  width: 32px;
  height: 32px;
  background: #0a7cff;
  color: #fff;
  bottom: 0;
  right: 10px;
}

.bubble-4 {
  width: 24px;
  height: 24px;
  background: #a855f7;
  color: #fff;
  bottom: 40px;
  left: 5px;
}

.graphics-bubble i {
  width: 14px;
  height: 14px;
}
.bubble-1 i {
  width: 20px;
  height: 20px;
}

.referral-section h3 {
  margin: 0 0 12px 0;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.referral-steps {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.referral-steps li {
  display: flex;
  align-items: center;
  gap: 12px;
}

.referral-steps .step-num {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: rgba(10, 124, 255, 0.1);
  color: var(--primary);
  font-size: 0.8rem;
  font-weight: 600;
  flex-shrink: 0;
}

.referral-steps .step-text {
  font-size: 0.88rem;
  color: var(--text-primary);
  font-weight: 500;
}

.referral-link-box {
  display: flex;
  gap: 8px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 6px 6px 6px 14px;
  align-items: center;
}

.referral-link-box input {
  flex: 1;
  border: none;
  background: transparent;
  font-size: 0.85rem;
  color: var(--text-secondary);
  outline: none;
  min-width: 0;
}

.referral-link-box button {
  padding: 8px 16px;
  font-size: 0.85rem;
  border-radius: 8px;
  margin: 0;
  height: 36px;
}

.referral-guest-box {
  background: var(--bg-secondary);
  border: 1px dashed var(--border-color);
  border-radius: 12px;
  padding: 16px 20px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.referral-guest-box p {
  margin: 0;
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.4;
}

.referral-guest-box button {
  align-self: center;
  padding: 8px 20px;
  font-size: 0.85rem;
  border-radius: 8px;
  height: 36px;
  margin: 0;
}

.referral-modal-footer-text {
  margin: 0;
  text-align: center;
  font-size: 0.75rem;
  color: var(--text-muted);
  line-height: 1.4;
}

.referral-modal-footer-text a {
  color: var(--primary);
  text-decoration: none;
  font-weight: 500;
}

body.dark-theme .referral-hero {
  background: linear-gradient(135deg, rgba(59, 156, 255, 0.1) 0%, rgba(59, 156, 255, 0.02) 100%);
  border-color: rgba(59, 156, 255, 0.15);
}

body.dark-theme .referral-steps .step-num {
  background: rgba(59, 156, 255, 0.15);
  color: #3b9cff;
}

/* ==========================================================================
   NETS CATALOG SCREEN
   ========================================================================== */
.nets-grid-container {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
  width: 100%;
}

@media (max-width: 1024px) {
  .nets-grid-container {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 600px) {
  .nets-grid-container {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }
  .net-card {
    padding: 14px;
    gap: 12px;
    border-radius: var(--radius-md);
  }
  .net-card-icon {
    width: 38px;
    height: 38px;
    border-radius: 10px;
  }
  .net-card-icon i {
    width: 18px !important;
    height: 18px !important;
  }
  .net-card-title {
    font-size: 0.95rem;
  }
  .net-card-desc {
    font-size: 0.75rem;
    line-height: 1.4;
    height: 4.2em; /* 3 lines of 1.4 line-height */
  }
  .net-card-btn {
    font-size: 0.8rem;
    padding: 8px 12px;
  }
}

.net-card {
  background: var(--bg-panel);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  transition: all var(--transition-normal);
  position: relative;
  overflow: hidden;
  text-align: left;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.02);
}

body.dark-theme .net-card {
  background: var(--bg-panel);
  border-color: var(--border-color);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}

.net-card:hover {
  transform: translateY(-4px);
  border-color: rgba(10, 124, 255, 0.35);
  box-shadow: 0 12px 30px rgba(10, 124, 255, 0.06);
}

body.dark-theme .net-card:hover {
  border-color: rgba(59, 156, 255, 0.35);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.35);
}

.net-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
}

.net-card-icon {
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all var(--transition-normal);
}

.net-card:hover .net-card-icon {
  transform: scale(1.05) rotate(3deg);
}


.net-card-badge {
  background: rgba(10, 124, 255, 0.06);
  border: 1px solid rgba(10, 124, 255, 0.15);
  color: var(--primary);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  display: flex;
  align-items: center;
  gap: 4px;
  backdrop-filter: blur(4px);
  transition: opacity var(--transition-normal), transform var(--transition-normal);
}

@media (hover: hover) {
  .net-card-badge {
    opacity: 0;
    transform: translateY(2px);
    pointer-events: none;
  }
  .net-card:hover .net-card-badge {
    opacity: 1;
    transform: translateY(0);
  }
}

body.dark-theme .net-card-badge {
  background: rgba(59, 156, 255, 0.12);
  color: #3b9cff;
  border-color: rgba(59, 156, 255, 0.22);
}

.net-card-title-group {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.net-card-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
  line-height: 1.3;
  transition: color var(--transition-fast);
}

.net-card:hover .net-card-title {
  color: var(--primary);
}

.net-card-provider {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.net-card-desc {
  font-size: 0.875rem;
  color: var(--text-secondary);
  line-height: 1.5;
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  height: 4.5em; /* Exactly 3 lines */
  flex-shrink: 0;
}

.net-card-footer {
  margin-top: 4px;
  width: 100%;
}

.net-card-btn {
  width: 100%;
  padding: 10px 16px;
  border-radius: var(--radius-pill);
  background: rgba(10, 124, 255, 0.08);
  color: var(--primary);
  border: 1px solid rgba(10, 124, 255, 0.15);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-normal);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

body.dark-theme .net-card-btn {
  background: rgba(59, 156, 255, 0.12);
  color: #3b9cff;
  border-color: rgba(59, 156, 255, 0.2);
}

.net-card:hover .net-card-btn {
  background: var(--primary);
  color: #ffffff;
  border-color: var(--primary);
  box-shadow: 0 4px 12px var(--primary-glow);
}

/* Share Chat Popover */
.share-chat-popover {
  width: 320px;
  max-width: calc(100vw - 32px);
  left: auto;
  right: 0;
  top: calc(100% + 8px);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.15);
  border-radius: 12px;
  z-index: 10000;
  cursor: default;
  border: 1px solid var(--border-color);
  background: var(--bg-panel);
}

@media (max-width: 768px) {
  .share-chat-popover {
    position: fixed;
    top: 68px; /* Below the header */
    left: 16px;
    right: 16px;
    width: auto;
    max-width: none;
    margin: 0 auto;
  }
}

/* Muza AI Icon Styling */
.muza-icon {
  font-size: 1.2em; /* Default size for dropdowns and triggers */
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  color: var(--text-primary); /* Remove blue color, inherit standard text color */
}

/* For main screens, override font-size */
.welcome-model-icon .muza-icon,
.net-card-icon .muza-icon {
  font-size: 2.2em;
}

body.recovery-mode .sidebar { display: none !important; }
body.guest-nets-mode .sidebar { display: none !important; }
body.guest-nets-mode .mobile-menu-toggle { display: none !important; }

/* Notification Banner */
.notification-banner {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
  border-radius: 16px;
  padding: 16px 20px;
  width: auto;
  max-width: 90vw;
  transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.notification-banner.hidden {
  opacity: 0;
  transform: translate(-50%, -100px);
  pointer-events: none;
}

.notification-banner-content {
  display: flex;
  align-items: center;
  gap: 20px;
}

.notification-banner-text {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.notification-banner-text h4 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-primary);
}

.notification-banner-text p {
  margin: 0;
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.notification-enable-btn {
  background: var(--bg-secondary);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  padding: 8px 16px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.notification-enable-btn:hover {
  background: var(--bg-hover);
  transform: translateY(-1px);
}

.notification-enable-btn:active {
  transform: translateY(1px);
}

.notification-close-btn {
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s ease;
  color: var(--text-muted);
}

.notification-close-btn:hover {
  background: var(--bg-secondary);
  color: var(--text-primary);
}

@media (max-width: 640px) {
  .notification-banner-content {
    gap: 12px;
  }
  .notification-banner-text h4 {
    font-size: 0.95rem;
  }
  .notification-banner-text p {
    font-size: 0.8rem;
  }
  .notification-enable-btn {
    padding: 6px 12px;
    font-size: 0.85rem;
  }
}

@media (max-width: 768px) {
  .user-card {
    flex-direction: column;
    align-items: stretch;
    gap: 24px;
    padding: 24px 20px;
  }

  .user-avatar-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 16px;
    width: 100%;
  }

  .user-meta {
    width: 100%;
    word-break: break-word;
  }

  .profile-logout-btn {
    width: 100%;
    justify-content: center;
  }
}

/* Chat Input Mobile Options Row */
@media (max-width: 600px) {
  .chat-options-row {
    flex-wrap: nowrap !important;
    overflow-x: auto;
    padding-bottom: 2px;
    scrollbar-width: none;
  }
  .chat-options-row::-webkit-scrollbar {
    display: none;
  }

  #composer-model-dropdown-menu {
    position: fixed;
    left: 8px;
    right: 8px;
    bottom: 8px;
    top: auto;
    width: auto;
    max-width: none;
    max-height: 65vh;
    border-radius: 20px;
    padding: 8px;
    z-index: 9999;
  }
  
  .format-popup {
    position: fixed !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    width: 100% !important;
    border-radius: 20px 20px 0 0 !important;
    box-shadow: 0 -4px 20px rgba(0,0,0,0.15) !important;
    margin: 0 !important;
    max-height: 50vh;
    overflow-y: auto;
    z-index: 9999 !important;
    padding-bottom: env(safe-area-inset-bottom, 20px) !important;
  }
}

/* Dictation Button Recording State */
@keyframes pulse-record {
  0% { box-shadow: 0 0 0 0 rgba(255, 59, 48, 0.4); background-color: rgba(255, 59, 48, 0.1); color: #ff3b30; }
  70% { box-shadow: 0 0 0 10px rgba(255, 59, 48, 0); background-color: rgba(255, 59, 48, 0.2); color: #ff3b30; }
  100% { box-shadow: 0 0 0 0 rgba(255, 59, 48, 0); background-color: rgba(255, 59, 48, 0.1); color: #ff3b30; }
}

.dictation-btn[hidden] { display:none !important; }
.dictation-btn.recording {
  animation: pulse-record 1.5s infinite !important;
  border-color: #ff3b30 !important;
  color: #ff3b30 !important;
  background-color: rgba(255, 59, 48, 0.1) !important;
}
.dictation-btn.recording svg {
  color: #ff3b30 !important;
}

/* Prevent iOS input zoom on mobile by enforcing 16px font-size */
@media screen and (max-width: 768px) {
  input[type="text"], input[type="email"], input[type="number"], input[type="password"], input[type="tel"], input[type="url"], textarea, select, .style-search-input {
    font-size: 16px !important;
  }

  #message-input::placeholder {
    font-size: 16px;
  }
}


@media screen and (max-width: 768px) {
  .guest-only-footer {
    flex-direction: column;
    gap: 8px;
    padding-bottom: 24px;
  }
}

/* ==========================================================================
   Muza AI Studio Styles
   ========================================================================== */

.studio-workspace {
  background: var(--bg-main);
  padding: 16px 20px 40px;
  container-type: inline-size;
}

.studio-home {
  width: 100%;
  max-width: 1120px;
  margin: 0 auto;
  padding: 40px 0;
}

.studio-home-heading { margin-bottom: 30px; }
.studio-home-eyebrow { display: inline-flex; align-items: center; gap: 7px; color: var(--primary); font-size: 13px; font-weight: 600; margin-bottom: 14px; }
.studio-home-eyebrow svg { width: 17px; height: 17px; }
.studio-home-heading h1 { font-size: clamp(28px, 4.2cqi, 40px); line-height: 1.15; font-weight: 650; letter-spacing: -1.2px; margin-bottom: 12px; }
.studio-home-heading p { font-size: 16px; line-height: 1.5; color: var(--text-secondary); }
.studio-entry-grid { display: grid; grid-template-columns: 1fr; gap: 20px; }
.studio-entry-card { position: relative; display: flex; flex-direction: column; min-width: 0; width: 100%; padding: 0; overflow: hidden; border: 1px solid var(--border-color); border-radius: 24px; background: var(--bg-panel); color: var(--text-primary); font: inherit; text-align: left; text-decoration: none; }
button.studio-entry-card { cursor: pointer; transition: border-color .18s, box-shadow .18s, transform .18s; }
button.studio-entry-card:hover { border-color: rgba(10, 124, 255, .4); box-shadow: 0 12px 32px rgba(10, 60, 120, .08); transform: translateY(-3px); }
button.studio-entry-card:focus-visible, .studio-back-btn:focus-visible { outline: 3px solid var(--primary); outline-offset: 4px; }
.studio-entry-image { display: block; width: 100%; height: auto; aspect-ratio: 3 / 2; object-fit: cover; background: #edf5ff; }
.studio-entry-body { display: flex; flex: 1; flex-direction: column; align-items: flex-start; padding: 24px; }
.studio-entry-title { font-size: 21px; font-weight: 600; line-height: 1.25; letter-spacing: -.5px; margin-bottom: 10px; }
.studio-entry-description { font-size: 14px; line-height: 1.6; color: var(--text-secondary); margin-bottom: 26px; }
.studio-entry-action, .studio-entry-soon { margin-top: auto; font-size: 14px; font-weight: 600; line-height: 24px; }
.studio-entry-action { display: inline-flex; align-items: center; gap: 7px; color: var(--primary); }
.studio-entry-action svg { width: 17px; height: 17px; }
.studio-entry-coming { background: var(--bg-card); }
.studio-entry-coming .studio-entry-image { opacity: .85; }
.studio-entry-image-wrap { position: relative; }
.studio-entry-badge { position: absolute; top: 16px; right: 16px; padding: 5px 12px; border-radius: 99px; background: var(--bg-panel); color: var(--text-primary); font-size: 12px; font-weight: 600; box-shadow: 0 2px 12px rgba(0, 0, 0, .04); }
.studio-entry-soon { color: var(--text-muted); font-weight: 500; }
.studio-workspace-nav { display: flex; flex-direction: column; gap: 18px; }
.studio-back-btn { display: inline-flex; align-items: center; gap: 7px; align-self: flex-start; min-height: 44px; border: 0; padding: 0; background: transparent; font: inherit; font-size: 14px; color: var(--text-secondary); cursor: pointer; }
.studio-back-btn svg { width: 17px; height: 17px; }
.studio-workspace-heading { display: flex; align-items: center; flex-wrap: wrap; justify-content: space-between; gap: 10px; }
.studio-workspace-heading h2 { font-size: 24px; font-weight: 600; letter-spacing: -.6px; }
.studio-task-tabs { display: flex; gap: 4px; width: min(100%, 420px); box-sizing: border-box; padding: 4px; border: 1px solid var(--border-color); border-radius: 12px; background: var(--bg-secondary); }
.studio-task-tab { display: inline-flex; flex: 1; flex-wrap: wrap; align-items: center; justify-content: center; gap: 3px 6px; min-width: 0; min-height: 44px; padding: 8px 12px; border: 0; border-radius: 8px; background: transparent; color: var(--text-secondary); font: inherit; font-size: .9rem; font-weight: 500; cursor: pointer; }
.studio-task-tab[aria-selected="true"] { background: var(--primary); color: #fff; }
.studio-task-tab:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.studio-task-tab:disabled { cursor: default; opacity: .55; }
.studio-task-soon { padding: 2px 5px; border-radius: 5px; background: var(--bg-panel); color: var(--text-secondary); font-size: .62rem; line-height: 1.3; }
@container (min-width: 760px) { .studio-entry-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@container (max-width: 759px) { .studio-home { max-width: 520px; padding: 20px 0; } }
@container (max-width: 360px) { .studio-entry-body { padding: 20px; } .studio-entry-title { font-size: 20px; } .studio-home-heading h1 { letter-spacing: -.7px; } }
@media (max-width: 767px) {
  .studio-entry-grid {
    grid-template-columns: none;
    grid-auto-flow: column;
    grid-auto-columns: 84%;
    gap: 12px;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scroll-snap-type: x mandatory;
    scrollbar-width: thin;
    padding: 4px 4px 12px;
  }
  .studio-entry-card { border-radius: 18px; scroll-snap-align: start; }
  .studio-entry-body { padding: 16px; }
  .studio-entry-title { font-size: 18px; margin-bottom: 8px; }
  .studio-entry-description { font-size: 13px; line-height: 1.5; margin-bottom: 16px; }
  .studio-entry-action { font-size: 13px; }
}
@media (prefers-reduced-motion: reduce) { button.studio-entry-card { transition: none; } button.studio-entry-card:hover { transform: none; } }

.studio-content-wrapper {
  max-width: 1040px;
  width: 100%;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.studio-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.studio-section-header {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
}

.studio-section-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text-primary);
}

.studio-count-badge {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  background: var(--primary-glow);
  color: var(--primary);
}

.studio-hint {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

/* Source Strip */
.studio-source-strip {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  padding: 8px 4px 12px;
  align-items: center;
  scrollbar-width: thin;
}

.studio-add-source-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 144px;
  height: 144px;
  min-width: 144px;
  border: 1.5px dashed var(--border-color);
  border-radius: var(--radius-md);
  background: var(--bg-card);
  color: var(--text-secondary);
  font-size: 0.75rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.studio-add-source-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-glow);
}

.studio-source-card {
  position: relative;
  width: 144px;
  height: 144px;
  min-width: 144px;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--border-color);
  background: var(--bg-panel);
  cursor: pointer;
  transition: transform var(--transition-fast), border-color var(--transition-fast);
}

.studio-source-card:hover {
  transform: translateY(-2px);
  border-color: var(--primary);
}

.studio-source-card.is-primary {
  border: 2px solid #eab308;
  box-shadow: 0 0 8px rgba(234, 179, 8, 0.25);
}

.studio-source-pending {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 144px;
  height: 144px;
  min-width: 144px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
}

.studio-source-pending .spinner {
  width: 22px;
  height: 22px;
  border: 2px solid var(--border-color);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.studio-source-pending,
.studio-source-card.is-loading {
  background: linear-gradient(90deg, var(--bg-card) 25%, var(--border-color) 50%, var(--bg-card) 75%);
  background-size: 200% 100%;
  animation: studio-shimmer 1.5s infinite;
}

.studio-source-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.studio-source-star-badge {
  position: absolute;
  top: 4px;
  left: 4px;
  background: #eab308;
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 2px 5px;
  border-radius: var(--radius-pill);
  box-shadow: 0 1px 4px rgba(0,0,0,0.25);
  display: flex;
  align-items: center;
  gap: 2px;
}

.studio-source-delete-btn {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity var(--transition-fast);
}

.studio-source-card:hover .studio-source-delete-btn {
  opacity: 1;
}

.studio-source-open-card-btn {
  position: absolute;
  bottom: 4px;
  left: 4px;
  right: 4px;
  background: rgba(0,0,0,0.65);
  color: #fff;
  border: none;
  border-radius: 4px;
  font-size: 0.72rem;
  padding: 4px 5px;
  text-align: center;
  opacity: 0;
  cursor: pointer;
  transition: opacity var(--transition-fast);
}

.studio-source-card:not(.is-primary) .studio-source-open-card-btn:first-of-type {
  bottom: 42px;
}

.studio-source-card:hover .studio-source-open-card-btn {
  opacity: 1;
}

/* Product Title & Category Row (Unified Plate) */
.studio-product-title-row {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  margin-top: 12px;
  padding: 12px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
}

.studio-product-title-label {
  font-size: 0.95rem;
  font-style: italic;
  font-weight: 600;
  color: var(--text-secondary);
  user-select: none;
  padding-top: 8px;
}

.studio-product-meta-fields {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

.studio-product-title-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 6px 12px;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.studio-product-title-input-wrapper:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-glow);
}

.studio-product-title-input {
  flex: 1;
  width: 100%;
  border: none;
  outline: none;
  background: transparent;
  color: var(--text-primary);
  font-size: 0.92rem;
  font-weight: 500;
  padding: 2px 0;
  font-family: inherit;
}

.studio-product-title-input::placeholder {
  color: var(--text-muted);
  font-style: normal;
  font-weight: 400;
}

.studio-product-title-loader {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-left: 8px;
  white-space: nowrap;
}

.studio-product-title-loader .spinner-sm {
  width: 14px;
  height: 14px;
  border: 2px solid var(--border-color);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.studio-category-select-wrapper {
  position: relative;
  width: 100%;
}

.studio-category-status { margin-top: 8px; color: var(--text-secondary); font-size: .8rem; line-height: 1.5; }
.studio-category-status button { display: block; margin-top: 6px; padding: 0; border: 0; background: none; color: var(--primary); font: inherit; cursor: pointer; }
.studio-category-status[hidden], .studio-category-status button[hidden] { display: none; }
.studio-product-editor .studio-category-select-wrapper:has(.studio-category-status:not([hidden]))::after { top: 22px; }

.studio-category-select-wrapper select.studio-category-select {
  width: 100%;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  color: var(--text-primary);
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  outline: none;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.studio-category-select-wrapper select.studio-category-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-glow);
}

/* Settings Card */
.studio-settings-card {
  padding: 20px;
}

.studio-settings-grid {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.studio-field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.studio-field-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.studio-field-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
}

[data-v2-detail-mode-field] { display: grid; gap: 6px; margin-top: 12px; }
[data-v2-detail-mode-field] .studio-select { min-height: 44px; }

.studio-text-btn {
  background: none;
  border: none;
  color: var(--primary);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  padding: 0;
}

.studio-input, .studio-select, .studio-textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--bg-input);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.9rem;
  outline: none;
  transition: border-color var(--transition-fast);
}

.studio-input:focus, .studio-select:focus, .studio-textarea:focus {
  border-color: var(--primary);
}

/* Category Chips */
.studio-category-chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-width: none;
}

.studio-category-chip {
  padding: 8px 14px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  color: var(--text-secondary);
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: all var(--transition-fast);
}

.studio-category-chip:hover {
  border-color: var(--text-secondary);
  color: var(--text-primary);
}

.studio-category-chip.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  box-shadow: 0 2px 8px var(--primary-glow);
}

/* Mode Toggle */
.studio-mode-toggle {
  display: inline-flex;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 3px;
  gap: 4px;
  width: fit-content;
}

.studio-mode-btn {
  padding: 6px 16px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.studio-mode-btn:hover {
  color: var(--text-primary);
}

.studio-mode-btn.active {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.15);
}

/* Card Text Section */
.studio-card-text-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 12px;
  background: var(--bg-panel);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  margin-top: 4px;
}

.studio-field-counter {
  font-size: 0.72rem;
  color: var(--text-muted);
}

/* Image editor presets use the same compact, swipeable choices as card mode. */
.studio-presets-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  padding: 2px 3px 8px;
}

@media (max-width: 640px) {
  .studio-presets-grid {
    grid-auto-flow: column;
    grid-auto-columns: clamp(136px, 36vw, 164px);
    grid-template-columns: none;
    gap: 8px;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
  }
}

.studio-preset-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 5px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  cursor: pointer;
  transition: all var(--transition-fast);
  text-align: center;
  align-items: center;
  outline: none;
  scroll-snap-align: start;
}

.studio-preset-card:hover {
  border-color: var(--primary);
  background: var(--bg-panel);
}

.studio-preset-card:focus-visible {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-glow);
}

.studio-preset-card.active {
  border: 2px solid var(--primary);
  background: var(--primary-glow);
  box-shadow: 0 2px 10px var(--primary-glow);
}

.studio-preset-thumb-wrapper {
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--bg-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
}

.studio-preset-thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: opacity var(--transition-fast);
}

.studio-preset-thumb.has-error {
  display: none;
}

.studio-preset-title {
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-primary);
  line-height: 1.25;
  word-break: break-word;
}

/* Card Reference Slots (Режим "Карточка") */
.studio-card-reference-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.studio-reference-slots-row {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}

.studio-ref-slot-item {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 140px;
}

.studio-ref-slot-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.studio-ref-slot-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
}

.studio-ref-slot-card {
  position: relative;
  width: 140px;
  height: 140px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color var(--transition-fast), background var(--transition-fast);
}

.studio-ref-upload-card {
  border-style: dashed;
  border-width: 1.5px;
  cursor: pointer;
}

.studio-ref-upload-card:hover {
  border-color: var(--primary);
  background: rgba(255, 255, 255, 0.05);
}

.studio-ref-upload-card:focus-visible {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-glow);
}

.studio-ref-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.studio-ref-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  color: var(--text-muted);
  text-align: center;
  padding: 8px;
}

.studio-ref-footer-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 140px;
}

.studio-ref-subtext {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.studio-ref-reset-btn {
  background: none;
  border: none;
  color: #ef4444;
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  padding: 0;
  text-decoration: underline;
}

.studio-ref-reset-btn:hover {
  color: #f87171;
}

/* Prompt / Wishes Textarea */
.studio-scene-ideas { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 14px; }
.studio-scene-idea-btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 44px; padding: 8px 16px; border: 1px solid var(--border-color); border-radius: var(--radius-pill); background: var(--bg-card); color: var(--text-primary); font: inherit; font-size: 14px; font-weight: 600; cursor: pointer; }
.studio-scene-idea-btn svg { width: 16px; height: 16px; color: var(--primary); }
.studio-scene-idea-btn:hover:not(:disabled) { border-color: var(--primary); background: var(--primary-glow); }
.studio-scene-idea-btn:disabled { opacity: .5; cursor: default; }
.studio-scene-idea-btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 3px; }
@media (max-width: 640px) { #studio-prompt-input { font-size: 16px; } }

.studio-prompt-textarea {
  min-height: 96px;
  max-height: 240px;
  resize: vertical;
  line-height: 1.5;
  padding: 10px 14px;
  font-size: 0.9rem;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  font-family: inherit;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.studio-prompt-textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-glow);
  outline: none;
}

/* Examples Modal & Button */
.studio-ref-examples-btn {
  background: none;
  border: none;
  color: var(--primary);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  transition: opacity var(--transition-fast), background var(--transition-fast);
}

.studio-ref-examples-btn:hover {
  opacity: 0.85;
  background: rgba(255, 255, 255, 0.05);
}

.studio-examples-content {
  max-width: 980px;
  max-height: 85vh;
  padding: 24px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.4);
}

.studio-examples-header {
  margin-bottom: 18px;
  padding-right: 36px;
}

.studio-examples-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.studio-examples-title {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-primary);
}

.studio-examples-subtitle {
  margin: 6px 0 0 0;
  font-size: 0.88rem;
  color: var(--text-secondary);
}

.studio-examples-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 14px;
  overflow-y: auto;
  max-height: calc(85vh - 120px);
  padding: 4px;
}

@media (max-width: 600px) {
  .studio-examples-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }
}

.studio-example-card {
  position: relative;
  display: flex;
  flex-direction: column;
  background: var(--bg-panel);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow: hidden;
  cursor: pointer;
  transition: transform var(--transition-fast), border-color var(--transition-fast), box-shadow var(--transition-fast);
  text-align: left;
  padding: 0;
  outline: none;
}

.studio-example-card:hover {
  transform: translateY(-2px);
  border-color: var(--primary);
  box-shadow: 0 4px 16px var(--primary-glow);
}

.studio-example-card:focus-visible {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary);
}

.studio-example-card.active {
  border: 2px solid var(--primary);
  box-shadow: 0 0 0 2px var(--primary-glow);
}

.studio-example-thumb-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 3 / 4;
  overflow: hidden;
  background: #000;
}

.studio-example-thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.studio-example-info {
  padding: 8px 10px;
}

.studio-example-name {
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text-primary);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.3;
}

/* Action Row */
.studio-action-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 6px;
  padding-top: 14px;
  border-top: 1px solid var(--border-color);
}

.studio-format-scroll { position: relative; width: 100%; min-width: 0; }
.studio-format-next { display: none; }
.studio-format-next[hidden] { display: none; }

.studio-format-selector {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.studio-format-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  padding: 6px 12px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  color: var(--text-secondary);
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
}

/* Miniature frame with the button's proportions. */
.studio-format-btn::before {
  content: '';
  flex: none;
  height: 12px;
  aspect-ratio: var(--format-ratio, 1 / 1);
  border: 1.5px solid currentColor;
  border-radius: 2px;
  opacity: 0.7;
}

.studio-format-btn.active {
  background: var(--text-primary);
  color: var(--bg-main);
  border-color: var(--text-primary);
}

.studio-primary-cta {
  min-height: 64px;
  padding: 18px 24px;
  border-radius: var(--radius-pill);
  font-size: 1.05rem;
  line-height: 1.4;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 14px var(--primary-glow);
}

@media (max-width: 540px) {
  .studio-primary-cta { padding-inline: 16px; }
}

/* Results Grid */
.studio-results-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
}

.studio-frame-card {
  position: relative;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--border-color);
  background: var(--bg-panel);
  cursor: pointer;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast), border-color var(--transition-fast);
  display: flex;
  flex-direction: column;
}

.studio-frame-card:hover {
  transform: translateY(-3px);
  border-color: var(--primary);
  box-shadow: 0 8px 24px rgba(0,0,0,0.08);
}

.studio-frame-thumb-wrapper {
  position: relative;
  width: 100%;
  aspect-ratio: 3 / 4;
  background: var(--bg-card);
  overflow: hidden;
}

.studio-frame-thumb-wrapper img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.studio-frame-pos-badge {
  position: absolute;
  top: 8px;
  left: 8px;
  background: rgba(0, 0, 0, 0.7);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: var(--radius-pill);
  backdrop-filter: blur(4px);
}

.studio-frame-intent-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  background: rgba(10, 124, 255, 0.85);
  color: #fff;
  font-size: 0.68rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  backdrop-filter: blur(4px);
}

.studio-frame-info {
  padding: 10px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.studio-frame-variant-tag {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--primary);
}

.studio-frame-variants-count {
  font-size: 0.7rem;
  color: var(--text-muted);
}

@media (max-width: 640px) {
  .studio-results-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  .studio-frame-info {
    flex-wrap: wrap;
    gap: 4px 8px;
    padding: 8px;
  }
}

/* Skeleton Loading Card */
.studio-generation-skeleton {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  width: 100%;
  max-width: 100%;
  border-radius: var(--radius-md);
  aspect-ratio: 3 / 4;
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: center;
  justify-content: center;
  padding: 12px;
}

.studio-generation-skeleton::before {
  content: '';
  position: absolute;
  inset: -50%;
  z-index: -1;
  background: radial-gradient(ellipse at 30% 35%, var(--primary-glow), transparent 55%),
    linear-gradient(115deg, transparent 30%, var(--border-color) 50%, transparent 70%);
  animation: studio-generation-drift 4s ease-in-out infinite alternate;
}

.studio-generation-sparkle { width: 28px; height: 28px; flex-shrink: 0; color: var(--primary); animation: studio-generation-breathe 2.4s ease-in-out infinite; }
.studio-generation-skeleton .studio-skeleton-label { text-align: center; line-height: 1.4; }
.studio-skeleton-label {
  font-size: 0.78rem;
  color: var(--text-secondary);
}

@keyframes studio-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
@keyframes studio-generation-drift {
  from { transform: translate(-12%, -8%) rotate(-10deg); }
  to { transform: translate(12%, 8%) rotate(10deg); }
}
@keyframes studio-generation-breathe {
  0%, 100% { opacity: .55; transform: scale(.9); }
  50% { opacity: 1; transform: scale(1.1); }
}
@media (prefers-reduced-motion: reduce) {
  .studio-generation-skeleton::before, .studio-generation-sparkle { animation: none; }
}

/* ==========================================================================
   Frame Inspector / Editor Responsive Layout (Modal on Desktop, Bottom Sheet on Mobile)
   ========================================================================== */

.studio-editor-modal .studio-editor-content {
  max-width: 960px;
  width: 100%;
  max-height: 90vh;
  padding: 0;
  overflow: hidden;
}

.studio-editor-layout {
  display: grid;
  grid-template-columns: 1fr 340px;
  height: 100%;
  max-height: 85vh;
}

.studio-editor-canvas-pane {
  display: flex;
  flex-direction: column;
  background: #000;
  position: relative;
  min-height: 400px;
}

.studio-editor-canvas-wrapper {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  padding: 16px;
}

.studio-editor-img {
  max-width: 100%;
  max-height: 60vh;
  object-fit: contain;
  border-radius: var(--radius-sm);
}

.studio-editor-loader {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.75);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: #fff;
  z-index: 10;
}

.studio-editor-variants-bar {
  background: rgba(20, 20, 20, 0.95);
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.studio-editor-variants-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.studio-editor-subheading {
  font-size: 0.78rem;
  color: rgba(255, 255, 255, 0.7);
  font-weight: 500;
}

.studio-editor-variants-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.studio-variant-btn,
.studio-editor-variants-bar .secondary-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: var(--radius-pill);
  font-size: 0.78rem;
  font-weight: 500;
  text-decoration: none !important;
  cursor: pointer;
  transition: all var(--transition-fast);
  line-height: 1.2;
  box-sizing: border-box;
}

.studio-variant-btn svg,
.studio-variant-btn i,
.studio-editor-variants-bar .secondary-btn svg,
.studio-editor-variants-bar .secondary-btn i {
  width: 14px;
  height: 14px;
  margin: 0 !important;
  flex-shrink: 0;
}

.studio-variant-btn:active,
.studio-editor-variants-bar .secondary-btn:active {
  transform: scale(0.97);
}

/* "Скачать" secondary button */
.studio-variant-btn-secondary,
.studio-editor-variants-bar #studio-download-variant-btn {
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff !important;
  border: 1px solid rgba(255, 255, 255, 0.18);
}

.studio-variant-btn-secondary:hover,
.studio-editor-variants-bar #studio-download-variant-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  color: #ffffff !important;
  border-color: rgba(255, 255, 255, 0.3);
  text-decoration: none !important;
}

/* "Сделать текущей" primary action button */
.studio-variant-btn-primary,
.studio-editor-variants-bar #studio-set-current-variant-btn {
  background: var(--primary);
  border: 1px solid var(--primary);
  color: #ffffff !important;
  box-shadow: 0 2px 8px var(--primary-glow);
}

.studio-variant-btn-primary:hover,
.studio-editor-variants-bar #studio-set-current-variant-btn:hover {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
  color: #ffffff !important;
}

.studio-editor-variants-strip {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.studio-variant-chip {
  padding: 6px 12px;
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #fff;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all var(--transition-fast);
}

.studio-variant-chip:hover {
  background: rgba(255, 255, 255, 0.2);
}

.studio-variant-chip.active {
  background: var(--primary);
  border-color: var(--primary);
  box-shadow: 0 0 10px var(--primary-glow);
}

.studio-editor-side-pane {
  padding: 24px 20px;
  background: var(--bg-panel);
  border-left: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  gap: 16px;
  overflow-y: auto;
}

.studio-editor-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-right: 32px;
}

.studio-editor-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
}

.studio-style-toggle-bar { display: flex; justify-content: center; padding: 0 14px 12px; background: #000; }
.studio-style-toggle-bar .studio-variant-btn:disabled { opacity: .58; cursor: default; }
.studio-series-hint { display: flex; align-items: center; gap: 9px; margin: 0; padding: 8px; border-left: 3px solid var(--primary); border-radius: 8px; background: var(--bg-panel); color: var(--text-secondary); }
.studio-series-hint-thumb { width: 34px; height: 42px; flex: 0 0 34px; border: 1px solid var(--border-color); border-radius: 5px; object-fit: cover; background: var(--bg-secondary); }
.studio-series-hint-copy { display: flex; flex: 1 1 auto; flex-direction: column; gap: 2px; min-width: 0; line-height: 1.3; }
.studio-series-hint-copy strong { color: var(--text-primary); font-size: .76rem; }
.studio-series-hint-copy small { color: var(--text-secondary); font-size: .68rem; }
.studio-series-hint.is-disabled .studio-series-hint-thumb { opacity: .58; }

.studio-intent-badge {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: var(--radius-pill);
  background: var(--primary-glow);
  color: var(--primary);
}

.studio-editor-tabs-nav {
  display: flex;
  background: var(--bg-card);
  padding: 3px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border-color);
}

.studio-editor-tab-btn {
  flex: 1;
  text-align: center;
  padding: 8px 10px;
  border-radius: var(--radius-pill);
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.studio-editor-tab-btn.active {
  background: var(--bg-panel);
  color: var(--text-primary);
  box-shadow: 0 2px 6px rgba(0,0,0,0.06);
}

.studio-editor-tab-content {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.studio-tab-desc {
  font-size: 0.82rem;
  color: var(--text-secondary);
  line-height: 1.4;
}

.studio-action-cta {
  width: 100%;
  padding: 12px;
  border-radius: var(--radius-pill);
  font-weight: 600;
  font-size: 0.92rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

/* Responsive Bottom Sheet Adaptation for Mobile */
@media screen and (max-width: 768px) {
  .studio-editor-modal {
    align-items: flex-end !important;
    padding: 0 !important;
  }

  .studio-editor-modal .studio-editor-content {
    max-width: 100% !important;
    border-radius: 20px 20px 0 0 !important;
    min-height: 0;
    max-height: 92vh !important;
    max-height: 92dvh !important;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-y: contain;
  }

  .studio-editor-layout {
    display: flex;
    flex-direction: column;
    height: auto;
    max-height: none;
    overflow: visible;
  }

  .studio-editor-canvas-pane {
    min-height: 0;
    flex: 0 0 auto;
  }

  .studio-editor-canvas-wrapper {
    flex: 0 0 auto;
    min-height: 280px;
  }

  .studio-editor-img {
    max-height: 40vh;
    max-height: 40dvh;
  }

  .studio-editor-side-pane {
    border-left: none;
    border-top: 1px solid var(--border-color);
    padding: 18px 16px;
    overflow: visible;
    overscroll-behavior: auto;
  }

  .studio-editor-modal .lightbox-close-btn {
    position: sticky;
    top: 8px;
    align-self: flex-end;
    margin: 8px 8px -52px 0;
  }

  .studio-workspace {
    padding: 12px 14px 32px;
  }

  .studio-presets-grid {
    grid-auto-flow: column;
    grid-auto-columns: clamp(136px, 36vw, 164px);
    grid-template-columns: none;
    gap: 8px;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
  }
}

/* Model indicator watermark for test comparison */
.studio-editor-model-watermark {
  position: absolute;
  bottom: 24px;
  right: 24px;
  background: rgba(15, 23, 42, 0.85);
  color: #fff;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  pointer-events: none;
  z-index: 10;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
}

.studio-frame-model-badge {
  position: absolute;
  bottom: 6px;
  right: 6px;
  background: rgba(15, 23, 42, 0.85);
  color: #fff;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.68rem;
  font-weight: 600;
  pointer-events: none;
  z-index: 3;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  border: 1px solid rgba(255, 255, 255, 0.15);
  max-width: calc(100% - 12px);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}



/* Keep editor controls above home indicators and on-screen keyboard insets. */
@media screen and (max-width: 768px) {
  .studio-editor-side-pane { padding-bottom: calc(18px + env(safe-area-inset-bottom, 0px)); }
  .studio-editor-content { overscroll-behavior-y: contain; }
}

/* Shared product editor uses the existing paid generation pipeline. */
.studio-mode-toggle { flex-wrap: wrap; max-width: 100%; }
.studio-card-v2 { display: flex; flex-direction: column; gap: 20px; min-width: 0; }
.studio-v2-block { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.studio-v2-block .studio-field-header { gap: 8px; flex-wrap: wrap; }
.studio-v2-copy-actions { display: flex; align-items: center; flex-wrap: nowrap; gap: 8px; }
.studio-v2-copy-actions .studio-scene-idea-btn { min-width: 0; padding-inline: 12px; }
.studio-v2-copy-actions .studio-scene-idea-btn svg { flex-shrink: 0; }
.studio-v2-copy-actions > .studio-hint { min-width: 0; flex: 0 1 auto; }
.studio-v2-copy-actions .secondary-btn { padding: 8px 12px; font-size: .85rem; }
.studio-v2-error { margin: 0; color: var(--error, #d64040); font-size: .85rem; }
.studio-v2-settings { display: flex; flex-direction: column; gap: 18px; }
.studio-v2-active .studio-action-row { justify-content: flex-end; }
.studio-v2-active .studio-primary-cta { width: 100%; }
@media (max-width: 540px) {
  .studio-mode-btn { padding: 9px 10px; }
  .studio-v2-copy-actions button { min-height: 44px; }
}
.studio-v2-options { display: flex; flex-direction: column; gap: 2px; }
.studio-v2-switch { display: flex; align-items: center; justify-content: space-between; gap: 18px; min-height: 64px; padding: 8px 0; cursor: pointer; }
.studio-v2-switch > span { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.studio-v2-switch strong { color: var(--text-primary); font-size: .9rem; font-weight: 600; }
.studio-v2-switch small { color: var(--text-secondary); font-size: .78rem; line-height: 1.4; }
.studio-v2-switch input { appearance: none; -webkit-appearance: none; flex-shrink: 0; width: 44px; height: 26px; padding: 3px; margin: 0; border: 1px solid var(--border-color); border-radius: 16px; background: var(--bg-secondary); cursor: pointer; transition: background .15s; }
.studio-v2-switch input::before { content: ''; display: block; width: 18px; height: 18px; border-radius: 50%; background: var(--text-secondary); transition: transform .15s; }
.studio-v2-switch input:checked { background: var(--primary); border-color: var(--primary); }
.studio-v2-switch input:checked::before { background: white; transform: translateX(18px); }
.studio-v2-switch input:disabled { opacity: .45; cursor: default; }
.studio-v2-switch:has(input:focus-visible) { outline: 2px solid var(--primary); outline-offset: 3px; border-radius: 6px; }
@media (max-width: 540px) {
  .studio-v2-switch { min-height: 64px; }
  .studio-v2-options { gap: 0; }
}
@media (prefers-reduced-motion: reduce) { .studio-v2-switch input, .studio-v2-switch input::before { transition: none; } }
/* Keep the reference library scrollable instead of compressing all 35 cards. */
.studio-examples-content { max-height: 88dvh; overflow: hidden; }
.studio-examples-header { flex: 0 0 auto; }
.studio-examples-grid { min-height: 0; grid-auto-rows: max-content; align-content: start; overscroll-behavior: contain; }
.studio-example-card { align-self: start; }
.studio-example-thumb-wrap, .studio-example-info { flex-shrink: 0; }
@media (max-width: 540px) {
  .studio-examples-modal { padding: 12px; }
  .studio-examples-content { padding: 16px; max-height: 90dvh; }
  .studio-examples-title { font-size: 1.05rem; }
  .studio-examples-title-row { gap: 7px; }
  .studio-examples-title-row > i, .studio-examples-title-row > svg { display: none; }
  .studio-examples-subtitle { font-size: .8rem; }
  .studio-examples-grid { max-height: none; overflow-y: auto; }
  .studio-examples-content .lightbox-close-btn { width: 40px; height: 40px; top: 8px; right: 8px; }
}
@media (max-width: 540px) {
  .studio-v2-active .studio-product-title-input,
  .studio-v2-active .studio-input,
  .studio-v2-active .studio-select,
  .studio-v2-active .studio-textarea { font-size: 16px; }
  .studio-v2-active .studio-format-btn,
  .studio-examples-content .lightbox-close-btn { min-width: 44px; min-height: 44px; }
}
@media (max-width: 640px) {
  /* Nine formats would take several rows; scroll them in one line instead. */
  .studio-format-selector { flex-wrap: nowrap; overflow-x: auto; width: 100%; padding: 0 2px 4px; scrollbar-width: thin; overscroll-behavior-x: contain; }
  .studio-format-btn { flex: none; min-height: 44px; }
  .studio-format-scroll.has-more-formats::after { content: ''; position: absolute; top: 0; bottom: 4px; right: 0; width: 72px; background: linear-gradient(to right, transparent, var(--bg-card) 65%); pointer-events: none; }
  .studio-format-next { display: inline-flex; position: absolute; top: 0; right: 0; z-index: 1; width: 44px; height: 44px; align-items: center; justify-content: center; border: 1px solid var(--border-color); border-radius: 50%; background: var(--bg-panel); color: var(--text-primary); cursor: pointer; }
  .studio-format-next svg { width: 18px; height: 18px; }
  .studio-format-next:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
}

/* Card setup: product presentation, visual style, then editable copy. */
.studio-v2-step { padding: 18px 0; border-bottom: 1px solid var(--border-color); gap: 8px; }
.studio-v2-step:first-child { padding-top: 0; }
.studio-v2-step-heading { display: flex; align-items: center; gap: 10px; min-width: 0; flex-wrap: wrap; }
.studio-v2-step-heading h3 { margin: 0; font-size: 1rem; font-weight: 600; line-height: 1.4; }
.studio-frame-design-tag { color: var(--text-secondary); font-size: .72rem; }
.studio-v2-step > .studio-hint, .studio-v2-presentation-fields > .studio-hint { margin: 0; line-height: 1.5; }
.studio-v2-presentation-fields, .studio-v2-reference-fields { display: flex; flex-direction: column; gap: 12px; }
.studio-v2-presentation-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.studio-v2-preset { display: flex; flex-direction: column; align-items: stretch; justify-content: flex-start; min-width: 0; padding: 0; overflow: hidden; border: 1px solid var(--border-color); border-radius: 10px; background: var(--bg-panel); color: var(--text-primary); font: inherit; text-align: left; cursor: pointer; scroll-snap-align: start; }
.studio-v2-preset img { display: block; width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 9px 9px 0 0; background: var(--bg-secondary); }
.studio-v2-preset span { display: block; padding: 10px; font-size: .8rem; line-height: 1.35; font-weight: 500; overflow-wrap: anywhere; }
.studio-v2-preset[aria-pressed="true"] { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary); }
.studio-v2-preset[aria-pressed="true"] span { color: var(--primary); }
.studio-v2-preset:hover { border-color: var(--primary); }
.studio-v2-preset:focus-visible, .studio-v2-reference-action:focus-visible { outline: 2px solid var(--primary); outline-offset: 3px; }
.studio-v2-preset:disabled, .studio-v2-reference-action:disabled { opacity: .5; cursor: default; }
/* Two reference sources share one stable layout, including saved series designs. */
.studio-v2-reference-sources { display: grid; grid-template-columns: minmax(0, .78fr) 28px minmax(0, 1.5fr); gap: 14px; align-items: stretch; }
.studio-v2-reference-source { display: flex; min-width: 0; }
.studio-v2-reference-upload, .studio-v2-reference-picker, .studio-v2-reference-selected { box-sizing: border-box; min-width: 0; border: 1px solid var(--border-color); border-radius: 14px; background: var(--bg-panel); }
.studio-v2-reference-upload { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; width: 100%; min-height: 300px; padding: 24px; border-style: dashed; color: var(--text-primary); font: inherit; text-align: center; cursor: pointer; }
.studio-v2-reference-upload small { color: var(--text-secondary); line-height: 1.5; }
.studio-v2-reference-upload:hover { border-color: var(--primary); }
.studio-v2-reference-upload:focus-visible { outline: 2px solid var(--primary); outline-offset: 3px; }
.studio-v2-reference-upload:disabled { opacity: .5; cursor: default; }
.studio-v2-reference-picker { display: flex; flex-direction: column; gap: 10px; padding: 16px; }
.studio-v2-reference-options { display: flex; flex-direction: column; gap: 12px; min-width: 0; flex: 1; }
.studio-v2-reference-grid { display: grid; grid-auto-flow: column; grid-auto-columns: 43%; gap: 8px; min-width: 0; overflow-x: auto; scroll-snap-type: x proximity; scrollbar-width: thin; padding: 3px 3px 10px; }
.studio-v2-reference-option { display: flex; flex-direction: column; align-items: stretch; justify-content: flex-start; position: relative; min-width: 0; padding: 4px; border: 1px solid var(--border-color); border-radius: 10px; background: var(--bg-panel); color: var(--text-primary); font: inherit; text-align: left; cursor: pointer; scroll-snap-align: start; }
.studio-v2-reference-option img { display: block; width: 100%; aspect-ratio: 3 / 4; object-fit: contain; background: var(--bg-secondary); border-radius: 6px; }
.studio-v2-reference-option[aria-pressed="true"] { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary); }
.studio-v2-reference-option:hover { border-color: var(--primary); }
.studio-v2-reference-option:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.studio-v2-reference-option:disabled { opacity: .5; cursor: default; }
.studio-v2-reference-options > [data-v2-all] { width: 100%; margin-top: auto; }
.studio-v2-reference-selected { position: relative; display: flex; flex-direction: column; align-items: stretch; gap: 12px; width: 100%; padding: 16px; }
.studio-v2-reference-clear { position: absolute; top: 20px; right: 20px; z-index: 1; display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; padding: 0; border: 1px solid var(--border-color); border-radius: 50%; background: var(--bg-panel); color: var(--text-primary); cursor: pointer; }
.studio-v2-reference-clear:hover { border-color: var(--primary); background: var(--bg-secondary); }
.studio-v2-reference-clear:focus-visible { outline: 2px solid var(--primary); outline-offset: 3px; }
.studio-v2-reference-clear:disabled { opacity: .5; cursor: default; }
.studio-v2-reference-selected > img { display: block; width: min(100%, 240px); aspect-ratio: 3 / 4; height: auto; max-height: 320px; margin-inline: auto; object-fit: contain; border-radius: 8px; background: var(--bg-secondary); }
.studio-v2-reference-selected > span { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.studio-v2-reference-selected strong { font-size: .88rem; font-weight: 600; overflow-wrap: anywhere; }
.studio-v2-reference-selected small { color: var(--text-secondary); font-size: .78rem; line-height: 1.4; }
.studio-v2-presentation-picker { display: flex; flex-direction: column; gap: 10px; }
.studio-v2-reference-selected > button { min-height: 44px; }
.studio-v2-reference-action { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 10px 14px; border: 1px solid var(--border-color); border-radius: 9px; background: var(--bg-panel); color: var(--text-primary); font: inherit; font-size: .85rem; cursor: pointer; }
.studio-v2-reference-action svg { flex: none; }
.studio-v2-reference-action:hover { border-color: var(--primary); background: var(--bg-secondary); }
.studio-example-selected { position: absolute; bottom: 8px; left: 8px; border-radius: 20px; padding: 5px 9px; background: var(--primary); color: white; font-size: .72rem; font-weight: 600; }
@media (min-width: 641px) {
  .studio-v2-presentation-grid { grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 9.6px; }
  .studio-v2-reference-upload { min-height: 220px; }
  .studio-v2-reference-grid { grid-auto-columns: 21.5%; }
}
@media (max-width: 640px) {
  .studio-v2-presentation-grid {
    grid-auto-flow: column;
    grid-auto-columns: clamp(136px, 36vw, 164px);
    grid-template-columns: none;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    padding: 2px 3px 8px;
  }
  .studio-v2-step-heading h3 { font-size: .94rem; }
  .studio-v2-reference-sources { grid-template-columns: minmax(0, 1fr); }
  .studio-v2-reference-upload { min-height: 180px; }
  .studio-v2-reference-grid { grid-auto-columns: 46%; }

}

/* Keep result controls comfortable to tap, including narrow phone screens. */
@media (max-width: 768px) {
  .studio-editor-modal .lightbox-close-btn { width: 44px; height: 44px; min-width: 44px; min-height: 44px; }
  .studio-editor-canvas-pane, .studio-editor-side-pane { min-width: 0; }
  .studio-editor-variants-header { flex-wrap: wrap; gap: 8px; }
  .studio-editor-variants-actions { flex-wrap: wrap; max-width: 100%; }
  .studio-editor-modal .studio-variant-btn,
  .studio-editor-modal .studio-variant-chip,
  .studio-editor-modal .studio-editor-tab-btn,
  .studio-editor-modal .studio-select,
  .studio-editor-modal .studio-action-cta { min-height: 44px; }
  .studio-editor-modal .studio-variant-chip { min-width: 44px; }
  .studio-editor-modal .studio-textarea,
  .studio-editor-modal .studio-select { font-size: 16px; }
  .studio-editor-side-pane { overscroll-behavior: auto; }
}

.studio-v2-setting { min-width: 0; }
.studio-v2-setting + .studio-v2-setting { margin-top: 16px; padding-top: 8px; border-top: 1px solid var(--border-color); }
.studio-v2-setting-fields { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.studio-v2-setting-fields textarea { width: 100%; box-sizing: border-box; resize: vertical; min-height: 96px; line-height: 1.5; }
.studio-v2-setting-fields button { min-height: 44px; }

/* Preserve readable scene choices when the app lives in a narrow desktop panel. */
@container (max-width: 700px) {
  .studio-v2-presentation-grid { grid-auto-flow: column; grid-auto-columns: 144px; grid-template-columns: none; overflow-x: auto; scroll-snap-type: x proximity; padding: 2px 3px 8px; }
  .studio-v2-reference-sources { grid-template-columns: minmax(0, 1fr); }
}
.studio-v2-reference-sources:has(.studio-v2-reference-picker.hidden) { grid-template-columns: minmax(0, 1fr); }

/* The same limit notice as other chats, outside the hideable Studio composer. */
.studio-composer-notice-slot { flex-shrink: 0; width: 100%; max-width: 712px; margin: 0 auto 8px; }
.studio-composer-notice-slot .chat-composer-notice { box-sizing: border-box; }
/* Invitation in historical image chats. */
.studio-legacy-banner { display: flex; align-items: center; gap: 20px; padding: 16px 20px; margin: 12px 24px 0; border: 1px solid var(--border-color); border-radius: 16px; background: var(--bg-surface); }
.studio-legacy-banner strong { font-size: 15px; }
.studio-legacy-banner p { margin: 4px 0 0; color: var(--text-secondary); font-size: 13px; line-height: 1.5; }
.studio-legacy-banner a { flex-shrink: 0; text-decoration: none; padding: 10px 18px; border-radius: 12px; }
@media (max-width: 600px) {
  .studio-legacy-banner { margin: 8px 12px 0; padding: 12px; gap: 12px; }
  .studio-legacy-banner p { font-size: 12px; }
  .studio-legacy-banner a { padding: 10px 12px; font-size: 13px; }
}
.studio-legacy-banner[hidden], .studio-format-btn[hidden] { display: none; }

/* Product editor. */
.studio-product-editor .studio-card-v2 { gap: 26px; }
.studio-product-editor .studio-v2-step { padding: 0; border-bottom: 0; gap: 16px; }
.studio-product-editor .studio-v2-step-heading h3 { font-size: 1.05rem; line-height: 1.4; }
.studio-product-editor .studio-v2-switch small { display: none; }
.studio-product-editor .studio-editor-design-choices { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 10px; }
.studio-editor-design-choices button { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 9px; min-height: 84px; padding: 14px 8px; border: 1px solid var(--border-color); border-radius: 14px; background: var(--bg-panel); color: var(--text-primary); font: inherit; font-size: .85rem; cursor: pointer; }
.studio-editor-design-choices button > svg { width: 18px; height: 18px; }
.studio-editor-design-choices button[aria-pressed="true"] { color: var(--primary); border-color: var(--primary); background: color-mix(in srgb, var(--primary) 8%, var(--bg-panel)); box-shadow: 0 0 0 1px var(--primary); }
.studio-editor-design-choices button:focus-visible { outline: 2px solid var(--primary); outline-offset: 3px; }
.studio-editor-design-choices button:disabled { opacity: .5; cursor: default; }
.studio-product-editor .studio-v2-reference-sources { grid-template-columns: minmax(0,1fr); gap: 12px; }
.studio-product-editor .studio-v2-reference-picker { padding: 0; border: 0; border-radius: 0; background: transparent; }
.studio-product-editor .studio-v2-reference-grid { grid-auto-columns: calc((100% - 40px) / 4.4); gap: 10px; }
.studio-product-editor .studio-v2-reference-selected { display: grid; grid-template-columns: 64px minmax(0,1fr) 44px; align-items: center; column-gap: 12px; padding: 12px; }
.studio-product-editor .studio-v2-reference-selected > img { grid-column: 1; grid-row: 1 / 3; width: 64px; max-height: 86px; }
.studio-product-editor .studio-v2-reference-selected > span { grid-column: 2; grid-row: 1; padding-right: 0; }
.studio-product-editor .studio-v2-reference-selected-upload { grid-column: 2; grid-row: 2; }
.studio-product-editor .studio-editor-apply-style { grid-column: 2; grid-row: 2; }
.studio-product-editor[data-editor-design="auto"] [data-v2-reference-selected-upload] { display: none; }
.studio-product-editor .studio-v2-reference-selected > .studio-v2-reference-clear { position: static; grid-column: 3; grid-row: 1 / 3; }
.studio-product-editor[data-editor-design="library"] [data-v2-reference-selected-upload] { display: none; }
.studio-product-editor .studio-v2-reference-upload { min-height: 170px; }
.studio-product-editor .studio-v2-options { gap: 0; }
.studio-product-editor .studio-v2-setting { position: relative; padding: 0; border-top: 1px solid var(--border-color); }
.studio-product-editor .studio-v2-setting + .studio-v2-setting { margin-top: 18px; padding-top: 0; }
.studio-product-editor .studio-v2-switch { min-height: 58px; gap: 12px; padding: 12px 64px 12px 0; }
.studio-product-editor .studio-v2-switch strong,
.studio-product-editor #studio-prompt-field .studio-field-label { font-size: .85rem; font-weight: 600; }
.studio-product-editor .studio-v2-switch > input { position: absolute; right: 0; top: 16px; }
.studio-product-editor .studio-v2-settings { gap: 18px; }
.studio-product-editor .studio-product-meta-fields > .studio-category-select-wrapper { min-width: 0; }
/* Product photos and editable metadata share one quiet surface. */
.studio-product-editor .studio-source-section { padding: 16px; gap: 12px; border: 1px solid var(--border-color); border-radius: var(--radius-md); background: var(--bg-card); }
.studio-product-editor .studio-source-section .studio-section-header { flex-direction: column; align-items: flex-start; gap: 4px; }
.studio-product-editor #studio-sources-count { background: var(--bg-panel); color: var(--text-secondary); font-weight: 500; }
.studio-product-editor #studio-sources-count::after { content: ' фото'; }
.studio-product-editor .studio-source-strip { gap: 10px; padding: 2px 0 6px; }
.studio-product-editor .studio-source-card,
.studio-product-editor .studio-source-pending,
.studio-product-editor .studio-add-source-btn { width: 168px; height: 168px; min-width: 168px; border-radius: 12px; }
.studio-product-editor .studio-add-source-btn { background: var(--bg-panel); border-width: 1px; }
.studio-product-editor .studio-source-card.is-primary { box-shadow: none; }
.studio-product-editor .studio-product-title-row { padding: 0; margin-top: 0; border: 0; border-radius: 0; background: transparent; }
.studio-product-editor .studio-product-title-label { display: none; }
.studio-product-editor .studio-product-meta-fields { flex-direction: row; flex-wrap: wrap; align-items: start; gap: 8px; }
/* Match native-control metrics across desktop browsers and iOS Safari. */
.studio-product-editor .studio-product-title-input-wrapper,
.studio-product-editor .studio-category-select-wrapper select.studio-category-select { height: 44px; min-height: 44px; }
.studio-product-editor .studio-product-title-input-wrapper { flex: 0 1 26rem; min-width: 0; padding: 8px 12px; border-color: var(--border-color); border-radius: 12px; background: var(--bg-panel); }
.studio-product-editor .studio-product-title-input { min-width: 0; min-height: 0; padding: 0; line-height: 24px; -webkit-appearance: none; appearance: none; font-size: .9rem; }
.studio-product-editor .studio-product-title-input-wrapper:focus-within { border-color: var(--primary); }
.studio-product-editor .studio-product-meta-fields > .studio-category-select-wrapper { flex: 0 1 20rem; width: auto; }
.studio-product-editor .studio-category-select-wrapper::after { content: ''; position: absolute; right: 16px; top: 50%; width: 8px; height: 8px; border-right: 2px solid var(--text-primary); border-bottom: 2px solid var(--text-primary); transform: translateY(-70%) rotate(45deg); pointer-events: none; }
.studio-product-editor .studio-category-select-wrapper select.studio-category-select { display: block; -webkit-appearance: none; appearance: none; padding: 8px 36px 8px 12px; line-height: 24px; border-color: var(--border-color); border-radius: 12px; background: var(--bg-panel); font-size: .85rem; }
.studio-product-editor .studio-category-select-wrapper select.studio-category-select:focus { border-color: var(--primary); }
@container (max-width: 700px) {
  .studio-product-editor .studio-v2-reference-grid { grid-auto-columns: 43%; }
}
@media (max-width: 640px) {
  .studio-product-editor .studio-editor-design-choices { gap: 8px; }
  .studio-editor-design-choices button { min-height: 80px; padding: 12px 4px; }
  .studio-product-editor .studio-v2-reference-grid { grid-auto-columns: 43%; }
  .studio-product-editor .studio-v2-switch { padding-right: 56px; }
  .studio-product-editor .studio-v2-reference-selected { grid-template-columns: 52px minmax(0,1fr) 44px; gap: 8px; }
  .studio-product-editor .studio-v2-reference-selected > img { width: 52px; }
  .studio-product-editor .studio-source-section { padding: 14px; }
  .studio-product-editor .studio-product-title-input-wrapper,
  .studio-product-editor .studio-product-meta-fields > .studio-category-select-wrapper { flex-basis: 100%; width: 100%; }
  .studio-product-editor .studio-product-title-input,
  .studio-product-editor .studio-category-select-wrapper select.studio-category-select { font-size: 16px; }
  .studio-product-editor .studio-product-title-loader { white-space: normal; font-size: .75rem; }
}

/* Public AI Studio chat: finished cards only */
.public-studio-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  align-items: start;
  gap: 16px;
  box-sizing: border-box;
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
}

/* Same lift on hover as the owner's frame cards (.studio-frame-card). */
.public-studio-card {
  margin: 0;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--bg-card);
  overflow: hidden;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast), border-color var(--transition-fast);
}

.public-studio-card:hover,
.public-studio-card:focus-within {
  transform: translateY(-3px);
  border-color: var(--primary);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
}

.public-studio-card-preview {
  position: relative;
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: none;
  cursor: zoom-in;
}

.public-studio-card-preview:focus-visible {
  outline: none;
}

.public-studio-card-badge {
  position: absolute;
  right: 8px;
  bottom: 8px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: var(--radius-pill);
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  font-size: .75rem;
  font-weight: 500;
}

.public-studio-card-badge svg {
  width: 12px;
  height: 12px;
}

.public-studio-card-preview img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 3 / 4;
  object-fit: contain;
}

@media (max-width: 600px) {
  .public-studio-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }
}

/* Studio owns edit fields; the reusable viewer owns the surrounding modal. */
.image-viewer-edit-panel .studio-editor-side-pane { padding: 0; border: 0; overflow: visible; background: transparent; }
.image-viewer-edit-panel .studio-editor-tabs-nav { margin: 4px 0; }
.image-viewer-edit-panel .studio-editor-tab-btn { min-height: 44px; min-width: 0; padding: 8px 4px; font-size: .78rem; }
.image-viewer-edit-panel .studio-action-cta { min-height: 48px; }
.generation-feedback {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  font-size: 12px;
  color: var(--text-secondary);
}
.generation-feedback .msg-action-btn { width: auto; padding: 5px 9px; }
.generation-feedback button[aria-pressed="true"] { color: var(--text-primary); outline: 1px solid currentColor; }
