:root {
  color-scheme: dark;
  --bg: #07080d;
  --panel: rgba(17, 18, 27, 0.86);
  --panel-solid: #11121b;
  --panel-soft: rgba(255, 255, 255, 0.055);
  --line: rgba(227, 205, 159, 0.2);
  --line-strong: rgba(227, 205, 159, 0.42);
  --text: #f2eadf;
  --muted: #a9a1b6;
  --gold: #d7b66f;
  --violet: #8d7ddf;
  --cyan: #73c8d5;
  --blue: #4f9fd9;
  --blue-soft: rgba(79, 159, 217, 0.18);
  --red: #d8898d;
  --green: #91c98e;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.45);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family:
    Inter, "SF Pro Display", "PingFang SC", "Microsoft YaHei", system-ui,
    sans-serif;
}

body.has-modal {
  overflow: hidden;
}

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

button {
  cursor: pointer;
}

#skyCanvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: -1;
  background:
    radial-gradient(circle at 74% 18%, rgba(79, 159, 217, 0.18), transparent 32%),
    radial-gradient(circle at 18% 82%, rgba(115, 200, 213, 0.1), transparent 28%),
    linear-gradient(140deg, rgba(20, 16, 29, 0.8), rgba(7, 8, 13, 0.98)),
    #07080d;
}

.app-shell {
  width: min(1160px, calc(100% - 32px));
  margin: 0 auto;
  padding: 36px 0 48px;
}

.topbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  min-height: 112px;
}

.donation-trigger {
  min-height: 42px;
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid rgba(215, 182, 111, 0.42);
  border-radius: 6px;
  background: rgba(215, 182, 111, 0.08);
  color: var(--text);
  padding: 0 16px;
  font-weight: 720;
  transition:
    border-color 160ms ease,
    background 160ms ease,
    transform 160ms ease;
}

.donation-trigger:hover {
  border-color: rgba(215, 182, 111, 0.7);
  background: rgba(215, 182, 111, 0.14);
  transform: translateY(-1px);
}

.donation-trigger span[aria-hidden="true"] {
  filter: drop-shadow(0 0 8px rgba(215, 182, 111, 0.42));
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--gold);
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: clamp(36px, 6vw, 76px);
  line-height: 0.96;
  font-weight: 760;
  letter-spacing: 0;
}

.brand-mark {
  flex: 0 0 auto;
  font-size: 0.72em;
  filter: drop-shadow(0 0 18px rgba(115, 200, 213, 0.54));
}

.privacy-note {
  width: min(380px, 100%);
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.7;
}

.workspace {
  margin-top: 30px;
  border: 1px solid rgba(115, 200, 213, 0.24);
  background: rgba(9, 10, 16, 0.74);
  box-shadow: var(--shadow), 0 0 42px rgba(79, 159, 217, 0.08);
  backdrop-filter: blur(18px);
}

.daily-brief {
  display: grid;
  gap: 0;
  border-bottom: 1px solid var(--line);
  background:
    linear-gradient(135deg, rgba(79, 159, 217, 0.075), rgba(215, 182, 111, 0.035)),
    rgba(8, 10, 16, 0.72);
}

.daily-brief-row {
  display: grid;
  grid-template-columns: minmax(240px, 1.45fr) repeat(3, minmax(120px, 1fr));
  gap: 0;
}

.daily-brief-row + .daily-brief-row {
  border-top: 1px solid rgba(115, 200, 213, 0.14);
}

.daily-brief-main,
.daily-brief-item {
  min-width: 0;
  display: grid;
  gap: 6px;
  align-content: center;
  padding: 14px 16px;
  background: rgba(255, 255, 255, 0.018);
  border-right: 1px solid rgba(115, 200, 213, 0.11);
}

.daily-brief-row > :last-child {
  border-right: 0;
}

.daily-brief-main span,
.daily-brief-item span {
  color: var(--gold);
  font-size: 12px;
}

