/* Thai Grammar Points: layout inspired by the Just the Docs theme */
:root {
  --body: #5c5962; --heading: #27262b; --link: #6741d9; --link-hover: #5328c9;
  --sidebar: #f5f6fa; --border: #eeebee; --code-bg: #f5f6fa; --bg: #ffffff;
  --muted: #8e8b93; --purple-000: #7253ed; --purple-100: #f2eefd;
  --green-dk: #026e46; --green-bg: #e6f7ef; --red-dk: #b42318; --red-bg: #fdecea;
  --blue-dk: #1e5bd2; --blue-bg: #eaf1fe; --yellow-bg: #fff8e1; --yellow-dk: #8a6100;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", "Noto Sans Thai", "Sarabun", "Leelawadee UI", "Thonburi", Tahoma, sans-serif;
  --sidebar-w: 280px;
}
* { box-sizing: border-box; }
html { font-size: 16px; scroll-behavior: smooth; }
body { margin: 0; font-family: var(--font); color: var(--body); background: var(--bg); line-height: 1.7; font-size: 1rem; }
a { color: var(--link); text-decoration: none; }
a:hover { color: var(--link-hover); text-decoration: underline; text-decoration-color: rgba(103,65,217,.35); }
h1, h2, h3, h4 { color: var(--heading); line-height: 1.3; font-weight: 600; }
.th-sub { color: var(--muted); font-weight: 400; font-size: .8em; margin-left: .35em; }

