*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #f5f5f5;
  --surface: #ffffff;
  --border: #d1d5db;
  --text: #111827;
  --muted: #6b7280;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --danger: #dc2626;
  --success-bg: #d1fae5;
  --success-text: #065f46;
  --error-bg: #fee2e2;
  --error-text: #991b1b;
  --info-bg: #dbeafe;
  --info-text: #1e40af;
  --radius: 6px;
  --max-w: 640px;
  --sidebar-w: 14rem; /* scales with font size: 224px default, 280px large, 336px larger */
}

/* Font size preference — set on <html> so rem values throughout scale */
html.font-large  { font-size: 20px; }
html.font-larger { font-size: 24px; }

/* Dark mode — override every CSS variable */
html.dark {
  --bg: #111827;
  --surface: #1f2937;
  --border: #374151;
  --text: #f9fafb;
  --muted: #9ca3af;
  --accent: #60a5fa;
  --accent-hover: #3b82f6;
  --danger: #f87171;
  --success-bg: #064e3b;
  --success-text: #6ee7b7;
  --error-bg: #7f1d1d;
  --error-text: #fca5a5;
  --info-bg: #1e3a5f;
  --info-text: #93c5fd;
}

/* Fix hardcoded colours that don't use variables */
html.dark .danger-zone           { border-color: #7f1d1d; background: #1f1414; }
html.dark .user-table tbody tr:hover { background: #374151; }
html.dark .pill-active           { background: #064e3b; color: #6ee7b7; }
html.dark .pill-locked           { background: #7f1d1d; color: #fca5a5; }
html.dark .pill-admin            { background: #1e3a5f; color: #93c5fd; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 1rem;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
}

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

/* Header */
header {
  position: sticky;
  top: 0;
  z-index: 200;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 1.5rem;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.header-left, .header-right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.header-left { flex-shrink: 0; min-width: 34px; }
.header-right { flex-shrink: 0; }

.site-title {
  flex: 1;
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--accent);
  text-decoration: none;
  text-align: center;
}

.profile-thumbnail {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--bg);
  color: var(--muted);
  border: 1.5px solid var(--border);
  text-decoration: none;
  flex-shrink: 0;
  transition: border-color 0.15s, color 0.15s;
}

.profile-thumbnail:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* Shared styling for header toggle buttons */
.header-left .sidebar-toggle,
.header-right .nav-toggle {
  display: inline-flex;
  align-items: center;
  background: none;
  border: none;
  font-size: 1rem;
  cursor: pointer;
  color: var(--text);
  padding: 0 0.4rem;
}

/* Panel icon flips to indicate collapsed state */
.panel-icon { transition: transform 0.15s; }
html.sidebar-hidden .panel-icon { transform: scaleX(-1); }

/* Optional sticky sub-header row (populated per-page via Jinja block) */
.header-sub {
  position: sticky;
  top: 52px;
  z-index: 190;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 1.5rem;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.85rem;
}
.header-sub a { color: var(--text); text-decoration: none; }
.header-sub a:hover { text-decoration: underline; }
/* Left: feed name + nav tabs */
.hs-left { flex: 1; display: flex; align-items: center; gap: 0.75rem; min-width: 0; }
.hs-feed-name { font-size: 1.05rem; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; border-right: 1px solid var(--border); padding-right: 0.75rem; margin-right: 0.25rem; }
.hs-tab { font-weight: 400; color: var(--muted); padding: 0 0.1rem; border-bottom: 2px solid transparent; line-height: 36px; }
.hs-tab:hover { color: var(--text); text-decoration: none; }
.hs-tab-active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 500; }
.tab-count { font-size: 0.75em; font-weight: 600; border-radius: 8px; padding: 0 5px; margin-left: 3px; vertical-align: middle; background: #e5e7eb; color: #6b7280; }
html.dark .tab-count { background: #374151; color: #9ca3af; }
.hs-tab-active .tab-count { background: #dbeafe; color: #2563eb; }
html.dark .hs-tab-active .tab-count { background: #1e3a5f; color: #60a5fa; }
/* Center: bulk action buttons */
.hs-center { flex: 0 0 auto; display: flex; align-items: center; gap: 0.5rem; }
/* Right: external links */
.hs-right { flex: 1; display: flex; align-items: center; justify-content: flex-end; gap: 0.75rem; }
.hs-ext { font-weight: 400; font-size: 0.8rem; color: var(--muted); }
.hs-ext:hover { color: var(--text); }
.hs-search { display: flex; align-items: center; }
.search-input { padding: 0.15rem 0.45rem; font-size: 0.8rem; border: 1px solid var(--border);
                border-radius: 4px; background: var(--bg); color: var(--text); width: 140px; }
mark { background: #ffe066; color: #222; border-radius: 2px; padding: 0 1px; }
.search-results-info { font-size: 0.9rem; color: var(--muted); margin-bottom: 1rem; }
.search-clear { font-size: 0.85rem; }

/* Mobile-responsive header-sub layout */
@media (max-width: 700px) {
  .header-sub {
    height: auto;
    flex-wrap: wrap;
    padding: 0.5rem 1.5rem;
    gap: 0.5rem;
  }

  /* Row 1: Navigation and feed name */
  .hs-left {
    flex: 1 1 100%;
    order: 1;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
  }

  .hs-feed-name {
    flex: 1 1 auto;
    min-height: 2.75rem;
    display: flex;
    align-items: center;
    border-right: none;
    border-bottom: none;
    padding-right: 0;
    margin-right: 0;
  }

  .hs-tab {
    min-height: 2.75rem;
    line-height: 2.75rem;
    padding: 0 0.5rem;
    font-size: 0.8rem;
  }

  /* Row 2: Action buttons and search split 50/50 */
  .hs-center {
    flex: 1 1 100%;
    order: 2;
    display: flex;
    gap: 0.25rem;
    align-items: stretch;
  }

  .hs-center button.btn-sm,
  .hs-center .hs-search,
  .hs-center .search-input {
    flex: 1;
    min-width: 0;
    height: 2.5rem;
    padding: 0.3rem 0.3rem;
    font-size: 0.7rem;
    line-height: 2.5rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--bg);
    color: var(--text);
    box-sizing: border-box;
  }

  .hs-center button.btn-sm {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    cursor: pointer;
    font-weight: 500;
  }

  /* Move search into hs-center on mobile */
  .hs-search {
    display: flex;
    align-items: stretch;
  }

  .search-input {
    border: none;
    outline: none;
  }

  /* Row 3: External links */
  .hs-right {
    flex: 1 1 100%;
    order: 3;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 0.5rem;
  }

  .hs-ext {
    font-size: 0.75rem;
    min-height: 2.75rem;
    display: inline-flex;
    align-items: center;
  }
}

/* Ultra-small phones: hide tabs */
@media (max-width: 480px) {
  .hs-left {
    gap: 0.35rem;
  }

  .hs-tab {
    display: none;
  }

  .tab-count {
    display: none;
  }

  .hs-feed-name {
    font-size: 0.95rem;
  }

  .sidebar-toggle {
    padding: 0.35rem 0.3rem;
    font-size: 0.9rem;
  }

  .search-input {
    font-size: 0.7rem;
  }

  .hs-ext {
    font-size: 0.7rem;
  }
}

/* Admin nav toggle button */
.nav-toggle {
  background: none;
  border: none;
  font-size: 1.5rem;
  line-height: 1;
  color: var(--accent);
  cursor: pointer;
  padding: 0.2rem 0.3rem;
  margin: 0;
}

/* Admin nav: always a dropdown, right-aligned */
#main-nav {
  display: none;
  position: absolute;
  top: 52px;
  right: 0;
  left: auto;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  border-left: 1px solid var(--border);
  padding: 0.75rem 1.5rem;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.9rem;
  z-index: 199;
  box-shadow: 0 4px 8px rgba(0,0,0,0.08);
  min-width: 140px;
}

#main-nav.nav-open { display: flex; }

/* On mobile, nav spans full width */
@media (max-width: 600px) {
  #main-nav { left: 0; border-left: none; }
}

nav a {
  color: var(--accent);
  text-decoration: none;
  font-size: 0.9rem;
}

nav a:hover { text-decoration: underline; }


.nav-profile { display: inline-flex; align-items: center; gap: 0.35rem; }
.nav-profile-icon { opacity: 0.6; flex-shrink: 0; }

.nav-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.1rem;
  height: 1.1rem;
  padding: 0 0.25rem;
  border-radius: 999px;
  background: var(--danger);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  line-height: 1;
  vertical-align: middle;
  margin-left: 0.2rem;
}

/* Main */
main {
  max-width: var(--max-w);
  margin: 2rem auto;
  padding: 0 1rem;
}

/* Flash messages */
.flash-messages {
  list-style: none;
  margin-bottom: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.flash {
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  font-size: 0.9rem;
}

.flash-success { background: var(--success-bg); color: var(--success-text); }
.flash-error   { background: var(--error-bg);   color: var(--error-text); }
.flash-info    { background: var(--info-bg);     color: var(--info-text); }

/* Card (login / register) */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
}

.card h1 {
  font-size: 1.4rem;
  margin-bottom: 1.5rem;
}

/* Forms */
form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

label {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text);
}

.hint {
  font-weight: 400;
  color: var(--muted);
  font-size: 0.8rem;
}

textarea {
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 1rem;
  color: var(--text);
  background: var(--surface);
  font-family: inherit;
  resize: vertical;
  transition: border-color 0.15s;
}

textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.15);
}

input[type="email"],
input[type="password"],
input[type="text"] {
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 1rem;
  color: var(--text);
  background: var(--surface);
  transition: border-color 0.15s;
}

input[type="email"]:focus,
input[type="password"]:focus,
input[type="text"]:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.15);
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.95rem;
  font-weight: 400;
  cursor: pointer;
}

