:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --line: #d9dee7;
  --text: #17202c;
  --muted: #627084;
  --accent: #0f766e;
  --accent-dark: #115e59;
  --danger: #b42318;
  --soft: #eef6f5;
  --code: #111827;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  min-height: 34px;
  padding: 0 12px;
  border-radius: 6px;
  cursor: pointer;
}

button:hover {
  border-color: var(--accent);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.hidden {
  display: none !important;
}

button.danger {
  color: var(--danger);
}

.app {
  display: grid;
  grid-template-columns: 280px 1fr;
  min-height: 100vh;
}

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card {
  width: min(360px, 100%);
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 8px;
  padding: 22px;
  display: grid;
  gap: 14px;
  box-shadow: 0 18px 48px rgba(15, 23, 42, 0.12);
}

.login-card h1 {
  margin: 0 0 4px;
  font-size: 26px;
}

.sidebar {
  border-right: 1px solid var(--line);
  background: #fbfcfd;
  padding: 16px;
  height: 100vh;
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) minmax(0, 1fr);
  gap: 14px;
}

.brand {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: flex-start;
}

.brand-title-row {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.brand-control-grid {
  display: grid;
  grid-template-columns: 54px 54px;
  gap: 6px;
  align-items: center;
}

.brand h1,
.topbar h2,
.chat-head h3,
.compiled h3 {
  margin: 0;
}

.brand h1 {
  font-size: 20px;
}

.brand p,
.topbar p,
.chat-head p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

#newBotBtn {
  width: 34px;
  padding: 0;
  font-size: 22px;
  line-height: 1;
}

#languageInput {
  width: auto;
  min-height: 30px;
  padding: 4px 8px;
  font-size: 12px;
}

#wikiBtn,
#usersBtn,
#logoutBtn {
  min-height: 30px;
  padding: 0 6px;
  font-size: 12px;
}

.sidebar-section {
  min-height: 0;
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 8px;
}

.sidebar-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.bot-list {
  display: grid;
  align-content: start;
  gap: 8px;
  min-height: 0;
  overflow: auto;
  padding-right: 2px;
}

.bot-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  display: grid;
  grid-template-columns: 34px 1fr 34px;
  align-items: stretch;
  overflow: hidden;
}

.bot-item.active {
  background: var(--soft);
  border-color: var(--accent);
}

.bot-main {
  width: 100%;
  min-height: 52px;
  border: 0;
  border-radius: 0;
  background: transparent;
  text-align: left;
  display: block;
  padding: 9px 10px 9px 8px;
  min-width: 0;
}

.bot-config-btn {
  min-height: 52px;
  width: 34px;
  padding: 0;
  border: 0;
  border-right: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
  color: var(--muted);
  font-size: 15px;
}

.bot-delete-btn {
  min-height: 52px;
  width: 34px;
  padding: 0;
  border: 0;
  border-left: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
  color: var(--danger);
  font-size: 18px;
}

.bot-config-btn:hover,
.bot-delete-btn:hover {
  background: var(--soft);
  color: var(--accent-dark);
}

.bot-delete-btn:hover {
  color: var(--danger);
}

.bot-item strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bot-item span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-top: 3px;
}

.session-list {
  display: grid;
  align-content: start;
  gap: 7px;
  min-height: 0;
  overflow: auto;
  padding-right: 2px;
}

.session-item {
  width: 100%;
  min-height: 48px;
  border-radius: 8px;
  background: #fff;
  display: grid;
  grid-template-columns: 1fr 32px;
  overflow: hidden;
  border: 1px solid var(--line);
}

.session-item.active {
  background: var(--soft);
  border-color: var(--accent);
}

.session-main {
  min-height: 48px;
  min-width: 0;
  padding: 8px 10px;
  border: 0;
  border-radius: 0;
  text-align: left;
  background: transparent;
}

.session-delete {
  min-height: 48px;
  width: 32px;
  padding: 0;
  border: 0;
  border-left: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
  color: var(--muted);
}

