/* =============================================================
   The Future In Our Hands — Design System
   Dark editorial. Kein Framework. Kein Overhead.
   ============================================================= */

:root {
  --bg:         #0f0f0f;
  --bg-2:       #181818;
  --bg-3:       #222;
  --border:     #2e2e2e;
  --border-2:   #3d3d3d;
  --text:       #e4e4e4;
  --muted:      #888;
  --faint:      #555;
  --accent:     #e63c3c;
  --accent-dim: #7a1f1f;
  --green:      #4caf6e;
  --red:        #e63c3c;
  --blue:       #4a9eff;
  --amber:      #f0a030;
  --radius:     6px;
  --font-sans:  system-ui, -apple-system, sans-serif;
  --font-mono:  'JetBrains Mono', 'Fira Code', monospace;
  --font-serif: Georgia, 'Times New Roman', serif;
}

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

html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

a { color: inherit; text-decoration: none; }
a:hover { color: var(--accent); }
button { cursor: pointer; border: none; background: none; font: inherit; color: inherit; }
input, textarea, select {
  font: inherit;
  color: var(--text);
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.6rem 0.8rem;
  width: 100%;
  transition: border-color 0.15s;
}
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--accent);
}
textarea { resize: vertical; min-height: 120px; }
img { max-width: 100%; }

/* =============================================================
   NAV
   ============================================================= */

.nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(15,15,15,0.95);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  padding: 0 1.5rem;
  height: 52px;
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.nav-brand {
  font-family: var(--font-serif);
  font-size: 1.1rem;
  font-weight: bold;
  color: var(--text);
  white-space: nowrap;
  flex-shrink: 0;
}
.nav-brand span { color: var(--accent); }

.nav-search {
  flex: 1;
  max-width: 360px;
}
.nav-search input {
  padding: 0.35rem 0.75rem;
  font-size: 0.875rem;
  background: var(--bg-3);
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  margin-left: auto;
}

.nav-link {
  padding: 0.4rem 0.75rem;
  border-radius: var(--radius);
  font-size: 0.875rem;
  color: var(--muted);
  transition: color 0.15s, background 0.15s;
}
.nav-link:hover { color: var(--text); background: var(--bg-3); }

.btn { display: inline-flex; align-items: center; gap: 0.4rem; padding: 0.45rem 1rem; border-radius: var(--radius); font-size: 0.875rem; font-weight: 500; transition: opacity 0.15s, background 0.15s; cursor: pointer; border: none; }
.btn-primary   { background: var(--accent); color: #fff; }
.btn-primary:hover { opacity: 0.85; color: #fff; }
.btn-ghost     { background: transparent; border: 1px solid var(--border-2); color: var(--muted); }
.btn-ghost:hover { border-color: var(--text); color: var(--text); }
.btn-sm { padding: 0.3rem 0.7rem; font-size: 0.8125rem; }

/* =============================================================
   LAYOUT
   ============================================================= */

.container { max-width: 1100px; margin: 0 auto; padding: 0 1.25rem; }
.page { padding: 1.75rem 0 4rem; }

.two-col {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 1.5rem;
  align-items: start;
}
@media (max-width: 768px) {
  .two-col {
    grid-template-columns: 1fr;
    /* Sidebar nach unten schieben */
  }
  .two-col > div:first-child { order: 1; }
  .sidebar {
    order: 2;
    display: block; /* Sichtbar auf Mobile */
    margin-top: 1rem;
  }
  /* Auf der Startseite Sidebar trotzdem ausblenden */
  .home-page .sidebar { display: none; }
}

/* =============================================================
   FLASH MESSAGES
   ============================================================= */

.flash { padding: 0.75rem 1.25rem; border-radius: var(--radius); margin-bottom: 1rem; font-size: 0.9rem; border-left: 3px solid; }
.flash-success { background: rgba(76,175,110,0.1); border-color: var(--green); color: var(--green); }
.flash-error   { background: rgba(230,60,60,0.1);  border-color: var(--red);   color: #ff6b6b; }
.flash-info    { background: rgba(74,158,255,0.1); border-color: var(--blue);  color: var(--blue); }

/* =============================================================
   HOME — Community Grid
   ============================================================= */

.page-hero {
  padding: 2.5rem 0 2rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 2rem;
}
.page-hero h1 {
  font-family: var(--font-serif);
  font-size: clamp(1.75rem, 4vw, 2.75rem);
  line-height: 1.2;
  margin-bottom: 0.5rem;
}
.page-hero h1 em { color: var(--accent); font-style: normal; }
.page-hero p { color: var(--muted); max-width: 520px; }

.sort-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
}
.sort-bar a {
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  font-size: 0.8125rem;
  color: var(--muted);
  border: 1px solid transparent;
}
.sort-bar a:hover { color: var(--text); }
.sort-bar a.active { border-color: var(--border-2); color: var(--text); background: var(--bg-3); }

.community-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
}

.community-card {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.25rem;
  transition: border-color 0.15s, transform 0.15s;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.community-card:hover { border-color: var(--border-2); transform: translateY(-1px); }

.community-card-header { display: flex; align-items: center; gap: 0.75rem; }
.community-icon {
  width: 40px; height: 40px;
  border-radius: 8px;
  background: var(--accent-dim);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem;
  font-weight: bold;
  color: var(--accent);
  flex-shrink: 0;
}
.community-card h3 { font-size: 1rem; font-weight: 600; }
.community-card h3 a:hover { color: var(--accent); }
.community-card .slug { font-family: var(--font-mono); font-size: 0.75rem; color: var(--faint); }
.community-card .desc { font-size: 0.875rem; color: var(--muted); line-height: 1.5; flex: 1; }
.community-card-footer {
  display: flex; align-items: center; justify-content: space-between;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
  font-size: 0.8rem;
}
.community-card-footer .meta { font-family: var(--font-mono); color: var(--faint); }
.badge-member { background: rgba(76,175,110,0.15); color: var(--green); padding: 0.2rem 0.6rem; border-radius: 999px; font-size: 0.75rem; }

/* =============================================================
   POSTS
   ============================================================= */

.post-list { display: flex; flex-direction: column; gap: 0; }

.post-item {
  display: grid;
  grid-template-columns: 52px 1fr;
  gap: 0;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 0.5rem;
  overflow: hidden;
  transition: border-color 0.15s;
}
.post-item:hover { border-color: var(--border-2); }

.vote-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0.75rem 0;
  gap: 0.2rem;
  background: var(--bg-3);
}
.vote-btn {
  width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 4px;
  color: var(--faint);
  font-size: 1rem;
  transition: color 0.1s, background 0.1s;
}
.vote-btn:hover { background: var(--border); color: var(--text); }
.vote-btn.up.active  { color: var(--green); }
.vote-btn.down.active { color: var(--red); }

.vote-score {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--muted);
  min-width: 2ch;
  text-align: center;
}

