/* ══ RiseTube ═════════════════════════════════════════════════════
 * Shares the media shell (.media-page / .media-topbar / .media-content)
 * with Cinema; everything below is the YouTube-shaped layer on top.
 * ═══════════════════════════════════════════════════════════════ */

/* ── Watch switch (both media topbars) ─────────────────────────── */

/*
 * Same segmented control as the profile page's tabs (.pf__tabs) - soft square
 * corners, an accent-tinted pill and accent text on the active side.
 */
.watch-switch {
	position: relative;
	display: inline-flex;
	align-items: center;
	gap: 0.3rem;
	padding: 0.25rem;
	border: 1px solid var(--line);
	border-radius: var(--r);
	background: rgb(var(--tint) / 0.04);
}

/*
 * Centred against the whole topbar rather than against whatever space the
 * brand and the search field happen to leave - out of flow, so neither can
 * push it off-centre.
 */
.media-topbar .watch-switch {
	position: absolute;
	left: 50%;
	top: 50%;
	transform: translate(-50%, -50%);
	margin: 0;
}

.watch-switch__glide {
	position: absolute;
	top: 0.25rem;
	left: 0;
	height: calc(100% - 0.5rem);
	border-radius: var(--r-xs);
	background: var(--accent-low);
	border: 1px solid rgb(var(--accent-rgb) / 0.3);
	pointer-events: none;
}

/* Set once the pill has been measured into place - see bindWatchSwitch. */
.watch-switch.is-ready .watch-switch__glide {
	transition:
		transform 0.45s var(--spring),
		width 0.45s var(--spring);
}

.watch-switch__btn {
	position: relative;
	z-index: 1;
	display: inline-flex;
	align-items: center;
	gap: 0.4rem;
	padding: 0.45rem 0.9rem;
	border: 1px solid transparent;
	background: transparent;
	border-radius: var(--r-xs);
	color: var(--text-dim);
	font: inherit;
	font-size: 0.8rem;
	font-weight: 640;
	white-space: nowrap;
	cursor: pointer;
	transition:
		background 0.2s var(--ease),
		color 0.2s var(--ease);
}

.watch-switch__btn .lucide {
	width: 15px;
	height: 15px;
}

.watch-switch__btn:hover {
	background: rgb(var(--tint) / 0.06);
	color: var(--text);
}

.watch-switch__btn.on {
	background: transparent;
	color: var(--accent);
}

/* ── "What do you want to watch?" picker ───────────────────────── */

.watch-pick {
	display: flex;
	flex-direction: column;
	gap: 0.6rem;
}

.watch-pick__card {
	display: flex;
	align-items: center;
	gap: 0.85rem;
	width: 100%;
	padding: 0.85rem 0.95rem;
	border: 1px solid var(--line);
	border-radius: var(--r-lg);
	background: var(--surface);
	color: var(--text);
	font: inherit;
	text-align: left;
	cursor: pointer;
	transition:
		border-color 0.25s var(--ease),
		background 0.25s var(--ease),
		transform 0.35s var(--spring);
}

.watch-pick__card:hover {
	transform: translateY(-2px);
	border-color: rgb(var(--accent-rgb) / 0.45);
	background: var(--surface-2);
}

.watch-pick__card.is-current {
	border-color: rgb(var(--accent-rgb) / 0.3);
}

.watch-pick__icon {
	display: grid;
	place-items: center;
	width: 42px;
	height: 42px;
	flex-shrink: 0;
	border-radius: var(--r);
	background: var(--accent-low);
	color: var(--accent);
}

.watch-pick__icon .lucide {
	width: 20px;
	height: 20px;
}

.watch-pick__text {
	display: flex;
	flex-direction: column;
	gap: 0.15rem;
	min-width: 0;
}

.watch-pick__text strong {
	font-size: 0.94rem;
	font-weight: 700;
}

.watch-pick__text small {
	font-size: 0.76rem;
	color: var(--text-dim);
	line-height: 1.4;
}

.watch-pick__arrow {
	margin-left: auto;
	color: var(--text-mute);
	transition: transform 0.35s var(--spring), color 0.25s var(--ease);
}

.watch-pick__card:hover .watch-pick__arrow {
	transform: translateX(3px);
	color: var(--accent);
}

/* ── Topbar ────────────────────────────────────────────────────── */

.tube-page .media-topbar {
	position: sticky;
	background: linear-gradient(
		color-mix(in srgb, var(--shell) 92%, transparent),
		color-mix(in srgb, var(--shell) 55%, transparent) 70%,
		transparent
	);
	border-bottom-color: transparent;
	color: var(--text);
}

.tube-topbar.is-stuck,
.tube-topbar.is-watching {
	background: var(--shell);
	border-color: var(--line);
	color: var(--text);
}

.tube-search {
	position: relative;
	display: flex;
	align-items: center;
	flex: 1;
	min-width: 180px;
	max-width: 420px;
	margin-left: auto;
}

.tube-search__icon {
	position: absolute;
	left: 0.85rem;
	width: 15px;
	height: 15px;
	color: var(--text-mute);
	pointer-events: none;
	transition: color 0.2s var(--ease);
}

.tube-search:focus-within .tube-search__icon {
	color: var(--accent);
}

.tube-search__input {
	width: 100%;
	height: 38px;
	border: 1px solid var(--line);
	border-radius: 999px;
	background: rgb(var(--tint) / 0.05);
	color: var(--text);
	padding: 0 2.6rem 0 2.4rem;
	font: inherit;
	font-size: 0.85rem;
	outline: none;
	transition:
		border-color 0.2s var(--ease),
		box-shadow 0.25s var(--ease),
		background 0.2s var(--ease);
}

.tube-search__input::placeholder {
	color: var(--text-mute);
}

.tube-search__input:focus {
	border-color: rgb(var(--accent-rgb) / 0.55);
	background: rgb(var(--tint) / 0.07);
	box-shadow: 0 0 0 4px rgb(var(--accent-rgb) / 0.1);
}

.tube-search__go {
	position: absolute;
	right: 4px;
	display: grid;
	place-items: center;
	width: 30px;
	height: 30px;
	border: none;
	border-radius: 50%;
	background: var(--accent-low);
	color: var(--accent);
	cursor: pointer;
	transition: background 0.2s var(--ease), transform 0.3s var(--spring);
}

