:root {
  color-scheme: light;
  --ink: #211b16;
  --ink-soft: #4a4037;
  --muted: #776b60;
  --paper: #fbf6ed;
  --card: #ffffff;
  --surface: #f4ece0;
  --surface-strong: #eee1d1;
  --line: #e5d8c8;
  --line-strong: #d1bdab;
  --sage: #9b6a3c;
  --sage-strong: #6f4829;
  --sage-soft: #f4e6d6;
  --violet: #7f6cb0;
  --violet-soft: #f0ecff;
  --gold: #c08a35;
  --danger: #a63f46;
  --danger-soft: #fff0f1;
  --success: #4f7a58;
  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-xl: 28px;
  --shadow-sm: 0 1px 2px rgba(33, 27, 22, .04), 0 8px 24px rgba(33, 27, 22, .04);
  --shadow-md: 0 18px 48px rgba(33, 27, 22, .1);
  --focus-ring: 0 0 0 3px rgba(155, 106, 60, .18);
  --ease: cubic-bezier(.22, 1, .36, 1);
  --z-nav: 20;
  --z-overlay: 100;
  --z-toast: 120;
}

* { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  background: var(--paper);
}

body {
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 8% 3%, rgba(127, 108, 176, .055), transparent 25rem),
    radial-gradient(circle at 92% 12%, rgba(192, 138, 53, .085), transparent 28rem),
    var(--paper);
  color: var(--ink);
  font-family: "DM Sans", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.5;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

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

button,
a,
label[for],
label:has(input[type="file"]),
label:has(input[type="checkbox"]),
label:has(input[type="radio"]) { -webkit-tap-highlight-color: transparent; }

button:not(:disabled),
a[href],
select:not(:disabled),
input[type="checkbox"]:not(:disabled),
input[type="radio"]:not(:disabled),
input[type="range"]:not(:disabled),
label:has(input[type="file"]:not(:disabled)),
label:has(input[type="checkbox"]:not(:disabled)),
label:has(input[type="radio"]:not(:disabled)),
details > summary { cursor: pointer; }

img { max-width: 100%; }

::selection {
  background: var(--violet-soft);
  color: var(--ink);
}

:focus-visible {
  outline: 2px solid var(--sage);
  outline-offset: 3px;
}

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

.icon {
  width: 19px;
  height: 19px;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon-sm { width: 15px; height: 15px; }
.icon-lg { width: 24px; height: 24px; }
.icon-xl { width: 34px; height: 34px; }

.help-button,
.help-popover-close,
.compare-close {
  width: 44px;
  height: 44px;
  padding: 0;
  flex: 0 0 44px;
  border: 1px solid var(--line);
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, .86);
  color: var(--sage-strong);
  transition: border-color .2s ease, background .2s ease, color .2s ease, box-shadow .2s ease;
}

.help-button:hover,
.help-popover-close:hover,
.compare-close:hover {
  border-color: var(--sage);
  background: var(--sage-soft);
  box-shadow: var(--shadow-sm);
}

.help-button {
  border-color: transparent;
  background: transparent;
  box-shadow: none;
}

.help-button:hover {
  border-color: transparent;
  background: transparent;
  color: var(--sage);
  box-shadow: none;
}

.help-button .icon { width: 20px; height: 20px; }

.field-with-help,
.page-heading-with-help,
.compare-head-actions,
.cost-preview-row,
.result-options-help,
.custom-prompt-help,
.bulk-update-heading {
  display: flex;
  align-items: center;
  gap: 8px;
}

.field-with-help { min-width: 0; align-items: flex-start; }
.field-with-help > .field { min-width: 0; flex: 1; }
.field-with-help.full { grid-column: 1 / -1; }
.page-heading-with-help { align-items: flex-start; }
.compare-head-actions { flex: 0 0 auto; }
.cost-preview-row { justify-content: flex-end; }
.result-options-help,
.custom-prompt-help {
  padding: 12px 0;
  justify-content: space-between;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}
.custom-prompt-help { padding: 10px 16px 0; }
.bulk-update-heading { grid-column: 1 / -1; justify-content: space-between; color: var(--sage-strong); font: 650 14px "Space Grotesk", sans-serif; }

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

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

.skip-link {
  position: fixed;
  top: 10px;
  left: 10px;
  z-index: 130;
  padding: 10px 14px;
  border-radius: 10px;
  background: var(--ink);
  color: white;
  font-size: 12px;
  font-weight: 700;
  text-decoration: none;
  transform: translateY(-150%);
  transition: transform .2s ease;
}

.skip-link:focus { transform: translateY(0); }

.noise {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: .18;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.035'/%3E%3C/svg%3E");
}

.shell {
  width: min(1240px, calc(100% - 64px));
  margin-inline: auto;
}

.topbar {
  position: sticky;
  top: 12px;
  z-index: var(--z-nav);
  min-height: 76px;
  margin-top: 12px;
  padding: 0 18px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 32px;
  border: 1px solid rgba(155, 106, 60, .18);
  border-radius: 20px;
  background: linear-gradient(135deg, rgba(244, 230, 214, .96), rgba(255, 255, 255, .9));
  box-shadow: var(--shadow-sm);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.brand,
.auth-brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  color: var(--sage-strong);
  text-decoration: none;
}

.brand { min-height: 44px; }

.brand-mark {
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  display: inline-grid;
  place-items: center;
}

.brand-mark img {
  display: block;
  width: 100%;
  height: 100%;
}

.brand-word {
  font: 700 21px/1 "Space Grotesk", sans-serif;
  letter-spacing: -.045em;
}

.brand-word > span { color: var(--gold); }

nav {
  justify-self: center;
  min-height: 52px;
  padding: 4px;
  border: 1px solid rgba(155, 106, 60, .14);
  border-radius: 16px;
  display: flex;
  align-items: center;
  gap: 4px;
  background: rgba(255, 255, 255, .52);
}

.nav-link {
  min-height: 44px;
  padding: 0 13px;
  border: 0;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
  transition: color .2s ease, background .2s ease, box-shadow .2s ease;
}

.nav-link .icon { width: 17px; height: 17px; }

.nav-link:hover {
  color: var(--ink);
  background: rgba(255, 255, 255, .68);
}

.nav-link.active {
  color: var(--sage-strong);
  background: rgba(244, 230, 214, .9);
  box-shadow: inset 0 0 0 1px rgba(155, 106, 60, .12), var(--shadow-sm);
}

.nav-count {
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  display: inline-grid;
  place-items: center;
  background: var(--card);
  color: var(--sage);
  font-size: 10px;
  font-weight: 800;
}

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

.api-status {
  min-height: 34px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, .78);
  color: var(--muted);
  font-size: 11px;
  font-weight: 650;
}

.api-status i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 0 4px rgba(183, 123, 45, .12);
}

.api-status.ready i {
  background: var(--success);
  box-shadow: 0 0 0 4px rgba(47, 122, 95, .12);
}

.api-status.error i {
  background: var(--danger);
  box-shadow: 0 0 0 4px rgba(166, 63, 70, .12);
}

.text-button {
  min-height: 44px;
  padding: 0 9px;
  border: 0;
  border-radius: 9px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: transparent;
  color: var(--sage);
  font-size: 12px;
  font-weight: 700;
  transition: color .2s ease, background .2s ease;
}

