:root {
  color-scheme: light;
  --bg: #f4f1ed;
  --surface: #fffaf5;
  --ink: #211f1d;
  --muted: #756e66;
  --line: #d8cfc5;
  --accent: #1f6f64;
  --accent-strong: #124c44;
  --warn: #9a5a16;
  --shadow: 0 10px 30px rgba(45, 35, 25, 0.12);
}

* {
  box-sizing: border-box;
}

html,
body {
  max-width: 100%;
  overflow-x: hidden;
}

html {
  min-height: 100%;
  overflow-y: scroll;
  scrollbar-color: #8c8176 #eee8e1;
  scrollbar-gutter: stable;
  scrollbar-width: auto;
}

html::-webkit-scrollbar {
  width: 16px;
}

html::-webkit-scrollbar-track {
  background: #eee8e1;
}

html::-webkit-scrollbar-thumb {
  border: 3px solid #eee8e1;
  border-radius: 999px;
  background: #8c8176;
}

html::-webkit-scrollbar-thumb:hover {
  background: #6f655c;
}

body {
  min-height: 100dvh;
  margin: 0;
  overflow-y: visible;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.45 Inter, "Segoe UI", Arial, sans-serif;
}

.page-scrollbar {
  display: none !important;
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 900;
  width: 22px;
  padding: 5px 4px;
  border-left: 1px solid rgba(33, 31, 29, 0.16);
  background: rgba(246, 242, 237, 0.96);
  box-shadow: -2px 0 10px rgba(45, 35, 25, 0.12);
  cursor: pointer;
  touch-action: none;
  user-select: none;
}

.page-scrollbar-thumb {
  position: absolute;
  left: 4px;
  right: 4px;
  top: 5px;
  min-height: 56px;
  border-radius: 999px;
  background: #625a52;
  box-shadow: 0 1px 6px rgba(45, 35, 25, 0.34);
}

.page-scrollbar:hover .page-scrollbar-thumb,
.page-scrollbar.dragging .page-scrollbar-thumb {
  background: var(--accent);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: center;
  padding: 18px 28px;
  background: rgba(255, 250, 245, 0.94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px);
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 24px;
  line-height: 1.1;
}

h2 {
  font-size: 20px;
}

.topbar p,
.section-heading p,
.summary-list {
  color: var(--muted);
}

.top-actions,
.slide-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.user-email {
  max-width: 220px;
  overflow: hidden;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.selected-only-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  padding: 0 12px 0 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: transparent;
  color: var(--ink);
  font-weight: 650;
  cursor: pointer;
  user-select: none;
}

.selected-only-toggle:hover {
  background: #eee6dd;
}

.selected-only-toggle.active {
  border-color: var(--accent);
  background: #e8f2ef;
}

.selected-only-toggle input {
  flex: 0 0 auto;
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--accent);
  cursor: pointer;
}

.selected-only-toggle span {
  white-space: nowrap;
}

.review-filter-button {
  font: inherit;
}

.selected-filter-control,
.generate-scope-control,
.review-filter-control {
  position: relative;
  display: inline-flex;
  z-index: 20;
}

.selected-filter-control.open,
.generate-scope-control.open,
.review-filter-control.open {
  z-index: 6000;
}

.selected-level-menu,
.generate-scope-menu,
.review-filter-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 50%;
  z-index: 6100;
  display: grid;
  gap: 6px;
  min-width: 156px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -4px);
  transition: opacity 0.14s ease, transform 0.14s ease;
}

.selected-filter-control:hover .selected-level-menu,
.selected-filter-control:focus-within .selected-level-menu,
.selected-filter-control.open .selected-level-menu,
.generate-scope-control:hover .generate-scope-menu,
.generate-scope-control:focus-within .generate-scope-menu,
.generate-scope-control.open .generate-scope-menu,
.review-filter-control:hover .review-filter-menu,
.review-filter-control:focus-within .review-filter-menu,
.review-filter-control.open .review-filter-menu {
  opacity: 1;
  pointer-events: auto;
  transform: translate(-50%, 0);
}

.selected-level-menu::before,
.generate-scope-menu::before,
.review-filter-menu::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: -12px;
  height: 12px;
}

.level-menu-option {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 30px;
  padding: 4px 6px;
  border-radius: 6px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}

.generate-cancel-button {
  min-width: 190px;
  min-height: 34px;
  padding: 0 12px;
  border-bottom: 1px solid rgba(176, 46, 36, 0.18);
  font-size: 13px;
  line-height: 1.15;
  white-space: normal;
}

.generate-cancel-button:disabled {
  border-color: var(--line);
  background: #eee6dd;
  color: var(--muted);
  cursor: default;
}

.level-menu-option:hover {
  background: #f2ece5;
}

.level-menu-option input {
  width: 15px;
  height: 15px;
  margin: 0;
  accent-color: var(--accent);
}

.add-variant-control {
  position: relative;
  display: inline-flex;
  z-index: 1;
}

.add-variant-control::before {
  content: "";
  position: absolute;
  left: -10px;
  right: -10px;
  bottom: 100%;
  display: none;
  height: 16px;
}

.add-variant-control.open-below::before {
  top: 100%;
  bottom: auto;
}

.add-variant {
  min-width: 42px;
  justify-content: center;
  font-size: 20px;
  line-height: 1;
}

.add-variant-menu {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 6px);
  z-index: 1000;
  display: grid;
  grid-template-columns: repeat(5, 32px);
  gap: 6px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 4px);
  transition: opacity 0.14s ease, transform 0.14s ease;
}

.add-variant-control.open-below .add-variant-menu {
  top: calc(100% + 6px);
  bottom: auto;
  transform: translate(-50%, -4px);
}

