:root {
  --bg: #07070d;
  --panel: rgba(18, 18, 28, 0.72);
  --border: rgba(255, 255, 255, 0.08);
  --text: #f4f4f8;
  --muted: #9ca3af;
  --red: #e4002b; /* Bakcell brand red */
  --red-dark: #7a0015;
  --glow: rgba(228, 0, 43, 0.32);
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.45);
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  min-height: 100%;
  font-family: Inter, system-ui, sans-serif;
  color: var(--text);
  background: var(--bg);
}

body {
  position: relative;
  overflow-x: hidden;
}

.bg-mesh,
.bg-grid {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}

.bg-mesh {
  background:
    radial-gradient(circle at 15% 20%, rgba(228, 0, 43, 0.18), transparent 28%),
    radial-gradient(circle at 85% 10%, rgba(228, 0, 43, 0.10), transparent 26%),
    radial-gradient(circle at 50% 80%, rgba(120, 70, 255, 0.12), transparent 30%);
}

.bg-grid {
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(circle at center, black, transparent 80%);
}

.header,
.container {
  position: relative;
  z-index: 1;
}

.screen {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: clamp(1rem, 3vw, 2.5rem);
}

.screen-card {
  width: min(480px, 100%);
  padding: clamp(1.5rem, 4vw, 2rem);
}

.brand-centered {
  justify-content: center;
  text-align: center;
  margin-bottom: 1.5rem;
}

.limit-content h2 {
  margin: 0 0 0.75rem;
  font-family: Outfit, sans-serif;
  font-size: clamp(1.5rem, 4vw, 2rem);
  line-height: 1.15;
}

.limit-text {
  margin: 0 0 1.5rem;
  color: var(--muted);
  line-height: 1.6;
}

.limit-usage {
  margin: 0 0 1.25rem;
  color: var(--muted);
  font-size: 0.88rem;
}

.limit-logout {
  margin-top: 0.5rem;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ── Auth screen ── */

.auth-screen {
  padding: 1.25rem;
}

.auth-shell {
  position: relative;
  width: min(460px, 100%);
  margin: 0 auto;
}

.auth-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(60px);
  pointer-events: none;
  z-index: 0;
}

.auth-orb-red {
  width: 180px;
  height: 180px;
  top: -40px;
  left: -60px;
  background: rgba(228, 0, 43, 0.35);
}

.auth-orb-cyan {
  width: 200px;
  height: 200px;
  bottom: -50px;
  right: -70px;
  background: rgba(228, 0, 43, 0.18);
}

.auth-card {
  position: relative;
  z-index: 1;
  border-radius: 28px;
  overflow: hidden;
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.06),
    0 32px 80px rgba(0, 0, 0, 0.55);
}

.auth-card-header {
  padding: 1.75rem 1.75rem 0;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.03), transparent);
}

.brand-compact .brand-mark {
  width: 46px;
  height: 46px;
  border-radius: 14px;
  font-size: 0.85rem;
}

.brand-compact h1 {
  font-size: 1.15rem;
}

.auth-card-body {
  padding: 1.75rem;
}

.auth-intro {
  text-align: center;
  margin-bottom: 1.25rem;
}

.auth-title {
  margin: 0.5rem 0 0.65rem;
  font-family: Outfit, sans-serif;
  font-size: clamp(1.65rem, 5vw, 2rem);
  line-height: 1.1;
  letter-spacing: -0.03em;
}

.auth-lead {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.55;
}

.phone-row {
  display: flex;
  gap: 0.4rem;
  align-items: stretch;
}

.phone-code-field {
  flex: 0 0 auto;
}

.phone-code-box {
  display: flex;
  align-items: center;
  gap: 0;
  min-height: 54px;
  padding: 0 0.55rem 0 0.6rem;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(8, 8, 14, 0.85);
  transition:
    border-color 0.2s ease,
    box-shadow 0.2s ease,
    background 0.2s ease;
}

.phone-code-box:hover {
  border-color: rgba(255, 255, 255, 0.16);
  background: rgba(12, 12, 20, 0.95);
}

.phone-code-box:focus-within {
  border-color: rgba(228, 0, 43, 0.55);
  background: rgba(228, 0, 43, 0.04);
  box-shadow: 0 0 0 4px rgba(228, 0, 43, 0.12);
}

.phone-code-plus {
  color: var(--red);
  font-weight: 600;
  font-size: 1rem;
  line-height: 1;
  flex-shrink: 0;
  margin-right: 0.25rem;
}

.phone-code-box input {
  width: 4.25ch;
  min-width: 4ch;
  min-height: auto;
  padding: 0;
  border: none;
  border-radius: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  outline: none;
  box-shadow: none;
  color-scheme: dark;
  -webkit-appearance: none;
  appearance: none;
}

.phone-code-box input:hover,
.phone-code-box input:focus {
  border: none;
  background: transparent;
  box-shadow: none;
}

.phone-number-field {
  flex: 1;
  min-width: 0;
}

