/* ==========================================
   共通ヘッダー / 共通フッター（全ページ共通）
   - ヘッダー: 上端固定 38px（不透明）
   - フッター: 下端固定 22px（不透明）
   ========================================== */

:root {
    --app-header-height: 38px;
    --app-footer-height: 22px;
}

/* HTML の hidden 属性を CSS の display 宣言で上書きされないよう明示
   (display: flex/grid/inline-flex 等を持つ要素で hidden が無効化される問題を防ぐ) */
[hidden] {
    display: none !important;
}

/* body にスペースを確保（固定ヘッダー/フッターに重ならないように） */
body {
    padding-top: var(--app-header-height);
    padding-bottom: var(--app-footer-height);
}

/* === ヘッダー === */
.app-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--app-header-height);
    z-index: 200;
    background: var(--bg-panel);
    border-bottom: 1px solid var(--border-subtle);
}


.app-header-inner {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    height: 100%;
    padding: 0 16px;
    gap: 12px;
    max-width: 1800px;
    margin: 0 auto;
}

.app-header-left {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 8px;
}

/* admin/一般 ユーザー向けメタ情報 (バージョン + 管理画面リンク + 権限バッジ) は
   左カラムの右端に寄せ、中央タイトルの直左に配置する。
   こうすることでタイトルは grid の auto 列に単独で残り、常にページ中央を保つ。 */
.app-header-meta {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
}

.app-header-center {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
}

.app-header-right {
    display: inline-flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
}

/* === バージョンバッジ === */
.app-header-version {
    display: inline-block;
    padding: 2px 8px;
    font-size: 0.68rem;
    font-weight: 600;
    color: var(--text-muted);
    background: var(--bg-surface);
    border: 1px solid var(--border-primary);
    border-radius: 999px;
    line-height: 1.4;
    letter-spacing: 0.04em;
    user-select: text;
}

.app-header-title {
    font-size: 1rem;
    font-weight: 800;
    letter-spacing: -0.01em;
    line-height: 1;
}

.app-header-title .title-pic {
    color: var(--text-heading);
}

.app-header-title .title-trans {
    background: var(--gradient-brand-text);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.app-header-company {
    font-size: 0.7rem;
    color: var(--text-secondary);
    letter-spacing: 0.04em;
}

/* === 権限バッジ（テスト用：管理者 / 一般 を可視化） === */
.app-header-role {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    font-size: 0.65rem;
    font-weight: 700;
    border-radius: 999px;
    line-height: 1;
    letter-spacing: 0.04em;
    align-self: center;
    user-select: none;
}

.app-header-role svg {
    flex: 0 0 auto;
}

.app-header-role.is-admin {
    color: #b45309;
    background: #fef3c7;
    border: 1px solid #f59e0b;
}

/* センター内に置かれる管理画面リンクは少し詰める */
.app-header-link.app-header-link-compact {
    padding: 2px 8px;
    font-size: 0.7rem;
    line-height: 1.4;
}

.app-header-link.app-header-link-compact svg {
    width: 12px;
    height: 12px;
}

/* === ヘッダー右端 共通リンク === */
.app-header-link {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 10px;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-primary);
    text-decoration: none;
    border-radius: 999px;
    border: 1px solid var(--border-primary);
    background: transparent;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
    font-family: inherit;
    line-height: 1.4;
}

/* HTML標準の hidden 属性を display:inline-flex より優先 */
.app-header-link[hidden] {
    display: none;
}

.app-header-link:hover {
    background: var(--accent-a08);
    border-color: var(--accent-a40);
    color: var(--accent);
}

.app-header-link svg {
    flex-shrink: 0;
    width: 12px;
    height: 12px;
}

.app-header-link.is-primary {
    background: var(--gradient-brand);
    color: #ffffff;
    border-color: transparent;
    box-shadow: var(--shadow-glow);
}

.app-header-link.is-primary:hover {
    color: #ffffff;
    box-shadow: var(--shadow-glow-hover);
    transform: translateY(-1px);
}