.add-variant-control.open::before,
.add-variant-control:hover::before,
.add-variant-control:focus-within::before {
  display: block;
}

.add-variant-control.open .add-variant-menu,
.add-variant-control:hover .add-variant-menu,
.add-variant-control:focus-within .add-variant-menu {
  opacity: 1;
  pointer-events: auto;
  transform: translate(-50%, 0);
}

.add-variant-control.open-below.open .add-variant-menu,
.add-variant-control.open-below:hover .add-variant-menu,
.add-variant-control.open-below:focus-within .add-variant-menu {
  transform: translate(-50%, 0);
}

.add-variant-count {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--soft);
  color: var(--ink);
  font: inherit;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
}

.add-variant-count:hover,
.add-variant-count.active {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid var(--accent);
  border-radius: 6px;
  background: var(--accent);
  color: white;
  text-decoration: none;
  font-weight: 650;
  cursor: pointer;
}

.button:hover {
  background: var(--accent-strong);
}

.button:disabled {
  cursor: default;
  opacity: 0.62;
}

.button.secondary {
  background: transparent;
  color: var(--ink);
  border-color: var(--line);
}

.button.secondary:hover {
  background: #eee6dd;
}

.button.choice {
  background: transparent;
  color: var(--ink);
  border-color: var(--line);
}

.button.choice:hover {
  background: #eee6dd;
}

.button.choice.active {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

.button.choice.level-1,
.button.level-1 {
  background: #1f6f64;
  color: #fff;
  border-color: #1f6f64;
}

.button.choice.level-2,
.button.level-2 {
  background: #a56719;
  color: #fff;
  border-color: #a56719;
}

.button.choice.level-3,
.button.level-3 {
  background: #8f2f45;
  color: #fff;
  border-color: #8f2f45;
}

.choice-level-control {
  position: relative;
  min-width: 0;
}

.choice-level-control .choose {
  width: 100%;
}

.choice-level-menu {
  position: absolute;
  left: 0;
  bottom: calc(100% + 6px);
  z-index: 80;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  width: max(100%, 138px);
  padding: 7px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffaf4;
  box-shadow: 0 12px 30px rgba(33, 31, 29, 0.22);
  opacity: 0;
  pointer-events: none;
  transform: translateY(4px);
  transition: opacity 0.12s ease, transform 0.12s ease;
}

.choice-level-menu::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -12px;
  height: 12px;
}

.choice-level-control.open .choice-level-menu {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.lightbox-choice-control {
  min-width: 112px;
  z-index: 90;
}

.lightbox-choice-control[hidden] {
  display: none;
}

.lightbox-choice-control.open {
  z-index: 7200;
}

.lightbox-choice-control .choice-level-menu {
  bottom: calc(100% - 1px);
  z-index: 7300;
  width: max(100%, 150px);
  transform: translateY(6px);
}

.lightbox-choice-control .choice-level-menu::after {
  bottom: -18px;
  height: 18px;
}

.choice-level-option {
  min-height: 30px;
  padding: 0 6px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f6efe7;
  color: var(--ink);
  font-size: 12px;
  font-weight: 850;
  cursor: pointer;
}

.choice-level-option:hover,
.choice-level-option.active {
  border-color: var(--accent);
  background: #e8f2ef;
}

.choice-level-option.level-1.active,
.choice-level-option.level-1:hover {
  border-color: #1f6f64;
  background: #1f6f64;
  color: #fff;
}

.choice-level-option.level-2.active,
.choice-level-option.level-2:hover {
  border-color: #a56719;
  background: #a56719;
  color: #fff;
}

.choice-level-option.level-3.active,
.choice-level-option.level-3:hover {
  border-color: #8f2f45;
  background: #8f2f45;
  color: #fff;
}

.button.danger {
  background: #b3342b;
  color: white;
  border-color: #b3342b;
}

.button.danger:hover {
  background: #8f261f;
}

.hidden {
  display: none !important;
}

.product-home {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 420px));
  gap: 22px;
  max-width: 980px;
  margin: 0 auto;
  padding: 28px 24px;
}

.product-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.product-cover {
  aspect-ratio: 3 / 4;
  background: #e4ddd5;
}

.product-cover img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.empty-cover {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  padding: 18px;
  color: var(--muted);
  text-align: center;
  font-weight: 750;
}

.product-body {
  display: grid;
  gap: 10px;
  padding: 16px;
}

.product-title-wrap {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  max-width: 100%;
}

.product-title-editable {
  min-width: 0;
  border: 0;
  padding: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  font-weight: inherit;
  text-align: left;
  cursor: text;
  overflow-wrap: anywhere;
}

.product-title-edit {
  width: 28px;
  height: 28px;
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--soft);
  color: var(--muted);
  font-weight: 800;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.product-title-wrap:hover .product-title-edit,
.product-title-edit:focus {
  opacity: 1;
}

.product-title-edit:hover {
  color: var(--accent);
  border-color: var(--accent);
}

.product-title-edit-input {
  width: min(460px, 76vw);
  min-height: 34px;
  padding: 4px 8px;
  border: 1px solid var(--accent);
  border-radius: 6px;
  background: white;
  color: var(--ink);
  font: inherit;
  font-weight: inherit;
}

.product-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.product-actions .delete-product {
  margin-left: auto;
}

.product-title-input {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 12px;
  background: white;
  color: var(--ink);
  font: inherit;
}

.create-product-card {
  display: grid;
  align-content: center;
  min-height: 260px;
  border-style: dashed;
  box-shadow: none;
}

.product-body p:empty {
  display: none;
}

.layout {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  align-items: start;
  gap: 24px;
  width: 100%;
  max-width: 1720px;
  margin: 0 auto;
  padding: 24px;
  overflow: visible;
}

