/* ─── Tokens ─────────────────────────────────────────────────────────────
   Apple-style light surfaces: #F5F5F7 canvas, white rounded cards, one blue
   accent. Spring curves are sampled damped springs (zeta 0.42 / 0.72). */
:root {
  color-scheme: light;
  --bg: #f5f5f7;
  --surface: #ffffff;
  --surface-2: #fbfbfd;
  --fill: rgba(118, 118, 128, 0.12);
  --fill-2: rgba(118, 118, 128, 0.07);
  --fill-strong: rgba(118, 118, 128, 0.2);
  --ink: #1d1d1f;
  --ink-2: #6e6e73;
  --ink-3: #8e8e93;
  --line: rgba(0, 0, 0, 0.08);
  --dash: rgba(0, 0, 0, 0.14);
  --accent: #0071e3;
  --accent-hover: #0077ed;
  --accent-text: #0060c0;
  --accent-soft: rgba(0, 113, 227, 0.1);
  --accent-ring: rgba(0, 113, 227, 0.3);
  --green: #17702f;
  --green-soft: rgba(52, 199, 89, 0.15);
  --orange: #9a4f00;
  --orange-soft: rgba(255, 149, 0, 0.16);
  --red: #c4001a;
  --red-soft: rgba(255, 59, 48, 0.1);
  --blue: #0060c0;
  --blue-soft: rgba(0, 113, 227, 0.1);
  --r-xs: 8px;
  --r-sm: 10px;
  --r-md: 14px;
  --r-lg: 18px;
  --r-xl: 24px;
  --r-pill: 999px;
  --shadow-1:
    0 1px 1px rgba(0, 0, 0, 0.02), 0 2px 8px rgba(0, 0, 0, 0.04),
    0 12px 32px rgba(0, 0, 0, 0.04);
  --shadow-2: 0 2px 6px rgba(0, 0, 0, 0.05), 0 18px 48px rgba(0, 0, 0, 0.1);
  --shadow-pop: 0 2px 8px rgba(0, 0, 0, 0.06), 0 30px 80px rgba(0, 0, 0, 0.22);
  --spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --spring-soft: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-in: cubic-bezier(0.4, 0, 1, 1);
  --sidebar: 224px;
  --gutter: 16px;
  font-family:
    -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC",
    "Hiragino Sans GB", "Helvetica Neue", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
@supports (transition-timing-function: linear(0, 1)) {
  :root {
    --spring: linear(
      0,
      0.038 2.2%,
      0.211 5.6%,
      0.51 9.6%,
      0.845 14.2%,
      1.107 19.2%,
      1.227 24.5%,
      1.208 30.2%,
      1.111 36.1%,
      1.01 42.4%,
      0.953 48.9%,
      0.949 55.6%,
      0.974 62.5%,
      1 69.6%,
      1.012 76.9%,
      1.01 84.5%,
      1.003 92.1%,
      1
    );
    --spring-soft: linear(
      0,
      0.013 2.2%,
      0.074 5.6%,
      0.189 9.6%,
      0.342 14.2%,
      0.511 19.2%,
      0.673 24.5%,
      0.811 30.2%,
      0.915 36.1%,
      0.983 42.4%,
      1.022 48.9%,
      1.037 55.6%,
      1.034 66%,
      1.02 76.9%,
      1.008 88.3%,
      1
    );
  }
}

/* ─── Base ──────────────────────────────────────────────────────────────── */
* {
  box-sizing: border-box;
}
/* Component display rules (flex rows, grids) must not resurrect hidden elements. */
[hidden] {
  display: none !important;
}
body {
  margin: 0;
  min-width: 600px;
  background: var(--bg);
}
::selection {
  background: var(--accent-soft);
}
h1,
h2,
h3,
p {
  margin: 0;
}
h1 {
  font-size: 30px;
  font-weight: 700;
  letter-spacing: -0.022em;
  line-height: 1.15;
}
h2 {
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.01em;
}
h3 {
  font-size: 15px;
  font-weight: 600;
}
small,
.muted {
  color: var(--ink-2);
  font-size: 12px;
  line-height: 1.5;
}
a {
  color: var(--accent);
  text-decoration: none;
}
label {
  display: block;
}
svg {
  flex-shrink: 0;
}
:focus-visible {
  outline: 3px solid var(--accent-ring);
  outline-offset: 2px;
}

/* ─── Buttons ───────────────────────────────────────────────────────────── */
button,
.button-link {
  font: inherit;
  font-weight: 500;
  color: var(--ink);
  background-color: var(--fill);
  border: 0;
  border-radius: var(--r-sm);
  padding: 8px 16px;
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  white-space: nowrap;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition:
    background-color 0.2s var(--ease-out),
    color 0.2s var(--ease-out),
    box-shadow 0.25s var(--ease-out),
    transform 0.5s var(--spring);
}
button:hover,
.button-link:hover {
  background-color: var(--fill-strong);
}
/* Press squashes quickly; release rebounds on the spring curve above. */
button:active:not(:disabled),
.button-link:active {
  transform: scale(0.95);
  transition-duration: 0.08s;
  transition-timing-function: var(--ease-out);
}
button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
button svg,
.button-link svg {
  width: 17px;
  height: 17px;
}
.primary {
  background-color: var(--accent);
  color: #fff;
}
.primary:hover {
  background-color: var(--accent-hover);
}
.quiet,
.ghost {
  background-color: transparent;
}
.quiet:hover,
.ghost:hover {
  background-color: var(--fill-2);
}
.ghost {
  color: var(--ink-2);
}
.link {
  background: none;
  color: var(--accent);
  min-height: 32px;
  padding: 4px 10px;
}
.link:hover {
  background-color: var(--accent-soft);
}
.danger {
  color: var(--red);
}
.small {
  font-size: 13px;
  padding: 5px 12px;
  min-height: 30px;
  border-radius: var(--r-xs);
}
.wide {
  width: 100%;
}
.pill {
  border-radius: var(--r-pill);
}
.icon-btn {
  width: 36px;
  height: 36px;
  min-height: 36px;
  padding: 0;
  border-radius: 50%;
  background-color: transparent;
  color: var(--ink-2);
  display: inline-grid;
  place-items: center;
  flex-shrink: 0;
}
.icon-btn:hover {
  background-color: var(--fill);
  color: var(--ink);
}
.icon-btn.small {
  width: 30px;
  height: 30px;
  min-height: 30px;
}
.icon-btn svg {
  width: 18px;
  height: 18px;
}
.icon-btn.small svg {
  width: 16px;
  height: 16px;
}
.glass {
  font-size: 13px;
  min-height: 30px;
  padding: 5px 14px;
  border-radius: var(--r-pill);
  color: var(--ink);
  background-color: rgba(255, 255, 255, 0.78);
  -webkit-backdrop-filter: saturate(180%) blur(16px);
  backdrop-filter: saturate(180%) blur(16px);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
}
.glass:hover {
  background-color: rgba(255, 255, 255, 0.95);
}
.button-link {
  background-color: var(--surface);
  box-shadow: var(--shadow-1);
  border-radius: var(--r-pill);
}

/* ─── Form controls ─────────────────────────────────────────────────────── */
input,
textarea,
select {
  font: inherit;
  width: 100%;
  color: var(--ink);
  background-color: var(--fill-2);
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  padding: 9px 12px;
  transition:
    background-color 0.2s var(--ease-out),
    border-color 0.2s var(--ease-out),
    box-shadow 0.2s var(--ease-out);
}
input:hover,
textarea:hover,
select:hover {
  background-color: var(--fill);
}
input:focus,
textarea:focus,
select:focus {
  outline: none;
  background-color: var(--surface);
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-ring);
}
::placeholder {
  color: var(--ink-3);
}
textarea {
  resize: vertical;
  min-height: 96px;
  line-height: 1.6;
}
select {
  appearance: none;
  padding-right: 32px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236e6e73' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m7 10 5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 14px;
  cursor: pointer;
}
input[type="checkbox"],
input[type="radio"] {
  width: auto;
  accent-color: var(--accent);
}
/* Round check: a native checkbox restyled, so labels and keyboard still work. */
input.check {
  appearance: none;
  -webkit-appearance: none;
  width: 22px;
  height: 22px;
  min-width: 22px;
  margin: 0;
  padding: 0;
  border-radius: 50%;
  border: 1.5px solid rgba(0, 0, 0, 0.24);
  background-color: var(--surface);
  background-position: center;
  background-repeat: no-repeat;
  background-size: 0;
  cursor: pointer;
  transition:
    background-color 0.2s var(--ease-out),
    border-color 0.2s var(--ease-out),
    background-size 0.35s var(--spring);
}
input.check:hover {
  border-color: var(--accent);
  background-color: var(--surface);
}
input.check:checked {
  background-color: var(--accent);
  border-color: var(--accent);
  background-size: 13px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m5.5 12.5 4 4 9-9'/%3E%3C/svg%3E");
}
input.check:focus {
  box-shadow: 0 0 0 4px var(--accent-ring);
}
input.check:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}
/* Segmented control: grey track with one white thumb that slides between
   equal-width segments. --n is the segment count, --i the selected index;
   motion.js springs the thumb between indices. */
