  :root {
    --bg: #eef2f7;
    --surface: rgba(255, 255, 255, 0.64);
    --surface-2: rgba(255, 255, 255, 0.82);
    --line: rgba(173, 186, 201, 0.34);
    --line-2: rgba(173, 186, 201, 0.52);
    --ink: #17202b;
    --muted: #77828e;
    --faint: #9aa5b0;
    --blue: #b32d33;
    --blue-soft: rgba(179, 45, 51, 0.10);
    --green: #2d9a5e;
    --green-soft: #e0f0e8;
    --gold: #d49516;
    --gold-soft: #faf0e0;
    --red: #d4504c;
    --red-soft: #fae8e6;
    --shadow: 0 12px 32px rgba(72, 89, 108, 0.09);
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "PingFang SC", "Helvetica Neue", "Microsoft YaHei", sans-serif;
  }

@font-face {
  font-family: "AlimamaShuhei";
  src: url("/assets/fonts/alimama-shuhei.ttf") format("truetype");
  font-display: swap;
}

.social-collector-panel {
  display: grid;
  gap: 16px;
}

.social-collector-panel[hidden] { display: none !important; }
#sourceTranscribePanel[hidden] { display: none !important; }

.social-collector-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.social-collector-head h2,
.social-coming-panel h2 {
  margin: 8px 0 4px;
}

