/* AiGenius Web App — Apple/Linear aesthetic */

:root {
  --font-sans: "Geist", -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  --font-mono: "Geist Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --font-serif: "Instrument Serif", "Times New Roman", serif;

  --bg: #F4F4F2;
  --bg-elev: #FFFFFF;
  --bg-sunken: #ECECEA;

  --ink: #0B0B0F;
  --ink-2: #3A3A40;
  --ink-3: #6E6E76;
  --ink-4: #A6A6AD;
  --ink-5: #D5D5D8;

  --hair: rgba(11,11,15,0.07);
  --hair-strong: rgba(11,11,15,0.12);

  --accent: #7C5DF3;
  --accent-rgb: 124,93,243;
  --accent-soft: oklch(94% 0.04 282);
  --accent-ink: oklch(28% 0.10 282);

  --t-video: oklch(70% 0.14 25);
  --t-photo: oklch(70% 0.13 145);
  --t-music: oklch(72% 0.13 240);
  --t-chat:  oklch(70% 0.13 282);

  --t-video-soft: #FFF0ED;
  --t-photo-soft: #EDFAF3;
  --t-music-soft: #EDF5FF;
  --t-chat-soft:  #F0EDFF;

  --shadow-1: 0 1px 2px rgba(11,11,15,0.04), 0 1px 3px rgba(11,11,15,0.04);
  --shadow-2: 0 2px 6px rgba(11,11,15,0.05), 0 8px 24px rgba(11,11,15,0.06);
  --border: rgba(11,11,15,0.10);

  --nav-height: 80px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

/* Light theme (explicit — same as :root defaults) */
.tg-light {
  --bg: #F4F4F2;
  --bg-elev: #FFFFFF;
  --bg-sunken: #ECECEA;
  --ink: #0B0B0F;
  --ink-2: #3A3A40;
  --ink-3: #6E6E76;
  --ink-4: #A6A6AD;
  --ink-5: #D5D5D8;
  --hair: rgba(11,11,15,0.07);
  --hair-strong: rgba(11,11,15,0.12);
  --accent-soft: oklch(94% 0.04 282);
  --accent-ink: oklch(28% 0.10 282);
  --border: rgba(11,11,15,0.10);
  --t-video-soft: #FFF0ED;
  --t-photo-soft: #EDFAF3;
  --t-music-soft: #EDF5FF;
  --t-chat-soft:  #F0EDFF;
  --shadow-1: 0 1px 2px rgba(11,11,15,0.04), 0 1px 3px rgba(11,11,15,0.04);
  --shadow-2: 0 2px 6px rgba(11,11,15,0.05), 0 8px 24px rgba(11,11,15,0.06);
}

/* Dark theme */
.tg-dark {
  --bg: #0A0A0F;
  --bg-elev: #15151B;
  --bg-sunken: #1E1E25;
  --ink: #F4F4F2;
  --ink-2: #D5D5D8;
  --ink-3: #8E8E96;
  --ink-4: #5A5A62;
  --ink-5: #2E2E36;
  --hair: rgba(255,255,255,0.06);
  --hair-strong: rgba(255,255,255,0.12);
  --border: rgba(255,255,255,0.10);
  --accent-soft: rgba(124,93,243,0.18);
  --t-video-soft: rgba(231,93,65,0.15);
  --t-photo-soft: rgba(52,175,100,0.15);
  --t-music-soft: rgba(64,143,229,0.15);
  --t-chat-soft:  rgba(124,93,243,0.15);
  --shadow-1: 0 1px 2px rgba(0,0,0,0.5);
  --shadow-2: 0 8px 24px rgba(0,0,0,0.4);
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; -webkit-touch-callout: none; }
/* Restore long-press for images — needed for iOS "Save to Photos" */
img { -webkit-touch-callout: default !important; }
html, body { height: 100%; overflow: hidden; overscroll-behavior: none; }
body {
  font-family: var(--font-sans);
  color: var(--ink);
  background: var(--tg-theme-bg-color, var(--bg));
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow: hidden;
}

/* ── Splash ── */
.splash {
  position: fixed; inset: 0;
  background: var(--bg);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 32px; z-index: 1000;
  transition: opacity 0.4s ease, transform 0.4s ease;
}
.splash.out { opacity: 0; transform: scale(0.96); pointer-events: none; }
.splash-logo { display: flex; align-items: center; gap: 12px; }
.splash-icon {
  width: 56px; height: 56px; border-radius: 16px;
  background: var(--accent);
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 8px 24px rgba(124,93,243,0.3);
}
.splash-name { font-size: 28px; font-weight: 700; letter-spacing: -0.5px; }
.splash-loader { width: 120px; height: 3px; background: var(--bg-sunken); border-radius: 99px; overflow: hidden; }
.splash-bar {
  height: 100%; background: var(--accent); border-radius: 99px;
  animation: splashLoad 1.2s ease forwards;
}
@keyframes splashLoad { from { width: 0 } to { width: 100% } }

/* ── App shell ── */
.app { position: fixed; inset: 0; display: flex; flex-direction: column; overflow: hidden; height: 100dvh; height: 100vh; }
.hidden { display: none !important; }
/* ── Nav back — universal clean back arrow ── */
.nav-back {
  width: 32px; height: 32px; border: none; background: none;
  color: var(--ink-3); display: flex; align-items: center;
  justify-content: center; cursor: pointer; flex-shrink: 0;
  padding: 0; -webkit-tap-highlight-color: transparent;
}
.nav-back:active { opacity: .4; }
.back-chevron { display: block; }


/* ── Screens ── */
.screen {
  position: absolute; inset: 0;
  bottom: calc(var(--nav-height) + var(--safe-bottom));
  display: flex; flex-direction: column; overflow: hidden;
  background: var(--tg-theme-bg-color, var(--bg));
  visibility: hidden; pointer-events: none;
  transform: translateZ(0); /* GPU layer for iOS */
}
.screen.active {
  visibility: visible; pointer-events: auto;
}
.screen-scroll { flex:1; overflow-y:auto; -webkit-overflow-scrolling:touch; background:var(--tg-theme-bg-color, var(--bg)); }

/* ── HOME ── */
.home-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  padding: 20px 20px 0;
}
.home-eyebrow {
  font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--ink-4); margin-bottom: 6px;
}
.home-title { font-size: 26px; font-weight: 700; letter-spacing: -0.6px; line-height: 1.15; }
.wave-hand { display: inline-block; animation: wave 2s ease-in-out 0.5s; transform-origin: 70% 70%; }
@keyframes wave {
  0%,100% { transform: rotate(0) }
  20% { transform: rotate(-15deg) }
  40% { transform: rotate(10deg) }
  60% { transform: rotate(-10deg) }
  80% { transform: rotate(5deg) }
}
.avatar-btn { background: none; border: none; cursor: pointer; }
.avatar {
  width: 38px; height: 38px; border-radius: 50%;
  background: var(--accent); color: white;
  font-size: 16px; font-weight: 600;
  display: flex; align-items: center; justify-content: center;
}