.segmented {
  position: relative;
  isolation: isolate;
  display: grid;
  grid-template-columns: repeat(var(--n, 2), minmax(0, 1fr));
  gap: 2px;
  padding: 3px;
  background: var(--fill);
  border-radius: 12px;
}
.seg-thumb {
  position: absolute;
  z-index: 0;
  top: 3px;
  bottom: 3px;
  left: 3px;
  width: calc((100% - 6px - (var(--n, 2) - 1) * 2px) / var(--n, 2));
  border-radius: 9px;
  background: var(--surface);
  box-shadow:
    0 1px 2px rgba(0, 0, 0, 0.08),
    0 3px 10px rgba(0, 0, 0, 0.08);
  transform: translateX(calc(var(--i, 0) * (100% + 2px)));
  pointer-events: none;
}
.segmented.empty .seg-thumb {
  opacity: 0;
}
.segmented button {
  position: relative;
  z-index: 1;
  min-width: 0;
  min-height: 32px;
  padding: 5px 10px;
  border-radius: 9px;
  background-color: transparent;
  font-size: 13px;
  transition:
    color 0.2s var(--ease-out),
    opacity 0.15s var(--ease-out);
}
.segmented button:hover:not(.selected) {
  background-color: transparent;
  color: var(--ink-2);
}
/* Pressing a segment dims its label; the thumb answers on release. */
.segmented button:active:not(:disabled) {
  transform: none;
  opacity: 0.55;
}
.segmented button.selected {
  font-weight: 600;
}
.segmented.compact button {
  min-height: 28px;
  padding: 3px 6px;
  font-size: 12px;
}
.segmented.tabs {
  display: inline-grid;
  grid-template-columns: repeat(var(--n, 2), minmax(76px, 1fr));
  margin-bottom: 24px;
}
.segmented.tabs button {
  padding: 5px 18px;
}
.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.field > label,
.field-head label {
  font-size: 13px;
  font-weight: 600;
}
.field-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 30px;
}
.field-head label {
  display: flex;
  align-items: center;
  gap: 6px;
}
.counter {
  font-size: 12px;
  font-weight: 500;
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
}
.search-field {
  position: relative;
  display: block;
}
.search-field svg {
  position: absolute;
  left: 11px;
  top: 50%;
  width: 16px;
  height: 16px;
  transform: translateY(-50%);
  color: var(--ink-3);
  pointer-events: none;
}
.search-field input {
  height: 36px;
  padding: 0 12px 0 34px;
}

/* ─── Utilities ─────────────────────────────────────────────────────────── */
.flex {
  display: flex;
  align-items: center;
  gap: 10px;
}
.between {
  justify-content: space-between;
}
.grow {
  flex: 1;
  min-width: 0;
}
.stack {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.number {
  font-variant-numeric: tabular-nums;
}
.hidden {
  display: none !important;
}
.tag {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 9px;
  border-radius: var(--r-pill);
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  background: var(--fill);
  color: var(--ink-2);
}
.tag.green {
  background: var(--green-soft);
  color: var(--green);
}
.tag.blue {
  background: var(--blue-soft);
  color: var(--blue);
}
.tag.orange {
  background: var(--orange-soft);
  color: var(--orange);
}
.tag.red {
  background: var(--red-soft);
  color: var(--red);
}
.tag.glass {
  position: absolute;
  top: 10px;
  right: 10px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.8);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
}
.banner {
  background: var(--red-soft);
  color: var(--red);
  border-radius: var(--r-lg);
  padding: 14px 18px;
  margin-bottom: 20px;
  font-size: 13px;
  line-height: 1.7;
}
.banner b {
  display: block;
  font-size: 14px;
}
.banner.info {
  background: var(--accent-soft);
  color: var(--accent-text);
  margin: 0;
}
.error {
  color: var(--red);
  font-size: 13px;
  line-height: 1.5;
}
.error:empty {
  display: none;
}
.warning {
  display: block;
  color: var(--orange);
  font-size: 12px;
  margin-top: 6px;
}
.no-results {
  padding: 64px 16px;
  text-align: center;
  color: var(--ink-2);
  font-size: 14px;
}
.pending {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 32px 12px;
  color: var(--ink-2);
  font-size: 13px;
}
.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid var(--fill-strong);
  border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
}
.skeleton {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 10px 2px;
}
.skeleton span {
  height: 12px;
  width: 82%;
  border-radius: 6px;
  background: var(--fill-2);
}
.skeleton .short {
  width: 48%;
}

