/* โครงหลัก: reset, หัวเว็บ, ส่วนทักทายหน้าแรก, กระดิ่ง, layout, หัวหน้าหุ้น/กราฟ/หน้าต่างกราฟขยาย
   (แยกออกจาก index.html ต.ค. 2026 — ลำดับไฟล์มีผล: theme → base → pages → mobile) */
* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg-grad) no-repeat, var(--bg);
  font-variant-numeric: tabular-nums;   /* ตัวเลขกว้างเท่ากัน: ราคาเปลี่ยนแล้วไม่กระโดด ตารางตรงหลัก */
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
button, input, select, textarea { font-family: inherit; }
:focus-visible { outline: 2px solid var(--accent-teal); outline-offset: 2px; }
::selection { background: color-mix(in srgb, var(--accent-teal) 30%, transparent); }

/* ---------- วงแหวนหมุนตอนกำลังโหลด: เส้นหนาปลายมน ยาว ~300° (เว้นช่องว่าง ~60°) ---------- */
.spinner { display: inline-block; width: var(--sp, 16px); height: var(--sp, 16px); flex: 0 0 auto; color: var(--accent-teal);
           vertical-align: -0.2em; animation: spin 0.9s linear infinite; }
.spinner circle { fill: none; stroke: currentColor; stroke-width: 3.6; stroke-linecap: round; stroke-dasharray: 50 60; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 2.4s; } }
.loading { display: inline-flex; align-items: center; gap: 8px; }
button .spinner { color: currentColor; }

.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

/* ---------- Top bar ---------- */
header {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 12px 28px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: color-mix(in srgb, var(--surface) 82%, transparent);
  backdrop-filter: saturate(1.4) blur(14px);
  -webkit-backdrop-filter: saturate(1.4) blur(14px);
  z-index: 10;
}

.wordmark {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-family: var(--font-sans);
  font-weight: 700;
  font-size: 17px;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  white-space: nowrap;
}
.wordmark-text span { color: var(--accent-teal); }
/* ชื่อเว็บ "An Investor" — เน้นสีตัว A กับ I ให้อ่านเป็นคำเล่น "AI" (เจ้าของเลือก 9 ต.ค. 2026) — Inter ปกติ "I" ใหญ่หน้าตาเหมือน "l" เล็ก
   cv08 = ตัว I แบบมีขีดหัว-ท้าย ทำให้อ่านออกว่าเป็น I */
.wordmark-text { font-feature-settings: "cv08" 1; letter-spacing: -0.02em; }
.wordmark-text span { font-weight: 800; }
/* ---------- หน้าแรก: ทักทาย + การ์ดพอร์ต (แนว Friendly) ---------- */
.home-hero { display: grid; grid-template-columns: minmax(0, 1fr) minmax(300px, 420px); gap: var(--sp-5); align-items: stretch;
  margin-bottom: var(--sp-5); }
.hh-left { display: flex; flex-direction: column; justify-content: center; min-width: 0; }
.hh-title { margin: 0 0 6px; font-size: 30px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.25; }
.hh-sub { margin: 0; color: var(--text-secondary); font-size: 15px; line-height: 1.7; }
.hh-sub .up { color: var(--positive); font-weight: 600; } .hh-sub .down { color: var(--negative); font-weight: 600; }
.hh-sub a { color: var(--accent-teal); font-weight: 600; text-decoration: none; }
.hh-sub a:hover { text-decoration: underline; }
.hh-card { position: relative; overflow: hidden; border-radius: var(--radius-lg); padding: var(--sp-5) var(--sp-6); color: #fff;
  background: linear-gradient(135deg, var(--hero-a), var(--hero-b)); box-shadow: 0 14px 34px color-mix(in srgb, var(--hero-a) 32%, transparent);
  min-height: 172px; display: flex; flex-direction: column; justify-content: center; gap: 6px; text-decoration: none; }
.hh-card::after { content: ""; position: absolute; right: -40px; top: -40px; width: 170px; height: 170px; border-radius: 50%;
  background: rgba(255, 255, 255, 0.08); pointer-events: none; }