.layout.hidden {
  display: none !important;
}

.sidebar {
  position: sticky;
  top: 92px;
  z-index: 120;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  box-shadow: var(--shadow);
}

.sidebar-title {
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
}

.model-panel {
  display: grid;
  gap: 8px;
  margin-bottom: 18px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.native-model-select {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.model-picker {
  position: relative;
  z-index: 130;
}

.model-picker-button {
  display: grid;
  gap: 4px;
  width: 100%;
  min-height: 58px;
  padding: 10px 34px 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, #fff, #f6f1ea);
  color: var(--ink);
  font: inherit;
  text-align: left;
  cursor: pointer;
  position: relative;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.03);
}

.model-picker-button::after {
  content: "⌄";
  position: absolute;
  right: 12px;
  top: 15px;
  color: var(--muted);
  font-size: 18px;
}

.model-picker-button:hover,
.model-picker-button[aria-expanded="true"] {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(20, 118, 102, 0.12);
}

#modelPickerName {
  display: block;
  font-weight: 800;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

#modelPickerPrice {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.25;
}

.model-picker-menu {
  position: absolute;
  z-index: 200;
  top: calc(100% + 8px);
  left: 0;
  display: grid;
  grid-template-columns: 320px 360px;
  width: min(720px, calc(100vw - 48px));
  max-height: 560px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  box-shadow: 0 18px 45px rgba(41, 32, 24, 0.18);
  overflow: hidden;
}

.model-option-list {
  max-height: 560px;
  overflow: auto;
  padding: 8px;
  border-right: 1px solid var(--line);
}

