/* -------------------------------------------------------------
   コミック本棚マネージャー - style.css
   モバイルファースト & ホワイトクリーンテーマ
------------------------------------------------------------- */

/* カスタム変数定義 */
:root {
    --primary-color: #4361ee;
    --primary-light: #eef2ff;
    --accent-color: #3f37c9;
    --success-color: #4cc9f0;
    --warning-color: #f72585;
    --info-color: #7209b7;
    
    --bg-main: #f8f9fa;
    --bg-card: #ffffff;
    --border-color: #eaeaea;
    --text-main: #2b2d42;
    --text-muted: #8d99ae;
    --text-light: #ffffff;
    
    --border-radius-sm: 8px;
    --border-radius-md: 14px;
    --border-radius-lg: 20px;
    
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 8px 20px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 12px 30px rgba(67, 97, 238, 0.15);
    
    --transition-fast: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-normal: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* 基本リセット */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'Noto Sans JP', 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background-color: #e9ecef;
    color: var(--text-main);
    line-height: 1.5;
    overflow: hidden;
}

/* スクロールバー非表示（iOSライクなスクロール） */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.1);
    border-radius: 10px;
}

/* アプリ全体のラッパー（PCではスマホ枠を中央に表示） */
.app-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    width: 100vw;
    background-color: #e2e8f0;
}

/* スマホサイズコンテナ */
.app-container {
    position: relative;
    width: 100%;
    max-width: 480px;
    height: 100vh;
    background-color: var(--bg-main);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

@media (max-width: 480px) {
    .app-wrapper {
        background-color: var(--bg-main);
    }
    .app-container {
        max-width: 100%;
        height: 100dvh; /* 動的ビューポート対応 */
        box-shadow: none;
    }
}

/* ヘッダー */
.app-header {
    height: 60px;
    background-color: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 20px;
    z-index: 10;
    flex-shrink: 0;
}

.header-logo {
    font-family: 'Outfit', sans-serif;
    font-size: 24px;
    font-weight: 700;
    color: var(--primary-color);
    letter-spacing: -0.5px;
}

.icon-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-main);
    padding: 8px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition-fast);
}

.icon-btn:hover {
    background-color: var(--primary-light);
    color: var(--primary-color);
}

.icon-btn.back-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    border-radius: 20px;
    padding: 6px 12px;
    font-size: 14px;
    font-weight: 500;
}

/* メインコンテンツ表示エリア */
.app-content {
    flex: 1;
    overflow-y: auto;
    position: relative;
    padding-bottom: 90px; /* 下部ナビとFABのための十分な余白 */
}

/* 画面切り替えの基本設定 */
.app-screen {
    display: none;
    opacity: 0;
    transition: opacity var(--transition-normal);
    padding: 20px;
}

.app-screen.active {
    display: block;
    opacity: 1;
}

/* スライドオーバーする詳細画面 */
.app-screen.detail-screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: var(--bg-main);
    z-index: 20;
    overflow-y: auto;
    padding: 0;
    padding-bottom: 80px;
}

.detail-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    position: sticky;
    top: 0;
    background-color: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    z-index: 25;
    border-bottom: 1px solid var(--border-color);
}

.detail-header-actions {
    display: flex;
    gap: 8px;
}

/* 共通画面タイトル */
.screen-header-block {
    margin-bottom: 20px;
}

.screen-header-block h1 {
    font-size: 26px;
    font-weight: 700;
    letter-spacing: -0.5px;
}

/* 下部固定ナビゲーション */
.bottom-nav {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 65px;
    background-color: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: space-around;
    align-items: center;
    z-index: 15;
    padding-bottom: env(safe-area-inset-bottom);
}

.nav-item {
    background: none;
    border: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    height: 100%;
    cursor: pointer;
    color: var(--text-muted);
    font-size: 10px;
    font-weight: 500;
    gap: 4px;
    transition: var(--transition-fast);
}

.nav-item svg {
    transition: transform var(--transition-fast);
}

