/* ========== CSS Variables (Design System) ========== */
:root {
  --paper: #e8dfd3;
  --ink: #2b2b2b;
  --sub: #5c5c5c;
  --line: #e6e0d6;
  --card: #ffffff;
  --red: #b43e2a;
  --blue: #2b6cb0;
  --chip: #f3efe6;
  --warn: #a15c00;
  --warn-bg: #fff5d8;
  --ok: #156a3a;
  --ok-bg: #e7f4ea;
  --hdrH: 88px;
  --kc-accent: #ff6a3d;
  --kc-accent2: #ffb86b;
}

/* ========== Base Styles ========== */
html {
  font-size: 17px;
}

@media (min-width: 480px) {
  html { font-size: 17.5px; }
  :root { --hdrH: 96px; }
}

@media (min-width: 768px) {
  html { font-size: 18px; }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, 'PingFang SC', HarmonyOS_Regular, Helvetica, Arial, sans-serif;
  line-height: 1.35;
}

/* ========== Layout Components ========== */
.container {
  max-width: 720px;
  margin: 0 auto;
  padding: 10px 10px 92px;
}

/* Header */
.hdr {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(248, 245, 239, 0.9);
  backdrop-filter: saturate(110%) blur(8px);
  border-bottom: 1px solid var(--line);
}

.hdr .wrap {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 14px 12px;
  min-height: var(--hdrH);
}

.logo {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  color: var(--red);
}

.logo img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
}

.brand {
  font-weight: 800;
  letter-spacing: 0.5px;
}

.sub {
  font-size: 0.82rem;
  color: var(--sub);
}

/* Cards */
.card {
  position: relative;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
  margin: 12px 10px;
}

.card.inner {
  background: #fffdf9;
}

/* Typography */
.title {
  font-weight: 700;
  margin: 0 0 6px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.small {
  font-size: 0.82rem;
  color: var(--sub);
}

/* ========== Report Content Optimization ========== */
#advice-list {
  font-size: 0.95rem;
  line-height: 1.6;
  color: var(--ink);
}

#advice-list h1, #advice-list h2, #advice-list h3,
#advice-list strong, #advice-list b {
  color: var(--ink);
  font-weight: 600;
}

#advice-list h1 {
  font-size: 1.1rem;
  margin: 1.2em 0 0.8em;
}

#advice-list h2 {
  font-size: 1.05rem;
  margin: 1em 0 0.6em;
}

#advice-list h3 {
  font-size: 1rem;
  margin: 0.8em 0 0.5em;
}

#advice-list ul, #advice-list ol {
  margin: 0.5em 0;
  padding-left: 1.2em;
}

#advice-list li {
  margin: 0.3em 0;
  line-height: 1.5;
}

#advice-list code, #advice-list pre {
  background: var(--chip);
  padding: 0.2em 0.4em;
  border-radius: 3px;
  font-family: 'SF Mono', Consolas, 'Liberation Mono', Menlo, monospace;
  font-size: 0.9em;
}

.card.chat #chat-status,
.card.chat #chat-status.small {
  font-size: 0.6rem !important;
  opacity: 0.6 !important;
  line-height: 1.2 !important;
}

.muted {
  opacity: 0.9;
}

