/*
 * 緊湊 dashboard + Apple Liquid Glass（跟 "Adopting Liquid Glass"）
 * - 顏色：iOS 語意色（label、separator、fill、系統藍 / 紅）
 * - 背景：固定嘅柔和漸變光暈，令玻璃 / material 有嘢可以透出嚟
 * - 內容層：standard material（模糊半透明，冇高光邊）
 * - 控制項 / 導航層：Liquid Glass（高光邊、浮起）；主要動作用藍色染色玻璃
 * - 唔疊玻璃：篩選列變成玻璃膠囊時，入面嘅控制項改用普通填色
 * - 「減少透明度」/「增加對比」時轉返實色
 */
:root {
  color-scheme: light;
  --page: #eef0f6;
  --label: #000000;
  --label-2: rgba(60, 60, 67, 0.64);          /* secondaryLabel（稍為加深，喺玻璃上面都夠對比） */
  --label-3: rgba(60, 60, 67, 0.32);
  --separator: rgba(60, 60, 67, 0.2);
  --grid: rgba(60, 60, 67, 0.1);
  --fill: rgba(118, 118, 128, 0.12);
  --blue: #4f46e5;                             /* 主色（文字 / 圖示；靛紫），白色玻璃上對比 6:1 */
  --accent-top: #8b7cf8;
  --accent-bottom: #5b5bf0;
  --accent-glow: rgba(99, 102, 241, 0.34);
  --accent-soft: rgba(99, 102, 241, 0.13);
  --red: #ef4444;
  --green-text: #1f7a36;
  --red-text: #d70015;
  --orange-text: #c93400;
  --series-1: #6366f1;
  --series-neg: #ef4444;

  /* 玻璃 */
  --glass: rgba(255, 255, 255, 0.58);          /* regular：內容面板 */
  --glass-strong: rgba(255, 255, 255, 0.82);   /* 需要遮住下面內容（標註、貼頂欄、sticky 欄） */
  --glass-clear: rgba(255, 255, 255, 0.38);    /* clear：控制項 */
  --glass-rim-hi: rgba(255, 255, 255, 0.9);
  --glass-rim-lo: rgba(255, 255, 255, 0.2);
  --glass-shadow: 0 1px 2px rgba(15, 23, 42, 0.05), 0 8px 24px rgba(15, 23, 42, 0.07);
  --blur: saturate(180%) blur(22px);
  --thumb: rgba(255, 255, 255, 0.95);

  --rounded: ui-rounded, "SF Pro Rounded", -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  --radius: 16px;
  --margin: 12px;
  --gap: 10px;
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --page: #06070b;
    --label: #ffffff;
    --label-2: rgba(235, 235, 245, 0.66);
    --label-3: rgba(235, 235, 245, 0.3);
    --separator: rgba(235, 235, 245, 0.14);
    --grid: rgba(235, 235, 245, 0.08);
    --fill: rgba(118, 118, 128, 0.26);
    --blue: #a5b4fc;
    --accent-top: #9d8cff;
    --accent-bottom: #6366f1;
    --accent-glow: rgba(124, 127, 247, 0.4);
    --accent-soft: rgba(129, 140, 248, 0.2);
    --red: #ef4444;
    --green-text: #30d158;
    --red-text: #ff6961;
    --orange-text: #ff9f0a;
    --series-1: #7c7ff7;
    --series-neg: #ef4444;

    --glass: rgba(30, 30, 34, 0.55);
    --glass-strong: rgba(28, 28, 32, 0.86);
    --glass-clear: rgba(255, 255, 255, 0.08);
    --glass-rim-hi: rgba(255, 255, 255, 0.28);
    --glass-rim-lo: rgba(255, 255, 255, 0.04);
    --glass-shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.35);
    --thumb: rgba(255, 255, 255, 0.22);
  }
}
@media (min-width: 740px) { :root { --margin: 20px; --gap: 12px; } }

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--page);
  color: var(--label);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", "PingFang HK", "Microsoft JhengHei", system-ui, sans-serif;
  font-size: 15px; line-height: 20px; letter-spacing: -0.015em;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
