/* ===== RSPG · White modern theme ===== */
:root {
  --brand: #15803d;
  --brand-600: #16a34a;
  --brand-700: #166534;
  --brand-50: #f0fdf4;
  --brand-100: #dcfce7;
  --accent: #d97706;
  --accent-50: #fffbeb;
  --ink: #111827;
  --ink-2: #374151;
  --muted: #6b7280;
  --line: #e5e7eb;
  --line-soft: #f1f3f5;
  --bg: #ffffff;
  --bg-soft: #f9fafb;
  --card: #ffffff;
  --radius: 16px;
  --shadow-xs: 0 1px 2px rgba(17, 24, 39, .04);
  --shadow-sm: 0 1px 3px rgba(17, 24, 39, .05), 0 1px 2px rgba(17, 24, 39, .03);
  --shadow: 0 8px 24px -8px rgba(17, 24, 39, .12);
  --shadow-lg: 0 24px 48px -16px rgba(17, 24, 39, .18);
  --font: "IBM Plex Sans Thai", "Noto Sans Thai", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.65;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { font-family: var(--font); letter-spacing: -.01em; }
a { color: var(--brand); }
.container { width: 100%; max-width: 1160px; margin: 0 auto; padding: 0 20px; }
.muted { color: var(--muted); }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid rgba(22, 163, 74, .35); outline-offset: 2px; }

