/* ===========================================
   Misa AI - Modern Chat UI (Gemini-Style)
   =========================================== */

:root {
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-tertiary: #334155;
    --bg-chat: #0b1120;
    --surface: rgba(30, 41, 59, 0.6);
    --surface-hover: rgba(51, 65, 85, 0.5);
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --accent: #6366f1;
    --accent-hover: #818cf8;
    --accent-gradient: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #a78bfa 100%);
    --border: rgba(148, 163, 184, 0.1);
    --border-focus: rgba(99, 102, 241, 0.5);
    --success: #22c55e;
    --error: #ef4444;
    --warning: #f59e0b;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 20px;
    --radius-xl: 24px;
    --radius-full: 9999px;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.4);
    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    height: 100vh;
    overflow: hidden;
}

/* ===========================================
   レイアウト
   =========================================== */
.app-layout {
    display: flex;
    height: 100vh;
}

/* ===========================================
   サイドバー
   =========================================== */
.sidebar-toggle {
    position: fixed;
    top: 16px;
    left: 16px;
    z-index: 100;
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
    backdrop-filter: blur(8px);
}

.sidebar-toggle:hover {
    background: var(--surface-hover);
    color: var(--text-primary);
}

.sidebar {
    width: 320px;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
    flex-shrink: 0;
}

.sidebar.collapsed {
    width: 0;
    border-right: none;
}

.sidebar-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.sidebar-logo {
    font-size: 1.2rem;
    font-weight: 700;
}

.sidebar-content {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
}

.sidebar-content::-webkit-scrollbar {
    width: 4px;
}

.sidebar-content::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.08);
    border-radius: 2px;
}

.sidebar-section {
    margin-bottom: 1.5rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border);
}

.sidebar-section:last-child {
    border-bottom: none;
}

.sidebar-section-title {
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    margin-bottom: 0.75rem;
    white-space: nowrap;
}

.sidebar-form {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.sidebar-form input[type="text"],
.sidebar-form input[type="time"] {
    padding: 0.6rem 0.75rem;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.85rem;
    outline: none;
    transition: border var(--transition);
}

.sidebar-form input:focus {
    border-color: var(--border-focus);
}

.sidebar-form-row {
    display: flex;
    gap: 0.5rem;
}

.sidebar-form-row>* {
    flex: 1;
}

.select-compact {
    padding: 0.6rem 0.75rem;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.85rem;
    cursor: pointer;
    outline: none;
}

.btn-sidebar-action {
    padding: 0.6rem;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
}

.btn-sidebar-action:hover {
    filter: brightness(1.15);
}

.btn-sidebar-action.btn-purple {
    background: #8b5cf6;
}

.btn-sidebar-action.btn-danger {
    background: var(--error);
}

.sidebar-textarea {
    width: 100%;
    min-height: 60px;
    padding: 0.6rem 0.75rem;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.85rem;
    resize: vertical;
    outline: none;
    margin-bottom: 0.5rem;
    font-family: var(--font);
}

.sidebar-subsection-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 0.75rem;
    margin-bottom: 0.5rem;
}

.btn-badge {
    padding: 2px 8px;
    border-radius: var(--radius-full);
    font-size: 0.7rem;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--accent-hover);
    cursor: pointer;
    transition: all var(--transition);
}

.btn-badge:hover {
    background: rgba(99, 102, 241, 0.1);
}

.btn-sidebar-secondary {
    width: 100%;
    margin-top: 0.75rem;
    padding: 0.5rem;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 0.8rem;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all var(--transition);
}

.btn-sidebar-secondary:hover {
    background: rgba(255, 255, 255, 0.03);
}

.sidebar-list {
    list-style: none;
}

.sidebar-list li {
    padding: 0.5rem 0.6rem;
    border-radius: var(--radius-sm);
    margin-bottom: 0.25rem;
    font-size: 0.85rem;
    background: rgba(0, 0, 0, 0.15);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* ===========================================
   メインコンテンツ
   =========================================== */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    position: relative;
}

/* ヘッダー */
.main-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 2rem;
    padding-left: 4rem;
    border-bottom: 1px solid var(--border);
    background: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(12px);
    min-height: 56px;
}

.main-title {
    font-size: 1.25rem;
    font-weight: 700;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.header-controls {
    display: flex;
    gap: 0.5rem;
}

.btn-icon {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-secondary);
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
}

.btn-icon:hover {
    background: var(--surface-hover);
    color: var(--text-primary);
    border-color: var(--border-focus);
}

/* ===========================================
   チャットエリア
/* ===========================================
   思考プロセス (Thought Process) アコーディオン
   =========================================== */

.thought-container {
    margin: 1rem 0;
    border-radius: var(--radius-lg);
    background: transparent;
    transition: var(--transition);
}

.thought-details {
    border: none;
}

.thought-summary {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 500;
    color: #94a3b8;
    list-style: none;
    user-select: none;
    border-radius: var(--radius-md);
    transition: background 0.2s;
    width: fit-content;
}

.thought-summary:hover {
    background: var(--surface-hover);
    color: var(--text-primary);
}

.thought-summary::-webkit-details-marker {
    display: none;
}

.thought-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    background: var(--accent-gradient);
    border-radius: 50%;
    color: white;
    box-shadow: 0 0 10px rgba(99, 102, 241, 0.3);
    flex-shrink: 0;
}

.thought-arrow {
    margin-left: 4px;
    transition: transform 0.2s;
    font-size: 0.8rem;
    opacity: 0.7;
}

.thought-details[open] .thought-arrow {
    transform: rotate(180deg);
}

.thought-content {
    margin-top: 8px;
    padding: 12px 16px;
    border-left: 2px solid rgba(99, 102, 241, 0.3);
    margin-left: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    background: rgba(15, 23, 42, 0.2);
    border-radius: 0 var(--radius-md) var(--radius-md) 0;
}