.radio-group {
  display: flex;
  gap: 1.5rem;
  flex-wrap: wrap;
  margin-top: 0.25rem;
}

button[type="submit"],
.btn-save {
  margin-top: 0.5rem;
  padding: 0.6rem 1.25rem;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s;
  align-self: flex-start;
}

button[type="submit"]:hover,
.btn-save:hover { background: var(--accent-hover); }

.form-footer {
  margin-top: 1.25rem;
  font-size: 0.9rem;
  color: var(--muted);
  text-align: center;
}

.form-footer a { color: var(--accent); }


.feed-url-row {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.feed-url-input {
  flex: 1;
  font-family: monospace;
  font-size: 0.85rem;
  background: var(--bg);
  color: var(--text);
}

.btn-copy {
  padding: 0.5rem 0.875rem;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s;
}

.btn-copy:hover { background: var(--accent-hover); }

.select-all-row {
  display: flex;
  gap: 0.5rem;
  padding-bottom: 0.75rem;
  margin-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
}

.btn-select-all {
  padding: 0.25rem 0.75rem;
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  margin-top: 0;
}
.btn-select-all:hover { background: var(--info-bg); }

.channel-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem;
  margin-bottom: 1.25rem;
}

@media (max-width: 480px) {
  .channel-list { grid-template-columns: 1fr; }
}

