:root {
  --bg: #fff8e7; --surface: #ffffff; --surface2: #fdf0cf; --ink: #3b2a1a; --muted: #8a7458; --line: #eadcb8;
  --accent: #c8741f; --accent-ink: #ffffff; --pudding: #f6c453; --good: #2e8b57; --bad: #c0392b;
  --shadow: 0 2px 10px rgba(120, 80, 20, .10);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1d1510; --surface: #2a1f17; --surface2: #36291e; --ink: #f6ead4; --muted: #b59d7c; --line: #4a3a2a;
    --accent: #f0a04b; --accent-ink: #2a1a08; --pudding: #f6c453; --good: #5dd39e; --bad: #ff7b6b;
    --shadow: 0 2px 12px rgba(0, 0, 0, .4); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #1d1510; --surface: #2a1f17; --surface2: #36291e; --ink: #f6ead4; --muted: #b59d7c; --line: #4a3a2a;
  --accent: #f0a04b; --accent-ink: #2a1a08; --pudding: #f6c453; --good: #5dd39e; --bad: #ff7b6b;
  --shadow: 0 2px 12px rgba(0, 0, 0, .4); color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 400 16px/1.6 Sarabun, system-ui, sans-serif; }
h1, h2, h3, .brand, .rc b { font-family: Kanit, Sarabun, sans-serif; font-weight: 600; line-height: 1.25; }
h1 { font-size: clamp(1.8rem, 5vw, 2.6rem); margin: .6em 0 .3em; }
h2 { font-size: 1.4rem; margin: 1.8em 0 .6em; }
h3 { font-size: 1.05rem; margin: 0 0 .3em; }
a { color: var(--accent); }
code { background: var(--surface2); padding: .1em .4em; border-radius: 5px; font-size: .92em; }
.wrap { max-width: 1080px; margin: 0 auto; padding: 0 16px; }
.muted { color: var(--muted); font-size: .92rem; }
.lead { font-size: 1.1rem; color: var(--muted); margin-top: 0; }

/* top bar */
.top { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
.bar { display: flex; align-items: center; gap: 14px; min-height: 58px; flex-wrap: wrap; }
.brand { font-size: 1.3rem; color: var(--ink); text-decoration: none; display: flex; align-items: center; gap: 8px; }
.logo { font-size: 1.5rem; }
nav { display: flex; gap: 4px; flex: 1; flex-wrap: wrap; }
nav a { color: var(--ink); text-decoration: none; padding: 6px 12px; border-radius: 999px; }
nav a:hover { background: var(--surface2); }
nav a[aria-current] { background: var(--pudding); color: #3b2a1a; font-weight: 700; }
.srv { display: inline-flex; align-items: center; gap: 6px; font-size: .88rem; color: var(--muted); }
.srv i { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); }
.srv.up i { background: var(--good); } .srv.down i { background: var(--bad); }
.theme { background: none; border: 1px solid var(--line); color: var(--ink); border-radius: 999px; width: 34px; height: 34px; cursor: pointer; }

/* hero */
.hero { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 28px; align-items: start; padding: 28px 0 8px; }
.eyebrow { color: var(--accent); font-weight: 700; letter-spacing: .06em; text-transform: uppercase; font-size: .85rem; margin: 0; }
.rates { display: flex; flex-wrap: wrap; gap: 10px; margin: 18px 0; }
.rc { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 8px 14px; text-align: center; min-width: 84px; box-shadow: var(--shadow); }
.rc b { display: block; font-size: 1.4rem; color: var(--accent); }
.rc span { font-size: .8rem; color: var(--muted); }
.cta { display: flex; flex-wrap: wrap; gap: 10px; margin: 16px 0; }
.btn { display: inline-block; border: 1px solid var(--line); background: var(--surface); color: var(--ink); padding: 9px 18px; border-radius: 999px; text-decoration: none; font: 600 1rem Sarabun, sans-serif; cursor: pointer; }
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.disabled { color: var(--muted); border-style: dashed; cursor: default; }

/* cards & forms */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 20px; box-shadow: var(--shadow); }
.card h2 { margin-top: 0; }
.card.narrow { max-width: 440px; }
.card.flush { padding: 0; overflow-x: auto; }
form label { display: block; font-weight: 500; margin-bottom: 12px; }
form input:not([type=radio]) { display: block; width: 100%; margin-top: 4px; padding: 9px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); color: var(--ink); font: inherit; }
input:focus-visible, button:focus-visible, a:focus-visible, summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
fieldset { border: 0; padding: 0; margin: 0 0 12px; }
legend { font-weight: 500; padding: 0; }
label.inl { display: inline-block; margin-right: 16px; font-weight: 400; }
.cf-slot { min-height: 0; margin-bottom: 12px; }
.msg { margin: 12px 0 0; min-height: 1.4em; font-weight: 500; }
.msg.ok { color: var(--good); } .msg.err { color: var(--bad); }

