/* ───────── Brand fonts (self-hosted, no CSP issues) ───────── */
@font-face {
  font-family: 'Monument Extended';
  src: url('/static/fonts/MonumentExtended-Bold.woff2') format('woff2');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Monument Extended';
  src: url('/static/fonts/MonumentExtended-Regular.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

/* ───────── Theme tokens ───────── */
:root {
  --bg: #08090d;
  --bg-elevated: #11131c;
  --bg-card: #161827;
  --text: #ecedf3;
  --text-muted: #8a8da0;
  --text-soft: #b9bccd;
  --accent-primary: #6366f1;
  --accent-secondary: #a855f7;
  --accent-gradient: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #a855f7 100%);
  --accent-gradient-soft: linear-gradient(135deg, rgba(99,102,241,0.18) 0%, rgba(168,85,247,0.18) 100%);
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.14);
  --shadow-glow: 0 8px 28px -6px rgba(99, 102, 241, 0.45);
  --radius: 14px;
  --radius-lg: 20px;
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;
  --space-2xl: 48px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 17px;
  line-height: 1.6;
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Атмосферный фон — мягкое свечение от градиента в углу */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 800px 600px at 90% -20%, rgba(168, 85, 247, 0.14), transparent 60%),
    radial-gradient(ellipse 700px 500px at -10% 110%, rgba(99, 102, 241, 0.10), transparent 60%);
  pointer-events: none;
  z-index: 0;
}

/* ───────── Header ───────── */
.page-header {
  position: relative;
  z-index: 2;
  padding: var(--space-lg);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(8px);
}

.bozex-logo {
  font-family: 'Monument Extended', 'Trebuchet MS', sans-serif;
  font-size: 1.9rem;
  font-weight: 700;
  letter-spacing: 4px;
  text-transform: uppercase;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  text-decoration: none;
  display: inline-block;
  filter: drop-shadow(0 4px 12px rgba(168, 85, 247, 0.25));
}

/* ───────── Layout ───────── */
.container {
  position: relative;
  z-index: 1;
  max-width: 600px;
  margin: 0 auto;
  padding: var(--space-2xl) var(--space-lg) var(--space-2xl);
}

.title {
  font-size: 2rem;
  font-weight: 700;
  line-height: 1.2;
  margin: 0 0 var(--space-md) 0;
  letter-spacing: -0.02em;
}

.subtitle {
  color: var(--text-soft);
  margin: 0 0 var(--space-2xl) 0;
  font-size: 1.05rem;
  line-height: 1.55;
}

