:root {
  color-scheme: dark;
  --bg: oklch(0.2 0.008 300);
  --bg-deep: oklch(0.15 0.006 300);
  --surface: oklch(0.24 0.01 300);
  --surface-2: oklch(0.25 0.01 300);
  --chip-bg: oklch(0.29 0.01 300);
  --nav-active: oklch(0.3 0.015 300);
  --avatar: oklch(0.33 0.015 300);
  --line: oklch(0.33 0.01 300);
  --line-soft: oklch(0.28 0.008 300);
  --ink: oklch(0.93 0.005 300);
  --muted: oklch(0.62 0.008 300);
  --muted-soft: oklch(0.55 0.008 300);
  --muted-strong: oklch(0.72 0.008 300);
  --accent: oklch(0.75 0.12 350);
  --accent-hover: oklch(0.82 0.12 350);
  --on-accent: oklch(0.2 0.02 350);
  --accent-soft-bg: oklch(0.26 0.03 350);
  --accent-soft-ink: oklch(0.78 0.1 350);
  --shared-pill-bg: oklch(0.29 0.04 350);
  --danger-border: oklch(0.4 0.06 25);
  --danger-bg: oklch(0.24 0.03 25);
  --danger-ink: oklch(0.75 0.1 25);
  --danger-hover: oklch(0.6 0.1 25);
  --guest-border: oklch(0.38 0.02 350);
  --guest-bg: oklch(0.23 0.015 350);
  --guest-ink: oklch(0.8 0.05 350);
  --thumb-stripe-1: oklch(0.27 0.01 300);
  --thumb-stripe-2: oklch(0.3 0.01 300);
  --avatar-stripe-1: oklch(0.3 0.01 300);
  --avatar-stripe-2: oklch(0.34 0.01 300);
  --profile-stripe-2: oklch(0.35 0.01 300);
  --mobile-nav-bg: rgba(25, 22, 27, 0.82);
  --overlay-control-bg: rgba(20, 18, 24, 0.78);
  --overlay-ink: #fff;
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: oklch(0.97 0.008 350);
  --bg-deep: oklch(0.95 0.012 350);
  --surface: oklch(0.995 0.004 350);
  --surface-2: oklch(0.92 0.014 350);
  --chip-bg: oklch(0.92 0.014 350);
  --nav-active: oklch(0.9 0.03 350);
  --avatar: oklch(0.88 0.02 350);
  --line: oklch(0.85 0.016 350);
  --line-soft: oklch(0.9 0.01 350);
  --ink: oklch(0.27 0.018 340);
  --muted: oklch(0.52 0.02 340);
  --muted-soft: oklch(0.6 0.015 340);
  --muted-strong: oklch(0.44 0.02 340);
  --accent: oklch(0.6 0.14 350);
  --accent-hover: oklch(0.52 0.14 350);
  --on-accent: #fff;
  --accent-soft-bg: oklch(0.92 0.03 350);
  --accent-soft-ink: oklch(0.5 0.12 350);
  --shared-pill-bg: oklch(0.9 0.04 350);
  --danger-border: oklch(0.75 0.08 25);
  --danger-bg: oklch(0.94 0.03 25);
  --danger-ink: oklch(0.5 0.13 25);
  --danger-hover: oklch(0.55 0.13 25);
  --guest-border: oklch(0.8 0.03 350);
  --guest-bg: oklch(0.94 0.015 350);
  --guest-ink: oklch(0.45 0.1 350);
  --thumb-stripe-1: oklch(0.93 0.012 350);
  --thumb-stripe-2: oklch(0.9 0.014 350);
  --avatar-stripe-1: oklch(0.9 0.014 350);
  --avatar-stripe-2: oklch(0.89 0.016 350);
  --profile-stripe-2: oklch(0.89 0.016 350);
  --mobile-nav-bg: rgba(255, 249, 252, 0.85);
}

* { box-sizing: border-box; }

html { min-width: 320px; background: var(--bg-deep); scrollbar-gutter: stable; }

body {
  min-width: 320px;
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Outfit, "Zen Kaku Gothic New", system-ui, sans-serif;
  font-size: 16px;
}

body::selection { background: var(--accent); color: var(--on-accent); }

a { color: var(--accent); }
a:hover { color: var(--accent-hover); }

