/* ─── Reset ──────────────────────────────────────────────────────────────── */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

/* ─── Variables ──────────────────────────────────────────────────────────── */
:root {
  --blue:       #0A84FF;
  --blue-dim:   rgba(10, 132, 255, 0.18);
  --blue-glow:  rgba(10, 132, 255, 0.35);
  --white:      #FFFFFF;
  --white-10:   rgba(255,255,255,0.10);
  --white-06:   rgba(255,255,255,0.06);
  --white-04:   rgba(255,255,255,0.04);
  --border:     rgba(255,255,255,0.10);
  --border-hi:  rgba(255,255,255,0.18);
  --text:       #FFFFFF;
  --text-2:     rgba(255,255,255,0.60);
  --text-3:     rgba(255,255,255,0.35);
  --bg:         #000000;
  --radius:     20px;
  --radius-sm:  12px;
}

/* ─── Body ───────────────────────────────────────────────────────────────── */
body {
  font-family: -apple-system, 'SF Pro Text', 'Inter', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
}

body::before {
  content: '';
  position: fixed; inset: 0; z-index: -1;
  background:
    radial-gradient(ellipse 80% 60% at 50% -10%, rgba(10,132,255,0.20) 0%, transparent 70%),
    radial-gradient(ellipse 50% 40% at 90% 80%,  rgba(10,132,255,0.10) 0%, transparent 60%),
    #000;
  pointer-events: none;
}

/* ─── Splash / Auth screen ───────────────────────────────────────────────── */
.splash {
  min-height: 100vh;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 16px; padding: 32px; text-align: center;
}
.splash-logo {
  position: relative; width: 80px; height: 80px;
  display: flex; align-items: center; justify-content: center;
}
.logo-ring {
  position: absolute; inset: 0;
  border: 2px solid var(--blue);
  border-radius: 50%;
  border-top-color: transparent;
  animation: spin .9s linear infinite;
}
.logo-emoji { font-size: 36px; }
.splash-title { font-size: 20px; font-weight: 600; }
.splash-text  { font-size: 14px; color: var(--text-2); max-width: 260px; line-height: 1.5; }
.tg-btn {
  display: inline-flex; align-items: center;
  background: var(--blue);
  color: #fff; border-radius: 14px;
  padding: 12px 28px; font-size: 15px; font-weight: 600;
  text-decoration: none; transition: opacity .2s;
  margin-top: 8px;
}
.tg-btn:hover { opacity: .85; }

/* ─── App Layout ─────────────────────────────────────────────────────────── */
.app {
  max-width: 480px; margin: 0 auto;
  padding: 0 16px 24px;
  display: flex; flex-direction: column; gap: 16px;
}