/* ───────── Notice (важная подсказка про чек) ───────── */
.notice {
  display: flex;
  gap: var(--space-md);
  align-items: flex-start;
  background: linear-gradient(135deg, rgba(99,102,241,0.10) 0%, rgba(168,85,247,0.10) 100%);
  border: 1px solid rgba(168, 85, 247, 0.32);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  margin-bottom: var(--space-lg);
}
.notice-icon {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  font-family: 'Monument Extended', 'Trebuchet MS', sans-serif;
  font-weight: 700;
  font-size: 1.3rem;
  line-height: 1;
  color: white;
  background: var(--accent-gradient);
  border-radius: 50%;
  box-shadow: 0 4px 14px -2px rgba(168, 85, 247, 0.55);
}
.notice-body { flex: 1; min-width: 0; }
.notice-title {
  margin: 0 0 var(--space-sm) 0;
  font-weight: 600;
  font-size: 1.08rem;
  line-height: 1.4;
  letter-spacing: -0.01em;
  color: var(--text);
}
.notice-text {
  margin: 0;
  font-size: 0.98rem;
  line-height: 1.55;
  color: var(--text-soft);
}
/* ───────── Warn card (отдельная акцентная плашка с инструкцией о чеке) ───────── */
.warn-card {
  display: flex;
  gap: var(--space-md);
  align-items: flex-start;
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.10) 0%, rgba(239, 68, 68, 0.08) 100%);
  border: 1px solid rgba(245, 158, 11, 0.45);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  margin-bottom: var(--space-lg);
  box-shadow: 0 8px 24px -10px rgba(245, 158, 11, 0.25);
}
.warn-icon {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  font-family: 'Monument Extended', 'Trebuchet MS', sans-serif;
  font-weight: 700;
  font-size: 1.3rem;
  line-height: 1;
  color: white;
  background: linear-gradient(135deg, #f59e0b 0%, #ea580c 100%);
  border-radius: 50%;
  box-shadow: 0 4px 14px -2px rgba(245, 158, 11, 0.5);
}
.warn-body { flex: 1; min-width: 0; }
.warn-text {
  margin: 0;
  font-size: 1rem;
  line-height: 1.55;
  color: #fde68a;
}
.warn-cap {
  margin: var(--space-md) 0 0 0;
  font-weight: 700;
  font-size: 1.25rem;
  line-height: 1.35;
  color: #fde68a;
  letter-spacing: -0.01em;
  text-shadow: 0 0 18px rgba(252, 211, 77, 0.5), 0 0 4px rgba(252, 211, 77, 0.35);
}

/* ───────── Instruction (свёрнутая по умолчанию, акцентный summary) ───────── */
.instruction {
  background: linear-gradient(180deg, var(--bg-elevated) 0%, var(--bg-card) 100%);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  padding: 0;
  margin-bottom: var(--space-2xl);
  box-shadow: 0 8px 32px -16px rgba(0, 0, 0, 0.6);
  overflow: hidden;
  transition: border-color 0.2s;
}
.instruction:hover {
  border-color: rgba(168, 85, 247, 0.4);
}

.instruction summary {
  cursor: pointer;
  user-select: none;
  list-style: none;
  display: grid;
  grid-template-columns: 36px 1fr auto;
  grid-template-areas:
    "q title title"
    ". .     meta";
  column-gap: var(--space-md);
  row-gap: var(--space-sm);
  padding: var(--space-lg);
  font-weight: 600;
  font-size: 1.15rem;
  letter-spacing: -0.01em;
  position: relative;
  align-items: center;
}
.instruction summary::-webkit-details-marker { display: none; }
/* Стрелка теперь часть .instruction-hint — старый ::after отключён */
.instruction summary::after { content: none; }

.instruction-q {
  grid-area: q;
  align-self: start;
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  font-family: 'Monument Extended', 'Trebuchet MS', sans-serif;
  font-weight: 700;
  font-size: 1.25rem;
  line-height: 1;
  color: white;
  background: var(--accent-gradient);
  border-radius: 50%;
  box-shadow: 0 4px 14px -2px rgba(168, 85, 247, 0.55);
}

.instruction-label {
  grid-area: title;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* «8 шагов ↓» — объединённая pill-кнопка: label + chevron как один visual */
.instruction-hint {
  grid-area: meta;
  justify-self: end;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  font-size: 1rem;
  color: #bbf7d0;
  background: rgba(134, 239, 172, 0.14);
  padding: 8px 18px;
  border-radius: 999px;
  border: 1px solid rgba(134, 239, 172, 0.55);
  box-shadow: 0 0 16px rgba(134, 239, 172, 0.32), inset 0 0 8px rgba(134, 239, 172, 0.1);
  letter-spacing: 0;
  transition: background 0.2s, box-shadow 0.2s, border-color 0.2s;
}
.instruction-hint::after {
  content: '';
  display: inline-block;
  width: 16px;
  height: 16px;
  background: currentColor;
  -webkit-mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><polyline fill='none' stroke='black' stroke-width='3' points='6 9 12 15 18 9'/></svg>") center/contain no-repeat;
          mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><polyline fill='none' stroke='black' stroke-width='3' points='6 9 12 15 18 9'/></svg>") center/contain no-repeat;
  transition: transform 0.25s ease;
}
.instruction[open] .instruction-hint::after {
  transform: rotate(180deg);
}
.instruction summary:hover .instruction-hint {
  background: rgba(134, 239, 172, 0.2);
  border-color: rgba(134, 239, 172, 0.7);
  box-shadow: 0 0 22px rgba(134, 239, 172, 0.45), inset 0 0 10px rgba(134, 239, 172, 0.14);
}

/* Padding для содержимого инструкции после summary */
.instruction[open] .steps {
  padding: 0 var(--space-lg) var(--space-md);
}

/* ───────── Steps ───────── */
.steps {
  list-style: none;
  padding: 0;
  margin: 0;
}

.steps > li {
  position: relative;
  padding: var(--space-lg) 0 var(--space-2xl);
}

/* Stylish gradient divider with center diamond glyph */
.steps > li:not(:first-child)::before {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: min(80%, 240px);
  height: 1px;
  background: linear-gradient(90deg,
    transparent 0%,
    rgba(99, 102, 241, 0.45) 35%,
    rgba(168, 85, 247, 0.85) 50%,
    rgba(99, 102, 241, 0.45) 65%,
    transparent 100%);
}
.steps > li:not(:first-child)::after {
  content: '';
  position: absolute;
  top: -4px;
  left: 50%;
  transform: translateX(-50%) rotate(45deg);
  width: 8px;
  height: 8px;
  background: var(--accent-gradient);
  box-shadow: 0 0 12px rgba(168, 85, 247, 0.6);
}

.step-head {
  display: flex;
  gap: var(--space-md);
  align-items: flex-start;
  margin-bottom: var(--space-md);
}

.step-num {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  font-family: 'Monument Extended', 'Trebuchet MS', sans-serif;
  font-weight: 700;
  font-size: 1.15rem;
  line-height: 1;
  color: white;
  background: var(--accent-gradient);
  border-radius: 12px;
  box-shadow: var(--shadow-glow);
  letter-spacing: 0;
}

.step-body {
  flex: 1;
  min-width: 0;
}

.step-text {
  margin: 0;
  font-size: 1.08rem;
  line-height: 1.55;
  color: var(--text);
}

.step-text em {
  font-style: normal;
  font-weight: 600;
  color: var(--text);
  background: var(--accent-gradient-soft);
  padding: 1px 8px;
  border-radius: 6px;
  border: 1px solid rgba(168, 85, 247, 0.25);
  white-space: nowrap;
}

.step-shot {
  margin: var(--space-md) 0 0 calc(44px + var(--space-md));
}
.step-shot img {
  width: 100%;
  max-width: 280px;
  height: auto;
  border-radius: 14px;
  display: block;
  background: #000;
  border: 1px solid var(--border-strong);
  box-shadow: 0 12px 32px -12px rgba(0, 0, 0, 0.7);
}

/* Step без скрина (последние шаги — указатель на форму) — выделить */
.step-action .step-text {
  font-weight: 600;
  font-size: 1.15rem;
}

/* ───────── Form ───────── */
.form {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
  margin-top: var(--space-lg);
}

textarea#rawInput {
  width: 100%;
  background: var(--bg-card);
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: var(--space-md);
  font-family: ui-monospace, SFMono-Regular, 'JetBrains Mono', monospace;
  font-size: 13px;
  resize: vertical;
  min-height: 88px;
  transition: border-color 0.2s, box-shadow 0.2s;
}
textarea#rawInput:focus {
  outline: none;
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.18);
}