/* 思考プロセス内のログ調整 */
.thought-content .info,
.thought-content .error,
.thought-content div {
    margin-bottom: 4px !important;
    font-size: 0.88rem;
}

.thought-content .log-image {
    max-width: 300px;
    border-radius: 8px;
    margin: 4px 0;
}


/* ===========================================
   自己進化提案 3レーンUI
   =========================================== */

/* モーダル拡幅版 */
.modal-content-wide {
    width: min(92vw, 1100px);
    max-height: 90vh;
}

/* タブバー */
.lane-tabs {
    display: flex;
    gap: 0.5rem;
    margin: 0.75rem 0;
    flex-wrap: wrap;
}

.lane-tab {
    padding: 0.4rem 1rem;
    border-radius: var(--radius-full, 9999px);
    border: 1px solid rgba(148, 163, 184, 0.2);
    background: rgba(30, 41, 59, 0.6);
    color: #94a3b8;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 500;
}

.lane-tab:hover {
    border-color: #6366f1;
    color: #a5b4fc;
}

.lane-tab.active {
    background: #6366f1;
    border-color: #6366f1;
    color: #fff;
    font-weight: 600;
}

/* レーンコンテナ */
.modal-proposals-lanes {
    display: flex;
    gap: 1rem;
    overflow-x: auto;
    padding-bottom: 0.5rem;
    min-height: 300px;
}

.lane-column {
    flex: 0 0 calc(33.33% - 0.67rem);
    min-width: 280px;
    background: rgba(15, 23, 42, 0.5);
    border: 1px solid rgba(148, 163, 184, 0.12);
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.lane-header {
    padding: 0.75rem 1rem;
    font-weight: 700;
    font-size: 0.9rem;
    border-bottom: 1px solid rgba(148, 163, 184, 0.12);
    letter-spacing: 0.02em;
    flex-shrink: 0;
}

.lane-header-misa {
    background: rgba(99, 102, 241, 0.18);
    color: #a5b4fc;
    border-bottom-color: rgba(99, 102, 241, 0.3);
}

.lane-header-api {
    background: rgba(59, 130, 246, 0.18);
    color: #93c5fd;
    border-bottom-color: rgba(59, 130, 246, 0.3);
}

.lane-header-skills {
    background: rgba(249, 115, 22, 0.15);
    color: #fdba74;
    border-bottom-color: rgba(249, 115, 22, 0.3);
}

.lane-cards {
    flex: 1;
    padding: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    overflow-y: auto;
}

/* レーン内カード */
.modal-proposal-card {
    background: rgba(30, 41, 59, 0.65);
    border: 1px solid rgba(148, 163, 184, 0.12);
    border-radius: 10px;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    font-size: 0.9rem;
    transition: border-color 0.2s;
}

.modal-proposal-card:hover {
    border-color: rgba(99, 102, 241, 0.4);
}

.modal-proposal-card pre {
    background: rgba(0, 0, 0, 0.35);
    border-radius: 8px;
    padding: 0.75rem;
    font-size: 0.8rem;
    white-space: pre-wrap;
    overflow: auto;
    max-height: 180px;
}

.modal-proposal-card code {
    font-size: 0.8rem;
    color: #c4d0e0;
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
}

.modal-card-footer {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.5rem;
    flex-wrap: wrap;
}

/* AI Summary Section */
.ai-summary-section {
    margin-bottom: 24px;
    padding: 16px;
    background: rgba(147, 51, 234, 0.05);
    border: 1px solid rgba(147, 51, 234, 0.2);
    border-radius: 16px;
}

.section-title-with-ai {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 1rem;
    color: var(--accent-primary);
    margin-bottom: 12px;
}

.ai-summary-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 16px;
}

.ai-summary-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    transition: transform 0.2s, box-shadow 0.2s;
}

.ai-summary-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.ai-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.category-badge {
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
}

.category-badge.feature {
    background: rgba(16, 185, 129, 0.1);
    color: #10b981;
}

.category-badge.ui {
    background: rgba(59, 130, 246, 0.1);
    color: #3b82f6;
}

.category-badge.bug {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
}

