/* Online stopwatch (kind "stopwatch"). Scoped to [data-stopwatch] or sw- classes. */
[data-stopwatch] .sw-face { container-type: inline-size; background: var(--canvas); border-radius: 12px; padding: 20px 8px 16px; display: flex; flex-direction: column;
  align-items: center; justify-content: center; min-height: clamp(200px, 36vh, 380px); min-width: 0; overflow: hidden; }
/* digits fill the width: vw first for older browsers, then container units (cqw) where supported */
[data-stopwatch] .sw-time { display: block; white-space: nowrap; letter-spacing: -0.045em; line-height: 1; font-size: 22vw; font-size: min(25cqw, 300px); }
[data-stopwatch] .sw-time[data-len="m"] { font-size: 19vw; font-size: min(21cqw, 260px); }
[data-stopwatch] .sw-time[data-len="l"] { font-size: 16vw; font-size: min(17cqw, 220px); }
[data-stopwatch] .sw-time[data-len="xl"] { font-size: 14vw; font-size: min(15cqw, 200px); }
[data-stopwatch] .sw-held .sw-time { color: var(--body); }
[data-stopwatch] .sw-cur { margin-top: 10px; min-height: 1.3em; font-weight: 600; font-size: clamp(18px, 4.6vw, 30px); font-variant-numeric: tabular-nums; color: var(--body); }
[data-stopwatch] .sw-controls { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
[data-stopwatch] .sw-btn { min-height: 76px; font-size: 22px; font-weight: 700; width: 100%; }
[data-stopwatch] .sw-btn:not(.pill-ink) { background: var(--canvas); }
[data-stopwatch] .sw-btn:not(.pill-ink):hover { background: var(--pressed); }
[data-stopwatch] .sw-btn:disabled { opacity: .45; }
[data-stopwatch] .sw-btn.sw-stop { box-shadow: inset 0 0 0 3px var(--ink); background: var(--canvas); color: var(--ink); }
[data-stopwatch] .sw-btn.sw-stop:hover { background: var(--pressed); opacity: 1; }
[data-stopwatch] .sw-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
[data-stopwatch] .sw-stat { background: var(--canvas); border-radius: 12px; padding: 10px 12px; min-width: 0; }
[data-stopwatch] .sw-stat span { display: block; font-size: 13px; color: var(--body); }
[data-stopwatch] .sw-stat b { display: block; font-size: 19px; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; overflow-wrap: anywhere; }
[data-stopwatch] .sw-stat-fast { box-shadow: inset 0 0 0 2px var(--signal); }
[data-stopwatch] .sw-list { background: var(--canvas); border-radius: 12px; padding: 4px 8px; min-width: 0; }
[data-stopwatch] .sw-scroll { position: relative; max-height: 420px; overflow-y: auto; }
[data-stopwatch] .sw-table th { position: sticky; top: 0; background: var(--canvas); z-index: 1; }
[data-stopwatch] .sw-table td { font-size: 17px; }
[data-stopwatch] .sw-table td.sw-lt { font-weight: 700; }
[data-stopwatch] .sw-table td.sw-diff { color: var(--body); font-size: 15px; }
[data-stopwatch] .sw-lapbtn { border: 0; background: none; padding: 4px 6px 4px 0; text-align: left; cursor: pointer; display: flex; flex-wrap: wrap; align-items: center; gap: 2px 6px;
  min-height: 44px; font-size: 17px; max-width: 13em; }
[data-stopwatch] .sw-lapbtn:focus-visible { outline: 3px solid var(--ink); outline-offset: 2px; border-radius: 6px; }
[data-stopwatch] .sw-lapname { flex-basis: 100%; font-size: 13px; color: var(--body); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
[data-stopwatch] .sw-lapname.sw-noname { color: var(--mute); text-decoration: underline dotted; }
[data-stopwatch] .sw-tag { display: inline-block; font-size: 12px; font-weight: 600; border-radius: var(--pill); padding: 1px 8px; }
[data-stopwatch] .sw-tag-fast { background: var(--signal); color: #fff; }
[data-stopwatch] .sw-tag-slow { box-shadow: inset 0 0 0 1.5px var(--ink); color: var(--ink); }
[data-stopwatch] tr.sw-fast td.sw-lt { color: var(--signal); }
[data-stopwatch] tr.sw-edit td { padding: 4px 0 10px; }
[data-stopwatch] tr.sw-edit .inp { background: var(--soft); }
[data-stopwatch] tr.sw-new td { animation: sw-new .7s ease-out; }
@keyframes sw-new { 0% { background: var(--pressed); } 100% { background: transparent; } }
[data-stopwatch] .sw-hist td { white-space: nowrap; }
[data-stopwatch] .sw-acts { display: flex; gap: 6px; justify-content: flex-end; }
[data-stopwatch] .sw-acts .pill { min-height: 40px; padding: 6px 12px; font-size: 14px; }
[data-stopwatch] .ct-chart .sw-avg { stroke: var(--mute); stroke-width: 2; stroke-dasharray: 6 5; }

/* full screen: the digits take the width, laps scroll underneath */
body.is-focus [data-stopwatch] .sw-stage { gap: 10px; }
body.is-focus [data-stopwatch] .sw-face { flex: 1 0 auto; min-height: 0; }
body.is-focus [data-stopwatch] .sw-time { font-size: min(25cqw, 52vh); }
body.is-focus [data-stopwatch] .sw-time[data-len="m"] { font-size: min(21cqw, 46vh); }
body.is-focus [data-stopwatch] .sw-time[data-len="l"] { font-size: min(17cqw, 40vh); }
body.is-focus [data-stopwatch] .sw-time[data-len="xl"] { font-size: min(15cqw, 36vh); }
body.is-focus [data-stopwatch] .sw-list { flex: 0 1 auto; min-height: 0; overflow: hidden; display: flex; }
body.is-focus [data-stopwatch] .sw-list[hidden] { display: none; }
body.is-focus [data-stopwatch] .sw-scroll { max-height: 34vh; flex: 1; }
body.is-focus [data-stopwatch] .sw-stats { display: none; }

@media (max-width: 520px) {
  [data-stopwatch] .sw-stats { grid-template-columns: 1fr 1fr; }
  [data-stopwatch] .sw-btn { min-height: 72px; font-size: 20px; }
  [data-stopwatch] .sw-table td { font-size: 15px; padding: 6px 4px; }
  [data-stopwatch] .sw-table th { padding: 6px 4px; }
  [data-stopwatch] .sw-stat b { font-size: 17px; }
}
@media (prefers-reduced-motion: reduce) { [data-stopwatch] tr.sw-new td { animation: none; } }
