@import url("https://fonts.googleapis.com/css2?family=Cormorant+Garamond:wght@500;600;700&family=Manrope:wght@400;500;600;700;800&display=swap");

:root {
  color-scheme: dark;
  --bg: #0c0b10;
  --bg-deep: #07070b;
  --panel: rgba(22, 20, 27, 0.88);
  --panel-strong: rgba(28, 25, 34, 0.94);
  --panel-soft: rgba(255, 255, 255, 0.045);
  --field: rgba(7, 7, 11, 0.58);
  --line: rgba(236, 226, 203, 0.14);
  --line-strong: rgba(236, 226, 203, 0.26);
  --text: #f5efe4;
  --text-soft: #d8cdbb;
  --muted: #9b9286;
  --gold: #d8b65f;
  --gold-strong: #f2d583;
  --teal: #64c6bc;
  --rose: #d87c7c;
  --wine: #5c2532;
  --ink: #121017;
  --error: #ff8f8f;
  --ring: rgba(216, 182, 95, 0.28);
  --radius: 8px;
  --shadow: 0 22px 70px rgba(0, 0, 0, 0.38);
  --shadow-soft: 0 16px 38px rgba(0, 0, 0, 0.26);
  font-size: 16px;
  font-family: "Manrope", "Segoe UI", Helvetica, Arial, sans-serif;
  -webkit-tap-highlight-color: rgba(216, 182, 95, 0.22);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg-deep);
  scroll-behavior: smooth;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

body {
  min-height: 100vh;
  margin: 0;
  padding: 0 clamp(0.9rem, 2.8vw, 2.5rem) 3rem;
  color: var(--text);
  background:
    linear-gradient(rgba(236, 226, 203, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(236, 226, 203, 0.028) 1px, transparent 1px),
    radial-gradient(circle at center, rgba(216, 182, 95, 0.10) 0 1px, transparent 1.8px),
    linear-gradient(135deg, #09090d 0%, #141018 44%, #101820 100%);
  background-size: 72px 72px, 72px 72px, 34px 34px, auto;
  font-family: inherit;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -2;
  pointer-events: none;
  background:
    linear-gradient(115deg, transparent 0 18%, rgba(216, 182, 95, 0.08) 18.2%, transparent 18.5% 57%, rgba(100, 198, 188, 0.07) 57.2%, transparent 57.6%),
    conic-gradient(from 215deg at 78% 20%, transparent 0 18deg, rgba(216, 182, 95, 0.10) 19deg 21deg, transparent 22deg 360deg);
  opacity: 0.9;
}

body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(7, 7, 11, 0.20), rgba(7, 7, 11, 0.78));
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  -webkit-user-select: none;
  user-select: none;
  touch-action: manipulation;
}

button:not(:disabled) {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
}

::selection {
  background: rgba(216, 182, 95, 0.34);
  color: #fff9ec;
}