.social-collector-head p,
.social-coming-panel p,
.social-status-message,
.social-manual-note {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.social-platform-badge,
.social-status-badge {
  display: inline-flex;
  min-height: 26px;
  align-items: center;
  justify-content: center;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
}

.social-platform-badge { color: #fff; background: #171b22; }
.social-status-badge { color: #697281; background: #eef0f3; white-space: nowrap; }
.social-status-badge.ready { color: #166534; background: #dcfce7; }
.social-status-badge.ready {
  width: 10px;
  min-width: 10px;
  height: 10px;
  min-height: 10px;
  padding: 0;
  overflow: hidden;
  color: transparent;
  background: #22c55e;
  box-shadow: 0 0 0 4px rgba(34, 197, 94, .14);
}
.social-status-badge.waiting,
.social-status-badge.checking { color: #92400e; background: #fef3c7; }
.social-status-badge.failed { color: #991b1b; background: #fee2e2; }
.social-status-action {
  border: 0;
  cursor: pointer;
}
.social-status-action:not(.ready):hover {
  color: #8f2429;
  background: #f8ecee;
}

.social-login-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.social-login-actions[hidden],
.social-status-message[hidden] { display: none !important; }

.social-profile-form { display: grid; gap: 10px; }
.social-profile-form input { min-height: 50px; }
.social-filter-grid {
  display: grid;
  width: 100%;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 9px;
  justify-items: stretch;
}
.social-filter-grid label {
  position: relative;
  display: grid;
  width: 100%;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-align: center;
}
.social-filter-grid label::after {
  position: absolute;
  right: 14px;
  bottom: 13px;
  color: #77828e;
  content: '⌄';
  font-size: 14px;
  line-height: 1;
  pointer-events: none;
}
.social-filter-grid label.social-select-enhanced::after { display: none; }
.social-filter-grid select {
  min-width: 0;
  min-height: 44px;
  padding-right: 30px;
  text-align: center;
  appearance: none;
}
.social-filter-grid select:disabled { opacity: 1; }
.social-select-menu {
  position: relative;
  width: 100%;
}

.social-select-menu > select {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

.social-select-trigger {
  display: flex;
  width: 100%;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 12px;
  border: 1px solid rgba(30, 37, 49, .08);
  border-radius: 14px;
  color: var(--ink);
  background: #f6f7f9;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.9);
  font: inherit;
  font-size: 13px;
  font-weight: 750;
  cursor: pointer;
}

.social-select-trigger svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  transition: transform .16s ease;
}

.social-select-menu.open .social-select-trigger {
  border-color: rgba(169,43,50,.28);
  background: #fff;
  box-shadow: 0 0 0 4px rgba(169,43,50,.07);
}

.social-select-menu.open .social-select-trigger svg { transform: rotate(180deg); }

.social-select-options {
  position: absolute;
  z-index: 80;
  top: calc(100% + 7px);
  right: 0;
  left: 0;
  display: none;
  gap: 3px;
  padding: 6px;
  overflow: hidden;
  border: 1px solid rgba(30,37,49,.08);
  border-radius: 15px;
  background: rgba(255,255,255,.98);
  box-shadow: 0 16px 38px rgba(26,33,44,.16);
  backdrop-filter: blur(18px);
}

.social-select-menu.open .social-select-options { display: grid; }

.social-select-options button {
  min-height: 40px;
  padding: 7px 10px;
  border: 0;
  border-radius: 10px;
  color: #555e6b;
  background: transparent;
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  text-align: center;
  cursor: pointer;
}

.social-select-options button:hover,
.social-select-options button.selected {
  color: #8f2429;
  background: #f8ecee;
}
.social-filter-grid-secondary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.douyin-filter-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.xiaohongshu-filter-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.social-filter-grid + .primary-btn { margin-top: 12px; }

.social-task-status {
  display: grid;
  gap: 8px;
  padding: 13px 14px;
  overflow: hidden;
  border-radius: 14px;
  background: #f6f7f9;
}
.social-task-status[hidden] { display: none !important; }

.social-task-status > div { display: flex; justify-content: space-between; gap: 12px; }
.social-task-status p { margin: 0; color: #991b1b; font-size: 13px; }
.social-task-status i { display: block; width: var(--progress, 0%); height: 4px; border-radius: 99px; background: #a92b32; transition: width .25s ease; }

.social-result-list { display: grid; gap: 10px; }
.social-result-card {
  display: grid;
  grid-template-columns: 76px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  padding: 10px;
  border-radius: 15px;
  background: #f6f7f9;
}
.social-result-card img,
.social-result-index { width: 76px; height: 96px; border-radius: 11px; object-fit: cover; background: #e6e9ee; }
.social-result-index { display: grid; place-items: center; color: #7a8492; font-size: 22px; font-weight: 800; }
.social-result-card div { min-width: 0; display: grid; gap: 5px; }
.social-result-card strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.social-result-card small { color: var(--muted); }
.social-result-card a { color: #a92b32; font-size: 13px; font-weight: 700; text-decoration: none; }
.social-result-card { cursor: pointer; }
.social-result-open { color: #a92b32; font-size: 13px; font-weight: 800; }
.social-processing-state { color: var(--muted); font-size: 12px; }
.social-processing-state.running { color: #92400e; }
.social-processing-state.complete { color: #166534; }
.social-processing-state.failed { color: #991b1b; }
.social-manual-note { padding-top: 2px; font-size: 12px; }
.social-candidate-cover-link {
  position: relative;
  display: grid;
  width: 100%;
  height: 100%;
  place-items: center;
  overflow: hidden;
  color: #fff;
  text-decoration: none;
  background: #151922;
}
.social-candidate-cover-link img { width: 100%; height: 100%; object-fit: contain; }
.social-candidate-cover-link span {
  position: absolute;
  bottom: 16px;
  padding: 8px 14px;
  border-radius: 999px;
  color: #fff;
  background: rgba(0,0,0,.72);
  font-weight: 800;
}
.social-transcript-panel { display: grid; gap: 8px; }
.social-transcript-panel h3 { margin: 0; }
.social-transcript-panel pre {
  max-height: 260px;
  margin: 0;
  padding: 14px;
  overflow: auto;
  border-radius: 12px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  background: #f6f7f9;
  font: inherit;
  line-height: 1.7;
}

@media (max-width: 760px) {
  html, body { min-height: 100%; overflow-y: auto !important; }
  .app-shell { min-height: 100%; height: auto !important; overflow: visible !important; }
  main,
  .stage.active,
  section[data-stage="source"] .source-grid { height: auto !important; min-height: 0; overflow: visible !important; }
  #douyinCollectorPanel { max-height: none !important; overflow: visible !important; }
  #douyinResults { overflow: visible !important; }
  .social-collector-panel { gap: 14px; }
  .social-collector-head { gap: 10px; }
  .social-collector-head { justify-content: flex-start; text-align: left; }
  .social-collector-head h2 { font-size: 21px; }
  .social-collector-head p { font-size: 13px; }
  .social-login-actions { gap: 8px; }
  .social-login-actions .secondary-btn { min-height: 44px; padding: 7px 8px; font-size: 13px; }
  .social-profile-form input { min-height: 48px; font-size: 13px; }
  .social-filter-grid { gap: 6px; }
  .social-filter-grid label { font-size: 11px; }
  .social-filter-grid select { min-height: 42px; padding: 6px 28px 6px 7px; font-size: 12px; text-align: center; }
  .social-result-card { grid-template-columns: 64px minmax(0, 1fr); }
  .social-result-card img,
  .social-result-index { width: 64px; height: 82px; }
}

/* External personal library */
.personal-library-panel {
  height: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 22px;
  overflow: hidden;
}

.personal-library-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  flex-shrink: 0;
}

.personal-library-eyebrow {
  display: block;
  margin-bottom: 5px;
  color: var(--red);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .12em;
}

.personal-library-header h2 {
  margin: 0;
  font-size: 24px;
}

.personal-library-header p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.personal-library-summary {
  padding: 9px 13px;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--ink);
  background: var(--surface-2);
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
}

.personal-library-toolbar {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) auto;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.personal-library-toolbar input {
  min-height: 42px;
  background: var(--surface);
}

.personal-library-filters {
  display: flex;
  align-items: center;
  gap: 6px;
  overflow-x: auto;
}

.personal-library-filters button {
  min-height: 34px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: var(--surface);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.personal-library-filters button.active {
  border-color: rgba(187, 39, 48, .3);
  color: var(--red);
  background: var(--red-soft);
}

.personal-library-filters em {
  margin-left: 4px;
  font-style: normal;
  opacity: .72;
}

.personal-library-content {
  min-height: 0;
  flex: 1;
  overflow-y: auto;
  padding-right: 4px;
}

.personal-library-total {
  display: inline-flex;
  min-height: 38px;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--muted);
  background: var(--surface);
  font-size: 12px;
  font-weight: 800;
}

.personal-library-total strong {
  color: var(--ink);
  font-size: 17px;
}

.personal-library-total.active {
  color: #fff;
  background: #252b34;
  border-color: #252b34;
}

.personal-library-total.active strong { color: #fff; }

.personal-library-overview {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.personal-library-overview button {
  display: flex;
  min-width: 0;
  min-height: 76px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 13px 15px;
  border: 1px solid var(--line);
  border-radius: 15px;
  color: var(--ink);
  background: var(--surface-2);
  text-align: left;
}

.personal-library-overview button > span {
  display: grid;
  min-width: 0;
  gap: 3px;
  font-size: 14px;
  font-weight: 850;
}

.personal-library-overview button small {
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.personal-library-overview button strong {
  flex: 0 0 auto;
  font-size: 22px;
}

.personal-library-overview button.active {
  border-color: rgba(169, 43, 50, .24);
  color: #98272d;
  background: #f8edef;
}

.personal-library-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.personal-library-section-head strong { font-size: 15px; }
.personal-library-section-head span { color: var(--muted); font-size: 12px; }

.personal-library-empty button {
  min-height: 42px;
  margin: 16px auto 0;
  padding: 0 18px;
  border: 0;
  border-radius: 12px;
  color: #fff;
  background: #a92b32;
  font-weight: 800;
}

.personal-library-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.personal-library-card {
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: 0 8px 24px rgba(32, 45, 68, .05);
}

.personal-library-media {
  aspect-ratio: 16 / 9;
  background: #111827;
}

.personal-library-media video {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
}

.personal-library-card-body {
  padding: 14px;
}

.personal-library-card-top,
.personal-library-card footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.personal-library-card-top span {
  color: var(--red);
  font-size: 11px;
  font-weight: 900;
}

.personal-library-card-top time,
.personal-library-card footer small {
  color: var(--muted);
  font-size: 11px;
}

.personal-library-card h3 {
  margin: 10px 0 7px;
  font-size: 16px;
  line-height: 1.4;
}

.personal-library-card p {
  min-height: 42px;
  margin: 0 0 14px;
  color: var(--ink);
  font-size: 13px;
  line-height: 1.6;
}

.personal-library-open {
  padding: 0;
  border: 0;
  color: var(--red);
  background: transparent;
  font-size: 12px;
  font-weight: 800;
}

.personal-library-empty {
  min-height: 320px;
  display: grid;
  place-content: center;
  text-align: center;
  color: var(--muted);
}

.personal-library-empty strong {
  color: var(--ink);
  font-size: 18px;
}

.personal-library-empty p {
  margin: 8px 0 0;
  font-size: 13px;
}

@media (max-width: 1100px) {
  .personal-library-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .personal-library-toolbar {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 680px) {
  .personal-library-panel {
    height: auto;
    padding: 16px;
    overflow: visible;
  }

  .personal-library-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .personal-library-grid {
    grid-template-columns: 1fr;
  }

  .personal-library-content {
    overflow: visible;
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  height: 100vh;
  overflow: hidden;
  color: var(--ink);
  background: var(--bg);
}

body.auth-required {
  overflow: hidden;
}

body.auth-pending .app-shell,
body.auth-required .app-shell {
  visibility: hidden;
  pointer-events: none;
}

body.auth-pending .auth-overlay {
  display: none;
}

body.auth-required .auth-overlay {
  background: var(--bg);
  backdrop-filter: none;
}

body.auth-pending::before {
  content: "正在恢复登录状态";
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  color: var(--muted);
  background: var(--bg);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0;
}

body.auth-pending::after {
  content: "";
  position: fixed;
  top: calc(50% - 28px);
  left: calc(50% - 10px);
  z-index: 41;
  width: 20px;
  height: 20px;
  border: 2px solid rgba(179, 45, 51, 0.18);
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

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

button {
  cursor: pointer;
}

.app-shell {
  width: 100%;
  max-width: 1440px;
  margin: 0 auto;
  padding: 28px;
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.hero {
  position: relative;
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 10px;
  flex-shrink: 0;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  position: relative;
}

.header-stats {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--muted);
  background: var(--surface);
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}

.user-name-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--blue);
  background: var(--blue-soft);
}

.user-name-btn:hover,
.user-name-btn[aria-expanded="true"] {
  border-color: rgba(179, 45, 51, 0.36);
  color: #8f2429;
  background: #f6e6e7;
}

.user-name-btn > span {
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-name-btn svg {
  width: 15px;
  height: 15px;
  flex: 0 0 15px;
  transition: transform 160ms ease;
}

.user-name-btn[aria-expanded="true"] svg {
  transform: rotate(180deg);
}

.account-wrap {
  position: relative;
}

.account-wrap[hidden],
.account-menu[hidden] {
  display: none;
}

.account-menu {
  position: absolute;
  z-index: 320;
  top: calc(100% + 8px);
  right: 0;
  width: 210px;
  padding: 10px;
  border: 1px solid rgba(179, 45, 51, 0.18);
  border-radius: 8px;
  background: rgba(250, 250, 253, 0.96);
  box-shadow: 0 18px 42px rgba(26, 26, 46, 0.15);
  backdrop-filter: blur(18px);
}

.account-menu-profile {
  padding: 4px 8px 10px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 6px;
}

.account-menu-profile strong,
.account-menu-profile small {
  display: block;
}

.account-menu-profile strong {
  color: var(--ink);
  font-size: 14px;
}

.account-menu-profile small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
}

.account-menu button {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  min-height: 38px;
  padding: 0 9px;
  border: 0;
  border-radius: 6px;
  color: var(--ink);
  background: transparent;
  text-align: left;
  font-size: 13px;
}

.account-menu button:hover,
.account-menu button:focus-visible {
  color: var(--blue);
  background: var(--blue-soft);
  outline: none;
}

.account-menu button svg {
  width: 16px;
  height: 16px;
  flex: 0 0 16px;
}

.project-overview {
  display: grid;
  gap: 8px;
  margin-bottom: 10px;
  flex-shrink: 0;
}

.project-overview:empty {
  display: none;
}

.auth-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 50;
  place-items: center;
  padding: 22px;
  background: rgba(0, 0, 0, 0.25);
  backdrop-filter: blur(4px);
}

.auth-overlay.active {
  display: grid;
}

.auth-modal {
  width: min(420px, 100%);
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.12);
}

.auth-heading {
  text-align: center;
}

.auth-heading h2 {
  font-size: 22px;
}

.auth-modal p {
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.auth-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
  margin-top: 20px;
}

.auth-grid .field-row {
  margin-bottom: 0;
}

.auth-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin-top: 4px;
}

.auth-error {
  margin: 2px 0 0;
  padding: 9px 11px;
  border: 1px solid rgba(212, 80, 76, 0.28);
  border-radius: 7px;
  color: #b33f3b;
  background: var(--red-soft);
  font-size: 13px;
  line-height: 1.45;
  text-align: center;
}

.auth-error[hidden] {
  display: none;
}

.auth-actions button {
  width: 100%;
  min-height: 42px;
}

.social-login {
  display: grid;
  gap: 10px;
  margin-top: 4px;
}

.social-login > span {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.social-login > span::before,
.social-login > span::after {
  content: '';
  height: 1px;
  flex: 1;
  background: var(--line);
}

.social-login-actions {
  display: grid;
  grid-template-columns: 1.2fr 1fr 1fr;
  gap: 8px;
}

.social-login-button {
  min-height: 38px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: var(--surface);
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
}

.social-login-button:hover,
.social-login-button:focus-visible {
  border-color: var(--blue);
  outline: none;
}

.social-login-button.wechat { color: #159b50; }
.social-login-button.alipay { color: #1677d2; }
.social-login-button.qq { color: #2676d2; }

.auth-display-name-field[hidden] {
  display: none;
}

.library-confirm-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 80;
  place-items: center;
  padding: 22px;
  background: rgba(0, 0, 0, 0.20);
  backdrop-filter: blur(4px);
}

.library-confirm-overlay.active {
  display: grid;
}

.library-confirm-modal {
  width: min(680px, 100%);
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.10);
}

.library-confirm-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
}

.library-confirm-head h3 {
  margin: 0;
  color: var(--ink);
  font-size: 18px;
}

.library-confirm-head p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.library-confirm-close {
  width: 32px;
  height: 32px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: var(--surface);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}

.library-confirm-field {
  display: grid;
  gap: 6px;
  margin-top: 14px;
}

.library-confirm-field[hidden] {
  display: none;
}

.library-confirm-field label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.library-confirm-field select {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: var(--surface);
  font: inherit;
  font-size: 13px;
  font-weight: 900;
}

.course-select-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.course-select-row select {
  min-width: 0;
}

.add-course-btn {
  white-space: nowrap;
}

.library-confirm-textarea {
  width: 100%;
  min-height: 112px;
  max-height: 180px;
  margin-top: 14px;
  resize: vertical;
}

.library-confirm-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 14px;
}

.text-input-modal {
  width: min(460px, 100%);
}

.course-create-modal {
  width: min(720px, 100%);
  max-height: calc(100dvh - 48px);
  overflow-y: auto;
  overscroll-behavior: contain;
}

.course-create-overlay {
  z-index: 9100;
  padding-top: max(24px, env(safe-area-inset-top));
  padding-bottom: max(24px, env(safe-area-inset-bottom));
}

.course-create-mode-switch {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px;
  margin: 14px 0;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
}

.course-create-mode-switch button {
  min-height: 38px;
  border: 0;
  border-radius: 6px;
  color: var(--muted);
  background: transparent;
  font-weight: 900;
  cursor: pointer;
}

.course-create-mode-switch button.active {
  color: var(--ink);
  background: var(--surface);
  box-shadow: 0 1px 4px rgba(24, 31, 44, 0.1);
}

.text-input-control {
  width: 100%;
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: var(--surface);
  font-size: 14px;
  font-weight: 800;
  outline: none;
}

.text-input-control:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(179, 45, 51, 0.12);
}

.text-input-control.input-error {
  border-color: var(--red);
  box-shadow: 0 0 0 3px rgba(212, 80, 76, 0.12);
}

textarea.text-input-control {
  min-height: 120px;
  padding: 10px 12px;
  resize: vertical;
  line-height: 1.6;
  font-weight: 500;
}

.library-confirm-field small {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.course-profile-modal {
  width: min(860px, 100%);
  max-height: calc(100vh - 44px);
  overflow-y: auto;
}

.course-profile-status {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 14px;
  padding: 10px 12px;
  border-left: 3px solid var(--blue);
  background: var(--blue-soft);
}

.course-profile-status.failed,
.course-profile-error {
  border-color: var(--red);
  color: var(--red);
  background: var(--red-soft);
}

.course-profile-status.ready {
  border-color: var(--green);
  background: var(--green-soft);
}

.course-profile-status small {
  margin-left: auto;
  color: var(--muted);
}

.course-profile-error,
.course-profile-summary {
  margin-top: 12px;
  padding: 10px 12px;
  line-height: 1.6;
}

.course-profile-summary {
  border-left: 3px solid var(--ink);
  background: var(--surface-2);
}

.course-profile-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0 18px;
  margin-top: 14px;
  border-top: 1px solid var(--line);
}

.course-profile-row {
  min-width: 0;
  padding: 11px 0;
  border-bottom: 1px solid var(--line);
}

.course-profile-row b,
.course-profile-issues h4 {
  font-size: 12px;
}

.course-profile-row p,
.course-profile-issues p,
.course-profile-issues li {
  margin-top: 5px;
  font-size: 13px;
  line-height: 1.6;
  overflow-wrap: anywhere;
}

.course-profile-empty {
  color: var(--muted);
}

.course-profile-issues,
.course-profile-evidence {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.course-profile-issues ul,
.course-profile-evidence ul {
  display: grid;
  gap: 10px;
  margin: 9px 0 0;
  padding-left: 18px;
}

.course-profile-issues small,
.course-profile-evidence small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  line-height: 1.5;
}

.course-profile-evidence summary {
  cursor: pointer;
  font-size: 13px;
  font-weight: 800;
}

.danger-action {
  background: var(--red) !important;
  color: #fff !important;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 32px;
  line-height: 1.08;
  font-weight: 850;
  letter-spacing: 0;
}

.brand-lockup {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.brand-logo {
  display: block;
  width: auto;
  height: 42px;
  object-fit: contain;
}

.brand-subtitle {
  min-height: 22px;
  display: inline-flex;
  align-items: center;
  padding-left: 12px;
  border-left: 1px solid var(--line-2);
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  line-height: 1.35;
  white-space: nowrap;
}

h2 {
  font-size: 19px;
}

.step-nav {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 12px;
  padding: 7px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.step-nav button {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--muted);
  background: var(--surface-2);
  font-weight: 800;
  font-size: 14px;
  padding: 0 8px;
  outline: none;
}

.step-nav button:focus-visible {
  box-shadow: 0 0 0 3px rgba(179, 45, 51, 0.18);
}

.step-nav button b {
  display: none;
  width: 25px;
  height: 25px;
  margin-right: 7px;
  place-items: center;
  border-radius: 999px;
  color: var(--faint);
  background: var(--surface);
}

.step-nav button.active {
  color: #fff;
  border-color: var(--blue);
  background: var(--blue);
}

.step-nav button.active b {
  color: var(--blue);
}

.step-nav button.collecting #realtimeNavLabel::after {
  display: inline-block;
  width: 10px;
  height: 10px;
  margin-left: 7px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  content: '';
  vertical-align: -1px;
  animation: spin 0.8s linear infinite;
}

.step-nav button.synthesizing #digitalHumanNavLabel::after {
  display: inline-block;
  width: 10px;
  height: 10px;
  margin-left: 7px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  content: '';
  vertical-align: -1px;
  animation: spin 0.8s linear infinite;
}

.stage {
  display: none;
}

.stage.active {
  display: block;
  height: 100%;
  overflow-y: hidden;
}

.stage-grid {
  display: grid;
  gap: 16px;
}

.source-grid,
.chat-grid,
.knowledge-grid,
.rewrite-grid,
.review-grid {
  grid-template-columns: minmax(360px, 0.85fr) minmax(420px, 1.15fr);
}

.panel {
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.panel-head {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
  flex-shrink: 0;
}

.panel-head p,
.panel > p {
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.review-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.metric-preview {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 4px 0 14px;
}

.metric-chip {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.72);
}

.metric-chip b {
  display: block;
  color: var(--ink);
  font-size: 15px;
  line-height: 1.3;
}

.metric-chip span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.metric-chip small {
  display: block;
  margin-top: 4px;
  color: var(--blue);
  font-size: 12px;
}

.advanced-review-fields {
  margin: 2px 0 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.48);
}

.advanced-review-fields summary {
  cursor: pointer;
  color: var(--ink);
  font-weight: 700;
  font-size: 13px;
}

.advanced-review-fields .field-row {
  margin-top: 12px;
}

.review-metric-line {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 8px;
}

.review-metric-line span {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 8px;
  color: var(--muted);
  font-size: 12px;
}

section[data-stage="review"] .panel {
  overflow-y: auto;
}

section[data-stage="review"] .panel-head {
  margin-bottom: 12px;
}

.review-form-title {
  width: fit-content;
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  padding: 0 12px;
  border: 1px solid rgba(179, 45, 51, 0.20);
  border-radius: 10px;
  color: var(--ink);
  background: linear-gradient(180deg, #ffffff 0%, #fff8f8 100%);
  font-size: 18px;
  font-weight: 950;
  letter-spacing: 0;
}

section[data-stage="review"] textarea {
  min-height: 116px;
}

section[data-stage="review"] #reviewLinks,
section[data-stage="review"] #reviewTranscript {
  min-height: 92px;
}

section[data-stage="review"] #reviewDataPaste {
  min-height: 92px;
}

section[data-stage="review"] .metric-preview {
  max-height: 188px;
  overflow-y: auto;
  padding-right: 4px;
}

.field-row {
  display: grid;
  gap: 8px;
  margin-bottom: 13px;
  flex-shrink: 0;
}

.field-row.compact {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-2);
}

label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--line-2);
  border-radius: 10px;
  outline: none;
  color: var(--ink);
  background: var(--surface);
}

input,
select {
  height: 42px;
  padding: 0 12px;
}

select {
  appearance: none;
  padding-right: 34px;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 18px) 17px, calc(100% - 12px) 17px;
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
  font-weight: 800;
}

textarea {
  min-height: 132px;
  padding: 12px;
  resize: vertical;
  line-height: 1.7;
}

.hidden-field {
  display: none;
}

.source-fields-hidden {
  display: none;
}

.source-mode-switch,
.source-method-switch {
  display: grid;
  gap: 6px;
  padding: 4px;
  margin-bottom: 13px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-2);
}

.source-mode-switch {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.source-method-switch {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-bottom: 0;
}

.chanmama-fields {
  gap: 9px;
}

.chanmama-filter-summary,
.chanmama-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chanmama-filter-summary span,
.chanmama-meta span {
  padding: 4px 7px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--muted);
  background: var(--surface-2);
  font-size: 12px;
}

.chanmama-task {
  grid-column: 1 / -1;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.chanmama-task-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.chanmama-task-head b {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.chanmama-task progress {
  width: 100%;
  height: 8px;
  margin-top: 9px;
}

.chanmama-task.failed b {
  color: var(--red);
}

.chanmama-video {
  display: block;
  width: min(100%, 320px);
  max-height: 480px;
  margin: 10px 0;
  background: #111;
  object-fit: contain;
}

.chanmama-browser {
  height: 100%;
  padding: 10px 4px 18px 0;
  overflow-y: auto;
}

#chanmamaWorkspace[hidden],
#miaosiWorkspace[hidden] {
  display: none;
}

.realtime-nav-item {
  position: relative;
  min-width: 0;
}

.step-nav .realtime-nav-main {
  display: flex;
  width: 100%;
  min-width: 0;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.step-nav .realtime-nav-main span {
  display: inline-block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.step-nav .realtime-nav-main .realtime-nav-caret {
  display: inline-flex;
  flex: 0 0 16px;
  width: 16px;
  height: 16px;
  align-items: center;
  justify-content: center;
  overflow: visible;
}

.step-nav .realtime-nav-main .realtime-nav-caret::before {
  width: 6px;
  height: 6px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  content: '';
  transform: translateY(-2px) rotate(45deg);
}

.step-nav .realtime-nav-main[aria-expanded="true"] .realtime-nav-caret::before {
  transform: translateY(2px) rotate(-135deg);
}

.realtime-nav-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 60;
  width: 132px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.16);
}

.realtime-nav-menu[hidden] {
  display: none;
}

.step-nav .realtime-nav-menu button {
  width: 100%;
  min-height: 34px;
  padding: 0 10px;
  border: 0;
  border-radius: 6px;
  color: var(--text);
  background: transparent;
  text-align: left;
}

.step-nav .realtime-nav-menu button:hover,
.step-nav .realtime-nav-menu button.active {
  color: var(--blue);
  background: var(--blue-soft);
}

.chanmama-category-tabs {
  display: flex;
  gap: 10px;
  padding: 4px 0 16px;
  overflow-x: auto;
}

.chanmama-category-tabs button {
  flex: 0 0 auto;
  min-height: 44px;
  padding: 0 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: var(--surface-2);
  font-size: 15px;
  font-weight: 900;
  cursor: pointer;
}

.chanmama-category-tabs button span {
  margin-left: 7px;
  color: var(--muted-2);
  font-size: 11px;
}

.chanmama-category-tabs button.active {
  border-color: var(--blue);
  color: #fff;
  background: var(--blue);
  box-shadow: 0 7px 18px rgba(179, 45, 51, 0.20);
}

.chanmama-category-tabs button.active span {
  color: rgba(255, 255, 255, 0.78);
}

.chanmama-category-tabs .category-del {
  margin-left: 10px;
  padding-left: 10px;
  border-left: 1px solid var(--line);
  color: var(--muted);
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  opacity: 0;
  transition: opacity 120ms ease;
}

.chanmama-category-tabs button:hover .category-del,
.chanmama-category-tabs button:focus-visible .category-del {
  opacity: 1;
}

.chanmama-category-tabs button.active .category-del {
  border-left-color: rgba(255, 255, 255, 0.25);
  color: rgba(255, 255, 255, 0.78);
}

.chanmama-category-tabs button.task-running:not(.active) {
  border-color: rgba(179, 45, 51, 0.55);
  color: var(--blue);
}

.chanmama-category-tabs button.task-failed:not(.active) {
  border-color: rgba(198, 60, 60, 0.45);
  color: var(--red);
}

.empty-category {
  padding: 7px 0;
  color: var(--muted);
  font-size: 13px;
}

.chanmama-collector-panel {
  display: grid;
  grid-template-columns: minmax(360px, 1fr);
  align-items: end;
  gap: 12px;
  padding: 12px 0 14px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.chanmama-collector-panel[hidden] {
  display: none;
}

.chanmama-collector-panel .field-row {
  margin: 0;
}

.chanmama-collector-panel input,
.chanmama-collector-panel select,
.chanmama-search-action button {
  min-height: 42px;
  height: 42px;
}

.chanmama-search-action button {
  white-space: nowrap;
}

.chanmama-search-action {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto;
  align-items: end;
  gap: 8px;
  padding-left: 14px;
  border-left: none;
}

.chanmama-search-action label {
  color: var(--blue);
  font-weight: 900;
}

.chanmama-search-action input {
  border-color: rgba(179, 45, 51, 0.75);
  background: var(--surface);
  box-shadow: 0 0 0 3px rgba(179, 45, 51, 0.08);
}

.chanmama-search-action input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(179, 45, 51, 0.16);
  outline: none;
}

.chanmama-task-strip {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 44px;
  padding: 10px 0;
  color: var(--muted);
  font-size: 12px;
}

.chanmama-task-strip span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.chanmama-task-strip progress {
  flex: 1;
  min-width: 120px;
  height: 7px;
}

.chanmama-task-strip .failed {
  color: var(--red);
}

.chanmama-task-error {
  flex: 1;
  color: var(--red);
  font-weight: 700;
}

.chanmama-task-summary {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 290px;
}

.chanmama-task-summary > div {
  display: grid;
  gap: 3px;
}

.chanmama-task-summary b {
  color: var(--ink);
  font-size: 13px;
}

.chanmama-task-summary small {
  color: var(--muted);
  font-size: 11px;
}

.chanmama-data-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 16px;
  align-items: start;
}

.chanmama-grid-empty {
  grid-column: 1 / -1;
}

.chanmama-grid-card {
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  cursor: pointer;
  transition: border-color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.chanmama-grid-card:hover,
.chanmama-grid-card:focus-visible {
  border-color: var(--blue);
  outline: none;
  box-shadow: 0 10px 26px rgba(20, 31, 52, 0.12);
  transform: translateY(-2px);
}

.chanmama-card-media {
  position: relative;
  aspect-ratio: 4 / 5;
  overflow: hidden;
  background: #111;
}

.chanmama-card-media img,
.chanmama-card-media video {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  pointer-events: none;
  transition: transform 200ms ease;
}

.chanmama-grid-card:hover .chanmama-card-media img,
.chanmama-grid-card:hover .chanmama-card-media video {
  transform: scale(1.025);
}

.chanmama-play-icon {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: rgba(12, 16, 24, 0.72);
  opacity: 0;
  transform: translate(-50%, -50%);
  transition: opacity 160ms ease;
}

.chanmama-play-icon::after {
  position: absolute;
  top: 14px;
  left: 19px;
  width: 0;
  height: 0;
  border-top: 10px solid transparent;
  border-bottom: 10px solid transparent;
  border-left: 15px solid #fff;
  content: '';
}

.chanmama-grid-card:hover .chanmama-play-icon,
.chanmama-grid-card:focus-visible .chanmama-play-icon {
  opacity: 1;
}

.chanmama-run-score {
  position: absolute;
  right: 8px;
  bottom: 8px;
  padding: 5px 7px;
  border-radius: 5px;
  color: #fff;
  background: rgba(16, 20, 28, 0.78);
  font-size: 12px;
}

.chanmama-saved-badge {
  position: absolute;
  top: 8px;
  left: 8px;
  padding: 5px 7px;
  border-radius: 5px;
  color: #fff;
  background: rgba(23, 126, 82, 0.9);
  font-size: 12px;
  font-weight: 800;
}

.chanmama-analysis-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  padding: 5px 7px;
  border-radius: 5px;
  color: #fff;
  background: rgba(179, 45, 51, 0.92);
  font-size: 12px;
  font-weight: 800;
}

.chanmama-analysis-badge.running {
  background: rgba(155, 99, 20, 0.94);
}

.chanmama-analysis-badge.failed {
  background: rgba(170, 47, 47, 0.94);
}

.chanmama-card-body {
  padding: 12px;
}

.chanmama-card-body h3 {
  display: -webkit-box;
  min-height: 42px;
  margin: 0;
  overflow: hidden;
  font-size: 14px;
  line-height: 1.5;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.chanmama-author {
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chanmama-author {
  margin: 8px 0 10px;
}

.chanmama-card-save {
  width: 100%;
  min-height: 34px;
  margin-top: 10px;
  border: 1px solid var(--blue);
  border-radius: 6px;
  color: var(--blue);
  background: transparent;
  font-weight: 800;
  cursor: pointer;
}

.chanmama-card-save:hover {
  color: #fff;
  background: var(--blue);
}

.chanmama-card-save.saved {
  border-color: var(--line);
  color: var(--muted);
  background: var(--surface-2);
  cursor: default;
}

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

.chanmama-primary-metrics.single {
  grid-template-columns: 1fr;
}

.chanmama-primary-metrics div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 7px;
  border-radius: 6px;
  background: var(--surface-2);
}

.chanmama-primary-metrics dt {
  min-width: 0;
  white-space: nowrap;
  color: var(--muted);
  font-size: 10px;
}

.chanmama-primary-metrics dd {
  margin: 0;
  color: var(--ink);
  font-size: 13px;
  font-weight: 900;
  white-space: nowrap;
}

.chanmama-player-overlay {
  position: fixed;
  inset: 0;
  /* Global content modal: above all workbench chrome, below the login overlay. */
  z-index: 9000;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(12, 16, 24, 0.72);
}

.chanmama-player-modal {
  position: relative;
  display: grid;
  grid-template-columns: minmax(320px, 0.82fr) minmax(320px, 1fr);
  width: min(980px, 100%);
  height: min(820px, calc(100vh - 48px));
  max-height: calc(100vh - 48px);
  overflow: hidden;
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.28);
}

.chanmama-player-media {
  display: grid;
  place-items: center;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background: #08090b;
}

.chanmama-player-media video {
  width: 100%;
  height: 100%;
  max-height: 100%;
  object-fit: contain;
}

.chanmama-player-detail {
  min-width: 0;
  min-height: 0;
  padding: 34px 28px 24px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.chanmama-player-detail h2 {
  margin: 14px 0 8px;
  font-size: 19px;
  line-height: 1.5;
}

.chanmama-player-detail > p {
  color: var(--muted);
}

.chanmama-player-detail dl {
  display: grid;
  gap: 1px;
  margin: 22px 0;
  background: var(--line);
}

.chanmama-player-detail dl div {
  display: grid;
  grid-template-columns: 110px 1fr;
  gap: 12px;
  padding: 11px 12px;
  background: var(--surface);
}

.chanmama-player-detail dt {
  color: var(--muted);
}

.chanmama-player-detail dd {
  margin: 0;
  font-weight: 800;
}

.chanmama-player-close {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 2;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 50%;
  color: var(--muted);
  background: var(--surface-2);
  font-size: 22px;
  cursor: pointer;
}

.chanmama-player-actions {
  display: flex;
  flex-wrap: nowrap;
  gap: 8px;
}

.chanmama-player-actions > * {
  flex: 1 1 0;
  min-width: 0;
  text-align: center;
  white-space: nowrap;
}

.chanmama-player-actions a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.chanmama-analysis {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.chanmama-analysis[hidden] {
  display: none;
}

.chanmama-analysis h3 {
  margin: 0 0 14px;
  font-size: 16px;
}

.chanmama-analysis h3 span {
  display: inline-block;
  margin-left: 6px;
  padding: 2px 6px;
  border-radius: 4px;
  color: var(--blue);
  background: var(--surface-2);
  font-size: 11px;
  vertical-align: 2px;
}

.chanmama-analysis > div {
  margin-bottom: 14px;
}

.chanmama-analysis b {
  font-size: 13px;
}

.chanmama-analysis p,
.chanmama-analysis ul,
.chanmama-analysis ol {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.7;
}

.chanmama-analysis ul,
.chanmama-analysis ol {
  padding-left: 20px;
}

.chanmama-structure-list li {
  margin-bottom: 10px;
}

.chanmama-structure-list li > b {
  color: var(--ink);
}

.chanmama-structure-list li > span {
  display: inline-block;
  margin-left: 8px;
  padding: 1px 5px;
  border-radius: 4px;
  color: var(--muted);
  background: var(--surface-2);
  font-size: 11px;
}

.chanmama-structure-list li > p {
  margin-top: 3px;
}

.chanmama-formula {
  padding: 10px 12px;
  border-left: 3px solid var(--blue);
  background: var(--surface-2);
  color: var(--ink) !important;
  font-weight: 700;
}

.chanmama-analysis-loading {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
}

.chanmama-analysis-loading > div {
  display: grid;
  gap: 3px;
}

.chanmama-analysis-loading small {
  color: var(--muted);
  font-size: 12px;
}

.chanmama-analysis-error {
  color: var(--red) !important;
}

.chanmama-save-overlay {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(12, 16, 24, 0.72);
}

.chanmama-save-dialog {
  position: relative;
  width: min(480px, 100%);
  padding: 26px;
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.28);
}

.chanmama-save-dialog h2 {
  margin: 0 38px 6px 0;
  font-size: 19px;
}

.chanmama-save-dialog > p {
  margin: 0 0 20px;
  color: var(--muted);
  font-size: 13px;
}

.chanmama-save-dialog label {
  display: grid;
  gap: 7px;
  margin-top: 14px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.chanmama-save-dialog [hidden] {
  display: none !important;
}

.chanmama-save-dialog select,
.chanmama-save-dialog input {
  width: 100%;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  background: var(--surface);
  padding: 0 10px;
}

.chanmama-save-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 22px;
}

.source-method-switch.two-options {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.source-mode-switch button,
.source-method-switch button {
  min-height: 34px;
  border: 0;
  border-radius: 8px;
  color: var(--muted);
  background: transparent;
  font-weight: 900;
  cursor: pointer;
}

.source-mode-switch button.active,
.source-method-switch button.active {
  color: #fff;
  background: var(--blue);
}

#sourceLinks,
#internalLinks {
  min-height: 112px;
  height: 112px;
}

#sourceTranscript,
#internalTranscript {
  min-height: 86px;
  height: 86px;
}

input[type="file"] {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.file-picker {
  min-height: 46px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  padding: 5px;
  border: 1px solid var(--line-2);
  border-radius: 12px;
  background: var(--surface);
}

.file-picker:focus-within {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px var(--blue-soft);
}

.file-picker-btn {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 14px;
  border-radius: 8px;
  color: #fff;
  background: var(--blue);
  font-size: 13px;
  font-weight: 900;
  cursor: pointer;
  white-space: nowrap;
}

.file-picker span {
  min-width: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-picker.has-file span {
  color: var(--ink);
}

.file-picker.local-upload-dropzone {
  min-height: 124px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 14px 18px;
  border: 2px dashed var(--line-2);
  border-radius: 8px;
  background: var(--surface);
  text-align: center;
  cursor: pointer;
  transition: border-color 160ms ease, background 160ms ease, box-shadow 160ms ease;
}

.file-picker.local-upload-dropzone:hover,
.file-picker.local-upload-dropzone:focus-within,
.file-picker.local-upload-dropzone:focus-visible,
.file-picker.local-upload-dropzone.drag-over {
  border-color: var(--blue);
  outline: none;
  background: var(--blue-soft);
  box-shadow: 0 0 0 3px rgba(179, 45, 51, 0.12);
}

.file-picker.local-upload-dropzone.has-file {
  border-color: var(--green);
  background: var(--green-soft);
  cursor: default;
}

.local-upload-empty,
.local-upload-selected {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.local-upload-selected {
  display: none;
}

.local-upload-dropzone.has-file .local-upload-empty {
  display: none;
}

.local-upload-dropzone.has-file .local-upload-selected {
  display: flex;
}

.local-upload-dropzone strong {
  max-width: 100%;
  color: var(--ink);
  font-size: 16px;
  overflow-wrap: anywhere;
}

.file-picker.local-upload-dropzone .local-upload-subtitle,
.file-picker.local-upload-dropzone .local-upload-selection {
  max-width: 100%;
  padding: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
  white-space: normal;
  overflow-wrap: anywhere;
}

.file-picker.local-upload-dropzone .local-upload-selection {
  color: var(--ink);
  font-weight: 900;
}

.local-upload-dropzone .file-picker-btn {
  width: auto;
  min-height: 34px;
}

.local-upload-cancel {
  min-height: 30px;
  padding: 0 14px;
  border: 1px solid var(--line-2);
  border-radius: 7px;
  color: var(--muted);
  background: var(--surface);
  font-size: 12px;
  font-weight: 900;
  cursor: pointer;
}

.local-upload-cancel:hover {
  color: var(--red);
  border-color: var(--red);
  background: var(--red-soft);
}

.local-source-row small {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px var(--blue-soft);
}

.primary-btn,
.ghost-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  min-height: 40px;
  padding: 0 16px;
  border: 0;
  font-weight: 900;
}

.primary-btn {
  color: #fff;
  background: var(--blue);
}

.primary-btn:disabled,
.ghost-btn:disabled {
  cursor: wait;
  opacity: 0.72;
}

.ghost-btn {
  border: 1px solid var(--line-2);
  color: var(--ink);
  background: var(--surface);
}

.card-list {
  display: grid;
  gap: 10px;
  max-height: 640px;
  overflow: auto;
  padding-right: 4px;
}

.source-queue-head {
  position: sticky;
  top: 0;
  z-index: 2;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 160px;
  align-items: center;
  gap: 14px;
  height: 64px;
  min-height: 64px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: linear-gradient(180deg, #ffffff 0%, #fff8f8 100%);
  box-shadow: 0 10px 24px rgba(39, 41, 92, 0.06);
}

.source-queue-head > div {
  display: inline-flex;
  align-items: center;
  align-self: center;
  justify-content: center;
  gap: 10px;
  justify-self: center;
}

.source-queue-head b {
  display: inline-block;
  line-height: 1.2;
  color: var(--ink);
  font-size: 18px;
  letter-spacing: 0;
}

.source-queue-head span {
  display: inline-block;
  margin-top: 0;
  line-height: 1.2;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.source-queue-toggle {
  align-self: center;
  justify-self: start;
  width: 100%;
  margin-right: 0;
  min-height: 36px;
  padding: 0 18px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 900;
  white-space: nowrap;
}

.source-queue-items {
  display: grid;
  gap: 10px;
  min-width: 0;
}

.source-material-card {
  min-width: 0;
  overflow: hidden;
}

.source-material-card .card-top {
  min-width: 0;
  flex-wrap: wrap;
}

.source-material-card .card-top h3 {
  flex: 1 1 220px;
  min-width: 0;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.source-material-card .card-top-right {
  flex: 0 1 auto;
  min-width: 0;
  max-width: 100%;
}

.source-material-card > p,
.source-material-card > small,
.source-material-card .chanmama-meta span {
  max-width: 100%;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.mini-card,
.version-card {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
}

.card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.card-top h3 {
  font-size: 15px;
  line-height: 1.35;
  min-width: 0;
  word-break: break-word;
  overflow-wrap: break-word;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 9px;
  border-radius: 999px;
  color: var(--blue);
  background: var(--blue-soft);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.pill.ok {
  color: var(--green);
  background: var(--green-soft);
}

.pill.working {
  color: #d49516;
  background: var(--gold-soft);
}

.pill.bad {
  color: var(--red);
  background: var(--red-soft);
}

.pill.muted {
  color: var(--muted);
  background: var(--surface-2);
}

.transcript-correction-pill {
  display: inline-flex;
  align-items: center;
  min-height: 21px;
  padding: 0 7px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 900;
  white-space: nowrap;
}

.transcript-correction-pill.risk-low {
  color: var(--muted);
  background: var(--surface-2);
}

.transcript-correction-pill.risk-medium {
  color: #9a6a00;
  background: var(--gold-soft);
}

.transcript-correction-pill.risk-high {
  color: var(--red);
  background: var(--red-soft);
}

.pipeline-status {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

.pipeline-status div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 48px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
}

.pipeline-status b,
.pipeline-status span {
  display: inline-block;
}

.pipeline-status b {
  font-size: 19px;
}

.pipeline-status span,
.pipeline-status p {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.pipeline-status p {
  grid-column: 1 / -1;
  margin: 0;
  padding: 9px 10px;
  border-radius: 10px;
  background: var(--surface-2);
}

.scope-box {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 130px)) minmax(0, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}

.scope-box div,
.scope-box p {
  margin: 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
}

.scope-box b,
.scope-box span {
  display: block;
}

.scope-box b {
  font-size: 18px;
}

.scope-box span,
.scope-box p {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.ip-library {
  display: grid;
  gap: 8px;
  margin-bottom: 12px;
}

.ip-library button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--ink);
  background: var(--surface);
  text-align: left;
}

.ip-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.ip-row .delete-ip-btn {
  width: auto;
  min-height: 44px;
  padding: 0 12px;
  justify-content: center;
  color: var(--red);
  background: var(--red-soft);
  font-size: 12px;
  font-weight: 900;
}

.ip-library span {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.knowledge-side-panel .ip-library,
.knowledge-side-panel .card-list {
  min-height: 0;
  max-height: none;
  margin-bottom: 0;
  overflow: auto;
}

.knowledge-side-panel .ip-library {
  flex-shrink: 0;
  max-height: 168px;
  padding-right: 4px;
}

.knowledge-side-panel .card-list {
  flex: 1;
}

.mini-card p,
.mini-card small {
  display: block;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.mini-card blockquote {
  margin: 8px 0;
  padding: 10px;
  border-left: 3px solid var(--blue);
  border-radius: 8px;
  color: var(--ink);
  background: #fff8f8;
  font-size: 13px;
  line-height: 1.6;
}

.review-card .card-top-right {
  align-items: center;
  gap: 6px;
}

.review-delete-btn {
  width: 26px;
  height: 26px;
  min-height: 26px;
  border-radius: 8px;
}

.knowledge-layout {
  height: 100%;
  min-height: 0;
  display: block;
  overflow: hidden;
}

.knowledge-elements-panel {
  height: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 10px 14px 12px;
}

.knowledge-elements-panel .panel-head {
  min-height: 0;
  align-items: center;
  margin-bottom: 2px;
}

.kb-source-switch {
  display: inline-flex;
  align-items: center;
  gap: 0;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  white-space: nowrap;
}

.kb-source-switch button {
  min-height: 28px;
  padding: 0 12px;
  border: 0;
  border-radius: 7px;
  color: var(--muted);
  background: transparent;
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
}

.kb-source-switch button.active {
  color: #fff;
  background: var(--blue);
}

.knowledge-elements-panel .panel-head h2 {
  font-size: 18px;
}

.knowledge-elements-panel .panel-head p {
  display: none;
}

.knowledge-searchbar {
  display: grid;
  grid-template-columns: minmax(280px, 1fr) auto;
  gap: 8px;
  margin-bottom: 4px;
  flex-shrink: 0;
  align-items: center;
}

.knowledge-searchbar input {
  min-height: 36px;
  border-color: var(--line-2);
  background: var(--surface);
  font-size: 13px;
  line-height: 36px;
  padding-top: 0;
  padding-bottom: 0;
  display: flex;
  align-items: center;
}

.knowledge-searchbar input::placeholder {
  color: var(--muted);
  font-size: 13px;
}

.knowledge-searchbar span {
  min-height: 36px;
  display: inline-grid;
  place-items: center;
  align-items: center;
  justify-self: end;
  min-width: 238px;
  padding: 0 12px;
  border: 1px solid var(--line-2);
  border-radius: 10px;
  color: var(--ink);
  background: var(--surface);
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}

.knowledge-search-results {
  display: grid;
  gap: 8px;
  margin-bottom: 10px;
  padding: 12px;
  border: 1px solid rgba(179, 45, 51, 0.28);
  border-radius: 11px;
  background: #f8fafc;
}

.knowledge-search-results-head,
.knowledge-search-result {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.knowledge-search-results-head > div {
  display: grid;
  gap: 2px;
}

.knowledge-search-results-head b {
  font-size: 15px;
}

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

.knowledge-search-result-list {
  display: grid;
  gap: 6px;
}

.knowledge-search-result {
  width: 100%;
  min-height: 62px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: var(--surface);
  text-align: left;
  cursor: pointer;
}

.knowledge-search-result:hover {
  border-color: rgba(179, 45, 51, 0.50);
  background: #fff;
}

.knowledge-search-result-main {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.knowledge-search-result-main b,
.knowledge-search-result-main em {
  overflow: hidden;
  text-overflow: ellipsis;
}

.knowledge-search-result-main b {
  font-size: 13px;
  white-space: nowrap;
}

.knowledge-search-result-main em {
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
  line-height: 1.45;
  white-space: normal;
}

.knowledge-search-result-meta {
  flex: 0 0 112px;
  display: grid;
  justify-items: end;
  gap: 3px;
}

.knowledge-search-result-meta small {
  max-width: 112px;
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.knowledge-search-result-meta strong {
  color: var(--blue);
  font-size: 12px;
}

.knowledge-search-no-result {
  padding: 16px 10px;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

.knowledge-coursebar {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 8px;
  margin-bottom: 4px;
  flex-shrink: 0;
}

.knowledge-coursebar > div:first-child {
  min-height: 30px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
}

.knowledge-coursebar span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.knowledge-coursebar b {
  font-size: 14px;
}

.knowledge-coursebar .add-course-btn {
  min-height: 32px;
  white-space: nowrap;
}

.course-profile-state {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  white-space: nowrap;
}

.course-profile-state.failed {
  color: var(--red);
  border-color: var(--red);
}

.course-tabs {
  min-height: 30px;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  overflow-x: auto;
}

.course-tabs button {
  min-height: 26px;
  padding: 0 12px;
  border: 0;
  border-radius: 8px;
  color: var(--muted);
  background: transparent;
  font-size: 13px;
  font-weight: 900;
  white-space: nowrap;
}

.course-tabs button.active {
  color: #fff;
  background: var(--blue);
}

.knowledge-workbench {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 10px;
  overflow: hidden;
}

.knowledge-tree-panel,
.element-cloud-panel {
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  overflow: hidden;
}

.knowledge-tree-panel {
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
}

.workbench-pane-head {
  min-height: 36px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 0 4px 0 2px;
  flex-shrink: 0;
}

.workbench-pane-head div {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.workbench-pane-head b {
  font-size: 15px;
  line-height: 1.25;
}

.workbench-pane-head span {
  display: none;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.workbench-pane-head em {
  flex: 0 0 auto;
  min-height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 9px;
  border-radius: 999px;
  color: var(--blue);
  background: var(--blue-soft);
  font-size: 11px;
  font-style: normal;
  font-weight: 900;
  white-space: nowrap;
}

.material-tree {
  flex: 1;
  min-height: 0;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--surface);
  overflow: auto;
}

.material-tree.hit-table-mode {
  flex: 1 1 auto;
  min-height: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  overflow: auto;
}

.hit-empty-state {
  display: grid;
  gap: 8px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
}

.hit-empty-state b {
  font-size: 16px;
}

.hit-empty-state p {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.compact-hit-empty {
  margin-top: 10px;
}

.pending-hit-group {
  margin-top: 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  overflow: hidden;
}

.pending-hit-group summary {
  min-height: 40px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 12px;
  cursor: pointer;
  list-style: none;
  background: var(--surface);
}

.pending-hit-group summary::-webkit-details-marker {
  display: none;
}

.pending-hit-group summary strong {
  color: var(--ink);
  font-size: 13px;
}

.pending-hit-group summary span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.pending-hit-group[open] summary span {
  color: var(--blue);
}

.pending-hit-group .hit-table {
  margin-top: 0;
  border-width: 1px 0 0;
  border-radius: 0;
}

.pending-audit-panel {
  margin-top: 10px;
}

.pending-audit-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 9px 10px;
  border-top: 1px solid var(--line);
  background: #fbfcff;
}

.pending-audit-tools button {
  min-height: 28px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 0 10px;
  border: 1px solid rgba(179, 45, 51, 0.18);
  border-radius: 8px;
  color: var(--muted);
  background: #fff;
  font-size: 12px;
  font-weight: 900;
  cursor: pointer;
}

.pending-audit-tools button.active {
  color: var(--blue);
  border-color: rgba(179, 45, 51, 0.34);
  background: var(--blue-soft);
}

.pending-audit-tools strong {
  color: inherit;
  font-size: 11px;
}

.knowledge-next-step {
  min-height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 10px;
  padding: 12px 14px;
  border: 1px solid rgba(179, 45, 51, 0.18);
  border-radius: 12px;
  color: var(--blue);
  background: linear-gradient(180deg, #f8fafc 0%, #f2f5f8 100%);
}

.knowledge-next-step b {
  display: block;
  color: var(--ink);
  font-size: 13px;
}

.knowledge-next-step span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.knowledge-next-step button {
  flex-shrink: 0;
  min-height: 34px;
  padding: 0 16px;
  border: 0;
  border-radius: 10px;
  color: #fff;
  background: var(--blue);
  font-size: 13px;
  font-weight: 900;
  cursor: pointer;
  white-space: nowrap;
}

.overview-next-step {
  margin-top: 10px;
}

.hit-stat-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
}

.hit-stat-grid span {
  min-height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: var(--surface);
  font-size: 11px;
  font-weight: 900;
}

.hit-stat-grid em {
  flex: 0 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-style: normal;
}

.hit-stat-grid strong {
  color: var(--ink);
  font-size: 15px;
  white-space: nowrap;
}

.pending-overview {
  display: grid;
  gap: 7px;
  padding-top: 2px;
}

.pending-overview-head,
.pending-overview-list button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.pending-overview-head {
  min-height: 30px;
  cursor: pointer;
  list-style: none;
}

.pending-overview-head::-webkit-details-marker {
  display: none;
}

.pending-overview-head b {
  color: var(--ink);
  font-size: 13px;
}

.pending-overview-head span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.pending-overview[open] .pending-overview-head span {
  color: var(--blue);
}

.pending-overview-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.pending-overview-list button {
  min-height: 30px;
  padding: 0 9px;
  border: 1px solid rgba(179, 45, 51, 0.18);
  border-radius: 8px;
  color: var(--blue);
  background: var(--blue-soft);
  font-size: 12px;
  font-weight: 900;
  cursor: pointer;
}

.pending-overview-list button span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--blue);
}

.pending-overview-list button strong {
  flex-shrink: 0;
}

.course-material-list {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.course-material-list article {
  display: grid;
  gap: 5px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
}

.course-material-list b {
  font-size: 13px;
  line-height: 1.4;
}

.course-material-list span {
  color: var(--muted);
  font-size: 12px;
}

.hit-table-head {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
}

.hit-table-head b,
.hit-table-head span {
  display: block;
}

.hit-table-head b {
  font-size: 15px;
}

.hit-table-head span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.hit-table {
  margin-top: 10px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
}

.hit-table table {
  width: 100%;
  min-width: 0;
  border-collapse: collapse;
  font-size: 12px;
  line-height: 1.55;
  table-layout: fixed;
}

.hit-table th,
.hit-table td {
  padding: 8px 7px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  overflow-wrap: anywhere;
}

.hit-table .col-text {
  width: 44%;
  vertical-align: middle;
}

.hit-table .col-text b {
  display: block;
  color: var(--ink);
  font-size: 13px;
  font-weight: 650;
  line-height: 1.5;
}

.hit-table .col-count {
  width: 52px;
  text-align: center;
  vertical-align: middle;
}

.hit-table .col-source {
  width: 31%;
  vertical-align: middle;
}

.hit-table .col-source b {
  display: block;
  font-size: 13px;
  white-space: normal;
  overflow-wrap: anywhere;
}

.hit-table .col-source small {
  display: block;
  margin-top: 2px;
  font-size: 11px;
  white-space: normal;
  overflow-wrap: anywhere;
}

.source-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 8px;
}

.hit-table .col-source .source-expand summary {
  display: block;
  min-height: 0;
  font-size: 11px;
}

.hit-table .col-owner {
  width: 64px;
  text-align: center;
  vertical-align: middle;
}

.hit-table th {
  color: var(--ink);
  background: var(--blue-soft);
  font-weight: 900;
  text-align: center;
  white-space: nowrap;
}

.hit-table td.col-text,
.hit-table td.col-source {
  text-align: left;
}

.hit-table td.col-count,
.hit-table td.col-owner {
  text-align: center;
}

.hit-table td:first-child {
  color: var(--ink);
}

.hit-table td {
  color: var(--muted);
}

.hit-table small {
  color: var(--faint);
}

.source-expand {
  margin: 0;
  contain: layout paint;
}

.source-expand-body {
  contain: layout paint;
}

.source-expand-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 10px;
  margin-top: 8px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.45;
}

.source-expand summary {
  min-height: 28px;
  display: flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  list-style: none;
  font-size: 12px;
  font-weight: 900;
  color: var(--blue);
}

.source-expand summary::-webkit-details-marker {
  display: none;
}

.source-link-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
}

.source-link-row code {
  flex: 1;
  min-width: 0;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--muted);
  background: var(--surface-2);
  font-size: 11px;
  font-family: inherit;
  word-break: break-all;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.copy-link-btn {
  flex-shrink: 0;
  min-height: 26px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--blue);
  background: var(--blue-soft);
  font-size: 11px;
  font-weight: 900;
  cursor: pointer;
}

.source-expand pre {
  max-height: 180px;
  overflow: auto;
  margin-top: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: var(--surface-2);
  font: inherit;
  font-size: 12px;
  line-height: 1.7;
  white-space: pre-wrap;
}

.tree-node {
  margin-bottom: 6px;
}

.tree-node summary {
  list-style: none;
}

.tree-node summary::-webkit-details-marker {
  display: none;
}

.tree-children {
  margin-left: 10px;
  padding-left: 9px;
  border-left: 1px solid var(--line);
}

.tree-scope-btn,
.sentence-row {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 32px;
  padding: 7px 8px;
  border: 0;
  border-radius: 8px;
  color: var(--ink);
  background: transparent;
  text-align: left;
}

.tree-scope-btn:hover,
.sentence-row:hover {
  background: var(--surface);
}

.tree-scope-btn.active {
  color: var(--blue);
  background: var(--blue-soft);
  font-weight: 900;
  box-shadow: inset 3px 0 0 var(--blue);
}

.tree-scope-btn span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tree-scope-btn em {
  min-width: 22px;
  height: 20px;
  display: grid;
  place-items: center;
  padding: 0 6px;
  border-radius: 999px;
  color: var(--muted);
  background: var(--surface-2);
  font-size: 11px;
  font-style: normal;
}

.tree-scope-btn.benchmark span {
  color: var(--green);
}

.tree-scope-btn.material {
  min-height: 40px;
  align-items: flex-start;
  background: var(--surface);
}

.tree-sentences {
  display: grid;
  gap: 5px;
  margin: 4px 0 8px 12px;
}

.sentence-row {
  align-items: flex-start;
  justify-content: flex-start;
  font-size: 12px;
  line-height: 1.55;
}

.sentence-row b {
  flex: 0 0 auto;
  min-width: 22px;
  color: var(--faint);
  font-size: 11px;
}

.sentence-row span {
  min-width: 0;
}

.sentence-row.highlight {
  color: var(--ink);
  background: var(--gold-soft);
  box-shadow: inset 3px 0 0 var(--gold);
}

.tree-empty {
  padding: 9px;
  color: var(--faint);
  font-size: 12px;
}

.cloud-scope-bar {
  min-height: 42px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--surface);
  flex-shrink: 0;
}

.cloud-scope-bar b,
.cloud-scope-bar span {
  display: block;
}

.cloud-scope-bar b {
  font-size: 14px;
}

.cloud-scope-bar span,
.cloud-scope-bar p {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.cloud-scope-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.cloud-element-search {
  width: min(220px, 24vw);
  min-width: 150px;
  height: 32px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 6px;
  padding: 0 7px 0 10px;
  border: 1px solid var(--line-2);
  border-radius: 8px;
  background: var(--surface);
}

.cloud-element-search:focus-within {
  border-color: rgba(179, 45, 51, 0.42);
  box-shadow: 0 0 0 2px rgba(179, 45, 51, 0.08);
}

.cloud-element-search input {
  min-width: 0;
  height: 30px;
  padding: 0;
  border: 0;
  outline: 0;
  background: transparent;
  font-size: 12px;
}

.cloud-element-search small {
  color: var(--muted);
  font-size: 10px;
  white-space: nowrap;
}

.cloud-element-search button {
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 5px;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
}

.cloud-element-search button:hover {
  color: var(--ink);
  background: var(--surface-2);
}

.cloud-scope-actions .ghost-btn {
  min-height: 30px;
  padding: 0 10px;
  border-radius: 8px;
  color: var(--blue);
  font-size: 12px;
}

.cloud-scope-actions .danger-btn {
  border-color: rgba(212, 80, 76, 0.24);
  color: var(--red);
  background: var(--red-soft);
}

.element-cloud {
  flex: 1;
  min-height: 240px;
  margin-top: 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #f7f8fb;
  overflow: auto;
  position: relative;
}

.element-directory {
  min-height: 100%;
  display: grid;
  align-content: start;
  gap: 10px;
  padding: 10px;
}

.element-directory-group {
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04);
}

.element-directory-group header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.element-directory-group header div {
  min-width: 0;
}

.element-directory-group header b,
.element-directory-group header span {
  display: block;
}

.element-directory-group header b {
  color: var(--blue);
  font-size: 13px;
  line-height: 1.3;
}

.element-directory-group header span {
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
}

.element-directory-group header em {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 11px;
  font-style: normal;
  font-weight: 800;
}

.element-directory-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 7px;
}

.element-directory-item {
  min-height: 42px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  padding: 7px 9px;
  border: 1px solid var(--line-2);
  border-radius: 8px;
  color: var(--ink);
  background: var(--surface);
  font-size: 12px;
  font-weight: 900;
  line-height: 1.35;
  text-align: left;
  cursor: pointer;
  transition: border-color 160ms ease, background 160ms ease, box-shadow 160ms ease;
}

.element-directory-item span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.element-directory-item em {
  color: var(--muted);
  font-size: 11px;
  font-style: normal;
  font-weight: 800;
  white-space: nowrap;
}

.element-directory-item:hover {
  border-color: rgba(179, 45, 51, 0.28);
  background: #fbfbff;
}

.element-directory-item.active {
  border-color: rgba(179, 45, 51, 0.52);
  background: var(--blue-soft);
  box-shadow: inset 3px 0 0 var(--blue);
}

.element-directory-item.placeholder {
  color: var(--muted);
  background: #fafafa;
}

.element-directory-item.placeholder em {
  color: var(--faint);
}

.element-directory-empty {
  padding: 22px 12px;
  border: 1px dashed var(--line-2);
  border-radius: 11px;
  color: var(--muted);
  background: var(--surface);
  font-size: 13px;
  text-align: center;
}

.element-detail {
  flex-shrink: 0;
  margin-top: 0;
}

.element-detail article,
.element-detail .empty {
  min-height: 78px;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--surface);
}

.element-detail p {
  color: var(--ink);
  font-size: 13px;
  line-height: 1.6;
}

.element-detail small {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.knowledge-topbar {
  display: grid;
  gap: 10px;
  margin-bottom: 12px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  flex-shrink: 0;
}

.kb-path {
  min-height: 30px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.3;
}

.kb-path b {
  color: var(--ink);
  font-size: 14px;
}

.kb-filter-row {
  display: grid;
  grid-template-columns: minmax(150px, 0.7fr) minmax(240px, 1.2fr) minmax(260px, 1.3fr);
  gap: 10px;
}

.kb-filter {
  min-width: 0;
  display: grid;
  gap: 6px;
}

.kb-filter > span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.kb-segment {
  min-height: 42px;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  overflow-x: auto;
}

.kb-segment button {
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 0 12px;
  border: 0;
  border-radius: 8px;
  color: var(--muted);
  background: transparent;
  font-size: 13px;
  font-weight: 900;
  white-space: nowrap;
}

.kb-segment button.active {
  color: var(--blue);
  background: var(--surface);
  box-shadow: 0 0 0 1px var(--blue-soft);
}

.kb-segment em {
  min-width: 22px;
  height: 20px;
  display: grid;
  place-items: center;
  padding: 0 6px;
  border-radius: 999px;
  color: var(--muted);
  background: var(--surface-2);
  font-size: 11px;
  font-style: normal;
}

.kb-segment button.active em {
  color: var(--blue);
  background: var(--blue-soft);
}

.knowledge-main {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(280px, 320px) minmax(0, 1fr);
  gap: 12px;
  overflow: hidden;
}

.knowledge-side-panel {
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow: hidden;
}

.knowledge-source-summary {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
}

.knowledge-source-summary div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.knowledge-source-summary b {
  font-size: 14px;
}

.knowledge-source-summary span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}

.knowledge-source-summary p {
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}

.internal-entry {
  flex-shrink: 0;
}

.course-kb-shell {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 190px minmax(0, 1fr);
  gap: 12px;
}

.course-nav {
  min-height: 0;
  overflow: auto;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
}

.course-nav-ip h3 {
  margin-bottom: 10px;
  font-size: 15px;
}

.course-nav-ip div {
  display: grid;
  gap: 8px;
}

.course-nav button {
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--ink);
  background: var(--surface);
  font-size: 13px;
  font-weight: 900;
}

.course-nav button.active {
  border-color: var(--blue);
  color: var(--blue);
  background: var(--blue-soft);
}

.course-nav button b {
  min-width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  color: var(--muted);
  background: var(--surface);
  font-size: 11px;
}

.knowledge-element-grid {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  overflow: auto;
  padding-right: 4px;
}

.element-column,
.element-group-panel {
  min-width: 0;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  overflow: hidden;
}

.element-column-head,
.element-group-head {
  min-height: 44px;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
}

.element-column-head h3,
.element-group-head h3 {
  font-size: 14px;
}

.element-column-head span,
.element-group-head span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}

.element-type-list {
  min-height: 0;
  display: grid;
  align-content: start;
  gap: 8px;
  padding: 10px;
  overflow: auto;
}

.element-type-card,
.element-subtype-card {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  overflow: hidden;
}

.element-type-card summary,
.element-subtype-card summary {
  min-height: 40px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 0 10px;
  cursor: pointer;
  list-style: none;
  font-size: 13px;
  font-weight: 900;
}

.element-subtype-card {
  margin-bottom: 8px;
  background: var(--surface);
}

.element-subtype-card summary {
  min-height: 36px;
  font-size: 12px;
}

.element-type-card em,
.element-subtype-card em {
  color: var(--muted);
  font-size: 11px;
  font-style: normal;
  white-space: nowrap;
}

.element-type-body {
  padding: 0 8px 8px;
}

.category-tools {
  display: flex;
  gap: 6px;
  padding: 0 8px 8px;
  opacity: 0.72;
}

.category-tools button,
.mini-action {
  min-height: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: var(--surface);
  font-size: 12px;
  font-weight: 900;
}

.mini-action {
  width: 100%;
  margin-top: 8px;
  color: var(--faint);
  background: var(--surface);
}

.group-add {
  width: calc(100% - 20px);
  margin: auto 10px 10px;
}

.element-column-body {
  min-height: 0;
  display: grid;
  align-content: start;
  gap: 8px;
  padding: 10px;
  overflow: auto;
}

.element-chip {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
}

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

.element-chip b {
  font-size: 13px;
  line-height: 1.35;
}

.element-chip span {
  color: var(--blue);
  font-size: 11px;
  font-weight: 900;
  white-space: nowrap;
}

.element-chip p {
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.element-empty {
  min-height: 72px;
  display: grid;
  place-items: center;
  border: 1px dashed var(--line-2);
  border-radius: 10px;
  color: var(--faint);
  background: var(--surface);
  font-size: 12px;
}

.pending-library {
  margin-top: 0;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--surface);
  overflow: hidden;
  flex-shrink: 0;
}

.pending-library summary {
  min-height: 38px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  cursor: pointer;
  list-style: none;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.pending-library em {
  color: var(--muted);
  font-style: normal;
  font-size: 12px;
}

.pending-element-list {
  max-height: 240px;
  display: grid;
  gap: 8px;
  padding: 10px;
  overflow: auto;
  border-top: 1px solid var(--line);
}

.pending-element-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(300px, 42%);
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
}

.pending-element-card b {
  font-size: 13px;
}

.pending-element-card p {
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.pending-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 72px;
  gap: 6px;
  align-items: center;
}

.pending-actions select,
.pending-actions button {
  min-height: 36px;
}

.kb-fold {
  padding: 0;
  overflow: hidden;
}

.kb-fold summary {
  min-height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  cursor: pointer;
  list-style: none;
}

.kb-fold summary::-webkit-details-marker {
  display: none;
}

.kb-fold summary span {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.kb-fold summary b {
  font-size: 15px;
}

.kb-fold summary small {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.kb-fold summary em {
  min-width: 48px;
  min-height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line-2);
  border-radius: 999px;
  color: var(--ink);
  background: var(--surface);
  font-size: 12px;
  font-style: normal;
  font-weight: 900;
}

.kb-fold[open] summary {
  border-bottom: 1px solid var(--line);
  margin-bottom: 12px;
}

.kb-fold[open] summary em {
  color: var(--blue);
  background: var(--blue-soft);
}

.kb-fold[open] summary em::before {
  content: "收起";
}

.kb-fold[open] summary em {
  font-size: 0;
}

.kb-fold[open] summary em::before {
  font-size: 12px;
}

.kb-fold > .field-row,
.kb-fold > .ip-library,
.kb-fold > .card-list {
  margin-left: 16px;
  margin-right: 16px;
}

.compact-list {
  max-height: 220px;
  margin-bottom: 16px;
}

.transcript-details {
  margin-top: 10px;
}

.transcript-details summary {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 9px;
  border-radius: 8px;
  color: var(--blue);
  background: rgba(179, 45, 51, 0.045);
  font-size: 12px;
  font-weight: 900;
  cursor: pointer;
  flex-wrap: wrap;
}

.transcript-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
  max-width: 100%;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.transcript-details summary .copy-btn {
  flex-shrink: 0;
}

.transcript-details pre {
  max-height: 220px;
  overflow: auto;
  margin: 10px 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: anywhere;
  color: var(--ink);
  background: var(--surface-2);
  font: inherit;
  font-size: 13px;
  line-height: 1.7;
}

.pending-audit-bulk-actions {
  display: flex;
  justify-content: flex-end;
  margin: 8px 0;
}

.pending-audit-bulk-actions .danger-btn {
  min-height: 32px;
  padding: 0 12px;
  border: 1px solid rgba(201, 58, 58, 0.26);
  border-radius: 7px;
  color: var(--red);
  background: var(--red-soft);
  font-size: 12px;
  font-weight: 900;
  cursor: pointer;
}

.pending-audit-bulk-actions .danger-btn:hover {
  border-color: var(--red);
}

.pending-audit-bulk-actions .danger-btn:disabled {
  cursor: wait;
  opacity: 0.65;
}

@media (max-width: 640px) {
  .source-material-card .card-top-right,
  .transcript-actions {
    width: 100%;
    justify-content: flex-start;
    margin-left: 0;
  }
}

.copy-btn {
  min-height: 32px;
  padding: 0 10px;
  font-size: 12px;
}

.material-transcript-modal {
  max-width: min(760px, calc(100vw - 32px));
}

.material-transcript-full {
  max-height: min(62vh, 620px);
  overflow: auto;
  margin: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--ink);
  background: var(--surface-2);
  white-space: pre-wrap;
  font: inherit;
  font-size: 14px;
  line-height: 1.8;
}

.mini-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 10px;
}

.mini-actions button,
.version-card button {
  border: 0;
  border-radius: 8px;
  padding: 7px 10px;
  color: var(--blue);
  background: var(--blue-soft);
  font-size: 12px;
  font-weight: 900;
}

.chat-log {
  min-height: 430px;
  max-height: 560px;
  overflow: auto;
  display: grid;
  align-content: start;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-2);
}

.chat-msg {
  position: relative;
  max-width: 92%;
  padding: 12px;
  border-radius: 12px;
  background: var(--surface);
  color: var(--ink);
  line-height: 1.7;
  font-size: 13px;
}

.chat-msg.assistant {
  padding-right: 58px;
}

.chat-collapse-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  min-height: 26px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--blue);
  background: var(--blue-soft);
  font-size: 12px;
  font-weight: 900;
  cursor: pointer;
}

.chat-collapsed-summary {
  display: grid;
  gap: 4px;
  padding: 4px 0;
}

.chat-collapsed-summary b {
  display: block;
  color: var(--ink);
  font-size: 13px;
}

.chat-collapsed-summary span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-msg.user {
  max-width: 86%;
  width: fit-content;
  justify-self: end;
  align-self: flex-end;
  padding: 8px 12px;
  color: var(--ink);
  border: 1px solid rgba(255, 255, 255, 0.90);
  background: rgba(255, 255, 255, 0.70);
  line-height: 1.55;
}

.chat-msg.pending {
  opacity: 0.78;
}

.chat-msg.pending.assistant {
  position: relative;
  padding-left: 34px;
}

.chat-msg.pending.assistant::before {
  content: "";
  position: absolute;
  left: 14px;
  top: 22px;
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--blue);
  box-shadow: 12px 0 0 rgba(179, 45, 51, 0.45), 24px 0 0 rgba(179, 45, 51, 0.22);
  animation: typingPulse 1s infinite ease-in-out;
}

@keyframes typingPulse {
  0%, 100% {
    opacity: 0.35;
  }
  50% {
    opacity: 1;
  }
}

.chat-msg strong {
  display: none;
}

.chat-source-meta {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: 100%;
  margin: 0 0 10px;
  padding: 5px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  line-height: 1.35;
}

.chat-source-meta em {
  color: var(--muted);
  font-style: normal;
  font-weight: 800;
}

.legacy-summary-notice {
  margin: 10px 0;
  padding: 10px 12px;
  border: 1px solid var(--line-2);
  border-radius: 10px;
  background: var(--surface-2);
  color: #d49516;
  font-size: 12px;
  font-weight: 800;
  line-height: 1.6;
}

.chat-msg p {
  margin: 0 0 10px;
}

.chat-msg p:last-child {
  margin-bottom: 0;
}

.chat-table-wrap {
  width: 100%;
  margin: 10px 0;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
}

.chat-table {
  width: 100%;
  min-width: 0;
  table-layout: fixed;
  border-collapse: collapse;
  font-size: 12px;
  line-height: 1.55;
}

.chat-table th,
.chat-table td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--line);
  border-right: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.chat-table th:last-child,
.chat-table td:last-child {
  border-right: 0;
}

.chat-table tr:last-child td {
  border-bottom: 0;
}

.chat-table th {
  color: var(--ink);
  background: var(--blue-soft);
  font-weight: 900;
  white-space: nowrap;
}

.chat-msg.user .chat-table-wrap {
  color: var(--ink);
}

.chat-review-head,
.chat-review-cell {
  width: 108px;
  min-width: 108px;
}

.chat-review-cell {
  vertical-align: middle;
}

.chat-table .chat-col-index {
  width: 56px;
  text-align: center;
  white-space: nowrap;
}

.chat-table .chat-col-type {
  width: 88px;
}

.chat-table .chat-col-count {
  width: 88px;
  white-space: nowrap;
}

.chat-table .chat-col-original {
  width: 64%;
}

.chat-table .chat-col-project {
  width: auto;
}

.chat-table .chat-col-insight {
  width: 28%;
}

.chat-actions,
.chat-review-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.chat-actions {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.chat-review-btn {
  min-height: 28px;
  padding: 0 9px;
  border: 0;
  border-radius: 7px;
  font-size: 12px;
  font-weight: 900;
  cursor: pointer;
}

.chat-review-btn.save {
  color: #fff;
  background: var(--blue);
}

.chat-review-btn.discard {
  color: var(--red);
  background: var(--red-soft);
}

.chat-review-status {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}

.chat-review-status.saved {
  color: var(--green);
  background: var(--green-soft);
}

.chat-review-status.discarded {
  color: var(--red);
  background: var(--red-soft);
}

.chat-review-status.muted {
  color: var(--muted);
  background: var(--surface-2);
}

.chat-box {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 96px;
  gap: 10px;
  margin-top: 12px;
}

.chat-box textarea {
  min-height: 72px;
}

.hint-box {
  margin-top: 14px;
  padding: 12px;
  border-radius: 10px;
  color: #d49516;
  background: var(--gold-soft);
  font-size: 13px;
  line-height: 1.6;
}

.rewrite-title-line {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 26px;
}

.rewrite-title-line span {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding-left: 12px;
  border-left: 1px solid var(--line-2);
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
}

.rewrite-mode-switch {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  padding: 4px;
  margin-bottom: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-2);
}

.rewrite-mode-switch button {
  min-height: 34px;
  border: 0;
  border-radius: 8px;
  color: var(--muted);
  background: transparent;
  font-weight: 900;
}

.rewrite-mode-switch button.active {
  color: #fff;
  background: var(--blue);
}

.rewrite-builder {
  display: grid;
  gap: 10px;
  min-height: 0;
  margin-bottom: 13px;
  align-content: start;
}

.rewrite-action-row {
  display: flex;
  flex-direction: row-reverse;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.rewrite-action-tools {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.rewrite-inline-status {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  min-width: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
}

.rewrite-inline-status .ghost-btn {
  min-height: 30px;
  padding: 0 10px;
  font-size: 12px;
}

.rewrite-inline-status:empty {
  display: none;
}

.rewrite-source-panel {
  display: grid;
  gap: 6px;
  margin-bottom: 12px;
}

.rewrite-source-panel label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
}

.rewrite-source-panel textarea {
  min-height: 122px;
}

.rewrite-profile-source {
  display: grid;
  gap: 10px;
  margin-bottom: 12px;
}

.rewrite-profile-source-controls {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 140px;
  gap: 8px;
}

.rewrite-profile-source-controls > input,
.rewrite-profile-source-controls > .primary-btn {
  width: 100%;
  min-width: 0;
  min-height: 50px;
}

.rewrite-profile-progress {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 4px 10px;
  overflow: hidden;
  padding: 11px 12px 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 12px;
}

.rewrite-profile-progress[hidden] { display: none; }
.rewrite-profile-progress strong { min-width: 0; color: var(--ink); font-size: 13px; }
.rewrite-profile-progress span { min-width: 0; text-align: right; }
.rewrite-profile-progress.ready { border-color: color-mix(in srgb, var(--green) 35%, var(--line)); }
.rewrite-profile-progress.failed { border-color: color-mix(in srgb, var(--red) 35%, var(--line)); }
.rewrite-profile-progress > i {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--blue) var(--profile-progress), transparent var(--profile-progress));
}

.rewrite-profile-steps {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
}

.rewrite-profile-steps span {
  min-width: 0;
  padding: 8px 4px;
  border-radius: 10px;
  color: var(--muted);
  background: var(--surface-2);
  font-size: 11px;
  font-weight: 800;
  text-align: center;
}

#xiaohongshuLoginActions {
  grid-template-columns: minmax(0, 1fr);
}

#xiaohongshuLoginActions .secondary-btn {
  width: 100%;
}

