* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

html, body { height: 100%; }

body {
  background:
    radial-gradient(900px 520px at 50% -8%, rgba(108, 79, 161, .22), transparent 62%),
    radial-gradient(700px 460px at 100% 100%, rgba(217, 178, 106, .05), transparent 60%),
    var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.6;
  overscroll-behavior-y: none;
  -webkit-font-smoothing: antialiased;
}

#app {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: calc(18px + env(safe-area-inset-top)) var(--pad) calc(96px + env(safe-area-inset-bottom));
  min-height: 100%;
}

/* ---------- типографика ---------- */
.kicker {
  font-size: 9px; letter-spacing: .32em; text-transform: uppercase;
  color: var(--gold); opacity: .8;
}
h1 { font-family: var(--serif); font-size: 34px; font-weight: 400; line-height: 1.12; letter-spacing: .01em; margin: 10px 0 6px; }
h2 { font-family: var(--serif); font-size: 23px; font-weight: 400; line-height: 1.22; margin: 4px 0 8px; }
h3 { font-family: var(--serif); font-size: 17px; font-weight: 400; margin: 0; }
.lede { color: var(--muted); font-size: 13px; line-height: 1.62; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.center { text-align: center; }

.rule { height: 1px; background: linear-gradient(90deg, var(--line), transparent); margin: 18px 0; }

/* ---------- верхняя панель ---------- */
.topbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.brand { display: flex; align-items: center; gap: 9px; }
.brand-mark {
  width: 26px; height: 34px; flex: none;
  border: 1px solid var(--gold); border-bottom: none;
  border-radius: 13px 13px 0 0; opacity: .85;
}
.brand-name { font-family: var(--serif); font-size: 15px; letter-spacing: .22em; text-transform: uppercase; }
.badge {
  font-size: 10px; letter-spacing: .1em; padding: 5px 9px; border-radius: 2px;
  border: 1px solid var(--line); color: var(--muted);
}
.badge.gold { border-color: rgba(217,178,106,.5); color: var(--gold); background: rgba(217,178,106,.08); }

/* ---------- карточки-списки ---------- */
.list { display: flex; flex-direction: column; gap: 9px; margin-top: 18px; }

.opt {
  display: flex; align-items: center; gap: 13px; width: 100%; text-align: left;
  padding: 13px 14px; border: 1px solid var(--line-soft); border-radius: var(--r);
  background: linear-gradient(180deg, rgba(26,31,53,.9), rgba(18,22,39,.9));
  color: var(--text); font-family: inherit; font-size: inherit; cursor: pointer;
  transition: border-color .2s var(--ease), background .2s var(--ease), transform .12s var(--ease);
}
.opt:active { transform: scale(.988); }
.opt.on, .opt:hover { border-color: rgba(217,178,106,.52); background: linear-gradient(180deg, #1D2340, #151A2C); }

.opt .ic { width: 28px; height: 36px; flex: none; opacity: .8; }
.opt .t { display: block; font-family: var(--serif); font-size: 17px; line-height: 1.2; }
.opt .d { display: block; font-size: 11.5px; color: var(--muted); margin-top: 2px; letter-spacing: .02em; }
.opt .right { margin-left: auto; flex: none; display: flex; align-items: center; gap: 8px; }
.opt .chev { color: var(--muted-2); font-size: 16px; }

/* мини-превью расклада */
.mini { display: flex; gap: 3px; }
.mini i {
  display: block; width: 13px; height: 22px; border: 1px solid rgba(217,178,106,.55);
  border-radius: 1px; background: linear-gradient(160deg, #1b2138, #0d1120);
}

/* ---------- кнопки ---------- */
.btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; padding: 15px; border-radius: var(--r); cursor: pointer;
  border: 1px solid rgba(217,178,106,.55);
  background: linear-gradient(180deg, rgba(217,178,106,.17), rgba(217,178,106,.05));
  color: var(--gold); font-family: var(--sans); font-size: 11.5px;
  letter-spacing: .22em; text-transform: uppercase;
  transition: transform .12s var(--ease), filter .2s var(--ease);
}
.btn:active { transform: scale(.985); filter: brightness(1.1); }
.btn.ghost { border-color: rgba(237,230,214,.16); background: none; color: rgba(237,230,214,.72); }
.btn.gold-solid { background: linear-gradient(180deg, #E1BC77, #C79E55); color: #12151f; border-color: #E1BC77; font-weight: 600; }
.btn[disabled] { opacity: .45; pointer-events: none; }
.btn-row { display: flex; gap: 9px; margin-top: 20px; }
.btn-row .btn { flex: 1; }

/* ---------- карта ---------- */
.card {
  position: relative; width: 100%; aspect-ratio: 4 / 7; border-radius: 2px; overflow: hidden;
  background: var(--surface-2); border: 1px solid var(--line-soft);
  box-shadow: 0 22px 50px -26px #000, 0 0 0 1px rgba(217,178,106,.06);
}
.card img { width: 100%; height: 100%; object-fit: cover; display: block; }
.card.flip { animation: flipIn .62s var(--ease) both; transform-style: preserve-3d; }
.card.rev img { transform: rotate(180deg); }

.cards-row { display: grid; gap: 9px; margin: 16px 0 4px; }
.cards-row.c1 { grid-template-columns: minmax(0, 190px); justify-content: center; }
.cards-row.c3 { grid-template-columns: repeat(3, 1fr); }
.cards-row.c5 { grid-template-columns: repeat(3, 1fr); }

/* ---------- чтение ---------- */
.block { margin-top: 22px; }
.block-h {
  display: flex; align-items: baseline; gap: 9px; margin-bottom: 7px;
  padding-bottom: 7px; border-bottom: 1px solid var(--line-soft);
}
.block-h .i { font-family: var(--serif); font-size: 12px; color: var(--gold); opacity: .8; }
.block-h .p { font-size: 10px; letter-spacing: .22em; text-transform: uppercase; color: var(--gold); }
.block-h .n { margin-left: auto; font-family: var(--serif); font-size: 14px; color: var(--muted); }
.reading { font-size: 14.5px; line-height: 1.74; color: rgba(237,230,214,.9); white-space: pre-line; }
.reading + .reading { margin-top: 14px; }

.pos-label { font-size: 9.5px; letter-spacing: .24em; text-transform: uppercase; color: var(--muted); text-align: center; margin-top: 8px; }
.rev-mark { color: var(--gold); opacity: .7; font-size: 10px; letter-spacing: .18em; }

.note {
  margin-top: 18px; padding: 12px 14px; border-left: 2px solid rgba(217,178,106,.4);
  background: rgba(217,178,106,.05); font-size: 12.5px; line-height: 1.62; color: var(--muted);
}

/* ---------- таббар ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: flex; justify-content: center;
  padding: 8px var(--pad) calc(8px + env(safe-area-inset-bottom));
  background: linear-gradient(180deg, rgba(11,14,26,0), rgba(11,14,26,.94) 42%);
  backdrop-filter: blur(10px);
}
.tabbar-inner { display: flex; width: 100%; max-width: var(--maxw); border-top: 1px solid var(--line-soft); }
.tab {
  flex: 1; padding: 12px 0 6px; background: none; border: none; cursor: pointer;
  color: var(--muted-2); font-family: var(--sans); font-size: 9.5px;
  letter-spacing: .2em; text-transform: uppercase; display: grid; gap: 5px; justify-items: center;
}
.tab svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 1.2; }
.tab.on { color: var(--gold); }

/* ---------- скелетон / загрузка ---------- */
.skel { height: 14px; border-radius: 2px; background: linear-gradient(90deg, rgba(237,230,214,.06), rgba(237,230,214,.11), rgba(237,230,214,.06)); background-size: 200% 100%; animation: shimmer 1.5s infinite; }
.skel.w80 { width: 80%; } .skel.w60 { width: 60%; } .skel.w95 { width: 95%; }
.skel + .skel { margin-top: 9px; }

.shuffle { display: flex; justify-content: center; align-items: center; height: 220px; position: relative; }
.shuffle i {
  position: absolute; width: 92px; height: 161px; border: 1px solid rgba(217,178,106,.5);
  border-radius: 2px; background: linear-gradient(160deg, #1b2138, #0b0e1a);
  animation: shuffle 2.4s var(--ease) infinite;
}
.shuffle i:nth-child(2) { animation-delay: .18s; }
.shuffle i:nth-child(3) { animation-delay: .36s; }
.shuffle i:nth-child(4) { animation-delay: .54s; }
.shuffle i:nth-child(5) { animation-delay: .72s; }

/* ---------- профиль ---------- */
.field { margin-top: 16px; }
.field label { display: block; font-size: 9.5px; letter-spacing: .22em; text-transform: uppercase; color: var(--gold); opacity: .8; margin-bottom: 7px; }
.field input, .field select {
  width: 100%; padding: 12px 13px; border-radius: var(--r);
  border: 1px solid var(--line-soft); background: rgba(26,31,53,.7);
  color: var(--text); font-family: var(--sans); font-size: 14px; outline: none;
  appearance: none;
}
.field input:focus, .field select:focus { border-color: rgba(217,178,106,.55); }
.field input::placeholder { color: var(--muted-2); }

.copyrow {
  display: flex; align-items: center; gap: 10px; padding: 12px 13px; margin-top: 6px;
  border: 1px dashed var(--line); border-radius: var(--r); cursor: pointer;
  font-variant-numeric: tabular-nums; letter-spacing: .06em;
}
.copyrow:active { background: rgba(217,178,106,.06); }
.copyrow .v { font-family: var(--serif); font-size: 16px; }
.copyrow .hint { margin-left: auto; font-size: 9.5px; letter-spacing: .18em; text-transform: uppercase; color: var(--muted-2); }

.langs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; margin-top: 6px; }
.lang {
  padding: 10px 0; text-align: center; border: 1px solid var(--line-soft); border-radius: var(--r);
  background: rgba(26,31,53,.6); color: var(--muted); cursor: pointer;
  font-family: var(--sans); font-size: 11px; letter-spacing: .14em; text-transform: uppercase;
}
.lang.on { border-color: rgba(217,178,106,.6); color: var(--gold); background: rgba(217,178,106,.1); }

/* ---------- история ---------- */
.hist-item {
  display: flex; gap: 12px; align-items: center; padding: 11px 12px; margin-top: 8px;
  border: 1px solid var(--line-soft); border-radius: var(--r); cursor: pointer;
  background: linear-gradient(180deg, rgba(26,31,53,.7), rgba(18,22,39,.7));
}
.hist-item img { width: 34px; height: 56px; object-fit: cover; border-radius: 1px; border: 1px solid var(--line-soft); }
.hist-item .hm { flex: 1; min-width: 0; }
.hist-item .hh { font-family: var(--serif); font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hist-item .hd { font-size: 11px; color: var(--muted); margin-top: 2px; }

/* ---------- утилиты ---------- */
.stack { display: flex; flex-direction: column; gap: 9px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.spacer { height: 8px; }
.hidden { display: none !important; }
.err { color: #E08B8B; font-size: 12.5px; margin-top: 10px; }
.empty { text-align: center; color: var(--muted); padding: 48px 0; font-size: 13px; }
.toast {
  position: fixed; left: 50%; bottom: 96px; transform: translateX(-50%) translateY(10px);
  background: rgba(26,31,53,.98); border: 1px solid var(--line); color: var(--text);
  padding: 10px 16px; border-radius: 2px; font-size: 12px; opacity: 0;
  transition: opacity .22s var(--ease), transform .22s var(--ease); z-index: 60; pointer-events: none;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@keyframes fadeUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes flipIn { from { opacity: 0; transform: rotateY(-72deg) scale(.96); } to { opacity: 1; transform: none; } }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
@keyframes shuffle {
  0%, 100% { transform: translateX(-76px) rotate(-9deg); }
  25% { transform: translateX(-32px) rotate(-4deg); }
  50% { transform: translateX(6px) rotate(2deg) translateY(-6px); }
  75% { transform: translateX(44px) rotate(7deg); }
}

.fade { animation: fadeUp .34s var(--ease) both; animation-delay: calc(var(--i, 0) * 60ms); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
