:root {
  --bg: #eef3ea;
  --bg2: #f7faf4;
  --card: #ffffff;
  --fg: #17210f;
  --muted: #5f6b57;
  --line: #e1e8da;
  --brand: #3fae14;
  --btn: #3fae14;
  --brand-d: #2e8f0a;
  --brand-soft: #eaf7df;
  --err: #b42318;
  --err-soft: #fdecea;
  --shadow: 0 1px 2px rgba(23,33,15,.06), 0 12px 32px rgba(23,33,15,.08);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f140c;
    --bg2: #141b10;
    --card: #1a2215;
    --fg: #e8efe1;
    --muted: #9eab95;
    --line: #2a3523;
    --brand: #5cc928;
    --btn: #3a9e12;
    --brand-d: #4bb41b;
    --brand-soft: #1f3115;
    --err: #ff8a80;
    --err-soft: #3a1d1b;
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 12px 32px rgba(0,0,0,.35);
  }
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 24px 16px;
  background: radial-gradient(1200px 600px at 50% -10%, var(--brand-soft), transparent 70%), linear-gradient(var(--bg2), var(--bg));
  color: var(--fg);
  font: 15px/1.6 "IBM Plex Sans Thai", "Noto Sans Thai", system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}
.brand { display: flex; flex-direction: column; align-items: center; gap: 8px; margin-bottom: 20px; text-decoration: none; }
.brand img { width: 64px; height: auto; display: block; }
.brand .word { font-weight: 700; letter-spacing: .14em; color: var(--brand); font-size: 15px; }
.card {
  width: 100%; max-width: 420px; background: var(--card); border: 1px solid var(--line); border-radius: 16px;
  padding: 28px 28px 22px; box-shadow: var(--shadow);
}
.card.wide { max-width: 640px; }
h1 { font-size: 20px; line-height: 1.35; margin: 0 0 6px; font-weight: 650; }
h2 { font-size: 16px; margin: 20px 0 6px; }
p { margin: 0 0 12px; }
.lead { color: var(--muted); margin-bottom: 22px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
code { font-size: 13px; background: var(--brand-soft); padding: 1px 6px; border-radius: 6px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px; width: 100%;
  font: inherit; font-weight: 600; padding: 12px 18px; border-radius: 10px; cursor: pointer;
  border: 1px solid var(--line); background: var(--card); color: var(--fg);
  transition: background .15s, border-color .15s, transform .05s;
}
.btn:hover { border-color: var(--brand); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--btn); border-color: var(--btn); color: #fff; }
.btn.primary:hover { background: var(--brand-d); border-color: var(--brand-d); }
.btn:disabled { opacity: .55; cursor: default; }
.btn:focus-visible { outline: 3px solid var(--brand-soft); outline-offset: 2px; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 22px; }
.linkbtn { border: 0; background: none; color: var(--brand); font: inherit; padding: 0; cursor: pointer; }
.linkbtn:hover { text-decoration: underline; }

.app { display: flex; align-items: center; gap: 12px; padding: 14px; border: 1px solid var(--line); border-radius: 12px; margin-bottom: 16px; }
.avatar {
  flex: none; width: 42px; height: 42px; border-radius: 10px; display: grid; place-items: center;
  background: var(--brand-soft); color: var(--brand-d); font-weight: 700; font-size: 18px; text-transform: uppercase;
}
.app .name { font-weight: 650; }
.app .host { color: var(--muted); font-size: 13px; }
.who { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 13px; color: var(--muted);
  background: var(--bg2); border-radius: 10px; padding: 8px 12px; margin-bottom: 16px; }
.who b { color: var(--fg); font-weight: 600; word-break: break-all; }
.scopes { list-style: none; margin: 6px 0 0; padding: 0; }
.scopes li { display: flex; align-items: flex-start; gap: 10px; padding: 8px 0; border-top: 1px solid var(--line); }
.scopes li:first-child { border-top: 0; }
.scopes li::before { content: ""; flex: none; width: 18px; height: 18px; margin-top: 2px; border-radius: 50%;
  background: var(--brand) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M4 8.5l2.5 2.5L12 5.5' fill='none' stroke='%23fff' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center/14px no-repeat; }
.scopes .sc { display: block; font-size: 12px; color: var(--muted); }
.note { font-size: 13px; color: var(--muted); margin-top: 16px; }

.spinner { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--brand);
  animation: spin .8s linear infinite; margin: 8px auto 12px; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 2.4s; } }
.center { text-align: center; }
.alert { background: var(--err-soft); color: var(--err); border-radius: 10px; padding: 12px 14px; margin: 0; }

footer.site { margin-top: 18px; font-size: 12px; color: var(--muted); display: flex; gap: 14px; }
footer.site a { color: var(--muted); text-decoration: none; }
footer.site a:hover { color: var(--brand); }
@media (max-width: 420px) { .card { padding: 22px 18px 18px; } .row { grid-template-columns: 1fr; } .row .btn.primary { order: -1; } }
