:root {
  color-scheme: light;
  --bg: #f3ece0;
  --bg-soft: #eadfce;
  --panel: rgba(250, 246, 238, 0.88);
  --panel-strong: #f8f1e6;
  --panel-border: #d8c9b6;
  --gold: #a2783f;
  --gold-soft: #6f512d;
  --accent: #b43a24;
  --lacquer: #b43a24;
  --paper: #2b2722;
  --text: #2e2924;
  --muted: #746b61;
  --danger: #a72f20;
  --success: #3c6b4f;
  --shadow: 0 14px 36px rgba(78, 58, 36, 0.1);
  --font-display: "Songti SC", "STSong", "Noto Serif CJK SC", "Yu Mincho", "Hiragino Mincho ProN", Georgia, serif;
  --font-body: "Songti SC", "STSong", "Noto Serif CJK SC", "Yu Mincho", "Hiragino Mincho ProN", Georgia, serif;
  --font-data: "SFMono-Regular", "Menlo", "Consolas", monospace;
}

* {
  box-sizing: border-box;
}

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

html,
body {
  margin: 0;
  min-height: 100%;
  background:
    linear-gradient(180deg, rgba(196, 127, 49, 0.1) 0%, rgba(18, 18, 18, 0) 360px),
    linear-gradient(180deg, #121212 0%, #171717 58%, #101010 100%);
  color: var(--text);
  font-family: var(--font-body);
}

body {
  padding: 0;
}

.app-shell {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 16px 40px;
  padding-bottom: calc(40px + env(safe-area-inset-bottom, 0px));
}

/* ===== Top bar ===== */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  width: 100vw;
  min-height: 64px;
  margin-left: calc(50% - 50vw);
  padding: 12px max(16px, calc((100vw - 1248px) / 2));
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(18, 18, 18, 0.86);
  box-shadow: none;
  backdrop-filter: blur(16px);
}

.brand-lockup {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  color: inherit;
  text-decoration: none;
}

.account-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 32px;
  height: 32px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 50%;
  background: var(--avatar-color, #a16b2c);
  color: #fff;
  font-family: var(--font-body);
  font-weight: 700;
  box-shadow: none;
  overflow: hidden;
}

