:root {
  --bg: #0f1115;
  --card: #181b22;
  --fg: #e9ebf1;
  --muted: #8b91a1;
  --accent: #ffb347;
  --ok: #22c55e;
  --wait: #f5a524;
  --bad: #ef4444;
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  background: var(--bg);
  color: var(--fg);
  font: 15px/1.35 system-ui, -apple-system, "Segoe UI", sans-serif;
}

body {
  position: fixed;
  inset: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) 0 env(safe-area-inset-left);
  user-select: none;
  -webkit-user-select: none;
  touch-action: pan-x pan-y; /* no pinch zoom; both pans stay with the scrollers */
}

/* ── Status bar ─────────────────────────────────────────────── */
#bar { display: flex; align-items: center; gap: 8px; padding: 10px 18px; font-size: 13px; color: var(--muted); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--bad); transition: background .3s; }
.dot.wait { background: var(--wait); }
.dot.ok { background: var(--ok); box-shadow: 0 0 0 3px rgb(34 197 94 / .18); }
#count { margin-left: auto; font-variant-numeric: tabular-nums; }
#bar { cursor: pointer; }

/* Connection details, opened by tapping the status bar. */
#conn { position: fixed; top: calc(40px + env(safe-area-inset-top)); left: 10px; right: 10px; z-index: 15; padding: 14px 16px; border-radius: 18px; background: #23262f; box-shadow: 0 10px 30px rgb(0 0 0 / .45); font-size: 14px; }
#conn[hidden] { display: none; }
#conn p { margin: 0 0 10px; }
#conn .hint { margin: 6px 0 0; color: var(--muted); font-size: 12px; }
.switch { display: flex; align-items: center; gap: 10px; font-weight: 600; }
.switch input { width: 20px; height: 20px; accent-color: var(--accent); }

/* ── Carousel of tabs ───────────────────────────────────────── */
#carousel {
  display: flex;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x mandatory;
  overscroll-behavior: contain;
  scrollbar-width: none;
  transition: opacity .3s;
}
#carousel::-webkit-scrollbar { display: none; }
body.offline #carousel { opacity: .45; }

.card { flex: 0 0 100%; height: 100%; padding: 0 10px; scroll-snap-align: center; scroll-snap-stop: always; }
.frame { position: relative; height: 100%; border-radius: 24px; background: var(--card); overflow: hidden; transition: box-shadow .3s; }
.card.active .frame { box-shadow: inset 0 0 0 1px rgb(255 179 71 / .35); }

/* Vertical overscroll stays in the card (no pull-to-refresh); horizontal swipes chain to the carousel. */
.scroller { position: absolute; inset: 0; overflow-x: hidden; overflow-y: auto; overscroll-behavior-y: contain; scrollbar-width: none; }
.scroller::-webkit-scrollbar { display: none; }
/* Alternating bands, one desktop screen each, so the page's length is felt while scrolling. */
.proxy {
  width: 100%;
  background: repeating-linear-gradient(to bottom,
    rgb(255 255 255 / .035) 0 var(--screen, 100%),
    transparent var(--screen, 100%) calc(var(--screen, 100%) * 2));
}

