:root {
  color-scheme: dark;
  --bg: #000000;
  --surface: #0a0a0a;
  --surface-2: #111111;
  --surface-3: #1a1a1a;
  --line: #1e1e1e;
  --line-soft: rgba(255, 255, 255, 0.06);
  --text: #f0f0f0;
  --muted: #888888;
  --faint: #555555;
  --accent: #3b82f6;
  --accent-dim: rgba(59, 130, 246, 0.15);
  --accent-glow: rgba(59, 130, 246, 0.35);
  --accent-soft: rgba(59, 130, 246, 0.08);
  --green: #3b82f6;
  --radius: 14px;
  --shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  overflow-x: hidden;
  background:
    radial-gradient(ellipse at 20% 0%, rgba(59, 130, 246, 0.07) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 100%, rgba(59, 130, 246, 0.04) 0%, transparent 50%),
    radial-gradient(circle at 50% 50%, rgba(59, 130, 246, 0.02) 0%, transparent 80%),
    #000000;
  background-attachment: fixed;
  color: var(--text);
  font-family: "SF Pro Display", Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0.01em;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -1;
  background-image:
    radial-gradient(circle at center, rgba(59, 130, 246, 0.04) 1px, transparent 1px);
  background-size: 32px 32px;
  pointer-events: none;
  mask-image: radial-gradient(ellipse at 50% 50%, black 30%, transparent 80%);
  -webkit-mask-image: radial-gradient(ellipse at 50% 50%, black 30%, transparent 80%);
}

body.auth-pending .app-frame,
body.is-logged-out .app-frame {
  display: none;
}

body.is-authenticated .login-screen {
  display: none;
}

.login-screen {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 22px;
}

.login-card {
  width: min(440px, 100%);
  display: grid;
  gap: 18px;
  padding: 28px;
  background: rgba(6, 6, 12, 0.92);
  border: 1px solid rgba(59, 130, 246, 0.12);
  border-radius: 18px;
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.login-card h1 {
  margin: 0;
  font-size: 28px;
  line-height: 1.12;
}

.login-copy,
.login-error {
  margin: 10px 0 0;
  color: var(--muted);
  line-height: 1.6;
}

.login-error {
  margin: 0;
  color: #fca5a5;
}

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

button,
select,
input,
textarea {
  max-width: 100%;
}

button {
  cursor: pointer;
}

select,
input,
textarea {
  width: 100%;
  color: var(--text);
  background: #0a0a0a;
  border: 1px solid #222222;
  border-radius: 10px;
  outline: none;
}

select,
input {
  min-height: 42px;
  padding: 0 12px;
}

textarea {
  padding: 12px;
  resize: vertical;
  line-height: 1.5;
}

select:focus,
input:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-dim);
}

code {
  color: #cccccc;
}

::-webkit-scrollbar {
  width: 9px;
  height: 9px;
}

::-webkit-scrollbar-track {
  background: #050505;
}

::-webkit-scrollbar-thumb {
  background: #333333;
  border-radius: 999px;
}

.app-frame {
  min-height: 100dvh;
  display: grid;
  grid-template-rows: auto 1fr;
  min-width: 0;
  max-width: 100vw;
  overflow-x: hidden;
  will-change: contents;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 18px;
  padding: 16px 22px;
  background: rgba(2, 2, 8, 0.92);
  border-bottom: 1px solid rgba(59, 130, 246, 0.1);
  backdrop-filter: blur(28px) saturate(1.4);
  -webkit-backdrop-filter: blur(28px) saturate(1.4);
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--accent);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  overflow-wrap: anywhere;
}

.hero-panel h2,
.panel-head h2,
.chat-header h2,
.history-panel h3,
.results-panel h3 {
  margin: 0;
}

.primary-tabs {
  display: flex;
  align-items: center;
  justify-self: start;
  gap: 6px;
  padding: 5px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 999px;
}

.tab-button,
.mobile-tab,
.icon-button,
.primary-button,
.secondary-button,
.ghost-button,
.send-button,
.link-button {
  border: 0;
}