.post-body { padding: 0.75rem 1rem; display: flex; flex-direction: column; gap: 0.4rem; }
.post-meta { font-size: 0.75rem; color: var(--faint); font-family: var(--font-mono); }
.post-meta a:hover { color: var(--muted); }
.post-title { font-size: 1rem; font-weight: 600; line-height: 1.3; }
.post-title a:hover { color: var(--accent); }
.post-title .link-badge {
  display: inline-block;
  margin-left: 0.4rem;
  font-size: 0.7rem;
  font-family: var(--font-mono);
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 0 0.3rem;
  color: var(--faint);
  vertical-align: middle;
}
.post-footer { display: flex; align-items: center; gap: 1rem; font-size: 0.8rem; color: var(--faint); }
.post-footer a:hover { color: var(--muted); }

/* =============================================================
   POST DETAIL
   ============================================================= */

.post-detail {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  margin-bottom: 1.5rem;
}

.post-detail-vote {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 1.25rem 0;
}

.post-detail-content { padding: 0 1.25rem 1.25rem; }
.post-detail-content h1 {
  font-family: var(--font-serif);
  font-size: clamp(1.25rem, 3vw, 1.75rem);
  line-height: 1.3;
  margin: 0.75rem 0 0.5rem;
}
.post-detail-meta { font-size: 0.8rem; color: var(--faint); font-family: var(--font-mono); margin-bottom: 1rem; }
.post-detail-body { color: var(--muted); line-height: 1.75; font-size: 0.95rem; }
.post-detail-body a { color: var(--blue); }
.post-detail-footer {
  display: flex; align-items: center; gap: 1rem;
  padding: 0.75rem 1.25rem;
  border-top: 1px solid var(--border);
  font-size: 0.825rem;
  color: var(--faint);
}

/* =============================================================
   COMMENTS
   ============================================================= */

.comment-box { margin-bottom: 1.5rem; }
.comment-box textarea { min-height: 100px; }
.comment-box-actions { display: flex; justify-content: flex-end; margin-top: 0.5rem; }

.comments-section h2 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 1rem;
  font-family: var(--font-mono);
}

.comment-thread { display: flex; flex-direction: column; gap: 0; }

.comment {
  display: grid;
  grid-template-columns: 20px 1fr;
  gap: 0 0.75rem;
}
.comment + .comment { margin-top: 0.75rem; }

.comment-line {
  width: 2px;
  background: var(--border);
  border-radius: 1px;
  margin: 0 auto;
  cursor: pointer;
  transition: background 0.15s;
}
.comment-line:hover { background: var(--accent-dim); }