.text-button:hover { background: var(--sage-soft); color: var(--sage-strong); }
.logout-button { color: var(--muted); }

.view {
  display: none;
  padding-bottom: 96px;
}

.view.active { display: block; }

.hero {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(300px, .65fr);
  gap: 80px;
  align-items: end;
  padding: 72px 0 52px;
}

.hero::after {
  content: "";
  position: absolute;
  right: 0;
  bottom: 48px;
  width: 82px;
  height: 3px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--sage), var(--violet));
  opacity: .75;
}

.eyebrow {
  margin: 0 0 18px;
  color: var(--sage);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .18em;
}

.hero h1,
.page-head h1 {
  max-width: 800px;
  margin: 0;
  font: 650 clamp(48px, 6.3vw, 78px)/.98 "Space Grotesk", sans-serif;
  letter-spacing: -.065em;
}

.hero h1 em,
.page-head h1 em,
.result-head em {
  color: var(--sage);
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 400;
  letter-spacing: -.045em;
}

.hero-copy {
  max-width: 430px;
  margin: 0 0 14px;
  padding-right: 96px;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.7;
}

.steps {
  margin-bottom: 56px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 18px;
  display: flex;
  align-items: center;
  background: rgba(255, 255, 255, .74);
  box-shadow: var(--shadow-sm);
}

.step {
  min-height: 44px;
  padding: 0 8px;
  border: 0;
  border-radius: 12px;
  display: flex;
  align-items: center;
  gap: 11px;
  background: transparent;
  color: #8a9791;
  font-size: 13px;
  font-weight: 650;
  transition: color .2s ease, background .2s ease;
}

.step:hover { color: var(--ink-soft); }

.step b {
  width: 30px;
  height: 30px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  display: grid;
  place-items: center;
  font: 700 10px "Space Grotesk", sans-serif;
}

.step.active {
  color: var(--sage-strong);
  background: var(--sage-soft);
}

.step.active b {
  border-color: var(--sage);
  background: var(--sage);
  color: white;
}

.step-line {
  height: 1px;
  margin: 0 18px;
  flex: 1;
  background: var(--line);
}

.stage { display: none; }

.stage.active {
  display: block;
  animation: stage-enter .32s var(--ease);
}

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

.section-heading {
  margin-bottom: 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.section-heading > div {
  display: flex;
  align-items: center;
  gap: 14px;
}

.section-heading h2 {
  margin: 0;
  font: 650 25px "Space Grotesk", sans-serif;
  letter-spacing: -.035em;
}

.section-heading > p {
  max-width: 430px;
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  text-align: right;
}

.number {
  width: 32px;
  height: 32px;
  border: 1px solid rgba(127, 108, 176, .24);
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: var(--violet-soft);
  color: var(--violet);
  font: 700 10px "Space Grotesk", sans-serif;
}

.reference-batch-bar {
  margin: 0 0 20px;
  padding: 18px 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  background: linear-gradient(105deg, var(--sage-soft), rgba(240, 236, 255, .48));
}

.reference-batch-bar > div {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.reference-batch-bar strong {
  color: var(--sage-strong);
  font: 650 14px "Space Grotesk", sans-serif;
}

.reference-batch-bar small {
  color: var(--muted);
  font-size: 12px;
}

.reference-batch-bar .secondary-button { background: rgba(255, 255, 255, .86); }
.reference-batch-bar .help-button { margin-left: auto; }

.style-notice {
  margin: -8px 0 20px;
  padding: 13px 16px;
  border: 1px solid rgba(155, 106, 60, .22);
  border-radius: 13px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  background: rgba(244, 230, 214, .58);
  color: var(--ink-soft);
  font-size: 12px;
  line-height: 1.5;
}

.style-notice > span { flex: 1; }
.style-notice .help-button { margin: -9px -7px -9px 0; }

.style-notice .icon {
  width: 18px;
  height: 18px;
  margin-top: 1px;
  color: var(--sage);
}

.style-grid {
  display: grid;
  grid-template-columns: minmax(0, .92fr) minmax(0, 1.08fr);
  gap: 20px;
}

.upload-card,
.target-upload {
  position: relative;
  min-height: 390px;
  overflow: hidden;
  border: 1.5px dashed var(--line-strong);
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, .66);
  transition: border-color .22s ease, background .22s ease, box-shadow .22s ease;
}

.upload-card:hover,
.target-upload:hover,
.upload-card.dragover,
.target-upload.dragover {
  border-color: var(--sage);
  background: var(--card);
  box-shadow: var(--shadow-md), inset 0 0 0 4px var(--sage-soft);
}

.upload-card input,
.target-upload input { display: none; }

.upload-empty {
  max-width: 310px;
  padding: 28px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.upload-icon {
  width: 54px;
  height: 54px;
  margin-bottom: 18px;
  border: 1px solid var(--line);
  border-radius: 16px;
  display: grid;
  place-items: center;
  background: var(--card);
  color: var(--sage);
  box-shadow: var(--shadow-sm);
}

.upload-empty strong {
  font: 650 17px "Space Grotesk", sans-serif;
  letter-spacing: -.02em;
}

.upload-empty small {
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
}

.file-types {
  margin-top: 20px;
  color: #7a8781;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .12em;
}

#referenceCount {
  min-height: 18px;
  color: var(--sage);
  font-weight: 700;
}

.upload-card > img,
.target-upload > img {
  display: none;
  width: 100%;
  height: 100%;
  padding: 12px;
  object-fit: contain;
  background: #f1ebe3;
}

.has-image > img { display: block; }
.has-image .upload-empty { display: none; }

.remove-image,
.mini-delete {
  width: 40px;
  height: 40px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, .42);
  border-radius: 12px;
  display: none;
  place-items: center;
  background: rgba(33, 27, 22, .82);
  color: white;
  backdrop-filter: blur(8px);
  transition: background .2s ease, transform .2s ease;
}

.remove-image {
  position: absolute;
  top: 14px;
  right: 14px;
}

.has-image .remove-image { display: grid; }

.remove-image:hover,
.mini-delete:hover { background: var(--danger); }

.upload-count-badge {
  position: absolute;
  top: 14px;
  left: 14px;
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid rgba(255, 255, 255, .42);
  border-radius: 999px;
  display: none;
  align-items: center;
  background: rgba(33, 27, 22, .82);
  color: white;
  font-size: 11px;
  font-weight: 700;
  backdrop-filter: blur(8px);
}

.has-image .upload-count-badge:not(:empty) { display: flex; }

.saved-panel {
  min-width: 0;
  min-height: 390px;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--card);
  box-shadow: var(--shadow-sm);
}

.panel-title,
.panel-title > div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 9px;
}

.panel-title h3 {
  margin: 0;
  font: 650 16px "Space Grotesk", sans-serif;
  letter-spacing: -.02em;
}

.spark {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  background: var(--violet-soft);
  color: var(--violet);
}

.spark .icon { width: 17px; height: 17px; }

.style-search {
  position: relative;
  display: block;
  margin-top: 18px;
}

.style-search > .icon {
  position: absolute;
  top: 50%;
  left: 13px;
  z-index: 1;
  width: 17px;
  height: 17px;
  transform: translateY(-50%);
  color: var(--muted);
  pointer-events: none;
}

