/* ========================================
   玄机阁 - AI 国学算命 | Design System
   ======================================== */

:root {
    --vermillion: #c93a40;
    --cinnabar: #e94e4e;
    --amber: #d4a844;
    --gold: #f0c75e;
    --jade: #2d8b6f;
    --ink: #1a1a2e;
    --deep-ink: #0f0f1e;

    --bg-primary: #0a0a14;
    --bg-secondary: #12121f;
    --bg-card: rgba(18, 18, 35, 0.7);
    --text-primary: #e8e0d4;
    --text-secondary: #a89f90;
    --text-muted: #6b6358;
    --border-color: rgba(212, 168, 68, 0.15);
    --border-glow: rgba(212, 168, 68, 0.3);

    --gradient-gold: linear-gradient(135deg, #d4a844, #f0c75e, #d4a844);
    --gradient-fire: linear-gradient(135deg, #c93a40, #e94e4e);
    --gradient-bg: linear-gradient(180deg, #0a0a14 0%, #12121f 50%, #0d0d1a 100%);

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --shadow-card: 0 8px 32px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.05);
    --shadow-glow: 0 0 20px rgba(212, 168, 68, 0.15);
    --shadow-button: 0 4px 15px rgba(201, 58, 64, 0.4);
    --transition-fast: 0.2s ease;
    --transition-normal: 0.3s ease;
}

*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    font-size: 16px;
}

body {
    font-family: 'Noto Sans SC', 'PingFang SC', 'Microsoft YaHei', sans-serif;
    background: var(--gradient-bg);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    line-height: 1.7;
}

#particles-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
}

/* ---------- Glass Card ---------- */
.glass-card {
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
    transition: border-color var(--transition-normal), box-shadow var(--transition-normal);
}

.glass-card:hover {
    border-color: var(--border-glow);
    box-shadow: var(--shadow-card), var(--shadow-glow);
}

/* ---------- Header ---------- */
.header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    background: rgba(10, 10, 20, 0.85);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border-color);
}

.header-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0.8rem 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.logo-icon {
    font-size: 2rem;
    animation: rotate-slow 8s linear infinite;
}