.item-count {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.summary-text {
    font-size: 0.9rem;
    line-height: 1.5;
    color: var(--text-primary);
    margin: 0;
}

.ai-card-actions {
    display: flex;
    gap: 8px;
    margin-top: auto;
}

.ai-card-actions button {
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid var(--border-color);
    background: var(--bg-primary);
    color: var(--text-primary);
    transition: all 0.2s;
}

.ai-card-actions .btn-approve:hover {
    background: #10b981;
    color: white;
    border-color: #10b981;
}

.ai-card-actions .btn-discard:hover {
    background: #ef4444;
    color: white;
    border-color: #ef4444;
}

.ai-card-actions .btn-copy:hover {
    background: var(--accent-primary);
    color: white;
    border-color: var(--accent-primary);
}

.action-btn-ai {
    background: linear-gradient(135deg, #a855f7 0%, #7c3aed 100%);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 12px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(124, 58, 237, 0.3);
}

/* スキルタグ */
.skill-target-tag {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    background: rgba(249, 115, 22, 0.15);
    border: 1px solid rgba(249, 115, 22, 0.35);
    border-radius: 999px;
    font-size: 0.75rem;
    color: #fdba74;
    margin-top: 0.25rem;
    font-weight: 600;
}

/* バッジ */
.badge {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.02em;
}

.badge-misa {
    background: rgba(99, 102, 241, 0.2);
    color: #a5b4fc;
    border: 1px solid rgba(99, 102, 241, 0.4);
}

.badge-api {
    background: rgba(59, 130, 246, 0.2);
    color: #93c5fd;
    border: 1px solid rgba(59, 130, 246, 0.4);
}

.badge-skills {
    background: rgba(249, 115, 22, 0.2);
    color: #fdba74;
    border: 1px solid rgba(249, 115, 22, 0.4);
}

/* 旧バッジ(後方互換) */
.badge-prompt {
    background: rgba(139, 92, 246, 0.2);
    color: #c4b5fd;
    border: 1px solid rgba(139, 92, 246, 0.4);
}

.badge-code {
    background: rgba(249, 115, 22, 0.2);
    color: #fdba74;
    border: 1px solid rgba(249, 115, 22, 0.4);
}

/* アクションボタン */
.btn-copy,
.action-btn-success,
.action-btn-danger,
.action-btn-primary {
    padding: 0.35rem 0.9rem;
    border-radius: 8px;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: all 0.2s;
}

.btn-copy {
    background: rgba(99, 102, 241, 0.12);
    color: #a5b4fc;
    border: 1px solid rgba(99, 102, 241, 0.3);
}

.btn-copy:hover {
    background: rgba(99, 102, 241, 0.25);
}

.btn-copy.success {
    background: rgba(34, 197, 94, 0.15);
    color: #4ade80;
    border-color: rgba(34, 197, 94, 0.4);
}

.action-btn-success {
    background: rgba(34, 197, 94, 0.15);
    color: #4ade80;
    border: 1px solid rgba(34, 197, 94, 0.4);
}

.action-btn-success:hover {
    background: rgba(34, 197, 94, 0.28);
}

.action-btn-danger {
    background: rgba(239, 68, 68, 0.12);
    color: #f87171;
    border: 1px solid rgba(239, 68, 68, 0.35);
}

.action-btn-danger:hover {
    background: rgba(239, 68, 68, 0.25);
}

.action-btn-primary {
    background: rgba(99, 102, 241, 0.2);
    color: #a5b4fc;
    border: 1px solid rgba(99, 102, 241, 0.4);
}

.action-btn-primary:hover {
    background: rgba(99, 102, 241, 0.35);
}

/* モーダル共通 */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.modal-content {
    background: var(--bg-secondary, #1e293b);
    border: 1px solid rgba(148, 163, 184, 0.15);
    border-radius: 16px;
    width: min(90vw, 800px);
    max-height: 88vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid rgba(148, 163, 184, 0.1);
    flex-shrink: 0;
}

.modal-header h2 {
    font-size: 1.15rem;
    font-weight: 700;
    color: #f1f5f9;
}

.modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 1.25rem 1.5rem;
    display: flex;
    flex-direction: column;
}

.modal-actions-bar {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 0.25rem;
    flex-wrap: wrap;
}

.close-btn {
    background: none;
    border: none;
    color: #64748b;
    cursor: pointer;
    font-size: 1.5rem;
    line-height: 1;
    transition: color 0.2s;
}

.close-btn:hover {
    color: #f1f5f9;
}

/* 設定モーダル用スタイル */
.settings-modal-content {
    width: min(90vw, 500px);
}

.settings-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1.25rem;
}

.settings-group label {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.settings-input,
.settings-textarea {
    width: 100%;
    background: rgba(15, 23, 42, 0.6);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 0.65rem 0.75rem;
    font-size: 0.9rem;
    line-height: 1.5;
}

.settings-input {
    min-height: 42px;
}

.settings-textarea {
    min-height: 110px;
    resize: vertical;
}

.settings-input:focus,
.settings-textarea:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.15);
}

.settings-hint {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

.settings-message {
    padding: 0.75rem;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    margin-bottom: 1.25rem;
    text-align: center;
}

.settings-message.success {
    background: rgba(34, 197, 94, 0.1);
    color: #4ade80;
    border: 1px solid rgba(34, 197, 94, 0.2);
}

.settings-message.error {
    background: rgba(239, 68, 68, 0.1);
    color: #f87171;
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.settings-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
}

.settings-actions button {
    padding: 0.6rem 1rem;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    height: 100vh;
    overflow: hidden;
}

/* ===========================================
   レイアウト
   =========================================== */
.app-layout {
    display: flex;
    height: 100vh;
}

/* ===========================================
   サイドバー
   =========================================== */
.sidebar-toggle {
    position: fixed;
    top: 16px;
    left: 16px;
    z-index: 100;
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
    backdrop-filter: blur(8px);
}

.sidebar-toggle:hover {
    background: var(--surface-hover);
    color: var(--text-primary);
}

.sidebar {
    width: 320px;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
    flex-shrink: 0;
}

.sidebar.collapsed {
    width: 0;
    border-right: none;
}

.sidebar-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.sidebar-logo {
    font-size: 1.2rem;
    font-weight: 700;
}

.sidebar-content {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
}

.sidebar-content::-webkit-scrollbar {
    width: 4px;
}

.sidebar-content::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.08);
    border-radius: 2px;
}

.sidebar-section {
    margin-bottom: 1.5rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border);
}

.sidebar-section:last-child {
    border-bottom: none;
}

.sidebar-section-title {
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    margin-bottom: 0.75rem;
    white-space: nowrap;
}

.sidebar-form {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.sidebar-form input[type="text"],
.sidebar-form input[type="time"] {
    padding: 0.6rem 0.75rem;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.85rem;
    outline: none;
    transition: border var(--transition);
}

.sidebar-form input:focus {
    border-color: var(--border-focus);
}

.sidebar-form-row {
    display: flex;
    gap: 0.5rem;
}

.sidebar-form-row>* {
    flex: 1;
}

.select-compact {
    padding: 0.6rem 0.75rem;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.85rem;
    cursor: pointer;
    outline: none;
}

.btn-sidebar-action {
    padding: 0.6rem;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
}

.btn-sidebar-action:hover {
    filter: brightness(1.15);
}

.btn-sidebar-action.btn-purple {
    background: #8b5cf6;
}

.btn-sidebar-action.btn-danger {
    background: var(--error);
}

.sidebar-textarea {
    width: 100%;
    min-height: 60px;
    padding: 0.6rem 0.75rem;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.85rem;
    resize: vertical;
    outline: none;
    margin-bottom: 0.5rem;
    font-family: var(--font);
}

.sidebar-subsection-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 0.75rem;
    margin-bottom: 0.5rem;
}

