/* =========================================================
   PromptKru 2.2 · Design System กลางของทุกโมดูล
   แนวทาง: เรียบ เป็นทางการ อ่านง่าย (เส้นบาง สีหลักสีเดียว ไม่มีอีโมจิในส่วนติดต่อผู้ใช้)
   ========================================================= */

:root {
  --font-sans: 'IBM Plex Sans Thai', 'Noto Sans Thai', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-head: var(--font-sans);
  --font-body: var(--font-sans);
  --font-mono: 'IBM Plex Mono', ui-monospace, 'SFMono-Regular', Menlo, monospace;
  --fs: 1;

  --bg: #f5f9fd;
  --bg-2: #edf4fa;
  --surface: #ffffff;
  --surface-2: #f5f9fd;
  --ink: #102d55;
  --ink-2: #435a77;
  --muted: #5d718b;
  --line: #e2ebf3;
  --line-2: #cbd9e8;

  --brand: #0077d8;
  --brand-ink: #0065bb;
  --brand-hover: #0064b8;
  --brand-soft: #e8f5ff;
  --brand-deep: #10284b;
  --on-brand: #ffffff;
  --gold: #a87a12;
  --gold-ink: #7a5806;
  --gold-soft: #f6f0de;
  --ok: #24704d;
  --ok-soft: #e7f2ec;
  --warn: #8a5a00;
  --warn-soft: #faf2df;
  --danger: #a3283a;
  --danger-soft: #f9e9eb;

  --m1: #087ec9; --m1-ink: #0069af; --m1-soft: #e7f5ff;
  --m2: #168365; --m2-ink: #146c54; --m2-soft: #e8f8f1;
  --m3: #a8790e; --m3-ink: #80600b; --m3-soft: #fff7df;
  --m4: #7750c4; --m4-ink: #6540af; --m4-soft: #f2ecff;

  --mod: var(--brand);
  --mod-ink: var(--brand-ink);
  --mod-soft: var(--brand-soft);

  --radius: 20px;
  --radius-md: 14px;
  --radius-sm: 10px;
  --shadow-1: 0 1px 2px rgba(20, 25, 30, .04);
  --shadow-2: 0 2px 4px rgba(20, 25, 30, .05), 0 8px 24px rgba(20, 25, 30, .07);
  --shadow-3: 0 12px 40px rgba(12, 18, 28, .22);
  --header-h: 84px;
  --bottomnav-h: 62px;
  --wrap: 1200px;
  --gutter: 16px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root[data-theme="auto"] {
    --bg: #111315; --bg-2: #16191c; --surface: #191c1f; --surface-2: #1f2326;
    --ink: #e9eaeb; --ink-2: #c3c7cb; --muted: #8e959c; --line: #2b3034; --line-2: #3b4147;
    --brand: #9fbbe6; --brand-ink: #a9c3ea; --brand-hover: #b7cdef; --brand-soft: #1c2738; --brand-deep: #0c1626; --on-brand: #0e1828;
    --gold: #d6aa48; --gold-ink: #e2bd6a; --gold-soft: #2e2715;
    --ok: #6cc59a; --ok-soft: #15291f; --warn: #e0b257; --warn-soft: #2d2513; --danger: #ef8a98; --danger-soft: #331b20;
    --m1: #80c7f3; --m1-ink: #9fd7fa; --m1-soft: #182c42;
    --m2: #79d8b6; --m2-ink: #a2e6ce; --m2-soft: #18342d;
    --m3: #d3ad4f; --m3-ink: #dfbf6d; --m3-soft: #2b2516;
    --m4: #bea6ed; --m4-ink: #cfbaf5; --m4-soft: #2b223c;
    --shadow-1: 0 1px 2px rgba(0, 0, 0, .3);
    --shadow-2: 0 8px 24px rgba(0, 0, 0, .4);
    --shadow-3: 0 16px 48px rgba(0, 0, 0, .55);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #111315; --bg-2: #16191c; --surface: #191c1f; --surface-2: #1f2326;
  --ink: #e9eaeb; --ink-2: #c3c7cb; --muted: #8e959c; --line: #2b3034; --line-2: #3b4147;
  --brand: #9fbbe6; --brand-ink: #a9c3ea; --brand-hover: #b7cdef; --brand-soft: #1c2738; --brand-deep: #0c1626; --on-brand: #0e1828;
  --gold: #d6aa48; --gold-ink: #e2bd6a; --gold-soft: #2e2715;
  --ok: #6cc59a; --ok-soft: #15291f; --warn: #e0b257; --warn-soft: #2d2513; --danger: #ef8a98; --danger-soft: #331b20;
  --m1: #80c7f3; --m1-ink: #9fd7fa; --m1-soft: #182c42;
  --m2: #79d8b6; --m2-ink: #a2e6ce; --m2-soft: #18342d;
  --m3: #d3ad4f; --m3-ink: #dfbf6d; --m3-soft: #2b2516;
  --m4: #bea6ed; --m4-ink: #cfbaf5; --m4-soft: #2b223c;
  --shadow-1: 0 1px 2px rgba(0, 0, 0, .3);
  --shadow-2: 0 8px 24px rgba(0, 0, 0, .4);
  --shadow-3: 0 16px 48px rgba(0, 0, 0, .55);
  color-scheme: dark;
}

[data-module="m1"] { --mod: var(--m1); --mod-ink: var(--m1-ink); --mod-soft: var(--m1-soft); }
[data-module="m2"] { --mod: var(--m2); --mod-ink: var(--m2-ink); --mod-soft: var(--m2-soft); }
[data-module="m3"] { --mod: var(--m3); --mod-ink: var(--m3-ink); --mod-soft: var(--m3-soft); }
[data-module="m4"] { --mod: var(--m4); --mod-ink: var(--m4-ink); --mod-soft: var(--m4-soft); }

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { font-size: calc(16.5px * var(--fs)); -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0; min-height: 100vh; background: var(--bg); color: var(--ink);
  font-family: var(--font-body); line-height: 1.7; font-size: 1rem; font-weight: 400;
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
  padding-bottom: calc(var(--bottomnav-h) + env(safe-area-inset-bottom));
  overflow-x: hidden;
}
@media (min-width: 1024px) { body { padding-bottom: 0; } }
h1, h2, h3, h4 { font-family: var(--font-head); line-height: 1.35; margin: 0 0 .45em; font-weight: 600; letter-spacing: 0; color: var(--ink); }
h1 { font-size: clamp(1.7rem, 1.25rem + 2vw, 2.45rem); line-height: 1.3; }
h2 { font-size: clamp(1.2rem, 1.05rem + .7vw, 1.5rem); }
h3 { font-size: 1.06rem; }
h4 { font-size: .98rem; }
p { margin: 0 0 .8em; }
b, strong { font-weight: 600; }
a { color: var(--brand-ink); text-underline-offset: 3px; text-decoration-thickness: 1px; }
img, svg, video { max-width: 100%; display: block; }
:where(button, a, summary, h1, h2, h3, h4, p, span, li, div.sub-h, label) > svg:not([width]) { width: 1.1em; height: 1.1em; flex: 0 0 auto; }
.sub-h svg, .next-item svg, .path-step svg, .mc-tool svg, .list-item > svg { width: 18px; height: 18px; flex: 0 0 auto; color: var(--muted); }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 4px; }
.hidden { display: none !important; }
.sr-only { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.wrap { width: 100%; max-width: var(--wrap); margin: 0 auto; padding-inline: var(--gutter); }
@media (min-width: 700px) { :root { --gutter: 28px; } }
.muted { color: var(--muted); }
.small { font-size: .86rem; }
.center { text-align: center; }
.stack > * + * { margin-top: .75rem; }
.row { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.grow { flex: 1 1 auto; min-width: 0; }
.mono { font-family: var(--font-mono); }
.skip-link { position: absolute; left: -999px; top: 8px; background: var(--brand); color: var(--on-brand); padding: .5rem 1rem; border-radius: 4px; z-index: 999; }
.skip-link:focus { left: 8px; }

/* ---------- Top bar (ข้อความกำกับหลักสูตร) ---------- */
.pk-topbar { background: var(--brand-deep); color: rgba(255, 255, 255, .82); font-size: .76rem; display: none; }
@media (min-width: 1024px) { .pk-topbar { display: block; } }
.pk-topbar .wrap { display: flex; align-items: center; justify-content: space-between; gap: 1rem; min-height: 34px; }
.pk-topbar a { color: #fff; text-decoration: none; }
.pk-topbar a:hover { text-decoration: underline; }
.pk-topbar nav { display: flex; gap: 1.2rem; }

/* ---------- Header ---------- */
.pk-header { position: sticky; top: 0; z-index: 60; height: var(--header-h); background: var(--surface); border-bottom: 1px solid var(--line); }
.pk-header .wrap { height: 100%; display: flex; align-items: center; gap: 1rem; }
.pk-brand { display: inline-flex; align-items: center; gap: .6rem; text-decoration: none; color: var(--ink); flex: 0 0 auto; }
.pk-logo { width: 34px; height: 34px; border-radius: 7px; display: grid; place-items: center; background: var(--brand-deep); flex: 0 0 auto; }
:root[data-theme="dark"] .pk-logo { background: #2a4a7c; }
@media (prefers-color-scheme: dark) { :root[data-theme="auto"] .pk-logo { background: #2a4a7c; } }
.pk-logo svg { width: 22px; height: 22px; }
.pk-brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.pk-brand-name { font-family: var(--font-head); font-weight: 600; font-size: 1.06rem; letter-spacing: -.005em; }
.pk-brand-name b { font-weight: 600; color: inherit; }
.pk-brand-sub { font-size: .68rem; color: var(--muted); font-weight: 500; }
.pk-nav { display: none; align-self: stretch; gap: .1rem; margin-left: .8rem; }
@media (min-width: 1024px) { .pk-nav { display: flex; } }
.pk-nav a {
  display: inline-flex; align-items: center; gap: .45rem; padding: 0 .75rem; position: relative;
  text-decoration: none; color: var(--ink-2); font-weight: 500; font-size: .88rem; white-space: nowrap;
}
.pk-nav a::after { content: ''; position: absolute; left: .75rem; right: .75rem; bottom: -1px; height: 2px; background: transparent; }
.pk-nav a .no { font-family: var(--font-mono); font-size: .74rem; font-weight: 600; color: var(--mod); }
.pk-nav a:hover { color: var(--ink); }
.pk-nav a:hover::after { background: var(--line-2); }
.pk-nav a[aria-current="page"] { color: var(--ink); font-weight: 600; }
.pk-nav a[aria-current="page"]::after { background: var(--mod); }
.pk-header-actions { margin-left: auto; display: flex; gap: .4rem; align-items: center; }
.pk-profile-btn {
  display: inline-flex; align-items: center; gap: .5rem; max-width: 30vw; border: 1px solid var(--line-2);
  background: var(--surface); padding: .38rem .8rem .38rem .6rem; border-radius: 6px; font-size: .84rem; font-weight: 500; color: var(--ink-2); min-height: 38px;
}
.pk-profile-btn svg { width: 17px; height: 17px; color: var(--muted); flex: 0 0 auto; }
.pk-profile-btn .lbl { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pk-profile-btn:hover { border-color: var(--ink-2); color: var(--ink); }
@media (max-width: 1023px) { .pk-profile-btn { display: none; } }
.icon-btn {
  width: 40px; height: 40px; border-radius: 6px; border: 1px solid transparent; background: transparent; color: var(--ink-2);
  display: inline-grid; place-items: center; flex: 0 0 auto; text-decoration: none;
}
.icon-btn:hover { background: var(--surface-2); border-color: var(--line); color: var(--ink); }
.icon-btn svg { width: 20px; height: 20px; }

/* ---------- Bottom nav (มือถือ/แท็บเล็ต) ---------- */
.pk-bottomnav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 70; height: calc(var(--bottomnav-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom); background: var(--surface); border-top: 1px solid var(--line);
  display: grid; grid-template-columns: repeat(5, 1fr);
}
@media (min-width: 1024px) { .pk-bottomnav { display: none; } }
.pk-bottomnav a, .pk-bottomnav button {
  position: relative; border: 0; background: none; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  text-decoration: none; color: var(--muted); font-size: clamp(11px, .68rem, 13px); font-weight: 500; padding: 6px 2px; min-width: 0; white-space: nowrap; overflow: hidden;
}
.pk-bottomnav svg { width: 22px; height: 22px; }
.pk-bottomnav .on { color: var(--ink); font-weight: 600; }
.pk-bottomnav .on::before { content: ''; position: absolute; top: -1px; left: 28%; right: 28%; height: 2px; background: var(--mod); }
.pk-bottomnav .mod-chip { width: 22px; height: 22px; border-radius: 4px; display: grid; place-items: center; border: 1.5px solid currentColor; font-family: var(--font-mono); font-size: .72rem; font-weight: 600; color: var(--mod); }

/* ---------- Buttons ---------- */
.btn {
  --b-bg: var(--surface); --b-fg: var(--ink); --b-bd: var(--line-2);
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem; min-height: 44px; padding: .5rem 1.05rem;
  border-radius: 6px; border: 1px solid var(--b-bd); background: var(--b-bg); color: var(--b-fg);
  font-weight: 600; font-size: .93rem; text-decoration: none; line-height: 1.3; transition: background .15s, border-color .15s, color .15s;
  -webkit-tap-highlight-color: transparent; user-select: none; text-align: center;
}
.btn:hover { border-color: var(--ink-2); }
.btn:active { transform: translateY(1px); }
.btn svg { width: 18px; height: 18px; flex: 0 0 auto; }
.btn[disabled], .btn.is-disabled { opacity: .5; pointer-events: none; }
.btn-primary { --b-bg: var(--brand); --b-fg: var(--on-brand); --b-bd: var(--brand); }
.btn-primary:hover { --b-bg: var(--brand-hover); border-color: var(--brand-hover); }
.btn-soft { --b-bg: var(--brand-soft); --b-fg: var(--brand-ink); --b-bd: transparent; }
.btn-soft:hover { border-color: color-mix(in srgb, var(--brand) 40%, transparent); }
.btn-mod { --b-bg: var(--mod-soft); --b-fg: var(--mod-ink); --b-bd: transparent; }
.btn-ghost { --b-bg: transparent; --b-bd: transparent; --b-fg: var(--ink-2); }
.btn-ghost:hover { --b-bg: var(--surface-2); border-color: var(--line); }
.btn-ok { --b-bg: var(--ok); --b-fg: #fff; --b-bd: var(--ok); }
.btn-lg { min-height: 52px; font-size: 1rem; padding: .65rem 1.4rem; }
.btn-sm { min-height: 36px; font-size: .84rem; padding: .3rem .75rem; }
.btn-block { width: 100%; }
.btn.is-done { --b-bg: var(--ok); --b-bd: var(--ok); --b-fg: #fff; }
:root[data-theme="dark"] .btn-ok, :root[data-theme="dark"] .btn.is-done { --b-fg: #0d1f16; }
@media (prefers-color-scheme: dark) { :root[data-theme="auto"] .btn-ok, :root[data-theme="auto"] .btn.is-done { --b-fg: #0d1f16; } }

/* ---------- Chips (ตัวเลือก) ---------- */
.chips { display: flex; flex-wrap: wrap; gap: .4rem; }
.chips.scroll { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; margin-inline: calc(var(--gutter) * -1); padding-inline: var(--gutter); scroll-padding-inline: var(--gutter); }
.chips.scroll::-webkit-scrollbar { display: none; }
.chip {
  display: inline-flex; align-items: center; gap: .4rem; min-height: 40px; padding: .35rem .8rem; border-radius: 6px;
  border: 1px solid var(--line-2); background: var(--surface); color: var(--ink-2); font-weight: 500; font-size: .9rem; white-space: nowrap;
  line-height: 1.35; -webkit-tap-highlight-color: transparent; transition: background .12s, border-color .12s, color .12s;
}
.chip:hover { border-color: var(--ink-2); color: var(--ink); }
.chip[aria-pressed="true"], .chip.on { background: var(--brand); border-color: var(--brand); color: var(--on-brand); font-weight: 600; }
.chip.wrap-text { white-space: normal; text-align: left; }
.chip .count { font-size: .76rem; opacity: .7; font-weight: 500; font-variant-numeric: tabular-nums; }
.chip-dashed { border-style: dashed; color: var(--brand-ink); }

/* ---------- Badges ---------- */
.badge { display: inline-flex; align-items: center; gap: .25rem; padding: .05rem .45rem; border-radius: 4px; font-size: .72rem; font-weight: 600; background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--line); white-space: nowrap; line-height: 1.6; }
.badge-mod { background: var(--mod-soft); color: var(--mod-ink); border-color: transparent; }
.badge-gold { background: var(--gold-soft); color: var(--gold-ink); border-color: transparent; }
.badge-ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.badge-new { background: var(--danger-soft); color: var(--danger); border-color: transparent; }

/* ---------- Cards ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.card-pad { padding: 1.1rem; }
@media (min-width: 700px) { .card-pad { padding: 1.4rem 1.5rem; } }

/* ---------- Page hero (หัวหน้าโมดูล) ---------- */
.mod-hero { position: relative; background: var(--surface); border-bottom: 1px solid var(--line); }
.mod-hero .wrap { padding-block: 1.2rem 1.4rem; position: relative; }
@media (min-width: 700px) { .mod-hero .wrap { padding-block: 1.6rem 1.8rem; } }
.mod-hero:has(.subnav) .wrap { padding-bottom: 0; }
.mod-hero .deco { display: none; }
.crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; font-size: .8rem; color: var(--muted); margin-bottom: .9rem; }
.crumbs a { color: var(--muted); text-decoration: none; }
.crumbs a:hover { color: var(--ink); text-decoration: underline; }
.crumbs .sep { color: var(--line-2); }
.mod-hero .eyebrow, .eyebrow { display: flex; flex-wrap: wrap; align-items: center; gap: .3rem .6rem; font-size: .84rem; font-weight: 500; color: var(--ink-2); margin: 0 0 .5rem; }
.eyebrow .mod-no, .mod-no { display: inline-flex; align-items: center; gap: .45rem; font-weight: 600; color: var(--mod-ink); }
.mod-no::before { content: ''; width: 9px; height: 9px; border-radius: 2px; background: var(--mod); flex: 0 0 auto; }
.mod-hero .eyebrow .num { display: none; }
.mod-hero h1 { font-size: clamp(1.6rem, 1.25rem + 1.6vw, 2.2rem); margin-bottom: .35rem; }
.mod-hero .lead { color: var(--ink-2); font-size: 1rem; max-width: 46rem; margin: 0; }
.steps-inline { display: flex; flex-wrap: wrap; align-items: center; gap: .3rem 1.1rem; margin-top: 1rem; font-size: .84rem; color: var(--muted); }
.steps-inline::before { content: 'วิธีใช้'; font-weight: 600; color: var(--ink-2); margin-right: .1rem; }
.steps-inline span { display: inline-flex; align-items: center; gap: .4rem; }
.steps-inline i { font-style: normal; font-family: var(--font-mono); width: 20px; height: 20px; border-radius: 50%; border: 1px solid var(--line-2); display: grid; place-items: center; font-size: .7rem; font-weight: 600; color: var(--ink-2); }

/* ---------- Profile bar ---------- */
.profile-bar { display: flex; align-items: center; gap: .5rem .8rem; flex-wrap: wrap; margin-top: 1.1rem; padding: .55rem .6rem .55rem .85rem; background: var(--surface-2); border: 1px solid var(--line); border-radius: 6px; font-size: .88rem; color: var(--ink-2); max-width: 46rem; }
.profile-bar .pin { display: inline-grid; place-items: center; color: var(--muted); }
.profile-bar .pin svg { width: 17px; height: 17px; }
.profile-bar b { font-weight: 600; color: var(--ink); }
.profile-bar > span:nth-child(2) { flex: 1 1 14rem; min-width: 0; }
.profile-bar .btn { margin-left: auto; }

/* ---------- Toolbar & library ---------- */
.lib-toolbar { position: sticky; top: var(--header-h); z-index: 30; background: var(--bg); padding-block: .8rem .6rem; border-bottom: 1px solid transparent; }
.lib-toolbar.stuck { border-bottom-color: var(--line); }
.search { position: relative; display: flex; align-items: center; }
.search svg { position: absolute; left: 13px; width: 19px; height: 19px; color: var(--muted); pointer-events: none; }
.search input {
  width: 100%; min-height: 48px; border-radius: 6px; border: 1px solid var(--line-2); background: var(--surface);
  padding: .55rem 2.8rem .55rem 2.6rem; font-size: 1rem; outline: none; transition: border-color .15s, box-shadow .15s;
}
.search input::placeholder { color: var(--muted); opacity: .85; }
.search input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 18%, transparent); }
input[type="search"]::-webkit-search-cancel-button { -webkit-appearance: none; display: none; }
.search .clear { position: absolute; right: 5px; width: 38px; height: 38px; border: 0; background: none; border-radius: 4px; color: var(--muted); display: grid; place-items: center; }
.search .clear svg { position: static; }
.search .clear:hover { background: var(--surface-2); }
.lib-toolbar .chips { margin-top: .6rem; }
.section-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; margin: 2.2rem 0 .9rem; padding-bottom: .6rem; border-bottom: 1px solid var(--line); }
.section-head h2 { margin: 0; display: flex; align-items: baseline; gap: .65rem; font-size: clamp(1.12rem, 1rem + .5vw, 1.32rem); }
.section-head h2 .sq, .section-head h2 .sec-no { font-family: var(--font-mono); font-size: .78rem; font-weight: 600; color: var(--mod-ink); background: none; width: auto; height: auto; display: inline; }
.section-head p { margin: .2rem 0 0; color: var(--muted); font-size: .88rem; }
.tool-grid { display: grid; gap: .75rem; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 640px) { .tool-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 1020px) { .tool-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .9rem; } }

.tool-card {
  position: relative; display: flex; flex-direction: column; gap: .4rem; text-align: left; width: 100%;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.05rem .85rem;
  color: var(--ink); text-decoration: none; transition: border-color .15s, box-shadow .15s;
  -webkit-tap-highlight-color: transparent; cursor: pointer;
}
.tool-card:hover { border-color: var(--line-2); box-shadow: var(--shadow-2); }
.tool-card:hover .tc-title { color: var(--brand-ink); }
.tool-card .tc-top { display: flex; align-items: flex-start; gap: .7rem; }
.tool-card .tc-icon { display: none; }
.tool-card .tc-mod { font-size: .76rem; font-weight: 600; color: var(--mod-ink); display: flex; align-items: center; gap: .4rem; }
.tool-card .tc-mod::before { content: ''; width: 7px; height: 7px; border-radius: 2px; background: var(--mod); }
.tool-card .tc-title { font-family: var(--font-head); font-weight: 600; font-size: 1.01rem; line-height: 1.45; margin: 0; padding-right: 2.2rem; transition: color .15s; }
.tool-card .tc-meta { display: flex; flex-wrap: wrap; gap: .3rem; margin-top: .3rem; }
.tool-card .tc-meta:empty { display: none; }
.tool-card .tc-problem { color: var(--ink-2); font-size: .9rem; margin: 0; line-height: 1.6; }
.tool-card .tc-get { margin-top: auto; padding-top: .6rem; border-top: 1px solid var(--line); display: flex; align-items: flex-start; gap: .5rem; font-size: .84rem; color: var(--ink-2); }
.tool-card .tc-get span { flex: 1 1 auto; min-width: 0; }
.tool-card .tc-get .k { flex: 0 0 auto; color: var(--muted); font-weight: 500; }
.tool-card .tc-get svg { width: 17px; height: 17px; flex: 0 0 auto; color: var(--muted); margin-top: .15rem; transition: transform .15s, color .15s; }
.tool-card:hover .tc-get svg { color: var(--brand-ink); transform: translateX(2px); }
.tool-card .fav { position: absolute; top: .55rem; right: .5rem; width: 38px; height: 38px; border-radius: 6px; border: 0; background: transparent; color: var(--line-2); display: grid; place-items: center; }
.tool-card .fav:hover { background: var(--surface-2); color: var(--gold); }
.tool-card .fav[aria-pressed="true"] { color: var(--gold); }
.tool-card .fav[aria-pressed="true"] svg { fill: currentColor; }
.tool-card .fav svg { width: 19px; height: 19px; }
.tool-card.flagship { border-color: color-mix(in srgb, var(--mod) 45%, var(--line)); box-shadow: inset 0 3px 0 var(--mod); }
.empty { text-align: center; padding: 2.5rem 1rem; color: var(--muted); }
.empty .big { display: grid; place-items: center; margin: 0 auto .6rem; width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--line-2); color: var(--muted); }
.empty .big svg { width: 20px; height: 20px; }

/* ---------- Feature cards (เครื่องมือพิเศษ) ---------- */
.feature-grid { display: grid; gap: .75rem; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 760px) { .feature-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.feature-card { display: flex; gap: .9rem; align-items: flex-start; padding: 1rem 1.1rem; border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface); text-align: left; width: 100%; color: var(--ink); text-decoration: none; transition: border-color .15s, box-shadow .15s; }
.feature-card:hover { border-color: var(--line-2); box-shadow: var(--shadow-2); }
.feature-card:hover h3 { color: var(--brand-ink); }
.feature-card .fi { width: 40px; height: 40px; border-radius: 6px; display: grid; place-items: center; flex: 0 0 auto; background: var(--mod-soft); color: var(--mod-ink); }
.feature-card .fi svg { width: 20px; height: 20px; }
.feature-card h3 { margin: 0 0 .15rem; transition: color .15s; }
.feature-card p { margin: 0; color: var(--ink-2); font-size: .9rem; }
.feature-card .fc-go { margin-left: auto; align-self: center; color: var(--muted); }
.feature-card .fc-go svg { width: 18px; height: 18px; }

/* ---------- Paths (เส้นทางแนะนำ) ---------- */
.path-grid { display: grid; gap: .75rem; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 900px) { .path-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.path-card { padding: 1rem 1.05rem 1.05rem; border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface); display: flex; flex-direction: column; }
.path-card .ph { display: flex; align-items: center; gap: .5rem; margin-bottom: .1rem; }
.path-card .ph .badge { font-size: .72rem; }
.path-card h3 { margin: .25rem 0 .2rem; font-size: 1rem; }
.path-card p { font-size: .87rem; color: var(--ink-2); margin: 0 0 .8rem; }
.path-steps { display: flex; flex-direction: column; margin-top: auto; border-top: 1px solid var(--line); }
.path-step { display: flex; align-items: center; gap: .6rem; width: 100%; border: 0; border-bottom: 1px solid var(--line); background: none; padding: .55rem .1rem; text-align: left; font-size: .88rem; font-weight: 500; color: var(--ink); text-decoration: none; }
.path-step:hover { color: var(--brand-ink); }
.path-step:hover svg { color: var(--brand-ink); }
.path-step .n { width: 22px; height: 22px; border-radius: 50%; border: 1px solid var(--line-2); display: grid; place-items: center; font-family: var(--font-mono); font-size: .7rem; font-weight: 600; flex: 0 0 auto; color: var(--ink-2); }
.path-step.done .n { background: var(--ok); border-color: var(--ok); color: #fff; }
.path-step .t { flex: 1 1 auto; min-width: 0; }

/* ---------- Sheet (bottom sheet บนมือถือ / แผงขวาบนจอใหญ่) ---------- */
.sheet-backdrop { position: fixed; inset: 0; z-index: 90; background: rgba(12, 16, 22, .45); opacity: 0; transition: opacity .2s ease; }
.sheet-backdrop.open { opacity: 1; }
.sheet {
  position: fixed; z-index: 91; left: 0; right: 0; bottom: 0; max-height: 94vh; max-height: 94dvh; display: flex; flex-direction: column;
  background: var(--surface); border-radius: 12px 12px 0 0; box-shadow: var(--shadow-3); transform: translateY(102%); transition: transform .26s cubic-bezier(.2, .8, .2, 1);
}
.sheet.open { transform: none; }
.sheet.full { height: 94vh; height: 94dvh; }
@media (min-width: 900px) {
  .sheet { left: auto; top: 0; bottom: 0; right: 0; width: min(720px, 92vw); max-height: none; height: 100vh; border-radius: 0; border-left: 1px solid var(--line); transform: translateX(102%); }
  .sheet.sheet-sm { width: min(520px, 92vw); }
  .sheet.full { height: 100vh; height: 100dvh; }
  .sheet.sheet-center { top: 50%; bottom: auto; right: 50%; height: auto; max-height: 90vh; border-radius: 10px; transform: translate(50%, -46%) scale(.98); opacity: 0; transition: transform .22s, opacity .22s; }
  .sheet.sheet-center.open { transform: translate(50%, -50%); opacity: 1; }
}
.sheet-grip { width: 40px; height: 4px; border-radius: 99px; background: var(--line-2); margin: 8px auto 0; flex: 0 0 auto; }
@media (min-width: 900px) { .sheet-grip { display: none; } }
.sheet-head { display: flex; align-items: flex-start; gap: .7rem; padding: .75rem 1rem .8rem 1.15rem; border-bottom: 1px solid var(--line); flex: 0 0 auto; }
@media (min-width: 900px) { .sheet-head { padding: 1.15rem 1.1rem 1.05rem 1.6rem; } }
.sheet-head .sh-icon { display: none; }
.sheet-head .sh-kicker { display: block; font-size: .76rem; font-weight: 600; color: var(--mod-ink); margin-bottom: .1rem; }
.sheet-head h2 { font-size: 1.14rem; margin: 0; line-height: 1.4; }
.sheet-head .sh-sub { margin: .15rem 0 0; font-size: .84rem; color: var(--muted); }
.sheet-head .sh-actions { margin-left: auto; display: flex; gap: .15rem; flex: 0 0 auto; }
.sheet-body { overflow-y: auto; overscroll-behavior: contain; padding: 1rem 1.15rem 1.4rem; flex: 1 1 auto; -webkit-overflow-scrolling: touch; }
@media (min-width: 900px) { .sheet-body { padding: 1.3rem 1.6rem 2rem; } }
.sheet-foot { flex: 0 0 auto; padding: .7rem 1rem calc(.7rem + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: var(--surface); display: flex; gap: .5rem; }
@media (min-width: 900px) { .sheet-foot { padding: .9rem 1.6rem; } }
.sheet-foot .btn { flex: 1 1 auto; }
body.sheet-lock { overflow: hidden; }

/* ---------- Form fields ---------- */
.field { margin-bottom: 1.15rem; }
.field > label, .field > .flabel { display: flex; align-items: baseline; gap: .4rem; flex-wrap: wrap; font-weight: 600; font-size: .93rem; margin-bottom: .4rem; color: var(--ink); }
.field .req { color: var(--danger); font-weight: 600; }
.field .opt { color: var(--muted); font-weight: 400; font-size: .8rem; }
.field .hint { color: var(--muted); font-size: .82rem; margin-top: .3rem; }
.input, .textarea, .select {
  width: 100%; min-height: 46px; padding: .55rem .8rem; border-radius: 6px; border: 1px solid var(--line-2); background: var(--surface);
  font-size: 1rem; line-height: 1.55; outline: none; transition: border-color .15s, box-shadow .15s;
}
.input::placeholder, .textarea::placeholder { color: var(--muted); opacity: .8; }
.textarea { min-height: 104px; resize: vertical; }
.input:focus, .textarea:focus, .select:focus { border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 16%, transparent); }
.field.invalid .input, .field.invalid .textarea { border-color: var(--danger); }
.field.invalid > label, .field.invalid > .flabel { color: var(--danger); }
.field.invalid .err { display: block; }
.field .err { display: none; color: var(--danger); font-size: .82rem; font-weight: 600; margin-top: .3rem; }
.field-tools { display: flex; gap: .4rem; flex-wrap: wrap; margin-top: .35rem; }
.link-btn { border: 0; background: none; padding: .2rem .1rem; color: var(--brand-ink); font-weight: 600; font-size: .84rem; display: inline-flex; align-items: center; gap: .3rem; text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1px; }
.link-btn svg { width: 15px; height: 15px; }
.grade-picker { display: grid; gap: .4rem; }
.grade-row { display: grid; grid-template-columns: 4.4rem 1fr; align-items: center; gap: .5rem; }
.grade-row .gl { font-size: .78rem; font-weight: 600; color: var(--muted); }
.grade-row .chips { gap: .3rem; }
.grade-row .chip { min-height: 38px; padding: .3rem .65rem; min-width: 50px; justify-content: center; }
@media (max-width: 380px) { .grade-row { grid-template-columns: 1fr; gap: .2rem; } }
.area-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .4rem; }
@media (min-width: 640px) { .area-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.area-btn { display: flex; align-items: center; gap: .55rem; padding: .5rem .65rem; min-height: 48px; border-radius: 6px; border: 1px solid var(--line-2); background: var(--surface); text-align: left; font-size: .86rem; font-weight: 500; color: var(--ink-2); line-height: 1.35; }
.area-btn:hover { border-color: var(--ink-2); }
.area-btn .ai { display: none; }
.area-btn[aria-pressed="true"] { border-color: var(--brand); background: var(--brand-soft); color: var(--brand-ink); font-weight: 600; box-shadow: inset 0 0 0 1px var(--brand); }
.adv-toggle { width: 100%; display: flex; align-items: center; justify-content: space-between; gap: .5rem; border: 1px solid var(--line); background: var(--surface-2); border-radius: 6px; padding: .6rem .85rem; font-weight: 600; color: var(--ink-2); font-size: .9rem; margin-bottom: 1rem; }
.adv-toggle:hover { border-color: var(--line-2); color: var(--ink); }
.adv-toggle svg { width: 18px; height: 18px; transition: transform .2s; }
.adv-toggle[aria-expanded="true"] svg { transform: rotate(180deg); }

/* ---------- Callouts (แถบข้อความ ใช้เส้นสีด้านซ้ายแทนไอคอน) ---------- */
.callout { display: flex; gap: .65rem; align-items: flex-start; padding: .7rem .9rem; border-radius: 0 6px 6px 0; border: 0; border-left: 3px solid var(--line-2); background: var(--surface-2); font-size: .9rem; color: var(--ink-2); margin-bottom: 1rem; line-height: 1.65; }
.callout .ci { display: none; }
.callout b { color: var(--ink); }
.callout-info { background: var(--brand-soft); border-left-color: var(--brand); }
.callout-warn { background: var(--warn-soft); border-left-color: var(--gold); }
.callout-ok { background: var(--ok-soft); border-left-color: var(--ok); }
.callout-danger { background: var(--danger-soft); border-left-color: var(--danger); }
.callout-mod { background: var(--mod-soft); border-left-color: var(--mod); }
.callout a { font-weight: 600; }

/* ---------- Tool brief (สรุปเครื่องมือในหัวฟอร์ม) ---------- */
.tool-brief { margin: 0 0 1.2rem; padding: .2rem 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); display: grid; }
.tool-brief > div { display: grid; grid-template-columns: 6.2rem 1fr; gap: .8rem; padding: .5rem 0; font-size: .9rem; }
.tool-brief > div + div { border-top: 1px dashed var(--line); }
.tool-brief dt { color: var(--muted); font-weight: 500; }
.tool-brief dd { margin: 0; color: var(--ink); }
@media (max-width: 420px) { .tool-brief > div { grid-template-columns: 1fr; gap: 0; } }

/* ---------- Profile pill in builder ---------- */
.ppill { display: flex; align-items: center; gap: .55rem; flex-wrap: wrap; padding: .5rem .6rem .5rem .8rem; border-radius: 6px; background: var(--surface-2); border: 1px solid var(--line); margin-bottom: 1.15rem; font-size: .88rem; }
.ppill .pp-l { flex: 1 1 auto; min-width: 0; color: var(--ink-2); }
.ppill .pp-l b { color: var(--ink); }

/* ---------- Result / prompt box ---------- */
.result { margin-top: .6rem; padding-top: 1.2rem; border-top: 1px solid var(--line); animation: rise .25s ease; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.result-head { display: flex; align-items: center; gap: .55rem; margin-bottom: .5rem; }
.result-head .okdot { width: 24px; height: 24px; border-radius: 50%; background: var(--ok); color: #fff; display: grid; place-items: center; flex: 0 0 auto; }
.result-head .okdot svg { width: 15px; height: 15px; }
.result-head h3 { margin: 0; font-size: 1.04rem; }
.prompt-box { position: relative; border: 1px solid var(--line-2); border-radius: 6px; background: var(--surface-2); }
.prompt-box textarea { width: 100%; border: 0; background: transparent; resize: vertical; min-height: 160px; max-height: 46vh; padding: .85rem .95rem; font-family: var(--font-body); font-size: .9rem; line-height: 1.65; color: var(--ink); outline: none; border-radius: 6px; }
.prompt-box.collapsed textarea { max-height: 7.5rem; overflow: hidden; resize: none; -webkit-mask-image: linear-gradient(#000 55%, transparent); mask-image: linear-gradient(#000 55%, transparent); }
.prompt-box .pb-bar { display: flex; align-items: center; justify-content: space-between; gap: .5rem; padding: .3rem .45rem .3rem .95rem; border-top: 1px solid var(--line); font-size: .78rem; color: var(--muted); font-family: var(--font-mono); }
.prompt-box .pb-bar .btn { font-family: var(--font-body); }
.ai-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: .2rem .6rem; margin: 1rem 0 .5rem; font-size: .86rem; color: var(--muted); }
.ai-head b { color: var(--ink); font-size: .93rem; }
.ai-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .5rem; margin-top: .4rem; }
.ai-btn { position: relative; }
.ai-btn.is-rec { border-color: var(--ai); box-shadow: inset 0 0 0 1px var(--ai); }
.ai-btn.is-avoid { opacity: .55; }
.ai-btn .ai-tag { position: absolute; top: -9px; left: 50%; transform: translateX(-50%); background: var(--ai); color: #fff; font-size: .66rem; font-weight: 600; padding: 0 .45rem; border-radius: 4px; line-height: 1.6; white-space: nowrap; }
.ai-btn { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .15rem; min-height: 64px; border-radius: 6px; border: 1px solid var(--line-2); background: var(--surface); color: var(--ink); text-decoration: none; font-weight: 600; font-size: .92rem; padding: .45rem; text-align: center; transition: border-color .15s, box-shadow .15s; }
.ai-btn:hover { border-color: var(--ai, var(--brand)); box-shadow: inset 0 0 0 1px var(--ai, var(--brand)); }
.ai-btn .ai-logo { width: 22px; height: 22px; border-radius: 5px; display: grid; place-items: center; color: #fff; background: var(--ai); font-size: .74rem; font-family: var(--font-mono); font-weight: 600; }
.ai-btn small { font-weight: 400; color: var(--muted); font-size: .7rem; line-height: 1.3; }
.followups { display: flex; flex-wrap: wrap; gap: .4rem; }
.followups .chip { min-height: 36px; font-size: .84rem; }
.checklist { border: 1px solid var(--line); border-radius: 6px; padding: .8rem .95rem; background: var(--surface); }
.checklist h4 { font-size: .93rem; margin: 0 0 .45rem; display: flex; align-items: center; gap: .5rem; }
.check { display: flex; gap: .6rem; align-items: flex-start; padding: .35rem 0; font-size: .9rem; color: var(--ink-2); cursor: pointer; }
.check input { width: 20px; height: 20px; margin: .15rem 0 0; accent-color: var(--ok); flex: 0 0 auto; }
.check input:checked + span { color: var(--ink); text-decoration: line-through; text-decoration-color: color-mix(in srgb, var(--ok) 60%, transparent); }
.sub-h { font-family: var(--font-head); font-weight: 600; font-size: .93rem; margin: 1.4rem 0 .55rem; color: var(--ink); display: flex; align-items: center; gap: .45rem; }
.next-list { display: grid; border-top: 1px solid var(--line); }
.next-item { display: flex; align-items: center; gap: .6rem; padding: .65rem .2rem; border: 0; border-bottom: 1px solid var(--line); background: none; text-align: left; width: 100%; color: var(--ink); text-decoration: none; font-weight: 600; font-size: .9rem; }
.next-item:hover { color: var(--brand-ink); }
.next-item:hover svg { color: var(--brand-ink); }
.next-item .ni { display: none; }
.next-item .t { flex: 1 1 auto; min-width: 0; }
.next-item small { display: block; font-weight: 400; color: var(--muted); }

/* ---------- Toast ---------- */
.toast-wrap { position: fixed; left: 50%; bottom: calc(var(--bottomnav-h) + 14px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: .4rem; width: max-content; max-width: calc(100vw - 32px); pointer-events: none; }
@media (min-width: 1024px) { .toast-wrap { bottom: 24px; } }
.toast { background: #1d2228; color: #fff; padding: .65rem 1rem; border-radius: 6px; box-shadow: var(--shadow-2); font-weight: 500; font-size: .9rem; display: flex; align-items: center; gap: .5rem; animation: toastIn .22s ease; pointer-events: auto; }
.toast.ok { background: #1f5a3f; }
.toast.warn { background: #6e4a06; }
@keyframes toastIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------- Return banner (กลับมาจาก AI) ---------- */
.return-banner { position: fixed; z-index: 80; left: 12px; right: 12px; bottom: calc(var(--bottomnav-h) + 12px + env(safe-area-inset-bottom)); max-width: 540px; margin: 0 auto; background: var(--surface); border: 1px solid var(--line-2); border-top: 3px solid var(--brand); border-radius: 8px; box-shadow: var(--shadow-3); padding: .9rem 1rem; display: flex; gap: .75rem; align-items: flex-start; animation: rise .25s ease; }
@media (min-width: 1024px) { .return-banner { bottom: 24px; } }
.return-banner .rb-i { display: none; }
.return-banner h4 { margin: 0 0 .15rem; font-size: 1rem; }
.return-banner p { margin: 0 0 .55rem; font-size: .86rem; color: var(--ink-2); }

/* ---------- Footer ---------- */
.pk-footer { margin-top: 4rem; border-top: 1px solid var(--line); background: var(--surface); }
.pk-footer .wrap { padding-block: 2.2rem 1.4rem; display: grid; gap: 1.6rem; }
@media (min-width: 860px) { .pk-footer .wrap { grid-template-columns: 1.4fr 1fr 1fr; } }
.pk-footer h4 { font-size: .82rem; margin-bottom: .6rem; color: var(--muted); font-weight: 600; }
.pk-footer ul { list-style: none; margin: 0; padding: 0; display: grid; gap: .35rem; }
.pk-footer a { color: var(--ink-2); text-decoration: none; font-size: .88rem; }
.pk-footer a:hover { color: var(--brand-ink); text-decoration: underline; }
.pk-footer .fine { font-size: .82rem; color: var(--muted); max-width: 30rem; }
.pk-footer .orgs { background: #fff; border-radius: 6px; padding: .5rem .7rem; display: block; width: 100%; max-width: 340px; height: auto; border: 1px solid var(--line); }
.pk-footer .legal { grid-column: 1 / -1; border-top: 1px solid var(--line); padding-top: 1rem; display: flex; flex-wrap: wrap; justify-content: space-between; gap: .5rem 1.5rem; font-size: .78rem; color: var(--muted); }

/* ---------- Settings / misc lists ---------- */
.list { display: grid; gap: .5rem; }
.list-item { display: flex; gap: .75rem; align-items: flex-start; padding: .75rem .85rem; border-radius: 6px; border: 1px solid var(--line); background: var(--surface); }
button.list-item:hover, a.list-item:hover { border-color: var(--line-2); }
.list-item .li-i { width: 34px; height: 34px; border-radius: 6px; background: var(--surface-2); border: 1px solid var(--line); color: var(--ink-2); display: grid; place-items: center; flex: 0 0 auto; }
.list-item .li-i svg { width: 18px; height: 18px; }
.list-item .li-b { flex: 1 1 auto; min-width: 0; }
.list-item .li-t { font-weight: 600; font-size: .94rem; }
.list-item .li-s { font-size: .8rem; color: var(--muted); }
.list-item .li-p { font-size: .84rem; color: var(--ink-2); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; margin-top: .2rem; }
.seg { display: inline-flex; border: 1px solid var(--line-2); border-radius: 6px; overflow: hidden; }
.seg button { border: 0; background: var(--surface); padding: .5rem .95rem; font-weight: 500; min-height: 42px; }
.seg button + button { border-left: 1px solid var(--line-2); }
.seg button[aria-pressed="true"] { background: var(--brand); color: var(--on-brand); font-weight: 600; }
.tabs { display: flex; gap: .2rem; border-bottom: 1px solid var(--line); margin-bottom: 1rem; overflow-x: auto; scrollbar-width: none; }
.tabs button { border: 0; background: none; padding: .6rem .8rem; font-weight: 500; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs button[aria-selected="true"] { color: var(--ink); font-weight: 600; border-bottom-color: var(--brand); }
kbd { font-family: var(--font-mono); font-size: .8em; padding: .05em .4em; border-radius: 4px; border: 1px solid var(--line-2); background: var(--surface-2); }
mark { background: color-mix(in srgb, var(--gold) 28%, transparent); color: inherit; border-radius: 2px; padding: 0 .1em; }
.mask-tag { background: var(--ok-soft); color: var(--ok); border-radius: 3px; padding: 0 .25em; font-weight: 600; }
.diff-view { white-space: pre-wrap; word-break: break-word; padding: .8rem .95rem; border-radius: 6px; border: 1px solid var(--line); background: var(--surface-2); font-size: .92rem; line-height: 1.75; max-height: 40vh; overflow: auto; }

/* ---------- Sub navigation (แท็บเครื่องมือในโมดูลเดียวกัน) ---------- */
.subnav { display: flex; gap: 1.6rem; margin-top: 1.4rem; overflow-x: auto; scrollbar-width: none; }
.subnav::-webkit-scrollbar { display: none; }
.subnav a { display: inline-flex; align-items: center; gap: .4rem; white-space: nowrap; padding: .55rem 0 .7rem; border-bottom: 2px solid transparent; color: var(--ink-2); font-weight: 500; font-size: .92rem; text-decoration: none; }
.subnav a:hover { color: var(--ink); border-bottom-color: var(--line-2); }
.subnav a[aria-current="page"] { color: var(--ink); font-weight: 600; border-bottom-color: var(--mod); }
.subnav a svg { width: 16px; height: 16px; color: var(--muted); }

/* ---------- Media thumbnails ---------- */
.tool-card .tc-thumb { position: relative; margin: -1rem -1.05rem .45rem; aspect-ratio: 16 / 10; border-radius: calc(var(--radius) - 1px) calc(var(--radius) - 1px) 0 0; overflow: hidden; background: var(--surface-2); border-bottom: 1px solid var(--line); }
.tool-card .tc-thumb img { width: 100%; height: 100%; object-fit: cover; transition: transform .35s ease; }
.tool-card:hover .tc-thumb img { transform: scale(1.03); }
.tool-card .tc-thumb-ic { display: none; }
.tool-card .tc-thumb + .tc-top .tc-title { padding-right: 0; }
.tool-card:has(.tc-thumb) .fav { top: .55rem; right: .55rem; background: color-mix(in srgb, var(--surface) 92%, transparent); color: var(--muted); }
.quickscan { margin-top: .2rem; }

/* ---------- Gallery (ตัวอย่างใบงาน) ---------- */
.gal-grid { display: grid; gap: .6rem; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 640px) { .gal-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.gal-card { text-align: left; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); padding: .8rem .9rem; display: grid; gap: .25rem; color: var(--ink); justify-items: start; }
.gal-card:hover { border-color: var(--line-2); box-shadow: var(--shadow-2); }
.gal-card b { font-family: var(--font-head); font-weight: 600; }
.gal-card span { font-size: .85rem; color: var(--ink-2); }
.sample-pre { white-space: pre-wrap; font-family: var(--font-body); font-size: .92rem; line-height: 1.8; background: var(--surface-2); border: 1px solid var(--line); border-radius: 6px; padding: 1rem 1.1rem; margin: 0 0 1rem; }

/* ---------- Home ---------- */
.notice { background: var(--surface-2); border-bottom: 1px solid var(--line); font-size: .84rem; color: var(--ink-2); }
.notice .wrap { display: flex; flex-wrap: wrap; align-items: center; gap: .3rem .7rem; padding-block: .55rem; }
.notice .tag { font-size: .72rem; font-weight: 600; color: var(--brand-ink); border: 1px solid color-mix(in srgb, var(--brand) 40%, transparent); border-radius: 4px; padding: 0 .4rem; }
.notice a { font-weight: 600; }
.home-hero { background: var(--surface); border-bottom: 1px solid var(--line); }
.home-hero .wrap.hero-grid { padding-block: 2rem 2rem; }
@media (min-width: 900px) { .home-hero .wrap.hero-grid { padding-block: 3.4rem 2.6rem; } }
.hero-grid { display: grid; gap: 2rem; align-items: start; }
.hero-grid > * { min-width: 0; }
@media (min-width: 1024px) { .hero-grid { grid-template-columns: minmax(0, 1.45fr) minmax(0, 1fr); gap: 3.5rem; } }
.overline { font-size: .84rem; font-weight: 600; color: var(--brand-ink); margin: 0 0 .8rem; display: flex; align-items: center; gap: .6rem; }
.overline::before { content: ''; width: 22px; height: 2px; background: var(--brand); }
.br-lg { display: none; }
@media (min-width: 700px) { .br-lg { display: inline; } }
.home-hero h1 { max-width: 18em; margin-bottom: .7rem; font-size: clamp(1.75rem, 1.2rem + 2.4vw, 2.7rem); }
.home-hero .lead { color: var(--ink-2); font-size: 1.04rem; max-width: 38rem; margin-bottom: 1.6rem; }
.home-search { max-width: 680px; position: relative; }
.search-label { display: block; font-weight: 600; font-size: .92rem; margin-bottom: .45rem; color: var(--ink); }
.home-search .search input { min-height: 54px; font-size: 1.04rem; padding-left: 2.8rem; border-color: var(--ink-2); }
.home-search .search input:focus { border-color: var(--brand); }
.home-search .search > svg { left: 15px; width: 20px; height: 20px; }
.quick-chips, .popular { display: flex; flex-wrap: wrap; align-items: baseline; gap: .35rem .9rem; margin-top: .9rem; font-size: .88rem; }
.popular .popular-l { color: var(--muted); font-weight: 500; }
.quick-chips a, .popular a { color: var(--brand-ink); text-decoration: underline; text-decoration-color: color-mix(in srgb, var(--brand) 35%, transparent); text-underline-offset: 4px; font-weight: 500; }
.quick-chips a:hover, .popular a:hover { text-decoration-color: currentColor; }
.search-results { margin-top: .6rem; display: grid; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); overflow: hidden; }
.search-results:empty { display: none; }
.sr-item { display: flex; gap: .8rem; align-items: flex-start; padding: .7rem .9rem; background: var(--surface); color: var(--ink); text-decoration: none; border-bottom: 1px solid var(--line); }
.sr-item:last-child { border-bottom: 0; }
a.sr-item:hover { background: var(--surface-2); }
a.sr-item:hover .st { color: var(--brand-ink); }
.sr-item .si { display: none; }
.sr-item .st { font-weight: 600; }
.sr-item .sp { font-size: .85rem; color: var(--ink-2); }
.sr-item .badge { margin-left: auto; flex: 0 0 auto; margin-top: .2rem; }
.sr-more { margin: 0; padding: .55rem .9rem; font-size: .84rem; color: var(--muted); background: var(--surface-2); }
.hero-panel { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface-2); padding: 1.3rem 1.4rem 1.2rem; }
.panel-title { font-size: .84rem; font-weight: 600; color: var(--muted); margin: 0 0 .6rem; }
.how-list { list-style: none; margin: 0; padding: 0; display: grid; }
.how-list li { display: grid; grid-template-columns: 28px 1fr; gap: .8rem; padding: .75rem 0; border-top: 1px solid var(--line); }
.how-list li:first-child { border-top: 0; padding-top: .2rem; }
.how-list .n { width: 28px; height: 28px; border-radius: 50%; background: var(--brand); color: var(--on-brand); display: grid; place-items: center; font-family: var(--font-mono); font-size: .8rem; font-weight: 600; }
.how-list b { display: block; font-weight: 600; line-height: 1.5; }
.how-list p { margin: .1rem 0 0; font-size: .87rem; color: var(--ink-2); line-height: 1.6; }
.video-link { display: flex; align-items: center; gap: .85rem; margin-top: .9rem; padding: .6rem; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); text-decoration: none; color: var(--ink); }
.video-link:hover { border-color: var(--line-2); }
.video-link:hover b { color: var(--brand-ink); }
.video-link .vthumb { position: relative; width: 96px; flex: 0 0 auto; aspect-ratio: 16 / 9; border-radius: 4px; overflow: hidden; background: var(--brand-deep); }
.video-link .vthumb img { width: 100%; height: 100%; object-fit: cover; }
.video-link .vthumb::after { content: ''; position: absolute; left: 50%; top: 50%; transform: translate(-40%, -50%); border-style: solid; border-width: 7px 0 7px 11px; border-color: transparent transparent transparent #fff; filter: drop-shadow(0 1px 2px rgba(0, 0, 0, .5)); }
.video-link .vt { flex: 1 1 auto; min-width: 0; line-height: 1.4; }
.video-link small { display: block; color: var(--muted); font-size: .8rem; }
.video-link > svg { width: 18px; height: 18px; color: var(--muted); }
.facts { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); border-top: 1px solid var(--line); }
@media (min-width: 900px) { .facts { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.facts li { padding: 1rem 1rem 1.1rem 0; display: grid; gap: .1rem; }
@media (min-width: 900px) { .facts li + li { border-left: 1px solid var(--line); padding-left: 1.4rem; } }
@media (max-width: 899px) { .facts li:nth-child(even) { border-left: 1px solid var(--line); padding-left: 1rem; } .facts li:nth-child(n+3) { border-top: 1px solid var(--line); } }
.facts b { font-family: var(--font-head); font-size: 1.35rem; font-weight: 600; line-height: 1.3; }
.facts span { font-size: .84rem; color: var(--muted); line-height: 1.5; }
.home-section { margin-top: 3rem; }
.home-section > h2 { display: flex; align-items: center; gap: .5rem; }
.home-section > p.sub { color: var(--muted); margin-top: -.2rem; }
.sec-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: .4rem 1.5rem; margin-bottom: 1.1rem; padding-bottom: .7rem; border-bottom: 1px solid var(--line); }
.sec-head h2 { margin: 0; }
.sec-head p { margin: .15rem 0 0; color: var(--muted); font-size: .9rem; max-width: 44rem; }
.sec-head .sec-link { font-size: .88rem; font-weight: 600; text-decoration: none; display: inline-flex; align-items: center; gap: .3rem; }
.sec-head .sec-link:hover { text-decoration: underline; }
.mod-grid { display: grid; gap: .9rem; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 760px) { .mod-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.mod-card { position: relative; display: flex; flex-direction: column; gap: .4rem; padding: 1.2rem 1.3rem 1rem; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); box-shadow: inset 0 3px 0 var(--mod); }
.mod-card .mc-head { display: block; }
.mod-card .mc-num { display: none; }
.mod-card .mod-no { font-size: .8rem; margin-bottom: .35rem; }
.mod-card h3 { margin: 0; font-size: 1.14rem; }
.mod-card .mc-course { font-size: .8rem; color: var(--muted); margin: .15rem 0 0; }
.mod-card .mc-blurb { color: var(--ink-2); font-size: .91rem; margin: .4rem 0 .5rem; }
.mod-card .mc-tools { display: grid; margin-top: auto; border-top: 1px solid var(--line); list-style: none; padding: 0; }
.mod-card .mc-tool { display: flex; align-items: center; gap: .8rem; padding: .7rem 0; border-bottom: 1px solid var(--line); color: var(--ink); text-decoration: none; font-weight: 600; font-size: .95rem; }
.mod-card .mc-tools > :last-child .mc-tool, .mod-card .mc-tools > .mc-tool:last-child { border-bottom: 0; }
.mod-card .mc-tool:hover { color: var(--mod-ink); }
.mod-card .mc-tool:hover svg { color: var(--mod-ink); transform: translateX(2px); }
.mod-card .mc-tool .ti { display: none; }
.mod-card .mc-tool .tt { flex: 1 1 auto; min-width: 0; line-height: 1.45; }
.mod-card .mc-tool small { display: block; font-weight: 400; color: var(--muted); font-size: .82rem; }
.mod-card .mc-count { font-size: .8rem; font-weight: 500; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.mod-card .mc-tool svg { width: 18px; height: 18px; color: var(--muted); flex: 0 0 auto; transition: transform .15s; }
.how-grid { display: grid; gap: .75rem; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 760px) { .how-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.how-card { padding: 1rem 1.1rem; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); }
.how-card .hn { width: 28px; height: 28px; border-radius: 50%; background: var(--brand); color: var(--on-brand); display: grid; place-items: center; font-family: var(--font-mono); font-size: .8rem; font-weight: 600; margin-bottom: .6rem; }
.how-card h3 { margin-bottom: .25rem; font-size: 1rem; }
.how-card p { margin: 0; color: var(--ink-2); font-size: .9rem; }
.pop-grid { display: grid; gap: .75rem; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 640px) { .pop-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 1020px) { .pop-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .9rem; } }
.principles { display: grid; gap: 0; grid-template-columns: minmax(0, 1fr); border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
@media (min-width: 860px) { .principles { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.principles > div { padding: 1.2rem 1.3rem; display: grid; grid-template-columns: 36px 1fr; gap: .2rem .9rem; align-content: start; }
.principles > div + div { border-top: 1px solid var(--line); }
@media (min-width: 860px) { .principles > div + div { border-top: 0; border-left: 1px solid var(--line); } }
.principles .pi { grid-row: span 2; width: 36px; height: 36px; border-radius: 6px; background: var(--brand-soft); color: var(--brand-ink); display: grid; place-items: center; }
.principles .pi svg { width: 19px; height: 19px; }
.principles h3 { margin: 0; font-size: .98rem; }
.principles p { margin: 0; font-size: .87rem; color: var(--ink-2); }
.video-cta { display: flex; flex-wrap: wrap; align-items: center; gap: 1rem; justify-content: space-between; padding: 1rem 1.2rem; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); margin-top: 1rem; }
.video-cta h3 { margin: 0; }
.video-cta p { margin: .1rem 0 0; color: var(--ink-2); font-size: .9rem; }

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

/* ---------- Print ---------- */
@media print {
  .pk-topbar, .pk-header, .pk-bottomnav, .pk-footer, .lib-toolbar, .sheet-backdrop, .toast-wrap { display: none !important; }
  body { background: #fff; padding: 0; }
}
