:root {
  --studio-bg: #f5f5f3;
  --studio-panel: #ffffff;
  --studio-soft: #f8f8f7;
  --studio-border: #e8e6e0;
  --studio-border-strong: #d9d6ce;
  --studio-text: #161512;
  --studio-muted: #74716a;
  --studio-faint: #aaa59d;
  --studio-black: #090908;
  --studio-green: #17734a;
  --studio-blue: #1776c8;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  overflow: hidden;
}

body {
  margin: 0;
  color: var(--studio-text);
  background: var(--studio-bg);
  font-family: "SF Pro Display", "SF Pro Text", "PingFang SC", "Microsoft YaHei", "Helvetica Neue", sans-serif;
}

body.modal-open {
  overflow: hidden;
}

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

button,
a,
label {
  -webkit-tap-highlight-color: transparent;
}

button {
  border: 0;
  cursor: pointer;
  transition: transform 0.16s ease, box-shadow 0.16s ease, border-color 0.16s ease, background 0.16s ease, opacity 0.16s ease;
}

button:hover {
  transform: translateY(-1px);
}

button:active {
  transform: translateY(0);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.56;
  transform: none;
}

body.resizing-history,
body.resizing-history * {
  cursor: col-resize !important;
  user-select: none;
}

body.resizing-composer,
body.resizing-composer * {
  cursor: ns-resize !important;
  user-select: none;
}

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

svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.9;
}

.studio-shell {
  display: grid;
  grid-template-columns: 92px var(--history-width, 320px) minmax(0, 1fr);
  gap: 16px;
  height: 100vh;
  min-width: 1120px;
  padding: 16px;
  background: var(--studio-bg);
  max-width: 1680px;
  margin: 0 auto;
}

.studio-rail,
.history-panel,
.workspace {
  border: 1px solid var(--studio-border);
  border-radius: 28px;
  background: rgba(255, 255, 255, 0.86);
  box-shadow: none;
}

.studio-rail {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 0;
  gap: 12px;
  padding: 12px 10px;
  background: #f0f0ed;
}

.rail-top {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.rail-logo,
.rail-collapse {
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  border: 1px solid var(--studio-border);
  border-radius: 16px;
  color: #625e56;
  background: #fff;
}

.rail-logo img {
  width: 28px;
  height: 28px;
  object-fit: contain;
  border-radius: 10px;
}

.rail-logo svg {
  width: 18px;
  height: 18px;
}

.rail-brand {
  display: none;
  min-width: 0;
  flex: 1;
  padding: 8px 8px;
  border-radius: 16px;
  color: inherit;
  text-decoration: none;
}

.rail-brand:hover {
  background: rgba(255, 255, 255, 0.68);
}

.rail-brand strong,
.rail-brand span,
.rail-copy strong,
.rail-copy small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rail-brand strong {
  color: #171512;
  font-size: 15px;
  font-weight: 780;
  letter-spacing: 0;
}

.rail-brand span {
  margin-top: 2px;
  color: #74716a;
  font-size: 12px;
}

.rail-nav {
  display: grid;
  gap: 4px;
  margin-top: 4px;
}

.rail-action {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  min-width: 0;
  width: 56px;
  min-height: 56px;
  padding: 10px;
  border: 1px solid transparent;
  border-radius: 18px;
  color: #4c4a45;
  background: transparent;
  box-shadow: none;
  text-decoration: none;
  text-align: left;
}

.rail-action:hover {
  border-color: transparent;
  background: rgba(255, 255, 255, 0.65);
}

.rail-action.rail-active,
.rail-action.active {
  color: #151411;
  background: #fff;
  box-shadow: 0 8px 22px rgba(15, 23, 42, 0.045);
}

.rail-icon {
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  border-radius: 15px;
  color: #6c675e;
  background: rgba(255, 255, 255, 0.78);
}

.rail-action.rail-active .rail-icon,
.rail-action.active .rail-icon {
  color: #fff;
  background: var(--studio-black);
}

.rail-copy {
  display: none;
  min-width: 0;
}

.rail-copy strong {
  color: inherit;
  font-size: 14px;
  font-weight: 760;
}

.rail-copy small {
  margin-top: 2px;
  color: #858078;
  font-size: 12px;
}

.rail-action.rail-active .rail-copy small,
.rail-action.active .rail-copy small {
  color: #6f6b63;
}

.rail-bottom {
  display: grid;
  gap: 8px;
  margin-top: auto;
}

.rail-wallet,
.rail-account {
  display: grid;
  width: 100%;
  min-width: 0;
  border: 1px solid var(--studio-border);
  background: #fff;
  box-shadow: none;
  text-align: left;
}

.rail-wallet {
  display: none;
}

.rail-wallet span {
  color: #74716a;
  font-size: 12px;
  font-weight: 720;
}

.rail-wallet strong {
  min-width: 0;
  overflow: hidden;
  color: var(--studio-green);
  font-size: 17px;
  font-weight: 780;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rail-account {
  display: grid;
  place-items: center;
  gap: 0;
  width: 66px;
  min-height: 48px;
  padding: 0;
  border-radius: 18px;
  color: #36332d;
}

.rail-account svg {
  flex: 0 0 auto;
}

.rail-account span {
  display: none;
}

.rail-collapsed .studio-shell {
  grid-template-columns: 92px var(--history-width, 320px) minmax(0, 1fr);
}

.rail-collapsed .studio-rail {
  align-items: center;
  padding: 12px 10px;
}

.rail-collapsed .rail-top {
  flex-direction: column;
}

.rail-collapsed .rail-brand,
.rail-collapsed .rail-copy,
.rail-collapsed .rail-wallet span,
.rail-collapsed .rail-wallet strong,
.rail-collapsed .rail-account span {
  display: none;
}

.rail-collapsed .rail-collapse svg {
  transform: rotate(180deg);
}

.rail-collapsed .rail-action {
  justify-content: center;
  width: 56px;
  min-height: 56px;
  padding: 10px;
}

.rail-collapsed .rail-wallet,
.rail-collapsed .rail-account {
  display: grid;
  place-items: center;
  width: 56px;
  min-height: 48px;
  padding: 0;
}

.rail-collapsed .rail-wallet::before {
  color: var(--studio-green);
  font-size: 12px;
  font-weight: 780;
  content: "充值";
}

.history-panel {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  position: relative;
  overflow: hidden;
}

.history-resize {
  position: absolute;
  top: 44%;
  right: -10px;
  z-index: 16;
  width: 18px;
  height: 98px;
  border: 1px solid var(--studio-border);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 8px 22px rgba(15, 23, 42, 0.08);
  cursor: col-resize;
  touch-action: none;
}

.history-resize::before {
  display: block;
  width: 3px;
  height: 42px;
  margin: 27px auto;
  border-radius: 999px;
  background: #c8c5bd;
  content: "";
}

.history-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 20px 16px 14px;
}

.history-panel-head h2 {
  margin: 0;
  color: #171512;
  font-size: 20px;
  font-weight: 760;
  letter-spacing: 0;
}

.history-panel-head span {
  display: inline-grid;
  place-items: center;
  min-width: 32px;
  height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  color: #77736d;
  background: #fff;
  font-size: 12px;
  box-shadow: 0 6px 18px rgba(15, 23, 42, 0.04);
}

.history-actions {
  display: grid;
  grid-template-columns: 1fr 46px;
  gap: 8px;
  padding: 0 16px 16px;
  border-bottom: 1px solid var(--studio-border);
}

.new-chat-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  border-radius: 16px;
  color: #fff;
  background: var(--studio-black);
  font-size: 14px;
  font-weight: 760;
}