.style-search input {
  width: 100%;
  min-height: 46px;
  padding: 0 14px 0 40px;
  border: 1px solid var(--line);
  border-radius: 12px;
  outline: none;
  background: var(--paper);
  color: var(--ink);
  font-size: 13px;
  transition: border-color .2s ease, box-shadow .2s ease, background .2s ease;
}

.style-search input:focus {
  border-color: var(--sage);
  background: var(--card);
  box-shadow: var(--focus-ring);
}

.saved-strip {
  max-height: 350px;
  margin-top: 16px;
  padding-right: 4px;
  overflow: auto;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
}

.style-mini-wrap {
  position: relative;
  min-width: 0;
}

.style-mini {
  position: relative;
  width: 100%;
  height: 162px;
  padding: 0;
  overflow: hidden;
  border: 2px solid transparent;
  border-radius: 13px;
  background: #f1ebe3;
  text-align: left;
  transition: border-color .2s ease, box-shadow .2s ease;
}

.style-mini img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  transition: transform .3s var(--ease);
}

.style-mini:hover img { transform: scale(1.025); }

.style-mini span {
  position: absolute;
  inset: auto 0 0;
  min-height: 54px;
  padding: 24px 9px 9px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  color: white;
  background: linear-gradient(transparent, rgba(13, 24, 20, .9));
  font-size: 10px;
  font-weight: 700;
  line-height: 1.25;
}

.style-mini span small {
  display: block;
  margin-top: 3px;
  color: #e8e1fa;
  font-size: 9px;
  font-weight: 600;
  line-height: 1.3;
}

.style-mini.selected {
  border-color: var(--violet);
  box-shadow: 0 0 0 3px var(--violet-soft);
}

.mini-delete {
  position: absolute;
  top: 7px;
  right: 7px;
  z-index: 2;
  width: 44px;
  height: 44px;
  display: grid;
  border-radius: 10px;
}

.mini-delete .icon { width: 16px; height: 16px; }

