/* SlipCheck — shared design tokens + components (bright, friendly) */
:root {
  color-scheme: light;
  --bg: #f1fcf8;
  --surface: #ffffff;
  --card: #ffffff;
  --muted: #f3f8f5;
  --line: #e2ece7;
  --line-strong: #cddbd4;
  --fg: #10241a;
  --fg-2: #3c4f46;
  --fg-3: #6a7d74;
  --accent: #14c9a0;
  --accent-2: #0ea888;
  --accent-ink: #0a7d66;
  --on-accent: #ffffff;
  --accent-soft: #dcfaf1;
  --danger: #e5484d;
  --danger-soft: #fdecec;
  --warn: #f5a524;
  --warn-soft: #fff4d9;
  /* playful tones for icon tiles and cards */
  --t-green: #14c9a0;  --t-green-soft: #dcfaf1;
  --t-blue: #3b82f6;   --t-blue-soft: #e8f1ff;
  --t-violet: #8b5cf6; --t-violet-soft: #f1ebff;
  --t-yellow: #f59e0b; --t-yellow-soft: #fff4d9;
  --t-coral: #f2617a;  --t-coral-soft: #ffecef;
  /* chart status steps (checked against white cards) */
  --st-good: #14c9a0;
  --st-warn: #f5b301;
  --st-crit: #e5484d;
  --st-none: #a3b2ab;
  --ring: #14c9a0;
  --radius: 14px;
  --radius-lg: 20px;
  --shadow: 0 1px 2px rgba(16, 36, 26, .04), 0 10px 30px rgba(14, 120, 100, .08);
  --shadow-lift: 0 18px 40px rgba(14, 120, 100, .16);
  --font: "Noto Sans Thai", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --ease: cubic-bezier(.2, .7, .2, 1);
  --spring: cubic-bezier(.34, 1.56, .64, 1);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; scroll-padding-top: 88px; }

/* ---------- page-to-page transition (Chrome/Edge/Safari 18+; others just load normally) */
@view-transition { navigation: auto; }
::view-transition-old(root) { animation: vt-out .16s ease both; }
::view-transition-new(root) { animation: vt-in .34s cubic-bezier(.2, .7, .2, 1) both; }
@keyframes vt-out { to { opacity: 0; } }
@keyframes vt-in { from { opacity: 0; transform: translateY(10px); } }

