:root {
  --bg: #0c0c0e;
  --bg2: #141418;
  --bg3: #1c1c22;
  --text: #f5f5f7;
  --muted: #8e8e93;
  --line: rgba(255, 255, 255, 0.08);
  --accent: #2dd4bf;
  --accent-dark: #0d9488;
  --radius: 18px;
  --nav-h: 78px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

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

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

body {
  padding-bottom: calc(var(--nav-h) + var(--safe-b));
}

#app { height: 100%; overflow: hidden; }

.screen {
  display: none;
  height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 12px 16px 24px;
  -webkit-overflow-scrolling: touch;
}

.screen.active { display: block; }

/* Header */
.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
  padding-top: 4px;
}

.top-bar.simple { margin-bottom: 24px; }

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

.brand-icon {
  width: 36px;
  height: 36px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--accent), #6366f1);
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 18px;
  color: #000;
}

.brand-name {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.top-actions { display: flex; gap: 8px; align-items: center; }

.pill-btn {
  background: var(--bg3);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 13px;
}

.icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: var(--bg3);
  border: 1px solid var(--line);
  color: var(--text);
  font-size: 18px;
}

/* Quick grid */
.quick-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 10px;
  margin-bottom: 14px;
}

.quick-item {
  background: none;
  border: none;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  font-size: 10px;
}

.quick-item span {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--bg3);
  border: 1px solid var(--line);
  display: grid;
  place-items: center;
  font-size: 20px;
}

.models-row {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 8px;
  margin-bottom: 20px;
  scrollbar-width: none;
}

.models-row::-webkit-scrollbar { display: none; }

.model-chip {
  flex: 0 0 auto;
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--bg3);
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
}

/* Blocks */
.block { margin-bottom: 28px; }

.block-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 14px;
}

.block-head h2 {
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 0.06em;
  margin-bottom: 4px;
}

.block-head p {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.3;
}

.outline-btn {
  flex-shrink: 0;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--text);
  font-size: 12px;
  white-space: nowrap;
}

.h-scroll {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-width: none;
}

.h-scroll::-webkit-scrollbar { display: none; }

.card {
  flex: 0 0 148px;
  height: 220px;
  border-radius: var(--radius);
  background: var(--img), var(--bg3);
  background-size: cover;
  background-position: center;
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
}

.card::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(0,0,0,.85) 0%, transparent 55%);
}

.card-tag {
  position: absolute;
  left: 10px;
  bottom: 36px;
  z-index: 1;
  font-size: 11px;
  color: rgba(255,255,255,.75);
}

.card h3 {
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: 10px;
  z-index: 1;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.25;
}

/* Empty / Profile */
.empty-state {
  text-align: center;
  padding: 60px 24px;
  color: var(--muted);
}

.empty-icon { font-size: 48px; display: block; margin-bottom: 16px; }

.empty-state h2 { color: var(--text); margin-bottom: 8px; }

.primary-btn {
  margin-top: 20px;
  padding: 14px 28px;
  border-radius: 14px;
  border: none;
  background: var(--accent);
  color: #000;
  font-weight: 700;
  font-size: 15px;
}

.profile-card {
  text-align: center;
  padding: 32px 16px;
  background: var(--bg2);
  border-radius: var(--radius);
  border: 1px solid var(--line);
  margin-bottom: 20px;
}

.avatar {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), #6366f1);
  display: grid;
  place-items: center;
  font-size: 28px;
  font-weight: 800;
  color: #000;
  margin: 0 auto 12px;
}

.profile-card h2 { font-size: 20px; margin-bottom: 4px; }
.profile-card p { color: var(--muted); font-size: 14px; }

.menu-list { display: flex; flex-direction: column; gap: 8px; }

.menu-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
  border-radius: 14px;
  background: var(--bg2);
  border: 1px solid var(--line);
  color: var(--text);
  font-size: 15px;
  text-align: left;
}

.menu-row span:last-child {
  margin-left: auto;
  color: var(--muted);
}

/* Bottom nav */
.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  height: calc(var(--nav-h) + var(--safe-b));
  padding-bottom: var(--safe-b);
  background: rgba(12, 12, 14, 0.92);
  backdrop-filter: blur(20px);
  border-top: 1px solid var(--line);
  display: grid;
  grid-template-columns: 1fr 1fr 1.2fr 1fr 1fr;
  align-items: end;
  padding-left: 8px;
  padding-right: 8px;
  z-index: 100;
}

