/* REV v95: 一覧のエクスポートをモーダル化し、画面に収まる時だけ左ペインを追従固定する。 */
/* REV v89: 管理者の共通設定を使い、OS/閲覧者ごとのテーマ指定は採用しない。 */
:root {
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color-scheme: light;
    --bg: #f4f4f2;
    --panel: #ffffff;
    --panel-subtle: #f8f8f6;
    --text: #181818;
    --muted: #686868;
    --line: #d8d8d4;
    --accent: #202020;
    --accent-text: #ffffff;
    --danger: #8f1f1f;
    --danger-hover: #fff4f2;
    --ok: #246b37;
    --ok-button: #246b37;
    --ok-button-text: #ffffff;
    --provider-enabled: #217a3c;
    --provider-disabled: #8a6b1f;
    --shadow: 0 10px 32px rgba(0, 0, 0, .07);
}

:root[data-theme="dark"] {
    color-scheme: dark;
    --bg: #171717;
    --panel: #242424;
    --panel-subtle: #303030;
    --text: #f1f1f1;
    --muted: #bcbcbc;
    --line: #484848;
    --accent: #f1f1f1;
    --accent-text: #171717;
    --danger: #ff9b9b;
    --danger-hover: #4b2b2b;
    --ok: #9ad7aa;
    --ok-button: #247545;
    --ok-button-text: #ffffff;
    --provider-enabled: #9ad7aa;
    --provider-disabled: #eed089;
    --shadow: 0 10px 32px rgba(0, 0, 0, .25);
}

* { box-sizing: border-box; }
body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
}
button, input { font: inherit; }
button { cursor: pointer; }

.page-shell {
    width: min(920px, 100%);
    margin: 0 auto;
    padding: 24px 16px 64px;
}

.app-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    margin-bottom: 20px;
}
.app-header h1 {
    margin: 0;
    font-size: clamp(1.65rem, 4vw, 2.2rem);
    letter-spacing: -.02em;
}
.app-header p {
    margin: 4px 0 0;
    color: var(--muted);
}

.search-panel,
.record-card,
.candidates {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 7px;
    box-shadow: var(--shadow);
}
.search-panel { padding: 16px; }
.search-panel label {
    display: block;
    margin-bottom: 8px;
    font-size: .9rem;
    font-weight: 700;
}
.search-row {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 10px;
}
.search-row input {
    width: 100%;
    min-width: 0;
    border: 1px solid var(--line);
    border-radius: 5px;
    padding: 13px 14px;
    background: var(--panel-subtle);
    color: var(--text);
    outline: none;
}
.search-row input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 15%, transparent);
}
.search-option {
    display: inline-flex !important;
    align-items: center;
    gap: 7px;
    margin: 10px 0 0 !important;
    font-size: .88rem !important;
    font-weight: 600 !important;
    color: var(--muted);
    cursor: pointer;
    user-select: none;
}
.search-option input {
    width: 18px;
    height: 18px;
    margin: 0;
    accent-color: var(--accent);
}

.search-row button,
.action-button,
.candidate-button {
    border: 1px solid var(--accent);
    border-radius: 5px;
    padding: 11px 16px;
    background: var(--accent);
    color: var(--accent-text);
    font-weight: 700;
}
button:disabled { opacity: .55; cursor: wait; }

.message {
    margin-top: 14px;
    border-radius: 7px;
    padding: 12px 14px;
    background: var(--panel-subtle);
    border: 1px solid var(--line);
    color: var(--muted);
}
.message.error { color: var(--danger); }
.message.ok { color: var(--ok); }

.candidates {
    margin-top: 16px;
    padding: 16px;
}
.candidates h2 { margin: 0 0 6px; font-size: 1.05rem; }
.candidates > p { margin: 0 0 14px; color: var(--muted); }
.candidate-list { display: grid; gap: 10px; }
.candidate {
    display: grid;
    grid-template-columns: 64px 1fr auto;
    gap: 12px;
    align-items: center;
    border: 1px solid var(--line);
    border-radius: 7px;
    padding: 10px;
    background: var(--panel-subtle);
}
.candidate img,
.candidate-placeholder {
    width: 64px;
    height: 64px;
    object-fit: cover;
    border-radius: 5px;
    background: color-mix(in srgb, var(--line) 60%, transparent);
}
.candidate-title { font-weight: 800; }
.candidate-artist { margin-top: 2px; }
.candidate-meta { margin-top: 4px; font-size: .82rem; color: var(--muted); line-height: 1.35; }
.candidate-button { white-space: nowrap; }
.candidate-button.current-selection { cursor: default; opacity: .72; }

.record-card {
    margin-top: 16px;
    overflow: hidden;
}
.record-main {
    display: grid;
    grid-template-columns: minmax(180px, 260px) 1fr;
    gap: 22px;
    padding: 20px;
}
.cover-wrap {
    width: 100%;
    aspect-ratio: 1 / 1;
    border-radius: 7px;
    overflow: hidden;
    background: var(--panel-subtle);
    border: 1px solid var(--line);
}
.cover-wrap img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.cover-empty {
    display: grid;
    place-items: center;
    height: 100%;
    color: var(--muted);
    font-weight: 700;
}
.record-title {
    margin: 0;
    font-size: clamp(1.45rem, 4vw, 2rem);
    line-height: 1.15;
}
.record-artist {
    margin: 6px 0 0;
    font-size: 1.05rem;
    color: var(--muted);
}
.record-artist-original {
    margin: 2px 0 18px;
    font-size: .9rem;
    color: var(--muted);
    opacity: .82;
}
.record-artist + .meta-grid {
    margin-top: 18px;
}
.record-artist-original + .meta-grid {
    margin-top: 0;
}
.meta-grid {
    display: grid;
    grid-template-columns: 308px minmax(0, 1fr);
    column-gap: 14px;
    row-gap: 8px;
    margin: 0;
}
.meta-grid dt { color: var(--muted); }
.meta-grid dd { margin: 0; word-break: break-word; }
.record-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    margin-top: 20px;
}
.owned-label {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    min-height: 44px;
    padding: 0 10px;
    border-radius: 5px;
    border: 1px solid var(--line);
    background: var(--panel-subtle);
    font-weight: 800;
}
.owned-label input { width: 20px; height: 20px; }
.secondary-button {
    background: transparent;
    color: var(--text);
    border-color: var(--line);
}
.source-link {
    color: inherit;
    text-decoration: underline;
    text-underline-offset: 3px;
}

