/* 飞书风格响应式设计 - 移动优先 */

/* 移动端基础样式 (默认) */
@media screen and (max-width: 767px) {
    :root {
        --header-height: 50px;
        --nav-height: 44px;
        --container-padding: 12px;
        --card-margin: 8px;
        --font-scale: 0.9;
    }

    /* 头部移动端优化 */
    .header {
        height: var(--header-height);
        line-height: var(--header-height);
        padding: 0 8px;
        font-size: 16px;
    }

    .header .bookname {
        font-size: 16px;
        padding: 0 8px;
    }

    .header .operate {
        padding: 0 12px;
        height: 32px;
        line-height: 32px;
        font-size: 13px;
        margin: 0 4px;
        border-radius: var(--radius-small);
    }

    /* 导航移动端优化 */
    .nav {
        height: var(--nav-height);
        line-height: var(--nav-height);
    }

    .nav ul li a {
        font-size: 14px;
        padding: 0 8px;
    }

    #navbox {
        top: calc(var(--header-height) + var(--nav-height));
    }

    #navbox ul {
        grid-template-columns: repeat(2, 1fr);
        gap: 4px;
        padding: 8px;
    }

    #navbox li {
        padding: 6px 8px;
    }

    #navbox li a {
        font-size: 13px;
    }

    /* 容器移动端优化 */
    .wrap-box {
        margin: var(--card-margin);
        border-radius: var(--radius-medium);
    }

    .wrap-title {
        height: 44px;
        line-height: 44px;
        padding: 0 12px;
        font-size: 15px;
    }

    .wrap-title .more {
        font-size: 13px;
        right: 12px;
    }

    .block-box {
        padding: 0;
    }

    /* 搜索框移动端优化 */
    .novel_search {
        padding: 12px 8px;
        margin: var(--card-margin);
    }

    #novel_search input {
        height: 40px;
        font-size: 14px;
        padding: 0 12px;
    }

    #novel_search button {
        height: 40px;
        font-size: 14px;
        padding: 0 16px;
    }

    /* 书籍卡片移动端优化 */
    .rec-focus,
    .sort-box,
    .rank-box {
        padding: 12px;
    }

    .rec-focus-book,
    .sort-book-first,
    .rank-book-first {
        height: 100px;
        margin-bottom: 12px;
        padding: 12px;
    }

    .rec-focus-book .book-img,
    .sort-book-first .book-img,
    .rank-book-first .book-img {
        width: 70px;
        margin-right: 12px;
    }

    .rec-focus-book .book-img img,
    .sort-book-first .book-img img,
    .rank-book-first .book-img img {
        width: 70px;
        height: 90px;
    }

    .rec-focus-book .book-info h2,
    .sort-book-first .book-info h4,
    .rank-book-first .book-info h4 {
        font-size: 15px;
        line-height: 20px;
        margin-bottom: 6px;
    }

    .rec-focus-book .book-info p,
    .sort-book-first .book-info p,
    .rank-book-first .book-info p {
        font-size: 12px;
        line-height: 18px;
    }

    /* 列表项移动端优化 */
    .sort-book-list li,
    .rank-book-list li {
        line-height: 40px;
        padding: 8px 12px;
    }

    .sort-book-list li span,
    .rank-book-list li span {
        font-size: 12px;
    }

    .rank-book-list li {
        padding-left: 40px;
    }

    .rank-book-list li span {
        width: 20px;
        height: 18px;
        line-height: 18px;
        font-size: 11px;
        left: 12px;
        top: 11px;
    }

    /* 导航列表移动端优化 */
    .navbar-list ul {
        grid-template-columns: 1fr;
        gap: 8px;
        padding: 0 var(--card-margin);
    }

    .navbar-list li a {
        padding: 12px;
        font-size: 15px;
    }

    /* 分类导航移动端优化 */
    .navpf {
        margin: var(--card-margin);
    }

    .sortChannel_nav {
        padding: 8px 12px;
        font-size: 14px;
    }

    .sortChannel_nav a {
        padding: 4px 8px;
        margin: 0 2px;
        font-size: 13px;
        line-height: 28px;
        height: 28px;
    }

    /* 书籍详情移动端优化 */
    .book-main {
        padding: 16px 12px;
        margin: var(--card-margin);
    }

    .book-main .book-img {
        width: 80px;
        height: 110px;
        margin-right: 12px;
    }

    .book-main .book-img img {
        width: 80px;
        height: 110px;
    }

    .book-main .bookname h1 {
        font-size: 18px;
        line-height: 24px;
        margin-bottom: 6px;
    }

    .book-main .bookname span {
        font-size: 13px;
        margin-left: 6px;
    }

    .book-main .book-info p {
        font-size: 13px;
        line-height: 20px;
        margin: 4px 0;
    }

    /* 按钮组移动端优化 */
    .book-detail-btn {
        margin: 16px 0 0;
    }

    .btn-group {
        flex-direction: column;
        gap: 8px;
    }

    .btn-normal {
        height: 40px;
        line-height: 40px;
        font-size: 14px;
    }

    /* 章节列表移动端优化 */
    .chapter-list li a {
        padding: 10px 12px;
        min-height: 40px;
    }
    
    .chapter-list li a span:first-child {
        font-size: 13px;
    }
    
    .chapter-list li a span:last-child {
        font-size: 11px;
    }

    /* 隐藏结构化数据meta标签在移动端 */
    .chapter-list li meta {
        display: none !important;
    }

    /* 阅读设置移动端优化 - 紧凑一行布局 */
    .set {
        margin: 8px 12px !important;
        padding: 4px 8px !important;
        background-color: var(--bg-card) !important;
        border-radius: 6px !important;
        box-shadow: 0 1px 4px rgba(0,0,0,0.1) !important;
        border: 1px solid var(--border-color) !important;
        
        /* 紧凑一行布局 */
        display: flex !important;
        align-items: center !important;
        justify-content: space-between !important;
        flex-wrap: nowrap !important;
        min-height: 32px !important;
        gap: 12px !important;
    }

    /* 左侧主题按钮组 */
    .set .set1 {
        flex: 0 0 auto !important;
        margin: 0 2px !important;
        padding: 4px 8px !important;
        font-size: 13px !important;
        height: 24px !important;
        line-height: 16px !important;
        border-radius: 4px !important;
        background-color: var(--bg-secondary) !important;
        border: 1px solid var(--border-color) !important;
        color: var(--text-primary) !important;
        white-space: nowrap !important;
        min-width: 36px !important;
        text-align: center !important;
        display: inline-block !important;
        cursor: pointer !important;
        transition: all 0.2s ease !important;
    }

    .set .set1:hover,
    .set .set1.active {
        background-color: var(--accent-color) !important;
        color: white !important;
        border-color: var(--accent-color) !important;
        transform: none !important; /* 移除transform效果 */
    }

    /* 右侧字体控制组 */
    .set .set2 {
        flex: 0 0 auto !important;
        display: flex !important;
        align-items: center !important;
        gap: 2px !important;
        margin: 0 !important;
        white-space: nowrap !important;
    }

    /* "字體："标签 */
    .set .set2 > span:first-child {
        font-size: 12px !important;
        color: var(--text-secondary) !important;
        margin-right: 4px !important;
        padding: 0 !important;
        border: none !important;
        background: none !important;
        cursor: default !important;
        line-height: 24px !important;
    }

    /* 字体大小按钮 */
    .set .set2 span:not(:first-child) {
        flex: 0 0 auto !important;
        padding: 4px 6px !important;
        font-size: 12px !important;
        height: 24px !important;
        line-height: 16px !important;
        border-radius: 3px !important;
        background-color: var(--bg-secondary) !important;
        border: 1px solid var(--border-color) !important;
        color: var(--text-primary) !important;
        margin: 0 1px !important;
        min-width: 24px !important;
        text-align: center !important;
        cursor: pointer !important;
        transition: all 0.2s ease !important;
    }

    .set .set2 span:not(:first-child):hover,
    .set .set2 span:not(:first-child).active {
        background-color: var(--accent-color) !important;
        color: white !important;
        border-color: var(--accent-color) !important;
        transform: none !important; /* 移除transform效果 */
    }

    /* 阅读内容移动端优化 */
    .content {
        margin: var(--card-margin);
    }

    .content h1 {
        padding: 16px 12px;
        font-size: 18px;
    }

    .txt {
        padding: 20px 16px;
        font-size: 16px;
        line-height: 1.8;
    }

    /* 章节导航移动端优化 */
    .chapter-page-btn {
        padding: 12px 8px;
    }

    .chapter-page-btn ul {
        grid-template-columns: repeat(2, 1fr);
        gap: 6px;
    }

    .chapter-page-btn li a {
        height: 40px;
        line-height: 40px;
        font-size: 14px;
    }

    /* 书架移动端优化 */
    .bookcase-book {
        margin: 0 var(--card-margin) var(--card-margin);
        padding: 12px;
    }

    .bookcase-book .book-img {
        width: 70px;
        margin-right: 12px;
    }

    .bookcase-book .book-img img {
        width: 70px;
        height: 90px;
    }

    .bookcase-book h4 {
        font-size: 15px;
        line-height: 20px;
        margin-bottom: 6px;
    }

    .bookcase-book .author,
    .bookcase-book .classify,
    .bookcase-book .read {
        font-size: 12px;
        line-height: 18px;
    }

    .bookcase-book .del-btn {
        right: 12px;
        top: 12px;
    }

    .bookcase-book .del-btn a {
        width: 50px;
        height: 28px;
        line-height: 28px;
        font-size: 11px;
    }

    /* 底部移动端优化 */
    .footer {
        height: 48px;
        line-height: 48px;
        padding: 12px 0;
    }

    .footer li {
        font-size: 14px;
    }

    /* 按钮移动端优化 */
    .btn-mulu {
        padding: 10px 20px;
        margin: 12px auto;
        font-size: 14px;
        max-width: 180px;
    }

    /* 页码移动端优化 */
    .page_num {
        padding: 12px;
        margin: 0 var(--card-margin);
        font-size: 13px;
        flex-wrap: wrap;
        gap: 8px;
    }

    .page_num select {
        height: 32px;
        font-size: 13px;
        min-width: 120px;
    }

    .page_num a {
        height: 32px;
        line-height: 32px;
        padding: 0 12px;
        font-size: 13px;
    }

    /* 分类页面移动端优化 */
    .sort_list > li {
        padding: 10px 12px;
        line-height: 22px;
    }

    .sort_list > li .s5 {
        font-size: 12px;
    }

    .sort_page_num {
        padding: 12px;
        margin: 0 var(--card-margin);
    }

    .sort_page_num > a {
        padding: 6px 12px;
        margin: 3px;
        font-size: 13px;
    }

    /* 登录页面移动端优化 */
    .novel_login .login {
        margin: var(--card-margin);
        padding: 20px 16px;
    }

    .novel_login .login h2 {
        font-size: 18px;
        margin-bottom: 20px;
    }

    .novel_login .login input[type="text"],
    .novel_login .login input[type="password"] {
        height: 40px;
        font-size: 14px;
        padding: 0 12px;
        margin-bottom: 12px;
    }

    .novel_login .login_btn a {
        height: 40px;
        line-height: 40px;
        font-size: 15px;
        margin: 12px 0;
    }

    /* 阅读增强功能移动端优化 */
    .back-to-top {
        bottom: 80px !important;
        right: 16px !important;
        width: 44px !important;
        height: 44px !important;
        font-size: 18px !important;
    }

    .auto-scroll-panel {
        bottom: 130px !important;
        right: 16px !important;
        min-width: 140px !important;
        padding: 10px !important;
    }

    .auto-scroll-panel div:first-child {
        font-size: 13px !important;
        margin-bottom: 6px !important;
    }

    .auto-scroll-panel span {
        font-size: 11px !important;
    }

    .auto-scroll-panel button {
        font-size: 11px !important;
        padding: 3px !important;
    }

    .feishu-toast {
        top: 60px !important;
        font-size: 13px !important;
        padding: 10px 20px !important;
        max-width: 80vw !important;
        text-align: center !important;
    }

    .reading-progress-container {
        height: 2px !important;
        top: calc(var(--header-height) + var(--nav-height)) !important;
    }

    /* 搜索建议移动端优化 */
    .search-suggestions {
        font-size: 14px !important;
    }

    .suggestion-item {
        padding: 10px 12px !important;
    }

    /* 标签移动端优化 */
    .tag span {
        font-size: 11px !important;
        padding: 1px 6px !important;
        margin-right: 4px !important;
    }

    /* 阅读记录移动端优化 */
    #tmpbook li {
        margin-bottom: 6px !important;
        padding: 10px !important;
    }

    #tmpbook .s1 {
        font-size: 14px !important;
        margin-bottom: 4px !important;
        display: block !important;
    }

    #tmpbook .s2,
    #tmpbook .s3 {
        font-size: 12px !important;
        color: var(--text-secondary) !important;
        display: block !important;
        margin: 2px 0 !important;
    }

    #tmpbook .s5 {
        margin-top: 8px !important;
        display: flex !important;
        gap: 8px !important;
        flex-wrap: wrap !important;
    }

    #tmpbook .s5 a {
        font-size: 12px !important;
        padding: 4px 8px !important;
        border-radius: var(--radius-small) !important;
        flex: 1 !important;
        text-align: center !important;
        min-width: 60px !important;
    }
}