.hidden,
.layout > section[hidden] {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.background-gradient {
  position: fixed;
  inset: 0;
  z-index: -3;
  pointer-events: none;
  background:
    repeating-linear-gradient(30deg, transparent 0 42px, rgba(216, 182, 95, 0.035) 43px, transparent 44px),
    repeating-linear-gradient(150deg, transparent 0 58px, rgba(100, 198, 188, 0.028) 59px, transparent 60px);
  mask-image: linear-gradient(180deg, #000 0%, transparent 88%);
}

.top-bar {
  position: sticky;
  top: 0;
  z-index: 20;
  width: min(1240px, 100%);
  margin: 0 auto;
  padding: 0.9rem 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  background: rgba(12, 11, 16, 0.76);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(18px);
}

.top-bar__brand {
  display: flex;
  align-items: center;
  min-width: 0;
}

.top-bar__badge,
.brand-badge {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  min-height: 2rem;
  border: 1px solid rgba(216, 182, 95, 0.42);
  border-radius: 999px;
  padding: 0.35rem 0.75rem;
  color: var(--gold-strong);
  background: rgba(216, 182, 95, 0.08);
  font-size: 0.73rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  white-space: nowrap;
}

.top-bar__controls {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.65rem;
  min-width: 0;
}

.language-switcher,
.mode-switcher,
.consult-link {
  display: inline-flex;
  align-items: center;
  min-height: 2.65rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(10, 9, 14, 0.70);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.language-switcher {
  gap: 0.45rem;
  padding: 0.25rem 0.35rem 0.25rem 0.75rem;
}

.language-switcher label {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.language-switcher select,
select {
  appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, currentColor 50%),
    linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: calc(100% - 18px) calc(50% - 3px), calc(100% - 12px) calc(50% - 3px);
  background-repeat: no-repeat;
  background-size: 6px 6px, 6px 6px;
}

.language-switcher select {
  width: auto;
  min-width: 7.5rem;
  min-height: 2rem;
  padding: 0.35rem 1.8rem 0.35rem 0.7rem;
  border: 1px solid transparent;
  border-radius: 999px;
  color: var(--text);
  background-color: transparent;
  font-size: 0.88rem;
}

.mode-switcher {
  gap: 0.18rem;
  padding: 0.24rem;
}

.mode-tab {
  position: relative;
  border: 0;
  border-radius: 999px;
  padding: 0.58rem 1.2rem;
  color: var(--text-soft);
  background: transparent;
  font-weight: 800;
  font-size: 0.9rem;
  letter-spacing: 0.02em;
  transition: color 180ms ease, background 180ms ease, transform 180ms ease;
}

.mode-tab:hover {
  color: var(--text);
}

.mode-tab.active {
  color: #151109;
  background: linear-gradient(135deg, var(--gold-strong), var(--gold));
  box-shadow: 0 8px 24px rgba(216, 182, 95, 0.22);
}

.mode-tab:focus-visible,
.language-switcher select:focus-visible,
.consult-link:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--ring);
}

.consult-link {
  justify-content: center;
  padding: 0.45rem 0.95rem;
  color: var(--gold-strong);
  font-size: 0.86rem;
  font-weight: 900;
  text-decoration: none;
  white-space: nowrap;
  transition: color 180ms ease, border-color 180ms ease, background 180ms ease, transform 180ms ease;
}

.consult-link:hover {
  color: #151109;
  border-color: rgba(242, 213, 131, 0.74);
  background: linear-gradient(135deg, rgba(242, 213, 131, 0.95), rgba(216, 182, 95, 0.9));
  transform: translateY(-1px);
}

.layout {
  width: min(1240px, 100%);
  margin: clamp(1rem, 3vw, 2.5rem) auto 0;
  display: grid;
  grid-template-columns: minmax(0, 1.02fr) minmax(360px, 0.88fr);
  gap: clamp(1rem, 2.6vw, 2rem);
  align-items: start;
}

.layout.mode-tarot {
  grid-template-columns: 1fr;
}

.hero,
.conversation {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.035), transparent 36%),
    linear-gradient(145deg, var(--panel-strong), rgba(14, 13, 19, 0.92));
  box-shadow: var(--shadow);
}

.hero {
  padding: clamp(1.35rem, 3.5vw, 2.8rem);
}

.conversation {
  padding: clamp(1.15rem, 2.7vw, 2rem);
}

.hero::before,
.conversation::before {
  content: "";
  position: absolute;
  pointer-events: none;
  opacity: 0.52;
}

