:root {
  --bg: #08080a;
  --surface: #111114;
  --card: #16161a;
  --raised: #1e1e24;
  --border: #2a2a32;
  --border-hover: #454550;
  --accent: #6c5ce7;
  --accent-soft: #a29bfe;
  --accent-wash: rgba(108, 92, 231, 0.16);
  --text: #e8e6f0;
  --text-dim: #a5a4af;
  --text-muted: #85848f;
  --success: #6ee7a8;
  --warning: #f0b45a;
  --danger: #f19a9a;
  --font-display: "Chakra Petch", sans-serif;
  --font-body: "Outfit", sans-serif;
  --space-xxs: 4px;
  --space-xs: 6px;
  --space-sm: 8px;
  --space-md: 12px;
  --space-lg: 16px;
  --space-xl: 24px;
  --space-page: 32px;
  --space-section: 48px;
  --radius-compact: 5px;
  --radius-small: 6px;
  --radius-control: 8px;
  --radius-group: 11px;
  --radius-surface: 12px;
  --radius-search: 14px;
  --ease-state: cubic-bezier(0.22, 1, 0.36, 1);
  --z-dropdown: 20;
  --z-sticky: 40;
  --z-modal-backdrop: 60;
  --z-modal: 70;
  --z-toast: 80;
  --z-tooltip: 90;
  color-scheme: dark;
  font-family: var(--font-body);
  font-size: 16px;
  font-synthesis: none;
  font-kerning: normal;
}

[data-theme="light"] {
  --bg: #f1ede2;
  --surface: #faf6ec;
  --card: #ffffff;
  --raised: #ece6d6;
  --border: #d6cfbd;
  --border-hover: #b7ad98;
  --accent-wash: rgba(108, 92, 231, 0.12);
  --text: #1a1620;
  --text-dim: #4f4a5c;
  --text-muted: #686273;
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--bg);
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  color: var(--text);
  background: var(--bg);
  font-family: var(--font-body);
  font-size: 0.875rem;
  line-height: 1.5;
  text-rendering: optimizeLegibility;
}

button,
input {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

a {
  color: inherit;
  text-decoration: none;
}

img,
svg {
  display: block;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1,
h2,
h3 {
  text-wrap: balance;
}

p {
  text-wrap: pretty;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--accent-soft);
  outline-offset: 2px;
}

[hidden] {
  display: none !important;
}

/* App shell */

.header {
  position: sticky;
  top: 0;
  z-index: var(--z-sticky);
  display: flex;
  align-items: center;
  gap: var(--space-lg);
  width: 100%;
  height: 60px;
  padding: 0 var(--space-page);
  border-bottom: 1px solid var(--border);
  background: color-mix(in oklab, var(--surface) 94%, transparent);
}

.logo {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  line-height: 1;
  text-transform: uppercase;
  transition: color 200ms var(--ease-state);
}

.logo:hover {
  color: var(--accent-soft);
}

.logo-mark {
  width: 26px;
  height: 26px;
  border-radius: var(--radius-small);
}

.header-nav {
  display: flex;
  align-items: center;
  gap: 2px;
}

.nav-group {
  padding: 3px;
  border: 1px solid var(--border);
  border-radius: var(--radius-group);
  background: color-mix(in oklab, var(--card) 72%, var(--raised));
}

.nav-link {
  padding: 7px 14px;
  border-radius: var(--radius-control);
  color: var(--text-dim);
  font-family: var(--font-display);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  line-height: 1;
  text-transform: uppercase;
  transition: color 200ms var(--ease-state), background 200ms var(--ease-state);
}

.nav-link:hover {
  color: var(--text);
  background: var(--raised);
}

.nav-link.active {
  color: #ffffff;
  background: var(--accent);
}

.header-right {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  margin-left: auto;
}

.private-label {
  color: var(--text-muted);
  font-family: var(--font-display);
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: var(--radius-control);
  color: var(--text-muted);
  background: transparent;
  cursor: pointer;
  transition: color 200ms var(--ease-state), background 200ms var(--ease-state), border-color 200ms var(--ease-state), transform 80ms ease;
}

.icon-btn:hover {
  border-color: var(--border);
  color: var(--text);
  background: var(--raised);
}

.icon-btn:active {
  transform: scale(0.96);
}

.theme-icon {
  width: 17px;
  height: 17px;
}

.theme-icon-moon,
[data-theme="light"] .theme-icon-sun {
  display: none;
}

[data-theme="light"] .theme-icon-moon {
  display: block;
}

.content {
  width: 100%;
  max-width: 1400px;
  min-height: calc(100vh - 60px);
  margin: 0 auto;
  padding: var(--space-page);
}

/* Shared controls and states */

.btn-primary,
.btn-quiet {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-xs);
  min-height: 34px;
  padding: 7px var(--space-md);
  border-radius: var(--radius-control);
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  transition: color 200ms var(--ease-state), background 200ms var(--ease-state), border-color 200ms var(--ease-state), transform 80ms ease;
}

