/* ===========================
   CSS カスタムプロパティ（nani風）
   =========================== */
:root {
    /* カラー */
    --bg: #f6f8fb;
    --surface: #ffffff;
    --border: #e8ecf2;
    --text: #0f1419;
    --text-secondary: #536471;
    --text-muted: #8b98a5;
    --accent: #2b8af6;
    --accent-hover: #1e70f0;
    --accent-light: #e8f3ff;
    
    /* タイポグラフィ */
    --font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Noto Sans JP', 'Helvetica Neue', sans-serif;
    
    /* スペーシング */
    --spacing-xs: 4px;
    --spacing-sm: 8px;
    --spacing-md: 12px;
    --spacing-lg: 16px;
    --spacing-xl: 24px;
    
    /* 角丸 */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --radius-xl: 18px;
    
    /* シャドウ */
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 2px 8px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.1);
}

/* ===========================
   リセット
   =========================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
    overflow: hidden;
}

body {
    font-family: var(--font-family);
    font-size: 15px;
    line-height: 1.6;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
}

/* ===========================
   モバイルヘッダー / ドロワー
   =========================== */
.mobile-header {
    display: none;
    height: 52px;
    padding: 0 10px;
    background: #ffffff;
    border-bottom: 1px solid var(--border);
    align-items: center;
    gap: 8px;
}

.mobile-menu-btn {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text-secondary);
}

.mobile-header-title {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
}

.mobile-header-actions {
    margin-left: auto;
    display: inline-flex;
    gap: 6px;
}

.mobile-drawer-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.35);
    display: none;
    z-index: 1500;
}

/* ドロワー化されたサイドバーアニメーション */
.sidebar.drawer {
    position: fixed;
    top: 52px; /* header 高さ */
    left: 0;
    height: calc(100vh - 52px);
    z-index: 1501;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    box-shadow: var(--shadow-lg);
}

.sidebar.drawer.open {
    transform: translateX(0);
}

button {
    font-family: inherit;
    cursor: pointer;
    border: none;
    background: none;
    outline: none;
}

/* ===========================
   レイアウト
   =========================== */
#app {
    height: 100vh;
    display: flex;
    flex-direction: column;
}

.app-container {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* ===========================
   左サイドバー
   =========================== */
.sidebar {
    width: 260px;
    background: #ffffff;
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 12px;
}

.sidebar-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--spacing-lg);
    padding: 4px;
}