/* 固定嘅漸變光暈背景：捲動時玻璃下面透出嘅顏色會慢慢變 */
body::before {
  content: ""; position: fixed; inset: -10vmax; z-index: -1; pointer-events: none;
  background:
    radial-gradient(38vmax 30vmax at 12% 8%, rgba(99, 102, 241, 0.26), transparent 70%),
    radial-gradient(34vmax 28vmax at 88% 16%, rgba(192, 132, 252, 0.24), transparent 70%),
    radial-gradient(40vmax 32vmax at 72% 80%, rgba(56, 189, 248, 0.18), transparent 70%),
    radial-gradient(30vmax 26vmax at 16% 90%, rgba(244, 114, 182, 0.14), transparent 70%);
}
@media (prefers-color-scheme: dark) {
  body::before {
    background:
      radial-gradient(38vmax 30vmax at 12% 8%, rgba(99, 102, 241, 0.36), transparent 70%),
      radial-gradient(34vmax 28vmax at 88% 16%, rgba(168, 85, 247, 0.28), transparent 70%),
      radial-gradient(40vmax 32vmax at 72% 80%, rgba(56, 189, 248, 0.16), transparent 70%),
      radial-gradient(30vmax 26vmax at 16% 90%, rgba(236, 72, 153, 0.14), transparent 70%);
  }
}
button, input, select { font: inherit; color: inherit; letter-spacing: inherit; }
a { color: inherit; text-decoration: none; }
.wrap {
  max-width: 1180px; margin: 0 auto;
  padding-left: max(var(--margin), env(safe-area-inset-left));
  padding-right: max(var(--margin), env(safe-area-inset-right));
}

/* ---------- 內容層：standard material ---------- */
.glass, .tile, .group, .list {
  position: relative;
  background: var(--glass);
  -webkit-backdrop-filter: var(--blur);
  backdrop-filter: var(--blur);
  border-radius: var(--radius);
  box-shadow: var(--glass-shadow);
}
/* ---------- 控制層：Liquid Glass 高光邊（光由左上打落嚟，邊緣由亮到暗） ---------- */
.btn::before, .seg::before, .picker-wrap::before, .toolbar-inner::before, .callout::before, .tabbar-inner::before {
  content: ""; position: absolute; inset: 0; border-radius: inherit; padding: 1px; pointer-events: none;
  background: linear-gradient(145deg, var(--glass-rim-hi), var(--glass-rim-lo) 38%, var(--glass-rim-lo) 62%, var(--glass-rim-hi));
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask: linear-gradient(#000 0 0) content-box exclude, linear-gradient(#000 0 0);
}

/* 字級（緊湊） */
.page-title { font-size: 22px; line-height: 28px; font-weight: 700; letter-spacing: -0.012em; margin: 0; }
.title3 { font-size: 15px; line-height: 20px; font-weight: 600; letter-spacing: -0.015em; margin: 0; }
.headline { font-size: 15px; line-height: 20px; font-weight: 600; }
.subhead { font-size: 14px; line-height: 19px; letter-spacing: -0.01em; }
.footnote { font-size: 12px; line-height: 16px; letter-spacing: 0; }
.caption { font-size: 11px; line-height: 14px; letter-spacing: 0.005em; }
.secondary { color: var(--label-2); }
.num { font-family: var(--rounded); font-variant-numeric: tabular-nums; }

/* ---------- 標題列 ---------- */
.page-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding-top: calc(12px + env(safe-area-inset-top)); padding-bottom: 6px;
}

/* 掣：藍色染色玻璃（主要動作）/ clear 玻璃 */
.btn {
  position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 32px; padding: 0 14px; border: 0; border-radius: 980px; cursor: pointer;
  background: linear-gradient(180deg, var(--accent-top), var(--accent-bottom)); color: #fff;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.45), inset 0 -1px 0 rgba(0, 0, 0, 0.12), 0 6px 18px var(--accent-glow);
  font-size: 14px; font-weight: 600;
  transition: transform 0.15s cubic-bezier(0.22, 1, 0.36, 1);
}
.btn::after { content: ""; position: absolute; inset: -6px; } /* 可撳範圍達 44px */
.btn.plain { background: transparent; box-shadow: none; color: var(--blue); padding: 0 4px; font-weight: 500; }
.btn.plain::before { display: none; }
.btn.tinted { background: var(--glass-clear); color: var(--blue); box-shadow: none; }
.btn:active { transform: scale(0.96); }
.btn:disabled { opacity: 0.45; cursor: default; }

/* ---------- 篩選列：捲動後變成浮起嘅玻璃膠囊 ---------- */
.toolbar {
  position: sticky; top: calc(8px + env(safe-area-inset-top)); z-index: 9;
  margin: 4px 0 0;
}
.toolbar-inner {
  position: relative; display: flex; align-items: center; gap: 8px; padding: 4px;
  border-radius: 980px; transition: background 0.25s, box-shadow 0.25s;
}
.toolbar-inner::before { opacity: 0; transition: opacity 0.25s; }
.toolbar.stuck .toolbar-inner {
  background: var(--glass-strong);
  -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur);
  box-shadow: var(--glass-shadow);
}
.toolbar.stuck .toolbar-inner::before { opacity: 1; }
/* 唔疊玻璃：膠囊入面嘅控制項改用普通填色 */
.toolbar.stuck .seg, .toolbar.stuck .picker { background-color: var(--fill); -webkit-backdrop-filter: none; backdrop-filter: none; }
.toolbar.stuck .seg::before, .toolbar.stuck .picker-wrap::before { display: none; }
/* Scroll edge effect：捲到篩選列下面嘅內容淡出 */
.toolbar::after {
  content: ""; position: absolute; z-index: -1; pointer-events: none; opacity: 0; transition: opacity 0.25s;
  left: calc(-1 * var(--margin)); right: calc(-1 * var(--margin));
  top: calc(-8px - env(safe-area-inset-top)); height: calc(100% + 26px + env(safe-area-inset-top));
  background: linear-gradient(var(--page) 45%, transparent);
}
.toolbar.stuck::after { opacity: 0.85; }

