[hidden] { display: none !important; }
:root {
  --bg: #ffffff; --surface: #f5f6f8; --surface-2: #eceef2; --text: #14161a; --muted: #687080; --border: #e3e6eb;
  --accent: #ff4f5e; --accent-text: #ffffff; --link: #2f6fde; --danger: #d23b3b;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Times New Roman", serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --radius: 14px; --top: 56px; --tab: 58px;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0f1114; --surface: #181b20; --surface-2: #22262d; --text: #eef0f3; --muted: #9098a6; --border: #262a31; --link: #7aa7ff; }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 var(--sans); padding-top: var(--top); padding-bottom: calc(var(--tab) + env(safe-area-inset-bottom)); overscroll-behavior-y: contain; }
body.has-composer { padding-bottom: calc(var(--tab) + 120px + env(safe-area-inset-bottom)); }
a { color: var(--link); }
button { font: inherit; color: inherit; cursor: pointer; }
input, select, textarea { font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 9px 11px; }
.muted { color: var(--muted); } .small { font-size: 13px; } .center { text-align: center; } .grow { flex: 1; min-width: 0; }

.topbar { position: fixed; inset: 0 0 auto 0; height: calc(var(--top) + env(safe-area-inset-top)); padding: env(safe-area-inset-top) 16px 0; display: flex; align-items: center; justify-content: space-between; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border-bottom: 1px solid var(--border); z-index: 20; }
body { padding-top: calc(var(--top) + env(safe-area-inset-top)); }
.logo { display: flex; align-items: center; gap: 8px; text-decoration: none; color: var(--text); font-weight: 800; letter-spacing: -0.02em; font-size: 19px; }
.logo img { border-radius: 8px; }
.top-actions { display: flex; gap: 4px; }
.icon-btn { display: inline-grid; place-items: center; min-width: 40px; height: 40px; border-radius: 12px; border: 0; background: transparent; text-decoration: none; font-size: 18px; color: var(--text); }
.icon-btn:hover { background: var(--surface); }

main { max-width: 640px; margin: 0 auto; }
.tabbar { position: fixed; inset: auto 0 0 0; height: calc(var(--tab) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom); display: flex; background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border-top: 1px solid var(--border); z-index: 20; }
.tabbar a { flex: 1; display: grid; place-items: center; text-decoration: none; color: var(--muted); font-weight: 600; font-size: 14px; }
.tabbar a.active { color: var(--text); }
.fab { position: fixed; right: max(16px, calc(50vw - 320px + 16px)); bottom: calc(var(--tab) + 18px + env(safe-area-inset-bottom)); width: 58px; height: 58px; border-radius: 50%; border: 0; background: var(--accent); color: var(--accent-text); font-size: 30px; line-height: 1; box-shadow: 0 8px 24px rgba(255, 79, 94, .4); z-index: 21; }
.fab:active { transform: scale(.95); }

.chips { display: flex; gap: 8px; overflow-x: auto; padding: 12px 16px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; border: 1px solid var(--border); background: var(--bg); border-radius: 999px; padding: 6px 14px; font-weight: 600; font-size: 14px; max-width: 220px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chip.on { background: var(--text); color: var(--bg); border-color: var(--text); }

.post { padding: 14px 16px 12px; border-bottom: 1px solid var(--border); }
.post-head { display: flex; gap: 10px; align-items: center; margin-bottom: 8px; }
.post-head .meta { min-width: 0; line-height: 1.3; }
.post-head .meta b { font-size: 15px; }
.avatar { flex: none; width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-weight: 800; font-size: 13px; letter-spacing: -0.02em; }
.avatar.book { border-radius: 10px; font-size: 17px; }
.avatar.you { background: var(--surface-2); color: var(--text); font-size: 11px; }
.excerpt { font-family: var(--serif); font-size: 18px; line-height: 1.6; cursor: pointer; overflow-wrap: break-word; }
.excerpt p { margin: 0 0 .7em; }
.excerpt.clamp { max-height: 17.5em; overflow: hidden; -webkit-mask-image: linear-gradient(#000 70%, transparent); mask-image: linear-gradient(#000 70%, transparent); }
.post.full .excerpt { cursor: auto; }
.linkish { border: 0; background: none; color: var(--link); padding: 0; font-weight: 600; }
.actions { display: flex; gap: 4px; margin: 6px -8px 2px; }
.act { border: 0; background: transparent; border-radius: 999px; padding: 6px 10px; display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 15px; }
.act:hover { background: var(--surface); color: var(--text); }
.act.liked { color: var(--accent); }
.preview { display: flex; gap: 10px; background: var(--surface); border-radius: var(--radius); padding: 10px 12px; margin-top: 6px; cursor: pointer; font-size: 14.5px; }
.preview .avatar { width: 28px; height: 28px; font-size: 11px; }
.typing .dots::after { content: '…'; animation: dots 1.2s steps(4) infinite; display: inline-block; width: 1.2em; overflow: hidden; vertical-align: bottom; }
@keyframes dots { 0% { width: 0 } 100% { width: 1.2em } }
.feed-end { padding: 24px 16px 40px; }
.end-card { text-align: center; padding: 20px; border: 1px dashed var(--border); border-radius: var(--radius); }

.btn { border: 1px solid var(--border); background: var(--surface); border-radius: 12px; padding: 10px 16px; font-weight: 700; }
.btn.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.btn.ghost { background: transparent; }
.btn.danger { background: transparent; color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, transparent); }
.btn.full { width: 100%; margin-top: 8px; }
.btn.small { padding: 6px 12px; font-size: 14px; }
.btn:disabled { opacity: .5; cursor: default; }
.badge { background: #ffe9a8; color: #6b4e00; border-radius: 6px; padding: 1px 6px; font-size: 12px; font-weight: 700; }

.welcome { padding: 32px 20px; text-align: center; }
.welcome h1 { font-size: 30px; line-height: 1.15; letter-spacing: -0.03em; margin: 8px 0; }
.welcome .lead { color: var(--muted); font-size: 17px; max-width: 460px; margin: 0 auto 20px; }
.hero-logo { font-size: 46px; }
.drop { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 26px 16px; margin: 12px 16px 14px; border: 2px dashed var(--border); border-radius: 18px; cursor: pointer; text-align: center; background: var(--surface); }
.welcome .drop { margin: 0 0 14px; }
.drop.over { border-color: var(--accent); }
.drop-icon { font-size: 28px; }
.progress { width: 100%; max-width: 280px; height: 6px; background: var(--surface-2); border-radius: 3px; overflow: hidden; margin-top: 8px; }
.progress div { height: 100%; width: 0; background: var(--accent); transition: width .2s; }

.page-title { font-size: 24px; letter-spacing: -0.02em; margin: 18px 16px 4px; }
.book-list { padding: 0 16px 20px; }
.book-row { display: flex; gap: 12px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--border); }
.bar { height: 4px; background: var(--surface-2); border-radius: 2px; overflow: hidden; margin: 6px 0 2px; }
.bar div { height: 100%; background: var(--accent); }
.row-actions { display: flex; gap: 4px; align-items: center; }

.card { margin: 12px 16px; padding: 14px 16px; border: 1px solid var(--border); border-radius: var(--radius); }
.card h2 { font-size: 16px; margin: 0 0 8px; }
.card p { margin: 6px 0; }
.row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.row input { flex: 1; min-width: 160px; }
.field { display: grid; gap: 4px; margin: 8px 0; font-size: 14px; }
.toggle { display: flex; gap: 10px; align-items: flex-start; margin: 10px 0; font-size: 14px; }
.toggle input { margin-top: 3px; width: 18px; height: 18px; accent-color: var(--accent); }
.toggle.disabled { opacity: .55; }
details summary { cursor: pointer; color: var(--link); margin-top: 8px; }

.detail-top { position: sticky; top: calc(var(--top) + env(safe-area-inset-top)); display: flex; align-items: center; gap: 6px; padding: 4px 8px; background: var(--bg); z-index: 5; font-weight: 700; border-bottom: 1px solid var(--border); }
.invite-row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 4px; }
.pchip { border: 1px solid color-mix(in srgb, var(--c) 50%, transparent); color: var(--c); background: color-mix(in srgb, var(--c) 10%, transparent); border-radius: 999px; padding: 4px 10px; font-weight: 700; font-size: 13px; }
.comments { padding: 8px 16px 24px; }
.thread { padding: 6px 0; border-bottom: 1px solid var(--border); }
.replies { margin-left: 44px; border-left: 2px solid var(--surface-2); padding-left: 10px; }
.replies .avatar { width: 28px; height: 28px; font-size: 11px; }
.comment { display: flex; gap: 10px; padding: 8px 0; }
.bubble { min-width: 0; flex: 1; }
.ctext { white-space: pre-wrap; overflow-wrap: break-word; margin-top: 2px; }
.mention-tag { color: var(--link); font-weight: 600; }
.cactions { display: flex; gap: 14px; margin-top: 4px; }
.cactions button { border: 0; background: none; padding: 0; color: var(--muted); font-weight: 600; font-size: 13px; }
.cactions button:hover { color: var(--text); }

.composer { position: fixed; left: 0; right: 0; bottom: calc(var(--tab) + env(safe-area-inset-bottom)); background: var(--bg); border-top: 1px solid var(--border); padding: 8px 12px; z-index: 19; }
.composer > * { max-width: 616px; margin-left: auto; margin-right: auto; }
.composer-row { display: flex; gap: 8px; align-items: flex-end; }
.composer textarea { flex: 1; resize: none; border-radius: 20px; padding: 10px 14px; max-height: 140px; line-height: 1.4; }
.send { width: 42px; height: 42px; border-radius: 50%; border: 0; background: var(--accent); color: #fff; font-size: 17px; flex: none; }
.replying { font-size: 13px; color: var(--muted); padding: 0 4px 6px; }
.mention { background: var(--bg); border: 1px solid var(--border); border-radius: 12px; margin-top: 6px; overflow: hidden; }
.mention button { display: flex; width: 100%; align-items: center; gap: 8px; border: 0; background: none; padding: 8px 10px; text-align: left; }
.mention button:hover { background: var(--surface); }
.mention .avatar { width: 24px; height: 24px; font-size: 10px; }
body:not(.has-composer) .composer { display: none; }

.sheet { position: fixed; inset: 0; background: rgba(0, 0, 0, 0); z-index: 50; display: flex; align-items: flex-end; justify-content: center; transition: background .2s; }
.sheet.open { background: rgba(0, 0, 0, .45); }
.sheet-card { width: 100%; max-width: 520px; background: var(--bg); border-radius: 20px 20px 0 0; padding: 18px 16px calc(18px + env(safe-area-inset-bottom)); transform: translateY(100%); transition: transform .2s ease-out; max-height: 88vh; overflow: auto; }
.sheet.open .sheet-card { transform: none; }
.sheet-card h2 { margin: 0 0 12px; font-size: 19px; }
@media (min-width: 700px) { .sheet { align-items: center; } .sheet-card { border-radius: 20px; } }
.choice-list { display: grid; gap: 8px; }
.choice { display: flex; flex-direction: column; align-items: flex-start; text-align: left; gap: 2px; border: 1px solid var(--border); background: var(--surface); border-radius: 14px; padding: 12px 14px; }
.choice span { color: var(--muted); font-size: 14px; }
.choice.persona { flex-direction: row; align-items: center; gap: 12px; }
.choice.persona > span { display: flex; flex-direction: column; color: var(--text); }

.toast { position: fixed; left: 50%; bottom: calc(var(--tab) + 90px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px); background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-size: 14px; max-width: min(92vw, 440px); opacity: 0; pointer-events: none; transition: .2s; z-index: 60; text-align: center; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