a.hh-card:hover { filter: brightness(1.05); }
.hh-lbl { font-size: 13px; font-weight: 500; opacity: 0.88; }
.hh-big { font-size: 34px; font-weight: 800; letter-spacing: -0.02em; line-height: 1.15; }
.hh-h { font-size: 20px; font-weight: 700; line-height: 1.35; }
.hh-chips { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 4px; }
.hh-chip { display: inline-flex; align-items: center; gap: 4px; padding: 4px 10px; border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, 0.18); font-size: 12.5px; font-weight: 600; }
.hh-card ul { margin: 2px 0 0; padding-left: 18px; font-size: 13.5px; line-height: 1.7; opacity: 0.95; }
.hh-btns { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; position: relative; z-index: 1; }
.hh-btn { background: #fff; color: var(--hero-a); border: 0; padding: 9px 16px; border-radius: var(--radius); font-weight: 700;
  font-size: 13.5px; text-decoration: none; cursor: pointer; }
.hh-btn.ghost { background: rgba(255, 255, 255, 0.18); color: #fff; }
.hh-more { font-size: 12.5px; font-weight: 600; opacity: 0.9; margin-top: 2px; }
.hh-card[data-href] { cursor: pointer; }
.hh-card[data-href]:hover { filter: brightness(1.05); }
/* ปุ่มตา: ซ่อน/แสดงจำนวนเงินในพอร์ต */
.hh-eye { position: absolute; top: 12px; right: 12px; z-index: 2; width: 36px; height: 36px; border: 0; border-radius: 50%;
  background: rgba(255, 255, 255, 0.18); color: #fff; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; }
.hh-eye:hover { background: rgba(255, 255, 255, 0.28); }
.hh-eye svg, .eye-btn svg { width: 18px; height: 18px; }
[data-eye]:hover svg { transform: none; }
@media (max-width: 760px) { .home-hero { grid-template-columns: minmax(0, 1fr); } }
.wordmark-mark { width: 28px; height: 28px; border-radius: 8px; background: var(--accent-teal); color: var(--on-accent);
  display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto; }
.wordmark-mark svg { width: 17px; height: 17px; }
.icon-btn.hd-back { display: none; }   /* ปุ่มย้อนกลับ: แสดงเฉพาะมือถือ (ดู media block ของมือถือ) */
.hd-back:hover svg { transform: none; }
/* ปุ่มมุมขวาบน (สลับธีม / ภาษา) */
.hd-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.lang-switch button { padding: 6px 10px; font-size: 12.5px; font-weight: 600; letter-spacing: 0.02em; }
.icon-btn { width: 38px; height: 38px; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface);
  color: var(--text-secondary); display: inline-flex; align-items: center; justify-content: center; cursor: pointer; padding: 0;
  transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease, transform 0.12s ease; }
.icon-btn:hover { color: var(--text-primary); border-color: var(--border-strong); background: var(--surface-hover); }
.icon-btn svg { width: 18px; height: 18px; transition: transform 0.45s var(--ease); }
.icon-btn:hover svg { transform: rotate(-20deg); }
/* ---------- กระดิ่งแจ้งเตือน ---------- */
.bell-btn { position: relative; }
.bell-btn:hover svg { transform: rotate(14deg); }
.bell-badge { position: absolute; top: -5px; right: -5px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px;
  background: var(--negative); color: #fff; font-size: 10.5px; font-weight: 700; line-height: 18px; text-align: center; font-family: var(--font-mono); }
.bell-panel { position: absolute; top: calc(100% + 6px); right: 16px; width: min(400px, calc(100vw - 24px)); max-height: min(70vh, 560px);
  display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.28); z-index: 60; animation: popIn 0.18s var(--ease); }
.bell-panel[hidden] { display: none; }
.bell-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px; border-bottom: 1px solid var(--border); }
.bell-readall { background: none; border: none; cursor: pointer; padding: 4px 0; }
.bell-readall[hidden] { display: none; }
.bell-list { overflow-y: auto; flex: 1 1 auto; min-height: 60px; overscroll-behavior: contain; }
.bell-item { display: block; width: 100%; text-align: left; background: none; border: none; border-bottom: 1px solid var(--border);
  padding: 10px 14px 10px 26px; cursor: pointer; color: var(--text-primary); font: inherit; position: relative; }
