/* ========== Reset & Base ========== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    color: #78350f;
    min-height: 100vh;
    background: linear-gradient(180deg, #fdf6f0, #f0e6d6);
    line-height: 1.5;
}

/* ========== Utility (Tailwind fallbacks) ========== */
.hidden { display: none !important; }
.flex { display: flex; }
.grid { display: grid; }
.space-y-3 > * + * { margin-top: 0.75rem; }
.space-y-4 > * + * { margin-top: 1rem; }
.text-center { text-align: center; }
.text-xs { font-size: 0.75rem; }
.text-sm { font-size: 0.875rem; }
.text-lg { font-size: 1.125rem; }
.text-2xl { font-size: 1.5rem; }
.font-bold { font-weight: 700; }
.font-medium { font-weight: 500; }
.mt-2 { margin-top: 0.5rem; }
.mt-3 { margin-top: 0.75rem; }
.mt-4 { margin-top: 1rem; }
.mt-5 { margin-top: 1.25rem; }
.mb-1 { margin-bottom: 0.25rem; }
.mb-3 { margin-bottom: 0.75rem; }
.mb-4 { margin-bottom: 1rem; }
.mb-5 { margin-bottom: 1.25rem; }
.p-4 { padding: 1rem; }
.p-5 { padding: 1.25rem; }
.py-6 { padding-top: 1.5rem; padding-bottom: 1.5rem; }
.py-12 { padding-top: 3rem; padding-bottom: 3rem; }
.pb-20 { padding-bottom: 5rem; }

/* ========== View Container ========== */
.view-container { display: none; }
.view-container.active { display: block; }
.max-w-2xl { max-width: 42rem; margin-left: auto; margin-right: auto; }

