:root {
  --bg: #fbf7ef; --panel: #fffdf8; --ink: #2f2a24; --muted: #8a8073; --line: #eadfcc;
  --accent: #c7782f; --accent-soft: #f6e4cf; --green: #4f8a5b; --blue: #4a77a8; --amber: #b8862b;
  --radius: 12px; --nav: 260px;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; }
a { color: var(--accent); }
button { font: inherit; cursor: pointer; }
.muted { color: var(--muted); } .small { font-size: 13px; }
.ghost { background: none; border: 1px solid transparent; border-radius: 8px; padding: 4px 10px; color: var(--ink); }
.ghost:hover { border-color: var(--line); background: #fff; }
.primary { background: var(--accent); color: #fff; border: 0; border-radius: 8px; padding: 8px 16px; font-weight: 600; }
.primary:disabled { opacity: .5; }

.top { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px; height: 56px;
  padding: 0 16px; background: var(--panel); border-bottom: 1px solid var(--line); }
.brand { font-weight: 700; color: var(--ink); text-decoration: none; }
.brand span { font-weight: 400; color: var(--muted); }
.top-right { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.badge { font-size: 12px; padding: 2px 8px; border-radius: 99px; background: var(--accent-soft); color: var(--accent); }
.menu-btn { display: none; background: none; border: 0; font-size: 22px; }

.layout { display: flex; min-height: calc(100vh - 56px); }
.nav { width: var(--nav); flex: none; border-right: 1px solid var(--line); padding: 16px 10px; background: var(--panel);
  position: sticky; top: 56px; height: calc(100vh - 56px); overflow: auto; }
.nav h4 { margin: 18px 10px 6px; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.nav a { display: flex; justify-content: space-between; gap: 6px; padding: 6px 10px; border-radius: 8px;
  color: var(--ink); text-decoration: none; font-size: 14px; }
.nav a:hover { background: var(--bg); }
.nav a.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.count { font-size: 12px; color: var(--muted); }
.main { flex: 1; min-width: 0; padding: 28px clamp(16px, 4vw, 48px) 120px; max-width: 1100px; }
.main h1 { margin: 0 0 6px; font-size: 28px; line-height: 1.25; }
.desc { color: var(--muted); margin: 0 0 18px; }

/* Khối nội dung có thể nhận xét */
.doc { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 0; }
.blk { position: relative; padding: 4px 56px 4px 24px; border-left: 3px solid transparent; }
.blk:hover { background: #fff8ee; }
.blk.has { border-left-color: var(--accent); }
.blk.sel { background: var(--accent-soft); }
.blk p { margin: 4px 0; }
.blk h2, .blk h3, .blk h4 { margin: 18px 0 6px; }
.blk.li { display: flex; gap: 8px; }
.blk.li .mk { color: var(--muted); flex: none; min-width: 14px; }
.blk.bq { color: #5e5446; font-style: italic; }
.cbtn { position: absolute; right: 10px; top: 4px; border: 1px solid var(--line); background: #fff; border-radius: 99px;
  padding: 0 9px; font-size: 13px; color: var(--muted); opacity: 0; transition: opacity .15s; }
.blk:hover .cbtn, .cbtn.n, .item:hover .cbtn { opacity: 1; }
.cbtn.n { color: var(--accent); border-color: var(--accent); font-weight: 600; }
@media (hover: none) { .cbtn { opacity: 1; } }
.tbl { overflow-x: auto; padding: 0 12px; }
table { border-collapse: collapse; width: 100%; font-size: 15px; }
th { text-align: left; font-size: 13px; color: var(--muted); font-weight: 600; padding: 6px 8px; border-bottom: 2px solid var(--line); }
tr.blk { padding: 0; }
tr.blk td { padding: 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
tr.blk td:last-child { padding-right: 56px; }
code { background: #f3ece0; padding: 0 4px; border-radius: 4px; font-size: .88em; }

/* Lưới ảnh */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; margin-bottom: 24px; }
.item { position: relative; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.item .thumb { display: block; width: 100%; aspect-ratio: 16/10; object-fit: contain; cursor: zoom-in;
  background: repeating-conic-gradient(#f1ebe0 0 25%, #fbf8f2 0 50%) 0 0/20px 20px; }
.item .cap { padding: 8px 12px 10px; font-size: 14px; }
.item .cbtn { top: 8px; right: 8px; }

/* Âm thanh */
.alist { display: flex; flex-direction: column; gap: 10px; }
.arow { position: relative; display: grid; grid-template-columns: 300px 1fr; gap: 16px; align-items: center;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 56px 10px 14px; }
.arow audio { width: 100%; }
.arow.has { border-left: 3px solid var(--accent); }
.arow .cbtn { opacity: 1; top: 50%; transform: translateY(-50%); }
@media (max-width: 760px) { .arow { grid-template-columns: 1fr; } }

.demo { width: 100%; aspect-ratio: 16/9; border: 1px solid var(--line); border-radius: var(--radius); background: #000; }
.pagebar { display: flex; gap: 8px; align-items: center; margin: 0 0 18px; flex-wrap: wrap; }
.home-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; text-decoration: none; color: var(--ink); }
.card:hover { border-color: var(--accent); }
.card b { display: block; } .card span { color: var(--muted); font-size: 13px; }
.howto { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 6px 20px; margin-bottom: 24px; }

/* Ngăn nhận xét */
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(420px, 100vw); background: var(--panel);
  border-left: 1px solid var(--line); box-shadow: -8px 0 30px rgba(60, 40, 10, .12); z-index: 60;
  transform: translateX(105%); transition: transform .2s; display: flex; flex-direction: column; }
.drawer.open { transform: none; }
.drawer-head { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.quote { margin: 12px 16px 0; padding: 8px 12px; background: var(--bg); border-left: 3px solid var(--accent);
  border-radius: 6px; font-size: 14px; max-height: 140px; overflow: auto; }
.quote img { max-width: 100%; max-height: 110px; display: block; }
.thread { flex: 1; overflow: auto; padding: 8px 16px; }
.c { padding: 10px 0; border-bottom: 1px solid var(--line); }
.c .who { font-weight: 600; font-size: 14px; }
.c .when { color: var(--muted); font-size: 12px; margin-left: 6px; }
.c .body { white-space: pre-wrap; margin-top: 2px; }
.c.done { opacity: .55; }
.tag { font-size: 11px; padding: 1px 7px; border-radius: 99px; margin-left: 6px; color: #fff; }
.tag.gop-y { background: var(--blue); } .tag.can-sua { background: var(--amber); } .tag.hay { background: var(--green); }
.tag.done { background: var(--muted); }
.form { border-top: 1px solid var(--line); padding: 12px 16px 16px; }
.form textarea { width: 100%; font: inherit; border: 1px solid var(--line); border-radius: 8px; padding: 8px; resize: vertical; }
.kinds { display: flex; gap: 12px; flex-wrap: wrap; font-size: 14px; margin-bottom: 8px; }
.form-row { display: flex; justify-content: space-between; align-items: center; margin-top: 8px; gap: 8px; }

/* Xem ảnh lớn + ghim */
.lightbox { position: fixed; inset: 0; background: rgba(20, 16, 10, .97); z-index: 50; display: flex; flex-direction: column; }
.lightbox[hidden] { display: none; }
.lb-bar { display: flex; gap: 14px; align-items: center; padding: 10px 16px; color: #fff; }
.lb-bar .ghost { color: #fff; margin-left: auto; }
.lb-stage { flex: 1; display: flex; align-items: center; justify-content: center; padding: 8px 16px 24px; min-height: 0; }
.drawer.open ~ .lightbox .lb-stage { padding-right: min(436px, 100vw); }
.lb-wrap { position: relative; max-width: 100%; max-height: 100%; }
.lb-wrap img { display: block; max-width: 100%; max-height: calc(100vh - 90px); cursor: crosshair; }
.pin { position: absolute; width: 26px; height: 26px; margin: -13px 0 0 -13px; border-radius: 50%; background: var(--accent);
  color: #fff; font-size: 12px; font-weight: 700; display: grid; place-items: center; border: 2px solid #fff;
  box-shadow: 0 2px 6px rgba(0,0,0,.4); cursor: pointer; }
.pin.new { background: #fff; color: var(--accent); }

dialog { border: 1px solid var(--line); border-radius: var(--radius); padding: 20px 24px; max-width: 380px; }
dialog input { width: 100%; font: inherit; padding: 8px; border: 1px solid var(--line); border-radius: 8px; }
dialog menu { padding: 0; margin: 14px 0 0; text-align: right; }

@media (max-width: 860px) {
  .menu-btn { display: block; }
  .nav { position: fixed; left: 0; z-index: 30; transform: translateX(-105%); transition: transform .2s; box-shadow: 8px 0 30px rgba(0,0,0,.1); }
  .nav.open { transform: none; }
  .brand span { display: none; }
  .blk { padding-left: 14px; }
}