.bell-item:hover { background: var(--surface-hover); }
.bell-item.unread::before { content: ""; position: absolute; left: 11px; top: 16px; width: 7px; height: 7px; border-radius: 50%; background: var(--accent-teal); }
.bell-item-title { font-size: 13px; font-weight: 500; line-height: 1.45; overflow-wrap: anywhere; }
.bell-item-body { font-size: 12px; color: var(--text-secondary); margin-top: 3px; line-height: 1.45; white-space: pre-line; overflow-wrap: anywhere; }
.bell-item-time { font-size: 11px; color: var(--text-dim); margin-top: 4px; }
.bell-empty { color: var(--text-dim); font-size: 13px; text-align: center; padding: 28px 16px; line-height: 1.6; }
.bell-settings { border-top: 1px solid var(--border); padding: 10px 14px; font-size: 13px; }
.bell-settings summary { cursor: pointer; color: var(--accent-teal); }
.bell-settings label { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 8px; margin-top: 10px; cursor: pointer; }
.bell-settings label[hidden] { display: none; }
.bell-settings label small { flex-basis: 100%; padding-left: 24px; color: var(--text-dim); font-size: 11.5px; }
.bell-test { margin-top: 12px; }
.bell-test[hidden] { display: none; }
.bell-toasts { position: fixed; right: 16px; bottom: 16px; z-index: 70; display: flex; flex-direction: column; gap: 8px; width: min(360px, calc(100vw - 32px)); pointer-events: none; }
.bell-toast { pointer-events: auto; background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--accent-teal);
  border-radius: var(--radius); padding: 10px 12px; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25); cursor: pointer; animation: popIn 0.2s var(--ease); font-size: 13px; }
.bell-toast.up { border-left-color: var(--positive); }
.bell-toast.down { border-left-color: var(--negative); }
.bell-toast.news { border-left-color: var(--accent-amber); }

.search-wrap {
  position: relative;
  flex: 1;
  max-width: 420px;
}

#searchInput {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  padding: 10px 14px 10px 38px;
  font-family: var(--font-sans);
  font-size: 14px;
  outline: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%238592A3' stroke-width='2' stroke-linecap='round' viewBox='0 0 24 24'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: 13px center;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
#searchInput:focus { border-color: var(--accent-teal); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent-teal) 18%, transparent); }
#searchInput::placeholder { color: var(--text-dim); }

#searchResults {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  display: none;
  box-shadow: var(--card-shadow-hover);
  z-index: 30;
}
#searchResults.open { display: block; animation: popIn 0.16s var(--ease); }
@keyframes popIn { from { opacity: 0; transform: translateY(-4px) scale(0.99); } to { opacity: 1; transform: none; } }

.result-item {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
}
.result-item:last-child { border-bottom: none; }
.result-item:hover { background: var(--surface-hover); }
/* โลโก้หุ้น: พื้นขาว (โลโก้หลายตัวเป็นสีดำพื้นใส มองไม่เห็นบนพื้นเข้ม) ถ้าไม่มีรูปจะเห็นตัวอักษรแรกที่อยู่ข้างใต้ */
.logo {
  position: relative; display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto;
  width: var(--sz, 28px); height: var(--sz, 28px); border-radius: 6px; overflow: hidden;
  background: var(--surface-hover); border: 1px solid var(--border); color: var(--text-secondary);
  font-family: var(--font-mono); font-weight: 600; font-size: calc(var(--sz, 28px) * 0.45);
}
.logo img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: #fff; padding: 12%; box-sizing: border-box; }
.result-item .logo { align-self: center; }
.result-symbol { font-family: var(--font-sans); font-weight: 700; color: var(--accent-teal); font-size: 13px; }
.result-name { color: var(--text-secondary); font-size: 13px; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.result-exchange { color: var(--text-dim); font-size: 11px; }

.search-status { padding: 12px 14px; color: var(--text-dim); font-size: 13px; }

/* ---------- Main layout ---------- */
main {
  max-width: 980px;
  margin: 0 auto;
  padding: 32px 28px 80px;
}

.empty-state {
  text-align: center;
  padding: 120px 20px;
  color: var(--text-dim);
}
.empty-state .glyph {
  font-family: var(--font-mono);
  font-size: 32px;
  color: var(--border);
  margin-bottom: 12px;
}
.empty-state p { font-size: 14px; }

#panel { display: none; }
#panel.visible { display: block; }

/* ---------- Ticker header ---------- */
/* หัวหน้าหุ้น = การ์ดใหญ่ (ขั้น 2 ของการปรับดีไซน์): ซ้าย ชื่อ + ปุ่ม / ขวา ราคา / แถวล่าง แนวรับ-แนวต้าน */
.ticker-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: var(--sp-4) var(--sp-6);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--card-shadow);
  padding: var(--sp-6);
  margin-bottom: var(--sp-5);
}
.ticker-head > .sr-block { grid-column: 1 / -1; margin-top: 0; max-width: none; }