.hero::before {
  width: 22rem;
  height: 22rem;
  right: -7rem;
  top: -8rem;
  border: 1px solid rgba(216, 182, 95, 0.18);
  border-radius: 50%;
  background:
    conic-gradient(from 0deg, rgba(216, 182, 95, 0.18), transparent 22%, rgba(100, 198, 188, 0.15), transparent 68%, rgba(216, 182, 95, 0.18)),
    repeating-conic-gradient(from 0deg, transparent 0 13deg, rgba(236, 226, 203, 0.12) 13.5deg 14deg);
  mask-image: radial-gradient(circle, transparent 0 35%, #000 36% 37%, transparent 38% 50%, #000 51% 52%, transparent 53% 100%);
}

.conversation::before {
  inset: 0;
  background:
    linear-gradient(90deg, transparent, rgba(100, 198, 188, 0.075), transparent),
    repeating-linear-gradient(0deg, transparent 0 42px, rgba(236, 226, 203, 0.035) 43px);
  opacity: 0.34;
}

.brand,
.conversation-header {
  position: relative;
  z-index: 1;
}

.brand {
  display: grid;
  gap: 1rem;
  max-width: 58rem;
  margin-bottom: clamp(1.35rem, 3vw, 2.35rem);
}

.brand h1 {
  max-width: 12ch;
  margin: 0;
  color: var(--text);
  font-family: "Cormorant Garamond", Georgia, serif;
  font-size: clamp(2.45rem, 7vw, 5.6rem);
  font-weight: 700;
  line-height: 0.88;
  letter-spacing: 0;
}

.brand p {
  max-width: 58ch;
  margin: 0;
  color: var(--text-soft);
  font-size: clamp(1rem, 1.5vw, 1.08rem);
  line-height: 1.75;
}

.astro-form {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 1.1rem;
}

fieldset {
  margin: 0;
  padding: 1.2rem 0 0;
  border: 0;
  border-top: 1px solid var(--line);
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

legend {
  padding: 0 0.75rem 0 0;
  color: var(--gold-strong);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.field {
  min-width: 0;
  display: grid;
  gap: 0.45rem;
}

.field--full,
.field-grid {
  grid-column: 1 / -1;
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

label {
  color: var(--text-soft);
  font-size: 0.84rem;
  font-weight: 800;
  letter-spacing: 0.04em;
}

.field:focus-within label {
  color: var(--gold-strong);
}

input,
textarea,
select {
  width: 100%;
  min-height: 3.15rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.86rem 0.95rem;
  color: var(--text);
  background-color: var(--field);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.035);
  transition: border-color 160ms ease, box-shadow 160ms ease, background-color 160ms ease, transform 160ms ease;
}

select {
  padding-right: 2.5rem;
  color: var(--text);
  cursor: pointer;
}

input::placeholder,
textarea::placeholder {
  color: rgba(216, 205, 187, 0.52);
}

input:hover,
textarea:hover,
select:hover {
  border-color: rgba(236, 226, 203, 0.28);
  background-color: rgba(10, 10, 15, 0.70);
}

input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: rgba(216, 182, 95, 0.78);
  background-color: rgba(8, 8, 13, 0.82);
  box-shadow: 0 0 0 3px var(--ring), inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

input:required:user-invalid,
select:required:user-invalid,
textarea:required:user-invalid {
  border-color: rgba(255, 143, 143, 0.72);
  box-shadow: 0 0 0 3px rgba(255, 143, 143, 0.12);
}

textarea {
  min-height: 7rem;
  resize: vertical;
  line-height: 1.55;
}

.field-hint,
.form-hint,
.follow-up-hint {
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.55;
}

.field-hint.location-status {
  min-height: 1.2rem;
  font-style: normal;
}

.field-hint.location-status.error {
  color: var(--error);
}

.input-with-action {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.55rem;
  align-items: stretch;
}

.location-btn,
.primary-btn,
.secondary-btn {
  border-radius: var(--radius);
  font-weight: 900;
  letter-spacing: 0.01em;
  transition: transform 160ms ease, border-color 160ms ease, box-shadow 160ms ease, background 160ms ease, color 160ms ease, opacity 160ms ease;
}

.primary-btn {
  min-height: 3.45rem;
  border: 1px solid rgba(242, 213, 131, 0.72);
  padding: 0.95rem 1.25rem;
  color: #171107;
  background: linear-gradient(135deg, var(--gold-strong), var(--gold) 56%, #b98838);
  box-shadow: 0 15px 34px rgba(216, 182, 95, 0.20), inset 0 1px 0 rgba(255, 255, 255, 0.42);
}

.primary-btn:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 18px 42px rgba(216, 182, 95, 0.27), inset 0 1px 0 rgba(255, 255, 255, 0.45);
}

.primary-btn:active:not(:disabled),
.secondary-btn:active:not(:disabled),
.location-btn:active:not(:disabled) {
  transform: translateY(0);
}

.primary-btn:disabled,
.secondary-btn:disabled,
.location-btn:disabled {
  opacity: 0.55;
}

.primary-btn:disabled {
  color: rgba(245, 239, 228, 0.62);
  border-color: rgba(236, 226, 203, 0.16);
  background: rgba(216, 182, 95, 0.28);
  box-shadow: none;
}

.primary-btn:focus-visible,
.secondary-btn:focus-visible,
.location-btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--ring);
}

.secondary-btn,
.location-btn {
  border: 1px solid var(--line-strong);
  color: var(--text);
  background: rgba(255, 255, 255, 0.055);
}

.secondary-btn {
  min-width: 7.5rem;
  min-height: 3.15rem;
  padding: 0.82rem 1rem;
}

.location-btn {
  min-width: 5.1rem;
  min-height: 3.15rem;
  padding: 0 0.85rem;
  color: var(--gold-strong);
}

.secondary-btn:hover:not(:disabled),
.location-btn:hover:not(:disabled) {
  color: var(--gold-strong);
  border-color: rgba(216, 182, 95, 0.58);
  background: rgba(216, 182, 95, 0.08);
}

.conversation-header {
  display: grid;
  gap: 0.45rem;
  margin-bottom: 1.15rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--line);
}

