/* asAi graphite Studio. Motion budget: 180ms / 200ms; no decorative gradients. */
:root {
  color-scheme: dark;
  --ink: #d6dce5;
  --ink-strong: #f7f9fc;
  --muted: #96a0ae;
  --subtle: #727d8c;
  --canvas: #0e1116;
  --surface: #181d25;
  --surface-soft: #131820;
  --line: #2b333e;
  --line-strong: #626d7c;
  --accent: #4661d6;
  --accent-dark: #8ca2f0;
  --accent-hover: #3b5bdb;
  --accent-soft: rgba(70, 97, 214, .18);
  --danger: #e89aa0;
  --shadow: 0 16px 40px rgba(0, 0, 0, .6);
  --radius: 12px;
  font-family: "Segoe UI Variable", "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html { min-height: 100%; scroll-behavior: smooth; }
body { margin: 0; min-height: 100%; overflow-x: hidden; background: var(--canvas); color: var(--ink); }
body, button, input, textarea, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
a { color: inherit; text-underline-offset: .2em; }
::selection { background: rgba(140, 162, 240, .3); color: var(--ink-strong); }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { border: 2px solid transparent; border-radius: 999px; background: #4d5868; background-clip: padding-box; }
button:focus-visible, a:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible {
  outline: 3px solid var(--accent-dark);
  outline-offset: 3px;
}
svg { display: block; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.8; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.skip-link { position: fixed; inset-block-start: -80px; inset-inline-start: 16px; z-index: 50; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); padding: 10px 14px; color: var(--ink); box-shadow: var(--shadow); }
.skip-link:focus { inset-block-start: 12px; }

.studio-shell { min-height: 100dvh; display: grid; grid-template-columns: 256px minmax(0, 1fr); }
.studio-sidebar { position: sticky; inset-block-start: 0; height: 100dvh; z-index: 30; display: flex; flex-direction: column; overflow-y: auto; border-inline-end: 1px solid var(--line); background: var(--surface-soft); padding: calc(24px + env(safe-area-inset-top)) 20px calc(22px + env(safe-area-inset-bottom)); }
.studio-brand-row { min-height: 40px; display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-block-end: 26px; }
.studio-brand { min-height: 44px; display: inline-flex; align-items: center; gap: 10px; text-decoration: none; }
.studio-brand img { display: block; width: 82px; height: auto; filter: brightness(1.5) saturate(1.1); }
.studio-brand span { border-inline-start: 1px solid var(--line); padding-inline-start: 10px; color: var(--muted); font-size: 14px; font-weight: 700; }
.sidebar-language { margin-inline-start: auto; }
.language-toggle { min-height: 36px; border: 1px solid var(--line-strong); border-radius: 999px; background: transparent; padding: 0 10px; color: var(--muted); font-size: 11px; font-weight: 750; letter-spacing: .04em; }
.language-toggle:hover { border-color: var(--accent); color: var(--accent); }
.sidebar-close, .menu-button { width: 44px; height: 44px; align-items: center; justify-content: center; border: 1px solid var(--line); border-radius: 11px; background: var(--surface); color: var(--ink); }
.sidebar-close { display: none; }
.sidebar-close svg, .menu-button svg { width: 19px; height: 19px; }
.sidebar-section { margin-block-start: 26px; }
.nav-label { margin: 0 10px 10px; color: var(--muted); font-size: 11px; font-weight: 750; letter-spacing: .09em; text-transform: uppercase; }
.mode-switch { display: grid; gap: 4px; }
.mode { min-height: 44px; display: flex; align-items: center; gap: 12px; width: 100%; border: 0; border-radius: 10px; background: transparent; padding: 0 12px; color: var(--muted); font-size: 14px; font-weight: 650; text-align: start; transition: background-color 180ms cubic-bezier(.2, .8, .2, 1), color 180ms cubic-bezier(.2, .8, .2, 1); }
.mode svg { width: 19px; height: 19px; }
.mode:hover { background: var(--surface); color: var(--ink-strong); }
.mode.active { background: var(--accent-soft); color: var(--accent-dark); }
.sidebar-footer { flex: 0 0 auto; margin-block-start: auto; border-block-start: 1px solid var(--line); padding: 18px 10px 4px; }
.sidebar-footer p { margin: 0 0 5px; color: var(--muted); font-size: 12px; }
.sidebar-footer strong { display: block; color: var(--ink-strong); font-size: 18px; font-variant-numeric: tabular-nums; }
.sidebar-footer a { display: inline-block; min-height: 44px; padding-block-start: 9px; color: var(--accent-dark); font-size: 13px; font-weight: 700; }

.studio-main { min-width: 0; min-height: 100dvh; display: flex; flex-direction: column; }
.studio-topbar { min-height: 64px; display: flex; align-items: center; gap: 12px; border-block-end: 1px solid var(--line); background: rgba(14, 17, 22, .94); padding: 0 28px; }
.menu-button { display: none; flex: 0 0 auto; }
.studio-version { display: inline-flex; align-items: center; min-height: 32px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface-soft); padding: 0 13px; color: var(--ink); font-size: 12px; font-weight: 700; }
.topbar-actions { margin-inline-start: auto; display: flex; align-items: center; gap: 10px; }
.account-link, .plain-link { color: var(--accent-dark); font-weight: 700; }
.account-link { min-height: 44px; display: inline-flex; align-items: center; padding: 0 10px; font-size: 13px; text-decoration: none; }
.text-button { min-height: 44px; border: 0; background: transparent; padding: 0 10px; color: var(--accent-dark); font-weight: 700; }

.auth-gate { width: min(980px, calc(100% - 48px)); min-height: calc(100dvh - 64px); margin: 0 auto; padding: 72px 0 84px; display: grid; grid-template-columns: 1.1fr .9fr; align-items: center; gap: 72px; }
.auth-mark, .hero-mark { display: grid; place-items: center; border: 1px solid #ccd7f4; background: var(--accent-soft); color: var(--accent); box-shadow: 0 14px 32px rgba(38, 73, 157, .12); }
.auth-mark { width: 58px; height: 58px; border-radius: 18px; margin-block-end: 28px; }
.auth-mark svg { width: 31px; height: 31px; }
.auth-copy h1 { max-width: 640px; margin: 0; color: var(--ink-strong); font-size: clamp(38px, 5vw, 64px); font-weight: 650; letter-spacing: -.04em; line-height: 1.02; text-wrap: balance; }
.auth-copy > p { max-width: 58ch; margin: 22px 0 15px; color: var(--muted); font-size: 18px; line-height: 1.65; }
.auth-card { border: 1px solid var(--line); border-radius: 16px; background: var(--surface); padding: 28px; box-shadow: var(--shadow); }
.auth-card h2 { margin: 0; color: var(--ink-strong); font-size: 20px; }
.auth-card > p:not(.status-message) { margin: 9px 0 22px; color: var(--muted); font-size: 14px; line-height: 1.55; }
.primary-button, .secondary-button { min-height: 46px; border-radius: 11px; padding: 0 16px; font-weight: 750; }
.primary-button { width: 100%; border: 1px solid var(--accent); background: var(--accent); color: #fff; }
.primary-button:hover { background: var(--accent-hover); color: #fff; }
.primary-button:active, .secondary-button:active { transform: scale(.985); }
.auth-legal { margin-block-end: 0 !important; font-size: 12px !important; }
.status-message { margin: 16px 0 0; color: var(--danger); font-size: 14px; line-height: 1.45; }

.workspace { min-height: calc(100dvh - 64px); display: flex; flex-direction: column; }
.welcome-hero { width: min(1060px, calc(100% - 48px)); margin: 0 auto; padding: 18px 0 8px; display: flex; flex-direction: column; align-items: start; }
.hero-mark { width: 56px; height: 56px; flex: 0 0 auto; border-radius: 50%; margin-block-end: 14px; }
.hero-mark svg { width: 30px; height: 30px; }
.hero-copy { text-align: center; }
.hero-copy h1 { margin: 0; color: var(--ink-strong); font-size: clamp(22px, 2.5vw, 32px); font-weight: 650; letter-spacing: -.03em; line-height: 1.08; text-wrap: balance; }
.hero-copy p { max-width: 65ch; margin: 8px auto 0; color: var(--muted); font-size: 14px; line-height: 1.5; }

.studio-composer { width: min(1600px, calc(100% - 48px)); margin: 0 auto; padding: 14px 0 calc(28px + env(safe-area-inset-bottom)); }
.composer-heading { display: flex; align-items: end; justify-content: space-between; margin-block-end: 10px; padding-inline: 4px; }
.composer-heading h2 { margin: 0; color: var(--ink-strong); font-size: 15px; }
.composer-heading p { margin: 3px 0 0; color: var(--muted); font-size: 12px; }
.composer-form { display: grid; gap: 10px; }
.image-options { min-width: 0; display: grid; grid-template-columns: max-content minmax(0, 1fr); align-items: center; gap: 10px; }
.image-options label { color: var(--muted); font-size: 12px; font-weight: 700; }
.image-options select { width: 100%; min-width: 0; min-height: 38px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface-soft); padding: 0 10px; color: var(--ink); }
.image-controls { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; }
.image-presets { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.preset-card { min-height: 42px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-soft); padding: 0 10px; color: var(--muted); font-size: 12px; font-weight: 700; text-align: start; transition: border-color 180ms cubic-bezier(.16, 1, .3, 1), background-color 180ms cubic-bezier(.16, 1, .3, 1), color 180ms cubic-bezier(.16, 1, .3, 1), transform 180ms cubic-bezier(.16, 1, .3, 1); }
.preset-card:hover { border-color: var(--accent); color: var(--ink-strong); transform: translateY(-1px); }
.preset-card.is-active { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-dark); }
.image-advanced { border-block: 1px solid var(--line); padding: 9px 6px; color: var(--muted); font-size: 12px; }
.image-advanced summary { cursor: pointer; color: var(--ink); font-weight: 700; }
.image-advanced:not([open]) + .image-edit-source { display: none; }
#image-form:not(.advanced-open) #image-model-group,
#image-form:not(.advanced-open) #image-size-group,
#image-form:not(.advanced-open) #image-aspect-ratio-group,
#image-form:not(.advanced-open) #image-resolution-group,
#image-form:not(.advanced-open) #image-quality-group,
#image-form:not(.advanced-open) #image-edit-source-group { display: none !important; }
.image-advanced.advanced-open { border-color: var(--accent); }
.prompt-row-p2 { grid-template-columns: minmax(0, 1fr) auto auto; }
.prompt-examples { display: flex; flex-wrap: wrap; gap: 6px; margin: 0; padding: 0; list-style: none; }
.prompt-example { min-height: 44px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface-soft); padding-inline: 13px; color: var(--muted); font-size: 12px; }
.prompt-example:hover { border-color: var(--accent); color: var(--accent-dark); }
.prompt-collection-btn { min-height: 44px; display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface-soft); padding: 0 16px; color: var(--muted); font-size: 12px; font-weight: 700; cursor: default; opacity: .6; }
.prompt-collection-btn:hover { border-color: var(--accent); color: var(--accent-dark); }
.prompt-collection-btn svg { width: 15px; height: 15px; flex: 0 0 auto; }
.prompt-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: end; gap: 10px; }
.prompt-row textarea { width: 100%; min-width: 0; min-height: 180px; max-height: 420px; resize: vertical; border: 0; outline: 0; background: transparent; padding: 11px 8px; color: var(--ink); line-height: 1.5; }
.prompt-row textarea::placeholder { color: #7a8597; }
.generate-button { width: 100%; min-height: 46px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid var(--accent); border-radius: 999px; background: var(--accent); padding: 0 17px; color: #fff; font-weight: 750; transition: background-color 180ms cubic-bezier(.2, .8, .2, 1), transform 180ms cubic-bezier(.2, .8, .2, 1); }
.generate-button svg { width: 17px; height: 17px; }
.generate-button:hover { background: var(--accent-hover); color: #fff; }
.generate-button:active { transform: scale(.985); }
.generate-button:disabled { cursor: not-allowed; opacity: .55; }
.generate-button.is-loading svg { animation: studio-spin 900ms linear infinite; }
.generate-button.is-loading span::after { content: "…"; }
.primary-button:disabled { cursor: not-allowed; opacity: .55; }
.composer-form [role="status"] { min-height: 19px; margin: 0 6px; color: var(--muted); font-size: 12px; line-height: 1.5; }
.image-estimate { border-block: 1px solid var(--line); margin: 2px 0; padding: 10px 6px; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.tts-panel { width: 100%; }
.tts-workspace { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; }
.tts-create-column { min-width: 0; }
.tts-controls { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.tts-options { min-width: 0; display: grid; grid-template-columns: max-content minmax(0, 1fr); align-items: center; gap: 10px; }
.tts-options label { color: var(--muted); font-size: 12px; font-weight: 700; }
.tts-options select { width: 100%; min-width: 0; min-height: 38px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface-soft); padding: 0 10px; color: var(--ink); }
.tts-estimate { border-block: 1px solid var(--line); margin: 2px 0; padding: 10px 6px; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.tts-result { display: grid; gap: 8px; }
.tts-result audio { width: 100%; }
.tts-result-actions { display: flex; justify-content: flex-end; }
@media (max-width: 720px) {
  .tts-controls { grid-template-columns: minmax(0, 1fr); }
}
.image-result-actions { display: flex; justify-content: flex-end; }
.image-edit-source { display: grid; gap: 8px; border-block: 1px solid var(--line); padding-block: 10px; }
.edit-source-heading { display: flex; align-items: center; justify-content: space-between; }
.edit-source-heading label { color: var(--muted); font-size: 12px; font-weight: 700; }
.image-edit-source input[type="file"] { width: 100%; min-height: 38px; color: var(--ink); font-size: 12px; }
.field-note { margin: 0; color: var(--muted); font-size: 12px; }
.image-source-preview { width: min(100%, 240px); max-height: 180px; object-fit: contain; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-soft); }
.image-workspace { display: grid; grid-template-columns: minmax(280px, 360px) minmax(0, 1fr); gap: 18px; align-items: stretch; }
.image-create-column { display: grid; gap: 10px; min-width: 0; align-content: start; }
.image-preview-column { display: grid; gap: 10px; min-width: 0; min-height: calc(100dvh - 160px); position: sticky; top: 82px; }
.image-canvas-empty { display: grid; place-items: center; min-height: 100%; border: 1px dashed var(--line-strong); border-radius: 14px; background: #111318; color: var(--muted); font-size: 13px; text-align: center; padding: 20px; }
@media (max-width: 720px) {
  .image-workspace { grid-template-columns: minmax(0, 1fr); }
  .image-preview-column { order: -1; position: static; min-height: 0; }
  .image-canvas-empty { min-height: 180px; }
  .image-stream .chat-image-card { min-height: 0; }
  .chat-image-preview { height: auto; max-height: 62vh; min-height: 180px; }
}
.image-stream { display: grid; gap: 12px; min-height: 0; }
.image-stream:not(:empty) { margin-block-end: 12px; padding: 3px; }
.image-stream .chat-image-card { width: 100%; max-width: 100%; min-height: min(72vh, 760px); }
.image-stream .chat-image-card .chat-image-preview { max-width: 100%; }
.chat-image-card { width: min(100%, 380px); max-width: 88%; display: grid; gap: 9px; justify-self: start; border: 1px solid var(--line); border-radius: 14px; background: var(--surface-soft); padding: 10px; }
.chat-image-preview { width: 100%; height: min(78vh, 1000px); display: block; object-fit: contain; border-radius: 9px; background: #111318; min-height: 280px; }
.chat-image-caption { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.45; overflow-wrap: anywhere; }
.chat-image-prompt { border-block-start: 1px solid var(--line); padding-block-start: 4px; }
.chat-image-prompt summary { min-height: 34px; display: flex; align-items: center; justify-content: space-between; gap: 10px; color: var(--ink-strong); font-size: 12px; font-weight: 700; cursor: pointer; list-style: none; }
.chat-image-prompt summary::-webkit-details-marker { display: none; }
.chat-image-prompt summary svg { width: 16px; height: 16px; color: var(--muted); transition: transform 180ms cubic-bezier(.2, .8, .2, 1); }
.chat-image-prompt[open] summary svg { transform: rotate(180deg); }
.chat-image-prompt .chat-image-caption { margin-block-start: 6px; }
.image-card-download { justify-self: start; min-height: 44px; padding: 0 14px; font-size: 13px; font-weight: 700; }
.image-loading { min-height: 120px; display: grid; place-items: center; gap: 8px; border: 1px dashed var(--line-strong); border-radius: 12px; color: var(--muted); font-size: 12px; }
.image-loading p { margin: 0; }
.spinner { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--line-strong); border-block-start-color: var(--accent); animation: studio-spin 900ms linear infinite; }
@keyframes studio-spin { to { transform: rotate(360deg); } }
.secondary-button { border: 1px solid var(--line-strong); background: var(--surface-soft); color: var(--accent-dark); }
.service-message { margin-block-end: 10px; border: 1px solid var(--line-strong); border-radius: 13px; background: var(--surface-soft); padding: 14px 16px; }
.service-message strong { display: block; color: var(--ink-strong); font-size: 14px; }
.service-message span { display: block; margin-block-start: 3px; color: var(--muted); font-size: 12px; }
.backdrop { display: none; }

@media (max-width: 1024px) {
  .studio-shell { display: block; }
  .studio-sidebar { position: fixed; inset: 0 auto 0 0; width: min(300px, 86vw); height: 100dvh; transform: translateX(-105%); transition: transform 180ms cubic-bezier(.2, .8, .2, 1); box-shadow: 16px 0 40px rgba(31, 43, 67, .16); }
  .studio-sidebar.open { transform: translateX(0); }
  .sidebar-close, .menu-button { display: inline-flex; }
  .studio-topbar { padding-inline: max(16px, env(safe-area-inset-left)) max(16px, env(safe-area-inset-right)); }
  .backdrop { position: fixed; inset: 0; z-index: 20; border: 0; background: rgba(23, 32, 51, .34); }
  .backdrop:not(.hidden) { display: block; }
  .auth-gate { width: min(100% - 40px, 760px); grid-template-columns: 1fr; gap: 36px; padding: 52px 0 72px; }
  .studio-composer { width: min(100% - 40px, 1600px); }
}

@media (max-width: 640px) {
  .studio-topbar { min-height: 60px; }
  .topbar-actions { gap: 0; }
  .account-link { display: none !important; }
  .auth-gate { width: calc(100% - 28px); padding: 38px 0 58px; }
  .auth-copy h1 { font-size: clamp(34px, 11vw, 48px); }
  .auth-copy > p { font-size: 16px; }
  .auth-card { padding: 22px; }
  .workspace { min-height: calc(100dvh - 60px); }
.welcome-hero, .studio-composer { width: calc(100% - 24px); }
  .welcome-hero { padding-block-start: 22px; }
  .hero-mark { width: 48px; height: 48px; margin-block-end: 12px; }
  .studio-composer { padding-block-end: calc(18px + env(safe-area-inset-bottom)); }
  .image-controls { grid-template-columns: 1fr; }
  .image-presets { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .image-options { grid-template-columns: 1fr; gap: 5px; }
  .prompt-row, .prompt-row-p2 { grid-template-columns: minmax(0, 1fr) auto; }

  .generate-button { min-width: 112px; width: auto; padding-inline: 14px; }
  .generate-button span { position: static; width: auto; height: auto; overflow: visible; clip: auto; }
}

@media (max-width: 359px) {
  .prompt-row { grid-template-columns: minmax(0, 1fr) 48px; }
  .generate-button { min-width: 48px; width: 48px; padding: 0; }
  .generate-button span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); }
}

@media (hover: hover) and (pointer: fine) {
  .text-button:hover, .account-link:hover, .plain-link:hover, .sidebar-footer a:hover { color: var(--accent); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; }
}

.gallery-panel { width: min(1060px, calc(100% - 48px)); margin: 0 auto auto; padding: 42px 0 56px; }
.gallery-heading { display: flex; align-items: end; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.gallery-heading h2 { margin: 0; color: var(--ink-strong); font-size: clamp(28px, 4vw, 44px); letter-spacing: -.035em; }
.gallery-heading p, .gallery-status { margin: 7px 0 0; color: var(--muted); font-size: 13px; }
.gallery-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); align-items: start; gap: 14px; }
.gallery-card { min-height: 160px; display: flex; flex-direction: column; justify-content: start; gap: 7px; overflow: hidden; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); padding: 0 16px 16px; box-shadow: 0 10px 28px rgba(31,43,67,.05); }
.gallery-card-preview { width: calc(100% + 32px); aspect-ratio: 1; display: block; margin: 0 -16px 9px; object-fit: cover; background: var(--surface-soft); }
.gallery-card-preview--skeleton {
  background: var(--surface-soft);
  /* Subtle pulse so the placeholder reads as intentionally empty, not broken. */
  animation: thumb-pending 1.6s ease-in-out infinite;
}
/* Speech cards have no artwork: keep a compact panel around the player. */
.gallery-card-preview--audio {
  aspect-ratio: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px 12px;
  margin: 0 -16px 9px;
  width: calc(100% + 32px);
  background: var(--surface-soft);
}
.gallery-card-preview--audio audio { width: 100%; max-width: 260px; }

@keyframes thumb-pending {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.6; }
}
.gallery-card h3 { margin: 0; color: var(--ink-strong); font-size: 15px; overflow-wrap: anywhere; }
.gallery-card-title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; line-height: 1.4; }
.gallery-card p { margin: 0; color: var(--muted); font-size: 12px; }
.gallery-actions { margin-top: 8px; }
.gallery-actions a { color: var(--accent-dark); font-size: 13px; font-weight: 750; }
@media (max-width: 640px) { .gallery-panel { width: calc(100% - 24px); padding-top: 28px; } .gallery-heading { align-items: start; flex-direction: column; } .gallery-grid { grid-template-columns: 1fr; } }

