:root {
  --bg: #0c0d12;
  --bg-elevated: #12141b;
  --panel: #161922;
  --panel2: #1c2030;
  --panel3: #232838;
  --border: #2c3348;
  --border-soft: rgba(255, 255, 255, 0.06);
  --text: #f0f2f8;
  --muted: #9aa3b8;
  --accent: #d4a574;
  --accent-strong: #e8c08a;
  --accent-rose: #e09aaa;
  --rose: #c97b8e;
  --accent2: #8da4ff;
  --ok: #3ecf8e;
  --warn: #f0a04b;
  --danger: #e85d5d;
  --flash: #b388ff;
  --extra: #6ec6ff;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.4);
  --shadow-soft: 0 4px 18px rgba(0, 0, 0, 0.25);
  --font: "PingFang SC", "Noto Sans SC", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  --gold-glow: rgba(212, 165, 116, 0.18);
  --rose-glow: rgba(224, 154, 170, 0.14);
}

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(201, 123, 142, 0.12), transparent 55%),
    radial-gradient(900px 500px at 90% 0%, rgba(212, 165, 116, 0.1), transparent 50%),
    var(--bg);
  color: var(--text);
  font-family: var(--font);
  line-height: 1.5;
  min-height: 100%;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent2); text-decoration: none; }
a:hover { text-decoration: underline; }

.app-header {
  position: sticky; top: 0; z-index: 44;
  display: flex; flex-wrap: wrap; gap: 12px; align-items: center;
  justify-content: space-between;
  padding: 10px 18px;
  background: rgba(12, 13, 18, 0.92);
  border-bottom: 1px solid var(--border-soft);
  backdrop-filter: blur(14px);
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 200px; }
.brand-mark {
  width: 36px; height: 36px; border-radius: 12px;
  background:
    linear-gradient(135deg, var(--accent-strong), var(--rose));
  box-shadow: 0 0 0 1px rgba(255,255,255,.12), 0 8px 20px var(--gold-glow);
  flex-shrink: 0;
}
.brand-text { display: flex; flex-direction: column; gap: 2px; }
.brand h1 {
  margin: 0; font-size: 17px; font-weight: 700;
  letter-spacing: 0.03em;
  background: linear-gradient(90deg, var(--accent-strong), var(--accent-rose));
  -webkit-background-clip: text; background-clip: text;
  color: transparent;
}
.brand .sub { color: var(--muted); font-size: 12px; }
.header-right { display: flex; flex-wrap: nowrap; flex-direction: row; gap: 10px; align-items: center; }
.header-right label {
  font-size: 12px; color: var(--muted);
  display: flex; gap: 8px; align-items: center;
}
.header-right input {
  width: 160px; background: var(--panel2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 8px 12px;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.header-right input:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--gold-glow);
}

.top-chrome {
  background: rgba(12, 13, 18, 0.55);
  border-bottom: 1px solid var(--border-soft);
}
.tabs {
  position: sticky;
  top: 58px; /* under compact sticky header */
  z-index: 42;
  display: flex; gap: 6px; flex-wrap: wrap;
  padding: 8px 18px;
  align-items: center;
  background: rgba(12, 13, 18, 0.94);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-soft);
}
.tab {
  background: transparent; border: 1px solid transparent;
  color: var(--muted); padding: 8px 14px; border-radius: 999px;
  cursor: pointer; transition: .15s ease; font-size: 13px;
}
.tab:hover { color: var(--text); background: rgba(255,255,255,.04); }
.tab.active {
  color: #1a1210;
  background: linear-gradient(135deg, var(--accent-strong), var(--accent-rose));
  border-color: transparent; font-weight: 650;
  box-shadow: 0 6px 18px var(--rose-glow);
}

