:root {
  --page-bg: #f6f8fb;
  --card-bg: #ffffff;
  --ink: #172126;
  --ink-muted: #66727a;
  --border: #dce5e8;
  --navy: #123a7a;
  --blue: #2f6feb;
  --blue-dark: #2759bd;
  --teal: #0f766e;
  --teal-dark: #0b5f59;
  --amber: #b7791f;
  --rose: #be123c;
  --ok: #15803d;
  --radius: 8px;
  --shadow: 0 18px 48px rgba(24,35,42,.12);
  --shadow-sm: 0 2px 8px rgba(24,35,42,.08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

[hidden] { display: none !important; }

body {
  background: var(--page-bg);
  color: var(--ink);
  line-height: 1.5;
  min-height: 100vh;
}
body.modal-open {
  overflow: hidden;
}

a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
.btn:hover, .btn:focus-visible { text-decoration: none; }

/* ---------- Topbar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 100;
  display: flex; align-items: center; gap: 16px;
  padding: 0 20px; height: 56px;
  background: var(--navy); color: #fff;
  backdrop-filter: blur(8px);
}
.topbar-start { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.brand { display: flex; align-items: center; gap: 10px; }
.brand-link { color: inherit; text-decoration: none; }
.brand-link:hover { text-decoration: none; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 8px;
  background: rgba(255,255,255,.15);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px; letter-spacing: .04em;
  flex-shrink: 0;
}
.brand-title { font-size: 15px; font-weight: 600; line-height: 1.2; }
.brand-subtitle { font-size: 11px; opacity: .7; line-height: 1.2; }

.status-strip {
  display: flex; align-items: center; gap: 6px;
  font-size: 12px; opacity: .85; margin-left: auto;
}
.dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--amber); flex-shrink: 0;
}
.dot.ok { background: var(--ok); }
.dot.warn { background: var(--amber); }
.dot.error { background: var(--rose); }
.status-dot-small {
  width: 6px;
  height: 6px;
}

.top-actions { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.top-actions .btn { padding-left: 12px; padding-right: 12px; }
.auth-user {
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: rgba(255,255,255,.86);
  font-size: 13px;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 16px; border: none; border-radius: var(--radius);
  font: inherit; font-size: 13px; font-weight: 500;
  cursor: pointer; white-space: nowrap; transition: background .15s, opacity .15s;
}
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary, .btn:not(.secondary):not(.ghost) {
  background: var(--teal); color: #fff;
}
.btn.primary:hover:not(:disabled) { background: var(--teal-dark); }
.btn.blue { background: var(--blue); color: #fff; }
.btn.blue:hover:not(:disabled) { background: var(--blue-dark); }
.btn.secondary {
  background: rgba(255,255,255,.12); color: #fff;
}
.btn.secondary:hover:not(:disabled) { background: rgba(255,255,255,.2); }
.btn.ghost { background: transparent; color: #fff; }
.btn.ghost:hover:not(:disabled) { background: rgba(255,255,255,.08); }
.btn.full { width: 100%; }
.no-shrink { flex-shrink: 0; }

.shared-action-icon {
  width: 15px;
  height: 15px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
}
.shared-action-icon svg {
  width: 15px;
  height: 15px;
  display: block;
}
.action-icon-btn {
  width: 34px;
  min-width: 34px;
  height: 34px;
  min-height: 34px;
  padding: 0 !important;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  border: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
  color: var(--blue) !important;
  text-decoration: none !important;
}
.action-icon-btn:hover,
.action-icon-btn:focus,
.action-icon-btn:focus-visible {
  text-decoration: none !important;
}
.action-icon-btn svg {
  width: 16px;
  height: 16px;
  display: block;
}
.action-icon-btn.is-danger-action {
  color: var(--rose) !important;
}
.action-icon-btn.is-selected-action {
  color: var(--ok) !important;
}
.btn > svg,
.disc-btn > svg,
.session-action-btn svg {
  width: 15px;
  height: 15px;
  display: block;
  flex: 0 0 auto;
}

.icon-btn { padding: 7px; width: 34px; height: 34px; justify-content: center; }
.icon-btn svg { width: 18px; height: 18px; }

/* ---------- Notice ---------- */
.notice {
  display: none;
  position: fixed; right: 18px; top: 88px; bottom: auto;
  z-index: 9999; width: fit-content; max-width: min(520px, calc(100vw - 36px));
  min-width: 460px;
  padding: 16px 48px 16px 30px; border: 1px solid var(--border); border-radius: var(--radius);
  background: #fff; box-shadow: var(--shadow); color: #263238;
  font-size: 13px; line-height: 1.5; white-space: normal;
}
.notice-text {
  display: block;
  min-width: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.notice-close {
  position: absolute;
  top: 10px;
  right: 12px;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  border-radius: 4px;
  color: var(--ink-muted);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
}
.notice-close:hover {
  background: rgba(0,0,0,.06);
  color: var(--ink);
}
.notice.active,
.notice.show {
  display: block;
  animation: rise 180ms ease both;
}
.notice.error {
  border-color: rgba(190, 18, 60, 0.28);
  color: #75142a;
}
.notice.success {
  border-color: rgba(21, 128, 61, 0.28);
  color: #14532d;
}
@keyframes rise {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---------- Config modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 10000;
  display: flex; align-items: flex-start; justify-content: center;
  padding: 20px; background: rgba(7,18,28,.48); backdrop-filter: blur(8px);
  pointer-events: auto;
  overflow-y: auto;
}
.modal-backdrop[hidden] { display: none; }
.config-modal {
  width: min(1320px, calc(100vw - 40px));
  height: min(920px, calc(100vh - 40px));
  display: flex; flex-direction: column; overflow: hidden;
  background: var(--card-bg); border-radius: 16px; box-shadow: var(--shadow);
  border: 1px solid rgba(220,229,232,.9);
  pointer-events: auto;
}
.config-modal-header {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 20px 28px; background: var(--navy);
  color: #fff;
  flex-shrink: 0;
}
.config-modal-kicker {
  margin-bottom: 4px; font-size: 11px; font-weight: 700; letter-spacing: .12em;
  text-transform: uppercase; opacity: .72;
}
.config-modal-header h2 { font-size: 24px; font-weight: 700; }
.config-close-btn { color: #fff; }
.config-modal-note {
  padding: 0 28px; border-bottom: 0 solid transparent;
  color: var(--ink-muted); font-size: 12px; background: #f9fbfc;
  min-height: 0;
  flex-shrink: 0;
}
.config-modal-note:not(:empty) { padding: 12px 28px; border-bottom-width: 1px; }
.config-modal-note.ok { color: var(--teal); }
.config-modal-note.saving { color: var(--blue); }
.config-modal-note.error { color: var(--rose); }
.config-form {
  flex: 1;
  min-height: 0;
  overflow-y: auto; overflow-x: hidden; padding: 22px 28px 28px;
  display: flex; flex-direction: column; gap: 16px;
  overscroll-behavior: contain;
  pointer-events: auto;
}
.config-loading { color: var(--ink-muted); font-size: 13px; padding: 16px; }
.config-group {
  border: 1px solid var(--border); border-radius: 12px;
  background: #fff; overflow: hidden;
  min-width: 0;
  flex: 0 0 auto;
}
.config-group summary {
  cursor: pointer; padding: 16px 18px; font-size: 16px; font-weight: 800;
  background: rgba(18,58,122,.05);
  user-select: none;
}
.config-group-body {
  padding: 16px; display: grid; grid-template-columns: repeat(auto-fit, minmax(min(360px, 100%), 1fr));
  gap: 14px;
  min-height: 0;
}
.config-group-body .config-group { grid-column: 1 / -1; }
.config-field {
  display: flex; flex-direction: column; gap: 6px;
  padding: 14px; border: 1px solid rgba(220,229,232,.72); border-radius: 10px;
  background: var(--page-bg);
  min-width: 0;
}
.config-field-title {
  font-size: 13px; font-weight: 700; color: var(--ink-muted);
  letter-spacing: .02em;
}
.config-field input {
  width: 100%; border: 1px solid var(--border); border-radius: 8px;
  padding: 10px 11px; font: inherit; font-size: 14px; background: #fff;
}
.config-field input:focus { outline: none; border-color: var(--blue); }
.config-field input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--teal); }
@media (max-width: 760px) {
  .modal-backdrop { padding: 12px; align-items: flex-start; }
  .config-modal {
    width: 100%;
    height: calc(100vh - 24px);
    max-height: none;
  }
  .config-group-body { grid-template-columns: 1fr; }
  .notice {
    left: 12px;
    right: 12px;
    top: 88px;
    width: auto;
  }
}

/* ============================================================
    门户页
    ============================================================ */
.product-portal {
  --grid-mx: 50%;
  --grid-my: 50%;
  --portal-left-column: clamp(380px, 38vw, 460px);
  --portal-gap: 16px;
  display: flex; flex-direction: column; align-items: center;
  justify-content: flex-start; min-height: calc(100vh - 56px);
  padding: 58px 24px 18px; position: relative; overflow: hidden;
}

.portal-sections {
  position: relative; z-index: 1;
  display: flex; flex-direction: column;
  gap: var(--portal-gap); width: min(1180px, 100%);
}

.portal-section {
  display: flex; align-items: stretch; gap: 0;
  border: 2px solid rgba(47,111,235,.22);
  border-radius: 16px;
  background: rgba(255,255,255,.45);
  padding: 14px 18px 14px 0;
  transition: border-color .2s, box-shadow .2s;
}
.portal-section:hover {
  border-color: rgba(47,111,235,.32);
  box-shadow: 0 8px 28px rgba(47,111,235,.08);
}

.portal-section-row {
  --portal-row-card: minmax(0, 1fr);
  display: grid;
  grid-template-columns: minmax(340px, 0.35fr) minmax(0, 0.65fr);
  gap: var(--portal-gap);
}

.section-label {
  display: flex; align-items: center; justify-content: center;
  writing-mode: vertical-rl;
  text-orientation: upright;
  font-size: 20px; font-weight: 700;
  color: var(--navy);
  letter-spacing: .2em;
  padding: 0 14px;
  border-right: 1px solid rgba(47,111,235,.14);
  flex-shrink: 0;
  user-select: none;
}

.section-cards {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--portal-gap);
  padding-left: 18px;
  align-items: stretch;
}

.portal-section[data-section="wuzhen"] .section-cards {
  grid-template-columns: minmax(0, var(--portal-left-column)) repeat(3, minmax(0, 1fr));
}
.portal-section[data-section="wuzhen"] .product-card:first-child {
  grid-row: auto;
}
.portal-section[data-section="wuzhen"] .product-card:not(:first-child) {
  padding: 20px 16px 14px;
}

.portal-section[data-section="wuli"] .section-cards {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.portal-section[data-section="wuzhen"] .product-card:nth-child(2) {
  margin-left: 8px;
}

.portal-section-row .section-cards {
  grid-template-columns: repeat(2, var(--portal-row-card));
}

.portal-section-row .portal-section[data-section="wuli"] .section-cards {
  grid-template-columns: repeat(4, var(--portal-row-card));
}

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

@media (max-width: 900px) {
  .section-cards { grid-template-columns: repeat(2, 1fr); }
  .portal-section[data-section="wuzhen"] .section-cards { grid-template-columns: repeat(2, 1fr); }
  .portal-section-row .section-cards { grid-template-columns: repeat(2, var(--portal-row-card)); }
}
@media (max-width: 720px) {
  .portal-section { flex-direction: column; padding: 16px; }
  .section-label {
    writing-mode: horizontal-tb;
    text-orientation: mixed;
    border-right: none;
    border-bottom: 1px solid rgba(47,111,235,.14);
    padding: 0 0 10px;
    margin-bottom: 12px;
    letter-spacing: .08em;
  }
  .section-cards { padding-left: 0; grid-template-columns: 1fr; }
  .portal-section-row { grid-template-columns: 1fr; }
  .portal-section-row .section-cards { grid-template-columns: 1fr; }
  .portal-section-row .portal-section[data-section="wuli"] .section-cards { grid-template-columns: 1fr; }
}

/* 背景网格纹理 */
.product-portal::before {
  content: ""; position: absolute; inset: 0; z-index: 0;
  background-image:
    radial-gradient(circle at var(--grid-mx) var(--grid-my), rgba(47,111,235,.14) 0%, transparent 42%),
    radial-gradient(circle at calc(100% - var(--grid-mx)) calc(100% - var(--grid-my)), rgba(15,118,110,.12) 0%, transparent 42%),
    linear-gradient(rgba(220,229,232,.35) 1px, transparent 1px),
    linear-gradient(90deg, rgba(220,229,232,.35) 1px, transparent 1px);
  background-size: 100% 100%, 100% 100%, 40px 40px, 40px 40px;
  pointer-events: none;
}

.product-portal::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  background: radial-gradient(280px circle at var(--grid-mx) var(--grid-my), rgba(255,255,255,.36) 0%, rgba(255,255,255,0) 72%);
  pointer-events: none;
}

.portal-hero {
  position: relative; z-index: 1; text-align: center; margin-bottom: 42px;
}
.portal-hero .eyebrow {
  font-size: 12px; font-weight: 600; letter-spacing: .08em;
  text-transform: uppercase; color: var(--teal); margin-bottom: 10px;
}
.portal-hero h1 {
  font-size: clamp(28px, 3.6vw, 40px); font-weight: 700;
  line-height: 1.15; color: var(--ink); margin-bottom: 10px;
  white-space: pre;
}
.portal-hero p {
  font-size: 15px; color: var(--ink-muted); max-width: 560px; margin: 0 auto;
}
.portal-notice {
  margin-top: 14px !important;
  font-size: 13px !important;
  color: #92400e !important;
  background: #fef3c7;
  border: 1px solid rgba(183,121,31,.32);
  border-radius: var(--radius);
  padding: 10px 16px;
  max-width: 840px;
}

.auth-panel {
  position: absolute;
  top: 24px;
  right: 24px;
  z-index: 2;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  width: min(280px, calc(100vw - 48px));
  margin: 0;
  padding: 12px;
  background: rgba(255,255,255,.85);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-sm);
}
.auth-panel input:first-of-type,
.auth-panel input:nth-of-type(2) {
  grid-column: 1 / -1;
}
.auth-panel input {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(255,255,255,.92);
  padding: 8px 11px;
  font: inherit;
  font-size: 13px;
  color: var(--ink);
}
.auth-panel input:focus {
  outline: none;
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(15,118,110,.12);
}
.auth-panel .btn {
  justify-content: center;
}
.auth-panel .btn.primary {
  background: var(--navy);
}
.auth-panel .btn.primary:hover:not(:disabled) {
  background: var(--blue-dark);
}
.auth-panel .btn.secondary {
  border: 1px solid var(--border);
  background: #fff;
  color: var(--ink);
}
.auth-panel .btn.secondary:hover:not(:disabled) {
  background: rgba(47,111,235,.06);
}
.auth-panel.is-hidden {
  display: none;
}
.auth-panel.is-authed {
  display: none;
}
@media (max-width: 900px) {
  .auth-panel {
    position: static;
    width: min(760px, 100%);
    margin: 0 0 24px;
    background: transparent;
    backdrop-filter: none;
    border: none;
    box-shadow: none;
    padding: 0;
    grid-template-columns: minmax(160px, 1fr) minmax(160px, 1fr) auto auto;
  }
}
@media (max-width: 720px) {
  .auth-panel { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 540px) {
  .auth-panel { grid-template-columns: 1fr; }
}

/* Product cards */
.product-card {
  background: var(--card-bg); border-radius: var(--radius);
  box-shadow: var(--shadow-sm); padding: 20px 20px 44px;
  display: flex; flex-direction: column; gap: 8px;
  border: 1px solid var(--border); transition: box-shadow .2s, transform .2s, border-color .2s;
  cursor: pointer; text-decoration: none; color: inherit;
  position: relative; overflow: hidden;
}
.product-card:hover {
  box-shadow: var(--shadow); transform: translateY(-2px);
  text-decoration: none;
  border-color: rgba(47,111,235,.35);
}
.product-card[data-static]:hover {
  transform: none;
  box-shadow: var(--shadow-sm);
  border-color: var(--border);
}
.discovery-flow {
  --flow-node-width: 76px;
  --flow-arrow-width: 10px;
  --flow-gap: 5px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 12px;
  align-items: flex-start;
  position: relative;
  transform: translateY(22px);
}
.flow-row {
  display: flex;
  align-items: center;
  gap: var(--flow-gap);
  position: relative;
  z-index: 1;
}
.flow-row-reverse {
  margin-left: calc(var(--flow-node-width) + var(--flow-arrow-width) + var(--flow-gap) * 2);
}
.flow-node {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  width: var(--flow-node-width);
  background: #f2f4f7;
  color: #4a5568;
  font-size: 12px;
  padding: 6px 8px;
  border-radius: 6px;
  border: 1px solid transparent;
  transition: all .2s;
  white-space: nowrap;
  cursor: default;
}
.flow-node:hover {
  background: #fff;
  color: var(--ink);
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
  border-color: rgba(47,111,235,.35);
}
.flow-arrow {
  display: inline-block;
  width: var(--flow-arrow-width);
  height: 0;
  border-top: 1px dashed #bbb;
  position: relative;
  flex-shrink: 0;
}
.flow-arrow::after {
  content: '';
  position: absolute;
  right: -1px;
  top: -3px;
  width: 0;
  height: 0;
  border-left: 4px solid #bbb;
  border-top: 3px solid transparent;
  border-bottom: 3px solid transparent;
}
.flow-arrow-left::after {
  left: -1px;
  right: auto;
  border-left: none;
  border-right: 4px solid #bbb;
}
.flow-return {
  position: absolute;
  left: 44px;
  top: 28px;
  z-index: 0;
  pointer-events: none;
}
.flow-drop {
  position: absolute;
  left: calc(var(--flow-node-width) * 3 + var(--flow-arrow-width) * 3 + var(--flow-gap) * 6 + var(--flow-node-width) / 2 - 6px);
  top: 28px;
  z-index: 0;
  pointer-events: none;
}
.product-card.disabled,

.product-card h3 { font-size: 17px; font-weight: 600; }
.product-card p { font-size: 13px; color: var(--ink-muted); line-height: 1.6; flex: 1; }

.card-watermark {
  position: absolute; right: -12px; bottom: -18px;
  font-size: 72px; line-height: 1;
  opacity: .06;
  color: var(--navy);
  pointer-events: none;
  user-select: none;
  z-index: 0;
}

/* ============================================================
    MoE 专家路由页
    ============================================================ */
.moe-shell {
  --grid-mx: 50%;
  --grid-my: 50%;
  --moe-sidebar-width: 360px;
  --moe-sidebar-effective-width: min(var(--moe-sidebar-width), calc(100vw - 24px));
  display: flex; flex-direction: column; min-height: 100vh;
  position: relative; overflow: visible;
}
.moe-shell::before {
  content: ""; position: absolute; inset: 56px 0 0; z-index: 0;
  background-image:
    radial-gradient(circle at var(--grid-mx) var(--grid-my), rgba(47,111,235,.14) 0%, transparent 42%),
    radial-gradient(circle at calc(100% - var(--grid-mx)) calc(100% - var(--grid-my)), rgba(15,118,110,.12) 0%, transparent 42%),
    linear-gradient(rgba(220,229,232,.35) 1px, transparent 1px),
    linear-gradient(90deg, rgba(220,229,232,.35) 1px, transparent 1px);
  background-size: 100% 100%, 100% 100%, 40px 40px, 40px 40px;
  pointer-events: none;
}
.moe-shell::after {
  content: ""; position: absolute; inset: 56px 0 0; z-index: 0;
  background: radial-gradient(280px circle at var(--grid-mx) var(--grid-my), rgba(255,255,255,.36) 0%, rgba(255,255,255,0) 72%);
  pointer-events: none;
}
.moe-shell .topbar { flex-shrink: 0; }
.moe-layout {
  display: grid;
  flex: 1;
  overflow: visible;
  grid-template-columns: 1fr;
  position: relative;
  z-index: 1;
}

/* --- Sidebar --- */
.moe-sidebar {
  position: fixed;
  left: calc(var(--moe-sidebar-effective-width) * -1);
  top: 56px;
  bottom: 0;
  width: var(--moe-sidebar-effective-width);
  z-index: 95;
  transition: left .25s ease;
  background: var(--card-bg);
  border-right: none;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  box-shadow: 12px 0 28px rgba(24,35,42,.12), inset -1px 0 0 var(--border);
  padding-bottom: 12px;
}
.moe-sidebar.open { left: 0; }
.moe-sidebar .btn.secondary {
  background: var(--page-bg);
  color: var(--ink);
  border: 1px solid var(--border);
}
.sidebar-resize-handle {
  position: fixed;
  top: 56px;
  bottom: 0;
  left: var(--moe-sidebar-effective-width);
  width: 12px;
  transform: translateX(-6px);
  z-index: 97;
  cursor: ew-resize;
}
.moe-sidebar:not(.open) .sidebar-resize-handle {
  display: none;
}
.sidebar-resize-handle::after {
  content: "";
  position: absolute;
  top: 12px;
  bottom: 12px;
  left: 5px;
  width: 2px;
  border-radius: 999px;
  background: transparent;
  transition: background .15s;
}
.sidebar-resize-handle:hover::after,
.sidebar-resize-handle:focus-visible::after,
.is-resizing-sidebar .sidebar-resize-handle::after {
  background: rgba(15,118,110,.42);
}
.sidebar-resize-handle:focus-visible {
  outline: none;
}
.is-resizing-sidebar {
  cursor: ew-resize;
  user-select: none;
}
.moe-sidebar-header {
  padding: 16px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.moe-sidebar-header h2 { font-size: 15px; font-weight: 600; }
.sidebar-header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}
.session-list { flex: 1; overflow-y: auto; padding: 8px; }
.session-item {
  padding: 10px 12px; border-radius: var(--radius);
  cursor: pointer; transition: background .15s;
  border: 1px solid transparent; margin-bottom: 4px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: start;
}
.session-item:hover { background: var(--page-bg); }
.session-item.active { background: rgba(47,111,235,.06); border-color: rgba(47,111,235,.2); }
.session-item-main { min-width: 0; }
.session-item-name { font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.session-item-meta { font-size: 11px; color: var(--ink-muted); margin-top: 2px; }
.session-item-actions {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 6px;
}
.session-action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  color: var(--ink-muted);
  cursor: pointer;
  font: inherit;
  font-size: 11px;
  font-weight: 600;
  line-height: 1;
  padding: 5px 7px;
}
.session-action-btn:hover {
  border-color: rgba(15,118,110,.32);
  color: var(--teal);
}
.session-action-btn.danger:hover {
  border-color: rgba(190,18,60,.28);
  color: var(--rose);
}
.session-action-btn.action-icon-btn {
  border: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
  color: var(--blue) !important;
}
.session-action-btn.action-icon-btn.is-danger-action {
  color: var(--rose) !important;
}
.session-empty {
  color: var(--ink-muted);
  font-size: 13px;
  cursor: default;
  border: none;
  display: block;
}
.session-empty:hover { background: transparent; }

.archived-sessions-modal {
  width: min(620px, calc(100vw - 48px));
  height: min(560px, calc(100vh - 48px));
}
.archived-session-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  list-style: none;
}
.archived-session-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
}
.archived-session-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.archived-session-main strong {
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.archived-session-main span,
.archived-session-main small {
  font-size: 11px;
  color: var(--ink-muted);
  overflow-wrap: anywhere;
}

/* --- Main Content --- */
.moe-main {
  overflow: visible;
  padding: 24px;
  display: flex; flex-direction: column; gap: 20px;
  width: min(1520px, calc(100vw - 32px));
  margin: 0 auto;
}

.moe-hero {
  background: var(--card-bg); border-radius: var(--radius);
  box-shadow: var(--shadow-sm); padding: 28px; border: 1px solid var(--border);
}
.moe-hero .eyebrow {
  font-size: 12px; font-weight: 600; letter-spacing: .08em;
  text-transform: uppercase; color: var(--teal); margin-bottom: 8px;
}
.moe-hero h2 {
  font-size: 22px; font-weight: 600; margin-bottom: 6px;
}
.moe-hero p { font-size: 14px; color: var(--ink-muted); margin-bottom: 20px; }

.moe-info-card {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 14px 16px; margin-bottom: 18px;
  border: 1px solid rgba(15,118,110,.18);
  border-radius: var(--radius);
  background: linear-gradient(135deg, rgba(15,118,110,.08), rgba(47,111,235,.05));
}
.moe-info-icon {
  width: 34px; height: 34px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; background: #fff; color: var(--teal);
  font-size: 11px; font-weight: 700; letter-spacing: .06em;
  box-shadow: var(--shadow-sm);
}
.moe-info-card h3 {
  font-size: 14px; font-weight: 600; margin-bottom: 4px;
}
.moe-info-card p {
  margin: 0; font-size: 13px; line-height: 1.6;
}

.moe-composer { display: flex; flex-direction: column; gap: 12px; }
.moe-input-wrap { position: relative; }
.moe-composer textarea {
  width: 100%; min-height: 188px; padding: 16px;
  border: 1px solid var(--border); border-radius: var(--radius);
  font: inherit; font-size: 14px; resize: vertical;
  background: var(--page-bg); transition: border-color .15s;
}
.moe-composer textarea:focus { outline: none; border-color: var(--blue); }
.moe-composer-footer {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}
.moe-composer-tools {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.mini-tool-btn,
.answer-copy-btn,
.code-copy-btn {
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  color: var(--ink-muted);
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  line-height: 1;
  padding: 6px 9px;
  cursor: pointer;
  box-shadow: 0 1px 4px rgba(24,35,42,.05);
}
.mini-tool-btn:hover,
.answer-copy-btn:hover,
.code-copy-btn:hover {
  border-color: rgba(15,118,110,.35);
  color: var(--teal);
  background: rgba(15,118,110,.04);
}
.send-icon-btn {
  width: 44px; height: 44px; border: none; border-radius: 12px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--navy); color: #fff; cursor: pointer;
  box-shadow: 0 10px 24px rgba(18,58,122,.24);
  transition: transform .15s, background .15s, opacity .15s;
}
.send-icon-btn:hover:not(:disabled) { background: var(--blue-dark); transform: scale(1.04); }
.send-icon-btn:disabled { opacity: .58; cursor: not-allowed; }
.send-icon-btn svg { width: 22px; height: 22px; }
.send-icon-btn .stop-icon { display: none; }
.send-icon-btn .send-spinner { display: none; animation: spin 1s linear infinite; }
.send-icon-btn.is-loading .send-icon { display: none; }
.send-icon-btn.is-loading .send-spinner { display: block; }
.send-icon-btn.is-stop .send-icon { display: none; }
.send-icon-btn.is-stop .stop-icon { display: block; }
.send-icon-btn.is-stop.is-loading .stop-icon { display: none; }
.composer-send-btn {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
}
.moe-composer-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.moe-input-box {
  position: relative;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--page-bg);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.moe-input-box textarea {
  width: 100%;
  min-height: 188px;
  border: none;
  background: transparent;
  font: inherit;
  font-size: 14px;
  resize: vertical;
  outline: none;
  line-height: 1.6;
  padding: 0;
}
.moe-input-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.typewriter-overlay {
  position: absolute;
  top: 16px;
  left: 16px;
  right: 16px;
  pointer-events: none;
  z-index: 2;
  font-size: 14px;
  line-height: 1.6;
  color: var(--ink-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.typewriter-prefix {
  color: var(--ink-muted);
}
.typewriter-cursor {
  display: inline-block;
  width: 2px;
  height: 1.1em;
  background: var(--ink-muted);
  margin-left: 2px;
  vertical-align: text-bottom;
  animation: typewriter-blink 1s step-end infinite;
}
@keyframes typewriter-blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}
.typewriter-overlay.hidden {
  display: none !important;
}
.moe-main.is-landing .typewriter-overlay {
  top: 18px;
  left: 20px;
  right: 20px;
  font-size: 16px;
}

/* --- MoE Landing State --- */
.moe-main.is-landing {
  justify-content: flex-start;
  min-height: calc(100vh - 56px);
  padding-top: 18vh;
  padding-bottom: 0;
}
.moe-main.is-landing .moe-hero {
  width: 100%;
  background: transparent;
  border: none;
  box-shadow: none;
  padding: 20px;
}
.moe-main.is-landing .moe-info-card {
  display: none;
}
.moe-landing-greeting {
  display: none;
}
.moe-main.is-landing .moe-landing-greeting {
  display: block;
  text-align: center;
  font-size: 28px;
  font-weight: 600;
  color: var(--ink);
  margin: 0 0 38px;
}
.moe-main.is-landing .moe-composer {
  width: 100%;
  margin: 0 auto;
}
.moe-main.is-landing .moe-input-box {
  border-radius: 24px;
  background: #fff;
  box-shadow: 0 1px 6px rgba(24,35,42,.06);
  padding: 18px 20px 14px;
  gap: 8px;
}
.moe-main.is-landing .moe-input-box textarea {
  min-height: 56px;
  font-size: 16px;
  resize: none;
}
.moe-main.is-landing .moe-composer-tools {
  display: none;
}
.moe-main.is-landing .moe-input-actions {
  justify-content: flex-end;
}
.moe-main.is-landing .composer-send-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
}
.moe-main.is-landing .composer-send-btn svg {
  width: 20px;
  height: 20px;
}

/* --- Expert Grid --- */
.expert-column-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(360px, 100%), 1fr));
  gap: 16px;
  align-items: stretch;
}
@media (max-width: 700px) {
  .expert-column-grid { grid-template-columns: 1fr; }
}

