:root {
  --font: "Roboto", "Arial", "Helvetica Neue", system-ui, -apple-system, "Segoe UI", sans-serif;
  --topbar-height: 56px;
  --guide-width: 240px;
  --guide-mini-width: 72px;
  --content-max: 1284px;
  --radius: 12px;
  --radius-sm: 8px;
  --radius-pill: 18px;
  --transition: 120ms ease;
}

html[data-theme="light"] {
  --bg: #ffffff;
  --bg-elevated: #ffffff;
  --bg-secondary: #f2f2f2;
  --bg-tertiary: #f9f9f9;
  --text: #0f0f0f;
  --text-secondary: #606060;
  --icon: #0f0f0f;
  --border: rgba(0, 0, 0, 0.1);
  --hover: rgba(0, 0, 0, 0.05);
  --active: rgba(0, 0, 0, 0.1);
  --chip-bg: #f2f2f2;
  --chip-active-bg: #0f0f0f;
  --chip-active-text: #ffffff;
  --brand: #ff0000;
  --link: #065fd4;
  --skeleton: #e5e5e5;
  --subscribe-bg: #0f0f0f;
  --subscribe-text: #ffffff;
  --badge-bg: rgba(0, 0, 0, 0.8);
  --scrim: rgba(0, 0, 0, 0.5);
  --shadow: 0 4px 32px rgba(0, 0, 0, 0.2);
}

html[data-theme="dark"] {
  --bg: #0f0f0f;
  --bg-elevated: #212121;
  --bg-secondary: #272727;
  --bg-tertiary: #181818;
  --text: #f1f1f1;
  --text-secondary: #aaaaaa;
  --icon: #f1f1f1;
  --border: rgba(255, 255, 255, 0.2);
  --hover: rgba(255, 255, 255, 0.1);
  --active: rgba(255, 255, 255, 0.2);
  --chip-bg: #272727;
  --chip-active-bg: #f1f1f1;
  --chip-active-text: #0f0f0f;
  --brand: #ff0000;
  --link: #3ea6ff;
  --skeleton: #272727;
  --subscribe-bg: #f1f1f1;
  --subscribe-text: #0f0f0f;
  --badge-bg: rgba(0, 0, 0, 0.8);
  --scrim: rgba(0, 0, 0, 0.6);
  --shadow: 0 4px 32px rgba(0, 0, 0, 0.6);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 20px;
  -webkit-font-smoothing: antialiased;
  padding-top: var(--topbar-height);
}

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

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

img {
  max-width: 100%;
  display: block;
}

button,
input,
select {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

svg {
  display: block;
  flex: none;
}

.dot {
  display: inline-block;
  width: 3px;
  height: 3px;
  margin: 0 4px;
  border-radius: 50%;
  background: var(--text-secondary);
  vertical-align: middle;
}

.muted {
  color: var(--text-secondary);
}

/* masthead */
.masthead {
  position: fixed;
  inset: 0 0 auto 0;
  height: var(--topbar-height);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 16px;
  background: var(--bg);
  z-index: 2000;
}

.masthead-start,
.masthead-end {
  display: flex;
  align-items: center;
  gap: 8px;
}

.masthead-start {
  min-width: 170px;
}

.masthead-end {
  margin-left: auto;
  gap: 4px;
}

.masthead-logo {
  display: flex;
  align-items: center;
  padding: 0 8px;
  height: 40px;
}

.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--icon);
  cursor: pointer;
  transition: background var(--transition);
}

.icon-button:hover {
  background: var(--hover);
}

.avatar-button {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  overflow: hidden;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-secondary);
  margin-left: 4px;
}

.avatar-button img {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
}

.avatar-initials {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #7b1fa2;
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 500;
}

.masthead-search {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  justify-content: center;
}

.search-box {
  position: relative;
  display: flex;
  align-items: center;
  height: 40px;
  width: 100%;
  max-width: 540px;
  border: 1px solid var(--border);
  border-right: 0;
  border-radius: 40px 0 0 40px;
  padding-left: 16px;
  background: transparent;
}