.conversation-header h2,
.tarot-conversation h3 {
  margin: 0;
  color: var(--text);
  font-family: "Cormorant Garamond", Georgia, serif;
  font-weight: 700;
  letter-spacing: 0;
}

.conversation-header h2 {
  font-size: clamp(1.9rem, 3.3vw, 2.65rem);
  line-height: 1;
}

.conversation-subtitle {
  max-width: 54ch;
  margin: 0;
  color: var(--text-soft);
  font-size: 0.92rem;
  line-height: 1.65;
}

.messages,
.tarot-messages {
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

.messages {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  max-height: 750px;
  overflow-y: auto;
  padding-right: 0.35rem;
  scrollbar-color: rgba(216, 182, 95, 0.38) transparent;
}

.messages::-webkit-scrollbar,
.tarot-messages::-webkit-scrollbar {
  width: 8px;
}

.messages::-webkit-scrollbar-thumb,
.tarot-messages::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: rgba(216, 182, 95, 0.34);
}

.message {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 0.75rem 0.9rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem;
  background: rgba(255, 255, 255, 0.045);
  box-shadow: var(--shadow-soft);
  scroll-margin-top: 6rem;
}

.message.user {
  border-color: rgba(216, 182, 95, 0.34);
  background: rgba(216, 182, 95, 0.075);
}

.message.assistant {
  border-color: rgba(100, 198, 188, 0.30);
  background: rgba(100, 198, 188, 0.07);
}

.message.error {
  border-color: rgba(255, 143, 143, 0.58);
  background: rgba(92, 37, 50, 0.32);
}

.message .avatar {
  width: 2.45rem;
  height: 2.45rem;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text-soft);
  background: rgba(255, 255, 255, 0.055);
  font-size: 0.82rem;
  font-weight: 900;
}

.message.user .avatar {
  color: #171107;
  border-color: rgba(216, 182, 95, 0.62);
  background: var(--gold);
}

.message.assistant .avatar {
  color: #061615;
  border-color: rgba(100, 198, 188, 0.56);
  background: var(--teal);
}

