@font-face {
  font-family: "Geist Pixel Square";
  src: url("/static/fonts/GeistPixel-Square.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Geist Pixel Line";
  src: url("/static/fonts/GeistPixel-Line.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

:root {
  --font-body: "Avenir Next", "Segoe UI", "Helvetica Neue", sans-serif;
  --font-mono: "SFMono-Regular", "Menlo", monospace;
  --font-display: "Geist Pixel Square", "Geist Pixel Line", monospace;
  --bg: #f4efe6;
  --bg-alt: #ece3d4;
  --panel: rgba(255, 249, 239, 0.92);
  --panel-strong: rgba(255, 252, 246, 0.98);
  --panel-soft: rgba(247, 239, 227, 0.88);
  --panel-elevated: rgba(255, 255, 255, 0.72);
  --ink: #2c2925;
  --ink-soft: #4f4942;
  --muted: #7b7268;
  --muted-strong: #675d54;
  --line: rgba(113, 95, 72, 0.14);
  --line-strong: rgba(233, 120, 47, 0.3);
  --accent: #e9782f;
  --accent-strong: #ffb14a;
  --accent-soft: #fff1dc;
  --teal: #1f8d81;
  --teal-soft: #ddf4f0;
  --success: #2f9c6c;
  --error: #d64d4d;
  --shadow: 0 24px 80px rgba(83, 65, 39, 0.12);
  --radius-xl: 30px;
  --radius-lg: 24px;
  --radius-md: 18px;
  --radius-sm: 14px;
  --radius-pill: 999px;
  color-scheme: light;
  font-family: var(--font-body);
}

* {
  box-sizing: border-box;
}

html {
  height: 100%;
  overflow: hidden;
  scrollbar-color: rgba(121, 112, 100, 0.45) transparent;
}

body {
  margin: 0;
  min-height: 100%;
  height: 100%;
  overflow: hidden;
  color: var(--ink);
  font-family: var(--font-body);
  background:
    radial-gradient(circle at top left, rgba(255, 177, 74, 0.18), transparent 26%),
    radial-gradient(circle at right, rgba(31, 141, 129, 0.14), transparent 24%),
    linear-gradient(180deg, #f8f3eb 0%, var(--bg) 55%, var(--bg-alt) 100%);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.28) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.28) 1px, transparent 1px);
  background-size: 56px 56px;
  mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.28), transparent 82%);
}

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

button {
  border: 0;
  cursor: pointer;
}

img {
  display: block;
  max-width: 100%;
}

a {
  color: inherit;
}

.auth-modal {
  width: min(1040px, calc(100vw - 32px));
  max-width: none;
  margin: auto;
  padding: 0;
  border: 1px solid rgba(44, 41, 37, 0.08);
  border-radius: 34px;
  background: transparent;
  box-shadow: 0 42px 120px rgba(42, 31, 17, 0.26);
  overflow: hidden;
}

.auth-modal::backdrop {
  background:
    radial-gradient(circle at top, rgba(255, 177, 74, 0.16), transparent 32%),
    rgba(33, 26, 18, 0.44);
  backdrop-filter: blur(14px);
}

.auth-modal-shell {
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(360px, 0.92fr);
  background:
    linear-gradient(135deg, rgba(255, 248, 237, 0.98), rgba(246, 237, 223, 0.96));
}

.auth-modal-hero,
.auth-modal-panel {
  min-width: 0;
}

.auth-modal-hero {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 34px;
  background:
    radial-gradient(circle at top left, rgba(255, 177, 74, 0.3), transparent 32%),
    radial-gradient(circle at right center, rgba(31, 141, 129, 0.18), transparent 28%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.76), rgba(255, 247, 235, 0.68));
}

.auth-modal-hero h2,
.composer-lockout h3 {
  margin: 0;
  font-family: var(--font-display);
  line-height: 1.14;
  letter-spacing: 0.02em;
}

.auth-modal-hero h2 {
  max-width: 18ch;
  font-size: clamp(1.55rem, 2.8vw, 2.2rem);
}

.auth-preview-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 4px;
}

.auth-preview-card {
  display: flex;
  min-height: 132px;
  flex-direction: column;
  justify-content: space-between;
  gap: 10px;
  padding: 14px;
  border: 1px solid rgba(44, 41, 37, 0.08);
  border-radius: var(--radius-lg);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.88), rgba(255, 248, 237, 0.82));
  box-shadow: 0 18px 38px rgba(83, 65, 39, 0.08);
}

.auth-preview-card img {
  align-self: flex-start;
  width: min(100%, 124px);
  image-rendering: pixelated;
}

.auth-preview-card figcaption {
  color: var(--ink-soft);
  font-family: var(--font-display);
  font-size: 0.68rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.auth-modal-panel {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 34px 32px 32px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(255, 252, 246, 0.94));
}

.auth-close {
  position: absolute;
  top: 18px;
  right: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border: 1px solid rgba(44, 41, 37, 0.08);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.8);
  color: var(--muted-strong);
  font-size: 1.4rem;
  line-height: 1;
}

.auth-close:hover:not(:disabled) {
  transform: translateY(-1px);
}

.auth-primary-actions {
  display: flex;
}

.auth-google-button,
.auth-email-submit {
  width: 100%;
  justify-content: center;
}

.auth-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--muted);
  font-family: var(--font-display);
  font-size: 0.64rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.auth-divider::before,
.auth-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: rgba(44, 41, 37, 0.1);
}

.auth-email-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.auth-field {
  gap: 8px;
}