.search-box-icon {
  display: none;
  color: var(--text-secondary);
  margin-right: 8px;
}

.search-box input {
  flex: 1;
  height: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  font-size: 16px;
  padding-right: 12px;
}

.search-submit {
  width: 64px;
  height: 40px;
  border: 1px solid var(--border);
  border-radius: 0 40px 40px 0;
  background: var(--chip-bg);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.search-submit:hover {
  background: var(--active);
}

.search-voice {
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 50%;
  background: var(--chip-bg);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.search-voice:hover {
  background: var(--active);
}

.suggest-panel {
  position: absolute;
  top: 46px;
  left: 0;
  right: 0;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 8px 0;
  z-index: 2100;
}

.suggest-panel a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 16px;
  font-size: 15px;
}

.suggest-panel a:hover {
  background: var(--hover);
}

.search-toggle-button {
  display: none;
}

.suggest-panel a.is-focused {
  background: var(--hover);
}

/* layout */
.page-shell {
  display: flex;
  min-height: calc(100vh - var(--topbar-height));
}

.guide {
  width: var(--guide-width);
  flex: none;
  padding: 12px 0 24px;
  position: sticky;
  top: var(--topbar-height);
  height: calc(100vh - var(--topbar-height));
  overflow-x: hidden;
  overflow-y: auto;
  scrollbar-width: none;
}

.guide::-webkit-scrollbar {
  display: none;
  width: 0;
  height: 0;
}

.guide-section {
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.guide-section:last-child {
  border-bottom: 0;
}

.guide-title {
  font-size: 16px;
  font-weight: 500;
  margin: 0;
  padding: 4px 24px 8px;
}

.guide-item {
  display: flex;
  align-items: center;
  gap: 24px;
  height: 40px;
  margin: 0 12px;
  padding: 0 12px;
  border-radius: 10px;
  font-size: 14px;
  transition: background var(--transition);
}

.guide-item:hover {
  background: var(--hover);
}

.guide-item.is-active {
  background: var(--hover);
  font-weight: 500;
}

.guide-icon {
  width: 24px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--icon);
}

.guide-label {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.guide-avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  object-fit: cover;
  flex: none;
}

.guide-avatar-fallback {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #7b1fa2;
  color: #fff;
  font-size: 10px;
}

.content {
  flex: 1;
  min-width: 0;
  padding: 0 0 48px;
}

body.page-home .content,
body.page-subscriptions .content,
body.page-you .content {
  max-width: none;
}

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  padding: 24px 24px 8px;
  flex-wrap: wrap;
}

.page-title {
  font-size: 24px;
  font-weight: 700;
  margin: 0 0 4px;
}

.page-subtitle {
  margin: 0;
  color: var(--text-secondary);
}

.page-head-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* chips */
.chips-bar {
  position: sticky;
  top: var(--topbar-height);
  z-index: 900;
  display: flex;
  gap: 12px;
  padding: 12px 24px;
  background: var(--bg);
  overflow-x: auto;
  scrollbar-width: none;
}

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

.chips-bar.is-static {
  position: static;
  padding: 8px 0;
}

.chip {
  display: inline-flex;
  align-items: center;
  height: 32px;
  padding: 0 12px;
  border-radius: 16px;
  background: var(--chip-bg);
  color: var(--text);
  font-size: 14px;
  white-space: nowrap;
  transition: background var(--transition);
}

.chip:hover {
  background: var(--active);
}

.chip.is-active {
  background: var(--chip-active-bg);
  color: var(--chip-active-text);
}

/* buttons */
.button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 36px;
  padding: 0 16px;
  border-radius: var(--radius-pill);
  border: 0;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--transition);
}

.button-primary {
  background: var(--subscribe-bg);
  color: var(--subscribe-text);
}

.button-primary:hover {
  opacity: 0.9;
}