.btn-primary {
  border: 1px solid var(--accent);
  color: #ffffff;
  background: var(--accent);
}

.btn-primary:hover {
  border-color: var(--accent-soft);
  background: var(--accent-soft);
}

.btn-quiet {
  border: 1px solid var(--border);
  color: var(--text-dim);
  background: var(--raised);
}

.btn-quiet:hover {
  border-color: var(--border-hover);
  color: var(--text);
}

.btn-primary:active,
.btn-quiet:active {
  transform: scale(0.97);
}

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--space-xl);
  margin-bottom: var(--space-xl);
}

.page-head h1,
.streamer-head h1,
.home-heading h1,
.login-copy h1 {
  color: var(--text);
  font-family: var(--font-display);
  font-size: 1.625rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  line-height: 1.1;
}

.page-head p,
.streamer-title > p,
.home-heading p,
.login-copy p {
  max-width: 70ch;
  margin-top: var(--space-sm);
  color: var(--text-dim);
  font-size: 0.875rem;
}

.status-message {
  display: flex;
  align-items: flex-start;
  gap: var(--space-md);
  max-width: 70ch;
  margin-top: var(--space-xl);
  padding: var(--space-lg);
  border: 1px solid var(--border);
  border-radius: var(--radius-control);
  background: var(--surface);
}

.status-message > svg {
  flex: 0 0 auto;
  width: 20px;
  height: 20px;
}

.status-message div {
  display: grid;
  gap: var(--space-xxs);
}

.status-message strong {
  font-size: 0.875rem;
  font-weight: 600;
}

.status-message span {
  color: var(--text-dim);
  font-size: 0.875rem;
}

.status-error {
  border-color: color-mix(in oklab, var(--danger) 50%, var(--border));
  color: var(--danger);
  background: color-mix(in oklab, var(--danger) 8%, var(--surface));
}

.results-summary {
  margin-bottom: var(--space-lg);
  color: var(--text-muted);
  font-family: var(--font-display);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.next-page {
  margin-top: var(--space-page);
}

/* Home */

.home-view {
  display: grid;
  gap: var(--space-page);
  max-width: 900px;
  margin: 64px auto 0;
}

.home-heading {
  display: grid;
  gap: var(--space-xxs);
}

.search-launcher,
.browse-search {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  width: 100%;
  min-height: 58px;
  padding: var(--space-sm);
  padding-left: var(--space-lg);
  border: 1px solid var(--border);
  border-radius: var(--radius-search);
  background: var(--card);
  transition: border-color 200ms var(--ease-state), box-shadow 200ms var(--ease-state);
}

.search-launcher:focus-within,
.browse-search:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-wash);
}

.search-launcher > svg,
.browse-search > svg {
  flex: 0 0 auto;
  width: 20px;
  height: 20px;
  color: var(--text-muted);
}

.search-launcher input,
.browse-search input {
  min-width: 0;
  flex: 1;
  padding: 0;
  border: 0;
  outline: 0;
  color: var(--text);
  background: transparent;
  font-size: 1rem;
}

.search-launcher input::placeholder,
.browse-search input::placeholder {
  color: var(--text-dim);
  opacity: 1;
}

.search-launcher kbd,
.browse-search kbd {
  min-width: 26px;
  padding: var(--space-xxs) var(--space-xs);
  border: 1px solid var(--border);
  border-radius: var(--radius-compact);
  color: var(--text-muted);
  background: var(--raised);
  font-family: var(--font-display);
  font-size: 0.6875rem;
  line-height: 1;
  text-align: center;
}

.search-launcher .btn-primary,
.browse-search .btn-primary {
  align-self: stretch;
  min-width: 88px;
}