.message .content,
.message-body {
  min-width: 0;
  display: grid;
  gap: 0.48rem;
}

.message .content h3 {
  margin: 0;
  color: var(--text);
  font-size: 0.92rem;
  font-weight: 900;
}

.message .content p {
  margin: 0;
  color: var(--text-soft);
  line-height: 1.72;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.timestamp {
  color: var(--muted);
  font-size: 0.72rem;
}

.loading {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  color: var(--text-soft);
}

.loading-dot {
  width: 0.48rem;
  height: 0.48rem;
  border-radius: 999px;
  background: currentColor;
  animation: pulse 1s ease-in-out infinite;
}

.loading-dot:nth-child(2) {
  animation-delay: 0.15s;
}

.loading-dot:nth-child(3) {
  animation-delay: 0.3s;
}

.follow-up-form {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 0.65rem;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
}

.follow-up-inputs {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.65rem;
  align-items: stretch;
}

.follow-up-inputs textarea {
  min-height: 5.5rem;
}

.tarot-user-info {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
  margin-bottom: clamp(1rem, 2.4vw, 1.6rem);
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.035);
}

.tarot-layout {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: minmax(360px, 0.95fr) minmax(320px, 1.05fr);
  gap: clamp(1rem, 2.4vw, 1.8rem);
  align-items: start;
}

.tarot-deck,
.tarot-conversation {
  min-width: 0;
}

.tarot-deck {
  display: grid;
  justify-items: center;
  gap: 1.15rem;
}

.tarot-controls {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
}

.tarot-selection-area {
  position: relative;
  width: min(390px, 100%);
  height: 312px;
  display: grid;
  place-items: center;
  perspective: 1300px;
  transition: width 220ms ease, height 220ms ease;
}

.tarot-selection-area.stage-ready {
  width: min(610px, 100%);
  height: 430px;
}

.tarot-selection-area.stage-piles {
  width: min(540px, 100%);
  min-height: 280px;
  height: auto;
  perspective: none;
}

.tarot-stack,
.tarot-piles,
.tarot-fan {
  position: relative;
}

.tarot-stack {
  width: 210px;
  height: 285px;
  display: grid;
  place-items: center;
  transform: rotate(-2deg);
}

.tarot-stack-cards {
  position: relative;
  width: 146px;
  height: 224px;
}

.tarot-stack-card,
.tarot-fan-card {
  overflow: hidden;
  border-radius: var(--radius);
  border: 1px solid rgba(216, 182, 95, 0.28);
  background:
    linear-gradient(135deg, rgba(216, 182, 95, 0.22), transparent 34%),
    repeating-linear-gradient(45deg, rgba(245, 239, 228, 0.10) 0 1px, transparent 1px 12px),
    linear-gradient(145deg, #321827, #10282a 58%, #2b2110) !important;
  box-shadow: 0 20px 42px rgba(0, 0, 0, 0.34);
}

.tarot-stack-card {
  position: absolute;
  inset: 0;
  transform: translateY(var(--offset, 0)) rotate(var(--rotation, 0));
  transition: transform 180ms ease;
}

.tarot-stack-card::after,
.tarot-fan-card::after {
  content: "";
  position: absolute;
  inset: 0.75rem;
  border: 1px solid rgba(245, 239, 228, 0.18);
  border-radius: 6px;
  background:
    linear-gradient(90deg, transparent 49%, rgba(216, 182, 95, 0.22) 50%, transparent 51%),
    linear-gradient(0deg, transparent 49%, rgba(216, 182, 95, 0.22) 50%, transparent 51%);
  pointer-events: none;
}

.tarot-stack.is-shuffling .tarot-stack-card {
  animation: tarotShuffleSpin 1.2s ease-in-out forwards;
}

.tarot-stack.is-shuffling .tarot-stack-card:nth-child(odd) {
  animation-delay: 40ms;
}

.tarot-stack.is-shuffling .tarot-stack-card:nth-child(even) {
  animation-delay: 120ms;
}

.tarot-piles {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(3, minmax(110px, 1fr));
  gap: 0.9rem;
}

.tarot-pile {
  position: relative;
  min-height: 226px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem 0.75rem;
  display: grid;
  align-content: end;
  justify-items: center;
  gap: 0.35rem;
  color: var(--text-soft);
  background: rgba(255, 255, 255, 0.04);
  box-shadow: var(--shadow-soft);
  transition: transform 180ms ease, border-color 180ms ease, box-shadow 180ms ease;
}

.tarot-pile::before {
  content: "";
  position: absolute;
  inset: 0.65rem 0.65rem 3.25rem;
  border: 1px solid rgba(216, 182, 95, 0.25);
  border-radius: 6px;
  background:
    linear-gradient(135deg, rgba(216, 182, 95, 0.20), transparent 38%),
    repeating-linear-gradient(45deg, rgba(245, 239, 228, 0.08) 0 1px, transparent 1px 11px),
    linear-gradient(150deg, rgba(92, 37, 50, 0.72), rgba(14, 42, 42, 0.82));
}

.tarot-pile:hover:not(:disabled) {
  transform: translateY(-3px);
  border-color: rgba(216, 182, 95, 0.58);
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.34);
}