.comment-body {}
.comment-header { display: flex; align-items: center; gap: 0.6rem; margin-bottom: 0.3rem; font-size: 0.8rem; }
.comment-author { font-weight: 600; color: var(--text); }
.comment-time   { color: var(--faint); font-family: var(--font-mono); }
.comment-content { font-size: 0.9rem; color: var(--muted); line-height: 1.65; }
.comment-deleted { color: var(--faint); font-style: italic; font-size: 0.875rem; }
.comment-footer { display: flex; align-items: center; gap: 0.75rem; margin-top: 0.35rem; }
.comment-vote-btn { display: flex; align-items: center; gap: 0.3rem; font-size: 0.775rem; color: var(--faint); padding: 0.2rem 0.4rem; border-radius: 3px; }
.comment-vote-btn:hover { background: var(--bg-3); color: var(--text); }
.comment-vote-btn.up.active   { color: var(--green); }
.comment-vote-btn.down.active { color: var(--red); }
.comment-reply-btn { font-size: 0.775rem; color: var(--faint); }
.comment-reply-btn:hover { color: var(--muted); }
.comment-score { font-family: var(--font-mono); font-size: 0.75rem; color: var(--faint); }

.comment-children { margin-left: 0.5rem; padding-left: 0.75rem; margin-top: 0.75rem; border-left: 2px solid var(--border); }

/* =============================================================
   SIDEBAR
   ============================================================= */

.sidebar-card {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.1rem;
  margin-bottom: 1rem;
}
.sidebar-card h3 {
  font-size: 0.8rem;
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--faint);
  margin-bottom: 0.75rem;
}
.sidebar-card p { font-size: 0.875rem; color: var(--muted); line-height: 1.6; }

.community-header {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  margin-bottom: 1.5rem;
}
.community-header-banner {
  height: 80px;
  background: linear-gradient(135deg, var(--accent-dim), #1a0a0a);
}
.community-header-body { padding: 1rem 1.25rem; }
.community-header-body h1 { font-size: 1.25rem; margin-bottom: 0.25rem; }
.community-header-body .slug { font-family: var(--font-mono); font-size: 0.8rem; color: var(--faint); margin-bottom: 0.75rem; }
.community-header-body p { font-size: 0.875rem; color: var(--muted); margin-bottom: 1rem; }
.community-header-stats { display: flex; gap: 1.5rem; margin-bottom: 1rem; }
.community-header-stats .stat { font-size: 0.8rem; }
.community-header-stats .stat strong { display: block; font-size: 1rem; color: var(--text); font-family: var(--font-mono); }
.community-header-stats .stat span { color: var(--faint); }

/* =============================================================
   AUTH FORMS
   ============================================================= */

.auth-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 2rem; }
.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 2rem;
}
.auth-card h1 { font-family: var(--font-serif); font-size: 1.5rem; margin-bottom: 0.25rem; }
.auth-card .subtitle { color: var(--muted); font-size: 0.875rem; margin-bottom: 1.75rem; }

.form-group { margin-bottom: 1rem; }
.form-group label { display: block; font-size: 0.8rem; color: var(--muted); margin-bottom: 0.4rem; font-family: var(--font-mono); text-transform: uppercase; letter-spacing: 0.05em; }
.form-group input { width: 100%; }

.auth-footer { margin-top: 1.5rem; text-align: center; font-size: 0.875rem; color: var(--faint); }
.auth-footer a { color: var(--accent); }

/* =============================================================
   VERIFICATION PAGE
   ============================================================= */

.verify-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; }
@media (max-width: 640px) { .verify-grid { grid-template-columns: 1fr; } }

.verify-card {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.5rem;
}
.verify-card h2 { font-size: 1rem; margin-bottom: 0.25rem; }
.verify-card .subtitle { font-size: 0.875rem; color: var(--muted); margin-bottom: 1.25rem; }

.challenge-text {
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  font-size: 1rem;
  line-height: 1.6;
  margin-bottom: 1rem;
  color: var(--text);
  font-style: italic;
}

.pending-item {
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 0.75rem;
}
.pending-item .username { font-weight: 600; margin-bottom: 0.5rem; }
.pending-item .question { font-size: 0.8rem; color: var(--faint); font-family: var(--font-mono); margin-bottom: 0.25rem; }
.pending-item .answer { font-size: 0.9rem; color: var(--muted); margin-bottom: 0.75rem; line-height: 1.5; }
.pending-item .vote-actions { display: flex; gap: 0.5rem; }

.verified-badge { display: inline-flex; align-items: center; gap: 0.4rem; background: rgba(76,175,110,0.15); color: var(--green); padding: 0.4rem 0.9rem; border-radius: 999px; font-size: 0.875rem; margin-bottom: 1rem; }

/* =============================================================
   MISC
   ============================================================= */

.empty-state { text-align: center; padding: 3rem 1rem; color: var(--faint); }
.empty-state svg { margin-bottom: 1rem; opacity: 0.3; }
.empty-state h3 { font-size: 1rem; margin-bottom: 0.5rem; color: var(--muted); }
.empty-state p { font-size: 0.875rem; }

