:root {
  --paper: #FAF7F1;
  --paper-dim: #F2EEE5;
  --ink: #1C1A17;
  --shu: #A6291D;
  --shu-soft: rgba(166,41,29,0.08);
  --stone: #8C8779;
  --line: #E1DACB;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { -webkit-tap-highlight-color: transparent; overscroll-behavior: none; height: 100%; }

body {
  background: var(--paper);
  font-family: 'Montserrat', sans-serif;
}

.app {
  position: relative;
  min-height: 100vh;
  min-height: 100dvh;
  overflow: hidden;
}

.screen {
  display: flex;
  flex-direction: column;
  padding: 32px 26px 24px;
  position: absolute;
  inset: 0;
  opacity: 0;
  transform: translateY(10px) scale(0.99);
  transition: opacity 0.32s cubic-bezier(.22,.61,.36,1), transform 0.32s cubic-bezier(.22,.61,.36,1);
  pointer-events: none;
}
.screen.active { opacity: 1; transform: translateY(0) scale(1); pointer-events: auto; }

.topbar { display: flex; align-items: center; gap: 12px; margin-bottom: 28px; min-height: 20px; align-self: stretch; width: 100%; }
.back-arrow { font-size: 13px; color: var(--stone); cursor: pointer; letter-spacing: 0.05em; transition: opacity 0.15s ease; }
.back-arrow:active { opacity: 0.5; }
.back-arrow--floating { position: absolute; top: 32px; left: 26px; z-index: 5; }

/* ---------- ENSO ---------- */
.enso { stroke: var(--shu); stroke-width: 5; fill: none; stroke-linecap: round; }

/* ---------- ЛОГО-ЧАША ---------- */
@keyframes bowlIn { from { opacity: 0; transform: translateY(10px) scale(0.94); } to { opacity: 1; transform: translateY(0) scale(1); } }
.bowl-logo { display: block; pointer-events: none; user-select: none; }
.bowl-logo--home { height: 48px; width: auto; margin: 0 auto; animation: bowlIn 0.6s cubic-bezier(.22,.61,.36,1) both; }
.bowl-logo--payment { height: 52px; width: auto; margin: 0 auto 22px; animation: bowlIn 0.6s cubic-bezier(.22,.61,.36,1) both; }
.bowl-logo--corner {
  position: absolute; right: 20px; bottom: 20px; height: 40px; width: auto;
  opacity: 0.14; animation: none;
}
.bowl-logo--result { right: 26px; bottom: 26px; }

.brand { font-family: 'Montserrat', sans-serif; font-size: 13px; letter-spacing: 0.34em; color: var(--ink); text-transform: lowercase; text-align: center; }

/* ---------- HOME ---------- */
.home-scroll { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; align-items: center; gap: 6px; width: 100%; }
.home-mark { display: flex; flex-direction: column; align-items: center; gap: 10px; margin-top: 34px; margin-bottom: 34px; }
.home-greeting { font-family: 'Cormorant Garamond', serif; font-size: 22px; color: var(--ink); margin-top: 6px; }
.card-list { width: 100%; display: flex; flex-direction: column; gap: 14px; }
.service-card {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--paper-dim);
  padding: 22px 20px;
  display: flex; align-items: center; gap: 16px;
  cursor: pointer;
  transition: transform 0.15s cubic-bezier(.22,.61,.36,1), background-color 0.15s ease;
}
.service-card:active { transform: scale(0.97); background-color: var(--shu-soft); }
.service-card .sc-icon { flex-shrink: 0; }
.service-card .sc-title { font-family: 'Cormorant Garamond', serif; font-size: 21px; color: var(--ink); }
.service-card .sc-sub { font-size: 11.5px; color: var(--stone); margin-top: 3px; }
.service-card.soon { opacity: 0.4; cursor: default; }
.service-card.soon:active { transform: none; background-color: var(--paper-dim); }
.card-arrow { margin-left: auto; color: var(--shu); font-size: 16px; }
.home-orders-btn {
  position: absolute; top: 32px; right: 26px; font-size: 11px; letter-spacing: 0.04em;
  color: var(--stone); cursor: pointer; transition: opacity 0.15s ease;
}
.home-orders-btn:active { opacity: 0.5; }
.home-support-btn {
  position: absolute; top: 32px; left: 26px; font-size: 11px; letter-spacing: 0.04em;
  color: var(--stone); cursor: pointer; transition: opacity 0.15s ease;
}
.home-support-btn:active { opacity: 0.5; }