/* 平板端优化 */
@media screen and (min-width: 768px) and (max-width: 1024px) {
    :root {
        --container-padding: 16px;
        --card-margin: 12px;
    }

    .header {
        height: 52px;
        line-height: 52px;
        font-size: 17px;
    }

    .header .bookname {
        font-size: 17px;
    }

    .header .operate {
        height: 34px;
        line-height: 34px;
        padding: 0 14px;
        margin: 0 8px;
    }

    .nav {
        height: 46px;
        line-height: 46px;
    }

    .nav ul li a {
        font-size: 15px;
    }

    #navbox ul {
        grid-template-columns: repeat(3, 1fr);
    }

    .wrap-box {
        margin: var(--card-margin);
    }

    .wrap-title {
        height: 46px;
        line-height: 46px;
        font-size: 16px;
        padding: 0 14px;
    }

    .novel_search {
        padding: 14px 12px;
        margin: var(--card-margin);
    }

    #novel_search input {
        height: 42px;
        font-size: 15px;
    }

    #novel_search button {
        height: 42px;
        font-size: 15px;
    }

    .rec-focus,
    .sort-box,
    .rank-box {
        padding: 14px;
    }

    .book-main {
        padding: 18px 14px;
        margin: var(--card-margin);
    }

    .book-main .book-img {
        width: 85px;
        height: 115px;
        margin-right: 14px;
    }

    .book-main .book-img img {
        width: 85px;
        height: 115px;
    }

    .btn-group {
        flex-direction: row;
        gap: 10px;
    }

    .btn-normal {
        height: 42px;
        line-height: 42px;
    }

    .chapter-page-btn ul {
        grid-template-columns: repeat(4, 1fr);
        gap: 8px;
    }

    .txt {
        font-size: 17px;
        padding: 22px 18px;
    }

    .set {
        padding: 10px 14px;
    }

    .back-to-top {
        bottom: 24px !important;
        right: 24px !important;
    }

    .auto-scroll-panel {
        bottom: 80px !important;
        right: 24px !important;
    }
}

