/* ==========================================================================
   AI Image Studio
   Material Design 3 · Blue & White
   ========================================================================== */

:root {
  color-scheme: light;

  --primary: #0b57d0;
  --primary-hover: #0a4cb8;
  --primary-soft: #2f7bff;
  --on-primary: #ffffff;
  --primary-container: #d9e3ff;
  --on-primary-container: #001a41;
  --secondary-container: #e3ecff;
  --on-secondary-container: #0b2a55;

  --surface: #f8faff;
  --surface-bright: #ffffff;
  --surface-dim: #eef4fe;
  --surface-container: #edf3fc;
  --surface-container-high: #e4edfa;
  --surface-container-low: #f3f7ff;

  --on-surface: #171c24;
  --on-surface-variant: #424a59;
  --on-surface-muted: #6b7484;
  --outline: #8d97a8;
  --outline-variant: #d5dce8;
  --outline-soft: #e3eaf6;

  --error: #c5221f;
  --error-container: #ffdad6;
  --success: #1b7f4d;
  --warning: #a05a00;

  --radius-xs: 8px;
  --radius-sm: 12px;
  --radius-md: 16px;
  --radius-lg: 22px;
  --radius-xl: 28px;
  --radius-full: 999px;

  --shadow-soft: 0 24px 80px -48px rgba(11, 87, 208, 0.36);
  --shadow-card: 0 18px 50px -32px rgba(11, 87, 208, 0.32);
  --shadow-float: 0 24px 64px -20px rgba(9, 34, 77, 0.32);

  --font-sans: "Roboto", "Segoe UI", "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Noto Sans SC", system-ui, sans-serif;
  --font-mono: "SFMono-Regular", "Cascadia Code", "Consolas", monospace;

  --page-max: 1440px;
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.6;
  color: var(--on-surface);
  background:
    radial-gradient(1100px 620px at 8% -8%, rgba(116, 166, 255, 0.3), transparent 60%),
    radial-gradient(900px 580px at 102% 2%, rgba(194, 218, 255, 0.58), transparent 58%),
    linear-gradient(180deg, #f8faff 0%, #f1f6ff 42%, #f8faff 100%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-image: radial-gradient(rgba(11, 87, 208, 0.06) 1px, transparent 1px);
  background-size: 28px 28px;
  -webkit-mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.55), transparent 62%);
  mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.55), transparent 62%);
}

::selection {
  background: var(--primary-container);
  color: var(--on-primary-container);
}

svg {
  display: block;
}

.svg-sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

:focus-visible {
  outline: 3px solid rgba(11, 87, 208, 0.4);
  outline-offset: 2px;
}

[hidden] {
  display: none !important;
}

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

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
}

img {
  max-width: 100%;
}

p,
h1,
h2,
h3,
h4 {
  margin: 0;
}

a {
  color: inherit;
  text-decoration: none;
}

.icon {
  width: 18px;
  height: 18px;
  flex: none;
  vertical-align: middle;
}

.sr-only {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  border-radius: 5px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  background: rgba(255, 255, 255, 0.1);
  font-family: var(--font-sans);
  font-size: 11px;
  line-height: 1;
  color: inherit;
}

/* ==========================================================================
   Buttons
   ========================================================================== */

.md-filled-button,
.md-tonal-button,
.md-outlined-button,
.md-text-button,
.text-button,
.link-btn,
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 0;
  background: transparent;
  border-radius: var(--radius-full);
  white-space: nowrap;
  transition:
    background-color 0.18s var(--ease),
    color 0.18s var(--ease),
    box-shadow 0.18s var(--ease),
    border-color 0.18s var(--ease),
    transform 0.18s var(--ease);
}

.md-filled-button {
  min-height: 44px;
  padding: 0 22px;
  background: var(--primary);
  color: var(--on-primary);
  font-weight: 600;
  font-size: 14px;
  box-shadow: 0 8px 22px -12px rgba(11, 87, 208, 0.8);
}

.md-filled-button:hover {
  background: var(--primary-hover);
  box-shadow: 0 12px 26px -12px rgba(11, 87, 208, 0.85);
}

.md-tonal-button {
  min-height: 42px;
  padding: 0 18px;
  background: var(--primary-container);
  color: var(--on-primary-container);
  font-weight: 600;
  font-size: 13.5px;
}

.md-tonal-button:hover {
  background: #cbdcff;
}

.md-outlined-button {
  min-height: 44px;
  padding: 0 18px;
  border: 1.5px solid var(--outline-variant);
  color: var(--primary);
  background: var(--surface-bright);
  font-weight: 600;
  font-size: 13.5px;
}

.md-outlined-button:hover {
  border-color: var(--primary);
  background: #f2f7ff;
}

.md-text-button {
  min-height: 38px;
  padding: 0 12px;
  color: var(--primary);
  font-weight: 600;
  font-size: 13px;
}

.md-text-button:hover {
  background: rgba(11, 87, 208, 0.08);
}

.md-text-button .icon {
  width: 15px;
  height: 15px;
}

.text-button {
  min-height: 32px;
  padding: 0 6px;
  color: var(--primary);
  font-weight: 600;
  font-size: 12.5px;
  gap: 4px;
}

.text-button .icon {
  width: 14px;
  height: 14px;
}

.text-button:hover {
  color: var(--primary-hover);
  gap: 7px;
}

.link-btn {
  padding: 0;
  min-height: 26px;
  border-radius: 6px;
  color: var(--primary);
  font-weight: 600;
  font-size: 12px;
}

.link-btn:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  color: var(--on-surface-variant);
}

.icon-btn:hover {
  background: var(--surface-container);
  color: var(--primary);
}

.icon-btn--dark {
  color: #e8eefc;
  background: rgba(255, 255, 255, 0.08);
}

.icon-btn--dark:hover {
  background: rgba(255, 255, 255, 0.16);
  color: #ffffff;
}

/* ==========================================================================
   App bar
   ========================================================================== */

.app-bar {
  position: sticky;
  top: 0;
  z-index: 40;
  border-bottom: 1px solid rgba(213, 220, 232, 0.72);
  background: rgba(248, 250, 255, 0.78);
  -webkit-backdrop-filter: blur(20px) saturate(1.4);
  backdrop-filter: blur(20px) saturate(1.4);
}

.app-bar__inner {
  display: flex;
  align-items: center;
  gap: 28px;
  width: 100%;
  max-width: var(--page-max);
  height: 76px;
  margin: 0 auto;
  padding: 0 40px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  flex: none;
  border-radius: var(--radius-sm);
}

.brand__mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 13px;
  color: #ffffff;
  background:
    radial-gradient(120% 120% at 18% 12%, rgba(255, 255, 255, 0.5), transparent 48%),
    linear-gradient(145deg, #3c8cff 0%, #0b57d0 62%, #063f9e 100%);
  box-shadow:
    0 8px 18px -8px rgba(11, 87, 208, 0.75),
    inset 0 1px 0 rgba(255, 255, 255, 0.35);
}

.brand__mark svg {
  width: 23px;
  height: 23px;
}

.brand__mark--small {
  width: 30px;
  height: 30px;
  border-radius: 9px;
}

.brand__mark--small svg {
  width: 16px;
  height: 16px;
}

.brand__text {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}

.brand__name {
  font-size: 19px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.brand__dot {
  color: var(--primary);
}

.brand__sub {
  margin-top: 3px;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.14em;
  color: var(--on-surface-muted);
}

.app-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: 8px;
}

.nav-link {
  position: relative;
  padding: 8px 14px;
  border-radius: var(--radius-full);
  font-size: 13.5px;
  font-weight: 500;
  color: var(--on-surface-variant);
  transition:
    color 0.18s var(--ease),
    background-color 0.18s var(--ease);
}

.nav-link:hover {
  color: var(--primary);
  background: rgba(11, 87, 208, 0.06);
}

.nav-link.is-active {
  color: var(--primary);
  font-weight: 600;
}

.nav-link.is-active::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -9px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--primary);
  transform: translateX(-50%);
}

.app-bar__actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  padding: 0 12px;
  border: 1px solid var(--outline-variant);
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.72);
  color: var(--on-surface-variant);
  font-size: 12px;
  font-weight: 600;
  transition:
    border-color 0.18s var(--ease),
    background-color 0.18s var(--ease);
}

.status-pill:hover {
  border-color: var(--primary);
  background: #ffffff;
}

.status-pill .icon {
  width: 14px;
  height: 14px;
  color: var(--on-surface-muted);
}

.status-dot {
  width: 7px;
  height: 7px;
  flex: none;
  border-radius: 50%;
  background: #9aa4b4;
  box-shadow: 0 0 0 3px rgba(154, 164, 180, 0.12);
}