.head {
  position: absolute; inset: 0 0 auto 0;
  display: flex; align-items: center; gap: 12px;
  padding: 16px 18px 28px;
  background: linear-gradient(var(--card) 55%, transparent);
  pointer-events: none;
}
.titles { min-width: 0; }
.title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.host { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.fav, .letter { width: 28px; height: 28px; border-radius: 8px; flex: none; object-fit: contain; }
.letter { display: grid; place-items: center; font-weight: 700; color: #15171c; }

.badge { position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none; }
.badge .fav, .badge .letter { width: 96px; height: 96px; border-radius: 26px; font-size: 46px; opacity: .14; filter: saturate(.6); }

.rail { position: absolute; right: 7px; top: 72px; bottom: 18px; width: 4px; border-radius: 2px; background: rgb(255 255 255 / .06); pointer-events: none; }
.rail[hidden] { display: none; }
.thumb { position: absolute; left: 0; right: 0; border-radius: 2px; background: var(--accent); }

.readout {
  position: absolute; left: 50%; bottom: 22px; transform: translateX(-50%);
  padding: 6px 13px; border-radius: 999px;
  background: rgb(0 0 0 / .55); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  font-size: 13px; font-variant-numeric: tabular-nums; white-space: nowrap;
  opacity: 0; transition: opacity .35s; pointer-events: none;
}
.readout.on { opacity: 1; transition: none; }
.note { position: absolute; left: 24px; right: 24px; bottom: 28px; text-align: center; color: var(--muted); font-size: 13px; pointer-events: none; }

/* ── Toolbar ────────────────────────────────────────────────── */
#tools { display: flex; gap: 4px; padding: 8px 10px calc(8px + env(safe-area-inset-bottom)); }
#tools button, #sheet button {
  flex: 1; height: 50px; border: 0; border-radius: 16px;
  background: none; color: var(--fg); font: inherit;
  display: grid; place-items: center; position: relative;
  touch-action: manipulation;
}
#tools button:active:not(:disabled) { background: rgb(255 255 255 / .08); }
#tools button:disabled { opacity: .28; }
#tools svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
#tools svg .solid { fill: currentColor; stroke: none; }
#mute .off, #mute.muted .on { display: none; }
#mute.muted .off { display: block; }
#mute.muted { color: var(--accent); }
#listCount { position: absolute; top: 7px; left: calc(50% + 8px); min-width: 16px; padding: 0 4px; border-radius: 8px; background: var(--accent); color: #15171c; font-size: 10px; font-weight: 700; line-height: 16px; }
#listCount:empty { display: none; }

/* ── Tab list sheet ─────────────────────────────────────────── */
#sheet { position: fixed; inset: 0; z-index: 10; display: flex; flex-direction: column; background: var(--bg); padding-top: env(safe-area-inset-top); }
#sheet[hidden] { display: none; }
#sheet header { display: flex; align-items: center; padding: 8px 10px 8px 20px; }
#sheet h2 { flex: 1; margin: 0; font-size: 17px; }
#sheet button { flex: none; padding: 0 16px; color: var(--accent); font-weight: 600; }
#rows { flex: 1; margin: 0; padding: 0 10px calc(84px + env(safe-area-inset-bottom)); /* room for the Undo toast */ overflow-y: auto; list-style: none; }
/* Swipe a row left to reveal its actions; drag all the way to close the tab. */
#rows li {
  position: relative; overflow: hidden; margin-bottom: 2px; border-radius: 14px;
  max-height: 90px; touch-action: pan-y;
  transition: max-height .25s ease .15s, opacity .25s ease .15s, margin .25s ease .15s;
}
#rows .fg {
  position: relative; z-index: 1;
  display: flex; align-items: center; gap: 12px; padding: 11px 10px;
  border-radius: 14px; background: var(--bg);
}
#rows li.current .fg { background: color-mix(in srgb, var(--accent) 12%, var(--bg)); }
#rows .titles { flex: 1; }
#rows .sound { color: var(--accent); font-size: 12px; }
#rows .sound:empty { display: none; }
#rows .acts { position: absolute; inset: 0 0 0 auto; z-index: 0; display: flex; width: 0; }
#rows .act {
  flex: 1 1 0; min-width: 0; height: auto; padding: 0 12px; border: 0; border-radius: 0;
  overflow: hidden; white-space: nowrap; color: #fff; font: 600 14px/1 system-ui, -apple-system, sans-serif;
  transition: flex-grow .2s ease;
}
#rows .act.mute { background: #5b6170; }
#rows .act.close { background: #e5484d; }
/* Past the full-swipe point the outermost button takes the whole row. */
#rows li.full .act:not(:last-child) { flex-grow: 0; padding: 0; }
#rows li.full .act:last-child { place-items: center start; padding-left: 22px; }
#rows li.closing { max-height: 0; margin-bottom: 0; opacity: 0; }
#rows li.closing .fg { transform: translateX(-100%) !important; transition: transform .2s ease !important; }
#rows li.closing .acts { width: 100% !important; }

