/* FotoRestartAI Mini App — premium dark (forced) */

:root {
  --bg: #08090d;
  --bg2: #12141c;
  --bg3: #1a1d28;
  --text: #f5f7ff;
  --hint: #8b93a8;
  --accent: #8b5cf6;
  --accent2: #c4b5fd;
  --gold1: #f6d365;
  --gold2: #fda085;
  --card: rgba(255, 255, 255, 0.045);
  --card-border: rgba(255, 255, 255, 0.09);
  --shadow: 0 20px 50px rgba(0, 0, 0, 0.55);
  --radius: 20px;
  --radius-sm: 14px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg) !important;
  color: var(--text) !important;
  font-family: "Manrope", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

body {
  min-height: 100dvh;
  padding-top: var(--safe-top);
}

.bg-glow {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(600px 320px at 10% -5%, rgba(139, 92, 246, 0.22), transparent 60%),
    radial-gradient(500px 280px at 95% 5%, rgba(253, 160, 133, 0.12), transparent 55%);
  z-index: 0;
}

.app {
  position: relative;
  z-index: 1;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  max-width: 520px;
  margin: 0 auto;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px 6px;
}

.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark {
  width: 40px; height: 40px;
  border-radius: 14px;
  background: linear-gradient(145deg, #1f2230, #12141c);
  border: 1px solid var(--card-border);
  display: grid; place-items: center;
  box-shadow: var(--shadow);
}
.brand-mark svg { width: 22px; height: 22px; }
.crown-lg { width: 22px; height: 22px; }
.brand-title { font-weight: 800; font-size: 15px; letter-spacing: -0.03em; }
.brand-sub { font-size: 11px; color: var(--hint); font-weight: 600; }

.balance-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid rgba(246, 211, 101, 0.35);
  background: linear-gradient(135deg, rgba(246, 211, 101, 0.12), rgba(253, 160, 133, 0.08));
  color: var(--text);
  border-radius: 999px;
  padding: 8px 12px;
  font-weight: 800;
  font-size: 13px;
}

.crown {
  width: 16px; height: 16px;
  background: linear-gradient(135deg, var(--gold1), var(--gold2));
  clip-path: polygon(50% 0%, 68% 35%, 100% 38%, 78% 62%, 86% 100%, 50% 78%, 14% 100%, 22% 62%, 0% 38%, 32% 35%);
}

.screen {
  flex: 1;
  overflow: auto;
  padding: 4px 16px calc(92px + var(--safe-bottom));
  scroll-behavior: smooth;
}

.tabbar {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(8px + var(--safe-bottom));
  width: min(500px, calc(100% - 16px));
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  padding: 6px;
  border-radius: 22px;
  background: rgba(8, 9, 13, 0.88);
  border: 1px solid var(--card-border);
  backdrop-filter: blur(20px);
  box-shadow: var(--shadow);
  z-index: 20;
}

.tab {
  border: 0;
  background: transparent;
  color: var(--hint);
  border-radius: 14px;
  padding: 7px 2px;
  font-size: 10px;
  font-weight: 700;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}
.tab.active {
  color: var(--text);
  background: linear-gradient(180deg, rgba(139, 92, 246, 0.28), rgba(139, 92, 246, 0.08));
  box-shadow: inset 0 0 0 1px rgba(139, 92, 246, 0.35);
}
.tab-ico { font-size: 15px; line-height: 1; opacity: 0.95; }

/* Hero */
.hero {
  position: relative;
  border-radius: 24px;
  overflow: hidden;
  margin-bottom: 18px;
  box-shadow: var(--shadow);
  border: 1px solid var(--card-border);
}
.hero img {
  width: 100%;
  height: min(52vw, 280px);
  object-fit: cover;
  display: block;
}
.hero-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(8,9,13,.15) 0%, rgba(8,9,13,.55) 45%, rgba(8,9,13,.92) 100%);
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 18px;
}
.hero-badge {
  align-self: flex-start;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #e9d5ff;
  background: rgba(139, 92, 246, 0.25);
  border: 1px solid rgba(196, 181, 253, 0.35);
  padding: 5px 10px;
  border-radius: 999px;
  margin-bottom: 8px;
}
.hero h1 {
  margin: 0 0 6px;
  font-size: 22px;
  line-height: 1.12;
  letter-spacing: -0.03em;
  text-shadow: 0 2px 16px rgba(0,0,0,.6);
}
.hero p {
  margin: 0;
  color: #c8cede;
  font-size: 13px;
  line-height: 1.45;
  max-width: 32ch;
}