.expert-card {
  background: var(--card-bg); border-radius: var(--radius);
  box-shadow: var(--shadow-sm); border: 1px solid var(--border);
  padding: 20px; display: flex; flex-direction: column; gap: 12px;
  transition: box-shadow .2s;
  height: 100%;
  min-width: 0;
}
.expert-card.thinking { border-color: rgba(47,111,235,.3); box-shadow: 0 0 0 1px rgba(47,111,235,.1); }

.expert-card-header {
  display: flex; align-items: center; gap: 10px;
}
.expert-card-avatar {
  width: 36px; height: 36px; border-radius: 8px;
  background: rgba(15,118,110,.08); display: flex;
  align-items: center; justify-content: center; flex-shrink: 0;
}
.expert-card-info { flex: 1; min-width: 0; }
.expert-card-name { font-size: 14px; font-weight: 600; }
.expert-card-model { font-size: 11px; color: var(--ink-muted); }

.expert-card-score {
  font-size: 11px; font-weight: 600; padding: 2px 8px;
  border-radius: 10px; background: rgba(15,118,110,.1); color: var(--teal);
  margin-left: auto;
}

.expert-card-status {
  font-size: 12px; font-weight: 500; display: flex; align-items: center; gap: 6px;
}
.expert-card-status.waiting { color: var(--ink-muted); }
.expert-card-status.thinking { color: var(--blue); }
.expert-card-status.done { color: var(--teal); }