.rewrite-course-picker {
  display: grid;
  grid-template-columns: 86px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  margin-bottom: 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-2);
}

.rewrite-course-picker label {
  justify-self: center;
  color: var(--ink);
  font-size: 15px;
  font-weight: 900;
  text-align: center;
}

.rewrite-course-picker select {
  min-height: 42px;
  border-color: rgba(179, 45, 51, 0.18);
  background: rgba(255, 255, 255, 0.82);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.92);
}

.rewrite-course-control {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  min-width: 0;
}

.rewrite-course-control .ghost-btn {
  min-width: 64px;
  padding-inline: 14px;
}

.rewrite-framework-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  max-height: 296px;
  overflow: auto;
  padding-right: 2px;
}

.rewrite-framework-card {
  min-height: 92px;
  display: grid;
  align-content: start;
  gap: 4px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--ink);
  background: var(--surface);
  text-align: left;
}

.rewrite-framework-card.active {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px var(--blue-soft);
}

.rewrite-framework-card span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.rewrite-framework-card b {
  font-size: 14px;
}

.rewrite-framework-card small {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.rewrite-flow {
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-2);
}

.rewrite-flow-head {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.rewrite-flow-head div {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.rewrite-flow-head b {
  color: var(--ink);
}

.rewrite-flow-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  min-height: 50px;
  border-radius: 10px;
}

.rewrite-flow-list.drag-over {
  outline: 2px dashed var(--blue);
  outline-offset: 3px;
}

.rewrite-flow-item {
  min-height: 58px;
  display: grid;
  grid-template-columns: 26px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  padding: 7px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  cursor: grab;
}

.rewrite-flow-item.dragging,
.rewrite-block.dragging {
  opacity: 0.45;
}

.rewrite-flow-item strong {
  width: 26px;
  height: 26px;
  display: inline-grid;
  place-items: center;
  border-radius: 999px;
  color: #fff;
  background: var(--blue);
  font-size: 12px;
}

.rewrite-flow-main {
  min-width: 0;
  display: grid;
  gap: 5px;
}

.rewrite-flow-item span {
  color: var(--ink);
  font-size: 13px;
  font-weight: 900;
}

.rewrite-flow-count {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.rewrite-flow-evidence-list {
  display: grid;
  gap: 5px;
  max-height: 132px;
  overflow-y: auto;
}

.rewrite-flow-evidence-list p {
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--muted);
  background: var(--surface-2);
  font-size: 12px;
  line-height: 1.45;
}

.rewrite-flow-item select {
  width: 100%;
  min-height: 30px;
  padding: 0 28px 0 9px;
  border: 1px solid var(--line-2);
  border-radius: 8px;
  color: var(--ink);
  background-color: #fff;
  font-size: 12px;
  font-weight: 800;
}

.rewrite-flow-item button {
  min-height: 26px;
  padding: 0 7px;
  border: 0;
  border-radius: 7px;
  color: var(--blue);
  background: var(--blue-soft);
  font-size: 12px;
  font-weight: 900;
}

.rewrite-flow-item button.active {
  color: #fff;
  background: var(--blue);
}

.rewrite-flow-item button:disabled {
  color: var(--faint);
  background: var(--surface-2);
  cursor: default;
}

.rewrite-flow-empty {
  width: 100%;
  padding: 10px;
  border: 1px dashed var(--line-2);
  border-radius: 10px;
  color: var(--muted);
  background: var(--surface);
  font-size: 12px;
  font-weight: 800;
}

.rewrite-palette-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.rewrite-palette-head b {
  color: var(--ink);
}

.rewrite-block-palette {
  width: 100%;
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(9, minmax(0, 1fr));
  gap: 8px;
  max-height: none;
  overflow: visible;
  align-content: center;
  margin: 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.46);
  box-sizing: border-box;
}

.rewrite-block {
  min-height: 64px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--muted);
  background: var(--surface);
  text-align: left;
  cursor: grab;
}

.rewrite-block-main {
  min-width: 0;
  display: grid;
  gap: 4px;
  padding: 2px;
  border: 0;
  color: inherit;
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.rewrite-block b {
  color: var(--ink);
  font-size: 14px;
}

.fission-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.fission-head div {
  display: grid;
  gap: 4px;
}

.fission-head b {
  color: var(--ink);
  font-size: 14px;
}

.fission-head em {
  font-style: normal;
  white-space: nowrap;
}

.fission-head-actions {
  display: flex !important;
  align-items: center;
  justify-content: flex-end;
  gap: 8px !important;
}

.fission-upload-mini {
  position: relative;
}

.fission-upload-mini summary {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  padding: 0 14px;
  border: 1px solid var(--line-2);
  border-radius: 10px;
  color: var(--blue);
  background: var(--surface);
  font-size: 13px;
  font-weight: 950;
  list-style: none;
  cursor: pointer;
}

.fission-upload-mini summary::-webkit-details-marker {
  display: none;
}

.fission-upload-mini[open] {
  z-index: 20;
}

.fission-upload-popover {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 2;
  width: 286px;
  max-width: calc(100vw - 32px);
  box-sizing: border-box;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: 0 14px 36px rgba(20, 27, 55, 0.14);
}

.fission-upload-mini input {
  display: block;
  width: 100%;
  min-height: 32px;
  font-size: 12px;
}

.fission-upload-mini textarea {
  display: block;
  width: 100%;
  min-height: 106px;
  margin-top: 6px;
  font-size: 12px;
}

.fission-upload-mini button {
  width: 100%;
  min-height: 30px;
  margin-top: 6px;
  border: 0;
  border-radius: 8px;
  color: #fff;
  background: var(--blue);
  font-size: 12px;
  font-weight: 950;
}

.fission-upload-mini p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
}

.fission-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  min-height: 230px;
}

.fission-column {
  min-width: 0;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  gap: 6px;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-2);
}

.fission-column-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.fission-column-head b {
  color: var(--ink);
  font-size: 13px;
}

.fission-column-head span {
  min-width: 22px;
  height: 22px;
  display: inline-grid;
  place-items: center;
  border-radius: 999px;
  color: var(--blue);
  background: var(--blue-soft);
  font-size: 11px;
  font-weight: 950;
}

.fission-column small {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.3;
}

.fission-card-list {
  display: grid;
  align-content: start;
  gap: 6px;
  overflow: visible;
  padding-right: 2px;
}

.fission-select {
  width: 100%;
  min-height: 30px;
  padding: 0 26px 0 8px;
  border: 1px solid var(--line-2);
  border-radius: 8px;
  color: var(--ink);
  background-color: #fff;
  font-size: 11px;
  font-weight: 800;
}

.fission-card {
  display: grid;
  grid-template-rows: 1fr auto;
  gap: 4px;
  min-height: 164px;
  position: relative;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: var(--surface);
  text-align: left;
  overflow: hidden;
}

.fission-card.active {
  border-color: var(--line);
  box-shadow: none;
}

