* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: rgba(0,0,0,0);
}

html, body {
    height: 100%;
    font-family: system-ui, -apple-system, -apple-system-font, 'Segoe UI', 'Roboto', sans-serif;
}

body {
    -webkit-touch-callout: none;
    -webkit-text-size-adjust: none;
    -webkit-user-select: none;
    background-color: #f5f5f5;
    padding: env(safe-area-inset-top, 0px) env(safe-area-inset-right, 0px) env(safe-area-inset-bottom, 0px) env(safe-area-inset-left, 0px);
}

.app-container {
    height: 100%;
    display: flex;
    flex-direction: column;
}

.content-area {
    flex: 1;
    overflow: hidden;
}

.page {
    display: none;
    height: 100%;
    padding: 20px;
}

.page.active {
    display: block;
}

.page-content {
    padding-bottom: 80px;
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow-y: auto;

    /* 吸顶内容 book-detail-header */
    position: relative;
}

.page-content h1 {
    font-size: 24px;
    color: #333;
    margin-bottom: 20px;
    text-align: center;
    flex-shrink: 0;
}

.search-box {
    display: flex;
    gap: 10px;
    margin-top: 20px;
    /* padding: 0 20px; */    

    /* 吸顶 */
    position: sticky;
    top: 0;
    background: #f5f5f5;
    padding-bottom: 10px;
    z-index: 99;
}

.search-box input {
    flex: 1;
    padding: 12px 15px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 16px;
    outline: none;
    box-sizing: border-box; /* 👈 加这个 */
    min-width: 0; /* 👈 保险再加这个，彻底不超出 */
}

.search-box button {
    padding: 12px 25px;
    background-color: #4CAF50;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    cursor: pointer;
    white-space: nowrap;
}

.search-box button:active {
    background-color: #45a049;
}

.search-results {
    margin-top: 20px;
    /* padding: 0 20px; */
}

.search-result-item {
    background-color: white;
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 10px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.05);
}

.search-result-item h3 {
    font-size: 16px;
    color: #333;
    margin-bottom: 8px;
}

.search-result-item .author {
    font-size: 14px;
    color: #999;
    margin-bottom: 5px;
}

.search-result-item .intro {
    font-size: 14px;
    color: #666;
    line-height: 1.5;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.search-loading {
    text-align: center;
    padding: 20px;
    color: #666;
}

.search-error {
    text-align: center;
    padding: 20px;
    color: #ff6b6b;
}

.search-empty {
    text-align: center;
    padding: 20px;
    color: #999;
}

.back-btn {
    background-color: #4CAF50;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 16px;
    cursor: pointer;
    margin-bottom: 20px;
}

.back-btn:active {
    background-color: #45a049;
}

.book-detail-header {
    display: flex;
    gap: 15px;
    margin-bottom: 20px;

    /* 吸顶 */
    position: sticky;
    top: 0;
    background: #f5f5f5;
    padding-bottom: 10px;
    z-index: 99;
}

.book-detail-header .back-btn,
.book-detail-header .refresh-btn {
    flex: 1;
    text-align: center;
    margin-bottom: 0;
    background-color: #4CAF50;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 16px;
    cursor: pointer;    
}

.book-detail-header .refresh-btn:active {
    background-color: #45a049;
}

.book-info {
    background-color: white;
    padding: 20px;
    border-radius: 12px;
    margin-bottom: 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    flex-shrink: 0;
}

.book-title {
    font-size: 24px;
    font-weight: bold;
    color: #333;
    margin-bottom: 15px;
}

.book-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    margin-bottom: 15px;
    font-size: 14px;
    color: #666;
}

.book-meta span {
    background-color: #f5f5f5;
    padding: 5px 10px;
    border-radius: 4px;
}

.book-intro {
    font-size: 14px;
    color: #666;
    line-height: 1.6;
    text-align: justify;
}

.book-chapters {
    margin-top: 20px;
}

.book-chapters h2 {
    font-size: 18px;
    color: #333;
    margin-bottom: 15px;
    flex-shrink: 0;
}

.chapter-list {
    margin-top: 10px;
}