.empty-inline {
  display: none;
  padding: 76px 0;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

.reference-queue { margin-top: 14px; }
.reference-queue:empty { display: none; }

.reference-queue-head {
  padding: 14px 16px;
  border-radius: 13px 13px 0 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  background: var(--sage-strong);
  color: white;
}

.reference-queue-head strong { font: 650 13px "Space Grotesk", sans-serif; }
.reference-queue-head span { color: #cbded7; font-size: 11px; }

.reference-file-list {
  padding: 12px;
  border: 1px solid var(--line);
  border-top: 0;
  border-radius: 0 0 13px 13px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  background: var(--surface);
}

.reference-file-list span {
  min-width: 0;
  min-height: 40px;
  padding: 8px 10px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  gap: 8px;
  overflow: hidden;
  background: var(--card);
  color: var(--ink-soft);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.reference-file-list b {
  width: 22px;
  height: 22px;
  flex: 0 0 22px;
  border-radius: 7px;
  display: grid;
  place-items: center;
  background: var(--sage-soft);
  color: var(--sage);
  font-size: 9px;
}

.reference-actions {
  margin-top: 18px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  display: grid;
  grid-template-columns: minmax(190px, .9fr) minmax(270px, 1.12fr) minmax(260px, auto);
  align-items: end;
  gap: 14px;
  background: rgba(255, 255, 255, .76);
  opacity: .52;
  pointer-events: none;
  transition: opacity .2s ease, background .2s ease;
}

.reference-actions .field input,
.reference-actions .field select { min-width: 0; }

.reference-actions .field > small {
  min-height: 34px;
  display: block;
}

.reference-actions .field-with-help.admin-only { display: none; }
.is-admin .reference-actions .field-with-help.admin-only { display: flex !important; }

.reference-actions .analyze-stack {
  align-self: end;
  width: 100%;
}

.reference-actions.ready {
  opacity: 1;
  pointer-events: auto;
  background: var(--card);
}

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

.field > span,
.control-row > label {
  color: var(--ink-soft);
  font-size: 11px;
  font-weight: 750;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.field small {
  color: var(--muted);
  font-weight: 500;
  letter-spacing: 0;
  line-height: 1.4;
  text-transform: none;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  min-width: 230px;
  min-height: 46px;
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: 11px;
  outline: none;
  background: var(--card);
  color: var(--ink);
  font-size: 13px;
  transition: border-color .2s ease, box-shadow .2s ease, background .2s ease;
}

.field textarea {
  min-height: 84px;
  line-height: 1.5;
  resize: vertical;
}

.field input:hover,
.field select:hover,
.field textarea:hover { border-color: var(--line-strong); }

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--sage);
  box-shadow: var(--focus-ring);
}

.field.full { padding-top: 18px; }

.primary-button,
.secondary-button,
.back-button {
  min-height: 46px;
  padding: 0 17px;
  border: 0;
  border-radius: 11px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  color: var(--ink);
  font-size: 12px;
  font-weight: 750;
  text-decoration: none;
  transition: color .2s ease, background .2s ease, border-color .2s ease, box-shadow .2s ease, transform .15s ease;
}

.primary-button {
  background: var(--sage);
  color: white;
  box-shadow: 0 8px 20px rgba(155, 106, 60, .16);
}

.primary-button:hover {
  background: var(--sage-strong);
  box-shadow: 0 10px 24px rgba(155, 106, 60, .22);
}

.primary-button .icon { color: #e4d9ff; }

.secondary-button {
  border: 1px solid var(--line-strong);
  background: var(--card);
  color: var(--ink-soft);
}

.secondary-button:hover {
  border-color: var(--sage);
  background: var(--sage-soft);
  color: var(--sage-strong);
}

.back-button {
  background: transparent;
  color: var(--muted);
}

.back-button:hover { background: var(--surface); color: var(--ink); }

.primary-button:active:not(:disabled),
.secondary-button:active:not(:disabled),
.back-button:active:not(:disabled) { transform: translateY(1px); }

.primary-button.large { min-height: 52px; padding-inline: 22px; }

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

.analyze-stack,
.generate-stack {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}

.cost-preview,
.bulk-cost {
  min-height: 38px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  display: flex;
  align-items: center;
  background: var(--surface);
  color: var(--sage-strong);
  font-size: 11px;
  font-weight: 700;
  line-height: 1.35;
}

.cost-preview { max-width: 360px; text-align: right; }
.analyze-stack .cost-preview { max-width: 330px; }

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

.selected-style {
  position: relative;
  height: 390px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: #f1ebe3;
  box-shadow: var(--shadow-sm);
}

.selected-style img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.selected-style div {
  position: absolute;
  inset: auto 0 0;
  padding: 64px 18px 18px;
  color: white;
  background: linear-gradient(transparent, rgba(13, 24, 20, .92));
}

.selected-style small {
  color: #dcd0fb;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .14em;
}

.selected-style strong {
  display: block;
  margin-top: 5px;
  font: 650 16px "Space Grotesk", sans-serif;
}

.target-upload { min-height: 390px; }

.transfer-mode-panel,
.control-panel {
  margin-top: 20px;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--card);
  box-shadow: var(--shadow-sm);
}

.transfer-mode-panel {
  background: linear-gradient(145deg, rgba(255, 255, 255, .92), rgba(244, 230, 214, .5));
}

.guided-panel .panel-title { align-items: flex-start; }

.technical-options {
  margin: 0 0 18px;
  padding: 0 14px;
  border: 1px dashed var(--line-strong);
  border-radius: 12px;
  background: rgba(255, 255, 255, .55);
}

.technical-options summary {
  min-height: 48px;
  display: flex;
  align-items: center;
  color: var(--ink-soft);
  font-size: 12px;
  font-weight: 700;
}

.technical-options[open] { padding-bottom: 14px; }
.technical-options .transfer-config-row { margin: 0; }

.panel-copy {
  max-width: 720px;
  margin: 12px 0 18px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.transfer-config-row {
  max-width: 900px;
  margin-bottom: 16px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.transfer-version-field {
  min-width: 0;
}

.transfer-version-field select {
  background: rgba(255, 255, 255, .9);
}

.transfer-mode-options {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.transfer-mode-card {
  position: relative;
  min-height: 164px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 14px;
  display: grid;
  grid-template-columns: 42px 1fr;
  align-items: flex-start;
  gap: 13px;
  background: rgba(255, 255, 255, .78);
  color: var(--ink-soft);
  transition: border-color .2s ease, box-shadow .2s ease, background .2s ease, transform .15s ease;
}

.transfer-mode-card:hover {
  border-color: var(--line-strong);
  background: var(--card);
  transform: translateY(-1px);
}

.transfer-mode-card input {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 18px;
  height: 18px;
  accent-color: var(--sage);
}

.mode-icon {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: var(--surface);
  color: var(--sage-strong);
}

.transfer-mode-card:has(input:checked) .mode-icon {
  background: var(--sage);
  color: white;
}

.transfer-mode-card em {
  display: block;
  margin: 1px 34px 6px 0;
  color: var(--sage-strong);
  font-size: 10px;
  font-style: normal;
  font-weight: 800;
  letter-spacing: .1em;
  text-transform: uppercase;
}

.transfer-mode-card:has(input:checked) {
  border-color: var(--sage);
  background: var(--sage-soft);
  box-shadow: 0 0 0 3px rgba(155, 106, 60, .1);
}

.transfer-mode-card b {
  display: block;
  color: var(--ink);
  font: 650 15px/1.3 "Space Grotesk", sans-serif;
}

.transfer-mode-card small {
  display: block;
  margin-top: 7px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.control-row {
  padding: 18px 0;
  border-bottom: 1px solid var(--line);
}

.control-section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}

.control-section-head h3 {
  margin: 3px 0 0;
  font: 650 clamp(20px, 2.2vw, 27px)/1.2 "Space Grotesk", sans-serif;
}

.control-kicker {
  color: var(--sage-strong);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .14em;
}

.intensity-row { border-bottom: 0; }

.intensity-row input,
.compare-controls input[type="range"] {
  min-height: 44px;
  margin: 0;
  touch-action: manipulation;
}

.intensity-feedback {
  min-height: 74px;
  padding: 14px 16px;
  border: 1px solid rgba(155, 106, 60, .2);
  border-radius: 13px;
  display: grid;
  grid-template-columns: minmax(90px, auto) 1fr;
  align-items: center;
  gap: 16px;
  background: linear-gradient(135deg, var(--sage-soft), rgba(255, 255, 255, .86));
}

.intensity-feedback span {
  color: var(--sage-strong);
  font: 700 15px "Space Grotesk", sans-serif;
}

.intensity-feedback p {
  margin: 0;
  color: var(--ink-soft);
  font-size: 13px;
}

.intensity-scale {
  margin: 8px 0 4px 210px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
}

.intensity-scale span:nth-child(2),
.intensity-scale span:nth-child(3) { text-align: center; }
.intensity-scale span:last-child { text-align: right; }

.result-options {
  margin-top: 22px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(244, 236, 224, .45);
}

.result-options > summary {
  min-height: 66px;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  list-style: none;
}

.result-options > summary::-webkit-details-marker { display: none; }
.result-options > summary > span { display: grid; gap: 2px; }
.result-options > summary b { color: var(--ink); font-size: 14px; }
.result-options > summary small { color: var(--muted); font-size: 11px; font-weight: 500; }
.result-options > summary > .icon { transition: transform .2s ease; }
.result-options[open] > summary > .icon { transform: rotate(45deg); }
.result-options[open] { padding: 0 16px 16px; }
.result-options[open] > summary { margin-inline: -16px; padding-inline: 32px; border-bottom: 1px solid var(--line); }
.result-options .control-row:last-of-type { border-bottom: 0; }

.control-row:first-child { padding-top: 4px; }

.range-row {
  display: grid;
  grid-template-columns: 190px 1fr 54px;
  align-items: center;
  gap: 20px;
}

.range-row input {
  width: 100%;
  accent-color: var(--sage);
}

.range-row output {
  min-height: 34px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  background: var(--sage-soft);
  color: var(--sage-strong);
  font: 700 13px "Space Grotesk", sans-serif;
}

.split {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 24px;
}

.toggle-field {
  min-height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  letter-spacing: 0 !important;
  text-transform: none !important;
}

.toggle-field > span { display: flex; flex-direction: column; }
.toggle-field b { font-size: 13px; }

.toggle-field small {
  margin-top: 4px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 400;
  line-height: 1.4;
}

.toggle-field input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.toggle-field i {
  position: relative;
  width: 46px;
  height: 27px;
  flex: 0 0 46px;
  border-radius: 999px;
  background: #bdc8c3;
  transition: background .2s ease, box-shadow .2s ease;
}

.toggle-field i::after {
  content: "";
  position: absolute;
  top: 4px;
  left: 4px;
  width: 19px;
  height: 19px;
  border-radius: 50%;
  background: white;
  box-shadow: 0 1px 4px rgba(33, 27, 22, .2);
  transition: transform .2s var(--ease);
}

.toggle-field input:focus-visible + i { box-shadow: var(--focus-ring); }
.toggle-field input:checked + i { background: var(--sage); }
.toggle-field input:checked + i::after { transform: translateX(19px); }

.json-editor {
  margin-top: 20px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.json-editor summary {
  min-height: 44px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--ink-soft);
  font-size: 12px;
  font-weight: 700;
}

.json-editor summary small { color: var(--muted); font-weight: 500; }

.json-editor textarea {
  width: 100%;
  height: 280px;
  margin: 10px 0 12px;
  padding: 16px;
  border: 1px solid #2b3732;
  border-radius: 12px;
  outline: none;
  background: #18221e;
  color: #dcebe4;
  font: 12px/1.55 Consolas, "SFMono-Regular", monospace;
}

.json-editor textarea:focus { box-shadow: 0 0 0 3px rgba(127, 108, 176, .22); }

.stage-footer,
.result-actions {
  margin-top: 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.result-head {
  max-width: 700px;
  margin: 0 auto;
  padding-top: 18px;
  text-align: center;
}

.result-head h2 {
  margin: 0;
  font: 650 44px "Space Grotesk", sans-serif;
  letter-spacing: -.05em;
}

.result-head > p:last-child { color: var(--muted); font-size: 14px; }

.job-status-panel {
  display: grid;
  gap: 8px;
  margin: 18px 0;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface-soft);
}
.job-status-panel > span { color: var(--muted); font-size: 14px; }
.job-status-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }

.result-frame {
  max-width: 980px;
  margin: 34px auto 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--card);
  box-shadow: var(--shadow-md);
}

.result-frame img {
  display: block;
  width: 100%;
  max-height: 680px;
  border-radius: 13px;
  object-fit: contain;
  background: #f1ebe3;
}

.result-actions { max-width: 980px; margin-inline: auto; }

.batch-results {
  max-width: 1100px;
  margin: 34px auto 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
}

.batch-result-card,
.library-card,
.history-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--card);
  box-shadow: var(--shadow-sm);
  transition: border-color .2s ease, box-shadow .2s ease, transform .2s ease;
}

.batch-result-card:hover,
.library-card:hover,
.history-card:hover {
  border-color: var(--line-strong);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.batch-result-card > button {
  width: 100%;
  padding: 0;
  border: 0;
  display: block;
  background: #f1ebe3;
}

.batch-result-card img {
  display: block;
  width: 100%;
  height: 520px;
  object-fit: contain;
  background: #f1ebe3;
}

.batch-result-card > div {
  min-height: 54px;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  color: var(--muted);
  font-size: 11px;
}

.batch-result-card span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.batch-result-card a {
  color: var(--sage);
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
}

.mini-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 7px;
}

.mini-actions button,
.mini-actions a {
  min-height: 34px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 9px;
  display: inline-flex;
  align-items: center;
  background: var(--card);
  color: var(--ink-soft);
  font-size: 10px;
  font-weight: 750;
  text-decoration: none;
  transition: border-color .2s ease, color .2s ease, background .2s ease;
}

.mini-actions button:hover,
.mini-actions a:hover {
  border-color: var(--sage);
  color: var(--sage);
  background: var(--sage-soft);
}

.page-head {
  padding: 72px 0 44px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 28px;
}

.page-head h1 { font-size: clamp(44px, 5vw, 62px); }

.page-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.import-style-button input { display: none; }

.library-grid,
.history-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 20px;
}