.daily-brief-main strong,
.daily-brief-item strong {
  color: var(--text);
  font-size: 14px;
  line-height: 1.45;
  font-weight: 720;
}

.daily-brief-main em {
  color: var(--muted);
  font-size: 13px;
  font-style: normal;
}

.ai-status {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.7;
}

.ai-status[data-state="ready"],
.ai-status[data-state="loading"] {
  color: #9eddf0;
}

.ai-status[data-state="missing-key"],
.ai-status[data-state="offline"] {
  color: #d7c5a3;
}

.mode-tabs {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.035);
}

.mode-tab {
  min-height: 58px;
  border: 0;
  border-right: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  font-size: 16px;
  transition:
    color 180ms ease,
    background 180ms ease;
}

.mode-tab:last-child {
  border-right: 0;
}

.mode-tab:hover,
.mode-tab.active {
  background: linear-gradient(135deg, rgba(215, 182, 111, 0.08), rgba(79, 159, 217, 0.08));
  color: var(--text);
}

.panel {
  display: none;
}

.panel.active {
  display: block;
}

.panel-grid {
  display: grid;
  grid-template-columns: minmax(300px, 410px) minmax(0, 1fr);
  min-height: 580px;
}

.input-panel {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 28px;
  border-right: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.025);
}

.form-row {
  display: grid;
  gap: 14px;
}

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

label {
  display: grid;
  gap: 8px;
}

label span {
  color: var(--gold);
  font-size: 13px;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 6px;
  background: rgba(6, 7, 12, 0.72);
  color: var(--text);
  outline: none;
  transition:
    border-color 160ms ease,
    box-shadow 160ms ease,
    background 160ms ease;
}

input,
select {
  min-height: 44px;
  padding: 0 12px;
}

textarea {
  resize: vertical;
  min-height: 112px;
  padding: 12px;
  line-height: 1.6;
}

input:focus,
select:focus,
textarea:focus {
  border-color: rgba(115, 200, 213, 0.56);
  box-shadow: 0 0 0 3px rgba(79, 159, 217, 0.12);
  background: rgba(10, 11, 18, 0.96);
}

.primary-action {
  min-height: 48px;
  margin-top: 0;
  border: 1px solid rgba(215, 182, 111, 0.56);
  border-radius: 6px;
  background: linear-gradient(135deg, #d7b66f, #9d7a37);
  color: #14100b;
  font-weight: 760;
  letter-spacing: 0;
  transition:
    transform 160ms ease,
    filter 160ms ease;
}

.primary-action:hover {
  filter: brightness(1.06);
  transform: translateY(-1px);
}

.secondary-action {
  min-height: 44px;
  width: fit-content;
  border: 1px solid rgba(115, 200, 213, 0.34);
  border-radius: 6px;
  background: rgba(115, 200, 213, 0.1);
  color: var(--text);
  padding: 0 16px;
  font-weight: 700;
}

.meta-lines {
  display: grid;
  gap: 8px;
  padding: 16px;
  border: 1px solid rgba(115, 200, 213, 0.22);
  background: rgba(79, 159, 217, 0.06);
  color: var(--muted);
  font-size: 13px;
  line-height: 1.7;
}

.meta-lines p {
  margin: 0;
}

.secondary-action:hover {
  border-color: rgba(115, 200, 213, 0.58);
  background: rgba(115, 200, 213, 0.16);
}

.ai-action-row {
  display: grid;
  grid-template-columns: 1fr;
  align-items: start;
  gap: 12px;
}

.ai-action-row .primary-action,
.ai-action-row .secondary-action {
  width: fit-content;
  min-width: 0;
}

.location-box {
  display: grid;
  gap: 8px;
}

.location-box p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.7;
}

.inline-ai-model {
  min-width: 0;
}

.inline-ai-model select,
#liurenCastTime {
  min-width: 0;
}