.app-logo {
    cursor: pointer;
    transition: transform 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.app-name {
    font-size: 16px;
    font-weight: 700;
    color: var(--text);
    letter-spacing: 0.5px;
}

.app-logo:hover {
    transform: scale(1.05);
}

.sidebar-actions {
    display: flex;
    gap: 6px;
}

.sidebar-new-btn {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    transition: all 0.2s;
}

.sidebar-new-btn:hover {
    background: var(--accent-light);
    border-color: var(--accent);
    color: var(--accent);
}

/* サイドバーセクション */
.sidebar-section {
    flex: 1;
    overflow-y: auto;
    margin-bottom: var(--spacing-md);
}


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

/* 未ログイン時CTA（サイドバー下部、フッターの10px上） */
.free-cta {
    position: sticky;
    bottom: calc(48px + 10px); /* フッター高さ(概ね48px) + 10px */
    padding-top: 8px;
    padding-bottom: 8px;
    background: linear-gradient(to top, var(--surface) 70%, rgba(255, 255, 255, 0));
    z-index: 5;
}

.sidebar-section.has-cta .history-list {
    /* CTAが重ならないように下余白を確保（CTA高さ分） */
    padding-bottom: 80px;
}

.btn-cta {
    display: block;
    width: 100%;
    padding: 10px 14px;
    border-radius: 999px;
    background: var(--accent);
    color: #fff;
    font-weight: 700;
    text-align: center;
    box-shadow: 0 2px 6px rgba(43, 138, 246, 0.35);
    transition: all 0.2s;
}

.btn-cta:hover {
    background: var(--accent-hover);
    transform: translateY(-1px);
}

.history-item {
    padding: 10px 36px 10px 12px;
    border-radius: 8px;
    font-size: 14px;
    color: var(--text);
    background: transparent;
    transition: all 0.15s;
    cursor: pointer;
    text-align: left;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.history-item:hover {
    background: var(--surface);
}

.history-item.active {
    background: var(--accent-light);
    font-weight: 500;
}

.history-item-text {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.history-item-delete {
    position: absolute;
    right: 4px;
    width: 28px;
    height: 28px;
    display: none;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    background: transparent;
    color: var(--text-muted);
    transition: all 0.15s;
    flex-shrink: 0;
}

.history-item:hover .history-item-delete {
    display: flex;
}

.history-item-delete:hover {
    background: #ef4444;
    color: white;
    transform: scale(1.05);
}

/* サイドバーフッター */
.sidebar-footer {
    display: flex;
    gap: 6px;
    padding-top: 8px;
    border-top: 1px solid var(--border);
}

.sidebar-footer-btn {
    flex: 0 0 auto;
    padding: 8px;
    border-radius: 8px;
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    font-size: 13px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sidebar-footer-btn:hover {
    background: var(--bg);
}

/* 利用回数UIアイコンの微調整 */
.sidebar-footer-btn svg {
    display: block;
}

/* 円グラフ（UIのみ） - 10 / 30 = 33.33% */
.usage-pie {
    --used: 10;
    --max: 30;
    --ratio: calc(var(--used) / var(--max));
    --deg: calc(var(--ratio) * 360deg);
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background:
      conic-gradient(
        var(--accent) 0deg var(--deg),
        #e5e7eb var(--deg) 360deg
      );
    display: inline-block;
    position: relative;
}

.usage-pie::after {
    content: "";
    position: absolute;
    inset: 4px;
    background: var(--surface);
    border-radius: 50%;
}

.usage-pie::before {
    content: attr(data-left);
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 9px;
    color: var(--text-secondary);
    z-index: 1;
}

/* サイドバーフッターの画像ボタン */
.sidebar-footer-btn img {
    display: block;
    width: 24px;
    height: 24px;
    object-fit: contain;
}

/* 初期非表示（JSで表示切替） */
#freeStartCta,
#emptyLinks,
#jumpToBottomBtn,
#jumpToBottomResultsBtn,
#provider-ibapi,
#provider-openai,
#provider-gemini,
#voice-iblink,
#voice-webspeech,
#loginModal,
#ibInfoModal,
#promptSettingsModal,
#accountInfoLoggedIn,
#accountInfoLoggedOut {
    display: none;
}

/* 設定モーダル見出し内リンク */
.modal-header-link {
    margin-left: auto;
    margin-right: 8px;
    font-size: 13px;
    color: var(--text-secondary);
    text-decoration: underline;
}
.modal-header-link:hover { color: var(--accent); }


/* ===========================
   メインコンテンツ
   =========================== */
.main-content {
    flex: 1;
    overflow: hidden;
    padding: 20px;
}

.content-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    height: 100%;
    overflow: hidden;
    margin-top: 0;
    margin-bottom: 0;
    align-items: stretch; /* 各列を同じ高さで伸ばす */
}

/* ===========================
   入力パネル
   =========================== */
.input-panel {
    display: flex;
    flex-direction: column;
    min-height: 0; /* グリッド内での過伸長を防ぎ内部スクロールに委譲 */
}

.panel-card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    height: 100%;
    max-height: none; /* 余白発生の原因となる上限を解除 */
    min-height: 0;
}

.panel-toolbar {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 12px;
}


.toolbar-title-input {
    flex: 1;
    padding: 6px 12px;
    border-radius: 8px;
    background: transparent;
    border: none;
    color: var(--text);
    font-size: 14px;
    font-family: inherit;
    transition: all 0.2s;
    outline: none;
}

.toolbar-title-input:focus {
    background: transparent;
}

.toolbar-title-input::placeholder {
    color: var(--text-muted);
}

.toolbar-mic-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--surface);
    border: 2px solid var(--border);
    color: var(--text-secondary);
    transition: all 0.2s;
    flex-shrink: 0;
    cursor: pointer;
}

.toolbar-mic-btn:hover {
    background: var(--accent-light);
    border-color: var(--accent);
    color: var(--accent);
}

/* タイトル横のAI鉛筆ボタン */
.toolbar-title-ai-btn {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    transition: all 0.2s;
    flex-shrink: 0;
}

