* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --left-panel-width: 300px;
    --right-panel-width: 360px;
    --left-panel-min: 260px;
    --right-panel-min: 260px;
    --center-min: 360px;
}

.hidden {
    display: none;
}

body {
    font-family: 'Arial', 'Hiragino Kaku Gothic ProN', sans-serif;
    background-color: #fef5f8;
    color: #4a4a4a;
    overflow: hidden;
}

/* 3分割レイアウト（左右をリサイズ可能） */
.main-layout {
    display: flex;
    height: 100vh;
    position: relative;
}

/* 左パネル */
.left-panel {
    width: var(--left-panel-width);
    min-width: var(--left-panel-min);
    background: linear-gradient(180deg, #6a5acd 0%, #9370db 100%);
    display: flex;
    flex-direction: column;
    box-shadow: 3px 0 15px rgba(106, 90, 205, 0.2);
    overflow-y: auto;
    flex: 0 0 auto;
}

.voice-container {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px; 
}

.voice-status {
    font-size: 14px;
    color: #666;
}


/* 中央エリア - クローン表示 */
.center-area {
    flex: 1 1 auto;
    min-width: var(--center-min);
    display: flex;
    flex-direction: column;
    background-color: #f0f0f0;
    position: relative;
}

/* 右パネル - チャット専用 */
.right-panel {
    width: var(--right-panel-width);
    min-width: var(--right-panel-min); /* チャットの視認性を考慮しmin-widthを設定 */
    background-color: #ffffff; /* 白い背景 */
    border-left: 1px solid #e8d5f0;
    flex-direction: column;
    box-shadow: -3px 0 15px rgba(0, 0, 0, 0.05);
    flex: 0 0 auto;
}

.panel-resizer {
    width: 10px;
    flex: 0 0 auto;
    cursor: col-resize;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    transition: background-color 0.2s ease;
}

.panel-resizer::after {
    content: '';
    width: 2px;
    height: 36px;
    background: #d6c8f0;
    border-radius: 4px;
    transition: transform 0.2s ease;
}

.panel-resizer:hover {
    background: rgba(186, 85, 211, 0.08);
}

.panel-resizer:hover::after {
    transform: scaleY(1.2);
}

.main-layout.resizing .panel-resizer {
    background: rgba(186, 85, 211, 0.12);
}

.settings-mode .right-panel,
.settings-mode .right-resizer {
    display: none;
}

.settings-mode .center-area {
    flex: 1 1 auto;
}

/* === 左パネルのスタイル (変更なし) === */
.panel-header {
    padding: 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

.panel-header h1 {
    color: #ffffff;
    font-size: 1.3em;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* アイドル切替セクション */
.idol-switch-section {
    padding: 15px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

.idol-switch-title {
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.85em;
    margin-bottom: 10px;
    text-transform: uppercase;
}

.idol-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.idol-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    background-color: rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
    position: relative;
}

.idol-item:hover {
    background-color: rgba(255, 255, 255, 0.2);
}

.idol-item.active {
    background-color: rgba(255, 105, 180, 0.3);
    border-left: 4px solid #ff69b4;
}

.idol-thumbnail {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    background-color: rgba(255, 255, 255, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
}

.idol-thumbnail img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
}

.idol-info {
    flex: 1;
}

.idol-name {
    color: #ffffff;
    font-weight: bold;
    font-size: 0.95em;
}

.idol-status {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 0.8em;
    color: rgba(255, 255, 255, 0.7);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: #7bed9f;
}

.status-dot.offline {
    background-color: #95a5a6;
}

/* メニューセクション */
.menu-section {
    flex: 1;
    padding: 15px;
}

.menu-list {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 15px;
    color: rgba(255, 255, 255, 0.85);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
    text-decoration: none;
}

.menu-item:hover,
.menu-item.active {
    background-color: rgba(255, 255, 255, 0.15);
    color: #ffffff;
}

.menu-item i {
    width: 20px;
    text-align: center;
}

/* 追加メニュー */
.bottom-menu {
    padding: 15px;
    border-top: 1px solid rgba(255, 255, 255, 0.2);
    margin-top: auto; /* サイドバー最下部に配置 */
}
.cost_time {
    margin-top: 12px;
    padding: 12px 14px;
    background: rgba(0, 0, 0, 0.6);
    border-radius: 8px;
    color: #eee;
    margin-left: 16px; 
    font-size: 13px;
    width: fit-content;
    min-width: 220px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.cost_item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 3px 0;
}

.cost_item .label {
    opacity: 0.85;
}

.cost_item .value {
    font-weight: 600;
    color: #6ee7ff;
}

.cost_item.total {
    margin-top: 6px;
    padding-top: 6px;
    border-top: 1px solid rgba(255, 255, 255, 0.2);
}

.cost_item.total .value {
    color: #4ade80;
    font-size: 14px;
}

.add-idol-btn {
    width: 100%;
    padding: 12px;
    background: linear-gradient(135deg, #ff69b4 0%, #ff1493 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-bottom: 10px;
    text-decoration: none;
}

.bg-selector-btn {
    max-width: 270px;
    display: block;      /* 让按钮成为块级元素 */
    margin: 0 auto;      /* 左右自动外边距，实现居中 */
}

.add-idol-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(255, 105, 180, 0.4);
}

.add-idol-inline {
    margin-top: 12px;
}

.user-menu {
    position: relative;
    margin-top: 12px;
}

.user-menu-trigger {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: 12px;
    padding: 10px 12px;
    color: #fff;
    cursor: pointer;
    transition: all 0.3s;
}

.user-menu-trigger:hover,
.user-menu.open .user-menu-trigger,
.user-menu-trigger.active {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.35);
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.2);
    display: grid;
    place-items: center;
    color: #fff;
    flex-shrink: 0;
}

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

.user-name {
    flex: 1;
    font-weight: bold;
    color: #fff;
    text-align: left;
}

.user-dropdown {
    display: none;
    position: absolute;
    left: 50%;
    bottom: calc(100% + 12px);
    transform: translateX(-50%);
    min-width: 200px;
    width: min(230px, calc(100% - 24px));
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
    overflow: hidden;
    z-index: 5;
}

.user-dropdown::before {
    content: '';
    position: absolute;
    left: 50%;
    bottom: -8px;
    transform: translateX(-50%);
    border-width: 8px;
    border-style: solid;
    border-color: #fff transparent transparent transparent;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.15));
}

.user-menu.open .user-dropdown {
    display: block;
}

.user-dropdown button {
    width: 100%;
    background: none;
    border: none;
    padding: 12px 14px;
    text-align: left;
    color: #4a4a4a;
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
}

.user-dropdown button + button {
    border-top: 1px solid #eee;
}

.user-dropdown button:hover {
    background: #f8f0ff;
    color: #6a5acd;
}

.time-display {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 0;
    margin-top: 4px;
    color: #fff;
    font-size: 0.95em;
}

.time-display i {
    color: rgba(255, 255, 255, 0.8);
}

/* === 中央エリアのスタイル === */
.content-view.active {
    /* chat-view以外のビューもcenter-area全体を使う */
    height: 100%;
}

/* モデルビューポートはchat-view内の高さを100%使用 */
.model-viewport {
    height: 100%; /* 中央エリアの高さ全体を使用 */
    position: relative;
    background: linear-gradient(135deg, #f8f0ff 0%, #fff0f8 100%);
    display: flex;
    align-items: center;
    justify-content: center;
}

.model-placeholder {
    text-align: center;
    color: #ba55d3;
}

.model-placeholder i {
    font-size: 5em;
    margin-bottom: 20px;
}

.model-placeholder img {
    max-width: 80%;
    max-height: 80%;
    object-fit: contain;
}
.row-set {
  display: flex;
  align-items: center;  
  gap: 8px;              
}

#model-display {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.75);
}

#model-display img {
    max-width: 90%;
    max-height: 90%;
    object-fit: contain;
    display: block;
}

