:root {
  --bg: #0b0c10;
  --panel: #15161c;
  --panel-2: #1d1f28;
  --panel-3: #242733;
  --ink: #f5f7fb;
  --muted: #8d95a3;
  --line: rgba(255,255,255,0.08);
  --accent: #05d7ff;
  --blue: #4b6bff;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
  overflow: hidden;
}

button, textarea, select, input { font: inherit; }
button, select { cursor: pointer; }
select option:disabled { color: #6f7b91; }

.app {
  height: 100vh;
  display: grid;
  grid-template-columns: 76px 240px minmax(0, 1fr);
  background: radial-gradient(circle at 50% -20%, rgba(52, 64, 95, 0.35), transparent 36%), var(--bg);
}
.app.hide-history {
  grid-template-columns: 76px minmax(0, 1fr);
}
.app.hide-history .history-panel {
  display: none;
}

.icon-rail {
  background: #08090d;
  border-right: 1px solid var(--line);
  padding: 24px 10px 18px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
}

.logo {
  width: 38px;
  height: 38px;
  border: 0;
  display: grid;
  place-items: center;
  border-radius: 10px;
  font-weight: 900;
  color: #061219;
  background: linear-gradient(135deg, #6df5ff, #4468ff 54%, #80ffb4);
  margin-bottom: 84px;
  padding: 0;
  cursor: pointer;
  transition: transform .18s ease, box-shadow .18s ease, filter .18s ease;
}
.logo:hover,
.logo.active {
  transform: translateY(-1px);
  box-shadow: 0 0 0 4px rgba(5, 215, 255, .14), 0 12px 28px rgba(0,0,0,.28);
  filter: brightness(1.05);
}

.rail-icon {
  width: 56px;
  min-height: 48px;
  border: 0;
  color: #f3f5fa;
  background: transparent;
  display: grid;
  place-items: center;
  gap: 3px;
  border-radius: 10px;
}
.rail-icon span { font-size: 12px; }
.rail-icon.active { background: rgba(255,255,255,0.06); }
.admin-rail { display: none; }
.rail-spacer { flex: 1; }
.user-entry {
  width: 42px;
  height: 42px;
  border: 1px solid rgba(255,255,255,.09);
  border-radius: 50%;
  background: #171b25;
  color: #eaf3ff;
  display: grid;
  place-items: center;
  padding: 0;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.06);
}
.user-entry span {
  width: 30px;
  height: 30px;
  border-radius: inherit;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #58d7ff, #4b6bff);
  color: #fff;
  font-weight: 900;
}
.user-entry:hover {
  border-color: rgba(5, 215, 255, .45);
  box-shadow: 0 0 0 3px rgba(5, 215, 255, .1);
}
.rail-chip {
  width: 56px;
  border: 1px solid rgba(0, 215, 255, .24);
  background: rgba(0, 215, 255, .08);
  color: var(--accent);
  border-radius: 10px;
  padding: 8px 4px;
  font-weight: 800;
  font-size: 12px;
}
.rail-chip small { font-size: 10px; }

.history-panel {
  background: #14151b;
  border-right: 1px solid var(--line);
  padding: 28px 16px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.history-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18px;
}
.history-head button, .new-chat {
  border: 0;
  color: var(--ink);
  background: transparent;
}
.new-chat {
  min-height: 36px;
  text-align: left;
  padding: 0 0 0 6px;
  margin-bottom: 12px;
}
.default-chat {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  margin-bottom: 24px;
}
.thumb {
  width: 32px;
  height: 32px;
  border-radius: 7px;
  flex: none;
  object-fit: cover;
  background: #272b38;
}
.gradient-thumb { background: linear-gradient(135deg, #fde68a, #fb7185, #60a5fa); }
.history-label {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 13px;
}
.history-list {
  overflow-x: hidden;
  overflow-y: auto;
  display: grid;
  gap: 6px;
  padding-right: 2px;
}
.history-item {
  border: 0;
  width: 100%;
  min-height: 38px;
  border-radius: 8px;
  padding: 4px 8px;
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  background: transparent;
  color: #f6f8ff;
  text-align: left;
}
.history-item.active, .history-item:hover { background: #242733; }
.history-item span:last-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
  font-size: 13px;
}
.pin-dot {
  display: inline-grid;
  place-items: center;
  min-height: 18px;
  padding: 0 5px;
  margin-right: 5px;
  border-radius: 5px;
  background: rgba(5, 215, 255, .14);
  color: var(--accent);
  font-size: 10px;
  line-height: 1;
  vertical-align: 1px;
}
.history-menu {
  position: fixed;
  z-index: 40;
  min-width: 132px;
  display: none;
  padding: 6px;
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 10px;
  background: #171a22;
  box-shadow: 0 18px 48px rgba(0,0,0,.42);
}
.history-menu.open {
  display: grid;
  gap: 4px;
}
.history-menu button {
  min-height: 34px;
  border: 0;
  border-radius: 8px;
  padding: 0 10px;
  background: transparent;
  color: #edf3ff;
  text-align: left;
  font-weight: 800;
}
.history-menu button:hover {
  background: #242837;
}
.history-menu .danger {
  color: #ffb8c2;
}
.history-menu .danger:hover {
  background: rgba(255, 92, 115, .14);
}

.agent-page {
  height: 100vh;
  display: none;
  grid-template-rows: auto minmax(0, 1fr) auto;
  max-width: 980px;
  width: 100%;
  margin: 0 auto;
  padding: 56px 48px 36px;
  overflow: hidden;
}
.stage.agent-view .agent-page {
  display: grid;
}
.stage.agent-view .feed,
.stage.agent-view .bottom-composer,
.stage.agent-view .asset-page,
.stage.agent-view .admin-page,
.stage.agent-view .lobby-page,
.stage.agent-view .commerce-page {
  display: none;
}
.agent-head {
  min-height: 74px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 18px;
}
.agent-head strong {
  display: block;
  font-size: 30px;
}
.agent-head span {
  color: var(--muted);
  font-size: 13px;
}
.agent-head-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}
.agent-head-actions select,
.commerce-agent-head-actions select {
  min-height: 38px;
  max-width: 260px;
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 10px;
  padding: 0 32px 0 12px;
  background: #151923;
  color: #e8eefb;
  font-size: 13px;
  font-weight: 800;
}
.agent-head button {
  min-height: 38px;
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 10px;
  padding: 0 14px;
  background: #20232e;
  color: #e8eefb;
  font-size: 13px;
  font-weight: 900;
}
.agent-messages {
  min-height: 0;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 4px 4px 22px;
}
.agent-empty {
  margin: auto 0;
  padding: 28px 22px;
  border: 1px dashed rgba(255,255,255,.12);
  border-radius: 12px;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.55;
}
.agent-message {
  max-width: min(720px, 86%);
  display: grid;
  gap: 7px;
  align-self: flex-start;
}
.agent-message.user {
  align-self: flex-end;
}
.agent-message span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
}
.agent-bubble {
  padding: 13px 15px;
  border-radius: 12px;
  background: #20232e;
  color: #eef3ff;
  font-size: 14px;
  line-height: 1.65;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}
.agent-message.user .agent-bubble {
  background: linear-gradient(135deg, #345bff, #05bce2);
  color: #fff;
}
.agent-loading-bubble {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: #dfe9f8;
}
.agent-loading-bubble i {
  width: 18px;
  height: 18px;
  flex: none;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,.18);
  border-top-color: var(--accent);
  animation: spin .85s linear infinite;
}
.agent-loading-bubble strong {
  font-size: 14px;
}
.agent-composer {
  display: grid;
  grid-template-columns: 88px minmax(0, 1fr) auto;
  align-items: end;
  gap: 12px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}
.agent-video-tile {
  width: 88px;
  height: 104px;
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 12px;
  background: linear-gradient(180deg, #232936, #171b25);
  color: #aab4c5;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 5px;
  position: relative;
  overflow: hidden;
  cursor: pointer;
  transition: border-color .18s ease, box-shadow .18s ease, transform .18s ease, color .18s ease;
}
.agent-video-tile:hover,
.agent-video-tile.drag-over {
  color: #ecfbff;
  border-color: rgba(5, 215, 255, .72);
  box-shadow: 0 0 0 3px rgba(5, 215, 255, .12);
  transform: translateY(-1px);
}
.agent-video-tile input {
  display: none;
}
.agent-video-tile video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: none;
  object-fit: cover;
  background: #080a0f;
}
.agent-video-tile span {
  font-size: 26px;
  line-height: 1;
}
.agent-video-tile small {
  max-width: 74px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 11px;
  font-weight: 900;
}
.agent-video-tile.has-preview video {
  display: block;
}
.agent-video-tile.has-preview span {
  display: none;
}
.agent-video-tile.has-preview small {
  position: absolute;
  inset: auto 6px 6px;
  min-height: 22px;
  display: grid;
  place-items: center;
  max-width: none;
  border-radius: 7px;
  background: rgba(7, 10, 16, .72);
  color: #fff;
  padding: 0 6px;
}
.agent-video-tile button {
  position: absolute;
  top: 6px;
  right: 6px;
  z-index: 2;
  width: 24px;
  height: 24px;
  display: none;
  border: 0;
  border-radius: 50%;
  background: rgba(7, 10, 16, .78);
  color: #fff;
  font-size: 17px;
  line-height: 1;
}
.agent-video-tile.has-preview button {
  display: grid;
  place-items: center;
}
.agent-composer textarea {
  min-height: 92px;
  max-height: 190px;
  resize: vertical;
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 12px;
  padding: 14px;
  outline: none;
  background: #0f1118;
  color: #f5f7fb;
  font-size: 14px;
  line-height: 1.45;
}
.agent-composer textarea:focus {
  border-color: rgba(5, 215, 255, .45);
  box-shadow: 0 0 0 3px rgba(5, 215, 255, .1);
}
.agent-composer button {
  align-self: end;
  min-height: 44px;
  border: 0;
  border-radius: 10px;
  padding: 0 18px;
  background: #f4f7ff;
  color: #11151d;
  font-weight: 900;
}
.agent-composer button:disabled {
  cursor: wait;
  opacity: .62;
  box-shadow: 0 0 0 3px rgba(5, 215, 255, .08);
}

.stage {
  position: relative;
  min-width: 0;
  height: 100vh;
  overflow: hidden;
}
.commerce-page {
  height: 100vh;
  display: none;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 20px;
  width: 100%;
  padding: 46px 42px 34px;
  overflow: hidden;
}
.stage.commerce-view .commerce-page {
  display: grid;
}
.stage.commerce-view .feed,
.stage.commerce-view .bottom-composer,
.stage.commerce-view .asset-page,
.stage.commerce-view .admin-page,
.stage.commerce-view .agent-page,
.stage.commerce-view .lobby-page,
.stage.commerce-view .market-page {
  display: none;
}
.commerce-side {
  min-height: 0;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(20, 22, 30, .86);
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.commerce-side-head {
  display: grid;
  gap: 4px;
  padding: 2px 2px 8px;
}
.commerce-side-head span,
.commerce-head span,
.commerce-upload small,
.commerce-tab small {
  color: var(--muted);
  font-size: 12px;
}
.commerce-side-head strong {
  font-size: 20px;
}
.commerce-new-session {
  width: 100%;
  min-height: 40px;
  border: 1px solid rgba(5, 215, 255, .34);
  border-radius: 10px;
  background: linear-gradient(135deg, rgba(75, 107, 255, .18), rgba(5, 215, 255, .12));
  color: #f3fbff;
  text-align: left;
  padding: 0 12px;
  font-weight: 900;
}
.commerce-new-session:hover {
  border-color: rgba(5, 215, 255, .7);
  background: linear-gradient(135deg, rgba(75, 107, 255, .26), rgba(5, 215, 255, .18));
}
.commerce-session-history {
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 10px;
  background: #171b25;
  overflow: hidden;
}
.commerce-session-history summary {
  min-height: 40px;
  padding: 0 11px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: #edf4ff;
  cursor: pointer;
  list-style: none;
  font-weight: 900;
}
.commerce-session-history summary::-webkit-details-marker {
  display: none;
}
.commerce-session-history summary::after {
  content: "⌄";
  color: #93a3bd;
  transition: transform .18s ease;
}
.commerce-session-history[open] summary::after {
  transform: rotate(180deg);
}
.commerce-session-history summary small {
  margin-left: auto;
  color: #8fa3c2;
  font-size: 11px;
  font-weight: 800;
}
.commerce-session-list {
  max-height: 230px;
  overflow-y: auto;
  display: grid;
  gap: 5px;
  padding: 0 7px 7px;
  border-top: 1px solid rgba(255,255,255,.06);
}
.commerce-session-item {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 28px;
  gap: 4px;
  align-items: center;
  border-radius: 8px;
  padding: 4px;
}
.commerce-session-item:hover,
.commerce-session-item.active {
  background: rgba(5, 215, 255, .08);
}
.commerce-session-item > button:first-child {
  min-width: 0;
  border: 0;
  padding: 6px;
  background: transparent;
  color: #edf4ff;
  text-align: left;
  display: grid;
  gap: 3px;
}
.commerce-session-item strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
}
.commerce-session-item small {
  color: #8798b3;
  font-size: 10px;
}
.commerce-session-delete {
  width: 26px;
  height: 26px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: #8798b3;
  font-size: 16px;
  opacity: 0;
}
.commerce-session-item:hover .commerce-session-delete,
.commerce-session-item.active .commerce-session-delete {
  opacity: 1;
}
.commerce-session-delete:hover {
  background: rgba(255, 92, 115, .14);
  color: #ffb8c2;
}
.commerce-tab {
  min-height: 64px;
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 10px;
  padding: 10px 12px;
  background: #171b25;
  color: #edf4ff;
  text-align: left;
  display: grid;
  gap: 4px;
}
.commerce-tab.active,
.commerce-tab:hover {
  border-color: rgba(5, 215, 255, .36);
  background: rgba(5, 215, 255, .08);
}
.commerce-tab span {
  font-weight: 900;
}
.commerce-workspace {
  min-width: 0;
  min-height: 0;
  overflow: auto;
  display: grid;
  align-content: start;
  gap: 18px;
  padding-bottom: 132px;
}
.commerce-head {
  max-width: 980px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}
.commerce-head strong {
  display: block;
  font-size: 28px;
}
.commerce-head button,
.commerce-fields button {
  min-height: 38px;
  border: 0;
  border-radius: 10px;
  padding: 0 14px;
  background: linear-gradient(135deg, #4b6bff, #58d7ff);
  color: #fff;
  font-weight: 900;
}
#commerceToGenerate {
  display: none;
}
.commerce-builder {
  max-width: 980px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  align-items: stretch;
}
.commerce-hidden-file {
  display: none;
}
.commerce-upload {
  min-height: 280px;
  border: 1px dashed rgba(255,255,255,.18);
  border-radius: 14px;
  background: linear-gradient(180deg, #20242f, #151923);
  display: grid;
  place-items: center;
  align-content: center;
  gap: 8px;
  color: #dce7f8;
  text-align: center;
  cursor: pointer;
  transition: border-color .18s ease, box-shadow .18s ease, background .18s ease;
}
.commerce-upload:hover,
.commerce-upload.drag-over {
  border-color: rgba(5, 215, 255, .72);
  background: linear-gradient(180deg, rgba(5, 215, 255, .12), rgba(75, 107, 255, .08)), #151923;
  box-shadow: 0 0 0 3px rgba(5, 215, 255, .1);
}
.commerce-upload input {
  display: none;
}
.commerce-upload span {
  width: 46px;
  height: 46px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: rgba(5, 215, 255, .12);
  color: var(--accent);
  font-size: 28px;
}
.commerce-upload-preview {
  width: 100%;
  max-height: 96px;
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 7px;
  overflow: auto;
  padding: 4px 10px 0;
}
.commerce-preview-chip {
  position: relative;
  width: 50px;
  height: 62px;
  border: 1px solid rgba(5, 215, 255, .28);
  border-radius: 8px;
  overflow: hidden;
  background: #10131b;
}
.commerce-preview-chip span {
  position: absolute;
  left: 4px;
  bottom: 4px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(7, 10, 16, .82);
  color: #fff;
  font-size: 10px;
  font-weight: 900;
  line-height: 1;
}
.commerce-preview-open {
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
  padding: 0;
  background: transparent;
}
.commerce-preview-chip img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}
.commerce-preview-chip > button:not(.commerce-preview-open) {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 18px;
  height: 18px;
  border: 0;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: rgba(7, 10, 16, .76);
  color: #fff;
  font-size: 13px;
  font-weight: 900;
  line-height: 1;
}
.commerce-fields {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(23, 26, 34, .88);
  display: grid;
  gap: 14px;
}
.commerce-fields label {
  display: grid;
  gap: 7px;
  color: #cfd7e6;
  font-size: 13px;
  font-weight: 800;
}
.commerce-fields input,
.commerce-fields textarea,
.commerce-fields select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #10131b;
  color: #fff;
  outline: none;
}
.commerce-fields input,
.commerce-fields select {
  min-height: 40px;
  padding: 0 12px;
}
.commerce-fields textarea {
  min-height: 112px;
  padding: 11px 12px;
  resize: vertical;
}
.commerce-fields input:focus,
.commerce-fields textarea:focus,
.commerce-fields select:focus {
  border-color: rgba(5, 215, 255, .55);
  box-shadow: 0 0 0 3px rgba(5, 215, 255, .1);
}
.commerce-options {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}
.commerce-button-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.commerce-button-row button:disabled {
  opacity: .68;
  cursor: wait;
}
.commerce-status {
  min-height: 20px;
  margin: -4px 0 0;
  color: #aeb8c8;
  font-size: 12px;
}
.commerce-agent-panel {
  position: relative;
  grid-column: 1 / -1;
  min-height: calc(100vh - 154px);
  padding: 0 4px 112px;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 12px;
}
.commerce-agent-panel.drag-over {
  border-radius: 18px;
  outline: 2px dashed rgba(5, 215, 255, .55);
  outline-offset: 6px;
}
.commerce-agent-head {
  order: 1;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
}
.commerce-agent-head > div {
  display: none !important;
}
.commerce-agent-head > .commerce-agent-head-actions {
  display: flex !important;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}