@keyframes rotate-slow {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

.logo h1 {
    font-family: 'Noto Serif SC', serif;
    font-size: 1.5rem;
    font-weight: 900;
    background: var(--gradient-gold);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: 0.1em;
}

.logo-sub {
    font-size: 0.75rem;
    color: var(--text-muted);
    padding: 2px 8px;
    border: 1px solid var(--border-color);
    border-radius: 20px;
    letter-spacing: 0.15em;
}

/* ---------- Hero ---------- */
.hero-section {
    text-align: center;
    padding: 2rem 0 1.5rem;
    position: relative;
    z-index: 1;
    animation: slideUp 0.6s ease-out;
}

.hero-badge {
    display: inline-block;
    padding: 6px 20px;
    background: rgba(212, 168, 68, 0.08);
    border: 1px solid rgba(212, 168, 68, 0.2);
    border-radius: 30px;
    font-size: 0.8rem;
    color: var(--gold);
    letter-spacing: 0.15em;
    margin-bottom: 1rem;
}

.hero-title {
    font-family: 'Noto Serif SC', serif;
    font-size: 2.2rem;
    font-weight: 900;
    background: var(--gradient-gold);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: 0.2em;
    margin-bottom: 0.5rem;
}

.hero-desc {
    color: var(--text-muted);
    font-size: 0.95rem;
    letter-spacing: 0.08em;
}

/* ---------- Main Container ---------- */
.main-container {
    max-width: 1000px;
    margin: 0 auto;
    padding: 80px 1.5rem 3rem;
    position: relative;
    z-index: 1;
}

/* ---------- Input Section ---------- */
.input-section {
    padding: 2rem;
    margin-bottom: 2rem;
    animation: slideUp 0.6s ease-out;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.input-header {
    text-align: center;
    margin-bottom: 1.5rem;
}

.section-title {
    font-family: 'Noto Serif SC', serif;
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.3rem;
    letter-spacing: 0.1em;
}

.title-icon {
    color: var(--gold);
    margin-right: 0.25rem;
}

.section-desc {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.fortune-form {
    max-width: 100%;
}

.form-section-label {
    font-family: 'Noto Serif SC', serif;
    font-size: 0.85rem;
    color: var(--amber);
    letter-spacing: 0.1em;
    margin-bottom: 0.6rem;
    margin-top: 1rem;
    padding-left: 0.5rem;
    border-left: 2px solid var(--amber);
}

.form-row {
    display: grid;
    gap: 1rem;
    margin-bottom: 0.5rem;
}

.form-row-2 {
    grid-template-columns: 1fr 1fr;
}

.form-row-3 {
    grid-template-columns: 1fr 1fr 1fr;
}

.form-row-4 {
    grid-template-columns: repeat(4, 1fr);
}

.form-group label {
    display: block;
    font-size: 0.82rem;
    color: var(--text-secondary);
    margin-bottom: 0.4rem;
    font-weight: 500;
    letter-spacing: 0.05em;
}

.form-group-full {
    margin-top: 1rem;
}

.input-wrapper {
    position: relative;
}

.input-wrapper input,
.input-wrapper select,
.input-wrapper textarea {
    width: 100%;
    padding: 10px 38px 10px 14px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.9rem;
    font-family: inherit;
    outline: none;
    transition: all var(--transition-fast);
}

.input-wrapper input:focus,
.input-wrapper select:focus,
.input-wrapper textarea:focus {
    border-color: var(--gold);
    box-shadow: 0 0 0 2px rgba(212, 168, 68, 0.15);
}

.input-wrapper select {
    appearance: none;
    -webkit-appearance: none;
    cursor: pointer;
}

.input-wrapper select option {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.input-wrapper textarea {
    resize: vertical;
    min-height: 70px;
}

.input-wrapper input::placeholder,
.input-wrapper textarea::placeholder {
    color: var(--text-muted);
}

.input-icon {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1rem;
    pointer-events: none;
}

.textarea-icon {
    top: 16px;
    transform: none;
}

.form-actions {
    display: flex;
    justify-content: center;
    margin-top: 1.5rem;
}

.btn-primary {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 13px 48px;
    background: var(--gradient-fire);
    color: white;
    border: none;
    border-radius: 50px;
    font-size: 1.05rem;
    font-family: 'Noto Serif SC', serif;
    font-weight: 600;
    cursor: pointer;
    letter-spacing: 0.15em;
    box-shadow: var(--shadow-button);
    transition: all var(--transition-normal);
    position: relative;
    overflow: hidden;
}

.btn-primary::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.15), transparent);
    transition: left 0.5s ease;
}

.btn-primary:hover::before {
    left: 100%;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 25px rgba(201, 58, 64, 0.5);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none !important;
}

/* ---------- Results ---------- */
.results-section {
    display: grid;
    gap: 1.5rem;
    animation: fadeIn 0.8s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.result-panel {
    padding: 2rem;
    animation: slideUp 0.6s ease-out;
}

.result-header {
    margin-bottom: 1.5rem;
    padding-bottom: 0.8rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.result-header h3 {
    font-family: 'Noto Serif SC', serif;
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--gold);
    letter-spacing: 0.1em;
}

.result-icon {
    margin-right: 0.4rem;
}

/* ---------- Pillars (八字) ---------- */
.pillars-container {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
    margin-bottom: 1rem;
}

.pillar-card {
    text-align: center;
    padding: 1rem;
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    transition: all var(--transition-normal);
}

.pillar-card:hover {
    border-color: var(--gold);
    transform: translateY(-3px);
    box-shadow: var(--shadow-glow);
}

.pillar-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 0.4rem;
    letter-spacing: 0.1em;
}

.pillar-gan,
.pillar-zhi {
    font-family: 'Noto Serif SC', serif;
    font-size: 2.2rem;
    font-weight: 900;
    line-height: 1.3;
}

.pillar-element {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 0.3rem;
    padding: 2px 10px;
    border-radius: 20px;
    display: inline-block;
}

.element-金 {
    color: #f0c75e;
    border: 1px solid rgba(240, 199, 94, 0.3);
}

.element-木 {
    color: #4caf50;
    border: 1px solid rgba(76, 175, 80, 0.3);
}

.element-水 {
    color: #42a5f5;
    border: 1px solid rgba(66, 165, 245, 0.3);
}

.element-火 {
    color: #ef5350;
    border: 1px solid rgba(239, 83, 80, 0.3);
}

.element-土 {
    color: #bc8f5e;
    border: 1px solid rgba(188, 143, 94, 0.3);
}

.gan-金,
.zhi-金 {
    color: #f0c75e;
}

.gan-木,
.zhi-木 {
    color: #4caf50;
}

.gan-水,
.zhi-水 {
    color: #42a5f5;
}

.gan-火,
.zhi-火 {
    color: #ef5350;
}

.gan-土,
.zhi-土 {
    color: #bc8f5e;
}

.bazi-meta {
    padding: 0.8rem 1rem;
    background: rgba(212, 168, 68, 0.05);
    border-radius: var(--radius-md);
    border-left: 3px solid var(--amber);
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.7;
}

/* ---------- AI Panel ---------- */
.ai-panel {
    min-height: 300px;
}

.ai-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8rem;
    color: var(--jade);
}