.tube-search__go:hover {
	background: var(--accent-mid);
	transform: scale(1.06);
}

.tube-search__go .lucide {
	width: 15px;
	height: 15px;
}

/* ── Feed ──────────────────────────────────────────────────────── */

.tube-content {
	padding: 0 var(--gutter) calc(var(--taskbar-h) + 3rem);
	scroll-behavior: smooth;
}

.tube-chips {
	position: sticky;
	top: 0;
	z-index: 8;
	display: flex;
	gap: 0.4rem;
	padding: 0.75rem 0;
	overflow-x: auto;
	scrollbar-width: none;
	background: linear-gradient(var(--bg) 65%, transparent);
}

.tube-chips::-webkit-scrollbar {
	display: none;
}

.tube-chips .chip {
	padding: 0.4rem 0.85rem;
	font-size: 0.78rem;
	white-space: nowrap;
}

.tube-chips .chip:hover {
	color: var(--text);
	background: rgb(var(--tint) / 0.09);
}

.tube-section {
	margin: 0.4rem 0 2rem;
	animation: tube-in 0.5s var(--ease) both;
}

.tube-section__head {
	display: flex;
	align-items: center;
	gap: 0.6rem;
	margin: 0 0 0.9rem;
}

.tube-chan__sort {
	position: relative;
	margin-left: auto;
}

.tube-chan__sort-btn {
	display: inline-flex;
	align-items: center;
	gap: 0.4rem;
	padding: 0.38rem 0.7rem;
	border: 1px solid var(--line);
	border-radius: var(--r-sm, 8px);
	background: var(--surface-2);
	color: var(--text);
	font: inherit;
	font-size: 0.78rem;
	font-weight: 640;
	cursor: pointer;
	transition: background 0.18s var(--ease), border-color 0.18s var(--ease);
}

.tube-chan__sort-btn:hover {
	background: var(--surface-3, var(--surface-2));
	border-color: var(--line-2);
}

.tube-chan__sort-btn .lucide {
	width: 14px;
	height: 14px;
	color: var(--text-dim);
}

.tube-chan__sort-menu {
	position: absolute;
	top: calc(100% + 6px);
	right: 0;
	z-index: 8;
	min-width: 132px;
	padding: 0.35rem;
	border: 1px solid var(--line-2);
	border-radius: var(--r, 10px);
	background: var(--shell, rgb(14 16 19 / 0.98));
	box-shadow: 0 14px 32px rgb(0 0 0 / 0.45);
}

.tube-chan__sort-menu button {
	display: block;
	width: 100%;
	padding: 0.4rem 0.55rem;
	border: none;
	border-radius: var(--r-xs, 6px);
	background: none;
	color: var(--text-dim);
	font: inherit;
	font-size: 0.78rem;
	text-align: left;
	cursor: pointer;
	transition: background 0.15s var(--ease), color 0.15s var(--ease);
}

.tube-chan__sort-menu button:hover {
	background: var(--surface-2);
	color: var(--text);
}

.tube-chan__sort-menu button.on {
	color: var(--text);
	background: var(--surface-2);
	font-weight: 680;
}

.tube-section__head h2 {
	display: flex;
	align-items: center;
	gap: 0.5rem;
	margin: 0;
	font-size: 1.02rem;
	font-weight: 720;
	letter-spacing: -0.01em;
}

.tube-section__head h2 .lucide {
	width: 17px;
	height: 17px;
	color: var(--accent);
}

.tube-section__count {
	padding: 0.12rem 0.5rem;
	border-radius: 999px;
	background: var(--surface-2);
	color: var(--text-mute);
	font-size: 0.7rem;
	font-variant-numeric: tabular-nums;
}

.tube-linkbtn {
	margin-left: auto;
	border: none;
	background: none;
	color: var(--text-dim);
	font: inherit;
	font-size: 0.76rem;
	font-weight: 640;
	cursor: pointer;
	transition: color 0.2s var(--ease);
}

.tube-linkbtn:hover {
	color: var(--accent);
}

.tube-grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(268px, 1fr));
	gap: 1.5rem 1.1rem;
}

.tube-rail {
	display: grid;
	grid-auto-flow: column;
	grid-auto-columns: minmax(258px, 1fr);
	gap: 1rem;
	overflow-x: auto;
	padding-bottom: 0.5rem;
	scrollbar-width: thin;
	scroll-snap-type: x proximity;
}

.tube-rail > * {
	scroll-snap-align: start;
}

.tube-rail::-webkit-scrollbar {
	height: 6px;
}

.tube-rail::-webkit-scrollbar-thumb {
	background: var(--line-2);
	border-radius: 999px;
}

/* ── Cards ─────────────────────────────────────────────────────── */

.tube-card {
	display: flex;
	flex-direction: column;
	gap: 0.7rem;
	cursor: pointer;
	outline: none;
	animation: tube-in 0.45s var(--ease) both;
}

.tube-card__art {
	position: relative;
	aspect-ratio: 16 / 9;
	border-radius: var(--r);
	overflow: hidden;
	background: rgb(var(--tint) / 0.04);
	transition:
		transform 0.4s var(--spring),
		box-shadow 0.4s var(--ease);
}

.tube-card__art img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	opacity: 0;
	transform: scale(1.02);
	transition:
		opacity 0.5s var(--ease),
		transform 0.6s var(--ease);
}

.tube-card__art img.is-loaded {
	opacity: 1;
	transform: scale(1);
}

.tube-card:hover .tube-card__art,
.tube-card:focus-visible .tube-card__art {
	transform: translateY(-3px);
	box-shadow:
		0 16px 34px rgb(0 0 0 / 0.5),
		0 0 0 1px rgb(var(--accent-rgb) / 0.28);
}

.tube-card:hover .tube-card__art img {
	transform: scale(1.06);
}

.tube-card__blank {
	display: grid;
	place-items: center;
	width: 100%;
	height: 100%;
	color: var(--text-mute);
}

.tube-card__blank .lucide {
	width: 32px;
	height: 32px;
}