.session-delete:hover {
  color: var(--danger);
  background: #fff5f5;
}

.session-item strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
}

.session-item span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-top: 3px;
}

.main {
  min-width: 0;
}

.topbar {
  min-height: 78px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 14px 20px;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 16px;
  padding: 16px;
  height: calc(100vh - 78px);
  min-height: 640px;
}

.config-pane,
.chat-pane,
.digital-human-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  min-width: 0;
  overflow: hidden;
}

.config-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.24);
  z-index: 20;
}

.config-backdrop.hidden,
.config-drawer.hidden {
  display: none;
}

.config-drawer {
  position: fixed;
  top: 0;
  left: 280px;
  width: min(760px, calc(100vw - 300px));
  height: 100vh;
  z-index: 21;
  border-radius: 0;
  border-top: 0;
  border-bottom: 0;
  box-shadow: 16px 0 40px rgba(15, 23, 42, 0.22);
  display: grid;
  grid-template-rows: auto auto 1fr;
}

.wiki-pane {
  position: fixed;
  top: 0;
  left: 280px;
  width: min(720px, calc(100vw - 300px));
  height: 100vh;
  z-index: 22;
  background: var(--panel);
  border-right: 1px solid var(--line);
  box-shadow: 16px 0 40px rgba(15, 23, 42, 0.22);
  display: grid;
  grid-template-rows: auto 1fr;
}

.wiki-pane.hidden {
  display: none;
}