.btn-badge {
    padding: 2px 8px;
    border-radius: var(--radius-full);
    font-size: 0.7rem;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--accent-hover);
    cursor: pointer;
    transition: all var(--transition);
}

.btn-badge:hover {
    background: rgba(99, 102, 241, 0.1);
}

.btn-sidebar-secondary {
    width: 100%;
    margin-top: 0.75rem;
    padding: 0.5rem;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 0.8rem;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all var(--transition);
}

.btn-sidebar-secondary:hover {
    background: rgba(255, 255, 255, 0.03);
}

.sidebar-list {
    list-style: none;
}

.sidebar-list li {
    padding: 0.5rem 0.6rem;
    border-radius: var(--radius-sm);
    margin-bottom: 0.25rem;
    font-size: 0.85rem;
    background: rgba(0, 0, 0, 0.15);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* ===========================================
   メインコンテンツ
   =========================================== */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    position: relative;
}

/* ヘッダー */
.main-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 2rem;
    padding-left: 4rem;
    border-bottom: 1px solid var(--border);
    background: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(12px);
    min-height: 56px;
}

.main-title {
    font-size: 1.25rem;
    font-weight: 700;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.header-controls {
    display: flex;
    gap: 0.5rem;
}

.btn-icon {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-secondary);
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
}

.btn-icon:hover {
    background: var(--surface-hover);
    color: var(--text-primary);
    border-color: var(--border-focus);
}

/* ===========================================
   チャットエリア
   =========================================== */
.chat-area {
    position: relative;
    flex: 1;
    overflow-y: auto;
    padding: 2rem;
    padding-bottom: 3.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    scroll-behavior: smooth;
}


.chat-activity {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 0.35rem 0.85rem;
    background: rgba(15, 23, 42, 0.85);
    border: 1px solid var(--border);
    border-radius: var(--radius-full);
    font-size: 0.78rem;
    color: var(--text-secondary);
    box-shadow: var(--shadow-sm);
    backdrop-filter: blur(8px);
    margin: 0.5rem 0 0.25rem 0;
}

.chat-activity.hidden {
    display: none;
}

.spinner.sm {
    width: 14px;
    height: 14px;
    border-width: 2px;
}

.inline-spinner {
    width: 12px;
    height: 12px;
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-top-color: var(--accent);
    border-radius: 50%;
    display: inline-block;
    margin-left: 8px;
    animation: spin 1s linear infinite;
    vertical-align: middle;
}

.chat-area::-webkit-scrollbar {
    width: 6px;
}

.chat-area::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.06);
    border-radius: 3px;
}

.chat-area::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.12);
}

/* ウェルカムスクリーン */
.welcome-screen {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    gap: 1rem;
    animation: fadeIn 0.6s ease;
}

.welcome-icon-img {
    width: 140px;
    height: 140px;
    object-fit: contain;
    animation: float 3s ease-in-out infinite;
    filter: drop-shadow(0 0 30px rgba(99, 102, 241, 0.5)) drop-shadow(0 0 60px rgba(139, 92, 246, 0.3));
    background: radial-gradient(circle, rgba(15, 23, 42, 0.9) 40%, transparent 70%);
    border-radius: 50%;
    padding: 10px;
}

.welcome-title {
    font-size: 2rem;
    font-weight: 700;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.welcome-subtitle {
    color: var(--text-secondary);
    font-size: 1.05rem;
    max-width: 400px;
}

.welcome-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    justify-content: center;
    margin-top: 1rem;
}

.suggestion-chip {
    padding: 0.6rem 1.2rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-full);
    color: var(--text-secondary);
    font-size: 0.9rem;
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
}

.suggestion-chip:hover {
    background: var(--surface-hover);
    color: var(--text-primary);
    border-color: var(--accent);
    transform: translateY(-2px);
}

/* チャットメッセージ */
.chat-area>div {
    max-width: 800px;
    width: 100%;
    margin: 0 auto;
    padding: 0.75rem 1rem;
    border-radius: var(--radius-md);
    font-size: 0.95rem;
    line-height: 1.7;
    word-break: break-word;
    animation: msgIn 0.3s ease;
}

.chat-area>div:not(.welcome-screen) {
    background: rgba(255, 255, 255, 0.02);
    border-left: 3px solid transparent;
}

/* ログタイプごとのスタイル */
.chat-area .info {
    color: var(--accent-hover);
    background: rgba(99, 102, 241, 0.06) !important;
    border-left-color: var(--accent) !important;
}

.chat-area .error {
    color: #fca5a5;
    background: rgba(239, 68, 68, 0.08) !important;
    border-left-color: var(--error) !important;
}

.chat-area .success {
    color: #86efac;
    background: rgba(34, 197, 94, 0.08) !important;
    border-left-color: var(--success) !important;
}

.chat-area .result {
    background: rgba(99, 102, 241, 0.08) !important;
    border-left-color: var(--accent) !important;
    padding: 1.25rem;
}

/* ログ内画像 */
.log-image {
    max-width: 100%;
    max-height: 400px;
    border-radius: var(--radius-md);
    margin-top: 0.75rem;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-md);
    cursor: zoom-in;
    transition: all var(--transition);
    display: block;
}

