/* ── VibePix v2 — Mobile-first, single-screen + bottom sheets ── */

:root {
  --bg-top: #fffbeb;
  --bg-bottom: #fef3c7;
  --ink: #1c1917;
  --muted: #57534e;
  --panel: rgba(255, 255, 255, 0.76);
  --panel-solid: #fff;
  --panel-border: rgba(28, 25, 23, 0.08);
  --primary: #d97706;
  --primary-strong: #b45309;
  --accent: #ea580c;
  --danger: #b91c1c;
  --radius: 14px;
  --shadow: 0 12px 30px rgba(28, 25, 23, 0.08);
  --sheet-shadow: 0 -8px 40px rgba(28, 25, 23, 0.18);
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  font-family: "Avenir Next", "Segoe UI", "Helvetica Neue", sans-serif;
}

/* ── Dark mode ── */
[data-theme="dark"] {
  --bg-top: #1c1917;
  --bg-bottom: #292524;
  --ink: #fafaf9;
  --muted: #a8a29e;
  --panel: rgba(41, 37, 36, 0.85);
  --panel-solid: #292524;
  --panel-border: rgba(250, 250, 249, 0.1);
  --primary: #f59e0b;
  --primary-strong: #d97706;
  --accent: #fb923c;
  --danger: #ef4444;
}
[data-theme="dark"] body {
  background:
    radial-gradient(circle at 80% 10%, rgba(234, 88, 12, 0.08), transparent 40%),
    radial-gradient(circle at 15% 85%, rgba(217, 119, 6, 0.06), transparent 35%),
    linear-gradient(170deg, var(--bg-top), var(--bg-bottom));
}
[data-theme="dark"] .camera-wrap { background: #0c0a09; }
[data-theme="dark"] .btn { background: #44403c; color: var(--ink); }
[data-theme="dark"] .format-toggle { background: #44403c; }
[data-theme="dark"] .format-btn.active { background: #57534e; color: var(--ink); }
[data-theme="dark"] .vibe-chip[data-vibe="funny"]     { background: #422006; color: #fef9c3; }
[data-theme="dark"] .vibe-chip[data-vibe="roast"]      { background: #450a0a; color: #fee2e2; }
[data-theme="dark"] .vibe-chip[data-vibe="wholesome"]  { background: #022c22; color: #d1fae5; }
[data-theme="dark"] .vibe-chip[data-vibe="hype"]       { background: #431407; color: #ffedd5; }
[data-theme="dark"] .vibe-chip[data-vibe="unhinged"]   { background: #500724; color: #fce7f3; }
[data-theme="dark"] .vibe-chip[data-vibe="mysterious"] { background: #172554; color: #dbeafe; }
[data-theme="dark"] .vibe-chip[data-vibe="epic"]       { background: #451a03; color: #fef3c7; }
[data-theme="dark"] .variant-card,
[data-theme="dark"] .raw-text { background: rgba(250, 250, 249, 0.05); border-color: rgba(250, 250, 249, 0.08); }
[data-theme="dark"] .text-editor { background: rgba(41, 37, 36, 0.9); border-color: rgba(250, 250, 249, 0.12); color: var(--ink); }
[data-theme="dark"] .gallery-card { background: var(--panel); border-color: var(--panel-border); }
[data-theme="dark"] .dot { background: rgba(250, 250, 249, 0.2); }
[data-theme="dark"] .toast { background: #fafaf9; color: #1c1917; }
[data-theme="dark"] .desktop-nudge { background: #172554; border-color: #1e3a5f; color: #93c5fd; }
[data-theme="dark"] .nudge-dismiss { color: #93c5fd; }
[data-theme="dark"] .suggest-form .input { background: #44403c; border-color: rgba(250, 250, 249, 0.1); color: var(--ink); }
[data-theme="dark"] .card-size-btn.active { background: var(--ink); color: var(--bg-top); }
[data-theme="dark"] .loading-pulse { background: var(--primary); }
[data-theme="dark"] .camera-placeholder { color: #78716c; }
[data-theme="dark"] .menu-divider { border-color: rgba(250, 250, 249, 0.08); }
[data-theme="dark"] .result-divider { border-color: rgba(250, 250, 249, 0.08); }
[data-theme="dark"] .leaderboard-row { border-color: rgba(250, 250, 249, 0.06); }
[data-theme="dark"] .recent-row { border-color: rgba(250, 250, 249, 0.06); }
[data-theme="dark"] .leaderboard-bar-wrap { background: rgba(250, 250, 249, 0.06); }

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  color: var(--ink);
  min-height: 100dvh;
  background:
    radial-gradient(circle at 80% 10%, rgba(234, 88, 12, 0.14), transparent 40%),
    radial-gradient(circle at 15% 85%, rgba(217, 119, 6, 0.10), transparent 35%),
    linear-gradient(170deg, var(--bg-top), var(--bg-bottom));
  -webkit-tap-highlight-color: transparent;
}

/* ── Shell ── */
.app-shell {
  max-width: 480px;
  margin: 0 auto;
  padding: calc(0.75rem + var(--safe-t)) 1rem calc(0.75rem + var(--safe-b));
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

/* ── Header ── */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.25rem 0;
}

.logo {
  font-size: 1.35rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.btn-icon {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  background: none;
  border: none;
  cursor: pointer;
  border-radius: 12px;
  color: var(--ink);
  transition: background 0.15s;
}
.btn-icon:hover { background: rgba(28, 25, 23, 0.06); }
.btn-icon:active { background: rgba(28, 25, 23, 0.10); }

.menu-btn { margin-left: -8px; }

/* ── Spark Badge (header) ── */
.spark-badge {
  display: flex; align-items: center; gap: 5px;
  padding: 4px 12px 4px 6px; border-radius: 20px;
  background: rgba(255, 215, 0, 0.12); border: 1px solid rgba(255, 215, 0, 0.25);
  cursor: pointer; font-size: 13px; font-weight: 650;
  color: #B8860B; transition: background 0.15s;
}
.spark-badge:hover { background: rgba(255, 215, 0, 0.2); }
.spark-coin { width: 22px; height: 22px; flex-shrink: 0; }
.spark-badge-count { white-space: nowrap; }

/* Spark badge states */
.spark-badge.spark-warning {
  background: rgba(255, 170, 50, 0.12); border-color: rgba(255, 170, 50, 0.25); color: #cc7700;
}
.spark-badge.spark-exhausted {
  background: rgba(239, 68, 68, 0.1); border-color: rgba(239, 68, 68, 0.2); color: #dc2626;
}

[data-theme="dark"] .spark-badge {
  background: rgba(255, 215, 0, 0.1); border-color: rgba(255, 215, 0, 0.2); color: #FFD700;
}
[data-theme="dark"] .spark-badge.spark-warning { color: #ffaa32; }
[data-theme="dark"] .spark-badge.spark-exhausted { color: #ff6b6b; }

/* ── Utility ── */
.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}
/* Skip link appears on focus for keyboard users */
#skipLink:focus {
  position: fixed;
  top: 0.5rem; left: 50%;
  transform: translateX(-50%);
  width: auto; height: auto;
  clip: auto;
  padding: 0.5rem 1rem;
  background: var(--ink);
  color: #fff;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  z-index: 9999;
  margin: 0;
  overflow: visible;
  white-space: normal;
}

/* ── Camera Section ── */
.camera-section { display: grid; gap: 0.6rem; }

.camera-wrap {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  background: #1c1917;
  aspect-ratio: 4 / 3;
  display: grid;
  place-items: center;
  border: 1px solid rgba(28, 25, 23, 0.12);
}

#cameraFeed,
#snapshotCanvas,
#snapshotPreview,
#demoPhoto {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  z-index: 1;
}

.camera-placeholder {
  position: absolute;
  inset: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  color: #a8a29e;
  font-size: 0.88rem;
  font-weight: 500;
  z-index: 1;
}

.media-hint {
  position: absolute;
  bottom: 0;
  left: 0; right: 0;
  margin: 0;
  padding: 0.6rem 0.75rem;
  font-size: 0.82rem;
  color: #e7e5e4;
  text-shadow: 0 2px 6px rgba(0,0,0,0.6);
  background: linear-gradient(transparent, rgba(0,0,0,0.45));
  z-index: 2;
}

.camera-controls {
  display: flex;
  gap: 0.5rem;
}

.cam-btn { flex: 1; }

/* ── Buttons (global) ── */
input, textarea, button, select { font: inherit; }

.btn {
  border: 0;
  border-radius: 12px;
  padding: 0.72rem 1rem;
  font-weight: 650;
  font-size: 0.95rem;
  background: #e7e5e4;
  color: var(--ink);
  cursor: pointer;
  transition: transform 130ms ease, filter 130ms ease;
  min-height: 44px;
  text-align: center;
}
.btn:active { transform: translateY(1px); }
.btn:hover:enabled { filter: brightness(0.97); }
.btn:disabled { cursor: not-allowed; opacity: 0.5; }
.btn.primary { background: var(--primary); color: #fff; }
.btn.primary:hover:enabled { background: var(--primary-strong); }

.btn-text {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--primary-strong);
  font-weight: 650;
  font-size: 0.88rem;
  padding: 0.4rem 0;
}
.btn-text:hover { text-decoration: underline; }

/* ── Format Toggle ── */
.format-section { display: grid; gap: 0.5rem; }

.format-toggle {
  display: flex;
  gap: 0;
  background: #e7e5e4;
  border-radius: 10px;
  padding: 3px;
}

.format-btn {
  flex: 1;
  border: none;
  border-radius: 8px;
  padding: 0.5rem 0.25rem;
  font: inherit;
  font-size: 0.85rem;
  font-weight: 650;
  cursor: pointer;
  text-align: center;
  min-height: 40px;
  background: transparent;
  color: var(--muted);
  transition: background 0.18s, color 0.18s, box-shadow 0.18s;
}
.format-btn:active { transform: translateY(1px); }
.format-btn.active {
  background: #fff;
  color: var(--ink);
  box-shadow: 0 1px 4px rgba(28, 25, 23, 0.12);
}

/* Sheet format toggle (compact) */
.sheet-format-section {
  margin-bottom: 0.4rem;
}

.sheet-format-toggle {
  display: flex;
  gap: 0;
  background: #e7e5e4;
  border-radius: 8px;
  padding: 2px;
}

.sheet-format-btn {
  flex: 1;
  border: none;
  border-radius: 6px;
  padding: 0.35rem 0.25rem;
  font: inherit;
  font-size: 0.75rem;
  font-weight: 650;
  cursor: pointer;
  text-align: center;
  min-height: 32px;
  background: transparent;
  color: var(--muted);
  transition: background 0.18s, color 0.18s, box-shadow 0.18s;
}
.sheet-format-btn:active { transform: translateY(1px); }
.sheet-format-btn.active {
  background: #fff;
  color: var(--ink);
  box-shadow: 0 1px 3px rgba(28, 25, 23, 0.10);
}

/* ── Vibe Chips ── */
.vibe-section { display: grid; gap: 0.5rem; }

.section-label {
  margin: 0;
  font-weight: 700;
  font-size: 0.95rem;
}

.vibe-grid {
  display: flex;
  gap: 0.45rem;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding: 0.15rem 0;
  scrollbar-width: none;
}
.vibe-grid::-webkit-scrollbar { display: none; }

.vibe-chip {
  flex: 0 0 auto;
  border: 2px solid transparent;
  border-radius: 10px;
  padding: 0.55rem 0.75rem;
  font: inherit;
  font-size: 0.78rem;
  font-weight: 650;
  cursor: pointer;
  text-align: center;
  min-height: 44px;
  display: grid;
  place-items: center;
  white-space: nowrap;
  transition: transform 130ms ease, border-color 180ms ease, box-shadow 180ms ease;
}
.vibe-chip:active { transform: translateY(1px); }

/* Chip colors */
.vibe-chip[data-vibe="funny"]     { background: #fef9c3; color: #854d0e; }
.vibe-chip[data-vibe="roast"]     { background: #fee2e2; color: #991b1b; }
.vibe-chip[data-vibe="wholesome"] { background: #d1fae5; color: #065f46; }
.vibe-chip[data-vibe="hype"]      { background: #ffedd5; color: #9a3412; }
.vibe-chip[data-vibe="unhinged"]  { background: #fce7f3; color: #831843; }
.vibe-chip[data-vibe="mysterious"]{ background: #dbeafe; color: #1e3a5f; }
.vibe-chip[data-vibe="epic"]      { background: #fef3c7; color: #92400e; }

.vibe-chip.active {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(217, 119, 6, 0.25);
}

/* ── Generate CTA ── */
.generate-cta {
  width: 100%;
  font-size: 1.05rem;
  padding: 0.85rem;
  margin-top: 0.4rem;
  background: var(--primary);
  color: #fff;
  border-radius: 14px;
}
.generate-cta:hover:enabled { background: var(--primary-strong); }

/* ── Loading ── */
.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  padding: 2rem 0;
}

.loading-pulse {
  width: 48px; height: 48px;
  border-radius: 50%;
  background: var(--primary);
  animation: pulse 1.2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { transform: scale(0.85); opacity: 0.5; }
  50%      { transform: scale(1.15); opacity: 1; }
}

.loading-msg {
  margin: 0;
  font-size: 0.95rem;
  color: var(--muted);
  font-weight: 600;
}

/* ── Overlay ── */
.sheet-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  z-index: 90;
  opacity: 0;
  transition: opacity 0.25s ease;
}
.sheet-overlay.visible { opacity: 1; }

/* ── Bottom Sheet (shared) ── */
.bottom-sheet {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 100;
  background: var(--panel-solid);
  border-radius: 20px 20px 0 0;
  box-shadow: var(--sheet-shadow);
  max-height: 92dvh;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 0.5rem 1rem calc(1rem + var(--safe-b));
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1);
}
.bottom-sheet.open {
  transform: translateY(0);
}

.sheet-handle {
  width: 36px; height: 4px;
  background: rgba(28, 25, 23, 0.18);
  border-radius: 2px;
  margin: 0 auto 0.75rem;
}

/* ── Inline Result Section ── */
.result-section {
  display: grid;
  gap: 0.6rem;
}

.result-divider {
  border: none;
  border-top: 1px solid rgba(28, 25, 23, 0.1);
  margin: 0.25rem 0 0;
}

.result-actions {
  display: grid;
  gap: 0.5rem;
}

.remix-btn {
  width: 100%;
  background: rgba(28, 25, 23, 0.06);
  color: var(--ink);
  border: 1px dashed rgba(28, 25, 23, 0.2);
  border-radius: 10px;
  padding: 0.5rem 1rem;
  font-weight: 650;
  font-size: 0.85rem;
  cursor: pointer;
  min-height: 40px;
}
.remix-btn:hover { background: rgba(28, 25, 23, 0.1); }
.remix-btn:active { transform: translateY(1px); }

.text-on-image-toggle {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: var(--muted);
  cursor: pointer;
  padding: 0.25rem 0;
}
.text-on-image-toggle input { accent-color: var(--primary); }

/* Character picker */
.character-picker {
  margin-bottom: 0.75rem;
  min-width: 0;
}
.character-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.4rem;
}
.character-header .section-label { margin-bottom: 0; }

.character-category-select {
  padding: 0.3rem 0.5rem;
  border-radius: 8px;
  border: 1.5px solid var(--panel-border);
  background: var(--panel);
  color: var(--ink);
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
}

.character-track {
  display: flex;
  gap: 0.4rem;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding: 0.25rem 0;
  scrollbar-width: none;
}
.character-track::-webkit-scrollbar { display: none; }

.character-pill {
  flex: 0 0 auto;
  padding: 0.35rem 0.75rem;
  border-radius: 20px;
  border: 1.5px solid var(--panel-border);
  background: var(--panel);
  color: var(--ink);
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
}
.character-pill:hover { background: rgba(217, 119, 6, 0.08); }
.character-pill:active { transform: scale(0.95); }
.character-pill.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

/* Disabled state during generation */
.character-track.disabled .character-pill,
.vibe-chip.disabled,
.format-btn:disabled {
  opacity: 0.45;
  pointer-events: none;
}

.secondary-actions {
  display: flex;
  gap: 1rem;
  justify-content: center;
}

/* Gallery */
.gallery-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
}
.gallery-header .section-label { margin-bottom: 0; }

.gallery-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.gallery-empty {
  text-align: center;
  color: var(--muted);
  padding: 2rem 1rem;
  font-size: 0.9rem;
}

.gallery-card {
  display: flex;
  gap: 0.75rem;
  padding: 0.75rem;
  border-radius: 12px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
}

.gallery-card-img {
  width: 72px;
  height: 72px;
  border-radius: 8px;
  object-fit: cover;
  flex-shrink: 0;
}

.gallery-card-body {
  flex: 1;
  min-width: 0;
}

.gallery-card-meta {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--primary);
  margin-bottom: 0.25rem;
}

.gallery-card-text {
  font-size: 0.85rem;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.gallery-card-date {
  font-size: 0.7rem;
  color: var(--muted);
  margin-top: 0.25rem;
}

.gallery-card-actions {
  display: flex;
  gap: 1rem;
  margin-top: 0.25rem;
}
.gallery-card-restore {
  font-size: 0.75rem;
  color: var(--accent);
}
.gallery-card-delete {
  font-size: 0.75rem;
  color: var(--muted);
}

/* Caption variants carousel */
.variants-wrap {
  margin-bottom: 0.75rem;
  min-width: 0; /* prevent grid blowout */
}
.variants-track {
  display: flex;
  gap: 0.75rem;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  padding: 0.25rem 0;
  scrollbar-width: none;
}
.variants-track::-webkit-scrollbar { display: none; }

.variant-card {
  flex: 0 0 100%;
  scroll-snap-align: center;
  background: rgba(28, 25, 23, 0.04);
  border: 1px solid rgba(28, 25, 23, 0.08);
  border-radius: 12px;
  padding: 1rem;
  font-size: 1rem;
  line-height: 1.5;
  min-height: 5rem;
}

.variants-dots {
  display: flex;
  justify-content: center;
  gap: 0.4rem;
  margin-top: 0.5rem;
}

.dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: rgba(28, 25, 23, 0.15);
  border: none;
  padding: 0;
  cursor: pointer;
  transition: background 0.2s;
}
.dot.active { background: var(--primary); }

/* Hidden share card canvas (offscreen, used for download/share only) */

/* Hidden share card canvas (offscreen, used for download/share only) */
.share-card-hidden {
  position: absolute;
  left: -9999px;
  top: -9999px;
  pointer-events: none;
}

/* Toast notification */
.toast {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%) translateY(100%);
  background: #1c1917;
  color: #fafaf9;
  padding: 0.6rem 1.2rem;
  border-radius: 10px;
  font-size: 0.85rem;
  font-weight: 500;
  opacity: 0;
  transition: transform 0.3s ease, opacity 0.3s ease;
  z-index: 1000;
  pointer-events: none;
}
.toast.visible {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

/* Raw text (poems/stories) */
.raw-text-wrap {
  margin-bottom: 0.75rem;
}

.raw-text {
  white-space: pre-wrap;
  background: rgba(28, 25, 23, 0.04);
  border: 1px solid rgba(28, 25, 23, 0.08);
  border-radius: 12px;
  padding: 1rem;
  line-height: 1.55;
  font-size: 1rem;
  min-height: 6rem;
}

.save-gallery-btn {
  width: 100%; background: rgba(28, 25, 23, 0.06); color: var(--ink);
  border: 1.5px solid rgba(28, 25, 23, 0.12); font-size: 0.88rem;
}
[data-theme="dark"] .save-gallery-btn { background: rgba(250, 250, 249, 0.08); border-color: rgba(250, 250, 249, 0.1); }

/* Preview button */
.preview-btn {
  width: 100%; background: rgba(28, 25, 23, 0.06); color: var(--ink);
  border: 1.5px solid rgba(28, 25, 23, 0.12); font-size: 0.88rem;
  display: flex; align-items: center; justify-content: center; gap: 0.4rem;
}
.preview-btn .act-icon { width: 16px; height: 16px; flex-shrink: 0; }
[data-theme="dark"] .preview-btn { background: rgba(250, 250, 249, 0.08); border-color: rgba(250, 250, 249, 0.1); }

/* Preview overlay */
.preview-overlay {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(0, 0, 0, 0.85);
  display: flex; align-items: center; justify-content: center;
  opacity: 0; transition: opacity 0.25s ease;
  padding: env(safe-area-inset-top, 0) env(safe-area-inset-right, 0) env(safe-area-inset-bottom, 0) env(safe-area-inset-left, 0);
}
.preview-overlay.visible { opacity: 1; }
.preview-close {
  position: absolute;
  top: calc(12px + env(safe-area-inset-top, 0));
  right: calc(12px + env(safe-area-inset-right, 0));
  width: 40px; height: 40px;
  background: rgba(255, 255, 255, 0.15); border: none; border-radius: 50%;
  color: #fff; font-size: 1.5rem; line-height: 1;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
}
.preview-close:hover { background: rgba(255, 255, 255, 0.25); }
.preview-canvas {
  max-width: calc(100vw - 32px);
  max-height: calc(100vh - 80px - env(safe-area-inset-top, 0) - env(safe-area-inset-bottom, 0));
  object-fit: contain; border-radius: 12px;
}

/* Share actions */
.share-actions {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.share-action-btn { flex: 1; font-size: 0.82rem; padding: 0.55rem 0.25rem; }
.share-action-btn .act-icon {
  width: 15px; height: 15px; vertical-align: -2px; margin-right: 0.25rem;
  display: inline-block;
}

/* Edit text */
.edit-section { margin-bottom: 0.25rem; }
.edit-text-link { font-size: 0.78rem; color: var(--muted); text-decoration: underline; text-underline-offset: 2px; }

.text-editor {
  width: 100%;
  border-radius: 12px;
  border: 1px solid rgba(28, 25, 23, 0.16);
  padding: 0.75rem;
  background: rgba(255, 255, 255, 0.95);
  font-size: 0.95rem;
  line-height: 1.5;
  resize: vertical;
  margin-top: 0.4rem;
}
.text-editor:focus {
  outline: 2px solid rgba(234, 88, 12, 0.25);
  border-color: rgba(234, 88, 12, 0.75);
}

/* (card-size, listen-btn, save-gallery removed — inline result section handles these) */

/* ── Menu Sheet ── */
.menu-sheet { padding-bottom: calc(1.5rem + var(--safe-b)); }

.menu-nav {
  display: flex;
  flex-direction: column;
}

.menu-item {
  background: none;
  border: none;
  cursor: pointer;
  font: inherit;
  font-weight: 600;
  font-size: 1rem;
  text-align: left;
  padding: 0.85rem 0.25rem;
  color: var(--ink);
  min-height: 44px;
  transition: background 0.12s;
  border-radius: 8px;
}
.menu-item:hover { background: rgba(28, 25, 23, 0.04); }
.menu-item:active { background: rgba(28, 25, 23, 0.08); }
.menu-item-muted { color: var(--muted); font-weight: 500; }

.menu-divider {
  border: none;
  border-top: 1px solid rgba(28, 25, 23, 0.08);
  margin: 0.25rem 0;
}

/* ── Quota ── */
.quota-count {
  text-align: center;
  font-size: 0.82rem;
  color: var(--muted);
  margin: 0.35rem 0 0;
}

.quota-sheet { padding-bottom: calc(1.5rem + var(--safe-b)); }

.quota-wall {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  text-align: center;
  padding: 0.5rem 0;
}
.quota-wall-title { margin: 0; font-size: 1.2rem; font-weight: 700; }
.quota-wall-desc { margin: 0; color: var(--muted); font-size: 0.95rem; }
.quota-refresh-msg {
  margin: 0; font-size: 0.9rem; color: var(--text);
  background: var(--bg-bottom, #f5f0e8); border-radius: 10px; padding: 0.75rem 1rem;
  text-align: center; line-height: 1.4;
}
@media (prefers-color-scheme: dark) {
  .quota-refresh-msg { background: rgba(255,255,255,0.06); }
}
.quota-purchase-options { display: flex; flex-direction: column; gap: 0.5rem; width: 100%; }
.quota-buy-btn { width: 100%; font-size: 0.95rem; }

/* Sparks quota wall sections */
.sparks-section { display: flex; flex-direction: column; gap: 0.5rem; width: 100%; }
.sparks-divider {
  width: 100%; display: flex; align-items: center; gap: 0.5rem;
  color: var(--muted); font-size: 0.82rem;
}
.sparks-divider::before, .sparks-divider::after {
  content: ''; flex: 1; height: 1px; background: rgba(28, 25, 23, 0.1);
}
[data-theme="dark"] .sparks-divider::before,
[data-theme="dark"] .sparks-divider::after { background: rgba(250, 250, 249, 0.1); }
.sparks-ad-btn { font-size: 1rem; padding: 0.75rem 1rem; }
.sparks-sub-msg { margin: 0; font-size: 0.78rem; color: var(--muted); }
.sparks-badge {
  background: #f59e0b; color: #fff; font-size: 0.7rem; font-weight: 700;
  padding: 0.1rem 0.35rem; border-radius: 4px; margin-left: 0.25rem;
  vertical-align: middle;
}
.sparks-pro { background: rgba(99, 102, 241, 0.05); border-radius: 12px; padding: 0.75rem; }
.sparks-pro-perks { font-size: 0.88rem; font-weight: 600; color: var(--text); }
.sparks-pro-perks p { margin: 0; }
[data-theme="dark"] .sparks-pro { background: rgba(99, 102, 241, 0.12); }

/* Spark count below generate button */
.spark-count {
  font-size: 0.82rem; color: var(--muted); text-align: center;
  margin: 0; padding: 0.15rem 0;
}

/* ── Sale Banner ── */
.sale-banner {
  display: flex; align-items: center; gap: 0.5rem;
  justify-content: center; width: 100%; margin-bottom: 0.25rem;
}
.sale-badge {
  background: #dc2626; color: #fff; font-size: 0.75rem; font-weight: 700;
  padding: 0.2rem 0.6rem; border-radius: 6px; text-transform: uppercase;
  letter-spacing: 0.02em;
  animation: sale-pulse 2s ease-in-out infinite;
}
.sale-countdown {
  font-size: 0.8rem; color: var(--muted); font-weight: 500;
}
.sale-original {
  text-decoration: line-through; color: var(--muted); font-size: 0.9em; opacity: 0.7;
}
.sale-price {
  color: #16a34a; font-weight: 700;
}
@keyframes sale-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.85; transform: scale(1.03); }
}
[data-theme="dark"] .sale-price { color: #4ade80; }
[data-theme="dark"] .sale-badge { background: #b91c1c; }

/* ── Desktop Nudge ── */
.desktop-nudge {
  display: flex; align-items: center; gap: 0.5rem;
  background: #eff6ff; border: 1px solid #bfdbfe; border-radius: 8px;
  padding: 0.6rem 0.75rem; margin-bottom: 0.5rem;
  font-size: 0.85rem; color: #1e40af;
}
.desktop-nudge span { flex: 1; }
.nudge-dismiss {
  background: none; border: none; font-size: 1.2rem; cursor: pointer;
  color: #1e40af; padding: 0 0.25rem; line-height: 1;
}

/* ── Offline Banner ── */
.offline-banner {
  background: #dc2626; color: #fff; text-align: center;
  padding: 0.5rem; font-size: 0.85rem; font-weight: 600;
  border-radius: 8px; margin-bottom: 0.5rem;
}

/* ── Card Size Toggle ── */
.card-size-toggle {
  display: flex; gap: 0.35rem; justify-content: center; margin: 0.5rem 0;
}
.card-size-btn {
  background: transparent; border: 1.5px solid rgba(28,25,23,0.15);
  border-radius: 6px; padding: 0.3rem 0.65rem; font-size: 0.78rem;
  font-weight: 600; color: var(--muted); cursor: pointer;
  transition: all 0.15s;
}
.size-ratio { font-weight: 400; font-size: 0.7rem; opacity: 0.6; margin-left: 0.15rem; }
.card-size-btn.active {
  background: var(--ink); color: var(--bg-top); border-color: var(--ink);
}

/* ── Info Sheets (About) ── */
.info-sheet { padding-bottom: calc(1.5rem + var(--safe-b)); }
.info-content {
  display: flex; flex-direction: column; gap: 0.5rem;
  padding: 0.5rem 0; font-size: 0.92rem; color: var(--ink);
  max-height: 65vh; overflow-y: auto;
}
.info-content p { margin: 0; line-height: 1.5; }
.info-muted { color: var(--muted); font-size: 0.85rem; }

/* ── Shared sheet styles ── */
.sheet-title { margin: 0; font-size: 1.2rem; font-weight: 700; }
.sheet-desc { margin: 0 0 0.5rem; color: var(--muted); font-size: 0.9rem; }
.sheet-loading { text-align: center; color: var(--muted); font-size: 0.9rem; padding: 1rem 0; }

/* ── Suggest ── */
.suggest-sheet { padding-bottom: calc(1.5rem + var(--safe-b)); }
.suggest-form {
  display: flex; flex-direction: column; align-items: center;
  gap: 0.6rem; text-align: center; padding: 0.5rem 0;
}
.suggest-form .input {
  width: 100%; box-sizing: border-box;
  border: 1.5px solid rgba(28,25,23,0.12); border-radius: 8px;
  padding: 0.65rem 0.75rem; font-size: 0.95rem;
  background: var(--surface); color: var(--ink);
}
.suggest-form .input:focus { outline: none; border-color: var(--accent); }
.suggest-reason { resize: vertical; font-family: inherit; }

/* ── Leaderboard ── */
.leaderboard-sheet { padding-bottom: calc(1.5rem + var(--safe-b)); }
.leaderboard-content {
  display: flex; flex-direction: column; align-items: center;
  gap: 0.5rem; text-align: center; padding: 0.5rem 0;
}
.leaderboard-list { width: 100%; max-height: 50vh; overflow-y: auto; }
.leaderboard-row {
  display: flex; align-items: center; gap: 0.5rem;
  padding: 0.5rem 0.25rem; border-bottom: 1px solid rgba(28,25,23,0.06);
}
.leaderboard-rank {
  font-weight: 700; font-size: 0.85rem; color: var(--muted);
  min-width: 1.8rem; text-align: center;
}
.leaderboard-name { flex: 1; text-align: left; font-size: 0.95rem; font-weight: 600; }
.leaderboard-bar-wrap {
  flex: 1; height: 6px; background: rgba(28,25,23,0.06); border-radius: 3px; overflow: hidden;
}
.leaderboard-bar {
  height: 100%; background: var(--accent); border-radius: 3px;
  transition: width 0.4s ease;
}
.leaderboard-pct { font-size: 0.82rem; color: var(--muted); min-width: 2.5rem; text-align: right; }

/* ── Recent ── */
.recent-sheet { padding-bottom: calc(1.5rem + var(--safe-b)); }
.recent-content {
  display: flex; flex-direction: column; align-items: center;
  gap: 0.5rem; text-align: center; padding: 0.5rem 0;
}
.recent-list { width: 100%; max-height: 50vh; overflow-y: auto; }
.recent-row {
  display: flex; align-items: center; gap: 0.5rem;
  padding: 0.55rem 0.25rem; border-bottom: 1px solid rgba(28,25,23,0.06);
}
.recent-icon { font-size: 1.1rem; min-width: 1.6rem; text-align: center; }
.recent-detail { flex: 1; text-align: left; }
.recent-detail-main { font-size: 0.92rem; font-weight: 600; }
.recent-detail-sub { font-size: 0.78rem; color: var(--muted); }
.recent-time { font-size: 0.78rem; color: var(--muted); white-space: nowrap; }

/* Favorite button */
.fav-btn {
  background: none; border: none; cursor: pointer;
  font-size: 1.1rem; color: var(--primary); padding: 0; min-width: 1.6rem;
  text-align: center; line-height: 1;
}
.fav-btn:hover { transform: scale(1.2); }

/* Tappable history rows */
.history-tappable { cursor: pointer; }
.history-tappable:active { background: rgba(28, 25, 23, 0.04); }
[data-theme="dark"] .history-tappable:active { background: rgba(250, 250, 249, 0.06); }

/* ── Trending badge ── */
.character-pill.trending {
  border-color: #f59e0b;
  background: rgba(245, 158, 11, 0.08);
}
.character-pill.trending.active {
  background: #f59e0b;
  color: #fff;
  border-color: #f59e0b;
}
[data-theme="dark"] .character-pill.trending {
  border-color: #d97706;
  background: rgba(217, 119, 6, 0.15);
}
[data-theme="dark"] .character-pill.trending.active {
  background: #d97706;
  color: #fff;
}

/* ── Share intents ── */
.share-intents {
  display: flex; gap: 0.35rem; justify-content: center; margin: 0.25rem 0;
}
.share-intent-btn {
  font-size: 0.78rem; padding: 0.4rem 0.65rem; border-radius: 8px;
  background: rgba(28, 25, 23, 0.06); border: 1px solid rgba(28, 25, 23, 0.1);
}
[data-theme="dark"] .share-intent-btn {
  background: rgba(250, 250, 249, 0.06); border-color: rgba(250, 250, 249, 0.1);
}

/* ── Responsive ── */
@media (min-width: 600px) {
  .app-shell {
    padding: 1.2rem;
    max-width: 540px;
  }
}

/* ── Reduced motion ── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .bottom-sheet { transition: none; }
}

/* ── Maintenance Overlay ── */
.maintenance-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: var(--bg, #fffbeb);
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 2rem;
}
.maintenance-content { max-width: 400px; }
.maintenance-icon { font-size: 3rem; margin-bottom: 1rem; }
.maintenance-content h2 { font-size: 1.5rem; margin-bottom: 0.5rem; color: var(--text, #1c1917); }
.maintenance-msg { color: var(--muted, #78716c); line-height: 1.5; }

/* ── Announcement Banner ── */
.announcement-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 1rem;
  font-size: 0.85rem;
  line-height: 1.4;
}
.announcement-banner.info { background: #dbeafe; color: #1e40af; }
.announcement-banner.warning { background: #fef3c7; color: #92400e; }
.announcement-dismiss {
  background: none;
  border: none;
  font-size: 1.2rem;
  cursor: pointer;
  padding: 0 0.25rem;
  color: inherit;
  opacity: 0.7;
}
.announcement-dismiss:hover { opacity: 1; }
[data-theme="dark"] .announcement-banner.info { background: #1e3a5f; color: #93c5fd; }
[data-theme="dark"] .announcement-banner.warning { background: #451a03; color: #fcd34d; }