.button-outline {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}

.button-outline:hover {
  background: var(--hover);
}

.button-block {
  width: 100%;
  justify-content: center;
  height: 40px;
}

.button-subscribe {
  background: var(--subscribe-bg);
  color: var(--subscribe-text);
  height: 36px;
  padding: 0 16px;
  margin-left: 8px;
}

.button-subscribe.is-subscribed {
  background: var(--chip-bg);
  color: var(--text);
}

.text-button {
  background: none;
  border: 0;
  padding: 0;
  color: var(--text-secondary);
  cursor: pointer;
  font-weight: 500;
}

.text-button:hover {
  color: var(--text);
}

/* rich grid */
.rich-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
  row-gap: 40px;
  padding: 16px 24px 32px;
  max-width: var(--content-max);
  margin: 0 auto;
}

.rich-grid.is-dense {
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  row-gap: 28px;
}

.rich-grid.is-compact {
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  padding: 8px 0 8px;
  row-gap: 24px;
}

.card {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.card-thumb {
  position: relative;
  display: block;
  aspect-ratio: 16 / 9;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--skeleton);
  transition: border-radius var(--transition);
}

.card-thumb:hover {
  border-radius: 0;
}

.card-thumb img,
.card-thumb-placeholder {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.badge {
  position: absolute;
  right: 8px;
  bottom: 8px;
  background: var(--badge-bg);
  color: #fff;
  font-size: 12px;
  font-weight: 500;
  line-height: 12px;
  padding: 4px 4px 3px;
  border-radius: 4px;
}

.badge-live {
  left: 8px;
  right: auto;
  background: var(--brand);
  text-transform: uppercase;
}

.card-progress {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 3px;
  background: rgba(255, 255, 255, 0.4);
}

.card-progress span {
  display: block;
  height: 100%;
  background: var(--brand);
}

.card-body {
  display: flex;
  gap: 12px;
  padding: 12px 0 0;
}

.card-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  overflow: hidden;
  flex: none;
  background: var(--bg-secondary);
}

.card-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.card-avatar-fallback {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #7b1fa2;
  color: #fff;
  font-size: 13px;
  font-weight: 500;
}

.card-text {
  min-width: 0;
  flex: 1;
}

.card-title {
  margin: 0 0 4px;
  font-size: 16px;
  line-height: 22px;
  font-weight: 500;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-channel,
.card-meta {
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 20px;
}

.card-channel {
  display: block;
  margin-bottom: 2px;
}

.card-channel:hover {
  color: var(--text);
}

.card-menu {
  width: 36px;
  height: 36px;
  opacity: 0;
  flex: none;
}

.card:hover .card-menu {
  opacity: 1;
}

/* notices */
.notice {
  margin: 8px 24px 16px;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 14px;
}

.notice-info {
  background: var(--chip-bg);
}

.notice-ok {
  background: rgba(46, 125, 50, 0.15);
  border: 1px solid rgba(46, 125, 50, 0.4);
}

.notice-error {
  background: rgba(198, 40, 40, 0.15);
  border: 1px solid rgba(198, 40, 40, 0.4);
}

/* empty state */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  text-align: center;
  padding: 64px 24px;
  color: var(--text-secondary);
}

.empty-state h2 {
  margin: 0;
  color: var(--text);
  font-size: 20px;
}

.empty-state p {
  margin: 0;
  max-width: 520px;
}

.empty-icon {
  color: var(--text-secondary);
  opacity: 0.7;
}

/* sections */
.section {
  padding: 16px 24px 8px;
  max-width: var(--content-max);
  margin: 0 auto;
}

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.section-title {
  font-size: 18px;
  font-weight: 700;
  margin: 0 0 8px;
}

.section-link {
  color: var(--text-secondary);
  font-weight: 500;
}

.section-link:hover {
  color: var(--text);
}

/* channel rows (subscriptions page) */
.channel-row {
  padding: 16px 24px 0;
  max-width: var(--content-max);
  margin: 0 auto;
}

