:root {
  --ink: #1d2825;
  --muted: #71807a;
  --line: #dfe7e3;
  --canvas: #eef3f0;
  --paper: #fbfcfb;
  --accent: #175f4c;
  --accent-soft: #e0eee8;
  --warm: #fff7ea;
  --danger: #a84b42;
  --shadow: 0 18px 50px rgba(24, 53, 44, 0.12);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", sans-serif;
  color: var(--ink);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--canvas); min-width: 1000px; overflow-x: auto; overflow-y: hidden; }
button, input, textarea, select { font: inherit; }
button { color: inherit; }

.app-shell { display: grid; grid-template-columns: 260px minmax(520px, 1fr) 280px; height: 100vh; height: 100dvh; min-height: 0; padding: 14px; gap: 1px; overflow: hidden; }
.sidebar, .chat-panel { min-height: 0; background: var(--paper); border: 1px solid rgba(29, 40, 37, .07); overflow: hidden; }
.left-panel { border-radius: 20px 0 0 20px; display: flex; flex-direction: column; padding: 22px 16px; }
.right-panel { border-radius: 0 20px 20px 0; padding: 25px 18px; display: flex; flex-direction: column; }
.chat-panel { display: grid; grid-template-rows: auto auto auto minmax(0, 1fr) auto; position: relative; }
.chat-header { grid-row: 1; }
.game-console { grid-row: 2; }
.private-memory-notice { grid-row: 3; }
.messages { grid-row: 4; }
.composer-wrap { grid-row: 5; }

.brand { display: flex; align-items: center; gap: 11px; padding: 0 8px 25px; }
.brand-mark { width: 38px; height: 38px; display: grid; place-items: center; color: white; background: var(--accent); border-radius: 50%; font-family: Georgia, serif; font-size: 18px; box-shadow: 0 7px 18px rgba(23, 95, 76, .25); }
.brand-mark img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; display: block; }
.brand strong, .brand span { display: block; }
.brand strong { font-size: 16px; letter-spacing: .04em; }
.brand span { color: var(--muted); font-size: 11px; margin-top: 3px; }

