/* Self-hosted fonts */
@font-face{font-family:"Kantumruy Pro";font-weight:400;font-display:swap;src:url(/fonts/kantumruy-pro-khmer-400-normal.woff2) format("woff2");unicode-range:U+1780-17FF,U+19E0-19FF,U+200C-200D,U+25CC}
@font-face{font-family:"Kantumruy Pro";font-weight:600;font-display:swap;src:url(/fonts/kantumruy-pro-khmer-600-normal.woff2) format("woff2");unicode-range:U+1780-17FF,U+19E0-19FF,U+200C-200D,U+25CC}
@font-face{font-family:"Kantumruy Pro";font-weight:700;font-display:swap;src:url(/fonts/kantumruy-pro-khmer-700-normal.woff2) format("woff2");unicode-range:U+1780-17FF,U+19E0-19FF,U+200C-200D,U+25CC}
@font-face{font-family:"Kantumruy Pro";font-weight:400;font-display:swap;src:url(/fonts/kantumruy-pro-latin-400-normal.woff2) format("woff2");unicode-range:U+0000-00FF,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD}
@font-face{font-family:"Kantumruy Pro";font-weight:600;font-display:swap;src:url(/fonts/kantumruy-pro-latin-600-normal.woff2) format("woff2");unicode-range:U+0000-00FF,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD}
@font-face{font-family:"Kantumruy Pro";font-weight:700;font-display:swap;src:url(/fonts/kantumruy-pro-latin-700-normal.woff2) format("woff2");unicode-range:U+0000-00FF,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD}