.auth-field-label {
  color: var(--muted-strong);
  font-family: var(--font-display);
  font-size: 0.64rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.auth-mode-label {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.auth-mode-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.auth-mode-toggle {
  min-height: 46px;
  padding: 12px 16px;
}

.brand-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.sidebar-close-button,
.mobile-chat-actions,
.mobile-sidebar-backdrop {
  display: none;
}

.sidebar-close-button {
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  border: 1px solid rgba(44, 41, 37, 0.08);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.82);
  color: var(--muted-strong);
  font-size: 1.4rem;
  line-height: 1;
}

.mobile-chat-actions {
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
  margin-left: auto;
}

.mobile-header-button {
  min-width: 96px;
}

.mobile-sidebar-backdrop {
  position: fixed;
  inset: 0;
  z-index: 25;
  border: 0;
  background: rgba(33, 26, 18, 0.34);
  backdrop-filter: blur(8px);
}

.shell {
  display: grid;
  grid-template-columns: minmax(304px, 356px) minmax(0, 1fr);
  grid-auto-rows: minmax(0, 1fr);
  gap: 18px;
  height: 100dvh;
  min-height: 100vh;
  max-height: 100dvh;
  padding: 16px;
  overflow: hidden;
}

.sidebar,
.panel-view {
  min-height: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.82), rgba(255, 252, 246, 0.72)),
    var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.sidebar {
  display: flex;
  height: 100%;
  min-width: 0;
  flex-direction: column;
  overflow: hidden;
}

.sidebar-top {
  display: flex;
  min-height: 0;
  flex: 1;
  flex-direction: column;
  gap: 18px;
  padding: 22px 22px 0;
  overflow: hidden;
}

.workspace {
  min-width: 0;
  min-height: 0;
}

.panel-view {
  display: flex;
  height: 100%;
  min-width: 0;
  flex-direction: column;
  overflow: hidden;
}

.brand-bar,
.chat-list-section,
.chat-header,
.composer-shell,
.bubble,
.chat-list-item,
.profile-card {
  position: relative;
}

.brand-bar {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.sidebar-new-chat {
  width: 100%;
  justify-content: center;
}

.brand {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.brand h1,
.profile-header h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(1.5rem, 2vw, 2.35rem);
  line-height: 1.05;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.eyebrow,
.pill,
.status,
.chat-list-title,
.composer-mode,
.secondary-button,
.primary-button,
#send,
.credits-badge,
.profile-metric-value,
.preview-chip {
  font-family: var(--font-display);
  letter-spacing: 0.05em;
}

.eyebrow {
  margin: 0;
  color: var(--accent);
  font-size: 0.7rem;
  text-transform: uppercase;
}

.lede,
.section-copy,
.thread-summary,
.assistant-meta,
.chat-list-meta,
.message-meta,
.composer-note,
.profile-copy,
.profile-launcher-meta {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.profile-card,
.admin-panel {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background:
    linear-gradient(180deg, rgba(255, 177, 74, 0.08), transparent 52%),
    rgba(255, 253, 247, 0.84);
}

.profile-actions,
.profile-tag-row,
.profile-metric-grid,
.gallery-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.admin-jobs-shell {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.profile-actions {
  align-items: center;
}

.chat-list-section {
  display: flex;
  min-height: 0;
  flex: 1;
  flex-direction: column;
  gap: 14px;
  overflow: hidden;
}

.section-heading {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 12px;
}

.chat-list {
  display: flex;
  min-height: 0;
  flex: 1;
  flex-direction: column;
  gap: 10px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  padding-right: 4px;
  padding-bottom: 12px;
}

.chat-list-empty {
  padding: 16px;
  border: 1px dashed var(--line);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.64);
  color: var(--muted);
  line-height: 1.5;
}

.chat-list-item {
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  width: 100%;
  padding: 12px;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  color: inherit;
  text-align: left;
  background:
    linear-gradient(180deg, rgba(255, 177, 74, 0.1), transparent 80%),
    rgba(255, 255, 255, 0.68);
  transition:
    transform 140ms ease,
    border-color 140ms ease,
    background 140ms ease,
    box-shadow 140ms ease;
}

.chat-list-item:hover:not(.active):not(:disabled) {
  transform: translateY(-1px);
  border-color: rgba(31, 141, 129, 0.2);
  box-shadow: 0 14px 34px rgba(83, 65, 39, 0.08);
}

.chat-list-item.active {
  border-color: var(--line-strong);
  background:
    linear-gradient(180deg, rgba(255, 177, 74, 0.16), transparent 80%),
    rgba(255, 247, 235, 0.92);
  box-shadow: 0 16px 40px rgba(83, 65, 39, 0.1);
}

.chat-list-item.is-preview {
  border-style: dashed;
}

.chat-list-preview {
  width: 56px;
  height: 56px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  display: grid;
  place-items: center;
  border: 1px solid rgba(44, 41, 37, 0.06);
  background:
    linear-gradient(45deg, rgba(44, 41, 37, 0.04) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(44, 41, 37, 0.04) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, rgba(44, 41, 37, 0.04) 75%),
    linear-gradient(-45deg, transparent 75%, rgba(44, 41, 37, 0.04) 75%),
    rgba(243, 237, 228, 0.92);
  background-size: 12px 12px;
  background-position: 0 0, 0 6px, 6px -6px, -6px 0;
}

.chat-list-preview img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  image-rendering: pixelated;
}

.chat-list-fallback {
  color: var(--ink-soft);
  font-family: var(--font-display);
  font-size: 0.72rem;
  text-transform: uppercase;
}

.chat-list-copy {
  min-width: 0;
}

.chat-list-title {
  margin: 0;
  color: var(--ink);
  font-size: 0.74rem;
  line-height: 1.25;
  text-transform: uppercase;
}

.chat-list-meta {
  margin-top: 6px;
  font-size: 0.9rem;
}

.preview-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  padding: 6px 10px;
  border-radius: var(--radius-pill);
  background: rgba(31, 141, 129, 0.12);
  color: var(--teal);
  font-size: 0.64rem;
  text-transform: uppercase;
}

.sidebar-footer {
  flex-shrink: 0;
  padding: 16px 22px 22px;
}

.profile-launcher {
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr) auto;
  gap: 16px;
  align-items: center;
  width: 100%;
  min-height: 92px;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: 28px;
  background:
    linear-gradient(180deg, rgba(31, 141, 129, 0.08), transparent 60%),
    rgba(255, 255, 255, 0.72);
  transition:
    transform 140ms ease,
    border-color 140ms ease,
    box-shadow 140ms ease;
}

.profile-launcher:hover,
.profile-launcher.active {
  transform: translateY(-1px);
  border-color: rgba(31, 141, 129, 0.22);
  box-shadow: 0 14px 36px rgba(83, 65, 39, 0.08);
}

