:root {
  --bg: #fdf5f6;
  --panel: rgba(255, 252, 253, 0.94);
  --panel-strong: #ffffff;
  --text: #4a3b40;
  --muted: #967d87;
  --line: rgba(186, 153, 166, 0.2);
  --accent: #d88fa4;
  --accent-strong: #bf6d86;
  --accent-soft: #f9e6eb;
  --shadow: 0 18px 50px rgba(105, 60, 77, 0.08);
  --radius-xl: 28px;
  --radius-lg: 20px;
  --radius-md: 14px;
}

::selection {
  background: #d291bc;
  color: #ffffff;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font-family: "Noto Serif TC", "PMingLiU", serif;
  background:
    radial-gradient(circle at top left, rgba(255, 214, 226, 0.85), transparent 32%),
    radial-gradient(circle at bottom right, rgba(235, 195, 212, 0.55), transparent 30%),
    linear-gradient(160deg, #fdf5f6 0%, #f6e8ec 52%, #eed7e0 100%);
}

* {
  box-sizing: border-box;
}

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

input,
select,
textarea {
  width: 100%;
  padding: 14px 16px;
  margin-top: 10px;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.92);
  color: var(--text);
  font: inherit;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

input:focus,
select:focus,
textarea:focus {
  border-color: rgba(216, 143, 164, 0.6);
  box-shadow: 0 0 0 4px rgba(216, 143, 164, 0.12);
}

textarea {
  min-height: 120px;
  resize: vertical;
}

button {
  border: none;
  cursor: pointer;
  font: inherit;
}

img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  display: block;
  border-radius: 18px;
  border: 1px solid rgba(186, 153, 166, 0.15);
  background: linear-gradient(135deg, #eee3e6, #fdf5f6);
}

@keyframes skeleton-loading {
  0% {
    background-color: rgba(210, 145, 188, 0.15);
  }
  50% {
    background-color: rgba(210, 145, 188, 0.4);
  }
  100% {
    background-color: rgba(210, 145, 188, 0.15);
  }
}

.skeleton {
  animation: skeleton-loading 1.5s infinite ease-in-out;
  color: transparent !important;
  pointer-events: none;
  user-select: none;
}

.skeleton > * {
  visibility: hidden;
}

img.skeleton {
  background-image: none; /* override default linear-gradient */
}

.page {
  width: min(1120px, calc(100% - 24px));
  margin: 0 auto;
  padding: 20px 0 40px;
}

.hero {
  padding: 28px 20px 12px;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(255, 252, 253, 0.7);
  border: 1px solid rgba(186, 153, 166, 0.2);
  color: var(--muted);
  font-size: 13px;
  letter-spacing: 0.04em;
}

.eyebrow-icon {
  width: 20px;
  height: 20px;
  object-fit: contain;
  border: none;
  background: transparent;
  border-radius: 0;
}

.hero h1 {
  margin-top: 14px;
  font-size: clamp(32px, 7vw, 56px);
  line-height: 1.04;
  letter-spacing: -0.04em;
}

.hero p {
  margin-top: 14px;
  max-width: 640px;
  color: var(--muted);
  line-height: 1.7;
  font-size: 15px;
}

.layout {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 0 0 20px;
}

.panel {
  background: var(--panel);
  backdrop-filter: blur(18px);
  border: 1px solid rgba(186, 153, 166, 0.15);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
}

.controls {
  padding: 22px;
}

.section+.section {
  margin-top: 22px;
}

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

.section-header.toggle-header {
  cursor: pointer;
  user-select: none;
  align-items: center;
}

.toggle-icon {
  color: var(--muted);
  transition: transform 0.2s ease;
}

.section.collapsed .toggle-icon {
  transform: rotate(-90deg);
}

.section.collapsed .section-content {
  display: none;
}

.section-header h3 {
  font-size: 15px;
}

.section-header span,
.helper-text,
.status {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.upload-actions,
.provider-grid,
.config-grid,
.action-row,
.preset-grid {
  display: grid;
  gap: 12px;
}

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

.provider-grid,
.config-grid {
  grid-template-columns: 1fr;
}

.field.hidden {
  display: none;
}

.ghost-button,
.primary-button,
.preset-button {
  min-height: 48px;
  border-radius: 16px;
  transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

.ghost-button,
.preset-button {
  border: 1px solid rgba(186, 153, 166, 0.2);
  background: rgba(255, 255, 255, 0.76);
  color: var(--text);
}

.primary-button {
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-strong) 100%);
  color: white;
  padding: 15px 22px;
  font-size: 16px;
  font-weight: 700;
  box-shadow: 0 14px 28px rgba(159, 79, 36, 0.28);
}

.primary-button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none !important;
  box-shadow: none;
}