.model-option {
  display: grid;
  gap: 4px;
  width: 100%;
  padding: 10px;
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  color: var(--ink);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.model-option span {
  font-weight: 700;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.model-option small {
  color: var(--muted);
  font-size: 12px;
}

.model-option:hover,
.model-option:focus,
.model-option[aria-selected="true"] {
  border-color: rgba(20, 118, 102, 0.24);
  background: #eef7f4;
  outline: none;
}

.model-hover-details {
  min-width: 0;
  padding: 16px;
  background: #fbf8f4;
}

.model-detail-card {
  display: grid;
  gap: 10px;
}

.model-detail-card h3 {
  margin: 0;
  font-size: 20px;
  line-height: 1.18;
}

.model-detail-card.compact h3 {
  font-size: 17px;
}

.model-detail-kicker {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.model-detail-price {
  display: inline-flex;
  width: fit-content;
  max-width: 100%;
  padding: 6px 9px;
  border-radius: 6px;
  background: #e3f1ed;
  color: var(--accent);
  font-weight: 800;
  line-height: 1.25;
}

.model-detail-meta {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.model-detail-card p {
  margin: 0;
  color: var(--ink);
  font-size: 13px;
  line-height: 1.45;
}

.model-detail-card code {
  color: var(--muted);
  font: 12px/1.35 ui-monospace, SFMono-Regular, Consolas, monospace;
  overflow-wrap: anywhere;
}

.model-detail-empty {
  color: var(--muted);
  font-weight: 700;
}

.model-info {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
  max-height: 40px;
  overflow: hidden;
}

.model-details-btn {
  width: 100%;
  min-height: 34px;
}

.model-details-panel {
  width: min(720px, calc(100vw - 28px));
  max-height: calc(100vh - 40px);
  overflow: auto;
  background: white;
  border-radius: 8px;
  padding: 22px;
  box-shadow: var(--shadow);
}

.model-details-body {
  display: grid;
  gap: 12px;
}

.model-detail-row {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 14px;
  align-items: start;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}

.model-detail-row span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.model-detail-row strong,
.model-detail-row code {
  color: var(--ink);
  font: inherit;
  overflow-wrap: anywhere;
}

.model-detail-description {
  margin-top: 4px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
  line-height: 1.55;
}

.common-photos {
  display: grid;
  gap: 10px;
  margin-bottom: 18px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.common-prompt-panel {
  display: grid;
  margin-bottom: 18px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.common-prompt-panel .button {
  width: 100%;
  min-height: 38px;
}

.common-prompt-modal-panel textarea {
  min-height: min(58vh, 520px);
  resize: vertical;
  font-family: Consolas, "SFMono-Regular", monospace;
  font-size: 13px;
  line-height: 1.45;
}

.common-photos .button {
  width: 100%;
  min-height: 34px;
}

.common-photo-list {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 7px;
}

.common-empty {
  grid-column: 1 / -1;
  padding: 10px;
  border: 1px dashed var(--line);
  border-radius: 6px;
  color: var(--muted);
  text-align: center;
  font-size: 13px;
  font-weight: 700;
}

.common-photo {
  position: relative;
  min-width: 0;
}

.common-photo-open {
  display: block;
  width: 100%;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: white;
  overflow: hidden;
  cursor: zoom-in;
}

.common-photo img {
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
}

.common-photo span {
  position: absolute;
  left: 4px;
  bottom: 4px;
  display: grid;
  place-items: center;
  min-width: 20px;
  height: 20px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--ink);
  font-size: 12px;
  font-weight: 800;
}

.delete-common-photo {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 24px;
  height: 24px;
  border: 1px solid rgba(0, 0, 0, 0.12);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.95);
  color: #8f261f;
  font-size: 17px;
  font-weight: 800;
  line-height: 1;
  cursor: pointer;
  opacity: 0;
}

.common-photo:hover .delete-common-photo,
.delete-common-photo:focus {
  opacity: 1;
}

.slide-nav {
  display: grid;
  gap: 6px;
}

.slide-nav-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  border-radius: 6px;
}

.slide-nav-item.nav-slide-dragging {
  opacity: 0.55;
}

.slide-nav a {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 9px 10px;
  border-radius: 6px;
  color: var(--ink);
  text-decoration: none;
}

.slide-nav a span:first-child {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.slide-nav a:hover,
.slide-nav-item:hover .slide-nav-link {
  background: #eee6dd;
}

.nav-slide-drag-handle {
  flex: 0 0 auto;
  width: 28px;
  height: 30px;
  display: inline-grid;
  place-items: center;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f2ebe4;
  color: var(--muted);
  cursor: grab;
  touch-action: none;
}

.nav-slide-drag-handle:hover,
.nav-slide-drag-handle:focus {
  border-color: var(--accent);
  color: var(--accent);
  background: #e8f2ef;
  outline: none;
}

.nav-slide-drag-handle:active {
  cursor: grabbing;
}

.slide-nav-item.nav-drop-before::before,
.slide-nav-item.nav-drop-after::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  height: 3px;
  border-radius: 999px;
  background: var(--accent);
  z-index: 2;
}

.slide-nav-item.nav-drop-before::before {
  top: -4px;
}

.slide-nav-item.nav-drop-after::after {
  bottom: -4px;
}

.dot {
  width: 10px;
  height: 10px;
  margin-top: 5px;
  border-radius: 50%;
  background: #bbb1a7;
}

.dot.selected {
  background: var(--accent);
}

.content,
.slides {
  display: grid;
  gap: 22px;
  min-width: 0;
}

.slide-section,
.summary {
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  box-shadow: var(--shadow);
}

.slide-section {
  position: relative;
  z-index: 1;
  overflow: visible;
}

.slide-section.slide-dragging {
  opacity: 0.72;
}

.slide-section.slide-drop-before::before,
.slide-section.slide-drop-after::after {
  content: "";
  position: absolute;
  left: 18px;
  right: 18px;
  z-index: 3;
  height: 4px;
  border-radius: 999px;
  background: var(--accent);
  box-shadow: 0 0 0 4px rgba(31, 111, 100, 0.14);
}

.slide-section.slide-drop-before::before {
  top: -12px;
}

.slide-section.slide-drop-after::after {
  bottom: -12px;
}

.slide-section.variant-menu-open {
  z-index: 80;
}

.slide-section.level-menu-open {
  z-index: 1600;
}

.summary {
  overflow: hidden;
}

.section-heading {
  position: relative;
  z-index: 20;
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: start;
  margin-bottom: 16px;
}

.slide-heading-main {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  min-width: 0;
}

.slide-heading-copy {
  min-width: 0;
}

.slide-drag-handle {
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  display: inline-grid;
  place-items: center;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f2ebe4;
  color: var(--muted);
  cursor: grab;
  touch-action: none;
}

.drag-dots {
  width: 14px;
  height: 18px;
  background-image: radial-gradient(circle, currentColor 1.7px, transparent 1.9px);
  background-position: 0 0;
  background-size: 7px 6px;
  pointer-events: none;
}

.slide-drag-handle:hover,
.slide-drag-handle:focus {
  border-color: var(--accent);
  color: var(--accent);
  background: #e8f2ef;
  outline: none;
}

.slide-drag-handle:active {
  cursor: grabbing;
}

.slide-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  min-width: 0;
}

.slide-title-wrap {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.slide-title-editable {
  border: 0;
  padding: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  font-weight: inherit;
  text-align: left;
  cursor: text;
  overflow-wrap: anywhere;
}

.slide-title-edit {
  width: 28px;
  height: 28px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--soft);
  color: var(--muted);
  font-weight: 800;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.slide-title-wrap:hover .slide-title-edit,
.slide-title-edit:focus {
  opacity: 1;
}

.slide-title-edit:hover {
  color: var(--accent);
  border-color: var(--accent);
}

.slide-title-input {
  width: min(360px, 70vw);
  min-height: 34px;
  padding: 4px 8px;
  border: 1px solid var(--accent);
  border-radius: 6px;
  font: inherit;
  font-weight: inherit;
}

.image-grid {
  display: flex;
  gap: 14px;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow-x: auto;
  overflow-y: hidden;
  overscroll-behavior-x: contain;
  scroll-snap-type: x mandatory;
  -ms-overflow-style: none;
  scrollbar-width: none;
  padding-bottom: 8px;
}

.image-grid::-webkit-scrollbar {
  display: none;
  width: 0;
  height: 0;
}

.image-grid-scrollbar {
  display: block;
  position: relative;
  height: 24px;
  margin-top: 10px;
  border: 1px solid rgba(33, 31, 29, 0.18);
  border-radius: 999px;
  background: #e8ded4;
  box-shadow: inset 0 1px 3px rgba(45, 35, 25, 0.12);
  cursor: pointer;
  touch-action: none;
  user-select: none;
}

.image-grid-scrollbar-thumb {
  position: absolute;
  top: 4px;
  left: 4px;
  height: 14px;
  min-width: 72px;
  border-radius: 999px;
  background: #625a52;
  box-shadow: 0 1px 5px rgba(45, 35, 25, 0.28);
}

.image-grid-scrollbar:hover .image-grid-scrollbar-thumb,
.image-grid-scrollbar.dragging .image-grid-scrollbar-thumb {
  background: var(--accent);
}

.image-tile {
  position: relative;
  flex: 0 0 min(244px, calc((100% - 56px) / 5));
  min-width: 190px;
  border: 2px solid transparent;
  border-radius: 8px;
  background: #efe8df;
  overflow: hidden;
  scroll-snap-align: start;
}

.image-tile.selected {
  border-color: var(--accent);
}

.image-tile.selection-level-1 {
  border-color: #1f6f64;
}

.image-tile.selection-level-2 {
  border-color: #a56719;
}

.image-tile.selection-level-3 {
  border-color: #8f2f45;
}

.image-tile.original {
  opacity: 0.92;
}

.image-tile.source-placeholder {
  border-style: dashed;
}

.tile-delete-image {
  position: absolute;
  z-index: 2;
  top: 8px;
  right: 8px;
  width: 34px;
  height: 34px;
  border: 1px solid rgba(0, 0, 0, 0.16);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.94);
  color: #8f261f;
  font-size: 22px;
  font-weight: 850;
  line-height: 1;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.14s ease, transform 0.14s ease;
}

.image-tile:hover .tile-delete-image,
.tile-delete-image:focus {
  opacity: 1;
}

.tile-delete-image:hover {
  transform: scale(1.04);
}

.tile-drag-handle {
  position: absolute;
  z-index: 2;
  top: 8px;
  left: 8px;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 1px solid rgba(0, 0, 0, 0.16);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.94);
  color: var(--muted);
  font-size: 18px;
  font-weight: 850;
  line-height: 1;
  cursor: grab;
  opacity: 0;
  transition: opacity 0.14s ease, transform 0.14s ease;
}

.image-tile:hover .tile-drag-handle {
  opacity: 1;
}

.image-tile.dragging {
  opacity: 0.55;
}

.image-tile.drag-over {
  outline: 3px solid rgba(31, 111, 100, 0.32);
  outline-offset: -3px;
}

.image-frame {
  position: relative;
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  aspect-ratio: 3 / 4;
  background: #e4ddd5;
  overflow: hidden;
}

.dimension-badge {
  position: absolute;
  left: 8px;
  bottom: 8px;
  z-index: 2;
  padding: 4px 7px;
  border-radius: 999px;
  background: #b42318;
  color: #fff;
  font-size: 11px;
  font-weight: 850;
  line-height: 1;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.22);
}

