/* Finstagram, Variante „Glut“. Mobil zuerst, dunkel. Spätere Abschnitte je Bildschirm. */

@font-face {
  font-family: "Cookie";
  src: url("fonts/cookie-latin-400-normal.woff2") format("woff2");
  font-display: swap;
}
@font-face {
  font-family: "Inter";
  src: url("fonts/inter-latin-wght-normal.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Inter";
  src: url("fonts/inter-latin-ext-wght-normal.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Inter";
  src: url("fonts/inter-cyrillic-wght-normal.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}

:root {
  --bg: #1a191d;
  --surface: #232227;
  --raised: #2e2c33;
  --line: #3a3840;
  --text: #f5f4f6;
  --muted: #b0aeb5;
  --accent: #ff4d5e;
  --poster: #ffd166;
  --link: #ffb48f;
  --btn: #8a0f4f;
  --grad: linear-gradient(45deg, #2b0a3d 0%, #8a0f4f 40%, #d23a1e 75%, #e88a12 100%);
  --textpost: linear-gradient(160deg, #0d0a0c 0%, #3a0a14 55%, #7a1020 100%);
  --mono: ui-monospace, Menlo, Consolas, monospace;
  --nav: calc(58px + env(safe-area-inset-bottom));
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0 auto;
  max-width: 600px;
  min-height: 100vh;
  padding-bottom: var(--nav);
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 Inter, system-ui, sans-serif;
}
main { flex: 1; display: flex; flex-direction: column; } /* .bottom-form sinkt ans Ende */
a { color: var(--link); text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; margin: 0; cursor: pointer; }
input, textarea {
  width: 100%;
  padding: 10px 12px;
  font: inherit;
  font-size: 16px; /* kleiner zoomt iOS beim Tippen hinein */
  color: var(--text);
  background: var(--raised);
  border: 1px solid var(--line);
  border-radius: 10px;
  outline: none;
}
input:focus, textarea:focus { border-color: var(--muted); }
input::placeholder, textarea::placeholder { color: var(--muted); }
textarea { resize: vertical; line-height: 1.4; }
:disabled { opacity: .45; cursor: not-allowed; }
:focus-visible { outline: 2px solid var(--link); outline-offset: 2px; }

.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.strong { font-weight: 600; }
.mono { font-family: var(--mono); letter-spacing: .08em; }
.error { color: var(--accent); }
.text { white-space: pre-line; overflow-wrap: anywhere; }
.tag { color: var(--link); }
.grow { flex: 1; }
.empty { padding: 24px 16px; text-align: center; color: var(--muted); }
.stack { padding: 14px; display: grid; gap: 12px; }

/* Kopfzeile */
.top {
  position: sticky;
  top: 0;
  z-index: 10;
  height: 54px;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 8px 0 4px;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.top .title { flex: 1; margin: 0; font-size: 17px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.logo { flex: 1; padding: 4px 0 0 10px; font: 36px/1 Cookie, cursive; color: var(--text); }
.icon-btn {
  position: relative;
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  color: var(--text);
}
.count {
  position: absolute;
  top: 6px;
  right: 5px;
  min-width: 17px;
  height: 17px;
  padding: 0 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 9px;
  background: var(--accent);
  color: #000;
  font-size: 10px;
  font-weight: 700;
}

/* Navigation unten */
.nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 10;
  max-width: 600px;
  height: var(--nav);
  margin: 0 auto;
  padding-bottom: env(safe-area-inset-bottom);
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  background: var(--bg);
  border-top: 1px solid var(--line);
}
.nav a { position: relative; display: flex; align-items: center; justify-content: center; color: var(--muted); }
.nav a[aria-current="page"] { color: var(--text); }
.nav .avatar { border: 2px solid transparent; }
.nav a[aria-current="page"] .avatar { border-color: var(--text); }
.dot { position: absolute; top: 10px; right: calc(50% - 20px); width: 9px; height: 9px; border-radius: 50%; background: var(--accent); }

/* Knöpfe */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 18px;
  border-radius: 10px;
  background: var(--raised);
  color: var(--text);
  font-weight: 600;
  text-align: center;
}
.btn.primary { background: var(--btn); color: #fff; }
.btn.small { min-height: 36px; padding: 0 12px; border-radius: 8px; }
.btn.wide { width: 100%; }
.link-btn { min-height: 44px; padding: 0 8px; color: var(--link); font-weight: 600; }

/* Profilbild */
.avatar { --size: 38px; flex: none; display: inline-flex; width: var(--size); height: var(--size); border-radius: 50%; overflow: hidden; }
.avatar img, .avatar .initial { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }
.avatar .initial { display: flex; align-items: center; justify-content: center; color: #fff; font-weight: 600; font-size: calc(var(--size) * .36); }
.avatar.ring { padding: 2px; background: var(--grad); }
.avatar.ring img, .avatar.ring .initial { border: 2px solid var(--bg); }

/* Meldungen */
.toasts { padding: 10px 12px 0; display: grid; gap: 8px; }
.toast { margin: 0; padding: 10px 12px; border-radius: 10px; background: var(--raised); font-size: 13px; }
.toast.error { border: 1px solid var(--accent); }

/* Login */
.login { padding: 24px 16px; display: grid; gap: 10px; }
.login label { margin-top: 6px; font-weight: 600; }
.login .btn { margin-top: 12px; }

/* Beiträge */
.post { padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.post-head { display: flex; align-items: center; gap: 10px; padding: 8px 12px; }
.who { display: flex; flex-direction: column; min-width: 0; }
.poster { color: var(--poster); font-weight: 700; }
.carousel { background: #000; }
.slides { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none; }
.slides::-webkit-scrollbar { display: none; }
.slide { flex: 0 0 100%; display: flex; align-items: center; justify-content: center; scroll-snap-align: center; }
.slide img { display: block; width: 100%; max-height: 80vh; object-fit: contain; }
.multi .slide { aspect-ratio: 1 / 1; }
.multi .slide img { height: 100%; max-height: none; }
.dots { display: flex; justify-content: center; gap: 5px; padding-top: 8px; background: var(--bg); }
.dots span { width: 6px; height: 6px; border-radius: 50%; background: var(--line); }
.dots span.on { background: var(--link); }
.textpost {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 220px;
  padding: 28px;
  background: var(--textpost);
  border-top: 3px solid transparent;
  border-image: var(--grad) 1;
  color: var(--text);
  font-size: 21px;
  font-weight: 600;
  line-height: 1.35;
  text-align: center;
}
.textpost.long { font-size: 16px; font-weight: 500; text-align: left; }
.post-actions .row { display: flex; align-items: center; padding: 2px 4px 0; }
.liked .icon-heart { fill: var(--accent); stroke: var(--accent); }
.code-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-right: 8px;
  padding: 5px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 12px;
}
.code-chip .mono { color: var(--text); }
.likes { margin: 0; padding: 0 14px; font-weight: 600; }
.post-body { display: grid; gap: 6px; padding: 4px 14px 0; }
.post-body p { margin: 0; }
.more { display: flex; justify-content: center; padding: 16px; }
.comments { display: grid; gap: 12px; padding: 10px 14px; }
.comment p { margin: 0; }
.commenter { color: var(--accent); font-weight: 600; }

/* Profil und Raster */
.profile { display: grid; gap: 12px; padding: 14px; }
.profile-top { display: flex; align-items: center; gap: 18px; }
.stats { flex: 1; display: grid; grid-template-columns: repeat(3, 1fr); margin: 0; text-align: center; }
.stats div { display: flex; flex-direction: column-reverse; }
.stats dt { font-size: 13px; }
.stats dd { margin: 0; font-size: 17px; font-weight: 700; }
.profile-text p { margin: 2px 0 0; }
.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 2px; padding-top: 2px; border-top: 1px solid var(--line); }
.grid .empty { grid-column: 1 / -1; }
.cell { position: relative; aspect-ratio: 1 / 1; overflow: hidden; background: var(--surface); color: var(--text); }
.cell img { display: block; width: 100%; height: 100%; object-fit: cover; }
.textcell { display: flex; align-items: flex-end; padding: 6px; background: var(--textpost); font-size: 10px; line-height: 1.3; }
.badge { position: absolute; top: 6px; right: 6px; color: #fff; filter: drop-shadow(0 0 2px #000); }
.badge.left { right: auto; left: 6px; }

/* Hashtag */
.taghead { display: flex; align-items: center; gap: 18px; padding: 18px 14px; }
.taghead p { margin: 2px 0 8px; }
.tagmark { flex: none; display: flex; align-items: center; justify-content: center; width: 76px; height: 76px; border: 1px solid var(--line); border-radius: 50%; font-size: 34px; }
.tagmark.small { width: 44px; height: 44px; font-size: 20px; }

/* Kommentieren und Bearbeiten */
.comment-meta { display: flex; align-items: center; gap: 12px; }
.comment-meta form { display: inline; }
.link { color: var(--link); }
.owner-tools { display: flex; gap: 8px; padding: 10px 14px 0; }
.bottom-form {
  margin-top: auto;
  position: sticky;
  bottom: var(--nav);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--bg);
  border-top: 1px solid var(--line);
}

/* Profil-Knöpfe, Anfragen, Listen */
.profile-buttons { display: flex; gap: 6px; }
.profile-buttons form { flex: 1; display: flex; }
.profile-buttons form:nth-child(2) { flex: 1.4; }
.profile-buttons .btn { flex: 1; padding: 0 6px; }
.box { display: grid; gap: 10px; padding: 12px; border: 1px solid var(--line); border-radius: 12px; }
.request { display: flex; align-items: center; gap: 8px; }
.own-links { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.list { list-style: none; margin: 0; padding: 0; }
.list .new { background: var(--surface); }
.row-link { display: flex; align-items: center; gap: 12px; min-height: 60px; padding: 8px 14px; color: var(--text); }
.names { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.section { margin: 0; padding: 12px 14px 4px; font-size: 16px; }

/* Suche */
.search { padding: 12px 14px 4px; }

/* Neuer Beitrag */
.composer fieldset { display: grid; gap: 10px; margin: 0; padding: 0; border: 0; }
.composer legend { margin-bottom: 8px; padding: 0; }
.pickers { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.thumbs { display: flex; flex-wrap: wrap; gap: 8px; margin: 0; padding: 0; list-style: none; }
.thumbs:empty { display: none; }
.thumbs li { position: relative; width: 84px; height: 84px; overflow: hidden; border-radius: 10px; touch-action: none; cursor: grab; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.thumbs li.dragging { opacity: .6; outline: 2px solid var(--link); }
.thumbs img { width: 100%; height: 100%; object-fit: cover; pointer-events: none; }
.thumbs .remove { position: absolute; top: 2px; right: 2px; width: 32px; height: 32px; border-radius: 50%; background: rgba(0, 0, 0, .65); color: #fff; font-size: 20px; }
.choice { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.choice input { position: absolute; opacity: 0; }
.choice label { display: flex; align-items: center; justify-content: center; min-height: 44px; border: 1px solid var(--line); border-radius: 10px; font-weight: 600; cursor: pointer; }
.choice input:checked + label { border-color: var(--text); background: var(--raised); }
.choice input:focus-visible + label { outline: 2px solid var(--link); }
.composer:has(#vis-public:checked) .hint-friends,
.composer:has(#vis-friends:checked) .hint-public { display: none; }
.notice { margin: 0; padding: 10px 12px; border-radius: 10px; background: var(--raised); color: var(--muted); }

/* Code-Eingabe */
.code-form { display: flex; gap: 8px; }
.code-form input { flex: 1; min-width: 0; font-size: 18px; letter-spacing: .14em; text-transform: uppercase; }
.result { display: grid; gap: 6px; padding: 14px; border: 1px solid var(--line); border-radius: 14px; background: var(--raised); }
.result.hit { border-color: var(--accent); }
.result p, .memory p { margin: 0; }
.stack .section { padding: 10px 0 0; }
.memory { display: grid; gap: 8px; margin-top: 10px; padding: 12px; border: 1px solid var(--line); border-radius: 12px; }
.memory-head { display: flex; align-items: center; gap: 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; padding-top: 10px; }
.chip { display: inline-flex; align-items: center; min-height: 32px; padding: 3px 12px; border: 1px solid var(--line); border-radius: 999px; color: var(--text); font-size: 12px; }
a.chip { color: var(--link); }

/* Chats */
.chats .row-link { min-height: 68px; }
.preview { overflow: hidden; color: var(--muted); font-size: 13px; white-space: nowrap; text-overflow: ellipsis; }
.unread strong, .unread .preview { color: var(--text); font-weight: 700; }
.unread-dot { flex: none; width: 9px; height: 9px; border-radius: 50%; background: var(--accent); }
.chat { padding: 18px 12px 12px; }
.chat-partner { display: flex; flex-direction: column; align-items: center; gap: 6px; padding-bottom: 14px; }
.messages { display: flex; flex-direction: column; gap: 6px; }
.message { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; }
.message.mine { align-items: flex-end; }
.msg-time { align-self: center; padding: 8px 0 2px; color: var(--muted); font-size: 11px; }
.msg-author { padding-left: 12px; color: var(--muted); font-size: 11px; }
.bubble { max-width: 75%; padding: 9px 13px; border-radius: 20px; background: var(--raised); color: #fff; overflow-wrap: anywhere; }
.mine .bubble { background: var(--btn); }
.bubble img { display: block; max-width: 100%; margin: 2px 0; border-radius: 12px; }
#message-text { border-radius: 22px; }
#chat-end { scroll-margin-bottom: calc(var(--nav) + 64px); }

/* Spielleitung */
.gm-nav a { font-size: 12px; font-weight: 600; }
.gm-form > div { display: grid; gap: 4px; }
.gm-form > div:has(> input[type="checkbox"]) { grid-template-columns: 1fr auto; align-items: center; min-height: 44px; }
.gm-form input[type="checkbox"], .locks input { width: 22px; height: 22px; padding: 0; }
.helptext { color: var(--muted); font-size: 12px; }
select {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  font: inherit;
  font-size: 16px;
  color: var(--text);
  background: var(--raised);
  border: 1px solid var(--line);
  border-radius: 10px;
}
.gm-links .row-link { min-height: 48px; border-bottom: 1px solid var(--line); }
.gm-row { display: grid; gap: 6px; padding: 10px 14px; border-bottom: 1px solid var(--line); color: var(--text); }
.meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.gm-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.gm-actions input { width: auto; }
.gm-actions form { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.gm-actions .btn, .locks .btn, .gm-pages .btn { min-height: 44px; }
.state { display: inline-block; padding: 1px 6px; border-radius: 6px; background: var(--raised); color: var(--muted); font-size: 11px; font-weight: 600; }
.state.warn { color: var(--poster); }
.locks { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 14px; }
.locks label { display: flex; align-items: center; gap: 6px; min-height: 44px; }
.gm-images { display: flex; gap: 4px; overflow-x: auto; }
.gm-images img { display: block; width: 110px; height: 110px; object-fit: cover; border-radius: 6px; }
.gm-pages { gap: 12px; align-items: center; }