/* TicketPass — направление: «билет-корешок». Бумага с фактурой, перфорация, моноширинные данные. */
:root {
  --paper: #f4eee1;
  --paper-2: #ece4d2;
  --ink: #17140f;
  --ink-soft: #5c564b;
  --line: #d6cdb9;
  --field: #fffdf8;
  --accent: #e4572e;
  --accent-ink: #fff;
  --accent-text: #b8391a; /* акцент для мелкого текста: контраст на бумаге ≥ 4,5:1 */
  --pass: #0b3d91;

  --font-ui: ui-rounded, "SF Pro Rounded", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-data: ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  --space-1: 0.5rem;
  --space-2: 0.875rem;
  --space-3: 1.5rem;
  --space-4: 2.5rem;
  --radius: 14px;
  --duration: 160ms;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);

  /* тонкая бумажная фактура */
  --grain: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0  0 0 0 0 0  0 0 0 0 0  0 0 0 .07 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #14120e;
    --paper-2: #1b1812;
    --ink: #f3ecdd;
    --ink-soft: #a79f8e;
    --line: #2e2a21;
    --field: #1d1a14;
    --accent: #ff7a4d;
    --accent-ink: #17140f;
    --accent-text: #ff7a4d;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--grain), radial-gradient(1200px 500px at 85% -10%, color-mix(in srgb, var(--accent) 14%, transparent), transparent 60%), var(--paper);
  color: var(--ink);
  font: 16px/1.5 var(--font-ui);
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

.wrap { max-width: 1000px; margin: 0 auto; padding: var(--space-3) 16px var(--space-4); }
.center { text-align: center; }

/* ---------- Шапка ---------- */
.head { margin-bottom: var(--space-3); }
.eyebrow {
  display: inline-block;
  margin: 0 0 var(--space-1);
  padding: 4px 10px;
  border: 1.5px solid var(--ink);
  border-radius: 999px;
  font: 700 0.72rem var(--font-data);
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.head h1 {
  margin: 0 0 var(--space-1);
  font-size: clamp(2.6rem, 1.2rem + 7vw, 5rem);
  line-height: 0.95;
  letter-spacing: -0.05em;
  font-weight: 800;
}
.head h1 span { color: var(--accent); }
.sub { margin: 0; max-width: 46ch; color: var(--ink-soft); font-size: 1.05rem; }

.notice {
  margin: 0 0 var(--space-2);
  padding: 0.75rem 1rem;
  border: 1px dashed var(--accent);
  border-radius: var(--radius);
  font-size: 0.95rem;
}
.notice[hidden] { display: none; }

/* ---------- Сетка ---------- */
.grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--space-3); }
@media (min-width: 880px) {
  .grid { grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.9fr); align-items: start; gap: var(--space-4); }
  .preview { position: sticky; top: var(--space-3); }
}

/* ---------- Форма и шаги ---------- */
form { display: grid; gap: var(--space-3); }
.step { display: grid; gap: var(--space-2); }
.step h2 {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  font-size: 1.15rem;
  letter-spacing: -0.01em;
}
.step h2 b {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--ink);
  color: var(--paper);
  font: 800 0.85rem var(--font-data);
}

[data-for].hidden { display: none; }
.row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: var(--space-2); }

/* Вкладки */
.tabs { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs button {
  flex: 0 0 auto;
  min-height: 44px;
  padding: 0 1rem;
  border: 1.5px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--duration) var(--ease), border-color var(--duration) var(--ease), transform var(--duration) var(--ease);
}
.tabs button:hover { border-color: var(--ink-soft); }
.tabs button:active { transform: scale(0.97); }
.tabs button[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--paper); }

/* Поля */
.f { display: grid; gap: 6px; }
.f > span {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-soft);
}
.f input, .f select, .f textarea {
  width: 100%;
  min-height: 48px;
  padding: 0.7rem 0.85rem;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  background: var(--field);
  color: var(--ink);
  font: 1rem var(--font-data);
  transition: border-color var(--duration) var(--ease), box-shadow var(--duration) var(--ease);
}
.f textarea { resize: vertical; }
.f input:hover, .f select:hover, .f textarea:hover { border-color: var(--ink-soft); }
.f input:focus-visible, .f select:focus-visible, .f textarea:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 25%, transparent);
}
.f input[type="color"] { padding: 4px; height: 48px; cursor: pointer; }
.color { max-width: none; }
.color input[type="color"] { width: 44px; height: 44px; padding: 3px; border-radius: 50%; }
.design { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; }
.dice {
  min-height: 44px;
  padding: 0 16px;
  border: 1.5px solid var(--ink);
  border-radius: 12px;
  background: transparent;
  color: var(--ink);
  font: 700 0.95rem var(--font-ui);
  cursor: pointer;
  transition: transform var(--duration) var(--ease), background var(--duration) var(--ease);
}
.dice:hover { background: color-mix(in srgb, var(--ink) 8%, transparent); transform: translateY(-1px); }
.dice:active { transform: translateY(1px) scale(0.98); }
.dice:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.code { margin: 0; padding: var(--space-2); display: grid; gap: var(--space-2); border: 1.5px dashed var(--line); border-radius: var(--radius); }
.code legend { padding: 0 6px; font-weight: 700; }