.avatar-color-0 { --avatar-color: #b4553d; }
.avatar-color-1 { --avatar-color: #3f7d6d; }
.avatar-color-2 { --avatar-color: #4169a1; }
.avatar-color-3 { --avatar-color: #8a5a9e; }
.avatar-color-4 { --avatar-color: #a16b2c; }
.avatar-color-5 { --avatar-color: #3d7f9a; }
.avatar-color-6 { --avatar-color: #6e7f3d; }
.avatar-color-7 { --avatar-color: #9a4964; }

.account-avatar__image {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.account-avatar__fallback {
  font-size: 0.72rem;
  line-height: 1;
}

.brand-mark {
  display: grid;
  grid-template-columns: repeat(2, 4px);
  grid-template-rows: repeat(2, 4px);
  gap: 3px;
  width: 16px;
  height: 16px;
  transform: rotate(45deg);
}

.brand-mark i {
  display: block;
  width: 4px;
  height: 4px;
  border: 1px solid rgba(219, 219, 219, 0.78);
  border-radius: 50%;
}

.brand-name {
  font-family: var(--font-display);
  color: var(--paper);
  font-size: 0.92rem;
  font-weight: 700;
  line-height: 1.1;
  white-space: nowrap;
}

.topbar-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  min-width: 0;
}

.account-panel {
  position: relative;
}

.account-chip {
  display: inline-flex;
  align-items: center;
  gap: 0;
  width: 40px;
  min-height: 40px;
  padding: 4px;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  cursor: pointer;
}

.account-email {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-email {
  color: var(--muted);
  font-family: var(--font-data);
  font-size: 0.72rem;
  line-height: 1.25;
}

.account-popover {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  width: min(340px, calc(100vw - 28px));
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  background: rgba(18, 18, 18, 0.98);
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(-4px);
  pointer-events: none;
  transition: opacity 0.16s ease, transform 0.16s ease;
}

.account-panel:hover .account-popover,
.account-panel:focus-within .account-popover,
.account-panel.is-open .account-popover {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.account-popover__header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.account-avatar--large {
  width: 42px;
  height: 42px;
}

.account-avatar--large .account-avatar__fallback {
  font-size: 0.84rem;
}

.account-popover__name {
  color: var(--paper);
  font-weight: 800;
  line-height: 1.35;
}

.account-popover__email {
  color: var(--muted);
  font-family: var(--font-data);
  font-size: 0.78rem;
  word-break: break-all;
}

.account-quota {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  padding: 18px 0;
}

.account-quota > div {
  min-width: 0;
}

.account-quota .meta-value {
  display: block;
  margin-top: 5px;
  color: var(--paper);
  font-family: var(--font-data);
  font-size: 0.86rem;
  line-height: 1.45;
  word-break: break-word;
}

.account-actions {
  display: grid;
  grid-template-columns: 1fr;
}

.account-actions .secondary-button {
  width: 100%;
  min-height: 40px;
  padding: 10px 12px;
}

/* ===== Login ===== */
.login-view {
  min-height: 100vh;
  min-height: 100svh;
  padding: 0 max(24px, calc((100vw - 1080px) / 2));
}

.login-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 64px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.login-topbar__actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.topbar-login-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 64px;
  min-height: 36px;
  padding: 7px 16px;
  border: 1px solid currentColor;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.04);
  color: rgba(219, 219, 219, 0.82);
  font: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
}

.topbar-login-button:hover:not(:disabled),
.topbar-login-button:focus-visible {
  background: rgba(255, 255, 255, 0.08);
  color: var(--paper);
}

.topbar-login-button:disabled {
  cursor: not-allowed;
  opacity: 0.38;
}

.language-switcher {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  color: rgba(219, 219, 219, 0.66);
  font-size: 0.82rem;
  cursor: pointer;
}

.language-switcher svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.language-switcher select {
  position: absolute;
  inset: 0;
  width: 100%;
  min-width: 0;
  min-height: 0;
  padding: 0;
  border: 0;
  opacity: 0;
  cursor: pointer;
}

.language-switcher:focus-within,
.language-switcher:hover {
  color: var(--paper);
}

.language-switcher--icon {
  width: 40px;
  justify-content: center;
}

.login-main {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(260px, 0.8fr);
  align-items: end;
  gap: clamp(48px, 10vw, 150px);
  min-height: calc(100svh - 64px);
  padding: clamp(80px, 15vh, 180px) 0 clamp(72px, 12vh, 130px);
}

.login-copy {
  max-width: 680px;
}

.login-trigrams {
  margin-bottom: 28px;
  color: rgba(219, 219, 219, 0.3);
  font-size: 0.8rem;
}

.login-eyebrow {
  margin: 0 0 16px;
  color: var(--gold);
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
}

.login-copy h1 {
  max-width: 620px;
  margin: 0;
  color: var(--paper);
  font-size: clamp(3.2rem, 7vw, 6.4rem);
  font-weight: 800;
  line-height: 1.02;
}

.login-copy > p:not(.login-eyebrow):not(.login-note) {
  max-width: 560px;
  margin: 26px 0 0;
  color: rgba(219, 219, 219, 0.58);
  font-size: 1rem;
  line-height: 1.85;
}

.google-auth-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-width: 220px;
  min-height: 48px;
  margin-top: 34px;
  padding: 0 22px;
  border: 0;
  border-radius: 999px;
  background: var(--gold);
  color: #fff;
  font: inherit;
  font-size: 0.92rem;
  font-weight: 700;
  cursor: pointer;
}

.google-auth-button:hover:not(:disabled) {
  background: #d08a39;
}

.google-auth-button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.google-mark {
  width: 20px;
  height: 20px;
  padding: 2px;
  border-radius: 50%;
  background: #fff;
}

.login-note {
  margin: 14px 0 0;
  color: rgba(150, 156, 166, 0.64);
  font-size: 0.74rem;
  line-height: 1.6;
}

.login-error {
  max-width: 520px;
  margin-top: 18px;
  color: var(--danger);
  font-size: 0.82rem;
  line-height: 1.6;
}

.login-aside {
  align-self: end;
  padding-bottom: 18px;
}

.login-aside__line {
  width: 42px;
  height: 1px;
  margin-bottom: 22px;
  background: var(--gold);
}

.login-aside p,
.login-aside span {
  margin: 0;
  color: var(--muted);
  font-size: 0.8rem;
}

.login-aside strong {
  display: block;
  margin: 12px 0 10px;
  color: var(--paper);
  font-size: clamp(1.6rem, 3vw, 2.5rem);
  line-height: 1.15;
}

/* ===== Hero ===== */
.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(280px, 0.9fr);
  gap: clamp(28px, 6vw, 96px);
  align-items: end;
  min-height: clamp(520px, 68vh, 760px);
  margin-bottom: 36px;
  padding: 54px 0 72px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.hero-copy {
  max-width: 720px;
}

.hero-ornament {
  color: rgba(219, 219, 219, 0.46);
  letter-spacing: 0;
  margin-bottom: 18px;
  font-family: var(--font-body);
  font-size: 0.86rem;
  font-weight: 600;
}

.hero h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(4rem, 8.6vw, 7.6rem);
  font-weight: 800;
  letter-spacing: 0;
  line-height: 0.98;
  color: var(--paper);
  text-shadow: none;
}

.subtitle {
  margin: 16px 0 0;
  color: rgba(219, 219, 219, 0.42);
  font-size: clamp(1.8rem, 3.8vw, 3.6rem);
  font-weight: 800;
  line-height: 1.05;
}

.intro {
  margin: 28px 0 0;
  max-width: 620px;
  color: rgba(219, 219, 219, 0.62);
  line-height: 1.9;
  font-size: 1.05rem;
}

.first-use-tip {
  max-width: 620px;
  margin: 18px 0 0;
  color: rgba(231, 214, 189, 0.9);
  line-height: 1.7;
  font-size: 0.98rem;
  font-weight: 600;
}

.disclaimer {
  max-width: 620px;
  margin: 12px 0 0;
  color: rgba(150, 156, 166, 0.78);
  line-height: 1.7;
  font-size: 0.92rem;
}

.hero-insight {
  justify-self: end;
  width: min(100%, 420px);
  min-height: 260px;
  display: block;
}

.hero-insight__rule {
  display: none;
}

.hero-insight__content {
  display: grid;
  align-content: end;
  gap: 12px;
  min-height: 260px;
  padding: 34px 0;
}

.hero-insight__content span,
.hero-insight__content small {
  color: var(--muted);
  line-height: 1.5;
}

.hero-insight__content strong {
  color: var(--paper);
  font-family: var(--font-display);
  font-size: clamp(2rem, 4vw, 3rem);
  font-weight: 800;
  line-height: 1.05;
}

/* ===== Social proof ===== */
.social-proof {
  margin: 16px 0 0;
  padding: 8px 20px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--gold-soft);
  font-size: 0.92rem;
}

.social-proof[hidden] {
  display: none !important;
}

.proof-icon {
  color: var(--gold);
  font-size: 1.1rem;
}

.social-proof strong {
  color: var(--gold);
  font-size: 1.05rem;
}

/* ===== Guide collapse ===== */
.guide-collapse {
  margin-bottom: 18px;
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.04);
  overflow: hidden;
}

.guide-toggle {
  display: block;
  padding: 14px 16px;
  cursor: pointer;
  color: var(--gold-soft);
  font-weight: 600;
  font-size: 0.95rem;
  list-style: none;
  user-select: none;
}

.guide-toggle::-webkit-details-marker {
  display: none;
}

.guide-body {
  padding: 0 16px 16px;
}

.guide-body ol {
  margin: 0;
  padding-left: 1.25rem;
  color: var(--muted);
  line-height: 1.75;
  font-size: 0.92rem;
}

.guide-body strong {
  color: var(--gold);
  font-weight: 700;
}

/* ===== Layout ===== */
.content-grid {
  display: grid;
  grid-template-columns: minmax(320px, 460px) minmax(320px, 1fr);
  gap: 20px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 24px;
  padding: 24px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.panel h2 {
  margin: 0 0 18px;
  color: var(--paper);
  font-size: 1.55rem;
}

/* ===== Fields ===== */
.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
}

.auth-panel,
.session-panel {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.auth-panel[hidden],
.session-panel[hidden],
[hidden] {
  display: none !important;
}

.auth-card {
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.04);
  border-radius: 18px;
  padding: 16px;
}

.auth-card h2 {
  margin: 0 0 12px;
}

.access-copy {
  margin: 0 0 14px;
  color: var(--muted);
  line-height: 1.7;
}

.field span,
.meta-label,
.result-card h3 {
  color: var(--gold);
}

.tier-selector {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.tier-button {
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.09);
  background: rgba(255, 255, 255, 0.04);
  color: var(--gold-soft);
  padding: 12px 14px;
  cursor: pointer;
  font: inherit;
  font-weight: 600;
}

.tier-button[hidden] {
  display: none;
}

.tier-button--active {
  border-color: rgba(196, 127, 49, 0.7);
  background: rgba(196, 127, 49, 0.18);
  color: #fff;
}

.tier-hint {
  margin: 10px 0 0;
  color: var(--muted);
  line-height: 1.6;
  font-size: 0.92rem;
}

textarea,
input,
select,
.submit-button,
.secondary-button {
  width: 100%;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  padding: 14px 14px;
  font: inherit;
  transition: border-color 0.2s, box-shadow 0.2s;
}

textarea {
  border-radius: 18px;
  resize: vertical;
}

textarea::placeholder {
  color: rgba(150, 156, 166, 0.72);
}

textarea:focus,
input:focus,
select:focus {
  outline: 1px solid rgba(196, 127, 49, 0.65);
  border-color: rgba(196, 127, 49, 0.65);
  box-shadow: 0 0 0 4px rgba(196, 127, 49, 0.12);
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

/* ===== Cards ===== */
.note-block,
.result-card,
.status-box,
.empty-state,
.error-box {
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.04);
  border-radius: 18px;
  padding: 16px 14px;
}

.note-block {
  margin-bottom: 16px;
}

.note-block h3 {
  margin: 0 0 12px;
  color: var(--gold-soft);
}

.note-block ol {
  margin: 0;
  padding-left: 1.2rem;
  color: var(--muted);
  line-height: 1.7;
}

/* ===== Buttons ===== */
.submit-button {
  cursor: pointer;
  background: var(--gold);
  color: #ffffff;
  font-weight: 700;
  transition: opacity 0.2s, transform 0.15s;
}

.submit-button:hover:not([disabled]) {
  opacity: 0.9;
  transform: translateY(-1px);
}

.submit-button:active:not([disabled]) {
  transform: translateY(0);
}

.secondary-button {
  cursor: pointer;
  background: rgba(255, 255, 255, 0.05);
  color: var(--paper);
  font-weight: 600;
  transition: background 0.2s;
}

.secondary-button:hover:not([disabled]) {
  background: rgba(255, 255, 255, 0.08);
}

.submit-button[disabled] {
  cursor: wait;
  opacity: 0.7;
}

.secondary-button[disabled] {
  cursor: wait;
  opacity: 0.7;
}

.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.05);
  color: var(--gold-soft);
  font: inherit;
  font-size: 1.15rem;
  line-height: 1;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, transform 0.15s;
}

.icon-button:hover:not([disabled]) {
  background: rgba(196, 127, 49, 0.14);
  border-color: rgba(196, 127, 49, 0.45);
  transform: translateY(-1px);
}

.icon-button[disabled] {
  cursor: default;
  opacity: 0.45;
}

.icon-button svg {
  width: 20px;
  height: 20px;
  display: block;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon-button .button-feedback {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  line-height: 1;
}

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

/* ===== Error / Status ===== */
.error-box {
  margin-bottom: 14px;
  color: var(--danger);
}

.result-panel {
  min-height: 640px;
}

.status-box,
.empty-state {
  color: var(--muted);
}

/* ===== Results ===== */
.result-card + .result-card {
  margin-top: 14px;
}

.result-card--summary {
  position: relative;
  padding-top: 62px;
}

.result-actions {
  position: absolute;
  top: 14px;
  right: 14px;
  display: flex;
  gap: 8px;
}

.result-card h3 {
  margin-top: 0;
  margin-bottom: 10px;
}

.meta-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}

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

.meta-value {
  margin-top: 6px;
  line-height: 1.6;
}

.warning-list {
  margin: 0;
  padding-left: 1.2rem;
  color: var(--muted);
  line-height: 1.7;
}

/* ===== Result text typography ===== */
.result-text {
  line-height: 1.85;
  letter-spacing: 0.02em;
  color: var(--text);
}

.classical-quote {
  margin: 0;
  padding: 14px 18px;
  border-left: 3px solid var(--gold);
  background: rgba(196, 127, 49, 0.06);
  border-radius: 0 12px 12px 0;
  line-height: 1.9;
  font-size: 1.05rem;
  color: var(--gold-soft);
  font-style: italic;
}

.result-card--classical {
  border-color: rgba(196, 127, 49, 0.25);
  background: rgba(196, 127, 49, 0.04);
}

.result-card--deep {
  border-color: rgba(196, 127, 49, 0.28);
  background: rgba(196, 127, 49, 0.06);
}

.result-card--deep h3 {
  color: var(--accent);
}

.deep-upgrade-actions {
  grid-template-columns: 1fr;
}

.deep-upgrade-actions .submit-button {
  min-height: 56px;
  font-size: 1.04rem;
}

.result-card--streaming {
  border-color: rgba(196, 127, 49, 0.22);
  background: rgba(196, 127, 49, 0.05);
}

.stream-status {
  margin-bottom: 10px;
  color: var(--gold-soft);
  font-size: 0.92rem;
}

.stream-text {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.8;
  color: var(--text);
  font-family: var(--font-data);
  font-size: 0.92rem;
}

/* ===== Hexagram visualization ===== */
.hexagram-visual {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 24px;
  padding: 18px 0;
  margin-bottom: 14px;
  position: relative;
}

.hex-column {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.hex-label {
  color: var(--muted);
  font-size: 0.85rem;
}

.hex-symbol {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  min-height: 100px;
}

.hex-name {
  color: var(--gold-soft);
  font-size: 0.95rem;
  margin-top: 6px;
}

.hex-arrow {
  color: var(--gold);
  font-size: 1.8rem;
  font-weight: 300;
  margin-bottom: 20px;
}

.hex-moving-badge {
  position: absolute;
  bottom: 4px;
  right: 8px;
  padding: 3px 10px;
  border-radius: 999px;
  background: rgba(196, 127, 49, 0.14);
  color: var(--gold);
  font-size: 0.82rem;
}

/* Yao lines */
.yao-line {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  height: 13px;
  margin-bottom: 3px;
  position: relative;
}

.yao-bar {
  height: 5px;
  border-radius: 2px;
}

.yao-bar-solid {
  width: 52px;
  background: var(--gold-soft);
}

.yao-bar-left,
.yao-bar-right {
  width: 20px;
  background: var(--gold-soft);
}

.yao-bar-gap {
  width: 12px;
}

.yao-moving .yao-bar-solid,
.yao-moving .yao-bar-left,
.yao-moving .yao-bar-right {
  background: var(--accent);
  box-shadow: 0 0 10px rgba(196, 127, 49, 0.35);
}

.yao-dot {
  position: absolute;
  right: -20px;
  color: var(--accent);
  font-size: 0.7rem;
}

/* ===== Deep upgrade CTA ===== */
.deep-upgrade-cta {
  border-color: rgba(196, 127, 49, 0.28);
  background:
    linear-gradient(180deg, rgba(196, 127, 49, 0.12), rgba(255, 255, 255, 0.04));
  text-align: center;
  padding: 22px 18px;
}

.upgrade-icon {
  font-size: 2rem;
  margin-bottom: 8px;
}

.deep-upgrade-cta h3 {
  color: var(--accent);
  margin-bottom: 10px;
}

.upgrade-desc {
  color: var(--muted);
  line-height: 1.7;
  margin-bottom: 12px;
}

.upgrade-desc strong {
  color: var(--gold-soft);
}

.upgrade-action {
  color: var(--gold);
  font-weight: 600;
  font-size: 1.02rem;
}

.upgrade-action strong {
  color: var(--gold-soft);
}

.catalog-list {
  display: grid;
  gap: 10px;
}

.catalog-item {
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 16px;
  padding: 14px;
  background: rgba(255, 255, 255, 0.04);
}

.catalog-item h4 {
  margin: 0 0 8px;
  color: var(--gold-soft);
}

.catalog-item p {
  margin: 0 0 12px;
  color: var(--muted);
  line-height: 1.6;
}

.catalog-item__meta {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
}

.bind-modal {
  position: fixed;
  inset: 0;
  z-index: 50;
}

.bind-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(6px);
}

.bind-modal__dialog {
  position: relative;
  width: min(92vw, 420px);
  margin: 8vh auto 0;
  padding: 22px 18px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 20px;
  background: rgba(18, 18, 18, 0.98);
  box-shadow: var(--shadow);
}

.bind-modal__dialog h2 {
  margin: 0 0 10px;
  color: var(--gold-soft);
}

.bind-modal__close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--gold-soft);
  font-size: 1.4rem;
  cursor: pointer;
}

