:root {
  --ink: #17211d;
  --ink-soft: #52605a;
  --paper: #f2f4ee;
  --surface: #fbfcf8;
  --surface-strong: #ffffff;
  --line: #dce2da;
  --line-strong: #c6cfc5;
  --coral: #ff6243;
  --coral-dark: #dd472c;
  --green: #16735e;
  --green-soft: #d8eee7;
  --blue: #3469d6;
  --yellow: #f1c84b;
  --dark-panel: #17201c;
  --radius: 8px;
  --shadow: 0 18px 60px rgba(28, 42, 35, 0.09);
  --font-sans: "Segoe UI", "Microsoft YaHei UI", "PingFang SC", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(rgba(23, 33, 29, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(23, 33, 29, 0.035) 1px, transparent 1px),
    var(--paper);
  background-size: 28px 28px;
  font-family: var(--font-sans);
  min-width: 320px;
}

button,
input {
  font: inherit;
}

button {
  color: inherit;
}

button:focus-visible,
input:focus-visible {
  outline: 3px solid rgba(52, 105, 214, 0.3);
  outline-offset: 2px;
}

svg {
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.app-shell {
  width: min(1600px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: 0 28px 30px;
}

.topbar {
  height: 74px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  border-bottom: 1px solid var(--line-strong);
}

.brand {
  color: inherit;
  display: inline-flex;
  align-items: center;
  gap: 11px;
  text-decoration: none;
}

.brand-mark {
  width: 39px;
  height: 39px;
  display: grid;
  place-items: center;
  color: white;
  background: var(--coral);
  border-radius: 10px 4px 10px 4px;
  box-shadow: 5px 5px 0 var(--green);
}

.brand-mark svg {
  width: 25px;
  height: 25px;
  stroke-width: 1.7;
}

.brand-mark svg path:first-child {
  fill: currentColor;
  stroke: none;
}

.brand > span:last-child {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
}

.brand strong {
  font-size: 16px;
  letter-spacing: 0.02em;
}

.brand small {
  margin-top: 4px;
  color: var(--ink-soft);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.18em;
}

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

.privacy-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 11px;
  color: var(--green);
  background: var(--green-soft);
  border: 1px solid #b9ddd2;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

.privacy-pill svg {
  width: 15px;
  height: 15px;
}

.privacy-pill[data-state="ready"] {
  color: #0f654e;
  background: #d6f0e7;
  border-color: #acd9cd;
}

.privacy-pill[data-state="error"] {
  color: #9e3b26;
  background: #ffe0d8;
  border-color: #f3b7aa;
}

.api-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: -8px 0 18px;
  padding: 12px 14px;
  color: #8c3828;
  background: #fff0eb;
  border: 1px solid #f2b8aa;
  border-radius: var(--radius);
}

.api-banner > div {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-right: auto;
}

.api-banner strong {
  font-size: 13px;
}

.api-banner span:not(.api-status-dot) {
  color: #9d6358;
  font-size: 11px;
}

.api-banner .button {
  flex: 0 0 auto;
}

.api-status-dot {
  width: 10px;
  height: 10px;
  flex: 0 0 auto;
  background: var(--coral);
  border-radius: 50%;
  box-shadow: 0 0 0 4px rgba(255, 98, 67, 0.14);
}

main {
  padding-top: 38px;
}

.intro {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 48px;
  padding: 0 2px 28px;
}

.eyebrow,
.section-kicker {
  color: var(--coral-dark);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.16em;
}

.intro h1 {
  max-width: 800px;
  margin: 8px 0 0;
  font-size: clamp(30px, 3.7vw, 58px);
  line-height: 1.04;
  letter-spacing: -0.04em;
}

.intro p {
  width: min(420px, 36vw);
  margin: 0 0 5px;
  color: var(--ink-soft);
  font-size: 14px;
  line-height: 1.75;
}

.studio {
  display: grid;
  grid-template-columns: minmax(270px, 0.8fr) minmax(390px, 1.25fr) minmax(350px, 1fr);
  min-height: 710px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: var(--shadow);
}

.panel {
  min-width: 0;
  padding: 24px;
  background: var(--surface);
}

.source-panel,
.style-panel {
  border-right: 1px solid var(--line);
}

.result-panel {
  color: #f5f7f3;
  background:
    radial-gradient(circle at 85% 8%, rgba(255, 98, 67, 0.16), transparent 24%),
    var(--dark-panel);
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-height: 36px;
  margin-bottom: 20px;
}

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

.panel-heading h2 {
  margin: 0;
  font-size: 17px;
  letter-spacing: -0.02em;
}

.step-number {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  color: var(--ink);
  background: var(--yellow);
  border-radius: 50%;
  font-size: 10px;
  font-weight: 900;
}

.panel-note {
  max-width: 120px;
  color: var(--ink-soft);
  font-size: 11px;
  font-weight: 700;
  text-align: right;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.panel-heading-light {
  color: white;
}

.panel-heading-light .panel-note {
  color: #aebbb4;
}

.button {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 14px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 13px;
  font-weight: 750;
  transition:
    transform 160ms ease,
    background 160ms ease,
    border-color 160ms ease,
    opacity 160ms ease;
}

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

.button:active:not(:disabled) {
  transform: translateY(0);
}

.button:disabled {
  cursor: not-allowed;
  opacity: 0.42;
}

.button svg {
  width: 17px;
  height: 17px;
}

.button-primary {
  color: white;
  background: var(--coral);
  border-color: var(--coral);
}

.button-primary:hover:not(:disabled) {
  background: var(--coral-dark);
  border-color: var(--coral-dark);
}

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

.button-secondary:hover:not(:disabled) {
  background: var(--green);
  border-color: var(--green);
}

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

.button-ghost:hover:not(:disabled) {
  background: white;
  border-color: var(--ink);
}

.button-wide {
  width: 100%;
}

.upload-state {
  display: grid;
  gap: 12px;
}

#fileInput {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.dropzone {
  position: relative;
  width: 100%;
  min-height: 412px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 28px;
  color: var(--ink);
  background:
    linear-gradient(135deg, rgba(22, 115, 94, 0.06), transparent 48%),
    white;
  border: 1px dashed #aab8ae;
  border-radius: var(--radius);
  cursor: pointer;
  overflow: hidden;
  transition:
    border-color 180ms ease,
    background 180ms ease;
}

.dropzone:hover,
.dropzone.is-dragging {
  background:
    linear-gradient(135deg, rgba(255, 98, 67, 0.08), transparent 48%),
    white;
  border-color: var(--coral);
}

.dropzone::before,
.dropzone::after {
  position: absolute;
  content: "";
  pointer-events: none;
}

.dropzone::before {
  top: 14px;
  left: 14px;
  width: 36px;
  height: 36px;
  border-top: 2px solid var(--coral);
  border-left: 2px solid var(--coral);
  border-radius: 6px 0 0;
}

.dropzone::after {
  right: 14px;
  bottom: 14px;
  width: 36px;
  height: 36px;
  border-right: 2px solid var(--green);
  border-bottom: 2px solid var(--green);
  border-radius: 0 0 6px;
}

.sample-portrait {
  position: relative;
  width: 132px;
  height: 132px;
  display: block;
  margin-bottom: 12px;
}

.sample-portrait img {
  width: 112px;
  height: 112px;
  object-fit: cover;
  border-radius: 50%;
  filter: saturate(0.92) contrast(1.05);
  box-shadow: 0 12px 34px rgba(22, 40, 32, 0.2);
}

.sample-ring {
  position: absolute;
  inset: 4px 0 0 8px;
  border: 2px solid var(--coral);
  border-radius: 50%;
  transform: rotate(-12deg) scale(1.08);
}

.sample-ring::after {
  position: absolute;
  right: -9px;
  top: 12px;
  width: 24px;
  height: 24px;
  content: "";
  background: var(--yellow);
  border: 3px solid white;
  border-radius: 50%;
}

.dropzone-icon {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  color: white;
  background: var(--green);
  border-radius: 50%;
  box-shadow: 0 0 0 5px rgba(22, 115, 94, 0.1);
}

.dropzone-icon svg {
  width: 18px;
  height: 18px;
}

.dropzone strong {
  margin-top: 6px;
  font-size: 16px;
}

.dropzone > span:not(.sample-portrait, .dropzone-icon) {
  color: var(--ink-soft);
  font-size: 13px;
}

.dropzone small {
  max-width: 230px;
  margin-top: 10px;
  color: #7c8881;
  font-size: 11px;
  line-height: 1.5;
}

.crop-stage {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  background:
    linear-gradient(45deg, #e6e9e4 25%, transparent 25%),
    linear-gradient(-45deg, #e6e9e4 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #e6e9e4 75%),
    linear-gradient(-45deg, transparent 75%, #e6e9e4 75%),
    white;
  background-position:
    0 0,
    0 8px,
    8px -8px,
    -8px 0;
  background-size: 16px 16px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: grab;
  touch-action: none;
}

.crop-stage:active {
  cursor: grabbing;
}

.crop-stage img {
  --crop-x: 0%;
  --crop-y: 0%;
  --crop-zoom: 1;
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  transform: translate(var(--crop-x), var(--crop-y)) scale(var(--crop-zoom));
  transform-origin: center;
  pointer-events: none;
  will-change: transform;
}

.crop-grid {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(
      to right,
      transparent calc(33.333% - 0.5px),
      rgba(255, 255, 255, 0.7) calc(33.333% - 0.5px),
      rgba(255, 255, 255, 0.7) calc(33.333% + 0.5px),
      transparent calc(33.333% + 0.5px),
      transparent calc(66.666% - 0.5px),
      rgba(255, 255, 255, 0.7) calc(66.666% - 0.5px),
      rgba(255, 255, 255, 0.7) calc(66.666% + 0.5px),
      transparent calc(66.666% + 0.5px)
    ),
    linear-gradient(
      to bottom,
      transparent calc(33.333% - 0.5px),
      rgba(255, 255, 255, 0.7) calc(33.333% - 0.5px),
      rgba(255, 255, 255, 0.7) calc(33.333% + 0.5px),
      transparent calc(33.333% + 0.5px),
      transparent calc(66.666% - 0.5px),
      rgba(255, 255, 255, 0.7) calc(66.666% - 0.5px),
      rgba(255, 255, 255, 0.7) calc(66.666% + 0.5px),
      transparent calc(66.666% + 0.5px)
    );
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.08);
}

.drag-hint {
  position: absolute;
  left: 50%;
  bottom: 12px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 9px;
  color: white;
  background: rgba(18, 28, 23, 0.72);
  border-radius: 999px;
  font-size: 10px;
  transform: translateX(-50%);
  pointer-events: none;
  backdrop-filter: blur(6px);
}

.drag-hint svg {
  width: 13px;
  height: 13px;
}

.editor-actions {
  justify-content: space-between;
  margin: 12px 0 18px;
}

.editor-actions .button {
  flex: 1;
}

.range-control {
  display: grid;
  gap: 9px;
}

.range-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--ink-soft);
  font-size: 12px;
  font-weight: 700;
}

.range-label output {
  color: var(--green);
}

input[type="range"] {
  width: 100%;
  height: 5px;
  margin: 0;
  background: linear-gradient(90deg, var(--green), var(--yellow), var(--coral));
  border-radius: 999px;
  appearance: none;
  cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
  width: 19px;
  height: 19px;
  background: white;
  border: 3px solid var(--ink);
  border-radius: 50%;
  box-shadow: 0 3px 9px rgba(0, 0, 0, 0.2);
  appearance: none;
}

input[type="range"]::-moz-range-thumb {
  width: 15px;
  height: 15px;
  background: white;
  border: 3px solid var(--ink);
  border-radius: 50%;
  box-shadow: 0 3px 9px rgba(0, 0, 0, 0.2);
}

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

.style-tile {
  position: relative;
  display: grid;
  gap: 9px;
  padding: 8px;
  text-align: left;
  background: white;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  cursor: pointer;
  overflow: hidden;
  transition:
    border-color 170ms ease,
    transform 170ms ease,
    box-shadow 170ms ease;
}

.style-tile:hover {
  border-color: var(--line-strong);
  transform: translateY(-2px);
  box-shadow: 0 10px 25px rgba(29, 44, 36, 0.1);
}

.style-tile[aria-pressed="true"] {
  border-color: var(--coral);
  box-shadow: 0 0 0 2px rgba(255, 98, 67, 0.16);
}

.style-preview {
  position: relative;
  aspect-ratio: 1;
  background:
    linear-gradient(135deg, rgba(22, 115, 94, 0.08), rgba(52, 105, 214, 0.08)),
    #e8ece6;
  border-radius: 5px;
  overflow: hidden;
}

.style-preview canvas {
  width: 100%;
  height: 100%;
  display: block;
  opacity: 0;
  transition: opacity 220ms ease;
}

.style-preview img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  transition: transform 220ms ease;
}

.style-tile:hover .style-preview img {
  transform: scale(1.035);
}

.style-demo-tag {
  position: absolute;
  left: 8px;
  bottom: 8px;
  padding: 4px 6px;
  color: white;
  background: rgba(18, 27, 23, 0.72);
  border-radius: 4px;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.04em;
  backdrop-filter: blur(5px);
}

.style-tile.is-ready .style-preview canvas {
  opacity: 1;
}

.style-name {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 21px;
  padding: 0 2px 1px;
  font-size: 13px;
  font-weight: 800;
}

.style-name span:last-child {
  width: 8px;
  height: 8px;
  flex: 0 0 auto;
  background: var(--style-color, var(--coral));
  border-radius: 50%;
}

.style-check {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 24px;
  height: 24px;
  display: none;
  place-items: center;
  color: white;
  background: var(--coral);
  border: 3px solid white;
  border-radius: 50%;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.18);
}

