:root {
  --bg: #070b14;
  --panel: rgba(255,255,255,.055);
  --panel-strong: rgba(255,255,255,.09);
  --line: rgba(255,255,255,.11);
  --line-strong: rgba(255,255,255,.18);
  --text: #f5f7fb;
  --muted: #9ea9bd;
  --weak: #6f7b91;
  --brand: #7bb7ff;
  --brand-2: #bfe0ff;
  --danger: #ff7b8a;
  --ok: #77e5b2;
  --radius: 18px;
  --shadow: 0 20px 80px rgba(0,0,0,.38);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(circle at top left, rgba(76,133,255,.20), transparent 32%),
    radial-gradient(circle at bottom right, rgba(60,201,255,.14), transparent 36%),
    var(--bg);
  color: var(--text);
  font-family: Arial, "Microsoft YaHei", sans-serif;
}

button,
textarea,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.svg-slot svg {
  display: block;
  width: 100%;
  height: 100%;
}

.app-shell {
  min-height: 100vh;
}

.pc-shell {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr) 310px;
}

.sidebar,
.asset-panel,
.admin-sidebar {
  border-right: 1px solid var(--line);
  background: rgba(6,10,18,.72);
  backdrop-filter: blur(18px);
}

.asset-panel {
  border-right: 0;
  border-left: 1px solid var(--line);
  padding: 20px;
}

.sidebar {
  padding: 20px;
  display: flex;
  flex-direction: column;
}

.brand-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-row.compact {
  gap: 10px;
}

.brand-mark {
  width: 38px;
  height: 38px;
  color: var(--brand);
}

.brand-title {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: .2px;
}

