/* 播放頁時間軸（timeline.js）：桌機是播放欄與筆記面板之間 48px 寬的直向分隔線，手機是播放器下方 52px 高的橫向時間軸。
   位置一律用自訂屬性 --pos（0–100%）；直向沿 top、橫向沿 left。 */
.timeline { position: relative; display: flex; flex-direction: column; align-items: center; gap: var(--sp-8); width: 48px; padding: var(--sp-12) 0 var(--sp-8); background: var(--c-panel); border-left: 1px solid var(--c-border); border-right: 1px solid var(--c-border); }
/* 「⋯」時間軸顯示：桌機 28px 圓鈕（受 48px 分隔線寬度限制），手機 44px 觸控尺寸；有類別被隱藏時加 .has-dot（controls.css） */
.timeline__more { width: 28px; height: 28px; padding: 0; display: flex; align-items: center; justify-content: center; flex: none; border-radius: 50%; border: 1px solid var(--c-border-input); background: var(--c-float-bg); color: var(--c-text-2); cursor: pointer; }
.timeline__more:hover { color: var(--c-text); border-color: var(--c-text); }
.timeline__more .icon { width: 16px; height: 16px; }
.timeline__more:focus-visible { outline: 2px solid var(--c-brand); outline-offset: 2px; }

.timeline__body { flex: 1; min-height: 0; width: 100%; display: flex; flex-direction: column; align-items: center; gap: var(--sp-4); }
.timeline__track { position: relative; flex: 1; min-height: 0; width: 32px; cursor: pointer; touch-action: none; }
.timeline__track:focus-visible { outline: 2px solid var(--c-brand); outline-offset: 2px; border-radius: var(--r-4); }
.timeline__track[aria-disabled="true"] { cursor: default; opacity: .6; }
.timeline__segments { position: absolute; top: 0; bottom: 0; left: 50%; width: 6px; transform: translateX(-50%); display: flex; flex-direction: column; gap: var(--sp-4); }
.timeline__segment { min-height: 2px; border-radius: var(--r-3); background: var(--c-chapter-track); }
.timeline__segments.is-segmented .timeline__segment { cursor: pointer; }
.timeline__segment[data-state="played"] { background: var(--c-brand-bg-2); }
.timeline__segment[data-state="current"] { background: var(--c-kind-chapter); align-self: center; width: 8px; }
.timeline__segment[data-state="upcoming"] { background: var(--c-chapter-track); }
.timeline__segment[data-state="played"], .timeline__segment[data-state="upcoming"] { align-self: center; width: 6px; }

/* 圖標道：標註在左半、筆記在右半，互不重疊；道本身不接收指標，只有圖標按鈕可按 */
.timeline__lane { position: absolute; top: 0; bottom: 0; width: 50%; pointer-events: none; }
.timeline__lane--annot { left: 0; }
.timeline__lane--note { right: 0; }
.timeline__marker { position: absolute; top: var(--pos); width: 20px; height: 20px; padding: 0; display: flex; align-items: center; justify-content: center; background: none; border: none; border-radius: 50%; cursor: pointer; pointer-events: auto; transform: translateY(-50%); z-index: 2; }
.timeline__marker--annot { --kind: var(--c-kind-annot); left: 0; }
.timeline__marker--note { --kind: var(--c-kind-note); right: 0; }
.timeline__marker:focus-visible { outline: 2px solid var(--c-text); outline-offset: 1px; }
.timeline__dot { width: 10px; height: 10px; border-radius: 50%; background: var(--kind); transition: transform .12s; }
.timeline__marker--annot .timeline__dot { border-radius: 1px; transform: rotate(45deg); }
.timeline__marker.is-highlighted { z-index: 4; }
.timeline__marker.is-highlighted .timeline__dot { transform: scale(1.5); box-shadow: 0 0 0 2px var(--c-panel), 0 0 0 4px var(--kind); }
.timeline__marker--annot.is-highlighted .timeline__dot { transform: rotate(45deg) scale(1.5); }

.timeline__line { position: absolute; left: 0; right: 0; top: var(--pos); height: 2px; background: var(--c-playhead); transform: translateY(-50%); pointer-events: none; z-index: 5; }
.timeline__line[hidden], .timeline__loop[hidden], .timeline__pin[hidden], .timeline__tip[hidden] { display: none; }
/* 位置線兩端的小三角（設計稿畫面 41、45） */
.timeline__line::before, .timeline__line::after { content: ""; position: absolute; top: 50%; width: 0; height: 0; border: 4px solid transparent; transform: translateY(-50%); }
.timeline__line::before { left: 0; border-left-color: var(--c-playhead); border-right-width: 0; }
.timeline__line::after { right: 0; border-right-color: var(--c-playhead); border-left-width: 0; }
/* 拉桿優先（prioritize-timeline-scrubber）：位置線畫在所有標記（含強調中）與調整時間單點之上；滑鼠停在位置線附近顯示可抓取，拖曳中標記不接收指標 */
.timeline__track.is-scrub-hover { cursor: grab; }
.timeline__track.is-dragging { cursor: grabbing; }
.timeline__track.is-dragging .timeline__marker { pointer-events: none; }
.timeline__loop { position: absolute; left: 0; right: 0; top: var(--from); height: var(--span); min-height: 2px; background: var(--c-loop-range); border-radius: var(--r-3); opacity: .75; pointer-events: none; z-index: 1; }
.timeline__pin { position: absolute; left: 0; right: 0; top: var(--pos); height: 4px; background: var(--c-kind-note-text); border-radius: 2px; transform: translateY(-50%); pointer-events: none; z-index: 4; }
.timeline__pin-label { position: absolute; right: calc(100% + 6px); top: 50%; transform: translateY(-50%); white-space: nowrap; background: var(--c-kind-note-text); color: var(--c-on-kind-note); font-family: var(--font-mono); font-size: var(--fs-12); font-weight: 500; line-height: 1.5; padding: var(--sp-2) var(--sp-8); border-radius: var(--r-4); }
.timeline__pin-label:empty { display: none; }
.timeline__time { flex: none; font-family: var(--font-mono); font-size: var(--fs-12); color: var(--c-text-3); }
.timeline__time[hidden] { display: none; }

