/* Shared studio surfaces */
:root {
  --paper: #f6f5fa;
  --ink: #252332;
  --iris: #5843aa;
  --lavender: #e7e0ff;
  --rule: #ddd9e5;
  --accent: var(--iris);
  --accent-strong: #463286;
  --accent-soft: #eeebfa;
  --text: var(--ink);
  --line: var(--rule);
  --muted: #686477;
}
body { font-family: "DM Sans", "Microsoft YaHei UI", "PingFang SC", system-ui, sans-serif; }
:where(a, button, summary, input, select, textarea):focus-visible {
  outline: 3px solid #896add;
  outline-offset: 3px;
}
body.shell-page {
  display: grid;
  grid-template: auto minmax(0, 1fr) / minmax(0, 1fr);
  height: 100dvh;
  width: 100%;
  overflow: hidden;
  background: var(--paper);
}
.shell-page .workspace, .admin-mail-page .workspace.mail-workspace {
  min-width: 0;
  overflow: auto;
  padding: clamp(24px, 4.2vw, 66px) clamp(18px, 6vw, 104px) 56px;
  border-radius: 0;
  background: var(--paper);
}
.studio-header {
  position: relative;
  z-index: 100;
  display: grid;
  grid-template-columns: minmax(max-content, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 15px;
  padding: 0 clamp(18px, 4vw, 68px);
  background: white;
  border-bottom: 1px solid var(--rule);
}
.studio-brand, .auth-wordmark { display: inline-flex; align-items: center; gap: 12px; }
.studio-brand { justify-self: start; color: var(--ink); text-decoration: none; font-size: 19px; }
.studio-symbol {
  position: relative;
  display: inline-block;
  width: 30px;
  height: 32px;
  flex: none;
  transform: rotate(-11deg);
}
.studio-symbol::before, .studio-symbol::after {
  content: "";
  position: absolute;
  width: 16px;
  height: 20px;
  border: 3px solid currentColor;
  border-radius: 5px;
  color: var(--iris);
}
.studio-symbol::before { top: 2px; left: 1px; }
.studio-symbol::after { bottom: 1px; right: 0; background: #c9baff; }
.studio-links { display: flex; gap: clamp(16px, 2.8vw, 44px); }
.studio-links a {
  display: grid;
  place-items: center;
  min-height: 64px;
  color: #635e70;
  border-block: 3px solid transparent;
  text-decoration: none;
  font-size: 14px;
  font-weight: 650;
  white-space: nowrap;
}
.studio-links a:hover, .studio-links a[aria-current] { color: var(--iris); }
.studio-links a[aria-current] { border-bottom-color: var(--iris); }
.studio-account { position: relative; justify-self: end; min-width: 0; max-width: 100%; }
.studio-account summary {
  display: flex; align-items: center; gap: 9px; min-height: 42px; padding: 0 12px;
  color: var(--ink); background: #f1eff6; border-radius: 24px;
  font-size: 13px; font-weight: 650; list-style: none; cursor: pointer;
}
.studio-account summary::-webkit-details-marker { display: none; }
.studio-account summary span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 14ch; }
.account-light { width: 10px; height: 10px; border-radius: 50%; background: var(--iris); flex: none; }
.menu-chevron { width: 7px; height: 7px; border: solid currentColor; border-width: 0 1.5px 1.5px 0; transform: rotate(45deg); margin: -3px 2px 0 0; }
.account-popover {
  position: absolute; top: calc(100% + 6px); right: 0; z-index: 2;
  width: 216px; padding: 12px; background: white;
  border: 1px solid var(--rule); border-radius: 14px; box-shadow: 0 16px 40px #29213920;
}
.account-popover p { display: flex; align-items: center; justify-content: space-between; margin: 0 0 6px; padding: 8px 9px 13px; border-bottom: 1px solid var(--rule); color: var(--muted); font-size: 13px; }
.account-popover p strong { font: 700 18px "Consolas", monospace; color: var(--iris); }
.studio-header .app-nav { display: grid; width: 100%; gap: 0; }
.studio-header .account-popover :is(a, button) {
  display: flex; align-items: center; gap: 8px; width: 100%; padding: 0 10px; min-height: 39px;
  background: transparent; border: 0; border-radius: 7px; color: var(--ink);
  text-align: left; text-decoration: none; font-size: 14px; font-weight: 500;
}
.studio-header .account-popover :is(a, button):hover,
.studio-header .account-popover a[aria-current] { background: #f1eef9; color: var(--iris); }
.studio-header .account-popover > button { margin-top: 5px; border-top: 1px solid var(--rule); border-radius: 0; }
.studio-home { max-width: 1240px; margin: auto; }
.studio-home h1, .shell-page .workspace :is(.feature-header, .text2image-header, .billing-header, .recharge-header, .mail-page-header, .settings-header) h1 {
  margin: 0; font-size: clamp(28px, 3.5vw, 52px); font-weight: 750; letter-spacing: -.045em; line-height: 1.2; color: var(--ink);
}
.studio-home h1 span { color: #8567d3; }
.creation-modes { display: grid; grid-template-columns: 1.12fr 1fr; gap: 18px; margin-block: 26px 20px; }
.mode-card {
  position: relative; isolation: isolate; overflow: hidden; display: flex;
  flex-direction: column; align-items: flex-start; justify-content: space-between;
  min-width: 0; min-height: clamp(218px, 19vw, 282px);
  padding: clamp(20px, 2.2vw, 36px); text-align: left;
  border: 1px solid transparent; border-radius: 16px; color: white;
  transition: box-shadow 160ms ease, transform 160ms ease;
}
.mode-card:hover { transform: translateY(-3px); box-shadow: 0 10px 24px #26203221; }
.mode-card:active { transform: translateY(0); }
.mode-copy { display: grid; gap: 7px; z-index: 1; }
.mode-copy strong { font-size: clamp(23px, 2.25vw, 34px); letter-spacing: -.035em; font-weight: 700; }
.mode-copy > span { font-size: 14px; line-height: 1.6; }
.mode-open { display: inline-flex; align-items: center; gap: 6px; z-index: 1; padding: 9px 13px; background: white; color: #30294f; border-radius: 8px; font-size: 13px; font-weight: 700; }
.mode-open b { font-size: 17px; line-height: 1; }
.workflow-mode {
  background-color: #35275b;
  background-image: radial-gradient(circle, #8674ac70 1px, transparent 1.25px), linear-gradient(115deg, #302544 26%, #594780 100%);
  background-size: 14px 14px, cover;
}
.workflow-mode .mode-copy > span { color: #e6def3; }
.node-sketch { position: absolute; width: 176px; height: 108px; right: 5%; bottom: 13%; transform: rotate(-7deg); }
.node-sketch i {
  position: absolute; z-index: 1; width: 64px; height: 42px; border: 1px solid #c9b6ed;
  border-radius: 7px; box-shadow: 3px 5px 0 #281a4940;
  background: linear-gradient(90deg,#e7e0ff 64%,transparent 0) 9px 23px/36px 2px no-repeat,
    linear-gradient(90deg,#d4c9f1 48%,transparent 0) 9px 29px/36px 2px no-repeat,
    linear-gradient(#aa91d7 13px,#776390 13px);
}
.node-sketch i:nth-child(1) { top: 0; left: 0; }
.node-sketch i:nth-child(2) { bottom: 0; left: 0; }
.node-sketch i:nth-child(3) { right: 0; top: 30px; width: 69px; height: 48px; background-color: #a195c5; }
.node-sketch::before, .node-sketch::after {
  content: ""; position: absolute; left: 60px; width: 54px; height: 31px;
  border: solid #d5c4fd; border-width: 0 0 2px 2px; border-radius: 0 0 0 14px;
  transform: skewX(40deg);
}
.node-sketch::before { top: 20px; }
.node-sketch::after { top: 53px; transform: scaleY(-1) skewX(40deg); }
.image-mode { color: #292336; border-color: #d5cde6; background: #e8e2f2; }
.image-mode::before {
  content: ""; position: absolute; z-index: -1; inset: 0;
  background: linear-gradient(100deg,#ebe6f4 5%,#eae3f0d9 36%,transparent 72%), url("/static/images/studio-architecture.webp") center 58% / cover;
}
.image-mode .mode-open { background: #352b48; color: white; }
.project-heading, .project-heading > div { display: flex; align-items: center; gap: 10px; }
.project-heading { justify-content: space-between; margin: clamp(30px, 3.6vw, 54px) 0 16px; }
.project-heading h2 { font-size: clamp(20px, 2vw, 26px); margin: 0; letter-spacing: -.035em; }
.project-heading .count-badge { color: var(--iris); background: var(--lavender); }
.project-actions button { min-height: 40px; padding: 0 13px; background: white; color: var(--ink); border: 1px solid var(--rule); border-radius: 8px; font-size: 13px; }
.project-actions button:hover:enabled { border-color: var(--iris); }
.project-actions button:disabled { opacity: .48; cursor: default; }
.studio-home .canvas-list-shell { padding: 0; background: transparent; border: 0; }
.studio-home .canvas-list { grid-template-columns: repeat(auto-fill, minmax(min(100%, 248px), 1fr)); gap: 12px; }
.project-card { position: relative; min-width: 0; border: 1px solid var(--rule); border-radius: 12px; background: white; }
.project-card:hover, .project-card.selected { border-color: #9a86bc; }
.project-card.selected { background: #f1edfb; }
.project-card a { display: grid; gap: 7px; padding: 18px 52px 18px 18px; color: var(--ink); text-decoration: none; border-radius: inherit; }
.project-card strong { font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.project-type { color: var(--iris); font-size: 12px; font-weight: 700; }
.project-date { font-size: 12px; color: var(--muted); }
.project-card label { position: absolute; top: 6px; right: 4px; display: grid; width: 44px; height: 44px; place-items: center; cursor: pointer; }
.project-card input { width: 17px; height: 17px; accent-color: var(--iris); }
.studio-home .empty-state { align-content: center; gap: 6px; min-height: 150px; padding: 18px; background: #eeedf3; border-color: #c6bfd3; text-align: center; font-size: 14px; }
.studio-home .empty-state p { margin: 0; }
.studio-home .create-inline { padding: 12px; border-radius: 12px; background: #e8e3f2; }
.shell-page .workspace > :is(.feature-panel, .text2image-panel, .billing-panel, .recharge-panel, .provider-settings-panel) {
  position: static; width: 100%; max-width: 1240px; min-height: 0; max-height: none;
  margin: 0 auto; padding: 0; gap: 28px; align-content: start;
  background: transparent; border: 0; box-shadow: none; transform: none;
}
.shell-page :is(.text2image-layout, .prompt-assistant-layout) { grid-template-columns: minmax(300px,.8fr) minmax(0,1.2fr); gap: 20px; }
.shell-page :is(.text2image-form, .prompt-assistant-form, .text2image-results, .prompt-output-card) {
  min-width: 0; padding: clamp(16px,2vw,28px); background: white; border: 1px solid var(--rule); border-radius: 14px;
}
.shell-page :is(.text2image-results,.prompt-output-card) { background: #eeecf4; }
.shell-page .text2image-run, .login-page .login-submit { color: white; background: var(--iris); border: 0; border-radius: 8px; }
.shell-page .text2image-run:hover, .login-page .login-submit:hover { background: var(--accent-strong); }
.shell-page :is(.billing-balance,.billing-summary-card) { background: var(--lavender); color: var(--ink); border-color: transparent; }
.shell-page .billing-balance :is(strong,span) { color: var(--accent-strong); }

/* Canvas chrome stays outside the transformed world layer. */
.canvas-page .editor-palette {
  --tool-bg: #fff; --tool-ink: #41374f; --tool-rule: #d9d2e2; --tool-hover: #ece6f7;
  position: absolute; z-index: 68; left: 16px; top: 50%; transform: translateY(-50%);
  display: grid; gap: 2px; align-items: start; padding: 5px;
  background: var(--tool-bg); border: 1px solid var(--tool-rule); border-radius: 12px;
  box-shadow: 0 5px 20px #23182f12;
}
.smart-mode .editor-palette { --tool-bg: var(--smart-panel); --tool-ink: var(--smart-text); --tool-rule: var(--smart-line); --tool-hover: var(--smart-soft); }
.editor-palette button {
  display: flex; align-items: center; justify-content: flex-start; gap: 9px; min-height: 44px;
  padding: 0 12px; color: var(--tool-ink); background: transparent; border: none;
  border-radius: 7px; box-shadow: none; font-size: 13px; font-weight: 650; white-space: nowrap;
}
.editor-palette button:hover { background: var(--tool-hover); color: var(--tool-ink); }
.editor-palette button:last-child { border-top: 1px solid var(--tool-rule); border-radius: 0 0 7px 7px; }
.editor-palette svg { width: 17px; height: 17px; }
.canvas-page:not(.smart-mode) .board { background: radial-gradient(#d1cbd9 1px,transparent 1.1px) 0 0/20px 20px, #f7f6f9; }
.canvas-page:not(.smart-mode) .canvas-topbar {
  top: 0; left: 0; right: 0; gap: 10px; align-items: center;
  padding: 6px 16px; background: #fcfbfe; border-bottom: 1px solid var(--rule); pointer-events: auto;
}
.canvas-topbar .canvas-title-chip, .canvas-topbar .canvas-toolbar .pill-button {
  background: transparent; box-shadow: none; border: none; border-radius: 7px;
}
.canvas-topbar .canvas-toolbar .pill-button:hover { background: #eae5f4; }
.canvas-page .canvas-app-full, .canvas-page .canvas-app-full .board { height: 100dvh; }
.smart-mode .smart-back { top: 12px; left: 16px; border-radius: 8px; }
.smart-mode .smart-title { top: 13px; left: 162px; }
.smart-mode .smart-actions-bar { top: 12px; right: 16px; }
.smart-mode .smart-actions-bar :is(.smart-log-toggle,.billing-toggle,.asset-toggle) { border-radius: 8px; }
.canvas-page .customer-service-float { bottom: 160px; width: 42px; height: 42px; right: 16px; }

/* Entry and policy pages */
body.login-page { display: block; height: auto; min-height: 100dvh; padding: 0; background: #fff; }
.login-page .login-shell {
  display: grid; grid-template-columns: minmax(0,1fr) minmax(400px,.95fr);
  align-items: center; width: 100%; min-height: 100dvh; margin: 0;
}
.auth-cover {
  position: sticky; top: 0; align-self: start; display: flex; flex-direction: column; justify-content: space-between;
  height: 100dvh; padding: clamp(24px,4vw,68px); overflow: hidden;
  color: white; background: linear-gradient(145deg,#362846bd 0%, #352a4a3b 44%,#261932bd 100%), url("/static/images/studio-architecture.webp") 58% center / cover;
}
.auth-wordmark { font-size: 16px; font-weight: 650; }
.auth-wordmark .studio-symbol::before { color: white; }
.auth-wordmark .studio-symbol::after { color: white; background: #a48aba; }
.auth-cover strong { font-size: clamp(64px, 7.4vw, 128px); line-height: .99; letter-spacing: -.08em; }
.auth-cover strong span { color: #d0baf7; }
.login-page .login-panel {
  width: min(100%, 490px); justify-self: center; margin: 0; padding: 40px clamp(26px, 3vw, 46px);
  border: 0; background: white; box-shadow: none; border-radius: 0;
}
.login-page .login-copy h1 { font-size: clamp(27px, 3vw, 40px); letter-spacing: -.05em; }
.login-page .login-form { gap: 18px; }
.login-page .login-form > label:not(.privacy-check) > span { color: var(--ink); }
.login-page .login-form input:not([type=checkbox]) { background: #f8f7fa; border-color: var(--rule); }
.privacy-page { background: var(--paper); }
.policy-page-shell .policy-title { text-align: left; }
.policy-page-shell .policy-title p { justify-content: flex-start; flex-wrap: wrap; }
.policy-card { border-top: 4px solid var(--iris); }
@media (min-width: 960px) {
  .policy-page-shell { display: grid; grid-template-columns: 230px minmax(0,1fr); align-items: start; gap: 36px; width: min(1180px,92vw); }
  .policy-page-shell .policy-title { position: sticky; top: 100px; }
  .policy-page-shell .policy-title p { display: grid; gap: 4px; }
  .policy-page-shell .policy-title p span { display: none; }
}
@media (max-width: 800px) {
  .shell-page :is(.text2image-layout, .prompt-assistant-layout) { grid-template-columns: minmax(0,1fr); }
  .node-sketch { transform: scale(.75) rotate(-7deg); transform-origin: right bottom; right: 3%; bottom: 8%; }
  .mode-card { min-height: 216px; }
  .canvas-page:not(.smart-mode) .canvas-topbar { align-items: flex-start; }
  .canvas-toolbar { max-width: 64vw; }
  .canvas-toolbar .points-pill { display: none; }
  .smart-mode .smart-title .ghost-title { width: min(18vw, 180px); }
}
@media (max-width: 640px) {
  .studio-header { grid-template: auto auto / 1fr auto; gap: 0 12px; padding: 6px 16px 0; }
  .studio-brand { min-height: 44px; font-size: 17px; }
  .studio-links { grid-row: 2; grid-column: 1/-1; justify-content: space-between; gap: 0; }
  .studio-links a { flex: 1; min-height: 44px; font-size: 13px; }
  .studio-account { grid-row: 1; grid-column: 2; }
  .studio-account summary { min-height: 38px; }
  .studio-header .account-popover a, .studio-header .account-popover button { min-height: 44px; }
  .creation-modes { grid-template-columns: 1fr; gap: 12px; margin-top: 18px; }
  .mode-card { min-height: 155px; padding: 18px; }
  .node-sketch { bottom: 12%; }
  .mode-copy strong { font-size: 23px; }
  .mode-copy > span { font-size: 13px; }
  .project-heading { gap: 5px; }
  .project-heading > div { gap: 6px; }
  .project-actions button { min-height: 44px; padding: 0 9px; }
  .canvas-page .editor-palette {
    top: auto; left: 50%; bottom: max(36px,env(safe-area-inset-bottom)); transform: translateX(-50%);
    width: max-content; max-width: calc(100vw - 16px); display: flex; overflow-x: auto; gap: 0;
  }
  .editor-palette button { flex-direction: column; justify-content: center; gap: 2px; padding: 4px 8px; min-width: 44px; font-size: 11px; }
  .editor-palette button:last-child { border-top: 0; border-left: 1px solid var(--tool-rule); }
  .canvas-page .minimap, .smart-mode .smart-minimap { width: 86px; height: 56px; bottom: 98px; right: 10px; }
  .canvas-page .customer-service-float { right: 10px; bottom: 164px; }
  .canvas-page:not(.smart-mode) .canvas-topbar { display: grid; gap: 0; padding: 3px 8px; }
  .canvas-topbar .canvas-toolbar { flex-wrap: nowrap; justify-content: start; max-width: calc(100vw - 16px); overflow: auto; }
  .canvas-topbar .canvas-toolbar .pill-button { white-space: nowrap; padding: 0 8px; min-height: 42px; }
  .smart-mode .smart-back { left: 10px; top: 10px; width: 40px; padding: 0; justify-content: center; }
  .smart-back span { display: none; }
  .smart-mode .smart-title { left: 60px; top: 12px; }
  .smart-mode .smart-title .ghost-title { width: 26vw; }
  .smart-mode .smart-actions-bar { right: 8px; top: 10px; gap: 4px; max-width: 48vw; }
  .smart-mode .smart-actions-bar :is(.smart-log-toggle,.billing-toggle,.asset-toggle) { width: 42px; min-width: 0; padding: 0; justify-content: center; }
  .smart-actions-bar :is(button,a) > span { display: none; }
  .login-page .login-shell { display: block; min-height: 100dvh; }
  .auth-cover { position: relative; height: 168px; padding: 16px 24px; background-position: center 55%; }
  .auth-cover strong { font-size: 40px; line-height: 1.1; }
  .auth-cover strong br { display: none; }
  .login-page .login-panel { margin: auto; padding: 26px 24px 36px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: 0s !important; animation-duration: .01ms !important; }
}