.btn,
.btn * {
  -webkit-touch-callout: none !important;
  -webkit-user-select: none !important;
  -moz-user-select: none !important;
  -ms-user-select: none !important;
  user-select: none !important;
}
.btn {
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  min-height: 60px;
  padding: 0 var(--space-lg);
  border-radius: var(--radius);
  font-size: 1.05rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  border: none;
  font-family: inherit;
  -webkit-appearance: none;
  letter-spacing: -0.01em;
  transition: transform 0.1s ease, box-shadow 0.25s ease, border-color 0.2s;
}
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* Version badge — справа сверху над pasteBtn, для диагностики кеша */
.version-badge {
  position: relative;
  text-align: right;
  font-size: 0.72rem;
  font-weight: 600;
  color: rgba(187, 247, 208, 0.65);
  background: rgba(134, 239, 172, 0.08);
  border: 1px solid rgba(134, 239, 172, 0.35);
  border-radius: 999px;
  padding: 2px 10px;
  margin-bottom: 6px;
  margin-right: 2px;
  margin-left: auto;
  letter-spacing: 0.5px;
  font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Consolas, monospace;
  align-self: flex-end;
  display: inline-block;
  width: max-content;
}

/* Подсказка-сноска внутри шага инструкции (фиолетовая accent-плашка слева) */
.step-tip {
  margin: var(--space-sm) 0 0 0;
  padding: 8px 12px;
  background: rgba(168, 85, 247, 0.08);
  border-left: 3px solid rgba(168, 85, 247, 0.5);
  border-radius: 0 8px 8px 0;
  font-size: 0.92rem;
  line-height: 1.5;
  color: rgba(229, 231, 235, 0.85);
}
.step-tip em {
  font-style: normal;
  color: #c4b5fd;
  font-weight: 600;
}

/* Inline feedback под кнопкой «Вставить из буфера» */
.paste-feedback {
  margin-top: calc(var(--space-sm) * -1 + 2px);
  margin-bottom: var(--space-sm);
  padding: 10px 14px;
  border-radius: var(--radius-md, 10px);
  font-size: 0.92rem;
  line-height: 1.45;
  font-weight: 500;
  background: linear-gradient(180deg, rgba(245, 158, 11, 0.14) 0%, rgba(245, 158, 11, 0.06) 100%);
  border: 1px solid rgba(245, 158, 11, 0.45);
  color: #fde68a;
  text-align: left;
  display: none;
}
.paste-feedback.show { display: block; }
.paste-feedback.ok {
  background: linear-gradient(180deg, rgba(134, 239, 172, 0.14) 0%, rgba(134, 239, 172, 0.06) 100%);
  border-color: rgba(134, 239, 172, 0.5);
  color: #bbf7d0;
}
.paste-feedback b { font-weight: 700; }