.fission-card-main {
  width: 100%;
  display: grid;
  gap: 4px;
  min-height: 132px;
  padding: 8px;
  border: 0;
  color: inherit;
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.fission-card b {
  color: var(--blue);
  font-size: 11px;
}

.fission-card p {
  display: -webkit-box;
  min-height: 52px;
  margin: 0;
  color: var(--ink);
  font-size: 12px;
  font-weight: 850;
  line-height: 1.45;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.fission-card span {
  color: var(--muted);
  font-size: 10px;
  line-height: 1.35;
}

.fission-delete-btn {
  justify-self: end;
  margin: 0 7px 7px 0;
  min-height: 22px;
  padding: 0 7px;
  border: 1px solid rgba(239, 68, 68, 0.22);
  border-radius: 7px;
  color: #b42318;
  background: #fff7f6;
  font-size: 10px;
  font-weight: 900;
  cursor: pointer;
}

.fission-delete-btn:hover {
  border-color: rgba(239, 68, 68, 0.42);
  background: #ffeceb;
}

.rewrite-block em {
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
  font-weight: 900;
}

.rewrite-block.active {
  color: var(--ink);
  border-color: var(--blue);
  background: var(--blue-soft);
}

.rewrite-block.active b,
.rewrite-block.active em {
  color: inherit;
}

.rewrite-clear-btn {
  min-height: 30px;
  padding: 0 10px;
  font-size: 12px;
}

.rewrite-result-area {
  margin-top: 8px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.duplicate-material-preview {
  display: grid;
  gap: 12px;
  padding: 16px;
  border: 1px solid rgba(179, 45, 51, 0.28);
  border-left: 3px solid var(--blue);
  border-radius: 10px;
  background: rgba(179, 45, 51, 0.05);
}

.duplicate-material-preview-head,
.duplicate-material-preview-actions,
.final-script-section-head,
.final-script-history-head,
.final-script-history-meta,
.final-script-editor-actions,
.version-card-actions,
.final-script-history-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.duplicate-material-preview-head h3 {
  margin: 8px 0 2px;
  font-size: 15px;
}

.duplicate-material-preview-head p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.duplicate-preview-close {
  width: 32px;
  min-width: 32px;
  height: 32px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 22px;
}

.duplicate-material-preview pre,
.final-script-history-card pre {
  max-height: 280px;
  margin: 0;
  padding: 12px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font: inherit;
  font-size: 13px;
  line-height: 1.7;
}

.duplicate-material-preview-actions {
  justify-content: flex-end;
}

.final-script-workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 22px;
  margin-top: 0;
}

.final-script-editor,
.final-script-history {
  min-width: 0;
}

.final-script-section-head,
.final-script-history-head {
  align-items: flex-start;
  margin-bottom: 12px;
}

.final-script-section-head {
  align-items: center;
}

.final-script-section-head h3,
.final-script-history-head h3 {
  margin: 0;
  font-size: 15px;
}

.final-script-history-title {
  display: flex;
  align-items: baseline;
  gap: 7px;
}

.final-script-history-title span {
  margin-top: 0;
}

.final-script-section-head span,
.final-script-history-head span {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.final-script-section-head em {
  color: var(--blue);
  font-size: 12px;
  font-style: normal;
  font-weight: 800;
  white-space: nowrap;
}

.final-script-editor > input,
.final-script-history-head input {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.final-script-editor textarea {
  width: 100%;
  height: 140px;
  min-height: 140px;
  margin-top: 0;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  line-height: 1.7;
}

.final-script-editor-actions {
  justify-content: flex-end;
  margin-top: 10px;
}

.final-script-history-head input {
  width: min(230px, 52%);
}

.final-script-history-list {
  display: grid;
  gap: 10px;
  max-height: 430px;
  overflow: auto;
}

.final-script-history-card {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.final-script-history-meta {
  align-items: flex-start;
}

.final-script-history-meta h4 {
  margin: 0;
  font-size: 13px;
}

.final-script-history-meta span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 11px;
}

.final-script-history-actions,
.version-card-actions {
  justify-content: flex-end;
}

.final-script-history-actions {
  flex-shrink: 0;
  gap: 2px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface-2);
}

.final-script-history-actions button {
  min-width: 44px;
  min-height: 28px;
  padding: 0 9px;
  border: 0;
  border-radius: 5px;
  color: var(--muted);
  background: transparent;
  font-size: 11px;
  font-weight: 800;
  cursor: pointer;
}

.final-script-history-actions button:hover {
  color: var(--ink);
  background: var(--surface);
}

.danger-text-btn {
  color: var(--red) !important;
}

.final-script-history-actions .danger-text-btn:hover {
  background: var(--red-soft);
}

.final-script-history-card details {
  margin-top: 10px;
}

.final-script-history-card summary {
  cursor: pointer;
  color: var(--blue);
  font-size: 12px;
  font-weight: 800;
}

.final-script-history-card details pre {
  margin-top: 8px;
}

.rewrite-versions-bar {
  min-height: 38px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.rewrite-versions-bar:empty {
  display: none;
}

.rewrite-versions-bar b {
  display: block;
  color: var(--ink);
  font-size: 14px;
  line-height: 1.3;
}

.rewrite-versions-bar span {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.rewrite-versions-bar button {
  min-height: 30px;
  padding: 0 12px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}

.version-grid {
  display: grid;
  gap: 12px;
}

.version-grid:has(.version-card:nth-child(2)) {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: start;
}

.rewrite-generating-panel {
  min-height: clamp(220px, 34vh, 360px);
  display: grid;
  place-items: center;
  align-content: center;
  gap: 14px;
  padding: 24px;
  border: 1px solid rgba(179, 45, 51, 0.18);
  border-radius: 12px;
  background: var(--surface);
  color: var(--blue);
  text-align: center;
}

.rewrite-generating-panel b {
  display: block;
  font-size: 20px;
  font-weight: 900;
}

.rewrite-generating-panel span:not(.status-spinner) {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 800;
}

.version-card pre {
  white-space: pre-wrap;
  line-height: 1.7;
  color: var(--ink);
  font: inherit;
  font-size: 13px;
}

.version-card-loading {
  min-height: 320px;
}

.rewrite-card-loading-body {
  min-height: 230px;
  display: grid;
  place-items: center;
  color: var(--blue);
}

.rewrite-card-error {
  min-height: 160px;
  display: grid;
  place-items: center;
  padding: 16px;
  border-radius: 10px;
  background: var(--red-soft);
  color: var(--red);
  font-size: 13px;
  font-weight: 800;
  text-align: center;
}

.version-provider {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.rewrite-structure {
  display: grid;
  gap: 4px;
  padding: 8px 10px;
  margin-bottom: 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-2);
}

.rewrite-structure div {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr);
  gap: 8px;
  align-items: start;
}

.rewrite-structure b {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.rewrite-structure span {
  color: var(--ink);
  font-size: 12px;
  font-weight: 800;
  line-height: 1.45;
}

.empty {
  padding: 32px 14px;
  border: 1px dashed var(--line-2);
  border-radius: 12px;
  text-align: center;
  color: var(--faint);
  background: var(--surface);
  font-size: 13px;
}

.toast {
  position: fixed;
  z-index: 1200;
  right: 18px;
  bottom: 18px;
  max-width: 340px;
  padding: 12px 14px;
  border-radius: 10px;
  color: #fff;
  background: var(--ink);
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(8px);
  transition: 0.18s;
  pointer-events: none;
}

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

@media (max-width: 980px) {
  .chanmama-data-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .chanmama-collector-panel {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .chanmama-player-modal {
    grid-template-columns: minmax(280px, 0.8fr) minmax(300px, 1fr);
  }

  .app-shell {
    padding: 18px;
  }

  .hero {
    display: flex;
    flex-wrap: nowrap;
  }

  .brand-lockup {
    flex: 1 1 auto;
    flex-wrap: nowrap;
  }

  .header-actions {
    flex: 0 0 auto;
    flex-wrap: nowrap;
    margin-left: auto;
  }

  .header-stats {
    display: none;
  }

  .auth-actions {
    flex-wrap: wrap;
  }

  .auth-panel,
  .auth-grid {
    grid-template-columns: 1fr;
  }

  .step-nav {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 6px;
    margin-bottom: 10px;
    padding: 6px;
  }

  .step-nav button {
    min-height: 34px;
    padding: 0 4px;
    font-size: 12px;
  }

  .source-grid,
  .chat-grid,
  .knowledge-grid,
  .rewrite-grid,
  .review-grid {
    grid-template-columns: 1fr;
  }

  .metric-preview {
    grid-template-columns: 1fr;
  }

  .kb-filter-row,
  .knowledge-main,
  .knowledge-workbench {
    grid-template-columns: 1fr;
  }

  .knowledge-workbench {
    grid-template-rows: minmax(260px, 42%) minmax(0, 1fr);
  }

  .knowledge-side-panel {
    max-height: 340px;
  }

  .knowledge-tree-panel {
    max-height: none;
    order: 2;
  }

  .element-cloud-panel {
    order: 1;
  }

  .knowledge-element-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .element-directory-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .pending-element-card {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .app-shell {
    padding: 12px;
  }

  .hero {
    gap: 8px;
    margin-bottom: 8px;
  }

  h1 {
    font-size: 24px;
    line-height: 1.15;
  }

  .brand-lockup {
    gap: 4px 10px;
  }

  .brand-logo {
    height: 34px;
  }

  .brand-subtitle {
    width: 100%;
    min-height: 0;
    padding-left: 0;
    border-left: 0;
    font-size: 12px;
    white-space: normal;
  }

  .header-actions {
    gap: 6px;
  }

  .header-stats {
    min-height: 34px;
    padding: 0 9px;
    font-size: 11px;
  }

  .header-actions .ghost-btn {
    min-height: 34px;
    padding: 0 10px;
    font-size: 12px;
  }

  .step-nav {
    margin-bottom: 8px;
    padding: 6px;
  }

  .step-nav button {
    min-height: 32px;
    font-size: 11px;
  }

  .knowledge-searchbar {
    grid-template-columns: 1fr;
  }

  .knowledge-coursebar {
    grid-template-columns: 1fr;
  }

  .knowledge-elements-panel {
    padding: 12px;
  }

  .element-directory-list {
    grid-template-columns: 1fr;
  }

  .workbench-pane-head {
    min-height: 42px;
  }

  .workbench-pane-head span {
    display: none;
  }

  .knowledge-element-grid {
    grid-template-columns: 1fr;
  }

  .cloud-scope-bar {
    display: grid;
    gap: 6px;
  }

  .cloud-scope-actions {
    flex-wrap: wrap;
    justify-content: flex-start;
  }

  .cloud-element-search {
    width: min(100%, 280px);
  }

  .element-cloud {
    min-height: 320px;
  }

  .knowledge-topbar {
    padding: 8px;
  }

  .kb-path {
    flex-wrap: wrap;
  }

  .kb-segment {
    min-height: 38px;
  }

  .kb-segment button {
    min-height: 30px;
    padding: 0 10px;
    font-size: 12px;
  }

  .pending-actions {
    grid-template-columns: 1fr;
  }

  .kb-fold summary {
    align-items: flex-start;
  }
}

/* === 固定视口：页面不误导滚动，内部列表/对话滚动 === */
body {
  height: 100vh;
  overflow: hidden;
}

.app-shell {
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.hero,
.step-nav {
  flex-shrink: 0;
}

main {
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.stage.active {
  height: 100%;
  overflow: hidden;
}

.stage-grid {
  height: 100%;
  min-height: 0;
  overflow: hidden;
}

.stage-grid .panel {
  min-height: 0;
  max-height: 100%;
  overflow: hidden;
}

section[data-stage="rewrite"] .panel {
  overflow-y: auto;
}

section[data-stage="rewrite"] .rewrite-grid {
  grid-template-columns: 1fr;
}

section[data-stage="rewrite"] .rewrite-panel {
  display: block;
}

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

section[data-stage="rewrite"] .version-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.card-list {
  flex: 1;
  min-height: 0;
}

section[data-stage="source"] .source-grid {
  grid-template-columns: minmax(0, 1fr);
}

section[data-stage="source"] .source-grid > .panel {
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overscroll-behavior: contain;
  scroll-behavior: smooth;
}

section[data-stage="source"] .source-library-section {
  flex: 0 0 auto;
  min-width: 0;
  margin-top: 18px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-2);
}

section[data-stage="source"] .source-library-section .pipeline-status {
  margin-bottom: 10px;
}

section[data-stage="source"] .source-library-section .source-queue-head {
  border-right: 0;
  border-bottom: 0;
  border-left: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

section[data-stage="chanmama"] .source-grid > .panel:last-child {
  display: flex;
  flex-direction: column;
}

section[data-stage="source"] #sourceQueue {
  flex: 0 0 auto;
  min-height: 0;
  max-height: none;
  align-content: start;
  grid-auto-rows: max-content;
  overflow: visible;
  padding-right: 0;
}

section[data-stage="chanmama"] #chanmamaDataList {
  flex: 1;
  min-height: 0;
  max-height: none;
  align-content: start;
  grid-auto-rows: max-content;
  overflow: auto;
}

section[data-stage="elements"].active .stage-grid {
  display: block;
}

section[data-stage="elements"].active .panel {
  height: 100%;
  padding: 14px;
  display: flex;
  flex-direction: column;
  border-color: rgba(255, 255, 255, 0.90);
}

section[data-stage="elements"] .panel-head {
  align-items: flex-start;
  margin-bottom: 8px;
  flex-shrink: 0;
}

section[data-stage="elements"] .panel-head h2 {
  font-size: 18px;
}

section[data-stage="elements"] .panel-head p {
  margin-top: 4px;
  font-size: 12px;
  line-height: 1.45;
}

section[data-stage="elements"] .scope-picker {
  display: none;
}

section[data-stage="elements"] .scope-box {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0;
  flex-shrink: 0;
  align-items: center;
  justify-content: flex-end;
}

section[data-stage="elements"] .scope-box div,
section[data-stage="elements"] .scope-box p {
  min-height: 38px;
  padding: 0 10px;
  display: flex;
  align-items: center;
  gap: 5px;
}

section[data-stage="elements"] .scope-source-row {
  min-height: 38px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
}

section[data-stage="elements"] .scope-source-row .kb-source-switch {
  min-height: 38px;
}

section[data-stage="elements"] .scope-select-card {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  width: min(420px, 42vw);
  max-width: 100%;
  padding: 4px 6px 4px 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #f2f5f8;
  box-shadow: inset 0 0 0 1px rgba(179, 45, 51, 0.04);
}

section[data-stage="elements"] .scope-unified-card {
  width: min(520px, 52vw);
}

section[data-stage="elements"] .scope-unified-card .scope-personal-filter {
  flex: 0 0 108px;
  min-width: 96px;
}

section[data-stage="elements"] .scope-unified-card #scopeTargetSelect {
  flex: 1 1 300px;
  min-width: 260px;
}

.analysis-scope-mode {
  display: inline-flex;
  gap: 4px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-2);
}

.analysis-scope-mode button {
  min-height: 32px;
  padding: 0 14px;
  border: 0;
  border-radius: 7px;
  color: var(--muted);
  background: transparent;
  font-size: 13px;
  font-weight: 900;
  cursor: pointer;
}

.analysis-scope-mode button.active {
  color: #fff;
  background: var(--blue);
}

section[data-stage="elements"] .scope-select-card select {
  flex: 1;
  min-width: 220px;
  height: 30px;
  padding: 0 30px 0 10px;
  border: 1px solid rgba(179, 45, 51, 0.28);
  border-radius: 8px;
  color: var(--ink);
  background-color: #fff;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 17px) 12px, calc(100% - 11px) 12px;
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
  appearance: none;
  font-size: 13px;
  font-weight: 900;
}

section[data-stage="elements"] .scope-box b {
  min-width: 48px;
  color: var(--ink);
  font-size: 13px;
  line-height: 1;
  white-space: nowrap;
}

section[data-stage="elements"] .scope-box span,
section[data-stage="elements"] .scope-box p {
  font-size: 12px;
  line-height: 1.2;
}

section[data-stage="elements"] .scope-box p {
  justify-content: center;
  padding: 0 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: center;
}

section[data-stage="elements"] .chat-log {
  flex: 1;
  min-height: 430px;
  max-height: none;
  margin: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-content: normal;
}

section[data-stage="elements"] .chat-box {
  margin-top: 10px;
  flex-shrink: 0;
  grid-template-columns: minmax(0, 1fr) 88px;
}

section[data-stage="elements"] .chat-box textarea {
  min-height: 46px;
  max-height: 46px;
  resize: none;
}

@media (min-width: 981px) {
  section[data-stage="elements"] .chat-box {
    grid-template-columns: minmax(0, 1fr) 76px;
    gap: 8px;
    margin-top: 8px;
  }

  section[data-stage="elements"] .chat-box textarea {
    min-height: 46px;
    max-height: 46px;
    padding: 8px 10px;
    line-height: 1.45;
  }

  section[data-stage="elements"] .chat-box .primary-btn {
    min-height: 46px;
    padding: 0 12px;
  }
}

@media (max-width: 980px) {
  section[data-stage="elements"] .panel-head {
    flex-wrap: wrap;
  }

  section[data-stage="elements"] .panel-head p {
    display: none;
  }

  section[data-stage="elements"] .scope-box {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-start;
    width: 100%;
  }

  section[data-stage="elements"] .scope-box p {
    display: block;
  }
}

@media (max-width: 560px) {
  section[data-stage="elements"].active .panel {
    padding: 10px;
    border-radius: 12px;
  }

  section[data-stage="elements"] .panel-head {
    margin-bottom: 6px;
  }

  section[data-stage="elements"] .panel-head h2 {
    font-size: 16px;
  }

  section[data-stage="elements"] .scope-box {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 6px;
  }

  section[data-stage="elements"] .scope-box div,
  section[data-stage="elements"] .scope-box p {
    min-height: 34px;
    padding: 0 8px;
  }

  section[data-stage="elements"] .scope-select-card {
    width: min(420px, 100%);
    padding: 4px 6px 4px 10px;
  }

  section[data-stage="elements"] .scope-unified-card {
    width: min(520px, 100%);
  }

  section[data-stage="elements"] .scope-unified-card {
    gap: 5px;
  }

  section[data-stage="elements"] .scope-unified-card .scope-personal-filter {
    flex-basis: 100px;
    min-width: 92px;
  }

  section[data-stage="elements"] .scope-unified-card #scopeTargetSelect {
    flex-basis: 220px;
    min-width: 200px;
  }

  section[data-stage="elements"] .scope-select-card select {
    height: 30px;
    font-size: 12px;
  }

  section[data-stage="elements"] .scope-box p {
    justify-content: center;
    text-align: center;
  }

  section[data-stage="elements"] .scope-box b {
    min-width: 48px;
    font-size: 12px;
    white-space: nowrap;
  }

  section[data-stage="elements"] .scope-box span,
  section[data-stage="elements"] .scope-box p {
    font-size: 11px;
  }

  section[data-stage="elements"] .chat-msg {
    max-width: 95%;
    padding: 10px;
    font-size: 12px;
  }

  section[data-stage="elements"] .chat-msg.user {
    max-width: 84%;
    width: fit-content;
    align-self: flex-end;
    padding: 8px 10px;
  }

  section[data-stage="elements"] .chat-box {
    grid-template-columns: minmax(0, 1fr) 72px;
    gap: 8px;
  }

  section[data-stage="elements"] .chat-box textarea {
    min-height: 46px;
    max-height: 46px;
    padding: 9px;
    font-size: 13px;
    line-height: 1.45;
  }

  section[data-stage="elements"] .chat-box .primary-btn {
    min-height: 52px;
    padding: 0 10px;
  }
}
.material-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
}

.material-title-row b {
  flex: 1;
  min-width: 0;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.delete-material-btn {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 6px;
  color: var(--faint);
  background: transparent;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
}

.delete-material-btn:hover {
  color: var(--red);
  background: var(--red-soft);
}

.card-top-right {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}
.scope-source-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
  flex-shrink: 0;
}

section[data-stage="elements"] #elementScope .scope-source-row {
  padding: 0;
}

.scope-stats {
  display: grid;
  grid-template-columns: auto auto;
  gap: 8px;
  margin-bottom: 6px;
  flex-shrink: 0;
}

.scope-stats div {
  min-height: 34px;
  padding: 0 10px;
  display: flex;
  align-items: center;
  gap: 5px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.scope-stats b {
  font-size: 15px;
  line-height: 1;
}

.scope-stats span {
  font-size: 11px;
  color: var(--muted);
}

.owner-cell {
  display: grid;
  justify-items: center;
  gap: 6px;
}

.owner-status {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  font-size: 12px;
  font-weight: 900;
  color: var(--ink);
}

.owner-status.pending {
  color: var(--faint);
}

.owner-status.saved {
  color: var(--green);
}

.owner-actions {
  display: flex;
  justify-content: center;
  gap: 4px;
}

.hit-table .pending-row .owner-actions {
  display: grid;
  grid-template-columns: 1fr;
  width: 44px;
  gap: 5px;
}

.owner-action-btn {
  min-height: 26px;
  padding: 0 10px;
  border: 0;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 900;
  cursor: pointer;
  white-space: nowrap;
}

.hit-table .pending-row .owner-action-btn {
  width: 100%;
  padding: 0 6px;
}

.owner-action-btn.save-btn {
  color: #fff;
  background: var(--green);
}

.owner-action-btn.discard-btn {
  color: var(--muted);
  background: var(--surface-2);
}

.owner-action-btn.remove-btn {
  color: var(--muted);
  background: var(--surface-2);
}

.source-target-section {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  overflow: hidden;
}

.source-target-section > summary {
  min-height: 40px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto 42px;
  align-items: center;
  gap: 10px;
  padding: 0 12px;
  cursor: pointer;
  list-style: none;
  background: var(--surface-2);
}

.source-target-section > summary::-webkit-details-marker {
  display: none;
}

.source-target-section > summary strong {
  font-size: 13px;
  color: var(--ink);
}

.source-target-section > summary span,
.source-target-section > summary em {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  font-style: normal;
  white-space: nowrap;
}

.source-target-section:not([open]) > summary em {
  font-size: 0;
}

.source-target-section:not([open]) > summary em::after {
  content: "展开";
  font-size: 11px;
}

.source-target-section-items {
  display: grid;
  gap: 8px;
  padding: 8px;
  border-top: 1px solid var(--line);
}

.ip-material-group {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.76);
  overflow: hidden;
}

.ip-material-group summary {
  min-height: 36px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 86px auto;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  cursor: pointer;
  list-style: none;
}

.ip-material-group summary::-webkit-details-marker {
  display: none;
}

.ip-material-group summary strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
  color: #17202b;
}

.ip-material-group summary .ip-material-count {
  color: #17202b;
  font-size: 11px;
  font-weight: 900;
  text-align: right;
  white-space: nowrap;
}

.ip-material-actions {
  display: none;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
}

.ip-material-group[open] .ip-material-actions {
  display: inline-flex;
}

.ip-material-actions button {
  display: grid;
  width: 26px;
  height: 26px;
  min-height: 26px;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 5px;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
}

.ip-material-actions button svg {
  width: 15px;
  height: 15px;
}

.ip-material-actions button:hover {
  color: var(--blue);
  background: var(--blue-soft);
}

.ip-material-actions button.danger:hover {
  color: var(--red);
  background: var(--red-soft);
}

.ip-material-items {
  display: grid;
  gap: 6px;
  padding: 8px 10px;
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.76);
}

.material-status-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  min-width: 0;
  margin-top: 4px;
}

.material-status-actions {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 6px;
}

.material-collected-time,
.material-status-processing {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
}

.material-status-failed {
  color: var(--red);
  font-weight: 900;
}

.material-view-btn {
  min-height: 24px;
  padding: 0 8px;
  border: 1px solid rgba(179, 45, 51, 0.22);
  border-radius: 999px;
  color: var(--blue);
  background: var(--blue-soft);
  font-size: 11px;
  font-weight: 900;
  cursor: pointer;
  white-space: nowrap;
}

.material-view-btn:hover {
  border-color: rgba(179, 45, 51, 0.42);
  background: rgba(179, 45, 51, 0.15);
}
.ip-combo {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.ip-combo select,
.ip-combo input,
.ip-combo button {
  width: auto;
}

.ip-combo .add-course-btn {
  min-width: 160px;
}

.compact-detail {
  flex-wrap: wrap;
  align-items: center;
}

.compact-detail small {
  color: var(--muted);
  font-size: 11px;
  white-space: nowrap;
}
.source-expand pre mark {
  background: var(--red-soft);
  color: var(--red);
  border-radius: 2px;
  padding: 0 2px;
  font-weight: 900;
}

.status-spinner {
  display: inline-block;
  width: 12px;
  height: 12px;
  margin-right: 5px;
  border: 2px solid transparent;
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.source-queue-guide {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 136px;
  align-items: center;
  gap: 14px;
  min-height: 46px;
  padding: 8px 12px;
  border-radius: 12px;
  font-size: 13px;
}

.source-queue-guide > div {
  justify-self: center;
}

.source-queue-guide.processing {
  min-height: clamp(220px, 46vh, 430px);
  grid-template-columns: 1fr;
  place-items: center;
  align-content: center;
  gap: 14px;
  border: 1px solid rgba(179, 45, 51, 0.18);
  background: var(--surface);
  color: var(--blue);
  text-align: center;
  box-shadow: inset 0 0 0 1px rgba(179, 45, 51, 0.04);
}

.source-queue-guide.ready {
  background: var(--blue-soft);
  color: var(--blue);
}

.source-queue-guide.failed {
  background: var(--red-soft);
  color: var(--red);
}

.source-queue-guide b {
  display: block;
  font-size: 13px;
  font-weight: 900;
}

.source-queue-guide.processing b {
  font-size: 20px;
}

.source-queue-guide span {
  display: block;
  margin-top: 2px;
  font-size: 12px;
  opacity: 0.8;
}

.source-queue-guide.processing span {
  font-size: 14px;
  color: var(--muted);
  opacity: 1;
}

.source-queue-spinner {
  width: 58px;
  height: 58px;
  margin: 0;
  border-width: 5px;
}

.source-queue-guide button {
  justify-self: start;
  margin-right: 0;
  min-height: 30px;
  padding: 0 14px;
  border: 0;
  border-radius: 10px;
  background: var(--blue);
  color: #fff;
  font-size: 13px;
  font-weight: 900;
  cursor: pointer;
  white-space: nowrap;
}

.source-upload-status.uploading {
  display: grid;
  gap: 12px;
  padding: 18px;
  border: 1px solid rgba(179, 45, 51, 0.22);
  border-radius: 12px;
  background: var(--surface);
}

.source-upload-status-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.source-upload-status-head b,
.source-upload-status-head span {
  display: block;
}

.source-upload-status-head b {
  color: var(--ink);
  font-size: 15px;
}

.source-upload-status-head span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.source-upload-status-head strong {
  flex-shrink: 0;
  color: var(--blue);
  font-size: 18px;
}

.source-upload-progress {
  height: 8px;
  overflow: hidden;
  border-radius: 4px;
  background: var(--surface-2);
}

.source-upload-progress i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--blue);
  transition: width 120ms linear;
}

.chat-auto-pending {
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--blue-soft);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 13px;
}

.chat-auto-pending span {
  color: var(--blue);
  font-weight: 900;
}

.chat-auto-pending button {
  min-height: 28px;
  padding: 0 12px;
  border: 0;
  border-radius: 7px;
  background: var(--blue);
  color: #fff;
  font-size: 12px;
  font-weight: 900;
  cursor: pointer;
  white-space: nowrap;
}

.source-expand .details-toggle-open { display: none !important; }
.source-expand[open] .details-toggle-open { display: inline !important; }
.source-expand[open] .details-toggle-closed { display: none !important; }

.knowledge-tree-panel { overflow-y: auto; overflow-x: hidden; }

.element-detail article, .element-detail .empty { min-height: auto; padding: 8px 10px; }
.element-detail p { margin: 0; font-size: 12px; }
.element-detail small { margin-top: 4px; }

/* Keep the AI analysis workspace bounded on narrow screens. */
@media (max-width: 980px) {
  section[data-stage="elements"].active .panel {
    height: calc(100dvh - 118px);
    min-height: 560px;
    max-height: 760px;
    overflow: hidden;
  }

  section[data-stage="elements"] .chat-log {
    flex: 1 1 auto;
    min-height: 430px;
    overflow-y: auto;
  }
}

@media (max-width: 980px) {
  html,
  body {
    height: auto;
    min-height: 100%;
    overflow-x: hidden;
    overflow-y: auto;
  }

  .app-shell {
    height: auto;
    min-height: 100vh;
    overflow: visible;
  }

  main,
  .stage.active,
  .stage-grid,
  .stage-grid .panel {
    height: auto;
    max-height: none;
    overflow: visible;
  }

  section[data-stage="rewrite"] .rewrite-framework-grid,
  section[data-stage="rewrite"] .version-grid {
    grid-template-columns: 1fr;
  }

  .fission-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .rewrite-flow-list {
    grid-template-columns: 1fr;
  }

  .fission-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .source-queue-guide {
    align-items: flex-start;
    flex-direction: column;
  }

  .source-queue-guide button,
  .source-queue-toggle {
    margin-right: 0;
  }

}

