/* App lớp 6A8 — giao diện chung. Mobile-first; mốc 768px và 1100px. */
:root {
  --bg: #F0F2EE;
  --surface: #FFFFFF;
  --surface-2: #F6F7F4;
  --text: #1B1F1D;
  --muted: #5B635E;
  --line: #E7EAE4;
  --border: #DDE1DA;
  --chip: #E4E7E1;
  --accent: #1D5FC4;
  --accent-hover: #164A99;
  --accent-soft: #E6EEFB;
  --on-accent: #FFFFFF;
  --ok: #1E7A46;
  --ok-soft: #DDF0E4;
  --warn: #B8561B;
  --warn-soft: #FBEBDD;
  --danger: #B42318;
  --danger-soft: #FCE4E1;
  --badge: #C2410C;
  --shadow: 0 1px 2px rgba(27, 31, 29, .06), 0 2px 8px rgba(27, 31, 29, .05);
  --radius: 12px;
  --top-h: 56px;
  --nav-h: 64px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121513; --surface: #1C201E; --surface-2: #232825; --text: #E8ECE9; --muted: #A3ACA6;
    --line: #2B312D; --border: #343B37; --chip: #2E3531; --accent: #6FA2F2; --accent-hover: #93BAF6;
    --accent-soft: #1E2C44; --on-accent: #0D1A30; --ok: #5CC389; --ok-soft: #173325; --warn: #F0A06A;
    --warn-soft: #3A2616; --danger: #F2877D; --danger-soft: #3D1C19; --badge: #F07A3E;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #121513; --surface: #1C201E; --surface-2: #232825; --text: #E8ECE9; --muted: #A3ACA6;
  --line: #2B312D; --border: #343B37; --chip: #2E3531; --accent: #6FA2F2; --accent-hover: #93BAF6;
  --accent-soft: #1E2C44; --on-accent: #0D1A30; --ok: #5CC389; --ok-soft: #173325; --warn: #F0A06A;
  --warn-soft: #3A2616; --danger: #F2877D; --danger-soft: #3D1C19; --badge: #F07A3E;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4); color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.5 'Be Vietnam Pro', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
}
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; line-height: 1.25; text-wrap: balance; }
h1 { font-size: 22px; font-weight: 700; }
h2 { font-size: 17px; font-weight: 700; }
h3 { font-size: 15px; font-weight: 600; }
p { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.tiny { font-size: 12px; }
.num { font-variant-numeric: tabular-nums; }
.ico { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
[hidden] { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------- Nút, ô nhập ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 16px; border-radius: 10px; border: none; cursor: pointer;
  font-weight: 600; font-size: 15px; background: var(--chip); color: var(--text); text-decoration: none;
  transition: background .15s, transform .05s;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: default; }
.btn-primary { background: var(--accent); color: var(--on-accent); }
.btn-primary:hover { background: var(--accent-hover); color: var(--on-accent); }
.btn-soft { background: var(--accent-soft); color: var(--accent-hover); }
.btn-danger { background: var(--danger-soft); color: var(--danger); }
.btn-ghost { background: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--chip); }
.btn-sm { min-height: 36px; padding: 0 12px; font-size: 13px; border-radius: 8px; }
.btn-block { width: 100%; }
.is-busy { position: relative; color: transparent !important; }
.is-busy::after {
  content: ''; position: absolute; width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid currentColor; border-color: var(--muted) transparent var(--muted) transparent; animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.icon-btn {
  width: 40px; height: 40px; border-radius: 50%; border: none; background: var(--chip); color: var(--text);
  display: inline-flex; align-items: center; justify-content: center; cursor: pointer; position: relative;
}
.icon-btn:hover { filter: brightness(.96); }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label, .label { font-size: 13px; font-weight: 600; color: var(--muted); }
.input {
  width: 100%; min-height: 46px; padding: 10px 14px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text); font-size: 16px;
}
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.input-pin { letter-spacing: .5em; font-size: 22px; text-align: center; font-variant-numeric: tabular-nums; }
.hint { font-size: 12px; color: var(--muted); }
.error-text { font-size: 13px; color: var(--danger); }
.form { display: flex; flex-direction: column; gap: 14px; }
.row { display: flex; gap: 10px; align-items: center; }
.row-wrap { display: flex; gap: 8px; flex-wrap: wrap; }
.grow { flex: 1 1 auto; min-width: 0; }

.pill { display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: 11px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.pill-ok { background: var(--ok-soft); color: var(--ok); }
.pill-warn { background: var(--warn-soft); color: var(--warn); }
.pill-danger { background: var(--danger-soft); color: var(--danger); }
.pill-muted { background: var(--chip); color: var(--muted); }
.pill-accent { background: var(--accent-soft); color: var(--accent-hover); }
.badge { position: absolute; top: -3px; right: -3px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--badge); color: #fff; font-size: 11px; font-weight: 700; display: flex; align-items: center; justify-content: center; }

.avatar { width: var(--av); height: var(--av); border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: calc(var(--av) * .36); flex-shrink: 0; }

/* ---------- Thẻ, danh sách ---------- */
.card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 16px; }
.section { display: flex; flex-direction: column; gap: 12px; }
.section-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.list { display: flex; flex-direction: column; }
.item { display: flex; gap: 12px; align-items: center; padding: 12px 16px; border-top: 1px solid var(--line); }
.item:first-child { border-top: none; }
.item-main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.item-title { font-weight: 600; overflow-wrap: anywhere; }
.item-sub { font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }
.item-actions { display: flex; gap: 6px; flex-shrink: 0; }
a.item, button.item { color: inherit; text-align: left; background: none; border-left: 0; border-right: 0; border-bottom: 0; width: 100%; cursor: pointer; font: inherit; }
a.item:hover, button.item:hover { background: var(--surface-2); }
.empty { padding: 28px 16px; text-align: center; color: var(--muted); display: flex; flex-direction: column; gap: 8px; align-items: center; }
.skeleton { height: 64px; margin: 8px 16px; border-radius: 10px; background: linear-gradient(90deg, var(--chip), var(--surface-2), var(--chip)); background-size: 200% 100%; animation: sk 1.2s infinite; }
@keyframes sk { to { background-position: -200% 0; } }

.tabs { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { height: 36px; padding: 0 14px; border-radius: 18px; border: none; background: var(--chip); color: var(--text); font-weight: 500; font-size: 14px; white-space: nowrap; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
.tab[aria-selected="true"] { background: var(--accent); color: var(--on-accent); font-weight: 600; }
.tab .count { font-size: 12px; opacity: .8; }

/* ---------- Khung app (S00) ---------- */
.topbar {
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 30; height: var(--top-h);
  background: var(--surface); border-bottom: 1px solid var(--border);
  display: grid; grid-template-columns: 1fr auto; align-items: center; padding: 0 12px; gap: 8px;
}
.brand { display: flex; align-items: center; gap: 8px; color: var(--accent); font-weight: 700; font-size: 20px; min-width: 0; }
.brand-mark { width: 36px; height: 36px; border-radius: 50%; background: var(--accent); color: var(--on-accent); display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 700; flex-shrink: 0; }
.brand-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-actions { display: flex; gap: 6px; align-items: center; }
.top-tabs { display: none; }
.me-btn { display: none; }

.layout { max-width: 1320px; margin: 0 auto; padding: 12px 0 calc(var(--nav-h) + 16px + env(safe-area-inset-bottom, 0px)); display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; }
.col-left, .col-right { display: none; }
.col-main { min-width: 0; display: flex; flex-direction: column; gap: 12px; }
.page-head { display: flex; align-items: center; gap: 8px; padding: 0 16px; min-height: 40px; }
.page-head h1 { font-size: 20px; }

.bottomnav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  height: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px)); padding-bottom: env(safe-area-inset-bottom, 0px);
  background: var(--surface); border-top: 1px solid var(--border); display: grid; grid-template-columns: repeat(5, minmax(0, 1fr));
}
.bottomnav a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; color: var(--muted); font-size: 11px; font-weight: 500; position: relative; }
.bottomnav a[aria-current="page"] { color: var(--accent); font-weight: 600; }
.bottomnav .badge { top: 6px; right: auto; left: calc(50% + 4px); }