.channel-row-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-bottom: 8px;
}

.channel-row-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
}

.channel-row-avatar.fallback {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #7b1fa2;
  color: #fff;
  font-weight: 500;
}

.channel-row-name {
  font-size: 18px;
  font-weight: 700;
}

.channel-row-more {
  margin-left: auto;
  color: var(--text-secondary);
  font-weight: 500;
}

/* tables */
.table-list {
  padding: 8px 24px 32px;
  max-width: var(--content-max);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
}

.table-list.is-plain {
  padding: 0;
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 0 16px;
}

.admin-form label {
  display: block;
  margin-bottom: 12px;
}

.admin-form label span {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
  color: var(--text-secondary);
}

.admin-form input[type="text"],
.admin-form input[type="email"] {
  width: 100%;
  height: 40px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: transparent;
  outline: 0;
}

.admin-form input:focus {
  border-color: var(--link);
}

.admin-form .pref-toggle {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 16px;
}

.admin-form .pref-toggle-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.admin-form .pref-toggle-text small {
  color: var(--text-secondary);
}

.admin-row {
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 12px;
}

.admin-row.is-disabled {
  opacity: 0.6;
}

.admin-row-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.admin-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.admin-actions form {
  display: inline;
}

.tag {
  display: inline-flex;
  align-items: center;
  height: 20px;
  padding: 0 8px;
  border-radius: 10px;
  background: var(--chip-bg);
  color: var(--text-secondary);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.tag-admin {
  background: rgba(62, 166, 255, 0.18);
  color: var(--link);
}

.tag-off {
  background: rgba(198, 40, 40, 0.2);
  color: #ef5350;
}

.button-danger {
  background: transparent;
  border: 1px solid rgba(198, 40, 40, 0.6);
  color: #ef5350;
}

.button-danger:hover {
  background: rgba(198, 40, 40, 0.15);
}

.temp-password {
  font-size: 15px;
  letter-spacing: 0.08em;
  margin: 0 8px;
}

.notice code {
  background: var(--bg-secondary);
  padding: 2px 6px;
  border-radius: 4px;
}

/* descoberta organica */
.organic-block {
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 24px 24px 8px;
  border-bottom: 1px solid var(--border);
}

.organic-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.organic-title {
  font-size: 20px;
  font-weight: 700;
  margin: 0 0 4px;
}

.organic-subtitle {
  margin: 0;
  color: var(--text-secondary);
  max-width: 620px;
}

.organic-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.organic-card {
  display: flex;
  flex-direction: column;
  background: var(--bg-tertiary);
  border-radius: var(--radius);
  overflow: hidden;
  padding-bottom: 8px;
}

.organic-card .card-thumb {
  border-radius: 0;
}

.organic-card .card-thumb:hover {
  border-radius: 0;
}

.organic-body {
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.organic-reason {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  margin: 4px 0;
  font-size: 12px;
  line-height: 16px;
  color: var(--text-secondary);
}

.organic-reason-icon {
  color: var(--link);
  margin-top: 1px;
}

.organic-topic {
  align-self: flex-start;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-secondary);
  background: var(--chip-bg);
  border-radius: 10px;
  padding: 2px 8px;
}

.organic-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.organic-action {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 30px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 15px;
  background: transparent;
  color: var(--text-secondary);
  font-size: 12px;
  cursor: pointer;
}

.organic-action:hover {
  background: var(--hover);
  color: var(--text);
}

.organic-action.is-active {
  border-color: var(--link);
  color: var(--link);
  background: rgba(62, 166, 255, 0.12);
}

.organic-note,
.organic-empty p {
  margin: 0 0 12px;
  color: var(--text-secondary);
}

.organic-foot {
  margin: 16px 0 0;
  font-size: 13px;
}

.badge-small {
  right: auto;
  left: 8px;
  background: rgba(62, 166, 255, 0.9);
  text-transform: none;
  letter-spacing: 0;
}

/* onboarding */
.onboarding {
  max-width: 860px;
  margin: 0 auto;
  padding: 32px 24px 48px;
}

.onboarding-kicker {
  display: inline-block;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.onboarding-head h1 {
  font-size: 26px;
  margin: 0 0 8px;
}

.onboarding-head p {
  color: var(--text-secondary);
  margin: 0 0 16px;
}

.onboarding-block {
  padding: 16px 0;
  border-bottom: 1px solid var(--border);
}

.onboarding-block h2 {
  font-size: 16px;
  margin: 0 0 12px;
}

.onboarding-actions {
  display: flex;
  gap: 12px;
  margin-top: 24px;
  flex-wrap: wrap;
}

.inline-form.is-tight {
  padding: 0 0 8px;
}

.channel-picker {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 8px;
}

.channel-option {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px;
  border-radius: var(--radius-sm);
}

.channel-option:hover {
  background: var(--hover);
}

.channel-option img,
.seed-avatar-fallback {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  flex: none;
}

.seed-avatar-fallback {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #7b1fa2;
  color: #fff;
  font-weight: 500;
}

.channel-option-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
}

.channel-option-text small {
  color: var(--text-secondary);
  font-size: 12px;
}

.seed-list {
  list-style: none;
  margin: 0 0 8px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.seed-list li {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  background: var(--bg-tertiary);
}

.seed-list img {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
}

.seed-list .seed-avatar-fallback {
  width: 32px;
  height: 32px;
  font-size: 12px;
}

.seed-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.seed-remove {
  width: 32px;
  height: 32px;
}

.topic-picker {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 8px;
}

.topic-option {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.topic-option:hover {
  background: var(--hover);
}

.topic-option input {
  margin-top: 2px;
}

.topic-label {
  font-weight: 500;
  display: block;
}

.topic-hint {
  display: block;
  color: var(--text-secondary);
  font-size: 12px;
}

.chip-form {
  display: inline;
}

.chip-removable {
  gap: 6px;
  cursor: pointer;
  border: 0;
}

.mini-check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-secondary);
}

.weight-select {
  height: 36px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  padding: 0 8px;
}

.block-title {
  font-size: 14px;
  margin: 16px 0 8px;
}

.inline-form select {
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  background: var(--bg);
}

.engine-form label {
  display: block;
  margin-bottom: 12px;
}

.engine-form label span {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
  color: var(--text-secondary);
}

.engine-form input[type="text"],
.engine-form textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  outline: 0;
  resize: vertical;
}