/* Обложка */
.cover { display: grid; gap: 10px; justify-items: start; padding: var(--space-2); border: 1.5px solid var(--line); border-radius: var(--radius); background: color-mix(in srgb, var(--accent) 5%, var(--field)); }
.cover-status { margin: 0; font-weight: 700; }
.picks { display: flex; gap: 10px; overflow-x: auto; width: 100%; padding: 2px 2px 6px; scrollbar-width: thin; }
.picks[hidden] { display: none; }
.pick {
  flex: 0 0 auto;
  display: grid;
  justify-items: center;
  gap: 4px;
  width: 84px;
  padding: 6px 4px;
  border: 2px solid transparent;
  border-radius: 12px;
  background: transparent;
  color: var(--ink);
  font: 600 0.72rem var(--font-ui);
  line-height: 1.15;
  text-align: center;
  cursor: pointer;
  transition: border-color var(--duration) var(--ease), transform var(--duration) var(--ease);
}
.pick img { width: 56px; height: 56px; border-radius: 50%; object-fit: cover; background: var(--line); }
.pick span { max-width: 100%; overflow-wrap: anywhere; }
.pick:hover { transform: translateY(-2px); }
.pick[aria-pressed="true"] { border-color: var(--accent); }
.pick:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.cover-tools { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; }
.cover-tools .drop { width: auto; padding: 0.55rem 0.9rem; grid-auto-flow: column; align-items: baseline; gap: 10px; }
.cover-tools .drop-title { font-size: 0.95rem; }
.cover-tools .drop-sub { font-size: 0.8rem; }
.drop {
  display: grid;
  gap: 2px;
  width: 100%;
  padding: 1rem 1.1rem;
  border: 2px dashed var(--ink-soft);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--accent) 7%, var(--field));
  cursor: pointer;
  transition: border-color var(--duration) var(--ease), background var(--duration) var(--ease), transform var(--duration) var(--ease);
}
.drop:hover, .drop.over { border-color: var(--accent); transform: translateY(-1px); }
.drop.over { background: color-mix(in srgb, var(--accent) 16%, var(--field)); }
.drop.done { border-style: solid; border-color: var(--accent); }
.drop-title { font-weight: 800; }
.drop-sub { font-size: 0.9rem; color: var(--ink-soft); }
.link { padding: 4px 0; border: 0; background: none; color: var(--accent-text); font: 600 0.9rem var(--font-ui); cursor: pointer; text-decoration: underline; }
.link[hidden] { display: none; }

/* Кнопки Wallet */
.actions { display: flex; flex-direction: column; gap: 18px; }
.wallet {
  display: flex;
  align-items: center;
  gap: 16px;
  width: 100%;
  min-height: 76px;
  padding: 0 24px;
  border: 0;
  border-radius: 16px;
  font: 700 1.2rem var(--font-ui);
  text-align: left;
  color: #fff;
  cursor: pointer;
  transition: transform var(--duration) var(--ease), filter var(--duration) var(--ease);
}
.wallet .ico { flex: 0 0 auto; width: auto; height: 48px; }
.wtxt { flex: 1; min-width: 0; line-height: 1.15; }
.go { font-size: 1.8rem; font-weight: 700; transition: transform var(--duration) var(--ease); }
.wallet:hover:not([disabled]) { transform: translateY(-2px); filter: brightness(1.12); }
.wallet:hover:not([disabled]) .go { transform: translateX(5px); }
.wallet:active:not([disabled]) { transform: translateY(1px) scale(0.99); }
.wallet:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }

/* Фирменные цвета: Apple — чёрный, Google Wallet — синий Google. Плоско, без декора. */
.wallet.apple { background: #000; }
.wallet.apple[disabled] { cursor: not-allowed; }
.wallet.google { background: #1a73e8; }
.wallet.google .ico { background: #fff; border-radius: 10px; padding: 5px; box-sizing: content-box; height: 38px; }
.badge {
  flex: 0 0 auto;
  padding: 5px 12px;
  border-radius: 999px;
  background: #fff;
  color: #000;
  font-size: .8rem;
  font-weight: 700;
  white-space: nowrap;
}
.badge[hidden] { display: none; }
@media (prefers-reduced-motion: reduce) { .wallet, .go { transition: none !important; } }

/* Как это работает, подсказки, ошибки, FAQ */
.how { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin: 0 0 var(--space-3); padding: 0; list-style: none; counter-reset: s; }
.how li { display: grid; gap: 6px; align-content: start; padding: 12px; border: 1px dashed var(--line); border-radius: var(--radius); font-size: .88rem; color: var(--ink-soft); line-height: 1.35; }
.how b { justify-self: start; padding: 3px 10px; border-radius: 999px; background: var(--ink); color: var(--paper); font: 700 .75rem var(--font-data); letter-spacing: .04em; text-transform: uppercase; }
@media (max-width: 560px) { .how { grid-template-columns: minmax(0, 1fr); } .how li { grid-template-columns: auto 1fr; align-items: center; } }
.hintrow { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 6px 14px; }
.hintrow .hint { flex: 1 1 220px; }
.help { border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; font-size: .88rem; color: var(--ink-soft); }
.help summary, .faq summary { cursor: pointer; font-weight: 600; color: var(--ink); }
.help p, .faq p { margin: 8px 0 0; line-height: 1.45; }
.ready { margin: 0; font: 600 .9rem var(--font-ui); color: var(--ink-soft); }
.ready.ok { color: #2e7d32; }
@media (prefers-color-scheme: dark) { .ready.ok { color: #7ad07f; } }
::placeholder { color: var(--ink-soft); opacity: .7; }
.foot a { color: var(--accent-text); }
.form-error { margin: 0; padding: 10px 14px; border-radius: 10px; border: 1px solid #c62828; background: color-mix(in srgb, #c62828 10%, var(--field)); color: var(--ink); font-size: .92rem; line-height: 1.4; }
.form-error[hidden] { display: none; }
.f input[aria-invalid="true"], .f textarea[aria-invalid="true"] { border-color: #c62828; }
.faq { display: grid; gap: 8px; margin: var(--space-4) 0 var(--space-3); }
.faq details { padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--field); }

.tabs button:focus-visible, .wallet:focus-visible, .link:focus-visible, .drop:focus-within {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}
.hint { margin: 0; font-size: 0.85rem; color: var(--ink-soft); }

/* ---------- Предпросмотр пасса ---------- */
.pass {
  --notch: 14px;
  position: relative;
  padding: 18px 18px 22px;
  border-radius: 20px;
  background:
    linear-gradient(160deg, rgba(255,255,255,.14), rgba(255,255,255,0) 45%),
    var(--pass);
  color: #fff;
  box-shadow: 0 1px 0 rgba(255,255,255,.2) inset, 0 24px 44px -20px rgba(0,0,0,.6);
  transition: background-color var(--duration) var(--ease);
  -webkit-mask:
    radial-gradient(circle var(--notch) at 0 var(--cut, 66%), #0000 98%, #000) left / 51% 100% no-repeat,
    radial-gradient(circle var(--notch) at 100% var(--cut, 66%), #0000 98%, #000) right / 51% 100% no-repeat;
  mask:
    radial-gradient(circle var(--notch) at 0 var(--cut, 66%), #0000 98%, #000) left / 51% 100% no-repeat,
    radial-gradient(circle var(--notch) at 100% var(--cut, 66%), #0000 98%, #000) right / 51% 100% no-repeat;
}
.pass.swap { animation: swap 260ms var(--ease); }
@keyframes swap { from { opacity: 0.4; transform: translateY(8px) scale(0.985); } to { opacity: 1; transform: none; } }

.pass-top { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; font-size: 0.95rem; }
.pass-top strong { font-weight: 800; letter-spacing: 0.02em; }
.pass-top span { font: 700 0.95rem var(--font-data); opacity: 0.9; }

/* Полоса с названием; с обложкой — те же пропорции 750:196, что и в Wallet */
.pass-hero { margin: 18px -18px; padding: 0 18px; background-size: cover; background-position: center; }
.pass-hero.has-cover { aspect-ratio: 750 / 196; display: flex; align-items: flex-end; padding-bottom: 12px; }
.pass-hero.has-cover .pass-main { margin: 0; width: 100%; text-shadow: 0 1px 10px rgba(0,0,0,.65); }

.pass-main { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; margin: 0; }
.pass-main .cell { min-width: 0; }
.pass-main .cell:last-child:not(:first-child) { text-align: right; }
.cell small, .pass-sec small { display: block; font-size: 0.65rem; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; opacity: 0.75; }
.pass-main .cell b {
  display: block;
  font: 800 clamp(1.6rem, 1rem + 3vw, 2.4rem) / 1.05 var(--font-data);
  letter-spacing: -0.02em;
  overflow-wrap: anywhere;
}
.pass-sec {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px 12px;
  padding-bottom: 22px;
  margin-bottom: 18px;
  border-bottom: 2px dashed rgba(255,255,255,.35);
}
.pass-sec[hidden] { display: none; }
.pass-sec b { display: block; font: 700 1rem var(--font-data); overflow-wrap: anywhere; }

.pass-qr { display: grid; place-items: center; }
#p-code {
  display: grid;
  place-items: center;
  width: 148px;
  height: 148px;
  padding: 10px;
  border-radius: 12px;
  background: #fff;
  color: #17140f;
  font: 700 0.75rem var(--font-data);
  text-align: center;
  white-space: pre-line;
  overflow-wrap: anywhere;
}

/* ---------- Футер ---------- */
.foot { margin-top: var(--space-4); padding-top: var(--space-2); border-top: 1.5px solid var(--line); font-size: 0.9rem; }
.foot a { color: var(--accent); font-weight: 600; }
.muted { color: var(--ink-soft); font-size: 0.8rem; }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
.color input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
.color input[type="color"]::-webkit-color-swatch { border: 0; border-radius: 50%; }