/* Layout Utilities */
.row {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

/* ========== Form Elements ========== */
.text {
  flex: 1;
  min-width: 40%;
  padding: 0.75rem 0.8rem;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #fff;
  font-size: 1rem;
}

.btn {
  display: inline-block;
  padding: 0.7rem 0.9rem;
  border-radius: 12px;
  background: var(--red);
  color: #fff;
  text-decoration: none;
  font-weight: 700;
  cursor: pointer;
  border: 1px solid var(--red);
  transition: all 0.2s ease;
}

.btn:hover {
  filter: saturate(110%);
}

.btn.ghost {
  background: #fff;
  border: 1px solid var(--line);
  color: var(--ink);
}

.btn.primary {
  background: var(--blue);
  border-color: var(--blue);
  box-shadow: 0 6px 18px rgba(43, 108, 176, 0.25);
}

.btn.primary:hover {
  filter: saturate(110%);
  box-shadow: 0 8px 22px rgba(43, 108, 176, 0.32);
}

.btn.small {
  font-size: 0.9rem;
  padding: 0.5rem 0.72rem;
}

.btn[disabled],
.btn[aria-disabled="true"] {
  opacity: 0.55;
  filter: grayscale(35%);
  cursor: not-allowed;
  pointer-events: none;
}

.pill {
  display: inline-block;
  padding: 0.4rem 0.8rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  font-size: 0.9rem;
  color: var(--ink);
}

.pill.right {
  margin-left: auto;
}

/* ========== Chat System ========== */
.card.chat {
  position: fixed !important;
  top: max(-15px, calc(env(safe-area-inset-top) - 15px)) !important;
  right: calc(6px + env(safe-area-inset-right)) !important;
  width: min(450px, 88vw) !important;
  z-index: 100 !important;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.18);
  padding: 8px !important;
}

@media (max-width: 480px) {
  .card.chat {
    top: calc(var(--hdrH) - 15px) !important;
    right: 8px !important;
    width: 82vw !important;
    padding: 6px !important;
  }
}

.chat-list {
  height: 72vh !important;
  max-height: 72vh !important;
  overflow: auto;
  padding: 6px 8px;
  background: rgba(0, 0, 0, 0.02);
  border: 1px solid rgba(0, 0, 0, 0.06);
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

@media (max-width: 480px) {
  .chat-list {
    height: 62vh !important;
    max-height: 62vh !important;
    padding: 4px 6px;
  }
}

.msg {
  display: flex;
  margin: 4px 0;
}

.msg.ai {
  justify-content: flex-start;
}

.msg.user {
  justify-content: flex-end;
}

.bubble {
  position: relative;
  max-width: 85%;
  padding: 10px 12px;
  border-radius: 14px;
  line-height: 1.4;
  white-space: pre-wrap;
  word-wrap: break-word;
  overflow-wrap: break-word;
  word-break: break-word;
  hyphens: auto;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  font-size: 15px;
}

.msg.ai .bubble {
  background: #f2f4f5;
  color: #222;
  border-top-left-radius: 6px;
}

.msg.user .bubble {
  background: #d6f8c6;
  color: #111;
  border-top-right-radius: 6px;
}

.msg.ai:first-child .bubble {
  max-width: 56%;
  font-size: 0.95rem;
}

.bubble .meta {
  display: block;
  text-align: right;
  font-size: 10px;
  opacity: 0.55;
  margin-top: 4px;
}

/* 聊天氣泡內段落樣式優化 */
.bubble p {
  margin: 0.3em 0;
  line-height: 1.5;
}

.bubble p:first-child {
  margin-top: 0;
}

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

.chat-input-row {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  margin-top: 6px;
}

#chat-input {
  flex: 1;
  resize: vertical;
  padding: 10px;
  border-radius: 10px;
  border: 1px solid #ddd;
  background: #fff;
  color: #111;
  font-size: 16px;
}

.chat-actions .btn {
  white-space: nowrap;
}

.typing {
  margin: 4px 0;
  font-size: 12px;
  color: #666;
}

.typing::after {
  content: ' …';
  animation: dots 1.2s infinite steps(4, end);
}

@keyframes dots {
  0% { content: ' '; }
  25% { content: ' .'; }
  50% { content: ' ..'; }
  75% { content: ' ...'; }
  100% { content: ' '; }
}

/* Chat Collapsed State */
#chat-card.chat-collapsed #chat-list,
#chat-card.chat-collapsed .chat-input-row,
#chat-card.chat-collapsed #typing-indicator {
  display: none;
}

#typing-indicator {
  display: none;
}

#chat-card.chat-collapsed .title .right {
  display: none;
}

#chat-card.chat-collapsed {
  padding: 0 !important;
  margin: 0 !important;
  border: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
  height: 0 !important;
  min-height: 0 !important;
  pointer-events: none !important;
}

/* Chat Toggle Elements */
.hdr .chat-toggle-pill {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0.42rem 0.65rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--ink);
  text-decoration: none;
  font-size: 0.9rem;
  white-space: nowrap;
}