.divider { border: none; border-top: 1px solid var(--border); margin: 1.5rem 0; }

.tag { display: inline-block; padding: 0.2rem 0.6rem; border-radius: 999px; font-size: 0.75rem; font-family: var(--font-mono); background: var(--bg-3); border: 1px solid var(--border); color: var(--faint); }
.tag-accent { background: rgba(230,60,60,0.1); border-color: var(--accent-dim); color: var(--accent); }

/* SSE indicator */
.live-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--green); margin-right: 0.4rem; animation: pulse 2s infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.3; } }

/* Scrollbar */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--faint); }

/* Selection */
::selection { background: var(--accent-dim); color: var(--text); }

/* =============================================================
   RESPONSIVE
   ============================================================= */

@media (max-width: 600px) {
  .nav { padding: 0 1rem; }
  .nav-search { display: none; }
  .container { padding: 0 1rem; }
  .post-item { grid-template-columns: 44px 1fr; }
}

/* =============================================================
   LIGHT MODE
   ============================================================= */

[data-theme="light"] {
  --bg:         #f4f3ef;
  --bg-2:       #ffffff;
  --bg-3:       #eceae4;
  --border:     #d8d6ce;
  --border-2:   #bbb9b0;
  --text:       #1a1a18;
  --muted:      #52524c;
  --faint:      #96948c;
  --accent:     #c73030;
  --accent-dim: #f5caca;
  --green:      #2d8a4e;
  --red:        #c73030;
  --blue:       #1a6fc4;
  --amber:      #a06010;
}

[data-theme="light"] input,
[data-theme="light"] textarea,
[data-theme="light"] select {
  background: #fff;
  border-color: var(--border);
  color: var(--text);
}

[data-theme="light"] .nav {
  background: rgba(244,243,239,0.95);
}

[data-theme="light"] .post-item,
[data-theme="light"] .community-card,
[data-theme="light"] .sidebar-card,
[data-theme="light"] .post-detail {
  box-shadow: 0 1px 3px rgba(0,0,0,.06);
}

[data-theme="light"] .vote-col {
  background: #f0efe9;
}

[data-theme="light"] ::-webkit-scrollbar-track { background: var(--bg); }
[data-theme="light"] ::-webkit-scrollbar-thumb { background: var(--border-2); }

/* =============================================================
   THEME TOGGLE BUTTON
   ============================================================= */

.theme-toggle {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-3);
  border: 1px solid var(--border);
  color: var(--muted);
  cursor: pointer;
  transition: all .2s;
  flex-shrink: 0;
  font-size: 16px;
}
.theme-toggle:hover {
  background: var(--bg-2);
  color: var(--text);
  border-color: var(--border-2);
}

/* =============================================================
   PROFILE — Nav-Avatar (mini)
   ============================================================= */

.nav-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: .65rem;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
  vertical-align: middle;
  margin-right: .3rem;
}

/* =============================================================
   MOBILE RESPONSIVE — Vollständige Überarbeitung
   Breakpoints: 430px (iPhone), 600px (klein), 768px (tablet)
   ============================================================= */

/* ── Verhindere horizontales Scrollen global ── */
html, body { overflow-x: hidden; max-width: 100%; }

/* ── Nav Mobile ── */
@media (max-width: 600px) {
  .nav { padding: 0 .75rem; gap: .5rem; height: 48px; }
  .nav-brand { font-size: .95rem; }

  /* Sekundäre Nav-Links auf Mobile ausblenden */
  .nav-link[href="/timeline"],
  .nav-link[href="/notifications"],
  .nav-link[href="/communities/new"] { display: none; }

  /* Verify-Status Punkt klein halten */
  .nav-link[href="/verify"] { padding: .25rem .4rem; }

  /* Username-Text neben Avatar ausblenden, nur Avatar zeigen */
  .nav-link[href^="/u/"] span:last-child { display: none; }
  .nav-link[href^="/u/"] { padding: .25rem .4rem; }

  /* Logout-Button kompakter */
  .nav .btn-ghost.btn-sm { padding: .3rem .55rem; font-size: .75rem; }

  /* Theme-Toggle kleiner */
  .theme-toggle { width: 30px; height: 30px; }
}

/* ── Container ── */
@media (max-width: 600px) {
  .container { padding: 0 .875rem; }
  .page { padding: 1.25rem 0 3rem; }
}

/* ── Hero ── */
@media (max-width: 600px) {
  .page-hero { padding: 1.5rem 0 1.25rem; margin-bottom: 1.25rem; }
  .page-hero h1 { font-size: 1.6rem; }
}

/* ── Community Grid ── */
@media (max-width: 600px) {
  .community-grid { grid-template-columns: 1fr; gap: .75rem; }
  .community-card { padding: 1rem; }
}

