:root {
    --ui-bg: #f3f6f5;
    --ui-surface: #ffffff;
    --ui-line: #e4ebe8;
    --ui-text: #172521;
    --ui-muted: #71817b;
    --ui-accent: #16856f;
    --ui-accent-dark: #116b5a;
    --ui-shadow: 0 8px 24px rgba(27, 55, 46, .06);
}
html { background: var(--ui-bg); }
body { color: var(--ui-text); background: var(--ui-bg); }
a { color: var(--ui-accent); }
.page { width: 100%; }
.page-body { width: min(100% - 40px, 1120px); max-width: 1120px; padding: 28px 0 40px; }
.topbar { height: 58px; background: rgba(255,255,255,.96); border-bottom-color: var(--ui-line); box-shadow: 0 2px 12px rgba(27,55,46,.035); }
.topbar .back, .topbar .right { color: var(--ui-accent); }
.bottom-nav { background: rgba(255,255,255,.97); border-top: 1px solid var(--ui-line); padding-bottom: env(safe-area-inset-bottom); }
.card, .panel, .form-card, .auth-card, .comment-section, .post-card, .profile-card {
    border-color: var(--ui-line);
    box-shadow: var(--ui-shadow);
}
.card, .panel, .form-card, .auth-card { border-radius: 10px; }
button, .btn, input, select, textarea { font: inherit; }
button, .btn { transition: background-color .16s ease, border-color .16s ease, color .16s ease, transform .16s ease; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 3px solid rgba(22,133,111,.24); outline-offset: 2px; }
input, select, textarea { max-width: 100%; }
img, video, iframe { max-width: 100%; }
.table-wrap, .table-responsive { max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
@media (min-width: 1400px) {
    .page-body { width: min(100% - 64px, 1240px); max-width: 1240px; }
}
@media (max-width: 1024px) {
    .page-body { width: min(100% - 32px, 900px); padding-top: 22px; }
}
@media (max-width: 767px) {
    body { font-size: 14px; }
    .page-body { width: 100%; padding: 14px 14px calc(84px + env(safe-area-inset-bottom)); }
    .topbar { height: 52px; }
    .bottom-nav { min-height: 58px; }
    .card, .panel, .form-card, .auth-card { border-radius: 8px; }
    .flex-between { gap: 10px; flex-wrap: wrap; }
}
@media (max-width: 480px) {
    .page-body { padding-left: 12px; padding-right: 12px; }
    .topbar { font-size: 16px; }
    .auth-logo { padding: 26px 0 16px; }
    .auth-logo .icon { width: 60px; height: 60px; border-radius: 16px; font-size: 28px; }
    .field-row { display: block; }
    .field-row > .field { width: 100%; }
    input, select, textarea { min-width: 0; }
}
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; }
}