/* ---------- TEST CHOICE ---------- */
.choice-title { font-family: 'Cormorant Garamond', serif; font-size: 26px; color: var(--ink); margin-bottom: 6px; }
.choice-sub { font-size: 12.5px; color: var(--stone); margin-bottom: 30px; }
.theme-option {
  padding: 20px 4px; border-bottom: 1px solid var(--line);
  cursor: pointer; display: flex; flex-direction: column; gap: 4px;
  transition: background-color 0.15s ease, padding-left 0.15s ease;
}
.theme-option:first-of-type { border-top: 1px solid var(--line); }
.theme-option:active { background-color: var(--shu-soft); padding-left: 10px; }
.theme-option .t-name { font-family: 'Cormorant Garamond', serif; font-size: 19px; color: var(--ink); }
.theme-option .t-desc { font-size: 12px; color: var(--stone); }

/* ---------- PAYMENT ---------- */
.pay-scroll {
  flex: 1; min-height: 0; overflow-y: auto;
  display: flex; flex-direction: column; align-items: center; justify-content: flex-start;
  text-align: center; gap: 20px; width: 100%; padding-top: 8px; padding-bottom: 8px;
}
.pay-eyebrow { font-size: 11px; letter-spacing: 0.2em; text-transform: uppercase; color: var(--shu); }
.pay-title { font-family: 'Cormorant Garamond', serif; font-size: 24px; color: var(--ink); max-width: 260px; line-height: 1.3; }
.pay-price { font-family: 'Cormorant Garamond', serif; font-size: 48px; color: var(--ink); margin: 4px 0; }
.pay-price span { font-size: 16px; color: var(--stone); }
.pay-note { font-size: 11px; color: var(--stone); max-width: 230px; line-height: 1.6; }
.pay-status { font-size: 12px; color: var(--stone); min-height: 16px; transition: opacity 0.2s ease; }
.pay-email-block { width: 100%; max-width: 260px; display: flex; flex-direction: column; gap: 6px; text-align: left; }
.pay-email-label { font-size: 11px; color: var(--stone); letter-spacing: 0.03em; }
.pay-email-input {
  font-family: 'Montserrat', sans-serif; font-size: 14px; color: var(--ink);
  background: var(--paper-dim); border: 1px solid var(--line); padding: 12px 14px; border-radius: 2px;
  transition: border-color 0.15s ease;
}
.pay-email-input:focus { outline: none; border-color: var(--shu); }
.pay-email-input.invalid { border-color: var(--shu); }
.pay-email-error { font-size: 11px; color: var(--shu); min-height: 14px; }
.btn-primary {
  font-family: 'Montserrat', sans-serif; font-size: 13px; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--paper); background: var(--ink); border: none; padding: 16px 40px; border-radius: 2px; cursor: pointer; margin-top: 6px;
  transition: transform 0.15s cubic-bezier(.22,.61,.36,1), background-color 0.15s ease;
}
.btn-primary:active { background: var(--shu); transform: scale(0.96); }
.btn-secondary {
  font-family: 'Montserrat', sans-serif; font-size: 12px; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--ink); background: transparent; border: 1px solid var(--ink); padding: 13px 22px; cursor: pointer;
  align-self: flex-start; transition: transform 0.15s cubic-bezier(.22,.61,.36,1), background-color 0.15s ease, color 0.15s ease;
}
.btn-secondary:active { background-color: var(--ink); color: var(--paper); transform: scale(0.97); }
/* Отмена под кнопкой оплаты: намеренно тише основной, это запасной выход */
.btn-pay-cancel { align-self: center; margin-top: 10px; border-color: var(--line); color: var(--stone); }