.is-hidden {
  display: none !important;
}

.result-panel {
  min-width: 0;
  padding: 30px;
}

.empty-state {
  min-height: 500px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 24px;
  color: var(--muted);
  text-align: center;
}

.sigil {
  width: 154px;
  aspect-ratio: 1;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  position: relative;
  background:
    conic-gradient(from 22deg, transparent 0 18deg, rgba(215, 182, 111, 0.18) 18deg 20deg, transparent 20deg 60deg),
    radial-gradient(circle, transparent 42%, rgba(141, 125, 223, 0.16) 43% 44%, transparent 45%);
}

.sigil::before,
.sigil::after {
  content: "";
  position: absolute;
  inset: 22px;
  border: 1px solid rgba(115, 200, 213, 0.25);
  border-radius: 50%;
}

.sigil::after {
  inset: 52px;
  border-color: rgba(215, 182, 111, 0.32);
}

.result-stack {
  display: grid;
  gap: 18px;
}

.result-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.result-header h2 {
  margin: 0;
  font-size: 28px;
  letter-spacing: 0;
}

.result-header p {
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.7;
}

.badge {
  flex: 0 0 auto;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--gold);
  font-size: 13px;
}

.pillars {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.pillar {
  min-height: 116px;
  display: grid;
  place-items: center;
  gap: 6px;
  border: 1px solid var(--line);
  background: var(--panel-soft);
}

.pillar strong {
  font-size: 30px;
  letter-spacing: 0;
}

.pillar span {
  color: var(--muted);
  font-size: 13px;
}

.element-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
}

.element {
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.04);
}

.element .meter {
  height: 5px;
  margin-top: 10px;
  background: rgba(255, 255, 255, 0.08);
}

.element .fill {
  height: 100%;
  width: var(--width);
  background: var(--color);
}

.reading {
  display: grid;
  gap: 14px;
  padding: 20px;
  border: 1px solid var(--line);
  background: var(--panel);
}

.reading p {
  margin: 0;
  color: #ded5ce;
  line-height: 1.8;
}

.reading h3 {
  margin: 0;
  color: var(--text);
  font-size: 18px;
}

.ai-reading {
  border-color: rgba(115, 200, 213, 0.28);
  background:
    linear-gradient(135deg, rgba(115, 200, 213, 0.08), transparent 46%),
    var(--panel);
}

.ai-reading.loading {
  color: var(--muted);
}

.ai-reading.failed {
  border-color: rgba(216, 137, 141, 0.3);
}

.oracle-card {
  display: grid;
  gap: 18px;
  padding: 26px;
  border: 1px solid var(--line-strong);
  background:
    linear-gradient(180deg, rgba(215, 182, 111, 0.08), transparent 34%),
    var(--panel);
}

.oracle-title {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 16px;
}

.oracle-title h2 {
  margin: 0;
  font-size: 30px;
}

.oracle-title span {
  color: var(--gold);
}

.poem {
  font-size: 22px;
  line-height: 1.8;
  color: var(--text);
}

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

.topic {
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.035);
  line-height: 1.7;
}

.topic strong {
  display: block;
  margin-bottom: 4px;
  color: var(--gold);
}

.palace-wheel {
  display: grid;
  grid-template-columns: repeat(3, minmax(74px, 1fr));
  grid-template-areas:
    "leftTop top rightTop"
    "leftTop center rightBottom"
    "leftBottom bottom rightBottom";
  gap: 12px;
  padding: 14px;
  border: 1px solid rgba(115, 200, 213, 0.2);
  background:
    radial-gradient(circle at 50% 48%, rgba(115, 200, 213, 0.14), transparent 36%),
    linear-gradient(135deg, rgba(79, 159, 217, 0.08), rgba(255, 255, 255, 0.02));
}