.room-list { display: flex; flex-direction: column; gap: 4px; max-height: 30vh; overflow-y: auto; margin-bottom: 20px; }
.room-row { display: flex; align-items: center; border-radius: 13px; }
.room-row.active { background: var(--accent-soft); }
.room-card, .thread-item { width: 100%; border: 0; background: transparent; display: flex; align-items: center; text-align: left; border-radius: 13px; cursor: pointer; }
.room-card { padding: 10px; gap: 10px; min-width: 0; }
.room-card.active { background: var(--accent-soft); }
.room-manage { width: 26px; flex: 0 0 26px; height: 30px; border: 0; background: transparent; color: #83908b; cursor: pointer; opacity: 0; }
.room-row:hover .room-manage, .room-row.active .room-manage { opacity: 1; }
.room-icon { background: var(--accent); color: white; width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; overflow: hidden; }
.room-icon img { width: 100%; height: 100%; object-fit: cover; display: block; }
.room-card span:nth-child(2) { min-width: 0; flex: 1; }
.room-card b, .room-card small, .thread-item b, .thread-item small { display: block; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.room-card b, .thread-item b { font-size: 13px; }
.room-card small, .thread-item small { color: var(--muted); font-size: 11px; margin-top: 3px; }
.section-label { padding: 0 8px 9px; display: flex; align-items: baseline; justify-content: space-between; }
.section-label span { color: #46534f; font-weight: 700; font-size: 11px; text-transform: uppercase; letter-spacing: .11em; }
.section-label small { color: #9aa5a1; font-size: 9px; }
.room-label button { border: 0; background: transparent; color: var(--accent); font-size: 10px; font-weight: 700; cursor: pointer; }
.thread-list { min-height: 0; display: flex; flex-direction: column; gap: 4px; overflow-y: auto; overscroll-behavior: contain; }
.thread-section { margin-bottom: 4px; }
.thread-section-head { width: 100%; border: 0; background: transparent; display: flex; align-items: center; gap: 5px; padding: 5px 8px 3px; cursor: pointer; color: #7d8a85; font-size: 9px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.thread-section-head i { font-style: normal; font-size: 9px; color: #9aa5a1; }
.thread-section-head:hover { color: var(--accent); }
.thread-section-body { display: flex; flex-direction: column; gap: 3px; }
.thread-empty { display: block; padding: 4px 12px; color: #a8b2ad; font-size: 10px; }
.thread-item { padding: 9px 10px; gap: 10px; }
.thread-item:hover, .thread-item.active { background: #edf2ef; }
.avatar { flex: 0 0 auto; width: 33px; height: 33px; border-radius: 50%; display: grid; place-items: center; overflow: hidden; color: white; font-weight: 700; font-size: 11px; }
.avatar img { display: block; width: 100%; height: 100%; object-fit: cover; }
.thread-item span:nth-child(2) { min-width: 0; flex: 1; }
.left-actions { margin-top: auto; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 7px; padding-top: 15px; }
.left-actions .ghost-button { min-width: 0; height: 40px; display: grid; place-items: center; padding: 0 5px; line-height: 1.15; white-space: nowrap; }
.reset-button { color: #8f625d; }

.chat-header { min-height: 86px; padding: 19px 28px 15px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); }
.header-title { min-width: 0; }
.title-line { display: flex; align-items: center; gap: 6px; }
.title-line h1 { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.title-line button { border: 0; background: transparent; color: #93a09b; cursor: pointer; letter-spacing: .08em; padding: 3px 6px; }
.title-line .back-to-room { background: var(--accent-soft); color: var(--accent); border-radius: 8px; padding: 6px 9px; margin-right: 3px; font-size: 10px; font-weight: 700; letter-spacing: 0; white-space: nowrap; }
.eyebrow { display: block; text-transform: uppercase; font-size: 9px; color: #8b9893; letter-spacing: .13em; font-weight: 800; margin-bottom: 3px; }
h1, h2 { margin: 0; font-family: Georgia, "Songti SC", serif; font-weight: 600; }
h1 { font-size: 21px; }
h2 { font-size: 20px; }
.header-actions { display: flex; gap: 8px; }
.primary-button, .soft-button, .ghost-button, .danger-button { border: 0; border-radius: 10px; padding: 9px 14px; cursor: pointer; font-size: 12px; font-weight: 700; }
.primary-button { background: var(--accent); color: white; box-shadow: 0 5px 12px rgba(23, 95, 76, .15); }
.primary-button:hover { background: #104f3e; }
.soft-button { background: var(--accent-soft); color: var(--accent); }
.sound-settings-button { width: 36px; padding: 0; display: grid; place-items: center; font-size: 15px; }
.ghost-button { background: #edf2ef; color: #53615c; text-align: center; }
.danger-button { background: #f4e4e2; color: var(--danger); }
button:disabled { opacity: .5; cursor: not-allowed; }
.round-control { position: relative; display: inline-flex; }
.round-menu { position: absolute; top: calc(100% + 6px); right: 0; z-index: 30; width: 220px; padding: 6px; background: white; border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 2px; }
.round-menu button { display: block; width: 100%; text-align: left; border: 0; background: transparent; border-radius: 9px; padding: 8px 10px; cursor: pointer; }
.round-menu button:hover { background: var(--accent-soft); }
.round-menu b { display: block; font-size: 12px; color: var(--accent); }
.round-menu small { display: block; margin-top: 2px; color: var(--muted); font-size: 10px; line-height: 1.4; }
.hidden { display: none !important; }

.game-console { margin: 12px 28px 0; border: 1px solid #e3d3c0; background: #fbf6ee; border-radius: 12px; padding: 12px 14px; font-size: 11px; color: #5b5346; }
.game-console.collapsed { padding-bottom: 3px; }
.game-console-head { display: flex; align-items: center; gap: 10px; margin-bottom: 9px; }
.game-console.collapsed .game-console-head { margin-bottom: 0; }
.game-console-head b { font-size: 12px; color: #7a4a2f; }
.game-console-phase { padding: 3px 9px; border-radius: 999px; background: #7a4a2f; color: white; font-size: 10px; font-weight: 700; }
.game-console-head .spacer { flex: 1; }
.game-flow { display: grid; gap: 6px; margin: -1px 0 10px; padding: 8px 10px; border: 1px solid #eadfcf; border-radius: 10px; background: #fffaf2; }
.game-flow-steps { display: flex; flex-wrap: wrap; gap: 6px; }
.game-flow-steps span { padding: 4px 8px; border-radius: 999px; background: #efe6d8; color: #8b7965; font-size: 9px; font-weight: 700; }
.game-flow-steps span.done { background: #e6f0e9; color: #4f7a60; }
.game-flow-steps span.current { background: #7a4a2f; color: white; }
.game-flow small { color: #8a7a65; font-size: 9px; line-height: 1.45; }
.task-card { margin: 0 0 10px; border: 1px solid #e5dac9; border-radius: 11px; background: #fffaf2; overflow: hidden; }
.task-card summary { cursor: pointer; list-style: none; padding: 8px 10px; color: #7a4a2f; font-size: 10px; font-weight: 800; }
.task-card summary::-webkit-details-marker { display: none; }
.task-card summary::before { content: "▾"; display: inline-block; width: 14px; color: #a8835f; }
.task-card:not([open]) summary::before { content: "▸"; }
.task-card-body { display: grid; gap: 7px; padding: 0 10px 10px; }
.task-card-line { margin: 0; color: #6d604f; font-size: 10px; line-height: 1.55; }
.speaker-queue { display: flex; flex-wrap: wrap; gap: 5px; }
.speaker-queue span { padding: 4px 7px; border-radius: 999px; background: #efe6d8; color: #8b7965; font-size: 9px; font-weight: 700; }
.speaker-queue span.done { background: #e6f0e9; color: #4f7a60; }
.speaker-queue span.current { background: #7a4a2f; color: white; }
.speaker-queue span.pending { background: white; border: 1px solid #eadfcf; }
.game-history { margin: 9px 0 0; border-top: 1px solid #eadfcf; padding-top: 8px; }
.game-history summary { cursor: pointer; color: #7a4a2f; font-size: 10px; font-weight: 800; }
.game-history div { display: grid; gap: 4px; max-height: 110px; overflow-y: auto; margin-top: 7px; }
.game-history p { margin: 0; padding: 5px 7px; border-radius: 7px; background: #fffaf2; color: #6d604f; font-size: 9px; line-height: 1.45; }
.game-history p span { color: #a39582; margin-right: 6px; }
.game-console-roster { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.game-roster-chip { display: inline-flex; align-items: center; gap: 5px; padding: 4px 9px; border-radius: 999px; background: white; border: 1px solid #e6dccd; font-size: 10px; }
.game-roster-chip > b { color: #7a4a2f; font-size: 9px; }
.game-roster-chip.dead { opacity: .5; text-decoration: line-through; }
.game-roster-chip .role-tag { color: #7a4a2f; font-weight: 700; }
.game-roster-chip .role-tag.wolf { color: var(--danger); }
.sheriff-badge { display: inline-grid; place-items: center; width: 15px; height: 15px; border-radius: 50%; background: #c48b3e; color: white; font-size: 9px; font-weight: 800; text-decoration: none; }
.roundtable-wrap { display: grid; gap: 7px; margin: 0 0 10px; padding: 9px 10px; border: 1px solid #eadfcf; border-radius: 12px; background: #fffdf8; }
.roundtable-title { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; color: #7a4a2f; }
.roundtable-title b { font-size: 11px; }
.roundtable-title small { color: #9a8d78; font-size: 9px; }
.roundtable { position: relative; height: 190px; max-width: 360px; margin: 0 auto; width: 100%; border-radius: 999px; background: radial-gradient(circle at center, #fffaf2 0 30%, transparent 31%), linear-gradient(#f7efe4, #f7efe4); border: 1px dashed #d7c7b1; }
.roundtable-core { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); width: 68px; height: 68px; display: grid; place-items: center; border-radius: 50%; background: #7a4a2f; color: #fff; font-size: 11px; font-weight: 800; box-shadow: 0 6px 16px rgba(122,74,47,.18); }
.table-seat { position: absolute; transform: translate(-50%, -50%); display: grid; place-items: center; min-width: 54px; max-width: 78px; padding: 5px 7px; border: 1px solid #ded0bf; border-radius: 12px; background: white; color: #53483d; font-size: 9px; line-height: 1.2; text-align: center; box-shadow: 0 4px 12px rgba(76,54,34,.08); }
.table-seat b { color: #7a4a2f; font-size: 10px; }
.table-seat span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 64px; }
.table-seat i { position: absolute; right: -5px; top: -5px; display: grid; place-items: center; width: 17px; height: 17px; border-radius: 50%; background: #c48b3e; color: white; font-style: normal; font-size: 9px; font-weight: 800; }
.table-seat.sheriff { border-color: #c48b3e; box-shadow: 0 0 0 2px rgba(196,139,62,.18); }
.table-seat.dead { opacity: .45; text-decoration: line-through; }
.game-console-setup { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.game-console-setup label { display: inline-flex; align-items: center; gap: 5px; margin: 0; color: #6a604f; font-size: 10px; font-weight: 700; }
.game-console-setup input[type="number"] { width: 52px; height: 30px; border: 1px solid #ddd3c3; border-radius: 8px; text-align: center; }
.game-console-setup input[type="checkbox"] { width: 15px; height: 15px; accent-color: #7a4a2f; }
.game-console-actions { display: flex; flex-wrap: wrap; gap: 7px; }
.game-button { border: 0; border-radius: 9px; padding: 7px 13px; font-size: 11px; font-weight: 700; cursor: pointer; background: #7a4a2f; color: white; }
.game-button.compact { padding: 5px 10px; font-size: 10px; }
.game-button:hover { background: #693d25; }
.game-button.ghost { background: #efe6d8; color: #6a4a30; }
.night-panel { display: flex; flex-direction: column; gap: 7px; }
.night-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 7px 9px; background: white; border: 1px solid #ece2d3; border-radius: 9px; font-size: 10px; }
.night-row > b { color: #7a4a2f; min-width: 44px; }
.night-row .game-button { padding: 5px 10px; }
.night-info { color: #6a604f; white-space: pre-line; }
.game-note { font-size: 10px; color: #9a8d78; align-self: center; }

.private-memory-notice { margin: 12px 28px 0; min-height: 38px; border: 1px solid #cfe0da; background: #eef7f3; border-radius: 11px; display: flex; align-items: center; padding: 8px 12px; gap: 9px; color: #527067; font-size: 10px; }
.private-memory-notice b { color: var(--accent); white-space: nowrap; }

.messages { min-height: 0; height: auto; padding: 24px 28px 14px; overflow-x: hidden; overflow-y: auto; overscroll-behavior: contain; scrollbar-gutter: stable; scroll-behavior: auto; }
.messages.selecting { overflow-anchor: none; }
.message-entry { position: relative; min-width: 0; }
.message-check { position: absolute; z-index: 1; left: -25px; top: 9px; width: 21px; height: 21px; display: grid; place-items: center; padding: 0; border: 1px solid #bdcac5; border-radius: 6px; background: white; color: white; cursor: pointer; font-size: 12px; font-weight: 800; line-height: 1; }
.message-check:hover { border-color: #76a292; }
.message-check.selected { border-color: var(--accent); background: var(--accent); }
.message-entry.selected { border-radius: 12px; background: rgba(224, 238, 232, .45); }
.empty-state { height: 100%; min-height: 280px; display: grid; place-items: center; text-align: center; color: var(--muted); }
.empty-state .empty-icon { margin: auto auto 14px; width: 54px; height: 54px; border: 1px solid #cfdbd6; border-radius: 50%; display: grid; place-items: center; font-family: Georgia, serif; font-size: 21px; color: var(--accent); }
.empty-state .empty-icon { overflow: hidden; }
.empty-state .empty-icon img { display: block; width: 100%; height: 100%; object-fit: cover; }
.empty-state h3 { margin: 0 0 7px; color: #394742; font-family: Georgia, "Songti SC", serif; font-size: 18px; }
.empty-state p { margin: 0; font-size: 12px; line-height: 1.7; }
.message { display: grid; grid-template-columns: 38px minmax(0, 1fr); gap: 10px; margin-bottom: 18px; max-width: 84%; }
.message.mine { grid-template-columns: minmax(0, 1fr) 38px; margin-left: auto; }
.message.mine .avatar { grid-column: 2; grid-row: 1; }
.message.mine .message-body { grid-column: 1; grid-row: 1; align-items: flex-end; }
.message-body { min-width: 0; display: flex; flex-direction: column; align-items: flex-start; }
.message-meta { display: flex; align-items: center; gap: 7px; font-size: 10px; color: #8c9994; margin: 0 3px 5px; }
.message-meta b { color: #40504a; font-size: 11px; }
.message-meta .fast-marker { color: #9a6a2f; font-weight: 700; }
.bubble { background: #f0f4f2; border: 1px solid #e4eae7; border-radius: 4px 14px 14px 14px; padding: 10px 13px; font-size: 13px; line-height: 1.65; white-space: pre-wrap; word-break: break-word; }
.mine .bubble { color: white; background: var(--accent); border: 0; border-radius: 14px 4px 14px 14px; }
.system-message { margin: 11px auto 20px; width: fit-content; max-width: 86%; border-radius: 999px; padding: 7px 13px; background: #f7f1e5; color: #8b734d; font-size: 10px; text-align: center; }
.system-message.multiline { border-radius: 14px; text-align: left; white-space: pre-wrap; line-height: 1.65; }
.typing { display: flex; gap: 4px; padding: 12px 16px; }
.typing i { width: 5px; height: 5px; background: #80918b; border-radius: 50%; animation: pulse 1s infinite alternate; }
.typing i:nth-child(2) { animation-delay: .2s; }.typing i:nth-child(3) { animation-delay: .4s; }
@keyframes pulse { to { opacity: .25; transform: translateY(-2px); } }

.composer-wrap { position: relative; z-index: 5; padding: 9px 28px 22px; background: var(--paper); border-top: 1px solid var(--line); box-shadow: 0 -8px 18px rgba(251, 252, 251, .92); }
.workflow-status { display: flex; align-items: center; gap: 8px; margin: 0 3px 7px; color: #806b49; font-size: 10px; line-height: 1.45; }
.workflow-status::before { content: ""; width: 7px; height: 7px; flex: 0 0 7px; border: 2px solid #d8c9aa; border-top-color: #8b734d; border-radius: 50%; animation: workflow-spin .8s linear infinite; }
@keyframes workflow-spin { to { transform: rotate(360deg); } }
.reply-row { display: flex; align-items: center; gap: 8px; margin: 0 3px 7px; font-size: 10px; color: var(--muted); }
.reply-row label { font-weight: 700; color: #53625c; }
.reply-row select { border: 0; background: transparent; color: var(--accent); outline: 0; font-size: 10px; font-weight: 700; }
.reply-row span { margin-left: auto; color: #9aa49f; }
.composer { padding: 7px 7px 7px 14px; background: white; border: 1px solid #ccd8d3; border-radius: 15px; box-shadow: 0 8px 28px rgba(32, 64, 54, .08); display: flex; align-items: flex-end; gap: 8px; }
.composer:focus-within { border-color: #80a99b; box-shadow: 0 8px 28px rgba(23, 95, 76, .12); }
.composer textarea { flex: 1; max-height: 130px; resize: none; border: 0; outline: 0; padding: 7px 0; line-height: 1.5; font-size: 13px; color: var(--ink); }
.composer textarea::placeholder { color: #a7b1ad; }
.composer button { width: 34px; height: 34px; border: 0; border-radius: 11px; background: var(--accent); color: white; font-size: 19px; cursor: pointer; }
.composer .stop-composer-button { flex: 0 0 34px; background: #f4e4e2; color: var(--danger); font-size: 13px; box-shadow: none; }
.composer .stop-composer-button:hover { background: #ead3d0; }

.panel-heading { display: flex; align-items: center; justify-content: space-between; margin: 1px 5px 20px; }
.panel-actions { display: flex; align-items: center; gap: 7px; }
.icon-button { border: 1px solid var(--line); background: white; border-radius: 10px; width: 32px; height: 32px; cursor: pointer; font-size: 18px; color: var(--accent); }
.agent-list { min-height: 0; display: flex; flex-direction: column; gap: 7px; overflow-y: auto; overscroll-behavior: contain; }
.agent-card { border: 1px solid transparent; background: transparent; border-radius: 13px; padding: 9px 8px; display: flex; gap: 10px; align-items: center; cursor: pointer; text-align: left; }
.agent-card:hover { border-color: var(--line); background: white; }
.agent-card.dragging { opacity: .45; border-color: var(--accent); background: #f4faf7; }
.agent-card.drag-over { border-color: var(--accent); background: #eef8f3; }
.agent-card.static { cursor: default; }
.agent-card.static:hover { border-color: transparent; background: transparent; }
.session-note { margin-top: 8px; padding: 8px 10px; border-radius: 9px; background: #f4f8f6; color: #8a958f; font-size: 9px; line-height: 1.5; }
.agent-info { flex: 1; min-width: 0; }
.agent-info b, .agent-info small { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.agent-info b { font-size: 12px; }
.agent-info small { color: var(--muted); font-size: 10px; margin-top: 3px; }
.agent-menu { opacity: 0; color: #96a19d; font-weight: 900; }
.agent-card:hover .agent-menu { opacity: 1; }
.provider-button { margin-top: auto; width: 100%; border: 1px solid var(--line); background: white; border-radius: 13px; padding: 11px; display: flex; align-items: center; gap: 9px; cursor: pointer; text-align: left; }
.provider-button span:nth-child(2) { flex: 1; }
.provider-button b, .provider-button small { display: block; }
.provider-button b { font-size: 11px; }.provider-button small { color: var(--muted); font-size: 9px; margin-top: 3px; }
.status-dot { width: 8px; height: 8px; background: #44a57e; border-radius: 50%; box-shadow: 0 0 0 4px #e1f1ea; }
.privacy-note { margin-top: 12px; padding: 12px; border-radius: 12px; background: var(--warm); color: #76684d; }
.privacy-note b { font-size: 10px; }.privacy-note p { font-size: 9px; line-height: 1.5; margin: 4px 0 0; }
.file-button { cursor: pointer; }.file-button input { display: none; }

.modal { width: min(550px, calc(100vw - 40px)); border: 0; border-radius: 20px; padding: 0; color: var(--ink); box-shadow: var(--shadow); }
.modal.wide { width: min(820px, calc(100vw - 40px)); }
.modal::backdrop { background: rgba(15, 27, 23, .48); backdrop-filter: blur(3px); }
.modal form { padding: 25px; }
.modal-title { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 20px; }
.close-button { border: 0; background: #eef2f0; width: 30px; height: 30px; border-radius: 50%; cursor: pointer; font-size: 18px; color: #7b8883; }
.modal label { display: block; color: #43514c; font-size: 11px; font-weight: 700; margin-bottom: 13px; }
.modal label > span { color: #98a29e; font-weight: 400; float: right; }
.modal input, .modal textarea, .modal select { display: block; width: 100%; margin-top: 6px; border: 1px solid #d9e1de; border-radius: 10px; outline: none; color: var(--ink); background-color: white; font-size: 12px; text-align: left; }
.modal input, .modal select { height: 37px; padding: 0 12px; line-height: 35px; }
.modal input[type="range"] { height: 28px; padding: 0; accent-color: var(--accent); }
.modal textarea { padding: 9px 12px; resize: vertical; line-height: 1.5; }
.modal textarea[data-line-scroll] { padding: 10px 12px; line-height: 20px; }
.modal textarea[readonly] { color: #697771; background: #f5f8f6; cursor: default; }
.crop-stage { display: grid; place-items: center; margin: 4px 0 16px; }
.crop-stage canvas { width: 256px; height: 256px; max-width: 100%; aspect-ratio: 1; border-radius: 50%; background: #f5f8f6; box-shadow: 0 0 0 2px var(--line); cursor: grab; touch-action: none; }
.crop-stage canvas:active { cursor: grabbing; }
.crop-zoom { display: flex; align-items: center; gap: 12px; margin-bottom: 4px; }
.crop-zoom input[type="range"] { margin-top: 0; flex: 1; }
.scenario-custom-action { margin: -4px 0 13px; padding: 10px 12px; border: 1px solid #d9e5e0; border-radius: 12px; background: #f5f9f7; }
.phase-hints-preview { margin: -3px 0 13px; border: 1px solid #d9e5e0; border-radius: 12px; background: #f5f9f7; overflow: hidden; }
.phase-hints-preview summary { cursor: pointer; list-style: none; padding: 10px 12px; color: var(--accent); font-size: 11px; font-weight: 800; }
.phase-hints-preview summary::-webkit-details-marker { display: none; }
.phase-hints-preview summary::before { content: "▸"; display: inline-block; width: 14px; color: #7da193; }
.phase-hints-preview[open] summary::before { content: "▾"; }
.phase-hints-preview summary span { float: right; color: #8c9994; font-size: 9px; font-weight: 400; }
.phase-hints-preview textarea { width: calc(100% - 20px); margin: 0 10px 10px; border-color: #d2ded9; background: #fbfdfc; color: #53625c; font-size: 11px; resize: vertical; }
.cognition-setting { margin: 2px 0 12px; padding: 9px 10px; border: 1px solid #d7e5df; border-radius: 10px; background: #f2f8f5; }
.modal .cognition-toggle { display: grid; grid-template-columns: 18px minmax(0, 1fr); align-items: start; column-gap: 8px; margin: 0; color: var(--accent); cursor: pointer; }
.modal .cognition-toggle input { appearance: none; display: grid; place-content: center; width: 16px; height: 16px; margin: 1px 0 0 1px; padding: 0; border: 1px solid #87a89c; border-radius: 3px; background: #fff; cursor: pointer; }
.modal .cognition-toggle input::after { content: ""; width: 4px; height: 8px; margin-top: -2px; border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(45deg) scale(0); transform-origin: center; }
.modal .cognition-toggle input:checked { border-color: var(--accent); background: var(--accent); }
.modal .cognition-toggle input:checked::after { transform: rotate(45deg) scale(1); }
.modal .cognition-toggle input:focus-visible { outline: 2px solid #9fc5b7; outline-offset: 2px; }
.modal .cognition-toggle > span { min-width: 0; float: none; color: inherit; }
.cognition-toggle b, .cognition-toggle small { display: block; }
.cognition-toggle b { font-size: 10px; line-height: 18px; }
.cognition-toggle small { margin-top: 2px; color: #72817b; font-size: 9px; font-weight: 400; line-height: 1.45; }
.setting-action { display: flex; align-items: center; gap: 9px; margin: 9px 0 0 26px; padding-top: 9px; border-top: 1px solid #dce7e2; }
.setting-action button { flex: 0 0 auto; padding: 7px 11px; }
.setting-action small { color: #72817b; font-size: 9px; line-height: 1.45; }
.modal select { appearance: none; -webkit-appearance: none; padding-right: 36px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='m2 2 4 4 4-4' fill='none' stroke='%2371807a' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; background-size: 12px 8px; }
.modal input:focus, .modal textarea:focus, .modal select:focus { border-color: #7ca696; }
.form-grid.two { display: grid; grid-template-columns: 1fr 110px; gap: 12px; }
.agent-avatar-setting { margin: -1px 0 13px; }
.agent-avatar-label { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 7px; color: #43514c; font-size: 11px; }
.agent-avatar-label span { color: #98a29e; font-size: 10px; }
.agent-avatar-row { display: flex; align-items: center; gap: 9px; }
.agent-avatar-preview { width: 42px; height: 42px; background: var(--accent); font-size: 12px; }
.modal .avatar-upload-button { display: grid; place-items: center; margin: 0; padding: 9px 14px; color: var(--accent); cursor: pointer; }
.avatar-upload-button input { display: none; }
.agent-avatar-row .ghost-button { padding: 9px 14px; }
.agent-cognition-view { margin: 4px 0 0; border: 1px solid #d9e5e0; border-radius: 11px; background: #f5f9f7; overflow: hidden; }
.agent-cognition-view summary { cursor: pointer; list-style: none; padding: 10px 12px; color: var(--accent); font-size: 11px; font-weight: 800; }
.agent-cognition-view summary::-webkit-details-marker { display: none; }
.agent-cognition-view summary::before { content: "▸"; display: inline-block; width: 14px; color: #7da193; }
.agent-cognition-view[open] summary::before { content: "▾"; }
.agent-cognition-view summary span { float: right; color: #8c9994; font-size: 9px; font-weight: 400; }
.agent-cognition-view textarea { width: calc(100% - 20px); margin: 0 10px 10px; border-color: #d2ded9; background: #fbfdfc; color: #53625c; font-size: 11px; line-height: 1.55; resize: vertical; }
.modal-actions { display: flex; flex-direction: row; flex-wrap: nowrap; align-items: center; justify-content: flex-end; gap: 8px; margin-top: 20px; }
.modal-actions > span { flex: 1; }
.modal-actions button { white-space: nowrap; }
.delete-button, .provider-delete { width: 32px; height: 32px; flex: 0 0 32px; display: grid; place-items: center; border: 1px solid #e4bcb7; border-radius: 8px; background: #fff7f6; color: var(--danger); cursor: pointer; font-size: 19px; line-height: 1; padding: 0; }
.delete-button:hover, .provider-delete:hover { background: #f5dfdc; border-color: #d99c94; }
.modal-intro { padding: 10px 12px; background: #f2f6f4; border-radius: 10px; color: #6a7772; font-size: 10px; line-height: 1.6; margin: -5px 0 16px; }
.sound-toggle { display: inline-flex !important; align-items: center; gap: 9px; width: 100%; margin-bottom: 12px !important; }
.sound-toggle input { display: inline-block; width: 16px; height: 16px; margin: 0; accent-color: var(--accent); }
.sound-preview-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin: 12px 0 6px; }
.sound-preview-grid .ghost-button { min-width: 0; padding: 8px 6px; }
.compact-modal { width: min(440px, calc(100vw - 28px)); }
.failure-modal .failure-body { display: grid; gap: 8px; }
.failure-message { max-height: 180px; overflow-y: auto; padding: 10px 12px; border-radius: 10px; background: #fff7f6; border: 1px solid #edd0cc; color: #8f4b43; font-size: 10px; line-height: 1.6; white-space: pre-wrap; }
.failure-modal .modal-actions { margin-top: 14px; }
.confirm-action-modal .modal-intro { white-space: pre-wrap; }
.discussion-rule-note { display: grid; gap: 3px; margin-top: 12px; padding: 10px 12px; border: 1px solid #d9e5e0; border-radius: 10px; background: #f5f9f7; }
.discussion-rule-note b { color: var(--accent); font-size: 10px; }
.discussion-rule-note span { color: #72817b; font-size: 9px; line-height: 1.55; }
.provider-list { max-height: min(520px, 62vh); overflow-y: auto; padding-right: 5px; }
.provider-row { border: 1px solid var(--line); border-radius: 14px; margin-bottom: 9px; background: #fdfefd; overflow: hidden; }
.provider-summary { width: 100%; min-height: 58px; display: grid; grid-template-columns: minmax(0, 1fr) auto 22px; align-items: center; gap: 12px; padding: 10px 14px; border: 0; background: transparent; color: inherit; text-align: left; cursor: pointer; }
.provider-summary:hover { background: #f6f9f7; }
.provider-summary-main { min-width: 0; }
.provider-summary-main b, .provider-summary-main small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.provider-summary-main b { font-size: 11px; color: #33453e; }
.provider-summary-main small { margin-top: 4px; color: #84908b; font-size: 9px; }
.provider-summary-type { padding: 5px 8px; border-radius: 7px; background: #eef4f1; color: #62736c; font-size: 9px; white-space: nowrap; }
.provider-chevron { color: #71807a; font-size: 18px; line-height: 1; text-align: center; transition: transform .18s ease; }
.provider-row.expanded .provider-chevron { transform: rotate(180deg); }
.provider-body { display: none; padding: 13px 14px 14px; border-top: 1px solid var(--line); }
.provider-row.expanded .provider-body { display: block; }
.provider-row-head { display: grid; grid-template-columns: minmax(180px, 1fr) 180px auto; gap: 10px; align-items: end; margin-bottom: 11px; }
.provider-row-head label, .provider-fields label { min-width: 0; margin: 0; color: #66736e; font-size: 9px; }
.provider-row-head input, .provider-row-head select, .provider-fields input { min-width: 0; margin-top: 4px; }
.provider-row-head input { font-weight: 700; }
.provider-row-actions { height: 37px; display: flex; flex-direction: row; align-items: stretch; gap: 6px; }
.provider-row-actions .provider-delete { width: 37px; height: 37px; flex-basis: 37px; line-height: 0; padding-bottom: 2px; }
.provider-inline-note { display: grid; grid-template-columns: 18px minmax(0, 1fr); gap: 8px; align-items: start; margin: 0 0 11px; padding: 8px 10px; border: 1px solid #eadfc8; border-radius: 9px; background: #fffaf0; color: #806b49; font-size: 9px; line-height: 1.5; }
.provider-inline-note > b { width: 18px; height: 18px; display: grid; place-items: center; border-radius: 50%; background: #b5853f; color: white; font-size: 11px; line-height: 1; }
.provider-inline-note a { color: #765322; font-weight: 700; text-decoration: none; white-space: nowrap; }
.provider-test, .provider-duplicate { height: 37px; display: grid; place-items: center; border: 1px solid #cddbd5; border-radius: 8px; background: #f4f8f6; color: var(--accent); cursor: pointer; padding: 0 10px; font-size: 10px; font-weight: 700; line-height: 1; white-space: nowrap; }
.provider-duplicate { color: #5f6d68; background: white; }
.provider-test:disabled { cursor: wait; }
.provider-fields { display: grid; grid-template-columns: 1.25fr 1fr 1fr; gap: 10px; }
.provider-options { display: grid; grid-template-columns: 150px 105px 110px minmax(0, 1fr); gap: 8px; align-items: end; margin-top: 9px; }
.provider-options label { margin: 0; font-size: 9px; color: #66736e; }
.provider-options input, .provider-options select { height: 32px; margin-top: 4px; line-height: 30px; font-size: 10px; }
.provider-options small { align-self: center; color: #8c9893; font-size: 9px; line-height: 1.45; }
.provider-test-status { display: none; margin: 8px 2px 0; font-size: 9px; line-height: 1.5; }
.provider-test-status.show { display: block; }
.provider-test-status.success { color: #2e7c61; }
.provider-test-status.error { color: var(--danger); }
.add-provider { width: 100%; border: 1px dashed #b7c8c1; color: var(--accent); background: #f6faf8; border-radius: 11px; padding: 10px; cursor: pointer; font-size: 11px; font-weight: 700; }
.toast { position: fixed; left: 50%; bottom: 25px; max-width: min(680px, calc(100vw - 40px)); transform: translate(-50%, 20px); background: #20342d; color: white; border-radius: 10px; padding: 9px 14px; font-size: 11px; line-height: 1.5; text-align: center; opacity: 0; pointer-events: none; transition: .2s ease; z-index: 20; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 1120px) {
  .app-shell { grid-template-columns: 220px minmax(500px, 1fr) 240px; padding: 8px; }
  .chat-header, .messages { padding-left: 20px; padding-right: 20px; }
  .private-memory-notice, .composer-wrap { margin-left: 20px; margin-right: 20px; }
  .composer-wrap { padding-left: 0; padding-right: 0; }
}
