.header-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}
.brand-wordmark {
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
  font-family: 'Manrope', sans-serif;
  font-size: clamp(20px, 2.2vw, 26px);
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: -0.055em;
  color: #f1f5f9;
}
.brand-wordmark-accent {
  color: #c7d2fe;
}
.brand-ai {
  margin-left: 9px;
  padding: 5px 6px;
  border: 1px solid #8796c34d;
  border-radius: 6px;
  background: #b5c4ef0d;
  color: #cbd8f5;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
  line-height: 1;
}
.brand-emblem {
  display: block;
  width: 40px;
  height: 40px;
  aspect-ratio: 1;
  flex-shrink: 0;
  border-radius: 50%;
  object-fit: contain;
}
html,
body {
  height: 100%;
  height: 100dvh;
  overflow-x: hidden;
}
main {
  min-width: 0;
}
button:focus-visible,
select:focus-visible,
textarea:focus-visible,
input:focus-visible,
a:focus-visible {
  outline: 2px solid #a5b4fc;
  outline-offset: 3px;
}
button:disabled {
  opacity: 0.5;
  cursor: wait;
}
#chat-messages > div {
  min-width: 0;
  overflow-wrap: anywhere;
}
#workspace-layout,
#workspace-chat,
#chat-messages {
  width: 100%;
  max-width: 100%;
  min-width: 0;
}
.chat-message-bubble {
  flex: 1 1 0%;
  min-width: 0;
  max-width: 100%;
  writing-mode: horizontal-tb;
  white-space: pre-wrap;
  word-break: normal;
}
#chat-messages > div > button {
  flex-shrink: 0;
}
#chat-messages pre {
  white-space: pre-wrap;
}
#bank-details {
  white-space: pre-wrap;
}
#toast {
  pointer-events: none;
  max-width: calc(100vw - 2rem);
}
[hidden] {
  display: none !important;
}
#agent-list > button {
  text-align: left;
  width: 100%;
}
@media (max-width: 767px) {
  header {
    height: auto !important;
    min-height: 4rem;
    flex-wrap: wrap;
    gap: 0.75rem;
    padding: 0.75rem !important;
  }
  header > div:last-child {
    gap: 0.4rem !important;
  }
  #workspace-chat > div:first-child {
    height: auto;
    min-height: 5rem;
    align-items: flex-start;
    flex-direction: column;
    gap: 0.5rem;
    padding: 0.65rem 0.75rem;
  }
  #current-agent-desc {
    font-size: 10px;
  }
  #chat-messages {
    padding: 0.75rem;
  }
  #chat-messages > div {
    gap: 0.5rem;
  }
  #chat-messages > div,
  .chat-message-bubble {
    width: 100%;
    max-width: 100%;
    min-width: 0;
  }
  #chat-input {
    padding-right: 0.75rem;
    padding-bottom: 4rem;
    min-height: 7rem;
  }
  #workspace-chat form > div {
    bottom: 0.6rem;
  }
  #workspace-chat > div:last-child {
    padding: 0.75rem;
  }
  #workspace-media {
    padding: 0.75rem;
  }
  #workspace-media .glass-panel {
    padding: 1rem;
  }
  #brand-tagline {
    display: none;
  }
}
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
}

#media-gallery.motion-preview article { overflow: hidden; }
#media-gallery.motion-preview article img { animation: kenBurnsMotion 8s ease-in-out infinite; }
@media (prefers-reduced-motion: reduce) {
  #media-gallery.motion-preview article img { animation: none !important; }
}

