/* Moin Feed Web-App. Keine Inline-Stile im HTML (CSP style-src 'self'). Marken-Farben wie in der Android-App (res/values/colors.xml). */
@font-face {
  font-family: "Bricolage";
  src: url("fonts/bricolage-extrabold.ttf") format("truetype");
  font-weight: 800;
  font-display: swap;
}

:root {
  --elbnacht: #0b1418;
  --flaeche: #14232a;
  --linie: #26404a;
  --moewe: #f4f1ea;
  --gedaempft: #9fb1b8;
  --backstein: #b84a30;
  --backstein-hell: #e0866c;
  --gefahr: #ff9d8f;
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
  --sar: env(safe-area-inset-right, 0px);
  --kopf: 52px;
  --leiste: 52px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  height: 100%;
  margin: 0;
  background: var(--elbnacht);
  color: var(--moewe);
  overscroll-behavior: none;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

body {
  position: fixed;
  inset: 0;
  font: 400 16px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, system-ui, sans-serif;
  touch-action: manipulation;
}

a { color: var(--moewe); text-underline-offset: 3px; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--backstein-hell); outline-offset: 2px; }

/* Rahmen: Kopf, Inhalt, Leiste. Seiten unter der durchscheinenden Statusleiste (black-translucent) bekommen den oberen Sicherheitsabstand. */
.app {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  padding-left: var(--sal);
  padding-right: var(--sar);
}

.topbar {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: calc(var(--kopf) + var(--sat));
  padding: var(--sat) 14px 0;
  background: var(--elbnacht);
}
.brand { display: flex; align-items: center; gap: 8px; color: var(--moewe); }
.brand-mark { width: 30px; height: 15px; color: var(--moewe); }
.brand-name { font: 800 19px/1 "Bricolage", -apple-system, system-ui, sans-serif; letter-spacing: 0.1px; white-space: nowrap; }

.seg { display: flex; background: var(--flaeche); border-radius: 12px; padding: 3px; }
.seg button {
  min-height: 36px;
  padding: 0 14px;
  white-space: nowrap;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--gedaempft);
  font-weight: 600;
}
.seg button[aria-selected="true"] { background: var(--moewe); color: var(--elbnacht); }

.pill { padding: 4px 10px; border-radius: 99px; background: var(--flaeche); color: var(--gedaempft); font-size: 13px; font-weight: 600; }

.view { flex: 1; min-height: 0; position: relative; outline: none; }

.tabbar {
  flex: none;
  display: flex;
  background: var(--elbnacht);
  border-top: 1px solid var(--linie);
  padding-bottom: var(--sab);
}
.tab {
  flex: 1;
  min-height: var(--leiste);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  color: var(--gedaempft);
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
}
.tab svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linejoin: round; stroke-linecap: round; }
.tab[aria-current="page"] { color: var(--moewe); }
.tab[aria-current="page"] svg { fill: currentColor; }

/* Feed */
.feed {
  height: 100%;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  scroll-snap-type: y mandatory;
  scrollbar-width: none;
  background: #000;
}
.feed::-webkit-scrollbar { display: none; }
.clip {
  position: relative;
  height: 100%;
  overflow: hidden;
  scroll-snap-align: start;
  scroll-snap-stop: always;
  background: #000;
  -webkit-user-select: none;
  user-select: none;
}
.clip video, .clip .poster {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  -webkit-touch-callout: none;
}
.clip-shade {
  position: absolute;
  inset: auto 0 0 0;
  height: 55%;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.72), rgba(0, 0, 0, 0));
  pointer-events: none;
}
.clip-info { position: absolute; left: 14px; right: 84px; bottom: 16px; display: grid; gap: 6px; text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6); }
.clip-author { display: flex; align-items: center; gap: 8px; font-weight: 700; }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--flaeche); object-fit: cover; flex: none; }
.avatar-fallback { display: inline-flex; align-items: center; justify-content: center; font-weight: 700; color: #fff; background: var(--backstein); }
.clip-caption { margin: 0; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.clip-tags { color: var(--backstein-hell); font-weight: 600; font-size: 14px; overflow-wrap: anywhere; }
.clip-rail { position: absolute; right: 10px; bottom: 16px; display: grid; gap: 14px; justify-items: center; }
.rail-btn {
  display: grid;
  justify-items: center;
  gap: 2px;
  min-width: 52px;
  min-height: 52px;
  padding: 6px 4px;
  border: 0;
  border-radius: 16px;
  background: rgba(0, 0, 0, 0.38);
  color: var(--moewe);
  font-size: 13px;
  font-weight: 700;
}
.rail-btn svg { width: 28px; height: 28px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linejoin: round; }
.rail-btn[aria-pressed="true"] svg { fill: var(--backstein-hell); stroke: var(--backstein-hell); }
.rail-stat { display: grid; justify-items: center; gap: 2px; min-width: 52px; padding: 4px; font-size: 13px; font-weight: 700; color: var(--moewe); text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6); }
.rail-stat svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linejoin: round; }
.sound {
  position: absolute;
  left: 14px;
  top: 12px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  padding: 0 12px;
  border: 0;
  border-radius: 99px;
  background: rgba(0, 0, 0, 0.45);
  color: var(--moewe);
  font-size: 14px;
  font-weight: 600;
}
.sound svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linejoin: round; stroke-linecap: round; }
.clip-tap { position: absolute; inset: 0 84px 0 0; background: transparent; border: 0; padding: 0; }
.feed-end { height: 100%; scroll-snap-align: start; display: grid; place-content: center; text-align: center; padding: 24px; color: var(--gedaempft); background: var(--elbnacht); }