.chat-toggle-title {
  background: var(--chip);
  padding: 6px 10px;
  border-radius: 10px;
  cursor: pointer;
  user-select: none;
  transition: background 0.2s, transform 0.05s;
  display: none !important; /* Hidden permanently */
}

/* Chat FAB (Floating Action Button) */
#chat-fab {
  position: fixed !important;
  top: max(8px, env(safe-area-inset-top) + 8px) !important;
  right: max(8px, env(safe-area-inset-right) + 8px) !important;
  z-index: 10000 !important;
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  padding: 0;
  cursor: pointer;
  border-radius: 50%;
  transition: transform 0.2s ease;
  width: auto !important;
  height: auto !important;
  overflow: visible !important;
  position: relative;
}

#chat-fab:hover {
  transform: scale(1.05);
}

#chat-fab img {
  display: block !important;
  width: 160px !important;
  height: 160px !important;
  transition: opacity 0.3s ease;
}

@media (max-width: 480px) {
  #chat-fab img {
    width: 112px !important;
    height: 112px !important;
  }
}

/* 關閉按鈕樣式 */
.chat-close-btn {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 64px;
  height: 64px;
  background: rgba(180, 62, 42, 0.95);
  border-radius: 50%;
  display: none;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  font-weight: 800;
  color: white;
  text-align: center;
  line-height: 1;
  box-shadow: 0 6px 20px rgba(180, 62, 42, 0.4);
  backdrop-filter: blur(10px);
  transition: all 0.3s ease;
}

@media (max-width: 480px) {
  .chat-close-btn {
    width: 56px;
    height: 56px;
    font-size: 24px;
  }
}

/* 對話框展開時的狀態 */
#chat-card:not(.chat-collapsed) ~ #chat-fab img {
  opacity: 0;
  pointer-events: none;
}

#chat-card:not(.chat-collapsed) ~ #chat-fab .chat-close-btn {
  display: flex;
  animation: fadeInScale 0.3s ease-out;
}

@keyframes fadeInScale {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.7);
  }
  100% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
}

/* ========== Form Controls Layout ========== */
.control-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
}

.control-row.center {
  justify-content: center;
}

#row-loc {
  display: flex !important;
  align-items: center;
  gap: 8px;
  width: 100%;
}

#row-loc #loc {
  flex: 1 1 auto;
  min-width: 0;
}

#row-loc .btn,
#row-loc button {
  white-space: nowrap;
  flex: 0 0 auto;
}

.row.row-actions {
  display: flex !important;
  flex-direction: column !important;
  align-items: center !important;
  gap: 10px;
}

#row-geo {
  display: flex !important;
  justify-content: center !important;
  width: 100%;
}

@media (max-width: 480px) {
  .control-row {
    gap: 6px;
  }
  
  #row-loc #loc {
    flex: 1;
  }
  
  .row.row-actions .btn {
    padding: 0.5rem 0.6rem;
    font-size: 0.85rem;
  }
}

/* ========== Generate Button ========== */
#btn-generate {
  display: block !important;
  margin: 14px auto !important;
  text-align: center;
  font-size: 1.25rem !important;
  padding: 1.1rem 1.6rem !important;
  border-radius: 16px !important;
}

#btn-generate:not([disabled]) {
  background: var(--blue) !important;
  border-color: var(--blue) !important;
  color: #fff !important;
}

#copy-report {
  margin-top: 8px;
}

/* ========== Chips System ========== */
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.chip {
  font-size: 0.86rem;
  line-height: 1.45;
  padding: 0.35rem 0.55rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--chip);
  color: var(--ink);
  word-wrap: break-word;
  word-break: break-word;
  white-space: normal;
  overflow-wrap: break-word;
}

/* Chip Layout */
#chip-loc {
  order: 0;
  flex: 1 1 100%;
  font-weight: 700;
  background: #fff;
  border-color: #e6e0d6;
}

#chip-temp {
  order: 1;
  flex: 1 1 calc(50% - 4px);
}

#chip-hum {
  order: 2;
  flex: 1 1 calc(50% - 4px);
}

