:root {
  color-scheme: dark;
  --bg: #05020a;
  --panel: rgba(12, 8, 22, 0.88);
  --panel-strong: rgba(18, 10, 34, 0.96);
  --line: rgba(139, 92, 246, 0.34);
  --line-warm: rgba(188, 148, 255, 0.36);
  --text: #f8f1ff;
  --muted: #a99ac5;
  --cyan: #bda3ff;
  --jade: #6d4acb;
  --gold: #d9c2ff;
  --magenta: #a855f7;
  --violet: #6d28d9;
  --deep-violet: #1c0b33;
  --danger: #ff6a86;
  --radius: 8px;
  --shadow: 0 28px 100px rgba(0, 0, 0, 0.62);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  color: var(--text);
  background:
    radial-gradient(circle at 18% 10%, rgba(109, 40, 217, 0.3), transparent 27rem),
    radial-gradient(circle at 82% 12%, rgba(76, 29, 149, 0.34), transparent 30rem),
    radial-gradient(circle at 52% 76%, rgba(168, 85, 247, 0.14), transparent 26rem),
    linear-gradient(135deg, rgba(11, 6, 24, 0.98), rgba(3, 2, 8, 0.99)),
    var(--bg);
}

body::before {
  position: fixed;
  inset: 0;
  z-index: -3;
  content: "";
  background-image:
    linear-gradient(rgba(139, 92, 246, 0.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(168, 85, 247, 0.06) 1px, transparent 1px);
  background-size: 54px 54px;
  mask-image: linear-gradient(to bottom, black, transparent 88%);
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

a {
  color: inherit;
  text-decoration: none;
}

.aura {
  position: fixed;
  z-index: -2;
  width: 34rem;
  height: 34rem;
  border-radius: 999px;
  filter: blur(58px);
  opacity: 0.16;
  pointer-events: none;
}

.aura-gold {
  right: -10rem;
  bottom: 12rem;
  background: #7c3aed;
}

.aura-cyan {
  left: -10rem;
  top: 28rem;
  background: #2e1065;
}

.scanlines {
  position: fixed;
  inset: 0;
  z-index: 20;
  pointer-events: none;
  opacity: 0.1;
  background: repeating-linear-gradient(
    to bottom,
    rgba(255, 255, 255, 0.24) 0,
    rgba(255, 255, 255, 0.24) 1px,
    transparent 1px,
    transparent 6px
  );
  mix-blend-mode: overlay;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  max-width: 1240px;
  margin: 0 auto;
  padding: 1.25rem clamp(1rem, 4vw, 2rem);
}

.brand {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 0.85rem;
}

.brand-mark {
  display: grid;
  width: 3.1rem;
  aspect-ratio: 1;
  place-items: center;
  color: #f6edff;
  font-size: 1.45rem;
  font-weight: 900;
  background:
    linear-gradient(135deg, #2e1065, var(--violet) 58%, #bda3ff);
  border: 1px solid rgba(217, 194, 255, 0.42);
  box-shadow: 0 0 38px rgba(109, 40, 217, 0.42);
  clip-path: polygon(50% 0, 92% 25%, 92% 75%, 50% 100%, 8% 75%, 8% 25%);
}

.brand h1,
.section-title h2,
.console-header h2 {
  margin: 0;
  line-height: 1.05;
  letter-spacing: 0;
}

.brand h1 {
  font-size: clamp(1.55rem, 4vw, 2.55rem);
}

.kicker {
  margin: 0 0 0.35rem;
  color: var(--gold);
  font-size: 0.74rem;
  font-weight: 750;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.nav-pills {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.55rem;
}

.header-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 0.65rem;
}

.nav-pills a {
  padding: 0.5rem 0.78rem;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid rgba(139, 92, 246, 0.2);
  border-radius: 999px;
}

.nav-pills a:hover,
.nav-pills a:focus-visible {
  color: var(--text);
  border-color: var(--line);
  outline: none;
}

.language-switcher {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  padding: 0.25rem;
  border: 1px solid rgba(139, 92, 246, 0.2);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.035);
}

.language-switcher button {
  min-height: 2rem;
  padding: 0 0.55rem;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 800;
  border: 0;
  border-radius: 999px;
  background: transparent;
}

.language-switcher button.active,
.language-switcher button:hover,
.language-switcher button:focus-visible {
  color: #faf5ff;
  outline: none;
  background: linear-gradient(135deg, #3b0764, #6d28d9 58%, #a78bfa);
}

main {
  max-width: 1240px;
  margin: 0 auto;
  padding: 0 clamp(1rem, 4vw, 2rem) 4rem;
}

.ritual-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.16fr) minmax(320px, 0.84fr);
  align-items: stretch;
  gap: 1.1rem;
  min-height: calc(100vh - 6.2rem);
}

.oracle-stage,
.ritual-console,
.wish-wall,
.donation-panel,
.comments-zone {
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.oracle-stage {
  position: relative;
  display: grid;
  min-height: 34rem;
  place-items: center;
  overflow: hidden;
  border-radius: var(--radius);
  background:
    radial-gradient(circle at 50% 50%, rgba(109, 40, 217, 0.18), transparent 34%),
    linear-gradient(145deg, rgba(88, 28, 135, 0.22), transparent 34%),
    linear-gradient(315deg, rgba(167, 139, 250, 0.1), transparent 36%),
    rgba(5, 3, 13, 0.88);
}

.oracle-stage::before,
.oracle-stage::after {
  position: absolute;
  inset: 1.2rem;
  content: "";
  border: 1px solid rgba(216, 180, 254, 0.2);
  clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%);
}

.oracle-stage::after {
  inset: 2.15rem;
  border-color: rgba(109, 40, 217, 0.34);
  transform: rotate(45deg);
}

#mandalaCanvas {
  width: min(92%, 42rem);
  max-height: 86vh;
  aspect-ratio: 1;
  filter: drop-shadow(0 0 32px rgba(109, 40, 217, 0.3));
}