#book-detail-content {
    flex: 1;
}

.chapter-item {
    background-color: white;
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 10px;
    color: #333;
    box-shadow: 0 1px 4px rgba(0,0,0,0.05);
    cursor: pointer;
}

.chapter-item:active {
    background-color: #f0f0f0;
}

.book-loading {
    text-align: center;
    padding: 40px;
    color: #666;
}

.book-error {
    text-align: center;
    padding: 40px;
    color: #ff6b6b;
}

.reading-container {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #fff;
    z-index: 100;
    display: flex;
    flex-direction: column;
}

.reading-controls {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    background-color: #f5f5f5;
    padding: 15px 20px;
    border-bottom: 1px solid #ddd;
    z-index: 10;
    transform: translateY(-100%);
    transition: transform 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.reading-controls.show {
    transform: translateY(0);
}

.reading-controls h2 {
    font-size: 18px;
    color: #333;
    text-align: center;
    flex: 1;
    margin: 0 15px;
    visibility: hidden;
}

.reading-controls .back-btn,
.reading-controls .refresh-btn {
    background-color: #4CAF50;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 16px;
    cursor: pointer;
    margin-bottom: 0;
}

.reading-controls .refresh-btn:active {
    background-color: #45a049;
}

.chapter-text {
    flex: 1;
    background-color: #fff;
    padding: 20px;
    padding-top: 60px;
    padding-bottom: 60px;
    font-size: 16px;
    line-height: 1.8;
    color: #333;
    white-space: pre-wrap;
    word-wrap: break-word;
    text-indent: 2em;
    overflow-y: auto;
    min-height: 100%;
    cursor: pointer;
    user-select: text;
}

.reading-settings {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background-color: white;
    padding: 15px 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
    transform: translateY(100%);
    transition: transform 0.3s ease;
}

.reading-settings.show {
    transform: translateY(0);
}

.setting-group {
    display: flex;
    align-items: center;
    gap: 10px;
}

.setting-group label {
    font-size: 14px;
    color: #333;
    min-width: 60px;
}

.color-btn {
    width: 30px;
    height: 30px;
    border: 2px solid #ddd;
    border-radius: 50%;
    cursor: pointer;
    transition: transform 0.2s;
}

.color-btn:active {
    transform: scale(0.9);
}

.color-btn.active {
    border-color: #4CAF50;
    box-shadow: 0 0 0 2px rgba(76, 175, 80, 0.3);
}

.font-btn {
    padding: 6px 12px;
    background-color: #f5f5f5;
    border: 1px solid #ddd;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
}

.font-btn:active {
    background-color: #e0e0e0;
}

.font-btn.active {
    background-color: #4CAF50;
    color: white;
    border-color: #4CAF50;
}

.chapter-loading {
    text-align: center;
    padding: 40px;
    color: #666;
    font-size: 14px;
}

.chapter-error {
    text-align: center;
    padding: 40px 20px;
    color: #ff6b6b;
}

.chapter-error p {
    font-size: 16px;
    margin-bottom: 30px;
}

.error-buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
    width: 100%;
    max-width: 300px;
    margin: 0 auto;
}

.error-btn {
    flex: 1;
    padding: 12px 20px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    cursor: pointer;
    min-width: 120px;
}

.error-btn.back-btn {
    background-color: #999;
    color: white;
}

.error-btn.refresh-btn {
    background-color: #4CAF50;
    color: white;
}

.error-btn:active {
    opacity: 0.8;
}

.feature-cards {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
    margin-top: 20px;
}

.card {
    background-color: white;
    padding: 25px;
    border-radius: 12px;
    text-align: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    color: #333;
    font-size: 16px;
}

.record-list {
    margin-top: 20px;
}

.record-item {
    background-color: white;
    padding: 15px 20px;
    border-radius: 8px;
    margin-bottom: 10px;
    color: #333;
    box-shadow: 0 1px 4px rgba(0,0,0,0.05);
}

.history-list {
    margin-top: 20px;
}

.history-item {
    background-color: white;
    padding: 15px;
    border-radius: 12px;
    margin-bottom: 15px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    cursor: pointer;
}