.engine-form input[type="text"] {
  height: 40px;
}

.engine-form input:focus,
.engine-form textarea:focus {
  border-color: var(--link);
}

.engine-test {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 8px;
}

.engine-diagnose {
  font-size: 13px;
}

.diagnose-table {
  width: 100%;
  border-collapse: collapse;
}

.diagnose-table td,
.diagnose-table th {
  text-align: left;
  padding: 6px 10px 6px 0;
  border-bottom: 1px solid var(--border);
  font-weight: 400;
}

.diagnose-ok {
  color: #4caf50;
}

.diagnose-bad {
  color: #ef5350;
}

.help-block {
  margin-top: 16px;
  font-size: 13px;
}

.help-block summary {
  cursor: pointer;
  color: var(--link);
}

.help-block ol {
  margin: 12px 0;
  padding-left: 20px;
  color: var(--text-secondary);
}

.table-row {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.table-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  object-fit: cover;
  flex: none;
}

.table-avatar.fallback {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #7b1fa2;
  color: #fff;
  font-weight: 500;
}

.table-thumb {
  position: relative;
  width: 160px;
  aspect-ratio: 16 / 9;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--skeleton);
  flex: none;
}

.table-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

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

.table-title {
  font-size: 16px;
  font-weight: 500;
  display: block;
  margin-bottom: 4px;
}