/* Mobile: thẻ tràn viền giống Facebook */
@media (max-width: 767px) {
  .col-main > .card, .feed-list > .card, .feed-pinned > .card, .detail > .card { border-radius: 0; box-shadow: none; }
}

@media (min-width: 768px) {
  .bottomnav { display: none; }
  .layout { padding: 16px 16px 32px; grid-template-columns: 240px minmax(0, 1fr); gap: 20px; }
  .col-left { display: flex; flex-direction: column; gap: 4px; position: sticky; top: calc(var(--top-h) + 16px); align-self: start; }
  .topbar { grid-template-columns: 1fr auto 1fr; padding: 0 16px; }
  .top-tabs { display: flex; justify-content: center; gap: 4px; height: 100%; }
  .top-tabs a { width: 96px; display: flex; align-items: center; justify-content: center; color: var(--muted); border-bottom: 3px solid transparent; position: relative; border-radius: 0; }
  .top-tabs a:hover { background: var(--surface-2); }
  .top-tabs a[aria-current="page"] { color: var(--accent); border-bottom-color: var(--accent); }
  .top-tabs .badge { top: 8px; right: 26px; }
  .top-actions { justify-content: flex-end; }
  .me-btn { display: inline-flex; }
  .page-head { padding: 0; }
}
@media (min-width: 1100px) {
  .layout { grid-template-columns: 280px minmax(0, 680px) 300px; justify-content: space-between; }
  .col-right { display: flex; flex-direction: column; gap: 16px; position: sticky; top: calc(var(--top-h) + 16px); align-self: start; }
}

