:root {
  --bg: #f6f8fb;
  --panel: #ffffff;
  --ink: #111827;
  --muted: #7b8494;
  --line: #e3e7ee;
  --soft: #f1f3f7;
  --dark: #111827;
  --blue: #6366f1;
  --shadow: 0 18px 60px rgba(20, 28, 45, .08);
}

* { box-sizing: border-box; }
html, body {
  width: 100%;
  min-width: 0;
  min-height: 100%;
  overflow-x: hidden;
}
body {
  margin: 0;
  color: var(--ink);
  background: var(--bg);
  font-family: "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
}
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }

.studio-topbar {
  width: 100vw;
  height: 70px;
  display: grid;
  grid-template-columns: clamp(240px, 18vw, 300px) minmax(0, 1fr) clamp(220px, 18vw, 300px);
  align-items: center;
  padding: 0 22px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, .82);
  backdrop-filter: blur(18px);
  position: sticky;
  top: 0;
  z-index: 30;
}
.studio-logo {
  min-width: 0;
  display: inline-flex;
  align-items: center;
  gap: 12px;
}
.studio-logo .logo-mark {
  width: 28px;
  height: 28px;
  display: block;
  flex: 0 0 auto;
  background: var(--dark);
  clip-path: polygon(50% 0, 61% 36%, 100% 50%, 61% 64%, 50% 100%, 39% 64%, 0 50%, 39% 36%);
}
.studio-logo strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 22px;
  font-weight: 900;
  letter-spacing: 0;
}
.top-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 42px;
  color: #344054;
  font-weight: 700;
}
.top-nav a { padding: 9px 0; }
.top-nav a.active { color: #0f172a; }
.top-actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 12px;
}
.soft-btn, .dark-btn {
  height: 40px;
  border-radius: 8px;
  padding: 0 18px;
  border: 1px solid var(--line);
  font-weight: 800;
}
.soft-btn { display: inline-flex; align-items: center; background: #f8fafc; }
.dark-btn { color: #fff; background: #111827; border-color: #111827; }

.user-avatar-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 40px;
  min-width: 0;
  max-width: 174px;
  padding: 0 12px 0 8px;
  border-radius: 8px;
  color: #111827;
  background: #f8fafc;
  border: 1px solid var(--line);
  cursor: pointer;
}
.account-menu-wrap {
  position: relative;
  display: inline-flex;
}
.account-menu-wrap[hidden] { display: none; }
.avatar-circle {
  width: 28px;
  height: 28px;
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 50%;
  color: #fff;
  background: linear-gradient(135deg, #2864ff 0%, #27d2a0 100%);
  font-weight: 900;
  letter-spacing: 0;
}
.user-avatar-btn .avatar-name {
  font-weight: 700;
  font-size: 14px;
  color: var(--ink);
  max-width: 100px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.account-menu {
  position: absolute;
  top: calc(100% + 18px);
  right: 0;
  z-index: 80;
  width: min(78vw, 420px);
  overflow: visible;
  border: 1px solid #d9e0eb;
  border-radius: 12px;
  background: rgba(255, 255, 255, .98);
  box-shadow: 0 30px 80px rgba(30, 41, 59, .16);
}
.account-menu[hidden] { display: none; }
.account-menu:before {
  content: "";
  position: absolute;
  top: -17px;
  right: 24px;
  width: 32px;
  height: 32px;
  border-left: 1px solid #d9e0eb;
  border-top: 1px solid #d9e0eb;
  background: rgba(255, 255, 255, .98);
  transform: rotate(45deg);
}
.account-menu-head {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 70px 1fr;
  align-items: center;
  gap: 18px;
  padding: 34px 32px 30px;
}
.account-menu-avatar {
  width: 70px;
  height: 70px;
  font-size: 28px;
}
.account-menu-head strong {
  display: block;
  overflow: hidden;
  color: #111827;
  font-size: 24px;
  font-weight: 900;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.account-menu-head span:not(.avatar-circle) {
  display: block;
  margin-top: 8px;
  overflow: hidden;
  color: #8b95a8;
  font-size: 16px;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.account-balance {
  padding: 26px 32px 30px;
  border-top: 1px solid #e3e7ee;
  border-bottom: 1px solid #e3e7ee;
}
.account-balance span {
  display: block;
  color: #8b95a8;
  font-size: 16px;
  font-weight: 800;
}
.account-balance strong {
  display: block;
  margin-top: 18px;
  color: #3164f4;
  font-size: 34px;
  line-height: 1;
}
.account-menu-links {
  display: grid;
  gap: 12px;
  padding: 24px 20px 26px;
}
.account-menu-links a {
  min-height: 62px;
  display: grid;
  grid-template-columns: 42px 1fr 18px;
  align-items: center;
  column-gap: 14px;
  border-radius: 10px;
  padding: 10px 14px;
  color: #111827;
}
.account-menu-links a:hover,
.account-menu-links a:focus-visible {
  background: #f2f5f9;
  outline: none;
}
.menu-icon {
  font-size: 26px;
  color: #1f2a44;
  text-align: center;
}
.account-menu-links strong {
  display: block;
  font-size: 18px;
  font-weight: 900;
}
.account-menu-links small {
  display: block;
  margin-top: 5px;
  overflow: hidden;
  color: #8b95a8;
  font-size: 14px;
  font-weight: 500;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.account-menu-links em {
  color: #9aa3b2;
  font-style: normal;
  font-size: 30px;
  line-height: 1;
}

.studio-shell {
  width: 100vw;
  height: calc(100dvh - 70px);
  display: grid;
  grid-template-columns: clamp(210px, 15vw, 270px) minmax(0, 1fr) clamp(320px, 24vw, 430px);
  overflow: hidden;
}
.left-rail, .asset-panel {
  min-width: 0;
  height: calc(100dvh - 70px);
  overflow: auto;
  background: rgba(255,255,255,.72);
  border-right: 1px solid var(--line);
  padding: 28px 20px 18px;
}
.left-rail {
  display: flex;
  flex-direction: column;
  gap: 22px;
}
.new-project {
  height: 54px;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  border: 0;
  border-radius: 8px;
  color: #fff;
  background: #101827;
  font-size: 16px;
  font-weight: 900;
}
.new-project span { font-size: 24px; font-weight: 400; }
.new-project i {
  width: 1px;
  height: 24px;
  margin-left: 12px;
  border-left: 1px solid rgba(255,255,255,.32);
}
.new-project:after { content: "⌄"; font-size: 14px; }
.history-block h2 {
  margin: 0 0 10px 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}
.history-item, .side-links a {
  width: 100%;
  min-height: 42px;
  display: flex;
  align-items: center;
  gap: 10px;
  border: 0;
  border-radius: 8px;
  padding: 0 12px;
  color: #4b5565;
  background: transparent;
  text-align: left;
}
.history-item:before { content: "▣"; color: #667085; }
.history-item.active { background: #e9edf3; color: #263041; }
.side-links {
  margin-top: auto;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}
.side-links a:before { content: "▱"; color: #667085; }
.quota-card {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 12px 30px rgba(20, 28, 45, .04);
}
.quota-card div {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 10px;
}
.quota-card strong { grid-row: span 2; }
.quota-card span { color: var(--muted); }
.quota-card b { font-size: 18px; }
.quota-card meter {
  width: 100%;
  height: 10px;
  margin-top: 14px;
  accent-color: var(--blue);
}
.quota-card p { margin: 9px 0 0; color: var(--muted); font-size: 12px; }
.user-card {
  display: grid;
  grid-template-columns: 38px 1fr auto 28px;
  align-items: center;
  gap: 10px;
}
.user-card img { width: 38px; height: 38px; object-fit: cover; border-radius: 50%; }
.user-card em {
  padding: 3px 9px;
  border-radius: 999px;
  color: #d48916;
  background: #fff3d9;
  font-style: normal;
  font-size: 12px;
}
.user-card button { border: 0; background: transparent; font-size: 18px; }

.workspace {
  min-width: 0;
  height: calc(100dvh - 70px);
  padding: 28px clamp(22px, 3.2vw, 54px) 44px;
  overflow: auto;
}
.dialog-space {
  min-height: clamp(210px, 31vh, 340px);
  margin-bottom: 28px;
  border-bottom: 1px solid var(--line);
}
.settings-card, .prompt-composer {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255,255,255,.9);
  box-shadow: var(--shadow);
}
.settings-card {
  width: 100%;
  padding: 16px;
  border-radius: 12px;
  box-shadow: 0 10px 24px rgba(20, 28, 45, .05);
}
.control-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}
.select-field label {
  display: block;
  margin-bottom: 9px;
  color: #5c6677;
  font-size: 13px;
  font-weight: 800;
}
.select-field select {
  width: 100%;
  height: 46px;
  border: 1px solid #cfd6e2;
  border-radius: 8px;
  padding: 0 14px;
  color: #475467;
  background: #f9fafc;
  outline: none;
}
.number-input {
  height: 46px;
  display: flex;
  align-items: center;
  border: 1px solid #cfd6e2;
  border-radius: 8px;
  background: #f9fafc;
}
.number-input input {
  width: 100%;
  min-width: 0;
  height: 100%;
  border: 0;
  padding: 0 6px 0 14px;
  color: #475467;
  background: transparent;
  outline: none;
  font: inherit;
}
.number-input span {
  flex: 0 0 auto;
  padding-right: 14px;
  color: #667085;
}
.upload-box {
  height: 46px;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border: 1px dashed #c5ceda;
  border-radius: 8px;
  color: #475467;
  background: #f9fafc;
  font-weight: 800;
}
.upload-box span { font-size: 20px; }
.result-section { margin-top: 24px; }
.result-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.result-head strong { font-size: 15px; }
.result-head span { margin-left: 22px; color: #98a2b3; }
.result-tools {
  display: flex;
  align-items: center;
  gap: 8px;
}
.result-tools button, .action-row button, .prompt-tools button {
  height: 34px;
  border: 0;
  border-radius: 8px;
  padding: 0 12px;
  color: #4b5565;
  background: rgba(255,255,255,.7);
}
.result-tools .icon-btn {
  width: 34px;
  padding: 0;
}
.result-tools .active { background: #edf1f6; color: #111827; }
.result-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: clamp(12px, 1.4vw, 20px);
}
.result-grid article {
  position: relative;
  overflow: hidden;
  border-radius: 8px;
  aspect-ratio: 1.42 / 1;
  background: #111827;
  transition: transform .35s ease, opacity .25s ease;
}
.result-grid article:hover { transform: translateY(-2px); }
.cyber-scene {
  background:
    radial-gradient(circle at 20% 18%, rgba(0, 214, 255, .7), transparent 16%),
    radial-gradient(circle at 76% 22%, rgba(255, 47, 172, .55), transparent 18%),
    linear-gradient(180deg, #06121f 0%, #102949 52%, #120c24 100%);
}
.cyber-scene:before {
  content: "";
  position: absolute;
  inset: 18% 4% 0;
  background:
    linear-gradient(90deg, transparent 0 6%, rgba(33, 209, 255, .95) 6% 7%, transparent 7% 14%, rgba(255, 67, 172, .9) 14% 15%, transparent 15% 22%, rgba(33, 209, 255, .9) 22% 23%, transparent 23% 32%, rgba(255, 255, 255, .8) 32% 33%, transparent 33%),
    repeating-linear-gradient(90deg, transparent 0 18px, rgba(12, 22, 39, .92) 18px 46px),
    linear-gradient(180deg, transparent 0 20%, rgba(2, 6, 23, .95) 20% 100%);
  clip-path: polygon(0 45%, 8% 32%, 13% 52%, 19% 26%, 26% 48%, 35% 18%, 42% 43%, 50% 12%, 59% 40%, 67% 22%, 75% 46%, 82% 30%, 90% 54%, 100% 36%, 100% 100%, 0 100%);
  opacity: .9;
}
.cyber-scene:after {
  content: "";
  position: absolute;
  left: -8%;
  right: -8%;
  bottom: -18%;
  height: 46%;
  background:
    linear-gradient(90deg, transparent, rgba(40, 210, 255, .7), transparent),
    repeating-linear-gradient(0deg, rgba(255,255,255,.14) 0 1px, transparent 1px 16px),
    repeating-linear-gradient(90deg, rgba(255,48,170,.16) 0 1px, transparent 1px 28px);
  transform: perspective(220px) rotateX(58deg);
  transform-origin: bottom;
}
.cyber-scene span {
  position: absolute;
  left: 12%;
  bottom: 18%;
  width: 28%;
  height: 13%;
  border-radius: 999px 999px 6px 6px;
  background: linear-gradient(90deg, #0d1728, #263047);
  box-shadow: 0 0 18px rgba(33, 209, 255, .6), inset 18px 0 0 rgba(255, 47, 172, .38);
}
.cyber-scene span:before,
.cyber-scene span:after {
  content: "";
  position: absolute;
  bottom: -8px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #07111f;
  box-shadow: 0 0 10px rgba(33, 209, 255, .9);
}
.cyber-scene span:before { left: 20%; }
.cyber-scene span:after { right: 18%; }
.scene-b { filter: hue-rotate(22deg) saturate(1.2); }
.scene-b span { left: 58%; width: 10%; height: 34%; border-radius: 999px 999px 0 0; }
.scene-c { filter: hue-rotate(-24deg) contrast(1.08); }
.scene-c span { left: 62%; bottom: 26%; width: 18%; transform: skewX(-12deg); }
.scene-d { filter: hue-rotate(54deg) saturate(1.15); }
.scene-d span { left: 42%; width: 34%; }
.action-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}

.prompt-composer {
  margin: 34px 10px 0;
  padding: 18px 22px;
}
.prompt-composer textarea {
  width: 100%;
  min-height: 86px;
  border: 0;
  resize: vertical;
  outline: none;
  color: #344054;
  background: transparent;
  font-size: 16px;
  line-height: 1.8;
}
.composer-foot {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 20px;
}
.prompt-tools {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.prompt-tools button {
  border: 1px solid var(--line);
  background: #fff;
}
.send-box {
  display: flex;
  align-items: center;
  gap: 18px;
  color: #7b8494;
  font-size: 13px;
}
.send-btn {
  height: 44px;
  min-width: 96px;
  border: 0;
  border-radius: 8px;
  color: #fff;
  background: #111827;
  font-weight: 900;
}

.asset-panel {
  position: relative;
  min-width: 0;
  border-right: 0;
  border-left: 1px solid var(--line);
  padding: 24px 20px 22px;
}
.asset-head h2 { margin: 0; font-size: 18px; }
.asset-head p { margin: 8px 0 18px; color: var(--muted); }
.search-box {
  height: 42px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 14px;
  border-radius: 999px;
  background: #eef0f3;
  color: #9aa3b2;
}
.search-box input {
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  color: #344054;
}
.tabs {
  display: flex;
  gap: 18px;
  margin: 14px 0 18px;
}
.tabs button {
  height: 28px;
  min-width: 42px;
  border: 0;
  border-radius: 999px;
  color: #7b8494;
  background: transparent;
}
.tabs .active { color: #fff; background: #111827; }
.asset-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  max-height: none;
  overflow: auto;
  padding-right: 4px;
}
.asset-grid article {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  cursor: pointer;
  transition: border-color .2s ease, box-shadow .2s ease, transform .2s ease, opacity .2s ease;
}
.asset-grid article:hover {
  border-color: #c9d2df;
  box-shadow: 0 10px 26px rgba(20, 28, 45, .08);
  transform: translateY(-1px);
}
.asset-grid article.is-picking {
  opacity: .58;
  pointer-events: none;
}
.asset-grid article.is-selected {
  border-color: #111827;
  box-shadow: 0 0 0 3px rgba(17, 24, 39, .12), 0 14px 30px rgba(17, 24, 39, .16);
  transform: translateY(-1px);
}
.asset-grid article.is-selected:after {
  content: "已选";
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 2;
  height: 24px;
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 0 9px;
  color: #fff;
  background: #111827;
  font-size: 12px;
  font-weight: 800;
  box-shadow: 0 8px 18px rgba(17, 24, 39, .25);
}
.asset-grid img {
  width: 100%;
  height: 108px;
  object-fit: cover;
}
.asset-grid strong {
  display: block;
  padding: 8px 8px 2px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-size: 13px;
}
.asset-grid span {
  display: block;
  padding: 0 8px 8px;
  color: var(--muted);
  font-size: 12px;
}
.empty-assets {
  grid-column: 1 / -1;
  margin: 20px 0;
  padding: 24px;
  border: 1px dashed var(--line);
  border-radius: 10px;
  color: var(--muted);
  background: #fff;
  text-align: center;
}
.floating-settings {
  position: fixed;
  right: 14px;
  bottom: 14px;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 8px 24px rgba(20, 28, 45, .18);
}

@media (max-width: 1280px) {
  .studio-topbar { grid-template-columns: 250px minmax(0, 1fr) 240px; }
  .studio-shell { grid-template-columns: 220px minmax(0, 1fr) 320px; }
}

@media (max-width: 1060px) {
  html, body { overflow-x: hidden; }
  .studio-topbar { grid-template-columns: auto 1fr auto; }
  .top-nav { gap: 18px; }
  .studio-shell {
    height: auto;
    min-height: calc(100dvh - 70px);
    grid-template-columns: 1fr;
    overflow: visible;
  }
  .left-rail, .asset-panel {
    height: auto;
    overflow: visible;
    position: static;
    border: 0;
  }
  .left-rail {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    padding: 18px;
  }
  .new-project, .settings-card, .side-links, .quota-card, .user-card { grid-column: 1 / -1; }
  .workspace {
    height: auto;
    padding: 34px 18px;
    overflow: visible;
  }
  .asset-grid { max-height: none; }
}

@media (max-width: 720px) {
  .studio-topbar {
    height: auto;
    grid-template-columns: 1fr auto;
    gap: 12px;
    padding: 14px;
  }
  .top-nav {
    grid-column: 1 / -1;
    justify-content: flex-start;
    overflow-x: auto;
    order: 3;
  }
  .top-actions { display: none; }
  .left-rail { grid-template-columns: 1fr; }
  .settings-card { padding: 14px; }
  .composer-foot, .result-head { display: grid; gap: 14px; }
  .result-grid, .asset-grid { grid-template-columns: 1fr; }
  .send-box { display: grid; justify-items: start; }
}
