:root {
  --sun: #f97316; --sun2: #fbbf24; --sun3: #dc2626; --ink: #1f2937; --muted: #6b7280;
  --line: #e5e7eb; --link: #1d4ed8; --crumb: #15803d; --bg: #ffffff; --soft: #fff7ed;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: "Sarabun", "Noto Sans Thai", "Leelawadee UI", Tahoma, sans-serif; color: var(--ink); background: var(--bg); }
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
mark { background: #fde68a; color: inherit; padding: 0 1px; border-radius: 2px; }

/* logo */
.logo { font-weight: 800; letter-spacing: -1px; display: inline-flex; align-items: flex-end; user-select: none; cursor: pointer;
  background: linear-gradient(90deg, var(--sun2), var(--sun) 45%, var(--sun3)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.logo .i { position: relative; display: inline-block; }
.logo .sun { position: absolute; left: 50%; transform: translateX(-50%); border-radius: 50%;
  background: radial-gradient(circle, #fff7d6 0%, var(--sun2) 45%, var(--sun) 100%);
  box-shadow: 0 0 0 3px rgba(251, 191, 36, .25), 0 0 14px rgba(249, 115, 22, .55); }
.logo.big { font-size: 84px; line-height: 1; }
.logo.big .sun { width: 20px; height: 20px; top: 2px; }
.logo.small { font-size: 30px; line-height: 1; }
.logo.small .sun { width: 8px; height: 8px; top: 1px; box-shadow: 0 0 6px rgba(249, 115, 22, .6); }

/* search box */
.box { display: flex; align-items: center; gap: 10px; border: 1px solid #dfe1e5; border-radius: 28px; padding: 0 16px; height: 50px; background: #fff; }
.box:hover, .box:focus-within { box-shadow: 0 1px 6px rgba(32, 33, 36, .22); border-color: transparent; }
.box input { flex: 1; border: 0; outline: 0; font-size: 17px; font-family: inherit; background: transparent; }
.box .ico { color: var(--muted); font-size: 18px; }
.box .clear { cursor: pointer; color: var(--muted); font-size: 20px; padding: 0 4px; }
.box input::-webkit-search-cancel-button { -webkit-appearance: none; appearance: none; display: none; }

/* home */
.home { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 20px; }
.home .tag { color: var(--muted); margin: 10px 0 26px; }
.home .box { width: min(620px, 92vw); }
.btns { margin-top: 24px; display: flex; gap: 12px; }
.btn { background: #f8f9fa; border: 1px solid #f8f9fa; border-radius: 6px; padding: 9px 16px; font-family: inherit; font-size: 14px; cursor: pointer; color: var(--ink); }
.btn:hover { border-color: #dadce0; box-shadow: 0 1px 1px rgba(0, 0, 0, .1); }
.btn.primary { background: var(--soft); border-color: #fed7aa; }
.chips { margin-top: 26px; display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; max-width: 660px; }
.chip { border: 1px solid var(--line); border-radius: 16px; padding: 5px 12px; font-size: 14px; cursor: pointer; background: #fff; color: var(--ink); }
.chip:hover { background: var(--soft); border-color: #fed7aa; }
.stats { margin-top: 34px; color: var(--muted); font-size: 13px; }

/* header */
.top { display: flex; align-items: center; gap: 24px; padding: 18px 28px 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.top .box { width: min(640px, 70vw); height: 44px; }
.tabs { display: flex; gap: 20px; padding: 14px 0 0 calc(28px + 120px + 24px); font-size: 14px; flex-wrap: wrap; }
.tab { padding-bottom: 10px; color: var(--muted); cursor: pointer; border-bottom: 3px solid transparent; }
.tab.on { color: var(--sun); border-color: var(--sun); font-weight: 600; }
.wrap { padding: 0 28px 60px calc(28px + 120px + 24px); max-width: 1180px; }
.count { color: var(--muted); font-size: 13px; margin: 14px 0 18px; }

/* results */
.res { display: flex; gap: 16px; margin-bottom: 26px; max-width: 760px; }
.res .body { flex: 1; min-width: 0; }
.res .crumb { font-size: 13px; color: var(--crumb); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.res .title { font-size: 19px; margin: 3px 0 4px; display: block; }
.res .snip { font-size: 14px; color: #4b5563; line-height: 1.6; }
.res .thumb { width: 116px; height: 78px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); flex: none; }
.empty { max-width: 640px; line-height: 1.8; }

/* article */
.art { display: grid; grid-template-columns: minmax(0, 1fr) 260px; gap: 40px; max-width: 1120px; }
.art .crumb { font-size: 13px; color: var(--crumb); margin: 18px 0 6px; }
.art h1 { font-size: 26px; margin: 4px 0 6px; }
.art .meta { color: var(--muted); font-size: 13px; margin-bottom: 16px; display: flex; gap: 14px; flex-wrap: wrap; align-items: center; }
.open { display: inline-block; border: 1px solid #fed7aa; background: var(--soft); color: #9a3412; border-radius: 16px; padding: 3px 12px; font-size: 13px; }
.content { line-height: 1.75; font-size: 16px; }
.content h2 { font-size: 21px; margin: 28px 0 8px; padding-top: 6px; border-top: 1px solid var(--line); }
.content h3 { font-size: 18px; margin: 22px 0 6px; }
.content p { margin: 6px 0; }
.content .q { background: var(--soft); border-left: 4px solid var(--sun2); padding: 8px 12px; border-radius: 6px; }
.content .li { display: flex; gap: 8px; margin: 4px 0; }
.content .li .mk { color: var(--sun); font-weight: 700; min-width: 22px; text-align: right; flex: none; }
.content figure { margin: 12px 0 18px; text-align: center; }
.content figure img { max-width: 100%; max-height: 520px; border: 1px solid var(--line); border-radius: 8px; cursor: zoom-in; }
.content figcaption { font-size: 13px; color: var(--muted); margin-top: 6px; }
.content table { border-collapse: collapse; margin: 10px 0 16px; font-size: 14px; width: 100%; }
.content td, .content th { border: 1px solid var(--line); padding: 6px 10px; vertical-align: top; text-align: left; }
.content th { background: #f9fafb; }
.content .file { display: inline-block; border: 1px solid var(--line); border-radius: 8px; padding: 6px 12px; margin: 4px 0; font-size: 14px; }
.side { position: sticky; top: 16px; align-self: start; margin-top: 18px; font-size: 14px; }
.side h4 { margin: 0 0 8px; font-size: 13px; color: var(--muted); font-weight: 600; }
.side a { display: block; padding: 4px 0 4px 10px; border-left: 2px solid var(--line); color: var(--ink); }
.side a.on, .side a:hover { border-left-color: var(--sun); color: var(--sun); text-decoration: none; }
.side a.l3 { padding-left: 22px; font-size: 13px; }
.back { display: inline-block; margin-top: 18px; font-size: 14px; }

#lightbox { position: fixed; inset: 0; background: rgba(17, 24, 39, .88); display: flex; flex-direction: column; align-items: center; justify-content: center; z-index: 10; cursor: zoom-out; padding: 20px; }
#lightbox[hidden] { display: none; }
#lightbox img { max-width: 96vw; max-height: 86vh; border-radius: 6px; background: #fff; }
#lightbox .lb-cap { color: #f3f4f6; margin-top: 10px; font-size: 14px; text-align: center; }

@media (max-width: 900px) {
  .tabs, .wrap { padding-left: 16px; padding-right: 16px; }
  .tabs { flex-wrap: nowrap; overflow-x: auto; gap: 18px; scrollbar-width: none; }
  .tabs::-webkit-scrollbar { display: none; }
  .tab { flex: none; white-space: nowrap; }
  .top { padding: 14px 16px 0; }
  .top .box { width: 100%; }
  .art { grid-template-columns: 1fr; }
  .side { position: static; }
  .logo.big { font-size: 64px; }
}