.milk-tea-qr-frame {
  display: flex;
  justify-content: center;
  margin: 16px 0;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 16px;
  background: #fff;
}

.milk-tea-qr {
  width: min(64vw, 260px);
  aspect-ratio: 1;
  object-fit: contain;
  display: block;
}

.milk-tea-packages {
  display: grid;
  gap: 10px;
  margin: 14px 0 12px;
}

.milk-tea-package {
  display: grid;
  gap: 4px;
  width: 100%;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.milk-tea-package strong {
  color: var(--gold-soft);
  font-size: 1.08rem;
}

.milk-tea-package span {
  color: var(--muted);
}

.milk-tea-package__name {
  color: var(--gold);
  font-weight: 700;
}

.milk-tea-package.is-selected {
  border-color: rgba(196, 127, 49, 0.72);
  background: rgba(196, 127, 49, 0.16);
}

.milk-tea-quota,
.ai-chat-quota {
  color: var(--gold);
  line-height: 1.6;
  font-size: 0.92rem;
  font-weight: 600;
}

/* ===== History ===== */
.history-card {
  margin-top: 18px;
}

.history-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.history-card-header h3 {
  margin: 0;
}

.history-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.history-item {
  padding: 10px 0;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--muted);
  line-height: 1.6;
  font-size: 0.9rem;
}