.workflow-strip {
  margin: 0 18px 10px;
  border: 1px solid var(--border-soft);
  border-radius: 12px;
  background: rgba(22, 25, 34, 0.72);
  color: var(--muted);
  font-size: 12.5px;
}
.workflow-strip > summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  align-items: center;
  padding: 8px 12px;
  user-select: none;
}
.workflow-strip > summary::-webkit-details-marker { display: none; }
.workflow-strip > summary::before {
  content: '▸';
  color: var(--accent);
  font-size: 11px;
  width: 12px;
}
.workflow-strip[open] > summary::before { content: '▾'; }
.workflow-strip .wf-label {
  color: var(--accent-strong);
  font-weight: 650;
  letter-spacing: 0.03em;
}
.workflow-strip .wf-brief { color: var(--muted); }
.workflow-strip .workflow-body {
  padding: 0 12px 10px 28px;
  line-height: 1.6;
  border-top: 1px solid var(--border-soft);
  padding-top: 8px;
}
.workflow-strip .workflow-body strong { color: var(--accent-strong); font-weight: 650; }
.workflow-strip .roles { margin-top: 4px; color: #c4cbd9; }

.main {
  padding: 12px 14px 72px;
  max-width: none;
  width: 100%;
  margin: 0;
}
.panel {
  background: rgba(22, 25, 34, 0.92);
  border: 1px solid var(--border-soft);
  border-radius: calc(var(--radius) + 2px);
  padding: 14px;
  box-shadow: var(--shadow);
  min-height: calc(100vh - 170px);
}
.toolbar {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: center;
  margin-bottom: 16px;
}
.toolbar.tight { margin-bottom: 12px; }
.toolbar .spacer { flex: 1; }

.section-label {
  margin: 0;
  font-size: 13px;
  font-weight: 650;
  letter-spacing: 0.04em;
  color: var(--accent-strong);
  text-transform: none;
}

.btn {
  background: var(--panel2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 8px 14px; cursor: pointer;
  transition: .15s ease;
}
.btn:hover { border-color: #4a5470; background: var(--panel3); }
.btn.primary {
  background: linear-gradient(135deg, var(--accent-strong), #d4937a);
  color: #1a1210; border-color: transparent; font-weight: 650;
  box-shadow: 0 4px 14px var(--gold-glow);
}
.btn.primary:hover { filter: brightness(1.05); }
.btn.ghost { background: transparent; }
.btn.danger { border-color: rgba(232, 93, 93, 0.5); color: #ffb4b4; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

select, .field, textarea, input[type="text"], input[type="number"], input[type="file"] {
  background: var(--panel2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 8px 12px;
  transition: border-color .15s ease, box-shadow .15s ease;
}
select:focus, textarea:focus, input[type="text"]:focus, input[type="number"]:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--gold-glow);
}
textarea {
  width: 100%; min-height: 280px; resize: vertical;
  line-height: 1.7; font-size: 13.5px;
  background: #12151d;
}
.muted { color: var(--muted); font-size: 12px; }
.hint-line { margin-top: 10px; }
.row { display: flex; flex-wrap: wrap; gap: 12px; }
.check { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
}
.split {
  display: grid; grid-template-columns: 1.1fr .9fr; gap: 16px;
  margin-top: 16px;
}
@media (max-width: 900px) {
  .split { grid-template-columns: 1fr; }
}

.script-drop {
  border: 1.5px dashed rgba(212, 165, 116, 0.45);
  border-radius: var(--radius);
  padding: 22px 20px;
  background:
    linear-gradient(180deg, rgba(212, 165, 116, 0.06), rgba(224, 154, 170, 0.04));
  transition: .18s ease;
  outline: none;
}
.script-drop:hover,
.script-drop.dragover {
  border-color: var(--accent-strong);
  background:
    linear-gradient(180deg, rgba(212, 165, 116, 0.12), rgba(224, 154, 170, 0.08));
  box-shadow: inset 0 0 0 1px rgba(232, 192, 138, 0.15);
}
.script-drop-visual {
  display: flex; flex-wrap: wrap; gap: 14px 18px;
  align-items: center; justify-content: space-between;
}
.script-drop-icon {
  width: 48px; height: 48px; border-radius: 14px;
  display: grid; place-items: center; font-size: 24px;
  background: rgba(255,255,255,.04);
  border: 1px solid var(--border-soft);
  flex-shrink: 0;
}
.script-drop-copy { flex: 1; min-width: 200px; }
.script-drop-title {
  font-size: 15px; font-weight: 650; color: var(--text); margin-bottom: 4px;
}
.script-drop-hint { font-size: 12.5px; color: var(--muted); line-height: 1.5; }

.script-editor-card,
.script-result-card {
  background: var(--panel2);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 14px;
}

.script-box {
  white-space: pre-wrap; font-size: 13px; line-height: 1.6;
  background: #12151c; border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 12px; max-height: 62vh; overflow: auto;
}

.asset-list {
  display: flex; flex-direction: column; gap: 5px;
  max-height: 62vh; overflow: auto; padding-right: 2px;
}
.asset-row {
  display: flex; gap: 8px; align-items: flex-start;
  padding: 7px 10px;
  border: 1px solid var(--border-soft);
  border-radius: 10px;
  background: rgba(18, 21, 29, 0.85);
  transition: border-color .15s ease, transform .15s ease;
}
.asset-row.compact { padding: 6px 9px; }
.asset-row:hover { border-color: rgba(212, 165, 116, 0.35); }
.asset-row .meta { flex: 1; min-width: 0; }
.asset-row-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 3px;
}
.asset-row h4 { margin: 0; font-size: 12.5px; font-weight: 650; line-height: 1.25; }
.asset-row .muted.one-line {
  margin-top: 2px;
  font-size: 10.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.asset-row .btn.danger.sm {
  padding: 2px 7px;
  font-size: 11px;
  border-radius: 7px;
  flex-shrink: 0;
}
.badges { display: flex; flex-wrap: wrap; gap: 4px; }
.badge {
  font-size: 10px; padding: 1px 7px; border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--muted); letter-spacing: 0.02em;
  line-height: 1.4;
}
.badge.flash {
  color: #efe6ff; border-color: rgba(179, 136, 255, 0.45);
  background: rgba(179, 136, 255, 0.16);
}
.badge.extra {
  color: #dff3ff; border-color: rgba(110, 198, 255, 0.4);
  background: rgba(110, 198, 255, 0.12);
}
.badge.type-character {
  color: #ffe8b0; border-color: rgba(212, 165, 116, 0.5);
  background: rgba(212, 165, 116, 0.12);
}
.badge.type-scene {
  color: #c8ffde; border-color: rgba(62, 207, 142, 0.4);
  background: rgba(62, 207, 142, 0.1);
}
.badge.type-prop {
  color: #ffd0d0; border-color: rgba(224, 154, 170, 0.45);
  background: rgba(224, 154, 170, 0.12);
}
.badge.selected {
  color: #d8ffe9; border-color: var(--ok);
  background: rgba(62, 207, 142, 0.14);
}

.card {
  background: linear-gradient(180deg, rgba(28, 32, 48, 0.95), rgba(22, 25, 34, 0.98));
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 16px;
  display: flex; flex-direction: column; gap: 14px;
  box-shadow: var(--shadow-soft);
  transition: border-color .15s ease, transform .15s ease;
}
.card:hover {
  border-color: rgba(212, 165, 116, 0.28);
  transform: translateY(-1px);
}
.card h3 {
  margin: 0; font-size: 15px; font-weight: 650;
  display: flex; flex-wrap: wrap; gap: 6px; align-items: center;
}

.dropzone, .drop-zone {
  border: 1.5px dashed #3a4460; border-radius: 12px; padding: 12px;
  text-align: center; color: var(--muted); font-size: 12.5px;
  min-height: 120px;
  display: flex; flex-direction: column;
  gap: 8px;
  transition: .15s ease; cursor: pointer;
  background: rgba(12, 13, 18, 0.35);
  position: relative;
}
.dropzone:hover,
.dropzone.dragover,
.drop-zone:hover,
.drop-zone.dragover {
  border-color: var(--accent);
  background: rgba(212, 165, 116, 0.10);
  color: var(--text);
  box-shadow: inset 0 0 0 1px rgba(212,165,116,.25);
}
.dropzone-visual {
  min-height: 64px;
  display: flex; align-items: center; justify-content: center;
  pointer-events: none;
}
.zone-file {
  position: absolute !important;
  width: 1px !important; height: 1px !important;
  opacity: 0 !important; overflow: hidden !important;
  clip: rect(0,0,0,0) !important;
  pointer-events: none !important;
}
.drop-zone .thumbs { pointer-events: auto; }
.drop-zone.dragover .drop-copy { color: var(--accent-strong); font-weight: 650; }

.thumbs { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.thumb {
  width: 104px; background: #12151c; border: 1px solid var(--border);
  border-radius: 10px; overflow: hidden; position: relative;
}
.thumb img, .thumb video {
  width: 100%; height: 76px; object-fit: cover; display: block; background: #000;
}
.thumb .cap { font-size: 10px; padding: 5px 6px; color: var(--muted); word-break: break-all; }
.thumb .actions { display: flex; gap: 4px; padding: 0 4px 6px; flex-wrap: wrap; }
.thumb .actions button { font-size: 11px; padding: 3px 6px; }
.thumb.picked { outline: 2px solid var(--ok); outline-offset: 1px; }

.seg {
  display: inline-flex; flex-wrap: wrap; gap: 4px; background: var(--panel2);
  border: 1px solid var(--border); border-radius: 999px; padding: 4px;
}
.seg button {
  border: 0; background: transparent; color: var(--muted);
  padding: 7px 12px; border-radius: 999px; cursor: pointer; font-size: 12px;
}
.seg button.active {
  background: linear-gradient(135deg, var(--accent-strong), var(--accent-rose));
  color: #1a1210; font-weight: 650;
}

.table-wrap {
  overflow: auto; border-radius: 12px;
  border: 1px solid var(--border-soft);
}
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td {
  text-align: left; padding: 12px 14px;
  border-bottom: 1px solid var(--border-soft); vertical-align: middle;
}
th {
  color: var(--muted); font-weight: 650; font-size: 12px;
  background: rgba(18, 21, 29, 0.96); letter-spacing: 0.03em;
  position: sticky; top: 0; z-index: 2;
}
tr:last-child td { border-bottom: 0; }
tr:hover td { background: rgba(255,255,255,.02); }
td img {
  width: 56px; height: 42px; object-fit: cover;
  border-radius: 8px; background: #000;
}

.shot {
  border: 1px solid var(--border-soft); border-radius: 14px;
  padding: 14px 16px; background: var(--panel2); margin-bottom: 12px;
}
.shot .head { display: flex; gap: 8px; align-items: center; margin-bottom: 10px; }
.comments { margin-top: 10px; display: flex; flex-direction: column; gap: 8px; }
.comment {
  background: #12151c; border-radius: 10px; padding: 10px 12px; font-size: 13px;
  border: 1px solid var(--border-soft);
}
.comment .who { color: var(--accent-rose); font-weight: 650; margin-right: 6px; }
.comment .when { color: var(--muted); font-size: 11px; margin-left: 6px; }
.comment-form { display: flex; gap: 8px; margin-top: 8px; }
.comment-form input { flex: 1; }

.video-layout { display: grid; grid-template-columns: 1.2fr .8fr; gap: 16px; }
@media (max-width: 900px) { .video-layout { grid-template-columns: 1fr; } }
video.player {
  width: 100%; max-height: 60vh; background: #000;
  border-radius: 14px; border: 1px solid var(--border-soft);
}

.modal-mask {
  position: fixed; inset: 0; background: rgba(0,0,0,.62); z-index: 110;
  display: flex; align-items: center; justify-content: center; padding: 16px;
  backdrop-filter: blur(4px);
}
.modal {
  width: min(520px, 100%);
  background: var(--panel);
  border: 1px solid var(--border-soft);
  border-radius: 18px; padding: 20px;
  box-shadow: var(--shadow);
}
.modal h3 { margin: 0 0 14px; font-size: 16px; }
.modal .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.modal label { font-size: 12px; color: var(--muted); display: flex; flex-direction: column; gap: 6px; }
.modal label.check { flex-direction: row; align-items: center; }

.hidden { display: none !important; }
.empty {
  padding: 36px 16px; text-align: center; color: var(--muted);
  border: 1px dashed var(--border); border-radius: 14px;
  background: rgba(0,0,0,.12);
}

.toast {
  position: fixed;
  left: 50%;
  top: calc(12px + env(safe-area-inset-top, 0px));
  bottom: auto;
  right: auto;
  z-index: 240;
  transform: translateX(-50%) translateY(-10px);
  background: linear-gradient(135deg, #2a2433, #223049);
  border: 1px solid rgba(212, 165, 116, 0.35);
  color: var(--text);
  padding: 11px 18px;
  border-radius: 12px;
  box-shadow: var(--shadow);
  opacity: 0;
  transition: opacity .2s ease, transform .2s ease;
  pointer-events: none;
  max-width: min(420px, calc(100vw - 32px));
  width: max-content;
  text-align: center;
  font-size: 13px;
  line-height: 1.35;
  font-weight: 500;
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.toast.toast-ok {
  border-color: rgba(90, 200, 140, 0.55);
  color: #b8f0d0;
}
.toast.toast-err {
  border-color: rgba(230, 100, 100, 0.55);
  color: #ffc4c4;
}

/* —— Produce layout: sticky episode rail + cards + chat —— */
.panel-produce {
  padding: 14px;
  overflow: visible;
}
.produce-layout {
  display: grid;
  grid-template-columns: 156px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
  min-height: calc(100vh - 160px);
}
@media (max-width: 900px) {
  .produce-layout { grid-template-columns: 1fr; }
  .ep-rail {
    position: relative !important;
    top: auto !important;
    max-height: 220px;
  }
}
.ep-rail {
  position: sticky;
  top: 12px;
  align-self: start;
  z-index: 5;
  background: var(--panel2);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  min-height: 0;
  max-height: calc(100vh - 130px);
  overflow: hidden;
  box-shadow: var(--shadow-soft);
}
.ep-rail-head {
  padding: 12px 14px;
  font-size: 12px;
  font-weight: 650;
  letter-spacing: 0.06em;
  color: var(--accent-strong);
  border-bottom: 1px solid var(--border-soft);
  flex-shrink: 0;
}
.ep-rail-list {
  overflow: auto;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
  min-height: 0;
  max-height: none;
}
.ep-rail-item {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  text-align: left;
  width: 100%;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  padding: 10px 12px;
  border-radius: 10px;
  cursor: pointer;
  transition: .15s ease;
}
.ep-rail-item:hover {
  background: rgba(255,255,255,.04);
  color: var(--text);
}
.ep-rail-item.active {
  background: linear-gradient(135deg, rgba(212,165,116,.18), rgba(224,154,170,.12));
  border-color: rgba(212,165,116,.35);
  color: var(--text);
}
.ep-rail-item .ep-num { font-weight: 650; font-size: 13px; }
.ep-rail-item .ep-title {
  font-size: 11px;
  opacity: .75;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}
.ep-rail-item.has-script .ep-num::after {
  content: '';
  display: inline-block;
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--ok);
  margin-left: 6px;
  vertical-align: middle;
}
.produce-main { min-width: 0; }
.produce-grid {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.produce-card .card-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}
.produce-card .zones {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
@media (max-width: 980px) {
  .produce-card .zones { grid-template-columns: 1fr; }
}
.zone-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 8px;
  font-size: 13px;
  font-weight: 650;
  color: var(--text);
}
.zone-head em {
  font-style: normal;
  color: var(--accent-strong);
  margin-left: 4px;
}
.drop-copy { pointer-events: none; }
.empty-thumbs { padding: 8px 0; font-size: 12px; }
.thumb {
  width: 132px;
}
.thumb img, .thumb video { height: 90px; }
.thumb-more {
  position: absolute;
  top: 4px; right: 4px;
  width: 26px; height: 26px;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,.2);
  background: rgba(0,0,0,.55);
  color: #fff;
  cursor: pointer;
  line-height: 1;
  padding: 0;
  font-size: 14px;
}
.thumb-more:hover { background: rgba(212,165,116,.55); color: #1a1210; }
.thumb .cap .fname {
  color: #c9d0e0;
}
.thumb.in-lib { box-shadow: inset 0 0 0 1px rgba(141,164,255,.5); }
.thumb .actions a.btn {
  font-size: 11px;
  padding: 3px 6px;
  text-decoration: none;
}
.badge.lib {
  color: #dce4ff;
  border-color: rgba(141,164,255,.5);
  background: rgba(141,164,255,.14);
}
.produce-card.selected-target {
  border-color: rgba(212, 165, 116, 0.55);
  box-shadow: 0 0 0 1px rgba(212,165,116,.25), var(--shadow-soft);
}
.produce-card { cursor: default; }
.produce-card .card-head { cursor: pointer; }

/* Right chat panel */
.produce-chat {
  position: sticky;
  top: 84px;
  align-self: start;
  z-index: 5;
  display: flex;
  flex-direction: column;
  min-height: 0;
  max-height: calc(100vh - 100px);
  background: var(--panel2);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-soft);
}
.chat-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-soft);
  flex-shrink: 0;
  background: linear-gradient(180deg, rgba(212,165,116,.08), transparent);
}
.chat-title {
  font-size: 13px;
  font-weight: 650;
  color: var(--accent-strong);
  letter-spacing: 0.04em;
}
.chat-dock-panel, .produce-chat {
  overflow: hidden;
}
.chat-messages {
  flex: 1;
  min-height: 120px;
  overflow: auto;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: rgba(12, 13, 18, 0.35);
}
.chat-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  max-width: min(92%, 560px);
  width: fit-content;
}
.chat-row.mine {
  align-self: flex-end;
  flex-direction: row-reverse;
  max-width: min(92%, 560px);
}
.chat-row.theirs {
  align-self: flex-start;
}
.chat-row.system {
  align-self: center;
  max-width: min(96%, 480px);
}
.chat-row.mention .chat-bubble {
  box-shadow: inset 3px 0 0 var(--accent-purple);
}
.chat-avatar {
  width: 34px;
  height: 34px;
  flex-shrink: 0;
  border-radius: 50%;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,.12);
  background: #1a1d28;
}
.chat-avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.chat-avatar-fallback {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  font-size: 13px;
  font-weight: 700;
  color: #fff;
}
.chat-msg, .chat-bubble {
  background: rgba(22, 25, 34, 0.96);
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 14px 14px 14px 6px;
  padding: 8px 11px 10px;
  font-size: 13px;
  min-width: 0;
}
.chat-bubble.mine {
  background: linear-gradient(160deg, rgba(110,85,190,.42), rgba(55,42,110,.55));
  border-color: rgba(168,140,255,.42);
  border-radius: 14px 14px 6px 14px;
  color: #f4f1ff;
}
.chat-bubble.theirs {
  background: rgba(28, 32, 42, 0.96);
  border-color: rgba(255,255,255,.1);
}
.chat-bubble.system-msg {
  background: rgba(255,255,255,.04);
  border-style: dashed;
  text-align: center;
  opacity: .9;
}
.chat-meta {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 2px;
}
.chat-msg .who, .chat-bubble .who { color: var(--accent-rose); font-weight: 650; margin-right: 0; font-size: 12px; }
.chat-bubble.mine .who { color: #e4d8ff; }
.chat-msg .when, .chat-bubble .when { color: var(--muted); font-size: 10.5px; float: none; margin-left: auto; }
.chat-msg .body, .chat-bubble .body { margin-top: 4px; white-space: pre-wrap; word-break: break-word; line-height: 1.45; }
.chat-msg-img {
  display: block;
  margin-top: 8px;
  max-width: 100%;
  max-height: 240px;
  border-radius: 10px;
  border: 1px solid var(--border);
  cursor: context-menu;
  background: #000;
  object-fit: contain;
}
.chat-msg-img:hover {
  outline: 2px solid rgba(212,165,116,.45);
  outline-offset: 1px;
}
body.view-workbench.chat-wide .chat-row {
  max-width: min(88%, 640px);
}
body.view-workbench.chat-wide .chat-msg-img {
  max-height: 280px;
}
.chat-compose {
  border-top: 1px solid var(--border-soft);
  padding: 12px;
  flex-shrink: 0;
  background: rgba(14, 16, 22, 0.96);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.mention-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}
.mention-bar .chip {
  border: 1px solid rgba(255,255,255,0.1);
  background: rgba(255,255,255,0.04);
  color: rgba(255,255,255,0.72);
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 12px;
  cursor: pointer;
}
.mention-bar .chip:hover { color: #fff; border-color: rgba(168,140,255,0.45); }
.mention-bar .chip.active {
  color: #140f22;
  background: linear-gradient(135deg, #c4b0ff, #9b7bff);
  border-color: transparent;
  font-weight: 650;
}
.mention-bar .chip.dim { opacity: 0.35; }
.mention-bar.suggesting, .mention-bar.pulse {
  outline: 1px solid rgba(168,140,255,0.35);
  outline-offset: 3px;
  border-radius: 12px;
}
.composer-shell {
  position: relative;
  border-radius: 18px;
  border: 1px solid rgba(255,255,255,0.08);
  background: #1a1d26;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.03);
  padding: 12px 12px 8px;
}
.composer-shell:focus-within {
  border-color: rgba(168,140,255,0.45);
  box-shadow: 0 0 0 2px rgba(168,140,255,0.12);
}
.composer-shell textarea#chatInput {
  width: 100%;
  min-height: 72px;
  max-height: 220px;
  resize: none;
  overflow-y: auto;
  padding: 4px 4px 10px;
  border: 0;
  background: transparent;
  color: #f2f2f5;
  font: inherit;
  font-size: 14px;
  line-height: 1.5;
  box-sizing: border-box;
}
.composer-shell textarea#chatInput:focus { outline: none; }
.composer-shell textarea#chatInput::placeholder { color: rgba(255,255,255,0.28); }
.composer-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding-top: 2px;
}
.composer-tools-left {
  display: flex;
  align-items: center;
  gap: 4px;
}
.icon-btn {
  width: 34px;
  height: 34px;
  border-radius: 999px;
  border: 0;
  background: transparent;
  color: rgba(255,255,255,0.55);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: background .15s, color .15s;
}
.icon-btn:hover {
  background: rgba(255,255,255,0.06);
  color: #fff;
}
.icon-btn.send {
  background: rgba(168,140,255,0.18);
  color: #d7c7ff;
  font-size: 14px;
}
.icon-btn.send:hover {
  background: rgba(168,140,255,0.32);
  color: #fff;
}
.chat-tip { margin: 0; line-height: 1.4; font-size: 11px; }
.chat-file {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid var(--border-soft);
  background: rgba(255,255,255,0.04);
  color: var(--accent-strong, #e8c9a0);
  text-decoration: none;
  font-size: 12px;
  word-break: break-all;
}
.chat-file:hover { border-color: rgba(212,165,116,.5); }
.chat-pending .pending-file {
  width: 44px; height: 44px; display: grid; place-items: center;
  border-radius: 8px; background: rgba(255,255,255,0.06); font-size: 20px;
}
.chat-pending .pending-name { flex: 1; min-width: 0; word-break: break-all; }
.chat-input-row {
  display: flex;
  gap: 8px;
  align-items: center;
}
.chat-input-row input[type="text"] { flex: 1; min-width: 0; }
.chat-pending {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  padding: 6px 8px;
  background: rgba(212,165,116,.1);
  border: 1px dashed rgba(212,165,116,.35);
  border-radius: 10px;
  font-size: 12px;
  color: var(--muted);
}
.chat-pending img {
  width: 44px; height: 44px; object-fit: cover;
  border-radius: 8px; background: #000;
}
.chat-pending .x {
  margin-left: auto;
  border: 0; background: transparent;
  color: #ffb4b4; cursor: pointer; font-size: 16px;
}
.produce-chat.dragover {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}
.produce-main { min-width: 0; }


/* Context menu */
.ctx-menu {
  position: fixed;
  z-index: 120;
  min-width: 180px;
  background: #1a1e2a;
  border: 1px solid rgba(212,165,116,.35);
  border-radius: 12px;
  padding: 6px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.ctx-menu button {
  text-align: left;
  border: 0;
  background: transparent;
  color: var(--text);
  padding: 9px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
}
.ctx-menu button:hover {
  background: rgba(212,165,116,.16);
}
.ctx-menu button.danger { color: #ffb4b4; }
.ctx-menu button.danger:hover { background: rgba(232,93,93,.16); }

.search-input {
  min-width: 220px;
  background: var(--panel2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
}
.fname-cell {
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  color: var(--muted);
}
.empty.small { padding: 16px 8px; font-size: 12px; }


/* —— Global floating chat (all tabs) —— */
/* z-index: above page content, below modals (110) and ctx (120) */
.global-chat {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 55;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
  pointer-events: none;
}
.global-chat > * { pointer-events: auto; }
.global-chat-toggle {
  display: none;
  align-items: center;
  gap: 8px;
  border: 1px solid rgba(212,165,116,.45);
  background: linear-gradient(135deg, #2a2433, #223049);
  color: var(--text);
  padding: 11px 16px;
  border-radius: 999px;
  cursor: pointer;
  box-shadow: var(--shadow);
  font-size: 13px;
  font-weight: 650;
  user-select: none;
}
.global-chat-toggle:hover {
  border-color: var(--accent-strong);
  box-shadow: 0 8px 24px var(--gold-glow);
}
.global-chat.collapsed .global-chat-toggle { display: inline-flex; }
.global-chat.collapsed .global-chat-panel { display: none; }
.global-chat.open .global-chat-panel { display: flex; }
.global-chat.open .global-chat-toggle { display: none; }
.global-chat-panel.produce-chat {
  position: static;
  top: auto;
  width: min(380px, calc(100vw - 28px));
  height: min(560px, calc(100vh - 110px));
  max-height: min(560px, calc(100vh - 110px));
  z-index: 55;
  box-shadow: 0 16px 48px rgba(0,0,0,.55);
}
.chat-head-text { min-width: 0; flex: 1; }
.chat-head-text .muted { font-size: 11.5px; line-height: 1.35; }
.chat-head-actions { display: flex; gap: 4px; flex-shrink: 0; }
.global-chat-panel.dragover,
.produce-chat.dragover {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}
@media (max-width: 640px) {
  .global-chat { right: 10px; bottom: 10px; left: 10px; align-items: stretch; }
  .global-chat-panel.produce-chat { width: 100%; height: min(68vh, 520px); }
}

.global-chat .produce-chat {
  position: relative !important;
  top: auto !important;
  align-self: auto;
}

/* Fill width: drop earlier max-width clamp */
.main { max-width: none; }
.panel-produce { min-height: calc(100vh - 160px); }
.produce-main .toolbar { position: sticky; top: 0; z-index: 3; background: rgba(22,25,34,.92); padding: 4px 0 10px; backdrop-filter: blur(8px); }
.split { gap: 12px; margin-top: 12px; }
.grid { grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }
.table-wrap { max-height: calc(100vh - 220px); }

/* ===== workflow2 overrides ===== */
:root {
  --accent-purple: #9b7bff;
  --purple-glow: rgba(155, 123, 255, 0.22);
  --accent2: #9b7bff;
}

body.chat-dock-open .app-shell {
  --chat-w: 400px;
}
body.chat-dock-collapsed .app-shell {
  --chat-w: 0px;
}

.app-shell {
  display: flex;
  align-items: stretch;
  min-height: calc(100vh - 120px);
  gap: 0;
}
.app-shell > .main {
  flex: 1;
  min-width: 0;
  padding-right: 12px;
  transition: margin .2s ease;
}
body.chat-dock-open .app-shell > .main {
  margin-right: 0;
}

/* Right dock chat */
.chat-dock {
  position: sticky;
  top: 58px;
  align-self: start;
  width: var(--chat-w, 400px);
  max-width: 42vw;
  height: calc(100vh - 70px);
  z-index: 50;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  pointer-events: none;
  transition: width .2s ease;
}
.chat-dock > * { pointer-events: auto; }
.chat-dock.collapsed {
  width: 0;
  max-width: 0;
  overflow: visible;
}
.chat-dock.collapsed .chat-dock-panel { display: none; }
.chat-dock.open .chat-dock-panel { display: flex; }
.chat-dock.open .chat-fab { display: none; }
.chat-dock.collapsed .chat-fab {
  display: inline-flex;
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 56;
}
.chat-fab {
  display: none;
  align-items: center;
  gap: 8px;
  border: 1px solid rgba(155,123,255,.5);
  background: linear-gradient(135deg, #2a2438, #1e2740);
  color: var(--text);
  padding: 12px 18px;
  border-radius: 999px;
  cursor: pointer;
  box-shadow: 0 10px 28px var(--purple-glow);
  font-size: 13px;
  font-weight: 650;
}
.chat-fab .unread-badge {
  min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 999px; background: var(--danger); color: #fff;
  font-size: 11px; display: inline-grid; place-items: center;
}
.chat-dock-panel.produce-chat {
  position: relative !important;
  top: auto !important;
  width: 100%;
  height: 100%;
  max-height: none;
  border-radius: 16px 0 0 16px;
  border-right: 0;
  box-shadow: -8px 0 32px rgba(0,0,0,.35);
  background: linear-gradient(180deg, #1a1d2a, #141722);
}
.chat-filters {
  margin: 0 12px 8px;
  flex-shrink: 0;
}
.mention-chips {
  display: flex; flex-wrap: wrap; gap: 6px;
  margin-bottom: 8px;
}
.mention-chips .chip {
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 11.5px;
  cursor: pointer;
}
.mention-chips .chip.active,
.mention-chips .chip:hover {
  border-color: var(--accent-purple);
  color: #e8e0ff;
  background: rgba(155,123,255,.16);
}
.chat-msg.for-me, .chat-bubble.for-me {
  border-color: rgba(155,123,255,.5);
}
.chat-msg.system-msg {
  opacity: .85;
  border-style: dashed;
}
.chat-msg .role-tag {
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 999px;
  margin-left: 4px;
  border: 1px solid var(--border);
  color: var(--muted);
}
.chat-msg .role-tag.client { color: #ffe8b0; border-color: rgba(212,165,116,.45); }
.chat-msg .role-tag.costume { color: #ffd0e0; border-color: rgba(224,154,170,.45); }
.chat-msg .role-tag.scene { color: #c8ffde; border-color: rgba(62,207,142,.4); }
.chat-msg .role-tag.face { color: #dce4ff; border-color: rgba(141,164,255,.5); }
.chat-msg .to-tag {
  font-size: 11px; color: var(--accent-purple); margin-left: 4px;
}
.header-right select {
  background: var(--panel2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 8px 10px; min-width: 120px;
}

/* Pipeline status legend (non-filter) + gap filters in sticky bar */
.pipe-legend {
  display: flex; flex-wrap: wrap; gap: 6px; align-items: center;
  margin: 0 0 12px; padding: 0 2px;
}
.pipe-legend-label {
  font-size: 11px; margin-right: 2px;
}
.pipe-legend .pill {
  cursor: default;
  pointer-events: none;
}
button.pill,
.pill {
  font-size: 11px; padding: 3px 9px; border-radius: 999px;
  border: 1px solid var(--border); color: var(--muted);
  background: transparent; cursor: pointer; font: inherit;
  line-height: 1.35; transition: background .15s, border-color .15s, box-shadow .15s, color .15s;
}
button.pill:hover { filter: brightness(1.12); }
.pill.need_ref { color: #c9d0e0; background: rgba(255,255,255,.04); }
.pill.in_design { color: #ffe8b0; background: rgba(212,165,116,.12); border-color: rgba(212,165,116,.4); }
.pill.pending_pick { color: #ffd9a8; background: rgba(240,160,75,.12); border-color: rgba(240,160,75,.4); }
.pill.picked { color: #dce4ff; background: rgba(155,123,255,.14); border-color: rgba(155,123,255,.45); }
.pill.merged { color: #e0d4ff; background: rgba(155,123,255,.22); border-color: rgba(155,123,255,.55); }
.pill.locked { color: #d8ffe9; background: rgba(62,207,142,.14); border-color: var(--ok); }
.produce-gap-filters {
  display: flex; flex-wrap: wrap; gap: 6px; align-items: center;
  margin-left: auto; flex-shrink: 0;
}
.produce-sticky-bar .produce-gap-filters {
  margin-left: 0;
}
.pill.gap-filter {
  color: #ffc9d6; background: rgba(255,105,135,.08);
  border-color: rgba(255,105,135,.35);
}
.pill.gap-filter.active {
  box-shadow: 0 0 0 2px rgba(255,140,160,.35), 0 0 12px rgba(255,105,135,.22);
  background: rgba(255,105,135,.22);
  border-color: rgba(255,140,160,.7);
  color: #ffd0db;
  font-weight: 650;
  filter: brightness(1.08);
}
.pipe-legend-sep {
  width: 1px; height: 16px; margin: 0 2px;
  background: rgba(255,255,255,.12); flex-shrink: 0;
}

.badge.pipe { font-weight: 650; }
.badge.wait { color: #ffd9a8; border-color: rgba(240,160,75,.45); background: rgba(240,160,75,.1); }

/* Character card with 3-thumb switcher */
.char-card-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 72px;
  gap: 12px;
  align-items: stretch;
}
.char-main-preview {
  position: relative;
  background: #0a0b10;
  border: 1px solid var(--border-soft);
  border-radius: 14px;
  overflow: hidden;
  min-height: 0;
  display: grid;
  place-items: center;
}
.char-main-preview img {
  width: 100%; height: 100%; object-fit: contain; background: #fff1;
}
.char-main-preview .empty-preview {
  color: var(--muted); font-size: 12px; padding: 12px; text-align: center;
}
.char-thumbs {
  display: flex; flex-direction: column; gap: 8px;
}
.char-thumbs button {
  width: 72px; height: 72px; padding: 0;
  border-radius: 10px; border: 1px solid var(--border);
  background: #12151c; overflow: hidden; cursor: pointer;
  opacity: .7; transition: .15s ease;
}
.char-thumbs button img {
  width: 100%; height: 100%; object-fit: cover; display: block;
}
.char-thumbs button.active,
.char-thumbs button:hover {
  opacity: 1;
  border-color: var(--accent-purple);
  box-shadow: 0 0 0 2px var(--purple-glow);
}
.char-thumbs .thumb-label {
  display: block; font-size: 9px; color: var(--muted);
  text-align: center; margin-top: 2px;
}
.stage-slots {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px;
  margin-top: 4px;
}
.stage-slots .drop-zone { min-height: 100px; }
.card-actions-row {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
}
.stage-progress {
  display: flex; gap: 4px; flex-wrap: wrap; margin-top: 6px;
}
.stage-dot {
  font-size: 10px; padding: 2px 7px; border-radius: 999px;
  border: 1px solid var(--border); color: var(--muted);
}
.stage-dot.on { color: #e8e0ff; border-color: rgba(155,123,255,.5); background: rgba(155,123,255,.14); }
.stage-dot.done { color: #d8ffe9; border-color: var(--ok); background: rgba(62,207,142,.12); }

/* Pick / completeness */
.completeness {
  display: flex; align-items: center; gap: 10px;
  padding: 4px 10px; border-radius: 12px;
  background: rgba(155,123,255,.08); border: 1px solid rgba(155,123,255,.25);
}
.completeness .ring { width: 36px; height: 36px; transform: rotate(-90deg); }
.ring-bg { fill: none; stroke: rgba(255,255,255,.08); stroke-width: 3; }
.ring-fg {
  fill: none; stroke: var(--accent-purple); stroke-width: 3;
  stroke-linecap: round;
  stroke-dasharray: 97.4;
  stroke-dashoffset: 97.4;
  transition: stroke-dashoffset .35s ease;
}
.comp-text { font-size: 12px; color: var(--muted); line-height: 1.2; }
.comp-text strong { color: var(--text); font-size: 15px; margin-right: 2px; }

.pick-grid, .library-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}
.pick-card, .lib-card {
  background: linear-gradient(180deg, rgba(28,32,48,.95), rgba(22,25,34,.98));
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 14px;
  display: flex; flex-direction: column; gap: 10px;
  transition: transform .15s ease, border-color .15s ease;
}
.pick-card:hover, .lib-card:hover {
  transform: translateY(-2px);
  border-color: rgba(155,123,255,.35);
}
.pick-card.empty-card {
  border-style: dashed;
  opacity: .92;
}
.pick-card .preview {
  height: 160px; border-radius: 12px; background: #0a0b10;
  display: grid; place-items: center; overflow: hidden;
  border: 1px solid var(--border-soft);
}
.pick-card .preview img {
  width: 100%; height: 100%; object-fit: contain;
}
.lib-card .preview {
  height: 140px; border-radius: 12px; overflow: hidden; background: #000;
}
.lib-card .preview img { width: 100%; height: 100%; object-fit: contain; }
.lib-card .used-yes { color: #d8ffe9; }
.lib-card .used-no { color: #ffd9a8; }

.wf-steps {
  display: flex; flex-wrap: wrap; gap: 8px 14px;
  margin-bottom: 6px;
}
.wf-steps span {
  font-size: 12px; color: #d4d9e8;
  padding: 4px 8px; border-radius: 8px;
  background: rgba(155,123,255,.08);
  border: 1px solid rgba(155,123,255,.18);
}

.tab.active {
  background: linear-gradient(135deg, #c4b0ff, #9b7bff);
  color: #140f22;
  box-shadow: 0 6px 18px var(--purple-glow);
}
.btn.primary {
  background: linear-gradient(135deg, #c4b0ff, #9b7bff);
  color: #140f22;
  box-shadow: 0 4px 14px var(--purple-glow);
}

@media (max-width: 960px) {
  body.chat-dock-open .app-shell { flex-direction: column; }
  .chat-dock, body.chat-dock-open .chat-dock {
    position: fixed; right: 0; top: auto; bottom: 0;
    width: min(420px, 100vw); height: min(70vh, 560px);
    max-width: 100vw;
  }
  .chat-dock-panel.produce-chat { border-radius: 16px 16px 0 0; }
  .char-card-body { grid-template-columns: 1fr; }
  .char-thumbs { flex-direction: row; }
}


/* ===== ui3 shell / layout / polish ===== */
html, body {
  height: 100%;
  overflow: hidden;
}
.app-frame {
  height: 100vh;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.app-header {
  flex-shrink: 0;
  display: grid;
  grid-template-columns: minmax(160px, 220px) minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 8px 16px;
  position: relative;
  z-index: 60;
}
.app-header .brand { cursor: pointer; min-width: 0; }
.app-header .header-right {
  justify-self: end;
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: center;
  gap: 8px;
  min-width: 0;
  max-width: none;
}
.header-center {
  justify-self: center;
  min-width: 0;
  max-width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
}
.app-nav {
  display: flex;
  gap: 6px;
  justify-self: center;
  flex-wrap: wrap;
  justify-content: center;
}
.app-nav.hidden { display: none !important; }
.app-nav-btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--muted);
  padding: 7px 14px;
  border-radius: 999px;
  cursor: pointer;
  font-size: 13px;
  white-space: nowrap;
  text-decoration: none;
  box-shadow: none;
  position: relative;
}
.app-nav-btn::after,
.app-nav-btn.active::after {
  content: none !important;
  display: none !important;
}
.app-nav-btn:hover { color: var(--text); background: rgba(255,255,255,.04); }
.app-nav-btn.active {
  color: #efeaff;
  background: rgba(155, 123, 255, 0.18);
  border: 1px solid rgba(180, 160, 255, 0.36);
  font-weight: 600;
  text-decoration: none;
  border-bottom-width: 1px;
  border-bottom-style: solid;
  border-bottom-color: rgba(180, 160, 255, 0.36);
  box-shadow:
    0 0 0 1px rgba(155, 123, 255, 0.06),
    0 8px 22px rgba(110, 80, 210, 0.2);
}
.project-tabs {
  position: static;
  left: auto;
  transform: none;
  display: flex;
  gap: 4px;
  flex-wrap: nowrap;
  justify-content: center;
  justify-self: center;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 2px 0;
  background: transparent;
  border: 0;
  top: auto;
  z-index: auto;
  scrollbar-width: none;
}
.project-tabs::-webkit-scrollbar { display: none; }
.project-tabs.hidden { display: none !important; }
.project-tabs .tab {
  padding: 7px 12px;
  font-size: 12.5px;
  white-space: nowrap;
  flex: 0 0 auto;
}
.project-chip {
  font-size: 12px;
  color: var(--accent-strong);
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid rgba(212,165,116,.3);
  background: rgba(212,165,116,.08);
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.profile-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--border);
  background: var(--panel2);
  border-radius: 999px;
  padding: 4px 12px 4px 4px;
  cursor: pointer;
  color: var(--text);
}
.profile-chip:hover { border-color: rgba(155,123,255,.45); }
.avatar {
  width: 28px; height: 28px; border-radius: 50%;
  display: inline-grid; place-items: center;
  font-size: 12px; font-weight: 700; color: #140f22;
  background: #9b7bff;
}
.avatar.lg { width: 48px; height: 48px; font-size: 18px; }
.profile-name { font-size: 13px; max-width: 100px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.profile-preview-row { display: flex; align-items: center; gap: 12px; }
.color-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 6px; }
.swatch {
  width: 28px; height: 28px; border-radius: 50%;
  border: 2px solid transparent; cursor: pointer; padding: 0;
}
.swatch:hover, .swatch:focus { border-color: #fff; }

.view-page {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 28px 32px 48px;
}
.view-page.hidden, .view-workbench.hidden, .hidden { display: none !important; }

/* ===== homefix1: 项目中心 hub（首页 = 项目管理） ===== */
.view-page.view-hub {
  padding: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.hub-shell {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 232px minmax(0, 1fr);
  height: 100%;
}
.hub-rail {
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 28px 22px 24px;
  border-right: 1px solid var(--border-soft);
  background:
    linear-gradient(165deg, rgba(28, 24, 40, 0.95), rgba(14, 16, 24, 0.98)),
    radial-gradient(500px 280px at 20% 0%, rgba(155, 123, 255, 0.12), transparent 60%);
  overflow: auto;
}
.hub-rail-top .eyebrow {
  letter-spacing: .16em;
  color: var(--accent-purple, #9b7bff);
  font-size: 11px;
  margin: 0 0 10px;
}
.hub-rail-title {
  margin: 0 0 10px;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.02em;
  background: linear-gradient(90deg, var(--accent-strong), var(--accent-rose));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.hub-rail-tip {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.65;
}
.hub-rail-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.hub-cta {
  width: 100%;
  padding: 12px 16px;
  border-radius: 12px;
  font-size: 14px;
  letter-spacing: 0.02em;
}
.hub-secondary {
  width: 100%;
  padding: 11px 16px;
  border-radius: 12px;
  background: rgba(255,255,255,.03);
  border-color: rgba(155,123,255,.28);
  color: #dcd6ff;
}
.hub-secondary:hover {
  border-color: rgba(155,123,255,.5);
  background: rgba(155,123,255,.08);
}
.hub-rail-foot {
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px solid var(--border-soft);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.hub-count {
  font-size: 12px;
  color: var(--accent-strong);
  letter-spacing: 0.04em;
}
.hub-rail-note {
  margin: 0;
  font-size: 11px;
  color: var(--muted);
  opacity: .85;
  line-height: 1.5;
}

.hub-main {
  min-width: 0;
  min-height: 0;
  overflow: auto;
  padding: 40px 48px 64px;
  display: flex;
  flex-direction: column;
  align-items: center;
  background:
    radial-gradient(900px 420px at 70% -8%, rgba(155,123,255,.07), transparent 55%),
    radial-gradient(700px 360px at 95% 10%, rgba(212,165,116,.05), transparent 50%),
    transparent;
}
.hub-main-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
  margin-bottom: 28px;
  width: 100%;
  max-width: 1040px;
}
.hub-main-head .page-title {
  margin: 0 0 6px;
  font-size: 26px;
  font-weight: 700;
  letter-spacing: 0.03em;
  background: linear-gradient(92deg, #f6f2ff 10%, #cfc0ff 55%, #e8c4d4 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.hub-main-head .muted {
  margin: 0;
  font-size: 13px;
  letter-spacing: 0.02em;
  opacity: 0.92;
}

.project-grid.hub-grid,
.hub-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 18px;
  width: 100%;
  max-width: 1040px;
}
.project-grid.hidden { display: none !important; }

.project-card.hub-card,
.hub-card {
  position: relative;
  overflow: hidden;
  background: linear-gradient(165deg, rgba(30, 34, 52, .96), rgba(18, 20, 30, .98));
  border: 1px solid var(--border-soft);
  border-radius: 18px;
  padding: 18px 18px 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  cursor: pointer;
  transition: transform .18s ease, border-color .18s ease, box-shadow .18s ease;
  box-shadow:
    0 12px 34px rgba(0,0,0,.3),
    0 1px 0 rgba(255,255,255,.045) inset;
  border-color: rgba(155,123,255,.16);
}
.hub-card:hover,
.hub-card:focus-visible {
  outline: none;
  transform: translateY(-3px);
  border-color: rgba(155,123,255,.42);
  box-shadow:
    0 14px 36px rgba(0,0,0,.35),
    0 0 0 1px rgba(155,123,255,.12),
    0 0 28px rgba(155,123,255,.12);
}
.hub-card-accent {
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: linear-gradient(180deg, #c4b0ff, var(--accent-strong), var(--accent-rose));
  opacity: .85;
}
.hub-card .project-card-top h3 {
  margin: 0 0 4px;
  font-size: 17px;
  font-weight: 650;
  letter-spacing: 0.01em;
}
.hub-card-aka {
  display: block;
  font-size: 12px;
  color: var(--muted);
}
/* cardDiscuss1: 讨论入口在卡片右上角 */
.hub-card-discuss {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 3;
  padding: 5px 11px !important;
  font-size: 12px !important;
  border-radius: 999px !important;
  line-height: 1.2;
  pointer-events: auto;
  background: rgba(155, 123, 255, 0.14) !important;
  border: 1px solid rgba(155, 123, 255, 0.38) !important;
  color: #e8e0ff !important;
  box-shadow: 0 4px 12px rgba(0,0,0,.18);
}
.hub-card-discuss:hover,
.hub-card-discuss:focus-visible {
  background: rgba(155, 123, 255, 0.28) !important;
  border-color: rgba(196, 176, 255, 0.7) !important;
  outline: none;
}
.hub-card .project-card-top {
  padding-right: 72px;
  min-width: 0;
}
.hub-card .project-stats {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--muted);
}
.hub-card .project-stats span {
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(155,123,255,.08);
  border: 1px solid rgba(155,123,255,.18);
}
.hub-card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: auto;
  padding-top: 4px;
}
.hub-card-when {
  font-size: 11px;
  color: var(--muted);
  opacity: .9;
}
.btn-sm {
  padding: 6px 12px !important;
  font-size: 12.5px !important;
  border-radius: 9px !important;
}

.hub-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 10px;
  min-height: 360px;
  padding: 48px 24px;
  width: 100%;
  max-width: 1040px;
  border: 1px dashed rgba(155,123,255,.28);
  border-radius: 20px;
  background:
    radial-gradient(420px 220px at 50% 30%, rgba(155,123,255,.1), transparent 65%),
    rgba(18,20,28,.55);
}
.hub-empty.hidden { display: none !important; }
.hub-empty-mark {
  width: 56px; height: 56px;
  border-radius: 16px;
  margin-bottom: 8px;
  background: linear-gradient(135deg, var(--accent-strong), var(--rose));
  box-shadow: 0 0 0 1px rgba(255,255,255,.12), 0 12px 28px var(--gold-glow);
}
.hub-empty h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 650;
}
.hub-empty p {
  margin: 0 0 12px;
  max-width: 360px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.65;
}

.page-title { margin: 0 0 4px; font-size: 22px; }
.projects-toolbar {
  display: flex; justify-content: space-between; align-items: flex-end;
  gap: 16px; margin-bottom: 18px;
}
.project-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
}
.project-card {
  background: linear-gradient(180deg, rgba(28,32,48,.95), rgba(22,25,34,.98));
  border: 1px solid var(--border-soft);
  border-radius: 16px;
  padding: 16px;
  display: flex; flex-direction: column; gap: 12px;
}
.project-card h3 { margin: 0; font-size: 16px; }
.project-stats { display: flex; gap: 10px; flex-wrap: wrap; font-size: 12px; color: var(--muted); }
.project-stats span {
  padding: 4px 8px; border-radius: 999px;
  background: rgba(155,123,255,.08); border: 1px solid rgba(155,123,255,.18);
}

@media (max-width: 900px) {
  .hub-shell { grid-template-columns: 1fr; }
  .hub-rail {
    border-right: 0;
    border-bottom: 1px solid var(--border-soft);
    padding: 20px 18px;
  }
  .hub-rail-actions { flex-direction: row; }
  .hub-cta, .hub-secondary { width: auto; flex: 1; }
  .hub-rail-foot { margin-top: 0; }
  .hub-main { padding: 22px 18px 40px; align-items: stretch; }
  .hub-main-head, .project-grid.hub-grid, .hub-grid, .hub-empty { max-width: none; }
  .project-tabs, .app-nav { grid-column: 1 / -1; }
  .app-header { grid-template-columns: 1fr auto; }
}

/* legacy hero (unused) kept minimal to avoid broken refs */
.hero-home, .home-howto, .howto-card, .home-project-card { display: none !important; }
.eyebrow { letter-spacing: .14em; color: var(--accent-purple, #9b7bff); font-size: 11px; margin: 0 0 8px; }

/* Workbench: page fixed — only inner content panes scroll */
html.view-workbench-lock,
body.view-workbench {
  overflow: hidden !important;
  height: 100%;
}
body.view-workbench .app-frame {
  height: 100vh;
  max-height: 100vh;
  overflow: hidden;
}
.view-workbench {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.workbench-shell {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--chat-w, 0px);
  transition: grid-template-columns .2s ease;
  overflow: hidden;
}
body.view-workbench.chat-dock-open {
  --chat-w: var(--chat-user-w, 380px);
}
body.view-workbench.chat-dock-collapsed {
  --chat-w: 0px;
}
body.view-workbench.chat-resizing .workbench-shell {
  transition: none;
}
body.view-workbench.chat-resizing {
  cursor: col-resize;
  user-select: none;
}
.chat-resize-handle {
  position: absolute;
  left: -3px;
  top: 0;
  bottom: 0;
  width: 8px;
  z-index: 60;
  cursor: col-resize;
  pointer-events: auto;
  touch-action: none;
}
.chat-dock.collapsed .chat-resize-handle { display: none; }
.chat-resize-handle::before {
  content: '';
  position: absolute;
  left: 3px;
  top: 50%;
  transform: translateY(-50%);
  width: 2px;
  height: 44px;
  border-radius: 999px;
  background: rgba(255,255,255,.14);
  transition: background .15s ease, height .15s ease;
}
.chat-resize-handle:hover::before,
body.chat-resizing .chat-resize-handle::before {
  background: rgba(168,140,255,.85);
  height: 72px;
}
/* adaptive chat layout when widened */
.chat-dock-panel.produce-chat {
  min-width: 0;
}
body.view-workbench.chat-wide .composer-shell textarea#chatInput {
  min-height: 52px;
}
body.view-workbench.chat-wide .mention-bar {
  gap: 6px;
}
body.view-workbench.chat-compact .chat-head-text .muted {
  display: none;
}
body.view-workbench.chat-compact .chat-filters.seg button {
  padding-left: 8px;
  padding-right: 8px;
  font-size: 11px;
}
.workbench-shell > .main {
  min-width: 0;
  min-height: 0;
  overflow: hidden; /* was auto — caused outer scrollbar & clipped top filters */
  padding: 8px 12px 8px;
  max-width: none;
  display: flex;
  flex-direction: column;
}
.workbench-shell > .main .panel {
  min-height: 0 !important;
  height: 100%;
  flex: 1;
  overflow: hidden;
  display: none;
  flex-direction: column;
}
.workbench-shell > .main .panel:not(.hidden) {
  display: flex;
}

/* Fixed chat dock — never moves with main scroll */
.chat-dock {
  position: relative !important;
  top: auto !important;
  width: 100% !important;
  max-width: none !important;
  height: 100% !important;
  align-self: stretch;
  z-index: 50;
  pointer-events: none;
}
.chat-dock > * { pointer-events: auto; }
.chat-dock.collapsed {
  width: 0 !important;
  overflow: visible;
}
.chat-dock-panel.produce-chat {
  position: absolute !important;
  inset: 0 0 0 0;
  width: 100%;
  height: 100%;
  max-height: none;
  border-radius: 0;
  display: flex;
  flex-direction: column;
  box-shadow: -10px 0 28px rgba(0,0,0,.4);
  background: linear-gradient(180deg, #171a26, #12141c);
  border-left: 1px solid var(--border-soft);
}
.chat-messages {
  flex: 1;
  min-height: 0;
  overflow: auto;
}
.chat-dock.collapsed .chat-fab {
  display: inline-flex;
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 70;
}

/* Produce sticky chrome */
.panel-produce {
  display: flex;
  flex-direction: column;
  padding: 8px !important;
  min-height: 0 !important;
  height: 100% !important;
  max-height: 100%;
  overflow: hidden !important;
}
.produce-layout {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 148px minmax(0, 1fr);
  gap: 10px;
  align-items: stretch;
  height: 100%;
  max-height: none;
}
.ep-rail {
  position: relative !important;
  top: auto !important;
  max-height: none !important;
  height: 100%;
  overflow: hidden;
}
.produce-main {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.produce-sticky-bar {
  flex-shrink: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  padding: 6px 2px 10px;
  background: rgba(22,25,34,.96);
  border-bottom: 1px solid var(--border-soft);
  position: sticky;
  top: 0;
  z-index: 4;
}
.pipe-legend { flex-shrink: 0; }
.produce-main .produce-scroll-wrap {
  flex: 1;
  min-height: 0;
}
.produce-main .produce-grid {
  min-height: 0;
  overflow: auto;
  padding-right: 4px;
  padding-bottom: 20px;
  height: 100%;
}
.sticky-toolbar {
  position: sticky;
  top: 0;
  z-index: 4;
  background: rgba(22,25,34,.96);
  padding-top: 4px;
  padding-bottom: 10px;
  backdrop-filter: blur(8px);
}

/* Character hero: preview + 3 final slots on the right
   Left black preview height governs; right slots equal-flex inside that height. */
.char-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 112px;
  gap: 8px;
  margin-bottom: 8px;
  align-items: stretch;
  height: 168px;
}
.char-main-preview {
  min-height: 0;
  height: 100%;
  align-self: stretch;
}
.char-main-preview img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  cursor: zoom-in;
}
.char-main-preview .empty-preview {
  font-size: 12px;
  padding: 12px;
}
.char-final-slots {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-height: 0;
  height: 100%;
  align-self: stretch;
}
.hero-slot {
  position: relative;
  flex: 1 1 0;
  min-height: 0;
  border-radius: 10px;
  border: 1px dashed rgba(155,123,255,.35);
  background: rgba(10,11,16,.85);
  overflow: hidden;
  cursor: pointer;
  display: flex;
  flex-direction: column;
}
.hero-slot.has-img { border-style: solid; border-color: rgba(155,123,255,.35); }
.hero-slot.active {
  border-color: var(--accent-purple);
  box-shadow: 0 0 0 2px var(--purple-glow);
}
.hero-slot img {
  width: 100%;
  flex: 1;
  object-fit: cover;
  display: block;
  cursor: zoom-in;
  background: #0a0b10;
}
.hero-slot-label {
  font-size: 10px;
  color: var(--muted);
  padding: 3px 6px;
  background: rgba(0,0,0,.55);
  flex-shrink: 0;
}
.hero-slot-empty {
  flex: 1;
  display: grid;
  place-items: center;
  font-size: 10px;
  color: var(--muted);
  padding: 6px;
  text-align: center;
}
.hero-slot.dragover {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}
.thumb-x {
  position: absolute;
  top: 4px;
  left: 4px;
  width: 22px; height: 22px;
  border-radius: 7px;
  border: 1px solid rgba(255,255,255,.2);
  background: rgba(0,0,0,.65);
  color: #ffb4b4;
  cursor: pointer;
  line-height: 1;
  padding: 0;
  font-size: 14px;
  z-index: 2;
}
.thumb-x:hover { background: rgba(232,93,93,.55); color: #fff; }

.stage-slots.work-lanes {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0;
  margin-top: 0;
  border-radius: 14px;
  overflow: hidden;
  background: rgba(8,10,16,.45);
}
.stage-slots.work-lanes .zone,
.stage-slots.work-lanes .drop-zone {
  min-height: 110px;
  padding: 8px 12px 10px;
  position: relative;
}
.stage-slots.work-lanes .zone:not(:first-child)::before {
  content: '';
  position: absolute;
  left: 0;
  top: 10%;
  bottom: 10%;
  width: 1px;
  background: linear-gradient(180deg,
    rgba(196,176,255,0),
    rgba(196,176,255,.55) 22%,
    rgba(212,165,116,.4) 50%,
    rgba(196,176,255,.55) 78%,
    rgba(196,176,255,0));
  pointer-events: none;
}
.density-compact .thumb {
  width: 72px;
}
.density-compact .thumb img {
  height: 56px;
}
.density-compact .thumb .actions { gap: 2px; }
.density-compact .thumb .actions .btn { font-size: 10px; padding: 2px 5px; }
.density-comfy .thumb { width: 110px; }
.density-comfy .thumb img { height: 78px; }

.produce-card {
  padding: 10px 12px;
  gap: 8px;
}
.produce-grid { gap: 10px; }

/* Dark range / progress (no white tracks) */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  height: 6px;
  border-radius: 999px;
  background: #2a3144;
  outline: none;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 6px;
  border-radius: 999px;
  background: #2a3144;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: linear-gradient(135deg, #c4b0ff, #9b7bff);
  border: 0;
  margin-top: -4px;
  cursor: pointer;
}
input[type="range"]::-moz-range-track {
  height: 6px;
  border-radius: 999px;
  background: #2a3144;
  border: 0;
}
input[type="range"]::-moz-range-thumb {
  width: 14px; height: 14px;
  border-radius: 50%;
  background: #9b7bff;
  border: 0;
  cursor: pointer;
}
progress {
  appearance: none;
  height: 8px;
  border-radius: 999px;
  background: #2a3144;
  border: 0;
  overflow: hidden;
}
progress::-webkit-progress-bar { background: #2a3144; border-radius: 999px; }
progress::-webkit-progress-value {
  background: linear-gradient(90deg, #9b7bff, #c4b0ff);
  border-radius: 999px;
}
progress::-moz-progress-bar {
  background: linear-gradient(90deg, #9b7bff, #c4b0ff);
  border-radius: 999px;
}
video::-webkit-media-controls-panel {
  background: linear-gradient(transparent, rgba(12,13,18,.85));
}

/* Lightbox */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(0,0,0,.82);
  display: grid;
  place-items: center;
  padding: 24px;
}
.lightbox.hidden { display: none !important; }
.lightbox img {
  max-width: min(96vw, 1200px);
  max-height: 90vh;
  object-fit: contain;
  border-radius: 12px;
  box-shadow: var(--shadow);
  background: #000;
}
.lightbox-close {
  position: absolute;
  top: 16px; right: 20px;
  width: 40px; height: 40px;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,.25);
  background: rgba(0,0,0,.5);
  color: #fff;
  font-size: 24px;
  cursor: pointer;
}

body.view-home .app-nav,
body.view-projects .app-nav { display: flex; }
body.view-workbench .app-nav { display: flex; opacity: .85; }

@media (max-width: 960px) {
  .workbench-shell {
    grid-template-columns: 1fr !important;
  }
  body.view-workbench.chat-dock-open .chat-dock {
    position: fixed !important;
    right: 0; bottom: 0; top: auto;
    width: min(420px, 100vw) !important;
    height: min(70vh, 560px) !important;
    z-index: 80;
  }
  .chat-dock-panel.produce-chat { border-radius: 16px 16px 0 0 !important; }
  .char-hero { grid-template-columns: 1fr; height: auto; }
  .char-main-preview { height: 148px; }
  .char-final-slots { flex-direction: row; height: 84px; }
  .hero-slot { min-height: 0; }
  .stage-slots.work-lanes { grid-template-columns: 1fr; }
  .panel-produce { height: 100%; overflow: hidden; }
  .produce-layout { height: 100%; grid-template-columns: 1fr; }
  .produce-main .produce-grid { overflow: auto; }
}


/* pc-scrollbar: thin dark thumbs, no fat white bars */
* {
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.22) transparent;
}
*::-webkit-scrollbar { width: 6px; height: 6px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.18);
  border-radius: 999px;
  border: 1px solid transparent;
  background-clip: padding-box;
}
*::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.32); }


/* ==== cards1: mini thumbs / zone zoom / scrubber ==== */

.sr-only {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0);
  border: 0;
}

.produce-scroll-wrap {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 16px minmax(0, 1fr);
  gap: 8px;
  align-items: stretch;
}
.produce-scroll-wrap .produce-grid {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding-right: 6px;
  padding-bottom: 24px;
}

/* Zone header + zoom (left) */
.zone-head {
  display: flex;
  justify-content: flex-start;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
}
.zone-head-left {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  min-width: 0;
}
.zone-title { font-size: 13px; font-weight: 650; }
.zone-hint { display: none; }
.zone-zoom {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  padding: 3px 8px 3px 10px;
  border-radius: 999px;
  background: rgba(255,255,255,.04);
  border: 1px solid rgba(255,255,255,.08);
}
.zone-zoom .zoom-label {
  font-size: 10.5px;
  color: rgba(232,228,255,.72);
  white-space: nowrap;
  letter-spacing: 0.02em;
}
.zone-zoom .zone-scale {
  width: 108px;
  height: 6px;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background: linear-gradient(90deg, rgba(155,123,255,.25), rgba(212,165,116,.28));
  border-radius: 999px;
  outline: none;
}
.zone-zoom .zone-scale::-webkit-slider-runnable-track {
  height: 6px;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(155,123,255,.28), rgba(212,165,116,.3));
}
.zone-zoom .zone-scale::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 22px;
  height: 14px;
  margin-top: -4px;
  border-radius: 999px;
  background: linear-gradient(135deg, #e4d8ff 0%, #b498ff 45%, #8f6dff 100%);
  border: 1px solid rgba(255,255,255,.42);
  box-shadow: 0 2px 8px rgba(120,90,220,.45), inset 0 1px 0 rgba(255,255,255,.35);
  cursor: grab;
}
.zone-zoom .zone-scale::-moz-range-track {
  height: 6px;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(155,123,255,.28), rgba(212,165,116,.3));
}
.zone-zoom .zone-scale::-moz-range-thumb {
  width: 22px;
  height: 14px;
  border-radius: 999px;
  background: linear-gradient(135deg, #e4d8ff 0%, #b498ff 45%, #8f6dff 100%);
  border: 1px solid rgba(255,255,255,.42);
  box-shadow: 0 2px 8px rgba(120,90,220,.45);
  cursor: grab;
}
.zone {
  --card-scale: 1;
  border: 0;
  border-radius: 0;
  background: rgba(12,14,22,.55);
  padding: 8px 10px 10px;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.stage-slots.work-lanes .zone[data-slot="ref"] {
  background: linear-gradient(180deg, rgba(18,16,28,.72), rgba(10,11,18,.55));
}
.stage-slots.work-lanes .zone[data-slot="costume"] {
  background: linear-gradient(180deg, rgba(22,16,20,.72), rgba(12,10,14,.55));
}
.stage-slots.work-lanes .zone[data-slot="face"] {
  background: linear-gradient(180deg, rgba(14,18,28,.72), rgba(10,12,18,.55));
}
.zone.dragover {
  background: rgba(155,123,255,.12) !important;
  box-shadow: inset 0 0 0 1px rgba(168,140,255,.45);
}
.thumbs-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  flex-wrap: wrap;
  flex: 1 1 auto;
  width: 100%;
  min-height: 96px;
  padding: 2px 0 0;
  border: 0;
  background: transparent;
  box-sizing: border-box;
}
.zone.dragover .thumbs-row {
  border-radius: 10px;
  outline: 1px dashed rgba(168,140,255,.5);
  outline-offset: 2px;
  background: rgba(155,123,255,.06);
}
.upload-tile {
  width: calc(76px * var(--card-scale, 1));
  min-height: calc(78px * var(--card-scale, 1));
  border-radius: 10px;
  border: 1px dashed rgba(255,255,255,.2);
  background: rgba(255,255,255,.035);
  color: rgba(255,255,255,.55);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  flex-shrink: 0;
  padding: 0;
  order: 99;
}
.upload-tile .plus { font-size: 22px; line-height: 1; color: #c4b0ff; }
.upload-tile-cap { font-size: 11px; }
.upload-tile:hover, .upload-tile.dragover {
  border-color: rgba(168,140,255,.65);
  color: #fff;
  background: rgba(155,123,255,.1);
}
.zone .dropzone-visual { display: none !important; }


.zone-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin: 0 0 8px;
}
.zf-chip {
  border: 1px solid rgba(255,255,255,.12);
  background: rgba(255,255,255,.04);
  color: var(--muted);
  border-radius: 999px;
  padding: 3px 9px;
  font-size: 11px;
  cursor: pointer;
  line-height: 1.2;
}
.zf-chip:hover { color: #fff; border-color: rgba(155,123,255,.4); }
.zf-chip.active {
  background: linear-gradient(135deg, rgba(155,123,255,.35), rgba(212,165,116,.28));
  color: #fff;
  border-color: rgba(155,123,255,.55);
  font-weight: 650;
}

/* Mini thumb cards */
.thumbs {
  display: flex;
  flex-wrap: wrap;
  gap: calc(6px * var(--card-scale, 1));
  margin-top: 6px;
}
.thumbs-row .thumbs {
  display: contents;
  margin-top: 0;
}
.thumb.mini {
  width: calc(76px * var(--card-scale, 1));
  background: #12151c;
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 10px;
  overflow: hidden;
  position: relative;
  transition: width .12s ease, box-shadow .15s ease;
}
.thumb.mini .thumb-media {
  position: relative;
  width: 100%;
  height: calc(58px * var(--card-scale, 1));
  background: #0a0b10;
}
.thumb.mini img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  cursor: zoom-in;
}
.thumb.mini .cap.one-line {
  font-size: calc(10px * min(var(--card-scale, 1), 1.15));
  padding: 3px 5px 4px;
  color: #aeb6c8;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  word-break: normal;
  line-height: 1.25;
}
.thumb.mini .thumb-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 3px;
  padding: 4px;
  background: linear-gradient(transparent 35%, rgba(0,0,0,.72));
  opacity: 0;
  transition: opacity .14s ease;
  pointer-events: none;
}
.thumb.mini:hover .thumb-overlay,
.thumb.mini:focus-within .thumb-overlay {
  opacity: 1;
  pointer-events: auto;
}
.thumb-ico {
  width: calc(22px * min(var(--card-scale, 1), 1.25));
  height: calc(22px * min(var(--card-scale, 1), 1.25));
  min-width: 18px;
  min-height: 18px;
  border-radius: 7px;
  border: 1px solid rgba(255,255,255,.22);
  background: rgba(12,14,20,.78);
  color: #fff;
  font-size: 12px;
  line-height: 1;
  display: inline-grid;
  place-items: center;
  cursor: pointer;
  text-decoration: none;
  padding: 0;
  pointer-events: auto;
}
.thumb-ico:hover { background: rgba(155,123,255,.55); border-color: transparent; }
.thumb-ico.select:hover,
.thumb-ico.on { background: rgba(72, 180, 120, .7); }
.thumb-ico.del:hover { background: rgba(232,93,93,.7); }
.thumb-ico.on {
  pointer-events: none;
  opacity: .95;
}
.thumb-badge {
  position: absolute;
  top: 4px;
  left: 4px;
  font-size: 9px;
  padding: 1px 5px;
  border-radius: 999px;
  background: rgba(72,180,120,.85);
  color: #04140c;
  font-weight: 700;
  z-index: 1;
  pointer-events: none;
}
.thumb-badge.lib {
  left: auto;
  right: 4px;
  background: rgba(141,164,255,.85);
  color: #0b1020;
}
.thumb.mini.picked {
  outline: 2px solid var(--ok);
  outline-offset: 1px;
}
.thumb.mini .thumb-x { display: none; } /* use overlay × */
.density-compact .thumb.mini { width: calc(76px * var(--card-scale, 1)); }
.density-comfy .thumb.mini { width: calc(96px * var(--card-scale, 1)); }
.density-comfy .thumb.mini .thumb-media { height: calc(72px * var(--card-scale, 1)); }

/* ==== carddense1: ~3 character cards / viewport in 紧凑; slots ≤ left preview ==== */
.density-compact.produce-grid,
.produce-grid.density-compact {
  gap: 8px;
}
.density-compact .produce-card {
  padding: 8px 10px;
  gap: 6px;
}
.density-compact .produce-card .card-head {
  gap: 8px;
}
.density-compact .card h3 {
  font-size: 13.5px;
  gap: 5px;
}
.density-compact .card-actions-row {
  gap: 6px;
}
.density-compact .card-actions-row .btn {
  font-size: 11px;
  padding: 3px 8px;
}
.density-compact .stage-progress {
  margin-top: 2px;
  gap: 3px;
}
.density-compact .stage-dot {
  font-size: 9px;
  padding: 1px 6px;
}
.density-compact .char-hero {
  height: 118px;
  gap: 6px;
  margin-bottom: 6px;
  grid-template-columns: minmax(0, 1fr) 96px;
}
.density-compact .char-final-slots {
  gap: 4px;
}
.density-compact .hero-slot-label {
  font-size: 9px;
  padding: 2px 4px;
}
.density-compact .hero-slot-empty {
  font-size: 9px;
  padding: 2px 4px;
}
.density-compact .char-main-preview .empty-preview {
  font-size: 11px;
  padding: 8px;
}
.density-compact .stage-slots.work-lanes .zone,
.density-compact .stage-slots.work-lanes .drop-zone {
  min-height: 72px;
  padding: 6px 8px 8px;
}
.density-compact .zone-head {
  margin-bottom: 4px;
  gap: 6px;
}
.density-compact .zone-title { font-size: 12px; }
.density-compact .zone-zoom {
  padding: 2px 6px 2px 8px;
  gap: 6px;
}
.density-compact .zone-zoom .zoom-label { font-size: 10px; }
.density-compact .zone-zoom .zone-scale { width: 84px; }
.density-compact .thumbs-row {
  min-height: 58px;
  gap: 6px;
  padding-top: 0;
}
.density-compact .thumb.mini {
  width: calc(56px * var(--card-scale, 1));
}
.density-compact .thumb.mini .thumb-media {
  height: calc(44px * var(--card-scale, 1));
}
.density-compact .upload-tile {
  width: calc(56px * var(--card-scale, 1));
  min-height: calc(58px * var(--card-scale, 1));
}
.density-compact .upload-tile .plus { font-size: 18px; }
.density-compact .upload-tile-cap { font-size: 10px; }
.density-compact .zone-filters {
  gap: 3px;
  margin: 0 0 4px;
}
.density-compact .zf-chip {
  padding: 2px 7px;
  font-size: 10px;
}
.density-comfy .char-hero {
  height: 200px;
  grid-template-columns: minmax(0, 1fr) 118px;
}
.density-comfy .produce-card {
  padding: 12px 14px;
  gap: 10px;
}
.density-comfy .produce-grid { gap: 12px; }


.produce-card.scrub-flash {
  box-shadow: 0 0 0 2px rgba(155,123,255,.65), 0 0 24px rgba(155,123,255,.25);
  transition: box-shadow .3s ease;
}

/* Quiet single-tip asset scrubber */
.asset-scrubber {
  position: sticky;
  top: 0;
  align-self: stretch;
  height: 100%;
  max-height: 100%;
  overflow: visible;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 0;
  padding: 8px 0;
  border-radius: 0;
  background: transparent;
  border: 0;
  box-shadow: none;
  z-index: 5;
  touch-action: none;
  user-select: none;
}
.asset-scrubber.empty { opacity: .35; }
.scrub-tick {
  position: relative;
  flex: 0 0 auto;
  width: 100%;
  height: 10px;
  margin: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  display: grid;
  place-items: center;
  padding: 0;
  z-index: 1;
}
.scrub-bar {
  width: 7px;
  height: 2px;
  border-radius: 999px;
  background: rgba(255,255,255,.22);
  transition: width .12s ease, height .12s ease, background .12s ease, box-shadow .12s ease;
  transform-origin: center;
  pointer-events: none;
}
.scrub-tick.active .scrub-bar {
  width: 11px;
  height: 3px;
  background: #b498ff;
  box-shadow: 0 0 8px rgba(155,123,255,.35);
}
.scrub-tick.hot .scrub-bar {
  width: 14px;
  height: 5px;
  background: #c4b0ff;
  box-shadow: 0 0 12px rgba(196,176,255,.55);
}
.scrub-tip {
  position: absolute;
  left: calc(100% + 10px);
  top: 50%;
  transform: translateY(-50%);
  transform-origin: left center;
  white-space: nowrap;
  font-size: 12px;
  letter-spacing: 0.02em;
  line-height: 1.35;
  padding: 7px 11px;
  border-radius: 10px;
  background: rgba(12,14,20,.96);
  border: 1px solid rgba(155,123,255,.45);
  color: #f2f4fa;
  opacity: 0;
  pointer-events: none;
  box-shadow: 0 10px 28px rgba(0,0,0,.4);
  transition: opacity .1s ease;
  z-index: 30;
  max-width: 240px;
  overflow: hidden;
  text-overflow: ellipsis;
}
/* tip only while hovering / scrubbing the hot tick — never stack ghosts */
.asset-scrubber.is-scrubbing .scrub-tick.hot .scrub-tip,
.scrub-tick.hot .scrub-tip {
  opacity: 1;
}

@media (max-width: 960px) {
  .produce-scroll-wrap {
    grid-template-columns: 1fr;
  }
  .asset-scrubber {
    display: none;
  }
}

/* ===== scriptfmt1: 剧本分析 TOC + 分级排版 ===== */
.panel-script {
  display: flex;
  flex-direction: column;
  min-height: 0;
  height: calc(100vh - 88px);
  overflow: hidden;
  padding: 10px !important;
}
.panel-script .script-drop {
  flex-shrink: 0;
  margin-bottom: 10px;
  padding: 12px 14px;
}
.panel-script .script-toolbar {
  flex-shrink: 0;
}
.script-layout {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 168px minmax(0, 1fr) 6px var(--script-analysis-w, 320px);
  gap: 0 8px;
  align-items: stretch;
}
.script-split-handle {
  width: 6px;
  margin: 0 -2px;
  cursor: col-resize;
  border-radius: 4px;
  background: transparent;
  position: relative;
  z-index: 2;
  touch-action: none;
  align-self: stretch;
}
.script-split-handle::after {
  content: '';
  position: absolute;
  top: 18%;
  bottom: 18%;
  left: 2px;
  width: 2px;
  border-radius: 2px;
  background: rgba(255,255,255,0.08);
  transition: background .15s ease, box-shadow .15s ease;
}
.script-split-handle:hover::after,
body.script-resizing .script-split-handle::after {
  background: rgba(168,140,255,0.55);
  box-shadow: 0 0 0 1px rgba(168,140,255,0.25);
}
body.script-resizing { cursor: col-resize !important; user-select: none !important; }
body.script-resizing * { cursor: col-resize !important; user-select: none !important; }
.script-toc {
  display: flex;
  flex-direction: column;
  min-height: 0;
  height: 100%;
  background: var(--panel2);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  overflow: hidden;
}
.script-toc-head {
  flex-shrink: 0;
  padding: 10px 12px 6px;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  border-bottom: 1px solid var(--border-soft);
}
.script-toc-eps {
  overflow: auto;
  padding: 6px 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-height: 0;
  flex: 1;
  max-height: none;
}
.script-toc-ep-block {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.script-toc-ep,
.script-toc-scene {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1px;
  width: 100%;
  text-align: left;
  padding: 7px 9px;
  border-radius: 9px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  transition: background .14s ease, border-color .14s ease;
}
.script-toc-ep:hover,
.script-toc-scene:hover {
  background: rgba(255,255,255,.04);
  border-color: rgba(212,165,116,.2);
}
.script-toc-ep.active {
  background: rgba(212,165,116,.12);
  border-color: rgba(212,165,116,.4);
}
.script-toc-scene.active {
  background: rgba(155,123,255,.14);
  border-color: rgba(155,123,255,.4);
}
.script-toc-ep .ep-num,
.script-toc-scene .sc-code {
  font-size: 12px;
  font-weight: 650;
  color: #f0e2c8;
}
.script-toc-ep .ep-title,
.script-toc-scene .sc-loc {
  font-size: 10.5px;
  color: var(--muted);
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.script-toc-nested {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin: 2px 0 6px 8px;
  padding: 4px 0 4px 8px;
  border-left: 1px solid rgba(212,165,116,.28);
}
.script-toc-scene {
  padding: 5px 8px;
}
.script-toc-scene .sc-code {
  font-size: 11.5px;
  color: #c4b0ff;
}
.script-toc-empty {
  font-size: 11px;
  color: var(--muted);
  padding: 4px 8px 6px;
}
.script-reader-card {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--panel2);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  overflow: hidden;
}
.script-reader-head {
  flex-shrink: 0;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px 10px;
  border-bottom: 1px solid var(--border-soft);
  background: linear-gradient(180deg, rgba(212,165,116,.07), transparent);
}
.script-show-title {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: #f6e7c8;
}
.script-ep-title {
  margin-top: 4px;
  font-size: 13.5px;
  color: #d4a574;
  font-weight: 600;
}
.script-reader {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 18px 22px 40px;
  scroll-behavior: smooth;
  font-size: var(--script-font-size, 15px);
}
.script-reader .sf-action,
.script-reader .sf-body,
.script-reader .sf-line,
.script-reader .sf-cast-list,
.script-reader .sf-dialogue,
.script-reader .sf-scene-title {
  font-size: inherit;
}
.script-reader.dimmed-behind-edit {
  display: none;
}
.script-edit-wrap {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 12px 14px 14px;
  gap: 8px;
}
.script-edit-wrap textarea {
  flex: 1;
  min-height: 240px;
  resize: none;
}
.panel-script .script-result-card {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  height: 100%;
}
.panel-script .script-result-card .asset-list {
  flex: 1;
  max-height: none;
  min-height: 0;
}

/* Formatted script typography — scriptquiet1: quiet chrome, loud asset marks */
.sf-show-title {
  font-size: 17px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: rgba(232, 228, 214, 0.78);
  margin: 0 0 4px;
  text-align: center;
}
.sf-ep-heading {
  text-align: center;
  font-size: 12.5px;
  font-weight: 500;
  color: rgba(200, 170, 130, 0.62);
  margin: 0 0 16px;
  padding-bottom: 10px;
  border-bottom: 1px solid rgba(255,255,255,.06);
}
.sf-scene {
  margin: 0 0 18px;
  padding: 2px 0 14px;
  border-radius: 0;
  border-bottom: 1px solid rgba(255,255,255,.05);
  scroll-margin-top: 12px;
  transition: background .35s ease, box-shadow .35s ease;
}
.sf-scene:last-child { border-bottom: none; padding-bottom: 4px; }
.sf-scene.flash-scene {
  background: rgba(212,165,116,.05);
  box-shadow: inset 0 0 0 1px rgba(212,165,116,.14);
}
.sf-scene-title {
  margin: 0 0 8px;
  padding: 3px 0 3px 8px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: rgba(220, 210, 190, 0.72);
  background: transparent;
  border-left: 2px solid rgba(212,165,116,.32);
  border-radius: 0;
}
.sf-cast {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 8px;
  align-items: baseline;
  margin: 0 0 6px;
  font-size: 11.5px;
  color: rgba(180,188,205,.55);
}
.sf-label {
  font-size: 10px;
  letter-spacing: 0.04em;
  color: rgba(150,158,178,.55);
  padding: 0 2px;
  border-radius: 0;
  border: none;
  background: transparent;
}
.sf-cast-list { color: rgba(175,182,200,.62); }
.sf-scene-note {
  margin: 0 0 8px;
  padding: 2px 0 2px 8px;
  font-size: 11.5px;
  line-height: 1.5;
  color: rgba(150,162,185,.58);
  background: transparent;
  border: none;
  border-left: 1px solid rgba(110,140,200,.22);
  border-radius: 0;
}
.sf-action {
  margin: 6px 0;
  padding-left: 2px;
  font-size: 11.5px;
  line-height: 1.55;
  color: rgba(170, 168, 190, 0.48);
  font-style: normal;
  font-weight: 450;
  letter-spacing: 0.01em;
}
.sf-dialogue {
  margin: 5px 0 5px 4px;
  font-size: 13.5px;
  line-height: 1.68;
  color: rgba(220,226,238,.88);
}
.sf-char {
  font-weight: 550;
  color: rgba(210, 190, 155, 0.72);
}
.sf-colon { color: rgba(180,170,150,.45); margin: 0 1px; }
.sf-line { color: rgba(220,226,238,.88); }
.sf-body {
  margin: 3px 0;
  font-size: 13px;
  line-height: 1.62;
  color: rgba(195,202,218,.72);
}
.sf-blank { height: 6px; }

@media (max-width: 1100px) {
  .script-layout {
    grid-template-columns: 148px minmax(0, 1fr);
  }
  .script-split-handle { display: none; }
  .panel-script .script-result-card {
    grid-column: 1 / -1;
    max-height: 280px;
  }
}
@media (max-width: 760px) {
  .panel-script { height: auto; overflow: visible; }
  .script-layout {
    grid-template-columns: 1fr;
    height: auto;
  }
  .script-split-handle { display: none; }
  .script-toc { max-height: 260px; }
  .script-reader { max-height: 55vh; }
}


/* Fixed panels: pick/library — outer no scroll */
#tab-pick,
#tab-library,
#tab-storyboard,
#tab-video,
#tab-script.panel {
  height: 100% !important;
  max-height: 100%;
  overflow: hidden !important;
  display: none;
  flex-direction: column;
  min-height: 0 !important;
}
#tab-pick:not(.hidden),
#tab-library:not(.hidden),
#tab-storyboard:not(.hidden),
#tab-video:not(.hidden),
#tab-script.panel:not(.hidden) {
  display: flex;
}
#tab-pick .sticky-toolbar,
#tab-library .sticky-toolbar {
  flex-shrink: 0;
  position: relative;
  top: auto;
}
#tab-pick .pick-scroll,
#tab-pick #pickGrid,
#tab-library #libraryGrid,
#tab-library .library-body {
  flex: 1;
  min-height: 0;
  overflow: auto;
}

.pick-grid, .library-grid {
  flex: 1;
  min-height: 0;
  overflow: auto;
}

.asset-group-label {
  margin: 4px 0 2px !important;
  font-size: 11px;
  letter-spacing: 0.04em;
}


/* —— auth1: login gate + profile popover —— */
.auth-gate {
  position: fixed; inset: 0; z-index: 200;
  display: grid; place-items: center;
  background:
    radial-gradient(ellipse at 20% 10%, rgba(155,123,255,.18), transparent 50%),
    radial-gradient(ellipse at 80% 90%, rgba(212,165,116,.12), transparent 45%),
    rgba(10, 8, 16, .92);
  backdrop-filter: blur(10px);
  padding: 24px;
}
.auth-card {
  width: min(420px, 100%);
  background: linear-gradient(160deg, rgba(36,30,48,.98), rgba(22,20,32,.98));
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 20px;
  padding: 28px 26px 24px;
  box-shadow: 0 24px 60px rgba(0,0,0,.45);
}
.auth-brand { text-align: center; margin-bottom: 18px; }
.auth-brand .brand-mark {
  width: 42px; height: 42px; margin: 0 auto 10px;
  border-radius: 12px;
  background: linear-gradient(135deg, #9b7bff, #d4a574);
}
.auth-brand h2 { margin: 0 0 6px; font-size: 20px; letter-spacing: .02em; }
.auth-tabs {
  display: grid; grid-template-columns: 1fr 1fr; gap: 6px;
  background: rgba(0,0,0,.25); border-radius: 12px; padding: 4px; margin-bottom: 14px;
}
.auth-tab {
  border: 0; background: transparent; color: var(--muted);
  padding: 9px 10px; border-radius: 9px; cursor: pointer; font-size: 13px;
}
.auth-tab.active {
  background: rgba(155,123,255,.22); color: var(--text); font-weight: 600;
}
.auth-form { display: flex; flex-direction: column; gap: 12px; }
.auth-form label {
  font-size: 12px; color: var(--muted);
  display: flex; flex-direction: column; gap: 6px;
}
.auth-form input {
  background: rgba(0,0,0,.28); border: 1px solid var(--border);
  border-radius: 10px; padding: 10px 12px; color: var(--text);
}
.auth-submit { width: 100%; margin-top: 4px; justify-content: center; }
.auth-error {
  margin: 0; color: #ff8f9f; font-size: 12px;
  background: rgba(255,80,100,.1); border: 1px solid rgba(255,80,100,.25);
  border-radius: 8px; padding: 8px 10px;
}
body.auth-locked .app-frame,
body:not(.app-ready) .app-frame { visibility: hidden; pointer-events: none; }
body.auth-locked #authGate:not(.hidden) { display: grid; }

.profile-popover {
  position: fixed;
  z-index: 130;
  width: min(340px, calc(100vw - 24px));
  max-height: min(80vh, 640px);
  overflow: auto;
  background: linear-gradient(165deg, rgba(38,32,52,.98), rgba(24,22,34,.98));
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 16px;
  box-shadow: 0 18px 48px rgba(0,0,0,.5);
  padding: 0;
}
.profile-popover-inner {
  padding: 14px 14px 16px;
  display: flex; flex-direction: column; gap: 12px;
}
.profile-popover-head {
  display: flex; align-items: center; justify-content: space-between;
}
.profile-popover-head strong { font-size: 14px; }
.profile-popover label {
  font-size: 12px; color: var(--muted);
  display: flex; flex-direction: column; gap: 6px;
}
.profile-popover input[type="text"],
.profile-popover input[type="password"] {
  background: rgba(0,0,0,.28); border: 1px solid var(--border);
  border-radius: 10px; padding: 9px 11px; color: var(--text);
}
.profile-popover input[readonly] {
  opacity: .7; cursor: default;
}
.profile-pass-block {
  padding-top: 4px;
  border-top: 1px solid rgba(255,255,255,.06);
  display: flex; flex-direction: column; gap: 10px;
}
.profile-popover-actions {
  display: flex; justify-content: space-between; gap: 8px; margin-top: 4px;
}
.profile-admin-entry {
  margin: 4px 0 10px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(155,123,255,.28);
  background: linear-gradient(135deg, rgba(155,123,255,.10), rgba(232,180,120,.08));
}
.profile-admin-entry #btnOpenAdmin {
  width: 100%;
  justify-content: center;
  font-weight: 650;
}
.profile-admin-hint {
  margin: 8px 0 0;
  font-size: 11px;
  line-height: 1.4;
}
html.theme-light .profile-admin-entry {
  border-color: rgba(120,90,180,.22);
  background: linear-gradient(135deg, rgba(155,123,255,.08), rgba(250,240,230,.65));
}
.avatar.has-img {
  background-size: cover !important;
  background-position: center !important;
  color: transparent !important;
}
.avatar-upload-btn {
  border: 0; padding: 0; cursor: pointer;
  box-shadow: 0 0 0 2px rgba(155,123,255,.25);
}
.btn.sm { padding: 6px 10px; font-size: 12px; }
.header-right { position: relative; }

/* —— frameless1: 工作台主区去外框，内容直接铺在页面上（对齐右侧聊天无框感） —— */
.workbench-shell > .main .panel,
.workbench-shell > .main .panel-produce,
.workbench-shell > .main #tab-pick.panel,
.workbench-shell > .main #tab-library.panel,
.workbench-shell > .main #tab-script.panel,
.workbench-shell > .main #tab-storyboard.panel,
.workbench-shell > .main #tab-video.panel {
  background: transparent !important;
  border: 0 !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  padding: 4px 2px 0 !important;
}
.panel-produce {
  background: transparent !important;
  border: 0 !important;
  box-shadow: none !important;
}
.produce-sticky-bar {
  background: transparent;
  border-bottom-color: rgba(255,255,255,.06);
  padding-left: 0;
  padding-right: 0;
}

/* ==== sysassist1: @系统 locate flash ==== */
.produce-card.system-locate-flash {
  box-shadow: 0 0 0 3px rgba(94, 234, 212, .75), 0 0 36px rgba(94, 234, 212, .35);
  transition: box-shadow .25s ease;
  animation: system-locate-pulse 1.4s ease-out 1;
}
@keyframes system-locate-pulse {
  0% { box-shadow: 0 0 0 4px rgba(94, 234, 212, .95), 0 0 40px rgba(94, 234, 212, .5); }
  100% { box-shadow: 0 0 0 2px rgba(94, 234, 212, .35), 0 0 12px rgba(94, 234, 212, .15); }
}
.chip.chip-system.active {
  background: rgba(94, 234, 212, .18);
  border-color: rgba(94, 234, 212, .55);
  color: #5eead4;
}

/* ==== cardgrid2: 2 produce cards / row on wide; 1-col narrow; denser for 2×2 / 2×3 ==== */
.produce-grid,
#produceGrid.produce-grid,
.produce-main .produce-grid,
.produce-scroll-wrap .produce-grid {
  display: grid !important;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  align-content: start;
  align-items: start;
}
.produce-grid > .empty {
  grid-column: 1 / -1;
}
.produce-grid > .produce-card {
  min-width: 0;
  width: 100%;
  box-sizing: border-box;
  align-self: start;
}
@media (max-width: 1100px) {
  .produce-grid,
  #produceGrid.produce-grid,
  .produce-main .produce-grid,
  .produce-scroll-wrap .produce-grid {
    grid-template-columns: 1fr;
  }
}

/* Wide 2-col: keep cards short so ~2×2 / 2×3 fit (preserve carddense1 hero align) */
@media (min-width: 1101px) {
  .density-compact.produce-grid,
  .produce-grid.density-compact {
    gap: 8px;
  }
  .density-compact .produce-card {
    padding: 7px 8px;
    gap: 5px;
  }
  .density-compact .produce-card .card-head {
    flex-wrap: wrap;
    gap: 6px;
  }
  .density-compact .card h3 {
    font-size: 13px;
    gap: 4px;
  }
  .density-compact .card-actions-row {
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 4px;
  }
  .density-compact .card-actions-row .btn {
    font-size: 10.5px;
    padding: 2px 7px;
  }
  .density-compact .char-hero {
    height: 104px;
    gap: 5px;
    margin-bottom: 5px;
    grid-template-columns: minmax(0, 1fr) 84px;
  }
  .density-compact .char-final-slots { gap: 3px; }
  .density-compact .hero-slot-label {
    font-size: 8.5px;
    padding: 1px 3px;
  }
  .density-compact .hero-slot-empty {
    font-size: 8.5px;
    padding: 2px;
  }
  .density-compact .char-main-preview .empty-preview {
    font-size: 10px;
    padding: 6px;
  }
  .density-compact .stage-slots.work-lanes .zone,
  .density-compact .stage-slots.work-lanes .drop-zone {
    min-height: 62px;
    padding: 5px 6px 6px;
  }
  .density-compact .zone-title { font-size: 11px; }
  .density-compact .zone-zoom .zone-scale { width: 72px; }
  .density-compact .thumbs-row {
    min-height: 52px;
    gap: 5px;
  }
  .density-compact .thumb.mini {
    width: calc(50px * var(--card-scale, 1));
  }
  .density-compact .thumb.mini .thumb-media {
    height: calc(40px * var(--card-scale, 1));
  }
  .density-compact .upload-tile {
    width: calc(50px * var(--card-scale, 1));
    min-height: calc(52px * var(--card-scale, 1));
  }
  .density-compact .upload-tile .plus { font-size: 16px; }
  .density-compact .zf-chip {
    padding: 1px 6px;
    font-size: 9.5px;
  }
  .produce-card .zones {
    gap: 8px;
  }
  .density-comfy.produce-grid,
  .produce-grid.density-comfy {
    gap: 11px;
  }
  .density-comfy .produce-card {
    padding: 10px 11px;
    gap: 8px;
  }
  .density-comfy .char-hero {
    height: 148px;
    grid-template-columns: minmax(0, 1fr) 96px;
  }
}


/* ==== scriptmark1 / scriptquiet1: entity marks pop above quiet chrome ==== */
.sf-mark {
  border-radius: 4px;
  padding: 1px 4px;
  font-style: normal;
  font-weight: 700;
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
  letter-spacing: 0.01em;
}
.sf-mark-character {
  color: #9af6ff;
  background: rgba(56, 190, 255, 0.28);
  box-shadow: inset 0 -2.5px 0 rgba(70, 200, 255, 0.95);
}
.sf-mark-scene {
  color: #a8ffc8;
  background: rgba(56, 210, 130, 0.26);
  box-shadow: inset 0 -2.5px 0 rgba(70, 220, 140, 0.92);
}
.sf-mark-prop {
  color: #ffe09a;
  background: rgba(255, 186, 72, 0.28);
  box-shadow: inset 0 -2.5px 0 rgba(255, 186, 72, 0.95);
}
.sf-mark-first {
  outline: 1px solid rgba(255,255,255,.12);
  outline-offset: 0;
}
/* dialogue speaker: keep quiet gold body, soft cyan underline if linked */
.sf-mark-speaker {
  text-decoration: none;
  box-shadow: inset 0 -1.5px 0 rgba(70, 200, 255, 0.45);
  border-radius: 2px;
}
.sf-first-badge {
  display: inline-block;
  margin-left: 2px;
  padding: 0 3px;
  font-size: 8px;
  font-weight: 600;
  line-height: 1.35;
  vertical-align: super;
  border-radius: 999px;
  color: rgba(180, 220, 230, 0.75);
  background: rgba(70, 180, 200, 0.14);
  border: 1px solid rgba(90, 200, 210, 0.28);
  letter-spacing: 0.02em;
}
.sf-action .sf-mark,
.sf-body .sf-mark,
.sf-cast-list .sf-mark,
.sf-scene-title .sf-mark,
.sf-line .sf-mark {
  cursor: help;
}
.sf-scene-code {
  opacity: 0.55;
  margin-right: 4px;
  font-weight: 500;
  color: rgba(200, 180, 150, 0.55);
}

/* selection bubble */
.script-mark-bubble {
  position: fixed;
  z-index: 80;
  padding: 4px;
  border-radius: 10px;
  background: rgba(18, 20, 30, 0.96);
  border: 1px solid rgba(126, 240, 255, 0.35);
  box-shadow: 0 8px 28px rgba(0,0,0,.45);
}
.script-mark-bubble.hidden { display: none !important; }
.script-mark-bubble .btn { white-space: nowrap; }

.mark-type-modal { max-width: 360px; }
.mark-quote {
  margin: 0 0 14px;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(255,255,255,.04);
  border: 1px solid rgba(255,255,255,.08);
  color: #e8ecf6;
  font-size: 14px;
  line-height: 1.5;
  word-break: break-all;
}
.mark-type-chips {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 8px;
}
.mark-chip {
  appearance: none;
  border: 1px solid transparent;
  border-radius: 12px;
  padding: 14px 8px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: transform .12s ease, box-shadow .12s ease;
}
.mark-chip:hover { transform: translateY(-1px); }
.mark-chip.character {
  color: #7ef0ff;
  background: rgba(46, 210, 232, 0.12);
  border-color: rgba(46, 210, 232, 0.45);
}
.mark-chip.scene {
  color: #8dffb8;
  background: rgba(62, 207, 142, 0.12);
  border-color: rgba(62, 207, 142, 0.45);
}
.mark-chip.prop {
  color: #ffd27a;
  background: rgba(255, 186, 72, 0.12);
  border-color: rgba(255, 186, 72, 0.45);
}

/* right analysis portrait / state */
.asset-portrait, .asset-state {
  margin-top: 5px;
  font-size: 11px;
  line-height: 1.45;
  color: rgba(210, 218, 232, 0.88);
}
.asset-portrait .ap-line { margin-top: 2px; }
.ap-k {
  display: inline-block;
  margin-right: 6px;
  padding: 0 5px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  border-radius: 999px;
  color: #c4b0ff;
  background: rgba(155, 123, 255, 0.14);
  border: 1px solid rgba(155, 123, 255, 0.28);
}
.asset-state .ap-k {
  color: #ffd27a;
  background: rgba(255, 186, 72, 0.12);
  border-color: rgba(255, 186, 72, 0.3);
}
.asset-row.mark-flash {
  animation: markFlash 1.2s ease;
  border-color: rgba(46, 210, 232, 0.65) !important;
}
@keyframes markFlash {
  0%, 100% { background: transparent; }
  30% { background: rgba(46, 210, 232, 0.12); }
}

/* ==== colsgrad1: zone divider fade + vertical wash; produce cols; title size ==== */
.stage-slots.work-lanes {
  background: rgba(8,10,16,.35);
}
.stage-slots.work-lanes .zone:not(:first-child)::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 1px;
  background: linear-gradient(180deg,
    rgba(196,176,255,0) 0%,
    rgba(196,176,255,.22) 12%,
    rgba(212,165,116,.55) 50%,
    rgba(196,176,255,.22) 88%,
    rgba(196,176,255,0) 100%);
  pointer-events: none;
  z-index: 2;
}
.stage-slots.work-lanes .zone[data-slot="ref"] {
  background: linear-gradient(180deg, rgba(28,24,42,.78) 0%, rgba(14,12,20,.42) 48%, rgba(8,9,14,.55) 100%) !important;
}
.stage-slots.work-lanes .zone[data-slot="costume"] {
  background: linear-gradient(180deg, rgba(34,22,28,.78) 0%, rgba(16,12,16,.42) 48%, rgba(10,9,12,.55) 100%) !important;
}
.stage-slots.work-lanes .zone[data-slot="face"] {
  background: linear-gradient(180deg, rgba(20,26,40,.78) 0%, rgba(12,14,22,.42) 48%, rgba(8,10,16,.55) 100%) !important;
}

/* produce-card title = largest text on card */
.produce-card .card-head h3,
.produce-card h3 {
  font-size: 18px !important;
  font-weight: 750 !important;
  letter-spacing: 0.02em;
  color: #f3f0ff !important;
  line-height: 1.25;
  text-shadow: 0 1px 0 rgba(0,0,0,.35);
}
.produce-card h3 .tag,
.produce-card h3 .pill,
.produce-card .card-head .tag,
.produce-card .card-head .pill {
  font-size: 11px !important;
  font-weight: 600 !important;
  letter-spacing: 0;
  text-shadow: none;
}
.density-compact .produce-card h3 { font-size: 17px !important; }
.density-comfy .produce-card h3 { font-size: 19px !important; }

/* column layout */
#produceGrid.produce-grid.cols-1,
.produce-grid.cols-1 {
  grid-template-columns: minmax(0, 1fr) !important;
  gap: 14px;
}
#produceGrid.produce-grid.cols-2,
.produce-grid.cols-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  gap: 10px;
}
#produceGrid.produce-grid.cols-3,
.produce-grid.cols-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
  gap: 8px;
}
@media (max-width: 1100px) {
  #produceGrid.produce-grid.cols-3,
  .produce-grid.cols-3 {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }
}
@media (max-width: 820px) {
  #produceGrid.produce-grid.cols-2,
  #produceGrid.produce-grid.cols-3,
  .produce-grid.cols-2,
  .produce-grid.cols-3 {
    grid-template-columns: minmax(0, 1fr) !important;
  }
}

/* cols-1: larger chrome */
.produce-grid.cols-1 .produce-card { padding: 12px 14px; gap: 10px; }
.produce-grid.cols-1 .char-hero {
  height: 168px;
  grid-template-columns: minmax(0, 1fr) 120px;
}
.produce-grid.cols-1.density-compact .char-hero,
.produce-grid.cols-1 .density-compact .char-hero { height: 148px; }
.produce-grid.cols-1 .stage-slots.work-lanes .zone,
.produce-grid.cols-1 .stage-slots.work-lanes .drop-zone {
  min-height: 110px;
  padding: 10px 12px 12px;
}
.produce-grid.cols-1 .thumb.mini { width: calc(84px * var(--card-scale, 1)); }
.produce-grid.cols-1 .thumb.mini .thumb-media { height: calc(64px * var(--card-scale, 1)); }
.produce-grid.cols-1 .upload-tile {
  width: calc(84px * var(--card-scale, 1));
  min-height: calc(86px * var(--card-scale, 1));
}
.produce-grid.cols-1 .produce-card h3 { font-size: 20px !important; }

/* cols-3: tighter chrome */
.produce-grid.cols-3 .produce-card { padding: 6px 7px; gap: 5px; }
.produce-grid.cols-3 .char-hero {
  height: 92px;
  gap: 4px;
  margin-bottom: 4px;
  grid-template-columns: minmax(0, 1fr) 72px;
}
.produce-grid.cols-3 .stage-slots.work-lanes .zone,
.produce-grid.cols-3 .stage-slots.work-lanes .drop-zone {
  min-height: 54px;
  padding: 4px 5px 5px;
}
.produce-grid.cols-3 .zone-title { font-size: 10.5px; }
.produce-grid.cols-3 .zone-zoom .zone-scale { width: 64px; }
.produce-grid.cols-3 .thumbs-row { min-height: 46px; gap: 4px; }
.produce-grid.cols-3 .thumb.mini { width: calc(44px * var(--card-scale, 1)); }
.produce-grid.cols-3 .thumb.mini .thumb-media { height: calc(34px * var(--card-scale, 1)); }
.produce-grid.cols-3 .upload-tile {
  width: calc(44px * var(--card-scale, 1));
  min-height: calc(46px * var(--card-scale, 1));
}
.produce-grid.cols-3 .upload-tile .plus { font-size: 14px; }
.produce-grid.cols-3 .zf-chip { padding: 1px 5px; font-size: 9px; }
.produce-grid.cols-3 .card-actions-row .btn { font-size: 10px; padding: 2px 6px; }
.produce-grid.cols-3 .produce-card h3 { font-size: 15px !important; }

.cols-seg button { min-width: 40px; }

/* @系统 chip always visible / distinct idle state */
.mention-bar .chip.chip-system {
  border-color: rgba(94, 234, 212, .35);
  color: #7ee7d5;
  background: rgba(94, 234, 212, .08);
}
.mention-bar .chip.chip-system:hover {
  border-color: rgba(94, 234, 212, .55);
  color: #a7f3e8;
}
.mention-bar .chip.chip-system.active {
  background: rgba(94, 234, 212, .2);
  border-color: rgba(94, 234, 212, .65);
  color: #5eead4;
  font-weight: 700;
}


/* —— lightbox1: 点缩略图任意处可放大，遮罩不吞点击 —— */
.thumb-media { position: relative; cursor: zoom-in; }
.thumb-overlay {
  pointer-events: none;
}
.thumb-overlay .thumb-ico,
.thumb-overlay a.thumb-ico,
.thumb-overlay button.thumb-ico {
  pointer-events: auto;
}
.lightbox {
  z-index: 5000;
}


/* —— chathover1: Feishu-like hover toolbar + quote + likes + reads —— */
.chat-col {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  min-width: 0;
  max-width: 100%;
  gap: 4px;
}
.chat-row.mine .chat-col { align-items: flex-end; }
.chat-bubble-wrap {
  position: relative;
  max-width: 100%;
}
.chat-hover-bar {
  position: absolute;
  top: -14px;
  right: 4px;
  z-index: 5;
  display: none;
  align-items: center;
  flex-wrap: wrap;
  gap: 2px;
  max-width: min(92vw, 360px);
  padding: 3px 4px;
  border-radius: 10px;
  background: rgba(18, 20, 28, 0.96);
  border: 1px solid rgba(255,255,255,0.12);
  box-shadow: 0 6px 18px rgba(0,0,0,0.45);
  white-space: normal;
}
.chat-row.mine .chat-hover-bar { right: auto; left: 4px; }
.chat-bubble-wrap:hover .chat-hover-bar,
.chat-row:hover .chat-hover-bar { display: inline-flex; }
.chat-row.system .chat-hover-bar { display: none !important; }
.chat-row.show-actions .chat-hover-bar { display: inline-flex !important; }
body.mobile .chat-row.show-actions .chat-hover-bar { display: inline-flex !important; }
.chat-hover-bar button {
  appearance: none;
  border: 0;
  background: transparent;
  color: rgba(255,255,255,0.78);
  font-size: 11px;
  padding: 4px 7px;
  border-radius: 7px;
  cursor: pointer;
  line-height: 1.2;
}
.chat-hover-bar button:hover {
  background: rgba(168,140,255,0.22);
  color: #fff;
}
.chat-hover-bar button.liked {
  color: #ffb4c8;
}
.chat-quote-in {
  margin: 0 0 6px;
  padding: 6px 8px;
  border-radius: 8px;
  border-left: 3px solid rgba(168,140,255,0.65);
  background: rgba(0,0,0,0.22);
  font-size: 11.5px;
  line-height: 1.35;
  color: rgba(255,255,255,0.72);
}
.chat-bubble.mine .chat-quote-in {
  background: rgba(0,0,0,0.18);
  border-left-color: rgba(228,216,255,0.7);
}
.chat-quote-in .q-author {
  font-weight: 650;
  color: rgba(212,165,116,0.95);
  margin-right: 4px;
}
.chat-bubble.mine .chat-quote-in .q-author { color: #e4d8ff; }
.chat-quote-in .q-body {
  display: inline;
  opacity: 0.9;
  word-break: break-word;
}
.chat-like-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  margin-top: 6px;
  padding: 2px 7px;
  border-radius: 999px;
  font-size: 11px;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.1);
  color: rgba(255,210,220,0.95);
  cursor: pointer;
  user-select: none;
}
.chat-like-badge.mine-liked {
  background: rgba(255,120,150,0.16);
  border-color: rgba(255,150,180,0.35);
}
.chat-like-badge:hover { filter: brightness(1.08); }
.chat-readers {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  padding: 0 2px;
}
.chat-reader {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  max-width: 120px;
}
.chat-reader-av {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
  border: 1px solid rgba(255,255,255,0.18);
  background: #2a2e3c;
  font-size: 9px;
  font-weight: 700;
  color: #fff;
  display: grid;
  place-items: center;
}
.chat-reader-av img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.chat-reader-name {
  font-size: 10px;
  color: rgba(255,255,255,0.45);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.chat-quote-preview {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin: 0 0 8px;
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(28, 24, 42, 0.92);
  border: 1px solid rgba(168,140,255,0.28);
  border-left: 3px solid rgba(168,140,255,0.75);
}
.chat-quote-preview.hidden { display: none; }
.chat-quote-preview .qp-body {
  flex: 1;
  min-width: 0;
  font-size: 12px;
  line-height: 1.4;
  color: rgba(255,255,255,0.78);
}
.chat-quote-preview .qp-author {
  font-weight: 650;
  color: #d4a574;
  margin-right: 4px;
}
.chat-quote-preview .qp-text {
  word-break: break-word;
  opacity: 0.9;
}
.chat-quote-preview .qp-x {
  appearance: none;
  border: 0;
  background: transparent;
  color: rgba(255,255,255,0.45);
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  padding: 2px 4px;
  border-radius: 6px;
}
.chat-quote-preview .qp-x:hover {
  color: #fff;
  background: rgba(255,255,255,0.08);
}


/* —— scriptpane1: analysis resize + font + color legend —— */
.script-font-ctrl {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-left: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  font-size: 11px;
}
.script-font-ctrl input[type="range"] {
  width: 88px;
  accent-color: #9b7bff;
  cursor: pointer;
}
.script-font-ctrl #scriptFontVal {
  min-width: 1.6em;
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.script-color-legend {
  flex-shrink: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 14px;
  padding: 8px 18px 6px;
  border-bottom: 1px solid rgba(255,255,255,0.05);
  background: rgba(0,0,0,0.12);
}
.script-color-legend .leg-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: rgba(255,255,255,0.62);
  letter-spacing: 0.02em;
}
.script-color-legend .leg-item i {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 3px;
  box-shadow: inset 0 -2px 0 rgba(0,0,0,0.15);
}
.script-color-legend .leg-char i {
  background: rgba(56, 190, 255, 0.45);
  box-shadow: inset 0 -2.5px 0 rgba(70, 200, 255, 0.95);
}
.script-color-legend .leg-scene i {
  background: rgba(56, 210, 130, 0.4);
  box-shadow: inset 0 -2.5px 0 rgba(70, 220, 140, 0.92);
}
.script-color-legend .leg-prop i {
  background: rgba(255, 186, 72, 0.42);
  box-shadow: inset 0 -2.5px 0 rgba(255, 186, 72, 0.95);
}
.panel-script .script-result-card {
  width: 100%;
  min-width: 0;
}


/* —— chatassign1: multi pending thumbs —— */
.chat-pending.multi {
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
}
.chat-pending-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 11px;
  color: rgba(255,255,255,0.55);
}
.chat-pending-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.chat-pending-item {
  position: relative;
  width: 58px;
  height: 58px;
  border-radius: 9px;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,0.12);
  background: #0c0e14;
  flex-shrink: 0;
}
.chat-pending-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  border-radius: 0;
}
.chat-pending-item .pending-file {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  font-size: 22px;
  background: rgba(255,255,255,0.05);
}
.chat-pending-item .xi {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 18px;
  height: 18px;
  border: 0;
  border-radius: 50%;
  background: rgba(0,0,0,0.72);
  color: #ffb4b4;
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
  display: grid;
  place-items: center;
  padding: 0;
}
.chat-pending-item .xi:hover { background: rgba(120,40,40,0.9); color: #fff; }
.chat-pending-name-list {
  font-size: 10.5px;
  color: rgba(255,255,255,0.4);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}


/* —— chatmention1: @ mention popup —— */
.composer-shell { position: relative; }
.mention-suggest {
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: calc(100% + 6px);
  z-index: 30;
  max-height: 220px;
  overflow: auto;
  padding: 4px;
  border-radius: 12px;
  background: rgba(16, 18, 26, 0.98);
  border: 1px solid rgba(168,140,255,0.35);
  box-shadow: 0 12px 28px rgba(0,0,0,0.55);
}
.mention-suggest.hidden { display: none !important; }
.mention-suggest-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  text-align: left;
  padding: 7px 8px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: rgba(255,255,255,0.88);
  cursor: pointer;
  font-size: 12.5px;
}
.mention-suggest-item:hover,
.mention-suggest-item.active {
  background: rgba(168,140,255,0.22);
}
.mention-suggest-av {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  border: 1px solid rgba(255,255,255,0.12);
  background: #9b7bff;
}
.mention-suggest-av img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.mention-suggest-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mention-suggest-empty {
  padding: 10px 8px;
  font-size: 12px;
  color: rgba(255,255,255,0.4);
  text-align: center;
}

/* ===== mobile1: chat-first mobile shell ===== */

/* Desktop: chat is sibling of workbench (moved out of .workbench-shell) */
body.view-workbench .app-frame {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  grid-template-columns: minmax(0, 1fr) var(--chat-w, 0px);
  height: 100vh;
  max-height: 100vh;
  overflow: hidden;
}
body.view-workbench .app-header {
  grid-column: 1 / -1;
  grid-row: 1;
}
body.view-workbench #view-workbench {
  grid-column: 1;
  grid-row: 2;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}
body.view-workbench .workbench-shell {
  grid-template-columns: minmax(0, 1fr) !important;
  height: 100%;
}
body.view-workbench #globalChat {
  grid-column: 2;
  grid-row: 2;
  position: relative;
  top: 0;
  height: 100%;
  max-height: none;
  width: 100%;
  max-width: none;
  align-self: stretch;
}
body.view-workbench #mobileHomePane { display: none !important; }

/* Desktop home: keep previous behavior — no floating chat on hub */
@media (min-width: 769px) {
  body.view-home #globalChat,
  body.view-home #mobileHomePane { display: none !important; }
}

/* System status bubbles: dashed frame; color only on text */
.chat-bubble.system-msg,
.chat-msg.system-msg {
  background: rgba(255, 255, 255, 0.04);
  border: 1px dashed rgba(255, 255, 255, 0.22);
  border-left: 1px dashed rgba(255, 255, 255, 0.22);
  color: rgba(242, 242, 245, 0.88);
  opacity: 1;
  box-shadow: none;
}
.chat-bubble.system-msg.sys-ok,
.chat-msg.system-msg.sys-ok {
  background: transparent;
  border: 1px dashed rgba(255, 255, 255, 0.22);
  color: #6ddea0;
  opacity: 1;
}
.chat-bubble.system-msg.sys-ok .body,
.chat-msg.system-msg.sys-ok .body,
.chat-bubble.system-msg.sys-ok .who,
.chat-msg.system-msg.sys-ok .who {
  color: #6ddea0;
}
.chat-bubble.system-msg.sys-err,
.chat-msg.system-msg.sys-err {
  background: transparent;
  border: 1px dashed rgba(255, 255, 255, 0.22);
  color: #ff8e98;
  opacity: 1;
}
.chat-bubble.system-msg.sys-err .body,
.chat-msg.system-msg.sys-err .body,
.chat-bubble.system-msg.sys-err .who,
.chat-msg.system-msg.sys-err .who {
  color: #ff8e98;
}
.chat-bubble.system-msg.sys-info,
.chat-msg.system-msg.sys-info {
  background: transparent;
  border: 1px dashed rgba(255, 255, 255, 0.22);
  color: rgba(242, 242, 245, 0.88);
  opacity: 1;
}

/* chatux2: recall / delete hover actions */
.chat-hover-bar button.danger {
  color: #ffb4bc;
}
.chat-hover-bar button.danger:hover {
  background: rgba(200, 60, 80, 0.35);
  color: #ffe0e4;
}
.chat-bubble.recalled,
.chat-msg.recalled {
  opacity: 0.72;
  background: rgba(120, 120, 140, 0.12);
  border-style: dashed;
}
.chat-recalled {
  font-style: italic;
  opacity: 0.85;
  color: rgba(220, 220, 235, 0.75);
  user-select: none;
}
.chat-row.recalled .chat-like-badge { display: none; }

/* chatux3: WeChat-style recall tip */
.chat-row.recall-tip {
  display: flex;
  justify-content: center;
  align-items: center;
  max-width: 100% !important;
  margin: 6px auto;
  padding: 0 12px;
}
.chat-recall-tip {
  font-size: 12px;
  color: rgba(180, 185, 200, 0.78);
  text-align: center;
  line-height: 1.4;
  user-select: none;
}
.chat-reedit {
  appearance: none;
  border: 0;
  background: transparent;
  color: #6db3ff;
  font-size: 12px;
  cursor: pointer;
  padding: 0 2px;
  margin-left: 2px;
}
.chat-reedit:hover { text-decoration: underline; color: #9accff; }

/* chataspect1: Feishu-like album — keep natural aspect (16:9 stays landscape) */
.chat-img-grid {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 8px;
  max-width: min(360px, 100%);
  width: 100%;
}
.chat-img-grid.n-1,
.chat-img-grid.n-2,
.chat-img-grid.n-3,
.chat-img-grid.n-4,
.chat-img-grid.n-5,
.chat-img-grid.n-6,
.chat-img-grid.n-7,
.chat-img-grid.n-8,
.chat-img-grid.n-9 {
  grid-template-columns: unset;
  max-width: min(360px, 100%);
}
.chat-album-cell {
  appearance: none;
  border: 0;
  padding: 0;
  margin: 0;
  background: rgba(0,0,0,.35);
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
  aspect-ratio: auto;
  width: 100%;
  height: auto;
  border: 1px solid var(--border);
  display: block;
  line-height: 0;
}
.chat-album-cell img {
  width: 100%;
  height: auto;
  max-height: min(52vh, 420px);
  object-fit: contain;
  object-position: center;
  display: block;
  background: #0a0b10;
}
.chat-album-cell:hover {
  outline: 2px solid rgba(212,165,116,.45);
  outline-offset: 1px;
}
.chat-album-more {
  font-size: 11px;
  color: var(--muted);
  margin-top: 4px;
}
.chat-file-list { margin-top: 6px; display: flex; flex-direction: column; gap: 4px; }
.chat-row.mine .chat-img-grid { margin-left: auto; }

/* single chat-msg-img also keep ratio */
.chat-msg-img {
  width: auto !important;
  max-width: min(360px, 100%);
  height: auto !important;
  max-height: min(52vh, 420px);
  object-fit: contain !important;
}



.mobile-home-pane { display: none; }

@media (max-width: 768px) {
  body.mobile {
    --mobile-lower-h: min(48dvh, 420px);
  }
  body.mobile .app-frame {
    display: flex !important;
    flex-direction: column;
    height: 100dvh;
    max-height: 100dvh;
    overflow: hidden;
  }
  body.mobile .app-header {
    flex-shrink: 0;
  }
  /* Upper: platform content */
  body.mobile #view-home,
  body.mobile #view-workbench {
    flex: 1 1 auto;
    min-height: 0;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
  }
  body.mobile.view-workbench #view-workbench {
    display: flex;
    flex-direction: column;
  }
  body.mobile.view-workbench .workbench-shell {
    display: block !important;
    height: auto;
    min-height: 0;
    overflow: visible;
  }
  body.mobile.view-workbench .workbench-shell > .main {
    max-width: none;
    padding-bottom: 12px;
  }

  /* Hide desktop chat width mechanics */
  body.mobile.view-workbench .app-frame {
    display: flex !important;
    grid-template-columns: none !important;
    grid-template-rows: none !important;
  }
  body.mobile #globalChat {
    position: fixed !important;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100% !important;
    max-width: none !important;
    height: var(--mobile-lower-h);
    z-index: 90;
    pointer-events: none;
  }
  body.mobile #globalChat > * { pointer-events: auto; }

  body.mobile #mobileHomePane {
    display: flex;
    position: fixed;
    left: 0; right: 0; bottom: 0;
    height: var(--mobile-lower-h);
    z-index: 85;
    background: linear-gradient(180deg, rgba(18,20,28,.92), rgba(12,14,20,.98));
    border-top: 1px solid rgba(255,255,255,.08);
    padding: 18px 20px calc(18px + env(safe-area-inset-bottom, 0px));
    box-sizing: border-box;
    overflow: auto;
  }
  body.mobile .mobile-home-inner { margin: auto 0; width: 100%; max-width: 420px; }
  body.mobile .mobile-home-title {
    font-size: 28px;
    letter-spacing: 0.08em;
    margin: 4px 0 10px;
    font-weight: 700;
  }
  body.mobile .mobile-home-lead {
    color: var(--muted);
    font-size: 14px;
    line-height: 1.55;
    margin: 0 0 14px;
  }
  body.mobile .mobile-home-points {
    margin: 0;
    padding-left: 1.1em;
    color: rgba(244,241,255,.82);
    font-size: 13px;
    line-height: 1.7;
  }

  /* Default: lower = home typography; chat panel hidden; FAB visible */
  body.mobile:not(.mobile-msg-open) #mobileHomePane { display: flex; }
  body.mobile:not(.mobile-msg-open) #globalChat .chat-dock-panel { display: none !important; }
  body.mobile:not(.mobile-msg-open) #globalChat .chat-fab {
    display: inline-flex !important;
    position: fixed;
    right: 16px;
    bottom: calc(12px + env(safe-area-inset-bottom, 0px));
    z-index: 95;
  }
  body.mobile:not(.mobile-msg-open) #globalChat .chat-resize-handle { display: none !important; }

  /* Message mode: lower = chat; hide home pane */
  body.mobile.mobile-msg-open #mobileHomePane { display: none !important; }
  body.mobile.mobile-msg-open #globalChat {
    pointer-events: auto;
  }
  body.mobile.mobile-msg-open #globalChat.collapsed,
  body.mobile.mobile-msg-open #globalChat.open {
    width: 100% !important;
    max-width: none !important;
  }
  body.mobile.mobile-msg-open #globalChat .chat-dock-panel {
    display: flex !important;
    position: absolute !important;
    inset: 0;
    width: 100% !important;
    height: 100% !important;
    max-height: none !important;
    border-radius: 16px 16px 0 0 !important;
    box-shadow: 0 -8px 32px rgba(0,0,0,.45);
  }
  body.mobile.mobile-msg-open #globalChat .chat-fab { display: none !important; }
  body.mobile.mobile-msg-open #globalChat .chat-resize-handle { display: none !important; }

  /* Content area leaves room for lower pane */
  body.mobile #view-home,
  body.mobile #view-workbench {
    padding-bottom: calc(var(--mobile-lower-h) + 8px);
  }

  body.mobile .app-header .brand-text h1 { font-size: 13px; }
  body.mobile .app-header .sub { display: none; }
  body.mobile .profile-name { max-width: 72px; overflow: hidden; text-overflow: ellipsis; }
  body.mobile .hub-shell { grid-template-columns: 1fr !important; }
  body.mobile .hub-rail { display: none; }
  body.mobile .project-tabs { overflow-x: auto; flex-wrap: nowrap; max-width: 58vw; }
  body.mobile .project-tabs .tab { flex-shrink: 0; font-size: 12px; padding: 6px 8px; }

  /* Touch: long-press friendly images */
  body.mobile .chat-msg-img,
  body.mobile .thumb img,
  body.mobile [data-chat-img] {
    -webkit-touch-callout: none;
    user-select: none;
    touch-action: manipulation;
  }
}