.expert-card-body {
  flex: 1; font-size: 14px; line-height: 1.65;
  overflow: auto; min-height: 260px; min-width: 0;
  padding: 4px 6px;
  resize: vertical;
}
.expert-card-body .md-content,
.conversation-card .md-content {
  overflow-wrap: anywhere;
  word-break: break-word;
}
.expert-card-body .md-content {
  padding: 2px 8px;
}
.expert-card-body .md-content p { margin-bottom: 8px; }
.expert-card-body .md-content ul,
.expert-card-body .md-content ol,
.conversation-card .md-content ul,
.conversation-card .md-content ol {
  margin: 8px 0 10px;
  padding-left: 1.45rem;
  list-style-position: outside;
}
.expert-card-body .md-content li,
.conversation-card .md-content li {
  margin: 4px 0;
  padding-left: 2px;
}
.expert-card-body .md-content code {
  background: #fff; border: 1px solid var(--border); padding: 1px 5px; border-radius: 4px; font-size: 13px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.expert-card-body .md-content pre {
  position: relative;
  background: #fff; color: var(--ink); border: 1px solid var(--border); padding: 12px;
  border-radius: var(--radius); overflow-x: hidden; margin: 8px 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.expert-card-body .md-content pre code { background: none; color: inherit; padding: 0; white-space: pre-wrap; }

/* --- Bot Animation --- */
.agent-bot {
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
}
.bot-figure { position: relative; width: 52px; height: 58px; }
.bot-head {
  width: 34px; height: 24px; background: linear-gradient(135deg, var(--blue), var(--teal));
  border-radius: 10px 10px 6px 6px; position: absolute;
  top: 3px; left: 50%; transform: translateX(-50%);
  box-shadow: 0 12px 26px rgba(47,111,235,.22);
}
.bot-eye {
  width: 5px; height: 5px; border-radius: 50%;
  background: #fff; position: absolute; top: 9px;
  animation: bot-eye-scan 1.5s ease-in-out infinite;
}
.bot-eye.left { left: 8px; }
.bot-eye.right { right: 8px; animation-delay: .15s; }
.bot-body {
  width: 40px; height: 24px; background: rgba(47,111,235,.16);
  border: 1px solid rgba(47,111,235,.15);
  border-radius: 8px; position: absolute;
  bottom: 0; left: 50%; transform: translateX(-50%);
}
.bot-antenna {
  width: 2px; height: 8px; background: var(--blue);
  position: absolute; top: -4px; left: 50%; transform: translateX(-50%);
  border-radius: 2px;
}
.bot-antenna::after {
  content: ""; width: 5px; height: 5px; border-radius: 50%;
  background: var(--blue); position: absolute; top: -3px; left: -1.5px;
}

@keyframes bot-bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}
.bot-figure.animating { animation: bot-bob 1.2s ease-in-out infinite; }
.bot-figure.animating .bot-antenna::after {
  animation: bot-blink 1.2s ease-in-out infinite;
}
.bot-figure.animating::before,
.bot-figure.animating::after {
  content: ""; position: absolute; inset: 6px;
  border: 1px solid rgba(47,111,235,.18); border-radius: 18px;
  animation: bot-signal 1.8s ease-out infinite;
}
.bot-figure.animating::after { animation-delay: .45s; }
@keyframes bot-blink {
  0%, 100% { opacity: 1; }
  50% { opacity: .3; }
}
@keyframes bot-signal {
  0% { transform: scale(.82); opacity: .5; }
  100% { transform: scale(1.45); opacity: 0; }
}