.history-trash {
  display: grid;
  place-items: center;
  min-height: 44px;
  border: 1px solid var(--studio-border);
  border-radius: 16px;
  color: #858078;
  background: rgba(255, 255, 255, 0.75);
}

.history-trash.confirming {
  color: #9b2f24;
  background: #fff0ed;
  border-color: #efc9c1;
}

.history {
  overflow: auto;
  padding: 24px 12px 16px;
}

.history .hint,
.history-loading,
.history-empty-copy {
  position: relative;
  margin: 0;
  color: #7f7b73;
  font-size: 15px;
  line-height: 1.6;
}

.history .hint,
.history-loading {
  padding-left: 30px;
}

.history-loading::before {
  position: absolute;
  left: 3px;
  top: 2px;
  width: 15px;
  height: 15px;
  border: 2px solid #b9b4ac;
  border-top-color: transparent;
  border-radius: 999px;
  content: "";
  animation: spin 1s linear infinite;
}

.history-empty-copy {
  padding: 4px 6px;
}

.history-item {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  gap: 10px;
  margin-bottom: 10px;
  padding: 10px;
  border: 1px solid #ece9e2;
  border-radius: 16px;
  background: #fff;
  box-shadow: none;
  cursor: pointer;
  transition: border-color 0.16s ease, transform 0.16s ease, background 0.16s ease;
}

.history-item:hover,
.history-item:focus-visible {
  border-color: #d4d0c7;
  background: #fbfbf9;
  outline: none;
  transform: translateY(-1px);
}

.history-item img {
  width: 72px;
  height: 72px;
  border-radius: 12px;
  object-fit: cover;
  background: #f2f1ed;
}

.history-body {
  min-width: 0;
  padding: 0;
}

.history-body p,
.history-item p {
  display: -webkit-box;
  margin: 5px 0 0;
  overflow: hidden;
  color: #77736d;
  font-size: 12px;
  line-height: 1.45;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.history-meta {
  display: flex;
  gap: 8px;
  color: #4c4942;
  font-size: 12px;
  font-weight: 760;
}

.history-item a {
  display: inline-flex;
  margin-top: 5px;
  color: #111;
  font-size: 12px;
  font-weight: 760;
  text-decoration: none;
}

.history-row-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
}

.history-row-actions a,
.history-row-actions button {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  margin: 0;
  padding: 0;
  border: 0;
  color: #111;
  background: transparent;
  font: inherit;
  font-size: 12px;
  font-weight: 760;
  text-decoration: none;
  cursor: pointer;
}

.history-row-actions button[data-confirm="1"] {
  color: #b42318;
}

.empty-history {
  display: block;
  color: #7f7b73;
  font-size: 14px;
  line-height: 1.65;
}

.empty-history article {
  display: none;
}

.empty-history::before {
  content: "还没有历史记录。创建第一条图片任务后，会在这里保留缩略图和提示词摘要。";
}

.workspace {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  position: relative;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.94);
}

.workspace-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 62px;
  padding: 12px 24px;
  border-bottom: 1px solid var(--studio-border);
}

.workspace-title,
.workspace-account {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.workspace-title h1 {
  margin: 0;
  color: #151411;
  font-size: 22px;
  font-weight: 780;
  letter-spacing: 0;
}

.workspace-badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 4px 9px;
  border-radius: 999px;
  color: var(--studio-blue);
  background: #eef7ff;
  font-size: 12px;
  font-weight: 760;
}

.workspace-badge.wallet {
  color: var(--studio-green);
  background: #e7f7ee;
}

.ready-pill,
.collapse-history-button,
.recharge-header-button,
.balance-nav,
.nav-link,
.account-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 38px;
  padding: 8px 14px;
  border: 1px solid var(--studio-border);
  border-radius: 999px;
  color: #59554d;
  background: rgba(255, 255, 255, 0.78);
  font-size: 14px;
  font-weight: 720;
  box-shadow: none;
  white-space: nowrap;
}

.balance-nav {
  color: #16734a;
  background: #e8f7ee;
  border-color: #cfecd8;
  font-weight: 780;
}

.account-pill {
  color: #3f3b35;
  background: #f6f5f1;
  border-color: #e4e1d9;
  font-weight: 760;
}

.recharge-header-button {
  color: #16734a;
  background: #e8f7ee;
  border-color: #cfecd8;
  font-weight: 780;
}

.workspace-header .recharge-header-button {
  display: none;
}

.ready-pill.offline {
  color: #9b2f24;
  background: #fff0ed;
  border-color: #efc9c1;
}

.account-pill span {
  max-width: 110px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.workspace-content {
  display: block;
  overflow: auto;
  padding: 18px 24px calc(var(--composer-textarea-height, 128px) + 190px);
  background: #fcfcfb;
}

.intro-panel {
  min-width: 0;
}

body[data-panel="prompts"] .intro-panel,
body[data-panel="agent"] .intro-panel,
body[data-panel="settings"] .intro-panel,
body[data-panel="prompts"] .admin-drawer,
body[data-panel="agent"] .admin-drawer,
body[data-panel="settings"] .admin-drawer {
  display: none;
}

body[data-panel="prompts"] .composer-card,
body[data-panel="agent"] .composer-card,
body[data-panel="settings"] .composer-card,
body[data-panel="prompts"] .result-thread,
body[data-panel="agent"] .result-thread,
body[data-panel="settings"] .result-thread {
  display: none !important;
}

body[data-panel="prompts"] .workspace-content,
body[data-panel="agent"] .workspace-content,
body[data-panel="settings"] .workspace-content {
  padding-bottom: 32px;
}

.feature-panel {
  display: none;
  min-height: 0;
  max-width: none;
  border: 1px solid var(--studio-border);
  border-radius: 30px;
  background: #fff;
  overflow: hidden;
}

body[data-panel="prompts"] #promptLibraryPanel,
body[data-panel="agent"] #agentPanel,
body[data-panel="settings"] #settingsPanel {
  display: flex;
  flex-direction: column;
}

body[data-panel="studio"] .workspace-content {
  display: block;
}

.feature-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  padding: 20px;
  border-bottom: 1px solid var(--studio-border);
}

.feature-head h2 {
  margin: 8px 0 4px;
  color: #14120f;
  font-size: 24px;
  font-weight: 780;
}

.feature-head p {
  margin: 0;
  color: var(--studio-muted);
  font-size: 14px;
  line-height: 1.7;
}

.feature-kicker {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  width: max-content;
  padding: 5px 10px;
  border-radius: 999px;
  color: #615d55;
  background: #f2f1ed;
  font-size: 12px;
  font-weight: 760;
}

.feature-search {
  position: relative;
  flex: 1 1 280px;
  max-width: 360px;
}

.feature-search svg {
  position: absolute;
  left: 14px;
  top: 50%;
  width: 16px;
  height: 16px;
  color: #9b968d;
  transform: translateY(-50%);
}

.feature-search input {
  padding-left: 40px;
}

.library-tags {
  display: flex;
  flex-direction: column;
  gap: 7px;
  padding: 14px 20px 0;
}

.library-filter-row {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 1px;
}

.library-tags button,
.library-card-tags em {
  flex: 0 0 auto;
  min-height: 34px;
  padding: 7px 13px;
  border-radius: 999px;
  color: #625f58;
  background: #f2f1ed;
  font-size: 13px;
  font-weight: 720;
}

.library-tag-row button,
.library-card-tags em {
  min-height: 28px;
  padding: 5px 10px;
  font-size: 12px;
}

.library-tags button:hover,
.library-tags button.active {
  color: #111;
  background: #e8e5df;
}

.library-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  padding: 16px 20px 20px;
}