/* ── Sort Bar ── */
@media (max-width: 600px) {
  .sort-bar { gap: .35rem; }
  .sort-bar a { padding: .3rem .6rem; font-size: .8rem; }
}

/* ── Post Items ── */
@media (max-width: 600px) {
  .post-item { grid-template-columns: 40px 1fr; border-radius: 6px; }
  .vote-col { padding: .65rem 0; }
  .vote-score { font-size: .7rem; }
  .post-body { padding: .65rem .85rem; gap: .3rem; }
  .post-title { font-size: .9rem; }
  .post-meta { font-size: .7rem; }
  .post-footer { font-size: .75rem; gap: .75rem; }
}

/* ── Post Detail ── */
@media (max-width: 600px) {
  .post-detail-content h1 { font-size: 1.2rem; }
  .post-detail-body { font-size: .875rem; }
  .post-detail-footer { font-size: .775rem; flex-wrap: wrap; gap: .5rem; }
}

/* ── Two-Column → Single Column ── */
@media (max-width: 768px) {
  .two-col { grid-template-columns: 1fr; gap: 1rem; }

  /* Sidebar generell sichtbar auf Mobile */
  .sidebar {
    display: block !important;
    order: 2; /* Sidebar UNTER Posts */
    margin-top: .75rem;
  }
  /* Community-Seite: Sidebar-Header ÜBER Posts für Kontext */
  .community-page .sidebar {
    order: -1;
  }
  .sidebar .community-header { margin-bottom: 0; }
  .sidebar .community-header-banner { height: 48px; }
  .sidebar .community-header-body { padding: .75rem 1rem; }
  .sidebar .community-header-body h1 { font-size: 1.05rem; }
  .sidebar .community-header-body p { display: none; } /* Beschreibung verstecken */
  .sidebar .community-header-stats { gap: 1rem; margin-bottom: .75rem; }
  /* Auf Community-Seite: Regeln-Card auf Mobile ausblenden */
  .community-page .sidebar .sidebar-card:last-child { display: none; }
}

/* ── Profile ── */
@media (max-width: 560px) {
  /* Header: Vertikal zentriert */
  .profile-header {
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 1rem;
    padding-bottom: 1.25rem;
  }
  .profile-avatar { width: 80px; height: 80px; font-size: 1.6rem; }
  .profile-name { font-size: 1.25rem; }
  .profile-badges { justify-content: center; }
  .profile-bio { margin: 0 auto 1rem; text-align: left; }
  .profile-actions { justify-content: center; }

  /* Stats: 3 + 2 Layout statt 5 nebeneinander */
  .profile-stats { flex-wrap: wrap; }
  .stat-pill { flex: 0 0 33.333%; border-bottom: 1px solid var(--border); }
  .stat-pill:nth-child(4),
  .stat-pill:nth-child(5) { flex: 0 0 50%; }
  .stat-pill:nth-child(3) { border-right: none; }
  .stat-pill .num { font-size: 1.1rem; }

  /* Posts unter Sidebar-Info */
  .profile-grid { grid-template-columns: 1fr; }
  .profile-grid aside { order: -1; } /* Info zuerst */

  /* Sidebar-Info kompakter */
  .sidebar-info { padding: .85rem; }
  .rep-bar { display: none; }
}

/* ── Auth Cards ── */
@media (max-width: 480px) {
  .auth-page { padding: 1rem; align-items: flex-start; padding-top: 2rem; }
  .auth-card { padding: 1.5rem 1.25rem; border-radius: 10px; }
  .auth-card h1 { font-size: 1.3rem; }
}

/* ── Comments ── */
@media (max-width: 600px) {
  .comment { grid-template-columns: 14px 1fr; gap: 0 .5rem; }
  .comment-content { font-size: .85rem; }
  .comment-children { margin-left: .25rem; padding-left: .5rem; }
  .comment-footer { gap: .5rem; }
}

