/* ════════════════════════════════════════════════════════
   暖心AI — 工具頁樣式
   ════════════════════════════════════════════════════════ */

.tool-body { background: #F7F6F3; }

/* ─── Tool Hero ─── */
.tool-hero {
  padding: 100px 24px 40px;
  background: linear-gradient(145deg, #1A1A2E 0%, #2D1B4E 60%, #1A1A2E 100%);
  text-align: center;
  position: relative;
  overflow: hidden;
}
.tool-hero::before {
  content: '';
  position: absolute;
  width: 500px; height: 500px;
  background: radial-gradient(circle, rgba(255,107,53,.25), transparent 70%);
  top: -200px; right: -100px;
  pointer-events: none;
}
.tool-hero-content { position: relative; z-index: 1; }
.tool-hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 16px;
  background: rgba(255,255,255,.1);
  border: 1px solid rgba(255,255,255,.2);
  border-radius: 20px;
  color: rgba(255,255,255,.85);
  font-size: .82rem;
  font-weight: 600;
  margin-bottom: 16px;
}
.tool-hero-title {
  font-family: 'Noto Serif TC', serif;
  font-size: clamp(1.8rem, 4vw, 2.6rem);
  font-weight: 700;
  color: #fff;
  margin-bottom: 12px;
}
.tool-hero-desc {
  font-size: 1rem;
  color: rgba(255,255,255,.7);
  line-height: 1.8;
  margin-bottom: 20px;
}
.tool-free-limit {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 8px 20px;
  background: rgba(255,255,255,.1);
  border-radius: 20px;
  color: rgba(255,255,255,.8);
  font-size: .88rem;
  flex-wrap: wrap;
  justify-content: center;
}
.tool-free-limit i { color: #FBBF24; }
.upgrade-link {
  color: #FBBF24;
  font-weight: 700;
  text-decoration: none;
  transition: opacity .2s;
}
.upgrade-link:hover { opacity: .8; text-decoration: underline; }

/* ─── Breadcrumb ─── */
.tool-breadcrumb {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: .85rem;
  color: var(--text-muted);
  flex: 1;
  padding: 0 24px;
}
.tool-breadcrumb a { color: var(--primary); font-weight: 500; }
.tool-breadcrumb a:hover { text-decoration: underline; }
.tool-breadcrumb .fa-chevron-right { font-size: .65rem; }
.tool-breadcrumb span { color: var(--text-secondary); font-weight: 600; }

/* ─── Tool Main Layout ─── */
.tool-main {
  max-width: 1160px;
  margin: 0 auto;
  padding: 40px 24px 60px;
}
.tool-layout {
  display: grid;
  grid-template-columns: 380px 1fr;
  gap: 32px;
  align-items: start;
}

/* ─── Controls Panel ─── */
.tool-controls {
  background: #fff;
  border-radius: 24px;
  border: 1px solid #EEE8E0;
  padding: 28px;
  display: flex;
  flex-direction: column;
  gap: 28px;
  box-shadow: 0 4px 20px rgba(26,26,46,.06);
  position: sticky;
  top: 88px;
}

.ctrl-section { display: flex; flex-direction: column; gap: 12px; }
.ctrl-step-label {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: .95rem;
  font-weight: 700;
  color: #1A1A2E;
}
.step-circle {
  width: 28px; height: 28px;
  background: linear-gradient(135deg, #FF6B35, #FF8C5A);
  color: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .8rem;
  font-weight: 800;
  flex-shrink: 0;
}

/* Upload Zone */
.upload-zone {
  border: 2px dashed #EEE8E0;
  border-radius: 16px;
  overflow: hidden;
  cursor: pointer;
  transition: all .3s;
  position: relative;
  background: #FAFAF8;
  min-height: 130px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.upload-zone:hover { border-color: #FF8C5A; background: #FFF8F0; }
.upload-placeholder { text-align: center; padding: 24px; }
.upload-icon { font-size: 2.5rem; margin-bottom: 8px; }
.upload-text { font-size: .9rem; font-weight: 600; color: #4A4A6A; margin-bottom: 4px; }
.upload-hint { font-size: .78rem; color: #8888AA; }
.upload-preview-img {
  width: 100%;
  height: 160px;
  object-fit: cover;
  display: block;
}
.upload-preview-img.hidden { display: none; }
.upload-remove {
  position: absolute;
  top: 8px; right: 8px;
  padding: 4px 10px;
  background: rgba(0,0,0,.6);
  color: #fff;
  border: none;
  border-radius: 12px;
  font-size: .75rem;
  cursor: pointer;
  transition: background .2s;
}
.upload-remove:hover { background: rgba(220,38,38,.8); }
.upload-remove.hidden { display: none; }

/* Name Presets */
.name-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.name-preset-btn {
  padding: 6px 14px;
  border: 1.5px solid #EEE8E0;
  border-radius: 20px;
  background: #FAFAF8;
  color: #4A4A6A;
  font-size: .85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all .2s;
}
.name-preset-btn:hover { border-color: #FF8C5A; color: #FF6B35; }
.name-preset-btn.active {
  background: linear-gradient(135deg, #FF6B35, #FF8C5A);
  border-color: transparent;
  color: #fff;
}

.ctrl-input {
  width: 100%;
  padding: 10px 16px;
  border: 1.5px solid #EEE8E0;
  border-radius: 12px;
  font-size: .9rem;
  font-family: 'Noto Sans TC', sans-serif;
  color: #1A1A2E;
  background: #FAFAF8;
  outline: none;
  transition: border-color .2s;
}
.ctrl-input:focus { border-color: #FF6B35; background: #fff; }

/* Template Grid */
.template-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}
.tpl-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 6px;
  border: 2px solid #EEE8E0;
  border-radius: 12px;
  background: #FAFAF8;
  cursor: pointer;
  transition: all .2s;
}
.tpl-btn:hover { border-color: #FF8C5A; transform: translateY(-2px); }
.tpl-btn.active {
  border-color: #FF6B35;
  background: #FFF8F0;
  box-shadow: 0 0 0 2px rgba(255,107,53,.2);
}
.tpl-btn-icon { font-size: 1.4rem; }
.tpl-btn-name { font-size: .72rem; font-weight: 600; color: #4A4A6A; }

/* Quote */
.quote-mode-row {
  display: flex;
  gap: 10px;
}
.radio-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border: 1.5px solid #EEE8E0;
  border-radius: 20px;
  cursor: pointer;
  font-size: .85rem;
  font-weight: 500;
  color: #4A4A6A;
  transition: all .2s;
}
.radio-pill input { display: none; }
.radio-pill:has(input:checked) {
  border-color: #FF6B35;
  background: #FFF3EC;
  color: #FF6B35;
  font-weight: 700;
}
.ctrl-textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid #EEE8E0;
  border-radius: 12px;
  font-size: .88rem;
  font-family: 'Noto Sans TC', sans-serif;
  color: #1A1A2E;
  background: #FAFAF8;
  resize: vertical;
  min-height: 70px;
  outline: none;
  transition: border-color .2s;
}
.ctrl-textarea:focus { border-color: #FF6B35; }
.ctrl-textarea.hidden { display: none; }

.quote-preview-wrap {
  background: #FFF8F0;
  border: 1px solid #FFD4B8;
  border-radius: 12px;
  padding: 12px 14px;
}
.quote-preview-label { font-size: .75rem; color: #8888AA; margin-bottom: 4px; }
.quote-preview-text {
  font-size: .88rem;
  color: #1A1A2E;
  line-height: 1.6;
  font-style: italic;
  margin-bottom: 10px;
}
.refresh-quote-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  background: #fff;
  border: 1px solid #FFD4B8;
  border-radius: 10px;
  color: #FF6B35;
  font-size: .8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all .2s;
}
.refresh-quote-btn:hover { background: #FF6B35; color: #fff; border-color: #FF6B35; }

/* Options Toggles */
.options-list { display: flex; flex-direction: column; gap: 12px; }
.option-toggle {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
}
.option-toggle input { display: none; }
.toggle-track {
  width: 44px; height: 24px;
  background: #DDD;
  border-radius: 24px;
  position: relative;
  transition: background .2s;
  flex-shrink: 0;
}
.toggle-track::before {
  content: '';
  position: absolute;
  width: 18px; height: 18px;
  background: #fff;
  border-radius: 50%;
  top: 3px; left: 3px;
  transition: transform .2s;
  box-shadow: 0 1px 4px rgba(0,0,0,.2);
}
.option-toggle input:checked + .toggle-track { background: #FF6B35; }
.option-toggle input:checked + .toggle-track::before { transform: translateX(20px); }
.opt-label { font-size: .9rem; color: #4A4A6A; font-weight: 500; }

/* Generate Button */
.generate-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 18px 24px;
  background: linear-gradient(135deg, #FF6B35, #FF8C5A);
  color: #fff;
  font-size: 1.05rem;
  font-weight: 700;
  border: none;
  border-radius: 16px;
  cursor: pointer;
  box-shadow: 0 6px 24px rgba(255,107,53,.40);
  transition: all .3s;
  font-family: 'Noto Sans TC', sans-serif;
}
.generate-btn:hover { transform: translateY(-3px); box-shadow: 0 12px 36px rgba(255,107,53,.50); }
.generate-btn:active { transform: translateY(0); }
.generate-btn.loading { opacity: .7; pointer-events: none; }

/* ─── Preview Area ─── */
.tool-preview-area {
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.preview-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.preview-label { font-size: .9rem; font-weight: 700; color: #1A1A2E; }
.preview-size-btns { display: flex; gap: 8px; }
.size-btn {
  padding: 6px 16px;
  border: 1.5px solid #EEE8E0;
  border-radius: 20px;
  background: #fff;
  font-size: .82rem;
  font-weight: 600;
  color: #8888AA;
  cursor: pointer;
  transition: all .2s;
}
.size-btn.active { border-color: #FF6B35; color: #FF6B35; background: #FFF3EC; }

.canvas-wrapper {
  background: #fff;
  border-radius: 24px;
  border: 1px solid #EEE8E0;
  overflow: hidden;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  box-shadow: 0 4px 20px rgba(26,26,46,.06);
  min-height: 400px;
}
#card-canvas {
  max-width: 100%;
  border-radius: 16px;
  box-shadow: 0 8px 30px rgba(0,0,0,.12);
  display: block;
}

.canvas-loading {
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,.9);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  border-radius: 24px;
  font-size: .95rem;
  font-weight: 600;
  color: #FF6B35;
  backdrop-filter: blur(4px);
}
.canvas-loading.hidden { display: none; }
.loading-spinner {
  width: 44px; height: 44px;
  border: 3px solid #FFE0CC;
  border-top-color: #FF6B35;
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.preview-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}
.action-btn {
  flex: 1;
  min-width: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 13px 20px;
  border-radius: 14px;
  font-size: .9rem;
  font-weight: 700;
  cursor: pointer;
  border: none;
  transition: all .2s;
  font-family: 'Noto Sans TC', sans-serif;
}
.action-refresh {
  background: #F7F6F3;
  color: #4A4A6A;
  border: 1.5px solid #EEE8E0;
}
.action-refresh:hover { background: #EEE; }
.action-download {
  background: linear-gradient(135deg, #1A1A2E, #2D2D50);
  color: #fff;
  box-shadow: 0 4px 16px rgba(26,26,46,.25);
}
.action-download:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(26,26,46,.3); }
.action-share {
  background: linear-gradient(135deg, #00B900, #00D300);
  color: #fff;
  box-shadow: 0 4px 16px rgba(0,185,0,.25);
}
.action-share:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(0,185,0,.35); }

.watermark-notice {
  padding: 10px 16px;
  background: #FFFBEB;
  border: 1px solid #FDE68A;
  border-radius: 10px;
  font-size: .82rem;
  color: #92400E;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.watermark-notice a { color: #FF6B35; font-weight: 700; }

/* Share Tips */
.share-tips {
  background: #fff;
  border-radius: 16px;
  border: 1px solid #EEE8E0;
  padding: 20px;
}
.share-tip-title {
  font-size: .88rem;
  font-weight: 700;
  color: #1A1A2E;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.share-tip-title i { color: #FBBF24; }
.share-tip-items { display: flex; flex-direction: column; gap: 10px; }
.share-tip-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: .85rem;
  color: #4A4A6A;
  line-height: 1.5;
}
.tip-icon { flex-shrink: 0; }

/* ─── Other Tools ─── */
.other-tools-section {
  background: #fff;
  padding: 60px 0;
  border-top: 1px solid #EEE8E0;
}
.other-tools-title {
  text-align: center;
  font-family: 'Noto Serif TC', serif;
  font-size: 1.4rem;
  font-weight: 700;
  color: #1A1A2E;
  margin-bottom: 28px;
}
.other-tools-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  max-width: 900px;
  margin: 0 auto;
  padding: 0 24px;
}
.other-tool-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  background: #FAFAF8;
  border: 1.5px solid #EEE8E0;
  border-radius: 16px;
  text-decoration: none;
  transition: all .2s;
}
.other-tool-card:hover {
  border-color: #FF8C5A;
  background: #FFF8F0;
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(255,107,53,.1);
}
.otc-icon { font-size: 1.6rem; flex-shrink: 0; }
.otc-name { flex: 1; font-size: .88rem; font-weight: 600; color: #1A1A2E; }
.otc-arrow { color: #FF6B35; font-size: .75rem; }

/* ─── Tool Footer ─── */
.tool-footer {
  background: #1A1A2E;
  padding: 24px;
  text-align: center;
  font-size: .85rem;
  color: rgba(255,255,255,.4);
}
.tool-footer a { color: rgba(255,255,255,.6); transition: color .2s; }
.tool-footer a:hover { color: #FF8C5A; }

/* ─── Responsive ─── */
@media (max-width: 900px) {
  .tool-layout {
    grid-template-columns: 1fr;
  }
  .tool-controls {
    position: static;
  }
  .other-tools-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .tool-main {
    padding: 28px 16px 48px;
  }
  .tool-hero {
    padding: 80px 16px 36px;
  }
  .tool-hero-title {
    font-size: clamp(1.5rem, 6vw, 2rem);
  }
  .tool-hero-desc {
    font-size: .92rem;
  }
  .tool-free-limit {
    font-size: .82rem;
    padding: 8px 14px;
    gap: 8px;
  }
}

@media (max-width: 640px) {
  /* ─ Hero ─ */
  .tool-hero { padding: 76px 14px 32px; }
  .tool-hero-title { font-size: 1.55rem; }
  .tool-hero-desc { font-size: .88rem; line-height: 1.7; }
  .tool-hero-badge { font-size: .76rem; padding: 5px 12px; }

  /* ─ Controls ─ */
  .tool-controls {
    padding: 20px 16px;
    gap: 22px;
    border-radius: 18px;
  }
  .ctrl-step-label { font-size: .88rem; }
  .step-circle { width: 24px; height: 24px; font-size: .72rem; }

  /* ─ Template grid: 4列在小螢幕保持，但按鈕更小 ─ */
  .template-grid { grid-template-columns: repeat(4, 1fr); gap: 6px; }
  .tpl-btn { padding: 8px 4px; border-radius: 10px; }
  .tpl-btn-icon { font-size: 1.2rem; }
  .tpl-btn-name { font-size: .65rem; }

  /* ─ Name presets ─ */
  .name-preset-btn { padding: 5px 10px; font-size: .8rem; }

  /* ─ Quote ─ */
  .quote-preview-wrap { padding: 10px 12px; }
  .quote-preview-text { font-size: .84rem; }

  /* ─ Generate btn ─ */
  .generate-btn { padding: 16px 20px; font-size: .98rem; border-radius: 14px; }

  /* ─ Canvas / Preview ─ */
  .canvas-wrapper { padding: 12px; min-height: 300px; border-radius: 18px; }
  #card-canvas { border-radius: 12px; }

  /* ─ Action buttons: 分兩行 ─ */
  .preview-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }
  .action-btn {
    flex: none;
    min-width: 0;
    padding: 12px 10px;
    font-size: .82rem;
    border-radius: 12px;
  }
  /* 第一個按鈕（重新生成）跨兩列 */
  .preview-actions .action-refresh {
    grid-column: 1 / -1;
  }

  /* ─ Watermark notice ─ */
  .watermark-notice { font-size: .78rem; padding: 8px 12px; }

  /* ─ Share tips ─ */
  .share-tips { padding: 16px; }
  .share-tip-item { font-size: .8rem; }

  /* ─ Other tools ─ */
  .other-tools-section { padding: 44px 0; }
  .other-tools-grid {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    padding: 0 14px;
  }
  .other-tool-card { padding: 12px 14px; border-radius: 12px; }
  .otc-icon { font-size: 1.3rem; }
  .otc-name { font-size: .8rem; }
}

@media (max-width: 400px) {
  /* 超小螢幕 (iPhone SE 等) */
  .tool-hero { padding: 72px 12px 28px; }
  .tool-main { padding: 20px 12px 40px; }
  .tool-controls { padding: 16px 14px; gap: 18px; }
  .template-grid { grid-template-columns: repeat(4, 1fr); gap: 5px; }
  .tpl-btn-name { display: none; }   /* 超小螢幕隱藏文字，只留 emoji */
  .generate-btn { padding: 14px 16px; font-size: .92rem; }
  .other-tools-grid { grid-template-columns: 1fr; }
  .name-presets { gap: 6px; }
  .name-preset-btn { padding: 5px 8px; font-size: .78rem; }
}