.phone-number-field .auth-input input {
  padding-left: 1rem;
}

.auth-form {
  display: grid;
  gap: 1.1rem;
}

.auth-field {
  display: grid;
  gap: 0.45rem;
}

.auth-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.auth-input {
  position: relative;
  display: flex;
  align-items: center;
}

.auth-input-icon {
  position: absolute;
  left: 1rem;
  display: grid;
  place-items: center;
  color: var(--red);
  opacity: 0.85;
  pointer-events: none;
  font-weight: 600;
}

.auth-input-icon svg {
  display: block;
}

.auth-input input {
  width: 100%;
  min-height: 54px;
  padding: 0.95rem 1rem 0.95rem 2.85rem;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(8, 8, 14, 0.85);
  color: var(--text);
  font: inherit;
  font-size: 1rem;
  color-scheme: dark;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
  transition:
    border-color 0.2s ease,
    box-shadow 0.2s ease,
    background 0.2s ease;
}

.auth-input input::placeholder {
  color: rgba(156, 163, 175, 0.55);
}

.auth-input input:hover {
  border-color: rgba(255, 255, 255, 0.16);
  background: rgba(12, 12, 20, 0.95);
}

.auth-input input:focus {
  border-color: rgba(228, 0, 43, 0.55);
  background: rgba(228, 0, 43, 0.04);
  box-shadow: 0 0 0 4px rgba(228, 0, 43, 0.12);
}

.auth-input input:-webkit-autofill,
.auth-input input:-webkit-autofill:hover,
.auth-input input:-webkit-autofill:focus {
  -webkit-text-fill-color: var(--text);
  box-shadow: 0 0 0 1000px rgba(8, 8, 14, 0.95) inset;
  border: 1px solid rgba(228, 0, 43, 0.35);
  transition: background-color 9999s ease-out 0s;
}

.auth-card-footer {
  padding: 1rem 1.75rem 1.35rem;
  text-align: center;
  font-size: 0.8rem;
  color: var(--muted);
  line-height: 1.5;
  border-top: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.15);
}

.auth-submit {
  margin-top: 0.35rem;
}

.auth-submit svg {
  transition: transform 0.2s ease;
}

.auth-submit:not(:disabled):hover svg {
  transform: translateX(3px);
}

.btn-full {
  width: 100%;
}

.btn-lg {
  min-height: 54px;
  padding: 0.95rem 1.4rem;
  font-size: 1rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
}

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.5rem 2rem 0;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.user-pill {
  display: inline-flex;
  align-items: center;
  padding: 0.65rem 0.9rem;
  border-radius: 999px;
  background: rgba(228, 0, 43, 0.10);
  border: 1px solid rgba(228, 0, 43, 0.26);
  color: #ffd2d2;
  font-size: 0.85rem;
  font-weight: 500;
}

.brand {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.brand-mark {
  width: 52px;
  height: 52px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  font-family: Outfit, sans-serif;
  font-weight: 700;
  background: linear-gradient(135deg, var(--red), var(--red-dark));
  box-shadow: 0 0 30px rgba(228, 0, 43, 0.35);
}

.brand-eyebrow {
  margin: 0 0 0.2rem;
  color: #ffd2d2;
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.brand h1,
.panel h3,
.hero h2 {
  margin: 0;
  font-family: Outfit, sans-serif;
}

.brand h1 {
  font-size: 1.35rem;
}

.session-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.65rem 0.9rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.85rem;
}

.session-pill .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 12px rgba(34, 197, 94, 0.8);
}

.session-pill.warning .dot {
  background: #f59e0b;
  box-shadow: 0 0 12px rgba(245, 158, 11, 0.8);
}

.session-pill.expired .dot {
  background: var(--red);
  box-shadow: 0 0 12px rgba(228, 0, 43, 0.8);
}

.container {
  width: min(1100px, calc(100% - 2rem));
  margin: 1.5rem auto 3rem;
  display: grid;
  gap: 1.25rem;
}

.glass {
  background: var(--panel);
  border: 1px solid var(--border);
  backdrop-filter: blur(20px);
  border-radius: 24px;
  box-shadow: var(--shadow);
}

.hero {
  padding: 1.75rem;
}