.tarot-pile:disabled {
  opacity: 0.72;
}

.tarot-pile[data-order]::after {
  content: attr(data-order);
  position: absolute;
  top: 0.65rem;
  right: 0.65rem;
  width: 2rem;
  height: 2rem;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #171107;
  background: var(--gold-strong);
  font-size: 0.9rem;
  font-weight: 900;
}

.tarot-pile-label {
  color: var(--text);
  font-size: 0.76rem;
  font-weight: 900;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.tarot-pile-count {
  color: var(--muted);
  font-size: 0.78rem;
}

.tarot-fan {
  width: 100%;
  height: 100%;
}

.tarot-fan-card {
  position: absolute;
  top: 20px;
  left: 50%;
  width: 138px;
  height: 220px;
  outline: none;
  transform-origin: bottom center;
  transform: translateX(-50%) rotate(calc(var(--angle, 0) * 1deg)) translateY(calc(var(--offset, 0) * 1px));
  transition: transform 220ms ease, box-shadow 220ms ease, opacity 180ms ease, border-color 180ms ease;
}

.tarot-fan.expanded .tarot-fan-card {
  top: 0;
  width: 158px;
  height: 246px;
}

.tarot-fan-card:hover {
  transform: translateX(-50%) rotate(calc(var(--angle, 0) * 1deg)) translateY(calc(var(--offset, 0) * 1px - 14px));
  border-color: rgba(242, 213, 131, 0.68);
  box-shadow: 0 28px 54px rgba(0, 0, 0, 0.44);
}

.tarot-fan-card:focus-visible {
  box-shadow: 0 0 0 3px var(--ring), 0 20px 42px rgba(0, 0, 0, 0.34);
}

.tarot-fan-card.selected {
  opacity: 0;
  pointer-events: none;
  transform: translateX(-50%) rotate(calc(var(--angle, 0) * 1deg)) translate(60px, -180px) scale(0.9);
}

.tarot-fan.expanded .tarot-fan-card.selected {
  transform: translateX(-50%) rotate(calc(var(--angle, 0) * 1deg)) translate(80px, -220px) scale(0.92);
}

.tarot-hint {
  max-width: 34ch;
  margin: 0;
  color: var(--text-soft);
  font-size: 0.88rem;
  line-height: 1.55;
  text-align: center;
}

.tarot-hint.subtle {
  display: none;
}

.tarot-spread {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.85rem;
  padding: 0.85rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.035);
}

.tarot-spread-slot {
  min-width: 0;
  display: flex;
  justify-content: center;
}

