/* ─── Reset & Variables ─────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #0b0805;
  --bg2:       #150f09;
  --ink:       #d4922a;
  --ink-dim:   #8c6020;
  --ink-soft:  rgba(180,120,40,.18);
  --earth:     #9a3c1e;
  --sky:       #3a6070;
  --text:      #ede0c8;
  --text-dim:  #9a8468;
  --card:      rgba(255,220,150,.03);
  --card-b:    rgba(180,120,40,.18);
  --radius:    3px;
  --font:      'SimSun', 'STSong', 'Songti SC', 'Noto Serif SC', Georgia, serif;
}

html { background-color: var(--bg); }
body {
  height: 100%; font-family: var(--font);
  background-color: var(--bg);
  background-image:
    repeating-linear-gradient(
      174deg,
      transparent 0px, transparent 5px,
      rgba(180,100,20,.04) 5px, rgba(180,100,20,.04) 6px,
      transparent 6px, transparent 14px,
      rgba(0,0,0,.03) 14px, rgba(0,0,0,.03) 15px
    );
  color: var(--text);
  overflow-x: hidden;
}

/* ─── Stars ──────────────────────────────────────────────────────────────── */
#stars { position: fixed; inset: 0; z-index: 0; pointer-events: none; }

/* ─── Phases ─────────────────────────────────────────────────────────────── */
.phase {
  position: relative; z-index: 1; min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  padding: 40px 20px;
}
.hidden { display: none !important; }

/* ─── HERO ───────────────────────────────────────────────────────────────── */
.hero-inner { max-width: 540px; width: 100%; text-align: center; }

.logo-glyph {
  font-size: 58px; line-height: 1; margin-bottom: 18px;
  color: var(--ink);
  text-shadow: 2px 2px 0 rgba(0,0,0,.6), -1px -1px 0 rgba(0,0,0,.3);
  animation: float 4s ease-in-out infinite;
  filter: none;
}
@keyframes float { 0%,100%{transform:translateY(0)} 50%{transform:translateY(-8px)} }

.brand {
  font-size: clamp(34px,8vw,52px); font-weight: 700; letter-spacing:.18em;
  color: var(--ink);
  text-shadow: 3px 3px 0 rgba(0,0,0,.55), 1px 1px 0 rgba(0,0,0,.4);
  margin-bottom: 14px;
}
.tagline {
  font-size: 14px; color: var(--text-dim); line-height: 2.1;
  letter-spacing:.08em; margin-bottom: 44px;
}

/* ─── Upload zone ────────────────────────────────────────────────────────── */
.upload-zone {
  border: none;
  border-radius: var(--radius);
  background-color: var(--bg2);
  background-image:
    repeating-linear-gradient(45deg,  rgba(180,120,40,.07) 0, rgba(180,120,40,.07) 1px, transparent 0, transparent 50%),
    repeating-linear-gradient(-45deg, rgba(180,120,40,.07) 0, rgba(180,120,40,.07) 1px, transparent 0, transparent 50%);
  background-size: 14px 14px;
  box-shadow: inset 0 0 0 1.5px rgba(180,120,40,.22), 0 4px 0 rgba(0,0,0,.45);
  cursor: pointer; transition: box-shadow .25s;
}
.upload-zone:hover {
  box-shadow: inset 0 0 0 1.5px rgba(180,120,40,.55), 0 4px 0 rgba(0,0,0,.5);
}
.upload-zone.drag-over { background-color: rgba(180,120,40,.05); }
.upload-inner { padding: 48px 24px; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.camera-icon { color: var(--ink-dim); transition: color .3s; }
.upload-zone:hover .camera-icon { color: var(--ink); }
.upload-hint { font-size: 16px; color: var(--text); letter-spacing:.06em; }
.upload-sub   { font-size: 12px; color: var(--text-dim); }

/* ─── QUESTION PHASE ─────────────────────────────────────────────────────── */
.question-inner {
  max-width: 800px; width: 100%;
  display: grid; grid-template-columns: 1fr 1fr; gap: 24px; align-items: start;
}

.preview-wrap { position: relative; border-radius: var(--radius); overflow: hidden; aspect-ratio: 4/3; }
.preview-img  { width: 100%; height: 100%; object-fit: cover; display: block; }
.preview-overlay {
  position: absolute; inset: 0; background: rgba(0,0,0,.3);
  display: flex; align-items: flex-start; justify-content: flex-end;
  padding: 12px; opacity: 0; transition: opacity .3s;
}
.preview-wrap:hover .preview-overlay { opacity: 1; }
.change-photo-btn {
  padding: 6px 14px; border-radius: 2px; background: rgba(0,0,0,.7);
  border: none; box-shadow: inset 0 0 0 1px rgba(255,255,255,.18);
  color: var(--text-dim); font-family: var(--font); font-size: 12px; cursor: pointer;
}

.question-panel { display: flex; flex-direction: column; gap: 14px; }
.question-label { font-size: 12px; color: var(--ink-dim); letter-spacing:.15em; }
.question-panel textarea {
  background-color: var(--bg2);
  background-image:
    repeating-linear-gradient(
      180deg,
      transparent 0px, transparent 27px,
      rgba(180,120,40,.06) 27px, rgba(180,120,40,.06) 28px
    );
  border: none; box-shadow: inset 0 0 0 1px var(--card-b);
  border-radius: var(--radius);
  padding: 14px; color: var(--text); font-family: var(--font);
  font-size: 15px; line-height: 1.85; resize: none; outline: none;
  caret-color: var(--ink);
}
.question-panel textarea::placeholder { color: var(--text-dim); }
.char-count { text-align: right; font-size: 11px; color: var(--text-dim); margin-top: -6px; }

.cast-btn {
  padding: 14px; border: none;
  box-shadow: inset 0 0 0 1px var(--ink-dim), 0 3px 0 rgba(0,0,0,.5);
  border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(180,120,40,.16) 0%, rgba(120,80,20,.1) 100%);
  color: var(--ink); font-family: var(--font); font-size: 15px;
  letter-spacing:.22em; cursor: pointer; transition: all .25s;
}
.cast-btn:hover {
  box-shadow: inset 0 0 0 1px var(--ink), 0 3px 0 rgba(0,0,0,.55);
  color: var(--text);
}
.cast-btn:disabled { opacity:.4; cursor:not-allowed; }
.btn-inner { display:flex; align-items:center; justify-content:center; gap:8px; }

