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

:root {
  --bg:        #0a0f1e;
  --surface:   #1e293b;
  --surface2:  #0f172a;
  --border:    #334155;
  --text:      #f8fafc;
  --text-2:    #e2e8f0;
  --text-muted:#94a3b8;
  --text-dim:  #64748b;
  --text-faint:#475569;
  --up:        #ef4444;
  --dn:        #22c55e;
  --neutral:   #94a3b8;
  --gold:      #fbbf24;
  --gold-dim:  #78350f;
  --blue:      #38bdf8;
  --orange:    #f97316;
  --purple:    #a78bfa;
  --green:     #22c55e;
  --radius:    14px;
  --radius-sm: 8px;
  --font-mono: 'DM Mono', 'Courier New', monospace;
  --font-sans: 'Noto Sans TC', 'PingFang TC', sans-serif;
  --font-serif:'Noto Serif TC', serif;
}

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior: none;
}

button { font-family: inherit; cursor: pointer; }
a { color: var(--blue); text-decoration: none; }
svg { display: block; }

/* ═══════════════════════════════════════════════════════
   LAYOUT
═══════════════════════════════════════════════════════ */
.site-header {
  background: var(--surface2);
  padding: 13px 16px 10px;
  position: sticky; top: 0; z-index: 200;
  border-bottom: 1px solid var(--border);
}
.header-inner {
  display: flex; justify-content: space-between; align-items: center;
  max-width: 600px; margin: 0 auto;
}
.header-sub   { font-size: 9px; color: #334155; letter-spacing: 2px; }
.header-title { font-size: 16px; font-weight: 900; color: var(--text); font-family: var(--font-serif); }
.header-right { text-align: right; }
.header-date  { font-size: 9px; color: var(--text-faint); margin-top: 3px; }

.live-badge {
  display: inline-flex; align-items: center; gap: 4px;
  background: rgba(34,197,94,.13); border: 1px solid rgba(34,197,94,.3);
  border-radius: 99px; padding: 2px 8px; margin-bottom: 3px;
}
.live-dot {
  width: 5px; height: 5px; background: var(--green);
  border-radius: 50%; display: inline-block;
  animation: pulse 2s infinite;
}
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.4} }

.page-container {
  max-width: 600px; margin: 0 auto;
  padding: 14px 14px 90px;
}

.page { display: none; }
.page.active { display: block; }

.cards-stack { display: flex; flex-direction: column; gap: 14px; }

/* ═══════════════════════════════════════════════════════
   BOTTOM NAV
═══════════════════════════════════════════════════════ */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 300;
  background: var(--surface2); border-top: 1px solid var(--border);
  display: flex; max-width: 600px; margin: 0 auto;
}
.nav-btn {
  flex: 1; padding: 7px 0 10px; border: none;
  background: transparent;
  border-top: 2px solid transparent;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  transition: all .2s;
}
.nav-btn.active {
  background: var(--surface); border-top-color: var(--blue);
}
.nav-icon { font-size: 18px; }
.nav-label { font-size: 9px; color: var(--text-dim); font-weight: 500; }
.nav-btn.active .nav-label { color: var(--blue); font-weight: 800; }

/* ═══════════════════════════════════════════════════════
   CARDS
═══════════════════════════════════════════════════════ */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 15px;
  border: 1px solid rgba(51,65,85,.5);
  box-shadow: 0 2px 16px rgba(0,0,0,.15);
}
.card-gold   { border-color: rgba(251,191,36,.35); box-shadow: 0 2px 16px rgba(251,191,36,.1); }
.card-oil    { border-color: rgba(249,115,22,.35); }
.card-blue   { border-color: rgba(56,189,248,.35); }
.card-green  { border-color: rgba(34,197,94,.35); }
.card-clickable { cursor: pointer; transition: opacity .15s; }
.card-clickable:active { opacity: .85; }

