/* ═══════════════════════════════════════════
   主題變數 — 5 種風格
═══════════════════════════════════════════ */

/* 1. 暖橘（預設） */
[data-theme="warm"], :root {
  --bg:      #FFFBF4;
  --primary: #FF8C69;
  --primary2:#FF6B45;
  --second:  #A8D8C8;
  --second2: #7EC8B0;
  --text:    #3D2B1F;
  --text2:   #6B4C3B;
  --accent:  #FFE0A3;
  --hi:      #FFD6CC;
  --card:    #FFFFFF;
  --border:  #FFE0A3;
  --shadow:  rgba(255,140,105,.18);
}

/* 2. 深海藍 */
[data-theme="ocean"] {
  --bg:      #F0F5FF;
  --primary: #4A7FDB;
  --primary2:#2E62C0;
  --second:  #6EC8D4;
  --second2: #4AAAB8;
  --text:    #1A2744;
  --text2:   #3A5080;
  --accent:  #C8DEFF;
  --hi:      #D4EDFF;
  --card:    #FFFFFF;
  --border:  #C8DEFF;
  --shadow:  rgba(74,127,219,.18);
}

/* 3. 薰衣草 */
[data-theme="lavender"] {
  --bg:      #FAF5FF;
  --primary: #9B6FD4;
  --primary2:#7C52B8;
  --second:  #F0A0C8;
  --second2: #D880A8;
  --text:    #2D1B4E;
  --text2:   #5A3880;
  --accent:  #E8D5FF;
  --hi:      #FFD6F0;
  --card:    #FFFFFF;
  --border:  #E8D5FF;
  --shadow:  rgba(155,111,212,.18);
}

/* 4. 抹茶 */
[data-theme="matcha"] {
  --bg:      #F4FFF6;
  --primary: #4FAD7A;
  --primary2:#389060;
  --second:  #D4B86A;
  --second2: #B89848;
  --text:    #1A3D28;
  --text2:   #3A6848;
  --accent:  #C8EDD8;
  --hi:      #FFF0C8;
  --card:    #FFFFFF;
  --border:  #C8EDD8;
  --shadow:  rgba(79,173,122,.18);
}

/* 5. 莓果 */
[data-theme="berry"] {
  --bg:      #FFF5F8;
  --primary: #E85480;
  --primary2:#C83060;
  --second:  #9B7FDB;
  --second2: #7C5EBE;
  --text:    #3D1B2B;
  --text2:   #703050;
  --accent:  #FFD0E0;
  --hi:      #E8D5FF;
  --card:    #FFFFFF;
  --border:  #FFD0E0;
  --shadow:  rgba(232,84,128,.18);
}

/* ═══════════════════════════════════════════
   Reset & Base
═══════════════════════════════════════════ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Nunito', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
  transition: background .4s, color .4s;
}

/* ── 背景裝飾泡泡 ── */
.bg-blobs { position: fixed; inset: 0; pointer-events: none; z-index: 0; }
.blob {
  position: absolute; border-radius: 50%; opacity: .15;
  animation: float 8s ease-in-out infinite;
  transition: background .4s;
}
.blob-1 { width:320px; height:320px; background:var(--primary); top:-80px; left:-80px; animation-delay:0s; }
.blob-2 { width:220px; height:220px; background:var(--second);  top:40%;  right:-60px; animation-delay:2s; }
.blob-3 { width:160px; height:160px; background:var(--accent);  bottom:10%; left:10%; animation-delay:4s; }
.blob-4 { width:120px; height:120px; background:var(--hi);      bottom:5%; right:20%; animation-delay:1s; }

@keyframes float {
  0%,100% { transform: translateY(0) scale(1); }
  50%      { transform: translateY(-20px) scale(1.05); }
}

/* ═══════════════════════════════════════════
   Header
═══════════════════════════════════════════ */
header {
  position: sticky; top: 0; z-index: 100;
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 40px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 2px dashed var(--border);
  transition: background .4s, border-color .4s;
}

.logo {
  display: flex; align-items: center; gap: 10px;
  font-size: 1.4rem; font-weight: 900; color: var(--text);
  text-decoration: none; white-space: nowrap;
}
.logo-icon {
  width: 40px; height: 40px;
  background: var(--primary); border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.3rem;
  transition: transform .3s, background .4s;
}
.logo:hover .logo-icon { transform: rotate(-15deg) scale(1.1); }