/* ─── SCANNING PHASE ─────────────────────────────────────────────────────── */
.scanning-inner {
  max-width: 700px; width: 100%;
  display: flex; flex-direction: column; align-items: center; gap: 28px;
}
.scan-photo-wrap { position: relative; width: 100%; border-radius: var(--radius); overflow: hidden; }
.scan-photo    { width: 100%; display: block; object-fit: cover; max-height: 380px; }
.scan-canvas   { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.scan-label-overlay {
  position: absolute; bottom: 0; left: 0; right: 0;
  background: linear-gradient(transparent, rgba(0,0,0,.82));
  padding: 24px 16px 12px;
  font-size: 11px; letter-spacing:.32em; color: var(--ink-dim); text-align: center;
}

.scan-log {
  width: 100%;
  background-color: var(--bg2);
  background-image:
    repeating-linear-gradient(
      175deg,
      transparent 0px, transparent 4px,
      rgba(180,100,20,.05) 4px, rgba(180,100,20,.05) 5px,
      transparent 5px, transparent 11px
    );
  box-shadow: inset 0 0 0 1px var(--card-b), 0 3px 0 rgba(0,0,0,.4);
  border-radius: var(--radius); padding: 20px; min-height: 100px;
  font-size: 14px; color: var(--text-dim); line-height: 2.2;
}
.scan-block {
  margin-bottom: 14px;
}
.scan-block:last-child { margin-bottom: 0; }
.scan-block-label {
  font-size: 10px;
  letter-spacing: .28em;
  color: var(--ink);
  opacity: 0.55;
  margin-bottom: 6px;
  text-transform: uppercase;
}
.scan-block-content {
  color: var(--text);
  font-size: 13px;
  line-height: 1.9;
  white-space: pre-wrap;
  word-break: break-word;
  opacity: 0.88;
  min-height: 1em;
}
.scan-line        { opacity: 0; transform: translateY(4px); transition: all .5s; }
.scan-line.active { opacity: 1; transform: translateY(0); color: var(--text); }
.scan-stream {
  color: var(--text);
  font-size: 13px;
  line-height: 1.9;
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 340px;
  overflow-y: auto;
  opacity: 0.9;
}

/* ─── 扫描进度条 ─────────────────────────────────────────────────────── */
.scan-progress-wrap {
  width: 100%;
  display: flex; flex-direction: column; gap: 10px;
}
.scan-progress-label {
  font-size: 13px; color: var(--ink-dim);
  letter-spacing: .12em; text-align: center;
}
.scan-progress-bar {
  width: 100%; height: 2px;
  background: rgba(180,120,40,.15);
  border-radius: 2px; overflow: hidden;
}
.scan-progress-fill {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--ink-dim), var(--ink));
  border-radius: 2px;
  transition: width .3s ease;
}
@keyframes progressPulse {
  0%   { opacity: .5; }
  50%  { opacity: 1; }
  100% { opacity: .5; }
}
.scan-progress-wrap:not(.hidden) .scan-progress-label {
  animation: progressPulse 2s ease-in-out infinite;
}

/* ─── RESULT PHASE ───────────────────────────────────────────────────────── */
#ph-result { align-items: flex-start; padding-top: 60px; padding-bottom: 80px; }
.result-inner { max-width: 860px; width: 100%; display: flex; flex-direction: column; gap: 28px; }

.scan-reveal { animation: fade-up .5s ease both; }
.scan-reveal:nth-child(2) { animation-delay:.1s; }
.scan-reveal:nth-child(3) { animation-delay:.2s; }
@keyframes fade-up { from{opacity:0;transform:translateY(18px)} to{opacity:1;transform:translateY(0)} }

