/* ---------------------------------------------------------------------
   Design tokens.
   Palette stays neutral (near-black surfaces, three grey steps, one red
   accent reserved for active/brand moments) so nothing competes with the
   thumbnails, which are the actual content on every page.
--------------------------------------------------------------------- */
:root {
  --bg-0: #0f0f0f;      /* page background */
  --bg-1: #181818;      /* raised surfaces: cards, player chrome */
  --bg-2: #212121;      /* inputs, hover states */
  --bg-3: #2a2a2a;      /* pressed / stronger hover */
  --border: #303030;
  --border-soft: #262626;

  --text-primary: #f1f1f1;
  --text-secondary: #aaaaaa;
  --text-tertiary: #717171;

  --accent: #ff3b30;        /* used only for brand / active / destructive-adjacent moments */
  --accent-hover: #ff5147;
  --accent-wash: rgba(255, 59, 48, 0.12);

  --focus-ring: #4b9eff;

  --radius-s: 6px;
  --radius-m: 10px;
  --radius-l: 14px;
  --radius-round: 999px;

  --nav-h: 56px;
  --sidebar-w: 240px;
  --sidebar-w-collapsed: 72px;

  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;

  --ease: cubic-bezier(0.4, 0, 0.2, 1);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg-0);
  color: var(--text-primary);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
}

body {
  min-height: 100vh;
}

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

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

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

button {
  cursor: pointer;
  background: none;
  border: none;
}

button:disabled { cursor: default; opacity: 0.5; }

:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

::selection { background: var(--accent-wash); }

/* Scrollbar - unobtrusive, dark-mode native */
* { scrollbar-color: #3a3a3a transparent; scrollbar-width: thin; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: #3a3a3a; border-radius: 999px; border: 2px solid var(--bg-0); }
*::-webkit-scrollbar-track { background: transparent; }

.icon {
  width: 24px;
  height: 24px;
  flex-shrink: 0;
  fill: currentColor;
}
.icon-sm { width: 18px; height: 18px; }

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

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 16px;
  border-radius: var(--radius-round);
  font-size: 14px;
  font-weight: 500;
  background: var(--bg-2);
  color: var(--text-primary);
  transition: background 0.15s var(--ease);
  white-space: nowrap;
}
.btn:hover { background: var(--bg-3); }

.btn-primary {
  background: var(--text-primary);
  color: #0f0f0f;
}
.btn-primary:hover { background: #d9d9d9; }

.btn-accent {
  background: var(--accent);
  color: #fff;
}
.btn-accent:hover { background: var(--accent-hover); }

.btn-ghost {
  background: transparent;
}
.btn-ghost:hover { background: var(--bg-2); }

.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: transparent;
}
.btn-icon:hover { background: var(--bg-2); }

.input, textarea.input {
  width: 100%;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-m);
  padding: 11px 14px;
  font-size: 14px;
  color: var(--text-primary);
  transition: border-color 0.15s var(--ease);
}
.input:focus, textarea.input:focus {
  border-color: var(--text-secondary);
  outline: none;
}
.input::placeholder, textarea.input::placeholder { color: var(--text-tertiary); }

.avatar {
  border-radius: 50%;
  object-fit: cover;
  background: var(--bg-3);
  flex-shrink: 0;
}

/* Red ring around a channel's avatar while they're live - the one visual
   cue used site-wide (nav, channel page, video cards, comments) since
   streams themselves are deliberately never mixed into normal feeds/grids
   (see the "Live" sidebar tab in shell.js and public/streams.html). */