.badge {
  display: inline-block;
  margin: 0 0 0.75rem;
  padding: 0.35rem 0.7rem;
  border-radius: 999px;
  background: rgba(228, 0, 43, 0.12);
  color: #ffd2d2;
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.hero h2 {
  font-size: clamp(1.7rem, 4vw, 2.5rem);
  line-height: 1.1;
  margin-bottom: 0.75rem;
}

.hero-text {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
  max-width: 56ch;
}

.panel {
  padding: 1.5rem;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.step {
  margin: 0 0 0.25rem;
  color: #ffd2d2;
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.template-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
}

.template-card,
.skeleton-card {
  min-height: 280px;
  border-radius: 20px;
  border: 1px solid var(--border);
  overflow: hidden;
  background: rgba(255, 255, 255, 0.02);
}

.skeleton-card {
  background: linear-gradient(90deg, rgba(255,255,255,0.03), rgba(255,255,255,0.08), rgba(255,255,255,0.03));
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
}

.template-card {
  cursor: pointer;
  transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.template-card:hover {
  transform: translateY(-4px);
  border-color: rgba(228, 0, 43, 0.30);
  box-shadow: 0 12px 40px rgba(228, 0, 43, 0.12);
}

.template-card.selected {
  border-color: rgba(228, 0, 43, 0.55);
  box-shadow: 0 0 0 1px rgba(228, 0, 43, 0.30), 0 18px 50px rgba(228, 0, 43, 0.16);
}

.template-card img {
  width: 100%;
  height: 220px;
  object-fit: cover;
  display: block;
}

.template-card .meta {
  padding: 0.9rem 1rem 1.1rem;
}

.template-card h4,
.template-card p {
  margin: 0;
}

.template-card p {
  margin-top: 0.35rem;
  color: var(--muted);
  font-size: 0.88rem;
}

.upload-zone {
  display: grid;
  place-items: center;
  min-height: 260px;
  border-radius: 20px;
  border: 1.5px dashed rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.02);
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: border-color 0.2s ease, background 0.2s ease;
}

.upload-zone:hover,
.upload-zone.dragover {
  border-color: rgba(228, 0, 43, 0.45);
  background: rgba(228, 0, 43, 0.04);
}

.upload-icon {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  font-size: 2rem;
  color: #ffd2d2;
  background: rgba(228, 0, 43, 0.10);
  margin-bottom: 0.75rem;
}

.upload-title {
  margin: 0;
  font-weight: 600;
}

.upload-hint {
  margin: 0.35rem 0 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.upload-preview {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.btn {
  border: none;
  border-radius: 14px;
  padding: 0.85rem 1.2rem;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease;
}

.btn:disabled,
.btn.is-locked {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
  box-shadow: none;
}

.btn-primary {
  color: #ffffff;
  background: linear-gradient(135deg, var(--red), var(--red-dark));
  box-shadow: 0 10px 30px var(--glow);
}

.btn-primary:not(:disabled):not(.is-locked):hover {
  transform: translateY(-1px);
}

.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  color: var(--text);
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border);
}

.btn-ghost {
  color: var(--text);
  background: transparent;
  border: 1px solid var(--border);
}

.result-area {
  min-height: 360px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.02);
  display: grid;
  place-items: center;
  position: relative;
  overflow: hidden;
}

.result-placeholder {
  text-align: center;
  color: var(--muted);
}

.pulse-ring {
  width: 72px;
  height: 72px;
  margin: 0 auto 1rem;
  border-radius: 50%;
  border: 2px solid rgba(228, 0, 43, 0.25);
  position: relative;
}

.pulse-ring::after {
  content: "";
  position: absolute;
  inset: -8px;
  border-radius: 50%;
  border: 2px solid rgba(228, 0, 43, 0.15);
  animation: pulse 2s infinite;
}

.result-image {
  width: min(100%, 420px);
  border-radius: 18px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
}

.result-actions {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  justify-content: center;
  padding: 1rem;
  background: linear-gradient(to top, rgba(7, 7, 13, 0.92), transparent);
}

.loader,
.toast {
  position: fixed;
  z-index: 20;
}

.loader {
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(4, 4, 8, 0.55);
  backdrop-filter: blur(6px);
}

.loader-card {
  padding: 1.5rem 1.75rem;
  text-align: center;
}

.loader-spinner {
  width: 48px;
  height: 48px;
  margin: 0 auto 1rem;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.12);
  border-top-color: var(--red);
  animation: spin 0.9s linear infinite;
}

.toast {
  left: 50%;
  bottom: 1.5rem;
  transform: translateX(-50%);
  padding: 0.85rem 1rem;
  border-radius: 12px;
  background: rgba(18, 18, 28, 0.95);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.toast.error {
  border-color: rgba(228, 0, 43, 0.45);
  color: #fecaca;
}

.hidden {
  display: none !important;
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.08); opacity: 0.45; }
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@media (max-width: 820px) {
  .header {
    flex-direction: column;
    align-items: flex-start;
    padding-inline: 1rem;
  }

  .panel-head {
    flex-direction: column;
    align-items: flex-start;
  }
}

@media (max-width: 480px) {
  .auth-screen {
    padding: 0.75rem;
    align-items: center;
  }

  .auth-card {
    border-radius: 22px;
  }

  .auth-card-header,
  .auth-card-body {
    padding-inline: 1.25rem;
  }

  .auth-card-header {
    padding-top: 1.35rem;
  }

  .auth-card-footer {
    padding-inline: 1.25rem;
  }

  .auth-title {
    font-size: 1.5rem;
  }

  .auth-input input {
    min-height: 50px;
    font-size: 16px;
  }

  .btn-lg {
    min-height: 50px;
  }
}
