/* 生日候 · 拨一年的圆盘。色板沿用站点 DESIGN.md：墨黑底、暖金点缀、米白正文 */
:root {
  --bg: #0d1012; --card: #171b1e; --text: #f1eee7; --muted: #a4a6a5; --gold: #d7b56d; --line: #303638; --red: #c4553f;
  --serif: 'Noto Serif SC', 'Songti SC', 'STSong', serif;
  --sans: 'Noto Sans SC', 'PingFang SC', system-ui, sans-serif;
  --kai: 'LXGW WenKai TC', 'Kaiti SC', 'STKaiti', serif;
  --D: min(780px, calc(100vh - 120px), calc(100vw - 600px));
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { min-height: 100%; overflow-x: hidden; }
body { text-autospace: normal; background: radial-gradient(900px 700px at 34% 52%, #161b1d, var(--bg) 70%) fixed, var(--bg); color: var(--text); font-family: var(--sans); -webkit-font-smoothing: antialiased; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; }
.skip { position: absolute; left: -999px; top: 8px; z-index: 50; background: var(--gold); color: #111; padding: 8px 12px; border-radius: 6px; }
.skip:focus { left: 8px; }

.top { display: flex; justify-content: space-between; padding: 26px 48px 0; font: 15px/1 var(--serif); color: var(--muted); letter-spacing: .12em; }
.top b { color: var(--text); font-weight: 600; }

.main { display: flex; align-items: center; justify-content: center; gap: clamp(40px, 6vw, 110px); padding: 24px 40px 40px; min-height: calc(100vh - 41px); }
.dialcol { flex: none; }
.dial { position: relative; width: var(--D); height: var(--D); touch-action: none; user-select: none; -webkit-user-select: none; outline: none; border-radius: 50%; }
.dial:focus-visible { box-shadow: 0 0 0 2px rgba(215,181,109,.5); }
#dialsvg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; display: block; cursor: grab; }
.dragging #dialsvg { cursor: grabbing; }

/* SVG 文字 */
.term-t { font: 400 14px/1 var(--serif); fill: #b9b6ae; letter-spacing: 1px; }
.term-t.on { fill: var(--gold); }
.mon-t { font: 12px/1 var(--sans); fill: #6f7473; }
.hou-t { font: 11px/1 var(--serif); fill: #5f6564; }
.hou-t.painted { fill: #e9e4d8; font-weight: 600; }
.hou-t.sel { fill: #1a160d; font-weight: 600; font-size: 12px; }
.wg { transition: fill .2s; }
.cell { cursor: pointer; }
.cell:hover .wg.u { stroke: #4a5254; }

/* 圆心：输入态 */
.cin { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; pointer-events: none; transition: opacity .35s; }
.cin .yr { pointer-events: auto; display: flex; align-items: center; gap: 14px; font: calc(var(--D) * .023) / 1 var(--sans); color: var(--muted); letter-spacing: 0; }
.cin .yr button { width: 32px; height: 32px; border: 1px solid var(--line); border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; color: var(--text); font-size: 16px; }
.cin .yr button:hover { border-color: var(--gold); color: var(--gold); }
.cin .md { margin-top: calc(var(--D) * .018); font: 600 calc(var(--D) * .097) / 1 var(--serif); letter-spacing: .02em; }
.cin .md small { font-size: .45em; font-weight: 400; margin: 0 .06em; }
.cin .hit { margin-top: calc(var(--D) * .023); font: calc(var(--D) * .023) / 1 var(--serif); color: var(--gold); letter-spacing: .04em; }
.mode-out .cin { opacity: 0; visibility: hidden; }

/* 圆心：邮票舞台 */
.stage { position: absolute; left: 50%; top: 50%; width: calc(var(--D) * .31); transform: translate(-50%, -50%); pointer-events: none; opacity: 0; transition: opacity .35s; }
.mode-out .stage { opacity: 1; pointer-events: auto; }
.stamp { position: relative; aspect-ratio: 620 / 798; cursor: pointer; filter: drop-shadow(0 0 28px rgba(215,181,109,.22)) drop-shadow(0 10px 18px rgba(0,0,0,.45)); --a: 1; --b: 1; }
.stamp img, .stamp canvas { position: absolute; left: 0; top: 0; width: 100%; height: 100%; display: block; }
.stamp .l-sk { -webkit-mask-image: linear-gradient(105deg, #000 calc(var(--a) * 130% - 30%), transparent calc(var(--a) * 130%)); mask-image: linear-gradient(105deg, #000 calc(var(--a) * 130% - 30%), transparent calc(var(--a) * 130%)); }
.stamp .l-sk.fake { filter: grayscale(1) sepia(.12) contrast(.85) brightness(1.1); }
.stamp .l-col { -webkit-mask-image: linear-gradient(to top, #000 calc(var(--b) * 125% - 25%), transparent calc(var(--b) * 125%)); mask-image: linear-gradient(to top, #000 calc(var(--b) * 125% - 25%), transparent calc(var(--b) * 125%)); }
.stamp .pm { left: 64%; top: 74%; width: 50%; height: auto; aspect-ratio: 1; pointer-events: none; }
.stamp.pending .l-sk, .stamp.pending .l-col { display: none; }
.stamp:not(.pending) .l-pend { display: none; }

/* 右栏 */
.side { width: 440px; flex: none; }
.s-out { display: none; }
.mode-out .s-in { display: none; }
.s-in h1 { font: 600 42px/1.25 var(--serif); letter-spacing: .04em; }
.lead { margin-top: 16px; font: 17px/1.75 var(--sans); color: #c9c8c3; }
.bform { margin-top: 28px; display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.fl { display: inline-flex; align-items: center; gap: 6px; height: 54px; padding: 0 12px 0 14px; background: var(--card); border: 1px solid var(--line); border-radius: 10px; font: 16px/1 var(--sans); color: var(--muted); }
.fl:focus-within { border-color: var(--gold); }
.fl input { width: 2.3ch; background: none; border: 0; color: var(--text); font: 600 24px/1 var(--serif); outline: none; text-align: right; }
.fl:first-child input { width: 4.4ch; }
.ferr { flex-basis: 100%; min-height: 0; font: 14px/1.4 var(--sans); color: #e08a74; }
.ferr:empty { display: none; }
.go { margin-top: 10px; height: 56px; padding: 0 30px; display: inline-flex; align-items: center; border-radius: 999px; background: var(--gold); color: #17130b; font: 600 18px/1 var(--sans); letter-spacing: .06em; }
.go:hover { background: #e3c47f; }
.legend { margin-top: 32px; display: grid; gap: 14px; font: 15px/1 var(--sans); color: #c9c8c3; }
.legend > span { display: flex; align-items: center; gap: 12px; }
.legend i { font-style: normal; }
.legend b { width: 26px; height: 18px; border-radius: 2px; display: inline-block; }
.lg-p { background: #3a3426; border: 1px solid #6c5f43; }
.lg-u { border: 1px dashed #4a5051; }
.lg-s { background: var(--gold); }
.kbd { margin-top: 22px; font: 13px/1.6 var(--sans); color: #6f7473; }

/* 结果面板文字排版：乙方案「产品页题签」（2026-10-17 选定，依据 排版调研-苹果.md）
   自上而下居中：眉题（节气 · 几候，全页唯一一处金色文字）→ 你的生日候是 → 候名 → 日期区间 → 细金线 → 古注「」→ 出处 → 白话 → 未画提示 → 按钮 → 上一候 / 下一候 */
/* 全页汉字与数字/字母之间自动留 1/8 em（text-autospace），源文本不手打空格 */
.s-out { font-kerning: normal; container-type: inline-size; }
.mode-out .s-out { display: flex; flex-direction: column; align-items: center; text-align: center; }
.r-term { order: 1; display: block; font: 600 17px/25px var(--sans); letter-spacing: .04em; color: var(--gold); }
.r-term .lb { display: inline-flex; align-items: baseline; }
.r-term .sep, .nbr .sep { margin: 0 .28em; opacity: .7; }
.r-term .dt { font-weight: 400; letter-spacing: 0; color: var(--muted); }
.r-term .dt::before { content: '·'; margin: 0 .28em 0 .56em; }
.r-you { order: 2; margin-top: 20px; font: 400 17px/25px var(--sans); color: var(--muted); }
.r-name { order: 3; margin-top: 4px; --fs: min(100px, calc(100cqi / (var(--L) * 1.04))); font: 700 var(--fs)/1.08 var(--serif); letter-spacing: .02em; }
.r-name[data-n="2"] { --fs: min(72px, calc(100cqi / (var(--L) * 1.04))); }
.r-name span { display: block; white-space: nowrap; }
.r-range { order: 4; margin-top: 12px; font: 400 15px/22px var(--sans); color: var(--muted); }
.r-range .rg-y::after { content: '　'; }
.r-quote { order: 5; margin-top: 32px; max-width: 26em; text-wrap: balance; font: 400 21px/1.7 var(--serif); letter-spacing: .04em; color: var(--text); }
.r-quote::before { content: ''; display: block; width: 24px; height: 1px; margin: 0 auto 24px; background: var(--gold); }
#rquote::before { content: '「'; }
#rquote::after { content: '」'; }
.r-quote cite { display: block; margin-top: 10px; font: 400 13px/20px var(--sans); font-style: normal; letter-spacing: 0; color: var(--muted); }
.r-plain { order: 6; margin-top: 16px; text-wrap: balance; font: 400 17px/1.65 var(--sans); color: #c9c8c3; }
.pend { display: none; order: 7; margin-top: 24px; max-width: 26em; text-wrap: pretty; font: 400 15px/1.7 var(--sans); color: var(--muted); }
.is-pending .pend { display: block; }
.chip { display: block; margin: 0 0 4px; font: 600 13px/18px var(--sans); letter-spacing: .08em; color: var(--gold); }
.pend-a { display: block; margin: 8px auto 0; padding: 4px 0; font: 600 15px/22px var(--sans); color: var(--gold); text-align: center; }
.pend-a:hover { text-decoration: underline; }
.pend-a:empty { display: none; }
.btns { order: 8; margin-top: 32px; display: flex; justify-content: center; gap: 12px; flex-wrap: wrap; }
.btn { height: 48px; padding: 0 24px; display: inline-flex; align-items: center; border-radius: 999px; font: 600 17px/1 var(--sans); letter-spacing: .02em; border: 1px solid #4a5051; white-space: nowrap; }
.btn:hover { border-color: var(--gold); }
.btn.pri { background: var(--text); color: #111; border-color: var(--text); }
.btn.pri:hover { background: #fff; }
.nbr { order: 9; margin-top: 36px; width: 100%; padding-top: 16px; border-top: 1px solid var(--line); display: flex; justify-content: space-between; gap: 12px; text-align: left; }
.nbr button { display: inline-flex; align-items: baseline; flex-wrap: wrap; gap: .5em; padding: 6px 0; font: 400 13px/18px var(--sans); color: var(--muted); text-align: left; }
.nbr button:last-child { justify-content: flex-end; text-align: right; }
.nbr button b { margin: 0; font: 600 15px/18px var(--serif); color: var(--text); }
.nbr button:hover b { color: var(--gold); }
.nbr .ar { color: var(--muted); }

.toast { position: fixed; left: 50%; bottom: 32px; transform: translate(-50%, 20px); background: var(--text); color: #111; font: 600 15px/1 var(--sans); padding: 14px 20px; border-radius: 999px; opacity: 0; pointer-events: none; transition: opacity .25s, transform .25s; z-index: 30; }
.toast.on { opacity: 1; transform: translate(-50%, 0); }

/* 窄屏：上下排 */
@media (max-width: 1080px) {
  :root { --D: min(680px, calc(100vw - 32px)); }
  .main { flex-direction: column; gap: 28px; padding: 18px 16px 48px; min-height: 0; }
  .side { width: min(560px, 100%); }
}
@media (max-width: 600px) {
  :root { --D: calc(100vw - 20px); }
  .top { padding: 18px 18px 0; font-size: 13px; }
  .main { padding: 14px 10px 40px; gap: 20px; }
  .side { padding: 0 12px; }
  .s-in h1 { font-size: 30px; }
  .lead { font-size: 15px; }
  .r-you { margin-top: 16px; font-size: 15px; }
  .r-name { --fs: min(72px, calc(100cqi / (var(--L) * 1.04))); }
  .r-name[data-n="2"] { --fs: min(52px, calc(100cqi / (var(--L) * 1.04))); }
  .r-quote { margin-top: 28px; font-size: 19px; }
  .r-quote::before { margin-bottom: 20px; }
  .r-plain { font-size: 15px; }
  .nbr { flex-direction: column; gap: 4px; }
  .nbr button:last-child { justify-content: flex-start; text-align: left; }
  .cin .yr button { width: 28px; height: 28px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; animation: none !important; } }

/* ---- 分享图：下载前的预览卡（填名字、边填边看成图） ---- */
dialog.sheet { margin: 0; border: 0; padding: 20px; width: 100%; height: 100%; max-width: none; max-height: none; background: rgba(5, 7, 8, .78); color: inherit; overscroll-behavior: contain; }
dialog.sheet[open] { display: flex; align-items: center; justify-content: center; }
dialog.sheet::backdrop { background: transparent; }
.sheet-card { display: flex; gap: 32px; align-items: center; max-width: 880px; width: 100%; max-height: calc(100dvh - 40px); background: #14181a; border: 1px solid var(--line); border-radius: 20px; padding: 28px; }
.sheet-card canvas { flex: none; height: min(620px, calc(100dvh - 120px)); aspect-ratio: 3 / 4; border-radius: 8px; box-shadow: 0 12px 40px rgba(0, 0, 0, .5); }
.sheet-side { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 16px; }
.sheet-side h3 { font: 600 24px/1.3 var(--serif); letter-spacing: .04em; }
.sheet-h { font: 400 15px/1.6 var(--sans); color: var(--muted); }
.sheet-btns { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 8px; }
.nm-row { display: flex; align-items: center; gap: 12px; height: 52px; padding: 0 16px; width: 100%; background: var(--card); border: 1px solid var(--line); border-radius: 12px; font: 400 15px/1 var(--sans); color: var(--muted); }
.nm-row:focus-within { border-color: var(--gold); }
.nm-row .nm-l { font-weight: 600; color: var(--gold); letter-spacing: .08em; }
.nm-in { flex: 1; min-width: 0; background: none; border: 0; outline: none; color: var(--text); font: 600 20px/1 var(--serif); letter-spacing: .08em; }
.nm-in::placeholder { font: 400 15px/1 var(--sans); letter-spacing: 0; color: #6f7473; }
/* 窄于 900：上下排，预览图宽度不超过卡片内容区（弹窗 20×2 + 卡片 padding 18×2 + 边框 2 = 78） */
@media (max-width: 900px) {
  .sheet-card { flex-direction: column; gap: 18px; padding: 18px; overflow: auto; }
  .sheet-card canvas { height: min(52dvh, 440px, calc((100vw - 78px) * 4 / 3)); max-width: 100%; }
  .sheet-side { width: 100%; }
}
/* 长按保存层（微信内置浏览器 / 不支持系统分享的手机） */
.box-card { background: #14181a; border: 1px solid var(--line); border-radius: 20px; padding: 20px; display: flex; flex-direction: column; align-items: center; gap: 14px; max-width: 520px; width: 100%; max-height: calc(100dvh - 40px); overflow: auto; }
.box-card img { max-width: 100%; max-height: calc(100dvh - 150px); width: auto; height: auto; border-radius: 8px; -webkit-touch-callout: default; user-select: auto; }
.box-t { font: 600 16px/1.4 var(--sans); color: var(--gold); }
