/* リセット & ベーススタイル */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* アイコンに合わせたティール→ブルーのグラデーション */
    --brand-grad-start: #19b3ab;
    --brand-grad-end: #0e6ba8;
    --page-bg: linear-gradient(135deg, var(--brand-grad-start) 0%, var(--brand-grad-end) 100%);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--page-bg);
    min-height: 100vh;
    color: #333;
}

.container {
    width: 100%;
    margin: 0;
    min-height: 100vh;
    background: white;
}

/* ヘッダー */
.header {
    background: linear-gradient(135deg, #2c3e50 0%, #4a6741 100%);
    color: white;
    padding: 0.4rem 1.5rem; /* 帯を狭く */
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.header h1 {
    font-size: 1.8rem;
    font-weight: 300;
    margin: 0; /* 帯の余白を詰める */
    line-height: 1.1; /* アイコン高さに合わせて詰める */
}

.header h1 i {
    margin-right: 10px;
    color: #3498db;
}

/* 置換したトップアイコン（画像）: 旧<i>と同じ見た目サイズ感に合わせる */
.header .logo-icon {
    width: 44px;   /* アイコンを大きく */
    height: 44px;
    object-fit: contain;
    vertical-align: middle;
    margin-right: 10px;
}

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

/* 表示切り替え */
.view-toggle {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-bottom: 2rem;
    padding: 1rem;
    background: #f8f9fa;
    border-radius: 8px;
}

.view-btn {
    background: white;
    border: 2px solid #e9ecef;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 500;
    color: #6c757d;
}

.view-btn.active {
    background: #007bff;
    border-color: #007bff;
    color: white;
}

.view-btn:hover:not(.active) {
    border-color: #007bff;
    color: #007bff;
}

.view-content {
    display: none;
}

.view-content.active {
    display: block;
}

/* 人物別表示（結果タブ用） */
.person-card-result {
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    margin-bottom: 2rem;
    overflow: hidden;
    border: 1px solid #e9ecef;
}

.person-header {
    background: linear-gradient(135deg, #4CAF50 0%, #45a049 100%);
    color: white;
    padding: 1.5rem;
}

.person-info {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.person-face-thumbnail {
    flex-shrink: 0;
}

.person-thumbnail {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid rgba(255, 255, 255, 0.3);
    background: rgba(255, 255, 255, 0.1);
}

.person-details h4 {
    margin: 0 0 0.5rem 0;
    font-size: 1.3rem;
    font-weight: 500;
}

.appearance-count {
    background: rgba(255, 255, 255, 0.2);
    padding: 0.3rem 0.8rem;
    border-radius: 15px;
    font-size: 0.9rem;
    display: inline-block;
}

.person-appearances {
    padding: 1.5rem;
}

.person-appearances h5 {
    margin: 0 0 1rem 0;
    color: #2c3e50;
    font-size: 1.1rem;
    border-bottom: 2px solid #e9ecef;
    padding-bottom: 0.5rem;
}

.appearance-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
}

.appearance-item {
    background: #f8f9fa;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid #e9ecef;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.appearance-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.appearance-image {
    position: relative;
    height: 120px;
    overflow: hidden;
}

.appearance-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.appearance-overlay {
    position: absolute;
    top: 8px;
    right: 8px;
}

.appearance-badge {
    background: #4CAF50;
    color: white;
    padding: 0.2rem 0.6rem;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 500;
}

.appearance-info {
    padding: 0.8rem;
}

.image-name {
    display: block;
    font-weight: 500;
    color: #2c3e50;
    margin-bottom: 0.3rem;
    font-size: 0.9rem;
}

.image-date {
    color: #6c757d;
    font-size: 0.8rem;
}

.person-images {
    padding: 1.5rem;
}

.person-image-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    margin-bottom: 1rem;
    background: #f8f9fa;
    border-radius: 8px;
    border-left: 4px solid #4CAF50;
}

.person-image-item:last-child {
    margin-bottom: 0;
}

.image-info {
    flex: 1;
}

.image-info h5 {
    margin: 0 0 0.5rem 0;
    color: #2c3e50;
    font-size: 1rem;
}

.image-date {
    color: #6c757d;
    font-size: 0.9rem;
    margin-right: 1rem;
}

.appearance-badge {
    background: #4CAF50;
    color: white;
    padding: 0.2rem 0.6rem;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 500;
}

.image-preview {
    flex-shrink: 0;
}

.image-preview img {
    width: 120px;
    height: 80px;
    object-fit: cover;
    border-radius: 6px;
    border: 2px solid #e9ecef;
}

.image-p.result-images img {
    width: 100%;
    max-width: 300px;
    height: auto;
    border-radius: 8px;
    border: 2px solid #e1e8ed;
}

/* 画像別表示の検出人物表示 */
.detected-people {
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 2px solid #e9ecef;
}

.detected-people h5 {
    margin: 0 0 1rem 0;
    color: #2c3e50;
    font-size: 1.1rem;
}

.detected-people-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 1rem;
}

.detected-person-item {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 1rem;
    text-align: center;
    border: 1px solid #e9ecef;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.detected-person-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.detected-person-face {
    margin-bottom: 0.8rem;
}

.person-face-thumb {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid #4CAF50;
    background: #f0f0f0;
}

.detected-person-info {
    text-align: center;
}

.person-name {
    display: block;
    font-weight: 500;
    color: #2c3e50;
    margin-bottom: 0.3rem;
    font-size: 0.9rem;
}

.detection-count {
    color: #6c757d;
    font-size: 0.8rem;
    background: #e9ecef;
    padding: 0.2rem 0.5rem;
    border-radius: 10px;
    display: inline-block;
}

.no-registered-people {
    text-align: center;
    color: #6c757d;
    font-style: italic;
    padding: 1rem;
    background: #f8f9fa;
    border-radius: 6px;
    border: 1px dashed #dee2e6;
}

/* グループ表示 */
.group-section {
    margin-bottom: 2rem;
}

.group-header {
    background: linear-gradient(135deg, #6f42c1 0%, #5a4fcf 100%);
    color: white;
    padding: 1rem;
    margin: 0 0 1rem 0;
    border-radius: 8px;
    font-size: 1.1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.group-count {
    background: rgba(255, 255, 255, 0.2);
    padding: 0.3rem 0.8rem;
    border-radius: 15px;
    font-size: 0.9rem;
}

.people-grid {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: wrap !important;
    gap: 1rem;
    margin-left: 0;
    justify-content: flex-start;
    align-items: stretch;
    width: 100%;
}

.person-card {
    flex: 0 0 260px !important;
    min-width: 260px !important;
    max-width: 280px !important;
    width: 260px !important;
    display: block !important;
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    border: 1px solid #e9ecef;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    margin-bottom: 0 !important;
}

.person-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15);
}

.person-face-preview {
    position: relative;
    height: 120px;
    overflow: hidden;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
}

.face-images {
    display: flex;
    height: 100%;
}

.face-image {
    flex: 1;
    position: relative;
    overflow: hidden;
}

.face-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.face-count-badge {
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 500;
}

.person-info {
    padding: 1rem;
}

.person-info h4 {
    margin: 0 0 0.5rem 0;
    color: #2c3e50;
    font-size: 1.1rem;
    font-weight: 600;
}

.person-stats {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.person-stats div {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: #6c757d;
    font-size: 0.9rem;
}

/* メインコンテンツ */
.main-content {
    padding: 1rem 2rem;
    max-width: none;
}

/* ボタン */
.btn {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.btn-primary {
    background: linear-gradient(135deg, #3498db, #2980b9);
    color: white;
}

.btn-secondary {
    background: linear-gradient(135deg, #95a5a6, #7f8c8d);
    color: white;
}

.btn-success {
    background: linear-gradient(135deg, #2ecc71, #27ae60);
    color: white;
}

.btn-danger {
    background: linear-gradient(135deg, #e74c3c, #c0392b);
    color: white;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* プロジェクト一覧 */
.projects-section h2 {
    margin-bottom: 1.5rem;
    color: #2c3e50;
    font-weight: 300;
}

.projects-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
}

.project-card {
    background: white;
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.07);
    border: 1px solid #e1e8ed;
    transition: all 0.3s ease;
    cursor: pointer;
}

.project-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

.project-card h3 {
    color: #2c3e50;
    margin-bottom: 0.5rem;
    font-weight: 600;
}

.project-card p {
    color: #7f8c8d;
    margin-bottom: 1rem;
    line-height: 1.5;
}

.project-stats {
    display: flex;
    justify-content: space-between;
    margin-bottom: 1rem;
    font-size: 0.9rem;
}

.stat {
    display: flex;
    align-items: center;
    gap: 5px;
    color: #95a5a6;
}

.stat i {
    color: #3498db;
}

.project-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.project-date {
    font-size: 0.8rem;
    color: #bdc3c7;
}

/* プロジェクト詳細 */
.project-detail {
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from { opacity: 0; transform: translateX(20px); }
    to { opacity: 1; transform: translateX(0); }
}

.detail-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 2rem;
}

.detail-header h2 {
    color: #2c3e50;
    font-weight: 300;
}

/* タブ */
.detail-tabs {
    display: flex;
    border-bottom: 2px solid #ecf0f1;
    margin-bottom: 2rem;
}

.tab-btn {
    background: none;
    border: none;
    padding: 1rem 1.5rem;
    cursor: pointer;
    border-bottom: 3px solid transparent;
    transition: all 0.3s ease;
    color: #7f8c8d;
    font-size: 1rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.tab-btn:hover {
    color: #3498db;
    background: rgba(52, 152, 219, 0.1);
}

.tab-btn.active {
    color: #3498db;
    border-bottom-color: #3498db;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

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

.tab-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

/* 削除: 古い人物グリッド（上でflexboxに変更済み） */

/* 削除: 重複した古いperson-cardスタイル */

.person-stats {
    font-size: 0.9rem;
    color: #7f8c8d;
}

/* アップロードエリア - 画面いっぱいレイアウト */
.upload-section {
    width: 100%;
    max-width: none;
    margin: 0;
    padding: 2rem;
    min-height: 70vh;
    display: flex;
    flex-direction: column;
}

.upload-section h3 {
    text-align: center;
    margin-bottom: 2rem;
    font-size: 2rem;
    color: #2c3e50;
    font-weight: 300;
}

.upload-area {
    border: 2px dashed #3498db;
    border-radius: 12px;
    padding: 3rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    background: rgba(52, 152, 219, 0.05);
    margin-bottom: 2rem;
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    min-height: 300px;
}

.upload-area:hover {
    border-color: #2980b9;
    background: rgba(52, 152, 219, 0.1);
}

.upload-area i {
    font-size: 5rem;
    color: #3498db;
    margin-bottom: 1.5rem;
    display: block;
}

.upload-area p {
    font-size: 1rem;
    color: #2c3e50;
    margin: 0;
    font-weight: 400;
}

.upload-area input[type="file"] {
    display: none;
}

.selected-images {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 15px;
    margin-bottom: 2rem;
    padding: 1rem;
    background: #f8f9fa;
    border-radius: 12px;
    border: 1px solid #e9ecef;
}

.image-item {
    position: relative;
    border-radius: 8px;
    overflow: hidden;
}

.image-item img {
    width: 100%;
    height: 100px;
    object-fit: cover;
}

.image-remove {
    position: absolute;
    top: 5px;
    right: 5px;
    background: rgba(231, 76, 60, 0.9);
    color: white;
    border: none;
    border-radius: 50%;
    width: 25px;
    height: 25px;
    cursor: pointer;
}

.image-remove:hover {
    background: #c0392b;
}

/* 画像処理ボタンの大型化 */
#process-btn {
    width: 100%;
    max-width: 400px;
    margin: 0 auto;
    display: block;
    padding: 1.5rem 3rem;
    font-size: 1.5rem;
    font-weight: 600;
    border-radius: 15px;
    background: linear-gradient(135deg, #27ae60, #2ecc71);
    border: none;
    color: white;
    box-shadow: 0 8px 20px rgba(46, 204, 113, 0.3);
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 1px;
}

#process-btn:hover:not(:disabled) {
    transform: translateY(-3px);
    box-shadow: 0 12px 30px rgba(46, 204, 113, 0.4);
    background: linear-gradient(135deg, #2ecc71, #27ae60);
}

#process-btn:disabled {
    background: #bdc3c7;
    box-shadow: none;
    cursor: not-allowed;
    transform: none;
}

/* アップロード履歴 */
.history-section {
    margin-top: 24px;
    background: #ffffff;
    border: 1px solid #e9ecef;
    border-radius: 12px;
    padding: 16px;
}
.history-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}
.history-header h4 {
    margin: 0;
}
.history-summary {
    color: #6c757d;
}
.history-table-wrap {
    overflow-x: auto;
}
table.table-compact {
    width: 100%;
    border-collapse: collapse;
}
table.table-compact th,
table.table-compact td {
    font-size: 0.95rem;
    padding: 8px 10px;
    border-bottom: 1px solid #f1f3f5;
    text-align: left;
}
table.table-compact thead th {
    background: #f8f9fa;
    color: #495057;
}

/* 人物別表示の新しいレイアウト */
.person-card-result {
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    margin-bottom: 2rem;
    overflow: hidden;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.person-card-result:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 15px rgba(0, 0, 0, 0.15);
}

/* 左右レイアウト */
.person-layout {
    display: flex;
    min-height: 300px;
}

.person-left {
    flex: 0 0 120px;
    padding: 0.75rem;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    border-right: 1px solid #dee2e6;
}

.person-right {
    flex: 1;
    padding: 2rem;
    background: white;
}

/* 人物の顔画像（大きく表示） */
.person-face-large {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    overflow: hidden;
    margin-bottom: 0.5rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    border: 3px solid white;
}

.person-face-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.person-face-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #3498db, #2980b9);
    color: white;
    font-size: 2rem;
}

/* 人物情報 */
.person-info h3 {
    margin: 0.25rem 0 0.5rem 0;
    color: #2c3e50;
    font-size: 1.2rem;
    font-weight: 600;
}

.person-stats {
    width: 100%;
    margin-top: 0.25rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.9rem;
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: #6c757d;
    font-size: 0.9rem;
    white-space: nowrap;
}

.stat-item i {
    width: 16px;
    color: #3498db;
}
/* 折り返し防止（日本語が1文字ずつ縦積みになるのを回避） */
.stat-item span {
    white-space: nowrap;
}

/* 右側の登場写真 */
.person-right h4 {
    margin: 0 0 1.5rem 0;
    color: #2c3e50;
    font-size: 1.2rem;
    font-weight: 600;
    border-bottom: 2px solid #3498db;
    padding-bottom: 0.5rem;
}

.appearance-photos {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 0.75rem;
}

.photo-item {
    position: relative;
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    background: #f8f9fa;
}

.photo-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
}

.photo-item img {
    width: 100%;
    height: 120px;
    object-fit: cover;
    display: block;
}

.photo-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.8));
    color: white;
    padding: 1rem;
    transform: translateY(100%);
    transition: transform 0.3s ease;
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
}