/* ─── Shell: floating glass sidebar ─────────────────────────────────────── */
.card {
  background: var(--surface);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-1);
}
.sidebar {
  position: fixed;
  top: var(--gutter);
  bottom: var(--gutter);
  left: var(--gutter);
  z-index: 20;
  width: var(--sidebar);
  display: flex;
  flex-direction: column;
  padding: 14px 12px 12px;
  border-radius: 26px;
  background: rgba(255, 255, 255, 0.7);
  -webkit-backdrop-filter: saturate(180%) blur(24px);
  backdrop-filter: saturate(180%) blur(24px);
  box-shadow:
    var(--shadow-1),
    inset 0 0 0 0.5px rgba(0, 0, 0, 0.06);
}
.nav {
  position: relative;
  isolation: isolate;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
/* Active-page highlight; slides vertically between items (gap 4px). */
.nav-thumb {
  position: absolute;
  z-index: 0;
  top: 0;
  left: 0;
  right: 0;
  height: 42px;
  border-radius: var(--r-md);
  background: var(--surface);
  box-shadow:
    0 1px 2px rgba(0, 0, 0, 0.06),
    0 4px 14px rgba(0, 0, 0, 0.06);
  transform: translateY(calc(var(--i, 0) * (100% + 4px)));
  pointer-events: none;
}
.nav.empty .nav-thumb {
  opacity: 0;
}
.nav-item {
  position: relative;
  z-index: 1;
  width: 100%;
  justify-content: flex-start;
  gap: 12px;
  min-height: 42px;
  padding: 9px 14px;
  border-radius: var(--r-md);
  background-color: transparent;
  color: var(--ink-2);
  font-size: 15px;
}
.nav-item svg {
  width: 20px;
  height: 20px;
}
.nav-item:hover {
  background-color: var(--fill-2);
  color: var(--ink);
}
.nav-item.active,
.nav-item.active:hover {
  background-color: transparent;
  color: var(--ink);
  font-weight: 600;
}
.nav-item[data-page]:active:not(:disabled) {
  transform: none;
  opacity: 0.6;
}
.nav-item.active svg {
  color: var(--accent);
}
.nav-divider {
  height: 1px;
  background: var(--line);
  margin: 8px 12px;
}
.sidebar-foot {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 12px 2px 2px 6px;
  border-top: 1px solid var(--line);
}
.avatar {
  width: 34px;
  height: 34px;
  flex-shrink: 0;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #64d2ff, #0a84ff);
  color: #fff;
  font-weight: 600;
  margin-right: 6px;
}
.who {
  flex: 1;
  min-width: 0;
}
.who b,
.who small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.who b {
  font-size: 14px;
  font-weight: 600;
}
.main {
  margin-left: calc(var(--sidebar) + var(--gutter) * 2);
  padding: 24px 32px 56px 16px;
  max-width: 1720px;
}
.page-enter {
  animation: page-in 0.55s var(--spring-soft) both;
}
.page-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 48px;
  margin: 4px 0 22px;
}
.page-heading > .flex {
  min-width: 0;
}
.page-heading h1 {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.block-title {
  margin: 4px 0 12px;
}

/* ─── Studio ────────────────────────────────────────────────────────────── */
.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 20px;
  align-items: start;
}
.workspace-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
#detail-slots {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
#active-results:empty {
  display: none;
}
.section-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 24px 0;
  min-height: 50px;
}
.section-body {
  padding: 16px 24px 24px;
}
.section-foot {
  padding: 0 24px 18px;
  color: var(--ink-2);
  font-size: 12px;
}
.style-layout {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 24px;
}
.dropzone {
  min-height: 260px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  text-align: center;
  color: var(--ink-2);
  background: var(--surface-2);
  border: 1.5px dashed var(--dash);
  border-radius: var(--r-lg);
  cursor: pointer;
  transition:
    background-color 0.25s var(--ease-out),
    border-color 0.25s var(--ease-out),
    transform 0.5s var(--spring);
}
.dropzone:hover,
.dropzone.over {
  background: var(--accent-soft);
  border-color: var(--accent);
}
.dropzone.over {
  transform: scale(1.02);
}
.dropzone:active {
  transform: scale(0.98);
  transition-duration: 0.08s;
}
.dropzone-icon {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--surface);
  color: var(--accent);
  box-shadow: var(--shadow-1);
}
.dropzone-icon svg {
  width: 22px;
  height: 22px;
}
.dropzone strong {
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
}
.source-image {
  position: relative;
  border-radius: var(--r-lg);
  overflow: hidden;
  background: var(--fill-2);
}
.source-image img {
  display: block;
  width: 100%;
  height: 280px;
  object-fit: contain;
}
.image-actions {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 10px;
  display: flex;
  justify-content: center;
  gap: 6px;
  opacity: 0;
  transform: translateY(6px);
  transition:
    opacity 0.2s var(--ease-out),
    transform 0.4s var(--spring-soft);
}
.source-image:hover .image-actions,
.source-image:focus-within .image-actions {
  opacity: 1;
  transform: none;
}
.source-image .box {
  position: absolute;
  border: 2px solid var(--accent);
  border-radius: 6px;
  background: rgba(0, 113, 227, 0.12);
  pointer-events: none;
  animation: fade 0.2s var(--ease-out);
}
.detail-grid {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 20px;
  padding: 16px 24px 24px;
}
.detail-column {
  min-width: 0;
}
.detail-grid .dropzone {
  min-height: 260px;
}
.detail-grid .source-image img {
  height: 260px;
}
.recognition-search {
  font-size: 13px;
}
.detail-column > .search-field {
  margin-bottom: 8px;
}
.item-list {
  max-height: 320px;
  overflow: auto;
  margin: 0 -6px;
  padding: 0 6px;
  scrollbar-width: thin;
  scrollbar-color: var(--fill-strong) transparent;
}
.group-title {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 6px 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-2);
  cursor: pointer;
  list-style: none;
}
.group-title::-webkit-details-marker {
  display: none;
}
.group-title::before {
  content: "›";
  display: inline-block;
  font-size: 16px;
  line-height: 1;
  transition: transform 0.35s var(--spring-soft);
}
details[open] > .group-title::before {
  transform: rotate(90deg);
}
/* Each recognized item is a pick: clicking inserts a reference card. */
.pick-row {
  position: relative;
  display: flex;
  align-items: flex-start;
  border-radius: var(--r-md);
  transition: background-color 0.15s var(--ease-out);
}
.pick-row:hover {
  background: var(--fill-2);
}
.pick-row.referenced {
  background: var(--accent-soft);
}
.pick {
  flex: 1;
  min-width: 0;
  min-height: 0;
  justify-content: flex-start;
  align-items: flex-start;
  gap: 10px;
  padding: 9px 8px;
  border-radius: var(--r-md);
  background-color: transparent;
  font-weight: 400;
  text-align: left;
  white-space: normal;
}
.pick:hover {
  background-color: transparent;
}
.pick:disabled {
  opacity: 0.45;
}
.pick b {
  display: block;
  font-weight: 500;
}
.pick small {
  display: block;
}
.pick-dot {
  position: relative;
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  margin-top: 1px;
  border-radius: 50%;
  border: 1.5px solid rgba(0, 0, 0, 0.18);
  color: var(--accent);
  background: var(--surface);
  transition:
    background-color 0.2s var(--ease-out),
    border-color 0.2s var(--ease-out);
}
.pick-dot svg {
  position: absolute;
  width: 13px;
  height: 13px;
  stroke-width: 2.6;
  transition:
    opacity 0.2s var(--ease-out),
    transform 0.4s var(--spring);
}
.pick-dot svg:last-child {
  opacity: 0;
  transform: scale(0.4);
}
.pick:hover .pick-dot {
  border-color: var(--accent);
}
.referenced .pick-dot {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.referenced .pick-dot svg:first-child {
  opacity: 0;
  transform: scale(0.4);
}
.referenced .pick-dot svg:last-child {
  opacity: 1;
  transform: none;
}
.type-tag {
  flex-shrink: 0;
  margin-top: 1px;
}
.pick-row .remove-item {
  width: 26px;
  height: 26px;
  min-height: 26px;
  margin: 8px 6px 0 -2px;
  opacity: 0;
}
.pick-row .remove-item svg {
  width: 14px;
  height: 14px;
}
.pick-row:hover .remove-item,
.pick-row .remove-item:focus-visible {
  opacity: 1;
}
.supplement {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 12px;
}
.supplement input {
  min-width: 0;
  font-size: 13px;
  padding: 7px 14px;
  border-radius: var(--r-pill);
}
.add-detail {
  width: 100%;
  min-height: 56px;
  gap: 8px;
  border-radius: var(--r-xl);
  background-color: transparent;
  border: 1.5px dashed var(--dash);
  color: var(--accent-text);
  font-size: 15px;
  font-weight: 600;
}
.add-detail:hover:not(:disabled) {
  background-color: var(--accent-soft);
  border-color: var(--accent);
}
.add-detail svg {
  width: 20px;
  height: 20px;
}
.inspector {
  position: sticky;
  top: var(--gutter);
  display: flex;
  flex-direction: column;
  gap: 20px;
  max-height: calc(100vh - var(--gutter) * 2);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 22px;
}
.inspector h2 {
  font-size: 20px;
  font-weight: 700;
}
.model-options {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}
.model-choice {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0;
  min-height: 0;
  padding: 4px;
  border-radius: var(--r-lg);
  background-color: var(--fill-2);
}
.model-choice:hover {
  background-color: var(--fill);
}
.model-choice img {
  display: block;
  width: 100%;
  aspect-ratio: 3 / 4;
  object-fit: cover;
  border-radius: 14px;
}
.model-choice small {
  padding: 6px 2px 2px;
  text-align: center;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.model-choice.selected {
  background-color: var(--accent-soft);
  box-shadow: inset 0 0 0 2px var(--accent);
}
.model-choice .order {
  position: absolute;
  top: 9px;
  right: 9px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--accent);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  box-shadow: 0 2px 8px rgba(0, 113, 227, 0.45);
}
/* Pinned to the panel's bottom edge while the fields above scroll. */
.inspector-footer {
  position: sticky;
  bottom: -22px;
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin: auto -22px -22px;
  padding: 18px 22px 22px;
  border-top: 1px solid var(--line);
  background: var(--surface);
}
.studio-head .filters:last-child {
  margin-bottom: 0;
}
.inspector-footer b {
  font-size: 15px;
}
.generate {
  min-height: 50px;
  font-size: 16px;
  font-weight: 600;
  box-shadow: 0 8px 22px rgba(0, 113, 227, 0.28);
}
.generate:hover {
  box-shadow: 0 10px 28px rgba(0, 113, 227, 0.36);
}

/* ─── Results ───────────────────────────────────────────────────────────── */
.status-line {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 16px 24px 0;
  padding: 16px 18px;
  border-radius: var(--r-lg);
  background: var(--fill-2);
}
.pulse {
  width: 10px;
  height: 10px;
  flex-shrink: 0;
  border-radius: 50%;
  background: var(--accent);
  animation: pulse-ring 1.6s var(--ease-out) infinite;
}
.progress {
  height: 4px;
  margin-top: 10px;
  overflow: hidden;
  border-radius: 4px;
  background: var(--fill);
}
.progress::after {
  content: "";
  display: block;
  width: 35%;
  height: 100%;
  border-radius: 4px;
  background: var(--accent);
  animation: progress 1.4s ease-in-out infinite;
}
.result-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
}
.result-image {
  position: relative;
  overflow: hidden;
  border-radius: var(--r-lg);
  background: var(--fill-2);
  cursor: zoom-in;
}
/* --ratio is set per card from the generated size; apparel keeps 2:3. */
.result-image > .no-results {
  display: grid;
  place-items: center;
  aspect-ratio: var(--ratio, 2 / 3);
  padding: 16px;
}
.result-image img {
  display: block;
  width: 100%;
  aspect-ratio: var(--ratio, 2 / 3);
  object-fit: cover;
  transition: transform 0.7s var(--spring-soft);
}
.result-image:hover img {
  transform: scale(1.03);
}
.result-caption {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 10px;
  font-size: 13px;
  color: var(--ink-2);
}
.compare-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  cursor: pointer;
}
.compare-toggle .check {
  width: 18px;
  height: 18px;
  min-width: 18px;
}
.compare-toggle .check:checked {
  background-size: 10px;
}
.result-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
}
/* Wrap instead of overflowing into the neighbouring card. */
.result-actions button {
  flex: 1 0 auto;
  min-height: 34px;
  padding: 6px 8px;
  font-size: 13px;
}
.result-error {
  aspect-ratio: var(--ratio, 2 / 3);
  display: grid;
  place-items: center;
  padding: 16px;
  text-align: center;
  font-size: 13px;
  color: var(--red);
  background: var(--red-soft);
  border-radius: var(--r-lg);
}

