@font-face {
  font-family: Archivo;
  src: url('/assets/archivo.woff2') format('woff2');
  font-weight: 100 900;
  font-stretch: 62% 125%;
  font-display: swap;
}

@font-face {
  font-family: 'JetBrains Mono';
  src: url('/assets/jetbrains-mono.woff2') format('woff2');
  font-weight: 100 800;
  font-display: swap;
}

@font-face {
  font-family: Inter;
  src: url('/assets/inter.woff2') format('woff2');
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

:root {
  color-scheme: dark;
  font-family: Inter, system-ui, sans-serif;
  font-synthesis: none;
  background: #111113;
  color: #f5f4f3;
  --surface: #1a1a1d;
  --raised: #232326;
  --tile: #27272b;
  --hover: #303035;
  --muted: #acabb0;
  --accent: #f0efed;
  --accent-ink: #18181b;
  --focus: #c2bfdd;
  --sidebar-width: 208px;
  --brand: #4227da;
  --lime: #8f7cff;
  --lime-deep: #2b1896;
  --green: #a99bff;
  --lilac: #4227da;
  --chip: #242428;
  --pill: #2c2c31;
  --mono: 'JetBrains Mono', ui-monospace, Consolas, monospace;
  --display: Archivo, Inter, system-ui, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; scroll-padding-top: 18px; }
body { margin: 0; min-width: 300px; min-height: 100vh; }
button, textarea, select, input { font: inherit; }
button, a, select, textarea, input { -webkit-tap-highlight-color: transparent; }
button { color: inherit; cursor: pointer; }
a { color: inherit; text-decoration: none; }
button, select, textarea, input { border: 0; }
:is(button, a, select, textarea, input):focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; }
button:disabled { cursor: default; opacity: .62; }
h1, h2, p { margin: 0; }
.icon-library { position: absolute; width: 0; height: 0; overflow: hidden; }
.icon { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.65; stroke-linecap: round; stroke-linejoin: round; }

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 2;
  width: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  padding: 23px 14px 17px;
  background: #161618;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 0 8px; width: max-content; }
