/* ============================
   基本設定・変数
   ============================ */
:root {
    --header-height: 60px;
    --footer-height: 65px;
    --primary-color: #f8f9fa;
    --accent-color: #007bff;
    --border-color: #ddd;
    --text-color: #333;
    --bg-color: #ffffff;
    --z-index-header: 100;
    --z-index-modal: 300;
    --z-index-nav: 50;
}

body {
    background-color: var(--bg-color);
    overflow: hidden;
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", "Yu Gothic", sans-serif;
    touch-action: none;
}

/* ============================
   ヘッダー
   ============================ */
#hymn-header {
    position: fixed; top: 0; left: 0; width: 100%; 
    height: var(--header-height);
    background-color: var(--primary-color);
    border-bottom: 1px solid var(--border-color);
    display: flex; align-items: center; justify-content: space-between; 
    padding: 0 10px; box-sizing: border-box; gap: 15px;
    z-index: var(--z-index-header);
    transition: transform 0.3s;
}
#hymn-header.hidden { transform: translateY(-100%); }

#current-id-display {
    font-weight: bold; font-size: 18px; color: var(--text-color);
    min-width: 50px; text-align: center;
}

#page-slider {
    flex-grow: 1; cursor: pointer; height: 44px; margin: 0;
}

/* ============================
   ビューアー (画像表示領域)
   ============================ */
#viewer-container {
    position: absolute; 
    top: 0; bottom: var(--footer-height); 
    left: 0; width: 100%;
    background-color: var(--bg-color);
    overflow: hidden;
    cursor: default;
}
#viewer-container.zoomed { cursor: grab; }
#viewer-container.zoomed:active { cursor: grabbing; }

#hymn-image {
    position: absolute;
    transform-origin: top left;
    will-change: width, height, top, left;
    user-select: none; 
    -webkit-user-drag: none;
}

/* スピナー */
#img-loading {
    position: absolute; top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    z-index: 40; pointer-events: none;
}
#img-loading.hidden { display: none; }

.spinner {
    width: 40px; height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid var(--accent-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

/* ナビゲーションゾーン */
.nav-zone {
    position: absolute; top: var(--header-height); bottom: 0; width: 15%;
    display: flex; align-items: center; justify-content: center;
    z-index: var(--z-index-nav); cursor: pointer;
    color: rgba(0,0,0,0.2); font-size: 4rem; font-weight: bold;
    user-select: none; -webkit-tap-highlight-color: transparent;
    transition: all 0.2s ease;
}
.nav-zone:hover {
    background: linear-gradient(to right, rgba(0,0,0,0.05), transparent);
    color: rgba(0,0,0,0.5);
}
.nav-zone.next-zone:hover {
    background: linear-gradient(to left, rgba(0,0,0,0.05), transparent);
}
.nav-zone:active { background: rgba(0,0,0,0.1); }
.prev-zone { left: 0; }
.next-zone { right: 0; }

/* ============================
   フッター & UIボタン
   ============================ */
#app-footer {
    position: fixed; bottom: 0; left: 0; width: 100%;
    height: var(--footer-height);
    background-color: var(--primary-color);
    border-top: 1px solid var(--border-color);
    z-index: var(--z-index-header);
}

.footer-nav {
    display: grid; grid-template-columns: repeat(5, 1fr); height: 100%;
}

.footer-btn {
    background: none; border: none; display: flex; flex-direction: column;
    align-items: center; justify-content: center; cursor: pointer;
    color: #555; padding: 5px 0; text-decoration: none;
}
.footer-btn.active { color: var(--accent-color); }
.footer-btn:active { background-color: #eee; }
.footer-btn .icon { font-size: 20px; margin-bottom: 4px; }
.footer-btn .label { font-size: 10px; }

.floating-left-btn {
    position: fixed; bottom: 75px; left: 15px; z-index: 90;
    background: #fff; border: 1px solid #ddd; border-radius: 30px;
    padding: 8px 15px; color: #333; font-size: 0.85rem; font-weight: bold;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    display: flex; align-items: center; justify-content: center; gap: 6px;
    cursor: pointer; transition: transform 0.1s;
}
.floating-left-btn:active { transform: scale(0.95); background: #f0f0f0; }
.icon-lg { font-size: 1.1rem; }

/* ============================
   モーダル & 検索
   ============================ */
.modal { 
    position: fixed; top: 0; left: 0; width: 100%; height: 100%; 
    background-color: rgba(0,0,0,0.5); z-index: var(--z-index-modal); 
    display: flex; justify-content: center; align-items: center; 
    visibility: visible; opacity: 1; transition: opacity 0.2s;
}
.modal.hidden { visibility: hidden; opacity: 0; pointer-events: none; }

.modal-content { 
    background: white; width: 90%; max-width: 500px; max-height: 85%; 
    overflow-y: auto; padding: 20px; border-radius: 8px; position: relative; 
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
}

.close-modal { 
    position: absolute; top: 10px; right: 15px; font-size: 28px; 
    cursor: pointer; color: #888; font-weight: bold; line-height: 1;
}

.search-controls {
    display: flex; flex-direction: column; gap: 10px; margin-bottom: 20px;
    border-bottom: 1px solid #eee; padding-bottom: 15px;
}
.search-label { font-size: 14px; font-weight: bold; color: #555; text-align: center;}
.search-input-group { display: flex; gap: 8px; }

#modal-search-input {
    flex: 1; padding: 10px; border: 1px solid #ddd; border-radius: 4px; font-size: 16px;
    background-color: #f9f9f9;
}
#modal-search-btn {
    padding: 0 20px; background: var(--accent-color); color: white; border: none; 
    border-radius: 4px; cursor: pointer; font-weight: bold;
}
#modal-search-btn:active { background: #0056b3; }

.search-list-container { padding-bottom: 10px; min-height: 50px; }
.song-item { 
    padding: 12px 10px; border-bottom: 1px solid #eee; cursor: pointer; 
    display: flex; justify-content: flex-start; align-items: center; gap: 15px; 
}
.song-item:hover { background-color: #f5f5f5; }
.song-id { color: var(--accent-color); font-weight: bold; min-width: 30px; text-align: right;}
.no-result { text-align: center; color: #888; margin-top: 20px; }

.modal-footer-actions { text-align: center; margin-top: 10px; }
#btn-show-all {
    background: none; border: none; color: var(--accent-color); 
    text-decoration: underline; cursor: pointer; font-size: 14px;
}

#loading { 
    position: fixed; top: 0; left: 0; width: 100%; height: 100%; 
    background: #fff; z-index: var(--z-index-modal); 
    display: flex; justify-content: center; align-items: center; 
    font-weight: bold; color: #666;
}