.table-meta {
  color: var(--text-secondary);
  font-size: 13px;
}

.progress-mini {
  margin-top: 8px;
  height: 3px;
  width: 100%;
  max-width: 420px;
  background: var(--chip-bg);
  border-radius: 2px;
  overflow: hidden;
}

.progress-mini span {
  display: block;
  height: 100%;
  background: var(--brand);
}

/* inline forms */
.inline-form {
  display: flex;
  gap: 8px;
  padding: 8px 24px 16px;
  max-width: var(--content-max);
  margin: 0 auto;
  flex-wrap: wrap;
}

.inline-form input[type="text"],
.inline-form input[type="url"] {
  flex: 1;
  min-width: 240px;
  height: 40px;
  padding: 0 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  background: transparent;
  outline: 0;
}

.inline-form input:focus {
  border-color: var(--link);
}

.inline-form-result {
  padding: 0 24px;
  color: var(--text-secondary);
}

/* search results */
.result-list {
  padding: 8px 24px 32px;
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.result-row {
  display: flex;
  gap: 16px;
}

.result-thumb {
  position: relative;
  width: 246px;
  flex: none;
  aspect-ratio: 16 / 9;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--skeleton);
}

.result-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.result-body {
  min-width: 0;
}

.result-title {
  margin: 0 0 4px;
  font-size: 18px;
  line-height: 24px;
  font-weight: 500;
}

.result-meta,
.result-channel {
  color: var(--text-secondary);
  font-size: 13px;
}

.result-channel {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 8px 0;
}

.result-channel img {
  width: 24px;
  height: 24px;
  border-radius: 50%;
}

.result-snippet {
  margin: 4px 0 0;
  color: var(--text-secondary);
  font-size: 13px;
}

/* channel page */
.channel-page {
  padding-bottom: 48px;
}

.channel-banner {
  max-height: 200px;
  overflow: hidden;
  background: var(--bg-secondary);
}

.channel-banner img {
  width: 100%;
  height: 200px;
  object-fit: cover;
}

.channel-header {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 16px 24px;
  max-width: var(--content-max);
  margin: 0 auto;
}

.channel-avatar {
  width: 128px;
  height: 128px;
  border-radius: 50%;
  object-fit: cover;
  flex: none;
}

.channel-avatar.fallback {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #7b1fa2;
  color: #fff;
  font-size: 40px;
}

.channel-info {
  min-width: 0;
}

.channel-name {
  margin: 0 0 4px;
  font-size: 32px;
  line-height: 38px;
  font-weight: 700;
}

.channel-meta {
  color: var(--text-secondary);
  font-size: 14px;
}

.channel-description {
  margin: 8px 0 0;
  color: var(--text-secondary);
  max-width: 640px;
}

.channel-tabs {
  display: flex;
  gap: 24px;
  padding: 0 24px;
  border-bottom: 1px solid var(--border);
  max-width: var(--content-max);
  margin: 0 auto;
}

.channel-tab {
  padding: 12px 0;
  font-size: 14px;
  font-weight: 500;
  text-transform: uppercase;
  color: var(--text-secondary);
  border-bottom: 2px solid transparent;
}

.channel-tab.is-active {
  color: var(--text);
  border-bottom-color: var(--text);
}

.channel-about {
  padding: 24px;
  max-width: 800px;
}

.channel-about h2 {
  font-size: 16px;
  margin: 0 0 8px;
}

.plain-list {
  list-style: none;
  margin: 0 0 16px;
  padding: 0;
  color: var(--text-secondary);
}

.plain-list li {
  padding: 4px 0;
}

/* you page */
.you-header {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 32px 24px 8px;
  max-width: var(--content-max);
  margin: 0 auto;
}

.you-avatar {
  width: 128px;
  height: 128px;
  border-radius: 50%;
  object-fit: cover;
  flex: none;
}

.you-avatar.fallback {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #7b1fa2;
  color: #fff;
  font-size: 44px;
  font-weight: 500;
}