.wiki-head {
  min-height: 62px;
  border-bottom: 1px solid var(--line);
  padding: 12px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.wiki-head h2 {
  margin: 0;
  font-size: 17px;
}

.wiki-head p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.wiki-content {
  overflow: auto;
  scrollbar-gutter: stable;
  padding: 16px 18px 28px;
}

.users-pane {
  position: fixed;
  top: 0;
  left: 280px;
  width: min(720px, calc(100vw - 300px));
  height: 100vh;
  z-index: 22;
  background: var(--panel);
  border-right: 1px solid var(--line);
  box-shadow: 16px 0 40px rgba(15, 23, 42, 0.22);
  display: grid;
  grid-template-rows: auto auto 1fr;
}

.users-pane.hidden {
  display: none;
}

.users-pane-head {
  min-height: 62px;
  border-bottom: 1px solid var(--line);
  padding: 12px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.users-pane-head h2 {
  margin: 0;
  font-size: 17px;
}

.users-pane-head p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.user-create-form {
  border-bottom: 1px solid var(--line);
  padding: 12px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.user-create-form button {
  align-self: end;
}

.user-list {
  overflow: auto;
  padding: 12px;
  display: grid;
  gap: 10px;
  align-content: start;
}

.user-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
}

.user-card strong,
.user-card span {
  display: block;
}

.user-card span {
  color: var(--muted);
  font-size: 12px;
  margin-top: 3px;
}

.user-actions {
  display: flex;
  gap: 8px;
}

.wiki-tabs {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 16px;
}

.wiki-tab {
  box-sizing: border-box;
  width: 100%;
  border: 1px solid #a7b0be;
  border-radius: 8px;
  background: #fff;
  color: #253244;
  min-height: 40px;
  padding: 7px 8px;
  font-size: 13px;
  line-height: 1.15;
  display: grid;
  place-items: center;
  text-align: center;
}

.wiki-tab.active {
  background: #102033;
  border-color: #102033;
  color: #fff;
  font-weight: 700;
}

.wiki-tab:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -4px;
}

.wiki-section {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 14px;
  margin-bottom: 16px;
}

.wiki-section:last-child {
  margin-bottom: 0;
}

.wiki-section h3 {
  margin: 0 0 8px;
  font-size: 15px;
}

.wiki-section p,
.wiki-section li {
  color: var(--text);
  font-size: 13px;
  line-height: 1.5;
}

.wiki-section ul {
  margin: 8px 0 0;
  padding-left: 18px;
}

.wiki-api-list {
  display: grid;
  gap: 12px;
  margin-top: 16px;
}

.wiki-api-setup {
  border: 2px solid #102033;
  border-radius: 8px;
  background: #eef6ff;
  color: #0b1220;
  padding: 12px;
  margin-top: 16px;
}

.wiki-api-setup strong {
  display: block;
  margin-bottom: 8px;
  font-size: 13px;
}

.wiki-api-setup code {
  display: block;
  background: #fff;
  border: 1px solid #aeb9c8;
  border-radius: 6px;
  color: #0b1220;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.45;
  margin-top: 6px;
  padding: 8px;
  overflow-wrap: anywhere;
}

.wiki-api-card {
  border: 1px solid #c6ceda;
  border-radius: 8px;
  background: #fff;
  padding: 12px;
}

.wiki-api-head {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  margin-bottom: 8px;
}

.wiki-api-head code {
  color: #111827;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.wiki-api-method {
  flex: 0 0 auto;
  min-width: 48px;
  border-radius: 6px;
  padding: 4px 7px;
  text-align: center;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  color: #fff;
  background: #111827;
  font-weight: 800;
}

.wiki-api-method.method-get {
  background: #005a46;
}

.wiki-api-method.method-post {
  background: #8a3000;
}

.wiki-api-method.method-patch {
  background: #3c348f;
}

.wiki-api-card p {
  margin: 0 0 10px;
  font-size: 13px;
  line-height: 1.5;
}

.wiki-api-card strong {
  display: block;
  margin: 10px 0 5px;
  font-size: 12px;
}

.wiki-api-card pre {
  max-height: 220px;
  overflow: auto;
  margin: 0;
  padding: 10px;
  border: 1px solid #b9c2cf;
  border-radius: 8px;
  background: #f4f7fb;
  color: #0b1220;
  font-size: 12px;
  line-height: 1.45;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

@media (max-width: 760px) {
  .wiki-tabs {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.config-drawer-head {
  min-height: 62px;
  border-bottom: 1px solid var(--line);
  padding: 12px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.config-drawer-head h3 {
  margin: 0;
  font-size: 16px;
}

.config-drawer-head p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.config-drawer-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--line);
  padding: 8px;
  overflow-x: auto;
}

.tab {
  white-space: nowrap;
}

.tab.active {
  background: var(--soft);
  color: var(--accent-dark);
  border-color: var(--accent);
}

.tab-panel {
  display: none;
  padding: 14px;
  height: 100%;
  overflow: auto;
}

.tab-panel.active {
  display: block;
}

.identity-tabs,
.live-tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--line);
  margin: -4px -2px 12px;
  padding: 0 2px 8px;
  overflow-x: auto;
}

.identity-tab,
.live-tab {
  min-height: 30px;
  font-size: 12px;
  white-space: nowrap;
}

.identity-tab.active,
.live-tab.active {
  background: var(--soft);
  color: var(--accent-dark);
  border-color: var(--accent);
}

.identity-panel,
.live-panel {
  display: none;
}

.identity-panel.active,
.live-panel.active {
  display: block;
}

label {
  display: block;
  color: var(--muted);
  font-size: 13px;
  margin: 12px 0 6px;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  padding: 10px;
}

textarea {
  min-height: 460px;
  resize: vertical;
  line-height: 1.45;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

textarea.readonly {
  background: #f3f5f7;
  color: var(--muted);
}

.toggle-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  margin-top: 12px;
}

.toggle-row label {
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px;
  margin: 0;
  font-size: 12px;
}

.toggle-row input {
  width: auto;
  margin-right: 6px;
}

pre {
  background: var(--code);
  color: #eef2f7;
  padding: 12px;
  border-radius: 6px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

.knowledge-upload {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
  margin-bottom: 14px;
}

.service-list {
  display: grid;
  gap: 12px;
}

.service-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 12px;
}

.service-card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}

.service-enabled {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  color: var(--text);
}

.service-enabled input {
  width: auto;
}

.service-remove {
  color: var(--danger);
  min-width: 82px;
  height: 34px;
}