.model-video-wrapper {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border-radius: 12px;
    overflow: hidden;
}

.model-video-wrapper video {
    width: 100%;
    height: 100%;
    min-width: 100%;
    min-height: 100%;
    object-fit: contain;
    display: block;
    background: transparent;
}

.model-video-wrapper canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    min-width: 100%;
    min-height: 100%;
    object-fit: contain;
    display: block;
}

/* === チャットエリアのスタイル (右パネル内に移動し、背景色を変更) === */
.chat-area {
    /* 右パネル全体を使用する */
    flex: 1; 
    height: 100%;
    background-color: #ffffff; /* 白い背景にする */
    backdrop-filter: none;
    display: flex;
    flex-direction: column;
}

.chat-messages {
    flex: 1;
    padding: 15px; /* パディング調整 */
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 10px; /* ギャップ調整 */
}

.message {
    display: flex;
    gap: 10px;
    max-width: 90%; /* 幅を広げる */
}

.message.user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.message-content {
    padding: 10px 15px;
    border-radius: 18px;
    line-height: 1.4;
}

.message-text {
    display: block;
}

.message.user .message-content {
    background: linear-gradient(135deg, #ba55d3 0%, #9370db 100%);
    color: white;
}

.message.idol .message-content {
    background-color: #f0f0f0; /* 薄いグレーに変更 */
    color: #4a4a4a;
}

.message-time {
    font-size: 0.75em;
    color: #999; /* 背景が白なので暗めの色に */
    margin-top: 4px;
}

.loading-indicator {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-weight: 400;
    font-style: italic;
    color: #666;
}

.loading-indicator .spinner {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 2px solid rgba(0, 0, 0, 0.15);
    border-top-color: #6a5acd;
    animation: rotate360 0.9s linear infinite;
}

@keyframes rotate360 {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

/* 入力エリア */
.chat-input-area {
    padding: 15px; /* パディング調整 */
    background-color: #ffffff; /* 白い背景にする */
    border-top: 1px solid #e8d5f0;
}

.input-wrapper {
    gap: 10px;
    align-items: center;
}

.chat-input {
    flex: 1;
    height: 48px;
    min-height: 48px;
    padding: 12px 15px;
    border: 1px solid #e8d5f0; /* 境界線を目立たなくする */
    border-radius: 25px;
    background-color: #ffffff;
    color: #4a4a4a;
    resize: none;
    font-size: 0.95em;
    font-family: inherit;
    line-height: 1.4;
    outline: none;
    overflow-y: auto;
    transition: border-color 0.3s;
    width: 100%;
}

.chat-input:focus {
    border-color: #ba55d3;
}

.input-btn {
    width: 40px;
    height: 40px;
    border: none;
    min-height: 45px;
    min-width: 45px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
    font-size: 1.1em;
}

.send-btn {
    background: linear-gradient(135deg, #ba55d3 0%, #9370db 100%);
    color: white;
}

.mode-toggle-btn {
    background: linear-gradient(135deg, #d780ec 0%, #9370db 100%);
    color: white;
}
.send-btn:hover {
    transform: scale(1.1);
}

.voice-btn {
    background: linear-gradient(135deg, #ff69b4 0%, #ff1493 100%);
    color: white;
}

.voice-btn:hover {
    transform: scale(1.1);
}
.comment-btn {
    background: linear-gradient(135deg, #76ec6c 0%, #d6c05b 100%);
    color: white;
}

.comment-btn:hover {
    transform: scale(1.1);
}

.voice-btn.recording {
    animation: pulse 1s infinite;
    background: linear-gradient(135deg, #ff4757 0%, #ff6348 100%);
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

/* コンテンツ切替 */
.content-view {
    display: none;
    height: 100%;
    /* flex-direction: column; は #chat-view から削除 (モデルビューポートが100%占めるため) */
}

.content-view.active {
    display: flex;
    flex-direction: column;
}

/* プロフィール画面 */
.profile-content {
    padding: 30px;
    overflow-y: auto;
}

.profile-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    border-bottom: 2px solid #e8d5f0;
}

.profile-tab {
    padding: 10px 20px;
    background-color: transparent;
    border: none;
    border-bottom: 3px solid transparent;
    cursor: pointer;
    color: #999;
    font-weight: bold;
    transition: all 0.3s;
}

.profile-tab.active {
    color: #6a5acd;
    border-bottom-color: #ba55d3;
}

.profile-detail {
    background-color: #ffffff;
    border: 2px solid #e8d5f0;
    border-radius: 12px;
    padding: 20px;
}

.detail-row {
    display: flex;
    padding: 12px 0;
    border-bottom: 1px solid #f0f0f0;
}

.detail-row:last-child {
    border-bottom: none;
}

.detail-label {
    width: 150px;
    font-weight: bold;
    color: #6a5acd;
}

.detail-value {
    flex: 1;
    color: #666;
}

/* 履歴画面 */
.history-content {
    padding: 30px;
    overflow-y: auto;
}

.history-filters {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.filter-input {
    flex: 1;
    padding: 10px;
    border: 2px solid #e8d5f0;
    border-radius: 8px;
    font-size: 0.95em;
}

.history-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.history-item {
    background-color: #ffffff;
    border: 2px solid #e8d5f0;
    border-radius: 12px;
    padding: 20px;
    cursor: pointer;
    transition: all 0.3s;
}

.history-item:hover {
    border-color: #ba55d3;
    box-shadow: 0 4px 15px rgba(186, 85, 211, 0.2);
}

.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.history-idol-name {
    font-weight: bold;
    color: #6a5acd;
    font-size: 1.1em;
}

.history-date {
    color: #999;
    font-size: 0.9em;
}

.history-stats {
    display: flex;
    gap: 20px;
    font-size: 0.9em;
    color: #666;
}

.history-stat i {
    margin-right: 5px;
    color: #ba55d3;
}

/* 設定画面 */
.settings-content {
    padding: 30px;
    overflow-y: auto;
}

.settings-section {
    margin-bottom: 30px;
}

.settings-title {
    font-size: 1.2em;
    font-weight: bold;
    color: #6a5acd;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 2px solid #e8d5f0;
}

.form-group {
    margin-bottom: 20px;
}

.form-label {
    display: block;
    font-weight: bold;
    color: #6a5acd;
    margin-bottom: 8px;
}

.form-input {
    width: 100%;
    padding: 10px;
    border: 2px solid #e8d5f0;
    border-radius: 6px;
    font-size: 0.95em;
}

.form-input:focus {
    border-color: #ba55d3;
    outline: none;
}

.input-error {
    border-color: #e74c3c !important;
    box-shadow: 0 0 0 2px rgba(231, 76, 60, 0.12);
}

.error-text {
    color: #e74c3c;
    font-size: 0.85em;
    margin-top: 6px;
}

.password-row {
    display: flex;
    gap: 15px;
}

.password-row .form-group {
    flex: 1;
    min-width: 0; /* ラベルの長さに左右されないよう均等に広げる */
}

.icon-upload {
    display: flex;
    align-items: center;
    gap: 16px;
}

.icon-preview {
    width: 80px;
    height: 80px;
    border-radius: 12px;
    border: 2px dashed #dda0dd;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #fefbff;
    overflow: hidden;
    color: #ba55d3;
    font-size: 1.4em;
}

.icon-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

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

.icon-upload-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 18px;
    background: linear-gradient(135deg, #ba55d3 0%, #9370db 100%);
    color: #fff;
    border: none;
    border-radius: 25px;
    box-shadow: 0 4px 15px rgba(186, 85, 211, 0.3);
    cursor: pointer;
    font-weight: bold;
    font-size: 0.95em;
    text-align: center;
    line-height: 1.2;
    gap: 8px;
    transition: all 0.3s;
}

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

.icon-upload-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(186, 85, 211, 0.4);
}

.icon-remove-btn {
    padding: 8px 12px;
    border: 2px solid #e8d5f0;
    background: #fff;
    border-radius: 8px;
    cursor: pointer;
    color: #6a5acd;
    font-weight: bold;
}

.icon-remove-btn:hover {
    background: #f8f0ff;
}

.password-field {
    position: relative;
    flex: 1;
}

.password-toggle {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    cursor: pointer;
    color: #ba55d3;
}

.note-small {
    font-size: 0.85em;
    color: #999;
    margin-top: 5px;
}

.display-id {
    padding: 10px;
    background: linear-gradient(135deg, #f8f0ff 0%, #fff0f8 100%);
    border: 2px solid #e8d5f0;
    border-radius: 6px;
    font-weight: bold;
    font-family: monospace;
    color: #6a5acd;
    width: 100%;
    box-sizing: border-box;
    display: block;
}

/* カラーテーマ */
.color-themes {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
    margin-top: 10px;
}

.theme-option {
    flex: 1;
    min-width: 120px;
    padding: 15px;
    border: 3px solid #e8d5f0;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s;
    text-align: center;
}

.theme-option:hover {
    transform: translateY(-3px);
    box-shadow: 0 4px 15px rgba(186, 85, 211, 0.2);
}

.theme-option.selected {
    border-color: #ba55d3;
    background: linear-gradient(135deg, #f8f0ff 0%, #fff0f8 100%);
}

.theme-preview {
    display: flex;
    gap: 5px;
    margin: 10px 0;
    justify-content: center;
}

.theme-preview-color {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: 2px solid white;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.theme-name {
    font-weight: bold;
    color: #6a5acd;
    margin-top: 8px;
}

.submit-btn {
    padding: 12px 30px;
    background: linear-gradient(135deg, #ba55d3 0%, #9370db 100%);
    color: white;
    border: none;
    border-radius: 25px;
    font-size: 1em;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s;
    margin-top: 20px;
}

.submit-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(186, 85, 211, 0.4);
}

.success-message {
    background: linear-gradient(135deg, #d4f4dd 0%, #c8f7dc 100%);
    border: 2px solid #7bed9f;
    color: #2d6a4f;
    padding: 12px;
    border-radius: 8px;
    margin-bottom: 20px;
    display: none;
    text-align: center;
}

.settings-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.settings-actions .success-message {
    margin: 0;
}

/* モーダル */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    background-color: #ffffff;
    border-radius: 12px;
    padding: 30px;
    max-width: 500px;
    width: 90%;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

.modal-title {
    font-size: 1.3em;
    font-weight: bold;
    color: #6a5acd;
    margin-bottom: 20px;
}

.modal-text {
    color: #666;
    line-height: 1.6;
    margin-bottom: 25px;
}

.modal-buttons {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

.modal-btn {
    padding: 10px 20px;
    border: none;
    border-radius: 20px;
    cursor: pointer;
    font-weight: bold;
    transition: all 0.3s;
}

.modal-btn-cancel {
    background-color: #f0f0f0;
    color: #666;
}

.modal-btn-confirm {
    background: linear-gradient(135deg, #ba55d3 0%, #9370db 100%);
    color: white;
}

.master-modal {
    max-width: 960px;
    width: 95%;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.modal-close-btn {
    background: none;
    border: none;
    color: #888;
    font-size: 1.2em;
    cursor: pointer;
    padding: 6px;
    border-radius: 50%;
    transition: color 0.2s, background-color 0.2s;
}

.modal-close-btn:hover {
    color: #333;
    background-color: #f2f2f2;
}

.master-table {
    border: 1px solid #e6e6e6;
    border-radius: 12px;
    overflow: hidden;
    background: linear-gradient(135deg, #ffffff 0%, #f8faff 100%);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

.master-table-row {
    display: grid;
    grid-template-columns: 90px 1.3fr 140px 190px 1.6fr;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    border-bottom: 1px solid #ececec;
}

.master-table-row:last-child {
    border-bottom: none;
}

.master-table-row.clickable {
    cursor: pointer;
}

.master-table-row.clickable:hover {
    background: linear-gradient(135deg, rgba(93, 173, 226, 0.08) 0%, rgba(52, 152, 219, 0.08) 100%);
}

.master-table-row.purchased {
    background: #f5f7fa;
    color: #888;
    cursor: not-allowed;
    opacity: 0.75;
}

.master-table-row.purchased:hover {
    background: #f5f7fa;
}

.master-table-row.purchased .master-cell {
    color: #777;
}

.master-table-row.purchased .master-name {
    color: #666;
}

.master-table-row.purchased .master-version {
    background: #f0f0f0;
    color: #777;
    border-color: #e4e4e4;
}

.master-table-row.purchased .master-icon {
    filter: grayscale(1);
    opacity: 0.8;
}

.master-table-head {
    background: linear-gradient(135deg, #edf1ff 0%, #e6eaff 100%);
    font-weight: bold;
    color: #4a4a4a;
}

.master-table-body {
    max-height: 50vh;
    overflow-y: auto;
}

.master-cell {
    color: #333;
    font-size: 0.95em;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.master-cell.icon-col {
    text-align: center;
}

.master-cell.comment-col {
    white-space: normal;
    line-height: 1.4;
    color: #555;
}

.master-cell.date-col {
    color: #555;
}

.master-icon {
    width: 64px;
    height: 64px;
    border-radius: 12px;
    background: #f4f6fb;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border: 1px solid #e6e6e6;
    margin: 0 auto;
}

.master-icon img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.master-icon i {
    color: #a0a0a0;
    font-size: 1.4em;
}

.master-name {
    font-weight: bold;
    color: #2d2d2d;
}

.master-version {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 12px;
    background: #eef1ff;
    color: #4b5fc4;
    font-weight: 600;
    font-size: 0.85em;
    border: 1px solid #dfe5ff;
}

.master-status {
    margin-top: 12px;
    color: #666;
    font-size: 0.95em;
}

.master-status.error {
    color: #d9534f;
}

.purchase-confirm {
    display: none;
    margin-top: 14px;
    padding: 14px;
    border-radius: 12px;
    background: linear-gradient(135deg, #f8faff 0%, #eef4ff 100%);
    border: 1px solid #dfe5ff;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.05);
    gap: 10px;
}

.purchase-confirm.active {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
}

.purchase-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.purchase-title {
    font-weight: bold;
    color: #304674;
}

.purchase-close {
    background: none;
    border: none;
    color: #7a8aaa;
    cursor: pointer;
    padding: 6px;
    border-radius: 50%;
    transition: background-color 0.2s, color 0.2s;
}

.purchase-close:hover {
    background-color: rgba(0, 0, 0, 0.05);
    color: #2c3e50;
}

.purchase-body {
    display: grid;
    gap: 6px;
}

.purchase-name {
    font-weight: 700;
    font-size: 1.05em;
    color: #2d2d2d;
}

.purchase-meta {
    display: flex;
    gap: 10px;
    color: #556;
    font-size: 0.93em;
    flex-wrap: wrap;
}

.purchase-version {
    padding: 2px 8px;
    border-radius: 10px;
    background: #eaf1ff;
    color: #4b5fc4;
    border: 1px solid #dfe5ff;
    font-weight: 600;
}

.purchase-date {
    color: #667;
}

.purchase-comment {
    color: #444;
    line-height: 1.4;
}

.purchase-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* スマホ対応 */
@media (max-width: 768px) {
    body {
        overflow: auto;
    }

    .main-layout {
        flex-direction: column;
        height: auto;
        min-height: 100vh;
    }

    .master-table {
        overflow-x: auto;
    }

    .master-table-row {
        min-width: 720px;
    }

    .left-panel {
        width: 100%;
        min-width: unset;
        height: auto;
        order: 1;
        flex-direction: row;
        gap: 8px;
        overflow-x: auto;
        padding: 10px;
        position: sticky;
        top: 0;
        z-index: 5;
    }

    .idol-switch-section,
    .menu-section,
    .bottom-menu {
        padding: 10px;
    }
    
    .idol-switch-section {
        border-right: 1px solid rgba(255, 255, 255, 0.2);
    }

    .idol-list {
        flex-direction: row;
        overflow-x: auto;
        gap: 10px;
    }

    .menu-list {
        flex-direction: row;
        gap: 10px;
        flex-wrap: wrap;
    }
    
    .menu-section {
        flex: unset;
        border-right: 1px solid rgba(255, 255, 255, 0.2);
    }

    .center-area {
        width: 100%;
        order: 2;
        height: auto;
        min-height: 320px;
    }

    .panel-resizer {
        display: none;
    }

    .right-panel {
        width: 100%;
        min-width: unset;
        height: auto;
        order: 3;
        border-left: none;
        border-top: 1px solid #e8d5f0;
        box-shadow: none;
        padding-bottom: 10px;
    }
    
    .model-viewport {
        height: auto;
        min-height: 260px;
        padding: 10px;
    }

    .chat-area {
        height: auto;
        min-height: 260px;
        max-height: 50vh;
    }

    .chat-messages {
        max-height: 45vh;
    }

    .input-wrapper {
        align-items: flex-start;
    }

    .history-filters {
        flex-direction: column;
    }

    .detail-row {
        flex-direction: column;
        gap: 6px;
    }

    .detail-label {
        width: 100%;
    }
}

@media (max-width: 480px) {
    .main-layout {
        gap: 10px;
    }

    .left-panel {
        flex-wrap: wrap;
        row-gap: 6px;
    }

    .idol-switch-section,
    .menu-section,
    .bottom-menu {
        padding: 8px;
    }

    .model-placeholder i {
        font-size: 3.5em;
    }

    .profile-content,
    .history-content,
    .settings-content {
        padding: 16px;
    }

    .profile-tabs {
        flex-wrap: wrap;
        gap: 6px;
    }

    .profile-tab {
        padding: 8px 12px;
        font-size: 0.9em;
    }

    .history-stats {
        flex-direction: column;
        gap: 8px;
    }

    .chat-area {
        max-height: 55vh;
    }

.chat-messages {
        gap: 8px;
    }
}

/* 背景选择弹窗里的图片 */
#bg-modal-body {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
    gap: 10px;
}

#bg-modal-body .bg-option-img {
    width: 90px;
    height: 60px;
    object-fit: cover;      /* 关键：裁切而不变形 */
    cursor: pointer;
    border-radius: 6px;
    border: 2px solid transparent;
    transition: all 0.2s ease;
}

#bg-modal-body .bg-option-img:hover {
    border-color: #5dade2;
    transform: scale(1.05);
}