.track-section {
    border-top: 1px solid var(--line);
    padding: 18px 20px 22px;
}
.track-section h2 { margin: 0 0 12px; font-size: 1.05rem; }
.track-list { margin: 0; padding: 0; list-style: none; }
.track {
    display: grid;
    grid-template-columns: 5.1rem minmax(0, 1fr) auto;
    gap: 10px;
    padding: 8px 0;
    border-top: 1px solid color-mix(in srgb, var(--line) 70%, transparent);
    align-items: baseline;
}
.track:first-child { border-top: 0; }
.track-pos, .track-duration { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.track-title { min-width: 0; }
.track-artist { display: block; margin-top: 2px; color: var(--muted); font-size: .85rem; }
.track-heading {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
    padding: 8px 10px;
    margin-top: 4px;
    border-top: 1px solid var(--line);
    background: color-mix(in srgb, var(--line) 35%, transparent);
    align-items: baseline;
    font-weight: 700;
}
.track-heading:first-child { margin-top: 0; }
.track-heading-title { min-width: 0; }
.empty-tracks { color: var(--muted); }

@media (max-width: 650px) {
    .page-shell { padding: 18px 12px 48px; }
    .search-row { grid-template-columns: 1fr; }
    .search-row button { min-height: 46px; }
    .record-main { grid-template-columns: 1fr; padding: 16px; }
    .cover-wrap { width: min(78vw, 360px); justify-self: center; }
    .candidate { grid-template-columns: 54px 1fr; }
    .candidate img, .candidate-placeholder { width: 54px; height: 54px; }
    .candidate-button { grid-column: 1 / -1; width: 100%; }
    .meta-grid { grid-template-columns: 7rem minmax(0, 1fr); font-size: .94rem; }
    .record-actions { align-items: stretch; }
    .record-actions > * { flex: 1 1 auto; justify-content: center; text-align: center; }
    .track-section { padding: 16px; }
    .track { grid-template-columns: 4.9rem minmax(0, 1fr) auto; gap: 7px; font-size: .94rem; }
}


.provider-status {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.45rem;
    margin: -0.25rem 0 1rem;
    color: var(--muted);
    font-size: 0.82rem;
}

.provider-status-label {
    margin-right: 0.1rem;
}

.provider-chip {
    display: inline-flex;
    align-items: center;
    min-height: 1.7rem;
    padding: 0.15rem 0.55rem;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--panel);
}

.provider-chip.enabled::before,
.provider-chip.disabled::before {
    content: '';
    width: 0.5rem;
    height: 0.5rem;
    margin-right: 0.35rem;
    border-radius: 50%;
    background: currentColor;
}

.provider-chip.enabled {
    color: var(--provider-enabled);
}

.provider-chip.disabled {
    color: var(--provider-disabled);
}

/* 画面右上の共通オーバーレイメニュー */
.floating-menu-button {
    position: fixed;
    z-index: 1001;
    top: max(14px, env(safe-area-inset-top));
    right: max(14px, env(safe-area-inset-right));
    width: 48px;
    height: 48px;
    display: grid;
    place-items: center;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: var(--panel);
    color: var(--text);
    box-shadow: var(--shadow);
    font-size: 1.45rem;
    line-height: 1;
}
.floating-menu-button.open { background: var(--panel-subtle); }
.floating-menu {
    position: fixed;
    z-index: 1000;
    top: calc(max(14px, env(safe-area-inset-top)) + 56px);
    right: max(14px, env(safe-area-inset-right));
    min-width: 180px;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: var(--panel);
    box-shadow: var(--shadow);
}
.floating-menu a {
    display: block;
    padding: 13px 16px;
    color: var(--text);
    text-decoration: none;
    border-top: 1px solid var(--line);
}
.floating-menu a:first-child { border-top: 0; }
.floating-menu a:hover,
.floating-menu a[aria-current="page"] { background: var(--panel-subtle); }