.nav-item:hover svg {
    transform: translateY(-2px);
}

.nav-item.active {
    color: var(--primary-color);
    font-weight: 700;
}

.nav-item.active svg {
    stroke: var(--primary-color);
    fill: var(--primary-light);
}

/* フローティングアクションボタン（FAB） */
.fab-btn {
    position: absolute;
    bottom: 80px;
    right: 20px;
    background: linear-gradient(135deg, var(--primary-color), var(--accent-color));
    color: var(--text-light);
    border: none;
    border-radius: 30px;
    padding: 12px 20px;
    box-shadow: var(--shadow-lg);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 15px;
    font-weight: 600;
    z-index: 12;
    transition: var(--transition-normal);
}

.fab-btn:hover {
    transform: translateY(-2px) scale(1.03);
    box-shadow: 0 15px 35px rgba(67, 97, 238, 0.25);
}

.fab-btn svg {
    stroke: var(--text-light);
}

/* -------------------------------------------------------------
   ホーム画面コンポーネント
------------------------------------------------------------- */
.welcome-banner {
    background-color: var(--bg-card);
    border-radius: var(--border-radius-md);
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
}

.welcome-banner h1 {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 4px;
}

.current-date {
    font-size: 13px;
    color: var(--text-muted);
    font-family: 'Outfit', sans-serif;
}

/* 統計カードグリッド */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-bottom: 24px;
}

.stats-grid > :nth-child(5) {
    grid-column: span 2;
}

.stat-card {
    background-color: var(--bg-card);
    border-radius: var(--border-radius-md);
    padding: 16px;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    cursor: pointer;
    transition: var(--transition-fast);
}

.stat-card:hover {
    transform: translateY(-2px);
    border-color: var(--primary-color);
}

.stat-num {
    font-family: 'Outfit', sans-serif;
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 4px;
}

.stat-label {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 500;
}

.text-accent { color: var(--primary-color); }
.text-warning { color: var(--warning-color); }
.text-info { color: var(--info-color); }

.section-block {
    margin-bottom: 24px;
}

.section-title {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* 最近追加した作品リスト */
.recent-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.empty-state {
    text-align: center;
    color: var(--text-muted);
    padding: 30px 20px;
    font-size: 14px;
    background-color: var(--bg-card);
    border-radius: var(--border-radius-md);
    border: 1px dashed var(--border-color);
}

/* -------------------------------------------------------------
   本棚 / 検索 共通リストカードUI
------------------------------------------------------------- */
.category-tabs-container {
    margin: -10px -20px 15px -20px;
    padding: 10px 20px;
    overflow-x: auto;
    white-space: nowrap;
}

.category-tabs {
    display: inline-flex;
    gap: 8px;
}

.category-tab {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    color: var(--text-main);
    transition: var(--transition-fast);
}

.category-tab.active {
    background-color: var(--primary-color);
    color: var(--text-light);
    border-color: var(--primary-color);
    box-shadow: 0 4px 10px rgba(67, 97, 238, 0.2);
}

.filter-chips {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}

.filter-chip {
    background-color: transparent;
    border: 1px solid var(--border-color);
    padding: 6px 12px;
    border-radius: 15px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    color: var(--text-muted);
    transition: var(--transition-fast);
}

.filter-chip.active {
    background-color: var(--primary-light);
    color: var(--primary-color);
    border-color: var(--primary-color);
}

/* 作品リスト */
.works-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* 作品カード */
.work-card {
    background-color: var(--bg-card);
    border-radius: var(--border-radius-md);
    padding: 12px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    display: flex;
    gap: 12px;
    cursor: pointer;
    transition: var(--transition-normal);
}

.work-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    border-color: rgba(67, 97, 238, 0.3);
}

/* 書籍表紙 */
.book-cover-wrapper {
    width: 70px;
    height: 95px;
    border-radius: var(--border-radius-sm);
    overflow: hidden;
    position: relative;
    box-shadow: 0 2px 6px rgba(0,0,0,0.1);
    flex-shrink: 0;
    background-color: #e2e8f0;
}