#toast {
  position: fixed; left: 12px; right: 12px; bottom: calc(14px + env(safe-area-inset-bottom)); z-index: 30;
  display: flex; align-items: center; gap: 10px; padding: 8px 8px 8px 18px;
  border-radius: 16px; background: #2b2f39; box-shadow: 0 10px 30px rgb(0 0 0 / .45);
}
#toast[hidden], #sheet[hidden] ~ #toast { display: none; }
#toastText { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#undo { flex: none; padding: 10px 12px; border: 0; background: none; color: var(--accent); font: 600 15px system-ui, -apple-system, sans-serif; }

/* Pairing: shown until this app has a pairing (a home-screen app has storage of its own). */
#pair { position: fixed; inset: 0; z-index: 20; display: flex; flex-direction: column; justify-content: center; gap: 14px; padding: 40px 28px calc(40px + env(safe-area-inset-bottom)); background: var(--bg); text-align: center; }
#pair[hidden] { display: none; }
#pair h1 { margin: 0; font-size: 22px; }
#pair p { margin: 0; color: var(--muted); }
#pairNote:empty { display: none; }
#pairNote.bad { color: var(--bad); }
.button { position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 12px 18px; border-radius: 14px; background: #2b2f39; color: var(--fg); font-weight: 600; cursor: pointer; }
.button.primary { margin-top: 10px; padding: 16px 20px; background: var(--accent); color: #111; font-size: 17px; }
.button svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linejoin: round; }
.button input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; } /* the label opens it */
#conn .button { margin-top: 12px; width: 100%; }
.pair-note:empty { display: none; }
.pair-note.bad { color: var(--bad); }
/* Chrome hasn't come for a while: what may be wrong, and the way to pair again. */
#stale { position: fixed; left: 16px; right: 16px; top: 50%; transform: translateY(-50%); z-index: 12; display: flex; flex-direction: column; gap: 12px; padding: 22px 20px; border-radius: 22px; background: #23262f; box-shadow: 0 10px 40px rgb(0 0 0 / .5); text-align: center; }
#stale[hidden] { display: none; }
#stale h2 { margin: 0; font-size: 18px; }
#stale p { margin: 0; color: var(--muted); }
.button.quiet { background: transparent; color: var(--muted); font-weight: 500; padding: 8px 12px; }
.detail { margin: 0; color: var(--muted); font-size: 11px; opacity: .8; overflow-wrap: anywhere; user-select: text; -webkit-user-select: text; }
.detail:empty { display: none; }


#message { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; padding: 40px; background: var(--bg); color: var(--muted); text-align: center; }
#message[hidden] { display: none; }