.tab-button {
  min-height: 36px;
  padding: 0 14px;
  color: var(--muted);
  background: transparent;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 800;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.tab-button:hover {
  color: var(--accent);
  background: var(--accent-soft);
}

.tab-button.is-active,
.mobile-tab.is-active {
  color: #ffffff;
  background: var(--accent);
  box-shadow: 0 0 14px var(--accent-glow);
}

.top-actions {
  display: flex;
  justify-self: end;
  justify-content: flex-end;
  align-items: center;
  gap: 10px;
}

.user-pill {
  max-width: 150px;
  padding: 8px 10px;
  overflow: hidden;
  color: #dbeafe;
  background: rgba(59, 130, 246, 0.12);
  border: 1px solid rgba(59, 130, 246, 0.18);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 850;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.compact-action {
  min-height: 34px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 12px;
}

.connection-chip {
  min-width: 70px;
  padding: 8px 10px;
  text-align: center;
  color: #ffffff;
  background: var(--accent);
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  box-shadow: 0 0 12px var(--accent-dim);
}

.connection-chip.live {
  background: var(--accent);
}

.connection-chip.warn {
  background: #333333;
  color: #888888;
  box-shadow: none;
}

.icon-button {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--line-soft);
  border-radius: 14px;
  transition: all 0.2s ease;
}

.icon-button:hover {
  border-color: rgba(59, 130, 246, 0.3);
  box-shadow: 0 0 12px var(--accent-dim);
  transform: scale(1.05);
}

.workspace {
  min-height: 0;
  min-width: 0;
  max-width: 100%;
  overflow-x: hidden;
  padding: 22px;
}

.view {
  min-width: 0;
  max-width: 100%;
  min-height: calc(100dvh - 108px);
}

.view:not(.view-dashboard):not(.view-chat) {
  display: grid;
  grid-template-columns: minmax(330px, 430px) minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}

.is-hidden {
  display: none !important;
}

.hero-panel,
.history-panel,
.studio-panel,
.results-panel,
.chat-layout {
  min-width: 0;
  max-width: 100%;
  width: 100%;
  background: rgba(6, 6, 12, 0.88);
  border: 1px solid rgba(59, 130, 246, 0.08);
  border-radius: var(--radius);
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255, 255, 255, 0.03);
  backdrop-filter: blur(24px) saturate(1.3);
  -webkit-backdrop-filter: blur(24px) saturate(1.3);
  animation: fadeSlideUp 0.5s cubic-bezier(0.16, 1, 0.3, 1) both;
  position: relative;
}

.hero-panel::before,
.history-panel::before,
.studio-panel::before,
.results-panel::before {
  content: '';
  position: absolute;
  top: -1px;
  left: 20px;
  right: 20px;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(59, 130, 246, 0.2), transparent);
  pointer-events: none;
}

.hero-panel {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(260px, 0.75fr);
  gap: 18px;
  align-items: end;
  padding: clamp(22px, 4vw, 42px);
  overflow: hidden;
}

.hero-panel h2 {
  max-width: 780px;
  font-size: clamp(30px, 4.1vw, 52px);
  line-height: 1.03;
  letter-spacing: -0.02em;
  word-break: break-word;
  background: linear-gradient(135deg, #ffffff 0%, #a0c4ff 50%, #ffffff 100%);
  background-size: 200% 100%;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: shimmerText 6s ease-in-out infinite;
}

.hero-copy {
  max-width: 760px;
  margin: 18px 0 0;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.65;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  min-width: 0;
}

.metric-card {
  min-height: 104px;
  padding: 16px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(59, 130, 246, 0.06);
  border-radius: 16px;
  transition: all 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
  overflow: hidden;
}

.metric-card::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  opacity: 0;
  transition: opacity 0.35s ease;
}

.metric-card:hover {
  border-color: rgba(59, 130, 246, 0.2);
  background: rgba(59, 130, 246, 0.05);
  transform: translateY(-3px);
  box-shadow: 0 8px 24px rgba(59, 130, 246, 0.08);
}

.metric-card:hover::after {
  opacity: 1;
}

.metric-card span {
  display: block;
  color: #ffffff;
  font-size: 34px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}

.metric-card p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-top: 18px;
  min-width: 0;
}

.action-tile {
  min-width: 0;
  min-height: 146px;
  padding: 20px;
  text-align: left;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: 18px;
  transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}