.book-cover {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* プレースホルダーのカバー（CSSで作成） */
.book-cover-placeholder {
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #a5b4fc, #818cf8);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 8px 6px;
    color: var(--text-light);
    font-weight: 700;
}

.placeholder-title {
    font-size: 10px;
    line-height: 1.2;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.placeholder-label {
    font-size: 8px;
    text-align: right;
    opacity: 0.8;
}

/* 作品カードの内容 */
.work-card-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-width: 0; /* 折り返しを有効にするため */
}

.work-card-top {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.work-card-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.work-card-author {
    font-size: 13px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.work-card-bottom {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
}

/* 進捗ゲージ */
.progress-container {
    display: flex;
    flex-direction: column;
    gap: 3px;
    width: 100%;
    max-width: 180px;
}

.progress-info {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    font-weight: 500;
    color: var(--text-muted);
}

.progress-bar-bg {
    height: 6px;
    background-color: var(--border-color);
    border-radius: 3px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    background-color: var(--primary-color);
    border-radius: 3px;
    transition: width var(--transition-normal);
}

/* ステータスバッジ */
.badge {
    padding: 3px 8px;
    border-radius: 10px;
    font-size: 10px;
    font-weight: 700;
}

.badge-status {
    background-color: #f3f4f6;
    color: #4b5563;
}
.badge-status.status-ongoing {
    background-color: #d1fae5;
    color: #065f46;
}
.badge-status.status-completed {
    background-color: #dbeafe;
    color: #1e40af;
}

.badge-unread {
    background-color: var(--warning-color);
    color: var(--text-light);
}

/* ジャンルとタグ */
.meta-tags {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
    margin-top: 4px;
}

.tag-mini {
    background-color: var(--bg-main);
    color: var(--text-muted);
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 4px;
    border: 1px solid var(--border-color);
}

/* -------------------------------------------------------------
   検索画面コンポーネント
------------------------------------------------------------- */
.search-bar-container {
    margin-bottom: 16px;
}

.search-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.search-input-wrapper input {
    width: 100%;
    height: 46px;
    padding: 0 16px 0 44px;
    border-radius: var(--border-radius-md);
    border: 1px solid var(--border-color);
    background-color: var(--bg-card);
    font-size: 15px;
    font-family: inherit;
    outline: none;
    box-shadow: var(--shadow-sm);
    transition: var(--transition-fast);
}

.search-input-wrapper input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(67, 97, 238, 0.15);
}

.search-icon {
    position: absolute;
    left: 14px;
    color: var(--text-muted);
    pointer-events: none;
}

.search-suggestions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}

.suggestion-chip {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    padding: 6px 12px;
    border-radius: 15px;
    font-size: 12px;
    cursor: pointer;
    transition: var(--transition-fast);
}

.suggestion-chip:hover {
    background-color: var(--primary-light);
    color: var(--primary-color);
    border-color: var(--primary-color);
}

/* -------------------------------------------------------------
   読みたい & 発売日 共通フラットリストUI
------------------------------------------------------------- */
.sub-tabs {
    display: flex;
    border-bottom: 2px solid var(--border-color);
    margin-bottom: 16px;
}

.sub-tab {
    flex: 1;
    background: none;
    border: none;
    padding: 12px;
    font-size: 15px;
    font-weight: 700;
    color: var(--text-muted);
    cursor: pointer;
    text-align: center;
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
    transition: var(--transition-fast);
}

.sub-tab.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
}