/* ── Player in a card ───────────────────────────────────────── */
.player {
  position: absolute; left: 10px; right: 10px; bottom: 10px; z-index: 2;
  pointer-events: none; /* drags over the player still scroll the page; only its buttons are targets */
  display: flex; align-items: center; gap: 4px; padding: 8px 6px 8px 8px;
  border-radius: 18px; background: rgb(255 255 255 / .07);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
}
.player[hidden], .player button[hidden] { display: none; }
.art { flex: none; width: 46px; height: 46px; margin-right: 6px; border-radius: 10px; overflow: hidden; display: grid; place-items: center; background: rgb(255 255 255 / .06); }
.art img { width: 100%; height: 100%; object-fit: cover; }
.art .fav, .art .letter { width: 30px; height: 30px; }
.meta { flex: 1; min-width: 0; }
.mtitle { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.martist { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* While an ad plays: what it is, never the ad's own title or artwork. Not a button: no Skip ad. */
.adpill { display: inline-block; margin-right: 6px; padding: 0 7px; border-radius: 999px; background: var(--wait); color: #15171c; font-weight: 700; font-size: 11px; line-height: 17px; }
.adpill[hidden] { display: none; }
.player button { border: 0; background: none; color: var(--fg); touch-action: manipulation; }
.player button { pointer-events: auto; flex: none; width: 44px; height: 44px; border-radius: 14px; display: grid; place-items: center; }
.player button:active { background: rgb(255 255 255 / .1); }
.player svg { width: 24px; height: 24px; }
.player .solid { fill: currentColor; }
.pp .pause, .pp.playing .play { display: none; }
.pp.playing .pause { display: block; }
.pp { background: var(--fg) !important; color: var(--bg) !important; border-radius: 50% !important; }
/* The artwork is a button: it opens the tab's controls (the rest of the strip lets drags through). */
.player .art { flex: none; width: 46px; height: 46px; margin-right: 6px; padding: 0; border-radius: 10px; background: rgb(255 255 255 / .06); overflow: hidden; }
/* How far the media is: a thin line along the bottom of the player. */
.prog { position: absolute; left: 14px; right: 14px; bottom: 3px; height: 2px; border-radius: 1px; background: rgb(255 255 255 / .12); overflow: hidden; pointer-events: none; }
.prog[hidden] { display: none; }
.prog i { display: block; height: 100%; width: 0; background: var(--accent); }
/* A mode running on the desktop for this tab: "Full screen", "Auto-scroll". */
.mode { position: absolute; top: 62px; left: 18px; padding: 2px 9px; border-radius: 999px; background: rgb(255 179 71 / .16); color: var(--accent); font-size: 12px; font-weight: 600; pointer-events: none; }
.mode[hidden] { display: none; }
.card.has-player .readout { bottom: 92px; }
.card.has-player .rail { bottom: 84px; }


/* ── Notices ────────────────────────────────────────────────── */
#notice {
  position: fixed; left: 12px; right: 12px; bottom: calc(76px + env(safe-area-inset-bottom)); z-index: 30;
  padding: 12px 18px; border-radius: 16px; background: #2b2f39; box-shadow: 0 10px 30px rgb(0 0 0 / .45);
  text-align: center; pointer-events: none;
}
#notice[hidden] { display: none; }
/* The one-time tip, under the status bar (it must not cover the card's player). */
#tip, #outdated { position: fixed; top: calc(42px + env(safe-area-inset-top)); left: 12px; right: 12px; z-index: 9; display: flex; align-items: center; gap: 10px; padding: 8px 8px 8px 16px; border-radius: 16px; background: #2b2f39; box-shadow: 0 10px 30px rgb(0 0 0 / .45); font-size: 14px; }
#tip[hidden], #outdated[hidden] { display: none; }
#tip span, #outdated span { flex: 1; }
#tip button, #outdated button { flex: none; min-height: 40px; padding: 0 12px; border: 0; border-radius: 12px; background: none; color: var(--accent); font: 600 15px system-ui, -apple-system, sans-serif; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* ── The "More" sheet ───────────────────────────────────────── */
/* A bottom panel in a modal dialog: the dialog fills the screen (a tap beside the panel closes
   it), the panel holds a scrolling body and the kind's main row fixed in thumb reach. */
#more-sheet { position: fixed; inset: 0; width: 100%; height: 100%; max-width: none; max-height: none; margin: 0; padding: 0; border: 0; background: none; color: var(--fg); overflow: hidden; }
#more-sheet::backdrop { background: rgb(0 0 0 / .45); } /* a plain colour: custom properties reach ::backdrop only from Safari 17.4 */
#more-sheet .panel {
  position: absolute; left: 0; right: 0; bottom: 0;
  display: flex; flex-direction: column;
  max-height: calc(100dvh - max(env(safe-area-inset-top), 12px) - 12px);
  border-radius: 22px 22px 0 0; background: #23262f;
  padding-bottom: max(16px, env(safe-area-inset-bottom));
  box-shadow: 0 -10px 40px rgb(0 0 0 / .4);
  animation: sheet-up .22s cubic-bezier(.2, .8, .2, 1);
  transition: transform .2s ease;
}
#more-sheet .panel.closing { transform: translateY(100%) !important; }
@keyframes sheet-up { from { transform: translateY(100%); } }
@media (min-width: 640px), (orientation: landscape) { #more-sheet .panel { max-width: 600px; margin-inline: auto; } }

.mhead { position: relative; display: flex; align-items: center; gap: 12px; padding: 18px 12px 10px 16px; touch-action: none; }
.grab { position: absolute; top: 7px; left: 50%; width: 36px; height: 5px; margin-left: -18px; border-radius: 3px; background: rgb(255 255 255 / .22); }
.mart { flex: none; width: 48px; height: 48px; border-radius: 12px; display: grid; place-items: center; background: rgb(255 255 255 / .06); overflow: hidden; }
.mart .fav, .mart .letter { width: 32px; height: 32px; }
.mtitles { flex: 1; min-width: 0; }
#moreTitle { margin: 0; font-size: 16px; line-height: 1.25; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; outline: none; }
.msub { display: flex; gap: 4px; margin: 2px 0 0; font-size: 12px; color: var(--muted); white-space: nowrap; }
.msubtext { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.mtoast { position: absolute; left: 12px; right: 12px; bottom: calc(96px + env(safe-area-inset-bottom)); z-index: 1; margin: 0; padding: 12px 18px; border-radius: 16px; background: #3a3f4b; box-shadow: 0 10px 30px rgb(0 0 0 / .45); text-align: center; pointer-events: none; }
.mtoast[hidden] { display: none; }
.mdone { flex: none; align-self: flex-start; min-width: 44px; height: 44px; padding: 0 12px; border: 0; border-radius: 12px; background: none; color: var(--accent); font: 600 15px system-ui, -apple-system, sans-serif; }
.mstatus { display: flex; align-items: center; gap: 10px; margin: 0 16px 8px; padding: 8px 12px; border-radius: 12px; background: rgb(245 165 36 / .14); color: #f8c46b; font-size: 13px; }
.mstatus[hidden] { display: none; }
.mstatus span { flex: 1; }
.mstatus button { min-height: 32px; padding: 0 12px; border: 0; border-radius: 10px; background: rgb(255 255 255 / .1); color: var(--fg); font: 600 13px system-ui, -apple-system, sans-serif; }
.mstatus button[hidden] { display: none; }

.mbody { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 0 16px; }
.mprimary { flex: none; padding: 8px 16px 0; }
.mprimary:empty { display: none; }
.mnote { margin: 4px 0 12px; color: var(--muted); font-size: 13px; }
.msec + .msec { margin-top: 6px; padding-top: 6px; border-top: 1px solid rgb(255 255 255 / .06); }
.mskel { height: 44px; margin: 8px 0; border-radius: 12px; background: linear-gradient(90deg, rgb(255 255 255 / .04), rgb(255 255 255 / .09), rgb(255 255 255 / .04)); background-size: 200% 100%; animation: skel 1.2s linear infinite; }
@keyframes skel { to { background-position: -200% 0; } }

.mctl { padding: 4px 0; }
.mrow { display: flex; align-items: center; gap: 12px; min-height: 52px; }
.mlabel { flex: 1; min-width: 0; font-weight: 600; }
.mlabel small { display: block; font-weight: 400; font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mlabel small:empty { display: none; }
.mwhy { margin: -4px 0 4px; font-size: 12px; color: var(--muted); }
.mwhy:empty { display: none; }
.mctl.failed .mwhy { color: var(--wait); }
.mctl.pending { opacity: .75; }

.stepper { display: flex; align-items: center; gap: 4px; }
.stepper button { min-width: 48px; height: 48px; border: 0; border-radius: 14px; background: rgb(255 255 255 / .08); color: var(--fg); font: 600 20px system-ui, -apple-system, sans-serif; touch-action: manipulation; }
.stepper .mpct { min-width: 76px; background: none; font-size: 15px; font-variant-numeric: tabular-nums; }
.stepper button:active:not(:disabled) { background: rgb(255 255 255 / .16); }
.stepper button:disabled { opacity: .35; }

/* Switches: native on iOS (<input switch>, with a haptic); a checkbox drawn as one elsewhere. */
.mswitch input { flex: none; width: 51px; height: 31px; margin: 0; accent-color: var(--ok); }
.no-switch .mswitch input { appearance: none; -webkit-appearance: none; position: relative; border-radius: 16px; background: rgb(255 255 255 / .16); transition: background .2s; }
.no-switch .mswitch input::before { content: ""; position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: 50%; background: #fff; box-shadow: 0 2px 4px rgb(0 0 0 / .3); transition: transform .2s; }
.no-switch .mswitch input:checked { background: var(--ok); }
.no-switch .mswitch input:checked::before { transform: translateX(20px); }
.mswitch input:disabled { opacity: .4; }

/* Media: previous, play/pause, next — big in the main row, compact in the body. */
.mmedia { display: flex; align-items: center; justify-content: center; gap: 18px; }
.mmedia button { display: grid; place-items: center; width: 64px; height: 64px; border: 0; border-radius: 18px; background: rgb(255 255 255 / .08); color: var(--fg); touch-action: manipulation; }
.mmedia.compact { justify-content: flex-start; gap: 8px; padding: 6px 0; }
.mmedia.compact button { width: 52px; height: 52px; }
.mmedia .mm-play { width: 72px; height: 72px; border-radius: 50%; background: var(--fg); color: var(--bg); }
.mmedia.compact .mm-play { width: 56px; height: 56px; }
.mmedia svg { width: 28px; height: 28px; }
.mmedia .solid { fill: currentColor; }
.mm-play .pause, .mm-play.playing .play { display: none; }
.mm-play.playing .pause { display: block; }
.mmedia button:disabled { opacity: .35; }
#more-sheet.offline .mbody, #more-sheet.offline .mprimary { opacity: .6; }
.mmedia svg .line { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.mart img { width: 100%; height: 100%; object-fit: cover; }
.mstatus.live { background: rgb(239 68 68 / .16); color: #fca5a5; font-weight: 700; letter-spacing: .04em; }

/* The seek zones: the largest targets; taps add up, a bubble shows the total. */
.mmedia:has(.mzone) { gap: 8px; }
.mmedia .mzone { position: relative; flex: 1; min-width: 0; height: 96px; border-radius: 20px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; }
.mmedia.compact .mzone { height: 52px; flex-direction: row; gap: 4px; }
.mmedia .mm-prev, .mmedia .mm-next, .mmedia .mm-restart { width: 56px; height: 56px; }
.mmedia.compact .mm-prev, .mmedia.compact .mm-next, .mmedia.compact .mm-restart { width: 52px; height: 52px; }
.mzlabel { font-size: 12px; font-weight: 700; font-variant-numeric: tabular-nums; }
.mbubble { position: absolute; top: 6px; left: 50%; transform: translateX(-50%) scale(.9); padding: 1px 8px; border-radius: 999px; background: var(--accent); color: #15171c; font: 700 13px/18px system-ui, -apple-system, sans-serif; white-space: nowrap; opacity: 0; transition: opacity .25s, transform .25s; pointer-events: none; }
.mbubble.on { opacity: 1; transform: translateX(-50%) scale(1); transition: none; }
.mmedia.compact .mbubble { top: -10px; }

/* The scrubber: a 44 px target around a 4 px track; the time under it in tabular figures. */
.mscrubwrap { padding: 2px 0 0; }
.mscrub { position: relative; height: 44px; display: flex; align-items: center; touch-action: pan-y; cursor: pointer; outline: none; } /* up and down scroll the sheet */
.mtrack { position: relative; flex: 1; height: 4px; border-radius: 2px; background: rgb(255 255 255 / .16); }
.mfill { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 2px; background: var(--accent); }
.mknob { position: absolute; top: 50%; width: 14px; height: 14px; margin: -7px 0 0 -7px; border-radius: 50%; background: #fff; box-shadow: 0 1px 4px rgb(0 0 0 / .4); transition: transform .15s; }
.mscrubwrap.dragging .mknob { transform: scale(1.5); }
.mscrubwrap.off .mtrack { opacity: .45; }
.mscrubwrap.off .mknob { display: none; }
.mscrub:focus-visible .mtrack { outline: 2px solid var(--accent); outline-offset: 6px; }
.mtimes { display: flex; align-items: center; gap: 8px; margin-top: -8px; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.mtchap { flex: 1; min-width: 0; text-align: center; color: var(--fg); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mtrest { min-height: 32px; padding: 0; border: 0; background: none; color: inherit; font: inherit; }

/* Volume (the speaker is the tab's sound), speed, repeat, shuffle. */
.mspeaker { display: grid; place-items: center; }
.mspeaker svg { width: 22px; height: 22px; }
.mspeaker svg .line { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.mspeaker.on { color: var(--accent); }
.mvolpct { min-width: 60px; text-align: center; font-variant-numeric: tabular-nums; }
.mrate .mlabel { display: block; padding: 10px 0 6px; }
.mseg { display: flex; gap: 4px; }
.mseg button { flex: 1; min-width: 0; min-height: 44px; border: 0; border-radius: 12px; background: rgb(255 255 255 / .08); color: var(--fg); font: 600 14px system-ui, -apple-system, sans-serif; touch-action: manipulation; }
.mseg button[aria-pressed="true"] { background: var(--accent); color: #15171c; }
.mseg button:disabled { opacity: .35; }
.mchip, .mwide, .mplaynext { min-height: 44px; padding: 0 16px; border: 0; border-radius: 14px; background: rgb(255 255 255 / .08); color: var(--fg); font: 600 15px system-ui, -apple-system, sans-serif; touch-action: manipulation; }
.mwide { width: 100%; margin: 6px 0; }
.mchip:disabled, .mwide:disabled, .mplaynext:disabled { opacity: .35; }

/* YouTube's next video, lists and chapters. */
.mhead3 { display: flex; align-items: baseline; gap: 8px; margin: 12px 0 4px; font-size: 13px; font-weight: 600; color: var(--muted); }
.mhead3 small { font-weight: 400; }
.mlist { list-style: none; margin: 0; padding: 0; }
.mitem { display: flex; align-items: center; gap: 12px; min-height: 64px; padding: 5px 6px; border-radius: 12px; touch-action: manipulation; cursor: pointer; }
.mitem:active { background: rgb(255 255 255 / .06); }
.mitem.cur { background: color-mix(in srgb, var(--accent) 14%, transparent); }
.mitem.pending { opacity: .55; }
.mitem[aria-disabled="true"] { opacity: .45; }
.mitem.big { min-height: 72px; }
.mthumb { flex: none; width: 96px; height: 54px; border-radius: 8px; overflow: hidden; background: rgb(255 255 255 / .06); }
.mthumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
img.broken { display: none; }
.mititles { flex: 1; min-width: 0; }
.mititle { font-size: 14px; font-weight: 600; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.miby { margin-top: 2px; font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mplaynext { flex: none; min-height: 56px; background: var(--accent); color: #15171c; }
.mchapters summary { min-height: 44px; display: flex; align-items: center; margin: 0; cursor: pointer; }
.mchapters.off { opacity: .45; pointer-events: none; }
.mchap { min-height: 48px; }
.mchtime { flex: none; width: 56px; color: var(--muted); font-variant-numeric: tabular-nums; }

/* PDFs: Previous, the page (it opens Go to page), Next — 64 px, in thumb reach. */
.mpdf { display: flex; flex-direction: column; gap: 8px; }
.mhint { margin: 0; font-size: 12px; color: var(--muted); text-align: center; }
.mpages { display: flex; gap: 8px; }
.mpg { flex: 1; min-width: 0; height: 64px; padding: 0 6px; border: 0; border-radius: 18px; background: rgb(255 255 255 / .08); color: var(--fg); font: 600 16px system-ui, -apple-system, sans-serif; font-variant-numeric: tabular-nums; white-space: nowrap; touch-action: manipulation; }
.mpg:disabled { opacity: .35; }
.mpgmid { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; background: none; box-shadow: inset 0 0 0 1px rgb(255 255 255 / .14); }
.mpgmain { max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.mpgsub { font-weight: 400; font-size: 11px; color: var(--muted); }
.mpgsub:empty { display: none; }
.mpgmid .mbubble { top: -12px; }
.mpgmid.opening .mpgmain { animation: wait 1s ease-in-out infinite alternate; }
@keyframes wait { to { opacity: .4; } }
.mgoto { display: flex; align-items: center; gap: 4px; }
.mgoto[hidden] { display: none; }
.mgoto .mchip { padding: 0 10px; }
.mgoto .mstep { flex: none; min-width: 44px; height: 44px; border: 0; border-radius: 14px; background: rgb(255 255 255 / .08); color: var(--fg); font: 600 20px system-ui, -apple-system, sans-serif; touch-action: manipulation; }
.mgonum { flex: 1; min-width: 0; height: 44px; padding: 0 4px; border: 0; border-radius: 12px; background: rgb(255 255 255 / .06); color: var(--fg); font: 600 17px system-ui, -apple-system, sans-serif; text-align: center; -moz-appearance: textfield; }
.mgonum::-webkit-inner-spin-button, .mgonum::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.mgo { flex: none; min-height: 44px; padding: 0 14px; border: 0; border-radius: 14px; background: var(--accent); color: #15171c; font: 600 15px system-ui, -apple-system, sans-serif; touch-action: manipulation; }
.mgoto button:disabled, .mgonum:disabled { opacity: .35; }

/* Ordinary pages: the scroll steps (in thumb reach when the page comes first), Contents, the link. */
.msteps { display: flex; gap: 8px; }
.msteps button { flex: 1; min-width: 0; height: 64px; padding: 0 4px; border: 0; border-radius: 18px; background: rgb(255 255 255 / .08); color: var(--fg); font: 600 15px system-ui, -apple-system, sans-serif; white-space: nowrap; touch-action: manipulation; }
.msteps.compact { padding: 6px 0; }
.msteps.compact button { height: 48px; border-radius: 14px; font-size: 14px; }
.msteps button:disabled { opacity: .35; }
.mcontents .mitem { min-height: 44px; }
.mcontents .mhead-2 { padding-left: 18px; }
.mcontents .mhead-3 { padding-left: 30px; }
.mcontents .mhead-3 .mititle { font-weight: 400; }
.mcontents .mititle { flex: 1; min-width: 0; }
.mipage { flex: none; color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.mreader .mlabel small { white-space: normal; }
.mfind .mrow { gap: 8px; }
.mfind input { flex: 1; min-width: 0; height: 48px; padding: 0 14px; border: 0; border-radius: 14px; background: rgb(255 255 255 / .06); color: var(--fg); font: 16px system-ui, -apple-system, sans-serif; } /* 16 px: iOS doesn't zoom in */
.mfind input::placeholder { color: var(--muted); }
.mfind input:disabled { opacity: .35; }
.mfind .mwhy { margin: 2px 0 4px; font-variant-numeric: tabular-nums; }
.mshare .mchip + .mchip { margin-left: 4px; }
.mrate .mlabel small { display: inline; margin-left: 8px; }
.mseg.tight { flex: none; gap: 3px; }
.mseg.tight button { flex: none; min-width: 42px; padding: 0 6px; }

@media (prefers-reduced-motion: reduce) {
  #more-sheet .panel { animation: none; transition: none; }
  .mpgmid.opening .mpgmain { animation: none; }
  .mskel { animation: none; }
  .mbubble, .mbubble.on { transform: translateX(-50%); transition: none; }
  .mknob { transition: none; }
}