.nav-item {
  background: none;
  border: none;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding-bottom: 10px;
  font-size: 10px;
}

.nav-item span:first-child { font-size: 22px; }

.nav-item.active { color: var(--text); }

.nav-create {
  position: relative;
  top: -14px;
  padding-bottom: 0;
  gap: 6px;
}

.nav-create span {
  width: 56px;
  height: 56px;
  border-radius: 18px;
  background: var(--accent);
  color: #000;
  display: grid;
  place-items: center;
  font-size: 26px;
  box-shadow: 0 8px 24px rgba(45, 212, 191, 0.35);
}

.nav-create small {
  display: block;
  font-size: 10px;
  color: var(--text);
  font-weight: 500;
}

/* Sheet */
.sheet[hidden] { display: none; }

.sheet {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: flex-end;
}

.sheet-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,.6);
}

.sheet-panel {
  position: relative;
  width: 100%;
  background: var(--bg2);
  border-radius: 24px 24px 0 0;
  padding: 24px 20px calc(24px + var(--safe-b));
  border-top: 1px solid var(--line);
}

.sheet-panel h2 { font-size: 22px; margin-bottom: 4px; }
.sheet-sub { color: var(--muted); margin-bottom: 20px; font-size: 14px; }

.create-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}

.create-opt {
  background: var(--bg3);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 16px 8px;
  color: var(--text);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}

.create-opt span { font-size: 28px; }

.sheet-close {
  width: 100%;
  padding: 14px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--text);
  font-size: 15px;
}

button { cursor: pointer; -webkit-tap-highlight-color: transparent; }
button:active { opacity: 0.75; }

.muted { color: var(--muted); font-size: 14px; }

.profile-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  background: var(--bg3);
  padding: 4px;
  border-radius: 999px;
}

.profile-tab {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--muted);
  padding: 10px 8px;
  border-radius: 999px;
  font-size: 13px;
}

.profile-tab.active {
  background: var(--text);
  color: #000;
  font-weight: 600;
}

.history-row-clickable { cursor: pointer; }
.history-row-clickable:active { opacity: 0.85; }
.history-open { display: block; font-size: 12px; margin-top: 4px; }

.model-catalog { margin-bottom: 8px; }

.catalog-block { margin-bottom: 20px; }

.model-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.model-catalog-btn {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  border: 1px solid rgba(255,255,255,0.08);
  background: var(--bg3);
  color: var(--text);
  border-radius: 14px;
  padding: 12px;
  font-size: 13px;
  text-align: left;
  min-height: 56px;
}

.model-catalog-btn small {
  font-size: 11px;
}

.chat-bubble-error {
  background: rgba(248, 113, 113, 0.15);
  color: #fca5a5;
  border: 1px solid rgba(248, 113, 113, 0.25);
}

.profile-id { font-size: 12px; margin-top: 4px; }

.profile-stats {
  background: var(--bg3);
  border-radius: var(--radius);
  padding: 4px 16px;
  margin-bottom: 12px;
}

.profile-stat-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  font-size: 14px;
}

.profile-stat-row:last-child { border-bottom: none; }

.tier-banner {
  background: rgba(248, 113, 113, 0.15);
  color: #fca5a5;
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 12px;
  font-size: 13px;
}

.content-body {
  font-size: 14px;
  line-height: 1.55;
  margin-bottom: 16px;
}

.content-body .tg-code {
  background: rgba(255,255,255,0.08);
  padding: 2px 6px;
  border-radius: 6px;
  font-size: 13px;
}

.content-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ref-card {
  background: linear-gradient(135deg, #2563eb, #7c3aed);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 12px;
}

.label-sm {
  font-size: 11px;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin: 12px 0 8px;
  text-transform: uppercase;
}

.ref-link {
  word-break: break-all;
  font-size: 13px;
  margin-bottom: 12px;
  opacity: 0.9;
}

.ref-hint { padding: 0 4px; }

.ref-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 14px;
}

.ref-stat {
  background: var(--bg3);
  border-radius: 16px;
  padding: 14px;
  text-align: center;
}