/* 横屏优化 */
@media screen and (max-width: 767px) and (orientation: landscape) {
    .header {
        height: 46px;
        line-height: 46px;
    }

    .header .operate {
        height: 30px;
        line-height: 30px;
        padding: 0 10px;
        margin: 0 6px;
    }

    .nav {
        height: 40px;
        line-height: 40px;
    }

    .wrap-title {
        height: 40px;
        line-height: 40px;
    }

    .set {
        padding: 6px 12px;
    }

    .set .set1,
    .set .set2 span {
        height: 26px;
        line-height: 26px;
        padding: 3px 6px;
        font-size: 12px;
    }

    .chapter-page-btn li a {
        height: 36px;
        line-height: 36px;
        font-size: 13px;
    }

    .btn-normal {
        height: 36px;
        line-height: 36px;
        font-size: 13px;
    }

    .reading-progress-container {
        top: calc(46px + 40px) !important;
    }
}

/* 小屏幕设备优化 (iPhone SE等) */
@media screen and (max-width: 375px) {
    :root {
        --card-margin: 6px;
        --font-scale: 0.85;
    }

    .header {
        font-size: 15px;
    }

    .header .bookname {
        font-size: 15px;
    }

    .header .operate {
        padding: 0 10px;
        font-size: 12px;
        margin: 0 3px;
    }

    .wrap-title {
        font-size: 14px;
        padding: 0 10px;
    }

    .wrap-title .more {
        font-size: 12px;
    }

    .novel_search {
        padding: 10px 6px;
    }

    .rec-focus,
    .sort-box,
    .rank-box {
        padding: 10px;
    }

    .book-main {
        padding: 14px 10px;
    }

    .book-main .book-img {
        width: 75px;
        height: 100px;
        margin-right: 10px;
    }

    .book-main .book-img img {
        width: 75px;
        height: 100px;
    }

    .book-main .bookname h1 {
        font-size: 16px;
    }

    .btn-group {
        gap: 6px;
    }

    .txt {
        padding: 18px 14px;
        font-size: 15px;
    }

    .chapter-page-btn {
        padding: 10px 6px;
    }

    .set {
        padding: 6px 8px;
    }

    .bookcase-book {
        padding: 10px;
    }

    .bookcase-book .book-img {
        width: 65px;
        margin-right: 10px;
    }

    .bookcase-book .book-img img {
        width: 65px;
        height: 85px;
    }

    .feishu-toast {
        padding: 8px 16px !important;
        font-size: 12px !important;
    }

    .chapter-list li a {
        padding: 8px 10px;
        min-height: 36px;
    }
    
    .chapter-list li a span:first-child {
        font-size: 12px;
    }
}