/* Счёт уже выставлен — email и согласия ушли в PayKeeper и правке не подлежат,
   поэтому гасим их, чтобы не выглядели редактируемыми */
.awaiting-payment .pay-email-block,
.awaiting-payment .pay-consent-row { opacity: 0.45; pointer-events: none; }

/* ---------- QUESTION ---------- */
#screen-question { justify-content: flex-start; }
.q-progress-row { display: flex; align-items: center; gap: 14px; margin-bottom: 36px; }
.q-count { font-family: 'Cormorant Garamond', serif; font-size: 15px; color: var(--stone); }
.q-progress-ring { transition: stroke-dashoffset 0.5s cubic-bezier(.22,.61,.36,1); }
.q-content { display: flex; flex-direction: column; }
.q-content.enter-forward { animation: qEnterForward 0.34s cubic-bezier(.22,.61,.36,1); }
.q-content.enter-back { animation: qEnterBack 0.34s cubic-bezier(.22,.61,.36,1); }
@keyframes qEnterForward { from { opacity: 0; transform: translateX(18px); } to { opacity: 1; transform: translateX(0); } }
@keyframes qEnterBack { from { opacity: 0; transform: translateX(-18px); } to { opacity: 1; transform: translateX(0); } }
.q-text { font-family: 'Cormorant Garamond', serif; font-weight: 500; font-size: 25px; line-height: 1.4; color: var(--ink); margin-bottom: 40px; }
.options { display: flex; flex-direction: column; }
.option {
  padding: 18px 4px; border-bottom: 1px solid var(--line); font-size: 14px; color: var(--ink);
  display: flex; align-items: center; justify-content: space-between; cursor: pointer;
  transition: color 0.2s ease, background-color 0.15s ease;
}
.option:first-child { border-top: 1px solid var(--line); }
.option:active { background-color: var(--shu-soft); }
.option .dot {
  width: 7px; height: 7px; border-radius: 50%; border: 1.4px solid var(--stone); opacity: 0.5;
  transition: background-color 0.2s ease, border-color 0.2s ease, opacity 0.2s ease, transform 0.2s cubic-bezier(.22,.61,.36,1);
}
.option.selected { color: var(--shu); }
.option.selected .dot { background: var(--shu); border-color: var(--shu); opacity: 1; transform: scale(1.2); }
.q-back { margin-top: auto; font-size: 12px; color: var(--stone); letter-spacing: 0.08em; text-transform: uppercase; align-self: flex-start; cursor: pointer; transition: opacity 0.15s ease; }
.q-back:active { opacity: 0.5; }

