/* Lumira Mini App — Telegram-aware styling.
   Pulls colors from Telegram WebApp themeParams when present, falls back
   to a dark gradient that works in either light or dark client themes. */

:root {
  /* Telegram theme defaults — overridden by JS via --tg-* CSS vars */
  --tg-bg: #0f172a;
  --tg-text: #f8fafc;
  --tg-secondary-bg: #1e293b;
  --tg-section-bg: #1e293b;
  --tg-hint: #94a3b8;
  --tg-link: #60a5fa;
  --tg-button: #6366f1;
  --tg-button-text: #ffffff;
  --tg-destructive: #f87171;

  --radius-card: 18px;
  --radius-pill: 999px;

  --gap-sm: 8px;
  --gap-md: 14px;
  --gap-lg: 22px;

  --shadow-card: 0 6px 20px rgba(0, 0, 0, 0.18);
  --shadow-card-hover: 0 10px 28px rgba(0, 0, 0, 0.28);

  --t: 180ms ease;

  color-scheme: dark light;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--tg-bg);
  color: var(--tg-text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, sans-serif;
  font-size: 16px;
  line-height: 1.4;
  min-height: 100vh;
  min-height: 100dvh;
  /* iOS safe-area: keep content above home indicator */
  padding-bottom: env(safe-area-inset-bottom);
}

#app {
  max-width: 720px;
  margin: 0 auto;
  padding: var(--gap-lg) var(--gap-md);
  display: flex;
  flex-direction: column;
  gap: var(--gap-lg);
}

/* ========== Hero ========== */

.hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--gap-sm);
  padding: 12px 0 4px;
}

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

.hero__icon {
  font-size: 28px;
  filter: drop-shadow(0 2px 8px rgba(99, 102, 241, 0.4));
}

.hero__title {
  margin: 0;
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, #a78bfa, #f472b6);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.hero__subtitle {
  margin: 0;
  color: var(--tg-hint);
  font-size: 14px;
}

.quota {
  margin-top: 6px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  background: var(--tg-secondary-bg);
  border-radius: var(--radius-pill);
  font-size: 13px;
}

.quota__label {
  color: var(--tg-hint);
}

.quota__value {
  font-weight: 600;
  color: var(--tg-text);
}

.quota__sub {
  color: var(--tg-link);
  font-weight: 600;
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.04em;
}

/* ========== Feature grid ========== */

.grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--gap-md);
}

.card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  padding: 18px 16px;
  border: none;
  border-radius: var(--radius-card);
  background: var(--tg-section-bg);
  color: var(--tg-text);
  text-align: left;
  cursor: pointer;
  font-family: inherit;
  font-size: 15px;
  transition: transform var(--t), box-shadow var(--t), background var(--t);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}

.card::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.08), transparent 50%);
  pointer-events: none;
}

.card:active {
  transform: scale(0.97);
}

.card:hover {
  box-shadow: var(--shadow-card-hover);
}

.card--stylize {
  background: linear-gradient(135deg, #6366f1, #ec4899);
}
.card--restore {
  background: linear-gradient(135deg, #f59e0b, #ef4444);
}
.card--colorize {
  background: linear-gradient(135deg, #06b6d4, #8b5cf6);
}
.card--remove-bg {
  background: linear-gradient(135deg, #10b981, #06b6d4);
}

.card__emoji {
  font-size: 28px;
  line-height: 1;
}

.card__title {
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.card__hint {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.78);
  font-weight: 500;
}

/* ========== Secondary links ========== */

.links {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.link {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border: none;
  border-radius: 12px;
  background: var(--tg-secondary-bg);
  color: var(--tg-text);
  font-family: inherit;
  font-size: 14px;
  cursor: pointer;
  transition: background var(--t);
}

.link:hover {
  background: color-mix(in srgb, var(--tg-secondary-bg) 80%, white);
}

.link:active {
  transform: scale(0.97);
}

/* ========== Toast ========== */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(20px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  background: var(--tg-section-bg);
  color: var(--tg-text);
  padding: 10px 16px;
  border-radius: var(--radius-pill);
  font-size: 14px;
  box-shadow: var(--shadow-card-hover);
  z-index: 100;
  max-width: 90vw;
  text-align: center;
}

.toast[hidden] {
  display: none;
}

/* ========== Bottom-sheet modal (style picker / progress / result) ========== */

.sheet {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.sheet[hidden] {
  display: none;
}

.sheet__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.sheet__panel {
  position: relative;
  background: var(--tg-bg);
  color: var(--tg-text);
  width: 100%;
  max-width: 720px;
  max-height: 90vh;
  border-radius: 24px 24px 0 0;
  padding: 26px 20px calc(28px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 16px;
  box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.45);
  animation: sheet-slide-up 220ms ease-out;
  overflow-y: auto;
}

.sheet__panel--centered {
  align-items: center;
  text-align: center;
}

@keyframes sheet-slide-up {
  from {
    transform: translateY(20%);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.sheet__close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 50%;
  background: var(--tg-secondary-bg);
  color: var(--tg-text);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}

.sheet__title {
  margin: 0;
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.sheet__sub {
  margin: 0;
  color: var(--tg-text);
  font-weight: 600;
}

.sheet__hint {
  margin: 0;
  color: var(--tg-hint);
  font-size: 13px;
}

/* ========== Style picker grid inside the style sheet ========== */

.style-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.style-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 18px 12px;
  border: none;
  border-radius: 14px;
  background: var(--tg-section-bg);
  color: var(--tg-text);
  font-family: inherit;
  font-size: 13px;
  cursor: pointer;
  transition: transform var(--t), background var(--t);
}

.style-card:active {
  transform: scale(0.95);
}

.style-card__emoji {
  font-size: 30px;
  line-height: 1;
}

.style-card__name {
  font-weight: 600;
  text-align: center;
  font-size: 13px;
}

/* ========== Spinner used in the progress sheet ========== */

.spinner {
  width: 56px;
  height: 56px;
  border: 4px solid var(--tg-section-bg);
  border-top-color: var(--tg-link);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-top: 8px;
}

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

/* ========== Result sheet ========== */

.result-image {
  width: 100%;
  max-height: 60vh;
  object-fit: contain;
  border-radius: 14px;
  background: var(--tg-section-bg);
}

.result-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.result-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 14px 16px;
  border: none;
  border-radius: 12px;
  background: var(--tg-secondary-bg);
  color: var(--tg-text);
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: background var(--t), transform var(--t);
}

.result-btn:active {
  transform: scale(0.97);
}

.result-btn--primary {
  background: var(--tg-button);
  color: var(--tg-button-text);
}

/* ========== Responsive ========== */

@media (max-width: 360px) {
  .grid {
    grid-template-columns: 1fr;
  }
  .links {
    grid-template-columns: 1fr;
  }
}
