:root {
  --bg: #f5f6fa;
  --surface: #ffffff;
  --border: #e2e5ee;
  --text: #1f2430;
  --text-muted: #6b7280;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --accent: #0ea5e9;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.06), 0 8px 24px rgba(0, 0, 0, 0.05);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang TC",
    "Microsoft JhengHei", "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
}

.container {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 20px;
}

.site-header {
  background: linear-gradient(135deg, #1e3a8a 0%, #2563eb 60%, #0ea5e9 100%);
  color: #fff;
  padding: 40px 0 32px;
}

.site-header h1 {
  margin: 0 0 8px;
  font-size: 1.9rem;
}

.subtitle {
  margin: 0;
  opacity: 0.92;
  font-size: 0.98rem;
}

.step {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  margin: 24px 0;
}

.step h2 {
  margin: 0 0 18px;
  font-size: 1.25rem;
  display: flex;
  align-items: center;
  gap: 10px;
}

.step-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-size: 1rem;
  flex-shrink: 0;
}

.hidden {
  display: none !important;
}

/* Upload */
.upload-zone {
  border: 2px dashed #b9c1d4;
  border-radius: var(--radius);
  padding: 48px 24px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  outline: none;
}

.upload-zone:hover,
.upload-zone:focus-visible,
.upload-zone.dragover {
  border-color: var(--primary);
  background: #eef4ff;
}

.upload-icon {
  font-size: 2.4rem;
  margin: 0 0 8px;
}

.hint {
  color: var(--text-muted);
  font-size: 0.88rem;
  margin: 6px 0 0;
}

.privacy-note {
  margin-top: 16px;
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
  color: #065f46;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 0.9rem;
}

/* Editor */
.editor-layout {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 24px;
}

.canvas-wrap {
  position: relative;
  background: #111318;
  border-radius: var(--radius);
  overflow: hidden;
  min-height: 420px;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: none;
}

#crop-canvas {
  display: block;
  max-width: 100%;
  cursor: grab;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

#crop-canvas:active {
  cursor: grabbing;
}

.controls {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.control-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.control-group label {
  font-size: 0.9rem;
  font-weight: 600;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--primary);
}

select,
input[type="number"] {
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  font-size: 0.92rem;
  background: #fff;
}

#custom-size-inputs {
  display: flex;
  gap: 10px;
  margin-top: 8px;
}

#custom-size-inputs label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.85rem;
  font-weight: 400;
}

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 16px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s, border-color 0.15s;
}

.btn:hover {
  background: #f3f4f6;
}

.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.btn-primary:hover {
  background: var(--primary-hover);
}

.btn-sm {
  padding: 7px 12px;
  font-size: 0.85rem;
}

.checkbox-label {
  display: flex !important;
  align-items: center;
  gap: 8px;
  font-weight: 400 !important;
  font-size: 0.9rem !important;
}

/* Results */
.result-single {
  display: flex;
  gap: 24px;
  align-items: flex-start;
  flex-wrap: wrap;
}

.result-frame {
  background: #f3f4f6;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  display: inline-block;
}

.result-frame img {
  display: block;
  max-width: 100%;
  height: auto;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
}

#single-result-img {
  width: 240px;
}

.result-meta {
  flex: 1;
  min-width: 240px;
}

.sheet-layout {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 24px;
  align-items: start;
}

.sheet-frame {
  background: #f3f4f6;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  justify-content: center;
}

.sheet-frame img {
  display: block;
  max-width: 100%;
  height: auto;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.15);
}

/* Info / explanation */
.info-block {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px 24px;
  margin: 24px 0;
}

.info-block h2 {
  margin: 0 0 16px;
  font-size: 1.3rem;
  line-height: 1.4;
}

.info-hero {
  display: grid;
  grid-template-columns: 1fr 1.2fr;
  gap: 28px;
  align-items: center;
}

.eyebrow {
  display: inline-block;
  margin: 0 0 10px;
  padding: 4px 12px;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--primary);
  background: #eef4ff;
  border: 1px solid #dbe6ff;
  border-radius: 999px;
}

.info-text p {
  margin: 0 0 14px;
  color: #4b5563;
  font-size: 0.97rem;
}

.info-text p:last-child {
  margin-bottom: 0;
}

.info-text .btn-row {
  margin-top: 18px;
}

.info-text .privacy-note {
  margin-top: 2px;
  color: #065f46;
  background: #ecfdf5;
  border-color: #a7f3d0;
}

.info-figure {
  margin: 0;
}

.info-figure > img {
  display: block;
  width: 100%;
  height: auto;
  border: 1px solid var(--border);
  border-radius: 10px;
}

/* Flow diagram (upload → adjust → single → sheet) */
.info-figure {
  margin: 0;
  background: linear-gradient(135deg, #eef4ff 0%, #dff5ff 100%);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 22px 14px 14px;
}

.flow-steps {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 14px 10px;
}

.flow-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.flow-thumb {
  position: relative;
  width: 150px;
  border-radius: 10px;
  overflow: hidden;
  background: #fff;
  border: 2px solid #fff;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.16);
}

.flow-thumb img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 50% 18%;
  aspect-ratio: 3 / 4;
}

.flow-thumb-id {
  width: 128px;
}

.flow-thumb-id img {
  aspect-ratio: 35 / 45;
}

.flow-guides {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.flow-arrow {
  color: #64748b;
  font-size: 1.3rem;
  font-weight: 700;
  line-height: 1;
  margin-bottom: 26px;
}

.flow-label {
  margin: 0;
  font-size: 0.86rem;
  font-weight: 600;
  color: #334155;
  text-align: center;
}

.mini-sheet {
  position: relative;
  width: 210px;
  aspect-ratio: 6 / 4;
  background: #fff;
  border: 2px solid #fff;
  border-radius: 6px;
  padding: 7px;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.16);
}