/* ── Admin ── */
@media (max-width: 768px) {
  .admin-wrap { grid-template-columns: 1fr; }
  .admin-nav { height: auto; padding: .5rem; display: flex; flex-wrap: wrap; gap: .25rem; }
  .admin-nav a { padding: .4rem .75rem; border-left: none !important; border-radius: 6px; }
  .admin-main { padding: 1rem; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .data-table { font-size: .8rem; display: block; overflow-x: auto; }
}

/* ── Footer auf Mobile ── */
@media (max-width: 600px) {
  footer .container { flex-direction: column; align-items: flex-start; gap: .5rem; }
}

/* ── Verify Grid ── */
@media (max-width: 480px) {
  .verify-grid { grid-template-columns: 1fr; }
}

/* ── Fix: Avatar-Ring auf Mobile deaktivieren (Performance) ── */
@media (max-width: 600px) {
  .profile-avatar-ring { animation: none; }
}

/* ── Prevent text overflow global ── */
@media (max-width: 600px) {
  .post-title a,
  .community-card h3 a,
  .profile-name { word-break: break-word; }
}

/* ── Post-Detail Vote auf Mobile horizontal ── */
@media (max-width: 600px) {
  .post-detail-vote {
    flex-direction: row;
    align-items: center;
    gap: .5rem;
    padding: .75rem 1rem 0;
    flex-wrap: wrap;
  }
  .post-detail-content { padding: 0 1rem .85rem; }
  .post-detail-content h1 { margin: .5rem 0 .4rem; }

  /* Community-Header auf Mobile kompakter */
  .community-header-banner { height: 52px; }
  .community-header-body { padding: .75rem 1rem; }
  .community-header-body h1 { font-size: 1.1rem; }
  .community-header-stats { gap: 1rem; }
  .community-header-stats .stat strong { font-size: .9rem; }
  .community-header-stats .stat span { font-size: .72rem; }

  /* Nav: Safe area auf iPhone (Notch/Dynamic Island) */
  .nav {
    padding-left: max(.75rem, env(safe-area-inset-left));
    padding-right: max(.75rem, env(safe-area-inset-right));
  }
}

/* =============================================================
   MOBILE NAV — radikal vereinfacht
   Nur Logo + Anmelden sichtbar. Alles andere weg.
   ============================================================= */

@media (max-width: 768px) {
  /* Alle Nav-Links ausblenden */
  .nav-links { gap: .4rem; }
  .nav-link          { display: none !important; }
  .theme-toggle      { display: none !important; }

  /* Nur die primären Buttons bleiben */
  /* Eingeloggt: nur Logout + Avatar (als Icon) */
  .nav-links .btn    { display: inline-flex !important; }

  /* Suchfeld weg */
  .nav-search        { display: none !important; }

  /* Nav kompakter */
  .nav { height: 48px; padding: 0 1rem; justify-content: space-between; }
  .nav-brand { font-size: 1rem; }
}

/* =============================================================
   NAV — Mobile-First, endgültige Version
   .nav-dt = "desktop-only" — auf Mobile ausgeblendet
   ============================================================= */

/* Desktop: alles sichtbar */
.nav-dt   { display: inline-flex !important; }
.nav-uname { font-size: .85rem; max-width: 90px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Mobile: nur Logo + Anmelden/Mitmachen + Avatar */
@media (max-width: 768px) {
  .nav-dt            { display: none !important; }
  .nav-uname         { display: none !important; }
  .nav-search        { display: none !important; }
  .nav               { padding: 0 1rem; height: 48px; }
  /* Theme-Toggle immer sichtbar, KI-Mod auf Mobile versteckt */
  .theme-toggle      { display: flex !important; width: 30px; height: 30px; }
  #ki-mod-toggle     { display: none !important; }

  /* Anmelden-Link auf Mobile als Button stylen */
  a.nav-link[href="/login"] {
    background: var(--bg-3);
    border: 1px solid var(--border-2);
    padding: .35rem .85rem;
    border-radius: 6px;
    font-size: .85rem;
    color: var(--text) !important;
  }
  a.nav-link[href="/login"]:hover {
    border-color: var(--accent);
    color: var(--accent) !important;
  }

  /* Mitmachen-Button auf Mobile etwas größer */
  .nav .btn-primary.btn-sm {
    padding: .4rem .9rem;
    font-size: .85rem;
  }

  /* Logged-in: Avatar + Abmelden kompakt */
  .nav-links .nav-link[href^="/u/"] {
    padding: .25rem .4rem;
  }
  .nav-links .btn-ghost.btn-sm {
    padding: .35rem .6rem;
    font-size: .8rem;
  }
}

/* =============================================================
   MOBILE SEARCH ICON + PANEL
   ============================================================= */

/* Search-Toggle Button — nur auf Mobile sichtbar */
.nav-search-toggle {
  display: none;
  width: 36px;
  height: 36px;
  align-items: center;
  justify-content: center;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--muted);
  cursor: pointer;
  flex-shrink: 0;
  transition: color .15s, border-color .15s;
  order: -1; /* Ganz links in den nav-links */
}
.nav-search-toggle:hover { color: var(--text); border-color: var(--border-2); }
.nav-search-toggle.active { color: var(--accent); border-color: var(--accent); }

/* Search Panel — klappt unter der Nav auf */
.nav-search-panel {
  display: none;
  position: absolute;
  top: 48px;
  left: 0;
  right: 0;
  background: var(--bg-2);
  border-bottom: 1px solid var(--border);
  padding: .6rem 1rem;
  z-index: 99;
}
.nav-search-panel input {
  width: 100%;
  padding: .6rem .9rem;
  font-size: 1rem;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
}
.nav-search-panel input:focus {
  outline: none;
  border-color: var(--accent);
}
.nav-search-panel.open { display: block; }

@media (max-width: 768px) {
  /* Toggle sichtbar auf Mobile */
  .nav-search-toggle { display: flex; }

  /* Desktop-Suchleiste bleibt versteckt */
  .nav-search { display: none !important; }

  /* Nav: position relative für das Panel */
  .nav { position: relative; }

  /* Theme-Toggle auch auf Mobile zeigen */
  .theme-toggle { display: flex !important; }
  .theme-toggle.nav-dt { display: flex !important; }
}

@media (min-width: 769px) {
  /* Auf Desktop: Toggle versteckt, Panel nie sichtbar */
  .nav-search-toggle { display: none !important; }
  .nav-search-panel  { display: none !important; }
}

/* Profile Hero Banner */
.profile-hero { padding: 0 0 0; border-bottom: 1px solid var(--border); margin-bottom: 2rem; }
.profile-hero .profile-inner { padding-top: 0; }
.profile-banner { height: 140px; }
@media (max-width: 560px) { .profile-banner { height: 90px; } }

/* =============================================================
   MOBILE BOTTOM NAVIGATION
   ============================================================= */

.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 200;
  background: var(--bg-2);
  border-top: 1px solid var(--border);
  padding: .4rem 0 calc(.4rem + env(safe-area-inset-bottom));
  grid-template-columns: repeat(4, 1fr);
}