button, input, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: 0.48; }

.app-shell {
  width: min(1240px, calc(100% - 40px));
  margin: 0 auto;
  padding: 26px 0 56px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 26px;
}

.brand-cluster, .account-area, .section-nav, .account-links, .featured-media-actions,
.featured-footer, .source-actions, .video-actions, .empty-actions, .profile-header {
  display: flex;
  align-items: center;
}

.brand-cluster { gap: 26px; min-width: 0; }

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  font-size: 1.2rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  line-height: 1;
  text-decoration: none;
  text-transform: uppercase;
  white-space: nowrap;
}

.brand-mark {
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  object-fit: cover;
}

.brand-name { display: inline-flex; align-items: baseline; }
.brand-name > span { color: var(--accent); }

.section-nav { gap: 4px; }

.nav-link, .queue-tab, .topic-chip {
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-weight: 600;
  white-space: nowrap;
}

.nav-link {
  min-height: 36px;
  padding: 0 15px;
  font-size: 0.86rem;
}

.nav-link:hover, .nav-link.active { background: var(--nav-active); color: var(--ink); }
.nav-icon { display: none; }

.account-area { position: relative; gap: 14px; flex-shrink: 0; }

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted-strong);
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
}
.theme-toggle:hover { border-color: var(--accent); color: var(--ink); }
.theme-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.theme-toggle-icon { width: 1em; color: var(--accent); font-size: 1rem; text-align: center; }

.stat-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 32px;
  padding: 6px 14px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 600;
  white-space: nowrap;
}

.stat-pill strong { color: var(--accent); font-weight: 800; }
.account-links { gap: 8px; }
.account-name { color: var(--muted); font-size: 0.82rem; font-weight: 600; }
.avatar, .profile-avatar, .source-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  border-radius: 999px;
  background: var(--avatar);
  color: var(--ink);
  font-weight: 700;
}
.avatar { width: 36px; height: 36px; font-size: 0.85rem; }
.settings-link { color: var(--muted); font-size: 1rem; text-decoration: none; }
.settings-link:hover { color: var(--accent); }
.admin-refresh { display: grid; gap: 5px; justify-items: end; }
.refresh-status { margin: 0; color: var(--muted-soft); font-size: 0.68rem; white-space: nowrap; }
.admin-refresh .ghost-button { min-height: 28px; padding: 0 10px; font-size: 0.72rem; }

.ghost-button, .accent-button, .primary-button, .danger-ghost, .link-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 0 16px;
  border-radius: 999px;
  text-decoration: none;
  white-space: nowrap;
}

.ghost-button, .danger-ghost {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted-strong);
  font-size: 0.8rem;
  font-weight: 700;
}
.ghost-button:hover, .ghost-button:focus-visible { border-color: var(--accent); color: var(--ink); }
.danger-ghost { color: var(--muted-soft); }
.danger-ghost:hover, .danger-ghost:focus-visible { border-color: var(--danger-hover); color: var(--danger-ink); }
.accent-button { border: 0; background: var(--accent); color: var(--on-accent); font-size: 0.86rem; font-weight: 800; }
.accent-button:hover, .accent-button:focus-visible { background: var(--accent-hover); color: var(--on-accent); }
.primary-button { border: 0; background: var(--accent); color: var(--on-accent); font-size: 0.86rem; font-weight: 800; }
.primary-button:hover, .primary-button:focus-visible { background: var(--accent-hover); color: var(--on-accent); }
.small-action { min-height: 34px; padding: 0 15px; font-size: 0.8rem; }
.action-link { min-height: 28px; padding: 0 11px; font-size: 0.74rem; }

.guest-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 26px;
  padding: 14px 20px;
  border: 1px dashed var(--guest-border);
  border-radius: 14px;
  background: var(--guest-bg);
}
.guest-banner p { margin: 0; color: var(--guest-ink); font-size: 0.9rem; font-weight: 600; }

.notice {
  margin-bottom: 18px;
  padding: 12px 15px;
  border: 1px solid var(--danger-border);
  border-radius: 12px;
  background: var(--danger-bg);
  color: var(--danger-ink);
  font-size: 0.86rem;
  font-weight: 600;
}
.notice--success { border-color: var(--accent-soft-ink); background: var(--accent-soft-bg); color: var(--accent-soft-ink); }