.volumes-flat-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.flat-vol-card {
    background-color: var(--bg-card);
    border-radius: var(--border-radius-md);
    padding: 12px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.flat-vol-info {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
    flex: 1;
}

.flat-vol-text {
    min-width: 0;
}

.flat-vol-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.flat-vol-subtitle {
    font-size: 11px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.flat-vol-meta {
    font-size: 11px;
    color: var(--primary-color);
    font-weight: 600;
    margin-top: 2px;
}

.flat-vol-actions {
    display: flex;
    gap: 8px;
}

/* -------------------------------------------------------------
   作品詳細画面コンポーネント
------------------------------------------------------------- */
.detail-hero {
    background-color: var(--bg-card);
    padding: 24px 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    text-align: center;
}

.detail-hero-cover {
    width: 140px;
    height: 195px;
    border-radius: var(--border-radius-md);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
    margin-bottom: 16px;
    overflow: hidden;
    background-color: #f1f5f9;
}

.detail-title {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 4px;
}

.detail-author {
    font-size: 14px;
    color: var(--text-muted);
    margin-bottom: 2px;
}

.detail-publisher {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 12px;
}

.detail-progress-pill {
    background-color: var(--bg-main);
    border: 1px solid var(--border-color);
    padding: 4px 14px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 700;
    color: var(--primary-color);
}

/* アクションボタン（グリッド） */
.detail-actions-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    width: 100%;
    max-width: 360px;
    margin: 16px 0 0 0;
}

.detail-action-btn {
    background: none;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-md);
    padding: 8px 4px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    font-size: 10px;
    font-weight: 500;
    color: var(--text-main);
    transition: var(--transition-fast);
}

.detail-action-btn:hover {
    background-color: var(--primary-light);
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.detail-action-btn.active {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
    color: var(--text-light);
}

.detail-action-btn svg {
    width: 20px;
    height: 20px;
}

/* メタ情報リスト */
.detail-meta-list {
    background-color: var(--bg-card);
    border-top: 1px solid var(--border-color);
    border-bottom: 1px solid var(--border-color);
    padding: 16px 20px;
    margin-top: 12px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.detail-meta-item {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
}

.detail-meta-label {
    color: var(--text-muted);
}

.detail-meta-value {
    font-weight: 500;
    text-align: right;
}

/* 詳細タブ切り替え */
.detail-tabs {
    display: flex;
    background-color: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
}

.detail-tab {
    flex: 1;
    background: none;
    border: none;
    padding: 14px;
    font-size: 14px;
    font-weight: 700;
    color: var(--text-muted);
    cursor: pointer;
    border-bottom: 3px solid transparent;
    margin-bottom: -1px;
    transition: var(--transition-fast);
}

.detail-tab.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
}

.detail-tab-content {
    display: none;
    padding: 16px;
}

.detail-tab-content.active {
    display: block;
}

/* 巻グリッド/リスト */
.volume-items-container {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.volume-row-item {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-md);
    padding: 10px 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    transition: var(--transition-fast);
}

.volume-row-item:hover {
    border-color: rgba(67, 97, 238, 0.2);
}

.volume-row-left {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    flex: 1;
}

.vol-mini-cover {
    width: 36px;
    height: 48px;
    border-radius: 4px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    flex-shrink: 0;
}

.vol-row-title-area {
    min-width: 0;
}

.vol-row-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-main);
}

.vol-row-release {
    font-size: 11px;
    color: var(--text-muted);
}

.volume-row-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* トグルチェックボックス */
.checkbox-pill-container {
    display: flex;
    gap: 6px;
}

.check-pill {
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 700;
    border: 1px solid var(--border-color);
    background-color: var(--bg-main);
    color: var(--text-muted);
    user-select: none;
    transition: var(--transition-fast);
}

.check-pill input {
    display: none;
}

.check-pill.checked-owned {
    background-color: var(--primary-light);
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.check-pill.checked-read {
    background-color: #d1fae5;
    border-color: #10b981;
    color: #047857;
}

.detail-memo-area {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-md);
    padding: 16px;
    min-height: 120px;
    font-size: 14px;
    color: var(--text-main);
    white-space: pre-wrap;
}

.detail-volume-count-desc {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 12px;
}