.status-pill.is-ready {
  color: #125c3d;
  border-color: #b9e0ce;
  background: #f2fbf6;
}

.status-pill.is-ready .status-dot {
  background: #1b7f4d;
  box-shadow: 0 0 0 3px rgba(27, 127, 77, 0.13);
}

.status-pill.is-demo {
  color: #7a4700;
  border-color: #f0d5ac;
  background: #fffaf1;
}

.status-pill.is-demo .status-dot {
  background: #b8730a;
  box-shadow: 0 0 0 3px rgba(184, 115, 10, 0.14);
}

.app-settings {
  min-height: 40px;
}

/* ==========================================================================
   Page shell
   ========================================================================== */

.page {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: var(--page-max);
  margin: 0 auto;
  padding: 46px 40px 20px;
}

/* ==========================================================================
   Workspace
   ========================================================================== */

.workspace {
  display: grid;
  grid-template-columns: minmax(340px, 400px) minmax(0, 1fr);
  gap: 24px;
  align-items: start;
}

.left-col {
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-width: 0;
}

.card {
  position: relative;
  border: 1px solid rgba(213, 220, 232, 0.78);
  border-radius: var(--radius-xl);
  background: rgba(255, 255, 255, 0.86);
  box-shadow: var(--shadow-soft);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
}

.overline {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.18em;
  color: var(--on-surface-muted);
}

.overline .icon {
  width: 14px;
  height: 14px;
  color: var(--primary);
}

.card-eyebrow {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.18em;
  color: var(--primary);
}

/* ==========================================================================
   Engine card
   ========================================================================== */

.engine-card {
  padding: 19px 20px 17px;
  border: 1px solid rgba(196, 212, 239, 0.9);
  border-radius: var(--radius-lg);
  background:
    radial-gradient(120% 130% at 100% 0%, rgba(207, 226, 255, 0.66), transparent 62%),
    rgba(255, 255, 255, 0.82);
  box-shadow: 0 18px 44px -34px rgba(11, 87, 208, 0.45);
}

.engine-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 13px;
}

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 4px;
  border-radius: var(--radius-full);
  background: var(--surface-container);
  border: 1px solid rgba(213, 220, 232, 0.68);
}

.provider-btn {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 10px;
  border: 0;
  border-radius: var(--radius-full);
  background: transparent;
  color: var(--on-surface-variant);
  font-size: 13px;
  font-weight: 600;
  transition:
    background-color 0.2s var(--ease),
    color 0.2s var(--ease),
    box-shadow 0.2s var(--ease);
}

.provider-btn .icon {
  width: 17px;
  height: 17px;
}

.provider-btn:hover {
  color: var(--primary);
}

.provider-btn[aria-pressed="true"] {
  background: var(--surface-bright);
  color: var(--primary);
  box-shadow: 0 3px 10px -4px rgba(16, 48, 96, 0.22);
}

.segment-check {
  display: none;
}

.engine-model-row {
  position: relative;
  margin-top: 11px;
}

.engine-model-row select {
  width: 100%;
  height: 46px;
  padding: 0 36px 0 32px;
  border: 1px solid var(--outline-variant);
  border-radius: 13px;
  background: rgba(255, 255, 255, 0.9);
  color: var(--on-surface);
  font-size: 13.5px;
  font-weight: 600;
  appearance: none;
  -webkit-appearance: none;
  text-overflow: ellipsis;
  cursor: pointer;
  transition: border-color 0.18s var(--ease);
}

.engine-model-row select:hover {
  border-color: #a9bddc;
}

.engine-model-row select:focus {
  border-color: var(--primary);
  outline: none;
  box-shadow: 0 0 0 3px rgba(11, 87, 208, 0.12);
}

.engine-status-dot {
  position: absolute;
  top: 50%;
  left: 14px;
  z-index: 1;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #9aa4b4;
  transform: translateY(-50%);
  pointer-events: none;
}

.engine-status-dot.is-ready {
  background: #1b7f4d;
  box-shadow: 0 0 0 3px rgba(27, 127, 77, 0.12);
}

.engine-status-dot.is-demo {
  background: #b8730a;
  box-shadow: 0 0 0 3px rgba(184, 115, 10, 0.12);
}

.select-chevron {
  position: absolute;
  top: 50%;
  right: 13px;
  width: 16px;
  height: 16px;
  color: var(--on-surface-muted);
  transform: translateY(-50%);
  pointer-events: none;
}

.engine-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 11px;
  padding: 0 2px;
}

.engine-url {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  color: var(--on-surface-muted);
  font-size: 10.5px;
  font-family: var(--font-mono);
}

.engine-url .icon {
  width: 12px;
  height: 12px;
  flex: none;
}

.engine-url span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#engineAuth {
  flex: none;
  font-size: 11.5px;
}

/* ==========================================================================
   Composer
   ========================================================================== */

.composer {
  padding: 25px 24px 22px;
}

.card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 20px;
}

.card-head h2 {
  margin-top: 2px;
  font-size: 21px;
  font-weight: 800;
  letter-spacing: -0.025em;
}

.step-pill {
  flex: none;
  margin-top: 6px;
  padding: 5px 10px;
  border-radius: var(--radius-full);
  background: #f0f5ff;
  color: var(--on-surface-muted);
  font-size: 10.5px;
  font-weight: 600;
}

.field-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 9px;
}

.field-head label,
.field-head .label {
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: 0.01em;
  color: var(--on-surface);
}

.optional {
  margin-left: 3px;
  font-size: 10px;
  font-weight: 500;
  color: var(--on-surface-muted);
}

.field-helper,
.char-count {
  font-size: 10.5px;
  color: var(--on-surface-muted);
  font-variant-numeric: tabular-nums;
}

.char-count.is-warning {
  color: var(--warning);
}

.textarea-wrap {
  position: relative;
}

.textarea-wrap textarea {
  display: block;
  width: 100%;
  min-height: 138px;
  padding: 14px 15px 34px;
  border: 1.5px solid var(--outline-variant);
  border-radius: 16px;
  background: #fbfdff;
  color: var(--on-surface);
  font-size: 14.5px;
  line-height: 1.7;
  resize: vertical;
  transition:
    border-color 0.18s var(--ease),
    box-shadow 0.18s var(--ease),
    background-color 0.18s var(--ease);
}

.textarea-wrap textarea::placeholder {
  color: #97a2b4;
}

.textarea-wrap textarea:hover {
  border-color: #bccbe2;
}

.textarea-wrap textarea:focus {
  outline: none;
  border-color: var(--primary);
  background: #ffffff;
  box-shadow: 0 0 0 4px rgba(11, 87, 208, 0.09);
}

.textarea-kbd {
  position: absolute;
  right: 12px;
  bottom: 10px;
  padding: 3px 6px;
  border-radius: 6px;
  background: var(--surface-container);
  color: var(--on-surface-muted);
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.04em;
  pointer-events: none;
}

.section-divider {
  height: 1px;
  margin: 20px 0;
  background: linear-gradient(90deg, transparent, var(--outline-soft) 12%, var(--outline-soft) 88%, transparent);
}

/* Reference upload */

.ref-zone {
  position: relative;
  padding: 10px;
  border: 1.5px dashed #c9d8ef;
  border-radius: 16px;
  background:
    radial-gradient(90% 120% at 0% 0%, rgba(220, 236, 255, 0.5), transparent 62%),
    #f9fbff;
  transition:
    border-color 0.18s var(--ease),
    background-color 0.18s var(--ease),
    box-shadow 0.18s var(--ease);
}

.ref-zone.is-dragover {
  border-color: var(--primary);
  background: #edf4ff;
  box-shadow: 0 0 0 4px rgba(11, 87, 208, 0.09);
}

.ref-zone.is-full {
  border-style: solid;
  border-color: var(--outline-soft);
}

.ref-empty {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 3px 2px;
}

.ref-icon {
  display: grid;
  width: 36px;
  height: 36px;
  flex: none;
  place-items: center;
  border-radius: 11px;
  background: var(--primary-container);
  color: var(--primary);
}

.ref-icon .icon {
  width: 18px;
  height: 18px;
}

.ref-empty-copy {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.35;
}

.ref-empty-copy strong {
  font-size: 12.5px;
  font-weight: 700;
}

.ref-empty-copy span {
  margin-top: 2px;
  font-size: 10.5px;
  color: var(--on-surface-muted);
}

#refBrowse {
  flex: none;
  margin-left: auto;
  min-height: 32px;
  padding: 0 11px;
  border: 1px solid #d3e0f4;
  background: #ffffff;
  font-size: 11.5px;
}

.ref-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 7px;
}

.ref-item {
  position: relative;
  aspect-ratio: 1;
  overflow: hidden;
  border-radius: 10px;
  background: var(--surface-container);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.5);
}