.commerce-agent-head div {
  display: grid;
  gap: 4px;
}
.commerce-agent-head span {
  color: var(--accent);
  font-size: 12px;
  font-weight: 900;
}
.commerce-agent-head strong {
  font-size: 18px;
}
.commerce-workflow {
  display: none;
  order: 2;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}
.commerce-step {
  min-width: 0;
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 14px;
  padding: 9px 10px;
  background: rgba(10, 13, 20, .5);
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  gap: 2px 8px;
  align-items: center;
}
.commerce-step i {
  grid-row: span 2;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: rgba(255, 183, 77, .14);
  color: #ffc168;
  font-style: normal;
  font-size: 12px;
  font-weight: 900;
}
.commerce-step.done i {
  background: rgba(57, 211, 123, .14);
  color: #75f0a5;
}
.commerce-step span {
  color: #f7fbff;
  font-size: 12px;
  font-weight: 900;
}
.commerce-step small {
  min-width: 0;
  overflow: hidden;
  color: #93a3bd;
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.commerce-suggestion-card {
  display: none !important;
  order: 4;
  border: 1px solid rgba(255, 196, 117, .2);
  border-radius: 18px;
  padding: 12px;
  background: rgba(255, 183, 77, .06);
  display: grid;
  gap: 10px;
}
.commerce-suggestion-card[hidden] {
  display: none;
}
.commerce-suggestion-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
}
.commerce-suggestion-head div {
  display: grid;
  gap: 3px;
}
.commerce-suggestion-head span {
  width: fit-content;
  border-radius: 999px;
  padding: 3px 8px;
  background: rgba(57, 211, 123, .12);
  color: #75f0a5;
  font-size: 11px;
  font-weight: 900;
}
.commerce-suggestion-head strong {
  font-size: 16px;
}
.commerce-suggestion-head button {
  min-height: 32px;
  border: 1px solid rgba(255, 196, 117, .3);
  border-radius: 999px;
  padding: 0 12px;
  background: rgba(255, 183, 77, .12);
  color: #ffd28b;
  font-weight: 900;
}
.commerce-suggestion-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}
.commerce-suggestion-grid p {
  margin: 0;
  min-width: 0;
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 12px;
  padding: 9px;
  background: rgba(10, 13, 20, .5);
  color: #dbe7f9;
  font-size: 12px;
  line-height: 1.5;
}
.commerce-suggestion-grid b {
  display: block;
  margin-bottom: 4px;
  color: #ffc168;
}
.commerce-scene-list {
  display: flex;
  gap: 7px;
  overflow-x: auto;
  padding-bottom: 2px;
}
.commerce-scene-list span {
  flex: 0 0 230px;
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 12px;
  padding: 8px 10px;
  background: rgba(10, 13, 20, .48);
  color: #dce7f8;
  font-size: 12px;
  line-height: 1.5;
}
.commerce-agent-head button,
.commerce-agent-prompts button {
  min-height: 30px;
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 999px;
  padding: 0 12px;
  background: rgba(15, 18, 27, .72);
  color: #dfe8f8;
  font-weight: 800;
}
.commerce-agent-prompts {
  order: 5;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.commerce-agent-prompts button:hover,
.commerce-agent-head button:hover {
  border-color: rgba(5, 215, 255, .45);
  color: #fff;
}
.commerce-agent-messages {
  order: 3;
  min-height: 0;
  max-height: none;
  overflow: auto;
  display: grid;
  align-content: start;
  gap: 10px;
  padding: 4px 6px 18px;
  scrollbar-gutter: stable;
}
.commerce-agent-messages::before {
  display: none;
}
.commerce-agent-message {
  max-width: 78%;
  display: grid;
  gap: 5px;
}
.commerce-agent-message span {
  color: #9fb4d5;
  font-size: 11px;
  font-weight: 900;
}
.commerce-agent-message div {
  white-space: pre-wrap;
  border: 0;
  border-radius: 12px;
  padding: 13px 15px;
  background: #20232e;
  color: #edf4ff;
  font-size: 14px;
  line-height: 1.65;
}
.commerce-agent-message.user {
  justify-self: end;
}
.commerce-agent-message.user span {
  text-align: right;
}
.commerce-agent-message.user div {
  background: linear-gradient(135deg, #4b6bff, #16b5df);
  border-color: transparent;
  color: #fff;
}
.commerce-chat-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.commerce-chat-actions button,
.commerce-result-actions button,
.commerce-result-item > button:not(:first-child) {
  min-height: 30px;
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 999px;
  padding: 0 12px;
  background: rgba(75, 107, 255, .16);
  color: #eaf3ff;
  font-weight: 900;
}
.commerce-chat-actions button:hover,
.commerce-result-actions button:hover,
.commerce-result-item > button:not(:first-child):hover {
  border-color: rgba(5, 215, 255, .5);
  background: rgba(5, 215, 255, .16);
}
.commerce-chat-actions button:disabled,
.commerce-result-actions button:disabled {
  opacity: .55;
  cursor: not-allowed;
}
.commerce-result-card {
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 18px;
  padding: 12px;
  background: rgba(11, 14, 22, .72);
  display: grid;
  gap: 12px;
}
.commerce-result-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.commerce-result-head span {
  display: block;
  color: #9fc8ff;
  font-size: 12px;
  font-weight: 900;
}
.commerce-result-head strong {
  color: #fff;
  font-size: 16px;
}
.commerce-result-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.commerce-result-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(116px, 1fr));
  gap: 10px;
}
.commerce-result-item {
  min-height: 154px;
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 14px;
  padding: 8px;
  background: rgba(7, 10, 16, .48);
  display: grid;
  gap: 7px;
  align-content: start;
}
.commerce-result-item.failed,
.commerce-result-item.skipped {
  border-color: rgba(255, 110, 110, .34);
  background: rgba(255, 110, 110, .08);
}
.commerce-result-item > button:first-child {
  border: 0;
  border-radius: 10px;
  padding: 0;
  overflow: hidden;
  background: #10131b;
}
.commerce-result-item img {
  width: 100%;
  height: 112px;
  display: block;
  object-fit: cover;
}
.commerce-result-placeholder {
  min-height: 112px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  gap: 6px;
  background: rgba(255,255,255,.04);
  color: #b8c7dc;
  text-align: center;
  padding: 10px;
}
.commerce-result-placeholder b {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: rgba(255, 183, 77, .14);
  color: #ffc168;
}
.commerce-result-placeholder span,
.commerce-result-item small,
.commerce-result-note {
  color: #aeb8c8;
  font-size: 12px;
  line-height: 1.45;
}
.commerce-result-note {
  margin: 0;
}
.commerce-agent-loading {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.commerce-agent-loading i {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,.22);
  border-top-color: var(--accent);
  animation: spin .8s linear infinite;
}
.commerce-agent-form {
  position: fixed;
  left: calc(68px + 220px + (100vw - 288px) / 2);
  bottom: 20px;
  z-index: 18;
  width: min(760px, calc(100vw - 160px));
  transform: translateX(-50%);
  min-height: 104px;
  display: grid;
  grid-template-columns: 76px minmax(0, 1fr) 42px;
  gap: 14px;
  align-items: stretch;
  padding: 14px;
  border: 1px solid rgba(255,255,255,.09);
  border-radius: 24px;
  background:
    linear-gradient(180deg, rgba(255,255,255,.045), rgba(255,255,255,.015)),
    #1b1e27;
  box-shadow: 0 22px 70px rgba(0,0,0,.42), inset 0 1px 0 rgba(255,255,255,.05);
  backdrop-filter: blur(14px);
}
.commerce-agent-form.drag-over {
  border-color: rgba(5, 215, 255, .8);
  background:
    linear-gradient(135deg, rgba(5, 215, 255, .14), rgba(75, 107, 255, .10)),
    rgba(11, 14, 22, .92);
  box-shadow: 0 20px 60px rgba(0,0,0,.36), 0 0 0 4px rgba(5, 215, 255, .14);
}
.commerce-agent-form.drag-over::after {
  content: "松手添加为参考图";
  position: absolute;
  inset: 8px;
  border: 1px dashed rgba(102, 243, 255, .55);
  border-radius: 16px;
  display: grid;
  place-items: center;
  background: rgba(5, 9, 16, .66);
  color: #eafcff;
  font-weight: 900;
  pointer-events: none;
}
.stage:not(.commerce-view) .commerce-agent-form {
  display: none;
}
.commerce-agent-upload,
.commerce-agent-send {
  border: 0;
  border-radius: 12px;
  color: #fff;
  font-weight: 900;
}
.commerce-agent-upload {
  background: linear-gradient(180deg, #303543, #262a36);
  border: 1px solid rgba(255,255,255,.08);
  display: grid;
  place-items: center;
  align-content: center;
  gap: 6px;
  overflow: hidden;
}
.commerce-agent-upload span {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: rgba(5, 215, 255, .14);
  color: var(--accent);
  font-size: 24px;
}
.commerce-agent-upload strong {
  font-size: 12px;
}
.commerce-agent-upload .commerce-agent-preview {
  width: 100%;
  max-height: 56px;
  justify-content: center;
  gap: 5px;
  padding: 0;
}
.commerce-agent-upload .commerce-preview-chip {
  width: 42px;
  height: 48px;
  border-radius: 8px;
}
.commerce-agent-upload .commerce-preview-chip > button:not(.commerce-preview-open) {
  top: 2px;
  right: 2px;
  width: 16px;
  height: 16px;
  font-size: 12px;
}
.commerce-agent-upload:has(.commerce-preview-chip) > span,
.commerce-agent-upload:has(.commerce-preview-chip) > strong {
  display: none;
}
.commerce-agent-input-main {
  min-width: 0;
  display: grid;
  grid-template-rows: minmax(42px, 1fr) auto;
  gap: 7px;
}
.commerce-agent-form textarea {
  min-height: 42px;
  border: 0;
  outline: none;
  resize: none;
  background: transparent;
  color: #fff;
  font-size: 14px;
  line-height: 1.65;
}
.commerce-agent-options {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 7px;
}
.commerce-agent-options span {
  flex: none;
  color: #8fa0ba;
  font-size: 11px;
  font-weight: 900;
}
.commerce-agent-options select {
  min-width: 0;
  height: 30px;
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 9px;
  outline: none;
  padding: 0 28px 0 10px;
  background: #151821;
  color: #eef4ff;
  font-size: 11px;
  font-weight: 800;
}
.commerce-agent-options select:hover,
.commerce-agent-options select:focus {
  border-color: rgba(5, 215, 255, .5);
  box-shadow: 0 0 0 3px rgba(5, 215, 255, .08);
}
.commerce-agent-send {
  align-self: end;
  width: 42px;
  height: 42px;
  min-height: 42px;
  border-radius: 50%;
  padding: 0;
  background: linear-gradient(135deg, #4b6bff, #58d7ff);
}
.commerce-agent-send:disabled {
  opacity: .68;
  cursor: wait;
}
.commerce-agent-preview {
  order: 6;
  justify-content: flex-start;
  max-height: 78px;
  padding: 0;
}
.commerce-agent-settings {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
  order: 7;
  display: grid;
  grid-template-columns: 1.1fr 1.5fr repeat(3, .75fr);
  gap: 8px;
  padding: 10px;
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 16px;
  background: rgba(10, 13, 20, .48);
}
.commerce-agent-settings label {
  display: grid;
  gap: 7px;
  color: #cfd7e6;
  font-size: 12px;
  font-weight: 900;
}
.commerce-agent-settings input,
.commerce-agent-settings textarea,
.commerce-agent-settings select {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #10131b;
  color: #fff;
  outline: none;
  padding: 0 12px;
}
.commerce-agent-settings textarea {
  min-height: 38px;
  max-height: 70px;
  padding: 10px 12px;
  resize: vertical;
  line-height: 1.55;
}
.commerce-agent-selling {
  grid-column: auto;
}
.commerce-agent-actions {
  display: none;
  order: 8;
  grid-template-columns: minmax(0, .9fr) minmax(0, .9fr) minmax(0, .9fr);
  gap: 10px;
  align-items: center;
}
.commerce-agent-actions button {
  min-height: 40px;
  border: 0;
  border-radius: 12px;
  padding: 0 14px;
  background: linear-gradient(135deg, #4b6bff, #58d7ff);
  color: #fff;
  font-weight: 900;
}
.commerce-agent-actions button:disabled {
  opacity: .68;
  cursor: wait;
}
.commerce-agent-actions .commerce-status {
  grid-column: 1 / -1;
}
.commerce-assets-panel {
  max-width: 1040px;
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 16px;
}
.commerce-assets-list {
  max-height: calc(100vh - 150px);
  overflow: auto;
  display: grid;
  gap: 14px;
  padding-right: 4px;
}
.commerce-assets-empty {
  min-height: 180px;
  display: grid;
  place-items: center;
  border: 1px dashed rgba(255,255,255,.14);
  border-radius: 14px;
  color: var(--muted);
  background: rgba(23, 26, 34, .6);
}
.commerce-set-card {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(23, 26, 34, .86);
  padding: 14px;
  display: grid;
  gap: 10px;
}
.commerce-set-meta {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.commerce-set-meta strong {
  font-size: 16px;
}
.commerce-set-meta span,
.commerce-set-card p {
  color: var(--muted);
  font-size: 12px;
}
.commerce-set-card p {
  max-height: 42px;
  overflow: hidden;
  margin: 0;
  line-height: 1.7;
}
.commerce-set-images {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 2px;
}
.commerce-set-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.commerce-set-actions button {
  border: 1px solid rgba(255,255,255,.08);
  background: #1b2130;
  color: #fff;
  border-radius: 10px;
  padding: 8px 14px;
  cursor: pointer;
}
.commerce-set-actions button:hover {
  border-color: rgba(87, 184, 255, .5);
  background: #20283a;
}
.commerce-set-images button,
.commerce-set-placeholder {
  width: 130px;
  height: 170px;
  flex: none;
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 10px;
  overflow: hidden;
  background: #10131b;
  padding: 0;
}
.commerce-shot {
  position: relative;
}
.commerce-shot-badge {
  position: absolute;
  left: 8px;
  top: 8px;
  z-index: 1;
  min-height: 20px;
  padding: 0 8px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  background: rgba(7, 10, 16, .82);
  color: #fff;
  font-size: 11px;
  font-weight: 900;
}
.commerce-shot-status {
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: 8px;
  z-index: 1;
  min-height: 22px;
  padding: 0 8px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(7, 10, 16, .82);
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  text-align: center;
}
.commerce-shot-completed .commerce-shot-status {
  background: rgba(36, 145, 88, .84);
}
.commerce-shot-processing .commerce-shot-status {
  background: rgba(63, 109, 255, .84);
}
.commerce-shot-failed .commerce-shot-status {
  background: rgba(219, 68, 68, .88);
}
.commerce-shot-skipped .commerce-shot-status {
  background: rgba(89, 98, 117, .88);
}
.commerce-shot-queued .commerce-shot-status {
  background: rgba(91, 105, 138, .84);
}
.commerce-set-images img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}
.commerce-set-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 34px 12px 34px;
  flex-direction: column;
  color: #aeb8c8;
  font-size: 12px;
  text-align: center;
}
.commerce-set-placeholder strong {
  margin-top: 10px;
  line-height: 1.5;
}

.market-page {
  height: 100vh;
  display: none;
  grid-template-rows: auto minmax(0, 1fr);
  padding: 42px 40px 28px;
  overflow: hidden;
}
.stage.market-view .market-page {
  display: grid;
}
.stage.market-view .feed,
.stage.market-view .bottom-composer,
.stage.market-view .asset-page,
.stage.market-view .admin-page,
.stage.market-view .agent-page,
.stage.market-view .commerce-page,
.stage.market-view .lobby-page {
  display: none;
}
.market-head {
  max-width: 1180px;
  width: 100%;
  min-height: 58px;
  margin: 0 auto 16px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}
.market-head strong {
  display: block;
  font-size: 28px;
}
.market-head span {
  color: var(--muted);
  font-size: 13px;
}
.market-head-actions {
  display: flex;
  gap: 8px;
}
.market-head-actions button,
.market-import {
  min-height: 36px;
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 8px;
  padding: 0 13px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #202637;
  color: #fff;
  font-weight: 900;
  cursor: pointer;
}
.market-import input {
  display: none;
}
.market-layout {
  max-width: 1180px;
  width: 100%;
  min-height: 0;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 170px minmax(0, 1fr);
  gap: 16px;
}
.market-side {
  min-height: 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  background: rgba(18, 21, 31, .82);
  display: grid;
  align-content: start;
  gap: 8px;
}
.market-tab {
  min-height: 38px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 0 12px;
  background: transparent;
  color: #dbe6ff;
  font-weight: 900;
  text-align: left;
}
.market-tab.active,
.market-tab:hover {
  border-color: rgba(5, 215, 255, .45);
  background: rgba(5, 215, 255, .1);
  color: #fff;
}
.market-main {
  min-height: 0;
  overflow: auto;
  padding-right: 4px;
  display: grid;
  align-content: start;
  gap: 14px;
}
.market-summary {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
}
.market-summary article {
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 8px;
  padding: 12px;
  background: #171b26;
}
.market-summary span,
.market-summary small {
  display: block;
  color: var(--muted);
  font-size: 12px;
}
.market-summary strong {
  display: block;
  margin: 4px 0;
  color: #fff;
  font-size: 24px;
}
.market-toolbar {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) 160px 160px;
  gap: 10px;
}
.market-toolbar input,
.market-toolbar select,
.market-form input,
.market-form select {
  min-height: 38px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  background: #10131b;
  color: #fff;
  outline: none;
}
.market-table-wrap {
  border: 1px solid var(--line);
  border-radius: 10px;
  height: clamp(300px, 46vh, 540px);
  overflow: auto;
  background: rgba(16, 19, 27, .9);
  scrollbar-width: thin;
  scrollbar-color: #3b455d #111722;
}
.market-table {
  width: 100%;
  table-layout: fixed;
  border-collapse: collapse;
  min-width: 760px;
}
.market-table-wrap::-webkit-scrollbar {
  height: 8px;
}
.market-table-wrap::-webkit-scrollbar-track {
  background: #111722;
  border-radius: 999px;
}
.market-table-wrap::-webkit-scrollbar-thumb {
  background: #3b455d;
  border-radius: 999px;
}
.market-table th:nth-child(1),
.market-table td:nth-child(1) {
  width: 74px;
}
.market-table th:nth-child(2),
.market-table td:nth-child(2) {
  width: 92px;
}
.market-table th:nth-child(6),
.market-table td:nth-child(6) {
  width: 76px;
}
.market-table th:nth-child(7),
.market-table td:nth-child(7) {
  width: 96px;
}
.market-table th,
.market-table td {
  padding: 11px 12px;
  border-bottom: 1px solid rgba(255,255,255,.06);
  text-align: left;
  vertical-align: top;
  font-size: 12px;
  line-height: 1.55;
  overflow-wrap: anywhere;
}
.market-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #1d2331;
  color: #dce8ff;
  font-weight: 900;
}
.market-table td {
  color: #d7e1f3;
}
.market-table td b {
  color: #fff;
}
.market-empty-row {
  text-align: center !important;
  color: var(--muted) !important;
}
.market-priority {
  min-width: 38px;
  min-height: 22px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 900;
}
.market-priority.p0 { background: #e15f5f; }
.market-priority.p1 { background: #3f7cff; }
.market-priority.p2 { background: #68758f; }
.market-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.market-actions button {
  min-height: 26px;
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 7px;
  padding: 0 9px;
  background: #242b3b;
  color: #eaf2ff;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}
.market-actions button:hover {
  border-color: rgba(82, 199, 255, .55);
  background: #2b3448;
}
.market-actions button.danger {
  color: #ffd8d8;
}
.market-actions button.danger:hover {
  border-color: rgba(255, 110, 110, .6);
  background: rgba(255, 110, 110, .16);
}
.market-readonly {
  color: var(--muted);
  font-size: 12px;
}
.market-panels {
  display: grid;
  grid-template-columns: minmax(0, .9fr) minmax(0, 1.1fr);
  gap: 14px;
}
.market-priority-card,
.market-form,
.market-source-panel {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px;
  background: rgba(23, 26, 34, .86);
}
.market-section-title {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.market-section-title strong {
  color: #fff;
  font-size: 16px;
}
.market-section-title span {
  color: var(--muted);
  font-size: 12px;
}
.market-priority-group {
  display: grid;
  grid-template-columns: 42px 1fr;
  gap: 10px;
  padding: 10px 0;
  border-top: 1px solid rgba(255,255,255,.06);
}
.market-priority-group:first-child {
  border-top: 0;
  padding-top: 0;
}
.market-priority-group strong {
  color: #fff;
}
.market-priority-group div {
  display: grid;
  gap: 6px;
}
.market-priority-group span {
  color: #d9e3f7;
  font-size: 12px;
  line-height: 1.5;
}
.market-form {
  display: grid;
  gap: 12px;
}
.market-form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
}
.market-form button {
  min-height: 38px;
  border: 0;
  border-radius: 8px;
  background: linear-gradient(135deg, #4b6bff, #58d7ff);
  color: #fff;
  font-weight: 900;
}
.market-source-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
}
.market-source-grid article {
  border: 1px solid rgba(255,255,255,.07);
  border-radius: 8px;
  padding: 12px;
  background: #10131b;
}
.market-source-grid strong {
  color: #fff;
  font-size: 14px;
}
.market-source-grid p,
.market-source-grid span {
  margin: 8px 0 0;
  color: #aeb8c8;
  font-size: 12px;
  line-height: 1.55;
}
.market-connection-panel {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px;
  background: rgba(23, 26, 34, .86);
}
.market-connection-form {
  display: grid;
  gap: 12px;
}
.market-connection-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.market-connection-grid label {
  display: grid;
  gap: 6px;
  color: #dce8ff;
  font-size: 12px;
  font-weight: 900;
}
.market-connection-grid input,
.market-connection-grid select,
.market-connection-grid textarea {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  background: #10131b;
  color: #fff;
  outline: none;
}
.market-connection-grid textarea {
  min-height: 76px;
  padding-top: 10px;
  resize: vertical;
  font: inherit;
}
.market-connection-note {
  grid-column: 1 / -1;
}
.market-connection-enabled {
  grid-column: 1 / -1;
  display: flex !important;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 8px !important;
}
.market-connection-enabled input {
  width: 16px;
  min-height: 16px;
}
.market-connection-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.market-connection-actions button,
.market-connection-card-actions button {
  min-height: 34px;
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 8px;
  padding: 0 12px;
  background: #242b3b;
  color: #eaf2ff;
  font-size: 12px;
  font-weight: 900;
}
.market-connection-actions button[type="submit"] {
  border: 0;
  background: linear-gradient(135deg, #4b6bff, #58d7ff);
  color: #fff;
}
#marketConnectionStatus {
  color: var(--muted);
  font-size: 12px;
}
.market-connection-list {
  margin-top: 14px;
  display: grid;
  gap: 10px;
}
.market-connection-card,
.market-connection-empty {
  border: 1px solid rgba(255,255,255,.07);
  border-radius: 10px;
  padding: 12px;
  background: #10131b;
}
.market-connection-card {
  display: grid;
  gap: 8px;
}
.market-connection-card strong {
  display: block;
  color: #fff;
  font-size: 15px;
}
.market-connection-card span,
.market-connection-card small,
.market-connection-card p,
.market-connection-empty {
  color: #aeb8c8;
  font-size: 12px;
  line-height: 1.55;
}
.market-connection-card p {
  margin: 0;
}
.market-connection-card-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.market-connection-card-actions .danger {
  color: #ffd8d8;
  background: rgba(255, 110, 110, .12);
}
.feed {
  height: 100vh;
  overflow: auto;
  padding: 64px 48px 230px;
  scroll-behavior: smooth;
}
.feed-inner {
  max-width: 920px;
  margin: 0 auto;
}
.date-title {
  max-width: 920px;
  margin: 0 auto 26px;
  font-size: 28px;
}
.empty-feed {
  max-width: 620px;
  margin: 15vh auto 0;
  text-align: center;
  color: var(--muted);
}
.empty-feed h1 { color: #fff; margin: 14px 0 8px; letter-spacing: 0; }
.empty-orb {
  width: 54px;
  height: 54px;
  border-radius: 16px;
  margin: 0 auto;
  display: grid;
  place-items: center;
  color: #071019;
  background: linear-gradient(135deg, #66f3ff, #6c72ff);
}

.work-item {
  max-width: 920px;
  margin: 0 auto 32px;
  position: relative;
}
.work-delete {
  position: absolute;
  top: 2px;
  right: 0;
  z-index: 8;
  width: 26px;
  height: 26px;
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: rgba(20, 23, 31, .82);
  color: #cdd5e6;
  font-size: 18px;
  line-height: 1;
  opacity: .55;
  transition: opacity .18s ease, background .18s ease, color .18s ease, transform .18s ease;
}
.work-delete:hover {
  opacity: 1;
  background: rgba(255, 92, 115, .16);
  color: #ffbdc6;
  transform: translateY(-1px);
}
.work-prompt {
  display: grid;
  grid-template-columns: 38px 1fr;
  gap: 12px;
  align-items: start;
  margin-bottom: 14px;
}
.prompt-thumb {
  width: 38px;
  height: 38px;
  border-radius: 7px;
  background: #252a36;
  object-fit: cover;
}
.prompt-text {
  line-height: 1.7;
  font-weight: 700;
  min-width: 0;
  padding-right: 42px;
  overflow-wrap: anywhere;
}
.prompt-copy {
  display: -webkit-box;
  max-width: 100%;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 4;
}
.prompt-meta {
  display: inline-block;
  color: var(--muted);
  font-weight: 500;
  margin: 5px 6px 0 0;
  white-space: nowrap;
}
.item-details {
  display: inline-block;
  position: relative;
  margin-left: 8px;
  color: #cfd6e6;
  font-weight: 600;
}
.item-details summary {
  list-style: none;
  cursor: pointer;
  color: #cfd6e6;
  white-space: nowrap;
}
.item-details summary::-webkit-details-marker { display: none; }
.item-details[open] summary { color: #fff; }
.detail-panel {
  position: absolute;
  z-index: 5;
  top: 30px;
  left: 0;
  width: min(440px, calc(100vw - 420px));
  min-width: 320px;
  padding: 14px;
  display: grid;
  gap: 10px;
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 10px;
  background: #171a22;
  box-shadow: 0 18px 50px rgba(0,0,0,.42);
}
.detail-row {
  display: grid;
  grid-template-columns: 82px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  font-size: 13px;
  line-height: 1.45;
}
.detail-row span, .detail-prompt span {
  color: var(--muted);
  font-weight: 700;
}
.detail-row strong {
  color: #f4f7ff;
  font-weight: 700;
  overflow-wrap: anywhere;
}
.detail-prompt {
  display: grid;
  gap: 6px;
  padding-top: 2px;
}
.detail-prompt p {
  margin: 0;
  color: #eef3ff;
  font-size: 13px;
  line-height: 1.55;
  font-weight: 600;
  overflow-wrap: anywhere;
}
.media-frame {
  background: #202333;
  width: fit-content;
  max-width: 100%;
  min-height: 0;
  display: grid;
  place-items: center;
  overflow: hidden;
  border-radius: 2px;
  position: relative;
}
.media-frame[data-preview-url] {
  cursor: zoom-in;
}
.media-frame img, .media-frame video {
  max-width: min(440px, 100%);
  max-height: 420px;
  width: auto;
  height: auto;
  display: block;
  object-fit: contain;
}
.media-frame img[data-reference-drag] {
  cursor: grab;
  transition: filter .18s ease, transform .18s ease;
}
.media-frame img[data-reference-drag]:hover {
  filter: brightness(1.06);
  transform: translateY(-1px);
}
.media-frame img[data-reference-drag]:active { cursor: grabbing; }
.media-frame video { max-width: min(520px, 100%); }
.media-preview-tip {
  position: absolute;
  right: 10px;
  bottom: 10px;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: rgba(7, 10, 16, .72);
  color: #fff;
  font-size: 12px;
  font-weight: 900;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity .18s ease, transform .18s ease;
  pointer-events: none;
}
.media-frame:hover .media-preview-tip {
  opacity: 1;
  transform: translateY(0);
}
.pending-media {
  width: min(360px, 82vw);
  min-height: 220px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 12px;
  color: #dfe6f3;
  text-align: center;
}
.pending-media strong {
  font-size: 18px;
  letter-spacing: 0;
}
.pending-media span {
  color: var(--muted);
  font-size: 13px;
}
.pending-spinner {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: 3px solid rgba(255,255,255,.1);
  border-top-color: var(--accent);
  animation: spin .9s linear infinite;
}
.progress-track {
  width: min(320px, 100%);
  height: 7px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(255,255,255,.08);
}
.progress-track i {
  display: block;
  height: 100%;
  min-width: 8px;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--blue));
  transition: width .35s ease;
}
.is-failed .pending-spinner {
  border-top-color: #ff6b7a;
  animation: none;
}
.is-failed .progress-track i {
  background: #ff6b7a;
}
@keyframes spin { to { transform: rotate(360deg); } }
.work-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 16px;
}
.work-actions button, .work-actions a {
  border: 0;
  border-radius: 8px;
  min-height: 36px;
  padding: 0 13px;
  background: #20232e;
  color: #f5f7fb;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  font-weight: 800;
}
.work-actions button.danger {
  color: #ffd7dd;
  background: rgba(255, 92, 115, .16);
}

.bottom-composer {
  position: absolute;
  z-index: 4;
  left: 50%;
  bottom: 20px;
  transform: translateX(-50%);
  width: min(840px, calc(100% - 72px));
}

.lobby-page {
  height: 100vh;
  display: none;
  grid-template-rows: auto minmax(0, 1fr);
  padding: 56px 48px 36px;
  overflow: hidden;
}
.stage.lobby-view .lobby-page {
  display: grid;
}
.stage.lobby-view .feed,
.stage.lobby-view .bottom-composer,
.stage.lobby-view .asset-page,
.stage.lobby-view .admin-page,
.stage.lobby-view .agent-page,
.stage.lobby-view .market-page {
  display: none;
}
.lobby-head {
  max-width: 1180px;
  width: 100%;
  min-height: 64px;
  margin: 0 auto;
  padding: 0 0 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.lobby-head strong {
  display: block;
  font-size: 30px;
}
.lobby-head span {
  color: var(--muted);
  font-size: 13px;
}
.lobby-head button {
  min-height: 38px;
  border: 0;
  border-radius: 10px;
  padding: 0 14px;
  background: #242837;
  color: #fff;
  font-weight: 900;
}
.lobby-home {
  max-width: 1180px;
  width: 100%;
  margin: 0 auto;
  padding: 0 2px 30px;
  overflow: auto;
  display: grid;
  gap: 18px;
  align-content: start;
}
.lobby-agent-card {
  display: grid;
  grid-template-columns: minmax(260px, .9fr) minmax(320px, 1.1fr);
  gap: 18px;
  padding: 22px;
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 24px;
  background:
    radial-gradient(circle at top left, rgba(76, 200, 255, .22), transparent 32%),
    linear-gradient(135deg, rgba(31, 37, 54, .94), rgba(13, 16, 24, .96));
  box-shadow: 0 20px 70px rgba(0,0,0,.28);
}
.lobby-agent-copy span {
  color: var(--accent);
  font-size: 13px;
  font-weight: 900;
}
.lobby-agent-copy h2 {
  margin: 12px 0 10px;
  font-size: clamp(28px, 4vw, 46px);
  line-height: 1.05;
}
.lobby-agent-copy p {
  max-width: 520px;
  margin: 0;
  color: #b8c5d9;
  line-height: 1.8;
  font-weight: 700;
}
.lobby-agent-form {
  display: grid;
  gap: 12px;
}
.lobby-agent-form textarea {
  min-height: 160px;
  resize: vertical;
  border: 1px solid rgba(102, 243, 255, .22);
  border-radius: 18px;
  padding: 16px;
  background: rgba(7, 10, 16, .66);
  color: #fff;
  line-height: 1.65;
  font: inherit;
  outline: none;
}
.lobby-agent-form textarea:focus {
  border-color: rgba(102, 243, 255, .78);
  box-shadow: 0 0 0 4px rgba(102, 243, 255, .1);
}
.lobby-agent-form div {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}
.lobby-agent-form button {
  min-height: 42px;
  border: 0;
  border-radius: 12px;
  padding: 0 16px;
  background: #252a39;
  color: #fff;
  font-weight: 900;
}
.lobby-agent-form button[type="submit"] {
  background: linear-gradient(135deg, var(--accent), var(--blue));
  color: #071019;
}
.lobby-agent-form button:disabled {
  opacity: .62;
  cursor: wait;
}
.lobby-text-panel {
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 22px;
  padding: 18px;
  background: rgba(18, 21, 31, .72);
}
.lobby-text-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}
.lobby-text-head strong {
  font-size: 20px;
}
.lobby-text-head span {
  color: var(--muted);
  font-size: 13px;
}
.lobby-text-list {
  display: grid;
  gap: 12px;
}
.lobby-text-card,
.lobby-text-empty {
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 16px;
  padding: 14px 16px;
  background: #1b1f2b;
}
.lobby-text-card span {
  display: block;
  margin-bottom: 8px;
  color: #9fb7ff;
  font-size: 12px;
  font-weight: 900;
}
.lobby-text-card p {
  margin: 0;
  color: #f4f7ff;
  line-height: 1.75;
  font-weight: 700;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.lobby-text-empty {
  color: var(--muted);
  line-height: 1.7;
  font-weight: 700;
}

.asset-page {
  height: 100vh;
  display: none;
  grid-template-rows: auto auto minmax(0, 1fr);
  padding: 56px 48px 36px;
  overflow: hidden;
}
.stage.assets-view .feed,
.stage.assets-view .bottom-composer,
.stage.assets-view .agent-page,
.stage.assets-view .lobby-page,
.stage.assets-view .market-page {
  display: none;
}
.stage.assets-view .asset-page {
  display: grid;
}
.stage.admin-view .feed,
.stage.admin-view .bottom-composer,
.stage.admin-view .asset-page,
.stage.admin-view .agent-page,
.stage.admin-view .lobby-page,
.stage.admin-view .market-page {
  display: none;
}
.asset-head {
  max-width: 1180px;
  width: 100%;
  min-height: 64px;
  margin: 0 auto;
  padding: 0 0 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.asset-head strong {
  display: block;
  font-size: 30px;
}
.asset-head span {
  color: var(--muted);
  font-size: 13px;
}
.asset-tabs {
  max-width: 1180px;
  width: 100%;
  margin: 0 auto 18px;
  padding: 6px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 140px));
  gap: 6px;
  background: #151821;
  border: 1px solid var(--line);
  border-radius: 12px;
}
.asset-tab {
  border: 0;
  border-radius: 9px;
  min-height: 38px;
  background: transparent;
  color: var(--muted);
  font-weight: 800;
}
.asset-tab.active {
  background: #242837;
  color: #fff;
}
.asset-grid {
  max-width: 1180px;
  width: 100%;
  margin: 0 auto;
  padding: 0 2px 24px;
  overflow: auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 14px;
  align-content: start;
}
.asset-empty {
  grid-column: 1 / -1;
  min-height: 180px;
  display: grid;
  place-items: center;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: 10px;
}
.asset-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  background: #0f1118;
}
.asset-media {
  width: 100%;
  border: 0;
  padding: 0;
  display: block;
  position: relative;
  background: #090a0f;
  color: #fff;
}
.asset-media img, .asset-media video {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  display: block;
  background: #090a0f;
}
.asset-media video { aspect-ratio: 16 / 9; }
.asset-media span {
  position: absolute;
  inset: auto 8px 8px auto;
  padding: 5px 8px;
  border-radius: 7px;
  background: rgba(7,10,16,.72);
  color: #fff;
  font-size: 12px;
  font-weight: 900;
  opacity: 0;
  transition: opacity .18s ease;
}
.asset-media:hover span { opacity: 1; }
.asset-card div {
  padding: 8px;
  display: grid;
  gap: 6px;
}
.asset-card p {
  margin: 0;
  color: #dce2ee;
  font-size: 12px;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.asset-card a {
  color: var(--accent);
  text-decoration: none;
  font-size: 12px;
  font-weight: 800;
}
.asset-actions {
  padding: 0 !important;
  display: grid !important;
  grid-template-columns: 1fr 1fr;
  gap: 6px !important;
}
.asset-actions button,
.asset-actions a,
.asset-card button[data-use-reference],
.asset-card button[data-reverse-video] {
  min-height: 32px;
  border: 0;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: #202430;
  color: #f4f7ff;
  text-decoration: none;
  font-size: 12px;
  font-weight: 900;
}
.asset-actions a {
  background: linear-gradient(135deg, #4b6bff, #58d7ff);
  color: #fff;
}
.asset-card button[data-use-reference] {
  background: #f4f7ff;
  color: #11151d;
}
.asset-card button[data-reverse-video] {
  background: rgba(5, 215, 255, .12);
  border: 1px solid rgba(5, 215, 255, .24);
  color: #cfeeff;
}

.admin-page {
  height: 100vh;
  display: none;
  grid-template-rows: auto minmax(0, 1fr);
  padding: 56px 48px 36px;
  overflow: hidden;
}
.stage.admin-view .admin-page {
  display: grid;
}
.admin-head {
  max-width: 1180px;
  width: 100%;
  min-height: 64px;
  margin: 0 auto;
  padding: 0 0 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.admin-head strong {
  display: block;
  font-size: 30px;
}
.admin-head span,
.admin-users-head span {
  color: var(--muted);
  font-size: 13px;
}
.admin-head button,
.admin-form button,
.admin-card-actions button {
  min-height: 38px;
  border: 0;
  border-radius: 10px;
  padding: 0 14px;
  background: #242837;
  color: #fff;
  font-weight: 900;
}
.admin-grid {
  max-width: 1180px;
  width: 100%;
  min-height: 0;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 180px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}
.admin-side-nav {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #11141c;
  padding: 10px;
  display: grid;
  gap: 8px;
}
.admin-section-tab {
  min-height: 42px;
  border: 0;
  border-radius: 10px;
  padding: 0 12px;
  background: transparent;
  color: #cbd4e5;
  text-align: left;
  font-weight: 900;
}
.admin-section-tab:hover,
.admin-section-tab.active {
  background: #242837;
  color: #fff;
}
.admin-section {
  display: none;
  min-height: 0;
}
.admin-section.active {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  gap: 18px;
}
#adminApiSection.active {
  grid-template-columns: minmax(420px, 720px);
}
.admin-form,
.admin-users {
  min-height: 0;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #11141c;
}
.admin-form {
  align-self: start;
  padding: 18px;
  display: grid;
  gap: 13px;
}
.api-key-form {
  grid-column: 1;
  max-height: calc(100vh - 170px);
  grid-template-rows: auto auto auto auto minmax(100px, 1fr) auto auto;
  overflow: hidden;
}
.model-pool-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 14px;
}
.model-pool-head > div {
  display: grid;
  gap: 5px;
}
.admin-form .model-pool-toggle {
  min-height: 34px;
  padding: 0 12px;
  background: #202633;
  color: #dce7f8;
  white-space: nowrap;
}
.admin-form .model-pool-toggle.is-disabled {
  background: rgba(255, 92, 115, .14);
  color: #ffb5c0;
}
.model-pool-picker {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto minmax(210px, .8fr);
  gap: 10px;
  align-items: end;
}
#adminCreateProvider {
  min-height: 38px;
  padding: 0 16px;
  white-space: nowrap;
}
.model-pool-create {
  grid-column: 1 / -1;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #0c0f16;
}
.model-pool-endpoint {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 10px;
  align-items: end;
}
.model-pool-costs {
  display: grid;
  grid-template-columns: minmax(120px, .6fr) minmax(140px, .7fr) auto;
  gap: 10px;
  align-items: end;
}
.model-pool-custom {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: end;
}
.model-pool-endpoint button,
.model-pool-costs button,
.model-pool-custom button {
  min-height: 38px;
  padding: 0 16px;
  white-space: nowrap;
}
.model-cost-pill {
  align-self: center;
  border: 1px solid rgba(82, 188, 255, .36);
  border-radius: 999px;
  padding: 8px 12px;
  background: rgba(30, 144, 255, .12);
  color: #cdeaff;
  font-weight: 800;
  white-space: nowrap;
}
.model-fetch-list {
  display: grid;
  max-height: 220px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px;
  gap: 8px;
  background: #0c0f16;
}
.model-fetch-list label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: #dbe7ff;
}
.model-fetch-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  position: sticky;
  bottom: -10px;
  padding-top: 8px;
  background: #0c0f16;
}
.model-fetch-list button {
  min-height: 34px;
  padding: 0 14px;
}
.model-pool-create summary {
  min-height: 38px;
  display: flex;
  align-items: center;
  padding: 0 12px;
  color: #dce7f8;
  cursor: pointer;
  font-size: 13px;
  font-weight: 900;
}
.model-pool-create > div {
  padding: 0 10px 10px;
  display: grid;
  gap: 8px;
}
.model-pool-create button {
  min-height: 36px;
}
.admin-form h3,
.admin-users h3 {
  margin: 0;
  font-size: 18px;
}
.admin-form p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}
.admin-form label,
.admin-edit-grid label {
  display: grid;
  gap: 7px;
  color: #cfd7e6;
  font-size: 13px;
  font-weight: 800;
}
.admin-form input,
.admin-form select,
.admin-form textarea,
.admin-edit-grid input,
.admin-edit-grid select {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #0c0f16;
  color: #fff;
  outline: none;
  padding: 0 11px;
}
.admin-form textarea {
  min-height: 118px;
  resize: vertical;
  padding: 10px 11px;
  line-height: 1.5;
}
.admin-form input:focus,
.admin-form select:focus,
.admin-form textarea:focus,
.admin-edit-grid input:focus,
.admin-edit-grid select:focus {
  border-color: rgba(5, 215, 255, .55);
  box-shadow: 0 0 0 3px rgba(5, 215, 255, .1);
}
.admin-form button {
  background: linear-gradient(135deg, #4b6bff, #58d7ff);
}
.admin-users {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
}
.api-key-list {
  min-height: 0;
  max-height: min(420px, calc(100vh - 420px));
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-right: 4px;
  display: grid;
  gap: 8px;
  align-content: start;
}
.api-key-list::-webkit-scrollbar {
  width: 8px;
}
.api-key-list::-webkit-scrollbar-track {
  background: rgba(255,255,255,.04);
  border-radius: 999px;
}
.api-key-list::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,.18);
  border-radius: 999px;
}
.api-key-list::-webkit-scrollbar-thumb:hover {
  background: rgba(5, 215, 255, .38);
}
.api-key-list > span {
  min-height: 38px;
  display: flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  color: #dce6f7;
  background: #0c0f16;
  font-size: 12px;
  font-weight: 800;
}
.api-key-row {
  min-height: 54px;
  display: grid;
  grid-template-columns: 70px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 10px;
  background: #0c0f16;
}
.api-key-row > span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}
.api-key-row strong {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  color: #f3f7ff;
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.api-key-row strong b {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font: inherit;
}
.api-key-row.expanded {
  align-items: start;
}
.api-key-row.expanded strong {
  display: grid;
  gap: 6px;
}
.api-key-row.expanded strong b {
  padding: 7px 8px;
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 8px;
  background: rgba(255,255,255,.04);
  color: #f8fbff;
  font-family: Consolas, "Cascadia Mono", monospace;
  font-size: 12px;
  line-height: 1.45;
  overflow-wrap: anywhere;
  white-space: normal;
}
.api-key-row strong em {
  flex: 0 0 auto;
  max-width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-style: normal;
  color: #9fb1c9;
  font-size: 11px;
  font-weight: 800;
}
.api-key-row div {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.api-key-row button {
  min-height: 30px;
  border: 0;
  border-radius: 8px;
  padding: 0 9px;
  background: #202430;
  color: #eef4ff;
  font-size: 12px;
  font-weight: 900;
}
.api-key-row button:disabled {
  opacity: .38;
  cursor: not-allowed;
}
.api-key-row .danger {
  background: rgba(255, 92, 115, .14);
  color: #ffb5c0;
}
.admin-users-head {
  min-height: 58px;
  padding: 16px 18px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--line);
}
.admin-user-list {
  max-height: calc(100vh - 250px);
  padding: 14px;
  overflow: auto;
  display: grid;
  gap: 12px;
  align-content: start;
  overscroll-behavior: contain;
}
.admin-empty {
  min-height: 180px;
  display: grid;
  place-items: center;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: 12px;
}
.admin-user-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px;
  background: #0d1017;
  display: grid;
  gap: 13px;
}
.admin-user-main {
  display: flex;
  align-items: center;
  gap: 12px;
}
.admin-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  flex: none;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #58d7ff, #4b6bff);
  color: #fff;
  font-weight: 900;
}
.admin-user-main strong {
  display: block;
}
.admin-user-main p,
.admin-user-main small {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 12px;
}
.admin-edit-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  align-items: end;
}
.admin-check {
  min-height: 38px;
  display: flex !important;
  align-items: center;
  gap: 9px !important;
  padding-top: 20px;
}
.admin-check input {
  width: 18px;
  min-height: 18px;
  accent-color: var(--accent);
}
.admin-card-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}
.admin-card-actions .danger {
  background: rgba(255, 92, 115, .14);
  color: #ffb5c0;
}
.admin-assets-modal {
  position: fixed;
  inset: 0;
  z-index: 34;
  display: none;
  place-items: center;
  padding: 28px;
  background: rgba(4, 6, 10, .78);
  backdrop-filter: blur(8px);
}
.admin-assets-modal.open {
  display: grid;
}
.admin-assets-card {
  width: min(1120px, 100%);
  max-height: calc(100vh - 56px);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 18px;
  background: #11141c;
  box-shadow: 0 30px 100px rgba(0,0,0,.58);
}
.admin-assets-head {
  min-height: 70px;
  padding: 18px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--line);
}
.admin-assets-head strong {
  display: block;
  font-size: 22px;
}
.admin-assets-head span {
  color: var(--muted);
  font-size: 13px;
}
.admin-assets-head button {
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 10px;
  background: #242837;
  color: #fff;
  font-size: 22px;
}
.admin-assets-list {
  min-height: 0;
  overflow: auto;
  padding: 16px;
  display: grid;
  gap: 14px;
  align-content: start;
}
.admin-asset-card {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
  background: #0c0f16;
}
.admin-asset-media {
  min-height: 160px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border-radius: 10px;
  background: #181c27;
}
.admin-asset-media img,
.admin-asset-media video {
  width: 100%;
  max-height: 240px;
  object-fit: contain;
  display: block;
}
.admin-asset-placeholder {
  padding: 12px;
  color: var(--muted);
  text-align: center;
  font-weight: 800;
}
.admin-asset-info {
  min-width: 0;
  display: grid;
  gap: 10px;
  align-content: start;
}
.admin-asset-info h4 {
  margin: 0;
  color: #f8fbff;
  line-height: 1.55;
  overflow-wrap: anywhere;
}
.admin-asset-meta {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
.admin-asset-meta span {
  min-width: 0;
  padding: 8px 10px;
  border-radius: 9px;
  background: rgba(255,255,255,.04);
  color: #e9f0ff;
  font-size: 12px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}
.admin-asset-meta b {
  display: block;
  margin-bottom: 3px;
  color: #8fa3c2;
}
.admin-asset-info a {
  width: fit-content;
  min-height: 34px;
  padding: 0 12px;
  border-radius: 9px;
  display: inline-flex;
  align-items: center;
  background: linear-gradient(135deg, #4b6bff, #58d7ff);
  color: #fff;
  text-decoration: none;
  font-size: 13px;
  font-weight: 900;
}

.preview-modal {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: none;
  place-items: center;
  padding: 28px;
  background: rgba(4, 6, 10, .78);
  backdrop-filter: blur(8px);
}
.preview-modal.open { display: grid; }
.preview-card {
  width: min(980px, 100%);
  max-height: calc(100vh - 56px);
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  position: relative;
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 16px;
  overflow: hidden;
  background: #12151d;
  box-shadow: 0 30px 100px rgba(0,0,0,.58);
}
.preview-close {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 2;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 10px;
  background: rgba(15,18,26,.78);
  color: #fff;
  font-size: 22px;
}
.preview-body {
  min-height: 280px;
  display: grid;
  place-items: center;
  background: #090b10;
  overflow: auto;
}
.preview-body img,
.preview-body video {
  max-width: 100%;
  max-height: calc(100vh - 190px);
  display: block;
  object-fit: contain;
}
.preview-meta {
  padding: 14px 16px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px 14px;
  align-items: center;
  border-top: 1px solid var(--line);
}
.preview-meta strong { font-size: 16px; }
.preview-meta p {
  grid-column: 1;
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.preview-meta a {
  grid-row: 1 / span 2;
  grid-column: 2;
  min-width: 96px;
  min-height: 38px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #4b6bff, #58d7ff);
  color: #fff;
  text-decoration: none;
  font-weight: 900;
}
.composer-card {
  min-height: 184px;
  border-radius: 24px;
  background:
    linear-gradient(180deg, rgba(255,255,255,.045), rgba(255,255,255,.015)),
    #1b1e27;
  border: 1px solid rgba(255,255,255,.09);
  box-shadow: 0 22px 70px rgba(0,0,0,.42), inset 0 1px 0 rgba(255,255,255,.05);
  padding: 18px 18px 16px;
  display: grid;
  grid-template-columns: 128px 1fr;
  gap: 18px;
}
.composer-card.drag-over {
  border-color: rgba(5, 215, 255, .75);
  box-shadow: 0 22px 70px rgba(0,0,0,.42), 0 0 0 3px rgba(5, 215, 255, .16);
}
.reference-tile-wrap {
  position: relative;
  min-width: 0;
  display: flex;
  align-items: flex-start;
  gap: 8px;
  flex-wrap: wrap;
}
.upload-tile {
  width: 60px;
  height: 74px;
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 8px;
  background: linear-gradient(180deg, #303543, #262a36);
  color: #9aa3b4;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 4px;
  transform: rotate(-7deg);
  box-shadow: 0 12px 24px rgba(0,0,0,.22);
  transition: transform .18s ease, border-color .18s ease, background .18s ease, box-shadow .18s ease, color .18s ease;
  cursor: pointer;
  position: relative;
  overflow: hidden;
}
.upload-tile:hover {
  color: #ecfbff;
  border-color: rgba(5, 215, 255, .72);
  background: linear-gradient(180deg, rgba(5, 215, 255, .18), rgba(75, 107, 255, .12)), #262d3c;
  box-shadow: 0 16px 34px rgba(0,0,0,.28), 0 0 0 3px rgba(5, 215, 255, .12);
  transform: rotate(-2deg) translateY(-2px);
}
.upload-tile.drag-over {
  color: #dffbff;
  background: rgba(5, 215, 255, .16);
  border: 1px dashed rgba(5, 215, 255, .78);
  transform: rotate(0deg) scale(1.02);
}
.upload-tile input { display: none; }
.upload-tile img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: none;
}
.upload-tile span { font-size: 24px; line-height: 1; color: currentColor; }
.upload-tile small { font-size: 11px; font-weight: 800; }
.upload-tile.has-preview {
  color: transparent;
  border-color: rgba(5, 215, 255, .5);
}
.upload-tile.has-preview img { display: block; }
.upload-tile.has-preview::after {
  content: "更换";
  position: absolute;
  inset: auto 6px 6px;
  min-height: 20px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  background: rgba(7, 10, 16, .68);
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  opacity: 0;
  transition: opacity .18s ease;
}
.upload-tile.has-preview:hover::after { opacity: 1; }
.reference-list {
  display: flex;
  flex: 1;
  flex-wrap: wrap;
  gap: 7px;
  min-width: 0;
  max-height: 84px;
  overflow: auto;
}
.reference-chip {
  position: relative;
  width: 54px;
  height: 66px;
  border: 1px solid rgba(5, 215, 255, .28);
  border-radius: 8px;
  overflow: hidden;
  background: #10131b;
  box-shadow: 0 10px 20px rgba(0,0,0,.22);
}
.reference-chip img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.reference-chip button {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 18px;
  height: 18px;
  border: 0;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: rgba(7, 10, 16, .76);
  color: #fff;
  font-size: 13px;
  font-weight: 900;
  line-height: 1;
}
.reference-clear {
  position: absolute;
  top: -3px;
  right: 0;
  z-index: 3;
  width: 22px;
  height: 22px;
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: rgba(10, 13, 20, .86);
  color: #fff;
  font-size: 15px;
  line-height: 1;
  font-weight: 900;
  box-shadow: 0 8px 18px rgba(0,0,0,.32);
  cursor: pointer;
  transition: transform .18s ease, background .18s ease, opacity .18s ease;
}
.reference-clear:hover {
  background: rgba(255, 92, 115, .92);
  transform: translateY(-1px) scale(1.04);
}
.reference-clear[hidden] {
  display: none;
}
.composer-main {
  display: grid;
  grid-template-rows: 1fr auto;
  gap: 12px;
}
#promptInput {
  border: 0;
  background: transparent;
  color: #f8fbff;
  outline: none;
  resize: none;
  padding: 0;
}
#promptInput {
  min-height: 64px;
  font-size: 15px;
  line-height: 1.7;
  letter-spacing: 0;
}
#promptInput::placeholder { color: #8d95a6; }
.composer-actions {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
}
.composer-actions select {
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background:
    linear-gradient(180deg, rgba(255,255,255,.045), rgba(255,255,255,.015)),
    #151821;
  color: #f3f6fb;
  padding: 0 34px 0 14px;
  font-weight: 800;
  width: auto;
  min-width: 112px;
  line-height: 1;
  outline: none;
  appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, #b9c2d3 50%),
    linear-gradient(135deg, #b9c2d3 50%, transparent 50%),
    linear-gradient(180deg, rgba(255,255,255,.045), rgba(255,255,255,.015));
  background-position:
    calc(100% - 18px) 50%,
    calc(100% - 12px) 50%,
    0 0;
  background-size:
    6px 6px,
    6px 6px,
    100% 100%;
  background-repeat: no-repeat;
  transition: background-color .18s ease, border-color .18s ease, box-shadow .18s ease, transform .18s ease;
}
.composer-actions select:hover,
.composer-actions select:focus {
  background-color: #202430;
  border-color: rgba(255,255,255,.14);
  box-shadow: 0 0 0 3px rgba(5, 215, 255, .08);
}
.composer-actions select option {
  background: #171a22;
  color: #f3f6fb;
  font-weight: 700;
  padding: 10px 12px;
}
.send-btn {
  margin-left: auto;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 0;
  color: #fff;
  font-size: 20px;
  background: #363d4d;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.1);
  transition: transform .18s ease, filter .18s ease, opacity .18s ease;
}
.send-btn:not(:disabled) { background: linear-gradient(135deg, #4b6bff, #58d7ff); }
.send-btn:not(:disabled):hover { transform: translateY(-1px); filter: brightness(1.08); }
.send-btn:disabled { cursor: wait; opacity: .65; }

.toast {
  position: fixed;
  left: 50%;
  top: 24px;
  z-index: 80;
  transform: translate(-50%, -14px);
  opacity: 0;
  pointer-events: none;
  max-width: min(520px, calc(100vw - 32px));
  padding: 12px 16px;
  border: 1px solid rgba(255,255,255,.14);
  border-radius: 12px;
  background: rgba(244, 247, 255, .96);
  color: #101319;
  box-shadow: 0 18px 48px rgba(0,0,0,.34);
  font-weight: 800;
  text-align: center;
  transition: opacity .2s ease, transform .2s ease;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* Compact polish: slightly denser controls and media for a more refined workspace. */
.app {
  grid-template-columns: 68px 224px minmax(0, 1fr);
}
.app.hide-history {
  grid-template-columns: 68px minmax(0, 1fr);
}
.icon-rail {
  padding: 20px 8px 16px;
  gap: 14px;
}
.logo {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  margin-bottom: 72px;
}
.rail-icon {
  width: 50px;
  min-height: 42px;
  border-radius: 9px;
}
.rail-icon span {
  font-size: 11px;
}
.user-entry {
  width: 38px;
  height: 38px;
}
.user-entry span {
  width: 27px;
  height: 27px;
}
.history-panel {
  padding: 22px 16px;
}
.feed {
  padding: 46px 42px 300px;
}
.date-title,
.work-item {
  max-width: 780px;
  margin-left: 0;
  margin-right: auto;
}
.date-title {
  margin-bottom: 20px;
  font-size: 24px;
}
.work-item {
  margin-bottom: 26px;
}
.work-prompt {
  grid-template-columns: 32px 1fr;
  gap: 10px;
  margin-bottom: 11px;
}
.prompt-thumb {
  width: 32px;
  height: 32px;
}
.prompt-text {
  font-size: 14px;
  line-height: 1.58;
  padding-right: 36px;
}
.prompt-copy {
  -webkit-line-clamp: 3;
}
.prompt-meta,
.item-details {
  font-size: 13px;
}
.work-delete {
  top: 0;
  right: 0;
  z-index: 16;
  width: 22px;
  height: 22px;
  font-size: 15px;
}
.media-frame img,
.media-frame video {
  max-width: min(360px, 100%);
  max-height: 360px;
}
.media-frame video {
  max-width: min(390px, 100%);
}
.pending-media {
  width: min(310px, 82vw);
  min-height: 180px;
}
.work-actions {
  margin-top: 12px;
}
.work-actions button,
.work-actions a {
  min-height: 32px;
  padding: 0 11px;
  border-radius: 7px;
  font-size: 13px;
}
.bottom-composer {
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  width: min(760px, calc(100% - 88px));
}
.composer-card {
  min-height: 144px;
  grid-template-columns: 128px 1fr;
  gap: 14px;
  padding: 14px 14px 13px;
  border-radius: 20px;
}
.reference-tile-wrap {
  width: auto;
  min-height: 76px;
}
.upload-tile {
  width: 52px;
  height: 64px;
}
.upload-tile span {
  font-size: 21px;
}
.upload-tile small {
  font-size: 10px;
}
.reference-clear {
  width: 20px;
  height: 20px;
  font-size: 13px;
}
#promptInput {
  min-height: 48px;
  font-size: 14px;
  line-height: 1.55;
}
.composer-main {
  gap: 10px;
}
.composer-actions {
  gap: 6px;
}
.composer-actions select {
  height: 34px;
  min-width: 104px;
  border-radius: 10px;
  padding-left: 12px;
  font-size: 13px;
}
.send-btn {
  width: 36px;
  height: 36px;
  font-size: 18px;
}
.agent-page,
.asset-page,
.admin-page,
.lobby-page,
.commerce-page,
.market-page {
  padding: 42px 40px 28px;
}
.agent-head,
.asset-head,
.admin-head,
.lobby-head,
.commerce-head,
.market-head,
.asset-tabs,
.asset-grid,
.admin-grid,
.lobby-home,
.commerce-builder,
.market-layout {
  max-width: 1040px;
}
.agent-head strong,
.asset-head strong,
.admin-head strong,
.lobby-head strong,
.commerce-head strong,
.market-head strong {
  font-size: 26px;
}
.agent-messages {
  max-width: 840px;
}
.agent-bubble {
  font-size: 13px;
  line-height: 1.65;
  padding: 12px 14px;
  border-radius: 12px;
}
.agent-composer {
  max-width: 840px;
  grid-template-columns: 78px minmax(0, 1fr) auto;
  padding-top: 14px;
}
.agent-video-tile {
  width: 76px;
  height: 76px;
}
.agent-composer textarea {
  min-height: 72px;
  font-size: 13px;
  border-radius: 12px;
  padding: 12px;
}
.agent-composer button {
  min-height: 38px;
  border-radius: 9px;
  padding: 0 15px;
}
.asset-grid {
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
}
.asset-card {
  border-radius: 11px;
}
.asset-card p {
  font-size: 12px;
}
.asset-card > div:not(.asset-media) {
  padding: 9px;
}
.admin-grid {
  grid-template-columns: 160px minmax(0, 1fr);
  gap: 14px;
}
.admin-section.active {
  grid-template-columns: 290px minmax(0, 1fr);
  gap: 14px;
}
.admin-form,
.admin-user-card {
  padding: 14px;
}
.admin-edit-grid {
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
}
.admin-form input,
.admin-form select,
.admin-form textarea,
.admin-edit-grid input,
.admin-edit-grid select {
  min-height: 34px;
  border-radius: 8px;
  font-size: 13px;
}
.lobby-agent-card {
  padding: 18px;
  border-radius: 20px;
}
.lobby-agent-copy h2 {
  font-size: clamp(24px, 3vw, 38px);
}
.lobby-agent-copy p,
.lobby-text-card p {
  font-size: 13px;
  line-height: 1.65;
}

.market-page .market-table-wrap {
  min-height: 320px;
  max-height: 54vh;
}

.auth-overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: none;
  place-items: center;
  background: rgba(5, 7, 12, .38);
  backdrop-filter: blur(4px);
}
.auth-overlay.open { display: grid; }
.auth-card {
  width: min(380px, calc(100% - 36px));
  padding: 28px;
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 18px;
  background: #181b24;
  box-shadow: 0 28px 90px rgba(0,0,0,.5);
  display: grid;
  gap: 14px;
}
.auth-logo {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  color: #061219;
  font-weight: 900;
  background: linear-gradient(135deg, #6df5ff, #4468ff 54%, #80ffb4);
}
.auth-card h2 { margin: 4px 0 0; }
.auth-card p, .auth-card small {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}
.auth-message {
  padding: 10px 12px;
  border: 1px solid rgba(255, 107, 129, .38);
  border-radius: 10px;
  background: rgba(255, 107, 129, .12);
  color: #ffd6de;
  font-size: 13px;
  line-height: 1.5;
  font-weight: 700;
}
.auth-card label {
  display: grid;
  gap: 7px;
  color: #cfd7e6;
  font-weight: 800;
  font-size: 13px;
}
.auth-card input {
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #10131b;
  color: #fff;
  outline: none;
  padding: 0 12px;
}
.auth-card input:focus {
  border-color: rgba(5, 215, 255, .55);
  box-shadow: 0 0 0 3px rgba(5, 215, 255, .1);
}
.auth-card button, .user-card button {
  height: 42px;
  border: 0;
  border-radius: 10px;
  background: linear-gradient(135deg, #4b6bff, #58d7ff);
  color: #fff;
  font-weight: 900;
}
.auth-card .auth-secondary {
  background: transparent;
  border: 1px solid var(--line);
  color: #d9e1ef;
}
.auth-card .auth-secondary:hover {
  border-color: rgba(5, 215, 255, .45);
  color: #fff;
}
.register-card {
  display: none;
}
.auth-overlay.register-mode #loginForm {
  display: none;
}
.auth-overlay.register-mode #registerForm {
  display: grid;
}
.user-popover {
  position: fixed;
  left: 84px;
  bottom: 18px;
  z-index: 12;
  display: none;
}
.user-popover.open { display: block; }
.user-card {
  width: 300px;
  padding: 16px;
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 14px;
  background: #171a22;
  box-shadow: 0 24px 70px rgba(0,0,0,.45);
  display: grid;
  gap: 12px;
}
.user-card-head {
  display: flex;
  align-items: center;
  gap: 12px;
}
.user-card-head > span {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #58d7ff, #4b6bff);
  font-weight: 900;
}
.user-card-head strong { display: block; }
.user-card-head p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 12px;
}
.user-info-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 13px;
}
.user-info-row strong {
  color: #f4f7ff;
}
.user-api-box {
  display: none;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #10131b;
}
.user-api-box strong {
  display: block;
  font-size: 14px;
}
.user-api-box p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}
.user-api-box .vip-upgrade-hint {
  margin-top: 7px;
  padding: 7px 9px;
  border: 1px solid rgba(5, 215, 255, .18);
  border-radius: 10px;
  color: #cfeeff;
  background: rgba(5, 215, 255, .07);
}
.user-api-box form {
  display: grid;
  gap: 8px;
}
.user-api-box input {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #0b0e15;
  color: #fff;
  outline: none;
  padding: 0 11px;
}
.user-api-box input:focus {
  border-color: rgba(5, 215, 255, .55);
  box-shadow: 0 0 0 3px rgba(5, 215, 255, .1);
}
.user-api-box button {
  min-height: 38px;
}