/* ─── Lists and tables ──────────────────────────────────────────────────── */
.filters {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 20px;
}
.filters input,
.filters select {
  width: auto;
  max-width: 260px;
  min-height: 38px;
  padding-top: 7px;
  padding-bottom: 7px;
  background-color: var(--surface);
  box-shadow: var(--shadow-1);
}
.filters input:focus,
.filters select:focus {
  box-shadow: 0 0 0 4px var(--accent-ring);
}
.filters input[type="date"] {
  width: 160px;
}
.filters .search-field {
  width: 260px;
}
.filters .search-field input {
  width: 100%;
  max-width: none;
}
.chip-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px 6px 8px;
  border-radius: var(--r-pill);
  background: var(--surface);
  box-shadow: var(--shadow-1);
  font-size: 13px;
  white-space: nowrap;
  cursor: pointer;
}
.chip-toggle .check {
  width: 20px;
  height: 20px;
  min-width: 20px;
}
.table-wrap {
  overflow: auto;
  padding: 6px 10px;
}
table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  text-align: left;
}
th {
  padding: 14px 14px 10px;
  border-bottom: 1px solid var(--line);
  color: var(--ink-2);
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}
td {
  padding: 13px 14px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
tr:last-child td {
  border-bottom: 0;
}
td small {
  display: block;
}
td .thumb {
  width: 36px;
  height: 48px;
  object-fit: cover;
  border-radius: 8px;
}
tr.clickable {
  cursor: pointer;
}
tr.clickable td {
  transition: background-color 0.15s var(--ease-out);
}
tr.clickable:hover td {
  background: var(--fill-2);
}
tr.clickable td:first-child {
  border-radius: 12px 0 0 12px;
}
tr.clickable td:last-child {
  border-radius: 0 12px 12px 0;
}
.row-chevron {
  width: 40px;
  color: var(--ink-3);
}
.row-chevron svg {
  display: block;
  width: 16px;
  height: 16px;
  margin-left: auto;
}
.table-more {
  display: flex;
  justify-content: center;
  padding: 14px 0 4px;
}
.table-empty {
  padding: 64px;
  text-align: center;
  color: var(--ink-2);
}
.stats-foot {
  margin-top: 14px;
  font-size: 13px;
}

/* ─── Works ─────────────────────────────────────────────────────────────── */
.works-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 20px;
}
.work-card {
  padding: 8px;
  cursor: pointer;
  transition:
    transform 0.55s var(--spring),
    box-shadow 0.3s var(--ease-out);
}
.work-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-2);
}
.work-card:active {
  transform: scale(0.97);
  transition-duration: 0.1s;
}
.work-card .cover {
  position: relative;
  display: grid;
  place-items: center;
  aspect-ratio: 3 / 4;
  overflow: hidden;
  border-radius: var(--r-lg);
  background: var(--fill-2);
}
.work-card .cover img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.work-card .cover .no-results {
  padding: 0;
  color: var(--ink-3);
}
.work-card .cover svg {
  width: 32px;
  height: 32px;
}
.work-meta {
  padding: 12px 6px 6px;
}
.work-meta h3 {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.work-meta small {
  display: block;
  margin-top: 2px;
}
.work-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 20px;
  align-items: start;
}
.work-layout > div:first-child,
.work-layout > aside {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
}
.edit-stage {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 560px;
  padding: 28px;
  border-radius: var(--r-xl);
  background: radial-gradient(circle at 50% 35%, #ffffff 0, #ebebef 100%);
  box-shadow: inset 0 0 0 1px var(--line);
}
.canvas-wrap {
  position: relative;
  max-width: 100%;
  line-height: 0;
  touch-action: none;
  overflow: hidden;
  border-radius: var(--r-md);
  box-shadow: var(--shadow-2);
}
.canvas-wrap > img {
  display: block;
  max-width: 100%;
  max-height: 640px;
  object-fit: contain;
}
.canvas-wrap canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  cursor: crosshair;
}
.stage-action {
  position: absolute;
  right: 16px;
  bottom: 16px;
}
.edit-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 20px;
}
.ref-thumbs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}
.ref-thumbs img {
  width: 56px;
  height: 72px;
  object-fit: cover;
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: transform 0.5s var(--spring);
}
.ref-thumbs img:hover {
  transform: scale(1.05);
}
.ref-add {
  width: 56px;
  height: 72px;
  border-radius: var(--r-sm);
  border: 1.5px dashed var(--dash);
  color: var(--accent);
}
.edit-hint {
  margin-top: -8px;
  font-size: 13px;
}
.edit-tools {
  position: absolute;
  top: 14px;
  left: 50%;
  z-index: 1;
  transform: translateX(-50%);
  /* Centered by its left edge, so never shrink to half the stage width. */
  width: max-content;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
  border-radius: var(--r-pill);
  background: var(--surface);
  box-shadow: var(--shadow-1);
}
.edit-tools .tool {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 34px;
  padding: 6px 12px;
  border-radius: var(--r-pill);
  background: transparent;
  color: var(--ink-2);
  font-size: 13px;
}
.edit-tools .tool:hover {
  background: var(--fill-2);
  color: var(--ink);
}
.edit-tools .tool.selected {
  background: var(--accent-soft);
  color: var(--accent-text);
}
.brush-size {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
  padding: 0 8px 0 10px;
  font-size: 12px;
  color: var(--ink-2);
}
/* A slider, not a text field: the shared input padding and box would draw the
   track wider than the thumb can travel, so it looked stuck short of both ends. */