.card-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 10px;
}
.card-title-group { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.card-icon  { font-size: 18px; }
.card-title { font-weight: 900; font-size: 13px; color: var(--text-2); font-family: var(--font-serif); }
.card-period{ font-size: 9px; color: var(--text-dim); }
.card-hint  { font-size: 10px; color: var(--text-dim); }

/* inner dark block */
.inner-block {
  background: var(--surface2);
  border-radius: 10px; padding: 11px 12px; margin-bottom: 8px;
}

/* price row */
.price-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 7px 0; border-bottom: 1px solid var(--surface);
}
.price-row:last-child { border-bottom: none; }
.price-label  { font-size: 13px; font-weight: 700; color: var(--text-2); }
.price-value  { font-size: 18px; font-weight: 900; color: var(--text); font-family: var(--font-mono); }
.price-unit   { font-size: 9px; color: var(--text-dim); margin-left: 3px; }
.price-adj    { font-size: 12px; font-weight: 800; margin-left: 10px; }

/* notice bar */
.notice-bar {
  background: #1e3a5f; border-radius: 8px;
  padding: 7px 10px; font-size: 10px; color: #93c5fd; margin-bottom: 6px;
}

/* two-col grid */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 6px; }

/* stat cell */
.stat-cell {
  background: var(--surface); border-radius: var(--radius-sm); padding: 6px 8px;
}
.stat-label { font-size: 9px; color: var(--text-dim); margin-bottom: 2px; }
.stat-value { font-size: 12px; font-weight: 800; color: var(--text); font-family: var(--font-mono); }

/* chip pair */
.chip-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 5px; flex-shrink: 0; }
.chip {
  background: var(--surface);
  border-radius: var(--radius-sm); padding: 7px 9px; text-align: center; min-width: 66px;
}
.chip-label { font-size: 9px; color: var(--text-dim); margin-bottom: 3px; }
.chip-value { font-size: 11px; font-weight: 900; font-family: var(--font-mono); white-space: nowrap; }