/* Brand: ChatKH purple + orange (from the logo). Layout: one centred column, card grid. */
:root {
  --bg: #f6f5fb;
  --surface: #ffffff;
  --sunk: #f0eef8;
  --ink: #1d1a2e;
  --muted: #625e78;
  --line: #e3e0ef;
  --accent: #5b4bc4;
  --accent-ink: #ffffff;
  --accent-soft: #ece9fb;
  --orange: #d9661b;
  --orange-soft: #fdeee2;
  --danger: #c0392b;
  --danger-soft: #fbe9e7;
  --good: #1f8a4c;
  --shadow: 0 1px 2px rgba(29, 26, 46, .05), 0 10px 28px -18px rgba(29, 26, 46, .35);
  --font: "Kantumruy Pro", "Noto Sans Khmer", "Khmer OS", system-ui, sans-serif;
  --r: 16px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121019; --surface: #1b1826; --sunk: #16131f; --ink: #ecebf5; --muted: #a19cb8; --line: #2d2940;
    --accent: #9d90f5; --accent-ink: #120f1f; --accent-soft: #26213f; --orange: #f59a55; --orange-soft: #33231a;
    --danger: #f08070; --danger-soft: #331b18; --good: #5fcf85;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 12px 30px -18px rgba(0, 0, 0, .7); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #121019; --surface: #1b1826; --sunk: #16131f; --ink: #ecebf5; --muted: #a19cb8; --line: #2d2940;
  --accent: #9d90f5; --accent-ink: #120f1f; --accent-soft: #26213f; --orange: #f59a55; --orange-soft: #33231a;
  --danger: #f08070; --danger-soft: #331b18; --good: #5fcf85;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 12px 30px -18px rgba(0, 0, 0, .7); color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font-family: var(--font); font-size: 15px; line-height: 1.6; }
[hidden] { display: none !important; }
h1, h2, h3 { margin: 0; text-wrap: balance; line-height: 1.3; }
a { color: var(--accent); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.wrap { max-width: 1080px; margin: 0 auto; padding-inline: 16px; }

/* header */
body.landing { min-height: 100dvh; display: flex; flex-direction: column; }
body.landing main { flex: 1; width: 100%; }
.top { padding-block: 16px; }
.top .wrap { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; font-weight: 700; font-size: 1.05rem; }
.brand img { width: 38px; height: 38px; border-radius: 10px; }
.top-link { font-size: .88rem; color: var(--muted); text-decoration: none; border: 1px solid var(--line); border-radius: 999px; padding: 5px 14px; background: var(--surface); }
.top-link:hover { color: var(--accent); border-color: var(--accent); }

/* hero banner: text left, the tools orbiting the logo on the right */
.hero { position: relative; overflow: hidden; display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); align-items: center; gap: 24px;
  margin-top: 6px; padding: clamp(24px, 4vw, 44px); border-radius: 24px; border: 1px solid var(--line);
  background:
    radial-gradient(120% 140% at 100% 0%, var(--orange-soft) 0%, transparent 55%),
    radial-gradient(120% 140% at 0% 100%, var(--accent-soft) 0%, transparent 60%),
    var(--surface); }
.eyebrow { display: inline-flex; align-items: center; gap: 8px; font-size: .78rem; font-weight: 700; letter-spacing: .04em; color: var(--accent);
  background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 3px 12px 3px 8px; }
.eyebrow i { width: 8px; height: 8px; border-radius: 50%; background: var(--orange); box-shadow: 0 0 0 3px var(--orange-soft); }
.hero h1 { margin-top: 14px; font-size: clamp(1.7rem, 4.2vw, 2.6rem); font-weight: 700; max-width: 18ch; }
.hero h1 em { font-style: normal; color: var(--accent); }
.hero-sub { margin: 12px 0 0; color: var(--muted); max-width: 46ch; font-size: 1rem; }
.facts { list-style: none; margin: 20px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.facts li { display: inline-flex; align-items: center; gap: 6px; font-size: .84rem; font-weight: 600; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 5px 12px; }
.facts b { color: var(--accent); font-variant-numeric: tabular-nums; }
.facts svg { width: 15px; height: 15px; color: var(--good); }

.orbit { position: relative; justify-self: center; width: min(100%, 300px); aspect-ratio: 1; max-width: 100%; }
.orbit::before, .orbit::after { content: ""; position: absolute; inset: 8%; border-radius: 50%; border: 1.5px dashed color-mix(in srgb, var(--accent) 35%, transparent); }
.orbit::after { inset: 26%; border-style: solid; border-color: color-mix(in srgb, var(--orange) 25%, transparent); }
.orbit-core { position: absolute; inset: 34%; border-radius: 28%; background: var(--surface); box-shadow: var(--shadow); display: grid; place-items: center; z-index: 1; }
.orbit-core img { width: 72%; height: 72%; }
.orbit .sat { position: absolute; width: 22%; aspect-ratio: 1; translate: -50% -50%; border-radius: 26%; overflow: hidden; background: var(--surface); box-shadow: var(--shadow);
  display: grid; place-items: center; text-decoration: none; transition: transform .2s; z-index: 2; }
.orbit .sat:hover { transform: scale(1.08); }
.orbit .sat .icon { width: 100%; height: 100%; border-radius: 0; }
@media (prefers-reduced-motion: no-preference) {
  .orbit .sat { animation: bob 5s ease-in-out infinite; }
  .orbit .sat:nth-child(2n) { animation-delay: -2.5s; }
  @keyframes bob { 50% { translate: -50% calc(-50% - 6px); } }
}
@media (max-width: 760px) {
  .hero { grid-template-columns: minmax(0, 1fr); }
  .orbit { width: min(70%, 230px); order: -1; }
}

/* toolbar: section title + search on one row, chips below */
.toolbar { display: flex; flex-direction: column; gap: 12px; padding-block: 28px 16px; }
.toolbar-row { display: flex; align-items: center; justify-content: space-between; gap: 12px 20px; flex-wrap: wrap; }
.toolbar h2 { font-size: 1.25rem; font-weight: 700; }
.toolbar h2 span { color: var(--muted); font-weight: 600; font-size: 1rem; margin-left: 4px; }
.search { position: relative; flex: 1 1 260px; max-width: 360px; }
.search svg { position: absolute; left: 13px; top: 50%; translate: 0 -50%; width: 18px; height: 18px; color: var(--muted); pointer-events: none; }
.search input { width: 100%; padding: 10px 14px 10px 40px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.search input:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 5px 14px; font-size: .86rem; cursor: pointer; color: var(--muted); }
.chip:hover { border-color: var(--accent); color: var(--ink); }
.chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.chip .n { opacity: .7; margin-left: 4px; font-variant-numeric: tabular-nums; }

/* tool grid: auto-fit so a full row of cards stretches edge to edge */
.grid { list-style: none; margin: 0; padding: 0 0 48px; display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 235px), 1fr)); gap: 14px; }
.grid.few { grid-template-columns: repeat(auto-fill, minmax(min(100%, 235px), 1fr)); }
.card { position: relative; display: flex; flex-direction: column; gap: 12px; height: 100%; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r); padding: 18px; color: inherit; text-decoration: none; transition: border-color .15s, box-shadow .15s, transform .15s; }
.card:hover { border-color: var(--accent); box-shadow: var(--shadow); transform: translateY(-3px); }
.card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.icon { width: 52px; height: 52px; border-radius: 14px; flex: none; object-fit: cover; background: var(--sunk); }
.icon.letter { --c1: #6c5ce7; --c2: #e8792b; display: grid; place-items: center; font-weight: 700; font-size: 1.35rem; color: #fff; background: linear-gradient(135deg, var(--c1), var(--c2)); }
.badge-new { background: var(--orange-soft); color: var(--orange); font-size: .72rem; font-weight: 700; border-radius: 999px; padding: 2px 10px; }
.card h3 { font-size: 1.05rem; font-weight: 700; overflow-wrap: anywhere; }
.cat { align-self: flex-start; font-size: .74rem; font-weight: 600; color: var(--accent); background: var(--accent-soft); border-radius: 999px; padding: 1px 10px; margin-top: -4px; }
.card p { margin: 0; color: var(--muted); font-size: .88rem; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.card-foot { margin-top: auto; padding-top: 12px; border-top: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 8px; min-width: 0; }
.domain { font-size: .78rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.go { flex: none; width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); font-weight: 700; transition: background .15s, color .15s, translate .15s; }
.card:hover .go { background: var(--accent); color: var(--accent-ink); translate: 2px 0; }

.empty { text-align: center; color: var(--muted); padding: 40px 16px; border: 1px dashed var(--line); border-radius: var(--r); margin: 0 0 48px; }
.skeleton { height: 210px; border-radius: var(--r); background: linear-gradient(90deg, var(--sunk), var(--surface), var(--sunk)); background-size: 200% 100%; animation: sk 1.2s linear infinite; }
@keyframes sk { from { background-position: 200% 0; } to { background-position: -200% 0; } }

.foot { border-top: 1px solid var(--line); padding-block: 18px 26px; color: var(--muted); font-size: .82rem; background: var(--surface); }
.foot .wrap { display: flex; justify-content: space-between; align-items: center; gap: 8px 16px; flex-wrap: wrap; }
.foot-brand { display: flex; align-items: center; gap: 8px; }
.foot-brand img { width: 22px; height: 22px; border-radius: 6px; }
.foot a { color: var(--accent); font-weight: 700; text-decoration: none; }

/* ---------- shared controls (admin) ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border-radius: 10px; padding: 9px 16px; font-weight: 600;
  border: 1px solid var(--line); background: var(--surface); cursor: pointer; text-decoration: none; color: var(--ink); white-space: nowrap; }
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--danger); }
.btn.danger.solid { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.sm { padding: 5px 10px; font-size: .82rem; }
.btn:disabled { opacity: .5; cursor: not-allowed; filter: none; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field label, .field .label { font-size: .84rem; font-weight: 600; }
.field small { color: var(--muted); font-size: .76rem; }
.input, textarea.input, select.input { width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px; background: var(--surface); }
.input:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
textarea.input { resize: vertical; min-height: 84px; }
.check { display: flex; align-items: flex-start; gap: 8px; font-size: .88rem; cursor: pointer; }
.check input { margin-top: 5px; accent-color: var(--accent); }
.check small { display: block; color: var(--muted); font-size: .76rem; }

@media (prefers-reduced-motion: reduce) { *, *::before { transition: none !important; animation: none !important; } }