.ref-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.ref-remove {
  position: absolute;
  top: 4px;
  right: 4px;
  display: grid;
  width: 21px;
  height: 21px;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(15, 23, 36, 0.66);
  color: #ffffff;
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  transition:
    background-color 0.16s var(--ease),
    transform 0.16s var(--ease);
}

.ref-remove:hover {
  background: var(--error);
  transform: scale(1.06);
}

.ref-remove .icon {
  width: 12px;
  height: 12px;
}

.ref-index {
  position: absolute;
  bottom: 4px;
  left: 5px;
  padding: 1px 5px;
  border-radius: 4px;
  background: rgba(15, 23, 36, 0.5);
  color: rgba(255, 255, 255, 0.9);
  font-family: var(--font-mono);
  font-size: 8px;
  line-height: 1.5;
  letter-spacing: 0.06em;
}

#refHint.is-full {
  color: var(--warning);
}

/* Parameters */

.setting-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.setting-row .label {
  font-size: 12.5px;
  font-weight: 700;
}

.setting-value {
  font-size: 10.5px;
  color: var(--on-surface-muted);
  font-variant-numeric: tabular-nums;
}

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

.ratio-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 62px;
  padding: 7px 3px 6px;
  border: 1.5px solid #dfe8f5;
  border-radius: 13px;
  background: #f8fbff;
  color: var(--on-surface-variant);
  transition:
    border-color 0.16s var(--ease),
    background-color 0.16s var(--ease),
    color 0.16s var(--ease),
    transform 0.16s var(--ease);
}

.ratio-btn:hover {
  border-color: #a9c3e9;
  background: #f2f7ff;
  transform: translateY(-1px);
}

.ratio-btn[aria-pressed="true"] {
  border-color: var(--primary);
  background: var(--primary-container);
  color: var(--primary);
}

.ratio-shape {
  display: block;
  width: 22px;
  height: 22px;
  border: 1.6px solid currentColor;
  border-radius: 4px;
  opacity: 0.85;
}

.ratio-btn[data-ratio="4:3"] .ratio-shape {
  width: 24px;
  height: 18px;
}

.ratio-btn[data-ratio="3:4"] .ratio-shape {
  width: 18px;
  height: 24px;
}

.ratio-btn[data-ratio="16:9"] .ratio-shape {
  width: 28px;
  height: 16px;
}

.ratio-btn[data-ratio="9:16"] .ratio-shape {
  width: 16px;
  height: 28px;
}

.ratio-label {
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.01em;
  line-height: 1;
}

.two-col {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 10px;
  margin-top: 13px;
}

.two-col.is-single {
  grid-template-columns: minmax(0, 1fr);
}

.two-col.is-single #countField {
  max-width: 180px;
}

.mini-field > label {
  display: block;
  margin-bottom: 5px;
  font-size: 10.5px;
  font-weight: 600;
  color: var(--on-surface-muted);
}

.select-wrap {
  position: relative;
}

.select-wrap select {
  width: 100%;
  height: 38px;
  padding: 0 28px 0 11px;
  border: 1px solid var(--outline-variant);
  border-radius: 11px;
  background: #ffffff;
  color: var(--on-surface);
  font-size: 11.5px;
  font-weight: 600;
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
}

.select-wrap select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(11, 87, 208, 0.1);
}

.select-wrap .icon {
  position: absolute;
  top: 50%;
  right: 9px;
  width: 14px;
  height: 14px;
  color: var(--on-surface-muted);
  transform: translateY(-50%);
  pointer-events: none;
}

.stepper {
  display: flex;
  align-items: center;
  height: 38px;
  border: 1px solid var(--outline-variant);
  border-radius: 11px;
  background: #ffffff;
  overflow: hidden;
}

.stepper button {
  display: grid;
  width: 32px;
  height: 100%;
  flex: none;
  place-items: center;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--on-surface-variant);
  transition: background-color 0.16s var(--ease);
}

.stepper button:hover:not(:disabled) {
  background: var(--surface-container);
  color: var(--primary);
}

.stepper button:disabled {
  opacity: 0.32;
}

.stepper .icon {
  width: 14px;
  height: 14px;
}

#countValue {
  flex: 1;
  min-width: 18px;
  text-align: center;
  font-size: 12px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.micro-hint {
  min-height: 15px;
  margin-top: 6px;
  font-size: 10px;
  line-height: 1.5;
  color: var(--on-surface-muted);
}

.custom-size-block {
  margin-top: 8px;
  padding-top: 12px;
  border-top: 1px solid #edf2fa;
}

.switch-row {
  display: flex;
  align-items: center;
  gap: 16px;
  cursor: pointer;
}

.switch-copy {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.4;
}

.switch-copy strong {
  font-size: 12px;
  font-weight: 600;
}

.switch-copy small {
  margin-top: 2px;
  font-size: 10px;
  color: var(--on-surface-muted);
}

.switch {
  position: relative;
  width: 42px;
  height: 24px;
  flex: none;
  margin-left: auto;
  border-radius: var(--radius-full);
  background: #c3cddc;
  transition: background-color 0.2s var(--ease);
}

.switch-thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 1px 4px rgba(16, 32, 56, 0.28);
  transition: transform 0.2s var(--ease);
}

.switch-row input:checked + .switch {
  background: var(--primary);
}

.switch-row input:checked + .switch .switch-thumb {
  transform: translateX(18px);
}

.switch-row input:focus-visible + .switch {
  outline: 3px solid rgba(11, 87, 208, 0.38);
  outline-offset: 2px;
}

.size-inputs {
  display: flex;
  align-items: flex-end;
  gap: 7px;
  margin-top: 11px;
  padding-left: 2px;
}

.size-field {
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 9px;
  font-weight: 600;
  color: var(--on-surface-muted);
}

.size-field input {
  width: 76px;
  height: 34px;
  padding: 0 8px;
  border: 1px solid var(--outline-variant);
  border-radius: 9px;
  background: #ffffff;
  font-size: 11.5px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.size-field input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(11, 87, 208, 0.1);
}

.size-times {
  padding-bottom: 9px;
  font-size: 11px;
  color: var(--on-surface-muted);
}

.size-unit {
  padding-bottom: 8px;
  font-size: 10px;
  color: var(--on-surface-muted);
}

/* Advanced */

.advanced-block {
  margin-top: 14px;
  border: 1px solid #e5edf8;
  border-radius: 13px;
  background: #fbfdff;
  overflow: hidden;
}

.advanced-block summary {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  list-style: none;
  cursor: pointer;
  user-select: none;
}

.advanced-block summary::-webkit-details-marker {
  display: none;
}

.summary-title {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--on-surface-variant);
}

.summary-title .icon {
  width: 14px;
  height: 14px;
  color: var(--primary);
}

.summary-note {
  margin-left: auto;
  font-size: 9.5px;
  color: var(--on-surface-muted);
}

.summary-chevron {
  width: 14px;
  height: 14px;
  color: var(--on-surface-muted);
  transition: transform 0.2s var(--ease);
}

.advanced-block[open] .summary-chevron {
  transform: rotate(180deg);
}

.advanced-block[open] summary {
  border-bottom: 1px solid #edf2fa;
}

.advanced-body {
  padding: 11px 12px 12px;
}

.advanced-body label {
  display: block;
  margin-bottom: 5px;
  font-size: 10px;
  font-weight: 600;
  color: var(--on-surface-muted);
}

.advanced-body textarea {
  display: block;
  width: 100%;
  min-height: 54px;
  padding: 8px 10px;
  border: 1px solid var(--outline-variant);
  border-radius: 9px;
  background: #ffffff;
  font-size: 11.5px;
  line-height: 1.55;
  resize: vertical;
}

.advanced-body textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(11, 87, 208, 0.09);
}

.field-hint {
  margin-top: 5px;
  font-size: 9.5px;
  line-height: 1.5;
  color: var(--on-surface-muted);
}

/* Generate */