#chip-aqi {
  order: 3;
  flex: 1 1 calc(50% - 4px);
}

#chip-season {
  order: 4;
  flex: 1 1 calc(50% - 4px);
  min-width: 0; /* 允許收縮 */
}

/* 特別針對節氣chip的小屏幕優化 */
@media (max-width: 480px) {
  #chip-season {
    flex: 1 1 100%; /* 小屏幕時佔滿一行 */
    order: 5;
    margin-top: 4px;
    font-size: 0.82rem;
    line-height: 1.3;
  }
}

/* AQI Semantic Colors */
.chip.aqi--good {
  background: #e7f4ea;
  color: #0b6e3f;
  border-color: #cfead6;
}

.chip.aqi--moderate {
  background: #fff8da;
  color: #8a5a00;
  border-color: #ffecb3;
}

.chip.aqi--unhealthy-sg {
  background: #ffe8d9;
  color: #994100;
  border-color: #ffd1b3;
}

.chip.aqi--unhealthy {
  background: #ffe0e0;
  color: #aa1100;
  border-color: #ffc8c8;
}

.chip.aqi--very-unhealthy {
  background: #f6d9f6;
  color: #7a007a;
  border-color: #edb8ed;
}

.chip.aqi--hazardous {
  background: #f6d7df;
  color: #7e0023;
  border-color: #efb9c4;
}

@media (max-width: 520px) {
  #chip-temp,
  #chip-hum {
    display: none !important;
  }
  
  #chip-loc {
    flex: 1 1 100%;
  }
}

@media (max-width: 420px) {
  .chip {
    font-size: 0.84rem;
    padding: 0.32rem 0.5rem;
  }
}

/* ========== Bottom Navigation ========== */
.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(90deg, #b43e2a 0%, #d44f2f 100%);
  border-top: 2px solid #992f1d;
  display: flex;
  z-index: 999;
}

.tabbar a {
  flex: 1;
  text-align: center;
  padding: 16px 0;
  color: #fff;
  text-decoration: none;
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  transition: background 0.25s, transform 0.15s;
}

.tabbar a:hover {
  background: rgba(255, 255, 255, 0.15);
  transform: translateY(-2px);
}

.tabbar a[aria-current="page"] {
  background: rgba(255, 255, 255, 0.25);
  color: #fff;
  font-weight: 800;
}

/* 五個標籤時縮小字體避免換行 */
.tabbar.tabbar-five a {
  font-size: 14px;
  padding: 13px 4px;
}

/* Chrome瀏覽器特定高度調整 */
@supports (-webkit-appearance: none) {
  .tabbar.tabbar-five a {
    padding: 11px 4px;
  }
}

/* ========== Modal System ========== */
.modal {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 15000;
}

.modal.show {
  display: flex;
}

.modal .modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.38);
}

/* ========== Knowledge Card Modal ========== */
.modal .modal-card.knowcard {
  position: relative;
  z-index: 1;
  max-width: 540px;
  width: min(96vw, 540px);
  height: 88vh;
  max-height: 88vh;
  padding: 0;
  border-radius: 16px;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.25);
  background: #fff;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal .modal-card.knowcard .title {
  margin: 0;
  padding: 10px 40px 10px 12px;
  background: linear-gradient(135deg, var(--kc-accent) 0%, var(--kc-accent2) 100%);
  color: #fff;
  border-bottom: none;
  font-weight: 800;
  font-size: 1.15rem;
  line-height: 1.35;
}

#know-close {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  border: none;
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
  font-weight: 800;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  cursor: pointer;
}

#know-close:hover {
  background: rgba(255, 255, 255, 0.28);
}

.knowcard .know-body {
  flex: 1;
  overflow-y: auto;
  padding: 10px;
  display: grid;
  gap: 8px;
}

.knowcard .know-media {
  background: #fff7f2;
  border: 1px solid #ffe3cf;
  border-radius: 14px;
  padding: 8px;
}

.knowcard .know-media img {
  width: 100%;
  max-height: 44vh;
  object-fit: contain;
  border-radius: 10px;
}

