/* ============================================
   RESET & BASE
   ============================================ */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

:root {
    /* ── Rainbow palette (from rainbow.jpg top→bottom) ── */
    --rb-red:    #e82020;
    --rb-orange: #f07820;
    --rb-yellow: #d8b800;
    --rb-green:  #28a840;
    --rb-cyan:   #1898d8;
    --rb-blue:   #1868c8;
    --rb-indigo: #2838b8;
    --rb-violet: #7828a0;

    /* Backgrounds — pure white with rainbow shimmer */
    --bg-deep:       #fdf6ff;
    --bg-mid:        #f6eeff;
    --bg-card:       rgba(255, 255, 255, 0.82);
    --bg-card-hover: rgba(255, 255, 255, 0.97);
    --bg-input:      rgba(255, 255, 255, 0.70);
    --bg-input-focus:rgba(255, 255, 255, 0.98);

    /* Semantic accent aliases */
    --gold:       #f07820;   /* orange */
    --gold-light: #f5a030;
    --blue:       #1868c8;
    --blue-light: #4898e0;
    --green:      #e04878;   /* kept as "warm rose" for legacy refs */
    --green-dim:  rgba(224, 72, 120, 0.12);
    --red:        #e82020;
    --red-dim:    rgba(232, 32, 32, 0.12);
    --purple:     #7828a0;
    --peach:      #f09060;
    --pink:       #e04878;

    --text-primary:  #1a083a;
    --text-secondary:#6040a0;
    --text-dim:      #a090c0;
    --border:        rgba(100, 60, 180, 0.14);
    --border-bright: rgba(100, 60, 180, 0.30);

    /* Spacing */
    --space-xs:  6px;
    --space-sm:  10px;
    --space-md:  16px;
    --space-lg:  24px;
    --space-xl:  32px;

    /* Radii */
    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 20px;

    /* Shadows */
    --shadow-sm: 0 2px 12px rgba(60, 20, 120, 0.08);
    --shadow-md: 0 4px 28px rgba(60, 20, 120, 0.13);
    --shadow-lg: 0 10px 48px rgba(60, 20, 120, 0.20);

    /* Safe area */
    --safe-top:    env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
}

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

body {
    font-family: -apple-system, 'SF Pro Text', 'PingFang SC', 'Helvetica Neue', Arial, sans-serif;
    background-color: var(--bg-deep);
    background-image:
        radial-gradient(ellipse 90% 40% at  0%   0%, rgba(232,  32,  32, 0.07) 0%, transparent 60%),
        radial-gradient(ellipse 70% 35% at 100%  0%, rgba(240, 120,  32, 0.06) 0%, transparent 55%),
        radial-gradient(ellipse 55% 28% at  50% 22%, rgba(216, 184,   0, 0.05) 0%, transparent 58%),
        radial-gradient(ellipse 65% 32% at   0% 62%, rgba( 40, 168,  64, 0.05) 0%, transparent 55%),
        radial-gradient(ellipse 75% 38% at 100% 80%, rgba( 24, 104, 200, 0.07) 0%, transparent 55%),
        radial-gradient(ellipse 55% 35% at  25% 100%,rgba(120,  40, 160, 0.08) 0%, transparent 50%);
    min-height: 100vh;
    min-height: -webkit-fill-available;
    color: var(--text-primary);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
}

/* ============================================
   APP SHELL
   ============================================ */
.app-shell {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-height: -webkit-fill-available;
}

/* ============================================
   HEADER
   ============================================ */
.app-header {
    position: relative;
    padding: calc(var(--safe-top) + 20px) var(--space-lg) var(--space-lg);
    flex-shrink: 0;
    overflow: hidden;
}

.header-glow {
    position: absolute;
    top: -40px;
    left: 50%;
    transform: translateX(-50%);
    width: 280px;
    height: 130px;
    background: radial-gradient(ellipse, rgba(212, 149, 106, 0.28) 0%, transparent 70%);
    pointer-events: none;
}

.header-content {
    display: flex;
    align-items: center;
    gap: var(--space-md);
}

.app-icon {
    width: 44px;
    height: 44px;
    flex-shrink: 0;
}

.app-icon svg {
    width: 100%;
    height: 100%;
}

.app-title {
    font-size: 26px;
    font-weight: 700;
    letter-spacing: 0.02em;
    background: linear-gradient(90deg,
        #e82020 0%,
        #f07820 17%,
        #d8b800 33%,
        #28a840 50%,
        #1868c8 67%,
        #2838b8 83%,
        #7828a0 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    line-height: 1.1;
}

.app-subtitle {
    font-size: 12px;
    color: var(--text-secondary);
    letter-spacing: 0.05em;
    margin-top: 2px;
}

/* ============================================
   MAIN SCROLL
   ============================================ */
.app-main {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 0 var(--space-md) 0;
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}

/* ============================================
   PERSON CARD
   ============================================ */
.person-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    box-shadow: var(--shadow-sm);
}

.card-label {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.08em;
    color: var(--text-secondary);
    text-transform: uppercase;
    margin-bottom: var(--space-lg);
}

.card-label-dot {
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    flex-shrink: 0;
}

.dot-gold  { background: var(--gold); box-shadow: 0 0 6px var(--gold); }
.dot-blue  { background: var(--blue); box-shadow: 0 0 6px var(--blue); }

.optional-badge {
    margin-left: auto;
    font-size: 10px;
    font-weight: 500;
    letter-spacing: 0.04em;
    color: var(--text-dim);
    background: rgba(255,255,255,0.06);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 1px 6px;
    text-transform: none;
}

/* ============================================
   FIELDS
   ============================================ */
.field-row {
    margin-bottom: var(--space-md);
}

.field-group {
    margin-bottom: var(--space-md);
}

.field-group:last-child {
    margin-bottom: 0;
}

.field-label {
    display: block;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: var(--space-xs);
    letter-spacing: 0.02em;
}

.field-label-dim {
    color: var(--text-dim);
}

.auto-badge {
    font-size: 10px;
    font-weight: 500;
    color: var(--gold);
    background: rgba(196, 162, 97, 0.12);
    border: 1px solid rgba(196, 162, 97, 0.25);
    border-radius: 4px;
    padding: 1px 5px;
    margin-left: 4px;
    vertical-align: middle;
}

.field-input {
    width: 100%;
    height: 44px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 15px;
    font-family: inherit;
    padding: 0 var(--space-md);
    outline: none;
    -webkit-appearance: none;
    transition: border-color 0.15s, background 0.15s;
}

.field-input:focus {
    border-color: var(--gold);
    background: var(--bg-input-focus);
    box-shadow: 0 0 0 3px rgba(212, 149, 106, 0.14);
}

.field-input::placeholder {
    color: var(--text-dim);
}

/* ============================================
   DATE INPUTS
   ============================================ */
.date-row {
    display: flex;
    gap: var(--space-xs);
    align-items: stretch;
}

.date-field {
    display: flex;
    align-items: center;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    overflow: hidden;
    flex: 2;
    height: 42px;
    transition: border-color 0.15s, background 0.15s;
}

.date-field-sm {
    flex: 1;
}

.date-field:focus-within {
    border-color: var(--gold);
    background: var(--bg-input-focus);
}