.library-card {
  display: flex;
  flex-direction: column;
  min-height: 330px;
  overflow: hidden;
  border: 1px solid #e3e0d8;
  border-radius: 18px;
  background: #fff;
}

.library-card.featured {
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.035);
}

.library-cover {
  position: relative;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  background: #f0eee8;
}

.library-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease;
}

.library-card:hover .library-cover img {
  transform: scale(1.03);
}

.library-cover span {
  position: absolute;
  left: 12px;
  top: 12px;
  background: rgba(255, 255, 255, 0.9);
  color: #3d3932;
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.08);
}

.library-card > div:not(.prompt-cover):not(.library-cover):not(.library-card-actions) {
  padding: 14px 16px;
}

.library-card span {
  display: inline-flex;
  padding: 4px 9px;
  border-radius: 999px;
  color: #77736d;
  background: #f2f1ed;
  font-size: 12px;
  font-weight: 700;
}

.library-card h3 {
  margin: 10px 0 8px;
  font-size: 16px;
}

.library-card p {
  display: -webkit-box;
  margin: 0;
  min-height: 42px;
  overflow: hidden;
  color: #77736d;
  font-size: 13px;
  line-height: 1.6;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.library-card small {
  display: block;
  margin-top: 8px;
  color: #9a948b;
  font-size: 11px;
  line-height: 1.5;
}

.library-card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.library-card-tags em {
  color: #77736d;
  font-style: normal;
}

.library-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: auto 16px 16px;
}

.library-card-actions button {
  flex: 1 1 auto;
  min-height: 36px;
  padding: 0 12px;
  border-radius: 999px;
  color: #fff;
  background: var(--studio-black);
  font-weight: 760;
}

.library-card-actions button + button {
  border: 1px solid #dedbd3;
  color: #2e2b26;
  background: #fff;
}

.feature-empty {
  grid-column: 1 / -1;
  margin: 0;
  padding: 24px;
  color: var(--studio-muted);
}

.agent-panel {
  flex-direction: row;
  min-height: 640px;
}

.agent-sidebar {
  display: flex;
  flex: 0 0 300px;
  flex-direction: column;
  min-height: 0;
  border-right: 1px solid var(--studio-border);
  background: #f6f6f4;
}

.agent-sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px;
}

.agent-sidebar-head strong {
  display: block;
  color: #181612;
  font-size: 14px;
}

.agent-sidebar-head span {
  display: block;
  margin-top: 2px;
  color: var(--studio-muted);
  font-size: 12px;
}

.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: 1px solid #e1ddd4;
  border-radius: 999px;
  color: #26231e;
  background: #fff;
  cursor: pointer;
}

.icon-button svg {
  width: 18px;
  height: 18px;
}

.agent-conversation-list {
  min-height: 0;
  flex: 1;
  overflow: auto;
  padding: 0 8px 12px;
}

.agent-conversation {
  display: flex;
  width: 100%;
  min-width: 0;
  flex-direction: column;
  gap: 7px;
  margin-bottom: 8px;
  padding: 12px;
  border: 1px solid #e2ded6;
  border-radius: 22px;
  color: #3a362f;
  background: #fff;
  text-align: left;
  cursor: pointer;
}

.agent-conversation.active {
  border-color: #181612;
  color: #fff;
  background: #181612;
}

