

/* ========== Responsive Design ========== */

/* Desktop + Tablet: 769px+ */
@media (min-width: 769px) {
    .app-aside { display: none; }
    .aside-overlay { display: none !important; }
    .aside-close-btn { display: none !important; }
    .desktop-header { display: block; }
    .app-main { margin-left: 0; }
    .app-footer { margin-left: 0; }
    .mobile-header { display: none; }
}

/* Tablet: 769px - 1024px */
@media (max-width: 1024px) {
    :root { --sidebar-width: 270px; }

    .app-main { margin-left: 0; padding: 20px; }

    .main-container { flex-direction: column; gap: 20px; }

    .app-sidebar { width: 100%; min-width: 0; flex-shrink: 1; }

    .sidebar-inner {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 16px;
        position: static;
    }

    .widget-tabs { grid-column: 1 / -1; }
    .sidebar-toggle { display: none; }

    .footer-inner { flex-direction: column; text-align: center; }

    .post-card-body { padding: 20px 24px; }
    .post-body { padding: 24px 28px; }
    .app-footer { margin-left: 0; }
}

/* Mobile: up to 768px */
@media (max-width: 768px) {
    :root {
        --aside-width: min(86vw, 320px);
        --sidebar-width: 100%;
    }

    .app-container { padding-top: var(--mobile-header-height); max-width: 100%; }
    .mobile-header { display: flex; }
    .desktop-header { display: none; }

    .app-aside {
        transform: translateX(-100%);
        position: fixed;
        top: var(--mobile-header-height);
        left: 0;
        bottom: 0;
        z-index: 950;
        width: var(--aside-width);
        box-shadow: none;
        display: flex;
        transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    }

    .show-aside .app-aside {
        transform: translateX(0);
        box-shadow: 8px 0 40px rgba(0, 0, 0, 0.2);
    }

    .show-aside .aside-overlay { opacity: 1; visibility: visible; display: block; }
    .aside-close-btn { display: flex; }

    .aside-user {
        display: grid;
        grid-template-columns: 52px minmax(0, 1fr);
        grid-template-rows: auto auto;
        align-items: center;
        column-gap: 12px;
        row-gap: 3px;
        padding: 18px 48px 16px 18px;
        text-align: left;
    }

    .aside-avatar-link {
        grid-row: 1 / 3;
        margin: 0;
    }

    .aside-avatar {
        width: 52px;
        height: 52px;
        margin: 0;
    }

    .aside-user-info { min-width: 0; }
    .aside-user-name { font-size: 16px; margin-bottom: 2px; }
    .aside-user-bio { font-size: 12px; }

    .aside-greeting {
        grid-column: 2;
        margin: 0;
        font-size: 12px;
    }

    .aside-greeting p { margin: 0; }
    .time-progress { display: none; }

    .aside-nav { padding: 10px 10px 6px; }
    .nav-list li { margin: 2px 0; }

    .nav-item {
        min-height: 48px;
        padding: 8px 10px;
        font-size: 14px;
        border-radius: 12px;
    }

    .nav-icon {
        width: 32px;
        height: 32px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        margin-right: 10px;
        border-radius: 10px;
        background: var(--bg-hover);
    }

    .nav-sub-list li { margin: 0; }
    .nav-sub-list li a {
        padding: 9px 12px 9px 54px;
        font-size: 13px;
        border-radius: 10px;
    }

    .aside-footer { padding: 16px 24px; gap: 10px; }
    .aside-footer-btn { width: 38px; height: 38px; font-size: 19px; }
    .app-aside .aside-footer { display: none; }

    .app-aside.has-mobile-sidebar .aside-nav {
        flex: none;
        overflow-y: visible;
    }

    .app-aside .app-sidebar.sidebar-in-aside {
        width: 100%;
        min-width: 0;
        flex-shrink: 0;
        padding: 0 16px 20px;
        box-sizing: border-box;
        border-top: 1px solid var(--border-light);
    }

    .app-aside .app-sidebar.sidebar-in-aside::before {
        content: '更多内容';
        display: block;
        padding: 14px 2px 8px;
        color: var(--text-muted);
        font-size: 11px;
        font-weight: 700;
        letter-spacing: 0.12em;
    }

    .app-aside .sidebar-in-aside .sidebar-inner {
        display: flex;
        flex-direction: column;
        gap: 0;
        position: static;
    }

    /* 顶部用户区已展示站长资料，避免移动抽屉内重复显示个人资料卡片。 */
    .app-sidebar .widget-emlog-blogger { display: none; }

    .app-aside .sidebar-in-aside .sidebar-widget {
        padding: 14px 2px;
        background: transparent;
        border-radius: 0;
        border-bottom: 1px solid var(--border-light);
        box-shadow: none;
        overflow: visible;
    }

    .app-aside .sidebar-in-aside .sidebar-widget:last-child {
        border-bottom: 0;
    }

    .app-aside .sidebar-in-aside .sidebar-widget:hover {
        box-shadow: none;
        transform: none;
    }

    .app-aside .sidebar-in-aside .widget-title {
        margin-bottom: 10px;
        padding-bottom: 8px;
        border-bottom: 0;
        font-size: 14px;
    }

    .app-main { margin-left: 0; padding: 14px; }
    .main-container { flex-direction: column; gap: 14px; overflow: hidden; }
    .content-wrapper { width: 100%; max-width: 100%; overflow: hidden; }

    .app-sidebar { width: 100%; min-width: 0; flex-shrink: 1; }

    .sidebar-inner { display: flex; flex-direction: column; gap: 14px; position: static; }
    .sidebar-toggle { display: none; }
    .app-footer { margin-left: 0; }

    .footer-inner { flex-direction: column; text-align: center; gap: 8px; }

    .post-card-body { padding: 14px 18px; }
    .post-card-title { font-size: 1.1rem; }
    .post-card-meta { font-size: 12px; }
    /* 手机端小图卡片：保持左图右文横向布局，图片缩小但保持包裹样式 */
    .post-card-img-small { width: 130px; min-width: 130px; padding: 10px; }
    .post-card-img-small img { border-radius: 12px; }
    .post-card-a .post-card-body { padding: 10px 12px; min-height: 90px; gap: 5px; }
    .post-card-a .post-card-title { font-size: 0.95rem; margin-bottom: 0; }
    .post-card-a .post-card-desc { font-size: 12px; line-height: 1.75; margin-bottom: 0; }
.post-card-a .post-card-foot { padding-top: 6px; gap: 8px; }
    .post-card-a .post-card-foot .foot-left { gap: 5px; }
    .post-card-a .post-card-foot .foot-right { gap: 8px; }
.post-card-a .post-card-foot .foot-dot { display: none; }
    .post-card-a .post-card-foot .foot-date { display: none; }
    .post-card-a .post-card-foot .foot-item { font-size: 11px; }
    .post-card-a .post-card-foot .foot-item i { font-size: 12px; }
    .post-card-b { min-height: 200px; }
    .post-card-b-inner { padding: 24px 18px 18px; }
    .post-card-b-inner .post-card-title { font-size: 1.1rem; }
.post-card-c .post-card-title { font-size: 1.05rem; }
    .post-card-c .post-card-body { padding: 14px 18px; min-height: 80px; }
    .post-card-foot { gap: 10px; font-size: 11px; }

    .post-body { padding: 18px 20px; }
    .post-title { font-size: 1.4rem; }
    .post-meta-bar { font-size: 12px; gap: 5px; }

    .comments-section { padding: 18px 20px; }
    .comment-children { margin-left: 12px; padding-left: 8px; }
    .comment-avatar img { width: 32px; height: 32px; }
    .comment-avatar { margin-right: 6px; }
    .comment-infos { margin-left: 38px; padding: 10px 12px; }
    .comment-form-fields { flex-direction: column; gap: 10px; }
    .comment-form-footer { flex-direction: column; align-items: stretch; gap: 10px; }
    .comment-form-submit-area {
        margin-left: 0;
        justify-content: flex-end;
        flex-wrap: wrap;
        gap: 10px;
    }
    .captcha-group { flex: 1 1 auto; justify-content: flex-start; min-width: 0; }
    .btn-submit { white-space: nowrap; flex-shrink: 0; }

    .related-grid { grid-template-columns: 1fr; }

    .form-row { flex-direction: column; gap: 0; }

    .single-post .post-cover { max-height: 240px; }
    .single-post .post-cover img { max-height: 240px; }

    .post-neighbor { flex-direction: column; gap: 10px; }
    .post-neighbor a { max-width: 100%; }

    .floating-actions { bottom: 20px; right: 20px; gap: 8px; }
    .floating-action-btn, .back-to-top { width: 40px; height: 40px; font-size: 20px; }

    .pagination-wrapper .pagination a,
    .pagination-wrapper .pagination span {
        min-width: 34px; height: 34px; font-size: 13px; padding: 0 8px;
    }
}

