:root {
  color-scheme: light;
  --accent: var(--tg-theme-button-color, #229ed9);
  --accent-text: var(--tg-theme-button-text-color, #ffffff);
  --bg: var(--tg-theme-bg-color, #ffffff);
  --surface: var(--tg-theme-secondary-bg-color, #f5f7f9);
  --text: var(--tg-theme-text-color, #12161c);
  --muted: var(--tg-theme-hint-color, #748094);
  --border: color-mix(in srgb, var(--muted) 20%, transparent);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, Roboto, "Segoe UI", "Apple Color Emoji", "Segoe UI Emoji", sans-serif;
  -webkit-text-size-adjust: 100%;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
}
button, input, select { font: inherit; }
button { color: inherit; }
.hidden { display: none !important; }

.app-shell {
  min-height: 100vh;
  max-width: 620px;
  margin: 0 auto;
  padding: 0 14px calc(116px + var(--safe-bottom));
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 8px;
  min-height: 58px;
  background: color-mix(in srgb, var(--bg) 94%, transparent);
  backdrop-filter: blur(16px);
}
.topbar h1 { margin: 0; font-size: 20px; line-height: 1.1; }

.feed-switcher {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 4px 10px;
  margin: 2px 0 14px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 13px;
  background: var(--surface);
}
.feed-switcher label { color: var(--muted); font-size: 11px; font-weight: 700; text-transform: uppercase; }
.feed-switcher select {
  min-width: 0;
  width: 100%;
  padding: 3px 24px 3px 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
}
.feed-status { grid-column: 2; color: var(--muted); font-size: 10.5px; }

.icon-button,
.outline-button,
.chip,
.category-button,
.nav-item {
  border: 0;
  background: transparent;
  cursor: pointer;
}
.icon-button { width: 38px; height: 38px; font-size: 23px; }
.outline-button,
.category-button {
  border: 1px solid var(--accent);
  color: var(--accent);
  border-radius: 12px;
  font-weight: 650;
}
.outline-button.compact { padding: 7px 10px; white-space: nowrap; font-size: 13px; }

.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 42px;
  padding: 0 12px;
  border-radius: 12px;
  background: var(--surface);
  color: var(--muted);
}
.search-box input {
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font-size: 14px;
}

.quick-filters {
  display: grid;
  grid-template-columns: auto auto 1fr;
  gap: 8px;
  margin: 10px 0 18px;
}
.chip {
  padding: 8px 12px;
  border-radius: 999px;
  background: var(--surface);
  font-weight: 600;
}
.chip.active { background: var(--accent); color: var(--accent-text); }
.category-button {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  min-width: 0;
  padding: 8px 10px;
  white-space: nowrap;
}
.grid-icon { font-size: 17px; }

h2 { margin: 16px 0 10px; font-size: 18px; }
.section-heading {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 10px;
  margin-bottom: 6px;
}
.section-heading h2 { margin-bottom: 3px; }
.section-heading p { margin: 0; color: var(--muted); font-size: 11.5px; }
.count-label { color: var(--muted); font-size: 11px; white-space: nowrap; }
.view-caption { margin: 6px 0 10px; color: var(--muted); font-size: 11.5px; }

.channel-list { border-top: 1px solid var(--border); }
.channel-row {
  display: grid;
  grid-template-columns: 24px 42px minmax(0, 1fr) 30px;
  align-items: center;
  gap: 8px;
  min-height: 68px;
  border-bottom: 1px solid var(--border);
}
.channel-rank { color: var(--muted); text-align: center; }
.channel-avatar {
  position: relative;
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--avatar, var(--accent));
  color: white;
  font-size: 16px;
  font-weight: 750;
  overflow: hidden;
}
.channel-avatar-image {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.channel-copy { min-width: 0; }
.channel-copy strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
}
.channel-copy span {
  display: block;
  overflow: hidden;
  margin-top: 3px;
  color: var(--muted);
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 11.5px;
}
.check-button {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border: 1.5px solid var(--muted);
  border-radius: 7px;
  background: transparent;
  color: transparent;
  cursor: pointer;
}
.check-button.checked { border-color: var(--accent); background: var(--accent); color: white; }
.remove-button {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 1px solid color-mix(in srgb, #e04444 45%, var(--border));
  border-radius: 8px;
  background: transparent;
  color: #e04444;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}
.remove-button:active { background: color-mix(in srgb, #e04444 10%, var(--bg)); }
.empty-state { padding: 30px 10px; color: var(--muted); text-align: center; font-size: 13px; }
.empty-state p { margin: 0 0 12px; }
.empty-state .outline-button { padding: 8px 12px; }

.popular-category-grid,
.category-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
.popular-category-card,
.category-card {
  border: 1px solid var(--border);
  background: var(--bg);
  cursor: pointer;
  text-align: left;
}
.popular-category-card {
  min-height: 94px;
  padding: 12px;
  border-radius: 14px;
}
.popular-category-card.selected { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, var(--bg)); }
.category-symbol {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  margin-bottom: 10px;
  border-radius: 50%;
  background: var(--surface);
  color: var(--accent);
  font-size: 17px;
}
.popular-category-card strong { font-size: 13px; }
.category-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  min-height: 46px;
  padding: 9px 11px;
  border-radius: 11px;
  font-size: 13px;
}
.all-categories-title { margin-top: 20px; }

.save-panel {
  position: fixed;
  z-index: 12;
  right: 0;
  bottom: calc(56px + var(--safe-bottom));
  left: 0;
  max-width: 620px;
  margin: 0 auto;
  padding: 8px 14px;
  background: color-mix(in srgb, var(--bg) 96%, transparent);
  backdrop-filter: blur(16px);
}
.info-banner {
  margin-bottom: 8px;
  padding: 9px 12px;
  border-radius: 12px;
  background: color-mix(in srgb, var(--accent) 10%, var(--bg));
  color: var(--accent);
  font-size: 11.5px;
}
.primary-button {
  width: 100%;
  min-height: 44px;
  border: 0;
  border-radius: 14px;
  background: var(--accent);
  color: var(--accent-text);
  font-weight: 750;
  cursor: pointer;
}
.primary-button:disabled { opacity: .55; cursor: wait; }

.bottom-nav {
  position: fixed;
  z-index: 11;
  right: 0;
  bottom: 0;
  left: 0;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  max-width: 620px;
  min-height: calc(56px + var(--safe-bottom));
  margin: 0 auto;
  padding-bottom: var(--safe-bottom);
  border-top: 1px solid var(--border);
  background: var(--bg);
}
.nav-item {
  display: grid;
  place-content: center;
  gap: 3px;
  color: var(--muted);
  font-size: 11px;
}
.nav-item span { font-size: 18px; }
.nav-item.active { color: var(--accent); font-weight: 700; }

.add-feed-button {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 1.5px solid var(--accent);
  border-radius: 8px;
  background: transparent;
  color: var(--accent);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  touch-action: manipulation;
}
.add-feed-button:active {
  background: var(--accent);
  color: var(--accent-text);
}

.recent-loader {
  display: grid;
  place-items: center;
  min-height: 64px;
  padding: 12px 0 2px;
}
.recent-loader .outline-button { padding: 8px 18px; }
.channel-skeleton > span {
  height: 11px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--surface), color-mix(in srgb, var(--muted) 12%, var(--surface)), var(--surface));
  background-size: 220% 100%;
  animation: skeleton-shimmer 1.15s ease-in-out infinite;
}
.channel-skeleton > span:nth-child(1) { width: 13px; }
.channel-skeleton > span:nth-child(2) { width: 42px; height: 42px; border-radius: 50%; }
.channel-skeleton > span:nth-child(3) { width: min(190px, 75%); }
.channel-skeleton > span:nth-child(4) { width: 27px; height: 27px; border-radius: 8px; }
@keyframes skeleton-shimmer { to { background-position: -220% 0; } }

.feeds-intro {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr);
  gap: 10px;
  margin: 4px 0 17px;
  padding: 12px;
  border-radius: 14px;
  background: color-mix(in srgb, var(--accent) 9%, var(--surface));
}
.feeds-intro > span {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 11px;
  background: var(--accent);
  color: var(--accent-text);
  font-size: 21px;
}
.feeds-intro strong,
.feeds-intro p { display: block; }
.feeds-intro strong { font-size: 13px; }
.feeds-intro p { margin: 4px 0 0; color: var(--muted); font-size: 10.5px; line-height: 1.45; }
.feeds-section-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin: 13px 0 7px;
}
.feeds-section-heading h2 { margin: 0; font-size: 16px; }
.feeds-section-heading span { color: var(--muted); font-size: 10.5px; }
.feed-list { display: grid; gap: 8px; }
.feed-card,
.new-feed-card {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 62px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--bg);
  color: var(--text);
  text-align: left;
  cursor: pointer;
}
.new-feed-card:active { background: var(--surface); }
.feed-card.is-disabled { opacity: .55; }
.feed-card-icon,
.new-feed-card > span:first-child {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: color-mix(in srgb, var(--accent) 12%, var(--surface));
  color: var(--accent);
  font-size: 20px;
}
.feed-card-icon {
  padding: 0;
  border: 0;
  cursor: pointer;
}
.feed-card-icon:active { transform: scale(.94); }
.feed-card-open {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  align-self: stretch;
  min-width: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
}
.feed-card-open:disabled { cursor: default; }
.feed-card-copy,
.new-feed-card > span:nth-child(2) { min-width: 0; }
.feed-card-copy strong,
.feed-card-copy small,
.new-feed-card strong,
.new-feed-card small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.feed-card-copy strong,
.new-feed-card strong { font-size: 13px; }
.feed-card-copy small,
.new-feed-card small { margin-top: 4px; color: var(--muted); font-size: 10.5px; }
.feed-card-arrow { color: var(--muted); font-size: 22px; }
.new-feed-card { margin-top: 9px; border-style: dashed; border-color: color-mix(in srgb, var(--accent) 48%, var(--border)); }
.feeds-empty {
  max-width: 460px;
  margin: 0 auto;
  padding: 15px 2px 4px;
  text-align: center;
}
.feeds-empty-art {
  position: relative;
  width: 104px;
  height: 76px;
  margin: 4px auto 15px;
}
.feeds-empty-art > span {
  display: grid;
  place-items: center;
  width: 70px;
  height: 70px;
  margin: auto;
  border-radius: 22px;
  background: color-mix(in srgb, var(--accent) 12%, var(--surface));
  color: var(--accent);
  font-size: 34px;
}
.feeds-empty-art i {
  position: absolute;
  display: grid;
  place-items: center;
  width: 25px;
  height: 25px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-text);
  font-style: normal;
  font-size: 12px;
}
.feeds-empty-art i:nth-of-type(1) { top: 2px; right: 3px; }
.feeds-empty-art i:nth-of-type(2) { right: 2px; bottom: 2px; }
.feeds-empty-art i:nth-of-type(3) { bottom: 0; left: 1px; }
.feeds-empty h2 { margin: 0 0 8px; font-size: 19px; }
.feeds-empty > p { margin: 0 auto 17px; color: var(--muted); font-size: 11.5px; line-height: 1.55; }
.feed-benefits { display: grid; gap: 8px; margin-bottom: 16px; text-align: left; }
.feed-benefits > div {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 12px;
  background: var(--surface);
}
.feed-benefits b {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: color-mix(in srgb, var(--accent) 13%, var(--bg));
  color: var(--accent);
  font-size: 17px;
}
.feed-benefits strong,
.feed-benefits small { display: block; }
.feed-benefits strong { font-size: 12px; }
.feed-benefits small { margin-top: 2px; color: var(--muted); font-size: 9.5px; line-height: 1.35; }
.feeds-refresh {
  display: block;
  margin: 14px auto 0;
  padding: 7px 10px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 10.5px;
  cursor: pointer;
}