.service-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 92px 150px 150px;
  gap: 10px;
}

.service-auth-details {
  display: grid;
  gap: 6px;
  min-height: 78px;
  margin-top: 10px;
}

.service-auth-details > span {
  color: var(--muted);
  font-size: 12px;
}

.service-auth-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  align-items: end;
}

.service-auth-none {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--muted);
  display: flex;
  align-items: center;
  padding: 0 10px;
}

@media (max-width: 760px) {
  .service-grid,
  .service-auth-fields {
    grid-template-columns: 1fr;
  }
}

.export-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.knowledge-list {
  display: grid;
  gap: 8px;
}

.knowledge-job-list {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
}

.knowledge-job-list:empty {
  display: none;
}

.knowledge-job-list h4 {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
}

.knowledge-item {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
}

.knowledge-main {
  appearance: none;
  border: 0;
  background: transparent;
  color: inherit;
  padding: 0;
  text-align: left;
  cursor: pointer;
}

.knowledge-main:hover strong {
  text-decoration: underline;
}

.knowledge-job {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
  background: var(--panel-2);
}

.knowledge-job.failed {
  border-color: #d16868;
}

.knowledge-job.succeeded {
  opacity: 0.78;
}

.knowledge-item strong {
  display: block;
}

.knowledge-item span,
.knowledge-job span {
  color: var(--muted);
  font-size: 12px;
}

.knowledge-preview {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-2);
  padding: 12px;
  margin-bottom: 14px;
  max-height: 420px;
  overflow: auto;
}

.knowledge-preview-head {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: start;
  margin-bottom: 12px;
}

.knowledge-preview-head h4 {
  margin: 0;
  font-size: 15px;
}

.knowledge-preview-head span {
  color: var(--muted);
  font-size: 12px;
}

.knowledge-preview-body {
  display: grid;
  gap: 12px;
}

.knowledge-section-preview {
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.knowledge-section-preview h5 {
  margin: 0 0 8px;
  font-size: 13px;
}

.knowledge-summary strong,
.knowledge-notes strong {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 4px;
}

.knowledge-summary p,
.knowledge-notes p {
  margin: 0 0 8px;
}

.knowledge-notes ul {
  margin: 0;
  padding-left: 18px;
}

.knowledge-notes li {
  margin-bottom: 8px;
}

.knowledge-notes li span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-top: 2px;
}

.chat-pane {
  display: grid;
  grid-template-rows: auto 1fr auto auto auto;
}

.runtime-grid {
  display: grid;
  grid-template-columns: minmax(440px, 1fr) minmax(320px, 38%);
  gap: 16px;
  min-height: 0;
  height: 100%;
}

.chat-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  border-bottom: 1px solid var(--line);
  padding: 12px;
}

.chat-title {
  min-width: 0;
}

.chat-title h3,
.chat-title p {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  min-width: 0;
}

.toolbar-button {
  width: 132px;
  min-width: 132px;
  max-width: 132px;
  padding: 0 8px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.icon-button {
  width: 36px;
  height: 36px;
  min-width: 36px;
  min-height: 36px;
  padding: 0;
  border-radius: 999px;
  display: inline-grid;
  place-items: center;
  font-size: 15px;
  line-height: 1;
}

#modeToggleBtn.active,
#digitalHumanBtn.connected,
#liveToggleBtn.live-on {
  background: var(--soft);
  border-color: var(--accent);
  color: var(--accent-dark);
}

#liveStopBtn span {
  font-size: 13px;
  line-height: 1;
}

#liveStopBtn.live-stop-ready {
  color: var(--danger);
  border-color: #e7b3ad;
}

.digital-human-panel {
  align-self: stretch;
  padding: 12px;
  display: grid;
  min-height: 0;
}

.avatar-frame {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, #f3f5f7, #e6eaef);
  overflow: hidden;
  display: grid;
  place-items: center;
}