.knowcard .know-text .kv {
  display: grid;
  grid-template-columns: 60px 1fr;
  border-bottom: 1px dashed var(--line);
  padding: 6px 0;
}

.know-text .kv .v {
  min-width: 0;
}

#know-eng {
  font-size: 0.95rem;
  line-height: 1.5;
  display: -webkit-box !important;
  -webkit-box-orient: vertical !important;
  -webkit-line-clamp: 4 !important;
  overflow: hidden !important;
}

#know-tran {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.45;
}

.knowcard .know-actions {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px 10px;
  border-top: 1px solid var(--line);
  background: #fff;
  border-radius: 0 0 16px 16px;
  flex-wrap: nowrap;
}

.knowcard .know-actions .jump-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.knowcard .know-actions .btn {
  background: var(--kc-accent);
  border: none;
  box-shadow: 0 6px 14px rgba(255, 106, 61, 0.25);
}

.knowcard .know-actions .btn.ghost {
  background: #fff;
  border: 1px solid var(--kc-accent);
  color: var(--kc-accent);
  box-shadow: none;
}

.knowcard .know-actions .text.small {
  font-size: 12px;
  padding: 5px 8px;
  height: 30px;
  width: 80px;
  min-width: 80px;
}

#know-jump {
  width: 50px;
}

.knowcard .know-footer {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px 12px;
  border-top: 1px dashed var(--line);
}

.knowcard #know-rand {
  flex: 1;
  text-align: center;
  background: var(--kc-accent, #ff6a3d);
  color: #fff;
  font-size: 1.1rem;
  font-weight: 800;
  padding: 10px 16px;
  border-radius: 999px;
  border: none;
  cursor: pointer;
  box-shadow: 0 6px 16px rgba(255, 106, 61, 0.28);
  transition: transform 0.15s ease, filter 0.2s ease;
}

.knowcard #know-rand:hover {
  transform: scale(1.04);
  filter: brightness(1.07);
}

.knowcard #know-idx {
  margin-left: auto;
  color: var(--sub);
  font-weight: 700;
}

.knowcard .small.muted {
  display: none !important;
}

@media (min-width: 880px) {
  .modal .modal-card.knowcard {
    width: min(520px, 48vw);
  }
}

@media (max-width: 480px) {
  .modal .modal-card.knowcard {
    height: 79vh !important;
    max-height: 79vh !important;
    width: min(94vw, 520px) !important;
  }
  
  .knowcard .know-media img {
    max-height: 36vh !important;
  }
}

/* ========== Game Card Modal ========== */
.modal .modal-card.gamecard {
  position: relative;
  z-index: 1;
  max-width: 920px;
  width: min(96vw, 920px);
  height: min(88vh, 860px);
  padding: 0;
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.25);
  overflow: hidden;
}

#game-frame {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
  background: #fff;
}

#game-close {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 2;
}

@media (max-width: 480px) {
  .modal .modal-card.gamecard {
    width: 96vw;
    height: 86vh;
  }
}

/* ========== 中英文庫 Modal ========== */
.modal .modal-card.tranccard {
  position: relative;
  z-index: 1;
  width: 95vw;
  height: 88vh;
  padding: 0;
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.25);
  overflow: hidden;
}

#tranc-frame {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
  background: #fff;
}

#tranc-close {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 2;
  background: rgba(255, 255, 255, 0.9);
  color: #333;
  border: 1px solid rgba(0, 0, 0, 0.1);
}

@media (max-width: 480px) {
  .modal .modal-card.tranccard {
    width: 95vw;
    height: 82vh;
  }
}

/* 快捷按鈕樣式 */
.quick-btn {
  background: #f0f0f0;
  color: #666;
  border: 1px solid #ddd;
  padding: 3px 8px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 400;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
  margin-left: 8px;
  display: inline-block;
  vertical-align: baseline;
}

.quick-btn:hover {
  background: #e8e8e8;
  color: #555;
  border-color: #ccc;
  transform: translateY(-1px);
}

.quick-btn:active {
  transform: translateY(0px);
}

/* AI 默認對話泡泡特殊樣式 */
#aph-plain {
  max-width: none !important;
  width: 100% !important;
  font-size: 15px !important;
}