.toolbar-title-ai-btn:hover {
    background: var(--accent-light);
    border-color: var(--accent);
    color: var(--accent);
}

.toolbar-title-ai-btn.processing {
    opacity: 0.7;
    cursor: not-allowed;
}

.toolbar-mic-btn.recording {
    background: #ef4444;
    border-color: #ef4444;
    color: white;
    animation: pulse-mic 1.5s ease-in-out infinite;
}

@keyframes pulse-mic {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4);
    }
    50% {
        transform: scale(1.05);
        box-shadow: 0 0 0 8px rgba(239, 68, 68, 0);
    }
}

.textarea-wrapper {
    position: relative;
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.panel-textarea {
    width: 100%;
    height: 100%;
    border: none;
    outline: none;
    padding: 16px;
    font-family: inherit;
    font-size: 15px;
    line-height: 1.6;
    color: var(--text);
    background: transparent;
    overflow-y: auto;
    white-space: pre-wrap;
    word-break: break-word;
}

/* 一番下へ移動ボタン */
.jump-to-bottom-btn {
    position: absolute;
    left: 50%;
    bottom: 10px;
    transform: translateX(-50%);
    width: 36px;
    height: 36px;
    border-radius: 999px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    box-shadow: var(--shadow-sm);
    transition: all 0.2s;
    z-index: 20;
}

.jump-to-bottom-btn:hover {
    background: var(--accent-light);
    border-color: var(--accent);
    color: var(--accent);
    box-shadow: var(--shadow-md);
}

/* contenteditable用のプレースホルダー */
.panel-textarea[contenteditable="true"]:empty::before {
    content: attr(data-placeholder);
    color: var(--text-muted);
    pointer-events: none;
}

.panel-textarea[contenteditable="true"]:focus {
    outline: none;
}

/* 書式設定のスタイル */
.panel-textarea h1,
.panel-textarea h2,
.panel-textarea h3 {
    margin: 0.5em 0;
    font-weight: 600;
}

.panel-textarea h1 {
    font-size: 2em;
}

.panel-textarea h2 {
    font-size: 1.5em;
}

.panel-textarea h3 {
    font-size: 1.25em;
}

.panel-textarea ul,
.panel-textarea ol {
    margin: 0.5em 0;
    padding-left: 1.5em;
}

.panel-textarea li {
    margin: 0.25em 0;
}

.panel-textarea p {
    margin: 0.5em 0;
}

/* 区切り線 */
.panel-textarea hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 12px 0;
}

.interim-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    padding: 12px 16px;
    margin: 16px;
    pointer-events: none;
    z-index: 10;
}

.interim-overlay .interim-bubble {
    display: inline-block;
    background: rgba(43, 138, 246, 0.95);
    color: #fff;
    padding: 6px 8px;
    border-radius: 6px;
    font-style: normal;
    white-space: pre-wrap;
    word-break: break-word;
    box-shadow: 0 4px 16px rgba(43, 138, 246, 0.3);
    backdrop-filter: blur(8px);
}


.settings-menu-item {
    padding: 8px 12px;
    border-radius: 8px;
    transition: background 0.2s;
}

.settings-menu-item:hover {
    background: var(--bg);
}

.settings-checkbox {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    font-size: 14px;
    color: var(--text);
}

.settings-checkbox input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--accent);
}

.settings-label {
    display: block;
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 6px;
    font-weight: 600;
}

.settings-select {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    font-family: inherit;
    cursor: pointer;
    outline: none;
    transition: all 0.2s;
}

.settings-select:hover {
    border-color: var(--accent);
}

.settings-select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(43, 138, 246, 0.1);
}

/* 書式設定ツールバー */
.format-toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 8px;
    background: var(--bg-secondary);
    border-bottom: 0.5px solid var(--border);
}

.format-group {
    display: flex;
    align-items: center;
    gap: 2px;
}

.format-divider {
    width: 1px;
    height: 20px;
    background: var(--border);
    margin: 0 4px;
}

.format-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 6px 8px;
    border-radius: 6px;
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 600;
    transition: all 0.15s;
    background: transparent;
    min-width: 28px;
}

.format-btn:hover {
    background: var(--hover);
    color: var(--text-primary);
}