/* ─── 线索 + 起卦 block ─────────────────────────────────────────────────── */
.result-card {
  position: relative; overflow: hidden;
  background-color: var(--bg2);
  box-shadow: inset 0 0 0 1px var(--card-b), 0 4px 0 rgba(0,0,0,.5);
  border-radius: var(--radius);
}
/* Wood grain layer */
.result-card::before {
  content: ''; position: absolute; inset: 0; pointer-events: none; z-index: 0;
  background-image:
    repeating-linear-gradient(
      177deg,
      transparent 0px, transparent 3px,
      rgba(180,110,30,.08) 3px, rgba(180,110,30,.08) 4px,
      transparent 4px, transparent 10px,
      rgba(0,0,0,.05) 10px, rgba(0,0,0,.05) 11px
    );
}
/* Woven layer */
.result-card::after {
  content: ''; position: absolute; inset: 0; pointer-events: none; z-index: 0;
  background-image:
    repeating-linear-gradient(45deg,  rgba(180,110,30,.04) 0, rgba(180,110,30,.04) 1px, transparent 0, transparent 50%),
    repeating-linear-gradient(-45deg, rgba(180,110,30,.04) 0, rgba(180,110,30,.04) 1px, transparent 0, transparent 50%);
  background-size: 12px 12px;
}
.result-card > * { position: relative; z-index: 1; }

.block-header {
  padding: 12px 20px; font-size: 11px; letter-spacing:.32em;
  color: var(--ink-dim); border-bottom: 1px solid var(--card-b);
}
.block-body { padding: 18px 20px; font-size: 14px; line-height: 2.1; color: var(--text-dim); white-space: pre-line; }
.clue-text strong { color: var(--ink); font-weight: 600; }
.gua-text { color: var(--text); }
.divider-line {
  display:flex; align-items:center; gap:12px;
  color:var(--text-dim); font-size:11px; letter-spacing:.25em; padding: 0 20px;
}
.divider-line::before, .divider-line::after { content:''; flex:1; height:1px; background:var(--card-b); }

/* ─── Two cards ──────────────────────────────────────────────────────────── */
.cards-row { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }

.fate-card {
  position: relative; overflow: hidden;
  background-color: var(--bg2);
  box-shadow: inset 0 0 0 1px var(--card-b), 0 4px 0 rgba(0,0,0,.5);
  border-radius: var(--radius);
  display: flex; flex-direction: column;
}
/* Wood grain */
.fate-card::before {
  content: ''; position: absolute; inset: 0; pointer-events: none; z-index: 0;
  background-image:
    repeating-linear-gradient(
      175deg,
      transparent 0px, transparent 4px,
      rgba(180,110,30,.07) 4px, rgba(180,110,30,.07) 5px,
      transparent 5px, transparent 13px,
      rgba(0,0,0,.04) 13px, rgba(0,0,0,.04) 14px
    );
}
/* Woven texture */
.fate-card::after {
  content: ''; position: absolute; inset: 0; pointer-events: none; z-index: 0;
  background-image:
    repeating-linear-gradient(45deg,  rgba(180,110,30,.045) 0, rgba(180,110,30,.045) 1px, transparent 0, transparent 50%),
    repeating-linear-gradient(-45deg, rgba(180,110,30,.045) 0, rgba(180,110,30,.045) 1px, transparent 0, transparent 50%);
  background-size: 12px 12px;
}
.fate-card > * { position: relative; z-index: 1; }

.main-card   { box-shadow: inset 0 0 0 1px var(--card-b), inset 2px 0 0 var(--ink-dim), 0 4px 0 rgba(0,0,0,.5); }
.change-card { box-shadow: inset 0 0 0 1px var(--card-b), inset 2px 0 0 rgba(58,96,112,.55), 0 4px 0 rgba(0,0,0,.5); }

.card-badge {
  display: inline-block; padding: 3px 12px; margin: 14px 16px 0;
  box-shadow: inset 0 0 0 1px var(--ink-dim);
  border-radius: 1px;
  font-size: 11px; letter-spacing:.22em; color: var(--ink-dim); align-self: flex-start;
}
.change-badge { box-shadow: inset 0 0 0 1px rgba(58,96,112,.5); color: rgba(120,180,200,.6); }

.card-hex-name {
  padding: 8px 16px 10px; font-size: 18px; font-weight: 700;
  color: var(--ink); text-shadow: 1px 1px 0 rgba(0,0,0,.55);
}

/* ─── Card image area ────────────────────────────────────────────────────── */
.card-snap-wrap { aspect-ratio: 1; overflow: hidden; background: var(--bg); position: relative; }
.card-snap-wrap img { width:100%; height:100%; object-fit:cover; display:block; }

/* Image generation progress overlay */
.snap-img-progress {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 14px; padding: 24px;
  background: rgba(11,8,5,.85);
}
.snap-img-progress-label {
  font-size: 12px; color: var(--ink-dim);
  letter-spacing: .12em; animation: progressPulse 2s ease-in-out infinite;
}
.snap-img-progress .scan-progress-bar { width: 100%; }