/* Small Mobile: up to 480px */
@media (max-width: 480px) {
    :root { --aside-width: 85%; }

    .app-main { padding: 10px; }
    .main-container { gap: 12px; }

    .post-card-body { padding: 12px 16px; }
    .post-card-title { font-size: 1rem; }
    .post-card-desc { font-size: 13px; -webkit-line-clamp: 2; }
    /* 小屏手机端小图卡片：保持左图右文，图片更小但保持包裹样式 */
    .post-card-img-small { width: 110px; min-width: 110px; padding: 8px; }
    .post-card-img-small img { border-radius: 10px; }
    .post-card-a .post-card-body { padding: 8px 10px; min-height: 78px; gap: 3px; }
    .post-card-a .post-card-title { font-size: 0.88rem; margin-bottom: 0; }
    .post-card-a .post-card-desc { font-size: 11px; line-height: 1.7; -webkit-line-clamp: 2; margin-bottom: 0; }
.post-card-a .post-card-foot { padding-top: 4px; gap: 6px; }
    .post-card-a .post-card-foot .foot-left { gap: 4px; }
    .post-card-a .post-card-foot .foot-right { gap: 6px; }
.post-card-a .post-card-foot .foot-dot { display: none; }
    .post-card-a .post-card-foot .foot-date { display: none; }
    .post-card-a .post-card-foot .foot-item { font-size: 10px; }
    .post-card-a .post-card-foot .foot-item i { font-size: 11px; }
    .post-card-b { min-height: 160px; }
    .post-card-b-inner { padding: 20px 16px 14px; }
    .post-card-b-inner .post-card-title { font-size: 1rem; }
    .post-card-meta { font-size: 11px; }
.post-card-c .post-card-title { font-size: 0.95rem; }
    .post-card-c .post-card-body { padding: 12px 16px; min-height: 70px; }
    .post-card-foot { gap: 8px; font-size: 10px; flex-wrap: wrap; }
    .pull-right { gap: 8px; }

    .post-body { padding: 16px; }
    .post-title { font-size: 1.2rem; }
    .post-content { font-size: 15px; }

    .comments-section { padding: 16px; }
    .comments-title { font-size: 1.1rem; }
    .sidebar-inner { gap: 12px; }
    .sidebar-widget { padding: 14px 16px; }
}