.home-note {
  display: flex;
  align-items: flex-start;
  gap: var(--space-md);
  padding-top: var(--space-xl);
  border-top: 1px solid var(--border);
}

.home-note-icon {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-control);
  color: var(--accent-soft);
  background: var(--accent-wash);
}

.home-note-icon svg {
  width: 18px;
  height: 18px;
}

.home-note h2 {
  color: var(--text);
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 600;
}

.home-note p {
  max-width: 65ch;
  margin-top: var(--space-xxs);
  color: var(--text-dim);
  font-size: 0.875rem;
}

/* Login */

.login-page .header-nav,
.login-page .private-label {
  display: none;
}

.login-page .content {
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-view {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 420px);
  gap: 64px;
  align-items: center;
  width: 100%;
  max-width: 960px;
}

.login-copy p {
  max-width: 48ch;
}

.login-form {
  display: grid;
  gap: var(--space-md);
  padding: var(--space-xl);
  border: 1px solid var(--border);
  border-radius: var(--radius-surface);
  background: var(--card);
}

.form-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-md);
  margin-bottom: var(--space-sm);
}

.form-heading h2 {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 700;
}

.form-heading p {
  color: var(--text-muted);
  font-size: 0.75rem;
}

.login-form label {
  color: var(--text-dim);
  font-size: 0.75rem;
  font-weight: 600;
}

.login-form input {
  width: 100%;
  min-height: 44px;
  padding: 0 var(--space-md);
  border: 1px solid var(--border);
  border-radius: var(--radius-control);
  outline: 0;
  color: var(--text);
  background: var(--raised);
  font-size: 1rem;
}

.login-form input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-wash);
}

.login-form .btn-primary {
  min-height: 44px;
  margin-top: var(--space-xxs);
}

.form-error {
  color: var(--danger);
  font-size: 0.875rem;
}

/* Browse search and channel results */

.browse-search {
  max-width: 820px;
}

.browse-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 300px;
  padding: var(--space-section) var(--space-xl);
  color: var(--text-dim);
  text-align: center;
}

.browse-empty > svg {
  width: 36px;
  height: 36px;
  margin-bottom: var(--space-lg);
  color: var(--text-muted);
}

.browse-empty h2 {
  color: var(--text);
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 600;
}

.browse-empty p {
  max-width: 52ch;
  margin-top: var(--space-sm);
  font-size: 0.875rem;
}

.channel-results {
  max-width: 920px;
  margin-top: var(--space-page);
}

.channel-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: var(--space-md);
}

.channel-row {
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr) auto auto;
  gap: var(--space-md);
  align-items: center;
  min-height: 80px;
  padding: var(--space-md);
  border: 1px solid var(--border);
  border-radius: var(--radius-group);
  background: var(--card);
  transition: border-color 200ms var(--ease-state), background 200ms var(--ease-state), transform 200ms var(--ease-state);
}

.channel-row:hover {
  border-color: var(--accent);
  background: var(--raised);
  transform: translateY(-2px);
}

.channel-row img {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--raised);
}

.channel-copy {
  display: grid;
  min-width: 0;
  gap: 2px;
}

.channel-copy strong {
  overflow: hidden;
  color: var(--text);
  font-size: 1rem;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.channel-copy span {
  overflow: hidden;
  color: var(--text-muted);
  font-size: 0.75rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.live-status {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  color: var(--accent-soft);
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
}

.live-status > span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
}

.row-arrow {
  width: 18px;
  height: 18px;
  color: var(--text-muted);
  transition: color 200ms var(--ease-state), transform 200ms var(--ease-state);
}

.channel-row:hover .row-arrow {
  color: var(--accent-soft);
  transform: translateX(2px);
}

/* Streamer VODs */

.streamer-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--space-xl);
  padding-bottom: var(--space-xl);
  border-bottom: 1px solid var(--border);
}

.streamer-title {
  min-width: 0;
}

.streamer-head h1 {
  overflow-wrap: anywhere;
}

.back-link {
  display: inline-flex;
  gap: var(--space-xs);
  align-items: center;
  margin-bottom: var(--space-md);
  color: var(--text-dim);
  font-size: 0.75rem;
  font-weight: 500;
}

.back-link:hover {
  color: var(--accent-soft);
}