.msg.ai .bubble:has(#aph-plain) {
  max-width: 95% !important;
}

/* 發送按鈕樣式 */
.send-btn {
  width: 50px !important;
  height: 50px !important;
  border-radius: 25px !important;
  font-size: 20px !important;
  font-weight: bold !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  padding: 0 !important;
  min-width: auto !important;
  background: #25D366 !important;
  color: white !important;
  border: none !important;
  box-shadow: 0 2px 8px rgba(37, 211, 102, 0.3) !important;
  transition: all 0.2s ease !important;
}

.send-btn:hover {
  background: #128C7E !important;
  transform: translateY(-2px) !important;
  box-shadow: 0 4px 12px rgba(37, 211, 102, 0.4) !important;
}

.send-btn:active {
  transform: translateY(0px) !important;
  box-shadow: 0 2px 6px rgba(37, 211, 102, 0.3) !important;
}


/* 一鍵定位按鈕樣式 */
#btn-geo {
  font-size: 1.35rem !important;
  padding: 1.2rem 1.8rem !important;
  border-radius: 18px !important;
  font-weight: 800 !important;
  background: var(--blue) !important;
  border-color: var(--blue) !important;
  color: #fff !important;
  box-shadow: 0 6px 20px rgba(43, 108, 176, 0.3) !important;
  animation: pulse-location-btn 0.8s infinite;
  transition: all 0.3s ease !important;
}

#btn-geo:hover {
  transform: translateY(-2px) !important;
  box-shadow: 0 8px 24px rgba(43, 108, 176, 0.4) !important;
}

/* 點擊後停止閃爍 */
#btn-geo.clicked {
  animation: none !important;
}

/* 成功獲取數據後的小尺寸樣式 */
#btn-geo.success {
  font-size: 1rem !important;
  padding: 0.7rem 0.9rem !important;
  border-radius: 12px !important;
  font-weight: 700 !important;
  background: var(--red) !important;
  border-color: var(--red) !important;
  color: #fff !important;
  box-shadow: none !important;
  animation: none !important;
  transform: none !important;
  transition: all 0.3s ease !important;
}

#btn-geo.success:hover {
  filter: saturate(110%) !important;
  transform: none !important;
  box-shadow: none !important;
}

/* 定位按鈕閃爍動畫 - 統一為STEP2效果 */
@keyframes pulse-location-btn {
  0% {
    transform: scale(1);
    box-shadow: 0 6px 18px rgba(43, 108, 176, 0.25);
    background: var(--blue);
  }
  50% {
    transform: scale(1.08);
    box-shadow: 0 15px 40px rgba(43, 108, 176, 0.55);
    background: #4299e1;
    filter: brightness(1.15);
  }
  100% {
    transform: scale(1);
    box-shadow: 0 6px 18px rgba(43, 108, 176, 0.25);
    background: var(--blue);
  }
}

/* 生成報告按鈕強烈脈衝動畫 */
@keyframes gentle-pulse {
  0% {
    transform: scale(1);
    box-shadow: 0 6px 18px rgba(43, 108, 176, 0.25);
    background: var(--blue);
  }
  50% {
    transform: scale(1.08);
    box-shadow: 0 15px 40px rgba(43, 108, 176, 0.55);
    background: #4299e1;
    filter: brightness(1.15);
  }
  100% {
    transform: scale(1);
    box-shadow: 0 6px 18px rgba(43, 108, 176, 0.25);
    background: var(--blue);
  }
}

/* ========== 穴位檢索卡片 ========== */
.modal .modal-card.ywcard {
  width: 900px;
  max-height: 85vh;
  overflow: hidden;
  background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15), 0 0 0 1px rgba(255, 255, 255, 0.8);
  border-radius: 16px;
}

.modal .modal-card.ywcard .title {
  padding: 8px 24px 6px;
  font-size: 0.95rem;
  font-weight: 700;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border-radius: 16px 16px 0 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 2px 8px rgba(102, 126, 234, 0.2);
}

.modal .modal-card.ywcard .yw-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.modal .modal-card.ywcard .yw-header-actions select {
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.5);
  color: #333;
}