.history-item:first-child {
  border-top: 0;
  padding-top: 0;
}

/* ===== CTA Footer ===== */
.cta-footer {
  margin-top: 24px;
  padding: 20px 18px;
  border: 1px solid rgba(196, 127, 49, 0.26);
  border-radius: 24px;
  background:
    linear-gradient(180deg, rgba(196, 127, 49, 0.1), rgba(255, 255, 255, 0.04));
  text-align: center;
  box-shadow: var(--shadow);
}

.cta-inner {
  max-width: 600px;
  margin: 0 auto;
}

.cta-text {
  margin: 0;
  color: var(--gold-soft);
  line-height: 1.8;
  font-size: 1.05rem;
}

.cta-text strong {
  color: var(--gold);
}

/* ===== Responsive ===== */
@media (max-width: 900px) {
  .login-main {
    grid-template-columns: 1fr;
    align-items: end;
    gap: 54px;
  }

  .login-aside {
    max-width: 360px;
  }

  .hero {
    grid-template-columns: 1fr;
    min-height: auto;
    gap: 24px;
    padding: 42px 0 52px;
  }

  .hero-insight {
    justify-self: stretch;
    width: 100%;
    min-height: 150px;
  }

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

  .hexagram-visual {
    gap: 16px;
  }
}

@media (max-width: 640px) {
  .app-shell {
    padding: 0 10px 28px;
    padding-bottom: calc(28px + env(safe-area-inset-bottom, 0px));
  }

  .topbar {
    top: 0;
    gap: 10px;
    min-height: 58px;
    padding: 9px 10px;
  }

  .topbar-actions {
    flex: 0 1 auto;
    gap: 8px;
  }

  .language-switcher--icon {
    width: 36px;
  }

  .account-chip {
    min-height: 36px;
    padding: 2px;
  }

  .account-popover {
    right: 0;
  }

  .hero {
    margin-bottom: 22px;
    padding: 34px 0 34px;
  }

  .hero h1 {
    font-size: clamp(2.45rem, 16vw, 4rem);
  }

  .subtitle {
    font-size: clamp(1.45rem, 8vw, 2.4rem);
  }

  .hero-insight {
    min-height: 126px;
  }

  .hero-insight__content {
    padding: 18px 0;
    min-height: 150px;
  }

  .login-view {
    padding: 0 20px;
  }

  .login-topbar {
    min-height: 58px;
  }

  .login-main {
    min-height: calc(100svh - 58px);
    gap: 44px;
    padding: 64px 0 48px;
  }

  .login-copy h1 {
    font-size: clamp(2.7rem, 12vw, 3.2rem);
  }

  .google-auth-button {
    width: 100%;
  }

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

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

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

  .cta-footer {
    border-radius: 18px;
    padding: 16px 14px;
  }

  .hexagram-visual {
    gap: 12px;
    padding: 14px 0;
  }

  .yao-bar-solid {
    width: 40px;
  }

  .yao-bar-left,
  .yao-bar-right {
    width: 16px;
  }

  .yao-bar-gap {
    width: 8px;
  }

  .hex-arrow {
    font-size: 1.4rem;
  }

  .classical-quote {
    padding: 12px 14px;
    font-size: 1rem;
  }

  .ai-chat-input-row {
    flex-direction: column;
  }

  .ai-chat-send {
    width: 100% !important;
  }
}

/* ===== AI Chat ===== */
.ai-chat-section h3 {
  color: var(--accent);
}

.ai-chat-hint {
  color: var(--muted);
  font-size: 0.9rem;
  margin-bottom: 14px;
  line-height: 1.6;
}