/* Fullscreen image viewer: click any generated image to inspect it at full size. */
.gallery-card-preview.is-zoomable,
.chat-image-preview.is-zoomable { cursor: zoom-in; }
.chat-image-preview.is-zoomable:focus-visible,
.gallery-card-preview.is-zoomable:focus-visible { outline: 2px solid var(--accent-dark); outline-offset: 2px; }
body.lightbox-open { overflow: hidden; }
.studio-lightbox { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; background: rgba(6, 8, 12, .94); padding: 24px; animation: lightbox-in 180ms cubic-bezier(.16, 1, .3, 1); }
.studio-lightbox-image { max-width: min(100%, 1600px); max-height: calc(100dvh - 48px); object-fit: contain; border-radius: 8px; cursor: default; }
.studio-lightbox-close { position: fixed; inset-block-start: calc(18px + env(safe-area-inset-top)); inset-inline-end: calc(18px + env(safe-area-inset-right)); min-height: 42px; border: 1px solid var(--line-strong); border-radius: 999px; background: rgba(19, 24, 32, .88); padding: 0 18px; color: var(--ink-strong); font-size: 13px; font-weight: 750; }
.studio-lightbox-close:hover { border-color: var(--accent); color: var(--accent-dark); }
@keyframes lightbox-in { from { opacity: 0; } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .studio-lightbox { animation: none; } .studio-detail-modal, .credits-panel { animation: none; } }