.brand-subtitle {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.primary-action,
.send-button {
  border: 0;
  color: #07111f;
  background: linear-gradient(135deg, #d8ecff, #78b8ff);
  box-shadow: 0 10px 30px rgba(102,168,255,.28);
  border-radius: 14px;
  padding: 12px 14px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.primary-action {
  width: 100%;
  margin: 24px 0;
}

.primary-action .svg-slot,
.send-button .svg-slot {
  width: 18px;
  height: 18px;
}

.ghost-button,
.icon-button,
.user-pill {
  border: 1px solid var(--line);
  color: var(--text);
  background: rgba(255,255,255,.055);
  border-radius: 12px;
  padding: 9px 12px;
}

.icon-button {
  width: 42px;
  height: 42px;
  padding: 10px;
}

.user-pill {
  border-color: rgba(123,183,255,.35);
}

.side-section {
  margin-top: 12px;
}

.bottom-section {
  margin-top: auto;
}

.section-title,
.panel-title,
.mobile-card-title {
  color: var(--text);
  font-size: 14px;
  font-weight: 800;
  margin-bottom: 12px;
}

.side-search {
  color: var(--weak);
  background: rgba(255,255,255,.045);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 13px;
  margin-bottom: 12px;
}

.conversation-item,
.nav-link,
.asset-row,
.setting-row,
.admin-nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 14px;
  padding: 11px 12px;
  text-decoration: none;
}

.conversation-item {
  display: block;
  margin-bottom: 8px;
}

.conversation-item.active,
.nav-link.active,
.admin-nav-item.active {
  color: var(--text);
  background: rgba(123,183,255,.12);
  border-color: rgba(123,183,255,.22);
}

.item-title {
  color: var(--text);
  font-size: 14px;
}

.item-desc {
  color: var(--weak);
  font-size: 12px;
  margin-top: 4px;
}

.nav-link .svg-slot,
.asset-row .svg-slot,
.setting-row .svg-slot,
.tab .svg-slot {
  width: 18px;
  height: 18px;
  color: var(--brand);
}

.workspace {
  min-width: 0;
  display: flex;
  flex-direction: column;
  height: 100vh;
}

.topbar,
.admin-topbar {
  height: 76px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  background: rgba(7,11,20,.62);
  backdrop-filter: blur(16px);
}

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

.page-title {
  font-size: 22px;
  font-weight: 850;
}

.page-subtitle {
  color: var(--muted);
  font-size: 13px;
  margin-top: 5px;
}

.chat-panel {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.message-list {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 28px;
  content-visibility: auto;
  contain: layout paint;
}

.message {
  display: flex;
  gap: 12px;
  margin-bottom: 18px;
}

.message.user {
  justify-content: flex-end;
}

.message.user .bubble {
  background: rgba(123,183,255,.14);
  border-color: rgba(123,183,255,.28);
}

.avatar {
  width: 34px;
  height: 34px;
  color: var(--brand);
  flex: 0 0 auto;
}

.bubble {
  max-width: 760px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,.06);
  border-radius: 18px;
  padding: 14px 16px;
  box-shadow: 0 12px 40px rgba(0,0,0,.18);
}

.bubble-title {
  font-weight: 800;
  margin-bottom: 8px;
}

.bubble-text {
  color: #dbe4f3;
  line-height: 1.75;
  white-space: pre-wrap;
  word-break: break-word;
}

.composer-card {
  border-top: 1px solid var(--line);
  background: rgba(7,11,20,.82);
  backdrop-filter: blur(18px);
  padding: 14px 24px 22px;
}

.mode-header {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 10px;
}

.muted {
  color: var(--weak);
}

.ability-strip {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding: 2px 0 12px;
  scrollbar-width: thin;
}

.ability-card {
  min-width: 190px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,.055);
  color: var(--text);
  border-radius: 16px;
  padding: 12px 14px;
  text-align: left;
  transition: transform .18s ease, border-color .18s ease, opacity .18s ease, background .18s ease;
}

.ability-card.selected {
  border-color: rgba(123,183,255,.55);
  background: rgba(123,183,255,.13);
}

.ability-card.pending {
  opacity: .56;
}

.ability-card:hover {
  transform: translateY(-1px);
}

.ability-title {
  font-weight: 800;
  font-size: 14px;
  margin-bottom: 6px;
}

.ability-subtitle {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.prompt-input {
  width: 100%;
  resize: none;
  color: var(--text);
  background: rgba(255,255,255,.055);
  border: 1px solid var(--line);
  border-radius: 16px;
  outline: none;
  padding: 14px;
  line-height: 1.6;
}

.prompt-input:focus {
  border-color: rgba(123,183,255,.55);
}

.composer-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-top: 12px;
}

.left-actions,
.right-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

.protected-action:disabled,
.ghost-button:disabled {
  opacity: .45;
  cursor: not-allowed;
}

.asset-card,
.admin-panel,
.metric-card {
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: 0 12px 40px rgba(0,0,0,.16);
  margin-bottom: 16px;
}

.anchor-chip {
  display: inline-flex;
  margin: 0 8px 8px 0;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: rgba(255,255,255,.04);
  font-size: 12px;
}

.setting-row {
  width: 100%;
  margin-top: 8px;
  color: var(--text);
  background: rgba(255,255,255,.045);
}

.focus-pulse {
  animation: whiteLightScale .5s ease both;
}

@keyframes whiteLightScale {
  0% {
    transform: scale(1);
    box-shadow: none;
  }
  35% {
    transform: scale(1.045);
    box-shadow: inset 120px 0 80px rgba(255,255,255,.38), 0 0 30px rgba(255,255,255,.22);
  }
  100% {
    transform: scale(1);
    box-shadow: none;
  }
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%) translateY(18px);
  opacity: 0;
  pointer-events: none;
  padding: 12px 16px;
  border-radius: 14px;
  color: var(--text);
  background: rgba(15,22,35,.94);
  border: 1px solid var(--line-strong);
  box-shadow: var(--shadow);
  transition: opacity .2s ease, transform .2s ease;
  z-index: 100;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.mobile-shell,
.admin-mobile-shell {
  min-height: 100vh;
  padding-bottom: 148px;
}

.mobile-top {
  height: 64px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px;
  background: rgba(7,11,20,.82);
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: blur(14px);
}

.mobile-content {
  padding: 14px;
}

.mobile-message-list {
  padding: 0;
  overflow: visible;
}

.mobile-composer {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 62px;
  padding: 10px 12px 12px;
  border-top: 1px solid var(--line);
  background: rgba(7,11,20,.94);
  backdrop-filter: blur(16px);
  z-index: 30;
}

.mobile-ability-strip .ability-card {
  min-width: 148px;
  padding: 10px 12px;
}

.mobile-input-row {
  display: grid;
  grid-template-columns: 1fr 48px;
  gap: 8px;
}

.mobile-input {
  min-height: 48px;
  max-height: 96px;
  padding: 10px 12px;
}

.mobile-send {
  width: 48px;
  height: 48px;
  padding: 0;
}

.mobile-action-row {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.bottom-tabs {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  height: 62px;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  border-top: 1px solid var(--line);
  background: rgba(7,11,20,.96);
  backdrop-filter: blur(16px);
  z-index: 35;
}

.tab {
  border: 0;
  background: transparent;
  color: var(--weak);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  font-size: 11px;
}

.tab.active {
  color: var(--text);
}

.tab .svg-slot {
  width: 20px;
  height: 20px;
}

.mobile-settings {
  margin-top: 18px;
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 18px;
  padding: 14px;
}

.admin-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 290px minmax(0, 1fr);
}

.admin-sidebar {
  padding: 20px;
  height: 100vh;
  overflow: auto;
}

.admin-nav {
  margin-top: 22px;
  display: grid;
  gap: 6px;
}

.admin-nav-item {
  font-size: 13px;
}

.admin-main {
  min-width: 0;
}

.admin-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  padding: 20px;
}

