:root {
  --nav: 56px;
  --bg: linear-gradient(170deg, #2a1210, #170b0a 50%, #0d0606);
  --btn: linear-gradient(135deg, #7a0f1f, #b3263a);
  --glow: rgba(212, 163, 115, .45);
  --gold: #d4a373;
  --text: #eae0c7;
  --muted: #c9a77e;
  --field: rgba(234, 224, 199, .08);
  --serif: Georgia, 'Times New Roman', serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  background: #0d0606 var(--bg) fixed;
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
}
body.signed-in { padding-bottom: var(--nav); }
a { color: var(--gold); }
button, input { font: inherit; color: inherit; }
button {
  border: 0; border-radius: 10px; padding: 10px 14px; cursor: pointer;
  background: var(--field); color: var(--text);
}
button.primary { background: var(--btn); color: #fff3e3; font-weight: 600; box-shadow: 0 0 18px var(--glow); }
button.danger { color: #ff9a9a; }
button:disabled { opacity: .6; }
input:not([type=checkbox]):not([type=radio]) {
  width: 100%; border: 1px solid transparent; border-radius: 10px; padding: 11px 12px;
  background: var(--field); outline: none;
}
input:focus { border-color: var(--gold); }
.muted, .small { color: var(--muted); }
.small { font-size: 13px; }
.error { color: #ff9a9a; min-height: 1.2em; margin: 4px 0; }
.error:empty { display: none; }

/* sign-in style screens */
.sign { max-width: 360px; margin: 0 auto; padding: 44px 22px; text-align: center; }
.sign .logo { width: 110px; height: 110px; border-radius: 24px; object-fit: cover; box-shadow: 0 0 0 2px var(--gold), 0 0 26px var(--glow); }
.sign .name, .page h1 { font-family: var(--serif); font-style: italic; font-weight: 400; }
.sign .name { font-size: 34px; margin: 12px 0 22px; letter-spacing: .5px; }
.sign h2 { font-family: var(--serif); font-style: italic; font-weight: 400; font-size: 22px; margin: 0 0 14px; }
.sign form { display: flex; flex-direction: column; gap: 10px; text-align: left; }
.field label { display: block; font-size: 13px; color: var(--muted); margin: 0 0 4px 2px; }
.sign button.primary { margin-top: 6px; padding: 12px; }

/* bottom nav */
#nav {
  position: fixed; left: 0; right: 0; bottom: 0; height: var(--nav); z-index: 10; max-width: 480px; margin: 0 auto;
  display: flex; justify-content: space-around; align-items: center;
  background: #0b0505; padding-bottom: env(safe-area-inset-bottom);
}
#nav[hidden] { display: none; }
/* previews: keep the Settings tab clear of the "Report bug" button (bottom right) */
@media (max-width: 640px) { body:has(> #g3-telemetry-host) #nav { padding-right: 120px; } }
#nav a { color: var(--muted); text-decoration: none; font-size: 11px; text-align: center; display: flex; flex-direction: column; align-items: center; position: relative; min-width: 64px; }
#nav a span { font-size: 17px; line-height: 1.2; }
#nav a.on { color: var(--gold); font-weight: 600; text-shadow: 0 0 10px var(--glow); }
.badge { position: absolute; top: -4px; right: 10px; background: #b3263a; color: #fff; border-radius: 9px; font-size: 10px; padding: 1px 5px; text-shadow: none; }

/* feed */
#feed {
  height: calc(100dvh - var(--nav)); overflow-y: auto; scroll-snap-type: y mandatory;
  max-width: 480px; margin: 0 auto; background: #000; scrollbar-width: none;
}
.post { height: 100%; scroll-snap-align: start; scroll-snap-stop: always; position: relative; overflow: hidden; background: #000; color: #fff; }
.post > .media { position: absolute; inset: 0; }
.media > img, .media > video { width: 100%; height: 100%; object-fit: contain; display: block; }
.post .top { position: absolute; top: 10px; left: 12px; font-size: 13px; opacity: .9; text-shadow: 0 1px 3px #000; }
.post .eye { margin-right: 4px; }
.post .side { position: absolute; right: 8px; bottom: 110px; display: flex; flex-direction: column; gap: 14px; align-items: center; }
.post .act { display: flex; flex-direction: column; align-items: center; font-size: 11px; text-align: center; text-shadow: 0 1px 3px #000; }
.post .side button { background: none; padding: 0; display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 11px; color: #fff; }
.post .side .icon {
  width: 42px; height: 42px; border-radius: 50%; background: rgba(255, 255, 255, .14);
  display: flex; align-items: center; justify-content: center; font-size: 18px;
}
.post .side button[aria-pressed=true] .icon { background: var(--btn); box-shadow: 0 0 14px var(--glow); color: #fff3e3; }
.post .site-score, .post .site-count { opacity: .7; font-size: 10px; }
.post .info { position: absolute; left: 12px; right: 70px; bottom: 16px; font-size: 13px; line-height: 1.4; text-shadow: 0 1px 3px #000; }
.post a.poster { color: #fff; font-weight: 600; text-decoration: none; }
.post .tag { display: inline-block; background: rgba(255, 255, 255, .14); border-radius: 12px; padding: 2px 9px; margin: 4px 4px 0 0; font-size: 12px; color: inherit; text-decoration: none; }
.placeholder { height: calc(100dvh - var(--nav)); display: flex; flex-direction: column; gap: 10px; text-align: center; padding: 24px; align-items: center; justify-content: center; color: var(--muted); font-family: var(--serif); font-style: italic; }
.sign .placeholder { height: auto; }
.empty { height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px; text-align: center; background: var(--bg); }

/* pages */
.page { max-width: 480px; margin: 0 auto; padding: 18px 16px 32px; }
.page h1 { font-size: 26px; margin: 6px 0 12px; }
fieldset { border: 0; padding: 0; margin: 18px 0 0; }
legend { font-size: 13px; color: var(--muted); margin-bottom: 8px; padding: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { position: relative; }
.chip input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.chip span { display: inline-block; border-radius: 14px; padding: 6px 12px; background: var(--field); color: var(--muted); font-size: 14px; }
.chip input:checked + span { background: var(--btn); color: #fff3e3; box-shadow: 0 0 12px var(--glow); }
.chip input:focus-visible + span { outline: 2px solid var(--gold); }
form.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
form.row label { width: 100%; font-size: 13px; color: var(--muted); }
form.row input { flex: 1; width: auto; }
ul.hidden-tags, ul.members { list-style: none; padding: 0; margin: 10px 0 0; }
ul.hidden-tags li, ul.members li, .links .item {
  display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px;
  background: rgba(234, 224, 199, .06); border-radius: 10px; padding: 8px 12px; margin-bottom: 8px;
}
.links { margin-top: 18px; }
.links .item { color: var(--text); text-decoration: none; padding: 12px; }
.links .item::after { content: '›'; color: var(--muted); }
.links .count { color: var(--gold); margin-left: auto; margin-right: 6px; }
.signout { margin-top: 18px; width: 100%; }
ul.members li .acts { display: flex; gap: 6px; }
ul.members li .member-link { width: 100%; }
ul.members li .member-link:empty { display: none; }
.linkbox { display: flex; gap: 6px; margin: 10px 0; }
.linkbox input { flex: 1; font-size: 13px; }
.new-link .muted { margin: 12px 0 0; font-size: 13px; }

#toast {
  position: fixed; left: 50%; bottom: calc(var(--nav) + 18px); transform: translateX(-50%); z-index: 20;
  background: var(--btn); color: #fff3e3; padding: 10px 18px; border-radius: 20px; box-shadow: 0 0 18px var(--glow);
}
#toast[hidden] { display: none; }

/* comments panel */
#comments {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 15; max-width: 480px; margin: 0 auto;
  height: 72dvh; display: flex; flex-direction: column;
  background: #1a0c0a var(--bg); border-radius: 18px 18px 0 0; box-shadow: 0 -6px 30px rgba(0, 0, 0, .6), 0 0 0 1px rgba(212, 163, 115, .25);
  animation: slide-up .22s ease-out;
}
@keyframes slide-up { from { transform: translateY(100%); } }
#comments header { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px 6px; }
#comments h2 { margin: 0; font-family: var(--serif); font-style: italic; font-weight: 400; font-size: 21px; }
#comments .close { padding: 6px 12px; font-size: 13px; }
#comments .list { flex: 1; overflow-y: auto; padding: 4px 16px; }
.comment, .site-comment { padding: 10px 0; border-bottom: 1px solid rgba(234, 224, 199, .08); }
.comment .meta, .site-comment .meta { display: flex; gap: 8px; align-items: baseline; font-size: 12px; color: var(--muted); flex-wrap: wrap; }
.comment .author { color: var(--gold); font-weight: 600; font-size: 13px; }
.site-comment .author { font-weight: 600; font-size: 13px; }
.site-comment .from { font-style: italic; }
.site-comment { opacity: .82; }
.comment .body, .site-comment .body { margin: 4px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.comment .acts, .edit .acts { display: flex; gap: 6px; margin-top: 6px; }
.comment .acts button, .edit .acts button { padding: 5px 11px; font-size: 13px; }
.versions { margin-top: 4px; font-size: 13px; color: var(--muted); }
.versions summary { cursor: pointer; }
.versions .old { border-left: 2px solid rgba(212, 163, 115, .35); padding-left: 8px; margin: 6px 0; }
.versions .old-body { margin: 0; white-space: pre-wrap; }
.versions .old-date { font-size: 11px; }
textarea {
  font: inherit; color: inherit; width: 100%; resize: none; border: 1px solid transparent; border-radius: 10px; padding: 10px 12px;
  background: var(--field); outline: none;
}
textarea:focus { border-color: var(--gold); }
.edit { margin-top: 6px; }
#comments .write { display: flex; gap: 8px; align-items: flex-end; padding: 10px 16px calc(12px + env(safe-area-inset-bottom)); border-top: 1px solid rgba(234, 224, 199, .1); }

/* search */
.modes { display: flex; gap: 6px; margin-bottom: 10px; }
.modes button { border-radius: 14px; padding: 6px 14px; font-size: 14px; color: var(--muted); }
.modes button[aria-pressed=true] { background: var(--btn); color: #fff3e3; box-shadow: 0 0 12px var(--glow); }
form.search .row { display: flex; gap: 8px; }
form.search input { flex: 1; }
.results { margin-top: 14px; }
a.poster-row {
  display: block; text-decoration: none; color: var(--text); background: rgba(234, 224, 199, .06);
  border-radius: 10px; padding: 12px; margin-bottom: 8px;
}
.page .empty { height: auto; background: none; padding: 40px 12px; color: var(--muted); font-family: var(--serif); font-style: italic; }

/* grids */
.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; }
.grid a.tile { position: relative; aspect-ratio: 3 / 4; background: #000; border-radius: 6px; overflow: hidden; display: block; }
.grid a.tile img { width: 100%; height: 100%; object-fit: cover; display: block; }
.grid a.tile[data-media=video]::after { content: '▶'; position: absolute; top: 6px; right: 7px; font-size: 11px; color: #fff; text-shadow: 0 1px 3px #000; }
button.more { display: block; width: 100%; margin-top: 12px; }
button.more[hidden] { display: none; }

/* reported posts */
ul.reports { list-style: none; padding: 0; margin: 10px 0 0; }
li.report { display: flex; gap: 12px; background: rgba(234, 224, 199, .06); border-radius: 10px; padding: 10px; margin-bottom: 10px; }
li.report button.open { padding: 0; background: none; box-shadow: none; flex: none; }
li.report button.link { background: none; box-shadow: none; padding: 0; color: var(--gold, #d4a373); text-decoration: underline; align-self: flex-start; font-size: 13px; }
dialog.reported { width: min(100vw, 560px); max-width: 100vw; max-height: 100dvh; padding: 0; border: 0; border-radius: 10px; background: #0d0606; color: inherit; overflow: auto; }
dialog.reported::backdrop { background: rgba(0, 0, 0, .85); }
dialog.reported .media { background: #000; height: 70dvh; }
dialog.reported .what { display: flex; flex-direction: column; gap: 6px; padding: 12px; overflow-wrap: anywhere; }
dialog.reported .acts { display: flex; gap: 6px; flex-wrap: wrap; }
li.report .thumb { width: 84px; height: 112px; object-fit: cover; border-radius: 6px; background: #000; flex: none; }
li.report .what { display: flex; flex-direction: column; gap: 4px; min-width: 0; overflow-wrap: anywhere; }
li.report .acts { display: flex; gap: 6px; margin-top: auto; flex-wrap: wrap; }
li.report .acts button { padding: 7px 12px; font-size: 13px; }

/* search tag cards and suggestions */
ul.chips, ul.suggest { list-style: none; padding: 0; margin: 0 0 10px; display: flex; flex-wrap: wrap; gap: 6px; }
ul.chips[hidden], ul.suggest[hidden] { display: none; }
li.chip { display: flex; align-items: center; gap: 6px; background: rgba(234, 224, 199, .1); border: 1px solid rgba(234, 224, 199, .2); border-radius: 10px; padding: 4px 4px 4px 10px; }
li.chip button { border-radius: 8px; padding: 0 8px; line-height: 24px; color: var(--muted); }
ul.suggest { margin: 8px 0 0; }
ul.suggest button { border-radius: 12px; padding: 4px 12px; font-size: 14px; }