.agent-conversation-top,
.agent-conversation-meta {
  display: flex;
  min-width: 0;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.agent-conversation-top strong {
  min-width: 0;
  overflow: hidden;
  font-size: 14px;
  font-weight: 760;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.agent-conversation-top small,
.agent-conversation-preview,
.agent-conversation-meta {
  color: #8a857c;
  font-size: 11px;
}

.agent-conversation.active .agent-conversation-top small,
.agent-conversation.active .agent-conversation-preview,
.agent-conversation.active .agent-conversation-meta {
  color: rgba(255, 255, 255, 0.68);
}

.agent-conversation-preview {
  display: -webkit-box;
  min-height: 32px;
  overflow: hidden;
  line-height: 1.45;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.agent-conversation-meta em {
  min-width: 0;
  overflow: hidden;
  font-style: normal;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.agent-conversation-meta span {
  display: flex;
  flex: 0 0 auto;
  gap: 6px;
}

.agent-conversation-meta i {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 7px;
  border-radius: 999px;
  background: #f1efea;
  color: #524d45;
  font-style: normal;
  cursor: pointer;
}

.agent-conversation.active .agent-conversation-meta i {
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
}

.agent-main {
  display: flex;
  flex: 1;
  min-width: 0;
  min-height: 0;
  flex-direction: column;
}

.agent-head {
  align-items: stretch;
}

.agent-controls {
  display: flex;
  min-width: min(360px, 100%);
  flex-direction: column;
  gap: 10px;
}

.agent-selects {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 128px;
  gap: 8px;
}

.agent-selects select {
  min-height: 40px;
  min-width: 0;
  padding: 0 12px;
  border: 1px solid #e0dcd3;
  border-radius: 999px;
  background: #fff;
  font-size: 13px;
  font-weight: 720;
  outline: none;
}

.agent-head-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.agent-messages {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 12px;
  min-height: 320px;
  max-height: min(58vh, 620px);
  overflow: auto;
  padding: 18px 20px;
  background: #fcfcfb;
}

.agent-empty {
  max-width: 720px;
  margin: auto;
  padding: 28px;
  border: 1px solid #e5e1d8;
  border-radius: 28px;
  background: #fff;
}

.agent-empty strong {
  display: block;
  color: #171511;
  font-size: 20px;
}

.agent-empty p {
  margin: 8px 0 0;
  color: var(--studio-muted);
  line-height: 1.7;
}

.agent-message {
  max-width: min(760px, 88%);
  padding: 14px 16px;
  border: 1px solid #e6e3dc;
  border-radius: 22px;
  background: #fff;
}

.agent-message.user {
  align-self: flex-end;
  color: #fff;
  background: var(--studio-black);
}

.agent-message span {
  display: block;
  margin-bottom: 6px;
  font-size: 12px;
  font-weight: 780;
  opacity: 0.72;
}

.agent-message p {
  margin: 0;
  white-space: pre-wrap;
  line-height: 1.8;
}

.agent-message-images {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 120px));
  gap: 8px;
  margin-top: 10px;
}

.agent-message-images img {
  width: 100%;
  aspect-ratio: 1;
  border-radius: 14px;
  object-fit: cover;
}

.agent-attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 20px;
}

.agent-attachment {
  position: relative;
  overflow: hidden;
  border: 1px solid #e2ded6;
  border-radius: 16px;
  background: #f2f1ed;
}

.agent-attachment img {
  width: 78px;
  height: 78px;
  object-fit: cover;
}

.agent-attachment button {
  position: absolute;
  right: 5px;
  top: 5px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 999px;
  color: #fff;
  background: rgba(0, 0, 0, 0.68);
  cursor: pointer;
}

.agent-composer {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 12px;
  padding: 16px 20px 20px;
  border-top: 1px solid var(--studio-border);
}

.agent-attach-button {
  align-self: end;
}

.agent-attach-button input {
  display: none;
}

.agent-composer textarea {
  min-height: 82px;
  max-height: 160px;
  border: 1px solid var(--studio-border);
  border-radius: 20px;
  background: #fafaf8;
}

.agent-composer button {
  align-self: end;
  min-width: 92px;
}

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

.settings-grid article {
  min-height: 150px;
  padding: 18px;
  border: 1px solid #e3e0d8;
  border-radius: 22px;
  background: #fcfcfb;
}

.settings-grid span {
  color: var(--studio-muted);
  font-size: 13px;
  font-weight: 760;
}

.settings-grid strong {
  display: block;
  margin-top: 12px;
  font-size: 24px;
}

.settings-grid p {
  margin: 10px 0 0;
  color: var(--studio-muted);
  line-height: 1.6;
}

.settings-actions {
  display: flex;
  gap: 10px;
  padding: 0 20px 20px;
}

.spark-icon {
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  margin-bottom: 22px;
  overflow: hidden;
  border: 1px solid var(--studio-border);
  border-radius: 18px;
  background: #fff;
}

.spark-icon img {
  width: 42px;
  height: 42px;
  object-fit: contain;
}

.intro-panel h2 {
  max-width: 760px;
  margin: 0 0 24px;
  color: #080807;
  font-size: clamp(38px, 3.1vw, 48px);
  font-weight: 820;
  line-height: 1.06;
  letter-spacing: 0;
}

.prompt-tools {
  display: flex;
  justify-content: center;
  gap: 14px;
  width: 100%;
  max-width: 1120px;
  overflow-x: auto;
  padding: 0 2px 10px;
  scroll-snap-type: x proximity;
  scrollbar-width: none;
}

.prompt-tools::-webkit-scrollbar {
  display: none;
}

.prompt-card {
  display: flex;
  flex: 0 0 220px;
  flex-direction: column;
  width: 220px;
  height: 235px;
  min-height: 0;
  overflow: hidden;
  padding: 0;
  border: 1px solid #dedbd4;
  border-radius: 22px;
  background: #fff;
  text-align: left;
  box-shadow: none;
  scroll-snap-align: start;
}

.prompt-card:hover {
  transform: translateY(-2px);
  border-color: #cbc7bd;
  box-shadow: 0 18px 36px rgba(15, 23, 42, 0.08);
}

.prompt-cover {
  flex: 0 0 78px;
  height: 78px;
  border-bottom: 1px solid #e5e1d8;
}

.prompt-purple .prompt-cover {
  background: linear-gradient(145deg, #231127 0%, #482740 48%, #c0a994 100%);
}

.prompt-blue .prompt-cover {
  background: linear-gradient(145deg, #1c4e83 0%, #3e78ac 54%, #d8d2c1 100%);
}

.prompt-rose .prompt-cover {
  background: linear-gradient(145deg, #5b091b 0%, #c80d46 48%, #f28b00 100%);
}

.prompt-cyan .prompt-cover {
  background: linear-gradient(145deg, #073142 0%, #0c5369 48%, #ff6b0a 100%);
}

.prompt-card span {
  width: max-content;
  margin: 14px 16px 8px;
  padding: 4px 9px;
  border-radius: 999px;
  color: #77736d;
  background: #f2f1ed;
  font-size: 12px;
  font-weight: 650;
}

.prompt-card span::first-letter {
  text-transform: uppercase;
}

.prompt-card strong {
  display: block;
  margin: 0 16px 9px;
  color: #14120f;
  font-size: 15px;
  font-weight: 780;
}

.prompt-card p {
  display: -webkit-box;
  min-height: 40px;
  margin: 0 16px 10px;
  overflow: hidden;
  color: #625f58;
  font-size: 13px;
  line-height: 1.55;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.prompt-card small {
  display: -webkit-box;
  margin: auto 16px 16px;
  padding-top: 10px;
  overflow: hidden;
  border-top: 1px solid #efede8;
  color: #77736d;
  font-size: 12px;
  line-height: 1.55;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.result-thread,
.admin-drawer,
.composer-card {
  border: 1px solid var(--studio-border);
  border-radius: 24px;
  background: #fff;
  box-shadow: none;
}

.result-thread {
  display: none;
  max-width: 1120px;
  margin-top: 18px;
  margin-bottom: 18px;
  padding: 18px;
}

.result-thread.is-visible,
.result-thread:has(.preview.loading),
.result-thread:has(.preview.has-result) {
  display: block;
}

.thread-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.thread-head h2 {
  margin: 0;
  font-size: 18px;
}

#previewMeta {
  display: inline-flex;
  min-height: 30px;
  padding: 6px 10px;
  border-radius: 999px;
  color: #16734a;
  background: #e8f7ee;
  font-size: 12px;
  font-weight: 760;
}

.preview {
  position: relative;
  display: grid;
  place-items: center;
  min-height: clamp(360px, 46vh, 600px);
  height: auto;
  overflow: hidden;
  border: 1px solid #e4e1d9;
  border-radius: 18px;
  background: #f8f8f5;
}

.preview-empty {
  display: grid;
  place-items: center;
  gap: 14px;
  width: 100%;
  height: 100%;
  padding: 28px;
  text-align: center;
}

.preview-empty img {
  width: min(420px, 82%);
  border-radius: 16px;
  box-shadow: 0 16px 42px rgba(31, 36, 32, 0.12);
}

.preview-empty h3 {
  margin: 0;
  font-size: 18px;
}

.preview-empty p {
  margin: 0;
  color: var(--studio-muted);
}

.generating-stage {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: minmax(220px, 360px) minmax(220px, 1fr);
  align-items: center;
  gap: 28px;
  width: 100%;
  height: 100%;
  padding: 32px;
}

.breathing-frame {
  position: relative;
  width: min(360px, 100%);
  aspect-ratio: 1;
  overflow: hidden;
  border: 1px solid rgba(15, 15, 14, 0.12);
  border-radius: 20px;
  background: linear-gradient(135deg, #f7f7f4, #ededec 48%, #fbf7f0);
  box-shadow: 0 18px 48px rgba(15, 23, 42, 0.1);
  animation: breathe 2.1s ease-in-out infinite;
}

.breathing-image {
  position: absolute;
  inset: 13%;
  border-radius: 18px;
  background:
    linear-gradient(90deg, rgba(255,255,255,.88), rgba(255,255,255,.42), rgba(255,255,255,.88)),
    linear-gradient(135deg, rgba(44,82,130,.24), rgba(240,139,53,.24));
  animation: imagePulse 2.1s ease-in-out infinite;
}

.breathing-line {
  position: absolute;
  left: 20%;
  height: 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.74);
  animation: linePulse 1.9s ease-in-out infinite;
}

.line-one { top: 30%; width: 48%; }
.line-two { top: 38%; width: 62%; animation-delay: .18s; }
.line-three { top: 46%; width: 38%; animation-delay: .34s; }

.generating-copy {
  display: grid;
  gap: 10px;
  justify-items: start;
  color: #23211d;
}

.generating-copy strong {
  font-size: 24px;
  line-height: 1.2;
}

.generating-copy p {
  margin: 0;
  color: var(--studio-muted);
  font-size: 14px;
  line-height: 1.7;
}

.single-result,
.multi-result {
  display: grid;
  width: 100%;
  min-height: clamp(300px, 38vh, 520px);
  height: 100%;
  gap: 12px;
  padding: 10px;
}

.single-result {
  place-items: center;
}

.single-result .result-card {
  width: 100%;
  height: 100%;
}

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

.result-card {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto auto;
  min-width: 0;
  min-height: 0;
  gap: 10px;
}

.result-image-frame {
  display: grid;
  place-items: center;
  min-width: 0;
  min-height: 0;
}

.single-result img,
.multi-result img {
  width: 100%;
  height: 100%;
  max-height: min(76vh, 820px);
  border-radius: 16px;
  object-fit: contain;
  background: #f8f8f5;
}

.single-result img {
  height: 100%;
}

.multi-result img {
  min-height: 0;
}

.result-meta {
  justify-self: center;
  max-width: 100%;
  min-height: 26px;
  padding: 5px 9px;
  overflow: hidden;
  border-radius: 999px;
  color: #68635b;
  background: #f2f1ed;
  font-size: 12px;
  font-weight: 760;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.result-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  min-height: 34px;
}

.result-actions a,
.result-actions button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 32px;
  padding: 0 12px;
  border: 1px solid #dedbd3;
  border-radius: 999px;
  color: #23211d;
  background: #fff;
  font: inherit;
  font-size: 12px;
  font-weight: 760;
  text-decoration: none;
  cursor: pointer;
}

.result-actions .export-4k-button {
  border-color: #15130f;
  color: #fff;
  background: #15130f;
}

.result-actions a:hover,
.result-actions button:hover {
  border-color: #cfc9bd;
  background: #f8f7f3;
}

.result-actions .export-4k-button:hover {
  border-color: #15130f;
  color: #fff;
  background: #2b2923;
}

.result-actions button:disabled {
  opacity: .45;
  cursor: not-allowed;
}

.preview-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 12px;
  color: var(--studio-muted);
  font-size: 14px;
}

.download-link {
  display: none;
  align-items: center;
  min-height: 38px;
  padding: 8px 14px;
  border-radius: 999px;
  color: #fff;
  background: var(--studio-black);
  text-decoration: none;
  font-weight: 760;
}

.admin-drawer {
  display: none;
  max-width: 760px;
  margin-top: 18px;
  padding: 18px;
}

.admin-form {
  display: grid;
  grid-template-columns: 1fr 180px auto;
  gap: 10px;
}

.admin-form button {
  min-width: 100px;
  border-radius: 999px;
  color: #fff;
  background: var(--studio-black);
  font-weight: 760;
}

.composer-card {
  position: absolute;
  left: 24px;
  right: 24px;
  bottom: 10px;
  z-index: 12;
  padding: 8px 16px 10px;
  border-radius: 28px;
  box-shadow: 0 14px 36px rgba(15, 23, 42, 0.055);
}

.generation-banner {
  display: none;
  align-items: center;
  gap: 10px;
  min-height: 40px;
  margin: 2px 0 10px;
  padding: 8px 12px;
  border: 1px solid #cfead9;
  border-radius: 18px;
  color: #14643f;
  background: #eaf8ef;
  font-size: 13px;
}

body.generating-active .generation-banner {
  display: flex;
}

.generation-banner span {
  flex: 0 0 auto;
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: #18a45b;
  box-shadow: 0 0 0 0 rgba(24, 164, 91, 0.35);
  animation: pulseDot 1.35s ease-out infinite;
}

.generation-banner strong {
  font-size: 13px;
}

.generation-banner em {
  margin-left: auto;
  color: #3f7f5f;
  font-style: normal;
}

.composer-resize {
  position: absolute;
  left: 50%;
  top: 0;
  width: 112px;
  height: 20px;
  border: 1px solid var(--studio-border);
  border-radius: 999px;
  background: #fff;
  transform: translate(-50%, -50%);
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.06);
}

.composer-resize:hover,
.composer-resize:active {
  transform: translate(-50%, -50%);
}

.composer-resize::before {
  display: block;
  width: 42px;
  height: 4px;
  margin: 7px auto;
  border-radius: 999px;
  background: #c8c5bd;
  content: "";
}

.composer-toolbar {
  position: relative;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  grid-template-areas: "mode selects";
  align-items: center;
  gap: 10px 14px;
  height: auto;
  margin-bottom: 8px;
  padding-top: 10px;
}

.toolbar-top-row,
.toolbar-bottom-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.toolbar-top-row {
  grid-area: selects;
  justify-content: flex-end;
  flex-wrap: wrap;
  width: 100%;
}

.toolbar-bottom-row {
  grid-area: mode;
  justify-content: flex-start;
}

.toolbar-billing-group {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  justify-content: flex-start;
  flex: 0 0 auto;
}

.mode-tabs,
.layout-tabs {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  border-radius: 999px;
  background: #f2f1ed;
}

.composer-card .mode-tabs button:hover,
.composer-card .mode-tabs button:active,
.composer-card .layout-tabs button:hover,
.composer-card .layout-tabs button:active,
.composer-card .select-pill button:hover,
.composer-card .select-pill button:active,
.composer-card .help-pill:hover,
.composer-card .help-pill:active,
.composer-card .billing-chip:hover,
.composer-card .billing-chip:active {
  transform: none;
}

.mode-tabs button,
.layout-tabs button {
  min-height: 32px;
  padding: 6px 15px;
  border-radius: 999px;
  color: #4f4b44;
  background: transparent;
  font-size: 14px;
  font-weight: 760;
  box-shadow: none;
}

.mode-tabs button.active,
.layout-tabs button.active {
  color: #fff;
  background: var(--studio-black);
}

.select-pill,
.help-pill,
.price-chip,
.billing-chip {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  padding: 8px 15px;
  border: 1px solid var(--studio-border);
  border-radius: 999px;
  color: #4d493f;
  background: rgba(255, 255, 255, 0.9);
  font-size: 14px;
  font-weight: 760;
  white-space: nowrap;
  box-shadow: none;
}

.select-pill {
  min-width: 108px;
}

.select-pill[data-select="size"],
.size-select {
  min-width: 246px;
}

.select-pill[data-select="quality"] {
  min-width: 136px;
}

.select-pill[data-select="format"] {
  min-width: 132px;
}

.count-select {
  min-width: 110px;
}

.help-pill {
  min-width: 40px;
  width: 40px;
  padding-inline: 0;
}

.select-pill svg,
.help-pill svg {
  width: 16px;
  height: 16px;
  color: #8d887e;
}

.pill-menu {
  position: absolute;
  left: 0;
  bottom: calc(100% + 4px);
  z-index: 50;
  display: none;
  min-width: 100%;
  max-height: min(360px, calc(100vh - 180px));
  padding: 6px;
  border: 1px solid var(--studio-border);
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 18px 48px rgba(15, 23, 42, 0.12);
  overflow-y: auto;
}

.pill-menu::after {
  position: absolute;
  left: 0;
  right: 0;
  bottom: -8px;
  height: 8px;
  content: "";
}

.select-pill.open .pill-menu {
  display: grid;
  gap: 4px;
}

.pill-menu button {
  min-height: 32px;
  padding: 6px 12px;
  border-radius: 12px;
  color: #57524b;
  background: transparent;
  font-size: 13px;
  text-align: left;
  white-space: nowrap;
}

.pill-menu button.active,
.pill-menu button:hover {
  color: #111;
  background: #f2f1ed;
}

.composer-row-break {
  display: none;
}

.price-chip {
  display: inline-flex;
  color: #16734a;
  background: #e8f7ee;
  border-color: transparent;
  font-size: 13px;
  font-weight: 760;
}

.billing-chip {
  color: #6c675e;
  background: #f2f1ed;
  border-color: transparent;
  font-size: 13px;
  min-width: 92px;
  cursor: default;
  user-select: none;
}

@media (max-width: 1320px) {
  .composer-toolbar {
    grid-template-columns: 1fr;
    grid-template-areas:
      "mode"
      "selects";
  }

  .toolbar-top-row {
    justify-content: flex-start;
  }
}

.upload-box {
  display: none;
  min-height: 82px;
  margin-bottom: 12px;
  place-items: center;
  gap: 6px;
  border: 1px dashed #d4d0c7;
  border-radius: 18px;
  color: #4f4b44;
  background: #fafaf8;
  text-align: center;
  cursor: pointer;
}

.upload-box.visible {
  display: grid;
}

.upload-box input {
  display: none;
}

.reference-preview {
  display: none;
  gap: 10px;
  margin-bottom: 12px;
  padding: 10px;
  border: 1px solid var(--studio-border);
  border-radius: 18px;
  background: #fafaf8;
}

.reference-preview.visible {
  display: grid;
}

.reference-head,
.reference-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.reference-head {
  justify-content: space-between;
}

.reference-head strong {
  color: #23211d;
  font-size: 13px;
}

.reference-head span {
  margin-right: auto;
  color: var(--studio-muted);
  font-size: 12px;
}

.source-strip {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 2px;
  scrollbar-width: none;
}

.source-strip::-webkit-scrollbar {
  display: none;
}

.source-card {
  position: relative;
  display: grid;
  grid-template-columns: 50px minmax(86px, 1fr) 24px;
  align-items: center;
  gap: 8px;
  min-width: 178px;
  padding: 6px;
  border: 1px solid #e4e0d7;
  border-radius: 16px;
  background: #fff;
}

.source-card.active {
  border-color: #1f1f1d;
  box-shadow: inset 0 0 0 1px #1f1f1d;
}

.source-thumb {
  position: relative;
  display: block;
  width: 50px;
  height: 50px;
  overflow: hidden;
  padding: 0;
  border: 0;
  border-radius: 12px;
  background: #efede8;
  cursor: pointer;
}

.source-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.source-thumb em {
  position: absolute;
  right: 3px;
  bottom: 3px;
  padding: 1px 4px;
  border-radius: 999px;
  color: #fff;
  background: rgba(31, 31, 29, .82);
  font-style: normal;
  font-size: 10px;
}

.source-card div {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 2px;
}

.source-card strong {
  overflow: hidden;
  color: #23211d;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.source-card span {
  color: var(--studio-muted);
  font-size: 11px;
}

.source-remove {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  padding: 0;
  border: 1px solid #e1ddd4;
  border-radius: 999px;
  color: #68625a;
  background: #fff;
  font: inherit;
  cursor: pointer;
}

.reference-actions {
  justify-content: flex-end;
}

.storyboard-draft {
  display: none;
  margin-top: 10px;
  padding: 12px;
  border: 1px solid #ece8dd;
  border-radius: 18px;
  background: #fbfaf7;
}

.storyboard-draft.visible {
  display: block;
}

.storyboard-draft-head,
.storyboard-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.storyboard-draft-head span {
  color: #3f3b34;
  font-size: 13px;
  font-weight: 780;
}

.storyboard-draft button {
  min-height: 30px;
  padding: 0 10px;
  border: 1px solid #dedbd3;
  border-radius: 999px;
  color: #23211d;
  background: #fff;
  font: inherit;
  font-size: 12px;
  font-weight: 760;
  cursor: pointer;
}

.storyboard-draft button:disabled {
  opacity: .6;
  cursor: wait;
}

.storyboard-scenes {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin: 10px 0;
}

.storyboard-scenes article {
  min-width: 0;
  padding: 10px;
  border: 1px solid #eeeae0;
  border-radius: 14px;
  background: #fff;
}

.storyboard-scenes strong {
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 999px;
  color: #fff;
  background: #1f1f1d;
  font-size: 12px;
}

.storyboard-scenes p {
  display: -webkit-box;
  margin: 8px 0 0;
  overflow: hidden;
  color: #5d5850;
  font-size: 12px;
  line-height: 1.5;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 4;
}

.storyboard-actions {
  justify-content: flex-end;
}

textarea {
  display: block;
  width: 100%;
  height: var(--composer-textarea-height, 128px);
  min-height: 104px;
  max-height: 260px;
  padding: 10px 18px 6px;
  border: 0;
  border-radius: 0;
  color: #25231f;
  background: transparent;
  resize: none;
  outline: none;
  box-shadow: none;
  font-size: 15px;
  line-height: 1.75;
}

textarea::placeholder {
  color: #aaa59d;
}

.composer-footer {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 12px;
  margin-top: 12px;
}

.composer-left-tools {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.upload-trigger,
.clarity-mode-button,
.prompt-optimize-button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 32px;
  padding: 7px 10px;
  border: 1px solid var(--studio-border);
  border-radius: 999px;
  color: #3f3b35;
  background: #fff;
  font-size: 12px;
  font-weight: 760;
  cursor: pointer;
}

.clarity-mode-button {
  min-width: 74px;
  justify-content: center;
  color: #676158;
  background: #fff;
}

.clarity-mode-button.active {
  border-color: #15130f;
  color: #fff;
  background: #15130f;
}

.prompt-optimize-button {
  min-width: 104px;
  justify-content: center;
  color: #23211d;
  background: #f7f6f2;
  font-size: 12px;
}

body:not(.has-prompt-text) #promptCount {
  display: none;
}

.upload-trigger svg {
  width: 15px;
  height: 15px;
}

#promptCount,
.status {
  color: #77736d;
  font-size: 13px;
}

.status {
  min-height: 0;
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.error-text {
  color: #b13a30 !important;
}

.generate-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: 118px;
  min-height: 42px;
  padding: 0 18px;
  border-radius: 999px;
  color: #fff;
  background: var(--studio-black);
  font-size: 14px;
  font-weight: 820;
}

.generate-button svg {
  width: 17px;
  height: 17px;
}

.generate-button span {
  white-space: nowrap;
}

.composer-expanded .workspace-content {
  padding-bottom: calc(var(--composer-textarea-height, 220px) + 190px);
}

.history-collapsed .studio-shell {
  grid-template-columns: 92px minmax(0, 1fr);
}

.rail-collapsed.history-collapsed .studio-shell {
  grid-template-columns: 92px minmax(0, 1fr);
}

.history-collapsed .history-panel {
  display: none;
}

.history-collapsed .history-resize {
  display: none;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: none;
  place-items: center;
  padding: 24px;
  background: rgba(31, 36, 32, 0.24);
  backdrop-filter: blur(10px);
}

.modal-backdrop.open {
  display: grid;
}

.selection-modal {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: none;
  padding: 18px;
  background: rgba(255, 255, 255, 0.86);
  backdrop-filter: blur(12px);
}

.selection-modal.open {
  display: grid;
  place-items: center;
}

.original-viewer {
  position: fixed;
  inset: 0;
  z-index: 95;
  display: none;
  padding: 18px;
  background: rgba(18, 20, 19, 0.82);
  backdrop-filter: blur(10px);
}

.original-viewer.open {
  display: grid;
  place-items: center;
}

.original-viewer-shell {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  width: min(1480px, 100%);
  height: min(920px, calc(100vh - 36px));
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 24px;
  background: #111;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.32);
}

.original-viewer-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  padding: 16px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  color: #fff;
}

.original-viewer-head h2 {
  margin: 0;
  font-size: 18px;
}

.original-viewer-head span {
  display: block;
  margin-top: 6px;
  color: rgba(255, 255, 255, 0.68);
  font-size: 13px;
  font-weight: 720;
}

.original-viewer-body {
  overflow: auto;
  background:
    linear-gradient(45deg, #151515 25%, transparent 25%),
    linear-gradient(-45deg, #151515 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #151515 75%),
    linear-gradient(-45deg, transparent 75%, #151515 75%);
  background-color: #0c0c0c;
  background-position: 0 0, 0 10px, 10px -10px, -10px 0;
  background-size: 20px 20px;
}

.original-viewer-body img {
  display: block;
  width: auto;
  height: auto;
  max-width: none;
  max-height: none;
}

.selection-shell {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  width: min(1180px, 100%);
  max-height: min(860px, calc(100vh - 36px));
  overflow: hidden;
  border: 1px solid var(--studio-border);
  border-radius: 28px;
  background: #fff;
  box-shadow: 0 24px 80px rgba(15, 23, 42, 0.14);
}

.selection-head {
  position: relative;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  padding: 18px 22px;
  border-bottom: 1px solid var(--studio-border);
}

.selection-head h2 {
  margin: 0;
  font-size: 22px;
  font-weight: 780;
}

.selection-head span {
  display: block;
  margin-top: 6px;
  color: var(--studio-muted);
  font-size: 13px;
}

.selection-body {
  display: grid;
  grid-template-columns: minmax(360px, 1fr) 220px;
  gap: 14px;
  min-height: 0;
  padding: 16px;
}

.selection-canvas-wrap {
  display: grid;
  place-items: center;
  min-width: 0;
  min-height: 320px;
  overflow: auto;
  border: 1px solid var(--studio-border);
  border-radius: 22px;
  background: #f6f5f1;
}

#selectionCanvas {
  max-width: 100%;
  max-height: 100%;
  border-radius: 16px;
  background: #fff;
  cursor: crosshair;
  touch-action: none;
  box-shadow: 0 12px 34px rgba(15, 23, 42, 0.08);
}

.selection-tools {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
}

.selection-tools label {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--studio-border);
  border-radius: 18px;
  color: #403d36;
  background: #fafaf8;
  font-size: 13px;
  font-weight: 760;
}

.selection-tools input[type="range"] {
  height: 28px;
  padding: 0;
}

.auth-dialog {
  position: relative;
  width: min(430px, 100%);
  padding: 26px;
  border: 1px solid var(--studio-border);
  border-radius: 24px;
  background: #fff;
  box-shadow: 0 20px 70px rgba(15, 23, 42, 0.16);
}

.auth-dialog h2 {
  margin: 0 0 8px;
  font-size: 24px;
  font-weight: 780;
}

.auth-dialog p:not(.eyebrow) {
  color: var(--studio-muted);
  line-height: 1.65;
}

.auth-dialog label,
.redeem-field {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
  color: #403d36;
  font-size: 14px;
  font-weight: 760;
}

.auth-register-only {
  display: none !important;
}

.auth-register-only.visible {
  display: grid !important;
}

input,
select {
  width: 100%;
  height: 46px;
  padding: 0 12px;
  border: 1px solid var(--studio-border);
  border-radius: 14px;
  color: var(--studio-text);
  background: #fff;
  outline: none;
}

input:focus,
select:focus {
  border-color: #c7c2b7;
  box-shadow: 0 0 0 4px rgba(15, 15, 14, 0.06);
}

.auth-status,
.recharge-note {
  min-height: 22px;
  margin: -2px 0 14px;
  color: var(--studio-muted);
  font-size: 13px;
}

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

.account-summary {
  display: grid;
  gap: 6px;
  margin: 18px 0;
  padding: 16px;
  border: 1px solid var(--studio-border);
  border-radius: 18px;
  background: #f8f8f6;
}

.account-summary span {
  color: var(--studio-muted);
  font-size: 13px;
}

.account-summary strong {
  color: #16734a;
  font-size: 22px;
}

.account-actions {
  display: grid;
  gap: 10px;
}

.recharge-dialog.user-recharge .auth-actions {
  grid-template-columns: 1fr;
}

.primary-button,
.secondary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 10px 16px;
  border-radius: 999px;
  font-weight: 780;
}

.primary-button {
  color: #fff;
  background: var(--studio-black);
}

.secondary-button {
  color: #4f4b44;
  background: #f2f1ed;
}

.modal-close {
  position: absolute;
  right: 18px;
  top: 18px;
  width: 34px;
  height: 34px;
  border-radius: 999px;
  color: #77736d;
  background: #f2f1ed;
  font-size: 20px;
}

.purchase-link {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  margin: 14px 0;
  border-radius: 999px;
  color: #fff;
  background: var(--studio-black);
  font-weight: 780;
  text-decoration: none;
}

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

.recharge-plan {
  display: grid;
  gap: 6px;
  min-height: 82px;
  padding: 14px;
  border: 1px solid var(--studio-border);
  border-radius: 18px;
  color: var(--studio-text);
  background: #fff;
  text-align: left;
}

.recharge-plan.active {
  border-color: #c9e9d4;
  background: #e8f7ee;
}

.recharge-plan strong {
  font-size: 23px;
}

.recharge-plan span {
  color: var(--studio-muted);
  font-size: 13px;
}

.eyebrow {
  margin: 0 0 8px;
  color: #16734a;
  font-size: 12px;
  font-weight: 780;
}

.section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
}