.contact-widget {
  position: fixed;
  right: 22px;
  bottom: 96px;
  z-index: 18;
  touch-action: none;
}
.contact-fab {
  width: 54px;
  height: 54px;
  border: 0;
  border-radius: 50%;
  display: grid;
  place-items: center;
  padding: 0;
  background: transparent;
  overflow: hidden;
  box-shadow: 0 18px 45px rgba(0,0,0,.36), 0 0 0 5px rgba(88, 215, 255, .12);
  transition: transform .18s ease, box-shadow .18s ease, filter .18s ease;
  cursor: grab;
}
.contact-fab img {
  width: 100%;
  height: 100%;
  display: block;
}
.contact-fab:hover {
  transform: translateY(-2px);
  box-shadow: 0 22px 52px rgba(0,0,0,.42), 0 0 0 6px rgba(88, 215, 255, .18);
}
.contact-widget.dragging .contact-fab {
  cursor: grabbing;
  transform: scale(.96);
  filter: brightness(1.08);
}
.contact-panel {
  position: absolute;
  right: 0;
  bottom: 68px;
  width: 300px;
  display: none;
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 16px;
  background: #171a22;
  box-shadow: 0 24px 70px rgba(0,0,0,.48);
  overflow: hidden;
}
.contact-panel.open { display: block; }
.contact-head {
  min-height: 50px;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
}
.contact-head strong {
  font-size: 16px;
}
.contact-head button {
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 8px;
  background: #242837;
  color: #fff;
  font-size: 20px;
}
.contact-panel img {
  width: 100%;
  display: block;
  background: #fff;
}