.altar-core {
  position: absolute;
  display: grid;
  width: clamp(8.5rem, 18vw, 11.4rem);
  aspect-ratio: 1;
  place-items: center;
  padding: 1rem;
  color: #0b1020;
  text-align: center;
  background: radial-gradient(circle, #f5edff 0 18%, #a78bfa 44%, #4c1d95 100%);
  border: 1px solid rgba(216, 180, 254, 0.7);
  border-radius: 50%;
  box-shadow:
    0 0 18px rgba(216, 180, 254, 0.46),
    0 0 76px rgba(109, 40, 217, 0.5);
}

.altar-core strong {
  font-size: clamp(2rem, 5vw, 3.3rem);
  line-height: 0.8;
}

.core-label {
  color: #19072d;
  font-size: 0.74rem;
  font-weight: 800;
  max-width: 7.6rem;
  line-height: 1.15;
}

.ritual-console {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding: clamp(1rem, 2.8vw, 1.4rem);
  border-radius: var(--radius);
}

.console-header h2,
.section-title h2 {
  font-size: clamp(1.38rem, 3vw, 2rem);
}

.identity-panel,
.wish-form,
.omens,
.comment-form {
  border: 1px solid rgba(139, 92, 246, 0.18);
  background: rgba(255, 255, 255, 0.032);
  border-radius: var(--radius);
}

.identity-panel,
.wish-form,
.comment-form {
  padding: 1rem;
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 2.35rem;
  color: var(--muted);
}

.status-dot {
  width: 0.7rem;
  aspect-ratio: 1;
  border-radius: 999px;
  background: var(--danger);
  box-shadow: 0 0 18px currentColor;
}

.user-chip.is-on .status-dot {
  color: var(--jade);
  background: var(--jade);
}

.auth-form,
.wish-form,
.comment-form {
  display: grid;
  gap: 0.85rem;
}

.auth-form {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.auth-form .button-row {
  grid-column: 1 / -1;
}

.logout-inline {
  display: none;
  width: 100%;
  margin-top: 0.75rem;
}

.identity-panel.is-logged-in .auth-form {
  display: none;
}

.identity-panel.is-logged-in .logout-inline {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

label {
  display: grid;
  gap: 0.4rem;
  color: var(--muted);
  font-size: 0.88rem;
}

input,
textarea {
  width: 100%;
  color: var(--text);
  background: rgba(3, 2, 8, 0.76);
  border: 1px solid rgba(169, 154, 197, 0.22);
  border-radius: 6px;
  outline: none;
}

input {
  min-height: 2.65rem;
  padding: 0 0.78rem;
}

textarea {
  min-height: 7.8rem;
  padding: 0.78rem;
  resize: vertical;
}

input:focus,
textarea:focus {
  border-color: var(--cyan);
  box-shadow: 0 0 0 3px rgba(109, 40, 217, 0.18);
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.btn {
  min-height: 2.75rem;
  padding: 0 1rem;
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 6px;
  transition:
    transform 160ms ease,
    border-color 160ms ease,
    box-shadow 160ms ease;
}

.btn:hover,
.btn:focus-visible {
  transform: translateY(-1px);
  outline: none;
}

.btn.primary {
  color: #faf5ff;
  font-size: 1.05rem;
  font-weight: 900;
  background: linear-gradient(135deg, #3b0764, var(--violet) 54%, #a78bfa);
  box-shadow: 0 0 42px rgba(109, 40, 217, 0.32);
}

.btn.secondary {
  color: #faf5ff;
  font-weight: 850;
  background: linear-gradient(135deg, #4c1d95, var(--magenta), #7c3aed);
}

.btn.ghost {
  color: var(--text);
  background: rgba(109, 40, 217, 0.16);
}

.btn.text {
  color: var(--muted);
  background: transparent;
}

.mode-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.55rem;
}

.mode-switch label {
  display: block;
  color: var(--muted);
}

.mode-switch input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.mode-switch span {
  display: grid;
  min-height: 2.75rem;
  place-items: center;
  padding: 0 0.65rem;
  border: 1px solid rgba(169, 154, 197, 0.18);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.035);
}

.mode-switch input:checked + span {
  color: #faf5ff;
  font-weight: 850;
  border-color: transparent;
  background: linear-gradient(135deg, #3b0764, var(--violet), #a78bfa);
}

.omens {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
  padding: 0.6rem;
}

.omens article {
  min-width: 0;
  padding: 0.7rem;
  border: 1px solid rgba(139, 92, 246, 0.14);
  border-radius: 6px;
  background: rgba(3, 2, 8, 0.42);
}

.omens span,
.wish-meta,
.comment-meta,
.donation-copy,
.comment-guard {
  color: var(--muted);
  font-size: 0.83rem;
}

.omens strong {
  display: block;
  margin-top: 0.32rem;
  overflow-wrap: anywhere;
}

.liturgy-band {
  margin: 1.1rem 0;
  padding: clamp(1.1rem, 3vw, 1.7rem);
  color: #faf5ff;
  border-radius: var(--radius);
  background:
    linear-gradient(90deg, rgba(46, 16, 101, 0.96), rgba(109, 40, 217, 0.94), rgba(167, 139, 250, 0.88)),
    var(--violet);
}

.liturgy-band p {
  max-width: 66rem;
  margin: 0 auto;
  font-size: clamp(1.05rem, 2.5vw, 1.55rem);
  font-weight: 850;
  text-align: center;
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 360px);
  gap: 1.1rem;
}

.wish-wall,
.donation-panel,
.comments-zone {
  padding: clamp(1rem, 2.7vw, 1.35rem);
  border-radius: var(--radius);
}

.section-title {
  margin-bottom: 1rem;
}

.wish-list,
.comment-list {
  display: grid;
  gap: 0.75rem;
}

.wish-card,
.comment-card {
  padding: 1rem;
  border: 1px solid rgba(139, 92, 246, 0.18);
  border-radius: var(--radius);
  background:
    linear-gradient(135deg, rgba(109, 40, 217, 0.12), transparent 45%),
    rgba(255, 255, 255, 0.035);
}

.wish-card p,
.comment-card p {
  margin: 0.6rem 0 0;
  line-height: 1.65;
  overflow-wrap: anywhere;
}

.wish-meta,
.comment-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
}

.wish-author,
.comment-meta strong {
  color: var(--gold);
}

.sigils {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-top: 0.85rem;
}

.sigils span {
  padding: 0.28rem 0.5rem;
  color: #faf5ff;
  font-size: 0.74rem;
  font-weight: 850;
  background: #4c1d95;
  border-radius: 999px;
  overflow-wrap: anywhere;
}

.sigils span:nth-child(2) {
  background: #6d28d9;
}

.sigils span:nth-child(3) {
  background: #8b5cf6;
}

.donation-panel {
  position: sticky;
  top: 1rem;
  align-self: start;
}

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

.payment-qr {
  display: grid;
  gap: 0.55rem;
  min-width: 0;
  margin: 0;
}

.qr-frame {
  position: relative;
  display: grid;
  aspect-ratio: 1;
  place-items: center;
  overflow: hidden;
  padding: 0.42rem;
  border: 1px solid var(--line-warm);
  border-radius: var(--radius);
  background: #fff;
  box-shadow:
    inset 0 0 0 1px rgba(0, 0, 0, 0.06),
    0 16px 38px rgba(0, 0, 0, 0.36);
  cursor: pointer;
}

.qr-frame img {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  object-fit: contain;
  border-radius: 4px;
}

.qr-frame img[hidden] {
  display: none !important;
}

.qr-frame img:not([src]),
.qr-frame img[src=""] {
  display: none;
}

.payment-qr figcaption {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-align: center;
  text-transform: lowercase;
}

.donation-copy {
  margin: 0;
  color: var(--gold);
  font-size: 0.95rem;
  font-weight: 900;
  text-align: center;
}

.merit-meter {
  height: 0.62rem;
  margin-top: 1rem;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.07);
}

.merit-meter span {
  display: block;
  width: var(--level);
  height: 100%;
  background: linear-gradient(90deg, #3b0764, var(--violet), #a78bfa);
}

.comments-zone {
  margin-top: 1.1rem;
}

.comment-form {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
}

.comment-form textarea {
  min-height: 5rem;
}

.comment-form[aria-disabled="true"] {
  opacity: 0.72;
}

.comment-form[aria-disabled="true"] textarea {
  pointer-events: none;
}

.comment-guard {
  margin: 0.8rem 0 1rem;
}

.toast {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 30;
  max-width: min(24rem, calc(100vw - 2rem));
  padding: 0.8rem 1rem;
  color: #faf5ff;
  font-weight: 850;
  border-radius: 6px;
  background: linear-gradient(135deg, #3b0764, var(--violet), #a78bfa);
  box-shadow: var(--shadow);
}

.empty-state {
  padding: 1rem;
  color: var(--muted);
  border: 1px dashed rgba(168, 178, 201, 0.22);
  border-radius: var(--radius);
}

@media (max-width: 920px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .header-actions {
    justify-content: flex-start;
    width: 100%;
  }

  .nav-pills {
    justify-content: flex-start;
  }

  .ritual-grid,
  .content-grid {
    grid-template-columns: 1fr;
  }

  .ritual-grid {
    min-height: 0;
  }

  .oracle-stage {
    min-height: 28rem;
  }

  .donation-panel {
    position: static;
  }
}

@media (max-width: 620px) {
  main {
    padding-bottom: 2rem;
  }

  .brand {
    align-items: flex-start;
  }

  .brand-mark {
    width: 2.55rem;
    font-size: 1.15rem;
  }

  .nav-pills {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    width: 100%;
  }

  .language-switcher {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    width: 100%;
    border-radius: 8px;
  }

  .nav-pills a {
    padding-inline: 0.35rem;
    text-align: center;
  }

  .language-switcher button {
    padding-inline: 0.2rem;
  }

  .oracle-stage {
    min-height: 23rem;
  }

  .omens,
  .mode-switch,
  .comment-form,
  .auth-form,
  .payment-grid {
    grid-template-columns: 1fr;
  }

  .wish-meta,
  .comment-meta {
    align-items: flex-start;
    flex-direction: column;
    gap: 0.2rem;
  }
}
