/* The free-tools pages (/tools/, /tools/script/; site/src/layouts/ToolPage.astro): a catalog look in Naka's own
   colours. Light pearl canvas with a soft cobalt glow by day, the Studio dark values by night (prefers-color-scheme,
   or data-theme on <html>). Cobalt marks brand and selection, orange is only for the main action and keeps navy text
   in both themes. Every control is at least 44px tall; inputs use 16px text so phones do not zoom in. */

:root {
  --tk-bg: #f4f7fc;
  --tk-glow: rgba(29, 80, 190, .1);
  --tk-glow-2: rgba(131, 180, 255, .16);
  --tk-surface: #ffffff;
  --tk-surface-soft: #edf3fb;
  --tk-line: #d2deed;
  --tk-line-strong: #b6c7de;
  --tk-ink: #14233b;
  --tk-ink-2: #4b5b74;
  --tk-ink-3: #506079;
  --tk-brand: #1d50be;
  --tk-brand-ink: #1a46a6;
  --tk-brand-soft: #e6efff;
  --tk-focus: #2d66d6;
  --tk-focus-halo: rgba(29, 80, 190, .2);
  --tk-action: #f97316;
  --tk-action-hover: #fb8a3c;
  --tk-action-press: #f38926;
  --tk-on-action: #14233b;
  --tk-error: #b42318;
  --tk-error-bg: #fdecea;
  --tk-template: #7a4b00;
  --tk-template-bg: #fdf1d8;
  --tk-glass: rgba(255, 255, 255, .86);
  --tk-shadow: 0 1px 2px rgba(20, 35, 59, .04), 0 10px 30px rgba(20, 35, 59, .06);
  --tk-shadow-hover: 0 2px 6px rgba(20, 35, 59, .06), 0 18px 40px rgba(20, 35, 59, .1);
  --tk-display: "Kanit", "IBM Plex Sans Thai", system-ui, sans-serif;
  --tk-body: "IBM Plex Sans Thai", system-ui, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --tk-bg: #0d1726;
    --tk-glow: rgba(131, 180, 255, .14);
    --tk-glow-2: rgba(29, 80, 190, .28);
    --tk-surface: #18273d;
    --tk-surface-soft: #1d304a;
    --tk-line: #2d4361;
    --tk-line-strong: #456184;
    --tk-ink: #f3f7fd;
    --tk-ink-2: #c3cfdf;
    --tk-ink-3: #a2b4cd;
    --tk-brand: #a5c9ff;
    --tk-brand-ink: #a5c9ff;
    --tk-brand-soft: #213c61;
    --tk-focus: #83b4ff;
    --tk-focus-halo: rgba(131, 180, 255, .24);
    --tk-error: #ffb4ab;
    --tk-error-bg: #3b1f22;
    --tk-template: #ffd88a;
    --tk-template-bg: #3a2e14;
    --tk-glass: rgba(16, 27, 45, .86);
    --tk-shadow: 0 1px 2px rgba(0, 0, 0, .16), 0 10px 30px rgba(0, 0, 0, .22);
    --tk-shadow-hover: 0 2px 6px rgba(0, 0, 0, .2), 0 18px 40px rgba(0, 0, 0, .32);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --tk-bg: #0d1726;
  --tk-glow: rgba(131, 180, 255, .14);
  --tk-glow-2: rgba(29, 80, 190, .28);
  --tk-surface: #18273d;
  --tk-surface-soft: #1d304a;
  --tk-line: #2d4361;
  --tk-line-strong: #456184;
  --tk-ink: #f3f7fd;
  --tk-ink-2: #c3cfdf;
  --tk-ink-3: #a2b4cd;
  --tk-brand: #a5c9ff;
  --tk-brand-ink: #a5c9ff;
  --tk-brand-soft: #213c61;
  --tk-focus: #83b4ff;
  --tk-focus-halo: rgba(131, 180, 255, .24);
  --tk-error: #ffb4ab;
  --tk-error-bg: #3b1f22;
  --tk-template: #ffd88a;
  --tk-template-bg: #3a2e14;
  --tk-glass: rgba(16, 27, 45, .86);
  --tk-shadow: 0 1px 2px rgba(0, 0, 0, .16), 0 10px 30px rgba(0, 0, 0, .22);
  --tk-shadow-hover: 0 2px 6px rgba(0, 0, 0, .2), 0 18px 40px rgba(0, 0, 0, .32);
  color-scheme: dark;
}