.action-tile::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 50% 120%, var(--accent-soft) 0%, transparent 70%);
  opacity: 0;
  transition: opacity 0.35s ease;
}

.action-tile:hover::before {
  opacity: 1;
}

.action-tile:hover {
  transform: translateY(-4px) scale(1.01);
  border-color: rgba(59, 130, 246, 0.35);
  box-shadow: 0 12px 40px rgba(59, 130, 246, 0.12), 0 0 0 1px rgba(59, 130, 246, 0.1);
}

.action-tile:nth-child(1) { animation: fadeSlideUp 0.4s ease-out 0.1s both; }
.action-tile:nth-child(2) { animation: fadeSlideUp 0.4s ease-out 0.2s both; }
.action-tile:nth-child(3) { animation: fadeSlideUp 0.4s ease-out 0.3s both; }
.action-tile:nth-child(4) { animation: fadeSlideUp 0.4s ease-out 0.4s both; }

.action-tile span {
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.action-tile strong {
  display: block;
  margin-top: 18px;
  font-size: 20px;
  line-height: 1.25;
}

.history-panel {
  margin-top: 18px;
  padding: 20px;
}

.section-title,
.panel-head,
.chat-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
}

.panel-head select,
.panel-head input {
  width: min(220px, 100%);
  flex-shrink: 0;
}

.timeline {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.timeline-item {
  display: grid;
  grid-template-columns: 76px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 12px;
  animation: fadeSlideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1) both;
  background: rgba(255, 255, 255, 0.025);
  border: 1px solid rgba(59, 130, 246, 0.06);
  border-radius: 14px;
  transition: all 0.25s ease;
}

.timeline-item:hover {
  background: rgba(59, 130, 246, 0.04);
  border-color: rgba(59, 130, 246, 0.15);
}

.timeline-item span,
.timeline-item em {
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
}

.timeline-item strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.empty-copy,
.empty-state {
  color: var(--faint);
}

.studio-panel,
.results-panel {
  padding: 20px;
}

.studio-panel {
  position: sticky;
  top: 92px;
  display: grid;
  gap: 16px;
  max-height: calc(100dvh - 122px);
  overflow-y: auto;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.field {
  display: grid;
  gap: 8px;
}

.field-wide {
  grid-column: 1 / -1;
}

.field-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
}