.library-card .image,
.history-card .image {
  position: relative;
  height: 300px;
  overflow: hidden;
  background: #f1ebe3;
}

.library-card img,
.history-card img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  transition: transform .32s var(--ease);
}

.library-card:hover img,
.history-card:hover img { transform: scale(1.02); }

.history-preview-button {
  width: 100%;
  height: 100%;
  padding: 0;
  border: 0;
  display: block;
  background: transparent;
}

.history-preview-button img { display: block; }

.library-card .body,
.history-card .body { padding: 18px; }

.library-card h3,
.history-card h3 {
  margin: 0 0 6px;
  font: 650 17px "Space Grotesk", sans-serif;
  letter-spacing: -.025em;
}

.library-card p,
.history-card p {
  margin: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.style-meta {
  display: block;
  margin-top: 10px;
  color: var(--sage);
  font-size: 11px;
  font-weight: 700;
}

.card-actions {
  margin-top: 16px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.card-actions button,
.card-actions a {
  min-height: 40px;
  padding: 0 11px;
  flex: 1;
  border: 1px solid var(--line);
  border-radius: 9px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: var(--card);
  color: var(--ink-soft);
  font-size: 11px;
  font-weight: 700;
  text-align: center;
  text-decoration: none;
  transition: border-color .2s ease, background .2s ease, color .2s ease;
}

.card-actions button:hover,
.card-actions a:hover { border-color: var(--sage); color: var(--sage); }

.card-actions .use {
  border-color: var(--sage);
  background: var(--sage);
  color: white;
}

.library-card .card-actions > * { min-width: calc(50% - 4px); }

.page-empty {
  display: none;
  padding: 96px 20px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, .52);
  color: var(--muted);
  text-align: center;
}

.page-empty > span {
  width: 60px;
  height: 60px;
  margin: 0 auto;
  border-radius: 18px;
  display: grid;
  place-items: center;
  background: var(--violet-soft);
  color: var(--violet);
}

.page-empty h3 {
  margin: 18px 0 6px;
  color: var(--ink);
  font: 650 20px "Space Grotesk", sans-serif;
}

.page-empty p { margin: 0 0 24px; font-size: 13px; }

.bulk-update-panel {
  margin: -16px 0 28px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  display: grid;
  grid-template-columns: 1fr 1fr auto auto;
  align-items: flex-end;
  gap: 14px;
  background: var(--card);
  box-shadow: var(--shadow-sm);
}

.bulk-update-panel .field select { min-width: 210px; }
.bulk-cost { min-height: 46px; white-space: nowrap; }

.settings-panel {
  max-width: 980px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  display: grid;
  grid-template-columns: .8fr 1.2fr;
  background: var(--card);
  box-shadow: var(--shadow-sm);
}

.settings-status {
  padding: 30px;
  display: flex;
  align-items: flex-start;
  gap: 16px;
  background: linear-gradient(145deg, var(--sage-soft), var(--violet-soft));
}

.settings-status .brand-mark {
  width: 40px;
  height: 40px;
  flex-basis: 40px;
}

.settings-status small {
  color: var(--sage);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .14em;
}

.settings-status strong {
  display: block;
  margin: 7px 0 8px;
  font: 650 22px "Space Grotesk", sans-serif;
}

.settings-status p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.settings-form { padding: 30px; }

.settings-models {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.settings-models .field input,
.settings-models .field select { min-width: 0; }

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

#accountView .settings-panel {
  grid-template-columns: minmax(0, 1fr) auto;
}

#accountView .settings-status {
  min-width: 0;
  align-items: center;
}

#accountView .settings-status > div { min-width: 0; }

#accountView .settings-status p { overflow-wrap: anywhere; }

#accountVerifyActions {
  margin-top: 0;
  padding: 30px;
  border-left: 1px solid var(--line);
  align-items: center;
  justify-content: flex-end;
  background: rgba(255, 255, 255, .72);
}

.model-availability {
  display: none;
  margin-top: 16px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--paper);
  color: var(--muted);
  font-size: 12px;
}

.model-availability.active {
  display: grid;
  gap: 10px;
}

.model-availability strong {
  display: block;
  color: var(--ink);
  font: 650 14px "Space Grotesk", sans-serif;
}

.model-availability small {
  display: block;
  margin-top: 3px;
}

.model-tags {
  display: grid;
  gap: 7px;
}

.model-tags span {
  padding: 9px 10px;
  border-radius: 9px;
  background: var(--card);
  color: var(--ink-soft);
  line-height: 1.45;
}

.prompt-panel,
.admin-panel {
  margin-top: 24px;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--card);
  box-shadow: var(--shadow-sm);
}

.custom-prompt-box {
  margin-top: 16px;
  border: 1px solid rgba(155, 106, 60, .2);
  border-radius: 14px;
  background: linear-gradient(135deg, rgba(244, 230, 214, .55), rgba(255, 255, 255, .82));
}

.capture-custom-prompt {
  margin-top: 14px;
}

.custom-prompt-box summary {
  min-height: 50px;
  padding: 0 16px;
  display: flex;
  align-items: center;
  color: var(--sage-strong);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.custom-prompt-form {
  padding: 0 16px 16px;
  display: grid;
  grid-template-columns: minmax(220px, .8fr) minmax(0, 1.2fr) auto;
  align-items: end;
  gap: 14px;
}

.custom-prompt-form .field.full {
  padding-top: 0;
}

.custom-prompt-form textarea {
  min-height: 118px;
}

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

.prompt-library details {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--paper);
}

.prompt-library summary {
  min-height: 48px;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  font-size: 12px;
}

.prompt-library summary span { color: var(--muted); font-weight: 700; }