/* -------------------------------------------------------------
   フォーム / モーダル UI
------------------------------------------------------------- */
.modal {
    position: fixed; /* position: absolute から fixed に変更し、スクロールに追従 */
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(0, 0, 0, 0.4);
    display: none;
    justify-content: center;
    align-items: center; /* スマホでも画面中央に配置 */
    z-index: 9990; /* 他のUIやデバッグログ(z-index: 90)より手前に配置 */
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.modal.active {
    display: flex;
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    animation: fadeIn var(--transition-fast) forwards;
}

.modal-content {
    background-color: var(--bg-card);
    border-radius: var(--border-radius-lg);
    width: 90%;
    max-width: 500px;
    max-height: calc(100vh - 180px); /* 画面外に見切れるのを防止 */
    overflow-y: auto;
    padding: 20px;
    transform: scale(0.9);
    animation: zoomIn var(--transition-normal) forwards;
}

@keyframes zoomIn {
    from { transform: scale(0.9); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 12px;
}

.modal-header h2 {
    font-size: 18px;
    font-weight: 700;
}

.modal-close-btn {
    background: none;
    border: none;
    font-size: 26px;
    cursor: pointer;
    color: var(--text-muted);
}

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 6px;
}

.form-group label.required::after {
    content: " *";
    color: var(--warning-color);
}

.field-desc {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: -4px;
    margin-bottom: 6px;
}

.form-group input[type="text"],
.form-group input[type="url"],
.form-group input[type="date"],
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    font-size: 14px;
    font-family: inherit;
    outline: none;
    background-color: var(--bg-main);
    transition: var(--transition-fast);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    border-color: var(--primary-color);
    background-color: var(--bg-card);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.volume-bulk-area {
    background-color: var(--bg-main);
    border: 1px dashed var(--border-color);
    border-radius: var(--border-radius-md);
    padding: 14px;
    margin: 16px 0;
}

.subsection-title {
    font-size: 14px;
    font-weight: 700;
    margin-bottom: 6px;
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 24px;
}

/* ボタン */
.btn {
    padding: 10px 20px;
    border-radius: var(--border-radius-sm);
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    border: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition-fast);
}

.btn-primary {
    background-color: var(--primary-color);
    color: var(--text-light);
}

.btn-primary:hover {
    background-color: var(--accent-color);
}

.btn-secondary {
    background-color: #f3f4f6;
    color: var(--text-main);
}

.btn-secondary:hover {
    background-color: #e5e7eb;
}

.btn-outline {
    background-color: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-main);
}

.btn-outline:hover {
    background-color: var(--primary-light);
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.btn-danger {
    background-color: #ef4444;
    color: var(--text-light);
}

.btn-danger:hover {
    background-color: #dc2626;
}

.btn-block {
    display: flex;
    width: 100%;
}

.text-center {
    text-align: center;
}

/* 設定セクション */
.settings-section {
    margin-bottom: 24px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 16px;
}

.settings-section h3 {
    font-size: 15px;
    font-weight: 700;
    margin-bottom: 6px;
}

/* トースト通知 */
.toast {
    position: absolute;
    top: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(-30px);
    background-color: rgba(0, 0, 0, 0.85);
    color: var(--text-light);
    padding: 10px 20px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
    z-index: 200;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition-fast), transform var(--transition-fast);
    box-shadow: var(--shadow-md);
    white-space: nowrap;
}