/* Initial placeholder (before results load) */
.snap-placeholder {
  width:100%; height:100%;
  display:flex; align-items:center; justify-content:center;
  background-color: var(--bg);
  background-image:
    linear-gradient( 45deg, rgba(180,110,30,.09) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(180,110,30,.09) 25%, transparent 25%),
    linear-gradient( 45deg, transparent 75%, rgba(180,110,30,.09) 75%),
    linear-gradient(-45deg, transparent 75%, rgba(180,110,30,.09) 75%);
  background-size: 22px 22px;
  background-position: 0 0, 0 11px, 11px -11px, -11px 0px;
}
.snap-glyph { font-size:44px; opacity:.2; color:var(--ink); }

/* ─── Image locked state ──────────────────────────────────────────────────── */
.img-locked {
  width: 100%; height: 100%;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 10px; padding: 16px;
  background-color: var(--bg);
  background-image:
    linear-gradient( 45deg, rgba(180,110,30,.09) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(180,110,30,.09) 25%, transparent 25%),
    linear-gradient( 45deg, transparent 75%, rgba(180,110,30,.09) 75%),
    linear-gradient(-45deg, transparent 75%, rgba(180,110,30,.09) 75%);
  background-size: 22px 22px;
  background-position: 0 0, 0 11px, 11px -11px, -11px 0px;
  position: relative;
}
/* Inner frame — tribal border echo */
.img-locked::before {
  content: '';
  position: absolute; inset: 7px;
  box-shadow: inset 0 0 0 1px rgba(180,110,30,.22);
  pointer-events: none;
}

/* Unicode hexagram character */
.img-hex-unicode {
  font-size: 52px; line-height: 1;
  color: var(--ink); opacity: .78;
  text-shadow: 2px 2px 0 rgba(0,0,0,.65);
  letter-spacing: 0;
}

/* Hexagram name */
.img-locked-name {
  font-size: 13px; color: var(--text-dim);
  letter-spacing:.18em; text-align: center; max-width: 90%;
}

.img-unlock-btn {
  margin-top: 6px; padding: 7px 22px;
  border: none;
  box-shadow: inset 0 0 0 1px var(--ink-dim), 0 2px 0 rgba(0,0,0,.5);
  border-radius: 1px;
  background: rgba(180,110,30,.12);
  color: var(--ink); font-family: var(--font); font-size: 12px;
  letter-spacing:.18em; cursor: pointer; transition: all .22s;
}
.img-unlock-btn:hover { background: rgba(180,110,30,.22); color: var(--text); }
.img-unlock-btn:disabled { opacity:.38; cursor:not-allowed; }

.card-poem {
  padding: 16px; font-size: 15px; line-height: 2.2; color: var(--text);
  white-space: pre-line; border-top: 1px solid var(--card-b);
}
.card-desc { padding: 0 16px 12px; font-size: 13px; line-height: 1.9; color: var(--text-dim); }
.card-conclusion {
  margin: 0 16px 16px; padding: 12px 14px;
  background: rgba(180,110,30,.06);
  box-shadow: inset 0 0 0 1px rgba(180,110,30,.16);
  border-radius: 2px;
  font-size: 13px; line-height: 1.8; color: var(--text);
}
.card-conclusion strong { color: var(--ink); font-size: 15px; }

/* ─── Deep Read ──────────────────────────────────────────────────────────── */
.deep-read {
  position: relative;
  background-color: var(--bg2);
  box-shadow: inset 0 0 0 1px var(--card-b), 0 4px 0 rgba(0,0,0,.5);
  border-radius: var(--radius); overflow: hidden;
}
/* Wood grain on deep read */
.deep-read::before {
  content: ''; position: absolute; inset: 0; pointer-events: none; z-index: 0;
  background-image:
    repeating-linear-gradient(
      173deg,
      transparent 0px, transparent 5px,
      rgba(180,110,30,.06) 5px, rgba(180,110,30,.06) 6px,
      transparent 6px, transparent 15px,
      rgba(0,0,0,.04) 15px, rgba(0,0,0,.04) 16px
    );
}
.deep-read > * { position: relative; z-index: 1; }

.deep-header {
  padding: 28px 24px 24px; text-align: center;
  border-bottom: 1px solid var(--card-b);
}
/* Tribal totem row above deep read header */
.deep-header::before {
  content: '◈  ◆  ◈';
  display: block;
  font-size: 10px; letter-spacing:.55em; color: var(--ink-dim);
  opacity: .5; margin-bottom: 16px;
}
.lock-icon { font-size: 18px; margin-bottom: 6px; }
.deep-title {
  font-size: 17px; color: var(--ink); letter-spacing:.18em;
  margin-bottom: 6px; text-shadow: 1px 1px 0 rgba(0,0,0,.5);
}
.deep-sub { font-size: 12px; color: var(--text-dim); margin-bottom: 18px; letter-spacing:.05em; }
.unlock-btn {
  padding: 10px 34px; border: none;
  box-shadow: inset 0 0 0 1px var(--ink-dim), 0 2px 0 rgba(0,0,0,.5);
  border-radius: 1px;
  background: rgba(180,110,30,.1);
  color: var(--ink); font-family: var(--font); font-size: 13px;
  letter-spacing:.15em; cursor: pointer; transition: all .22s;
}
.unlock-btn:hover { background: rgba(180,110,30,.22); color: var(--text); }
.unlock-btn:disabled { opacity:.38; cursor:not-allowed; }