/* 高分辨率屏幕优化 */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .chapter-list li a span:last-child:not([itemprop]),
    .rank-book-list li span {
        transform: scale(0.8);
        transform-origin: center;
    }
}

/* 深色模式移动端优化 */
@media (prefers-color-scheme: dark) {
    @media screen and (max-width: 767px) {
        .header {
            background: var(--bg-white);
            border-bottom-color: var(--border-light);
        }

        .nav {
            background: var(--bg-white);
            border-bottom-color: var(--border-light);
        }

        #navbox {
            background: var(--bg-white);
        }

        .wrap-box,
        .novel_search,
        .book-main,
        .bookcase-book {
            background: var(--bg-white);
        }

        .content {
            background: var(--bg-white);
        }

        .set {
            background: var(--bg-white);
        }

        .footer {
            background: var(--bg-white);
        }
    }
}

/* 触摸设备优化 */
@media (hover: none) and (pointer: coarse) {
    /* 增加触摸目标大小 */
    .header .operate,
    .nav ul li a,
    .btn-normal,
    .chapter-list li a,
    .chapter-page-btn li a,
    .set .set1,
    .set .set2 span {
        min-height: 44px;
        min-width: 44px;
    }

    /* 移除hover效果 */
    .wrap-box:hover,
    .bookcase-book:hover,
    .rec-focus-book:hover,
    .sort-book-first:hover,
    .rank-book-first:hover {
        transform: none;
        box-shadow: var(--shadow-light);
    }

    .chapter-list li:hover,
    .sort-book-list li:hover,
    .rank-book-list li:hover {
        background: transparent;
    }

    /* 添加按压反馈 */
    .header .operate:active,
    .btn-normal:active,
    .chapter-page-btn li a:active,
    .set .set1:active,
    .set .set2 span:active {
        transform: scale(0.98);
        opacity: 0.8;
    }
}