.side-link { display: flex; align-items: center; gap: 12px; padding: 8px 10px; border-radius: 10px; color: var(--text); font-weight: 500; position: relative; }
.side-link:hover { background: var(--chip); color: var(--text); }
.side-link[aria-current="page"] { background: var(--accent-soft); color: var(--accent-hover); }
.side-link .ico { color: var(--accent); }
.side-link .pill { margin-left: auto; }
.side-sep { height: 1px; background: var(--border); margin: 8px 10px; }
.side-title { font-size: 13px; font-weight: 700; color: var(--muted); padding: 4px 10px; }

/* ---------- Màn đăng nhập (S01–S03) ---------- */
.auth { min-height: 100%; display: flex; flex-direction: column; align-items: center; padding: 24px 16px 40px; gap: 16px; }
.auth-brand { display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; padding-top: 12px; }
.auth-brand .brand-mark { width: 56px; height: 56px; font-size: 20px; }
.auth-brand h1 { font-size: 26px; color: var(--accent); }
.auth-card { width: 100%; max-width: 440px; padding: 20px; display: flex; flex-direction: column; gap: 16px; }
.seg { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; background: var(--chip); border-radius: 12px; padding: 4px; }
.seg button { height: 40px; border: none; border-radius: 9px; background: transparent; font-weight: 600; font-size: 14px; color: var(--muted); cursor: pointer; }
.seg button[aria-selected="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.suggest { display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: 12px; overflow: hidden; max-height: 320px; overflow-y: auto; }
.suggest button { display: flex; gap: 12px; align-items: center; padding: 10px 12px; border: none; border-top: 1px solid var(--line); background: var(--surface); text-align: left; cursor: pointer; }
.suggest button:first-child { border-top: none; }
.suggest button:hover, .suggest button:focus-visible { background: var(--accent-soft); }
.picked { display: flex; gap: 12px; align-items: center; padding: 12px; border-radius: 12px; background: var(--surface-2); }
.rel-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.rel-btn { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; padding: 12px; border-radius: 12px; border: 1.5px solid var(--border); background: var(--surface); cursor: pointer; text-align: left; }
.rel-btn:hover { border-color: var(--accent); }
.rel-btn[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); }
.rel-btn strong { font-size: 16px; }
.demo-box { width: 100%; max-width: 440px; padding: 16px; display: flex; flex-direction: column; gap: 10px; border: 1.5px dashed var(--warn); background: var(--warn-soft); border-radius: var(--radius); }
.demo-box h2 { font-size: 15px; color: var(--warn); }
.demo-quick { display: flex; flex-wrap: wrap; gap: 6px; }
.demo-quick button { min-height: 34px; padding: 0 10px; border-radius: 17px; border: 1px solid var(--border); background: var(--surface); font-size: 13px; cursor: pointer; }
.demo-banner { background: var(--warn-soft); color: var(--warn); font-size: 12px; font-weight: 600; text-align: center; padding: 4px 12px; }
.steps { display: flex; gap: 6px; }
.steps span { flex: 1; height: 4px; border-radius: 2px; background: var(--chip); }
.steps span.on { background: var(--accent); }
.notice { display: flex; gap: 10px; padding: 12px; border-radius: 10px; background: var(--accent-soft); color: var(--accent-hover); font-size: 14px; align-items: flex-start; }
.notice-warn { background: var(--warn-soft); color: var(--warn); }
.notice-ok { background: var(--ok-soft); color: var(--ok); }