/* 所持リスト */
.list-page-shell { width: min(1180px, 100%); }
.list-header { padding-right: 64px; }
.list-filters {
    display: grid;
    grid-template-columns: 110px minmax(150px, 1fr) minmax(180px, 1fr) auto;
    gap: 10px;
    align-items: end;
    margin-bottom: 18px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: var(--panel);
    box-shadow: var(--shadow);
}
.list-filters label { display: grid; gap: 6px; }
.list-filters label > span { font-size: .82rem; font-weight: 700; color: var(--muted); }
.list-filters input {
    width: 100%;
    min-width: 0;
    border: 1px solid var(--line);
    border-radius: 5px;
    padding: 10px 11px;
    background: var(--panel-subtle);
    color: var(--text);
    outline: none;
}
.list-filters input:focus { border-color: var(--accent); }
.list-filter-actions { display: flex; gap: 8px; }
.list-filter-actions .action-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    text-decoration: none;
    white-space: nowrap;
}
.catalog-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
    gap: 16px;
}
.catalog-tile {
    min-width: 0;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: var(--panel);
    box-shadow: var(--shadow);
    color: var(--text);
    text-decoration: none;
    transition: transform .12s ease, box-shadow .12s ease;
}
.catalog-tile:hover { transform: translateY(-2px); }
.tile-cover {
    position: relative;
    aspect-ratio: 1 / 1;
    overflow: hidden;
    background: var(--panel-subtle);
    border-bottom: 1px solid var(--line);
}
.tile-cover img {
    position: relative;
    z-index: 2;
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.tile-cover-empty {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    color: var(--muted);
    font-weight: 700;
    font-size: .85rem;
}
.tile-info { padding: 12px; }
.tile-title {
    font-weight: 800;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    overflow: hidden;
}
.tile-artist {
    margin-top: 5px;
    color: var(--muted);
    font-size: .92rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.tile-artist-original {
    margin-top: 2px;
    color: var(--muted);
    opacity: .8;
    font-size: .78rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.tile-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 5px 9px;
    margin-top: 8px;
    color: var(--muted);
    font-size: .78rem;
}

@media (max-width: 720px) {
    .list-filters { grid-template-columns: 1fr 1fr; }
    .list-filters label:last-of-type { grid-column: 1 / -1; }
    .list-filter-actions { grid-column: 1 / -1; }
    .list-filter-actions > * { flex: 1 1 0; }
    .catalog-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
    .tile-info { padding: 10px; }
}

@media (max-width: 390px) {
    .catalog-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
    .tile-title { font-size: .92rem; }
    .tile-artist { font-size: .82rem; }
}

@media (max-width: 650px) {
    .app-header { padding-right: 62px; }
}

.app-version {
    display: inline-block;
    margin-left: .35em;
    padding: .16em .48em;
    border: 1px solid var(--line);
    border-radius: 999px;
    color: var(--muted);
    font-size: .38em;
    font-weight: 700;
    vertical-align: middle;
    letter-spacing: .02em;
}

.list-load-status {
    min-height: 48px;
    margin: 16px 0 4px;
    display: grid;
    place-items: center;
    color: var(--muted);
    font-size: .88rem;
    text-align: center;
}
.list-load-status.loading { opacity: .8; }
.list-load-status.retry {
    cursor: pointer;
    text-decoration: underline;
    text-underline-offset: 3px;
}


/* Discogsの英語/日本語併記を分離した時の元タイトル */
.record-title-original,
.candidate-title-original,
.tile-title-original {
    margin-top: 0.15rem;
    color: var(--muted);
    font-size: 0.92em;
    line-height: 1.35;
}

.candidate-artist-original {
    color: var(--muted);
    font-size: 0.9em;
    line-height: 1.35;
}

/* rev v19: 所持リスト抽出とアートワーク作成 */
.list-filters {
    grid-template-columns: minmax(180px, 1fr) minmax(180px, 1fr) 110px auto;
}

.artwork-panel {
    margin: 0 0 18px;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: var(--panel);
    box-shadow: var(--shadow);
    overflow: hidden;
}
.artwork-panel > summary {
    cursor: pointer;
    padding: 13px 15px;
    font-weight: 800;
    user-select: none;
}
.artwork-panel[open] > summary {
    border-bottom: 1px solid var(--line);
}
.artwork-panel-body {
    padding: 14px;
}
.artwork-controls {
    display: grid;
    grid-template-columns: 110px 110px minmax(170px, 1fr) 110px auto;
    gap: 10px;
    align-items: end;
}
.artwork-controls label {
    display: grid;
    gap: 6px;
}
.artwork-controls label > span {
    color: var(--muted);
    font-size: .82rem;
    font-weight: 700;
}
.artwork-controls input[type="number"],
.artwork-controls select {
    width: 100%;
    min-height: 42px;
    border: 1px solid var(--line);
    border-radius: 5px;
    padding: 8px 10px;
    background: var(--panel-subtle);
    color: var(--text);
}
.artwork-controls input[type="color"] {
    width: 100%;
    min-height: 42px;
    padding: 3px;
    border: 1px solid var(--line);
    border-radius: 5px;
    background: var(--panel-subtle);
}
.artwork-controls .action-button {
    min-height: 42px;
}
.artwork-help {
    margin: 10px 0 0;
    color: var(--muted);
    font-size: .82rem;
}
.artwork-status {
    min-height: 1.4em;
    margin-top: 8px;
    color: var(--muted);
    font-size: .84rem;
}
.artwork-status.error {
    color: var(--danger);
}

@media (max-width: 720px) {
    .list-filters {
        grid-template-columns: 1fr 1fr;
    }
    .list-filters label:nth-of-type(3) {
        grid-column: 1 / -1;
    }
    .artwork-controls {
        grid-template-columns: 1fr 1fr;
    }
    .artwork-controls .action-button {
        grid-column: 1 / -1;
    }
}


/* 外部APIなどのアプリ設定画面 */
.settings-page-shell { width: min(820px, 100%); }
.settings-header { padding-right: 64px; }
.settings-form {
    display: grid;
    gap: 16px;
    margin-top: 18px;
}
.settings-section {
    padding: 18px;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: var(--panel);
    box-shadow: var(--shadow);
}
.settings-section h2 {
    margin: 0 0 16px;
    font-size: 1.05rem;
}
.settings-field {
    display: grid;
    gap: 7px;
}
.settings-field + .settings-field { margin-top: 18px; }
.settings-field > span {
    font-size: .9rem;
    font-weight: 700;
}
.settings-field input,
.settings-field select {
    width: 100%;
    box-sizing: border-box;
    border: 1px solid var(--line);
    border-radius: 5px;
    padding: 11px 12px;
    background: var(--panel-subtle);
    color: var(--text);
    outline: none;
}
.settings-field input:focus,
.settings-field select:focus { border-color: var(--accent); }
.settings-field-small { max-width: 220px; }
.settings-help {
    margin: 7px 0 0;
    color: var(--muted);
    font-size: .84rem;
    line-height: 1.5;
}
.settings-links {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 14px;
    margin-top: 9px;
    font-size: .84rem;
}
.settings-links a {
    color: var(--accent);
    font-weight: 700;
    text-decoration: underline;
    text-underline-offset: 2px;
}
.settings-check {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 12px;
    font-size: .9rem;
}
.settings-check input { width: 18px; height: 18px; }
.settings-actions { display: flex; justify-content: flex-end; }

/* rev v24: destructive action is visually distinct. */
.danger-button { border-color: var(--danger); color: var(--danger); background: var(--panel); }
.danger-button:hover:not(:disabled) { background: var(--danger-hover); }

/* rev v25: keep multi-disc positions such as CD-2-10 on one line. */

/* JSON登録 */
.json-import-page-shell {
    width: min(980px, 100%);
}
.ai-instruction-panel,
.json-import-panel,
.json-preview {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 7px;
    box-shadow: var(--shadow);
}
.ai-instruction-panel {
    margin-bottom: 16px;
    overflow: hidden;
}
.ai-instruction-panel > summary {
    padding: 15px 16px;
    cursor: pointer;
    font-weight: 800;
    user-select: none;
}
.ai-instruction-body {
    padding: 0 16px 16px;
}
.ai-instruction-body p {
    margin: 0 0 10px;
    color: var(--muted);
}
.json-import-panel {
    padding: 16px;
}
.json-import-panel h2 {
    margin: 0 0 12px;
    font-size: 1.08rem;
}
.json-textarea {
    display: block;
    width: 100%;
    min-height: 290px;
    resize: vertical;
    border: 1px solid var(--line);
    border-radius: 5px;
    padding: 12px 14px;
    background: var(--panel-subtle);
    color: var(--text);
    font: 0.92rem/1.55 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    tab-size: 2;
}
.json-textarea:focus {
    border-color: var(--accent);
    outline: none;
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 15%, transparent);
}
.instruction-textarea {
    min-height: 420px;
    margin-bottom: 10px;
}
.json-import-actions,
.json-preview-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 12px;
}
.file-button {
    position: relative;
    overflow: hidden;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}