.channel-row {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  padding: 0.35rem 0;
  border-bottom: 1px solid var(--border);
}

.channel-row:last-child { border-bottom: none; }

.channel-row-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  width: 100%;
}

.channel-focus-row {
  width: 100%;
  padding-left: 1.4rem;
}

.focus-input {
  width: 100%;
  font-size: 0.82rem;
  padding: 0.2rem 0.4rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface, var(--bg));
  color: var(--text);
  box-sizing: border-box;
}

.channel-browse {
  font-size: 0.8rem;
  color: var(--accent);
  white-space: nowrap;
  flex-shrink: 0;
}
.channel-browse:hover { text-decoration: underline; }

.bundle-row {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--border);
}

.bundle-row:last-of-type { border-bottom: none; }

.bundle-name-input {
  font-size: 0.9rem;
  padding: 0.3rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface, var(--bg));
  color: var(--text);
  width: 100%;
  max-width: 24rem;
  box-sizing: border-box;
}

.bundle-channels-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1rem;
  padding-left: 0.25rem;
}

.bundle-ch-label {
  font-size: 0.85rem;
}

.bundle-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 0.75rem;
}

.muted { color: var(--muted); font-size: 0.9rem; }
.mono  { font-family: monospace; font-size: 0.875rem; }

/* ── Admin ───────────────────────────────────────────────────── */

.admin h1 { font-size: 1.4rem; margin-bottom: 1.5rem; display: flex; align-items: center; gap: 0.75rem; }

