: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 minmax(0, 1fr) auto; position: relative; }
.chat-header { grid-row: 1; }
.scenario-strip { grid-row: 2; }
.messages { grid-row: 3; }
.composer-wrap { grid-row: 4; }

.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: 13px; font-family: Georgia, serif; font-size: 18px; box-shadow: 0 7px 18px rgba(23, 95, 76, .25); }
.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: 11px; display: grid; place-items: center; font-weight: 700; }
.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-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; color: white; font-weight: 700; font-size: 11px; }
.thread-item span:nth-child(2) { min-width: 0; flex: 1; }
.left-actions { margin-top: auto; display: grid; grid-template-columns: 1fr 1fr auto; gap: 7px; padding-top: 15px; }
.left-actions .ghost-button { padding-left: 10px; padding-right: 10px; }
.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); }
.ghost-button { background: #edf2ef; color: #53615c; text-align: center; }
.danger-button { background: #f4e4e2; color: var(--danger); }
button:disabled { opacity: .5; cursor: not-allowed; }
.hidden { display: none !important; }

.scenario-strip { margin: 12px 28px 0; border: 1px solid #e6e8dc; background: #fffdf5; min-height: 38px; border-radius: 11px; display: flex; align-items: center; padding: 5px 6px 5px 12px; gap: 8px; }
.scenario-strip span { font-size: 10px; color: #9b8153; font-weight: 800; white-space: nowrap; }
.scenario-strip input { min-width: 0; flex: 1; border: 0; outline: 0; background: transparent; font-size: 11px; color: #665b46; }
.scenario-strip button { border: 0; border-radius: 7px; padding: 6px 9px; color: #8b7448; background: #f5ecd7; font-size: 10px; cursor: pointer; }

.messages { min-height: 0; height: 100%; padding: 24px 28px 12px; overflow-x: hidden; overflow-y: auto; overscroll-behavior: contain; scrollbar-gutter: stable; scroll-behavior: smooth; }
.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 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; }
.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; }
.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 { padding: 8px 28px 22px; }
.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; }

.panel-heading { display: flex; align-items: center; justify-content: space-between; margin: 1px 5px 20px; }
.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-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(720px, 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 textarea { padding: 9px 12px; resize: vertical; line-height: 1.5; }
.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; }
.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; }
.doubao-guide { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 11px 12px; margin: -5px 0 14px; border: 1px solid #eadfc8; border-radius: 11px; background: #fffaf0; }
.doubao-guide div { min-width: 0; }
.doubao-guide b, .doubao-guide span { display: block; }
.doubao-guide b { color: #70552f; font-size: 11px; margin-bottom: 3px; }
.doubao-guide span { color: #8d7959; font-size: 9px; line-height: 1.5; }
.doubao-guide a { flex: 0 0 auto; color: #8a6230; font-size: 10px; font-weight: 700; text-decoration: none; white-space: nowrap; }
.provider-list { max-height: 430px; overflow-y: auto; padding-right: 4px; }
.provider-row { border: 1px solid var(--line); border-radius: 13px; padding: 13px; margin-bottom: 9px; }
.provider-row-head { display: grid; grid-template-columns: minmax(0, 1fr) 145px auto; gap: 8px; align-items: center; margin-bottom: 9px; }
.provider-row-head input { min-width: 0; margin: 0; font-weight: 700; }
.provider-row-head select { min-width: 0; width: 100%; margin: 0; }
.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-test { 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-test:disabled { cursor: wait; }
.provider-fields { display: grid; grid-template-columns: 1.2fr 1fr 1fr; gap: 8px; }
.provider-fields input { margin: 0; }
.provider-options { display: grid; grid-template-columns: 180px 130px 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; }
  .scenario-strip, .composer-wrap { margin-left: 20px; margin-right: 20px; }
  .composer-wrap { padding-left: 0; padding-right: 0; }
}