.prompt-library .custom-prompt-item {
  border-color: rgba(155, 106, 60, .26);
  background: var(--sage-soft);
}

.prompt-item-actions {
  padding: 0 14px 12px;
  display: flex;
  justify-content: flex-end;
}

.prompt-library pre {
  max-height: 440px;
  margin: 0;
  padding: 16px;
  overflow: auto;
  border-top: 1px solid #2b3732;
  background: #18221e;
  color: #dcebe4;
  font: 12px/1.6 Consolas, "SFMono-Regular", monospace;
  white-space: pre-wrap;
}

.admin-note {
  margin-bottom: 16px;
  padding: 14px;
  border: 1px solid rgba(155, 106, 60, .2);
  border-radius: 11px;
  background: var(--sage-soft);
  color: var(--sage-strong);
  font-size: 12px;
  font-weight: 650;
}

.admin-users { display: grid; gap: 12px; }

.admin-user-card {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  display: grid;
  grid-template-columns: 1fr 170px 130px auto;
  align-items: flex-end;
  gap: 14px;
  background: var(--paper);
}

.admin-user-card strong {
  display: block;
  font: 650 15px "Space Grotesk", sans-serif;
}

.admin-user-card span,
.admin-user-card small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.admin-user-card .field input,
.admin-user-card .field select { min-width: 0; }

.auth-screen {
  position: fixed;
  inset: 0;
  z-index: 90;
  padding: 24px;
  display: grid;
  place-items: center;
  overflow: auto;
  background:
    radial-gradient(circle at 12% 12%, rgba(127, 108, 176, .08), transparent 24rem),
    radial-gradient(circle at 88% 82%, rgba(192, 138, 53, .1), transparent 28rem),
    var(--paper);
}

.authenticated .auth-screen { display: none; }
body:not(.authenticated) .topbar,
body:not(.authenticated) main { display: none; }

.token-screen {
  position: fixed;
  inset: 0;
  z-index: 95;
  padding: 24px;
  display: none;
  place-items: center;
  overflow: auto;
  background:
    radial-gradient(circle at 12% 12%, rgba(127, 108, 176, .08), transparent 24rem),
    radial-gradient(circle at 88% 82%, rgba(192, 138, 53, .1), transparent 28rem),
    var(--paper);
}
body.token-action-open .token-screen { display: grid; }

.auth-card {
  position: relative;
  width: min(470px, 100%);
  padding: 36px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: rgba(255, 255, 255, .9);
  box-shadow: var(--shadow-md);
}

.auth-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--sage), var(--violet));
}

.auth-brand { margin-bottom: 28px; }

.auth-card h1 {
  margin: 0 0 24px;
  font: 650 35px/1.08 "Space Grotesk", sans-serif;
  letter-spacing: -.045em;
}

.auth-tabs {
  margin-bottom: 18px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 13px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: var(--surface);
}

.auth-tabs button {
  min-height: 42px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.auth-tabs button.active {
  background: var(--card);
  color: var(--sage-strong);
  box-shadow: var(--shadow-sm);
}

.auth-form { display: grid; gap: 14px; }
.auth-form#registerForm { display: none; }
.auth-form small { color: var(--muted); font-size: 12px; line-height: 1.5; }

.admin-only { display: none !important; }
.is-admin .admin-only { display: inline-flex !important; }
.is-admin .settings-models.admin-only { display: grid !important; }
.is-admin .prompt-panel.admin-only { display: block !important; }
.is-admin details.admin-only { display: block !important; }
.is-admin label.field.admin-only { display: flex !important; }
.is-admin .bulk-update-panel.admin-only { display: grid !important; }

.loading-overlay {
  position: fixed;
  inset: 0;
  z-index: var(--z-overlay);
  display: none;
  place-items: center;
  align-content: center;
  padding: 24px;
  background: rgba(247, 249, 247, .94);
  text-align: center;
  backdrop-filter: blur(14px);
}

.loading-overlay.active { display: grid; }

.loader-art {
  position: relative;
  width: 104px;
  height: 104px;
  margin: 0 auto;
}

.loader-art i {
  position: absolute;
  inset: 8px;
  border: 1px solid var(--line-strong);
  border-top-color: var(--sage);
  border-radius: 50%;
  animation: orbit 1.7s linear infinite;
}

.loader-art i:nth-child(2) { inset: 17px; animation-direction: reverse; animation-duration: 1.25s; }
.loader-art i:nth-child(3) { inset: 27px; border-top-color: var(--violet); animation-duration: .95s; }

.loader-art img {
  position: absolute;
  inset: 34px;
  width: 36px;
  height: 36px;
}

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

.loading-overlay h3 {
  margin: 16px 0 6px;
  font: 650 22px "Space Grotesk", sans-serif;
  letter-spacing: -.025em;
}

.loading-overlay p { margin: 0; color: var(--muted); font-size: 13px; }

.loading-line {
  width: min(280px, 74vw);
  height: 3px;
  margin-top: 22px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--line);
}

.loading-line span {
  display: block;
  width: 40%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--sage), var(--violet));
  animation: loading-pass 1.5s var(--ease) infinite;
}

@keyframes loading-pass {
  from { transform: translateX(-110%); }
  to { transform: translateX(360%); }
}

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  z-index: var(--z-toast);
  max-width: min(520px, calc(100% - 32px));
  min-height: 46px;
  padding: 12px 18px;
  border: 1px solid rgba(255, 255, 255, .12);
  border-radius: 12px;
  display: flex;
  align-items: center;
  background: var(--ink);
  color: white;
  box-shadow: var(--shadow-md);
  font-size: 12px;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 16px);
  transition: opacity .22s ease, transform .22s var(--ease);
}

.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: var(--danger); }

.image-modal {
  position: fixed;
  inset: 0;
  z-index: 110;
  padding: 28px;
  display: none;
  place-items: center;
  background: rgba(33, 27, 22, .76);
  backdrop-filter: blur(10px);
}

.image-modal.active { display: grid; }

.image-modal img {
  max-width: min(1180px, 94vw);
  max-height: 86vh;
  border-radius: 14px;
  object-fit: contain;
  background: var(--paper);
  box-shadow: 0 24px 70px rgba(33, 27, 22, .35);
}

.image-modal-close {
  position: fixed;
  top: 18px;
  right: 18px;
  width: 48px;
  height: 48px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, .34);
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, .92);
  color: var(--ink);
  box-shadow: var(--shadow-md);
}

.compare-modal {
  position: fixed;
  inset: 0;
  z-index: 111;
  padding: 16px;
  display: none;
  place-items: center;
  background: rgba(33, 27, 22, .84);
  backdrop-filter: blur(10px);
}

.compare-modal.active { display: grid; }

body.compare-open { overflow: hidden; }

.compare-box {
  width: min(1600px, calc(100vw - 32px));
  height: min(1040px, calc(100dvh - 32px));
  min-height: 0;
  padding: 16px;
  border: 1px solid rgba(255, 255, 255, .28);
  border-radius: 22px;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 12px;
  background: var(--paper);
  box-shadow: 0 24px 70px rgba(33, 27, 22, .36);
}

.compare-head {
  min-width: 0;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
}

.compare-head h2 {
  margin: 1px 0 2px;
  font: 650 clamp(23px, 3vw, 34px)/1.1 "Space Grotesk", sans-serif;
}