.add-dialog {
  width: min(100% - 20px, 480px);
  max-height: calc(100dvh - 20px);
  padding: 0;
  border: 0;
  border-radius: 18px;
  background: var(--bg);
  color: var(--text);
}
.add-dialog::backdrop { background: rgba(15, 23, 42, .44); }
.dialog-card { max-height: calc(100dvh - 20px); padding: 16px; overflow-y: auto; }
.dialog-header { display: flex; justify-content: space-between; gap: 12px; }
.dialog-header h2 { margin: 0 0 4px; font-size: 19px; }
.dialog-header p { margin: 0; color: var(--muted); font-size: 12px; }
.picker-button {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  width: 100%;
  margin-top: 16px;
  padding: 11px 12px;
  border: 1px solid color-mix(in srgb, var(--accent) 42%, var(--border));
  border-radius: 13px;
  background: color-mix(in srgb, var(--accent) 8%, var(--bg));
  color: var(--text);
  text-align: left;
  cursor: pointer;
}
.picker-button:disabled { opacity: .55; cursor: wait; }
.picker-button strong,
.picker-button small { display: block; }
.picker-button strong { font-size: 13px; }
.picker-button small { margin-top: 2px; color: var(--muted); font-size: 10.5px; }
.picker-icon {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-text);
}
.add-search-box { margin-bottom: 8px; }
.add-channel-list {
  max-height: 228px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 13px;
}
.add-channel-row {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) 24px;
  align-items: center;
  gap: 9px;
  min-height: 50px;
  padding: 7px 10px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}