/* Zustaende (laden, leer, Fehler, offline) */
.state { height: 100%; display: grid; place-content: center; justify-items: center; gap: 14px; padding: 24px; text-align: center; background: var(--elbnacht); }
.state h2 { margin: 0; font: 800 22px/1.2 "Bricolage", -apple-system, system-ui, sans-serif; }
.state p { margin: 0; max-width: 32ch; color: var(--gedaempft); }
.spinner { width: 34px; height: 34px; border-radius: 50%; border: 3px solid var(--linie); border-top-color: var(--moewe); animation: dreh 0.9s linear infinite; }
@keyframes dreh { to { transform: rotate(360deg); } }

/* Profil und Formulare */
.page { height: 100%; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; padding: 8px 16px 28px; }
.page-inner { max-width: 520px; margin: 0 auto; display: grid; gap: 16px; }
.page h1 { margin: 8px 0 0; font: 800 26px/1.15 "Bricolage", -apple-system, system-ui, sans-serif; overflow-wrap: anywhere; hyphens: manual; }
.page h2 { margin: 0; font-size: 17px; }
.page p { margin: 0; }
.muted { color: var(--gedaempft); }
.small { font-size: 14px; }
.card { background: var(--flaeche); border: 1px solid var(--linie); border-radius: 16px; padding: 16px; display: grid; gap: 12px; }
.me { display: flex; align-items: center; gap: 14px; }
.me .avatar { width: 64px; height: 64px; font-size: 26px; }
.counts { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; text-align: center; }
.counts b { display: block; font-size: 18px; }
.counts span { font-size: 12px; color: var(--gedaempft); }

