:root {
  --mono: 'JetBrains Mono', ui-monospace, Menlo, Consolas, monospace;
  --disp: 'Space Grotesk', system-ui, sans-serif;
  --thai: 'IBM Plex Sans Thai', system-ui, sans-serif;
  --gx: 40px;
  --accent: linear-gradient(120deg, oklch(0.42 0.2 265), oklch(0.2 0.09 265) 85%);
  --accent-lt: oklch(0.82 0.13 265);
  --body-size: 18px;
}
html { scroll-behavior: smooth; }
body { margin: 0; background: #000; color: #e6e6e6; font-family: var(--thai); min-height: 100vh; }
body.read { background: #0f1113; }
a { color: #fff; text-decoration: none; }
button { font: inherit; }
input::placeholder, textarea::placeholder { color: #666; }
:focus-visible { outline: 1px solid #fff; outline-offset: 2px; }
[hidden] { display: none !important; }
@keyframes kvmarq { from { transform: translateX(0); } to { transform: translateX(-50%); } }
@keyframes kvblink { 50% { opacity: 0; } }

#prog { position: fixed; top: 0; left: 0; height: 3px; width: 0; background: var(--accent-lt); z-index: 50; }

/* ---------- header ---------- */
#hdr {
  position: fixed; top: 0; left: 0; right: 0; z-index: 20;
  display: flex; align-items: center; gap: 20px;
  padding: 16px var(--gx); padding-top: max(16px, env(safe-area-inset-top));
  font-family: var(--mono); font-size: 13px; letter-spacing: .06em;
  background: linear-gradient(#000 40%, transparent);
}
body.read #hdr { background: #0a0b0d; }
.logo { color: #fff; white-space: nowrap; }
#tabs { flex: 1; display: flex; align-self: stretch; margin: -16px 0 -16px 24px; min-width: 0; }
#tabs a {
  flex: 1; display: flex; align-items: center; justify-content: center;
  border-bottom: 2px solid transparent; color: #8a8a8a; letter-spacing: .14em; font-size: 12px;
}
#tabs a:hover, #tabs a:focus-visible { color: #fff; background: #0c0c0c; }
#tabs a.on { color: #fff; border-bottom-color: #fff; }
.short { display: none; }
.hbtn { background: none; border: 1px solid #2e2e2e; color: #fff; padding: 9px 14px; cursor: pointer; white-space: nowrap; }
.hbtn:hover, .hbtn:focus-visible { border-color: #fff; }
.newbtn { border: 1px solid #fff; padding: 9px 16px; white-space: nowrap; }
.newbtn:hover, .newbtn:focus-visible { background: #fff; color: #000; }
#searchPanel {
  position: absolute; top: 100%; right: var(--gx); width: min(480px, calc(100vw - 2 * var(--gx)));
  background: #050505; border: 1px solid #2e2e2e; margin-top: -4px;
}
#q { width: 100%; box-sizing: border-box; background: transparent; border: none; border-bottom: 1px solid #1c1c1c; color: #fff; padding: 14px; font: inherit; font-size: 13px; outline: none; }
#results { max-height: 50vh; overflow: auto; }
.res { display: block; padding: 12px 14px; border-bottom: 1px solid #161616; }
.res:hover, .res:focus-visible { background: #101010; }
.res-t { color: #fff; font-family: var(--thai); font-size: 14px; letter-spacing: 0; }
.res-p { font-size: 11px; color: #777; margin-top: 3px; }
.res-none { padding: 14px; color: #777; font-size: 12px; }

/* ---------- home / hero ---------- */
.hero { position: relative; height: 100vh; height: 100svh; min-height: 560px; overflow: hidden; background: #000; }
.hud, .log { position: absolute; z-index: 2; left: var(--gx); font-family: var(--mono); font-size: 11px; white-space: pre; pointer-events: none; }
.hud { top: 84px; letter-spacing: .1em; color: #777; line-height: 1.8; }
.log { top: 170px; letter-spacing: .06em; color: #8a8a8a; line-height: 1.9; }
#globe { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.hero-ov {
  position: absolute; inset: 0; pointer-events: none;
  background: repeating-linear-gradient(0deg, rgba(255,255,255,.025) 0 1px, transparent 1px 3px),
              radial-gradient(ellipse at center, transparent 45%, #000 105%);
}
.hero-txt {
  position: absolute; left: var(--gx); right: var(--gx); bottom: max(48px, env(safe-area-inset-bottom));
  display: flex; justify-content: space-between; align-items: flex-end; gap: 24px; flex-wrap: wrap;
}
.hero-h1 {
  margin: 0; font-family: var(--disp); font-size: clamp(40px, 8vw, 112px); font-weight: 700; color: #fff;
  line-height: .95; letter-spacing: -.03em; text-shadow: 0 0 12px #000, 0 0 24px #000;
}
.blink { animation: kvblink 1s steps(1) infinite; font-weight: 400; }
.hero-sub { margin-top: 16px; font-family: var(--mono); font-size: 13px; color: #8a8a8a; text-shadow: 0 0 8px #000; }
.enter { font-family: var(--mono); font-size: 13px; letter-spacing: .1em; border: 1px solid #fff; padding: 14px 26px; background: rgba(0,0,0,.4); }
.enter:hover, .enter:focus-visible { background: #fff; color: #000; }
.marquee { border-top: 1px solid #1c1c1c; border-bottom: 1px solid #1c1c1c; overflow: hidden; background: #000; padding: 14px 0; }
.marquee-in { display: flex; width: max-content; animation: kvmarq 40s linear infinite; font-family: var(--mono); font-size: 12px; letter-spacing: .2em; color: #777; white-space: nowrap; }

#library { padding: 96px var(--gx); max-width: 1200px; margin: 0 auto; }
.kicker { font-family: var(--mono); font-size: 12px; color: #fff; letter-spacing: .14em; }
.recent-k { margin-top: 72px; }
.lib-h { font-size: 36px; font-weight: 400; margin: 8px 0 40px; color: #fff; }
.cats { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(300px, 100%), 1fr)); gap: 1px; background: #1c1c1c; border: 1px solid #1c1c1c; }
.card { position: relative; background: #050505; will-change: transform; padding: 28px; display: flex; flex-direction: column; gap: 16px; min-height: 220px; cursor: pointer; color: inherit; }
.card-top { display: flex; justify-content: space-between; font-family: var(--mono); font-size: 12px; color: #8a8a8a; }
.card-name { font-size: 26px; color: #fff; }
.card-desc { color: #8a8a8a; font-size: 15px; line-height: 1.6; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: auto; }
.chip { font-family: var(--mono); font-size: 12px; padding: 5px 10px; border: 1px solid #2e2e2e; color: #fff; }
.rlist { margin-top: 16px; border: 1px solid #1c1c1c; }
.rrow { display: flex; align-items: center; gap: 16px; padding: 16px 20px; border-bottom: 1px solid #161616; background: #050505; }
.rrow:last-child { border-bottom: none; }
.rrow:hover, .rrow:focus-visible { background: #101010; }
.rrow-t { flex: 1; color: #fff; min-width: 0; }
.rrow-p { font-family: var(--mono); font-size: 11px; color: #777; white-space: nowrap; }
.tag { flex: none; font-family: var(--mono); font-size: 11px; width: 56px; color: #000; text-align: center; padding: 3px 0; }

/* ---------- category / item band ---------- */
.band { background: var(--accent); padding: 112px var(--gx) 52px; position: relative; overflow: hidden; }
.band.item { padding: 104px var(--gx) 44px; }
.bits {
  position: absolute; inset: 0; overflow: hidden; opacity: .16; font-family: var(--mono); font-size: 12px; line-height: 15px;
  letter-spacing: .3em; color: #fff; word-break: break-all; pointer-events: none;
  -webkit-mask-image: linear-gradient(90deg, transparent 10%, #000 85%); mask-image: linear-gradient(90deg, transparent 10%, #000 85%);
}
.band-in { max-width: 1000px; margin: 0 auto; color: #fff; position: relative; }
.crumb { font-family: var(--mono); font-size: 12px; color: #fff; }
.crumb a:hover { text-decoration: underline; }
.cat-h1 { font-family: var(--disp); font-size: clamp(44px, 8vw, 96px); font-weight: 700; letter-spacing: -.03em; line-height: 1; color: #fff; margin: 18px 0 16px; }
.cat-meta { display: flex; gap: 16px; align-items: baseline; flex-wrap: wrap; }
.cat-desc { font-size: 18px; color: #fff; max-width: 560px; line-height: 1.7; }
.mono12 { font-family: var(--mono); font-size: 12px; color: #fff; }
.wrap { max-width: 1000px; margin: 0 auto; padding: 44px var(--gx) 100px; }
.subtabs { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 28px; }
.subtab { font-family: var(--mono); font-size: 12px; padding: 8px 14px; cursor: pointer; border: 1px solid #343a40; background: transparent; color: #9a9fa4; }
.subtab:hover { color: #f2f2ee; border-color: #9a9fa4; }
.subtab.on { border-color: #f2f2ee; background: #f2f2ee; color: #111; }
.clist { border: 1px solid #262a2e; }
.crow { display: flex; align-items: center; gap: 16px; padding: 18px 20px; border-bottom: 1px solid #1e2226; background: #15181b; transition: padding .2s, background .2s; }
.crow:last-child { border-bottom: none; }
.crow:hover, .crow:focus-visible { background: #1c2024; padding-left: 30px; }
.crow-b { flex: 1; min-width: 0; }
.crow-t { color: #f2f2ee; font-size: 19px; font-weight: 500; line-height: 1.4; }
.crow-x { font-size: 14px; line-height: 1.6; color: #9a9fa4; margin-top: 6px; max-width: 640px; }
.crow-m { font-family: var(--mono); font-size: 11px; color: #7d838a; margin-top: 4px; }
.arrow { color: #7d838a; }
.empty { padding: 32px; color: #7d838a; text-align: center; }
.empty a { text-decoration: underline; }

/* ---------- item ---------- */
.item-h1 { font-family: 'Space Grotesk', 'IBM Plex Sans Thai', sans-serif; font-size: clamp(32px, 5vw, 58px); font-weight: 700; line-height: 1.1; letter-spacing: -.02em; color: #fff; margin: 18px 0 22px; max-width: 860px; text-wrap: balance; }
.item-meta { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; font-family: var(--mono); font-size: 12px; color: #fff; }
.item-type { color: #000; background: #fff; padding: 2px 8px; }
.ghost { font-family: var(--mono); font-size: 12px; padding: 6px 14px; cursor: pointer; background: none; color: #fff; border: 1px solid #fff; }
.ghost:hover, .ghost:focus-visible { background: #fff; color: #000; }
.ghost.dim { border-color: rgba(255,255,255,.45); }
.ghost.push { margin-left: auto; }
.item-wrap { padding-top: 48px; }
.item-cols { display: flex; flex-wrap: wrap; gap: 56px; align-items: flex-start; }
.item-main { flex: 1 1 560px; min-width: 0; display: flex; flex-direction: column; gap: 36px; }
.prose { max-width: 720px; }
.prose h2 {
  font-family: 'Space Grotesk', 'IBM Plex Sans Thai', sans-serif; font-size: 30px; font-weight: 600; letter-spacing: -.01em; line-height: 1.25; color: #f2f2ee;
  margin: 36px 0 14px; padding-top: 22px; border-top: 1px solid #262a2e; display: flex; gap: 14px; align-items: baseline; scroll-margin-top: 90px;
}
.prose h2 .n { font-family: var(--mono); font-size: 13px; font-weight: 600; color: var(--accent-lt); }
.prose p { font-size: var(--body-size); line-height: 1.95; color: #d8d8d4; margin: 0 0 20px; white-space: pre-wrap; text-wrap: pretty; overflow-wrap: anywhere; }
figure { margin: 0; }
.media-img { max-width: 100%; display: block; border: 1px solid #262a2e; }
.media-vid { width: 100%; display: block; background: #000; border: 1px solid #1c1c1c; }
.media-ph { aspect-ratio: 16/9; display: flex; align-items: center; justify-content: center; border: 1px solid #262a2e; color: #7d838a; font-family: var(--mono); font-size: 12px; }
.cap { margin-top: 10px; font-family: var(--mono); font-size: 12px; color: #9a9fa4; }
.cfg { border: 1px solid #2e2e2e; background: #020202; }
.cfg-h { display: flex; align-items: center; padding: 10px 16px; border-bottom: 1px solid #1c1c1c; font-family: var(--mono); font-size: 12px; color: #8a8a8a; gap: 16px; }
.cfg-h span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cfg-btn { background: none; border: 1px solid #2e2e2e; color: #fff; padding: 5px 12px; font-family: var(--mono); font-size: 12px; cursor: pointer; }
.cfg-btn:hover, .cfg-btn:focus-visible { border-color: #fff; }
.cfg-b { overflow: auto; max-height: 70vh; padding: 14px 0; font-family: var(--mono); font-size: 13px; line-height: 1.7; }
.ln { display: flex; white-space: pre; min-width: max-content; }
.ln:hover { background: rgba(255,255,255,.07); }
.ln i { font-style: normal; width: 48px; flex: none; text-align: right; padding-right: 16px; color: #3b4b43; user-select: none; }
.ln b { font-weight: 400; }
.filebox { display: flex; align-items: center; gap: 16px; border: 1px solid #262a2e; background: #15181b; padding: 16px 20px; }
.filebox .ft { font-family: var(--mono); font-size: 11px; color: #000; background: #f2f2ee; padding: 3px 8px; }
.filebox .fb { flex: 1; min-width: 0; }
.filebox .fn { color: #f2f2ee; overflow-wrap: anywhere; }
.filebox .fm { font-family: var(--mono); font-size: 11px; color: #7d838a; margin-top: 3px; }
.dlbtn { background: none; border: 1px solid #343a40; color: #f2f2ee; padding: 7px 14px; font-family: var(--mono); font-size: 12px; cursor: pointer; }
.dlbtn:hover, .dlbtn:focus-visible { border-color: #f2f2ee; }
.toc { flex: 0 0 220px; position: sticky; top: 96px; font-family: var(--mono); font-size: 12px; }
.toc-k { color: #7d838a; letter-spacing: .14em; margin-bottom: 14px; }
.toc-l { display: flex; flex-direction: column; border-left: 1px solid #343a40; }
.toc-l a { padding: 7px 0 7px 16px; margin-left: -1px; border-left: 1px solid transparent; color: #9a9fa4; line-height: 1.5; font-family: var(--thai); font-size: 14px; }
.toc-l a:hover, .toc-l a.on { color: #f2f2ee; border-left-color: #f2f2ee; }

/* ---------- editor ---------- */
.ed { padding: 120px var(--gx); max-width: 860px; margin: 0 auto; }
.ed-k { font-family: var(--mono); font-size: 12px; color: #f2f2ee; letter-spacing: .14em; }
.ed-h { font-size: 40px; font-weight: 400; color: #f2f2ee; margin: 8px 0 28px; }
.ed-f { display: flex; flex-direction: column; gap: 16px; }
.inp { background: #15181b; border: 1px solid #343a40; color: #f2f2ee; padding: 10px 12px; font-family: var(--mono); font-size: 13px; outline: none; }
.inp:focus, .ta:focus { border-color: #9a9fa4; }
.inp.title { font-family: var(--thai); font-size: 18px; padding: 14px; }
select.inp { padding: 14px; color: #d8d8d4; }
.ta { background: #15181b; border: 1px solid #343a40; color: #d8d8d4; padding: 12px; font-family: var(--thai); font-size: 16px; line-height: 1.7; outline: none; resize: vertical; }
.ta.code { font-family: var(--mono); font-size: 13px; line-height: 1.6; white-space: pre; }
.ebs { display: flex; flex-direction: column; gap: 14px; margin-top: 8px; }
.eb { border: 1px solid #262a2e; background: #15181b; }
.eb-h { display: flex; align-items: center; gap: 6px; padding: 8px 12px; border-bottom: 1px solid #262a2e; font-family: var(--mono); font-size: 11px; color: #9a9fa4; letter-spacing: .1em; }
.eb-h span { flex: 1; }
.ib { background: none; border: none; color: #9a9fa4; cursor: pointer; font-family: var(--mono); padding: 4px 8px; }
.ib:hover, .ib:focus-visible { color: #f2f2ee; }
.ib.x { color: #e07a74; }
.eb-b { padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.pick { align-self: flex-start; border: 1px dashed #4d545b; padding: 10px 16px; cursor: pointer; font-family: var(--mono); font-size: 12px; color: #9a9fa4; }
.pick:hover, .pick:focus-within { border-color: #f2f2ee; color: #f2f2ee; }
.pick input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.prev-img, .prev-vid { max-width: 100%; max-height: 300px; align-self: flex-start; border: 1px solid #262a2e; background: #000; }
.adds { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; font-family: var(--mono); font-size: 12px; }
.adds-k { color: #7d838a; margin-right: 4px; }
.addb { background: none; border: 1px solid #343a40; color: #f2f2ee; padding: 9px 14px; font-family: var(--mono); font-size: 12px; cursor: pointer; }
.addb:hover, .addb:focus-visible { border-color: #f2f2ee; }
.ed-foot { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-top: 12px; border-top: 1px solid #262a2e; padding-top: 20px; }
.save { background: #f2f2ee; color: #111; border: none; padding: 14px 28px; font-family: var(--mono); font-size: 13px; letter-spacing: .08em; cursor: pointer; }
.save:hover, .save:focus-visible { background: #fff; }
.save:disabled { opacity: .5; cursor: wait; }
.err { font-family: var(--mono); font-size: 12px; color: #e07a74; }
.note { margin-left: auto; font-family: var(--mono); font-size: 11px; color: #7d838a; }

/* ---------- responsive ---------- */
@media (max-width: 860px) {
  :root { --gx: 20px; }
  #hdr { gap: 10px; font-size: 12px; }
  #tabs { margin-left: 4px; }
  #tabs a { letter-spacing: .06em; font-size: 11px; }
  .full { display: none; }
  .short { display: inline; }
  .hbtn, .newbtn { padding: 8px 10px; }
  .toc { display: none; }
  .crow .arrow, .rrow-p { display: none; }
  .note { margin-left: 0; }
}
@media (max-width: 480px) {
  .logo { font-size: 0; }
  .logo::before { content: '>_'; font-size: 13px; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .marquee-in, .blink { animation: none; }
  .crow { transition: none; }
}
.ed.login { max-width: 480px; padding-top: 160px; }