.section-head h2 {
  margin: 0;
  font-size: 20px;
}

.section-head span {
  color: var(--studio-muted);
  font-size: 13px;
}

.text-button {
  color: #3f3b35;
}

.sidebar-scrollable {
  scrollbar-width: none;
  scrollbar-color: transparent transparent;
}

.sidebar-scrollable::-webkit-scrollbar {
  width: 0;
  height: 0;
}

.sidebar-scrollable::-webkit-scrollbar-track {
  background: transparent;
}

.sidebar-scrollable::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: transparent;
}

.theme-dark {
  --studio-bg: #090909;
  --studio-panel: #171717;
  --studio-soft: #20201e;
  --studio-border: rgba(255, 255, 255, 0.12);
  --studio-text: #f5f5f5;
  --studio-muted: #aaa59a;
  color: var(--studio-text);
  background: var(--studio-bg);
}

.theme-dark .studio-shell,
.theme-dark .workspace-content {
  background: var(--studio-bg);
}

.theme-dark .studio-rail,
.theme-dark .history-panel,
.theme-dark .workspace,
.theme-dark .composer-card,
.theme-dark .result-thread,
.theme-dark .admin-drawer,
.theme-dark .auth-dialog {
  border-color: var(--studio-border);
  background: #171717;
}

.theme-dark .rail-action,
.theme-dark .rail-logo,
.theme-dark .rail-collapse,
.theme-dark .rail-wallet,
.theme-dark .rail-account,
.theme-dark .ready-pill,
.theme-dark .collapse-history-button,
.theme-dark .recharge-header-button,
.theme-dark .nav-link,
.theme-dark .select-pill,
.theme-dark .help-pill,
.theme-dark .upload-trigger,
.theme-dark .clarity-mode-button,
.theme-dark .prompt-optimize-button,
.theme-dark .history-trash {
  border-color: var(--studio-border);
  color: #f5f5f5;
  background: #20201e;
}