.brush-size input {
  width: 160px;
  padding: 0;
  border: 0;
  background: none;
  accent-color: var(--accent);
}
.brush-size input:hover,
.brush-size input:focus {
  background: none;
  box-shadow: none;
}
.brush-size input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
  border-radius: var(--r-pill);
}
.edit-stage:has(.edit-tools) {
  padding-top: 68px;
}
.material-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(92px, 1fr));
  gap: 8px;
}
.material-card {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 4px;
  min-width: 0;
  padding: 4px 4px 6px;
  border-radius: var(--r-sm);
  background: var(--fill-2);
  color: var(--ink);
  text-align: left;
  box-shadow: inset 0 0 0 1px transparent;
  transition:
    background-color 0.2s var(--ease-out),
    box-shadow 0.2s var(--ease-out);
}
.material-card img {
  width: 100%;
  aspect-ratio: 4 / 5;
  object-fit: cover;
  border-radius: 6px;
  background: var(--surface);
}
.material-name {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
  font-size: 12px;
  font-weight: 600;
}
.material-name > span {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.material-card small {
  padding-left: 2px;
  font-size: 11px;
  color: var(--ink-2);
}
.material-card:hover {
  box-shadow: inset 0 0 0 1.5px var(--accent-ring);
}
.material-card.selected {
  background: var(--accent-soft);
  box-shadow: inset 0 0 0 1.5px var(--accent);
}

/* ─── Flat-lay ──────────────────────────────────────────────────────────── */
.flatlay-sources {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 200px;
  gap: 20px;
  padding: 16px 24px 12px;
}
.flatlay-source {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}
.flatlay-source .dropzone {
  min-height: 280px;
}
.garment-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.garment-card {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr);
  gap: 16px;
  padding: 12px;
  border-radius: var(--r-lg);
  background: var(--fill-2);
  transition:
    opacity 0.2s var(--ease-out),
    background-color 0.2s var(--ease-out);
}
.garment-card.off {
  opacity: 0.55;
}
.garment-card > img {
  width: 96px;
  height: 128px;
  object-fit: contain;
  border-radius: var(--r-md);
  background: var(--surface);
  cursor: zoom-in;
}
.garment-info {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}
.garment-title {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}
.garment-select {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}
.garment-select b {
  font-size: 15px;
}
.garment-info > small {
  color: var(--ink-2);
}
.garment-sides {
  display: flex;
  gap: 6px;
}
.side-toggle {
  min-height: 30px;
  padding: 4px 14px;
  border-radius: var(--r-pill);
  font-size: 13px;
  background: var(--surface);
  color: var(--ink-2);
  box-shadow: inset 0 0 0 1px var(--line);
}
.side-toggle.selected {
  background: var(--accent-soft);
  color: var(--accent-text);
  box-shadow: inset 0 0 0 1.5px var(--accent);
}
.garment-note {
  font-size: 13px;
}
.flatlay-rows {
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.flatlay-row-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}
.flatlay-pair {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 260px));
  gap: 16px;
}
.flatlay-pair .result-image img,
.flatlay-pair .result-error,
.flatlay-pending {
  aspect-ratio: 1 / 1;
  object-fit: contain;
  background: #fff;
}
.flatlay-pair.ratio-tall .result-image img,
.flatlay-pair.ratio-tall .result-error,
.flatlay-pair.ratio-tall .flatlay-pending {
  aspect-ratio: 3 / 4;
}
.flatlay-pending {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: var(--r-lg);
  background: var(--fill-2);
  color: var(--ink-2);
  font-size: 13px;
}
.flatlay-cell .result-actions + .result-actions {
  margin-top: 4px;
}
.result-actions button {
  white-space: nowrap;
}
.version-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.version {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 10px;
  border-radius: var(--r-md);
  transition: background-color 0.15s var(--ease-out);
}
.version:hover {
  background: var(--fill-2);
}
.version.current {
  background: var(--accent-soft);
}
.version img {
  width: 36px;
  height: 48px;
  object-fit: cover;
  border-radius: 8px;
  cursor: zoom-in;
}
.version b {
  font-weight: 600;
}
.version b small {
  font-weight: 400;
}
.version-actions {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.version small {
  display: block;
}

/* ─── Admin ─────────────────────────────────────────────────────────────── */
.metrics {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}
.metric {
  padding: 16px 18px;
  border-radius: var(--r-lg);
  background: var(--surface);
  box-shadow: var(--shadow-1);
}
.metric small {
  font-size: 13px;
}
.metric b {
  display: block;
  margin-top: 4px;
  font-size: 30px;
  font-weight: 700;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}
.chart {
  height: 220px;
  padding: 22px 24px;
  margin-bottom: 24px;
}
.chart svg {
  width: 100%;
  height: 100%;
  overflow: visible;
}
.chart .no-results {
  padding: 60px 0;
}
.library-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
}
.library-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
  padding: 10px 10px 14px;
}
.library-card > img {
  display: block;
  width: 100%;
  aspect-ratio: 3 / 4;
  object-fit: cover;
  border-radius: var(--r-lg);
  background: var(--fill-2);
}
.library-card > .flex,
.card-actions {
  padding: 0 4px;
}
.card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