.ai-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--jade);
    animation: dotPulse 1.2s ease-in-out infinite;
}

@keyframes dotPulse {

    0%,
    100% {
        opacity: 0.4;
        transform: scale(0.8);
    }

    50% {
        opacity: 1;
        transform: scale(1.2);
    }
}

.ai-status.done {
    color: var(--text-muted);
}

.ai-status.done .ai-dot {
    animation: none;
    background: var(--text-muted);
}

/* ---------- Markdown Body ---------- */
.ai-content {
    font-size: 0.95rem;
    line-height: 1.9;
    color: var(--text-primary);
    overflow-wrap: break-word;
}

.ai-content h2 {
    font-family: 'Noto Serif SC', serif;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--gold);
    margin: 1.8rem 0 0.8rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-color);
    letter-spacing: 0.08em;
}

.ai-content h3 {
    font-family: 'Noto Serif SC', serif;
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--amber);
    margin: 1.2rem 0 0.5rem;
}

.ai-content p {
    margin: 0.6rem 0;
    color: var(--text-secondary);
}

.ai-content strong {
    color: var(--text-primary);
    font-weight: 600;
}

.ai-content ul,
.ai-content ol {
    padding-left: 1.5rem;
    margin: 0.5rem 0;
}

.ai-content li {
    color: var(--text-secondary);
    margin: 0.3rem 0;
}

.ai-content blockquote {
    border-left: 3px solid var(--jade);
    padding: 0.5rem 1rem;
    margin: 0.8rem 0;
    background: rgba(45, 139, 111, 0.06);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    color: var(--text-secondary);
    font-style: italic;
}

.ai-content code {
    background: rgba(255, 255, 255, 0.06);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.85em;
    color: var(--gold);
}

.ai-content hr {
    border: none;
    height: 1px;
    background: var(--border-color);
    margin: 1.5rem 0;
}

.cursor-blink {
    display: inline-block;
    animation: blink 1s step-end infinite;
    color: var(--gold);
    font-weight: 100;
}

@keyframes blink {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0;
    }
}

/* ---------- Loading ---------- */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(10, 10, 20, 0.85);
    backdrop-filter: blur(10px);
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
}

.loading-spinner {
    text-align: center;
    position: relative;
    width: 120px;
    height: 120px;
}

.spinner-ring {
    position: absolute;
    border: 2px solid transparent;
    border-radius: 50%;
}