.ref-stat strong {
  display: block;
  font-size: 22px;
  margin-bottom: 4px;
}

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

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

.milestone-row {
  background: var(--bg3);
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 14px;
}

.milestone-row.reached { opacity: 0.85; }

.ref-progress {
  margin-bottom: 12px;
  font-size: 13px;
}

.ref-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.bonus-card {
  background: var(--bg3);
  border-radius: var(--radius);
  padding: 16px;
  margin: 12px 0;
}

.channel-card .channel-desc {
  margin: 0 0 12px;
  font-size: 14px;
}

.channel-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.promo-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

.promo-input {
  border: 1px solid rgba(255,255,255,0.12);
  background: var(--bg2);
  color: var(--text);
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 15px;
}

.promo-btn {
  padding: 12px 16px;
  min-width: 64px;
}

.promo-msg { margin-top: 8px; font-size: 13px; }
.promo-msg.success { color: #4ade80; }
.promo-msg.error { color: #f87171; }

.topup-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.topup-item {
  padding: 10px 0;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  font-size: 14px;
}

.topup-item:last-child { border-bottom: none; }

.wizard-panel { display: flex; flex-direction: column; gap: 12px; }
.wizard-body { flex: 1; overflow-y: auto; }
.wizard-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.wizard-actions .primary-btn,
.wizard-actions .outline-btn { flex: 1; min-width: 120px; }
.wizard-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 8px;
}
.wizard-chip {
  border: 1px solid rgba(255,255,255,0.1);
  background: var(--bg3);
  color: var(--text);
  border-radius: 14px;
  padding: 12px 10px;
  font-size: 13px;
  text-align: left;
}
.wizard-loading { text-align: center; padding: 24px; color: var(--muted); }
.wizard-error { color: #f87171; margin-bottom: 12px; }
.wizard-lyrics {
  white-space: pre-wrap;
  font-family: inherit;
  font-size: 13px;
  background: var(--bg3);
  border-radius: 12px;
  padding: 14px;
  max-height: 240px;
  overflow-y: auto;
  margin: 8px 0;
}
.wizard-output { margin-top: 8px; }
.suno-track { margin-bottom: 12px; }
.suno-track audio { width: 100%; margin-top: 6px; }

.sheet-head-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.sheet-panel-tall { max-height: 92vh; overflow-y: auto; }

.trend-tag {
  display: inline-block;
  background: rgba(255,255,255,0.12);
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 11px;
  margin-bottom: 12px;
}

.trend-preview {
  width: 100%;
  border-radius: 16px;
  max-height: 200px;
  object-fit: cover;
  margin-bottom: 8px;
}

.trend-guide-thread {
  min-height: 160px;
  max-height: 240px;
}

.trend-guide-compose {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 10px;
}

.trend-guide-input {
  min-height: 56px;
  margin-bottom: 0;
}

.guide-hint {
  font-size: 13px;
  margin: 0 0 10px;
  line-height: 1.4;
}

.trend-guide-uploads {
  margin-bottom: 8px;
}

.prompt-box {
  background: var(--bg3);
  border-radius: 14px;
  padding: 12px;
  margin-bottom: 8px;
}

.prompt-box p {
  font-size: 13px;
  line-height: 1.45;
  max-height: 120px;
  overflow-y: auto;
  margin-bottom: 8px;
}

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

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

.generate-btn { margin-top: 8px; }

.pricing-list { display: flex; flex-direction: column; gap: 10px; }

.pricing-section {
  margin-bottom: 20px;
}

.pricing-section-title {
  font-size: 15px;
  margin: 0 0 10px;
  font-weight: 700;
}

.pricing-topup {
  padding-top: 4px;
  border-top: 1px solid var(--line);
}

.topup-base {
  font-size: 13px;
  margin: 0 0 4px;
}

.topup-hint {
  font-size: 12px;
  margin: 0 0 12px;
  line-height: 1.4;
}

.topup-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.topup-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: linear-gradient(135deg, rgba(45, 212, 191, 0.06), var(--bg3));
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 14px;
}

.topup-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  min-width: 0;
}

.topup-meta strong {
  font-size: 15px;
}

.topup-meta small {
  font-size: 11px;
}

.topup-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 999px;
  background: rgba(251, 191, 36, 0.18);
  color: #fbbf24;
  margin-top: 2px;
}