/* ─── Login ─────────────────────────────────────────────────────────────── */
.login {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 32px 16px;
  background:
    radial-gradient(
      900px 600px at 12% 8%,
      rgba(0, 113, 227, 0.12),
      transparent 60%
    ),
    radial-gradient(
      800px 600px at 92% 92%,
      rgba(255, 45, 85, 0.09),
      transparent 60%
    ),
    var(--bg);
}
.login-card {
  width: min(400px, 100%);
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 36px 32px 24px;
  border-radius: 30px;
  box-shadow: var(--shadow-2);
  animation: sheet-in 0.65s var(--spring-soft) both;
}
.login-card h1 {
  text-align: center;
  font-size: 28px;
  margin-bottom: 6px;
}
.login-card .field input {
  min-height: 46px;
  font-size: 15px;
}
.login-card .primary {
  min-height: 48px;
  margin-top: 4px;
  font-size: 16px;
  font-weight: 600;
}
.login-foot {
  text-align: center;
}

/* ─── Dialogs, lightbox, toast ──────────────────────────────────────────── */
dialog {
  width: 560px;
  max-width: calc(100vw - 32px);
  max-height: calc(100vh - 48px);
  padding: 0;
  border: 0;
  border-radius: 26px;
  color: var(--ink);
  background: var(--surface);
  box-shadow: var(--shadow-pop);
}
dialog::backdrop {
  background: rgba(0, 0, 0, 0.28);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}