.tarot-spread-card {
  width: 100%;
  max-width: 205px;
  min-height: 100%;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(10, 9, 14, 0.58);
  box-shadow: var(--shadow-soft);
  transition: border-color 180ms ease, transform 180ms ease;
}

.tarot-spread-card.active {
  border-color: rgba(216, 182, 95, 0.62);
  transform: translateY(-2px);
}

.tarot-spread-image {
  position: relative;
  width: 100%;
  padding-bottom: 150%;
  background:
    linear-gradient(135deg, rgba(216, 182, 95, 0.18), transparent 35%),
    repeating-linear-gradient(45deg, rgba(245, 239, 228, 0.08) 0 1px, transparent 1px 11px),
    linear-gradient(150deg, rgba(92, 37, 50, 0.74), rgba(14, 42, 42, 0.82));
  background-position: center;
  background-size: cover;
  transition: transform 240ms ease;
}

.tarot-spread-image.reversed {
  transform: rotate(180deg);
}

.tarot-spread-image::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(7, 7, 11, 0.54), transparent 52%);
}

.tarot-spread-image.missing {
  display: grid;
  place-items: center;
  padding: 1rem;
  color: var(--text-soft);
  text-align: center;
}

.tarot-spread-image.missing::before {
  content: attr(data-fallback);
  position: absolute;
  inset: 0;
  z-index: 1;
  display: grid;
  place-items: center;
  padding: 1rem;
}

.tarot-spread-info {
  display: grid;
  gap: 0.25rem;
  padding: 0.75rem 0.8rem 0.9rem;
}