.field > span,
.field-line > span,
.check-row span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.field-line em {
  min-width: 0;
  overflow: hidden;
  color: var(--faint);
  font-size: 12px;
  font-style: normal;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ratio-toggle {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.video-ratio-toggle {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.ratio-choice {
  position: relative;
  display: grid;
  gap: 4px;
  min-height: 58px;
  padding: 10px 12px;
  align-content: center;
  background: rgba(255, 255, 255, 0.025);
  border: 1px solid #222222;
  border-radius: 10px;
  cursor: pointer;
  transition: border-color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
}

.ratio-choice input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.ratio-choice span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 850;
}

.ratio-choice strong {
  color: var(--text);
  font-size: 18px;
  line-height: 1;
}

.ratio-choice:hover {
  border-color: rgba(59, 130, 246, 0.3);
}

.ratio-choice.is-selected,
.ratio-choice:has(input:checked) {
  background: rgba(59, 130, 246, 0.12);
  border-color: rgba(59, 130, 246, 0.65);
  box-shadow: 0 0 0 1px rgba(59, 130, 246, 0.18);
}

.ratio-choice.is-selected span,
.ratio-choice:has(input:checked) span {
  color: #93c5fd;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
}

.check-row input {
  width: 18px;
  height: 18px;
  min-height: 18px;
  accent-color: var(--accent);
}

.switch-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.upload-zone {
  position: relative;
  min-height: 128px;
  display: grid;
  place-items: center;
  padding: 12px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px dashed rgba(59, 130, 246, 0.2);
  border-radius: 16px;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.upload-zone:hover {
  border-color: var(--accent);
  box-shadow: 0 0 16px var(--accent-dim);
}

.upload-zone input,
.composer-input input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.upload-empty {
  color: var(--muted);
  font-size: 13px;
}

.preview-grid {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.preview-grid img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border: 1px solid var(--line-soft);
  border-radius: 10px;
}

.soft-disabled {
  opacity: 0.58;
}

.field.is-required > span::after {
  content: " *";
  color: var(--danger);
}

.primary-button,
.secondary-button,
.ghost-button,
.send-button {
  min-height: 42px;
  border-radius: 12px;
  font-weight: 900;
}

.primary-button {
  width: 100%;
  color: #ffffff;
  background: var(--accent);
  box-shadow: 0 0 18px var(--accent-glow);
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.primary-button:hover {
  background: #5b9aff;
  box-shadow: 0 0 28px var(--accent-glow), 0 4px 16px rgba(59, 130, 246, 0.25);
  transform: translateY(-1px);
}

.primary-button:active {
  transform: translateY(1px) scale(0.98);
  box-shadow: 0 0 10px var(--accent-dim);
}

.secondary-button {
  padding: 0 14px;
  color: #ffffff;
  background: rgba(59, 130, 246, 0.2);
  border: 1px solid rgba(59, 130, 246, 0.3);
}

.ghost-button {
  padding: 0 14px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--line-soft);
  transition: all 0.2s ease;
}

.ghost-button:hover {
  border-color: rgba(59, 130, 246, 0.25);
  background: rgba(59, 130, 246, 0.06);
}

.primary-button:disabled,
.secondary-button:disabled,
.send-button:disabled {
  cursor: wait;
  opacity: 0.62;
}

.asset-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 16px;
  margin-top: 16px;
  min-width: 0;
}

.video-output-grid {
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
}

.asset-card {
  min-width: 0;
  overflow: hidden;
  background: #0a0a0a;
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 14px;
  transition: all 0.3s ease;
  animation: fadeSlideUp 0.4s ease-out both;
}

.asset-card:hover {
  border-color: rgba(59, 130, 246, 0.2);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.3), 0 0 0 1px rgba(59, 130, 246, 0.08);
  transform: translateY(-2px);
}

.asset-media {
  position: relative;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: #050505;
}

.portrait-media {
  aspect-ratio: 9 / 16;
}

.landscape-media {
  aspect-ratio: 16 / 9;
}

.square-media {
  aspect-ratio: 1 / 1;
}

.poster-media {
  aspect-ratio: 3 / 4;
}

.product-media {
  aspect-ratio: 4 / 5;
}

.cinema-media {
  aspect-ratio: 21 / 9;
}

.image-result-stack {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(0, 1fr));
  gap: 2px;
}

.image-thumb-button {
  width: 100%;
  height: 100%;
  padding: 0;
  overflow: hidden;
  background: transparent;
  border: 0;
}

.asset-media img,
.asset-media video {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.image-result-stack img,
.image-thumb-button img {
  object-fit: cover;
}

.loader {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--muted);
  text-align: center;
  padding: 18px;
}

