/* ============================================================
   AppPrize — Liquid Glass 設計系統
   深色極光為預設；淺色為霜面日光。玻璃 = 背景模糊 + 飽和提升 +
   頂部鏡面高光 + 內外雙層陰影。
   ============================================================ */

* { box-sizing: border-box; margin: 0; padding: 0; }

/* hidden 屬性必須贏過任何 display 設定（.result{display:flex} 等） */
[hidden] { display: none !important; }

:root {
  --font-display: "Bricolage Grotesque", "Noto Sans TC", -apple-system, "PingFang TC", sans-serif;
  --font-body: "Noto Sans TC", -apple-system, "PingFang TC", "Segoe UI", sans-serif;

  --bg: #060b14;
  --bg-glow-a: #0e7490;
  --bg-glow-b: #4338ca;
  --bg-glow-c: #0f766e;
  --ink: #eaf2fb;
  --ink-dim: rgba(234, 242, 251, 0.62);
  --ink-faint: rgba(234, 242, 251, 0.38);
  --accent: #5eead4;
  --accent-2: #38bdf8;
  --accent-3: #a78bfa;
  --gold: #fbbf24;
  --danger: #fb7185;

  --glass-bg: linear-gradient(160deg, rgba(255,255,255,0.085), rgba(255,255,255,0.035) 42%, rgba(255,255,255,0.06));
  --glass-bg-strong: linear-gradient(160deg, rgba(23,34,52,0.88), rgba(13,21,36,0.92));
  --glass-border: rgba(255,255,255,0.14);
  --glass-highlight: rgba(255,255,255,0.28);
  --glass-shadow: 0 18px 50px -18px rgba(2, 8, 20, 0.85), 0 4px 16px -8px rgba(2, 8, 20, 0.5);
  --row-hover: rgba(255,255,255,0.05);

  --r-lg: 28px;
  --r-md: 20px;
  --r-sm: 14px;
  --r-pill: 999px;
}

html[data-theme="light"] {
  --bg: #d8e6f5;
  --bg-glow-a: #38bdf8;
  --bg-glow-b: #a78bfa;
  --bg-glow-c: #2dd4bf;
  --ink: #0c1a2e;
  --ink-dim: rgba(12, 26, 46, 0.66);
  --ink-faint: rgba(12, 26, 46, 0.42);
  --accent: #0d9488;
  --accent-2: #0369a1;
  --accent-3: #7c3aed;
  --gold: #b45309;
  --danger: #e11d48;

  --glass-bg: linear-gradient(160deg, rgba(255,255,255,0.78), rgba(255,255,255,0.5) 42%, rgba(255,255,255,0.66));
  --glass-bg-strong: linear-gradient(160deg, rgba(255,255,255,0.96), rgba(240,246,253,0.97));
  --glass-border: rgba(255,255,255,0.9);
  --glass-highlight: rgba(255,255,255,0.98);
  --glass-shadow: 0 18px 50px -20px rgba(30, 58, 105, 0.55), 0 4px 14px -8px rgba(30, 58, 105, 0.3);
  --row-hover: rgba(255,255,255,0.55);
}

html { color-scheme: dark; }
html[data-theme="light"] { color-scheme: light; }

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--ink);
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  line-height: 1.6;
}

/* ---------- 極光背景 ---------- */
.aurora {
  position: fixed; inset: -20%;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
}
.aurora__blob {
  position: absolute;
  width: 55vmax; height: 55vmax;
  border-radius: 50%;
  filter: blur(90px);
  opacity: 0.55;
  mix-blend-mode: screen;
  animation: drift 26s ease-in-out infinite alternate;
}
html[data-theme="light"] .aurora__blob { mix-blend-mode: normal; opacity: 0.4; filter: blur(110px) saturate(1.3); }
.aurora__blob--a { background: radial-gradient(circle at 35% 35%, var(--bg-glow-a), transparent 65%); top: -8%; left: -12%; }
.aurora__blob--b { background: radial-gradient(circle at 60% 40%, var(--bg-glow-b), transparent 65%); top: 22%; right: -18%; animation-delay: -9s; animation-duration: 32s; }
.aurora__blob--c { background: radial-gradient(circle at 50% 60%, var(--bg-glow-c), transparent 62%); bottom: -15%; left: 22%; animation-delay: -17s; animation-duration: 38s; }
@keyframes drift {
  from { transform: translate3d(0, 0, 0) scale(1) rotate(0deg); }
  to { transform: translate3d(6%, -5%, 0) scale(1.15) rotate(18deg); }
}
.aurora__grain {
  position: absolute; inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.05'/%3E%3C/svg%3E");
  opacity: 0.7;
}