.generate-btn {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  min-height: 54px;
  margin-top: 16px;
  padding: 0 20px;
  border: 0;
  border-radius: var(--radius-full);
  background:
    radial-gradient(120% 160% at 12% 0%, rgba(255, 255, 255, 0.28), transparent 45%),
    linear-gradient(120deg, #0b57d0 0%, #1668e8 58%, #2f7bff 100%);
  color: #ffffff;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.01em;
  box-shadow:
    0 16px 32px -16px rgba(11, 87, 208, 0.8),
    inset 0 1px 0 rgba(255, 255, 255, 0.25);
  overflow: hidden;
  transition:
    transform 0.18s var(--ease),
    box-shadow 0.18s var(--ease),
    filter 0.18s var(--ease);
}

.generate-btn::after {
  content: "";
  position: absolute;
  top: 0;
  left: -60%;
  width: 40%;
  height: 100%;
  background: linear-gradient(100deg, transparent, rgba(255, 255, 255, 0.22), transparent);
  transform: skewX(-18deg);
  transition: left 0.55s var(--ease);
  pointer-events: none;
}

.generate-btn:hover {
  transform: translateY(-1px);
  box-shadow:
    0 20px 38px -16px rgba(11, 87, 208, 0.9),
    inset 0 1px 0 rgba(255, 255, 255, 0.25);
}

.generate-btn:hover::after {
  left: 120%;
}

.generate-btn:active {
  transform: translateY(0);
}

.generate-btn:disabled {
  filter: grayscale(0.25);
  opacity: 0.6;
}

.generate-btn.is-loading {
  background: linear-gradient(120deg, #3d4a5e 0%, #263246 100%);
  box-shadow: 0 14px 28px -18px rgba(16, 24, 40, 0.8);
}

.generate-icon {
  display: grid;
  width: 24px;
  height: 24px;
  place-items: center;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.16);
}

.generate-icon .icon {
  width: 15px;
  height: 15px;
}

.generate-kbd {
  margin-left: 2px;
  padding: 3px 7px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.14);
  color: rgba(255, 255, 255, 0.85);
  font-size: 10px;
  font-weight: 500;
}

.generate-spinner {
  display: none;
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: #ffffff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.generate-btn.is-loading .generate-icon,
.generate-btn.is-loading .generate-kbd {
  display: none;
}

.generate-btn.is-loading .generate-spinner {
  display: block;
}

.cost-hint {
  margin-top: 8px;
  text-align: center;
  font-size: 9.5px;
  line-height: 1.5;
  color: var(--on-surface-muted);
}

/* ==========================================================================
   Studio / canvas
   ========================================================================== */

.studio {
  display: flex;
  flex-direction: column;
  min-height: 780px;
  padding: 24px 24px 16px;
}

.studio-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.studio-title-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 11px;
}

.studio-title-row h2 {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.03em;
}

.studio-status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 24px;
  padding: 0 9px;
  border: 1px solid var(--outline-soft);
  border-radius: var(--radius-full);
  background: #f8fbff;
  color: var(--on-surface-muted);
  font-size: 10px;
  font-weight: 600;
}

.studio-status .status-dot {
  width: 6px;
  height: 6px;
  box-shadow: none;
}

.studio-status[data-state="running"] {
  color: #0b57d0;
  border-color: #c9dcff;
  background: #eff6ff;
}

.studio-status[data-state="running"] .status-dot {
  background: #0b57d0;
  animation: pulse 1.5s ease-in-out infinite;
}

.studio-status[data-state="success"] {
  color: #125c3d;
  border-color: #c4e6d7;
  background: #f2fbf6;
}

.studio-status[data-state="success"] .status-dot {
  background: #1b7f4d;
}

.studio-status[data-state="error"] {
  color: var(--error);
  border-color: #f3c7c4;
  background: #fff7f6;
}

.studio-status[data-state="error"] .status-dot {
  background: var(--error);
}

.studio-status[data-state="demo"] {
  color: #7a4700;
  border-color: #f0d5ac;
  background: #fffaf1;
}

.studio-status[data-state="demo"] .status-dot {
  background: #b8730a;
}

.studio-sub {
  margin-top: 5px;
  font-size: 12px;
  color: var(--on-surface-muted);
}

.studio-actions {
  display: flex;
  align-items: center;
  gap: 2px;
}

.canvas {
  position: relative;
  display: flex;
  flex: 1;
  flex-direction: column;
  min-height: 600px;
  margin-top: 18px;
  border: 1px solid #e0e9f7;
  border-radius: 20px;
  background:
    radial-gradient(110% 80% at 8% 0%, #eaf3ff 0%, transparent 58%),
    radial-gradient(100% 100% at 100% 100%, #dcebff 0%, transparent 56%),
    #f4f8ff;
  overflow: hidden;
  transition: background-color 0.25s var(--ease);
}

.canvas.is-error {
  background:
    radial-gradient(110% 80% at 50% 0%, #fff5f4 0%, transparent 58%),
    #fdfbfb;
}

/* Empty state */

.empty-state {
  display: grid;
  grid-template-columns: minmax(0, 1.04fr) minmax(0, 0.96fr);
  flex: 1;
  min-height: 600px;
}

.empty-visual {
  position: relative;
  min-height: 100%;
  overflow: hidden;
  border-right: 1px solid rgba(255, 255, 255, 0.5);
}

.empty-art {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.empty-visual::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg, rgba(244, 250, 255, 0.05) 0%, transparent 34%, rgba(9, 38, 85, 0.06) 100%),
    linear-gradient(90deg, transparent 66%, rgba(244, 249, 255, 0.72) 100%);
  pointer-events: none;
}

.empty-badge {
  position: absolute;
  top: 16px;
  left: 16px;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 10px;
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.58);
  color: #18355f;
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.03em;
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}

.empty-badge .status-dot {
  width: 5px;
  height: 5px;
  background: #1b7f4d;
  box-shadow: none;
}

.sample-prompt {
  position: absolute;
  right: 16px;
  bottom: 16px;
  left: 16px;
  z-index: 2;
  padding: 13px 14px 10px;
  border: 1px solid rgba(255, 255, 255, 0.78);
  border-radius: 15px;
  background: rgba(255, 255, 255, 0.64);
  box-shadow: 0 16px 38px -26px rgba(13, 45, 96, 0.6);
  -webkit-backdrop-filter: blur(16px) saturate(1.2);
  backdrop-filter: blur(16px) saturate(1.2);
}

.sample-label {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--primary);
}

.sample-label .icon {
  width: 12px;
  height: 12px;
}

.sample-prompt p {
  margin: 6px 0 3px;
  font-size: 11.5px;
  line-height: 1.6;
  color: #21344f;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.sample-prompt .md-text-button {
  min-height: 28px;
  padding: 0;
  font-size: 10.5px;
}

.empty-copy {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 38px 34px;
}

.empty-index {
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.16em;
  color: var(--primary);
}

.empty-copy h2 {
  margin-top: 12px;
  font-size: clamp(27px, 2.7vw, 38px);
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: -0.04em;
  color: #101722;
}

.empty-copy > p {
  max-width: 320px;
  margin-top: 13px;
  font-size: 12px;
  line-height: 1.75;
  color: var(--on-surface-variant);
}

.empty-steps {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-top: 22px;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--on-surface-muted);
}

.empty-steps i {
  width: 20px;
  height: 1px;
  background: #c6d4e8;
}

.empty-tip {
  display: inline-flex;
  align-items: center;
  align-self: flex-start;
  gap: 6px;
  margin-top: 20px;
  padding: 7px 10px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid #e0e9f7;
  font-size: 9.5px;
  color: var(--on-surface-muted);
}

.empty-tip .icon {
  width: 12px;
  height: 12px;
  color: var(--primary);
}

/* Result grid */

.result-shell {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-height: 0;
  padding: 12px;
}

.result-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px 12px;
  font-size: 11.5px;
  color: var(--on-surface-variant);
}

.result-banner strong {
  font-weight: 700;
  color: var(--on-surface);
}

.result-banner .banner-spacer {
  flex: 1;
}

.result-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(213, 220, 232, 0.9);
  font-size: 9px;
  font-weight: 600;
  color: var(--on-surface-muted);
}

.result-badge .status-dot {
  width: 5px;
  height: 5px;
  box-shadow: none;
  background: #1b7f4d;
}

.result-grid {
  display: grid;
  flex: 1;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  align-content: center;
  gap: 12px;
  min-height: 0;
}

.result-grid[data-count="1"] {
  grid-template-columns: minmax(0, 1fr);
}

.result-grid[data-count="1"] .result-card {
  max-height: 620px;
}

.result-card {
  position: relative;
  aspect-ratio: var(--card-ratio, 1);
  max-height: 520px;
  overflow: hidden;
  border-radius: 16px;
  background: #dfe9f8;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.55) inset,
    0 16px 38px -28px rgba(9, 38, 85, 0.5);
  cursor: zoom-in;
  isolation: isolate;
}

.result-grid[data-count="1"] .result-card {
  aspect-ratio: var(--card-ratio, 1);
}

.result-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.45s var(--ease);
}

.result-card:hover img {
  transform: scale(1.025);
}

.result-card__shade {
  position: absolute;
  inset: auto 0 0;
  z-index: 1;
  height: 42%;
  background: linear-gradient(180deg, transparent, rgba(8, 20, 40, 0.52));
  opacity: 0;
  transition: opacity 0.2s var(--ease);
  pointer-events: none;
}