.format-btn:active {
    transform: scale(0.95);
}

.format-btn svg {
    display: block;
}

/* 文字色カラーピッカー */
.format-color-input {
    width: 28px;
    height: 28px;
    padding: 0;
    border: none;
    background: transparent;
    cursor: pointer;
    border-radius: 6px;
}
.format-color-input:hover {
    outline: 2px solid var(--hover);
}


/* ===========================
   結果パネル
   =========================== */
.result-panel {
    overflow: hidden;
    min-height: 0; /* グリッド内での高さ計算のため */
    position: relative;
}

.result-scroll {
    height: 100%;
    overflow-y: auto;
    padding-right: 4px;
    display: flex;
    flex-direction: column;
}

/* 空状態リンク集 */
.empty-links { padding: 16px 4px 12px 4px; margin-top: auto; }
.empty-links-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 20px; color: var(--text-secondary); max-width: 900px; margin: 0 auto; justify-items: center; text-align: center; }
.empty-brand {
    font-weight: 800;
    color: var(--text);
}
.empty-desc { margin: 6px 0 0 0; }
.empty-heading { font-weight: 700; color: var(--text); margin-bottom: 6px; }
.empty-links ul { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.empty-links a { color: var(--text-secondary); text-decoration: none; }
.empty-links a:hover { color: var(--accent); text-decoration: underline; }

@media (max-width: 800px) {
    .empty-links-grid { grid-template-columns: 1fr; }
}

.result-cards {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.result-card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    padding: 16px 16px 0px 16px;
    transition: all 0.2s;
}

.result-card:hover {
    box-shadow: var(--shadow-md);
}

/* チャット（共通） */
.chat-card-user,
.chat-card-assistant {
    max-width: 80%;
    padding: 8px 14px 8px 14px;

    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    transition: box-shadow 0.2s, transform 0.2s;
}
.chat-card-user:hover,
.chat-card-assistant:hover { box-shadow: var(--shadow-md); }

/* ユーザー/アシスタント個別 */
.chat-card-user {
    align-self: flex-end;
    background: #008CF0;
    border-color: #008CF0;
    color: #fff;
}
.chat-card-assistant {
    align-self: flex-start;
    background: var(--surface);
    border-color: var(--border);
    color: var(--text);
    padding: 8px 16px 8px 16px;
}

/* チャット本文（.result-main-text を踏襲） */
.chat-card-user .result-main-text,
.chat-card-assistant .result-main-text {
    font-size: 15px;
    font-weight: 400;
    color: var(--text);
    line-height: 1.6;
    margin: 0; /* 余白はchat-cardのpaddingに集約 */
}
.chat-card-user .result-main-text { color: #fff; }
.chat-card-user .result-main-text a { color: #fff; text-decoration: underline; }

.result-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.result-avatar {
    width: 32px;
    height: 32px;
    flex-shrink: 0;
}

.result-badge {
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 500;
}

.result-main-text {
    font-size: 15px;
    font-weight: 400;
    color: var(--text);
    line-height: 1.6;
    margin-bottom: 8px;
}

/* result-main-text内のMarkdownスタイル */
.result-main-text h1,
.result-main-text h2,
.result-main-text h3,
.result-main-text h4,
.result-main-text h5,
.result-main-text h6 {
    margin: 0.8em 0 0.4em 0;
    font-weight: 600;
    line-height: 1.4;
}

.result-main-text h1 {
    font-size: 1.6em;
}

.result-main-text h2 {
    font-size: 1.4em;
}

.result-main-text h3 {
    font-size: 1.2em;
}

.result-main-text h4,
.result-main-text h5,
.result-main-text h6 {
    font-size: 1em;
}

.result-main-text p {
    margin: 0.5em 0;
}

.result-main-text ul,
.result-main-text ol {
    margin: 0.5em 0;
    padding-left: 1.5em;
}

.result-main-text li {
    margin: 0.25em 0;
}

.result-main-text pre {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 12px;
    overflow-x: auto;
    margin: 0.5em 0;
}

.result-main-text code {
    background: var(--bg);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 0.9em;
}

.result-main-text pre code {
    background: transparent;
    padding: 0;
}

.result-main-text blockquote {
    border-left: 3px solid var(--accent);
    padding-left: 12px;
    margin: 0.5em 0;
    color: var(--text-secondary);
}

.result-main-text hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 12px 0;
}

.result-main-text a {
    color: var(--accent);
    text-decoration: none;
}

.result-main-text a:hover {
    text-decoration: underline;
}

.result-main-text table {
    border-collapse: collapse;
    width: 100%;
    margin: 0.5em 0;
}

.result-main-text th,
.result-main-text td {
    border: 1px solid var(--border);
    padding: 8px;
    text-align: left;
}

.result-main-text th {
    background: var(--bg);
    font-weight: 600;
}

.result-main-text strong {
    font-weight: 600;
}

.result-main-text em {
    font-style: italic;
}

.result-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 10px;
}

/* チャットカード内のコピーアクションの色調整 */
.chat-card-user .result-action-btn { color: rgba(255,255,255,0.9); }
.chat-card-user .result-action-btn:hover { background: rgba(255,255,255,0.15); }

.result-action-btn {
    padding: 6px 8px;
    border-radius: 6px;
    color: var(--text-secondary);
    background: transparent;
    transition: all 0.2s;
}

.result-action-btn:hover {
    background: var(--bg);
}


.result-variants {
    list-style: none;
    padding: 0;
    margin: 0 0 10px 0;
}

.result-variants li {
    padding-left: 16px;
    position: relative;
    font-size: 15px;
    color: var(--text);
    line-height: 1.6;
    margin-bottom: 6px;
}

.result-variants li::before {
    content: "•";
    position: absolute;
    left: 0;
    color: var(--accent);
    font-weight: bold;
}

.summary-action-item {
    position: relative;
    display: flex;
    align-items: center;
    padding: 10px 48px 10px 12px;
    background: linear-gradient(135deg, rgba(43, 138, 246, 0.05) 0%, rgba(168, 85, 247, 0.05) 100%);
    border: 1px solid transparent;
    border-radius: 12px;
    font-size: 15px;
    color: var(--text);
    cursor: pointer;
    transition: all 0.2s;
    width: 100%;
    text-align: left;
}

.summary-action-item:hover {
    background: linear-gradient(135deg, rgba(43, 138, 246, 0.1) 0%, rgba(168, 85, 247, 0.1) 100%);
    border-color: var(--accent);
    transform: translateY(-1px);
}

.summary-action-item > span {
    flex: 1;
}

.summary-question-item {
    position: relative;
    display: flex;
    align-items: center;
    gap: 8px;
}

.summary-question-input {
    flex: 1;
    padding: 10px 16px;
    padding-right: 48px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    font-size: 15px;
    color: var(--text);
    font-family: inherit;
    outline: none;
    transition: all 0.2s;
}

.summary-question-input:focus {
    background: var(--surface);
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(43, 138, 246, 0.1);
}

.summary-question-input::placeholder {
    color: var(--text-muted);
}

.summary-question-submit {
    position: absolute;
    right: 8px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #8e9093;
    border: none;
    border-radius: 8px;
    color: white;
    cursor: pointer;
    transition: all 0.2s;
}

.summary-question-submit:hover {
    background: #757779;
    transform: scale(1.05);
}

.summary-question-submit svg {
    width: 16px;
    height: 16px;
}

/* 質問カード */
.question-card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    padding: 16px;
    transition: all 0.2s;
}

