:root {
  color-scheme: dark;
  --bg: #000;
  --bg-elev: #000;
  --text: #e7e9ea;
  --muted: #71767b;
  --line: #2f3336;
  --hover: rgba(231, 233, 234, 0.08);
  --accent: #1d9bf0;
  --accent-hover: #1a8cd8;
  --like: #f91880;
  --like-bg: rgba(249, 24, 128, 0.12);
  --reply: #1d9bf0;
  --reply-bg: rgba(29, 155, 240, 0.12);
  --danger: #f4212e;
  --chip: #16181c;
  --font: "Segoe UI", "PingFang SC", "Noto Sans SC", "WenQuanYi Micro Hei", "Droid Sans Fallback", sans-serif;
  --nav: 260px;
  --feed: 600px;
  --rail: 320px;
}

html[data-theme="light"] {
  color-scheme: light;
  --bg: #fff;
  --bg-elev: #fff;
  --text: #0f1419;
  --muted: #536471;
  --line: #eff3f4;
  --hover: rgba(15, 20, 25, 0.06);
  --chip: #f7f9f9;
  --like-bg: rgba(249, 24, 128, 0.1);
  --reply-bg: rgba(29, 155, 240, 0.1);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; min-height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.4;
}
button, input, textarea { font: inherit; color: inherit; }
p { margin: 0; }
a { color: inherit; text-decoration: none; }
a:hover { text-decoration: underline; }
::selection { background: rgba(29, 155, 240, 0.35); }
.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  border: 0;
}
.skip {
  position: absolute;
  left: 12px;
  top: -40px;
  background: var(--accent);
  color: #fff;
  padding: 8px 12px;
  border-radius: 999px;
}
.skip:focus { top: 8px; z-index: 20; }

.app {
  display: grid;
  grid-template-columns: var(--nav) var(--feed) var(--rail);
  justify-content: center;
  min-height: 100vh;
}

.nav {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 8px 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.logo {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.04em;
  padding: 12px;
  width: fit-content;
  border-radius: 999px;
  text-decoration: none;
}
.logo:hover { background: var(--hover); text-decoration: none; }
.nav-links { display: flex; flex-direction: column; gap: 2px; flex: 1; min-height: 0; overflow: auto; }
.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  border-radius: 999px;
  font-size: 16px;
  font-weight: 500;
  background: transparent;
  border: 0;
  cursor: pointer;
  text-align: left;
  text-decoration: none;
  color: var(--text);
}
.nav-link svg { width: 22px; height: 22px; fill: currentColor; flex: 0 0 auto; }
.nav-link:hover, .more summary:hover { background: var(--hover); text-decoration: none; }
.nav-link.is-current { font-weight: 800; background: var(--hover); }
.badge {
  margin-left: auto;
  background: var(--accent);
  color: #fff;
  border-radius: 999px;
  min-width: 18px;
  padding: 0 6px;
  font-size: 12px;
  font-style: normal;
  text-align: center;
}
.more { margin: 0; }
.more summary { list-style: none; cursor: pointer; }
.more summary::-webkit-details-marker { display: none; }
.more-menu { display: flex; flex-direction: column; padding: 0 0 8px 46px; gap: 6px; }
.more-menu a, .more-menu button {
  background: none;
  border: 0;
  color: var(--text);
  text-align: left;
  padding: 6px 0;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
}
.search-bar, .result-block { border-bottom: 1px solid var(--line); }
.search-bar { display: flex; gap: 8px; padding: 12px 16px; }
.search-bar input, .auth-card textarea, .longform { width: 100%; }
.search-bar input {
  flex: 1;
  border: 1px solid var(--line);
  background: transparent;
  border-radius: 999px;
  padding: 10px 14px;
}
.result, .notice { display: flex; flex-direction: column; gap: 4px; padding: 12px 16px; border-bottom: 1px solid var(--line); text-decoration: none; }
.result:hover { background: var(--hover); text-decoration: none; }
.empty-inline, .result-block { padding: 12px 16px; }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; padding: 16px; }
.stats p { margin: 0; border: 1px solid var(--line); border-radius: 16px; padding: 16px; }
.stats strong { display: block; font-size: 28px; }
.stats span, .empty-inline { color: var(--muted); }
.dm { display: grid; }
.bubble { border: 1px solid var(--line); border-radius: 16px; padding: 10px 12px; margin: 8px 16px; max-width: 80%; }
.bubble.mine { margin-left: auto; background: rgba(29, 155, 240, 0.12); }
.bubble time { display: block; color: var(--muted); font-size: 12px; }
.longform { padding: 16px; }
.auth-card textarea { min-height: 140px; border: 1px solid var(--line); border-radius: 12px; background: transparent; padding: 12px; }
.tabbar .is-current { color: var(--accent); }
.tick { width: 16px; height: 16px; margin-left: 2px; vertical-align: -2px; }
.byline .tick { margin-left: 0; }
.author { display: inline-flex; align-items: center; }
.nav-account { margin-top: auto; display: flex; flex-direction: column; gap: 8px; }
.account-chip {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  border-radius: 999px;
  text-decoration: none;
}
.account-chip:hover { background: var(--hover); text-decoration: none; }
.account-chip strong { display: block; font-size: 15px; }
.account-chip small, .fine, .count, .status, .picked { color: var(--muted); }
.account-chip small { font-size: 13px; }