/* ---------- skeleton (loading placeholder) */
.skel { position: relative; overflow: hidden; background: #eaf2ee; border-radius: 10px; }
.skel::after { content: ""; position: absolute; inset: 0; transform: translateX(-100%); background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .7), transparent); animation: skel-shine 1.3s ease-in-out infinite; }
@keyframes skel-shine { to { transform: translateX(100%); } }
.skel-line { height: 14px; margin: 10px 0; }
.skel-line.sm { width: 40%; } .skel-line.md { width: 65%; } .skel-line.lg { width: 90%; }
.skel-title { height: 26px; width: 45%; margin-bottom: 18px; }
.skel-num { height: 34px; width: 60%; margin-top: 12px; }
.skel-ico { width: 34px; height: 34px; border-radius: 12px; }
body {
  margin: 0; color: var(--fg);
  background: radial-gradient(900px 520px at 0% 0%, #d9f8ee 0, transparent 60%), radial-gradient(800px 520px at 100% 0%, #e6f0ff 0, transparent 60%), radial-gradient(800px 600px at 60% 100%, #f2ecff 0, transparent 60%), var(--bg);
  background-attachment: fixed; font-family: var(--font);
  font-size: 17px; line-height: 1.65; -webkit-font-smoothing: antialiased;
}
a { color: var(--accent-ink); text-underline-offset: 3px; }
a:hover { color: var(--accent); }
img, svg { display: block; }
h1, h2, h3, h4 { line-height: 1.25; margin: 0; letter-spacing: -.01em; }
p { margin: 0; }
code, pre, .mono { font-family: var(--mono); font-size: .875em; }
:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; border-radius: 6px; }
::selection { background: rgba(20, 201, 160, .22); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.ico { width: 20px; height: 20px; flex: 0 0 auto; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.ico.sm { width: 16px; height: 16px; }
.ico.lg { width: 28px; height: 28px; }
.muted { color: var(--fg-3); }
.small { font-size: 14px; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.stack { display: grid; gap: 16px; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }

/* ---------- logo */
.logo { display: inline-flex; align-items: center; gap: 10px; color: var(--fg); text-decoration: none; font-weight: 700; font-size: 18px; }
.logo-mark {
  width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center;
  background: var(--accent); color: var(--on-accent);
}
.logo-mark .ico { width: 18px; height: 18px; stroke-width: 2.4; }

/* ---------- buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 10px 18px; border-radius: 10px; border: 1px solid var(--line-strong);
  background: var(--muted); color: var(--fg); font: inherit; font-size: 15px; font-weight: 600;
  cursor: pointer; text-decoration: none; transition: background .18s var(--ease), border-color .18s var(--ease), transform .12s var(--ease);
  white-space: nowrap;
}
.btn:hover { background: #eef6f2; color: var(--fg); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.primary:hover { background: var(--accent-2); border-color: var(--accent-2); color: var(--on-accent); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--fg-2); }
.btn.ghost:hover { background: var(--muted); color: var(--fg); }
.btn.danger { background: transparent; border-color: rgba(229, 72, 77, .4); color: #c0262d; }
.btn.danger:hover { background: var(--danger-soft); }
.btn.sm { min-height: 36px; padding: 6px 12px; font-size: 14px; border-radius: 8px; }
.btn.block { width: 100%; }
.icon-btn { min-width: 44px; padding: 10px; }
.spinner {
  width: 16px; height: 16px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent;
  animation: spin .7s linear infinite; display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- forms */
.field { display: grid; gap: 6px; align-content: start; }
.field label, .label { font-size: 14px; font-weight: 600; color: var(--fg-2); }
.field .hint { font-size: 13px; color: var(--fg-3); }
.field .err { font-size: 13px; color: #c0262d; }
.input, select.input, textarea.input {
  width: 100%; min-height: 44px; padding: 10px 14px; border-radius: 10px;
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--fg);
  font: inherit; font-size: 15px; transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
}
.input::placeholder { color: #9aaba3; }
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px rgba(20, 201, 160, .15); }
.input[aria-invalid="true"] { border-color: var(--danger); }
select.input { appearance: none; padding-right: 36px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; background-size: 16px; }
.check { display: inline-flex; align-items: center; gap: 10px; min-height: 44px; cursor: pointer; font-size: 15px; color: var(--fg-2); }
.check input { width: 18px; height: 18px; accent-color: var(--accent); }
.form-grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }

/* ---------- cards & panels */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 20px; box-shadow: var(--shadow); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.card-head h2, .card-head h3 { font-size: 17px; font-weight: 700; }
.card-head p { color: var(--fg-3); font-size: 14px; margin-top: 2px; }

/* ---------- badges */
.badge {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px;
  font-size: 13px; font-weight: 600; border: 1px solid transparent; white-space: nowrap; line-height: 1.5;
}
.badge .ico { width: 14px; height: 14px; stroke-width: 2.4; }
.badge.success { background: var(--accent-soft); color: var(--accent-ink); border-color: rgba(20, 201, 160, .3); }
.badge.warning { background: var(--warn-soft); color: #8a5300; border-color: rgba(245, 165, 36, .35); }
.badge.fail { background: var(--danger-soft); color: #b4232a; border-color: rgba(229, 72, 77, .3); }
.badge.neutral { background: var(--muted); color: var(--fg-2); border-color: var(--line-strong); }

/* ---------- alerts */
.alert { display: flex; gap: 12px; padding: 14px 16px; border-radius: var(--radius); border: 1px solid var(--line-strong); background: var(--muted); font-size: 14px; color: var(--fg-2); }
.alert .ico { margin-top: 2px; }
.alert.warn { border-color: rgba(251, 179, 21, .35); background: var(--warn-soft); color: #74470a; }
.alert.error { border-color: rgba(239, 68, 68, .35); background: var(--danger-soft); color: #8f1d22; }
.alert.ok { border-color: rgba(20, 201, 160, .35); background: var(--accent-soft); color: #075e4d; }
.alert b { color: var(--fg); }

/* ---------- tables */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-weight: 600; color: var(--fg-3); font-size: 13px; padding: 10px 14px; background: var(--surface); border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: #f6fbf8; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.empty { padding: 40px 16px; text-align: center; color: var(--fg-3); }
.empty .ico { margin: 0 auto 10px; width: 36px; height: 36px; color: #a6bab0; }

/* ---------- code */
.code {
  position: relative; background: #10241a; border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; overflow-x: auto; font-family: var(--mono); font-size: 13px; line-height: 1.7; color: #d1d5db;
}
.code pre { margin: 0; white-space: pre; }
.code .copy { position: absolute; top: 8px; right: 8px; }
.tok-k { color: #93c5fd; } .tok-s { color: #8eeccf; } .tok-c { color: #64748b; } .tok-n { color: #fcd34d; }
.key-box { display: flex; gap: 8px; align-items: stretch; }
.key-box code { flex: 1; min-width: 0; background: var(--muted); border: 1px solid var(--line-strong); border-radius: 10px; padding: 10px 12px; overflow-x: auto; white-space: nowrap; font-size: 13px; display: flex; align-items: center; }

/* ---------- modal */
.modal-back { position: fixed; inset: 0; background: rgba(16, 36, 26, .32); backdrop-filter: blur(4px); display: grid; place-items: center; padding: 16px; z-index: 50; animation: fade .15s var(--ease); }
.modal { width: min(520px, 100%); background: var(--card); border: 1px solid var(--line-strong); border-radius: var(--radius-lg); padding: 24px; box-shadow: 0 24px 64px rgba(16, 36, 26, .18); animation: rise .2s var(--ease); max-height: calc(100vh - 32px); overflow-y: auto; }
.modal h3 { font-size: 18px; margin-bottom: 6px; }
.modal .actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; flex-wrap: wrap; }
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }

/* ---------- toast */
.toast-host { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); display: grid; gap: 8px; z-index: 60; pointer-events: none; width: min(420px, calc(100% - 32px)); }
.toast { background: #fff; border: 1px solid var(--line-strong); color: var(--fg); padding: 12px 16px; border-radius: 10px; font-size: 14px; box-shadow: var(--shadow); animation: rise .2s var(--ease); display: flex; gap: 10px; align-items: center; }
.toast.error { border-color: rgba(229, 72, 77, .5); }
.toast.ok .ico { color: var(--accent); }
.toast.error .ico { color: var(--danger); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
  @view-transition { navigation: none; }
  .skel::after { animation: none; }
}
