/* ta.css — 個股技術分析主圖＋副圖（ta-chart.jsx）。顏色一律走 styles.css token */

.ta-chart { font-family: var(--font-sans); color: var(--ink); min-width: 0; }
.ta-num { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.ta-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.ta-empty { padding: 40px 16px; text-align: center; color: var(--ink-mute); font-size: var(--fs-xs, 13px); }

/* ── 工具列 ── */
.ta-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 22px; padding: 8px 0 12px; font-size: 13px; }
.ta-toolbar button { font: inherit; cursor: pointer; }
.ta-toolbar button:disabled { cursor: not-allowed; opacity: .45; }
.ta-toolbar button:focus-visible, .ta-sub-rm:focus-visible, .ta-sub-add select:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.ta-seg { display: flex; gap: 2px; background: var(--surface-2); padding: 3px; border-radius: var(--radius-sm); }
.ta-seg button { border: 0; background: transparent; padding: 6px 12px; border-radius: 4px; color: var(--ink-soft); }
.ta-seg button.on { background: var(--surface); color: var(--ink); font-weight: 600; box-shadow: var(--shadow-sm); }

.ta-ranges { display: flex; gap: 2px; }
.ta-ranges button { border: 0; background: transparent; padding: 6px 8px; color: var(--ink-soft); font-family: var(--font-mono); }
.ta-ranges button.on { color: var(--ink); font-weight: 600; box-shadow: inset 0 -2px 0 var(--ink); }

.ta-group { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.ta-glabel { color: var(--ink-mute); font-size: 12px; }
.ta-chip { border: 1px solid var(--line); background: var(--surface); padding: 5px 10px; border-radius: 4px; color: var(--ink-soft); }
.ta-chip:hover:not(:disabled) { border-color: var(--ink-faint); }
.ta-chip[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); color: var(--gold-deep, var(--accent)); }

/* ── 主圖面板 ── */
.ta-panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-md); padding: 12px 14px 10px; min-width: 0; }
.ta-info { display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: 12.5px; color: var(--ink-soft); padding: 0 2px 6px; min-height: 22px; }
.ta-info-date { color: var(--ink); font-weight: 600; }
.ta-tag { color: var(--warn); }

.ta-chart-wrap { position: relative; }
.ta-main { height: 420px; }
.ta-ovl { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; overflow: visible; font-family: var(--font-sans); }
.ta-ovl .ta-ev { pointer-events: auto; cursor: default; }

/* ── 副圖 ── */
.ta-sub { margin-top: 6px; }
.ta-sub-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 11.5px; color: var(--ink-mute); padding: 6px 2px 2px; }
.ta-sub-name { letter-spacing: .04em; display: flex; flex-wrap: wrap; gap: 2px 12px; align-items: baseline; }
.ta-sub-val { letter-spacing: 0; }
.ta-sub-note { color: var(--warn); letter-spacing: 0; }
.ta-sub-rm { flex: 0 0 auto; white-space: nowrap; border: 0; background: transparent; color: var(--ink-mute); padding: 2px 4px; font: inherit; cursor: pointer; border-radius: 3px; }
.ta-sub-rm:hover { color: var(--accent); text-decoration: underline; }
.ta-sub-chart { height: 120px; }
.ta-sub-chart.ta-vol { height: 90px; }

.ta-sub-add { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; border-top: 1px solid var(--line); margin-top: 10px; padding-top: 10px; font-size: 12.5px; }
.ta-sub-add select { font: inherit; border: 1px dashed var(--ink-faint); background: transparent; padding: 5px 10px; border-radius: 4px; color: var(--ink-soft); cursor: pointer; }
.ta-sub-add select:disabled { opacity: .45; cursor: not-allowed; }
.ta-sub-hint { color: var(--ink-mute); }

@media (max-width: 640px) {
  .ta-toolbar { flex-wrap: nowrap; overflow-x: auto; gap: 10px 16px; padding-bottom: 10px; -webkit-overflow-scrolling: touch; }
  .ta-toolbar > * { flex: 0 0 auto; }
  .ta-group { flex-wrap: nowrap; }
  .ta-panel { padding: 10px 8px 8px; }
  .ta-main { height: 320px; }
  .ta-sub-chart { height: 100px; }
  .ta-sub-chart.ta-vol { height: 72px; }
}