.profile-launcher.is-auth-entry {
  border-color: rgba(233, 120, 47, 0.24);
  background:
    linear-gradient(180deg, rgba(255, 177, 74, 0.16), rgba(255, 244, 225, 0.88)),
    rgba(255, 255, 255, 0.78);
  box-shadow: 0 18px 40px rgba(233, 120, 47, 0.14);
}

.profile-launcher.is-auth-entry:hover {
  border-color: rgba(233, 120, 47, 0.38);
}

.profile-launcher-avatar,
.profile-avatar {
  width: 56px;
  height: 56px;
  border-radius: 20px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  overflow: hidden;
  background:
    linear-gradient(135deg, rgba(255, 177, 74, 0.28), rgba(31, 141, 129, 0.14)),
    rgba(255, 245, 233, 0.92);
  color: var(--ink);
  font-family: var(--font-display);
  font-size: 0.82rem;
  text-transform: uppercase;
}

.profile-launcher-avatar img,
.profile-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.profile-launcher-copy {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  text-align: left;
}

.profile-launcher-name {
  margin: 0;
  color: var(--ink);
  font-size: 1.02rem;
  font-weight: 600;
  line-height: 1.2;
}

.profile-launcher-meta {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.credits-badge,
.pill,
.status {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: 8px 12px;
  border-radius: var(--radius-pill);
  border: 1px solid rgba(44, 41, 37, 0.08);
  background: rgba(255, 255, 255, 0.74);
  color: var(--ink-soft);
  font-size: 0.66rem;
  line-height: 1;
  text-transform: uppercase;
}

.credits-badge {
  justify-self: end;
  min-width: 60px;
  min-height: 42px;
  padding: 0 16px;
  background:
    linear-gradient(180deg, rgba(255, 177, 74, 0.18), transparent 56%),
    rgba(255, 242, 223, 0.92);
  color: #8a4f12;
}

.credits-badge.is-unlimited {
  background:
    linear-gradient(180deg, rgba(31, 141, 129, 0.16), transparent 56%),
    rgba(223, 244, 240, 0.94);
  color: var(--teal);
}

.credits-badge.is-locked {
  background: rgba(255, 255, 255, 0.84);
  color: var(--muted);
}

.status {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.86);
}

.chat-header,
.profile-header {
  display: flex;
  gap: 20px;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}

.chat-header {
  min-width: 0;
  align-items: center;
  padding: 18px 24px;
}

.profile-header {
  justify-content: space-between;
  align-items: flex-start;
  padding: 24px;
}

.thread-title {
  margin: 0;
  min-width: 0;
  overflow: hidden;
  color: var(--ink);
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.4;
  letter-spacing: 0;
  text-overflow: ellipsis;
  text-transform: none;
  white-space: nowrap;
}

.chat-header-copy {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 10px;
}

.chat-header-meta,
.profile-header-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: flex-end;
}

.thread-facts,
.profile-tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chat-workspace,
.profile-body {
  min-height: 0;
  flex: 1;
  overflow-y: auto;
}

.chat-workspace {
  display: flex;
  min-height: 0;
  overflow: hidden;
  padding: 16px;
}

.profile-body {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 24px;
}

.workspace-empty {
  display: grid;
  place-items: center;
  min-height: 100%;
  padding: 24px;
  border: 1px dashed rgba(44, 41, 37, 0.12);
  border-radius: var(--radius-lg);
  background:
    linear-gradient(180deg, rgba(255, 177, 74, 0.08), transparent 58%),
    rgba(255, 255, 255, 0.56);
  text-align: center;
}

.workspace-empty-title {
  margin: 0;
  color: var(--ink);
  font-weight: 600;
  font-size: 1rem;
}

.workspace-empty-copy {
  margin: 10px 0 0;
  color: var(--muted);
  line-height: 1.6;
}

.visual-thread {
  display: grid;
  flex: 1;
  min-width: 0;
  gap: 14px;
  grid-template-columns: minmax(0, 1fr) 116px;
  height: 100%;
  min-height: 0;
  align-items: stretch;
}

.visual-thread-main {
  display: flex;
  flex: 1;
  min-width: 0;
  min-height: 0;
  flex-direction: column;
  gap: 12px;
  overflow: hidden;
}

.workspace-prompt-panel,
.workspace-active-card,
.visual-thread-history {
  border: 1px solid rgba(44, 41, 37, 0.08);
  border-radius: var(--radius-lg);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.92), rgba(255, 249, 241, 0.88));
  box-shadow: 0 18px 48px rgba(83, 65, 39, 0.08);
}

.workspace-prompt-panel {
  display: flex;
  align-items: center;
  flex-shrink: 0;
  max-height: 88px;
  overflow: hidden;
  padding: 10px 14px;
}

