/* 手機優先設計：字大、卡片少、一頁一件事（docs/04-設計規範.md）
   台灣股市顏色習慣：紅=漲、綠=跌 */
:root {
  --red: #e0483e;      /* 漲 */
  --green: #0f9d58;    /* 跌 */
  --bg: #f5f6f8;
  --card: #ffffff;
  --text: #1f2329;
  --muted: #6b7280;
  --brand: #1a5cff;
}

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

body {
  font-family: "Microsoft JhengHei", "PingFang TC", "Noto Sans TC", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 17px;          /* 字大，手機好讀 */
  line-height: 1.6;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--brand);
  color: #fff;
  padding: 12px 16px;
}
.topbar a { color: #fff; }
.brand { font-weight: bold; }
.userbox { font-size: 15px; }

.container {
  max-width: 640px;         /* 手機寬度優先，桌機也不拉太寬 */
  margin: 0 auto;
  padding: 16px;
}

.card {
  background: var(--card);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

h1 { font-size: 24px; margin-bottom: 8px; }
h2 { font-size: 20px; margin-bottom: 8px; }
.muted { color: var(--muted); font-size: 15px; }
.card p { margin-bottom: 8px; }
.card p:last-child { margin-bottom: 0; }

label { display: block; margin-bottom: 12px; font-weight: bold; }
input {
  width: 100%;
  font-size: 17px;
  padding: 10px;
  margin-top: 4px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
}
.btn {
  width: 100%;
  background: var(--brand);
  color: #fff;
  font-size: 18px;
  padding: 12px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
}
.btn:active { background: #1449cc; }

.error {
  background: #fdecea;
  color: var(--red);
  padding: 10px 12px;
  border-radius: 8px;
  margin-bottom: 12px;
}

.disclaimer {
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  padding: 16px;
}

/* ── 站內導覽列（docs/04 3-3） ── */
.nav {
  display: flex;
  background: #fff;
  border-bottom: 1px solid #e5e7eb;
}
.nav a {
  flex: 1;
  text-align: center;
  padding: 10px 0;
  color: var(--text);
  text-decoration: none;
  font-weight: bold;
  font-size: 15px;  /* 5 格在 375px 手機也放得下、好點 */
  border-bottom: 3px solid transparent;
}
.nav a.active {
  color: var(--brand);
  border-bottom-color: var(--brand);
}

/* ── 漲跌顏色（台灣習慣：紅=漲、綠=跌） ── */
.up { color: var(--red); }
.down { color: var(--green); }
.flat { color: var(--muted); }

/* ── 股票列表頁（docs/04 3-1） ── */
.searchbar {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}
.searchbar input { margin-top: 0; flex: 1; }
.searchbar .btn { width: auto; padding: 10px 20px; }

.tabs { display: flex; gap: 8px; margin-bottom: 12px; }
.tab {
  padding: 6px 18px;
  border-radius: 999px;
  background: #fff;
  color: var(--text);
  text-decoration: none;
  border: 1px solid #d1d5db;
  font-size: 15px;
}
.tab.active { background: var(--brand); color: #fff; border-color: var(--brand); }

.stock-list { padding: 8px 12px; }
.data-table { width: 100%; border-collapse: collapse; font-size: 15px; }
.data-table th, .data-table td {
  padding: 10px 4px;
  border-bottom: 1px solid #f0f0f0;
  text-align: left;
}
.data-table th { color: var(--muted); font-size: 13px; font-weight: normal; }
.data-table tr:last-child td { border-bottom: none; }
.num {
  text-align: right;
  font-variant-numeric: tabular-nums;  /* 數字等寬，比較好讀 */
  white-space: nowrap;
}
.stock-link { color: var(--text); text-decoration: none; font-weight: bold; }
.tag {
  font-size: 12px;
  padding: 1px 6px;
  border-radius: 4px;
  margin-left: 4px;
}
.tag-tw { background: #e3edff; color: var(--brand); }
.tag-us { background: #fff3e0; color: #b26a00; }

/* ── 股票詳細頁（docs/04 3-2） ── */
.price-card { text-align: center; }
.big-price { font-size: 42px; font-weight: bold; line-height: 1.2; }
.change-line { font-size: 18px; font-weight: bold; margin-bottom: 4px; }
.ma-list p { margin-bottom: 6px; }
.bold { font-weight: bold; }

/* ── 新聞頁（第 5 步） ── */
.news-head { display: flex; gap: 10px; align-items: flex-start; }
.news-head-text { flex: 1; }
.news-title { font-weight: bold; color: var(--text); text-decoration: none; }
a.news-title { color: var(--brand); }
.news-meta { font-size: 13px; color: var(--muted); margin-top: 2px; }
.news-summary { font-size: 15px; color: #374151; margin-top: 8px; }
.news-chips { margin-top: 8px; }
.chip {
  display: inline-block;
  font-size: 12px;
  background: #eef2ff;
  color: #4338ca;
  border-radius: 10px;
  padding: 1px 8px;
  margin: 0 4px 4px 0;
}
/* 重要度徽章：分數越高越紅（docs/06 分級 0-20/21-40/41-60/61-80/81-100） */
.score {
  min-width: 52px;
  text-align: center;
  font-weight: bold;
  font-size: 15px;
  border-radius: 8px;
  padding: 4px 8px;
  white-space: nowrap;
}
.s-81 { background: var(--red); color: #fff; }
.s-61 { background: #f59e0b; color: #fff; }
.s-41 { background: #facc15; color: #1f2329; }
.s-21 { background: #60a5fa; color: #fff; }
.s-0  { background: #9ca3af; color: #fff; }
.s-none { background: #e5e7eb; color: var(--muted); font-size: 13px; }

/* ── 警報頁（docs/04 6-1）：卡左邊色條，重大紅、重要橙 ── */
.alert-major { border-left: 5px solid var(--red); }
.alert-warning { border-left: 5px solid #f59e0b; }
.tag-major { background: #fef2f2; color: #b91c1c; margin-left: 0; }
.tag-warning { background: #fff7ed; color: #c2410c; }
.chip-stock { text-decoration: none; background: #f0fdf4; color: #15803d; }

/* ── 小螢幕表格：太寬就左右滑，不爆版（第 7 步） ── */
.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;  /* iOS 滑起來順一點 */
}
.table-scroll .data-table { min-width: 320px; }

/* ── 首頁 5 大區塊（第 7 步，docs/04 第 2 節） ── */
.news-row {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 8px 0;
  border-bottom: 1px solid #f0f0f0;
}
.news-row:last-of-type { border-bottom: none; }
.news-row-text { flex: 1; min-width: 0; }  /* 標題太長會自動換行，不撐破卡片 */
.stock-row {
  padding: 8px 0;
  border-bottom: 1px solid #f0f0f0;
}
.stock-row:last-of-type { border-bottom: none; }

/* ── 股票詳細頁：AI 白話分析（第 6 步） ── */
.ai-card h3 { font-size: 15px; margin: 14px 0 6px; color: var(--text); }
.ai-verdict {
  display: inline-block;
  font-size: 20px;
  font-weight: bold;
  padding: 6px 14px;
  border-radius: 10px;
  background: #f0f2f5;
  margin: 6px 0 10px;
}
.ai-oneliner { font-size: 16px; font-weight: bold; margin: 8px 0; }
.ai-list { margin: 4px 0 8px; padding-left: 20px; }
.ai-list li { margin-bottom: 4px; }
.ai-trigger {
  margin-top: 14px;
  padding-top: 10px;
  border-top: 1px dashed #d8dce2;
}
.ai-trigger p { margin-bottom: 4px; }
