/* ================================================================
   model-viewer.css — 3D モデルビュワー オブジェクトモード UI
   ================================================================ */

/* ── オーバーレイ（画面全体を覆う透明レイヤー） ── */
.model-viewer-overlay {
    position: fixed;
    inset: 0;
    pointer-events: none; /* 子要素だけがクリックを受け取る */
    z-index: 300;
}

.model-viewer-overlay.hidden {
    display: none;
}

/* ── 左上: ビューモードを閉じるピル ── */
.mv-close-pill {
    pointer-events: all;
    position: absolute;
    top: 20px;
    left: 20px;
    display: flex;
    align-items: center;
    gap: 6px;
    height: 44px;
    padding: 8px 16px 8px 12px;
    background: rgba(11, 13, 16, 0.88);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 999px;
    box-shadow: 0 16px 34px rgba(0, 0, 0, 0.28);
    color: rgba(255, 255, 255, 0.88);
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.15s ease, color 0.15s ease, transform 0.15s ease;
}

.mv-close-pill:hover {
    background: rgba(8, 14, 20, 0.94);
    color: #ffffff;
    transform: translateY(-1px);
}

.mv-close-pill-icon {
    width: 18px;
    height: 15px;
    flex-shrink: 0;
}

/* ── 右側パネル群 ── */
.mv-right-panels {
    pointer-events: none;
    position: absolute;
    top: 20px;
    right: 0;
    width: 280px;
    height: calc(100vh - 40px);
    max-height: calc(100vh - 40px);
    display: flex;
    flex-direction: column;
    gap: 8px;
    overflow: hidden;
}

/* ── 共通パネル ── */
.mv-panel {
    pointer-events: all;
    display: flex;
    flex-direction: column;
    flex: 0 0 auto;
    min-height: 0;
    background: rgba(11, 13, 16, 0.88);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-right: none;
    border-radius: 22px 0 0 22px;
    box-shadow: none;
    overflow: hidden;
    color: rgba(255, 255, 255, 0.88);
    font-family: inherit;
    font-size: 13px;
}

.mv-panel.hidden {
    display: none;
}

.mv-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 50px;
    padding: 14px 16px 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.mv-panel-title {
    font-size: 15px;
    font-weight: 600;
    color: #ffffff;
    line-height: 1.2;
}

.mv-panel-collapse {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    background: transparent;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    color: rgba(255, 255, 255, 0.86);
    transition: color 0.12s, background 0.12s, transform 0.2s;
    padding: 0;
}

.mv-panel-collapse-icon {
    width: 16px;
    height: 16px;
    opacity: 0.86;
    pointer-events: none;
}

.mv-panel-collapse:hover {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.12);
}

.mv-panel-collapse:hover .mv-panel-collapse-icon {
    opacity: 1;
}

.mv-panel-collapse[aria-expanded="false"] {
    transform: rotate(-90deg);
}

.mv-panel-body {
    min-height: 0;
    padding: 12px 16px 14px;
}

.mv-controls-panel {
    flex: 1 1 0;
}

#model-viewer-parts-panel {
    flex: 1.35 1 0;
}

#model-viewer-parts-panel.hidden {
    display: none;
}

.mv-panel.is-collapsed {
    align-self: flex-end;
    width: 64px;
    min-height: 0;
    transition: width 0.16s ease;
}

.mv-panel.is-collapsed .mv-panel-header {
    flex: 1 1 auto;
    flex-direction: column;
    justify-content: flex-start;
    gap: 12px;
    min-height: 0;
    height: 100%;
    padding: 14px 8px;
    border-bottom: none;
}

.mv-panel.is-collapsed .mv-panel-body {
    display: none !important;
}

.mv-panel.is-collapsed .mv-panel-title {
    order: 1;
    writing-mode: vertical-rl;
    text-orientation: mixed;
    white-space: nowrap;
    font-size: 14px;
    line-height: 1;
}