.history-item:active {
    background-color: #f0f0f0;
}

.history-item .book-title {
    font-size: 18px;
    font-weight: bold;
    color: #333;
    margin-bottom: 8px;
}

.history-item .book-author {
    font-size: 14px;
    color: #999;
    margin-bottom: 5px;
}

.history-item .read-progress {
    font-size: 14px;
    color: #4CAF50;
    margin-bottom: 5px;
}

.history-item .last-read {
    font-size: 12px;
    color: #999;
}

.history-item .delete-btn {
    background-color: #ff6b6b;
    color: white;
    border: none;
    padding: 5px 10px;
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
    float: right;
}

.history-item .delete-btn:active {
    background-color: #ee5a5a;
}

.history-empty {
    text-align: center;
    padding: 40px;
    color: #999;
    font-size: 16px;
}

.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 60px;
    background-color: white;
    display: flex;
    justify-content: space-around;
    align-items: center;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
    padding-bottom: env(safe-area-inset-bottom, 0px);
    transition: transform 0.3s ease;
}

.hide-bottom-nav .bottom-nav {
    transform: translateY(100%);
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    height: 100%;
    border: none;
    background: none;
    cursor: pointer;
}

.nav-item .icon {
    font-size: 24px;
    margin-bottom: 4px;
}

.nav-item .label {
    font-size: 12px;
    color: #666;
}

.nav-item.active .label,
.nav-item.active .icon {
    color: #4CAF50;
}

.home-content {
    max-width: 100%;
    margin: 0 auto;
}

.disclaimer {
    background-color: white;
    padding: 20px;
    border-radius: 12px;
    margin-bottom: 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.disclaimer h2 {
    font-size: 18px;
    color: #333;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid #eee;
}

.disclaimer p {
    font-size: 14px;
    color: #666;
    line-height: 1.6;
    margin-bottom: 10px;
    text-align: justify;
}

.disclaimer p:last-child {
    margin-bottom: 0;
}

.donation-section {
    background-color: white;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.donation-section h2 {
    font-size: 18px;
    color: #333;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid #eee;
}

.donation-section p {
    font-size: 14px;
    color: #666;
    line-height: 1.6;
    margin-bottom: 15px;
    text-align: center;
}

.qr-code-container {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.qr-code {
    width: 200px;
    height: 200px;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.qr-code-label {
    font-size: 14px;
    color: #999;
    margin-top: 15px;
}

/* 起点白金/大神作家区域 */
.qidian-section {
    margin-top: 20px;
    padding: 15px;
    background-color: #f9f9f9;
    border-radius: 8px;
}

.qidian-section h2 {
    font-size: 18px;
    color: #333;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid #eee;
}

.qidian-year-block {
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px dashed #ddd;
}

.qidian-year-block:last-child {
    border-bottom: none;
}

.qidian-year {
    font-size: 16px;
    color: #666;
    font-weight: bold;
    margin-bottom: 8px;
}

.qidian-category {
    margin-bottom: 8px;
}

.qidian-label {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: bold;
    margin-right: 8px;
}

.qidian-label.platinum {
    background-color: #ffd700;
    color: #333;
}

.qidian-label.god {
    background-color: #ff6b6b;
    color: white;
}

.qidian-author {
    margin: 5px 0;
    padding-left: 50px;
    font-size: 14px;
    line-height: 1.8;
}

.qidian-name {
    color: #333;
    font-weight: bold;
}

.qidian-works {
    color: #666;
    margin-left: 8px;
}

.qidian-work {
    display: inline-block;
    margin-right: 8px;
    color: #4a90d9;
}

/* 可点击元素样式 */
.clickable {
    cursor: pointer;
    transition: color 0.2s, background-color 0.2s;
}

.clickable:hover {
    color: #ff6b6b;
}

.qidian-name.clickable:hover {
    color: #ff6b6b;
}

.qidian-work.clickable:hover {
    color: #ff6b6b;
    text-decoration: underline;
}

.qidian-error {
    text-align: center;
    padding: 20px;
    color: #999;
}