/* ========== Header ========== */
header {
    position: sticky;
    top: 0;
    z-index: 40;
    background: rgba(255,255,255,0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid rgba(251,191,36,0.15);
}
header > div {
    max-width: 42rem;
    margin: 0 auto;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
header .logo {
    display: flex;
    align-items: center;
    gap: 8px;
}
header .logo-icon {
    width: 36px; height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, #fbbf24, #f97316);
    display: flex; align-items: center; justify-content: center;
    color: white; font-size: 0.8rem; font-weight: 700;
    box-shadow: 0 2px 8px rgba(249,115,22,0.3);
}
header .logo-text {
    font-weight: 700; font-size: 1.125rem; color: #92400e; letter-spacing: 0.05em;
}
header nav {
    display: flex; gap: 4px;
}

/* ========== Nav Buttons ========== */
.nav-btn {
    width: 40px; height: 40px;
    border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    color: #b45309; background: transparent; border: none;
    cursor: pointer; transition: all 0.2s;
}
.nav-btn:hover, .nav-btn.active {
    background: rgba(251,191,36,0.15); color: #d97706;
}

/* ========== Glass Card ========== */
.glass-card {
    background: rgba(255,255,255,0.8);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(251,191,36,0.15);
    border-radius: 20px;
    box-shadow: 0 4px 24px rgba(180,120,40,0.06);
}

/* ========== Progress Section ========== */
.progress-section {
    display: flex; align-items: center; gap: 20px;
}
.progress-ring-wrapper {
    position: relative; width: 80px; height: 80px; flex-shrink: 0;
}
.progress-ring { transform: rotate(-90deg); }
.progress-ring-bg { fill: none; stroke: #fef3c7; stroke-width: 6; }
.progress-ring-fill {
    fill: none; stroke: url(#ring-gradient); stroke-width: 6;
    stroke-linecap: round; stroke-dasharray: 213.6; stroke-dashoffset: 213.6;
    transition: stroke-dashoffset 1s ease;
}
.progress-ring-text {
    position: absolute; top: 50%; left: 50%;
    transform: translate(-50%,-50%); text-align: center; line-height: 1;
}
.progress-info { flex: 1; }
.progress-info .stage-badge {
    display: inline-block; padding: 2px 12px; border-radius: 20px;
    font-size: 0.75rem; font-weight: 600;
    background: #fef3c7; color: #92400e;
}
.progress-info .stats {
    display: flex; gap: 16px; font-size: 0.875rem; color: #92400e; margin-top: 8px;
}
.progress-bar-track {
    margin-top: 12px; height: 8px; background: #fef3c7;
    border-radius: 8px; overflow: hidden;
}
.progress-bar-fill {
    height: 100%; border-radius: 8px;
    background: linear-gradient(90deg, #fbbf24, #f97316);
    transition: width 0.7s ease;
}

/* ========== Today Section ========== */
.today-header {
    display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px;
}
.today-header h2 { font-size: 1.125rem; font-weight: 700; color: #92400e; }
.today-header h2 span { color: #f97316; }
.today-header .date { font-size: 0.75rem; color: #d97706; }

/* ========== Card Area ========== */
.card-area {
    perspective: 1200px;
    min-height: 320px;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; border-radius: 16px; overflow: hidden;
    margin-bottom: 16px;
}
.card-face {
    width: 100%; max-width: 240px;
    aspect-ratio: 3/4; border-radius: 16px; overflow: hidden;
    transition: transform 0.6s ease;
    box-shadow: 0 8px 32px rgba(120,53,15,0.15);
}
.card-back-face {
    background: linear-gradient(135deg, #fbbf24, #f59e0b, #d97706);
    display: flex; align-items: center; justify-content: center;
}
.card-back-pattern {
    width: calc(100% - 16px); height: calc(100% - 16px);
    border: 2px dashed rgba(255,255,255,0.4); border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
}
.card-back-inner { text-align: center; color: white; text-shadow: 0 1px 4px rgba(0,0,0,0.1); }
.card-back-inner .q-mark { font-size: 2.5rem; margin-bottom: 4px; }
.card-back-inner .label { font-size: 0.875rem; font-weight: 500; }
.card-front-face { background: white; position: relative; }
.card-image { width: 100%; height: 100%; object-fit: cover; display: block; }
.card-placeholder {
    width: 100%; height: 100%;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    background: linear-gradient(135deg, #fffbeb, #fef3c7);
}
.card-label {
    position: absolute; bottom: 8px; right: 8px;
    background: rgba(255,255,255,0.85); backdrop-filter: blur(4px);
    padding: 2px 10px; border-radius: 20px; color: #b45309;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08); font-size: 0.75rem;
}
@keyframes cardFlipIn {
    0% { transform: rotateY(0deg); opacity: 1; }
    50% { transform: rotateY(90deg); opacity: 0.5; }
    100% { transform: rotateY(0deg); opacity: 1; }
}
.card-flipping { animation: cardFlipIn 0.7s ease-in-out; }

/* ========== Done Today ========== */
.done-today {
    text-align: center; padding: 24px 0;
}
.done-today .check-circle {
    width: 64px; height: 64px; margin: 0 auto 12px;
    border-radius: 50%; background: #ecfdf5;
    display: flex; align-items: center; justify-content: center;
}
.done-today .check-circle svg { width: 32px; height: 32px; color: #22c55e; }
.done-today p { color: #92400e; font-weight: 500; }
.done-today .sub { font-size: 0.75rem; color: #d97706; margin-top: 4px; }

/* ========== Question Blocks ========== */
.questions-form > * + * { margin-top: 1rem; }
.question-block {
    background: rgba(254,243,199,0.3);
    border: 1px solid rgba(251,191,36,0.15);
    border-radius: 14px; padding: 14px; transition: all 0.2s;
}
.question-block:focus-within {
    background: rgba(254,243,199,0.5);
    border-color: rgba(251,191,36,0.35);
    box-shadow: 0 0 0 3px rgba(251,191,36,0.08);
}
.question-label {
    display: flex; align-items: center; gap: 6px;
    font-size: 0.875rem; font-weight: 600; color: #92400e; margin-bottom: 8px;
}
.question-input {
    width: 100%; border: none; background: transparent;
    resize: none; outline: none;
    font-size: 0.875rem; line-height: 1.6; color: #78350f;
}
.question-input::placeholder { color: #d4a76a; }

/* ========== Submit Button ========== */
.submit-btn {
    width: 100%; padding: 14px; border: none; border-radius: 14px;
    background: linear-gradient(135deg, #fbbf24, #f59e0b);
    color: white; font-size: 1rem; font-weight: 600;
    cursor: pointer; transition: all 0.3s;
    box-shadow: 0 4px 16px rgba(245,158,11,0.25); letter-spacing: 0.05em;
}
.submit-btn:hover { transform: translateY(-1px); box-shadow: 0 6px 20px rgba(245,158,11,0.35); }
.submit-btn:active { transform: translateY(0); }
.submit-btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

/* ========== Feedback Section ========== */
.feedback-header {
    display: flex; align-items: center; gap: 8px; margin-bottom: 12px;
}
.feedback-icon {
    width: 28px; height: 28px; border-radius: 50%; background: #f3e8ff;
    display: flex; align-items: center; justify-content: center;
}
.feedback-icon svg { width: 16px; height: 16px; color: #a855f7; }

/* ========== History ========== */
.history-header {
    display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px;
}
.history-header h2 { font-size: 1.125rem; font-weight: 700; color: #92400e; }
.filter-select {
    padding: 6px 12px; border: 1px solid #fde68a; border-radius: 8px;
    background: #fffbeb; color: #92400e; font-size: 0.8rem; outline: none;
    cursor: pointer;
}
.history-item {
    background: rgba(254,243,199,0.25);
    border: 1px solid rgba(251,191,36,0.1);
    border-radius: 14px; padding: 14px; cursor: pointer; transition: all 0.2s;
}
.history-item:hover {
    background: rgba(254,243,199,0.45);
    transform: translateY(-1px); box-shadow: 0 4px 12px rgba(180,120,40,0.06);
}
.history-item-header {
    display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px;
}
.history-day-badge {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 2px 10px; border-radius: 20px; font-size: 0.75rem; font-weight: 600;
    background: linear-gradient(135deg, #fef3c7, #fde68a); color: #92400e;
}
.discovery-btn {
    background: none; border: none; cursor: pointer;
    font-size: 1.1rem; transition: transform 0.2s; padding: 4px;
}
.discovery-btn:hover { transform: scale(1.2); }
.history-preview { font-size: 0.8rem; color: #a16207; line-height: 1.5; }
.history-empty {
    text-align: center; padding: 48px 0; color: #d97706;
}

/* ========== Achievement Cards ========== */
.achievements-grid {
    display: grid; grid-template-columns: 1fr 1fr; gap: 12px;
}
.achievement-card {
    background: rgba(254,243,199,0.25);
    border: 1px solid rgba(251,191,36,0.1);
    border-radius: 16px; padding: 16px; text-align: center; transition: all 0.3s;
}
.achievement-card.unlocked {
    background: linear-gradient(135deg, rgba(254,243,199,0.5), rgba(253,230,138,0.3));
    border-color: rgba(251,191,36,0.3);
}
.achievement-card.locked { opacity: 0.45; filter: grayscale(0.6); }
.achievement-icon { font-size: 2rem; margin-bottom: 6px; }
.achievement-name { font-size: 0.875rem; font-weight: 700; color: #92400e; margin-bottom: 2px; }
.achievement-desc { font-size: 0.7rem; color: #b45309; }

/* ========== Modal ========== */
.modal-overlay {
    display: none; position: fixed; inset: 0; z-index: 50;
    background: rgba(0,0,0,0.4); backdrop-filter: blur(4px);
    align-items: center; justify-content: center; padding: 16px;
}
.modal-overlay.open { display: flex; }
.modal-box {
    background: #fdf6f0; border-radius: 20px; padding: 24px;
    max-width: 480px; width: 100%; max-height: 80vh; overflow-y: auto;
    box-shadow: 0 16px 48px rgba(0,0,0,0.15);
}
.modal-close-btn {
    display: inline-block; margin-top: 16px;
    padding: 8px 20px; border: 1px solid #fde68a; border-radius: 10px;
    background: #fef3c7; color: #92400e; font-size: 0.875rem;
    cursor: pointer; transition: background 0.2s;
}
.modal-close-btn:hover { background: #fde68a; }
.modal-answer-block {
    background: rgba(254,243,199,0.3); border-radius: 12px; padding: 12px;
}
.modal-answer-block + .modal-answer-block { margin-top: 8px; }
.modal-answer-label { font-size: 0.75rem; font-weight: 600; color: #b45309; margin-bottom: 4px; }
.modal-answer-text { font-size: 0.85rem; color: #78350f; line-height: 1.6; }
.modal-card-thumb {
    width: 120px; aspect-ratio: 3/4; border-radius: 12px;
    object-fit: cover; box-shadow: 0 4px 16px rgba(120,53,15,0.12);
}

/* ========== Loading ========== */
.loading-overlay {
    display: none; position: fixed; inset: 0; z-index: 50;
    background: rgba(0,0,0,0.2); backdrop-filter: blur(4px);
    align-items: center; justify-content: center;
}
.loading-overlay.open { display: flex; }
.loading-box {
    background: white; border-radius: 20px; padding: 24px; text-align: center;
    box-shadow: 0 8px 32px rgba(0,0,0,0.1);
}
.loading-dots { display: flex; gap: 6px; justify-content: center; margin-bottom: 12px; }
.loading-dots span {
    width: 10px; height: 10px; border-radius: 50%; background: #fbbf24;
    animation: dotBounce 1.2s ease-in-out infinite;
}
.loading-dots span:nth-child(2) { animation-delay: 0.2s; }
.loading-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes dotBounce {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
    40% { transform: scale(1); opacity: 1; }
}

/* ========== Toast ========== */
.toast-container {
    position: fixed; top: 16px; left: 50%; transform: translateX(-50%);
    z-index: 60; display: flex; flex-direction: column; gap: 8px; align-items: center;
}
.toast-msg {
    padding: 10px 20px; border-radius: 12px; font-size: 0.875rem;
    box-shadow: 0 4px 16px rgba(0,0,0,0.1); animation: slideIn 0.3s ease;
    display: flex; align-items: center; gap: 8px; color: white;
}
.toast-msg.success { background: #22c55e; }
.toast-msg.error { background: #ef4444; }
@keyframes slideIn {
    from { transform: translateY(-20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

/* ========== Auth Page ========== */
.auth-container {
    min-height: 100vh;
    display: flex; align-items: center; justify-content: center;
    padding: 16px;
}
.auth-card {
    background: rgba(255,255,255,0.9);
    backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(251,191,36,0.15);
    border-radius: 24px; padding: 36px 32px;
    width: 100%; max-width: 380px;
    box-shadow: 0 8px 40px rgba(180,120,40,0.12);
}
.auth-title { text-align: center; margin-bottom: 28px; }
.auth-logo { font-size: 3rem; margin-bottom: 8px; }
.auth-title h1 { font-size: 1.5rem; font-weight: 700; color: #92400e; }
.auth-title p { font-size: 0.875rem; color: #b45309; margin-top: 6px; }
.auth-tabs {
    display: flex; background: #fef3c7; border-radius: 12px;
    padding: 4px; margin-bottom: 24px;
}
.auth-tab {
    flex: 1; padding: 10px; border: none; border-radius: 10px;
    background: transparent; color: #92400e;
    font-size: 0.9rem; font-weight: 600;
    cursor: pointer; transition: all 0.2s;
}
.auth-tab.active {
    background: white; color: #d97706;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}
.auth-input {
    width: 100%; padding: 13px 16px;
    border: 1px solid #fde68a; border-radius: 12px;
    background: #fffbeb; font-size: 0.9rem; color: #78350f;
    outline: none; transition: border-color 0.2s, box-shadow 0.2s;
    margin-bottom: 14px;
}
.auth-input:focus {
    border-color: #fbbf24;
    box-shadow: 0 0 0 3px rgba(251,191,36,0.12);
}
.auth-input::placeholder { color: #d4a76a; }
.auth-submit {
    width: 100%; padding: 14px; border: none; border-radius: 12px;
    background: linear-gradient(135deg, #fbbf24, #f59e0b);
    color: white; font-size: 1rem; font-weight: 600;
    cursor: pointer; transition: all 0.3s;
    box-shadow: 0 4px 16px rgba(245,158,11,0.25);
    margin-top: 4px;
}
.auth-submit:hover { transform: translateY(-1px); box-shadow: 0 6px 20px rgba(245,158,11,0.35); }
.auth-submit:active { transform: translateY(0); }
.auth-submit:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

/* ========== User Badge ========== */
.user-badge {
    font-size: 0.75rem; color: #92400e; font-weight: 500;
    padding: 4px 10px; background: #fef3c7; border-radius: 8px;
    max-width: 80px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* ========== Responsive ========== */
@media (max-width: 640px) {
    .card-area { min-height: 260px; }
    .card-face { max-width: 200px; }
    .glass-card { border-radius: 16px; }
    .nav-btn { width: 36px; height: 36px; }
    .achievements-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
    .progress-section { gap: 12px; }
    .progress-ring-wrapper { width: 64px; height: 64px; }
}

/* ========== Guide Page ========== */
.guide-container {
    min-height: 100vh;
    display: flex; align-items: flex-start; justify-content: center;
    padding: 24px 16px 40px; overflow-y: auto;
}
.guide-card {
    background: rgba(255,255,255,0.9);
    backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(251,191,36,0.15);
    border-radius: 24px; padding: 32px 24px;
    width: 100%; max-width: 420px;
    box-shadow: 0 8px 40px rgba(180,120,40,0.12);
}
.guide-welcome { text-align: center; margin-bottom: 24px; }
.guide-welcome h1 { font-size: 1.25rem; font-weight: 700; color: #92400e; margin-bottom: 8px; }
.guide-welcome p { font-size: 0.875rem; color: #b45309; }
.guide-section { margin-bottom: 20px; }
.guide-section-title { font-size: 1rem; font-weight: 700; color: #92400e; margin-bottom: 12px; }
.guide-item {
    background: rgba(254,243,199,0.3);
    border-radius: 12px; padding: 12px 14px;
    font-size: 0.85rem; color: #78350f; line-height: 1.6;
}
.guide-item + .guide-item { margin-top: 8px; }
.guide-item strong { color: #92400e; }
.guide-steps { display: flex; flex-direction: column; gap: 10px; }
.guide-step {
    display: flex; align-items: flex-start; gap: 12px;
    font-size: 0.85rem; color: #78350f; line-height: 1.5;
}
.step-num {
    display: flex; align-items: center; justify-content: center;
    width: 24px; height: 24px; flex-shrink: 0;
    border-radius: 50%; background: linear-gradient(135deg, #fbbf24, #f97316);
    color: white; font-size: 0.75rem; font-weight: 700;
}
.guide-stages {
    margin-top: 14px; padding: 12px 14px;
    background: rgba(254,243,199,0.3); border-radius: 12px;
}
.guide-stage-item {
    display: flex; align-items: center; gap: 8px;
    font-size: 0.8rem; color: #92400e; padding: 4px 0;
}
.stage-dot {
    width: 8px; height: 8px; border-radius: 50%;
    background: linear-gradient(135deg, #fbbf24, #f97316); flex-shrink: 0;
}
.guide-contact {
    text-align: center; margin: 20px 0 4px;
    padding: 16px; background: rgba(254,243,199,0.4);
    border-radius: 14px;
}
.guide-contact p { font-size: 0.85rem; color: #92400e; }
.guide-contact .wechat-id { font-weight: 700; color: #d97706; font-size: 1rem; margin-top: 6px; }

/* ========== Scrollbar ========== */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-thumb { background: #fbbf24; border-radius: 4px; }
::-webkit-scrollbar-track { background: transparent; }
