:root {
    --bg-main: #0a0a0a;
    --bg-sidebar: #141414;
    --bg-card: #1e1e1e;
    --bg-header: #141414;
    
    --text-main: #ffffff;
    --text-muted: #a0a0a0;
    
    --accent-blue: #2a6ee5;
    --accent-border: #333333;
    
    --sidebar-width: 250px;
    --header-height: 60px;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background-color: var(--bg-main);
    color: var(--text-main);
    line-height: 1.6;
    height: 100vh;
    overflow: hidden;
}

/* Layout */
.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

.main-content {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* Header */
.app-header {
    height: var(--header-height);
    background-color: var(--bg-header);
    border-bottom: 1px solid var(--accent-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 20px;
}

.header-logo {
    display: flex;
    align-items: center;
    gap: 10px;
}

.logo-icon {
    width: 30px;
    height: 30px;
    background-color: white;
    border-radius: 4px;
    /* ClickDesign icon placeholder */
    display: flex;
    justify-content: center;
    align-items: center;
}
.logo-icon::after {
    content: "CD";
    color: green;
    font-weight: bold;
}

.header-logo h1 {
    font-size: 1.2rem;
    font-weight: 600;
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 20px;
}

.storage-info {
    display: flex;
    align-items: center;
    gap: 10px;
    background-color: #000;
    padding: 5px 15px;
    border-radius: 4px;
    border: 1px solid var(--accent-border);
    font-size: 0.85rem;
}
.usage-percentage {
    color: #4CAF50;
    margin-left: 5px;
}

.settings-btn {
    background: none;
    border: none;
    color: var(--text-main);
    font-size: 1.2rem;
    cursor: pointer;
}

/* Sidebar */
.sidebar-left {
    width: var(--sidebar-width);
    flex-shrink: 0;
    background-color: var(--bg-sidebar);
    border-right: 1px solid var(--accent-border);
    display: flex;
    flex-direction: column;
    padding: 15px;
    gap: 15px;
    /* 親の高さに固定してカラム単体でスクロール */
    align-self: stretch;
    overflow-y: auto;
    overflow-x: hidden;
    scroll-behavior: smooth;
    /* Mac風スクロールバー：hover時のみ表示 */
    scrollbar-width: thin;
    scrollbar-color: transparent transparent;
    transition: scrollbar-color 0.3s;
}
.sidebar-left:hover {
    scrollbar-color: #3a3a3a transparent;
}
.sidebar-left::-webkit-scrollbar { width: 4px; }
.sidebar-left::-webkit-scrollbar-track { background: transparent; }
.sidebar-left::-webkit-scrollbar-thumb {
    background: transparent;
    border-radius: 4px;
    transition: background 0.3s;
}
.sidebar-left:hover::-webkit-scrollbar-thumb { background: #3a3a3a; }
.sidebar-left:hover::-webkit-scrollbar-thumb:hover { background: #555; }

.sidebar-section {
    border: 1px solid var(--accent-border);
    border-radius: 8px;
    overflow: hidden;
    background-color: #000;
    /* 子要素が縮小されないよう固定 → コンテンツが溢れてスクロール発動 */
    flex-shrink: 0;
}

.section-title {
    padding: 10px 15px;
    font-weight: bold;
    font-size: 1rem;
    text-align: center;
    background-color: var(--bg-card);
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.sidebar-section.active .section-title {
    border-bottom: 1px solid var(--accent-border);
}

.status-badge {
    font-size: 0.7rem;
    padding: 2px 6px;
    background-color: #555;
    border-radius: 10px;
    font-weight: normal;
}
.status-badge.done {
    background-color: #4CAF50;
}

.section-content {
    padding: 15px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

textarea {
    width: 100%;
    background-color: #1a1a1a;
    border: 1px solid var(--accent-border);
    color: var(--text-main);
    padding: 10px;
    border-radius: 4px;
    resize: vertical;
    font-family: inherit;
    font-size: 0.9rem;
    max-height: 300px;
}

.generate-btn {
    width: 100%;
    padding: 10px;
    background-color: var(--accent-blue);
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
    transition: background-color 0.2s;
    flex-shrink: 0;
    min-height: 40px;
}
.generate-btn:hover {
    background-color: #1e5dd1;
}
.generate-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}
.section-content .generate-btn {
    flex-shrink: 0;
}

.btn-orange {
    background-color: #ff9800;
}
.btn-orange:hover {
    background-color: #e68a00;
}

.copy-prompt-btn {
    margin-top: 10px;
    font-size: 0.8rem;
    background-color: #2a2a2a;
}
.copy-prompt-btn:hover {
    background-color: #3a3a3a;
}

.info-summary {
    font-size: 0.85rem;
    color: var(--text-muted);
    background-color: #1a1a1a;
    padding: 10px;
    border-radius: 4px;
    border: 1px solid var(--accent-border);
    min-height: 50px;
    max-height: 120px;
    overflow-y: auto;
}

.hidden {
    display: none !important;
}

/* Content Area */
.content-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.content-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    background-color: var(--bg-main);
    border-bottom: 1px solid var(--accent-border);
}

/* Content Header Actions (mock from image) */
.design-select-area {
    display: flex;
    align-items: center;
    gap: 15px;
}
.design-select-area .label {
    font-weight: bold;
}

.tab-buttons {
    display: flex;
    gap: 20px;
}

.tab-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 5px 0;
    font-size: 0.9rem;
}
.tab-btn.active {
    color: var(--accent-blue);
    border-bottom: 2px solid var(--accent-blue);
}

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

.action-btn {
    background-color: var(--bg-card);
    border: 1px solid var(--accent-border);
    color: var(--text-main);
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 5px;
}
.action-btn.primary {
    background-color: var(--accent-blue);
    border-color: var(--accent-blue);
}

/* Main View Tabs */
.main-tabs {
    display: flex;
    gap: 10px;
    padding: 10px 20px;
    background-color: var(--bg-main);
    justify-content: center;
}

.main-tab-btn {
    padding: 10px 40px;
    background-color: #000;
    color: var(--text-main);
    border: 1px solid var(--accent-border);
    cursor: pointer;
    font-size: 1.1rem;
    font-weight: bold;
    width: 200px;
}
.main-tab-btn.active {
    background-color: var(--bg-card);
    border-bottom: 2px solid var(--accent-blue);
}

/* View Container */
.view-container {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background-color: #000;
}

.parts-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    height: 100%;
}

.part-card {
    border: 1px solid #ffffff;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    background-color: #000;
    min-height: 400px;
}

.part-card h3 {
    text-align: center;
    padding: 15px;
    font-size: 1.5rem;
}

.card-content {
    flex: 1;
    padding: 20px;
    color: var(--text-muted);
    overflow-y: auto;
    font-size: 0.95rem;
    line-height: 1.8;
}

.placeholder-text {
    text-align: center;
    margin-top: 50px;
    color: #666;
}

/* Slide View Specifics */
.slide-controls {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 10px;
    margin-bottom: 15px;
}

#template-selector {
    background-color: var(--bg-card);
    color: white;
    border: 1px solid var(--accent-border);
    padding: 5px 10px;
    border-radius: 4px;
}

.slide-preview {
    width: 100%;
    aspect-ratio: 16/9;
    background-color: #333;
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 15px;
    position: relative;
    overflow: hidden;
}

.template-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    position: absolute;
    top: 0;
    left: 0;
    opacity: 0.8;
}