.ticker-id { display: flex; align-items: center; gap: 14px; }
.ticker-titles { display: flex; flex-direction: column; min-width: 0; }
.ticker-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: var(--sp-3); }
.ticker-symbol {
  font-family: var(--font-sans);
  font-size: 30px;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.ticker-name { color: var(--text-secondary); font-size: 15px; line-height: 1.4; }
.ticker-meta { color: var(--text-dim); font-size: 12.5px; margin-top: var(--sp-2); }
/* แนวรับ/แนวต้าน ใต้ชื่อหุ้น: 2 กล่อง (รับ = เขียว, ต้าน = แดง) กล่องละ 3 ช่อง + ปุ่ม ? อธิบายวิธีคำนวณ */
.sr-block { margin-top: 14px; max-width: 720px; }
.sr-title { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text-secondary); margin-bottom: 8px; }
.sr-title b { color: var(--text-primary); font-weight: 600; }
.sr-title .sr-asof { color: var(--text-dim); font-size: 11.5px; }
.sr-panels { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; }
.sr-panel { border: 1px solid var(--border); border-left-width: 3px; border-radius: var(--radius); padding: 8px 10px 9px; }
.sr-panel.sup { border-left-color: var(--positive); background: color-mix(in srgb, var(--positive) 6%, transparent); }
.sr-panel.res { border-left-color: var(--negative); background: color-mix(in srgb, var(--negative) 6%, transparent); }
.sr-panel-h { font-size: 11.5px; font-weight: 600; margin-bottom: 6px; }
.sr-panel.sup .sr-panel-h { color: var(--positive); }
.sr-panel.res .sr-panel-h { color: var(--negative); }
.sr-cells { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.sr-cell { padding: 0 8px; min-width: 0; }
.sr-cell:first-child { padding-left: 0; }
.sr-cell + .sr-cell { border-left: 1px solid var(--border); }
.sr-k { font-size: 11px; color: var(--text-dim); white-space: nowrap; }
.sr-v { font-family: var(--font-mono); font-size: 16px; font-weight: 600; color: var(--text-primary); margin-top: 1px; white-space: nowrap; }
.sr-pct { font-family: var(--font-mono); font-size: 11px; margin-top: 1px; }
.sr-panel.sup .sr-pct { color: var(--positive); }
.sr-panel.res .sr-pct { color: var(--negative); }
.sr-help { width: 18px; height: 18px; border-radius: 50%; border: 1px solid var(--border); background: transparent; color: var(--text-secondary); font-size: 11px; font-weight: 700; cursor: pointer; padding: 0; line-height: 16px; }
.sr-help:hover { border-color: var(--accent-teal); color: var(--accent-teal); }
.sr-msg { color: var(--text-dim); font-size: 12px; }
@media (max-width: 640px) {
  .sr-panels { grid-template-columns: minmax(0, 1fr); }
  .sr-v { font-size: 15px; }
}
.sr-pop-backdrop { position: fixed; inset: 0; background: color-mix(in srgb, var(--shadow) 55%, transparent); z-index: 200; display: flex; align-items: flex-start; justify-content: center; padding: calc(env(safe-area-inset-top, 0px) + 40px) 16px 24px; overflow-y: auto; }
.sr-pop { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; max-width: 760px; width: 100%; padding: 20px 22px; font-size: 13.5px; line-height: 1.7; box-shadow: 0 20px 60px color-mix(in srgb, var(--shadow) 50%, transparent); }
.sr-pop h3 { margin: 0 0 4px; font-size: 17px; }
.sr-pop h4 { margin: 16px 0 6px; font-size: 13px; color: var(--accent-teal); }
.sr-pop ol { margin: 0; padding-left: 20px; }
.sr-pop li { margin-bottom: 4px; }
.sr-pop .pf-table td { white-space: normal; font-size: 12.5px; padding: 8px; }
.sr-pop .pf-table td.sr-why { font-family: var(--font-sans); text-align: left; color: var(--text-secondary); }
.sr-pop-close { float: right; background: transparent; border: 1px solid var(--border); color: var(--text-secondary); border-radius: var(--radius); padding: 3px 10px; cursor: pointer; font-family: inherit; }
.sr-pop-close:hover { border-color: var(--accent-teal); color: var(--accent-teal); }
.sr-caveat { background: color-mix(in srgb, var(--accent-amber) 8%, transparent); border: 1px solid color-mix(in srgb, var(--accent-amber) 35%, transparent); border-radius: var(--radius); padding: 10px 12px; font-size: 12.5px; }

.price-block { text-align: right; }
.price-value { font-family: var(--font-mono); font-size: 30px; font-weight: 600; letter-spacing: -0.02em; }
.price-change { font-family: var(--font-mono); font-size: 13.5px; font-weight: 600; margin-top: 6px;
  display: inline-flex; align-items: center; gap: 4px; padding: 4px 11px; border-radius: var(--radius-pill); }

/* ---------- ราคานอกเวลาทำการ (pre-market / after-hours / overnight) ---------- */
.live-line {
  display: inline-flex; align-items: center; gap: 5px; white-space: nowrap;
  font-family: var(--font-mono); font-size: 11.5px; color: var(--text-secondary);
}
.live-ico { width: 14px; height: 14px; flex: 0 0 auto; }
.live-head { margin-top: 6px; min-height: 0; }
.live-head .live-line { font-size: 13px; gap: 7px; }
.live-head .live-ico { width: 17px; height: 17px; }
.live-label { color: var(--text-dim); font-family: var(--font-sans); }
.ql-live { margin-top: 3px; }
.ql-live:empty, .live-head:empty { display: none; }
.pf-src { display: flex; align-items: center; justify-content: flex-end; gap: 4px; color: var(--text-secondary); }
.pf-src .live-ico { width: 12px; height: 12px; }
.pf-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--positive); box-shadow: 0 0 5px var(--positive); }
.price-change.up { color: var(--positive); background: color-mix(in srgb, var(--positive) 12%, transparent); }
.price-change.down { color: var(--negative); background: color-mix(in srgb, var(--negative) 11%, transparent); }