.section-view[hidden], [hidden] { display: none !important; }
.section-copy { max-width: 58ch; margin: 6px 0 0; color: var(--muted); font-size: 0.92rem; line-height: 1.5; }
.eyebrow { margin: 0 0 5px; color: var(--accent); font-size: 0.76rem; font-weight: 800; letter-spacing: 0.14em; text-transform: uppercase; }
.section-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.section-heading h2, .content-section h2 { margin: 0; font-size: 1.5rem; font-weight: 700; line-height: 1.2; }
.feed-meta { flex: 0 0 auto; color: var(--muted); font-size: 0.86rem; white-space: nowrap; }

.featured-hero {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr);
  gap: 0;
  margin-bottom: 34px;
  overflow: hidden;
  border-radius: 20px;
  background: var(--surface);
}
.featured-media { position: relative; aspect-ratio: 16 / 9; overflow: hidden; background: repeating-linear-gradient(45deg, var(--thumb-stripe-1), var(--thumb-stripe-1) 12px, var(--thumb-stripe-2) 12px, var(--thumb-stripe-2) 24px); }
.featured-media img { width: 100%; height: 100%; display: block; object-fit: cover; transition: opacity 160ms ease; }
.featured-media:not(.has-image) .thumb-placeholder { display: flex; }
.thumb-placeholder { display: none; align-items: center; justify-content: center; width: 100%; height: 100%; color: var(--muted-soft); font-family: ui-monospace, monospace; font-size: 0.72rem; }
.featured-media-actions { position: absolute; left: 20px; bottom: 20px; gap: 10px; }
.featured-watch { min-height: 44px; padding: 0 22px; font-size: 0.95rem; }
.duration-badge { display: inline-flex; align-items: center; min-height: 24px; padding: 2px 9px; border-radius: 6px; background: rgba(0, 0, 0, 0.65); color: var(--overlay-ink); font-size: 0.72rem; font-weight: 700; white-space: nowrap; }
.featured-copy { display: grid; align-content: center; gap: 12px; padding: 30px 32px; }
.featured-copy h1 { margin: 0; font-size: clamp(1.4rem, 2.4vw, 2rem); font-weight: 700; line-height: 1.2; }
.featured-description { margin: 0; color: var(--muted); font-size: 0.95rem; line-height: 1.55; }
.chip-row { display: flex; align-items: center; gap: 8px; overflow-x: auto; scrollbar-width: none; }
.chip-row::-webkit-scrollbar { display: none; }
.chip { display: inline-flex; align-items: center; min-height: 24px; padding: 3px 10px; border-radius: 999px; background: var(--chip-bg); color: var(--muted-strong); font-size: 0.74rem; font-weight: 700; white-space: nowrap; }
.featured-tags { overflow: visible; flex-wrap: wrap; }
.featured-footer { justify-content: space-between; gap: 10px; margin-top: 2px; }
.featured-byline { margin: 0; color: var(--muted); font-size: 0.82rem; }

.topic-chips { margin-bottom: 18px; }
.topic-chip { min-height: 34px; padding: 0 14px; border: 1px solid var(--line); font-size: 0.8rem; }
.topic-chip:hover, .topic-chip.active { border-color: transparent; background: var(--accent); color: var(--on-accent); }
.feed-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 24px; }
.queue-tabs { display: flex; align-items: center; gap: 4px; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.queue-tabs::-webkit-scrollbar { display: none; }
.queue-tab { min-height: 32px; padding: 0 12px; font-size: 0.78rem; }
.queue-tab.active, .queue-tab:hover { background: var(--nav-active); color: var(--ink); }
.queue-tab span { margin-left: 3px; color: var(--accent); }
.filter-details { position: relative; flex: 0 0 auto; }
.filter-details summary { list-style: none; min-height: 32px; padding: 7px 12px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted-strong); cursor: pointer; font-size: 0.78rem; font-weight: 700; }
.filter-details summary::-webkit-details-marker { display: none; }
.filter-details[open] summary { border-color: var(--accent); color: var(--accent); }
.filters { position: absolute; z-index: 8; right: 0; top: 44px; display: grid; grid-template-columns: repeat(2, minmax(140px, 1fr)); gap: 10px; width: min(460px, calc(100vw - 40px)); padding: 14px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }
.filters label, .source-form label { display: grid; gap: 6px; color: var(--muted); font-size: 0.74rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; }
.filters input, .filters select, .source-form input, .source-form textarea, .auth-field input, .channel-fields input, .channel-add-form input { width: 100%; min-height: 42px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); color: var(--ink); padding: 0 12px; outline: none; }
.source-form textarea { padding-top: 10px; padding-bottom: 10px; font: inherit; line-height: 1.45; }
.filters input:focus, .filters select:focus, .source-form input:focus, .source-form textarea:focus, .auth-field input:focus, .channel-fields input:focus, .channel-add-form input:focus { border-color: var(--accent); }
.search-filter { grid-column: 1 / -1; }