/* ---------- Danh bạ (S53) ---------- */
.search-box { position: relative; }
.search-box .ico { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.search-box .input { padding-left: 42px; border-radius: 24px; background: var(--surface-2); border-color: transparent; }
.family { padding: 4px 0; }
.family + .family { border-top: 8px solid var(--bg); }
.fam-head { display: flex; align-items: center; gap: 8px; padding: 12px 16px 4px; }
.person { display: flex; gap: 12px; align-items: center; padding: 10px 16px; }
.person-main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.person-name { font-weight: 600; }
.person-meta { font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }
.person-actions { display: flex; gap: 6px; flex-shrink: 0; }
.act { width: 40px; height: 40px; border-radius: 50%; border: none; background: var(--accent-soft); color: var(--accent-hover); display: inline-flex; align-items: center; justify-content: center; cursor: pointer; }
.act[aria-disabled="true"] { background: var(--chip); color: var(--muted); opacity: .5; pointer-events: none; }
mark { background: #FFF1A8; color: inherit; border-radius: 2px; padding: 0 1px; }
:root[data-theme="dark"] mark { background: #5A4B00; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) mark { background: #5A4B00; } }

/* ---------- Hộp thoại, toast ---------- */
.sheet-wrap { position: fixed; inset: 0; z-index: 60; background: rgba(15, 18, 16, .45); display: flex; align-items: flex-end; justify-content: center; animation: fade .15s; }
.sheet { width: 100%; max-width: 520px; max-height: 88vh; overflow-y: auto; background: var(--surface); border-radius: 16px 16px 0 0; padding: 16px 16px calc(16px + env(safe-area-inset-bottom, 0px)); display: flex; flex-direction: column; gap: 14px; animation: up .2s ease-out; }
.sheet-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.sheet-body { display: flex; flex-direction: column; gap: 12px; }
.sheet-actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.sheet-actions .btn { flex: 1 1 120px; }
.sheet-wrap.out { opacity: 0; transition: opacity .18s; }
@media (min-width: 768px) { .sheet-wrap { align-items: center; } .sheet { border-radius: 16px; } }
@keyframes up { from { transform: translateY(24px); opacity: .6; } }
@keyframes fade { from { opacity: 0; } }
#toasts { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--nav-h) + 16px + env(safe-area-inset-bottom, 0px)); z-index: 80; display: flex; flex-direction: column; gap: 8px; width: min(420px, calc(100% - 32px)); }
.toast { background: #222826; color: #fff; padding: 12px 16px; border-radius: 10px; font-size: 14px; box-shadow: 0 6px 20px rgba(0, 0, 0, .2); animation: up .2s; transition: opacity .3s; }
.toast-error { background: #8A1C12; }
.toast-ok { background: #1E6B3E; }
.toast.out { opacity: 0; }
@media (min-width: 768px) { #toasts { bottom: 24px; } }

.stat-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.stat { background: var(--surface-2); border-radius: 10px; padding: 10px 12px; display: flex; flex-direction: column; gap: 2px; }
.stat b { font-size: 22px; font-variant-numeric: tabular-nums; }
.stat span { font-size: 12px; color: var(--muted); }
.progress { height: 8px; border-radius: 4px; background: var(--chip); overflow: hidden; }
.progress > div { height: 100%; background: var(--ok); border-radius: 4px; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 500; overflow-wrap: anywhere; }
.pw-box { display: flex; gap: 8px; align-items: center; }
.pw-box .input { font-family: ui-monospace, 'SF Mono', Menlo, monospace; font-size: 20px; letter-spacing: .08em; text-align: center; }
.soon { padding: 32px 20px; text-align: center; display: flex; flex-direction: column; gap: 10px; align-items: center; }
.soon .ico { color: var(--accent); }
.soon ul { text-align: left; margin: 4px 0 0; padding-left: 20px; color: var(--muted); font-size: 14px; display: flex; flex-direction: column; gap: 4px; }

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* =================== Bảng tin (M4) =================== */
.no-scroll { overflow: hidden; }
.link-btn { background: none; border: none; padding: 0; color: var(--muted); font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; }
.link-btn:hover { text-decoration: underline; }
.icon-btn.ghost { background: transparent; color: var(--muted); }
.icon-btn.ghost:hover { background: var(--chip); }
.composer-box { display: flex; align-items: center; gap: 10px; }
.fake-input { flex: 1; min-height: 42px; border-radius: 21px; border: none; background: var(--surface-2); color: var(--muted); text-align: left; padding: 0 16px; font-size: 15px; cursor: pointer; }
.fake-input:hover { background: var(--chip); }
.feed-tabs { padding: 0 16px; }
@media (min-width: 768px) { .feed-tabs { padding: 0; } .fab { display: none !important; } .composer-box { display: flex; } }
@media (max-width: 767px) { .composer-box { display: none; } }
.fab {
  position: fixed; right: 16px; bottom: calc(var(--nav-h) + 16px + env(safe-area-inset-bottom, 0px)); z-index: 25;
  width: 56px; height: 56px; border-radius: 50%; border: none; background: var(--accent); color: var(--on-accent);
  display: flex; align-items: center; justify-content: center; box-shadow: 0 6px 18px rgba(29, 95, 196, .35); cursor: pointer;
}
.new-pill { position: sticky; top: calc(var(--top-h) + 8px + env(safe-area-inset-top, 0px)); z-index: 20; align-self: center; display: inline-flex; gap: 6px; align-items: center; height: 36px; padding: 0 14px; border-radius: 18px; border: none; background: var(--accent); color: var(--on-accent); font-weight: 600; font-size: 14px; box-shadow: var(--shadow); cursor: pointer; }
.feed-pinned, .feed-list, .detail { display: flex; flex-direction: column; gap: 12px; }
.feed-pinned:empty { display: none; }
.feed-end { height: 1px; }

.post { display: flex; flex-direction: column; }
.post-head { display: flex; gap: 10px; align-items: center; padding: 12px 12px 8px 16px; }
.post-author { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.role-chip { font-size: 11px; font-weight: 600; color: var(--accent-hover); background: var(--accent-soft); border-radius: 6px; padding: 1px 6px; }
.post-meta { font-size: 12px; color: var(--muted); display: inline-flex; align-items: center; gap: 2px; }
.post-meta a { color: inherit; }
.post-meta a:hover { text-decoration: underline; }
.post-text { padding: 0 16px 10px; line-height: 1.55; overflow-wrap: anywhere; }
.post-text.clamp { display: -webkit-box; -webkit-line-clamp: 5; -webkit-box-orient: vertical; overflow: hidden; padding-bottom: 0; }
.more-btn { margin: 0 16px 10px; align-self: flex-start; }
.mention { color: var(--accent-hover); font-weight: 600; }

.grid { display: grid; gap: 2px; background: var(--surface); }
.g1 { grid-template-columns: 1fr; max-height: 620px; }
.g2 { grid-template-columns: 1fr 1fr; aspect-ratio: 2 / 1; }
.g3 { grid-template-columns: 2fr 1fr; grid-template-rows: 1fr 1fr; aspect-ratio: 3 / 2; }
.g3 .tile:first-child { grid-row: span 2; }
.g4 { grid-template-columns: 1fr 1fr; aspect-ratio: 1; }
.g5 { grid-template-columns: repeat(6, 1fr); grid-template-rows: 3fr 2fr; aspect-ratio: 1; }
.g5 .tile:nth-child(-n+2) { grid-column: span 3; }
.g5 .tile:nth-child(n+3) { grid-column: span 2; }
.tile { position: relative; overflow: hidden; border: none; padding: 0; background: #2A302D; cursor: pointer; min-height: 0; min-width: 0; }
.tile img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .25s; }
.tile img.broken { visibility: hidden; }
.tile:hover img { transform: scale(1.02); }
.tile-play { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); width: 56px; height: 56px; border-radius: 50%; background: rgba(0, 0, 0, .55); color: #fff; display: flex; align-items: center; justify-content: center; }
.tile-chip { position: absolute; left: 8px; top: 8px; background: rgba(0, 0, 0, .6); color: #fff; font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 10px; }
.tile-more { position: absolute; inset: 0; background: rgba(0, 0, 0, .5); color: #fff; font-size: 28px; font-weight: 700; display: flex; align-items: center; justify-content: center; }

.post-stats { display: flex; justify-content: space-between; align-items: center; padding: 8px 16px; font-size: 14px; color: var(--muted); min-height: 36px; }
.rx-sum { display: inline-flex; align-items: center; gap: 6px; }
.rx-icons { display: inline-flex; }
.rx-icons span { width: 20px; height: 20px; border-radius: 50%; background: var(--surface); display: inline-flex; align-items: center; justify-content: center; font-size: 13px; margin-left: -4px; box-shadow: 0 0 0 2px var(--surface); }
.rx-icons span:first-child { margin-left: 0; }
.post-actions { display: flex; margin: 0 12px; border-top: 1px solid var(--line); padding: 4px 0; }
.post-actions > * { flex: 1; display: flex; }
.act-btn { flex: 1; min-height: 40px; border: none; background: transparent; border-radius: 8px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; color: var(--muted); font-weight: 600; font-size: 14px; cursor: pointer; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; touch-action: manipulation; }
.act-btn:hover { background: var(--surface-2); }
.rx-emoji { font-size: 18px; line-height: 1; }
.rx-picker { position: fixed; z-index: 90; display: flex; gap: 2px; padding: 6px; border-radius: 28px; background: var(--surface); box-shadow: 0 6px 24px rgba(0, 0, 0, .18); animation: up .15s ease-out; }
.rx-picker button { width: 44px; height: 44px; border: none; background: none; border-radius: 50%; cursor: pointer; font-size: 28px; line-height: 1; transition: transform .12s; }
.rx-picker button:hover, .rx-picker button:focus-visible { transform: scale(1.3) translateY(-4px); }

/* Bình luận */
.cmts { padding: 4px 16px 12px; display: flex; flex-direction: column; gap: 8px; border-top: 1px solid var(--line); margin: 0 0 0; }
.post > [data-slot="comments"]:empty { display: none; }
.cmt-list { display: flex; flex-direction: column; gap: 8px; padding-top: 8px; }
.cmt { display: flex; gap: 8px; align-items: flex-start; }
.cmt.reply { margin-left: 40px; }
.cmt.is-hidden { opacity: .55; }
.cmt-body { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.cmt-bubble { position: relative; background: var(--surface-2); border-radius: 16px; padding: 8px 12px; overflow-wrap: anywhere; max-width: 100%; }
.cmt-name { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px; font-weight: 600; font-size: 13px; }
.cmt-sub { font-weight: 400; color: var(--muted); font-size: 12px; }
.wall-chip { font-size: 10px; font-weight: 700; padding: 0 5px; border-radius: 5px; }
.wall-chip.hs { background: var(--warn-soft); color: var(--warn); }
.wall-chip.ph { background: var(--accent-soft); color: var(--accent-hover); }
.cmt-text { font-size: 14px; line-height: 1.45; }
.cmt-rx { position: absolute; right: -6px; bottom: -10px; background: var(--surface); border-radius: 10px; padding: 0 5px; font-size: 12px; box-shadow: var(--shadow); display: inline-flex; gap: 2px; align-items: center; }
.cmt-meta { display: flex; gap: 12px; padding-left: 12px; font-size: 12px; color: var(--muted); align-items: center; flex-wrap: wrap; }
.cmt-meta .link-btn { font-size: 12px; }
.more-cmts { align-self: flex-start; }
.cmt-form { display: flex; gap: 8px; align-items: flex-end; }
.cmt-input-wrap { flex: 1; position: relative; min-width: 0; }
.cmt-input { width: 100%; resize: none; min-height: 38px; max-height: 140px; border-radius: 19px; border: 1px solid transparent; background: var(--surface-2); padding: 8px 14px; font-size: 15px; line-height: 1.4; }
.cmt-input:focus { outline: none; border-color: var(--accent); }
.cmt-reply { font-size: 12px; color: var(--muted); padding: 0 8px 4px; }
.cmt-form .send { background: transparent; color: var(--accent); }
.cmt-form .send:disabled { color: var(--muted); opacity: .5; }
.mention-box { position: absolute; bottom: calc(100% + 4px); left: 0; right: 0; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow); overflow: hidden; z-index: 5; }
.mention-box button { display: flex; width: 100%; gap: 8px; align-items: center; padding: 8px 10px; border: none; background: none; text-align: left; cursor: pointer; }
.mention-box button:hover, .mention-box button:first-child { background: var(--accent-soft); }
.wall-note { padding-left: 40px; }
.cmt-edit { display: flex; flex-direction: column; gap: 6px; }

/* Xem ảnh/video (S13) */
.viewer { position: fixed; inset: 0; z-index: 70; display: grid; grid-template-columns: 1fr; background: rgb(8, 10, 9); color: #fff; animation: fade .15s; }
.v-stage { position: relative; display: flex; align-items: center; justify-content: center; overflow: hidden; min-height: 0; padding-top: env(safe-area-inset-top, 0px); }
.v-media { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; touch-action: pan-y; }
.v-media > img { max-width: 100%; max-height: 100%; object-fit: contain; user-select: none; transition: transform .15s; }
.v-video { width: 100%; max-width: 1100px; aspect-ratio: 16 / 9; max-height: 100%; }
.v-video iframe, .v-video video { width: 100%; height: 100%; border: 0; background: #000; }
.v-demo-video { position: relative; max-width: 100%; max-height: 100%; }
.v-demo-video img { max-width: 100%; max-height: 80vh; display: block; }
.v-demo-video span { position: absolute; inset: auto 12px 12px 12px; background: rgba(0, 0, 0, .65); padding: 10px 12px; border-radius: 10px; font-size: 13px; display: flex; gap: 8px; align-items: center; }
.v-btn { position: absolute; width: 44px; height: 44px; border-radius: 50%; border: none; background: rgba(255, 255, 255, .14); color: #fff; display: flex; align-items: center; justify-content: center; cursor: pointer; }
.v-btn:hover { background: rgba(255, 255, 255, .26); }
.v-close { top: calc(12px + env(safe-area-inset-top, 0px)); left: 12px; }
.v-prev { left: 12px; top: 50%; transform: translateY(-50%); }
.v-next { right: 12px; top: 50%; transform: translateY(-50%); }
.v-count { position: absolute; top: calc(22px + env(safe-area-inset-top, 0px)); left: 50%; transform: translateX(-50%); font-size: 14px; opacity: .85; }
.v-bar { position: absolute; left: 0; right: 0; bottom: 0; padding: 24px 16px calc(12px + env(safe-area-inset-bottom, 0px)); background: linear-gradient(transparent, rgba(0, 0, 0, .75)); display: flex; flex-direction: column; gap: 8px; }
.v-caption { font-size: 14px; }
.v-actions { display: flex; gap: 4px; }
.v-actions > * { flex: 1; }
.v-act, .v-actions .act-btn { min-height: 40px; border: none; background: rgba(255, 255, 255, .1); color: #fff; border-radius: 8px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; font-weight: 600; font-size: 13px; cursor: pointer; }
.v-actions .react-btn.on { background: rgba(255, 255, 255, .2); }
.v-actions .act-btn:hover, .v-act:hover { background: rgba(255, 255, 255, .2); color: #fff; }
.v-side { display: none; }
.v-drawer { position: absolute; left: 0; right: 0; bottom: 0; max-height: 75%; background: var(--surface); color: var(--text); border-radius: 16px 16px 0 0; display: flex; flex-direction: column; animation: up .2s; padding-bottom: env(safe-area-inset-bottom, 0px); z-index: 3; }
.v-drawer-head { display: flex; justify-content: space-between; align-items: center; padding: 10px 16px; border-bottom: 1px solid var(--line); }
.v-drawer-body { overflow-y: auto; }
.v-drawer-body .cmts { border-top: 0; }
@media (min-width: 900px) {
  .viewer { grid-template-columns: minmax(0, 1fr) 360px; }
  .v-bar { display: none; }
  .v-side { display: flex; flex-direction: column; background: var(--surface); color: var(--text); overflow-y: auto; }
  .v-side .post-head { padding-top: 16px; }
  .v-side-stats .post-stats { padding: 4px 16px; }
  .v-media-title { padding: 8px 16px 0; }
  .v-drawer { display: none; }
}

/* Soạn bài (S11) */
.composer { max-width: 620px; gap: 12px; }
@media (max-width: 767px) { .composer-wrap { align-items: stretch; } .composer { max-height: none; height: 100%; border-radius: 0; padding-top: calc(16px + env(safe-area-inset-top, 0px)); } }
.cp-text { resize: vertical; min-height: 110px; font-size: 16px; line-height: 1.5; }
.cp-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 6px; }
.cp-item { position: relative; aspect-ratio: 1; border-radius: 10px; overflow: hidden; background: #2A302D; }
.cp-item img, .cp-item video { width: 100%; height: 100%; object-fit: cover; display: block; }
.cp-item .tile-play { width: 36px; height: 36px; }
.cp-rm { position: absolute; top: 4px; right: 4px; width: 28px; height: 28px; border-radius: 50%; border: none; background: rgba(0, 0, 0, .6); color: #fff; display: flex; align-items: center; justify-content: center; cursor: pointer; }
.cp-size { position: absolute; left: 4px; bottom: 4px; background: rgba(0, 0, 0, .55); color: #fff; border-radius: 6px; padding: 0 5px; }
.cp-vtitle { grid-column: 1 / -1; font-size: 14px; min-height: 40px; }
.cp-tools { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; }
.cp-add { cursor: pointer; }
.cp-progress { display: flex; flex-direction: column; gap: 6px; }

#bg-up { position: fixed; left: 12px; bottom: calc(var(--nav-h) + 12px + env(safe-area-inset-bottom, 0px)); z-index: 26; display: flex; flex-direction: column; gap: 6px; }
@media (min-width: 768px) { #bg-up { bottom: 16px; } }
.bg-chip { display: inline-flex; align-items: center; gap: 8px; background: var(--surface); color: var(--text); border-radius: 18px; padding: 6px 12px; font-size: 13px; box-shadow: 0 4px 14px rgba(0, 0, 0, .15); }
.v-thumb { width: 96px; aspect-ratio: 16 / 9; object-fit: cover; border-radius: 8px; background: #2A302D; flex-shrink: 0; }
.todo-card .item { padding-block: 10px; }