/* ---------- 玻璃 ---------- */
.glass, .glass-strong {
  position: relative;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--r-lg);
  box-shadow:
    inset 0 1px 0 var(--glass-highlight),
    inset 0 -1px 0 rgba(255,255,255,0.04),
    var(--glass-shadow);
  backdrop-filter: blur(26px) saturate(1.7);
  -webkit-backdrop-filter: blur(26px) saturate(1.7);
}
.glass-strong {
  background: var(--glass-bg-strong);
  backdrop-filter: blur(34px) saturate(1.8);
  -webkit-backdrop-filter: blur(34px) saturate(1.8);
}
/* 鏡面斜光 */
.glass::before, .glass-strong::before {
  content: "";
  position: absolute; inset: 0;
  border-radius: inherit;
  background: linear-gradient(115deg, rgba(255,255,255,0.14) 0%, rgba(255,255,255,0) 28%);
  pointer-events: none;
}

/* ---------- 頂列 ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
  padding: max(14px, env(safe-area-inset-top)) 20px 10px;
  max-width: 1020px; width: 100%;
  margin: 0 auto;
}
.brand {
  display: flex; align-items: center; gap: 10px;
  text-decoration: none; color: var(--ink);
}
.brand__mark { width: 34px; height: 34px; filter: drop-shadow(0 4px 14px rgba(56,189,248,0.45)); }
.brand__word {
  font-family: var(--font-display);
  font-weight: 700; font-size: 1.3rem; letter-spacing: -0.02em;
}
.brand__word em {
  font-style: normal;
  background: linear-gradient(90deg, var(--accent), var(--accent-2), var(--accent-3));
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent; color: transparent;
}
.topbar__actions { display: flex; align-items: center; gap: 8px; }

.pill {
  display: inline-flex; align-items: center; gap: 7px;
  font: 500 0.88rem var(--font-body);
  color: var(--ink);
  padding: 8px 14px;
  border-radius: var(--r-pill);
  border: 1px solid var(--glass-border);
  background: var(--glass-bg);
  backdrop-filter: blur(18px) saturate(1.6);
  -webkit-backdrop-filter: blur(18px) saturate(1.6);
  box-shadow: inset 0 1px 0 var(--glass-highlight);
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}
.pill:hover { transform: translateY(-1px); box-shadow: inset 0 1px 0 var(--glass-highlight), 0 8px 22px -10px rgba(56,189,248,0.55); }
.pill:active { transform: translateY(0) scale(0.98); }
.pill--accent { border-color: color-mix(in srgb, var(--accent-2) 55%, transparent); color: var(--accent-2); font-weight: 700; }
.pill--danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 45%, transparent); }
.pill__chev { width: 11px; height: 11px; opacity: 0.7; }
.pill__ic { width: 15px; height: 15px; }

.iconbtn {
  width: 38px; height: 38px;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--ink-dim);
  border-radius: var(--r-pill);
  border: 1px solid var(--glass-border);
  background: var(--glass-bg);
  backdrop-filter: blur(18px) saturate(1.6);
  -webkit-backdrop-filter: blur(18px) saturate(1.6);
  cursor: pointer;
  transition: transform 0.18s ease, color 0.18s ease;
}
.iconbtn:hover { transform: translateY(-1px); color: var(--ink); }
.iconbtn svg { width: 19px; height: 19px; }

/* ---------- 主要版面 ---------- */
.shell {
  flex: 1;
  width: 100%; max-width: 1020px;
  margin: 0 auto;
  padding: 12px 20px 40px;
}