.palace {
  min-height: 78px;
  display: grid;
  gap: 4px;
  place-items: center;
  border: 1px solid rgba(115, 200, 213, 0.18);
  background:
    linear-gradient(180deg, rgba(115, 200, 213, 0.08), rgba(255, 255, 255, 0.03));
  color: var(--muted);
  box-shadow: inset 0 0 22px rgba(79, 159, 217, 0.035);
}

.palace-top {
  grid-area: top;
}

.palace-right-top {
  grid-area: rightTop;
}

.palace-right-bottom {
  grid-area: rightBottom;
}

.palace-bottom {
  grid-area: bottom;
}

.palace-left-bottom {
  grid-area: leftBottom;
}

.palace-left-top {
  grid-area: leftTop;
}

.palace.active {
  border-color: rgba(115, 200, 213, 0.78);
  background:
    radial-gradient(circle at 50% 20%, rgba(215, 182, 111, 0.22), transparent 48%),
    linear-gradient(180deg, rgba(115, 200, 213, 0.2), rgba(79, 159, 217, 0.08));
  color: var(--text);
  box-shadow:
    0 0 0 1px rgba(215, 182, 111, 0.24),
    0 12px 34px rgba(79, 159, 217, 0.18);
}

.palace strong {
  font-size: 16px;
}

.palace small {
  color: var(--gold);
  font-size: 12px;
}

.palace-center {
  grid-area: center;
  min-height: 78px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(215, 182, 111, 0.28);
  background:
    radial-gradient(circle, rgba(215, 182, 111, 0.16), rgba(79, 159, 217, 0.08) 58%, transparent 62%);
  color: var(--gold);
  font-size: 13px;
  letter-spacing: 0;
}

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

.number-card {
  display: grid;
  gap: 14px;
  padding: 18px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
}

.number-card.full {
  grid-column: 1 / -1;
}

.number-card h3 {
  margin: 0;
  color: var(--gold);
  font-size: 16px;
}

.number-line {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.number-token {
  min-width: 44px;
  height: 44px;
  display: inline-grid;
  place-items: center;
  border: 1px solid rgba(215, 182, 111, 0.36);
  border-radius: 50%;
  background: rgba(215, 182, 111, 0.1);
  color: var(--text);
  font-size: 18px;
  font-weight: 760;
}

.number-token.blue {
  border-color: rgba(115, 200, 213, 0.5);
  background: rgba(115, 200, 213, 0.12);
}

.number-token.violet {
  border-color: rgba(141, 125, 223, 0.5);
  background: rgba(141, 125, 223, 0.14);
}

.scratch-order {
  display: flex;
  align-items: baseline;
  gap: 10px;
  color: var(--text);
}

.scratch-order strong {
  font-size: 52px;
  line-height: 1;
  color: var(--gold);
}

.scratch-order span {
  color: var(--muted);
}

.warning-note {
  padding: 14px;
  border: 1px solid rgba(216, 137, 141, 0.32);
  background: rgba(216, 137, 141, 0.08);
  color: #ead3d4;
  line-height: 1.7;
}

.site-footer {
  width: min(1160px, calc(100% - 32px));
  margin: 0 auto;
  padding: 0 0 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 6px 10px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.7;
  text-align: center;
}

.site-footer a {
  color: inherit;
  text-decoration: none;
  transition: color 160ms ease;
}

.site-footer a:hover,
.site-footer a:focus-visible {
  color: var(--text);
}

.footer-separator {
  color: rgba(169, 161, 182, 0.5);
}

.donation-modal[hidden] {
  display: none;
}

.donation-modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 20px;
}

.donation-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(2, 3, 7, 0.72);
  backdrop-filter: blur(10px);
}