.spinner {
  width: 34px;
  height: 34px;
  border: 2px solid rgba(59, 130, 246, 0.15);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.asset-body {
  display: grid;
  gap: 10px;
  padding: 13px;
}

.asset-topline {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
}

.asset-title {
  min-width: 0;
  overflow: hidden;
  color: #e0e0e0;
  font-size: 13px;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status-badge {
  flex: 0 0 auto;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 900;
}

.status-running {
  color: var(--accent);
  background: var(--accent-dim);
}

.status-success {
  color: #a0d0ff;
  background: rgba(59, 130, 246, 0.12);
}

.status-failed {
  color: #999999;
  background: rgba(255, 255, 255, 0.05);
}

.prompt-text {
  display: -webkit-box;
  overflow: hidden;
  color: #999999;
  text-align: left;
  line-height: 1.45;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.prompt-text.is-open {
  display: block;
}

.asset-meta,
.error-box {
  color: var(--muted);
  font-size: 12px;
}

.asset-meta {
  line-height: 1.45;
}

.asset-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.link-button {
  padding: 0;
  color: var(--accent);
  background: transparent;
  font-size: 12px;
  font-weight: 800;
  text-decoration: none;
}

.link-button:hover {
  color: #5b9aff;
}

.danger-link {
  color: #fca5a5;
}

.danger-link:hover {
  color: #fecaca;
}

.error-box {
  padding: 8px;
  color: #bbbbbb;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  overflow-wrap: anywhere;
}

.chat-layout {
  height: calc(100dvh - 108px);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  overflow: hidden;
  border: 1px solid rgba(59, 130, 246, 0.08);
}

/* ═══════ Analysis View ═══════ */

.analyze-modes {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.analyze-mode-btn {
  padding: 12px 16px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 12px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.analyze-mode-btn:hover {
  color: var(--text);
  background: rgba(59, 130, 246, 0.04);
  border-color: rgba(59, 130, 246, 0.15);
}

.analyze-mode-btn.is-active {
  color: #ffffff;
  background: rgba(59, 130, 246, 0.12);
  border-color: rgba(59, 130, 246, 0.35);
  box-shadow: 0 0 14px rgba(59, 130, 246, 0.08);
}

.analyze-upload {
  min-height: 200px;
  display: grid;
  place-items: center;
  text-align: center;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.analyze-upload:hover {
  border-color: var(--accent);
  background: rgba(59, 130, 246, 0.03);
  box-shadow: 0 0 20px rgba(59, 130, 246, 0.06);
}

.upload-icon {
  font-size: 28px;
  margin-bottom: 8px;
  opacity: 0.5;
}

.upload-hint {
  color: var(--faint);
  font-size: 12px;
  margin-top: 4px;
}

.analyze-preview {
  width: 100%;
  display: grid;
  place-items: center;
  padding: 8px;
}

.analyze-preview img,
.analyze-preview video {
  max-width: 100%;
  max-height: 320px;
  border-radius: 10px;
  border: 1px solid var(--line-soft);
  object-fit: contain;
}

.analyze-preview img { display: block; }
.analyze-preview video { display: none; }
.analyze-preview.is-video img { display: none; }
.analyze-preview.is-video video { display: block; }

.analyze-result-card {
  padding: 20px;
  background: rgba(59, 130, 246, 0.04);
  border: 1px solid rgba(59, 130, 246, 0.12);
  border-radius: 14px;
  line-height: 1.7;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 14px;
  animation: fadeSlideUp 0.4s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.analyze-result-card h4 {
  margin: 0 0 12px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.analyze-result-card .prompt-block {
  margin-top: 14px;
  padding: 14px;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(59, 130, 246, 0.08);
  border-radius: 10px;
  font-family: "SF Mono", "Fira Code", monospace;
  font-size: 13px;
  line-height: 1.6;
}


.chat-header {
  padding: 18px 20px;
  border-bottom: 1px solid var(--line-soft);
}

.chat-header select,
.chat-header input {
  width: min(280px, 100%);
}

.chat-history {
  display: flex;
  flex-direction: column;
  gap: 16px;
  overflow-y: auto;
  padding: 22px;
  scroll-behavior: smooth;
}

.chat-empty {
  margin-top: 44px;
  color: var(--faint);
  text-align: center;
}

.message-row {
  display: flex;
}

.message-row.user {
  justify-content: flex-end;
}

.bubble {
  max-width: min(780px, 84%);
  padding: 13px 15px;
  line-height: 1.55;
  border: 1px solid var(--line-soft);
  box-shadow: 0 14px 32px rgba(0, 0, 0, 0.18);
  transition: box-shadow 0.3s ease;
}

.bubble.user {
  color: #000000;
  background: #ffffff;
  border-radius: 16px 16px 4px 16px;
}

.bubble.ai {
  color: var(--text);
  background: linear-gradient(135deg, rgba(10, 10, 18, 0.95), rgba(15, 15, 25, 0.95));
  border: 1px solid rgba(59, 130, 246, 0.08);
  border-radius: 16px 16px 16px 4px;
}

.bubble p {
  margin: 0 0 10px;
}

.bubble p:last-child {
  margin-bottom: 0;
}

.media-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.media-strip img,
.media-strip video,
.generated-image {
  max-width: min(360px, 100%);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 12px;
}

.media-strip img,
.media-strip video {
  width: 104px;
  height: 104px;
  object-fit: cover;
}

.generated-image {
  display: block;
  margin-top: 12px;
}

.thinking::after {
  content: "";
  animation: dots 1.1s steps(4, end) infinite;
}

@keyframes dots {
  0%,
  20% {
    content: ".";
  }
  40% {
    content: "..";
  }
  60%,
  100% {
    content: "...";
  }
}

.chat-composer {
  position: relative;
  display: flex;
  gap: 12px;
  padding: 18px 20px;
  border-top: 1px solid var(--line-soft);
}

.composer-input {
  position: relative;
  flex: 1;
}

.composer-input textarea {
  min-height: 48px;
  max-height: 180px;
  padding-right: 78px;
  resize: none;
}

.attach-button {
  position: absolute;
  right: 10px;
  bottom: 10px;
  padding: 5px 9px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.07);
  border-radius: 9px;
  font-size: 12px;
  font-weight: 900;
  cursor: pointer;
}

.send-button {
  width: 86px;
  color: #ffffff;
  background: var(--accent);
  border-radius: 10px;
  font-weight: 800;
  box-shadow: 0 0 14px var(--accent-dim);
}

.chat-preview {
  position: absolute;
  left: 20px;
  right: 120px;
  bottom: calc(100% - 10px);
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 10px;
  background: var(--surface-2);
  border: 1px solid var(--line-soft);
  border-radius: 14px;
  box-shadow: var(--shadow);
}

.chat-preview-strip {
  display: flex;
  gap: 8px;
  overflow-x: auto;
}

.chat-preview-strip img,
.chat-preview-strip video {
  width: 64px;
  height: 64px;
  flex: 0 0 auto;
  object-fit: cover;
  border: 1px solid var(--line-soft);
  border-radius: 10px;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 22px;
  background: rgba(0, 0, 0, 0.76);
  backdrop-filter: blur(12px);
}

.modal-card {
  width: min(440px, 100%);
  display: grid;
  gap: 18px;
  padding: 22px;
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: 20px;
  box-shadow: var(--shadow);
}

.modal-card header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.image-preview-card {
  width: min(1000px, 100%);
  max-height: calc(100dvh - 44px);
  overflow: auto;
}

.preview-stage {
  display: grid;
  place-items: center;
  min-height: 260px;
  overflow: hidden;
  background: #050505;
  border: 1px solid var(--line-soft);
  border-radius: 16px;
}

.preview-stage img {
  max-width: 100%;
  max-height: min(68dvh, 760px);
  object-fit: contain;
}

.preview-meta {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

.close-button {
  width: 38px;
  height: 38px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.04);
  border: 0;
  border-radius: 12px;
  font-size: 24px;
}

.connection-row {
  display: grid;
  grid-template-columns: 14px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.045);
  border: 1px solid var(--line-soft);
  border-radius: 14px;
  color: #d9e3ef;
  font-size: 13px;
}

.setting-row {
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--line-soft);
  border-radius: 14px;
}

.api-key-setting {
  display: grid;
  gap: 12px;
}

.settings-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.status-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #64748b;
}

.status-dot.success {
  background: var(--accent);
  box-shadow: 0 0 14px var(--accent-glow);
}

.status-dot.failed {
  background: #666666;
}

.status-dot.running {
  background: var(--accent);
  box-shadow: 0 0 10px var(--accent-dim);
  animation: pulse 1.1s ease-in-out infinite;
}

@keyframes pulse {
  50% {
    opacity: 0.45;
  }
}

.settings-note {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}

.toast-stack {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 60;
  display: grid;
  gap: 10px;
}

.toast {
  max-width: 360px;
  padding: 12px 14px;
  color: var(--text);
  background: #0a0a0a;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  box-shadow: var(--shadow);
  font-size: 13px;
  animation: toastIn 0.35s cubic-bezier(0.4, 0, 0.2, 1) both;
}

.toast.error {
  border-color: rgba(255, 255, 255, 0.15);
}

.mobile-nav {
  display: none;
}

.self-test-result {
  position: fixed;
  left: 12px;
  bottom: 12px;
  z-index: 80;
  padding: 9px 12px;
  color: #ffffff;
  background: var(--accent);
  border-radius: 10px;
  font-size: 12px;
  font-weight: 800;
  box-shadow: 0 0 14px var(--accent-dim);
}

@media (max-width: 1040px) {
  .topbar {
    grid-template-columns: 1fr auto;
  }

  .primary-tabs {
    grid-column: 1 / -1;
    justify-self: stretch;
    overflow-x: auto;
  }

  .view:not(.view-dashboard):not(.view-chat) {
    grid-template-columns: 1fr;
  }

  .studio-panel {
    position: static;
    max-height: none;
  }

  .hero-panel {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .app-frame *,
  .app-frame *::before,
  .app-frame *::after {
    min-width: 0;
  }

  body {
    padding-bottom: env(safe-area-inset-bottom);
  }

  .app-frame {
    padding-bottom: 72px;
  }

  .topbar {
    grid-template-columns: 1fr auto;
    gap: 12px;
    padding: 12px;
  }

  .top-actions {
    gap: 8px;
  }

  .connection-chip {
    display: none;
  }

  .primary-tabs {
    display: none;
  }

  .workspace {
    padding: 12px;
    display: grid;
    justify-items: center;
  }

  .view {
    min-height: auto;
    width: 100%;
  }

  .hero-panel,
  .studio-panel,
  .results-panel,
  .history-panel,
  .chat-layout {
    border-radius: 16px;
    width: min(100%, 366px);
  }

  .dashboard-grid {
    width: min(100%, 366px);
  }

  .hero-panel {
    padding: 20px;
  }

  .hero-panel h2 {
    font-size: 28px;
    line-height: 1.15;
    max-width: 100%;
    word-break: break-all;
    overflow-wrap: anywhere;
  }

  .hero-copy {
    font-size: 14px;
    max-width: 100%;
    word-break: break-all;
  }

  .metric-grid,
  .dashboard-grid,
  .form-grid,
  .switch-grid {
    grid-template-columns: 1fr;
  }

  .ratio-toggle,
  .video-ratio-toggle {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .dashboard-grid {
    gap: 12px;
  }

  .action-tile {
    min-height: 112px;
  }

  .action-tile strong {
    word-break: break-all;
  }

  .timeline-item {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .timeline-item strong {
    white-space: normal;
  }

  .section-title,
  .panel-head,
  .chat-header {
    align-items: stretch;
    flex-direction: column;
  }

  .asset-grid,
  .video-output-grid {
    grid-template-columns: 1fr;
  }

  .chat-layout {
    height: calc(100dvh - 100px);
  }

  .chat-header,
  .chat-history,
  .chat-composer {
    padding-left: 14px;
    padding-right: 14px;
  }

  .bubble {
    max-width: 92%;
  }

  .chat-composer {
    gap: 8px;
  }

  .send-button {
    width: 68px;
  }

  .chat-preview {
    left: 14px;
    right: 92px;
  }

  .mobile-nav {
    position: fixed;
    left: 12px;
    right: auto;
    bottom: calc(10px + env(safe-area-inset-bottom));
    transform: none;
    z-index: 45;
    display: grid;
    width: min(366px, calc(100vw - 24px));
    max-width: calc(100vw - 24px);
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 6px;
    padding: 6px;
    background: rgba(0, 0, 0, 0.92);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 14px;
    backdrop-filter: blur(20px);
    box-shadow: var(--shadow);
  }

  .mobile-tab {
    min-height: 42px;
    color: var(--muted);
    background: transparent;
    border-radius: 13px;
    font-size: 12px;
    font-weight: 900;
  }

  .toast-stack {
    left: 12px;
    right: 12px;
    bottom: 82px;
  }

  .toast {
    max-width: none;
  }
}

/* Stable product UI: keep transitions, remove entrance blur and ambient motion. */
.hero-panel,
.history-panel,
.studio-panel,
.results-panel,
.asset-card,
.timeline-item,
.analyze-result-card,
.bubble,
.view:not(.is-hidden),
.action-tile {
  animation: none !important;
  filter: none !important;
}

.hero-panel,
.history-panel,
.studio-panel,
.results-panel,
.chat-layout,
.topbar,
.mobile-nav,
.modal {
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
}

.hero-panel h2 {
  animation: none !important;
  background: none;
  -webkit-text-fill-color: currentColor;
  color: #f5f7fb;
}

.topbar::after,
.hero-panel::after {
  display: none;
}

@media (max-width: 430px) {
  .hero-panel,
  .dashboard-grid,
  .history-panel,
  .studio-panel,
  .results-panel,
  .chat-layout {
    width: calc(100vw - 24px);
    max-width: 366px;
  }

  .mobile-nav {
    width: calc(100vw - 24px);
    max-width: 366px;
    right: auto;
  }
}

/* ═══════ Dynamic Animations ═══════ */

@keyframes breathe {
  0%, 100% { box-shadow: 0 0 16px var(--accent-glow), 0 0 4px var(--accent-dim); }
  50% { box-shadow: 0 0 32px var(--accent-glow), 0 0 10px var(--accent-dim), 0 0 60px rgba(59, 130, 246, 0.1); }
}

@keyframes fadeSlideUp {
  from {
    opacity: 0;
    transform: translateY(20px) scale(0.98);
    filter: blur(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
    filter: blur(0);
  }
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateX(30px) scale(0.92);
    filter: blur(2px);
  }
  to {
    opacity: 1;
    transform: translateX(0) scale(1);
    filter: blur(0);
  }
}

@keyframes shimmerText {
  0% { background-position: 200% 0; }
  50% { background-position: 0% 0; }
  100% { background-position: 200% 0; }
}

@keyframes scanline {
  0% { transform: translateX(-100%); opacity: 0; }
  10% { opacity: 1; }
  90% { opacity: 1; }
  100% { transform: translateX(200%); opacity: 0; }
}

.topbar::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 0;
  width: 40%;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--accent), rgba(59, 130, 246, 0.6), transparent);
  animation: scanline 5s cubic-bezier(0.4, 0, 0.2, 1) infinite;
}

.hero-panel {
  position: relative;
  overflow: hidden;
}

.hero-panel::after {
  content: '';
  position: absolute;
  top: -40%;
  right: -15%;
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, rgba(59, 130, 246, 0.06) 0%, rgba(59, 130, 246, 0.02) 40%, transparent 70%);
  animation: float 10s ease-in-out infinite;
  pointer-events: none;
}

@keyframes float {
  0%, 100% { transform: translate(0, 0) scale(1); opacity: 0.6; }
  25% { transform: translate(-25px, 15px) scale(1.08); opacity: 1; }
  50% { transform: translate(10px, -10px) scale(1.02); opacity: 0.8; }
  75% { transform: translate(20px, 10px) scale(0.96); opacity: 1; }
}

.chat-layout {
  animation: none;
}

.bubble {
  animation: bubbleIn 0.35s cubic-bezier(0.16, 1, 0.3, 1) both;
}

@keyframes bubbleIn {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.94);
    filter: blur(2px);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
    filter: blur(0);
  }
}

.view:not(.is-hidden) {
  animation: viewEnter 0.45s cubic-bezier(0.16, 1, 0.3, 1) both;
}

@keyframes viewEnter {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.995);
    filter: blur(3px);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
    filter: blur(0);
  }
}