@keyframes spin { to { transform: rotate(360deg); } }
.spin-icon { animation: spin 1s linear infinite; }

.vote-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 7px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
}
.vote-badge svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}
.vote-badge.agree {
  color: var(--teal);
  background: rgba(15,118,110,.1);
}
.vote-badge.disagree {
  color: var(--amber);
  background: rgba(183,121,31,.12);
}
.answer-copy-btn {
  flex-shrink: 0;
  margin-left: 0;
}
.code-copy-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  padding: 5px 8px;
  opacity: .92;
}

.moe-resource-header {
  padding: 16px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.moe-resource-header h2 { font-size: 14px; font-weight: 600; }

.resource-tabs {
  display: flex; border-bottom: 1px solid var(--border);
  overflow-x: auto;
}
.resource-tab {
  padding: 8px 14px; font-size: 12px; font-weight: 500;
  cursor: pointer; white-space: nowrap; border: none;
  background: none; color: var(--ink-muted); border-bottom: 2px solid transparent;
  transition: color .15s, border-color .15s;
}
.resource-tab:hover { color: var(--ink); }
.resource-tab.active { color: var(--blue); border-bottom-color: var(--blue); }

.resource-panel-content { flex: 1; overflow-y: auto; padding: 12px; }
.resource-pane[hidden] { display: none; }
.file-list { list-style: none; }
.file-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 8px; border-radius: 4px; font-size: 12px;
  cursor: pointer; transition: background .1s;
}
.file-item:hover { background: var(--page-bg); }
.file-item-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-item-size { color: var(--ink-muted); flex-shrink: 0; margin-left: 8px; }

