/* Vật Phẩm codex (make-codex.py): on top of landing.css; no hero here, so the bar is solid from the top. */
.codex .bar { background: rgba(252, 245, 230, .96); box-shadow: 0 1px 0 var(--line), 0 8px 20px -14px rgba(58, 38, 22, .5); }
.nav a[aria-current="page"] { background: var(--paper-2); color: var(--jade-d); }
.codex [hidden] { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.cx { padding-top: 84px; padding-bottom: 24px; }
.cx-head { margin-bottom: 20px; }
.cx-head h1 { font-size: clamp(32px, 7vw, 48px); font-weight: 800; }

/* tools: sticky under the bar so a long book can be switched mid-scroll */
.cx-tools { position: sticky; top: 60px; z-index: 10; display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; padding: 10px 0 12px; margin-bottom: 8px;
	background: linear-gradient(var(--paper) 82%, rgba(252, 245, 230, 0)); }
.cx-search input { width: 100%; min-height: 46px; padding: 0 16px; font: 500 17px var(--f); color: var(--ink);
	background: var(--cream); border: 2px solid var(--line); border-radius: 12px; -webkit-appearance: none; appearance: none; }
.cx-search input:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 3px rgba(201, 160, 98, .25); }
.tabs { display: none; gap: 6px; overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; margin: 0 -16px; padding: 0 16px 2px; }
.tabs::-webkit-scrollbar { display: none; }
.js .tabs { display: flex; }
.tab { flex: none; min-height: 38px; padding: 0 14px; font: 600 15px var(--f); color: var(--ink); background: var(--cream);
	border: 1.5px solid var(--line); border-radius: 999px; cursor: pointer; white-space: nowrap; }
.tab:hover { border-color: var(--gold); }
.tab[aria-pressed="true"] { color: #fff; background: var(--jade); border-color: var(--jade-d); }
@media (min-width: 900px) { .tabs { flex-wrap: wrap; justify-content: center; overflow: visible; margin: 0; padding: 0; } }

/* books */
.cat { margin: 26px 0 0; scroll-margin-top: 170px; }
.cat-h { text-align: center; margin-bottom: 14px; }
.cat-h h2 { font-size: clamp(26px, 5.4vw, 36px); }
.cat-h h2::before, .cat-h h2::after { content: "◆"; font-size: 11px; vertical-align: 6px; margin: 0 12px; color: var(--gold); }
.cat-h p { margin: 4px 0 0; color: var(--muted); font-style: italic; }
.part { margin-top: 14px; }
.part-h { font-size: 19px; font-weight: 700; color: var(--gold-d); margin: 0 0 8px; padding-bottom: 4px; border-bottom: 1px dashed var(--line); }
.grid { list-style: none; display: grid; gap: 10px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 620px) { .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 980px) { .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }

/* item card */
.it { display: flex; gap: 12px; align-items: flex-start; padding: 12px; background: var(--cream); border: 1.5px solid var(--line);
	border-radius: 12px; }
.it-pic { flex: none; display: grid; place-items: center; width: 64px; height: 64px; border-radius: 10px;
	background: var(--paper-2) radial-gradient(circle, rgba(255, 251, 241, .9), transparent 70%); border: 1px solid var(--line); }
.it-pic img { image-rendering: pixelated; image-rendering: crisp-edges; }
.ph { color: var(--gold); font-size: 22px; opacity: .6; }
.it-txt { min-width: 0; }
.it-n { display: block; font-size: 18px; line-height: 1.25; color: var(--ink); }
.r1 .it-n { color: #2a64a8; }
.r2 .it-n { color: #8a3cb0; }
.r2 { border-color: #d6b4e6; box-shadow: 0 0 0 1px rgba(138, 60, 176, .12) inset; }
.r2 .it-pic { border-color: #d6b4e6; }
.it-d { margin: 2px 0 0; font-size: 15px; color: var(--body); }
.it-t { margin: 4px 0 0; font-size: 15px; line-height: 1.45; color: var(--muted); font-style: italic; }
.it-details { margin-top: 4px; font-size: 14px; line-height: 1.5; color: var(--body); overflow-wrap: anywhere; }
.it-details summary { min-height: 44px; padding: 10px 0; cursor: pointer; color: var(--jade-d); font-weight: 600; }
.it-details summary:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; border-radius: 4px; }
.it-details ul { list-style: none; margin: 0; padding: 0; }
.it-details li + li { margin-top: 8px; }
.it-src { list-style: none; display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.it-src li { font-size: 12.5px; font-weight: 600; line-height: 1; padding: 5px 8px; border-radius: 999px; color: var(--gold-d);
	background: var(--paper-2); border: 1px solid var(--line); }
.cx-empty { text-align: center; margin: 40px 0; color: var(--muted); font-style: italic; }

/* Thần Nông Dược Điển: a herbal scroll, parchment with a jade edge */
.book-duoc-dien { padding: 18px 14px 20px; margin-left: -4px; margin-right: -4px; border-radius: 16px;
	background: #f1ead0 linear-gradient(180deg, rgba(46, 127, 94, .08), rgba(46, 127, 94, 0) 40%);
	border: 2px solid #7fb08e; border-top-width: 6px; border-bottom-width: 6px;
	box-shadow: 0 0 0 4px #f1ead0, 0 0 0 5px #c8dcc0, var(--shadow); }
.book-duoc-dien .cat-h h2 { color: var(--jade-d); }
.book-duoc-dien .cat-h h2::before, .book-duoc-dien .cat-h h2::after { content: "❦"; font-size: 16px; vertical-align: 4px; color: var(--jade); }
.book-duoc-dien .part-h { color: var(--jade-d); border-bottom-color: #a9c9a6; }
.book-duoc-dien .it { background: #fbf7e6; border-color: #cfdcbf; }
.book-duoc-dien .it-pic { background: #e3ecd3 radial-gradient(circle, rgba(251, 247, 230, .9), transparent 70%); border-color: #c0d4b4; }
.book-duoc-dien .it-src li { color: var(--jade-d); background: #e6efd9; border-color: #c0d4b4; }
@media (min-width: 860px) { .book-duoc-dien { padding: 26px 24px 28px; } }