.you-info h1 {
  margin: 0 0 8px;
  font-size: 36px;
  line-height: 42px;
}

.you-meta {
  color: var(--text-secondary);
}

.channel-strip {
  display: flex;
  gap: 16px;
  overflow-x: auto;
  padding: 8px 0 16px;
}

.channel-chip {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: 96px;
  text-align: center;
  font-size: 12px;
}

.channel-chip img,
.channel-chip .fallback {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  object-fit: cover;
}

.channel-chip .fallback {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #7b1fa2;
  color: #fff;
  font-size: 20px;
}

/* playlists */
.playlist-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
  padding: 8px 24px 24px;
  max-width: var(--content-max);
  margin: 0 auto;
}

.playlist-card {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-tertiary);
  border-radius: var(--radius);
  padding: 8px;
}

.playlist-link {
  display: flex;
  align-items: center;
  gap: 16px;
  flex: 1;
  min-width: 0;
}

.playlist-icon {
  width: 72px;
  height: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-secondary);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
}

.playlist-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.playlist-info span {
  color: var(--text-secondary);
  font-size: 12px;
}

.playlist-items {
  list-style: none;
  margin: 0;
  padding: 8px 24px 32px;
  max-width: 1000px;
}

.playlist-item {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}

.playlist-index {
  width: 24px;
  text-align: center;
  color: var(--text-secondary);
}

.playlist-thumb {
  width: 120px;
  aspect-ratio: 16 / 9;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--skeleton);
  flex: none;
}

.playlist-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.playlist-item-body {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
}

.playlist-item-title {
  font-weight: 500;
}

.playlist-item-channel {
  color: var(--text-secondary);
  font-size: 12px;
}

/* settings */
.settings-form,
.settings-section {
  max-width: 860px;
  margin: 0 auto;
  padding: 8px 24px;
}

.settings-section {
  padding: 16px 24px 24px;
  border-bottom: 1px solid var(--border);
}

.settings-section h2 {
  font-size: 16px;
  margin: 0 0 12px;
}

.pref-toggle {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 0;
  cursor: pointer;
}

.pref-toggle.is-locked {
  cursor: default;
  opacity: 0.85;
}

.pref-toggle-text,
.pref-field-text {
  display: flex;
  flex-direction: column;
  flex: 1;
}

.pref-toggle small,
.pref-field small {
  color: var(--text-secondary);
  font-size: 12px;
}

.pref-toggle input {
  display: none;
}

.pref-switch {
  position: relative;
  width: 40px;
  height: 22px;
  border-radius: 11px;
  background: var(--chip-bg);
  flex: none;
  transition: background var(--transition);
}

.pref-switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--text-secondary);
  transition: transform var(--transition), background var(--transition);
}

.pref-toggle input:checked + .pref-switch {
  background: var(--link);
}

.pref-toggle input:checked + .pref-switch::after {
  transform: translateX(18px);
  background: #fff;
}

.pref-field {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 0;
}

.pref-field select {
  min-width: 200px;
  height: 36px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
}

.settings-actions {
  display: flex;
  gap: 12px;
  padding: 16px 24px;
  max-width: 860px;
  margin: 0 auto;
}

/* modal */
.modal {
  position: fixed;
  inset: 0;
  background: var(--scrim);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 3000;
}

.modal-panel {
  width: min(420px, 92vw);
  background: var(--bg-elevated);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}

.modal-head h2 {
  margin: 0;
  font-size: 16px;
}

.modal-body {
  padding: 8px 0 16px;
}

.modal-list {
  list-style: none;
  margin: 0 0 8px;
  padding: 0;
  max-height: 280px;
  overflow-y: auto;
}

.modal-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 10px 16px;
  background: none;
  border: 0;
  cursor: pointer;
  text-align: left;
}

.modal-item:hover {
  background: var(--hover);
}

.modal-body .inline-form {
  padding: 8px 16px 0;
}