.avatar-frame.connected {
  border-color: var(--accent);
  background: linear-gradient(180deg, #edf8f6, #e4eceb);
}

.avatar-video-mount {
  position: absolute;
  inset: 0;
  z-index: 1;
  background: #111827;
}

.avatar-video-mount:empty {
  display: none;
}

.avatar-video-mount video,
.avatar-video-mount canvas {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  background: #111827;
}

.avatar-silhouette {
  width: min(42%, 220px);
  height: 72%;
  display: grid;
  justify-items: center;
  align-content: end;
  gap: 0;
  opacity: 0.8;
}

.avatar-frame.video-ready .avatar-silhouette {
  display: none;
}

.avatar-head {
  width: 35%;
  aspect-ratio: 1;
  border-radius: 999px;
  background: #9aa4b2;
  margin-bottom: -2%;
}

.avatar-body {
  width: 70%;
  height: 58%;
  border-radius: 48% 48% 8% 8%;
  background: #8e98a8;
}

.avatar-status {
  position: absolute;
  z-index: 2;
  left: 12px;
  right: 12px;
  bottom: 10px;
  min-height: 44px;
  border-top: 1px solid rgba(23, 32, 44, 0.12);
  display: grid;
  align-content: center;
}

.avatar-status strong {
  font-size: 13px;
}

.avatar-status span {
  color: var(--muted);
  font-size: 12px;
}

.inline-check {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 64px;
  padding-top: 22px;
}

@media (max-width: 1120px) {
  .runtime-grid {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(320px, 42vh) minmax(0, 1fr);
  }

  .digital-human-panel {
    order: -1;
  }
}

.messages {
  overflow: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.message {
  max-width: 86%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  white-space: pre-wrap;
  line-height: 1.45;
}

.message.user {
  align-self: flex-end;
  background: var(--soft);
  border-color: #b8d9d6;
}

.message.assistant {
  align-self: flex-start;
  background: #fff;
}

.message.streaming::after {
  content: " ▌";
  color: var(--accent);
}

.message.service {
  align-self: flex-start;
  background: #eef6ff;
  border-color: #93b4d8;
  color: #0b355c;
}

.message.service-error {
  align-self: flex-start;
  background: #fff1f2;
  border-color: #f0a8ae;
  color: #7a1e26;
}

.message.local-debug {
  align-self: stretch;
  max-width: 100%;
  background: #f7f5ef;
  border-color: #d8d0bd;
  color: #302a21;
}

.openfm-debug {
  font-size: 13px;
}

.openfm-debug-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
  color: #5b4b36;
}

.openfm-debug-header span,
.openfm-debug-empty {
  color: var(--muted);
}

.openfm-debug-section {
  border-top: 1px solid #ded5c3;
  padding-top: 10px;
  margin-top: 10px;
}

.openfm-debug-section h4 {
  margin: 0 0 8px;
  font-size: 13px;
}

.openfm-debug-item {
  border: 1px solid #e2dacb;
  border-radius: 8px;
  background: #fffdf8;
  padding: 8px;
  margin-top: 8px;
}

.openfm-debug-line {
  display: grid;
  grid-template-columns: 110px minmax(0, 1fr);
  gap: 8px;
  margin: 2px 0;
  overflow-wrap: anywhere;
}

.openfm-debug-key {
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.openfm-debug-item p {
  margin: 8px 0 0;
}

.studio-section {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 12px;
  background: #fff;
}

.studio-section-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 10px;
}

.studio-section-head.compact {
  margin-bottom: 8px;
}

.studio-section-head h3 {
  margin: 0;
  font-size: 14px;
}

.studio-section-head p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.auto-live-actions {
  display: flex;
  gap: 8px;
}

.studio-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.studio-grid label {
  margin: 0;
}

.studio-grid input,
.studio-grid select {
  margin-top: 5px;
  padding: 8px;
  min-height: 34px;
}

.studio-grid input:disabled,
.studio-grid select:disabled,
.category-choice:disabled,
.category-pill button:disabled {
  background: #f3f5f7;
  color: var(--muted);
  border-color: var(--line);
  opacity: 0.72;
}

.auto-live-categories {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 10px;
}

.category-choices,
.category-order {
  border: 1px solid var(--line);
  border-radius: 6px;
  min-height: 72px;
  max-height: 132px;
  overflow: auto;
  padding: 8px;
  display: flex;
  flex-wrap: wrap;
  align-content: flex-start;
  gap: 6px;
}

.category-choice,
.category-pill {
  border: 1px solid var(--line);
  border-radius: 6px;
  min-height: 30px;
  padding: 5px 8px;
  background: #fff;
  font-size: 12px;
}

.category-choice.active {
  background: var(--soft);
  border-color: var(--accent);
  color: var(--accent-dark);
}

.category-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.category-pill button {
  min-height: 22px;
  padding: 0 6px;
  font-size: 12px;
}

.rundown-list {
  display: grid;
  gap: 10px;
}

.rundown-run {
  display: grid;
  gap: 6px;
}

.rundown-run-head {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  line-height: 1.35;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding: 6px 0;
}

.rundown-run-head button {
  min-height: 24px;
  width: 24px;
  padding: 0;
  color: var(--muted);
}

.rundown-run-head button:hover {
  color: var(--danger);
  border-color: var(--danger);
}

.rundown-run-body {
  display: grid;
  gap: 6px;
}

.rundown-category {
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  margin-top: 6px;
}

.rundown-item {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 9px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
}

.rundown-item strong {
  display: block;
  font-size: 13px;
  line-height: 1.3;
}

.rundown-item span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-top: 3px;
}