/* === フッター === */
.app-footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--app-footer-height);
    z-index: 200;
    background: var(--bg-panel);
    border-top: 1px solid var(--border-subtle);
}

.app-footer-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    height: 100%;
    padding: 0 16px;
    max-width: 1800px;
    margin: 0 auto;
}

.app-footer-note {
    margin: 0;
    font-size: 0.68rem;
    color: var(--text-muted);
    line-height: 1.3;
    flex: 1;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.app-footer-credit {
    margin: 0;
    font-size: 0.68rem;
    color: var(--text-muted);
    opacity: 0.85;
    white-space: nowrap;
    line-height: 1.3;
}

.app-footer-contact {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.68rem;
    color: var(--text-muted);
    text-decoration: underline;
    white-space: nowrap;
    line-height: 1.3;
    opacity: 0.85;
    transition: opacity 0.15s, color 0.15s;
}
.app-footer-contact:hover {
    opacity: 1;
    color: var(--text-primary);
}
.app-footer-contact svg {
    flex-shrink: 0;
}


/* ==========================================
   アプリ画面 全体スクロール制御
   - body の overflow を抑制し、container を position:fixed で画面に固定
   - container 内を CSS Grid で「auto + 1fr」に分割
   - style.css の .container max-width / margin / padding を完全に上書き
   ========================================== */
/* PC 専用 (最小 1280px)、ビューポートが 1280px 未満なら横スクロール、
   要素配置はそのまま縮小せず見切れる */
html,
body.app-page {
    min-width: 1280px;
}

body.app-page {
    position: relative;  /* 子要素 (absolute) の基準にする */
    margin: 0;
    padding-top: 0;
    padding-bottom: 0;
    height: 100vh;
    min-height: 560px;   /* ノート PC (ブックマークバー等で実効 580〜600px) でも縦スクロールしない */
    overflow: auto;       /* 横・縦とも見切れたらスクロール */
}

body.app-page .app-header,
body.app-page .app-footer {
    position: absolute;  /* 横スクロールに連動するよう absolute に */
    min-width: 1280px;
}

body.app-page .container {
    position: absolute;
    top: var(--app-header-height);
    bottom: var(--app-footer-height);
    left: 0;
    right: 0;
    min-width: 1280px;
    max-width: none;
    margin: 0;
    padding: 12px 24px;
    display: grid;
    grid-template-rows: auto 1fr;
    gap: 12px;
    overflow: hidden;
    box-sizing: border-box;
}

body.app-page .info-panels {
    margin-bottom: 0;
}

/* === アップ後 info-panels コンパクトモード === */
body.app-page .info-panels.compact {
    gap: 8px;
}

body.app-page .info-panels.compact > details > summary {
    padding: 4px 10px;
    font-size: 0.75rem;
}

body.app-page .info-panels.compact > details > summary .details-chevron {
    width: 11px;
    height: 11px;
}

body.app-page #upload-section,
body.app-page #detail-section {
    min-height: 0;
    overflow: hidden;
}

/* ==========================================
   アプリ画面 詳細セクション 左右2分割レイアウト
   - 左: ファイル名 + 単一画像カード（固定）
   - 右: 3セクションアコーディオン（独立スクロール）
   ========================================== */

#detail-section {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr;
    gap: 24px;
    align-items: stretch;
    height: 100%;
    min-height: 0;
}

/* HTML標準の hidden 属性を display:grid より優先 */
#detail-section[hidden] {
    display: none;
}

.detail-left {
    display: flex;
    flex-direction: column;
    gap: 12px;
    height: 100%;
    min-height: 0;
    overflow: hidden;
}

.detail-right {
    display: flex;
    flex-direction: column;
    gap: 12px;
    height: 100%;
    min-width: 0;
    min-height: 0;
    overflow: visible;
}

/* === 画像表示カード（単一） === */
.image-display-card {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    border: 1px solid var(--border-subtle);
    border-radius: 10px;
    background: var(--bg-panel);
    overflow: hidden;
}

.image-display-card .panel-header {
    flex: 0 0 auto;
    padding: 8px 12px;
    border-bottom: 1px solid var(--border-subtle);
    background: var(--bg-surface);
}