.dimension-badge.edited {
  background: var(--accent);
}

button.image-frame {
  cursor: zoom-in;
}

.image-frame img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.tile-footer {
  display: grid;
  gap: 7px;
  padding: 9px;
}

.tile-title {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-weight: 700;
}

.placeholder-tile {
  display: grid;
  place-items: center;
  min-height: 100%;
  padding: 22px;
  color: var(--muted);
  text-align: center;
  font-weight: 700;
}

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

.tile-actions .button {
  min-width: 0;
  min-height: 30px;
  padding: 0 7px;
  font-size: 12px;
  line-height: 1.1;
  text-align: center;
  white-space: normal;
  overflow-wrap: anywhere;
}

.generation-actions {
  grid-template-columns: 1fr;
}

.generation-status {
  grid-column: 1 / -1;
  padding: 6px 8px;
  border: 1px solid rgba(48, 104, 178, 0.22);
  border-radius: 6px;
  background: rgba(48, 104, 178, 0.08);
  color: #23548e;
  font-size: 12px;
  font-weight: 800;
  line-height: 1.25;
}

.generation-error {
  grid-column: 1 / -1;
  width: 100%;
  padding: 6px 8px;
  border: 1px solid rgba(176, 46, 36, 0.24);
  border-radius: 6px;
  background: rgba(176, 46, 36, 0.08);
  color: #8f261f;
  font: inherit;
  font-size: 12px;
  font-weight: 800;
  line-height: 1.25;
  text-align: left;
  max-height: 56px;
  overflow: hidden;
  cursor: pointer;
}

.generation-error:hover,
.generation-error:focus-visible {
  border-color: rgba(176, 46, 36, 0.48);
  background: rgba(176, 46, 36, 0.13);
  outline: none;
}

.generation-error-message {
  display: block;
  max-height: 30px;
  overflow: hidden;
}

.generation-error-action {
  display: block;
  margin-top: 3px;
  color: #6f5345;
  font-size: 10px;
  font-weight: 850;
}

.generation-attempts {
  grid-column: 1 / -1;
  padding: 6px 8px;
  border: 1px solid rgba(106, 86, 51, 0.22);
  border-radius: 6px;
  background: rgba(245, 238, 224, 0.66);
  color: #55442d;
  font-size: 11px;
  line-height: 1.25;
}

.generation-attempts summary {
  cursor: pointer;
  font-weight: 800;
  list-style-position: inside;
}

.generation-attempt-list {
  display: grid;
  gap: 4px;
  max-height: 108px;
  margin-top: 6px;
  overflow: auto;
}

.generation-attempt-row {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: 6px;
  align-items: start;
  border-radius: 4px;
  padding: 2px 3px;
  cursor: pointer;
}

.generation-attempt-row:hover,
.generation-attempt-row:focus-visible {
  background: rgba(255, 255, 255, 0.72);
  outline: 1px solid rgba(31, 111, 100, 0.22);
}

.generation-attempt-label {
  font-weight: 800;
  white-space: nowrap;
}

.generation-attempt-detail {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.generation-attempt-row.failed .generation-attempt-label,
.generation-attempt-row.retrying .generation-attempt-label {
  color: #8f261f;
}

.generation-attempt-row.success .generation-attempt-label {
  color: #21725f;
}

.cancel-generation {
  grid-column: 1 / -1;
}

textarea {
  width: 100%;
  min-height: 56px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 12px;
  background: white;
  color: var(--ink);
  font: inherit;
}

.summary-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 10px;
}

.add-slide-panel {
  display: grid;
  place-items: center;
  min-height: 96px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: rgba(255, 250, 245, 0.68);
}

.summary-item {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 160;
  box-sizing: border-box;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto auto;
  gap: 12px;
  height: 100dvh;
  max-height: 100dvh;
  padding: 18px;
  overflow: hidden;
  overscroll-behavior: contain;
  background: rgba(21, 18, 15, 0.86);
}

