/* ============================================================
   八字命理 - Apple Design System
   ============================================================ */

:root {
    --bg-primary: #f2f2f7;
    --bg-secondary: #ffffff;
    --bg-tertiary: #f2f2f7;
    --bg-grouped: #f2f2f7;

    --label-primary: #1c1c1e;
    --label-secondary: #3c3c43cc;
    --label-tertiary: #3c3c4399;
    --label-quaternary: #3c3c4366;

    --separator: #3c3c4349;
    --separator-opaque: #c6c6c8;

    --fill-primary: #78788033;
    --fill-secondary: #78788028;
    --fill-tertiary: #7676801e;

    --blue: #007aff;
    --green: #34c759;
    --orange: #ff9500;
    --red: #ff3b30;
    --purple: #af52de;
    --pink: #ff2d55;
    --teal: #30b0c7;
    --indigo: #5856d6;
    --brown: #a2845e;

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 22px;

    --shadow-sm: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 16px rgba(0,0,0,0.08), 0 2px 6px rgba(0,0,0,0.05);
    --shadow-lg: 0 8px 32px rgba(0,0,0,0.10), 0 4px 12px rgba(0,0,0,0.06);

    --font-sf: -apple-system, 'SF Pro Display', 'SF Pro Text', 'PingFang SC', 'Helvetica Neue', sans-serif;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg-primary: #000000;
        --bg-secondary: #1c1c1e;
        --bg-tertiary: #2c2c2e;
        --label-primary: #ffffff;
        --label-secondary: #ebebf599;
        --label-tertiary: #ebebf566;
        --separator: #54545899;
        --fill-primary: #7878805c;
        --fill-secondary: #78788052;
        --fill-tertiary: #7676803d;
    }
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html {
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: var(--font-sf);
    background: var(--bg-primary);
    min-height: 100vh;
    overflow-x: hidden;
    color: var(--label-primary);
    -webkit-font-smoothing: antialiased;
}

.hidden {
    display: none !important;
}

/* ============================================================
   Page Layout
   ============================================================ */
.page {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ============================================================
   Home Page
   ============================================================ */
#homePage {
    background: var(--bg-primary);
}

.app-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 56px 20px 8px;
    position: relative;
}