.metric-label {
  color: var(--muted);
  font-size: 13px;
}

.metric-value {
  margin-top: 10px;
  font-size: 28px;
  font-weight: 850;
}

.admin-panels {
  padding: 0 20px 20px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.panel-line {
  color: var(--muted);
  line-height: 1.7;
  font-size: 14px;
}

.admin-mobile-content {
  padding: 14px;
}

.mobile-admin-grid {
  display: grid;
  gap: 12px;
}

body.generating {
  user-select: none;
}

body.generating textarea,
body.generating button,
body.generating input {
  user-select: auto;
}

@media (max-width: 1180px) {
  .pc-shell {
    grid-template-columns: 240px minmax(0, 1fr);
  }

  .asset-panel {
    display: none;
  }

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

  .admin-panels {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .pc-shell,
  .admin-shell {
    display: block;
  }

  .sidebar,
  .asset-panel,
  .admin-sidebar {
    display: none;
  }

  .topbar,
  .admin-topbar {
    height: auto;
    padding: 16px;
    gap: 12px;
    align-items: flex-start;
  }

  .top-actions {
    display: none;
  }

  .message-list {
    padding: 16px;
  }

  .composer-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .left-actions,
  .right-actions {
    justify-content: space-between;
  }

  .admin-grid {
    grid-template-columns: 1fr;
  }
}
/* stage8a-admin-layout-fix */
@media (min-width: 761px) {
  body[data-page="admin"] {
    height: 100vh;
    overflow: hidden;
  }

  body[data-page="admin"] .admin-shell {
    height: 100vh;
    min-height: 100vh;
    overflow: hidden;
    display: grid;
    grid-template-columns: 290px minmax(0, 1fr);
  }

  body[data-page="admin"] .admin-sidebar {
    height: 100vh;
    max-height: 100vh;
    overflow-y: auto;
    overflow-x: hidden;
    position: sticky;
    top: 0;
    align-self: start;
    scrollbar-width: thin;
  }

  body[data-page="admin"] .admin-main {
    height: 100vh;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    overscroll-behavior: contain;
  }

  body[data-page="admin"] .admin-topbar {
    position: sticky;
    top: 0;
    z-index: 25;
    background: rgba(7,11,20,.88);
    backdrop-filter: blur(16px);
  }

  body[data-page="admin"] .viz-section {
    padding-bottom: 40px;
  }
}