.tarot-spread-position {
  color: var(--gold-strong);
  font-size: 0.66rem;
  font-weight: 900;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.tarot-spread-name {
  color: var(--text);
  font-size: 0.98rem;
  font-weight: 900;
  line-height: 1.25;
}

.tarot-spread-orientation {
  color: var(--muted);
  font-size: 0.78rem;
}

.tarot-conversation {
  display: grid;
  gap: 0.9rem;
}

.tarot-conversation h3 {
  font-size: clamp(1.55rem, 2.4vw, 2.1rem);
}

.tarot-messages {
  min-height: 420px;
  max-height: 910px;
}

.messages.tarot-messages .message {
  border-color: rgba(100, 198, 188, 0.26);
}

.messages.tarot-messages .message.user {
  border-color: rgba(216, 182, 95, 0.34);
}

@keyframes tarotShuffleSpin {
  0% {
    transform: translateY(var(--offset, 0)) rotate(var(--rotation, 0));
  }

  50% {
    transform: translateY(var(--offset, 0)) rotate(calc(var(--rotation, 0) + 360deg));
  }

  100% {
    transform: translateY(var(--offset, 0)) rotate(calc(var(--rotation, 0) + 720deg));
  }
}

@keyframes pulse {
  0%,
  100% {
    opacity: 0.28;
    transform: translateY(0);
  }

  50% {
    opacity: 1;
    transform: translateY(-3px);
  }
}

@media (hover: none) and (pointer: coarse) {
  .primary-btn:active,
  .secondary-btn:active,
  .mode-tab:active,
  .tarot-fan-card:active,
  .tarot-pile:active,
  .location-btn:active {
    transform: scale(0.98);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}

@media (max-width: 1120px) {
  .layout,
  .layout.mode-tarot {
    grid-template-columns: 1fr;
  }

  .tarot-layout {
    grid-template-columns: 1fr;
  }

  .tarot-user-info {
    grid-template-columns: 1fr 1fr;
  }

  .messages {
    max-height: none;
  }

  .tarot-messages {
    min-height: 280px;
    max-height: 520px;
  }
}

@media (max-width: 760px) {
  body {
    padding: 0 0.85rem 2.25rem;
    background-size: 54px 54px, 54px 54px, 28px 28px, auto;
  }

  .top-bar {
    align-items: stretch;
    flex-direction: column;
    padding: 0.75rem 0;
  }

  .top-bar__controls {
    width: 100%;
    align-items: stretch;
    flex-direction: column;
  }

  .top-bar__badge {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .language-switcher,
  .mode-switcher,
  .consult-link {
    width: 100%;
  }

  .language-switcher {
    justify-content: space-between;
  }

  .language-switcher label {
    display: none;
  }

  .language-switcher select {
    width: 100%;
  }

  .mode-tab {
    flex: 1;
    padding-inline: 0.7rem;
  }

  .consult-link {
    min-height: 2.75rem;
  }

  .hero,
  .conversation {
    padding: 1.15rem;
  }

  .hero::before {
    width: 15rem;
    height: 15rem;
    right: -7rem;
    top: -5rem;
  }

  .brand h1 {
    max-width: 11ch;
    font-size: clamp(2.35rem, 15vw, 4.35rem);
  }

  fieldset,
  .field-grid,
  .tarot-user-info,
  .tarot-controls,
  .follow-up-inputs {
    grid-template-columns: 1fr;
  }

  .input-with-action {
    grid-template-columns: 1fr;
  }

  .location-btn,
  .secondary-btn {
    width: 100%;
  }

  .tarot-selection-area {
    width: min(340px, 100%);
    height: 285px;
  }

  .tarot-selection-area.stage-ready {
    width: 100%;
    height: 360px;
  }

  .tarot-selection-area.stage-piles {
    width: 100%;
  }

  .tarot-stack {
    width: 172px;
    height: 238px;
  }

  .tarot-stack-cards {
    width: 116px;
    height: 178px;
  }

  .tarot-piles {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.55rem;
  }

  .tarot-pile {
    min-height: 166px;
    padding: 0.8rem 0.45rem;
  }

  .tarot-fan-card {
    width: 112px;
    height: 178px;
  }

  .tarot-fan.expanded .tarot-fan-card {
    width: 128px;
    height: 202px;
  }

  .tarot-spread {
    grid-template-columns: 1fr;
  }

  .tarot-spread-slot {
    justify-content: stretch;
  }

  .tarot-spread-card {
    max-width: none;
    display: grid;
    grid-template-columns: minmax(86px, 0.35fr) minmax(0, 1fr);
  }

  .tarot-spread-image {
    min-height: 132px;
    padding-bottom: 0;
  }

  .message {
    grid-template-columns: 1fr;
  }

  .message .avatar {
    width: 2.15rem;
    height: 2.15rem;
  }
}

@media (max-width: 420px) {
  body {
    padding-inline: 0.55rem;
  }

  .layout {
    gap: 0.75rem;
  }

  .hero,
  .conversation {
    padding: 1rem;
  }

  .brand h1 {
    font-size: clamp(2.1rem, 16vw, 3.35rem);
  }

  .brand p,
  .conversation-subtitle {
    font-size: 0.9rem;
  }

  .tarot-piles {
    grid-template-columns: 1fr;
  }

  .tarot-pile {
    min-height: 132px;
  }

  .tarot-pile::before {
    inset: 0.55rem 0.55rem 2.75rem;
  }

  .tarot-selection-area.stage-piles {
    min-height: 0;
  }

  .tarot-selection-area.stage-ready {
    height: 330px;
  }

  .tarot-fan-card {
    width: 98px;
    height: 156px;
  }

  .tarot-fan.expanded .tarot-fan-card {
    width: 112px;
    height: 178px;
  }

  .tarot-spread-card {
    grid-template-columns: 84px minmax(0, 1fr);
  }

  .tarot-spread-name {
    font-size: 0.92rem;
  }
}

html.is-mobile body {
  padding-bottom: 2rem;
}

html.is-mobile .layout,
html.is-mobile .layout.mode-tarot,
html.is-mobile .tarot-layout {
  grid-template-columns: 1fr;
}

html.is-mobile .messages {
  padding-right: 0;
}