.modal .modal-card.ywcard .yw-header-actions button {
  background: rgba(255, 255, 255, 0.2);
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.3);
}

.ywcard .yw-body {
  padding: 24px;
  min-height: 350px;
  max-height: 400px;
  overflow-y: auto;
  display: flex;
  flex-direction: row;
  gap: 24px;
  align-items: flex-start;
}

.ywcard .yw-media {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ywcard .yw-img-container {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ywcard .yw-media img {
  max-width: 240px;
  height: auto;
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
  border: 2px solid rgba(102, 126, 234, 0.1);
}

.ywcard .yw-nav-left {
  position: absolute;
  left: -80px;
  top: 50%;
  transform: translateY(-50%);
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: linear-gradient(135deg, #667eea, #764ba2);
  color: white;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
  transition: all 0.2s ease;
  z-index: 10;
}

.ywcard .yw-nav-right {
  position: absolute;
  right: -80px;
  top: 50%;
  transform: translateY(-50%);
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: linear-gradient(135deg, #667eea, #764ba2);
  color: white;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
  transition: all 0.2s ease;
  z-index: 10;
}

.ywcard .yw-nav-left:hover,
.ywcard .yw-nav-right:hover {
  transform: translateY(-50%) scale(1.1);
  box-shadow: 0 6px 16px rgba(102, 126, 234, 0.4);
}

.ywcard .yw-media img {
  cursor: pointer;
  transition: all 0.2s ease;
}

.ywcard .yw-media img:hover {
  transform: scale(1.02);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.15);
}

/* 放大鏡按鈕 */
.ywcard .yw-zoom-btn {
  position: absolute;
  bottom: 8px;
  right: -60px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.6);
  color: white;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s ease;
  z-index: 15;
}

.ywcard .yw-zoom-btn:hover {
  background: rgba(0, 0, 0, 0.8);
  transform: scale(1.1);
}

/* 圖片放大檢視 Modal */
.zoom-modal {
  background: rgba(0, 0, 0, 0.95);
}

.zoom-modal .modal-backdrop {
  background: transparent;
}

.zoom-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  box-sizing: border-box;
}

.zoom-container img {
  max-width: 90%;
  max-height: 90%;
  object-fit: contain;
  border-radius: 8px;
  box-shadow: 0 10px 50px rgba(0, 0, 0, 0.5);
  cursor: pointer;
}

.ywcard .yw-inline-number {
  font-weight: 400;
  font-size: 0.75rem;
  color: #999;
  margin-left: 8px;
}

.ywcard .yw-text {
  flex: 1;
  overflow-y: auto;
  max-height: 350px;
}

.ywcard .yw-text .kv {
  display: flex;
  margin-bottom: 16px;
  align-items: flex-start;
  gap: 16px;
  padding: 12px;
  border-radius: 10px;
  transition: all 0.2s ease;
}

.ywcard .yw-text .kv:hover {
  background: rgba(102, 126, 234, 0.05);
  transform: translateX(4px);
}

.ywcard .yw-text .kv.primary {
  background: linear-gradient(135deg, rgba(102, 126, 234, 0.1), rgba(118, 75, 162, 0.1));
  border-left: 4px solid #667eea;
}

.ywcard .yw-text .kv.purpose {
  background: linear-gradient(135deg, rgba(76, 175, 80, 0.1), rgba(139, 195, 74, 0.1));
  border-left: 4px solid #4CAF50;
}

.ywcard .yw-text .kv .k {
  font-weight: 600;
  color: #555;
  font-size: 0.85rem;
  min-width: 45px;
  flex-shrink: 0;
}

.ywcard .yw-text .kv .v {
  color: var(--ink);
  font-size: 0.9rem;
  line-height: 1.4;
  flex: 1;
}

.ywcard .yw-text .kv .v.bold {
  font-weight: 700;
  color: #333;
}

.ywcard .yw-text .kv.method {
  margin-top: 8px;
  background: linear-gradient(135deg, rgba(255, 193, 7, 0.1), rgba(255, 152, 0, 0.1));
  border-left: 4px solid #FF9800;
}

.ywcard .yw-text .kv.method .v {
  font-size: 0.85rem;
  line-height: 1.5;
  color: #555;
}

.ywcard .yw-actions {
  background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
  border-top: 1px solid rgba(0, 0, 0, 0.05);
}

.ywcard .yw-actions .jump-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
  color: #666;
  flex-wrap: wrap;
}