/* Mobile workspace: desktop rules remain unchanged above 720px. */
@media (max-width: 720px) {
  .chanmama-browser {
    padding: 4px 0 16px;
  }

  .chanmama-page-head {
    align-items: flex-start;
  }

  .chanmama-page-head p {
    display: none;
  }

  .chanmama-collector-panel {
    grid-template-columns: 1fr;
  }

  .chanmama-task-strip {
    flex-wrap: wrap;
  }

  .chanmama-task-strip progress {
    flex-basis: 100%;
  }

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

  .chanmama-card-body {
    padding: 9px;
  }

  .chanmama-card-body h3 {
    min-height: 38px;
    font-size: 12px;
  }

  .chanmama-primary-metrics {
    grid-template-columns: 1fr;
    gap: 4px;
  }

  .chanmama-player-overlay {
    padding: 10px;
  }

  .chanmama-player-modal {
    display: block;
    height: auto;
    max-height: calc(100dvh - 20px);
    overflow-y: auto;
  }

  .chanmama-player-media {
    min-height: 0;
  }

  .chanmama-player-media video {
    height: 52vh;
  }

  .chanmama-player-detail {
    padding: 18px 14px;
  }

  .chanmama-player-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  html,
  body {
    width: 100%;
    min-width: 0;
    height: auto;
    min-height: 100%;
    overflow-x: hidden;
    overflow-y: auto;
  }

  body.auth-required {
    height: 100dvh;
    overflow: hidden;
  }

  .app-shell {
    width: 100%;
    height: auto;
    min-height: 100dvh;
    padding: 10px;
    overflow: visible;
  }

  .hero {
    display: flex;
    flex-wrap: nowrap;
    gap: 8px;
    margin-bottom: 8px;
  }

  .brand-lockup {
    flex: 1;
    min-width: 0;
    flex-wrap: nowrap;
  }

  .brand-logo {
    max-width: 188px;
    height: 34px;
  }

  .brand-subtitle,
  .header-stats {
    display: none !important;
  }

  .header-actions {
    flex: 0 0 auto;
    margin-left: auto;
  }

  .header-actions .ghost-btn {
    min-height: 34px;
    max-width: 92px;
    padding: 0 10px;
    overflow: hidden;
    font-size: 12px;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .step-nav {
    position: sticky;
    top: 0;
    z-index: 30;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 4px;
    margin-bottom: 8px;
    padding: 4px;
    border-radius: 10px;
  }

  .step-nav button {
    min-width: 0;
    min-height: 38px;
    padding: 3px 2px;
    border-radius: 8px;
    font-size: 11px;
    line-height: 1.2;
    white-space: normal;
  }

  main,
  .stage.active,
  .stage-grid {
    height: auto;
    min-height: 0;
    overflow: visible;
  }

  main {
    flex: none;
    width: 100%;
  }

  .stage-grid {
    gap: 10px;
  }

  .stage-grid .panel,
  section[data-stage="source"] .panel,
  section[data-stage="knowledge"] .panel,
  section[data-stage="rewrite"] .panel,
  section[data-stage="review"] .panel {
    width: 100%;
    min-width: 0;
    max-height: none;
    padding: 12px;
    border-radius: 12px;
    overflow: visible;
  }

  .panel-head {
    gap: 8px;
    margin-bottom: 12px;
  }

  .panel-head h2 {
    font-size: 17px;
  }

  .panel-head p,
  .panel > p {
    font-size: 12px;
    line-height: 1.5;
  }

  input,
  select,
  .primary-btn,
  .ghost-btn {
    min-height: 42px;
  }

  .ip-combo,
  .file-picker,
  .rewrite-course-picker {
    grid-template-columns: 1fr;
  }

  .rewrite-course-control {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .ip-combo button {
    width: 100%;
  }

  .file-picker-btn {
    width: 100%;
  }

  .file-picker span {
    padding: 0 8px 5px;
    text-align: center;
  }

  .source-method-switch button,
  .source-mode-switch button,
  .rewrite-mode-switch button {
    min-width: 0;
    min-height: 38px;
    padding: 4px;
    font-size: 12px;
    line-height: 1.25;
  }

  .pipeline-status {
    gap: 6px;
  }

  .pipeline-status div {
    min-height: 48px;
    padding: 8px;
  }

  .pipeline-status b {
    font-size: 17px;
  }

  .source-queue-head,
  .source-queue-guide {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
  }

  .source-queue-head > div,
  .source-queue-guide > div {
    justify-self: start;
  }

  .source-queue-head b {
    font-size: 16px;
  }

  .source-queue-toggle,
  .source-queue-guide button {
    min-height: 36px;
    padding: 0 14px;
    font-size: 13px;
  }

  section[data-stage="source"] #sourceQueue {
    flex: none;
    max-height: none;
    overflow: visible;
  }

  .card-top {
    flex-wrap: wrap;
  }

  .material-status-actions {
    flex-wrap: wrap;
  }

  section[data-stage="elements"].active .stage-grid {
    display: block;
  }

  section[data-stage="elements"].active .panel {
    height: calc(100dvh - 118px);
    min-height: 560px;
    max-height: 760px;
    padding: 10px;
    overflow: hidden;
  }

  section[data-stage="elements"] .panel-head {
    display: block;
  }

  section[data-stage="elements"] .scope-box {
    width: 100%;
    justify-content: flex-start;
  }

  section[data-stage="elements"] .scope-select-card {
    width: 100%;
  }

  section[data-stage="elements"] .scope-select-card select {
    min-width: 0;
  }

  section[data-stage="elements"] .chat-log {
    min-height: 0;
    overscroll-behavior: contain;
  }

  section[data-stage="elements"] .chat-msg {
    max-width: 100%;
  }

  section[data-stage="elements"] .chat-box {
    grid-template-columns: minmax(0, 1fr) 64px;
    gap: 6px;
  }

  section[data-stage="elements"] .chat-box .primary-btn {
    min-width: 64px;
    padding: 0 8px;
  }

  .chat-table-wrap,
  .hit-table {
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .chat-table,
  .hit-table table {
    min-width: 680px;
  }

  .knowledge-layout,
  .knowledge-elements-panel {
    height: auto;
    min-height: 0;
    overflow: visible;
  }

  .knowledge-elements-panel {
    display: block;
  }

  .knowledge-searchbar,
  .knowledge-coursebar {
    grid-template-columns: 1fr;
  }

  .knowledge-searchbar span {
    width: 100%;
    min-width: 0;
    justify-self: stretch;
  }

  .knowledge-workbench {
    display: flex;
    flex-direction: column;
    gap: 10px;
    overflow: visible;
  }

  .element-cloud-panel {
    order: 1;
    min-height: 0;
    padding: 8px;
    overflow: visible;
  }

  .knowledge-tree-panel {
    order: 2;
    max-height: 58dvh;
    overflow-y: auto;
  }

  .element-cloud {
    height: 58dvh;
    min-height: 380px;
    max-height: 560px;
    overflow: auto;
    overscroll-behavior: contain;
  }

  .cloud-scope-bar {
    display: grid;
    gap: 8px;
  }

  .cloud-scope-actions {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    justify-content: stretch;
    gap: 6px;
  }

  .cloud-element-search {
    width: 100%;
    min-width: 0;
  }

  .cloud-scope-actions .ghost-btn {
    min-height: 32px;
    padding: 0 9px;
  }

  .element-directory-list,
  .knowledge-element-grid {
    grid-template-columns: 1fr;
  }

  .hit-stat-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .knowledge-next-step {
    display: grid;
    grid-template-columns: 1fr;
  }

  .knowledge-next-step button {
    width: 100%;
  }

  .rewrite-mode-switch {
    gap: 4px;
  }

  section[data-stage="rewrite"] .rewrite-framework-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    max-height: 420px;
  }

  .rewrite-framework-card {
    min-height: 104px;
    padding: 9px;
  }

  .rewrite-action-row,
  .rewrite-versions-bar,
  .fission-head,
  .fission-head-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .rewrite-action-row {
    align-items: center;
    flex-direction: row;
  }

  .rewrite-action-row .primary-btn {
    width: auto;
  }

  .rewrite-action-tools {
    min-width: 0;
  }

  .rewrite-inline-status {
    justify-content: flex-start;
  }

  section[data-stage="rewrite"] .version-grid,
  .version-grid:has(.version-card:nth-child(2)),
  .fission-grid,
  .rewrite-flow-list {
    grid-template-columns: 1fr;
  }

  .final-script-workspace {
    grid-template-columns: 1fr;
    gap: 18px;
  }

  .final-script-section-head,
  .final-script-history-head,
  .final-script-history-meta {
    align-items: stretch;
    flex-direction: column;
  }

  .final-script-section-head {
    align-items: center;
    flex-direction: row;
  }

  .final-script-history-head input {
    width: 100%;
  }

  .final-script-history-actions {
    justify-content: flex-start;
  }

  .fission-upload-popover {
    right: 0;
    width: min(286px, calc(100vw - 44px));
  }

  .version-card pre {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
  }

  section[data-stage="review"] .metric-preview {
    max-height: none;
    overflow: visible;
  }

  .metric-preview {
    grid-template-columns: 1fr;
  }

  .auth-overlay,
  .library-confirm-overlay {
    padding: 10px;
  }

  .auth-modal {
    width: 100%;
    padding: 22px 18px;
  }

  .library-confirm-overlay.active {
    align-items: start;
    overflow-y: auto;
  }

  .course-create-overlay {
    align-items: center;
    padding-top: max(10px, env(safe-area-inset-top));
    padding-bottom: max(10px, env(safe-area-inset-bottom));
    overflow: hidden;
  }

  .course-create-modal {
    max-height: calc(100dvh - max(20px, env(safe-area-inset-top) + env(safe-area-inset-bottom)));
  }

  .library-confirm-modal {
    width: 100%;
    max-height: calc(100dvh - 20px);
    padding: 14px;
    overflow-y: auto;
  }

  .library-confirm-actions {
    position: sticky;
    bottom: -14px;
    padding: 10px 0 14px;
    background: var(--surface);
  }

  .material-transcript-modal {
    max-height: calc(100dvh - 20px);
  }

  .toast {
    right: 10px;
    bottom: 10px;
    left: 10px;
    max-width: none;
  }
}

@media (max-width: 760px) {
  .digital-human-workflow:not(.has-avatar),
  .auto-edit-workspace:not(.has-source) {
    margin-top: 0;
  }

  .digital-human-workflow:not(.has-avatar) .digital-human-avatar-column,
  .auto-edit-workspace:not(.has-source) .auto-edit-source-card {
    display: grid;
    min-height: 0;
    padding: 12px;
    place-items: center;
    border: 0;
    background: transparent;
    box-shadow: none;
  }

  .digital-human-workflow:not(.has-avatar) .digital-human-card-head,
  .digital-human-workflow:not(.has-avatar) .digital-human-avatar-stage,
  .auto-edit-workspace:not(.has-source) .auto-edit-source-card-head,
  .auto-edit-workspace:not(.has-source) .auto-edit-preview-stage,
  .auto-edit-workspace:not(.has-source) .auto-edit-preview-meta {
    display: none;
  }

  .digital-human-workflow:not(.has-avatar) #digitalHumanChooseAvatarBtn,
  .auto-edit-workspace:not(.has-source) #autoEditChooseSourceBtn {
    display: grid;
    width: 100%;
    min-height: 112px;
    margin: 0;
    place-items: center;
    border: 1px dashed rgba(169, 43, 50, .32);
    border-radius: 16px;
    color: #a92b32;
    background: #f9f1f2;
    box-shadow: none;
    font-size: 15px;
    font-weight: 800;
  }
}

/* Digital human is a long-form workspace; scroll the stage instead of clipping it. */
section[data-stage="digital-human"].active {
  min-height: 0;
  padding-bottom: 0;
  overflow-x: hidden;
  overflow-y: hidden;
  overscroll-behavior: contain;
}

section[data-stage="digital-human"] .digital-human-grid {
  height: auto;
  min-height: 100%;
  overflow: visible;
}

section[data-stage="digital-human"] .digital-human-panel {
  height: auto;
  min-height: 0;
  max-height: none;
  overflow: visible;
}

/* Coach Certification visual baseline for the Lingshu workbench. */
html,
body {
  background: var(--bg);
  letter-spacing: 0;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.app-shell {
  width: min(1240px, calc(100% - 48px));
  max-width: none;
  margin: 0 auto;
  padding: 28px 0 64px;
}

.hero {
  min-height: 54px;
  gap: 20px;
  margin-bottom: 18px;
}

.brand-lockup {
  flex-wrap: nowrap;
  gap: 14px;
}

.brand-logo {
  height: 48px;
}

.brand-subtitle {
  min-height: 15px;
  padding-left: 13px;
  border-left-color: rgba(102, 113, 125, 0.42);
  color: #66717d;
  font-size: 11px;
  font-weight: 500;
}

.header-stats,
.user-name-btn {
  min-height: 38px;
  border: 1px solid rgba(173, 186, 201, 0.38);
  border-radius: 10px;
  color: #596470;
  background: rgba(255, 255, 255, 0.52);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.78);
}

.user-name-btn {
  padding-inline: 14px 12px;
}

.user-name-btn:hover,
.user-name-btn[aria-expanded="true"] {
  border-color: rgba(179, 45, 51, 0.22);
  color: var(--ink);
  background: rgba(255, 255, 255, 0.74);
  box-shadow: 0 6px 16px rgba(72, 89, 108, 0.08), inset 0 1px 0 rgba(255, 255, 255, 0.90);
}

.account-menu {
  top: calc(100% + 10px);
  padding: 12px;
  border-color: rgba(255, 255, 255, 0.95);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.90);
  box-shadow: 0 16px 35px rgba(72, 89, 108, 0.16);
}

.account-menu button {
  min-height: 36px;
  border-radius: 7px;
  font-weight: 500;
}

.account-menu button:hover,
.account-menu button:focus-visible {
  color: var(--blue);
  background: var(--blue-soft);
}

.step-nav {
  position: relative;
  z-index: 200;
  gap: 6px;
  margin-bottom: 14px;
  padding: 7px;
  border-color: rgba(255, 255, 255, 0.88);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.51);
  box-shadow: 0 10px 28px rgba(72, 89, 108, 0.07), inset 0 1px 0 rgba(255, 255, 255, 0.90);
  backdrop-filter: blur(18px) saturate(180%);
  -webkit-backdrop-filter: blur(18px) saturate(180%);
}

.step-nav button {
  position: relative;
  min-height: 50px;
  border-color: transparent;
  border-radius: 10px;
  color: #707986;
  background: rgba(255, 255, 255, 0.17);
  font-size: 15px;
  font-weight: 600;
  transition: color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
}

.step-nav button:hover {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.42);
}

.step-nav button.active {
  color: var(--ink);
  border-color: rgba(255, 255, 255, 0.82);
  background: rgba(255, 255, 255, 0.68);
  box-shadow: 0 10px 24px rgba(73, 92, 112, 0.12), 0 2px 5px rgba(73, 92, 112, 0.05), inset 0 1px 0 rgba(255, 255, 255, 0.95);
}

.step-nav > button.active::after,
.step-nav > .realtime-nav-item > button.active::after,
.step-nav > .ai-nav-item > button.active::after {
  position: absolute;
  left: 50%;
  bottom: -1px;
  width: 28px;
  height: 3px;
  border-radius: 3px 3px 0 0;
  background: var(--blue);
  content: "";
  transform: translateX(-50%);
}

.realtime-nav-menu {
  z-index: 220;
  top: calc(100% + 10px);
  padding: 7px;
  border-color: rgba(255, 255, 255, 0.95);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 16px 35px rgba(72, 89, 108, 0.16);
  backdrop-filter: blur(18px);
}

.ai-nav-item {
  position: relative;
  min-width: 0;
}

.step-nav .ai-nav-main {
  display: flex;
  width: 100%;
  min-width: 0;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.step-nav .ai-nav-main > span:not(.ai-nav-caret) {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ai-nav-caret {
  display: inline-flex;
  flex: 0 0 16px;
  width: 16px;
  height: 16px;
  align-items: center;
  justify-content: center;
}

.ai-nav-caret::before {
  width: 6px;
  height: 6px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  content: '';
  transform: translateY(-2px) rotate(45deg);
}

.ai-nav-main[aria-expanded="true"] .ai-nav-caret::before {
  transform: translateY(2px) rotate(-135deg);
}

.ai-nav-menu {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  z-index: 220;
  width: 132px;
  padding: 7px;
  border: 1px solid rgba(255, 255, 255, 0.95);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 16px 35px rgba(72, 89, 108, 0.16);
  backdrop-filter: blur(18px);
}

.ai-nav-menu[hidden] {
  display: none;
}

.step-nav .ai-nav-menu button {
  width: 100%;
  min-height: 34px;
  padding: 0 10px;
  border: 0;
  border-radius: 6px;
  color: var(--text);
  background: transparent;
  text-align: left;
}

.step-nav .ai-nav-menu button:hover,
.step-nav .ai-nav-menu button.active {
  color: var(--blue);
  background: var(--blue-soft);
}

.ai-chat-workspace {
  display: grid;
  grid-template-columns: minmax(180px, 212px) minmax(0, 1fr);
  min-height: min(650px, calc(100vh - 238px));
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.9);
  border-radius: 15px;
  background: rgba(255, 255, 255, 0.57);
  box-shadow: 0 14px 38px rgba(72, 89, 108, 0.09), inset 0 1px 0 rgba(255, 255, 255, 0.9);
}

.ai-chat-sidebar {
  display: flex;
  min-height: 0;
  flex-direction: column;
  gap: 14px;
  padding: 15px;
  border-right: 1px solid var(--line);
  background: rgba(247, 249, 252, 0.62);
}

.ai-chat-sidebar-head,
.ai-chat-main-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.ai-chat-main-head-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  min-width: 0;
}

.ai-chat-connection-status {
  display: inline-flex;
  align-items: center;
  width: 24px;
  height: 24px;
  justify-content: center;
  padding: 0;
  border: 0;
  background: transparent;
}

.ai-chat-connection-status i {
  width: 8px;
  height: 8px;
  flex: 0 0 8px;
  border-radius: 50%;
  background: #aab3bf;
  box-shadow: 0 0 0 3px rgba(170, 179, 191, 0.15);
}

.ai-chat-connection-status.is-ready i {
  background: #2eaa68;
  box-shadow: 0 0 0 3px rgba(46, 170, 104, 0.15);
}

.ai-chat-connection-status.is-error i {
  background: #d04545;
  box-shadow: 0 0 0 3px rgba(208, 69, 69, 0.15);
}

.ai-chat-connection-status:hover {
  background: rgba(226, 231, 239, 0.72);
}

.seedance-account-status {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 9px;
  min-height: 28px;
}

.seedance-account-dot {
  position: relative;
  width: 10px;
  height: 10px;
  flex: 0 0 10px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: #aab3bf;
  box-shadow: 0 0 0 3px rgba(170, 179, 191, 0.15);
}

.seedance-account-dot.is-ready {
  background: #2eaa68;
  box-shadow: 0 0 0 3px rgba(46, 170, 104, 0.15);
}

.seedance-account-dot.is-error {
  background: #d04545;
  box-shadow: 0 0 0 3px rgba(208, 69, 69, 0.15);
}

.seedance-account-dot.is-busy {
  animation: seedanceAccountPulse 1.2s ease-in-out infinite;
}

@keyframes seedanceAccountPulse {
  50% { opacity: 0.45; }
}

.seedance-main {
  min-height: 0;
}

.seedance-log {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.seedance-task-result {
  width: 100%;
}

.seedance-message {
  max-width: min(720px, 88%);
}

.seedance-prompt-message > div {
  white-space: pre-wrap;
}

.seedance-prompt-message {
  align-self: flex-end;
}

.seedance-result-message {
  align-self: flex-start;
}

.seedance-result-message > div {
  width: 100%;
}

.seedance-assistant-text {
  align-self: flex-start;
  white-space: pre-wrap;
}

.seedance-assistant-text > div {
  line-height: 1.65;
}

.seedance-attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-bottom: 7px;
}

.seedance-attachment {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 180px;
  padding: 4px 7px 4px 4px;
  border: 1px solid #e3e7ed;
  border-radius: 8px;
  background: #f7f8fa;
  color: #59616d;
  font-size: 11px;
}

.seedance-attachment img {
  width: 28px;
  height: 28px;
  border-radius: 5px;
  object-fit: cover;
}

.seedance-attachment > span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.seedance-attachment button {
  width: 16px;
  height: 16px;
  padding: 0;
  border: 0;
  background: transparent;
  color: #8b939e;
  cursor: pointer;
}

.seedance-attachment.is-uploading {
  opacity: 0.65;
}

.seedance-attach-btn {
  width: 22px;
  height: 22px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #8d96a2;
  cursor: pointer;
  font-size: 19px;
  line-height: 22px;
}

.seedance-attach-btn:hover,
.seedance-attach-btn:focus-visible {
  background: #f0f2f5;
  color: #59616d;
  outline: none;
}

.seedance-status-line {
  display: flex !important;
  align-items: center;
  gap: 8px;
}

.seedance-generating-spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  flex: 0 0 14px;
  border: 2px solid rgba(179, 45, 51, 0.22);
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: seedanceGeneratingSpin 0.8s linear infinite;
}

@keyframes seedanceGeneratingSpin {
  to { transform: rotate(360deg); }
}

.seedance-task-result > header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 9px;
}

.seedance-task-result > header strong,
.seedance-task-result > header small {
  display: block;
}

.seedance-task-result > header small {
  margin-top: 4px;
  color: var(--muted);
}

.seedance-task-result video {
  display: block;
  width: min(100%, 300px);
  aspect-ratio: 9 / 16;
  border-radius: 8px;
  background: #111;
  object-fit: cover;
}

.seedance-empty {
  display: grid;
  min-height: 100%;
  place-items: center;
  color: var(--muted);
  text-align: center;
}

.ai-chat-sidebar-head strong {
  font-size: 16px;
}

.ai-workspace-mode-wrap {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.ai-workspace-tabs {
  display: grid;
  width: 100%;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px;
  padding: 3px;
  border-radius: 12px;
  background: #f3f4f6;
}

.ai-workspace-tabs button {
  min-width: 0;
  min-height: 36px;
  padding: 5px 8px;
  border: 0;
  border-radius: 9px;
  color: #747d89;
  background: transparent;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.ai-workspace-tabs button.active {
  color: #171b22;
  background: #fff;
  box-shadow: 0 4px 12px rgba(30, 37, 49, .09);
}

.ai-workspace-mode-select {
  position: relative;
  min-width: 0;
}

.ai-workspace-mode-button {
  display: flex;
  width: auto;
  min-height: 34px;
  align-items: center;
  justify-content: flex-start;
  gap: 6px;
  padding: 4px 2px;
  border: 0;
  color: var(--ink);
  background: transparent;
  text-align: left;
}

.ai-workspace-mode-button svg {
  width: 15px;
  height: 15px;
  transition: transform 160ms ease;
}

.ai-workspace-mode-button[aria-expanded="true"] svg {
  transform: rotate(180deg);
}

.ai-workspace-mode-menu {
  position: absolute;
  z-index: 30;
  top: calc(100% + 5px);
  left: 0;
  width: 150px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 12px 28px rgba(72, 89, 108, 0.14);
}

.ai-workspace-mode-menu[hidden] {
  display: none;
}

.ai-workspace-mode-menu button {
  display: block;
  width: 100%;
  min-height: 32px;
  padding: 6px 8px;
  border: 0;
  border-radius: 6px;
  color: var(--muted);
  background: transparent;
  text-align: left;
}

.ai-workspace-mode-menu button:hover,
.ai-workspace-mode-menu button.active {
  color: var(--ink);
  background: rgba(226, 231, 239, 0.72);
}

.ai-sidebar-collapse-button {
  display: inline-grid;
  width: 30px;
  height: 30px;
  flex: 0 0 30px;
  place-items: center;
  border: 0;
  border-radius: 7px;
  color: var(--muted);
  background: transparent;
}

.ai-sidebar-collapse-button:hover {
  color: var(--ink);
  background: rgba(226, 231, 239, 0.72);
}

.ai-sidebar-collapse-button svg {
  width: 16px;
  height: 16px;
  transition: transform 160ms ease;
}

.ai-analysis-main {
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

@media (min-width: 761px) {
  .ai-chat-workspace.sidebar-collapsed {
    grid-template-columns: 52px minmax(0, 1fr);
  }

  .ai-chat-workspace.sidebar-collapsed .ai-chat-sidebar {
    padding-right: 10px;
    padding-left: 10px;
  }

  .ai-chat-workspace.sidebar-collapsed .ai-workspace-mode-select,
  .ai-chat-workspace.sidebar-collapsed .ai-chat-thread-section {
    display: none;
  }

.ai-chat-workspace.sidebar-collapsed .ai-workspace-mode-wrap {
    justify-content: center;
  }
}

.ai-analysis-main .stage-grid {
  height: 100%;
}

.ai-chat-section-toggle {
  display: flex;
  width: 100%;
  min-height: 34px;
  align-items: center;
  justify-content: space-between;
  padding: 7px 8px;
  border: 0;
  border-radius: 7px;
  color: var(--muted);
  background: transparent;
  font: inherit;
  font-size: 12px;
  font-weight: 800;
  text-align: left;
  cursor: pointer;
}

.ai-chat-section-toggle:hover,
.ai-chat-section-toggle.is-open {
  color: var(--ink);
  background: rgba(226, 231, 239, 0.62);
}

.ai-chat-section-toggle svg {
  width: 15px;
  height: 15px;
  transition: transform 160ms ease;
}

.ai-chat-section-toggle:not(.is-open) svg {
  transform: rotate(-90deg);
}

.ai-chat-thread-section {
  display: grid;
  min-height: 0;
  gap: 6px;
}

.ai-analysis-thread-section {
  flex: 1 1 auto;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
}

.ai-chat-thread-section[hidden] {
  display: none;
}

.ai-chat-analysis-link {
  display: flex;
  width: 100%;
  min-height: 34px;
  align-items: center;
  justify-content: space-between;
  margin-top: 2px;
  padding: 7px 8px;
  border: 0;
  border-radius: 7px;
  color: var(--muted);
  background: transparent;
  font: inherit;
  font-size: 12px;
  font-weight: 800;
  text-align: left;
  cursor: pointer;
}

.ai-chat-analysis-link:hover,
.ai-chat-analysis-link:focus-visible {
  color: var(--ink);
  background: rgba(226, 231, 239, 0.62);
  outline: none;
}

.ai-chat-analysis-link svg {
  width: 15px;
  height: 15px;
}

.ai-chat-new-thread-row {
  display: flex;
  min-height: 34px;
  align-items: center;
  gap: 8px;
  padding: 7px 8px;
  border: 1px solid rgba(205, 212, 222, 0.85);
  border-radius: 7px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.72);
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  text-align: left;
  cursor: pointer;
}

.ai-chat-new-thread-row svg {
  width: 17px;
  height: 17px;
}

.ai-chat-new-thread-row:hover {
  border-color: rgba(173, 182, 195, 0.95);
  background: #fff;
}

.ai-chat-new-thread-row:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.ai-chat-agent-field {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.ai-chat-agent-field select {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--ink);
  background: var(--surface);
  font: inherit;
  font-size: 13px;
}

.ai-chat-thread-list {
  display: grid;
  min-height: 0;
  align-content: start;
  grid-auto-rows: max-content;
  gap: 5px;
  overflow-y: auto;
}

.ai-chat-thread-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 30px;
  align-items: center;
  gap: 3px;
  border-radius: 7px;
}

.ai-chat-thread-row.active {
  background: var(--blue-soft);
}

.ai-chat-thread-button {
  display: grid;
  min-width: 0;
  gap: 3px;
  padding: 9px 8px;
  border: 0;
  border-radius: 7px;
  color: var(--ink);
  background: transparent;
  text-align: left;
}

.ai-chat-thread-title-input,
.ai-chat-title-input {
  width: 100%;
  min-width: 0;
  height: 34px;
  padding: 5px 8px;
  border: 1px solid var(--blue);
  border-radius: 7px;
  background: var(--surface);
  color: var(--ink);
  font-size: 13px;
  outline: none;
}

.ai-chat-title-input {
  width: min(420px, 100%);
  height: 32px;
  font-size: 17px;
  font-weight: 800;
}

.ai-chat-thread-button strong,
.ai-chat-thread-button small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ai-chat-thread-button strong {
  font-size: 13px;
  font-weight: 750;
}

.ai-chat-thread-button small,
.ai-chat-thread-empty {
  color: var(--muted);
  font-size: 12px;
}

.ai-chat-thread-delete {
  display: inline-grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border: 0;
  border-radius: 6px;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  opacity: 0;
  transition: opacity 140ms ease, color 140ms ease, background 140ms ease;
}

.ai-chat-thread-row:hover .ai-chat-thread-delete,
.ai-chat-thread-delete:focus-visible {
  opacity: 1;
}

.ai-chat-thread-delete:hover {
  color: var(--red);
  background: var(--red-soft);
}

.ai-chat-main {
  display: grid;
  min-width: 0;
  min-height: 0;
  grid-template-rows: auto minmax(0, 1fr) auto;
}

.ai-chat-main-head {
  min-height: 72px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
}

.ai-chat-main-head h2 {
  max-width: 42ch;
  overflow: hidden;
  font-size: 17px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ai-chat-main-head p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.ai-chat-model-select {
  width: min(210px, 42vw);
  height: 36px;
  padding: 0 30px 0 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--ink);
  background: var(--surface);
  font: inherit;
  font-size: 13px;
  font-weight: 700;
}

.ai-chat-main-head > .ai-chat-model-select {
  display: none;
}

.ai-chat-model-select:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.ai-chat-log {
  display: grid;
  min-height: 0;
  align-content: start;
  gap: 14px;
  padding: 18px;
  overflow-y: auto;
}

.ai-chat-log.is-empty {
  align-content: center;
  place-items: center;
}

.ai-chat-message {
  display: grid;
  width: fit-content;
  max-width: min(760px, 88%);
  gap: 6px;
}

.ai-chat-message > span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.ai-chat-message > div {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: var(--surface);
  font-size: 14px;
  line-height: 1.7;
  overflow-wrap: anywhere;
}

.ai-chat-message.assistant {
  width: min(760px, 88%);
}

.ai-chat-message.assistant > div {
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
}

.ai-chat-message.user {
  justify-self: end;
}

.ai-chat-message.user > div {
  border-color: rgba(255, 255, 255, 0.9);
  background: var(--blue-soft);
}

.ai-chat-message.pending {
  opacity: 0.72;
}

.ai-chat-typing {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--blue);
  box-shadow: 10px 0 0 rgba(179, 45, 51, 0.62), 20px 0 0 rgba(179, 45, 51, 0.3);
  animation: aiChatTyping 1.05s ease-in-out infinite;
}

@keyframes aiChatTyping {
  50% { opacity: 0.25; }
}

.ai-chat-welcome {
  align-self: center;
  justify-self: center;
  max-width: 330px;
  padding: 20px;
  color: var(--muted);
  text-align: center;
}

.ai-chat-welcome strong {
  display: block;
  color: var(--ink);
  font-size: 15px;
}

.ai-chat-welcome p {
  margin-top: 6px;
  font-size: 13px;
  line-height: 1.6;
}

.ai-chat-composer {
  display: grid;
  min-height: 116px;
  margin: 0 18px 18px;
  padding: 14px 16px 10px;
  border: 1px solid rgba(214, 220, 229, 0.9);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 8px 22px rgba(72, 89, 108, 0.08), inset 0 1px 0 rgba(255, 255, 255, 0.96);
}

.ai-chat-composer textarea {
  width: 100%;
  height: 58px;
  min-height: 58px;
  max-height: 58px;
  padding: 1px 2px;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  color: var(--ink);
  font-size: 15px;
  line-height: 1.6;
  resize: none;
  scrollbar-width: none;
}

.ai-chat-composer textarea:focus {
  border: 0;
  box-shadow: none;
  outline: none;
}

.ai-chat-composer textarea::placeholder {
  color: #8a929d;
}

.ai-chat-composer textarea::-webkit-scrollbar {
  display: none;
}

.ai-chat-composer-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  min-height: 34px;
  padding-top: 8px;
  border-top: 1px solid #edf0f4;
}

.ai-chat-composer-hint {
  margin-right: auto;
  color: #9aa1ab;
  font-size: 11px;
}

.ai-chat-composer-model-select {
  width: 145px;
  max-width: 145px;
  height: 32px;
  padding: 0 26px 0 8px;
  border: 0;
  border-radius: 8px;
  color: #4f5661;
  appearance: none;
  -webkit-appearance: none;
  background-color: transparent;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-position: right 7px center;
  background-repeat: no-repeat;
  background-size: 14px 14px;
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  text-align: right;
  text-align-last: right;
}

.ai-chat-composer-model-select option {
  text-align: left;
}

.ai-chat-composer-model-select:hover,
.ai-chat-composer-model-select:focus {
  border-color: transparent;
  background-color: transparent;
  box-shadow: none;
  outline: none;
}

.ai-chat-composer-actions #aiChatComposerModelSelect,
.ai-chat-composer-actions #aiChatComposerModelSelect:hover,
.ai-chat-composer-actions #aiChatComposerModelSelect:focus {
  border: 0 !important;
  border-radius: 0;
  background-color: transparent !important;
  box-shadow: none !important;
  outline: 0;
}

.ai-chat-send-btn {
  display: inline-grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border: 0;
  border-radius: 10px;
  color: #fff;
  background: var(--blue);
  cursor: pointer;
}

.ai-chat-send-btn svg {
  width: 17px;
  height: 17px;
}

.ai-chat-send-btn:hover {
  background: var(--blue-dark, #142d58);
}

.ai-chat-send-btn:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

@media (max-width: 760px) {
  .step-nav > .ai-nav-item {
    min-width: 82px;
    flex: 0 0 82px;
    scroll-snap-align: start;
  }

  .ai-chat-workspace {
    min-height: calc(100vh - 205px);
    grid-template-columns: minmax(0, 1fr);
  }

  .ai-chat-sidebar {
    gap: 8px;
    padding: 10px 12px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .ai-chat-thread-list {
    display: flex;
    overflow-x: auto;
    overflow-y: hidden;
  }

  .ai-chat-thread-row {
    flex: 0 0 150px;
  }

  .ai-chat-main-head,
  .ai-chat-composer {
    padding-right: 12px;
    padding-left: 12px;
  }

  .ai-chat-composer {
    margin-right: 12px;
    margin-bottom: 12px;
    margin-left: 12px;
  }

  .ai-chat-composer-hint {
    display: none;
  }

  .ai-chat-log {
    padding: 14px 12px;
  }
}

/* External mobile-first source actions: two clear standalone operations. */
#externalSourceMethodSwitch.source-method-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 8px;
  padding: 0;
  margin: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
}

#externalSourceMethodSwitch .source-method-action {
  position: relative;
  display: flex;
  width: 100%;
  min-height: 72px;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 4px;
  padding: 13px 16px 13px 20px;
  border: 1px solid rgba(179, 45, 51, 0.16);
  border-radius: 12px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.72);
  text-align: left;
  box-shadow: 0 5px 16px rgba(72, 89, 108, 0.06);
}