.rundown-item em {
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 7px;
  white-space: nowrap;
}

.rundown-item.status-script_ready em {
  background: var(--soft);
  border-color: #b8d9d6;
  color: var(--accent-dark);
}

.rundown-item.status-script_generating em {
  background: #fff7ed;
  border-color: #fed7aa;
  color: #9a3412;
}

.chat-form.hidden {
  display: none;
}

.live-line,
.live-audience,
.live-response,
.live-note {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 11px;
  line-height: 1.45;
  white-space: pre-wrap;
}

.live-line {
  background: #fff;
}

.live-audience {
  background: var(--soft);
  border-color: #b8d9d6;
}

.live-response {
  background: #fff7ed;
  border-color: #fed7aa;
}

.live-note {
  background: #f8fafc;
  color: var(--muted);
  font-size: 13px;
}

.chat-form {
  display: grid;
  grid-template-columns: 1fr minmax(92px, auto);
  gap: 8px;
  padding: 12px;
  border-top: 1px solid var(--line);
}

.chat-form textarea {
  min-height: 48px;
  max-height: 130px;
  font-family: inherit;
}

.send-button {
  min-width: 92px;
  min-height: 48px;
  padding: 5px 10px;
  display: grid;
  place-items: center;
  align-content: center;
  line-height: 1.05;
}

.send-button span {
  font-size: 13px;
  font-weight: 600;
}

.send-button small {
  display: block;
  font-size: 10px;
  color: var(--muted);
  white-space: nowrap;
}

.toast {
  position: fixed;
  right: 16px;
  bottom: 16px;
  max-width: min(420px, calc(100vw - 32px));
  background: #17202c;
  color: #fff;
  padding: 10px 12px;
  border-radius: 6px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.18);
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: 160ms ease;
}

.toast.visible {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 980px) {
  .app {
    grid-template-columns: 1fr;
  }

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
    height: auto;
    grid-template-rows: auto auto auto;
  }

  .bot-list,
  .session-list {
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    max-height: 240px;
  }

  .workspace {
    grid-template-columns: 1fr;
    height: auto;
  }

  .config-drawer {
    left: 0;
    width: 100vw;
  }

  .studio-grid,
  .auto-live-categories {
    grid-template-columns: 1fr;
  }

  .config-pane,
  .chat-pane {
    min-height: 560px;
  }

  .chat-head {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .chat-actions {
    justify-content: flex-end;
    flex-wrap: wrap;
  }
}