/* Page-specific responsive refinements */
.post-page, .profile-page { background: var(--ui-bg); }
.post-body { width: min(100% - 32px, 820px); max-width: 820px; }
.post-page .p-text, .comment-item .c-text { overflow-wrap: anywhere; word-break: break-word; }
.post-page .p-imgs img, .comment-item img { max-width: 100%; height: auto; object-fit: contain; }
.post-page .comment-section { border: 1px solid var(--ui-line); border-radius: 10px; background: var(--ui-surface); }
.post-page .comment-children { margin-left: 42px; border-left-color: #dce7e2; }
.post-page .comment-more-page { border-radius: 7px; }
.profile-page { min-height: 100vh; }
.profile-body { width: min(100% - 32px, 820px); max-width: 820px; }
.profile-body .card { border: 1px solid var(--ui-line); border-radius: 10px; }
.profile-body input, .profile-body select, .profile-body textarea { min-height: 42px; }
.home-root { background: var(--ui-bg); }
.home-root { bottom: calc(56px + env(safe-area-inset-bottom)); }
.home-empty, .home-ads-wrap { max-width: 1120px; margin-left: auto; margin-right: auto; }
@media (min-width: 768px) {
    .post-body { padding: 0; }
    .post-page .author-card, .post-page .content-card, .post-page .comment-section { border-radius: 10px; }
}
@media (max-width: 767px) {
    .post-body, .profile-body { width: 100%; max-width: none; }
    .post-page { padding-bottom: calc(90px + env(safe-area-inset-bottom)); }
    .post-page .comment-children { margin-left: 14px; padding-left: 10px; }
    .post-page .comment-item .m-actions { flex-wrap: wrap; gap: 8px; }
    .post-page .comment-item .m-act { min-height: 34px; }
    .profile-body { padding-left: 12px; padding-right: 12px; }
    .profile-head .ph-inner { flex-wrap: wrap; }
}
@media (max-width: 480px) {
    .post-body { width: 100%; }
    .post-page .author-card, .post-page .content-card { padding-left: 14px; padding-right: 14px; }
    .post-page .comment-children { margin-left: 8px; padding-left: 8px; }
    .profile-body .gender-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .profile-body .field { min-width: 0; }
}

/* Commerce, tasks, forum and account pages */
.exchange-body .goods-card, .task-card, .tieba-page .post-card, .my-body .card { border-color: var(--ui-line); box-shadow: var(--ui-shadow); }
.exchange-page .goods-card, .task-card, .tieba-page .post-card { border-radius: 9px; }
.exchange-page .goods-list { grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr)); }
.task-head, .tieba-top, .exchange-top { background: rgba(255,255,255,.96); border-bottom-color: var(--ui-line); }
.task-title, .goods-title, .tieba-page h1 { color: var(--ui-text); }
input, select, textarea { color: var(--ui-text); }
input::placeholder, textarea::placeholder { color: #84928d; }
.login-page, .reg-page { min-height: 100svh; padding-left: 16px; padding-right: 16px; }
.login-page .card, .reg-page .card { width: min(100%, 440px); border: 1px solid var(--ui-line); border-radius: 12px; box-shadow: 0 16px 42px rgba(25,58,46,.09); }
@media (min-width: 900px) {
    .exchange-body, .tieba-list, .my-body { max-width: 1180px; }
    .tieba-page .post-list { max-width: 980px; margin-left: auto; margin-right: auto; }
}
@media (max-width: 767px) {
    .exchange-page .goods-list { grid-template-columns: minmax(0, 1fr); }
    .tieba-page .post-list { padding-left: 10px; padding-right: 10px; }
    .my-header { border-radius: 0 0 12px 12px; }
    .login-page, .reg-page { padding: 16px 12px calc(24px + env(safe-area-inset-bottom)); }
    .login-page .card, .reg-page .card { width: 100%; max-width: 480px; }
}
@media (max-width: 420px) {
    .task-head { padding-left: 14px; padding-right: 14px; }
    .login-page .auth-logo, .reg-page .auth-logo { padding-top: 18px; }
    .login-page .btn-submit, .reg-page .btn-submit { width: 100%; min-height: 46px; }
    .login-page .card, .reg-page .card { padding-left: 16px; padding-right: 16px; border-radius: 10px; }
}
.task-page { width: min(100% - 32px, 1120px); margin: 0 auto; }
.task-card { border: 1px solid var(--ui-line); border-radius: 9px; box-shadow: var(--ui-shadow); }
.my-header { border-radius: 0 0 14px 14px; }
@media (max-width: 767px) {
    .task-page { width: 100%; padding-left: 12px; padding-right: 12px; }
    .exchange-page .goods-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .my-header { border-radius: 0 0 12px 12px; }
}
@media (max-width: 420px) {
    .exchange-page .goods-list { grid-template-columns: minmax(0, 1fr); }
}
.tieba-page { min-height: 100svh; background: var(--ui-bg); }
.tieba-page .tieba-top { border-bottom: 1px solid var(--ui-line); }
.tieba-page .post-list { width: min(100%, 980px); margin-left: auto; margin-right: auto; }
.my-header { box-shadow: 0 8px 24px rgba(25,58,46,.08); }
.my-header .user-info { min-width: 0; }
@media (max-width: 767px) {
    .tieba-page .post-list { width: 100%; }
    .my-header { padding-bottom: max(16px, env(safe-area-inset-bottom)); }
}

/* Secondary front-end pages */
.msg-page, .notif-page, .search-page, .user-page, .collect-page,
.publish-page, .report-page {
    color: var(--ui-text);
    background: var(--ui-bg);
}
.msg-page .topbar, .notif-page .topbar, .search-page .topbar,
.user-page .topbar, .collect-page .topbar, .publish-page .topbar,
.report-page .topbar { border-bottom-color: var(--ui-line); }
.conv-list, .notif-list, .result-wrap, .user-list, .collect-list {
    border-color: var(--ui-line);
}
.conv-item, .notif-item, .result-item, .user-item, .collect-card,
.post-item, .field, .reason-item, .info-tip {
    border-color: var(--ui-line);
}
.pager { color: var(--ui-muted); }
.pager a, .pager .cur { border-color: var(--ui-line); }
button, .btn, .btn-submit { border-radius: 8px; }
input, select, textarea {
    border-color: var(--ui-line);
    background: var(--ui-surface);
}
@media (max-width: 767px) {
    .msg-page, .notif-page, .search-page, .user-page, .collect-page,
    .publish-page, .report-page { min-height: 100svh; }
    .pager { flex-wrap: wrap; gap: 6px; }
    .conv-item, .notif-item, .result-item, .user-item, .collect-card,
    .post-item { min-width: 0; }
    .publish-page .field, .report-page .field { min-width: 0; }
}


/* Exchange detail rich content and small-screen lists */
.exchange-page .detail-rich { overflow-wrap: anywhere; }
.exchange-page .detail-rich img,
.exchange-page .detail-rich video,
.exchange-page .detail-rich iframe { max-width: 100%; }
.exchange-page .detail-rich table { display: block; max-width: 100%; overflow-x: auto; }
@media (max-width: 767px) {
    .exchange-page .detail-box { width: min(100% - 24px, 560px); max-height: 90svh; }
    .exchange-page .detail-body { min-height: 0; }
    .exchange-page .detail-rich { overflow-wrap: anywhere; }
    .msg-page, .notif-page, .search-page, .user-page, .collect-page,
    .publish-page, .report-page { overflow-x: clip; }
    .search-page .result-wrap, .collect-page .collect-list,
    .msg-page .conv-list, .notif-page .notif-list { min-width: 0; }
}

@media (min-width: 768px) {
    .page-body, .exchange-body { width: calc(100% - 32px); max-width: none; }
    .page-body { padding: 18px 0 24px; }
    .page-body, .exchange-page, .home-root, .post-page, .profile-page, .publish-page, .report-page, .login-page, .reg-page { min-height: 100%; }
}
@media (min-width: 768px) and (max-width: 1023px) {
    .exchange-page .goods-list { gap: 14px; }
}

/* Responsive rules aligned with the page markup. */
.post-page .post-body, .exchange-page { min-width: 0; }
.post-page .content-card, .post-page .comment-section, .exchange-page .detail-rich { overflow-wrap: anywhere; }
.post-page .content-card img, .post-page .content-card video, .post-page .content-card iframe,
.post-page .comment-section img, .exchange-page .detail-rich img,
.exchange-page .detail-rich video, .exchange-page .detail-rich iframe { max-width: 100%; height: auto; }
.post-page .content-card pre, .post-page .content-card table, .exchange-page .detail-rich pre, .exchange-page .detail-rich table { max-width: 100%; overflow-x: auto; }
.msg-page .conv-list, .notif-page .notif-list { min-width: 0; }
@media (max-width: 767px) {
    .post-page .post-body { width: 100%; padding-left: 12px; padding-right: 12px; }
    .post-page .author-card, .post-page .content-card, .post-page .comment-section { min-width: 0; }
    .post-page .content-card img, .post-page .comment-section img { height: auto; }
    .exchange-page .detail-box { width: calc(100% - 24px); max-width: 560px; max-height: 90vh; max-height: 90svh; }
    .exchange-page .detail-body { min-height: 0; overflow-y: auto; }
    .msg-page .conv-list, .notif-page .notif-list { width: 100%; }
    .pager { flex-wrap: wrap; gap: 6px; }
}


.home-root { min-width: 0; overflow-x: clip; }
.home-root .home-iframe-wrap, .home-root .home-html-wrap, .home-root .home-ads-wrap { width: min(100%, 1120px); margin-left: auto; margin-right: auto; }
.home-root .home-iframe-wrap iframe { display: block; width: 100%; border: 0; background: var(--ui-surface, #fff); }
.home-root .home-html-wrap { overflow-wrap: anywhere; }
.home-root .home-html-wrap img, .home-root .home-html-wrap video, .home-root .home-html-wrap iframe { max-width: 100%; }
.home-root .home-default { display: grid; min-height: min(72vh, 680px); place-items: center; padding: 28px 16px; }
.home-default .hd-box { width: min(100%, 560px); padding: 28px 24px; border: 1px solid var(--ui-line, #dce3df); border-radius: 10px; background: var(--ui-surface, #fff); box-shadow: var(--ui-shadow, 0 8px 28px rgba(24, 39, 33, .08)); text-align: center; }
.home-default .hd-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin-top: 20px; }
.home-default .hd-btn { display: inline-flex; min-height: 44px; align-items: center; justify-content: center; padding: 0 18px; border: 1px solid var(--ui-line, #dce3df); border-radius: 7px; text-decoration: none; }
.home-default .hd-btn.primary { border-color: #27835f; background: #27835f; box-shadow: none; }
.home-default .hd-btn.ghost { background: var(--ui-bg, #f4f7f5); color: var(--ui-text, #34433b); }
@media (max-width: 767px) {
    .home-root .home-iframe-wrap, .home-root .home-html-wrap, .home-root .home-ads-wrap { width: 100%; }
    .home-root .home-default { min-height: 58vh; padding: 20px 12px; }
    .home-default .hd-box { padding: 24px 18px; }
    .home-default .hd-actions { display: grid; grid-template-columns: minmax(0, 1fr); }
    .home-default .hd-btn { width: 100%; }
}
@media (min-width: 768px) {
    #appShell { width: min(100vw, calc(100vh * 9 / 16)); max-width: none; height: min(100vh, calc(100vw * 16 / 9)); min-height: 0; margin: 0 auto; }
    #appShell .page { min-height: 100%; height: auto; padding: 0; }
    .topbar { display: flex; }
    #pwaInstallBar, #pwaNotifyBar { position: absolute; }
    .exchange-page { min-height: 100%; padding: 0 0 24px; background: #f3f6f5; }
    .exchange-page .goods-list { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
    .exchange-page .goods-card { border: 1px solid #e4ebe8; border-radius: 8px; box-shadow: 0 4px 14px rgba(27,55,46,.07); }
    .exchange-page .goods-card:hover { transform: translateY(-3px); box-shadow: 0 10px 24px rgba(27,55,46,.12); }
}
@media (min-width: 768px) {
    .page-body, .exchange-body { width: calc(100% - 32px); max-width: none; }
    .page-body { padding: 18px 0 24px; }
    .page-body, .exchange-page, .home-root, .post-page, .profile-page, .publish-page, .report-page, .login-page, .reg-page { min-height: 100%; }
}
@media (min-width: 768px) and (max-width: 1023px) {
    .tabbar { justify-content: flex-start; overflow-x: auto; padding: 0 16px; }
    .page-body, .exchange-body { width: calc(100% - 40px); }
    .exchange-page .goods-list { gap: 14px; }
}
