:root {
  color-scheme: dark;
  --bg: var(--tg-theme-bg-color, #10110f);
  --surface: var(--tg-theme-secondary-bg-color, #191a17);
  --surface-strong: #22231f;
  --text: var(--tg-theme-text-color, #f4f4ed);
  --muted: var(--tg-theme-hint-color, #a7a99f);
  --line: rgba(255, 255, 255, 0.1);
  --accent: #dfff31;
  --accent-text: #11120e;
  --danger: #ff8279;
  --warning: #ffd36b;
  --radius: 22px;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
}

* { box-sizing: border-box; }

html { min-height: 100%; background: var(--bg); }

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(circle at 85% -10%, rgba(223, 255, 49, 0.11), transparent 34rem),
    var(--bg);
}

button, input, textarea { font: inherit; }

button, label, input, textarea { -webkit-tap-highlight-color: transparent; }

.shell {
  width: min(100%, 760px);
  margin: 0 auto;
  padding: max(20px, env(safe-area-inset-top)) 16px max(32px, env(safe-area-inset-bottom));
}

.brand {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 4px 2px 22px;
}

.brand-mark {
  display: grid;
  width: 48px;
  height: 48px;
  place-items: center;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-text);
  font-weight: 900;
  font-size: 22px;
}

.eyebrow, .step {
  margin: 0 0 3px;
  color: var(--accent);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.14em;
}

h1, h2, legend, p { margin-top: 0; }

h1 { margin-bottom: 0; font-size: clamp(22px, 5vw, 30px); line-height: 1.05; letter-spacing: -0.035em; }

h2, legend { margin-bottom: 0; padding: 0; font-size: 18px; line-height: 1.2; font-weight: 760; letter-spacing: -0.02em; }

.secure-badge {
  align-self: start;
  padding: 7px 10px;
  border: 1px solid rgba(223, 255, 49, 0.25);
  border-radius: 999px;
  color: var(--accent);
  background: rgba(223, 255, 49, 0.07);
  font-size: 11px;
  white-space: nowrap;
}

form { display: grid; gap: 12px; }

.card, .progress-panel, .notice {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--surface) 96%, transparent);
}

.card { padding: 18px; }

fieldset { min-width: 0; margin: 0; }