.file-button input {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
}
.json-preview {
    margin-top: 16px;
    overflow: hidden;
}
.json-preview-main {
    display: grid;
    grid-template-columns: minmax(160px, 240px) 1fr;
    gap: 22px;
    padding: 20px;
}
.json-preview-cover {
    width: 100%;
    aspect-ratio: 1 / 1;
    border: 1px solid var(--line);
    border-radius: 7px;
    overflow: hidden;
    background: var(--panel-subtle);
}
.json-preview-cover img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
}
.json-duplicate-warning {
    margin: 0 20px 16px;
    padding: 12px 14px;
    border: 1px solid color-mix(in srgb, var(--danger) 45%, var(--line));
    border-radius: 7px;
    color: var(--danger);
    background: color-mix(in srgb, var(--danger) 7%, var(--panel));
}
.json-duplicate-warning strong {
    display: block;
    margin-bottom: 4px;
}
.json-preview-tracks {
    border-top: 1px solid var(--line);
}
.json-preview-actions {
    padding: 0 20px 20px;
}

@media (max-width: 640px) {
    .json-preview-main {
        grid-template-columns: 1fr;
    }
    .json-preview-cover {
        width: min(320px, 100%);
    }
    .instruction-textarea {
        min-height: 340px;
    }
}

/* rev v34: 所持リスト4条件 / ログイン */
.list-filters {
    grid-template-columns: minmax(160px, 1fr) minmax(160px, 1fr) minmax(120px, .75fr) 100px auto;
}
.login-page-shell {
    width: min(560px, 100%);
}
.login-form {
    margin-top: 18px;
}

@media (max-width: 720px) {
    .list-filters {
        grid-template-columns: 1fr 1fr;
    }
    .list-filters label:nth-of-type(3),
    .list-filters label:last-of-type {
        grid-column: auto;
    }
    .list-filter-actions {
        grid-column: 1 / -1;
    }
}

/* rev v34: 所持リストでは複雑なFormat文字列から代表メディア種別を1つだけ表示する。 */
.tile-format-badge {
    position: absolute;
    z-index: 4;
    top: 9px;
    left: 9px;
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    padding: 4px 9px;
    border: 1px solid rgba(255, 255, 255, .35);
    border-radius: 999px;
    background: rgba(18, 18, 18, .82);
    color: #fff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, .22);
    font-size: .76rem;
    font-weight: 800;
    line-height: 1;
    letter-spacing: .02em;
    pointer-events: none;
}

@media (max-width: 390px) {
    .tile-format-badge {
        top: 7px;
        left: 7px;
        min-height: 25px;
        padding: 3px 7px;
        font-size: .68rem;
    }
}

/* rev v34: 登録済みメディアの基本情報を詳細画面から手動編集する。 */
.record-edit-panel {
    border-top: 1px solid var(--line);
    padding: 18px 20px 20px;
    background: var(--panel-subtle);
}
.record-edit-panel h2 {
    margin: 0 0 14px;
    font-size: 1.05rem;
}
.record-edit-form {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px 14px;
}
.record-edit-field {
    display: grid;
    gap: 6px;
    min-width: 0;
}
.record-edit-field > span {
    font-size: .82rem;
    font-weight: 700;
    color: var(--muted);
}
.record-edit-field input {
    width: 100%;
    min-width: 0;
    border: 1px solid var(--line);
    border-radius: 5px;
    padding: 10px 11px;
    background: var(--panel);
    color: var(--text);
    outline: none;
}
.record-edit-field input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 15%, transparent);
}
.record-edit-actions {
    grid-column: 1 / -1;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 2px;
}
@media (max-width: 650px) {
    .record-edit-panel { padding: 16px; }
    .record-edit-form { grid-template-columns: 1fr; }
    .record-edit-actions { grid-column: 1; }
    .record-edit-actions .action-button { flex: 1 1 auto; }
}