.tube-card__shade {
	position: absolute;
	inset: 0;
	background: linear-gradient(transparent 55%, rgb(0 0 0 / 0.55));
	opacity: 0;
	transition: opacity 0.3s var(--ease);
}

.tube-card:hover .tube-card__shade {
	opacity: 1;
}

.tube-card__badge {
	position: absolute;
	right: 8px;
	bottom: 8px;
	padding: 0.14rem 0.4rem;
	border-radius: 6px;
	background: rgb(0 0 0 / 0.82);
	color: #fff;
	font-size: 0.7rem;
	font-weight: 650;
	font-variant-numeric: tabular-nums;
	letter-spacing: 0.01em;
}

.tube-card__badge.is-live {
	background: #e0264a;
	letter-spacing: 0.06em;
}

.tube-card__play {
	position: absolute;
	inset: 0;
	display: grid;
	place-items: center;
	color: #fff;
	opacity: 0;
	border-radius: var(--r);
	transition: opacity 0.28s var(--ease);
}

.tube-card__play .lucide {
	width: 44px;
	height: 44px;
	padding: 11px;
	border-radius: var(--r);
	background: rgb(var(--accent-rgb) / 0.9);
	color: var(--accent-ink);
	transform: scale(0.85);
	transition: transform 0.4s var(--spring);
	box-shadow: 0 10px 26px rgb(0 0 0 / 0.5);
}

.tube-card:hover .tube-card__play {
	opacity: 1;
}

.tube-card:hover .tube-card__play .lucide {
	transform: scale(1);
}

.tube-card__resume {
	position: absolute;
	left: 0;
	right: 0;
	bottom: 0;
	height: 3px;
	background: rgb(var(--tint) / 0.22);
}

.tube-card__resume i {
	display: block;
	height: 100%;
	background: var(--accent);
}

.tube-card__body {
	display: flex;
	gap: 0.7rem;
	min-width: 0;
}

.tube-card__avatar {
	display: grid;
	place-items: center;
	width: 34px;
	height: 34px;
	flex-shrink: 0;
	padding: 0;
	border: none;
	border-radius: 50%;
	overflow: hidden;
	background: var(--surface-2);
	cursor: pointer;
	transition: box-shadow 0.25s var(--ease), transform 0.3s var(--spring);
}

.tube-card__avatar img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	opacity: 0;
	transition: opacity 0.4s var(--ease);
}

.tube-card__avatar img.is-loaded {
	opacity: 1;
}

.tube-card__avatar:hover {
	transform: scale(1.08);
	box-shadow: 0 0 0 2px rgb(var(--accent-rgb) / 0.5);
}

.tube-card__text {
	min-width: 0;
}

.tube-card__title {
	margin: 0 0 0.25rem;
	font-size: 0.88rem;
	font-weight: 660;
	line-height: 1.35;
	letter-spacing: -0.005em;
	display: -webkit-box;
	-webkit-line-clamp: 2;
	line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
}

.tube-card__channel {
	display: block;
	max-width: 100%;
	padding: 0;
	border: none;
	background: none;
	color: var(--text-dim);
	font: inherit;
	font-size: 0.78rem;
	text-align: left;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
	cursor: pointer;
	transition: color 0.2s var(--ease);
}

.tube-card__channel:hover {
	color: var(--accent);
}

.tube-card__meta {
	margin: 0.1rem 0 0;
	font-size: 0.75rem;
	color: var(--text-mute);
	font-variant-numeric: tabular-nums;
}

/* Sidebar / up-next variant */
.tube-card--row {
	display: grid;
	grid-template-columns: 168px 1fr;
	gap: 0.7rem;
	align-items: start;
}

.tube-card--row .tube-card__art {
	border-radius: var(--r);
}

.tube-card--row .tube-card__title {
	font-size: 0.82rem;
	-webkit-line-clamp: 2;
	line-clamp: 2;
}

.tube-card--row .tube-card__play .lucide {
	width: 34px;
	height: 34px;
	padding: 9px;
}

.tube-card--skeleton {
	pointer-events: none;
}

.tube-card--skeleton .tube-card__art {
	aspect-ratio: 16 / 9;
}

.tube-sk-line {
	height: 11px;
	border-radius: 6px;
	margin-bottom: 0.45rem;
}

.tube-sk-line--short {
	width: 55%;
}

.tube-sk-line--title {
	height: 20px;
	width: 70%;
	margin-top: 1rem;
}

.tube-card--skeleton .tube-card__body {
	display: block;
}

/* ── Subscription rail ─────────────────────────────────────────── */

.tube-subrail {
	display: flex;
	gap: 0.55rem;
	overflow-x: auto;
	padding-bottom: 0.4rem;
	scrollbar-width: none;
}

.tube-subrail::-webkit-scrollbar {
	display: none;
}

.tube-subchip {
	display: inline-flex;
	align-items: center;
	gap: 0.5rem;
	flex-shrink: 0;
	padding: 0.3rem 0.85rem 0.3rem 0.3rem;
	border: 1px solid var(--line);
	border-radius: 999px;
	background: var(--surface);
	color: var(--text-dim);
	font: inherit;
	font-size: 0.78rem;
	font-weight: 620;
	cursor: pointer;
	transition:
		border-color 0.25s var(--ease),
		color 0.25s var(--ease),
		transform 0.3s var(--spring);
}

.tube-subchip:hover {
	color: var(--text);
	border-color: rgb(var(--accent-rgb) / 0.4);
	transform: translateY(-2px);
}

.tube-subchip img,
.tube-subchip__blank {
	width: 28px;
	height: 28px;
	border-radius: 50%;
	object-fit: cover;
	display: grid;
	place-items: center;
	background: var(--surface-2);
}