.feed { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 20px 16px; }
.video-card { display: grid; align-content: start; gap: 8px; min-width: 0; transition: opacity 160ms ease, transform 160ms ease; }
.video-card.is-updating { opacity: 0.45; transform: translateY(4px); pointer-events: none; }
.video-thumb-wrap { position: relative; }
.video-thumb { position: relative; display: block; aspect-ratio: 16 / 9; overflow: hidden; border-radius: 12px; background: repeating-linear-gradient(45deg, var(--thumb-stripe-1), var(--thumb-stripe-1) 12px, var(--thumb-stripe-2) 12px, var(--thumb-stripe-2) 24px); }
.video-thumb img { width: 100%; height: 100%; display: block; object-fit: cover; }
.video-thumb .thumb-placeholder { display: flex; position: absolute; }
.video-thumb .duration-badge { position: absolute; right: 7px; bottom: 7px; }
.new-badge { position: absolute; left: 8px; top: 8px; padding: 3px 7px; border-radius: 5px; background: var(--accent); color: var(--on-accent); font-size: 0.68rem; font-weight: 800; letter-spacing: 0.04em; }
.share-button { position: absolute; right: 8px; top: 8px; z-index: 2; display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px; border: 1px solid var(--line); border-radius: 999px; background: var(--overlay-control-bg); color: var(--overlay-ink); font-size: 1rem; }
.share-button:hover { border-color: var(--accent); color: var(--accent); }
.video-title { margin: 0; min-height: 2.6em; font-size: 0.92rem; font-weight: 600; line-height: 1.4; }
.video-title a { display: -webkit-box; overflow: hidden; color: var(--ink); text-decoration: none; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
.video-title a:hover { color: var(--accent); }
.video-meta { display: flex; align-items: center; justify-content: space-between; gap: 8px; color: var(--muted); font-size: 0.79rem; }
.video-source { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.video-proof { flex: 0 0 auto; color: var(--accent); font-weight: 700; white-space: nowrap; }
.video-actions { gap: 6px; min-height: 28px; }
.video-actions .ghost-button, .video-actions .accent-button, .video-actions .danger-ghost { min-height: 28px; padding: 0 11px; font-size: 0.74rem; }
.loading-panel { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; color: var(--muted); font-size: 0.86rem; font-weight: 600; }
.spinner { width: 16px; height: 16px; border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 999px; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.feed-pager { min-height: 24px; margin-top: 24px; color: var(--muted-soft); font-size: 0.8rem; text-align: center; }

.discover-layout { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 28px; align-items: start; }
.discover-main { min-width: 0; }
.discover-topics { margin-bottom: 18px; }
.source-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.source-card { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 12px; align-content: start; min-width: 0; padding: 18px; border-radius: 16px; background: var(--surface); }
.source-card--added { border: 1px solid color-mix(in oklch, var(--accent) 38%, transparent); background: color-mix(in oklch, var(--surface) 92%, var(--accent) 8%); }
.source-card.is-adding { opacity: 0.78; }
.source-card.is-just-added { animation: source-added-confirm 700ms ease-out; }
@keyframes source-added-confirm {
  0% { box-shadow: 0 0 0 0 color-mix(in oklch, var(--accent) 48%, transparent); transform: translateY(0); }
  38% { box-shadow: 0 0 0 5px color-mix(in oklch, var(--accent) 18%, transparent); transform: translateY(-2px); }
  100% { box-shadow: 0 0 0 0 transparent; transform: translateY(0); }
}
.source-avatar { position: relative; width: 42px; height: 42px; overflow: hidden; background: repeating-linear-gradient(45deg, var(--avatar-stripe-1), var(--avatar-stripe-1) 6px, var(--avatar-stripe-2) 6px, var(--avatar-stripe-2) 12px); color: var(--muted-strong); font-size: 0.78rem; }
.source-avatar img { position: absolute; inset: 0; width: 100%; height: 100%; display: block; object-fit: cover; }
.source-main { min-width: 0; }
.source-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; min-width: 0; }
.source-header h3 { overflow: hidden; margin: 0; font-size: 1rem; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.source-header p, .source-contributors { margin: 2px 0 0; color: var(--muted); font-size: 0.8rem; }
.source-count { flex: 0 0 auto; color: var(--accent); font-size: 0.76rem; font-weight: 800; white-space: nowrap; }
.source-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 11px; }
.source-contributors { margin-top: 11px; }
.source-contributor { padding: 0; border: 0; background: transparent; color: var(--accent); font: inherit; font-weight: 700; }
.source-contributor:hover { color: var(--accent-hover); text-decoration: underline; }
.source-card > .source-actions { grid-column: 1 / -1; gap: 8px; flex-wrap: wrap; }
.source-added-status { display: inline-flex; align-items: center; gap: 6px; min-height: 34px; padding: 0 11px; border-radius: 999px; background: color-mix(in oklch, var(--accent) 18%, transparent); color: var(--accent); font-size: 0.78rem; font-weight: 800; }
.source-view-link { padding: 0; border: 0; background: transparent; color: var(--muted-strong); font: inherit; font-size: 0.76rem; font-weight: 700; text-decoration: underline; text-underline-offset: 3px; }
.source-view-link:hover { color: var(--accent); }
.source-card--mine { grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; border-radius: 14px; padding: 14px 18px; }
.source-card--mine .source-tags, .source-card--mine .source-contributors { display: none; }
.source-card--mine .source-actions { grid-column: auto; justify-content: flex-end; }
.privacy-pill { display: inline-flex; align-items: center; min-height: 24px; padding: 0 9px; border-radius: 999px; font-size: 0.7rem; font-weight: 800; letter-spacing: 0.08em; }
.privacy-pill.is-shared { background: var(--shared-pill-bg); color: var(--accent-soft-ink); }
.privacy-pill.is-private { background: var(--chip-bg); color: var(--muted); }
.source-compose-card { position: sticky; top: 20px; display: grid; gap: 14px; padding: 22px; border-radius: 16px; background: var(--surface); }
.source-form { display: grid; gap: 14px; }
.source-form h3, .members-gate h3 { margin: 0; font-size: 1.15rem; font-weight: 700; }
.source-form p, .members-gate p { margin: 6px 0 0; color: var(--muted); font-size: 0.86rem; line-height: 1.5; }
.source-form .accent-button { width: 100%; min-height: 42px; }
.private-toggle { display: flex !important; align-items: center; gap: 9px !important; color: var(--muted-strong) !important; font-size: 0.86rem !important; letter-spacing: 0 !important; text-transform: none !important; }
.private-toggle input { width: 17px; height: 17px; min-height: auto; accent-color: var(--accent); }
.members-gate { display: grid; gap: 10px; justify-items: start; }

.content-section { min-width: 0; }
.my-sources-list { display: grid; gap: 10px; }
.empty-state { display: grid; justify-items: center; gap: 12px; padding: 50px 24px; border: 1px dashed var(--line); border-radius: 16px; text-align: center; }
.feed > .empty-state { grid-column: 1 / -1; }
.empty-state h3 { margin: 0; font-size: 1.15rem; font-weight: 700; }
.empty-state p { max-width: 42ch; margin: 0; color: var(--muted); font-size: 0.9rem; line-height: 1.55; }
.empty-icon { display: inline-flex; align-items: center; justify-content: center; width: 56px; height: 56px; border-radius: 999px; background: var(--accent-soft-bg); color: var(--accent-soft-ink); font-size: 1.4rem; }
.compact-gate { max-width: 620px; margin: 30px auto 0; }
.error-state .empty-icon { background: var(--danger-bg); color: var(--danger-ink); }

.profile-header { gap: 16px; margin-bottom: 24px; }
.profile-avatar { width: 72px; height: 72px; background: repeating-linear-gradient(45deg, var(--avatar-stripe-1), var(--avatar-stripe-1) 8px, var(--profile-stripe-2) 8px, var(--profile-stripe-2) 16px); font-size: 1.2rem; }
.profile-header > div:nth-child(2) { min-width: 0; flex: 1 1 auto; }
.profile-status { flex: 0 0 auto; color: var(--accent); font-size: 0.8rem; font-weight: 700; }
.profile-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-bottom: 30px; }
.profile-stats > div { display: grid; gap: 4px; padding: 16px; border-radius: 14px; background: var(--surface); }
.profile-stats span { color: var(--muted); font-size: 0.72rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; }
.profile-stats strong { color: var(--accent); font-size: 1.5rem; font-weight: 700; }
.subsection-title { margin: 0 0 14px; font-size: 1rem; font-weight: 700; }
.profile-source-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.profile-source-grid .source-card { grid-template-columns: auto minmax(0, 1fr); }

.auth-shell, .settings-shell { min-height: 100vh; padding: 40px 20px; background: var(--bg-deep); }
.auth-shell { display: flex; align-items: center; justify-content: center; }
.auth-wrap { width: min(420px, 100%); }
.auth-theme-row { display: flex; justify-content: flex-end; margin-bottom: 12px; }
.auth-brand { margin-bottom: 22px; text-align: center; }
.auth-brand .brand { font-size: 1.15rem; }
.auth-card, .settings-card { border-radius: 20px; background: var(--bg); padding: 40px 34px; }
.auth-card-heading, .settings-heading, .settings-title-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.auth-card-heading { margin-bottom: 8px; }
.auth-card h1, .settings-card h1 { margin: 0; font-size: 1.45rem; font-weight: 700; line-height: 1.16; }
.auth-mark, .settings-mark { display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto; min-width: 46px; min-height: 46px; border-radius: 14px; background: var(--accent-soft-bg); color: var(--accent-soft-ink); font-family: "Zen Kaku Gothic New", sans-serif; font-size: 1.2rem; font-weight: 700; }
.auth-sub { margin: 6px 0 22px; color: var(--muted); font-size: 0.9rem; line-height: 1.5; }
.auth-card form { display: grid; gap: 16px; }
.auth-field { display: grid; gap: 6px; color: var(--muted); font-size: 0.74rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; }
.auth-field input { min-height: 46px; border-radius: 12px; background: var(--surface); font-size: 0.95rem; }
.field-hint { color: var(--muted-soft); font-size: 0.74rem; font-weight: 500; letter-spacing: 0; text-transform: none; }
.auth-submit { width: 100%; min-height: 48px; margin-top: 4px; font-size: 0.95rem; }
.auth-error { display: flex; gap: 10px; margin: 0 0 16px; padding: 12px 14px; border: 1px solid var(--danger-border); border-radius: 12px; background: var(--danger-bg); color: var(--danger-ink); font-size: 0.86rem; font-weight: 600; line-height: 1.45; }
.auth-alt, .auth-back { color: var(--muted); font-size: 0.88rem; text-align: center; }
.auth-alt { margin: 18px 0 0; }
.auth-back { margin: 16px 0 0; }
.auth-alt a, .auth-back a { color: var(--accent); font-weight: 700; text-decoration: none; }
.settings-shell { display: flex; justify-content: center; }
.settings-card { width: min(560px, 100%); }
.settings-heading { margin-bottom: 34px; }
.settings-heading-actions { display: flex; align-items: center; gap: 10px; }
.settings-heading .brand { margin-bottom: 12px; font-size: 1rem; }
.settings-title-row { align-items: end; margin-bottom: 22px; }
.settings-title-row .settings-status { margin: 0; text-align: right; }
.settings-card > h1 { margin-bottom: 22px; }
.settings-status { margin: 0 0 16px; color: var(--muted); font-size: 0.86rem; }
.settings-list { margin: 0 0 18px; padding: 14px 0; border-top: 1px solid var(--line-soft); border-bottom: 1px solid var(--line-soft); }
.settings-list > div { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.settings-list dt { color: var(--muted); font-size: 0.76rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; }
.settings-list dd { margin: 0; font-weight: 700; }
.settings-logout { width: 100%; min-height: 44px; }
.danger-button { border: 1px solid var(--danger-border); border-radius: 999px; background: var(--danger-bg); color: var(--danger-ink); font-weight: 700; }
.settings-admin { margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--line-soft); }
.settings-section-title { margin-bottom: 16px; }
.settings-section-title h2 { margin: 0; font-size: 1.15rem; }
.settings-section-title p:last-child { max-width: 48ch; margin: 7px 0 0; color: var(--muted); font-size: 0.86rem; line-height: 1.5; }
.channel-add-form { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 20px; }
.channel-add-form label, .channel-fields label { display: grid; gap: 5px; color: var(--muted); font-size: 0.7rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; }
.channel-add-form button { grid-column: 1 / -1; justify-self: start; min-height: 40px; }
.channel-list { display: grid; gap: 14px; }
.channel-row { display: grid; gap: 10px; padding-top: 14px; border-top: 1px solid var(--line-soft); }
.channel-row-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.channel-row-header strong { display: block; font-size: 0.95rem; }
.channel-row-header span { display: block; color: var(--muted); font-size: 0.78rem; overflow-wrap: anywhere; }
.channel-enabled { display: inline-flex !important; grid-template-columns: auto auto !important; align-items: center; gap: 8px; white-space: nowrap; }
.channel-enabled input { width: 18px; height: 18px; accent-color: var(--accent); }
.channel-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.channel-meta { margin: 0; color: var(--muted-soft); font-size: 0.78rem; overflow-wrap: anywhere; }
.channel-actions { display: flex; justify-content: flex-end; gap: 8px; }
.channel-actions .primary-button, .channel-actions .danger-button { min-height: 34px; padding: 0 14px; border-radius: 999px; }
.settings-note { color: var(--muted); font-size: 0.88rem; text-align: center; }
.source-step, .source-preview { display: grid; gap: 12px; }
.source-preview { padding-top: 14px; border-top: 1px solid var(--line-soft); }
.source-preview-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.source-preview textarea { width: 100%; resize: vertical; }
.source-preview-meta { margin: 0; color: var(--muted); font-size: 0.78rem; line-height: 1.45; }
.text-button { padding: 0; border: 0; background: none; color: var(--accent); cursor: pointer; font: inherit; }
.source-preview-button { display: inline-flex; align-items: center; justify-content: center; gap: 9px; }
.button-spinner { display: none; width: 16px; height: 16px; flex: 0 0 auto; border: 2px solid rgba(255, 255, 255, 0.38); border-top-color: currentColor; border-radius: 50%; }
.source-preview-button[aria-busy="true"] .button-spinner { display: block; animation: source-button-spin 0.7s linear infinite; }
@keyframes source-button-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .source-preview-button[aria-busy="true"] .button-spinner { animation-duration: 1.4s; } }

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