@media (max-width: 980px) {
  .app { grid-template-columns: 64px minmax(0, 1fr); }
  .history-panel { display: none; }
  .asset-page { padding: 40px 18px 28px; }
  .agent-page { padding: 40px 18px 28px; }
  .lobby-page { padding: 40px 18px 28px; }
  .market-page {
    padding: 40px 18px 28px;
    overflow: auto;
  }
  .market-layout {
    grid-template-columns: 1fr;
  }
  .market-side {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
  .market-summary,
  .market-source-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .market-panels,
  .market-toolbar {
    grid-template-columns: 1fr;
  }
  .commerce-page {
    grid-template-columns: 1fr;
    padding: 40px 18px 28px;
    overflow: auto;
  }
  .commerce-workspace {
    padding-bottom: 150px;
  }
  .commerce-side {
    min-height: auto;
  }
  .commerce-builder {
    grid-template-columns: 1fr;
  }
  .commerce-assets-list {
    max-height: none;
  }
  .lobby-agent-card { grid-template-columns: 1fr; }
  .admin-page { padding: 40px 18px 28px; }
  .admin-grid { grid-template-columns: 1fr; overflow: auto; }
  .admin-side-nav { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .admin-section.active,
  #adminApiSection.active { grid-template-columns: 1fr; }
  .admin-edit-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .feed { padding: 72px 18px 230px; }
  .bottom-composer { width: calc(100% - 28px); }
}

@media (max-width: 640px) {
  .model-pool-head,
  .model-pool-picker {
    grid-template-columns: 1fr;
  }
  .model-pool-head {
    display: grid;
  }
  .model-pool-endpoint {
    grid-template-columns: 1fr;
  }
  .model-pool-costs {
    grid-template-columns: 1fr;
  }
  .icon-rail { display: none; }
  .app,
  .app.hide-history { grid-template-columns: 1fr; }
  .composer-card { grid-template-columns: 1fr; }
  .lobby-head,
  .lobby-text-head,
  .commerce-head,
  .market-head,
  .market-section-title,
  .lobby-agent-form div {
    align-items: stretch;
    flex-direction: column;
  }
  .market-side,
  .market-summary,
  .market-source-grid,
  .market-form-grid {
    grid-template-columns: 1fr;
  }
  .commerce-options {
    grid-template-columns: 1fr;
  }
  .commerce-button-row {
    grid-template-columns: 1fr;
  }
  .commerce-agent-settings,
  .commerce-agent-actions {
    grid-template-columns: 1fr;
  }
  .commerce-workflow,
  .commerce-suggestion-grid {
    grid-template-columns: 1fr;
  }
  .commerce-agent-selling {
    grid-column: auto;
  }
  .commerce-agent-message {
    max-width: 100%;
  }
  .commerce-agent-form {
    left: 50%;
    width: calc(100% - 36px);
    grid-template-columns: 64px minmax(0, 1fr) 42px;
    gap: 9px;
    padding: 10px;
  }
  .commerce-agent-send {
    grid-column: auto;
  }
  .agent-composer {
    grid-template-columns: 88px minmax(0, 1fr);
  }
  .agent-composer > button {
    grid-column: 1 / -1;
  }
  .upload-tile { display: none; }
  .item-details {
    display: block;
    margin: 4px 0 0;
  }
  .detail-panel {
    position: static;
    width: 100%;
    min-width: 0;
    margin-top: 8px;
  }
  .contact-widget {
    right: 14px;
    bottom: 84px;
  }
  .contact-panel {
    width: min(300px, calc(100vw - 28px));
  }
  .admin-edit-grid { grid-template-columns: 1fr; }
  .api-key-row { grid-template-columns: 1fr; }
  .api-key-row div { justify-content: stretch; }
  .api-key-row button { flex: 1; }
  .admin-card-actions { justify-content: stretch; }
  .admin-card-actions button { flex: 1; }
  .admin-assets-modal { padding: 12px; }
  .admin-asset-card,
  .admin-asset-meta { grid-template-columns: 1fr; }
  .admin-asset-media { min-height: 140px; }
  .media-frame img, .media-frame video { max-width: 100%; }
}