/* 打印样式 */
@media print {
    .header,
    .nav,
    .set,
    .chapter-page-btn,
    .footer,
    .back-to-top,
    .auto-scroll-panel,
    .feishu-toast,
    .reading-progress-container {
        display: none !important;
    }

    .content {
        margin: 0 !important;
        box-shadow: none !important;
        border-radius: 0 !important;
    }

    .txt {
        font-size: 12pt !important;
        line-height: 1.6 !important;
        color: #000 !important;
        background: #fff !important;
    }

    .wrap-box {
        break-inside: avoid;
        margin: 0 0 1em 0 !important;
        box-shadow: none !important;
        border: 1px solid #ccc !important;
    }
}

/* 超小屏幕进一步优化 */
@media screen and (max-width: 375px) {
    .set {
        margin: 6px 8px !important;
        padding: 3px 6px !important;
        gap: 8px !important;
        min-height: 28px !important;
    }

    .set .set1 {
        padding: 3px 6px !important;
        font-size: 12px !important;
        height: 22px !important;
        line-height: 16px !important;
        min-width: 32px !important;
        margin: 0 1px !important;
    }

    .set .set2 > span:first-child {
        font-size: 11px !important;
        margin-right: 3px !important;
        line-height: 22px !important;
    }

    .set .set2 span:not(:first-child) {
        padding: 3px 5px !important;
        font-size: 11px !important;
        height: 22px !important;
        line-height: 16px !important;
        min-width: 22px !important;
    }
}

/* 横屏模式下的特殊处理 */
@media screen and (max-width: 767px) and (orientation: landscape) {
    .set {
        margin: 4px 8px !important;
        padding: 2px 6px !important;
        min-height: 28px !important;
        gap: 10px !important;
    }

    .set .set1 {
        height: 22px !important;
        padding: 3px 6px !important;
        font-size: 12px !important;
        line-height: 16px !important;
    }

    .set .set2 span:not(:first-child) {
        height: 22px !important;
        padding: 3px 5px !important;
        font-size: 11px !important;
        line-height: 16px !important;
    }
} 