.mv-panel.is-collapsed .mv-panel-collapse {
    order: 0;
    flex-shrink: 0;
}

.mv-panel.is-collapsed .mv-panel-collapse[aria-expanded="false"] {
    transform: rotate(90deg);
}

.mv-right-panels.parts-hidden {
    height: auto;
}

.mv-right-panels.parts-hidden .mv-controls-panel {
    flex: 0 0 auto;
}

.mv-right-panels.parts-hidden #model-viewer-controls-body {
    max-height: min(360px, calc(100vh - 168px));
}

#model-viewer-parts-body {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    overflow: hidden;
}

#model-viewer-controls-body {
    flex: 1 1 auto;
    max-height: none;
    overflow-y: auto;
    overflow-x: hidden;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
}

.mv-panel-body.collapsed {
    display: none !important;
}

/* ── 表示/非表示パネル ── */
.mv-parts-hint {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.58);
    margin: 0;
    padding: 0 6px 7px;
    line-height: 1.5;
}

.mv-parts-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 1px;
    min-height: 0;
    max-height: none;
    flex: 1 1 auto;
    overflow-y: auto;
    overflow-x: hidden;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
}

.mv-part-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 6px;
    border-radius: 6px;
    transition: background 0.1s;
}

.mv-part-item:hover {
    background: rgba(255, 255, 255, 0.12);
}

/* 数字バッジ */
.mv-part-index {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.12);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.72);
}

.mv-part-label {
    flex: 1;
    font-size: 13px;
    color: rgba(255, 255, 255, 0.88);
    cursor: pointer;
    user-select: none;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* 目アイコントグルボタン */
.mv-part-eye-button {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    background: transparent;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    color: rgba(255, 255, 255, 0.72);
    transition: color 0.12s, background 0.12s;
    padding: 0;
}

.mv-part-eye-button:hover {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.12);
}

.mv-part-eye-button[data-visible="false"] {
    color: rgba(255, 255, 255, 0.32);
    opacity: 0.52;
}

.mv-part-eye-button[data-visible="false"] .mv-eye-open {
    display: none;
}

.mv-part-eye-button[data-visible="true"] .mv-eye-closed {
    display: none;
}

.mv-eye-icon {
    width: 16px;
    height: 16px;
    pointer-events: none;
}

/* ── 操作パネル ── */
.mv-controls-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
    color: rgba(255, 255, 255, 0.72);
    font-size: 12px;
}

.mv-orbit-icon {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    opacity: 0.58;
}

.mv-key-row {
    display: flex;
    align-items: center;
    gap: 3px;
}

.mv-key-layout {
    display: grid;
    grid-template-columns: 87px 87px 28px;
    align-items: center;
    column-gap: 19px;
    margin-bottom: 12px;
}

.mv-key-pad {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.mv-key-column {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.mv-key-row-space {
    margin-top: 4px;
}

.mv-key-blank {
    width: 28px;
    height: 28px;
    flex-shrink: 0;
}

kbd.mv-key {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 28px;
    height: 28px;
    padding: 0 6px;
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: 5px;
    font-family: inherit;
    font-size: 12px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.88);
    line-height: 1;
    box-shadow: 0 2px 0 rgba(0, 0, 0, 0.4);
}

kbd.mv-key-arrow {
    font-size: 14px;
}

kbd.mv-key-space {
    min-width: 64px;
    font-size: 11px;
    font-weight: 400;
}

kbd.mv-key-esc {
    min-width: 38px;
    font-size: 11px;
    font-weight: 400;
}

.mv-key-label {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.58);
    margin-left: 6px;
}

@media (max-width: 640px) {
    .mv-close-pill {
        top: 16px;
        left: 16px;
    }

    .mv-right-panels {
        top: 16px;
        right: 0;
        width: min(280px, calc(100vw - 16px));
        height: calc(100vh - 32px);
        max-height: calc(100vh - 32px);
    }

}