/* 提示：在軌道裡，浮在分隔線左側（蓋在播放區上），對齊圖標的位置 */
.timeline__tip { position: absolute; z-index: 8; right: calc(100% + 8px); top: var(--pos); transform: translateY(-50%); max-width: 320px; padding: var(--sp-4) var(--sp-8); border-radius: var(--r-4); background: var(--c-inverse); color: var(--c-on-inverse); font-size: var(--fs-12); line-height: 1.5; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; pointer-events: none; }

/* 調寬：兩側 7px 邊緣（hover 出現細線）與底部握把；只有桌機直向才有 */
.timeline__edge { position: absolute; top: 0; bottom: 0; width: 7px; z-index: 6; cursor: col-resize; touch-action: none; }
.timeline__edge--start { left: -4px; }
.timeline__edge--end { right: -4px; }
.timeline__edge:hover, .timeline__edge.is-dragging { background: linear-gradient(var(--c-brand), var(--c-brand)) center / 2px 100% no-repeat; }
.timeline__edge--start:hover, .timeline__edge--start.is-dragging { background-position: left center; }
.timeline__edge--end:hover, .timeline__edge--end.is-dragging { background-position: right center; }
.timeline__grip { flex: none; width: 100%; height: 24px; display: flex; align-items: center; justify-content: center; cursor: col-resize; touch-action: none; }
.timeline__grip-bars { width: 6px; height: 18px; border-left: 2px solid var(--c-private-border); border-right: 2px solid var(--c-private-border); }
.timeline__grip:hover .timeline__grip-bars, .timeline__grip:focus-visible .timeline__grip-bars, .timeline__grip.is-dragging .timeline__grip-bars { border-color: var(--c-brand); }
.timeline__grip:focus-visible { outline: none; }
.timeline__grip[hidden], .timeline__edge[hidden] { display: none; }

/* 手機：橫向，左側開關、右側軌道（標註上排、筆記下排） */
@media (max-width: 899.98px) {
  .timeline { flex-direction: row; width: auto; height: 52px; padding: 0 var(--sp-12); gap: var(--sp-12); border: 0; border-top: 1px solid var(--c-border); border-bottom: 1px solid var(--c-border); }
  .timeline__more { width: 44px; height: 44px; align-self: center; }
  .timeline__body { flex-direction: row; height: 100%; }
  .timeline__track { width: auto; height: 100%; }
  .timeline__segments { top: 50%; bottom: auto; left: 0; right: 0; width: auto; height: 6px; transform: translateY(-50%); flex-direction: row; }
  .timeline__segment[data-state="current"] { align-self: stretch; height: 8px; width: auto; margin: 0; }
  .timeline__segment[data-state="played"], .timeline__segment[data-state="upcoming"] { align-self: stretch; width: auto; }
  .timeline__lane { left: 0; right: 0; top: 0; bottom: auto; width: auto; height: 50%; }
  .timeline__lane--note { top: 50%; }
  .timeline__marker { top: 50%; left: var(--pos); right: auto; transform: translate(-50%, -50%); }
  .timeline__line { left: var(--pos); right: auto; top: 0; bottom: 0; width: 2px; height: auto; transform: translateX(-50%); }
  .timeline__line::before { top: 0; left: 50%; border: 4px solid transparent; border-top-color: var(--c-playhead); border-bottom-width: 0; transform: translateX(-50%); }
  .timeline__line::after { top: auto; bottom: 0; right: auto; left: 50%; border: 4px solid transparent; border-bottom-color: var(--c-playhead); border-top-width: 0; transform: translateX(-50%); }
  .timeline__loop { left: var(--from); width: var(--span); right: auto; top: 0; bottom: 0; height: auto; min-height: 0; min-width: 2px; }
  .timeline__pin { left: var(--pos); right: auto; top: 0; bottom: 0; width: 4px; height: auto; transform: translateX(-50%); }
  .timeline__pin-label { right: auto; left: 50%; top: auto; bottom: calc(100% + 2px); transform: translateX(-50%); }
  .timeline__tip { right: auto; left: var(--pos); top: auto; bottom: calc(100% + 4px); transform: translateX(-50%); }
}