dialog[open] {
  animation: sheet-in 0.5s var(--spring-soft);
}
dialog[open]::backdrop {
  animation: fade 0.3s var(--ease-out);
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 18px 4px 24px;
}
.modal-head h2 {
  font-size: 19px;
  font-weight: 700;
}
.modal-body {
  max-height: 70vh;
  overflow: auto;
  padding: 14px 24px 22px;
}
.modal-body p + p {
  margin-top: 8px;
}
.modal-body .stack > label,
.modal-body > label {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
}
.modal-body .stack > label.flex {
  flex-direction: row;
  align-items: center;
  font-weight: 400;
  font-size: 14px;
}
.modal-body .result-section {
  box-shadow: none;
  background: var(--surface-2);
  border: 1px solid var(--line);
}
.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 0 24px 22px;
}
.modal-footer button {
  min-width: 96px;
  min-height: 40px;
  border-radius: var(--r-pill);
}
.summary-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.summary-list li {
  padding: 11px 14px;
  border-radius: var(--r-md);
  background: var(--fill-2);
  line-height: 1.6;
}
.lightbox {
  width: 1080px;
}
.lightbox .modal-body {
  display: flex;
  justify-content: center;
  gap: 16px;
  max-height: 80vh;
  padding: 12px 24px 24px;
}
.lightbox img {
  max-width: 48%;
  max-height: 74vh;
  object-fit: contain;
  border-radius: var(--r-lg);
}
.lightbox img:only-child {
  max-width: 100%;
}
.region-preview {
  position: relative;
  overflow: hidden;
  line-height: 0;
  border-radius: var(--r-lg);
  background: var(--fill-2);
}
.region-preview img {
  display: block;
  width: 100%;
  height: auto;
}
.region-outline {
  position: absolute;
  border: 2.5px solid var(--accent);
  border-radius: 8px;
  background: rgba(0, 113, 227, 0.08);
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.3);
  pointer-events: none;
}
.region-preview-large {
  max-width: 460px;
  margin: 0 auto;
}
/* A manual popover (top layer); reset the UA popover box before placing it. */
#toast {
  position: fixed;
  inset: auto;
  left: 50%;
  bottom: 28px;
  z-index: 100;
  margin: 0;
  border: 0;
  overflow: visible;
  max-width: min(560px, calc(100vw - 32px));
  padding: 12px 20px;
  border-radius: 18px;
  text-align: center;
  font-size: 14px;
  line-height: 1.5;
  color: #fff;
  background: rgba(29, 29, 31, 0.88);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  box-shadow: var(--shadow-2);
  opacity: 0;
  transform: translate(-50%, 24px) scale(0.96);
  pointer-events: none;
  transition:
    opacity 0.2s var(--ease-in),
    transform 0.25s var(--ease-in);
}
#toast.show {
  opacity: 1;
  transform: translate(-50%, 0) scale(1);
  transition:
    opacity 0.25s var(--ease-out),
    transform 0.6s var(--spring);
}

/* ─── Prompt composer and reference cards ──────────────────────────────── */
.prompt-editor {
  min-height: 150px;
  max-height: 320px;
  overflow-y: auto;
  padding: 10px 12px;
  border: 1px solid transparent;
  border-radius: var(--r-md);
  background-color: var(--fill-2);
  line-height: 2.1;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  cursor: text;
  transition:
    background-color 0.2s var(--ease-out),
    border-color 0.2s var(--ease-out),
    box-shadow 0.2s var(--ease-out);
}
.prompt-editor:hover {
  background-color: var(--fill);
}
.prompt-editor:focus {
  outline: none;
  background-color: var(--surface);
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-ring);
}
.prompt-editor.is-empty::before {
  content: attr(data-placeholder);
  color: var(--ink-3);
  pointer-events: none;
}
#prompt-stats.over {
  color: var(--red);
}
/* Style cards are blue, detail cards indigo; stale cards are struck through. */
.ref-chip {
  --chip: var(--accent);
  --chip-ink: var(--accent-text);
  --chip-soft: var(--accent-soft);
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 26px;
  margin: 0 2px;
  padding: 0 9px 0 3px;
  border-radius: 9px;
  vertical-align: middle;
  line-height: 1;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  color: var(--chip-ink);
  background: var(--chip-soft);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--chip) 22%, transparent);
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  transition:
    background-color 0.2s var(--ease-out),
    box-shadow 0.2s var(--ease-out);
}
.ref-chip.detail {
  --chip: #5856d6;
  --chip-ink: #4240b8;
  --chip-soft: rgba(88, 86, 214, 0.12);
}
.ref-chip:hover {
  box-shadow: inset 0 0 0 1.5px var(--chip);
}
.ref-src {
  display: inline-grid;
  place-items: center;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  border-radius: 7px;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  background: var(--chip);
}
.ref-aspect {
  font-size: 12px;
  font-weight: 500;
  opacity: 0.75;
}
.ref-chip .spinner {
  width: 12px;
  height: 12px;
}
.ref-chip.error {
  box-shadow: inset 0 0 0 1.5px var(--red);
}
.ref-chip.stale {
  --chip: #8e8e93;
  --chip-ink: var(--red);
  --chip-soft: var(--red-soft);
}
.ref-chip.stale .ref-name {
  text-decoration: line-through;
}
.ref-chip.static {
  cursor: default;
}
.ref-ghost {
  position: fixed;
  z-index: 200;
  display: inline-flex;
  align-items: center;
  height: 28px;
  padding: 0 12px;
  border-radius: 9px;
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  background: var(--accent);
  box-shadow: 0 8px 24px rgba(0, 113, 227, 0.35);
  pointer-events: none;
}
.chip-menu {
  position: fixed;
  z-index: 150;
  width: 272px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 14px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.92);
  -webkit-backdrop-filter: saturate(180%) blur(24px);
  backdrop-filter: saturate(180%) blur(24px);
  box-shadow: var(--shadow-pop);
}
.chip-menu[hidden] {
  display: none;
}
.chip-menu.open {
  animation: menu-in 0.4s var(--spring-soft) both;
}
.chip-menu h3 {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
}
.chip-menu h3 small {
  margin-left: auto;
  font-weight: 400;
}
.ref-src-inline {
  display: inline-grid;
  place-items: center;
  height: 20px;
  padding: 0 6px;
  border-radius: 7px;
  font-size: 11px;
  color: #fff;
  background: var(--accent);
}
.menu-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
}
.menu-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}
.prompt-preview {
  margin-bottom: 14px;
  padding: 14px 16px;
  border-radius: var(--r-md);
  background: var(--fill-2);
  line-height: 2.1;
  white-space: pre-wrap;
}
.summary-list li b {
  margin-right: 6px;
}
.summary-list li small {
  display: block;
}