.visual-thread-history-title {
  margin: 0;
  color: var(--muted);
  font-family: var(--font-display);
  font-size: 0.68rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.workspace-prompt-value {
  margin: 0;
  display: -webkit-box;
  overflow: hidden;
  color: var(--ink);
  font-size: 0.98rem;
  line-height: 1.35;
  font-weight: 500;
  word-break: break-word;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.workspace-active-card {
  display: flex;
  min-height: 0;
  flex: 1;
  padding: 12px;
  overflow: hidden;
}

.workspace-active-card .workspace-asset-card {
  display: flex;
  min-height: 0;
  flex: 1;
  flex-direction: column;
  width: 100%;
  max-width: none;
  gap: 10px;
  align-items: stretch;
}

.workspace-active-card .workspace-asset-card.has-debug {
  width: 100%;
  max-width: none;
}

.workspace-active-card .workspace-asset-card.has-debug .asset-top-row {
  display: flex;
}

.workspace-asset-card .asset-top-row {
  display: flex;
  position: relative;
  min-height: 0;
  flex: 1;
  overflow: hidden;
}

.workspace-asset-card .asset-preview-shell {
  display: flex;
  flex: 1;
  min-height: 0;
}

.workspace-asset-card .asset-preview-frame {
  display: flex;
  min-height: 0;
  flex: 1;
}

.workspace-asset-card .asset-preview {
  min-height: 0;
  width: 100%;
  height: 100%;
  aspect-ratio: auto;
}

.workspace-asset-card .asset-preview-canvas {
  padding: 24px;
}

.workspace-asset-card .asset-actual-size-panel {
  right: 12px;
  bottom: 12px;
  min-width: 104px;
}

.workspace-asset-card .asset-debug {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 1;
  width: min(184px, 34%);
  max-height: calc(100% - 20px);
  overflow: auto;
  min-height: 0;
  padding: 8px 10px;
  border: 1px solid rgba(44, 41, 37, 0.08);
  border-radius: var(--radius-md);
  background: rgba(243, 248, 247, 0.9);
  box-shadow: 0 18px 36px rgba(83, 65, 39, 0.12);
  backdrop-filter: blur(8px);
}

.workspace-asset-card .asset-debug-list {
  gap: 4px;
}

.workspace-asset-card .asset-debug-label,
.workspace-asset-card .asset-debug-value {
  font-size: 0.68rem;
}

.workspace-asset-card .asset-debug-row.is-total {
  margin-top: 6px;
  padding-top: 6px;
}

.workspace-asset-card .asset-actions {
  flex-shrink: 0;
}

.workspace-asset-card .processed-output-toggle button {
  min-height: 56px;
  padding: 6px 8px;
}

.workspace-asset-card .processed-output-toggle-preview {
  width: 40px;
  height: 40px;
}

.workspace-asset-card .asset-download {
  min-height: 40px;
  width: 40px;
  min-width: 40px;
}

.visual-thread-history {
  display: flex;
  height: 100%;
  min-height: 0;
  flex-direction: column;
  gap: 10px;
  padding: 10px;
}

.visual-thread-history-header {
  display: flex;
  justify-content: flex-start;
  align-items: baseline;
  gap: 8px;
  padding: 0;
}

.visual-thread-history-list {
  display: flex;
  min-height: 0;
  flex: 1;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  padding-right: 2px;
}

.history-step {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  flex: 0 0 auto;
  padding: 0;
  overflow: hidden;
  border: 0;
  border-radius: 12px;
  background:
    linear-gradient(45deg, rgba(44, 41, 37, 0.05) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(44, 41, 37, 0.05) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, rgba(44, 41, 37, 0.05) 75%),
    linear-gradient(-45deg, transparent 75%, rgba(44, 41, 37, 0.05) 75%),
    rgba(246, 239, 228, 0.92);
  background-size: 16px 16px;
  background-position: 0 0, 0 8px, 8px -8px, -8px 0;
  box-shadow: inset 0 0 0 1px rgba(44, 41, 37, 0.08);
  color: inherit;
  transition:
    transform 140ms ease,
    box-shadow 140ms ease;
}

.history-step:hover {
  transform: translateY(-1px);
  box-shadow:
    inset 0 0 0 1px rgba(31, 141, 129, 0.36),
    0 10px 18px rgba(83, 65, 39, 0.1);
}

.history-step.is-active {
  box-shadow:
    inset 0 0 0 2px rgba(255, 177, 74, 0.92),
    0 12px 22px rgba(83, 65, 39, 0.12);
}

.history-step img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  image-rendering: pixelated;
}

.message {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

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

.message.user .bubble {
  max-width: min(620px, 100%);
  background:
    linear-gradient(180deg, rgba(255, 177, 74, 0.18), transparent 100%),
    rgba(255, 247, 235, 0.96);
  border-color: rgba(233, 120, 47, 0.18);
}

.message.assistant .bubble {
  max-width: min(780px, 100%);
  background:
    linear-gradient(180deg, rgba(31, 141, 129, 0.08), transparent 100%),
    rgba(255, 255, 255, 0.92);
}

.message.failed .bubble {
  border-color: rgba(214, 77, 77, 0.22);
  background: rgba(255, 244, 242, 0.94);
}

.avatar {
  flex: 0 0 42px;
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(31, 141, 129, 0.14);
  background:
    linear-gradient(180deg, rgba(31, 141, 129, 0.16), transparent 100%),
    rgba(223, 244, 240, 0.9);
  color: var(--ink);
  font-family: var(--font-display);
  font-size: 0.68rem;
  text-transform: uppercase;
}

.bubble {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  box-shadow: 0 14px 40px rgba(83, 65, 39, 0.08);
}

.bubble p {
  margin: 0;
  line-height: 1.6;
}

.bubble p + p {
  margin-top: 10px;
}

.message-title {
  color: var(--ink);
  font-family: var(--font-display);
  font-size: 0.82rem;
  line-height: 1.4;
  text-transform: uppercase;
}

.message-title:empty,
.assistant-meta:empty {
  display: none;
}

.message-meta,
.assistant-meta {
  margin-top: 8px;
  color: var(--muted-strong);
  font-size: 0.9rem;
}

.bubble-copy {
  color: var(--ink-soft);
}

.bubble-copy + .bubble-copy,
.bubble-copy + .asset-card {
  margin-top: 12px;
}

.assistant .assistant-meta + .bubble-copy,
.assistant .assistant-meta + .asset-card,
.assistant .message-title + .bubble-copy,
.assistant .message-title + .asset-card,
.assistant .assistant-meta + .message-error,
.assistant .message-title + .message-error {
  margin-top: 12px;
}

.asset-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: flex-start;
  width: min(100%, 288px);
  max-width: 288px;
}

.asset-card.has-debug {
  width: min(100%, 520px);
  max-width: 520px;
}

.asset-top-row {
  width: 100%;
}

.asset-card.has-debug .asset-top-row {
  display: grid;
  grid-template-columns: minmax(0, 288px) minmax(0, 1fr);
  gap: 12px;
  align-items: stretch;
}

.asset-preview-shell {
  display: flex;
  flex-direction: column;
  width: 100%;
  padding: 10px;
  border: 1px solid rgba(44, 41, 37, 0.08);
  border-radius: var(--radius-md);
  background:
    linear-gradient(180deg, rgba(31, 141, 129, 0.06), transparent 72%),
    rgba(255, 251, 245, 0.9);
}

.asset-preview-toolbar {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  pointer-events: none;
}

.asset-actual-size-label,
.asset-actual-size-meta,
.processed-output-toggle-label {
  margin: 0;
  font-family: var(--font-display);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.asset-actual-size-label {
  color: var(--muted);
  font-size: 0.64rem;
}

.asset-zoom-controls {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
  border: 1px solid rgba(44, 41, 37, 0.08);
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 12px 24px rgba(83, 65, 39, 0.1);
  backdrop-filter: blur(10px);
  pointer-events: auto;
}

.asset-zoom-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  min-height: 32px;
  padding: 0 8px;
  border: 1px solid rgba(44, 41, 37, 0.08);
  border-radius: var(--radius-pill);
  background: rgba(243, 237, 228, 0.92);
  color: var(--ink);
  font-family: var(--font-display);
  font-size: 0.7rem;
  line-height: 1;
  text-transform: uppercase;
  transition:
    border-color 120ms ease,
    background 120ms ease,
    opacity 120ms ease,
    transform 120ms ease;
}

.asset-zoom-button:hover:not(:disabled) {
  transform: translateY(-1px);
  border-color: rgba(31, 141, 129, 0.18);
  background: rgba(255, 255, 255, 0.92);
}

.asset-zoom-button:disabled {
  opacity: 0.44;
  cursor: default;
}

.asset-zoom-reset {
  min-width: 50px;
}

.asset-debug-toggle {
  min-width: 62px;
  padding: 0 12px;
  background: rgba(255, 255, 255, 0.9);
  pointer-events: auto;
}

.asset-debug-toggle.is-active {
  border-color: rgba(31, 141, 129, 0.28);
  background: rgba(220, 245, 241, 0.94);
}

.asset-preview-frame {
  position: relative;
  width: 100%;
  min-height: 0;
}

.asset-preview {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  overflow: auto;
  border: 1px dashed rgba(44, 41, 37, 0.1);
  border-radius: var(--radius-sm);
  background:
    linear-gradient(45deg, rgba(44, 41, 37, 0.05) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(44, 41, 37, 0.05) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, rgba(44, 41, 37, 0.05) 75%),
    linear-gradient(-45deg, transparent 75%, rgba(44, 41, 37, 0.05) 75%),
    rgba(246, 239, 228, 0.92);
  background-size: 20px 20px;
  background-position: 0 0, 0 10px, 10px -10px, -10px 0;
  scrollbar-gutter: stable both-edges;
}

.asset-preview-canvas {
  display: grid;
  place-items: center;
  width: max-content;
  min-width: 100%;
  min-height: 100%;
  padding: 18px;
}

.asset-preview-image,
.asset-actual-size-image {
  display: block;
  object-fit: contain;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

.asset-preview-image {
  max-width: none;
  max-height: none;
}

.asset-actual-size-panel {
  position: absolute;
  right: 12px;
  bottom: 12px;
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: flex-start;
  min-width: 96px;
  padding: 8px;
  border: 1px solid rgba(44, 41, 37, 0.08);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 18px 36px rgba(83, 65, 39, 0.12);
  backdrop-filter: blur(12px);
}

.asset-actual-size-frame {
  display: grid;
  place-items: center;
  min-width: 48px;
  min-height: 48px;
  padding: 8px;
  border: 1px dashed rgba(44, 41, 37, 0.1);
  border-radius: 12px;
  background:
    linear-gradient(45deg, rgba(44, 41, 37, 0.05) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(44, 41, 37, 0.05) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, rgba(44, 41, 37, 0.05) 75%),
    linear-gradient(-45deg, transparent 75%, rgba(44, 41, 37, 0.05) 75%),
    rgba(246, 239, 228, 0.92);
  background-size: 12px 12px;
  background-position: 0 0, 0 6px, 6px -6px, -6px 0;
}

.asset-actual-size-image {
  width: auto;
  height: auto;
  max-width: none;
  max-height: none;
}

.asset-actual-size-meta {
  color: var(--muted-strong);
  font-size: 0.56rem;
}

.asset-debug {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid rgba(44, 41, 37, 0.08);
  border-radius: var(--radius-md);
  background:
    linear-gradient(180deg, rgba(31, 141, 129, 0.08), transparent 38%),
    rgba(255, 255, 255, 0.88);
}

.asset-debug-title {
  margin: 0;
  color: var(--muted);
  font-family: var(--font-display);
  font-size: 0.62rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.asset-debug-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.asset-debug-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: baseline;
}

.asset-debug-row.is-total {
  margin-top: 2px;
  padding-top: 8px;
  border-top: 1px solid rgba(44, 41, 37, 0.08);
}

.asset-debug-label,
.asset-debug-value {
  font-size: 0.74rem;
  line-height: 1.3;
}

.asset-debug-label {
  color: var(--muted);
}

.asset-debug-value {
  color: var(--ink);
  font-family: var(--font-mono);
  white-space: nowrap;
}

.asset-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  width: 100%;
  gap: 10px;
  align-items: stretch;
}

.processed-output-toggle {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(0, 1fr);
  gap: 4px;
  padding: 4px;
  border: 1px solid rgba(44, 41, 37, 0.08);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.78);
}