.question-card:hover {
    box-shadow: var(--shadow-md);
}

.question-card .summary-question-item {
    margin: 0;
}


/* ===========================
   スクロールバー
   =========================== */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* ===========================
   レスポンシブ
   =========================== */
@media (max-width: 1200px) {
    .content-grid {
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr;
    }
    
    .panel-card {
        max-height: 400px;
    }
}

@media (max-width: 968px) {
    .mobile-header { display: flex; }
    .sidebar { display: none; }
    .sidebar.drawer { display: flex; }
    
    .main-content {
        padding: 12px;
    }
}

/* ===========================
   アクセシビリティ
   =========================== */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

button:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* ===========================
   モーダル（UIのみ）
   =========================== */
.modal {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: none;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 20, 25, 0.4);
}

.modal-dialog {
    position: relative;
    width: 640px;
    max-width: calc(100vw - 32px);
    max-height: calc(100vh - 96px);
    margin: 48px auto;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 14px;
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
}

.modal-close {
    font-size: 20px;
    line-height: 1;
    color: var(--text-secondary);
    padding: 6px 8px;
    border-radius: 8px;
}

.modal-close:hover { background: var(--bg); }

.modal-body {
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    overflow-y: auto;
    flex: 1;
    min-height: 0;
}

.modal-section-title {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.modal-footer {
    padding: 12px 16px;
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    border-top: 1px solid var(--border);
}

.segmented {
    display: inline-flex;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 4px;
    gap: 4px;
}

.segmented-btn {
    padding: 8px 12px;
    border-radius: 8px;
    color: var(--text-secondary);
    background: transparent;
}

.segmented-btn.active, .segmented-btn:hover { 
    background: var(--surface); 
    color: var(--text);
}

.provider-panel { 
    margin-top: 12px; 
    padding: 12px; 
    border: 1px solid var(--border); 
    border-radius: 10px; 
    background: var(--surface);
}

.inline-field { display: flex; gap: 8px; align-items: center; }
.inline-field.right { justify-content: flex-end; }
.inline-field.space-between { justify-content: space-between; }
.inline-status { min-height: 18px; }

.settings-input {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg);
    font-size: 14px;
    color: var(--text);
}

