.app-nav {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--nav-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  background: var(--bg-0);
  border-bottom: 1px solid var(--border-soft);
  z-index: 100;
}

.nav-left { display: flex; align-items: center; gap: 6px; min-width: 0; flex-shrink: 0; }
.nav-brand {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px 8px 6px;
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}
.nav-brand .icon { width: 26px; height: 26px; color: var(--accent); }

.nav-center {
  flex: 1;
  min-width: 0; /* without this, a flex item won't shrink below its content's natural width - this is why the search bar was pushing the avatar/upload/bell icons off-screen on narrow viewports */
  max-width: 640px;
  margin: 0 32px;
}
.search-form {
  display: flex;
  align-items: stretch;
  height: 40px;
  min-width: 0;
}
.search-form input {
  flex: 1;
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-right: none;
  border-radius: var(--radius-round) 0 0 var(--radius-round);
  padding: 0 16px;
  font-size: 15px;
  min-width: 0;
}
.search-form input:focus { outline: none; border-color: var(--focus-ring); }
.search-form button {
  width: 64px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 0 var(--radius-round) var(--radius-round) 0;
  display: flex; align-items: center; justify-content: center;
}
.search-form button:hover { background: var(--bg-3); }

.nav-right { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.nav-avatar-btn { padding: 2px; border-radius: 50%; }
.nav-avatar-btn img { width: 32px; height: 32px; }

/* ---- Nav dropdowns (notifications, account menu) ---- */
.nav-dropdown { position: relative; }
.dropdown-panel {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  min-width: 280px;
  max-width: calc(100vw - 24px);
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-m);
  box-shadow: 0 12px 32px rgba(0,0,0,0.45);
  padding: 8px;
  opacity: 0;
  transform: translateY(-6px);
  pointer-events: none;
  transition: opacity 0.12s var(--ease), transform 0.12s var(--ease);
  z-index: 150;
}
.nav-dropdown.open .dropdown-panel { opacity: 1; transform: none; pointer-events: auto; }
.dropdown-header { font-size: 14px; font-weight: 600; padding: 8px 10px; }
.dropdown-empty {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  padding: 28px 16px; color: var(--text-secondary); font-size: 13px; text-align: center;
}
.dropdown-empty .icon { color: var(--text-tertiary); }
.dropdown-divider { height: 1px; background: var(--border-soft); margin: 6px 4px; }
.dropdown-item {
  display: flex; align-items: center; gap: 12px;
  width: 100%; text-align: left;
  padding: 10px 10px; border-radius: var(--radius-s);
  font-size: 14px; color: var(--text-primary);
}
.dropdown-item:hover { background: var(--bg-2); }
.dropdown-account-row { display: flex; align-items: center; gap: 12px; padding: 6px 10px 10px; }
.dropdown-account-row .avatar { width: 40px; height: 40px; }
.dropdown-account-name { font-size: 14px; font-weight: 600; }
.dropdown-account-handle { font-size: 12px; color: var(--text-secondary); }

/* ---- Notification bell + panel ---- */
.notif-btn { position: relative; }
.notif-badge {
  position: absolute;
  top: 4px; right: 4px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: var(--radius-round);
  background: var(--accent);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  line-height: 16px;
  text-align: center;
  box-shadow: 0 0 0 2px var(--bg-0);
}
.notif-panel { min-width: 340px; padding: 6px; }
.dropdown-header-row { display: flex; align-items: center; justify-content: space-between; padding: 2px 2px 2px 8px; }
.dropdown-header-row .dropdown-header { padding: 8px 0; }
.notif-list { max-height: 420px; overflow-y: auto; }
.notif-item {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 10px 8px; border-radius: var(--radius-s);
  position: relative;
}
.notif-item:hover { background: var(--bg-2); }
.notif-item .avatar { width: 36px; height: 36px; flex-shrink: 0; }
.notif-item-body { flex: 1; min-width: 0; }
.notif-item-text { font-size: 13px; line-height: 1.4; color: var(--text-primary); }
.notif-item-time { font-size: 12px; color: var(--text-secondary); margin-top: 3px; }
.notif-item-thumb { width: 56px; height: 32px; object-fit: cover; border-radius: var(--radius-s); flex-shrink: 0; }
.notif-item.unread { background: var(--accent-wash); }
.notif-item.unread:hover { background: var(--bg-2); }
.notif-item.unread::before {
  content: '';
  position: absolute;
  left: -2px; top: 50%;
  transform: translateY(-50%);
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--accent);
}
.notif-load-more { display: block; width: 100%; text-align: center; padding: 10px; font-size: 13px; font-weight: 600; color: var(--text-secondary); border-radius: var(--radius-s); }
.notif-load-more:hover { background: var(--bg-2); color: var(--text-primary); }
@media (max-width: 500px) {
  .notif-panel { min-width: min(92vw, 380px); }
}