/* FAB label short on tiny screens */
@media (max-width: 420px) {
  body.mobile .chat-fab .gc-label { display: none; }
}


/* ===== gapright1: gap filters in sticky top-right ===== */
@media (max-width: 768px) {
  .pipe-legend { gap: 5px; margin-bottom: 8px; }
  button.pill, .pill { font-size: 10px; padding: 3px 8px; }
  .produce-gap-filters { gap: 5px; width: 100%; justify-content: flex-end; }
  .pipe-legend-sep { height: 14px; }
}


/* ===== chatjump1: scroll jump chips ===== */
.chat-msg-stage {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.chat-msg-stage > .chat-messages {
  flex: 1;
  min-height: 0;
}
.chat-jump-stack {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  bottom: 0;
  display: block;
  pointer-events: none;
  z-index: 8;
}
#btnChatJumpTop {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
}
#btnChatJumpLatest {
  position: absolute;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
}
.chat-jump-chip {
  pointer-events: auto;
  border: 1px solid rgba(255,255,255,.16);
  background: rgba(18, 20, 28, 0.92);
  color: rgba(255,255,255,.9);
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 12px;
  font-weight: 560;
  letter-spacing: 0.02em;
  box-shadow: 0 6px 18px rgba(0,0,0,.38);
  cursor: pointer;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: opacity .15s ease, transform .15s ease, background .15s ease;
}
.chat-jump-chip:hover {
  background: rgba(32, 36, 50, 0.96);
  border-color: rgba(168,140,255,.45);
  color: #fff;
}
#btnChatJumpTop:hover,
#btnChatJumpLatest:hover {
  transform: translateX(-50%);
}
.chat-jump-chip.hidden { display: none !important; }
.chat-jump-chip[data-mode="new"] {
  border-color: rgba(168,140,255,.5);
  background: rgba(48, 36, 80, 0.94);
  color: #efe8ff;
}
body.mobile #btnChatJumpLatest { bottom: 10px; }
body.mobile .chat-jump-chip { font-size: 11.5px; padding: 6px 12px; }