/* モーダル内でAPIキー入力欄をモデル選択と同じ横幅に揃える */
.provider-panel .settings-input {
    width: 100%;
}

.btn-primary {
    padding: 10px 14px;
    border-radius: 10px;
    background: var(--accent);
    color: #fff;
    font-weight: 600;
}

/* ユーティリティ */
.m-0 { margin: 0; }
.mb-3 { margin-bottom: 3px; }
.mb-12 { margin-bottom: 12px; }
.mt-8 { margin-top: 8px; }
.mr-8 { margin-right: 8px; }
.text-center { text-align: center; }
.text-muted-sm { font-size: 0.85em; color: #666; }
.w-max { width: max-content; }
.flex-row-12-center { display: flex; gap: 12px; align-items: center; }

.btn-primary.disabled,
.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-secondary {
    padding: 8px 12px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
}

/* 通信テストの成功/失敗表示用 */
#iblinkTestStatus {
    margin-top: 6px;
    min-height: 18px;
}
#iblinkTestStatus.success { color: #16a34a; }
#iblinkTestStatus.error { color: #dc2626; }

/* 音声用テスト結果 */
#iblinkVoiceTestStatus {
    margin-top: 6px;
    min-height: 18px;
}
#iblinkVoiceTestStatus.success { color: #16a34a; }
#iblinkVoiceTestStatus.error { color: #dc2626; }

.btn-muted {
    padding: 10px 14px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-secondary);
}

.note { font-size: 12px; color: var(--text-secondary); margin-top: 8px; }

/* スピナーアニメーション */
@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* .summary-action-item .spinner は未使用（JSで .spinner-circle を使用）。ルール自体を削除 */

/* 確実に視認しやすい純CSSボーダースピナー */
.spinner-circle {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid currentColor;
    border-right-color: transparent; /* 一部を透過して回転感を出す */
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    vertical-align: middle;
    margin-left: 8px;
}

.summary-action-item.processing {
    opacity: 0.7;
    cursor: not-allowed;
}

/* 考え中のドットアニメーション */
.thinking-dots {
    color: var(--text-secondary);
}

.thinking-dots .dot {
    animation: thinking-fade 1.4s infinite;
    opacity: 0;
}

.thinking-dots .dot:nth-child(1) {
    animation-delay: 0s;
}

.thinking-dots .dot:nth-child(2) {
    animation-delay: 0.2s;
}

.thinking-dots .dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes thinking-fade {
    0%, 100% { opacity: 0; }
    50% { opacity: 1; }
}

/* プロンプト設定ボタン */
.summary-settings-btn {
    position: absolute;
    right: 8px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #8e9093;
    border: none;
    border-radius: 8px;
    color: white;
    cursor: pointer;
    transition: all 0.2s;
}

.summary-settings-btn:hover {
    background: #757779;
    transform: scale(1.05);
}

.summary-settings-btn svg {
    width: 16px;
    height: 16px;
}