.donation-dialog {
  position: relative;
  width: min(560px, 100%);
  max-height: min(760px, calc(100vh - 40px));
  overflow: auto;
  display: grid;
  gap: 18px;
  border: 1px solid rgba(115, 200, 213, 0.28);
  background:
    linear-gradient(135deg, rgba(115, 200, 213, 0.1), transparent 42%),
    linear-gradient(180deg, rgba(215, 182, 111, 0.08), transparent 34%),
    rgba(12, 13, 20, 0.98);
  box-shadow: var(--shadow), 0 0 46px rgba(79, 159, 217, 0.14);
  padding: 28px;
}

.donation-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 34px;
  height: 34px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  font-size: 22px;
  line-height: 1;
}

.donation-close:hover {
  border-color: rgba(215, 182, 111, 0.48);
  background: rgba(215, 182, 111, 0.1);
}

.donation-dialog h2 {
  margin: 0;
  padding-right: 38px;
  font-size: 28px;
  line-height: 1.25;
  letter-spacing: 0;
}

.donation-intro,
.donation-footnote {
  margin: 0;
  color: #ded5ce;
  line-height: 1.8;
}

.donation-footnote {
  color: var(--muted);
  font-size: 13px;
}

.donation-impact {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.donation-impact div {
  display: grid;
  gap: 8px;
  min-height: 104px;
  align-content: start;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.04);
  padding: 16px;
}

.donation-impact strong {
  color: var(--gold);
}

.donation-impact span {
  color: var(--muted);
  line-height: 1.65;
  font-size: 14px;
}

.donation-qr {
  min-height: 156px;
  display: grid;
  place-items: center;
  border: 1px dashed rgba(115, 200, 213, 0.32);
  background: rgba(6, 7, 12, 0.48);
  padding: 14px;
}

.donation-qr img {
  width: min(220px, 100%);
  aspect-ratio: 1;
  object-fit: contain;
  background: #fff;
  padding: 8px;
}

.qr-placeholder {
  color: var(--muted);
  text-align: center;
  line-height: 1.7;
  font-size: 14px;
}

@media (max-width: 860px) {
  .app-shell {
    width: min(100% - 20px, 680px);
    padding-top: 22px;
  }

  .topbar {
    display: grid;
    align-items: start;
    min-height: unset;
  }

  .donation-trigger {
    width: fit-content;
  }

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

  .daily-brief {
    grid-template-columns: 1fr;
  }

  .daily-brief-row,
  .daily-brief-row:first-child {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .input-panel {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .pillars,
  .element-grid,
  .topic-grid,
  .number-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .palace-wheel {
    grid-template-columns: repeat(3, minmax(64px, 1fr));
  }
}

@media (max-width: 560px) {
  .app-shell {
    width: 100%;
    padding: 0;
  }

  .topbar {
    padding: 24px 16px;
  }

  .workspace {
    margin-top: 0;
    border-left: 0;
    border-right: 0;
  }

  .daily-brief {
    grid-template-columns: 1fr;
  }

  .daily-brief-row,
  .daily-brief-row:first-child {
    grid-template-columns: 1fr;
  }

  .mode-tab {
    min-height: 52px;
    font-size: 15px;
  }

  .input-panel,
  .result-panel {
    padding: 20px 16px;
  }

  .form-row.two,
  .pillars,
  .element-grid,
  .topic-grid,
  .number-grid {
    grid-template-columns: 1fr;
  }

  .ai-action-row {
    grid-template-columns: 1fr;
  }

  .ai-action-row .primary-action,
  .ai-action-row .secondary-action {
    width: 100%;
  }

  .palace-wheel {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
    padding: 10px;
  }

  .palace,
  .palace-center {
    min-height: 68px;
  }

  .result-header,
  .oracle-title {
    display: grid;
  }

  .donation-modal {
    align-items: end;
    padding: 12px;
  }

  .donation-dialog {
    max-height: calc(100vh - 24px);
    padding: 24px 18px;
  }

  .donation-impact {
    grid-template-columns: 1fr;
  }

}

@media (max-width: 420px) {
  .mode-tabs {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .mode-tab:nth-child(2) {
    border-right: 0;
  }
}