/* rev v35: 所持リストのエクスポート */
.export-panel-body {
    display: grid;
    gap: 18px;
}
.export-section + .export-section {
    padding-top: 16px;
    border-top: 1px solid var(--line);
}
.export-section h2 {
    margin: 0 0 12px;
    font-size: 1rem;
}
.export-data-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}
.export-data-actions .action-button {
    text-decoration: none;
}

/* rev v43: プレイURL */
.play-button,
.tile-play-button {
    text-decoration: none;
}
.record-play-button {
    margin-left: auto;
    background: var(--ok-button);
    border-color: var(--ok-button);
    color: var(--ok-button-text);
}
.catalog-tile-wrap {
    position: relative;
    min-width: 0;
}
.catalog-tile {
    display: block;
    height: 100%;
}
.catalog-tile-wrap.has-play .tile-info {
    padding-bottom: 56px;
}
.tile-play-button {
    position: absolute;
    right: 10px;
    bottom: 10px;
    z-index: 5;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 36px;
    padding: 7px 11px;
    border: 1px solid var(--accent);
    border-radius: 999px;
    background: var(--accent);
    color: var(--accent-text);
    font-size: .78rem;
    font-weight: 800;
    line-height: 1;
    box-shadow: 0 4px 14px rgba(0, 0, 0, .16);
}
.tile-play-button:hover {
    filter: brightness(1.08);
}
@media (max-width: 650px) {
    .record-play-button {
        margin-left: 0;
    }
    .tile-play-button {
        right: 8px;
        bottom: 8px;
        min-height: 34px;
        padding: 7px 10px;
    }
}

/* rev v48: media category + owned-list sorting */
.registration-category-label {
    display: block;
    margin-bottom: 6px;
    font-size: .82rem;
    font-weight: 700;
    color: var(--muted);
}
.registration-category-select {
    width: min(220px, 100%);
    min-height: 44px;
    margin-bottom: 14px;
    border: 1px solid var(--line);
    border-radius: 5px;
    padding: 9px 11px;
    background: var(--panel-subtle);
    color: var(--text);
    outline: none;
}
.registration-category-select:focus { border-color: var(--accent); }

.list-filters {
    grid-template-columns: 110px 130px minmax(150px, 1fr) minmax(150px, 1fr) minmax(115px, .7fr) 95px auto;
}
.list-filters select,
.record-edit-field select {
    width: 100%;
    min-width: 0;
    min-height: 42px;
    border: 1px solid var(--line);
    border-radius: 5px;
    padding: 8px 10px;
    background: var(--panel-subtle);
    color: var(--text);
    outline: none;
}
.list-filters select:focus,
.record-edit-field select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 15%, transparent);
}

@media (max-width: 980px) {
    .list-filters {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
    .list-filter-actions { grid-column: 1 / -1; }
}

@media (max-width: 720px) {
    .list-filters {
        grid-template-columns: 1fr 1fr;
    }
    .list-filters label:nth-of-type(n) { grid-column: auto; }
    .list-filter-actions { grid-column: 1 / -1; }
}


/* rev v48: 楽天バックエンド許可IP確認 */
.settings-ip-list { display: grid; gap: 10px; }
.settings-ip-row { display: grid; grid-template-columns: minmax(170px, 220px) minmax(0, 1fr); align-items: center; gap: 12px; }
.settings-ip-row > span { color: var(--muted); font-weight: 600; }
.settings-ip-value { display: block; min-width: 0; padding: 9px 11px; border: 1px solid var(--line); border-radius: 5px; background: var(--panel-subtle); color: var(--text); overflow-wrap: anywhere; }
.settings-inline-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; margin-top: 14px; }
@media (max-width: 560px) { .settings-ip-row { grid-template-columns: 1fr; gap: 5px; } }

/* ゲームカテゴリだけで表示する機種選択欄の余白を登録フォームに合わせる。 */
.game-platform-field {
    margin: 0;
}

.game-platform-field[hidden] {
    display: none;
}


/* rev v54: 基本表示条件をさらに詰め、抽出条件の右端余白を均等にする。 */
.list-filters {
    display: grid;
    grid-template-columns: 308px minmax(0, 1fr);
    gap: 10px;
    align-items: stretch;
    margin-bottom: 18px;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
}
.list-filter-section {
    padding: 12px 14px 14px;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: var(--panel);
    box-shadow: var(--shadow);
}
.list-view-controls {
    border-color: color-mix(in srgb, var(--accent) 28%, var(--line));
    background: color-mix(in srgb, var(--accent) 5%, var(--panel));
}
.list-filter-section-title {
    margin-bottom: 9px;
    color: var(--muted);
    font-size: .8rem;
    font-weight: 800;
    letter-spacing: .02em;
}
.list-view-controls .list-filter-section-title {
    color: var(--accent);
}
.list-view-controls-grid {
    display: grid;
    grid-template-columns: 120px 150px;
    gap: 8px;
    align-items: end;
}
.list-narrow-controls {
    min-width: 0;
}
.list-narrow-controls-grid {
    display: grid;
    min-width: 0;
    grid-template-columns: minmax(0, 1.2fr) minmax(0, 1.2fr) minmax(90px, .8fr) 90px max-content;
    gap: 8px;
    align-items: end;
}
.list-filters .list-filter-actions {
    grid-column: auto;
    justify-self: end;
}

/* 「その他」のゲーム機種は外部検索を使わずJSON登録へ案内する。 */
.game-json-only-note {
    margin: 0 0 14px;
    padding: 11px 13px;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: var(--panel-subtle);
    color: var(--muted);
    line-height: 1.55;
}
.game-json-only-note a {
    color: var(--accent);
    font-weight: 800;
}
.game-json-only-note[hidden] { display: none; }

