html { scroll-behavior: smooth; }
* { box-sizing: border-box; }
body { font-size: var(--base-font-size, 18px); overflow-x: hidden; }
img, svg, video, canvas { max-width: 100%; height: auto; }
button, input, select, textarea { max-width: 100%; }
.access-btn { display: inline-flex; align-items: center; justify-content: center; border: 1px solid #cbd5e1; border-radius: 999px; padding: .45rem .7rem; font-weight: 700; background: white; }
.primary-btn { display: inline-flex; align-items: center; justify-content: center; border-radius: 1rem; background: #1d4ed8; color: white; padding: 1rem 1.35rem; font-size: 1.125rem; font-weight: 800; box-shadow: 0 10px 22px rgba(29,78,216,.2); text-align: center; }
.primary-btn:hover { background: #1e40af; }
.secondary-btn { display: inline-flex; align-items: center; justify-content: center; border-radius: 1rem; background: white; color: #1e3a8a; border: 1px solid #bfdbfe; padding: 1rem 1.35rem; font-size: 1.125rem; font-weight: 800; text-align: center; }
.secondary-btn:hover { background: #eff6ff; }
.section-title { font-size: clamp(2rem, 3vw, 3rem); font-weight: 900; line-height: 1.1; margin-bottom: .75rem; }
.section-subtitle { font-size: 1.25rem; color: #475569; line-height: 1.6; }
#categories,
#questions,
#ask-ai,
#register {
    scroll-margin-top: 96px;
}
.auth-panel, .content-panel, .admin-action-card { border-radius: 1.5rem; }
.category-card { background: white; border: 1px solid #e2e8f0; border-radius: 1.5rem; padding: 1.5rem; box-shadow: 0 6px 18px rgba(15,23,42,.06); transition: transform .18s ease, box-shadow .18s ease; }
.category-card:hover { transform: translateY(-3px); box-shadow: 0 12px 26px rgba(15,23,42,.1); }
.icon-circle { width: 3.5rem; height: 3.5rem; border-radius: 1.25rem; display: flex; align-items: center; justify-content: center; font-size: 2rem; background: #eff6ff; }
.faq-card { background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 1.5rem; padding: 1.5rem; }
.faq-card details { border-top: 1px solid #e2e8f0; padding: .9rem 0; }
.faq-card details:first-of-type { border-top: 0; }
.faq-card summary { cursor: pointer; font-weight: 750; font-size: 1.05rem; }
.faq-card p { margin-top: .55rem; color: #475569; line-height: 1.55; }
.chat-bubble { border: 1px solid; border-radius: 1.25rem; padding: 1rem 1.15rem; font-size: 1.1rem; line-height: 1.6; }
.mini-action { border: 1px solid #cbd5e1; border-radius: 1rem; padding: .8rem; background: white; font-weight: 700; }
.prompt-btn { width: 100%; text-align: left; border: 1px solid #e2e8f0; background: #f8fafc; border-radius: 1rem; padding: .85rem 1rem; font-weight: 650; }
.prompt-btn:hover { background: #eff6ff; border-color: #bfdbfe; }
.form-input { width: 100%; border: 1px solid #cbd5e1; border-radius: 1rem; padding: 1rem 1.15rem; font-size: 1.1rem; }
.ad-card { border: 2px dashed #cbd5e1; background: white; color: #475569; border-radius: 1.5rem; padding: 1.5rem; min-height: 130px; display: flex; align-items: center; justify-content: center; text-align: center; font-weight: 650; }
.en-hidden { display: none; }
html[data-lang="zh"] .zh-hidden { display: none; }
html[data-lang="zh"] .en-hidden { display: block; }
:focus-visible { outline: 4px solid #f59e0b; outline-offset: 3px; }

.signin-container {
    max-width: 420px;
    margin: 80px auto;
    padding: 32px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.1);
}

.signin-box {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-top: 24px;
}

.signin-box input {
    padding: 14px;
    font-size: 18px;
    border: 1px solid #ccc;
    border-radius: 8px;
}

.signin-box button {
    padding: 14px;
    font-size: 18px;
    background: #2563eb;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
}

.register-link-container {
    margin-top: 24px;
    text-align: center;
}

.register-link-container a {
    color: #2563eb;
    text-decoration: none;
    margin-left: 6px;
}

.faq-card {
    scroll-margin-top: 100px;
}

.question-toggle {
    min-width: 0;
}

.question-toggle span:first-child {
    overflow-wrap: anywhere;
}

.question-answer {
    overflow-wrap: anywhere;
}

.spoken-word {
    border-radius: .35rem;
    transition: background-color .12s ease, color .12s ease;
}

.spoken-word-active {
    background: #fde68a;
    color: #78350f;
    box-shadow: 0 0 0 2px #fde68a;
}

.comments-section {
    scroll-margin-top: 110px;
}

.comment-user-icon {
    width: 2.75rem;
    height: 2.75rem;
    border-radius: 999px;
    background: #dbeafe;
    color: #1e40af;
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    font-size: 1.35rem;
}

.comment-user-icon.small {
    width: 2.25rem;
    height: 2.25rem;
    font-size: 1rem;
}

.comment-input {
    resize: vertical;
}

.comment-card {
    display: flex;
    gap: .75rem;
    border: 1px solid #e2e8f0;
    background: #f8fafc;
    border-radius: 1rem;
    padding: 1rem;
}

.comment-reactions {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
}

.comment-reaction-btn {
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    border: 1px solid #cbd5e1;
    background: white;
    color: #475569;
    border-radius: 999px;
    padding: .35rem .65rem;
    font-size: .95rem;
    font-weight: 700;
    min-height: 36px;
    cursor: pointer;
}

.comment-reaction-btn:hover {
    background: #eff6ff;
    border-color: #93c5fd;
    color: #1d4ed8;
}

.comment-reaction-btn:disabled {
    cursor: wait;
    opacity: .65;
}

.comment-reply-link {
    color: #1d4ed8;
    font-weight: 800;
    padding: .35rem .25rem;
    min-height: 36px;
}

.comment-reply-link:hover {
    text-decoration: underline;
}

.comment-replies-toggle {
    color: #1d4ed8;
    font-weight: 800;
    margin-top: .75rem;
}

.comment-replies-toggle:hover {
    text-decoration: underline;
}

.comment-reply-card {
    margin-left: 2.25rem;
    border-left: 4px solid #bfdbfe;
}

.comment-reply-box {
    border-left: 4px solid #dbeafe;
    padding-left: 1rem;
}

.reply-input {
    resize: vertical;
}

@media (max-width: 640px) {
    body {
        font-size: var(--base-font-size, 17px);
    }

    #categories,
    #questions,
    #ask-ai,
    #register {
        scroll-margin-top: 112px;
    }

    .section-title {
        font-size: 2rem;
    }

    .section-subtitle {
        font-size: 1.1rem;
    }

    .auth-panel,
    .content-panel,
    .admin-action-card,
    .category-card,
    .faq-card,
    .ad-card {
        border-radius: 1rem;
    }

    .category-card,
    .faq-card,
    .ad-card {
        padding: 1.15rem;
    }

    .primary-btn,
    .secondary-btn {
        width: 100%;
        padding: .9rem 1rem;
        font-size: 1rem;
        min-height: 48px;
    }

    .form-input {
        padding: .9rem 1rem;
        font-size: 1rem;
    }

    .chat-bubble {
        border-radius: 1rem;
        padding: .9rem 1rem;
        font-size: 1rem;
    }

    .mini-action,
    .prompt-btn {
        min-height: 48px;
    }

    .question-toggle {
        align-items: flex-start;
        font-size: 1rem;
    }

    .question-answer .flex {
        flex-direction: column;
    }

    .comment-compose {
        flex-direction: column;
    }

    .comment-user-icon {
        width: 2.5rem;
        height: 2.5rem;
    }

    .comment-reply-card {
        margin-left: .75rem;
    }
}