.date-input {
    flex: 1;
    min-width: 0;
    height: 100%;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 14px;
    font-family: inherit;
    padding: 0 4px 0 var(--space-xs);
    outline: none;
    -webkit-appearance: none;
    -moz-appearance: textfield;
    text-align: center;
}

.date-input::-webkit-inner-spin-button,
.date-input::-webkit-outer-spin-button {
    -webkit-appearance: none;
}

.date-input::placeholder {
    color: var(--text-dim);
    font-size: 12px;
}

.date-unit {
    font-size: 11px;
    color: var(--text-dim);
    padding-right: 5px;
    flex-shrink: 0;
    user-select: none;
}

.date-input-readonly {
    color: var(--text-secondary);
    font-size: 13px;
}

.lunar-group .date-field {
    border-color: transparent;
    background: rgba(255,255,255,0.03);
}

.lunar-group .date-field:focus-within {
    border-color: transparent;
}

/* ============================================
   DATE/TIME PICKERS (native)
   ============================================ */
.picker-group {
    margin-bottom: var(--space-md);
}

.picker-row-label {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: var(--space-xs);
    letter-spacing: 0.02em;
}

.date-time-row {
    display: flex;
    gap: var(--space-xs);
}



/* Three-part date input */
.date-parts-group {
    flex: 3;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 2px;
    height: 44px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0 var(--space-sm);
    transition: border-color 0.15s, background 0.15s;
}

.date-parts-group:focus-within {
    border-color: var(--gold);
    background: var(--bg-input-focus);
    box-shadow: 0 0 0 3px rgba(212, 149, 106, 0.14);
}

.date-part-sep {
    color: var(--text-dim);
    font-size: 14px;
    user-select: none;
    flex-shrink: 0;
}

.date-part-input {
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-size: 15px;
    font-family: inherit;
    font-variant-numeric: tabular-nums;
    text-align: center;
    padding: 0;
    min-width: 0;
    -webkit-appearance: none;
}

.date-part-input::placeholder {
    color: var(--text-dim);
}

.date-part-input.year-input  { width: 44px; }
.date-part-input.month-input { width: 26px; }
.date-part-input.day-input   { width: 26px; }

.cal-btn {
    margin-left: auto;
    flex-shrink: 0;
    background: none;
    border: none;
    padding: 4px;
    color: var(--text-dim);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.15s;
}

.cal-btn:active { color: var(--gold-light); }

/* Two-part time input */
.time-parts-group {
    flex: 2;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 2px;
    height: 44px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0 var(--space-sm);
    transition: border-color 0.15s, background 0.15s;
}

.time-parts-group:focus-within {
    border-color: var(--gold);
    background: var(--bg-input-focus);
}

.time-part-sep {
    color: var(--text-dim);
    font-size: 14px;
    user-select: none;
    flex-shrink: 0;
}

.time-part-input {
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-size: 15px;
    font-family: inherit;
    font-variant-numeric: tabular-nums;
    text-align: center;
    padding: 0;
    min-width: 0;
    -webkit-appearance: none;
}

.time-part-input::placeholder {
    color: var(--text-dim);
}

.time-part-input.hour-input { width: 28px; }
.time-part-input.min-input  { width: 28px; }

/* Hidden native date/time picker — off-screen but still interactive for showPicker() */
.cal-btn-wrap {
    position: relative;
    display: inline-flex;
}

.date-picker-overlay {
    position: absolute;
    inset: 0;
    opacity: 0;
    width: 100%;
    height: 100%;
    cursor: pointer;
    z-index: 1;
}

/* Lunar auto-display row */
.lunar-display-row {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    background: rgba(138, 170, 200, 0.08);
    border: 1px solid rgba(138, 170, 200, 0.22);
    border-radius: var(--radius-sm);
    padding: var(--space-xs) var(--space-sm);
    margin-top: var(--space-xs);
}

.lunar-row-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--blue);
    white-space: nowrap;
    flex-shrink: 0;
    opacity: 0.8;
}

.lunar-row-value {
    font-size: 13px;
    font-weight: 700;
    color: var(--blue);
    margin-left: auto;
    text-align: right;
    font-variant-numeric: tabular-nums;
}

/* Add / Remove person buttons */
.add-person-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-xs);
    width: 100%;
    height: 44px;
    background: transparent;
    border: 1px dashed var(--border);
    border-radius: var(--radius-lg);
    color: var(--text-secondary);
    font-size: 14px;
    font-family: inherit;
    cursor: pointer;
    transition: border-color 0.15s, color 0.15s;
}

.add-person-btn:active {
    border-color: var(--gold);
    color: var(--gold);
}

.add-person-icon {
    font-size: 18px;
    line-height: 1;
}

.remove-person-btn {
    margin-left: auto;
    background: transparent;
    border: none;
    color: var(--text-dim);
    font-size: 14px;
    cursor: pointer;
    padding: 2px 4px;
    line-height: 1;
}

.remove-person-btn:active {
    color: var(--text-secondary);
}

/* ============================================
   ERROR CARD
   ============================================ */
.error-card {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    background: rgba(248, 113, 113, 0.1);
    border: 1px solid rgba(248, 113, 113, 0.25);
    border-radius: var(--radius-md);
    padding: var(--space-md);
}

.error-icon {
    font-size: 18px;
    flex-shrink: 0;
}

.error-body {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-sm);
}

.error-msg {
    font-size: 13px;
    color: var(--red);
    flex: 1;
}

.swap-btn {
    flex-shrink: 0;
    background: rgba(248, 113, 113, 0.2);
    border: 1px solid rgba(248, 113, 113, 0.4);
    border-radius: var(--radius-sm);
    color: var(--red);
    font-size: 12px;
    font-weight: 600;
    font-family: inherit;
    padding: 6px 12px;
    cursor: pointer;
    transition: background 0.15s;
}

.swap-btn:active {
    background: rgba(248, 113, 113, 0.3);
}

/* ============================================
   GENERATE BUTTON
   ============================================ */
.generate-btn {
    width: 100%;
    height: 54px;
    background: linear-gradient(90deg, #e82020 0%, #f07820 30%, #28a840 60%, #1868c8 80%, #7828a0 100%);
    border: none;
    border-radius: var(--radius-md);
    color: #fff;
    font-size: 16px;
    font-weight: 700;
    font-family: inherit;
    letter-spacing: 0.04em;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    box-shadow:
        0 6px 28px rgba(120, 40, 160, 0.35),
        0 1px 0 rgba(255,255,255,0.22) inset;
    transition: transform 0.12s, box-shadow 0.12s, opacity 0.12s;
    -webkit-user-select: none;
    user-select: none;
}

.generate-btn:active {
    transform: scale(0.98);
    box-shadow: 0 2px 10px rgba(120, 40, 160, 0.25);
    opacity: 0.92;
}

.generate-btn-icon {
    font-size: 18px;
    font-weight: 400;
    opacity: 0.7;
}

/* ============================================
   LOADING
   ============================================ */
.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(250, 240, 235, 0.80);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--space-md);
    z-index: 100;
}