/* ---------- page ---------- */
* { box-sizing: border-box; }
.tk-page [hidden] { display: none !important; }
html { background: var(--tk-bg); }
body.tk-page {
  margin: 0; min-height: 100vh; color: var(--tk-ink); font-family: var(--tk-body); font-size: 16px; line-height: 1.7;
  background:
    radial-gradient(900px 420px at 50% -80px, var(--tk-glow), transparent 70%),
    radial-gradient(600px 300px at 85% 120px, var(--tk-glow-2), transparent 70%),
    var(--tk-bg);
  background-repeat: no-repeat;
  -webkit-text-size-adjust: 100%;
}
.tk-page a { color: inherit; text-decoration: none; }
.tk-page img, .tk-page svg { display: block; max-width: 100%; }
.tk-page :focus-visible { outline: 3px solid var(--tk-focus); outline-offset: 3px; border-radius: 8px; }
.tk-skip { position: absolute; left: 16px; top: -60px; z-index: 100; padding: 10px 14px; border-radius: 10px; background: var(--tk-surface); }
.tk-skip:focus { top: 12px; }

/* ---------- top bar ---------- */
.tk-bar {
  position: sticky; top: 12px; z-index: 50; display: flex; align-items: center; gap: 12px;
  width: min(100% - 32px, 1200px); min-height: 64px; margin: 12px auto 0; padding: 8px 10px 8px 16px;
  border: 1px solid var(--tk-line); border-radius: 20px; background: var(--tk-glass); box-shadow: var(--tk-shadow);
  -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px);
}
.tk-brand { display: inline-flex; align-items: center; gap: 10px; min-height: 44px; font-family: var(--tk-display); font-size: 20px; font-weight: 600; letter-spacing: -.02em; }
.tk-brand img { border-radius: 10px; }
.tk-brand b { color: var(--tk-brand); }
.tk-nav { display: flex; gap: 6px; margin-left: 12px; }
.tk-nav a {
  display: inline-flex; align-items: center; min-height: 40px; padding: 0 14px; border: 1px solid transparent; border-radius: 999px;
  color: var(--tk-ink-2); font-size: 14px; font-weight: 500; transition: background-color .16s ease, color .16s ease;
}
.tk-nav a:hover { background: var(--tk-surface-soft); color: var(--tk-ink); }
.tk-nav a[aria-current="page"] { border-color: var(--tk-line); background: var(--tk-brand-soft); color: var(--tk-brand-ink); font-weight: 600; }
.tk-bar-end { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.tk-signin { display: inline-flex; align-items: center; min-height: 44px; padding: 0 12px; color: var(--tk-ink-2); font-size: 14px; font-weight: 500; }
.tk-signin:hover { color: var(--tk-ink); }

/* ---------- buttons ---------- */
.tk-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; padding: 0 22px;
  border: 1px solid transparent; border-radius: 12px; font: inherit; font-size: 16px; font-weight: 600; line-height: 1.2;
  text-align: center; cursor: pointer; transition: background-color .16s ease, border-color .16s ease, transform .16s ease;
}
.tk-btn-sm { min-height: 44px; padding: 0 16px; font-size: 14px; }
.tk-btn-block { width: 100%; }
.tk-btn-primary { background: var(--tk-action); color: var(--tk-on-action); }
.tk-btn-primary:hover { background: var(--tk-action-hover); }
.tk-btn-primary:active { background: var(--tk-action-press); }
.tk-btn-primary:disabled { opacity: .6; cursor: progress; }
.tk-btn-quiet { border-color: var(--tk-line); background: var(--tk-surface-soft); color: var(--tk-ink); }
.tk-btn-quiet:hover { border-color: var(--tk-line-strong); }