/* price block (gold / fx style) */
.price-block {
  background: var(--surface2); border-radius: 12px;
  padding: 13px 14px; margin-bottom: 10px;
}
.pb-header {
  display: flex; align-items: center; gap: 7px; margin-bottom: 8px;
}
.pb-icon { font-size: 15px; }
.pb-label { font-size: 12px; font-weight: 800; color: var(--text-2); }
.pb-sub   { font-size: 9px; color: var(--text-dim); }
.pb-body  { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.pb-price-wrap { display: flex; align-items: baseline; gap: 5px; min-width: 0; }
.pb-price { font-size: 24px; font-weight: 900; font-family: var(--font-mono); letter-spacing: -.5px; line-height: 1; }
.pb-unit  { font-size: 11px; font-weight: 600; color: var(--text-dim); white-space: nowrap; }
.pb-meta  {
  display: flex; gap: 10px; margin-top: 9px; font-size: 9px; color: var(--text-faint);
  border-top: 1px solid var(--border); padding-top: 7px; flex-wrap: wrap;
}
.pb-divider { color: var(--border); }

/* bid/ask sub-row */
.bidask-row { display: grid; grid-template-columns: 1fr 1fr; gap: 5px; margin-top: 8px; }
.bidask-cell {
  background: var(--surface); border-radius: 7px; padding: 5px 8px;
}
.bidask-label { font-size: 9px; color: var(--text-dim); }
.bidask-value { font-size: 13px; font-weight: 800; font-family: var(--font-mono); }

/* ═══════════════════════════════════════════════════════
   BADGES
═══════════════════════════════════════════════════════ */
.freq-badge {
  border-radius: 4px; font-size: 9px; font-weight: 800;
  padding: 1px 5px; border: 1px solid;
}
.freq-realtime { background: rgba(167,139,250,.13); color: #a78bfa; border-color: rgba(167,139,250,.27); }
.freq-daily    { background: rgba(56,189,248,.13);  color: #38bdf8; border-color: rgba(56,189,248,.27); }
.freq-weekly   { background: rgba(251,191,36,.13);  color: #fbbf24; border-color: rgba(251,191,36,.27); }

.note-badge {
  background: #fef3c7; color: #92400e;
  border: 1px solid #fcd34d; border-radius: 4px;
  font-size: 9px; padding: 1px 5px; font-weight: 600;
}
.conf-badge {
  border-radius: 4px; font-size: 10px; font-weight: 800; padding: 2px 7px; border: 1px solid;
}
.conf-high { background:rgba(34,197,94,.13); color:#22c55e; border-color:rgba(34,197,94,.33); }
.conf-mid  { background:rgba(245,158,11,.13); color:#f59e0b; border-color:rgba(245,158,11,.33); }
.conf-low  { background:rgba(148,163,184,.13); color:#94a3b8; border-color:rgba(148,163,184,.33); }

.season-badge {
  font-size: 9px; border-radius: 4px; padding: 1px 4px; font-weight: 700;
}

/* ═══════════════════════════════════════════════════════
   CHANGE INDICATORS
═══════════════════════════════════════════════════════ */
.chg-up      { color: var(--up); }
.chg-dn      { color: var(--dn); }
.chg-neutral { color: var(--neutral); }

/* ═══════════════════════════════════════════════════════
   DIRECTION HERO (oil prediction)
═══════════════════════════════════════════════════════ */
.dir-hero {
  display: flex; justify-content: space-between;
  align-items: center; margin-bottom: 10px;
}
.dir-left {}
.dir-label-row {
  display: flex; align-items: baseline; gap: 6px; margin-bottom: 4px;
}
.dir-prefix  { font-size: 13px; color: var(--text-dim); }
.dir-value   { font-size: 13px; font-weight: 900; }
.dir-sub     { font-size: 13px; color: var(--text-2); }
.alert-box {
  border-radius: 10px; padding: 8px 10px; text-align: center;
  flex-shrink: 0; border: 1px solid;
}
.alert-icon  { font-size: 22px; }
.alert-label { font-size: 10px; font-weight: 700; margin-top: 2px; }

/* ═══════════════════════════════════════════════════════
   SECTION HEADER (gold / fx detail pages)
═══════════════════════════════════════════════════════ */
.section-header {
  display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px;
}
.section-header-left { display: flex; align-items: center; gap: 8px; }
.section-header-icon { font-size: 20px; }
.section-header-title {
  font-weight: 900; font-size: 14px; color: var(--text-2); font-family: var(--font-serif);
}

/* ═══════════════════════════════════════════════════════
   FOOD ITEMS
═══════════════════════════════════════════════════════ */
.food-row {
  display: flex; justify-content: space-between; align-items: flex-start;
  padding: 10px 0; border-bottom: 1px solid var(--surface2); cursor: pointer;
}
.food-row:last-child { border-bottom: none; }
.food-left { flex: 1; min-width: 0; }
.food-name-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.food-name { font-size: 14px; font-weight: 700; color: var(--text); }
.food-cat  { font-size: 9px; color: var(--text-faint); }
.food-src  { font-size: 9px; color: var(--text-faint); margin-top: 2px; }
.food-right { text-align: right; flex-shrink: 0; margin-left: 10px; }
.food-price-kg  { font-size: 16px; font-weight: 900; font-family: var(--font-mono); }
.food-price-jin { font-size: 13px; font-weight: 700; font-family: var(--font-mono); color: var(--text-muted); }
.food-unit { font-size: 9px; color: var(--text-dim); margin-left: 2px; }

/* filter tabs */
.filter-tabs { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; margin-bottom: 10px; }
.filter-tab {
  flex-shrink: 0; padding: 6px 12px; border-radius: 99px; border: none;
  font-size: 11px; font-weight: 700; transition: all .2s;
  background: var(--surface); color: var(--text-dim);
}
.filter-tab.active { background: #1d4ed8; color: #fff; }

/* ═══════════════════════════════════════════════════════
   FORMULA BLOCK (oil detail)
═══════════════════════════════════════════════════════ */
.formula-block {
  background: var(--surface2); border-radius: 10px;
  padding: 11px 12px; font-family: var(--font-mono);
  font-size: 11px; color: #a5f3fc; line-height: 2;
}
.formula-comment { color: var(--text-faint); }
.formula-result  { color: var(--gold); }
.formula-up   { color: #f87171; }
.formula-dn   { color: #4ade80; }

/* prediction table */
.pred-row {
  display: flex; align-items: center; padding: 7px 0;
  border-bottom: 1px solid var(--surface2); font-size: 12px; gap: 0;
}
.pred-row:last-child { border-bottom: none; }
.pred-week   { color: var(--text-dim); font-size: 11px; width: 48px; flex-shrink: 0; }
.pred-est    { color: #60a5fa; font-family: var(--font-mono); width: 90px; flex-shrink: 0; }
.pred-actual { font-family: var(--font-mono); width: 90px; flex-shrink: 0; }
.pred-note   { flex: 1; min-width: 0; }

/* accuracy badge */
.accuracy-badge { font-size: 11px; color: var(--dn); }

/* ═══════════════════════════════════════════════════════
   CHARTS
═══════════════════════════════════════════════════════ */
.chart-wrap { overflow: hidden; }
.chart-svg  { width: 100%; height: auto; display: block; overflow: visible; }
.chart-labels {
  display: flex; justify-content: space-between;
  font-size: 8px; color: var(--text-faint); margin-top: 4px;
}
.chart-legend { display: flex; gap: 14px; font-size: 9px; margin-top: 6px; }
.chart-note   { font-size: 8px; color: var(--text-faint); margin-left: auto; }
.range-grid   { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-top: 8px; }
.range-cell   { background: var(--surface2); border-radius: 7px; padding: 5px 8px; }
.range-header { font-size: 8px; margin-bottom: 2px; }
.range-lo     { font-size: 10px; color: var(--dn); }
.range-hi     { font-size: 10px; color: var(--up); }
.range-cur    { font-size: 9px; color: var(--text-dim); }

/* side-by-side charts */
.dual-charts  { display: flex; gap: 12px; }
.single-chart { flex: 1; min-width: 0; }
.sc-title     { font-size: 10px; font-weight: 700; margin-bottom: 2px; }
.sc-unit      { font-size: 8px; color: var(--text-dim); margin-bottom: 4px; }

/* ═══════════════════════════════════════════════════════
   DRAWER
═══════════════════════════════════════════════════════ */
.drawer-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.55);
  z-index: 998; display: none;
}
.drawer-overlay.open { display: block; }

.drawer {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 999;
  background: var(--surface2); border-radius: 20px 20px 0 0;
  padding: 20px 18px 48px; max-height: 88vh; overflow-y: auto;
  transform: translateY(100%); transition: transform .3s ease;
}
.drawer.open { transform: translateY(0); }

.drawer-handle {
  width: 40px; height: 4px; background: var(--border);
  border-radius: 2px; margin: 0 auto 16px;
}
.drawer-title {
  font-weight: 900; font-size: 16px; color: var(--text);
  margin-bottom: 8px; font-family: var(--font-serif);
}
.drawer-badges { display: flex; gap: 5px; flex-wrap: wrap; margin-bottom: 14px; }
.drawer-section-title {
  font-size: 11px; color: var(--text-dim); font-weight: 700;
  margin: 14px 0 7px;
}
.drawer-table { background: var(--surface); border-radius: 10px; overflow: hidden; }
.drawer-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 9px 12px; border-bottom: 1px solid var(--border);
}
.drawer-row:last-child { border-bottom: none; }
.drawer-key   { color: var(--text-dim); font-size: 11px; flex-shrink: 0; }
.drawer-val   { color: var(--text-2); font-size: 12px; font-weight: 600; text-align: right; max-width: 62%; }
.drawer-close {
  margin-top: 16px; width: 100%; padding: 13px; border-radius: 12px;
  background: #1d4ed8; color: #fff; font-weight: 800; font-size: 14px;
  border: none;
}

/* src button */
.src-btn {
  font-size: 9px; color: var(--text-faint); background: none; border: none;
  cursor: pointer; flex-shrink: 0;
}

/* ═══════════════════════════════════════════════════════
   META ROW
═══════════════════════════════════════════════════════ */
.meta-row {
  margin-top: 8px; padding-top: 7px; border-top: 1px solid var(--border);
  display: flex; flex-wrap: wrap; gap: 8px; font-size: 9px; color: var(--text-faint);
}

/* ═══════════════════════════════════════════════════════
   RESPONSIVE — tablet & desktop
═══════════════════════════════════════════════════════ */
@media (min-width: 600px) {
  .bottom-nav { left: 50%; transform: translateX(-50%); width: 600px; }
  .page-container { padding-left: 20px; padding-right: 20px; }
  .grid-2 { grid-template-columns: 1fr 1fr; }
}
@media (min-width: 900px) {
  .site-header .header-inner { padding: 0; }
  .cards-stack { gap: 18px; }
  .card { padding: 18px 20px; }
}