/* ========== Print Styles ========== */
@media print {
    *, *::before, *::after {
        background: #fff !important;
        color: #000 !important;
        box-shadow: none !important;
        text-shadow: none !important;
    }

    body { font-size: 12pt; line-height: 1.6; }

    .app-aside, .app-sidebar, .mobile-header, .aside-overlay,
    .back-to-top, .app-footer, .comments-section, .post-neighbor,
    .post-tags-section, .sidebar-toggle, .desktop-header { display: none !important; }

    .app-container { display: block; max-width: 100%; padding-top: 0; }
    .app-main { margin-left: 0; padding: 0; }
    .main-container { display: block; gap: 0; }
    .content-wrapper { width: 100%; }

    .post-card, .single-post {
        box-shadow: none;
        border: 1px solid #ccc;
        page-break-inside: avoid;
    }

    a { text-decoration: underline; }

    a[href]:after {
        content: " (" attr(href) ")";
        font-size: 0.8em;
        color: #666;
    }

    .post-content pre, .post-content code {
        border: 1px solid #ccc;
        background: #f5f5f5 !important;
    }
}

/* Shiguang responsive layout */
@media (max-width: 1024px) {
    .app-main {
        padding: 20px 16px 38px;
    }

    .sidebar-inner {
        gap: 14px;
    }
}