/* ===== gapright1 sticky gap chips far right ===== */
.produce-sticky-bar .produce-gap-filters {
  margin-left: 4px;
}
.produce-sticky-bar > .spacer {
  flex: 1 1 auto;
  min-width: 8px;
}

/* ===== homeelite1: premium centered home hub ===== */
.view-page.view-hub {
  background:
    radial-gradient(1000px 500px at 50% -20%, rgba(155,123,255,.05), transparent 60%),
    transparent;
}
body.view-home .app-nav-btn.active {
  /* no bottom mark line — soft fill + glow only */
  text-decoration: none !important;
  border-bottom: 1px solid rgba(180, 160, 255, 0.36);
}

/* Single centered column — no left rail */
.hub-shell {
  display: block !important;
  grid-template-columns: none !important;
  overflow: auto;
}
.hub-rail { display: none !important; }

.hub-main {
  min-width: 0;
  min-height: 0;
  overflow: visible;
  padding: 48px 24px 80px;
  display: flex;
  flex-direction: column;
  align-items: center;
  background:
    radial-gradient(900px 420px at 50% -8%, rgba(155,123,255,.08), transparent 55%),
    radial-gradient(700px 360px at 80% 8%, rgba(212,165,116,.04), transparent 50%),
    transparent;
}

/* Hero: title + tip + CTAs centered */
.hub-hero {
  width: 100%;
  max-width: 720px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  margin: 8px auto 40px;
  padding: 8px 12px 0;
}
.hub-hero .eyebrow {
  letter-spacing: .18em;
  color: var(--accent-purple, #9b7bff);
  font-size: 11px;
  margin: 0 0 14px;
  font-weight: 600;
}
.hub-hero-title {
  margin: 0 0 12px;
  font-size: clamp(28px, 3.2vw, 36px);
  font-weight: 720;
  letter-spacing: 0.04em;
  background: linear-gradient(92deg, #f6f2ff 8%, #cfc0ff 48%, #e8c4d4 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  line-height: 1.2;
}
.hub-hero-tip {
  margin: 0 0 26px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.7;
  max-width: 420px;
  letter-spacing: 0.02em;
}
.hub-hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: center;
  margin-bottom: 18px;
}
.hub-hero-actions .hub-cta,
.hub-hero-actions .hub-secondary {
  width: auto;
  min-width: 132px;
  padding: 12px 22px;
  border-radius: 12px;
  font-size: 14px;
  letter-spacing: 0.02em;
}
.hub-hero-meta {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}
.hub-hero-meta .hub-count {
  font-size: 12px;
  color: var(--accent-strong);
  letter-spacing: 0.06em;
  padding: 4px 12px;
  border-radius: 999px;
  background: rgba(155,123,255,.08);
  border: 1px solid rgba(155,123,255,.18);
}

.hub-main-head {
  display: flex;
  justify-content: center;
  align-items: center;
  text-align: center;
  gap: 16px;
  margin-bottom: 22px;
  width: 100%;
  max-width: 960px;
}
.hub-main-head .page-title {
  margin: 0 0 6px;
  font-size: 18px;
  font-weight: 650;
  letter-spacing: 0.06em;
  color: var(--text);
  background: none;
  -webkit-background-clip: unset;
  background-clip: unset;
  opacity: 0.92;
}
.hub-main-head .muted {
  margin: 0;
  font-size: 12.5px;
  letter-spacing: 0.02em;
  opacity: 0.85;
}

.project-grid.hub-grid,
.hub-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 20px;
  width: 100%;
  max-width: 960px;
  justify-content: center;
}
/* Single card: keep visually centered */
.project-grid.hub-grid:has(> :only-child) {
  grid-template-columns: minmax(280px, 420px);
  justify-content: center;
}

.project-card.hub-card,
.hub-card {
  background: linear-gradient(165deg, rgba(34, 38, 56, .92), rgba(18, 20, 30, .96));
  border: 1px solid rgba(155,123,255,.18);
  border-radius: 20px;
  box-shadow:
    0 16px 40px rgba(0,0,0,.28),
    0 1px 0 rgba(255,255,255,.05) inset;
  backdrop-filter: blur(8px);
}
.hub-empty {
  max-width: 720px;
  margin: 0 auto;
}

@media (min-width: 1100px) {
  .hub-main { padding: 56px 40px 96px; }
}
@media (max-width: 900px) {
  .hub-main { padding: 28px 16px 56px; }
  .hub-hero { margin-bottom: 28px; }
  .hub-hero-title { font-size: 26px; }
  .hub-main-head, .project-grid.hub-grid, .hub-grid, .hub-empty { max-width: none; }
  .project-grid.hub-grid:has(> :only-child) {
    grid-template-columns: 1fr;
  }
}

/* ===== Theme toggle: compact icon left of account ===== */
.theme-toggle-btn {
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  padding: 0;
  margin: 0;
  display: inline-grid;
  place-items: center;
  border-radius: 50%;
  border: 1px solid rgba(155,123,255,.28);
  background: rgba(155,123,255,.08);
  color: #dcd6ff;
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease, color .15s ease, box-shadow .15s ease;
  box-shadow: none;
  line-height: 0;
}
.theme-toggle-btn:hover {
  background: rgba(155,123,255,.16);
  border-color: rgba(155,123,255,.48);
  color: #fff;
  box-shadow: 0 0 0 3px rgba(155,123,255,.1);
}
.theme-toggle-btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(155,123,255,.28);
}
.theme-toggle-btn .theme-icon { display: none; }
/* Dark mode → show sun (switch to light) */
html:not(.theme-light) .theme-toggle-btn .theme-icon-sun { display: block; }
/* Light mode → show moon (switch to dark) */
html.theme-light .theme-toggle-btn .theme-icon-moon { display: block; }

/* ===== Light theme polish ===== */
html.theme-light {
  color-scheme: light;
  --bg: #f5f5f7;
  --bg-elevated: #ffffff;
  --panel: #ffffff;
  --panel2: #f0f0f2;
  --panel3: #ebebed;
  --border: #e0e0e4;
  --border-soft: rgba(0, 0, 0, 0.08);
  --text: #1a1a22;
  --muted: #5a5a66;
  --accent: #b8864a;
  --accent-strong: #9a6b2f;
  --accent-rose: #8b6bb8;
  --rose: #6b5b95;
  --accent2: #5b6fd6;
  --ok: #2a9f6a;
  --warn: #d4882a;
  --danger: #d04545;
  --flash: #6b5b95;
  --extra: #3a8fd0;
  --shadow: 0 12px 36px rgba(0, 0, 0, 0.08);
  --shadow-soft: 0 4px 16px rgba(0, 0, 0, 0.06);
  --gold-glow: rgba(184, 134, 74, 0.14);
  --rose-glow: rgba(107, 91, 149, 0.1);
  --accent-purple: #6b5b95;
}
html.theme-light,
html.theme-light body {
  background: var(--bg);
  color: var(--text);
}
html.theme-light .app-header {
  background: rgba(255, 255, 255, 0.9);
  border-bottom-color: var(--border-soft);
  box-shadow: 0 1px 0 rgba(255,255,255,.8);
}
html.theme-light .brand h1 {
  background: none;
  -webkit-background-clip: unset;
  background-clip: unset;
  color: #1a1a22;
}
html.theme-light .app-nav-btn:hover {
  color: var(--text);
  background: rgba(122, 92, 219, 0.06);
}
html.theme-light .app-nav-btn.active {
  color: #3d2f78;
  background: rgba(122, 92, 219, 0.12);
  border-color: rgba(122, 92, 219, 0.28);
  box-shadow: 0 6px 18px rgba(122, 92, 219, 0.12);
}
html.theme-light .profile-chip {
  background: var(--panel2);
  border-color: var(--border);
  color: var(--text);
}
html.theme-light .profile-chip:hover {
  border-color: rgba(122, 92, 219, 0.45);
}
html.theme-light .theme-toggle-btn {
  border-color: rgba(122, 92, 219, 0.28);
  background: rgba(122, 92, 219, 0.08);
  color: #5a4a9a;
}
html.theme-light .theme-toggle-btn:hover {
  background: rgba(122, 92, 219, 0.14);
  border-color: rgba(122, 92, 219, 0.45);
  color: #3d2f78;
}
html.theme-light .hub-hero-title {
  background: none;
  -webkit-background-clip: unset;
  background-clip: unset;
  color: #1a1a22;
}
html.theme-light .hub-main {
  background: transparent;
}
html.theme-light .hub-hero-meta .hub-count {
  color: #5a4a9a;
  background: rgba(122,92,219,.08);
  border-color: rgba(122,92,219,.2);
}
html.theme-light .hub-secondary {
  background: rgba(122,92,219,.04);
  border-color: rgba(122,92,219,.28);
  color: #4a3d8a;
}
html.theme-light .hub-secondary:hover {
  border-color: rgba(122,92,219,.45);
  background: rgba(122,92,219,.1);
}
html.theme-light .project-card.hub-card,
html.theme-light .hub-card {
  background: #ffffff;
  border-color: rgba(0,0,0,.1);
  box-shadow:
    0 10px 28px rgba(0,0,0,.06),
    0 1px 0 rgba(255,255,255,.9) inset;
}
html.theme-light .hub-card:hover,
html.theme-light .hub-card:focus-visible {
  border-color: rgba(122,92,219,.38);
  box-shadow:
    0 16px 40px rgba(40,28,70,.12),
    0 0 0 1px rgba(122,92,219,.1),
    0 0 24px rgba(122,92,219,.1);
}
html.theme-light .hub-card .project-stats span {
  background: rgba(122,92,219,.07);
  border-color: rgba(122,92,219,.16);
  color: var(--muted);
}
html.theme-light .hub-empty {
  border-color: rgba(122,92,219,.22);
  background:
    radial-gradient(420px 220px at 50% 30%, rgba(122,92,219,.08), transparent 65%),
    rgba(255,255,255,.7);
}
html.theme-light .hub-main-head .page-title {
  color: var(--text);
  opacity: 1;
}
html.theme-light .btn {
  border-color: var(--border);
}
html.theme-light .btn.primary {
  color: #fff;
}
/* Chat panel chrome (not bubble layout) */
html.theme-light #globalChat .chat-dock-panel,
html.theme-light .chat-dock-panel {
  background: rgba(255,255,255,.96);
  border-color: var(--border-soft);
  color: var(--text);
  box-shadow: 0 16px 48px rgba(40,28,70,.14);
}
html.theme-light .chat-fab {
  background: #6b5b95;
  color: #fff;
}
html.theme-light .tabs,
html.theme-light .top-chrome {
  background: rgba(255,255,255,.92);
  border-bottom-color: var(--border-soft);
}
html.theme-light .panel,
html.theme-light .main,
html.theme-light .workbench-shell {
  color: var(--text);
}
html.theme-light .tab.active {
  color: #1a1210;
}


/* ===== chatFit3: ONLY image bubbles shrink-wrap; text bubbles wrap normally ===== */
/* Text / default: restore natural bubble width (no width:0 / fit-content collapse) */
.chat-row {
  width: auto;
  max-width: min(92%, 560px);
}
.chat-row.mine {
  max-width: min(92%, 560px);
}
.chat-col {
  width: auto;
  max-width: 100%;
  min-width: 0;
}
.chat-bubble-wrap {
  width: auto;
  max-width: 100%;
}
.chat-msg, .chat-bubble {
  display: block;
  width: auto;
  max-width: min(92%, 420px);
  box-sizing: border-box;
}
.chat-meta {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 6px 8px;
  width: auto;
  max-width: 100%;
  box-sizing: border-box;
  overflow: visible;
}
.chat-meta .who {
  flex: 0 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.chat-meta .to-tag { flex: 0 1 auto; }
.chat-meta .when {
  flex: 0 0 auto;
  margin-left: auto;
}
.chat-bubble .body {
  width: auto;
  max-width: 100%;
  box-sizing: border-box;
  white-space: pre-wrap;
  word-break: break-word;
}

/* Image bubbles only: tighten to media width, kill hollow side gaps */
.chat-row.has-media {
  width: fit-content;
  max-width: min(92%, 420px);
}
.chat-row.has-media .chat-col,
.chat-row.has-media .chat-bubble-wrap {
  width: fit-content;
  max-width: 100%;
}
.chat-bubble.has-media,
.chat-msg.has-media {
  width: fit-content;
  max-width: min(92%, 400px);
}
.chat-bubble.has-media .chat-meta {
  /* fill bubble sized by image; do not apply to text-only */
  width: 0;
  min-width: 100%;
  overflow: hidden;
}
.chat-img-grid {
  width: fit-content;
  max-width: min(360px, 100%);
  margin: 0 !important;
}
.chat-row.mine .chat-img-grid { margin-left: 0 !important; }
.chat-album-cell {
  width: auto;
  max-width: 100%;
}
.chat-album-cell img,
.chat-msg-img {
  width: auto;
  max-width: min(360px, 100%);
  height: auto;
  display: block;
}
body.view-workbench.chat-wide .chat-row {
  max-width: min(88%, 560px);
}
body.view-workbench.chat-wide .chat-row.has-media {
  max-width: min(88%, 480px);
}

/* ===== headerFix3: tabs centered again; keep compact right chrome ===== */
.app-header {
  display: grid !important;
  grid-template-columns: auto minmax(0, 1fr) auto !important;
  align-items: center;
  gap: 10px;
  padding: 6px 14px !important;
  min-height: 0;
  flex-wrap: nowrap;
}
.app-header .brand {
  min-width: 0 !important;
  max-width: 220px;
  gap: 10px;
}
.app-header .brand-mark {
  width: 32px;
  height: 32px;
  border-radius: 10px;
}
.app-header .brand h1 {
  font-size: 15px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.app-header .brand .sub {
  font-size: 11px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.app-header .header-center {
  justify-self: center !important;
  justify-content: center !important;
  min-width: 0;
  overflow: hidden;
  display: flex;
  align-items: center;
  width: 100%;
}
.app-header .project-tabs,
.app-header .app-nav {
  justify-content: center !important;
  justify-self: center;
  margin: 0 auto;
}
.app-header .header-right {
  justify-self: end;
  display: flex !important;
  flex-direction: row !important;
  flex-wrap: nowrap !important;
  align-items: center;
  gap: 8px;
}
.app-header .header-right #projectChip { order: 1; flex: 0 1 auto; max-width: 160px; }
.app-header .header-right #btnThemeToggle { order: 2; flex: 0 0 auto; }
.app-header .header-right #btnProfile { order: 3; flex: 0 0 auto; }
.app-header .project-chip {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding: 5px 9px;
  font-size: 12px;
}
.app-header .theme-toggle-btn {
  width: 32px;
  height: 32px;
}
.app-header .profile-chip {
  padding: 3px 10px 3px 3px;
}
.app-header .avatar {
  width: 26px;
  height: 26px;
}

/* ===== noPipeLegend1: remove produce status legend row ===== */
.pipe-legend { display: none !important; }

/* ===== mobileSys1: no input zoom + full-screen chat + smaller @ chips ===== */
@media (max-width: 768px) {
  /* iOS: inputs <16px trigger page zoom */
  body.mobile .composer-shell textarea#chatInput,
  body.mobile #chatInput,
  body.mobile input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="file"]):not([type="hidden"]),
  body.mobile textarea,
  body.mobile select {
    font-size: 16px !important;
  }

  /* Open chat = full viewport; hide upper chrome to avoid keyboard crowding */
  body.mobile.mobile-msg-open .app-header,
  body.mobile.mobile-msg-open #view-home,
  body.mobile.mobile-msg-open #view-workbench {
    display: none !important;
  }
  body.mobile.mobile-msg-open #globalChat {
    top: 0 !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    height: 100dvh !important;
    max-height: none !important;
    z-index: 200;
    pointer-events: auto;
  }
  body.mobile.mobile-msg-open #globalChat.collapsed,
  body.mobile.mobile-msg-open #globalChat.open {
    width: 100% !important;
    max-width: none !important;
    height: 100dvh !important;
  }
  body.mobile.mobile-msg-open #globalChat .chat-dock-panel {
    display: flex !important;
    position: absolute !important;
    inset: 0 !important;
    width: 100% !important;
    height: 100% !important;
    max-height: none !important;
    border-radius: 0 !important;
    box-shadow: none;
  }
  body.mobile.mobile-msg-open #view-home,
  body.mobile.mobile-msg-open #view-workbench {
    padding-bottom: 0 !important;
  }

  /* Smaller @ mention chips; scroll horizontally instead of wrapping huge pills */
  body.mobile .mention-bar,
  body.mobile #mentionChips {
    flex-wrap: nowrap !important;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    gap: 4px !important;
    padding-bottom: 2px;
    scrollbar-width: none;
  }
  body.mobile .mention-bar::-webkit-scrollbar,
  body.mobile #mentionChips::-webkit-scrollbar { display: none; }
  body.mobile .mention-bar .chip,
  body.mobile #mentionChips .chip {
    flex: 0 0 auto;
    padding: 3px 8px !important;
    font-size: 11px !important;
    line-height: 1.25;
  }
}

/* ===== gapTypo1: refine gap filter chips (readable, calm) ===== */
.produce-gap-filters {
  display: inline-flex !important;
  flex-wrap: nowrap !important;
  align-items: center;
  gap: 0 !important;
  margin-left: auto;
  flex-shrink: 0;
  padding: 3px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,.08);
  background: rgba(255,255,255,.03);
}
.produce-sticky-bar .produce-gap-filters {
  margin-left: 8px;
}
button.pill.gap-filter,
.pill.gap-filter {
  margin: 0;
  border: 0 !important;
  border-radius: 999px;
  padding: 6px 12px !important;
  font-size: 12px !important;
  font-weight: 500;
  letter-spacing: 0.02em;
  line-height: 1.2;
  color: var(--muted) !important;
  background: transparent !important;
  box-shadow: none !important;
  filter: none !important;
  white-space: nowrap;
  cursor: pointer;
  transition: color .15s ease, background .15s ease;
}
button.pill.gap-filter:hover,
.pill.gap-filter:hover {
  color: #f0eef8 !important;
  background: rgba(255,255,255,.06) !important;
}
button.pill.gap-filter.active,
.pill.gap-filter.active {
  color: #efeaff !important;
  background: rgba(155, 123, 255, 0.22) !important;
  font-weight: 600;
  box-shadow: none !important;
  filter: none !important;
  border: 0 !important;
}
html.theme-light .produce-gap-filters {
  border-color: rgba(40, 30, 70, 0.1);
  background: rgba(40, 30, 70, 0.04);
}
html.theme-light button.pill.gap-filter,
html.theme-light .pill.gap-filter {
  color: #6a6480 !important;
}
html.theme-light button.pill.gap-filter:hover,
html.theme-light .pill.gap-filter:hover {
  color: #2a2440 !important;
  background: rgba(122, 92, 219, 0.08) !important;
}
html.theme-light button.pill.gap-filter.active,
html.theme-light .pill.gap-filter.active {
  color: #3b2f6b !important;
  background: rgba(122, 92, 219, 0.16) !important;
}

/* ===== chatAvatarTop1: avatar beside bubble top (not bottom) ===== */
.chat-row {
  align-items: flex-start !important;
}
.chat-row .chat-avatar {
  margin-top: 2px;
  align-self: flex-start;
}

/* ===== sysCenter1: system bubbles always centered ===== */
.chat-row.system {
  align-self: center !important;
  margin-left: auto !important;
  margin-right: auto !important;
  width: fit-content !important;
  max-width: min(92%, 420px) !important;
  justify-content: center;
}
.chat-row.system .chat-col,
.chat-row.system .chat-bubble-wrap {
  align-items: center;
  width: fit-content;
  max-width: 100%;
}
.chat-bubble.system,
.chat-bubble.system-msg {
  text-align: center;
  margin-left: auto;
  margin-right: auto;
}

/* ===== homeCenter1: true screen center for project hub ===== */
body.view-home .app-frame {
  min-height: 100vh;
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
body.view-home .app-header {
  flex-shrink: 0;
}
/* 「首页」对准屏幕水平中心（不受左右品牌/账号列挤压） */
body.view-home .app-header {
  position: relative;
}
body.view-home .app-header .header-center {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  justify-self: center;
  width: auto;
  max-width: min(70vw, 640px);
  z-index: 2;
  pointer-events: none;
}
body.view-home .app-header .header-center .app-nav,
body.view-home .app-header .header-center .app-nav-btn {
  pointer-events: auto;
}
body.view-home #view-home.view-hub {
  flex: 1 1 auto;
  min-height: 0;
  display: flex !important;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow: auto;
  padding: 24px 20px 40px;
  box-sizing: border-box;
}
body.view-home .hub-shell {
  width: 100%;
  max-width: 920px;
  margin: 0 auto;
  display: flex !important;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow: visible;
  height: auto;
}
body.view-home .hub-main {
  width: 100%;
  max-width: 920px;
  margin: 0 auto;
  padding: 0 !important;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  overflow: visible;
  background: transparent;
}
body.view-home .hub-hero {
  margin: 0 auto 28px !important;
  padding: 0 !important;
  width: 100%;
  max-width: 640px;
  text-align: center;
  align-items: center;
}
body.view-home .hub-main-head {
  width: 100%;
  max-width: 920px;
  text-align: center;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
}
body.view-home .hub-main-head > div {
  width: 100%;
  text-align: center;
}
body.view-home .project-grid.hub-grid,
body.view-home .hub-grid,
body.view-home .hub-empty {
  width: 100%;
  max-width: 920px;
  margin: 0 auto;
  justify-items: center;
}
body.view-home .project-grid.hub-grid:has(> :only-child) {
  display: flex;
  justify-content: center;
}
body.view-home .project-card.hub-card {
  width: min(100%, 560px);
  margin: 0 auto;
}
@media (max-width: 768px) {
  body.view-home #view-home.view-hub {
    justify-content: flex-start;
    padding-top: 28px;
  }
  body.view-home .app-header .header-center {
    position: static;
    transform: none;
    left: auto;
  }
}
/* ===== lightTheme2: premium light surfaces (no hub layout) ===== */
/* Hardcoded dark panels ignore CSS vars — override under html.theme-light only. */