.sell-strip {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 16px;
}
.sell-item {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-sm);
  padding: 10px 8px;
  text-align: center;
}
.sell-item strong {
  display: block;
  font-size: 15px;
  background: linear-gradient(135deg, var(--gold1), var(--gold2));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.sell-item span { font-size: 10px; color: var(--hint); font-weight: 600; }

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin: 16px 0 10px;
}
.section-title {
  margin: 0;
  font-size: 17px;
  font-weight: 800;
  letter-spacing: -0.02em;
}
.section-link {
  border: 0;
  background: none;
  color: var(--accent2);
  font-size: 12px;
  font-weight: 700;
  padding: 0;
}

.sell-item span { font-size: 11px; color: var(--hint); font-weight: 600; line-height: 1.3; }

.cat-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 14px;
}
.cat-row {
  width: 100%;
  border: 1px solid var(--card-border);
  background: var(--bg2);
  color: var(--hint);
  border-radius: var(--radius-sm);
  padding: 13px 14px;
  font-size: 13px;
  font-weight: 700;
  text-align: left;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.cat-row.active {
  color: var(--text);
  border-color: rgba(139, 92, 246, 0.55);
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.22), rgba(139, 92, 246, 0.06));
  box-shadow: inset 0 0 0 1px rgba(139, 92, 246, 0.2);
}
.cat-row-meta { font-size: 11px; color: var(--hint); font-weight: 600; white-space: nowrap; }

.chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 2px 0 10px;
  margin: 0 -4px;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
}
.chips::-webkit-scrollbar { display: none; }

.chip {
  flex: 0 0 auto;
  scroll-snap-align: start;
  border: 1px solid var(--card-border);
  background: var(--bg2);
  color: var(--hint);
  border-radius: 999px;
  padding: 9px 14px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}
.chip.active {
  color: var(--text);
  border-color: rgba(139, 92, 246, 0.55);
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.25), rgba(139, 92, 246, 0.08));
}

.grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  align-items: stretch;
}

.card {
  border: 1px solid var(--card-border);
  background: var(--bg2);
  border-radius: var(--radius);
  overflow: hidden;
  text-align: left;
  color: inherit;
  padding: 0;
  position: relative;
  box-shadow: 0 8px 24px rgba(0,0,0,.25);
  display: flex;
  flex-direction: column;
  height: 100%;
  width: 100%;
}
.card:active { transform: scale(0.98); }
.card-img-wrap {
  position: relative;
  aspect-ratio: 3/4;
  width: 100%;
  flex-shrink: 0;
  overflow: hidden;
  background: #1e2230;
}
.card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 22%;
  display: block;
}
.card-tag {
  position: absolute;
  left: 8px;
  top: 8px;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(8, 9, 13, 0.72);
  border: 1px solid rgba(255,255,255,.12);
  color: #e8ebf5;
  backdrop-filter: blur(8px);
}
.card-body {
  padding: 11px 11px 13px;
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  min-height: 72px;
}
.card-title {
  font-size: 13px;
  font-weight: 800;
  margin: 0 0 4px;
  letter-spacing: -0.01em;
  line-height: 1.25;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card-desc {
  font-size: 11px;
  color: var(--hint);
  margin: 0;
  line-height: 1.35;
  font-weight: 500;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.preview-hero {
  margin-bottom: 12px;
  border-radius: var(--radius);
  border: 1px solid var(--card-border);
  box-shadow: var(--shadow);
}

.panel {
  border: 1px solid var(--card-border);
  background: linear-gradient(180deg, var(--bg2), rgba(18,20,28,.6));
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
}
.panel h2 { margin: 0 0 6px; font-size: 18px; font-weight: 800; letter-spacing: -0.02em; }
.panel p { margin: 0; color: var(--hint); font-size: 13px; line-height: 1.5; font-weight: 500; }

.btn {
  width: 100%;
  border: 0;
  border-radius: 16px;
  padding: 15px 16px;
  font-size: 15px;
  font-weight: 800;
  letter-spacing: -0.01em;
  background: linear-gradient(135deg, #7c3aed, #a78bfa);
  color: #fff;
  margin-top: 12px;
  box-shadow: 0 10px 28px rgba(124, 58, 237, 0.35);
}
.btn:active { opacity: 0.92; transform: scale(0.99); }
.btn.secondary {
  background: transparent;
  border: 1px solid var(--card-border);
  color: var(--text);
  box-shadow: none;
}
.btn.ghost {
  background: rgba(255,255,255,.04);
  box-shadow: none;
  border: 1px solid var(--card-border);
}

.option-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.opt {
  border: 1px solid var(--card-border);
  background: var(--bg3);
  color: var(--hint);
  border-radius: 12px;
  padding: 9px 12px;
  font-size: 12px;
  font-weight: 700;
}
.opt.active {
  color: var(--text);
  border-color: rgba(139, 92, 246, 0.6);
  background: rgba(139, 92, 246, 0.18);
}

.tier-grid { display: grid; gap: 10px; margin-top: 12px; }
.tier {
  border: 1px solid var(--card-border);
  border-radius: var(--radius-sm);
  padding: 14px;
  background: var(--bg2);
  text-align: left;
  color: inherit;
}
.tier.active {
  border-color: rgba(139, 92, 246, 0.7);
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.15), rgba(139, 92, 246, 0.04));
}
.tier-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
.tier-name { font-weight: 800; font-size: 14px; }
.tier-cost {
  font-weight: 800;
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--gold1);
}
.tier-desc { font-size: 12px; color: var(--hint); line-height: 1.45; }