#externalSourceMethodSwitch .source-method-action::before {
  position: absolute;
  top: 13px;
  bottom: 13px;
  left: 8px;
  width: 3px;
  border-radius: 3px;
  background: transparent;
  content: "";
}

#externalSourceMethodSwitch .source-method-action strong {
  font-size: 14px;
  font-weight: 800;
}

#externalSourceMethodSwitch .source-method-action small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  line-height: 1.45;
}

#externalSourceMethodSwitch .source-method-action:hover {
  border-color: rgba(179, 45, 51, 0.32);
  background: rgba(255, 255, 255, 0.94);
}

#externalSourceMethodSwitch .source-method-action.active {
  border-color: rgba(179, 45, 51, 0.30);
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 8px 20px rgba(179, 45, 51, 0.10);
}

#externalSourceMethodSwitch .source-method-action.active::before {
  background: var(--blue);
}

#externalSourceMethodSwitch .source-method-action.active::after {
  display: none;
}

/* Mobile navigation follows the Xiaohongshu pattern: bottom navigation is the
   primary control, while the small workspace nav stays quiet and swipeable. */
@media (max-width: 760px) {
  .app-shell {
    padding-bottom: calc(100px + env(safe-area-inset-bottom));
  }

  .step-nav {
    right: 8px;
    bottom: 10px;
    left: 8px;
    min-height: 68px;
    align-items: stretch;
    padding: 7px 6px calc(7px + env(safe-area-inset-bottom));
    border: 1px solid rgba(215, 221, 230, 0.92);
    border-radius: 18px;
    box-shadow: 0 10px 28px rgba(39, 52, 70, 0.18), inset 0 1px 0 rgba(255, 255, 255, 0.98);
  }

  .step-nav > button,
  .step-nav > .realtime-nav-item,
  .step-nav > .ai-nav-item {
    min-height: 52px;
  }

  .step-nav > button,
  .step-nav > .realtime-nav-item > button,
  .step-nav > .ai-nav-item > button {
    min-height: 52px;
    padding: 6px 3px;
    border: 0;
    border-radius: 13px;
    color: #778293;
    background: transparent;
    font-size: 13px;
    font-weight: 800;
  }

  .step-nav > button.active,
  .step-nav > .ai-nav-item > button.active {
    color: var(--ink);
    background: #f4f6f9;
    box-shadow: none;
  }

  .step-nav > button.active::after,
  .step-nav > .ai-nav-item > button.active::after {
    display: none;
  }

  .workspace-subnav {
    display: flex;
    overflow-x: auto;
    gap: 18px;
    margin: 0 0 10px;
    padding: 2px 2px 5px;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    scrollbar-width: none;
    overscroll-behavior-x: contain;
    -webkit-overflow-scrolling: touch;
  }

  .workspace-subnav::-webkit-scrollbar {
    display: none;
  }

  .workspace-subnav button {
    position: relative;
    flex: 0 0 auto;
    min-height: 34px;
    padding: 4px 2px;
    border: 0;
    border-radius: 0;
    color: #7a8492;
    background: transparent;
    box-shadow: none;
    font-size: 14px;
  }

  .workspace-subnav button.active {
    color: var(--ink);
    background: transparent;
    box-shadow: none;
  }

  .workspace-subnav button.active::before {
    top: auto;
    right: 18%;
    bottom: -2px;
    left: 18%;
    width: auto;
    height: 3px;
    border-radius: 99px;
    background: var(--blue);
  }

  .ai-chat-workspace {
    min-height: calc(100dvh - 190px);
    gap: 0;
  }

  .ai-chat-sidebar {
    min-height: 0;
    padding: 8px 10px;
    border-bottom: 1px solid #e8ecf1;
  }

  .ai-chat-main {
    min-height: 0;
  }

  .ai-chat-main-head {
    min-height: 46px;
    padding: 8px 12px;
  }

  .ai-chat-log {
    min-height: 170px;
    padding: 12px;
  }

  .ai-chat-composer {
    min-height: 118px;
    margin: 8px 10px 10px;
    padding: 10px 11px 8px;
    border-radius: 14px;
    box-shadow: 0 5px 16px rgba(72, 89, 108, 0.08);
  }

  .ai-chat-composer textarea {
    height: 64px;
    min-height: 64px;
    max-height: 64px;
    font-size: 14px;
  }

  .ai-chat-composer-actions {
    min-height: 28px;
    gap: 4px;
    padding-top: 5px;
  }

  .ai-chat-composer-model-select {
    width: 118px;
    max-width: 118px;
    height: 28px;
    font-size: 12px;
  }

  .ai-chat-send-btn {
    width: 30px;
    height: 30px;
    border-radius: 9px;
  }

  .personal-library-header {
    align-items: flex-start;
    gap: 8px;
  }

  .personal-library-summary {
    min-width: auto;
    padding: 7px 9px;
    border-radius: 10px;
    font-size: 12px;
    white-space: nowrap;
  }

  .personal-library-toolbar {
    gap: 8px;
  }

  .personal-library-filters {
    display: flex;
    overflow-x: auto;
    gap: 7px;
    padding-bottom: 2px;
    scrollbar-width: none;
  }

  .personal-library-filters::-webkit-scrollbar {
    display: none;
  }

  .personal-library-filters button {
    flex: 0 0 auto;
    min-height: 36px;
    padding: 0 12px;
    border-radius: 18px;
    font-size: 13px;
  }

  .rewrite-course-picker {
    padding: 10px 12px;
    border: 0;
    border-radius: 12px;
    background: #f5f7fa;
  }

  .rewrite-mode-switch {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 7px;
    padding: 0;
    border: 0;
    background: transparent;
  }

  .rewrite-mode-switch button:first-child {
    grid-column: 1 / -1;
    min-height: 48px;
  }
}

/* Final mobile polish: center the primary navigation and remove decorative
   selection bars that compete with the content. */
@media (max-width: 760px) {
  .step-nav {
    grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
    justify-items: stretch;
    align-items: center;
  }

  .step-nav > button,
  .step-nav > .ai-nav-item {
    grid-column: span 1 !important;
    display: grid;
    place-items: center;
    width: 100%;
  }

  .step-nav > button[hidden] {
    display: none !important;
  }

  .step-nav > button,
  .step-nav > .ai-nav-item > button {
    font-size: 15px !important;
    font-weight: 800;
    text-align: center;
  }

  .step-nav > button.active,
  .step-nav > .ai-nav-item > button.active {
    color: var(--ink);
    background: #eef2f6;
    box-shadow: 0 6px 14px rgba(44, 57, 73, 0.10) !important;
  }

  .workspace-subnav button.active::before {
    display: none !important;
  }

  .workspace-subnav button.active {
    padding-right: 12px;
    padding-left: 12px;
    border-radius: 10px;
    background: #f3f5f8;
    box-shadow: 0 4px 12px rgba(44, 57, 73, 0.08);
  }

  #sourcePanelHelp {
    display: none !important;
  }

  #sourceLinksLabel {
    display: none !important;
  }

  #sourcePlatformNotice {
    display: none !important;
  }

  #sourceLinks {
    margin-top: 0;
  }

  #externalSourceMethodSwitch .source-method-action::before {
    display: none;
  }

  #externalSourceMethodSwitch .source-method-action.active {
    background: #f1f3f6;
    border-color: rgba(179, 45, 51, 0.22);
    box-shadow: 0 8px 20px rgba(179, 45, 51, 0.12);
  }

  .source-workspace-nav,
  .creation-workspace-nav {
    justify-content: center;
    width: fit-content;
    max-width: 100%;
    margin-right: auto;
    margin-left: auto;
    gap: 8px;
  }

  .source-workspace-nav button,
  .creation-workspace-nav button {
    min-width: 94px;
    padding-right: 12px;
    padding-left: 12px;
    text-align: center;
  }

  #externalSourceMethodSwitch.source-method-actions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  #externalSourceMethodSwitch .source-method-action {
    min-height: 48px;
    align-items: center;
    justify-content: center;
    padding: 8px 7px;
    text-align: center;
  }

  #externalSourceMethodSwitch .source-method-action strong { font-size: 14px; }
  #externalSourceMethodSwitch .source-method-action small { display: none; }

  .ai-chat-workspace {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr);
  }

  .ai-chat-sidebar { display: contents; }
  .ai-chat-sidebar-head {
    display: flex;
    grid-row: 1;
    min-height: 48px;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    border-bottom: 1px solid var(--line);
  }
  .ai-chat-thread-section,
  .ai-chat-sidebar .ai-sidebar-collapse-button { display: none !important; }
  .ai-chat-main {
    grid-row: 2;
    min-height: 0;
  }
  .ai-chat-main-head { display: none; }
  .ai-chat-log { min-height: 0; padding: 14px 12px; }
  .ai-chat-composer {
    min-height: 118px;
    margin: 6px 10px 8px;
    padding: 8px 10px 7px;
    border-radius: 14px;
  }
  .ai-chat-composer textarea {
    height: 64px;
    min-height: 64px;
    max-height: 64px;
    font-size: 14px;
  }
  .ai-chat-composer-actions { min-height: 26px; padding-top: 4px; gap: 4px; }
  .ai-chat-composer-model-select {
    width: 96px;
    max-width: 96px;
    height: 26px;
    padding-right: 19px;
    font-size: 12px;
  }
  .ai-chat-send-btn { width: 30px; height: 30px; }

  .rewrite-course-picker {
    display: grid;
    gap: 8px;
    padding: 0;
    border: 0;
    background: transparent;
  }
  .rewrite-course-control { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; }
  #rewriteProfileUrl { min-width: 0; min-height: 44px; }
  #addRewriteCourseBtn { min-height: 44px; white-space: nowrap; }
  #rewriteCourseId { display: none; }
  .rewrite-mode-switch {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
    padding: 0;
    border: 0;
    background: transparent;
  }
  .rewrite-mode-switch button {
    min-height: 44px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--surface);
  }
  .rewrite-mode-switch button:first-child {
    grid-column: 1 / -1;
    min-height: 50px;
  }
  .rewrite-action-row { margin-top: 10px; }
  #makeRewriteBtn { width: 100%; min-height: 48px; }
  #clearFinalScriptBtn { display: none !important; }

  .personal-library-header {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: start;
    gap: 8px;
  }
  .personal-library-header > div:first-child { grid-column: 1 / -1; }
  .personal-library-header .personal-library-summary { grid-column: 1 / -1; justify-self: start; }
  .personal-library-header .personal-library-filters {
    grid-column: 1 / -1;
    width: 100%;
    order: 3;
  }
  .personal-library-toolbar { display: block; }
  .personal-library-toolbar input { width: 100%; }
}

/* Mobile refinements for the final four-screen navigation. */
@media (max-width: 760px) {
  .rewrite-mode-switch {
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
  }
  .rewrite-mode-switch button,
  .rewrite-mode-switch button:first-child {
    grid-column: auto !important;
    min-width: 0;
    min-height: 44px;
    padding: 5px 3px;
    font-size: 12px;
    line-height: 1.2;
  }
  .rewrite-inline-generate-btn {
    display: block;
    width: 100%;
    min-height: 48px;
    margin: 10px 0 12px;
  }
  .rewrite-framework-active .rewrite-action-row { display: none !important; }
  .seedance-log {
    min-height: 0;
    justify-content: center;
  }
  .seedance-empty {
    width: 100%;
    min-height: 180px;
    align-self: center;
    place-items: center;
  }
  .seedance-empty > div {
    width: 100%;
    text-align: center;
  }
  #seedanceLog {
    display: grid !important;
    place-items: center;
  }
  #seedanceLog .seedance-empty {
    min-height: 0;
  }
  .personal-library-header {
    grid-template-columns: minmax(0, 1fr) !important;
  }
  .personal-library-header .personal-library-filters {
    grid-column: 1 / -1;
  }
}

/* Keep the conversation frame fixed while only the message stream scrolls. */
.ai-chat-workspace {
  height: 100%;
  min-height: 0;
}

.ai-chat-main {
  overflow: hidden;
}

.ai-chat-log {
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
}

@media (max-width: 980px) {
  .ai-chat-workspace {
    height: calc(100dvh - 172px);
    min-height: 360px;
  }

  .ai-chat-sidebar {
    min-height: 0;
  }

  .ai-chat-thread-section {
    min-height: 0;
    overflow: hidden;
  }

  .ai-chat-thread-list {
    min-height: 0;
    max-height: 126px;
    overflow-y: auto;
  }
}

.panel,
.chanmama-collector-panel,
.knowledge-elements-panel,
.rewrite-panel {
  border-color: rgba(255, 255, 255, 0.90);
  border-radius: 15px;
  background: rgba(255, 255, 255, 0.57);
  box-shadow: 0 14px 38px rgba(72, 89, 108, 0.09), inset 0 1px 0 rgba(255, 255, 255, 0.90);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
}

input,
textarea,
select {
  border-color: var(--line);
  border-radius: 10px;
  background-color: rgba(255, 255, 255, 0.80);
  font-weight: 500;
}

input:focus,
textarea:focus,
select:focus {
  border-color: rgba(179, 45, 51, 0.58);
  box-shadow: 0 0 0 3px rgba(179, 45, 51, 0.10);
}

.primary-btn,
.ghost-btn {
  min-height: 42px;
  border-radius: 9px;
  font-weight: 650;
}

.primary-btn {
  background: var(--blue);
  box-shadow: 0 10px 22px rgba(179, 45, 51, 0.18);
}

.ghost-btn {
  border-color: var(--line);
  background: rgba(255, 255, 255, 0.70);
}

.chanmama-category-tabs {
  gap: 6px;
  padding: 7px;
  margin-bottom: 14px;
  border: 1px solid rgba(255, 255, 255, 0.88);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.43);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.90);
}

.chanmama-category-tabs:empty {
  display: none;
}

.chanmama-category-tabs button {
  min-height: 48px;
  border-color: transparent;
  border-radius: 9px;
  color: #6f7a86;
  background: transparent;
  font-size: 14px;
  font-weight: 600;
}

.chanmama-category-tabs button:hover {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.46);
}

.chanmama-category-tabs button.active {
  border-color: rgba(255, 255, 255, 0.90);
  color: var(--ink);
  background: rgba(255, 255, 255, 0.76);
  box-shadow: 0 8px 18px rgba(72, 89, 108, 0.10), inset 0 1px 0 rgba(255, 255, 255, 0.98);
}

.chanmama-category-tabs button.active span {
  color: var(--blue);
}

.chanmama-grid-card,
.source-material-card,
.version-card,
.mini-card,
.element-subtype-card,
.pending-element-card,
.rewrite-framework-card,
.rewrite-block,
.fission-card,
.final-script-history-card,
.knowledge-search-result {
  border-color: rgba(255, 255, 255, 0.90);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.62);
  box-shadow: 0 10px 26px rgba(72, 89, 108, 0.08), inset 0 1px 0 rgba(255, 255, 255, 0.94);
}

.source-queue-head,
.knowledge-searchbar,
.knowledge-coursebar,
.rewrite-title-line,
.rewrite-versions-bar {
  border-color: rgba(255, 255, 255, 0.90);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.68);
  box-shadow: 0 8px 20px rgba(72, 89, 108, 0.06);
}

.rewrite-framework-card.active,
.rewrite-block.active,
.knowledge-search-result:hover {
  border-color: rgba(179, 45, 51, 0.24);
  background: rgba(255, 255, 255, 0.84);
  box-shadow: 0 10px 24px rgba(72, 89, 108, 0.10), inset 3px 0 0 var(--blue);
}

.chat-msg.assistant {
  border: 1px solid rgba(255, 255, 255, 0.90);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.70);
  box-shadow: 0 8px 20px rgba(72, 89, 108, 0.06);
}

.chat-msg.user {
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.70);
  box-shadow: 0 8px 20px rgba(72, 89, 108, 0.06);
}

section[data-stage="elements"].active .panel {
  border-color: rgba(255, 255, 255, 0.90);
}

section[data-stage="elements"] .scope-select-card {
  background: rgba(255, 255, 255, 0.70);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.92);
}

section[data-stage="elements"] .scope-select-card select {
  border-color: var(--line);
}

.auth-overlay,
.library-confirm-overlay,
.chanmama-save-overlay {
  background: rgba(23, 32, 43, 0.22);
  backdrop-filter: blur(8px);
}

.auth-modal,
.library-confirm-modal,
.text-input-modal,
.course-create-modal,
.course-profile-modal,
.chanmama-player-modal,
.chanmama-save-dialog {
  border-color: rgba(255, 255, 255, 0.92);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: 0 18px 50px rgba(72, 89, 108, 0.14);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

@media (max-width: 1050px) {
  .app-shell {
    width: min(calc(100% - 40px), 920px);
  }
}

@media (max-width: 680px) {
  .rewrite-profile-source-controls {
    grid-template-columns: minmax(0, 1fr) 126px;
  }

  .rewrite-profile-source-controls > .primary-btn {
    padding-inline: 8px;
    font-size: 12px;
    white-space: nowrap;
  }

  .app-shell {
    width: 100%;
    padding: 18px 12px 28px;
  }

  .hero {
    min-height: 50px;
    margin-bottom: 16px;
  }

  .brand-logo {
    height: 40px;
  }

  .brand-subtitle,
  .header-stats {
    display: none;
  }

  .step-nav {
    gap: 5px;
    padding: 6px;
    border-radius: 12px;
  }

  .step-nav button {
    min-height: 48px;
    padding-inline: 4px;
    border-radius: 9px;
    font-size: 12px;
  }

  #realtimeNavLabel {
    font-size: 0;
  }

  #realtimeNavLabel::before {
    color: inherit;
    content: "实时";
    font-size: 12px;
  }

  .panel,
  .chanmama-collector-panel,
  .knowledge-elements-panel,
  .rewrite-panel {
    border-radius: 13px;
  }

  .chanmama-category-tabs {
    padding: 6px;
  }

  .chanmama-category-tabs button {
    min-height: 44px;
    padding-inline: 14px;
    font-size: 12px;
  }
}

/* Digital human workflow */
.digital-human-grid {
  grid-template-columns: minmax(0, 1fr);
}

.digital-human-panel {
  min-width: 0;
}

.digital-human-panel > .panel-head {
  align-items: flex-end;
}

.digital-human-workflow {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  margin-top: 20px;
}

.digital-human-card {
  min-width: 0;
  padding: 20px;
  border: 1px solid rgba(224, 229, 235, 0.95);
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 8px 24px rgba(40, 52, 66, 0.05);
}

.digital-human-card:nth-child(2) {
  display: flex;
  flex-direction: column;
}

.digital-human-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.digital-human-card-head > div {
  display: grid;
  gap: 5px;
}

.digital-human-card-head strong {
  color: var(--ink);
  font-size: 16px;
}

.digital-human-card-head span {
  color: #7b8590;
  font-size: 12px;
}

.digital-human-avatar-column .digital-human-card-head,
.digital-human-result-column .digital-human-card-head {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  margin-bottom: 14px;
  padding: 0 8px;
  text-align: center;
}

.digital-human-avatar-column .digital-human-card-head strong,
.digital-human-result-column .digital-human-card-head strong {
  font-size: 16px;
  font-weight: 700;
}

.digital-human-view-all {
  position: absolute;
  right: 2px;
  min-height: 30px;
  padding: 0 4px;
  border: 0;
  color: var(--blue);
  background: transparent;
  font-size: 12px;
  font-weight: 700;
}

.digital-human-view-all:hover {
  text-decoration: underline;
}

.digital-human-view-all[hidden] {
  display: none !important;
}

.digital-human-status {
  flex: 0 0 auto;
  color: #7b8590;
  font-size: 12px;
}

.digital-human-health {
  position: absolute;
  top: 50%;
  left: 8px;
  z-index: 8;
  transform: translateY(-50%);
}

.digital-human-health-toggle {
  display: grid;
  width: 24px;
  height: 24px;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 8px rgba(39, 48, 58, 0.14);
}

.digital-human-health-toggle:hover,
.digital-human-health-toggle[aria-expanded="true"] {
  background: #f4f6f8;
}

.digital-human-health-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #a5adb5;
  box-shadow: 0 0 0 3px rgba(165, 173, 181, 0.14);
}

.digital-human-health[data-status="healthy"] .digital-human-health-dot {
  background: #1f9d62;
  box-shadow: 0 0 0 3px rgba(31, 157, 98, 0.14);
}

.digital-human-health[data-status="error"] .digital-human-health-dot {
  background: #c44343;
  box-shadow: 0 0 0 3px rgba(196, 67, 67, 0.14);
}

.digital-human-health-popover {
  position: absolute;
  top: 32px;
  left: 0;
  display: grid;
  width: min(290px, calc(100vw - 48px));
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 14px 36px rgba(39, 48, 58, 0.2);
  text-align: left;
}

.digital-human-health-popover[hidden] {
  display: none !important;
}

.digital-human-health-copy {
  display: grid;
  min-width: 0;
  gap: 3px;
}

.digital-human-health-copy strong {
  color: var(--ink);
  font-size: 12px;
}

.digital-human-health-copy small {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.45;
}

.digital-human-health .icon-btn {
  width: 32px;
  min-width: 32px;
  height: 32px;
}

.digital-human-field,
.digital-human-upload {
  display: grid;
  gap: 8px;
}

.digital-human-field > span,
.digital-human-upload > span {
  color: var(--ink);
  font-size: 13px;
  font-weight: 600;
}

.digital-human-field textarea {
  width: 100%;
  min-height: 164px;
  resize: vertical;
}

.digital-human-upload-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 14px;
}

.digital-human-selected-row,
.digital-human-selected-avatar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-height: 68px;
  padding: 12px 14px;
  border: 1px solid #e0e5eb;
  border-radius: 6px;
  background: #fbfcfd;
}

.digital-human-selected-row > div,
.digital-human-selected-avatar > div {
  display: grid;
  min-width: 0;
  gap: 6px;
}

.digital-human-selected-row span,
.digital-human-selected-avatar span {
  color: #7b8590;
  font-size: 12px;
}

.digital-human-selected-row strong,
.digital-human-selected-avatar strong {
  overflow: hidden;
  color: var(--ink);
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.digital-human-selected-avatar video {
  flex: 0 0 64px;
  width: 64px;
  height: 64px;
  border-radius: 5px;
  background: #20252b;
  object-fit: cover;
}

.digital-human-selected-avatar video[hidden] {
  display: none !important;
}

.digital-human-upload-compact {
  min-height: 0;
  margin-top: 12px;
}

.digital-human-upload {
  min-width: 0;
  padding: 13px;
  border: 1px dashed #d8dee6;
  border-radius: 6px;
  background: #fafbfc;
}

.digital-human-upload input {
  width: 100%;
  min-width: 0;
  color: #66717d;
  font-size: 12px;
}

.digital-human-upload em {
  overflow: hidden;
  color: #89929c;
  font-size: 12px;
  font-style: normal;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.digital-human-avatar-upload {
  flex: 1 1 auto;
  min-height: 112px;
  align-content: center;
}

.digital-human-avatar-list {
  display: grid;
  gap: 8px;
  max-height: 170px;
  margin-top: 4px;
  overflow-y: auto;
}

.digital-human-avatar-list[hidden] {
  display: none !important;
}

.digital-human-avatar-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  min-height: 40px;
  padding: 9px 11px;
  border: 1px solid #dce2e9;
  border-radius: 5px;
  color: var(--ink);
  background: #fff;
  text-align: left;
}

.digital-human-avatar-option:hover {
  border-color: rgba(179, 45, 51, 0.45);
}

.digital-human-avatar-option.active {
  border-color: rgba(179, 45, 51, 0.65);
  background: rgba(179, 45, 51, 0.06);
}

.digital-human-avatar-option strong {
  min-width: 0;
  overflow: hidden;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.digital-human-avatar-option span {
  flex: 0 0 auto;
  color: #8a939d;
  font-size: 11px;
}

.digital-human-action {
  width: 100%;
  margin-top: 16px;
}

.digital-human-player {
  display: block;
  width: 100%;
  max-height: 360px;
  margin-top: 16px;
  border-radius: 6px;
  background: transparent;
}

video.digital-human-player {
  background: #111820;
}

.digital-human-player[hidden],
.digital-human-download[hidden] {
  display: none !important;
}

.digital-human-download {
  display: inline-flex;
  margin-top: 12px;
  color: var(--blue);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
}

.digital-human-download:hover {
  text-decoration: underline;
}

.digital-human-task-status {
  min-height: 20px;
  margin-top: 12px;
  color: #7b8590;
  font-size: 12px;
  line-height: 1.6;
}

.digital-human-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(28, 35, 43, 0.48);
}

.digital-human-rename-overlay {
  z-index: 1100;
}

.digital-human-modal[hidden] {
  display: none !important;
}

.digital-human-modal-dialog {
  display: grid;
  grid-template-rows: auto auto auto minmax(220px, 1fr) auto;
  width: min(820px, 100%);
  max-height: min(640px, calc(100dvh - 40px));
  padding: 20px;
  border: 1px solid #e3e7ec;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 24px 70px rgba(35, 43, 52, 0.25);
}

.digital-human-avatar-modal-dialog {
  grid-template-rows: auto auto minmax(220px, 1fr) auto;
}

.digital-human-video-modal-dialog {
  grid-template-rows: auto minmax(0, 1fr);
  width: min(1040px, 100%);
  max-height: min(780px, calc(100dvh - 40px));
}

.digital-human-all-video-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-content: start;
  gap: 16px;
  min-height: 0;
  padding: 16px 2px 2px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.digital-human-all-video-list .digital-human-result-item {
  align-content: start;
  padding: 10px;
  border: 1px solid #e0e5eb;
  border-radius: 8px;
  background: #f7f8fa;
}

.digital-human-all-video-list .digital-human-result-item:last-child {
  padding-bottom: 10px;
  border: 1px solid #e0e5eb;
}

.digital-human-all-video-list .digital-human-result-item video {
  max-height: 470px;
}

.digital-human-modal-head,
.digital-human-modal-foot {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 16px;
}

.digital-human-modal-head {
  justify-content: space-between;
  padding-bottom: 14px;
  border-bottom: 1px solid #edf0f3;
}

.digital-human-modal-head h3 {
  margin: 0;
  color: var(--ink);
  font-size: 18px;
}

.digital-human-modal-close {
  width: 32px;
  height: 32px;
  border: 0;
  color: #7b8590;
  background: transparent;
  font-size: 24px;
}

.digital-human-modal-tabs {
  display: flex;
  gap: 22px;
  border-bottom: 1px solid #edf0f3;
}

.digital-human-modal-tabs button {
  min-height: 46px;
  padding: 0 4px;
  border: 0;
  border-bottom: 2px solid transparent;
  color: #8a939d;
  background: transparent;
  font-size: 13px;
  font-weight: 700;
}

.digital-human-modal-tabs button.active {
  color: var(--blue);
  border-bottom-color: var(--blue);
}

.digital-human-modal-filters {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 0;
  color: #68737e;
  font-size: 12px;
}

.digital-human-modal-filters button {
  min-height: 30px;
  padding: 0 13px;
  border: 1px solid #dce2e8;
  border-radius: 4px;
  color: #66717d;
  background: #fff;
}

.digital-human-modal-filters button.active {
  color: #fff;
  border-color: var(--blue);
  background: var(--blue);
}

.digital-human-gender-filter {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  min-height: 34px;
  gap: 4px;
  padding: 0 8px;
  border: 1px solid #dce2e8;
  border-radius: 6px;
  background: #fff;
}

.digital-human-gender-filter > span {
  padding-right: 4px;
  color: #68737e;
}

.digital-human-modal-filters .digital-human-gender-filter button,
.digital-human-modal-filters .digital-human-gender-filter button.active {
  min-height: 28px;
  padding: 0 7px;
  border: 0;
  border-radius: 4px;
  color: #68737e;
  background: transparent;
  font-weight: 600;
}

.digital-human-modal-filters .digital-human-gender-filter button.active {
  color: var(--blue);
  font-weight: 800;
}

.digital-human-modal-filters input {
  flex: 1 1 240px;
  min-width: 160px;
  min-height: 34px;
  margin-left: 10px;
}

.digital-human-avatar-filters #digitalHumanAvatarSearch {
  flex-basis: 160px;
  min-width: 120px;
  margin-left: 4px;
}

.digital-human-teacher-filter {
  flex: 1 1 auto;
  min-width: 0;
  gap: 2px;
  overflow-x: auto;
  scrollbar-width: thin;
}

.digital-human-add-ip-btn {
  flex: 0 0 auto;
  white-space: nowrap;
}

.digital-human-library-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-auto-rows: max-content;
  align-content: start;
  gap: 10px;
  min-height: 220px;
  max-height: min(420px, calc(100dvh - 270px));
  padding: 2px;
  overflow-y: auto;
}

.digital-human-library-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  min-height: 68px;
  padding: 10px;
  border: 1px solid #e0e5eb;
  border-radius: 6px;
  color: var(--ink);
  background: #fff;
  text-align: left;
}

.digital-human-library-actions {
  position: absolute;
  right: 8px;
  bottom: 5px;
  display: flex;
  gap: 3px;
}

.digital-human-library-action {
  display: grid;
  width: 26px;
  height: 26px;
  place-items: center;
  border-radius: 5px;
  color: #68717d;
  cursor: pointer;
}

.digital-human-library-action svg {
  width: 15px;
  height: 15px;
}

.digital-human-library-rename:hover,
.digital-human-library-rename:focus-visible {
  color: var(--blue);
  background: #edf3f8;
  outline: none;
}

.digital-human-library-delete {
  color: #9b3b3f;
}

.digital-human-library-delete:hover,
.digital-human-library-delete:focus-visible {
  color: #b32d33;
  background: #fbefef;
  outline: none;
}

.digital-human-library-item:hover,
.digital-human-library-item.active {
  border-color: rgba(179, 45, 51, 0.65);
  background: rgba(179, 45, 51, 0.05);
}

.digital-human-library-play {
  display: grid;
  flex: 0 0 32px;
  width: 32px;
  height: 32px;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  background: var(--blue);
  font-size: 11px;
}

.digital-human-library-copy {
  display: grid;
  min-width: 0;
  gap: 5px;
}