/* 分段控制：clear 玻璃軌道 + 滑動嘅玻璃滑塊 */
.seg {
  position: relative; display: grid; grid-auto-columns: 1fr; grid-auto-flow: column;
  padding: 2px; border-radius: 980px; background: var(--glass-clear); flex: 1; max-width: 340px;
  -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur);
}
.seg-thumb {
  position: absolute; top: 2px; bottom: 2px; left: 2px; border-radius: 980px;
  background: var(--thumb); box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12), inset 0 0.5px 0 rgba(255, 255, 255, 0.9);
  transition: transform 0.35s cubic-bezier(0.22, 1, 0.36, 1);
}
.seg button {
  position: relative; z-index: 1; border: 0; background: transparent; cursor: pointer;
  min-height: 28px; padding: 0 6px; font-size: 13px; line-height: 18px; font-weight: 500; white-space: nowrap;
}
.seg button[aria-pressed="true"] { font-weight: 600; }
.seg button::after { content: ""; position: absolute; inset: -8px 0; } /* 44px 可撳範圍 */

/* 平台篩選：原生選單（iOS 會用系統 picker），包喺 clear 玻璃膠囊入面 */
.picker-wrap { position: relative; flex: none; border-radius: 980px; }
.picker {
  appearance: none; -webkit-appearance: none; border: 0; cursor: pointer;
  min-height: 32px; padding: 0 26px 0 12px; border-radius: 980px;
  background-color: var(--glass-clear);
  -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur);
  font-size: 13px; font-weight: 500;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%23888' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center;
}

/* ---------- 內容 ---------- */
main { padding-bottom: calc(32px + env(safe-area-inset-bottom)); transition: opacity 0.2s; }
main.loading { opacity: 0.55; }
.section { margin-top: 18px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin: 0 4px 6px; }
.group { padding: 12px 14px; min-width: 0; }
.footer-note { margin: 6px 6px 0; }

/* 摘要 */
.summary-line { margin: 0 4px 8px; }
.tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--gap); }
.tile { padding: 10px 12px; min-width: 0; }
.tile-value { font-family: var(--rounded); font-size: 20px; line-height: 25px; font-weight: 700; margin-top: 2px; overflow-wrap: anywhere; }
.tile-value .approx { font-size: 12px; }

/* 走勢 */
.detail-top { display: flex; align-items: center; gap: 8px; }
.account-picker {
  appearance: none; -webkit-appearance: none; border: 0; background: transparent; cursor: pointer;
  font-size: 15px; font-weight: 600; padding: 0 18px 0 0; min-height: 36px; min-width: 0; max-width: 100%;
  text-overflow: ellipsis; color: var(--label);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='7'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%23007aff' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 2px center;
}
.account-picker option, .picker option { background: var(--page); color: var(--label); }
.account-picker:focus, .picker:focus { outline: none; }
.account-picker:focus-visible, .picker:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; border-radius: 8px; }
.stat-caption { text-transform: uppercase; }
.stat-line { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 10px; }
.stat-value { font-family: var(--rounded); font-size: 22px; line-height: 28px; font-weight: 700; }
.chart { position: relative; width: 100%; touch-action: pan-y; -webkit-user-select: none; user-select: none; }
.chart-block { margin-top: 8px; }
.chart-block + .chart-block { margin-top: 12px; padding-top: 10px; border-top: 0.5px solid var(--separator); }
.chart-block.scrubbing > :not(.chart) { visibility: hidden; }
.chart-svg { display: block; overflow: visible; outline: none; }
.chart-svg .grid { stroke: var(--grid); stroke-width: 1; }
.chart-svg .baseline { stroke: var(--separator); stroke-width: 1; }
.chart-svg .tick { fill: var(--label-2); font-size: 10px; font-variant-numeric: tabular-nums; }
.chart-svg .rule { stroke: var(--label-3); stroke-width: 1.5; }
.chart-svg .ring { stroke: var(--glass-strong); stroke-width: 2; }
.chart-svg .hit { cursor: pointer; }
.chart-svg:focus-visible { outline: 2px solid var(--blue); outline-offset: 4px; border-radius: 6px; }
.chart-empty { color: var(--label-2); font-size: 13px; padding: 24px 0; text-align: center; }
/* 選中位置嘅標註：浮起嘅玻璃 */
.callout {
  position: absolute; top: 0; left: 0; z-index: 2; pointer-events: none; white-space: nowrap;
  background: var(--glass-strong); -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur);
  border-radius: 10px; padding: 4px 9px; box-shadow: var(--glass-shadow);
}
.callout-caption { font-size: 10px; line-height: 13px; color: var(--label-2); text-transform: uppercase; }
.callout-value { font-family: var(--rounded); font-size: 16px; line-height: 20px; font-weight: 700; }
.callout-date { font-size: 10px; line-height: 13px; color: var(--label-2); }