/* ---------- RESULT ---------- */
#screen-result { padding: 0; }
.r-scroll {
  flex: 1; min-height: 0; overflow-y: auto;
  display: flex; flex-direction: column; align-items: flex-start;
  padding: 32px 26px 40px;
}
@keyframes riseIn { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: translateY(0); } }
.r-eyebrow { font-size: 11px; letter-spacing: 0.2em; text-transform: uppercase; color: var(--shu); margin-bottom: 10px; animation: riseIn 0.5s cubic-bezier(.22,.61,.36,1) both; }
.r-type { font-family: 'Cormorant Garamond', serif; font-weight: 600; font-size: 32px; color: var(--ink); line-height: 1.15; margin-bottom: 4px; animation: riseIn 0.5s cubic-bezier(.22,.61,.36,1) both 0.05s; }
.r-rule { width: 40px; height: 1px; background: var(--shu); margin-bottom: 20px; animation: riseIn 0.5s cubic-bezier(.22,.61,.36,1) both 0.1s; }
.r-desc { font-size: 14px; line-height: 1.7; color: var(--ink); margin-bottom: 30px; animation: riseIn 0.5s cubic-bezier(.22,.61,.36,1) both 0.15s; }
.r-save-hint {
  width: 100%; background: var(--paper-dim); border: 1px solid var(--line); padding: 18px 20px;
  display: flex; flex-direction: column; gap: 14px; margin-bottom: 32px;
  animation: riseIn 0.5s cubic-bezier(.22,.61,.36,1) both 0.18s;
}
.r-save-text { font-size: 12.5px; color: var(--stone); line-height: 1.6; }
.r-section { width: 100%; margin-bottom: 28px; animation: riseIn 0.5s cubic-bezier(.22,.61,.36,1) both; }
.r-label { font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--shu); margin-bottom: 12px; }
.r-list { list-style: none; width: 100%; }
.r-list li { font-size: 13.5px; color: var(--ink); line-height: 1.6; padding: 9px 0; border-bottom: 1px solid var(--line); }
.r-text { font-size: 13.5px; color: var(--ink); line-height: 1.7; }
.scale-row { margin-bottom: 16px; }
.scale-labels { display: flex; justify-content: space-between; font-size: 11.5px; color: var(--ink); margin-bottom: 6px; }
.scale-bar { height: 3px; background: var(--line); width: 100%; position: relative; }
.scale-fill { position: absolute; left: 0; top: 0; height: 100%; background: var(--shu); width: 0; transition: width 0.8s cubic-bezier(.22,.61,.36,1); }
.r-signoff { font-family: 'Cormorant Garamond', serif; font-size: 14px; color: var(--stone); margin-top: 6px; animation: riseIn 0.5s cubic-bezier(.22,.61,.36,1) both; }
.btn-result-home { align-self: center; margin-top: 32px; animation: riseIn 0.5s cubic-bezier(.22,.61,.36,1) both; }

/* ---------- CARD OF THE DAY ---------- */
#screen-card-intro { align-items: center; text-align: center; }
.card-intro-body { display: flex; flex-direction: column; align-items: center; justify-content: center; flex: 1; gap: 20px; max-width: 260px; margin: 0 auto; }
#card-intro-text { white-space: pre-line; }

.card-grid-body { display: flex; flex-direction: column; align-items: center; justify-content: center; flex: 1; width: 100%; }
.grid-title { font-family: 'Cormorant Garamond', serif; font-size: 20px; color: var(--ink); margin-bottom: 20px; text-align: center; }