@media (max-width: 768px) {
    body.handsome-body {
        background:
            radial-gradient(circle at 0 9%, rgba(90,194,255,.34), transparent 31%),
            radial-gradient(circle at 100% 24%, rgba(255,165,210,.24), transparent 32%),
            linear-gradient(150deg, #eff9ff, #fff 54%, #f5f3ff);
    }

    body.dark-mode.handsome-body {
        background:
            radial-gradient(circle at 0 9%, rgba(47,136,207,.18), transparent 31%),
            radial-gradient(circle at 100% 24%, rgba(155,77,143,.13), transparent 32%),
            linear-gradient(150deg, #0d1522, #121b29 54%, #111827);
    }

    .mobile-header {
        top: 10px;
        left: 11px;
        right: 11px;
        width: auto;
        height: 54px;
        padding: 0 7px;
        border: 1px solid var(--glass-border);
        border-radius: 19px;
        box-shadow: var(--shadow-md);
    }

    .mobile-logo {
        font-weight: 800;
        letter-spacing: .035em;
    }

    .mobile-menu-btn,
    .mobile-dark-btn {
        width: 40px;
        height: 40px;
        border-radius: 13px;
    }

    .app-container {
        padding-top: 74px;
    }

    .app-main {
        padding: 10px 11px 32px;
    }

    .main-container {
        gap: 14px;
    }

    .app-aside {
        top: 0;
        z-index: 1100;
        border-radius: 0 24px 24px 0;
        box-shadow: var(--shadow-elevated);
    }

    .show-aside .app-aside {
        box-shadow: var(--shadow-elevated);
    }
.post-list {
        gap: 14px;
    }

    .post-card {
        border-radius: 23px;
    }

    .post-card-a {
        min-height: 0;
    }

    .post-card-img-small {
        margin: 11px 11px 0;
        border-radius: 18px;
    }

    .post-card-a .post-card-body,
    .post-card-body {
        padding: 20px;
    }

    .post-card-title {
        font-size: 20px;
    }

    .single-post {
        border-radius: 25px;
    }

    .post-cover {
        margin: 10px 10px 0;
        width: calc(100% - 20px);
        border-radius: 19px;
    }

    .post-body {
        padding: 25px 21px 28px;
    }

    .post-title {
        font-size: 28px;
    }

    .post-content {
        font-size: 15.5px;
    }

    .post-content img {
        border-radius: 16px;
    }

    .comments-section {
        padding: 23px 19px;
        border-radius: 25px;
    }

    .sidebar-widget {
        border-radius: 22px;
    }

    .footer-inner {
        width: calc(100% - 22px);
        border-radius: 18px;
    }

    .floating-actions {
        right: 14px;
        bottom: max(16px, env(safe-area-inset-bottom));
    }
}

@media (max-width: 480px) {
.post-card-a .post-card-foot {
        gap: 8px;
    }

    .post-meta-bar .meta-item {
        padding: 4px 7px;
    }

    .error-container {
        padding: 42px 22px !important;
    }
}

@media (prefers-reduced-motion: reduce) {
    body.handsome-body {
        background-attachment: scroll;
    }

    .post-card:hover,
    .sidebar-widget:hover,
    .desktop-nav-item:hover,
    .floating-action-btn:hover,
    .back-to-top:hover {
        transform: none;
    }
}

/* Semantic dark mode and focus normalization */
.comment-top-badge {
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
}

.comment-is-top > .comment-infos,
.comment-is-author > .comment-infos {
    border-color: rgba(var(--accent-rgb), .34);
    background: rgba(var(--accent-rgb), .06);
}

.comment-is-top > .comment-avatar img,
.comment-is-author .comment-avatar img {
    border-color: var(--accent);
}

body.dark-mode .desktop-header-brand {
    color: var(--text-primary);
}

body.dark-mode .desktop-header-brand i {
    color: #fff;
}

body.dark-mode .desktop-header-brand:hover,
body.dark-mode .desktop-nav-item:hover,
body.dark-mode .desktop-nav-subitem:hover,
body.dark-mode .desktop-nav-subitem:hover i,
body.dark-mode .desktop-action-btn:hover {
    color: var(--accent);
}

body.dark-mode .desktop-header-actions,
body.dark-mode .widget-link-item,
body.dark-mode .widget-comment-item,
body.dark-mode .widget-post-item,
body.dark-mode .widget-emlog .widget-title {
    border-color: var(--border-light);
}

body.dark-mode .desktop-nav-item,
body.dark-mode .desktop-nav-subitem,
body.dark-mode .widget-link-item a,
body.dark-mode .widget-sort-item > a,
body.dark-mode .widget-comment-text,
body.dark-mode .widget-post-item a,
body.dark-mode .widget-twitter-content,
body.dark-mode .widget-custom-content {
    color: var(--text-secondary);
}

body.dark-mode .desktop-nav-subitem i,
body.dark-mode .widget-sort-sub-item a,
body.dark-mode .widget-blogger-description,
body.dark-mode .widget-empty,
body.dark-mode .load-more-end,
body.dark-mode .comment-pagination em {
    color: var(--text-muted);
}

body.dark-mode .desktop-nav-item:hover,
body.dark-mode .desktop-nav-subitem:hover,
body.dark-mode .desktop-action-btn:hover,
body.dark-mode .tag-cloud-item:hover {
    background: rgba(var(--accent-rgb), .10);
}

body.dark-mode .desktop-nav-submenu,
body.dark-mode .comment-pagination a {
    color: var(--text-secondary);
    border-color: var(--glass-border);
    background: var(--bg-card-solid);
}

body.dark-mode .page-link,
body.dark-mode .load-more-btn {
    color: var(--accent);
    border-color: rgba(var(--accent-rgb), .32);
    background: rgba(var(--accent-rgb), .07);
}

body.dark-mode .page-link:hover,
body.dark-mode .load-more-btn:hover,
body.dark-mode .comment-pagination a:hover {
    color: #fff;
    border-color: transparent;
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
}

body.dark-mode .page-item.active .page-link,
body.dark-mode .comment-pagination span {
    color: #fff;
    border-color: transparent;
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
}

body.dark-mode .comment-infos,
body.dark-mode .comment-is-author > .comment-infos,
body.dark-mode .comment-is-top > .comment-infos {
    border-color: rgba(var(--accent-rgb), .24);
    background: rgba(var(--accent-rgb), .07);
}

body.dark-mode .comment-item:hover > .comment-infos {
    border-color: rgba(var(--accent-rgb), .46);
    box-shadow: 0 8px 22px rgba(0,0,0,.18);
}

body.dark-mode .comment-avatar img,
body.dark-mode .comment-is-author .comment-avatar img,
body.dark-mode .comment-is-top > .comment-avatar img {
    border-color: var(--accent);
}

body.dark-mode .form-input,
body.dark-mode .form-textarea,
body.dark-mode .captcha-group .captcha_input,
body.dark-mode .widget-search-input,
body.dark-mode .widget-archive-select {
    color: var(--text-primary);
    border-color: var(--border-input);
    background: var(--bg-input);
}

body.dark-mode .form-input:focus,
body.dark-mode .form-textarea:focus,
body.dark-mode .captcha-group .captcha_input:focus {
    border-color: rgba(var(--accent-rgb), .55);
    box-shadow: 0 0 0 4px rgba(var(--accent-rgb), .11);
}

body.dark-mode .comment-form-avatar {
    background: var(--bg-hover);
}

body.dark-mode .post-card:hover,
body.dark-mode .single-post,
body.dark-mode .comments-section {
    box-shadow: var(--shadow-card);
}

body.dark-mode .post-content code {
    color: var(--accent);
}

body.dark-mode .post-content pre code {
    color: #dfe7f1;
}
:root {
    --action-gradient: linear-gradient(135deg, #197ac9, #6950cc);
}

.desktop-header-brand i,
.comment-top-badge,
.comments-header-left > i,
.comments-count-badge,
.comment-submit,
.btn-submit,
body.dark-mode .page-item.active .page-link,
body.dark-mode .comment-pagination span {
    background: var(--action-gradient);
}

.load-more-btn:hover,
.floating-action-btn:hover,
.back-to-top:hover,
body.dark-mode .page-link:hover,
body.dark-mode .load-more-btn:hover,
body.dark-mode .comment-pagination a:hover {
    background: var(--action-gradient);
}
a:focus-visible,
button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
    outline: 3px solid rgba(var(--accent-rgb), .42);
    outline-offset: 3px;
}

@media (max-width: 768px) {
    .mobile-menu-btn,
    .mobile-dark-btn {
        width: 44px;
        height: 44px;
    }
}

@media (max-width: 768px) {
    .app-aside .app-sidebar.sidebar-in-aside { padding: 0 12px 22px; border-top-color: var(--border-light); }
    .app-aside .app-sidebar.sidebar-in-aside::before { padding: 18px 4px 10px; font-size: 12px; }
    .app-aside .sidebar-in-aside .sidebar-inner { gap: 11px; }
    .app-aside .sidebar-in-aside .sidebar-widget,
    .app-aside .sidebar-in-aside .sidebar-widget:last-child {
        padding: 15px 16px;
        overflow: hidden;
        border: 1px solid var(--glass-border);
        border-radius: 18px;
        background: rgba(249, 253, 255, .94);
        box-shadow: 0 10px 28px rgba(68,81,107,.08), inset 0 1px 0 rgba(255,255,255,.88);
        -webkit-backdrop-filter: none;
        backdrop-filter: none;
    }
    .app-aside .sidebar-in-aside .sidebar-widget:hover { box-shadow: 0 10px 28px rgba(68,81,107,.08); transform: none; }
    .app-aside .sidebar-in-aside .widget-title { margin-bottom: 12px; padding-bottom: 11px; border-bottom: 1px solid var(--border-light); font-size: 14px; }
    .app-aside .sidebar-in-aside .widget-title i { width: 30px; height: 30px; display: grid; place-items: center; border-radius: 10px; background: rgba(var(--accent-rgb), .11); }
    .app-aside .sidebar-in-aside .widget-empty { padding: 16px 10px; border-radius: 13px; background: rgba(var(--accent-rgb), .045); }
    .app-aside .sidebar-in-aside .widget-search-form { gap: 8px; align-items: stretch; }
    .app-aside .sidebar-in-aside .widget-search-input { min-width: 0; height: 44px; padding: 0 12px; border: 1px solid var(--border-input); border-radius: 13px; background: var(--bg-input); box-shadow: none; }
    .app-aside .sidebar-in-aside .widget-search-input:focus { border-color: rgba(var(--accent-rgb), .68); box-shadow: inset 0 0 0 2px rgba(var(--accent-rgb), .17); }
    .app-aside .sidebar-in-aside .widget-search-btn { width: 44px; min-width: 44px; height: 44px; padding: 0; border: 0; border-radius: 13px; background: var(--action-gradient); box-shadow: 0 8px 18px rgba(var(--accent-rgb), .18); }
    body.dark-mode .app-aside .sidebar-in-aside .sidebar-widget { border-color: var(--glass-border); background: rgba(31, 43, 61, .96); box-shadow: 0 12px 30px rgba(0,0,0,.20), inset 0 1px 0 rgba(255,255,255,.04); }
    body.handsome-body { background-attachment: scroll; }
    .mobile-header, .app-aside { -webkit-backdrop-filter: none; backdrop-filter: none; }
}

/* Continuous painted desktop background */
@media (min-width: 769px) {
    body.handsome-body {
        padding-top: 12px;
    }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    .post-card:hover { transform: none !important; }
}