.lightbox-topbar {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.lightbox-stage {
  position: relative;
  z-index: 1;
  width: min(1400px, calc(100vw - 150px));
  height: 100%;
  min-width: 0;
  min-height: 0;
  max-width: 100%;
  display: grid;
  place-items: center;
  gap: 18px;
  justify-self: center;
  overflow: hidden;
}

.lightbox-stage.compare-mode {
  grid-template-columns: minmax(280px, 0.9fr) minmax(320px, 1fr);
  align-items: stretch;
  width: min(1420px, calc(100vw - 150px));
}

.lightbox-stage.compare-mode .lightbox-canvas {
  align-self: center;
  justify-self: center;
  width: min(100%, calc((100dvh - 170px) * var(--canvas-ratio-number, 0.75)));
}

.lightbox-canvas {
  position: relative;
  display: grid;
  place-items: center;
  width: min(100%, calc((100dvh - 170px) * var(--canvas-ratio-number, 0.75)));
  max-width: 100%;
  max-height: 100%;
  aspect-ratio: var(--canvas-ratio, 3 / 4);
  overflow: hidden;
  border-radius: 8px;
  background: #111;
}

.lightbox-canvas.dimension-mismatch {
  background:
    repeating-linear-gradient(
      45deg,
      rgba(180, 35, 24, 0.28) 0,
      rgba(180, 35, 24, 0.28) 12px,
      rgba(255, 255, 255, 0.1) 12px,
      rgba(255, 255, 255, 0.1) 24px
    ),
    #111;
}

.lightbox-main-image,
.source-image-wrap img {
  display: block;
  align-self: center;
  justify-self: center;
  min-width: 0;
  min-height: 0;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  background: transparent;
}

.lightbox-main-image {
  width: 100%;
  height: 100%;
}

.lightbox-diagnostic {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 12px;
  z-index: 2;
  padding: 8px 10px;
  border-radius: 7px;
  background: rgba(180, 35, 24, 0.94);
  color: #fff;
  font-size: 13px;
  font-weight: 850;
  text-align: center;
}

.source-image-wrap img {
  width: 100%;
  height: 100%;
}

.lightbox-close,
.lightbox-source-toggle {
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.12);
  color: white;
  cursor: pointer;
}

.lightbox-source-toggle.active {
  background: var(--accent);
  border-color: var(--accent);
}

.lightbox-source-toggle:disabled {
  opacity: 0.48;
  cursor: default;
}

.lightbox-sources-panel {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 10px;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
}

.source-panel-heading {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: white;
  font-weight: 800;
}

.source-panel-heading span {
  color: rgba(255, 255, 255, 0.76);
}

.source-image-wrap {
  position: relative;
  min-height: 0;
  display: grid;
  place-items: center;
  overflow: hidden;
  border-radius: 8px;
  background: #111;
}

.source-image-wrap img {
  width: 100%;
  height: 100%;
}

.source-nav {
  position: absolute;
  top: 50%;
  z-index: 2;
  width: 36px;
  height: 52px;
  transform: translateY(-50%);
  border: 1px solid rgba(255, 255, 255, 0.32);
  border-radius: 7px;
  background: rgba(0, 0, 0, 0.32);
  color: white;
  font-size: 32px;
  cursor: pointer;
}

.source-nav.prev {
  left: 8px;
}

.source-nav.next {
  right: 8px;
}

.source-nav:disabled {
  display: none;
}

.source-thumbs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.source-thumb {
  position: relative;
  flex: 0 0 58px;
  width: 58px;
  height: 58px;
  padding: 0;
  border: 2px solid transparent;
  border-radius: 7px;
  overflow: hidden;
  background: #fff;
  cursor: pointer;
}

.source-thumb.active {
  border-color: var(--accent);
}

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

.source-thumb span {
  position: absolute;
  left: 4px;
  bottom: 4px;
  display: grid;
  place-items: center;
  min-width: 18px;
  height: 18px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--ink);
  font-size: 11px;
  font-weight: 850;
}

.lightbox-nav {
  position: absolute;
  top: 50%;
  width: 48px;
  height: 72px;
  transform: translateY(-50%);
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.13);
  color: white;
  font-size: 46px;
  line-height: 1;
  cursor: pointer;
}

.lightbox-nav:hover {
  background: rgba(255, 255, 255, 0.24);
}

.lightbox-nav.prev {
  left: 24px;
}

.lightbox-nav.next {
  right: 24px;
}

.lightbox-caption {
  position: relative;
  z-index: 2;
  justify-self: center;
  color: white;
  font-weight: 750;
  pointer-events: none;
}

.lightbox-actions {
  position: relative;
  z-index: 7000;
  justify-self: center;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}

.lightbox-actions .button {
  min-width: 112px;
}

.lightbox-actions .button.secondary {
  color: white;
  border-color: rgba(255, 255, 255, 0.32);
  background: rgba(255, 255, 255, 0.12);
}

.lightbox-actions .button.secondary:hover {
  background: rgba(255, 255, 255, 0.24);
}

.lightbox-actions .button.active {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

.variant-editor-modal {
  position: fixed;
  inset: 0;
  z-index: 220;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(21, 18, 15, 0.78);
}

.variant-editor-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 14px;
  width: min(1480px, calc(100vw - 36px));
  height: min(920px, calc(100dvh - 36px));
  min-height: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 16px;
}

.variant-editor-header,
.variant-editor-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.variant-editor-header p {
  color: var(--muted);
  font-weight: 700;
}

.variant-editor-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 260px;
  gap: 16px;
  min-height: 0;
}

.variant-editor-stage {
  position: relative;
  display: grid;
  place-items: center;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    repeating-linear-gradient(
      45deg,
      rgba(180, 35, 24, 0.18) 0,
      rgba(180, 35, 24, 0.18) 12px,
      rgba(255, 255, 255, 0.65) 12px,
      rgba(255, 255, 255, 0.65) 24px
    ),
    #2b2926;
}