.deep-body { padding: 0 24px 24px; }
.deep-section { padding: 20px 0; border-bottom: 1px solid var(--card-b); }
.deep-section:last-of-type { border-bottom: none; }
.deep-sec-title {
  font-size: 11px; letter-spacing:.3em; color: var(--ink-dim); margin-bottom: 12px;
}
.deep-sec-title::before { content: '▪  '; }
.deep-sec-body { font-size: 14px; line-height: 2.1; color: var(--text-dim); white-space: pre-line; }
.epilogue .deep-sec-body { color: var(--text); font-size: 15px; line-height: 2.3; }
.watermark {
  text-align: center; font-size: 11px; color: var(--text-dim);
  opacity:.38; margin-top: 20px; letter-spacing:.04em;
}

/* ─── Retry ──────────────────────────────────────────────────────────────── */
.retry-btn {
  align-self: center; padding: 10px 38px;
  border: none;
  box-shadow: inset 0 0 0 1px rgba(180,110,30,.22), 0 2px 0 rgba(0,0,0,.4);
  border-radius: 1px;
  background: transparent; color: var(--text-dim);
  font-family: var(--font); font-size: 13px;
  letter-spacing:.2em; cursor: pointer; transition: all .22s;
}
.retry-btn:hover {
  color: var(--ink);
  box-shadow: inset 0 0 0 1px var(--ink-dim), 0 2px 0 rgba(0,0,0,.4);
}

/* ─── Toast ──────────────────────────────────────────────────────────────── */
.toast {
  position: fixed; bottom: 32px; left: 50%; transform: translateX(-50%);
  background: rgba(110,26,14,.96); color:var(--text); padding:12px 24px;
  border-radius: 2px;
  box-shadow: inset 0 0 0 1px rgba(180,70,40,.3), 0 3px 0 rgba(0,0,0,.5);
  font-size:14px; z-index:999; animation:fade-up .3s ease;
}

/* ─── Card Design (from user spec) ──────────────────────────────────────── */
:root {
  --card-w: 340px;
  --card-h: 520px;
  --card-bg: #f5f0e8;
  --card-bg-warm: #f2ece2;
  --text-dark: #2a1f14;
  --text-mid: #5a4d3e;
  --text-muted: #8a7b68;
  --text-light: #b0a28e;
  --text-red: #c4503a;
  --border-fine: #e8e0d2;
}

/* Shared card shell */
.card {
  width: var(--card-w);
  height: var(--card-h);
  background: var(--card-bg);
  border-radius: 4px;
  position: relative;
  box-shadow: 0 1px 3px rgba(0,0,0,0.12), 0 6px 24px rgba(0,0,0,0.25), 0 20px 60px rgba(0,0,0,0.2);
  overflow: hidden;
}

/* ── Front ── */
.front { padding: 13px 13px 0 13px; }