.digital-human-library-copy strong {
  overflow: hidden;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.digital-human-library-copy small {
  color: #8a939d;
  font-size: 11px;
}

.digital-human-avatar-library-item {
  display: grid;
  grid-template-rows: auto auto;
  align-items: stretch;
  gap: 9px;
  min-height: 190px;
  overflow: hidden;
}

.digital-human-avatar-library-item video,
.digital-human-avatar-library-item img {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  height: auto;
  min-height: 132px;
  max-height: 150px;
  border-radius: 6px;
  background: #23282e;
  object-fit: contain;
}

.digital-human-uploading-item {
  pointer-events: none;
  border-style: dashed;
  background: #f7f8fa;
}

.digital-human-uploading-preview {
  display: grid;
  min-height: 132px;
  place-items: center;
  align-content: center;
  gap: 10px;
  border-radius: 6px;
  color: #68737e;
  background: #eef1f4;
  font-size: 12px;
}

.digital-human-uploading-preview .status-spinner {
  width: 26px;
  height: 26px;
}

.digital-human-avatar-modal-grid {
  min-height: 0;
  overscroll-behavior: contain;
}

.digital-human-library-empty {
  grid-column: 1 / -1;
  display: grid;
  min-height: 220px;
  place-items: center;
  color: #8a939d;
  font-size: 13px;
}

@media (max-width: 820px) {
  .digital-human-workflow,
  .digital-human-upload-row {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* Flat selection and command treatment: brand red is an accent, not a filled surface. */
.source-mode-switch button.active,
.source-method-switch button.active,
.rewrite-mode-switch button.active,
.analysis-scope-mode button.active,
.kb-source-switch button.active,
.course-tabs button.active,
.pending-audit-tools button.active,
.kb-segment button.active,
.course-nav button.active {
  position: relative;
  border: 1px solid rgba(255, 255, 255, 0.92);
  color: var(--blue);
  background: rgba(255, 255, 255, 0.82);
  box-shadow: 0 7px 16px rgba(72, 89, 108, 0.08), inset 0 -3px 0 var(--blue);
}

.source-mode-switch button.active::after,
.source-method-switch button.active::after,
.rewrite-mode-switch button.active::after,
.analysis-scope-mode button.active::after,
.kb-source-switch button.active::after,
.course-tabs button.active::after,
.pending-audit-tools button.active::after,
.kb-segment button.active::after,
.course-nav button.active::after {
  display: none;
}

#ingestLinksBtn,
#makeRewriteBtn {
  min-width: 142px;
  border: 1px solid rgba(179, 45, 51, 0.30);
  color: var(--blue);
  background: rgba(179, 45, 51, 0.08);
  box-shadow: none;
}

#ingestLinksBtn:hover,
#makeRewriteBtn:hover {
  border-color: rgba(179, 45, 51, 0.48);
  background: rgba(179, 45, 51, 0.13);
}

#ingestLinksBtn {
  align-self: flex-end;
  width: auto;
  margin-left: auto;
}

@media (max-width: 680px) {
  #ingestLinksBtn {
    width: 100%;
    align-self: stretch;
  }
}
.chanmama-search-action button.running {
  opacity: 0.7;
  cursor: default;
}

.chanmama-login-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: rgba(16, 18, 22, 0.72);
}

.chanmama-login-dialog {
  width: min(1440px, 100%);
  height: min(900px, calc(100vh - 36px));
  display: grid;
  grid-template-rows: 52px minmax(0, 1fr) 62px;
  overflow: hidden;
  border: 1px solid #d9dde5;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.28);
}

.chanmama-login-dialog header,
.chanmama-login-dialog footer {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 16px;
  background: #fff;
}

.chanmama-login-dialog header {
  justify-content: space-between;
  border-bottom: 1px solid #e5e7eb;
}

.chanmama-login-dialog footer {
  justify-content: flex-end;
  border-top: 1px solid #e5e7eb;
}

.chanmama-login-dialog iframe {
  width: 100%;
  height: 100%;
  border: 0;
  background: #16191f;
}

.chanmama-login-dialog .icon-btn {
  width: 36px;
  height: 36px;
  padding: 0;
  border: 0;
  background: transparent;
  color: #374151;
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
}

@media (max-width: 720px) {
  .course-profile-grid {
    grid-template-columns: 1fr;
  }

  .course-profile-status {
    align-items: flex-start;
    flex-wrap: wrap;
  }

  .course-profile-status small {
    width: 100%;
    margin-left: 0;
  }

  .course-profile-modal .library-confirm-actions {
    flex-wrap: wrap;
  }

  .course-profile-modal .library-confirm-actions button {
    flex: 1 1 140px;
  }

  .chanmama-login-overlay {
    padding: 0;
  }

  .chanmama-login-dialog {
    width: 100%;
    height: 100%;
    border: 0;
    border-radius: 0;
    grid-template-rows: 48px minmax(0, 1fr) 58px;
  }
}

.chanmama-grid-card {
  border-radius: 16px;
}

.chanmama-card-save {
  border-radius: 9px;
}

.chanmama-primary-metrics div {
  border-radius: 8px;
}

.chanmama-search-action {
  grid-template-columns: minmax(0, 1fr) auto;
  justify-content: stretch;
  padding-inline: 18px;
}

#startChanmamaBtn,
#startMiaosiBtn {
  min-width: 116px;
  border: 1px solid rgba(179, 45, 51, 0.30);
  color: var(--blue);
  background: rgba(179, 45, 51, 0.08);
  box-shadow: none;
}

#chatSendBtn {
  min-width: 0;
  width: 100%;
  border: 1px solid rgba(179, 45, 51, 0.30);
  color: var(--blue);
  background: rgba(179, 45, 51, 0.08);
  box-shadow: none;
}

@media (min-width: 981px) {
  section[data-stage="elements"] .chat-box {
    grid-template-columns: minmax(0, 1fr) 96px;
  }
}

#startChanmamaBtn:hover,
#startMiaosiBtn:hover,
#chatSendBtn:hover {
  border-color: rgba(179, 45, 51, 0.48);
  background: rgba(179, 45, 51, 0.13);
}

.chanmama-analysis-badge,
.chanmama-run-score {
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 6px;
  background: rgba(16, 20, 28, 0.58);
}

.chat-review-btn.save {
  border: 1px solid rgba(34, 131, 94, 0.20);
  color: #22835e;
  background: rgba(34, 131, 94, 0.12);
}

.chat-review-btn.discard {
  border: 1px solid rgba(179, 45, 51, 0.16);
  color: var(--blue);
  background: rgba(179, 45, 51, 0.08);
}

.chat-review-actions {
  flex-wrap: nowrap;
  justify-content: center;
}

.chat-review-actions .chat-review-btn {
  flex: 0 0 auto;
}

.pending-audit-tools button.active {
  border-color: rgba(179, 45, 51, 0.24);
  color: var(--blue);
  background: #fff;
  box-shadow: inset 3px 0 0 var(--blue);
}

#materialTree .source-target-section {
  border-color: rgba(179, 45, 51, 0.18);
  background: rgba(255, 255, 255, 0.62);
}

#materialTree .source-target-section > summary {
  border-radius: 12px;
  color: var(--blue);
  background: rgba(179, 45, 51, 0.08);
}

#materialTree .source-target-section > summary strong,
#materialTree .source-target-section > summary span,
#materialTree .source-target-section > summary em {
  color: inherit;
}

.source-method-switch {
  gap: 6px;
  padding: 7px;
  border-color: rgba(255, 255, 255, 0.88);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.51);
  box-shadow: 0 10px 28px rgba(72, 89, 108, 0.07), inset 0 1px 0 rgba(255, 255, 255, 0.90);
  backdrop-filter: blur(18px) saturate(180%);
  -webkit-backdrop-filter: blur(18px) saturate(180%);
}

.source-method-switch button {
  position: relative;
  min-height: 46px;
  border: 1px solid transparent;
  border-radius: 10px;
  color: #707986;
  background: rgba(255, 255, 255, 0.17);
  font-size: 14px;
  font-weight: 600;
}

.source-method-switch button:hover {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.42);
}

.source-method-switch button.active {
  color: var(--ink);
  border-color: rgba(255, 255, 255, 0.82);
  background: rgba(255, 255, 255, 0.68);
  box-shadow: 0 10px 24px rgba(73, 92, 112, 0.12), 0 2px 5px rgba(73, 92, 112, 0.05), inset 0 1px 0 rgba(255, 255, 255, 0.95);
}

.source-method-switch button.active::after {
  display: block;
  position: absolute;
  left: 50%;
  bottom: -1px;
  width: 28px;
  height: 3px;
  border-radius: 3px 3px 0 0;
  background: var(--blue);
  content: "";
  transform: translateX(-50%);
}

.rewrite-mode-switch button.active,
.analysis-scope-mode button.active {
  box-shadow: 0 7px 16px rgba(72, 89, 108, 0.08);
}

.rewrite-mode-switch button.active::after,
.analysis-scope-mode button.active::after {
  display: block;
  position: absolute;
  left: 50%;
  bottom: -1px;
  width: 28px;
  height: 3px;
  border-radius: 3px 3px 0 0;
  background: var(--blue);
  content: "";
  transform: translateX(-50%);
}

.rewrite-mode-switch {
  gap: 6px;
  padding: 7px;
  border-color: rgba(255, 255, 255, 0.88);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.51);
  box-shadow: 0 10px 28px rgba(72, 89, 108, 0.07), inset 0 1px 0 rgba(255, 255, 255, 0.90);
  backdrop-filter: blur(18px) saturate(180%);
  -webkit-backdrop-filter: blur(18px) saturate(180%);
}

.rewrite-mode-switch button {
  min-height: 46px;
  border: 1px solid transparent;
  border-radius: 10px;
  color: #707986;
  background: rgba(255, 255, 255, 0.17);
  font-size: 14px;
  font-weight: 600;
}

.rewrite-mode-switch button:hover {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.42);
}

.rewrite-mode-switch button.active {
  color: var(--ink);
  border-color: rgba(255, 255, 255, 0.82);
  background: rgba(255, 255, 255, 0.68);
}

.chanmama-fields > label {
  display: none;
}

.chanmama-search-action input::placeholder {
  color: #8b949e;
  font-size: 12px;
  opacity: 1;
}

@media (max-width: 680px) {
  .rewrite-builder {
    min-height: 0;
  }

  .rewrite-block-palette {
    grid-template-columns: repeat(auto-fit, minmax(104px, 1fr));
  }

  .chanmama-search-action {
    grid-template-columns: minmax(0, 1fr) auto;
  }
}

/* Digital human three-column production workspace */
.digital-human-engine-label {
  color: #8a939d;
  font-size: 12px;
  font-weight: 500;
}

.digital-human-workflow {
  grid-template-columns: minmax(210px, 0.84fr) minmax(360px, 1.45fr) minmax(260px, 1.16fr);
  align-items: stretch;
  margin-top: 0;
}

.digital-human-card,
.digital-human-card:nth-child(2) {
  display: flex;
  /* Fit the full workspace in the viewport; only the finished-video library scrolls. */
  height: max(540px, calc(100dvh - 305px));
  min-height: 0;
  flex-direction: column;
}

.digital-human-script-column .digital-human-field {
  position: relative;
  flex: 1 1 auto;
}

.digital-human-script-column .digital-human-field textarea {
  height: 100%;
  min-height: 330px;
}

.digital-human-script-column .digital-human-field textarea::placeholder {
  color: #6f7a86;
  font-size: 14px;
  opacity: 1;
}

.digital-human-synthesis-overlay {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 12px;
  padding: 28px;
  border: 1px solid rgba(179, 45, 51, 0.22);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.94);
  text-align: center;
  backdrop-filter: blur(2px);
}

.digital-human-synthesis-overlay[hidden] {
  display: none !important;
}

.digital-human-synthesis-overlay .source-queue-spinner {
  width: 64px;
  height: 64px;
  border-width: 5px;
}

.digital-human-synthesis-overlay strong {
  color: var(--ink);
  font-size: 17px;
  font-weight: 900;
}

.digital-human-synthesis-overlay small {
  max-width: 320px;
  color: #68737e;
  font-size: 13px;
  line-height: 1.6;
}

.digital-human-audio-strip {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  min-height: 68px;
  margin-bottom: 14px;
  padding: 12px 14px;
  border: 1px solid rgba(179, 45, 51, 0.22);
  border-radius: 12px;
  background: rgba(179, 45, 51, 0.055);
}

.digital-human-audio-current {
  display: grid;
  min-width: 0;
  align-content: center;
  gap: 4px;
}

.digital-human-audio-current span,
.digital-human-inline-upload span {
  color: #8f2429;
  font-size: 12px;
  font-weight: 700;
}

.digital-human-audio-current strong {
  overflow: hidden;
  color: var(--ink);
  font-size: 14px;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#digitalHumanChooseAudioBtn,
#digitalHumanChooseAvatarBtn {
  min-width: 112px;
  min-height: 44px;
  border-color: rgba(179, 45, 51, 0.28);
  color: var(--blue);
  background: #fff;
  font-size: 14px;
  font-weight: 800;
}

#digitalHumanChooseAudioBtn {
  min-width: 136px;
}

#digitalHumanChooseAudioBtn:hover,
#digitalHumanChooseAvatarBtn:hover {
  border-color: rgba(179, 45, 51, 0.45);
  background: rgba(255, 255, 255, 0.86);
}

#digitalHumanChooseAvatarBtn {
  width: 100%;
}

.digital-human-inline-upload {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 6px;
}

.digital-human-inline-upload input {
  width: 92px;
  min-width: 0;
  color: #7b8590;
  font-size: 10px;
}

.digital-human-inline-upload em {
  display: none;
}

.digital-human-audio-action-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  margin-top: 10px;
}

.digital-human-audio-action-row .primary-btn {
  flex: 0 0 auto;
  min-width: 96px;
}

.digital-human-audio-player {
  flex: 1 1 auto;
  min-width: 0;
  height: 36px;
  margin-top: 0;
}

.digital-human-audio-action-row .digital-human-download {
  flex: 0 0 auto;
  margin-top: 0;
}

.digital-human-avatar-stage,
.digital-human-result-stage {
  position: relative;
  display: grid;
  flex: 1 1 auto;
  min-height: clamp(280px, calc(100dvh - 540px), 320px);
  margin-bottom: 16px;
  place-items: center;
  overflow: hidden;
  border: 1px solid #e0e5eb;
  border-radius: 10px;
  background: #f3f5f7;
}

.digital-human-avatar-stage video {
  width: 100%;
  height: 100%;
  max-height: none;
  margin: 0;
  border-radius: 0;
  background: #20252b;
  object-fit: contain;
}

.digital-human-result-list {
  display: grid;
  align-self: stretch;
  width: 100%;
  height: 100%;
  min-height: 0;
  max-height: none;
  gap: 12px;
  padding: 10px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.digital-human-result-list[hidden] {
  display: none !important;
}

.digital-human-result-item {
  display: grid;
  gap: 8px;
  padding-bottom: 12px;
  border-bottom: 1px solid #dfe4ea;
}

.digital-human-result-item:last-child {
  padding-bottom: 0;
  border-bottom: 0;
}

.digital-human-result-item video {
  display: block;
  width: 100%;
  aspect-ratio: 9 / 16;
  max-height: 360px;
  border-radius: 8px;
  background: #20252b;
  object-fit: contain;
}

.digital-human-result-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: #7b8590;
  font-size: 12px;
}

.digital-human-result-meta a {
  color: var(--blue);
  font-weight: 700;
  text-decoration: none;
}

.digital-human-result-meta a:hover {
  text-decoration: underline;
}

.digital-human-result-actions {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.digital-human-result-actions button {
  padding: 0;
  border: 0;
  color: var(--red);
  background: transparent;
  font: inherit;
  font-weight: 700;
}

.digital-human-result-actions button:hover {
  text-decoration: underline;
}

.digital-human-avatar-placeholder,
.digital-human-video-empty {
  padding: 24px;
  color: #8a939d;
  font-size: 13px;
  line-height: 1.6;
  text-align: center;
}

.digital-human-avatar-placeholder[hidden],
.digital-human-video-empty[hidden] {
  display: none !important;
}

.digital-human-avatar-column > .primary-btn {
  width: 100%;
}

.digital-human-upload-btn {
  width: auto;
  min-width: 132px;
  min-height: 42px;
  border-color: #dce3eb;
  color: #4c5865;
  background: #fff;
  font-size: 13px;
  font-weight: 800;
}

.digital-human-upload-btn:hover {
  border-color: rgba(179, 45, 51, 0.32);
  color: var(--blue);
  background: rgba(179, 45, 51, 0.055);
}

.digital-human-avatar-column .digital-human-upload-compact {
  margin-top: 10px;
}

.digital-human-result-column .digital-human-task-status {
  min-height: 20px;
  margin-top: 10px;
}

.digital-human-result-column .digital-human-task-status:empty {
  display: none;
}

.digital-human-result-column .digital-human-action {
  margin-top: auto;
}

.digital-human-result-column .digital-human-download {
  align-self: flex-end;
}

/* A disabled generation action should read as unavailable, not as a washed-out brand red. */
#digitalHumanGenerateVideoBtn:disabled {
  color: #fff;
  background: #aeb7c1;
  cursor: not-allowed;
  opacity: 1;
}

@media (max-width: 1050px) {
  .digital-human-workflow {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .digital-human-result-column {
    grid-column: 1 / -1;
  }

  .digital-human-all-video-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  .digital-human-workflow {
    grid-template-columns: minmax(0, 1fr);
  }

  .digital-human-result-column {
    grid-column: auto;
  }

  .digital-human-card,
  .digital-human-card:nth-child(2) {
    min-height: 0;
  }

  .digital-human-video-modal-dialog {
    max-height: calc(100dvh - 24px);
    padding: 14px;
  }

  .digital-human-all-video-list {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* Automatic editing */
.auto-edit-grid {
  grid-template-columns: minmax(0, 1fr);
}

.auto-edit-panel {
  display: flex;
  min-width: 0;
  height: 100%;
  min-height: 0;
  flex-direction: column;
  overflow: hidden;
}

.auto-edit-preview-meta,
.auto-edit-transcript-head,
.auto-edit-setting-row,
.auto-edit-footer,
.auto-edit-actions,
.auto-edit-export-head,
.auto-edit-export-option {
  display: flex;
  align-items: center;
}

.auto-edit-export-head h3 {
  margin: 0;
}

.auto-edit-export-head p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.auto-edit-health {
  position: absolute;
  top: 12px;
  right: 18px;
  z-index: 8;
}

.auto-edit-health-toggle {
  display: grid;
  width: 24px;
  height: 24px;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 8px rgba(39, 48, 58, 0.14);
}

.auto-edit-health-toggle:hover,
.auto-edit-health-toggle[aria-expanded="true"] {
  background: #f4f6f8;
}

.auto-edit-health-popover {
  position: absolute;
  top: 32px;
  right: 0;
  display: grid;
  width: min(310px, calc(100vw - 48px));
  gap: 12px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 14px 36px rgba(39, 48, 58, 0.2);
}

.auto-edit-health-popover[hidden] {
  display: none;
}

.auto-edit-health-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #a5adb5;
  box-shadow: 0 0 0 3px rgba(165, 173, 181, 0.14);
}

.auto-edit-health[data-status="healthy"] .auto-edit-health-dot {
  background: #1f9d62;
  box-shadow: 0 0 0 3px rgba(31, 157, 98, 0.14);
}

.auto-edit-health[data-status="warning"] .auto-edit-health-dot,
.auto-edit-health[data-status="error"] .auto-edit-health-dot {
  background: #c44343;
  box-shadow: 0 0 0 3px rgba(196, 67, 67, 0.14);
}

.auto-edit-health-copy {
  display: grid;
  min-width: 0;
  gap: 2px;
}

.auto-edit-health-copy strong,
.auto-edit-health-copy small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.auto-edit-health-copy strong {
  color: var(--ink);
  font-size: 12px;
}

.auto-edit-health-copy small {
  color: var(--muted);
  font-size: 11px;
}

.auto-edit-health .icon-btn {
  width: 32px;
  min-width: 32px;
  height: 32px;
}

.auto-edit-health .ghost-btn {
  min-height: 32px;
  padding: 0 10px;
  white-space: nowrap;
}

.auto-edit-health-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.auto-edit-segmented {
  display: inline-grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(92px, 1fr);
  flex: 0 0 auto;
  gap: 3px;
  padding: 3px;
  border: 1px solid #dfe5eb;
  border-radius: 8px;
  background: #f3f5f7;
}

.auto-edit-segmented button {
  min-height: 34px;
  padding: 0 12px;
  border: 0;
  border-radius: 6px;
  color: #6d7782;
  background: transparent;
  font-size: 13px;
  font-weight: 750;
}

.auto-edit-segmented button.active {
  color: var(--ink);
  background: #fff;
  box-shadow: 0 3px 10px rgba(72, 89, 108, 0.11);
}

.auto-edit-source-control {
  display: flex;
  min-width: 0;
  flex: 1 1 auto;
  align-items: center;
  gap: 8px;
}

.auto-edit-source-control[hidden] {
  display: none !important;
}

.auto-edit-source-control select {
  min-width: 0;
  height: 40px;
  flex: 1 1 auto;
}

.auto-edit-source-control .ghost-btn {
  min-height: 40px;
  white-space: nowrap;
}

#autoEditLocalName {
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.auto-edit-workspace {
  display: grid;
  min-height: 0;
  flex: 1 1 auto;
  grid-template-columns: minmax(250px, 0.76fr) minmax(500px, 1.55fr);
  gap: 16px;
  margin-top: 8px;
}

.auto-edit-preview-column,
.auto-edit-editor-column {
  display: flex;
  min-width: 0;
  min-height: 0;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.72);
}

.auto-edit-preview-column {
  padding: 12px;
}

.auto-edit-source-card-head {
  justify-content: center;
  margin-bottom: 14px;
  text-align: center;
}

.auto-edit-source-card > .ghost-btn {
  width: 100%;
  min-height: 48px;
  margin-top: 14px;
  border-color: rgba(179, 45, 51, .26);
  color: var(--red);
  font-weight: 800;
}

.fission-empty-action {
  width: 100%;
}

.fission-empty-action > summary {
  display: grid;
  width: 100%;
  min-height: 52px;
  place-items: center;
  border: 1px solid rgba(179, 45, 51, .26);
  border-radius: 10px;
  color: var(--red);
  background: #fff;
  font-weight: 800;
  list-style: none;
  cursor: pointer;
}

.fission-empty-action > summary::-webkit-details-marker {
  display: none;
}

.fission-empty-action .fission-upload-popover {
  position: static;
  width: 100%;
  margin-top: 8px;
  box-shadow: none;
}

.auto-edit-preview-column.has-source {
  padding: 0;
  overflow: hidden;
  border: 0;
  background: #20252b;
}

.auto-edit-preview-column.has-source .auto-edit-preview-stage {
  background: #20252b;
}

.auto-edit-preview-stage {
  position: relative;
  display: grid;
  min-height: 0;
  flex: 1 1 auto;
  place-items: center;
  overflow: hidden;
  border-radius: 8px;
  background: #20252b;
}

.auto-edit-preview-stage.is-empty {
  border: 1px dashed #cfd6dd;
  background: #fff;
}

.auto-edit-preview-stage video {
  display: block;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  max-height: calc(100dvh - 390px);
  background: #20252b;
  object-fit: contain;
  object-position: center;
  transform: none;
}

.auto-edit-preview-load {
  position: absolute;
  right: 12px;
  bottom: 12px;
  left: 12px;
  z-index: 5;
  display: grid;
  gap: 6px;
  padding: 9px 10px;
  border-radius: 7px;
  color: #fff;
  background: rgba(24, 29, 34, 0.82);
  pointer-events: none;
}

.auto-edit-preview-load[hidden] {
  display: none !important;
}

.auto-edit-preview-load-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 12px;
}

.auto-edit-preview-load-head span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.auto-edit-preview-load-head strong {
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}

.auto-edit-preview-load-bar {
  height: 5px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.18);
}

.auto-edit-preview-load-bar i {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #ff6b6b, #f6a45c);
  transition: width 120ms linear;
}

@keyframes autoEditTaskScan {
  to {
    transform: translateX(100%);
  }
}

.auto-edit-preview-column.has-source .auto-edit-preview-stage video {
  max-height: none;
}

.auto-edit-delete-source {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 4;
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.9);
  border-radius: 50%;
  color: #fff;
  background: rgba(31, 38, 45, 0.78);
  box-shadow: 0 4px 14px rgba(20, 28, 36, 0.2);
  cursor: pointer;
}

.auto-edit-delete-source:hover {
  background: #c92f3d;
}

.auto-edit-delete-source:disabled {
  cursor: wait;
  opacity: 0.55;
}

.auto-edit-delete-source svg {
  width: 17px;
  height: 17px;
}

.auto-edit-delete-source[hidden] {
  display: none !important;
}

.auto-edit-preview-stage video[hidden],
.auto-edit-preview-empty[hidden],
.auto-edit-processing[hidden],
.auto-edit-tab-panel[hidden],
.auto-edit-modal[hidden] {
  display: none !important;
}

.auto-edit-preview-empty {
  display: grid;
  width: 100%;
  height: 100%;
  max-width: none;
  place-content: center;
  gap: 8px;
  padding: 24px;
  border: 0;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  text-align: center;
}

.auto-edit-preview-empty strong {
  color: var(--ink);
  font-size: 22px;
}

.auto-edit-preview-empty span {
  font-size: 12px;
  line-height: 1.6;
}

.auto-edit-processing {
  position: absolute;
  top: 48px;
  right: 14px;
  bottom: 76px;
  left: 14px;
  z-index: 5;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 12px;
  padding: 28px;
  border: 1px solid #e0e5ea;
  border-radius: 8px;
  color: var(--ink);
  background: #f7f8f9;
  text-align: center;
}

.auto-edit-processing .status-spinner {
  width: 54px;
  height: 54px;
  border-width: 4px;
}

#autoEditProcessingProgress {
  color: #5e6974;
  font-size: 14px;
  font-weight: 800;
}

.auto-edit-processing small {
  max-width: 360px;
  color: #69737d;
  font-size: 12px;
  line-height: 1.5;
  text-align: center;
}

.auto-edit-processing-bar {
  width: min(360px, calc(100% - 32px));
  height: 7px;
  overflow: hidden;
  border-radius: 999px;
  background: #dfe4e8;
}

.auto-edit-processing-bar i {
  position: relative;
  display: block;
  width: 0;
  height: 100%;
  overflow: hidden;
  border-radius: inherit;
  background: #c7353e;
  transition: width 220ms ease;
}

.auto-edit-processing-bar i::after {
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.55), transparent);
  content: "";
  transform: translateX(-100%);
  animation: autoEditTaskScan 1.35s linear infinite;
}

.auto-edit-processing[data-status="failed"] .status-spinner,
.auto-edit-processing[data-status="completed"] .status-spinner {
  display: none;
}

.auto-edit-processing[data-status="failed"] .auto-edit-processing-bar i {
  background: #d54b55;
}

.auto-edit-processing[data-status="failed"] .auto-edit-processing-bar i::after,
.auto-edit-processing[data-status="completed"] .auto-edit-processing-bar i::after {
  display: none;
}

.auto-edit-processing[data-status="completed"] .auto-edit-processing-bar i {
  background: #2fa36b;
}

.auto-edit-preview-meta {
  display: none;
  justify-content: space-between;
  gap: 10px;
  min-height: 38px;
  padding-top: 10px;
}

.auto-edit-preview-meta strong {
  min-width: 0;
  overflow: hidden;
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.auto-edit-preview-meta span {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.auto-edit-editor-column {
  position: relative;
  padding: 0 14px 14px;
}

.auto-edit-tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  flex: 0 0 auto;
  border-bottom: 1px solid var(--line);
}

.auto-edit-tabs button {
  position: relative;
  display: grid;
  min-height: 48px;
  place-items: center;
  border: 0;
  color: #77818c;
  background: transparent;
  font-size: 17px;
  font-weight: 800;
  line-height: 1;
}

.auto-edit-tabs button.active {
  color: var(--ink);
}

.auto-edit-tabs button.active::after {
  position: absolute;
  right: auto;
  bottom: -1px;
  left: 50%;
  width: 28px;
  height: 2px;
  border-radius: 2px 2px 0 0;
  background: var(--blue);
  transform: translateX(-50%);
  content: '';
}

.auto-edit-tab-panel {
  min-height: 0;
  flex: 1 1 auto;
  padding-top: 14px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.auto-edit-template-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.auto-edit-template-card {
  position: relative;
  display: grid;
  min-width: 0;
  gap: 5px;
  padding: 7px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: #fff;
  text-align: left;
}

.auto-edit-template-card:hover {
  background: #f6f7f8;
  box-shadow: 0 6px 15px rgba(72, 89, 108, 0.08);
}

.auto-edit-template-card.active {
  border-color: rgba(179, 45, 51, 0.36);
  background: #fff;
  box-shadow: 0 7px 18px rgba(179, 45, 51, 0.12);
}

.auto-edit-template-card.active::after {
  position: absolute;
  right: 50%;
  bottom: 2px;
  width: 34px;
  height: 3px;
  border-radius: 999px;
  background: var(--red);
  content: "";
  transform: translateX(50%);
}

.auto-edit-template-preview {
  position: relative;
  display: grid;
  min-height: 0;
  aspect-ratio: 3 / 4;
  place-items: end start;
  padding: 0;
  overflow: hidden;
  border-radius: 8px;
  color: #fff;
  background: #2a3138;
}

.auto-edit-template-preview img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border-radius: inherit;
  object-fit: cover;
}

.auto-edit-template-card:nth-child(-n + 8) .auto-edit-template-preview img {
  transform: translateX(-1px) scale(1.055);
  transform-origin: center;
}

.auto-edit-source-dialog {
  display: grid;
  width: min(660px, 100%);
  max-height: min(680px, calc(100dvh - 40px));
  padding: 16px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.94);
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 22px 60px rgba(32, 43, 54, 0.2);
}

.auto-edit-source-choice-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.auto-edit-source-choice-grid[hidden],
.auto-edit-existing-picker[hidden] {
  display: none !important;
}

.auto-edit-source-choice-grid button {
  display: grid;
  min-height: 92px;
  place-content: center;
  gap: 8px;
  padding: 14px;
  border: 1px solid #dce2e8;
  border-radius: 10px;
  color: var(--ink);
  background: #f8f9fa;
  text-align: center;
}

.auto-edit-source-choice-grid button:hover {
  border-color: rgba(179, 45, 51, 0.48);
  background: #fff;
}

.auto-edit-source-choice-grid span,
.auto-edit-existing-video-card small {
  color: var(--muted);
  font-size: 12px;
}