/* ─── Motion ────────────────────────────────────────────────────────────── */
/* .jelly is added by motion.js to the control that was just pressed. */
.jelly {
  animation: jelly 0.6s var(--ease-out) both;
}
.check.jelly {
  animation: jelly-pop 0.5s var(--ease-out) both;
}
.pick.jelly {
  animation: jelly-soft 0.5s var(--ease-out) both;
}
.chip-pop {
  animation: chip-pop 0.55s var(--ease-out) both;
}
@keyframes jelly {
  0% {
    transform: scale(0.94);
  }
  30% {
    transform: scale(1.05, 0.96);
  }
  50% {
    transform: scale(0.97, 1.03);
  }
  70% {
    transform: scale(1.015, 0.99);
  }
  100% {
    transform: scale(1);
  }
}
@keyframes jelly-pop {
  0% {
    transform: scale(0.7);
  }
  40% {
    transform: scale(1.18);
  }
  65% {
    transform: scale(0.94);
  }
  85% {
    transform: scale(1.03);
  }
  100% {
    transform: scale(1);
  }
}
@keyframes jelly-soft {
  0% {
    transform: scale(0.985);
  }
  40% {
    transform: scale(1.012, 0.99);
  }
  100% {
    transform: scale(1);
  }
}
@keyframes chip-pop {
  0% {
    transform: scale(0.6);
  }
  45% {
    transform: scale(1.12);
  }
  70% {
    transform: scale(0.96);
  }
  100% {
    transform: scale(1);
  }
}
@keyframes menu-in {
  from {
    opacity: 0;
    transform: translateY(-6px) scale(0.96);
  }
}
@keyframes page-in {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
}
@keyframes sheet-in {
  from {
    opacity: 0;
    transform: translateY(16px) scale(0.96);
  }
}
@keyframes fade {
  from {
    opacity: 0;
  }
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
@keyframes pulse-ring {
  0% {
    box-shadow: 0 0 0 0 rgba(0, 113, 227, 0.45);
  }
  100% {
    box-shadow: 0 0 0 10px rgba(0, 113, 227, 0);
  }
}
@keyframes progress {
  from {
    transform: translateX(-100%);
  }
  to {
    transform: translateX(390%);
  }
}

/* ─── Responsive ────────────────────────────────────────────────────────── */
@media (min-width: 1600px) {
  .workspace {
    grid-template-columns: minmax(0, 1fr) 380px;
  }
  .detail-grid,
  .style-layout {
    grid-template-columns: 240px minmax(0, 1fr);
  }
}
/* Medium desktops: a narrower image column. */
@media (max-width: 1439px) {
  .detail-grid,
  .style-layout {
    grid-template-columns: 190px minmax(0, 1fr);
  }
  .metrics {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}
/* Compact window: icon rail sidebar, single-column studio. */
@media (max-width: 1179px) {
  :root {
    --sidebar: 64px;
    --gutter: 12px;
  }
  .sidebar {
    padding: 10px 8px;
    border-radius: 22px;
  }
  .nav-item {
    justify-content: center;
    padding: 9px 0;
  }
  .nav-item span,
  .who {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }
  .nav-divider {
    margin: 8px 6px;
  }
  .sidebar-foot {
    flex-direction: column;
    padding: 10px 0 0;
    gap: 6px;
  }
  .avatar {
    margin: 0 0 4px;
  }
  .main {
    padding: 20px 20px 48px 8px;
  }
  .workspace {
    grid-template-columns: minmax(0, 1fr);
  }
  .inspector {
    position: static;
  }
  .model-options {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
  .work-layout {
    grid-template-columns: minmax(0, 1fr);
  }
  .result-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .edit-stage {
    min-height: 440px;
  }
}
@media (max-width: 760px) {
  h1 {
    font-size: 26px;
  }
  .flatlay-sources {
    grid-template-columns: minmax(0, 1fr);
  }
  .garment-card {
    grid-template-columns: 72px minmax(0, 1fr);
  }
  .garment-card > img {
    width: 72px;
    height: 96px;
  }
  .edit-tools .tool span {
    display: none;
  }
  .style-layout,
  .detail-grid {
    grid-template-columns: minmax(0, 1fr);
  }
  .metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .filters .search-field {
    width: 100%;
  }
}
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* Category navigation and settings share the existing studio spacing. */
.category-badge {
  margin-left: auto;
  font-size: 10px;
  white-space: nowrap;
  opacity: 0.72;
}
.category-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
}
.quick-picks {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}
.product-flow {
  margin: 0 0 20px;
}
.design-base {
  display: flex;
  gap: 24px;
  align-items: center;
  margin-bottom: 20px;
}
.design-base > img {
  width: 180px;
  max-height: 220px;
  object-fit: contain;
  border-radius: 10px;
}
.design-base p {
  margin: 8px 0;
  line-height: 1.7;
}
/* The planner stacks vertically; the image lightbox lays children in a row. */
.planner {
  width: 960px;
}
@media (max-width: 760px) {
  .design-base {
    flex-direction: column;
    align-items: flex-start;
  }
}
.ip-thumb {
  position: relative;
  display: inline-block;
}
.ip-thumb img {
  width: 120px;
  height: 120px;
  object-fit: contain;
  border-radius: var(--r-sm);
  background: var(--fill-2);
  cursor: zoom-in;
}
.ref-thumbs .ip-thumb img {
  width: 56px;
  height: 72px;
  object-fit: cover;
}
.ip-detail-hint {
  margin: 4px 4px -4px;
}
.ip-thumb .icon-btn {
  position: absolute;
  top: 2px;
  right: 2px;
  background: var(--surface);
}