.app-icon {
    width: 72px;
    height: 72px;
    background: linear-gradient(145deg, #6e56cf, #4a3ba3);
    border-radius: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 38px;
    box-shadow: var(--shadow-md);
}

.app-title-section {
    text-align: center;
    padding: 16px 20px 8px;
}

.app-title {
    font-size: 34px;
    font-weight: 700;
    letter-spacing: -0.5px;
    color: var(--label-primary);
    line-height: 1.1;
}

.app-subtitle {
    font-size: 15px;
    color: var(--label-secondary);
    margin-top: 6px;
    font-weight: 400;
}

.main-content {
    padding: 20px 16px 40px;
    flex: 1;
}

/* ============================================================
   Grouped List (iOS Settings style)
   ============================================================ */
.form-section {
    margin-bottom: 16px;
}

.form-section-label {
    font-size: 13px;
    font-weight: 400;
    color: var(--label-secondary);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    padding: 0 16px 8px;
}

.list-group {
    background: var(--bg-secondary);
    border-radius: var(--radius-xl);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.list-cell {
    display: flex;
    align-items: center;
    padding: 13px 16px;
    min-height: 52px;
    position: relative;
    background: var(--bg-secondary);
    border: none;
    width: 100%;
    text-align: left;
    cursor: pointer;
    transition: background 0.15s;
}

.list-cell:active {
    background: var(--fill-tertiary);
}

.list-cell + .list-cell::before {
    content: '';
    position: absolute;
    top: 0;
    left: 16px;
    right: 0;
    height: 0.5px;
    background: var(--separator);
}

.cell-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 17px;
    margin-right: 12px;
    flex-shrink: 0;
}

.cell-icon-purple { background: linear-gradient(145deg, #af52de, #6e56cf); }
.cell-icon-blue   { background: linear-gradient(145deg, #007aff, #0051d5); }
.cell-icon-orange { background: linear-gradient(145deg, #ff9500, #ff6b00); }
.cell-icon-pink   { background: linear-gradient(145deg, #ff2d55, #ff6b9d); }
.cell-icon-green  { background: linear-gradient(145deg, #34c759, #248a3d); }

.cell-body {
    flex: 1;
    min-width: 0;
}

.cell-label {
    font-size: 17px;
    font-weight: 400;
    color: var(--label-primary);
    line-height: 1.3;
}

.cell-detail {
    font-size: 15px;
    color: var(--label-secondary);
    margin-top: 1px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cell-value {
    font-size: 17px;
    color: var(--label-secondary);
    margin-right: 6px;
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cell-value.filled {
    color: var(--label-primary);
}

.cell-chevron {
    color: var(--label-quaternary);
    font-size: 14px;
    font-weight: 600;
    flex-shrink: 0;
}

/* ============================================================
   Gender Selector
   ============================================================ */
.gender-row {
    padding: 13px 16px;
    background: var(--bg-secondary);
    display: flex;
    align-items: center;
}

.gender-row .cell-icon {
    flex-shrink: 0;
}

.gender-row .cell-label {
    flex: 1;
    font-size: 17px;
}

.gender-toggle {
    display: flex;
    background: var(--fill-tertiary);
    border-radius: 9px;
    padding: 2px;
    gap: 2px;
}

.gender-toggle-btn {
    padding: 6px 16px;
    border: none;
    border-radius: 7px;
    background: transparent;
    font-size: 15px;
    font-weight: 500;
    color: var(--label-secondary);
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 4px;
}

.gender-toggle-btn.active {
    background: var(--bg-secondary);
    color: var(--label-primary);
    box-shadow: var(--shadow-sm);
}

.gender-toggle-btn .sym {
    font-size: 16px;
}

.gender-toggle-btn[data-gender="male"] .sym { color: #007aff; }
.gender-toggle-btn[data-gender="female"] .sym { color: #ff2d55; }

/* ============================================================
   CTA Button
   ============================================================ */
.cta-section {
    padding: 8px 0 16px;
}

.btn-cta {
    width: 100%;
    padding: 16px;
    background: var(--blue);
    color: #ffffff;
    border: none;
    border-radius: var(--radius-xl);
    font-size: 17px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    letter-spacing: -0.1px;
    box-shadow: 0 4px 20px rgba(0, 122, 255, 0.35);
}

.btn-cta:active {
    transform: scale(0.97);
    box-shadow: 0 2px 10px rgba(0, 122, 255, 0.25);
}

.btn-cta:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    box-shadow: none;
}

.footer-links {
    display: flex;
    justify-content: center;
    gap: 24px;
    padding: 8px 0 16px;
}

.footer-links a {
    font-size: 14px;
    color: var(--blue);
    text-decoration: none;
    font-weight: 400;
}

/* ============================================================
   Name Input (inline)
   ============================================================ */
.name-input {
    flex: 1;
    border: none;
    outline: none;
    background: transparent;
    font-size: 17px;
    color: var(--label-primary);
    font-family: var(--font-sf);
    text-align: right;
    min-width: 0;
}

.name-input::placeholder {
    color: var(--label-quaternary);
}

/* ============================================================
   Modal / Bottom Sheet
   ============================================================ */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    z-index: 1000;
    animation: modal-fade-in 0.25s ease;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

@keyframes modal-fade-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}

.modal-sheet {
    background: var(--bg-secondary);
    width: 100%;
    max-width: 520px;
    border-radius: 20px 20px 0 0;
    padding-bottom: env(safe-area-inset-bottom, 16px);
    animation: sheet-up 0.35s cubic-bezier(0.34, 1.06, 0.64, 1);
    max-height: 90vh;
    display: flex;
    flex-direction: column;
}

@keyframes sheet-up {
    from { transform: translateY(100%); }
    to   { transform: translateY(0); }
}

.sheet-handle {
    width: 36px;
    height: 5px;
    background: var(--separator-opaque);
    border-radius: 3px;
    margin: 10px auto 0;
    flex-shrink: 0;
}

.sheet-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px 8px;
    flex-shrink: 0;
}

.sheet-title {
    font-size: 17px;
    font-weight: 600;
    color: var(--label-primary);
}

.sheet-done-btn {
    background: var(--fill-tertiary);
    border: none;
    color: var(--blue);
    font-size: 17px;
    font-weight: 600;
    padding: 8px 16px;
    border-radius: 20px;
    cursor: pointer;
    font-family: var(--font-sf);
    transition: background 0.15s;
}

.sheet-done-btn:active {
    background: var(--fill-secondary);
}

/* Calendar type tabs */
.seg-control {
    display: flex;
    margin: 0 20px 16px;
    background: var(--fill-tertiary);
    border-radius: 10px;
    padding: 2px;
    flex-shrink: 0;
}

.seg-btn {
    flex: 1;
    padding: 8px;
    border: none;
    border-radius: 8px;
    background: transparent;
    font-size: 15px;
    font-weight: 500;
    color: var(--label-secondary);
    cursor: pointer;
    transition: all 0.2s;
    font-family: var(--font-sf);
}

.seg-btn.active {
    background: var(--bg-secondary);
    color: var(--label-primary);
    box-shadow: var(--shadow-sm);
}

/* Picker rows */
.picker-container {
    display: flex;
    gap: 0;
    flex: 1;
    overflow: hidden;
    padding: 0 12px;
    min-height: 0;
}

.picker {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.picker::-webkit-scrollbar {
    display: none;
}

.picker-item {
    padding: 13px 8px;
    text-align: center;
    cursor: pointer;
    transition: all 0.15s;
    font-size: 16px;
    color: var(--label-primary);
    border-radius: var(--radius-md);
    margin: 1px 2px;
}

.picker-item:active {
    background: var(--fill-tertiary);
}

.picker-item.selected {
    background: var(--blue);
    color: #ffffff;
    font-weight: 600;
    border-radius: var(--radius-md);
}

.sheet-footer {
    padding: 12px 20px 4px;
    flex-shrink: 0;
}

.btn-confirm {
    width: 100%;
    padding: 16px;
    background: var(--blue);
    color: #ffffff;
    border: none;
    border-radius: var(--radius-xl);
    font-size: 17px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-family: var(--font-sf);
}

.btn-confirm:active {
    transform: scale(0.97);
    opacity: 0.85;
}

/* ============================================================
   Loading Page
   ============================================================ */
#loadingPage {
    background: var(--bg-primary);
    align-items: center;
    justify-content: center;
}

.loading-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 40px 20px;
    gap: 36px;
}

/* --- Progress Steps --- */
.progress-steps {
    display: flex;
    align-items: center;
    width: 100%;
    max-width: 320px;
    padding: 0 8px;
}

.progress-step {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.step-dot {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--fill-secondary);
    border: 2.5px solid var(--separator-opaque);
    transition: all 0.4s ease;
    position: relative;
}

.progress-step.active .step-dot {
    background: var(--blue);
    border-color: var(--blue);
    box-shadow: 0 2px 8px rgba(0,122,255,0.35);
}

.progress-step.active .step-dot::after {
    content: '✓';
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 14px;
    font-weight: 700;
}

.progress-step.current .step-dot {
    border-color: var(--blue);
    background: var(--bg-secondary);
    box-shadow: 0 0 0 4px rgba(0,122,255,0.15);
}

.progress-step.current .step-dot::after {
    content: '';
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--blue);
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.step-label {
    font-size: 11px;
    color: var(--label-tertiary);
    white-space: nowrap;
    transition: color 0.3s ease;
}

.progress-step.active .step-label,
.progress-step.current .step-label {
    color: var(--label-primary);
    font-weight: 500;
}

.progress-line {
    flex: 1;
    height: 3px;
    background: var(--fill-secondary);
    border-radius: 2px;
    margin: 0 6px;
    margin-bottom: 24px;
    overflow: hidden;
}

.progress-line-fill {
    height: 100%;
    width: 0%;
    background: var(--blue);
    border-radius: 2px;
    transition: width 0.6s ease;
}

/* --- Taiji & Ring --- */
.loading-visual {
    position: relative;
    width: 120px;
    height: 120px;
}

.loading-ring {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    border: 3px solid var(--fill-primary);
    border-top-color: var(--blue);
    animation: spin 1s linear infinite;
}

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

.loading-icon-center {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 44px;
}

.taiji-spin {
    animation: taiji-rotate 3s linear infinite;
}

@keyframes taiji-rotate {
    from { transform: rotate(0deg); }
    to { transform: rotate(-360deg); }
}

/* SVG 太极图颜色 — 经典黑白，不跟随深色模式 */
.taiji-dark {
    fill: #1a1a1a;
}

.taiji-light {
    fill: #ffffff;
}

/* 首页 app-icon 紫色背景上的太极 — 用纯黑白高对比 */
.app-icon .taiji-dark {
    fill: #1a1a1a;
}

.app-icon .taiji-light {
    fill: #ffffff;
}

/* 加载页太极 — 深色背景上依然黑白 */
.loading-icon-center .taiji-dark {
    fill: #1a1a1a;
}

.loading-icon-center .taiji-light {
    fill: #ffffff;
}

.loading-text-group {
    text-align: center;
}

.loading-title {
    font-size: 22px;
    font-weight: 600;
    color: var(--label-primary);
    margin-bottom: 8px;
}

.loading-subtitle {
    font-size: 15px;
    color: var(--label-secondary);
}

/* ============================================================
   Result Page
   ============================================================ */
#resultPage {
    background: var(--bg-primary);
}

.result-container {
    padding: 16px 16px 40px;
}

.result-section {
    margin-bottom: 32px;
}

.result-section-label {
    font-size: 13px;
    font-weight: 400;
    color: var(--label-secondary);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    padding: 0 4px 8px;
    text-align: center;
}

.result-card {
    background: var(--bg-secondary);
    border-radius: var(--radius-xl);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

/* ---- 基础信息卡片（头像+信息并排） ---- */
.basic-info-card {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 20px;
    padding: 24px 32px;
    background: var(--bg-secondary);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-sm);
}

.basic-info-avatar {
    flex-shrink: 0;
}

.avatar-circle {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
}

.avatar-name {
    font-size: 22px;
    font-weight: 700;
    color: var(--label-primary);
}

.avatar-gender {
    font-size: 18px;
    font-weight: 700;
    line-height: 1;
}

.basic-info-body {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding-top: 2px;
}

.basic-info-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 16px;
    align-items: center;
}

.basic-info-tag {
    font-size: 14px;
    color: var(--label-primary);
    font-weight: 500;
}

.basic-info-text {
    font-size: 14px;
    color: var(--label-secondary);
    line-height: 1.4;
}

/* ---- 八字信息表格（Apple Grouped Table 风格） ---- */
.bazi-table {
    background: var(--bg-secondary);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
}

.bazi-row {
    display: grid;
    grid-template-columns: 52px repeat(4, 1fr);
    min-height: 44px;
    align-items: center;
    border-bottom: 0.5px solid var(--separator);
}

.bazi-row:last-child {
    border-bottom: none;
}

.bazi-header {
    background: transparent;
    min-height: 48px;
}

.bazi-header .bazi-cell {
    border-right: none;
}

.bazi-header-cell {
    color: var(--label-secondary);
    font-weight: 600;
    font-size: 13px;
    text-align: center;
    letter-spacing: 0.5px;
}

.bazi-cell {
    padding: 10px 4px;
    text-align: center;
    color: var(--label-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 3px;
    min-height: 40px;
    border-right: none;
    font-size: 14px;
    font-weight: 400;
}

.bazi-cell:last-child {
    border-right: none;
}

.bazi-label-cell {
    color: var(--label-tertiary);
    font-size: 11px;
    background: transparent;
    font-weight: 500;
    border-right: none;
    letter-spacing: 0.3px;
}

.bazi-header .bazi-label-cell {
    border-right: none;
}

.bazi-nayin-row {
    background: rgba(0, 122, 255, 0.04);
}

.bazi-nayin-row .bazi-cell {
    font-weight: 500;
    color: var(--blue);
    border-right: none;
}

.bazi-nayin-row .bazi-label-cell {
    color: var(--label-tertiary);
    font-weight: 500;
}

.wx-icon {
    font-size: 13px;
    margin-right: 1px;
}

/* 天干行加大字重 */
.bazi-row:nth-child(3) .bazi-cell,
.bazi-row:nth-child(4) .bazi-cell {
    font-size: 20px;
    font-weight: 600;
    letter-spacing: 1px;
}

/* 主星行高亮 */
.bazi-row:nth-child(2) .bazi-cell {
    font-weight: 500;
    color: var(--label-secondary);
    font-size: 13px;
}

/* Info rows inside result-card */
.result-card .info-row {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    min-height: 46px;
    position: relative;
}

.result-card .info-row + .info-row::before {
    content: '';
    position: absolute;
    top: 0;
    left: 16px;
    right: 0;
    height: 0.5px;
    background: var(--separator);
}

.info-label {
    font-size: 15px;
    color: var(--label-secondary);
    min-width: 80px;
    flex-shrink: 0;
}

.info-value {
    font-size: 15px;
    color: var(--label-primary);
    font-weight: 400;
    flex: 1;
    text-align: right;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Wuxing 五行 */
.wuxing-ring {
    display: flex;
    justify-content: space-around;
    padding: 20px 8px;
}

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

.wuxing-circle {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    font-weight: 700;
    color: #fff;
    position: relative;
}

.wuxing-jin   { background: linear-gradient(145deg, #c0c0c0, #a0a0a0); color: #333; }
.wuxing-mu    { background: linear-gradient(145deg, #34c759, #248a3d); }
.wuxing-shui  { background: linear-gradient(145deg, #007aff, #0051d5); }
.wuxing-huo   { background: linear-gradient(145deg, #ff3b30, #c0392b); }
.wuxing-tu    { background: linear-gradient(145deg, #ff9500, #c87900); }

.wuxing-count {
    font-size: 13px;
    color: var(--label-secondary);
    font-weight: 500;
}

.wuxing-tag {
    font-size: 11px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 10px;
}

.tag-like { background: rgba(52, 199, 89, 0.15); color: var(--green); }
.tag-hate { background: rgba(255, 59, 48, 0.12); color: var(--red); }
.tag-neutral { background: rgba(255, 159, 10, 0.12); color: var(--orange); }
.tag-normal { background: var(--fill-tertiary); color: var(--label-tertiary); }

/* Shishen 十神 bar chart */
.shishen-chart {
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.shishen-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.shishen-name {
    font-size: 13px;
    color: var(--label-secondary);
    width: 32px;
    text-align: right;
    flex-shrink: 0;
}

.shishen-track {
    flex: 1;
    height: 8px;
    background: var(--fill-tertiary);
    border-radius: 4px;
    overflow: hidden;
}

.shishen-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.6s cubic-bezier(0.34, 1.06, 0.64, 1);
}

.shishen-val {
    font-size: 12px;
    color: var(--label-tertiary);
    width: 28px;
    text-align: left;
    flex-shrink: 0;
}

/* Rich text card */
.text-card {
    background: var(--bg-secondary);
    border-radius: var(--radius-xl);
    padding: 16px;
    box-shadow: var(--shadow-sm);
    font-size: 15px;
    color: var(--label-primary);
    line-height: 1.75;
}

.text-card strong {
    color: var(--blue);
    font-weight: 600;
}

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

/* References card */
/* ---- 添加道长微信 ---- */
.wechat-cta {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 16px;
    cursor: pointer;
    transition: background 0.2s;
    -webkit-tap-highlight-color: transparent;
}

.wechat-cta:active {
    background: var(--fill-tertiary);
}

.wechat-cta-icon {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: #07c160;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.wechat-cta-text {
    flex: 1;
}

.wechat-cta-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--label-primary);
    margin-bottom: 2px;
}

.wechat-cta-desc {
    font-size: 13px;
    color: var(--label-secondary);
}

.wechat-cta-arrow {
    flex-shrink: 0;
    display: flex;
    align-items: center;
}

/* ---- 二维码弹窗 ---- */
.qrcode-overlay {
    position: fixed;
    inset: 0;
    z-index: 10000;
    background: rgba(0,0,0,0.4);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s;
}

.qrcode-overlay.active {
    opacity: 1;
    visibility: visible;
}

.qrcode-modal {
    width: 300px;
    background: var(--bg-secondary);
    border-radius: var(--radius-xl);
    overflow: hidden;
    transform: scale(0.9);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.qrcode-overlay.active .qrcode-modal {
    transform: scale(1);
}

.qrcode-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 0.5px solid var(--separator);
}

.qrcode-title {
    font-size: 17px;
    font-weight: 600;
    color: var(--label-primary);
}

.qrcode-close {
    width: 28px;
    height: 28px;
    border: none;
    background: var(--fill-primary);
    border-radius: 50%;
    font-size: 16px;
    color: var(--label-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.qrcode-close:active {
    background: var(--fill-secondary);
}

.qrcode-body {
    padding: 24px 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

.qrcode-image {
    width: 220px;
    height: 220px;
    border-radius: var(--radius-md);
    border: 1px solid var(--separator-opaque);
    object-fit: contain;
    background: #fff;
}

.qrcode-tip {
    font-size: 13px;
    color: var(--label-tertiary);
}

/* ============================================================
   Admin Page styles
   ============================================================ */
.admin-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 56px 20px 16px;
    background: rgba(242, 242, 247, 0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    position: sticky;
    top: 0;
    z-index: 10;
}

.admin-nav h1 {
    font-size: 17px;
    font-weight: 600;
    color: var(--label-primary);
}

.admin-container {
    padding: 16px 16px 40px;
    max-width: 900px;
    margin: 0 auto;
}

.stat-cards {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--bg-secondary);
    border-radius: var(--radius-xl);
    padding: 20px 16px;
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.stat-icon {
    font-size: 28px;
    line-height: 1;
}

.stat-number {
    font-size: 32px;
    font-weight: 700;
    color: var(--blue);
    letter-spacing: -0.5px;
    line-height: 1;
}

.stat-label {
    font-size: 13px;
    color: var(--label-secondary);
}

.chart-section {
    background: var(--bg-secondary);
    border-radius: var(--radius-xl);
    padding: 20px;
    margin-bottom: 16px;
    box-shadow: var(--shadow-sm);
}

.chart-section-title {
    font-size: 17px;
    font-weight: 600;
    color: var(--label-primary);
    margin-bottom: 16px;
}

/* Gender pie */
.pie-wrap {
    display: flex;
    align-items: center;
    gap: 24px;
}

.pie-svg {
    width: 100px;
    height: 100px;
    flex-shrink: 0;
}

.pie-legend {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: var(--label-primary);
}

.legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

/* Wuxing bar chart (admin) */
.wx-bars {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.wx-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.wx-label {
    font-size: 14px;
    font-weight: 600;
    width: 24px;
    text-align: center;
    flex-shrink: 0;
}

.wx-track {
    flex: 1;
    height: 10px;
    background: var(--fill-tertiary);
    border-radius: 5px;
    overflow: hidden;
}

.wx-fill {
    height: 100%;
    border-radius: 5px;
    transition: width 0.6s cubic-bezier(0.34, 1.06, 0.64, 1);
}

.wx-count {
    font-size: 13px;
    color: var(--label-tertiary);
    width: 36px;
    text-align: right;
    flex-shrink: 0;
}

/* Record list */
.records-section {
    background: var(--bg-secondary);
    border-radius: var(--radius-xl);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.records-header {
    padding: 16px 16px 12px;
    border-bottom: 0.5px solid var(--separator);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.records-title {
    font-size: 17px;
    font-weight: 600;
    color: var(--label-primary);
}

.record-item {
    padding: 16px;
    position: relative;
    transition: background 0.15s;
}

.record-item + .record-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: 16px;
    right: 0;
    height: 0.5px;
    background: var(--separator);
}

.record-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.record-name {
    font-size: 17px;
    font-weight: 600;
    color: var(--label-primary);
}

.record-time {
    font-size: 13px;
    color: var(--label-tertiary);
}

.record-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 10px;
}

.meta-chip {
    font-size: 13px;
    color: var(--label-secondary);
    background: var(--fill-tertiary);
    padding: 4px 10px;
    border-radius: 20px;
}

.record-bazi {
    font-size: 16px;
    font-weight: 600;
    color: var(--purple);
    letter-spacing: 2px;
    margin-bottom: 10px;
}

.btn-delete {
    background: rgba(255, 59, 48, 0.1);
    color: var(--red);
    border: none;
    padding: 8px 18px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
    font-family: var(--font-sf);
}

.btn-delete:active {
    background: rgba(255, 59, 48, 0.2);
    transform: scale(0.96);
}

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--label-tertiary);
    font-size: 15px;
}

.empty-state-icon {
    font-size: 48px;
    margin-bottom: 16px;
    display: block;
}

.loading-state {
    text-align: center;
    padding: 40px;
    color: var(--label-secondary);
    font-size: 15px;
}

/* ============================================================
   Date Verify Page
   ============================================================ */
.verify-container {
    max-width: 680px;
    margin: 0 auto;
    padding: 16px 16px 40px;
}

.page-hero {
    padding: 56px 16px 24px;
    text-align: center;
}

.page-hero-title {
    font-size: 28px;
    font-weight: 700;
    color: var(--label-primary);
    margin-bottom: 8px;
}

.page-hero-sub {
    font-size: 15px;
    color: var(--label-secondary);
}

.verify-nav-links {
    display: flex;
    gap: 12px;
    padding: 0 16px 16px;
    justify-content: center;
}

.verify-nav-links a {
    color: var(--blue);
    text-decoration: none;
    font-size: 15px;
    padding: 8px 16px;
    background: var(--bg-secondary);
    border-radius: 20px;
    box-shadow: var(--shadow-sm);
    transition: all 0.15s;
}

.verify-nav-links a:active {
    opacity: 0.7;
}

/* ============================================================
   Inline form fields for verify page
   ============================================================ */
.field-row {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    min-height: 46px;
    position: relative;
}

.field-row + .field-row::before {
    content: '';
    position: absolute;
    top: 0;
    left: 16px;
    right: 0;
    height: 0.5px;
    background: var(--separator);
}

.field-label {
    font-size: 15px;
    color: var(--label-primary);
    min-width: 90px;
    flex-shrink: 0;
}

.field-input {
    flex: 1;
    border: none;
    outline: none;
    background: transparent;
    font-size: 15px;
    color: var(--label-primary);
    font-family: var(--font-sf);
    text-align: right;
}

.field-input:focus {
    color: var(--blue);
}

.field-select {
    flex: 1;
    border: none;
    outline: none;
    background: transparent;
    font-size: 15px;
    color: var(--label-primary);
    font-family: var(--font-sf);
    text-align: right;
    -webkit-appearance: none;
    appearance: none;
    cursor: pointer;
}

.field-hint {
    font-size: 12px;
    color: var(--label-tertiary);
    padding: 6px 16px 12px;
}

.checkbox-field {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    font-size: 15px;
    color: var(--label-primary);
}

.btn-group {
    display: flex;
    gap: 10px;
    padding: 8px 0;
}

.btn-group .btn-main {
    flex: 1;
    padding: 14px;
    background: var(--blue);
    color: #fff;
    border: none;
    border-radius: var(--radius-xl);
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    font-family: var(--font-sf);
    transition: all 0.2s;
}

.btn-group .btn-ghost {
    padding: 14px 20px;
    background: var(--fill-tertiary);
    color: var(--label-primary);
    border: none;
    border-radius: var(--radius-xl);
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    font-family: var(--font-sf);
    transition: all 0.2s;
}

/* Verify result */
.verify-result {
    background: var(--bg-secondary);
    border-radius: var(--radius-xl);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    margin-bottom: 16px;
}

.verify-banner {
    padding: 20px 16px;
    display: flex;
    align-items: center;
    gap: 16px;
}

.verify-banner-icon {
    font-size: 40px;
    flex-shrink: 0;
}

.verify-banner-text h3 {
    font-size: 17px;
    font-weight: 600;
    margin-bottom: 4px;
}

.verify-banner-text p {
    font-size: 14px;
    opacity: 0.8;
}

.banner-success { background: rgba(52, 199, 89, 0.12); }
.banner-success h3 { color: var(--green); }
.banner-error   { background: rgba(255, 59, 48, 0.10); }
.banner-error h3 { color: var(--red); }

.quick-tools-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.quick-tool-card {
    background: var(--bg-secondary);
    border-radius: var(--radius-xl);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.quick-tool-title {
    font-size: 15px;
    font-weight: 600;
    padding: 14px 16px 8px;
    color: var(--label-primary);
    border-bottom: 0.5px solid var(--separator);
}

.quick-result {
    padding: 12px 16px;
    font-size: 14px;
    color: var(--label-secondary);
    min-height: 44px;
}

.quick-result strong {
    color: var(--blue);
}

/* Tools inputs for quick convert */
.tool-inputs-wrap {
    padding: 12px 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.tool-field {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 0;
    border-bottom: 0.5px solid var(--separator);
}

.tool-field:last-child { border-bottom: none; }

.tool-field label {
    font-size: 13px;
    color: var(--label-secondary);
    width: 50px;
    flex-shrink: 0;
}

.tool-field input,
.tool-field select {
    flex: 1;
    border: none;
    outline: none;
    background: transparent;
    font-size: 14px;
    color: var(--label-primary);
    font-family: var(--font-sf);
    text-align: right;
}

.tool-field-action {
    padding: 10px 16px;
}

.btn-tool {
    width: 100%;
    padding: 12px;
    background: var(--blue);
    color: #fff;
    border: none;
    border-radius: var(--radius-md);
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    font-family: var(--font-sf);
}

/* Instructions */
.instructions-list {
    list-style: none;
    font-size: 14px;
    color: var(--label-secondary);
}

.instructions-list li {
    padding: 10px 16px;
    border-bottom: 0.5px solid var(--separator);
    line-height: 1.5;
}

.instructions-list li:last-child { border-bottom: none; }

.instructions-list strong {
    color: var(--label-primary);
}

/* ============================================================
   Login Page styles
   ============================================================ */
.login-page {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: var(--bg-primary);
    padding: 40px 24px;
}

.login-logo {
    font-size: 64px;
    margin-bottom: 16px;
    animation: login-pulse 2s ease-in-out infinite;
}

@keyframes login-pulse {
    0%, 100% { transform: scale(1); opacity: 0.9; }
    50% { transform: scale(1.06); opacity: 1; }
}

.login-title {
    font-size: 28px;
    font-weight: 700;
    color: var(--label-primary);
    margin-bottom: 6px;
    letter-spacing: -0.5px;
}

.login-subtitle {
    font-size: 15px;
    color: var(--label-tertiary);
    margin-bottom: 40px;
}

.login-card {
    width: 100%;
    max-width: 400px;
    background: var(--bg-secondary);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-md);
    overflow: hidden;
}

.login-form {
    padding: 28px 24px 24px;
}

.login-field {
    margin-bottom: 16px;
}

.login-field:last-of-type {
    margin-bottom: 24px;
}

.login-label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--label-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.login-input {
    width: 100%;
    padding: 14px 16px;
    font-size: 17px;
    font-family: var(--font-sf);
    color: var(--label-primary);
    background: var(--bg-tertiary);
    border: 1px solid var(--separator-opaque);
    border-radius: var(--radius-md);
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
    -webkit-appearance: none;
}

.login-input::placeholder {
    color: var(--label-quaternary);
}

.login-input:focus {
    border-color: var(--blue);
    box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.15);
}

.login-btn {
    width: 100%;
    padding: 16px;
    font-size: 17px;
    font-weight: 600;
    font-family: var(--font-sf);
    color: #ffffff;
    background: var(--blue);
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: opacity 0.15s, transform 0.1s;
    -webkit-appearance: none;
}

.login-btn:active {
    opacity: 0.85;
    transform: scale(0.98);
}

.login-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.login-error {
    display: none;
    text-align: center;
    font-size: 14px;
    color: var(--red);
    padding: 12px 16px;
    background: rgba(255, 59, 48, 0.08);
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
    animation: shake 0.4s ease;
}

.login-error.show {
    display: block;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20%, 60% { transform: translateX(-6px); }
    40%, 80% { transform: translateX(6px); }
}

.login-footer {
    text-align: center;
    margin-top: 24px;
    font-size: 13px;
    color: var(--label-quaternary);
}

.login-footer a {
    color: var(--blue);
    text-decoration: none;
}

/* ============================================================
   Responsive
   ============================================================ */
@media (min-width: 600px) {
    .main-content {
        padding: 24px 20px 60px;
    }

    .result-container {
        max-width: 600px;
        margin: 0 auto;
    }

    .quick-tools-grid {
        grid-template-columns: 1fr 1fr;
    }
}

@media (max-width: 480px) {
    .quick-tools-grid {
        grid-template-columns: 1fr;
    }
}

@media (min-width: 900px) {
    .stat-cards {
        grid-template-columns: repeat(4, 1fr);
    }
}