html.theme-light .panel {
  background: rgba(255, 255, 255, 0.94);
  border-color: var(--border-soft);
  box-shadow: 0 10px 28px rgba(40, 28, 70, 0.06);
  color: var(--text);
}
html.theme-light .top-chrome,
html.theme-light .tabs {
  background: rgba(255, 255, 255, 0.94);
  border-bottom-color: var(--border-soft);
}
html.theme-light .tab {
  color: var(--muted);
}
html.theme-light .tab:hover {
  color: var(--text);
  background: rgba(122, 92, 219, 0.06);
}
html.theme-light .tab.active {
  color: #1a1210;
}
html.theme-light .btn {
  background: #fff;
  border-color: var(--border);
  color: var(--text);
}
html.theme-light .btn:hover {
  background: var(--panel2);
  border-color: rgba(122, 92, 219, 0.35);
}
html.theme-light .btn.ghost,
html.theme-light .btn.secondary {
  background: rgba(122, 92, 219, 0.04);
}
html.theme-light .seg {
  background: #f3f0f8;
  border-color: var(--border);
}
html.theme-light .seg button.active {
  background: #fff;
  color: var(--text);
  box-shadow: 0 1px 4px rgba(40, 28, 70, 0.08);
}
html.theme-light .workflow-strip .roles { color: var(--muted); }

/* Episode rail */
html.theme-light .ep-rail {
  background: #fff;
  border-color: var(--border);
  box-shadow: 0 8px 22px rgba(40, 28, 70, 0.06);
}
html.theme-light .ep-rail-item:hover {
  background: rgba(122, 92, 219, 0.06);
  color: var(--text);
}
html.theme-light .ep-rail-item.active {
  background: linear-gradient(135deg, rgba(122, 92, 219, 0.12), rgba(192, 112, 136, 0.08));
  border-color: rgba(122, 92, 219, 0.28);
  color: var(--text);
}

/* Produce sticky / toolbars */
html.theme-light .produce-sticky-bar,
html.theme-light .sticky-toolbar,
html.theme-light .produce-main .toolbar {
  background: rgba(255, 255, 255, 0.96) !important;
  border-bottom-color: var(--border-soft);
  backdrop-filter: blur(10px);
}

/* Cards — white/off-white (image voids stay dark below) */
html.theme-light .card,
html.theme-light .produce-card.card,
html.theme-light .pick-card,
html.theme-light .lib-card {
  background: linear-gradient(180deg, #ffffff, #f8f6fc);
  border-color: rgba(122, 92, 219, 0.14);
  box-shadow: 0 10px 28px rgba(40, 28, 70, 0.07);
  color: var(--text);
}
html.theme-light .card:hover,
html.theme-light .pick-card:hover,
html.theme-light .lib-card:hover {
  border-color: rgba(122, 92, 219, 0.32);
  transform: translateY(-1px);
}
html.theme-light .produce-card.selected-target {
  border-color: rgba(122, 92, 219, 0.45);
  box-shadow: 0 0 0 2px rgba(122, 92, 219, 0.12);
}

/* Drop zones / thumbs — soft light, not charcoal */
html.theme-light .dropzone,
html.theme-light .drop-zone {
  background: rgba(122, 92, 219, 0.03);
  border-color: rgba(122, 92, 219, 0.22);
  color: var(--muted);
}
html.theme-light .dropzone:hover,
html.theme-light .dropzone.dragover,
html.theme-light .drop-zone:hover,
html.theme-light .drop-zone.dragover {
  background: rgba(122, 92, 219, 0.08);
  border-color: rgba(122, 92, 219, 0.4);
  color: var(--text);
  box-shadow: inset 0 0 0 1px rgba(122, 92, 219, 0.15);
}
html.theme-light .thumb {
  background: #f3f0f8;
  border-color: var(--border);
}
html.theme-light .stage-slots.work-lanes {
  background: rgba(122, 92, 219, 0.04);
}
html.theme-light .stage-slots.work-lanes .zone:not(:first-child)::before {
  background: linear-gradient(180deg,
    rgba(122, 92, 219, 0),
    rgba(122, 92, 219, 0.35) 22%,
    rgba(184, 134, 74, 0.3) 50%,
    rgba(122, 92, 219, 0.35) 78%,
    rgba(122, 92, 219, 0));
}
html.theme-light .stage-dot.on {
  color: #3d2f78;
  border-color: rgba(122, 92, 219, 0.4);
  background: rgba(122, 92, 219, 0.1);
}
html.theme-light .stage-dot.done {
  color: #1a7a4a;
  border-color: rgba(42, 159, 106, 0.45);
  background: rgba(42, 159, 106, 0.1);
}
html.theme-light .completeness {
  background: rgba(122, 92, 219, 0.06);
  border-color: rgba(122, 92, 219, 0.22);
}
html.theme-light .ring-bg { stroke: rgba(40, 28, 70, 0.1); }
html.theme-light .wf-steps span {
  color: var(--text);
  background: rgba(122, 92, 219, 0.06);
  border-color: rgba(122, 92, 219, 0.16);
}

/* Preview empty slots: light placeholders (images keep their own pixels) */
html.theme-light .char-main-preview,
html.theme-light .pick-card .preview,
html.theme-light .lib-card .preview {
  background: #efeaf8 !important;
  border-color: rgba(122, 92, 219, 0.22) !important;
  color: #4a4a58 !important;
}
html.theme-light .char-main-preview .empty-preview,
html.theme-light .hero-slot-empty {
  color: #4a4a58 !important;
}
html.theme-light .hero-slot {
  background: #efeaf8 !important;
  border-color: rgba(122, 92, 219, 0.3) !important;
}
html.theme-light .hero-slot.has-img {
  background: #efeaf8 !important;
}
html.theme-light .hero-slot img,
html.theme-light .thumb img,
html.theme-light .thumb video,
html.theme-light .char-main-preview img,
html.theme-light .pick-card .preview img,
html.theme-light .lib-card .preview img {
  background: transparent !important;
}
html.theme-light .hero-slot-label {
  background: rgba(255, 255, 255, 0.92) !important;
  color: #4a4a58 !important;
}
html.theme-light .char-thumbs button {
  background: #efeaf8 !important;
  border-color: var(--border) !important;
}

/* Pills */
html.theme-light .pill.need_ref {
  color: #5a5470;
  background: rgba(40, 28, 70, 0.04);
  border-color: rgba(40, 28, 70, 0.12);
}
html.theme-light .pill.in_design {
  color: #8a5a1a;
  background: rgba(212, 165, 116, 0.14);
  border-color: rgba(184, 134, 74, 0.4);
}
html.theme-light .pill.pending_pick {
  color: #9a5a12;
  background: rgba(240, 160, 75, 0.12);
  border-color: rgba(212, 140, 50, 0.4);
}
html.theme-light .pill.picked {
  color: #3d2f78;
  background: rgba(122, 92, 219, 0.1);
  border-color: rgba(122, 92, 219, 0.35);
}
html.theme-light .pill.merged {
  color: #3d2f78;
  background: rgba(122, 92, 219, 0.16);
  border-color: rgba(122, 92, 219, 0.45);
}
html.theme-light .pill.locked {
  color: #1a7a4a;
  background: rgba(42, 159, 106, 0.1);
  border-color: rgba(42, 159, 106, 0.4);
}
html.theme-light .badge.wait {
  color: #9a5a12;
  border-color: rgba(212, 140, 50, 0.4);
  background: rgba(240, 160, 75, 0.1);
}

/* Range / progress tracks */
html.theme-light input[type="range"],
html.theme-light input[type="range"]::-webkit-slider-runnable-track,
html.theme-light input[type="range"]::-moz-range-track,
html.theme-light progress,
html.theme-light progress::-webkit-progress-bar {
  background: #ddd6ea;
}
html.theme-light .chat-resize-handle::before {
  background: rgba(40, 28, 70, 0.18);
}

/* ===== Chat panel (light) ===== */
html.theme-light #globalChat .chat-dock-panel,
html.theme-light .chat-dock-panel,
html.theme-light .chat-dock-panel.produce-chat,
html.theme-light .global-chat-panel.produce-chat {
  background: linear-gradient(180deg, #ffffff, #f6f4fa) !important;
  border-color: var(--border-soft) !important;
  border-left-color: var(--border) !important;
  color: var(--text);
  box-shadow: -10px 0 32px rgba(40, 28, 70, 0.1);
}
html.theme-light .chat-head,
html.theme-light .chat-dock-panel .chat-head {
  background: linear-gradient(180deg, rgba(122, 92, 219, 0.06), transparent);
  border-bottom-color: var(--border-soft);
}
html.theme-light .chat-messages {
  background: #f0edf5 !important;
}
html.theme-light .chat-msg,
html.theme-light .chat-bubble {
  background: #ffffff;
  border-color: rgba(40, 28, 70, 0.1);
  color: var(--text);
  box-shadow: 0 2px 8px rgba(40, 28, 70, 0.05);
}
html.theme-light .chat-bubble.theirs {
  background: #f4f2f8;
  border-color: rgba(40, 28, 70, 0.1);
  color: var(--text);
}
html.theme-light .chat-bubble.mine {
  background: linear-gradient(160deg, #efe8ff, #e4d9ff);
  border-color: rgba(122, 92, 219, 0.35);
  color: #2a2440;
}
html.theme-light .chat-bubble.mine .who { color: #5a4a9a; }
html.theme-light .chat-msg .who,
html.theme-light .chat-bubble .who { color: #a05068; }
html.theme-light .chat-msg .when,
html.theme-light .chat-bubble .when { color: var(--muted); }
html.theme-light .chat-msg .body,
html.theme-light .chat-bubble .body { color: inherit; }
html.theme-light .chat-avatar {
  background: #e8e2f4;
  border-color: rgba(40, 28, 70, 0.12);
}
html.theme-light .chat-bubble.for-me,
html.theme-light .chat-msg.for-me {
  border-color: rgba(122, 92, 219, 0.45);
}
html.theme-light .chat-row.mention .chat-bubble {
  box-shadow: inset 3px 0 0 #7a5cdb, 0 2px 8px rgba(40, 28, 70, 0.05);
}

/* System bubbles: light tint + readable; row stays centered via sysCenter */
html.theme-light .chat-bubble.system-msg,
html.theme-light .chat-msg.system-msg {
  background: #ffffff;
  border: 1px dashed rgba(40, 28, 70, 0.28);
  border-left: 1px dashed rgba(40, 28, 70, 0.28);
  color: #1a1a22;
  opacity: 1;
  box-shadow: none;
}
html.theme-light .chat-bubble.system-msg.sys-ok {
  background: #ffffff;
  border: 1px dashed rgba(40, 28, 70, 0.28);
  color: #1a7a45;
}
html.theme-light .chat-bubble.system-msg.sys-err {
  background: #ffffff;
  border: 1px dashed rgba(40, 28, 70, 0.28);
  color: #c0392b;
}
html.theme-light .chat-bubble.system-msg.sys-info {
  background: #ffffff;
  border: 1px dashed rgba(40, 28, 70, 0.28);
  color: #1a1a22;
}

/* Composer + mention chips */
html.theme-light .composer-shell {
  background: #ffffff;
  border-color: rgba(40, 28, 70, 0.12);
  box-shadow: 0 2px 10px rgba(40, 28, 70, 0.05);
}
html.theme-light .composer-shell:focus-within {
  border-color: rgba(122, 92, 219, 0.45);
  box-shadow: 0 0 0 2px rgba(122, 92, 219, 0.12);
}
html.theme-light .composer-shell textarea#chatInput {
  color: var(--text);
}
html.theme-light .composer-shell textarea#chatInput::placeholder {
  color: rgba(40, 28, 70, 0.35);
}
html.theme-light .icon-btn {
  color: rgba(40, 28, 70, 0.45);
}
html.theme-light .icon-btn:hover {
  background: rgba(122, 92, 219, 0.08);
  color: #3d2f78;
}
html.theme-light .icon-btn.send {
  background: rgba(122, 92, 219, 0.14);
  color: #4a3d8a;
}
html.theme-light .icon-btn.send:hover {
  background: rgba(122, 92, 219, 0.28);
  color: #2a2440;
}
html.theme-light .mention-bar .chip,
html.theme-light .mention-chips .chip {
  background: #fff;
  border-color: var(--border);
  color: var(--muted);
}
html.theme-light .mention-bar .chip:hover,
html.theme-light .mention-chips .chip:hover {
  color: #3d2f78;
  border-color: rgba(122, 92, 219, 0.4);
  background: rgba(122, 92, 219, 0.06);
}
html.theme-light .mention-bar .chip.active,
html.theme-light .mention-chips .chip.active {
  color: #3d2f78;
  border-color: rgba(122, 92, 219, 0.45);
  background: rgba(122, 92, 219, 0.12);
}
html.theme-light .chat-pending .pending-file,
html.theme-light .chat-file {
  background: rgba(122, 92, 219, 0.05);
  border-color: var(--border-soft);
  color: var(--accent-strong);
}
html.theme-light .chat-hover-bar {
  background: rgba(255, 255, 255, 0.96);
  border-color: var(--border);
  box-shadow: 0 6px 18px rgba(40, 28, 70, 0.1);
}
html.theme-light .chat-hover-bar button {
  color: var(--text);
}
html.theme-light .chat-hover-bar button:hover {
  background: rgba(122, 92, 219, 0.1);
}
html.theme-light .chat-quote-in {
  background: rgba(40, 28, 70, 0.04);
  border-left-color: rgba(122, 92, 219, 0.4);
  color: var(--muted);
}
html.theme-light .chat-readers {
  color: var(--muted);
}
html.theme-light .chat-recall-tip {
  color: var(--muted);
}
html.theme-light .ctx-menu {
  background: #fff;
  border-color: var(--border);
  box-shadow: 0 12px 32px rgba(40, 28, 70, 0.14);
}
html.theme-light .ctx-menu button:hover {
  background: rgba(122, 92, 219, 0.08);
}

/* Modals */
html.theme-light .modal-mask {
  background: rgba(30, 24, 50, 0.35);
}
html.theme-light .modal {
  background: #fff;
  border-color: var(--border);
  color: var(--text);
  box-shadow: 0 20px 50px rgba(40, 28, 70, 0.18);
}

/* Scrubber */
html.theme-light .asset-scrubber {
  background: rgba(255, 255, 255, 0.92);
  border-color: var(--border-soft);
}
html.theme-light .scrub-tick {
  background: rgba(40, 28, 70, 0.12);
}
html.theme-light .scrub-tick.hot {
  background: rgba(122, 92, 219, 0.55);
}

/* Scrollbars */
html.theme-light *::-webkit-scrollbar-thumb {
  background: rgba(40, 28, 70, 0.18);
}
html.theme-light *::-webkit-scrollbar-thumb:hover {
  background: rgba(40, 28, 70, 0.3);
}

/* Reinforce system row centering after chatFit / avatar patches */
html.theme-light .chat-row.system,
.chat-row.system {
  align-self: center !important;
  margin-left: auto !important;
  margin-right: auto !important;
  width: fit-content !important;
  max-width: min(92%, 420px) !important;
  justify-content: center !important;
  flex-direction: row !important;
}
.chat-row.system .chat-col,
.chat-row.system .chat-bubble-wrap {
  align-items: center !important;
  margin-left: auto;
  margin-right: auto;
}

/* ===== mobileChat1: phone chat column align + system bubble cap ===== */
@media (max-width: 768px) {
  body.mobile {
    /* row shelf = 85%; bubble lane ≈ 85% - avatar ≈ 78% (shared with system) */
    --m-chat-row-max: 85%;
    --m-chat-bubble-max: 78%;
    --m-chat-avatar-slot: 42px; /* 34px avatar + 8px gap */
  }

  body.mobile .chat-messages {
    padding: 10px 12px calc(10px + env(safe-area-inset-bottom, 0px));
    gap: 10px;
  }

  /* —— Mine / theirs: full shelf width so alignment edges are a straight line —— */
  body.mobile .chat-row.mine,
  body.mobile .chat-row.theirs {
    width: 100% !important;
    max-width: var(--m-chat-row-max) !important;
    box-sizing: border-box;
    gap: 8px;
  }
  body.mobile .chat-row.mine {
    align-self: flex-end !important;
    flex-direction: row-reverse !important;
    justify-content: flex-start !important; /* pack from right with row-reverse */
    margin-left: auto;
    margin-right: 0;
  }
  body.mobile .chat-row.theirs {
    align-self: flex-start !important;
    flex-direction: row !important;
    justify-content: flex-start !important; /* pack from left */
    margin-left: 0;
    margin-right: auto;
  }

  body.mobile .chat-row .chat-avatar {
    width: 34px;
    height: 34px;
    flex: 0 0 34px;
    margin-top: 2px;
    align-self: flex-start;
  }

  body.mobile .chat-row.mine .chat-col,
  body.mobile .chat-row.theirs .chat-col {
    flex: 0 1 auto;
    min-width: 0;
    max-width: calc(100% - var(--m-chat-avatar-slot));
    width: auto;
  }
  body.mobile .chat-row.mine .chat-col {
    align-items: flex-end !important;
  }
  body.mobile .chat-row.theirs .chat-col {
    align-items: flex-start !important;
  }

  /* Bubbles stay fit-content; alignment edge comes from the row shelf */
  body.mobile .chat-row.mine .chat-bubble-wrap,
  body.mobile .chat-row.theirs .chat-bubble-wrap {
    width: fit-content;
    max-width: 100%;
    margin: 0;
  }
  body.mobile .chat-row.mine .chat-msg,
  body.mobile .chat-row.mine .chat-bubble,
  body.mobile .chat-row.theirs .chat-msg,
  body.mobile .chat-row.theirs .chat-bubble {
    display: block;
    width: fit-content !important;
    max-width: 100% !important;
    box-sizing: border-box;
  }

  /* Image rows: shrink-wrap but keep same edge via align-self */
  body.mobile .chat-row.mine.has-media,
  body.mobile .chat-row.theirs.has-media {
    width: fit-content !important;
    max-width: var(--m-chat-row-max) !important;
  }
  body.mobile .chat-row.mine.has-media {
    margin-left: auto;
  }
  body.mobile .chat-row.theirs.has-media {
    margin-right: auto;
  }

  /* —— System: centered, never wider than ordinary bubble lane —— */
  body.mobile .chat-row.system {
    align-self: center !important;
    justify-content: center !important;
    flex-direction: row !important;
    width: fit-content !important;
    max-width: var(--m-chat-bubble-max) !important; /* ≤ mine/theirs bubble, not 通栏 */
    margin-left: auto !important;
    margin-right: auto !important;
  }
  body.mobile .chat-row.system .chat-col,
  body.mobile .chat-row.system .chat-bubble-wrap {
    align-items: center !important;
    width: fit-content !important;
    max-width: 100% !important;
    margin-left: auto !important;
    margin-right: auto !important;
  }
  body.mobile .chat-row.system .chat-msg,
  body.mobile .chat-row.system .chat-bubble,
  body.mobile .chat-row.system .chat-bubble.system-msg {
    width: fit-content !important;
    max-width: 100% !important;
    margin-left: auto;
    margin-right: auto;
    text-align: center;
    box-sizing: border-box;
  }

  /* Filters / compose polish on small screens */
  body.mobile .chat-filters.seg {
    gap: 4px;
    padding: 4px;
  }
  body.mobile .chat-filters.seg button {
    font-size: 11px;
    padding: 5px 9px;
  }
  body.mobile .chat-compose {
    padding: 8px 10px calc(8px + env(safe-area-inset-bottom, 0px));
    gap: 6px;
  }
  body.mobile .composer-shell {
    gap: 6px;
  }
}

/* ===== mobileHome1: unify mobile hub to light/center style; hide guide pane ===== */
/* Fix light-theme primary CTA: .btn { background:#fff } was washing out .primary */
html.theme-light .btn.primary,
html.theme-light button.btn.primary,
html.theme-light .hub-cta.btn.primary,
html.theme-light #btnNewProject,
html.theme-light #btnNewProjectEmpty {
  background: linear-gradient(135deg, #7a5cdb, #c07088) !important;
  color: #fff !important;
  border-color: transparent !important;
  box-shadow: 0 4px 16px rgba(122, 92, 219, 0.32);
  text-shadow: none;
}
html.theme-light .btn.primary:hover,
html.theme-light .hub-cta.btn.primary:hover,
html.theme-light #btnNewProject:hover,
html.theme-light #btnNewProjectEmpty:hover {
  filter: brightness(1.06);
  color: #fff !important;
}

@media (max-width: 768px) {
  /* Never show the dark lower guide pane on mobile */
  body.mobile #mobileHomePane,
  body.mobile:not(.mobile-msg-open) #mobileHomePane,
  #mobileHomePane.mobile-home-pane {
    display: none !important;
    visibility: hidden !important;
    pointer-events: none !important;
    height: 0 !important;
    overflow: hidden !important;
  }

  /* Home: reclaim full viewport under header; true vertical+horizontal center */
  body.mobile.view-home #view-home,
  body.mobile.view-home #view-home.view-hub {
    flex: 1 1 auto !important;
    min-height: 0 !important;
    height: auto !important;
    padding-top: 0 !important;
    padding-bottom: 0 !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    overflow: auto !important;
    -webkit-overflow-scrolling: touch;
    background: transparent;
  }

  body.mobile.view-home .hub-shell {
    width: 100% !important;
    max-width: 560px;
    margin: 0 auto;
    padding: 20px 18px calc(88px + env(safe-area-inset-bottom, 0px)) !important;
    box-sizing: border-box;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    min-height: 100%;
    grid-template-columns: 1fr !important;
    background: transparent !important;
  }

  body.mobile.view-home .hub-main {
    width: 100% !important;
    max-width: 520px !important;
    margin: 0 auto !important;
    padding: 0 !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 10px !important;
    background: transparent !important;
  }

  body.mobile.view-home .hub-hero {
    width: 100% !important;
    max-width: 440px !important;
    margin: 0 auto 18px !important;
    padding: 0 !important;
    text-align: center !important;
    align-items: center !important;
  }

  body.mobile.view-home .hub-hero-actions {
    width: 100%;
    justify-content: center;
    gap: 10px;
  }
  body.mobile.view-home .hub-hero-actions .hub-cta,
  body.mobile.view-home .hub-hero-actions .hub-secondary {
    flex: 1 1 0;
    min-width: 0;
    max-width: 168px;
  }

  body.mobile.view-home .hub-main-head {
    width: 100%;
    max-width: 520px;
    margin: 0 auto 12px !important;
    text-align: center;
  }
  body.mobile.view-home .hub-main-head .muted {
    display: none; /* keep title only; less clutter on phone */
  }

  body.mobile.view-home .project-grid.hub-grid,
  body.mobile.view-home .hub-grid,
  body.mobile.view-home .hub-empty {
    width: 100% !important;
    max-width: 520px !important;
    margin: 0 auto !important;
  }
  body.mobile.view-home .project-card.hub-card {
    width: 100% !important;
    max-width: 520px !important;
  }

  /* Override homeCenter1 mobile flex-start */
  body.mobile.view-home #view-home.view-hub {
    justify-content: center !important;
    padding-top: 0 !important;
  }
  body.mobile.view-home .app-header .header-center {
    position: static;
    transform: none;
    left: auto;
  }

  /* cardDiscuss1: home discuss moved onto project cards; hide global FAB on home */
  body.mobile.view-home:not(.mobile-msg-open) #globalChat {
    height: 0 !important;
    max-height: none;
    pointer-events: none;
    background: transparent !important;
    border: none !important;
  }
  body.mobile.view-home:not(.mobile-msg-open) #globalChat .chat-dock-panel,
  body.mobile.view-home:not(.mobile-msg-open) #globalChat .chat-resize-handle {
    display: none !important;
  }
  body.mobile.view-home:not(.mobile-msg-open) #globalChat .chat-fab {
    display: none !important;
  }
}


/* ===== lightTheme3: kill black blocks + force readable dark text ===== */
/* Scope: html.theme-light only. Do not touch hub layout / mobileChat alignment. */

html.theme-light {
  --text: #1a1a22;
  --muted: #4a4a58;
}