.topup-buy-btn {
  flex-shrink: 0;
  background: var(--accent);
  color: #000;
  border: none;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

.topup-buy-btn:disabled {
  opacity: 0.55;
}

.topup-profile-btn {
  width: 100%;
  margin-top: 10px;
}

.topup-loading {
  text-align: center;
  padding: 12px;
}

.pricing-row {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg3);
  padding: 12px;
  border-radius: 14px;
}

.pricing-row span { flex: 1; font-weight: 600; }

.pricing-row button {
  background: var(--bg2);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 8px 10px;
  border-radius: 10px;
  font-size: 12px;
}

.history-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
}

.history-thumb {
  flex-shrink: 0;
  width: 52px;
  height: 52px;
  border-radius: 12px;
  object-fit: cover;
  background: var(--bg3);
  border: 1px solid var(--line);
}

.history-thumb-vid,
.history-thumb-audio,
.history-thumb-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  position: relative;
  overflow: hidden;
}

.history-thumb-vid video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.history-thumb-vid span {
  position: absolute;
  font-size: 14px;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.8);
}

.history-meta {
  flex: 1;
  min-width: 0;
}

.history-meta strong {
  display: block;
  font-size: 14px;
  margin-bottom: 2px;
}

.history-prompt {
  margin: 4px 0 0;
  font-size: 12px;
  line-height: 1.35;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cost-badge {
  background: var(--bg3);
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
}

.menu-row.static { cursor: default; }

.card {
  background-image: var(--img);
  background-size: cover;
  background-position: center;
}

.field-select, .field-input, .field-textarea {
  width: 100%;
  background: var(--bg3);
  border: 1px solid var(--line);
  border-radius: 14px;
  color: var(--text);
  padding: 12px 14px;
  margin-bottom: 12px;
  font-size: 14px;
}

.field-select.full { margin-bottom: 16px; }

.field-textarea { resize: vertical; min-height: 100px; font-family: inherit; }

.params-form { margin-bottom: 8px; }

.field-block { margin-bottom: 4px; }

.toggle-btn {
  background: var(--bg2);
  border: 1px solid var(--line);
  color: var(--muted);
  padding: 10px 18px;
  border-radius: 12px;
  margin-bottom: 12px;
}

.toggle-btn.on {
  background: var(--accent);
  color: #000;
  border-color: var(--accent);
}

.chat-result {
  margin-top: 16px;
  padding: 14px;
  background: var(--bg3);
  border-radius: 14px;
  white-space: pre-wrap;
  font-size: 14px;
  line-height: 1.5;
}

.chat-thread {
  max-height: 280px;
  overflow-y: auto;
  margin-bottom: 12px;
  padding: 10px;
  background: var(--bg2);
  border: 1px solid var(--line);
  border-radius: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.chat-thread-empty {
  text-align: center;
  font-size: 13px;
  padding: 24px 8px;
}

.chat-bubble {
  max-width: 88%;
  padding: 10px 12px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
}

.chat-bubble-user {
  align-self: flex-end;
  background: var(--accent);
  color: #000;
  border-bottom-right-radius: 4px;
}

.chat-bubble-ai {
  align-self: flex-start;
  background: var(--bg3);
  border: 1px solid var(--line);
  border-bottom-left-radius: 4px;
}

.chat-bubble-typing {
  opacity: 0.7;
  font-style: italic;
}

.chat-bubble-typing {
  opacity: 0.7;
  font-style: italic;
}

.chat-reset-btn {
  margin-bottom: 10px;
  width: 100%;
}

.model-helpers {
  margin-bottom: 12px;
  padding: 12px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--bg2);
}

.helper-hint {
  font-size: 12px;
  margin: 0 0 10px;
}

.helper-block {
  margin-bottom: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.helper-block:last-child {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
}

.helper-title {
  font-size: 13px;
  font-weight: 600;
  margin: 0 0 8px;
}

.suno-tracks {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.suno-track-row {
  margin-bottom: 12px;
  padding: 10px;
  border-radius: 12px;
  background: var(--bg3);
  border: 1px solid var(--line);
}

.suno-track-meta {
  margin-bottom: 6px;
}

.suno-track-meta strong {
  display: block;
  font-size: 14px;
}

.suno-track-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.suno-stem {
  margin-top: 8px;
  padding: 8px;
  border-radius: 10px;
  background: var(--bg2);
}

.gen-result {
  margin-top: 16px;
  border-radius: 14px;
  overflow: hidden;
  background: var(--bg3);
}

.gen-preview-img,
.gen-preview-vid {
  width: 100%;
  display: block;
  border-radius: 14px;
}

.gen-preview-aud {
  width: 100%;
  padding: 12px;
}

.output-panel {
  margin-top: 20px;
  margin-bottom: 24px;
}

.output-panel-compact {
  margin-top: 12px;
}

.output-body {
  min-height: 120px;
  background: var(--bg3);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.output-idle {
  text-align: center;
  font-size: 13px;
  padding: 20px 8px;
}

.output-loading-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 16px 8px;
}

.output-loading-text {
  font-size: 14px;
  font-weight: 600;
  margin: 0;
}

.output-loading-hint {
  font-size: 12px;
  margin: 0;
  text-align: center;
}

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.85s linear infinite;
}

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

.output-error {
  text-align: center;
  padding: 8px 4px;
}

.output-error-text {
  color: #ff8a8a;
  font-size: 14px;
  line-height: 1.45;
  margin: 0 0 12px;
}

.output-pay-btn {
  margin: 0 auto;
}

.output-link {
  display: block;
  text-align: center;
  padding: 16px;
  color: var(--accent);
  font-weight: 600;
  text-decoration: none;
}

.gen-result:not([hidden]),
.chat-result:not([hidden]) {
  margin-top: 0;
}

.model-chip {
  flex-shrink: 0;
  background: var(--bg3);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 11px;
  white-space: nowrap;
}

/* Home hero & tiles */
.home-hero {
  margin-bottom: 20px;
  padding: 4px 2px 0;
}

.home-hero-title {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.03em;
  margin-bottom: 8px;
}

.home-hero-sub {
  font-size: 14px;
  line-height: 1.45;
  margin-bottom: 16px;
}

.home-create-btn {
  display: block;
  margin: 0 auto 20px;
  min-width: 220px;
  max-width: 280px;
}

.btn-center-row {
  display: flex;
  justify-content: center;
  margin: 16px 0;
}

.generate-btn {
  display: block;
  margin: 16px auto 0;
  min-width: 220px;
  max-width: 280px;
}

.model-helpers[hidden] {
  display: none !important;
}

.file-picker {
  margin-bottom: 16px;
}

.file-picker-input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.file-picker-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 14px 16px;
  border-radius: 14px;
  border: 1px dashed rgba(45, 212, 191, 0.45);
  background: rgba(45, 212, 191, 0.06);
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.file-picker-btn:active {
  transform: scale(0.98);
}

.file-picker-icon {
  font-size: 20px;
}

.file-picker-name {
  color: var(--muted);
  font-weight: 500;
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 60%;
}

.file-picker-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.file-picker-thumb {
  width: 64px;
  height: 64px;
  border-radius: 10px;
  object-fit: cover;
  border: 1px solid var(--line);
}

.file-picker-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--bg3);
  border: 1px solid var(--line);
  font-size: 12px;
  color: var(--muted);
}