.bottom-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .2rem;
  padding: .4rem .5rem;
  color: var(--faint);
  font-size: .6rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  transition: color .15s;
  text-decoration: none;
}

.bottom-nav-item.active,
.bottom-nav-item:hover { color: var(--accent); }

.bottom-nav-item svg { stroke: currentColor; }

@media (max-width: 768px) {
  .bottom-nav { display: grid; }

  /* Seite nach oben schieben damit Content nicht hinter Nav */
  body { padding-bottom: calc(64px + env(safe-area-inset-bottom)); }

  /* Top-Nav auf Mobile schlank halten */
  main { padding-top: 48px; }
}

/* =============================================================
   PULSE — Live-Aktivitäts-Panel
   ============================================================= */

#pulse-btn {
  position: fixed;
  bottom: calc(72px + env(safe-area-inset-bottom));
  right: 1.25rem;
  width: 44px; height: 44px;
  border-radius: 50%;
  background: var(--bg-2);
  border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; z-index: 150;
  box-shadow: 0 2px 12px rgba(0,0,0,.25);
  transition: transform .2s, box-shadow .2s;
  font-size: 1rem;
}
#pulse-btn:hover { transform: scale(1.08); box-shadow: 0 4px 20px rgba(0,0,0,.3); }
#pulse-btn .pulse-dot {
  position: absolute; top: 8px; right: 8px;
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 2px var(--bg-2);
  animation: pulse-ring 2s infinite;
}
@keyframes pulse-ring {
  0%   { box-shadow: 0 0 0 2px var(--bg-2), 0 0 0 0 rgba(76,175,110,.5); }
  70%  { box-shadow: 0 0 0 2px var(--bg-2), 0 0 0 6px rgba(76,175,110,0); }
  100% { box-shadow: 0 0 0 2px var(--bg-2), 0 0 0 0 rgba(76,175,110,0); }
}

#pulse-panel {
  position: fixed;
  bottom: calc(124px + env(safe-area-inset-bottom));
  right: 1.25rem;
  width: 300px;
  max-height: 380px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0,0,0,.3);
  z-index: 149;
  display: flex; flex-direction: column;
  overflow: hidden;
  transform: scale(.95) translateY(8px);
  opacity: 0;
  pointer-events: none;
  transition: all .2s cubic-bezier(.4,0,.2,1);
}
#pulse-panel.open {
  transform: scale(1) translateY(0);
  opacity: 1;
  pointer-events: all;
}
.pulse-header {
  padding: .65rem 1rem;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  font-size: .75rem; font-family: var(--font-mono); color: var(--faint);
  text-transform: uppercase; letter-spacing: .08em; flex-shrink: 0;
}
.pulse-header .pulse-live {
  display: flex; align-items: center; gap: .4rem; color: var(--green);
}
.pulse-list {
  overflow-y: auto; flex: 1;
  padding: .25rem 0;
}
.pulse-item {
  display: flex; align-items: flex-start; gap: .6rem;
  padding: .5rem 1rem; font-size: .8rem; color: var(--muted);
  transition: background .15s; cursor: pointer; text-decoration: none;
}
.pulse-item:hover { background: var(--bg-3); color: var(--text); }
.pulse-item-icon { flex-shrink: 0; font-size: .9rem; margin-top: .05rem; }
.pulse-item-text { flex: 1; min-width: 0; line-height: 1.4; }
.pulse-item-text strong { color: var(--text); }
.pulse-item-time {
  flex-shrink: 0; font-family: var(--font-mono); font-size: .68rem;
  color: var(--faint); white-space: nowrap; margin-top: .1rem;
}
.pulse-empty {
  padding: 1.5rem; text-align: center; color: var(--faint); font-size: .82rem;
}