/* 共用 */
.approx { font-size: 0.65em; font-weight: 600; color: var(--label-2); margin-right: 2px; font-family: -apple-system, BlinkMacSystemFont, system-ui, sans-serif; }
.up { color: var(--green-text); }
.down { color: var(--red-text); }
.flat, .na { color: var(--label-2); }

/* 每日變化熱圖 */
.scroll-x { overflow-x: auto; margin: 0 -14px; padding: 0 14px; -webkit-overflow-scrolling: touch; }
table { border-collapse: separate; border-spacing: 2px; width: 100%; font-size: 12px; line-height: 16px; font-variant-numeric: tabular-nums; }
th, td { padding: 5px 7px; text-align: right; white-space: nowrap; }
th { color: var(--label-2); font-weight: 600; font-size: 11px; vertical-align: bottom; }
th:first-child, td:first-child { text-align: left; }
.heat td.cell { border-radius: 6px; min-width: 52px; font-family: var(--rounded); font-weight: 500; }
.heat .th-name { display: flex; align-items: center; justify-content: flex-end; gap: 4px; max-width: 120px; margin-left: auto; }
.heat .th-name span:last-child { overflow: hidden; text-overflow: ellipsis; }
.sticky { position: sticky; left: 0; z-index: 1; background: var(--glass-strong); border-radius: 6px; }