.log-image:hover {
    transform: scale(1.01);
    box-shadow: var(--shadow-lg);
    border-color: var(--accent);
}

/* ===========================================
   入力エリア
   =========================================== */
.input-area {
    padding: 1rem 2rem 1.5rem;
    background: linear-gradient(to top, var(--bg-primary), transparent);
}

.image-preview-area {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem 0;
    /* 画像がない場合は非表示 */
    empty-cells: hide;
}

.image-preview-area:empty {
    display: none;
}

.auto-proposal-control {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.control-label {
    font-size: 0.7rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.switch-tiny {
    position: relative;
    display: inline-block;
    width: 44px;
    /* 少し広げて文字を入れやすくする */
    height: 18px;
}

.switch-tiny input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider-tiny {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(255, 255, 255, 0.1);
    transition: .4s;
    border-radius: 18px;
    border: 1px solid var(--border);
}

.slider-tiny:before {
    position: absolute;
    content: "";
    height: 12px;
    width: 12px;
    left: 3px;
    bottom: 2px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
    z-index: 2;
}

/* ON/OFF テキストの表示 */
.slider-tiny:after {
    position: absolute;
    content: "OFF";
    font-size: 8px;
    font-weight: bold;
    right: 5px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
    transition: .4s;
}

input:checked+.slider-tiny {
    background-color: var(--accent);
    border-color: var(--accent);
}

input:checked+.slider-tiny:after {
    content: "ON";
    left: 7px;
    right: auto;
    color: white;
}

input:checked+.slider-tiny:before {
    transform: translateX(25px);
}

.preview-item {
    position: relative;
    width: 64px;
    height: 64px;
    border-radius: var(--radius-sm);
    overflow: hidden;
    border: 2px solid var(--accent);
    animation: scaleIn 0.3s ease;
}

.preview-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.preview-item .remove-img {
    position: absolute;
    top: 2px;
    right: 2px;
    background: rgba(239, 68, 68, 0.85);
    color: white;
    border: none;
    border-radius: 50%;
    width: 16px;
    height: 16px;
    font-size: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.input-container {
    max-width: 800px;
    margin: 0 auto;
    width: 100%;
}

.input-box {
    display: flex;
    align-items: flex-end;
    gap: 0;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: 0.5rem;
    transition: all var(--transition);
    box-shadow: var(--shadow-sm);
}

.input-box:focus-within {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.1), var(--shadow-md);
}

.btn-attach {
    background: transparent;
    border: none;
    color: var(--text-muted);
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
    flex-shrink: 0;
}

.btn-attach:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.05);
}

#objectiveInput {
    flex: 1;
    min-width: 0;
    padding: 0.6rem 0.5rem;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 1rem;
    font-family: var(--font);
    outline: none;
    resize: none;
    min-height: 44px;
    max-height: 200px;
    line-height: 1.5;
    width: 100%;
}

#objectiveInput::placeholder {
    color: var(--text-muted);
}

.input-actions {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    flex-shrink: 0;
}

.composer-tools-panel {
    position: fixed;
    left: 12px;
    top: 12px;
    width: min(640px, calc(100vw - 24px));
    max-height: min(70vh, 520px);
    overflow: visible;
    padding: 0.6rem 0.7rem;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: rgba(15, 23, 42, 0.72);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    box-shadow: 0 20px 50px rgba(2, 6, 23, 0.55);
    z-index: 2600;
    isolation: isolate;
    display: block;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateY(8px) scale(0.98);
    transform-origin: bottom right;
    transition: opacity 0.16s ease, transform 0.16s ease, visibility 0.16s ease;
}

.composer-tools-panel.open {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translateY(0) scale(1);
}

.composer-tools-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.55rem;
}

.composer-tool-group {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    border: 1px solid rgba(148, 163, 184, 0.2);
    border-radius: 10px;
    padding: 0.35rem 0.45rem;
    background: rgba(15, 23, 42, 0.4);
}

.composer-tool-label {
    font-size: 0.74rem;
    color: var(--text-secondary);
    font-weight: 600;
}

.composer-media-actions {
    margin-top: 0.55rem;
    display: flex;
    gap: 0.45rem;
    flex-wrap: wrap;
}

.composer-mini-btn {
    border: 1px solid rgba(148, 163, 184, 0.35);
    background: rgba(30, 41, 59, 0.65);
    color: var(--text-primary);
    border-radius: 9px;
    padding: 0.35rem 0.6rem;
    font-size: 0.76rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
}

.composer-mini-btn:hover {
    border-color: var(--accent);
    background: rgba(99, 102, 241, 0.22);
}

.select-inline {
    padding: 0.4rem 0.5rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    outline: none;
    transition: all var(--transition);
}

.sr-only-select {
    display: none !important;
}

.compact-picker {
    position: relative;
    z-index: 3;
}

.btn-icon-compact {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.06);
    color: #fff;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
}

.btn-icon-compact:hover {
    border-color: var(--border-focus);
    transform: translateY(-1px);
}

.picker-icon {
    font-size: 1rem;
    line-height: 1;
}

.picker-menu {
    position: absolute;
    right: 0;
    bottom: calc(100% + 8px);
    min-width: 170px;
    padding: 0.35rem;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: rgba(15, 23, 42, 0.96);
    box-shadow: var(--shadow-lg);
    display: none;
    z-index: 2800;
}

.picker-menu.open {
    display: block;
}

.picker-option {
    width: 100%;
    border: none;
    background: transparent;
    color: var(--text-primary);
    text-align: left;
    border-radius: 8px;
    padding: 0.45rem 0.55rem;
    cursor: pointer;
    font-size: 0.8rem;
}

.picker-option:hover {
    background: rgba(99, 102, 241, 0.14);
}