@media (max-width: 768px) {
  #pulse-btn  { bottom: calc(80px + env(safe-area-inset-bottom)); right: 1rem; }
  #pulse-panel {
    bottom: calc(136px + env(safe-area-inset-bottom));
    right: 1rem; left: 1rem; width: auto;
  }
}

/* =============================================================
   MARKDOWN EDITOR
   ============================================================= */

.md-toolbar {
  display: flex; align-items: center; gap: .2rem;
  padding: .4rem .5rem;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-bottom: none;
  border-radius: 6px 6px 0 0;
  flex-wrap: wrap;
}
.md-btn {
  padding: .25rem .55rem;
  border-radius: 4px;
  border: 1px solid transparent;
  background: none;
  color: var(--muted);
  cursor: pointer;
  font-size: .85rem;
  transition: all .15s;
  line-height: 1.4;
}
.md-btn:hover, .md-btn.active {
  background: var(--bg-2);
  border-color: var(--border);
  color: var(--text);
}
.md-sep {
  width: 1px; height: 18px;
  background: var(--border);
  margin: 0 .25rem;
  flex-shrink: 0;
}
.md-editor-wrap {
  position: relative;
}
.md-editor-wrap textarea {
  border-radius: 0 0 6px 6px;
  border-top: none;
}
.md-preview {
  min-height: 180px;
  padding: .75rem;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 6px 6px;
  font-size: .9rem;
  line-height: 1.7;
  color: var(--text);
}
.md-preview h1, .md-preview h2, .md-preview h3 { font-family: var(--font-serif); margin: .75rem 0 .4rem; }
.md-preview code { background: var(--bg-3); padding: .1rem .35rem; border-radius: 3px; font-family: var(--font-mono); font-size: .85em; }
.md-preview blockquote { border-left: 3px solid var(--accent); padding-left: .85rem; color: var(--muted); margin: .5rem 0; }
.md-preview a { color: var(--accent); }

/* Lesezeit Badge */
.readtime-badge {
  display: inline-flex; align-items: center; gap: .3rem;
  font-size: .72rem; font-family: var(--font-mono);
  color: var(--faint);
}

/* Share Button Dropdown Item */
.share-item {
  display: flex; align-items: center; gap: .5rem;
  padding: .5rem .75rem; border-radius: 6px;
  font-size: .85rem; color: var(--muted); cursor: pointer;
  background: none; border: none; width: 100%; text-align: left;
  text-decoration: none; transition: background .15s;
}
.share-item:hover { background: var(--bg-3); color: var(--text); }

/* =============================================================
   SKELETON LOADER
   ============================================================= */

@keyframes skeleton-shimmer {
  0%   { background-position: -400px 0; }
  100% { background-position: 400px 0; }
}

.skeleton {
  background: linear-gradient(90deg,
    var(--bg-3) 25%,
    var(--bg-2) 50%,
    var(--bg-3) 75%
  );
  background-size: 800px 100%;
  animation: skeleton-shimmer 1.5s infinite;
  border-radius: 4px;
}

.skeleton-card {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem;
  margin-bottom: .75rem;
}
.skeleton-line {
  height: 14px;
  margin-bottom: .5rem;
  border-radius: 3px;
}
.skeleton-title  { height: 20px; width: 65%; margin-bottom: .75rem; }
.skeleton-meta   { height: 11px; width: 40%; margin-bottom: 1rem; }
.skeleton-text   { height: 13px; margin-bottom: .4rem; }
.skeleton-text.short { width: 80%; }
.skeleton-text.shorter { width: 55%; }


/* ── LOGOUT BUTTON — Desktop: Text, Mobile: rotes Icon ─────── */
.nav-logout-btn {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  padding: .3rem .65rem;
  font-size: .8rem;
  color: var(--muted);
  font-family: inherit;
  transition: all .15s;
}
.nav-logout-btn:hover {
  color: var(--accent);
  border-color: rgba(230,60,60,.4);
  background: rgba(230,60,60,.06);
}
.nav-logout-icon { display: none; }
.nav-logout-text { display: inline; }

@media (max-width: 768px) {
  .nav-logout-text { display: none; }
  .nav-logout-icon { display: flex; }
  .nav-logout-btn {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
    border-radius: 6px;
    padding: .3rem .45rem;
    width: 30px;
    height: 30px;
    justify-content: center;
  }
  .nav-logout-btn:hover {
    background: #c93030;
    border-color: #c93030;
    color: #fff;
  }
  /* Theme-Toggle immer sichtbar + korrekte Größe */
  .theme-toggle {
    display: flex !important;
    width: 30px !important;
    height: 30px !important;
    flex-shrink: 0;
  }
  /* Avatar-Link ohne Username kompakter */
  .nav-avatar-link .nav-uname { display: none; }
  .nav-avatar-link { padding: .25rem .35rem !important; }
}