.style-tile[aria-pressed="true"] .style-check {
  display: grid;
}

.style-check svg {
  width: 12px;
  height: 12px;
  stroke-width: 3;
}

.tuning-panel {
  margin-top: 18px;
  padding: 17px;
  background: #f2f5ef;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.tuning-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 15px;
  margin-bottom: 18px;
}

.tuning-header h3 {
  margin: 4px 0 0;
  font-size: 14px;
}

.tuning-value {
  color: var(--coral-dark);
  font-size: 13px;
  font-weight: 900;
}

.prompt-field {
  display: grid;
  gap: 7px;
  margin-top: 17px;
  color: var(--ink-soft);
  font-size: 12px;
  font-weight: 700;
}

.prompt-field textarea {
  width: 100%;
  min-height: 76px;
  padding: 10px 11px;
  color: var(--ink);
  background: white;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  outline: 0;
  resize: vertical;
  font-size: 12px;
  line-height: 1.55;
}

.prompt-field textarea:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(22, 115, 94, 0.12);
}

.result-stage {
  position: relative;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  margin-bottom: 18px;
  background:
    linear-gradient(45deg, #27312c 25%, transparent 25%),
    linear-gradient(-45deg, #27312c 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #27312c 75%),
    linear-gradient(-45deg, transparent 75%, #27312c 75%),
    #202925;
  background-position:
    0 0,
    0 10px,
    10px -10px,
    -10px 0;
  background-size: 20px 20px;
  border: 1px solid #34423b;
  border-radius: var(--radius);
  overflow: hidden;
}

#resultCanvas {
  width: 100%;
  height: 100%;
  display: none;
  object-fit: contain;
}

.has-result #resultCanvas {
  display: block;
}

.empty-result {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  color: #a6b3ac;
  text-align: center;
}

.has-result .empty-result {
  display: none;
}

.empty-result strong {
  color: #e6ece8;
  font-size: 14px;
}

.empty-result > span:last-child {
  font-size: 11px;
}

.empty-orbit {
  position: relative;
  width: 80px;
  height: 80px;
  display: block;
  margin-bottom: 12px;
  border: 1px dashed #53625b;
  border-radius: 50%;
}

.empty-orbit span {
  position: absolute;
  display: block;
  border-radius: 50%;
}

.empty-orbit span:nth-child(1) {
  inset: 18px;
  background: var(--coral);
}

.empty-orbit span:nth-child(2) {
  top: -4px;
  left: 32px;
  width: 15px;
  height: 15px;
  background: var(--yellow);
}

.empty-orbit span:nth-child(3) {
  right: 3px;
  bottom: 8px;
  width: 19px;
  height: 19px;
  background: var(--green);
}

.processing-label {
  position: absolute;
  inset: 0;
  display: none;
  place-items: center;
  color: white;
  background: rgba(15, 22, 19, 0.7);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.06em;
  backdrop-filter: blur(4px);
}

.processing-label::before {
  width: 18px;
  height: 18px;
  content: "";
  margin-right: 9px;
  border: 2px solid rgba(255, 255, 255, 0.25);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 700ms linear infinite;
}

.result-stage.is-processing .processing-label {
  display: flex;
  align-items: center;
  justify-content: center;
}

.result-stale {
  position: absolute;
  left: 50%;
  bottom: 13px;
  z-index: 2;
  display: none;
  padding: 7px 10px;
  color: #17211d;
  background: var(--yellow);
  border-radius: 999px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.18);
  font-size: 10px;
  font-weight: 850;
  white-space: nowrap;
  transform: translateX(-50%);
}

