/* Luxi：落ち着いた白／グレー基調。ライト／ダーク対応。日常的に使うチャット画面 */
:root {
  --bg: #ffffff; --bg-soft: #f5f5f5; --bg-side: #f9f9f9; --bg-input: #ffffff; --border: #e5e5e5; --border-strong: #cacaca;
  --text: #242424; --muted: #737373; --accent: #202020; --accent-text: #ffffff; --danger: #c93c37; --ok: #1a7f37; --warn: #9a6700;
  --user-bubble: #f0f0f0; --code-bg: #f7f7f7; --hover: #eeeeee; --selected: #e9e9e9; --shadow: 0 1px 2px rgba(0, 0, 0, .06);
  --font: system-ui, -apple-system, "Segoe UI", "Hiragino Sans", "Noto Sans JP", "Yu Gothic UI", sans-serif;
  --mono: ui-monospace, "Cascadia Mono", Consolas, "SFMono-Regular", monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #151515; --bg-soft: #252525; --bg-side: #101010; --bg-input: #252525; --border: #333333; --border-strong: #555555;
    --text: #ececec; --muted: #a5a5a5; --accent: #ececec; --accent-text: #202020; --danger: #e5534b; --ok: #3fb950; --warn: #d29922;
    --user-bubble: #292929; --code-bg: #101010; --hover: #242424; --selected: #282828; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #151515; --bg-soft: #252525; --bg-side: #101010; --bg-input: #252525; --border: #333333; --border-strong: #555555;
  --text: #ececec; --muted: #a5a5a5; --accent: #ececec; --accent-text: #202020; --danger: #e5534b; --ok: #3fb950; --warn: #d29922;
  --user-bubble: #292929; --code-bg: #101010; --hover: #242424; --selected: #282828; color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.7 var(--font); -webkit-text-size-adjust: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border-radius: 8px; border: 1px solid var(--border); background: var(--bg); padding: 6px 12px; }
button:disabled { opacity: .5; cursor: not-allowed; }
.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.ghost { background: transparent; }
.icon { border: none; background: transparent; padding: 6px 8px; font-size: 18px; line-height: 1; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.error { color: var(--danger); min-height: 1.2em; }
[hidden] { display: none !important; }
.brand { font-weight: 700; letter-spacing: .02em; font-size: 18px; }

/* ログイン */
.auth { min-height: 100%; display: grid; place-items: center; padding: 24px 16px; }
.auth-card { width: min(380px, 100%); display: flex; flex-direction: column; gap: 8px; }
.auth-card input { padding: 10px 12px; border: 1px solid var(--border-strong); border-radius: 8px; background: var(--bg-input); }
.auth-card .brand { font-size: 28px; margin: 0 0 4px; }
#pw2Wrap { display: flex; flex-direction: column; gap: 8px; }

/* 全体 */
.app { display: grid; grid-template-columns: 260px minmax(0, 1fr) auto; height: 100dvh; }
.sidebar { background: var(--bg-side); border-right: 1px solid var(--border); display: flex; flex-direction: column; min-height: 0; }
.side-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px; }
.history { flex: 1; overflow-y: auto; padding: 4px 8px; min-height: 0; }
.history a { display: block; padding: 7px 10px; border-radius: 8px; color: var(--text); text-decoration: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 14px; }
.history a:hover { background: var(--bg-soft); }
.history a.active { background: var(--border); }
.side-section { padding: 8px 12px; border-top: 1px solid var(--border); }
.side-section h2 { font-size: 12px; color: var(--muted); margin: 4px 0; font-weight: 600; }
.project-list { list-style: none; margin: 0; padding: 0; font-size: 13px; }
.project-list li { padding: 3px 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-bottom { padding: 8px 12px 12px; border-top: 1px solid var(--border); }

.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.topbar { display: flex; align-items: center; gap: 8px; padding: 8px 16px; border-bottom: 1px solid var(--border); }
.conv-title { flex: 1; min-width: 0; border: 1px solid transparent; background: transparent; padding: 4px 8px; border-radius: 6px; font-weight: 600; }
.conv-title:hover, .conv-title:focus { border-color: var(--border); outline: none; }
.gpu-pill { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; padding: 4px 10px; border-radius: 999px; white-space: nowrap; }
.gpu-pill .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.gpu-pill[data-state="ready"] .dot { background: var(--ok); }
.gpu-pill[data-state="starting"] .dot, .gpu-pill[data-state="provisioning"] .dot, .gpu-pill[data-state="waiting_gpu"] .dot { background: var(--warn); }
.gpu-pill[data-state="unavailable"] .dot, .gpu-pill[data-state="stop_failed"] .dot { background: var(--danger); }
.gpu-pill .cost { color: var(--muted); }
.banner { background: #fff4e5; color: #6b4300; padding: 6px 16px; font-size: 13px; border-bottom: 1px solid var(--border); }
:root[data-theme="dark"] .banner { background: #3a2a10; color: #f0c674; }
.only-mobile { display: none; }

/* 会話 */
.messages { flex: 1; overflow-y: auto; padding: 16px; min-height: 0; }
.msg { max-width: 820px; margin: 0 auto 18px; }
.msg.user .bubble { background: var(--user-bubble); border-radius: 14px; padding: 8px 14px; margin-left: auto; width: fit-content; max-width: 85%; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg .meta { font-size: 12px; color: var(--muted); margin-bottom: 2px; }
.msg.user .meta { text-align: right; }
.msg.assistant .content { overflow-wrap: anywhere; }
.msg.assistant .content p { margin: 0 0 .7em; }
.msg.assistant .content h2, .msg.assistant .content h3, .msg.assistant .content h4 { margin: 1em 0 .4em; font-size: 1.05em; }
.content code { font-family: var(--mono); font-size: .9em; background: var(--code-bg); padding: 1px 5px; border-radius: 4px; }
.code { border: 1px solid var(--border); border-radius: 8px; margin: .6em 0; overflow: hidden; }
.code-head { display: flex; justify-content: space-between; align-items: center; padding: 2px 8px 2px 12px; background: var(--bg-soft); font-size: 12px; color: var(--muted); }
.code-head .copy { font-size: 12px; padding: 2px 8px; }
.code pre { margin: 0; padding: 10px 12px; overflow-x: auto; background: var(--code-bg); }
.code pre code { background: none; padding: 0; font-size: 13px; line-height: 1.55; }
.empty { max-width: 640px; margin: 12vh auto 0; text-align: center; color: var(--muted); }
.empty h1 { color: var(--text); font-size: 24px; font-weight: 600; }
.typing { color: var(--muted); }

/* タスク（変更）の状態 */
.task { border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; margin: 6px 0; background: var(--bg-soft); }
.task .phase { font-size: 14px; display: flex; align-items: center; gap: 8px; }
.spinner { width: 12px; height: 12px; border: 2px solid var(--border-strong); border-top-color: var(--accent); border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.badges { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0; }
.badge { font-size: 12px; padding: 1px 8px; border-radius: 999px; border: 1px solid var(--border-strong); color: var(--muted); }
.badge.ok { color: var(--ok); border-color: var(--ok); }
.badge.ng { color: var(--danger); border-color: var(--danger); }
.badge.warn { color: var(--warn); border-color: var(--warn); }
.task .actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.task .actions button { font-size: 13px; padding: 3px 10px; }

/* 入力 */
.composer { border-top: 1px solid var(--border); padding: 8px 16px calc(10px + env(safe-area-inset-bottom)); max-width: 900px; width: 100%; margin: 0 auto; }
.composer-opts { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 6px; }
.seg { display: inline-flex; border: 1px solid var(--border-strong); border-radius: 8px; overflow: hidden; }
.seg-btn { border: none; border-radius: 0; padding: 3px 14px; background: transparent; font-size: 14px; }
.seg-btn.active { background: var(--text); color: var(--bg); }
#projectSel { padding: 3px 8px; border-radius: 8px; border: 1px solid var(--border-strong); background: var(--bg-input); max-width: 100%; font-size: 14px; }
.composer-row { display: flex; gap: 8px; align-items: flex-end; }
#input { flex: 1; resize: none; max-height: 40vh; min-height: 44px; padding: 10px 12px; border: 1px solid var(--border-strong); border-radius: 12px; background: var(--bg-input); line-height: 1.5; }
#input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.send { min-height: 44px; min-width: 64px; }

/* 詳細パネル */
.detail { width: min(560px, 45vw); border-left: 1px solid var(--border); display: flex; flex-direction: column; min-height: 0; background: var(--bg); }
.detail-head { display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--border); padding: 4px 8px; gap: 4px; }
.tabs { display: flex; gap: 2px; overflow-x: auto; }
.tab { border: none; background: transparent; font-size: 13px; padding: 6px 10px; border-radius: 6px; white-space: nowrap; }
.tab.active { background: var(--bg-soft); font-weight: 600; }
.detail-body { flex: 1; overflow: auto; padding: 12px; min-height: 0; font-size: 14px; }
.diff { font-family: var(--mono); font-size: 12.5px; line-height: 1.5; white-space: pre; overflow-x: auto; margin: 0; }
.diff .add { background: rgba(26, 127, 55, .14); display: block; }
.diff .del { background: rgba(201, 60, 55, .14); display: block; }
.diff .hunk { color: var(--accent); display: block; }
.vlist { list-style: none; padding: 0; margin: 0; }
.vlist li { border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; margin-bottom: 8px; }
.shots img { max-width: 100%; border: 1px solid var(--border); border-radius: 6px; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; margin: 8px 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }

/* ダイアログ */
.dialog { border: 1px solid var(--border); border-radius: 12px; background: var(--bg); color: var(--text); width: min(460px, calc(100vw - 32px)); padding: 16px 18px; }
.dialog::backdrop { background: rgba(0, 0, 0, .35); }
.dialog h2 { margin: 0 0 8px; font-size: 17px; }
.dialog .row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.dialog .row.disabled { opacity: .7; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.stop-help p { margin: 4px 0; }

/* スマホ幅：サイドバーは折り畳み、詳細はシート表示 */
@media (max-width: 820px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .only-mobile { display: inline-block; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: min(82vw, 300px); z-index: 30; transform: translateX(-100%); transition: transform .2s; }
  .sidebar.open { transform: none; box-shadow: 4px 0 16px rgba(0, 0, 0, .2); }
  .scrim { position: fixed; inset: 0; background: rgba(0, 0, 0, .3); z-index: 20; }
  .detail { position: fixed; inset: auto 0 0 0; width: 100%; height: 85dvh; z-index: 40; border-left: none; border-top: 1px solid var(--border); border-radius: 14px 14px 0 0; box-shadow: 0 -4px 16px rgba(0, 0, 0, .2); }
  .topbar { padding: 6px 8px; }
  .gpu-pill .cost { display: none; }
  .messages { padding: 12px; }
  .composer { padding: 6px 8px calc(8px + env(safe-area-inset-bottom)); }
  .msg.user .bubble { max-width: 92%; }
  #modeNote { display: none; }
}

/* プロジェクトの取り込み */
.project-list li { white-space: normal; }
.project-list summary { cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; list-style: none; }
.project-list summary::-webkit-details-marker { display: none; }
.project-list .kv { grid-template-columns: 1fr; gap: 0 0; margin: 4px 0 6px 18px; }
.project-list .kv dd { overflow-wrap: anywhere; margin-bottom: 4px; }
.small-btn { margin-top: 6px; font-size: 13px; padding: 4px 8px; width: 100%; text-align: left; }
.dialog.wide { width: min(640px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); overflow-y: auto; }
.import-pick { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 10px 0; }
.stack { display: flex; flex-direction: column; gap: 4px; margin: 8px 0; }
.stack input { padding: 7px 10px; border: 1px solid var(--border-strong); border-radius: 8px; background: var(--bg-input); color: var(--text); font: inherit; min-width: 0; }
.import-path { display: flex; gap: 6px; }
.import-path input { flex: 1; }
.import-result h3 { font-size: 14px; margin: 14px 0 4px; }
.import-result ul { margin: 0; padding-left: 20px; }
.import-result li { overflow-wrap: anywhere; margin: 2px 0; }
.import-result .kv dd { overflow-wrap: anywhere; }
.warn-list li::marker { color: var(--warn); }
.error-box { background: color-mix(in srgb, var(--danger) 12%, transparent); color: var(--danger); border: 1px solid color-mix(in srgb, var(--danger) 40%, transparent); border-radius: 8px; padding: 8px 12px; font-size: 13px; white-space: pre-wrap; }
.ok-box { background: color-mix(in srgb, var(--ok) 12%, transparent); border: 1px solid color-mix(in srgb, var(--ok) 40%, transparent); border-radius: 8px; padding: 8px 12px; font-size: 14px; }
@media (max-width: 640px) { .import-path { flex-direction: column; } }

/* 続けての修正 */
.follow-hint { margin: 8px 0 0; padding: 6px 10px; border-left: 3px solid var(--accent); background: var(--bg-soft); border-radius: 4px; }
.task-target strong { color: var(--text); font-weight: 600; }

/* お知らせ（閉じるまで残す） */
.notices { display: flex; flex-direction: column; gap: 6px; padding: 0 16px; }
.notices:not(:empty) { padding-top: 8px; }
.notice { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; padding: 8px 12px; border-radius: 8px; border: 1px solid var(--border); background: var(--bg-soft); font-size: 14px; overflow-wrap: anywhere; }
.notice.warn { border-color: color-mix(in srgb, var(--warn) 50%, transparent); background: color-mix(in srgb, var(--warn) 10%, var(--bg)); }
.notice.error { border-color: color-mix(in srgb, var(--danger) 50%, transparent); background: color-mix(in srgb, var(--danger) 10%, var(--bg)); }
.notice .small { color: var(--muted); margin-top: 2px; }
.notice button { flex: none; border: none; background: transparent; padding: 2px 6px; }

/* 統一チャット：対象・アクセスの表示（モードの選択ではない） */
.target-label { margin-right: -2px; }
.chip { border-radius: 999px; padding: 2px 10px; background: var(--bg-soft); border: 1px solid var(--border); color: var(--muted); max-width: 22em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#statusNote { overflow-wrap: anywhere; }
/* 作業の途中の質問 */
.question { border: 1px solid var(--border-strong); border-left: 4px solid var(--accent); border-radius: 8px; padding: 8px 12px; margin: 6px 0; background: var(--bg-soft); }
.question.answered, .question.cancelled { border-left-color: var(--border-strong); opacity: .85; }
.q-head { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.q-text { white-space: pre-wrap; margin: 6px 0; overflow-wrap: anywhere; }
.q-choices { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0; }
.q-choices button { white-space: normal; text-align: left; }
.primary-soft { border-color: var(--accent); color: var(--accent); }
.q-free { display: flex; gap: 6px; margin-top: 4px; }
.q-free input { flex: 1; min-width: 0; padding: 6px 10px; border: 1px solid var(--border-strong); border-radius: 8px; background: var(--bg-input); color: var(--text); font: inherit; }
.steers { list-style: none; padding: 0; margin: 6px 0; }
.steers li { margin: 2px 0; overflow-wrap: anywhere; }
/* アクセスと自動実行 */
.access { border-top: 1px solid var(--border); margin-top: 8px; padding-top: 4px; }
.access h3 { font-size: 15px; margin: 8px 0 4px; }
.access h4 { font-size: 13px; margin: 10px 0 4px; }
.preset-list { display: flex; flex-direction: column; gap: 6px; margin: 6px 0; }
.preset { display: flex; gap: 8px; align-items: flex-start; padding: 6px 8px; border: 1px solid var(--border); border-radius: 8px; cursor: pointer; }
.preset:has(input:checked) { border-color: var(--accent); }
.full-confirm { border: 1px solid color-mix(in srgb, var(--warn) 50%, transparent); border-radius: 8px; padding: 6px 10px; }
.target-list { padding-left: 18px; }
.target-list li { overflow-wrap: anywhere; margin: 4px 0; }
.target-add { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
@media (max-width: 640px) { .chip { max-width: 100%; } .q-free { flex-direction: column; } }

/* 出典・計算方法（回答の邪魔にならない大きさで） */
.extras { margin-top: 6px; color: var(--muted); }
.extras .sources a { margin-right: 8px; color: var(--muted); text-decoration: underline dotted; overflow-wrap: anywhere; }
.extras details summary { cursor: pointer; }
.extras pre.calc { white-space: pre-wrap; background: var(--code-bg); padding: 6px 10px; border-radius: 6px; margin: 4px 0; font-size: 13px; }

/* GPU の不調のお知らせの操作 */
.notice .small { white-space: pre-wrap; }
.notice-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.notice-actions button { font-size: 13px; padding: 4px 10px; white-space: normal; text-align: left; }

/* プロトタイプの配置を、既存の会話・作業部品へ反映 */
:root { --motion-speed: .18s; }
button, a, select { transition: background-color var(--motion-speed), border-color var(--motion-speed), transform var(--motion-speed); }
button:not(:disabled):hover { background-color: var(--bg-soft); }
button.primary:not(:disabled):hover { background-color: color-mix(in srgb, var(--accent) 88%, black); }
button.danger:not(:disabled):hover { background-color: color-mix(in srgb, var(--danger) 88%, black); }
button:not(:disabled):active { transform: scale(.97); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.app { grid-template-columns: 264px minmax(0, 1fr) auto; transition: grid-template-columns var(--motion-speed); height: var(--app-height, 100dvh); position: relative; top: var(--app-top, 0px); }
.sidebar { position: relative; overflow: visible; }
.side-top { padding: 17px 15px 12px; }
.brand span { color: var(--accent); }
.new-chat { height: 36px; min-height: 36px; max-height: 36px; flex: 0 0 36px; width: calc(100% - 24px); margin: 0 12px 20px; padding: 0 11px; text-align: left; font-size: 13px; line-height: 1; background: var(--bg); border-radius: 9px; }
.side-label { margin: 0; padding: 0 19px 7px; font-size: 11px; font-weight: 600; color: var(--muted); }
.history { padding: 0 9px 12px; }
.history a { font-size: 13px; padding: 9px 11px; }
.side-section { max-height: min(240px, 28dvh); overflow: auto; flex: none; margin-bottom: 18px; }
.side-section > summary { cursor: pointer; padding: 0 0 7px; font-size: 12px; }
.project-list summary { display: flex; gap: 5px; align-items: center; }
.project-list summary .muted { flex: none; font-size: 10px; }
.project-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.history, .side-section { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
.history::-webkit-scrollbar, .side-section::-webkit-scrollbar { width: 5px; }
.history::-webkit-scrollbar-thumb, .side-section::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 8px; }
.side-bottom { flex: none; }
.side-bottom { position: relative; display: flex; align-items: center; padding: 8px; }
.profile-trigger { display: flex; gap: 9px; align-items: center; min-width: 0; width: 100%; padding: 8px; text-align: left; border: 0; background: transparent; }
.person { display: flex; flex-direction: column; flex: 1; min-width: 0; line-height: 1.5; }
.person strong, #whoami { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.person strong { font-size: 13px; }
#whoami { font-size: 10px; }
.avatar { width: 35px; height: 35px; border-radius: 50%; background: color-mix(in srgb, var(--accent) 15%, var(--bg)); color: var(--text); display: grid; place-items: center; flex: none; overflow: hidden; font-weight: 700; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar.big { width: 72px; height: 72px; font-size: 25px; }
.app.sidebar-collapsed { grid-template-columns: 0 minmax(0, 1fr) auto; }
.app.sidebar-collapsed .sidebar { visibility: hidden; overflow: hidden; }
.topbar { min-height: 61px; flex-wrap: wrap; gap: 8px; padding: 9px 18px; }
.model-select { max-width: min(300px, 38vw); border: 0; padding: 5px 2px; background: transparent; font-size: 14px; font-weight: 650; text-overflow: ellipsis; }
.conv-title { font-size: 12px; font-weight: 500; color: var(--muted); }
#deleteChat { font-size: 11px; padding: 4px 8px; }
.gpu-pill { font-size: 11px; }
.messages { padding: 30px 24px 24px; overscroll-behavior: contain; }
.msg { max-width: 800px; margin-bottom: 25px; }
.msg.user .bubble { padding: 11px 16px; border-radius: 17px 17px 5px 17px; }
.msg.assistant { padding-left: 36px; position: relative; }
.msg.assistant::before { content: '✳'; position: absolute; left: 0; top: 0; width: 28px; height: 28px; display: grid; place-items: center; border-radius: 9px; background: color-mix(in srgb, var(--accent) 10%, var(--bg)); color: var(--accent); }
.msg.assistant > .meta { font-weight: 600; color: var(--text); margin-bottom: 8px; }
.msg.assistant > .content { width: fit-content; min-width: 0; max-width: 100%; padding: 12px 16px; border: 1px solid var(--border); border-radius: 5px 17px 17px 17px; background: var(--bg); }
.msg.assistant .content > :last-child { margin-bottom: 0; }
.empty { max-width: 540px; margin: 10vh auto 0; }
.empty h1 { font-size: 30px; font-weight: 600; letter-spacing: -.04em; }
.empty p { font-size: 13px; }
.composer { position: relative; border: 1px solid var(--border); border-radius: 20px; width: calc(100% - 40px); max-width: 760px; margin: 0 auto calc(18px + env(safe-area-inset-bottom)); padding: 11px 12px; box-shadow: 0 3px 16px #00000008; background: var(--bg-input); }
.composer:focus-within { border-color: var(--border-strong); }
.composer-opts { gap: 6px; font-size: 11px; }
#projectSel { font-size: 12px; max-width: min(220px, 55vw); }
#accessChip { max-width: min(22em, 65vw); font-size: 11px; }
#statusNote { font-size: 11px; }
.composer-row { gap: 9px; }
#input { border: 0; border-radius: 0; outline: 0; background: transparent; min-width: 0; min-height: 36px; max-height: min(130px, 25dvh); padding: 7px 0; line-height: 1.6; overflow-y: auto; }
#input:focus { outline: 0; }
.plus { height: 36px; width: 36px; flex: none; padding: 0; border-radius: 50%; font-size: 21px; }
#sendBtn { min-width: 36px; width: 36px; height: 36px; min-height: 36px; padding: 0; border-radius: 12px; font-size: 22px; }
#stopBtn { min-height: 36px; padding: 5px 10px; font-size: 12px; }
.popup { position: absolute; z-index: 45; padding: 6px; border: 1px solid var(--border); border-radius: 13px; background: var(--bg); box-shadow: 0 15px 40px #0002; opacity: 1; transform: none; transition: opacity var(--motion-speed), transform var(--motion-speed), display var(--motion-speed) allow-discrete; }
.popup[hidden] { opacity: 0; transform: translateY(8px); pointer-events: none; }
@starting-style { .popup:not([hidden]) { opacity: 0; transform: translateY(8px); } }
.popup button { display: block; border: 0; width: 100%; padding: 10px; text-align: left; background: transparent; font-size: 13px; }
.profile-menu { bottom: calc(100% + 5px); left: 9px; width: min(225px, calc(100vw - 32px)); }
.attach-menu { bottom: calc(100% + 9px); left: 0; width: min(270px, calc(100vw - 32px)); }
.attach-menu p { margin: 2px 10px 8px; font-size: 11px; }
.settings-dialog { width: min(820px, calc(100vw - 32px)); height: min(650px, calc(100dvh - 32px)); max-height: calc(100dvh - 32px); padding: 0; overflow: hidden; }
.settings-dialog[open] { display: flex; flex-direction: column; }
.settings-head { display: flex; align-items: center; justify-content: space-between; flex: none; padding: 15px 20px; border-bottom: 1px solid var(--border); }
.settings-head h2 { margin: 0; }
.settings-body { display: flex; min-height: 0; flex: 1; }
.settings-tabs { background: var(--bg-side); border-right: 1px solid var(--border); display: flex; flex-direction: column; gap: 3px; flex: 0 0 166px; padding: 12px 8px; }
.settings-tabs button { flex: none; text-align: left; border: 0; background: transparent; font-size: 12px; padding: 11px; }
.settings-tabs button[aria-selected='true'] { background: var(--border); font-weight: 600; }
.settings-content { min-width: 0; flex: 1; padding: 22px 24px; overflow: auto; overscroll-behavior: contain; }
.settings-panel > h3 { margin: 0 0 10px; font-size: 18px; }
.settings-panel > .access:first-child { border-top: 0; margin-top: 0; padding-top: 0; }
.settings-panel p { font-size: 12px; }
.settings-panel input, .settings-panel textarea, .settings-panel select { max-width: 100%; min-width: 0; }
.settings-panel input[type='text'], .settings-panel input[type='number'], .settings-panel textarea, .settings-panel select { padding: 7px 10px; border: 1px solid var(--border-strong); border-radius: 8px; background: var(--bg-input); }
input[type='checkbox'], input[type='radio'] { accent-color: var(--accent); }
.settings-panel .target-add { flex-wrap: wrap; }
.settings-panel .target-add input { width: 100%; }
.settings-panel .row { flex-wrap: wrap; }
.settings-foot { display: flex; flex: none; align-items: center; gap: 15px; border-top: 1px solid var(--border); padding: 10px 20px; }
.photo-setting { display: flex; align-items: center; gap: 18px; margin: 18px 0; }
.photo-setting button { font-size: 12px; }
.dialog { opacity: 0; transform: translateY(8px); transition: opacity var(--motion-speed), transform var(--motion-speed), display var(--motion-speed) allow-discrete, overlay var(--motion-speed) allow-discrete; }
.dialog[open] { opacity: 1; transform: none; }
@starting-style { .dialog[open] { opacity: 0; transform: translateY(8px); } }
.typing, .motion-sample { display: flex; align-items: center; gap: 10px; }
.typing-dots { display: inline-flex; gap: 5px; align-items: center; height: 20px; }
.typing-dots i { display: block; width: 6px; height: 6px; background: var(--muted); border-radius: 50%; animation: luxi-dot 1s ease infinite; }
.typing-dots i:nth-child(2) { animation-delay: .15s; }
.typing-dots i:nth-child(3) { animation-delay: .3s; }
.conversation-skeleton { max-width: 760px; margin: 15px auto; }
.conversation-skeleton span { display: block; height: 12px; border-radius: 6px; width: 70%; margin: 16px 0; background: linear-gradient(90deg, var(--border), var(--bg-soft), var(--border)); background-size: 200% 100%; animation: luxi-shimmer 1.1s linear infinite; }
.conversation-skeleton span:nth-child(2) { width: 55%; }
.conversation-skeleton span:nth-child(3) { width: 35%; }
.loading-history::before { content: '読み込み中…'; display: block; padding: 10px; font-size: 12px; color: var(--muted); }
.msg.appear { animation: luxi-enter var(--motion-speed) ease both; }
@keyframes luxi-dot { 0%,65%,100% { opacity: .3; transform: none; } 35% { opacity: 1; transform: translateY(-3px); } }
@keyframes luxi-enter { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes luxi-shimmer { to { background-position: -200% 0; } }
:root[data-motion='off'] *, :root[data-motion='off'] *::before, :root[data-motion='off'] *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; } }
@media (max-width: 820px) {
  .app, .app.sidebar-collapsed { grid-template-columns: minmax(0, 1fr); }
  .sidebar, .app.sidebar-collapsed .sidebar { position: fixed; width: min(82vw, 300px); inset: 0 auto 0 0; visibility: visible; overflow: visible; }
  .app.sidebar-collapsed .sidebar:not(.open) { transform: translateX(-100%); }
  .topbar { padding: 7px 10px; gap: 6px; }
  .model-select { max-width: calc(100vw - 200px); font-size: 12px; }
  .conv-title { flex-basis: 100%; order: 2; padding: 1px 5px; }
  .gpu-pill { margin-left: auto; font-size: 10px; padding: 4px 6px; }
  #deleteChat { order: 3; margin-left: auto; }
  .messages { padding: 22px 14px; }
  .msg.assistant { padding-left: 29px; }
  .msg.assistant::before { width: 23px; height: 23px; }
  .msg.assistant > .content { padding: 10px 12px; }
  .composer { width: calc(100% - 22px); padding: 9px 10px; margin-bottom: calc(12px + env(safe-area-inset-bottom)); }
}
@media (max-width: 600px) {
  .settings-body { flex-direction: column; }
  .settings-tabs { flex: none; flex-direction: row; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--border); padding: 7px; }
  .settings-tabs button { white-space: nowrap; padding: 8px 10px; }
  .settings-content { padding: 18px 16px; }
  .settings-dialog { width: calc(100vw - 20px); height: min(650px, calc(100dvh - 20px)); max-height: calc(100dvh - 20px); }
  .photo-setting { gap: 12px; }
  .photo-setting .avatar.big { width: 58px; height: 58px; }
}

/* 会話に視線が集まる、余白を主体にしたチャット画面。管理カードの表示は維持する。 */
.sidebar { border-right: 0; }
.new-chat { border: 0; background: transparent; box-shadow: none; text-align: left; padding-left: 11px; }
.history a { padding-block: 8px; }
.history a:hover { background: var(--hover); }
.history a.active { background: var(--selected); }
.side-section, .side-bottom { border-color: transparent; }
.topbar { position: relative; border-bottom: 0; min-height: 56px; flex-wrap: nowrap; }
.model-select { font-size: 15px; max-width: 180px; }
.gpu-pill { margin-left: auto; border: 0; background: transparent; color: var(--muted); padding: 5px 7px; }
.gpu-pill { min-width: 0; }
#gpuLabel { overflow: hidden; text-overflow: ellipsis; max-width: 13em; }
.conversation-menu { top: calc(100% - 2px); right: 14px; width: min(300px, calc(100vw - 24px)); }
.conversation-menu .stack { padding: 3px 10px; }
.conversation-menu .conv-title { color: var(--text); border-color: var(--border); width: 100%; }
.conversation-menu p { margin: 8px 10px; font-size: 11px; overflow-wrap: anywhere; }
.conversation-menu #deleteChat { color: var(--danger); font-size: 13px; }
@media (min-width: 821px) { .app:not(.sidebar-collapsed) #menuBtn { display: none; } }
.messages { padding-top: 38px; }
.msg { margin-bottom: 34px; font-size: 16px; line-height: 1.8; }
.msg.user .bubble { max-width: 80%; border-radius: 22px; padding: 10px 19px; }
.msg.assistant { padding-left: 0; }
.msg.assistant::before { content: none; }
.msg.assistant > .meta { color: var(--muted); font-weight: 400; font-size: 11px; margin-bottom: 3px; }
.assistant-name { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.msg.assistant > .meta:not(.meta-route) { margin: 0; line-height: 0; }
.reply-status { display: block; color: var(--muted); font-size: 11px; line-height: 1.4; margin-top: 7px; }
.msg.assistant > .content { width: 100%; padding: 0; background: transparent; border: 0; border-radius: 0; }
.empty { margin: max(6vh, 55px) auto 0; max-width: 660px; }
.empty h1 { font-size: clamp(22px, 2.4vw, 30px); font-weight: 550; letter-spacing: -.03em; line-height: 1.6; }
.empty p { font-size: 14px; }
.composer-dock { flex: none; width: calc(100% - 48px); max-width: 800px; margin: 0 auto calc(20px + env(safe-area-inset-bottom)); }
.composer { display: block; width: 100%; max-width: none; margin: 0; border: 1px solid transparent; border-radius: 30px; background: var(--bg-soft); box-shadow: none; padding: 10px; }
.composer-row { display: flex; gap: 8px; align-items: center; }
#input { flex: 1; width: 0; min-width: 0; min-height: 36px; padding: 6px 0; font-size: 15px; line-height: 24px; }
#attachBtn { border: 0; background: transparent; }
#sendBtn { flex: none; border-radius: 50%; }
#stopBtn { flex: none; }
.composer-context { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 10px; padding: 0 9px; }
.composer-context:has(> :not([hidden])) { padding-top: 7px; }
.composer-context .chip { max-width: min(420px, 65vw); color: var(--text); font-size: 12px; background: transparent; }
#workWarning { color: var(--warn); }
.work-panel { bottom: calc(100% + 10px); left: 0; width: min(390px, calc(100vw - 24px)); max-height: min(450px, 65dvh); overflow: auto; padding: 15px; }
.work-panel h2 { font-size: 14px; margin: 0 0 8px; }
.composer-opts { display: flex; flex-direction: column; align-items: stretch; gap: 8px; margin: 0; }
.work-panel #projectSel { width: 100%; max-width: none; font-size: 13px; }
.work-panel #accessChip { max-width: none; font-size: 12px; text-align: left; white-space: normal; }
.work-panel .mem-toggle { display: flex; gap: 5px; align-items: center; }
.work-panel p { margin: 10px 0; font-size: 12px; }
.work-panel #workClose { text-align: center; }
.content .table-scroll { max-width: 100%; overflow-x: auto; }
.content table { border-collapse: collapse; min-width: max-content; font-size: 14px; }
.content th, .content td { border-bottom: 1px solid var(--border); padding: 6px 12px; text-align: left; }
.location-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.location-setting p { line-height: 1.8; }
@media (max-width: 820px) {
  .topbar { min-height: 54px; gap: 4px; }
  .model-select { font-size: 14px; max-width: 135px; }
  .messages { padding: 24px 12px; }
  .msg { font-size: 15px; margin-bottom: 28px; }
  .msg.assistant { padding-left: 0; }
  .msg.assistant > .content { padding: 0; }
  .composer-dock { width: calc(100% - 24px); margin-bottom: calc(12px + env(safe-area-inset-bottom)); }
  .composer { width: 100%; padding: 10px; margin: 0; }
  #input { font-size: 16px; }
  .empty { margin-top: 7vh; }
  .empty p { font-size: 12px; }
}