.theme-dark .rail-active,
.theme-dark .mode-tabs button.active,
.theme-dark .layout-tabs button.active,
.theme-dark .generate-button,
.theme-dark .primary-button,
.theme-dark .new-chat-button,
.theme-dark .purchase-link {
  color: #080807;
  background: #f3f2ee;
}

.theme-dark .clarity-mode-button.active {
  border-color: #f3f2ee;
  color: #080807;
  background: #f3f2ee;
}

.theme-dark .prompt-card,
.theme-dark .pill-menu,
.theme-dark input,
.theme-dark select,
.theme-dark .modal-close,
.theme-dark .secondary-button,
.theme-dark .mode-tabs,
.theme-dark .layout-tabs {
  border-color: var(--studio-border);
  color: #f5f5f5;
  background: #20201e;
}

.theme-dark .intro-panel h2,
.theme-dark .workspace-title h1,
.theme-dark .history-panel-head h2,
.theme-dark .rail-brand strong,
.theme-dark .prompt-card strong,
.theme-dark textarea {
  color: #f5f5f5;
}

.theme-dark .prompt-card p,
.theme-dark .prompt-card small,
.theme-dark .rail-brand span,
.theme-dark .rail-copy small,
.theme-dark .history .hint,
.theme-dark .status {
  color: #aaa59a;
}