/* ─── Header ─────────────────────────────────────────────────────────────── */
.app-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 0 8px;
}
.app-logo {
  display: flex; align-items: center; gap: 8px;
}
.logo-mark { font-size: 24px; }
.logo-name {
  font-size: 18px; font-weight: 700;
  background: linear-gradient(135deg, #fff 30%, var(--blue) 100%);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
}
.app-pills { display: flex; gap: 8px; }
.pill {
  display: flex; align-items: center; gap: 5px;
  padding: 7px 14px; border-radius: 100px;
  border: 1px solid var(--border);
  background: var(--white-06);
  backdrop-filter: blur(12px);
  font-size: 13px; font-weight: 500; color: var(--text);
  cursor: pointer; transition: background .2s, border-color .2s;
  font-family: inherit;
}
.pill:hover { background: var(--white-10); border-color: var(--border-hi); }
.pill-token { color: #FBB24A; }

.support-link {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  margin-top: 4px; padding: 12px;
  border-radius: 14px;
  border: 1px solid rgba(96,165,250,.3);
  background: rgba(96,165,250,.08);
  color: #60a5fa; font-size: 14px; font-weight: 600;
  text-decoration: none; cursor: pointer;
  transition: background .2s;
}
.support-link:hover { background: rgba(96,165,250,.16); }

/* ─── Hero ───────────────────────────────────────────────────────────────── */
.hero { text-align: center; padding: 8px 0 4px; }
.hero-title {
  font-size: 28px; font-weight: 700; letter-spacing: -.5px;
  line-height: 1.2;
}
.hero-sub { font-size: 14px; color: var(--text-2); margin-top: 6px; line-height: 1.5; }

/* ─── Upload Grid ────────────────────────────────────────────────────────── */
.upload-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 12px;
}
.upload-card {
  position: relative;
  aspect-ratio: 1 / 1;
  border-radius: var(--radius);
  border: 1.5px dashed rgba(255,255,255,0.20);
  background: var(--white-04);
  backdrop-filter: blur(16px);
  overflow: hidden;
  transition: border-color .25s, background .25s;
  cursor: pointer;
}
.upload-card:hover { border-color: var(--blue); background: var(--blue-dim); }
.upload-card.has-image { border-style: solid; border-color: var(--blue); }

.upload-label {
  display: flex; align-items: center; justify-content: center;
  width: 100%; height: 100%; cursor: pointer;
}
.thumb {
  width: 100%; height: 100%;
  object-fit: cover;
}
.upload-placeholder {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 6px; padding: 16px; text-align: center;
}
.upload-icon { font-size: 32px; }
.upload-title { font-size: 13px; font-weight: 600; color: var(--text); }
.upload-sub   { font-size: 11px; color: var(--text-2); line-height: 1.4; }

.upload-labels {
  display: flex; justify-content: space-between;
  font-size: 12px; color: var(--text-3);
  padding: 0 4px;
}

/* ─── Generate Button ────────────────────────────────────────────────────── */
.gen-btn {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  width: 100%; padding: 17px;
  background: var(--blue);
  color: #fff; border: none; border-radius: var(--radius);
  font-size: 16px; font-weight: 600; font-family: inherit;
  cursor: pointer;
  box-shadow: 0 4px 24px var(--blue-glow);
  transition: opacity .2s, transform .15s;
}
.gen-btn:hover:not(.disabled) { opacity: .9; transform: translateY(-1px); }
.gen-btn.disabled { background: rgba(255,255,255,0.12); box-shadow: none; cursor: not-allowed; color: var(--text-2); }
.gen-spinner {
  width: 18px; height: 18px;
  border: 2.5px solid rgba(255,255,255,.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .7s linear infinite;
  flex-shrink: 0;
}

/* ─── Error Banner ───────────────────────────────────────────────────────── */
.error-banner {
  background: rgba(255, 59, 48, 0.15);
  border: 1px solid rgba(255, 59, 48, 0.35);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-size: 13px; color: #FF6B6B;
  text-align: center;
}

/* ─── Result ─────────────────────────────────────────────────────────────── */
.result-section {
  display: flex; flex-direction: column; gap: 12px;
}
.result-label {
  font-size: 15px; font-weight: 600; text-align: center; color: var(--text-2);
}
.result-card {
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--white-04);
  backdrop-filter: blur(12px);
  box-shadow: 0 8px 32px rgba(0,0,0,.5);
}
.result-img { width: 100%; display: block; }
.result-actions { display: flex; gap: 10px; }

/* ─── Overlay + Sheet (bottom modal) ─────────────────────────────────────── */
.overlay {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(0,0,0,.55);
  backdrop-filter: blur(6px);
  display: flex; align-items: flex-end; justify-content: center;
}
.sheet {
  width: 100%; max-width: 480px;
  background: rgba(18, 18, 22, 0.92);
  backdrop-filter: blur(30px);
  border: 1px solid var(--border);
  border-bottom: none;
  border-radius: 24px 24px 0 0;
  padding: 0 20px 32px;
  max-height: 90vh; overflow-y: auto;
  display: flex; flex-direction: column; gap: 14px;
  animation: slideUp .28s cubic-bezier(.34,1.2,.64,1);
}
@keyframes slideUp {
  from { transform: translateY(100%); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}
.sheet-handle {
  width: 36px; height: 4px;
  background: rgba(255,255,255,0.20);
  border-radius: 2px;
  margin: 14px auto 4px;
}
.sheet-header {
  display: flex; align-items: center; justify-content: space-between;
}
.sheet-title { font-size: 17px; font-weight: 600; }
.sheet-close {
  background: rgba(255,255,255,.08); border: none;
  color: var(--text-2); border-radius: 50%;
  width: 28px; height: 28px;
  font-size: 13px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background .2s;
}
.sheet-close:hover { background: rgba(255,255,255,.15); }

/* ─── Token Row ──────────────────────────────────────────────────────────── */
.token-row {
  display: flex; align-items: center; justify-content: space-between;
  background: rgba(10,132,255,.12);
  border: 1px solid rgba(10,132,255,.25);
  border-radius: var(--radius-sm);
  padding: 12px 16px; font-size: 14px;
  color: #6BB8FF; cursor: pointer;
  transition: background .2s;
}
.token-row:hover { background: rgba(10,132,255,.20); }
.token-chip { font-weight: 700; font-size: 15px; }

/* ─── Fields ─────────────────────────────────────────────────────────────── */
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; min-width: 0; }
.field-row > .field { min-width: 0; overflow: hidden; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field input { min-width: 0; width: 100%; }
.field label {
  font-size: 11px; font-weight: 500; color: var(--text-2);
  text-transform: uppercase; letter-spacing: .05em;
}
.field input {
  background: rgba(255,255,255,.07);
  border: 1px solid var(--border);
  color: var(--text); border-radius: var(--radius-sm);
  padding: 10px 14px; font-size: 14px; font-family: inherit;
  outline: none; transition: border-color .2s;
}
.field input:focus { border-color: var(--blue); }

/* ─── Action Button ──────────────────────────────────────────────────────── */
.action-btn {
  width: 100%; padding: 13px;
  background: var(--blue);
  color: #fff; border: none; border-radius: var(--radius-sm);
  font-size: 15px; font-weight: 600; font-family: inherit;
  cursor: pointer; transition: opacity .2s;
}
.action-btn:hover:not(:disabled) { opacity: .88; }
.action-btn:disabled { opacity: .5; cursor: not-allowed; }
.action-btn.secondary {
  background: rgba(255,255,255,.10);
  border: 1px solid var(--border);
  color: var(--text);
}
.action-btn.secondary:hover { background: rgba(255,255,255,.16); }

/* ─── Tabs ───────────────────────────────────────────────────────────────── */
.tabs {
  display: flex; gap: 2px;
  background: rgba(255,255,255,.06);
  border-radius: var(--radius-sm);
  padding: 3px;
}
.tab {
  flex: 1; padding: 9px 12px;
  background: none; border: none;
  color: var(--text-2); border-radius: 10px;
  font-size: 14px; font-weight: 500; font-family: inherit;
  cursor: pointer; transition: all .2s;
}
.tab.active { background: rgba(255,255,255,.12); color: var(--text); }
.tab-body { display: flex; flex-direction: column; gap: 12px; }

/* ─── Token Purchase ─────────────────────────────────────────────────────── */
.hint-text {
  font-size: 13px; color: var(--text-2);
  background: rgba(255,255,255,.05);
  border-radius: 10px; padding: 10px 14px;
  text-align: center;
}
.presets { display: grid; grid-template-columns: repeat(4,1fr); gap: 8px; }
.preset {
  padding: 10px; background: rgba(255,255,255,.07);
  border: 1px solid var(--border); color: var(--text);
  border-radius: 10px; font-size: 14px; font-family: inherit;
  cursor: pointer; transition: all .2s;
}
.preset.active { background: var(--blue); border-color: var(--blue); }
.preset:hover:not(.active) { background: rgba(255,255,255,.14); }
.price-row {
  display: flex; justify-content: space-between; align-items: center;
  background: rgba(255,255,255,.05); border-radius: 10px;
  padding: 12px 16px;
}
.price-big { font-size: 22px; font-weight: 700; }
.note-text { font-size: 12px; color: var(--text-3); text-align: center; }

/* ─── Purchase History ───────────────────────────────────────────────────── */
.history-row {
  display: flex; justify-content: space-between;
  padding: 10px 0; border-bottom: 1px solid rgba(255,255,255,.06);
  font-size: 13px;
}
.h-amount { font-weight: 600; }
.h-date   { font-size: 11px; color: var(--text-3); margin-top: 2px; }
.st-paid   { color: #30D158; font-size: 11px; }
.st-pending { color: #FFD60A; font-size: 11px; }
.st-cancel  { color: #FF453A; font-size: 11px; }
.empty-msg { color: var(--text-3); text-align: center; padding: 24px 0; font-size: 14px; }

/* ─── Messages ───────────────────────────────────────────────────────────── */
.msg-ok  { color: #30D158; font-size: 13px; }
.msg-err { color: #FF453A; font-size: 13px; }

/* ─── Animations ─────────────────────────────────────────────────────────── */
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Mobile tweaks ──────────────────────────────────────────────────────── */
@media (max-width: 380px) {
  .hero-title { font-size: 24px; }
  .upload-grid { gap: 8px; }
}
