:root {
  --bg: #f6f7f9;
  --card: #ffffff;
  --ink: #1b1f24;
  --muted: #5f6b7a;
  --line: #e2e6eb;
  --accent: #2563eb;
  --new: #2563eb;
  --sold: #16a34a;
  --del: #9ca3af;
  --shelf: #f59e0b;
  --chip: #eef2f7;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111418;
    --card: #1a1f25;
    --ink: #e6e9ed;
    --muted: #97a3b3;
    --line: #2b323b;
    --accent: #60a5fa;
    --new: #60a5fa;
    --sold: #4ade80;
    --del: #6b7280;
    --shelf: #fbbf24;
    --chip: #232a33;
  }
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.6 -apple-system, BlinkMacSystemFont, "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", sans-serif;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.wrap { max-width: 1080px; margin: 0 auto; padding: 0 16px; }
.top { background: var(--card); border-bottom: 1px solid var(--line); padding: 20px 0 14px; }
h1 { margin: 0; font-size: 26px; letter-spacing: .02em; }
h2 { margin: 0; font-size: 17px; }
.sub { margin: 4px 0 0; color: var(--muted); }

.day-bar { display: flex; gap: 8px; align-items: center; margin: 18px 0 12px; flex-wrap: wrap; }
button, input, select {
  font: inherit; color: var(--ink); background: var(--card);
  border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px;
}
button { cursor: pointer; }
button:hover { border-color: var(--accent); }
button:disabled { opacity: .4; cursor: default; }
.ghost { background: transparent; }
.day-bar button { flex-shrink: 0; white-space: nowrap; }
.day-bar input { min-width: 0; max-width: 100%; }
.day-bar button.on { color: var(--accent); border-color: var(--accent); background: var(--chip); font-weight: 650; }

.kpis { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; }
.kpi .label { color: var(--muted); font-size: 13px; }
.kpi .value { font-size: 28px; font-weight: 650; font-variant-numeric: tabular-nums; }
.kpi .note { color: var(--muted); font-size: 12px; }
@media (max-width: 720px) { .kpis { grid-template-columns: repeat(2, 1fr); } }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 16px; margin: 14px 0; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.hint { color: var(--muted); font-size: 12px; margin: 8px 0 0; }
.legend { color: var(--muted); font-size: 13px; display: flex; align-items: center; gap: 6px; }
.sw { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-left: 6px; }
.sw.new { background: var(--new); } .sw.sold { background: var(--sold); } .sw.shelf { background: var(--shelf); height: 3px; }

.chart { width: 100%; overflow-x: auto; }
.chart svg { display: block; width: 100%; min-width: 560px; height: 220px; }
.chart .axis { fill: var(--muted); font-size: 11px; }
.chart .grid { stroke: var(--line); }
.chart .bar-new { fill: var(--new); }
.chart .bar-sold { fill: var(--sold); }
.chart .shelf { fill: none; stroke: var(--shelf); stroke-width: 2; }
.chart .hit { fill: transparent; cursor: pointer; }
.chart .hit:hover, .chart .hit.sel { fill: var(--chip); }

.tabs { display: flex; gap: 4px; flex-wrap: wrap; }
.tabs button { border-radius: 999px; padding: 4px 12px; }
.tabs button.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; }

.scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th, td { text-align: left; padding: 7px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { color: var(--muted); font-weight: 500; font-size: 13px; cursor: pointer; user-select: none; }
th.sorted::after { content: " ▾"; }
th.sorted.asc::after { content: " ▴"; }
td.num, th.num { text-align: right; }
td .est { color: var(--muted); font-size: 12px; }
td.notes { white-space: normal; color: var(--muted); font-size: 13px; min-width: 180px; }

.items { display: grid; gap: 8px; }
.item { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; }
.item .name { font-weight: 600; }
.item .price { font-weight: 650; font-size: 17px; text-align: right; font-variant-numeric: tabular-nums; }
.item .meta { color: var(--muted); font-size: 13px; }
.item .side { text-align: right; }
.chip { display: inline-block; background: var(--chip); border-radius: 999px; padding: 0 8px; font-size: 12px; margin-right: 4px; }
.chip.pm { background: #c2410c; color: #fff; font-weight: 650; }
.st-在售 { color: var(--new); } .st-交易中 { color: var(--shelf); } .st-已售出 { color: var(--sold); } .st-已刪除 { color: var(--del); }
.empty { color: var(--muted); padding: 18px 0; text-align: center; }
.more { display: block; margin: 12px auto 0; }
.watch-shortcut { display: inline-block; margin-top: 10px; font-size: 14px; }
.watch-shortcut span { display: inline-block; min-width: 24px; padding: 0 6px; border-radius: 999px; background: var(--chip); text-align: center; }
.watch-entry { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.watch-entry > div:first-child { min-width: 0; overflow-wrap: anywhere; }
.watch-entry .hint { margin-top: 3px; }
.watch-actions { display: flex; gap: 8px; flex-shrink: 0; }
.watch-actions button, .watch-filter-bar button { min-height: 44px; }
.watch-filter-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 10px; }
.watch-filter-bar .hint { margin: 0; overflow-wrap: anywhere; }
th.watch-column { cursor: default; }
.watch-model { white-space: nowrap; min-width: 44px; min-height: 44px; font-size: 20px; line-height: 1; padding: 0; border: 0; }
.watch-model[aria-pressed="true"] { color: var(--accent); }
button:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
#watchlist, #listings-section { scroll-margin-top: 16px; }
#watch-feedback:not(:empty) { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 5; max-width: calc(100% - 32px); width: max-content; margin: 0; padding: 12px 16px; border: 1px solid var(--line); border-radius: 10px; background: var(--card); color: var(--ink); box-shadow: 0 4px 20px #0002; pointer-events: none; }
@media (max-width: 540px) {
  .watch-entry { align-items: flex-start; flex-direction: column; }
  .watch-actions { align-self: flex-end; }
}
.foot { color: var(--muted); font-size: 13px; padding-bottom: 32px; }
[hidden] { display: none !important; }

/* 機型頁 */
.back { font-size: 14px; }
.model-title { display: flex; align-items: center; gap: 4px; margin-top: 6px; }
.storage-tabs { margin: 18px 0 12px; }
.storage-tabs button { min-height: 40px; padding: 4px 14px; }
.storage-tabs .count { color: var(--muted); font-size: 12px; margin-left: 2px; }
.storage-tabs button.on .count { color: inherit; opacity: .85; }
#model-main .kpis { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 720px) { #model-main .kpis { grid-template-columns: repeat(2, 1fr); } }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-left: 6px; background: currentColor; }
#model-main .chart svg { height: 240px; }
.chart .pt { fill: currentColor; fill-opacity: .75; stroke: var(--card); stroke-width: 1; }
.chart a:hover .pt { fill-opacity: 1; stroke: var(--ink); }
.chart .median { stroke: var(--muted); stroke-dasharray: 4 4; }
.linkish { border: 0; padding: 0; background: none; color: var(--accent); }
.linkish:hover { text-decoration: underline; }
#compare tr.current td { background: var(--chip); }
#compare th { cursor: default; }

/* 每週專欄 */
.column-link { margin-left: 12px; }
.column .crumbs { color: var(--muted); font-size: 14px; }
.col-article { max-width: 760px; margin: 18px auto; padding: 20px 22px; line-height: 1.85; font-size: 16px; }
.col-article h1 { font-size: 24px; line-height: 1.45; margin: 6px 0 2px; }
.col-article h2 { font-size: 19px; margin: 28px 0 8px; padding-left: 10px; border-left: 4px solid var(--accent); line-height: 1.45; }
.col-article p { margin: 10px 0; }
.col-article .issue { display: inline-block; margin: 0; font-size: 13px; font-weight: 650; color: #fff; background: var(--accent); border-radius: 999px; padding: 1px 10px; }
.col-article .points { border: 2px solid var(--accent); border-radius: 10px; padding: 2px 16px 8px; margin: 16px 0; }
.col-article .points h2 { border: 0; padding: 0; margin: 10px 0 4px; font-size: 16px; color: var(--accent); }
.col-article .points ul, .col-article .toc ol { margin: 0; padding-left: 1.3em; }
.col-article .toc { background: var(--chip); border-radius: 10px; padding: 6px 16px 10px; margin: 16px 0; }
.col-article .toc-title { font-weight: 650; margin: 4px 0; }
.col-article table { font-size: 14px; margin-top: 8px; }
.col-article caption { text-align: left; color: var(--muted); font-size: 13px; padding-bottom: 4px; }
.col-article th { cursor: default; }
.col-article tbody th { color: var(--ink); font-weight: 600; font-size: 14px; }
.col-article .faq dt { font-weight: 650; margin-top: 12px; }
.col-article .faq dd { margin: 4px 0 0; }
.back-issues { max-width: 760px; margin: 14px auto; }
.back-issues ul { margin: 8px 0 0; padding-left: 1.2em; line-height: 1.9; }
.back-issues a[aria-current] { font-weight: 650; color: var(--ink); }
@media (max-width: 540px) { .col-article { padding: 16px; font-size: 15px; } .col-article h1 { font-size: 21px; } }

/* 機型頁的 Apple 原廠區塊 */
.apple .muted { color: var(--muted); font-size: 12px; }
.apple .buy { font-weight: 600; text-decoration: none; }
.apple .buy:hover { text-decoration: underline; }

/* 顏色比較用文字標示，不以機身顏色作背景。 */
.color-chip { border: 1px solid var(--line); color: var(--ink); white-space: normal; }
.color-card table { width: 100%; min-width: 0; }
.color-best { margin: 0 0 14px; font-weight: 600; }
.relative-low { color: #16733c; font-weight: 650; }
.relative-high { color: #b64025; font-weight: 650; }
@media (prefers-color-scheme: dark) {
  .relative-low { color: #79dda1; }
  .relative-high { color: #ffab91; }
}
@media (max-width: 600px) {
  .color-card thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .color-card table, .color-card tbody, .color-card tr { display: block; }
  .color-card tr { padding: 10px 0; border-bottom: 1px solid var(--line); }
  .color-card td { display: flex; justify-content: space-between; gap: 12px; padding: 3px 0; border: 0; white-space: normal; }
  .color-card td::before { content: attr(data-label); color: var(--muted); font-weight: 400; text-align: left; }
  .color-card td:first-child { font-weight: 650; }
}