.log-box {
  font-family: "SF Mono", Menlo, Consolas, monospace;
  font-size: 11px; line-height: 1.5; white-space: pre-wrap;
  color: var(--ink-muted); max-height: 100%; overflow-y: auto;
}

.json-preview {
  font-family: "SF Mono", Menlo, Consolas, monospace;
  font-size: 11px; white-space: pre-wrap; word-break: break-all;
  background: var(--page-bg); padding: 12px; border-radius: var(--radius);
  max-height: 300px; overflow-y: auto;
}

/* --- Routing Info --- */
.routing-panel {
  background: var(--card-bg); border-radius: var(--radius);
  box-shadow: var(--shadow-sm); border: 1px solid var(--border);
  padding: 16px; display: flex; flex-direction: column; gap: 8px;
}
.routing-panel.hidden { display: none; }
.routing-panel h4 { font-size: 13px; font-weight: 600; }
.routing-bars { display: flex; flex-direction: column; gap: 10px; }
.routing-bar-row {
  display: flex; align-items: center; gap: 8px; font-size: 12px;
}
.routing-bar-label { width: 80px; flex-shrink: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.routing-bar-track { flex: 1; height: 8px; background: var(--page-bg); border-radius: 4px; overflow: hidden; }
.routing-bar-fill { height: 100%; border-radius: 4px; background: var(--blue); transition: width .4s ease; }
.routing-bar-score { width: 40px; text-align: right; color: var(--ink-muted); font-size: 11px; }
.routing-match-card {
  display: flex; align-items: center; gap: 12px;
  padding: 12px; border: 1px solid rgba(47,111,235,.14);
  border-radius: 12px; background: linear-gradient(135deg, #fff, rgba(47,111,235,.035));
}
.routing-agent-badge,
.agent-bot-icon {
  width: 40px; height: 40px; flex-shrink: 0; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  background: rgba(15,118,110,.09); color: var(--teal);
}
.agent-bot-icon.compact {
  width: 100%;
  height: 100%;
  border-radius: inherit;
  background: transparent;
}
.agent-bot-icon.compact .mini-bot,
.conversation-card .mini-bot {
  transform: scale(.9);
}
.agent-bot-icon.routing {
  width: 40px;
  height: 40px;
}
.mini-bot {
  width: 23px; height: 18px; border-radius: 8px 8px 5px 5px;
  background: currentColor; position: relative; box-shadow: 0 6px 16px rgba(15,118,110,.18);
  animation: mini-bot-pulse 1.8s ease-in-out infinite;
}
.mini-bot::before {
  content: ""; position: absolute; left: 50%; top: -7px;
  width: 2px; height: 7px; background: currentColor; transform: translateX(-50%);
}
.mini-bot::after {
  content: ""; position: absolute; left: 50%; top: -10px;
  width: 5px; height: 5px; border-radius: 50%; background: currentColor; transform: translateX(-50%);
}
.mini-bot span {
  position: absolute; top: 7px; width: 4px; height: 4px; border-radius: 50%; background: #fff;
  animation: bot-eye-scan 1.8s ease-in-out infinite;
}
.mini-bot span:first-child { left: 6px; }
.mini-bot span:last-child { right: 6px; animation-delay: .12s; }
.routing-match-main { flex: 1; min-width: 0; }
.routing-match-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.routing-match-name { font-size: 13px; font-weight: 650; }
.routing-match-rank {
  font-size: 10px; font-weight: 700; color: var(--teal);
  background: rgba(15,118,110,.09); border-radius: 999px; padding: 2px 7px;
}
.routing-match-model {
  margin-top: 2px; font-size: 11px; color: var(--ink-muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.routing-match-track {
  height: 5px; border-radius: 999px; overflow: hidden;
  background: rgba(47,111,235,.08);
  flex: 1;
}
.routing-match-fill {
  height: 100%; border-radius: inherit;
  background: linear-gradient(90deg, var(--teal), var(--blue));
  transition: width .5s ease;
}
.routing-match-meter { display: flex; align-items: center; gap: 10px; margin-top: 9px; }
.routing-match-score {
  min-width: 50px; text-align: right; font-family: "SF Mono", Menlo, Consolas, monospace;
  font-size: 11px; font-weight: 700; color: var(--teal);
}
@keyframes mini-bot-pulse {
  0%, 100% { transform: translateY(0); filter: drop-shadow(0 0 0 rgba(15,118,110,0)); }
  50% { transform: translateY(-2px); filter: drop-shadow(0 0 8px rgba(15,118,110,.34)); }
}
@keyframes bot-eye-scan {
  0%, 100% { opacity: .95; transform: translateX(0); }
  50% { opacity: .55; transform: translateX(1px); }
}

.embedding-symbol-panel {
  display: grid;
  grid-template-columns: minmax(360px, .8fr) minmax(420px, 1.2fr);
  gap: 18px; align-items: stretch;
  padding: 18px; border-radius: var(--radius);
  background: var(--card-bg);
  color: var(--ink); box-shadow: var(--shadow-sm); overflow: hidden;
  position: relative;
  border: 1px solid var(--border);
}
.embedding-symbol-panel.hidden { display: none; }
.embedding-symbol-copy {
  position: relative;
  z-index: 1;
  display: contents;
}
.embedding-symbol-copy h4 {
  grid-column: 1 / -1;
  font-size: 18px;
  font-weight: 700;
  margin-bottom: -8px;
}
.embedding-symbol-copy p {
  grid-column: 1 / -1;
  font-size: 13px;
  line-height: 1.65;
  color: var(--ink-muted);
  margin-bottom: -4px;
}
.semantic-expert-selector {
  grid-column: 2;
  grid-row: 3;
  border: 1px solid rgba(220,229,232,.9);
  border-radius: var(--radius);
  background: linear-gradient(180deg, #fff, rgba(15,118,110,.025));
  padding: 12px;
}
.semantic-expert-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
  font-size: 12px;
  font-weight: 700;
  color: var(--ink);
}
.semantic-expert-header span:last-child {
  color: var(--teal);
  font-size: 11px;
  text-align: right;
}
.semantic-expert-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.semantic-expert-item {
  min-width: 0;
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border: 1px solid rgba(220,229,232,.78);
  border-radius: var(--radius);
  background: rgba(255,255,255,.78);
}
.semantic-expert-item.selected {
  border-color: rgba(15,118,110,.32);
  background: rgba(15,118,110,.055);
}
.semantic-expert-rank {
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px 10px 6px 6px;
  background: rgba(102,114,122,.1);
  color: var(--ink-muted);
  font-size: 12px;
  font-weight: 800;
}
.semantic-expert-item.podium-1 .semantic-expert-rank {
  background: linear-gradient(135deg, rgba(15,118,110,.18), rgba(47,111,235,.18));
  color: var(--teal-dark);
}
.semantic-expert-item.podium-2 .semantic-expert-rank {
  background: rgba(47,111,235,.13);
  color: var(--blue);
}
.semantic-expert-item.podium-3 .semantic-expert-rank {
  background: rgba(183,121,31,.14);
  color: var(--amber);
}
.semantic-expert-main {
  min-width: 0;
}
.semantic-expert-top {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-top: 2px;
  font-size: 11px;
  font-weight: 600;
  color: var(--ink-muted);
}
.semantic-expert-top span:last-child {
  color: var(--ink-muted);
  font-family: "SF Mono", Menlo, Consolas, monospace;
  font-size: 11px;
  font-weight: 600;
}
.semantic-expert-model {
  color: var(--ink);
  font-size: 13px;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.semantic-expert-score {
  justify-self: end;
  min-width: 58px;
  padding: 5px 8px;
  border-radius: 999px;
  background: rgba(15,118,110,.1);
  color: var(--teal);
  font-family: "SF Mono", Menlo, Consolas, monospace;
  font-size: 12px;
  font-weight: 800;
  text-align: center;
}
.embedding-symbol-art {
  grid-column: 1;
  grid-row: 3;
  min-height: 360px; position: relative; border-radius: 12px; overflow: hidden;
  border: 1px solid rgba(220,229,232,.9); background: #fff;
}
.embedding-symbol-art canvas {
  display: block; width: 100%; height: 360px; position: relative; z-index: 1;
}
.embedding-symbol-glow {
  position: absolute; inset: -30%; z-index: 0; opacity: .55;
  background: radial-gradient(circle at 50% 50%, rgba(15,118,110,.12), transparent 62%);
  filter: blur(18px);
}
@keyframes semantic-glow { to { transform: rotate(360deg); } }
@media (max-width: 760px) {
  .embedding-symbol-panel { grid-template-columns: 1fr; }
  .embedding-symbol-copy h4,
  .embedding-symbol-copy p {
    grid-column: 1;
  }
  .semantic-expert-selector,
  .embedding-symbol-art {
    grid-column: 1;
    grid-row: auto;
  }
}

.conversation-timeline {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  align-items: stretch;
}
.conversation-timeline.count-1 { grid-template-columns: 1fr; }
.conversation-timeline.count-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.conversation-timeline.hidden { display: none; }
.conversation-card {
  padding: 18px;
}
.conversation-card.aggregator-message {
  grid-column: 1 / -1;
  border-color: rgba(15,118,110,.78);
  box-shadow: 0 18px 38px rgba(15,118,110,.14), 0 0 0 1px rgba(47,111,235,.1);
  background: var(--card-bg);
}
.conversation-card.aggregator-message .expert-card-avatar {
  background: rgba(15,118,110,.16);
  color: var(--teal);
}
.conversation-card.aggregator-message .expert-card-name {
  color: var(--teal-dark);
}
.conversation-card.aggregator-message .expert-card-body {
  min-height: 180px;
  padding: 8px 4px 4px;
}
.aggregator-answer-block {
  padding: 4px 4px 0;
}
.conversation-card.aggregator-message .aggregator-answer-block .md-content {
  padding: 2px 8px;
}
.conversation-timeline > .conversation-card.input-request-card { grid-column: 1 / -1 !important; }
.conversation-card-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 0;
}
.conversation-card-header .answer-copy-btn {
  margin-left: auto;
}
@media (max-width: 700px) {
  .conversation-timeline,
  .conversation-timeline.count-1,
  .conversation-timeline.count-2 {
    grid-template-columns: 1fr;
  }
}

.hitl-option {
  width: 100%;
  text-align: left;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
  padding: 10px 12px;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.input-request-options .hitl-option {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  column-gap: 12px;
}
.hitl-option.recommended {
  border-color: rgba(15,118,110,.42);
  background: rgba(15,118,110,.045);
}
.hitl-option:hover {
  border-color: rgba(47,111,235,.35);
  background: rgba(47,111,235,.04);
}
.hitl-option.is-selected {
  border-color: rgba(47,111,235,.55);
  background: rgba(47,111,235,.08);
}
.hitl-option-copy {
  min-width: 0;
}
.hitl-option-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  font-size: 13px;
  font-weight: 600;
}
.hitl-option-title {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 13px;
  font-weight: 600;
}
.hitl-option-badge {
  justify-self: end;
  flex-shrink: 0;
  margin-left: auto;
  font-size: 11px;
  color: #fff;
  background: var(--teal);
  border-radius: 999px;
  padding: 2px 7px;
}
.hitl-option-desc {
  font-size: 12px;
  color: var(--ink-muted);
  margin-top: 4px;
}
.input-request-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.input-request-options {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.input-request-card.is-locked {
  opacity: .82;
}
.input-request-card.is-locked .hitl-option {
  pointer-events: none;
}
.input-request-card.is-locked .hitl-option,
.input-request-card.is-locked .human-input {
  background: rgba(240,244,247,.8);
  border-color: rgba(191,203,211,.8);
  color: var(--ink-muted);
}
.input-request-card.is-locked .human-send-btn {
  background: #8ea4af;
  box-shadow: none;
  cursor: not-allowed;
  transform: none;
}
.input-request-card .field {
  margin-top: 0 !important;
}
.input-request-card .session-item-meta {
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
  line-height: 1.55;
}
.human-input {
  flex: 1 1 auto;
  width: 100%;
  min-width: 0;
  min-height: 120px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  font: inherit;
  font-size: 14px;
  resize: vertical;
}
.human-input:focus {
  outline: none;
  border-color: var(--blue);
}
.human-input-wrap {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  width: 100%;
}
.human-send-btn {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  box-shadow: 0 8px 20px rgba(18,58,122,.2);
}
.human-send-btn .send-spinner {
  display: none;
  animation: spin 1s linear infinite;
}
.human-send-btn.is-loading .send-icon {
  display: none;
}
.human-send-btn.is-loading .send-spinner {
  display: block;
}
.aggregator-review-section {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid rgba(15,118,110,.22);
}
.aggregator-review-section-title {
  display: inline-flex;
  align-items: center;
  margin: 0 0 10px 4px;
  padding: 3px 9px;
  border-radius: 999px;
  background: rgba(15,118,110,.1);
  color: var(--teal-dark);
  font-size: 12px;
  font-weight: 800;
}
.aggregator-review-grid {
  gap: 12px;
}
.aggregator-review-card {
  min-width: 0;
  border: 1px solid rgba(15,118,110,.18);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(248,253,252,.96), rgba(246,250,255,.9));
  box-shadow: 0 8px 18px rgba(15,118,110,.07), 0 2px 8px rgba(47,111,235,.06);
  padding: 14px;
}
.aggregator-review-verdict {
  display: flex;
  align-items: center;
  margin-bottom: 10px;
}
.aggregator-review-verdict .vote-badge {
  padding: 7px 11px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 0;
  box-shadow: 0 2px 8px rgba(24,35,42,.07);
}
.aggregator-review-verdict .vote-badge svg {
  width: 16px;
  height: 16px;
}
.aggregator-review-verdict .vote-badge.agree {
  background: rgba(15,118,110,.15);
  border: 1px solid rgba(15,118,110,.24);
}
.aggregator-review-verdict .vote-badge.disagree {
  background: rgba(183,121,31,.16);
  border: 1px solid rgba(183,121,31,.26);
}
.aggregator-review-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}
.aggregator-review-name {
  font-size: 13px;
  font-weight: 700;
}
.aggregator-review-model {
  margin-top: 2px;
  font-size: 11px;
  color: var(--ink-muted);
}
.aggregator-review-card .md-content {
  padding: 0;
}
.aggregator-review-card .md-content p:last-child {
  margin-bottom: 0;
}
@media (max-width: 560px) {
  .human-input-wrap {
    flex-direction: column;
    align-items: stretch;
  }
  .human-send-btn {
    align-self: flex-end;
  }
  .aggregator-review-grid {
    grid-template-columns: 1fr;
  }
}

/* --- Debug details --- */
.debug-details { margin-top: auto; border-top: 1px solid var(--border); }
.debug-details summary {
  padding: 10px 16px; font-size: 12px; color: var(--ink-muted);
  cursor: pointer; display: flex; align-items: center; gap: 6px;
}
.debug-details[open] summary { border-bottom: 1px solid var(--border); }
.debug-content { padding: 12px 16px; }
.debug-content .field { margin-bottom: 12px; }
.debug-content label { display: block; font-size: 12px; font-weight: 500; margin-bottom: 4px; }
.inline-field-row { display: flex; gap: 6px; }
.debug-content input {
  width: 100%; padding: 6px 10px; border: 1px solid var(--border);
  border-radius: var(--radius); font: inherit; font-size: 12px;
}
.moe-resource-inline {
  margin-top: 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
  overflow: hidden;
}

.file-empty {
  color: var(--ink-muted);
  cursor: default;
}
.file-empty:hover { background: transparent; }

/* --- Responsive mobile sidebar --- */
.sidebar-backdrop {
  position: fixed;
  top: 56px;
  right: 0;
  bottom: 0;
  left: var(--moe-sidebar-effective-width);
  z-index: 90;
  background: rgba(15, 23, 42, .16);
  cursor: default !important;
}
.sidebar-backdrop[hidden] { display: none; }

@media (max-width: 1024px) {
  .moe-sidebar {
    left: calc(var(--moe-sidebar-effective-width) * -1);
    width: var(--moe-sidebar-effective-width);
  }
  .moe-sidebar.open { left: 0; }
  .moe-main {
    width: calc(100vw - 24px);
    padding: 16px 0 20px;
  }
}

/* ---------- Floating quick actions ---------- */
.floating-quick-actions {
  position: fixed;
  right: 26px;
  bottom: 26px;
  z-index: 80;
  display: grid;
  grid-template-rows: 44px 1px 44px;
  width: 46px;
  overflow: visible;
  border: 1px solid rgba(255, 255, 255, 0.42);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.95);
  color: #0f172a;
  box-shadow: 0 18px 36px rgba(15, 23, 42, 0.16);
}
.floating-quick-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 46px;
  height: 44px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
  position: relative;
  text-decoration: none;
  transition: background 180ms ease, color 180ms ease, opacity 180ms ease;
}
.floating-feedback-action {
  border-radius: 999px 999px 0 0;
}
.floating-back-to-top-action {
  border-radius: 0 0 999px 999px;
}
.floating-quick-action svg {
  display: block;
  width: 20px;
  height: 20px;
}
.floating-quick-action:hover {
  background: rgba(15, 23, 42, 0.07);
  color: #0f172a;
}
.floating-quick-action:focus-visible {
  outline: 2px solid rgba(37, 99, 235, 0.55);
  outline-offset: -3px;
}
.floating-quick-action[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  right: calc(100% + 12px);
  top: 50%;
  z-index: 2;
  transform: translate(6px, -50%);
  min-width: max-content;
  max-width: 220px;
  padding: 7px 9px;
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.94);
  color: #f8fafc;
  font-size: 12px;
  line-height: 1.35;
  white-space: nowrap;
  text-align: center;
  box-shadow: 0 14px 30px rgba(15, 23, 42, 0.22);
  opacity: 0;
  pointer-events: none;
  transition: opacity 120ms ease, transform 120ms ease;
}
.floating-quick-action[data-tooltip]::before {
  content: "";
  position: absolute;
  right: calc(100% + 7px);
  top: 50%;
  z-index: 2;
  width: 8px;
  height: 8px;
  background: rgba(15, 23, 42, 0.94);
  transform: translate(6px, -50%) rotate(45deg);
  opacity: 0;
  pointer-events: none;
  transition: opacity 120ms ease, transform 120ms ease;
}
.floating-quick-action:hover::after,
.floating-quick-action:focus-visible::after {
  opacity: 1;
  transform: translate(0, -50%);
}
.floating-quick-action:hover::before,
.floating-quick-action:focus-visible::before {
  opacity: 1;
  transform: translate(0, -50%) rotate(45deg);
}
.floating-quick-actions-divider {
  width: 28px;
  height: 1px;
  justify-self: center;
  background: rgba(15, 23, 42, 0.13);
}
.floating-back-to-top-action {
  opacity: 1;
  pointer-events: auto;
}