.compare-head p:last-child {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.compare-close { border-radius: 13px; }
.compare-head-actions .help-button,
.compare-head-actions .compare-close { flex: 0 0 44px; }

.compare-stage {
  position: relative;
  min-width: 0;
  min-height: 260px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, .1);
  border-radius: 15px;
  background:
    linear-gradient(45deg, rgba(255, 255, 255, .035) 25%, transparent 25%, transparent 75%, rgba(255, 255, 255, .035) 75%),
    linear-gradient(45deg, rgba(255, 255, 255, .035) 25%, transparent 25%, transparent 75%, rgba(255, 255, 255, .035) 75%),
    #1b1815;
  background-position: 0 0, 12px 12px;
  background-size: 24px 24px;
  cursor: default;
  user-select: none;
  touch-action: none;
}

.compare-stage.is-zoomed { cursor: grab; }
.compare-stage.is-dragging { cursor: grabbing; }

.compare-media-frame {
  position: absolute;
  top: 50%;
  left: 50%;
  overflow: hidden;
  background: #111;
  opacity: 0;
  transform: translate(-50%, -50%);
  transition: opacity .16s ease-out;
}

.compare-stage.is-ready .compare-media-frame { opacity: 1; }

.compare-stage-status {
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: 4;
  width: min(300px, calc(100% - 32px));
  margin: 0;
  color: rgba(255, 255, 255, .78);
  font-size: 12px;
  font-weight: 700;
  text-align: center;
  transform: translate(-50%, -50%);
}