.card-fan-wrap {
  --fan-card-w: clamp(56px, 21vw, 96px);
  position: relative; width: 100%; overflow: hidden;
  height: calc(var(--fan-card-w) * 1.75 + 40px);
}
.fan-card {
  position: absolute; left: 50%; bottom: 40px; width: var(--fan-card-w);
  transform-origin: bottom center; cursor: pointer;
  transition: filter 0.15s ease, z-index 0.15s ease;
}
.fan-card:nth-child(1) { transform: translateX(-50%) translateX(calc(var(--fan-card-w) * -1.1806)) rotate(-12deg) translateY(calc(var(--fan-card-w) * 0.2222)); z-index: 1; }
.fan-card:nth-child(2) { transform: translateX(-50%) translateX(calc(var(--fan-card-w) * -0.7222)) rotate(-7deg) translateY(calc(var(--fan-card-w) * 0.0556)); z-index: 2; }
.fan-card:nth-child(3) { transform: translateX(-50%) translateX(calc(var(--fan-card-w) * -0.25)) rotate(-2deg) translateY(calc(var(--fan-card-w) * -0.0556)); z-index: 3; }
.fan-card:nth-child(4) { transform: translateX(-50%) translateX(calc(var(--fan-card-w) * 0.25)) rotate(2deg) translateY(calc(var(--fan-card-w) * -0.0556)); z-index: 3; }
.fan-card:nth-child(5) { transform: translateX(-50%) translateX(calc(var(--fan-card-w) * 0.7222)) rotate(7deg) translateY(calc(var(--fan-card-w) * 0.0556)); z-index: 2; }
.fan-card:nth-child(6) { transform: translateX(-50%) translateX(calc(var(--fan-card-w) * 1.1806)) rotate(12deg) translateY(calc(var(--fan-card-w) * 0.2222)); z-index: 1; }
.fan-card:active { filter: brightness(0.85); }
.fan-card:hover, .fan-card:active { z-index: 10; }
.fan-card-img {
  width: 100%; display: block; border-radius: 4px;
  box-shadow: 0 10px 24px rgba(0,0,0,0.3);
  outline: 2px solid transparent; outline-offset: 3px;
  transition: outline-color 0.15s ease;
}
.fan-card:hover .fan-card-img, .fan-card:active .fan-card-img { outline-color: var(--shu); }
.fan-card-badge {
  position: absolute; left: 50%; bottom: 8%; transform: translateX(-50%);
  width: 24px; height: 24px; border-radius: 50%; background: var(--shu); color: var(--paper);
  font-family: 'Montserrat', sans-serif; font-weight: 600; font-size: 12px;
  display: flex; align-items: center; justify-content: center;
}

#screen-card-result { align-items: center; justify-content: center; text-align: center; }
.card-result-wrap { display: flex; flex-direction: column; align-items: center; gap: 22px; width: 100%; }
.card-result-eyebrow { font-size: 11px; letter-spacing: 0.2em; text-transform: uppercase; color: var(--shu); }
.card-result-img { width: 100%; max-width: 320px; display: block; opacity: 0; transition: opacity 0.4s ease; }
.card-result-img.loaded { opacity: 1; }