.brand-mark { width: 35px; height: 35px; display: grid; place-items: center; color: var(--accent-ink); background: var(--accent); border-radius: 9px; }
.brand-mark .icon { width: 25px; height: 25px; }
.brand-name { font-size: 1.2rem; font-weight: 725; letter-spacing: -.055em; white-space: nowrap; }
.brand-name span { color: var(--muted); font-weight: 470; }
.app-nav { margin-top: 41px; display: flex; flex: 1; flex-direction: column; justify-content: space-between; gap: 14px; }
.nav-links { display: grid; gap: 4px; }
.nav-links a, .sidebar-settings { display: flex; align-items: center; gap: 11px; min-height: 43px; border-radius: 9px; background: transparent; padding: 0 13px; text-align: left; color: var(--muted); font-size: .875rem; font-weight: 560; white-space: nowrap; }
.nav-links a:hover, .sidebar-settings:hover { background: var(--raised); color: var(--accent); }
.nav-links a[aria-current="page"], .nav-links a[aria-current="true"] { background: #2b2b2f; color: var(--accent); }
.nav-links .icon, .sidebar-settings .icon { width: 17px; height: 17px; }
.sidebar-settings { width: 100%; }
.mobile-menu { display: none !important; }

.app-main { margin-left: var(--sidebar-width); min-height: 100vh; background: radial-gradient(ellipse 780px 320px at 43% 0%, #1b1b1e, transparent); }
.topbar { height: 65px; padding: 0 clamp(23px, 4vw, 62px); display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.topbar-label { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: .875rem; font-weight: 520; white-space: nowrap; }
.topbar-label .icon { width: 16px; height: 16px; }
.connection { display: inline-flex; align-items: center; gap: 8px; min-height: 34px; border-radius: 24px; background: var(--raised); padding: 0 12px; color: #dedce2; font-size: .8125rem; font-weight: 550; white-space: nowrap; }
.connection:hover { background: var(--hover); }
.connection-dot { width: 7px; height: 7px; border-radius: 50%; background: #d6ae7d; }
.connection-dot[data-state="connected"] { background: #e9e7f0; }

.workspace { max-width: 1240px; margin: 0 auto; padding: 0 clamp(23px, 4vw, 62px) 52px; }

.text-button { display: inline-flex; align-items: center; gap: 6px; padding: 0; background: none; color: #bfbec4; font-size: .875rem; font-weight: 560; text-align: left; }
.text-button:hover { color: var(--accent); }


.studio-select { min-width: 0; }
.studio-select-trigger { display: flex; justify-content: space-between; align-items: center; gap: 6px; width: 100%; min-height: 26px; padding: 2px 0; border-radius: 5px; background: transparent; color: var(--accent); font-size: .875rem; font-weight: 635; text-align: left; }
.studio-select-trigger:not(:disabled):hover .studio-select-value { color: #fff; }
.studio-select-trigger:disabled { opacity: 1; }
.studio-select-trigger:disabled .studio-select-chevron { visibility: hidden; }
.studio-select-value { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.studio-select-chevron, .studio-select-check { width: 15px; height: 15px; flex: none; color: #aaa8b1; }
.studio-select-trigger[aria-expanded="true"] .studio-select-chevron { transform: rotate(180deg); }
.studio-select-menu { position: fixed; z-index: 30; inset: auto; margin: 0; width: max-content; padding: 5px; overflow-y: auto; overscroll-behavior: contain; border: 0; border-radius: 10px; background: #29292e; color: var(--accent); box-shadow: 0 12px 30px #0009; }
.studio-select-menu:focus { outline: none; }
.studio-select-option { display: flex; justify-content: space-between; align-items: center; gap: 12px; width: 100%; min-height: 36px; padding: 6px 9px; border-radius: 6px; color: #e0dee4; background: transparent; font-size: .875rem; font-weight: 520; cursor: pointer; }
.studio-select-option[aria-selected="true"] { color: #faf9fa; font-weight: 660; }
.studio-select-option:is(:hover, [data-active="true"]) { color: #fff; background: #3b3b42; }
.studio-select-option[aria-disabled="true"] { cursor: default; opacity: .5; }
.studio-select-option[aria-selected="false"] .studio-select-check { visibility: hidden; }

.field-hint { margin-top: 3px; color: var(--muted); font-size: .8125rem; }

.reference-heading { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 5px 10px; }
.reference-heading h2 { color: #d7d5db; font-size: .875rem; font-weight: 600; }
.reference-modes { display: inline-flex; gap: 4px; padding: 3px; border-radius: 9px; background: #121214; }
.reference-modes button { min-height: 32px; padding: 0 9px; border-radius: 7px; background: none; color: var(--muted); font-size: .8125rem; font-weight: 600; text-align: left; }
.reference-modes button:hover, .reference-modes button[aria-pressed="true"] { background: var(--hover); color: var(--accent); }
.reference-link { min-height: 32px; }
.reference-pickers { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 160px), 1fr)); gap: 6px; }
.reference-picker { display: flex; align-items: center; gap: 6px; min-height: 42px; min-width: 0; padding: 6px 8px; border-radius: 8px; background: var(--raised); color: #e3e1e6; text-align: left; }
.reference-picker:enabled:hover { background: var(--hover); }
.reference-picker > .icon { width: 16px; height: 16px; color: #b8b7be; }
.reference-picker-label { flex: 1; font-size: .875rem; font-weight: 600; overflow-wrap: anywhere; }
.reference-picker-action { display: block; color: var(--muted); font-size: .75rem; font-weight: 500; }
.reference-picker-count { color: var(--muted); font-size: .8125rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.reference-picker .reference-plus { width: 14px; height: 14px; }
.reference-upload-hint { margin: 6px 0 0; line-height: 1.45; }
.reference-link-controls { display: grid; gap: 5px; margin-top: 7px; padding: 8px; border-radius: 8px; background: var(--raised); }
.reference-link-controls label { font-size: .8125rem; color: #d5d4db; }
.reference-link-input { display: flex; flex-wrap: wrap; gap: 6px; }
.reference-link-input input { flex: 1 1 150px; min-width: 0; min-height: 38px; padding: 6px 8px; background: #131315; color: var(--accent); border-radius: 6px; font-size: .875rem; }
.reference-link-input input::placeholder { color: #96959f; }
.reference-link-input button { min-height: 38px; }
.reference-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)); gap: 6px; max-height: 198px; overflow-y: auto; margin: 7px 0 0; padding: 0; list-style: none; }
.reference-item { display: flex; align-items: center; gap: 6px; min-width: 0; padding: 5px; border-radius: 8px; background: var(--raised); }
.reference-item-thumbnail { width: 34px; height: 34px; flex: none; border-radius: 5px; object-fit: cover; background: #131315; }
.reference-item-info { min-width: 0; flex: 1; }
.reference-item-name, .reference-item-meta { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.reference-item-name { color: #e3e1e6; font-size: .8125rem; font-weight: 590; }
.reference-item-meta { color: var(--muted); font-size: .75rem; }
.reference-item-token, .reference-item-remove { flex: none; border-radius: 5px; background: var(--tile); color: var(--accent); }
.reference-item-token:hover, .reference-item-remove:hover { background: var(--hover); }
.reference-item-token { min-height: 29px; padding: 0 5px; font-size: .75rem; white-space: nowrap; }
.reference-item .reference-item-remove { display: grid; place-items: center; width: 29px; height: 29px; padding: 0; }
.reference-item-remove .icon { width: 14px; height: 14px; }
.frame-references { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
.frame-picker { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 7px; min-width: 0; min-height: 42px; padding: 5px 8px; border-radius: 8px; background: var(--raised); }
.frame-picker .reference-btn { min-height: 31px; color: #dedce3; }
.frame-picker .reference-btn:hover { color: #fff; }
.frame-picker .reference-btn .icon { width: 15px; height: 15px; }
.frame-references > .field-hint { grid-column: 1 / -1; }
.reference-feedback { color: var(--muted); margin-top: 1px; font-size: .8125rem; line-height: 1.4; }
.reference-preview { display: flex; align-items: center; gap: 7px; max-width: 100%; padding: 3px 3px 3px 5px; border-radius: 7px; color: #e3e1e7; background: var(--raised); font-size: .8125rem; }
.reference-preview img { width: 27px; height: 24px; object-fit: cover; border-radius: 4px; }
.reference-preview span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.reference-preview .icon-button { width: 25px; height: 25px; }

.primary-button, .secondary-button { display: inline-flex; align-items: center; justify-content: center; min-height: 42px; gap: 8px; border-radius: 9px; padding: 0 15px; white-space: nowrap; font-weight: 680; font-size: .875rem; }
.primary-button { background: var(--accent); color: var(--accent-ink); }
.primary-button:not(:disabled):hover { background: #fff; }
.primary-button .icon, .secondary-button .icon { width: 17px; height: 17px; }
.secondary-button { background: var(--tile); color: var(--accent); }
.secondary-button:not(:disabled):hover { background: var(--hover); }
.generation-status { margin-top: 10px; color: var(--muted); font-size: .875rem; line-height: 1.4; }
.generation-status:empty { display: none; }
[data-state="error"] { color: #ffbcb8; }

.gallery { margin-top: 28px; }
#studio[hidden] + .gallery { margin-top: 39px; }
.gallery-header { display: flex; justify-content: space-between; align-items: end; gap: 12px; margin-bottom: 13px; }
.gallery-header h2, .dialog h2 { font-size: 1.42rem; letter-spacing: -.045em; font-weight: 680; }
.gallery-header p { color: var(--muted); font-size: .875rem; line-height: 1.45; margin-top: 5px; }
.gallery-actions { display: flex; gap: 11px; align-items: center; flex-wrap: wrap; justify-content: end; }
.gallery-filters { display: flex; gap: 2px; padding: 3px; border-radius: 9px; background: var(--surface); }
.gallery-filters button { min-height: 30px; padding: 0 9px; border-radius: 6px; background: transparent; color: var(--muted); font-size: .8125rem; font-weight: 580; }
.gallery-filters button:hover { color: var(--accent); }
.gallery-filters button[aria-pressed="true"] { background: var(--hover); color: var(--accent); }
.gallery-toggle { min-height: 32px; white-space: nowrap; }
.gallery-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 11px; }
.gallery-card { display: flex; flex-direction: column; min-width: 0; overflow: hidden; padding: 0; border-radius: 11px; background: var(--surface); text-align: left; }
.gallery-card:hover { background: var(--raised); }
.gallery-card-thumb { position: relative; display: block; overflow: hidden; width: 100%; aspect-ratio: 16 / 10; background: #242428; }
.gallery-card-thumb > :is(img, video) { display: block; width: 100%; height: 100%; object-fit: cover; transition: transform .3s ease; }
.gallery-card:hover .gallery-card-thumb > :is(img, video) { transform: scale(1.04); }
.gallery-tag { position: absolute; top: 8px; left: 8px; display: inline-flex; align-items: center; gap: 4px; border-radius: 6px; padding: 4px 6px; background: #151517d9; color: #f3f2f2; font-size: .75rem; font-weight: 620; }
.gallery-tag .icon { width: 13px; height: 13px; }
.gallery-play { position: absolute; right: 8px; bottom: 8px; width: 29px; height: 29px; border-radius: 50%; display: grid; place-items: center; color: #f4f3f3; background: #151517d9; }
.gallery-play .icon { width: 17px; height: 17px; }
.gallery-card-body { display: flex; width: 100%; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 3px 6px; padding: 10px; }
.gallery-card-body strong { font-size: .875rem; font-weight: 650; color: #eceaf0; overflow-wrap: anywhere; }
.gallery-card-body > span { color: var(--muted); font-size: .75rem; }
.gallery-empty { margin-top: 15px; padding: 28px 16px; border-radius: 10px; text-align: center; color: var(--muted); background: var(--surface); }

.icon-button { flex: none; display: inline-grid; width: 36px; height: 36px; place-items: center; border-radius: 8px; background: var(--tile); color: var(--accent); }
.icon-button:hover { background: var(--hover); }
.icon-button .icon { width: 17px; height: 17px; }
.dialog { width: min(660px, calc(100% - 28px)); max-height: calc(100% - 28px); border: 0; border-radius: 16px; padding: 19px; background: #202023; color: var(--accent); box-shadow: 0 22px 90px #0009; }
.dialog::backdrop { background: #08080ab8; backdrop-filter: blur(5px); }
.dialog-heading { display: flex; align-items: center; justify-content: space-between; gap: 15px; margin-bottom: 14px; }
.dialog-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: end; margin-top: 15px; }
.media-stage { display: grid; place-items: center; overflow: hidden; min-height: 100px; border-radius: 9px; background: #101012; }
.media-stage :is(img, video) { width: 100%; max-height: 53vh; object-fit: contain; }
.media-prompt, .settings-dialog p { color: #c1bfc7; line-height: 1.55; margin-top: 12px; overflow-wrap: anywhere; }
.media-prompt { white-space: pre-wrap; }
.settings-dialog { width: min(510px, calc(100% - 28px)); }
.integration-list { display: grid; gap: 5px; margin: 15px 0 0; }
.integration-list > div { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 9px 11px; border-radius: 8px; background: var(--tile); }
.integration-list dt { font-size: .875rem; font-weight: 650; }
.integration-list dt span { display: block; color: var(--muted); font-weight: 450; font-size: .8125rem; margin-top: 2px; }
.integration-list dd { margin: 0; color: #c9c7cf; font-size: .8125rem; text-align: right; }
.credential-form { display: grid; gap: 7px; margin-top: 16px; }
.credential-form label { color: var(--accent); font-size: .875rem; font-weight: 630; }
.credential-form input { width: 100%; padding: 11px 12px; border-radius: 8px; background: #121214; color: var(--accent); }
.credential-form input::placeholder { color: #9a98a1; opacity: 1; }
.credential-actions { display: flex; flex-wrap: wrap; gap: 7px; }
.settings-dialog .credential-status { margin-top: 1px; font-size: .875rem; }
.settings-dialog .credential-status:empty { display: none; }
.settings-dialog .credential-status[data-state="error"] { color: #ffbcb8; }

@media (max-width: 1160px) {
  :root { --sidebar-width: 176px; }
  .sidebar { padding-inline: 11px; }
  .workspace, .topbar { padding-inline: 23px; }
}

@media (max-width: 910px) {
  .gallery-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 680px) {
  .sidebar { position: relative; width: 100%; flex-direction: row; justify-content: space-between; align-items: center; padding: 11px 15px; }
  .brand { padding: 0; }
  .brand-mark { width: 33px; height: 33px; }
  .brand-name { font-size: 1.14rem; }
  .mobile-menu { display: inline-grid !important; }
  .app-nav { display: none; position: absolute; top: calc(100% + 5px); right: 12px; width: min(252px, calc(100% - 24px)); margin: 0; padding: 6px; border-radius: 10px; background: #242427; box-shadow: 0 12px 24px #0009; }
  #mobile-menu[aria-expanded="true"] + .app-nav, .app-nav[data-open="true"] { display: flex; }
  .app-main { margin-left: 0; }
  .topbar { height: 47px; padding-inline: 15px; }
  .topbar-label { font-size: .8125rem; }
  .connection { min-height: 30px; }
  .workspace { padding-inline: 13px; }
  .gallery { margin-top: 24px; }
  .gallery-header { align-items: start; flex-direction: column; }
  .gallery-grid { gap: 8px; }
  .gallery-card-body { padding: 8px; }
}

@media (max-width: 465px) {
  .reference-pickers { grid-template-columns: repeat(auto-fit, minmax(min(100%, 120px), 1fr)); }
  .reference-picker .reference-plus { display: none; }
}

/* ===== Compositor Lumefy ===== */
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.workspace { max-width: 1320px; }
.hero { padding: clamp(28px, 6vh, 70px) 0 clamp(26px, 4.5vh, 48px); text-align: center; }
.hero h1 {
  font-family: var(--display);
  font-stretch: 82%;
  font-weight: 750;
  font-size: clamp(2.2rem, 5vw, 4.3rem);
  line-height: 1;
  letter-spacing: -.03em;
  background: linear-gradient(180deg, #ffffff 0%, #ececec 40%, #a3a2a8 100%);
  padding-bottom: .08em;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: 0 1px 0 #ffffff10;
}

.composer-shell { display: flex; align-items: flex-end; justify-content: center; gap: 10px; }
.mode-rail { flex: none; display: flex; flex-direction: column; gap: 6px; padding: 7px; margin-bottom: 0; border-radius: 26px; background: #1b1b1e; box-shadow: inset 0 0 0 1px #ffffff08; }
.mode-rail button { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; width: 92px; min-height: 76px; border-radius: 20px; background: transparent; color: #8f8e95; font-size: .875rem; font-weight: 700; }
.mode-rail button .icon { width: 21px; height: 21px; }
.mode-rail button:hover { color: #e9e8ec; background: #232327; }
.mode-rail button[aria-selected="true"] { color: #fff; background: #2a2a2f; box-shadow: inset 0 0 0 1px #ffffff0d, 0 6px 18px #0006; }

.composer { position: relative; flex: 1 1 auto; min-width: 0; max-width: 1200px; padding: 11px; border-radius: 30px; background: #1b1b1e; box-shadow: inset 0 0 0 1px #ffffff09, 0 30px 80px #0000004d; }

.chip-row { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; padding-bottom: 0; }
.chip-row::-webkit-scrollbar { display: none; }
.chip-group[hidden] { display: none; }
.chip-group { display: contents; border: 0; margin: 0; padding: 0; }
.chip { position: relative; flex: 1 1 0; min-width: 150px; display: flex; align-items: center; gap: 11px; min-height: 62px; padding: 8px 14px 8px 8px; border-radius: 20px; background: var(--chip); color: inherit; text-align: left; transition: background .15s ease; }
.chip:hover, .chip:focus-within, .chip[aria-expanded="true"] { background: #2c2c31; }
.chip-references { min-width: 150px; }
.chip-thumb { flex: none; width: 44px; height: 44px; border-radius: 12px; object-fit: cover; background: #303035; box-shadow: inset 0 0 0 1px #ffffff12; }
.chip-thumb-plus { display: grid; place-items: center; color: #d6d5da; background: #1a1a1d; box-shadow: inset 0 0 0 1px #ffffff14; overflow: hidden; }
.chip-thumb-plus img { width: 100%; height: 100%; object-fit: cover; }
.chip-thumb-plus .icon { width: 20px; height: 20px; }
.chip-text { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.chip-label { display: block; overflow: hidden; color: #85848b; font-family: var(--mono); font-size: .7rem; font-weight: 400; letter-spacing: -.01em; white-space: nowrap; text-overflow: ellipsis; cursor: pointer; }
.chip-value, .chip .studio-select-trigger { color: #f4f3f5; font-size: 1.04rem; font-weight: 700; letter-spacing: -.02em; }
.chip-value { font-variant-numeric: tabular-nums; }
.chip .studio-select { position: static; }
.chip .studio-select-trigger { position: static; min-height: 0; padding: 0; }
.chip .studio-select-trigger::after { content: ''; position: absolute; inset: 0; border-radius: inherit; }
.chip .studio-select-chevron { display: none; }
.chip:has(.studio-select-trigger:focus-visible) { outline: 2px solid var(--focus); outline-offset: 2px; }
.chip .studio-select-trigger:focus-visible { outline: none; }

.prompt-box { display: flex; align-items: stretch; gap: 12px; margin-top: 9px; padding: 14px 12px 12px 18px; border-radius: 24px; background: var(--chip); }
.prompt-box:focus-within { background: #26262a; }
.prompt-main { position: relative; flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 12px; }
.prompt-corner { position: absolute; z-index: 3; top: -6px; right: -2px; display: flex; align-items: center; gap: 4px; }
.prompt-corner .tool-icon { color: #8f8e95; }
.prompt-corner .tool-icon:hover { color: #fff; }
#prompt { display: block; width: 100%; padding-right: 120px !important; min-height: 56px; max-height: 260px; resize: none; padding: 2px 0 0; border-radius: 0; background: transparent; color: #f2f1f4; font-size: 1.06rem; line-height: 1.5; outline: 0; field-sizing: content; }
#prompt::placeholder { color: #85848c; opacity: 1; }
.toolbar { position: relative; display: flex; align-items: center; flex-wrap: wrap; gap: 6px; margin-left: -6px; }
.tool-group { position: relative; display: flex; align-items: center; height: 42px; padding: 0 3px; border-radius: 13px; background: var(--pill); }
.tool-icon { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 10px; background: transparent; color: #d7d6db; }
.tool-icon:hover, .tool-icon[aria-expanded="true"] { background: #3a3a40; color: #fff; }
.tool-icon .icon { width: 19px; height: 19px; }
.tool-divider { width: 1px; height: 20px; margin: 0 2px; background: #ffffff1c; }
.tool-pill { position: relative; display: inline-flex; align-items: center; gap: 7px; height: 42px; padding: 0 12px; border-radius: 13px; background: var(--pill); color: #f1f0f3; font-size: .95rem; font-weight: 700; letter-spacing: -.015em; white-space: nowrap; }
.tool-pill:hover, .tool-pill:focus-within { background: #35353b; }
.tool-pill > .icon { width: 18px; height: 18px; color: #e8e7eb; }
.tool-square { justify-content: center; width: 42px; padding: 0; }
.tool-square[aria-pressed="true"] { background: #3b3b42; color: var(--lime); box-shadow: inset 0 0 0 1px #8f7cff66; }
.tool-square[aria-pressed="true"] .icon { color: var(--lime); }
.tool-model { padding-right: 9px; }
.tool-model .model-icon { color: var(--lime); stroke-width: 2.2; width: 20px; height: 20px; }
.tool-model .output-value { font-weight: 700; }
.tool-model .tool-chevron { width: 16px; height: 16px; color: #a9a8af; }
.tool-pill .studio-select { position: static; }
.tool-pill .studio-select-trigger { position: static; min-height: 0; padding: 0; font-size: .95rem; font-weight: 700; color: #f1f0f3; }
.tool-pill .studio-select-trigger::after { content: ''; position: absolute; inset: 0; border-radius: inherit; }
.tool-pill .studio-select-chevron { display: none; }
.tool-pill:has(.studio-select-trigger:focus-visible) { outline: 2px solid var(--focus); outline-offset: 2px; }
.tool-pill .studio-select-trigger:focus-visible { outline: none; }
.tool-stepper { gap: 2px; padding: 0 4px; }
.tool-stepper button { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 9px; background: transparent; color: #a9a8af; }
.tool-stepper button:not(:disabled):hover { background: #3a3a40; color: #fff; }
.tool-stepper button:disabled { opacity: .35; }
.tool-stepper .icon { width: 16px; height: 16px; }
.tool-stepper output { min-width: 34px; text-align: center; font-variant-numeric: tabular-nums; }
.prompt-count { padding: 0 4px; color: #6f6e75; font-family: var(--mono); font-size: .72rem; font-variant-numeric: tabular-nums; }

.generate-button { position: relative; isolation: isolate; overflow: hidden; flex: none; align-self: stretch; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; width: clamp(150px, 15vw, 196px); min-height: 104px; margin-bottom: 5px; border-radius: 20px; background: linear-gradient(115deg, #4227da 0%, #4b31e3 28%, #5a41ee 55%, #4227da 78%, #6450f5 100%); background-size: 260% 100%; background-position: 0% 50%; color: #ffffff; box-shadow: inset 0 1px 0 #ffffff8a, 0 5px 0 #2b1896, 0 14px 34px #7b66ff33; font-family: var(--display); font-stretch: 90%; font-size: 1.12rem; font-weight: 800; letter-spacing: .02em; text-transform: uppercase; animation: lumify-shift 7s ease-in-out infinite alternate; transition: transform .12s ease, box-shadow .12s ease, filter .15s ease; }
.generate-button::after { content: ''; position: absolute; inset: 0; z-index: -1; background: radial-gradient(120% 80% at 30% 0%, #ffffff33, transparent 60%); pointer-events: none; }
.generate-button:not(:disabled):hover { filter: brightness(1.05) saturate(1.05); }
.generate-button:not(:disabled):active { transform: translateY(4px); box-shadow: inset 0 1px 0 #ffffff8a, 0 1px 0 #2b1896; }
.generate-button:disabled { opacity: .75; }
.generate-button[aria-busy="true"] { animation-duration: 1.6s; }
.generate-meta { display: inline-flex; align-items: center; gap: 4px; font-family: Inter, system-ui, sans-serif; font-size: .95rem; font-weight: 700; letter-spacing: -.01em; text-transform: none; font-variant-numeric: tabular-nums; }
.generate-meta .icon { width: 14px; height: 14px; }
@keyframes lumify-shift { 0% { background-position: 0% 50%; box-shadow: inset 0 1px 0 #ffffff8a, 0 5px 0 #2b1896, 0 14px 34px #4227da55; } 100% { background-position: 100% 50%; box-shadow: inset 0 1px 0 #ffffff8a, 0 5px 0 #2b1896, 0 14px 34px #4227da66; } }

.generation-status { margin: 12px 6px 2px; }

.mention-menu { position: absolute; left: 0; bottom: calc(100% + 8px); z-index: 25; min-width: 240px; max-width: 320px; padding: 5px; border-radius: 13px; background: #2a2a2f; box-shadow: 0 16px 40px #000a, inset 0 0 0 1px #ffffff0d; }
.mention-menu button { display: flex; align-items: center; gap: 9px; width: 100%; min-height: 40px; padding: 5px 8px; border-radius: 9px; background: transparent; color: #e9e8ec; font-size: .875rem; font-weight: 600; text-align: left; }
.mention-menu button:is(:hover, :focus-visible) { background: #3b3b42; outline: none; }
.mention-menu img, .mention-menu .mention-icon { width: 28px; height: 28px; flex: none; border-radius: 7px; object-fit: cover; background: #1b1b1e; display: grid; place-items: center; }
.mention-menu .mention-icon .icon { width: 15px; height: 15px; }
.mention-menu small { display: block; color: #8f8e95; font-size: .75rem; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 220px; }
.mention-menu p { padding: 9px 10px; color: #a9a8af; font-size: .8125rem; line-height: 1.45; }

.reference-popover { position: absolute; z-index: 20; top: calc(100% + 10px); left: 11px; width: min(620px, calc(100% - 22px)); display: grid; gap: 9px; padding: 14px; border-radius: 22px; background: #232327; box-shadow: 0 24px 60px #000b, inset 0 0 0 1px #ffffff10; }
.reference-popover .reference-heading { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.reference-popover .popover-close { margin-left: auto; width: 32px; height: 32px; border-radius: 10px; }
.reference-popover .reference-picker, .reference-popover .reference-link-controls, .reference-popover .reference-item, .reference-popover .frame-picker { background: #2d2d32; }
.reference-popover .reference-modes { background: #1a1a1d; }

@media (max-width: 1100px) {
  .chip { min-width: 168px; }
  .mode-rail button { width: 78px; min-height: 68px; }
}

@media (max-width: 760px) {
  .composer-shell { flex-direction: column; align-items: stretch; }
  .mode-rail { flex-direction: row; align-self: center; border-radius: 20px; }
  .mode-rail button { flex-direction: row; width: auto; min-height: 44px; padding: 0 18px; border-radius: 14px; }
  .composer { border-radius: 24px; padding: 8px; }
  .chip { flex: 0 0 auto; min-width: 0; max-width: 220px; min-height: 56px; border-radius: 16px; }
  .chip-thumb { width: 38px; height: 38px; border-radius: 10px; }
  .prompt-box { flex-direction: column; padding: 12px; border-radius: 20px; }
  .generate-button { width: 100%; min-height: 62px; flex-direction: row; gap: 12px; }
  #prompt { padding-right: 44px !important; }
  .prompt-count { display: none; }
  .reference-popover { left: 8px; width: calc(100% - 16px); }
}

/* ===== Conta, login, feed e admin ===== */
.sidebar-settings { display: none; }
.sidebar-bottom { display: grid; gap: 8px; }
.buy-credits { display: flex; align-items: center; justify-content: center; gap: 7px; min-height: 40px; border-radius: 11px; background: linear-gradient(115deg, #4227da, #4227da); color: #ffffff; font-size: .85rem; font-weight: 750; }
.buy-credits .icon { width: 15px; height: 15px; }
.buy-credits:hover { filter: brightness(1.06); }
.user-card { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 54px; padding: 7px 9px; border-radius: 12px; background: #1d1d20; text-align: left; }
.user-card:hover { background: var(--raised); }
.user-card-text { min-width: 0; display: grid; gap: 1px; }
.user-card-text strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .875rem; font-weight: 650; }
.user-card-text > span { color: var(--muted); font-size: .75rem; }
.avatar { flex: none; display: grid; place-items: center; width: 36px; height: 36px; overflow: hidden; border-radius: 50%; background: linear-gradient(135deg, #4227da, #4227da); color: #ffffff; font-size: .8rem; font-weight: 800; letter-spacing: .02em; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar-large { width: 84px; height: 84px; font-size: 1.6rem; }
#admin-link[data-badge]:not([data-badge=""])::after { content: attr(data-badge); margin-left: auto; min-width: 20px; padding: 1px 6px; border-radius: 10px; background: var(--brand); color: #ffffff; font-size: .72rem; font-weight: 800; text-align: center; }

.topbar { justify-content: space-between; }
.credits-pill { display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 0 14px; border-radius: 20px; background: var(--raised); color: #f1f0f3; font-size: .875rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.credits-pill .icon { width: 15px; height: 15px; color: var(--green); }
.credits-pill-label { color: var(--muted); font-weight: 550; }
.credits-pill:hover { background: var(--hover); }

/* Login */
.auth-screen { position: fixed; inset: 0; z-index: 50; display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(360px, .85fr); background: #0e0e10; }
body[data-auth="loading"] .sidebar, body[data-auth="loading"] .app-main, body[data-auth="out"] .sidebar, body[data-auth="out"] .app-main { visibility: hidden; }
.auth-visual { position: relative; overflow: hidden; }
.auth-mosaic { position: absolute; inset: -4%; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; transform: rotate(-4deg) scale(1.06); opacity: .9; }
.auth-mosaic img { width: 100%; height: 100%; object-fit: cover; border-radius: 22px; }
.auth-visual::after { content: ''; position: absolute; inset: 0; background: linear-gradient(90deg, #0e0e1000 30%, #0e0e10 100%), linear-gradient(0deg, #0e0e10e6 0%, #0e0e1000 55%); }
.auth-visual-copy { position: absolute; z-index: 1; left: clamp(28px, 5vw, 64px); bottom: clamp(28px, 7vh, 72px); display: grid; gap: 16px; }
.auth-visual-copy p { font-family: var(--display); font-stretch: 82%; font-size: clamp(2rem, 3.6vw, 3.4rem); font-weight: 750; line-height: 1; letter-spacing: -.03em; background: linear-gradient(180deg, #fff, #b7b6bc); -webkit-background-clip: text; background-clip: text; color: transparent; }
.auth-panel { display: flex; flex-direction: column; justify-content: center; gap: 14px; width: min(420px, 100%); margin: 0 auto; padding: 40px 28px; }
.auth-brand { margin-bottom: 18px; padding: 0; }
.auth-panel h1 { font-size: 1.9rem; font-weight: 720; letter-spacing: -.04em; }
.auth-subtitle { color: var(--muted); line-height: 1.5; margin-top: -6px; }
.auth-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; border-radius: 12px; background: #19191c; }
.auth-tabs button { min-height: 38px; border-radius: 9px; background: none; color: var(--muted); font-size: .875rem; font-weight: 650; }
.auth-tabs [aria-selected="true"] { background: #2b2b30; color: #fff; }
.google-button { display: flex; align-items: center; justify-content: center; gap: 10px; min-height: 48px; border-radius: 12px; background: #fff; color: #1f1f1f; font-weight: 650; }
.google-button .icon { width: 19px; height: 19px; }
.google-button:hover { background: #f1f1f1; }
.auth-divider { display: flex; align-items: center; gap: 12px; color: #77767d; font-size: .8rem; }
.auth-divider::before, .auth-divider::after { content: ''; flex: 1; height: 1px; background: #ffffff14; }
.auth-form { display: grid; gap: 12px; }
.field { display: grid; gap: 6px; }
.field > span { color: #cfcdd4; font-size: .82rem; font-weight: 600; }
.field input, .field textarea, .package-row input, .credit-adjust input, .field-inline input[type=number] { width: 100%; min-height: 44px; padding: 10px 12px; border-radius: 10px; background: #19191c; color: #f3f2f5; box-shadow: inset 0 0 0 1px #ffffff0f; font-size: .95rem; }
.field textarea { resize: vertical; line-height: 1.45; }
.field input:focus, .field textarea:focus, .package-row input:focus, .credit-adjust input:focus { outline: 2px solid #7b66ff; outline-offset: 0; }
.auth-error { padding: 10px 12px; border-radius: 10px; background: #3a1d1f; color: #ffc4c0; font-size: .875rem; line-height: 1.4; }
.cta-button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 46px; padding: 0 18px; border-radius: 12px; background: linear-gradient(115deg, #4227da 0%, #5a41ee 55%, #4227da 100%); color: #ffffff; font-weight: 760; font-size: .95rem; }
.cta-button:not(:disabled):hover { filter: brightness(1.06); }
.small-button { min-height: 34px !important; padding: 0 11px !important; font-size: .8rem !important; border-radius: 9px !important; }

/* Conta */
.account-dialog { width: min(640px, calc(100% - 28px)); }
.account-tabs { display: inline-flex; gap: 4px; padding: 4px; margin-bottom: 16px; border-radius: 11px; background: #161618; }
.account-tabs button { min-height: 34px; padding: 0 14px; border-radius: 8px; background: none; color: var(--muted); font-size: .875rem; font-weight: 650; }
.account-tabs [aria-selected="true"] { background: #303035; color: #fff; }
.profile-head { display: flex; align-items: center; gap: 16px; margin-bottom: 16px; }
.profile-head > div { display: grid; gap: 3px; }
.profile-head strong { font-size: 1.1rem; }
.profile-head span { color: var(--muted); font-size: .875rem; }
.profile-hint { font-size: .78rem !important; color: #7d7c83 !important; }
.avatar-upload { position: relative; cursor: pointer; border-radius: 50%; }
.avatar-upload:hover .avatar { filter: brightness(.8); }
.avatar-upload-badge { position: absolute; right: -2px; bottom: -2px; display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: #f3f2f5; color: #141416; box-shadow: 0 0 0 3px #202023; }
.avatar-upload-badge .icon { width: 16px; height: 16px; }
.admin-form { display: grid; gap: 10px; margin-top: 12px; }
.admin-form > button { justify-self: start; }
.form-status { min-height: 1.2em; font-size: .85rem; color: var(--muted); }
.form-status[data-state="success"], .admin-note[data-state="success"] { color: #b3a8ff; }
.form-status[data-state="error"], .admin-note[data-state="error"] { color: #ffbcb8; }
.balance-card { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 18px; border-radius: 16px; background: linear-gradient(115deg, #1f1650, #2b1f6e); }
.balance-card span { color: #cfc8ff; font-size: .875rem; }
.balance-card strong { display: inline-flex; align-items: center; gap: 6px; font-size: 1.3rem; font-variant-numeric: tabular-nums; }
.balance-card .icon { width: 18px; height: 18px; color: var(--green); }
.pricing-note { margin: 10px 2px 14px; color: var(--muted); font-size: .8125rem; line-height: 1.45; }
.packages { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px; }
.package { position: relative; display: grid; gap: 6px; padding: 16px; border-radius: 16px; background: #29292e; box-shadow: inset 0 0 0 1px #ffffff0d; }
.package[data-highlight="true"] { box-shadow: inset 0 0 0 1.5px #7b66ff; }
.package[data-highlight="true"]::before { content: 'Mais escolhido'; position: absolute; top: -9px; left: 14px; padding: 2px 8px; border-radius: 8px; background: var(--brand); color: #ffffff; font-size: .7rem; font-weight: 800; }
.package-name { color: var(--muted); font-size: .8rem; font-weight: 650; text-transform: uppercase; letter-spacing: .05em; }
.package-credits { font-size: 1.25rem; letter-spacing: -.02em; }
.package-price { color: #e9e8ec; font-weight: 600; }
.package-buy { margin-top: 6px; min-height: 40px; }
.payment-box { margin-top: 12px; padding: 14px 16px; border-radius: 14px; background: #1e1a3d; color: #dcd6ff; line-height: 1.5; white-space: pre-wrap; }
.payment-box p { margin-top: 4px; }
.history-title { margin: 18px 0 8px; font-size: .9rem; font-weight: 650; }
.history { display: grid; gap: 4px; max-height: 220px; overflow-y: auto; margin: 0; padding: 0; list-style: none; }
.history li { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 9px 11px; border-radius: 10px; background: #29292e; font-size: .85rem; }
.history li > span { display: grid; gap: 2px; }
.history small { color: #85848b; font-size: .75rem; }
.history b { font-variant-numeric: tabular-nums; white-space: nowrap; color: #ffbcb8; }
.history li[data-positive="true"] b { color: #b3a8ff; }
.history li[data-pending="true"] b { color: #f3d38a; font-weight: 600; }
.history-empty { justify-content: center !important; color: var(--muted); }

/* Feed atrás do compositor */
.feed { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 250px), 1fr)); grid-auto-flow: dense; align-items: start; gap: 10px; padding: 8px 0 24px; }
.feed-card { position: relative; display: block; width: 100%; overflow: hidden; padding: 0; border-radius: 14px; background: #1c1c1f; color: inherit; text-align: left; aspect-ratio: var(--ratio, 16 / 9); }
.feed-open { position: absolute; inset: 0; display: block; width: 100%; height: 100%; padding: 0; border-radius: inherit; background: none; overflow: hidden; }
.feed-open > :is(img, video) { display: block; width: 100%; height: 100%; object-fit: cover; transition: transform .35s ease; }
.feed-card:hover .feed-open > :is(img, video) { transform: scale(1.03); }
.feed-card[data-status="sending"], .feed-card[data-status="queued"], .feed-card[data-status="processing"] { background: linear-gradient(110deg, #1c1c1f 30%, #26262b 50%, #1c1c1f 70%); background-size: 220% 100%; animation: feed-shimmer 1.8s linear infinite; }
@keyframes feed-shimmer { to { background-position: -220% 0; } }
.feed-badge { position: absolute; top: 12px; left: 12px; display: inline-flex; align-items: center; gap: 7px; padding: 7px 12px; border-radius: 20px; background: #111113d9; color: var(--green); font-size: .85rem; font-weight: 700; }
.feed-badge-error { color: #ffbcb8; }
.spinner { width: 13px; height: 13px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.feed-caption { position: absolute; left: 12px; right: 12px; bottom: 12px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; color: #a9a8af; font-size: .8rem; line-height: 1.4; }
.feed-card[data-status="failed"] { box-shadow: inset 0 0 0 1px #ffbcb833; }
.feed-card[data-status="failed"] .feed-caption { color: #f0c9c6; -webkit-line-clamp: 4; }
.feed-dismiss { position: absolute; top: 9px; right: 9px; display: grid; place-items: center; width: 30px; height: 30px; border-radius: 9px; background: #111113d9; color: #d7d6db; }
.feed-dismiss .icon { width: 15px; height: 15px; }
.feed-tag { position: absolute; left: 10px; bottom: 10px; padding: 4px 8px; border-radius: 8px; background: #111113c9; color: #ecebef; font-size: .72rem; font-weight: 650; opacity: 0; transition: opacity .2s; }
.feed-card:hover .feed-tag, .feed-open:focus-visible .feed-tag { opacity: 1; }

body[data-feed="on"][data-view="studio"] .hero { display: none; }
body[data-feed="on"][data-view="studio"] .workspace { padding-bottom: 300px; }
body[data-feed="on"][data-view="studio"] .composer-shell { position: fixed; z-index: 15; left: calc(var(--sidebar-width) + 24px); right: 24px; bottom: 16px; margin: 0 auto; max-width: 1320px; }
body[data-feed="on"][data-view="studio"] .composer { box-shadow: inset 0 0 0 1px #ffffff12, 0 -10px 60px #0e0e10, 0 30px 80px #000c; background: #1b1b1ef2; backdrop-filter: blur(14px); }
body[data-feed="on"][data-view="studio"] .mode-rail { background: #1b1b1ef2; backdrop-filter: blur(14px); }
body[data-feed="on"][data-view="studio"] .feed { padding-top: 4px; }
body[data-feed="on"][data-view="studio"] .reference-popover { top: auto; bottom: calc(100% + 10px); }
body[data-feed="on"][data-view="studio"] .app-main::after { content: ''; position: fixed; left: var(--sidebar-width); right: 0; bottom: 0; height: 220px; z-index: 14; pointer-events: none; background: linear-gradient(0deg, #111113 25%, #11111300); }
body[data-feed="on"][data-view="studio"] .generation-status { position: absolute; left: 0; bottom: calc(100% + 8px); margin: 0; padding: 8px 12px; border-radius: 10px; background: #26262bf2; }
body[data-feed="on"][data-view="studio"] .generation-status[hidden] { display: none; }

/* Administração */
.admin { padding: 20px 0 40px; }
.admin-header h2 { font-size: 1.6rem; letter-spacing: -.04em; font-weight: 700; }
.admin-header p { color: var(--muted); margin-top: 6px; }
.admin-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 360px), 1fr)); gap: 14px; margin-top: 18px; }
.admin-card { min-width: 0; padding: 18px; border-radius: 18px; background: #1b1b1e; box-shadow: inset 0 0 0 1px #ffffff09; }
.admin-wide { grid-column: 1 / -1; }
.admin-card h3 { margin: 0 0 12px; font-size: 1rem; font-weight: 680; }
.admin-note { color: var(--muted); font-size: .875rem; line-height: 1.5; }
.admin-list { display: grid; gap: 6px; max-height: 420px; overflow-y: auto; }
.admin-row { display: flex; align-items: center; flex-wrap: wrap; gap: 10px 14px; padding: 10px 12px; border-radius: 12px; background: #242428; }
.admin-row-main { flex: 1 1 220px; min-width: 0; display: grid; gap: 2px; }
.admin-row-main strong { font-size: .9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.admin-row-main small { color: #8f8e95; font-size: .78rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.admin-row-meta { color: #d9d8dd; font-size: .85rem; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.admin-row-actions { display: flex; align-items: center; gap: 6px; }
.credit-adjust input { width: 130px; min-height: 34px; padding: 6px 10px; font-size: .85rem; }
.admin-row-error { flex-basis: 100%; color: #ffbcb8; font-size: .8rem; }
.admin-form fieldset { display: flex; flex-wrap: wrap; gap: 8px 12px; margin: 0; padding: 0; border: 0; }
.admin-form legend { margin-bottom: 6px; color: #cfcdd4; font-size: .82rem; font-weight: 600; }
.field-inline { display: inline-flex; align-items: center; gap: 6px; color: #cfcdd4; font-size: .85rem; }
.field-inline input[type=number] { width: 84px; min-height: 38px; padding: 6px 9px; }
.package-rows { display: grid; gap: 6px; }
.package-row { display: grid; grid-template-columns: 1.2fr .8fr 1fr auto; gap: 6px; align-items: center; }
.package-row input { min-height: 38px; padding: 6px 9px; font-size: .875rem; }

@media (max-width: 900px) {
  .auth-screen { grid-template-columns: 1fr; }
  .auth-visual { display: none; }
}

@media (max-width: 760px) {
  body[data-feed="on"][data-view="studio"] .composer-shell { left: 8px; right: 8px; bottom: 8px; }
  body[data-feed="on"][data-view="studio"] .mode-rail { display: none; }
  body[data-feed="on"][data-view="studio"] .chip-row { display: none; }
  body[data-feed="on"][data-view="studio"] .workspace { padding-bottom: 280px; }
  body[data-feed="on"][data-view="studio"] .app-main::after { left: 0; }
  .feed { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
  .package-row { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 680px) {
  .sidebar-bottom { margin-top: 8px; }
  .credits-pill-label { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition-duration: 0s !important; }
  .generate-button, .feed-card, .spinner { animation-duration: 0s !important; }
}

.provider-switch { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 12px; }
.provider-option { display: flex; align-items: center; gap: 10px; padding: 12px; border-radius: 12px; background: #242428; cursor: pointer; box-shadow: inset 0 0 0 1px #ffffff0a; }
.provider-option:has(input:checked) { box-shadow: inset 0 0 0 1.5px #7b66ff; background: #1e1a3d; }
.provider-option input { accent-color: #4227da; }
.provider-option span { display: grid; gap: 2px; }
.provider-option small { color: #8f8e95; font-size: .75rem; }
.provider-key-form { padding-top: 10px; border-top: 1px solid #ffffff0d; }

.brand-logo { flex: none; display: block; width: 36px; height: 36px; border-radius: 10px; object-fit: cover; }
.auth-visual-copy .brand-logo { width: 52px; height: 52px; border-radius: 14px; box-shadow: 0 10px 30px #4227da55; }
@media (max-width: 680px) { .brand-logo { width: 33px; height: 33px; } }

/* Cobrança desligada: esconde saldo e compra */
body[data-billing="off"] :is(.credits-pill, .buy-credits, [data-account-tab="credits"], .user-card-text > span) { display: none !important; }
body[data-billing="off"] .account-tabs { display: none; }
.billing-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.billing-row h3 { margin-bottom: 4px; }
.switch { position: relative; flex: none; display: inline-block; width: 56px; height: 32px; cursor: pointer; }
.switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.switch-track { position: absolute; inset: 0; border-radius: 20px; background: #3a3a40; transition: background .2s; }
.switch-track::after { content: ''; position: absolute; top: 4px; left: 4px; width: 24px; height: 24px; border-radius: 50%; background: #fff; transition: transform .2s; }
.switch input:checked + .switch-track { background: #4227da; }
.switch input:checked + .switch-track::after { transform: translateX(24px); }
.switch input:focus-visible + .switch-track { outline: 2px solid #7b66ff; outline-offset: 2px; }
.mini-switch { display: inline-flex; align-items: center; gap: 7px; color: #cfcdd4; font-size: .78rem; font-weight: 600; white-space: nowrap; cursor: pointer; position: relative; }
.mini-switch input { position: absolute; width: 34px; height: 20px; opacity: 0; margin: 0; cursor: pointer; }
.mini-switch .switch-track { position: relative; display: inline-block; width: 34px; height: 20px; border-radius: 12px; background: #3a3a40; transition: background .2s; }
.mini-switch .switch-track::after { content: ''; position: absolute; top: 3px; left: 3px; width: 14px; height: 14px; border-radius: 50%; background: #fff; transition: transform .2s; }
.mini-switch input:checked + .switch-track { background: #4227da; }
.mini-switch input:checked + .switch-track::after { transform: translateX(14px); }
.mini-switch input:disabled + .switch-track { opacity: .5; }
.mini-switch input:focus-visible + .switch-track { outline: 2px solid #7b66ff; outline-offset: 2px; }

/* Melhorar prompt e perguntas guiadas */
.prompt-corner { gap: 6px; }
.corner-button { display: inline-flex; align-items: center; gap: 5px; height: 30px; padding: 0 10px; border-radius: 9px; background: #2f2f35; color: #e6e5ea; font-size: .78rem; font-weight: 650; white-space: nowrap; }
.corner-button .icon { width: 15px; height: 15px; }
.corner-button:hover { background: #3a3a41; color: #fff; }
.corner-primary { background: #4227da; color: #fff; }
.corner-primary:hover { background: #5236ee; }
.corner-button[aria-busy="true"] .icon { animation: spin 1s linear infinite; }
#guide-btn[data-count]:not([data-count=""])::after { content: attr(data-count); min-width: 17px; padding: 0 5px; border-radius: 9px; background: #4227da; color: #fff; font-size: .68rem; line-height: 17px; text-align: center; }
#guide-btn[aria-expanded="true"] { background: #3a3a41; color: #fff; }
#prompt { padding-right: 330px !important; }
.prompt-main[data-busy="true"] #prompt { opacity: .55; }
.guide-panel { position: absolute; z-index: 22; top: calc(100% + 10px); left: 11px; right: 11px; max-height: min(560px, 70vh); display: flex; flex-direction: column; border-radius: 22px; background: #232327; box-shadow: 0 24px 60px #000c, inset 0 0 0 1px #ffffff10; overflow: hidden; }
body[data-feed="on"][data-view="studio"] .guide-panel { top: auto; bottom: calc(100% + 10px); }
.guide-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 16px 18px 10px; }
.guide-header h2 { font-size: 1.05rem; font-weight: 700; letter-spacing: -.02em; }
.guide-header p { margin-top: 3px; color: var(--muted); font-size: .82rem; }
.guide-header .icon-button { width: 32px; height: 32px; border-radius: 10px; }
.guide-list { flex: 1; overflow-y: auto; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 330px), 1fr)); gap: 10px; padding: 4px 18px 14px; }
.guide-question { display: grid; gap: 8px; min-width: 0; margin: 0; padding: 12px; border: 0; border-radius: 14px; background: #2a2a2f; }
.guide-question legend { float: left; width: 100%; padding: 0; color: #f1f0f3; font-size: .86rem; font-weight: 650; }
.guide-options { display: flex; flex-wrap: wrap; gap: 6px; }
.guide-chip { min-height: 30px; padding: 0 11px; border-radius: 15px; background: #34343a; color: #d7d6db; font-size: .78rem; font-weight: 600; }
.guide-chip:hover { background: #3e3e45; color: #fff; }
.guide-chip[aria-pressed="true"] { background: #4227da; color: #fff; }
.guide-text { width: 100%; min-height: 36px; padding: 7px 10px; border-radius: 9px; background: #1c1c1f; color: #f1f0f3; font-size: .82rem; box-shadow: inset 0 0 0 1px #ffffff0d; }
.guide-text::placeholder { color: #7c7b82; }
.guide-text:focus { outline: 2px solid #7b66ff; outline-offset: 0; }
.guide-footer { display: flex; align-items: center; gap: 8px; padding: 12px 18px; border-top: 1px solid #ffffff0d; background: #202024; }
.guide-count { margin-right: auto; color: var(--muted); font-size: .8rem; }
.guide-footer .cta-button { min-height: 40px; font-size: .88rem; background: #4227da; color: #fff; }
.guide-footer .cta-button .icon { width: 16px; height: 16px; }
@media (max-width: 760px) {
  #prompt { padding-right: 4px !important; padding-top: 40px !important; }
  .prompt-corner { left: 0; right: auto; top: -4px; }
  .corner-button { padding: 0 8px; }
  .guide-panel { left: 8px; right: 8px; }
  .guide-footer { flex-wrap: wrap; }
}

/* Menções coloridas no prompt */
.prompt-highlight { position: absolute; z-index: 0; overflow: hidden; pointer-events: none; color: #f2f1f4; white-space: pre-wrap; overflow-wrap: break-word; word-break: break-word; }
.prompt-highlight > div { will-change: transform; }
#prompt.has-highlight { position: relative; z-index: 1; color: transparent; caret-color: #f2f1f4; }
#prompt.has-highlight::selection { color: transparent; background: #4227da66; }
.prompt-mention { color: #b7a9ff; background: #4227da59; border-radius: 5px; box-shadow: 0 0 0 2px #4227da59; }
.prompt-main[data-busy="true"] .prompt-highlight { opacity: .55; }

/* Biblioteca de referências */
.library-strip { margin-top: 10px; padding-top: 10px; border-top: 1px solid #ffffff0d; }
.library-strip-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 7px; color: var(--muted); font-size: .78rem; font-weight: 650; }
.library-strip-head a { color: #b7a9ff; font-weight: 600; }
.library-strip-list { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; }
.library-chip { position: relative; flex: 0 0 auto; width: 52px; height: 52px; border-radius: 10px; overflow: hidden; background: #2f2f35; }
.library-chip img, .library-chip video { width: 100%; height: 100%; object-fit: cover; display: block; }
.library-chip .library-icon { position: absolute; right: 3px; bottom: 3px; display: grid; place-items: center; width: 18px; height: 18px; border-radius: 6px; background: #000a; }
.library-chip[data-type="audio"] .library-icon:first-child { inset: 0; width: auto; height: auto; background: none; }
.library-chip .icon { width: 12px; height: 12px; }
.library-chip[data-type="audio"] .library-icon:first-child .icon { width: 20px; height: 20px; }
.library-chip:hover { outline: 2px solid #7b66ff; }
.library-card { display: flex; flex-direction: column; cursor: default; }
.library-card .gallery-card-thumb video, .library-card .gallery-card-thumb img { width: 100%; height: 100%; object-fit: cover; }
.library-card[data-kind="audio"] .gallery-card-thumb { display: grid; place-items: center; background: linear-gradient(135deg, #2a2440, #1d1d22); }
.library-card .library-icon .icon { width: 34px; height: 34px; color: #b7a9ff; }
.library-card audio { position: absolute; left: 10px; right: 10px; bottom: 10px; width: calc(100% - 20px); height: 34px; }
.library-actions { display: flex; gap: 6px; padding: 0 12px 12px; }
.library-use { flex: 1; min-height: 34px; border-radius: 10px; background: #4227da; color: #fff; font-size: .8rem; font-weight: 650; }
.library-use:hover { background: #5236ee; }
.library-remove { width: 34px; height: 34px; border-radius: 10px; }

/* Ações sobre a imagem (feed e visualizador) */
.card-actions { position: absolute; z-index: 2; top: 8px; left: 8px; right: 8px; display: flex; justify-content: flex-end; gap: 6px; opacity: 0; transform: translateY(-4px); transition: opacity .18s, transform .18s; pointer-events: none; }
.feed-card:hover .card-actions, .feed-card:focus-within .card-actions { opacity: 1; transform: none; pointer-events: auto; }
.card-action, .media-action { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 10px; border-radius: 10px; background: #121214cc; color: #f2f1f4; font-size: .78rem; font-weight: 650; backdrop-filter: blur(8px); box-shadow: inset 0 0 0 1px #ffffff14; text-decoration: none; white-space: nowrap; }
.card-action .icon, .media-action .icon { width: 15px; height: 15px; }
.card-action:hover, .media-action:hover { background: #26262bdd; color: #fff; }
.card-action-primary, .media-action-primary { background: #4227da; box-shadow: none; }
.card-action-primary:hover, .media-action-primary:hover { background: #5236ee; }
.card-action:not(.card-action-primary) { width: 32px; padding: 0; justify-content: center; }
.media-frame { position: relative; }
.media-actions { position: absolute; z-index: 2; top: 10px; left: 10px; right: 10px; display: flex; justify-content: flex-end; gap: 6px; }
.media-actions [hidden] { display: none; }
@media (hover: none) { .card-actions { opacity: 1; transform: none; pointer-events: auto; } }

/* Proporção e logos dos modelos */
.aspect-icon { display: inline-grid; place-items: center; width: 18px; height: 18px; flex: none; color: #d7d6db; }
.aspect-svg, .studio-select-ratio { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.6; flex: none; }
.studio-select-option-label { display: inline-flex; align-items: center; gap: 10px; min-width: 0; }
.studio-select-value { display: inline-flex; align-items: center; gap: 8px; }
.studio-select-logo { width: 18px; height: 18px; flex: none; border-radius: 4px; object-fit: contain; }
.tool-model[data-has-logo] .model-icon { display: none; }

/* Tradução do prompt */
.translate-wrap { position: relative; display: inline-flex; }
.translate-menu { position: absolute; z-index: 30; right: 0; bottom: calc(100% + 8px); display: grid; gap: 4px; width: 230px; padding: 6px; border-radius: 14px; background: #26262b; box-shadow: 0 18px 40px #000b, inset 0 0 0 1px #ffffff12; }
.translate-menu[hidden] { display: none; }
.translate-menu button { display: grid; gap: 2px; padding: 9px 10px; border-radius: 9px; text-align: left; color: #f2f1f4; background: none; }
.translate-menu button:hover, .translate-menu button:focus-visible { background: #34343a; outline: none; }
.translate-menu strong { font-size: .84rem; }
.translate-menu small { color: var(--muted); font-size: .74rem; }
#prompt { padding-right: 420px !important; }
@media (max-width: 760px) {
  #prompt { padding-right: 4px !important; }
  .translate-menu { left: 0; right: auto; bottom: auto; top: calc(100% + 8px); }
}


/* ===== Ajustes 05/12: configurações, compartilhar, referências, modo mini e painel lateral ===== */
.prompt-field { position: relative; }
.feed-placeholder, .feed-details { display: none; }

/* Modelo e configurações sobre a criação */
.model-badge { display: inline-flex; align-items: center; gap: 6px; min-width: 0; font-weight: 650; }
.model-badge img { width: 16px; height: 16px; flex: none; border-radius: 4px; object-fit: contain; }
.model-badge span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.model-badge-small img { width: 14px; height: 14px; }
.model-badge-chip { align-self: flex-start; max-width: 100%; padding: 5px 9px; border-radius: 8px; background: #26262b; box-shadow: inset 0 0 0 1px #ffffff12; font-size: .78rem; }
.card-info { position: absolute; left: 8px; right: 8px; bottom: 8px; display: flex; flex-direction: column; align-items: flex-start; gap: 5px; padding: 8px 9px; border-radius: 11px; background: #111113d9; backdrop-filter: blur(8px); color: #f2f1f4; font-size: .78rem; opacity: 0; transform: translateY(4px); transition: opacity .18s, transform .18s; pointer-events: none; }
.feed-card:hover .card-info, .feed-card:focus-within .card-info { opacity: 1; transform: none; }
.card-settings, .feed-pills { display: flex; flex-wrap: wrap; gap: 4px; }
.card-settings span, .feed-pills span { padding: 2px 7px; border-radius: 6px; background: #ffffff14; color: #dcdbe0; font-size: .7rem; font-weight: 600; font-variant-numeric: tabular-nums; }
@media (hover: none) and (min-width: 761px) { .card-info { opacity: 1; transform: none; } }
.composer:has(.ref-tray[data-empty="false"]) .chip-row .chip-references { display: none; }
@media (max-width: 999px) { #layout-btn { display: none; } }
@media (max-width: 760px) {
  .feed-card .card-action-primary { width: 32px; padding: 0; justify-content: center; }
  .feed-card .card-action-primary .action-text { display: none; }
  .feed-card .card-actions { gap: 4px; }
}
.gallery-card-details { display: flex; align-items: center; gap: 6px; min-width: 0; color: var(--muted); font-size: .75rem; }
.gallery-card-details .model-badge { color: #d6d4dc; font-weight: 600; }
.gallery-card-body { flex-direction: column; align-items: flex-start; }

.media-settings { margin-top: 14px; padding: 12px; border-radius: 12px; background: #18181b; }
.media-settings h3 { margin: 0 0 8px; color: #d7d5db; font-size: .82rem; font-weight: 650; }
.media-settings dl { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px; margin: 0; }
.media-settings dl > div { padding: 7px 9px; border-radius: 9px; background: #232327; min-width: 0; }
.media-settings dt { color: var(--muted); font-size: .7rem; font-family: var(--mono); }
.media-settings dd { margin: 2px 0 0; color: #f2f1f4; font-size: .85rem; font-weight: 650; overflow-wrap: anywhere; }
.media-dialog { width: min(820px, calc(100% - 28px)); }

/* Compartilhar */
.share-dialog { width: min(520px, calc(100% - 28px)); }
.share-note { color: var(--muted); font-size: .85rem; line-height: 1.45; }
.share-link { display: flex; gap: 8px; margin-top: 12px; }
.share-link input { flex: 1; min-width: 0; min-height: 42px; padding: 0 12px; border-radius: 9px; background: #131315; color: #f2f1f4; font-size: .85rem; }
.share-link .primary-button { background: var(--brand); color: #fff; }
.share-link .primary-button:not(:disabled):hover { background: #5236ee; }
.share-targets { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.share-targets .secondary-button { min-height: 36px; font-size: .8rem; }
.share-dialog .dialog-actions .text-button { color: #ffbcb8; }

/* Bandeja de referências */
.ref-tray { display: none; margin-top: 9px; padding: 8px 10px; border-radius: 18px; background: var(--chip); }
.ref-tray[data-empty="false"] { display: block; }
.ref-tray-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.ref-tray-title { color: #d7d5db; font-size: .8rem; font-weight: 650; }
.ref-tray-count { color: var(--muted); font-family: var(--mono); font-size: .7rem; }
.ref-tray-clear { margin-left: auto; display: inline-flex; align-items: center; gap: 5px; min-height: 28px; padding: 0 9px; border-radius: 8px; background: #2d2d32; color: #ffcdc9; font-size: .75rem; font-weight: 650; }
.ref-tray-clear:hover { background: #3a2a2c; }
.ref-tray-clear .icon { width: 14px; height: 14px; }
.ref-tray-body { display: flex; align-items: center; gap: 6px; overflow-x: auto; scrollbar-width: thin; }
.ref-thumbs { display: flex; gap: 6px; margin: 0; padding: 0; list-style: none; }
.ref-thumb { position: relative; flex: none; width: 58px; height: 58px; border-radius: 11px; overflow: hidden; background: #2f2f35; cursor: pointer; box-shadow: inset 0 0 0 1px #ffffff14; }
.ref-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ref-thumb-icon { display: grid; place-items: center; width: 100%; height: 100%; color: #b7a9ff; }
.ref-thumb-tag { position: absolute; left: 3px; bottom: 3px; max-width: calc(100% - 6px); padding: 1px 4px; border-radius: 5px; background: #000b; color: #fff; font-size: .6rem; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ref-thumb-remove { position: absolute; top: 3px; right: 3px; display: grid; place-items: center; width: 20px; height: 20px; padding: 0; border-radius: 6px; background: #000c; color: #fff; opacity: 0; transition: opacity .15s; }
.ref-thumb:hover .ref-thumb-remove, .ref-thumb-remove:focus-visible { opacity: 1; }
.ref-thumb-remove .icon { width: 12px; height: 12px; }
@media (hover: none) { .ref-thumb-remove { opacity: 1; } }
.ref-tray-add { flex: none; display: inline-flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; width: 74px; height: 58px; border-radius: 11px; background: #2c2c31; color: #d7d6db; font-size: .66rem; font-weight: 650; box-shadow: inset 0 0 0 1px #ffffff10; }
.ref-tray-add:hover { background: #36363c; color: #fff; }
.ref-tray-add .icon { width: 18px; height: 18px; }
.reference-clear { min-height: 32px; color: #ffcdc9; font-size: .8rem; }
.reference-clear .icon { width: 15px; height: 15px; }
.reference-generated { display: flex; align-items: center; gap: 10px; width: 100%; margin-top: 7px; padding: 9px 10px; border-radius: 10px; background: #2d2d32; color: #e9e8ec; text-align: left; }
.reference-generated:hover { background: #36363c; }
.reference-generated > .icon:first-child { color: #b7a9ff; }
.reference-generated span { flex: 1; display: grid; gap: 1px; }
.reference-generated strong { font-size: .85rem; }
.reference-generated small { color: var(--muted); font-size: .75rem; }
.reference-generated > .icon:last-child { width: 15px; height: 15px; color: var(--muted); }

/* Escolher criações como referência */
.picker-dialog { width: min(860px, calc(100% - 28px)); }
.picker-grid { columns: 4 160px; column-gap: 8px; max-height: min(58vh, 560px); overflow-y: auto; margin-top: 12px; padding-right: 4px; }
.picker-item { position: relative; display: block; width: 100%; margin: 0 0 8px; padding: 0; break-inside: avoid; border-radius: 11px; overflow: hidden; background: #101012; aspect-ratio: var(--ratio, 1); box-shadow: inset 0 0 0 1px #ffffff12; }
.picker-item > :is(img, video) { display: block; width: 100%; height: 100%; object-fit: cover; }
.picker-item[aria-pressed="true"] { box-shadow: 0 0 0 3px var(--brand); }
.picker-check { position: absolute; top: 7px; right: 7px; display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: #000a; box-shadow: inset 0 0 0 2px #ffffffaa; color: transparent; }
.picker-item[aria-pressed="true"] .picker-check { background: var(--brand); box-shadow: none; color: #fff; }
.picker-check .icon { width: 15px; height: 15px; stroke-width: 2.4; }
.picker-label { position: absolute; left: 6px; right: 6px; bottom: 6px; padding: 3px 6px; border-radius: 6px; background: #000a; color: #eee; font-size: .7rem; text-align: left; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.picker-dialog .primary-button { background: var(--brand); color: #fff; }
.picker-dialog .primary-button:not(:disabled):hover { background: #5236ee; }

/* Meus projetos: miniatura recortada ou completa */
.thumb-toggle { display: flex; gap: 2px; padding: 3px; border-radius: 9px; background: var(--surface); }
.thumb-toggle button { display: inline-flex; align-items: center; gap: 5px; min-height: 30px; padding: 0 9px; border-radius: 6px; background: transparent; color: var(--muted); font-size: .8125rem; font-weight: 580; }
.thumb-toggle button .icon { width: 15px; height: 15px; }
.thumb-toggle button:hover { color: var(--accent); }
.thumb-toggle button[aria-pressed="true"] { background: var(--hover); color: var(--accent); }
.gallery-grid[data-thumbs="full"] { display: block; columns: 4 230px; column-gap: 11px; }
.gallery-grid[data-thumbs="full"] .gallery-card { width: 100%; margin-bottom: 11px; break-inside: avoid; }
.gallery-grid[data-thumbs="full"] .gallery-card-thumb { aspect-ratio: auto; min-height: 80px; background: #101012; }
.gallery-grid[data-thumbs="full"] .gallery-card-thumb > :is(img, video) { height: auto; object-fit: contain; }
.gallery-grid[data-thumbs="full"] .gallery-card:hover .gallery-card-thumb > :is(img, video) { transform: none; }

/* Ferramentas do painel (painel lateral e modo mini) */
.panel-tools { position: absolute; z-index: 4; right: 16px; bottom: calc(100% + 8px); display: flex; gap: 6px; }
.panel-tool { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 10px; border-radius: 10px; background: #1b1b1ef2; color: #c9c8ce; font-size: .75rem; font-weight: 650; box-shadow: inset 0 0 0 1px #ffffff12, 0 6px 18px #0007; backdrop-filter: blur(10px); }
.panel-tool:hover { color: #fff; background: #2a2a2f; }
.panel-tool .icon { width: 15px; height: 15px; }

/* Modo mini: só o campo do prompt */
body[data-panel="mini"] :is(.chip-row, .ref-tray, .toolbar, .prompt-corner, .reference-popover, .guide-panel, .mode-rail, .generation-status:empty) { display: none !important; }
body[data-panel="mini"] .composer { padding: 6px; border-radius: 22px; }
body[data-panel="mini"] .prompt-box { margin-top: 0; padding: 6px 6px 6px 16px; align-items: center; border-radius: 18px; }
body[data-panel="mini"] #prompt { min-height: 26px; max-height: 26px; overflow: hidden; padding-right: 8px !important; white-space: nowrap; field-sizing: fixed; cursor: text; }
body[data-panel="mini"] .prompt-highlight { white-space: nowrap; }
body[data-panel="mini"] .generate-button { flex-direction: row; gap: 10px; width: auto; min-height: 42px; padding: 0 20px; margin-bottom: 0; border-radius: 14px; font-size: .95rem; box-shadow: inset 0 1px 0 #ffffff8a, 0 3px 0 #2b1896; }
body[data-panel="mini"][data-feed="on"][data-view="studio"] .workspace { padding-bottom: 120px; }
body[data-panel="mini"][data-feed="on"][data-view="studio"] .app-main::after { height: 110px; }

/* Painel lateral: controles à esquerda e gerações à direita */
@media (min-width: 1000px) {
  body[data-layout="side"] { --side-panel: 372px; }
  body[data-layout="side"][data-view="studio"] .hero { display: none; }
  body[data-layout="side"][data-view="studio"] .app-main { padding-left: calc(var(--side-panel) + 12px); background: none; }
  body[data-layout="side"][data-view="studio"] .app-main::after { display: none; }
  body[data-layout="side"][data-view="studio"] .workspace { max-width: none; padding-bottom: 40px !important; padding-left: 20px; padding-right: 24px; }
  body[data-layout="side"][data-view="studio"] .gallery { margin-top: 4px; }
  body[data-layout="side"][data-view="studio"] .composer-shell {
    position: fixed; z-index: 15; top: 12px; bottom: 12px; left: calc(var(--sidebar-width) + 12px); right: auto;
    width: var(--side-panel); max-width: none; margin: 0; display: flex; flex-direction: column; align-items: stretch; gap: 8px;
    padding: 10px; border-radius: 22px; background: #161618; box-shadow: inset 0 0 0 1px #ffffff0d, 0 20px 50px #0007;
  }
  body[data-layout="side"][data-view="studio"] .mode-rail { display: flex !important; flex-direction: row; gap: 4px; padding: 4px; border-radius: 14px; background: #1f1f22; box-shadow: none; backdrop-filter: none; margin-right: 0; }
  body[data-layout="side"][data-view="studio"] .mode-rail button { flex: 1; flex-direction: row; width: auto; min-height: 38px; gap: 7px; border-radius: 10px; font-size: .85rem; }
  body[data-layout="side"][data-view="studio"] .mode-rail button .icon { width: 17px; height: 17px; }
  body[data-layout="side"][data-view="studio"] .composer { flex: 1; min-height: 0; display: flex; flex-direction: column; padding: 0; border-radius: 0; background: none; box-shadow: none; backdrop-filter: none; overflow: visible; }
  body[data-layout="side"][data-view="studio"] .panel-tools { position: static; order: -1; justify-content: flex-end; margin-bottom: 8px; }
  body[data-layout="side"][data-view="studio"] .panel-tool { background: #1f1f22; box-shadow: inset 0 0 0 1px #ffffff0d; backdrop-filter: none; }
  body[data-layout="side"][data-view="studio"] #create-panel { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 8px; overflow-y: auto; overscroll-behavior: contain; margin-right: -6px; padding-right: 6px; scrollbar-width: thin; }
  body[data-layout="side"][data-view="studio"] :is(.prompt-box, .prompt-main) { display: contents; }

  body[data-layout="side"][data-view="studio"] .ref-tray { order: 1; display: block; margin: 0; padding: 10px; border-radius: 16px; background: #1f1f22; border: 1px dashed #ffffff1c; }
  body[data-layout="side"][data-view="studio"] .ref-tray-body { flex-wrap: wrap; overflow: visible; }
  body[data-layout="side"][data-view="studio"] .ref-thumbs { flex-wrap: wrap; }
  body[data-layout="side"][data-view="studio"] .ref-thumb { width: 54px; height: 54px; }
  body[data-layout="side"][data-view="studio"] .ref-tray[data-empty="true"] .ref-tray-body { justify-content: center; padding: 6px 0; }
  body[data-layout="side"][data-view="studio"] .ref-tray-add { width: 96px; height: 62px; }
  body[data-layout="side"][data-view="studio"] .reference-popover { order: 2; position: static; width: auto; padding: 12px; border-radius: 16px; box-shadow: inset 0 0 0 1px #ffffff10; }
  body[data-layout="side"][data-view="studio"] .guide-panel { order: 4; position: static; max-height: none; border-radius: 16px; overflow: visible; }
  body[data-layout="side"][data-view="studio"] .guide-list { grid-template-columns: 1fr; padding: 4px 12px 12px; }
  body[data-layout="side"][data-view="studio"] .guide-footer { flex-wrap: wrap; }

  body[data-layout="side"][data-view="studio"] .prompt-field { order: 3; padding: 10px 12px 8px; border-radius: 16px 16px 0 0; background: #1f1f22; }
  body[data-layout="side"][data-view="studio"] .prompt-field::before { content: attr(data-label); display: block; margin-bottom: 4px; color: #e9e8ec; font-size: .82rem; font-weight: 700; }
  body[data-layout="side"][data-view="studio"] .prompt-field:focus-within { background: #242428; }
  body[data-layout="side"][data-view="studio"] #prompt { min-height: 96px; max-height: 320px; padding-right: 0 !important; font-size: .95rem; }
  body[data-layout="side"][data-view="studio"] .prompt-corner { order: 3; position: static; flex-wrap: wrap; justify-content: flex-start; gap: 4px; margin-top: -8px; padding: 0 10px 10px; border-radius: 0 0 16px 16px; background: #1f1f22; }
  body[data-layout="side"][data-view="studio"] .prompt-field:focus-within + .prompt-corner { background: #242428; }
  body[data-layout="side"][data-view="studio"] .prompt-count { order: 9; margin-left: auto; }

  body[data-layout="side"][data-view="studio"] .chip-row { order: 5; display: grid; grid-template-columns: 1fr 1fr; gap: 6px; overflow: visible; }
  body[data-layout="side"][data-view="studio"] .chip-row .chip-references { display: none; }
  body[data-layout="side"][data-view="studio"] .chip { min-width: 0; min-height: 50px; padding: 6px 10px 6px 6px; gap: 8px; border-radius: 14px; background: #1f1f22; }
  body[data-layout="side"][data-view="studio"] .chip-thumb { width: 34px; height: 34px; border-radius: 9px; }
  body[data-layout="side"][data-view="studio"] .chip-value, body[data-layout="side"][data-view="studio"] .chip .studio-select-trigger { font-size: .85rem; }

  body[data-layout="side"][data-view="studio"] .toolbar { order: 6; display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin: 0; }
  body[data-layout="side"][data-view="studio"] .toolbar > [hidden] { display: none !important; }
  body[data-layout="side"][data-view="studio"] .tool-pill { height: auto; min-height: 54px; flex-direction: column; align-items: flex-start; justify-content: center; gap: 2px; padding: 7px 12px; border-radius: 14px; background: #1f1f22; font-size: .9rem; }
  body[data-layout="side"][data-view="studio"] .tool-pill:hover, body[data-layout="side"][data-view="studio"] .tool-pill:focus-within { background: #26262a; }
  body[data-layout="side"][data-view="studio"] .tool-pill[data-label]::before { content: attr(data-label); color: var(--muted); font-size: .72rem; font-weight: 600; letter-spacing: 0; }
  body[data-layout="side"][data-view="studio"] .tool-pill > .icon, body[data-layout="side"][data-view="studio"] .tool-pill > .aspect-icon { display: none; }
  body[data-layout="side"][data-view="studio"] .tool-model { grid-column: 1 / -1; }
  body[data-layout="side"][data-view="studio"] .tool-model .studio-select { width: 100%; }
  body[data-layout="side"][data-view="studio"] .tool-square { width: auto; }
  body[data-layout="side"][data-view="studio"] .tool-square > .icon { display: block; width: 18px; height: 18px; }
  body[data-layout="side"][data-view="studio"] .tool-group { grid-column: 1 / -1; height: 44px; justify-content: flex-start; border-radius: 14px; background: #1f1f22; }
  body[data-layout="side"][data-view="studio"] .tool-stepper { grid-column: 1 / -1; min-height: 46px; flex-direction: row; align-items: center; justify-content: space-between; padding: 0 8px; }
  body[data-layout="side"][data-view="studio"] .mention-menu { bottom: auto; top: calc(100% + 6px); }

  body[data-layout="side"][data-view="studio"] .generation-status { order: 7; position: static; margin: 0; padding: 8px 10px; border-radius: 10px; background: #1f1f22; }
  body[data-layout="side"][data-view="studio"] .generate-button { order: 9; position: sticky; bottom: 0; z-index: 3; flex: none; flex-direction: row; gap: 12px; width: 100%; min-height: 54px; margin: auto 0 4px; border-radius: 16px; font-size: 1rem; }

  /* Modo mini no painel lateral */
  body[data-layout="side"][data-panel="mini"][data-view="studio"] .composer-shell { bottom: auto; }
  body[data-layout="side"][data-panel="mini"][data-view="studio"] .mode-rail { display: none !important; }
  body[data-layout="side"][data-panel="mini"][data-view="studio"] #create-panel { overflow: visible; }
  body[data-layout="side"][data-panel="mini"][data-view="studio"] .prompt-field { border-radius: 16px; }
  body[data-layout="side"][data-panel="mini"][data-view="studio"] .prompt-field::before { display: none; }
  body[data-layout="side"][data-panel="mini"][data-view="studio"] #prompt { min-height: 26px; max-height: 26px; }
  body[data-layout="side"][data-panel="mini"][data-view="studio"] .generate-button { margin-top: 0; }

  /* Gerações em lista à direita (mídia + detalhes) */
  body[data-layout="side"][data-view="studio"] .feed { display: flex; flex-direction: column; gap: 14px; padding: 8px 0 24px; }
  body[data-layout="side"][data-view="studio"] .feed-card { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 0; aspect-ratio: auto; border-radius: 18px; background: #18181b; box-shadow: inset 0 0 0 1px #ffffff0b; overflow: hidden; animation: none; }
  body[data-layout="side"][data-view="studio"] .feed-open { position: relative; inset: auto; height: auto; max-height: 520px; aspect-ratio: var(--ratio, 16 / 9); border-radius: 0; background: #0d0d0f; }
  body[data-layout="side"][data-view="studio"] .feed-open > :is(img, video) { object-fit: contain; }
  body[data-layout="side"][data-view="studio"] .feed-card:hover .feed-open > :is(img, video) { transform: none; }
  body[data-layout="side"][data-view="studio"] .feed-card > .card-actions, body[data-layout="side"][data-view="studio"] .card-info { display: none; }
  body[data-layout="side"][data-view="studio"] .feed-placeholder { display: block; min-height: 220px; aspect-ratio: var(--ratio, 16 / 9); max-height: 520px; background: linear-gradient(110deg, #1c1c1f 30%, #26262b 50%, #1c1c1f 70%); background-size: 220% 100%; animation: feed-shimmer 1.8s linear infinite; }
  body[data-layout="side"][data-view="studio"] .feed-card[data-status="failed"] .feed-placeholder { animation: none; background: #1d1718; }
  body[data-layout="side"][data-view="studio"] .feed-card:not([data-status="completed"]) .feed-caption { right: calc(44% + 12px); }
  body[data-layout="side"][data-view="studio"] .feed-card:not([data-status="completed"]) .feed-dismiss { left: calc(56% - 42px); right: auto; }
  body[data-layout="side"][data-view="studio"] .feed-details { display: flex; flex-direction: column; gap: 12px; min-width: 0; padding: 16px 18px; }
  .feed-prompt { margin: 0; color: #d7d6db; font-size: .9rem; line-height: 1.55; white-space: pre-wrap; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 8; -webkit-box-orient: vertical; overflow: hidden; }
  .feed-prompt mark { padding: 0 4px; border-radius: 5px; background: #4227da59; color: #c9bfff; font-weight: 650; }
  .feed-pills span { padding: 4px 8px; background: #26262b; font-size: .74rem; }
  .feed-details-footer { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px; margin-top: auto; padding-top: 6px; }
  .feed-details-footer time { color: var(--muted); font-size: .78rem; }
  .feed-details .card-actions { position: static; opacity: 1; transform: none; pointer-events: auto; justify-content: flex-end; flex-wrap: wrap; }
  .feed-details .card-action:not(.card-action-primary) { background: #26262b; }
}

/* Ferramentas do painel só com ícone; no painel lateral ficam acima de Imagem/Vídeo */
.composer-shell { position: relative; }
.panel-tool { width: 32px; height: 32px; padding: 0; justify-content: center; }
.panel-tool .icon { width: 17px; height: 17px; }
@media (min-width: 1000px) {
  body[data-layout="side"][data-view="studio"] .panel-tools { position: static; order: -1; justify-content: flex-end; margin: 0; }
}

/* Painel lateral: a bandeja é o lugar único das referências (sem repetições) */
@media (min-width: 1000px) {
  body[data-layout="side"][data-view="studio"] :is(#reference-list, #reference-pick-generated, #reference-clear, #add-reference-btn, #pick-generated-btn, .tool-group .tool-divider) { display: none !important; }
  body[data-layout="side"][data-view="studio"] form[data-mode="image"] .tool-group { display: none; }
}

/* Direção de cena com miniaturas */
.preset-trigger { position: static; padding: 0; background: none; color: #f4f3f5; font-size: 1.04rem; font-weight: 700; letter-spacing: -.02em; text-align: left; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.preset-trigger::after { content: ''; position: absolute; inset: 0; border-radius: inherit; }
.chip:has(.preset-trigger:focus-visible) { outline: 2px solid var(--focus); outline-offset: 2px; }
.preset-trigger:focus-visible { outline: none; }
.chip[data-preset-set] { box-shadow: inset 0 0 0 1px #8f7cff66; }
.chip[data-preset-set] .chip-thumb { box-shadow: 0 0 0 2px var(--brand); }
.preset-dialog { width: min(1040px, calc(100% - 28px)); padding: 16px; background: #1c1c1f; }
.preset-heading-actions { display: flex; align-items: center; gap: 8px; }
.preset-heading-actions .secondary-button { min-height: 36px; border-radius: 999px; padding: 0 16px; }
.preset-body { display: grid; grid-template-columns: 230px minmax(0, 1fr); gap: 12px; min-height: min(560px, 70vh); }
.preset-tabs { display: flex; flex-direction: column; gap: 4px; padding: 6px; border-radius: 16px; background: #161618; }
.preset-tab { position: relative; display: flex; align-items: center; gap: 10px; padding: 7px; border-radius: 12px; background: none; color: #9a99a2; text-align: left; }
.preset-tab:hover { background: #222226; color: #e9e8ec; }
.preset-tab[aria-selected="true"] { background: #2a2a2f; color: #fff; }
.preset-tab img { width: 46px; height: 34px; flex: none; border-radius: 8px; object-fit: cover; background: #2a2a2f; }
.preset-tab span { display: grid; min-width: 0; }
.preset-tab strong { font-size: .875rem; font-weight: 700; }
.preset-tab small { color: var(--muted); font-size: .72rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.preset-dot { position: absolute; top: 50%; right: 10px; width: 7px; height: 7px; margin-top: -3.5px; border-radius: 50%; background: #8f7cff; box-shadow: 0 0 0 3px #4227da55; }
.preset-panel { min-width: 0; display: flex; flex-direction: column; padding: 14px; border-radius: 16px; background: #161618; }
.preset-panel-head h3 { margin: 0; font-size: 1rem; font-weight: 700; letter-spacing: -.01em; }
.preset-panel-head p { margin-top: 3px; color: var(--muted); font-size: .82rem; }
.preset-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; margin-top: 14px; overflow-y: auto; max-height: min(480px, 60vh); padding: 4px; }
.preset-card { position: relative; display: block; padding: 0; border-radius: 18px; overflow: hidden; background: #26262b; aspect-ratio: 3 / 2; box-shadow: inset 0 0 0 1px #ffffff12; transition: transform .15s ease, box-shadow .15s ease; }
.preset-card img { display: block; width: 100%; height: 100%; object-fit: cover; opacity: .72; transition: opacity .15s; }
.preset-card span { position: absolute; left: 0; right: 0; bottom: 0; padding: 26px 10px 9px; background: linear-gradient(0deg, #000000d9, #0000); color: #f2f1f4; font-size: .84rem; font-weight: 700; text-align: center; }
.preset-card:hover { transform: translateY(-2px); }
.preset-card:hover img { opacity: 1; }
.preset-card[aria-checked="true"] { box-shadow: 0 0 0 3px #fff, 0 0 0 6px var(--brand); }
.preset-card[aria-checked="true"] img { opacity: 1; }
.preset-card[aria-checked="true"]::after { content: ''; position: absolute; top: 9px; right: 9px; width: 22px; height: 22px; border-radius: 50%; background: var(--brand) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 12.5 4 4L18 8'/%3E%3C/svg%3E") center / 14px no-repeat; }
@media (min-width: 1000px) {
  body[data-layout="side"][data-view="studio"] .preset-trigger { font-size: .85rem; }
}
@media (max-width: 760px) {
  .preset-body { grid-template-columns: 1fr; }
  .preset-tabs { flex-direction: row; overflow-x: auto; }
  .preset-tab { flex: none; }
  .preset-tab small, .preset-dot { display: none; }
  .preset-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); max-height: 56vh; }
}

/* Ícones dos chips (arte própria com cantos transparentes) */
.chip-thumb[src^="/assets/chip-"], .chip-thumb-plus[data-icon] { background: none; box-shadow: none; object-fit: contain; border-radius: 0; }
.chip-thumb-plus[data-icon] img { object-fit: contain; }
.chip[data-preset-set] .chip-thumb { border-radius: 12px; object-fit: cover; }

/* Referência ampliada com detalhes */
.ref-viewer { width: min(1280px, calc(100% - 28px)); height: min(820px, calc(100% - 28px)); max-width: none; max-height: none; padding: 0; border: 0; border-radius: 20px; overflow: hidden; background: #0c0c0e; color: var(--accent); box-shadow: 0 30px 100px #000c; }
.ref-viewer[open] { display: grid; grid-template-columns: minmax(0, 1fr) 340px; }
.ref-viewer::backdrop { background: #050507d9; backdrop-filter: blur(6px); }
.ref-viewer-stage { display: grid; place-items: center; min-width: 0; min-height: 0; padding: 28px; background: radial-gradient(ellipse at 30% 40%, #1b1626, #0c0c0e 70%); }
.ref-viewer-stage > :is(img, video) { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 6px; box-shadow: 0 20px 60px #0009; }
.ref-viewer-stage > audio { width: min(520px, 100%); }
.ref-viewer-side { display: flex; flex-direction: column; gap: 14px; min-height: 0; padding: 16px; background: #1a1a1d; box-shadow: inset 1px 0 0 #ffffff0d; overflow-y: auto; }
.ref-viewer-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.ref-viewer-title { font-size: 1rem; font-weight: 700; letter-spacing: -.01em; }
.ref-viewer-details { padding: 12px; border-radius: 14px; background: #222226; }
.ref-viewer-details h3 { display: flex; align-items: center; gap: 7px; margin: 0 0 10px; color: var(--muted); font-size: .74rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.ref-viewer-details h3 .icon { width: 15px; height: 15px; }
.ref-viewer-details dl { display: grid; gap: 2px; margin: 0; padding: 6px 10px; border-radius: 10px; background: #2a2a2f; }
.ref-viewer-details dl > div { display: flex; justify-content: space-between; gap: 12px; padding: 5px 0; }
.ref-viewer-details dt { color: var(--muted); font-size: .84rem; }
.ref-viewer-details dd { margin: 0; color: #f2f1f4; font-size: .84rem; font-weight: 600; text-align: right; overflow-wrap: anywhere; }
.ref-viewer-actions { display: grid; gap: 8px; margin-top: auto; }
.ref-viewer-main { width: 100%; min-height: 46px; background: var(--brand); color: #fff; }
.ref-viewer-main:not(:disabled):hover { background: #5236ee; }
.ref-viewer-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.ref-viewer-row .secondary-button { min-height: 44px; }
.ref-thumb { cursor: zoom-in; }
@media (max-width: 760px) {
  .ref-viewer[open] { grid-template-columns: 1fr; grid-template-rows: minmax(0, 1fr) auto; }
  .ref-viewer-side { max-height: 46vh; }
}

/* Login: olho da senha e recuperação */
.field-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.link-button { padding: 0; background: none; color: #b7a9ff; font-size: .8rem; font-weight: 600; }
.link-button:hover { color: #fff; text-decoration: underline; }
.password-input { position: relative; display: block; }
.password-input input { width: 100%; padding-right: 46px !important; }
.reveal-button { position: absolute; top: 50%; right: 6px; display: grid; place-items: center; width: 34px; height: 34px; margin-top: -17px; padding: 0; border-radius: 9px; background: transparent; color: #8f8e95; touch-action: none; user-select: none; -webkit-user-select: none; }
.reveal-button:hover { color: #e9e8ec; background: #ffffff0d; }
.reveal-button[data-active] { color: #fff; background: #4227da55; }
.reveal-button .icon { width: 18px; height: 18px; }
.auth-success { padding: 10px 12px; border-radius: 10px; background: #4227da26; color: #d9d2ff; font-size: .86rem; line-height: 1.45; }
.auth-back { justify-self: center; margin-top: 4px; }
#email-form select { min-height: 42px; padding: 0 10px; border-radius: 9px; background: #131315; color: var(--accent); }
.field label { color: #cfcdd4; font-size: .82rem; font-weight: 600; }
.field > .password-input { font-size: inherit; font-weight: inherit; }