/* —— Global chrome: no charcoal bars —— */
html.theme-light .app-header {
  background: rgba(255, 255, 255, 0.96) !important;
  border-bottom-color: rgba(40, 28, 70, 0.1) !important;
  color: var(--text);
  box-shadow: 0 1px 0 rgba(255,255,255,.9), 0 4px 18px rgba(40,28,70,.06);
}
html.theme-light .app-nav-btn {
  color: #4a4a58 !important;
}
html.theme-light .app-nav-btn:hover {
  color: #1a1a22 !important;
  background: rgba(122, 92, 219, 0.08) !important;
}
html.theme-light .app-nav-btn.active {
  color: #3d2f78 !important;
  background: rgba(122, 92, 219, 0.14) !important;
  border-color: rgba(122, 92, 219, 0.3) !important;
}
html.theme-light .brand .sub,
html.theme-light .muted {
  color: #4a4a58 !important;
}
html.theme-light .top-chrome,
html.theme-light .tabs,
html.theme-light .sticky-toolbar,
html.theme-light .produce-sticky-bar,
html.theme-light .produce-main .toolbar,
html.theme-light .panel-script .script-toolbar {
  background: rgba(255, 255, 255, 0.96) !important;
  border-bottom-color: rgba(40, 28, 70, 0.1) !important;
  color: var(--text);
}
html.theme-light .panel,
html.theme-light .main,
html.theme-light .workbench-shell,
html.theme-light .workbench-shell > .main .panel {
  background: #f7f5fb !important;
  color: var(--text) !important;
  border-color: rgba(40, 28, 70, 0.1);
}
html.theme-light .script-font-ctrl {
  background: rgba(122, 92, 219, 0.06) !important;
  border-color: rgba(122, 92, 219, 0.18) !important;
  color: #4a4a58 !important;
}
html.theme-light .btn {
  background: #fff !important;
  border-color: #d5cee6 !important;
  color: #1a1a22 !important;
}
html.theme-light .btn:hover {
  background: #f3effa !important;
  border-color: rgba(122, 92, 219, 0.4) !important;
}
html.theme-light .btn.primary,
html.theme-light .btn.primary:hover {
  color: #fff !important;
  background: linear-gradient(135deg, #7a5cdb, #c07088) !important;
  border-color: transparent !important;
}
html.theme-light .btn.ghost,
html.theme-light .btn.secondary {
  background: rgba(122, 92, 219, 0.05) !important;
  color: #3d2f78 !important;
}
html.theme-light .seg {
  background: #efeaf8 !important;
  border-color: #d5cee6 !important;
}
html.theme-light .seg button {
  color: #4a4a58 !important;
}
html.theme-light .seg button:hover {
  color: #1a1a22 !important;
  background: rgba(122, 92, 219, 0.08) !important;
}
html.theme-light .seg button.active {
  background: #fff !important;
  color: #1a1a22 !important;
  box-shadow: 0 1px 4px rgba(40, 28, 70, 0.1);
}

/* —— Script reader: dark text on light paper —— */
html.theme-light .script-toc,
html.theme-light .script-reader-card,
html.theme-light .script-editor-card,
html.theme-light .script-result-card,
html.theme-light .panel-script .script-result-card {
  background: #ffffff !important;
  border-color: rgba(40, 28, 70, 0.1) !important;
  color: #1a1a22 !important;
  box-shadow: 0 8px 24px rgba(40, 28, 70, 0.05);
}
html.theme-light .script-toc-head,
html.theme-light .section-label {
  color: #4a4a58 !important;
  border-bottom-color: rgba(40, 28, 70, 0.1) !important;
}
html.theme-light .script-toc-ep,
html.theme-light .script-toc-scene {
  color: #1a1a22 !important;
}
html.theme-light .script-toc-ep:hover,
html.theme-light .script-toc-scene:hover {
  background: rgba(122, 92, 219, 0.06) !important;
  border-color: rgba(122, 92, 219, 0.2) !important;
}
html.theme-light .script-toc-ep.active {
  background: rgba(184, 134, 74, 0.12) !important;
  border-color: rgba(184, 134, 74, 0.35) !important;
}
html.theme-light .script-toc-scene.active {
  background: rgba(122, 92, 219, 0.12) !important;
  border-color: rgba(122, 92, 219, 0.35) !important;
}
html.theme-light .script-toc-ep .ep-num {
  color: #7a5a28 !important;
}
html.theme-light .script-toc-scene .sc-code {
  color: #5a4a9a !important;
}
html.theme-light .script-toc-ep .ep-title,
html.theme-light .script-toc-scene .sc-loc,
html.theme-light .script-toc-empty {
  color: #4a4a58 !important;
}
html.theme-light .script-reader-head {
  background: linear-gradient(180deg, rgba(122, 92, 219, 0.06), transparent) !important;
  border-bottom-color: rgba(40, 28, 70, 0.1) !important;
}
html.theme-light .script-show-title {
  color: #1a1a22 !important;
}
html.theme-light .script-ep-title {
  color: #7a5a28 !important;
}
html.theme-light .script-color-legend {
  background: #f7f5fb !important;
  border-bottom-color: rgba(40, 28, 70, 0.1) !important;
}
html.theme-light .script-color-legend .leg-item {
  color: #4a4a58 !important;
}
html.theme-light .script-reader,
html.theme-light .script-edit-wrap textarea,
html.theme-light .script-box {
  background: #ffffff !important;
  color: #1a1a22 !important;
  border-color: rgba(40, 28, 70, 0.12) !important;
}
html.theme-light .sf-show-title { color: #1a1a22 !important; }
html.theme-light .sf-ep-heading {
  color: #5a4a3a !important;
  border-bottom-color: rgba(40, 28, 70, 0.1) !important;
}
html.theme-light .sf-scene {
  border-bottom-color: rgba(40, 28, 70, 0.08) !important;
}
html.theme-light .sf-scene-title {
  color: #2a2440 !important;
  border-left-color: rgba(184, 134, 74, 0.55) !important;
}
html.theme-light .sf-cast,
html.theme-light .sf-cast-list,
html.theme-light .sf-label,
html.theme-light .sf-scene-note,
html.theme-light .sf-action {
  color: #4a4a58 !important;
}
html.theme-light .sf-dialogue,
html.theme-light .sf-line,
html.theme-light .sf-body {
  color: #1a1a22 !important;
}
html.theme-light .sf-char {
  color: #6a4a1a !important;
}
html.theme-light .sf-colon { color: #6a6480 !important; }
html.theme-light .sf-scene-code { color: #6a5a40 !important; }
html.theme-light .sf-scene-note {
  border-left-color: rgba(90, 140, 200, 0.4) !important;
}

/* Script marks: dark saturated text on soft tint (readable on white) */
html.theme-light .sf-mark-character {
  color: #0a6a8a !important;
  background: rgba(56, 190, 255, 0.18) !important;
  box-shadow: inset 0 -2px 0 rgba(20, 140, 190, 0.85) !important;
}
html.theme-light .sf-mark-scene {
  color: #0a6a3a !important;
  background: rgba(56, 210, 130, 0.16) !important;
  box-shadow: inset 0 -2px 0 rgba(30, 160, 90, 0.85) !important;
}
html.theme-light .sf-mark-prop {
  color: #8a5a08 !important;
  background: rgba(255, 186, 72, 0.2) !important;
  box-shadow: inset 0 -2px 0 rgba(200, 140, 30, 0.9) !important;
}
html.theme-light .sf-mark-speaker {
  box-shadow: inset 0 -1.5px 0 rgba(20, 140, 190, 0.55) !important;
}
html.theme-light .sf-first-badge {
  color: #0a5a6a !important;
  background: rgba(70, 180, 200, 0.14) !important;
  border-color: rgba(40, 140, 160, 0.35) !important;
}
html.theme-light .script-split-handle::after {
  background: rgba(122, 92, 219, 0.25) !important;
}
html.theme-light .script-drop {
  background: #f7f5fb !important;
  border-color: rgba(122, 92, 219, 0.22) !important;
  color: #1a1a22 !important;
}
html.theme-light .script-drop-icon {
  background: rgba(122, 92, 219, 0.08) !important;
  border-color: rgba(122, 92, 219, 0.2) !important;
}
html.theme-light .script-drop-title { color: #1a1a22 !important; }
html.theme-light .script-drop-hint { color: #4a4a58 !important; }

/* —— Analysis / asset rows: light cards, not black blocks —— */
html.theme-light .asset-row,
html.theme-light .asset-row.compact {
  background: #ffffff !important;
  border-color: rgba(40, 28, 70, 0.12) !important;
  color: #1a1a22 !important;
  box-shadow: 0 2px 8px rgba(40, 28, 70, 0.04);
}
html.theme-light .asset-row:hover {
  border-color: rgba(122, 92, 219, 0.35) !important;
}
html.theme-light .asset-row h4 {
  color: #1a1a22 !important;
}
html.theme-light .asset-row .muted,
html.theme-light .asset-row .muted.one-line {
  color: #4a4a58 !important;
}
html.theme-light .asset-portrait,
html.theme-light .asset-state {
  color: #3a3a48 !important;
}
html.theme-light .ap-k {
  color: #4a3d8a !important;
  background: rgba(122, 92, 219, 0.12) !important;
  border-color: rgba(122, 92, 219, 0.3) !important;
}
html.theme-light .asset-state .ap-k {
  color: #8a5a12 !important;
  background: rgba(240, 160, 75, 0.14) !important;
  border-color: rgba(212, 140, 50, 0.4) !important;
}
html.theme-light .asset-group-label {
  color: #4a4a58 !important;
}
html.theme-light .badge {
  color: #3a3a48 !important;
  border-color: rgba(40, 28, 70, 0.16) !important;
  background: rgba(40, 28, 70, 0.04) !important;
}

/* —— Produce cards / zones / empty previews: light surfaces —— */
html.theme-light .card,
html.theme-light .produce-card,
html.theme-light .produce-card.card,
html.theme-light .pick-card,
html.theme-light .lib-card {
  background: linear-gradient(180deg, #ffffff, #f8f6fc) !important;
  border-color: rgba(122, 92, 219, 0.16) !important;
  color: #1a1a22 !important;
  box-shadow: 0 10px 28px rgba(40, 28, 70, 0.06);
}
html.theme-light .produce-card .card-head h3,
html.theme-light .produce-card h3,
html.theme-light .card h3 {
  color: #1a1a22 !important;
  text-shadow: none !important;
}
html.theme-light .dropzone,
html.theme-light .drop-zone,
html.theme-light .stage-slots .drop-zone {
  background: rgba(122, 92, 219, 0.04) !important;
  border-color: rgba(122, 92, 219, 0.28) !important;
  border-style: dashed !important;
  color: #4a4a58 !important;
}
html.theme-light .dropzone:hover,
html.theme-light .dropzone.dragover,
html.theme-light .drop-zone:hover,
html.theme-light .drop-zone.dragover {
  background: rgba(122, 92, 219, 0.1) !important;
  border-color: rgba(122, 92, 219, 0.45) !important;
  color: #1a1a22 !important;
}
html.theme-light .thumb {
  background: #efeaf8 !important;
  border-color: rgba(122, 92, 219, 0.2) !important;
  color: #1a1a22 !important;
}
html.theme-light .thumb .cap { color: #4a4a58 !important; }
html.theme-light .thumb img,
html.theme-light .thumb video {
  background: #e8e2f4 !important;
}

/* Ref / costume / face lanes — light washes, kill charcoal !important gradients */
html.theme-light .stage-slots.work-lanes {
  background: rgba(122, 92, 219, 0.05) !important;
  border: 1px solid rgba(122, 92, 219, 0.12);
}
html.theme-light .stage-slots.work-lanes .zone[data-slot="ref"],
html.theme-light .stage-slots.work-lanes .zone[data-slot="costume"],
html.theme-light .stage-slots.work-lanes .zone[data-slot="face"],
html.theme-light .stage-slots.work-lanes .zone {
  background: linear-gradient(180deg, rgba(255,255,255,0.95), rgba(244,240,252,0.92)) !important;
  color: #1a1a22 !important;
}
html.theme-light .stage-slots.work-lanes .zone[data-slot="ref"] {
  background: linear-gradient(180deg, rgba(122, 92, 219, 0.08), rgba(255,255,255,0.9) 55%) !important;
}
html.theme-light .stage-slots.work-lanes .zone[data-slot="costume"] {
  background: linear-gradient(180deg, rgba(192, 112, 136, 0.08), rgba(255,255,255,0.9) 55%) !important;
}
html.theme-light .stage-slots.work-lanes .zone[data-slot="face"] {
  background: linear-gradient(180deg, rgba(58, 143, 208, 0.08), rgba(255,255,255,0.9) 55%) !important;
}
html.theme-light .zone-title,
html.theme-light .upload-tile-cap,
html.theme-light .drop-copy {
  color: #4a4a58 !important;
}
html.theme-light .char-main-preview,
html.theme-light .pick-card .preview,
html.theme-light .lib-card .preview,
html.theme-light .hero-slot {
  background: #efeaf8 !important;
  border: 1px dashed rgba(122, 92, 219, 0.32) !important;
  color: #4a4a58 !important;
}
html.theme-light .hero-slot.has-img,
html.theme-light .char-main-preview:has(img) {
  border-style: solid !important;
  background: #f3effa !important;
}
html.theme-light .upload-tile,
html.theme-light .thumb-more,
html.theme-light .plus {
  background: rgba(122, 92, 219, 0.06) !important;
  color: #4a3d8a !important;
  border-color: rgba(122, 92, 219, 0.25) !important;
}
html.theme-light .ep-rail {
  background: #ffffff !important;
  border-color: rgba(40, 28, 70, 0.1) !important;
  color: #1a1a22 !important;
}
html.theme-light .ep-rail-item {
  color: #1a1a22 !important;
}
html.theme-light .ep-rail-item:hover {
  background: rgba(122, 92, 219, 0.06) !important;
}
html.theme-light .ep-rail-item.active {
  background: linear-gradient(135deg, rgba(122, 92, 219, 0.14), rgba(192, 112, 136, 0.08)) !important;
  color: #1a1a22 !important;
}
html.theme-light .workflow-strip {
  background: #f7f5fb !important;
  border-color: rgba(40, 28, 70, 0.1) !important;
  color: #4a4a58 !important;
}

/* —— Chat panel: full light chrome —— */
html.theme-light #globalChat .chat-dock-panel,
html.theme-light .chat-dock-panel,
html.theme-light .chat-dock-panel.produce-chat,
html.theme-light .global-chat-panel.produce-chat {
  background: linear-gradient(180deg, #ffffff, #f6f4fa) !important;
  border-color: rgba(40, 28, 70, 0.1) !important;
  border-left-color: rgba(40, 28, 70, 0.12) !important;
  color: #1a1a22 !important;
  box-shadow: -10px 0 32px rgba(40, 28, 70, 0.08);
}
html.theme-light .chat-head,
html.theme-light .chat-dock-panel .chat-head {
  background: linear-gradient(180deg, rgba(122, 92, 219, 0.07), #ffffff) !important;
  border-bottom-color: rgba(40, 28, 70, 0.1) !important;
  color: #1a1a22 !important;
}
html.theme-light .chat-title {
  color: #5a4a9a !important;
}
html.theme-light .chat-messages,
html.theme-light .chat-msg-stage {
  background: #f0edf5 !important;
}
html.theme-light .chat-compose {
  background: #ffffff !important;
  border-top-color: rgba(40, 28, 70, 0.1) !important;
  color: #1a1a22 !important;
}
html.theme-light .composer-shell {
  background: #ffffff !important;
  border-color: rgba(40, 28, 70, 0.14) !important;
  box-shadow: 0 2px 10px rgba(40, 28, 70, 0.05);
}
html.theme-light .composer-shell textarea#chatInput,
html.theme-light #chatInput {
  color: #1a1a22 !important;
  background: transparent !important;
}
html.theme-light .composer-shell textarea#chatInput::placeholder {
  color: rgba(40, 28, 70, 0.4) !important;
}
html.theme-light .icon-btn {
  color: #4a4a58 !important;
}
html.theme-light .icon-btn:hover {
  background: rgba(122, 92, 219, 0.1) !important;
  color: #3d2f78 !important;
}
html.theme-light .icon-btn.send {
  background: rgba(122, 92, 219, 0.16) !important;
  color: #3d2f78 !important;
}

/* Bubbles */
html.theme-light .chat-msg,
html.theme-light .chat-bubble {
  background: #ffffff !important;
  border-color: rgba(40, 28, 70, 0.12) !important;
  color: #1a1a22 !important;
  box-shadow: 0 2px 8px rgba(40, 28, 70, 0.05);
  opacity: 1 !important;
}
html.theme-light .chat-bubble.theirs,
html.theme-light .chat-msg.theirs {
  background: #f4f2f8 !important;
  color: #1a1a22 !important;
}
html.theme-light .chat-bubble.mine,
html.theme-light .chat-msg.mine {
  background: linear-gradient(160deg, #efe8ff, #e4d9ff) !important;
  border-color: rgba(122, 92, 219, 0.35) !important;
  color: #1a1a22 !important;
}
html.theme-light .chat-bubble.mine .who,
html.theme-light .chat-msg.mine .who {
  color: #4a3d8a !important;
}
html.theme-light .chat-msg .who,
html.theme-light .chat-bubble .who {
  color: #a05068 !important;
}
html.theme-light .chat-msg .when,
html.theme-light .chat-bubble .when,
html.theme-light .chat-readers,
html.theme-light .chat-recall-tip {
  color: #4a4a58 !important;
}
html.theme-light .chat-msg .body,
html.theme-light .chat-bubble .body {
  color: inherit !important;
}
html.theme-light .chat-msg .to-tag,
html.theme-light .chat-bubble .to-tag,
html.theme-light .to-tag {
  color: #4a3d8a !important;
  background: rgba(122, 92, 219, 0.1);
  border-radius: 999px;
  padding: 1px 7px;
  font-weight: 600;
}

/* System bubbles: dashed only; success/err color on text */
html.theme-light .chat-bubble.system-msg,
html.theme-light .chat-msg.system-msg,
html.theme-light .chat-bubble.system {
  background: #ffffff !important;
  border: 1px dashed rgba(40, 28, 70, 0.28) !important;
  border-left: 1px dashed rgba(40, 28, 70, 0.28) !important;
  color: #1a1a22 !important;
  opacity: 1 !important;
  box-shadow: none !important;
}
html.theme-light .chat-bubble.system-msg .body,
html.theme-light .chat-msg.system-msg .body,
html.theme-light .chat-bubble.system-msg .who,
html.theme-light .chat-msg.system-msg .who {
  color: #1a1a22 !important;
}
html.theme-light .chat-bubble.system-msg.sys-ok,
html.theme-light .chat-msg.system-msg.sys-ok {
  background: #ffffff !important;
  border: 1px dashed rgba(40, 28, 70, 0.28) !important;
  color: #1a7a45 !important;
}
html.theme-light .chat-bubble.system-msg.sys-ok .body,
html.theme-light .chat-msg.system-msg.sys-ok .body,
html.theme-light .chat-bubble.system-msg.sys-ok .who,
html.theme-light .chat-msg.system-msg.sys-ok .who {
  color: #1a7a45 !important;
}
html.theme-light .chat-bubble.system-msg.sys-err,
html.theme-light .chat-msg.system-msg.sys-err {
  background: #ffffff !important;
  border: 1px dashed rgba(40, 28, 70, 0.28) !important;
  color: #c0392b !important;
}
html.theme-light .chat-bubble.system-msg.sys-err .body,
html.theme-light .chat-msg.system-msg.sys-err .body,
html.theme-light .chat-bubble.system-msg.sys-err .who,
html.theme-light .chat-msg.system-msg.sys-err .who {
  color: #c0392b !important;
}
html.theme-light .chat-bubble.system-msg.sys-info,
html.theme-light .chat-msg.system-msg.sys-info {
  background: #ffffff !important;
  border: 1px dashed rgba(40, 28, 70, 0.28) !important;
  color: #1a1a22 !important;
}
html.theme-light .chat-avatar {
  background: #e8e2f4 !important;
  border-color: rgba(40, 28, 70, 0.14) !important;
}

/* @ chips / mention bar — light pills, dark text */
html.theme-light .mention-bar .chip,
html.theme-light .mention-chips .chip,
html.theme-light #mentionChips .chip {
  background: #ffffff !important;
  border-color: rgba(40, 28, 70, 0.16) !important;
  color: #3a3a48 !important;
}
html.theme-light .mention-bar .chip:hover,
html.theme-light .mention-chips .chip:hover,
html.theme-light #mentionChips .chip:hover {
  color: #3d2f78 !important;
  border-color: rgba(122, 92, 219, 0.4) !important;
  background: rgba(122, 92, 219, 0.08) !important;
}
html.theme-light .mention-bar .chip.active,
html.theme-light .mention-chips .chip.active,
html.theme-light #mentionChips .chip.active {
  color: #2a2440 !important;
  background: linear-gradient(135deg, #efe8ff, #e0d4ff) !important;
  border-color: rgba(122, 92, 219, 0.45) !important;
  font-weight: 650;
}
html.theme-light .mention-bar .chip.chip-system {
  color: #3d2f78 !important;
  background: rgba(122, 92, 219, 0.08) !important;
  border-color: rgba(122, 92, 219, 0.3) !important;
}
html.theme-light .mention-suggest {
  background: #ffffff !important;
  border-color: rgba(40, 28, 70, 0.14) !important;
  color: #1a1a22 !important;
  box-shadow: 0 12px 32px rgba(40, 28, 70, 0.14);
}
html.theme-light .mention-suggest-item {
  color: #1a1a22 !important;
}
html.theme-light .mention-suggest-item:hover,
html.theme-light .mention-suggest-item.active {
  background: rgba(122, 92, 219, 0.1) !important;
}
html.theme-light .mention-suggest-empty {
  color: #4a4a58 !important;
}

/* Jump chips — light pills */
html.theme-light .chat-jump-chip,
html.theme-light #btnChatJumpTop,
html.theme-light #btnChatJumpLatest {
  background: rgba(255, 255, 255, 0.96) !important;
  border-color: rgba(122, 92, 219, 0.28) !important;
  color: #2a2440 !important;
  box-shadow: 0 6px 18px rgba(40, 28, 70, 0.12);
}
html.theme-light .chat-jump-chip:hover,
html.theme-light #btnChatJumpTop:hover,
html.theme-light #btnChatJumpLatest:hover {
  background: #efe8ff !important;
  border-color: rgba(122, 92, 219, 0.45) !important;
  color: #1a1a22 !important;
}
html.theme-light .chat-jump-chip[data-mode="new"] {
  background: rgba(122, 92, 219, 0.14) !important;
  border-color: rgba(122, 92, 219, 0.4) !important;
  color: #2a2440 !important;
}

html.theme-light .chat-pending .pending-file,
html.theme-light .chat-file,
html.theme-light .chat-pending-item {
  background: rgba(122, 92, 219, 0.06) !important;
  border-color: rgba(122, 92, 219, 0.2) !important;
  color: #3d2f78 !important;
}
html.theme-light .chat-hover-bar {
  background: rgba(255, 255, 255, 0.98) !important;
  border-color: rgba(40, 28, 70, 0.14) !important;
}
html.theme-light .chat-hover-bar button {
  color: #1a1a22 !important;
}
html.theme-light .chat-quote-in,
html.theme-light .chat-quote-preview {
  background: rgba(40, 28, 70, 0.04) !important;
  border-left-color: rgba(122, 92, 219, 0.45) !important;
  color: #4a4a58 !important;
}
html.theme-light .ctx-menu,
html.theme-light .modal,
html.theme-light .profile-popover,
html.theme-light .script-mark-bubble {
  background: #ffffff !important;
  border-color: rgba(40, 28, 70, 0.14) !important;
  color: #1a1a22 !important;
  box-shadow: 0 16px 40px rgba(40, 28, 70, 0.14);
}
html.theme-light .profile-popover input,
html.theme-light .auth-form input,
html.theme-light .modal input,
html.theme-light .modal textarea,
html.theme-light .modal select {
  background: #f7f5fb !important;
  border-color: #d5cee6 !important;
  color: #1a1a22 !important;
}
html.theme-light .auth-card {
  background: #ffffff !important;
  border-color: rgba(40, 28, 70, 0.12) !important;
  color: #1a1a22 !important;
}
html.theme-light .auth-tabs {
  background: #efeaf8 !important;
}
html.theme-light .auth-tab {
  color: #4a4a58 !important;
}
html.theme-light .auth-tab.active {
  background: rgba(122, 92, 219, 0.14) !important;
  color: #1a1a22 !important;
}

/* Mobile lower pane / home pane — light if theme-light (no hub layout change) */
html.theme-light body.mobile #mobileHomePane {
  background: linear-gradient(180deg, #ffffff, #f4f2f8) !important;
  border-top-color: rgba(40, 28, 70, 0.1) !important;
  color: #1a1a22 !important;
}
html.theme-light body.mobile .mobile-home-points {
  color: #3a3a48 !important;
}
html.theme-light body.mobile .chat-compose {
  background: #ffffff !important;
}

/* Catch-all: any leftover near-black panels under light theme */
html.theme-light .panel[style*="background"],
html.theme-light [class*="preview"]:not(img):not(video) {
  /* soft nudge only for empty chrome; images untouched via element type */
}

html.theme-light .empty,
html.theme-light .empty.small {
  color: #4a4a58 !important;
}

html.theme-light *::-webkit-scrollbar-thumb {
  background: rgba(40, 28, 70, 0.2) !important;
}
html.theme-light *::-webkit-scrollbar-track {
  background: rgba(40, 28, 70, 0.04);
}


/* ===== lightTheme3b: leftover voids / labels ===== */
html.theme-light .lib-card .preview {
  background: #efeaf8 !important;
}
html.theme-light .thumb.mini .thumb-media {
  background: #efeaf8 !important;
}
html.theme-light .chat-album-cell img,
html.theme-light .chat-msg-img {
  background: #e8e2f4 !important;
}
html.theme-light .lib-card .used-yes {
  color: #1a7a4a !important;
}
html.theme-light .lib-card .used-no,
html.theme-light .pick-card .muted,
html.theme-light .lib-card .muted {
  color: #4a4a58 !important;
}
html.theme-light .produce-card .zone-title em,
html.theme-light .zone-title em {
  color: #5a4a9a !important;
}
html.theme-light .thumb-x {
  background: rgba(255, 255, 255, 0.92) !important;
  border-color: rgba(40, 28, 70, 0.2) !important;
  color: #a03030 !important;
}
html.theme-light .hero-slot-label,
html.theme-light .thumb-badge,
html.theme-light .thumb-badge.lib {
  background: rgba(255, 255, 255, 0.92) !important;
  color: #3a3a48 !important;
  border-color: rgba(40, 28, 70, 0.12);
}
html.theme-light .mark-chip,
html.theme-light .mark-chip.character,
html.theme-light .mark-chip.scene,
html.theme-light .mark-chip.prop {
  color: #1a1a22 !important;
}
html.theme-light .mark-chip.character {
  color: #0a6a8a !important;
  background: rgba(56, 190, 255, 0.14) !important;
  border-color: rgba(20, 140, 190, 0.4) !important;
}
html.theme-light .mark-chip.scene {
  color: #0a6a3a !important;
  background: rgba(56, 210, 130, 0.14) !important;
  border-color: rgba(30, 160, 90, 0.4) !important;
}
html.theme-light .mark-chip.prop {
  color: #8a5a08 !important;
  background: rgba(255, 186, 72, 0.16) !important;
  border-color: rgba(200, 140, 30, 0.45) !important;
}
html.theme-light .comment {
  background: #f7f5fb !important;
  color: #1a1a22 !important;
}
html.theme-light .profile-chip,
html.theme-light .project-chip {
  background: #f7f5fb !important;
  border-color: rgba(40, 28, 70, 0.14) !important;
  color: #1a1a22 !important;
}

/* ===== mobileChatCompact1: WeChat-like compact phone chat — more message area ===== */
@media (max-width: 768px) {
  /* —— Top chrome: slim head + filters —— */
  body.mobile .chat-head {
    padding: 8px 10px !important;
    align-items: center !important;
    gap: 6px !important;
  }
  body.mobile .chat-title {
    font-size: 15px !important;
    line-height: 1.2 !important;
    letter-spacing: 0.02em;
  }
  /* Hide secondary muted lines to reclaim vertical space */
  body.mobile .chat-head-text .muted,
  body.mobile #chatEpContext,
  body.mobile #chatTargetHint {
    display: none !important;
  }
  body.mobile .chat-head-actions .btn.ghost {
    padding: 4px 8px !important;
    min-height: 28px;
    font-size: 14px;
  }

  body.mobile .chat-filters,
  body.mobile .chat-filters.seg {
    margin: 0 8px 4px !important;
    padding: 2px !important;
    gap: 2px !important;
  }
  body.mobile .chat-filters.seg button {
    font-size: 11px !important;
    padding: 4px 8px !important;
    line-height: 1.2 !important;
  }

  /* —— Message list: tighter —— */
  body.mobile .chat-messages {
    padding: 6px 10px 8px !important;
    gap: 8px !important;
  }
  body.mobile .chat-jump-chip {
    padding: 5px 11px !important;
    font-size: 11px !important;
  }
  #btnChatJumpTop { top: 6px !important; }
  #btnChatJumpLatest { bottom: 8px !important; }

  /* —— Compose: keep @ chips, shrink empty input like WeChat —— */
  body.mobile .chat-compose {
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom, 0px)) !important;
    gap: 4px !important;
  }

  /* @ chips stay visible; slightly denser */
  body.mobile .mention-bar,
  body.mobile #mentionChips {
    flex-wrap: nowrap !important;
    overflow-x: auto;
    gap: 3px !important;
    padding: 0 0 1px !important;
    margin: 0 !important;
    min-height: 0 !important;
  }
  body.mobile .mention-bar .chip,
  body.mobile #mentionChips .chip {
    padding: 2px 7px !important;
    font-size: 10.5px !important;
    line-height: 1.3 !important;
    border-radius: 999px !important;
  }

  /* Single-row WeChat-style composer: [tools] [textarea] [send] */
  body.mobile .composer-shell {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    align-items: flex-end !important;
    gap: 4px !important;
    padding: 4px 6px !important;
    border-radius: 12px !important;
    box-sizing: border-box;
  }
  body.mobile .composer-shell > .mention-suggest {
    /* stays absolute; out of flex flow */
    left: 4px;
    right: 4px;
  }
  body.mobile .composer-toolbar {
    display: contents; /* hoist tools-left + send into shell row */
  }
  body.mobile .composer-tools-left {
    order: 1;
    flex: 0 0 auto;
    display: flex !important;
    align-items: center;
    gap: 0 !important;
    padding: 0 !important;
  }
  body.mobile .composer-shell textarea#chatInput {
    order: 2;
    flex: 1 1 auto;
    width: auto !important;
    min-width: 0;
    min-height: 36px !important;
    max-height: 140px !important;
    height: auto; /* JS autoSize sets inline height on input */
    padding: 8px 8px !important;
    margin: 0 !important;
    border: 0 !important;
    line-height: 1.4 !important;
    font-size: 16px !important; /* keep iOS no-zoom */
    box-sizing: border-box;
    overflow-y: hidden;
    color: #f2f2f5;
  }
  body.mobile .composer-shell .icon-btn.send,
  body.mobile #btnChatSend {
    order: 3;
    flex: 0 0 auto;
    width: 32px !important;
    height: 32px !important;
    margin: 0 0 2px 0 !important;
  }
  body.mobile .composer-tools-left .icon-btn {
    width: 30px !important;
    height: 30px !important;
    font-size: 15px !important;
    margin: 0 0 2px 0;
  }

  /* Light theme: height/spacing only — keep light surfaces (no black restore) */
  html.theme-light body.mobile .chat-compose {
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom, 0px)) !important;
  }
  html.theme-light body.mobile .composer-shell {
    padding: 4px 6px !important;
  }
}

/* ===== chatPolish3: readable growing input; hide 相框; keep @ chips ===== */
@media (max-width: 768px) {
  body.mobile .chat-compose {
    padding: 5px 8px calc(5px + env(safe-area-inset-bottom, 0px)) !important;
    gap: 4px !important;
  }

  body.mobile .mention-bar,
  body.mobile #mentionChips {
    gap: 3px !important;
    padding: 0 !important;
  }
  body.mobile .mention-bar .chip,
  body.mobile #mentionChips .chip {
    padding: 2px 7px !important;
    font-size: 10.5px !important;
    line-height: 1.3 !important;
  }

  body.mobile #chatPendingPreview.hidden,
  body.mobile #chatQuotePreview.hidden,
  body.mobile .chat-pending.hidden,
  body.mobile .chat-quote-preview.hidden {
    display: none !important;
    margin: 0 !important;
    padding: 0 !important;
    height: 0 !important;
    min-height: 0 !important;
    overflow: hidden !important;
    border: 0 !important;
  }

  /* Hide landscape/相框 — use + for files */
  body.mobile #btnChatPickImageOnly,
  #btnChatPickImageOnly {
    display: none !important;
    width: 0 !important;
    height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: hidden !important;
    visibility: hidden !important;
    pointer-events: none !important;
  }

  body.mobile .composer-shell {
    gap: 4px !important;
    padding: 4px 6px !important;
    border-radius: 12px !important;
    align-items: flex-end !important;
  }
  body.mobile .composer-shell textarea#chatInput {
    min-height: 36px !important;
    max-height: 140px !important;
    height: auto; /* JS autoSize sets inline height; never lock with fixed px */
    padding: 8px 8px !important;
    line-height: 1.4 !important;
    font-size: 16px !important;
    color: #f2f2f5 !important;
    overflow-y: hidden;
    -webkit-text-fill-color: #f2f2f5;
  }
  body.mobile .composer-shell textarea#chatInput::placeholder {
    color: rgba(255, 255, 255, 0.45) !important;
    -webkit-text-fill-color: rgba(255, 255, 255, 0.45);
    opacity: 1;
  }
  body.mobile .composer-tools-left .icon-btn {
    width: 30px !important;
    height: 30px !important;
    font-size: 15px !important;
    margin: 0 0 3px 0 !important;
  }
  body.mobile .composer-shell .icon-btn.send,
  body.mobile #btnChatSend {
    width: 32px !important;
    height: 32px !important;
    margin: 0 0 2px 0 !important;
  }

  body.mobile #chatPendingPreview:not(.hidden),
  body.mobile .chat-pending:not(.hidden) {
    margin: 0 0 2px !important;
    padding: 4px !important;
  }
  body.mobile .chat-pending-item {
    width: 44px !important;
    height: 44px !important;
  }
  body.mobile .chat-pending-item img {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover;
  }

  html.theme-light body.mobile .chat-compose {
    padding: 5px 8px calc(5px + env(safe-area-inset-bottom, 0px)) !important;
  }
  html.theme-light body.mobile .composer-shell {
    padding: 4px 6px !important;
  }
  html.theme-light body.mobile .composer-shell textarea#chatInput {
    color: #1a1a22 !important;
    -webkit-text-fill-color: #1a1a22;
  }
  html.theme-light body.mobile .composer-shell textarea#chatInput::placeholder {
    color: rgba(40, 28, 70, 0.42) !important;
    -webkit-text-fill-color: rgba(40, 28, 70, 0.42);
  }
}

/* Also hide 相框 on any viewport size (desktop uses + too) */
#btnChatPickImageOnly {
  display: none !important;
}


/* ===== lightClean1: clean white/gray light theme — purple accents only ===== */
/* Colors only. Do not alter mobileStable / chatPolish layout or alignment. */

html.theme-light {
  --bg: #f5f5f7 !important;
  --bg-elevated: #ffffff !important;
  --panel: #ffffff !important;
  --panel2: #f0f0f2 !important;
  --panel3: #ebebed !important;
  --border: #e0e0e4 !important;
  --border-soft: rgba(0, 0, 0, 0.08) !important;
  --text: #1a1a22 !important;
  --muted: #5a5a66 !important;
  --shadow: 0 12px 36px rgba(0, 0, 0, 0.08) !important;
  --shadow-soft: 0 4px 16px rgba(0, 0, 0, 0.06) !important;
  --accent-purple: #6b5b95 !important;
  --flash: #6b5b95 !important;
}

html.theme-light,
html.theme-light body {
  background: #f5f5f7 !important;
  color: #1a1a22 !important;
}

/* Global chrome / shells — flat white/gray, no lilac wash */
html.theme-light .app-header,
html.theme-light .top-chrome,
html.theme-light .tabs,
html.theme-light .sticky-toolbar,
html.theme-light .produce-sticky-bar,
html.theme-light .produce-main .toolbar,
html.theme-light .panel-script .script-toolbar {
  background: rgba(255, 255, 255, 0.96) !important;
  border-bottom-color: rgba(0, 0, 0, 0.08) !important;
  box-shadow: 0 1px 0 rgba(255,255,255,.9), 0 2px 10px rgba(0,0,0,.04);
}

html.theme-light .panel,
html.theme-light .main,
html.theme-light .workbench-shell,
html.theme-light .workbench-shell > .main .panel,
html.theme-light .workflow-strip {
  background: #f5f5f7 !important;
  border-color: rgba(0, 0, 0, 0.08) !important;
  color: #1a1a22 !important;
}

html.theme-light .brand h1,
html.theme-light .hub-hero-title,
html.theme-light .hub-main-head .page-title {
  background: none !important;
  -webkit-background-clip: unset !important;
  background-clip: unset !important;
  color: #1a1a22 !important;
}

html.theme-light .hub-main,
html.theme-light .hub-empty {
  background: transparent !important;
}
html.theme-light .hub-empty {
  border-color: rgba(0, 0, 0, 0.1) !important;
  background: #ffffff !important;
}

html.theme-light .project-card.hub-card,
html.theme-light .hub-card,
html.theme-light .card,
html.theme-light .produce-card,
html.theme-light .produce-card.card,
html.theme-light .pick-card,
html.theme-light .lib-card,
html.theme-light .script-toc,
html.theme-light .script-reader-card,
html.theme-light .script-editor-card,
html.theme-light .script-result-card,
html.theme-light .panel-script .script-result-card,
html.theme-light .asset-row,
html.theme-light .asset-row.compact,
html.theme-light .ep-rail,
html.theme-light .modal,
html.theme-light .auth-card,
html.theme-light .ctx-menu,
html.theme-light .profile-popover,
html.theme-light .script-mark-bubble {
  background: #ffffff !important;
  border-color: rgba(0, 0, 0, 0.1) !important;
  color: #1a1a22 !important;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.05);
}

html.theme-light .hub-card:hover,
html.theme-light .hub-card:focus-visible,
html.theme-light .card:hover,
html.theme-light .pick-card:hover,
html.theme-light .lib-card:hover,
html.theme-light .asset-row:hover {
  border-color: rgba(107, 91, 149, 0.35) !important;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.08);
}

/* Accents only: selected nav / tabs / primary actions */
html.theme-light .app-nav-btn:hover {
  background: rgba(0, 0, 0, 0.04) !important;
  color: #1a1a22 !important;
}
html.theme-light .app-nav-btn.active {
  color: #4a3d78 !important;
  background: rgba(107, 91, 149, 0.1) !important;
  border-color: rgba(107, 91, 149, 0.28) !important;
  box-shadow: none !important;
}
html.theme-light .tab:hover {
  background: rgba(0, 0, 0, 0.04) !important;
  color: #1a1a22 !important;
}
html.theme-light .tab.active {
  color: #4a3d78 !important;
}
html.theme-light .theme-toggle-btn {
  border-color: rgba(0, 0, 0, 0.12) !important;
  background: #f0f0f2 !important;
  color: #4a4a58 !important;
}
html.theme-light .theme-toggle-btn:hover {
  background: rgba(107, 91, 149, 0.1) !important;
  border-color: rgba(107, 91, 149, 0.35) !important;
  color: #4a3d78 !important;
}

html.theme-light .btn {
  background: #ffffff !important;
  border-color: #d8d8dc !important;
  color: #1a1a22 !important;
}
html.theme-light .btn:hover {
  background: #f0f0f2 !important;
  border-color: #c8c8ce !important;
}
html.theme-light .btn.ghost,
html.theme-light .btn.secondary {
  background: #f5f5f7 !important;
  color: #3a3a48 !important;
}
html.theme-light .btn.primary,
html.theme-light button.btn.primary,
html.theme-light .hub-cta.btn.primary,
html.theme-light #btnNewProject,
html.theme-light #btnNewProjectEmpty,
html.theme-light .btn.primary:hover,
html.theme-light .hub-cta.btn.primary:hover,
html.theme-light #btnNewProject:hover,
html.theme-light #btnNewProjectEmpty:hover {
  background: #6b5b95 !important;
  color: #fff !important;
  border-color: transparent !important;
  box-shadow: 0 4px 14px rgba(107, 91, 149, 0.28);
  filter: none;
}
html.theme-light .chat-fab {
  background: #6b5b95 !important;
  color: #fff !important;
}

html.theme-light .seg {
  background: #f0f0f2 !important;
  border-color: #e0e0e4 !important;
}
html.theme-light .seg button.active {
  background: #ffffff !important;
  color: #1a1a22 !important;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}

html.theme-light .hub-hero-meta .hub-count,
html.theme-light .hub-secondary {
  color: #4a3d78 !important;
  background: rgba(107, 91, 149, 0.08) !important;
  border-color: rgba(107, 91, 149, 0.22) !important;
}
html.theme-light .hub-secondary:hover {
  background: rgba(107, 91, 149, 0.12) !important;
  border-color: rgba(107, 91, 149, 0.35) !important;
}
html.theme-light .hub-card .project-stats span {
  background: #f0f0f2 !important;
  border-color: #e0e0e4 !important;
  color: #5a5a66 !important;
}

/* Produce: white cards, gray placeholders — no lavender/pink zone washes */
html.theme-light .dropzone,
html.theme-light .drop-zone,
html.theme-light .stage-slots .drop-zone {
  background: #f5f5f7 !important;
  border-color: rgba(0, 0, 0, 0.16) !important;
  color: #5a5a66 !important;
}
html.theme-light .dropzone:hover,
html.theme-light .dropzone.dragover,
html.theme-light .drop-zone:hover,
html.theme-light .drop-zone.dragover {
  background: rgba(107, 91, 149, 0.06) !important;
  border-color: rgba(107, 91, 149, 0.35) !important;
  color: #1a1a22 !important;
  box-shadow: none !important;
}

html.theme-light .thumb,
html.theme-light .char-main-preview,
html.theme-light .pick-card .preview,
html.theme-light .lib-card .preview,
html.theme-light .hero-slot,
html.theme-light .hero-slot.has-img,
html.theme-light .char-main-preview:has(img),
html.theme-light .char-thumbs button {
  background: #f0f0f2 !important;
  border-color: rgba(0, 0, 0, 0.12) !important;
  color: #5a5a66 !important;
}
html.theme-light .thumb img,
html.theme-light .thumb video {
  background: #ebebed !important;
}
html.theme-light .hero-slot-label,
html.theme-light .thumb-badge,
html.theme-light .thumb-badge.lib {
  background: rgba(255, 255, 255, 0.94) !important;
  color: #5a5a66 !important;
}

html.theme-light .stage-slots.work-lanes {
  background: #f0f0f2 !important;
  border: 1px solid rgba(0, 0, 0, 0.08) !important;
}
html.theme-light .stage-slots.work-lanes .zone,
html.theme-light .stage-slots.work-lanes .zone[data-slot="ref"],
html.theme-light .stage-slots.work-lanes .zone[data-slot="costume"],
html.theme-light .stage-slots.work-lanes .zone[data-slot="face"] {
  background: #ffffff !important;
  color: #1a1a22 !important;
}
html.theme-light .stage-slots.work-lanes .zone:not(:first-child)::before {
  background: rgba(0, 0, 0, 0.08) !important;
}
html.theme-light .upload-tile,
html.theme-light .thumb-more,
html.theme-light .plus {
  background: #f5f5f7 !important;
  color: #4a3d78 !important;
  border-color: rgba(0, 0, 0, 0.12) !important;
}
html.theme-light .produce-card.selected-target {
  border-color: rgba(107, 91, 149, 0.45) !important;
  box-shadow: 0 0 0 2px rgba(107, 91, 149, 0.12) !important;
}
html.theme-light .ep-rail-item:hover {
  background: rgba(0, 0, 0, 0.04) !important;
}
html.theme-light .ep-rail-item.active {
  background: rgba(107, 91, 149, 0.1) !important;
  border-color: rgba(107, 91, 149, 0.28) !important;
  color: #1a1a22 !important;
}
html.theme-light .script-font-ctrl,
html.theme-light .script-color-legend,
html.theme-light .script-drop {
  background: #f5f5f7 !important;
  border-color: rgba(0, 0, 0, 0.1) !important;
  color: #1a1a22 !important;
}
html.theme-light .script-reader-head {
  background: #ffffff !important;
  border-bottom-color: rgba(0, 0, 0, 0.08) !important;
}
html.theme-light .script-toc-ep:hover,
html.theme-light .script-toc-scene:hover {
  background: rgba(0, 0, 0, 0.04) !important;
  border-color: rgba(0, 0, 0, 0.1) !important;
}
html.theme-light .script-toc-scene.active {
  background: rgba(107, 91, 149, 0.1) !important;
  border-color: rgba(107, 91, 149, 0.3) !important;
}
html.theme-light .script-drop-icon {
  background: #f0f0f2 !important;
  border-color: rgba(0, 0, 0, 0.1) !important;
}
html.theme-light .completeness,
html.theme-light .wf-steps span {
  background: #f0f0f2 !important;
  border-color: rgba(0, 0, 0, 0.1) !important;
  color: #1a1a22 !important;
}
html.theme-light .stage-dot.on {
  color: #4a3d78 !important;
  border-color: rgba(107, 91, 149, 0.35) !important;
  background: rgba(107, 91, 149, 0.1) !important;
}
html.theme-light input[type="range"],
html.theme-light input[type="range"]::-webkit-slider-runnable-track,
html.theme-light input[type="range"]::-moz-range-track,
html.theme-light progress,
html.theme-light progress::-webkit-progress-bar {
  background: #e4e4e8 !important;
}
html.theme-light .scrub-tick.hot {
  background: rgba(107, 91, 149, 0.55) !important;
}

/* Chat: gray stage, white panel, soft purple only on mine bubble / send */
html.theme-light #globalChat .chat-dock-panel,
html.theme-light .chat-dock-panel,
html.theme-light .chat-dock-panel.produce-chat,
html.theme-light .global-chat-panel.produce-chat {
  background: #ffffff !important;
  border-color: rgba(0, 0, 0, 0.1) !important;
  border-left-color: rgba(0, 0, 0, 0.1) !important;
  color: #1a1a22 !important;
  box-shadow: -8px 0 28px rgba(0, 0, 0, 0.06);
}
html.theme-light .chat-head,
html.theme-light .chat-dock-panel .chat-head {
  background: #ffffff !important;
  border-bottom-color: rgba(0, 0, 0, 0.08) !important;
  color: #1a1a22 !important;
}
html.theme-light .chat-title {
  color: #1a1a22 !important;
}
html.theme-light .chat-messages,
html.theme-light .chat-msg-stage {
  background: #f5f5f7 !important;
}
html.theme-light .chat-compose {
  background: #ffffff !important;
  border-top-color: rgba(0, 0, 0, 0.08) !important;
}
html.theme-light .composer-shell {
  background: #ffffff !important;
  border-color: rgba(0, 0, 0, 0.12) !important;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
}
html.theme-light .composer-shell:focus-within {
  border-color: rgba(107, 91, 149, 0.4) !important;
  box-shadow: 0 0 0 2px rgba(107, 91, 149, 0.1) !important;
}
html.theme-light .chat-msg,
html.theme-light .chat-bubble,
html.theme-light .chat-bubble.theirs {
  background: #ffffff !important;
  border-color: rgba(0, 0, 0, 0.1) !important;
  color: #1a1a22 !important;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
}
html.theme-light .chat-bubble.mine {
  background: #ebe8f4 !important;
  border-color: rgba(107, 91, 149, 0.28) !important;
  color: #1a1a22 !important;
}
html.theme-light .chat-bubble.mine .who { color: #5a4a88 !important; }
html.theme-light .chat-msg .who,
html.theme-light .chat-bubble .who { color: #6a5a50 !important; }
html.theme-light .chat-avatar {
  background: #e8e8ec !important;
  border-color: rgba(0, 0, 0, 0.1) !important;
}
html.theme-light .chat-row.mention .chat-bubble {
  box-shadow: inset 3px 0 0 #6b5b95, 0 1px 4px rgba(0,0,0,.04) !important;
}
html.theme-light .icon-btn:hover {
  background: rgba(107, 91, 149, 0.08) !important;
  color: #4a3d78 !important;
}
html.theme-light .icon-btn.send {
  background: rgba(107, 91, 149, 0.14) !important;
  color: #4a3d78 !important;
}
html.theme-light .icon-btn.send:hover {
  background: #6b5b95 !important;
  color: #fff !important;
}
html.theme-light .mention-bar .chip,
html.theme-light .mention-chips .chip,
html.theme-light #mentionChips .chip {
  background: #ffffff !important;
  border-color: #e0e0e4 !important;
  color: #5a5a66 !important;
}
html.theme-light .mention-bar .chip:hover,
html.theme-light .mention-chips .chip:hover,
html.theme-light #mentionChips .chip:hover {
  color: #4a3d78 !important;
  border-color: rgba(107, 91, 149, 0.35) !important;
  background: rgba(107, 91, 149, 0.06) !important;
}
html.theme-light .mention-bar .chip.active,
html.theme-light .mention-chips .chip.active,
html.theme-light #mentionChips .chip.active {
  color: #4a3d78 !important;
  border-color: rgba(107, 91, 149, 0.4) !important;
  background: rgba(107, 91, 149, 0.12) !important;
}
html.theme-light .chat-pending .pending-file,
html.theme-light .chat-file,
html.theme-light .chat-pending-item {
  background: #f5f5f7 !important;
  border-color: rgba(0, 0, 0, 0.1) !important;
}
html.theme-light .chat-hover-bar {
  background: #ffffff !important;
  border-color: rgba(0, 0, 0, 0.1) !important;
}
html.theme-light .chat-hover-bar button:hover,
html.theme-light .ctx-menu button:hover {
  background: rgba(107, 91, 149, 0.08) !important;
}
html.theme-light .chat-quote-in,
html.theme-light .chat-quote-preview {
  background: #f5f5f7 !important;
  border-left-color: rgba(107, 91, 149, 0.4) !important;
}
html.theme-light .chat-jump-chip,
html.theme-light #btnChatJumpTop,
html.theme-light #btnChatJumpLatest {
  background: #ffffff !important;
  border-color: rgba(0, 0, 0, 0.12) !important;
  color: #1a1a22 !important;
}
html.theme-light .chat-jump-chip:hover,
html.theme-light #btnChatJumpTop:hover,
html.theme-light #btnChatJumpLatest:hover {
  border-color: rgba(107, 91, 149, 0.35) !important;
  color: #4a3d78 !important;
}
html.theme-light .pill.picked,
html.theme-light .pill.merged {
  color: #4a3d78 !important;
  background: rgba(107, 91, 149, 0.1) !important;
  border-color: rgba(107, 91, 149, 0.35) !important;
}
html.theme-light .ap-k {
  color: #4a3d78 !important;
  background: rgba(107, 91, 149, 0.1) !important;
  border-color: rgba(107, 91, 149, 0.28) !important;
}
html.theme-light .modal-mask {
  background: rgba(0, 0, 0, 0.28) !important;
}
html.theme-light .profile-chip,
html.theme-light .project-chip {
  background: #f0f0f2 !important;
  border-color: #e0e0e4 !important;
  color: #1a1a22 !important;
}
html.theme-light .profile-chip:hover {
  border-color: rgba(107, 91, 149, 0.35) !important;
}
html.theme-light .auth-tabs {
  background: #f0f0f2 !important;
}
html.theme-light .auth-tab.active {
  background: #ffffff !important;
  color: #4a3d78 !important;
}
html.theme-light .profile-popover input,
html.theme-light .auth-form input,
html.theme-light .modal input,
html.theme-light .modal textarea,
html.theme-light .modal select {
  background: #ffffff !important;
  border-color: #e0e0e4 !important;
  color: #1a1a22 !important;
}
html.theme-light body.mobile #mobileHomePane {
  background: #f5f5f7 !important;
}
html.theme-light body.mobile .chat-compose {
  background: #ffffff !important;
}
html.theme-light .empty,
html.theme-light .empty.small {
  color: #5a5a66 !important;
}
html.theme-light *::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.18) !important;
}
html.theme-light *::-webkit-scrollbar-track {
  background: transparent !important;
}