@media (max-width: 640px) {
  .floating-quick-actions {
    right: 16px;
    bottom: 16px;
    grid-template-rows: 42px 1px 42px;
    width: 44px;
  }
  .floating-quick-action {
    width: 44px;
    height: 42px;
  }
}

/* ---------- Back-to-top button ---------- */
.back-to-top-btn {
  position: fixed;
  right: 26px;
  bottom: 26px;
  z-index: 40;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 54px;
  height: 54px;
  border: 1px solid rgba(255, 255, 255, 0.38);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.94);
  color: #0f172a;
  box-shadow: 0 18px 36px rgba(15, 23, 42, 0.16);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: opacity 180ms ease, transform 180ms ease, background 180ms ease, box-shadow 180ms ease;
}
.back-to-top-btn svg {
  width: 20px;
  height: 20px;
  display: block;
}
.back-to-top-btn.is-visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}
.back-to-top-btn:hover {
  background: rgba(255, 255, 255, 0.32);
  box-shadow: 0 22px 42px rgba(15, 23, 42, 0.2);
}

[data-ai-assistant] {
  min-width: 0;
  min-height: 0;
}

[data-ai-assistant] .ai-assistant-root {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  min-width: 0;
  min-height: 0;
  height: 100%;
  background: #fbfcfd;
  color: #1f2937;
}