.add-channel-row:last-child { border-bottom: 0; }
.add-channel-row > span:nth-child(2) { min-width: 0; }
.add-channel-row strong,
.add-channel-row small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.add-channel-row strong { font-size: 12px; }
.add-channel-row small { margin-top: 2px; color: var(--muted); font-size: 10px; }
.add-channel-row input { width: 19px; height: 19px; accent-color: var(--accent); }
.mini-avatar {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--avatar, var(--accent));
  color: white;
  font-size: 11px;
  font-weight: 750;
}
.add-list-empty { margin: 0; padding: 18px 12px; color: var(--muted); text-align: center; font-size: 11px; }
#add-selected-button { min-height: 40px; margin-top: 8px; border-radius: 12px; }
.form-divider {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 13px 0 0;
  color: var(--muted);
  font-size: 10px;
}
.form-divider::before,
.form-divider::after { content: ''; flex: 1; height: 1px; background: var(--border); }
.dialog-close {
  flex: 0 0 42px;
  width: 42px;
  height: 42px;
  margin: -9px -9px 0 0;
  border-radius: 50%;
  line-height: 1;
  touch-action: manipulation;
}
.dialog-close:active { background: var(--surface); }
.compact-dialog { width: min(100% - 20px, 420px); }
.feed-choice-list { display: grid; gap: 7px; margin: 15px 0 11px; }
.feed-choice-row {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) 22px;
  align-items: center;
  gap: 10px;
  min-height: 56px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 12px;
  cursor: pointer;
}
.feed-choice-row:has(input:checked) {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 7%, var(--bg));
}
.feed-choice-row.is-existing { opacity: .58; cursor: default; }
.feed-choice-icon {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 11px;
  background: var(--surface);
  color: var(--accent);
  font-size: 19px;
}
.feed-choice-row > span:nth-child(2) { min-width: 0; }
.feed-choice-row strong,
.feed-choice-row small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.feed-choice-row strong { font-size: 12.5px; }
.feed-choice-row small { margin-top: 3px; color: var(--muted); font-size: 10px; }
.feed-choice-row input { width: 19px; height: 19px; accent-color: var(--accent); }
.destination-option {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 62px;
  margin-top: 9px;
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: 13px;
  background: var(--bg);
  color: var(--text);
  text-align: left;
  cursor: pointer;
}
.destination-option:first-of-type { margin-top: 16px; }
.destination-option > span:first-child {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 11px;
  background: color-mix(in srgb, var(--accent) 12%, var(--surface));
  color: var(--accent);
  font-size: 19px;
}
.destination-option > span:nth-child(2) { min-width: 0; }
.destination-option strong,
.destination-option small { display: block; }
.destination-option strong { font-size: 12.5px; }
.destination-option small { margin-top: 3px; color: var(--muted); font-size: 9.5px; line-height: 1.35; }
.destination-option b { color: var(--muted); font-size: 20px; font-weight: 400; }
.dialog-note { margin: 12px 2px 0; color: var(--muted); font-size: 9.5px; line-height: 1.5; }
.field-label { display: block; margin: 16px 0 7px; font-size: 12px; font-weight: 700; }
.text-input {
  width: 100%;
  height: 46px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 13px;
  outline: none;
  background: var(--bg);
  color: var(--text);
}
.text-input:focus { border-color: var(--accent); }
.field-hint { margin: 7px 0 13px; color: var(--muted); font-size: 11px; }
.resolved-channel { margin-bottom: 11px; padding: 11px; border: 1px solid var(--accent); border-radius: 12px; }
.resolved-channel strong { display: block; }
.resolved-channel span { color: var(--muted); font-size: 13px; }
.field-error { margin: 0 0 11px; color: #d92d20; font-size: 12px; }

.toast {
  position: fixed;
  z-index: 50;
  right: 20px;
  bottom: calc(70px + var(--safe-bottom));
  left: 20px;
  max-width: 500px;
  margin: auto;
  padding: 10px 14px;
  border-radius: 12px;
  background: #17202a;
  color: white;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
  transition: .2s ease;
}
.toast.visible { opacity: 1; transform: translateY(0); }

@media (max-width: 390px) {
  .app-shell { padding-right: 12px; padding-left: 12px; }
  .topbar h1 { font-size: 18px; }
  .outline-button.compact { padding: 7px 8px; font-size: 12px; }
  .quick-filters { grid-template-columns: auto auto; }
  .category-button { grid-column: 1 / -1; }
  .channel-row { grid-template-columns: 20px 38px minmax(0, 1fr) 28px; }
  .channel-avatar { width: 38px; height: 38px; }
  .nav-item { font-size: 9.5px; }
  .nav-item span { font-size: 16px; }
  .feed-switcher { margin-bottom: 9px; padding: 9px 10px; }
  .feeds-empty { padding-top: 7px; }
}

/* Mini App surfaces follow Telegram's theme, with browser fallbacks. */
:root {
  color-scheme: light dark;
  --title-size: 24px;
  --section-title-size: 20px;
  --row-size: 16px;
  --caption-size: 13px;
  --accent: light-dark(var(--tg-theme-button-color, #167abb), #78b8f1);
  --accent-text: light-dark(var(--tg-theme-button-text-color, #fff), #102338);
  --link: light-dark(var(--tg-theme-accent-text-color, var(--tg-theme-link-color, #126fa8)), #78b8f1);
  --bg: light-dark(var(--tg-theme-bg-color, #fff), #232e3c);
  --secondary: light-dark(var(--tg-theme-secondary-bg-color, #eff2f5), #202b38);
  --surface: light-dark(color-mix(in srgb, var(--tg-theme-section-bg-color, var(--secondary)) 55%, var(--secondary)), #17212b);
  --input-surface: light-dark(var(--surface), #333c47);
  --nav-surface: light-dark(var(--tg-theme-bottom-bar-bg-color, var(--surface)), #13253e);
  --nav-active: light-dark(color-mix(in srgb, var(--link) 13%, var(--nav-surface)), #1b3250);
  --nav-border: light-dark(var(--border), #405670);
  --text: light-dark(var(--tg-theme-text-color, #17212b), #f3f7fc);
  --muted: light-dark(var(--tg-theme-subtitle-text-color, var(--tg-theme-hint-color, #566676)), #a9bbcd);
  --border: light-dark(var(--tg-theme-section-separator-color, color-mix(in srgb, var(--muted) 23%, transparent)), #344457);
  --danger: var(--tg-theme-destructive-text-color, light-dark(#b82d3a, #ff8c96));
  --safe-bottom: max(env(safe-area-inset-bottom, 0px), var(--tg-safe-area-inset-bottom, 0px));
}

:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }

body { min-width: 0; }
.app-shell {
  max-width: 560px;
  padding: 0 14px calc(78px + var(--safe-bottom));
}
.topbar {
  min-height: 58px;
  gap: 9px;
  background: color-mix(in srgb, var(--bg) 95%, transparent);
}
.topbar h1 { font-size: 19px; font-weight: 650; }
.header-add-button {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  padding: 0;
  border: 1px solid var(--accent);
  border-radius: 13px;
  background: transparent;
  color: var(--accent);
  font-size: 23px;
  line-height: 1;
  cursor: pointer;
  touch-action: manipulation;
}
.header-add-button:active { background: color-mix(in srgb, var(--accent) 13%, var(--bg)); }

.feed-switcher {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  min-height: 62px;
  margin: 4px 0 14px;
  padding: 9px 12px;
  border: 0;
  border-radius: 14px;
  background: var(--surface);
}
.feed-switcher-icon {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 11px;
  background: color-mix(in srgb, var(--accent) 15%, transparent);
  color: var(--accent);
  font-size: 21px;
}
.feed-switcher-copy { min-width: 0; }
.feed-switcher label {
  display: block;
  color: var(--muted);
  font-size: 9.5px;
  font-weight: 500;
  line-height: 1.1;
  text-transform: none;
}
.feed-switcher select {
  display: block;
  width: 100%;
  min-width: 0;
  margin-top: 3px;
  padding: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font-size: 13.5px;
  font-weight: 650;
  appearance: none;
}
.feed-switcher-chevron { color: var(--muted); font-size: 17px; }
.feed-status { display: none; }

.search-box {
  height: 40px;
  padding: 0 11px;
  border-radius: 12px;
}
.search-box input { font-size: 13px; }
.quick-filters {
  grid-template-columns: auto auto minmax(0, 1fr);
  gap: 7px;
  margin: 9px 0 14px;
}
.chip { padding: 7px 11px; font-size: 12px; }
.category-button { padding: 7px 9px; font-size: 11.5px; }
.grid-icon { font-size: 15px; }
h2 { font-size: 16px; }
.section-heading { margin-bottom: 4px; align-items: end; }
.section-heading h2 { margin: 11px 0 2px; font-size: 16px; }
.section-heading p { font-size: 10.5px; }
.count-label { font-size: 10.5px; }
.view-caption {
  margin: 0 2px 6px;
  color: var(--muted);
  font-size: 11px;
}

.channel-list { border-top-color: var(--border); }
.channel-row {
  grid-template-columns: 21px 40px minmax(0, 1fr) 34px;
  gap: 9px;
  min-height: 64px;
}
.channel-row-my { grid-template-columns: 40px minmax(0, 1fr) 34px; }
.channel-rank { font-size: 11px; }
.channel-avatar { width: 40px; height: 40px; font-size: 14px; }
.channel-copy strong { font-size: 13px; font-weight: 650; }
.channel-copy span { margin-top: 3px; font-size: 10.5px; }
.add-feed-button {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  font-size: 20px;
}
.remove-button {
  width: 34px;
  height: 44px;
  border: 0;
  border-radius: 0;
  color: #ff6067;
  font-size: 20px;
}
.remove-button:active { background: transparent; color: #ff8b90; }

.feeds-section-heading { margin: 9px 2px 6px; }
.feeds-section-heading h2 { font-size: 14px; }
.feeds-section-heading span { font-size: 10px; }
.feed-list { gap: 7px; }
.feed-card,
.new-feed-card {
  grid-template-columns: 38px minmax(0, 1fr) auto;
  gap: 10px;
  min-height: 60px;
  padding: 9px 11px;
  border-radius: 14px;
}
.feed-card-icon,
.new-feed-card > span:first-child {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  font-size: 19px;
}
.feed-card-copy strong,
.new-feed-card strong { font-size: 12.5px; }
.feed-card-copy small,
.new-feed-card small { margin-top: 3px; font-size: 9.5px; }
.new-feed-card { margin-top: 7px; }
.feeds-intro { display: none; }
.feeds-empty { padding: 21px 5px 4px; }
.feeds-empty-art { width: 92px; height: 68px; margin-bottom: 12px; }
.feeds-empty-art > span { width: 62px; height: 62px; border-radius: 20px; font-size: 31px; }
.feeds-empty-art i { width: 22px; height: 22px; font-size: 10px; }
.feeds-empty h2 { margin-bottom: 7px; font-size: 17px; }
.feeds-empty > p { max-width: 330px; margin-bottom: 14px; font-size: 10.5px; }
.feeds-empty .primary-button { max-width: 330px; }
.feed-benefits { display: none; }
.feeds-refresh { margin-top: 10px; font-size: 10px; }

.bottom-nav {
  max-width: 560px;
  min-height: calc(60px + var(--safe-bottom));
  background: color-mix(in srgb, var(--bg) 98%, transparent);
}
.nav-item { gap: 3px; font-size: 9.5px; }
.nav-item span { font-size: 17px; }

.save-panel {
  bottom: calc(60px + var(--safe-bottom));
  max-width: 560px;
  padding: 7px 14px;
}
.info-banner { display: none; }
.primary-button { min-height: 42px; border-radius: 13px; font-size: 13px; }

.add-dialog { width: min(100% - 18px, 440px); border-radius: 17px; }
.dialog-card { padding: 14px; }
.dialog-header h2 { font-size: 17px; }
.dialog-header p { font-size: 10.5px; }
.dialog-close { width: 42px; height: 42px; }
.picker-button {
  grid-template-columns: 34px minmax(0, 1fr) auto;
  gap: 9px;
  margin-top: 13px;
  padding: 9px 10px;
  border-radius: 12px;
}
.picker-icon { width: 34px; height: 34px; }
.picker-button strong { font-size: 12px; }
.picker-button small { font-size: 9.5px; }
.field-label { margin: 13px 0 6px; font-size: 11px; }
.add-channel-list { max-height: 216px; border-radius: 12px; }
.add-channel-row { min-height: 48px; padding: 6px 9px; }
.text-input { height: 42px; border-radius: 12px; font-size: 13px; }
.field-hint { margin: 6px 0 10px; font-size: 9.5px; }
.form-divider { margin-top: 11px; }
.feed-choice-list { margin: 13px 0 9px; gap: 6px; }
.feed-choice-row { min-height: 54px; padding: 7px 9px; }
.destination-option { min-height: 58px; padding: 8px 9px; }
.destination-option strong { font-size: 12px; }
.destination-option small { font-size: 9px; }
.dialog-note { font-size: 9px; }

@media (max-width: 390px) {
  .app-shell { padding-right: 11px; padding-left: 11px; }
  .topbar h1 { font-size: 18px; }
  .quick-filters { grid-template-columns: auto auto minmax(0, 1fr); }
  .category-button { grid-column: auto; }
  .channel-row { grid-template-columns: 19px 38px minmax(0, 1fr) 32px; gap: 7px; }
  .channel-row-my { grid-template-columns: 38px minmax(0, 1fr) 32px; }
  .channel-avatar { width: 38px; height: 38px; }
}

.feed-icon-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
  margin-top: 14px;
}
.feed-icon-option {
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg);
  font-size: 23px;
  cursor: pointer;
}
.feed-icon-option.selected {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 14%, var(--bg));
  box-shadow: 0 0 0 1px var(--accent) inset;
}
.feed-icon-option:active { transform: scale(.94); }

@media (max-width: 390px) {
  .feed-icon-grid { gap: 6px; }
  .feed-icon-option { border-radius: 10px; font-size: 21px; }
}

/* Feed lists, sources and Telegram-style navigation */
body { font-size: var(--row-size); line-height: 1.4; }
.app-shell { padding-bottom: calc(84px + var(--safe-bottom)); }
.topbar { display: flex; min-height: 44px; background: var(--bg); }
.app-shell { padding-top: 12px; }
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
#back-button { flex: 0 0 36px; color: var(--link); }
.header-add-button {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  width: auto;
  min-height: 44px;
  height: auto;
  padding: 0 10px;
  border: 0;
  border-radius: 12px;
  background: var(--surface);
  color: var(--link);
  font-size: var(--caption-size);
  font-weight: 600;
}
.header-add-button::before { content: "+"; font-size: 19px; font-weight: 500; }

.bottom-nav {
  right: 12px;
  bottom: calc(8px + var(--safe-bottom));
  left: 12px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 3px;
  min-height: 56px;
  max-width: 536px;
  padding: 3px;
  border: 1px solid var(--nav-border);
  border-radius: 30px;
  background: var(--nav-surface);
  box-shadow: 0 3px 16px rgba(0, 0, 0, .12);
}
.nav-item { justify-items: center; gap: 3px; min-height: 48px; border-radius: 24px; font-size: 11px; }
.nav-item.active { background: var(--nav-active); color: var(--link); }
.nav-icon[data-feed-emoji] { width: 24px; height: 24px; background: none; mask: none; }
.nav-icon, .action-icon {
  display: block;
  width: 20px;
  height: 20px;
  background: currentColor;
  -webkit-mask: var(--nav-icon-image) center / contain no-repeat;
  mask: var(--nav-icon-image) center / contain no-repeat;
}
.nav-icon-feeds { --nav-icon-image: url("/icons/nut-fill.svg"); }
.nav-icon-sources { --nav-icon-image: url("/icons/megaphone.svg"); }
.nav-icon-collections { --nav-icon-image: url("/icons/list-star.svg"); }
.icon-bin { --nav-icon-image: url("/icons/bin.svg"); }
.icon-close { --nav-icon-image: url("/icons/xmark.svg"); }
.icon-refresh { --nav-icon-image: url("/icons/refresh.svg"); }
.icon-swap { --nav-icon-image: url("/icons/swap.svg"); }
.icon-telegram { --nav-icon-image: url("/icons/telegram.svg"); }
.icon-settings { --nav-icon-image: url("/icons/settings.svg"); }

#feeds-content { padding-top: 3px; }
.feed-list, #my-channel-list { border: 0; border-radius: 14px; background: var(--surface); }
.feed-list { gap: 0; }
.feed-card {
  display: block;
  min-height: 64px;
  padding: 9px 12px;
  border: 0;
  border-radius: 0;
  background: transparent;
  cursor: default;
}
.feed-card + .feed-card { border-top: 1px solid var(--border); }
.feed-card:first-child { border-radius: 14px 14px 0 0; }
.feed-card:last-child { border-radius: 0 0 14px 14px; }
.feed-card:only-child { border-radius: 14px; }
.feed-card-icon {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  color: var(--link);
  font-size: 22px;
}
.feed-card-open {
  grid-template-columns: 44px minmax(0, 1fr) auto;
  width: 100%;
  min-height: 44px;
  gap: 10px;
  border-radius: 7px;
}
.feed-card-copy strong { font-size: var(--row-size); font-weight: 600; }
.feed-card-copy small { margin-top: 2px; font-size: var(--caption-size); }
.feed-card-arrow { font-size: 22px; font-weight: 400; }
.new-feed-card {
  display: flex;
  justify-content: center;
  gap: 7px;
  min-height: 48px;
  margin-top: 14px;
  padding: 8px 12px;
  border: 0;
  border-radius: 12px;
  background: var(--accent);
  color: var(--accent-text);
}
.new-feed-card > span:first-child {
  width: auto;
  height: auto;
  background: transparent;
  color: var(--accent-text);
  font-size: 24px;
}
.new-feed-card strong { font-size: var(--row-size); font-weight: 600; }
.new-feed-card:active { background: color-mix(in srgb, var(--accent) 88%, black); }

.feed-switcher { min-height: 60px; padding: 8px 12px; }
.feed-switcher-icon { border-radius: 50%; color: var(--link); }
.feed-switcher label { font-size: var(--caption-size); }
.feed-switcher select { min-height: 27px; margin: 0; font-size: var(--row-size); font-weight: 600; text-overflow: ellipsis; }
.feed-status {
  display: block;
  grid-column: 2 / -1;
  margin-top: -6px;
  font-size: 12px;
  overflow-wrap: anywhere;
}
.feed-status:empty { display: none; }
.view-caption { margin: 0 4px 7px; font-size: var(--caption-size); }
.channel-row-my {
  grid-template-columns: 38px minmax(0, 1fr) 44px;
  min-height: 57px;
  padding: 5px 5px 5px 11px;
}
.channel-row-my:last-child { border-bottom: 0; }
.channel-row-my .channel-avatar { width: 38px; height: 38px; }
.channel-copy strong { font-size: var(--row-size); font-weight: 600; }
.channel-copy span { font-size: var(--caption-size); }
.remove-button { width: 44px; color: var(--danger); border-radius: 50%; }
.remove-button:active { color: var(--danger); background: color-mix(in srgb, var(--danger) 10%, transparent); }
.empty-state p { font-size: 13px; }
.outline-button { font-size: 13px; }
.primary-button { min-height: 46px; font-size: var(--row-size); font-weight: 600; }

.add-dialog { background: var(--bg); }
.add-dialog::backdrop { background: rgba(0, 0, 0, .42); }
.dialog-card { padding: 16px; }
.dialog-header h2 { font-size: var(--section-title-size); font-weight: 700; }
.dialog-header p { font-size: var(--caption-size); }
.dialog-close { flex-basis: 44px; width: 44px; height: 44px; color: var(--muted); }
.feed-choice-list, .digest-toggles {
  margin-top: 12px;
  border-radius: 12px;
  background: var(--surface);
}
.feed-choice-list { gap: 0; }
.feed-choice-row { border: 0; border-radius: 0; }
.feed-choice-row:has(input:checked) { background: color-mix(in srgb, var(--accent) 9%, var(--surface)); }
.feed-choice-row + .feed-choice-row,
.digest-toggle + .digest-toggle { border-top: 1px solid var(--border); }

.create-feed-screen {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  overscroll-behavior: contain;
  background: var(--bg);
  color: var(--text);
}
.create-feed-screen::backdrop { background: var(--bg); }
.create-feed-content {
  max-width: 560px;
  margin: 0 auto;
  padding: 18px 16px calc(24px + var(--safe-bottom));
}
.create-feed-screen[open] .create-feed-content { animation: open-create-feed .22s ease-out both; }
@keyframes open-create-feed {
  from { opacity: 0; transform: translateX(12px); }
  to { opacity: 1; transform: translateX(0); }
}
.create-feed-back {
  min-height: 44px;
  margin: -8px 0 6px;
  padding: 0 8px 0 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--link);
  cursor: pointer;
}
#create-feed-title {
  margin: 0 0 8px;
  font-size: var(--section-title-size);
  font-weight: 700;
  line-height: 1.2;
}
#create-feed-intro {
  max-width: 38ch;
  margin: 0 0 20px;
  color: var(--muted);
  font-size: var(--row-size);
  line-height: 1.4;
}
.create-feed-screen[open] #create-feed-choice:not(.hidden),
.create-feed-screen[open] #connect-feed-step:not(.hidden) {
  animation: open-create-feed .18s ease-out both;
}
.connect-feed-copy, .connect-feed-status {
  max-width: 42ch;
  color: var(--muted);
  line-height: 1.45;
}
.connect-feed-copy { margin: 0 0 20px; }
.connect-feed-status { margin: 0 0 14px; color: var(--text); font-size: var(--caption-size); }
.connect-feed-status:empty { display: none; }
.destination-list {
  border-radius: 12px;
  background: var(--surface);
}
.destination-option {
  grid-template-columns: 38px minmax(0, 1fr) 12px;
  min-height: 68px;
  margin: 0;
  padding: 11px 12px;
  border: 0;
  border-radius: 0;
  background: transparent;
  transition: background-color .14s ease;
}
.destination-option:first-of-type { margin: 0; }
.destination-option:first-child { border-radius: 12px 12px 0 0; }
.destination-option:last-child { border-radius: 0 0 12px 12px; }
.destination-option + .destination-option { border-top: 1px solid var(--border); }
.destination-option > .destination-icon:first-child {
  position: relative;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--link) 12%, transparent);
  color: var(--link);
  transition: transform .14s ease;
}
.destination-icon::before, .destination-icon::after {
  position: absolute;
  content: "";
  border: 1.5px solid currentColor;
}
.destination-icon-group::before {
  top: 8px;
  left: 15px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
}
.destination-icon-group::after {
  bottom: 9px;
  left: 10px;
  width: 18px;
  height: 9px;
  border-radius: 8px 8px 4px 4px;
}
.destination-icon-channel::before { inset: 11px 10px; border-radius: 3px; }
.destination-icon-channel::after { inset: 15px 14px; border-width: 1.5px 0; }
.destination-option strong { font-size: 17px; font-weight: 600; }
.destination-option small { font-size: var(--caption-size); line-height: 1.35; }
.destination-option:active {
  background: color-mix(in srgb, var(--link) 12%, var(--surface));
}
.destination-option:active .destination-icon { transform: scale(.92); }
.picker-button { border: 0; background: var(--surface); }
.picker-button strong { font-size: var(--row-size); }
.picker-button small, .field-label { font-size: var(--caption-size); }
.text-input { height: 46px; background: var(--input-surface); font-size: 16px; }
.text-input::placeholder { color: var(--muted); opacity: 1; }
.add-channel-row strong { font-size: 13px; }
.add-channel-row small,
.field-hint,
.add-list-empty { font-size: var(--caption-size); }
.field-error { color: var(--danger); }
.feed-choice-row strong { font-size: 13.5px; }
.feed-choice-row small { font-size: 12px; }

@media (max-width: 480px) {
  .add-dialog {
    inset: auto 0 0;
    width: min(100%, 440px);
    max-width: none;
    margin: 0 auto;
    border-radius: 20px 20px 0 0;
  }
  .dialog-card { padding-bottom: calc(16px + var(--safe-bottom)); }
}

.telegram-mobile .picker-button,
.telegram-mobile .form-divider,
#telegram-picker-button.hidden + .form-divider { display: none; }
.telegram-mobile #add-dialog .field-label { margin-top: 9px; }

/* Delivery health state */
.feed-card.is-disabled {
  opacity: 1;
  background: color-mix(in srgb, var(--danger) 6%, var(--surface));
}
.feed-card.is-disabled .feed-card-icon {
  background: color-mix(in srgb, var(--danger) 12%, var(--surface));
}
.feed-card.is-disabled .feed-card-copy small { color: var(--danger); }
.feed-card.is-disabled .feed-card-arrow { display: none; }
.feed-actions {
  display: grid;
  margin-bottom: 14px;
  overflow: hidden;
  border-radius: 14px;
  background: var(--surface);
}
.feed-action {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 43px;
  padding: 6px 12px;
  border: 0;
  background: transparent;
  color: var(--link);
  font-size: var(--row-size);
  text-align: left;
  cursor: pointer;
  transition: background-color .15s ease;
}
.feed-action:not(.hidden) ~ .feed-action:not(.hidden) { border-top: 1px solid var(--border); }
.feed-action-danger { color: var(--danger); }
.feed-action:active { background: color-mix(in srgb, currentColor 10%, transparent); }
.feed-action:disabled { opacity: .55; cursor: wait; }
.feed-action .action-icon { flex: none; }

.app-shell[data-view="feed"], .app-shell[data-view="settings"], .app-shell[data-view="feed-add"],
.app-shell[data-view="feed-catalog"], .app-shell[data-view="collection"] {
  padding-bottom: calc(24px + var(--safe-bottom));
}
.feed-summary {
  --summary-icon-size: clamp(72px, 23vw, 92px);
  display: grid;
  grid-template-columns: var(--summary-icon-size) minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  padding: 12px 2px 6px;
}
.feed-summary-copy { overflow-wrap: anywhere; }
.feed-summary h2 { margin: 0 0 5px; font-size: var(--section-title-size); line-height: 1.2; }
.feed-summary p { margin: 3px 0 0; color: var(--muted); font-size: var(--caption-size); }
.feed-summary p:empty { display: none; }
.feed-summary .feed-card-icon {
  width: var(--summary-icon-size);
  height: var(--summary-icon-size);
  border-radius: 25%;
  background: var(--surface);
  font-size: 43px;
  cursor: default;
}
.feed-summary-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.feed-edit { width: 44px; height: 44px; border-radius: 50%; color: var(--link); }
.feed-edit:disabled, .header-add-button:disabled { opacity: .48; cursor: default; }
.feed-edit .action-icon { width: 23px; height: 23px; }
.feed-section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 14px 0 7px;
}
.feed-section-heading h2 { margin: 0; font-size: var(--row-size); }
#library-list, #feed-library { border: 0; border-radius: 14px; background: var(--surface); }
.channel-row .remove-button { display: grid; height: 44px; place-items: center; }
.list-empty { margin: 0; padding: 16px 12px; color: var(--muted); font-size: var(--caption-size); }
.library-retry {
  min-height: 44px;
  padding: 0 12px;
  border: 0;
  background: transparent;
  color: var(--link);
  cursor: pointer;
}
#channel-search-form { margin-bottom: 10px; }
#channel-search-input {
  display: block;
  height: auto;
  min-height: 44px;
  max-height: 115px;
  padding-block: 10px;
  field-sizing: content;
  font: inherit;
  line-height: 1.4;
  resize: none;
}
#channel-search-error { margin: 6px 0 0; white-space: pre-line; overflow-wrap: anywhere; }
#channel-search-error:empty, #digest-time-hint:empty { display: none; }
#channel-search-add { margin-top: 8px; }
#channel-search-more { display: block; margin: 3px auto 0; }
.feed-catalog-title { margin: 0 0 8px; font-size: var(--row-size); }
.source-shortcuts { display: flex; flex-wrap: wrap; gap: 5px; }
.source-shortcuts:has(button:not(.hidden)) { margin-bottom: 9px; }
.source-shortcuts .text-action {
  display: flex;
  align-items: center;
  gap: 7px;
  min-height: 44px;
  width: fit-content;
  margin: 0;
  padding-inline: 12px;
  border-radius: 12px;
  background: var(--surface);
  font-weight: 600;
}
#telegram-picker-button .action-icon { width: 16px; height: 16px; flex: none; }
.source-shortcuts .text-action:active { background: var(--nav-active); }
.channel-current { color: var(--muted); font-size: 12px; white-space: nowrap; }
:is(#channel-search-results, #collection-channels) .channel-row-my:has(.channel-current) {
  grid-template-columns: 38px minmax(0, 1fr) auto;
}
.text-action {
  min-height: 44px;
  margin-left: auto;
  padding: 0 4px;
  border: 0;
  background: transparent;
  color: var(--link);
  font-size: 13px;
  cursor: pointer;
}
.selectable-source { cursor: pointer; }
.selectable-source:has(:checked) { background: var(--nav-active); }
.source-checkbox {
  appearance: none;
  display: grid;
  place-content: center;
  justify-self: center;
  width: 21px;
  height: 21px;
  margin: 0;
  border: 1.5px solid var(--muted);
  border-radius: 6px;
  background: var(--surface);
  cursor: pointer;
}
.source-checkbox:checked { background: var(--accent); border-color: var(--accent); }
.source-checkbox:checked::after {
  content: '';
  width: 10px;
  height: 6px;
  border-left: 2px solid var(--accent-text);
  border-bottom: 2px solid var(--accent-text);
  transform: translateY(-1px) rotate(-45deg);
}
.feed-library-bar {
  position: sticky;
  bottom: var(--safe-bottom);
  z-index: 1;
  padding-block: 8px;
  background: var(--bg);
}
.settings-card {
  padding: 12px;
  border-radius: 14px;
  background: var(--surface);
}
.settings-card > .field-label { margin-top: 0; }
.settings-icons { margin-top: 9px; }
.settings-icons summary {
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 42px;
  padding-inline: 8px;
  cursor: pointer;
  list-style: none;
}
.settings-icons summary::-webkit-details-marker { display: none; }
.settings-icons summary::after { content: "›"; color: var(--muted); }
.settings-icons[open] summary::after { transform: rotate(90deg); }
#settings-icon-preview { margin-left: auto; padding-inline: 10px; font-size: 19px; }
.settings-heading { margin: 15px 0 7px; font-size: var(--row-size); }
#settings-form .digest-toggles, #settings-form .digest-fields { margin-block: 0 8px; }
#settings-error:empty { display: none; }
.access-screen {
  display: grid;
  place-items: center;
  min-height: 100dvh;
  padding: 20px 16px calc(20px + var(--safe-bottom));
}
.access-card { width: min(100%, 400px); padding: 22px; border-radius: 18px; background: var(--surface); text-align: center; }
.access-icon { display: grid; width: 50px; height: 50px; margin: auto; place-items: center; border-radius: 50%; color: var(--link); background: var(--bg); }
.access-icon .action-icon { width: 28px; height: 28px; }
.access-card h1 { margin: 14px 0 5px; font-size: var(--section-title-size); }
.access-card p { margin: 0 0 18px; color: var(--muted); }
.access-card a { display: grid; place-items: center; text-decoration: none; }
.access-card .outline-button {
  min-height: 44px;
  margin-top: 8px;
  padding-inline: 16px;
  border-radius: 999px;
}
#channel-search-results, .collection-channels { overflow: hidden; border: 0; border-radius: 14px; background: var(--surface); }
.catalog-save { display: grid; place-items: center; width: 44px; height: 44px; border: 0; border-radius: 50%; background: transparent; color: var(--link); font-size: 22px; cursor: pointer; }
.catalog-save:active { background: color-mix(in srgb, var(--link) 10%, var(--surface)); }
.catalog-save:disabled { color: var(--muted); cursor: default; }
.collection-card { min-height: 62px; padding: 9px 11px; }
.collection-card + .collection-card { border-top: 1px solid var(--border); }
.collection-heading {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  padding: 12px;
  border-radius: 14px;
  background: var(--surface);
}
.collection-heading h2 { margin: 0; font-size: var(--section-title-size); }
.collection-heading p { margin: 3px 0 0; color: var(--muted); font-size: var(--caption-size); }
.collection-selection {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: -4px 4px 3px;
  color: var(--muted);
  font-size: var(--caption-size);
}
.collection-selection .text-action:disabled { opacity: .5; cursor: default; }
.collection-buttons { display: grid; gap: 7px; margin-top: 10px; }
.collection-buttons button {
  min-height: 46px;
  width: 100%;
  border-radius: 999px;
  font-size: var(--row-size);
}
.collection-buttons button:disabled { opacity: .55; cursor: default; }
.appearance-icons { min-width: 0; margin: 12px 0 16px; padding: 0; border: 0; }
.appearance-icons .field-label { padding: 0; }
.appearance-icons .feed-icon-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); margin-top: 4px; }
.appearance-icons .feed-icon-option { min-height: 44px; aspect-ratio: auto; }
#feed-appearance-error:empty { display: none; }
.add-dialog[open] .dialog-card { animation: open-app-sheet .19s ease-out both; }
@keyframes open-app-sheet {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
.digest-toggle {
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 48px;
  gap: 12px;
  padding: 6px 12px;
  font-size: 14px;
}
.digest-toggle input {
  appearance: none;
  flex: none;
  width: 38px;
  height: 22px;
  margin: 0;
  padding: 3px;
  border-radius: 99px;
  background: color-mix(in srgb, var(--muted) 46%, var(--surface));
  cursor: pointer;
  transition: background-color .15s ease;
}
.digest-toggle input::before {
  display: block;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  content: "";
  transition: transform .15s ease;
}
.digest-toggle input:checked { background: var(--accent); }
.digest-toggle input:checked::before { transform: translateX(16px); }
.digest-toggle input:disabled { opacity: .5; cursor: default; }
.digest-fields {
  display: grid;
  gap: 10px;
  min-width: 0;
  margin: 14px 0;
  padding: 12px;
  border: 0;
  border-radius: 14px;
  background: var(--surface);
  transition: opacity .18s ease;
}
.digest-fields:disabled { opacity: .5; }
.digest-fields label { display: grid; gap: 5px; font-size: 13px; }
.digest-fields .field-hint { margin: 0; }
#digest-preview {
  width: 100%;
  min-height: 44px;
  margin-top: 8px;
  padding: 6px 10px;
  border: 0;
  background: var(--surface);
  color: var(--link);
}
#digest-error:empty { display: none; }

.app-shell :focus-visible, .dialog-card :focus-visible, .create-feed-screen button:focus-visible {
  outline: 2px solid var(--link);
  outline-offset: 2px;
}
.topbar h1:focus { outline: none; }

picture[data-emoji] {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
}
picture[data-emoji] img { display: block; width: 100%; height: 100%; object-fit: contain; }
.feeds-hero { display: grid; justify-items: center; padding: 23px 6px 12px; text-align: center; }
.feeds-hero h2 { margin: 5px 0 0; font-size: 23px; line-height: 1.15; }
.feeds-hero-art { display: block; width: 76px; height: 76px; }
#feeds-view .feeds-hero .text-action { margin: 1px 0 0; }
.feed-status-tabs {
  display: flex;
  justify-content: center;
  gap: 5px;
  margin: 8px auto 12px;
}
.feed-status-tabs button {
  min-height: 42px;
  padding: 0 13px;
  border: 0;
  border-radius: 23px;
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.feed-status-tabs button[aria-pressed="true"] { background: var(--input-surface); color: var(--text); }
.feed-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.feed-grid-empty { text-align: center; }
.feed-tile { display: flex; min-width: 0; }
.feed-tile-button {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  min-height: 130px;
  gap: 4px;
  padding: 13px 8px 12px;
  border: 0;
  border-radius: 17px;
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  text-align: center;
  cursor: pointer;
}
.feed-tile-button:active { background: var(--nav-active); }
.feed-tile-button strong {
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow-wrap: anywhere;
  line-height: 1.23;
}
.feed-tile-icon { display: grid; place-items: center; width: 44px; height: 44px; font-size: 31px; }
.feed-tile-count, .feed-tile-button small { color: var(--muted); font-size: 12px; line-height: 1.2; }
.feed-tile-button small { overflow-wrap: anywhere; }
#feeds-create { margin-top: 12px; }
.feed-summary .feed-card-icon picture { width: 58%; height: 58%; }
.feed-card-open .feed-card-icon picture { width: 30px; height: 30px; }
.feed-icon-option picture { width: 30px; height: 30px; }

#settings-view { --settings-text-size: 14px; }
.telegram-mobile #settings-view { --settings-text-size: 16px; }
#settings-view :is(.field-label, .text-input, .settings-icons summary, .digest-toggle, .digest-fields label, .feed-action, .primary-button) {
  font-size: var(--settings-text-size);
}
#settings-view .text-input { height: 42px; }
#settings-view .settings-heading { margin: 15px 0 7px; padding-left: 4px; }
#settings-view .settings-icons { margin-top: 5px; }
#settings-view .settings-icons summary { padding-inline: 0 4px; min-height: 43px; }
#settings-icon-preview { display: grid; place-items: center; width: 24px; height: 24px; margin: 0 7px 0 auto; padding: 0; }
.settings-digest-card { overflow: hidden; border-radius: 14px; background: var(--surface); }
#settings-form .digest-fields { margin: 0; padding-block: 4px 12px; background: transparent; }
#settings-view .settings-link { width: 100%; min-height: 46px; padding: 7px 12px; }
#settings-view .settings-link > :first-child { display: block; flex: 0 0 21px; width: 21px; height: 21px; }
#settings-view #digest-preview { margin: 0; border-top: 1px solid var(--border); }
#settings-view #digest-preview > :last-child { margin-left: auto; color: var(--muted); }
#settings-view #feed-actions:not(.hidden) { border-top: 1px solid var(--border); }
#settings-view .feed-actions { margin: 0; }
#settings-save { margin: 14px 0 0; }

:root { --action-blue: light-dark(#17669f, #3a73aa); }
.primary-button, .new-feed-card, .story-guide-actions .primary-button {
  border-radius: 999px;
  background: var(--action-blue);
  color: #fff;
  font-weight: 650;
}
.new-feed-card > span:first-child { color: inherit; }
.new-feed-card:active { background: color-mix(in srgb, var(--action-blue) 88%, var(--bg)); }
.new-feed-card strong { font-weight: inherit; }

.bottom-nav {
  right: 18px;
  bottom: calc(10px + var(--safe-bottom));
  left: 18px;
  max-width: 288px;
  min-height: 58px;
  border-radius: 999px;
  border-color: var(--border);
  background: color-mix(in srgb, var(--surface) 96%, var(--bg));
  box-shadow: 0 5px 18px #0002;
}
.bottom-nav .nav-item { gap: 5px; min-height: 49px; border-radius: 999px; font-size: 10px; font-weight: 600; }
.bottom-nav .nav-item.active { background: var(--input-surface); }
.bottom-nav .nav-icon { width: 24px; height: 24px; }

.feeds-hero-art { width: 96px; height: 96px; }
.app-shell[data-view="feeds"] .feeds-hero-art { animation: folder-arrive .55s cubic-bezier(.2,.75,.3,1) both; }
@keyframes folder-arrive {
  from { opacity: .45; transform: translateY(8px) scale(.9); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.feed-open-destination {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  margin: 0;
  padding-inline: 10px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--link) 12%, var(--surface));
  font-weight: 600;
  text-align: left;
}
.feed-open-destination .action-icon { width: 16px; height: 16px; flex: none; }

.collections-title { margin: 4px 0 14px; font-size: 23px; line-height: 1.15; }
.collections-filters {
  display: flex;
  gap: 7px;
  overflow-x: auto;
  scrollbar-width: none;
  margin: 0 -3px 17px;
  padding: 3px;
}
.collections-filters::-webkit-scrollbar { display: none; }
.collections-filters button {
  display: flex;
  align-items: center;
  gap: 5px;
  flex: none;
  min-height: 42px;
  padding: 0 12px;
  border: 0;
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  font-weight: 650;
  cursor: pointer;
}
.collections-filters button[aria-pressed="true"] { background: var(--input-surface); color: var(--link); }
.collection-group + .collection-group { margin-top: 21px; }
.collection-group-heading { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 42px; }
.collection-group-heading h3 { margin: 0; font-size: 17px; }
.collection-group-heading .text-action { font-size: 14px; }
.collection-index-row {
  display: grid;
  grid-template-columns: 50px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 68px;
  padding: 5px 0;
  border: 0;
  border-radius: 10px;
  color: var(--text);
  background: transparent;
  text-align: left;
  cursor: pointer;
}
.collection-index-row + .collection-index-row { border-radius: 0 0 10px 10px; }
.collection-thumb {
  display: grid;
  place-items: center;
  width: 50px;
  height: 50px;
  border-radius: 13px;
  background: color-mix(in srgb, var(--link) 16%, var(--surface));
  font-size: 26px;
}
.collection-group[data-category="local"] .collection-thumb { background: light-dark(#e3eefe, #233757); }
.collection-group[data-category="work"] .collection-thumb { background: light-dark(#e3f2e8, #214036); }
.collection-group[data-category="leisure"] .collection-thumb { background: light-dark(#f3e7ff, #352c52); }
.collection-group[data-category="sport"] .collection-thumb { background: light-dark(#ffebdb, #493329); }
.collection-thumb picture { width: 35px; height: 35px; }
.collection-row-copy { display: grid; align-content: center; min-height: 58px; padding-block: 5px; line-height: 1.24; }
.collection-index-row:not(:last-child) .collection-row-copy { border-bottom: 1px solid var(--border); }
.collection-row-copy strong, .collection-row-copy small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.collection-row-copy strong { font-size: 15px; }
.collection-row-copy span, .collection-row-copy small { color: var(--muted); font-size: 12px; }
.collection-open {
  padding: 5px 10px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--link) 11%, var(--surface));
  color: var(--link);
  font-size: 12px;
  font-weight: 650;
}
.collection-group { animation: collection-arrive .22s ease-out both; }
@keyframes collection-arrive { from { opacity: 0; transform: translateY(7px); } }

.app-shell[data-view] .view:not(.hidden) { animation: enter-app-view .23s cubic-bezier(.2,.7,.25,1) both; }
.app-shell[data-direction="back"] .view:not(.hidden) { --view-offset: -13px; }
@keyframes enter-app-view {
  from { opacity: 0; transform: translateX(var(--view-offset, 13px)); }
  to { opacity: 1; transform: translateX(0); }
}
.nav-item, .feed-card-open, .feed-edit, .selectable-source,
.primary-button, .new-feed-card, .header-add-button, .outline-button, .feed-icon-option {
  transition: background-color .15s ease, opacity .15s ease, transform .15s ease;
}
.feed-card-open:active, .feed-edit:active {
  background: color-mix(in srgb, var(--link) 10%, var(--surface));
}
.primary-button:active:not(:disabled), .new-feed-card:active, .header-add-button:active:not(:disabled) {
  transform: scale(.985);
}
button:not(:disabled), a.primary-button, .settings-icons summary {
  -webkit-tap-highlight-color: transparent;
  transition: background-color .16s ease, color .16s ease, opacity .16s ease, transform .16s ease;
}
button:not(:disabled):active, a.primary-button:active, .settings-icons summary:active { transform: scale(.97); }
@media (prefers-reduced-motion: reduce) {
  .create-feed-screen[open] .create-feed-content,
  .create-feed-screen[open] #create-feed-choice:not(.hidden),
  .create-feed-screen[open] #connect-feed-step:not(.hidden),
  .add-dialog[open] .dialog-card,
  .app-shell[data-view] .view:not(.hidden), .app-shell[data-view="feeds"] .feeds-hero-art,
  .collection-group { animation: none; }
  .destination-option, .destination-icon, .digest-toggle input, .digest-toggle input::before, .toast { transition: none; }
  .nav-item, .feed-card-open, .feed-edit, .selectable-source, .digest-fields,
  .primary-button, .new-feed-card, .header-add-button, .outline-button, .feed-icon-option { transition: none; }
  .destination-option:active .destination-icon, .primary-button:active:not(:disabled), .new-feed-card:active,
  .header-add-button:active:not(:disabled), .feed-icon-option:active { transform: none; }
  button:not(:disabled), a.primary-button, .settings-icons summary { transition: none; }
  button:not(:disabled):active, a.primary-button:active, .settings-icons summary:active { transform: none; }
}