@media (max-width: 980px) {
    .list-filters {
        grid-template-columns: 1fr;
    }
    .list-narrow-controls-grid {
        grid-template-columns: 1fr 1fr;
    }
    .list-narrow-controls-grid .list-filter-actions {
        grid-column: 1 / -1;
    }
}

@media (max-width: 520px) {
    .list-view-controls-grid,
    .list-narrow-controls-grid {
        grid-template-columns: 1fr;
    }
    .list-narrow-controls-grid .list-filter-actions {
        grid-column: 1;
    }
}

/* rev v60: 大容量バックアップは公開用ランダムURLからWebサーバーが直接配信する。 */
.backup-status-panel {
    margin-top: 18px;
    padding: 16px 18px;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: var(--panel);
    box-shadow: var(--shadow);
}
.backup-status-panel.is-error {
    border-color: color-mix(in srgb, var(--danger) 45%, var(--line));
}
.backup-status-panel.is-finished {
    border-color: color-mix(in srgb, var(--ok) 45%, var(--line));
}
.backup-status-summary {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
}
.backup-status-summary > div {
    min-width: 0;
    padding: 11px 12px;
    border-radius: 7px;
    background: var(--panel-subtle);
}
.backup-status-summary span,
.backup-status-summary strong {
    display: block;
}
.backup-status-summary span {
    margin-bottom: 4px;
    color: var(--muted);
    font-size: .78rem;
    font-weight: 700;
}
.backup-status-summary strong {
    font-size: 1rem;
    overflow-wrap: anywhere;
}
.backup-progress-area {
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid var(--line);
}
.backup-progress-heading,
.backup-progress-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}
.backup-progress-heading {
    margin-bottom: 8px;
}
.backup-progress-heading span,
.backup-progress-meta {
    color: var(--muted);
    font-size: .82rem;
}
.backup-progress-area progress {
    display: block;
    width: 100%;
    height: 14px;
    accent-color: var(--accent);
}
.backup-progress-meta {
    margin-top: 7px;
}
#backup-current-file {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-align: right;
}
.backup-capacity-note {
    margin-top: 12px;
}
.backup-download-actions {
    display: flex;
    justify-content: flex-end;
    margin-top: 12px;
}
.backup-download-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--accent);
    border-radius: 5px;
    padding: 10px 14px;
    background: var(--accent);
    color: var(--accent-text);
    font-weight: 700;
    text-decoration: none;
}
.backup-download-link[hidden] {
    display: none;
}

@media (max-width: 640px) {
    .backup-status-summary {
        grid-template-columns: 1fr;
    }
    .backup-progress-heading,
    .backup-progress-meta {
        align-items: flex-start;
        flex-direction: column;
        gap: 4px;
    }
    #backup-current-file {
        width: 100%;
        text-align: left;
    }
}

/* REV v83: 普段は検索1欄だけ。詳細条件は必要な時だけ開く。 */
.list-quick-search-row {
    display: flex;
    align-items: stretch;
    gap: 8px;
    min-width: 0;
}
.list-quick-search-field {
    flex: 1 1 auto;
    min-width: 0;
}
.list-quick-search-row input[type="search"] {
    height: 46px;
    border-radius: 5px;
}
.list-quick-search-row .list-filter-actions {
    display: flex;
    flex: 0 0 auto;
    gap: 8px;
}
.list-quick-search-row .action-button {
    min-height: 46px;
}
.list-advanced-filters {
    margin-top: 10px;
}
.list-advanced-filters > summary {
    display: inline-block;
    cursor: pointer;
    color: var(--muted);
    font-size: .85rem;
    font-weight: 700;
    user-select: none;
}
.list-advanced-filters > summary::before {
    content: '▸ ';
}
.list-advanced-filters[open] > summary::before {
    content: '▾ ';
}
.list-advanced-filters > .list-narrow-controls-grid {
    margin-top: 12px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
}
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}
@media (max-width: 520px) {
    .list-quick-search-row {
        gap: 5px;
    }
    .list-quick-search-row .list-filter-actions {
        grid-column: auto;
        gap: 5px;
    }
    .list-quick-search-row .action-button {
        flex: 0 0 auto;
        padding: 9px 10px;
        font-size: .87rem;
    }
    .list-quick-search-row input[type="search"] {
        padding: 10px 9px;
        font-size: 16px; /* iPhoneで入力時に自動ズームしない */
    }
    .list-advanced-filters > .list-narrow-controls-grid {
        grid-template-columns: 1fr;
    }
}

