:root {
  --bg: #f8f8f8;
  --ink: #0a0a0a;
  --muted: #7a7a7a;
  --chip: #e6e6e6;
  --chip-active: #b9b9b9;
  --teal: #3f7f95;
  --teal-bg: #5f95a3;
  --line: #ececec;
  --danger: #e5484d;
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font); min-height: 100vh; }
a { color: inherit; text-decoration: none; }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
img, video { display: block; max-width: 100%; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------- top bar ---------- */
.topbar { position: relative; height: 84px; display: flex; align-items: center; justify-content: center; }
.plus {
  position: absolute; left: 20px; top: 25px; width: 34px; height: 34px; border-radius: 50%;
  border: 0; background: #d9d9d9; font-size: 22px; line-height: 1; display: grid; place-items: center;
  transition: background .15s, transform .15s;
}
.plus:hover { background: #cbcbcb; transform: scale(1.06); }
.logo { display: inline-flex; align-items: center; }
.logo img { height: 42px; width: auto; }
.account { position: absolute; right: 18px; top: 10px; }
.avatar-btn { border: 0; padding: 0; background: none; border-radius: 50%; box-shadow: 0 2px 10px rgba(0,0,0,.3); }
.login-btn { border: 0; background: var(--ink); color: #fff; font-weight: 600; font-size: 14px; padding: 10px 18px; border-radius: 999px; margin-top: 14px; }
.menu { position: absolute; right: 0; top: 72px; min-width: 190px; background: #fff; border-radius: 16px; box-shadow: 0 10px 34px rgba(0,0,0,.2); padding: 8px; z-index: 20; }
.menu a, .menu button { display: block; width: 100%; text-align: left; padding: 10px 12px; border: 0; background: none; border-radius: 10px; font-size: 14px; font-weight: 500; }
.menu a:hover, .menu button:hover { background: #f2f2f2; }
.menu .who { padding: 8px 12px 10px; font-size: 12px; color: var(--muted); border-bottom: 1px solid var(--line); margin-bottom: 6px; }

/* ---------- avatars ---------- */
.avatar { border-radius: 50%; object-fit: cover; flex: none; display: inline-grid; place-items: center; color: #fff; font-weight: 700; background: #888; overflow: hidden; }

/* ---------- layout ---------- */
main { padding: 0 16px 80px; }
.empty, .error-box { text-align: center; color: var(--muted); padding: 80px 0; font-size: 15px; }

/* ---------- profile ---------- */
.profile { text-align: center; padding-top: 12px; }
.profile .avatar { width: 132px; height: 132px; font-size: 48px; box-shadow: 0 2px 12px rgba(0,0,0,.18); }
.profile h1 { font-size: 40px; font-weight: 800; letter-spacing: -.8px; margin: 12px 0 4px; }
.profile .bio { font-size: 16px; line-height: 1.25; white-space: pre-line; color: #222; margin: 0; }
.profile .edit { margin-top: 12px; border: 1px solid #d5d5d5; background: #fff; border-radius: 999px; padding: 7px 16px; font-size: 13px; font-weight: 600; }
.chips { display: flex; justify-content: center; gap: 10px; margin: 18px 0 16px; }
.chip { border: 0; background: var(--chip); color: #333; font-size: 15px; padding: 7px 18px; border-radius: 999px; transition: background .15s; }
.chip:hover { background: #d9d9d9; }
.chip[aria-pressed="true"] { background: var(--chip-active); color: #fff; }

/* ---------- masonry grid ---------- */
.grid { display: flex; gap: 11px; max-width: 1074px; margin: 0 auto; align-items: flex-start; }
.col { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; gap: 11px; }
.card { position: relative; display: block; border-radius: 22px; overflow: hidden; background: #ddd; box-shadow: 0 2px 8px rgba(0,0,0,.18); isolation: isolate; }
.card > img, .card > video { width: 100%; height: 100%; object-fit: cover; }
.card .play { position: absolute; inset: 0; margin: auto; width: 21%; min-width: 44px; max-width: 76px; aspect-ratio: 1; filter: drop-shadow(0 2px 6px rgba(0,0,0,.35)); pointer-events: none; z-index: 1; }
.card .play svg { width: 100%; height: 100%; fill: none; }
.card .over {
  position: absolute; inset: 0; z-index: 2; display: flex; flex-direction: column; justify-content: space-between; padding: 14px 16px;
  background: rgba(190, 205, 225, .45); backdrop-filter: blur(2px) saturate(.85); -webkit-backdrop-filter: blur(2px) saturate(.85);
  opacity: 0; transition: opacity .18s ease; color: #fff; text-shadow: 0 1px 6px rgba(0,0,0,.35);
}
.card:hover .over, .card:focus-visible .over { opacity: 1; }
.card:focus-visible { outline: 3px solid var(--teal); outline-offset: 2px; }
.card .t { font-size: 22px; font-weight: 800; line-height: 1.15; letter-spacing: -.3px; word-break: break-word; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.stats { display: flex; gap: 12px; align-items: center; font-weight: 700; font-size: 15px; }
.stat { display: inline-flex; align-items: center; gap: 4px; }
.stat svg { width: 1.05em; height: 1.05em; fill: currentColor; }
@media (hover: none) { .card .over { opacity: 0; } }

/* ---------- post page ---------- */
.post-wrap { max-width: 880px; margin: 16px auto 0; }
.back { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; margin: 8px 0 12px 12px; }
.back svg { width: 20px; height: 20px; }
.post-card { background: #fff; border-radius: 56px; padding: 26px; box-shadow: 0 6px 26px rgba(0,0,0,.2); display: grid; grid-template-columns: minmax(0, 1.95fr) minmax(250px, 1fr); gap: 14px; }
.media { border-radius: 30px; overflow: hidden; background: #f0f0f0; display: grid; place-items: center; align-self: start; box-shadow: 0 2px 10px rgba(0,0,0,.15); }
.media img, .media video { width: 100%; height: auto; max-height: 72vh; object-fit: contain; background: #f0f0f0; }
.side { display: flex; flex-direction: column; min-width: 0; min-height: 420px; padding-top: 2px; }
.author { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 16px; }
.author .avatar { width: 44px; height: 44px; font-size: 16px; box-shadow: 0 1px 6px rgba(0,0,0,.25); }
.post-title { font-size: 34px; font-weight: 900; letter-spacing: -1px; line-height: 1.05; margin: 22px 0 14px 4px; text-shadow: 0 1px 4px rgba(0,0,0,.22); word-break: break-word; }
.post-stats { display: flex; gap: 12px; font-size: 18px; font-weight: 800; margin: 0 0 4px 4px; align-items: center; }
.post-stats .stat { gap: 5px; }
.like-btn { border: 0; background: none; padding: 0; font: inherit; font-weight: 800; display: inline-flex; align-items: center; gap: 5px; }
.like-btn svg { width: 1.05em; height: 1.05em; fill: currentColor; transition: transform .15s, fill .15s; }
.like-btn:hover svg { transform: scale(1.18); }
.like-btn[aria-pressed="true"] { color: var(--danger); }
.like-btn:active svg { transform: scale(.9); }
.del-post { margin-left: auto; border: 0; background: none; color: var(--muted); font-size: 12px; font-weight: 600; }
.del-post:hover { color: var(--danger); }
.comments { flex: 1; overflow-y: auto; max-height: 360px; margin: 22px 0 10px; padding-right: 4px; display: flex; flex-direction: column; gap: 10px; }
.comment { display: flex; gap: 8px; align-items: flex-start; }
.comment.reply { margin-left: 20px; }
.comment .avatar { width: 28px; height: 28px; font-size: 11px; margin-top: 2px; }
.comment .meta { font-size: 11px; color: #333; }
.comment .meta b { font-weight: 600; margin-right: 4px; }
.comment .meta span { color: var(--muted); font-size: 10px; }
.comment .body { font-size: 14px; font-weight: 600; line-height: 1.3; word-break: break-word; white-space: pre-wrap; }
.comment .actions { font-size: 11px; color: var(--muted); display: flex; gap: 10px; margin-top: 1px; }
.comment .actions button { border: 0; background: none; padding: 0; color: inherit; font-size: inherit; font-weight: 600; }
.comment .actions button:hover { color: var(--ink); }
.no-comments { color: var(--muted); font-size: 13px; margin: 4px 0; }
.compose { margin-top: auto; }
.replying { font-size: 12px; color: var(--muted); display: flex; justify-content: space-between; padding: 0 12px 6px; }
.replying button { border: 0; background: none; color: inherit; }
.compose input { width: 100%; border: 0; background: #f0f0f0; border-radius: 999px; padding: 11px 16px; font-size: 13px; outline: none; }
.compose input:focus { box-shadow: 0 0 0 2px rgba(63,127,149,.45); }
.compose input::placeholder { color: #a4a4a4; }

/* ---------- modal ---------- */
.overlay { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: grid; place-items: center; padding: 16px; z-index: 50; animation: fade .15s ease; }
.modal { background: #fff; width: min(440px, 100%); max-height: 92vh; overflow-y: auto; border-radius: 28px; padding: 26px; box-shadow: 0 20px 60px rgba(0,0,0,.35); }
.modal h2 { margin: 0 0 16px; font-size: 22px; font-weight: 800; letter-spacing: -.4px; }
.field { display: block; margin-bottom: 12px; }
.field > span { display: block; font-size: 12px; font-weight: 600; color: #555; margin-bottom: 5px; }
.field input, .field textarea { width: 100%; border: 1px solid #ddd; background: #fafafa; border-radius: 14px; padding: 11px 14px; font-size: 14px; outline: none; resize: vertical; }
.field input:focus, .field textarea:focus { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(63,127,149,.2); }
.btn { border: 0; background: var(--ink); color: #fff; font-weight: 700; font-size: 14px; border-radius: 999px; padding: 12px 20px; }
.btn:disabled { opacity: .5; cursor: default; }
.btn.ghost { background: #eee; color: var(--ink); }
.row { display: flex; gap: 10px; justify-content: flex-end; margin-top: 14px; }
.form-error { color: var(--danger); font-size: 13px; min-height: 18px; margin: 4px 0 0; }
.switch { text-align: center; font-size: 13px; color: var(--muted); margin: 14px 0 0; }
.switch button { border: 0; background: none; color: var(--teal); font-weight: 700; padding: 0; }
.hint { font-size: 12px; color: var(--muted); margin: 10px 0 0; text-align: center; }
.drop { border: 2px dashed #cfcfcf; border-radius: 20px; min-height: 180px; display: grid; place-items: center; text-align: center; color: var(--muted); font-size: 14px; padding: 16px; margin-bottom: 14px; cursor: pointer; transition: border-color .15s, background .15s; overflow: hidden; }
.drop.over, .drop:hover { border-color: var(--teal); background: #f3f9fb; }
.drop b { color: var(--ink); }
.drop.has { padding: 0; border-style: solid; border-color: #e5e5e5; }
.drop.has img, .drop.has video { width: 100%; max-height: 300px; object-fit: contain; background: #f0f0f0; }
.progress { height: 6px; border-radius: 99px; background: #eee; overflow: hidden; margin-top: 12px; }
.progress i { display: block; height: 100%; width: 0; background: var(--teal); transition: width .1s; }
.avatar-pick { display: flex; align-items: center; gap: 14px; margin-bottom: 14px; }
.avatar-pick .avatar { width: 64px; height: 64px; font-size: 22px; }

#toast { position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 20px); background: #111; color: #fff; font-size: 14px; font-weight: 500; padding: 11px 18px; border-radius: 999px; opacity: 0; pointer-events: none; transition: .2s; z-index: 80; max-width: 90vw; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }
@keyframes fade { from { opacity: 0; } }

/* ---------- responsive ---------- */
@media (max-width: 760px) {
  .topbar { height: 72px; }
  .plus { left: 14px; top: 19px; }
  .logo img { height: 32px; }
  .account { right: 12px; top: 8px; }
  .login-btn { margin-top: 10px; padding: 8px 14px; }
  .profile .avatar { width: 108px; height: 108px; }
  .profile h1 { font-size: 32px; }
  .grid, .col { gap: 8px; }
  .card { border-radius: 16px; }
  .card .t { font-size: 17px; }
  .post-card { grid-template-columns: 1fr; border-radius: 32px; padding: 16px; }
  .media { border-radius: 22px; }
  .side { min-height: 0; }
  .post-title { font-size: 28px; }
  .comments { max-height: none; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* google sign-in */
.google-slot { display: flex; justify-content: center; min-height: 44px; margin-bottom: 4px; }
.or { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 12px; margin: 12px 0 14px; }
.or::before, .or::after { content: ''; flex: 1; height: 1px; background: var(--line); }