.theme-dark .result-actions .export-4k-button {
  border-color: #f3f2ee;
  color: #080807;
  background: #f3f2ee;
}

.theme-dark .result-actions .export-4k-button:hover {
  color: #080807;
  background: #ffffff;
}

.theme-dark .agent-sidebar,
.theme-dark .agent-messages {
  background: var(--studio-panel-soft);
}

.theme-dark .agent-conversation,
.theme-dark .agent-empty,
.theme-dark .agent-message,
.theme-dark .agent-selects select,
.theme-dark .agent-attachment,
.theme-dark .icon-button {
  border-color: var(--studio-border);
  color: var(--studio-text);
  background: var(--studio-panel);
}

.theme-dark .agent-conversation.active {
  color: var(--studio-accent-foreground);
  background: var(--studio-accent-strong);
}

@keyframes breathe {
  50% { transform: scale(1.018); opacity: .86; }
}

@keyframes imagePulse {
  50% { filter: brightness(1.08); transform: scale(1.02); }
}

@keyframes linePulse {
  50% { opacity: .5; transform: translateX(8px); }
}

@keyframes pulseDot {
  70% { box-shadow: 0 0 0 10px rgba(24, 164, 91, 0); }
  100% { box-shadow: 0 0 0 0 rgba(24, 164, 91, 0); }
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@media (min-width: 1536px) {
  .library-grid {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }
}

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

@media (max-width: 1180px) {
  html,
  body {
    overflow: auto;
  }

  .studio-shell {
    display: grid;
    grid-template-columns: 92px minmax(0, 1fr);
    min-width: 0;
    height: auto;
    min-height: 100vh;
    max-width: none;
  }

  .composer-card {
    left: 24px;
    right: 24px;
  }

  .history-panel {
    display: none;
  }

  .history-mobile-open .history-panel {
    position: fixed;
    inset: 92px 12px 12px;
    z-index: 35;
    display: grid;
    box-shadow: 0 24px 80px rgba(15, 23, 42, 0.16);
  }

  .selection-body {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(360px, 1fr) auto;
  }

  .selection-tools {
    display: grid;
    grid-template-columns: minmax(180px, 1fr) repeat(3, auto);
    align-items: center;
  }

  .selection-tools label {
    min-width: 180px;
  }
}

@media (max-width: 760px) {
  html,
  body {
    width: 100%;
    overflow-x: hidden;
  }

  .studio-shell {
    display: block;
    padding: 10px;
    width: 100%;
    overflow-x: hidden;
  }

  .studio-rail {
    position: sticky;
    top: 10px;
    z-index: 20;
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 6px;
    margin-bottom: 10px;
    padding: 10px;
    border-radius: 18px;
  }

  .rail-top,
  .rail-nav {
    display: contents;
  }

  .rail-bottom {
    display: contents;
  }

  .rail-brand,
  .rail-collapse,
  .rail-wallet {
    display: none;
  }

  .rail-action,
  .rail-action.rail-active,
  .rail-logo,
  .rail-account {
    width: 100%;
    min-height: 44px;
    height: 44px;
    justify-content: center;
    padding: 0;
    border-radius: 15px;
  }

  .rail-copy,
  .rail-account span {
    display: none;
  }

  .workspace {
    min-height: calc(100vh - 88px);
    border-radius: 18px;
    width: 100%;
    min-width: 0;
  }

  .workspace-header,
  .workspace-account {
    display: grid;
    grid-template-columns: 1fr;
  }

  .workspace-header {
    padding: 12px 14px;
  }

  .workspace-title {
    flex-wrap: wrap;
    min-width: 0;
  }

  .composer-toolbar,
  .composer-footer,
  .composer-left-tools {
    display: flex;
  }

  .composer-toolbar {
    flex-direction: column;
    align-items: stretch;
    flex-wrap: wrap;
    height: auto;
  }

  .toolbar-top-row,
  .toolbar-bottom-row {
    position: static;
    flex-wrap: wrap;
    width: 100%;
  }

  .toolbar-billing-group {
    flex: 1 1 100%;
    flex-wrap: wrap;
    justify-content: flex-start;
  }

  .composer-footer {
    grid-template-columns: none;
    flex-wrap: wrap;
  }

  .composer-left-tools {
    flex: 1 1 100%;
  }

  .workspace-content {
    padding: 22px 14px 22px;
  }

  .intro-panel h2 {
    max-width: 100%;
    width: 100%;
    font-size: 32px;
    line-height: 1.06;
    overflow-wrap: anywhere;
    word-break: break-word;
  }

  .prompt-tools {
    justify-content: flex-start;
    max-width: 100%;
    min-width: 0;
    width: 100%;
  }

  .feature-head,
  .settings-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .agent-panel {
    flex-direction: column;
  }

  .agent-sidebar {
    flex: 0 0 auto;
    max-height: 260px;
    border-right: 0;
    border-bottom: 1px solid var(--studio-border);
  }

  .agent-head {
    display: grid;
    grid-template-columns: 1fr;
  }

  .agent-controls {
    min-width: 0;
  }

  .agent-selects,
  .agent-composer {
    grid-template-columns: 1fr;
  }

  .agent-head-actions {
    justify-content: stretch;
    flex-wrap: wrap;
  }

  .agent-head-actions button {
    flex: 1;
  }

  .agent-attach-button {
    width: 100%;
  }

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

  .feature-search {
    max-width: none;
  }

  .prompt-card {
    height: 210px;
    flex-basis: min(78vw, 260px);
    width: min(78vw, 260px);
    min-width: 0;
  }

  .prompt-card strong,
  .prompt-card p,
  .prompt-card small {
    overflow-wrap: anywhere;
  }

  .composer-card {
    position: static;
    margin: 10px 0 0;
    padding: 26px 14px 14px;
  }

  .select-pill,
  .select-pill[data-select="size"],
  .size-select {
    width: auto;
    flex: 1 1 148px;
    min-width: 0;
  }

  .mode-tabs,
  .layout-tabs {
    width: 100%;
    flex: 1 1 100%;
  }

  .mode-tabs button,
  .layout-tabs button {
    flex: 1;
    padding-inline: 12px;
  }

  .price-chip,
  .billing-chip {
    flex: 1 1 150px;
    min-width: 0;
    white-space: normal;
  }

  .generate-button {
    margin-left: auto;
  }

  .preview {
    min-height: clamp(280px, 54vh, 520px);
  }

  .single-result,
  .multi-result {
    min-height: clamp(280px, 54vh, 520px);
  }

  .generating-stage {
    grid-template-columns: 1fr;
    gap: 18px;
    padding: 22px;
  }

  .generating-copy {
    justify-items: center;
    text-align: center;
  }

  .generating-copy strong {
    font-size: 20px;
  }

  .single-result img,
  .multi-result img {
    max-height: min(64vh, 620px);
  }

  .storyboard-scenes {
    grid-template-columns: 1fr;
  }

  .storyboard-actions {
    justify-content: stretch;
    flex-wrap: wrap;
  }

  .storyboard-actions button {
    flex: 1;
  }

  .selection-modal {
    padding: 10px;
  }

  .selection-shell {
    max-height: calc(100vh - 20px);
    border-radius: 22px;
  }

  .selection-head {
    padding: 14px 16px;
  }

  .selection-head h2 {
    font-size: 18px;
  }

  .selection-body {
    grid-template-rows: minmax(280px, 1fr) auto;
    padding: 10px;
  }

  .selection-canvas-wrap {
    min-height: 280px;
  }

  .selection-tools {
    grid-template-columns: 1fr;
  }
}
