/* =====================================================================
   チャット画面（index.html）固有のスタイル
   ---------------------------------------------------------------------
   読み込み順: tokens.css -> base.css -> components.css -> pages/index.css

   ★ index.html は app-base.css を読み込まない ★
     app-base.css は管理系 3 画面だけの要素レベル基底（* の margin リセット、
     body/button のサイズ、label のブロック化、select 込みのフォーム基本形）。
     index に当てると見た目が変わるため対象外。詳細は app-base.css 冒頭。

   共通化した分（:root / リセット / button / スクロールバー / glass modal /
   login overlay のブランド部）はここには無い。
   .topbar と .login-panel は共通定義に対する index 固有の上書き。
   ===================================================================== */

input[type="text"], input[type="email"], input[type="password"], textarea {
    font-family: inherit; width: 100%; border: none; border-radius: 10px;
    background: var(--bg-deep); color: var(--text); box-shadow: var(--nm-inset);
    outline: none; transition: box-shadow 0.2s ease; padding: 10px 12px;
}
input:focus, textarea:focus { box-shadow: var(--nm-inset), 0 0 0 1.5px var(--accent), 0 0 10px rgba(94,129,172,0.2); }
input::placeholder, textarea::placeholder { color: var(--text-dim); }
label { color: var(--text-muted); }

/* ── アプリシェル ── */
.app-shell { display: flex; height: 100vh; width: 100%; overflow: hidden; }