.chat-compose-row {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  margin-top: 8px;
}

.chat-compose-row .field-textarea {
  flex: 1;
  margin: 0;
}

.chat-attach-btn {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--bg3);
  color: var(--text);
  font-size: 18px;
}

.chat-bubble-images {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.chat-bubble-images img {
  max-width: 120px;
  max-height: 120px;
  border-radius: 10px;
  object-fit: cover;
}

.trend-direct-hint {
  font-size: 13px;
  line-height: 1.45;
  margin: 0 0 12px;
}

.home-tiles {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 22px;
}

.home-tile {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
  padding: 16px;
  border-radius: var(--radius);
  background: var(--bg2);
  border: 1px solid var(--line);
  color: var(--text);
  text-align: left;
  min-height: 88px;
}

.home-tile span:first-child {
  font-size: 28px;
  line-height: 1;
}

.home-tile strong {
  font-size: 15px;
  font-weight: 700;
}

.home-block { margin-bottom: 24px; }

.balance-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border-radius: 999px;
  background: var(--bg3);
  border: 1px solid var(--line);
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
}

.balance-pill-icon { font-size: 14px; }

.low-balance-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  margin-bottom: 18px;
  border-radius: 14px;
  background: rgba(251, 191, 36, 0.12);
  border: 1px solid rgba(251, 191, 36, 0.35);
  font-size: 13px;
}