.ai-chat-messages {
  max-height: 400px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 14px;
  min-height: 0;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.ai-chat-messages::-webkit-scrollbar {
  width: 0;
  height: 0;
}

.chat-bubble {
  padding: 10px 14px;
  border-radius: 14px;
  line-height: 1.7;
  font-size: 0.94rem;
  max-width: 85%;
  white-space: pre-wrap;
  word-break: break-word;
}

.chat-user {
  align-self: flex-end;
  background: rgba(196, 127, 49, 0.16);
  border: 1px solid rgba(196, 127, 49, 0.32);
  color: var(--gold-soft);
}

.chat-assistant {
  align-self: flex-start;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text);
}

.ai-chat-input-row {
  display: flex;
  gap: 10px;
  align-items: flex-end;
}

.ai-chat-input {
  flex: 1;
  resize: none;
}

.ai-chat-send {
  width: 80px;
  flex-shrink: 0;
  padding: 14px 10px;
}

/* ===== Rice-paper visual system ===== */
html,
body {
  background-color: var(--bg);
  background-image:
    linear-gradient(180deg, rgba(243, 236, 224, 0.68), rgba(243, 236, 224, 0.86)),
    url("/ink-mountains.webp");
  background-position: center top, center top;
  background-size: cover, cover;
  background-repeat: no-repeat, no-repeat;
  background-attachment: fixed, fixed;
  color: var(--text);
}

body {
  overflow-x: hidden;
}

.app-shell {
  max-width: 1120px;
  padding: 0 24px 56px;
}

.topbar {
  min-height: 64px;
  padding: 10px max(24px, calc((100vw - 1072px) / 2));
  border-bottom: 1px solid rgba(117, 91, 61, 0.18);
  background: rgba(243, 236, 224, 0.88);
  box-shadow: none;
}

.brand-lockup {
  gap: 11px;
}

.brand-seal,
.section-seal,
.footer-seal,
.upgrade-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--accent);
  border-radius: 5px;
  color: var(--accent);
  font-family: var(--font-display);
  line-height: 1;
  box-shadow: inset 0 0 0 1px rgba(180, 58, 36, 0.22);
}

.brand-seal {
  width: 34px;
  height: 34px;
  font-size: 1rem;
}

.brand-copy {
  display: grid;
  gap: 2px;
}

.brand-name {
  color: var(--text);
  font-size: 1rem;
  font-weight: 700;
}

.brand-subtitle {
  color: var(--muted);
  font-size: 0.64rem;
  line-height: 1.2;
}

.topbar-login-button,
.language-switcher {
  color: var(--muted);
}

.topbar-login-button {
  border-color: rgba(180, 58, 36, 0.52);
  background: rgba(250, 246, 238, 0.56);
  color: var(--accent);
}

.topbar-login-button:hover:not(:disabled),
.topbar-login-button:focus-visible,
.language-switcher:hover,
.language-switcher:focus-within {
  color: var(--accent);
}

.topbar-login-button:hover:not(:disabled),
.topbar-login-button:focus-visible {
  border-color: var(--accent);
  background: rgba(180, 58, 36, 0.08);
}

.account-avatar {
  border-color: rgba(80, 58, 35, 0.14);
  font-family: ui-sans-serif, system-ui, sans-serif;
}

.account-popover {
  border-color: var(--panel-border);
  border-radius: 8px;
  background: rgba(250, 246, 238, 0.98);
  box-shadow: var(--shadow);
}

.account-popover__header {
  border-bottom-color: rgba(117, 91, 61, 0.16);
}

.account-popover__name,
.account-quota .meta-value {
  color: var(--text);
}

.account-popover__email {
  color: var(--muted);
}

.login-view {
  position: relative;
  min-height: 100vh;
  min-height: 100svh;
  padding: 0 max(24px, calc((100vw - 1080px) / 2));
  background:
    linear-gradient(180deg, rgba(243, 236, 224, 0.28), rgba(243, 236, 224, 0.76) 58%, var(--bg) 100%),
    url("/ink-mountains.webp") center 38% / cover no-repeat;
}

.login-topbar {
  border-bottom-color: rgba(117, 91, 61, 0.16);
}

.login-main {
  grid-template-columns: minmax(0, 760px);
  justify-content: center;
  align-items: center;
  min-height: calc(100svh - 64px);
  padding: 72px 0 96px;
  text-align: center;
}

.login-copy {
  max-width: 720px;
}

.login-trigrams {
  margin-bottom: 22px;
  color: rgba(56, 47, 39, 0.5);
}

.login-eyebrow {
  margin-bottom: 18px;
  color: var(--accent);
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0;
}

.login-copy h1 {
  max-width: none;
  color: var(--text);
  font-size: clamp(2.65rem, 5.5vw, 4.6rem);
  font-weight: 600;
  line-height: 1.15;
}

.login-copy > p:not(.login-eyebrow):not(.login-note) {
  max-width: 600px;
  margin: 24px auto 0;
  color: var(--muted);
  font-size: 1rem;
  line-height: 2;
}

.google-auth-button {
  min-width: 230px;
  min-height: 48px;
  margin-top: 30px;
  border-radius: 6px;
  background: var(--accent);
  box-shadow: 0 7px 18px rgba(180, 58, 36, 0.16);
}

.google-auth-button:hover:not(:disabled) {
  background: #9f301f;
}

.login-note {
  color: rgba(85, 73, 62, 0.72);
}

.login-error {
  margin-right: auto;
  margin-left: auto;
}

.login-aside {
  display: none;
}

.hero {
  position: relative;
  display: block;
  width: 100vw;
  min-height: 0;
  margin: 0 0 72px calc(50% - 50vw);
  padding: 64px max(24px, calc((100vw - 1072px) / 2)) 52px;
  overflow: hidden;
  border-bottom: 1px solid rgba(117, 91, 61, 0.16);
  background:
    linear-gradient(180deg, rgba(243, 236, 224, 0.25), rgba(243, 236, 224, 0.7) 68%, var(--bg) 100%),
    url("/ink-mountains.webp") center 48% / cover no-repeat;
  text-align: center;
}

.hero-copy {
  max-width: 760px;
  margin: 0 auto;
}

.hero-ornament {
  margin-bottom: 20px;
  color: rgba(70, 56, 43, 0.5);
  font-size: 0.8rem;
  font-weight: 400;
}

.hero h1 {
  color: var(--text);
  font-size: clamp(2.8rem, 5vw, 4.8rem);
  font-weight: 600;
  line-height: 1.08;
}