.admin-header { margin-bottom: 1.5rem; }
.admin-header h1 { margin-bottom: 0.25rem; }
.back-link { font-size: 0.875rem; color: var(--accent); text-decoration: none; display: inline-block; margin-bottom: 0.5rem; }
.back-link:hover { text-decoration: underline; }

.admin-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 1.25rem;
}

.add-user-details > summary {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--accent);
  cursor: pointer;
  list-style: none;
}
.add-user-details > summary::-webkit-details-marker { display: none; }
.add-user-details > summary::before { content: "+ "; }
.add-user-details[open] > summary::before { content: "− "; }

.admin-section h2 {
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 1rem;
}

.admin-section form { gap: 0.75rem; }

.form-row { display: flex; flex-direction: column; gap: 0.3rem; }

.inline-form { display: inline; }

.danger-zone { border-color: #fca5a5; background: #fff8f8; }

.onboarding-banner { border-color: var(--accent); background: var(--info-bg); color: var(--info-text); }
html.dark .onboarding-banner { background: var(--info-bg); color: var(--info-text); }

.alert-danger {
  background: #fff0f0;
  border: 1px solid var(--danger);
  border-radius: 6px;
  padding: 0.75rem 1rem;
  margin-bottom: 1.25rem;
  font-size: 0.9rem;
  color: var(--text);
}
html.dark .alert-danger { background: #2d1515; }

/* Badges / pills */
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--border);
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: 999px;
  padding: 0 0.5rem;
  min-width: 1.5rem;
  height: 1.5rem;
}