.app-body {
  display: flex;
  padding-top: var(--nav-h);
  min-height: 100vh;
}

.app-sidebar {
  position: fixed;
  top: var(--nav-h);
  left: 0;
  bottom: 0;
  width: var(--sidebar-w);
  overflow-y: auto;
  padding: 12px 8px;
  transition: width 0.15s var(--ease);
}
.sidebar-section {
  padding: 8px 4px;
  border-bottom: 1px solid var(--border-soft);
  margin-bottom: 8px;
}
.sidebar-section:last-child { border-bottom: none; }
.sidebar-link {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 10px 12px;
  border-radius: var(--radius-m);
  font-size: 14px;
  color: var(--text-primary);
}
.sidebar-link:hover { background: var(--bg-1); }
.sidebar-link.active { background: var(--bg-2); font-weight: 600; }
.sidebar-link .icon { color: var(--text-primary); }
.sidebar-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.app-main {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-width: 0;
  padding: 24px 32px 64px;
  transition: margin-left 0.15s var(--ease);
}

/* Sidebar collapse: toggled by adding "sidebar-collapsed" to .app-body
   (see shell.js). Both the sidebar's width AND the main content's margin
   change together so collapsing never leaves an empty gap behind. */
.app-body.sidebar-collapsed .app-sidebar {
  width: 0;
  padding-left: 0;
  padding-right: 0;
  overflow: hidden;
}
.app-body.sidebar-collapsed .app-main {
  margin-left: 0;
}

@media (max-width: 900px) {
  .app-main { margin-left: 0; padding: 16px 16px 48px; }
  .nav-center { margin: 0 12px; }
  .nav-brand span { display: none; }

  /* On mobile the sidebar is a slide-in drawer instead of a fixed column -
     hidden off-canvas by default, toggled open by the same hamburger
     button, see shell.js. */
  .app-sidebar {
    background: var(--bg-0);
    width: 280px;
    max-width: 82vw;
    border-right: 1px solid var(--border-soft);
    transform: translateX(-100%);
    transition: transform 0.2s var(--ease);
    z-index: 200;
    padding-top: 16px;
  }
  .app-body.sidebar-collapsed .app-sidebar {
    width: 280px; /* override the desktop "collapse to 0" rule on mobile */
    padding-left: 8px;
    padding-right: 8px;
    overflow-y: auto;
  }
  .app-body.sidebar-mobile-open .app-sidebar {
    transform: translateX(0);
    box-shadow: 12px 0 32px rgba(0,0,0,0.5);
  }
  .sidebar-link { padding: 13px 14px; font-size: 15px; } /* roomier tap targets */

  .sidebar-backdrop {
    display: none;
    position: fixed;
    inset: var(--nav-h) 0 0 0;
    background: rgba(0,0,0,0.55);
    z-index: 190;
  }
  .app-body.sidebar-mobile-open .sidebar-backdrop { display: block; }
}

/* Prevents the page behind the open mobile drawer from scrolling too. */
body.no-scroll { overflow: hidden; }

.page-title {
  font-size: 20px;
  font-weight: 600;
  margin: 0 0 20px;
}