.f-image {
  width: 100%; height: 370px;
  border-radius: 2px; overflow: hidden;
  position: relative; background: #2a1f14;
}
.f-art {
  width: 100%; height: 100%;
  background:
    radial-gradient(ellipse at 50% 45%, rgba(240,210,140,0.7) 0%, transparent 35%),
    radial-gradient(ellipse at 50% 42%, rgba(255,245,210,0.5) 0%, transparent 18%),
    radial-gradient(ellipse at 35% 25%, rgba(140,90,55,0.8) 0%, transparent 45%),
    radial-gradient(ellipse at 65% 25%, rgba(130,80,50,0.7) 0%, transparent 45%),
    radial-gradient(ellipse at 50% 75%, rgba(60,38,22,0.9) 0%, transparent 50%),
    linear-gradient(175deg, #7a5035 0%, #4a2e1c 35%, #2e1c10 70%, #1a100a 100%);
}
.f-overlay {
  position: absolute; bottom: 0; left: 0; right: 0;
  padding: 14px 12px 10px;
  background: linear-gradient(to top, rgba(15,10,6,0.8) 0%, rgba(15,10,6,0.3) 70%, transparent 100%);
  display: flex; justify-content: space-between; align-items: flex-end;
  z-index: 1;
}
.f-overlay-label {
  font-family: 'Space Mono', monospace;
  font-size: 9px; letter-spacing: 2.5px;
  color: rgba(220,200,170,0.5); text-transform: uppercase;
}
.mini-hex { display:flex; flex-direction:column; gap:3px; align-items:center; }
.ml { height:3px; border-radius:0.5px; }
.ml.y { width:28px; background:rgba(220,200,170,0.55); }
.ml.n { width:28px; display:flex; justify-content:space-between; }
.ml.n::before,.ml.n::after { content:''; width:11px; height:3px; background:rgba(220,200,170,0.55); border-radius:0.5px; }
.ml.y.mv { background:var(--text-red); }
.ml.n.mv::before,.ml.n.mv::after { background:var(--text-red); }

.f-info { padding: 12px 5px 0; }
.f-row { display:flex; justify-content:space-between; align-items:flex-start; }
.f-title {
  font-family: 'Cormorant Garamond', serif;
  font-size: 17px; font-weight: 600; color: var(--text-dark);
  letter-spacing: 2px; text-transform: uppercase; line-height: 1.2;
}
.f-sub {
  font-family: 'Crimson Pro', serif;
  font-size: 11px; font-weight: 300; font-style: italic;
  color: var(--text-muted); margin-top: 2px;
}
.f-right { text-align: right; }
.f-cn {
  font-family: 'Noto Serif SC', serif;
  font-size: 20px; font-weight: 400; color: var(--text-dark); line-height: 1;
}
.f-num {
  font-family: 'Space Mono', monospace;
  font-size: 9px; color: var(--text-muted); letter-spacing: 1px; margin-top: 3px;
}
.f-foot {
  display:flex; justify-content:space-between; align-items:center;
  margin-top: 8px; padding-top: 7px; border-top: 1px solid var(--border-fine);
}
.f-mv {
  font-family: 'Space Mono', monospace;
  font-size: 9px; letter-spacing: 1.5px; color: var(--text-red); font-weight: 700;
}
.f-date {
  font-family: 'Space Mono', monospace;
  font-size: 9px; color: var(--text-light); letter-spacing: 1px;
}
.f-brand {
  font-family: 'Space Mono', monospace;
  font-size: 7px; color: var(--text-light);
  letter-spacing: 2px; text-transform: uppercase;
  text-align: center; margin-top: 6px; opacity: 0.45;
}

/* ── Back ── */
.back { background: var(--card-bg-warm); display:flex; flex-direction:column; }
.b-inner { padding: 22px 22px 16px; display:flex; flex-direction:column; height:100%; }
.b-head {
  display:flex; justify-content:space-between; align-items:center;
  padding-bottom: 10px; border-bottom: 1px solid var(--border-fine);
}
.b-head-l {
  font-family: 'Space Mono', monospace;
  font-size: 9px; letter-spacing: 2.5px; color: var(--text-light); text-transform: uppercase;
}
.b-head-r {
  font-family: 'Noto Serif SC', serif;
  font-size: 12px; font-weight: 300; color: var(--text-muted);
}
.b-center {
  flex:1; display:flex; flex-direction:column;
  align-items:center; justify-content:center; padding: 10px 0;
}
.b-cn {
  font-family: 'Noto Serif SC', serif;
  font-size: 48px; font-weight: 200; color: var(--text-dark);
  line-height: 1; letter-spacing: 12px; margin-bottom: 4px;
}
.b-en {
  font-family: 'Cormorant Garamond', serif;
  font-size: 12px; font-weight: 400; letter-spacing: 5px;
  text-transform: uppercase; color: var(--text-muted); margin-bottom: 22px;
}
.b-lines { display:flex; flex-direction:column; gap:9px; align-items:center; margin-bottom:18px; }
.b-lr { display:flex; align-items:center; gap:10px; }
.b-ln {
  font-family: 'Space Mono', monospace;
  font-size: 8px; color: var(--text-light); width: 16px; text-align: right;
}
.b-yao { height:7px; border-radius:1px; }
.b-yao.y { width:130px; background:var(--text-dark); }
.b-yao.n { width:130px; display:flex; justify-content:space-between; }
.b-yao.n::before,.b-yao.n::after { content:''; width:56px; height:7px; background:var(--text-dark); border-radius:1px; }
.b-yao.y.mv { background:var(--text-red); }
.b-yao.n.mv::before,.b-yao.n.mv::after { background:var(--text-red); }
.b-le { width:16px; font-size:9px; }
.b-dot { color:var(--text-red); }
.b-tri { display:flex; gap:44px; justify-content:center; }
.tri { text-align:center; }
.tri-pos {
  font-family: 'Space Mono', monospace;
  font-size: 7px; letter-spacing: 2px; color: var(--text-light);
  text-transform: uppercase; margin-bottom: 3px;
}
.tri-name { font-family:'Cormorant Garamond',serif; font-size:14px; font-weight:500; color:var(--text-mid); }
.tri-cn   { font-family:'Noto Serif SC',serif; font-size:12px; font-weight:300; color:var(--text-muted); margin-top:1px; }
.tri-el   { font-family:'Crimson Pro',serif; font-size:9px; font-style:italic; color:var(--text-light); margin-top:1px; }

.b-text { border-top:1px solid var(--border-fine); padding-top:12px; margin-top:auto; }
.b-slabel {
  font-family: 'Space Mono', monospace;
  font-size: 7px; letter-spacing: 2px; color: var(--text-red);
  text-transform: uppercase; margin-bottom: 6px;
}
.b-yaoci {
  font-family: 'Crimson Pro', serif;
  font-size: 12px; font-weight: 300; color: var(--text-mid); line-height: 1.6; margin-bottom: 4px;
}
.b-yaoci-cn {
  font-family: 'Noto Serif SC', serif;
  font-size: 11px; font-weight: 300; color: var(--text-muted); line-height: 1.6;
}
.b-foot {
  display:flex; justify-content:space-between; align-items:center;
  margin-top: 12px; padding-top: 8px; border-top: 1px solid var(--border-fine);
}
.bf   { font-family:'Space Mono',monospace; font-size:8px; color:var(--text-light); letter-spacing:1.5px; }
.bf-b { font-family:'Space Mono',monospace; font-size:7px; color:var(--text-light); letter-spacing:3px; text-transform:uppercase; opacity:0.4; }
.bf-r { font-family:'Space Mono',monospace; font-size:8px; color:var(--text-red); letter-spacing:1.5px; font-weight:700; }

/* ── Flip mechanism (click-triggered) ── */
.flip-wrap { perspective:1200px; cursor:pointer; width:var(--card-w); margin:0 auto; }
.flip-in {
  position:relative; width:var(--card-w); height:var(--card-h);
  transition:transform 0.8s cubic-bezier(0.23,1,0.32,1);
  transform-style:preserve-3d;
}
.flip-wrap.flipped .flip-in { transform:rotateY(180deg); }
.flip-f,.flip-b { position:absolute; top:0; left:0; width:100%; height:100%; backface-visibility:hidden; }
.flip-b { transform:rotateY(180deg); }

/* Image loading overlay (inside .f-image) */
.snap-img-progress {
  position:absolute; inset:0; z-index:2;
  display:flex; flex-direction:column; align-items:center; justify-content:center;
  gap:14px; padding:24px; background:rgba(11,8,5,.85);
}

/* Cards row: center the fixed-width cards */
.cards-row { display:grid; grid-template-columns:1fr 1fr; gap:20px; justify-items:center; }


/* ─── Mobile ─────────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  /* Phase containers */
  .phase { padding: 24px 14px; }
  #ph-result { padding-top: 32px; padding-bottom: 48px; }

  /* Hero */
  .logo-glyph { font-size: 44px; margin-bottom: 14px; }
  .tagline { font-size: 13px; margin-bottom: 32px; }
  .upload-inner { padding: 32px 16px; gap: 10px; }
  .upload-hint { font-size: 15px; }

  /* Question phase */
  .question-inner { grid-template-columns: 1fr; }
  .cast-btn { min-height: 48px; font-size: 14px; }

  /* Scanning phase */
  .scanning-inner { gap: 18px; }
  .scan-photo { max-height: 260px; }
  .scan-log { padding: 14px; font-size: 13px; }
  .scan-stream { max-height: 220px; }

  /* Result phase */
  .result-inner { gap: 18px; }
  .block-header { padding: 10px 14px; }
  .block-body { padding: 14px; font-size: 13px; line-height: 1.95; }

  /* Cards */
  .cards-row { grid-template-columns: 1fr; }
  .card-hex-name { font-size: 16px; padding: 7px 14px 9px; }
  .card-poem { padding: 12px 14px; font-size: 14px; line-height: 2.1; }
  .card-desc { padding: 0 14px 10px; font-size: 12px; }
  .card-conclusion { margin: 0 14px 14px; padding: 10px 12px; font-size: 12px; }
  .card-conclusion strong { font-size: 14px; }
  .card-badge { padding: 2px 10px; margin: 12px 14px 0; font-size: 10px; }

  /* Card image area — keep square but full-width */
  .card-snap-wrap { aspect-ratio: 1; }

  /* Locked image */
  .img-hex-unicode { font-size: 40px; }
  .img-locked-name { font-size: 12px; }
  .img-unlock-btn { min-height: 40px; padding: 8px 18px; font-size: 12px; }

  /* Deep Read */
  .deep-header { padding: 20px 16px 18px; }
  .deep-title { font-size: 15px; }
  .deep-sub { font-size: 11px; }
  .unlock-btn { min-height: 44px; padding: 10px 24px; font-size: 12px; }
  .deep-body { padding: 0 14px 18px; }
  .deep-section { padding: 16px 0; }
  .deep-sec-body { font-size: 13px; line-height: 2.0; }
  .epilogue .deep-sec-body { font-size: 14px; line-height: 2.1; }

  /* Retry */
  .retry-btn { min-height: 44px; padding: 10px 28px; font-size: 12px; }

  /* Toast */
  .toast { bottom: 20px; font-size: 13px; padding: 10px 18px; width: 90%; text-align: center; }

  /* Divider */
  .divider-line { padding: 0 14px; }

  /* Cards mobile */
  .cards-row { grid-template-columns: 1fr; }
  .flip-wrap,.flip-in { width:100%; max-width:var(--card-w); }
  .card { width:100%; max-width:var(--card-w); }
  .b-yao.y,.b-yao.n { width:100px; }
  .b-yao.n::before,.b-yao.n::after { width:42px; }
  .b-cn { font-size:36px; letter-spacing:8px; }
  .b-tri { gap:24px; }
}