/* 管理列表（撳「編輯」先可以刪除） */
.row { display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 6px 14px; position: relative; }
.row + .row::before { content: ""; position: absolute; top: 0; right: 0; left: 42px; border-top: 0.5px solid var(--separator); }
.row-main { flex: 1; min-width: 0; }
.row-title { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.row-sub { color: var(--label-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-value { font-family: var(--rounded); font-weight: 600; text-align: right; white-space: nowrap; }
.row .brand, .watch-row .brand { flex: none; }
.minus {
  flex: none; width: 20px; height: 20px; border-radius: 50%; border: 0; padding: 0; cursor: pointer;
  background: var(--red); position: relative;
}
.minus::before { content: ""; position: absolute; left: 5px; right: 5px; top: 9px; height: 2px; border-radius: 1px; background: #fff; }
.minus::after { content: ""; position: absolute; inset: -12px; }
.row .delete {
  flex: none; align-self: stretch; margin: -6px -14px -6px 0; padding: 0 16px; border: 0; cursor: pointer;
  background: var(--red); color: #fff; font-weight: 600; font-size: 14px;
}
.list > .row:first-child .delete { border-top-right-radius: var(--radius); }
.row.add-row { color: var(--blue); cursor: pointer; }
.add-form { display: flex; gap: 8px; width: 100%; }
.add-form input {
  flex: 1; min-width: 0; min-height: 32px; padding: 0 12px; border-radius: 10px; border: 0;
  background: var(--fill); font-size: 15px;
}
.add-form input:focus { outline: 2px solid var(--blue); outline-offset: 0; }
.preview { padding: 0 14px 12px; }
.preview:empty { display: none; }
.preview-card { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; background: var(--glass-clear); border-radius: 12px; padding: 10px 12px; }
.err { color: var(--orange-text); }

/* ---------- 手機 ---------- */
@media (max-width: 739px) {
  :root { --radius: 14px; }
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tile-value { font-size: 18px; line-height: 22px; }
  .seg { max-width: none; }
}

/* ---------- 無障礙：減少透明度 / 增加對比 → 實色；減少動態 ---------- */
@media (prefers-reduced-transparency: reduce), (prefers-contrast: more) {
  :root { --glass: #ffffff; --glass-strong: #ffffff; --glass-clear: #e5e5ea; --separator: rgba(60, 60, 67, 0.36); }
  body::before { display: none; }
}
@media (prefers-color-scheme: dark) and (prefers-reduced-transparency: reduce), (prefers-color-scheme: dark) and (prefers-contrast: more) {
  :root { --glass: #1c1c1e; --glass-strong: #1c1c1e; --glass-clear: #2c2c2e; --separator: rgba(84, 84, 88, 0.8); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; }
}

/* ---------- 分頁 tab bar（Liquid Glass；手機喺底部浮起，電腦喺頁頂中間） ---------- */
.head-title { min-width: 0; }
.tabbar-inner {
  position: relative; display: grid; grid-template-columns: repeat(4, 1fr); padding: 4px; border-radius: 980px;
  background: var(--glass-strong); -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur);
  box-shadow: var(--glass-shadow);
}
.tab {
  position: relative; z-index: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px;
  min-height: 44px; min-width: 64px; padding: 4px 10px; border-radius: 980px;
  color: var(--label-2); font-size: 10px; line-height: 12px; font-weight: 600;
  transition: color 0.2s;
}
.tab svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tab[aria-current="page"] { color: var(--blue); }
.tab:active { transform: scale(0.94); }
/* 選中嘅 tab 後面有一粒玻璃滑塊 */
.tab-thumb {
  position: absolute; top: 4px; bottom: 4px; left: 4px; width: calc((100% - 8px) / 4); border-radius: 980px;
  background: var(--accent-soft); box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.5);
  transition: transform 0.4s cubic-bezier(0.22, 1, 0.36, 1);
}
.page { animation: page-in 0.25s cubic-bezier(0.22, 1, 0.36, 1); }
@keyframes page-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .page { animation: none; } .tab-thumb { transition: none; } }

@media (max-width: 739px) {
  .tabbar {
    position: fixed; z-index: 20; left: 50%; transform: translateX(-50%);
    bottom: calc(10px + env(safe-area-inset-bottom)); width: min(360px, calc(100% - 24px));
  }
  main { padding-bottom: calc(96px + env(safe-area-inset-bottom)); }
}
@media (min-width: 740px) {
  .page-head { display: grid; grid-template-columns: 1fr auto 1fr; }
  .page-head .btn { justify-self: end; }
  .tab { flex-direction: row; gap: 6px; font-size: 13px; line-height: 18px; min-height: 36px; padding: 0 14px; }
  .tab svg { width: 18px; height: 18px; }
}

/* ---------- 選單觸發掣（取代原生 select） ---------- */
.picker { display: inline-flex; align-items: center; gap: 6px; background-image: none; padding-right: 12px; color: var(--label); }
.chev { width: 10px; height: 6px; flex: none; opacity: 0.6; transition: transform 0.25s cubic-bezier(0.22, 1, 0.36, 1); }
[aria-expanded="true"] > .chev { transform: rotate(180deg); }
.account-trigger {
  display: inline-flex; align-items: center; gap: 6px; min-width: 0;
  border: 0; background: transparent; cursor: pointer; min-height: 36px; padding: 0 8px 0 0;
  font-size: 15px; font-weight: 600; color: var(--label);
}
.account-trigger .label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-trigger .chev { opacity: 1; color: var(--blue); }
.account-trigger:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; border-radius: 10px; }

/* ---------- 選單：手機 bottom sheet / 電腦 popover ---------- */
.picker-layer { position: fixed; inset: 0; z-index: 50; }
.picker-backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, 0); transition: background 0.3s; }
.picker-panel {
  position: absolute; display: flex; flex-direction: column; overflow: hidden;
  background: var(--glass-strong); -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.18), 0 0 0 0.5px var(--separator);
}
.picker-list { overflow-y: auto; overscroll-behavior: contain; padding: 4px; }
.picker-item {
  display: flex; align-items: center; gap: 10px; width: 100%; border: 0; background: transparent; cursor: pointer;
  text-align: left; color: var(--label); border-radius: 10px; padding: 0 10px; min-height: 36px;
}
.picker-item:hover, .picker-item:focus-visible { background: var(--fill); outline: none; }
.picker-item:active { background: var(--accent-soft); }
.picker-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.picker-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.picker-sub { font-size: 11px; line-height: 14px; color: var(--label-2); font-family: var(--rounded); font-weight: 400; }
.picker-check { width: 16px; height: 16px; flex: none; }
.picker-item[aria-selected="true"] { color: var(--blue); font-weight: 600; }
.picker-item[aria-selected="true"] .picker-check { background: currentColor; -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M3 8.5l3.2 3L13 4.5' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat; mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M3 8.5l3.2 3L13 4.5' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat; }
/* 電腦：由上方輕微放大淡入 */
.is-popover .picker-panel {
  border-radius: 14px; opacity: 0; transform: translateY(-4px) scale(0.97); transform-origin: top left;
  transition: opacity 0.16s ease-out, transform 0.2s cubic-bezier(0.22, 1, 0.36, 1);
}
.is-popover.open .picker-panel { opacity: 1; transform: none; }
/* 手機：由底部推上嚟，大行距方便手指撳 */
.is-sheet .picker-panel {
  left: 8px; right: 8px; bottom: calc(8px + env(safe-area-inset-bottom)); max-height: 70vh;
  border-radius: 28px; transform: translateY(calc(100% + 20px));
  transition: transform 0.38s cubic-bezier(0.22, 1, 0.36, 1);
}
.is-sheet.open .picker-panel { transform: none; }
.is-sheet.open .picker-backdrop { background: rgba(0, 0, 0, 0.28); }
.is-sheet .picker-list { padding: 4px 8px 8px; }
.is-sheet .picker-item { min-height: 50px; padding: 0 14px; border-radius: 16px; }
.is-sheet .picker-label { font-size: 16px; }
.sheet-handle { width: 36px; height: 5px; border-radius: 3px; background: var(--label-3); margin: 8px auto 4px; flex: none; }
.sheet-title { text-align: center; font-size: 13px; font-weight: 600; color: var(--label-2); padding: 2px 0 6px; flex: none; }
html.sheet-open { overflow: hidden; }