/* Balance card */
.balance-card {
  margin: 16px 20px 0;
  background: linear-gradient(135deg, #6B46F0 0%, #9B6BF2 50%, #7C5DF3 100%);
  color: white; border-radius: 22px; padding: 20px 20px 16px;
  cursor: pointer; overflow: hidden; position: relative;
  box-shadow: 0 8px 28px rgba(124,93,243,0.40);
}
.balance-card::before {
  content:''; position:absolute; top:-40px; right:-30px;
  width:130px; height:130px; border-radius:50%;
  background:rgba(255,255,255,0.08);
}
.balance-card::after {
  content:''; position:absolute; bottom:-25px; right:50px;
  width:90px; height:90px; border-radius:50%;
  background:rgba(255,255,255,0.05);
}
.balance-card-inner { display:flex; justify-content:space-between; align-items:flex-start; margin-bottom:14px; position:relative; z-index:1; }
.balance-label { font-size:10px; color:rgba(255,255,255,0.65); font-weight:500; margin-bottom:6px; letter-spacing:0.08em; text-transform:uppercase; font-family:var(--font-mono); }
.balance-amount { font-size:38px; font-weight:700; letter-spacing:-1.2px; font-variant-numeric:tabular-nums; line-height:1; }
.balance-right { text-align:right; }
.balance-badge {
  display:inline-block; padding:5px 12px; border-radius:99px;
  font-size:11px; font-weight:600; letter-spacing:0.03em;
  background:rgba(255,255,255,0.22); backdrop-filter:blur(8px);
}
.balance-badge.premium { background:linear-gradient(135deg,#f59e0b,#f97316); }
.balance-hint { font-size:11px; color:rgba(255,255,255,0.5); margin-top:5px; font-family:var(--font-mono); }
.balance-track { background:rgba(255,255,255,0.18); height:4px; border-radius:99px; overflow:hidden; position:relative; z-index:1; }
.balance-fill { height:100%; background:rgba(255,255,255,0.75); border-radius:99px; transition:width 0.6s ease; }

/* Section headers */
.section-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px 10px; }
.section-title { font-size: 15px; font-weight: 600; letter-spacing: -0.2px; }
.section-action { font-size: 12px; color: var(--ink-3); font-family: var(--font-mono); }

/* Mode grid */
/* Mode scroll wrapper */
.mode-scroll-wrap {
  overflow-x: auto;
  overflow-y: hidden;
  padding: 0 20px 4px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.mode-scroll-wrap::-webkit-scrollbar { display: none; }

/* Mode grid — horizontal row, fixed tile size */
.mode-grid {
  display: flex;
  flex-direction: row;
  gap: 10px;
  width: max-content;
}
.mode-tile {
  border-radius: 20px; padding: 16px 8px 14px;
  display: flex; flex-direction: column; align-items: center;
  gap: 10px; cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  width: 80px; flex-shrink: 0;
  aspect-ratio: 1; position: relative; overflow: hidden;
}
.mode-tile:active { transform: scale(0.93); }

/* Chat — violet */
.mode-tile.mode-chat {
  background: linear-gradient(145deg, #7C5DF3, #9B7FF5);
  box-shadow: 0 4px 16px rgba(124,93,243,0.35);
}
/* Photo — emerald */
.mode-tile.mode-photo {
  background: linear-gradient(145deg, #10B981, #34D399);
  box-shadow: 0 4px 16px rgba(16,185,129,0.35);
}
/* Video — coral */
.mode-tile.mode-video {
  background: linear-gradient(145deg, #EF4444, #F97316);
  box-shadow: 0 4px 16px rgba(239,68,68,0.35);
}
/* Music — sky */
.mode-tile.mode-music {
  background: linear-gradient(145deg, #3B82F6, #60A5FA);
  box-shadow: 0 4px 16px rgba(59,130,246,0.35);
}
.mode-icon {
  width: 38px; height: 38px; border-radius: 12px;
  background: rgba(255,255,255,0.25);
  display: flex; align-items: center; justify-content: center;
  color: white;
}
.mode-label { font-size: 12px; font-weight: 600; letter-spacing: -0.1px; color: white; }

/* Tools list */
.tools-list { padding: 0 20px; display: flex; flex-direction: column; gap: 2px; }
.tool-row {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px; background: var(--bg-sunken);
  border-radius: 14px; cursor: pointer;
  transition: background 0.15s;
}
.tool-row:first-child { border-radius: 14px 14px 6px 6px; }
.tool-row:last-child  { border-radius: 6px 6px 14px 14px; }
.tool-row:active { background: var(--bg-sunken); }
.tool-icon {
  width: 30px; height: 30px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.tool-icon-neutral { background: var(--bg-sunken); color: var(--ink-3); }
.tool-info { flex: 1; }
.tool-name { font-size: 13px; font-weight: 500; letter-spacing: -0.1px; }
.tool-desc { font-size: 11px; color: var(--ink-4); margin-top: 1px; }
.tool-chev { color: var(--ink-5); flex-shrink: 0; }

/* History */
.home-history-list { padding: 0 20px; min-height: 60px; }
.history-empty {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  padding: 24px 0; color: var(--ink-4); font-size: 13px;
}
.history-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 0; border-bottom: 0.5px solid var(--hair);
  cursor: pointer;
}
.history-thumb {
  width: 44px; height: 44px; border-radius: 10px;
  background: var(--bg-sunken); overflow: hidden; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}
.history-thumb img { width: 100%; height: 100%; object-fit: cover; }
.history-info { flex: 1; min-width: 0; }
.history-prompt { font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.history-meta { font-size: 11px; color: var(--ink-4); margin-top: 2px; font-family: var(--font-mono); }

/* ── CHAT ── */
.chat-topbar {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px;
  background: var(--bg); border-bottom: 0.5px solid var(--hair);
  flex-shrink: 0;
}
.chat-model-btn {
  display: flex; align-items: center; gap: 5px;
  background: var(--bg-sunken); padding: 6px 12px; border-radius: 99px;
  font-size: 13px; font-weight: 500; cursor: pointer;
  max-width: 160px; overflow: hidden;
}
.chat-model-btn span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-topbar-mode { font-size: 12px; color: var(--ink-4); font-family: var(--font-mono); margin-left: auto; }
.icon-btn {
  width: 32px; height: 32px; border-radius: 9px; border: none;
  background: var(--bg-sunken); color: var(--ink-3);
  display: flex; align-items: center; justify-content: center; cursor: pointer;
}


/* Profile ID copy button */
.profile-id-copy {
  cursor: pointer; display: inline-flex; align-items: center; gap: 5px;
  transition: opacity 0.15s; border-radius: 6px; padding: 2px 6px;
  margin: 0 auto;
}
.profile-id-copy:active { opacity: 0.5; }

.chat-messages {
  flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
  padding: 16px 16px 0;
  display: flex; flex-direction: column; gap: 12px;
}
.chat-welcome {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; text-align: center;
  padding: 32px 20px; gap: 0;
  width: 100%; min-height: 60%;
}
/* Default welcome */
.cw-default {
  display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center;
}
.cw-icon {
  width: 56px; height: 56px; border-radius: 18px;
  background: var(--accent-soft); color: var(--accent);
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 4px;
}
.cw-title {
  font-size: 18px; font-weight: 700; color: var(--ink); text-align: center;
}
.cw-sub {
  font-size: 13px; color: var(--ink-4); max-width: 240px; line-height: 1.5; text-align: center;
}
/* Model hero */
.cw-model {
  display: flex; flex-direction: column; align-items: center; gap: 16px;
  width: 100%; text-align: center;
}
.cwm-logo {
  width: 56px; height: 56px; border-radius: 16px;
  background: var(--bg-elev); overflow: hidden;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 12px rgba(0,0,0,0.12);
  flex-shrink: 0;
}
.cwm-logo svg, .cwm-logo img { width: 40px; height: 40px; object-fit: contain; }
.cwm-desc-card {
  width: 100%; max-width: 300px; text-align: center;
}
.hero-bullet {
  font-size: 14px; color: var(--ink-2); line-height: 1.9;
  display: block; text-align: center;
}
.chat-quick-btns { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 4px; }
.quick-btn {
  padding: 8px 14px; border-radius: 99px; border: 1.5px solid var(--border);
  background: var(--bg-elev); color: var(--ink-2);
  font-size: 12px; font-family: var(--font-sans); cursor: pointer;
  transition: all 0.15s;
}
.quick-btn:active { opacity: .6; }

/* Message bubbles */
.msg { display: flex; gap: 8px; }
.msg.user { flex-direction: row-reverse; }
.msg-bubble {
  max-width: 82%; padding: 10px 14px;
  border-radius: 18px; font-size: 14px; line-height: 1.5;
  white-space: pre-wrap; word-break: break-word;
}
.msg.user .msg-bubble {
  background: var(--accent); color: white;
  border-bottom-right-radius: 6px;
}
.msg.assistant .msg-bubble {
  background: var(--bg-elev); color: var(--ink);
  border-bottom-left-radius: 6px;
  box-shadow: var(--shadow-1);
}
.msg-avatar {
  width: 28px; height: 28px; border-radius: 50%; flex-shrink: 0;
  background: var(--accent); color: white;
  font-size: 11px; font-weight: 600;
  display: flex; align-items: center; justify-content: center; align-self: flex-end;
}
.typing-dots { display: flex; gap: 4px; align-items: center; padding: 4px 0; }
.typing-dots span {
  width: 7px; height: 7px; border-radius: 50%; background: var(--ink-4);
  animation: typingDot 1.2s infinite;
}
.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes typingDot { 0%,80%,100% { transform: scale(0.8); opacity: 0.5 } 40% { transform: scale(1); opacity: 1 } }

/* Composer */
.chat-composer {
  display: flex; align-items: flex-end; gap: 8px;
  padding: 10px 12px 12px;
  background: var(--bg);
  border-top: 0.5px solid var(--hair);
  flex-shrink: 0;
}
.composer-attach {
  width: 38px; height: 38px; border-radius: 12px;
  background: var(--bg-sunken); color: var(--ink-3);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; flex-shrink: 0;
}
.composer-input-wrap { flex: 1; min-width: 0; }
.image-preview-wrap {
  position: relative; margin-bottom: 6px;
  width: 60px; height: 60px; border-radius: 10px; overflow: hidden;
}
.image-preview-wrap img { width: 100%; height: 100%; object-fit: cover; }
.remove-img-btn {
  position: absolute; top: 3px; right: 3px;
  width: 18px; height: 18px; border-radius: 50%;
  background: rgba(0,0,0,0.5); color: white; border: none;
  font-size: 12px; cursor: pointer; display: flex; align-items: center; justify-content: center;
}
.composer-textarea {
  width: 100%; background: var(--bg-sunken); border: none;
  border-radius: 14px; padding: 9px 12px;
  font-size: 16px !important; font-family: var(--font-sans); color: var(--ink);
  resize: none; outline: none; line-height: 1.4;
  max-height: 120px; overflow-y: auto;
  -webkit-appearance: none; appearance: none;
  touch-action: manipulation; -webkit-user-select: text; user-select: text;
}
.composer-textarea::placeholder { color: var(--ink-4); }
.send-btn {
  width: 38px; height: 38px; border-radius: 12px; border: none;
  background: var(--accent); color: white;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; flex-shrink: 0; transition: transform 0.15s, opacity 0.15s;
}
.send-btn:active { transform: scale(0.9); }
.send-btn:disabled { opacity: 0.4; }

/* ── CREATE ── */
.create-topbar {
  padding: 8px 12px;
  background: var(--tg-theme-bg-color, var(--bg));
  border-bottom: 0.5px solid var(--hair);
  display: flex; align-items: center;
  flex-shrink: 0;
  position: relative;
  height: 44px;
}
.create-topbar-title {
  position: absolute;
  left: 50%; transform: translateX(-50%);
  display: flex; align-items: center; gap: 7px;
  font-size: 16px; font-weight: 600;
  color: var(--tg-theme-text-color, var(--ink));
  white-space: nowrap;
  pointer-events: none;
}
.create-model-btn {
  margin-left: auto;
  display: flex; align-items: center; gap: 5px;
  font-size: 12px; color: var(--ink-2); cursor: pointer;
  font-family: var(--font-sans); font-weight: 500;
  background: var(--bg-sunken); padding: 5px 10px 5px 8px;
  border-radius: 99px; max-width: 130px;
  white-space: nowrap; overflow: hidden;
}
.create-model-btn span {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.create-panel { display: none; flex: 1; overflow: hidden; }
.create-panel.active { display: flex; flex-direction: column; }
.create-scroll { flex: 1; overflow-y: auto; padding: 16px 16px calc(var(--safe-bottom, 0px) + 80px); display: flex; flex-direction: column; gap: 12px; -webkit-overflow-scrolling: touch; }
.create-prompt-area { margin-bottom: 12px; }
.create-textarea {
  width: 100%; background: var(--bg-sunken); border: 1px solid var(--hair-strong);
  border-radius: 16px; padding: 14px 16px;
  font-size: 16px !important; font-family: var(--font-sans); color: var(--ink);
  resize: none; outline: none; line-height: 1.5;
  -webkit-appearance: none; appearance: none;
  /* iOS: фиксированная высота чтобы не сжималась при клавиатуре */
  height: 120px; min-height: 120px; max-height: 120px;
  overflow-y: auto; -webkit-overflow-scrolling: touch;
}
.create-textarea::placeholder { color: var(--ink-4); }
.create-textarea:focus { border-color: var(--accent); }

.create-img-attach-row { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }

/* Все create-screen одинаково устойчивы к клавиатуре */
#screen-photo .create-scroll,
#screen-video .create-scroll,
#screen-music .create-scroll,
#screen-voice .create-scroll {
  flex: 1; overflow-y: auto; min-height: 0;
  -webkit-overflow-scrolling: touch;
  padding-bottom: calc(var(--safe-bottom, 0px) + 80px);
}
.attach-img-btn {
  display: flex; align-items: center; gap: 7px;
  padding: 8px 14px; border-radius: 10px; border: 1px dashed var(--hair-strong);
  background: var(--bg-sunken); color: var(--ink-3); font-size: 12px;
  font-family: var(--font-sans); cursor: pointer;
}
.edit-img-name { font-size: 11px; color: var(--ink-4); font-family: var(--font-mono); }
.generate-btn {
  width: 100%; height: 50px; border-radius: 14px; border: none;
  background: var(--accent); color: white;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  font-size: 15px; font-weight: 600; font-family: var(--font-sans);
  cursor: pointer; transition: opacity 0.15s;
  align-self: stretch; /* fix: stretch в flex-column контейнере */
  flex-shrink: 0;
}
.generate-btn:active { opacity: 0.8; }
.generate-btn:disabled { opacity: 0.4; }
.generate-btn-video { background: linear-gradient(135deg, #e26a4e, #f59e0b); }
.generate-btn-music { background: linear-gradient(135deg, #2a6fdb, #7c5df3); }

/* Kling options */
.kling-options { margin-bottom: 12px; }
.param-label { font-size: 12px; font-weight: 500; color: var(--ink-3); margin-bottom: 8px; }
.duration-chips { display: flex; gap: 8px; }
.dur-chip {
  padding: 8px 22px; border-radius: 10px; border: 1.5px solid var(--hair-strong);
  background: var(--bg-elev); color: var(--ink-2);
  font-size: 14px; font-weight: 500; font-family: var(--font-sans); cursor: pointer;
  transition: all 0.15s; min-width: 60px; text-align: center;
}
.dur-chip:active { transform: scale(0.96); }
.dur-chip.active {
  background: var(--accent); color: white; border-color: var(--accent);
  box-shadow: 0 2px 8px rgba(124,93,243,0.3);
}

/* Music tips */
.music-tips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.music-tip {
  padding: 6px 14px; border-radius: 99px;
  background: var(--t-music-soft); color: var(--t-music);
  font-size: 12px; font-weight: 500; cursor: pointer;
  transition: all 0.12s; border: 1px solid transparent;
}
.music-tip:active { border-color: var(--t-music); opacity: .7; }

/* Results */
.image-result, .video-result, .music-result, .voice-result {
  margin-top: 16px; border-radius: 18px;
  animation: fadeUp 0.4s ease;
}
.image-result {
  display: flex; flex-direction: column; gap: 10px;
}
.voice-result {
  display: flex; flex-direction: column; gap: 10px;
}
@keyframes fadeUp { from { opacity:0; transform: translateY(12px) } to { opacity:1; transform: none } }
.result-img { width: 100%; border-radius: 18px; display: block; cursor: pointer; }
.result-video { width: 100%; border-radius: 18px; display: block; }
.music-player {
  background: var(--bg-elev); border-radius: 18px; padding: 16px;
  display: flex; flex-direction: column; gap: 12px;
  box-shadow: var(--shadow-1);
}
.music-player-cover { width: 80px; height: 80px; border-radius: 12px; object-fit: cover; }
.music-player-info .music-title { font-size: 14px; font-weight: 600; }
.music-player-info .music-desc { font-size: 12px; color: var(--ink-4); margin-top: 2px; }
.music-player-controls { display: flex; align-items: center; gap: 12px; }
.play-btn {
  width: 44px; height: 44px; border-radius: 50%; border: none;
  background: var(--accent); color: white;
  display: flex; align-items: center; justify-content: center; cursor: pointer;
}
.result-meta { padding: 10px 14px 0; font-size: 11px; color: var(--ink-4); font-family: var(--font-mono); }

/* ── PRICING ── */
.pricing-scroll { flex:1; overflow-y:auto; padding:0 20px; -webkit-overflow-scrolling:touch; background:var(--tg-theme-bg-color, var(--bg)); }
.pricing-header { text-align:center; padding:24px 0 16px; }
.section-eyebrow {
  font-family:var(--font-mono); font-size:10px; letter-spacing:0.1em;
  text-transform:uppercase; color:var(--ink-4);
}
.pricing-title { font-size:28px; font-weight:700; letter-spacing:-0.6px; margin:6px 0 6px; }
.pricing-sub { font-size:13px; color:var(--ink-3); line-height:1.5; }

.plans-list { display:flex; flex-direction:column; gap:12px; margin-bottom:20px; }

/* Request cost card */
.req-cost-card {
  background: var(--bg-elev); border-radius:20px; padding:18px;
  margin-bottom:20px; border:1px solid var(--hair);
}
.req-cost-title { font-size:13px; font-weight:600; color:var(--ink-3); margin-bottom:14px; text-transform:uppercase; letter-spacing:0.05em; font-family:var(--font-mono); }
.req-cost-grid { display:grid; grid-template-columns:1fr 1fr; gap:10px; }
.req-cost-item { display:flex; align-items:center; gap:10px; }
.req-cost-icon { width:32px; height:32px; border-radius:9px; flex-shrink:0; display:flex; align-items:center; justify-content:center; }
.req-cost-info { display:flex; flex-direction:column; }
.req-cost-name { font-size:12px; font-weight:500; color:var(--ink-2); }
.req-cost-val { font-size:11px; color:var(--ink-4); font-family:var(--font-mono); margin-top:1px; }

/* Plan cards */
.plan-card {
  border-radius:22px; padding:20px; cursor:pointer;
  border:1.5px solid var(--hair-strong);
  background:var(--bg-elev);
  transition:border-color 0.2s, transform 0.15s;
  position:relative; overflow:hidden;
}
.plan-card:active { transform:scale(0.98); }
.plan-card.featured {
  background:linear-gradient(145deg, #1a1040 0%, #2d1b6b 50%, #1e1247 100%);
  border-color:rgba(124,93,243,0.5);
  box-shadow:0 8px 28px rgba(124,93,243,0.3);
}
.plan-card.featured .plan-name,
.plan-card.featured .plan-price,
.plan-card.featured .plan-period { color:white; }
.plan-card.featured .plan-tokens { color:rgba(255,255,255,0.55); }
.plan-card.featured .plan-requests { color:rgba(255,255,255,0.7); }

.plan-popular-badge {
  position:absolute; top:14px; right:14px;
  padding:4px 12px; border-radius:99px;
  background:var(--accent); color:white;
  font-size:10px; font-weight:700; letter-spacing:0.06em; text-transform:uppercase;
}
.plan-header { display:flex; align-items:center; gap:10px; margin-bottom:14px; }
.plan-icon { width:40px; height:40px; border-radius:12px; display:flex; align-items:center; justify-content:center; font-size:20px; }
.plan-name { font-size:17px; font-weight:700; letter-spacing:-0.3px; }
.plan-requests { font-size:12px; color:var(--ink-3); margin-bottom:4px; font-family:var(--font-mono); }
.plan-tokens { font-size:12px; color:var(--ink-3); margin-bottom:16px; }
.plan-price-row { display:flex; align-items:baseline; gap:5px; margin-bottom:2px; }
.plan-price { font-size:32px; font-weight:700; letter-spacing:-0.8px; }
.plan-period { font-size:13px; color:var(--ink-4); }
.plan-buy-btn {
  margin-top:16px; width:100%; height:46px; border-radius:13px; border:none;
  background:var(--bg-sunken); color:var(--ink);
  font-size:14px; font-weight:600; font-family:var(--font-sans); cursor:pointer;
  transition:opacity 0.15s, transform 0.1s;
}
.plan-buy-btn:active { opacity:0.8; transform:scale(0.98); }
.plan-card.featured .plan-buy-btn {
  background:var(--accent); color:white;
  box-shadow:0 4px 14px rgba(124,93,243,0.4);
}

/* Pricing includes */
.pricing-includes { margin-bottom:20px; }
.pricing-includes-title { font-size:13px; font-weight:600; color:var(--ink-3); margin-bottom:12px; text-transform:uppercase; letter-spacing:0.05em; font-family:var(--font-mono); }
.feat-row { display:flex; align-items:center; gap:10px; font-size:14px; color:var(--ink-2); padding:7px 0; border-bottom:0.5px solid var(--hair); }
.feat-row:last-child { border-bottom:none; }
.feat-check { color:var(--accent); font-size:14px; font-weight:700; width:18px; text-align:center; flex-shrink:0; }

/* Promo (kept for profile page) */
.promo-section { margin-bottom:24px; }
.promo-label { font-size:13px; font-weight:500; margin-bottom:8px; color:var(--ink-2); }
.promo-row { display:flex; gap:8px; }
.promo-input {
  flex:1; height:44px; border-radius:12px; border:1px solid var(--hair-strong);
  background:var(--bg-elev); padding:0 14px;
  font-size:14px; font-family:var(--font-mono); color:var(--ink);
  outline:none; text-transform:uppercase;
}
.promo-input:focus { border-color:var(--accent); }
.promo-btn {
  height:44px; padding:0 18px; border-radius:12px; border:none;
  background:var(--accent); color:white;
  font-size:14px; font-weight:600; font-family:var(--font-sans); cursor:pointer;
}
.promo-msg { font-size:12px; margin-top:6px; color:var(--ink-3); }
.promo-msg.ok { color:#1F8A5B; }
.promo-msg.err { color:#E26A4E; }

/* ── LIBRARY ── */
.library-topbar { padding: 8px 16px 0; flex-shrink: 0; }
.lib-title { font-size: 22px; font-weight: 700; letter-spacing: -0.4px; }
.lib-filter-row { display: flex; gap: 6px; padding: 8px 0 10px; overflow-x: auto; }
.lib-filter-row::-webkit-scrollbar { display: none; }
.lib-chip {
  padding: 6px 14px; border-radius: 99px; border: none;
  background: var(--bg-sunken); color: var(--ink-3);
  font-size: 13px; font-weight: 500; font-family: var(--font-sans);
  cursor: pointer; white-space: nowrap; transition: all 0.12s;
}
.lib-chip:active { opacity: .6; }
.lib-chip.active { background: var(--accent); color: white; }

.library-grid {
  flex: 1; overflow-y: auto; padding: 0 16px calc(var(--nav-height) + var(--safe-bottom) + 24px);
  display: flex; flex-direction: column; gap: 8px;
  -webkit-overflow-scrolling: touch;
}
.lib-empty {
  display: flex; flex-direction: column;
  align-items: center; gap: 10px; padding: 60px 0;
  color: var(--ink-4); font-size: 13px; text-align: center;
}

/* Library card — horizontal row layout */
.lib-card {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: 14px;
  background: var(--bg-sunken); cursor: pointer;
  transition: background 0.12s; min-height: 60px;
}
.lib-card:active { opacity: .7; }
.lib-card-thumb {
  width: 50px; height: 50px; border-radius: 10px;
  background: var(--bg); flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden; font-size: 22px; color: var(--ink-4);
}
.lib-card-thumb img { width: 100%; height: 100%; object-fit: cover; }
.lib-card-info { flex: 1; min-width: 0; }
.lib-card-prompt {
  font-size: 13px; font-weight: 500; color: var(--ink);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.lib-card-meta {
  font-size: 11px; color: var(--ink-4); margin-top: 2px;
  font-family: var(--font-mono); display: flex; align-items: center; gap: 6px;
}
.lib-card-type {
  display: inline-flex; padding: 2px 7px; border-radius: 5px;
  font-size: 10px; font-weight: 600; letter-spacing: .03em;
}
.lib-card-type.t-image { background: rgba(52,175,100,0.15); color: #34D399; }
.lib-card-type.t-video { background: rgba(239,68,68,0.15); color: #F87171; }
.lib-card-type.t-music { background: rgba(59,130,246,0.15); color: #60A5FA; }
.lib-card-type.t-chat  { background: rgba(124,93,243,0.15); color: #A78BFA; }
.lib-card-action {
  width: 36px; height: 36px; border-radius: 50%; border: none;
  background: var(--accent); color: white;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; flex-shrink: 0; font-size: 14px;
}
.lib-card-audio-btns {
  display: flex; flex-direction: column; gap: 6px; align-items: center;
}
.lib-card-dl { background: var(--bg-sunken); color: var(--accent); }

/* ── PROFILE ── */
.profile-scroll { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.profile-hero {
  display: flex; flex-direction: column; align-items: center;
  padding: 28px 20px 20px; text-align: center;
}
.profile-avatar-lg {
  width: 72px; height: 72px; border-radius: 50%;
  background: var(--accent); color: white;
  font-size: 28px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 8px 20px rgba(var(--accent-rgb), 0.3);
  margin-bottom: 12px;
}
.profile-name { font-size: 20px; font-weight: 700; letter-spacing: -0.4px; }
.profile-id { font-size: 12px; color: var(--ink-4); font-family: var(--font-mono); margin-top: 3px; }
.profile-premium-badge {
  margin-top: 8px; padding: 4px 14px; border-radius: 99px;
  font-size: 12px; font-weight: 600;
  background: var(--bg-sunken); color: var(--ink-3);
}
.profile-premium-badge.premium { background: linear-gradient(135deg,#f59e0b,#f97316); color: white; }

.profile-stats-row {
  display: flex; align-items: center; justify-content: center;
  margin: 0 20px 20px; background: var(--bg-sunken);
  border-radius: 18px; padding: 16px; box-shadow: var(--shadow-1);
}
.profile-stat { text-align: center; flex: 1; }
.stat-value { font-size: 20px; font-weight: 700; letter-spacing: -0.4px; font-variant-numeric: tabular-nums; }
.stat-label { font-size: 11px; color: var(--ink-4); margin-top: 2px; }
.profile-stat-divider { width: 0.5px; height: 32px; background: var(--hair-strong); margin: 0 12px; }

.profile-section-title { font-size: 13px; font-weight: 600; color: var(--ink-3); padding: 0 20px 8px; text-transform: uppercase; letter-spacing: 0.06em; font-family: var(--font-mono); }
.profile-rows { padding: 0 20px; display: flex; flex-direction: column; gap: 2px; }
.profile-row {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 14px; background: var(--bg-sunken);
  cursor: pointer; transition: background 0.15s;
}
.profile-row:first-child { border-radius: 14px 14px 4px 4px; }
.profile-row:last-child  { border-radius: 4px 4px 14px 14px; }
.profile-row:active { background: var(--bg-sunken); }
.prow-icon {
  width: 32px; height: 32px; border-radius: 9px;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.prow-icon-accent { background: rgba(124,93,243,0.12); color: var(--accent); }
.prow-icon-green  { background: rgba(31,138,91,0.12); color: #1F8A5B; }
.prow-icon-orange { background: rgba(226,106,78,0.12); color: #E26A4E; }
.prow-info { flex: 1; }
.prow-title { font-size: 14px; font-weight: 500; }
.prow-desc { font-size: 11px; color: var(--ink-4); margin-top: 1px; }

/* ── BOTTOM NAV ── */
.bottom-nav {
  position: absolute; left: 0; right: 0; bottom: 0;
  height: calc(var(--nav-height) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: var(--bg);
  border-top: 0.5px solid var(--hair);
  display: flex; align-items: flex-start;
  padding: 8px 0 0;
  z-index: 100;
}
.nav-item {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  gap: 3px; padding: 0; background: none; border: none;
  color: var(--ink-4); cursor: pointer;
  transition: color 0.15s; position: relative;
}
.nav-item.active { color: var(--accent); }
.nav-label { font-size: 10px; font-weight: 500; letter-spacing: 0; }
.nav-icon { transition: transform 0.15s; }
.nav-item.active .nav-icon { transform: scale(1.05); }
.nav-center-btn { position: relative; }
.nav-center-circle {
  width: 46px; height: 46px; border-radius: 50%;
  background: var(--accent); color: white;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 14px rgba(var(--accent-rgb),0.35);
  transform: translateY(-8px);
}

/* ── SHEETS ── */
.sheet-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.4);
  z-index: 200; animation: fadeIn 0.2s ease;
}
@keyframes fadeIn { from { opacity:0 } to { opacity:1 } }
.bottom-sheet {
  position: fixed; left: 0; right: 0; bottom: 0;
  background: var(--bg-sunken); border-radius: 24px 24px 0 0;
  z-index: 201; padding: 0 0 calc(var(--safe-bottom) + 20px);
  animation: slideUp 0.3s cubic-bezier(.32,1,.6,1);
  max-height: 80vh; overflow-y: auto;
}
@keyframes slideUp { from { transform: translateY(100%) } to { transform: none } }
.sheet-handle {
  width: 36px; height: 4px; border-radius: 2px;
  background: var(--ink-5); margin: 12px auto 8px;
}
.sheet-title { font-size: 16px; font-weight: 700; padding: 4px 20px 12px; letter-spacing: -0.3px; }

/* Model sheet */
.model-sheet-list { padding: 0 12px; display: flex; flex-direction: column; gap: 4px; }
.model-sheet-item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px; border-radius: 14px;
  cursor: pointer; transition: background 0.15s;
}
.model-sheet-item:active { background: var(--bg-sunken); }
.model-sheet-item.active { background: var(--accent-soft); }
.model-item-icon {
  width: 36px; height: 36px; border-radius: 10px;
  background: var(--bg-sunken); flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; font-size: 18px;
  overflow: hidden; line-height: 0;
}
.model-item-icon img {
  width: 28px; height: 28px; object-fit: contain;
  display: block; vertical-align: middle;
}
.model-item-info { flex: 1; min-width: 0; display: flex; flex-direction: column; justify-content: center; }
.model-item-name { font-size: 14px; font-weight: 500; line-height: 1.3; }
.model-item-desc { font-size: 11px; color: var(--ink-4); margin-top: 1px; }
.model-item-price {
  font-family: var(--font-mono); font-size: 12px; color: var(--ink-3);
  background: var(--bg-sunken); padding: 3px 8px; border-radius: 6px;
}
.model-item-check { color: var(--accent); font-size: 18px; }

/* Referral sheet */
.ref-sheet-body { padding: 0 20px; }
.ref-stats-row { display: flex; gap: 12px; margin-bottom: 16px; }
.ref-stat {
  flex: 1; background: var(--bg-sunken); border-radius: 14px; padding: 14px;
  text-align: center;
}
.ref-stat span { font-size: 24px; font-weight: 700; display: block; margin-bottom: 3px; }
.ref-stat small { font-size: 11px; color: var(--ink-4); }
.ref-link-label { font-size: 12px; font-weight: 500; color: var(--ink-3); margin-bottom: 6px; }
.ref-link-box {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--bg-sunken); border-radius: 12px; padding: 12px 14px;
  cursor: pointer; gap: 10px;
}
.ref-link-box span {
  font-family: var(--font-mono); font-size: 12px; color: var(--ink-2);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.ref-hint { font-size: 12px; color: var(--ink-3); margin-top: 10px; line-height: 1.5; }

/* ── TOAST ── */
.toast {
  position: fixed; bottom: calc(var(--nav-height) + var(--safe-bottom) + 16px); left: 50%;
  transform: translateX(-50%); z-index: 300;
  background: #1A1A22; color: #F0F0F4; padding: 10px 20px;
  border-radius: 99px; font-size: 13px; font-weight: 500;
  white-space: nowrap; box-shadow: var(--shadow-2);
  animation: toastIn 0.3s cubic-bezier(.32,1,.6,1);
}
@keyframes toastIn { from { opacity:0; transform: translateX(-50%) translateY(12px) } to { opacity:1; transform: translateX(-50%) translateY(0) } }

/* ── RESULT OVERLAY ── */
.result-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.95); z-index: 500;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 16px; padding: 60px 16px 32px;
}
.result-close {
  position: absolute; top: 20px; right: 20px;
  width: 36px; height: 36px; border-radius: 50%; border: none;
  background: rgba(255,255,255,0.15); color: white;
  font-size: 16px; cursor: pointer;
}
.result-content img, .result-content video {
  max-width: 100%; max-height: 90vh; border-radius: 8px;
}
/* iOS: allow long-press context menu on images to enable "Save to Photos" */
/* iOS: allow long-press to save image — use max specificity */
.result-content img,
#result-content img,
.result-overlay img {
  -webkit-touch-callout: default !important;
  -webkit-user-select: auto !important;
  user-select: auto !important;
  pointer-events: auto !important;
  touch-action: auto !important;
}

/* ── LOADING STATES ── */
.generating {
  display: flex; flex-direction: column; align-items: center; gap: 14px;
  padding: 30px 0; color: var(--ink-3); font-size: 13px;
}
.gen-spinner {
  width: 36px; height: 36px; border-radius: 50%;
  border: 3px solid var(--hair-strong); border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg) } }


/* ── Markdown in chat ── */
.md-content { white-space: normal !important; }
.md-content p { margin-bottom: 8px; line-height: 1.6; }
.md-content p:last-child { margin-bottom: 0; }
.md-content ul.md-ul { padding-left: 18px; margin: 6px 0; }
.md-content ul.md-ul li { margin-bottom: 4px; font-size: 14px; line-height: 1.5; }
.md-content h2.md-h2 { font-size: 17px; font-weight: 700; margin: 10px 0 6px; }
.md-content h3.md-h3 { font-size: 15px; font-weight: 700; margin: 8px 0 4px; }
.md-content h4.md-h4 { font-size: 14px; font-weight: 600; margin: 6px 0 4px; }
.md-content strong { font-weight: 700; }
.md-content em { font-style: italic; }
.inline-code {
  background: var(--bg-sunken); border-radius: 4px;
  padding: 1px 5px; font-family: var(--font-mono); font-size: 12px;
  color: var(--accent);
}
.code-block {
  background: var(--bg-sunken); border-radius: 12px;
  margin: 8px 0; overflow: hidden; position: relative;
}
.code-lang {
  font-family: var(--font-mono); font-size: 10px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--ink-4); padding: 8px 14px 0;
}
.code-block pre {
  padding: 10px 14px 14px; overflow-x: auto; margin: 0;
  -webkit-overflow-scrolling: touch;
}
.code-block code {
  font-family: var(--font-mono); font-size: 12px;
  color: var(--ink-2); line-height: 1.6; white-space: pre;
}
.code-copy-btn {
  position: absolute; top: 8px; right: 10px;
  background: var(--bg-elev); border: none; border-radius: 6px;
  padding: 4px 6px; cursor: pointer; color: var(--ink-3);
  display: flex; align-items: center;
}
.code-copy-btn:active { opacity: .6; }

/* ZIP export button in chat */
.chat-zip-row { margin-top: 10px; }
.chat-zip-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px; border-radius: 99px; border: none;
  background: var(--accent-soft); color: var(--accent);
  font-size: 12px; font-weight: 600; font-family: var(--font-sans); cursor: pointer;
  transition: background 0.15s;
}
.chat-zip-btn:active { opacity: .7; }

/* Plan card icon as letter */
.plan-icon { font-family: var(--font-mono); }

/* quick-btn icon alignment */
.quick-btn { display: inline-flex; align-items: center; gap: 5px; }
.quick-btn svg { flex-shrink: 0; }

/* feat-check SVG */
svg.feat-check { flex-shrink: 0; }

/* wave-hand SVG */
.wave-hand { display: inline-block; animation: wave 2s ease-in-out 0.5s; transform-origin: 70% 70%; }
.wave-hand svg { vertical-align: -3px; }

/* Scroll hiding */
::-webkit-scrollbar { width: 0; background: transparent; }

/* ── iOS input zoom prevention ── */
input, textarea, select { font-size: 16px !important; -webkit-text-size-adjust: 100%; }

/* ── Admin table mobile ── */
.table-wrap { overflow: hidden; }
.admin-content table { min-width: 600px; }
@media (max-width: 640px) {
  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .content { padding: 12px; }
  .section-hd { flex-direction: column; align-items: flex-start; gap: 8px; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .modal { padding: 16px; width: calc(100vw - 24px); }
  .form-grid { grid-template-columns: 1fr; }
  .settings-row { flex-direction: column; align-items: flex-start; gap: 8px; }
  .settings-inline-input { width: 100%; text-align: left; }
  .modal-footer { flex-wrap: wrap; }
  .sidebar { display: none; }
  .main { width: 100%; }
}

/* ── Result overlay download button ── */
.result-dl-btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 10px 20px; border-radius: 99px; border: none;
  background: rgba(255,255,255,0.15); backdrop-filter: blur(12px);
  color: white; font-size: 14px; font-weight: 600;
  font-family: var(--font-sans); cursor: pointer;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
}
.result-dl-btn:active { opacity: .7; }

/* result-overlay layout already in main block */

/* ── Mobile adaptation — full screens ── */
@media (max-width: 430px) {
  .home-title { font-size: 22px; }
  .balance-amount { font-size: 32px; }
  .mode-scroll-wrap { padding: 0 12px 4px; }
  .mode-tile { width: 72px; border-radius: 16px; padding: 12px 6px 10px; }
  .mode-icon { width: 32px; height: 32px; }
  .mode-label { font-size: 11px; }
  .tools-list { padding: 0 16px; }
  .home-history-list { padding: 0 16px; }
  .section-head { padding: 14px 16px 8px; }
  .create-scroll { padding: 12px 16px; }
  .create-textarea { font-size: 16px; min-height: 100px; }
  .generate-btn { height: 46px; font-size: 14px; }
  .pricing-scroll { padding: 0 16px; }
  .plan-price { font-size: 26px; }
  .library-grid { padding: 0 12px calc(var(--nav-height) + var(--safe-bottom) + 16px); }
  .profile-hero { padding: 20px 16px 16px; }
  .profile-rows { padding: 0 16px; }
  .profile-stats-row { margin: 0 16px 16px; padding: 12px; }
  .stat-value { font-size: 18px; }
  .ref-sheet-body { padding: 0 16px; }
  .model-sheet-list { padding: 0 8px; }
  .model-sheet-item { padding: 10px 12px; }
  .model-item-name { font-size: 13px; }
  .sheet-title { font-size: 15px; padding: 4px 16px 10px; }
}

/* ── iOS safe area for bottom sheet ── */
.bottom-sheet { padding-bottom: calc(var(--safe-bottom) + 24px); }

/* ── Smooth tab transitions — removed: conflicts with display:none/flex ── */

/* ── Chat retry button ── */
[data-retry-text] button:active { opacity: .6; }

/* ── Separate create screens ── */

/* Voice presets */
.voice-presets {
  display: flex; gap: 8px; flex-wrap: wrap;
}
.voice-preset {
  padding: 7px 16px; border-radius: 99px; border: 1.5px solid var(--border);
  background: var(--bg-elev); color: var(--ink-3);
  font-size: 13px; font-weight: 500; font-family: var(--font-sans);
  cursor: pointer; transition: all .15s;
}
.voice-preset.active {
  border-color: var(--accent); color: var(--accent);
  background: var(--accent-soft);
}

/* Mode tiles — 4 cols */
.mode-tiles { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 360px) {
  .mode-tiles { grid-template-columns: repeat(2, 1fr); }
}

/* Mode tile colors */
.mode-tile.mode-voice { background: linear-gradient(145deg, #F59E0B 0%, #F97316 100%); box-shadow: 0 4px 20px rgba(249,115,22,0.35); }

/* Generate btn voice */
.generate-btn-voice { background: linear-gradient(135deg, #F97316, #EF4444); }


/* ── Desktop layout ──────────────────────────────────────────── */
@media (min-width: 768px) {
  /* Scale down to 90% on desktop */
  html { zoom: 0.9; }

  /* App wrapper — centered column */
  .app {
    position: relative !important;
    height: auto !important;
    min-height: 100vh;
    overflow: visible !important;
    max-width: 480px;
    margin: 0 auto;
    box-shadow: 0 0 60px rgba(0,0,0,0.15);
  }

  /* All vertical scrollable areas — enable wheel scroll */
  .screen-scroll,
  .chat-messages,
  .create-scroll,
  .lib-grid,
  .profile-scroll,
  .home-scroll {
    overflow-y: auto !important;
    max-height: calc(100vh - 110px);
    overscroll-behavior: contain;
  }

  /* Horizontal scrollable areas — enable wheel scroll via JS */
  .mode-scroll-wrap {
    overflow-x: auto !important;
    cursor: grab;
  }
  .mode-scroll-wrap:active { cursor: grabbing; }

  /* Screens */
  .screen {
    position: relative !important;
    visibility: visible !important;
    pointer-events: none !important;
    display: none !important;
  }
  .screen.active {
    display: flex !important;
    pointer-events: auto !important;
    min-height: calc(100vh - 56px);
  }

  /* Nav stays at bottom */
  .nav-bar {
    position: sticky;
    bottom: 0;
    z-index: 100;
  }
}

/* ── Voice screen iOS keyboard fix ─────────────────────────── */
#screen-voice {
  display: none;
  flex-direction: column;
  height: 100%;
}
#screen-voice.active { display: flex; }

#screen-voice .create-scroll {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
  padding-bottom: calc(var(--safe-bottom, 0px) + 80px);
  /* iOS: не сжимать при открытии клавиатуры */
  -webkit-overflow-scrolling: touch;
}

/* Textarea — фиксированная высота, не меняется при клавиатуре */
#voice-prompt {
  height: 120px;
  min-height: 120px;
  max-height: 120px;
  resize: none;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* Voice presets wrap nicely */
.voice-presets {
  display: flex; gap: 8px; flex-wrap: wrap;
}

/* ── Model sheet extras ── */

/* ── Model description bar ── */
.model-desc-bar {
  padding: 8px 16px;
  background: var(--bg-sunken);
  border-bottom: 0.5px solid var(--hair);
  font-size: 12px;
  color: var(--ink-3);
  line-height: 1.5;
  animation: fadeIn 0.2s ease;
}
.model-desc-bar .mdesc-caps { margin-left: 6px; font-size: 11px; }
@keyframes fadeIn { from { opacity: 0 } to { opacity: 1 } }





/* ── FAQ Accordion ──────────────────────────────────────────── */
.faq-list { padding: 0 16px 8px; display: flex; flex-direction: column; gap: 10px; }

.faq-category { border-radius: 16px; overflow: hidden; background: var(--bg-elev); }

.faq-cat-btn {
  width: 100%; display: flex; align-items: center; gap: 12px;
  padding: 14px 16px; border: none; background: transparent;
  font-family: var(--font-sans); cursor: pointer; text-align: left;
}
.faq-cat-icon {
  width: 34px; height: 34px; border-radius: 10px;
  background: var(--accent-soft); color: var(--accent);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.faq-cat-title { font-size: 15px; font-weight: 700; color: var(--ink); flex: 1; }
.faq-chevron { color: var(--ink-3); transition: transform 0.25s ease; flex-shrink: 0; }

.faq-cat-body { display: none; padding: 0 12px 12px; flex-direction: column; gap: 8px; }
.faq-cat-body.open { display: flex; }

.faq-model-card { background: var(--bg-sunken); border-radius: 12px; overflow: hidden; }
.faq-model-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px; cursor: pointer; gap: 8px;
}
.faq-model-name { font-size: 13px; font-weight: 600; color: var(--ink); }

.faq-model-body { display: none; padding: 0 14px 12px; }
.faq-model-body.open { display: block; }

.faq-badge-row { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.faq-badge {
  padding: 3px 10px; border-radius: 99px;
  background: var(--accent-soft); color: var(--accent);
  font-size: 11px; font-weight: 600; font-family: var(--font-sans);
}

.faq-list-items {
  margin: 0; padding: 0 0 0 4px; list-style: none;
  display: flex; flex-direction: column; gap: 5px;
}
.faq-list-items li {
  font-size: 13px; color: var(--ink-2); line-height: 1.5;
  padding-left: 14px; position: relative;
}
.faq-list-items li::before {
  content: "·"; position: absolute; left: 0;
  color: var(--accent); font-weight: 700; font-size: 16px; line-height: 1.2;
}