.source-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--text-dim);
  margin-top: 8px;
}
.source-badge .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--text-dim); }
.source-badge.live .dot { background: var(--accent-amber); box-shadow: 0 0 6px var(--accent-amber); }
.source-badge.live { color: var(--accent-amber); border-color: color-mix(in srgb, var(--accent-amber) 35%, transparent); }
.source-badge.cache .dot { background: var(--accent-teal); }
.source-badge.cache { color: var(--accent-teal); border-color: color-mix(in srgb, var(--accent-teal) 35%, transparent); }

.refresh-btn {
  display: block;
  margin-top: 8px;
  margin-left: auto;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-secondary);
  font-family: var(--font-sans);
  font-size: 12px;
  padding: 5px 10px;
  cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease;
}
.refresh-btn:hover:not(:disabled) { border-color: var(--accent-teal); color: var(--accent-teal); }
.refresh-btn:disabled { opacity: 0.5; cursor: default; }

/* ---------- Controls ---------- */
.controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 16px;
}

.btn-group {
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.btn-group button {
  background: transparent;
  border: none;
  border-radius: 9px;
  color: var(--text-secondary);
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 500;
  padding: 6px 13px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.18s ease, color 0.18s ease, box-shadow 0.18s ease, transform 0.12s ease;
}
.btn-group button:hover { color: var(--text-primary); background: var(--surface-hover); }
.btn-group button.active { background: var(--surface); color: var(--accent-teal); font-weight: 600;
  box-shadow: 0 1px 3px color-mix(in srgb, var(--shadow) 14%, transparent), inset 0 0 0 1px var(--border); }

/* ---------- Chart cards ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--sp-5) var(--sp-6);
  margin-bottom: var(--sp-5);
  box-shadow: var(--card-shadow);
}
/* ชื่อการ์ด: ตัวใหญ่ หนา อ่านง่าย + คำอธิบายสั้นบรรทัดล่าง (<small>) ให้ผู้ใช้ใหม่รู้ว่าการ์ดนี้คืออะไร */
.card-label {
  font-family: var(--font-sans);
  font-size: 16.5px;
  font-weight: 650;
  letter-spacing: -0.01em;
  line-height: 1.3;
  color: var(--text-primary);
  margin-bottom: 14px;
}
.card-label small { display: block; font-size: 12.5px; font-weight: 400; letter-spacing: 0; color: var(--text-secondary); margin-top: 3px; }

.card-label-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px 12px;
  margin-bottom: 14px;
}
.card-label-row .card-label { margin-bottom: 0; }