/* Ambient border glow on hover for panels */
.studio-panel {
  transition: border-color 0.4s ease, box-shadow 0.4s ease;
}

.studio-panel:hover {
  border-color: rgba(59, 130, 246, 0.12);
  box-shadow: var(--shadow), 0 0 40px rgba(59, 130, 246, 0.04);
}

.results-panel {
  transition: border-color 0.4s ease, box-shadow 0.4s ease;
}

.results-panel:hover {
  border-color: rgba(59, 130, 246, 0.1);
}

/* Smooth number counter feel */
.metric-card span {
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.metric-card:hover span {
  transform: scale(1.06);
}

/* HUD corner decorations for hero panel */
.hero-panel .metric-grid::before {
  content: '';
  position: absolute;
  top: 8px;
  right: 8px;
  width: 20px;
  height: 20px;
  border-top: 2px solid rgba(59, 130, 246, 0.3);
  border-right: 2px solid rgba(59, 130, 246, 0.3);
  pointer-events: none;
}

/* Smooth focus glow transition for all inputs */
select, input, textarea {
  transition: border-color 0.25s ease, box-shadow 0.25s ease;
}

/* Link button hover transition */
.link-button {
  transition: color 0.2s ease;
}

/* Secondary button hover */
.secondary-button {
  transition: all 0.25s ease;
}

.secondary-button:hover {
  background: rgba(59, 130, 246, 0.3);
  box-shadow: 0 0 14px var(--accent-dim);
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