.catalog-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  border-radius: 14px;
  background: var(--bg2);
  border: 1px solid var(--line);
  color: var(--text);
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 12px;
}

.catalog-toggle[aria-expanded="true"] .catalog-chevron {
  transform: rotate(90deg);
}

.catalog-chevron {
  color: var(--muted);
  font-size: 18px;
  transition: transform 0.2s;
}

.menu-section-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 12px 4px 6px;
}

.menu-section-label:first-child { padding-top: 0; }

/* Toasts */
.toast-stack {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: calc(var(--nav-h) + var(--safe-b) + 12px);
  z-index: 500;
  display: flex;
  flex-direction: column-reverse;
  gap: 8px;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-radius: 14px;
  background: rgba(28, 28, 34, 0.96);
  border: 1px solid var(--line);
  backdrop-filter: blur(16px);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.45);
  font-size: 14px;
  line-height: 1.35;
  animation: toast-in 0.28s ease;
}

.toast-success { border-color: rgba(45, 212, 191, 0.4); }
.toast-error { border-color: rgba(248, 113, 113, 0.45); }
.toast-info { border-color: rgba(99, 102, 241, 0.4); }

.toast-icon { font-size: 18px; flex-shrink: 0; }
.toast-text { flex: 1; }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(12px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* App dialog */
.app-dialog {
  position: fixed;
  inset: 0;
  z-index: 600;
  display: grid;
  place-items: center;
  padding: 24px 20px calc(var(--nav-h) + var(--safe-b));
}

.app-dialog[hidden] {
  display: none !important;
  pointer-events: none;
}

.app-dialog-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
}

.app-dialog-panel {
  position: relative;
  width: 100%;
  max-width: 340px;
  padding: 24px 20px 20px;
  border-radius: 20px;
  background: var(--bg2);
  border: 1px solid var(--line);
  text-align: center;
  animation: dialog-in 0.25s ease;
}

.app-dialog-icon {
  font-size: 40px;
  margin-bottom: 12px;
}

.app-dialog-title {
  font-size: 18px;
  font-weight: 800;
  margin-bottom: 8px;
}

.app-dialog-message {
  font-size: 14px;
  color: var(--muted);
  line-height: 1.45;
  margin-bottom: 20px;
}

.app-dialog-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.app-dialog-actions .primary-btn,
.app-dialog-actions .outline-btn {
  width: 100%;
}

@keyframes dialog-in {
  from { opacity: 0; transform: scale(0.94); }
  to { opacity: 1; transform: scale(1); }
}

.app-dialog-input {
  width: 100%;
  margin-top: 12px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--bg3);
  color: var(--text);
  font-size: 15px;
}

.guest-banner[hidden] {
  display: none !important;
}

.guest-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  margin-bottom: 16px;
  border-radius: 14px;
  background: rgba(99, 102, 241, 0.12);
  border: 1px solid rgba(99, 102, 241, 0.35);
}

.guest-banner-text strong { display: block; margin-bottom: 4px; }

.guest-catalog-msg {
  padding: 20px 16px;
  border-radius: 14px;
  background: var(--bg2);
  border: 1px dashed var(--line);
  text-align: center;
}

.guest-chips-hint { padding: 8px 4px; font-size: 13px; }

.pricing-row-highlight {
  border-color: var(--accent) !important;
  box-shadow: 0 0 0 1px rgba(45, 212, 191, 0.35);
}

.history-thumb-chat {
  display: flex;
  align-items: flex-start;
  padding: 8px;
  background: var(--bg3);
  font-size: 11px;
  line-height: 1.35;
  overflow: hidden;
}

.history-chat-snippet {
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
  color: var(--muted);
}

.history-detail-block {
  padding: 12px 14px;
  margin-bottom: 16px;
  border-radius: 12px;
  background: var(--bg2);
  border: 1px solid var(--line);
  white-space: pre-wrap;
  line-height: 1.45;
  font-size: 14px;
}