.result-card:hover .result-card__shade {
  opacity: 1;
}

.result-card__actions {
  position: absolute;
  right: 9px;
  bottom: 9px;
  z-index: 2;
  display: flex;
  gap: 5px;
  opacity: 0;
  transform: translateY(5px);
  transition:
    opacity 0.2s var(--ease),
    transform 0.2s var(--ease);
}

.result-card:hover .result-card__actions,
.result-card:focus-within .result-card__actions {
  opacity: 1;
  transform: translateY(0);
}

.result-action {
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 9px;
  background: rgba(16, 24, 40, 0.58);
  color: #ffffff;
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  transition:
    background-color 0.16s var(--ease),
    transform 0.16s var(--ease);
}

.result-action:hover {
  background: rgba(11, 87, 208, 0.9);
  transform: translateY(-1px);
}

.result-action .icon {
  width: 15px;
  height: 15px;
}

.result-index {
  position: absolute;
  top: 9px;
  left: 9px;
  z-index: 2;
  padding: 2px 6px;
  border-radius: 5px;
  background: rgba(16, 24, 40, 0.46);
  color: rgba(255, 255, 255, 0.9);
  font-family: var(--font-mono);
  font-size: 8px;
  letter-spacing: 0.06em;
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}

/* Generating state */

.generating-state {
  display: flex;
  flex: 1;
  flex-direction: column;
  padding: 14px;
}

.generating-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 4px 14px;
}

.generating-orb {
  position: relative;
  display: grid;
  width: 38px;
  height: 38px;
  flex: none;
  place-items: center;
  border-radius: 50%;
  background: var(--primary-container);
  color: var(--primary);
}

.generating-orb::before {
  content: "";
  position: absolute;
  inset: -5px;
  border: 1.5px solid rgba(11, 87, 208, 0.28);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 1.3s linear infinite;
}

.generating-orb .icon {
  width: 17px;
  height: 17px;
}

.generating-copy {
  display: flex;
  flex-direction: column;
  line-height: 1.4;
}

.generating-copy strong {
  font-size: 12.5px;
  font-weight: 700;
}

.generating-copy span {
  margin-top: 2px;
  font-size: 10px;
  color: var(--on-surface-muted);
  font-variant-numeric: tabular-nums;
}

.generating-copy .generating-message {
  margin-top: 3px;
  color: var(--on-surface-variant);
  font-variant-numeric: normal;
}

.generating-bar {
  flex: 1;
  height: 4px;
  min-width: 60px;
  max-width: 220px;
  margin-left: auto;
  border-radius: var(--radius-full);
  background: rgba(11, 87, 208, 0.1);
  overflow: hidden;
}

.generating-bar::after {
  content: "";
  display: block;
  width: 42%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #7db4ff, #0b57d0);
  animation: indeterminate 1.5s var(--ease) infinite;
}

.loading-grid {
  display: grid;
  flex: 1;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 12px;
  align-content: center;
}

.loading-card {
  position: relative;
  aspect-ratio: var(--card-ratio, 1);
  max-height: 480px;
  border-radius: 16px;
  background:
    linear-gradient(100deg, rgba(255, 255, 255, 0) 28%, rgba(255, 255, 255, 0.62) 48%, rgba(255, 255, 255, 0) 68%),
    linear-gradient(150deg, #e3edfc, #d6e5fa 52%, #e8f1fd);
  background-size: 220% 100%, 100% 100%;
  animation: shimmer 1.8s linear infinite;
  overflow: hidden;
}

.loading-card::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 34px;
  height: 34px;
  border: 2px solid rgba(11, 87, 208, 0.18);
  border-top-color: rgba(11, 87, 208, 0.72);
  border-radius: 50%;
  animation: spin-center 1s linear infinite;
}

/* Error state */

.error-state {
  display: flex;
  flex: 1;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 36px;
  text-align: center;
}

.error-icon {
  display: grid;
  width: 48px;
  height: 48px;
  place-items: center;
  border-radius: 15px;
  background: var(--error-container);
  color: var(--error);
}

.error-icon .icon {
  width: 22px;
  height: 22px;
}

.error-state h3 {
  margin-top: 16px;
  font-size: 16px;
  font-weight: 800;
  letter-spacing: -0.01em;
}

.error-state p {
  max-width: 440px;
  margin-top: 8px;
  font-size: 12px;
  line-height: 1.7;
  color: var(--on-surface-variant);
  overflow-wrap: anywhere;
}

.error-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-top: 18px;
}

/* Canvas footer */

.canvas-controls {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(220px, 280px);
  grid-template-rows: auto auto;
  align-items: start;
  column-gap: 16px;
  row-gap: 9px;
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--outline-soft);
}

.ref-head {
  grid-column: 1;
  grid-row: 1;
  margin-bottom: 0;
}

.ref-zone {
  grid-column: 1;
  grid-row: 2;
}

.generate-panel {
  display: flex;
  flex-direction: column;
  grid-column: 2;
  grid-row: 2;
  min-width: 0;
}

.canvas-controls .generate-btn {
  margin-top: 0;
}

.canvas-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 4px 2px;
  font-size: 9.5px;
  color: var(--on-surface-muted);
}

.canvas-footer > span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.canvas-footer .icon {
  width: 12px;
  height: 12px;
}

.canvas-shortcut {
  font-variant-numeric: tabular-nums;
}

.canvas-shortcut kbd {
  min-width: 16px;
  height: 17px;
  padding: 0 4px;
  border: 1px solid var(--outline-soft);
  background: #f5f8fe;
  color: var(--on-surface-muted);
  font-size: 9px;
}

/* ==========================================================================
   Recent & features
   ========================================================================== */

.recent-section {
  margin-top: 54px;
}

.section-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.section-head h2 {
  margin-top: 3px;
  font-size: 25px;
  font-weight: 800;
  letter-spacing: -0.035em;
}

.recent-scroll {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.history-card {
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 0;
  border: 1px solid rgba(213, 220, 232, 0.82);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: 0 14px 34px -30px rgba(11, 87, 208, 0.28);
  overflow: hidden;
  text-align: left;
  transition:
    box-shadow 0.2s var(--ease),
    transform 0.2s var(--ease),
    border-color 0.2s var(--ease);
}

.history-card:hover {
  transform: translateY(-2px);
  border-color: #bfd2ef;
  box-shadow: 0 20px 40px -28px rgba(11, 87, 208, 0.42);
}

.history-cover {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2px;
  aspect-ratio: 1.62;
  background: #e8f0fc;
  overflow: hidden;
}

.history-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.history-cover[data-count="1"] {
  grid-template-columns: 1fr;
}

.history-cover[data-count="1"] img {
  grid-column: span 2;
}

.history-cover[data-count="2"] {
  grid-template-columns: 1fr 1fr;
}

.history-cover[data-count="3"] img:first-child {
  grid-row: span 2;
}

.history-cover[data-count="3"] {
  grid-template-rows: 1fr 1fr;
}

.history-cover[data-count="3"] img:first-child {
  grid-row: span 2;
}

.history-cover .more-count {
  display: grid;
  place-items: center;
  background: var(--surface-container);
  color: var(--primary);
  font-size: 12px;
  font-weight: 700;
}

.history-body {
  padding: 10px 12px 12px;
}

.history-prompt {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  font-size: 10.5px;
  line-height: 1.55;
  color: var(--on-surface-variant);
}

.history-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  font-size: 8.5px;
  color: var(--on-surface-muted);
}

.history-engine {
  padding: 2px 6px;
  border-radius: 4px;
  background: #f0f5ff;
  color: var(--primary);
  font-weight: 700;
  letter-spacing: 0.02em;
}

.history-meta .dot-sep {
  width: 2px;
  height: 2px;
  border-radius: 50%;
  background: #aab4c4;
}

.history-empty {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 20px 22px;
  border: 1px dashed #cddbf0;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.48);
  color: var(--on-surface-muted);
}

.history-empty .history-empty-icon {
  display: grid;
  width: 38px;
  height: 38px;
  flex: none;
  place-items: center;
  border-radius: 11px;
  background: #eef5ff;
  color: var(--primary);
}

.history-empty strong {
  display: block;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--on-surface-variant);
}

.history-empty span {
  font-size: 10px;
}

.history-empty .md-text-button {
  margin-left: auto;
  flex: none;
}

.features {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-top: 44px;
}

.feature-card {
  display: flex;
  align-items: flex-start;
  gap: 13px;
  padding: 18px;
  border: 1px solid rgba(213, 220, 232, 0.72);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.55);
}

.feature-icon {
  display: grid;
  width: 36px;
  height: 36px;
  flex: none;
  place-items: center;
  border-radius: 10px;
  background: var(--primary-container);
  color: var(--primary);
}