[data-ai-assistant] .ai-assistant-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid #dce5e8;
  background: #ffffff;
}

[data-ai-assistant] .ai-assistant-head > div {
  display: grid;
  gap: 4px;
  min-width: 0;
}

[data-ai-assistant] .ai-assistant-head strong {
  color: #111827;
  font-size: 14px;
  line-height: 1.25;
}

[data-ai-assistant] .ai-assistant-head span {
  color: #66727a;
  font-size: 12px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

[data-ai-assistant] .ai-assistant-clear {
  flex: 0 0 auto;
  min-height: 28px;
  padding: 0 10px;
  border: 1px solid #dce5e8;
  border-radius: 7px;
  background: #ffffff;
  color: #4b5960;
  font-size: 12px;
  font-weight: 750;
}

[data-ai-assistant] .ai-assistant-messages {
  display: grid;
  align-content: start;
  gap: 12px;
  min-height: 0;
  padding: 14px 16px;
  overflow: auto;
}

[data-ai-assistant] .ai-assistant-empty {
  display: grid;
  gap: 8px;
  padding: 18px 16px;
  border: 1px solid #dce5e8;
  border-radius: 8px;
  background: #ffffff;
}

[data-ai-assistant] .ai-assistant-empty strong {
  color: #111827;
  font-size: 15px;
}

[data-ai-assistant] .ai-assistant-empty span {
  color: #66727a;
  font-size: 13px;
  line-height: 1.55;
}

[data-ai-assistant] .ai-assistant-message {
  display: grid;
  gap: 6px;
  max-width: 100%;
}

[data-ai-assistant] .ai-assistant-message-role {
  color: #66727a;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

[data-ai-assistant] .ai-assistant-message-body {
  padding: 11px 12px;
  border: 1px solid #dce5e8;
  border-radius: 8px;
  background: #ffffff;
  color: #1f2937;
  font-size: 13px;
  line-height: 1.6;
  overflow-wrap: anywhere;
}

[data-ai-assistant] .ai-assistant-message.is-user .ai-assistant-message-body {
  border-color: rgba(43, 108, 176, 0.28);
  background: #edf6ff;
}

[data-ai-assistant] .ai-assistant-message-body p,
[data-ai-assistant] .ai-assistant-message-body ul,
[data-ai-assistant] .ai-assistant-message-body ol,
[data-ai-assistant] .ai-assistant-message-body pre {
  margin: 0 0 9px;
}

[data-ai-assistant] .ai-assistant-message-body > :last-child {
  margin-bottom: 0;
}

[data-ai-assistant] .ai-assistant-message-body pre {
  overflow: auto;
  padding: 10px;
  border-radius: 7px;
  background: #111827;
  color: #eef2f7;
}

[data-ai-assistant] .ai-assistant-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 42px;
  gap: 10px;
  margin: 0 16px 16px;
  padding: 12px;
  border: 1px solid #dce5e8;
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 12px 28px rgba(24, 35, 42, 0.08);
}

[data-ai-assistant] .ai-assistant-textarea {
  width: 100%;
  min-width: 0;
  height: 42px;
  max-height: 150px;
  padding: 10px 0;
  border: 0;
  outline: 0;
  resize: none;
  color: #111827;
  background: transparent;
  font: inherit;
  font-size: 13px;
  line-height: 1.45;
}

[data-ai-assistant] .ai-assistant-send {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 999px;
  background: var(--primary, #2b6cb0);
  color: #ffffff;
}

[data-ai-assistant] .ai-assistant-send:disabled {
  opacity: 0.58;
  cursor: wait;
}

[data-ai-assistant] .ai-assistant-send svg {
  width: 18px;
  height: 18px;
}

[data-ai-assistant] .ai-assistant-attached {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0 16px 10px;
  min-height: 0;
}

[data-ai-assistant] .ai-assistant-attached-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  border: 1px solid rgba(43, 108, 176, 0.22);
  border-radius: 999px;
  background: #edf6ff;
  color: #1f2937;
  font-size: 12px;
  line-height: 1.3;
  max-width: 100%;
}

[data-ai-assistant] .ai-assistant-attached-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

[data-ai-assistant] .ai-assistant-attached-remove {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  display: inline-grid;
  place-items: center;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: #66727a;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
}

[data-ai-assistant] .ai-assistant-attached-remove:hover {
  background: rgba(190, 18, 60, 0.1);
  color: var(--rose);
}

[data-ai-assistant] .ai-assistant-attached-hint {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px;
  border: 1px solid rgba(43, 108, 176, 0.18);
  border-radius: 6px;
  background: rgba(47, 111, 235, 0.05);
  color: var(--blue);
  font-size: 12px;
  font-weight: 500;
  line-height: 1.3;
  margin-bottom: 6px;
  cursor: pointer;
  user-select: none;
}

[data-ai-assistant] .ai-assistant-attached-hint-toggle {
  border: none;
  background: transparent;
  color: var(--blue);
  font: inherit;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  padding: 0;
  line-height: 1;
}

[data-ai-assistant] .ai-assistant-attached-detail {
  margin-bottom: 8px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #f8fafc;
  font-size: 12px;
  line-height: 1.55;
  color: var(--ink);
}

[data-ai-assistant] .ai-assistant-attached-detail[hidden] {
  display: none;
}

[data-ai-assistant] .ai-assistant-attached-detail-item + .ai-assistant-attached-detail-item {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

[data-ai-assistant] .ai-assistant-attached-detail-item strong {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-muted);
}

[data-ai-assistant] .ai-assistant-attached-detail-item p {
  margin-top: 4px;
  color: var(--ink);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.reader-selection-tooltip {
  position: fixed;
  z-index: 10001;
  padding: 0;
  background: #ffffff;
  border: 1px solid #dce5e8;
  border-radius: 999px;
  box-shadow: 0 4px 14px rgba(24, 35, 42, 0.12);
  animation: rise 120ms ease both;
  pointer-events: auto;
  font-size: 12px;
}

.reader-selection-tooltip-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px 5px 8px;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: #1f2937;
  font: inherit;
  font-size: inherit;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  line-height: 1;
}

.reader-selection-tooltip-btn:hover {
  background: rgba(47, 111, 235, 0.06);
}

.reader-selection-tooltip-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 1.5px solid currentColor;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  flex-shrink: 0;
}