.btn-icon-compact.state-flash {
    background: linear-gradient(135deg, #f59e0b, #f97316);
    border-color: transparent;
}

.btn-icon-compact.state-pro {
    background: linear-gradient(135deg, #0ea5e9, #2563eb);
    border-color: transparent;
}

.btn-icon-compact.state-legacy {
    background: linear-gradient(135deg, #f97316, #ea580c);
    border-color: transparent;
}

.btn-icon-compact.state-async {
    background: linear-gradient(135deg, #3b82f6, #1d4ed8);
    border-color: transparent;
}

.btn-icon-compact.state-api {
    background: linear-gradient(135deg, #facc15, #f59e0b);
    border-color: transparent;
}

.btn-icon-compact.state-auto {
    background: linear-gradient(135deg, #14b8a6, #0d9488);
    border-color: transparent;
}

.btn-icon-compact.state-ytauto {
    background: linear-gradient(135deg, #14b8a6, #0d9488);
    border-color: transparent;
}

.btn-icon-compact.state-yta {
    background: linear-gradient(135deg, #22c55e, #16a34a);
    border-color: transparent;
}

.btn-icon-compact.state-ytb {
    background: linear-gradient(135deg, #6366f1, #4f46e5);
    border-color: transparent;
}

.btn-icon-compact.state-tools {
    background: linear-gradient(135deg, #334155, #1e293b);
    border-color: rgba(148, 163, 184, 0.45);
}

.lane-header-misa {
    background: linear-gradient(135deg, #c084fc, #9333ea);
    color: white;
    border-color: var(--accent-secondary);
}

.lane-header-api {
    background: linear-gradient(135deg, #60a5fa, #2563eb);
    color: white;
    border-color: #3b82f6;
}

.lane-header-skills {
    background: linear-gradient(135deg, #fb923c, #ea580c);
    color: white;
    border-color: #f97316;
}

.lane-header-auto {
    background: linear-gradient(135deg, #2dd4bf, #0f766e);
    color: white;
    border-color: #14b8a6;
}

.btn-send {
    width: 40px;
    height: 40px;
    background: var(--accent-gradient);
    border: none;
    border-radius: var(--radius-md);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
    flex-shrink: 0;
}

.btn-send:hover:not(:disabled) {
    transform: scale(1.05);
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.4);
}

.btn-send:active {
    transform: scale(0.95);
}

.btn-send:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.btn-stop {
    width: 40px;
    height: 40px;
    background: var(--error);
    border: none;
    border-radius: var(--radius-md);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
    flex-shrink: 0;
}

.btn-stop:hover {
    background: #dc2626;
}

.runtime-toggle-row {
    margin-top: 0.5rem;
    padding: 0.55rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: rgba(15, 23, 42, 0.45);
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.45rem 0.8rem;
}

.runtime-toggle-title {
    font-size: 0.76rem;
    color: var(--text-secondary);
    font-weight: 700;
    letter-spacing: 0.03em;
}

.runtime-toggle-item {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.82rem;
    color: var(--text-primary);
    user-select: none;
}

.runtime-toggle-item input[type="checkbox"] {
    width: 15px;
    height: 15px;
    accent-color: var(--accent);
}

.runtime-toggle-save {
    margin-left: auto;
    border: 1px solid var(--border);
    background: rgba(99, 102, 241, 0.2);
    color: #fff;
    border-radius: 8px;
    height: 30px;
    padding: 0 0.75rem;
    cursor: pointer;
    font-size: 0.78rem;
    font-weight: 600;
}

.runtime-toggle-save:hover {
    border-color: var(--accent);
    background: rgba(99, 102, 241, 0.35);
}

.runtime-toggle-hint {
    width: 100%;
    font-size: 0.72rem;
    color: var(--text-muted);
}

.runtime-toggle-hint.error {
    color: #fca5a5;
}

.input-hint {
    text-align: center;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.5rem;
}

/* ===========================================
   ドラッグ&ドロップ
   =========================================== */
.input-box.drag-active,
.chat-input-container.drag-active {
    border-color: var(--accent);
    background: rgba(99, 102, 241, 0.08);
}

/* ===========================================
   リッチ結果表示
   =========================================== */
.result-rich h1,
.result-rich h2,
.result-rich h3 {
    margin-top: 1rem;
    margin-bottom: 0.5rem;
}

.result-rich h1 {
    font-size: 1.4rem;
}

.result-rich h2 {
    font-size: 1.2rem;
}

.result-rich h3 {
    font-size: 1.05rem;
}

.result-rich ul,
.result-rich ol {
    padding-left: 1.5rem;
    margin: 0.5rem 0;
}

.result-rich code {
    background: rgba(0, 0, 0, 0.3);
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    font-size: 0.9em;
}

.result-rich strong {
    color: var(--accent-hover);
}

.result-rich a {
    color: var(--accent-hover);
    text-decoration: none;
}

.result-rich a:hover {
    text-decoration: underline;
}

/* ===========================================
   レビューUI
   =========================================== */
.review-block {
    background: rgba(99, 102, 241, 0.06);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    margin: 1rem 0;
    max-width: 800px;
    width: 100%;
    margin-left: auto;
    margin-right: auto;
}

.review-block h3 {
    margin-bottom: 0.75rem;
}

.review-block textarea {
    width: 100%;
    min-height: 80px;
    padding: 0.75rem;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: var(--font);
    font-size: 0.95rem;
    resize: vertical;
    outline: none;
    margin-bottom: 0.75rem;
}

.review-block textarea:focus {
    border-color: var(--border-focus);
}

.review-submit-btn {
    background: var(--accent);
    color: white;
    border: none;
    padding: 0.6rem 1.5rem;
    border-radius: var(--radius-sm);
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
}

.review-submit-btn:hover {
    background: var(--accent-hover);
}

/* ===========================================
   ソースリンク
   =========================================== */
.source-link {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--accent-hover);
    text-decoration: none;
    font-size: 0.9rem;
    transition: all var(--transition);
    margin: 0.25rem 0;
    max-width: 800px;
    width: 100%;
    margin-left: auto;
    margin-right: auto;
}

.source-link:hover {
    background: var(--surface-hover);
    border-color: var(--accent);
    transform: translateX(4px);
}

/* ===========================================
   バッジ
   =========================================== */
.badge-type {
    display: inline-block;
    padding: 2px 8px;
    border-radius: var(--radius-full);
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
}

.badge-code {
    background: #22c55e;
    color: white;
    padding: 2px 8px;
    border-radius: var(--radius-full);
    font-size: 0.7rem;
    font-weight: 700;
    border: none;
    cursor: pointer;
}

.badge-prompt {
    background: var(--accent);
    color: white;
}

.badge-api {
    background: var(--warning);
    color: #000;
}

.badge-auto {
    background: #0d9488;
    color: white;
}

/* ===========================================
   モーダル
   =========================================== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(6px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.2s ease;
}

.modal-content {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    width: 90%;
    max-width: 900px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-lg);
    animation: scaleIn 0.3s ease;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem 2rem;
    border-bottom: 1px solid var(--border);
}

.modal-header h2 {
    font-size: 1.2rem;
    font-weight: 700;
}

.close-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.8rem;
    cursor: pointer;
    line-height: 1;
    transition: color var(--transition);
}

.close-btn:hover {
    color: var(--text-primary);
}

.modal-body {
    padding: 1.5rem 2rem;
    overflow-y: auto;
    flex: 1;
}

.modal-actions-bar {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px dashed var(--border);
}

.action-btn-primary,
.action-btn-success,
.action-btn-danger {
    padding: 0.6rem 1.25rem;
    border: none;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all var(--transition);
    color: white;
}

.action-btn-primary {
    background: var(--accent);
}

.action-btn-success {
    background: var(--success);
}

.action-btn-danger {
    background: var(--error);
}

.action-btn-primary:hover {
    filter: brightness(1.15);
}

.action-btn-success:hover {
    filter: brightness(1.15);
}

.action-btn-danger:hover {
    filter: brightness(1.15);
}

.modal-proposals-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 1rem;
}

.modal-proposal-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    transition: all var(--transition);
    display: flex;
    flex-direction: column;
}

.modal-proposal-card:hover {
    transform: translateY(-2px);
    background: var(--surface-hover);
}

.modal-proposal-card pre {
    background: rgba(0, 0, 0, 0.35);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 1rem;
    margin: 1rem 0;
    max-height: 250px;
    overflow-y: auto;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 0.9rem;
    line-height: 1.6;
    color: #c4d0e0;
}

.modal-proposal-card pre code {
    white-space: pre-wrap;
    word-break: break-all;
    display: block;
}

.modal-card-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    margin-top: auto;
    padding-top: 1rem;
}

.btn-copy {
    background: rgba(99, 102, 241, 0.1);
    border: 1px solid var(--accent);
    color: var(--accent-hover);
    padding: 0.4rem 1rem;
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
}

.btn-copy:hover {
    background: var(--accent);
    color: white;
}


/* ===========================================
   アニメーション
   =========================================== */
@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes msgIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes float {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-10px);
    }
}

/* ===========================================
   レスポンシブ
   =========================================== */
@media (max-width: 768px) {

    .sidebar {
        position: fixed;
        z-index: 50;
        height: 100vh;
    }

    .main-header {
        padding-left: 4rem;
    }

    .chat-area>div {
        max-width: 100%;
    }

    .input-container {
        max-width: 100%;
    }

    .select-inline {
        display: none;
    }

    .compact-picker {
        position: relative;
        z-index: 3;
    }

    .runtime-toggle-row {
        gap: 0.4rem 0.65rem;
        padding: 0.5rem 0.65rem;
    }

    .composer-tools-grid {
        grid-template-columns: 1fr;
    }

    .composer-tools-panel {
        width: min(94vw, 520px);
        max-height: 62vh;
        transform-origin: bottom center;
    }

    .composer-media-actions {
        flex-direction: column;
    }

    .composer-mini-btn {
        width: 100%;
        text-align: center;
    }

    .runtime-toggle-save {
        margin-left: 0;
        width: 100%;
        justify-content: center;
    }

    .cafe-grid {
        grid-template-columns: 1fr;
    }
}

/* Agent 切り替えタブ */
.agent-tabs {
    display: flex;
    gap: 8px;
    margin-left: 20px;
}

.agent-tab {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #fff;
    padding: 4px 12px;
    border-radius: 12px;
    cursor: pointer;
    transition: 0.2s;
}

.agent-tab.active {
    background: rgba(255, 255, 255, 0.2);
    font-weight: bold;
}

.agent-tab:hover {
    background: rgba(255, 255, 255, 0.1);
}

.agent-view {
    display: none;
    flex: 1;
    overflow: hidden;
    flex-direction: column;
    height: 100%;
}

.agent-view.active {
    display: flex;
}

/* Cafe Layout */
.cafe-layout {
    height: 100%;
    overflow-y: auto;
    padding: 24px;
}

.cafe-panel {
    max-width: 920px;
    margin: 0 auto;
}

.cafe-title {
    font-size: 1.35rem;
    margin-bottom: 0.35rem;
}

.cafe-subtitle {
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

.cafe-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}

.cafe-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.cafe-field label {
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.cafe-field-wide {
    grid-column: 1 / -1;
}

.cafe-checks {
    justify-content: center;
    gap: 8px;
}

.cafe-checks label {
    font-size: 0.85rem;
    color: var(--text-primary);
}

.cafe-actions {
    margin-top: 14px;
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.cafe-result {
    margin-top: 10px;
    min-height: 220px;
    max-height: 420px;
    overflow: auto;
    padding: 14px;
    border-radius: 10px;
    background: rgba(2, 6, 23, 0.75);
    border: 1px solid rgba(148, 163, 184, 0.2);
    color: #dbeafe;
    font-family: Consolas, Monaco, 'Courier New', monospace;
    font-size: 0.82rem;
    line-height: 1.5;
}

/* Studio Layout */
.studio-layout {
    display: flex;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

.studio-sidebar {
    width: 220px;
    padding: 16px;
    border-right: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    flex-direction: column;
}

.studio-main {
    flex: 1;
    padding: 24px;
    overflow-y: auto;
    background: rgba(0, 0, 0, 0.1);
}

.view-section {
    display: none;
}

.view-section.active {
    display: block;
}

.nav-menu {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.nav-item {
    padding: 12px;
    color: rgba(255, 255, 255, 0.8);
    text-decoration: none;
    border-radius: 6px;
    transition: 0.2s;
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 500;
}

.nav-item:hover,
.nav-item.active {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

.glass-panel {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(10px);
}

.hidden {
    display: none !important;
}

.mt-4 {
    margin-top: 16px;
}

.glass-input {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: #fff;
    padding: 10px;
    border-radius: 6px;
    font-family: inherit;
}

.glass-input:focus {
    outline: none;
    border-color: rgba(255, 255, 255, 0.4);
}

.primary-btn {
    background: linear-gradient(135deg, #3742fa, #5352ed);
}

.success-btn {
    background: linear-gradient(135deg, #2ed573, #7bed9f);
    color: #2f3542;
}

.warning-btn {
    background: linear-gradient(135deg, #ffa502, #eccc68);
    color: #2f3542;
}

.danger-btn {
    background: linear-gradient(135deg, #ff4757, #ff6b81);
}

.glow {
    box-shadow: 0 0 15px rgba(255, 255, 255, 0.1);
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 16px;
}

.stat-card {
    display: flex;
    align-items: center;
    gap: 16px;
}

.stat-icon {
    font-size: 2em;
    color: rgba(255, 255, 255, 0.8);
}

.stat-info h3 {
    margin: 0;
    font-size: 0.9em;
    color: rgba(255, 255, 255, 0.6);
    font-weight: 500;
}

.stat-value {
    margin: 4px 0 0 0;
    font-size: 1.5em;
    font-weight: bold;
}

.gradient-text {
    background: linear-gradient(135deg, #7bed9f, #2ed573);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.cost-value {
    color: #ffa502;
}

.status-indicator {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
    margin-right: 6px;
}

.status-indicator.online {
    background: #2ed573;
    box-shadow: 0 0 8px #2ed573;
}

.agent-status {
    margin-top: auto;
    padding-top: 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    font-size: 0.9em;
    color: rgba(255, 255, 255, 0.6);
}

/* Loader */
.loader {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.spinner {
    width: 24px;
    height: 24px;
    border: 3px solid rgba(255, 255, 255, 0.1);
    border-top-color: #3742fa;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}









/* ===========================================
   Artist Room
   =========================================== */

#artistAgentContent {
    background: radial-gradient(circle at top right, rgba(139, 92, 246, 0.15), transparent 40%),
        radial-gradient(circle at bottom left, rgba(99, 102, 241, 0.15), transparent 40%);
}

.artist-layout {
    height: 100%;
    padding: 2rem;
    overflow-y: auto;
}

.artist-panel {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2.5rem;
    animation: slideUp 0.5s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.artist-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 0.5rem;
}

.artist-title {
    font-size: 2rem;
    font-weight: 800;
    color: var(--text-primary);
    letter-spacing: -0.02em;
}

.artist-subtitle {
    color: var(--text-secondary);
    margin-bottom: 2.5rem;
    font-size: 1.1rem;
}

.artist-main-grid {
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: 2rem;
}

.artist-chat-container {
    display: flex;
    flex-direction: column;
    height: 600px;
    background: rgba(15, 23, 42, 0.4);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

#artistLogOutput {
    flex: 1;
    padding: 1.5rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.welcome-screen {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    color: var(--text-secondary);
}

.welcome-icon-wrapper {
    width: 80px;
    height: 80px;
    background: var(--accent-gradient);
    border-radius: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1.5rem;
    box-shadow: 0 8px 24px rgba(99, 102, 241, 0.3);
}

.welcome-icon {
    font-size: 2.5rem;
    color: white;
}

.welcome-suggestions {
    display: flex;
    gap: 0.75rem;
    margin-top: 2rem;
}

.suggestion-chip {
    padding: 0.6rem 1.2rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-full);
    color: var(--text-primary);
    font-size: 0.9rem;
    cursor: pointer;
    transition: all var(--transition);
}

.suggestion-chip:hover {
    background: var(--surface-hover);
    border-color: var(--accent);
    transform: translateY(-2px);
}

.artist-skills-sidebar {
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.sidebar-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.skill-group {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.skill-item {
    padding: 1rem;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.skill-item strong {
    color: var(--accent-hover);
    font-size: 0.95rem;
}

.skill-item span {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.agent-status-card {
    margin-top: auto;
    padding: 1rem;
    background: rgba(16, 185, 129, 0.1);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--success);
    font-size: 0.9rem;
    font-weight: 600;
}

.status-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.status-indicator.online {
    background: var(--success);
    box-shadow: 0 0 10px var(--success);
}

.badge.purple {
    background: rgba(168, 85, 247, 0.2);
    color: #c084fc;
    border: 1px solid rgba(168, 85, 247, 0.4);
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@media (max-width: 1024px) {
    .artist-main-grid {
        grid-template-columns: 1fr;
    }
}