.hint-box {
  margin-top: 10px;
  padding: 12px;
  border-radius: 14px;
  background: rgba(139, 92, 246, 0.1);
  border: 1px solid rgba(139, 92, 246, 0.25);
  font-size: 12px;
  line-height: 1.5;
  color: #ddd6fe;
}

.status { text-align: center; padding: 36px 12px; color: var(--hint); }
.spinner {
  width: 44px; height: 44px;
  border-radius: 50%;
  border: 3px solid rgba(255,255,255,.08);
  border-top-color: var(--accent);
  animation: spin .75s linear infinite;
  margin: 0 auto 14px;
}
@keyframes spin { to { transform: rotate(360deg); } }

.result-img {
  width: 100%;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin: 12px 0;
  border: 1px solid var(--card-border);
}

.pack {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--card-border);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  background: var(--bg2);
}
.pack strong { display: block; font-size: 14px; font-weight: 800; }
.pack-meta { font-size: 12px; color: var(--hint); font-weight: 600; margin-top: 2px; }
.pack-meta .crown-inline {
  display: inline-block;
  width: 11px; height: 11px;
  vertical-align: -1px;
  margin: 0 1px;
  background: linear-gradient(135deg, var(--gold1), var(--gold2));
  clip-path: polygon(50% 0%, 68% 35%, 100% 38%, 78% 62%, 86% 100%, 50% 78%, 14% 100%, 22% 62%, 0% 38%, 32% 35%);
}
.pack button {
  border: 0;
  border-radius: 12px;
  padding: 10px 14px;
  background: linear-gradient(135deg, #7c3aed, #a78bfa);
  color: #fff;
  font-weight: 800;
  font-size: 12px;
  white-space: nowrap;
  box-shadow: 0 6px 18px rgba(124, 58, 237, 0.3);
}

.profile-balance {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 10px;
  padding: 14px 16px;
  border-radius: 14px;
  background: linear-gradient(135deg, rgba(246, 211, 101, 0.1), rgba(139, 92, 246, 0.08));
  border: 1px solid rgba(246, 211, 101, 0.2);
}
.profile-balance-main { flex: 1; min-width: 0; }
.profile-balance .crown { width: 28px; height: 28px; flex-shrink: 0; }
.profile-balance .num { font-size: 28px; font-weight: 800; line-height: 1; }
.profile-balance .lbl { font-size: 12px; color: var(--hint); font-weight: 600; margin-top: 2px; }

.history-item {
  display: grid;
  grid-template-columns: 64px 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--card-border);
  background: var(--bg2);
  margin-bottom: 8px;
}
.history-thumb {
  width: 64px; height: 64px;
  border-radius: 12px;
  object-fit: cover;
  background: #1e2230;
  border: 1px solid var(--card-border);
}
.history-title { font-size: 13px; font-weight: 800; margin: 0 0 2px; }
.history-meta { font-size: 11px; color: var(--hint); margin: 0; }
.history-open {
  border: 0;
  background: rgba(139, 92, 246, 0.15);
  color: var(--accent2);
  font-size: 11px;
  font-weight: 800;
  padding: 8px 10px;
  border-radius: 10px;
}

.error { color: #fca5a5; font-size: 13px; margin-top: 8px; line-height: 1.4; }
.empty { text-align: center; padding: 28px 12px; color: var(--hint); font-size: 13px; }