.processed-output-toggle button {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  min-height: 48px;
  padding: 6px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: rgba(243, 237, 228, 0.8);
  color: var(--ink-soft);
  box-shadow: none;
  transition:
    transform 120ms ease,
    border-color 120ms ease,
    background 120ms ease,
    box-shadow 120ms ease;
}

.processed-output-toggle button:hover:not(.is-active) {
  transform: translateY(-1px);
  border-color: rgba(31, 141, 129, 0.16);
  background: rgba(255, 255, 255, 0.88);
}

.processed-output-toggle-preview {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  overflow: hidden;
  border: 1px dashed rgba(44, 41, 37, 0.1);
  border-radius: 12px;
  background:
    linear-gradient(45deg, rgba(44, 41, 37, 0.05) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(44, 41, 37, 0.05) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, rgba(44, 41, 37, 0.05) 75%),
    linear-gradient(-45deg, transparent 75%, rgba(44, 41, 37, 0.05) 75%),
    rgba(246, 239, 228, 0.92);
  background-size: 12px 12px;
  background-position: 0 0, 0 6px, 6px -6px, -6px 0;
}

.processed-output-toggle-preview img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

.processed-output-toggle-label {
  color: inherit;
  font-size: 0.64rem;
  line-height: 1.15;
  text-align: left;
}