/* 桌面導覽 */
nav { display: flex; align-items: center; gap: 6px; }
nav a {
  text-decoration: none; color: var(--text2);
  font-weight: 700; font-size: .88rem;
  padding: 7px 14px; border-radius: 30px;
  transition: all .2s; white-space: nowrap;
}
nav a:hover  { background: var(--accent); color: var(--text); }
nav a.active { background: var(--primary); color: #fff; }

/* 登入按鈕 */
.btn-login {
  background: var(--primary); color: #fff;
  border: none; border-radius: 30px;
  padding: 8px 18px; font-size: .88rem; font-weight: 800;
  cursor: pointer; white-space: nowrap;
  transition: transform .2s, background .2s;
}
.btn-login:hover { background: var(--primary2); transform: scale(1.04); }

/* ── 主題切換器 ── */
.theme-switcher {
  display: flex; align-items: center; gap: 6px; margin-left: 10px;
}
.theme-dot {
  width: 20px; height: 20px; border-radius: 50%;
  border: 2.5px solid transparent;
  cursor: pointer;
  transition: transform .2s, border-color .2s;
  position: relative;
}
.theme-dot:hover           { transform: scale(1.25); }
.theme-dot.active          { border-color: var(--text); transform: scale(1.15); }
.theme-dot[data-t="warm"]    { background: #FF8C69; }
.theme-dot[data-t="ocean"]   { background: #4A7FDB; }
.theme-dot[data-t="lavender"]{ background: #9B6FD4; }
.theme-dot[data-t="matcha"]  { background: #4FAD7A; }
.theme-dot[data-t="berry"]   { background: #E85480; }

/* Tooltip */
.theme-dot::after {
  content: attr(data-label);
  position: absolute; bottom: 26px; left: 50%; transform: translateX(-50%);
  background: var(--text); color: var(--bg);
  font-size: .7rem; font-weight: 700; white-space: nowrap;
  padding: 3px 8px; border-radius: 8px;
  opacity: 0; pointer-events: none;
  transition: opacity .2s;
}
.theme-dot:hover::after { opacity: 1; }

/* ── 漢堡選單 ── */
.hamburger {
  display: none; flex-direction: column; gap: 5px;
  cursor: pointer; padding: 6px; border-radius: 10px;
  transition: background .2s;
}
.hamburger:hover { background: var(--accent); }
.hamburger span {
  display: block; width: 22px; height: 2.5px;
  background: var(--text); border-radius: 4px; transition: all .3s;
}
.hamburger.open span:nth-child(1) { transform: translateY(7.5px) rotate(45deg); }
.hamburger.open span:nth-child(2) { opacity: 0; }
.hamburger.open span:nth-child(3) { transform: translateY(-7.5px) rotate(-45deg); }

.mobile-menu {
  display: none; position: absolute; top: 100%; left: 0; right: 0;
  background: color-mix(in srgb, var(--bg) 97%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 2px dashed var(--border);
  flex-direction: column; padding: 10px 16px 16px; gap: 4px; z-index: 99;
}
.mobile-menu.open { display: flex; }
.mobile-menu a {
  text-decoration: none; color: var(--text2);
  font-weight: 700; font-size: 1rem;
  padding: 11px 16px; border-radius: 14px; transition: all .2s;
}
.mobile-menu a:hover, .mobile-menu a.active { background: var(--hi); color: var(--text); }
.mobile-menu .btn-login {
  margin-top: 4px; text-align: center; display: block;
  padding: 11px 16px; border-radius: 14px;
}
/* 手機版主題選擇器 */
.mobile-theme-row {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 16px 4px;
  font-size: .82rem; font-weight: 700; color: var(--text2);
}
.mobile-theme-row .theme-dot { width: 22px; height: 22px; }

/* ═══════════════════════════════════════════
   Hero
═══════════════════════════════════════════ */
.hero {
  position: relative; z-index: 5;
  text-align: center; padding: 64px 20px 48px;
}
.hero-badge {
  display: inline-block;
  background: var(--accent); color: var(--text);
  font-weight: 800; font-size: .84rem;
  padding: 5px 16px; border-radius: 30px; margin-bottom: 18px;
  animation: badge-bounce .6s ease-out;
}
@keyframes badge-bounce {
  0%   { transform: scale(.5); opacity: 0; }
  70%  { transform: scale(1.1); }
  100% { transform: scale(1);   opacity: 1; }
}
.hero h1 {
  font-size: clamp(1.9rem, 5vw, 3rem);
  font-weight: 900; line-height: 1.2; margin-bottom: 14px;
}
.hero h1 span { color: var(--primary); }
.hero p {
  font-size: 1.05rem; color: var(--text2);
  max-width: 460px; margin: 0 auto 32px; line-height: 1.7;
}
.hero-cups { display: flex; justify-content: center; gap: 14px; flex-wrap: wrap; margin-bottom: 36px; }
.hero-cup { font-size: 2.6rem; animation: cup-float 3s ease-in-out infinite; }
.hero-cup:nth-child(2) { animation-delay: .4s; }
.hero-cup:nth-child(3) { animation-delay: .8s; }
@keyframes cup-float {
  0%,100% { transform: translateY(0); }
  50%      { transform: translateY(-10px); }
}
.btn-start {
  background: var(--primary); color: #fff;
  border: none; border-radius: 50px;
  padding: 14px 36px; font-size: 1.05rem; font-weight: 800;
  cursor: pointer; transition: transform .2s, background .2s, box-shadow .2s;
  box-shadow: 0 4px 16px var(--shadow);
}
.btn-start:hover { background: var(--primary2); transform: scale(1.05) translateY(-2px); }

/* ═══════════════════════════════════════════
   步驟導覽
═══════════════════════════════════════════ */
.steps-bar {
  position: relative; z-index: 5;
  display: flex; justify-content: center; align-items: center;
  gap: 0; padding: 0 20px 32px; flex-wrap: nowrap;
}
.step-item {
  display: flex; align-items: center; gap: 8px;
  font-size: .88rem; font-weight: 700; color: var(--text2);
  transition: color .3s;
}
.step-item.active { color: var(--primary); }
.step-item.done   { color: var(--second2); }
.step-num {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--accent); color: var(--text);
  display: flex; align-items: center; justify-content: center;
  font-weight: 900; font-size: .88rem;
  transition: background .3s, color .3s;
}
.step-item.active .step-num { background: var(--primary); color: #fff; }
.step-item.done   .step-num { background: var(--second2); color: #fff; }
.step-line { width: 32px; height: 2px; background: var(--border); margin: 0 4px; flex-shrink: 0; }

/* ═══════════════════════════════════════════
   主要卡片容器
═══════════════════════════════════════════ */
.main-wrap {
  position: relative; z-index: 5;
  max-width: 860px; margin: 0 auto; padding: 0 20px 60px;
}

.card {
  background: var(--card);
  border-radius: 24px;
  padding: 32px;
  box-shadow: 0 4px 24px var(--shadow);
  margin-bottom: 24px;
  transition: background .4s, box-shadow .4s;
}
.card-title {
  font-size: 1.2rem; font-weight: 900; margin-bottom: 20px;
  display: flex; align-items: center; gap: 10px;
}
.card-title .icon {
  width: 36px; height: 36px; border-radius: 12px;
  background: var(--accent); color: var(--text);
  display: flex; align-items: center; justify-content: center; font-size: 1.1rem;
}

/* ═══════════════════════════════════════════
   杯型選擇
═══════════════════════════════════════════ */
.cup-scroll {
  display: flex; gap: 12px; overflow-x: auto; padding-bottom: 8px;
  scrollbar-width: thin; scrollbar-color: var(--border) transparent;
}
.cup-scroll::-webkit-scrollbar { height: 4px; }
.cup-scroll::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

.cup-btn {
  flex-shrink: 0;
  background: var(--bg); border: 2px solid var(--border);
  border-radius: 18px; padding: 14px 20px;
  cursor: pointer; text-align: center;
  transition: all .2s; min-width: 110px;
}
.cup-btn:hover  { border-color: var(--primary); transform: translateY(-3px); }
.cup-btn.active { border-color: var(--primary); background: var(--hi); }
.cup-btn .cup-emoji { font-size: 1.6rem; display: block; margin-bottom: 4px; }
.cup-btn .cup-name  { font-size: .82rem; font-weight: 700; color: var(--text2); }
.cup-btn.active .cup-name { color: var(--primary); }

/* 尺寸提示框 */
.spec-box {
  display: none; margin-top: 16px;
  background: var(--hi); border-radius: 14px;
  padding: 14px 18px;
  animation: slide-in .3s ease-out;
}
.spec-box.show { display: flex; flex-direction: column; gap: 6px; }
@keyframes slide-in {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.spec-row1 {
  display: flex; align-items: center; gap: 6px;
}
.spec-icon { font-size: 1rem; flex-shrink: 0; }
.spec-name {
  font-size: 1rem; font-weight: 900; color: var(--text);
}
.spec-row2 {
  display: flex; align-items: center; gap: 10px;
}
.spec-label {
  font-size: .82rem; font-weight: 700; color: var(--text2);
  white-space: nowrap;
}
.spec-badge {
  background: var(--primary); color: #fff;
  border-radius: 10px; padding: 5px 14px;
  font-size: .92rem; font-weight: 900; white-space: nowrap;
  letter-spacing: .03em;
}

/* ═══════════════════════════════════════════
   Stage 切換 Tabs
═══════════════════════════════════════════ */
.tab-row { display: flex; gap: 8px; margin-bottom: 20px; }
.tab-btn {
  flex: 1; padding: 10px; border-radius: 14px; border: 2px solid var(--border);
  background: var(--bg); font-weight: 800; font-size: .9rem; cursor: pointer;
  transition: all .2s; color: var(--text2);
}
.tab-btn:hover  { border-color: var(--primary); color: var(--text); }
.tab-btn.active { background: var(--primary); border-color: var(--primary); color: #fff; }

.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ═══════════════════════════════════════════
   表單元件
═══════════════════════════════════════════ */
.form-group { margin-bottom: 18px; }
.form-group label {
  display: block; font-weight: 800; font-size: .88rem;
  margin-bottom: 6px; color: var(--text2);
}
.form-group input,
.form-group textarea,
.form-group select {
  width: 100%; padding: 10px 14px;
  border: 2px solid var(--border); border-radius: 14px;
  background: var(--bg); color: var(--text);
  font-family: 'Nunito', sans-serif; font-size: .95rem;
  outline: none; transition: border-color .2s;
}
.form-group input:focus,
.form-group textarea:focus { border-color: var(--primary); }
.form-group textarea { resize: vertical; min-height: 80px; }

/* ── AI 資訊框 ── */
.info-box {
  background: var(--accent); border-radius: 14px;
  padding: 12px 16px; margin-bottom: 18px;
  font-size: .88rem; font-weight: 700;
  display: flex; align-items: center; gap: 8px;
}

/* ── 上傳區 ── */
.drop-zone {
  border: 2.5px dashed var(--border); border-radius: 18px;
  padding: 36px 20px; text-align: center; cursor: pointer;
  transition: all .2s; background: var(--bg);
  margin-bottom: 16px;
}
.drop-zone:hover, .drop-zone.drag-over {
  border-color: var(--primary); background: var(--hi);
}
.drop-zone .dz-icon { font-size: 2.4rem; margin-bottom: 10px; }
.drop-zone p  { font-size: .9rem; color: var(--text2); font-weight: 700; }
.drop-zone small { color: var(--text2); opacity: .7; font-size: .8rem; }

/* ── 主要按鈕 ── */
.btn-primary {
  width: 100%; padding: 13px;
  background: var(--primary); color: #fff;
  border: none; border-radius: 14px;
  font-size: 1rem; font-weight: 900; cursor: pointer;
  transition: transform .2s, background .2s;
}
.btn-primary:hover:not(:disabled) { background: var(--primary2); transform: scale(1.02); }
.btn-primary:disabled { opacity: .5; cursor: not-allowed; }

/* ═══════════════════════════════════════════
   進度條 & 結果
═══════════════════════════════════════════ */
.progress-wrap { display: none; margin-top: 20px; }
.progress-wrap.show { display: block; }
.progress-bar-bg {
  background: var(--accent); border-radius: 50px; height: 14px; overflow: hidden;
}
.progress-bar-fill {
  height: 100%; background: var(--primary); border-radius: 50px; width: 0%;
  transition: width .4s ease;
}
.progress-msg { font-size: .88rem; font-weight: 700; color: var(--text2); margin-top: 8px; text-align: center; }

.result-wrap { display: none; margin-top: 24px; }
.result-wrap.show { display: block; }
.result-title { font-size: 1rem; font-weight: 900; margin-bottom: 14px; text-align: center; }
.result-imgs {
  display: grid; grid-template-columns: 1fr 1fr; gap: 16px;
}
.result-card {
  background: var(--bg); border-radius: 18px; padding: 16px; text-align: center;
  border: 2px solid var(--border);
}
.result-card img { width: 100%; border-radius: 12px; margin-bottom: 10px; }
.result-card p { font-size: .84rem; font-weight: 700; color: var(--text2); margin-bottom: 10px; }
.btn-dl {
  display: inline-block; background: var(--second2); color: #fff;
  border-radius: 10px; padding: 8px 18px; font-size: .84rem; font-weight: 800;
  text-decoration: none; transition: background .2s;
}
.btn-dl:hover { background: var(--second); }

/* ── 成功動畫 ── */
.celebrate { display: none; text-align: center; padding: 20px; font-size: 2rem; }
.celebrate.show { display: block; animation: celebrate .6s ease-out; }
@keyframes celebrate {
  0%   { transform: scale(.5); opacity: 0; }
  70%  { transform: scale(1.15); }
  100% { transform: scale(1);   opacity: 1; }
}

/* ── 錯誤訊息 ── */
.error-msg {
  display: none; background: #FFE8E8; color: #C0392B;
  border-radius: 12px; padding: 12px 16px;
  font-size: .88rem; font-weight: 700; margin-top: 12px;
}
.error-msg.show { display: block; }

/* ═══════════════════════════════════════════
   Footer
═══════════════════════════════════════════ */
footer {
  position: relative; z-index: 5;
  text-align: center; padding: 24px 20px;
  font-size: .82rem; color: var(--text2);
  border-top: 2px dashed var(--border);
}

/* ═══════════════════════════════════════════
   RWD 手機
═══════════════════════════════════════════ */
@media (max-width: 640px) {
  header { padding: 12px 16px; }
  nav, .btn-login { display: none; }
  .theme-switcher { display: none; }
  .hamburger { display: flex; }

  .hero { padding: 48px 16px 36px; }
  .card { padding: 20px; border-radius: 18px; }
  .main-wrap { padding: 0 12px 48px; }

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

  .steps-bar { gap: 0; padding: 0 12px 24px; }
  .step-line { width: 20px; }
  .step-item span:last-child { display: none; }
}

/* ═══════════════════════════════════════════
   管理後台
═══════════════════════════════════════════ */
.admin-wrap {
  max-width: 680px;
  margin: 0 auto;
  padding: 32px 20px 80px;
}
.admin-header { text-align: center; margin-bottom: 28px; }
.admin-header h2 { font-size: 1.6rem; font-weight: 800; color: var(--text1); }
.admin-header p  { color: var(--text2); margin-top: 6px; }

.admin-card { max-width: 100%; }
.admin-form { display: flex; flex-direction: column; gap: 20px; }

.admin-select {
  width: 100%;
  padding: 12px 16px;
  border: 2px solid var(--border);
  border-radius: 12px;
  background: var(--bg2);
  color: var(--text1);
  font-size: .95rem;
  font-family: inherit;
  cursor: pointer;
}
.admin-select:focus { outline: none; border-color: var(--primary); }

.key-input-wrap { display: flex; gap: 8px; }
.key-input-wrap input { flex: 1; }
.btn-eye {
  padding: 0 14px;
  border: 2px solid var(--border);
  border-radius: 12px;
  background: var(--bg2);
  cursor: pointer;
  font-size: 1.1rem;
  transition: border-color .2s;
}
.btn-eye:hover { border-color: var(--primary); }

.key-status { font-size: .85rem; margin-top: 6px; }
.key-status.set   { color: #4caf50; }
.key-status.unset { color: var(--text2); }

.form-hint { font-size: .82rem; color: var(--text2); margin-top: 4px; display: block; }
.form-hint a { color: var(--primary); text-decoration: none; }
.form-hint a:hover { text-decoration: underline; }

.admin-actions { display: flex; gap: 12px; }
.btn-test {
  flex: 1;
  padding: 14px;
  border: 2px solid var(--primary);
  border-radius: 14px;
  background: transparent;
  color: var(--primary);
  font-weight: 700;
  font-size: .95rem;
  cursor: pointer;
  transition: all .2s;
}
.btn-test:hover { background: var(--primary); color: #fff; }
.btn-test:disabled { opacity: .5; cursor: not-allowed; }

.admin-save { flex: 1; }

.test-result {
  display: none;
  padding: 14px 18px;
  border-radius: 12px;
  font-size: .92rem;
  font-weight: 600;
}
.test-result.show { display: block; }
.test-result.ok  { background: #e8f5e9; color: #2e7d32; }
.test-result.err { background: #fdecea; color: #c62828; }