/* ── サイドバー ── */
.app-sidebar {
    width: 232px; flex-shrink: 0; display: flex; flex-direction: column;
    background: #232323; border-right: 1px solid var(--panel-border-light);
    box-shadow: inset -1px 0 0 rgba(255,255,255,0.04), 2px 0 24px rgba(0,0,0,0.3);
    transition: width 0.25s ease; overflow: hidden;
}
.sidebar-header { padding: 14px 14px 12px; display: flex; align-items: center; gap: 8px; }
.sidebar-brand { display: flex; flex-direction: column; align-items: center; gap: 3px; min-width: 0; flex: 1; overflow: hidden; }
.sidebar-brand svg { height: 15px; width: auto; display: block; fill: #fff; }
.sidebar-brand .brand-sub {
    font-size: 9px; font-weight: 600; letter-spacing: 0.2em; color: var(--accent);
    text-transform: uppercase; white-space: nowrap;
}
.sidebar-toggle {
    flex-shrink: 0; width: 28px; height: 28px; padding: 0;
    display: flex; align-items: center; justify-content: center;
    border: none; background: transparent; color: rgba(255,255,255,0.55);
    border-radius: 7px;
}
.sidebar-toggle:hover { background: rgba(255,255,255,0.08); color: #fff; }
.sidebar-toggle svg { width: 18px; height: 18px; fill: currentColor; }
.sidebar-menu { padding: 6px 8px; display: flex; flex-direction: column; gap: 2px; flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; }
.sidebar-item {
    display: flex; align-items: center; gap: 10px; padding: 8px 10px;
    color: rgba(255,255,255,0.68); font-size: 13.5px; letter-spacing: 0.01em;
    border-radius: 8px; cursor: pointer; transition: color 0.2s ease, background 0.2s ease;
    border: none; background: transparent; width: 100%; text-align: left; white-space: nowrap;
}
.sidebar-item:hover:not(:disabled) { color: #fff; background: rgba(255,255,255,0.06); border: none; }
.sidebar-item svg { width: 17px; height: 17px; flex-shrink: 0; opacity: 0.7; fill: currentColor; }
.sidebar-item:hover svg { opacity: 1; }
.sidebar-divider { height: 1px; background: rgba(255,255,255,0.08); margin: 8px 12px; }
.sidebar-footer {
    flex-shrink: 0; padding: 10px 12px 14px; border-top: 1px solid rgba(255,255,255,0.07);
    display: flex; flex-direction: column; gap: 8px; overflow: hidden;
}
.sidebar-user { display: flex; align-items: center; gap: 8px; font-size: 11.5px; color: var(--text-muted); overflow: hidden; }
.sidebar-user svg { width: 20px; height: 20px; flex-shrink: 0; fill: rgba(255,255,255,0.55); }
.sidebar-user span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── サイドバー折りたたみ（アイコンのみ表示） ── */
.app-sidebar.collapsed { width: 60px; }
.app-sidebar.collapsed .sidebar-header { justify-content: center; padding: 14px 0 12px; }
.app-sidebar.collapsed .sidebar-brand { display: none; }
.app-sidebar.collapsed .sidebar-item { justify-content: center; padding: 8px 0; gap: 0; }
.app-sidebar.collapsed .sidebar-item span,
.app-sidebar.collapsed .conn-badge span:not(.dot),
.app-sidebar.collapsed #activeEnvLabel,
.app-sidebar.collapsed .sidebar-user span { display: none; }
.app-sidebar.collapsed .conn-badge { justify-content: center; padding: 6px 0; }
.app-sidebar.collapsed .sidebar-user { justify-content: center; }

/* ── メイン ── */
.app-main { flex: 1; min-width: 0; display: flex; flex-direction: column; overflow: hidden; }
.topbar {
    display: flex; align-items: center; gap: 10px; padding: 10px 18px;
    border-bottom: 1px solid var(--panel-border); background: rgba(16,18,24,0.35);
    backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
    flex-shrink: 0; min-height: 54px; flex-wrap: wrap;
}

/* 利用者モードトグル */
#modeToggle { display: flex; gap: 0; padding: 3px; background: var(--bg-deep); border-radius: var(--r-pill); box-shadow: var(--nm-inset); }
.mode-btn {
    padding: 5px 14px; font-size: 12px; border: 1.5px solid transparent;
    color: rgba(255,255,255,0.45); background: transparent; border-radius: var(--r-pill);
}
.mode-btn:hover:not(:disabled) { background: transparent; color: rgba(255,255,255,0.85); border-color: rgba(255,255,255,0.2); }
.mode-btn.mode-active {
    color: #fff; background: linear-gradient(135deg, var(--accent) 0%, var(--accent-2) 100%);
    border-color: transparent; box-shadow: 0 0 12px var(--accent-glow); font-weight: 500;
}
.mode-btn.mode-active:hover { color: #fff; }
/* この組織で許可されていないモード（allowed_mode による制限、Issue #88） */
.mode-btn:disabled { opacity: 0.35; cursor: not-allowed; }

/* Salesforce 接続インジケータ（サイドバー下部）。
   ★ display は .hidden より詳細度が低い書き方にしないこと ★
     移行前はこのルールが ID セレクタ(1,0,0) で display:inline-flex を持ち、
     Tailwind の .hidden(0,1,0/!important なし) に勝ってしまうため、
     class="hidden" が付いていても常に表示されていた。
     いまは base.css の .hidden が !important なので ID でも隠れる。 */
/* 接続インジケータ。Salesforce（#sfConnectionBadge）と、連携システム
   （#connectorBadges 内に JS が動的に足す）で同じ見た目を共有する。 */
.conn-badge {
    display: inline-flex; align-items: center; gap: 7px; font-size: 11.5px; color: var(--text-muted);
    padding: 6px 13px; background: var(--panel-bg); border: 1px solid var(--panel-border-light);
    border-radius: var(--r-pill); white-space: nowrap;
}
.conn-badge .dot {
    width: 7px; height: 7px; border-radius: 50%; background: var(--ok);
    box-shadow: 0 0 8px rgba(129,199,132,0.7);
}
/* 連携システムのバッジは縦に並べる（サイドバーフッターと同じ間隔）。
   0件のときは :empty で消し、フッターの gap が余分に空かないようにする。 */
#connectorBadges { display: flex; flex-direction: column; gap: 8px; }
#connectorBadges:empty { display: none; }
#activeEnvLabel { font-size: 11.5px; color: var(--text-muted); }

/* レイアウトは移行前 inline にあったものをここへ移した。
   移行前は class="hidden" と inline の display:flex が同居しており、
   Tailwind の .hidden（!important なし）に inline が勝つため、
   レコード未選択でも空のピルが描画され続けていた（renderRecordContext() は
   起動時には呼ばれない）。base.css の .hidden は !important なので、
   ここに display を置けば「未選択なら非表示」が正しく効く。 */
#recordContextChip {
    display: flex; align-items: center; gap: 8px;
    font-size: 11.5px; color: var(--text); padding: 6px 8px 6px 13px;
    background: rgba(94,129,172,0.14); border: 1px solid rgba(94,129,172,0.35);
    border-radius: var(--r-pill); white-space: nowrap;
}
#recordContextClear { border: none; background: transparent; color: var(--text-muted); padding: 0 4px; font-size: 14px; line-height: 1; }
#recordContextClear:hover { color: #fff; background: transparent; }
.topbar-label { font-size: 10.5px; letter-spacing: 0.14em; color: rgba(255,255,255,0.8); text-transform: uppercase; font-weight: 600; white-space: nowrap; }

.topbar-orb-wrap {
    position: relative; width: 34px; height: 34px; flex-shrink: 0; border-radius: 50%;
    filter: drop-shadow(0 0 8px rgba(66,165,245,0.7)); transition: filter 0.4s ease;
}
.topbar-orb-wrap.thinking { filter: drop-shadow(0 0 9px rgba(255,152,0,0.85)); animation: orb-thinking 1.8s ease-in-out infinite; }
.topbar-orb-wrap canvas { width: 100%; height: 100%; display: block; }
@keyframes orb-thinking { 0%, 100% { transform: scale(1); opacity: 0.95; } 50% { transform: scale(1.08); opacity: 1; } }

/* ── チャット ── */
.chat-mid { flex: 1; display: flex; min-height: 0; }
.chat-col { flex: 1; min-width: 0; display: flex; flex-direction: column; padding: 16px 20px; overflow: hidden; }
#chatBox {
    flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 12px;
    padding: 6px 4px 6px; margin-bottom: 12px;
}
.chat-message {
    padding: 11px 15px; border-radius: 13px; max-width: 82%; line-height: 1.6;
    word-break: break-word; font-size: 14px; font-weight: 300;
}
.chat-message.msg-user {
    align-self: flex-end; background: linear-gradient(135deg, var(--accent) 0%, var(--accent-2) 100%);
    color: #fff; border-bottom-right-radius: 4px; box-shadow: 0 4px 12px var(--accent-glow);
    white-space: pre-wrap;
}
.chat-message.msg-agent {
    align-self: center; max-width: 95%; background: var(--bg-light); border: 1px solid var(--panel-border);
    color: var(--text); border-bottom-left-radius: 4px; box-shadow: var(--nm-flat);
}
.chat-message.msg-system {
    align-self: center; max-width: 100%; font-size: 12.5px; padding: 7px 18px;
    color: var(--warn); background: rgba(255,204,128,0.07); border: 1px solid rgba(255,204,128,0.22);
    border-radius: var(--r-pill); text-align: center;
}

/* Markdown（AI応答） */
.markdown-body p { margin: 0 0 0.5em; }
.markdown-body p:last-child { margin-bottom: 0; }
.markdown-body h1, .markdown-body h2, .markdown-body h3 { font-size: 1.02em; font-weight: 600; margin: 0.8em 0 0.4em; color: #fff; }
.markdown-body ul, .markdown-body ol { padding-left: 1.4em; margin: 0.3em 0 0.6em; }
.markdown-body li { margin: 0.15em 0; }
.markdown-body pre { background: var(--code-bg); border: 1px solid rgba(94,129,172,0.2); border-radius: 10px; padding: 12px 14px; overflow-x: auto; margin: 0.5em 0; box-shadow: inset 0 0 20px rgba(0,0,0,0.6); }
.markdown-body code { background: var(--code-bg); color: var(--code-text); padding: 0.15em 0.4em; border-radius: 5px; font-family: "Consolas", "JetBrains Mono", monospace; font-size: 0.88em; border: 1px solid rgba(94,129,172,0.18); }
.markdown-body pre code { background: transparent; border: none; padding: 0; font-size: 12.5px; }
.markdown-body table { border-collapse: collapse; width: 100%; margin: 0.5em 0; font-size: 12.5px; }
.markdown-body th { background: rgba(94,129,172,0.16); color: #fff; font-weight: 500; text-align: left; padding: 7px 10px; border: 1px solid rgba(255,255,255,0.09); }
.markdown-body td { padding: 6px 10px; border: 1px solid rgba(255,255,255,0.07); }
.markdown-body a { color: #8fb4e3; text-decoration: underline; text-underline-offset: 3px; }
.markdown-body a:hover { color: #a9c6ec; }
.markdown-body strong { color: #fff; font-weight: 600; }

/* 仕様書プレビュー（右パネル内・Issue #91）: 文書調の見出し階層を出すため
   .markdown-body のほぼ均一な見出しサイズをパネル内スコープで上書きする */
.spec-preview { padding: 4px 4px 24px; }
.spec-preview h1 { font-size: 1.35em; border-bottom: 2px solid rgba(255,255,255,0.25); padding-bottom: 0.3em; margin: 0.2em 0 0.7em; }
.spec-preview h2 { font-size: 1.12em; border-bottom: 1px solid rgba(255,255,255,0.12); padding-bottom: 0.2em; margin-top: 1.3em; }
.spec-preview h3 { font-size: 1.02em; margin-top: 1em; }

/* ── コピーボタン（Issue #18: コードブロック／応答全体のコピー） ── */
.code-block-wrap { margin: 0.5em 0; border-radius: 10px; overflow: hidden; border: 1px solid rgba(94,129,172,0.2); }
.code-block-wrap pre { margin: 0; border: none; border-radius: 0; }
.code-block-toolbar { display: flex; align-items: center; justify-content: space-between; padding: 4px 10px; background: rgba(94,129,172,0.10); border-bottom: 1px solid rgba(94,129,172,0.15); }
.code-block-lang { font-size: 10px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-dim); font-family: "Consolas", "JetBrains Mono", monospace; }
.code-copy-btn {
    font-family: "Montserrat", "Noto Sans JP", sans-serif; padding: 2px 11px; font-size: 10.5px;
    border-radius: var(--r-pill); border: 1px solid rgba(255,255,255,0.22); background: transparent; color: rgba(255,255,255,0.62);
}
.code-copy-btn:hover:not(:disabled) { background: rgba(255,255,255,0.92); color: #181a1f; border-color: #fff; }
.code-copy-btn.copied { color: var(--ok); border-color: rgba(129,199,132,0.5); background: transparent; }
.msg-copy-row { display: flex; align-items: center; justify-content: flex-start; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.msg-copy-btn {
    padding: 2px 12px; font-size: 10.5px; border-radius: var(--r-pill);
    border: 1px solid rgba(255,255,255,0.15); background: transparent; color: var(--text-dim);
}
.msg-copy-btn:hover:not(:disabled) { background: rgba(255,255,255,0.92); color: #181a1f; border-color: #fff; }
.msg-copy-btn.copied { color: var(--ok); border-color: rgba(129,199,132,0.5); background: transparent; }

/* AI回答への Good/Bad フィードバック（Issue #92） */
/* コピー／仕様書ボタンと同じ行に、それらの右側へ続けて配置する（全体は左寄せ） */
.fb-group { display: inline-flex; align-items: center; gap: 4px; }
/* 枠線だけのアイコンボタン（黒ベース背景で目立ちすぎないよう線画のみ） */
.fb-icon-btn {
    display: inline-flex; align-items: center; justify-content: center;
    width: 28px; height: 28px; padding: 0; border-radius: 6px; cursor: pointer;
    border: none; background: transparent; color: var(--text-dim);
}
.fb-icon-btn svg { width: 17px; height: 17px; display: block; }
.fb-icon-btn:hover:not(:disabled) { color: var(--text); background: rgba(255,255,255,0.07); }
.fb-icon-btn:disabled { opacity: 0.45; cursor: default; }
.fb-icon-btn.fb-active-good { color: var(--ok); }
.fb-icon-btn.fb-active-bad { color: var(--err); }
/* テキストボタン（コメント送信用）。コメント欄の主アクションなので、
   利用者モードトグルや自分の発言と同じアクセントの塗りで目立たせる（Issue #126） */
.fb-btn {
    padding: 5px 16px; font-size: 11.5px; font-weight: 600; border-radius: var(--r-pill); cursor: pointer;
    color: #fff; background: linear-gradient(135deg, var(--accent) 0%, var(--accent-2) 100%);
    border: 1px solid transparent; box-shadow: 0 0 12px var(--accent-glow);
}
/* background は button:hover の白塗りに上書きされるため明示的に指定する */
.fb-btn:hover:not(:disabled) {
    color: #fff; border-color: rgba(255,255,255,0.35);
    background: linear-gradient(135deg, #6b8fbd 0%, #8b69d0 100%);
    box-shadow: 0 0 18px var(--accent-glow), 0 0 0 1px rgba(255,255,255,0.12);
}
.fb-btn:disabled { opacity: 0.45; cursor: default; box-shadow: none; }
.fb-status { font-size: 11px; color: var(--text-dim); margin-left: 4px; }
.fb-comment-box { display: flex; flex-direction: column; gap: 6px; margin-top: 6px; width: 100%; }
.fb-comment-box textarea {
    width: 100%; min-height: 58px; resize: vertical; box-sizing: border-box;
    border-radius: 8px; padding: 8px; font-size: 12px; font-family: inherit;
    background: rgba(255,255,255,0.04); border: 1px solid rgba(255,255,255,0.15); color: var(--text);
}
.fb-comment-actions { display: flex; justify-content: flex-end; gap: 6px; }

/* レコードコンテキストチップ行 */
.chip-row { margin-bottom: 8px; flex-shrink: 0; align-self: flex-start; }

/* よくある質問サジェストチップ（新規会話画面のみ表示。Issue #100 Phase 1） */
.sq-row { display: flex; flex-wrap: wrap; gap: 6px; align-self: stretch; }
.sq-chip {
    padding: 5px 14px; font-size: 12px; border-radius: var(--r-pill); cursor: pointer;
    border: 1px solid var(--panel-border); background: var(--bg-light); color: var(--text-muted);
    max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
/* background/color はグローバルの button:hover に上書きされるため明示的に指定する */
.sq-chip:hover { background: var(--bg-light); color: var(--text); border-color: var(--panel-border-light); }

/* 送信待ち添付ファイルのチップ行（チャット添付 第1弾） */
.attach-row { display: flex; flex-wrap: wrap; gap: 6px; align-self: stretch; }
.attach-chip {
    display: inline-flex; align-items: center; gap: 6px; max-width: 260px;
    font-size: 11.5px; color: var(--text); padding: 5px 6px 5px 12px;
    background: rgba(94,129,172,0.14); border: 1px solid rgba(94,129,172,0.35);
    border-radius: var(--r-pill); white-space: nowrap;
}
.attach-chip .attach-name { overflow: hidden; text-overflow: ellipsis; }
.attach-chip .attach-status { font-size: 10.5px; color: var(--text-dim); flex-shrink: 0; }
.attach-chip.attach-error { border-color: rgba(229,115,115,0.5); background: rgba(229,115,115,0.10); }
.attach-chip.attach-error .attach-status { color: var(--err); }
.attach-chip-remove { border: none; background: transparent; color: var(--text-muted); padding: 0 4px; font-size: 14px; line-height: 1; flex-shrink: 0; box-shadow: none; }
.attach-chip-remove:hover { color: #fff; background: transparent; }
/* 送信済みユーザーメッセージ内の添付インジケータ（📎 ファイル名） */
.msg-attachments { margin-top: 6px; font-size: 11.5px; opacity: 0.85; display: flex; flex-direction: column; gap: 2px; }

/* ファイルドラッグ中のドロップ先ハイライト（チャット添付 第2弾: D&D）。
   inset のリングで既存レイアウトを動かさずに「ここに落とせる」ことを示す */
.chat-col.drag-over {
    box-shadow: inset 0 0 0 2px var(--accent), inset 0 0 24px rgba(94,129,172,0.18);
    border-radius: 12px;
    transition: box-shadow 0.15s ease;
}

/* 入力エリア */
/* align-items:flex-end で、入力欄が改行で縦に伸びても送信ボタン類は下端に揃えたままにする（入力欄は上方向に拡大） */
.input-row { display: flex; gap: 8px; flex-shrink: 0; align-items: flex-end; }
#recordSearchBtn, #attachBtn {
    flex-shrink: 0; width: 44px; height: 44px; display: flex; align-items: center; justify-content: center;
    border-radius: 12px; background: var(--bg-light); border: 1px solid var(--panel-border);
    color: rgba(255,255,255,0.6); box-shadow: var(--nm-flat);
}
#recordSearchBtn:hover, #attachBtn:hover:not(:disabled) { background: var(--bg-light); color: #fff; border-color: var(--panel-border-light); }
#recordSearchBtn svg, #attachBtn svg { width: 18px; height: 18px; fill: currentColor; }
#attachBtn:disabled { opacity: 0.45; cursor: default; }
/* 改行に合わせて JS が height を scrollHeight に追従させる。min-height で初期2行分を確保し、
   max-height を超えたらスクロール（overflow-y:auto）。box-sizing は全体で border-box。 */
#messageInput { flex: 1; resize: none; padding: 11px 14px; font-size: 14px; line-height: 1.5; min-height: 58px; max-height: 40vh; overflow-y: auto; }
#sendBtn { flex-shrink: 0; padding: 0 26px; font-size: 14px; font-weight: 600; letter-spacing: 0.04em; }

/* ── データブラウザー ── */
#resizeHandle {
    width: 5px; cursor: col-resize; background: rgba(255,255,255,0.06); flex-shrink: 0;
    transition: background 0.15s; position: relative;
}
#resizeHandle:hover, #resizeHandle.dragging { background: var(--accent); }
#resizeHandle::after {
    content: ''; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
    width: 2px; height: 32px; background: rgba(255,255,255,0.4); border-radius: 1px;
}
#dataBrowserPanel {
    width: 0; min-width: 0; overflow: hidden; transition: width 0.3s ease, min-width 0.3s ease;
    display: flex; flex-direction: column;
    background: var(--panel-bg-solid); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
}
#dataBrowserPanel.open { width: 480px; min-width: 220px; }
#dataBrowserPanel.no-transition { transition: none !important; }
.db-header { display: flex; align-items: center; justify-content: space-between; padding: 13px 16px; border-bottom: 1px solid var(--panel-border); flex-shrink: 0; background: rgba(16,18,24,0.4); }
.db-header .db-title { font-weight: 600; font-size: 12px; letter-spacing: 0.1em; color: var(--text-muted); text-transform: uppercase; }
#dbRecordCount { margin-left: 8px; font-size: 11.5px; color: var(--accent); font-weight: 500; }
#dataBrowserClose { border: none; background: transparent; color: var(--text-muted); font-size: 18px; line-height: 1; padding: 2px 6px; box-shadow: none; }
#dataBrowserClose:hover { color: #fff; background: transparent; }
#dbSoqlArea { padding: 10px 16px; background: var(--code-bg); border-bottom: 1px solid rgba(94,129,172,0.15); flex-shrink: 0; }
#dbSoqlText { font-size: 11px; color: var(--code-text); font-family: "Consolas", monospace; word-break: break-all; }
.db-scroll { overflow-x: auto; overflow-y: auto; flex: 1; padding: 8px; }
#dbTable { border-collapse: collapse; width: 100%; font-size: 0.78rem; }
#dbTable th { background: #1c2536; color: #fff; padding: 0.45rem 0.7rem; text-align: left; white-space: nowrap; position: sticky; top: 0; z-index: 1; font-weight: 500; }
#dbTable td { border-bottom: 1px solid rgba(255,255,255,0.06); padding: 0.4rem 0.7rem; white-space: nowrap; max-width: 200px; overflow: hidden; text-overflow: ellipsis; color: var(--text); }
#dbTable tr:hover td { background: rgba(94,129,172,0.12); }
#dbTable a { color: #8fb4e3; text-decoration: underline; }
#dbTable a:hover { color: #a9c6ec; }

/* ── データ一括編集（Issue #90） ── */
.db-actions { display: flex; gap: 6px; align-items: center; }
.db-btn {
    font-size: 11px; padding: 4px 12px; border-radius: 6px; cursor: pointer;
    border: 1px solid rgba(255,255,255,0.18); background: rgba(255,255,255,0.05); color: var(--text-muted);
}
.db-btn:hover:not(:disabled) { color: #fff; border-color: rgba(255,255,255,0.35); background: rgba(255,255,255,0.09); }
.db-btn:disabled { opacity: 0.45; cursor: default; }
.db-btn-primary { background: rgba(94,129,172,0.85); border-color: rgba(94,129,172,0.85); color: #fff; }
.db-btn-primary:hover:not(:disabled) { background: rgba(110,145,190,0.95); border-color: rgba(110,145,190,0.95); color: #fff; }
#dbEditNote { font-size: 11.5px; color: var(--text-muted); padding: 7px 16px; border-bottom: 1px solid var(--panel-border); flex-shrink: 0; }
#dbEditNote.db-note-err { color: var(--err); }
#dbTable td.db-cell-input { padding: 2px 4px; max-width: none; overflow: visible; }
.db-input {
    width: 100%; min-width: 90px; box-sizing: border-box; font-size: 0.78rem; padding: 4px 6px;
    background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.16); border-radius: 4px; color: var(--text);
}
.db-input:focus { outline: none; border-color: rgba(94,129,172,0.9); }
select.db-input { min-width: 110px; }
select.db-input option { background: #1c2536; color: #fff; }
input[type="checkbox"].db-input { width: auto; min-width: 0; cursor: pointer; }
#dbTable td.db-cell-dirty { background: rgba(255,204,128,0.14); }
#dbTable td.db-cell-dirty .db-input { border-color: rgba(255,204,128,0.65); }
#dbTable tr.db-row-error td { background: rgba(242,139,130,0.10); }
#dbTable tr.db-row-error-msg td {
    color: var(--err); font-size: 0.72rem; white-space: normal; max-width: none;
    border-bottom: 1px solid rgba(242,139,130,0.35); padding-top: 2px;
}
/* 差分プレビューモーダル */
#dataEditPreviewTable { border-collapse: collapse; width: 100%; font-size: 12.3px; }
#dataEditPreviewTable th { background: #1c2536; color: #fff; padding: 6px 10px; text-align: left; position: sticky; top: 0; font-weight: 500; }
#dataEditPreviewTable td { border-bottom: 1px solid rgba(255,255,255,0.07); padding: 5px 10px; color: var(--text); word-break: break-all; }
#dataEditPreviewTable td.diff-before { color: var(--text-dim); }
#dataEditPreviewTable td.diff-after { color: #ffd9a0; }
.empty-note { margin-top: 2rem; }


/* コードブラウザー（LWCデプロイ承認時） */
.code-file-header { display: flex; align-items: center; justify-content: space-between; font-family: "Consolas", monospace; font-size: 10.5px; font-weight: 700; letter-spacing: 0.06em; color: #fff; background: rgba(94,129,172,0.1); border: 1px solid rgba(94,129,172,0.2); border-radius: 8px 8px 0 0; padding: 6px 10px; margin-top: 12px; text-transform: uppercase; }
.code-file-body { font-size: 12px; background: var(--code-bg); border: 1px solid rgba(94,129,172,0.2); border-top: none; border-radius: 0 0 8px 8px; padding: 10px 12px; overflow-x: auto; white-space: pre; margin: 0; color: #fff; font-family: "Consolas", "JetBrains Mono", monospace; box-shadow: inset 0 0 20px rgba(0,0,0,0.6); }
.delete-warning { font-size: 11.5px; color: var(--err); margin-top: 10px; font-weight: 600; }

/* ── 選択肢 / 承認（ask_user_choice） ── */
.choice-area {
    display: flex; flex-direction: column; gap: 10px; margin-top: 4px; padding: 16px 18px;
    background: rgba(24, 40, 68, 0.55); border: 1px solid rgba(94, 129, 172, 0.3);
    border-radius: 14px; backdrop-filter: blur(12px); box-shadow: 0 8px 28px rgba(0,0,0,0.3), 0 0 20px rgba(94,129,172,0.1);
    align-self: stretch; max-width: 100% !important;
}
.choice-question { color: var(--text); border: none; background: transparent; padding: 0; font-size: 14px; font-weight: 500; white-space: pre-wrap; line-height: 1.6; }
.choice-btn {
    display: inline-block; text-align: left; padding: 8px 18px; border-radius: var(--r-pill); font-size: 13px;
    font-weight: 500; cursor: pointer; border: 1.5px solid rgba(255,255,255,0.28);
    background: transparent; color: rgba(255,255,255,0.78);
}
.choice-btn-primary { background: #fff; color: #181a1f; border-color: #fff; box-shadow: 0 0 14px rgba(255,255,255,0.18); }
.choice-btn-primary:hover { background: #fff; color: #181a1f; }
.choice-btn-secondary:hover { background: rgba(255,255,255,0.95); color: #181a1f; }
.choice-btn-danger { color: var(--err); border-color: rgba(242,139,130,0.4); }
.choice-btn-danger:hover { background: rgba(220,50,50,0.85); color: #fff; border-color: rgba(220,50,50,0.85); }
.choice-btn:disabled { opacity: 0.4; cursor: not-allowed; pointer-events: none; }

/* ── チャット内データ更新の承認カード（choices.data_update、propose_data_update） ──
   選択肢エリア（.choice-area）内に変更前→変更後の差分表を出す。
   表の列構成は agents.css の .ag-proposal-table と同形（画面ごとの名前空間の
   規約に従い、クラス名はチャット画面独自の du- 系統にする） */
.du-card { border: 1px solid rgba(94,129,172,0.3); border-radius: 10px; padding: 10px 12px; background: rgba(10,16,28,0.35); overflow-x: auto; }
.du-card-head { font-size: 13px; font-weight: 600; color: #fff; margin-bottom: 8px; }
.du-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.du-table th { background: rgba(94,129,172,0.16); color: #fff; font-weight: 500; text-align: left; padding: 6px 10px; border: 1px solid rgba(255,255,255,0.09); white-space: nowrap; }
.du-table td { padding: 6px 10px; border: 1px solid rgba(255,255,255,0.07); word-break: break-all; }
.du-arrow { color: var(--text-muted); white-space: nowrap; }
.du-after { color: #fff; font-weight: 600; }
.du-note { font-size: 11.5px; color: var(--text-muted); margin: 6px 0 0; }

/* ── 応答待ちローディング ── */
#loadingIndicator { align-self: flex-start; display: flex; align-items: center; gap: 12px; padding: 12px 18px; background: var(--bg-light); border: 1px solid var(--panel-border); border-radius: 13px; border-bottom-left-radius: 4px; box-shadow: var(--nm-flat); color: var(--text-muted); font-size: 12.5px; }
.mini-orb { width: 20px; height: 20px; border-radius: 50%; flex-shrink: 0; background: radial-gradient(ellipse 65% 65% at 38% 32%, #7a4f2a 0%, #5c3a21 55%, #3a2210 100%); box-shadow: inset -3px -3px 7px rgba(0,0,0,0.65), inset 2px 2px 6px rgba(255,255,255,0.15), 0 0 14px rgba(255,152,0,0.65), 0 0 28px rgba(255,152,0,0.3); animation: orb-thinking 1.8s ease-in-out infinite; }
#loadingElapsed { margin-left: 4px; font-size: 11px; color: var(--text-dim); }

/* ── 環境設定 ── */
.env-item { display: flex; align-items: center; gap: 0.75rem; padding: 0.85rem; border-radius: 12px; background: var(--bg-light); box-shadow: var(--nm-flat); border: 1px solid var(--panel-border); }
.env-item-active { border-color: rgba(94,129,172,0.45); box-shadow: 0 0 14px rgba(94,129,172,0.15), var(--nm-flat); }
.env-item-inactive:hover { border-color: var(--panel-border-light); }
.env-name { font-weight: 500; color: var(--text); }
.env-name-active { color: #bcd4ee; }
.env-badge-active { flex-shrink: 0; font-size: 10px; letter-spacing: 0.06em; background: rgba(94,129,172,0.25); color: #cfe0f2; padding: 2px 9px; border-radius: var(--r-pill); border: 1px solid rgba(94,129,172,0.4); }
.env-domain { font-size: 11.5px; color: var(--text-dim); }
.env-btn { font-size: 0.72rem; padding: 0.32rem 0.75rem; border-radius: var(--r-pill); border: 1.5px solid; cursor: pointer; white-space: nowrap; }
.env-btn-select { background: transparent; border-color: rgba(94,129,172,0.5); color: #a9c6ec; }
.env-btn-select:hover { background: var(--accent); color: #fff; border-color: var(--accent); }
.env-btn-edit { background: transparent; border-color: rgba(255,255,255,0.25); color: rgba(255,255,255,0.7); }
.env-btn-edit:hover { background: rgba(255,255,255,0.9); color: #181a1f; }
.env-btn-delete { background: transparent; border-color: rgba(242,139,130,0.4); color: var(--err); }
.env-btn-delete:hover { background: rgba(220,50,50,0.85); color: #fff; border-color: rgba(220,50,50,0.85); }
.login-orb-wrap { position: relative; width: 220px; height: 220px; margin: 0 auto 6px; animation: login-orb-breathe 3.4s ease-in-out infinite; }
@keyframes login-orb-breathe {
    0%, 100% { filter: drop-shadow(0 0 22px rgba(255,255,255,0.34)) drop-shadow(0 0 60px rgba(255,255,255,0.12)); }
    50% { filter: drop-shadow(0 0 55px rgba(255,255,255,0.6)) drop-shadow(0 0 110px rgba(255,255,255,0.25)); }
}
.login-orb-wrap canvas { width: 100%; height: 100%; display: block; border-radius: 50%; }
.login-panel { background: transparent; border: none; box-shadow: none; backdrop-filter: none; }


/* ── 会話履歴ドロワー ── */
#historyDrawer { z-index: var(--z-drawer); }
#historyDrawer .history-panel {
    background: var(--panel-bg-solid); backdrop-filter: blur(24px); -webkit-backdrop-filter: blur(24px);
    border-right: 1px solid var(--panel-border-light); box-shadow: 8px 0 32px rgba(0,0,0,0.5);
}
.history-item { padding: 12px 16px; cursor: pointer; border-bottom: 1px solid var(--panel-border); transition: background 0.15s ease; }
.history-item:hover { background: rgba(94,129,172,0.10); }
.history-title { font-size: 13.5px; font-weight: 500; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.history-sub { margin-top: 3px; font-size: 11px; color: var(--text-dim); display: flex; align-items: center; gap: 6px; }
.history-mode-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.history-mode-dot.mode-admin-dot { background: var(--accent); box-shadow: 0 0 5px var(--accent-glow); }
.history-mode-dot.mode-business-dot { background: var(--ok); box-shadow: 0 0 5px rgba(129,199,132,0.5); }
.history-info-row { padding: 1rem; font-size: 0.85rem; color: var(--text-dim); text-align: center; }
.history-search-bar { padding: 12px 16px 6px; border-bottom: 1px solid var(--panel-border); flex-shrink: 0; }
.history-search-bar input[type="text"] { font-size: 12.5px; padding: 8px 12px; }
.history-owner-filter { display: flex; gap: 4px; margin-top: 8px; }
.history-owner-btn {
    flex: 1; padding: 6px 4px; font-size: 11.5px; cursor: pointer;
    background: var(--bg-light); border: 1px solid var(--panel-border);
    color: var(--text-dim); border-radius: 8px; transition: all 0.15s ease;
}
.history-owner-btn:hover:not(.active) { color: var(--text); border-color: var(--panel-border-light); }
.history-owner-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.history-search-note { margin-top: 6px; font-size: 10.5px; color: var(--text-dim); }
.history-mine-badge {
    flex-shrink: 0; font-size: 9.5px; font-weight: 700; color: var(--accent);
    border: 1px solid var(--accent); border-radius: 6px; padding: 0 5px; line-height: 15px;
}
.history-rename-btn {
    flex-shrink: 0; background: none; border: none; cursor: pointer; padding: 0 2px;
    font-size: 12px; color: var(--text-dim); line-height: 1; opacity: 0; transition: opacity 0.15s ease;
}
.history-item:hover .history-rename-btn { opacity: 1; }
.history-rename-btn:hover { color: var(--accent); }
.history-rename-input {
    flex: 1; min-width: 0; font-size: 13.5px; padding: 4px 8px;
    border-radius: 8px; background: var(--bg-deep); color: var(--text); box-shadow: var(--nm-inset);
}

/* ── レコード検索モーダル ──
   オーバーレイとダイアログの外観は components.css の
   .glass-overlay / .glass-dialog に統一済み（markup 側でクラスを併記）。
   ここに残すのは配置とサイズだけ。

   ダイアログはオーバーレイの「子」ではなく「兄弟」なので、
   オーバーレイ（--z-modal）より 1 つ上に載せる必要がある。 */
#recordSearchModal .rs-dialog {
    position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%);
    width: 480px; max-width: 95vw; height: 80vh; max-height: 80vh;
    display: flex; flex-direction: column; z-index: calc(var(--z-modal) + 1);
}
#recordSearchModal .rs-header { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--panel-border); flex-shrink: 0; background: rgba(16,18,24,0.4); border-radius: 16px 16px 0 0; }
#recordSearchModal .rs-header h3 { color: #fff; }
#recordSearchModal .rs-body { flex: 1; overflow-y: auto; padding: 0; }
#recordSearchModal .rs-search-bar { display: flex; gap: 8px; padding: 12px 16px; border-bottom: 1px solid var(--panel-border); flex-shrink: 0; }
.rs-record-item { display: flex; align-items: center; gap: 12px; padding: 0.6rem 1.25rem; cursor: pointer; border-bottom: 1px solid var(--panel-border); }
.rs-record-item:hover { background: rgba(94,129,172,0.10); }
.rs-record-item .rs-icon { width: 30px; height: 30px; border-radius: 8px; display: flex; align-items: center; justify-content: center; font-size: 0.72rem; font-weight: 700; color: #fff; flex-shrink: 0; box-shadow: 0 3px 8px rgba(0,0,0,0.4), inset 0 1px 0 rgba(255,255,255,0.18); }
.rs-type-Account .rs-icon { background: #7c5cbf; }
.rs-type-Opportunity .rs-icon { background: #c9873a; }
.rs-type-Contact .rs-icon { background: #3a8fa8; }
.rs-type-Lead .rs-icon { background: #d1662e; }
.rs-type-Case .rs-icon { background: #4a9d5f; }
.rs-type-default .rs-icon { background: #6b7280; }
.rs-record-name { font-size: 0.85rem; font-weight: 500; color: var(--text); }
.rs-record-type { font-size: 0.7rem; color: var(--text-dim); }
.rs-empty { text-align: center; padding: 2rem; color: var(--text-dim); font-size: 0.85rem; }
.rs-loading { text-align: center; padding: 2rem; color: var(--text-muted); font-size: 0.85rem; }
.rs-section-heading { padding: 0.7rem 1.25rem 0.3rem; font-size: 0.7rem; font-weight: 700; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.08em; }

.rs-slide-viewport { flex: 1; overflow: hidden; position: relative; min-height: 0; }
.rs-slide-container { width: 100%; height: 100%; position: relative; }
.rs-slide-page { width: 100%; height: 100%; display: none; flex-direction: column; position: absolute; top: 0; left: 0; }
.rs-slide-page.rs-page-active { display: flex; }
#rsContent, #rsObjContent, #rsObjRecContent { flex: 1; overflow-y: auto; min-height: 0; }
.rs-obj-section-header { padding: 0.5rem 1.25rem; font-size: 0.7rem; font-weight: 700; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.06em; background: rgba(255,255,255,0.02); border-bottom: 1px solid var(--panel-border); position: sticky; top: 0; z-index: 1; }
.rs-obj-item { display: flex; align-items: center; justify-content: space-between; padding: 0.65rem 1.25rem; cursor: pointer; border-bottom: 1px solid var(--panel-border); }
.rs-obj-item:hover { background: rgba(94,129,172,0.10); }
.rs-obj-label { font-size: 0.85rem; font-weight: 500; color: var(--text); }
.rs-obj-api { font-size: 0.7rem; color: var(--text-dim); }
.rs-obj-arrow { color: var(--text-dim); font-size: 0.85rem; }
.rs-objrec-item { display: flex; align-items: center; gap: 0.5rem; padding: 0.6rem 1.25rem; cursor: pointer; border-bottom: 1px solid var(--panel-border); }
.rs-objrec-item:hover { background: rgba(94,129,172,0.10); }
.rs-objrec-hash { color: var(--text-dim); font-weight: 700; font-size: 0.85rem; }
.rs-objrec-name { font-size: 0.85rem; font-weight: 500; color: var(--text); }
.rs-back-btn { display: flex; align-items: center; gap: 0.25rem; color: var(--text-muted); font-size: 0.9rem; cursor: pointer; background: none; border: none; padding: 2px 4px; box-shadow: none; }
.rs-back-btn:hover { color: #fff; background: transparent; }
.rs-browse-objects-link { display: flex; align-items: center; justify-content: space-between; padding: 0.75rem 1.25rem; cursor: pointer; border-top: 1px solid var(--panel-border); color: #a9c6ec; font-size: 0.85rem; font-weight: 600; flex-shrink: 0; }
.rs-browse-objects-link:hover { background: rgba(94,129,172,0.10); }
.icon-x { border: none; background: transparent; color: var(--text-muted); font-size: 18px; line-height: 1; padding: 2px 6px; box-shadow: none; }
.icon-x:hover { color: #fff; background: transparent; }

@media (max-width: 640px) {
    .app-sidebar { width: 64px; }
    .sidebar-brand, .sidebar-item span, .sidebar-user span { display: none; }
}