.processed-output-toggle button.is-active {
  border-color: rgba(233, 120, 47, 0.52);
  background:
    linear-gradient(180deg, rgba(255, 177, 74, 0.18), transparent 45%),
    rgba(255, 243, 227, 0.96);
  color: var(--ink);
  box-shadow:
    0 0 0 2px rgba(233, 120, 47, 0.2),
    0 10px 24px rgba(83, 65, 39, 0.08);
}

.asset-download {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  justify-self: end;
  min-height: 46px;
  width: 46px;
  min-width: 46px;
  padding: 0;
  border: 1px solid rgba(44, 41, 37, 0.08);
  border-radius: var(--radius-md);
  background:
    linear-gradient(180deg, rgba(31, 141, 129, 0.12), transparent 50%),
    rgba(255, 255, 255, 0.84);
  color: var(--ink);
  text-decoration: none;
  transition:
    transform 120ms ease,
    border-color 120ms ease,
    background 120ms ease,
    opacity 120ms ease;
}

.asset-download svg {
  width: 18px;
  height: 18px;
}

.asset-download:hover {
  transform: translateY(-1px);
  border-color: rgba(31, 141, 129, 0.24);
}

.asset-download.is-disabled {
  opacity: 0.45;
  pointer-events: none;
}

.message-error {
  color: var(--error);
  font-weight: 600;
}

.composer {
  flex-shrink: 0;
  padding: 12px 16px 16px;
  border-top: 1px solid var(--line);
  background: rgba(244, 239, 230, 0.86);
}

.composer.is-locked .composer-shell {
  border-style: dashed;
}

.composer-shell {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 12px;
  border: 1px solid rgba(44, 41, 37, 0.08);
  border-radius: var(--radius-xl);
  background:
    linear-gradient(180deg, rgba(255, 177, 74, 0.08), transparent 34%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(255, 249, 239, 0.98));
  box-shadow: 0 24px 60px rgba(83, 65, 39, 0.1);
}

.composer-copy {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.composer-mode {
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.7rem;
  line-height: 1.5;
  text-transform: uppercase;
}

.composer-note {
  font-size: 0.95rem;
}

.grid,
.field,
.composer-entry {
  display: flex;
}

.field {
  min-width: 0;
  flex-direction: column;
  gap: 8px;
}

.field-prompt {
  flex: 1;
}

textarea,
select,
input[type="color"],
input[type="search"],
input[type="text"],
input[type="number"],
input[type="email"],
input[type="password"] {
  width: 100%;
  border: 1px solid rgba(44, 41, 37, 0.1);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.88);
  color: var(--ink);
  outline: none;
  transition:
    border-color 120ms ease,
    box-shadow 120ms ease,
    background 120ms ease,
    opacity 120ms ease;
}

textarea:focus,
select:focus,
input[type="color"]:focus,
input[type="search"]:focus,
input[type="text"]:focus,
input[type="number"]:focus,
input[type="email"]:focus,
input[type="password"]:focus {
  border-color: rgba(233, 120, 47, 0.36);
  box-shadow: 0 0 0 3px rgba(233, 120, 47, 0.12);
}

textarea:disabled,
select:disabled,
input[type="color"]:disabled,
input[type="search"]:disabled,
input[type="text"]:disabled,
input[type="number"]:disabled,
input[type="email"]:disabled,
input[type="password"]:disabled {
  cursor: not-allowed;
  opacity: 0.72;
}

textarea,
select,
input[type="search"],
input[type="text"],
input[type="number"],
input[type="email"],
input[type="password"] {
  padding: 13px 15px;
}

textarea {
  min-height: 64px;
  max-height: 220px;
  resize: none;
  line-height: 1.55;
}

textarea::placeholder {
  color: #9d948a;
}

.composer-entry {
  align-items: end;
  gap: 12px;
}

.composer-lockout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 18px;
  align-items: center;
  padding: 18px 20px;
  border: 1px solid rgba(233, 120, 47, 0.16);
  border-radius: calc(var(--radius-xl) - 8px);
  background:
    radial-gradient(circle at top left, rgba(255, 177, 74, 0.2), transparent 34%),
    radial-gradient(circle at right, rgba(31, 141, 129, 0.12), transparent 26%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(255, 247, 235, 0.92));
}

.composer-lockout-copy {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.composer-lockout h3 {
  max-width: 22ch;
  font-size: 0.98rem;
}

.composer-lockout-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.composer-lockout .primary-button,
.composer-lockout .secondary-button {
  min-width: 180px;
}

#send,
.secondary-button,
.primary-button {
  border-radius: var(--radius-md);
  min-height: 52px;
  padding: 14px 20px;
  text-transform: uppercase;
  transition:
    transform 120ms ease,
    box-shadow 120ms ease,
    opacity 120ms ease,
    border-color 120ms ease,
    background 120ms ease;
}

.primary-button,
#send {
  background:
    linear-gradient(180deg, rgba(255, 241, 220, 0.9), rgba(255, 177, 74, 0.92)),
    linear-gradient(135deg, var(--accent-strong) 0%, var(--accent) 100%);
  color: #5d3310;
  box-shadow: 0 18px 38px rgba(233, 120, 47, 0.18);
}

#send {
  min-width: 168px;
}

.secondary-button {
  background:
    linear-gradient(180deg, rgba(31, 141, 129, 0.08), transparent 50%),
    rgba(255, 255, 255, 0.84);
  border: 1px solid rgba(31, 141, 129, 0.16);
  color: var(--ink);
}

#send:hover:not(:disabled),
.secondary-button:hover:not(:disabled),
.primary-button:hover:not(:disabled) {
  transform: translateY(-1px);
}

#send:disabled,
.secondary-button:disabled,
.primary-button:disabled {
  opacity: 0.64;
  cursor: not-allowed;
  box-shadow: none;
}

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