.subtitle {
  margin-top: 15px;
  color: var(--accent);
  font-size: clamp(1.15rem, 2.4vw, 1.7rem);
  font-weight: 600;
  line-height: 1.35;
}

.intro {
  max-width: 690px;
  margin: 24px auto 0;
  color: var(--muted);
  font-size: 1rem;
  line-height: 2;
}

.first-use-tip {
  max-width: 680px;
  margin: 17px auto 0;
  color: var(--gold-soft);
  font-size: 0.9rem;
}

.disclaimer {
  max-width: 680px;
  margin: 8px auto 0;
  color: rgba(84, 74, 64, 0.66);
  font-size: 0.8rem;
}

.hero-insight {
  display: none;
}

.social-proof {
  margin-top: 18px;
  padding: 7px 14px;
  border-color: rgba(162, 120, 63, 0.3);
  border-radius: 999px;
  background: rgba(250, 246, 238, 0.62);
  color: var(--gold-soft);
}

.content-grid {
  grid-template-columns: minmax(0, 1fr);
  gap: 64px;
  max-width: 860px;
  margin: 0 auto;
}

.panel {
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 8px 24px rgba(78, 58, 36, 0.07);
  backdrop-filter: blur(5px);
}

.form-panel {
  padding: clamp(24px, 5vw, 48px);
}

.casting-steps {
  max-width: 680px;
  margin: 0 auto 24px;
  padding: 18px 20px;
  border-left: 2px solid rgba(162, 120, 63, 0.36);
  background: rgba(234, 223, 206, 0.24);
}

.casting-steps h3 {
  margin: 0;
  text-align: left;
  color: var(--gold-soft);
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.casting-steps ol {
  display: grid;
  gap: 9px;
  margin: 14px 0 0;
  padding: 0;
  list-style: none;
  counter-reset: casting-step;
}

.casting-steps li {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr);
  gap: 9px;
  align-items: start;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.75;
  counter-increment: casting-step;
}

.casting-steps li::before {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  margin-top: 3px;
  border: 1px solid rgba(180, 58, 36, 0.42);
  border-radius: 50%;
  color: var(--accent);
  font-family: var(--font-data);
  font-size: 0.72rem;
  line-height: 1;
  content: counter(casting-step);
}

.panel h2 {
  color: var(--text);
  font-size: clamp(1.65rem, 3vw, 2.2rem);
  font-weight: 600;
  text-align: center;
}

.guide-collapse {
  margin: 0 0 28px;
  border-color: rgba(117, 91, 61, 0.18);
  border-radius: 6px;
  background: rgba(234, 223, 206, 0.36);
}

.guide-toggle {
  padding: 13px 16px;
  color: var(--gold-soft);
  font-size: 0.9rem;
}

.guide-body ol {
  color: var(--muted);
}

.guide-body strong {
  color: var(--accent);
}

.field {
  gap: 9px;
  margin-bottom: 20px;
}

.field > span,
.meta-label,
.result-card h3 {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 600;
}

textarea,
input,
select,
.submit-button,
.secondary-button {
  border: 1px solid var(--panel-border);
  border-radius: 6px;
  background: rgba(255, 252, 247, 0.7);
  color: var(--text);
}

textarea {
  min-height: 116px;
  border-radius: 6px;
  text-align: center;
  line-height: 1.8;
}

textarea::placeholder {
  color: rgba(92, 81, 70, 0.58);
}

textarea:focus,
input:focus,
select:focus {
  outline: 1px solid rgba(180, 58, 36, 0.4);
  border-color: rgba(180, 58, 36, 0.6);
  box-shadow: 0 0 0 3px rgba(180, 58, 36, 0.08);
}

.grid-3 {
  gap: 10px;
}

.grid-3 .field {
  margin-bottom: 20px;
  padding: 14px;
  border: 1px solid rgba(117, 91, 61, 0.16);
  border-radius: 7px;
  background: rgba(247, 240, 229, 0.5);
}

.grid-3 .field > span {
  color: var(--accent);
  text-align: center;
}

.grid-3 select {
  padding: 11px 8px;
  background: rgba(255, 252, 247, 0.78);
  text-align: center;
}

.tier-selector {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.tier-button {
  border-color: rgba(117, 91, 61, 0.18);
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
}

.tier-button--active {
  border-color: rgba(180, 58, 36, 0.48);
  background: rgba(180, 58, 36, 0.08);
  color: var(--accent);
}

.tier-hint {
  color: var(--muted);
  text-align: center;
}

.submit-button {
  min-height: 48px;
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
  box-shadow: 0 7px 18px rgba(180, 58, 36, 0.14);
}

.submit-button:hover:not([disabled]) {
  background: #9f301f;
  opacity: 1;
}

.secondary-button {
  background: rgba(255, 252, 247, 0.55);
  color: var(--text);
}

.secondary-button:hover:not([disabled]) {
  background: var(--bg-soft);
}

.icon-button {
  border-color: rgba(117, 91, 61, 0.18);
  background: rgba(255, 252, 247, 0.58);
  color: var(--accent);
}

.icon-button:hover:not([disabled]) {
  border-color: rgba(180, 58, 36, 0.4);
  background: rgba(180, 58, 36, 0.07);
}

.note-block,
.result-card,
.status-box,
.empty-state,
.error-box {
  border-color: rgba(117, 91, 61, 0.18);
  border-radius: 8px;
  background: rgba(250, 246, 238, 0.72);
}

.error-box {
  background: rgba(167, 47, 32, 0.06);
}

.result-panel {
  min-height: 0;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
  backdrop-filter: none;
}

.result-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 24px;
  padding-bottom: 18px;
  border-bottom: 1px solid rgba(117, 91, 61, 0.2);
}

.result-panel-header > div {
  display: flex;
  align-items: center;
  gap: 12px;
}

.result-panel-header h2 {
  margin: 0;
  text-align: left;
}

.section-seal {
  width: 34px;
  height: 34px;
  font-size: 0.95rem;
}

.reset-cast-button {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  width: auto;
  min-height: 40px;
  padding: 9px 14px;
}

.reset-cast-button svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.result-card {
  padding: 22px;
}

.result-card + .result-card {
  margin-top: 12px;
}

.result-card--summary {
  padding-top: 64px;
  border-color: rgba(180, 58, 36, 0.24);
  background: rgba(250, 246, 238, 0.86);
}

.meta-label {
  color: var(--muted);
}

.meta-value,
.result-text {
  color: var(--text);
}

.meta-grid {
  gap: 10px;
  padding-top: 16px;
  border-top: 1px solid rgba(117, 91, 61, 0.14);
}

.hexagram-visual {
  gap: clamp(28px, 8vw, 72px);
  margin: 12px 0 18px;
  padding: 24px 0 32px;
}