/* REV v89: PCでは左サイドバー＋右一覧の2ペインレイアウトにする。 */
.list-page-shell {
    width: min(1440px, 100%);
}
.list-browser {
    display: grid;
    grid-template-columns: 320px minmax(0, 1fr);
    gap: 18px;
    align-items: start;
}
.list-sidebar {
    min-width: 0;
}
.list-sidebar-form {
    display: grid;
    gap: 14px;
}
.list-sidebar-section {
    padding: 16px;
    border-radius: 7px;
}
.list-sidebar-section .list-filter-section-title,
.list-sidebar-export > summary {
    margin-bottom: 12px;
    color: var(--text);
    font-size: 1.02rem;
    font-weight: 800;
    letter-spacing: 0;
}
.list-sidebar-section .list-filter-section-title {
    display: flex;
    align-items: center;
    gap: 8px;
}
.sidebar-button-group {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
}
.sidebar-chip {
    width: 100%;
    min-height: 46px;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 5px;
    background: var(--panel-subtle);
    color: var(--text);
    font-weight: 800;
    text-align: left;
    transition: background .14s ease, border-color .14s ease, color .14s ease, transform .14s ease;
}
.sidebar-chip:hover {
    transform: translateY(-1px);
}
.sidebar-chip.is-active {
    border-color: color-mix(in srgb, var(--accent) 30%, var(--line));
    background: color-mix(in srgb, var(--accent) 8%, var(--panel));
    color: var(--accent);
}
:root[data-theme="dark"] .sidebar-chip.is-active {
    background: color-mix(in srgb, #4f8cff 28%, var(--panel));
    border-color: color-mix(in srgb, #7aa5ff 42%, var(--line));
    color: #ffffff;
}
.list-sidebar-search-row {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
}
.list-sidebar-search-actions {
    justify-content: stretch;
}
.list-sidebar-search-actions > * {
    flex: 1 1 0;
    justify-content: center;
}
.list-advanced-filters {
    margin-top: 12px;
}
.list-advanced-filters > summary {
    color: var(--muted);
}
.list-advanced-filters > .list-narrow-controls-grid {
    grid-template-columns: 1fr;
    gap: 10px;
}
.list-advanced-filters label,
.list-advanced-filters input {
    min-width: 0;
}
.list-sidebar-export {
    margin-top: 14px;
    background: var(--panel);
    border-radius: 7px;
    box-shadow: var(--shadow);
}
.list-sidebar-export > summary {
    padding: 16px;
}
.list-sidebar-export .artwork-panel-body {
    padding-top: 0;
}
.list-sidebar-export .export-section + .export-section {
    margin-top: 18px;
    padding-top: 16px;
    border-top: 1px solid var(--line);
}
.list-sidebar-export .artwork-controls {
    grid-template-columns: 1fr;
    gap: 10px;
}
.list-sidebar-export .export-data-actions {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
}
.list-main {
    min-width: 0;
}
.list-main-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 16px;
    padding: 16px 18px;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: var(--panel);
    box-shadow: var(--shadow);
}
.list-main-head h2 {
    margin: 0;
    font-size: clamp(1.35rem, 2.7vw, 1.9rem);
}
.list-main-head p {
    margin: 5px 0 0;
    color: var(--muted);
}
.list-main .message {
    margin-top: 0;
    margin-bottom: 14px;
}
.list-main .catalog-grid {
    grid-template-columns: repeat(auto-fill, minmax(205px, 1fr));
}

/* REV v89: 長いエクスポート操作が画面下に隠れないよう、
   PCでも左ペインを固定せずページ全体を自然にスクロールさせる。 */

@media (max-width: 1080px) {
    .list-browser {
        grid-template-columns: 1fr;
    }
    .list-sidebar-export .artwork-controls {
        grid-template-columns: 1fr 1fr;
    }
    .list-sidebar-export .artwork-controls .action-button {
        grid-column: 1 / -1;
    }
    .list-sidebar-export .export-data-actions {
        grid-template-columns: 1fr 1fr;
    }
}

@media (max-width: 720px) {
    .sidebar-button-group {
        grid-template-columns: 1fr 1fr;
    }
    .list-main-head {
        padding: 14px 16px;
    }
    .list-main .catalog-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 520px) {
    .sidebar-button-group,
    .list-sidebar-export .artwork-controls,
    .list-sidebar-export .export-data-actions {
        grid-template-columns: 1fr;
    }
    .list-sidebar-search-actions {
        display: flex;
        gap: 8px;
    }
    .list-main .catalog-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}


/* REV v89: 一覧ヘッダを省き、左ペイン各セクションの開閉表示を統一する。 */
.list-page-shell {
    padding-top: 18px;
}
.list-sidebar-section > summary.list-filter-section-title,
.list-sidebar-export > summary {
    display: flex;
    align-items: center;
    gap: 9px;
    list-style: none;
    cursor: pointer;
    user-select: none;
}
.list-sidebar-section > summary.list-filter-section-title::-webkit-details-marker,
.list-sidebar-export > summary::-webkit-details-marker {
    display: none;
}
.list-sidebar-section > summary.list-filter-section-title::before,
.list-sidebar-export > summary::before {
    content: '▶';
    display: inline-block;
    flex: 0 0 auto;
    font-size: .72rem;
    transition: transform .12s ease;
}
.list-sidebar-section[open] > summary.list-filter-section-title::before,
.list-sidebar-export[open] > summary::before {
    transform: rotate(90deg);
}
.list-sidebar-section:not([open]) > summary.list-filter-section-title,
.list-sidebar-export:not([open]) > summary {
    margin-bottom: 0;
}
.list-sidebar-section > summary.list-filter-section-title:focus-visible,
.list-sidebar-export > summary:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 4px;
}
/* REV v89: 件数は左ペイン末尾。右のカード一覧に上余白を作らない。 */
.list-sidebar-count {
    display: flex;
    align-items: baseline;
    justify-content: flex-end;
    gap: 10px;
    margin: 12px 3px 0;
    color: var(--muted);
    font-size: .85rem;
    font-variant-numeric: tabular-nums;
}
.list-sidebar-count strong {
    color: var(--text);
    font-weight: 700;
}

/* VERSIONは操作ではないので、メニュー最下部に控えめな文字で表示する。 */
.floating-menu-version {
    padding: 11px 16px;
    border-top: 1px solid var(--line);
    color: var(--muted);
    font-size: .8rem;
    text-align: right;
    font-variant-numeric: tabular-nums;
}