/* tiles */
.grid3, .grid2 { display: grid; gap: 14px; margin: 18px 0; }
.grid3 { grid-template-columns: repeat(3, 1fr); } .grid2 { grid-template-columns: repeat(2, 1fr); }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 16px; }
.tile p { margin: 0; color: var(--muted); }
.sec-h { display: flex; justify-content: space-between; align-items: baseline; }
.feats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.feat { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; text-align: center; padding: 12px 8px; color: var(--ink); text-decoration: none; }
.feat:hover { border-color: var(--accent); }
.feat img { display: block; margin: 0 auto 6px; max-width: 100%; height: 170px; object-fit: contain; }
.feat span { font-weight: 500; font-size: .95rem; }

/* tables */
.tbl { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.tbl th, .tbl td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
.tbl tr:last-child > * { border-bottom: 0; }
.tbl th { width: 36%; font-weight: 500; }
.tbl td.v { font-family: Kanit, sans-serif; font-weight: 600; color: var(--accent); white-space: nowrap; }
.tbl.rank th { width: auto; background: var(--surface2); font-size: .88rem; }
.tbl.rank td:first-child, .tbl.rank th:first-child { width: 48px; text-align: center; }
.tbl.rank td.n { text-align: right; font-variant-numeric: tabular-nums; }

/* tabs / filters */
.tabs { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
.tabs button { border: 1px solid var(--line); background: var(--surface); color: var(--ink); padding: 6px 14px; border-radius: 999px; cursor: pointer; font: 500 .95rem Sarabun, sans-serif; }
.tabs button.on { background: var(--pudding); border-color: var(--pudding); color: #3b2a1a; font-weight: 700; }
.tabs b { opacity: .6; font-weight: 500; margin-left: 2px; }
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; }
#wing-q { flex: 1 1 240px; max-width: 360px; padding: 8px 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); font: inherit; }
.rules { color: var(--muted); padding-left: 1.2em; }
.empty { text-align: center; color: var(--muted); padding: 40px 0; }

/* wings */
.wings { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; margin-top: 10px; }
.wing { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; overflow: hidden; display: flex; flex-direction: column; box-shadow: var(--shadow); scroll-margin-top: 80px; }
.wing:target { border-color: var(--accent); outline: 2px solid var(--accent); }
.stage { background: var(--surface2); text-align: center; padding: 8px 8px 10px; position: relative; }
.pv { display: block; margin: 0 auto; width: 160px; height: 170px; image-rendering: auto; }
.ctl { display: flex; justify-content: center; gap: 6px; margin-top: 6px; flex-wrap: wrap; }
.ctl button { border: 1px solid var(--line); background: var(--surface); color: var(--ink); border-radius: 999px; padding: 2px 12px; font: 500 .85rem Sarabun, sans-serif; cursor: pointer; }
.ctl button.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.wb { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.wb header { display: flex; gap: 10px; align-items: center; }
.ico { width: 34px; height: 34px; object-fit: contain; flex: none; }
.tag { font-size: .78rem; padding: 1px 9px; border-radius: 999px; background: var(--surface2); color: var(--muted); }
.tag.c2 { background: #fde6a8; color: #5c3d00; } .tag.c3 { background: #ead3ff; color: #4a1f73; }
.chips { display: flex; flex-wrap: wrap; gap: 5px; }
.chip.stat { background: var(--surface2); border-radius: 6px; padding: 0 8px; font: 600 .85rem Kanit, sans-serif; color: var(--accent); }
.fx { margin: 0; padding-left: 1.1em; }
.note { margin: 0; font-size: .85rem; color: var(--muted); }
details { border-top: 1px solid var(--line); padding-top: 6px; margin-top: auto; }
summary { cursor: pointer; font-weight: 600; padding: 4px 0; }
.rec { width: 100%; border-collapse: collapse; font-size: .92rem; }
.rec td { padding: 3px 4px; vertical-align: top; }
.rec td.q { width: 3.2em; color: var(--accent); font-weight: 700; white-space: nowrap; }
.rec small { display: block; color: var(--muted); font-size: .8rem; }

/* download / misc */
.steps { padding-left: 1.3em; } .steps li { margin: 8px 0; }
#status-box dl { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin: 0; }
#status-box dt { color: var(--muted); font-size: .85rem; } #status-box dd { margin: 0; font: 600 1.3rem Kanit, sans-serif; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; background: var(--muted); }
.dot.up { background: var(--good); } .dot.down { background: var(--bad); }
.foot { padding: 30px 16px 40px; color: var(--muted); font-size: .88rem; border-top: 1px solid var(--line); margin-top: 48px; }
.foot p { margin: 4px 0; }

@media (max-width: 800px) {
  .hero { grid-template-columns: 1fr; }
  .grid3, .grid2 { grid-template-columns: 1fr; }
  .feats { grid-template-columns: repeat(2, 1fr); }
  .tbl th { width: 42%; }
  .bar { padding-top: 8px; padding-bottom: 8px; gap: 8px; }
  .brand { flex: 1; }
  nav { order: 5; flex: 0 0 100%; flex-wrap: nowrap; overflow-x: auto; padding-bottom: 2px; }
  nav a { white-space: nowrap; }
}
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; } }
.rec td.ic { width: 30px; padding-right: 0; }
.rec td.ic img { display: block; image-rendering: pixelated; }
.cardhover { cursor: help; text-decoration: underline dotted var(--muted); text-underline-offset: 3px; }
.cardtip { position: fixed; z-index: 50; pointer-events: none; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 6px; box-shadow: 0 6px 24px rgba(0, 0, 0, .35); }
.cardtip img { display: block; width: 150px; height: 200px; object-fit: contain; }

/* home: wing showcase + quick start */
.showcase { display: block; min-width: 0; max-width: 100%; position: relative; margin-top: 8px; border: 1px solid var(--line); border-radius: 18px; padding: 14px 18px 12px; text-decoration: none; color: var(--ink);
  background: radial-gradient(120% 90% at 30% 40%, var(--surface) 0%, var(--surface2) 100%); box-shadow: var(--shadow); }
.showcase:hover { border-color: var(--accent); }
.hs-stage { display: flex; align-items: center; gap: 12px; height: 340px; overflow: hidden; }
.hs-img { width: 320px; height: 340px; flex: none; image-rendering: pixelated; }
.hs-txt { min-width: 0; flex: 1; max-height: 100%; overflow: hidden; overflow-wrap: anywhere; }
.hs-txt li { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.hs-txt h3 { font-size: 1.25rem; margin: 6px 0 8px; }
.hs-txt ul { margin: 8px 0 0; padding-left: 1.1em; color: var(--muted); }
.hs-dots { position: absolute; left: 18px; bottom: 12px; display: flex; gap: 6px; }
.hs-dots i { width: 8px; height: 8px; border-radius: 50%; background: var(--line); cursor: pointer; }
.hs-dots i.on { background: var(--accent); }
.hs-more { position: absolute; right: 18px; bottom: 10px; font-size: .9rem; color: var(--accent); font-weight: 600; }
.quick { list-style: none; counter-reset: q; display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; padding: 0; margin: 0; }
.quick li { counter-increment: q; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 16px 16px 16px 60px; position: relative; }
.quick li::before { content: counter(q); position: absolute; left: 14px; top: 14px; width: 32px; height: 32px; border-radius: 50%; background: var(--pudding); color: #3b2a1a; font: 600 1.1rem Kanit, sans-serif; display: grid; place-items: center; }
.quick b { display: block; font-family: Kanit, sans-serif; }
.quick span { color: var(--muted); font-size: .95rem; }
@media (max-width: 800px) {
  .hs-stage { flex-direction: column; height: 470px; text-align: center; }
  .hs-img { width: 240px; height: 255px; }
  .hs-txt ul { text-align: left; display: inline-block; }
  .hs-dots { position: static; justify-content: center; margin-top: 6px; }
  .hs-more { position: static; display: block; text-align: center; margin-top: 4px; }
  .quick { grid-template-columns: 1fr; }
}

/* mobile: the 5 rate chips stay on one row */
@media (max-width: 800px) {
  .rates { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; }
  .rc { min-width: 0; padding: 6px 2px; border-radius: 10px; }
  .rc b { font-size: 1.1rem; }
  .rc span { font-size: .68rem; white-space: nowrap; }
}
.tbl.rank th.n { text-align: right; }
.logo { width: 30px; height: 30px; }
