:root {
  --navy: #071628;
  --navy-2: #0f2b4d;
  --brand: #004b99;
  --brand-2: #2b7de9;
  --upvote: #ff4d1a;
  --downvote: #6d8cff;
  --bg: #eef2f7;
  --card: #ffffff;
  --text: #111827;
  --muted: #6b7280;
  --line: #e5e7eb;
  --danger: #dc2626;
  --ok: #059669;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.05), 0 10px 28px rgba(15, 23, 42, 0.06);
  --nav-h: 64px;
  --tab-h: 0px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  min-height: 100%;
  touch-action: pan-y;
  -ms-touch-action: pan-y;
}
html { scroll-behavior: smooth; }
body {
  font-family: "Plus Jakarta Sans", system-ui, sans-serif;
  background:
    radial-gradient(1200px 500px at 10% -10%, rgba(43, 125, 233, 0.16), transparent 55%),
    radial-gradient(900px 400px at 100% 0%, rgba(255, 77, 26, 0.08), transparent 45%),
    var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  padding-bottom: calc(var(--tab-h) + var(--safe-bottom));
}
button, input, textarea, select { font: inherit; }
button, a, input, textarea, select { touch-action: manipulation; }
a { color: var(--brand); text-decoration: none; }
img { max-width: 100%; display: block; }
:focus-visible {
  outline: 2px solid var(--brand-2);
  outline-offset: 2px;
}

