/* ========================================
   Mobile UI Improvements
======================================== */

/* サイドバートグルボタンの改善 */
.menu-toggle {
    position: fixed;
    top: 10px;
    left: 10px;
    z-index: 1001;
    background: rgba(44, 62, 80, 0.95);
    border: 2px solid var(--text-primary);
    border-radius: 0;
    padding: 8px;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 3px 3px 0 rgba(0,0,0,0.2);
}

.menu-toggle:hover {
    background: var(--text-primary);
    transform: translate(-2px, -2px);
    box-shadow: 5px 5px 0 rgba(0,0,0,0.25);
}

/* TOC項目の余白調整 */
.toc-item {
    padding: 8px 12px;
}

@media (max-width: 768px) {
    /* ヘッダーのレイアウト調整 */
    .reader-header {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        z-index: 100;
        background: var(--text-primary);
        box-shadow: 0 2px 10px rgba(0,0,0,0.2);
    }
    
    .header-content {
        display: flex;
        align-items: center;
        gap: 10px;
        padding: 10px 15px;
        position: relative;
    }
    
    .header-info {
        flex: 1;
        text-align: center;
        margin: 0 10px;
    }
    
    .book-title {
        font-size: 1rem;
        font-weight: 600;
        margin: 0;
        line-height: 1.2;
        color: white;
        font-family: var(--font-serif);
    }
    
    .current-chapter {
        font-size: 0.75rem;
        opacity: 0.9;
        line-height: 1.2;
        margin-top: 2px;
        display: block;
        color: rgba(255, 255, 255, 0.8);
    }
    
    /* サイドバーの改善 */
    .reader-sidebar {
        top: 0;
        height: 100vh;
        background: white;
        box-shadow: 2px 0 10px rgba(0,0,0,0.2);
        border-right: 2px solid var(--border-color);
    }
    
    .toc-container {
        height: calc(100vh - 60px);
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    /* TOC項目の読みやすさ改善 */
    .toc-item {
        border-bottom: 1px solid var(--border-color);
        position: relative;
        border-radius: 0;
    }
    
    .toc-item.active {
        background: var(--text-primary);
        color: white;
        border-left: 4px solid var(--secondary-color);
        padding-left: 8px;
        box-shadow: 2px 2px 0 rgba(0, 0, 0, 0.1);
    }
    
    .toc-text {
        display: flex;
        flex-direction: column;
        gap: 2px;
    }
    
    .toc-title {
        font-size: 14px;
        line-height: 1.4;
    }
    
    /* 進捗率表示は削除 */
    
    /* ヘッダーアクションの調整 */
    .header-actions {
        display: flex;
        align-items: center;
        gap: 5px;
    }
    
    .settings-toggle {
        padding: 6px;
        width: 32px;
        height: 32px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    .settings-toggle svg {
        width: 18px;
        height: 18px;
    }
    
    .back-link {
        font-size: 12px;
        padding: 6px 10px;
        white-space: nowrap;
        color: white;
        border-color: white;
        border-radius: 0;
    }
    
    .back-link:hover {
        background: white;
        color: var(--text-primary);
    }
    
    /* コンテンツエリアの改善 */
    .reader-content {
        padding: 15px;
        padding-top: 70px; /* ヘッダー分のスペース */
    }
    
    .content-area {
        padding: 0.5rem;
        max-width: 100%;
    }
    
    /* チャプターコンテンツの余白を最適化 */
    .chapter-content {
        padding: 1rem;
        box-shadow: none;
        border: none;
        border-top: 1px solid var(--border-color);
    }
    
    /* 章の導入文（引用部分）のモバイル対応 */
    .chapter-intro {
        padding: 1rem;
        margin: 1.5rem -0.5rem;
        font-size: 0.95rem;
        border-left-width: 3px;
        background: var(--background);
    }
    
    /* 本文の最適化 */
    .chapter-body {
        font-size: 1rem;
        line-height: 1.8;
    }
    
    .chapter-body p {
        text-indent: 0.5em;
        margin-bottom: 1rem;
    }
    
    /* オーバーレイの改善 */
    .overlay {
        backdrop-filter: blur(2px);
        -webkit-backdrop-filter: blur(2px);
    }
    
    /* 設定パネルのモバイル対応 */
    .settings-panel {
        width: 100%;
        max-width: 320px;
        height: 100vh;
        top: 0;
        box-shadow: -2px 0 10px rgba(0,0,0,0.2);
        border-left: 2px solid var(--border-color);
    }
    
    .settings-panel.active {
        transform: translateX(0);
    }
    
    /* 設定グループの調整 */
    .settings-group {
        padding: 15px;
    }
    
    .settings-group h3 {
        font-size: 0.9rem;
        margin-bottom: 10px;
    }
    
    /* ボタンサイズの調整 */
    .font-size-btn,
    .line-height-btn,
    .theme-btn,
    .font-btn {
        padding: 10px 5px;
        font-size: 12px;
        border-radius: 0;
    }
    
    .theme-icon {
        font-size: 1.2rem;
    }
    
    /* リセットボタンの調整 */
    .reset-settings {
        font-size: 14px;
        padding: 10px;
    }
}

/* タブレット対応 */
@media (min-width: 769px) and (max-width: 1024px) {
    .reader-sidebar {
        width: 280px;
    }
    
    .reader-content {
        margin-left: 280px;
        padding: var(--spacing-lg);
    }
    
    .toc-progress {
        font-size: 12px;
    }
}