.compare-stage.is-ready .compare-stage-status { display: none; }
.compare-stage.is-error .compare-stage-status { color: #ffd5d0; }

.compare-layer,
.compare-layer img {
  position: absolute;
  inset: 0;
}

.compare-layer {
  overflow: hidden;
  pointer-events: none;
}

.compare-layer img {
  width: 100%;
  height: 100%;
  object-fit: fill;
  transform: translate(var(--compare-pan-x, 0px), var(--compare-pan-y, 0px)) scale(var(--compare-zoom, 1));
  transform-origin: center;
  transition: transform .16s ease-out;
  will-change: transform;
}

.compare-after {
  clip-path: inset(0 0 0 50%);
}

.compare-image-label {
  position: absolute;
  top: 12px;
  z-index: 2;
  min-height: 30px;
  padding: 6px 10px;
  border: 1px solid rgba(255, 255, 255, .18);
  border-radius: 999px;
  background: rgba(25, 21, 18, .72);
  color: white;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
  backdrop-filter: blur(8px);
}

.compare-before-layer .compare-image-label { left: 12px; }
.compare-after .compare-image-label { right: 12px; }

.compare-divider {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 2px;
  background: white;
  box-shadow: 0 0 0 1px rgba(33, 27, 22, .16), 0 0 28px rgba(33, 27, 22, .26);
  pointer-events: none;
}

.compare-divider > span {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 52px;
  height: 52px;
  border: 1px solid rgba(33, 27, 22, .12);
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1px;
  background: white;
  color: var(--sage-strong);
  transform: translate(-50%, -50%);
  box-shadow: 0 8px 24px rgba(33, 27, 22, .22);
}

.compare-divider .icon { width: 14px; height: 14px; }

.compare-controls {
  min-height: 62px;
  display: grid;
  grid-template-columns: minmax(280px, 1fr) minmax(260px, .65fr) auto;
  align-items: center;
  gap: 20px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.compare-position-control {
  min-width: 0;
  display: grid;
  grid-template-columns: auto minmax(120px, 1fr) auto;
  align-items: center;
  gap: 12px;
}

.compare-position-control b:first-of-type { color: var(--ink-soft); }
.compare-position-control b:last-of-type { color: var(--sage-strong); }

.compare-zoom-control {
  min-width: 0;
  display: grid;
  grid-template-columns: auto auto minmax(100px, 1fr) 48px;
  align-items: center;
  gap: 9px;
}

.compare-controls input {
  width: 100%;
  accent-color: var(--sage);
}

.compare-zoom-control output {
  color: var(--ink-soft);
  font: 700 12px "Space Grotesk", sans-serif;
  text-align: right;
}

.compare-reset {
  min-height: 44px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 11px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  background: white;
  color: var(--ink-soft);
  font-size: 12px;
  font-weight: 700;
  transition: border-color .2s ease, background .2s ease;
}

.compare-reset:hover { border-color: var(--sage); background: var(--sage-soft); }

.help-popover {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 125;
  width: min(380px, calc(100vw - 32px));
  padding: 20px 58px 20px 20px;
  border: 1px solid var(--line-strong);
  border-radius: 17px;
  display: none;
  background: rgba(255, 255, 255, .98);
  box-shadow: 0 22px 60px rgba(33, 27, 22, .22);
}

.help-popover.active { display: block; animation: help-in .2s var(--ease); }

.help-popover strong {
  display: block;
  color: var(--ink);
  font: 650 16px "Space Grotesk", sans-serif;
}

.help-popover p {
  margin: 7px 0 0;
  color: var(--ink-soft);
  font-size: 13px;
  line-height: 1.55;
}

.help-popover-close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 40px;
  height: 40px;
  flex-basis: 40px;
  border-radius: 11px;
}

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

@media (max-width: 1100px) {
  .shell { width: min(100% - 40px, 1240px); }
  .topbar { gap: 18px; }
  .nav-link { padding-inline: 10px; }
  .nav-link .icon { display: none; }
  .api-status span { display: none; }
  .hero { gap: 48px; }
  .hero-copy { padding-right: 80px; }
  .saved-strip { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .bulk-update-panel { grid-template-columns: 1fr 1fr; }
  .transfer-mode-options { grid-template-columns: 1fr; }
  .transfer-mode-card { min-height: 0; }
  .compare-controls { grid-template-columns: 1fr 1fr; }
  .compare-reset { grid-column: 1 / -1; justify-self: end; }
  .bulk-update-panel .secondary-button { width: 100%; }
  .bulk-cost { justify-content: center; white-space: normal; text-align: center; }
}

@media (max-width: 820px) {
  body { padding-bottom: 72px; }
  .shell { width: min(100% - 28px, 1240px); }
  .topbar {
    position: relative;
    top: 0;
    margin-top: 0;
    padding-inline: 0;
    border-radius: 0;
    border-inline: 0;
    min-height: 68px;
    grid-template-columns: 1fr auto;
    gap: 12px;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }
  .topbar nav {
    position: fixed;
    right: 10px;
    bottom: calc(10px + env(safe-area-inset-bottom));
    left: 10px;
    z-index: var(--z-nav);
    height: 62px;
    padding: 5px;
    border: 1px solid var(--line);
    border-radius: 18px;
    justify-content: space-around;
    background: rgba(255, 255, 255, .94);
    box-shadow: 0 12px 36px rgba(33, 27, 22, .15);
    backdrop-filter: blur(18px);
  }
  .is-admin .topbar nav {
    justify-content: flex-start;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scrollbar-width: none;
  }
  .is-admin .topbar nav::-webkit-scrollbar { display: none; }
  .is-admin .nav-link { flex: 0 0 64px; }
  .nav-link {
    min-width: 56px;
    height: 50px;
    padding: 4px 7px;
    flex-direction: column;
    gap: 2px;
    border-radius: 13px;
    font-size: 9px;
  }
  .nav-link .icon { display: block; width: 18px; height: 18px; }
  .nav-count { position: absolute; margin: -25px 0 0 29px; }
  .logout-button span { display: none; }
  .logout-button { width: 44px; height: 44px; padding: 0; }
  .hero {
    grid-template-columns: 1fr;
    gap: 22px;
    padding: 50px 0 38px;
  }
  .hero h1 { font-size: clamp(44px, 12vw, 62px); }
  .hero-copy { max-width: 590px; padding-right: 0; }
  .hero::after { display: none; }
  .steps { margin-bottom: 42px; }
  .step span { display: none; }
  .step.active span { display: block; white-space: nowrap; }
  .step.active { padding-right: 12px; }
  .step-line { margin-inline: 10px; }
  .section-heading { align-items: flex-start; }
  .section-heading > p { display: none; }
  .style-grid,
  .workspace-grid,
  .settings-panel { grid-template-columns: 1fr; }
  #accountView .settings-panel { grid-template-columns: 1fr; }
  .saved-panel { order: -1; min-height: 0; }
  .saved-strip {
    max-height: none;
    padding-bottom: 6px;
    overflow-x: auto;
    display: flex !important;
  }
  .style-mini-wrap { min-width: 135px; }
  .style-mini { height: 176px; }
  .upload-card,
  .target-upload { min-height: 330px; }
  .reference-actions { grid-template-columns: 1fr; align-items: stretch; }
  .reference-actions .field input,
  .reference-actions .field select { min-width: 0; }
  .analyze-stack,
  .generate-stack { align-items: stretch; }
  .cost-preview,
  .analyze-stack .cost-preview { max-width: none; justify-content: center; text-align: center; }
  .selected-style { height: 220px; }
  .range-row { grid-template-columns: 1fr 54px; }
  .range-row label { grid-column: 1 / -1; }
  .intensity-scale { margin-left: 0; }
  .compare-box { height: calc(100dvh - 24px); width: calc(100vw - 24px); }
  .compare-controls { grid-template-columns: 1fr; gap: 8px; }
  .compare-reset { grid-column: auto; justify-self: stretch; }
  .batch-results { grid-template-columns: 1fr; }
  .batch-result-card img { height: auto; max-height: 650px; }
  .library-grid,
  .history-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .page-head { padding-top: 54px; align-items: flex-start; flex-direction: column; }
  .page-actions { width: 100%; }
  .page-actions > * { flex: 1; }
  .bulk-update-panel,
  .settings-models,
  .admin-user-card,
  .custom-prompt-form,
  .transfer-config-row { grid-template-columns: 1fr; }
  .settings-actions { flex-direction: column; }
  .settings-actions > * { width: 100%; }
  #accountVerifyActions {
    padding-top: 22px;
    border-top: 1px solid var(--line);
    border-left: 0;
    justify-content: flex-start;
  }
  .stage-footer { align-items: stretch; }
  .generate-stack { flex: 1; }
  .batch-result-card > div { align-items: stretch; flex-direction: column; }
  .mini-actions { justify-content: flex-start; }
}

@media (max-width: 560px) {
  .brand-word { font-size: 19px; }
  .top-actions { gap: 4px; }
  .api-status { padding-inline: 9px; }
  .hero { padding-top: 40px; }
  .hero h1 { font-size: 43px; }
  .steps { padding: 8px; }
  .section-heading h2 { font-size: 22px; }
  .reference-batch-bar { align-items: stretch; flex-direction: column; }
  .reference-batch-bar .secondary-button { width: 100%; }
  .style-notice { margin-top: -4px; }
  .style-notice { align-items: flex-start; }
  .reference-file-list { grid-template-columns: 1fr; }
  .upload-card,
  .target-upload { min-height: 300px; }
  .control-panel { padding: 17px; }
  .transfer-mode-panel { padding: 17px; }
  .transfer-mode-card { grid-template-columns: 38px 1fr; padding: 15px; }
  .mode-icon { width: 38px; height: 38px; }
  .split { grid-template-columns: 1fr; gap: 18px; }
  .intensity-feedback { grid-template-columns: 1fr; gap: 4px; }
  .intensity-scale { font-size: 9px; }
  .stage-footer { flex-direction: column; }
  .stage-footer > *,
  .stage-footer .primary-button { width: 100%; }
  .result-head h2 { font-size: 34px; }
  .result-frame { margin-inline: -6px; padding: 6px; }
  .result-actions { flex-direction: column-reverse; }
  .result-actions > * { width: 100%; }
  .compare-modal { padding: 0; place-items: stretch; }
  .compare-box {
    width: 100vw;
    height: 100dvh;
    padding: max(10px, env(safe-area-inset-top)) 10px max(10px, env(safe-area-inset-bottom));
    border: 0;
    border-radius: 0;
    gap: 8px;
  }
  .compare-head { gap: 10px; }
  .compare-head .eyebrow,
  .compare-head p:last-child { display: none; }
  .compare-head h2 { margin-top: 9px; font-size: 24px; }
  .compare-stage { min-height: 220px; border-radius: 11px; }
  .compare-position-control { grid-template-columns: auto minmax(80px, 1fr) auto; gap: 8px; }
  .compare-zoom-control { grid-template-columns: auto auto minmax(70px, 1fr) 44px; }
  .compare-reset { min-height: 42px; }
  .compare-image-label { top: 8px; }
  .compare-before-layer .compare-image-label { left: 8px; }
  .compare-after .compare-image-label { right: 8px; }
  .help-popover { right: 12px; bottom: calc(84px + env(safe-area-inset-bottom)); }
  .library-grid,
  .history-grid { grid-template-columns: 1fr; }
  .library-card .image,
  .history-card .image { height: 340px; }
  .page-head h1 { font-size: 42px; }
  .page-actions { flex-direction: column; }
  .page-actions > * { width: 100%; }
  .auth-card { padding: 26px 22px; border-radius: 20px; }
  .auth-card h1 { font-size: 30px; }
  #accountView .settings-status { padding: 24px 22px; }
  #accountVerifyActions { padding: 20px 22px 24px; }
  .prompt-library summary { align-items: flex-start; flex-direction: column; gap: 3px; }
  .toast { bottom: calc(84px + env(safe-area-inset-bottom)); }
}

@media (max-width: 390px) {
  .shell { width: calc(100% - 22px); }
  .brand-mark { width: 31px; height: 31px; flex-basis: 31px; }
  .brand-word { font-size: 18px; }
  .api-status { display: none; }
  .hero h1 { font-size: 39px; }
  .step-line { margin-inline: 5px; }
  .style-mini-wrap { min-width: 126px; }
}

@media (max-height: 580px) and (orientation: landscape) {
  .auth-screen { position: absolute; place-items: start center; }
  .auth-card { margin-block: 18px; }
  .topbar nav { position: static; height: 58px; box-shadow: none; }
  body { padding-bottom: 0; }
  .compare-box { grid-template-columns: minmax(0, 1fr) 280px; grid-template-rows: auto minmax(0, 1fr); }
  .compare-head { grid-column: 2; grid-row: 1; }
  .compare-head p:last-child { display: none; }
  .compare-stage { grid-column: 1; grid-row: 1 / -1; min-height: 0; }
  .compare-controls { grid-column: 2; grid-row: 2; align-content: center; }
}

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