.photo-preview-app-container {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    border: 1px solid #ddd;
    border-radius: 8px;
    background: #fff;
    overflow: hidden;
    margin: 2em 0;
    box-shadow: 0 4px 15px rgba(0,0,0,0.05);
    display: flex;
    flex-direction: column;
    height: 700px;
    min-height: 500px;
}

.photo-preview-app-container:fullscreen {
    height: 100vh;
    margin: 0;
    border-radius: 0;
    border: none;
}

.photo-preview-header {
    padding: 1.5em;
    background: #f8f9fa;
    border-bottom: 1px solid #ddd;
    flex: none;
}

.photo-preview-header h3 {
    margin-top: 0;
    margin-bottom: 0.5em;
    font-size: 1.25em;
}

.photo-preview-header p {
    color: #666;
    margin-bottom: 1em;
    font-size: 0.9em;
}

.file-input-wrapper {
    display: flex;
    align-items: center;
    gap: 1em;
    flex-wrap: wrap;
}

.file-input-button {
    display: inline-block;
    padding: 8px 16px;
    background: #0073aa;
    color: #fff;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 600;
    transition: background 0.2s;
}

.hidden-file-input {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

.file-input-button:hover {
    background: #005177;
}

#photo-preview-status {
    font-size: 0.9em;
    color: #444;
}

.photo-preview-layout {
    display: flex;
    flex: 1;
    overflow: hidden;
}

.photo-preview-sidebar {
    width: 250px;
    border-right: 1px solid #ddd;
    background: #fafafa;
    display: flex;
    flex-direction: column;
}

.photo-preview-sidebar h4 {
    margin: 0;
    padding: 1em;
    font-size: 1em;
    border-bottom: 1px solid #ddd;
    background: #eee;
}

.file-list {
    list-style: none;
    margin: 0;
    padding: 0;
    overflow-y: auto;
    flex: 1;
}

.file-list li {
    padding: 10px 15px;
    border-bottom: 1px solid #eaeaea;
    cursor: pointer;
    font-size: 0.9em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: background 0.2s;
}

.file-list li:hover {
    background: #e6f7ff;
}

.file-list li.active {
    background: #0073aa;
    color: #fff;
}

.file-list li.empty-message {
    color: #999;
    text-align: center;
    padding: 2em 1em;
    cursor: default;
}

.file-list li.empty-message:hover {
    background: none;
}

.photo-preview-main {
    flex: 1;
    background: #000;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

.viewer-controls {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 1000;
    display: flex;
    gap: 8px;
}

.control-btn {
    background: rgba(0, 0, 0, 0.6);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.4);
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    transition: background 0.2s, color 0.2s;
}

.control-btn:hover {
    background: rgba(255, 255, 255, 0.9);
    color: #000;
}

.viewer-message {
    color: #fff;
    font-size: 1.1em;
}

.viewer-container {
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
}

.dicom-canvas {
    width: 100%;
    height: 100%;
}

.metadata-panel {
    position: absolute;
    top: 0;
    right: 0;
    width: 320px;
    height: 100%;
    background: rgba(255, 255, 255, 0.95);
    z-index: 1001;
    display: flex;
    flex-direction: column;
    box-shadow: -2px 0 10px rgba(0,0,0,0.3);
}

.metadata-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 15px;
    border-bottom: 1px solid #ddd;
    background: #f8f9fa;
}

.metadata-header h4 {
    margin: 0;
    font-size: 1em;
    color: #333;
}

.metadata-content {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
    background: #fff;
}

#metadata-list {
    list-style: none;
    margin: 0;
    padding: 0;
    font-size: 0.85em;
    color: #333;
    word-break: break-all;
}

#metadata-list li {
    margin-bottom: 8px;
    border-bottom: 1px dashed #eee;
    padding-bottom: 4px;
}

.loading-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.7);
    color: #fff;
    padding: 10px 20px;
    border-radius: 4px;
    z-index: 100;
}

/* JS9 overrides */
#photo-preview-fits-container .JS9Menubar {
    background-color: #f1f1f1;
    border-bottom: 1px solid #ddd;
}

#photo-preview-fits-container .JS9 {
    width: 100%;
    height: calc(100% - 40px); /* Account for menubar height */
}

/* レスポンシブ対応 (スマホ・タブレット向け) */
@media screen and (max-width: 768px) {
    .photo-preview-app-container {
        height: 90vh; /* スマホでは縦幅を広めに */
        margin: 1em 0;
    }

    .photo-preview-layout {
        flex-direction: column;
    }
    
    .photo-preview-sidebar {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid #ddd;
        flex: none;
    }
    
    .file-list {
        max-height: 150px;
        flex: none;
    }
    
    .photo-preview-main {
        flex: 1;
        min-height: 0; /* flex内で縮小可能にする */
    }
    
    .photo-preview-header {
        padding: 1em;
    }
    
    .file-input-button {
        width: 100%;
        text-align: center;
        box-sizing: border-box;
    }
    
    .file-input-wrapper {
        flex-direction: column;
        align-items: stretch;
        gap: 0.5em;
    }
    
    #photo-preview-status {
        text-align: center;
        margin-top: 0.5em;
    }
    
    .metadata-panel {
        width: 100%;
    }
}

/* 最大化クラス */
.photo-preview-maximized {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    margin: 0 !important;
    border-radius: 0 !important;
    border: none !important;
    z-index: 999999 !important;
    max-height: none !important;
}

/* 研究者向けツールバー */
.viewer-toolbar {
    position: absolute;
    top: 10px;
    left: 10px;
    z-index: 1000;
    display: flex;
    gap: 4px;
    background: rgba(0, 0, 0, 0.6);
    padding: 6px;
    border-radius: 4px;
    flex-wrap: wrap;
    max-width: 60%;
}

.tool-btn {
    background: transparent;
    color: #fff;
    border: 1px solid transparent;
    padding: 4px 8px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    transition: background 0.2s;
}

.tool-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

.tool-btn.active {
    background: #0073aa;
    border-color: #0073aa;
}

/* ピクセル情報表示エリア */
.fits-pixel-info {
    position: absolute;
    bottom: 10px;
    left: 10px;
    z-index: 1000;
    background: rgba(0, 0, 0, 0.7);
    color: #00ff00;
    padding: 6px 12px;
    border-radius: 4px;
    font-family: monospace;
    font-size: 13px;
    pointer-events: none;
    display: none;
}