.tube-subchip span {
	max-width: 140px;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

/* ── Channel hover preview ─────────────────────────────────────── */

.tube-peek {
	position: fixed;
	z-index: 90;
	width: 290px;
	padding: 0.85rem;
	border: 1px solid var(--line-2);
	border-radius: var(--r-lg);
	background: var(--shell);
	box-shadow: 0 22px 50px rgb(0 0 0 / 0.6);
	opacity: 0;
	transform: translateY(6px) scale(0.97);
	pointer-events: none;
	transition:
		opacity 0.22s var(--ease),
		transform 0.32s var(--spring);
}

.tube-peek.is-open {
	opacity: 1;
	transform: none;
}

.tube-peek__head {
	display: flex;
	align-items: center;
	gap: 0.65rem;
}

.tube-peek__head img {
	width: 42px;
	height: 42px;
	border-radius: 50%;
	object-fit: cover;
}

.tube-peek__head strong {
	display: block;
	font-size: 0.86rem;
	font-weight: 700;
}

.tube-peek__head span {
	font-size: 0.72rem;
	color: var(--text-mute);
}

.tube-peek p {
	margin: 0.6rem 0 0;
	font-size: 0.75rem;
	line-height: 1.5;
	color: var(--text-dim);
}

.tube-peek__cta {
	display: block;
	margin-top: 0.6rem;
	font-size: 0.7rem;
	font-weight: 650;
	color: var(--accent);
}

/* ── Watch page ────────────────────────────────────────────────── */

.tube-watch,
.tube-channel {
	flex: 1;
	overflow-y: auto;
	overflow-x: hidden;
	padding: 0 var(--gutter) calc(var(--taskbar-h) + 3rem);
}

.tube-watch {
	padding-top: 1.75rem;
}

.tube-watch__inner {
	display: grid;
	grid-template-columns: minmax(0, 1fr) 372px;
	gap: 1.6rem;
	align-items: start;
	max-width: 1680px;
	margin: 0 auto;
	animation: tube-in 0.45s var(--ease) both;
}

.tube-watch__main {
	min-width: 0;
}

.tube-backbtn {
	display: inline-flex;
	align-items: center;
	gap: 0.45rem;
	margin: 0 0 0.75rem;
	padding: 0.4rem 0.8rem 0.4rem 0.6rem;
	border: 1px solid var(--line);
	border-radius: var(--r);
	background: var(--surface);
	color: var(--text-dim);
	font: inherit;
	font-size: 0.78rem;
	font-weight: 640;
	cursor: pointer;
	transition:
		color 0.2s var(--ease),
		border-color 0.2s var(--ease),
		transform 0.3s var(--spring);
}

.tube-backbtn:hover {
	color: var(--text);
	border-color: var(--line-2);
	transform: translateX(-2px);
}

.tube-backbtn--float {
	position: absolute;
	top: 1rem;
	left: 1rem;
	z-index: 4;
	background: rgb(10 12 14 / 0.75);
}

/* ── Player stage ──────────────────────────────────────────────── */

.tube-watch__main,
.tube-stage {
	overflow: visible;
}

/* Keep titles / meta / comments above any spilled ambient glow. */
.tube-watch__main > :not(.tube-stage) {
	position: relative;
	z-index: 3;
}

.tube-stage {
	position: relative;
	z-index: 0;
	background: transparent;
	aspect-ratio: 16 / 9;
	isolation: isolate;
	margin: 0.35rem 0 0.85rem;
}

/*
 * Live ambient: muted twin of the player, soft halo under the frame + text.
 */
.tube-stage__glow {
	position: absolute;
	inset: -2.5%;
	z-index: 0;
	border-radius: var(--r-xl);
	overflow: hidden;
	filter: blur(64px) saturate(1.05) brightness(0.72);
	opacity: 0.34;
	pointer-events: none;
	backface-visibility: hidden;
	background: #000;
	transition: opacity 0.35s ease;
}

.tube-stage.is-playing .tube-stage__glow {
	opacity: 0.42;
}

.tube-stage__glow-mount,
.tube-stage__glow-mount iframe {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	border: 0;
	pointer-events: none;
}

.tube-stage__frame {
	position: absolute;
	inset: 0;
	z-index: 2;
	border-radius: var(--r-xl);
	overflow: hidden;
	background: #000;
	box-shadow:
		0 30px 70px -20px rgb(0 0 0 / 0.75),
		0 0 0 1px rgb(var(--tint) / 0.06);
}

.tube-stage__mount,
.tube-stage__mount iframe {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	border: 0;
}

/* Swallows clicks so YouTube's own hidden controls never fire. */
.tube-stage__catch {
	position: absolute;
	inset: 0;
	z-index: 2;
	cursor: pointer;
}

.tube-stage__poster {
	position: absolute;
	inset: 0;
	z-index: 3;
	display: grid;
	place-items: center;
	background-size: cover;
	background-position: center;
	transition: opacity 0.45s var(--ease), visibility 0.45s;
}

.tube-stage__poster::before {
	content: "";
	position: absolute;
	inset: 0;
	background: rgb(0 0 0 / 0.35);
}

.tube-stage__poster.is-gone {
	opacity: 0;
	visibility: hidden;
	pointer-events: none;
}

.tube-stage__fail {
	position: relative;
	max-width: 420px;
	margin: 0;
	padding: 1rem 1.2rem;
	border-radius: var(--r);
	background: rgb(10 12 14 / 0.88);
	color: var(--text-dim);
	font-size: 0.86rem;
	text-align: center;
}

.tube-bigplay {
	position: relative;
	display: grid;
	place-items: center;
	width: 78px;
	height: 78px;
	border: none;
	border-radius: 50%;
	background: rgb(var(--accent-rgb) / 0.92);
	color: var(--accent-ink);
	cursor: pointer;
	box-shadow: 0 18px 44px rgb(0 0 0 / 0.55);
	transition: transform 0.4s var(--spring);
}

.tube-bigplay:hover {
	transform: scale(1.08);
}

.tube-bigplay .lucide {
	width: 30px;
	height: 30px;
	margin-left: 4px;
}

.tube-spinner {
	position: absolute;
	inset: 0;
	z-index: 4;
	display: grid;
	place-items: center;
	pointer-events: none;
}

.tube-spinner i {
	width: 42px;
	height: 42px;
	border-radius: 50%;
	border: 3px solid rgb(var(--tint) / 0.16);
	border-top-color: var(--accent);
	animation: tube-spin 0.8s linear infinite;
}

.tube-toast {
	position: absolute;
	top: 1rem;
	left: 50%;
	z-index: 6;
	transform: translateX(-50%);
	padding: 0.35rem 0.8rem;
	border-radius: 999px;
	background: rgb(0 0 0 / 0.75);
	color: #fff;
	font-size: 0.78rem;
	font-weight: 650;
	pointer-events: none;
	opacity: 0;
}

.tube-toast.is-on {
	animation: tube-flash 0.7s var(--ease) both;
}

/* ── Controls ──────────────────────────────────────────────────── */

.tube-controls {
	position: absolute;
	left: 0;
	right: 0;
	bottom: 0;
	z-index: 5;
	padding: 2.6rem 0.9rem 0.65rem;
	background: linear-gradient(transparent, rgb(0 0 0 / 0.78));
	opacity: 0;
	transform: translateY(8px);
	pointer-events: none;
	transition:
		opacity 0.28s var(--ease),
		transform 0.32s var(--ease);
}

.tube-stage.show-chrome .tube-controls {
	opacity: 1;
	transform: none;
	pointer-events: auto;
}

.tube-stage.show-chrome {
	cursor: default;
}

/*
 * Proxied playback. The embed can't be driven from out here, so it keeps its
 * own controls and ours retreat to a corner with the two buttons that are
 * about the page rather than the video.
 */
.tube-stage.is-proxied .tube-stage__catch,
.tube-stage.is-proxied .tube-scrub,
.tube-stage.is-proxied .tube-controls__row > *:not([data-theater]):not([data-fullscreen]) {
	display: none;
}

.tube-stage.is-proxied .tube-controls {
	top: 0;
	bottom: auto;
	left: auto;
	padding: 0.55rem 0.6rem 1.8rem;
	background: linear-gradient(rgb(0 0 0 / 0.55), transparent);
	border-bottom-left-radius: var(--r-lg);
}

.tube-scrub {
	position: relative;
	height: 18px;
	display: flex;
	align-items: center;
	cursor: pointer;
	touch-action: none;
	outline: none;
}

.tube-scrub__rail {
	position: relative;
	width: 100%;
	height: 4px;
	border-radius: 999px;
	background: rgb(var(--tint) / 0.25);
	transition: height 0.18s var(--ease);
}

.tube-scrub:hover .tube-scrub__rail,
.tube-scrub:focus-visible .tube-scrub__rail {
	height: 6px;
}

.tube-scrub__buffer,
.tube-scrub__fill {
	position: absolute;
	left: 0;
	top: 0;
	bottom: 0;
	border-radius: 999px;
}

.tube-scrub__buffer {
	background: rgb(var(--tint) / 0.28);
	transition: width 0.4s linear;
}

.tube-scrub__fill {
	background: var(--accent);
	box-shadow: 0 0 12px rgb(var(--accent-rgb) / 0.5);
}

.tube-scrub__knob {
	position: absolute;
	top: 50%;
	width: 13px;
	height: 13px;
	margin-left: -6.5px;
	border-radius: 50%;
	background: var(--accent);
	transform: translateY(-50%) scale(0);
	transition: transform 0.25s var(--spring);
	box-shadow: 0 2px 8px rgb(0 0 0 / 0.5);
}

.tube-scrub:hover .tube-scrub__knob,
.tube-scrub:focus-visible .tube-scrub__knob {
	transform: translateY(-50%) scale(1);
}

.tube-scrub__tip {
	position: absolute;
	bottom: 22px;
	transform: translateX(-50%);
	padding: 0.15rem 0.45rem;
	border-radius: 6px;
	background: rgb(0 0 0 / 0.86);
	color: #fff;
	font-size: 0.72rem;
	font-variant-numeric: tabular-nums;
	pointer-events: none;
}

.tube-controls__row {
	position: relative;
	display: flex;
	align-items: center;
	gap: 0.15rem;
	margin-top: 0.15rem;
}

.tube-controls__spacer {
	flex: 1;
}

.tube-cbtn {
	position: relative;
	display: grid;
	place-items: center;
	width: 36px;
	height: 36px;
	border: none;
	border-radius: var(--r-sm);
	background: none;
	color: #fff;
	cursor: pointer;
	transition:
		background 0.2s var(--ease),
		transform 0.3s var(--spring);
}

.tube-cbtn:hover {
	background: rgb(var(--tint) / 0.14);
	transform: scale(1.06);
}

.tube-cbtn .lucide {
	width: 19px;
	height: 19px;
}

.tube-vol {
	display: flex;
	align-items: center;
}

.tube-vol__slider {
	width: 0;
	opacity: 0;
	height: 4px;
	margin: 0;
	appearance: none;
	background: rgb(var(--tint) / 0.3);
	border-radius: 999px;
	outline: none;
	cursor: pointer;
	transition:
		width 0.3s var(--ease),
		opacity 0.25s var(--ease),
		margin 0.3s var(--ease);
}

.tube-vol:hover .tube-vol__slider,
.tube-vol__slider:focus-visible {
	width: 72px;
	opacity: 1;
	margin: 0 0.5rem 0 0.15rem;
}

.tube-vol__slider::-webkit-slider-thumb {
	appearance: none;
	width: 12px;
	height: 12px;
	border-radius: 50%;
	background: #fff;
	cursor: pointer;
}

.tube-vol__slider::-moz-range-thumb {
	width: 12px;
	height: 12px;
	border: none;
	border-radius: 50%;
	background: #fff;
	cursor: pointer;
}

.tube-time {
	margin-left: 0.4rem;
	color: rgb(var(--tint) / 0.85);
	font-size: 0.76rem;
	font-variant-numeric: tabular-nums;
	white-space: nowrap;
}

.tube-time b {
	font-weight: 650;
	color: #fff;
}

.tube-menu {
	position: absolute;
	right: 84px;
	bottom: 44px;
	width: 168px;
	max-height: min(70vh, 420px);
	overflow: auto;
	padding: 0.5rem;
	border: 1px solid var(--line-2);
	border-radius: var(--r);
	background: color-mix(in srgb, var(--shell) 94%, transparent);
	box-shadow: 0 18px 40px rgb(0 0 0 / 0.45);
	animation: tube-in 0.22s var(--ease) both;
}

.tube-menu--player {
	width: 188px;
}

.tube-menu__sec + .tube-menu__sec {
	margin-top: 0.45rem;
	padding-top: 0.45rem;
	border-top: 1px solid var(--line);
}

.tube-menu p {
	margin: 0.1rem 0 0.4rem;
	padding: 0 0.4rem;
	font-size: 0.68rem;
	font-weight: 700;
	letter-spacing: 0.06em;
	text-transform: uppercase;
	color: var(--text-mute);
}

.tube-menu button {
	display: block;
	width: 100%;
	padding: 0.34rem 0.5rem;
	border: none;
	border-radius: var(--r-xs);
	background: none;
	color: var(--text-dim);
	font: inherit;
	font-size: 0.78rem;
	text-align: left;
	cursor: pointer;
	transition: background 0.18s var(--ease), color 0.18s var(--ease);
}

.tube-menu button:hover {
	background: var(--surface-2);
	color: var(--text);
}

.tube-menu button.on {
	color: var(--accent);
	background: var(--accent-low);
}

/* ── Title, owner, actions ─────────────────────────────────────── */

.tube-title {
	margin: 1rem 0 0.75rem;
	font-size: 1.32rem;
	font-weight: 730;
	line-height: 1.3;
	letter-spacing: -0.015em;
}

.tube-owner {
	display: flex;
	align-items: center;
	gap: 0.8rem;
	flex-wrap: wrap;
	padding-bottom: 1rem;
	border-bottom: 1px solid var(--line);
}

.tube-owner__id {
	display: flex;
	align-items: center;
	gap: 0.7rem;
	padding: 0;
	border: none;
	background: none;
	color: var(--text);
	font: inherit;
	text-align: left;
	cursor: pointer;
}

.tube-owner__id img,
.tube-owner__blank {
	width: 42px;
	height: 42px;
	border-radius: 50%;
	object-fit: cover;
	display: grid;
	place-items: center;
	background: var(--surface-2);
	transition: box-shadow 0.25s var(--ease);
}

.tube-owner__id:hover img,
.tube-owner__id:hover .tube-owner__blank {
	box-shadow: 0 0 0 2px rgb(var(--accent-rgb) / 0.5);
}

.tube-owner__id strong {
	display: block;
	font-size: 0.9rem;
	font-weight: 690;
}

.tube-owner__id small {
	font-size: 0.74rem;
	color: var(--text-mute);
}

.tube-sub {
	display: inline-flex;
	align-items: center;
	gap: 0.45rem;
	padding: 0.5rem 1.05rem;
	border: 1px solid transparent;
	border-radius: var(--r);
	background: var(--accent);
	color: var(--accent-ink);
	font: inherit;
	font-size: 0.82rem;
	font-weight: 700;
	cursor: pointer;
	transition:
		background 0.25s var(--ease),
		color 0.25s var(--ease),
		transform 0.3s var(--spring);
}

.tube-sub:hover {
	transform: translateY(-1px);
	background: var(--accent-hi);
}

.tube-sub.on {
	background: var(--surface-2);
	border-color: var(--line-2);
	color: var(--text-dim);
}

.tube-sub.on:hover {
	background: var(--surface-3);
	color: var(--text);
}

.tube-sub .lucide {
	width: 16px;
	height: 16px;
}

.tube-actions {
	display: flex;
	align-items: center;
	gap: 0.5rem;
	flex-wrap: wrap;
	margin-left: auto;
}

.tube-vote {
	display: flex;
	align-items: center;
	border: 1px solid var(--line);
	border-radius: var(--r);
	background: var(--surface);
	overflow: hidden;
}

.tube-vote__btn {
	display: inline-flex;
	align-items: center;
	gap: 0.4rem;
	padding: 0.5rem 0.95rem;
	border: none;
	background: none;
	color: var(--text-dim);
	font: inherit;
	font-size: 0.8rem;
	font-weight: 650;
	font-variant-numeric: tabular-nums;
	cursor: pointer;
	transition: background 0.2s var(--ease), color 0.2s var(--ease);
}

.tube-vote__btn:hover {
	background: var(--surface-2);
	color: var(--text);
}

.tube-vote__btn.on {
	color: var(--accent);
}

.tube-vote__btn.on .lucide {
	fill: rgb(var(--accent-rgb) / 0.25);
}

.tube-vote__btn .lucide {
	width: 17px;
	height: 17px;
}

.tube-vote__btn.is-pop .lucide {
	animation: tube-pop 0.4s var(--spring);
}

.tube-vote__sep {
	width: 1px;
	height: 20px;
	background: var(--line);
}


.tube-pill {
	display: inline-flex;
	align-items: center;
	gap: 0.45rem;
	padding: 0.5rem 0.95rem;
	border: 1px solid var(--line);
	border-radius: 999px;
	background: var(--surface);
	color: var(--text-dim);
	font: inherit;
	font-size: 0.8rem;
	font-weight: 650;
	cursor: pointer;
	transition:
		background 0.2s var(--ease),
		color 0.2s var(--ease),
		transform 0.3s var(--spring);
}

.tube-pill:hover {
	background: var(--surface-2);
	color: var(--text);
	transform: translateY(-1px);
}

.tube-pill .lucide {
	width: 16px;
	height: 16px;
}

/* ── Description ───────────────────────────────────────────────── */

.tube-desc {
	margin: 1rem 0 1.6rem;
	padding: 0.95rem 1.05rem;
	border: 1px solid var(--line);
	border-radius: var(--r-lg);
	background: var(--surface);
}

.tube-desc__stats {
	display: flex;
	gap: 0.7rem;
	flex-wrap: wrap;
	margin-bottom: 0.5rem;
	font-size: 0.82rem;
	color: var(--text-dim);
	font-variant-numeric: tabular-nums;
}

.tube-desc__stats strong {
	color: var(--text);
	font-weight: 700;
}

.tube-live {
	padding: 0 0.4rem;
	border-radius: 5px;
	background: #e0264a;
	color: #fff;
	font-size: 0.7rem;
	font-weight: 700;
	letter-spacing: 0.06em;
}

.tube-desc__body {
	max-height: 4.6rem;
	overflow: hidden;
	font-size: 0.83rem;
	line-height: 1.65;
	color: var(--text-dim);
	white-space: pre-wrap;
	word-break: break-word;
	mask-image: linear-gradient(#000 55%, transparent);
	-webkit-mask-image: linear-gradient(#000 55%, transparent);
	transition: max-height 0.35s var(--ease);
}

.tube-desc.is-open .tube-desc__body {
	max-height: none;
	mask-image: none;
	-webkit-mask-image: none;
}

.tube-desc__body a {
	color: var(--accent);
	text-decoration: none;
}

.tube-desc__body a:hover {
	text-decoration: underline;
}

.tube-desc__more {
	margin-top: 0.5rem;
	padding: 0;
	border: none;
	background: none;
	color: var(--text);
	font: inherit;
	font-size: 0.78rem;
	font-weight: 700;
	cursor: pointer;
}

.tube-desc__more:hover {
	color: var(--accent);
}

.tube-stamp {
	padding: 0 0.15rem;
	border: none;
	background: none;
	color: var(--accent);
	font: inherit;
	font-variant-numeric: tabular-nums;
	cursor: pointer;
}

.tube-stamp:hover {
	text-decoration: underline;
}

/* ── Comments ──────────────────────────────────────────────────── */

.tube-comments {
	margin-bottom: 2rem;
}

.tube-comments__head {
	display: flex;
	align-items: center;
	gap: 0.8rem;
	flex-wrap: wrap;
	margin-bottom: 1.1rem;
}

.tube-comments__head h2 {
	display: flex;
	align-items: center;
	gap: 0.5rem;
	margin: 0;
	font-size: 1rem;
	font-weight: 720;
}

.tube-comments__head h2 .lucide {
	width: 17px;
	height: 17px;
	color: var(--accent);
}

.tube-comments__sort {
	display: flex;
	gap: 0.35rem;
	margin-left: auto;
}

.tube-comments__list {
	display: flex;
	flex-direction: column;
	gap: 1.15rem;
}

.tube-comment {
	display: grid;
	grid-template-columns: 40px 1fr;
	gap: 0.8rem;
	animation: tube-in 0.4s var(--ease) both;
}

.tube-comment__avatar {
	width: 40px;
	height: 40px;
	border-radius: 50%;
	overflow: hidden;
	background: var(--surface-2);
}

.tube-comment__avatar img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	opacity: 0;
	transition: opacity 0.4s var(--ease);
}

.tube-comment__avatar img.is-loaded {
	opacity: 1;
}

.tube-comment__by {
	display: flex;
	align-items: baseline;
	gap: 0.5rem;
	margin: 0 0 0.25rem;
	font-size: 0.8rem;
}

.tube-comment__by strong {
	font-weight: 690;
}

.tube-comment__by span {
	font-size: 0.73rem;
	color: var(--text-mute);
}

.tube-comment__text {
	font-size: 0.85rem;
	line-height: 1.6;
	color: var(--text-dim);
	word-break: break-word;
}

.tube-comment__text a {
	color: var(--accent);
	text-decoration: none;
}

.tube-comment__foot {
	display: flex;
	align-items: center;
	gap: 1rem;
	margin-top: 0.4rem;
}

.tube-comment__likes {
	display: inline-flex;
	align-items: center;
	gap: 0.35rem;
	font-size: 0.74rem;
	color: var(--text-mute);
	font-variant-numeric: tabular-nums;
}

.tube-comment__likes .lucide {
	width: 14px;
	height: 14px;
}

.tube-comment__replies {
	display: inline-flex;
	align-items: center;
	gap: 0.3rem;
	padding: 0.2rem 0.55rem;
	border: none;
	border-radius: var(--r);
	background: var(--accent-low);
	color: var(--accent);
	font: inherit;
	font-size: 0.74rem;
	font-weight: 650;
	cursor: pointer;
	transition: background 0.2s var(--ease);
}

.tube-comment__replies:hover {
	background: var(--accent-mid);
}

.tube-comment__replies .lucide {
	width: 13px;
	height: 13px;
	transition: transform 0.3s var(--ease);
}

.tube-comment__replies.on .lucide {
	transform: rotate(180deg);
}

.tube-comment__thread {
	display: flex;
	flex-direction: column;
	gap: 0.9rem;
	margin-top: 0.9rem;
	padding-left: 0.9rem;
	border-left: 2px solid var(--line);
}

.tube-comment__thread .tube-comment {
	grid-template-columns: 30px 1fr;
	gap: 0.6rem;
}

.tube-comment__thread .tube-comment__avatar {
	width: 30px;
	height: 30px;
}

.tube-comments__off {
	padding: 1.2rem;
	border: 1px dashed var(--line);
	border-radius: var(--r);
	color: var(--text-mute);
	font-size: 0.83rem;
	text-align: center;
}

.tube-comments__loading {
	display: flex;
	flex-direction: column;
	gap: 1rem;
}

.tube-more {
	align-self: flex-start;
	padding: 0.5rem 1.05rem;
	border: 1px solid var(--line);
	border-radius: var(--r);
	background: var(--surface);
	color: var(--text-dim);
	font: inherit;
	font-size: 0.8rem;
	font-weight: 650;
	cursor: pointer;
	transition: background 0.2s var(--ease), color 0.2s var(--ease);
}

.tube-more:hover {
	background: var(--surface-2);
	color: var(--text);
}

/* ── Up-next sidebar ───────────────────────────────────────────── */

.tube-watch__side {
	position: relative;
	top: auto;
	display: flex;
	flex-direction: column;
	gap: 0.9rem;
	min-width: 0;
}

.tube-side__head {
	display: flex;
	align-items: center;
	gap: 0.5rem;
	margin: 0;
	font-size: 0.95rem;
	font-weight: 720;
}

.tube-side__head .lucide {
	width: 16px;
	height: 16px;
	color: var(--accent);
}

.tube-side__list {
	display: flex;
	flex-direction: column;
	gap: 0.85rem;
}

/* ── Channel page ──────────────────────────────────────────────── */

.tube-chan {
	position: relative;
	max-width: 1400px;
	margin: 0 auto;
	animation: tube-in 0.45s var(--ease) both;
}

.tube-chan__banner {
	position: relative;
	height: clamp(130px, 20vw, 230px);
	border-radius: var(--r-xl);
	background: var(--surface-2);
	background-size: cover;
	background-position: center;
	overflow: hidden;
}

.tube-chan__bannerveil {
	position: absolute;
	inset: 0;
	background: linear-gradient(transparent 40%, rgb(10 12 11 / 0.85));
}

.tube-chan__head {
	display: flex;
	align-items: flex-end;
	gap: 1.2rem;
	flex-wrap: wrap;
	margin: -3.2rem 0 2rem 1.5rem;
	position: relative;
	z-index: 2;
}

.tube-chan__avatar {
	display: grid;
	place-items: center;
	width: 104px;
	height: 104px;
	border-radius: 50%;
	overflow: hidden;
	background: var(--bg-2);
	border: 3px solid var(--bg);
	box-shadow: 0 14px 34px rgb(0 0 0 / 0.5);
	flex-shrink: 0;
}

.tube-chan__avatar img {
	width: 100%;
	height: 100%;
	object-fit: cover;
}

.tube-chan__id {
	min-width: 0;
	flex: 1;
	padding-bottom: 0.2rem;
}

.tube-chan__id h1 {
	margin: 0 0 0.3rem;
	font-size: 1.5rem;
	font-weight: 760;
	letter-spacing: -0.02em;
}

.tube-chan__meta {
	display: flex;
	gap: 0.5rem;
	flex-wrap: wrap;
	margin: 0;
	font-size: 0.8rem;
	color: var(--text-dim);
	font-variant-numeric: tabular-nums;
}

.tube-chan__meta span:not(:last-child)::after {
	content: " ·";
	color: var(--text-mute);
}

.tube-chan__blurb {
	margin: 0.5rem 0 0;
	max-width: 62ch;
	font-size: 0.8rem;
	line-height: 1.6;
	color: var(--text-mute);
}

/* ── Theater mode ──────────────────────────────────────────────── */

/*
 * The suggestions column folds underneath and the video takes the width it can
 * get - but height-led, so the whole 16:9 frame still fits on screen without
 * scrolling. Everything is measured off one width, so the video, the heading
 * and the suggestions below all share the same centre line.
 */
html.tube-theater {
	--tube-stage-w: min(100%, calc((100vh - var(--taskbar-h) - 11rem) * 16 / 9));
}

html.tube-theater .tube-watch {
	padding-top: 1.1rem;
}

html.tube-theater .tube-watch__inner {
	grid-template-columns: minmax(0, 1fr);
	max-width: none;
	gap: 1.4rem;
}

/*
 * Everything on the page takes the video's width and the video's left edge -
 * title, channel, description, comments and the suggestions underneath. One
 * column, one measure, nothing floating in the middle of its own margin.
 */
html.tube-theater .tube-stage,
html.tube-theater .tube-watch__main > *,
html.tube-theater .tube-watch__side {
	width: var(--tube-stage-w);
	margin-inline: auto;
}

html.tube-theater .tube-stage__frame {
	border-radius: var(--r-lg);
}

/* Inline-flex ignores auto margins, so line the button up by hand. */
html.tube-theater .tube-backbtn {
	display: flex;
	width: max-content;
	margin-inline: calc((100% - var(--tube-stage-w)) / 2) auto;
}

html.tube-theater .tube-watch__side {
	position: static;
}

html.tube-theater .tube-side__list {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(330px, 1fr));
	gap: 1rem;
}

/* ── Empty / misc ──────────────────────────────────────────────── */

.tube-empty {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 0.8rem;
	padding: 4rem 1rem;
	color: var(--text-mute);
	font-size: 0.88rem;
	text-align: center;
}

.tube-empty .lucide {
	width: 34px;
	height: 34px;
	opacity: 0.5;
}

.tube-empty--page {
	padding-top: 6rem;
}

/* ── Motion ────────────────────────────────────────────────────── */

@keyframes tube-in {
	from {
		opacity: 0;
		transform: translateY(10px);
	}
	to {
		opacity: 1;
		transform: none;
	}
}

@keyframes tube-spin {
	to {
		transform: rotate(360deg);
	}
}

@keyframes tube-pop {
	40% {
		transform: scale(1.35) translateY(-3px);
	}
	to {
		transform: none;
	}
}

@keyframes tube-flash {
	0% {
		opacity: 0;
		transform: translate(-50%, -6px);
	}
	18% {
		opacity: 1;
		transform: translate(-50%, 0);
	}
	75% {
		opacity: 1;
	}
	100% {
		opacity: 0;
	}
}

@media (prefers-reduced-motion: reduce) {
	.tube-card,
	.tube-section,
	.tube-comment,
	.tube-watch__inner,
	.tube-chan {
		animation: none;
	}
}

/* ── Responsive ────────────────────────────────────────────────── */

@media (max-width: 1180px) {
	.tube-watch__inner {
		grid-template-columns: minmax(0, 1fr);
	}

	.tube-watch__side {
		position: static;
	}

	.tube-side__list {
		display: grid;
		grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
		gap: 1rem;
	}
}

/*
 * Below this the brand and the search field close in on the middle, so the
 * switch rejoins the flow rather than sitting underneath them.
 */
@media (max-width: 1060px) {
	.media-topbar .watch-switch {
		position: static;
		transform: none;
		margin-left: auto;
	}
}

@media (max-width: 820px) {
	.media-topbar .watch-switch {
		order: 3;
	}

	.tube-search {
		order: 2;
		max-width: none;
	}

	.tube-grid {
		grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
		gap: 1.2rem 0.9rem;
	}

	.tube-title {
		font-size: 1.1rem;
	}

	.tube-actions {
		margin-left: 0;
		width: 100%;
	}

	.tube-card--row {
		grid-template-columns: 148px 1fr;
	}
}

@media (max-width: 560px) {
	.tube-grid {
		grid-template-columns: 1fr;
	}

	.tube-card--row {
		grid-template-columns: 128px 1fr;
	}

	.tube-cbtn[data-back10],
	.tube-cbtn[data-fwd10],
	.tube-cbtn[data-theater] {
		display: none;
	}
}