/* ---------- toast（頁頂玻璃提示） ---------- */
.toast-host {
  position: fixed; z-index: 60; left: 50%; transform: translateX(-50%); top: calc(10px + env(safe-area-inset-top));
  display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none;
  width: max-content; max-width: calc(100% - 24px);
}
.toast {
  display: flex; align-items: center; gap: 8px; padding: 9px 14px 9px 12px; border-radius: 980px;
  background: var(--glass-strong); -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.16), 0 0 0 0.5px var(--separator);
  font-size: 13px; font-weight: 500; line-height: 18px;
  opacity: 0; transform: translateY(-12px) scale(0.96);
  transition: opacity 0.2s, transform 0.35s cubic-bezier(0.22, 1, 0.36, 1);
}
.toast.show { opacity: 1; transform: none; }
.toast-icon { width: 16px; height: 16px; border-radius: 50%; flex: none; box-sizing: border-box; }
.toast[data-tone="success"] .toast-icon { background: #22c55e; box-shadow: inset 0 0 0 4px #bbf7d0; }
.toast[data-tone="error"] .toast-icon { background: var(--red); }
.toast[data-tone="info"] .toast-icon { background: var(--accent-bottom); }
.toast.loading .toast-icon, .spinner {
  background: none; box-shadow: none; border: 2px solid var(--accent-soft); border-top-color: var(--accent-bottom);
  border-radius: 50%; animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- 更新中：掣入面轉圈 + 頁頂流動進度條 ---------- */
.btn .spinner { width: 14px; height: 14px; border-color: rgba(255, 255, 255, 0.35); border-top-color: #fff; }
.progress { position: fixed; z-index: 70; top: 0; left: 0; right: 0; height: 3px; pointer-events: none; overflow: hidden; opacity: 0; transition: opacity 0.3s; }
.progress.active { opacity: 1; }
.progress::before {
  content: ""; position: absolute; top: 0; bottom: 0; width: 40%; border-radius: 3px;
  background: linear-gradient(90deg, transparent, var(--accent-top), var(--accent-bottom), transparent);
  animation: progress 1.2s cubic-bezier(0.4, 0, 0.2, 1) infinite;
}
@keyframes progress { from { left: -40%; } to { left: 100%; } }

/* ---------- 有變化嘅卡片亮一下 ---------- */
.flash { animation: flash 1.4s ease-out; }
@keyframes flash {
  0% { box-shadow: 0 0 0 2px var(--accent-bottom), 0 0 24px var(--accent-glow); }
  100% { box-shadow: var(--glass-shadow); }
}

/* ---------- skeleton（第一次載入） ---------- */
.skeleton { overflow: hidden; }
.bone { display: block; border-radius: 6px; background: var(--fill); }
.skeleton::before {
  content: ""; position: absolute; inset: 0; border-radius: inherit; z-index: 1;
  background: linear-gradient(100deg, transparent 30%, rgba(255, 255, 255, 0.35) 50%, transparent 70%);
  background-size: 200% 100%; animation: shimmer 1.3s linear infinite;
}
@keyframes shimmer { from { background-position: 150% 0; } to { background-position: -50% 0; } }
@media (prefers-reduced-motion: reduce) {
  .skeleton::before, .progress::before, .toast.loading .toast-icon, .spinner, .flash { animation: none; }
}

/* ---------- 帳戶觀察清單（Stocks 式；20+ 個帳戶都一屏睇到） ---------- */
.watch { display: grid; grid-template-columns: minmax(0, 1fr); padding: 2px 0; }
.watch-row {
  position: relative; display: flex; align-items: center; gap: 10px; width: 100%; min-height: 44px; padding: 0 14px;
  border: 0; background: transparent; color: inherit; font: inherit; text-align: left; cursor: pointer;
  transition: background 0.15s;
}
.watch-row::before { content: ""; position: absolute; top: 0; right: 14px; left: 46px; border-top: 0.5px solid var(--separator); }
.watch > .watch-row:first-child::before { display: none; }
.watch-row:hover { background: var(--fill); }
.watch-row:active { background: var(--accent-soft); }
.watch-row:focus-visible { outline: 2px solid var(--blue); outline-offset: -2px; border-radius: 10px; }
.watch-row[aria-current="true"] .watch-title { color: var(--blue); }
.watch-name { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.watch-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; font-weight: 500; }
.watch-err { font-size: 11px; line-height: 13px; color: var(--orange-text); }
.watch-spark { flex: none; width: 56px; height: 24px; }
.watch-value { flex: none; min-width: 58px; text-align: right; font-family: var(--rounded); font-weight: 600; font-size: 14px; }
.pill {
  flex: none; min-width: 58px; padding: 3px 8px; border-radius: 8px; text-align: right;
  font-family: var(--rounded); font-size: 12px; font-weight: 700; line-height: 16px; font-variant-numeric: tabular-nums;
}
.pill.up { color: var(--green-text); background: color-mix(in srgb, #22c55e 16%, transparent); }
.pill.down { color: var(--red-text); background: color-mix(in srgb, #ef4444 14%, transparent); }
.pill.flat { color: var(--label-2); background: var(--fill); }
.watch-more {
  grid-column: 1 / -1; min-height: 44px; border: 0; background: transparent; cursor: pointer;
  color: var(--blue); font: inherit; font-size: 14px; font-weight: 500; border-top: 0.5px solid var(--separator);
}
.sort-btn { font-size: 13px; }
.add-badge {
  display: inline-flex; align-items: center; justify-content: center; flex: none; width: 20px; height: 20px; border-radius: 6px;
  background: linear-gradient(180deg, var(--accent-top), var(--accent-bottom)); color: #fff; font-size: 15px; font-weight: 700;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.4);
}
/* 電腦：分兩欄，20 個帳戶大約 10 行 */
@media (min-width: 740px) {
  .watch { grid-template-columns: repeat(2, minmax(0, 1fr)); grid-template-rows: repeat(var(--rows, 1), auto); grid-auto-flow: column; }
  .watch-row.col-start::before { display: none; }
  .watch-row.col-left { border-right: 0.5px solid var(--separator); }
}
@media (min-width: 1100px) {
  .watch-spark { width: 80px; }
}
@media (max-width: 380px) {
  .watch-spark { display: none; }
}

/* 選單搜尋框（選項多過 8 個先出現） */
.picker-search {
  flex: none; margin: 8px 8px 4px; min-height: 34px; padding: 0 12px; border: 0; border-radius: 10px;
  background: var(--fill); font-size: 14px; color: var(--label);
}
.is-sheet .picker-search { margin: 0 14px 6px; min-height: 40px; font-size: 16px; } /* 16px 避免 iOS 自動放大 */
.picker-search:focus { outline: 2px solid var(--blue); outline-offset: 0; }
.picker-empty { padding: 14px; text-align: center; font-size: 13px; color: var(--label-2); }

/* ---------- 品牌 icon ---------- */
.brand { display: block; flex: none; }
.brand.threads { color: var(--label); }
.th-name .brand, .detail-top .brand { width: 16px; height: 16px; }

/* ---------- 更新掣：玻璃圓形 icon 掣，更新時箭嘴轉 ---------- */
.icon-btn {
  position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 6px; justify-self: end;
  width: 40px; height: 40px; padding: 0; border: 0; border-radius: 980px; cursor: pointer; color: var(--blue);
  background: var(--glass-strong); -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur);
  box-shadow: var(--glass-shadow);
  transition: transform 0.2s cubic-bezier(0.22, 1, 0.36, 1), color 0.2s;
}
.icon-btn::before {
  content: ""; position: absolute; inset: 0; border-radius: inherit; padding: 1px; pointer-events: none;
  background: linear-gradient(145deg, var(--glass-rim-hi), var(--glass-rim-lo) 38%, var(--glass-rim-lo) 62%, var(--glass-rim-hi));
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0); -webkit-mask-composite: xor;
  mask: linear-gradient(#000 0 0) content-box exclude, linear-gradient(#000 0 0);
}
.icon-btn::after { content: ""; position: absolute; inset: -2px; }
.icon-btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn-label { display: none; font-size: 14px; font-weight: 600; }
.icon-btn:hover { transform: translateY(-1px); }
.icon-btn:active { transform: scale(0.94); }
.icon-btn:focus-visible { outline: 2px solid var(--blue); outline-offset: 3px; }
.icon-btn.spinning { cursor: progress; }
.icon-btn.spinning svg { animation: spin 0.9s linear infinite; }
@media (min-width: 740px) {
  .icon-btn { width: auto; padding: 0 16px 0 13px; }
  .icon-btn-label { display: inline; color: var(--label); }
}

/* ---------- 新增帳戶 dialog ---------- */
.is-dialog .picker-panel {
  left: 50%; top: 50%; width: min(460px, calc(100% - 32px)); max-height: calc(100vh - 64px); border-radius: 24px;
  opacity: 0; transform: translate(-50%, -48%) scale(0.96);
  transition: opacity 0.18s ease-out, transform 0.28s cubic-bezier(0.22, 1, 0.36, 1);
}
.is-dialog.open .picker-panel { opacity: 1; transform: translate(-50%, -50%); }
.is-dialog.open .picker-backdrop { background: rgba(0, 0, 0, 0.24); }
.dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 16px 4px 20px; }
.is-sheet .dialog-head { padding-top: 4px; }
.dialog-title { font-size: 17px; font-weight: 700; }
.dialog-close { position: relative; width: 30px; height: 30px; border: 0; border-radius: 50%; background: var(--fill); cursor: pointer; color: var(--label-2); }
.dialog-close::before, .dialog-close::after { content: ""; position: absolute; left: 9px; right: 9px; top: 14px; height: 2px; border-radius: 1px; background: currentColor; }
.dialog-close::before { transform: rotate(45deg); }
.dialog-close::after { transform: rotate(-45deg); }
.dialog-body { padding: 8px 20px 20px; overflow-y: auto; }
.add-dialog { display: flex; flex-direction: column; gap: 10px; }
.add-platforms { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.add-platforms .footnote { margin-left: 4px; }

/* 輸入框：左邊即時顯示認到嘅平台，右邊清除 / 貼上 */
.field {
  display: flex; align-items: center; gap: 10px; min-height: 50px; padding: 0 8px 0 14px; border-radius: 14px;
  background: var(--fill); box-shadow: inset 0 0 0 1px transparent; transition: box-shadow 0.2s, background 0.2s;
}
.field:focus-within { background: var(--glass-strong); box-shadow: inset 0 0 0 1.5px var(--accent-bottom), 0 0 0 4px var(--accent-soft); }
.field.invalid { box-shadow: inset 0 0 0 1.5px var(--red), 0 0 0 4px color-mix(in srgb, var(--red) 14%, transparent); }
.field-lead { display: flex; flex: none; color: var(--label-2); transition: transform 0.25s cubic-bezier(0.22, 1, 0.36, 1); }
.field.detected .field-lead { transform: scale(1.08); }
.field-input { flex: 1; min-width: 0; border: 0; background: transparent; font-size: 16px; outline: none; color: var(--label); }
.field-input::placeholder { color: var(--label-3); }
.field-clear { position: relative; flex: none; width: 22px; height: 22px; border: 0; border-radius: 50%; background: var(--label-3); cursor: pointer; }
.field-clear::before, .field-clear::after { content: ""; position: absolute; left: 6px; right: 6px; top: 10px; height: 2px; border-radius: 1px; background: var(--page); }
.field-clear::before { transform: rotate(45deg); }
.field-clear::after { transform: rotate(-45deg); }
.field-paste {
  flex: none; min-height: 34px; padding: 0 12px; border: 0; border-radius: 10px; cursor: pointer;
  background: var(--accent-soft); color: var(--blue); font-size: 14px; font-weight: 600;
}
.field-status { display: flex; align-items: center; gap: 6px; min-height: 18px; font-size: 12px; line-height: 16px; color: var(--label-2); padding: 0 4px; }
.field-status .spinner { width: 12px; height: 12px; }
.field-status[data-kind="error"] { color: var(--red-text); }
.field-status[data-kind="ok"] { color: var(--green-text); }
.add-result:empty { display: none; }
.result-card {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 16px;
  background: var(--glass-strong); box-shadow: var(--glass-shadow);
  animation: result-in 0.35s cubic-bezier(0.22, 1, 0.36, 1);
}
@keyframes result-in { from { opacity: 0; transform: translateY(6px) scale(0.98); } to { opacity: 1; transform: none; } }
.result-main { flex: 1; min-width: 0; }
.result-name, .result-key { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.result-add { min-width: 64px; min-height: 34px; }
.result-add .spinner { width: 14px; height: 14px; }
.result-chip { flex: none; padding: 5px 10px; border-radius: 980px; background: var(--fill); color: var(--label-2); font-size: 12px; font-weight: 600; }
.row.add-row { width: 100%; border: 0; background: transparent; font: inherit; text-align: left; color: var(--blue); cursor: pointer; font-weight: 500; }
.row.add-row:hover { background: var(--fill); }
@media (prefers-reduced-motion: reduce) { .icon-btn.spinning svg, .result-card { animation: none; } }

/* ---------- Seeday 字標 ---------- */
.page-title { display: flex; align-items: center; line-height: 0; }
.wordmark { display: block; height: 29px; width: auto; filter: drop-shadow(0 3px 10px var(--accent-glow)); }
@media (min-width: 740px) { .wordmark { height: 32px; } }