.expand-btn {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-secondary);
  font-family: var(--font-sans);
  font-size: 12.5px;
  font-weight: 500;
  padding: 6px 12px;
  cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease, transform 0.12s ease;
}
.expand-btn:hover { border-color: var(--accent-teal); color: var(--accent-teal); background: color-mix(in srgb, var(--accent-teal) 6%, transparent); }

/* ---------- Modal: กราฟขยายใหญ่ + zoom/pan ---------- */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: color-mix(in srgb, var(--shadow) 88%, transparent);
  backdrop-filter: blur(4px);
  z-index: 100;
  padding: 24px;
}
.modal-overlay.open { display: flex; align-items: center; justify-content: center; }

.modal-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 100%;
  max-width: 1100px;
  height: 100%;
  max-height: 720px;
  display: flex;
  flex-direction: column;
  padding: 18px 22px;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 12px;
}
.modal-title { font-size: 18px; font-weight: 600; letter-spacing: 0.01em; }
.modal-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.modal-hint { color: var(--text-dim); font-size: 12px; }

.modal-btn {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-secondary);
  font-family: var(--font-sans);
  font-size: 12px;
  padding: 6px 12px;
  cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease;
}
.modal-btn:hover { border-color: var(--accent-teal); color: var(--accent-teal); }
.modal-btn.close:hover { border-color: var(--negative); color: var(--negative); }

.modal-chart-box { position: relative; flex: 1; min-height: 0; }

@media (max-width: 640px) {
  .modal-overlay { padding: 8px; }
  .modal-card { padding: 12px 14px; }
  .modal-hint { display: none; }
}
.chart-box { position: relative; height: 320px; }
.chart-box.volume { height: 110px; }

/* ---------- Info grid ---------- */
.info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
}
.info-item { }
.info-label { font-size: 12px; color: var(--text-secondary); margin-bottom: 4px; }
.info-value { font-family: var(--font-mono); font-size: 15px; color: var(--text-primary); }

.error-msg {
  color: var(--negative);
  font-size: 13px;
  padding: 10px 14px;
  background: color-mix(in srgb, var(--negative) 8%, transparent);
  border: 1px solid color-mix(in srgb, var(--negative) 25%, transparent);
  border-radius: var(--radius);
  margin-bottom: 16px;
  display: none;
}
.error-msg.visible { display: block; }
.error-msg.notice { color: var(--accent-amber); background: color-mix(in srgb, var(--accent-amber) 8%, transparent); border-color: color-mix(in srgb, var(--accent-amber) 30%, transparent); }