.profile-card-wide {
  grid-column: 1 / -1;
}

.profile-card {
  min-width: 0;
  justify-content: space-between;
}

.profile-card h3,
.profile-card h4 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 0.92rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.profile-card p {
  margin: 0;
}

.profile-identity {
  display: flex;
  gap: 14px;
  align-items: center;
}

.profile-avatar {
  width: 58px;
  height: 58px;
  border-radius: 18px;
  font-size: 0.96rem;
}

.profile-identity-copy {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 6px;
}

.profile-name {
  color: var(--ink);
  font-size: 1.15rem;
  font-weight: 700;
}

.profile-metric-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.profile-metric {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px;
  border: 1px solid rgba(44, 41, 37, 0.08);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.72);
}

.profile-metric-label {
  color: var(--muted);
  font-family: var(--font-display);
  font-size: 0.66rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.profile-metric-value {
  color: var(--ink);
  font-size: 0.86rem;
  line-height: 1.3;
}

.profile-credit-total {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.profile-credit-balance {
  color: var(--ink);
  font-family: var(--font-display);
  font-size: clamp(1.8rem, 4vw, 2.8rem);
  line-height: 1;
  text-transform: uppercase;
}

.profile-credit-caption {
  color: var(--muted);
  max-width: 32ch;
}

.profile-purchase-shell {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid rgba(44, 41, 37, 0.08);
}

.profile-purchase-heading {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.profile-purchase-copy {
  color: var(--muted);
  max-width: 40ch;
}

.profile-purchase-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
}

.purchase-pack-button {
  appearance: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 14px;
  border: 1px solid rgba(44, 41, 37, 0.1);
  border-radius: var(--radius-md);
  background:
    linear-gradient(180deg, rgba(31, 141, 129, 0.08), transparent 78%),
    rgba(255, 255, 255, 0.88);
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition:
    transform 140ms ease,
    border-color 140ms ease,
    box-shadow 140ms ease,
    background 140ms ease;
}

.purchase-pack-button:hover,
.purchase-pack-button:focus-visible {
  transform: translateY(-1px);
  border-color: rgba(31, 141, 129, 0.24);
  box-shadow: 0 16px 28px rgba(83, 65, 39, 0.08);
}

.purchase-pack-button:focus-visible {
  outline: 0;
}

.purchase-pack-button:disabled {
  opacity: 0.6;
  cursor: wait;
  transform: none;
  box-shadow: none;
}

.purchase-pack-name {
  color: var(--ink);
  font-family: var(--font-display);
  font-size: 0.84rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.purchase-pack-meta,
.purchase-pack-price {
  color: var(--muted);
  font-size: 0.84rem;
}

.purchase-pack-price {
  color: var(--ink);
  font-weight: 700;
}

.gallery-item {
  appearance: none;
  display: flex;
  flex-direction: column;
  gap: 9px;
  width: 100%;
  padding: 10px;
  border: 1px solid rgba(44, 41, 37, 0.08);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.74);
  color: inherit;
  font: inherit;
  text-align: left;
  transition:
    transform 140ms ease,
    border-color 140ms ease,
    background 140ms ease,
    box-shadow 140ms ease;
  cursor: pointer;
}

.gallery-item:hover,
.gallery-item:focus-visible {
  transform: translateY(-1px);
  border-color: rgba(31, 141, 129, 0.2);
  background:
    linear-gradient(180deg, rgba(31, 141, 129, 0.06), transparent 72%),
    rgba(255, 255, 255, 0.9);
  box-shadow: 0 14px 30px rgba(83, 65, 39, 0.08);
}

.gallery-item:focus-visible {
  outline: 0;
}

.gallery-thumb {
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  min-height: 124px;
  border-radius: 14px;
  overflow: hidden;
  border: 1px dashed rgba(44, 41, 37, 0.1);
  background:
    linear-gradient(45deg, rgba(44, 41, 37, 0.02) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(44, 41, 37, 0.02) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, rgba(44, 41, 37, 0.02) 75%),
    linear-gradient(-45deg, transparent 75%, rgba(44, 41, 37, 0.02) 75%),
    rgba(246, 239, 228, 0.92);
  background-size: 18px 18px;
  background-position: 0 0, 0 9px, 9px -9px, -9px 0;
}

.gallery-thumb img {
  width: 96px;
  height: 96px;
  object-fit: contain;
  image-rendering: pixelated;
}

.gallery-item-title {
  color: var(--ink);
  font-size: 0.92rem;
  font-weight: 700;
  line-height: 1.35;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.gallery-item-copy {
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.45;
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(132px, 1fr));
  gap: 12px;
}

.admin-panel {
  gap: 12px;
}

.admin-search input {
  min-height: 48px;
}

.admin-users,
.admin-jobs {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.admin-user-card,
.admin-job-row {
  padding: 12px;
  border: 1px solid rgba(44, 41, 37, 0.08);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.78);
}

.admin-user-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.admin-user-actions {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
}

.admin-inline-input.reason {
  grid-column: span 2;
}

.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;
}

[hidden] {
  display: none !important;
}

@media (max-width: 1180px) {
  html,
  body {
    height: auto;
    min-height: 100%;
    overflow-x: hidden;
    overflow-y: auto;
  }

  .shell {
    grid-template-columns: 1fr;
    gap: 12px;
    height: auto;
    min-height: 100dvh;
    max-height: none;
    padding: 12px;
    overflow: visible;
  }

  body.mobile-sidebar-open {
    overflow: hidden;
  }

  .mobile-sidebar-backdrop {
    display: block;
  }

  .sidebar,
  .panel-view {
    border-radius: var(--radius-lg);
  }

  .workspace,
  .panel-view {
    min-height: auto;
    overflow: visible;
  }

  .panel-view {
    height: auto;
    min-height: calc(100dvh - 24px);
  }

  .sidebar {
    position: fixed;
    top: 12px;
    left: 12px;
    bottom: 12px;
    width: min(380px, calc(100vw - 24px));
    max-width: calc(100vw - 24px);
    height: auto;
    max-height: calc(100dvh - 24px);
    z-index: 40;
    transform: translateX(calc(-100% - 18px));
    visibility: hidden;
    pointer-events: none;
    transition:
      transform 180ms ease,
      box-shadow 180ms ease,
      visibility 0s linear 180ms;
  }

  body.mobile-sidebar-open .sidebar {
    transform: translateX(0);
    visibility: visible;
    pointer-events: auto;
    transition:
      transform 180ms ease,
      box-shadow 180ms ease;
  }

  .auth-modal {
    width: min(900px, calc(100vw - 24px));
  }

  .auth-modal-shell {
    grid-template-columns: 1fr;
  }

  .auth-modal-hero {
    padding-bottom: 22px;
  }

  .chat-list {
    max-height: none;
  }

  .composer-lockout {
    grid-template-columns: 1fr;
  }

  .profile-grid {
    grid-template-columns: 1fr;
  }

  .profile-header {
    flex-direction: column;
  }

  .profile-header-actions {
    align-items: flex-start;
  }

  .thread-facts {
    justify-content: flex-start;
  }

  .brand-row {
    align-items: center;
  }

  .sidebar-top {
    padding: 18px 18px 0;
  }

  .sidebar-footer {
    padding: 12px 18px calc(18px + env(safe-area-inset-bottom));
  }

  .sidebar-close-button,
  .mobile-chat-actions {
    display: flex;
  }

  .chat-header {
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
    padding: 18px 20px;
  }

  .profile-header,
  .chat-workspace,
  .profile-body,
  .composer {
    padding-left: 20px;
    padding-right: 20px;
  }

  .chat-workspace,
  .profile-body {
    overflow: visible;
  }

  .chat-workspace {
    display: block;
    padding-bottom: 20px;
  }

  .thread-title {
    flex: 1;
    white-space: normal;
  }

  .mobile-header-button {
    width: auto;
    min-height: 46px;
    padding: 12px 16px;
  }

  .workspace-prompt-panel {
    max-height: none;
  }

  .workspace-prompt-value {
    -webkit-line-clamp: 3;
  }

  .workspace-active-card .asset-preview {
    min-height: min(50vh, 520px);
    max-height: 58vh;
  }

  .workspace-active-card .asset-preview-canvas {
    padding: 24px 18px;
  }

  .composer {
    position: sticky;
    bottom: 0;
    z-index: 5;
    padding-bottom: calc(16px + env(safe-area-inset-bottom));
    background:
      linear-gradient(180deg, rgba(244, 239, 230, 0.2), rgba(244, 239, 230, 0.96) 28%),
      rgba(244, 239, 230, 0.96);
    backdrop-filter: blur(12px);
  }
}

@media (max-width: 820px) {
  .sidebar {
    top: 10px;
    left: 10px;
    bottom: 10px;
    width: calc(100vw - 20px);
    max-width: calc(100vw - 20px);
  }

  .chat-header,
  .profile-header,
  .chat-workspace,
  .profile-body,
  .composer {
    padding-left: 16px;
    padding-right: 16px;
  }

  .chat-header {
    gap: 12px;
  }

  .auth-modal {
    width: min(100vw - 16px, 760px);
  }

  .auth-modal-hero,
  .auth-modal-panel {
    padding: 24px 20px;
  }

  .auth-preview-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .mobile-chat-actions {
    width: 100%;
    justify-content: stretch;
  }

  .mobile-chat-actions .mobile-header-button {
    width: auto;
    min-width: 0;
    flex: 1 1 0;
  }

  .composer-entry {
    flex-direction: column;
    align-items: stretch;
  }

  .composer-lockout-actions {
    justify-content: stretch;
  }

  #send,
  .secondary-button,
  .primary-button {
    width: 100%;
  }

  .mobile-chat-actions .secondary-button {
    width: auto;
  }

  .profile-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .profile-metric-grid,
  .gallery-grid,
  .admin-user-actions {
    grid-template-columns: 1fr;
  }

  .asset-card.has-debug .asset-top-row {
    grid-template-columns: 1fr;
  }

  .visual-thread {
    grid-template-columns: 1fr;
    height: auto;
  }

  .chat-workspace {
    overflow-y: auto;
    padding-bottom: 16px;
  }

  .visual-thread-main {
    flex: none;
    min-height: auto;
    overflow: visible;
  }

  .workspace-active-card {
    flex: none;
    min-height: auto;
    padding: 14px;
    overflow: visible;
  }

  .workspace-asset-card .asset-top-row,
  .workspace-asset-card .asset-preview-shell,
  .workspace-asset-card .asset-preview-frame {
    flex: none;
    min-height: auto;
  }

  .workspace-asset-card .asset-preview-frame {
    flex-direction: column;
  }

  .workspace-asset-card .asset-preview {
    aspect-ratio: 1;
    min-height: 0;
    height: auto;
    max-height: none;
  }

  .workspace-asset-card .asset-preview-canvas {
    min-height: 100%;
    padding: 22px 16px 18px;
  }

  .workspace-asset-card .asset-preview-toolbar {
    top: 12px;
    left: 12px;
    right: 12px;
    justify-content: space-between;
    flex-wrap: wrap;
  }

  .workspace-asset-card .asset-actions {
    grid-template-columns: 1fr;
  }

  .workspace-asset-card .processed-output-toggle {
    grid-auto-flow: row;
    grid-auto-columns: unset;
    grid-template-columns: 1fr;
  }

  .workspace-asset-card .asset-actual-size-frame {
    min-width: 64px;
    min-height: 64px;
    padding: 10px;
  }

  .workspace-asset-card .asset-actual-size-panel {
    position: static;
    right: auto;
    bottom: auto;
    align-self: flex-end;
    margin-top: 10px;
    min-width: auto;
  }

  .workspace-asset-card .asset-download {
    justify-self: end;
  }

  .visual-thread-history {
    padding: 12px;
    height: auto;
  }

  .visual-thread-history-list {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: 48px;
    gap: 8px;
    align-items: center;
    overflow-x: auto;
    overflow-y: hidden;
    padding-bottom: 4px;
    padding-right: 0;
  }

  .workspace-empty {
    min-height: clamp(240px, 38vh, 420px);
    padding: 20px;
  }
}