.feature-icon .icon {
  width: 18px;
  height: 18px;
}

.feature-card h3 {
  font-size: 12.5px;
  font-weight: 700;
}

.feature-card p {
  margin-top: 4px;
  font-size: 10.5px;
  line-height: 1.6;
  color: var(--on-surface-muted);
}

/* ==========================================================================
   Footer
   ========================================================================== */

.footer {
  position: relative;
  z-index: 1;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  column-gap: 18px;
  row-gap: 12px;
  width: 100%;
  max-width: var(--page-max);
  margin: 0 auto;
  padding: 26px 40px 34px;
  border-top: 1px solid rgba(213, 220, 232, 0.6);
  color: var(--on-surface-muted);
  font-size: 10px;
}

.footer-brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: var(--on-surface-variant);
  font-size: 11px;
  font-weight: 700;
}

.footer p {
  flex: 1;
}

.footer-meta {
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.04em;
}

.footer-credit {
  flex: 1 0 100%;
  padding-top: 12px;
  border-top: 1px solid rgba(213, 220, 232, 0.55);
  font-size: 10.5px;
  letter-spacing: 0.02em;
  text-align: center;
  color: var(--on-surface-muted);
}

/* ==========================================================================
   Dialogs
   ========================================================================== */

dialog {
  color: var(--on-surface);
}

dialog::backdrop {
  background: rgba(16, 24, 40, 0.44);
  -webkit-backdrop-filter: blur(7px);
  backdrop-filter: blur(7px);
}

.settings-dialog {
  width: min(564px, calc(100vw - 32px));
  max-width: 564px;
  max-height: calc(100vh - 48px);
  margin: auto;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.6);
  border-radius: var(--radius-xl);
  background: #fbfdff;
  box-shadow: var(--shadow-float);
  overflow: hidden;
}

.settings-dialog[open] {
  animation: dialog-in 0.28s var(--ease);
}

.settings-dialog form {
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 48px);
}

.dialog-head {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 22px 24px 16px;
}

.dialog-icon {
  display: grid;
  width: 42px;
  height: 42px;
  flex: none;
  place-items: center;
  border-radius: 13px;
  background: var(--primary-container);
  color: var(--primary);
}

.dialog-icon .icon {
  width: 21px;
  height: 21px;
}

.dialog-head h2 {
  margin-top: 1px;
  font-size: 21px;
  font-weight: 800;
  letter-spacing: -0.03em;
}

.dialog-close {
  margin-left: auto;
}

.dialog-body {
  flex: 1 1 auto;
  min-height: 0;
  padding: 0 24px 20px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.dialog-lede {
  margin-bottom: 18px;
  padding: 10px 12px;
  border-radius: 11px;
  background: #f2f7ff;
  border: 1px solid #e1ebfa;
  font-size: 10.5px;
  line-height: 1.65;
  color: var(--on-surface-variant);
}

.dialog-section {
  margin-bottom: 15px;
}

.dialog-label {
  display: block;
  margin-bottom: 7px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--on-surface-muted);
  text-transform: uppercase;
}

.dialog-provider {
  background: #eef3fb;
}

.dialog-provider .provider-btn {
  min-height: 38px;
}

.field {
  position: relative;
  margin-bottom: 13px;
}

.field input {
  width: 100%;
  height: 56px;
  padding: 23px 52px 7px 15px;
  border: 1.5px solid var(--outline-variant);
  border-radius: 13px;
  background: #ffffff;
  color: var(--on-surface);
  font-size: 13px;
  font-weight: 500;
  transition:
    border-color 0.18s var(--ease),
    box-shadow 0.18s var(--ease);
}

.field input:hover {
  border-color: #b9c9e0;
}

.field input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3.5px rgba(11, 87, 208, 0.1);
}

.field input[aria-invalid="true"] {
  border-color: var(--error);
  box-shadow: 0 0 0 3px rgba(197, 34, 31, 0.09);
}

.field label {
  position: absolute;
  top: 50%;
  left: 15px;
  padding: 0 3px;
  color: var(--on-surface-muted);
  font-size: 12.5px;
  transform: translateY(-50%);
  transform-origin: left center;
  pointer-events: none;
  transition:
    top 0.16s var(--ease),
    transform 0.16s var(--ease),
    font-size 0.16s var(--ease),
    color 0.16s var(--ease);
}

.field input:focus + label,
.field input:not(:placeholder-shown) + label {
  top: 10px;
  transform: translateY(0);
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--primary);
}

.field input[type="password"] {
  letter-spacing: 0.02em;
}

.field input[type="password"]:not(:placeholder-shown) {
  letter-spacing: 0.14em;
}

#baseUrlInput {
  padding-right: 78px;
}

.field-action {
  position: absolute;
  top: 50%;
  right: 8px;
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--on-surface-muted);
  transform: translateY(-50%);
  transition:
    background-color 0.16s var(--ease),
    color 0.16s var(--ease);
}

.field-action:hover {
  background: var(--surface-container);
  color: var(--primary);
}

.field-action .icon {
  width: 18px;
  height: 18px;
}

.field-action--text {
  width: auto;
  padding: 0 10px;
  color: var(--primary);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.03em;
}

.field-action--text:hover {
  background: #eef5ff;
}

.field-error {
  margin: -7px 0 11px;
  padding-left: 3px;
  font-size: 10px;
  color: var(--error);
}

.field-error::before {
  content: "!  ";
  font-weight: 800;
}

.model-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin: -4px 0 15px;
}

.model-chip {
  padding: 4px 9px;
  border: 1px solid #dfe8f5;
  border-radius: var(--radius-full);
  background: #f7faff;
  color: var(--on-surface-variant);
  font-size: 9.5px;
  font-weight: 500;
  transition:
    border-color 0.16s var(--ease),
    color 0.16s var(--ease),
    background-color 0.16s var(--ease);
}

.model-chip:hover {
  border-color: #9eb9e6;
  color: var(--primary);
  background: #eef5ff;
}

.model-chip[aria-pressed="true"] {
  border-color: var(--primary);
  background: var(--primary-container);
  color: var(--on-primary-container);
  font-weight: 700;
}

.connection-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin: 2px 0 17px;
}

#testConnectionBtn {
  min-height: 38px;
  padding: 0 14px;
  font-size: 11.5px;
}

#testConnectionBtn .icon {
  width: 14px;
  height: 14px;
}

.button-spinner {
  display: none;
  width: 13px;
  height: 13px;
  border: 1.8px solid rgba(11, 87, 208, 0.22);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

#testConnectionBtn.is-loading .button-spinner {
  display: block;
}

#testConnectionBtn.is-loading > .icon {
  display: none;
}

.connection-result {
  flex: 1;
  min-width: 150px;
  font-size: 10px;
  line-height: 1.5;
  color: var(--on-surface-muted);
  overflow-wrap: anywhere;
}

.connection-result.is-success {
  color: var(--success);
}

.connection-result.is-error {
  color: var(--error);
}

.connection-result.is-warning {
  color: var(--warning);
}

.connection-result.is-loading {
  color: var(--primary);
}

.settings-advanced {
  margin-top: 4px;
  padding: 4px 0;
  border-top: 1px solid #e9f0fa;
  border-bottom: 1px solid #e9f0fa;
}

.settings-advanced .switch-row {
  padding: 10px 0;
}

.settings-advanced .switch-row + .switch-row {
  border-top: 1px solid #eff4fb;
}

.settings-advanced .switch-copy strong {
  font-size: 12px;
}

.settings-advanced .switch-copy small {
  font-size: 9.5px;
}

.privacy-note {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-top: 14px;
  padding: 9px 11px;
  border-radius: 10px;
  background: #f6f9fe;
  color: var(--on-surface-muted);
  font-size: 9.5px;
  line-height: 1.6;
}

.privacy-note .icon {
  width: 14px;
  height: 14px;
  flex: none;
  margin-top: 1px;
  color: var(--success);
}

.dialog-foot {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 24px 17px;
  border-top: 1px solid #e9f0fa;
  background: rgba(251, 253, 255, 0.96);
}

.dialog-transport {
  flex: 1;
  min-width: 0;
  font-size: 9px;
  line-height: 1.5;
  color: var(--on-surface-muted);
}

.dialog-foot-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: none;
}

#saveSettings {
  min-height: 40px;
  padding: 0 18px;
  font-size: 12.5px;
}

#saveSettings .icon {
  width: 15px;
  height: 15px;
}

/* ==========================================================================
   Lightbox
   ========================================================================== */