/* toast + scrim */
.toast {
  position: fixed;
  left: 24px;
  bottom: 24px;
  background: var(--bg-elevated);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  box-shadow: var(--shadow);
  z-index: 4000;
  max-width: 420px;
}

.scrim {
  position: fixed;
  inset: 0;
  background: var(--scrim);
  z-index: 1500;
}

/* auth */
.page-auth {
  padding-top: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--bg);
}

.auth-shell {
  width: 100%;
  display: flex;
  justify-content: center;
  padding: 24px;
}

.auth-card {
  width: min(420px, 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
  background: var(--bg);
}

.auth-logo {
  display: flex;
  justify-content: center;
  margin-bottom: 16px;
}

.auth-card h1 {
  font-size: 22px;
  text-align: center;
  margin: 0 0 16px;
}

.auth-card label {
  display: block;
  margin-bottom: 16px;
}

.auth-card label span {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
  color: var(--text-secondary);
}

.auth-card input {
  width: 100%;
  height: 44px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: transparent;
  outline: 0;
}

.auth-card input:focus {
  border-color: var(--link);
}

.auth-alt {
  text-align: center;
  color: var(--text-secondary);
  margin: 16px 0 0;
}

.auth-alt a {
  color: var(--link);
}

.error-page {
  max-width: 720px;
  margin: 0 auto;
  padding: 64px 24px;
  text-align: center;
}

.error-trace {
  text-align: left;
  background: var(--bg-secondary);
  padding: 16px;
  border-radius: var(--radius-sm);
  overflow-x: auto;
  font-size: 12px;
}

/* responsive */
@media (max-width: 1200px) {
  .guide {
    position: fixed;
    left: 0;
    top: var(--topbar-height);
    background: var(--bg);
    transform: translateX(-100%);
    transition: transform 160ms ease;
    z-index: 1600;
    box-shadow: var(--shadow);
  }

  body.guide-open .guide {
    transform: translateX(0);
  }

  body.guide-open .scrim {
    display: block;
  }

  .masthead-start {
    min-width: auto;
  }
}

@media (min-width: 1201px) {
  body.page-watch .guide,
  body.page-channel .guide,
  body.page-search .guide {
    width: var(--guide-mini-width);
  }

  body.page-watch .guide-label,
  body.page-channel .guide-label,
  body.page-search .guide-label,
  body.page-watch .guide-title,
  body.page-channel .guide-title,
  body.page-search .guide-title {
    display: none;
  }

  body.page-watch .guide-item,
  body.page-channel .guide-item,
  body.page-search .guide-item {
    flex-direction: column;
    gap: 6px;
    height: 74px;
    justify-content: center;
    font-size: 10px;
    margin: 0 4px;
    padding: 0 2px;
    min-width: 0;
  }

  body.page-watch .guide-item .guide-label,
  body.page-channel .guide-item .guide-label,
  body.page-search .guide-item .guide-label {
    display: block;
    text-align: center;
    max-width: 100%;
    white-space: normal;
    overflow-wrap: anywhere;
    line-height: 1.25;
  }

  body.page-watch .guide-channel .guide-label,
  body.page-channel .guide-channel .guide-label,
  body.page-search .guide-channel .guide-label {
    display: block;
  }

  body.page-watch .guide-section,
  body.page-channel .guide-section,
  body.page-search .guide-section {
    border-bottom: 0;
    padding: 4px 0;
  }
}

@media (max-width: 860px) {
  .masthead-search {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: var(--topbar-height);
    padding: 0 16px;
    background: var(--bg);
    display: none;
  }

  body.search-open .masthead-search {
    display: flex;
  }

  .search-toggle-button {
    display: inline-flex;
  }

  body.search-open .search-toggle-button {
    display: none;
  }

  .result-row {
    flex-direction: column;
  }

  .result-thumb {
    width: 100%;
  }

  .channel-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .you-header {
    flex-direction: column;
    align-items: flex-start;
  }
}