.image-display-card .panel-header h3 {
    margin: 0;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
    display: inline-flex;
    align-items: center;
    gap: 10px;
}

.image-display-card .image-display-area {
    flex: 1 1 auto;
    min-height: 0;
    padding: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-primary);
}

.image-display-card .image-display-area img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    display: block;
}

/* === 比較ボタン === */
.compare-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 10px;
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--accent);
    background: var(--accent-a06);
    border: 1px solid var(--accent-a40);
    border-radius: 999px;
    cursor: pointer;
    font-family: inherit;
    transition: background 0.15s, border-color 0.15s;
}

.compare-btn:hover {
    background: var(--accent-a08);
    border-color: var(--accent);
}

.compare-btn[hidden] {
    display: none;
}

.compare-btn svg {
    flex-shrink: 0;
}

/* === 比較モーダル === */
.compare-modal {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.compare-modal[hidden] {
    display: none;
}

.compare-modal-content {
    width: 90vw;
    max-width: 1400px;
    height: 80vh;
    background: var(--bg-panel);
    border: 1px solid var(--border-primary);
    border-radius: 14px;
    box-shadow: 0 24px 48px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.compare-modal-header {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 18px;
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border-subtle);
}

.compare-modal-title {
    margin: 0;
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-heading);
}

.compare-modal-header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.compare-modal-close {
    width: 30px;
    height: 30px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 16px;
    cursor: pointer;
    border-radius: 8px;
    transition: background 0.15s, color 0.15s;
}

.compare-modal-close:hover {
    background: var(--bg-surface-hover);
    color: var(--text-primary);
}

.compare-modal-body {
    flex: 1 1 auto;
    min-height: 0;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    padding: 18px;
}

.compare-modal-footer {
    flex: 0 0 auto;
    padding: 12px 18px 16px;
    border-top: 1px solid var(--border-subtle);
    background: var(--bg-surface);
}

.compare-warning {
    margin: 0;
    padding: 10px 14px;
    background: rgba(243, 156, 18, 0.08);
    border: 1px solid var(--color-warning);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 0.78rem;
    line-height: 1.55;
}

.compare-warning-title {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 6px;
    font-weight: 700;
    color: var(--color-warning);
}

.compare-warning-list {
    margin: 0;
    padding-left: 18px;
    color: var(--text-secondary);
}

.compare-warning-list li {
    margin-bottom: 2px;
}

.compare-warning-list li:last-child {
    margin-bottom: 0;
}

.compare-figure {
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-height: 0;
}

.compare-figure-caption {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    letter-spacing: 0.04em;
    text-align: center;
}

.compare-figure-img {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px;
    background: var(--bg-primary);
    border: 1px solid var(--border-subtle);
    border-radius: 10px;
    overflow: hidden;
}

.compare-figure-img img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    display: block;
}

/* === アコーディオン === */
.detail-accordion {
    border: 1px solid var(--border-subtle);
    border-radius: 10px;
    background: var(--bg-panel);
    overflow: hidden;
}

.detail-accordion[open] {
    border-color: var(--accent-a30);
}

.detail-accordion-summary {
    list-style: none;
    cursor: pointer;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
    background: var(--bg-surface);
    transition: background 0.15s;
}

.detail-accordion-summary::-webkit-details-marker {
    display: none;
}

.detail-accordion-summary:hover {
    background: var(--accent-a06);
}

.detail-accordion[open] .detail-accordion-summary {
    border-bottom: 1px solid var(--border-subtle);
}

.detail-accordion .acc-num {
    color: var(--accent);
    font-weight: 800;
    font-size: 1rem;
}

.detail-accordion .acc-title {
    flex: 0 0 auto;
    white-space: nowrap;
}

/* summary 内 簡易説明 (タイトルと実行ボタンの間) */
.detail-accordion .acc-summary-desc {
    flex: 1 1 auto;
    min-width: 0;
    margin: 0 8px;
    font-size: 0.78rem;
    font-weight: 400;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* summary 内 アクションボタン (アコーディオンを開かなくても実行可能) */
.detail-accordion .acc-action-btn {
    padding: 4px 14px;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--accent-on);
    background: var(--accent);
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.2s, opacity 0.2s;
    font-family: inherit;
    line-height: 1.4;
    white-space: nowrap;
}