.pill {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  border-radius: 999px;
  padding: 0.1rem 0.55rem;
  text-transform: uppercase;
}
.pill-active { background: #d1fae5; color: #065f46; }
.pill-locked { background: #fee2e2; color: #991b1b; }
.pill-admin  { background: #dbeafe; color: #1e40af; }

/* User table */
.user-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}
.user-table th {
  text-align: left;
  padding: 0.5rem 0.75rem;
  border-bottom: 2px solid var(--border);
  font-weight: 600;
  color: var(--muted);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.user-table td {
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.user-table tbody tr:hover { background: #f9fafb; }
.row-locked td { opacity: 0.6; }

/* Small buttons */
.btn-sm {
  display: inline-block;
  padding: 0.25rem 0.625rem;
  font-size: 0.8rem;
  font-weight: 500;
  background: var(--accent);
  color: #fff;
  border-radius: var(--radius);
  text-decoration: none;
  white-space: nowrap;
}
.btn-sm:visited { color: #fff; }
.btn-sm:hover { background: var(--accent-hover); }
/* Allow <button> elements to use the small style without being overridden
   by the global button[type="submit"] rule */
button.btn-sm {
  margin-top: 0;
  padding: 0.25rem 0.625rem;
  font-size: 0.8rem;
  font-weight: 500;
  line-height: 1;
  transition: background 0.15s;
}

.btn-danger {
  padding: 0.6rem 1.25rem;
  background: var(--danger);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s;
}
.btn-danger:hover { background: #b91c1c; }
.btn-danger:disabled { opacity: 0.4; cursor: not-allowed; }

button.btn-danger-sm {
  padding: 0.25rem 0.625rem;
  background: transparent;
  color: var(--danger);
  border: 1px solid var(--danger);
  border-radius: var(--radius);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  margin-top: 0;
}
button.btn-danger-sm:hover { background: #fee2e2; }

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


.feed-header {
  margin-bottom: 1.75rem;
  padding-bottom: 1rem;
  border-bottom: 2px solid var(--border);
}

.feed-header h1 {
  font-size: 1.5rem;
  margin-bottom: 0.25rem;
}

.feed-meta {
  font-size: 0.875rem;
  color: var(--muted);
}

.feed-meta a { color: var(--accent); }

/* ---- Channel sidebar layout ---- */

/* When the feed layout is active, let main stretch to full viewport width
   so the sidebar sits at the far left and the feed area is unrestricted. */
main:has(.feed-layout) {
  max-width: none;
  padding-left: 0;
  padding-right: 0;
}

.feed-layout {
  display: flex;
  align-items: flex-start;
  padding: 0 1rem; /* restore the 1rem horizontal breathing room */
}

.feed-page {
  flex: 1;
  min-width: 0;
  max-width: 640px;
  margin-left: 2rem; /* space between sidebar and content */
}

.channel-sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  position: sticky;
  top: 88px; /* 52px header + 36px sub-header */
  max-height: calc(100vh - 96px);
  overflow-y: auto;
  padding: 0.5rem 0;
}

.sidebar-channel {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.35rem 0.6rem;
  border-radius: 4px;
  font-size: 0.85rem;
  color: var(--text);
  text-decoration: none;
  gap: 0.4rem;
}

.sidebar-channel:visited { color: var(--text); }
.sidebar-channel:hover { background: var(--border); }

.sc-active {
  background: var(--border);
  font-weight: 600;
}

.sc-all {
  font-weight: 700;
  border-bottom: 1px solid var(--border);
  margin-bottom: 0.35rem;
  padding-bottom: 0.35rem;
}

.sc-bundles {
  border-bottom: 1px solid var(--border);
  margin-bottom: 0.35rem;
  padding-bottom: 0.35rem;
}

.sc-bundle .sc-name {
  font-style: italic;
}

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

.sc-count {
  font-size: 0.75rem;
  background: var(--accent);
  color: #fff;
  border-radius: 10px;
  padding: 0.05rem 0.4rem;
  flex-shrink: 0;
}

/* Sidebar drag-resize handle */
.sidebar-resize {
  width: 16px;
  flex-shrink: 0;
  cursor: col-resize;
  position: relative;
  touch-action: none;
  user-select: none;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(90deg, transparent 40%, var(--border) 45%, var(--border) 55%, transparent 60%);
  background-repeat: repeat-y;
  background-size: 100% 4px;
  transition: background-color 0.15s;
}
.sidebar-resize:hover {
  background: linear-gradient(90deg, transparent 35%, var(--accent) 40%, var(--accent) 60%, transparent 65%);
}
.sidebar-resize.is-dragging {
  background: linear-gradient(90deg, transparent 30%, var(--accent) 35%, var(--accent) 65%, transparent 70%);
}

/* Persistent sidebar: hidden state (desktop only — mobile uses overlay) */
@media (min-width: 701px) {
  html.sidebar-hidden .channel-sidebar { display: none; }
  html.sidebar-hidden .sidebar-resize   { display: none; }
  html.sidebar-hidden .feed-page { margin-left: 0; }
}

@media (max-width: 700px) {
  .sidebar-resize { display: none; }
  .feed-layout { display: block; padding: 0 1rem; }

  .feed-page { margin-left: 0; }

  .channel-sidebar {
    display: none;
    position: fixed;
    left: 0;
    top: 52px;
    width: 100%;
    max-width: 320px;
    max-height: calc(100vh - 52px);
    background: var(--surface);
    border-right: 1px solid var(--border);
    padding: 0.5rem 0;
    overflow-y: auto;
    z-index: 195;
    box-shadow: 2px 0 8px rgba(0,0,0,0.12);
  }

  .channel-sidebar.sidebar-open { display: block; }

  /* No extra sidebar-toggle rules needed on mobile — global rule handles it */

  /* Backdrop for sidebar popover */
  body.sidebar-backdrop::before {
    content: '';
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.3);
    z-index: 194;
  }
}
/* ---- End channel sidebar ---- */

.story {
  padding: 1.5rem 0;
  border-bottom: 1px solid var(--border);
}

.story:last-child { border-bottom: none; }

.story h2 {
  font-size: 1.15rem;
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.story-dateline {
  font-style: italic;
  color: var(--muted);
  font-size: 0.9rem;
  margin-bottom: 0.25rem;
}

.story-published {
  font-style: italic;
  color: var(--muted);
  font-size: 0.9rem;
  margin-bottom: 0.25rem;
}

.story-source {
  font-style: italic;
  color: var(--muted);
  font-size: 0.9rem;
  margin-bottom: 0.2rem;
}

.story-links {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: nowrap;
  overflow-x: auto;
  margin-bottom: 0.75rem;
}

.story-links-sep {
  color: var(--muted);
  font-size: 0.8rem;
}

.story-body p {
  margin: 0.4rem 0;
  line-height: 1.65;
}

.story-watch,
.story-transcript {
  font-size: 0.85rem;
  color: var(--danger);
  text-decoration: none;
  white-space: nowrap;
}

.story-watch:hover,
.story-transcript:hover { text-decoration: underline; }

.story-toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 0.75rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--border);
}

.story-toolbar button,
.story-toolbar a {
  font-size: 0.78rem;
  padding: 0.2rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg);
  color: var(--muted);
  cursor: pointer;
  text-decoration: none;
  line-height: 1.4;
  white-space: nowrap;
  flex-shrink: 0;
  appearance: none;
  -webkit-appearance: none;
  touch-action: manipulation; /* prevent iOS double-tap zoom on buttons */
  /* margins instead of gap — gap in flex wasn't supported before iOS Safari 14.5 */
  margin: 0.2rem 0.4rem 0 0;
}

.story-toolbar button:disabled {
  opacity: 0.5;
  cursor: default;
  pointer-events: none;
}

.story-toolbar button:hover,
.story-toolbar a:hover {
  color: var(--bg);
  background: var(--text);
  border-color: var(--text);
}

.tb-delete { color: #dc2626; border-color: #fca5a5; }
.tb-delete:hover { color: #fff !important; background: #dc2626 !important; border-color: #dc2626 !important; }

.tb-unstar { color: var(--accent); border-color: var(--accent); }
.tb-unstar:hover { color: #fff !important; background: var(--accent) !important; border-color: var(--accent) !important; }

/* On narrow/touch viewports meet the 44 pt iOS tap-target guideline and
   ensure the buttons are visible even after JS hides the redundant ones. */
@media (max-width: 700px) {
  .story-toolbar {
    padding-top: 0.75rem;
    margin-top: 0.75rem;
  }
  .story-toolbar button,
  .story-toolbar a {
    font-size: 0.85rem;
    padding: 0.5rem 0.75rem;
    min-height: 2.75rem; /* ~44 pt at 16 px base */
    display: inline-flex;
    align-items: center;
    margin: 0.35rem 0.5rem 0 0;
  }
}

.feed-empty {
  color: var(--muted);
  margin-top: 2rem;
  font-size: 0.95rem;
}

/* ── Story comments ──────────────────────────────────────────── */

.story-comments {
  border-top: 1px solid var(--border);
  padding: 0.75rem 0 0.25rem;
  margin-top: 0.25rem;
}

.sc-comment {
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
}

.sc-comment:last-of-type { border-bottom: none; }

.sc-comment-meta {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.2rem;
  flex-wrap: wrap;
}

.sc-author { font-weight: 600; font-size: 0.85rem; }
.sc-time   { font-size: 0.78rem; color: var(--muted); }
.sc-you    { font-weight: 400; color: var(--muted); }

.sc-body {
  margin: 0;
  font-size: 0.9rem;
  white-space: pre-wrap;
  word-break: break-word;
}

.sc-empty { color: var(--muted); font-size: 0.88rem; margin: 0.25rem 0 0.5rem; }

.sc-delete, .sc-edit {
  font-size: 0.75rem;
  padding: 0.1rem 0.4rem;
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
}
.sc-delete { margin-left: auto; }
.sc-edit   { margin-left: auto; margin-right: 0.25rem; }
.sc-delete:hover { color: var(--bg); background: var(--danger, #c00); border-color: var(--danger, #c00); }
.sc-edit:hover   { color: var(--bg); background: var(--accent);       border-color: var(--accent); }

.sc-edit-input { display: block; width: 100%; margin-top: 0.25rem; }
.sc-save   { margin-top: 0.4rem; margin-right: 0.4rem; }
.sc-cancel { margin-top: 0.4rem; }

.sc-form {
  display: flex;
  gap: 0.5rem;
  align-items: flex-start;
  margin-top: 0.75rem;
}

.sc-input {
  flex: 1;
  font-size: 0.88rem;
  padding: 0.35rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface, var(--bg));
  color: var(--text);
  resize: vertical;
  font-family: inherit;
  min-height: 2.5rem;
}

.sc-submit {
  font-size: 0.82rem;
  padding: 0.35rem 0.75rem;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  white-space: nowrap;
  align-self: flex-end;
}
.sc-submit:hover { background: var(--accent-hover, var(--accent)); filter: brightness(1.1); }
.sc-submit:disabled { opacity: 0.6; cursor: default; }