.hex-label {
  color: var(--muted);
}

.hex-name {
  color: var(--text);
  font-size: 1.05rem;
}

.hex-arrow {
  color: var(--gold);
}

.hex-moving-badge {
  right: 50%;
  bottom: 0;
  transform: translateX(50%);
  border: 1px solid rgba(180, 58, 36, 0.2);
  background: rgba(180, 58, 36, 0.06);
  color: var(--accent);
}

.yao-bar-solid,
.yao-bar-left,
.yao-bar-right {
  background: var(--text);
}

.yao-moving .yao-bar-solid,
.yao-moving .yao-bar-left,
.yao-moving .yao-bar-right {
  background: var(--accent);
  box-shadow: none;
}

.yao-dot {
  color: var(--accent);
}

.classical-quote {
  padding: 18px 22px;
  border-left-color: var(--accent);
  border-radius: 0 6px 6px 0;
  background: rgba(180, 58, 36, 0.045);
  color: var(--text);
  font-size: 1.08rem;
  font-style: normal;
}

.result-card--classical {
  border-color: rgba(180, 58, 36, 0.2);
  background: rgba(250, 246, 238, 0.76);
}

.result-card--deep,
.result-card--streaming {
  border-color: rgba(162, 120, 63, 0.26);
  background: rgba(234, 223, 206, 0.34);
}

.stream-status {
  color: var(--gold-soft);
}

.stream-text {
  color: var(--text);
}

.deep-upgrade-cta {
  padding: 28px 22px;
  border-color: rgba(180, 58, 36, 0.24);
  background: linear-gradient(180deg, rgba(180, 58, 36, 0.07), rgba(250, 246, 238, 0.8));
}

.upgrade-icon {
  width: 38px;
  height: 38px;
  margin: 0 auto 12px;
  font-size: 0.9rem;
}

.deep-upgrade-cta h3,
.result-card--deep h3,
.ai-chat-section h3 {
  color: var(--accent);
}

.upgrade-action,
.milk-tea-quota,
.ai-chat-quota {
  color: var(--accent);
}

.catalog-item,
.milk-tea-package {
  border-color: rgba(117, 91, 61, 0.18);
  border-radius: 7px;
  background: rgba(255, 252, 247, 0.56);
}

.catalog-item h4,
.milk-tea-package strong {
  color: var(--text);
}

.milk-tea-package.is-selected {
  border-color: rgba(180, 58, 36, 0.52);
  background: rgba(180, 58, 36, 0.07);
}

.bind-modal__backdrop {
  background: rgba(51, 42, 34, 0.42);
  backdrop-filter: blur(5px);
}

.bind-modal__dialog {
  border-color: var(--panel-border);
  border-radius: 8px;
  background: #f8f1e6;
  box-shadow: 0 24px 70px rgba(53, 40, 28, 0.2);
}

.bind-modal__dialog h2 {
  color: var(--text);
}

.bind-modal__close {
  border-radius: 50%;
  background: rgba(117, 91, 61, 0.08);
  color: var(--text);
}

.milk-tea-qr-frame {
  border-color: rgba(117, 91, 61, 0.18);
  border-radius: 8px;
}

.history-card {
  margin-top: 28px;
  background: rgba(247, 240, 229, 0.46);
}

.history-item {
  border-top-color: rgba(117, 91, 61, 0.16);
}

.cta-footer {
  margin: 72px calc(50% - 50vw) -56px;
  padding: 36px 24px 42px;
  border: 0;
  border-top: 1px solid rgba(117, 91, 61, 0.18);
  border-radius: 0;
  background: rgba(234, 223, 206, 0.38);
  box-shadow: none;
}

.cta-inner {
  display: grid;
  justify-items: center;
  gap: 12px;
}

.footer-seal {
  width: 32px;
  height: 32px;
  font-size: 0.88rem;
}

.cta-text {
  color: var(--muted);
  font-size: 0.9rem;
}

.chat-bubble {
  border-radius: 7px;
}

.chat-user {
  border-color: rgba(180, 58, 36, 0.24);
  background: rgba(180, 58, 36, 0.07);
  color: var(--text);
}

.chat-assistant {
  border-color: rgba(117, 91, 61, 0.16);
  background: rgba(255, 252, 247, 0.6);
  color: var(--text);
}

button:focus-visible,
a:focus-visible,
summary:focus-visible,
select:focus-visible,
textarea:focus-visible,
input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.grid-3 .field {
  position: relative;
  padding-top: 38px;
}

.grid-3 .number-seal {
  position: absolute;
  top: 10px;
  left: 50%;
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  transform: translateX(-50%);
  border: 1px solid rgba(180, 58, 36, 0.62);
  border-radius: 4px;
  color: var(--accent);
  font-size: 0.68rem;
  line-height: 1;
}

#result-view {
  overflow: hidden;
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  background: rgba(250, 246, 238, 0.76);
  color: #28221d;
  font-size: 1.04rem;
  box-shadow: 0 10px 28px rgba(78, 58, 36, 0.07);
}

#result-view .result-card h3 {
  color: #43382e;
  font-size: 1.06rem;
  line-height: 1.45;
}

#result-view .meta-label,
#result-view .hex-label {
  color: #5d5146;
  font-size: 0.9rem;
}

#result-view .meta-value {
  color: #28221d;
  font-size: 1.02rem;
  font-weight: 600;
  line-height: 1.65;
}

#result-view .result-text {
  color: #28221d;
  font-size: 1.08rem;
  line-height: 1.95;
}

#result-view .classical-quote {
  color: #28221d;
  font-size: 1.16rem;
  line-height: 1.9;
}

#result-view .deep-section p {
  color: #28221d;
  font-size: 1.05rem;
  line-height: 1.9;
}

#result-view > .result-card {
  margin: 0;
  padding: 26px clamp(18px, 4vw, 34px);
  border: 0;
  border-top: 1px solid rgba(117, 91, 61, 0.17);
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

#result-view > .result-card:first-child {
  border-top: 0;
}

#result-view > .result-card--summary {
  padding-top: 68px;
}

#result-view > .deep-upgrade-cta {
  background: linear-gradient(180deg, rgba(180, 58, 36, 0.09), rgba(250, 246, 238, 0.82));
}

#result-view > .result-card--streaming {
  background:
    linear-gradient(90deg, transparent, rgba(162, 120, 63, 0.07), transparent),
    rgba(234, 223, 206, 0.26);
  background-size: 220% 100%, auto;
  animation: ink-wash 2.4s ease-in-out infinite;
}

.warning-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding-left: 1.3em;
  color: var(--muted);
  line-height: 1.8;
}