/* ─── Image Lock Overlay ─────────────────────────────────────────────────── */
.img-lock-overlay {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: rgba(11,8,5,0.82);
  backdrop-filter: blur(6px);
  border-radius: 2px;
}
.lock-glyph {
  font-size: 28px;
  color: var(--gold, #c8a97e);
  opacity: 0.9;
}
.lock-text {
  font-family: 'Noto Serif SC', serif;
  font-size: 13px;
  color: #e8d5b0;
  letter-spacing: 0.08em;
}
.lock-pay-btn {
  margin-top: 4px;
  padding: 8px 20px;
  background: transparent;
  border: 1px solid #c8a97e;
  color: #c8a97e;
  font-family: 'Noto Serif SC', serif;
  font-size: 12px;
  letter-spacing: 0.1em;
  border-radius: 3px;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}
.lock-pay-btn:hover { background: #c8a97e; color: #0b0805; }

/* ─── Credit Badge ───────────────────────────────────────────────────────── */
.credit-badge-wrap {
  display: flex;
  align-items: center;
  gap: 5px;
  font-family: 'Space Mono', monospace;
  font-size: 12px;
  color: #c8a97e;
  margin-bottom: 8px;
}
.credit-icon { font-size: 14px; }

/* ─── Payment Modal ──────────────────────────────────────────────────────── */
.pay-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(0,0,0,0.75);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.pay-modal {
  background: #130f0a;
  border: 1px solid rgba(200,169,126,0.3);
  border-radius: 12px;
  padding: 28px 24px 24px;
  width: 100%;
  max-width: 380px;
  position: relative;
}
.pay-modal-close {
  position: absolute;
  top: 14px; right: 16px;
  background: none;
  border: none;
  color: #888;
  font-size: 16px;
  cursor: pointer;
  padding: 4px 8px;
}
.pay-modal-title {
  font-family: 'Cormorant Garamond', serif;
  font-size: 22px;
  color: #e8d5b0;
  margin-bottom: 4px;
  text-align: center;
}
.pay-modal-sub {
  font-family: 'Noto Serif SC', serif;
  font-size: 12px;
  color: #888;
  text-align: center;
  margin-bottom: 20px;
}

/* Package buttons */
.pkg-row {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
}
.pkg-btn {
  flex: 1;
  position: relative;
  padding: 14px 10px;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(200,169,126,0.25);
  border-radius: 8px;
  color: #e8d5b0;
  cursor: pointer;
  text-align: center;
  transition: border-color 0.2s, background 0.2s;
}
.pkg-btn.selected {
  border-color: #c8a97e;
  background: rgba(200,169,126,0.1);
}
.pkg-count { font-size: 20px; font-family: 'Cormorant Garamond', serif; font-weight: 600; }
.pkg-price { font-size: 15px; color: #c8a97e; margin: 2px 0; }
.pkg-unit  { font-size: 11px; color: #777; }
.pkg-badge {
  position: absolute;
  top: -8px; right: 8px;
  background: #c8a97e;
  color: #0b0805;
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 10px;
  font-family: 'Space Mono', monospace;
}

/* Stripe element */
#stripe-payment-element { margin-bottom: 12px; }

/* Buttons */
.pay-action-btn {
  width: 100%;
  padding: 13px;
  background: #c8a97e;
  border: none;
  border-radius: 6px;
  color: #0b0805;
  font-family: 'Noto Serif SC', serif;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.08em;
  cursor: pointer;
  transition: opacity 0.2s;
  margin-bottom: 8px;
}
.pay-action-btn:disabled { opacity: 0.6; cursor: not-allowed; }
.pay-confirm-btn { background: #5a9a6a; }

/* Divider */
.pay-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 12px 0;
  color: #555;
  font-size: 12px;
}
.pay-divider::before,.pay-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: rgba(255,255,255,0.1);
}

/* Recovery */
.recover-row {
  display: flex;
  gap: 8px;
  margin-bottom: 6px;
}
.recover-input {
  flex: 1;
  padding: 9px 12px;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 6px;
  color: #e8d5b0;
  font-size: 13px;
}
.recover-input::placeholder { color: #555; }
.recover-btn {
  padding: 9px 14px;
  background: transparent;
  border: 1px solid rgba(200,169,126,0.4);
  border-radius: 6px;
  color: #c8a97e;
  font-size: 13px;
  cursor: pointer;
}
.recover-btn:hover { background: rgba(200,169,126,0.1); }
.pay-error {
  color: #e07070;
  font-size: 12px;
  min-height: 16px;
  text-align: center;
}