.loading-spinner {
    width: 36px;
    height: 36px;
    border: 2px solid rgba(224, 120, 128, 0.2);
    border-top-color: var(--red);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

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

.loading-text {
    font-size: 13px;
    color: var(--text-secondary);
    letter-spacing: 0.04em;
}

/* ============================================
   RESULTS
   ============================================ */
.results-section {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
    animation: results-appear 0.4s ease both;
}

@keyframes results-appear {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* Layout containers generated by app.js */
.two-person-layout,
.person-results {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}

/* ---- Row wrappers ---- */
.birth-info-row,
.tree-diagram-row,
.annual-tables-row {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}

.relationship-chart-row,
.relationship-timeline-row {
    width: 100%;
}

/* ============================================
   SECTION CARD (shared wrapper)
   ============================================ */
.detailed-birth-info,
.tree-diagram,
.annual-tables,
.timeline-section,
.relationship-chart,
.relationship-timeline {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    box-shadow: var(--shadow-md);
    overflow: hidden;
}

.annual-tables-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(212,149,106,0.06);
    border: 1px solid rgba(212,149,106,0.20);
    border-radius: var(--radius-sm);
    padding: 10px var(--space-md);
    cursor: pointer;
    width: 100%;
    text-align: left;
    -webkit-tap-highlight-color: transparent;
    transition: background 0.15s, border-color 0.15s;
}

.annual-tables-toggle:active {
    background: rgba(212,149,106,0.12);
}

.toggle-label {
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--gold);
    flex: 1;
}

.toggle-meta {
    font-size: 10px;
    font-weight: 600;
    color: var(--text-dim);
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.02em;
}

.toggle-chevron {
    font-size: 13px;
    color: var(--gold);
    opacity: 0.65;
    line-height: 1;
    flex-shrink: 0;
}

.toggle-person {
    font-size: 11px;
    font-weight: 700;
    color: var(--text-secondary);
    opacity: 0.8;
}

.annual-tables-content {
    margin-top: var(--space-md);
}

.tree-diagram {
    display: flex;
    flex-direction: column;
    align-items: center;
    overflow: visible; /* triangle nodes extend to edges — must not clip */
}

.section-person-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-top: -6px;
    margin-bottom: var(--space-sm);
    opacity: 0.75;
}

/* ---- Section h3 — vivid full-bleed color bars ---- */
.detailed-birth-info h3,
.tree-diagram h3,
.annual-tables h3,
.timeline-section h3,
.timeline-title,
.relationship-chart h3,
.relationship-timeline h3 {
    font-size: 13px;
    font-weight: 900;
    letter-spacing: 0.10em;
    text-transform: uppercase;
    color: #fff;
    -webkit-text-fill-color: #fff;
    background: none;
    -webkit-background-clip: unset;
    background-clip: unset;
    margin: calc(-1 * var(--space-lg)) calc(-1 * var(--space-lg)) var(--space-md);
    padding: 10px var(--space-lg) 10px calc(var(--space-lg) + 6px);
    border-bottom: none;
    display: flex;
    align-items: center;
    gap: 8px;
    position: relative;
    overflow: hidden;
}

.detailed-birth-info h3::before,
.tree-diagram h3::before,
.annual-tables h3::before,
.timeline-section h3::before,
.relationship-chart h3::before,
.relationship-timeline h3::before {
    content: '';
    display: block;
    width: 4px;
    height: 16px;
    background: rgba(255,255,255,0.55);
    border-radius: 3px;
    flex-shrink: 0;
    -webkit-background-clip: unset;
    background-clip: unset;
    -webkit-text-fill-color: unset;
}