/* Refined dark surfaces, with opaque foundations for consistent contrast. */
:root {
  color-scheme: dark;
  --surface-gradient: linear-gradient(135deg, #1b2940, #141d30 65%, #192139);
  --primary-gradient: linear-gradient(115deg, #4338a3, #493bb0 48%, #37308b);
}
body.bg-dark-900,
body > div > main {
  background: radial-gradient(ellipse at 88% 0%, #202542, transparent 58%),
    radial-gradient(ellipse at 10% 100%, #102731, transparent 55%),
    linear-gradient(155deg, #101827, #0b101b 75%);
}
body > header {
  background: linear-gradient(110deg, #172138, #11192b 65%, #1b2036);
}
#sidebar {
  background: radial-gradient(ellipse at 0% 0%, #222b47, transparent 65%),
    linear-gradient(175deg, #151e30, #0f1726);
}
#sidebar > div:last-child,
#workspace-chat > div:first-child,
#workspace-chat > div:last-child {
  background: linear-gradient(110deg, #172135, #121b2d);
}
body .glass-panel,
#chat-messages .bg-dark-800,
#credit-modal .bg-dark-800,
#credit-modal [class~="bg-dark-700/80"],
#toast {
  background: var(--surface-gradient);
  box-shadow: inset 0 1px 0 #dbe7ff08, 0 8px 24px #03071126;
}
#chat-messages [class~="bg-indigo-600/20"],
#agent-list [class~="bg-indigo-600/20"] {
  background: linear-gradient(120deg, #2c2e56, #1c2842);
}
#agent-list [class~="bg-dark-700/50"] {
  background: linear-gradient(120deg, #1e2a3d, #192236);
}
#agent-list [class~="bg-dark-700/50"]:hover {
  background: linear-gradient(120deg, #29364d, #222d45);
}
body button.bg-indigo-600,
body button[onclick="generateMediaContent()"],
#credit-modal span.bg-indigo-600 {
  background: var(--primary-gradient);
  background-size: 180% 100%;
  color: #fff;
}
body button.bg-amber-600 {
  background: linear-gradient(115deg, #854509, #92520e, #713f12);
  background-size: 180% 100%;
  color: #fff;
}
body button.bg-emerald-600 {
  background: linear-gradient(115deg, #065f46, #07684f, #115e59);
  background-size: 180% 100%;
  color: #fff;
}
body button,
#brand-tagline,
#msg-cost-badge,
#credit-modal span.bg-indigo-600 {
  transition: background-position 220ms ease, background-color 180ms ease,
    border-color 180ms ease, color 180ms ease, box-shadow 180ms ease;
}
body button:is(.bg-indigo-600, .bg-amber-600, .bg-emerald-600, [onclick="generateMediaContent()"]):hover:not(:disabled),
#credit-modal span.bg-indigo-600:hover {
  background-position: 70% 50%;
  box-shadow: inset 0 0 0 1px #ffffff35;
}
body button:is(.bg-indigo-600, .bg-amber-600, .bg-emerald-600, [onclick="generateMediaContent()"]):active:not(:disabled) {
  background-position: 100% 50%;
  box-shadow: inset 0 2px 5px #05081655;
}
#brand-tagline,
#msg-cost-badge,
header button[onclick="openCreditModal()"],
#thinking-mode-btn,
#credit-modal [class~="bg-emerald-500/15"] {
  background: linear-gradient(115deg, #25314b, #1d283e, #2e3653);
  background-size: 180% 100%;
}
#thinking-mode-btn[class~="bg-amber-500/20"] {
  background-image: linear-gradient(115deg, #49331c, #322b25, #50391f);
}
#brand-tagline:hover,
#msg-cost-badge:hover,
header button[onclick="openCreditModal()"]:hover,
#thinking-mode-btn:hover {
  background-position: 100% 50%;
}
body :is(input, textarea, select) {
  background: linear-gradient(120deg, #202c40, #1b2639);
  color: #f1f5f9;
  border-color: #78869e;
}
body select option {
  background: #1b2639;
  color: #f1f5f9;
}
body :is(input, textarea)::placeholder {
  color: #abb8cd;
  opacity: 1;
}
/* Small copy stays readable at the lightest point of the dark surfaces. */
body .text-slate-500,
body .text-slate-400 { color: #abb8cd; }
body .text-indigo-400 { color: #b3baff; }
body .text-violet-400 { color: #c4b5fd; }
body :is(button, input, textarea, select, a, [tabindex]):focus-visible {
  outline: 2px solid #c7d2fe;
  outline-offset: 3px;
}
@media (prefers-reduced-motion: reduce) {
  body button,
  #brand-tagline,
  #msg-cost-badge,
  #credit-modal span.bg-indigo-600 { transition: none !important; }
}
@media (forced-colors: active) {
  body button,
  body :is(input, textarea, select) { border: 1px solid ButtonText; }
}

/* Workspace navigation stays above both the history and the active tool. */
.agents-bar { display: flex; align-items: center; gap: 12px; flex-shrink: 0; min-width: 0; padding: 0 16px; background: #111b2c; border-bottom: 1px solid #2a3548; }
#history-toggle { flex: 0 0 36px; height: 36px; border: 1px solid #3b4960; border-radius: 9px; color: #bdc9dc; }
#history-toggle:hover { background: #26334a; color: #fff; }
#agent-list { display: flex; flex: 1 1 0%; gap: 6px; overflow-x: auto; min-width: 0; max-width: 100%; padding: 9px 2px; overscroll-behavior-x: contain; -webkit-overflow-scrolling: touch; }
#agent-list > .agent-tab { width: auto; flex: 0 0 auto; display: flex; align-items: center; gap: 9px; padding: 11px 16px; border-radius: 8px; border: 1px solid transparent; color: #b2bfd3; font-size: 12px; font-weight: 500; white-space: nowrap; background: transparent; }
#agent-list > .agent-tab:hover { background: #202d42; color: #f1f5f9; }
#agent-list > .agent-tab[aria-selected="true"] { background: #2a2e50; border-color: #6666a0; color: #e0e2ff; }
#sidebar { width: 264px; min-height: 0; transition: none; }
.history-heading { padding: 20px 16px 8px; }
.new-chat-button { display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%; border: 1px solid #646499; background: #343359; border-radius: 10px; padding: 12px; font-size: 13px; font-weight: 600; }
.new-chat-button:hover { background: #42416c; }
#sidebar-title { margin: 24px 6px 8px; font-size: 10px; text-transform: uppercase; letter-spacing: .14em; font-weight: 600; color: #9aabc4; }
#history-list { flex: 1; overflow-y: auto; min-height: 0; padding: 0 10px 16px; }
.history-status { padding: 12px; font-size: 12px; line-height: 1.7; color: #9aabc4; }
.history-item { display: flex; flex-direction: column; gap: 6px; width: 100%; text-align: left; padding: 12px; margin-bottom: 4px; border: 1px solid transparent; border-radius: 9px; }
.history-item span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; font-size: 12px; color: #d5dfef; }
.history-item time { font-size: 10px; color: #96a6be; }
.history-item:hover { background: #222e43; }
.history-item[aria-current="true"] { background: #292e49; border-color: #484f70; }
#workspace-layout main { background: #0f1726; }
#chat-messages { min-height: 0; }
#workspace-chat:has(#chat-messages:empty) #chat-toolbar,
#chat-footer-note { display: none; }
#workspace-chat > #chat-composer { background: transparent; }
#chat-composer form { max-width: none; }
#chat-composer { padding: 20px clamp(16px, 4vw, 64px) 28px; }
#chat-input { min-height: 58px; }
#workspace-chat:has(#chat-messages:empty) #chat-composer { margin-block: auto; }
#workspace-chat:has(#chat-messages:empty) #chat-messages { flex: 0; padding: 0; }
@media (max-width: 767px) {
  .agents-bar { padding: 0 10px; gap: 8px; }
  #agent-list > .agent-tab { padding: 10px 12px; }
  #sidebar { position: absolute; inset: 0 auto 0 0; width: min(280px, 85vw); box-shadow: 12px 0 32px #050a1466; }
  #sidebar-title, #new-chat-btn, #tab-chat-text, #tab-media-text { display: inline; }
  #chat-composer { padding: 12px; }
  #chat-input { min-height: 112px; }
}

#workspace-layout, #workspace-chat { min-height: 0; }
#msg-cost-badge { display: none !important; }
#chat-input { padding-left: 3.2rem !important; }
#attach-button { z-index: 2; }
#attachment-chip:not([hidden]) { display: flex; gap: .5rem; align-items: center; overflow-wrap: anywhere; padding: .5rem .8rem; border: 1px solid #475569; border-radius: .8rem; }
.creator-plan { display: flex; flex-direction: column; gap: .7rem; padding: 1.2rem; border: 1px solid #475569; border-radius: 1rem; background: #192432; }
.creator-plan h4 { font-weight: 700; color: #e2e8f0; }
.creator-plan strong { font-size: 1.8rem; color: #a7f3d0; }
.creator-plan p { font-size: .75rem; color: #cbd5e1; }
.creator-plan button { margin-top: auto; padding: .7rem; border-radius: .6rem; background: #354d78; color: #fff; }
.creator-plan button:hover { background: #456191; }
.creator-plan button:focus-visible, #attach-button:focus-visible { outline: 2px solid #a7f3d0; outline-offset: 3px; }

.generation-frame { position: relative; isolation: isolate; overflow: hidden; background: #16252e; }
.generation-art { position: absolute; inset: -25%; background: radial-gradient(ellipse at 30% 35%, #cda67d 0%, transparent 40%), radial-gradient(ellipse at 70% 60%, #608c88 0%, transparent 45%), radial-gradient(ellipse at 45% 80%, #496486 0%, transparent 50%); filter: blur(25px); animation: studio-compose 9s ease-in-out infinite alternate; }
.generation-frame::after { content: ""; position: absolute; inset: 0; pointer-events: none; background: linear-gradient(110deg, transparent 20%, #eef4ed24 48%, transparent 75%); transform: translateX(-100%); animation: studio-shimmer 3.6s ease-in-out infinite; }
.generation-status { position: absolute; z-index: 2; inset: auto 16px 16px; padding: 14px 16px; border: 1px solid #d2dfdb30; border-radius: 12px; background: #12212bd9; color: #eef2ee; }
.generation-status strong, .generation-status span { display: block; }
.generation-status strong { font-size: .875rem; font-weight: 600; }
.generation-status span { margin-top: 5px; font-size: .7rem; color: #c0cecc; }
.generation-status::before { content: ""; display: block; height: 2px; margin-bottom: 12px; background: linear-gradient(90deg, transparent, #d8c09f, #99c3b6, transparent); transform-origin: left; animation: studio-pulse 2.4s ease-in-out infinite alternate; }
.generation-frame > img { position: absolute; z-index: 1; inset: 0; height: 100%; opacity: 0; transition: opacity .8s ease; }
.generation-frame.is-ready > img { opacity: 1; }
.generation-frame.is-ready .generation-status, .generation-frame.is-ready .generation-art { opacity: 0; transition: opacity .8s ease; pointer-events: none; }
.generation-frame.is-ready .generation-art, .generation-frame.is-ready::after { animation: none; }
.generation-frame.is-ready::after { display: none; }
@keyframes studio-compose { from { transform: rotate(-12deg) scale(1); } to { transform: rotate(18deg) scale(1.3) translate(4%, -5%); } }
@keyframes studio-shimmer { to { transform: translateX(100%); } }
@keyframes studio-pulse { from { transform: scaleX(.35); opacity: .5; } to { transform: scaleX(1); opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
  .generation-art, .generation-frame::after, .generation-status::before { animation: none; }
  .generation-frame > img, .generation-frame.is-ready .generation-status, .generation-frame.is-ready .generation-art { transition: none; }
}