/* ---------- ИСТОРИЯ ЗАКАЗОВ ---------- */
.orders-list { width: 100%; display: flex; flex-direction: column; }
.orders-list--top { margin-top: 26px; }
.order-row { padding: 16px 4px; border-bottom: 1px solid var(--line); display: flex; flex-direction: column; gap: 4px; }
.order-row:first-child { border-top: 1px solid var(--line); }
.order-row-top { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.order-row-theme { font-family: 'Cormorant Garamond', serif; font-size: 17px; color: var(--ink); }
.order-row-amount { font-size: 14px; color: var(--ink); white-space: nowrap; }
.order-row-meta { display: flex; justify-content: space-between; font-size: 11px; color: var(--stone); }
.order-row-btn { margin-top: 12px; padding: 9px 16px; font-size: 10.5px; }
.orders-empty { font-size: 13px; color: var(--stone); padding: 20px 4px; line-height: 1.6; }

/* ---------- ЮРИДИЧЕСКИЕ ЭКРАНЫ ---------- */
.legal-scroll { flex: 1; min-height: 0; overflow-y: auto; padding-bottom: 20px; }
.legal-title { font-family: 'Cormorant Garamond', serif; font-size: 25px; color: var(--ink); margin-bottom: 4px; line-height: 1.25; }
.legal-subtitle { font-size: 11px; color: var(--stone); margin-bottom: 22px; }
.legal-note {
  font-size: 12px; line-height: 1.7; color: var(--stone); font-style: italic;
  background: var(--paper-dim); border: 1px solid var(--line); padding: 14px 16px; margin-bottom: 22px;
}
.legal-h { font-family: 'Cormorant Garamond', serif; font-weight: 500; font-size: 17.5px; color: var(--ink); margin: 22px 0 8px; }
.legal-h:first-of-type { margin-top: 0; }
.legal-p { font-size: 13px; line-height: 1.7; color: var(--ink); margin-bottom: 10px; }
.legal-list { list-style: none; margin-bottom: 10px; }
.legal-list li { font-size: 13px; line-height: 1.7; color: var(--ink); padding-left: 16px; position: relative; margin-bottom: 6px; }
.legal-list li::before { content: "—"; position: absolute; left: 0; color: var(--stone); }
.legal-lines { margin-bottom: 10px; }
.legal-lines div { font-size: 12.5px; line-height: 1.8; color: var(--stone); }
.legal-link { color: var(--shu); text-decoration: underline; text-underline-offset: 2px; cursor: pointer; }

/* ---------- ФУТЕР ---------- */
.legal-footer { font-size: 11px; color: var(--stone); text-align: center; letter-spacing: 0.01em; line-height: 1.6; }
.legal-footer-link { cursor: pointer; transition: opacity 0.15s ease; }
.legal-footer-link:active { opacity: 0.5; }
.legal-footer--pinned { margin-top: auto; padding-top: 24px; }
/* Логотипы платёжных систем — обязательны для боевого режима эквайринга */
.pay-logos { display: block; width: 100%; max-width: 190px; height: auto; margin: 12px auto 0; opacity: 0.9; }

/* ---------- СОГЛАСИЕ НА ОПЛАТЕ ---------- */
.pay-consent-row { display: flex; align-items: flex-start; gap: 10px; width: 100%; max-width: 260px; text-align: left; }
.pay-consent-checkbox { flex-shrink: 0; width: 16px; height: 16px; margin-top: 1px; accent-color: var(--shu); cursor: pointer; }
.pay-consent-text { font-size: 11.5px; line-height: 1.6; color: var(--stone); cursor: pointer; }
.pay-consent-row--optional { padding-top: 2px; border-top: 1px solid var(--line); margin-top: 2px; }
.btn-primary:disabled { opacity: 0.35; cursor: not-allowed; }
.btn-primary:disabled:active { background: var(--ink); transform: none; }

/* ---------- НАСТРОЙКИ ---------- */
.settings-row { display: flex; align-items: flex-start; gap: 16px; padding: 20px 4px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.settings-row-text { flex: 1; }
.settings-row-title { font-family: 'Cormorant Garamond', serif; font-size: 18px; color: var(--ink); margin-bottom: 4px; }
.settings-row-desc { font-size: 12px; line-height: 1.6; color: var(--stone); }
.settings-status { font-size: 12px; color: var(--stone); margin-top: 14px; min-height: 16px; }

.toggle { position: relative; flex-shrink: 0; display: block; width: 42px; height: 24px; cursor: pointer; }
.toggle input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.toggle-track {
  position: absolute; inset: 0; background: var(--line); border-radius: 12px;
  transition: background-color 0.2s ease;
}
.toggle-thumb {
  position: absolute; top: 2px; left: 2px; width: 20px; height: 20px; border-radius: 50%;
  background: var(--paper); box-shadow: 0 1px 3px rgba(0,0,0,0.25);
  transition: transform 0.2s cubic-bezier(.22,.61,.36,1);
}
.toggle input:checked ~ .toggle-track { background: var(--shu); }
.toggle input:checked ~ .toggle-track .toggle-thumb { transform: translateX(18px); }

/* ---------- ERROR ---------- */
#screen-error { align-items: center; justify-content: center; text-align: center; gap: 16px; }
.err-title { font-family: 'Cormorant Garamond', serif; font-size: 22px; color: var(--ink); }
.err-text { font-size: 13px; color: var(--stone); max-width: 260px; line-height: 1.6; }

/* ---------- TOAST ---------- */
.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%) translateY(20px);
  background: var(--ink); color: var(--paper); font-size: 12.5px; line-height: 1.5;
  padding: 12px 18px; max-width: 320px; text-align: center; opacity: 0; pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease; z-index: 1000;
}
.toast.visible { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- ДОСТУПНОСТЬ ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