.template-placeholder {
    font-size: 1.5rem;
    font-weight: bold;
    z-index: 10;
    text-shadow: 0px 0px 5px rgba(0,0,0,0.8);
}

/* 台本ストリーミング表示 */
.slide-marker {
    background-color: rgba(42, 110, 229, 0.15);
    border-left: 3px solid var(--accent-blue);
    padding: 8px 12px;
    margin: 16px 0 8px 0;
    border-radius: 0 4px 4px 0;
}
.slide-marker strong { color: #4fc3f7; font-size: 1rem; }
.speech-text { color: #e0e0e0; padding: 2px 0; line-height: 1.9; }
.generating-indicator { animation: pulse 1.5s ease-in-out infinite; }
@keyframes pulse { 0%,100%{opacity:0.4;} 50%{opacity:1;} }

/* Settings Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}
.modal-box {
    background: var(--bg-card);
    border: 1px solid var(--accent-border);
    border-radius: 10px;
    width: 420px;
    max-width: 90vw;
    display: flex;
    flex-direction: column;
    gap: 0;
}
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--accent-border);
}
.modal-header h2 { font-size: 1.1rem; font-weight: bold; }
.modal-close-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.2rem;
    cursor: pointer;
}
.modal-close-btn:hover { color: var(--text-main); }
.modal-body {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.modal-body label {
    font-size: 0.9rem;
    color: var(--text-muted);
}
.modal-body input[type="password"] {
    width: 100%;
    background: #1a1a1a;
    border: 1px solid var(--accent-border);
    color: var(--text-main);
    padding: 10px;
    border-radius: 4px;
    font-family: inherit;
    font-size: 0.95rem;
}
.modal-hint {
    font-size: 0.78rem;
    color: #666;
}
.modal-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--accent-border);
}

/* スライド生成パネル */
.slide-generation-panel {
    background-color: var(--bg-card);
    border: 1px solid var(--accent-border);
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
}
.slide-panel-title {
    font-size: 1.2rem;
    margin-bottom: 8px;
}
.slide-panel-desc {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 16px;
}
.ai-service-selector {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
}
.service-option {
    flex: 1;
    cursor: pointer;
}
.service-option input[type="radio"] {
    display: none;
}
.service-card {
    border: 2px solid var(--accent-border);
    border-radius: 8px;
    padding: 16px;
    text-align: center;
    transition: border-color 0.2s, background-color 0.2s;
}
.service-option input[type="radio"]:checked + .service-card {
    border-color: var(--accent-blue);
    background-color: rgba(42, 110, 229, 0.1);
}
.service-card:hover {
    border-color: #555;
}
.service-name {
    font-size: 1.1rem;
    font-weight: bold;
    margin-bottom: 6px;
}
.service-desc {
    font-size: 0.8rem;
    color: var(--text-muted);
}
.slide-generation-actions {
    text-align: center;
}
.slide-action-hint {
    font-size: 0.78rem;
    color: #666;
    margin-top: 8px;
}

/* スライドコンテンツエリア */
.slide-script-content {
    padding: 12px !important;
}

/* ─── スライドプレースホルダー (16:9) ─── */
.slide-placeholder {
    width: 100%;
    aspect-ratio: 16 / 9;
    background-color: #eef1f8;
    background-image:
        linear-gradient(rgba(21, 101, 232, 0.08) 1px, transparent 1px),
        linear-gradient(90deg, rgba(21, 101, 232, 0.08) 1px, transparent 1px);
    background-size: 16px 16px;
    border: 2px solid #ffffff;
    border-radius: 3px;
    position: relative;
    overflow: hidden;
    box-shadow: 0 1px 4px rgba(21,101,232,0.10);
}
.slide-placeholder svg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

/* ─── 生成済みスライドフレーム ─── */
.slide-frame {
    width: 100%;
    aspect-ratio: 16 / 9;
    background-color: #f8f9fd;
    background-image:
        linear-gradient(rgba(21, 101, 232, 0.05) 1px, transparent 1px),
        linear-gradient(90deg, rgba(21, 101, 232, 0.05) 1px, transparent 1px);
    background-size: 16px 16px;
    border: 1px solid #dde3f0;
    border-radius: 3px;
    position: relative;
    overflow: hidden;
    margin-bottom: 10px;
    flex-shrink: 0;
    box-shadow: 0 1px 4px rgba(21,101,232,0.08);
}

/* 上部ブルーバー */
.slide-frame-topbar {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 11%;
    background-color: #1565e8;
    display: flex;
    align-items: center;
    padding: 0 3%;
    gap: 1.5%;
}
.slide-topbar-label {
    font-size: 0.42rem;
    color: rgba(255,255,255,0.7);
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.slide-topbar-sep {
    font-size: 0.4rem;
    color: rgba(255,255,255,0.4);
}
.slide-topbar-title {
    font-size: 0.42rem;
    color: #ffffff;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
}

/* コンテンツエリア */
.slide-frame-inner {
    position: absolute;
    top: 11%;
    left: 0;
    right: 0;
    bottom: 0;
    padding: 4% 5% 3% 5%;
    display: flex;
    flex-direction: column;
}

/* スライド番号バッジ */
.slide-num-badge {
    position: absolute;
    top: 13%;
    right: 3%;
    background-color: #1565e8;
    color: #ffffff;
    font-size: 0.42rem;
    font-weight: 700;
    padding: 0.8% 1.6%;
    border-radius: 2px;
    line-height: 1;
}

/* タイトル */
.slide-frame-title {
    font-size: 0.82rem;
    font-weight: 800;
    color: #111827;
    line-height: 1.3;
    margin-bottom: 3%;
    padding-right: 12%;
    flex-shrink: 0;
}

/* タイトル下のアクセントライン */
.slide-frame-title-line {
    width: 18%;
    height: 2px;
    background-color: #1565e8;
    margin-bottom: 4%;
    flex-shrink: 0;
    border-radius: 1px;
}

/* ボディ */
.slide-frame-body {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    gap: 3%;
}

.slide-display-item {
    font-size: 0.58rem;
    color: #374151;
    line-height: 1.4;
    padding-left: 5%;
    position: relative;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.slide-display-item::before {
    content: '▸';
    position: absolute;
    left: 0;
    color: #1565e8;
    font-size: 0.52rem;
}

.slide-display-muted {
    font-size: 0.52rem;
    color: #9ca3af;
    font-style: italic;
    padding-left: 0;
    white-space: normal;
    line-height: 1.5;
}
.slide-display-muted::before { content: none; }

/* ─── Gemini スライド生成中インジケーター ─── */
.gemini-slide-generating {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 40px 20px;
    min-height: 120px;
}
.gemini-generating-indicator {
    display: flex;
    gap: 6px;
}
.gemini-dot {
    width: 8px;
    height: 8px;
    background-color: var(--accent-blue);
    border-radius: 50%;
    animation: gemini-bounce 1.2s ease-in-out infinite;
}
.gemini-dot:nth-child(2) { animation-delay: 0.2s; }
.gemini-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes gemini-bounce {
    0%, 80%, 100% { transform: translateY(0); opacity: 0.4; }
    40% { transform: translateY(-6px); opacity: 1; }
}
.gemini-progress-text {
    font-size: 0.85rem;
    color: var(--text-muted);
}
.gemini-stream-preview {
    font-size: 0.75rem;
    color: var(--accent-blue);
    opacity: 0.8;
}

/* ─── Canvas テンプレートスライド ─── */
.tpl-rendering-indicator {
    padding: 30px;
    text-align: center;
    color: var(--text-muted);
}
.tpl-slide-wrap {
    width: 100%;
    margin-bottom: 14px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.tpl-slide-label {
    font-size: 0.70rem;
    color: var(--text-muted);
    padding: 0 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.tpl-slide-img {
    width: 100%;
    aspect-ratio: 16 / 9;
    display: block;
    border-radius: 4px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.50);
    object-fit: cover;
}

/* ─── テンプレート選択 ─── */
.template-select-section {
    margin-bottom: 16px;
}
.template-select-label {
    font-size: 0.85rem;
    font-weight: bold;
    color: var(--text-main);
    margin-bottom: 8px;
}
.template-select-hint {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: normal;
}
.template-thumbs {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}
.template-thumb {
    width: 64px;
    cursor: pointer;
    border: 2px solid transparent;
    border-radius: 4px;
    overflow: hidden;
    transition: border-color 0.15s;
    background: #1a1a1a;
}
.template-thumb img {
    width: 100%;
    height: 36px;
    object-fit: cover;
    display: block;
}
.template-thumb span {
    display: block;
    text-align: center;
    font-size: 0.6rem;
    color: var(--text-muted);
    padding: 2px 0;
}
.template-thumb:hover {
    border-color: #555;
}
.template-thumb.selected {
    border-color: var(--accent-blue);
}
.template-thumb.selected span {
    color: var(--accent-blue);
}

/* ─── テンプレート適用済みスライドフレーム ─── */
.slide-frame.has-template {
    background-color: transparent;
}
.slide-template-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.42);
    z-index: 1;
}
.slide-frame.has-template .slide-frame-topbar {
    z-index: 2;
    background-color: rgba(21, 101, 232, 0.82);
}
.slide-frame.has-template .slide-num-badge {
    z-index: 2;
    background-color: rgba(21, 101, 232, 0.85);
}
.slide-frame.has-template .slide-frame-inner {
    z-index: 2;
}
.slide-frame.has-template .slide-frame-title {
    color: #ffffff;
    text-shadow: 0 1px 4px rgba(0,0,0,0.9);
}
.slide-frame.has-template .slide-frame-title-line {
    background-color: rgba(255, 255, 255, 0.75);
}
.slide-frame.has-template .slide-display-item {
    color: #f0f0f0;
    text-shadow: 0 1px 3px rgba(0,0,0,0.9);
}
.slide-frame.has-template .slide-display-item::before {
    color: #90c4ff;
}
.slide-frame.has-template .slide-display-muted {
    color: #d0d0d0;
    text-shadow: 0 1px 3px rgba(0,0,0,0.8);
}