.avatar-live {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

.pill {
  display: inline-flex;
  align-items: center;
  padding: 4px 12px;
  border-radius: var(--radius-round);
  font-size: 13px;
  background: var(--bg-2);
  color: var(--text-secondary);
}

.skeleton {
  background: linear-gradient(100deg, var(--bg-1) 30%, var(--bg-2) 50%, var(--bg-1) 70%);
  background-size: 200% 100%;
  animation: shimmer 1.4s var(--ease) infinite;
}
@keyframes shimmer {
  0% { background-position: 150% 0; }
  100% { background-position: -50% 0; }
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 64px 24px;
  color: var(--text-secondary);
  text-align: center;
}
.empty-state .icon { width: 40px; height: 40px; color: var(--text-tertiary); }

.toast-stack {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 1000;
}
.toast {
  background: #2a2a2a;
  border: 1px solid var(--border);
  color: var(--text-primary);
  padding: 12px 18px;
  border-radius: var(--radius-m);
  font-size: 14px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  animation: toast-in 0.2s var(--ease);
}
.toast.error { border-color: rgba(255,59,48,0.4); }
@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---- Toggle switch (settings on/off rows) ----
   Used by the admin panel and by the per-user notification settings
   (channel.js), so it lives here rather than in a page-specific stylesheet. */
.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 0;
  border-bottom: 1px solid var(--border-soft);
}
.toggle-row:last-child { border-bottom: none; }
.toggle-row-label { font-size: 14px; font-weight: 500; }
.toggle-row-desc { font-size: 12px; color: var(--text-secondary); margin-top: 2px; max-width: 480px; }
.toggle-switch {
  position: relative;
  width: 44px;
  height: 26px;
  flex-shrink: 0;
  border-radius: var(--radius-round);
  background: var(--bg-3);
  transition: background 0.15s var(--ease);
}
.toggle-switch::after {
  content: '';
  position: absolute;
  top: 3px; left: 3px;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.15s var(--ease);
}
.toggle-switch.on { background: var(--accent); }
.toggle-switch.on::after { transform: translateX(18px); }

@media (max-width: 900px) {
  :root { --sidebar-w: 0px; }
}

/* iOS Safari auto-zooms the whole page when focusing any text input whose
   font-size is under 16px - jarring on a page that otherwise never zooms.
   Every text input on the site (search, forms, comments, ...) uses .input
   or .search-form input, so this one rule fixes it everywhere at once.
   !important because this file loads before layout.css/watch.css, which
   set their own (smaller, desktop-oriented) font-sizes on the same
   selectors at equal specificity - without it, later stylesheets would
   silently win the mobile query back off. */
@media (max-width: 900px) {
  .input, textarea.input, .search-form input, .comment-input {
    font-size: 16px !important;
  }
}


/* =====================================================================
   Rich Text: Links, @-Erwähnungen, Video-Previews, Autovervollständigung
   (siehe public/js/rich.js)
   ===================================================================== */
:root { --link: #3ea6ff; }
.rich-link, .mention { color: var(--link); text-decoration: none; word-break: break-word; }
.rich-link:hover, .mention:hover { text-decoration: underline; }
/* In Titeln/Karten ist die Erwähnung ein <span> (kein Link in einem Link) */
span.mention { cursor: inherit; }

.link-previews { display: flex; flex-direction: column; gap: 8px; margin: 8px 0 4px; max-width: 420px; }
.link-preview {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 8px; border: 1px solid var(--border-soft); border-radius: var(--radius-m);
  background: var(--bg-1); color: var(--text-primary);
}
.link-preview:hover { background: var(--bg-2); }
.link-preview-thumb { position: relative; width: 140px; flex-shrink: 0; aspect-ratio: 16 / 9; border-radius: 6px; overflow: hidden; background: var(--bg-2); }
.link-preview-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.link-preview-meta { min-width: 0; flex: 1; }
.link-preview-title {
  font-size: 14px; font-weight: 500; line-height: 1.3;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.link-preview-sub { font-size: 12px; color: var(--text-secondary); margin-top: 3px; }
@media (max-width: 480px) { .link-preview-thumb { width: 110px; } }

.mention-box {
  position: fixed; z-index: 2000; width: 280px; max-height: 300px; overflow-y: auto;
  background: var(--bg-1); border: 1px solid var(--border); border-radius: var(--radius-m);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5); padding: 4px;
}
.mention-item { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; cursor: pointer; }
.mention-item:hover, .mention-item.selected { background: var(--bg-3); }
.mention-item-text { min-width: 0; }
.mention-item-name { font-size: 14px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mention-item-handle { font-size: 12px; color: var(--text-secondary); }