.source-chip {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  gap: var(--space-xs);
  min-height: 30px;
  padding: var(--space-xs) var(--space-md);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text-dim);
  background: var(--raised);
  font-size: 0.75rem;
  font-weight: 500;
}

.source-chip svg {
  width: 14px;
  height: 14px;
}

.source-note {
  display: flex;
  align-items: flex-start;
  gap: var(--space-sm);
  max-width: 70ch;
  margin-top: var(--space-lg);
  color: var(--text-muted);
}

.source-note svg {
  flex: 0 0 auto;
  width: 16px;
  height: 16px;
  margin-top: 2px;
}

.source-note p {
  font-size: 0.75rem;
}

.vod-section {
  margin-top: var(--space-page);
}

.vod-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: var(--space-page) var(--space-lg);
}

.vod-card {
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius-surface);
  background: var(--card);
  transition: border-color 200ms var(--ease-state), transform 200ms var(--ease-state), box-shadow 200ms var(--ease-state);
}

.vod-card:hover {
  border-color: var(--accent);
  transform: translateY(-3px);
  box-shadow: 0 8px 8px color-mix(in oklab, var(--bg) 68%, transparent);
}

.vod-card:focus-visible {
  outline-offset: 3px;
}

.vod-thumb {
  position: relative;
  display: block;
  overflow: hidden;
  aspect-ratio: 16 / 9;
  background: var(--raised);
}

.vod-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 300ms var(--ease-state), filter 300ms var(--ease-state);
}

.vod-card:hover .vod-thumb img {
  transform: scale(1.025);
  filter: brightness(0.78);
}

.thumb-shade {
  position: absolute;
  inset: 0;
  background: color-mix(in oklab, var(--bg) 18%, transparent);
  opacity: 0;
  transition: opacity 200ms var(--ease-state);
}

.vod-card:hover .thumb-shade {
  opacity: 1;
}

.play-icon {
  position: absolute;
  inset: 50% auto auto 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  color: #ffffff;
  background: var(--accent);
  opacity: 0;
  transform: translate(-50%, -44%) scale(0.92);
  transition: opacity 200ms var(--ease-state), transform 200ms var(--ease-state);
}

.play-icon svg {
  width: 22px;
  height: 22px;
  fill: currentColor;
  transform: translateX(1px);
}