/* ---------- main column ---------- */
.tk-main { width: min(100% - 32px, 1200px); margin: 0 auto; padding: 0 0 48px; }
.tk-crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 16px 0 0; color: var(--tk-ink-3); font-size: 14px; }
.tk-crumbs a { display: inline-flex; align-items: center; min-height: 44px; color: var(--tk-brand-ink); font-weight: 500; }
.tk-crumbs a:hover { text-decoration: underline; text-underline-offset: 3px; }

/* ---------- hero ---------- */
.tk-hero { max-width: 820px; margin: 0 auto; padding: 64px 0 40px; text-align: center; }
.tk-hero-tool { padding-top: 28px; }
.tk-eyebrow {
  display: inline-flex; align-items: center; gap: 10px; margin: 0 0 14px; color: var(--tk-brand-ink);
  font-size: 13px; font-weight: 600; letter-spacing: .04em;
}
.tk-eyebrow::before { content: ""; width: 18px; height: 2px; border-radius: 2px; background: currentColor; opacity: .7; }
.tk-hero h1 {
  margin: 0 0 14px; font-family: var(--tk-display); font-size: clamp(32px, 6.4vw, 56px); font-weight: 600;
  line-height: 1.2; letter-spacing: -.02em; text-wrap: balance;
}
.tk-hero h1 em { font-style: normal; color: var(--tk-brand); }
.tk-lead { max-width: 640px; margin: 0 auto; color: var(--tk-ink-2); font-size: 17px; line-height: 1.8; text-wrap: pretty; }
.tk-stats { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin: 24px 0 0; padding: 0; list-style: none; }
.tk-stats li {
  display: inline-flex; align-items: center; gap: 8px; min-height: 36px; padding: 0 14px; border: 1px solid var(--tk-line);
  border-radius: 999px; background: var(--tk-surface); color: var(--tk-ink-2); font-size: 14px;
}
.tk-stats li::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--tk-brand); }
.tk-stats li:nth-child(2)::before { background: var(--tk-action); }
.tk-stats li:nth-child(3)::before { background: var(--tk-ink-3); }
.tk-stats b { color: var(--tk-ink); font-weight: 700; }
.tk-tabs {
  display: inline-flex; flex-wrap: wrap; justify-content: center; gap: 4px; margin: 28px 0 0; padding: 5px;
  border: 1px solid var(--tk-line); border-radius: 16px; background: var(--tk-surface); box-shadow: var(--tk-shadow);
}
.tk-tabs a {
  display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 16px; border-radius: 12px;
  color: var(--tk-ink-2); font-size: 15px; font-weight: 600; transition: background-color .16s ease, color .16s ease;
}
.tk-tabs a:first-child { background: var(--tk-brand); color: #fff; }
.tk-tabs a:not(:first-child):hover { background: var(--tk-surface-soft); color: var(--tk-ink); }
.tk-tabs span { min-width: 26px; padding: 1px 7px; border-radius: 999px; background: var(--tk-surface-soft); color: var(--tk-ink-3); font-size: 12px; text-align: center; }
.tk-tabs a:first-child span { background: rgba(255, 255, 255, .22); color: #fff; }
:root[data-theme="dark"] .tk-tabs a:first-child { color: #0d1726; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .tk-tabs a:first-child { color: #0d1726; } }
:root[data-theme="dark"] .tk-tabs a:first-child span { background: rgba(13, 23, 38, .18); color: #0d1726; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .tk-tabs a:first-child span { background: rgba(13, 23, 38, .18); color: #0d1726; } }

/* ---------- banner ---------- */
.tk-banner {
  display: flex; align-items: center; gap: 16px; margin: 8px 0 56px; padding: 20px 22px; border: 1px solid var(--tk-line);
  border-radius: 24px; background: linear-gradient(100deg, var(--tk-brand-soft), var(--tk-surface) 60%); box-shadow: var(--tk-shadow);
}
.tk-banner > div { flex: 1; min-width: 0; }
.tk-banner strong { display: block; font-family: var(--tk-display); font-size: 20px; font-weight: 600; line-height: 1.4; }
.tk-banner p { margin: 2px 0 0; color: var(--tk-ink-2); font-size: 15px; line-height: 1.7; }
.tk-banner-quiet { margin: 40px 0 0; background: var(--tk-surface); }
.tk-banner-quiet strong { font-size: 18px; }

/* ---------- icon tile, badges ---------- */
.tk-tile {
  display: inline-grid; flex: none; place-items: center; width: 44px; height: 44px; border-radius: 14px;
  background: var(--tk-brand-soft); color: var(--tk-brand);
}
.tk-tile-lg { width: 56px; height: 56px; border-radius: 18px; }
.tk-badge {
  display: inline-flex; align-items: center; min-height: 26px; padding: 0 10px; border-radius: 999px;
  background: var(--tk-action); color: var(--tk-on-action); font-size: 12px; font-weight: 700; white-space: nowrap;
}
.tk-badge-quiet { background: var(--tk-surface-soft); color: var(--tk-ink-2); font-weight: 600; }
.tk-badge-template { background: var(--tk-template-bg); color: var(--tk-template); }
.sc-result-head .tk-badge:not(.tk-badge-template) { background: var(--tk-brand-soft); color: var(--tk-brand-ink); }

/* ---------- sections and cards ---------- */
.tk-section { margin: 0 0 56px; scroll-margin-top: 96px; }
.tk-section-head { display: flex; align-items: flex-start; gap: 14px; margin: 0 0 20px; }
.tk-section-head > div { flex: 1; min-width: 0; }
.tk-section-head .tk-eyebrow { margin: 0 0 2px; font-size: 12px; }
.tk-section-head h2 { margin: 0; font-family: var(--tk-display); font-size: clamp(24px, 3.6vw, 30px); font-weight: 600; line-height: 1.3; }
.tk-section-head p { margin: 2px 0 0; color: var(--tk-ink-3); font-size: 14px; }
.tk-count {
  flex: none; align-self: center; padding: 4px 12px; border: 1px solid var(--tk-line); border-radius: 999px;
  background: var(--tk-surface); color: var(--tk-ink-2); font-size: 13px; white-space: nowrap;
}
.tk-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; margin: 0; padding: 0; list-style: none; }
.tk-card > a {
  position: relative; display: flex; flex-direction: column; gap: 8px; height: 100%; padding: 20px; border: 1px solid var(--tk-line);
  border-radius: 20px; background: var(--tk-surface); box-shadow: var(--tk-shadow);
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}
.tk-card > a:hover { transform: translateY(-2px); border-color: var(--tk-line-strong); box-shadow: var(--tk-shadow-hover); }
.tk-card .tk-badge { position: absolute; top: 16px; right: 16px; }
.tk-card .tk-tile { margin-bottom: 6px; }
.tk-card-label { color: var(--tk-ink-3); font-size: 12px; font-weight: 600; letter-spacing: .03em; }
.tk-card strong { font-family: var(--tk-display); font-size: 19px; font-weight: 600; line-height: 1.4; }
.tk-card-desc { flex: 1; color: var(--tk-ink-2); font-size: 14px; line-height: 1.7; }
.tk-card-go { margin-top: 6px; color: var(--tk-brand-ink); font-size: 14px; font-weight: 600; }
.tk-grid-feature { grid-template-columns: minmax(0, 1fr); }
.tk-card-feature > a {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; grid-template-areas: "tile label go" "tile title go" "tile desc go";
  align-items: center; column-gap: 20px; row-gap: 2px; padding: 24px 28px;
  background: linear-gradient(110deg, var(--tk-surface) 55%, var(--tk-brand-soft));
}
.tk-card-feature .tk-tile { grid-area: tile; margin: 0; }
.tk-card-feature .tk-card-label { grid-area: label; }
.tk-card-feature strong { grid-area: title; font-size: 22px; }
.tk-card-feature .tk-card-desc { grid-area: desc; }
.tk-card-feature .tk-card-go {
  grid-area: go; margin: 0; padding: 0 20px; min-height: 48px; display: inline-flex; align-items: center;
  border-radius: 12px; background: var(--tk-action); color: var(--tk-on-action); font-size: 15px;
}
.tk-card-feature .tk-badge { position: static; grid-area: label; justify-self: end; }

/* ---------- the tool: form beside its result ---------- */
.tk-work { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); gap: 20px; align-items: start; }
.tk-panel { padding: 24px; border: 1px solid var(--tk-line); border-radius: 24px; background: var(--tk-surface); box-shadow: var(--tk-shadow); }
.tk-panel-head { display: flex; align-items: center; gap: 12px; margin: 0 0 18px; }
.tk-panel-head h2 { margin: 0; font-family: var(--tk-display); font-size: 20px; font-weight: 600; line-height: 1.4; }
.tk-step {
  display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 10px;
  background: var(--tk-brand-soft); color: var(--tk-brand); font-family: var(--tk-display); font-weight: 600;
}
.tk-note { margin: 10px 0 0; color: var(--tk-ink-3); font-size: 13px; line-height: 1.6; }

.sc-field { display: grid; gap: 8px; min-width: 0; margin: 0 0 18px; padding: 0; border: 0; }
.sc-field label, .sc-field legend { padding: 0; color: var(--tk-ink); font-size: 15px; font-weight: 600; }
.sc-field legend { margin-bottom: 8px; }
.sc-field legend span { margin-left: 6px; color: var(--tk-ink-3); font-size: 13px; font-weight: 400; }
.sc-field input {
  width: 100%; min-height: 48px; padding: 0 14px; border: 1px solid var(--tk-line-strong); border-radius: 12px;
  background: var(--tk-surface); color: var(--tk-ink); font: inherit; font-size: 16px;
  transition: border-color .16s ease, box-shadow .16s ease;
}
.sc-field input::placeholder { color: var(--tk-ink-3); opacity: 1; }
.sc-field input:focus { border-color: var(--tk-focus); box-shadow: 0 0 0 4px var(--tk-focus-halo); outline: none; }
.sc-turnstile { min-height: 65px; margin: 0 0 16px; }
.sc-error { margin: 0 0 16px; padding: 10px 14px; border-radius: 12px; background: var(--tk-error-bg); color: var(--tk-error); font-size: 14px; line-height: 1.6; }

.sc-empty {
  display: grid; justify-items: center; gap: 12px; padding: 48px 16px; border: 1.5px dashed var(--tk-line-strong); border-radius: 18px;
  color: var(--tk-ink-3); text-align: center;
}
.sc-empty p { max-width: 280px; margin: 0; font-size: 15px; }
.sc-result { scroll-margin-top: 96px; }
.sc-result-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 12px; }
.sc-result h3 { margin: 0; font-family: var(--tk-display); font-size: 18px; font-weight: 600; line-height: 1.4; overflow-wrap: anywhere; }
.sc-via-note { margin: 8px 0 0; color: var(--tk-ink-2); font-size: 14px; line-height: 1.7; }
.sc-result h4 { margin: 20px 0 6px; color: var(--tk-ink-3); font-size: 13px; font-weight: 600; letter-spacing: .02em; }
.sc-hook {
  margin: 0; padding: 14px 16px; border-left: 4px solid var(--tk-action); border-radius: 0 12px 12px 0; background: var(--tk-surface-soft);
  font-family: var(--tk-display); font-size: clamp(20px, 4.4vw, 24px); font-weight: 600; line-height: 1.45; overflow-wrap: anywhere;
}
.sc-lines { margin: 0; padding-left: 24px; }
.sc-lines li { margin: 4px 0; font-size: 16px; line-height: 1.75; overflow-wrap: anywhere; }
.sc-caption { margin: 0; font-size: 15px; line-height: 1.8; overflow-wrap: anywhere; }
.sc-tags { margin: 0; color: var(--tk-brand-ink); font-size: 15px; font-weight: 600; line-height: 1.8; overflow-wrap: anywhere; }
.sc-actions { display: flex; flex-wrap: wrap; gap: 10px; margin: 24px 0 0; }

/* ---------- footer ---------- */
.tk-foot { width: min(100% - 32px, 1200px); margin: 0 auto; padding: 24px 0 32px; border-top: 1px solid var(--tk-line); color: var(--tk-ink-3); font-size: 14px; }
.tk-foot nav { display: flex; flex-wrap: wrap; gap: 4px 6px; margin: 0 0 8px 0; }
.tk-foot nav a { display: inline-flex; align-items: center; min-height: 44px; padding: 0 10px; border-radius: 10px; color: var(--tk-ink-2); }
.tk-foot nav a:hover { background: var(--tk-surface-soft); color: var(--tk-ink); }
.tk-foot p { margin: 0 10px; font-size: 13px; }

/* ---------- smaller screens ---------- */
@media (max-width: 980px) {
  .tk-nav { display: none; }
  .tk-work { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 720px) {
  .tk-card-feature > a { grid-template-columns: auto minmax(0, 1fr); grid-template-areas: "tile label" "title title" "desc desc" "go go"; padding: 20px; row-gap: 6px; }
  .tk-card-feature .tk-card-go { justify-content: center; margin-top: 10px; }
  .tk-banner { flex-wrap: wrap; }
  .tk-banner > a { width: 100%; }
}
@media (max-width: 560px) {
  .tk-bar { width: calc(100% - 24px); margin-top: 8px; top: 8px; padding: 6px 6px 6px 12px; min-height: 58px; }
  .tk-brand { font-size: 18px; gap: 8px; }
  .tk-brand img { width: 28px; height: 28px; }
  .tk-signin { padding: 0 8px; }
  .tk-main, .tk-foot { width: calc(100% - 32px); }
  .tk-hero { padding: 40px 0 28px; }
  .tk-hero-tool { padding-top: 20px; }
  .tk-lead { font-size: 16px; }
  .tk-tabs { display: flex; width: 100%; }
  .tk-tabs a { flex: 1 1 auto; justify-content: center; padding: 0 10px; font-size: 14px; }
  .tk-panel { padding: 18px 16px; border-radius: 20px; }
  .tk-banner { padding: 18px 16px; margin-bottom: 40px; }
  .tk-section-head { flex-wrap: wrap; }
  .tk-count { order: 3; margin-left: 58px; }
  .tk-section-head .tk-count { align-self: auto; }
  .sc-actions .tk-btn { width: 100%; }
  /* cards become compact rows: tile, name and one line, the whole row is the link */
  .tk-grid { gap: 10px; }
  .tk-card:not(.tk-card-feature) > a {
    display: grid; grid-template-columns: auto minmax(0, 1fr); grid-template-areas: "tile title" "tile desc";
    align-items: center; column-gap: 14px; row-gap: 0; padding: 14px 16px; border-radius: 16px;
  }
  .tk-card:not(.tk-card-feature) .tk-tile { grid-area: tile; margin: 0; }
  .tk-card:not(.tk-card-feature) strong { grid-area: title; padding-right: 92px; font-size: 17px; }
  .tk-card:not(.tk-card-feature) .tk-card-desc { grid-area: desc; font-size: 13.5px; line-height: 1.6; }
  .tk-card:not(.tk-card-feature) :is(.tk-card-label, .tk-card-go) { display: none; }
  .tk-card:not(.tk-card-feature) .tk-badge { top: 12px; right: 12px; min-height: 22px; padding: 0 8px; font-size: 11px; }
}
@media (max-width: 420px) {
  .tk-tabs { gap: 2px; }
  .tk-tabs a { gap: 6px; padding: 0 8px; font-size: 13.5px; }
  .tk-tabs span { min-width: 20px; padding: 0 5px; }
}
@media (max-width: 360px) {
  .tk-signin { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .tk-page * { transition: none !important; }
  .tk-card > a:hover { transform: none; }
}