.lightbox-dialog {
  width: min(1180px, calc(100vw - 40px));
  max-width: 1180px;
  max-height: calc(100vh - 40px);
  margin: auto;
  padding: 0;
  border: 0;
  border-radius: 22px;
  background: transparent;
  box-shadow: 0 40px 120px -30px rgba(0, 0, 0, 0.72);
  overflow: visible;
}

.lightbox-dialog[open] {
  animation: dialog-in 0.28s var(--ease);
}

.lightbox-panel {
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 40px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 22px;
  background: #0b1220;
  color: #e8eefc;
  overflow: hidden;
}

.lightbox-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.lightbox-head .overline {
  color: rgba(232, 238, 252, 0.45);
}

.lightbox-meta {
  margin-top: 2px;
  font-size: 11.5px;
  font-weight: 600;
  color: rgba(232, 238, 252, 0.86);
}

.lightbox-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.lightbox-ref {
  background: rgba(255, 255, 255, 0.1);
  color: #e8eefc;
  min-height: 38px;
  font-size: 11.5px;
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.lightbox-ref:hover {
  background: rgba(255, 255, 255, 0.18);
}

.lightbox-ref .icon {
  width: 14px;
  height: 14px;
}

.lightbox-stage {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 260px;
  padding: 16px 62px;
  background:
    radial-gradient(80% 80% at 50% 50%, #111b2d 0%, #05080f 100%);
  overflow: hidden;
}

#lbImage {
  display: block;
  max-width: 100%;
  max-height: 68vh;
  border-radius: 6px;
  object-fit: contain;
  background: #05080f;
  box-shadow: 0 24px 60px -30px rgba(0, 0, 0, 0.9);
}

.lightbox-nav {
  position: absolute;
  top: 50%;
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
  transform: translateY(-50%);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  transition:
    background-color 0.16s var(--ease),
    opacity 0.16s var(--ease);
}

.lightbox-nav:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.2);
}

.lightbox-nav:disabled {
  opacity: 0.2;
}

.lightbox-nav .icon {
  width: 18px;
  height: 18px;
}

#lbPrev {
  left: 14px;
}

#lbNext {
  right: 14px;
}

.lightbox-counter {
  position: absolute;
  right: 18px;
  bottom: 14px;
  padding: 4px 9px;
  border-radius: var(--radius-full);
  background: rgba(0, 0, 0, 0.5);
  color: rgba(255, 255, 255, 0.75);
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.04em;
}

.lightbox-foot {
  padding: 14px 20px 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.07);
  max-height: 150px;
  overflow-y: auto;
}

.lightbox-foot p {
  font-size: 11.5px;
  line-height: 1.65;
  color: rgba(232, 238, 252, 0.72);
}

.lightbox-foot .revised-prompt {
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px dashed rgba(255, 255, 255, 0.12);
  color: rgba(232, 238, 252, 0.46);
  font-size: 10px;
}

/* ==========================================================================
   Snackbar
   ========================================================================== */

.snackbar {
  position: fixed;
  bottom: 24px;
  left: 50%;
  z-index: 80;
  display: flex;
  align-items: center;
  gap: 16px;
  max-width: min(520px, calc(100vw - 32px));
  padding: 12px 16px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 13px;
  background: #171c24;
  color: #f1f5fb;
  box-shadow: 0 20px 44px -16px rgba(0, 0, 0, 0.55);
  font-size: 11.5px;
  line-height: 1.5;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 14px);
  transition:
    opacity 0.22s var(--ease),
    transform 0.22s var(--ease);
}

.snackbar.is-visible {
  opacity: 1;
  pointer-events: auto;
  transform: translate(-50%, 0);
}

.snackbar-action {
  flex: none;
  padding: 4px 6px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #9dc2ff;
  font-size: 11px;
  font-weight: 700;
}

.snackbar-action:hover {
  background: rgba(157, 194, 255, 0.12);
}

/* ==========================================================================
   Animations
   ========================================================================== */

body.dialog-open {
  overflow: hidden;
}

#studio,
#studioPanel,
#recent,
#features {
  scroll-margin-top: 96px;
}

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

/* 保持自身居中，只做原地旋转；普通 spin 会覆盖 translate 导致图标绕圈。 */
@keyframes spin-center {
  from {
    transform: translate(-50%, -50%) rotate(0deg);
  }
  to {
    transform: translate(-50%, -50%) rotate(360deg);
  }
}

@keyframes pulse {
  0%,
  100% {
    opacity: 1;
    box-shadow: 0 0 0 0 rgba(11, 87, 208, 0.3);
  }
  50% {
    opacity: 0.7;
    box-shadow: 0 0 0 4px rgba(11, 87, 208, 0);
  }
}

@keyframes shimmer {
  from {
    background-position: 180% 0, 0 0;
  }
  to {
    background-position: -60% 0, 0 0;
  }
}

@keyframes indeterminate {
  0% {
    transform: translateX(-110%);
  }
  100% {
    transform: translateX(280%);
  }
}

@keyframes dialog-in {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.985);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes fade-up {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.result-card,
.history-card {
  animation: fade-up 0.35s var(--ease) both;
}

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

/* ==========================================================================
   Responsive
   ========================================================================== */

@media (max-width: 1240px) {
  .app-bar__inner,
  .page,
  .footer {
    padding-right: 28px;
    padding-left: 28px;
  }

  .workspace {
    grid-template-columns: minmax(330px, 370px) minmax(0, 1fr);
    gap: 20px;
  }

  .empty-copy {
    padding: 30px 26px;
  }

  .empty-visual::after {
    background:
      linear-gradient(180deg, rgba(244, 250, 255, 0.05) 0%, transparent 34%, rgba(9, 38, 85, 0.06) 100%);
  }

  .recent-scroll {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 1080px) {
  .app-nav {
    display: none;
  }

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

  .left-col {
    display: grid;
    grid-template-columns: minmax(280px, 0.82fr) minmax(0, 1.18fr);
    align-items: start;
    gap: 18px;
  }

  .composer {
    grid-column: 2;
  }

  .engine-card {
    grid-column: 1;
    grid-row: 1;
  }

  .studio {
    min-height: auto;
    margin-top: 0;
  }

  .canvas {
    min-height: 520px;
  }

  .empty-state {
    min-height: 520px;
  }

  .recent-scroll {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 860px) {
  .page {
    padding-top: 32px;
  }

  .left-col {
    display: flex;
    flex-direction: column;
    align-items: stretch;
  }

  .composer,
  .engine-card {
    grid-column: auto;
    grid-row: auto;
  }

  .composer {
    order: 2;
  }

  .engine-card {
    order: 1;
  }

  .empty-state {
    grid-template-columns: 1fr;
    min-height: 0;
  }

  .empty-visual {
    min-height: 340px;
    border-right: 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.55);
  }

  .empty-visual::after {
    background: linear-gradient(180deg, rgba(244, 250, 255, 0.05) 0%, transparent 48%, rgba(244, 249, 255, 0.8) 100%);
  }

  .empty-copy {
    padding: 26px 24px 30px;
  }

  .empty-copy h2 {
    font-size: 30px;
  }

  .empty-copy > p {
    max-width: none;
  }

  .canvas {
    min-height: auto;
  }

  .canvas-controls {
    grid-template-columns: 1fr;
  }

  .ref-head,
  .ref-zone,
  .generate-panel {
    grid-column: 1;
  }

  .ref-head {
    grid-row: 1;
  }

  .ref-zone {
    grid-row: 2;
  }

  .generate-panel {
    grid-row: 3;
  }

  .features {
    grid-template-columns: 1fr;
    gap: 10px;
  }

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

  .footer {
    flex-wrap: wrap;
    gap: 10px 16px;
    padding-top: 22px;
    padding-bottom: 26px;
  }

  .footer p {
    order: 3;
    flex-basis: 100%;
  }
}

@media (max-width: 640px) {
  body {
    font-size: 14px;
  }

  .app-bar__inner {
    height: 66px;
    padding: 0 16px;
    gap: 12px;
  }

  .brand__mark {
    width: 38px;
    height: 38px;
    border-radius: 12px;
  }

  .brand__name {
    font-size: 17px;
  }

  .brand__sub {
    display: none;
  }

  .status-pill {
    min-height: 36px;
    padding: 0 10px;
  }

  .status-pill > span:not(.status-dot) {
    display: none;
  }

  .status-pill .icon {
    display: none;
  }

  .app-settings {
    min-height: 38px;
    padding: 0 13px;
  }

  .app-settings span {
    display: none;
  }

  .app-settings .icon {
    width: 19px;
    height: 19px;
  }

  .page {
    padding: 26px 14px 12px;
  }

  .composer {
    padding: 20px 16px 17px;
  }

  .studio {
    padding: 18px 14px 12px;
  }

  .engine-card {
    padding: 16px;
  }

  .card-head h2,
  .studio-title-row h2 {
    font-size: 19px;
  }

  .step-pill {
    display: none;
  }

  .ratio-grid {
    gap: 5px;
  }

  .ratio-btn {
    min-height: 58px;
  }

  .ref-empty {
    flex-wrap: wrap;
    gap: 9px;
  }

  #refBrowse {
    width: auto;
    flex: 0 0 auto;
    margin-left: auto;
  }

  .ref-empty-copy {
    flex: 1;
  }

  .empty-visual {
    min-height: 300px;
  }

  .empty-badge {
    top: 12px;
    left: 12px;
  }

  .sample-prompt {
    right: 12px;
    bottom: 12px;
    left: 12px;
  }

  .empty-copy {
    padding: 22px 18px 26px;
  }

  .empty-copy h2 {
    font-size: 27px;
  }

  .empty-steps,
  .empty-tip {
    display: none;
  }

  .studio-head {
    gap: 8px;
  }

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

  .result-card {
    max-height: 420px;
  }

  .result-grid[data-count="1"] .result-card {
    max-height: 480px;
  }

  .result-banner {
    flex-wrap: wrap;
    gap: 6px;
  }

  .result-banner .banner-spacer {
    display: none;
  }

  .recent-scroll {
    grid-template-columns: 1fr;
  }

  .history-cover {
    aspect-ratio: 2.1;
  }

  .section-head h2 {
    font-size: 21px;
  }

  .recent-section {
    margin-top: 38px;
  }

  .features {
    margin-top: 32px;
  }

  .footer {
    padding: 20px 16px 26px;
  }

  .footer-meta {
    display: none;
  }

  .settings-dialog {
    width: calc(100% - 18px);
    max-width: calc(100% - 18px);
    max-height: calc(100vh - 18px);
    margin: auto 9px;
    border-radius: 22px;
  }

  .settings-dialog form {
    max-height: calc(100vh - 18px);
  }

  .dialog-head {
    padding: 17px 17px 13px;
  }

  .dialog-body {
    padding: 0 17px 16px;
  }

  .dialog-foot {
    flex-wrap: wrap;
    gap: 8px;
    padding: 12px 17px 14px;
  }

  .dialog-transport {
    flex-basis: 100%;
    order: 2;
  }

  .dialog-foot-actions {
    flex: 1;
    justify-content: flex-end;
  }

  .lightbox-dialog {
    width: calc(100vw - 16px);
    max-height: calc(100vh - 16px);
  }

  .lightbox-panel {
    max-height: calc(100vh - 16px);
  }

  .lightbox-head {
    padding: 12px;
  }

  .lightbox-ref span {
    display: none;
  }

  .lightbox-ref {
    width: 38px;
    padding: 0;
  }

  .lightbox-stage {
    padding: 12px 42px;
  }

  #lbImage {
    max-height: 58vh;
  }

  .lightbox-nav {
    width: 32px;
    height: 32px;
  }

  #lbPrev {
    left: 6px;
  }

  #lbNext {
    right: 6px;
  }

  .lightbox-foot {
    padding: 11px 14px 13px;
  }
}