/* 一覧画面の過度な角丸を抑え、角を少しだけ柔らかくする。 */
.list-page-shell .list-sidebar-section,
.list-page-shell .list-sidebar-export,
.list-page-shell .catalog-tile,
.list-page-shell .message {
    border-radius: 7px;
}
.list-page-shell .sidebar-chip,
.list-page-shell .action-button,
.list-page-shell .list-sidebar input,
.list-page-shell .list-sidebar select,
.list-page-shell .tile-play-button {
    border-radius: 5px;
}
.list-page-shell .list-quick-search-field,
.list-page-shell .list-quick-search-field input[type="search"] {
    display: block;
    width: 100%;
    min-width: 0;
}
.list-page-shell .list-quick-search-field input[type="search"] {
    padding: 10px 12px;
    border: 1px solid var(--line);
    background: var(--panel-subtle);
    color: var(--text);
    outline: none;
}
.list-page-shell .list-quick-search-field input[type="search"]:focus {
    border-color: var(--accent);
}
.list-page-shell .tile-format-badge {
    border-radius: 999px; /* 種別バッジの識別性は維持する。 */
}
.floating-menu-button,
.floating-menu {
    border-radius: 7px;
}

/* REV v95: 左ペインは画面内に収まるPCだけ追従。高さ不足ではJSが固定を外す。 */
@media (min-width: 1081px) {
    .list-page-shell .list-sidebar.is-sticky {
        position: sticky;
        top: 12px;
    }
}

/* エクスポートは左ペインを伸ばさず、管理者向けモーダルで操作する。 */
body.export-dialog-open {
    overflow: hidden;
}
.list-page-shell .list-export-button {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    min-height: 56px;
    margin-top: 14px;
    padding: 14px 16px;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: var(--panel);
    color: var(--text);
    box-shadow: var(--shadow);
    font-size: 1.02rem;
    font-weight: 800;
    text-align: left;
}
.list-export-button > span {
    font-size: 1.15rem;
    font-weight: 700;
    line-height: 1;
}
.list-export-button:hover {
    background: var(--panel-subtle);
}
.list-export-button:focus-visible,
.export-dialog-close:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}
.export-dialog {
    width: min(650px, calc(100% - 24px));
    max-width: 650px;
    max-height: calc(100vh - 28px);
    max-height: calc(100dvh - 28px);
    margin: auto;
    padding: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: var(--panel);
    color: var(--text);
    box-shadow: 0 20px 70px rgba(0, 0, 0, .42);
}
.export-dialog::backdrop {
    background: rgba(0, 0, 0, .68);
}
.export-dialog-heading {
    position: sticky;
    z-index: 1;
    top: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 18px;
    border-bottom: 1px solid var(--line);
    background: var(--panel);
}
.export-dialog-heading h2 {
    margin: 0;
    font-size: 1.08rem;
}
.export-dialog-close {
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    padding: 0;
    border: 1px solid var(--line);
    border-radius: 5px;
    background: var(--panel-subtle);
    color: var(--text);
    font-size: 1.4rem;
    line-height: 1;
}
.export-dialog .artwork-panel-body {
    padding: 18px;
}
.export-dialog .export-section h3 {
    margin: 0 0 12px;
    font-size: 1rem;
}
.export-dialog .artwork-controls {
    grid-template-columns: 90px 120px minmax(0, 1fr);
    gap: 10px;
}
.export-dialog .artwork-controls .export-dialog-mode {
    grid-column: 3;
}
.export-dialog .artwork-controls > .action-button {
    grid-column: 2 / -1;
}
.export-dialog .export-data-actions .action-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
}
@media (max-width: 560px) {
    .export-dialog .artwork-controls {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
    .export-dialog .artwork-controls .export-dialog-mode,
    .export-dialog .artwork-controls > .action-button {
        grid-column: 1 / -1;
    }
    .export-dialog .artwork-panel-body {
        padding: 14px;
    }
    .export-dialog .export-data-actions {
        display: grid;
        grid-template-columns: 1fr 1fr;
    }
}

/* REV v95: 管理機能は一覧の上に表示する共通モーダルへ集約する。 */
body.tool-modal-open {
    overflow: hidden;
}
.tool-modal {
    width: min(1060px, calc(100vw - 28px));
    max-width: none;
    height: min(860px, calc(100dvh - 28px));
    max-height: calc(100dvh - 28px);
    padding: 0;
    margin: auto;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: var(--panel);
    color: var(--text);
    box-shadow: 0 20px 70px rgba(0, 0, 0, .42);
}
.tool-modal::backdrop {
    background: rgba(0, 0, 0, .68);
}
.tool-modal[open] {
    display: flex;
    flex-direction: column;
}
.tool-modal-heading {
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--line);
    background: var(--panel);
}
.tool-modal-heading h2 {
    font-size: 1.08rem;
    margin: 0;
}
.tool-modal-frame {
    flex: 1 1 auto;
    width: 100%;
    min-height: 0;
    border: 0;
    background: var(--bg);
}
/* モーダル内では、二重のメニューとバージョン見出しを表示しない。 */
html[data-modal-embed="1"] .floating-menu-button,
html[data-modal-embed="1"] .floating-menu {
    display: none !important;
}
html[data-modal-embed="1"] .app-header h1 {
    display: none;
}
html[data-modal-embed="1"] .app-header {
    margin-bottom: 10px;
}
html[data-modal-embed="1"] .app-header p {
    margin: 0;
    font-size: .86rem;
}
html[data-modal-embed="1"] .page-shell {
    width: min(100%, 1020px);
    max-width: none;
    padding: 16px 16px 32px;
}
html[data-modal-embed="1"] body {
    min-height: 100%;
}
/* エクスポートボタンは右上メニューにのみ表示する。 */
@media (max-width: 600px) {
    .tool-modal {
        width: calc(100vw - 12px);
        height: calc(100dvh - 12px);
        max-height: calc(100dvh - 12px);
    }
    .tool-modal-heading {
        padding: 10px 12px;
    }
    html[data-modal-embed="1"] .page-shell {
        padding: 12px 10px 24px;
    }
}

/* 詳細モーダル内では空のページ見出し領域を表示しない。 */
html[data-modal-embed="1"][data-detail-only="1"] .app-header { display: none; }