/* Sidebar icons & chat link */
.chat-link { display: inline-flex; align-items: center; gap: 8px; }
.chat-link svg { width: 16px; height: 16px; flex: 0 0 auto; }

/* Balance button (replaces <strong> in sidebar) */
.balance-button { display: block; width: 100%; min-height: 36px; border: 0; background: transparent; padding: 0; color: var(--ink-strong); font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums; text-align: start; cursor: pointer; }
.balance-button:hover { color: var(--accent-dark); }

/* Gallery filters */
.gallery-filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.gallery-filter { min-height: 38px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface-soft); padding: 0 14px; color: var(--ink); font-size: 12px; font-weight: 700; }
.gallery-filter:hover { border-color: var(--accent); }
.gallery-fav-toggle { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.gallery-fav-toggle svg { width: 14px; height: 14px; }
.gallery-fav-toggle[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-dark); }
.gallery-fav-toggle[aria-pressed="true"] svg { fill: var(--accent-dark); }

/* Gallery card enhancements */
.gallery-card { position: relative; transition: border-color 180ms cubic-bezier(.2,.8,.2,1); }
.gallery-card:hover { border-color: var(--accent); }
.gallery-card-overlay { position: absolute; top: 12px; right: 12px; z-index: 2; width: 32px; height: 32px; display: grid; place-items: center; border: 0; border-radius: 8px; background: rgba(14,17,22,.78); color: var(--ink); opacity: 0; transition: opacity 180ms; cursor: pointer; }
.gallery-card-overlay svg { width: 16px; height: 16px; }
.gallery-card:hover .gallery-card-overlay { opacity: 1; }
.gallery-card-meta { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.gallery-card-model { color: var(--accent-dark); font-size: 11px; font-weight: 700; }
.gallery-card-time { color: var(--subtle); font-size: 11px; }

/* Gallery hover action bar */
.gallery-action-bar { position: absolute; bottom: 12px; right: 12px; z-index: 3; display: flex; gap: 4px; opacity: 0; transition: opacity 180ms; pointer-events: none; }
.gallery-card:hover .gallery-action-bar { opacity: 1; pointer-events: auto; }
/* Touch devices: reveal the action bar once the preview is ready. */
@media (hover: none) { .gallery-action-bar .gallery-action-btn.is-ready { opacity: 1; pointer-events: auto; } }
.gallery-action-btn { min-height: 32px; display: inline-flex; align-items: center; gap: 5px; border: 0; border-radius: 8px; background: rgba(14,17,22,.88); padding: 0 10px; color: var(--ink); font-size: 11px; font-weight: 700; cursor: pointer; }
.gallery-action-btn:hover { background: var(--surface); }
.gallery-action-btn svg { width: 14px; height: 14px; }
.gallery-action-btn.is-danger { color: var(--danger); }
.gallery-action-btn.is-view { color: var(--accent-dark); }

/* Image detail modal — fullscreen viewer */
.studio-detail-modal { position: fixed; inset: 0; z-index: 60; background: rgba(6,8,12,.96); padding: 24px; animation: lightbox-in 180ms cubic-bezier(.16,1,.3,1); }
.detail-modal-close { position: fixed; inset-block-start: calc(18px + env(safe-area-inset-top)); inset-inline-end: calc(18px + env(safe-area-inset-right)); width: 42px; height: 42px; display: grid; place-items: center; border: 1px solid var(--line-strong); border-radius: 999px; background: rgba(19, 24, 32, .88); color: var(--ink-strong); cursor: pointer; }
.detail-modal-close svg { width: 18px; height: 18px; }
.detail-modal-close:hover { border-color: var(--accent); color: var(--accent-dark); }
.detail-modal-body { height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; min-height: 0; }
.detail-modal-image { flex: 1 1 auto; min-height: 0; display: grid; place-items: center; width: 100%; }
.detail-modal-image img { max-width: 100%; max-height: calc(100dvh - 190px); display: block; object-fit: contain; border-radius: 8px; background: #111318; }
.detail-modal-caption { flex: 0 0 auto; max-width: min(900px, 100%); margin: 0; display: flex; flex-wrap: wrap; align-items: baseline; justify-content: center; gap: 4px 14px; color: var(--muted); font-size: 12px; text-align: center; }
.detail-prompt { color: var(--muted); }
.detail-model { color: var(--accent-dark); font-weight: 700; }
.detail-modal-actions { flex: 0 0 auto; display: flex; justify-content: center; gap: 10px; }
.detail-action { min-height: 42px; display: inline-flex; align-items: center; justify-content: center; gap: 7px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-soft); padding: 0 14px; color: var(--ink); font-size: 13px; font-weight: 700; cursor: pointer; transition: border-color 180ms, background-color 180ms; }
.detail-action svg { width: 16px; height: 16px; }
.detail-action:hover { border-color: var(--accent); }
.detail-action-primary { border-color: var(--accent); background: var(--accent); color: #fff; }
.detail-action-primary:hover { background: var(--accent-hover); color: #fff; }
.detail-action-danger { color: var(--danger); }
.detail-action-danger:hover { border-color: var(--danger); background: rgba(232,154,160,.1); }

/* Prompt collection library */
.prompt-library-modal { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; background: rgba(6,8,12,.94); padding: 24px; animation: lightbox-in 180ms cubic-bezier(.16,1,.3,1); }
.prompt-library-panel { width: min(760px, calc(100% - 32px)); height: min(82dvh, 900px); display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); box-shadow: var(--shadow); overflow: hidden; }
.prompt-library-header { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px 12px; border-bottom: 1px solid var(--line); }
.prompt-library-header h3 { margin: 0; color: var(--ink-strong); font-size: 15px; font-weight: 750; }
.prompt-library-header .detail-modal-close { position: static; width: 36px; height: 36px; border-radius: 10px; background: var(--surface-soft); border-color: var(--line); color: var(--ink); }
.prompt-library-search { padding: 12px 18px 4px; }
.prompt-library-search input { width: 100%; min-height: 40px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-soft); padding: 0 12px; color: var(--ink); font-size: 13px; }
.prompt-library-categories { display: flex; flex-wrap: nowrap; gap: 6px; padding: 10px 18px; border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: thin; }
.prompt-library-chip { flex: 0 0 auto; min-height: 34px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface-soft); padding: 0 12px; color: var(--muted); font-size: 12px; font-weight: 700; white-space: nowrap; }
.prompt-library-chip:hover { border-color: var(--accent); color: var(--accent-dark); }
.prompt-library-chip.is-active { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-dark); }
.prompt-library-list { flex: 1 1 auto; min-height: 0; display: grid; align-content: start; gap: 10px; padding: 14px 18px 18px; overflow-y: auto; }
.prompt-library-card { display: grid; gap: 8px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-soft); padding: 12px 14px; }
.prompt-library-card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.prompt-library-card-title { color: var(--ink-strong); font-size: 13px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.prompt-library-card-category { flex: 0 0 auto; color: var(--subtle); font-size: 11px; }
.prompt-library-card-text { margin: 0; max-height: 4.4em; overflow: hidden; color: var(--muted); font-size: 12px; line-height: 1.45; overflow-wrap: anywhere; }
.prompt-library-use { justify-self: start; min-height: 38px; padding: 0 14px; }
.prompt-library-empty { margin: 8px 0; color: var(--muted); font-size: 13px; }

/* Credits panel */
.credits-panel { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; background: rgba(6,8,12,.94); padding: 24px; animation: lightbox-in 180ms cubic-bezier(.16,1,.3,1); }
.credits-panel-inner { width: min(400px, calc(100% - 32px)); max-height: calc(100dvh - 48px); overflow-y: auto; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); box-shadow: var(--shadow); }
.credits-panel-header { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px 14px; border-bottom: 1px solid var(--line); }
.credits-panel-header h3 { margin: 0; color: var(--ink-strong); font-size: 15px; font-weight: 750; text-transform: uppercase; letter-spacing: .04em; }
.credits-balance { padding: 20px; border-bottom: 1px solid var(--line); }
.credits-balance p { margin: 0 0 4px; color: var(--muted); font-size: 12px; }
.credits-balance strong { display: block; color: var(--ink-strong); font-size: 24px; font-variant-numeric: tabular-nums; }
.credits-history { padding: 16px 20px; }
.credits-history h4 { margin: 0 0 12px; color: var(--ink-strong); font-size: 13px; font-weight: 700; }
.credits-entry { display: flex; align-items: baseline; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.credits-entry:last-child { border-bottom: 0; }
.credits-amount { color: var(--danger); font-size: 13px; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.credits-desc { flex: 1; color: var(--ink); font-size: 13px; }
.credits-time { color: var(--subtle); font-size: 11px; white-space: nowrap; }
.credits-empty { color: var(--muted); font-size: 13px; }
.credits-topup { padding: 12px 20px; border-top: 1px solid var(--line); }
.credits-topup a { display: inline-flex; align-items: center; gap: 6px; color: var(--accent-dark); font-size: 13px; font-weight: 700; text-decoration: underline; text-underline-offset: .2em; }
.credits-topup svg { width: 16px; height: 16px; flex: 0 0 auto; }

@media (max-width: 640px) {
  .gallery-filters { flex-direction: column; }
  .gallery-filter { width: 100%; }
}