.section-heading {
  display: flex;
  min-height: 42px;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.inline-heading { margin-bottom: 10px; }

.muted, .optional { color: var(--muted); font-size: 13px; }

label:not(.dropzone, .platform, .radio-row) {
  display: block;
  margin: 16px 0 7px;
  font-size: 14px;
  font-weight: 650;
}

textarea, input[type="url"] {
  width: 100%;
  min-height: 48px;
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  outline: none;
  background: var(--surface-strong);
  color: var(--text);
  font-size: 16px;
  line-height: 1.45;
}

textarea { resize: vertical; }

textarea:focus, input[type="url"]:focus, button:focus-visible, .dropzone:focus-within, .platform:has(input:focus-visible), .radio-row:has(input:focus-visible) {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(223, 255, 49, 0.14);
}

textarea::placeholder, input::placeholder { color: color-mix(in srgb, var(--muted) 72%, transparent); }

#files {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

.dropzone {
  display: grid;
  min-height: 150px;
  place-items: center;
  align-content: center;
  gap: 7px;
  padding: 24px;
  border: 1px dashed rgba(223, 255, 49, 0.38);
  border-radius: 18px;
  background: linear-gradient(145deg, rgba(223, 255, 49, 0.075), rgba(255, 255, 255, 0.025));
  cursor: pointer;
  text-align: center;
}

.dropzone strong { font-size: 18px; }
.dropzone span:last-child { color: var(--muted); font-size: 13px; }
.dropzone-icon { display: grid; width: 42px; height: 42px; place-items: center; border-radius: 50%; background: var(--accent); color: var(--accent-text); font-size: 27px; line-height: 1; }

.file-list { display: grid; gap: 8px; margin: 12px 0 0; padding: 0; list-style: none; }
.file-item { display: grid; grid-template-columns: 42px minmax(0, 1fr) auto; align-items: center; gap: 10px; min-height: 58px; padding: 8px 10px; border-radius: 14px; background: var(--surface-strong); }
.file-kind { display: grid; width: 42px; height: 42px; place-items: center; border-radius: 11px; background: rgba(255, 255, 255, 0.07); font-size: 19px; }
.file-copy { min-width: 0; }
.file-copy strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.file-copy small { color: var(--muted); }
.remove-file { width: 44px; height: 44px; border: 0; border-radius: 50%; background: transparent; color: var(--muted); cursor: pointer; font-size: 22px; }
.remove-file:hover { background: rgba(255, 255, 255, 0.07); color: var(--text); }

.platform-help { margin: -8px 0 12px; }
.platform-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.platform { position: relative; display: flex; min-height: 48px; align-items: center; padding: 0 13px; border: 1px solid var(--line); border-radius: 13px; background: var(--surface-strong); cursor: pointer; }
.platform input { position: absolute; opacity: 0; pointer-events: none; }
.platform span { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 650; }
.platform span::before { content: ""; width: 17px; height: 17px; border: 1px solid var(--muted); border-radius: 5px; }
.platform:has(input:checked) { border-color: rgba(223, 255, 49, 0.45); background: rgba(223, 255, 49, 0.08); }
.platform input:checked + span::before { border-color: var(--accent); background: var(--accent); box-shadow: inset 0 0 0 4px var(--surface-strong); }

.text-button { min-height: 44px; padding: 0 4px; border: 0; background: none; color: var(--accent); cursor: pointer; font-size: 13px; font-weight: 700; }

.compact-card { display: grid; gap: 8px; }
.radio-row { display: grid; grid-template-columns: 20px 1fr; align-items: start; gap: 11px; min-height: 62px; padding: 12px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface-strong); cursor: pointer; }
.radio-row input { width: 18px; height: 18px; margin: 2px 0 0; accent-color: var(--accent); }
.radio-row strong, .radio-row small { display: block; }
.radio-row strong { font-size: 14px; }
.radio-row small { margin-top: 3px; color: var(--muted); font-size: 12px; line-height: 1.35; }

.progress-panel { padding: 17px; }
.progress-copy, .progress-meta { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.progress-copy strong { display: block; max-width: 70vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
#progress-percent { font-size: 20px; font-weight: 800; font-variant-numeric: tabular-nums; }
.progress-track { height: 9px; margin: 14px 0 9px; overflow: hidden; border-radius: 999px; background: rgba(255, 255, 255, 0.08); }
.progress-track span { display: block; width: 0; height: 100%; border-radius: inherit; background: var(--accent); transition: width 160ms ease-out; }
.progress-meta { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }

.notice { padding: 14px 16px; margin-bottom: 12px; line-height: 1.45; }
.notice-warning { border-color: rgba(255, 211, 107, 0.3); color: var(--warning); background: rgba(255, 211, 107, 0.06); }
.status { min-height: 0; margin: 4px 2px 0; color: var(--muted); font-size: 13px; line-height: 1.45; }
.error { margin: 0; padding: 13px 15px; border: 1px solid rgba(255, 130, 121, 0.28); border-radius: 14px; color: var(--danger); background: rgba(255, 130, 121, 0.07); font-size: 14px; line-height: 1.45; }

.actions { position: sticky; bottom: max(8px, env(safe-area-inset-bottom)); z-index: 5; display: grid; grid-template-columns: 1fr auto; gap: 8px; padding: 8px; border: 1px solid var(--line); border-radius: 18px; background: rgba(16, 17, 15, 0.88); backdrop-filter: blur(18px); }
.primary-button, .secondary-button { min-height: 52px; padding: 0 20px; border: 0; border-radius: 13px; cursor: pointer; font-weight: 800; }
.primary-button { background: var(--accent); color: var(--accent-text); }
.secondary-button { border: 1px solid var(--line); background: var(--surface-strong); color: var(--text); }
button:disabled { cursor: wait; opacity: 0.55; }

footer { padding: 18px 8px 0; color: var(--muted); font-size: 12px; line-height: 1.5; text-align: center; }
footer p { margin-bottom: 0; }

[hidden] { display: none !important; }

@media (min-width: 620px) {
  .shell { padding-inline: 24px; }
  .card { padding: 22px; }
  .platform-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