/* Video grid (home / search / channel) */
.video-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 24px 16px;
}

.video-card { display: flex; flex-direction: column; gap: 10px; }
.video-card a { display: block; }
.thumb-wrap {
  position: relative;
  aspect-ratio: 16 / 9;
  border-radius: var(--radius-m);
  overflow: hidden;
  background: var(--bg-1);
}
.thumb-wrap img { width: 100%; height: 100%; object-fit: cover; }
.duration-badge {
  position: absolute;
  right: 6px;
  bottom: 6px;
  background: rgba(15,15,15,0.85);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 4px;
}
.video-card-meta { display: flex; gap: 10px; }
.video-card-meta .avatar { width: 36px; height: 36px; margin-top: 2px; }
.video-card-title {
  font-size: 15px;
  font-weight: 500;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.video-card-sub { font-size: 13px; color: var(--text-secondary); margin-top: 4px; }
.video-card-sub div + div { margin-top: 1px; }

.processing-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-secondary);
  background: rgba(15,15,15,0.85);
  padding: 4px 8px;
  border-radius: 4px;
  position: absolute;
  left: 6px;
  top: 6px;
}

.section-chips {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
  overflow-x: auto;
  padding-bottom: 4px;
}
.chip {
  flex-shrink: 0;
  padding: 7px 14px;
  border-radius: var(--radius-s);
  background: var(--bg-2);
  font-size: 14px;
  font-weight: 500;
}
.chip.active { background: var(--text-primary); color: #0f0f0f; }
.chip:hover:not(.active) { background: var(--bg-3); }

/* ---- Seitenweite Banner (Ankündigung, Lockdown, Team-Hinweise) ---- */
#site-banners { display: flex; flex-direction: column; }
.site-banner { display: flex; gap: 12px; align-items: center; justify-content: center; flex-wrap: wrap; padding: 9px 16px; font-size: 14px; text-align: center; border-bottom: 1px solid var(--border-soft); background: rgba(75,158,255,0.14); }
.site-banner.warning { background: rgba(255,204,0,0.16); }
.site-banner.danger { background: rgba(255,59,48,0.18); }
.site-banner a { text-decoration: underline; font-weight: 600; }
.site-banner .banner-close { font-size: 20px; line-height: 1; color: var(--text-secondary); padding: 0 6px; }
.site-banner .banner-close:hover { color: var(--text-primary); }
.impersonation-bar { position: fixed; left: 50%; bottom: 16px; transform: translateX(-50%); z-index: 3000; display: flex; gap: 14px; align-items: center; background: #c4161c; color: #fff; padding: 10px 16px; border-radius: 999px; box-shadow: 0 6px 24px rgba(0,0,0,.45); font-size: 14px; max-width: calc(100vw - 24px); }
.impersonation-bar .btn { padding: 6px 14px; background: #fff; color: #c4161c; }
.site-banner .banner-link { text-decoration: underline; font-weight: 600; color: inherit; }

/* ---- Dialoge (Melden, Einspruch, Admin) ----
   Bewusst hier in layout.css (von jeder Seite geladen) und nicht nur in pages.css:
   watch.html und index.html laden pages.css nicht, der Melden-Dialog öffnete dort
   unsichtbar am Seitenende. */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,0.6);
  display: flex; align-items: center; justify-content: center;
  z-index: 3500; padding: 20px;
}
.modal {
  background: var(--bg-1);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-l);
  width: 100%; max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 24px;
}
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.modal-title { font-size: 17px; font-weight: 600; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }
@media (max-width: 640px) {
  .modal-backdrop { padding: 0; align-items: flex-end; }
  .modal { max-width: 100%; max-height: 88vh; padding: 18px; border-radius: var(--radius-l) var(--radius-l) 0 0; }
}
.modal .field { margin-bottom: 0; }
.modal .field label { display: block; font-size: 13px; color: var(--text-secondary); margin-bottom: 6px; }
.modal select.input { appearance: auto; }