/* プロンプト設定用テキストエリア */
.prompt-textarea {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    font-family: inherit;
    line-height: 1.6;
    resize: vertical;
    outline: none;
    transition: all 0.2s;
}

.prompt-textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(43, 138, 246, 0.1);
}

.prompt-textarea::placeholder {
    color: var(--text-muted);
}

/* チャットカードのヘッダー（アイコン・「アシスタント」バッジ）を非表示 */
.chat-card-user .result-header,
.chat-card-assistant .result-header {
    display: none !important;
}

/* ===========================
   アカウント情報セクション
   =========================== */
/* 新しいアカウント情報カード */
.account-info-card-new {
    background: transparent;
    border-radius: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.account-info-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.account-info-left {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
}

.account-avatar {
    width: 48px;
    height: 48px;
    background: #5b8def;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    flex-shrink: 0;
}

.account-info-text {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.account-plan-new {
    font-size: 14px;
    font-weight: 500;
    color: #1a1a1a;
}

.btn-logout {
    padding: 8px 16px;
    background: #4285f4;
    color: white;
    border: none;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
    flex-shrink: 0;
    white-space: nowrap;
}

.btn-logout:hover {
    background: #3367d6;
}

.account-usage-section {
    position: relative;
    background: transparent;
    border: none;
    border-radius: 0;
    padding: 0;
}

.usage-month-label {
    position: static;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.account-usage-badges {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    flex-direction: column;
}

.usage-badge-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 0;
    background: transparent;
    border: none;
    border-radius: 0;
    font-size: 13px;
}

.usage-label {
    color: var(--text-secondary);
}

.usage-value {
    font-weight: 600;
    color: #1a1a1a;
}

.usage-unit {
    color: var(--text-secondary);
    margin-left: 4px;
}

/* 残り回数の丸囲みバッジ */
.usage-remaining-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    height: 40px;
    padding: 0 10px;
    border-radius: 999px;
    background: var(--surface);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    font-weight: 700;
    color: var(--text);
    font-size: 14px;
}

.usage-remaining-pill .label { margin-right: 8px; color: var(--text-secondary); font-weight: 600; }
.usage-remaining-pill .num { font-size: 14px; line-height: 1; }

.usage-remaining-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.usage-remaining-label {
    font-size: 13px;
    color: var(--text-secondary);
}

.usage-ratio-text { 
    margin-left: 20px;
    margin-top: 2px; font-size: 14px; color: var(--text-secondary); }

.account-login-prompt {
    background: var(--bg);
    border-radius: 12px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    text-align: center;
}

.account-login-text {
    font-size: 14px;
    color: var(--text-secondary);
    margin: 0;
}

.account-login-text-small {
    font-size: 12px;
    color: var(--text-muted);
    margin: 0;
    margin-top: -13px;
}

.account-login-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 20px;
    font-size: 15px;
    font-weight: 600;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    transition: all 0.2s;
}

.account-login-btn:hover {
    background: var(--bg);
    border-color: var(--accent);
}

.account-login-btn svg {
    flex-shrink: 0;
}

/* =========================== */
/* 未ログイン: 2カラム分割 */
.loggedout-split {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    align-items: stretch;
}

.loggedout-left,
.loggedout-right {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px;
}

.loggedout-right {
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.offline-reco-title {
    font-weight: 700;
    margin-bottom: 6px;
}

.offline-reco-desc {
    margin: 0 0 12px 0;
    color: var(--text-secondary);
    font-size: 14px;
}

.offline-reco-links {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.offline-link-btn {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    border: 1px solid var(--border);
    background: var(--surface);
    border-radius: 10px;
    padding: 10px 14px;
    text-decoration: none;
    color: inherit;
    width: 100%;
    min-height: 44px;
}

.offline-link-btn:hover {
    border-color: var(--accent);
}

@media (max-width: 640px) {
    .loggedout-split {
        grid-template-columns: 1fr;
    }
}

/* 右側エリア常時表示用の2カラムレイアウト */
.account-split {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.account-left,
.account-right {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px;
}

.account-right .offline-link-btn img {
    width: 20px;
    height: 20px;
}

@media (max-width: 640px) {
    .account-split {
        grid-template-columns: 1fr;
    }
}