/* ---------- Hero ---------- */
.hero { padding-top: clamp(28px, 7vh, 84px); text-align: center; }
.hero__title {
  font-family: var(--font-display);
  font-size: clamp(2.1rem, 6vw, 3.6rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.15;
  animation: rise 0.7s cubic-bezier(0.22, 1, 0.36, 1) both;
}
.hero__grad {
  background: linear-gradient(92deg, var(--accent) 0%, var(--accent-2) 45%, var(--accent-3) 100%);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent; color: transparent;
}
.hero__sub {
  color: var(--ink-dim);
  max-width: 560px;
  margin: 14px auto 30px;
  font-size: 0.98rem;
  animation: rise 0.7s 0.08s cubic-bezier(0.22, 1, 0.36, 1) both;
}
@keyframes rise { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: none; } }

.search {
  display: flex; align-items: center; gap: 10px;
  max-width: 640px;
  margin: 0 auto;
  padding: 10px 10px 10px 20px;
  border-radius: var(--r-pill);
  animation: rise 0.7s 0.16s cubic-bezier(0.22, 1, 0.36, 1) both;
  transition: box-shadow 0.25s ease, border-color 0.25s ease;
}
.search:focus-within {
  border-color: color-mix(in srgb, var(--accent-2) 60%, transparent);
  box-shadow:
    inset 0 1px 0 var(--glass-highlight),
    0 0 0 4px color-mix(in srgb, var(--accent-2) 18%, transparent),
    var(--glass-shadow);
}
.search__icon { width: 20px; height: 20px; color: var(--ink-faint); flex: none; }
.search__input {
  flex: 1; min-width: 0;
  background: none; border: none; outline: none;
  color: var(--ink);
  font: 400 1rem var(--font-body);
}
.search__input::placeholder { color: var(--ink-faint); }
.search__go {
  flex: none;
  font: 700 0.95rem var(--font-display);
  letter-spacing: 0.02em;
  color: #04121f;
  background: linear-gradient(120deg, var(--accent), var(--accent-2));
  border: none; border-radius: var(--r-pill);
  padding: 10px 22px;
  cursor: pointer;
  box-shadow: 0 8px 24px -8px color-mix(in srgb, var(--accent-2) 70%, transparent);
  transition: transform 0.18s ease, filter 0.18s ease;
}
.search__go:hover { transform: translateY(-1px); filter: brightness(1.08); }
.search__go:active { transform: scale(0.97); }

/* 搜尋框要建立高於後續兄弟元素（提示標籤、歷史卡片）的堆疊層級，
   否則玻璃效果的 backdrop-filter stacking context 會讓下拉選單被蓋住、無法點選 */
.search { position: relative; z-index: 40; }
.search__menu {
  position: absolute; top: calc(100% + 10px); left: 0; right: 0;
  border-radius: var(--r-md);
  padding: 6px;
  max-height: min(330px, 55dvh); overflow: auto;
  z-index: 30;
  text-align: left;
  /* 下拉選單背景要接近不透明：候選列表下方常有其他文字，不能透出干擾閱讀 */
  background: linear-gradient(160deg, rgba(26, 37, 56, 0.985), rgba(13, 21, 36, 0.99));
}
html[data-theme="light"] .search__menu {
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.99), rgba(242, 247, 253, 0.99));
}
.search__item {
  display: flex; align-items: center; gap: 12px;
  width: 100%;
  padding: 9px 10px;
  border: none; background: none;
  border-radius: var(--r-sm);
  color: var(--ink);
  cursor: pointer;
  text-align: left;
  font: 400 0.93rem var(--font-body);
}
.search__item:hover, .search__item[aria-selected="true"] { background: var(--row-hover); }
.search__item img { width: 40px; height: 40px; border-radius: 10px; flex: none; }
.search__item small { display: block; color: var(--ink-faint); font-size: 0.78rem; }