/* ---------- Topbar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 40;
  background: rgba(255, 255, 255, .85);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--line);
}
.topbar-inner { display: flex; align-items: center; justify-content: space-between; height: 64px; gap: 16px; }
.brand { display: flex; align-items: center; gap: 12px; color: var(--ink); text-decoration: none; }
.brand-logo { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 12px; background: var(--brand); }
.logo-svg, .logo-img { width: 34px; height: 34px; object-fit: contain; }
.brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.brand-text strong { font-size: 18px; font-weight: 700; }
.brand-text small { font-size: 11.5px; color: var(--muted); letter-spacing: .4px; }
.topnav { display: flex; align-items: center; gap: 4px; margin-left: auto; }
.topnav a { color: var(--ink-2); text-decoration: none; padding: 8px 14px; border-radius: 10px; font-size: 15px; font-weight: 500; transition: .15s; }
.topnav a:hover { color: var(--brand); background: var(--brand-50); }
.btn-ghost-sm { border: 1px solid var(--line); margin-left: 6px; }
.btn-ghost-sm:hover { border-color: var(--brand-100); }

/* ---------- Hero / Search ---------- */
.hero {
  position: relative; overflow: hidden;
  padding: 56px 0 44px;
  background:
    radial-gradient(700px 280px at 50% 0%, rgba(22, 163, 74, .07), transparent 70%),
    linear-gradient(180deg, #fbfdfb 0%, #ffffff 100%);
  border-bottom: 1px solid var(--line-soft);
}
.hero::before {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background-image: linear-gradient(var(--line-soft) 1px, transparent 1px), linear-gradient(90deg, var(--line-soft) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: radial-gradient(ellipse 70% 60% at 50% 30%, #000 20%, transparent 75%);
  -webkit-mask-image: radial-gradient(ellipse 70% 60% at 50% 30%, #000 20%, transparent 75%);
  opacity: .8;
}
.hero-inner { position: relative; z-index: 2; text-align: center; }
.hero-bg { display: none; }

.eyebrow {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 14px; border-radius: 999px;
  background: var(--brand-50); color: var(--brand-700); border: 1px solid var(--brand-100);
  font-size: 14px; font-weight: 500;
}
.eyebrow .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--brand-600); }
.hero h1 { font-size: clamp(30px, 4.6vw, 50px); line-height: 1.2; margin: 18px 0 10px; font-weight: 700; color: var(--ink); }
.hero h1 .hl { color: var(--brand); }
.lead { max-width: 720px; margin: 0 auto 30px; color: var(--muted); font-size: 16.5px; text-wrap: balance; }

.search-card {
  max-width: 860px; margin: 0 auto;
  background: #fff; color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 20px; padding: 8px;
  box-shadow: var(--shadow-lg);
  text-align: left;
}
.search-main { display: flex; align-items: center; gap: 8px; padding: 4px 4px 4px 14px; }
.search-main .ico { width: 22px; height: 22px; fill: none; stroke: var(--muted); stroke-width: 2.2; stroke-linecap: round; flex: none; }
.search-main input {
  flex: 1; min-width: 0; border: 0; outline: 0; font: inherit; font-size: 18px;
  padding: 14px 6px; background: transparent; color: var(--ink);
}
.search-main input::placeholder { color: #9ca3af; }
.search-main input::-webkit-search-cancel-button { display: none; }
.search-card:focus-within { border-color: #bbf7d0; box-shadow: var(--shadow-lg), 0 0 0 4px rgba(22, 163, 74, .1); }
.clear { border: 0; background: var(--bg-soft); color: var(--muted); width: 32px; height: 32px; border-radius: 50%; font-size: 20px; cursor: pointer; flex: none; }
.clear:hover { background: var(--line); color: var(--ink); }
.btn-primary {
  border: 0; cursor: pointer; flex: none;
  background: var(--brand); color: #fff; font: inherit; font-size: 16px; font-weight: 600;
  padding: 13px 28px; border-radius: 14px;
  transition: background .15s, transform .15s;
}
.btn-primary:hover { background: var(--brand-700); }
.btn-primary:active { transform: scale(.98); }
.search-filters {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  border-top: 1px solid var(--line-soft); margin-top: 6px; padding: 10px 8px 4px;
}
.select { display: inline-flex; align-items: center; gap: 6px; background: var(--bg-soft); border: 1px solid var(--line); border-radius: 12px; padding: 2px 6px 2px 12px; font-size: 14px; color: var(--muted); }
.select select { border: 0; background: transparent; font: inherit; color: var(--ink); font-weight: 500; padding: 7px 4px; outline: 0; cursor: pointer; max-width: 230px; }
.quick { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 14px; color: var(--muted); margin-left: auto; }
.chip {
  border: 1px solid var(--line); background: #fff; color: var(--ink-2);
  border-radius: 999px; padding: 5px 12px; font: inherit; font-size: 13.5px; cursor: pointer; transition: .15s;
}
.chip:hover, .chip.active { border-color: var(--brand-600); color: var(--brand-700); background: var(--brand-50); }

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; max-width: 860px; margin: 28px auto 0; }
.stat { background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 14px 10px; box-shadow: var(--shadow-xs); }
.stat b { display: block; font-size: 28px; font-weight: 700; color: var(--brand); line-height: 1.2; }
.stat span { font-size: 14px; color: var(--muted); }

/* ---------- Sections ---------- */
main { padding: 44px 20px 30px; }
.section-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.section-head h2 { margin: 0; font-size: 24px; font-weight: 700; }
.section-head p { margin: 2px 0 0; }
.results-wrap { margin-bottom: 52px; scroll-margin-top: 84px; }
.groups-section { scroll-margin-top: 84px; }

/* ---------- Result cards ---------- */
.results { display: grid; gap: 12px; }
.r-card {
  --gc: var(--brand-600);
  position: relative; display: grid; grid-template-columns: auto 1fr auto; gap: 18px; align-items: center;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px 20px; box-shadow: var(--shadow-xs);
  animation: rise .3s ease both;
  transition: box-shadow .2s, border-color .2s;
}
.r-card:hover { box-shadow: var(--shadow); border-color: #d1d5db; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.r-badge {
  width: 76px; height: 76px; border-radius: 18px; flex: none;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  color: var(--gc);
  background: color-mix(in srgb, var(--gc) 9%, white);
  border: 1.5px solid color-mix(in srgb, var(--gc) 28%, white);
}
.r-badge small { font-size: 12px; font-weight: 500; line-height: 1; color: color-mix(in srgb, var(--gc) 75%, black); }
.r-badge b { font-size: 34px; line-height: 1.1; font-weight: 700; }
.r-name { font-size: 19px; font-weight: 600; margin: 0 0 2px; color: var(--ink); }
.r-pos { color: var(--ink-2); margin: 0 0 8px; font-size: 15px; }
.r-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag { display: inline-flex; align-items: center; gap: 5px; font-size: 13.5px; padding: 3px 10px; border-radius: 8px; background: var(--bg-soft); border: 1px solid var(--line); color: var(--ink-2); }
.tag svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2; }
.tag.gold { background: var(--accent-50); border-color: #fde68a; color: #92400e; }
.r-side { text-align: right; min-width: 210px; }
.r-area { font-weight: 600; color: var(--ink); display: flex; align-items: center; justify-content: flex-end; gap: 6px; }
.r-area svg { width: 18px; height: 18px; fill: none; stroke: var(--gc); stroke-width: 2.2; }
.r-mentor { font-size: 14px; color: var(--muted); margin: 2px 0 10px; }
.btn-outline {
  border: 1px solid var(--line); background: #fff; color: var(--ink-2);
  padding: 7px 14px; border-radius: 10px; font: inherit; font-size: 14px; font-weight: 500; cursor: pointer; transition: .15s;
}
.btn-outline:hover { border-color: var(--brand-600); color: var(--brand-700); background: var(--brand-50); }
mark { background: #fef08a; color: inherit; padding: 0 2px; border-radius: 3px; }

.empty { text-align: center; background: var(--bg-soft); border: 1px dashed #d1d5db; border-radius: var(--radius); padding: 44px 20px; }
.empty-ico { font-size: 40px; }
.empty h3 { margin: 8px 0 4px; }
.empty p { margin: 0; color: var(--muted); }

.skeleton { height: 112px; border-radius: var(--radius); background: linear-gradient(90deg, #f3f4f6 25%, #fafafa 50%, #f3f4f6 75%); background-size: 200% 100%; animation: shimmer 1.2s infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ---------- Group grid ---------- */
.group-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.group-card {
  --gc: var(--brand-600);
  position: relative; display: flex; align-items: center; gap: 14px; text-align: left;
  border: 1px solid var(--line); background: #fff; border-radius: var(--radius);
  padding: 16px; cursor: pointer; font: inherit; color: inherit;
  box-shadow: var(--shadow-xs); transition: transform .18s, box-shadow .18s, border-color .18s;
}
.group-card::before { content: ""; position: absolute; left: 16px; right: 16px; top: -1px; height: 3px; border-radius: 0 0 4px 4px; background: var(--gc); opacity: 0; transition: .2s; }
.group-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: color-mix(in srgb, var(--gc) 35%, white); }
.group-card:hover::before { opacity: 1; }
.gc-num {
  width: 56px; height: 56px; border-radius: 14px; flex: none;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  color: var(--gc); font-size: 24px; font-weight: 700; line-height: 1;
  background: color-mix(in srgb, var(--gc) 9%, white);
  border: 1.5px solid color-mix(in srgb, var(--gc) 25%, white);
}
.gc-num small { font-size: 10px; font-weight: 500; margin-bottom: 3px; color: color-mix(in srgb, var(--gc) 75%, black); }
.gc-body { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.gc-area { display: flex; align-items: center; gap: 5px; font-weight: 600; font-size: 15.5px; color: var(--ink); }
.gc-area svg { width: 16px; height: 16px; flex: none; fill: none; stroke: var(--gc); stroke-width: 2.4; }
.gc-mentor { font-size: 13.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gc-count { font-weight: 700; font-size: 20px; color: var(--ink); text-align: center; line-height: 1; }
.gc-count small { display: block; font-size: 11px; font-weight: 400; color: var(--muted); margin-top: 3px; }

/* ---------- Modal ---------- */
.modal { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 20px; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(17, 24, 39, .35); backdrop-filter: blur(3px); animation: fade .2s; }
.modal-dialog {
  --gc: var(--brand-600);
  position: relative; width: 100%; max-width: 740px; max-height: calc(100vh - 40px);
  display: flex; flex-direction: column;
  background: #fff; border-radius: 20px; box-shadow: var(--shadow-lg); overflow: hidden;
  border-top: 5px solid var(--gc);
  animation: pop .22s cubic-bezier(.2, .9, .3, 1.15);
}
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(12px) scale(.98); } }
.modal-head {
  display: flex; justify-content: space-between; align-items: flex-start; gap: 16px;
  padding: 22px 24px 18px; color: var(--ink);
  border-bottom: 1px solid var(--line);
}
.m-eyebrow { font-size: 13px; color: var(--muted); }
.modal-head h3 { margin: 0 0 10px; font-size: 26px; font-weight: 700; color: var(--gc); }
.m-meta { display: flex; flex-wrap: wrap; gap: 8px; }
.m-meta span { background: var(--bg-soft); border: 1px solid var(--line); color: var(--ink-2); padding: 3px 12px; border-radius: 999px; font-size: 14px; }
.m-close { border: 1px solid var(--line); background: #fff; color: var(--muted); width: 38px; height: 38px; border-radius: 50%; font-size: 22px; cursor: pointer; flex: none; transition: .15s; }
.m-close:hover { background: var(--bg-soft); color: var(--ink); }
.modal-body { overflow: auto; padding: 8px 10px 14px; }
.m-list { list-style: none; margin: 0; padding: 0; }
.m-list li { display: grid; grid-template-columns: 36px 1fr; gap: 12px; align-items: start; padding: 11px 14px; border-radius: 12px; border-bottom: 1px solid var(--line-soft); }
.m-list li:last-child { border-bottom: 0; }
.m-list li.me { background: var(--accent-50); outline: 1.5px solid #fcd34d; border-bottom-color: transparent; }
.m-no { width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center; background: color-mix(in srgb, var(--gc) 10%, white); color: var(--gc); font-weight: 700; font-size: 14px; }
.m-name { font-weight: 600; }
.m-sub { font-size: 14px; color: var(--muted); }

/* ---------- Footer ---------- */
.footer { border-top: 1px solid var(--line); padding: 28px 0 40px; text-align: center; font-size: 14.5px; color: var(--ink-2); background: var(--bg-soft); margin-top: 40px; }
.footer p { margin: 4px 0; }

/* ---------- Responsive ---------- */
@media (max-width: 820px) {
  .r-card { grid-template-columns: auto 1fr; }
  .r-side { grid-column: 1 / -1; text-align: left; min-width: 0; border-top: 1px solid var(--line-soft); padding-top: 12px; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 12px; }
  .r-area { justify-content: flex-start; }
  .r-mentor { margin: 0; flex: 1 1 100%; order: 2; }
  .r-side .btn-outline { order: 3; }
  .quick { margin-left: 0; }
}
@media (max-width: 640px) {
  .container { padding: 0 16px; }
  .topnav a:not(.btn-ghost-sm) { display: none; }
  .brand-text small { display: none; }
  .hero { padding: 28px 0 32px; }
  .lead { font-size: 15px; }
  .search-card { border-radius: 18px; box-shadow: var(--shadow); }
  .search-main { flex-wrap: wrap; padding: 4px; }
  .search-main .ico { margin-left: 10px; }
  .search-main input { font-size: 16px; padding: 12px 4px; }
  .search-main .btn-primary { width: 100%; }
  .select { flex: 1 1 100%; }
  .select select { max-width: none; flex: 1; }
  .stats { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .stat b { font-size: 24px; }
  .r-card { padding: 16px; gap: 14px; }
  .r-badge { width: 62px; height: 62px; border-radius: 15px; }
  .r-badge b { font-size: 27px; }
  .r-name { font-size: 17px; }
  main { padding: 30px 16px 20px; }
  .modal { padding: 0; align-items: end; }
  .modal-dialog { border-radius: 20px 20px 0 0; max-height: 92vh; }
  .modal-head h3 { font-size: 22px; }
}