/* Per-section rainbow colors */
.detailed-birth-info h3 {
    background: linear-gradient(90deg, #c81810, #f07020);  /* red → orange */
}
.tree-diagram h3 {
    background: linear-gradient(90deg, #1a8828, #50b840);  /* green */
}
.annual-tables h3 {
    background: linear-gradient(90deg, #0858b8, #2888e0);  /* blue */
}
.relationship-chart h3 {
    background: linear-gradient(90deg, #6018a0, #9840c8);  /* violet */
}
.relationship-timeline h3 {
    background: linear-gradient(90deg, #2030b0, #4858d8);  /* indigo */
}
.timeline-section h3,
.timeline-title {
    background: linear-gradient(90deg, #2030b0, #4858d8);  /* indigo */
}

/* ============================================
   BIRTH INFO TABLE
   ============================================ */
.birth-info-table {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}

.birth-table {
    overflow: hidden;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}

.birth-table.solar-table {
    border-left: 3px solid var(--gold);
}

.birth-table.lunar-table {
    border-left: 3px solid var(--blue);
}

.table-header {
    padding: var(--space-sm) var(--space-md);
    border-bottom: 1px solid var(--border);
}

.solar-table .table-header {
    background: linear-gradient(90deg, rgba(212,149,106,0.15), rgba(244,230,222,0.35));
}

.lunar-table .table-header {
    background: linear-gradient(90deg, rgba(138,170,200,0.15), rgba(244,230,222,0.35));
}

.table-header h4 {
    font-size: 11px;
    font-weight: 700;
    color: var(--text-secondary);
    letter-spacing: 0.05em;
    font-variant-numeric: tabular-nums;
}

.birth-calculation-table {
    width: 100%;
    table-layout: fixed;
    border-collapse: collapse;
    font-size: 11px;
}

.birth-calculation-table th,
.birth-calculation-table td {
    padding: 7px 2px;
    text-align: center;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
    overflow: hidden;
}

.birth-calculation-table th {
    background: rgba(244,230,222,0.55);
    color: var(--text-dim);
    font-weight: 700;
    font-size: 10px;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.birth-calculation-table td {
    color: var(--text-primary);
}

.birth-calculation-table tr:nth-child(odd) td {
    background: rgba(255,255,255,0.35);
}

.birth-calculation-table tr:nth-child(even) td {
    background: rgba(244,230,222,0.20);
}

.birth-calculation-table tr:last-child td {
    border-bottom: none;
}

/* Label column is wider; data columns share remaining space equally */
.birth-calculation-table th:first-child,
.birth-calculation-table td:first-child {
    width: 22%;
    text-align: left;
    padding-left: 8px;
}

/* ---- 日 column (4th) — most prominent ---- */
.birth-calculation-table th:nth-child(4) {
    background: linear-gradient(135deg, #e82020, #f07820) !important;
    color: #fff !important;
    font-size: 12px;
    font-weight: 900;
    letter-spacing: 0.06em;
    text-shadow: 0 1px 3px rgba(0,0,0,0.20);
}
.birth-calculation-table td:nth-child(4) {
    background: rgba(232, 32, 32, 0.07) !important;
    font-weight: 700;
}
.birth-calculation-table tr:nth-child(odd) td:nth-child(4) {
    background: rgba(232, 32, 32, 0.11) !important;
}
.birth-calculation-table tr:nth-child(even) td:nth-child(4) {
    background: rgba(232, 32, 32, 0.05) !important;
}
.birth-calculation-table td.master-cell:nth-child(4) {
    font-size: 30px !important;
    color: var(--rb-orange) !important;
    text-shadow: 0 0 18px rgba(240,120,32,0.45);
}

.birth-calculation-table td.label-cell {
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 10px;
    letter-spacing: 0.02em;
    white-space: nowrap;
}

.birth-calculation-table td.date-cell {
    font-weight: 500;
    font-size: 12px;
    font-variant-numeric: tabular-nums;
}

.birth-calculation-table td.post-heaven-cell {
    color: var(--text-secondary);
    font-size: 11px;
    font-variant-numeric: tabular-nums;
}

.birth-calculation-table tr:has(td.master-cell) {
    background: rgba(212,130,74,0.09) !important;
}

.birth-calculation-table td.master-cell {
    font-weight: 900;
    font-size: 26px;
    color: var(--gold-light);
    letter-spacing: -0.01em;
    text-shadow: 0 0 12px rgba(240,184,64,0.30);
}

.birth-calculation-table td.soul-cell {
    font-weight: 700;
    font-size: 13px;
}

.soul-circle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    font-size: 13px;
    font-weight: 800;
    border: 1.5px solid currentColor;
    background: transparent;
    box-shadow: 0 0 8px rgba(0,0,0,0.05);
}

.soul-circle-empty {
    opacity: 0.22;
    color: var(--text-dim);
    border-color: var(--text-dim);
}

/* Soul level colors — one per rainbow band */
.soul-level-1 .soul-circle, td.soul-cell.soul-level-1 { color: var(--rb-red); }
.soul-level-2 .soul-circle, td.soul-cell.soul-level-2 { color: var(--rb-orange); }
.soul-level-3 .soul-circle, td.soul-cell.soul-level-3 { color: var(--rb-yellow); }
.soul-level-4 .soul-circle, td.soul-cell.soul-level-4 { color: var(--rb-green); }
.soul-level-5 .soul-circle, td.soul-cell.soul-level-5 { color: var(--rb-cyan); }
.soul-level-6 .soul-circle, td.soul-cell.soul-level-6 { color: var(--rb-blue); }
.soul-level-7 .soul-circle, td.soul-cell.soul-level-7 { color: var(--rb-violet); }

/* Subtle level-specific fill */
.soul-level-1 .soul-circle { background: rgba(232, 32,  32, 0.10); }
.soul-level-2 .soul-circle { background: rgba(240,120,  32, 0.10); }
.soul-level-3 .soul-circle { background: rgba(216,184,   0, 0.10); }
.soul-level-4 .soul-circle { background: rgba( 40,168,  64, 0.10); }
.soul-level-5 .soul-circle { background: rgba( 24,152, 216, 0.10); }
.soul-level-6 .soul-circle { background: rgba( 24,104, 200, 0.10); }
.soul-level-7 .soul-circle { background: rgba(120, 40, 160, 0.10); }

/* ============================================
   MAIN NUMBER (主命数) DESCRIPTION PANEL
   ============================================ */
.main-number-desc-panel {
    margin-top: var(--space-lg);
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.mnd-title {
    font-size: 13px;
    font-weight: 800;
    color: var(--gold);
    letter-spacing: 0.04em;
    margin-bottom: 2px;
    padding-left: 2px;
}

.mnd-subtitle {
    font-size: 11px;
    font-weight: 400;
    color: var(--text-dim);
    letter-spacing: 0;
}

.mnd-block {
    border-radius: 10px;
    overflow: hidden;
    background: rgba(255,255,255,0.55);
    border: 1px solid rgba(0,0,0,0.07);
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}

.mnd-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 14px;
    font-weight: 700;
    font-size: 12px;
}

.mnd-num-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    font-size: 16px;
    font-weight: 900;
    color: #fff;
    flex-shrink: 0;
}

.mnd-label {
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.03em;
}

/* Per-number accent colors (reuse rainbow palette) */
.mnd-num-1 .mnd-header { background: linear-gradient(90deg, #c81010, #e83030); }  /* red */
.mnd-num-2 .mnd-header { background: linear-gradient(90deg, #c86010, #f07820); }  /* orange */
.mnd-num-3 .mnd-header { background: linear-gradient(90deg, #a89000, #d8b800); }  /* yellow */
.mnd-num-4 .mnd-header { background: linear-gradient(90deg, #1a8028, #38b840); }  /* green */
.mnd-num-5 .mnd-header { background: linear-gradient(90deg, #0888c0, #18a8e8); }  /* cyan */
.mnd-num-6 .mnd-header { background: linear-gradient(90deg, #0858b0, #1878d0); }  /* blue */
.mnd-num-7 .mnd-header { background: linear-gradient(90deg, #2030a8, #4058d0); }  /* indigo */
.mnd-num-8 .mnd-header { background: linear-gradient(90deg, #6018a0, #9038c8); }  /* violet */
.mnd-num-9 .mnd-header { background: linear-gradient(90deg, #c81010, #9038c8); }  /* full rainbow */

.mnd-num-1 .mnd-num-badge { background: rgba(255,255,255,0.25); }
.mnd-num-2 .mnd-num-badge { background: rgba(255,255,255,0.25); }
.mnd-num-3 .mnd-num-badge { background: rgba(255,255,255,0.25); }
.mnd-num-4 .mnd-num-badge { background: rgba(255,255,255,0.25); }
.mnd-num-5 .mnd-num-badge { background: rgba(255,255,255,0.25); }
.mnd-num-6 .mnd-num-badge { background: rgba(255,255,255,0.25); }
.mnd-num-7 .mnd-num-badge { background: rgba(255,255,255,0.25); }
.mnd-num-8 .mnd-num-badge { background: rgba(255,255,255,0.25); }
.mnd-num-9 .mnd-num-badge { background: rgba(255,255,255,0.25); }

.mnd-body {
    padding: 10px 14px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.mnd-row {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    font-size: 12px;
    line-height: 1.5;
}

.mnd-tag {
    flex-shrink: 0;
    display: inline-block;
    padding: 1px 6px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.02em;
    min-width: 28px;
    text-align: center;
    margin-top: 1px;
}

.mnd-tag-yuan { background: rgba(240,184,64,0.18); color: #b07020; }
.mnd-tag-high { background: rgba(86,201,176,0.18); color: #1a8c70; }
.mnd-tag-low  { background: rgba(224,112,128,0.18); color: #c03050; }
.mnd-tag-life { background: rgba(126,168,232,0.18); color: #2060a8; }
.mnd-tag-love { background: rgba(199,110,196,0.18); color: #8030a0; }

.mnd-text {
    color: var(--text-main, #3a3a3a);
    line-height: 1.55;
}

/* ============================================
   TREE / TRIANGLE DIAGRAM
   ============================================ */
.triangle-container {
    position: relative;
    width: 100%;
    max-width: 340px;
    margin: 0 auto;
    aspect-ratio: 1 / 0.9;
    overflow: visible;
}

.triangle-node {
    position: absolute;
    transform: translate(-50%, -50%);
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(255,255,255,0.72);
    border: 1px solid var(--border-bright);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    box-shadow: var(--shadow-sm);
    gap: 0;
    cursor: default;
    transition: transform 0.15s;
}

.triangle-node .node-label {
    font-size: 9px;
    color: var(--text-dim);
    letter-spacing: 0.02em;
    line-height: 1;
}

.triangle-node .node-solar,
.triangle-node .node-lunar {
    font-size: 13px;
    font-weight: 700;
    line-height: 1.1;
}

.triangle-node .node-solar {
    color: var(--gold);
    font-size: 15px;
    font-weight: 800;
}
.triangle-node .node-lunar { color: var(--blue); font-size: 11px; }

.triangle-node.current-year {
    border-color: var(--gold);
    box-shadow: 0 0 0 4px rgba(212, 149, 106, 0.18), 0 0 20px rgba(212, 149, 106, 0.45);
    background: rgba(212, 149, 106, 0.14);
}

.triangle-node.current-year .node-solar { color: var(--gold-light); font-weight: 800; }

.triangle-svg {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    overflow: visible;
}

/* Highlight classes used by tree nodes */
.highlight-green { color: var(--green) !important; }
.highlight-red   { color: var(--red) !important; }


/* ============================================
   TIMELINE
   ============================================ */
.timeline-row {
    display: flex;
    align-items: flex-start;
    gap: var(--space-md);
    padding: var(--space-sm) 0;
    border-bottom: 1px solid var(--border);
}

.timeline-row:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.timeline-year {
    font-size: 14px;
    font-weight: 700;
    color: var(--gold);
    min-width: 44px;
    flex-shrink: 0;
    font-variant-numeric: tabular-nums;
}

.timeline-months {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    flex: 1;
}

.timeline-month {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    background: rgba(255,255,255,0.65);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 4px 9px;
    font-variant-numeric: tabular-nums;
    transition: background 0.15s;
}

.timeline-month.highlight-green {
    color: var(--green);
    background: var(--green-dim);
    border-color: rgba(74, 222, 128, 0.25);
}

.timeline-month.highlight-red {
    color: var(--red);
    background: var(--red-dim);
    border-color: rgba(248, 113, 113, 0.25);
}

/* ============================================
   RELATIONSHIP CHART
   ============================================ */
.info-grid {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}

.calendar-section {
    background: rgba(244,230,222,0.4);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: var(--space-md);
}

.calendar-section h4 {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    text-transform: uppercase;
    margin-bottom: var(--space-sm);
}

.info-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 5px 0;
    border-bottom: 1px solid var(--border);
}

.info-row:last-of-type {
    border-bottom: none;
}

.info-row .label {
    font-size: 12px;
    color: var(--text-dim);
}

.info-row .value {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
}

.soul-explanation {
    margin-top: var(--space-sm);
    padding: var(--space-sm);
    background: rgba(244,230,222,0.4);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 11px;
    line-height: 1.5;
}

.soul-explanation strong {
    color: var(--text-primary);
    font-size: 11px;
}

/* Number rows (used by some views) */
.number-rows {
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
}

.number-row {
    display: flex;
    gap: var(--space-xs);
    justify-content: center;
}

.number-item {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(255,255,255,0.65);
    border: 1px solid var(--border);
    font-size: 14px;
    font-weight: 700;
    color: var(--text-primary);
}

.number-item.highlight-green {
    background: var(--green-dim);
    border-color: rgba(74, 222, 128, 0.3);
    color: var(--green);
}

.number-item.highlight-red {
    background: var(--red-dim);
    border-color: rgba(248, 113, 113, 0.3);
    color: var(--red);
}

/* Tree node variants (older tree view) */
.tree-level {
    display: flex;
    justify-content: center;
    gap: var(--space-sm);
    margin-bottom: var(--space-sm);
}

.tree-node {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255,255,255,0.65);
    border: 1px solid var(--border);
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
}

.tree-node.highlight-green {
    background: var(--green-dim);
    border-color: rgba(74, 222, 128, 0.3);
    color: var(--green);
}

.tree-node.highlight-red {
    background: var(--red-dim);
    border-color: rgba(248, 113, 113, 0.3);
    color: var(--red);
}

/* ============================================
   PERSON HEADER (single person view)
   ============================================ */
.person-header {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    box-shadow: var(--shadow-sm);
    border-top-width: 3px;
}

.person-1-header {
    border-top-color: var(--gold);
}

.person-2-header {
    border-top-color: var(--blue);
}

.person-header h2 {
    font-size: 22px;
    font-weight: 800;
    color: var(--text-primary);
    letter-spacing: 0.01em;
    margin-bottom: var(--space-sm);
}

.birth-info {
    display: flex;
    gap: var(--space-md);
}

.birth-date h4 {
    font-size: 9px;
    font-weight: 800;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.10em;
    margin-bottom: 3px;
}

.birth-date p {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.01em;
}

/* ============================================
   RAINBOW RESULTS
   ============================================ */
.rainbow-results {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-md);
    position: relative;
}

.rainbow-results::before {
    content: '';
    display: block;
    height: 5px;
    background: linear-gradient(90deg,
        #f0b840 0%,
        #f5874a 20%,
        #e07080 40%,
        #c76ec4 60%,
        #7ea8e8 80%,
        #56c9b0 100%);
    flex-shrink: 0;
}

/* Dual number display */
.rr-row {
    display: flex;
    align-items: stretch;
    min-height: 130px;
}

.rr-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 22px 12px 18px;
    gap: 0;
}

.rr-solar { background: linear-gradient(160deg, rgba(240,120,32,0.10) 0%, rgba(232,32,32,0.06) 100%); }
.rr-lunar { background: linear-gradient(160deg, rgba(24,104,200,0.10) 0%, rgba(40,56,184,0.06) 100%); }

.rr-sign {
    font-size: 20px;
    font-weight: 700;
    line-height: 1;
    margin-bottom: 4px;
}
.rr-solar .rr-sign { color: rgba(240,120,32,0.75); }
.rr-lunar .rr-sign { color: rgba(24,104,200,0.75); }

.rr-num {
    font-size: 56px;
    font-weight: 900;
    font-variant-numeric: tabular-nums;
    line-height: 1;
    letter-spacing: -0.03em;
}
.rr-solar .rr-num {
    background: linear-gradient(135deg, #f07820, #e82020);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    filter: drop-shadow(0 2px 8px rgba(240,120,32,0.40));
}
.rr-lunar .rr-num {
    background: linear-gradient(135deg, #1868c8, #2838b8);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    filter: drop-shadow(0 2px 8px rgba(24,104,200,0.35));
}

.rr-info {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1px;
    margin-top: 8px;
}

.rr-type {
    font-size: 9px;
    font-weight: 800;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    opacity: 0.65;
}
.rr-solar .rr-type { color: var(--gold); }
.rr-lunar .rr-type { color: var(--blue); }

.rr-date {
    font-size: 10px;
    color: var(--text-dim);
    font-variant-numeric: tabular-nums;
}

.rr-sep {
    width: 1px;
    background: var(--border);
    flex-shrink: 0;
    margin: 20px 0;
}

/* ============================================
   NUMBERS TABLE
   ============================================ */
.numbers-table table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    margin-bottom: var(--space-sm);
}

.numbers-table th {
    color: var(--text-dim);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.04em;
    padding: 6px 8px;
    background: rgba(244,230,222,0.5);
    text-align: center;
}

.numbers-table td {
    color: var(--text-primary);
    padding: 7px 8px;
    text-align: center;
    border-top: 1px solid var(--border);
}

/* ============================================
   BOTTOM SAFE AREA
   ============================================ */
.safe-area-bottom {
    height: calc(var(--safe-bottom) + 20px);
    flex-shrink: 0;
}

/* ============================================
   SCROLLBAR
   ============================================ */
::-webkit-scrollbar {
    width: 0;
    background: transparent;
}

/* ============================================
   RESPONSIVE — slightly larger screens
   ============================================ */
@media (min-width: 400px) {
    .date-input { font-size: 15px; }
    .date-unit  { font-size: 12px; }
}

@media (min-width: 500px) {
    .app-main { padding: 0 var(--space-lg); }
    .person-card { padding: var(--space-xl); }
}

/* ============================================
   TRIANGLE DIAGRAM POINTS
   ============================================ */
.triangle-container {
    position: relative;
    /* width & height set dynamically by JS */
    margin: 0 auto;
    overflow: visible;
}

.triangle-point {
    position: absolute;
    width: 60px;
    text-align: center;
}

.triangle-point .number-display {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 54px;
    height: 54px;
    border-radius: 50%;
    background: rgba(255,255,255,0.75);
    border: 1px solid var(--border-bright);
    box-shadow: var(--shadow-sm);
    margin: 0 auto;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.triangle-point .number-display.current-year {
    border-color: var(--gold);
    box-shadow: 0 0 0 4px rgba(212,149,106,0.18), 0 0 20px rgba(212,149,106,0.4);
    background: rgba(212,149,106,0.12);
}

.triangle-point .positive {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.1;
}

.triangle-point .negative {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    line-height: 1.1;
}

.triangle-point .current-indicator {
    font-size: 9px;
    color: var(--gold);
    letter-spacing: 0.04em;
    margin-top: 1px;
}

.triangle-point.current-year .positive { color: var(--gold-light); }

.flow-marker-dot {
    position: absolute;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--gold);
    box-shadow: 0 0 8px rgba(196,162,97,0.6);
}

/* ============================================
   ANNUAL TABLE (horizontal scroll format)
   ============================================ */
.annual-table-section {
    margin-bottom: var(--space-md);
}

.annual-table-section:last-child {
    margin-bottom: 0;
}

.annual-table-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}

.annual-table {
    border-collapse: collapse;
    font-size: 12px;
    table-layout: fixed;
    width: 100%;
    min-width: 520px;
}

.annual-table th,
.annual-table td {
    padding: 7px 8px;
    text-align: center;
    vertical-align: middle;
    white-space: nowrap;
    border-bottom: 1px solid var(--border);
}

.annual-table th {
    background: rgba(244,230,222,0.55);
    color: var(--text-dim);
    font-weight: 600;
    font-size: 10px;
    letter-spacing: 0.04em;
}

.annual-table td {
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
}

.annual-table tr:last-child th,
.annual-table tr:last-child td {
    border-bottom: none;
}

.annual-table td.current-year-cell {
    color: var(--gold-light);
    font-weight: 800;
    background: rgba(212,149,106,0.12);
    box-shadow: inset 0 0 0 1px rgba(212,149,106,0.25);
}

/* ============================================
   RELATIONSHIP SQUARE
   ============================================ */
.main-life-relationship-square {
    margin-bottom: var(--space-sm);
}

.main-life-relationship-square h4 {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: var(--space-sm);
}

.relationship-square-container {
    display: flex;
    justify-content: center;
}

.square-with-edges {
    position: relative;
    display: inline-block;
}

.edge-number {
    position: absolute;
    font-size: 24px;
    font-weight: 900;
    background: linear-gradient(135deg, #e07080, #c06898);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.02em;
    filter: drop-shadow(0 1px 4px rgba(200,80,120,0.25));
}

.top-edge    { top: -24px; left: 50%; transform: translateX(-50%); }
.bottom-edge { bottom: -24px; left: 50%; transform: translateX(-50%); }
.left-edge   { left: -28px; top: 50%; transform: translateY(-50%); }
.right-edge  { right: -28px; top: 50%; transform: translateY(-50%); }

.square-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1px;
    background: var(--border);
    border: 1px solid var(--border-bright);
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.square-cell {
    background: rgba(255,255,255,0.65);
    padding: var(--space-md) var(--space-lg);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    min-width: 90px;
    transition: background 0.15s;
}

.square-cell .number-display {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.square-cell .positive {
    font-size: 24px;
    font-weight: 900;
    color: var(--gold);
    line-height: 1;
}

.square-cell .negative {
    font-size: 24px;
    font-weight: 900;
    color: var(--blue);
    line-height: 1;
}

.square-cell .person-label {
    font-size: 10px;
    font-weight: 600;
    color: var(--text-secondary);
    letter-spacing: 0.02em;
    text-align: center;
    opacity: 0.75;
    margin-top: 2px;
}

/* Current period highlight */
.main-life-relationship-square.current-period .square-grid {
    border-color: rgba(212,149,106,0.5);
    box-shadow: 0 0 20px rgba(212,149,106,0.20);
}

/* Timeline relationship squares */
.timeline-relationship-square {
    margin: var(--space-sm) 0;
}

/* ============================================
   TIMELINE DATE MARKERS
   ============================================ */
.timeline-container {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.timeline-date {
    padding: var(--space-xs) 0;
}

.date-marker {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.marker-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-dim);
    flex-shrink: 0;
}

.date-marker.person1 .marker-dot { background: var(--gold); }
.date-marker.person2 .marker-dot { background: var(--blue); }
.date-marker.current-date .marker-dot {
    background: var(--gold);
    box-shadow: 0 0 8px rgba(196,162,97,0.6);
}

.date-label {
    font-size: 13px;
    color: var(--text-secondary);
    font-variant-numeric: tabular-nums;
}

/* ─── Relationship Timeline (period cards) ─── */
.rel-timeline-track {
    position: relative;
}

.rel-timeline-track::before {
    content: '';
    position: absolute;
    left: 23px;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--border);
    border-radius: 1px;
}

.rel-year-chip {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.1em;
    color: var(--text-dim);
    padding: 12px 0 5px 52px;
}

.rel-period-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: var(--space-sm);
}

.rel-period-item.is-past {
    opacity: 0.45;
}

.rel-point {
    width: 48px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding-top: 12px;
    gap: 5px;
    position: relative;
    z-index: 1;
}

.rel-point-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--text-dim);
    border: 2px solid var(--bg-deep);
    box-sizing: border-box;
    flex-shrink: 0;
}
.rel-point-dot.p1 { background: var(--gold); }
.rel-point-dot.p2 { background: var(--blue); }
.rel-period-item.is-current .rel-point-dot { box-shadow: 0 0 7px rgba(196,162,97,0.7); }

.rel-point-date {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    font-variant-numeric: tabular-nums;
    text-align: center;
}

.rel-period-card {
    flex: 1;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 0;
    overflow: hidden;
}

.rel-period-card.is-current {
    border-color: rgba(196,162,97,0.45);
    box-shadow: 0 0 14px rgba(196,162,97,0.1);
}

.rel-period-header {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding: 6px var(--space-md) 0;
}

.rel-now-badge {
    font-size: 10px;
    font-weight: 700;
    color: var(--gold);
    background: rgba(196,162,97,0.15);
    border: 1px solid rgba(196,162,97,0.35);
    border-radius: 20px;
    padding: 2px 8px;
    letter-spacing: 0.05em;
}

/* Period square: same format as 主命关系 but smaller grid, larger edge numbers */
.rel-period-square .relationship-square-container {
    padding: 32px 38px;
}

.rel-period-square .square-cell {
    min-width: 62px;
    padding: 8px 10px;
}

.rel-period-square .square-cell .positive,
.rel-period-square .square-cell .negative {
    font-size: 15px;
}

.rel-period-square .square-cell .person-label {
    display: none;
}

.rel-period-square .edge-number {
    font-size: 26px;
}

.rel-period-square .top-edge    { top: -32px; }
.rel-period-square .bottom-edge { bottom: -32px; }
.rel-period-square .left-edge   { left: -36px; }
.rel-period-square .right-edge  { right: -36px; }

.rel-col-header {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1px;
    margin-bottom: 3px;
}

.rel-col-header span {
    text-align: center;
    font-size: 10px;
    font-weight: 700;
    padding: 3px 4px;
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
}

.rel-col-header span:first-child {
    color: var(--gold);
    background: rgba(196,162,97,0.12);
}

.rel-col-header span:last-child {
    color: var(--blue);
    background: rgba(100,149,200,0.12);
}

/* Relationship analysis */
.relationship-analysis {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}

.relationship-grid {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}

/* Chronological progression */
.chronological-progression {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
}

.progression-container {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}

.year-section h4 {
    font-size: 14px;
    font-weight: 700;
    color: var(--gold);
    margin-bottom: var(--space-xs);
}

.months-container {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-xs);
}

.month-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.month-section h5 {
    font-size: 10px;
    color: var(--text-dim);
    font-weight: 500;
}

.month-numbers {
    display: flex;
    gap: 4px;
}

.number-cell {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    background: rgba(255,255,255,0.65);
    border: 1px solid var(--border);
    color: var(--text-primary);
}

.number-cell.highlight-green {
    background: var(--green-dim);
    border-color: rgba(74,222,128,0.3);
    color: var(--green);
}

/* ============================================
   VIEW SYSTEM
   ============================================ */
.view {
    display: none;
    flex-direction: column;
    min-height: 100vh;
    min-height: -webkit-fill-available;
    padding-top: calc(var(--safe-top) + 0px);
}

.view.active {
    display: flex;
}

/* ============================================
   LANGUAGE TOGGLE
   ============================================ */
.lang-toggle {
    position: fixed;
    top: calc(var(--safe-top) + 14px);
    right: var(--space-md);
    display: flex;
    align-items: center;
    gap: 4px;
    z-index: 100;
    background: rgba(255,255,255,0.75);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 4px 10px;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    box-shadow: 0 2px 8px rgba(180,140,160,0.12);
}

.lang-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 500;
    letter-spacing: 0.04em;
    cursor: pointer;
    padding: 2px 4px;
    border-radius: 10px;
    transition: color 0.2s;
}

.lang-btn.active {
    color: var(--red);
    font-weight: 700;
}

.lang-sep {
    color: var(--border-bright);
    font-size: 11px;
    pointer-events: none;
}

/* ============================================
   SUB-HEADER (card / rainbow views)
   ============================================ */
.sub-header {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: calc(var(--safe-top) + 16px) var(--space-md) var(--space-sm);
    flex-shrink: 0;
}

.back-btn {
    background: none;
    border: none;
    color: var(--red);
    font-size: 15px;
    cursor: pointer;
    padding: 6px 0;
    white-space: nowrap;
}

.sub-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-secondary);
    letter-spacing: 0.04em;
}

/* ============================================
   HOME VIEW
   ============================================ */
.home-hero {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: calc(var(--safe-top) + 64px) var(--space-lg) var(--space-xl);
    gap: var(--space-sm);
    flex-shrink: 0;
}

.home-bloom-icon {
    width: 180px;
    height: 180px;
    margin-bottom: var(--space-sm);
}

.home-bloom-icon img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: 28px;
    box-shadow: 0 8px 32px rgba(120,40,160,0.15), 0 2px 8px rgba(0,0,0,0.06);
}

.home-title {
    display: none;
}

.home-tagline {
    font-size: 14px;
    color: var(--text-secondary);
    letter-spacing: 0.06em;
    font-style: italic;
}

.home-entries {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
    padding: 0 var(--space-md);
}

.home-entry {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    cursor: pointer;
    text-align: left;
    transition: background 0.2s, border-color 0.2s, transform 0.15s;
    -webkit-tap-highlight-color: transparent;
    width: 100%;
}

.home-entry:active {
    transform: scale(0.98);
    background: var(--bg-card-hover);
    border-color: var(--border-bright);
}

.entry-icon {
    width: 52px;
    height: 52px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    flex-shrink: 0;
}

.entry-icon-card {
    background: linear-gradient(135deg, rgba(232,32,32,0.12), rgba(240,120,32,0.10));
    border: 1px solid rgba(232,32,32,0.22);
    color: var(--rb-red);
}

.entry-icon-rainbow {
    background: linear-gradient(135deg, rgba(24,104,200,0.12), rgba(120,40,160,0.10));
    border: 1px solid rgba(24,104,200,0.22);
    color: var(--rb-blue);
}

.entry-body {
    flex: 1;
}

.entry-title {
    font-size: 17px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.entry-desc {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.4;
}

.entry-arrow {
    font-size: 22px;
    color: var(--text-dim);
    flex-shrink: 0;
}

/* ============================================
   BREATHING GUIDE
   ============================================ */
.card-intro {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--space-xl) var(--space-lg);
    gap: var(--space-lg);
    text-align: center;
}

.card-intro-icon {
    font-size: 40px;
    color: var(--gold-light);
    line-height: 1;
    animation: pulse-soft 3s ease-in-out infinite;
}

@keyframes pulse-soft {
    0%, 100% { opacity: 0.6; transform: scale(1); }
    50%       { opacity: 1;   transform: scale(1.12); }
}

.card-intro-title {
    font-size: 22px;
    font-weight: 600;
    letter-spacing: 0.04em;
    color: var(--text-primary);
}

.card-intro-body {
    font-size: 15px;
    line-height: 1.65;
    color: var(--text-secondary);
    max-width: 300px;
}

.begin-breathing-btn {
    margin-top: var(--space-sm);
    padding: 14px 32px;
    border-radius: 100px;
    border: 1px solid var(--gold);
    background: transparent;
    color: var(--gold-light);
    font-size: 15px;
    font-weight: 500;
    letter-spacing: 0.03em;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}

.begin-breathing-btn:active {
    background: rgba(196, 162, 97, 0.15);
}

.breath-guide {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--space-xl) var(--space-lg);
    gap: var(--space-lg);
}

.breath-ring-outer {
    width: 200px;
    height: 200px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255,255,255,0.45);
    border: 1px solid var(--border);
}

.breath-circle {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    transform: scale(0.7);
    opacity: 0.6;
    background: radial-gradient(circle at 40% 40%,
        rgba(245,176,154,0.75),
        rgba(232,144,168,0.45));
    box-shadow: 0 0 40px rgba(224,112,128,0.25);
    transition: transform 0s;
}

.breath-circle.breathe-in {
    animation: breath-expand 4s ease-in-out forwards;
}

.breath-circle.hold {
    animation: none;
    transform: scale(1.25);
}

.breath-circle.breathe-out {
    animation: breath-contract 4s ease-in-out forwards;
}

.breath-circle.calm {
    animation: breath-calm 4s ease-in-out infinite alternate;
}

@keyframes breath-expand {
    from { transform: scale(0.7); opacity: 0.6; }
    to   { transform: scale(1.25); opacity: 1; }
}

@keyframes breath-contract {
    from { transform: scale(1.25); opacity: 1; }
    to   { transform: scale(0.7); opacity: 0.6; }
}

@keyframes breath-calm {
    from { transform: scale(0.9); opacity: 0.7; }
    to   { transform: scale(1.05); opacity: 0.9; }
}

.breath-label {
    font-size: 18px;
    color: var(--text-secondary);
    letter-spacing: 0.08em;
    min-height: 28px;
    text-align: center;
}

.breath-counter {
    font-size: 16px;
    color: var(--purple);
    letter-spacing: 0.3em;
    min-height: 24px;
    text-align: center;
}

.think-text {
    font-size: 15px;
    color: var(--text-secondary);
    text-align: center;
    font-style: italic;
    line-height: 1.6;
    opacity: 0;
    transition: opacity 0.8s ease;
    max-width: 280px;
}

.ready-btn {
    background: linear-gradient(135deg, var(--gold), var(--gold-light));
    color: #1a1000;
    border: none;
    border-radius: 28px;
    padding: 14px 32px;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    letter-spacing: 0.03em;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.8s ease, transform 0.15s;
}

.ready-btn:active {
    transform: scale(0.97);
}

/* ============================================
   ORACLE CARD
   ============================================ */
.card-reveal {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--space-lg);
    gap: var(--space-xl);
}

.oracle-card {
    width: min(320px, 85vw);
    height: min(480px, 65vh);
    perspective: 1000px;
    cursor: default;
}

.oracle-card-inner {
    width: 100%;
    height: 100%;
    position: relative;
    transform-style: preserve-3d;
    transition: transform 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

.oracle-card.flipped .oracle-card-inner {
    transform: rotateY(180deg);
}

.oracle-card-back,
.oracle-card-front {
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: var(--radius-lg);
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}

.oracle-card-back {
    background: #2e1a28;
    border: 1px solid rgba(192,160,200,0.3);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Shared full-cover image style */
.card-img {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    object-fit: cover;
    border-radius: var(--radius-lg);
}

/* Back pattern shown when image fails to load */
.card-back-pattern {
    position: relative;
    font-size: 60px;
    color: rgba(192,160,200,0.35);
    user-select: none;
    animation: card-back-pulse 3s ease-in-out infinite;
}

@keyframes card-back-pulse {
    0%, 100% { opacity: 0.25; transform: scale(1); }
    50%       { opacity: 0.5; transform: scale(1.05); }
}

/* Hide back pattern when image loaded */
.oracle-card-back:has(.card-img[src]:not([src=""])) .card-back-pattern {
    display: none;
}

.oracle-card-front {
    --card-accent: #d4956a;
    background: #2e1a28;
    border: 1px solid rgba(192,160,200,0.25);
    transform: rotateY(180deg);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 60px rgba(0,0,0,0.6);
}

/* Symbol fallback (shown when image missing) */
.card-symbol {
    font-size: 48px;
    color: var(--card-accent);
    filter: drop-shadow(0 0 16px var(--card-accent));
}

/* Both cards shown side by side after reveal */
.card-pair {
    display: flex;
    gap: var(--space-md);
    align-items: center;
    justify-content: center;
}

.card-pair .oracle-card,
.card-back-revealed {
    width: min(150px, 40vw);
    height: min(225px, 60vw);
}

.card-back-revealed {
    position: relative;
    border-radius: var(--radius-lg);
    overflow: hidden;
    border: 1px solid rgba(192,160,200,0.3);
    flex-shrink: 0;
    transition: opacity 0.5s ease;
}

.draw-again-btn {
    background: var(--bg-card);
    border: 1px solid var(--border-bright);
    color: var(--text-secondary);
    border-radius: 24px;
    padding: 12px 28px;
    font-size: 14px;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}

.draw-again-btn:active {
    background: var(--bg-card-hover);
    color: var(--text-primary);
}

/* ============================================
   CONSULTATION BOOKING BUTTON
   ============================================ */
.consult-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin: 16px auto 0;
    padding: 13px 28px;
    border-radius: 28px;
    font-size: 14px;
    font-weight: 700;
    letter-spacing: 0.02em;
    text-decoration: none;
    cursor: pointer;
    transition: opacity 0.18s, transform 0.15s;
    background: linear-gradient(90deg, #f0b840 0%, #f5874a 40%, #e07080 75%, #c76ec4 100%);
    color: #fff;
    border: none;
    box-shadow: 0 3px 14px rgba(240,140,80,0.28);
    width: fit-content;
}

.consult-btn svg {
    flex-shrink: 0;
    opacity: 0.92;
}

.consult-btn:active {
    opacity: 0.82;
    transform: scale(0.97);
}

.consult-btn-rainbow {
    margin-top: 24px;
}

.consult-btn-home {
    margin-top: 20px;
}

/* ============================================
   CARD READING PANEL
   ============================================ */
.card-reading {
    width: 100%;
    max-width: 420px;
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
    transition: opacity 0.5s ease;
}

.reading-guide-block {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: var(--space-md);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.reading-meta-row {
    display: flex;
    align-items: baseline;
    gap: var(--space-xs);
    margin-bottom: 4px;
}

.reading-meta-label {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--gold);
    white-space: nowrap;
    flex-shrink: 0;
}

.reading-guide-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
}

.reading-message {
    font-size: 14px;
    line-height: 1.65;
    color: var(--text-primary);
    font-style: italic;
    margin: 0;
}

.reading-dims {
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
}

.reading-dim {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: var(--space-md);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.reading-dim-head {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    margin-bottom: var(--space-xs);
}

.reading-dim-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    font-size: 13px;
    font-weight: 700;
    flex-shrink: 0;
}

.reading-dim-body   { background: rgba(245,176,154,0.25); color: var(--peach); border: 1px solid rgba(245,176,154,0.4); }
.reading-dim-mind   { background: rgba(232,144,168,0.25); color: var(--pink);  border: 1px solid rgba(232,144,168,0.4); }
.reading-dim-spirit { background: rgba(192,160,200,0.25); color: var(--purple); border: 1px solid rgba(192,160,200,0.4); }

.reading-dim-label {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-primary);
}

.reading-dim-text {
    font-size: 13px;
    line-height: 1.65;
    color: var(--text-secondary);
    margin: 0;
}

/* Make card-reveal scrollable when reading is shown */
.card-reveal {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

/* ============================================
   RAINBOW VIEW — override app-main for view
   ============================================ */
#view-rainbow .app-main {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}