.result-stage.is-stale .result-stale {
  display: block;
}

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

.result-controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 15px 18px;
  padding-bottom: 18px;
  border-bottom: 1px solid #34423b;
}

.control-block {
  min-width: 0;
}

.control-label {
  display: block;
  margin-bottom: 8px;
  color: #98a79f;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.segmented-control {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  padding: 3px;
  background: #222d28;
  border: 1px solid #35443d;
  border-radius: var(--radius);
}

.segmented-control button {
  height: 35px;
  display: grid;
  place-items: center;
  color: #9caaa3;
  background: transparent;
  border: 0;
  border-radius: 5px;
  cursor: pointer;
}

.segmented-control button[aria-pressed="true"] {
  color: white;
  background: #3a4841;
}

.segmented-control svg {
  width: 18px;
  height: 18px;
}

.swatch-row,
.border-control {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 35px;
}

.color-swatch {
  position: relative;
  width: 29px;
  height: 29px;
  padding: 0;
  background: var(--swatch, #f2f0e8);
  border: 2px solid #4e5c55;
  border-radius: 50%;
  cursor: pointer;
}

.color-swatch[data-background="transparent"] {
  background:
    linear-gradient(45deg, #d9ddd9 25%, transparent 25%),
    linear-gradient(-45deg, #d9ddd9 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #d9ddd9 75%),
    linear-gradient(-45deg, transparent 75%, #d9ddd9 75%),
    white;
  background-position:
    0 0,
    0 5px,
    5px -5px,
    -5px 0;
  background-size: 10px 10px;
}

.color-swatch[aria-pressed="true"] {
  border-color: white;
  box-shadow: 0 0 0 2px var(--coral);
}

.border-control button {
  min-width: 36px;
  height: 31px;
  padding: 0 9px;
  color: #b5c0ba;
  background: #222d28;
  border: 1px solid #3a4841;
  border-radius: 5px;
  cursor: pointer;
  font-size: 11px;
  font-weight: 750;
}

.border-control button[aria-pressed="true"] {
  color: #18201c;
  background: var(--yellow);
  border-color: var(--yellow);
}

.result-actions {
  display: grid;
  gap: 9px;
  margin-top: 18px;
}

.result-panel .button-ghost {
  color: #eaf0ec;
  border-color: #4a5b53;
}

.result-panel .button-ghost:hover:not(:disabled) {
  color: white;
  background: #27362f;
  border-color: #6d8177;
}

.gallery-section {
  margin-top: 34px;
  padding: 28px;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  box-shadow: var(--shadow);
}

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

.gallery-heading h2 {
  margin: 6px 0 5px;
  font-size: 29px;
  letter-spacing: -0.035em;
}

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

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

.gallery-card {
  min-width: 0;
  padding: 10px;
  background: white;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.gallery-card canvas {
  width: 100%;
  aspect-ratio: 1;
  display: block;
  margin-bottom: 9px;
  background:
    linear-gradient(45deg, #e4e8e3 25%, transparent 25%),
    linear-gradient(-45deg, #e4e8e3 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #e4e8e3 75%),
    linear-gradient(-45deg, transparent 75%, #e4e8e3 75%),
    white;
  background-position:
    0 0,
    0 7px,
    7px -7px,
    -7px 0;
  background-size: 14px 14px;
  border-radius: 5px;
}

.gallery-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.gallery-card-footer strong {
  font-size: 13px;
}

.gallery-download {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  color: var(--ink);
  background: #eef2ec;
  border: 1px solid var(--line);
  border-radius: 6px;
  cursor: pointer;
}

.gallery-download:hover {
  color: white;
  background: var(--green);
  border-color: var(--green);
}

.gallery-download svg {
  width: 16px;
  height: 16px;
}

.gallery-skeleton {
  aspect-ratio: 1;
  border-radius: var(--radius);
  background: linear-gradient(110deg, #edf0eb 8%, #f8faf6 18%, #edf0eb 33%);
  background-size: 200% 100%;
  animation: shimmer 1.2s linear infinite;
}

.service-empty {
  grid-column: 1 / -1;
  min-height: 180px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 24px;
  color: var(--ink-soft);
  text-align: center;
  background: #f3f6f1;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
}

.service-empty strong {
  color: var(--ink);
  font-size: 14px;
}

.service-empty span {
  font-size: 12px;
  line-height: 1.6;
}

@keyframes shimmer {
  to {
    background-position-x: -200%;
  }
}

footer {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  padding: 24px 3px 2px;
  color: var(--ink-soft);
  font-size: 11px;
}

footer span:first-child {
  color: var(--ink);
  font-weight: 800;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 20;
  max-width: min(420px, calc(100vw - 32px));
  padding: 11px 15px;
  color: white;
  background: #1d2823;
  border: 1px solid #3c4b44;
  border-radius: var(--radius);
  box-shadow: 0 15px 40px rgba(0, 0, 0, 0.2);
  font-size: 12px;
  font-weight: 700;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 12px);
  transition:
    opacity 180ms ease,
    transform 180ms ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.setup-dialog {
  width: min(560px, calc(100vw - 28px));
  padding: 0;
  color: var(--ink);
  background: var(--surface-strong);
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.28);
}

.setup-dialog::backdrop {
  background: rgba(15, 23, 19, 0.68);
  backdrop-filter: blur(3px);
}

.setup-dialog form {
  padding: 24px;
}

.setup-dialog-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 17px;
}

.setup-dialog h2 {
  margin: 5px 0 0;
  font-size: 22px;
  letter-spacing: -0.03em;
}

.setup-dialog p {
  color: var(--ink-soft);
  font-size: 13px;
  line-height: 1.7;
}

.setup-dialog pre {
  margin: 9px 0 18px;
  padding: 14px;
  color: #d7f0e7;
  background: #17201c;
  border-radius: 7px;
  overflow-x: auto;
  font-size: 12px;
  line-height: 1.7;
}

.setup-dialog code {
  font-family: Consolas, "SFMono-Regular", monospace;
}

.setup-note {
  margin-bottom: 0;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.dialog-close {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  color: var(--ink-soft);
  background: #eef2ec;
  border: 1px solid var(--line);
  border-radius: 50%;
  cursor: pointer;
  font-size: 21px;
  line-height: 1;
}

[hidden] {
  display: none !important;
}

@media (max-width: 1280px) {
  .studio {
    grid-template-columns: minmax(260px, 0.75fr) minmax(360px, 1.15fr) minmax(330px, 1fr);
  }

  .panel {
    padding: 20px;
  }

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

@media (max-width: 1080px) {
  .intro {
    align-items: start;
    flex-direction: column;
    gap: 16px;
  }

  .intro p {
    width: min(580px, 100%);
  }

  .studio {
    grid-template-columns: minmax(240px, 0.82fr) minmax(360px, 1.18fr);
  }

  .result-panel {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: minmax(280px, 0.9fr) minmax(320px, 1.1fr);
    gap: 0 24px;
  }

  .result-panel .panel-heading {
    grid-column: 1 / -1;
  }

  .result-stage {
    grid-row: 2 / 4;
    margin-bottom: 0;
  }

  .result-actions {
    align-self: end;
  }
}

@media (max-width: 760px) {
  .app-shell {
    padding: 0 14px 24px;
  }

  .topbar {
    height: 66px;
  }

  .privacy-pill {
    display: none;
  }

  .top-actions .button {
    width: 40px;
    padding: 0;
    font-size: 0;
  }

  .top-actions .button svg {
    width: 18px;
    height: 18px;
  }

  main {
    padding-top: 25px;
  }

  .intro {
    padding-bottom: 21px;
  }

  .intro h1 {
    font-size: 34px;
  }

  .studio {
    grid-template-columns: 1fr;
    border-radius: 10px;
  }

  .source-panel,
  .style-panel {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .result-panel {
    grid-column: auto;
    display: block;
  }

  .result-stage {
    margin-bottom: 18px;
  }

  .dropzone {
    min-height: 360px;
  }

  .gallery-section {
    padding: 20px 16px;
  }

  .gallery-heading {
    align-items: start;
    flex-direction: column;
  }

  .gallery-actions {
    width: 100%;
  }

  .gallery-actions .button {
    flex: 1;
  }

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

  footer {
    align-items: start;
    flex-direction: column;
    gap: 5px;
  }
}

@media (max-width: 430px) {
  .brand strong {
    font-size: 14px;
  }

  .brand small {
    display: none;
  }

  .panel {
    padding: 17px;
  }

  .style-grid {
    gap: 9px;
  }

  .style-tile {
    padding: 6px;
  }

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

  .gallery-heading h2 {
    font-size: 24px;
  }
}

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

/* 2026 dark studio refresh */
:root {
  --ink: #f3f7f3;
  --ink-soft: #98a59e;
  --paper: #080b0a;
  --surface: #111714;
  --surface-strong: #171e1a;
  --line: #26312c;
  --line-strong: #35443d;
  --coral: #ff7150;
  --coral-dark: #e45738;
  --green: #c6f66f;
  --green-soft: #26372a;
  --blue: #6c9cff;
  --yellow: #f6c85f;
  --dark-panel: #090d0b;
  --shadow: 0 30px 90px rgba(0, 0, 0, 0.42);
}

body {
  color: var(--ink);
  background:
    radial-gradient(circle at 18% 0%, rgba(198, 246, 111, 0.08), transparent 28%),
    radial-gradient(circle at 88% 4%, rgba(255, 113, 80, 0.08), transparent 25%),
    var(--paper);
}

.app-shell {
  width: min(1640px, 100%);
  padding: 0 24px 34px;
}

.topbar {
  height: 72px;
  border-color: #202923;
}

.brand {
  color: var(--ink);
}

.brand-mark {
  color: #101510;
  background: var(--green);
  border-radius: 8px 3px 8px 3px;
  box-shadow: 5px 5px 0 #33422e;
}

.brand small {
  color: #75827b;
}

.privacy-pill {
  color: #cae7dc;
  background: #14211c;
  border-color: #2a4137;
}

.privacy-pill[data-state="ready"] {
  color: #c6f66f;
  background: #182319;
  border-color: #38502e;
}

.privacy-pill[data-state="error"] {
  color: #ffad9c;
  background: #281715;
  border-color: #5f2f28;
}

.api-banner {
  margin-top: 0;
  color: #ffc2b4;
  background: #211513;
  border-color: #5b2d25;
}

.api-banner span:not(.api-status-dot) {
  color: #b98277;
}

.api-status-dot {
  background: var(--coral);
}

.intro {
  align-items: center;
  padding: 34px 4px 30px;
}

.eyebrow,
.section-kicker {
  color: var(--green);
}

.intro h1 {
  max-width: 760px;
  margin-top: 7px;
  font-size: clamp(32px, 3.3vw, 48px);
  line-height: 1.06;
  letter-spacing: -0.045em;
}

.intro p {
  color: #87948d;
}

.studio {
  min-height: 760px;
  background: #0d110f;
  border-color: #2b3731;
  border-radius: 10px;
  box-shadow: var(--shadow);
}

.panel,
.source-panel,
.style-panel {
  background: #111714;
}

.source-panel,
.style-panel {
  border-color: #222c27;
}

.result-panel {
  background:
    radial-gradient(circle at 78% 0%, rgba(198, 246, 111, 0.08), transparent 24%),
    #090d0b;
}

.panel-heading h2,
.panel-heading-light {
  color: #f5f8f5;
}

.step-number {
  color: #101510;
  background: var(--green);
  font-weight: 950;
}

.panel-note {
  color: #77847d;
}

.button {
  border-radius: 7px;
}

.button-primary {
  color: #101510;
  background: var(--green);
  border-color: var(--green);
}

.button-primary:hover:not(:disabled) {
  color: #101510;
  background: #d8ff95;
  border-color: #d8ff95;
}

.button-secondary {
  color: #f4f7f4;
  background: #232d28;
  border-color: #36443d;
}

.button-secondary:hover:not(:disabled) {
  color: #101510;
  background: var(--yellow);
  border-color: var(--yellow);
}

.button-ghost {
  color: #d8dfda;
  background: transparent;
  border-color: #39463f;
}

.button-ghost:hover:not(:disabled) {
  color: #f5f8f5;
  background: #202923;
  border-color: #607168;
}

.dropzone {
  min-height: 460px;
  color: #f3f7f3;
  background:
    linear-gradient(180deg, rgba(0, 0, 0, 0.08), rgba(0, 0, 0, 0.7)),
    radial-gradient(circle at 50% 20%, #28362f, #121815 70%);
  border: 1px solid #33423a;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.dropzone:hover,
.dropzone.is-dragging {
  background:
    linear-gradient(180deg, rgba(198, 246, 111, 0.06), rgba(0, 0, 0, 0.68)),
    radial-gradient(circle at 50% 20%, #34483b, #121815 70%);
  border-color: var(--green);
}

.dropzone::before {
  border-color: var(--green);
}

.dropzone::after {
  border-color: var(--coral);
}

.sample-portrait {
  width: 176px;
  height: 176px;
  margin-bottom: 20px;
}

.sample-portrait img {
  width: 156px;
  height: 156px;
  object-position: center 32%;
  filter: saturate(0.95) contrast(1.04);
  box-shadow:
    0 24px 60px rgba(0, 0, 0, 0.48),
    0 0 0 1px rgba(255, 255, 255, 0.16);
}

.sample-ring {
  inset: 7px 0 0 9px;
  border-color: var(--green);
}

.sample-ring::after {
  background: var(--coral);
  border-color: #111714;
}

.dropzone-icon {
  color: #121712;
  background: var(--green);
  box-shadow: 0 0 0 6px rgba(198, 246, 111, 0.1);
}

.dropzone strong {
  color: white;
  font-size: 17px;
}

.dropzone > span:not(.sample-portrait, .dropzone-icon),
.dropzone small {
  color: #98a69f;
}

.sample-portrait img,
.crop-stage,
.style-preview,
.tuning-panel,
.result-stage,
.segmented-control,
.border-control button,
.gallery-card,
.gallery-card canvas,
.setup-dialog {
  border-radius: 7px;
}

.crop-stage {
  border-color: #35443d;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.03);
}

.editor-actions .button {
  background: #161d19;
}

.range-label {
  color: #8b9891;
}

.range-label output {
  color: var(--green);
}

input[type="range"] {
  background: linear-gradient(90deg, var(--green), var(--yellow), var(--coral));
}

input[type="range"]::-webkit-slider-thumb,
input[type="range"]::-moz-range-thumb {
  border-color: #121713;
  box-shadow: 0 0 0 2px var(--green);
}

.style-grid {
  gap: 11px;
}

.style-tile {
  position: relative;
  display: block;
  padding: 0;
  color: white;
  background: #151c18;
  border-color: #2c3731;
  overflow: hidden;
  box-shadow: none;
}

.style-tile:hover {
  border-color: #64746b;
  transform: translateY(-3px);
  box-shadow: 0 18px 45px rgba(0, 0, 0, 0.38);
}

.style-tile[aria-pressed="true"] {
  border-color: var(--green);
  box-shadow:
    0 0 0 2px rgba(198, 246, 111, 0.16),
    0 18px 45px rgba(0, 0, 0, 0.4);
}

.style-preview {
  aspect-ratio: 4 / 5;
  background: #202923;
}

.style-preview::after {
  position: absolute;
  inset: 0;
  content: "";
  pointer-events: none;
  background:
    linear-gradient(180deg, rgba(0, 0, 0, 0.02) 35%, rgba(0, 0, 0, 0.85) 100%),
    linear-gradient(135deg, color-mix(in srgb, var(--style-color) 22%, transparent), transparent 58%);
}

.style-preview img {
  height: 100%;
  object-position: center 31%;
}

.style-preview::before {
  position: absolute;
  inset: 0;
  z-index: 1;
  content: "";
  pointer-events: none;
  opacity: 0.72;
  mix-blend-mode: soft-light;
}

.style-tile.has-reference .style-preview::before {
  opacity: 0.2;
}

.style-tile.has-reference .style-preview::after {
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.01) 42%, rgba(0, 0, 0, 0.78) 100%);
}

.style-tile[data-style="ghibli"] .style-preview::before {
  background:
    radial-gradient(circle at 22% 16%, rgba(255, 232, 146, 0.85), transparent 35%),
    radial-gradient(circle at 82% 74%, rgba(87, 149, 92, 0.8), transparent 44%);
}

.style-tile[data-style="cartoon"] .style-preview::before {
  background: linear-gradient(145deg, rgba(255, 191, 54, 0.68), rgba(255, 100, 72, 0.44));
}

.style-tile[data-style="anime"] .style-preview::before {
  background:
    linear-gradient(115deg, rgba(255, 175, 208, 0.58), transparent 46%),
    radial-gradient(circle at 72% 17%, rgba(147, 203, 255, 0.62), transparent 38%);
}

.style-tile[data-style="watercolor"] .style-preview::before {
  background:
    radial-gradient(circle at 22% 30%, rgba(92, 205, 190, 0.74), transparent 35%),
    radial-gradient(circle at 74% 68%, rgba(250, 186, 104, 0.6), transparent 42%);
}

.style-tile[data-style="clay"] .style-preview::before {
  background:
    repeating-linear-gradient(18deg, transparent 0 8px, rgba(255, 255, 255, 0.12) 8px 9px),
    linear-gradient(145deg, rgba(210, 139, 94, 0.76), rgba(255, 217, 177, 0.4));
}

.style-tile[data-style="comic"] .style-preview::before {
  background-image: radial-gradient(rgba(0, 0, 0, 0.42) 1px, transparent 1px);
  background-size: 5px 5px;
  mix-blend-mode: multiply;
}

.style-tile[data-style="pixel"] .style-preview::before {
  background:
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.1) 0 4px, transparent 4px 8px),
    repeating-linear-gradient(0deg, rgba(0, 0, 0, 0.12) 0 4px, transparent 4px 8px);
  mix-blend-mode: overlay;
}

.style-tile[data-style="cyber"] .style-preview::before {
  background:
    linear-gradient(115deg, rgba(15, 245, 255, 0.72), transparent 44%),
    linear-gradient(295deg, rgba(255, 47, 177, 0.72), transparent 48%);
}

.style-tile[data-style="storybook"] .style-preview::before {
  background:
    repeating-linear-gradient(94deg, transparent 0 7px, rgba(87, 56, 23, 0.12) 7px 8px),
    linear-gradient(145deg, rgba(193, 144, 73, 0.58), rgba(255, 235, 193, 0.38));
}

.style-tile[data-style="cinematic"] .style-preview::before {
  background:
    linear-gradient(180deg, rgba(4, 9, 11, 0.08), rgba(2, 6, 8, 0.58)),
    linear-gradient(110deg, rgba(255, 178, 91, 0.38), transparent 38%, rgba(43, 106, 148, 0.45));
}

.style-demo-tag {
  top: 8px;
  right: auto;
  bottom: auto;
  left: 8px;
  z-index: 2;
  color: #101510;
  background: var(--green);
}

.style-check {
  top: 8px;
  right: 8px;
  z-index: 3;
  border-color: #121713;
  background: var(--green);
  color: #101510;
}

.style-name {
  position: absolute;
  right: 11px;
  bottom: 9px;
  left: 11px;
  z-index: 2;
  min-height: 0;
  padding: 0;
  color: white;
  font-size: 14px;
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.8);
}

.style-name span:last-child {
  width: 7px;
  height: 7px;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.2);
}

.tuning-panel {
  background: #151c18;
  border-color: #2c3731;
}

.tuning-header h3 {
  color: #f4f7f4;
}

.tuning-value {
  color: var(--green);
}

.prompt-field {
  color: #87948d;
}

.prompt-field textarea {
  color: #eff4f0;
  background: #0e1310;
  border-color: #34423b;
}

.prompt-field textarea::placeholder {
  color: #5f6c65;
}

.prompt-field textarea:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(198, 246, 111, 0.1);
}

.result-stage {
  min-height: 0;
  background:
    linear-gradient(45deg, #141a17 25%, transparent 25%),
    linear-gradient(-45deg, #141a17 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #141a17 75%),
    linear-gradient(-45deg, transparent 75%, #141a17 75%),
    #0d1210;
  border-color: #29352f;
}

.empty-result strong {
  color: #dce4df;
}

.empty-orbit {
  border-color: #47564e;
}

.empty-orbit span:nth-child(1) {
  background: var(--green);
}

.empty-orbit span:nth-child(3) {
  background: var(--coral);
}

.control-label {
  color: #7d8a83;
}

.segmented-control {
  background: #0e1310;
  border-color: #34423b;
}

.segmented-control button[aria-pressed="true"] {
  color: #101510;
  background: var(--green);
}

.color-swatch {
  border-color: #526159;
}

.color-swatch[aria-pressed="true"] {
  border-color: white;
  box-shadow: 0 0 0 2px var(--green);
}

.border-control button {
  color: #a9b5ae;
  background: #121814;
  border-color: #34423b;
}

.border-control button[aria-pressed="true"] {
  color: #101510;
  background: var(--green);
  border-color: var(--green);
}

.result-panel .button-ghost {
  color: #dce4df;
  border-color: #34423b;
}

.result-panel .button-ghost:hover:not(:disabled) {
  color: #f6f9f6;
  background: #202923;
  border-color: #617169;
}

.gallery-section {
  background: #0d1210;
  border-color: #2b3731;
}

.gallery-heading h2 {
  color: white;
}

.gallery-heading p {
  color: #7e8b84;
}

.gallery-card {
  background: #141b17;
  border-color: #2b3731;
}

.gallery-card-footer strong {
  color: #eef3ef;
}

.gallery-download {
  color: #101510;
  background: var(--green);
  border-color: var(--green);
}

.gallery-download:hover {
  color: white;
  background: var(--coral);
  border-color: var(--coral);
}

.gallery-skeleton,
.service-empty {
  background: #171e1a;
  border-color: #2d3933;
}

.service-empty strong {
  color: #ecf1ed;
}

.service-empty span {
  color: #7f8c85;
}

footer {
  color: #68766f;
}

footer span:first-child {
  color: #aab6af;
}

.toast {
  color: #111611;
  background: var(--green);
  border-color: var(--green);
}

.setup-dialog {
  color: #eef3ef;
  background: #151c18;
  border-color: #39473f;
}

.setup-dialog::backdrop {
  background: rgba(0, 0, 0, 0.78);
}

.setup-dialog p {
  color: #94a098;
}

.setup-dialog pre {
  color: #d9ff9b;
  background: #080b09;
  border: 1px solid #26312c;
}

.dialog-close {
  color: #d7dfda;
  background: #222b26;
  border-color: #3b4942;
}

@media (max-width: 760px) {
  .app-shell {
    padding: 0 12px 26px;
  }

  .intro {
    align-items: flex-start;
    padding-top: 26px;
  }

  .intro h1 {
    font-size: 34px;
  }

  .studio {
    border-radius: 8px;
  }

  .style-preview {
    aspect-ratio: 4 / 5;
  }
}