.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* 作品詳細 進行状況 & ステータスボード */
.detail-progress-container {
    width: 100%;
    max-width: 360px;
    margin: 12px 0 6px 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

.detail-progress-bar-bg {
    width: 100%;
    height: 8px;
    background-color: var(--border-color);
    border-radius: 4px;
    overflow: hidden;
}

.detail-progress-bar-fill {
    height: 100%;
    background-color: var(--primary-color);
    border-radius: 4px;
    transition: width var(--transition-normal);
}

.detail-progress-ratio {
    font-size: 14px;
    font-weight: 700;
    color: var(--primary-color);
}

/* 書籍情報検索候補リスト */
.book-candidates-list {
    max-height: 220px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    background-color: var(--bg-main);
    padding: 8px 8px 36px 8px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.candidate-item {
    display: flex;
    gap: 12px;
    padding: 10px;
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    align-items: flex-start;
    transition: background-color var(--transition-fast), border-color var(--transition-fast);
    min-height: 74px;
    margin-bottom: 4px;
}

.candidate-item:hover {
    background-color: var(--primary-light);
    border-color: var(--primary-color);
}

.candidate-cover {
    width: 38px;
    height: 54px;
    object-fit: cover;
    border-radius: 4px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    flex-shrink: 0;
    background-color: #e2e8f0;
}

.candidate-details {
    flex: 1;
    min-width: 0;
    line-height: 1.4;
}

.candidate-title {
    font-size: 13.5px;
    font-weight: 700;
    color: var(--text-main);
    word-break: break-word;
    overflow-wrap: anywhere;
    margin-bottom: 3px;
}

.candidate-meta {
    font-size: 11px;
    color: var(--text-muted);
    word-break: break-word;
    overflow-wrap: anywhere;
    margin-bottom: 2px;
}

.candidate-status-text {
    font-size: 12px;
    text-align: center;
    padding: 12px;
    color: var(--text-muted);
    font-weight: 500;
}

/* 別名辞書UIのスタイル */
.alias-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
    padding: 6px 10px;
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    transition: var(--transition-fast);
}

.alias-item:hover {
    border-color: var(--primary-color);
}

.alias-item-text {
    flex: 1;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-weight: 500;
}

.alias-delete-btn {
    background: none;
    border: none;
    color: var(--warning-color);
    cursor: pointer;
    font-weight: 700;
    padding: 0 4px;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.alias-delete-btn:hover {
    opacity: 0.8;
}

/* 取得元・ステータスバッジのスタイル */
.badge-api-source {
    display: inline-block;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 9px;
    font-weight: 700;
    color: var(--text-light);
    margin-right: 6px;
    vertical-align: middle;
}

.badge-source-google {
    background-color: #ea4335;
}

.badge-source-cache {
    background-color: #34a853;
}

.badge-source-demo {
    background-color: #fbbc05;
}

/* 本棚絞り込みチップスクロールエリア */
.filter-scroll-chips {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 4px;
}
/* スクロールバー非表示 (見た目のため) */
.filter-scroll-chips::-webkit-scrollbar {
    display: none;
}

.bookshelf-count-badge {
    font-size: 11px;
    font-weight: 700;
    color: var(--primary-color);
    background-color: var(--primary-light);
    padding: 4px 10px;
    border-radius: 20px;
}

/* トグルスイッチのスタイル */
.switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}
.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}
.slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: #ccc;
    transition: .4s;
    border-radius: 24px;
}
.slider:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}
input:checked + .slider {
    background-color: var(--primary-color);
}
input:checked + .slider:before {
    transform: translateX(20px);
}

/* 各モーダル（作品登録、設定、巻編集など）共通のレイアウト安定化と横揺れ防止 */
.modal .modal-content,
#modal-work-form .modal-content,
#modal-settings .modal-content,
#modal-volume-edit .modal-content {
    width: min(92vw, 420px) !important;
    max-width: 420px !important;
    min-width: 320px !important;
    box-sizing: border-box !important;
    overflow-x: hidden !important;
    transform: none !important; /* アニメーションでのtransformによる横揺れ防止 */
    transition: opacity 0.15s ease !important;
    scrollbar-gutter: stable !important; /* スクロールバーの出現による横ブレ防止 */
}

.modal .modal-body,
.modal form,
#modal-work-form .modal-body,
#modal-work-form form,
#modal-settings .modal-body,
#modal-settings form,
#modal-volume-edit .modal-body,
#modal-volume-edit form {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
    overflow-x: hidden !important;
}