.mini-sheet-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 3px;
  width: 100%;
  height: 100%;
}

.mini-sheet-grid img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 50% 15%;
  border-radius: 1px;
}

.mini-sheet-badge {
  position: absolute;
  top: -8px;
  right: -8px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #10b981;
  border: 2px solid #fff;
  color: #fff;
  font-size: 0.85rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.flow-caption {
  margin: 14px 0 0;
  font-size: 0.8rem;
  color: var(--text-muted);
  text-align: center;
}

.steps-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.step-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 18px 16px;
}

.step-card h3 {
  margin: 0;
  font-size: 1.02rem;
}

.step-card p {
  margin: 0;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.feature-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 18px 24px;
}

.feature-item {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.feature-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  flex-shrink: 0;
  font-size: 1.3rem;
  background: #eef4ff;
  border: 1px solid var(--border);
  border-radius: 10px;
}

.feature-item h3 {
  margin: 0 0 4px;
  font-size: 0.98rem;
}

.feature-item p {
  margin: 0;
  font-size: 0.89rem;
  color: var(--text-muted);
}

.faq-list details {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 10px;
  overflow: hidden;
}

.faq-list summary {
  position: relative;
  padding: 14px 44px 14px 16px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  list-style: none;
}

.faq-list summary::-webkit-details-marker {
  display: none;
}

.faq-list summary::after {
  content: "+";
  position: absolute;
  right: 16px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--primary);
  font-size: 1.2rem;
  line-height: 1;
}

.faq-list details[open] summary::after {
  content: "–";
}

.faq-list summary:hover {
  background: #f8fafc;
}

.faq-list details p {
  margin: 0;
  padding: 0 16px 16px;
  color: var(--text-muted);
  font-size: 0.92rem;
}

/* How-to list (numbered steps with visuals) */
.section-lead {
  margin: -8px 0 20px;
  color: var(--text-muted);
  font-size: 0.95rem;
}

.howto-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-auto-rows: 1fr;
  gap: 20px;
}

.how-row {
  display: flex;
  align-items: center;
  gap: 26px;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 22px 26px;
}

.how-row-reverse {
  flex-direction: row-reverse;
}

/* 步驟 5「相紙排版」：欄位更寬，縮圖放到 ~410px */
.how-row-wide .how-visual {
  flex-basis: 420px;
}

.how-visual {
  flex: 0 0 330px;
  height: 340px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
}

.how-text {
  flex: 1;
  min-width: 0;
}

.how-text h3 {
  margin: 0 0 6px;
  font-size: 1.15rem;
  display: flex;
  align-items: center;
  gap: 10px;
}

.how-text p {
  margin: 0;
  color: var(--text-muted);
  font-size: 1rem;
}

.how-thumb {
  width: min(255px, 100%);
}

.how-thumb-id {
  width: 240px;
  max-width: 100%;
}

/* 教學區塊的相紙縮圖：放到 ~410px（hero 流程圖維持原尺寸） */
.how-visual .mini-sheet {
  width: min(410px, 100%);
}

.how-result {
  padding: 14px;
  width: max-content;
  max-width: 100%;
}

/* Small CSS mocks for step visuals */
.mock-upload {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 2px dashed #b9c1d4;
  border-radius: 10px;
  background: #fff;
  padding: 24px 14px;
  font-size: 0.85rem;
  color: #4b5563;
  text-align: center;
}

.mock-upload-icon {
  font-size: 2rem;
}

.mock-upload-hint {
  color: #9ca3af;
  font-size: 0.72rem;
}

.mock-controls {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: space-evenly;
}

.mock-select {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
  font-size: 0.85rem;
  color: var(--text);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.mock-select-caret {
  color: #6b7280;
}

.mock-slider {
  width: 100%;
  height: 10px;
  border-radius: 999px;
  background: #e2e8f0;
  overflow: hidden;
}

.mock-slider span {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: var(--primary);
}

/* Use-case chips */
.usecase-chips {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.usecase-chips li {
  background: #eef4ff;
  border: 1px solid #dbe6ff;
  color: var(--primary);
  font-size: 0.9rem;
  font-weight: 600;
  border-radius: 999px;
  padding: 8px 16px;
}

/* Footer */
.site-footer {
  padding: 32px 0 48px;
  color: var(--text-muted);
  font-size: 0.85rem;
  text-align: center;
}

/* Responsive */
@media (max-width: 860px) {
  .editor-layout,
  .sheet-layout,
  .info-hero,
  .steps-grid,
  .feature-grid {
    grid-template-columns: 1fr;
  }

  .info-block {
    padding: 22px 18px;
  }

  .how-row,
  .how-row-reverse {
    flex-direction: column;
    align-items: flex-start;
    gap: 14px;
  }

  .how-visual,
  .how-row-wide .how-visual {
    flex-basis: auto;
    width: 100%;
  }

  .controls {
    max-width: none;
  }
}

/* AI 修圖 prompt 區塊 */
.prompt-box {
  margin: 14px 0 8px;
}

.prompt-box pre {
  margin: 0 0 10px;
  padding: 14px 16px;
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  font-size: 0.92rem;
  line-height: 1.7;
  white-space: pre-wrap;
  word-break: break-word;
  color: #334155;
  font-family: inherit;
}

html.dark .prompt-box pre {
  background: #1e293b;
  border-color: #334155;
  color: #cbd5e1;
}