form { display: grid; gap: 14px; }
.field { display: grid; gap: 6px; }
.field label { font-weight: 600; font-size: 15px; }
.field .hint { font-size: 13px; color: var(--gedaempft); }
/* 16 px und mehr: iOS zoomt beim Fokussieren sonst die ganze Seite heran. */
input, select, textarea {
  width: 100%;
  min-height: 48px;
  padding: 10px 14px;
  font-size: 16px;
  background: var(--elbnacht);
  color: var(--moewe);
  border: 1px solid var(--linie);
  border-radius: 12px;
  -webkit-appearance: none;
  appearance: none;
}
select {
  background-image: linear-gradient(45deg, transparent 50%, var(--gedaempft) 50%), linear-gradient(135deg, var(--gedaempft) 50%, transparent 50%);
  background-position: calc(100% - 20px) 21px, calc(100% - 15px) 21px;
  background-size: 5px 5px;
  background-repeat: no-repeat;
  padding-right: 36px;
}
input[type="checkbox"] { width: 24px; height: 24px; min-height: 24px; padding: 0; border-radius: 6px; flex: none; }
input[type="checkbox"]:checked { background: var(--backstein); border-color: var(--backstein); background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path d='M5 12.5l4.5 4.5L19 7.5' fill='none' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'/></svg>"); background-size: 18px; background-position: center; background-repeat: no-repeat; }
.check { display: flex; gap: 12px; align-items: flex-start; font-size: 15px; }
.error { color: var(--gefahr); font-weight: 600; font-size: 15px; }
.keybox { font: 600 18px/1.5 ui-monospace, "SF Mono", Menlo, Consolas, monospace; letter-spacing: 0.5px; padding: 14px; background: var(--elbnacht); border: 1px dashed var(--backstein-hell); border-radius: 12px; overflow-wrap: anywhere; user-select: all; -webkit-user-select: all; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 0 20px;
  border: 0;
  border-radius: 12px;
  background: var(--backstein);
  color: #fff;
  font-weight: 700;
  text-decoration: none;
}
.btn[disabled] { opacity: 0.55; cursor: default; }
.btn-ghost { background: transparent; color: var(--moewe); border: 1px solid var(--linie); }
.btn-danger { background: transparent; color: var(--gefahr); border: 1px solid var(--gefahr); }
.btn-small { min-height: 36px; padding: 0 14px; font-size: 14px; }
.btn-row { display: grid; gap: 10px; }
.links { display: grid; gap: 4px; padding: 0; margin: 0; list-style: none; }
.links a { display: flex; align-items: center; min-height: 44px; }

/* Hinweise */
.toast {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: calc(var(--leiste) + var(--sab) + 14px);
  z-index: 30;
  margin: 0 auto;
  max-width: 440px;
  padding: 12px 16px;
  border-radius: 12px;
  background: var(--moewe);
  color: var(--elbnacht);
  font-weight: 600;
  text-align: center;
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
}
.toast.show { opacity: 1; transform: none; }
.banner {
  position: fixed;
  left: 16px;
  right: 16px;
  top: calc(var(--kopf) + var(--sat) + 6px);
  z-index: 25;
  margin: 0 auto;
  max-width: 440px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 8px 8px 16px;
  border-radius: 12px;
  background: var(--flaeche);
  border: 1px solid var(--backstein-hell);
}
.sheet-backdrop { position: fixed; inset: 0; z-index: 40; background: rgba(0, 0, 0, 0.55); }
.sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 41;
  max-height: 85vh;
  max-height: 85dvh;
  overflow-y: auto;
  margin: 0 auto;
  max-width: 560px;
  padding: 20px 20px calc(20px + var(--sab));
  border-radius: 20px 20px 0 0;
  background: var(--flaeche);
  border-top: 1px solid var(--linie);
  display: grid;
  gap: 14px;
}
.sheet h2 { margin: 0; font: 800 21px/1.2 "Bricolage", -apple-system, system-ui, sans-serif; }
.sheet p { margin: 0; }
.steps { margin: 0; padding-left: 22px; display: grid; gap: 10px; }
.share-icon { display: inline-block; width: 20px; height: 20px; vertical-align: -4px; fill: none; stroke: var(--backstein-hell); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.noscript { padding: 24px; }

@media (min-width: 700px) {
  .feed { max-width: 460px; margin: 0 auto; }
}
@media (prefers-reduced-motion: reduce) {
  .spinner { animation-duration: 3s; }
  .toast { transition: none; }
}
@media (display-mode: standalone) {
  body { -webkit-user-select: none; user-select: none; }
  input, textarea { -webkit-user-select: text; user-select: text; }
  .keybox { -webkit-user-select: all; user-select: all; }
}

/* Feed-Huelle: Steuerelemente liegen ueber dem Scroll-Bereich und bleiben beim Wischen stehen. */
.feedwrap { position: relative; height: 100%; background: var(--elbnacht); }
.clip-info, .clip-shade { pointer-events: none; }
.scope {
  position: absolute;
  top: 12px;
  right: 14px;
  width: auto;
  max-width: 48%;
  min-height: 36px;
  padding: 0 34px 0 14px;
  border: 0;
  border-radius: 99px;
  background-color: rgba(0, 0, 0, 0.45);
  background-position: calc(100% - 18px) 15px, calc(100% - 13px) 15px;
  color: var(--moewe);
  font-size: 16px;
  font-weight: 600;
}
.banner-bottom { top: auto; bottom: calc(var(--leiste) + var(--sab) + 10px); }

details > summary { cursor: pointer; display: flex; align-items: center; min-height: 44px; font-weight: 700; list-style: none; }
details > summary::-webkit-details-marker { display: none; }
details[open] > summary { margin-bottom: 12px; }
details > summary.btn { font-weight: 700; }
.banner-actions { display: flex; gap: 8px; flex: none; }

details.card { display: block; }
details > summary.btn { justify-content: center; text-align: center; }
@media (max-width: 350px) {
  .brand-name { display: none; }
  .seg button { padding: 0 10px; }
}

/* Teilen-Links (#/v/<shareId>, #/@<name>), v0.8.0 */
.link-page { display: grid; gap: 12px; justify-items: start; }
.link-video { width: 100%; max-height: 70vh; aspect-ratio: 9 / 16; object-fit: contain; background: #000; border-radius: 14px; }
.avatar-big { width: 88px; height: 88px; font-size: 36px; }
.rail-btn[aria-disabled="true"] { opacity: 0.55; }
