/* ── Telegram CSS variable aliases (fallbacks for local dev) ── */
:root {
  --bg:          var(--tg-theme-bg-color,           #ffffff);
  --text:        var(--tg-theme-text-color,          #1c1c1e);
  --hint:        var(--tg-theme-hint-color,          #8e8e93);
  --link:        var(--tg-theme-link-color,          #007aff);
  --btn:         var(--tg-theme-button-color,        #1a6b3c);
  --btn-text:    var(--tg-theme-button-text-color,   #ffffff);
  --secondary:   var(--tg-theme-secondary-bg-color,  #f2f2f7);
  --header-bg:   var(--tg-theme-header-bg-color,     #f2f2f7);
  --section-sep: var(--tg-theme-section-separator_color, #c6c6c8);

  --brand:       #1a6b3c;
  --brand-light: #e8f5ee;
  --brand-dark:  #0d4a2a;
  --danger:      #ff3b30;
  --success:     #34c759;
  --warning:     #ff9500;

  --r-lg: 16px;
  --r-md: 12px;
  --r-sm: 8px;
  --shadow: 0 2px 12px rgba(0,0,0,.07);
}

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

html, body {
  height: 100%;
  background: var(--secondary);
  color: var(--text);
  font-family: -apple-system, 'Segoe UI', Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

/* ── Screen container ──────────────────────────────────────── */
.screen {
  display: none;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  background: var(--secondary);
  animation: fadeIn .2s ease;
}

.screen.active { display: flex; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateX(18px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* ── Screen header (progress + back) ──────────────────────── */
.screen-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px 10px;
  background: var(--bg);
  border-bottom: 1px solid var(--section-sep);
  flex-shrink: 0;
}

.screen-header.no-back { padding-left: 16px; }

.btn-back {
  background: none;
  border: none;
  font-size: 28px;
  line-height: 1;
  color: var(--brand);
  cursor: pointer;
  padding: 0 4px;
  flex-shrink: 0;
}

.progress-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.progress-bar {
  height: 4px;
  background: var(--section-sep);
  border-radius: 4px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--brand);
  border-radius: 4px;
  transition: width .4s ease;
}

.progress-label {
  font-size: 11px;
  color: var(--hint);
  text-align: right;
}

/* ── Screen body ───────────────────────────────────────────── */
.screen-body {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 20px 16px 8px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.screen-body.centered {
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 16px;
}

.screen-body h2 {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text);
}

/* ── Screen footer ─────────────────────────────────────────── */
.screen-footer {
  padding: 12px 16px;
  padding-bottom: max(12px, env(safe-area-inset-bottom));
  background: var(--bg);
  border-top: 1px solid var(--section-sep);
  flex-shrink: 0;
}

/* ── Hero (Welcome screen) ─────────────────────────────────── */
.hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px 0 4px;
  gap: 4px;
}

.logo-circle {
  font-size: 52px;
  line-height: 1;
  margin-bottom: 4px;
}

.app-name {
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--brand);
  letter-spacing: -0.5px;
}

.tagline {
  font-size: 0.82rem;
  color: var(--hint);
  letter-spacing: 0.02em;
}

/* ── Steps preview ─────────────────────────────────────────── */
.steps-preview {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 0.78rem;
  color: var(--hint);
}

.step-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
}

.step-num {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--brand-light);
  color: var(--brand);
  font-size: 0.72rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.step-sep {
  color: var(--section-sep);
  font-size: 1rem;
  margin-bottom: 14px;
}

/* ── Card ──────────────────────────────────────────────────── */
.card {
  background: var(--bg);
  border-radius: var(--r-lg);
  padding: 16px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.card-title {
  font-size: 1rem;
  font-weight: 700;
}

.card-desc {
  font-size: 0.85rem;
  color: var(--hint);
  margin-top: -6px;
}

.card-section-label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--hint);
  padding-bottom: 4px;
  border-bottom: 1px solid var(--section-sep);
}

/* ── Form fields ───────────────────────────────────────────── */
.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.field label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--hint);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.field input {
  width: 100%;
  padding: 10px 12px;
  border: 1.5px solid var(--section-sep);
  border-radius: var(--r-sm);
  background: var(--secondary);
  color: var(--text);
  font-size: 0.95rem;
  outline: none;
  transition: border-color .15s;
  -webkit-appearance: none;
}

.field input:focus {
  border-color: var(--brand);
  background: var(--bg);
}

.input-row {
  display: flex;
  gap: 8px;
  align-items: stretch;
}

.input-row input { flex: 1; }

/* ── Upload zone ───────────────────────────────────────────── */
.upload-zone {
  position: relative;
  border: 2px dashed var(--section-sep);
  border-radius: var(--r-lg);
  background: var(--bg);
  min-height: 180px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: border-color .2s, background .2s;
  overflow: hidden;
  flex-shrink: 0;
}

.upload-zone:hover, .upload-zone:active {
  border-color: var(--brand);
  background: var(--brand-light);
}

.upload-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 24px;
  text-align: center;
  pointer-events: none;
}

.upload-emoji { font-size: 40px; line-height: 1; }

.upload-placeholder p {
  font-size: 0.9rem;
  color: var(--text);
  font-weight: 500;
}

.upload-hint {
  font-size: 0.76rem;
  color: var(--hint);
}

.upload-preview {
  width: 100%;
  height: 220px;
  object-fit: cover;
  border-radius: calc(var(--r-lg) - 2px);
  display: block;
}

.btn-change {
  position: absolute;
  bottom: 10px;
  right: 10px;
  background: rgba(0,0,0,.55);
  color: #fff;
  border: none;
  border-radius: 20px;
  padding: 6px 14px;
  font-size: 0.78rem;
  cursor: pointer;
  backdrop-filter: blur(4px);
}

/* ── Tips list ─────────────────────────────────────────────── */
.tips {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px 14px;
  background: var(--brand-light);
  border-radius: var(--r-md);
  font-size: 0.83rem;
  color: var(--brand-dark);
}

/* ── Hint text ─────────────────────────────────────────────── */
.hint {
  font-size: 0.87rem;
  color: var(--hint);
  line-height: 1.5;
}

/* ── Buttons ───────────────────────────────────────────────── */
.btn-primary {
  width: 100%;
  padding: 14px;
  background: var(--brand);
  color: var(--btn-text);
  border: none;
  border-radius: var(--r-md);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity .15s, transform .1s;
  -webkit-appearance: none;
}

.btn-primary:active { transform: scale(.98); opacity: .9; }

.btn-primary:disabled {
  background: var(--section-sep);
  color: var(--hint);
  cursor: not-allowed;
}

.btn-icon {
  padding: 10px 12px;
  background: var(--brand-light);
  color: var(--brand);
  border: 1.5px solid var(--section-sep);
  border-radius: var(--r-sm);
  font-size: 1.1rem;
  cursor: pointer;
  flex-shrink: 0;
  transition: background .15s;
}

.btn-icon:active { background: var(--brand); color: #fff; }

/* ── Spinner ───────────────────────────────────────────────── */
.spinner {
  width: 48px;
  height: 48px;
  border: 4px solid var(--brand-light);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}

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

.loading-title {
  font-size: 1.1rem;
  font-weight: 600;
}

/* ── Success screen ────────────────────────────────────────── */
.success-circle {
  font-size: 64px;
  line-height: 1;
  animation: pop .4s cubic-bezier(.34,1.56,.64,1);
}

@keyframes pop {
  from { transform: scale(0); opacity: 0; }
  to   { transform: scale(1); opacity: 1; }
}

.screen-success h2 {
  font-size: 1.4rem;
  font-weight: 800;
}

/* ── Info card (success screen) ────────────────────────────── */
.info-card {
  width: 100%;
  background: var(--bg);
  border-radius: var(--r-lg);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.info-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  font-size: 0.88rem;
  border-bottom: 1px solid var(--section-sep);
}

.info-row:last-child { border-bottom: none; }

.info-row span { color: var(--hint); }

.badge-pending {
  background: #fff3cd;
  color: #856404;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.78rem;
}

/* ── Toast ─────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: #1c1c1e;
  color: #fff;
  padding: 10px 20px;
  border-radius: 20px;
  font-size: 0.85rem;
  max-width: calc(100vw - 40px);
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s, transform .25s;
  z-index: 9999;
  white-space: pre-line;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.toast.success { background: var(--brand); }
.toast.warning { background: var(--warning); }

/* ── Utility ───────────────────────────────────────────────── */
.hidden { display: none !important; }