.skip-link { position: absolute; left: -999px; top: 0; }
.skip-link:focus { left: 8px; background: #fff; padding: 8px; z-index: 80; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  min-height: var(--nav-h);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: calc(10px + var(--safe-top)) 16px 10px;
  background: rgba(7, 22, 40, 0.88);
  color: #fff;
  backdrop-filter: blur(18px) saturate(1.2);
  -webkit-backdrop-filter: blur(18px) saturate(1.2);
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #fff;
  flex: 0 0 auto;
}
.brand strong { display: block; font-size: 15px; line-height: 1.1; letter-spacing: -0.02em; }
.brand small { color: #9cb4d4; font-size: 11px; }
.topbar-right {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-left: auto;
  min-width: 0;
}
.search {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255,255,255,.96);
  color: var(--text);
  border-radius: 999px;
  padding: 0 14px;
  width: min(320px, 36vw);
  max-width: 320px;
  height: 42px;
  flex: 0 1 320px;
}
.search input {
  border: 0;
  outline: 0;
  width: 100%;
  background: transparent;
  font-size: 16px;
}
.search-toggle, .search-close { display: none; color: #fff; }
.top-actions { display: flex; align-items: center; gap: 8px; position: relative; }
.icon-btn, .btn {
  border: 0;
  cursor: pointer;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.icon-btn {
  width: 44px;
  height: 44px;
  background: transparent;
  color: inherit;
}
.menu-btn { display: none; color: #fff; }
.btn {
  min-height: 42px;
  padding: 0 16px;
  font-weight: 700;
  font-size: 14px;
}
.btn-primary { background: var(--upvote); color: #fff; box-shadow: 0 8px 18px rgba(255, 77, 26, .25); }
.btn-ghost { background: transparent; color: #fff; border: 1px solid rgba(255,255,255,.22); }
.btn-light { background: #fff; color: var(--navy); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-outline { background: #fff; color: var(--text); border: 1px solid var(--line); }
.avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  object-fit: cover;
  background: #dbeafe;
}
.avatar.lg { width: 76px; height: 76px; }
.avatar.sm { width: 32px; height: 32px; font-size: 13px; }

.shell {
  display: grid;
  grid-template-columns: 270px minmax(0, 1fr);
  gap: 18px;
  max-width: 1120px;
  margin: 20px auto 56px;
  padding: 0 16px;
}
.feed, #app {
  min-width: 0;
  max-width: 100%;
}
.sidebar, .card, .post, .panel {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid rgba(255,255,255,.7);
}
.sidebar { padding: 18px; height: fit-content; position: sticky; top: calc(var(--nav-h) + 16px); }
.side-title { font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); margin: 18px 0 8px; font-weight: 700; }
.side-title:first-child { margin-top: 0; }
.side-link, .chip {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  color: var(--text);
  padding: 10px;
  border-radius: 10px;
  cursor: pointer;
}
.side-link:hover, .side-link.active, .chip:hover, .chip.active { background: #e8f1fc; color: var(--brand); }
.chip-row { display: flex; flex-wrap: wrap; gap: 6px; max-width: 100%; }
.chip { width: auto; font-size: 12px; background: #f3f4f6; padding: 7px 11px; font-weight: 600; }
.muted { color: var(--muted); }
.about p { margin: 0 0 12px; font-size: 14px; color: #374151; line-height: 1.5; }
.side-logo {
  width: 92px;
  height: 92px;
  object-fit: contain;
  border-radius: 14px;
  margin: 0 auto 12px;
  background: #004b99;
}

.cat-scroll {
  display: none;
  gap: 8px;
  overflow-x: auto;
  padding: 2px 2px 12px;
  margin: 0 -4px 8px;
  scrollbar-width: none;
}
.cat-scroll::-webkit-scrollbar { display: none; }
.cat-scroll .chip { flex: 0 0 auto; background: #fff; box-shadow: var(--shadow); }

.sortbar {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
  flex-wrap: nowrap;
  overflow-x: auto;
  scrollbar-width: none;
}
.sortbar::-webkit-scrollbar { display: none; }
.sortbar button {
  background: var(--card);
  border: 0;
  border-radius: 999px;
  padding: 10px 16px;
  font-weight: 700;
  color: var(--muted);
  cursor: pointer;
  box-shadow: var(--shadow);
  flex: 0 0 auto;
}
.sortbar button.active { color: #fff; background: var(--brand); }

.post {
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr);
  margin-bottom: 14px;
  overflow: hidden;
  max-width: 100%;
}
.votes {
  background: linear-gradient(180deg, #f7f9fc, #eef2f7);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px 0;
  gap: 4px;
  font-weight: 800;
  font-size: 13px;
}
.vote {
  border: 0;
  background: transparent;
  color: #878a8c;
  cursor: pointer;
  width: 40px;
  height: 36px;
  border-radius: 10px;
}
.vote:hover { background: #e5e7eb; }
.vote.up.active, .score.up { color: var(--upvote); }
.vote.down.active, .score.down { color: var(--downvote); }
.post-body {
  padding: 14px 16px 16px;
  min-width: 0;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.meta { font-size: 12px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 6px; }
.meta a { color: inherit; font-weight: 700; }
.meta a:hover { color: var(--brand); }
.title {
  margin: 6px 0 8px;
  font-size: 20px;
  line-height: 1.25;
  letter-spacing: -0.03em;
  font-family: Fraunces, Georgia, serif;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.title a { color: inherit; }
.excerpt {
  margin: 0 0 10px;
  overflow-wrap: anywhere;
  word-break: break-word;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.body-text { white-space: pre-wrap; overflow-wrap: anywhere; word-break: break-word; font-size: 15px; line-height: 1.6; }
.post-image { margin: 8px 0 12px; border-radius: 12px; max-height: 420px; object-fit: cover; width: 100%; }
.actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.action {
  border: 0;
  background: #f3f5f8;
  color: var(--muted);
  font-weight: 700;
  font-size: 12px;
  cursor: pointer;
  padding: 8px 10px;
  border-radius: 999px;
}
.action:hover { background: #e8edf4; color: var(--text); }

.form { display: grid; gap: 12px; }
.form label { font-size: 13px; font-weight: 700; display: grid; gap: 6px; }
.form input, .form textarea, .form select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  background: #fff;
  font-size: 16px;
}
.form textarea { min-height: 160px; resize: vertical; }
.chip-picker { display: flex; flex-wrap: wrap; gap: 8px; }
.chip-picker .chip { border: 1px solid var(--line); }
.chip-picker .chip.active { background: var(--brand); color: #fff; }
.help { font-size: 12px; color: var(--muted); margin: 0; }
.error { color: var(--danger); font-size: 13px; min-height: 1.2em; }
.panel { padding: 22px; }
.panel h1, .page-head h1 {
  margin: 0 0 8px;
  font-size: 28px;
  font-family: Fraunces, Georgia, serif;
  letter-spacing: -0.03em;
}
.page-head { margin-bottom: 14px; }
.profile-head { display: flex; gap: 14px; align-items: center; }

.comments { margin-top: 16px; }
.comments h3 { margin: 0 0 14px; font-size: 20px; }
.comment-compose textarea { min-height: 96px; }
#comment-form .btn { width: 100%; }
.comment-compose-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}
.comment-compose-actions .btn { width: auto; min-width: 88px; }
.comment-list, #comment-list { display: grid; gap: 4px; }
.comment {
  display: block;
  margin: 0;
  padding: 14px 0 6px;
  border-top: 1px solid var(--line);
  min-width: 0;
}
#comment-list > .comment:first-child { border-top: 0; padding-top: 8px; }
.comment-main { min-width: 0; }
.comment-head {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.comment-avatar { flex-shrink: 0; line-height: 0; }
.comment-by {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 8px;
  min-width: 0;
  font-size: 13px;
  font-weight: 700;
}
.comment-by a { color: var(--text); }
.comment-by a:hover { color: var(--brand); }
.comment-by .muted { font-weight: 500; }
.comment-body {
  margin: 8px 0 0;
  padding-left: 42px;
}
.comment-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 10px 0 0;
  padding-left: 42px;
}
.comment-votes {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  background: #f3f5f8;
  border-radius: 999px;
  padding: 2px;
}
.comment-votes .vote {
  width: 36px;
  height: 36px;
  font-size: 12px;
}
.comment-votes .score {
  min-width: 1.6em;
  text-align: center;
  font-size: 13px;
  font-weight: 800;
}
.comment-toolbar .action { background: transparent; }
.comment .reply-slot { padding-left: 42px; margin-top: 10px; }
.comment-kids {
  margin: 8px 0 0 16px;
  padding-left: 14px;
  border-left: 2px solid var(--line);
}
.comment-kids .comment { padding-top: 12px; }
.activity-comment { margin-bottom: 12px; }
.activity-comment .comment-body { padding-left: 42px; }
.empty, .loading { text-align: center; padding: 48px 16px; color: var(--muted); }

.user-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #fff;
  background: transparent;
  border: 0;
  cursor: pointer;
  padding: 4px 8px 4px 4px;
  border-radius: 999px;
}
.user-chip:hover, .user-menu.open .user-chip { background: rgba(255,255,255,.1); }
.user-caret { font-size: 10px; opacity: .7; }
.user-menu { position: relative; }
.user-menu-panel {
  display: none;
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  min-width: 220px;
  padding: 8px;
  background: #fff;
  color: var(--text);
  border-radius: 14px;
  box-shadow: 0 16px 40px rgba(15, 23, 42, 0.18);
  border: 1px solid var(--line);
  z-index: 80;
}
.user-menu.open .user-menu-panel { display: grid; }
.user-menu-panel a,
.user-menu-panel button {
  display: flex;
  align-items: center;
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  color: var(--text);
  font-weight: 700;
  font-size: 14px;
  padding: 12px 12px;
  border-radius: 10px;
  cursor: pointer;
  min-height: 44px;
}
.user-menu-panel a:hover,
.user-menu-panel button:hover { background: #e8f1fc; color: var(--brand); }
.user-menu-panel button { color: var(--danger); }
.user-menu-panel button:hover { background: #fef2f2; color: var(--danger); }
.profile-tabs {
  display: flex;
  gap: 8px;
  margin: 0 0 14px;
}
.profile-tabs a {
  padding: 8px 14px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 13px;
  background: var(--card);
  color: var(--muted);
  box-shadow: var(--shadow);
}
.profile-tabs a.active { background: var(--brand); color: #fff; }
#account-settings h2 { margin: 0 0 14px; font-size: 20px; }
#account-settings h3 { margin: 28px 0 8px; }
.admin-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.admin-table th, .admin-table td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); }
.notice {
  background: #e8f1fc;
  border: 1px solid #c9ddf5;
  color: #123056;
  border-radius: 14px;
  padding: 14px 16px;
  margin-bottom: 14px;
  font-size: 14px;
  line-height: 1.5;
}
.notice.warn { background: #fff7ed; border-color: #fed7aa; color: #9a3412; }
.notice.ok { background: #ecfdf5; border-color: #a7f3d0; color: #065f46; }
.badge-trial,
.badge-member,
.badge-rejected,
.badge-admin {
  display: inline-flex;
  align-items: center;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .04em;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 999px;
}
.badge-trial { background: #fff7ed; color: #c2410c; }
.badge-member { background: #ecfdf5; color: #047857; }
.badge-rejected { background: #fef2f2; color: #b91c1c; }
.badge-admin { background: #e8f1fc; color: var(--brand); }
.admin-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.admin-search {
  display: grid;
  gap: 6px;
  font-size: 13px;
  font-weight: 700;
  margin: 16px 0 14px;
}
.admin-search input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 16px;
}
.user-list, .whitelist-list { display: grid; gap: 10px; margin-bottom: 8px; }
.user-card {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #f8fafc;
  min-width: 0;
}
.user-card.compact { padding: 12px 14px; }
.user-card-body { min-width: 0; flex: 1; }
.user-card-top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}
.user-card-meta {
  margin: 6px 0 0;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.user-card .admin-actions { margin-top: 10px; }
.tag-add-form { grid-template-columns: 1fr auto; align-items: end; }

.site-footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 16px 24px;
  max-width: 1120px;
  margin: 8px auto 24px;
  padding: 16px 16px calc(16px + var(--tab-h) + var(--safe-bottom));
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}
.site-footer a { color: var(--muted); }
.site-footer a:hover { color: var(--brand); }
.tabbar { display: none; }
.drawer-backdrop { display: none; }
.legal {
  max-width: 760px;
  margin: 24px auto 48px;
  padding: 28px;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.legal h1 {
  font-family: Fraunces, Georgia, serif;
  letter-spacing: -0.03em;
  margin: 0 0 16px;
}
.legal h2 { font-size: 18px; margin: 28px 0 10px; color: var(--navy); }
.legal h3 { font-size: 15px; margin: 16px 0 8px; }
.legal p, .legal li { line-height: 1.65; font-size: 15px; }
.legal ul { padding-left: 1.2em; }
.legal-footer { padding-bottom: calc(16px + var(--safe-bottom)); }

@media (min-width: 861px) {
  .site-footer {
    gap: 28px;
    margin: 0 auto 40px;
    padding: 18px 16px 8px;
    font-size: 14px;
  }
}
.drawer-backdrop { display: none; }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(20px + var(--tab-h) + var(--safe-bottom));
  transform: translateX(-50%);
  background: var(--navy);
  color: #fff;
  padding: 12px 18px;
  border-radius: 999px;
  z-index: 98;
  box-shadow: var(--shadow);
  max-width: calc(100vw - 32px);
  text-align: center;
  font-weight: 600;
}
.toast[hidden] { display: none !important; }

.intro-modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 90;
  background: rgba(7, 22, 40, 0.72);
  padding: max(12px, var(--safe-top)) 12px max(12px, var(--safe-bottom));
  align-items: center;
  justify-content: center;
}
html.show-intro,
html.show-intro body { overflow: hidden; }
html.show-intro .intro-modal { display: flex; }
.intro-dialog {
  width: min(720px, 100%);
  max-height: min(92dvh, 900px);
  background: #fff;
  border-radius: 20px;
  box-shadow: 0 24px 64px rgba(11, 31, 58, 0.35);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.intro-brand {
  display: flex;
  justify-content: center;
  align-items: center;
  background: #546980;
  padding: 18px 16px;
  flex-shrink: 0;
}
.intro-logo {
  width: 112px;
  height: 112px;
  object-fit: contain;
  border-radius: 16px;
  background: #004b99;
}
.intro-scroll {
  overflow: auto;
  padding: 24px 28px 16px;
  -webkit-overflow-scrolling: touch;
}
.intro-scroll h1 {
  font-family: Fraunces, Georgia, serif;
  font-size: 30px;
  line-height: 1.2;
  letter-spacing: -0.03em;
  margin: 0 0 16px;
}
.intro-scroll h2 { font-size: 18px; margin: 22px 0 10px; color: var(--navy); }
.intro-scroll p { margin: 0 0 12px; line-height: 1.65; font-size: 15px; }
.intro-close-line { font-size: 18px !important; text-align: center; margin: 24px 0 8px !important; }
.intro-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 20px calc(16px + var(--safe-bottom));
  border-top: 1px solid var(--line);
  background: #fff;
}
.intro-hide {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--text);
  cursor: pointer;
  user-select: none;
}
.intro-hide input { width: 18px; height: 18px; accent-color: var(--brand); }

.auth-gate {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 85;
  background: rgba(7, 22, 40, 0.72);
  padding: max(12px, var(--safe-top)) 12px max(12px, var(--safe-bottom));
  align-items: center;
  justify-content: center;
}
html.show-auth-gate,
html.show-auth-gate body { overflow: hidden; }
html.show-auth-gate .auth-gate { display: flex; }
html.show-intro .auth-gate { display: none; }
.auth-gate-dialog {
  width: min(440px, 100%);
  max-height: min(92dvh, 900px);
  overflow: auto;
  background: #fff;
  border-radius: 20px;
  box-shadow: 0 24px 64px rgba(11, 31, 58, 0.35);
  padding: 22px 22px 18px;
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.auth-gate-close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 40px;
  height: 40px;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  border-radius: 999px;
}
.auth-gate-close:hover { background: #f3f4f6; color: var(--text); }
.auth-tabs {
  display: flex;
  gap: 8px;
  margin: 0 36px 16px 0;
}
.auth-tabs button {
  flex: 1;
  border: 0;
  background: #f3f4f6;
  color: var(--muted);
  font-weight: 700;
  padding: 10px 12px;
  border-radius: 999px;
  cursor: pointer;
}
.auth-tabs button.active { background: var(--brand); color: #fff; }
.auth-skip {
  display: block;
  width: 100%;
  margin-top: 12px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-weight: 700;
  cursor: pointer;
  padding: 10px;
}
.auth-skip:hover { color: var(--brand); }

.install-prompt {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 92;
  background: rgba(7, 22, 40, 0.72);
  padding: max(12px, var(--safe-top)) 12px max(12px, var(--safe-bottom));
  align-items: center;
  justify-content: center;
}
html.show-install .install-prompt { display: flex; }
html.show-intro .install-prompt { display: none; }
.install-dialog {
  width: min(400px, 100%);
  background: #fff;
  border-radius: 20px;
  box-shadow: 0 24px 64px rgba(11, 31, 58, 0.35);
  padding: 28px 22px 18px;
  text-align: center;
}
.install-logo {
  width: 88px;
  height: 88px;
  border-radius: 20px;
  margin: 0 auto 16px;
  background: #004b99;
}
.install-dialog h2 {
  margin: 0 0 8px;
  font-family: Fraunces, Georgia, serif;
  letter-spacing: -0.03em;
  font-size: 24px;
}
.install-dialog .btn { width: 100%; margin-top: 8px; }

.crop-modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 96;
  background: rgba(7, 22, 40, 0.78);
  padding: max(12px, var(--safe-top)) 12px max(12px, var(--safe-bottom));
  align-items: center;
  justify-content: center;
}
html.show-crop .crop-modal { display: flex; }
html.show-crop,
html.show-crop body { overflow: hidden; }
.crop-dialog {
  width: min(420px, 100%);
  background: #fff;
  border-radius: 20px;
  padding: 20px 18px 16px;
  box-shadow: 0 24px 64px rgba(11, 31, 58, 0.35);
}
.crop-dialog h2 {
  margin: 0 0 6px;
  font-family: Fraunces, Georgia, serif;
  font-size: 22px;
}
.crop-stage {
  position: relative;
  width: min(280px, 72vw);
  height: min(280px, 72vw);
  margin: 16px auto;
  overflow: hidden;
  border-radius: 50%;
  background: #111;
  touch-action: none;
  cursor: grab;
  user-select: none;
}
.crop-stage:active { cursor: grabbing; }
.crop-stage img {
  position: absolute;
  left: 50%;
  top: 50%;
  max-width: none;
  transform-origin: center center;
  pointer-events: none;
}
.crop-hole {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  box-shadow: 0 0 0 999px rgba(0,0,0,.28);
  pointer-events: none;
}
.crop-zoom-label {
  display: grid;
  gap: 8px;
  font-size: 13px;
  font-weight: 700;
  margin: 8px 8px 16px;
}
.crop-actions { display: flex; gap: 8px; }
.crop-actions .btn { flex: 1; }
.avatar-picker {
  display: flex;
  align-items: center;
  gap: 14px;
}
.avatar-preview {
  width: 76px;
  height: 76px;
  border-radius: 50%;
  overflow: hidden;
  background: #dbeafe;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--brand);
  font-size: 28px;
  flex-shrink: 0;
}
.avatar-preview img { width: 100%; height: 100%; object-fit: cover; }
.avatar-pick-btn { position: relative; overflow: hidden; }
.avatar-pick-btn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

@media (max-width: 860px) {
  :root { --tab-h: 64px; }
  html.drawer-open,
  html.drawer-open body {
    overflow: hidden;
    touch-action: none;
  }
  .menu-btn, .search-toggle { display: inline-flex; }
  .brand { display: none; }
  .topbar-right { gap: 4px; }
  .search {
    display: none;
    position: absolute;
    left: 12px;
    right: 12px;
    top: calc(8px + var(--safe-top));
    width: auto;
    max-width: none;
    flex: none;
    z-index: 5;
  }
  .search.open { display: flex; }
  .search-close { display: inline-flex; color: var(--text); width: 36px; height: 36px; }
  .top-actions .btn-ghost, .top-actions .btn-label, .top-actions .btn-primary { display: none; }
  .user-chip { display: flex; }
  .user-menu { display: block; }
  .shell { grid-template-columns: minmax(0, 1fr); margin: 12px auto 24px; overflow-x: hidden; }
  .cat-scroll {
    display: flex;
    max-width: 100%;
    touch-action: pan-x;
    -webkit-overflow-scrolling: touch;
  }
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    height: 100dvh;
    max-height: 100dvh;
    width: min(86vw, 340px);
    z-index: 60;
    transform: translateX(-110%);
    transition: transform .22s ease;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    touch-action: pan-y;
    border-radius: 0 20px 20px 0;
    padding-top: calc(18px + var(--safe-top));
    padding-bottom: calc(28px + var(--tab-h) + var(--safe-bottom));
  }
  .sidebar.open { transform: translateX(0); }
  .drawer-backdrop.open {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, .45);
    z-index: 55;
  }
  .post {
    grid-template-columns: minmax(0, 1fr);
  }
  .post > .votes {
    flex-direction: row;
    justify-content: flex-start;
    padding: 8px 12px 0;
    background: transparent;
    gap: 6px;
  }
  .post > .votes .vote { width: 44px; height: 44px; }
  .title { font-size: 18px; }
  .panel { padding: 16px; }
  .panel h1, .page-head h1 { font-size: 24px; }
  .tabbar {
    display: grid;
    grid-template-columns: 1fr 1fr 56px 1fr;
    align-items: center;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 70;
    height: calc(var(--tab-h) + var(--safe-bottom));
    padding: 0 8px var(--safe-bottom);
    background: rgba(255,255,255,.92);
    backdrop-filter: blur(16px);
    border-top: 1px solid var(--line);
  }
  .tabbar a, .tabbar button {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    min-width: 0;
    color: var(--muted);
    background: none;
    border: 0;
    font-size: 11px;
    font-weight: 700;
  }
  .tabbar a.active, .tabbar button.active, .tabbar a:hover { color: var(--brand); }
  .tabbar i { font-size: 18px; }
  .tabbar .tab-post {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    justify-self: center;
    align-self: center;
    width: 48px;
    height: 48px;
    min-width: 48px;
    min-height: 48px;
    padding: 0;
    margin: 0;
    color: #fff;
    background: var(--upvote);
    border-radius: 14px;
    box-shadow: 0 8px 16px rgba(255, 77, 26, .3);
  }
  .tabbar .tab-post i { font-size: 20px; color: #fff; line-height: 1; }
  .tabbar .tab-post.active,
  .tabbar .tab-post:hover { color: #fff; background: var(--upvote); }
  .intro-modal { padding: 0; align-items: stretch; }
  .intro-dialog {
    width: 100%;
    max-height: 100dvh;
    border-radius: 0;
  }
  .intro-logo { width: 88px; height: 88px; }
}

@media (max-width: 520px) {
  .topbar { gap: 6px; padding-left: 10px; padding-right: 10px; }
  .comment-body, .comment-toolbar, .comment .reply-slot { padding-left: 0; }
  .comment-kids { margin-left: 8px; padding-left: 10px; }
  .tag-add-form { grid-template-columns: 1fr; }
  .intro-scroll { padding: 18px 16px 12px; }
  .intro-scroll h1 { font-size: 24px; }
  .intro-footer { flex-direction: column; align-items: stretch; }
  .intro-footer .btn { width: 100%; min-height: 48px; }
  .auth-gate { padding: 0; align-items: stretch; }
  .auth-gate-dialog {
    width: 100%;
    min-height: 100dvh;
    max-height: none;
    border-radius: 0;
    padding: calc(18px + var(--safe-top)) 16px calc(18px + var(--safe-bottom));
    justify-content: safe center;
    overflow-y: auto;
  }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .sidebar { transition: none; }
}
