:root {
    --purple: #6d4aff;
    --purple-dark: #4d2dcc;
    --purple-soft: #f0edff;
    --ink: #20183a;
    --muted: #6f6882;
    --line: #e7e2f1;
    --surface: #ffffff;
    --surface-alt: #f8f7fc;
    --success: #16845b;
    --danger: #c9364f;
    --warning: #a76b00;
    --shadow: 0 18px 55px rgba(44, 25, 100, .12);
    --radius: 22px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; color: var(--ink); background: var(--surface); font-family: "Noto Sans Thai", "Leelawadee UI", Tahoma, Arial, sans-serif; line-height: 1.65; }
body.admin-body { background: #f5f3fa; }
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
button, input, textarea, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
.container { width: min(1160px, calc(100% - 40px)); margin-inline: auto; }
.skip-link { position: fixed; left: 16px; top: -80px; z-index: 1000; padding: 10px 16px; background: var(--ink); color: #fff; border-radius: 10px; }
.skip-link:focus { top: 16px; }
.eyebrow { margin: 0 0 8px; color: var(--purple); font-size: .82rem; font-weight: 800; letter-spacing: .11em; text-transform: uppercase; }
.muted { color: var(--muted); }
.center { text-align: center; }

.site-header { position: sticky; top: 0; z-index: 100; background: rgba(255,255,255,.92); border-bottom: 1px solid rgba(231,226,241,.9); backdrop-filter: blur(18px); }
.nav-wrap { min-height: 76px; display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.site-brand { display: inline-flex; align-items: center; gap: 11px; min-width: max-content; }
.site-brand > span:last-child { display: grid; line-height: 1.15; }
.site-brand strong { font-size: 1.25rem; }
.site-brand small { margin-top: 4px; color: var(--muted); font-size: .72rem; letter-spacing: .06em; }
.brand-mark { width: 72px; height: 72px; display: grid; place-items: center; color: #fff; background: linear-gradient(145deg, #8f73ff, #5630e4); border-radius: 23px; font-weight: 900; font-size: 2.25rem; box-shadow: 0 14px 34px rgba(109,74,255,.28); }
.brand-mark.small { width: 43px; height: 43px; border-radius: 14px; font-size: 1.35rem; }
.brand-logo { width: 44px; height: 44px; flex: 0 0 44px; object-fit: contain; border-radius: 13px; background: #fff; box-shadow: 0 8px 24px rgba(56,37,120,.13); }
.site-nav { display: flex; align-items: center; gap: 3px; }
.site-nav a { padding: 10px 13px; color: #5d5670; border-radius: 11px; font-size: .94rem; font-weight: 650; }
.site-nav a:hover, .site-nav a.active { color: var(--purple-dark); background: var(--purple-soft); }
.nav-toggle { display: none; width: 44px; height: 44px; border: 0; border-radius: 12px; background: var(--purple-soft); padding: 11px; }
.nav-toggle span { display: block; height: 2px; margin: 4px 0; background: var(--purple-dark); }

.hero { position: relative; overflow: hidden; background: radial-gradient(circle at 85% 20%, #ddd5ff 0, transparent 32%), linear-gradient(155deg, #faf9ff 0%, #f1edff 58%, #fff 100%); border-bottom: 1px solid var(--line); }
.hero::after { content: ""; position: absolute; width: 420px; height: 420px; right: -220px; bottom: -260px; border: 70px solid rgba(109,74,255,.08); border-radius: 50%; }
.hero-grid { min-height: 620px; display: grid; grid-template-columns: 1.12fr .88fr; align-items: center; gap: 72px; padding: 80px 0; }
.hero h1 { max-width: 720px; margin: 0 0 22px; font-size: clamp(2.5rem, 5.3vw, 5.3rem); line-height: 1.04; letter-spacing: -.045em; }
.hero h1 span { color: var(--purple); }
.hero-lead { max-width: 680px; margin: 0 0 30px; color: var(--muted); font-size: 1.16rem; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 12px; }
.hero-notes { display: flex; flex-wrap: wrap; gap: 12px 22px; margin-top: 24px; color: var(--muted); font-size: .91rem; }
.hero-notes span::before { content: ""; display: inline-block; width: 7px; height: 7px; margin-right: 8px; background: var(--success); border-radius: 50%; }
.code-window { position: relative; border: 1px solid rgba(109,74,255,.16); background: #21163d; color: #f5f2ff; border-radius: 26px; box-shadow: 0 30px 80px rgba(32,24,58,.25); overflow: hidden; transform: rotate(1.4deg); }
.code-top { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; color: #bdb1df; background: #2b1f4b; font-size: .82rem; }
.code-dots { display: flex; gap: 7px; }
.code-dots i { width: 9px; height: 9px; border-radius: 50%; background: #7c689e; }
.code-window pre { margin: 0; padding: 32px 28px 38px; min-height: 290px; overflow: auto; font-family: Consolas, "Leelawadee UI", monospace; line-height: 1.9; }
.code-command { color: #b9a6ff; }
.code-string { color: #72dfb2; }
.code-comment { color: #8e82aa; }
.version-pill { display: inline-flex; align-items: center; gap: 7px; margin-bottom: 18px; padding: 7px 12px; color: var(--purple-dark); background: #fff; border: 1px solid #ded6ff; border-radius: 99px; font-size: .84rem; font-weight: 800; box-shadow: 0 8px 28px rgba(70,43,170,.08); }

.button { min-height: 46px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 11px 20px; border: 1px solid transparent; border-radius: 13px; cursor: pointer; font-weight: 780; transition: transform .16s ease, box-shadow .16s ease, background .16s ease; }
.button:hover { transform: translateY(-1px); }
.button.primary { color: #fff; background: linear-gradient(135deg, var(--purple), #5832df); box-shadow: 0 12px 28px rgba(109,74,255,.26); }
.button.secondary { color: var(--purple-dark); background: #fff; border-color: #dcd4f6; }
.button.light { color: var(--purple-dark); background: #fff; }
.button.danger { color: #fff; background: var(--danger); }
.button.ghost { min-height: 38px; padding: 7px 12px; color: var(--purple-dark); background: var(--purple-soft); }
.button.small { min-height: 36px; padding: 7px 12px; border-radius: 10px; font-size: .88rem; }
.button:disabled { opacity: .55; cursor: not-allowed; transform: none; }

.section { padding: 88px 0; }
.section.alt { background: var(--surface-alt); border-block: 1px solid var(--line); }
.section-heading { max-width: 760px; margin-bottom: 38px; }
.section-heading.center { margin-inline: auto; }
.section-heading h2, .page-hero h1 { margin: 0 0 12px; font-size: clamp(2rem, 4vw, 3.4rem); line-height: 1.16; letter-spacing: -.025em; }
.section-heading p, .page-hero p { margin: 0; color: var(--muted); font-size: 1.05rem; }
.feature-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.feature-card, .content-card, .download-card, .news-card, .product-card, .doc-card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 10px 32px rgba(38,23,84,.05); }
.feature-card { padding: 26px; }
.feature-icon { width: 46px; height: 46px; display: grid; place-items: center; margin-bottom: 20px; color: var(--purple-dark); background: var(--purple-soft); border-radius: 14px; font-weight: 900; }
.feature-card h3 { margin: 0 0 8px; font-size: 1.13rem; }
.feature-card p { margin: 0; color: var(--muted); }

.page-hero { padding: 76px 0 56px; background: linear-gradient(145deg, #faf9ff, #f0ecff); border-bottom: 1px solid var(--line); }
.page-hero .container { max-width: 920px; }
.breadcrumbs { margin-bottom: 16px; color: var(--muted); font-size: .9rem; }
.breadcrumbs a:hover { color: var(--purple); }
.content-grid { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 28px; align-items: start; }
.content-card { padding: 32px; }
.prose h2 { margin: 30px 0 12px; font-size: 1.5rem; }
.prose h3 { margin: 25px 0 10px; font-size: 1.18rem; }
.prose p { color: #443d55; }
.prose ul { padding-left: 22px; }
.prose pre { overflow: auto; padding: 18px; color: #f4f0ff; background: #21163d; border-radius: 14px; }
.prose code { padding: 2px 6px; color: #5233c9; background: #f0edff; border-radius: 6px; font-family: Consolas, monospace; }
.prose pre code { padding: 0; color: inherit; background: none; }
.sidebar-card { padding: 22px; background: #fff; border: 1px solid var(--line); border-radius: 18px; }
.sidebar-card + .sidebar-card { margin-top: 18px; }
.sidebar-card h3 { margin: 0 0 14px; }
.link-list { display: grid; gap: 7px; }
.link-list a { padding: 10px 12px; color: #5e5770; background: #faf9fd; border-radius: 10px; }
.link-list a:hover, .link-list a.active { color: var(--purple-dark); background: var(--purple-soft); }

.download-featured { display: grid; grid-template-columns: 1fr auto; gap: 25px; align-items: center; padding: 30px; background: linear-gradient(140deg, #251941, #4a2f9d); color: #fff; border-radius: 25px; box-shadow: var(--shadow); }
.download-featured h2 { margin: 5px 0 9px; font-size: 2rem; }
.download-featured p { margin: 0; color: #d9d0f0; }
.file-list { display: grid; gap: 11px; margin-top: 24px; }
.file-row { display: grid; grid-template-columns: minmax(0,1fr) auto auto; gap: 14px; align-items: center; padding: 16px 18px; background: #fff; border: 1px solid var(--line); border-radius: 14px; }
.file-row strong { display: block; }
.file-row small { color: var(--muted); }
.file-meta { color: var(--muted); font-size: .84rem; text-align: right; }
.hash { overflow-wrap: anywhere; font-family: Consolas, monospace; font-size: .79rem; color: var(--muted); }
.version-list { display: grid; gap: 18px; }
.download-card { padding: 25px; }
.download-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; }
.download-card h2 { margin: 0; }
.tag { display: inline-flex; padding: 5px 10px; color: var(--purple-dark); background: var(--purple-soft); border-radius: 99px; font-size: .77rem; font-weight: 800; }
.tag.stable { color: #126643; background: #e2f7ee; }
.tag.beta { color: #945d00; background: #fff2cf; }

.news-grid, .product-grid, .docs-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.news-card, .product-card, .doc-card { overflow: hidden; }
.news-cover, .product-image { aspect-ratio: 16/9; display: grid; place-items: center; color: var(--purple-dark); background: linear-gradient(135deg, #e8e2ff, #f8f6ff); font-size: 2.7rem; font-weight: 900; overflow: hidden; }
.news-cover img, .product-image img { width: 100%; height: 100%; object-fit: cover; }
.card-body { padding: 22px; }
.card-body h2, .card-body h3 { margin: 7px 0 8px; line-height: 1.35; }
.card-body p { margin: 0; color: var(--muted); }
.card-meta { display: flex; gap: 10px; align-items: center; color: var(--muted); font-size: .82rem; }
.card-link { display: inline-flex; margin-top: 17px; color: var(--purple-dark); font-weight: 800; }
.empty-state { padding: 48px 24px; text-align: center; color: var(--muted); background: #fff; border: 1px dashed #cec6df; border-radius: 20px; }

.steps { counter-reset: steps; display: grid; gap: 16px; }
.step { counter-increment: steps; display: grid; grid-template-columns: 54px 1fr; gap: 18px; padding: 22px; background: #fff; border: 1px solid var(--line); border-radius: 18px; }
.step::before { content: counter(steps); width: 46px; height: 46px; display: grid; place-items: center; color: #fff; background: var(--purple); border-radius: 14px; font-weight: 900; }
.step h3 { margin: 2px 0 5px; }
.step p { margin: 0; color: var(--muted); }

.sponsor-strip { padding: 45px 0 28px; overflow: hidden; background: #faf9fd; border-top: 1px solid var(--line); }
.sponsor-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 20px; margin-bottom: 22px; }
.sponsor-heading span { color: var(--purple); font-weight: 800; }
.sponsor-heading strong { color: var(--muted); font-size: .9rem; }
.sponsor-viewport { overflow: hidden; mask-image: linear-gradient(to right, transparent, black 8%, black 92%, transparent); }
.sponsor-track { width: max-content; display: flex; gap: 14px; animation: sponsor-scroll 30s linear infinite; }
.sponsor-track:hover { animation-play-state: paused; }
.sponsor-item { min-width: 280px; display: flex; align-items: center; gap: 13px; padding: 14px 17px; background: #fff; border: 1px solid var(--line); border-radius: 15px; }
.sponsor-item img, .sponsor-letter { width: 42px; height: 42px; object-fit: contain; border-radius: 11px; }
.sponsor-letter { display: grid; place-items: center; color: #fff; background: var(--purple); font-weight: 900; }
.sponsor-item span:last-child { display: grid; }
.sponsor-item small { color: var(--muted); }
@keyframes sponsor-scroll { to { transform: translateX(calc(-50% - 7px)); } }
.support-callout { padding: 50px 0; color: #fff; background: linear-gradient(135deg, #5b37e3, #3e228f); }
.support-inner { display: flex; align-items: center; justify-content: space-between; gap: 28px; }
.support-inner .eyebrow { color: #d8ceff; }
.support-inner h2 { margin: 0 0 5px; font-size: 1.8rem; }
.support-inner p { margin: 0; color: #dfd9f3; }

.site-footer { padding: 58px 0 24px; color: #cfc8df; background: #1d172b; }
.footer-grid { display: grid; grid-template-columns: 1.5fr repeat(3,1fr); gap: 40px; }
.footer-brand { color: #fff; }
.footer-grid h3 { margin: 0 0 12px; color: #fff; font-size: .95rem; }
.footer-grid > div { display: grid; align-content: start; gap: 7px; }
.footer-grid p { max-width: 330px; color: #9f96b4; }
.footer-grid a:not(.site-brand):hover { color: #fff; }
.copyright { margin-top: 38px; padding-top: 20px; color: #8f869f; border-top: 1px solid #332a46; font-size: .84rem; }

.alert { margin: 14px 0; padding: 13px 16px; border-radius: 12px; }
.alert.success { color: #0d6644; background: #e5f8ef; border: 1px solid #bee8d5; }
.alert.error { color: #a6253c; background: #fff0f2; border: 1px solid #f2c8d0; }
.alert.warning { color: #835500; background: #fff5d9; border: 1px solid #efdca7; }

label { display: grid; gap: 7px; color: #4b445d; font-size: .91rem; font-weight: 700; }
input, textarea, select { width: 100%; padding: 12px 13px; color: var(--ink); background: #fff; border: 1px solid #d8d2e2; border-radius: 11px; outline: none; }
input:focus, textarea:focus, select:focus { border-color: var(--purple); box-shadow: 0 0 0 3px rgba(109,74,255,.12); }
textarea { min-height: 150px; resize: vertical; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-grid .full { grid-column: 1 / -1; }
.checkbox { display: flex; align-items: center; gap: 9px; }
.checkbox input { width: auto; }
.full-button { width: 100%; margin-top: 22px; }

.installer { min-height: 100vh; background: linear-gradient(135deg, #241640, #5835d8); }
.install-shell { width: min(1180px, calc(100% - 36px)); min-height: 100vh; margin: auto; display: grid; grid-template-columns: .78fr 1.22fr; align-items: center; gap: 48px; padding: 54px 0; }
.install-intro { color: #fff; }
.install-intro .eyebrow { color: #d8ceff; }
.install-intro h1 { margin: 12px 0 16px; font-size: clamp(2.4rem, 5vw, 4.2rem); line-height: 1.1; }
.install-intro p { color: #ddd6ed; }
.feature-list { padding-left: 22px; color: #eee9f7; }
.install-card { max-width: 560px; margin: 40px auto; padding: 34px; background: #fff; border-radius: 26px; box-shadow: 0 30px 90px rgba(16,8,39,.32); }
.install-card.wide { max-width: none; margin: 0; }
.install-card h2 { margin: 0 0 16px; font-size: 1.7rem; }
.install-card h3 { margin: 25px 0 13px; }
.requirements { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.requirement { display: flex; align-items: center; gap: 8px; padding: 9px 11px; background: #faf9fc; border-radius: 9px; font-size: .84rem; }
.requirement span { padding: 2px 7px; border-radius: 99px; font-size: .7rem; font-weight: 900; }
.requirement.pass span { color: #0d6644; background: #dcf5e9; }
.requirement.fail span { color: #a6253c; background: #ffe2e7; }

.admin-shell { min-height: 100vh; display: grid; grid-template-columns: 260px minmax(0,1fr); }
.admin-sidebar { position: sticky; top: 0; height: 100vh; padding: 22px 16px; color: #d8d1e7; background: #211a31; overflow-y: auto; }
.admin-sidebar .site-brand { padding: 0 9px 20px; color: #fff; }
.admin-user { margin: 0 4px 18px; padding: 13px; background: #2d2441; border-radius: 12px; }
.admin-user strong { display: block; color: #fff; }
.admin-user small { color: #aaa0bd; }
.admin-menu { display: grid; gap: 4px; }
.admin-menu a { padding: 10px 12px; border-radius: 10px; }
.admin-menu a:hover, .admin-menu a.active { color: #fff; background: #3b2e58; }
.admin-sidebar-footer { margin-top: 22px; padding-top: 17px; border-top: 1px solid #3a304b; display: grid; gap: 6px; }
.admin-main { min-width: 0; padding: 34px; }
.admin-top { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 25px; }
.admin-top h1 { margin: 0; font-size: 2rem; }
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.stat-card { padding: 20px; background: #fff; border: 1px solid var(--line); border-radius: 16px; }
.stat-card small { color: var(--muted); }
.stat-card strong { display: block; margin-top: 7px; font-size: 2rem; }
.admin-card { margin-top: 20px; padding: 22px; background: #fff; border: 1px solid var(--line); border-radius: 18px; }
.admin-card h2 { margin: 0 0 16px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 12px 11px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-size: .78rem; letter-spacing: .04em; text-transform: uppercase; }
.actions { display: flex; flex-wrap: wrap; gap: 7px; }
.admin-form { display: grid; gap: 17px; }
.admin-form .form-actions { display: flex; gap: 10px; padding-top: 6px; }
.login-page { min-height: 100vh; display: grid; place-items: center; padding: 28px; background: linear-gradient(145deg, #f4f0ff, #fff); }
.login-card { width: min(430px, 100%); padding: 34px; background: #fff; border: 1px solid var(--line); border-radius: 24px; box-shadow: var(--shadow); }
.login-card .brand-mark { margin-bottom: 20px; }
.install-logo { width: 88px; height: 88px; object-fit: contain; display: block; margin: 0 0 20px; border-radius: 24px; background: #fff; box-shadow: 0 14px 36px rgba(65,42,150,.17); }
.login-card .install-logo { margin-inline: auto; }
.login-card h1 { margin: 0 0 6px; }
.login-card form { display: grid; gap: 15px; margin-top: 22px; }

@media (max-width: 960px) {
    .site-nav { position: absolute; top: 66px; left: 20px; right: 20px; display: none; padding: 12px; background: #fff; border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); }
    .site-nav.open { display: grid; }
    .nav-toggle { display: block; }
    .hero-grid { min-height: auto; grid-template-columns: 1fr; gap: 48px; padding: 65px 0 74px; }
    .code-window { transform: none; }
    .feature-grid, .news-grid, .product-grid, .docs-grid { grid-template-columns: repeat(2,1fr); }
    .content-grid { grid-template-columns: 1fr; }
    .footer-grid { grid-template-columns: 1.4fr 1fr 1fr; }
    .footer-grid > div:last-child { grid-column: 2; }
    .install-shell { grid-template-columns: 1fr; }
    .install-intro { max-width: 720px; }
    .admin-shell { grid-template-columns: 84px minmax(0,1fr); }
    .admin-sidebar { padding-inline: 10px; }
    .admin-sidebar .site-brand > span:last-child, .admin-user, .admin-menu span, .admin-sidebar-footer span { display: none; }
    .admin-menu a { text-align: center; font-size: .76rem; }
    .stats-grid { grid-template-columns: repeat(2,1fr); }
}

@media (max-width: 640px) {
    .container { width: min(100% - 28px, 1160px); }
    .nav-wrap { min-height: 66px; }
    .hero h1 { font-size: 2.55rem; }
    .hero-grid { padding-top: 48px; }
    .hero-actions .button { width: 100%; }
    .section { padding: 64px 0; }
    .feature-grid, .news-grid, .product-grid, .docs-grid { grid-template-columns: 1fr; }
    .file-row { grid-template-columns: 1fr; }
    .file-meta { text-align: left; }
    .download-featured { grid-template-columns: 1fr; }
    .download-featured .button { width: 100%; }
    .support-inner, .sponsor-heading { align-items: flex-start; flex-direction: column; }
    .footer-grid { grid-template-columns: 1fr 1fr; gap: 30px 22px; }
    .footer-grid > div:first-child { grid-column: 1 / -1; }
    .footer-grid > div:last-child { grid-column: auto; }
    .form-grid, .requirements { grid-template-columns: 1fr; }
    .form-grid .full { grid-column: auto; }
    .install-shell { width: min(100% - 24px, 1180px); padding: 28px 0; }
    .install-card { padding: 24px; border-radius: 20px; }
    .admin-shell { display: block; }
    .admin-sidebar { position: static; width: 100%; height: auto; }
    .admin-sidebar .site-brand > span:last-child { display: grid; }
    .admin-menu { grid-template-columns: repeat(3, 1fr); }
    .admin-main { padding: 22px 14px; }
    .admin-top { align-items: flex-start; flex-direction: column; }
    .stats-grid { grid-template-columns: 1fr 1fr; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .001ms !important; animation-iteration-count: 1 !important; }
    .sponsor-track { animation: none; }
}