.btn-primary {
  background: var(--accent-gradient);
  color: white;
  box-shadow: var(--shadow-glow);
}
.btn-primary:not(:disabled):hover {
  box-shadow: 0 12px 36px -8px rgba(168, 85, 247, 0.55);
}

.btn-secondary {
  background: var(--bg-card);
  color: var(--text);
  border: 1px solid var(--border-strong);
}
.btn-secondary:not(:disabled):hover {
  border-color: var(--accent-primary);
  background: var(--bg-elevated);
}

/* Валидный URL вставлен → кнопка горит зелёным glow (визуальное подтверждение что готово) */
.btn-secondary.btn-valid {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: white;
  border-color: transparent;
  box-shadow: 0 8px 28px -6px rgba(16, 185, 129, 0.55);
  animation: btn-pulse-green 1.4s ease-in-out infinite;
}
.btn-secondary.btn-valid:hover {
  background: linear-gradient(135deg, #34d399 0%, #10b981 100%);
  border-color: transparent;
  box-shadow: 0 12px 36px -8px rgba(16, 185, 129, 0.7);
}
@keyframes btn-pulse-green {
  0%, 100% { box-shadow: 0 8px 28px -6px rgba(16, 185, 129, 0.55); }
  50%      { box-shadow: 0 8px 32px -4px rgba(16, 185, 129, 0.85); }
}

.btn-copy {
  background: var(--accent-gradient);
  color: white;
  width: 100%;
  margin-top: var(--space-md);
  box-shadow: var(--shadow-glow);
}

.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.btn-icon svg { display: block; }

/* ───────── Result ───────── */
.result {
  margin-top: var(--space-2xl);
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.code-card {
  background: linear-gradient(180deg, var(--bg-elevated) 0%, var(--bg-card) 100%);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  position: relative;
  overflow: hidden;
}
.code-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--accent-gradient);
}
.code-card.used { opacity: 0.55; }

.code-card-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 0.95rem;
  color: var(--text-muted);
  margin-bottom: var(--space-md);
}
.code-product {
  color: var(--text);
  font-weight: 600;
  font-size: 1.05rem;
  letter-spacing: -0.01em;
}

.code-value {
  font-family: ui-monospace, SFMono-Regular, 'JetBrains Mono', monospace;
  font-size: 2.5rem;
  font-weight: 700;
  letter-spacing: 6px;
  text-align: center;
  padding: var(--space-md) 0;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.code-status {
  margin-top: var(--space-md);
  padding: var(--space-md);
  background: rgba(255, 255, 255, 0.04);
  border-radius: 10px;
  font-size: 0.95rem;
  color: var(--text-soft);
  text-align: center;
  border: 1px solid var(--border);
}

/* ───────── Errors / banners ───────── */
.error-box, .banner-warning {
  margin-top: var(--space-lg);
  padding: var(--space-md) var(--space-lg);
  border-radius: var(--radius);
  background: rgba(239, 68, 68, 0.08);
  border: 1px solid rgba(239, 68, 68, 0.32);
  color: #fca5a5;
  font-size: 1rem;
  line-height: 1.5;
}
.banner-warning {
  background: rgba(234, 179, 8, 0.08);
  border-color: rgba(234, 179, 8, 0.32);
  color: #fde68a;
}

/* ───────── Toast ───────── */
.toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(8, 9, 13, 0.95);
  color: white;
  padding: 14px 22px;
  border-radius: 12px;
  font-size: 0.95rem;
  font-weight: 500;
  border: 1px solid var(--border-strong);
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
  animation: toast-in 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 1000;
}
@keyframes toast-in {
  from { opacity: 0; transform: translate(-50%, 12px); }
  to   { opacity: 1; transform: translate(-50%, 0); }
}

/* ───────── Responsive ───────── */
@media (max-width: 420px) {
  html, body { font-size: 16px; }
  .container { padding: var(--space-xl) var(--space-md) var(--space-xl); }
  .title { font-size: 1.6rem; }
  .bozex-logo { font-size: 1.5rem; letter-spacing: 3px; }
  .step-num { width: 38px; height: 38px; font-size: 1rem; border-radius: 10px; }
  .step-shot { margin-left: calc(38px + var(--space-md)); }
  .code-value { font-size: 2rem; letter-spacing: 4px; }
}

/* ───────── Custom scrollbars (per global UI rule) ───────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #2a2a4a; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #3a3a5a; }
::-webkit-scrollbar-button { display: none; }
* { scrollbar-width: thin; scrollbar-color: #2a2a4a transparent; }