/* ===== mobileStable1: mode switch + single-line input + script mobile layout + flash2 ===== */

/* Mode switch in chat head */
.chat-mode-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
}
.chat-mode-btn {
  font-size: 12px !important;
  padding: 4px 8px !important;
  min-height: 28px;
  letter-spacing: 0.02em;
}
.chat-mode-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 80;
  min-width: 148px;
  padding: 6px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(22, 20, 32, 0.97);
  box-shadow: 0 12px 32px rgba(0,0,0,0.45);
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.chat-mode-menu.hidden { display: none !important; }
.chat-mode-menu button {
  appearance: none;
  border: 0;
  background: transparent;
  color: rgba(242,242,245,0.92);
  text-align: left;
  padding: 9px 10px;
  border-radius: 8px;
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}
.chat-mode-menu button:hover,
.chat-mode-menu button.active {
  background: rgba(155,123,255,0.18);
  color: #fff;
}
html.theme-light .chat-mode-menu {
  background: #fff;
  border-color: rgba(40,28,70,0.14);
  box-shadow: 0 12px 28px rgba(40,28,70,0.14);
}
html.theme-light .chat-mode-menu button {
  color: #1a1a22;
}
html.theme-light .chat-mode-menu button:hover,
html.theme-light .chat-mode-menu button.active {
  background: rgba(110,90,200,0.12);
  color: #1a1a22;
}

/* flash2: keep hub hidden while boot-pending toward workbench */
html.boot-pending[data-boot-view="workbench"] body:not(.app-ready) #view-home,
html.boot-pending[data-boot-view="workbench"] body:not(.app-ready) .hub-hero,
html.boot-pending[data-boot-view="workbench"] body:not(.app-ready) .hub-shell {
  display: none !important;
  visibility: hidden !important;
}

@media (max-width: 768px) {
  /* Always show mode switch on phone chat (desktop top tabs already exist) */
  body.mobile .chat-mode-wrap { display: inline-flex !important; }
  body.mobile .chat-mode-btn {
    font-size: 12px !important;
    padding: 4px 9px !important;
  }
  body.mobile .chat-mode-menu {
    right: 0;
    left: auto;
    min-width: 156px;
  }

  /* Bug D: empty composer = one WeChat row; grow only when typing */
  body.mobile .composer-shell textarea#chatInput {
    min-height: 34px !important;
    max-height: 140px !important;
    padding: 7px 8px !important;
    line-height: 1.35 !important;
    white-space: pre-wrap;
  }
  body.mobile .composer-shell textarea#chatInput::placeholder {
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    line-height: 1.35 !important;
  }

  /* Bug C: script analysis — stack sections, no overlap, readable */
  body.mobile #tab-script.panel,
  body.mobile #tab-script.panel:not(.hidden) {
    display: flex !important;
    flex-direction: column !important;
    height: auto !important;
    max-height: none !important;
    overflow: auto !important;
    min-height: 0 !important;
    padding: 8px !important;
    gap: 8px;
  }
  body.mobile .panel-script .script-toolbar {
    flex-wrap: wrap;
    gap: 6px;
  }
  body.mobile .panel-script .script-drop {
    margin-bottom: 0 !important;
    padding: 10px 12px !important;
  }
  body.mobile .script-layout {
    display: flex !important;
    flex-direction: column !important;
    grid-template-columns: none !important;
    height: auto !important;
    min-height: 0 !important;
    gap: 10px !important;
    align-items: stretch !important;
  }
  body.mobile .script-split-handle {
    display: none !important;
  }
  body.mobile .script-toc {
    position: relative !important;
    width: 100% !important;
    max-height: 150px !important;
    height: auto !important;
    flex: 0 0 auto !important;
    z-index: 1;
  }
  body.mobile .script-reader-card {
    position: relative !important;
    width: 100% !important;
    flex: 1 1 auto !important;
    min-height: 42vh !important;
    max-height: none !important;
    z-index: 1;
    overflow: hidden;
  }
  body.mobile .script-reader {
    max-height: none !important;
    min-height: 36vh;
    font-size: var(--script-font-size, 15px);
    line-height: 1.65;
    padding: 14px 14px 28px !important;
    color: rgba(242, 242, 245, 0.92);
  }
  body.mobile .script-reader-head {
    padding: 12px 14px 8px !important;
  }
  body.mobile .script-show-title {
    font-size: 16px !important;
  }
  body.mobile .script-ep-title {
    font-size: 13px !important;
  }
  body.mobile .script-result-card,
  body.mobile .panel-script .script-result-card {
    position: relative !important;
    grid-column: auto !important;
    width: 100% !important;
    max-height: 38vh !important;
    height: auto !important;
    flex: 0 0 auto !important;
    z-index: 1;
    overflow: auto;
    margin-top: 0 !important;
  }
  body.mobile .script-color-legend {
    padding: 0 14px 8px;
    gap: 10px;
  }

  html.theme-light body.mobile .script-reader {
    color: #1a1a22 !important;
  }
  html.theme-light body.mobile .script-toc,
  html.theme-light body.mobile .script-reader-card,
  html.theme-light body.mobile .script-result-card {
    background: #fff !important;
  }
}

/* Desktop: mode button optional (tabs already visible); keep compact */
@media (min-width: 769px) {
  body:not(.mobile) .chat-mode-wrap {
    display: inline-flex;
  }
}


/* ===== lightPolish2: light theme detail polish — white/gray hierarchy, no pink ===== */
/* Visual only under html.theme-light. No layout / scroll / @系统 logic. */

html.theme-light {
  --bg: #f4f4f6 !important;
  --panel: #ffffff !important;
  --panel2: #f7f7f9 !important;
  --panel3: #eeeef1 !important;
  --border: #d8d8de !important;
  --border-soft: rgba(0, 0, 0, 0.1) !important;
  --text: #1a1a22 !important;
  --muted: #5c5c68 !important;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 8px 22px rgba(0,0,0,.06) !important;
  --shadow-soft: 0 1px 2px rgba(0,0,0,.05), 0 4px 12px rgba(0,0,0,.04) !important;
}

html.theme-light,
html.theme-light body {
  background: #f4f4f6 !important;
  color: #1a1a22 !important;
}

/* —— Chrome / rails: moderate separation from content —— */
html.theme-light .app-header,
html.theme-light .top-chrome,
html.theme-light .tabs,
html.theme-light .sticky-toolbar,
html.theme-light .produce-sticky-bar,
html.theme-light .produce-main .toolbar {
  background: #ffffff !important;
  border-bottom: 1px solid rgba(0, 0, 0, 0.1) !important;
  box-shadow: 0 1px 0 rgba(255,255,255,.9) !important;
}

html.theme-light .ep-rail {
  background: #ffffff !important;
  border: 1px solid rgba(0, 0, 0, 0.1) !important;
  box-shadow: 0 1px 2px rgba(0,0,0,.04), 0 6px 16px rgba(0,0,0,.04) !important;
}
html.theme-light .ep-rail-item.active {
  background: #f0eef6 !important;
  border-color: rgba(107, 91, 149, 0.3) !important;
  color: #1a1a22 !important;
}
html.theme-light .workflow-strip {
  background: #f7f7f9 !important;
  border-color: rgba(0, 0, 0, 0.1) !important;
  color: #5c5c68 !important;
}
html.theme-light .panel,
html.theme-light .main,
html.theme-light .workbench-shell {
  background: #f4f4f6 !important;
  border-color: rgba(0, 0, 0, 0.08) !important;
}

/* —— Cards: clearer edge + light lift —— */
html.theme-light .card,
html.theme-light .produce-card,
html.theme-light .produce-card.card,
html.theme-light .pick-card,
html.theme-light .lib-card,
html.theme-light .hub-card,
html.theme-light .project-card.hub-card,
html.theme-light .script-toc,
html.theme-light .script-reader-card,
html.theme-light .script-result-card,
html.theme-light .asset-row {
  background: #ffffff !important;
  border: 1px solid rgba(0, 0, 0, 0.12) !important;
  box-shadow:
    0 1px 2px rgba(0, 0, 0, 0.04),
    0 8px 20px rgba(0, 0, 0, 0.05) !important;
  color: #1a1a22 !important;
}
html.theme-light .card:hover,
html.theme-light .produce-card:hover,
html.theme-light .pick-card:hover,
html.theme-light .lib-card:hover,
html.theme-light .hub-card:hover {
  border-color: rgba(107, 91, 149, 0.32) !important;
  box-shadow:
    0 1px 2px rgba(0, 0, 0, 0.04),
    0 12px 28px rgba(0, 0, 0, 0.07) !important;
}
html.theme-light .produce-card.selected-target {
  border-color: rgba(107, 91, 149, 0.45) !important;
  box-shadow: 0 0 0 2px rgba(107, 91, 149, 0.12), 0 8px 20px rgba(0,0,0,.05) !important;
}

/* —— Secondary buttons: white + dark text + gray edge (not cold gray fill) —— */
html.theme-light .btn,
html.theme-light .card-actions-row .btn,
html.theme-light .btn.ghost,
html.theme-light .btn.secondary,
html.theme-light .btn-sm {
  background: #ffffff !important;
  border: 1px solid #d0d0d6 !important;
  color: #2a2a34 !important;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
}
html.theme-light .btn:hover,
html.theme-light .card-actions-row .btn:hover,
html.theme-light .btn.ghost:hover,
html.theme-light .btn.secondary:hover,
html.theme-light .btn-sm:hover {
  background: #f7f7f9 !important;
  border-color: rgba(107, 91, 149, 0.4) !important;
  color: #3d2f78 !important;
}
html.theme-light .btn.primary,
html.theme-light button.btn.primary,
html.theme-light .card-actions-row .btn.primary,
html.theme-light .hub-cta.btn.primary,
html.theme-light #btnNewProject,
html.theme-light #btnNewProjectEmpty {
  background: #6b5b95 !important;
  border-color: transparent !important;
  color: #ffffff !important;
  box-shadow: 0 4px 14px rgba(107, 91, 149, 0.28) !important;
}
html.theme-light .btn.primary:hover,
html.theme-light .card-actions-row .btn.primary:hover {
  background: #5c4d86 !important;
  color: #ffffff !important;
  border-color: transparent !important;
}

/* —— Empty preview / hero slots: clean dashed, not dirty solid gray —— */
html.theme-light .char-main-preview,
html.theme-light .pick-card .preview,
html.theme-light .lib-card .preview {
  background: #fafafa !important;
  border: 1px dashed rgba(0, 0, 0, 0.18) !important;
  color: #6a6a76 !important;
  box-shadow: none !important;
}
html.theme-light .char-main-preview:has(img),
html.theme-light .pick-card .preview:has(img),
html.theme-light .lib-card .preview:has(img) {
  background: #ffffff !important;
  border-style: solid !important;
  border-color: rgba(0, 0, 0, 0.1) !important;
}
html.theme-light .char-main-preview .empty-preview {
  color: #6a6a76 !important;
  font-size: 12px !important;
  opacity: 0.9;
}
html.theme-light .hero-slot {
  background: #fafafa !important;
  border: 1px dashed rgba(0, 0, 0, 0.18) !important;
  color: #6a6a76 !important;
  box-shadow: none !important;
}
html.theme-light .hero-slot.has-img {
  background: #ffffff !important;
  border-style: solid !important;
  border-color: rgba(0, 0, 0, 0.12) !important;
}
html.theme-light .hero-slot.active {
  border-color: rgba(107, 91, 149, 0.45) !important;
  box-shadow: 0 0 0 2px rgba(107, 91, 149, 0.12) !important;
}
html.theme-light .hero-slot-empty {
  color: #6a6a76 !important;
  background: transparent !important;
}
html.theme-light .hero-slot-label {
  background: rgba(255, 255, 255, 0.96) !important;
  color: #4a4a56 !important;
  border-top: 1px solid rgba(0, 0, 0, 0.06);
}
html.theme-light .hero-slot img,
html.theme-light .char-main-preview img,
html.theme-light .thumb img,
html.theme-light .thumb video {
  background: transparent !important;
}
html.theme-light .char-thumbs button {
  background: #fafafa !important;
  border-color: rgba(0, 0, 0, 0.12) !important;
}
html.theme-light .thumb {
  background: #fafafa !important;
  border-color: rgba(0, 0, 0, 0.12) !important;
  color: #5c5c68 !important;
}

/* Add / empty upload tiles: dashed light, not solid gray blocks */
html.theme-light .upload-tile,
html.theme-light .thumb-more,
html.theme-light .plus,
html.theme-light .dropzone,
html.theme-light .drop-zone,
html.theme-light .stage-slots .drop-zone {
  background: #fafafa !important;
  border: 1px dashed rgba(0, 0, 0, 0.18) !important;
  color: #5c5c68 !important;
  box-shadow: none !important;
}
html.theme-light .upload-tile .plus,
html.theme-light .plus {
  color: #6b5b95 !important;
  background: transparent !important;
  border: none !important;
}
html.theme-light .upload-tile:hover,
html.theme-light .dropzone:hover,
html.theme-light .drop-zone:hover,
html.theme-light .dropzone.dragover,
html.theme-light .drop-zone.dragover {
  background: rgba(107, 91, 149, 0.05) !important;
  border-color: rgba(107, 91, 149, 0.4) !important;
  color: #3d2f78 !important;
}

/* —— Ref / costume / face: fine solid dividers, no dirty gradients —— */
html.theme-light .stage-slots.work-lanes {
  background: #ffffff !important;
  border: 1px solid rgba(0, 0, 0, 0.1) !important;
  border-radius: 14px;
  overflow: hidden;
  box-shadow: none !important;
}
html.theme-light .stage-slots.work-lanes .zone,
html.theme-light .stage-slots.work-lanes .drop-zone,
html.theme-light .stage-slots.work-lanes .zone[data-slot="ref"],
html.theme-light .stage-slots.work-lanes .zone[data-slot="costume"],
html.theme-light .stage-slots.work-lanes .zone[data-slot="face"] {
  background: #ffffff !important;
  color: #1a1a22 !important;
}
html.theme-light .stage-slots.work-lanes .zone:not(:first-child)::before {
  background: rgba(0, 0, 0, 0.1) !important;
  width: 1px !important;
  top: 8% !important;
  bottom: 8% !important;
  opacity: 1 !important;
}
html.theme-light .zone-title,
html.theme-light .upload-tile-cap,
html.theme-light .drop-copy {
  color: #5c5c68 !important;
}
html.theme-light .produce-card .zone-title em,
html.theme-light .zone-title em {
  color: #6b5b95 !important;
}

/* —— Chat dock: clearer panel / message / composer boundaries —— */
html.theme-light #globalChat .chat-dock-panel,
html.theme-light .chat-dock-panel,
html.theme-light .chat-dock-panel.produce-chat,
html.theme-light .global-chat-panel.produce-chat {
  background: #ffffff !important;
  border-left: 1px solid rgba(0, 0, 0, 0.12) !important;
  box-shadow: -6px 0 24px rgba(0, 0, 0, 0.05) !important;
  color: #1a1a22 !important;
}
html.theme-light .chat-head,
html.theme-light .chat-dock-panel .chat-head {
  background: #ffffff !important;
  border-bottom: 1px solid rgba(0, 0, 0, 0.1) !important;
}
html.theme-light .chat-title {
  color: #1a1a22 !important;
}
html.theme-light .chat-messages,
html.theme-light .chat-msg-stage {
  background: #f4f4f6 !important;
}
html.theme-light .chat-compose {
  background: #ffffff !important;
  border-top: 1px solid rgba(0, 0, 0, 0.12) !important;
  box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.03);
}
html.theme-light .composer-shell {
  background: #ffffff !important;
  border: 1px solid rgba(0, 0, 0, 0.14) !important;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}
html.theme-light .composer-shell:focus-within {
  border-color: rgba(107, 91, 149, 0.42) !important;
  box-shadow: 0 0 0 2px rgba(107, 91, 149, 0.1) !important;
}

/* Bubbles: clean mine lavender; system stays dashed-only */
html.theme-light .chat-msg,
html.theme-light .chat-bubble,
html.theme-light .chat-bubble.theirs {
  background: #ffffff !important;
  border: 1px solid rgba(0, 0, 0, 0.1) !important;
  color: #1a1a22 !important;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}
html.theme-light .chat-bubble.mine,
html.theme-light .chat-msg.mine {
  background: #efeaf8 !important;
  border-color: rgba(107, 91, 149, 0.28) !important;
  color: #1a1a22 !important;
  box-shadow: 0 1px 3px rgba(107, 91, 149, 0.06);
}
html.theme-light .chat-bubble.mine .who,
html.theme-light .chat-msg.mine .who {
  color: #5a4a88 !important;
}
html.theme-light .chat-bubble.system-msg,
html.theme-light .chat-msg.system-msg,
html.theme-light .chat-bubble.system {
  background: #ffffff !important;
  border: 1px dashed rgba(0, 0, 0, 0.28) !important;
  box-shadow: none !important;
  color: #1a1a22 !important;
}
html.theme-light .chat-avatar {
  background: #ececf0 !important;
  border-color: rgba(0, 0, 0, 0.1) !important;
}
html.theme-light .mention-bar .chip,
html.theme-light .mention-chips .chip,
html.theme-light #mentionChips .chip {
  background: #ffffff !important;
  border: 1px solid #d8d8de !important;
  color: #4a4a56 !important;
}
html.theme-light .mention-bar .chip:hover,
html.theme-light .mention-chips .chip:hover,
html.theme-light #mentionChips .chip:hover,
html.theme-light .mention-bar .chip.active,
html.theme-light .mention-chips .chip.active,
html.theme-light #mentionChips .chip.active {
  border-color: rgba(107, 91, 149, 0.4) !important;
  color: #4a3d78 !important;
  background: rgba(107, 91, 149, 0.08) !important;
}
html.theme-light .icon-btn.send {
  background: rgba(107, 91, 149, 0.14) !important;
  color: #4a3d78 !important;
}
html.theme-light .icon-btn.send:hover {
  background: #6b5b95 !important;
  color: #ffffff !important;
}

/* Seg / filters in chat head */
html.theme-light .seg {
  background: #f0f0f2 !important;
  border-color: #e0e0e4 !important;
}
html.theme-light .seg button.active {
  background: #ffffff !important;
  color: #1a1a22 !important;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

/* Mode menu already light; keep readable */
html.theme-light .chat-mode-menu {
  background: #ffffff !important;
  border-color: rgba(0, 0, 0, 0.12) !important;
}

/* ===== cardDiscuss1: light + mobile card discuss chip ===== */
html.theme-light .hub-card-discuss {
  background: rgba(108, 92, 231, 0.08) !important;
  border: 1px solid rgba(108, 92, 231, 0.28) !important;
  color: #5b4bb8 !important;
  box-shadow: 0 2px 8px rgba(40, 28, 70, 0.06);
}
html.theme-light .hub-card-discuss:hover,
html.theme-light .hub-card-discuss:focus-visible {
  background: rgba(108, 92, 231, 0.14) !important;
  border-color: rgba(108, 92, 231, 0.45) !important;
  color: #4738a0 !important;
}
@media (max-width: 768px) {
  body.mobile .hub-card-discuss {
    top: 10px;
    right: 10px;
    padding: 6px 12px !important;
    font-size: 12.5px !important;
  }
  body.mobile .hub-card .project-card-top {
    padding-right: 68px;
  }
}

/* ===== lightRead1: light-theme component contrast (not var-only swap) ===== */
/* Keep white/gray base + purple accents; no pink wash. */

html.theme-light {
  --muted: #3f3f4a;
}

/* —— Read receipts: dark name + clear avatar ring (fixes white-on-light) —— */
html.theme-light .chat-readers {
  color: #3a3a45 !important;
  gap: 8px;
}
html.theme-light .chat-reader {
  color: #3a3a45 !important;
}
html.theme-light .chat-reader-name {
  color: #2e2e38 !important;
  font-size: 11px !important;
  font-weight: 600 !important;
  opacity: 1 !important;
  -webkit-text-fill-color: #2e2e38 !important;
}
html.theme-light .chat-reader-av {
  border: 1.5px solid rgba(40, 28, 70, 0.35) !important;
  background: #6b5b95 !important;
  color: #ffffff !important;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.9);
}
html.theme-light .chat-reader-av img {
  border-radius: 50%;
}

/* —— Timestamps / muted / secondary chrome —— */
html.theme-light .chat-msg .when,
html.theme-light .chat-bubble .when,
html.theme-light .comment .when,
html.theme-light .hub-card-when {
  color: #4a4a56 !important;
  opacity: 1 !important;
}
html.theme-light .muted,
html.theme-light .brand .sub,
html.theme-light .chat-head-text .muted,
html.theme-light .hub-main-head .muted,
html.theme-light .workflow-strip .roles,
html.theme-light .workflow-strip .wf-brief,
html.theme-light .comp-text,
html.theme-light .thumb-label,
html.theme-light .thumb .cap,
html.theme-light .script-drop-hint,
html.theme-light .empty,
html.theme-light .chat-recall-tip,
html.theme-light .asset-row .muted,
html.theme-light .asset-row .muted.one-line,
html.theme-light .pick-card .muted,
html.theme-light .lib-card .muted,
html.theme-light .zone-title,
html.theme-light .upload-tile-cap,
html.theme-light .drop-copy,
html.theme-light .check {
  color: #3f3f4a !important;
  opacity: 1 !important;
}
html.theme-light .tab:not(.active),
html.theme-light .seg button:not(.active),
html.theme-light .ep-rail-item:not(.active) {
  color: #3f3f4a !important;
  opacity: 1 !important;
}
html.theme-light .tab.active,
html.theme-light .seg button.active,
html.theme-light .ep-rail-item.active {
  color: #1a1a22 !important;
}
html.theme-light .comp-text strong {
  color: #1a1a22 !important;
}

/* —— Ghost / secondary buttons (e.g. 参考-style chips & .btn.ghost) —— */
html.theme-light .btn.ghost,
html.theme-light .btn.secondary,
html.theme-light button.btn.ghost,
html.theme-light button.btn.secondary {
  background: #ffffff !important;
  border: 1px solid #9a9aa8 !important;
  color: #2e2e38 !important;
  opacity: 1 !important;
}
html.theme-light .btn.ghost:hover,
html.theme-light .btn.secondary:hover {
  background: rgba(107, 91, 149, 0.08) !important;
  border-color: rgba(107, 91, 149, 0.45) !important;
  color: #3d2f78 !important;
}

/* Inactive stage dots (参考 / 服装 / 人脸 …) — was too faint */
html.theme-light .stage-dot {
  color: #3a3a45 !important;
  border: 1px solid #8e8e9a !important;
  background: #ffffff !important;
  font-weight: 600;
}
html.theme-light .stage-dot.on {
  color: #3d2f78 !important;
  border-color: rgba(107, 91, 149, 0.5) !important;
  background: rgba(107, 91, 149, 0.12) !important;
}
html.theme-light .stage-dot.done {
  color: #1a7a4a !important;
  border-color: rgba(42, 159, 106, 0.5) !important;
  background: rgba(42, 159, 106, 0.12) !important;
}

/* Zone filter chips (参考服装 / 全部 …) */
html.theme-light .zf-chip {
  background: #ffffff !important;
  border: 1px solid #8e8e9a !important;
  color: #2e2e38 !important;
  font-weight: 600;
}
html.theme-light .zf-chip:hover {
  color: #3d2f78 !important;
  border-color: rgba(107, 91, 149, 0.5) !important;
  background: rgba(107, 91, 149, 0.08) !important;
}
html.theme-light .zf-chip.active {
  color: #3d2f78 !important;
  border-color: rgba(107, 91, 149, 0.55) !important;
  background: rgba(107, 91, 149, 0.14) !important;
  font-weight: 700;
}

/* Gap filters: 脸未制作 / 服装未制作 / 未加参考图 */
html.theme-light .produce-gap-filters {
  background: #f0f0f2 !important;
  border: 1px solid #d0d0d6 !important;
}
html.theme-light button.pill.gap-filter,
html.theme-light .pill.gap-filter {
  background: #ffffff !important;
  border: 1px solid #8e8e9a !important;
  color: #2e2e38 !important;
  font-weight: 600 !important;
  opacity: 1 !important;
}
html.theme-light button.pill.gap-filter:hover,
html.theme-light .pill.gap-filter:hover {
  color: #3d2f78 !important;
  border-color: rgba(107, 91, 149, 0.5) !important;
  background: rgba(107, 91, 149, 0.08) !important;
}
html.theme-light button.pill.gap-filter.active,
html.theme-light .pill.gap-filter.active {
  color: #3d2f78 !important;
  border: 1px solid rgba(107, 91, 149, 0.55) !important;
  background: rgba(107, 91, 149, 0.16) !important;
  font-weight: 700 !important;
}

/* Status / pipeline pills still readable on white */
html.theme-light .pill.need_ref,
html.theme-light .badge.pipe.need_ref {
  color: #3a3a45 !important;
  background: #f0f0f2 !important;
  border: 1px solid #9a9aa8 !important;
}
html.theme-light .mention-bar .chip,
html.theme-light .mention-chips .chip,
html.theme-light #mentionChips .chip,
html.theme-light .chat-jump-chip,
html.theme-light .mark-chip,
html.theme-light .seg button:not(.active) {
  color: #2e2e38 !important;
  border-color: #9a9aa8 !important;
  background: #ffffff !important;
}
html.theme-light .seg button:not(.active):hover,
html.theme-light .mention-bar .chip:hover,
html.theme-light .mention-chips .chip:hover {
  color: #3d2f78 !important;
  border-color: rgba(107, 91, 149, 0.45) !important;
}

/* Asset scrubber ticks: dark bars on light (was white translucent) */
html.theme-light .scrub-bar {
  background: rgba(40, 28, 70, 0.35) !important;
}
html.theme-light .scrub-tick.active .scrub-bar {
  background: #6b5b95 !important;
  box-shadow: 0 0 6px rgba(107, 91, 149, 0.35) !important;
}
html.theme-light .scrub-tick.hot .scrub-bar {
  background: #5a4a88 !important;
  box-shadow: 0 0 10px rgba(107, 91, 149, 0.4) !important;
}
html.theme-light .scrub-tip {
  background: #ffffff !important;
  border: 1px solid rgba(40, 28, 70, 0.18) !important;
  color: #1a1a22 !important;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.12) !important;
}

/* Sidebar / rail labels */
html.theme-light .ep-rail-item {
  color: #3a3a45 !important;
}
html.theme-light .icon-btn {
  color: #4a4a56 !important;
}
html.theme-light .chat-like-badge {
  color: #4a4a56 !important;
  border-color: rgba(40, 28, 70, 0.18) !important;
  background: rgba(40, 28, 70, 0.04) !important;
}


/* ===== mobileHeader1: compact phone top bar — avatar only, visible mode tabs ===== */
.brand-title-short { display: none; }
.brand-title-full { display: inline; }

@media (max-width: 768px) {
  /* 1) Avatar only — hide profile name */
  body.mobile .app-header .profile-name,
  body.mobile #profileNameLabel {
    display: none !important;
  }
  body.mobile .app-header .profile-chip {
    padding: 2px !important;
    gap: 0 !important;
    min-width: 0;
    border-radius: 50%;
  }
  body.mobile .app-header .avatar {
    width: 30px !important;
    height: 30px !important;
  }

  /* Brand: short label only; free space for mode tabs */
  body.mobile .brand-title-full { display: none !important; }
  body.mobile .brand-title-short {
    display: inline !important;
    font-size: inherit;
  }
  body.mobile .app-header .brand {
    max-width: 78px !important;
    min-width: 0 !important;
    gap: 6px !important;
    flex: 0 0 auto;
  }
  body.mobile .app-header .brand-mark {
    width: 26px !important;
    height: 26px !important;
    border-radius: 8px;
    flex: 0 0 auto;
  }
  body.mobile .app-header .brand-text {
    min-width: 0;
    max-width: 48px;
  }
  body.mobile .app-header .brand-text h1 {
    font-size: 12px !important;
    line-height: 1.15 !important;
    letter-spacing: 0 !important;
    max-width: 48px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  body.mobile .app-header .sub { display: none !important; }

  /* Hide redundant project chip on phone (name lives in short brand) */
  body.mobile .app-header .header-right #projectChip,
  body.mobile #projectChip {
    display: none !important;
  }

  /* One-row header: short brand | scrollable mode tabs | theme + avatar */
  body.mobile .app-header {
    display: grid !important;
    grid-template-columns: auto minmax(0, 1fr) auto !important;
    gap: 6px !important;
    padding: 6px 10px !important;
    align-items: center;
  }
  body.mobile .app-header .header-right {
    gap: 6px !important;
    flex-shrink: 0;
  }
  body.mobile .app-header .theme-toggle-btn {
    width: 30px !important;
    height: 30px !important;
  }

  /* 2+3) Mode tabs fill the freed center/left space; always tappable */
  body.mobile.view-workbench .app-header .header-center {
    position: static !important;
    transform: none !important;
    left: auto !important;
    justify-self: stretch !important;
    justify-content: flex-start !important;
    width: 100% !important;
    max-width: none !important;
    min-width: 0 !important;
    overflow: hidden;
    pointer-events: auto !important;
  }
  body.mobile.view-workbench .app-header .project-tabs {
    display: flex !important;
    justify-content: flex-start !important;
    justify-self: stretch !important;
    margin: 0 !important;
    width: 100% !important;
    max-width: none !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    flex-wrap: nowrap !important;
    gap: 2px !important;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    mask-image: linear-gradient(90deg, #000 0%, #000 calc(100% - 18px), transparent 100%);
    -webkit-mask-image: linear-gradient(90deg, #000 0%, #000 calc(100% - 18px), transparent 100%);
  }
  body.mobile.view-workbench .app-header .project-tabs::-webkit-scrollbar { display: none; }
  body.mobile.view-workbench .app-header .project-tabs .tab {
    flex: 0 0 auto !important;
    font-size: 12px !important;
    padding: 5px 9px !important;
    line-height: 1.2;
  }

  /* Home: keep nav readable; still avatar-only on the right */
  body.mobile.view-home .app-header .header-center {
    justify-content: center !important;
  }
}

/* light theme: keep short brand / tabs readable (inherits lightRead1) */
html.theme-light body.mobile .app-header .brand-text h1,
html.theme-light body.mobile .brand-title-short {
  color: #1a1a22 !important;
}
html.theme-light body.mobile.view-workbench .app-header .project-tabs .tab {
  color: #3f3f4a !important;
}
html.theme-light body.mobile.view-workbench .app-header .project-tabs .tab.active {
  color: #3d2f78 !important;
}

/* ==== toastTopLight1: top-center toast + light theme ==== */
html.theme-light .toast {
  background: #ffffff;
  color: #1a1a22;
  border: 1px solid #d8d8de;
  box-shadow: 0 10px 32px rgba(0, 0, 0, 0.12), 0 2px 8px rgba(0, 0, 0, 0.06);
}
html.theme-light .toast.toast-ok {
  background: #f4fbf7;
  color: #1a6b45;
  border-color: rgba(42, 159, 106, 0.45);
}
html.theme-light .toast.toast-err {
  background: #fff6f6;
  color: #a83232;
  border-color: rgba(208, 69, 69, 0.45);
}


/* ===== saZoomLite1: script analysis font slider (independent of asset zoom) ===== */
.sa-font-zoom {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-left: 4px;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  font-size: 11px;
  font-weight: 500;
  line-height: 1;
  user-select: none;
}
.sa-font-zoom-label,
.sa-font-zoom-val {
  color: rgba(232, 228, 255, 0.78);
  font-weight: 500;
  letter-spacing: 0.02em;
}
.sa-font-zoom-val {
  min-width: 1.6em;
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
}
/* Reset global dark range look — own track/thumb for script only */
.sa-font-zoom .sa-font-zoom-range,
.sa-font-zoom input[type="range"].sa-font-zoom-range {
  -webkit-appearance: none;
  appearance: none;
  width: 92px;
  height: 14px;
  margin: 0;
  padding: 0;
  background: transparent !important;
  border: 0;
  outline: none;
  cursor: pointer;
  accent-color: #a894e8;
}
.sa-font-zoom .sa-font-zoom-range::-webkit-slider-runnable-track {
  height: 3px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.18) !important;
  border: 0;
}
.sa-font-zoom .sa-font-zoom-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 12px;
  height: 12px;
  margin-top: -4.5px;
  border-radius: 50%;
  background: #c8b8f0;
  border: 1px solid rgba(255, 255, 255, 0.35);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
  cursor: pointer;
}
.sa-font-zoom .sa-font-zoom-range::-moz-range-track {
  height: 3px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.18) !important;
  border: 0;
}
.sa-font-zoom .sa-font-zoom-range::-moz-range-thumb {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #c8b8f0;
  border: 1px solid rgba(255, 255, 255, 0.35);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
  cursor: pointer;
}

/* Light theme — restrained, premium, not candy-pink */
html.theme-light .sa-font-zoom,
html.theme-light label.script-font-ctrl.sa-font-zoom {
  background: #f3f3f5 !important;
  border: 1px solid rgba(0, 0, 0, 0.08) !important;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
  color: #3a3a44 !important;
}
html.theme-light .sa-font-zoom .sa-font-zoom-label,
html.theme-light .sa-font-zoom .sa-font-zoom-val,
html.theme-light .sa-font-zoom .muted {
  color: #5a5a66 !important;
  font-weight: 500;
}
html.theme-light .sa-font-zoom .sa-font-zoom-range,
html.theme-light .sa-font-zoom input[type="range"].sa-font-zoom-range {
  background: transparent !important;
  accent-color: #8b7eb5;
}
html.theme-light .sa-font-zoom .sa-font-zoom-range::-webkit-slider-runnable-track {
  height: 3px;
  border-radius: 999px;
  background: #d8d8de !important;
  border: 0;
  box-shadow: none;
}
html.theme-light .sa-font-zoom .sa-font-zoom-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 13px;
  height: 13px;
  margin-top: -5px;
  border-radius: 50%;
  background: #f7f6fa;
  border: 1px solid rgba(107, 91, 149, 0.35);
  box-shadow: 0 1px 3px rgba(40, 28, 70, 0.14), 0 0 0 1px rgba(255, 255, 255, 0.6) inset;
  cursor: pointer;
}
html.theme-light .sa-font-zoom .sa-font-zoom-range::-moz-range-track {
  height: 3px;
  border-radius: 999px;
  background: #d8d8de !important;
  border: 0;
}
html.theme-light .sa-font-zoom .sa-font-zoom-range::-moz-range-thumb {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: #f7f6fa;
  border: 1px solid rgba(107, 91, 149, 0.35);
  box-shadow: 0 1px 3px rgba(40, 28, 70, 0.14);
  cursor: pointer;
}
html.theme-light .sa-font-zoom .sa-font-zoom-range:hover::-webkit-slider-thumb {
  border-color: rgba(107, 91, 149, 0.5);
  box-shadow: 0 2px 5px rgba(40, 28, 70, 0.18), 0 0 0 1px rgba(255, 255, 255, 0.7) inset;
}
html.theme-light .sa-font-zoom .sa-font-zoom-range:active::-webkit-slider-thumb {
  background: #efeaf8;
}



