/* 全家貼圖工坊 — 樣式表
   風格：可愛、溫暖、大按鈕大字，行動優先（375px 為主要目標） */

:root {
  --color-bg: #fff8f2;
  --color-card: #ffffff;
  --color-primary: #ff9270;
  --color-primary-dark: #ef7a56;
  --color-secondary: #ffd166;
  --color-accent: #8fd3c7;
  --color-text: #4a3b34;
  --color-text-soft: #8a7a70;
  --color-border: #ffe1cf;
  --color-danger: #e2574c;
  --radius-lg: 24px;
  --radius-md: 16px;
  --radius-sm: 10px;
  --shadow-soft: 0 6px 18px rgba(200, 130, 90, 0.15);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: "jf-openhuninn", "Helvetica Neue", "PingFang TC",
    "Microsoft JhengHei", sans-serif;
  -webkit-tap-highlight-color: transparent;
}

body {
  padding-bottom: 40px;
}

.app-shell {
  max-width: 480px;
  margin: 0 auto;
  padding: 16px;
}

/* ---------- Header ---------- */

.app-header {
  text-align: center;
  padding: 20px 8px 12px;
}

.app-header h1 {
  font-size: 26px;
  margin: 0 0 4px;
  color: var(--color-primary-dark);
}

.app-header p {
  margin: 0;
  color: var(--color-text-soft);
  font-size: 15px;
}

/* ---------- Step indicator ---------- */

.step-indicator {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin: 12px 0 20px;
}

.step-dot {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--color-card);
  border: 2px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  color: var(--color-text-soft);
  font-size: 16px;
}

.step-dot.active {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: #fff;
}

.step-dot.done {
  background: var(--color-accent);
  border-color: var(--color-accent);
  color: #fff;
}

/* ---------- Cards / steps ---------- */

.step-panel {
  background: var(--color-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-soft);
  padding: 20px 16px;
  margin-bottom: 20px;
  display: none;
}

.step-panel.active {
  display: block;
}

.step-title {
  font-size: 20px;
  font-weight: bold;
  margin: 0 0 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.step-title .num {
  background: var(--color-secondary);
  color: #6b4a12;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
}

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 16px 18px;
  font-size: 19px;
  font-weight: bold;
  border-radius: var(--radius-md);
  border: none;
  cursor: pointer;
  margin: 6px 0;
  transition: transform 0.08s ease, opacity 0.15s ease;
  touch-action: manipulation;
}

.btn:active {
  transform: scale(0.97);
}

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

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

.btn-secondary {
  background: var(--color-accent);
  color: #1c4a41;
}

.btn-outline {
  background: #fff;
  color: var(--color-primary-dark);
  border: 2px solid var(--color-primary);
}

.btn-ghost {
  background: transparent;
  color: var(--color-text-soft);
  border: 2px dashed var(--color-border);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

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

.btn-row .btn {
  flex: 1;
}

.btn-small {
  width: auto;
  padding: 10px 16px;
  font-size: 16px;
}

/* ---------- File input / photo preview ---------- */

.file-drop {
  display: block;
  border: 3px dashed var(--color-border);
  border-radius: var(--radius-lg);
  padding: 28px 14px;
  text-align: center;
  color: var(--color-text-soft);
  font-size: 17px;
  cursor: pointer;
  background: #fffaf6;
}

.file-drop input[type="file"] {
  display: none;
}

.photo-preview-wrap {
  text-align: center;
  margin: 14px 0;
}

.photo-preview-wrap img,
.photo-preview-wrap canvas {
  max-width: 100%;
  max-height: 320px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-soft);
  background: repeating-conic-gradient(#eee 0% 25%, #fff 0% 50%) 50% / 20px
    20px;
}

/* ---------- Toggle switch ---------- */

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #fff6ee;
  border-radius: var(--radius-md);
  padding: 12px 14px;
  margin: 10px 0;
  font-size: 17px;
}

.switch {
  position: relative;
  display: inline-block;
  width: 52px;
  height: 30px;
  flex-shrink: 0;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.switch-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background-color: #ddd0c6;
  border-radius: 30px;
  transition: 0.2s;
}

.switch-slider::before {
  position: absolute;
  content: "";
  height: 24px;
  width: 24px;
  left: 3px;
  top: 3px;
  background-color: white;
  border-radius: 50%;
  transition: 0.2s;
}

.switch input:checked + .switch-slider {
  background-color: var(--color-primary);
}

.switch input:checked + .switch-slider::before {
  transform: translateX(22px);
}

/* ---------- Segmentation status ---------- */

.status-line {
  text-align: center;
  font-size: 15px;
  color: var(--color-text-soft);
  min-height: 20px;
  margin: 8px 0;
}

.spinner {
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 3px solid var(--color-border);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  vertical-align: middle;
  margin-right: 6px;
}

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

.notice-box {
  background: #fff3e0;
  border: 2px solid var(--color-secondary);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  font-size: 15px;
  color: #6b4a12;
  margin: 10px 0;
}

/* ---------- Word picker ---------- */

.tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.tab-btn {
  padding: 8px 16px;
  border-radius: 999px;
  border: 2px solid var(--color-border);
  background: #fff;
  color: var(--color-text-soft);
  font-size: 15px;
  font-weight: bold;
  cursor: pointer;
}

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

.word-chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.word-chip {
  padding: 10px 14px;
  border-radius: 999px;
  background: #fff6ee;
  border: 2px solid var(--color-border);
  font-size: 16px;
  cursor: pointer;
  color: var(--color-text);
}

.word-chip.selected {
  background: var(--color-secondary);
  border-color: var(--color-secondary);
  color: #6b4a12;
}

.custom-text-row {
  display: flex;
  gap: 8px;
  margin: 10px 0;
}

.custom-text-row input[type="text"] {
  flex: 1;
  padding: 12px 14px;
  font-size: 17px;
  border-radius: var(--radius-sm);
  border: 2px solid var(--color-border);
}

.field-label {
  font-size: 15px;
  font-weight: bold;
  color: var(--color-text-soft);
  margin: 14px 0 8px;
}

.style-swatch-row,
.size-swatch-row {
  display: flex;
  gap: 10px;
  margin-bottom: 10px;
}

.style-swatch {
  flex: 1;
  border-radius: var(--radius-md);
  border: 3px solid var(--color-border);
  padding: 10px 4px;
  text-align: center;
  font-size: 15px;
  cursor: pointer;
  background: #fff;
}

.style-swatch.selected {
  border-color: var(--color-primary);
  background: #fff1ea;
}

.style-preview-canvas {
  display: block;
  width: 100%;
  height: 56px;
  margin-bottom: 4px;
}

.size-swatch {
  flex: 1;
  border-radius: var(--radius-md);
  border: 3px solid var(--color-border);
  padding: 10px 4px;
  text-align: center;
  font-size: 15px;
  cursor: pointer;
  background: #fff;
}

.size-swatch.selected {
  border-color: var(--color-primary);
  background: #fff1ea;
}

/* ---------- Editor canvas (drag text) ---------- */

.editor-canvas-wrap {
  text-align: center;
  margin: 14px 0;
  touch-action: none;
}

.editor-canvas-wrap canvas {
  max-width: 100%;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-soft);
  background: repeating-conic-gradient(#eee 0% 25%, #fff 0% 50%) 50% / 20px
    20px;
  touch-action: none;
  cursor: grab;
}

.hint-text {
  text-align: center;
  font-size: 14px;
  color: var(--color-text-soft);
  margin: 4px 0 14px;
}

/* ---------- Sticker list (step 4) ---------- */

.sticker-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 12px;
  margin: 14px 0;
}

.sticker-card {
  background: #fff6ee;
  border-radius: var(--radius-md);
  padding: 8px;
  text-align: center;
}

.sticker-card img {
  width: 100%;
  border-radius: var(--radius-sm);
  background: repeating-conic-gradient(#eee 0% 25%, #fff 0% 50%) 50% / 12px
    12px;
}

.sticker-card .sticker-name {
  font-size: 13px;
  color: var(--color-text-soft);
  margin: 4px 0;
}

.sticker-card .btn {
  font-size: 14px;
  padding: 8px 10px;
}

.output-hint {
  background: #eafaf3;
  border: 2px solid var(--color-accent);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  font-size: 16px;
  text-align: center;
  color: #1c4a41;
  margin: 14px 0;
  font-weight: bold;
}

/* ---------- Footer ---------- */

.app-footer {
  text-align: center;
  color: var(--color-text-soft);
  font-size: 13px;
  padding: 20px 12px 8px;
  line-height: 1.6;
}

/* ---------- Responsive tweaks ---------- */

@media (min-width: 600px) {
  .app-shell {
    padding: 24px;
  }
}

@media (min-width: 900px) {
  .app-shell {
    max-width: 560px;
  }
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

/* ---------- 首頁 / 回首頁按鈕 ---------- */

.app-header {
  position: relative;
}

.home-fab {
  position: absolute;
  left: 4px;
  top: 12px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  background: #fff;
  box-shadow: var(--shadow-soft);
  font-size: 20px;
  cursor: pointer;
}

.home-choice-btn {
  font-size: 22px;
  padding: 22px 18px;
}

/* ---------- 口頭禪包：句子清單 ---------- */

.phrase-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: #fff6ee;
  border: 2px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  margin-bottom: 8px;
  font-size: 17px;
}

.phrase-row .phrase-source {
  font-size: 12px;
  color: var(--color-text-soft);
  margin-left: 8px;
}

.phrase-row .phrase-delete {
  border: none;
  background: #ffe3d9;
  color: var(--color-danger);
  border-radius: 50%;
  width: 32px;
  height: 32px;
  font-size: 16px;
  cursor: pointer;
  flex-shrink: 0;
}

.phrase-textarea {
  width: 100%;
  padding: 12px 14px;
  font-size: 16px;
  border-radius: var(--radius-sm);
  border: 2px solid var(--color-border);
  font-family: inherit;
  margin: 8px 0;
  resize: vertical;
}

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