.detail-accordion .acc-action-btn:hover:not(:disabled) {
    background: var(--accent-hover);
}

.detail-accordion .acc-action-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* 処理ステータス + 経過タイマーバッジ (アクションボタンの左隣) */
.detail-accordion .acc-status {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    font-size: 0.72rem;
    font-weight: 700;
    border-radius: 999px;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
    color: var(--color-success, #16a34a);
    background: rgba(22, 163, 74, 0.10);
    border: 1px solid rgba(22, 163, 74, 0.30);
}
.detail-accordion .acc-status::before {
    content: "✓";
    font-weight: 800;
}
/* 処理中: アクセント色 + スピナー */
.detail-accordion .acc-status.is-processing {
    color: var(--accent, #2563eb);
    background: var(--accent-a08, rgba(37, 99, 235, 0.08));
    border-color: var(--accent-a25, rgba(37, 99, 235, 0.25));
}
.detail-accordion .acc-status.is-processing::before {
    content: "";
    display: inline-block;
    width: 10px;
    height: 10px;
    border: 2px solid currentColor;
    border-top-color: transparent;
    border-radius: 50%;
    animation: acc-status-spin 0.7s linear infinite;
}
/* 警告: 150s 超で赤化 */
.detail-accordion .acc-status.is-warning {
    color: var(--color-error, #dc2626);
    background: rgba(220, 38, 38, 0.10);
    border-color: rgba(220, 38, 38, 0.30);
}
.detail-accordion .acc-status.is-warning::before {
    border-color: currentColor;
    border-top-color: transparent;
}
.detail-accordion .acc-status-note {
    margin-left: 6px;
    font-size: 0.70rem;
    font-weight: 600;
    color: var(--color-error, #dc2626);
    white-space: nowrap;
}
@keyframes acc-status-spin {
    to { transform: rotate(360deg); }
}

.detail-accordion .acc-chevron {
    color: var(--text-muted);
    transition: transform 0.2s;
}

.detail-accordion[open] .acc-chevron {
    transform: rotate(180deg);
}

.detail-accordion-body {
    padding: 14px 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    /* JS で max-height と overflow-y を動的設定 */
}

.detail-accordion .acc-desc {
    margin: 0;
    font-size: 0.8rem;
    color: var(--text-muted);
    line-height: 1.5;
}

/* アコーディオン内 ヒントボックス (情報・使い方) */
.detail-accordion .acc-hint {
    margin: 0;
    padding: 10px 14px;
    background: var(--accent-a06);
    border: 1px solid var(--accent);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 0.78rem;
    line-height: 1.55;
}

.detail-accordion .acc-hint-title {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 6px;
    font-weight: 700;
    color: var(--accent);
}

.detail-accordion .acc-hint-list {
    margin: 0;
    padding-left: 18px;
    color: var(--text-secondary);
}

.detail-accordion .acc-hint-list li {
    margin-bottom: 3px;
}

.detail-accordion .acc-hint-list li:last-child {
    margin-bottom: 0;
}

.detail-accordion .acc-hint-list strong {
    color: var(--text-primary);
    font-weight: 700;
}

/* アコーディオン内 警告ボックス */
.detail-accordion .acc-warning {
    margin: 0;
    padding: 10px 14px;
    background: rgba(243, 156, 18, 0.08);
    border: 1px solid var(--color-warning);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 0.78rem;
    line-height: 1.55;
}

.detail-accordion .acc-warning-title {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 6px;
    font-weight: 700;
    color: var(--color-warning);
}

.detail-accordion .acc-warning-list {
    margin: 0;
    padding-left: 18px;
    color: var(--text-secondary);
}

.detail-accordion .acc-warning-list li {
    margin-bottom: 2px;
}

.detail-accordion .acc-warning-list li:last-child {
    margin-bottom: 0;
}