.hero__hint {
  display: flex; flex-wrap: wrap; gap: 8px; justify-content: center;
  margin-top: 22px;
  animation: rise 0.7s 0.24s cubic-bezier(0.22, 1, 0.36, 1) both;
}
.hero__hint-chip {
  font-size: 0.82rem; color: var(--ink-dim);
  padding: 6px 13px;
  border-radius: var(--r-pill);
  border: 1px dashed color-mix(in srgb, var(--ink) 22%, transparent);
  cursor: pointer;
  transition: all 0.18s ease;
}
.hero__hint-chip:hover { color: var(--accent-2); border-color: var(--accent-2); border-style: solid; }

/* ---------- 歷史 ---------- */
.history { margin-top: clamp(40px, 8vh, 72px); text-align: left; }
.history__title { font: 700 0.95rem var(--font-display); color: var(--ink-dim); margin-bottom: 14px; letter-spacing: 0.02em; }
.history__grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px;
}
.history__card {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  border-radius: var(--r-md);
  cursor: pointer;
  border: 1px solid var(--glass-border);
  background: var(--glass-bg);
  backdrop-filter: blur(18px) saturate(1.6);
  -webkit-backdrop-filter: blur(18px) saturate(1.6);
  color: var(--ink);
  transition: transform 0.18s ease, box-shadow 0.18s ease;
  text-align: left;
}
.history__card:hover { transform: translateY(-2px); box-shadow: var(--glass-shadow); }
.history__card img { width: 38px; height: 38px; border-radius: 9px; flex: none; object-fit: cover; }
.history__card b { font-size: 0.86rem; font-weight: 500; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.history__card small { color: var(--ink-faint); font-size: 0.72rem; }

/* ---------- 結果頁 ---------- */
.result { display: flex; flex-direction: column; gap: 16px; padding-top: 6px; }
.back {
  align-self: flex-start;
  display: inline-flex; align-items: center; gap: 4px;
  background: none; border: none;
  color: var(--ink-dim);
  font: 500 0.88rem var(--font-body);
  cursor: pointer;
  padding: 6px 4px;
}
.back:hover { color: var(--ink); }
.back svg { width: 16px; height: 16px; }

.appcard {
  display: flex; align-items: center; gap: 18px;
  padding: 20px 22px;
  flex-wrap: wrap;
}
.appcard__icon {
  width: 88px; height: 88px;
  border-radius: 22px;
  box-shadow: 0 10px 30px -10px rgba(2,8,20,0.7);
  background: var(--row-hover);
}
.appcard__info { flex: 1; min-width: 200px; }
.appcard__name { font-family: var(--font-display); font-size: 1.5rem; font-weight: 700; letter-spacing: -0.02em; }
.appcard__dev { color: var(--ink-dim); font-size: 0.88rem; }
.appcard__links { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 9px; }
.applink {
  font-size: 0.75rem; color: var(--ink-dim);
  text-decoration: none;
  padding: 3px 10px;
  border-radius: var(--r-pill);
  border: 1px solid var(--glass-border);
  transition: all 0.15s ease;
}
.applink:hover { color: var(--accent-2); border-color: var(--accent-2); }

/* ---------- 載入 ---------- */
.loading {
  display: flex; align-items: center; gap: 14px;
  padding: 18px 22px;
  color: var(--ink-dim); font-size: 0.9rem;
}
.loading__spinner {
  width: 22px; height: 22px; flex: none;
  border-radius: 50%;
  border: 2.5px solid color-mix(in srgb, var(--accent-2) 25%, transparent);
  border-top-color: var(--accent-2);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.skeleton-row {
  height: 74px;
  border-radius: var(--r-md);
  background: linear-gradient(100deg, var(--row-hover) 40%, color-mix(in srgb, var(--ink) 9%, transparent) 50%, var(--row-hover) 60%);
  background-size: 220% 100%;
  animation: shimmer 1.3s linear infinite;
}
@keyframes shimmer { to { background-position: -120% 0; } }

/* ---------- 摘要橫幅 ---------- */
.summary {
  padding: 16px 22px;
  border-radius: var(--r-md);
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  font-size: 0.95rem;
}
.summary__flag { font-size: 1.7rem; }
.summary b { font-family: var(--font-display); font-size: 1.12rem; }
.summary .save { color: var(--accent); font-weight: 700; }

/* ---------- 方案切換 ---------- */
.plantabs { display: flex; flex-wrap: wrap; gap: 8px; }
.plantab {
  font: 500 0.86rem var(--font-body);
  color: var(--ink-dim);
  padding: 8px 16px;
  border-radius: var(--r-pill);
  border: 1px solid var(--glass-border);
  background: var(--glass-bg);
  backdrop-filter: blur(14px) saturate(1.5);
  -webkit-backdrop-filter: blur(14px) saturate(1.5);
  cursor: pointer;
  transition: all 0.18s ease;
}
.plantab[aria-selected="true"] {
  color: #04121f;
  font-weight: 700;
  background: linear-gradient(120deg, var(--accent), var(--accent-2));
  border-color: transparent;
  box-shadow: 0 6px 18px -6px color-mix(in srgb, var(--accent-2) 60%, transparent);
}
.plantab__period {
  font-size: 0.7rem; opacity: 0.75; margin-left: 5px;
}

/* ---------- 排行榜 ---------- */
.board { display: flex; flex-direction: column; gap: 10px; }
.row-card {
  display: grid;
  grid-template-columns: 44px 1fr auto;
  align-items: center;
  gap: 8px 14px;
  padding: 14px 18px;
  border-radius: var(--r-md);
  border: 1px solid var(--glass-border);
  background: var(--glass-bg);
  backdrop-filter: blur(22px) saturate(1.65);
  -webkit-backdrop-filter: blur(22px) saturate(1.65);
  box-shadow: inset 0 1px 0 var(--glass-highlight);
  position: relative;
  overflow: hidden;
  animation: rise 0.5s cubic-bezier(0.22, 1, 0.36, 1) both;
  animation-delay: calc(var(--i, 0) * 55ms);
  transition: transform 0.18s ease;
}
.row-card:hover { transform: translateX(3px); }
.row-card--best {
  border-color: color-mix(in srgb, var(--accent) 65%, transparent);
  box-shadow:
    inset 0 1px 0 var(--glass-highlight),
    0 0 0 1px color-mix(in srgb, var(--accent) 35%, transparent),
    0 12px 40px -14px color-mix(in srgb, var(--accent) 55%, transparent);
}
.row-card--muted { opacity: 0.62; }
.row-card__rank {
  font-family: var(--font-display);
  font-weight: 800; font-size: 1.15rem;
  color: var(--ink-faint);
  text-align: center;
}
.row-card--best .row-card__rank { color: var(--accent); }
.row-card__who { display: flex; align-items: center; gap: 11px; min-width: 0; }
.row-card__flag { font-size: 1.55rem; flex: none; filter: drop-shadow(0 2px 6px rgba(0,0,0,0.3)); }
.row-card__country { font-weight: 500; font-size: 0.95rem; }
.row-card__local { color: var(--ink-faint); font-size: 0.78rem; display: block; }
.row-card__price { text-align: right; }
.row-card__converted {
  font-family: var(--font-display);
  font-weight: 700; font-size: 1.28rem;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  display: block;
}
.row-card--best .row-card__converted { color: var(--accent); }
.row-card__delta { font-size: 0.75rem; color: var(--ink-faint); font-variant-numeric: tabular-nums; }
.row-card__delta--more { color: var(--danger); }
.badge-best {
  font: 700 0.68rem var(--font-body);
  color: #052019;
  background: linear-gradient(120deg, var(--accent), #86efac);
  padding: 3px 9px;
  border-radius: var(--r-pill);
  margin-left: 8px;
  vertical-align: 2px;
  letter-spacing: 0.05em;
  box-shadow: 0 3px 10px -3px color-mix(in srgb, var(--accent) 70%, transparent);
}
.badge-official {
  font: 700 0.68rem var(--font-body);
  color: #1c1204;
  background: linear-gradient(120deg, var(--gold), #fde68a);
  padding: 3px 9px;
  border-radius: var(--r-pill);
  margin-left: 8px;
  vertical-align: 2px;
  letter-spacing: 0.05em;
}
.row-card__bar {
  grid-column: 1 / -1;
  height: 4px;
  border-radius: 4px;
  background: color-mix(in srgb, var(--ink) 8%, transparent);
  overflow: hidden;
}
.row-card__bar i {
  display: block; height: 100%;
  width: calc(var(--pct, 100) * 1%);
  border-radius: 4px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  opacity: 0.85;
  transition: width 0.6s cubic-bezier(0.22, 1, 0.36, 1);
}
.row-card--best .row-card__bar i { background: linear-gradient(90deg, var(--accent), #86efac); }
.row-card__err { grid-column: 2 / -1; color: var(--ink-faint); font-size: 0.8rem; }

/* ---------- 官網卡 ---------- */
.official { padding: 18px 22px; border-radius: var(--r-md); }
.official__head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.official__head h3 { font-family: var(--font-display); font-size: 1.02rem; }
.official__row {
  display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap;
  padding: 8px 0;
  border-top: 1px solid color-mix(in srgb, var(--ink) 8%, transparent);
}
.official__name { flex: 1; min-width: 140px; font-size: 0.92rem; }
.official__price { font-family: var(--font-display); font-weight: 700; font-size: 1.1rem; font-variant-numeric: tabular-nums; }
.official__conv { color: var(--ink-dim); font-size: 0.85rem; font-variant-numeric: tabular-nums; }
.official__note { color: var(--ink-faint); font-size: 0.78rem; margin-top: 10px; }
.official__link { color: var(--accent-2); text-decoration: none; font-size: 0.85rem; font-weight: 500; }
.official__link:hover { text-decoration: underline; }
.official--win { border-color: color-mix(in srgb, var(--gold) 55%, transparent); }

/* ---------- 價格歷史 ---------- */
.phistory { padding: 18px 22px; border-radius: var(--r-md); }
.phistory__head { font-family: var(--font-display); font-size: 1.02rem; margin-bottom: 10px; }
.phistory__sparks { display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; }
.phistory__row {
  display: flex; align-items: center; gap: 10px;
  font-size: 0.85rem;
  padding: 4px 0;
}
.phistory__flag { font-size: 1.15rem; }
.phistory__cc { min-width: 56px; color: var(--ink-dim); }
.phistory__spark { color: var(--accent-2); display: inline-flex; }
.phistory__range { color: var(--ink-faint); font-size: 0.78rem; font-variant-numeric: tabular-nums; }
.phistory__event {
  display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap;
  padding: 7px 0;
  border-top: 1px solid color-mix(in srgb, var(--ink) 8%, transparent);
  font-size: 0.86rem;
}
.phistory__date { color: var(--ink-faint); font-size: 0.78rem; font-variant-numeric: tabular-nums; }
.phistory__what { flex: 1; min-width: 120px; }
.phistory__up { color: var(--danger); font-variant-numeric: tabular-nums; }
.phistory__down { color: var(--accent); font-variant-numeric: tabular-nums; }
.phistory__note { color: var(--ink-faint); font-size: 0.8rem; margin-top: 6px; }

/* ---------- 我的訂閱 ---------- */
.plantab--star { border-style: dashed; color: var(--ink-dim); }
.plantab--star.is-on {
  border-style: solid;
  color: var(--gold);
  border-color: color-mix(in srgb, var(--gold) 55%, transparent);
  background: color-mix(in srgb, var(--gold) 10%, transparent);
}
.mysubs__title { font-family: var(--font-display); font-size: 1.4rem; letter-spacing: -0.02em; }
.msub {
  display: grid;
  grid-template-columns: minmax(160px, 1.3fr) auto 1fr auto;
  align-items: center;
  gap: 10px 16px;
}
.msub__who { display: flex; align-items: center; gap: 10px; min-width: 0; }
.msub__who img, .msub__noicon {
  width: 42px; height: 42px; border-radius: 10px; flex: none;
  background: var(--row-hover); display: inline-block;
}
.msub__app { display: block; font-weight: 600; color: var(--ink); text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msub__app:hover { color: var(--accent-2); }
.msub__plan { display: block; color: var(--ink-dim); font-size: 0.8rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msub__cur { display: flex; align-items: center; gap: 10px; }
.msub__cur .row-card__converted { font-size: 1.15rem; }
.msub__cur small { font-size: 0.7em; color: var(--ink-faint); font-weight: 400; }
.msub__cc {
  background: var(--row-hover);
  border: 1px solid var(--glass-border);
  border-radius: 10px;
  color: var(--ink);
  padding: 6px 8px;
  font: 400 0.84rem var(--font-body);
  max-width: 130px;
}
.msub__best { font-size: 0.85rem; color: var(--ink-dim); min-width: 0; }
.msub__best b { color: var(--ink); font-variant-numeric: tabular-nums; }
.msub__best .save { color: var(--accent); font-weight: 700; margin-left: 6px; }
.msub__ok { color: var(--accent); font-weight: 600; }
.msub__rm {
  width: 30px; height: 30px;
  border-radius: 50%;
  border: 1px solid var(--glass-border);
  background: none;
  color: var(--ink-faint);
  cursor: pointer;
  transition: all 0.15s ease;
}
.msub__rm:hover { color: var(--danger); border-color: var(--danger); }

/* ---------- 注意事項 / meta ---------- */
.notes { padding: 16px 22px; border-radius: var(--r-md); font-size: 0.86rem; color: var(--ink-dim); }
.notes summary { cursor: pointer; font-weight: 500; color: var(--ink); }
.notes ul { margin: 10px 0 0 20px; display: flex; flex-direction: column; gap: 6px; }
.metaline { color: var(--ink-faint); font-size: 0.78rem; text-align: center; }
.metaline .warn { color: var(--gold); }
.metaline a { color: var(--accent-2); text-decoration: none; }
.metaline a:hover { text-decoration: underline; }

/* ---------- 幣別選單 ---------- */
.menu {
  position: fixed;
  z-index: 60;
  border-radius: var(--r-md);
  padding: 6px;
  max-height: min(380px, 70dvh);
  overflow: auto;
  min-width: 210px;
}
.menu__item {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  width: 100%;
  padding: 9px 13px;
  border: none; background: none;
  border-radius: var(--r-sm);
  color: var(--ink);
  font: 400 0.9rem var(--font-body);
  cursor: pointer;
  text-align: left;
}
.menu__item:hover { background: var(--row-hover); }
.menu__item[aria-selected="true"] { color: var(--accent-2); font-weight: 700; }
.menu__item small { color: var(--ink-faint); }

/* ---------- 設定面板 ---------- */
.sheet {
  border: 1px solid var(--glass-border);
  border-radius: var(--r-lg);
  width: min(560px, calc(100vw - 32px));
  max-height: min(86dvh, 720px);
  padding: 0;
  color: var(--ink);
  margin: auto;
}
.sheet::backdrop { background: rgba(3, 8, 18, 0.55); backdrop-filter: blur(6px); }
.sheet__body { padding: 22px 24px 26px; overflow: auto; max-height: inherit; }
.sheet__head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.sheet__head h2 { font-family: var(--font-display); font-size: 1.25rem; }
.sheet__sec { margin-top: 20px; }
.sheet__sec h3 { font-size: 0.95rem; margin-bottom: 8px; font-weight: 700; }
.sheet__desc { color: var(--ink-faint); font-size: 0.8rem; margin-bottom: 10px; }
.row { display: flex; align-items: center; gap: 9px; padding: 5px 0; font-size: 0.9rem; }
.row--indent { padding-left: 26px; }
.row--col { flex-direction: column; align-items: stretch; gap: 6px; }
.row--col > span { font-size: 0.85rem; color: var(--ink-dim); }
.row code { font-size: 0.8em; background: var(--row-hover); padding: 1px 5px; border-radius: 5px; }
.numinput, .textinput {
  background: var(--row-hover);
  border: 1px solid var(--glass-border);
  border-radius: 10px;
  color: var(--ink);
  padding: 7px 10px;
  font: 400 0.9rem var(--font-body);
}
.numinput { width: 84px; text-align: right; }
.numinput:focus, .textinput:focus { outline: 2px solid color-mix(in srgb, var(--accent-2) 45%, transparent); }
.countrygrid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(128px, 1fr));
  gap: 6px;
}
.countrychip {
  display: flex; align-items: center; gap: 7px;
  font-size: 0.83rem;
  padding: 7px 10px;
  border-radius: var(--r-sm);
  border: 1px solid var(--glass-border);
  background: none;
  color: var(--ink-dim);
  cursor: pointer;
  transition: all 0.15s ease;
}
.countrychip[aria-pressed="true"] {
  color: var(--ink);
  border-color: color-mix(in srgb, var(--accent-2) 55%, transparent);
  background: color-mix(in srgb, var(--accent-2) 12%, transparent);
  font-weight: 500;
}
.countrychip small { margin-left: auto; color: var(--ink-faint); font-size: 0.7rem; }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  left: 50%; bottom: max(26px, env(safe-area-inset-bottom));
  transform: translate(-50%, 0);
  padding: 12px 20px;
  border-radius: var(--r-pill);
  font-size: 0.88rem;
  z-index: 80;
  /* 專用動畫：進場位移必須保留 -50% 的水平置中 */
  animation: toast-rise 0.3s ease both;
  max-width: min(90vw, 480px);
  text-align: center;
}
@keyframes toast-rise {
  from { opacity: 0; transform: translate(-50%, 14px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

.toast__btn {
  margin-left: 10px;
  font: 700 0.84rem var(--font-body);
  color: #04121f;
  background: linear-gradient(120deg, var(--accent), var(--accent-2));
  border: none;
  border-radius: var(--r-pill);
  padding: 6px 15px;
  cursor: pointer;
  transition: transform 0.15s ease, filter 0.15s ease;
}
.toast__btn:hover { transform: translateY(-1px); filter: brightness(1.08); }

/* ---------- Footer ---------- */
.foot {
  display: flex; align-items: center; justify-content: center; gap: 14px; flex-wrap: wrap;
  padding: 18px 20px max(22px, env(safe-area-inset-bottom));
  color: var(--ink-faint);
  font-size: 0.76rem;
}
.foot a { color: var(--ink-dim); text-decoration: none; }
.foot a:hover { color: var(--accent-2); }

/* ---------- RWD ---------- */
@media (max-width: 560px) {
  .msub { grid-template-columns: 1fr auto; }
  .msub__who { grid-column: 1 / -1; }
  .msub__best { grid-column: 1 / -1; }
  .appcard__icon { width: 64px; height: 64px; border-radius: 16px; }
  .appcard__name { font-size: 1.2rem; }
  .row-card { grid-template-columns: 30px 1fr auto; padding: 12px 14px; }
  .row-card__converted { font-size: 1.1rem; }
  .search { padding: 8px 8px 8px 16px; }
  .search__go { padding: 9px 16px; }
  .brand__word { font-size: 1.15rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}

/* 不支援 backdrop-filter 的備援 */
@supports not (backdrop-filter: blur(1px)) {
  .glass { background: rgba(18, 28, 46, 0.92); }
  .glass-strong, .menu, .sheet { background: rgba(13, 21, 36, 0.97); }
  html[data-theme="light"] .glass { background: rgba(255, 255, 255, 0.94); }
  html[data-theme="light"] .glass-strong { background: rgba(250, 252, 255, 0.98); }
}