.variant-editor-stage canvas {
  display: block;
  width: var(--editor-stage-width, 100%);
  height: var(--editor-stage-height, 100%);
  max-width: 100%;
  max-height: 100%;
  cursor: move;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.28);
  touch-action: none;
}

.variant-editor-box {
  position: absolute;
  z-index: 2;
  border: 2px solid #22c7b8;
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.08);
  cursor: move;
  touch-action: none;
}

.variant-editor-handle {
  position: absolute;
  width: 16px;
  height: 16px;
  border: 2px solid #fff;
  border-radius: 50%;
  background: #22c7b8;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  padding: 0;
}

.variant-editor-handle.n { top: -9px; left: 50%; transform: translateX(-50%); cursor: ns-resize; }
.variant-editor-handle.e { right: -9px; top: 50%; transform: translateY(-50%); cursor: ew-resize; }
.variant-editor-handle.s { bottom: -9px; left: 50%; transform: translateX(-50%); cursor: ns-resize; }
.variant-editor-handle.w { left: -9px; top: 50%; transform: translateY(-50%); cursor: ew-resize; }
.variant-editor-handle.nw { left: -9px; top: -9px; cursor: nwse-resize; }
.variant-editor-handle.ne { right: -9px; top: -9px; cursor: nesw-resize; }
.variant-editor-handle.se { right: -9px; bottom: -9px; cursor: nwse-resize; }
.variant-editor-handle.sw { left: -9px; bottom: -9px; cursor: nesw-resize; }

.variant-editor-controls {
  display: grid;
  align-content: start;
  gap: 12px;
  min-width: 0;
}

.variant-editor-control-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.variant-editor-status {
  min-height: 44px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
  font-weight: 700;
}

.variant-editor-actions {
  justify-content: flex-end;
}

.prompt-modal {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(21, 18, 15, 0.58);
}

.prompt-panel {
  width: min(920px, 100%);
  max-height: calc(100vh - 36px);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 18px;
  box-shadow: var(--shadow);
}

.auth-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at 20% 10%, rgba(245, 169, 95, 0.28), transparent 32%),
    radial-gradient(circle at 80% 20%, rgba(84, 112, 255, 0.16), transparent 30%),
    var(--bg);
}

.auth-card {
  width: min(420px, 100%);
  display: grid;
  gap: 16px;
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.auth-card h1 {
  margin: 0;
  font-size: 30px;
}

.auth-card p {
  margin: 0;
  color: var(--muted);
}

.auth-card form {
  display: grid;
  gap: 14px;
}

.auth-card label {
  display: grid;
  gap: 6px;
  font-weight: 800;
}

.auth-card input {
  width: 100%;
  box-sizing: border-box;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font: inherit;
}

.password-field {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
}

.password-toggle {
  align-self: stretch;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-soft);
  color: var(--text);
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

.password-toggle:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.auth-error {
  min-height: 20px;
  color: #b42318 !important;
  font-weight: 800;
}

.auth-switch a {
  color: var(--accent);
  font-weight: 900;
}

.settings-panel {
  width: min(520px, 100%);
  max-height: calc(100vh - 36px);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 18px;
  box-shadow: var(--shadow);
}

.generation-error-panel {
  width: min(980px, 100%);
  max-height: calc(100vh - 36px);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 18px;
  box-shadow: var(--shadow);
}

.generation-error-meta {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.generation-error-panel textarea {
  min-height: min(58vh, 560px);
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fff;
  color: var(--ink);
  font-family: Consolas, "SFMono-Regular", monospace;
  font-size: 12px;
  line-height: 1.45;
  white-space: pre;
}

.generation-attempt-popover {
  position: fixed;
  z-index: 160;
  display: grid;
  gap: 8px;
  width: min(520px, calc(100vw - 24px));
  max-height: min(360px, calc(100vh - 24px));
  border: 1px solid rgba(106, 86, 51, 0.28);
  border-radius: 8px;
  background: #fffdf8;
  padding: 10px;
  box-shadow: 0 18px 42px rgba(36, 28, 20, 0.22);
}

.generation-attempt-popover-title {
  color: var(--ink);
  font-size: 12px;
  font-weight: 900;
}

.generation-attempt-popover textarea {
  min-height: 160px;
  max-height: 290px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px;
  background: #fff;
  color: var(--ink);
  font-family: Consolas, "SFMono-Regular", monospace;
  font-size: 11px;
  line-height: 1.45;
  resize: both;
  white-space: pre;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 16px;
}

.settings-field {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-weight: 750;
}

.settings-field input,
.settings-field select {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 12px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-weight: 800;
}

.settings-field input:focus,
.settings-field select:focus {
  border-color: var(--accent);
  outline: 2px solid rgba(31, 111, 100, 0.16);
}

.prompt-panel textarea {
  min-height: 360px;
  font-family: Consolas, "SFMono-Regular", monospace;
  font-size: 13px;
}

.prompt-mode-switch {
  display: inline-flex;
  gap: 4px;
  margin: 8px 0 12px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
}

.prompt-mode-button {
  min-height: 34px;
  border: 0;
  border-radius: 6px;
  padding: 0 12px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-weight: 850;
  cursor: pointer;
}

.prompt-mode-button.active {
  background: var(--accent);
  color: #fff;
}

.prompt-pane {
  display: block;
}

.prompt-shared-settings {
  margin-top: 12px;
}

.variant-prompt-pane {
  display: grid;
  grid-template-columns: minmax(170px, 220px) minmax(0, 1fr);
  gap: 14px;
  margin-top: 4px;
}

.variant-prompt-sidebar {
  display: grid;
  align-content: start;
  gap: 8px;
  min-width: 0;
}

.variant-prompt-list-tools {
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px;
}

.variant-prompt-list-tools .button {
  width: 100%;
  min-height: 34px;
  padding-inline: 10px;
}

.variant-prompt-list {
  display: grid;
  align-content: start;
  gap: 8px;
  max-height: 560px;
  overflow: auto;
  padding-right: 4px;
}

.variant-prompt-item {
  display: grid;
  gap: 3px;
  min-height: 50px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  background: #fff;
  color: var(--ink);
  text-align: left;
  font: inherit;
  cursor: pointer;
}

.variant-prompt-item span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.variant-prompt-item.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(31, 111, 100, 0.14);
}

.variant-prompt-empty {
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 12px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
  text-align: center;
}

.variant-prompt-editor {
  display: grid;
  gap: 10px;
  min-width: 0;
}

.variant-prompt-heading,
.variant-prompt-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.variant-prompt-heading {
  justify-content: space-between;
}

#variantPromptMeta {
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

#variantPromptText {
  min-height: 430px;
  width: 100%;
}