.result-card--warnings h3 {
  color: var(--accent);
}

.deep-section {
  display: grid;
  grid-template-columns: minmax(70px, 0.18fr) minmax(0, 1fr);
  gap: 18px;
  padding: 18px 0;
  border-top: 1px solid rgba(117, 91, 61, 0.14);
}

.deep-section:first-of-type {
  margin-top: 14px;
}

.deep-section h4,
.deep-section p {
  margin: 0;
}

.deep-section h4 {
  color: var(--accent);
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.08em;
}

.deep-section p {
  color: var(--text);
  line-height: 1.9;
  white-space: pre-wrap;
}

.deep-section--risk p {
  color: var(--danger);
}

@keyframes ink-wash {
  0%, 100% { background-position: 110% 0, 0 0; }
  50% { background-position: -110% 0, 0 0; }
}

@media (max-width: 900px) {
  .hero {
    min-height: 0;
    margin-bottom: 48px;
    padding-top: 56px;
    padding-bottom: 46px;
  }

  .content-grid {
    gap: 48px;
  }
}

@media (max-width: 640px) {
  .app-shell {
    padding: 0 14px 40px;
  }

  .topbar {
    min-height: 58px;
    padding: 8px 14px;
  }

  .brand-seal {
    width: 32px;
    height: 32px;
  }

  .brand-subtitle {
    display: none;
  }

  .login-view {
    padding: 0 18px;
    background-position: 45% 34%;
  }

  .login-main {
    min-height: calc(100svh - 58px);
    padding: 54px 0 68px;
  }

  .login-copy h1 {
    font-size: clamp(2.4rem, 12vw, 3.1rem);
  }

  .login-copy > p:not(.login-eyebrow):not(.login-note) {
    font-size: 0.94rem;
    line-height: 1.85;
  }

  .hero {
    min-height: 0;
    margin-bottom: 40px;
    padding: 38px 18px 34px;
    background-position: 46% 38%;
  }

  .hero h1 {
    font-size: clamp(2.5rem, 14vw, 3.5rem);
  }

  .subtitle {
    font-size: 1.2rem;
  }

  .intro {
    font-size: 0.93rem;
    line-height: 1.85;
  }

  .form-panel {
    padding: 22px 16px;
  }

  .panel h2 {
    font-size: 1.6rem;
  }

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

  .grid-3 .field {
    margin-bottom: 0;
  }

  .tier-selector {
    grid-template-columns: 1fr;
  }

  .result-panel-header {
    align-items: flex-start;
  }

  .reset-cast-button {
    width: 40px;
    padding: 9px;
  }

  .reset-cast-button span {
    display: none;
  }

  .result-card {
    padding: 18px 14px;
  }

  #result-view > .result-card {
    padding: 22px 16px;
  }

  #result-view > .result-card--summary {
    padding-top: 58px;
  }

  .deep-section {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .result-card--summary {
    padding-top: 58px;
  }

  .hexagram-visual {
    gap: 18px;
    padding: 18px 0 34px;
  }

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

  .cta-footer {
    margin: 56px -14px -40px;
    padding: 30px 18px calc(32px + env(safe-area-inset-bottom, 0px));
  }
}

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

/* Global interaction loading */
.global-loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at center, rgba(250, 246, 238, 0.76), rgba(238, 226, 207, 0.9)),
    rgba(243, 236, 224, 0.84);
  backdrop-filter: blur(5px);
  cursor: wait;
}

.global-loading-card {
  display: grid;
  justify-items: center;
  gap: 12px;
  min-width: 170px;
  padding: 24px 28px 20px;
  border: 1px solid rgba(117, 91, 61, 0.2);
  border-radius: 8px;
  background: rgba(250, 246, 238, 0.94);
  box-shadow: 0 24px 70px rgba(53, 40, 28, 0.16);
}

.global-loading-bagua {
  width: 120px;
  height: 120px;
  overflow: visible;
  color: var(--text);
}

.global-loading-bagua__orbit {
  transform-origin: 60px 60px;
  animation: global-bagua-spin 2.4s linear infinite;
}

.global-loading-bagua__orbit text {
  fill: var(--text);
  font-family: var(--font-display);
  font-size: 13px;
  text-anchor: middle;
}

.global-loading-bagua__ring {
  fill: none;
  stroke: rgba(162, 120, 63, 0.52);
  stroke-width: 1.25;
  stroke-dasharray: 2 5;
}

.global-loading-bagua__center {
  fill: rgba(180, 58, 36, 0.08);
  stroke: var(--accent);
  stroke-width: 1.5;
}

.global-loading-bagua__seal {
  fill: var(--accent);
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 700;
  text-anchor: middle;
}

.global-loading-card p {
  margin: 0;
  color: var(--text);
  font-size: 0.9rem;
  letter-spacing: 0.18em;
}

.is-operation-loading {
  opacity: 0.7;
  cursor: wait !important;
}

body[aria-busy="true"] button,
body[aria-busy="true"] select,
body[aria-busy="true"] a {
  cursor: wait;
}

@keyframes global-bagua-spin {
  to { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
  .global-loading-bagua__orbit {
    animation: none !important;
    opacity: 0.72;
  }
}

/* Dual-track casting gateway */
.cast-mode-gateway {
  margin: 18px 0 6px;
  padding: 18px;
  border: 1px solid rgba(111, 91, 61, 0.2);
  border-radius: 12px;
  background: rgba(255, 252, 245, 0.58);
  text-align: center;
}

.cast-mode-title {
  margin: 0 0 12px;
  color: var(--ink-700, #4e493f);
  font-weight: 650;
}

.cast-mode-actions {
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}

.cast-mode-actions .submit-button,
.cast-mode-actions .secondary-button {
  width: auto;
  min-width: 150px;
}

.manual-cast-panel {
  margin-top: 16px;
}

.manual-cast-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.text-button {
  padding: 4px 0;
  border: 0;
  border-bottom: 1px solid currentColor;
  background: transparent;
  color: var(--cinnabar, #a23b2d);
  font: inherit;
  font-size: 0.78rem;
  cursor: pointer;
}

.manual-cast-diagram {
  display: block;
  width: min(100%, 620px);
  height: auto;
  margin: 0 auto 12px;
  color: rgba(83, 69, 43, 0.75);
}

cyber-divination {
  margin-top: 16px;
}

.cyber-cast-return {
  display: block;
  margin: 10px auto 0;
}

@media (max-width: 520px) {
  .cast-mode-actions {
    display: grid;
  }

  .cast-mode-actions .submit-button,
  .cast-mode-actions .secondary-button {
    width: 100%;
  }
}