/* モーダル内部のセクションやコンテナ要素の押し広げ防止 */
.modal .settings-section,
.modal .form-group,
.modal .form-row,
.modal .form-actions,
#modal-work-form .form-group,
#modal-work-form .form-row,
#modal-work-form .search-panel,
#modal-work-form .book-search-results,
#modal-work-form .book-candidate,
#modal-work-form .chip-list,
#modal-work-form .form-actions,
#modal-settings .settings-section,
#modal-settings .alias-form,
#modal-settings .file-input-wrapper,
#modal-settings #alias-list-container,
#modal-settings .alias-item,
#modal-volume-edit .form-group,
#modal-volume-edit .form-row,
#modal-volume-edit .form-actions {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
    overflow-x: hidden !important;
}

/* flexレイアウトのコンテナとその子要素の押し広げ防止 (別名辞書やデバッグトグル等の横並びレイアウト対策) */
#modal-settings .alias-form,
#modal-settings .alias-item,
#modal-settings .settings-section > div[style*="display: flex"] {
    display: flex !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
}

#modal-settings .alias-form > *,
#modal-settings .alias-item > *,
#modal-settings .settings-section > div[style*="display: flex"] > * {
    min-width: 0 !important; /* flex子要素が親幅を超えて広がらないようにする */
    max-width: 100% !important;
    box-sizing: border-box !important;
}

/* トグルスイッチや追加・削除ボタンが潰れないようにサイズを保護 */
#modal-settings .switch,
#modal-settings .alias-form button,
#modal-settings .alias-item button {
    flex-shrink: 0 !important;
}

/* モーダル内の入力欄や画像URLが横幅をはみ出すのを防止 + iOS Safariのフォーカス自動ズーム揺れ防止 */
.modal input,
.modal select,
.modal textarea,
.modal button,
#modal-work-form input,
#modal-work-form select,
#modal-work-form textarea,
#modal-work-form button,
#modal-settings input,
#modal-settings select,
#modal-settings textarea,
#modal-settings button,
#modal-volume-edit input,
#modal-volume-edit select,
#modal-volume-edit textarea,
#modal-volume-edit button {
    box-sizing: border-box !important;
    max-width: 100% !important;
    min-width: 0 !important;
    font-size: 16px !important; /* 16px以上にすることでiOSでフォーカス時に画面が自動ズームして横揺れするのを防ぐ */
}

/* ボタン要素の内部テキストが押し広げないように折り返しを許可 */
.modal button,
.modal .btn,
#modal-settings button,
#modal-settings .btn {
    white-space: normal !important;
    word-break: break-word !important;
    overflow-wrap: anywhere !important;
}

/* 検索結果カードや候補タイトルなどの押し広げ防止 */
#modal-work-form .book-candidates-list {
    max-width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
    max-height: 180px !important;
    -webkit-overflow-scrolling: touch !important;
    padding-bottom: 24px !important;
}

#modal-work-form .candidate-item {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
    word-break: break-all !important;
    display: flex !important;
    align-items: flex-start !important;
}

#modal-work-form .candidate-item * {
    max-width: 100% !important;
    min-width: 0 !important;
    overflow-wrap: anywhere !important;
    word-break: break-word !important;
}

#modal-work-form .candidate-title,
#modal-work-form .candidate-meta {
    word-break: break-word !important;
    overflow-wrap: anywhere !important;
    white-space: normal !important;
    max-width: 100% !important;
    min-width: 0 !important;
}

/* モーダル内の長い説明文やURLなどのテキストが親幅を押し広げるのを防止 */
.modal p,
.modal h2,
.modal h3,
.modal span,
.modal div,
#modal-settings .settings-section *,
#modal-settings .alias-item *,
#modal-settings p,
#modal-settings h3 {
    max-width: 100% !important;
    min-width: 0 !important;
    overflow-wrap: anywhere !important;
    word-break: break-word !important;
}

@media (max-width: 360px) {
    .modal .modal-content,
    #modal-work-form .modal-content,
    #modal-settings .modal-content,
    #modal-volume-edit .modal-content {
        width: calc(100vw - 24px) !important;
        min-width: 0 !important;
    }
}