/* soonModes1 — 分镜制作 / 视频审片 待开放 */
.tab.tab-soon,
.chat-mode-menu .mode-soon {
  opacity: 0.88;
}
.soon-badge {
  display: inline-flex;
  align-items: center;
  margin-left: 6px;
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 650;
  letter-spacing: 0.04em;
  line-height: 1.4;
  color: #8a6b2e;
  background: rgba(212, 168, 75, 0.18);
  border: 1px solid rgba(212, 168, 75, 0.35);
  vertical-align: middle;
}
.chat-mode-menu .mode-soon .soon-badge {
  margin-left: 8px;
}
.soon-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 8px;
  min-height: min(56vh, 480px);
  margin: 8px 0 24px;
  padding: 48px 28px;
  border-radius: 22px;
  border: 1px solid rgba(155, 123, 255, 0.22);
  background:
    radial-gradient(420px 240px at 50% 28%, rgba(155, 123, 255, 0.14), transparent 62%),
    radial-gradient(320px 180px at 70% 80%, rgba(212, 168, 75, 0.08), transparent 55%),
    rgba(18, 20, 28, 0.45);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.04) inset;
}
.soon-mark {
  width: 64px;
  height: 64px;
  display: grid;
  place-items: center;
  margin-bottom: 6px;
  font-size: 28px;
  border-radius: 18px;
  background: linear-gradient(145deg, rgba(155, 123, 255, 0.28), rgba(212, 168, 75, 0.2));
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.22);
}
.soon-eyebrow {
  margin: 0;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.16em;
  color: var(--muted);
}
.soon-title {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.soon-lead {
  margin: 4px 0 0;
  font-size: 15px;
  font-weight: 550;
  color: var(--text);
}
.soon-hint {
  margin: 4px 0 0;
  max-width: 380px;
  font-size: 13px;
  line-height: 1.65;
  color: var(--muted);
}
.soon-legacy.hidden { display: none !important; }

html.theme-light .soon-badge {
  color: #7a5a1a;
  background: rgba(212, 168, 75, 0.16);
  border-color: rgba(180, 140, 50, 0.32);
}
html.theme-light .soon-panel {
  border-color: rgba(120, 100, 180, 0.18);
  background:
    radial-gradient(420px 240px at 50% 28%, rgba(155, 123, 255, 0.1), transparent 62%),
    radial-gradient(320px 180px at 70% 80%, rgba(212, 168, 75, 0.07), transparent 55%),
    #f7f5fb;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.9) inset,
    0 12px 32px rgba(40, 36, 60, 0.06);
}
html.theme-light .soon-mark {
  background: linear-gradient(145deg, rgba(155, 123, 255, 0.18), rgba(212, 168, 75, 0.16));
  border-color: rgba(100, 90, 140, 0.12);
  box-shadow: 0 8px 20px rgba(60, 50, 90, 0.08);
}
html.theme-light .soon-title {
  color: #1c1a24;
}
html.theme-light .soon-lead {
  color: #2a2734;
}
html.theme-light .soon-hint,
html.theme-light .soon-eyebrow {
  color: #6b6578;
}
html.theme-light .tab.tab-soon {
  opacity: 0.92;
}

/* ===== lightboxMobile1: centered full-bleed preview (mobile + desktop) ===== */
.lightbox {
  position: fixed !important;
  inset: 0 !important;
  left: 0 !important;
  right: 0 !important;
  top: 0 !important;
  bottom: 0 !important;
  width: 100% !important;
  height: 100% !important;
  max-width: 100vw !important;
  max-height: 100dvh !important;
  z-index: 10000 !important;
  margin: 0 !important;
  box-sizing: border-box !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  padding:
    max(12px, env(safe-area-inset-top, 0px))
    max(12px, env(safe-area-inset-right, 0px))
    max(12px, env(safe-area-inset-bottom, 0px))
    max(12px, env(safe-area-inset-left, 0px)) !important;
  overflow: hidden !important;
  background: rgba(0, 0, 0, 0.82) !important;
  -webkit-tap-highlight-color: transparent;
}
.lightbox.hidden { display: none !important; }
.lightbox img,
.lightbox #lightboxImg {
  display: block !important;
  box-sizing: border-box !important;
  width: auto !important;
  height: auto !important;
  max-width: min(100%, calc(100vw - 24px - env(safe-area-inset-left, 0px) - env(safe-area-inset-right, 0px))) !important;
  max-height: min(100%, calc(100dvh - 24px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px))) !important;
  object-fit: contain !important;
  object-position: center center !important;
  margin: 0 auto !important;
  border-radius: 12px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
  background: #0a0a0c !important;
  pointer-events: auto;
}
.lightbox-close,
#btnLightboxClose {
  position: fixed !important;
  top: max(12px, env(safe-area-inset-top, 0px)) !important;
  right: max(12px, env(safe-area-inset-right, 0px)) !important;
  left: auto !important;
  bottom: auto !important;
  z-index: 10001 !important;
  width: 40px !important;
  height: 40px !important;
  border-radius: 50% !important;
  border: 1px solid rgba(255, 255, 255, 0.3) !important;
  background: rgba(0, 0, 0, 0.55) !important;
  color: #fff !important;
  font-size: 24px !important;
  line-height: 1 !important;
  cursor: pointer !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  padding: 0 !important;
}
html.theme-light .lightbox {
  background: rgba(20, 18, 28, 0.78) !important;
}
html.theme-light .lightbox img,
html.theme-light .lightbox #lightboxImg {
  background: #fff !important;
  box-shadow: 0 12px 40px rgba(40, 36, 60, 0.28);
}
html.theme-light .lightbox-close,
html.theme-light #btnLightboxClose {
  background: rgba(255, 255, 255, 0.92) !important;
  color: #1a1a22 !important;
  border-color: rgba(40, 28, 70, 0.18) !important;
}
.chat-msg-img,
.chat-album-cell,
[data-chat-img][data-lightbox] {
  cursor: zoom-in !important;
}

.thumb-badge.backup{background:#c9a227;color:#fff;}

/* shareAdmin1 */
.auth-share-hint {
  margin: 8px 0 0;
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(155, 123, 255, 0.12);
  color: #5b4a9e;
  font-size: 13px;
  line-height: 1.4;
}
html.theme-light .auth-share-hint {
  background: #f3eefc;
  color: #4a3a86;
  border: 1px solid #e4daf8;
}
.project-card.hub-card { position: relative; }
.hub-card-share {
  position: absolute;
  top: 12px;
  right: 72px;
  z-index: 2;
}
.share-link-row {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 6px;
}
.share-link-row input { flex: 1; min-width: 0; font-size: 12px; }
.modal-share select {
  width: 100%;
  margin-top: 6px;
  padding: 8px 10px;
  border-radius: 10px;
}

/* ===== projLogo2: transparent drama logo on project cards (no black plate) ===== */
.hub-card.has-logo .project-card-top {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.hub-card-logo-wrap {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  width: 100%;
  padding: 0;
  background: transparent;
  border: none;
  box-shadow: none;
  overflow: visible;
}
.hub-card-logo {
  display: block;
  width: auto;
  max-width: 100%;
  height: auto;
  max-height: 72px;
  object-fit: contain;
  object-position: left center;
  pointer-events: none;
  user-select: none;
  -webkit-user-drag: none;
  background: transparent;
}
.hub-card.has-logo .hub-card-aka {
  margin-top: 2px;
}
html.theme-light .hub-card-logo-wrap {
  background: transparent;
  border: none;
  box-shadow: none;
}
@media (max-width: 768px) {
  .hub-card-logo-wrap {
    padding: 0;
  }
  .hub-card-logo {
    max-height: 56px;
  }
}


/* ===== hubCard1: denser project card — larger type, metrics row, no empty right void ===== */
.project-card.hub-card,
.hub-card {
  padding: 20px 20px 18px 22px !important;
  gap: 0 !important;
  min-height: 0;
}
.hub-card-inner {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas:
    "brand actions"
    "metrics metrics"
    "foot foot";
  gap: 14px 16px;
  align-items: start;
  width: 100%;
  min-width: 0;
}
.hub-card-brand {
  grid-area: brand;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
  padding-right: 4px;
}
.hub-card-brand h3 {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0.01em;
  line-height: 1.25;
}
.hub-card-aka {
  display: block !important;
  font-size: 14px !important;
  line-height: 1.45 !important;
  color: var(--muted) !important;
  opacity: 1 !important;
  font-weight: 500;
  letter-spacing: 0.02em;
}
.hub-card-actions {
  grid-area: actions;
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: flex-start;
  gap: 8px;
  position: relative;
  z-index: 3;
}
/* Unstick absolute share/discuss — they live in actions row now */
.hub-card-share,
.hub-card-discuss {
  position: static !important;
  top: auto !important;
  right: auto !important;
  margin: 0 !important;
  padding: 7px 14px !important;
  font-size: 13px !important;
  font-weight: 600 !important;
  border-radius: 999px !important;
  line-height: 1.2 !important;
  white-space: nowrap;
}
.hub-card-metrics {
  grid-area: metrics;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  width: 100%;
}
.hub-metric {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 14px 10px 12px;
  border-radius: 14px;
  background: rgba(155, 123, 255, 0.1);
  border: 1px solid rgba(155, 123, 255, 0.22);
  text-align: center;
  min-width: 0;
  transition: border-color .15s ease, background .15s ease;
}
.hub-card:hover .hub-metric {
  border-color: rgba(155, 123, 255, 0.36);
  background: rgba(155, 123, 255, 0.14);
}
.hub-metric strong {
  display: block;
  font-size: 24px;
  font-weight: 750;
  letter-spacing: -0.02em;
  line-height: 1.1;
  color: #f2eeff;
  font-variant-numeric: tabular-nums;
}
.hub-metric span {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: var(--muted);
  opacity: 0.95;
}
/* Hide legacy pills if any leftover */
.hub-card .project-stats { display: none !important; }
.hub-card .project-card-top { display: none !important; padding-right: 0 !important; }

.hub-card-foot {
  grid-area: foot;
  display: flex !important;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 2px;
  padding-top: 2px;
}
.hub-card-when {
  font-size: 12.5px !important;
  color: var(--muted) !important;
  opacity: 0.92 !important;
  line-height: 1.4;
  min-width: 0;
}
.hub-card-open {
  flex: 0 0 auto;
  padding: 9px 22px !important;
  font-size: 14px !important;
  font-weight: 650 !important;
  border-radius: 11px !important;
  min-width: 88px;
  box-shadow: 0 6px 18px rgba(155, 123, 255, 0.28);
}

/* Logo: larger, still transparent plate */
.hub-card-logo-wrap {
  display: flex !important;
  align-items: center;
  justify-content: flex-start;
  width: 100%;
  max-width: 100%;
  padding: 0 !important;
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  overflow: visible !important;
}
.hub-card-logo {
  display: block !important;
  width: auto !important;
  max-width: min(100%, 340px) !important;
  height: auto !important;
  max-height: 88px !important;
  object-fit: contain !important;
  object-position: left center !important;
  background: transparent !important;
}
.hub-card.has-logo .hub-card-brand {
  gap: 10px;
}

/* Single card: a bit wider so metrics breathe */
body.view-home .project-card.hub-card {
  width: min(100%, 640px) !important;
}

/* —— Light theme —— */
html.theme-light .hub-metric {
  background: #f3f1f8 !important;
  border-color: rgba(107, 91, 149, 0.18) !important;
}
html.theme-light .hub-card:hover .hub-metric {
  background: #ebe7f4 !important;
  border-color: rgba(107, 91, 149, 0.32) !important;
}
html.theme-light .hub-metric strong {
  color: #2a2248 !important;
}
html.theme-light .hub-metric span {
  color: #5a5a66 !important;
}
html.theme-light .hub-card-aka {
  color: #4a4a56 !important;
}
html.theme-light .hub-card-when {
  color: #4a4a56 !important;
  opacity: 1 !important;
}
html.theme-light .hub-card-share,
html.theme-light .hub-card-discuss {
  background: rgba(108, 92, 231, 0.08) !important;
  border: 1px solid rgba(108, 92, 231, 0.28) !important;
  color: #5b4bb8 !important;
  box-shadow: 0 2px 8px rgba(40, 28, 70, 0.06);
}
html.theme-light .hub-card-share:hover,
html.theme-light .hub-card-discuss:hover,
html.theme-light .hub-card-share:focus-visible,
html.theme-light .hub-card-discuss:focus-visible {
  background: rgba(108, 92, 231, 0.14) !important;
  border-color: rgba(108, 92, 231, 0.45) !important;
  color: #4738a0 !important;
}
html.theme-light .hub-card-open {
  box-shadow: 0 4px 14px rgba(107, 91, 149, 0.28) !important;
}

/* —— Mobile / WeChat compact —— */
@media (max-width: 768px) {
  .project-card.hub-card,
  .hub-card {
    padding: 16px 14px 14px 16px !important;
  }
  .hub-card-inner {
    grid-template-columns: 1fr;
    grid-template-areas:
      "brand"
      "actions"
      "metrics"
      "foot";
    gap: 12px;
  }
  .hub-card-actions {
    justify-content: flex-start;
  }
  .hub-card-brand h3 {
    font-size: 18px;
  }
  .hub-card-aka {
    font-size: 13.5px !important;
  }
  .hub-metric {
    padding: 12px 6px 10px;
    border-radius: 12px;
  }
  .hub-metric strong {
    font-size: 20px;
  }
  .hub-metric span {
    font-size: 11.5px;
    letter-spacing: 0.04em;
  }
  .hub-card-logo {
    max-height: 64px !important;
    max-width: min(100%, 280px) !important;
  }
  .hub-card-open {
    padding: 8px 18px !important;
    font-size: 13.5px !important;
    min-width: 76px;
  }
  .hub-card-when {
    font-size: 12px !important;
  }
  body.view-home .project-card.hub-card,
  body.mobile.view-home .project-card.hub-card {
    width: 100% !important;
    max-width: 520px !important;
  }
}


/* hubCard1: beat older body.mobile absolute discuss chip sizing */
@media (max-width: 768px) {
  body.mobile .hub-card-share,
  body.mobile .hub-card-discuss,
  body.mobile.view-home .hub-card-share,
  body.mobile.view-home .hub-card-discuss {
    position: static !important;
    top: auto !important;
    right: auto !important;
    padding: 7px 13px !important;
    font-size: 13px !important;
    font-weight: 600 !important;
  }
  body.mobile .hub-card .project-card-top,
  body.mobile.view-home .hub-card .project-card-top {
    display: none !important;
    padding-right: 0 !important;
  }
}

/* ========================================================================
   uiRev1 + hubBg2 — 即风·协作台 visual; hubBg2 = clean premium ambient
   Append-only overrides; preserve all feature structures (hubCard1, chat, etc.)
   ======================================================================== */

:root {
  --jf-purple: #8b6cff;
  --jf-purple-strong: #a78bfa;
  --jf-purple-deep: #6d4dff;
  --jf-navy: #070b16;
  --jf-charcoal: #0e1424;
  --jf-glass: rgba(16, 22, 38, 0.72);
  --jf-glass-border: rgba(167, 139, 250, 0.18);
  --jf-wind: rgba(110, 198, 255, 0.14);
  --btn-accent: #8b6cff;
  --btn-accent-2: #6d4dff;
  --radius-lg: 20px;
}

/* —— hubBg2: clean premium ambient (soft wash, no carnival FX) —— */
.jf-ambient {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
  background:
    radial-gradient(1000px 620px at 12% -6%, rgba(109, 77, 255, 0.10), transparent 58%),
    radial-gradient(860px 520px at 88% 4%, rgba(110, 198, 255, 0.06), transparent 55%),
    radial-gradient(720px 480px at 50% 108%, rgba(255, 255, 255, 0.03), transparent 60%),
    linear-gradient(165deg, #070b16 0%, #0c1220 48%, #0a0f18 100%);
}
.jf-ambient-wash {
  position: absolute;
  inset: -8%;
  background:
    radial-gradient(ellipse 55% 42% at 22% 28%, rgba(139, 108, 255, 0.14), transparent 72%),
    radial-gradient(ellipse 48% 38% at 78% 22%, rgba(110, 198, 255, 0.08), transparent 70%);
  filter: blur(40px);
  opacity: 0.85;
}
.jf-ambient-aurora,
.jf-ambient-wind,
.jf-ambient-orbs,
.jf-ambient-grid,
.jf-ambient-sheen {
  display: none !important;
}

@media (prefers-reduced-motion: no-preference) {
  .jf-ambient-wash {
    animation: jfWashDrift 48s ease-in-out infinite alternate;
  }
}
@keyframes jfWashDrift {
  0% { transform: translate3d(0, 0, 0) scale(1); opacity: 0.78; }
  100% { transform: translate3d(1.2%, -0.8%, 0) scale(1.03); opacity: 0.9; }
}
@media (prefers-reduced-motion: reduce) {
  .jf-ambient-wash {
    animation: none !important;
  }
}

/* Keep ambient behind UI; soften in workbench for readability */
.app-frame { position: relative; z-index: 1; }
body.view-workbench .jf-ambient {
  opacity: 0.38;
}
body.view-workbench .jf-ambient-wash {
  opacity: 0.55;
}
body.view-home .jf-ambient,
body.auth-locked .jf-ambient {
  opacity: 1;
}

/* Body background becomes transparent so ambient shows through */
html, body {
  background: transparent !important;
}
html body {
  min-height: 100vh;
  color: var(--text);
}
/* Fallback solid under ambient for safety */
html:not(.theme-light) {
  background: #070b16 !important;
}

/* —— Dark theme editorial polish —— */
html:not(.theme-light) {
  --bg: #070b16;
  --bg-elevated: #0e1424;
  --panel: rgba(18, 24, 40, 0.78);
  --panel2: rgba(24, 32, 52, 0.88);
  --panel3: #1c2640;
  --border: rgba(140, 160, 220, 0.16);
  --border-soft: rgba(255, 255, 255, 0.07);
  --text: #f3f5fb;
  --muted: #9aa6c0;
  --flash: #a78bfa;
  --accent2: #8da4ff;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
}

html:not(.theme-light) .app-header {
  background: rgba(8, 12, 24, 0.72) !important;
  border-bottom: 1px solid var(--jf-glass-border) !important;
  backdrop-filter: blur(18px) saturate(1.25);
  -webkit-backdrop-filter: blur(18px) saturate(1.25);
  box-shadow: 0 8px 32px rgba(0,0,0,0.25);
}
html:not(.theme-light) .brand-mark {
  background: linear-gradient(135deg, #8b6cff, #6ec6ff 70%, #d4a574) !important;
  box-shadow: 0 0 0 1px rgba(255,255,255,.14), 0 10px 28px rgba(139,108,255,.35) !important;
}
html:not(.theme-light) .brand h1 {
  background: linear-gradient(100deg, #f5f0ff 10%, #a78bfa 55%, #6ec6ff 100%) !important;
  -webkit-background-clip: text !important;
  background-clip: text !important;
  color: transparent !important;
  font-size: 18px;
  letter-spacing: 0.04em;
}
html:not(.theme-light) .brand .sub {
  letter-spacing: 0.12em;
  font-size: 11px;
  text-transform: uppercase;
  opacity: 0.85;
}

/* Primary buttons — purple accent only on emphasis */
.btn.primary,
button.btn.primary {
  background: linear-gradient(135deg, var(--btn-accent), var(--btn-accent-2)) !important;
  border: 1px solid rgba(167, 139, 250, 0.45) !important;
  color: #fff !important;
  box-shadow: 0 8px 24px rgba(109, 77, 255, 0.35) !important;
  font-weight: 650;
  letter-spacing: 0.01em;
}
.btn.primary:hover,
button.btn.primary:hover {
  filter: brightness(1.08);
  box-shadow: 0 10px 30px rgba(109, 77, 255, 0.45) !important;
}
.hub-cta {
  box-shadow: 0 10px 32px rgba(109, 77, 255, 0.4) !important;
}

/* Hub hero — cinematic editorial */
.hub-hero {
  position: relative;
  padding: 28px 8px 18px;
}
.hub-hero .eyebrow {
  letter-spacing: 0.22em;
  font-size: 11px;
  color: var(--jf-purple-strong);
  font-weight: 650;
}
.hub-hero-title {
  font-size: clamp(28px, 4vw, 40px) !important;
  font-weight: 780 !important;
  letter-spacing: -0.02em !important;
  line-height: 1.15 !important;
  margin: 8px 0 10px !important;
}
html:not(.theme-light) .hub-hero-title {
  background: linear-gradient(105deg, #ffffff 0%, #c4b5fd 45%, #7dd3fc 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.hub-hero-tip {
  font-size: 14.5px !important;
  max-width: 36em;
  line-height: 1.55;
}
.hub-main-head .page-title {
  font-size: 22px !important;
  font-weight: 720 !important;
  letter-spacing: -0.015em;
}

/* Glass hub cards */
html:not(.theme-light) .project-card.hub-card,
html:not(.theme-light) .hub-card {
  background: linear-gradient(165deg, rgba(28, 34, 56, 0.82), rgba(14, 18, 32, 0.88)) !important;
  border: 1px solid rgba(167, 139, 250, 0.16) !important;
  backdrop-filter: blur(16px) saturate(1.15);
  -webkit-backdrop-filter: blur(16px) saturate(1.15);
  box-shadow:
    0 16px 48px rgba(0, 0, 0, 0.35),
    0 1px 0 rgba(255,255,255,0.05) inset !important;
  border-radius: 18px !important;
}
html:not(.theme-light) .hub-card:hover,
html:not(.theme-light) .hub-card:focus-visible {
  border-color: rgba(167, 139, 250, 0.42) !important;
  box-shadow:
    0 22px 56px rgba(0, 0, 0, 0.42),
    0 0 0 1px rgba(139, 108, 255, 0.2),
    0 0 40px rgba(109, 77, 255, 0.18) !important;
  transform: translateY(-2px);
}
.hub-card-accent {
  background: linear-gradient(180deg, #8b6cff, #6ec6ff) !important;
  width: 3px !important;
  opacity: 0.95;
}

/* Empty state */
.hub-empty {
  border-radius: 20px !important;
  border: 1px dashed rgba(167, 139, 250, 0.35) !important;
  background:
    radial-gradient(500px 240px at 50% 0%, rgba(139,108,255,0.16), transparent 70%),
    rgba(12, 16, 28, 0.55) !important;
  backdrop-filter: blur(12px);
  padding: 48px 28px !important;
}
.hub-empty h3 {
  font-size: 20px !important;
  font-weight: 720;
}

/* Auth gate — premium glass over ambient */
.auth-gate {
  background: rgba(4, 8, 18, 0.35) !important;
  backdrop-filter: blur(8px) !important;
}
.auth-card {
  background: linear-gradient(165deg, rgba(28, 34, 58, 0.92), rgba(12, 16, 30, 0.94)) !important;
  border: 1px solid rgba(167, 139, 250, 0.28) !important;
  border-radius: 22px !important;
  box-shadow:
    0 28px 80px rgba(0, 0, 0, 0.55),
    0 0 60px rgba(109, 77, 255, 0.18),
    inset 0 1px 0 rgba(255,255,255,0.06) !important;
  backdrop-filter: blur(20px) saturate(1.2);
  -webkit-backdrop-filter: blur(20px) saturate(1.2);
}
.auth-brand h2 {
  font-size: 22px !important;
  letter-spacing: 0.04em;
  background: linear-gradient(100deg, #fff, #c4b5fd);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.auth-tab.active {
  background: rgba(139, 108, 255, 0.28) !important;
  box-shadow: 0 0 0 1px rgba(167, 139, 250, 0.25);
}
.auth-form input:focus {
  outline: none;
  border-color: rgba(139, 108, 255, 0.55);
  box-shadow: 0 0 0 3px rgba(139, 108, 255, 0.2);
}

/* Profile popover glass */
.profile-popover {
  background: linear-gradient(165deg, rgba(30, 36, 58, 0.96), rgba(14, 18, 32, 0.98)) !important;
  border: 1px solid rgba(167, 139, 250, 0.22) !important;
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

/* Chat dock glass (dark) */
html:not(.theme-light) #globalChat .chat-dock-panel,
html:not(.theme-light) .chat-dock-panel {
  background: rgba(12, 16, 28, 0.88) !important;
  border-color: rgba(167, 139, 250, 0.14) !important;
  backdrop-filter: blur(16px) saturate(1.1);
  -webkit-backdrop-filter: blur(16px) saturate(1.1);
}
html:not(.theme-light) .chat-fab {
  background: linear-gradient(135deg, #8b6cff, #6d4dff) !important;
  box-shadow: 0 10px 28px rgba(109, 77, 255, 0.4);
}

/* Toast — light-aware, top already */
html:not(.theme-light) .toast {
  background: linear-gradient(135deg, rgba(36, 32, 58, 0.96), rgba(20, 28, 48, 0.96)) !important;
  border: 1px solid rgba(167, 139, 250, 0.35) !important;
  backdrop-filter: blur(12px);
}
html.theme-light .toast {
  background: rgba(255, 255, 255, 0.96) !important;
  border: 1px solid rgba(0, 0, 0, 0.1) !important;
  color: #1a1a22 !important;
  box-shadow: 0 12px 36px rgba(40, 28, 70, 0.14) !important;
}
html.theme-light .toast.toast-ok { color: #1a7a4c !important; border-color: rgba(42, 159, 106, 0.4) !important; }
html.theme-light .toast.toast-err { color: #c0392b !important; border-color: rgba(208, 69, 69, 0.4) !important; }

/* Tabs / nav active — purple emphasis */
html:not(.theme-light) .tab.active {
  color: #12081c !important;
  background: linear-gradient(135deg, #c4b5fd, #8b6cff) !important;
  box-shadow: 0 8px 22px rgba(109, 77, 255, 0.35) !important;
}
html:not(.theme-light) .app-nav-btn.active {
  color: #eae4ff !important;
  background: rgba(139, 108, 255, 0.22) !important;
  border-color: rgba(167, 139, 250, 0.35) !important;
}

/* Theme toggle polish */
.theme-toggle-btn {
  border-radius: 12px !important;
  transition: background .15s ease, border-color .15s ease, transform .15s ease;
}
.theme-toggle-btn:hover { transform: translateY(-1px); }

/* —— Light theme: clean white-gray high contrast (no pink wash) —— */
html.theme-light {
  --bg: #f4f5f8;
  --bg-elevated: #ffffff;
  --panel: #ffffff;
  --panel2: #f0f1f5;
  --panel3: #e8eaef;
  --border: #d8dbe3;
  --border-soft: rgba(20, 24, 40, 0.08);
  --text: #141822;
  --muted: #5c6478;
  --accent: #6d4dff;
  --accent-strong: #5a3fe0;
  --accent-rose: #6b5b95;
  --rose: #5b4bb8;
  --accent2: #4f6ef7;
  --flash: #6d4dff;
  --gold-glow: rgba(109, 77, 255, 0.12);
  --rose-glow: rgba(109, 77, 255, 0.1);
  --btn-accent: #6d4dff;
  --btn-accent-2: #5a3fe0;
}
html.theme-light .jf-ambient {
  background:
    radial-gradient(980px 560px at 8% -10%, rgba(109, 77, 255, 0.06), transparent 58%),
    radial-gradient(820px 480px at 92% 0%, rgba(79, 110, 247, 0.045), transparent 55%),
    linear-gradient(180deg, #f8f9fb 0%, #f1f2f6 55%, #eceef3 100%) !important;
}
html.theme-light .jf-ambient-wash {
  background:
    radial-gradient(ellipse 50% 40% at 20% 20%, rgba(109, 77, 255, 0.07), transparent 70%),
    radial-gradient(ellipse 45% 35% at 80% 15%, rgba(79, 110, 247, 0.05), transparent 68%);
  opacity: 0.7;
  filter: blur(48px);
}
html.theme-light,
html.theme-light body {
  background: transparent !important;
  color: var(--text);
}
html.theme-light {
  background: #f4f5f8 !important;
}
html.theme-light .app-header {
  background: rgba(255, 255, 255, 0.82) !important;
  border-bottom: 1px solid rgba(20, 24, 40, 0.08) !important;
  backdrop-filter: blur(16px) saturate(1.15);
  -webkit-backdrop-filter: blur(16px) saturate(1.15);
  box-shadow: 0 1px 0 rgba(255,255,255,0.9), 0 8px 28px rgba(40, 28, 70, 0.05);
}
html.theme-light .brand-mark {
  background: linear-gradient(135deg, #6d4dff, #4f6ef7 65%, #6ec6ff) !important;
  box-shadow: 0 0 0 1px rgba(109,77,255,.2), 0 8px 20px rgba(109,77,255,.22) !important;
}
html.theme-light .brand h1 {
  background: none !important;
  -webkit-background-clip: unset !important;
  background-clip: unset !important;
  color: #141822 !important;
  font-weight: 780;
}
html.theme-light .hub-hero-title {
  background: none !important;
  -webkit-background-clip: unset !important;
  background-clip: unset !important;
  color: #141822 !important;
}
html.theme-light .hub-hero .eyebrow {
  color: #5a3fe0;
}
html.theme-light .project-card.hub-card,
html.theme-light .hub-card {
  background: rgba(255, 255, 255, 0.92) !important;
  border: 1px solid rgba(20, 24, 40, 0.1) !important;
  box-shadow:
    0 12px 36px rgba(40, 28, 70, 0.07),
    0 1px 0 rgba(255,255,255,0.95) inset !important;
  backdrop-filter: blur(12px);
}
html.theme-light .hub-card:hover,
html.theme-light .hub-card:focus-visible {
  border-color: rgba(109, 77, 255, 0.35) !important;
  box-shadow:
    0 18px 48px rgba(40, 28, 70, 0.12),
    0 0 0 1px rgba(109, 77, 255, 0.12),
    0 0 28px rgba(109, 77, 255, 0.1) !important;
}
html.theme-light .auth-gate {
  background: rgba(244, 245, 248, 0.35) !important;
}
html.theme-light .auth-card {
  background: rgba(255, 255, 255, 0.94) !important;
  border: 1px solid rgba(20, 24, 40, 0.1) !important;
  box-shadow: 0 24px 64px rgba(40, 28, 70, 0.14) !important;
  color: var(--text);
}
html.theme-light .auth-brand h2 {
  background: none !important;
  -webkit-background-clip: unset !important;
  background-clip: unset !important;
  color: #141822 !important;
}
html.theme-light .auth-form input {
  background: #f4f5f8 !important;
  border-color: var(--border) !important;
  color: var(--text) !important;
}
html.theme-light .auth-tab.active {
  background: rgba(109, 77, 255, 0.12) !important;
  color: #3d2f78 !important;
}
html.theme-light .profile-popover {
  background: rgba(255, 255, 255, 0.97) !important;
  border: 1px solid rgba(20, 24, 40, 0.1) !important;
  color: var(--text);
  box-shadow: 0 18px 48px rgba(40, 28, 70, 0.14) !important;
}
html.theme-light .profile-popover input[type="text"],
html.theme-light .profile-popover input[type="password"] {
  background: #f4f5f8 !important;
  border-color: var(--border) !important;
  color: var(--text) !important;
}
html.theme-light .hub-empty {
  background:
    radial-gradient(480px 220px at 50% 20%, rgba(109,77,255,0.08), transparent 65%),
    rgba(255,255,255,0.75) !important;
  border-color: rgba(109, 77, 255, 0.25) !important;
}
html.theme-light .tab.active {
  color: #fff !important;
  background: linear-gradient(135deg, #6d4dff, #5a3fe0) !important;
  box-shadow: 0 8px 20px rgba(109, 77, 255, 0.28) !important;
}
html.theme-light body.view-workbench .jf-ambient {
  opacity: 0.55;
}

/* Workbench panels — subtle glass without hurting readability */
html:not(.theme-light) body.view-workbench .panel,
html:not(.theme-light) body.view-workbench .panel-produce {
  background: rgba(14, 18, 32, 0.55);
  border-color: rgba(140, 160, 220, 0.12);
}
html.theme-light body.view-workbench .panel,
html.theme-light body.view-workbench .panel-produce {
  background: rgba(255, 255, 255, 0.88);
  border-color: rgba(20, 24, 40, 0.08);
}

/* —— Avatar crop modal —— */
body.avatar-crop-open {
  overflow: hidden;
}
.avatar-crop-modal {
  position: fixed;
  inset: 0;
  z-index: 260;
  display: grid;
  place-items: center;
  padding: 16px;
  padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  background: rgba(4, 8, 18, 0.72);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
.avatar-crop-modal.hidden { display: none !important; }
.avatar-crop-card {
  width: min(440px, 100%);
  max-height: min(92vh, 720px);
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: linear-gradient(165deg, rgba(28, 34, 58, 0.98), rgba(12, 16, 30, 0.98));
  border: 1px solid rgba(167, 139, 250, 0.28);
  border-radius: 20px;
  padding: 14px 14px 16px;
  box-shadow: 0 28px 80px rgba(0,0,0,0.55), 0 0 40px rgba(109,77,255,0.15);
}
html.theme-light .avatar-crop-card {
  background: rgba(255,255,255,0.98);
  border-color: rgba(20,24,40,0.12);
  color: #141822;
  box-shadow: 0 24px 64px rgba(40,28,70,0.18);
}
.avatar-crop-head {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-areas: "title x" "hint hint";
  gap: 4px 8px;
  align-items: center;
}
.avatar-crop-head strong {
  grid-area: title;
  font-size: 15px;
  font-weight: 700;
}
.avatar-crop-hint {
  grid-area: hint;
  font-size: 12px;
  color: var(--muted);
}
.avatar-crop-x { grid-area: x; }
.avatar-crop-stage {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  max-height: min(56vh, 420px);
  border-radius: 16px;
  overflow: hidden;
  background: #0a0e18;
  border: 1px solid rgba(255,255,255,0.08);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  cursor: grab;
}
html.theme-light .avatar-crop-stage {
  background: #e8eaef;
  border-color: rgba(20,24,40,0.1);
}
.avatar-crop-stage:active { cursor: grabbing; }
.avatar-crop-canvas-wrap {
  position: absolute;
  inset: 0;
  overflow: hidden;
}
.avatar-crop-img {
  position: absolute;
  left: 0; top: 0;
  max-width: none !important;
  transform-origin: 0 0;
  pointer-events: none;
  -webkit-user-drag: none;
}
.avatar-crop-veil {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: rgba(0,0,0,0.48);
  /* hole punched via box-shadow on frame */
  opacity: 0;
}
.avatar-crop-frame {
  position: absolute;
  left: 0; top: 0;
  box-sizing: border-box;
  border: 2px solid rgba(196, 181, 253, 0.95);
  border-radius: 4px;
  box-shadow: 0 0 0 9999px rgba(0,0,0,0.52);
  cursor: move;
  touch-action: none;
  z-index: 2;
}
.avatar-crop-frame .c {
  position: absolute;
  width: 12px; height: 12px;
  border: 2px solid #fff;
  border-radius: 2px;
  background: rgba(139, 108, 255, 0.85);
  pointer-events: none;
}
.avatar-crop-frame .c.tl { left: -2px; top: -2px; border-right: 0; border-bottom: 0; }
.avatar-crop-frame .c.tr { right: -2px; top: -2px; border-left: 0; border-bottom: 0; }
.avatar-crop-frame .c.bl { left: -2px; bottom: -2px; border-right: 0; border-top: 0; }
.avatar-crop-frame .c.br { right: -2px; bottom: -2px; border-left: 0; border-top: 0; }
.avatar-crop-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.avatar-crop-toolbar input[type="range"] {
  flex: 1 1 120px;
  min-width: 80px;
  accent-color: #8b6cff;
}
.avatar-crop-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}
@media (max-width: 480px) {
  .avatar-crop-card {
    width: 100%;
    padding: 12px;
    border-radius: 16px;
  }
  .avatar-crop-stage {
    max-height: min(52vh, 380px);
  }
  .avatar-crop-hint { font-size: 11.5px; }
}

/* System message rules stay: dashed + green/red only — do not restyle text colors here */

/* hubBg2: hub CTA — static accent shadow, no pulse */
.hub-cta {
  box-shadow: 0 10px 28px rgba(109, 77, 255, 0.32);
}
@media (prefers-reduced-motion: reduce) {
  .hub-cta { animation: none !important; }
}