.column {
  border-left: 1px solid var(--line);
  border-right: 1px solid var(--line);
  min-height: 100vh;
  min-width: 0;
}
.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  backdrop-filter: blur(12px);
  background: var(--bg);
  border-bottom: 1px solid var(--line);
  padding: 0 16px;
  height: 53px;
  display: flex;
  align-items: center;
}
.topbar h1, .profile-head h2, .auth-card h2, .empty h2, .panel h2 {
  margin: 0;
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.banner, .composer, .auth-card, .profile-head {
  padding: 12px 16px 16px;
  border-bottom: 1px solid var(--line);
}
.banner {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}
.banner > div:first-child { flex: 1; min-width: 0; }
.banner-actions { display: flex; gap: 8px; flex-shrink: 0; }
.pay-qr {
  display: block;
  width: min(220px, 100%);
  height: auto;
  margin: 8px 0 12px;
  background: #fff;
  border-radius: 12px;
}
.price-hkd { font-size: 32px; font-weight: 800; margin: 8px 0; letter-spacing: -0.03em; }
.price-hkd span { font-size: 15px; font-weight: 500; color: var(--muted); }
.perks {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 10px 0 12px;
  padding: 0;
  list-style: none;
  scroll-margin-top: 64px;
}
.perks li {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 12px;
  font-weight: 700;
}
.pay-panel { margin-top: 12px; }
.ad-slot {
  margin: 12px 16px;
  padding: 12px 14px;
  border: 1px dashed var(--line);
  border-radius: 16px;
}
.ad-mark {
  display: inline-block;
  margin: 0 0 4px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
}
.banner p, .lede { margin: 4px 0 0; color: var(--muted); }
.banner strong { font-size: 17px; }
.banner-actions, .composer-foot, .ritual-actions { display: flex; align-items: center; gap: 8px; }

.composer-row, .post-body { display: flex; gap: 12px; }
.grow { flex: 1; min-width: 0; }
.composer textarea {
  width: 100%;
  border: 0;
  resize: none;
  min-height: 72px;
  background: transparent;
  padding: 12px 0 0;
  font-size: 20px;
  line-height: 1.35;
  outline: none;
}
.composer textarea::placeholder, .reply textarea::placeholder, .field input::placeholder { color: var(--muted); }

.choices {
  border: 0;
  margin: 8px 0 0;
  padding: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.choices legend { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.choice {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 10px 12px;
  cursor: pointer;
}
.choice input { margin-top: 3px; accent-color: var(--accent); }
.choice strong { display: block; }
.choice small { display: block; color: var(--muted); font-size: 13px; line-height: 1.35; }
.choice:has(input:checked) { border-color: var(--accent); background: rgba(29, 155, 240, 0.08); }
.choice.is-disabled { opacity: 0.55; cursor: not-allowed; }
.composer-foot { justify-content: flex-end; margin-top: 8px; }
.form-error { color: var(--danger); margin: 0; flex: 1; }
.form-error:empty { display: none; }

.btn {
  border: 0;
  border-radius: 999px;
  padding: 8px 16px;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  flex-shrink: 0;
}
.btn:hover { text-decoration: none; }
.btn:disabled { opacity: 0.5; cursor: progress; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-ghost { background: transparent; color: var(--text); border: 1px solid var(--line); }
.btn-ghost:hover { background: var(--hover); }
.btn-block { width: 100%; margin-top: 8px; min-height: 44px; }
.text-button {
  background: none;
  border: 0;
  color: var(--accent);
  cursor: pointer;
  padding: 0;
  font-weight: 700;
}

.avatar {
  width: 40px;
  height: 40px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  font-weight: 700;
  color: #fff;
  flex: 0 0 auto;
}
.avatar-lg { width: 72px; height: 72px; font-size: 28px; }
.hue-0 { background: #1d9bf0; }
.hue-1 { background: #7856ff; }
.hue-2 { background: #ff7a00; }
.hue-3 { background: #00ba7c; }
.hue-4 { background: #f91880; }
.hue-5 { background: #5b7083; }
.hue-6 { background: #e0245e; }
.hue-7 { background: #17bf63; }

.card { border-bottom: 1px solid var(--line); }
.card:hover { background: var(--hover); }
.post-body { padding: 12px 16px 4px; }
.post-main { min-width: 0; flex: 1; }
.byline {
  display: flex;
  flex-wrap: wrap;
  gap: 2px 6px;
  align-items: baseline;
  min-width: 0;
}
.author { font-weight: 800; }
.handle, .mode, time { color: var(--muted); }
.author:hover, .handle:hover { text-decoration: underline; }
.text { margin: 4px 0 8px; font-size: 15px; white-space: pre-wrap; overflow-wrap: anywhere; }
.actions { display: flex; gap: 8px; max-width: 320px; margin: 0 0 4px -8px; }
.act {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 0;
  background: transparent;
  color: var(--muted);
  border-radius: 999px;
  padding: 6px 8px;
  cursor: pointer;
  text-decoration: none;
  font-size: 13px;
}
.act svg { width: 18px; height: 18px; fill: currentColor; }
.act:hover { color: var(--reply); background: var(--reply-bg); text-decoration: none; }
.act-like:hover, .act-like.is-liked { color: var(--like); background: var(--like-bg); }
.act-text { padding-left: 0; font-weight: 700; }
.comment { margin-top: 8px; }
.comment[data-depth="1"] { margin-left: 24px; }
.comment[data-depth="2"], .comment[data-depth="3"] { margin-left: 24px; }
.comment .post-body { padding: 8px 0; }
.reply { margin: 8px 0 12px; }
.reply textarea, .field input {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--bg);
  border-radius: 8px;
  padding: 12px;
}
.reply textarea { min-height: 72px; resize: vertical; }
.field { display: block; margin-top: 12px; }
.field > span { display: block; margin-bottom: 6px; font-weight: 700; font-size: 14px; }
.replying { margin: 0 0 8px; color: var(--accent); }

.empty { padding: 40px 24px; }
.empty p { color: var(--muted); }
.profile-head { display: flex; gap: 16px; align-items: center; }
.auth-card { max-width: 100%; }
.auth-card .lede { margin-bottom: 8px; }

.rail { padding: 12px 16px 16px 24px; }
.panel {
  background: var(--chip);
  border-radius: 16px;
  padding: 16px;
}
.panel p { color: var(--muted); }
.panel h2 { margin-bottom: 8px; }

.tabbar { display: none; }
.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  background: var(--accent);
  color: #fff;
  border-radius: 8px;
  padding: 12px 16px;
  z-index: 40;
  max-width: min(480px, calc(100% - 24px));
}
.ritual {
  position: fixed;
  inset: 0;
  background: rgba(91, 112, 131, 0.4);
  display: grid;
  place-items: center;
  z-index: 50;
  padding: 16px;
}
.ritual-card {
  width: min(480px, 100%);
  background: var(--bg);
  border-radius: 16px;
  padding: 16px;
  border: 1px solid var(--line);
}
.tiles { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
.tile {
  width: 48px;
  height: 48px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: transparent;
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
}
.tile:hover { background: var(--reply-bg); }
.tile:disabled { opacity: 0.35; }
.bar { height: 4px; background: var(--line); border-radius: 999px; overflow: hidden; }
.bar span { display: block; height: 100%; width: 0; background: var(--accent); }
.trap {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

@media (max-width: 1080px) {
  .app { grid-template-columns: var(--nav) minmax(0, var(--feed)); }
  .rail { display: none; }
}
@media (max-width: 700px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .nav { display: none; }
  .column { border: 0; }
  .tabbar {
    display: flex;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    height: 52px;
    border-top: 1px solid var(--line);
    background: var(--bg);
    z-index: 10;
    align-items: center;
    justify-content: space-around;
  }
  .tabbar a, .tabbar button {
    background: none;
    border: 0;
    color: var(--text);
    font-weight: 700;
    text-decoration: none;
    padding: 8px;
  }
  body { padding-bottom: 60px; }
  .banner, .choices { display: grid; grid-template-columns: 1fr; }
  .composer textarea { font-size: 18px; }
  .comment[data-depth="1"],
  .comment[data-depth="2"],
  .comment[data-depth="3"] { margin-left: 12px; }
  .toast { bottom: 68px; }
}
@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto; }
}