@media (max-width: 720px) {
  .variant-prompt-pane {
    grid-template-columns: 1fr;
  }

  .variant-prompt-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    max-height: 170px;
  }

  .variant-prompt-list-tools {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.canvas-settings {
  display: grid;
  gap: 10px;
  margin: 12px 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
}

.canvas-settings-heading,
.canvas-size-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.canvas-settings-heading {
  justify-content: space-between;
  color: var(--ink);
}

#canvasSettingsSummary {
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
}

.canvas-ratio-buttons {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.canvas-ratio-button {
  min-height: 32px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

.canvas-ratio-button.active {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.canvas-size-field {
  display: grid;
  gap: 5px;
  min-width: 120px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.canvas-size-field:first-child {
  min-width: 180px;
}

.canvas-size-field input,
.canvas-size-field select {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 9px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-weight: 800;
}

.prompt-tools {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 12px;
  color: var(--muted);
  flex-wrap: wrap;
}

.prompt-attachments {
  display: flex;
  gap: 12px;
  margin-top: 12px;
  overflow-x: auto;
  padding-bottom: 8px;
}

.attachment-counter {
  flex: 0 0 150px;
  display: grid;
  place-items: center;
  min-height: 140px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
  padding: 12px;
  font-weight: 700;
}

.prompt-attachment {
  position: relative;
  flex: 0 0 160px;
  display: grid;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 8px;
  color: var(--ink);
  text-align: left;
  cursor: grab;
}

button.prompt-attachment {
  font: inherit;
}

.prompt-attachment img {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  border-radius: 6px;
  background: #e4ddd5;
}

.prompt-attachment:hover {
  border-color: var(--accent);
}

.prompt-attachment.dragging {
  opacity: 0.55;
}

.prompt-attachment.drag-over {
  outline: 3px solid rgba(31, 111, 100, 0.28);
}

.source-attachment {
  cursor: zoom-in;
}

.source-attachment.disabled-source {
  border-style: dashed;
  opacity: 0.72;
}

.source-attachment .attachment-note {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.25;
}

.source-toggle {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  min-height: 30px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--soft);
  color: var(--accent);
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
}

.attachment-index {
  font-weight: 750;
  font-size: 13px;
}

.delete-attachment {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 30px;
  height: 30px;
  border: 1px solid rgba(0, 0, 0, 0.12);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.92);
  color: #8f261f;
  font-size: 20px;
  font-weight: 800;
  line-height: 1;
  cursor: pointer;
  opacity: 0;
}

.prompt-attachment:hover .delete-attachment,
.delete-attachment:focus {
  opacity: 1;
}

.prompt-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 14px;
  flex-wrap: wrap;
}

.api-preview {
  display: grid;
  gap: 10px;
  margin-top: 16px;
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

.api-preview summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  cursor: pointer;
  font-size: 17px;
  font-weight: 800;
}

.api-preview summary::after {
  content: "⌄";
  font-size: 18px;
}

.api-preview[open] summary::after {
  transform: rotate(180deg);
}

.api-preview-images {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.api-preview-image {
  flex: 0 0 150px;
  display: grid;
  gap: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 8px;
  color: var(--ink);
  text-align: left;
  cursor: zoom-in;
}

.api-preview-image span {
  color: var(--muted);
  font-size: 12px;
}

#apiPreviewText {
  min-height: 320px;
  font-family: Consolas, "SFMono-Regular", monospace;
  font-size: 12px;
}

@media (max-width: 720px) {
  .lightbox {
    padding: 12px;
  }

  .lightbox-stage {
    width: 100%;
  }

  .lightbox-nav {
    top: auto;
    bottom: 76px;
    width: 44px;
    height: 52px;
    font-size: 36px;
  }
}

@media (max-width: 980px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
  }

  .slide-nav {
    grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  }

  .image-grid {
    display: flex;
  }

  .image-tile {
    flex-basis: min(280px, calc((100% - 14px) / 2));
  }

  .model-picker-menu {
    grid-template-columns: 1fr;
    width: min(520px, calc(100vw - 48px));
  }

  .model-option-list {
    max-height: 300px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .lightbox-stage.compare-mode {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(220px, 0.85fr) minmax(260px, 1fr);
    width: min(720px, calc(100vw - 32px));
  }

  .variant-editor-body {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(320px, 1fr) auto;
  }

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

@media (max-width: 560px) {
  .topbar,
  .section-heading {
    flex-direction: column;
  }

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

  .layout {
    padding: 14px;
  }

  .image-grid {
    display: flex;
  }

  .image-tile {
    flex-basis: min(280px, 88%);
  }
}