/* ── 畫線層（ta-draw.jsx）── */
.ta-draw { position: absolute; left: 0; right: 0; pointer-events: none; z-index: 3; }
.ta-draw-svg { position: absolute; left: 0; top: 0; pointer-events: none; overflow: hidden; font-family: var(--font-sans); }
.ta-draw-svg.active { pointer-events: auto; cursor: crosshair; }
.ta-d-line { stroke: var(--accent); stroke-width: 1.5; fill: none; }
.ta-d-line.sel { stroke-width: 2.25; }
.ta-d-diag { stroke-dasharray: 3 3; opacity: .55; }
.ta-d-mid { stroke-dasharray: 4 4; opacity: .5; stroke-width: 1; }
.ta-d-chfill { fill: var(--accent); fill-opacity: .07; stroke: none; }
.ta-d-rect { fill: var(--accent); fill-opacity: .08; stroke: var(--accent); stroke-width: 1.5; }
.ta-d-label { font-size: 12px; fill: var(--ink); font-weight: 600; paint-order: stroke; stroke: var(--bg, #f7f5f0); stroke-width: 3px; stroke-linejoin: round; }
.ta-d-label.sel { fill: var(--accent); }
/* 命中層：沒選工具時也能點到線（其餘區域照樣讓滑鼠穿過去給主圖拖曳、縮放） */
.ta-d-hit { stroke: transparent; stroke-width: 12; fill: none; pointer-events: stroke; cursor: pointer; }
.ta-d-hitbox { fill: transparent; stroke: none; pointer-events: all; cursor: move; }
.ta-d-handle { fill: var(--bg, #f7f5f0); stroke: var(--accent); stroke-width: 2; pointer-events: all; cursor: grab; }
.ta-d-hit, .ta-d-hitbox, .ta-d-handle { touch-action: none; }   /* 觸控：拖線時不要讓瀏覽器捲動頁面 */
.ta-draw-svg.active .ta-d-hit, .ta-draw-svg.active .ta-d-hitbox { cursor: crosshair; }
.ta-draw-svg.dragging, .ta-draw-svg.dragging * { cursor: grabbing !important; }
.ta-d-input { position: absolute; width: 180px; height: 24px; padding: 0 6px; font: inherit; font-size: 12px; border: 1px solid var(--accent); border-radius: 3px; background: var(--surface, #fff); color: var(--ink); pointer-events: auto; outline: none; box-shadow: 0 1px 4px rgba(0,0,0,.12); }
.ta-d-tip { font-size: 11.5px; padding: 2px 8px; border-radius: 3px; background: var(--surface-2, #f0ede4); color: var(--ink-soft); border: 1px solid var(--paper-line); }
.ta-d-prev { opacity: .6; stroke-dasharray: 4 3; }
.ta-d-dot { fill: var(--bg, #f7f5f0); stroke: var(--accent); stroke-width: 1.5; }
.ta-d-fib { stroke: var(--up-tint, #a3701f); stroke-width: 1; opacity: .75; }
.ta-d-fib.end { stroke-width: 1.5; opacity: 1; }
.ta-d-txt { font-size: 10.5px; fill: var(--ink-soft); font-family: var(--font-mono, monospace); }
.ta-d-txt.strong { fill: var(--ink); font-weight: 600; }
.ta-d-meas { stroke: none; }
.ta-d-meas.up { fill: var(--up); fill-opacity: .1; }
.ta-d-meas.dn { fill: var(--dn); fill-opacity: .1; }
.ta-d-mbg { fill: var(--bg, #f7f5f0); stroke: var(--paper-line); stroke-width: 1; }
.ta-d-chip { position: absolute; transform: translate(-100%, -50%); display: flex; align-items: center; gap: 4px; padding: 1px 3px 1px 6px; border: 1px solid var(--paper-line); border-radius: 3px; background: var(--bg, #f7f5f0); font-size: 10.5px; line-height: 16px; color: var(--ink-soft); pointer-events: auto; white-space: nowrap; }
.ta-d-chip .ta-d-del { opacity: 0; font: inherit; font-size: 10.5px; padding: 0 5px; border: 1px solid var(--paper-line); border-radius: 3px; background: transparent; color: var(--ink); cursor: pointer; }
.ta-d-chip:hover .ta-d-del, .ta-d-chip:focus-within .ta-d-del, .ta-d-chip.sel .ta-d-del { opacity: 1; }
.ta-d-chip.sel { border-color: var(--accent); color: var(--ink); }
@media (hover: none) { .ta-d-chip .ta-d-del { opacity: 1; } }
.ta-d-chip .ta-d-del:hover, .ta-d-chip .ta-d-del:focus-visible { background: var(--accent-soft); outline: 2px solid var(--accent); outline-offset: 1px; }
.ta-d-bar { position: absolute; left: 8px; top: 6px; display: flex; gap: 8px; align-items: center; pointer-events: none; }
.ta-d-hint { font-size: 11.5px; padding: 2px 8px; border-radius: 3px; background: var(--accent); color: #fff; }
.ta-d-clear { pointer-events: auto; font: inherit; font-size: 11.5px; padding: 2px 8px; border: 1px solid var(--paper-line); border-radius: 3px; background: var(--bg, #f7f5f0); color: var(--ink-soft); cursor: pointer; }
.ta-d-clear:hover, .ta-d-clear:focus-visible { border-color: var(--ink-faint); color: var(--ink); }

/* ── 右欄「現在位置」（ta-position.jsx）── */
.ta-pos { font-family: var(--font-sans); color: var(--ink); min-width: 0; }
.ta-pos-eyebrow { font-size: 12px; letter-spacing: .12em; color: var(--accent); font-weight: 600; }
.ta-pos-title { margin: 2px 0 12px; font-family: var(--font-serif, 'Newsreader', 'Noto Serif TC', serif); font-size: 24px; font-weight: 600; }
.ta-pos-note { margin: -8px 0 12px; font-size: 11.5px; color: var(--ink-mute); }
.ta-pos-sec { padding: 12px 0; border-top: 1px solid var(--paper-line, var(--line)); }
.ta-pos-label { font-size: 12.5px; color: var(--ink-mute); margin-bottom: 4px; }
.ta-pos-stage, .ta-pos-vol { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 10px; margin: 2px 0 4px; }
.ta-pos-stage-name { font-size: 22px; font-weight: 600; }
.ta-pos-stage-name.up { color: var(--up); }
.ta-pos-stage-name.down { color: var(--dn); }
.ta-pos-stage-name.range { color: var(--ink-soft); }
.ta-pos-sub { font-size: 12.5px; color: var(--ink-soft); }
.ta-pos-text { font-size: 13px; color: var(--ink-soft); line-height: 1.75; }
.ta-pos-table { width: 100%; border-collapse: collapse; font-size: 13px; margin-bottom: 6px; }
.ta-pos-table th { text-align: left; font-weight: 400; padding: 3px 8px 3px 0; }
.ta-pos-table td { text-align: right; padding: 3px 0; white-space: nowrap; }
.ta-pos-mute { color: var(--ink-mute); margin-left: 4px; }
.ta-pos .up { color: var(--up); }
.ta-pos .dn { color: var(--dn); }
.ta-pos-big { font-size: 20px; font-weight: 600; }
.ta-pos-meter { position: relative; height: 6px; background: linear-gradient(90deg, var(--accent-soft), var(--surface-2) 60%, var(--line)); border-radius: 3px; margin: 8px 0 6px; }
.ta-pos-meter i { position: absolute; top: -4px; width: 2px; height: 14px; background: var(--ink); }
.ta-pos-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.ta-pos-mini { font-size: 12px; color: var(--ink-mute); }
.ta-pos-mid { font-size: 18px; }
.ta-pos-line { font-size: 13px; line-height: 1.85; }
.ta-pos-strong { font-weight: 600; }
.ta-pos-foot { font-size: 11.5px; color: var(--ink-mute); border-top: 1px solid var(--paper-line, var(--line)); padding-top: 10px; margin: 0; }

/* ── 條件統計區（ta-conditions.jsx）── */
.ta-cond { font-family: var(--font-sans); color: var(--ink); min-width: 0; border-top: 2px solid var(--ink); padding-top: 10px; margin-top: 28px; }
.ta-cond .up { color: var(--up); }
.ta-cond .dn { color: var(--dn); }
.ta-cond-eyebrow { font-size: 12px; letter-spacing: .12em; color: var(--accent); font-weight: 600; }
.ta-cond-title { margin: 2px 0 6px; font-family: var(--font-serif, 'Newsreader', 'Noto Serif TC', serif); font-size: 26px; font-weight: 600; }
.ta-cond-lede { margin: 0 0 14px; color: var(--ink-soft); max-width: 820px; font-size: 14px; }
.ta-cond-chips { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 10px; }
.ta-cond-chip { font: inherit; font-size: 13px; cursor: pointer; border: 1px solid var(--accent); background: var(--accent); color: #fff; padding: 7px 14px; border-radius: 999px; }
.ta-cond-chip:hover { filter: brightness(1.1); }
.ta-cond-chip.add { border: 1px dashed var(--ink-faint); background: transparent; color: var(--ink-soft); }
.ta-cond-chip.add:hover { border-color: var(--ink); color: var(--ink); filter: none; }
.ta-cond-chip:focus-visible, .ta-cond-mitem:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.ta-cond-addwrap { position: relative; display: inline-block; }
.ta-cond-menu { position: absolute; z-index: 20; top: calc(100% + 6px); left: 0; width: 260px; max-width: calc(100vw - 32px); max-height: 340px; overflow-y: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-md); box-shadow: var(--shadow-sm, 0 4px 16px rgba(0,0,0,.12)); padding: 6px; }
.ta-cond-mlabel { font-size: 11.5px; color: var(--ink-mute); letter-spacing: .08em; padding: 6px 8px 2px; }
.ta-cond-mitem { display: block; width: 100%; text-align: left; font: inherit; font-size: 13px; border: 0; background: transparent; color: var(--ink); padding: 7px 8px; border-radius: 4px; cursor: pointer; }
.ta-cond-mitem:hover:not(:disabled) { background: var(--accent-soft); }
.ta-cond-mitem[aria-pressed="true"] { color: var(--accent); font-weight: 600; }
.ta-cond-mitem:disabled { color: var(--ink-faint); cursor: not-allowed; }
.ta-cond-sum { font-size: 13px; color: var(--ink-soft); margin: 4px 0 16px; }
.ta-cond-sum b { color: var(--ink); }
.ta-cond-box { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 18px 16px; text-align: center; color: var(--ink-soft); font-size: 14px; margin: 4px 0 16px; }
.ta-cond-cols { display: flex; flex-wrap: wrap; gap: 20px; }
.ta-cond-col { flex: 1 1 380px; min-width: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-md); padding: 16px 18px; }
.ta-cond-h3 { margin: 0 0 10px; font-size: 16px; font-weight: 600; }
.ta-cond-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-bottom: 14px; }
.ta-cond-k { font-size: 12px; color: var(--ink-mute); }
.ta-cond-v { font-size: 22px; font-weight: 600; }
.ta-cond-v.sm { font-size: 14px; padding-top: 6px; }
.ta-cond-s { font-size: 11.5px; color: var(--ink-mute); }
.ta-cond-fig { margin: 0; }
.ta-cond-svg { display: block; width: 100%; height: auto; }
.ta-cond-tick { font-size: 12px; fill: var(--ink-soft); font-family: var(--font-mono, monospace); }
.ta-cond-legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 12px; color: var(--ink-soft); margin-top: 6px; }
.ta-cond-sw { display: inline-block; width: 10px; height: 10px; margin-right: 5px; vertical-align: -1px; }
.ta-cond-sw.solid { background: var(--accent); }
.ta-cond-sw.outline { border: 1.5px solid var(--ink-faint); }
.ta-cond-read { margin: 10px 0 0; font-size: 13px; line-height: 1.8; background: var(--surface-2); padding: 10px 12px; border-radius: 6px; }
.ta-cond-recent { margin-top: 22px; }
.ta-cond-scroll { overflow-x: auto; }
.ta-cond-table { width: 100%; min-width: 440px; border-collapse: collapse; font-size: 13px; }
.ta-cond-table th { text-align: right; font-weight: 500; font-size: 12px; color: var(--ink-mute); padding: 6px 8px; border-bottom: 1px solid var(--ink); }
.ta-cond-table th:first-child, .ta-cond-table td:first-child { text-align: left; padding-left: 0; }
.ta-cond-table td { text-align: right; padding: 6px 8px; border-bottom: 1px solid var(--line); }
.ta-cond-table tr.cur { background: var(--accent-soft); }
.ta-cond-mute { color: var(--ink-mute); font-size: 13px; }
.ta-cond-foot { font-size: 12px; color: var(--ink-mute); margin: 16px 0 0; max-width: 900px; line-height: 1.8; }
@media (max-width: 640px) {
  .ta-cond-title { font-size: 22px; }
  .ta-cond-col { padding: 14px 12px; flex-basis: 100%; }
  .ta-cond-stats { gap: 6px; }
  .ta-cond-v { font-size: 18px; }
  .ta-cond-v.sm { font-size: 12.5px; }
  .ta-cond-table { min-width: 0; font-size: 12.5px; }
  .ta-cond-table th, .ta-cond-table td { padding-left: 4px; padding-right: 4px; }
}

/* ── 技術分頁版面（stock.jsx 組裝：主圖＋右欄、下方條件統計） ── */
.ta-page { padding: 16px 0 8px; min-width: 0; }
.ta-grid { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 24px; align-items: start; }
.ta-left, .ta-right { min-width: 0; }
.ta-page .ta-toolbar { overflow-x: auto; }   /* 桌機換行；≤640px 改單行橫捲（見上方工具列 media） */
.ta-page .ta-cond { margin-top: 32px; }
@media (max-width: 900px) {
  .ta-grid { grid-template-columns: minmax(0, 1fr); }   /* 手機：右欄排在主圖下方 */
}