/* sidebar */
.side-bar { position: fixed; top: 0; left: 0; bottom: 0; width: var(--sidebar-w); background: var(--sidebar); border-right: 1px solid var(--border); display: flex; flex-direction: column; z-index: 10; }
.site-header { display: flex; align-items: center; justify-content: space-between; min-height: 64px; padding: 0 16px; border-bottom: 1px solid var(--border); }
.site-title { display: flex; align-items: center; gap: 10px; color: var(--heading); }
.site-title:hover { text-decoration: none; color: var(--heading); }
.site-title b { display: block; font-size: 1.1rem; line-height: 1.2; }
.site-title small { display: block; font-size: .78rem; color: var(--muted); letter-spacing: .02em; }
.site-logo { width: 36px; height: 36px; border-radius: 8px; background: var(--purple-000); color: #fff; display: grid; place-items: center; font-size: 1.3rem; font-weight: 700; }
.menu-button { display: none; border: 0; background: none; font-size: 1.5rem; color: var(--link); cursor: pointer; }
.site-nav { flex: 1; overflow-y: auto; padding: 12px 0 24px; }
.nav-list, .nav-sub { list-style: none; margin: 0; padding: 0; }
.nav-link { display: flex; justify-content: space-between; align-items: baseline; gap: 6px; padding: 5px 16px 5px 28px; color: var(--body); font-size: .92rem; line-height: 1.45; }
.nav-link:hover { background: linear-gradient(-90deg, rgba(235,237,245,1) 0%, rgba(235,237,245,.8) 80%, rgba(235,237,245,0) 100%); text-decoration: none; color: var(--link); }
.nav-item.active > .nav-link, .nav-item.active > details > summary > .nav-link { color: var(--link); font-weight: 600; background: linear-gradient(-90deg, rgba(235,237,245,1) 0%, rgba(235,237,245,.8) 80%, rgba(235,237,245,0) 100%); }
details > summary { list-style: none; position: relative; cursor: pointer; }
details > summary::-webkit-details-marker { display: none; }
details > summary::before { content: "›"; position: absolute; left: 12px; top: 4px; color: var(--muted); transition: transform .15s; font-size: 1rem; }
details[open] > summary::before { transform: rotate(90deg); }
.nav-count { font-size: .72rem; color: var(--muted); white-space: nowrap; }
.nav-sub .nav-link { padding-left: 40px; font-size: .86rem; justify-content: flex-start; }
.nav-id { font-size: .7rem; color: var(--muted); font-variant-numeric: tabular-nums; min-width: 40px; }
.nav-num { color: var(--muted); font-variant-numeric: tabular-nums; }
.site-footer { padding: 10px 16px; font-size: .75rem; color: var(--muted); border-top: 1px solid var(--border); }

/* main */
.main { margin-left: var(--sidebar-w); min-height: 100vh; }
.main-header { position: sticky; top: 0; z-index: 5; height: 64px; background: rgba(255,255,255,.96); border-bottom: 1px solid var(--border); display: flex; align-items: center; padding: 0 32px; }
.search { position: relative; width: 100%; max-width: 640px; }
#search-input { width: 100%; padding: 9px 12px 9px 36px; border: 1px solid transparent; border-radius: 6px; background: var(--sidebar) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%238e8b93' stroke-width='2'%3E%3Ccircle cx='7' cy='7' r='5'/%3E%3Cpath d='m11 11 4 4'/%3E%3C/svg%3E") no-repeat 11px center; font: inherit; font-size: .95rem; color: var(--heading); outline: none; }
#search-input:focus { background-color: #fff; border-color: var(--purple-000); box-shadow: 0 0 0 3px var(--purple-100); }
.search-results { display: none; position: absolute; top: 46px; left: 0; right: 0; max-height: 70vh; overflow-y: auto; background: #fff; border: 1px solid var(--border); border-radius: 6px; box-shadow: 0 10px 30px rgba(0,0,0,.12); }
.search-results.show { display: block; }
.search-results a { display: block; padding: 8px 14px; border-bottom: 1px solid var(--border); color: var(--body); }
.search-results a:hover, .search-results a.sel { background: var(--purple-100); text-decoration: none; }
.search-results .r-title { color: var(--heading); font-weight: 600; }
.search-results .r-id { font-size: .75rem; color: var(--muted); margin-right: 6px; }
.search-results .r-sub { display: block; font-size: .82rem; color: var(--muted); }
.search-results .r-none { padding: 10px 14px; color: var(--muted); }
.main-content-wrap { max-width: 860px; padding: 20px 32px 48px; }
.breadcrumb { font-size: .82rem; color: var(--muted); margin-bottom: 8px; }
.breadcrumb .sep { margin: 0 6px; color: #c8c6cc; }
.main-content h1 { font-size: 2rem; margin: 8px 0 16px; }
.main-content h2 { font-size: 1.4rem; margin: 40px 0 12px; padding-bottom: 6px; border-bottom: 1px solid var(--border); }
.main-content h3 { font-size: 1.12rem; margin: 28px 0 10px; }
.main-content p { margin: 0 0 14px; }
.main-content strong { color: var(--heading); }
.page-footer { margin-top: 48px; padding-top: 16px; border-top: 1px solid var(--border); font-size: .8rem; color: var(--muted); }

/* labels */
.label { display: inline-block; padding: 1px 9px; border-radius: 12px; font-size: .72rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; vertical-align: middle; line-height: 1.7; }
.label-beginner { background: var(--green-bg); color: var(--green-dk); }
.label-intermediate { background: var(--blue-bg); color: var(--blue-dk); }
.label-advanced { background: var(--purple-100); color: #5328c9; }
.label-green { background: var(--green-bg); color: var(--green-dk); }
.label-grey { background: #f0eff2; color: var(--muted); }

/* home */
.hero { padding: 28px 28px 20px; margin: 4px 0 24px; border-radius: 10px; background: linear-gradient(135deg, #f2eefd 0%, #f5f6fa 60%, #eaf1fe 100%); }
.hero h1 { margin: 0 0 6px !important; }
.hero-stats { margin: 0; color: var(--body); }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; }
.card { display: flex; flex-direction: column; gap: 3px; padding: 14px 16px; border: 1px solid var(--border); border-radius: 8px; background: #fff; color: var(--body); transition: box-shadow .15s, border-color .15s; }
.card:hover { text-decoration: none; border-color: #d9d2f7; box-shadow: 0 4px 14px rgba(114,83,237,.12); }
.card-title { color: var(--heading); font-weight: 600; }
.card-th { color: var(--muted); font-size: .9rem; }
.card-meta { font-size: .78rem; color: var(--muted); }

/* progress */
.progress { display: block; height: 6px; border-radius: 3px; background: #ecebef; overflow: hidden; max-width: 420px; }
.progress.small { margin: 6px 0 2px; max-width: none; height: 4px; }
.progress-bar { display: block; height: 100%; background: var(--purple-000); border-radius: 3px; }
.progress-text { font-size: .85rem; color: var(--muted); margin-top: 6px !important; }

/* tables */
.table-wrapper { overflow-x: auto; margin: 0 0 20px; border-radius: 6px; box-shadow: 0 1px 2px rgba(0,0,0,.07), 0 3px 10px rgba(0,0,0,.05); }
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th, td { padding: 8px 12px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: top; }
th { background: #fafafc; color: var(--heading); font-weight: 600; font-size: .8rem; }
td:first-child { white-space: nowrap; font-size: .8rem; }
td:nth-child(2) { color: var(--heading); font-weight: 600; min-width: 140px; }
tr:hover td { background: #fbfaff; }

/* point page */
.point-head { margin: 4px 0 8px; }
.point-meta { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.point-id { font-size: .8rem; font-weight: 600; color: var(--muted); letter-spacing: .04em; }
.point-title { font-size: 2.3rem !important; margin: 10px 0 4px !important; }
.lead { font-size: 1.12rem; color: var(--body); }
#structure ul { list-style: none; padding: 0; margin: 0; }
#structure li { padding: 10px 14px; margin: 0 0 8px; background: var(--code-bg); border-left: 4px solid var(--purple-000); border-radius: 0 6px 6px 0; color: var(--heading); font-size: 1.05rem; }
#examples ol, #more-examples ol { list-style: none; counter-reset: ex; padding: 0; margin: 0; }
#examples ol > li, #more-examples ol > li { counter-increment: ex; position: relative; padding: 10px 14px 10px 50px; margin: 0 0 10px; border: 1px solid var(--border); border-radius: 8px; color: var(--heading); font-size: 1.15rem; line-height: 1.6; }
#examples ol > li::before, #more-examples ol > li::before { content: counter(ex); position: absolute; left: 14px; top: 12px; width: 24px; height: 24px; border-radius: 50%; background: var(--purple-100); color: var(--purple-000); font-size: .8rem; font-weight: 700; display: grid; place-items: center; }
#examples li em, #more-examples li em { display: block; font-style: normal; color: var(--body); font-size: .93rem; }
#examples li strong, #more-examples li strong, .pair strong { color: var(--purple-000); }
.pair { margin: 14px 0; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.pair p { margin: 0 !important; padding: 9px 14px; }
.pair .bad { background: var(--red-bg); color: var(--red-dk); font-size: 1.08rem; }
.pair .bad strong, .pair .good strong { font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; margin-right: 4px; color: inherit; }
.pair .good { background: var(--green-bg); color: var(--green-dk); font-size: 1.08rem; }
.pair .good em { color: var(--body); font-size: .9rem; }
.pair .why { font-size: .93rem; background: #fff; }
.pair .why strong { color: var(--heading); }
.draft { padding: 12px 16px; margin: 16px 0; border-left: 4px solid #f7d12e; background: var(--yellow-bg); color: var(--yellow-dk); border-radius: 0 6px 6px 0; }
.draft p { margin: 0 !important; }
#related ul { padding-left: 20px; }
.refs { margin-top: 32px !important; font-size: .85rem; color: var(--muted); }
.prev-next { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 32px; }
.prev-next a { display: block; padding: 10px 14px; border: 1px solid var(--border); border-radius: 8px; color: var(--heading); }
.prev-next a:hover { border-color: #d9d2f7; text-decoration: none; background: #fbfaff; }
.prev-next small { display: block; color: var(--muted); font-size: .75rem; }
.prev-next .next { text-align: right; grid-column: 2; }

/* mobile */
@media (max-width: 860px) {
  .side-bar { position: static; width: auto; border-right: 0; border-bottom: 1px solid var(--border); }
  .menu-button { display: block; }
  .site-nav, .site-footer { display: none; }
  body.nav-open .site-nav, body.nav-open .site-footer { display: block; }
  .main { margin-left: 0; }
  .main-header { padding: 0 16px; }
  .main-content-wrap { padding: 16px 16px 40px; }
  .point-title { font-size: 1.9rem !important; }
  td:nth-child(3) { min-width: 180px; }
}