.photo-item:hover .photo-overlay {
    transform: translateY(0);
}

.photo-info {
    flex: 1;
}

.photo-name {
    display: block;
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 0.2rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.photo-count {
    display: block;
    font-size: 0.8rem;
    opacity: 0.9;
}

.photo-expand {
    font-size: 1.2rem;
    opacity: 0.8;
    transition: opacity 0.2s ease;
}

.photo-item:hover .photo-expand {
    opacity: 1;
}

/* 画像拡大モーダル */
/* 新しいフルスクリーン画像ビューア */
.image-viewer { position: fixed; inset: 0; z-index: 10000; }
.image-viewer .viewer-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,0.9); }
.image-viewer .viewer-toolbar {
  position: absolute; top: 0; left: 0; right: 0; height: 56px;
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
  padding: 0 0.75rem; background: rgba(0,0,0,0.5); color: #fff;
}
.image-viewer .viewer-title { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; max-width: 50vw; }
.image-viewer .viewer-actions { display: flex; gap: 6px; }
.image-viewer .viewer-actions-center { justify-self: center; align-items: center; gap: 10px; }
.image-viewer .viewer-actions-right { justify-self: end; }
.image-viewer .viewer-btn.select-toggle { font-weight: 700; }
.image-viewer .viewer-btn.select-toggle.is-selected { background: #c0392b; color: #fff; }
.image-viewer .viewer-btn.select-toggle:not(.is-selected) { background: #27ae60; color: #fff; }
.image-viewer .viewer-btn { background: rgba(255,255,255,0.9); border: none; border-radius: 6px; padding: 6px 10px; cursor: pointer; }
.image-viewer .viewer-btn:hover { background: #fff; }
.image-viewer .viewer-close { background: rgba(255,70,70,0.95); color: #fff; }
.image-viewer .viewer-stage { position: absolute; top: 56px; bottom: 0; left: 0; right: 0; overflow: hidden; cursor: grab; }
.image-viewer .viewer-stage.is-panning { cursor: grabbing; }
.image-viewer .viewer-canvas { position: absolute; inset: 0; }
.image-viewer .viewer-image { position: absolute; top: 0; left: 0; will-change: transform; transform-origin: 0 0; user-select: none; pointer-events: auto; }
.image-viewer .viewer-check { position: absolute; top: 6px; left: 6px; background: rgba(39, 174, 96, 0.9); color: #fff; border-radius: 50%; width: 28px; height: 28px; display: flex; align-items: center; justify-content: center; font-size: 16px; z-index: 2; }

#process-btn i {
    margin-right: 0.8rem;
    font-size: 1.3rem;
}

/* 結果グリッド */
.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.results-grid {
    display: grid;
    gap: 1.5rem;
}

.result-card {
    background: white;
    border-radius: 12px;
    padding: 1.5rem;
    border: 1px solid #e1e8ed;
}

.result-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.result-images {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

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

.result-image img {
    max-width: 100%;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.people-detected {
    margin-top: 1rem;
}

.people-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.person-tag {
    background: linear-gradient(135deg, #3498db, #2980b9);
    color: white;
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.8rem;
}

/* モーダル */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    animation: modalFadeIn 0.3s ease;
}

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

.modal-content {
    background-color: white;
    margin: 5vh auto;
    padding: 0;
    border-radius: 12px;
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: modalSlideIn 0.3s ease;
    display: flex;
    flex-direction: column;
}

@keyframes modalSlideIn {
    from { transform: translateY(-50px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.modal-header {
    background: linear-gradient(135deg, #2c3e50, #4a6741);
    color: white;
    padding: 1.5rem 2rem;
    border-radius: 12px 12px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    font-weight: 300;
}

.close {
    font-size: 1.5rem;
    cursor: pointer;
    opacity: 0.7;
}

.close:hover {
    opacity: 1;
}

.modal form {
    padding: 2rem;
    flex: 1;
    overflow: auto;
    display: flex;
    flex-direction: column;
}

/* Dialog: improved visuals */
.dialog .dialog-content { border: 1px solid #eaeef3; box-shadow: 0 24px 60px rgba(16, 24, 40, 0.18); }
.dialog .dialog-header { display:flex; align-items:center; justify-content:space-between; padding: 1rem 1.25rem; background: linear-gradient(135deg, #224361, #355e45); color:#fff; border-radius: 12px 12px 0 0; }
.dialog .dialog-body { display:flex; gap:14px; align-items:flex-start; padding: 1.25rem 1.5rem; line-height:1.6; color:#2c3e50; }
.dialog .dialog-icon { flex: 0 0 32px; display:flex; align-items:center; justify-content:center; }
.dialog .dialog-message { white-space: pre-wrap; }
.dialog .dialog-footer { padding: 1rem 1.25rem; border-top: 1px solid #eef2f7; background:#fafbfc; border-radius: 0 0 12px 12px; display:flex; justify-content:flex-end; gap:10px; }
.dialog .close { color:#fff; }

.dialog .btn.btn-primary { background: linear-gradient(135deg, #2d7ff9, #1b5fe4); box-shadow: 0 6px 16px rgba(45,127,249,.24); }
.dialog .btn.btn-primary:hover { filter: brightness(0.98); }
.dialog .btn.btn-secondary { background: linear-gradient(135deg, #95a5a6, #7f8c8d); }

.dialog .variant-info svg path[fill="#2d7ff9"],
.dialog .variant-warning svg path[stroke="#f5a524"],
.dialog .variant-success svg path[stroke="#27ae60"],
.dialog .variant-error svg path[stroke="#e74c3c"] { filter: drop-shadow(0 2px 6px rgba(0,0,0,.1)); }


/* フォーム */
.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: #2c3e50;
}

.form-group input,
.form-group textarea {
    width: 100%;
    padding: 0.75rem;
    border: 2px solid #e1e8ed;
    border-radius: 6px;
    font-size: 1rem;
    transition: border-color 0.3s ease;
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #3498db;
}

.help-text {
    font-size: 0.8rem;
    color: #7f8c8d;
    margin-top: 0.25rem;
}

.image-preview {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 10px;
    margin-top: 1rem;
    max-height: 40vh;
    overflow: auto;
}

.preview-item {
    position: relative;
}

.preview-item img {
    width: 100%;
    height: 80px;
    object-fit: cover;
    border-radius: 6px;
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 2rem;
    border-top: 1px solid #e1e8ed;
    padding-top: 1.5rem;
    position: sticky;
    bottom: 0;
    background: #fff;
}

/* 通知 */
.notification {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 10001;
    max-width: 400px;
    animation: slideInRight 0.3s ease;
}

@keyframes slideInRight {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

.notification-content {
    background: white;
    padding: 1rem 1.5rem;
    border-radius: 8px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
    border-left: 4px solid #2ecc71;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.notification.error .notification-content {
    border-left-color: #e74c3c;
}

.notification-close {
    cursor: pointer;
    font-size: 1.2rem;
    opacity: 0.7;
    margin-left: 1rem;
}

.notification-close:hover {
    opacity: 1;
}

/* ローディング */
.loading {
    text-align: center;
    padding: 2rem;
    color: #7f8c8d;
}

.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1002;
}

.loading-spinner {
    background: white;
    padding: 2rem;
    border-radius: 12px;
    text-align: center;
}

.loading-spinner i {
    font-size: 2rem;
    color: #3498db;
    margin-bottom: 1rem;
}

.loading-progress {
    margin-top: 1rem;
    width: 200px;
}

.loading-progress-bar {
    width: 100%;
    height: 8px;
    background: #e0e0e0;
    border-radius: 4px;
    overflow: hidden;
}

.loading-progress-bar-inner {
    height: 100%;
    width: 0%;
    background: #3498db;
    transition: width 0.2s ease;
}

.loading-progress-text {
    margin-top: 0.5rem;
    font-size: 0.9rem;
    color: #2c3e50;
}

/* ユーティリティクラス */
.hidden {
    display: none !important;
}

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

.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }

/* レスポンシブ */
@media (max-width: 768px) {
    .container {
        margin: 0;
        min-height: 100vh;
    }
    
    .header {
        padding: 1rem;
        flex-direction: column;
        gap: 1rem;
    }
    
    .main-content {
        padding: 1rem;
    }
    
    .projects-grid {
        grid-template-columns: 1fr;
    }
    
    .detail-tabs {
        overflow-x: auto;
    }
    
    .tab-btn {
        white-space: nowrap;
    }
}

/* 選別タブ - サブタブはdetail-tabs/tab-btnスタイルを継承 */
.culling-mode { display:none; }
.culling-mode.active { display:block; }
.people-mode { display: none; }
.people-mode.active { display: block; }
.confirm-grid { display:flex; flex-direction:column; gap:12px; }
.confirm-image { position:relative; border-radius:8px; overflow:hidden; background:#f8f9fa; }
.confirm-image img { width:100%; height:auto; object-fit:contain; display:block; }
/* 確認ビュー: 選択枚数バッジ（赤） */
.confirm-image .selected-count-badge {
    position:absolute; top:8px; left:8px;
    min-width:28px; height:28px; padding:0 8px;
    background: #e74c3c; color:#fff; border-radius:999px;
    border: 2px solid #fff; font-size:13px; font-weight:800;
    display:inline-flex; align-items:center; justify-content:center;
    box-shadow: 0 3px 10px rgba(231,76,60,0.35);
    z-index: 2;
}
/* 確認ビュー: 顔枠の色（人物に選択が1枚以上あれば緑、なければ赤） */
.confirm-image .bbox.is-selected { outline-color: #27ae60; box-shadow: 0 0 0 1px rgba(39,174,96,0.25); }
.confirm-image .bbox.is-unselected { outline-color: #e74c3c; box-shadow: 0 0 0 1px rgba(231,76,60,0.25); }
/* 値付きの丸ラベルを枠色に合わせる（見やすさ向上） */
.confirm-image .bbox.is-selected .num { background: #27ae60; }
.confirm-image .bbox.is-unselected .num { background: #e74c3c; }
/* 選択有無で枠色変更 */
.confirm-image.has-selected { border: 3px solid #27ae60; }
.confirm-image.no-selected { border: 3px solid #e74c3c; }

/* 確認タブ: 全人物サマリー */
/* 旧: 人物カードは廃止（スタイル削除） */
.confirm-image .bbox { position:absolute; border:0; outline:4px solid red; outline-offset:0; box-shadow:0 0 0 1px rgba(255,0,0,0.25); pointer-events:none; }
.confirm-image .bbox .num {
    position:absolute; top:-14px; left:-14px;
    min-width:24px; height:24px; padding:0 6px;
    background: rgba(0,0,0,0.7); color:#fff; border-radius:999px;
    font-size:12px; font-weight:800; display:flex; align-items:center; justify-content:center;
}
.confirm-image .bbox .num { position:absolute; top:0; left:0; background:rgba(231,76,60,0.9); color:#fff; font-size:12px; padding:2px 4px; }
.confirm-image .bbox.disabled { outline-color: #888; box-shadow: 0 0 0 1px rgba(0,0,0,0.15); }

/* 無効タブ（クリック可能な枠）: 有効=緑 / 無効=グレー */
.confirm-image.toggleable .bbox { outline-color: #27ae60; box-shadow: 0 0 0 1px rgba(39,174,96,0.25); pointer-events:auto; cursor: pointer; }
.confirm-image.toggleable .bbox.disabled { outline-color: #888; box-shadow: 0 0 0 1px rgba(0,0,0,0.15); }
.confirm-image.toggleable .bbox .num { display: none; }

/* 無効顔サマリー（人物ごとの顔クラスタ） */
.disabled-summary { margin: 8px 0 14px; }
.disabled-summary .simple-list { display:flex; flex-wrap: wrap; list-style:none; padding:0; margin:0; gap:10px; }
.disabled-summary .simple-list li { display:block; padding:8px 10px; border:1px solid #e9ecef; border-radius:10px; background:#fff; flex: 0 1 320px; min-width: 260px; }
.disabled-summary .simple-list .head { display:flex; align-items:center; gap:10px; margin-bottom:6px; }
.disabled-summary .simple-list .name { color:#2c3e50; font-weight:800; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.disabled-summary .simple-list .count { color:#6c757d; font-weight:700; margin-left:auto; }
.disabled-summary .simple-list .faces { display:flex; flex-wrap: wrap; gap:8px; padding-bottom: 4px; }
.disabled-summary .simple-list .face-thumb { width:56px; height:56px; border-radius:8px; overflow:hidden; border:2px solid #888; }
.disabled-summary .simple-list .face-thumb img { width:100%; height:100%; object-fit:cover; filter: grayscale(100%); }
.confirm-image .bbox.disabled .num { background: #888; }
.culling-layout {
    display: grid;
    grid-template-columns: 700px 1fr;
    gap: 1rem;
}

.culling-topbar {
    display: grid;
    grid-template-columns: 1fr auto auto;
    align-items: center;
    gap: 12px;
    margin-bottom: 0.75rem;
}

.culling-topbar .count-badge {
    background: linear-gradient(135deg, #f8f9fa, #eef2f7);
    color: #2c3e50;
    padding: 8px 16px;
    border-radius: 999px;
    font-weight: 700;
    font-size: 1.05rem;
    border: 1px solid #e1e8ed;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.culling-topbar-actions { display: inline-flex; align-items: center; gap: 10px; }

#export-zip-btn.btn.btn-warning { background: linear-gradient(135deg, #f6d365, #fda085); color: #2c3e50; border: none; }
#export-zip-btn.btn.btn-warning:hover { filter: brightness(0.95); }
.export-status { min-width: 140px; color: #6c757d; font-size: 0.9rem; }

.culling-left {
    background: #fff;
    border: 1px solid #e9ecef;
    border-radius: 12px;
    padding: 1rem;
    max-height: calc(100vh - 200px);
    display: flex;
    flex-direction: column;
}

.culling-left-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.75rem;
}

.people-count-badge {
    font-size: 0.9rem; color: #6c757d; font-weight: 600; margin-left: 8px;
}

.count-badge { color: #2c3e50; font-size: 1rem; font-weight: 700; }
.count-badge strong { color: #2c3e50; }

#people-register-summary.count-badge {
    padding: 6px 12px;
    background: linear-gradient(135deg, #f8f9fa, #eef2f7);
    border: 1px solid #e1e8ed;
    border-radius: 999px;
}

.face-thumb-grid {
    display: grid;
    grid-template-columns: repeat(5, 120px);
    gap: 10px;
    max-height: calc(100vh - 260px);
    overflow-y: auto;
    padding-right: 4px;
}

.face-thumb {
    position: relative;
    width: 120px;
    height: 120px;
    border-radius: 10px;
    overflow: hidden;
    border: 2px solid #e9ecef;
    cursor: pointer;
    background: #f8f9fa;
}

.face-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }

.face-thumb .badge {
    position: absolute; top: 6px; right: 6px;
    background: linear-gradient(135deg, #e74c3c, #c0392b);
    color: #fff;
    padding: 4px 10px; border-radius: 14px; font-size: 13px; font-weight: 700;
    box-shadow: 0 2px 6px rgba(231,76,60,0.4);
}

/* 左上の白丸：検出画像数（images.length） */
.face-thumb .white-badge {
    position: absolute;
    top: 6px;
    left: 6px;
    min-width: 24px;
    height: 24px;
    padding: 0 6px;
    background: #fff;
    color: #2c3e50;
    border-radius: 999px;
    border: 1px solid rgba(0,0,0,0.08);
    font-size: 12px;
    font-weight: 800;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 6px rgba(0,0,0,0.08);
}

.face-thumb.selected { outline: 3px solid #e74c3c; }

.culling-right {
    background: #fff;
    border: 1px solid #e9ecef;
    border-radius: 12px;
    padding: 1rem;
    min-height: 400px;
}

.culling-right-header {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    margin-bottom: 0.75rem;
}

.culling-right-header h3#culling-selected-person { justify-self: start; }
.culling-right .culling-actions { justify-self: center; }
.toggle-group { display: flex; gap: 18px; align-items: center; }
.toggle-group .switch .label { white-space: nowrap; }

/* スタイリッシュトグルスイッチ */
.switch { position: relative; display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; }
.switch input { display: none; }
.switch .slider {
    position: relative; width: 48px; height: 26px; background: #ced4da; border-radius: 999px;
    transition: background 0.2s ease; box-shadow: inset 0 1px 3px rgba(0,0,0,0.2);
}
.switch .slider::after {
    content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; background: #fff; border-radius: 50%;
    transition: transform 0.2s ease; box-shadow: 0 2px 6px rgba(0,0,0,0.25);
}
.switch input:checked + .slider { background: linear-gradient(135deg, #2ecc71, #27ae60); }
.image-viewer .switch .label { color: #fff; }
.switch input:checked + .slider::after { transform: translateX(22px); }
.switch .label { font-weight: 700; color: #343a40; }

.culling-photos-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 12px;
}

.culling-photo {
    position: relative;
    border-radius: 8px;
    overflow: hidden;
    background: #f8f9fa;
    border: 2px solid transparent;
}

.culling-photo img { width: 100%; height: 220px; object-fit: cover; display: block; cursor: zoom-in; }

.culling-photo .bbox {
    position: absolute;
    border: 0;
    outline: 4px solid red;
    outline-offset: 0;
    box-shadow: 0 0 0 1px rgba(255,0,0,0.25);
    pointer-events: none;
    z-index: 2;
}

/* 識別（緑枠）: トグル「識別」ON時に付与する .identified クラス */
.culling-photo .bbox.identified { outline-color: #27ae60; box-shadow: 0 0 0 1px rgba(39,174,96,0.25); z-index: 1; }

/* 画像拡大ビューワ用のbbox */
.image-viewer .bbox {
    position: absolute;
    border: 0;
    outline: 4px solid red;
    outline-offset: 0;
    box-shadow: 0 0 0 1px rgba(255,0,0,0.25);
    pointer-events: none;
    z-index: 2;
}

/* 画像拡大ビューアでの識別（緑枠） */
.image-viewer .bbox.identified { outline-color: #27ae60; box-shadow: 0 0 0 1px rgba(39,174,96,0.25); z-index: 1; }

/* オーバーレイ層自体もイベントを透過させる */
.image-viewer .viewer-overlays { position: absolute; top: 0; left: 0; pointer-events: none; }

.culling-photo.selected { border-color: #27ae60; }

.culling-photo .check {
    position: absolute; top: 6px; left: 6px; background: rgba(39, 174, 96, 0.9); color: #fff; border-radius: 50%; width: 24px; height: 24px; display: flex; align-items: center; justify-content: center; font-size: 14px;
}

.culling-photo .actions {
    display: flex; gap: 8px; padding: 8px; justify-content: center; align-items: center; background: #fff; border-top: 1px solid #e9ecef;
}
.culling-photo .btn-select { background: #27ae60; color: #fff; border: none; border-radius: 6px; padding: 6px 10px; cursor: pointer; }
.culling-photo .btn-select.is-selected { background: #c0392b; }

@media (max-width: 1024px) {
    .culling-layout { grid-template-columns: 1fr; }
}

/* 共通フッター */
.site-footer {
    text-align: center;
    padding: 44px 16px 24px; /* 上部をさらに広めに */
    color: #6c757d;
    /* frosted glass (white-leaning, less color bleed) */
    background: rgba(255, 255, 255, 0.84);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-top: 1px solid rgba(0, 0, 0, 0.06);
    box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.06);
    margin-top: auto; /* 親がflex列のとき下寄せ */
}
.site-footer a { color: #3498db; text-decoration: none; }

/* 共通フッター（メニュー + コピーライト） */
.footer-spacer { height: 256px; }
.brand-footer-links { display: inline-flex; gap: 3rem; flex-wrap: wrap; align-items: center; justify-content: center; padding: 8px 0; }
.brand-footer-links a { color: #3498db; text-decoration: none; }
.brand-footer-links a:hover { text-decoration: underline; }
.brand-footer-copy { margin-top: 10px; font-size: 0.9rem; color: #6c757d; }