.auto-edit-existing-picker {
  display: grid;
  min-height: 0;
  overflow: hidden;
}

.auto-edit-existing-video-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-content: start;
  gap: 14px;
  min-height: 0;
  overflow-y: auto;
}

.auto-edit-existing-video-card {
  display: grid;
  min-width: 0;
  gap: 6px;
  padding: 8px;
  border: 1px solid #dfe4e9;
  border-radius: 8px;
  background: #fff;
  text-align: left;
}

.auto-edit-existing-video-cover {
  display: grid;
  aspect-ratio: 9 / 16;
  place-items: center;
  overflow: hidden;
  border-radius: 6px;
  background: #20252b;
}

.auto-edit-existing-video-cover video {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.auto-edit-existing-video-card strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.auto-edit-existing-empty {
  grid-column: 1 / -1;
  padding: 40px 20px;
  color: var(--muted);
  text-align: center;
}

.auto-edit-template-card strong {
  overflow: hidden;
  color: var(--ink);
  font-size: 12px;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.auto-edit-option-row {
  display: flex;
  gap: 22px;
  margin-top: 14px;
  padding: 12px 2px 2px;
  border-top: 1px solid var(--line);
}

.auto-edit-footer .auto-edit-option-row {
  margin: 0;
  padding: 0;
  border: 0;
}

.auto-edit-option-row label {
  display: inline-flex;
  min-width: 0;
  align-items: center;
  gap: 7px;
  color: #4f5964;
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

.auto-edit-option-row input[type="checkbox"] {
  width: 16px;
  height: 16px;
  min-width: 16px;
  margin: 0;
  accent-color: var(--blue);
}

.auto-edit-transcript-head {
  justify-content: space-between;
  gap: 12px;
  padding: 0 2px 10px;
}

.auto-edit-transcript-head span {
  color: var(--muted);
  font-size: 11px;
}

.auto-edit-title-editor {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 8px;
  margin-bottom: 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

.auto-edit-title-fields {
  display: grid;
  grid-column: 1 / -1;
  gap: 8px;
}

.auto-edit-title-fields > label {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
}

.auto-edit-title-editor-head {
  display: flex;
  grid-column: 1 / -1;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 12px;
}

.auto-edit-title-editor-head span {
  color: var(--muted);
}

.auto-edit-title-editor input {
  width: 100%;
  min-width: 0;
  height: 36px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--text);
  background: #fff;
}

.auto-edit-title-editor input:disabled {
  color: var(--muted);
  background: #f5f6f7;
}

.auto-edit-transcript {
  display: grid;
  gap: 8px;
}


.auto-edit-transcript-row {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 6px 12px;
  border: 1px solid #e1e6eb;
  border-radius: 7px;
  color: var(--ink);
  background: #fff;
  text-align: left;
  cursor: pointer;
}

.auto-edit-transcript-row time {
  color: var(--muted);
  font-size: 11px;
}

.auto-edit-transcript-row span {
  font-size: 13px;
  line-height: 1.55;
}

.auto-edit-transcript-row textarea {
  width: 100%;
  min-height: 58px;
  resize: vertical;
  border: 1px solid rgba(179, 45, 51, 0.42);
  border-radius: 6px;
  color: var(--ink);
  background: #fff;
  font: inherit;
  font-size: 13px;
  line-height: 1.55;
  cursor: text;
}

.auto-edit-transcript-row.editing {
  border-color: rgba(179, 45, 51, 0.42);
  box-shadow: 0 0 0 2px rgba(179, 45, 51, 0.08);
}

.auto-edit-transcript-row.selected {
  border-color: rgba(179, 45, 51, 0.34);
  background: #fff8f8;
}

.auto-edit-transcript-actions {
  display: flex;
  gap: 4px;
}

.auto-edit-transcript-actions button {
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  padding: 0;
  border: 1px solid #dfe4e9;
  border-radius: 6px;
  color: #68727d;
  background: #fff;
}

.auto-edit-transcript-actions button:hover {
  color: var(--blue);
  border-color: rgba(38, 112, 184, 0.42);
  background: #f5f9fd;
}

.auto-edit-transcript-actions svg {
  width: 16px;
  height: 16px;
}

.auto-edit-transcript-row.removed {
  color: #9ba3ab;
  background: #f4f5f6;
}

.auto-edit-transcript-row.removed > span {
  text-decoration: line-through;
}

.auto-edit-setting-row {
  justify-content: space-between;
  gap: 20px;
  min-height: 48px;
  padding: 6px 4px;
  border-bottom: 1px solid var(--line);
}

.auto-edit-setting-row > div:first-child {
  display: grid;
  gap: 5px;
}

.auto-edit-setting-row strong {
  font-size: 14px;
}

.auto-edit-setting-row span {
  color: var(--muted);
  font-size: 12px;
}

#autoEditSoundPanel {
  padding-top: 0;
}

#autoEditSoundPanel .auto-edit-setting-row {
  min-height: 52px;
  padding-block: 3px;
}

#autoEditSoundPanel .auto-edit-setting-row > div:first-child {
  gap: 2px;
}

#autoEditSoundPanel .auto-edit-setting-row span {
  line-height: 1.2;
}

.auto-edit-volume-control {
  display: grid;
  grid-template-columns: minmax(140px, 220px) 42px;
  align-items: center;
  gap: 10px;
}

.auto-edit-volume-control input[type="range"] {
  --range-progress: 78%;
  width: 100%;
  height: 20px;
  margin: 0;
  appearance: none;
  -webkit-appearance: none;
  background: transparent;
}

.auto-edit-volume-control input[type="range"]::-webkit-slider-runnable-track {
  height: 6px;
  border-radius: 999px;
  background: linear-gradient(
    to right,
    #2f72e8 0,
    #2f72e8 var(--range-progress),
    #dce3ec var(--range-progress),
    #dce3ec 100%
  );
}

.auto-edit-volume-control input[type="range"]::-webkit-slider-thumb {
  width: 16px;
  height: 16px;
  margin-top: -5px;
  border: 0;
  border-radius: 50%;
  appearance: none;
  -webkit-appearance: none;
  background: #2f72e8;
  box-shadow: 0 1px 3px rgba(24, 58, 112, 0.22);
}

.auto-edit-volume-control input[type="range"]::-moz-range-track {
  height: 6px;
  border-radius: 999px;
  background: #dce3ec;
}

.auto-edit-volume-control input[type="range"]::-moz-range-progress {
  height: 6px;
  border-radius: 999px;
  background: #2f72e8;
}

.auto-edit-volume-control input[type="range"]::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border: 0;
  border-radius: 50%;
  background: #2f72e8;
  box-shadow: 0 1px 3px rgba(24, 58, 112, 0.22);
}

.auto-edit-volume-control output {
  min-height: 34px;
  padding: 7px 5px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  font-size: 12px;
  text-align: center;
}

.auto-edit-switch {
  position: relative;
  display: inline-flex;
  width: 46px;
  height: 26px;
}

.auto-edit-switch input {
  position: absolute;
  opacity: 0;
}

.auto-edit-switch span {
  width: 100%;
  border-radius: 13px;
  background: #cbd2d9;
  transition: background 0.18s ease;
}

.auto-edit-switch span::after {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 5px rgba(24, 32, 40, 0.18);
  content: '';
  transition: transform 0.18s ease;
}

.auto-edit-switch input:checked + span {
  background: var(--blue);
}

.auto-edit-switch input:checked + span::after {
  transform: translateX(20px);
}

.auto-edit-footer {
  justify-content: space-between;
  gap: 14px;
  flex: 0 0 auto;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

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

.auto-edit-actions {
  flex: 0 0 auto;
  gap: 8px;
}

.auto-edit-actions button {
  min-width: 104px;
}

.auto-edit-actions button[hidden] {
  display: none !important;
}

.auto-edit-update-btn.is-dirty:not(:disabled) {
  border-color: #c92f3d;
  color: #fff;
  background: #c92f3d;
}

.auto-edit-update-btn.is-dirty:not(:disabled):hover {
  background: #ae2432;
}

.auto-edit-modal {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(24, 31, 38, 0.28);
  backdrop-filter: blur(6px);
}

.auto-edit-export-dialog {
  width: min(440px, 100%);
  padding: 20px;
  border: 1px solid rgba(255, 255, 255, 0.94);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 22px 60px rgba(32, 43, 54, 0.2);
}

.auto-edit-export-head {
  justify-content: space-between;
  margin-bottom: 18px;
}

.auto-edit-close {
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 50%;
  color: #66717c;
  background: #eef1f3;
  font-size: 22px;
}

.auto-edit-export-option {
  justify-content: space-between;
  min-height: 64px;
  border-top: 1px solid var(--line);
  font-size: 13px;
}

.auto-edit-preview-notice {
  margin: 12px 0;
  padding: 11px 12px;
  border-radius: 7px;
  color: #6b747e;
  background: #f2f4f6;
  font-size: 12px;
  line-height: 1.55;
}

.auto-edit-export-dialog > .primary-btn {
  width: 100%;
  margin-top: 4px;
}

@media (max-width: 900px) {
  .auto-edit-panel {
    height: auto;
    min-height: 0;
    overflow: visible;
  }

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

  .auto-edit-preview-stage {
    min-height: 520px;
  }

  .auto-edit-preview-stage video {
    height: 520px;
    max-height: 70dvh;
  }

  .auto-edit-editor-column {
    min-height: 520px;
  }
}

@media (max-width: 680px) {
  .step-nav {
    display: flex;
    overflow-x: auto;
    scroll-snap-type: x proximity;
    scrollbar-width: none;
  }

  .step-nav::-webkit-scrollbar {
    display: none;
  }

  .step-nav > button,
  .step-nav > .realtime-nav-item {
    min-width: 82px;
    flex: 0 0 82px;
    scroll-snap-align: start;
  }

  .auto-edit-segmented {
    width: 100%;
  }

  .auto-edit-source-control {
    width: 100%;
  }

  .auto-edit-preview-stage {
    min-height: 430px;
  }

  .auto-edit-preview-stage video {
    height: 430px;
  }

  .auto-edit-editor-column {
    min-height: 500px;
    padding: 12px;
  }

  .auto-edit-processing {
    top: 60px;
    right: 12px;
    bottom: 128px;
    left: 12px;
  }

  .auto-edit-template-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .auto-edit-source-choice-grid,
  .auto-edit-existing-video-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .auto-edit-transcript-row {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .auto-edit-transcript-row time {
    grid-column: 1 / -1;
  }

  .auto-edit-setting-row {
    align-items: stretch;
    flex-direction: column;
  }

  .auto-edit-volume-control {
    grid-template-columns: minmax(0, 1fr) 42px;
  }

  .auto-edit-footer {
    align-items: stretch;
    flex-direction: column;
  }

  .auto-edit-actions {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
  }
}

/* External mobile navigation and stacked workspaces. Desktop navigation stays at the top. */
@media (max-width: 760px) {
  .app-shell {
    padding-bottom: calc(84px + env(safe-area-inset-bottom));
  }

  main {
    width: 100%;
    min-width: 0;
  }

  .step-nav {
    position: fixed;
    top: auto;
    right: 8px;
    bottom: 18px;
    left: 8px;
    z-index: 500;
    display: grid;
    grid-template-columns: repeat(12, minmax(0, 1fr));
    gap: 4px;
    margin: 0;
    padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
    overflow: visible;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.97);
    box-shadow: 0 12px 30px rgba(39, 52, 70, 0.26), 0 0 0 1px rgba(255, 255, 255, 0.92), inset 0 1px 0 rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
  }

  .step-nav > button,
  .step-nav > .realtime-nav-item,
  .step-nav > .ai-nav-item {
    grid-column: span 3;
    width: 100%;
    min-width: 0;
    flex: none;
    scroll-snap-align: none;
  }

  .step-nav > button,
  .step-nav > .realtime-nav-item > button,
  .step-nav > .ai-nav-item > button {
    width: 100%;
    min-width: 0;
    min-height: 38px;
    padding: 3px 4px;
    font-size: 11px;
    line-height: 1.15;
  }

  .step-nav > button.active,
  .step-nav > .ai-nav-item > button.active {
    color: var(--ink);
    background: rgba(245, 247, 250, 0.98);
    box-shadow: inset 0 -3px 0 var(--blue);
  }

  .step-nav .realtime-nav-main span,
  .step-nav .ai-nav-main > span:not(.ai-nav-caret) {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .realtime-nav-menu,
  .ai-nav-menu {
    top: auto;
    right: auto;
    bottom: calc(100% + 8px);
    left: 0;
  }

  .source-grid,
  .chat-grid,
  .knowledge-grid,
  .rewrite-grid,
  .review-grid,
  .digital-human-workflow,
  .auto-edit-workspace,
  .knowledge-main,
  .knowledge-workbench,
  .personal-library-toolbar {
    grid-template-columns: minmax(0, 1fr);
  }

  .stage-grid > *,
  .digital-human-workflow > *,
  .auto-edit-workspace > *,
  .knowledge-workbench > * {
    min-width: 0;
  }

  section[data-stage="digital-human"].active,
  section[data-stage="auto-edit"].active {
    height: auto;
    max-height: none;
    overflow: visible;
  }

  main img,
  main video {
    max-width: 100%;
  }
}

.workspace-subnav {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  margin-bottom: 12px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: rgba(255, 255, 255, 0.58);
  box-shadow: 0 8px 24px rgba(72, 89, 108, 0.06);
}

.workspace-subnav[hidden] {
  display: none !important;
}

.workspace-subnav button {
  position: relative;
  min-width: 0;
  min-height: 42px;
  padding: 6px 10px;
  border: 1px solid transparent;
  border-radius: 9px;
  color: var(--muted);
  background: transparent;
  font-size: 14px;
  font-weight: 800;
}

.workspace-subnav button.active {
  border-color: rgba(255, 255, 255, 0.9);
  color: var(--ink);
  background: rgba(255, 255, 255, 0.82);
  box-shadow: 0 5px 14px rgba(72, 89, 108, 0.08);
}

.workspace-subnav button.active::before {
  position: absolute;
  top: 9px;
  bottom: 9px;
  left: 0;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--blue);
  content: '';
}

.source-platform-notice {
  display: block;
  margin-top: 7px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}

@media (max-width: 760px) {
  .workspace-subnav {
    position: sticky;
    top: 0;
    z-index: 25;
    gap: 4px;
    margin-bottom: 8px;
    padding: 4px;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
  }

  .workspace-subnav button {
    min-height: 38px;
    padding: 4px 3px;
    font-size: 12px;
  }
}

/* Last-pass mobile overrides (must remain after all legacy responsive rules). */
@media (max-width: 760px) {
  .step-nav {
    grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
    justify-items: stretch;
    align-items: center;
  }

  .step-nav > button,
  .step-nav > .ai-nav-item {
    grid-column: span 1 !important;
    display: grid;
    place-items: center;
    width: 100%;
  }

  .step-nav > button[hidden] { display: none !important; }

  .step-nav > button,
  .step-nav > .ai-nav-item > button {
    min-height: 52px;
    padding: 6px 3px;
    border: 0;
    border-radius: 13px;
    color: #778293;
    background: transparent;
    box-shadow: none !important;
    font-size: 15px !important;
    font-weight: 800;
    text-align: center;
  }

  .step-nav > button.active,
  .step-nav > .ai-nav-item > button.active {
    color: var(--ink);
    background: #eef2f6;
    box-shadow: 0 6px 14px rgba(44, 57, 73, 0.10) !important;
  }

  .workspace-subnav {
    display: flex;
    overflow-x: auto;
    gap: 18px;
    margin: 0 0 10px;
    padding: 2px 2px 5px;
    border: 0 !important;
    border-radius: 0;
    background: transparent !important;
    box-shadow: none !important;
    scrollbar-width: none;
  }

  .workspace-subnav::-webkit-scrollbar { display: none; }

  .workspace-subnav button {
    flex: 0 0 auto;
    min-height: 34px;
    padding: 4px 2px;
    border: 0;
    border-radius: 0;
    color: #7a8492;
    background: transparent;
    box-shadow: none;
    font-size: 14px;
  }

  .workspace-subnav button.active {
    padding-right: 12px;
    padding-left: 12px;
    border-radius: 10px;
    color: var(--ink);
    background: #f3f5f8;
    box-shadow: 0 4px 12px rgba(44, 57, 73, 0.08);
  }

  .workspace-subnav button.active::before { display: none !important; }
  #sourcePanelHelp, #sourceLinksLabel, #sourcePlatformNotice { display: none !important; }
  #externalSourceMethodSwitch .source-method-action::before { display: none; }
  #externalSourceMethodSwitch .source-method-action.active {
    background: #f1f3f6;
    border-color: rgba(179, 45, 51, 0.22);
    box-shadow: 0 8px 20px rgba(179, 45, 51, 0.12);
  }
}

/* Final mobile information architecture overrides. */
@media (max-width: 760px) {
  .source-workspace-nav,
  .creation-workspace-nav {
    justify-content: center !important;
    width: fit-content;
    max-width: 100%;
    margin-right: auto !important;
    margin-left: auto !important;
    gap: 8px !important;
  }
  .source-workspace-nav button,
  .creation-workspace-nav button {
    min-width: 94px;
    padding-right: 12px !important;
    padding-left: 12px !important;
    text-align: center;
  }
  #externalSourceMethodSwitch.source-method-actions {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 8px;
  }
  #externalSourceMethodSwitch .source-method-action {
    min-height: 48px;
    align-items: center;
    justify-content: center;
    padding: 8px 7px;
    text-align: center;
  }
  #externalSourceMethodSwitch .source-method-action small { display: none; }
  .ai-chat-workspace {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) !important;
    grid-template-rows: auto minmax(0, 1fr) !important;
  }
  .ai-chat-sidebar { display: contents !important; }
  .ai-chat-sidebar-head {
    display: flex !important;
    grid-row: 1;
    min-height: 48px;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    border-bottom: 1px solid var(--line);
  }
  .ai-chat-thread-section,
  .ai-chat-sidebar .ai-sidebar-collapse-button { display: none !important; }
  .ai-chat-main { grid-row: 2; min-height: 0; }
  .ai-chat-main-head { display: none !important; }
  .ai-chat-main { grid-template-rows: minmax(0, 1fr) auto !important; }
  .ai-chat-log { min-height: 0; padding: 14px 12px; }
  .ai-chat-composer {
    min-height: 118px;
    margin: 6px 10px 8px;
    padding: 8px 10px 7px;
    border-radius: 14px;
  }
  .ai-chat-composer textarea {
    height: 64px;
    min-height: 64px;
    max-height: 64px;
    font-size: 14px;
  }
  .ai-chat-composer-actions { min-height: 26px; padding-top: 4px; gap: 4px; }
  .ai-chat-composer-model-select {
    width: 96px !important;
    max-width: 96px !important;
    height: 26px;
    padding-right: 19px;
    font-size: 12px;
  }
  .ai-chat-send-btn { width: 30px; height: 30px; }
  .rewrite-course-picker { display: grid; gap: 8px; padding: 0; border: 0; background: transparent; }
  .rewrite-course-control { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; }
  #rewriteProfileUrl { min-width: 0; min-height: 44px; }
  #addRewriteCourseBtn { min-height: 44px; white-space: nowrap; }
  #rewriteCourseId { display: none; }
  .rewrite-mode-switch {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 6px;
    padding: 0;
    border: 0;
    background: transparent;
  }
  .rewrite-mode-switch button {
    min-height: 44px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--surface);
  }
  .rewrite-mode-switch button:first-child { grid-column: 1 / -1; min-height: 50px; }
  #makeRewriteBtn { width: 100%; min-height: 48px; }
  #clearFinalScriptBtn { display: none !important; }
  .personal-library-header { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: start; gap: 8px; }
  .personal-library-header > div:first-child { grid-column: 1 / -1; }
  .personal-library-header .personal-library-summary { grid-column: 1 / -1; justify-self: start; }
  .personal-library-header .personal-library-filters { grid-column: 1 / -1; width: 100%; order: 3; }
  .personal-library-toolbar { display: block; }
  .personal-library-toolbar input { width: 100%; }
}

/* Absolute final mobile overrides. Keep this block at EOF. */
@media (max-width: 760px) {
  .rewrite-mode-switch {
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
  }
  .rewrite-mode-switch button,
  .rewrite-mode-switch button:first-child {
    grid-column: auto !important;
    min-width: 0;
    min-height: 44px;
    padding: 5px 3px;
    font-size: 12px;
    line-height: 1.2;
  }
  .rewrite-inline-generate-btn {
    display: block;
    width: 100%;
    min-height: 48px;
    margin: 10px 0 12px;
  }
  .rewrite-framework-active .rewrite-action-row { display: none !important; }
  #seedanceLog {
    display: grid !important;
    place-items: center !important;
    place-content: center !important;
  }
  #seedanceLog .seedance-empty {
    width: 100%;
    min-height: 0;
    align-self: center;
    text-align: center;
  }
  .rewrite-mode-switch {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }
  .rewrite-mode-switch button {
    min-height: 46px;
    border: 1px solid var(--line) !important;
    border-radius: 11px !important;
    color: var(--muted);
    background: rgba(255, 255, 255, 0.72) !important;
    box-shadow: none !important;
  }
  .rewrite-mode-switch button.active {
    color: var(--ink);
    border-color: rgba(179, 45, 51, 0.22) !important;
    background: #f1f3f6 !important;
    box-shadow: 0 6px 14px rgba(44, 57, 73, 0.08) !important;
  }
  .rewrite-mode-switch button.active::after { display: none !important; }
  .auto-edit-editor-column[hidden],
  .digital-human-script-column[hidden],
  .digital-human-result-column[hidden] {
    display: none !important;
  }
  .auto-edit-workspace:not(.has-source),
  .digital-human-workflow:not(.has-avatar) {
    grid-template-columns: minmax(0, 1fr) !important;
  }
}

/* Premium mobile visual system inspired by mature mobile-first web apps. */
@media (max-width: 760px) {
  :root {
    --mobile-page: #f4f5f7;
    --mobile-card: #ffffff;
    --mobile-soft: #f6f7f9;
    --mobile-line: rgba(26, 32, 44, 0.08);
    --mobile-shadow: 0 10px 30px rgba(29, 36, 48, 0.08);
    --mobile-radius: 20px;
  }

  html, body {
    background: var(--mobile-page);
  }

  body {
    color: #171b22;
  }

  .app-shell {
    width: 100%;
    max-width: 560px;
    margin: 0 auto;
    padding: 12px 12px calc(102px + env(safe-area-inset-bottom));
  }

  .hero {
    min-height: 58px;
    margin-bottom: 12px;
    padding: 6px 2px;
    border: 0;
    background: transparent;
    box-shadow: none;
  }

  .brand-logo { height: 32px; }
  .brand-lockup { gap: 8px; }
  .brand-subtitle {
    min-height: 18px;
    padding-left: 8px;
    border-left-color: rgba(23, 27, 34, 0.12);
    color: #242a33;
    font-size: 12px;
  }

  .account-wrap .user-name-btn {
    min-height: 36px;
    padding: 0 11px;
    border: 1px solid var(--mobile-line);
    border-radius: 12px;
    background: rgba(255,255,255,.78);
    box-shadow: none;
  }

  .account-wrap .account-avatar-btn {
    width: 42px;
    min-width: 42px;
    height: 42px;
    min-height: 42px;
    padding: 0;
    justify-content: center;
    border: 0;
    border-radius: 50%;
    color: inherit;
    background: transparent;
    box-shadow: none;
  }

  .account-avatar {
    display: block;
    width: 40px;
    height: 40px;
    overflow: hidden;
    border-radius: 50%;
    background: transparent;
  }

  .account-avatar img { display: block; width: 100%; height: 100%; object-fit: cover; }
  .account-avatar-btn > svg { display: none; }

  .sr-only {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
  }

  main { overflow: visible; }

  .panel,
  .ai-chat-workspace,
  .personal-library-panel {
    border: 1px solid rgba(255,255,255,.92);
    border-radius: var(--mobile-radius);
    background: var(--mobile-card);
    box-shadow: var(--mobile-shadow);
  }

  .panel {
    padding: 16px;
  }

  .panel-head { margin-bottom: 14px; }
  .panel-head h2,
  .personal-library-header h2 {
    font-size: 21px;
    letter-spacing: -0.02em;
  }

  .workspace-subnav {
    min-height: 42px;
    gap: 4px !important;
    margin-bottom: 12px !important;
    padding: 3px !important;
    border-radius: 14px !important;
    background: rgba(255,255,255,.62) !important;
  }

  .source-workspace-nav,
  .creation-workspace-nav {
    width: 100%;
    justify-content: stretch !important;
  }

  .source-workspace-nav button,
  .creation-workspace-nav button {
    min-width: 0;
    flex: 1 1 0;
    min-height: 38px;
    padding: 5px 6px !important;
    border-radius: 11px !important;
    font-size: 13px;
    font-weight: 700;
  }

  .workspace-subnav button.active {
    color: #171b22;
    background: #fff !important;
    box-shadow: 0 4px 14px rgba(30, 37, 49, .09) !important;
  }

  .field-row { gap: 8px; }

  textarea,
  input:not([type="checkbox"]):not([type="radio"]),
  select {
    border-color: transparent;
    border-radius: 14px;
    background: var(--mobile-soft);
    box-shadow: inset 0 0 0 1px var(--mobile-line);
    font-size: 14px;
  }

  textarea:focus,
  input:focus,
  select:focus {
    border-color: transparent;
    box-shadow: inset 0 0 0 1.5px rgba(179,45,51,.45), 0 0 0 4px rgba(179,45,51,.08);
  }

  #externalSourceMethodSwitch .source-method-action,
  .rewrite-mode-switch button {
    border: 0 !important;
    border-radius: 14px !important;
    color: #59616d;
    background: var(--mobile-soft) !important;
    box-shadow: inset 0 0 0 1px var(--mobile-line) !important;
  }

  #externalSourceMethodSwitch .source-method-action.active,
  .rewrite-mode-switch button.active {
    color: #171b22;
    background: #fff !important;
    box-shadow: 0 6px 18px rgba(30,37,49,.09), inset 0 0 0 1px rgba(179,45,51,.18) !important;
  }

  .primary-btn,
  #ingestLinksBtn,
  #makeRewriteBtn,
  .rewrite-inline-generate-btn {
    min-height: 48px;
    border: 0;
    border-radius: 14px;
    color: #fff;
    background: #a92b32;
    box-shadow: 0 8px 20px rgba(169,43,50,.20);
    font-size: 15px;
    font-weight: 800;
  }

  .primary-btn:disabled,
  #ingestLinksBtn:disabled,
  #makeRewriteBtn:disabled,
  .rewrite-inline-generate-btn:disabled {
    color: #a0a6af;
    background: #eceef1;
    box-shadow: none;
  }

  .rewrite-framework-grid {
    gap: 10px;
  }

  .rewrite-framework-card {
    min-height: 104px;
    padding: 14px;
    border: 0;
    border-radius: 16px;
    background: var(--mobile-soft);
    box-shadow: inset 0 0 0 1px var(--mobile-line);
  }

  .rewrite-framework-card.active {
    color: #8f2429;
    background: #f8ecee;
    box-shadow: inset 0 0 0 1px rgba(169, 43, 50, .28), 0 6px 16px rgba(30,37,49,.07);
  }

  .ai-chat-workspace {
    overflow: hidden;
  }

  .ai-chat-sidebar-head {
    min-height: 50px;
    padding: 8px 14px;
    border-bottom-color: var(--mobile-line);
  }

  .ai-workspace-mode-button {
    min-height: 34px;
    padding: 0;
    font-size: 15px;
  }

  .ai-chat-composer {
    margin: 8px 10px 10px;
    border: 0;
    border-radius: 17px;
    background: #fff;
    box-shadow: 0 8px 24px rgba(28,35,46,.10), inset 0 0 0 1px var(--mobile-line);
  }

  .ai-chat-send-btn {
    border-radius: 11px;
    background: #a92b32;
    box-shadow: 0 6px 14px rgba(169,43,50,.20);
  }

  #aiChatSendBtn {
    width: 52px;
    min-width: 52px;
    height: 32px;
    border-radius: 11px;
  }

  #aiChatSendBtn svg { width: 18px; height: 18px; }

  .personal-library-panel {
    padding: 18px 16px;
  }

  .personal-library-header {
    display: flex !important;
    flex-direction: row !important;
    align-items: center;
    justify-content: space-between;
    text-align: left;
  }

  .personal-library-header > div:first-child {
    grid-column: auto !important;
    min-width: 0;
  }

  .personal-library-total {
    flex: 0 0 auto;
    min-height: 38px;
    padding: 0 10px;
  }

  .personal-library-overview {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .personal-library-overview button {
    min-height: 62px;
    padding: 10px 13px;
  }

  .personal-library-overview button small { white-space: normal; }

  .personal-library-eyebrow {
    color: #a92b32;
    font-size: 10px;
    letter-spacing: .16em;
  }

  .personal-library-filters button {
    min-height: 36px;
    border: 0;
    background: var(--mobile-soft);
    box-shadow: inset 0 0 0 1px var(--mobile-line);
  }

  .personal-library-filters button.active {
    color: #fff;
    background: #252b34;
    box-shadow: none;
  }

  .personal-library-header .personal-library-filters {
    display: flex;
    flex-wrap: wrap;
    overflow: visible;
  }

  .personal-library-filters button {
    flex: 0 0 auto;
    padding: 0 10px;
    font-size: 11px;
  }

  .auto-edit-workspace:not(.has-source) #autoEditChooseSourceBtn {
    border: 0;
    color: #9b272e;
    background: #f7ebed;
    box-shadow: none;
  }

  .step-nav {
    right: 10px;
    bottom: 10px;
    left: 10px;
    min-height: 68px;
    padding: 7px;
    border: 0;
    border-radius: 22px;
    background: rgba(255,255,255,.94);
    box-shadow: 0 14px 38px rgba(27,34,45,.16), inset 0 0 0 1px rgba(255,255,255,.92);
  }

  .step-nav > button,
  .step-nav > .ai-nav-item > button {
    min-height: 52px;
    border-radius: 16px;
    color: #7c8490;
    font-size: 13px !important;
    font-weight: 750;
  }

  .step-nav > button.active,
  .step-nav > .ai-nav-item > button.active {
    color: #fff;
    background: #222831;
    box-shadow: 0 7px 18px rgba(34,40,49,.20) !important;
  }

  .toast {
    right: 14px;
    bottom: calc(92px + env(safe-area-inset-bottom));
    left: 14px;
    width: auto;
    max-width: none;
    text-align: center;
  }
}