.spinner-ring:nth-child(1) {
    width: 100%;
    height: 100%;
    border-top-color: var(--vermillion);
    animation: spin 1.2s linear infinite;
}

.spinner-ring:nth-child(2) {
    width: 75%;
    height: 75%;
    top: 12.5%;
    left: 12.5%;
    border-right-color: var(--gold);
    animation: spin 1s linear infinite reverse;
}

.spinner-ring:nth-child(3) {
    width: 50%;
    height: 50%;
    top: 25%;
    left: 25%;
    border-bottom-color: var(--jade);
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

.loading-text {
    position: absolute;
    bottom: -40px;
    left: 50%;
    transform: translateX(-50%);
    white-space: nowrap;
    font-family: 'Noto Serif SC', serif;
    color: var(--text-secondary);
    font-size: 0.9rem;
    letter-spacing: 0.2em;
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 0.5;
    }

    50% {
        opacity: 1;
    }
}

/* ---------- Footer ---------- */
.footer {
    text-align: center;
    padding: 2rem 1.5rem;
    color: var(--text-muted);
    font-size: 0.85rem;
    position: relative;
    z-index: 1;
    border-top: 1px solid var(--border-color);
    margin-top: 2rem;
}

.footer-note {
    font-size: 0.75rem;
    margin-top: 0.3rem;
    opacity: 0.6;
}

/* ---------- Calendar Toggle ---------- */
.calendar-toggle {
    display: flex;
    gap: 2px;
    background: rgba(255, 255, 255, 0.04);
    border-radius: 6px;
    padding: 2px;
    border: 1px solid var(--border-color);
}

.cal-btn {
    padding: 4px 14px;
    border: none;
    border-radius: 4px;
    background: transparent;
    color: var(--text-muted);
    font-size: 0.8rem;
    font-family: 'Noto Serif SC', serif;
    cursor: pointer;
    transition: all 0.2s ease;
    letter-spacing: 0.05em;
}

.cal-btn.active {
    background: var(--gradient-gold);
    color: #0a0a14;
    font-weight: 600;
}

.cal-btn:hover:not(.active) {
    color: var(--gold);
}

.leap-month-row {
    margin-top: 0.3rem;
    margin-bottom: 0.5rem;
    padding-left: 0.2rem;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-size: 0.85rem;
    color: var(--text-secondary);
    user-select: none;
}

.checkbox-label input[type="checkbox"] {
    display: none;
}

.checkbox-custom {
    width: 18px;
    height: 18px;
    border-radius: 4px;
    border: 1px solid var(--border-color);
    background: rgba(255, 255, 255, 0.04);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.checkbox-label input[type="checkbox"]:checked+.checkbox-custom {
    background: var(--amber);
    border-color: var(--amber);
}

.checkbox-label input[type="checkbox"]:checked+.checkbox-custom::after {
    content: '✓';
    color: #0a0a14;
    font-size: 0.7rem;
    font-weight: 700;
}

.hidden {
    display: none !important;
}

/* ---------- Responsive ---------- */
@media (max-width: 768px) {
    .header-inner {
        padding: 0.6rem 1rem;
    }

    .main-container {
        padding: 70px 1rem 2rem;
    }

    .hero-title {
        font-size: 1.5rem;
    }

    .input-section,
    .result-panel {
        padding: 1.2rem;
    }

    .form-row-3,
    .form-row-4 {
        grid-template-columns: repeat(2, 1fr);
    }

    .form-row-2 {
        grid-template-columns: 1fr;
    }

    .pillars-container {
        grid-template-columns: repeat(2, 1fr);
    }

    .pillar-gan,
    .pillar-zhi {
        font-size: 1.6rem;
    }
}

@media (max-width: 480px) {

    .form-row-3,
    .form-row-4 {
        grid-template-columns: 1fr;
    }

    .hero-title {
        font-size: 1.3rem;
    }
}