.ywcard .yw-actions .btn {
  font-size: 0.8rem;
  padding: 10px 18px;
  border-radius: 8px;
  font-weight: 600;
  transition: all 0.2s ease;
  background: linear-gradient(135deg, #667eea, #764ba2);
  color: white;
  border: none;
}

/* 統一搜尋區域樣式 */
.ywcard .jump-wrap input.text.small {
  padding: 8px 12px !important;
  height: auto;
  font-size: 0.8rem;
  vertical-align: middle;
  box-shadow: 0 2px 8px rgba(102, 126, 234, 0.2);
  width: 200px !important;
  border: 2px solid #ddd;
  box-sizing: border-box;
}

.ywcard .yw-actions .btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.ywcard .yw-actions .btn.ghost {
  background: transparent;
  color: #667eea;
  border: 2px solid #667eea;
  box-shadow: none;
}

.ywcard .yw-actions .btn.ghost:hover {
  background: #667eea;
  color: white;
}

.ywcard .yw-actions .text.small {
  font-size: 0.75rem;
  padding: 6px 10px;
  min-width: auto;
  border-radius: 6px;
  border: 1px solid #ddd;
}

/* 桌面版專用樣式 - 確保不被覆蓋 */
@media (min-width: 769px) {
  .modal .modal-card.ywcard {
    width: 950px !important;
  }
  
  .ywcard .yw-nav-left {
    left: -80px !important;
  }
  
  .ywcard .yw-nav-right {
    right: -80px !important;
  }
  
  .ywcard .yw-zoom-btn {
    right: -60px !important;
  }
  
  /* 桌面版：顯示搜尋區域按鈕，隱藏圖片旁按鈕 */
  .ywcard .yw-nav-desktop {
    display: inline-block !important;
  }
  
  .ywcard .yw-nav-mobile {
    display: none !important;
  }
}

@media (max-width: 768px) {
  .modal .modal-card.ywcard {
    width: 94vw;
    max-height: 90vh;
  }
  
  .ywcard .yw-body {
    flex-direction: column;
    padding: 20px;
    min-height: 280px;
    max-height: 450px;
    gap: 16px;
  }
  
  .ywcard .yw-media {
    align-self: center;
  }
  
  .ywcard .yw-media img {
    max-width: 200px;
  }
  
  .ywcard .yw-nav-left {
    left: -80px;
    width: 50px;
    height: 50px;
    font-size: 22px;
  }
  
  .ywcard .yw-nav-right {
    right: -80px;
    width: 50px;
    height: 50px;
    font-size: 22px;
  }

  /* 手機版放大鏡按鈕調整 */
  .ywcard .yw-zoom-btn {
    width: 36px;
    height: 36px;
    font-size: 16px;
    bottom: 10px;
    right: -60px;
  }
  
  .ywcard .yw-text {
    max-height: 250px;
  }

  /* 手機版統一搜尋區域樣式 */
  .ywcard .jump-wrap input.text.small {
    padding: 10px 12px !important;
    font-size: 0.9rem;
  }
  
  .ywcard .yw-actions .btn {
    padding: 10px 16px;
    font-size: 0.9rem;
  }
  
  .ywcard .yw-text .kv {
    padding: 10px;
    margin-bottom: 12px;
  }
  
  .ywcard .yw-actions {
    padding: 14px 20px;
    flex-direction: column;
    gap: 10px;
  }
  
  .ywcard .yw-actions .jump-wrap {
    justify-content: center;
    text-align: center;
  }
  
  /* 手機版：顯示圖片旁按鈕，隱藏搜尋區域按鈕 */
  .ywcard .yw-nav-mobile {
    display: flex !important;
  }
  
  .ywcard .yw-nav-desktop {
    display: none !important;
  }
}