.vod-card:hover .play-icon,
.vod-card:focus-visible .play-icon {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

.duration {
  position: absolute;
  right: var(--space-sm);
  bottom: var(--space-sm);
  padding: var(--space-xxs) var(--space-xs);
  border-radius: var(--radius-compact);
  color: #ffffff;
  background: rgba(8, 8, 10, 0.88);
  font-family: var(--font-display);
  font-size: 0.6875rem;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

.vod-body {
  display: grid;
  gap: var(--space-sm);
  padding: var(--space-md) var(--space-lg) var(--space-lg);
}

.vod-title {
  display: -webkit-box;
  min-height: 2.8em;
  overflow: hidden;
  color: var(--text);
  font-size: 0.875rem;
  font-weight: 600;
  line-height: 1.4;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.vod-meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
  color: var(--text-muted);
  font-size: 0.75rem;
  font-variant-numeric: tabular-nums;
}

.vod-meta span + span::before {
  margin-right: var(--space-sm);
  color: var(--border-hover);
  content: "·";
}

/* Watch */

.watch-page {
  overflow: hidden;
}

.watch-page .content {
  max-width: none;
  height: calc(100vh - 60px);
  height: calc(100dvh - 60px);
  min-height: 0;
  padding: 0;
}

.watch-layout {
  display: flex;
  width: 100%;
  height: 100%;
  min-height: 0;
}

.player-main {
  display: flex;
  min-width: 0;
  min-height: 0;
  flex: 1;
  flex-direction: column;
  background: var(--bg);
}

.player-frame {
  position: relative;
  min-width: 0;
  min-height: 0;
  flex: 1;
  overflow: hidden;
  background: var(--bg);
}

#twitch-player,
#twitch-player iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.player-bar {
  display: flex;
  align-items: center;
  gap: var(--space-lg);
  min-height: 76px;
  padding: var(--space-md) var(--space-lg);
  border-top: 1px solid var(--border);
  background: var(--surface);
}

.player-copy {
  display: grid;
  min-width: 0;
  flex: 1;
  gap: 2px;
}

.player-streamer {
  width: fit-content;
  color: var(--accent-soft);
  font-size: 0.75rem;
  font-weight: 600;
}

.player-streamer:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.player-title {
  overflow: hidden;
  color: var(--text);
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.player-meta {
  overflow: hidden;
  color: var(--text-muted);
  font-size: 0.75rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.player-meta-warning,
.secure-context-warning {
  color: var(--warning);
}

.theatre-btn {
  flex: 0 0 auto;
}

.theatre-btn svg {
  width: 15px;
  height: 15px;
}

.theatre-mode .theatre-btn {
  border-color: var(--accent);
  color: #ffffff;
  background: var(--accent);
}

.secure-context-warning {
  padding: var(--space-sm) var(--space-lg);
  border-top: 1px solid color-mix(in oklab, var(--warning) 45%, var(--border));
  background: color-mix(in oklab, var(--warning) 8%, var(--surface));
  font-size: 0.75rem;
}

.chat-panel {
  position: relative;
  display: flex;
  width: 340px;
  min-width: 300px;
  min-height: 0;
  flex: 0 0 auto;
  flex-direction: column;
  border-left: 1px solid var(--border);
  background: var(--surface);
}

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
  min-height: 58px;
  padding: var(--space-md) var(--space-lg);
  border-bottom: 1px solid var(--border);
}

.chat-header h2 {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 600;
}

.chat-status {
  max-width: 34ch;
  margin-top: 2px;
  overflow: hidden;
  color: var(--text-muted);
  font-size: 0.6875rem;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-status[data-state="error"] {
  color: var(--danger);
  white-space: normal;
}

.chat-retry {
  min-height: 30px;
  padding: var(--space-xs) var(--space-sm);
  border: 1px solid color-mix(in oklab, var(--danger) 55%, var(--border));
  border-radius: var(--radius-small);
  color: var(--danger);
  background: transparent;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
}

.chat-loading {
  display: grid;
  gap: var(--space-md);
  padding: var(--space-lg);
}

.chat-loading span:not(.sr-only) {
  display: block;
  width: 72%;
  height: 12px;
  border-radius: var(--radius-compact);
  background: var(--raised);
  animation: chat-pulse 1.4s ease-in-out infinite alternate;
}

.chat-loading span:nth-child(3),
.chat-loading span:nth-child(5) {
  width: 88%;
}

.chat-loading span:nth-child(4) {
  width: 58%;
}

@keyframes chat-pulse {
  from { opacity: 0.45; }
  to { opacity: 0.9; }
}

.chat-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 180px;
  padding: var(--space-xl);
  color: var(--text-muted);
  text-align: center;
}

.chat-empty svg {
  width: 30px;
  height: 30px;
  margin-bottom: var(--space-md);
}

.chat-empty strong {
  color: var(--text-dim);
  font-size: 0.875rem;
  font-weight: 600;
}

.chat-empty span {
  max-width: 30ch;
  margin-top: var(--space-xxs);
  font-size: 0.75rem;
}

.chat-messages {
  min-height: 0;
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: var(--space-md) var(--space-lg) var(--space-xl);
  scrollbar-color: var(--border-hover) transparent;
}

.chat-message {
  margin: 0;
  padding: var(--space-xxs) 0;
  color: var(--text);
  font-size: 0.875rem;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.chat-message:nth-child(even) {
  background: color-mix(in oklab, var(--text) 2%, transparent);
}

.chat-time {
  margin-right: var(--space-sm);
  color: var(--text-muted);
  font-family: var(--font-display);
  font-size: 0.6875rem;
  font-variant-numeric: tabular-nums;
}

.chat-badge {
  width: 18px;
  height: 18px;
  margin-right: var(--space-xxs);
  vertical-align: text-bottom;
}

.chat-badge-fallback {
  margin-right: var(--space-xxs);
  padding: 2px var(--space-xxs);
  border: 1px solid var(--border);
  border-radius: var(--radius-compact);
  color: var(--text-muted);
  font-size: 0.6875rem;
  vertical-align: text-bottom;
}

.chat-name {
  margin-right: var(--space-xs);
  font-weight: 600;
}

.chat-emote {
  display: inline-block;
  height: 1.5em;
  margin-inline: 1px;
  vertical-align: middle;
}

.watch-page.theatre-mode .header {
  display: none;
}

.watch-page.theatre-mode .content,
.watch-page.theatre-mode .watch-layout {
  height: 100vh;
  height: 100dvh;
}

/* Responsive structure */

@media (max-width: 1024px) {
  .private-label {
    display: none;
  }

  .content {
    padding: var(--space-xl);
  }
}

@media (max-width: 900px) {
  .login-view {
    grid-template-columns: 1fr;
    gap: var(--space-page);
    max-width: 560px;
  }

  .watch-layout {
    flex-direction: column;
  }

  .player-main {
    flex: 0 0 auto;
  }

  .player-frame {
    flex: 0 0 auto;
    width: 100%;
    aspect-ratio: 16 / 9;
  }

  .player-bar {
    min-height: 68px;
  }

  .theatre-btn {
    display: none;
  }

  .chat-panel {
    width: 100%;
    min-width: 0;
    min-height: 0;
    flex: 1 1 auto;
    border-top: 1px solid var(--border);
    border-left: 0;
  }

  .chat-messages {
    padding-bottom: max(var(--space-sm), env(safe-area-inset-bottom));
  }
}

@media (max-width: 768px) {
  .header {
    height: auto;
    min-height: 60px;
    flex-wrap: wrap;
    gap: var(--space-sm);
    padding: var(--space-md) var(--space-lg);
  }

  .header-nav {
    width: 100%;
    order: 3;
  }

  .nav-link {
    flex: 1;
    text-align: center;
  }

  .content {
    min-height: calc(100vh - 108px);
    padding: var(--space-xl) var(--space-lg);
  }

  .home-view {
    margin-top: var(--space-page);
  }

  .search-launcher kbd,
  .browse-search kbd {
    display: none;
  }

  .streamer-head {
    align-items: flex-start;
  }

  .watch-page .header {
    height: 60px;
    min-height: 60px;
    flex-wrap: nowrap;
    padding: 0 var(--space-lg);
  }

  .watch-page .header-nav {
    display: none;
  }

  .watch-page .content {
    height: calc(100vh - 60px);
    height: calc(100dvh - 60px);
  }
}

@media (max-width: 480px) {
  .logo {
    font-size: 1rem;
    letter-spacing: 0.1em;
  }

  .logo-mark {
    width: 22px;
    height: 22px;
  }

  .page-head h1,
  .streamer-head h1,
  .home-heading h1,
  .login-copy h1 {
    font-size: 1.25rem;
  }

  .search-launcher,
  .browse-search {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    padding: var(--space-md);
  }

  .search-launcher .btn-primary,
  .browse-search .btn-primary {
    grid-column: 1 / -1;
    min-height: 44px;
  }

  .channel-list,
  .vod-grid {
    grid-template-columns: 1fr;
  }

  .channel-row {
    grid-template-columns: 52px minmax(0, 1fr) auto;
  }

  .channel-row img {
    width: 52px;
    height: 52px;
  }

  .live-status {
    grid-column: 2;
  }

  .row-arrow {
    grid-row: 1 / span 2;
    grid-column: 3;
  }

  .streamer-head {
    flex-direction: column;
    gap: var(--space-lg);
  }

  .player-bar {
    padding: var(--space-sm) var(--space-md);
  }

  .player-streamer,
  .player-meta {
    font-size: 0.6875rem;
  }

  .chat-header {
    padding-inline: var(--space-md);
  }

  .chat-messages {
    padding-inline: var(--space-md);
  }
}

@media (max-width: 900px) and (orientation: landscape) {
  .watch-layout {
    flex-direction: row;
  }

  .player-main {
    min-width: 0;
    flex: 1;
  }

  .player-frame {
    min-height: 0;
    flex: 1;
    aspect-ratio: auto;
  }

  .player-bar {
    min-height: 60px;
  }

  .chat-panel {
    width: 280px;
    min-width: 260px;
    flex: 0 0 auto;
    border-top: 0;
    border-left: 1px solid var(--border);
  }
}

@media (pointer: coarse) {
  .icon-btn,
  .btn-primary,
  .btn-quiet,
  .nav-link,
  .chat-retry {
    min-height: 44px;
  }
}

@media (hover: none) {
  .vod-card:hover,
  .channel-row:hover {
    transform: none;
  }

  .vod-card .play-icon {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