.ghost-button {
  padding: 14px 16px;
  font-weight: 600;
}

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

.preset-button {
  text-align: left;
  padding: 14px;
}

.preset-button strong,
.preset-button span {
  display: block;
}

.preset-button strong {
  font-size: 14px;
  margin-bottom: 4px;
}

.preset-button span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.preset-button.active {
  background: var(--accent-soft);
  border-color: rgba(216, 143, 164, 0.4);
  box-shadow: inset 0 0 0 1px rgba(216, 143, 164, 0.16);
}

.style-preview {
  margin-top: 12px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.6);
  border-radius: var(--radius-md);
  border: 1px solid rgba(186, 153, 166, 0.2);
  display: none;
}

.style-preview h4 {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 8px;
}

.style-preview img {
  width: 100%;
  height: auto;
  max-height: 240px;
  object-fit: cover;
  border-radius: 12px;
  border: 1px solid rgba(186, 153, 166, 0.15);
  background: transparent;
  cursor: zoom-in;
}

.ghost-button:hover,
.primary-button:hover,
.preset-button:hover {
  transform: translateY(-1px);
}

.results {
  padding: 18px;
  display: grid;
  gap: 16px;
}

.image-card {
  padding: 14px;
  border-radius: 22px;
  background: var(--panel-strong);
  border: 1px solid rgba(186, 153, 166, 0.15);
}

.image-card h2 {
  font-size: 16px;
  margin-bottom: 12px;
}

.placeholder {
  display: grid;
  place-items: center;
  min-height: 220px;
  text-align: center;
  color: var(--muted);
  padding: 24px;
  line-height: 1.7;
}

.hidden-input {
  display: none;
}

.camera-modal {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: #000;
  z-index: 20;
}

.camera-modal.open {
  display: flex;
}

.camera-panel {
  width: 100%;
  height: 100%;
  background: #000;
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.camera-header {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 20px;
  background: linear-gradient(to bottom, rgba(0, 0, 0, 0.6), transparent);
  z-index: 10;
  color: white;
}

.camera-header h3 {
  font-size: 18px;
}

.camera-close {
  width: 44px;
  height: 44px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.2);
  color: white;
  font-size: 24px;
  line-height: 1;
  backdrop-filter: blur(8px);
}

.camera-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #000;
  position: absolute;
  inset: 0;
  z-index: 1;
}

.camera-actions {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  padding: 32px 20px 48px;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.8), transparent);
  z-index: 10;
}

.camera-actions .ghost-button {
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: white;
  backdrop-filter: blur(10px);
}

.camera-actions .primary-button {
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.camera-canvas {
  display: none;
}

.status {
  margin-top: 12px;
  min-height: 20px;
}

/* 燈箱大圖功能 */
.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.9);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
  cursor: zoom-out;
  padding: 20px;
}

.lightbox.open {
  display: flex;
}

.lightbox img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border: none;
  box-shadow: 0 0 30px rgba(0,0,0,0.5);
  border-radius: 8px;
}

.image-card img {
  cursor: zoom-in;
}

.floating-mascot {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 50;
  pointer-events: none;
}

.floating-mascot img {
  width: 150px;
  height: auto;
  aspect-ratio: auto;
  border: none;
  background: transparent;
  border-radius: 0;
  filter: drop-shadow(0 12px 24px rgba(105, 60, 77, 0.2));
}

@media (min-width: 720px) {
  .page {
    width: min(1200px, calc(100% - 48px));
    padding-top: 28px;
  }

  .hero {
    padding: 24px 12px 18px;
  }

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

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

@media (min-width: 980px) {
  .layout {
    grid-template-columns: minmax(320px, 420px) minmax(0, 1fr);
    display: grid;
    align-items: start;
  }

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