@media (max-width: 380px) {
  .ratio-label {
    font-size: 8.5px;
  }

  .ratio-shape {
    transform: scale(0.86);
  }

  .two-col {
    grid-template-columns: 1fr;
  }

  .count-field {
    grid-column: auto;
  }

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

/* ==========================================================================
   Image tool, custom ratios, model tools and history actions
   ========================================================================== */

.brand__mark img {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: inherit;
  object-fit: cover;
}

.brand--icon {
  border-radius: 15px;
}

.brand--icon .brand__mark {
  width: 44px;
  height: 44px;
  overflow: hidden;
  background: #ffffff;
}

.brand__mark img {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: inherit;
  object-fit: cover;
}

.brand--icon:hover .brand__mark {
  transform: translateY(-1px);
  box-shadow:
    0 16px 28px -16px rgba(11, 87, 208, 0.55),
    0 2px 5px rgba(16, 35, 65, 0.12);
}

.empty-state--minimal {
  grid-template-columns: minmax(0, 1fr);
}

.empty-state--minimal .empty-visual {
  border-right: 0;
}

.empty-state--minimal .empty-visual::after {
  background: linear-gradient(180deg, rgba(244, 250, 255, 0.04) 0%, transparent 38%, rgba(9, 38, 85, 0.05) 100%);
}

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

.ratio-btn[data-ratio="custom"] .ratio-shape {
  width: 20px;
  height: 20px;
  border: 1.5px dashed currentColor;
  border-radius: 5px;
  background: transparent;
}

.custom-ratio-block {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 8px;
  padding: 8px 10px;
  border: 1px solid rgba(213, 220, 232, 0.8);
  border-radius: 12px;
  background: #f7faff;
}

.custom-ratio-label {
  margin-right: 2px;
  color: var(--on-surface-muted);
  font-size: 10px;
  font-weight: 700;
}

.custom-ratio-block[hidden] {
  display: none;
}

.ratio-field input {
  width: 50px;
  min-height: 30px;
  padding: 3px 6px;
  border: 1px solid var(--outline-soft);
  border-radius: 8px;
  background: #ffffff;
  color: var(--on-surface);
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  text-align: center;
}

.ratio-field input:focus {
  border-color: var(--primary);
  outline: 2px solid rgba(11, 87, 208, 0.16);
  outline-offset: 0;
}

.ratio-colon {
  color: var(--on-surface-muted);
  font-size: 13px;
  font-weight: 800;
}

.custom-ratio-note {
  margin-left: auto;
  color: var(--on-surface-muted);
  font-size: 9.5px;
}

.model-tools {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin: -4px 0 14px;
}

.model-tools .md-text-button {
  min-height: 34px;
  padding-inline: 10px;
  font-size: 10.5px;
}

.model-tools .connection-result {
  flex: 1 1 180px;
  min-height: 0;
  padding: 0;
  border: 0;
  background: transparent;
  font-size: 10px;
  line-height: 1.45;
}

.model-tools .connection-result:empty {
  display: none;
}

.model-history {
  margin: -2px 0 15px;
  padding: 10px 11px;
  border: 1px solid rgba(213, 220, 232, 0.8);
  border-radius: 13px;
  background: #f8fbff;
}

.model-history[hidden] {
  display: none;
}

.model-history-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 7px;
  color: var(--on-surface-muted);
  font-size: 10px;
  font-weight: 700;
}

.model-history-head .text-button {
  min-height: 22px;
  padding: 0 2px;
  font-size: 9.5px;
}

.model-history-list {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.model-history-chip {
  display: inline-flex;
  align-items: stretch;
  overflow: hidden;
  border: 1px solid #cfdbee;
  border-radius: 999px;
  background: #ffffff;
}

.model-history-pick,
.model-history-remove {
  border: 0;
  background: transparent;
  color: var(--on-surface-variant);
  font: inherit;
  cursor: pointer;
}

.model-history-pick {
  max-width: 210px;
  padding: 5px 4px 5px 10px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 10px;
  font-weight: 600;
}

.model-history-pick:hover {
  background: var(--primary-container);
  color: var(--primary);
}

.model-history-remove {
  display: grid;
  width: 24px;
  place-items: center;
  color: var(--on-surface-muted);
}

.model-history-remove:hover {
  background: #ffefef;
  color: var(--error);
}

.model-history-remove .icon {
  width: 11px;
  height: 11px;
}

.history-card {
  cursor: pointer;
  color: inherit;
  font: inherit;
}

.history-card:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.history-model {
  display: block;
  margin-top: 3px;
  overflow: hidden;
  color: var(--primary);
  font-size: 9.5px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-delete {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 3;
  display: grid;
  width: 27px;
  height: 27px;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 9px;
  background: rgba(248, 251, 255, 0.9);
  box-shadow: 0 4px 12px rgba(16, 35, 65, 0.14);
  color: var(--on-surface-variant);
  cursor: pointer;
  opacity: 0;
  transform: translateY(-3px);
  transition: opacity 0.18s var(--ease), transform 0.18s var(--ease), background 0.18s var(--ease);
}

.history-card:hover .history-delete,
.history-card:focus-within .history-delete,
.history-delete:focus-visible {
  opacity: 1;
  transform: none;
}

.history-delete:hover {
  background: var(--error);
  color: #ffffff;
}

.history-delete .icon {
  width: 13px;
  height: 13px;
}

@media (hover: none) {
  .history-delete {
    opacity: 1;
    transform: none;
  }
}

@media (max-width: 430px) {
  .custom-ratio-note {
    width: 100%;
    margin-left: 0;
  }

  .ratio-field input {
    width: 46px;
  }

  .history-delete {
    width: 25px;
    height: 25px;
  }
}
