:root {
  --bg: #eaf0fb;
  --bg-grad-1: #0b3d9a;
  --bg-grad-2: #0a2d7a;
  --panel: rgba(255, 255, 255, 0.94);
  --panel-strong: #ffffff;
  --panel-soft: #f4f7ff;
  --panel-blue: linear-gradient(180deg, #0f4ab7 0%, #0a2f81 100%);
  --panel-blue-soft: linear-gradient(180deg, rgba(20, 79, 188, 0.16) 0%, rgba(20, 79, 188, 0.06) 100%);
  --text: #10213d;
  --heading: #0c1f50;
  --muted: #5f6f8f;
  --line: rgba(12, 42, 107, 0.12);
  --line-strong: rgba(12, 42, 107, 0.18);
  --accent: #f7a620;
  --accent-strong: #f08a00;
  --accent-soft: rgba(247, 166, 32, 0.16);
  --accent-glow: rgba(247, 166, 32, 0.28);
  --danger: #cb3d4d;
  --shadow: 0 18px 48px rgba(12, 42, 107, 0.12);
  --shadow-strong: 0 24px 60px rgba(11, 39, 98, 0.16);
  --message-shadow: 0 14px 40px rgba(19, 56, 129, 0.10);
  color-scheme: light;
}
html[data-theme="dark"] {
  --bg: #081631;
  --bg-grad-1: #0a2f81;
  --bg-grad-2: #061942;
  --panel: rgba(12, 27, 61, 0.92);
  --panel-strong: rgba(8, 22, 49, 0.98);
  --panel-soft: rgba(255, 255, 255, 0.045);
  --panel-blue: linear-gradient(180deg, #114fc0 0%, #0a2f81 100%);
  --panel-blue-soft: linear-gradient(180deg, rgba(247, 166, 32, 0.13) 0%, rgba(17, 79, 192, 0.08) 100%);
  --text: #eef3ff;
  --heading: #ffffff;
  --muted: #9fb1d7;
  --line: rgba(255, 255, 255, 0.09);
  --line-strong: rgba(255, 255, 255, 0.16);
  --accent: #ffb22d;
  --accent-strong: #ff9800;
  --accent-soft: rgba(255, 178, 45, 0.16);
  --accent-glow: rgba(255, 178, 45, 0.24);
  --danger: #ff8d98;
  --shadow: 0 20px 56px rgba(0, 0, 0, 0.34);
  --shadow-strong: 0 26px 72px rgba(0, 0, 0, 0.40);
  --message-shadow: 0 16px 46px rgba(0, 0, 0, 0.24);
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body {
  margin: 0;
  height: 100%;
  min-height: 100%;
  background:
    radial-gradient(circle at top right, rgba(247, 166, 32, 0.12), transparent 26%),
    linear-gradient(180deg, rgba(12, 61, 154, 0.06) 0%, transparent 28%),
    var(--bg);
  color: var(--text);
  font-family: Inter, "Segoe UI", system-ui, sans-serif;
}
body::before {
  content: "";
  position: fixed;
  inset: 0 0 auto 0;
  height: 220px;
  background: linear-gradient(135deg, var(--bg-grad-1) 0%, #0f51c7 45%, var(--bg-grad-2) 100%);
  z-index: -2;
}
body { overflow: hidden; }
[hidden] { display: none !important; }
body::after {
  content: "";
  position: fixed;
  top: 0;
  right: 6vw;
  width: 260px;
  height: 180px;
  background: radial-gradient(circle, rgba(255,255,255,0.18), transparent 68%);
  z-index: -1;
  pointer-events: none;
}
button, input, textarea, select { font: inherit; }
button {
  cursor: pointer;
  border: 1px solid transparent;
  background: linear-gradient(180deg, var(--accent) 0%, var(--accent-strong) 100%);
  color: #fff;
  font-weight: 700;
  letter-spacing: 0.01em;
  padding: 0.7rem 1.05rem;
  border-radius: 16px;
  box-shadow: 0 10px 24px var(--accent-glow);
  transition: transform .16s ease, box-shadow .16s ease, filter .16s ease;
}
button.secondary {
  background: var(--panel-strong);
  color: var(--heading);
  border-color: var(--line-strong);
  box-shadow: none;
}
button.danger {
  background: rgba(203, 61, 77, 0.10);
  border-color: rgba(203, 61, 77, 0.16);
  color: var(--danger);
  box-shadow: none;
}
button:hover { transform: translateY(-1px); filter: saturate(1.05); }
button:active { transform: translateY(0); }
input, textarea, select {
  width: 100%;
  border-radius: 16px;
  border: 1px solid var(--line-strong);
  background: var(--panel-soft);
  color: var(--text);
  padding: 0.88rem 1rem;
  outline: none;
}
input:focus, textarea:focus, select:focus {
  border-color: rgba(17, 79, 192, 0.34);
  box-shadow: 0 0 0 4px rgba(17, 79, 192, 0.10);
}
textarea { resize: vertical; min-height: 72px; max-height: 240px; line-height: 1.55; }
.app-shell {
  display: grid;
  grid-template-columns: 372px minmax(0, 1fr) 340px;
  min-height: 100vh;
  height: 100vh;
  gap: 0;
  overflow: hidden;
}
.sidebar {
  display: flex;
  flex-direction: column;
  padding: 18px;
  border-right: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(8, 36, 94, 0.12), rgba(255,255,255,0.0) 220px), transparent;
  overflow: hidden;
  min-height: 0;
  height: 100vh;
}
.sidebar-scroll {
  flex: 1 1 auto;
  overflow-y: auto;
  overflow-x: hidden;
  min-height: 0;
  padding-right: 2px;
  padding-top: 16px;
}
.main-panel { display: grid; grid-template-rows: auto minmax(0, 1fr); min-width: 0; min-height: 0; height: 100vh; overflow: hidden; }
.insights-panel {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  height: 100vh;
  padding: 18px 18px 18px 0;
}
.insight-card {
  position: relative;
  background: var(--panel);
  backdrop-filter: blur(16px);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}
.insight-card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 10px;
  background: linear-gradient(90deg, var(--bg-grad-2), #0f51c7 72%, var(--accent) 100%);
}
.insights-scroll { flex: 1 1 auto; overflow-y: auto; min-height: 0; display: grid; gap: 14px; padding-right: 2px; }
.insight-card { border-radius: 0 0 22px 22px; padding: 20px 16px 16px; overflow: hidden; background: linear-gradient(180deg, rgba(255,255,255,0.98), rgba(247,250,255,0.96)); min-height: 0; display: flex; flex-direction: column; }
.insight-card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 12px; }
.insight-card-head h3 { margin: 0; color: var(--heading); font-size: 1.04rem; }
.insight-card-head p { margin: 4px 0 0; color: var(--muted); }
.placeholder-stack { display:grid; gap:12px; }
.placeholder-card { border: 1px dashed var(--line-strong); border-radius: 18px; background: var(--panel-soft); padding: 14px; color: var(--muted); line-height: 1.55; }
.memo-tabs { display:flex; gap:8px; flex-wrap:wrap; margin-bottom:12px; }
.memo-tab { padding: 0.7rem 0.95rem; border-radius: 14px; }
.brand-card, .control-card, .center-tab-header, .composer-shell {
  position: relative;
  background: var(--panel);
  backdrop-filter: blur(16px);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}
.brand-card {
  border-radius: 0 0 26px 26px;
  padding: 18px;
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 1px;
  background: linear-gradient(135deg, rgba(255,255,255,0.96), rgba(236,242,255,0.94));
  overflow: hidden;
  position: relative;
  z-index: 8;
  flex: 0 0 auto;
}
.brand-card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 68px;
  background: linear-gradient(90deg, var(--bg-grad-2), #0f51c7 58%, #1e72ea 100%);
}
.brand-card::after {
  content: "";
  position: absolute;
  right: -26px;
  top: -34px;
  width: 132px;
  height: 132px;
  background: radial-gradient(circle, rgba(247,166,32,0.24), transparent 68%);
}
.brand-card > * { position: relative; }
.brand-card h1 {
  margin: 0;
  color: #fff;
  text-shadow: 0 2px 12px rgba(0,0,0,0.18);
}
.brand-card p {
  margin: 0.35rem 0 0;
  color: rgba(255,255,255,0.86);
  font-size: 0.92rem;
}
.brand-mark {
  width: 58px;
  height: 58px;
  margin-top: 18px;
  border-radius: 19px;
  display: grid;
  place-items: center;
  background: linear-gradient(180deg, #fff 0%, #dbe8ff 100%);
  color: #0d368a;
  font-weight: 900;
  font-size: 1.1rem;
  box-shadow: 0 12px 30px rgba(6, 32, 84, 0.25);
}
.control-card {
  border-radius: 0 0 24px 24px;
  padding: 16px;
  margin-bottom: 14px;
  background: linear-gradient(180deg, rgba(255,255,255,0.98), rgba(247,250,255,0.96));
}
.control-card::before,
.center-tab-header::before,
.composer-shell::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 10px;
  border-radius: inherit inherit 0 0;
  background: linear-gradient(90deg, var(--bg-grad-2), #0f51c7 72%, var(--accent) 100%);
}
.control-card label {
  display: block;
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--heading);
  margin-bottom: 8px;
}
.control-row { display: flex; gap: 10px; align-items: center; }
.inline-note { color: var(--muted); font-size: 0.9rem; line-height: 1.45; }
.pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(17, 79, 192, 0.10), rgba(17, 79, 192, 0.04));
  padding: 0.42rem 0.8rem;
  color: var(--heading);
  border: 1px solid var(--line);
  font-size: 0.85rem;
  font-weight: 700;
}
.chat-list { display: grid; gap: 10px; }
.chat-item {
  width: 100%;
  text-align: left;
  background: linear-gradient(180deg, var(--panel-strong) 0%, #f5f8ff 100%);
  color: var(--text);
  border-radius: 20px;
  border: 1px solid var(--line);
  padding: 14px;
  box-shadow: 0 10px 24px rgba(17, 79, 192, 0.08);
}
.chat-item.active {
  outline: 2px solid rgba(247, 166, 32, 0.86);
  box-shadow: 0 12px 30px rgba(247, 166, 32, 0.18);
}
.chat-item-head, .chat-item-foot { display: flex; justify-content: space-between; gap: 10px; }
.chat-title { font-weight: 800; color: var(--heading); }
.chat-preview, .chat-date, .chat-count, .chat-score { color: var(--muted); font-size: 0.88rem; }
.chat-preview { margin: 8px 0; line-height: 1.48; }
.center-tab-header {
  display: flex;
  align-items: stretch;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 18px 12px;
  margin: 18px 18px 0 18px;
  border-radius: 0 0 24px 24px;
  background: linear-gradient(180deg, rgba(255,255,255,0.98), rgba(247,250,255,0.96));
  position: relative;
  z-index: 3;
}
.center-tab-buttons {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1 1 auto;
  min-width: 0;
}
.center-tab-button {
  flex: 1 1 0;
  min-width: 112px;
  max-width: 180px;
  background: var(--panel-strong);
  color: var(--heading);
  border-color: var(--line-strong);
  box-shadow: none;
}
.center-tab-button.active {
  background: linear-gradient(180deg, var(--accent) 0%, var(--accent-strong) 100%);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 10px 24px var(--accent-glow);
}
.center-tab-controls {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  flex: 0 1 auto;
  min-width: 0;
  margin-left: auto;
}
.center-tab-controls[hidden] {
  display: none !important;
}
.center-tab-controls.is-empty {
  display: none;
}
.tab-controls {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 14px;
  width: auto;
  max-width: 100%;
  margin-left: auto;
}
.center-pane-body {
  min-height: 0;
  overflow: hidden;
  padding: 18px;
  padding-top: 1px;
}
.tab-panel {
  display: none;
  height: 100%;
  min-height: 0;
}
.tab-panel.active {
  display: grid;
}
.chat-tab-panel {
  grid-template-rows: minmax(0, 1fr) auto;
  overflow: hidden;
}
.develop-tab-panel {
  overflow-y: auto;
  align-content: start;
}
.develop-placeholder-card {
  position: relative;
  background: linear-gradient(180deg, rgba(255,255,255,0.98), rgba(247,250,255,0.96));
  backdrop-filter: blur(16px);
  border: 1px solid var(--line);
  border-radius: 0 0 24px 24px;
  box-shadow: var(--shadow);
  overflow: hidden;
  padding: 28px 22px 22px;
}
.develop-placeholder-card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 10px;
  background: linear-gradient(90deg, var(--bg-grad-2), #0f51c7 72%, var(--accent) 100%);
}
.develop-placeholder-card h2,
.develop-placeholder-card p {
  position: relative;
}
.develop-placeholder-card h2 {
  margin: 0 0 10px;
  color: var(--heading);
}
.develop-placeholder-card p {
  margin: 0 0 12px;
  color: var(--muted);
  line-height: 1.6;
}
.message-list {
  overflow-anchor: none;
  /*margin: 0 18px 18px 18px;*/
  padding: 16px 8px 24px;
  overflow-y: auto;
  overflow-x: hidden;
  min-width: 0;
  min-height: 0;
  overscroll-behavior: contain;
}
.message {
  max-width: 1040px;
  margin: 0 auto 18px auto;
  display: grid;
  grid-template-columns: 104px minmax(0, 1fr);
  gap: 14px;
}
.message-role {
  color: var(--heading);
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding-top: 14px;
}
.message-role::before {
  content: "";
  display: block;
  width: 56px;
  height: 56px;
  margin-bottom: 10px;
  border-radius: 999px;
  background: radial-gradient(circle at 30% 30%, #ffffff 0%, #d9e7ff 34%, #114fc0 100%);
  box-shadow: inset 0 0 0 4px rgba(255,255,255,0.50), 0 10px 24px rgba(17,79,192,0.16);
}
.message.user .message-role::before {
  background: radial-gradient(circle at 30% 30%, #fff4df 0%, #ffd483 38%, #f39a0e 100%);
  box-shadow: inset 0 0 0 4px rgba(255,255,255,0.45), 0 10px 24px rgba(247,166,32,0.22);
}
.message-body {
  min-width: 0;
  padding: 18px 20px;
  border-radius: 24px;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, var(--panel-strong) 0%, #f8fbff 100%);
  box-shadow: var(--message-shadow);
  overflow: hidden;
}
.message.user .message-body {
  background: linear-gradient(180deg, rgba(247, 166, 32, 0.14), rgba(255,255,255,0.98));
  border-color: rgba(247, 166, 32, 0.22);
}
.message-body > :first-child { margin-top: 0; }
.message-body > :last-child { margin-bottom: 0; }
.message-body p { margin: 0 0 0.95rem; line-height: 1.68; overflow-wrap: anywhere; }
.message-body a { color: #1256cf; font-weight: 600; }
.message-body pre, .message-body code, .message-body table, .message-body iframe, .message-body object { max-width: 100%; }
.message-body code {
  border-radius: 8px;
  background: rgba(17,79,192,0.08);
  padding: 0.12rem 0.4rem;
}
.message-body pre {
  overflow-y: auto;
  overflow-x: hidden;
  background: linear-gradient(180deg, #10295d 0%, #0a1e48 100%);
  color: #eff5ff;
  border-radius: 18px;
  padding: 15px;
  border: 1px solid rgba(255,255,255,0.08);
}
.message-body table {
  display: block;
  overflow: auto;
  border-collapse: collapse;
  width: 100%;
  margin: 0.75rem 0;
  background: var(--panel-strong);
}
.message-body th {
  background: linear-gradient(180deg, #f0f5ff 0%, #e4edff 100%);
  color: var(--heading);
}
.message-body th, .message-body td {
  border: 1px solid var(--line);
  padding: 0.72rem 0.82rem;
  text-align: left;
  vertical-align: top;
}
.message-body img, .message-body video {
  max-width: min(100%, 860px);
  height: auto;
  border-radius: 18px;
  display: block;
  border: 1px solid var(--line);
  box-shadow: 0 10px 28px rgba(17,79,192,0.10);
}
.message-body iframe, .message-body object {
  width: 100%;
  height: min(72vh, 760px);
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #fff;
}
.message-body ul, .message-body ol { padding-left: 1.2rem; }
.viewer-card {
  border: 1px solid var(--line);
  border-radius: 20px;
  overflow: hidden;
  background: var(--panel-soft);
  margin: 0.9rem 0;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.4);
}
.viewer-header {
  padding: 0.84rem 1rem;
  border-bottom: 1px solid var(--line);
  font-size: 0.9rem;
  color: var(--heading);
  font-weight: 800;
  background: linear-gradient(180deg, rgba(17,79,192,0.10), rgba(17,79,192,0.04));
}
.composer-shell {
  margin: 0 18px 18px;
  border-radius: 0 0 28px 28px;
  padding: 8px 16px 12px;
  background: linear-gradient(180deg, rgba(255,255,255,0.98) 0%, rgba(245,248,255,0.97) 100%);
  position: sticky;
  bottom: 0;
  z-index: 7;
}
.upload-zone {
  position: relative;
  box-sizing: border-box;
  display: flex;
  justify-content: center;
  gap: 8px;
  align-items: center;
  border: 1px dashed rgba(17, 79, 192, 0.26);
  border-radius: 18px;
  padding: 0 10px;
  min-width: 0;
  height: 46px;
  min-height: 46px;
  max-height: 46px;
  background: linear-gradient(180deg, rgba(17,79,192,0.06), rgba(17,79,192,0.03));
  color: var(--heading);
  font-weight: 800;
  white-space: nowrap;
}
.upload-zone.drag { border-color: var(--accent); background: linear-gradient(180deg, rgba(247,166,32,0.14), rgba(247,166,32,0.07)); }

.upload-zone.upload-disabled {
  cursor: not-allowed;
}
.upload-zone.upload-disabled button,
.upload-zone.upload-disabled span {
  filter: grayscale(1);
  opacity: 0.48;
}
.upload-blocker {
  display: none;
}
.upload-zone.upload-disabled .upload-blocker {
  position: absolute;
  inset: 0;
  display: block;
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(120,130,145,0.26), rgba(120,130,145,0.18));
  border: 1px solid rgba(120,130,145,0.22);
  z-index: 3;
  pointer-events: auto;
}
.upload-zone button { width: 28px; min-height: 28px; padding: 0; border-radius: 999px; }
.upload-zone span { overflow: hidden; text-overflow: ellipsis; }
.attachment-list { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.attachment-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: linear-gradient(180deg, #fff 0%, #f4f8ff 100%);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.52rem 0.86rem;
  font-size: 0.88rem;
  box-shadow: 0 8px 18px rgba(17,79,192,0.06);
}
.composer-row { display: grid; grid-template-columns: 140px 1fr 128px; gap: 12px; align-items: center; }
.composer-row textarea { box-sizing: border-box; min-height: 46px; height: 46px; max-height: 46px; resize: none; padding-top: 0.7rem; padding-bottom: 0.7rem; line-height: 1.2; overflow-y: auto; }
.composer-row > button { box-sizing: border-box; height: 46px; min-height: 46px; max-height: 46px; display: inline-flex; align-items: center; justify-content: center; }
::selection { background: rgba(247, 166, 32, 0.26); }
@media (max-width: 1380px) { .app-shell { grid-template-columns: 336px minmax(0, 1fr) 300px; } }
@media (max-width: 1120px) {
  body { overflow: auto; }
  .app-shell { grid-template-columns: 320px minmax(0, 1fr); grid-template-areas: 'sidebar main' 'sidebar insights'; height: auto; min-height: 100vh; overflow: visible; }
  .sidebar { grid-area: sidebar; border-right: 1px solid var(--line); border-bottom: 0; height: auto; min-height: 100vh; }
  .main-panel { grid-area: main; height: auto; min-height: 58vh; }
  .insights-panel { grid-area: insights; height: auto; padding: 0 18px 18px 0; }
  .insights-scroll { overflow: visible; }
}
@media (max-width: 720px) {
  .message { grid-template-columns: 1fr; }
  .message-role { display: flex; align-items: center; gap: 12px; padding-top: 0; }
  .message-role::before { margin-bottom: 0; flex: 0 0 auto; }
  .composer-row { grid-template-columns: 1fr; }
  .chat-header { flex-direction: column; align-items: flex-start; }
  .upload-zone { width: 100%; }
}

.admin-card-head { display:flex; align-items:center; justify-content:space-between; gap:10px; margin-bottom:10px; }
.admin-workspace-list { display:grid; gap:10px; margin-top:12px; }
.admin-workspace-item { display:flex; justify-content:space-between; gap:10px; align-items:flex-start; padding:12px; border:1px solid var(--line); border-radius:18px; background:var(--panel-soft); }
.admin-workspace-meta { display:grid; gap:4px; }
.admin-workspace-meta span { color: var(--muted); font-size: 0.86rem; }
.admin-workspace-actions { display:flex; gap:8px; flex-wrap:wrap; }
@media (max-width: 980px) {
  .app-shell { grid-template-columns: 1fr; grid-template-areas: none; }
  .sidebar, .main-panel, .insights-panel { height: auto; }
  .sidebar { border-right: none; border-bottom: 1px solid var(--line); min-height: 0; }
  .sidebar-scroll { max-height: 42vh; }
  .insights-panel { padding: 0 18px 18px 18px; }
}




.streaming-text { white-space: pre-wrap; line-height: 1.68; overflow-wrap: anywhere; }
.stream-target { min-height: 1.5rem; overflow-anchor: none; }
.message[data-ephemeral="true"] { overflow-anchor: none; }
.thinking-indicator { display:flex; align-items:center; gap:10px; min-height: 28px; margin-bottom: 0.5rem; }
.thinking-spinner { width: 18px; height: 18px; border-radius: 50%; border: 2px solid rgba(17,79,192,0.18); border-top-color: var(--accent); animation: spin 0.9s linear infinite; }
.thinking-dots { display:flex; align-items:center; flex-wrap:wrap; gap:6px; min-height:18px; }
.think-dot { width: 10px; height: 10px; border-radius: 50%; background: radial-gradient(circle at 30% 30%, #fff 0%, #ffe1a8 26%, #f6a41f 68%, #d67900 100%); box-shadow: inset 0 1px 1px rgba(255,255,255,0.65), 0 2px 4px rgba(240,138,0,0.22); }
.wait-dot { width: 10px; height: 10px; border-radius: 50%; background: radial-gradient(circle at 30% 30%, #fff 0%, #eef1f5 30%, #aeb7c4 68%, #737d8b 100%); box-shadow: inset 0 1px 1px rgba(255,255,255,0.72), 0 2px 4px rgba(36,48,65,0.18); }
.syntax-block code { display:block; white-space: pre-wrap; }
.tok-key { color: #8fd3ff; }
.tok-string { color: #ffd28c; }
.tok-number { color: #b9f27c; }
.tok-keyword { color: #ff93c9; }
.tok-tag { color: #8fd3ff; }
.tok-attr { color: #f9b95c; }
@keyframes spin { to { transform: rotate(360deg); } }

.center-pane-body .message-list {
  margin-left: 0;
  margin-right: 0;
}
.center-pane-body .composer-shell {
  margin: 0;
}
@media (max-width: 1180px) {
  .center-tab-header {
    flex-direction: column;
    align-items: stretch;
  }
  .tab-controls {
    justify-content: space-between;
    flex-wrap: wrap;
  }
}
@media (max-width: 820px) {
  .center-tab-buttons {
    flex-wrap: wrap;
  }
  .center-tab-button {
    flex: 1 1 calc(50% - 10px);
    max-width: none;
  }
}

.snippet-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 28px;
  background: rgba(5, 12, 28, 0.48);
  backdrop-filter: blur(8px);
}
.snippet-modal-panel {
  width: min(940px, calc(100vw - 42px));
  max-height: min(820px, calc(100vh - 42px));
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
  border: 1px solid rgba(255,255,255,0.24);
  border-radius: 0 0 28px 28px;
  background: var(--panel);
  box-shadow: var(--shadow-strong);
  color: var(--text);
  font-family: Inter, "Segoe UI", system-ui, sans-serif;
}
.snippet-modal-header {
  position: sticky;
  top: 0;
  z-index: 2;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 18px;
  align-items: start;
  padding: 18px 20px;
  background: var(--panel-blue);
  color: #fff;
}
.snippet-modal-question { min-width: 0; display: grid; gap: 6px; }
.snippet-modal-question span {
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  opacity: 0.82;
}
.snippet-modal-question strong {
  font-size: 1.02rem;
  line-height: 1.45;
  overflow-wrap: anywhere;
}
.snippet-modal-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.snippet-modal-actions button.secondary {
  background: rgba(255,255,255,0.14);
  color: #fff;
  border-color: rgba(255,255,255,0.32);
  box-shadow: none;
}
.snippet-modal-actions button:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }
.snippet-modal-body {
  overflow: auto;
  padding: 18px 20px 22px;
  display: grid;
  gap: 14px;
  background: linear-gradient(180deg, var(--panel-strong) 0%, var(--panel-soft) 100%);
}
.snippet-meta-card {
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 14px 16px;
  background: var(--panel);
}
.snippet-meta-card h3 { margin: 0 0 10px; color: var(--heading); font-size: 1rem; }
.snippet-meta-grid { display: grid; grid-template-columns: 110px minmax(0, 1fr); gap: 6px 12px; align-items: baseline; }
.snippet-meta-grid span { color: var(--muted); font-size: 0.86rem; }
.snippet-meta-grid strong { min-width: 0; overflow-wrap: anywhere; font-size: 0.92rem; color: var(--text); }
.snippet-terms { display: flex; flex-wrap: wrap; gap: 8px; }
.snippet-terms span {
  border: 1px solid rgba(17,79,192,0.20);
  border-radius: 999px;
  padding: 0.42rem 0.72rem;
  background: var(--panel-blue-soft);
  color: var(--heading);
  font-weight: 700;
  font-size: 0.88rem;
}
.snippet-text {
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 16px;
  background: var(--panel-strong);
  line-height: 1.68;
  overflow-wrap: anywhere;
  white-space: normal;
}
.snippet-text.snippet-text-table {
  overflow-x: auto;
  overflow-y: hidden;
  overflow-wrap: normal;
  white-space: pre;
  line-height: 1.45;
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 0.88rem;
  tab-size: 4;
}
.snippet-text mark {
  border-radius: 6px;
  padding: 0.04rem 0.18rem;
  background: rgba(247, 166, 32, 0.34);
  color: inherit;
}
.snippet-raw {
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 12px 14px;
  background: var(--panel-soft);
}
.snippet-raw summary { cursor: pointer; font-weight: 800; color: var(--heading); }
.snippet-raw pre {
  margin: 12px 0 0;
  overflow: auto;
  max-height: 320px;
  border-radius: 14px;
  padding: 12px;
  background: rgba(5, 12, 28, 0.92);
  color: #eff5ff;
  font-size: 0.86rem;
}
@media (max-width: 720px) {
  .snippet-modal-overlay { padding: 12px; }
  .snippet-modal-panel { width: calc(100vw - 24px); max-height: calc(100vh - 24px); }
  .snippet-modal-header { grid-template-columns: 1fr; }
  .snippet-modal-actions { justify-content: flex-start; }
  .snippet-meta-grid { grid-template-columns: 1fr; }
}

/* Responsive layout: keep desktop unchanged; rebuild tablet and phone only. */
@media (max-width: 1120px) and (min-width: 721px) {
  html, body {
    height: auto;
    min-height: 100%;
  }
  body {
    overflow-y: auto;
    overflow-x: hidden;
  }
  .app-shell {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 280px;
    grid-template-areas:
      "brand brand"
      "main insights"
      "leftrest insights";
    align-items: start;
    gap: 0;
    height: auto;
    min-height: 100vh;
    overflow: visible;
  }
  .sidebar {
    display: contents;
    padding: 0;
    border: 0;
    background: none;
    height: auto;
    min-height: 0;
    overflow: visible;
  }
  .brand-card {
    grid-area: brand;
    margin: 18px 18px 0;
    min-height: 104px;
  }
  .sidebar-scroll {
    grid-area: leftrest;
    max-height: none;
    overflow: visible;
    padding: 0 18px 18px;
    display: grid;
    gap: 14px;
  }
  .sidebar-scroll > .control-card,
  .sidebar-scroll > .chat-list {
    margin-bottom: 0;
  }
  .main-panel {
    grid-area: main;
    height: auto;
    min-height: calc(100vh - 140px);
    max-height: none;
    overflow: visible;
    display: grid;
    grid-template-rows: auto minmax(520px, calc(100vh - 246px));
  }
  .center-tab-header {
    margin: 18px 10px 0 18px;
  }
  .center-pane-body {
    padding: 1px 10px 18px 18px;
    overflow: visible;
    min-height: 0;
  }
  .chat-tab-panel {
    min-height: 0;
  }
  .message-list {
    min-height: 320px;
  }
  .insights-panel {
    grid-area: insights;
    height: auto;
    min-height: calc(100vh - 140px);
    padding: 18px 18px 18px 0;
    position: sticky;
    top: 0;
  }
  .insights-scroll {
    max-height: calc(100vh - 36px);
    overflow-y: auto;
    overflow-x: hidden;
  }
  .composer-shell {
    margin: 0 0 0 0;
  }
  .composer-row {
    grid-template-columns: 116px minmax(0, 1fr) 112px;
    gap: 10px;
  }
  .upload-zone {
    font-size: 0.9rem;
  }
}

@media (max-width: 720px) {
  html, body {
    height: auto;
    min-height: 100%;
  }
  body {
    overflow-y: auto;
    overflow-x: hidden;
  }
  body::before {
    height: 150px;
  }
  .app-shell {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      "brand"
      "main"
      "insights"
      "leftrest";
    height: auto;
    min-height: 100vh;
    overflow: visible;
  }
  .sidebar {
    display: contents;
    padding: 0;
    border: 0;
    background: none;
    height: auto;
    min-height: 0;
    overflow: visible;
  }
  .brand-card {
    grid-area: brand;
    margin: 10px 10px 0;
    min-height: 76px;
    padding: 12px;
    gap: 10px;
    border-radius: 0 0 20px 20px;
  }
  .brand-card::before {
    height: 56px;
  }
  .brand-card h1 {
    font-size: 1.08rem;
  }
  .brand-card p {
    display: none;
  }
  .brand-mark {
    width: 42px;
    height: 42px;
    margin-top: 10px;
    border-radius: 14px;
    font-size: 0.92rem;
  }
  .main-panel {
    grid-area: main;
    height: auto;
    min-height: calc(100vh - 96px);
    overflow: visible;
    display: grid;
    grid-template-rows: auto minmax(440px, calc(100vh - 184px));
  }
  .center-tab-header {
    margin: 10px 10px 0;
    padding: 14px 12px 10px;
    gap: 10px;
    flex-direction: column;
    border-radius: 0 0 20px 20px;
  }
  .center-tab-buttons {
    width: 100%;
    gap: 8px;
  }
  .center-tab-button {
    min-width: 0;
    max-width: none;
    padding: 0.58rem 0.75rem;
    border-radius: 13px;
  }
  .center-tab-controls,
  .tab-controls {
    width: 100%;
    justify-content: space-between;
    gap: 10px;
  }
  .header-actions button {
    padding: 0.58rem 0.75rem;
    border-radius: 13px;
  }
  .center-pane-body {
    padding: 1px 10px 10px;
    overflow: visible;
  }
  .message-list {
    min-height: 260px;
    padding: 12px 0 16px;
  }
  .message {
    grid-template-columns: 1fr;
    gap: 8px;
    margin-bottom: 14px;
  }
  .message-body {
    padding: 14px;
    border-radius: 18px;
  }
  .composer-shell {
    margin: 0;
    padding: 8px 10px 10px;
    border-radius: 0 0 20px 20px;
    position: sticky;
    bottom: 0;
  }
  .composer-row {
    grid-template-columns: 46px minmax(0, 1fr) 92px;
    gap: 8px;
    align-items: center;
  }
  .upload-zone {
    width: 46px;
    min-width: 46px;
    padding: 0;
    gap: 0;
    border-radius: 14px;
  }
  .upload-zone span {
    display: none;
  }
  .upload-zone button {
    width: 100%;
    height: 100%;
    min-height: 44px;
    border-radius: 14px;
    background: transparent;
    color: var(--heading);
    border: 0;
    box-shadow: none;
  }
  .composer-row textarea {
    min-width: 0;
  }
  .composer-row > button {
    min-width: 0;
    padding-left: 0.65rem;
    padding-right: 0.65rem;
    border-radius: 14px;
  }
  .insights-panel {
    grid-area: insights;
    height: auto;
    min-height: 0;
    padding: 0 10px 10px;
  }
  .insights-scroll {
    max-height: none;
    overflow: visible;
  }
  .sidebar-scroll {
    grid-area: leftrest;
    max-height: none;
    overflow: visible;
    padding: 0 10px 10px;
    display: grid;
    gap: 12px;
  }
  .sidebar-scroll > .control-card,
  .sidebar-scroll > .chat-list {
    margin-bottom: 0;
  }
  .control-card,
  .insight-card {
    border-radius: 0 0 20px 20px;
  }
  .control-row {
    flex-wrap: wrap;
  }
}

/* Keep tab buttons and the delete-chat action in one compact header row on tablet and phone. */
@media (max-width: 1120px) {
  .center-tab-header {
    flex-direction: row !important;
    align-items: center !important;
    justify-content: space-between;
    flex-wrap: nowrap;
  }
  .center-tab-buttons {
    flex: 1 1 auto;
    min-width: 0;
    width: auto !important;
    flex-wrap: nowrap !important;
  }
  .center-tab-button {
    flex: 1 1 0;
    min-width: 0;
    white-space: nowrap;
  }
  .center-tab-controls,
  .tab-controls {
    flex: 0 0 auto;
    width: auto !important;
    min-width: 0;
    justify-content: flex-end;
    flex-wrap: nowrap !important;
  }
  .header-actions {
    display: flex;
    align-items: center;
    flex: 0 0 auto;
  }
  .header-actions button {
    white-space: nowrap;
  }
}

@media (max-width: 720px) {
  .center-tab-header {
    gap: 8px;
    padding-left: 10px;
    padding-right: 10px;
  }
  .center-tab-buttons {
    gap: 6px;
  }
  .center-tab-button {
    padding-left: 0.55rem;
    padding-right: 0.55rem;
  }
  .header-actions button {
    padding-left: 0.55rem;
    padding-right: 0.55rem;
  }
}

/* 2026-04-29: Keep chat tab buttons and the delete action in one row on every screen size. */
.center-tab-header {
  flex-direction: row !important;
  align-items: center !important;
  justify-content: space-between;
  flex-wrap: nowrap !important;
}
.center-tab-buttons {
  flex: 1 1 auto;
  min-width: 0;
  width: auto !important;
  flex-wrap: nowrap !important;
}
.center-tab-button {
  min-width: 0;
  white-space: nowrap;
}
.center-tab-controls,
.tab-controls,
.header-actions {
  flex: 0 0 auto;
  width: auto !important;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: nowrap !important;
}
.header-actions button {
  white-space: nowrap;
}

/* On narrower layouts the upload control becomes icon-only so the input row keeps enough width. */
@media (max-width: 980px) {
  .composer-row {
    grid-template-columns: 46px minmax(0, 1fr) 112px;
  }
  .upload-zone {
    width: 46px;
    min-width: 46px;
    padding: 0;
    gap: 0;
  }
  .upload-zone span {
    display: none;
  }
  .upload-zone button {
    width: 100%;
    height: 100%;
    min-height: 44px;
  }
}

@media (max-width: 720px) {
  .composer-row {
    grid-template-columns: 46px minmax(0, 1fr) 92px;
  }
}

/* Workspace/Admin panel fine tuning */
.workspace-card input[data-bind="workspace"],
.admin-create-workspace-row input[data-bind="admin-workspace-name"] {
  margin-bottom: 12px;
}
.workspace-actions {
  justify-content: space-between;
  width: 100%;
}
.workspace-actions button[data-action="new-chat"] {
  margin-left: auto;
}


/* 2026-04-29: requested panel cleanup and uniform panel button widths. */
.admin-card .control-row button,
.admin-workspace-actions button {
  flex: 1 1 0;
  min-width: 0;
  justify-content: center;
  text-align: center;
}
.admin-card .control-row {
  width: 100%;
}
.admin-workspace-actions {
  flex: 0 0 220px;
  display: flex;
}
.chat-list[data-bind="chat-list"] {
  display: none !important;
}

@media (max-width: 720px) {
  .admin-workspace-item {
    flex-direction: column;
  }
  .admin-workspace-actions {
    flex: 0 0 auto;
    width: 100%;
  }
}

/* 2026-04-29: compact right-aligned Admin/Themen buttons; no forced wide buttons. */
.admin-card .control-row {
  justify-content: flex-end;
}
.admin-card .control-row button,
.admin-workspace-actions button {
  width: auto;
  min-width: 90px;
  max-width: 144px;
  justify-content: center;
  text-align: center;
}
.admin-workspace-actions {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: flex-start;
  gap: 8px;
  margin-left: auto;
}
.admin-workspace-item {
  align-items: flex-start;
}
@media (max-width: 720px) {
  .admin-workspace-actions {
    width: 100%;
    align-items: flex-end;
  }
}

/* 2026-04-29: Verfügbare-Themen panel uses dedicated classes, independent of admin styling. */
.themes-workspace-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--panel-soft);
}
.themes-workspace-meta {
  display: flex;
  align-items: center;
  min-height: 36px;
  min-width: 0;
}
.themes-workspace-meta strong {
  display: block;
  overflow-wrap: anywhere;
}
.themes-workspace-actions {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  margin-left: auto;
}
.themes-workspace-actions button {
  width: auto;
  min-width: 90px;
  max-width: 144px;
  justify-content: center;
  text-align: center;
}
@media (max-width: 720px) {
  .themes-workspace-item {
    align-items: center;
  }
  .themes-workspace-actions {
    align-items: center;
  }
}

.information-panel {
  min-height: 360px;
}
.demo-info-frame {
  width: 100%;
  flex: 1 1 auto;
  min-height: 320px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel-soft);
}
@media (max-width: 980px) {
  .information-panel { min-height: 300px; }
  .demo-info-frame { min-height: 260px; }
}


/* Empty chat introduction iframe shown only before the first message. */
.message-list.has-empty-chat-frame {
  display: flex;
  flex-direction: column;
}
.empty-chat-frame-card {
  display: flex;
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--panel-soft);
  overflow: hidden;
  box-shadow: var(--shadow-soft);
}
.empty-chat-frame {
  width: 100%;
  height: 100%;
  min-height: 0;
  flex: 1 1 auto;
  border: 0;
  background: var(--panel-soft);
}
@media (max-width: 980px) {
  .empty-chat-frame-card { min-height: 0; }
}


/* Legal footer panel: desktop fixed at the bottom of the right column, reachable by scrolling on narrow layouts. */
.legal-footer-panel {
  flex: 0 0 auto;
  margin-top: 14px;
  min-height: 96px;
  padding: 20px 16px 16px;
  border-radius: 0 0 22px 22px;
  overflow: hidden;
}
.legal-footer-panel::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 10px;
  background: linear-gradient(90deg, var(--bg-grad-2), #0f51c7 72%, var(--accent) 100%);
}
.legal-footer-links {
  display: grid;
  gap: 8px;
}
.legal-footer-links a {
  display: block;
  padding: 0.62rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel-soft);
  color: var(--heading);
  font-weight: 750;
  text-decoration: none;
}
.legal-footer-links a:hover {
  border-color: rgba(17, 79, 192, 0.26);
  box-shadow: 0 8px 22px rgba(12, 42, 107, 0.08);
}
@media (min-width: 1121px) {
  .insights-panel {
    display: flex;
    flex-direction: column;
  }
  .insights-scroll {
    flex: 1 1 auto;
    min-height: 0;
  }
  .legal-footer-panel {
    margin-top: 14px;
  }
}
@media (max-width: 1120px) {
  .legal-footer-panel {
    margin-top: 14px;
  }
}
@media (max-width: 720px) {
  .legal-footer-panel {
    min-height: 0;
    margin-top: 12px;
    border-radius: 0 0 20px 20px;
  }
}


/* 2026-05-24: On phone layouts the legal footer is the final panel below all other areas. */
@media (max-width: 720px) {
  .app-shell {
    grid-template-areas:
      "brand"
      "main"
      "insights"
      "leftrest"
      "legalfooter";
  }
  .insights-panel {
    display: contents;
    padding: 0;
  }
  .insights-scroll {
    grid-area: insights;
    padding: 0 10px 10px;
  }
  .legal-footer-panel {
    grid-area: legalfooter;
    margin: 0 10px 10px;
    min-height: 0;
    border-radius: 0 0 20px 20px;
  }
}

/* 2026-05-29: Snippet-Popup view preparation (Ausschnitt/Kompakt/Original). */
.snippet-modal-actions button.snippet-view-toggle.active {
  background: var(--accent-orange, #f7a620);
  border-color: rgba(255,255,255,0.55);
  color: #fff;
  box-shadow: 0 8px 18px rgba(247,166,32,0.22);
}
.snippet-view { display: none; min-width: 0; }
.snippet-view.active { display: block; }
.snippet-view-compact {
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 16px;
  background: var(--panel-strong);
  max-height: min(58vh, 620px);
  overflow-y: auto;
  overflow-x: hidden;
}
.snippet-compact-markdown {
  min-width: 0;
}
.snippet-compact-markdown table {
  display: block;
  overflow-x: auto;
  max-width: 100%;
}

/* 2026-05-29: Kompaktansicht als rohe Markdown-Datei mit überlagerbaren Markierungen. */
.snippet-compact-block {
  margin: 0;
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 0.88rem;
  line-height: 1.45;
  color: var(--text);
}
.snippet-compact-text-block {
  white-space: normal;
  overflow-wrap: anywhere;
  font-family: inherit;
}
.snippet-compact-text-block .snippet-compact-heading {
  margin: 0.9rem 0 0.38rem;
  line-height: 1.22;
  color: var(--text);
}
.snippet-compact-text-block .snippet-compact-heading:first-child {
  margin-top: 0;
}
.snippet-compact-text-block h1.snippet-compact-heading { font-size: 1.28rem; }
.snippet-compact-text-block h2.snippet-compact-heading { font-size: 1.16rem; }
.snippet-compact-text-block h3.snippet-compact-heading { font-size: 1.06rem; }
.snippet-compact-text-block h4.snippet-compact-heading,
.snippet-compact-text-block h5.snippet-compact-heading,
.snippet-compact-text-block h6.snippet-compact-heading { font-size: 1rem; }
.snippet-compact-paragraph {
  margin: 0.36rem 0;
}
.snippet-compact-list {
  margin: 0.36rem 0 0.55rem 1.35rem;
  padding: 0;
}
.snippet-compact-list li {
  margin: 0.2rem 0;
}
.snippet-compact-spacer {
  height: 0.45rem;
}
.snippet-compact-text-block code {
  padding: 0.08rem 0.28rem;
  border-radius: 6px;
  background: rgba(23, 32, 51, 0.08);
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 0.92em;
}
.snippet-compact-table-block {
  display: block;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  white-space: pre;
  overflow-wrap: normal;
  padding-bottom: 4px;
}
.snippet-compact-match {
  display: inline;
  border-radius: 8px;
  padding: 0.06rem 0.18rem;
  color: inherit;
}
.snippet-compact-match-chunk {
  background: rgba(247, 166, 32, 0.30);
}
.snippet-compact-match-term {
  background: rgba(30, 136, 229, 0.24);
}
.snippet-compact-match-chunk .snippet-compact-match-term {
  background: rgba(30, 136, 229, 0.38);
}
.streaming-markdown { line-height: 1.68; overflow-wrap: anywhere; }
.streaming-markdown > :first-child { margin-top: 0; }
.streaming-markdown > :last-child { margin-bottom: 0; }
.streaming-pending-line { opacity: 0.96; }