@media (max-width: 1100px) {
  .feed { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .discover-layout { grid-template-columns: minmax(0, 1fr) 320px; }
  .profile-source-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 820px) {
  .topbar { align-items: flex-start; flex-wrap: wrap; }
  .brand-cluster { display: grid; gap: 14px; }
  .section-nav { gap: 2px; }
  .nav-link { padding: 0 10px; }
  .account-area .theme-toggle { width: 36px; padding: 0; }
  .account-area .theme-toggle [data-theme-label] { display: none; }
  .account-area { margin-left: auto; }
  .discover-layout { grid-template-columns: 1fr; }
  .source-compose-card { position: static; grid-row: 1; }
  .discover-main { grid-row: 2; }
  .feed { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .featured-hero { grid-template-columns: 1fr; }
  .featured-media { aspect-ratio: 16 / 8; }
}

@media (max-width: 600px) {
  body { padding-bottom: 82px; }
  .app-shell { width: min(100% - 24px, 520px); padding: 58px 0 30px; }
  .topbar { align-items: center; flex-wrap: wrap; margin-bottom: 20px; }
  .brand-cluster { display: block; }
  .brand { font-size: 1.02rem; }
  .brand-mark { width: 30px; height: 30px; border-radius: 9px; }
  .section-nav { position: fixed; z-index: 20; right: 14px; bottom: 14px; left: 14px; justify-content: space-around; gap: 0; padding: 7px; border: 1px solid var(--line); border-radius: 999px; background: var(--mobile-nav-bg); backdrop-filter: blur(18px); }
  .nav-link { display: grid; justify-items: center; gap: 1px; min-width: 66px; min-height: 44px; padding: 4px 8px; font-size: 0.64rem; font-weight: 600; }
  .nav-icon { display: block; font-size: 1rem; line-height: 1; }
  .nav-link.active { color: var(--accent); }
  .account-area { gap: 8px; }
  .account-name, .settings-link { display: none; }
  .stat-pill { min-height: 28px; padding: 5px 9px; font-size: 0.7rem; }
  .avatar { width: 30px; height: 30px; font-size: 0.72rem; }
  .is-signed-in .topbar { align-items: flex-start; flex-wrap: nowrap; gap: 12px; }
  .is-signed-in .brand-cluster { flex: 0 0 auto; padding-top: 3px; }
  .is-signed-in .brand-name { display: none; }
  .is-signed-in .account-area { display: grid; flex: 1 1 auto; grid-template-columns: auto auto; justify-content: end; min-width: 0; margin-left: 0; }
  .is-signed-in .theme-toggle { grid-column: 1; grid-row: 1; }
  .is-signed-in .stat-pill { grid-column: 2; grid-row: 1; }
  .is-signed-in .account-links, .is-signed-in .avatar { display: none; }
  .admin-refresh { position: static; flex: 0 0 100%; display: flex; align-items: center; justify-content: flex-end; gap: 8px; }
  .is-signed-in .admin-refresh { grid-column: 1 / -1; grid-row: 2; }
  .refresh-status { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
  .guest-banner { align-items: stretch; flex-direction: column; margin-bottom: 18px; padding: 13px 15px; }
  .guest-banner .accent-button { align-self: flex-start; }
  .featured-hero { margin-bottom: 24px; border-radius: 18px; }
  .featured-media { aspect-ratio: auto; overflow: visible; background: none; }
  .featured-media img, .featured-media .thumb-placeholder { display: none !important; }
  .featured-copy { gap: 10px; padding: 18px 16px; }
  .featured-copy h1 { font-size: 1.35rem; }
  .featured-description { font-size: 0.86rem; }
  .featured-media-actions { position: static; padding: 16px 16px 0; }
  .featured-watch { min-height: 40px; padding: 0 16px; font-size: 0.82rem; }
  .topic-chips { margin-right: -12px; }
  .feed-toolbar { align-items: flex-start; flex-direction: column; margin-bottom: 18px; }
  .queue-tabs { width: 100%; }
  .filter-details { align-self: flex-end; }
  .filters { position: fixed; z-index: 30; right: 12px; top: auto; bottom: 76px; grid-template-columns: 1fr; width: calc(100vw - 24px); }
  .search-filter { grid-column: auto; }
  .section-heading { align-items: flex-start; flex-direction: column; gap: 7px; }
  .feed { grid-template-columns: 1fr; gap: 22px; }
  .video-title { min-height: 0; font-size: 0.94rem; }
  .source-grid, .profile-source-grid, .profile-stats { grid-template-columns: 1fr; }
  .source-card--mine { grid-template-columns: auto minmax(0, 1fr); }
  .source-card--mine .source-actions { grid-column: 1 / -1; justify-content: flex-start; }
  .profile-header { align-items: flex-start; flex-wrap: wrap; }
  .profile-status { margin-left: 88px; margin-top: -10px; }
  .profile-stats { gap: 8px; }
  .profile-stats > div { padding: 12px; }
  .channel-add-form, .channel-fields { grid-template-columns: 1fr; }
  .channel-add-form button { grid-column: auto; width: 100%; }
  .channel-row-header, .channel-actions { align-items: stretch; flex-direction: column; }
  .channel-actions .primary-button, .channel-actions .danger-button { width: 100%; }
  .auth-shell, .settings-shell { padding: 24px 12px; }
  .auth-card, .settings-card { padding: 30px 20px; }
  .settings-heading { flex-wrap: wrap; }
  .settings-heading-actions { margin-left: auto; }
  .settings-heading .theme-toggle { width: 36px; padding: 0; }
  .settings-heading .theme-toggle [data-theme-label] { display: none; }
}
