/* ==========================================================================
   work — design tokens
   Palette structure from ui-ux-pro-max (Analytics Dashboard: blue data neutrals).
   Amber accent from that entry is deliberately NOT used — project rule: no yellow.
   ========================================================================== */

@font-face {
  font-family: "K2D";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("../fonts/k2d-400-thai.woff2") format("woff2");
  unicode-range: U+0E01-0E3A, U+0E3F-0E5B;
}
@font-face {
  font-family: "K2D";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("../fonts/k2d-500-thai.woff2") format("woff2");
  unicode-range: U+0E01-0E3A, U+0E3F-0E5B;
}
@font-face {
  font-family: "K2D";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("../fonts/k2d-700-thai.woff2") format("woff2");
  unicode-range: U+0E01-0E3A, U+0E3F-0E5B;
}
@font-face {
  font-family: "K2D";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("../fonts/k2d-400-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+2000-206F;
}
@font-face {
  font-family: "K2D";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("../fonts/k2d-500-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+2000-206F;
}
@font-face {
  font-family: "K2D";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("../fonts/k2d-700-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+2000-206F;
}

:root {
  color-scheme: light;

  /* colour roles */
  --background: #f4f7fc;
  --surface: #ffffff;
  --surface-sunken: #eef2f9;
  --foreground: #0f172a;
  --muted-foreground: #4a5568;
  --border: #dbe4f0;
  --border-strong: #b9c9de;
  --primary: #1e40af;
  --primary-hover: #1a3690;
  --on-primary: #ffffff;
  --primary-soft: #e8eefb;
  --primary-ink: #1b3a94;
  --accent-line: #2563eb;
  --success: #15803d;
  --success-soft: #e7f6ec;
  --danger: #b91c1c;
  --danger-soft: #fdeaea;
  --ring: #2563eb;

  /* type */
  --font-sans: "K2D", "Segoe UI", system-ui, -apple-system, "Noto Sans Thai", sans-serif;
  --font-mono: "JetBrains Mono", "Cascadia Mono", Consolas, "SFMono-Regular", ui-monospace, monospace;
  --text-xs: 0.75rem;
  --text-sm: 0.875rem;
  --text-base: 1rem;
  --text-lg: 1.125rem;
  --text-xl: 1.375rem;
  --text-2xl: 1.75rem;
  --text-hero: clamp(1.9rem, 4.4vw, 3rem);

  /* space + shape */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-pill: 999px;
  --shadow-card: 0 1px 2px rgba(15, 23, 42, 0.04), 0 8px 24px -18px rgba(15, 23, 42, 0.35);
  --shadow-pop: 0 12px 40px -12px rgba(15, 23, 42, 0.28);
  --transition: 180ms cubic-bezier(0.4, 0, 0.2, 1);
  --topbar-h: 62px;
  --page-max: 1180px;
}

[data-theme="dark"] {
  color-scheme: dark;
  --background: #0a1020;
  --surface: #111a2e;
  --surface-sunken: #0e1626;
  --foreground: #f1f5fb;
  --muted-foreground: #9fb0c9;
  --border: #22304a;
  --border-strong: #33456a;
  --primary: #7ea6ff;
  --primary-hover: #9ab8ff;
  --on-primary: #0a1020;
  --primary-soft: #16233c;
  --primary-ink: #b9cdff;
  --accent-line: #7ea6ff;
  --success: #6ee7a8;
  --success-soft: #10281c;
  --danger: #fca5a5;
  --danger-soft: #2a1414;
  --ring: #9ab8ff;
  --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.4), 0 10px 30px -20px rgba(0, 0, 0, 0.8);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--background);
  color: var(--foreground);
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3,
h4 {
  margin: 0;
  line-height: 1.25;
  font-weight: 700;
  letter-spacing: -0.01em;
}

p {
  margin: 0;
}

a {
  color: var(--primary-ink);
  text-decoration: none;
}

button {
  font: inherit;
  color: inherit;
}

:focus-visible {
  outline: 2px solid var(--ring);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

.skip-link {
  position: absolute;
  left: 12px;
  top: -60px;
  z-index: 100;
  background: var(--surface);
  color: var(--foreground);
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  transition: top var(--transition);
}
.skip-link:focus {
  top: 12px;
}

.wrap {
  width: 100%;
  max-width: var(--page-max);
  margin: 0 auto;
  padding-inline: var(--space-5);
}

/* ── topbar ────────────────────────────────────────────────────────────── */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: color-mix(in srgb, var(--background) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.topbar__inner {
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: var(--space-4);
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--foreground);
  font-weight: 700;
  font-size: var(--text-lg);
  letter-spacing: -0.02em;
}
.brand__mark {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: var(--primary);
  color: var(--on-primary);
  display: grid;
  place-items: center;
  flex: none;
}
.brand__mark svg {
  width: 17px;
  height: 17px;
}
.brand small {
  display: block;
  font-size: 11px;
  font-weight: 500;
  color: var(--muted-foreground);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  line-height: 1;
}

.nav {
  display: flex;
  align-items: center;
  gap: 2px;
  margin-inline-start: auto;
}
.nav a {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--muted-foreground);
  padding: 9px 13px;
  border-radius: var(--radius-pill);
  font-size: var(--text-sm);
  font-weight: 500;
  min-height: 40px;
  transition: background var(--transition), color var(--transition);
}
.nav a:hover {
  color: var(--foreground);
  background: var(--surface-sunken);
}
.nav a[aria-current="page"] {
  background: var(--primary-soft);
  color: var(--primary-ink);
}
.nav a svg {
  width: 16px;
  height: 16px;
}

.icon-btn {
  width: 40px;
  height: 40px;
  flex: none;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted-foreground);
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: color var(--transition), border-color var(--transition), background var(--transition);
}
.icon-btn:hover {
  color: var(--foreground);
  border-color: var(--border-strong);
}
.icon-btn svg {
  width: 18px;
  height: 18px;
}

/* ── buttons ───────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 18px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-size: var(--text-sm);
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  transition: background var(--transition), color var(--transition), border-color var(--transition),
    transform var(--transition);
}
.btn svg {
  width: 16px;
  height: 16px;
  flex: none;
}
.btn--primary {
  background: var(--primary);
  color: var(--on-primary);
}
.btn--primary:hover {
  background: var(--primary-hover);
}
.btn--ghost {
  background: var(--surface);
  border-color: var(--border-strong);
  color: var(--foreground);
}
.btn--ghost:hover {
  background: var(--surface-sunken);
}
.btn--quiet {
  background: transparent;
  color: var(--muted-foreground);
  border-color: transparent;
  padding-inline: 10px;
}
.btn--quiet:hover {
  color: var(--foreground);
  background: var(--surface-sunken);
}
.btn--danger {
  background: var(--danger-soft);
  color: var(--danger);
  border-color: transparent;
}
.btn--danger:hover {
  background: var(--danger);
  color: #fff;
}
.btn--sm {
  min-height: 36px;
  padding-inline: 12px;
  font-size: var(--text-xs);
}
.btn[disabled] {
  opacity: 0.5;
  cursor: not-allowed;
}
.btn:active {
  transform: translateY(1px);
}

/* ── hero ──────────────────────────────────────────────────────────────── */
.hero {
  padding-block: var(--space-7) var(--space-5);
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.85fr);
  gap: var(--space-5);
  align-items: stretch;
}
.hero__copy {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: clamp(20px, 3.4vw, 40px);
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}
.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  align-self: flex-start;
  background: var(--primary-soft);
  color: var(--primary-ink);
  border-radius: var(--radius-pill);
  padding: 5px 12px;
  font-size: var(--text-xs);
  font-weight: 500;
  letter-spacing: 0.02em;
}
.eyebrow i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent-line);
}
.hero h1 {
  font-size: var(--text-hero);
  letter-spacing: -0.03em;
}
.hero h1 span {
  color: var(--primary);
  white-space: nowrap;
}
.hero__lede {
  color: var(--muted-foreground);
  max-width: 46ch;
  font-size: var(--text-lg);
}
.hero__actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  margin-top: auto;
  padding-top: var(--space-3);
}

.hero__stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-template-rows: repeat(2, minmax(0, 1fr));
  gap: var(--space-4);
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-4) var(--space-5);
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
}
.stat-card__label {
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted-foreground);
}
.stat-card__value {
  font-family: var(--font-mono);
  font-size: clamp(1.5rem, 3vw, 2rem);
  font-weight: 500;
  letter-spacing: -0.02em;
}
.stat-card__hint {
  font-size: var(--text-sm);
  color: var(--muted-foreground);
}
.stat-card--ink {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--on-primary);
}
.stat-card--ink .stat-card__label,
.stat-card--ink .stat-card__hint {
  color: color-mix(in srgb, var(--on-primary) 78%, transparent);
}

/* ── bento ─────────────────────────────────────────────────────────────── */
.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-4);
  margin-block: var(--space-5) var(--space-3);
}
.section-head h2 {
  font-size: var(--text-xl);
}
.section-head p {
  color: var(--muted-foreground);
  font-size: var(--text-sm);
}

.bento {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: var(--space-4);
  padding-bottom: var(--space-7);
}
.tool-card {
  grid-column: span 3;
  position: relative;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding: var(--space-5);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  color: inherit;
  transition: border-color var(--transition), transform var(--transition), box-shadow var(--transition);
}
.tool-card:hover {
  border-color: var(--border-strong);
  transform: translateY(-2px);
  box-shadow: var(--shadow-pop);
}
.tool-card__head {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
}
.tool-card__icon {
  width: 42px;
  height: 42px;
  flex: none;
  border-radius: var(--radius-md);
  background: var(--primary-soft);
  color: var(--primary);
  display: grid;
  place-items: center;
}
.tool-card__icon svg {
  width: 21px;
  height: 21px;
}
.tool-card h3 {
  font-size: var(--text-lg);
}
.tool-card__kicker {
  font-size: var(--text-xs);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted-foreground);
}
.tool-card p {
  color: var(--muted-foreground);
  font-size: var(--text-sm);
}
.tool-card__preview {
  margin-top: auto;
  border: 1px solid var(--border);
  background: var(--surface-sunken);
  border-radius: var(--radius-md);
  padding: var(--space-3);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  line-height: 1.9;
  color: var(--foreground);
  overflow-x: auto;
}
.tool-card__preview .row {
  display: flex;
  justify-content: space-between;
  gap: var(--space-3);
  white-space: nowrap;
}
.tool-card__preview .dim {
  color: var(--muted-foreground);
}
.tool-card__go {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--primary-ink);
}
.tool-card__go svg {
  width: 15px;
  height: 15px;
  transition: transform var(--transition);
}
.tool-card:hover .tool-card__go svg {
  transform: translateX(3px);
}

.info-card {
  grid-column: span 2;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-4) var(--space-5);
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.info-card h3 {
  font-size: var(--text-sm);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted-foreground);
  font-weight: 500;
}
.info-card ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: var(--text-sm);
}
.info-card li {
  display: flex;
  justify-content: space-between;
  gap: var(--space-3);
  align-items: baseline;
  border-bottom: 1px dashed var(--border);
  padding-bottom: 7px;
}
.info-card li:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}
.info-card li span {
  color: var(--muted-foreground);
}
.info-card .empty {
  color: var(--muted-foreground);
  font-size: var(--text-sm);
}
.bar-list {
  display: flex;
  flex-direction: column;
  gap: 9px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.bar-list li {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 44px;
  gap: 8px;
  align-items: center;
  border: 0;
  padding: 0;
}
.bar-list__track {
  display: block;
  grid-column: 1 / -1;
  height: 6px;
  border-radius: 3px;
  background: var(--surface-sunken);
  overflow: hidden;
}
.bar-list__fill {
  display: block;
  height: 100%;
  border-radius: 3px;
  background: var(--accent-line);
}
.bar-list__label {
  color: var(--foreground) !important;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.bar-list__num {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  text-align: right;
  color: var(--muted-foreground) !important;
}

/* ── tool view shell ──────────────────────────────────────────────────── */
.view {
  padding-block: var(--space-5) var(--space-7);
}
.view__head {
  display: flex;
  align-items: flex-start;
  gap: var(--space-4);
  flex-wrap: wrap;
  margin-bottom: var(--space-5);
}
.view__head .back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: var(--text-sm);
  color: var(--muted-foreground);
  min-height: 32px;
  margin-bottom: 6px;
}
.view__head .back:hover {
  color: var(--foreground);
}
.view__head h1 {
  font-size: var(--text-2xl);
}
.view__head p {
  color: var(--muted-foreground);
  font-size: var(--text-sm);
  max-width: 62ch;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: var(--space-5);
}
.panel--flush {
  padding: 0;
  overflow: hidden;
}
.panel__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  flex-wrap: wrap;
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--border);
}
.panel__head h2 {
  font-size: var(--text-base);
  display: flex;
  align-items: center;
  gap: 8px;
}
.panel__head h2 svg {
  width: 17px;
  height: 17px;
  color: var(--primary);
}
.panel__body {
  padding: var(--space-5);
}

/* ── forms ─────────────────────────────────────────────────────────────── */
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.field__label {
  font-size: var(--text-sm);
  font-weight: 500;
}
.field__hint {
  font-size: var(--text-xs);
  color: var(--muted-foreground);
}
.field__error {
  font-size: var(--text-xs);
  color: var(--danger);
  min-height: 0;
}
.input,
.select,
.textarea {
  width: 100%;
  min-height: 44px;
  padding: 9px 12px;
  background: var(--surface);
  color: var(--foreground);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  transition: border-color var(--transition), box-shadow var(--transition);
}
.input::placeholder,
.textarea::placeholder {
  color: var(--muted-foreground);
  font-family: var(--font-sans);
}
.input:focus,
.select:focus,
.textarea:focus {
  outline: none;
  border-color: var(--ring);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--ring) 22%, transparent);
}
.input[aria-invalid="true"] {
  border-color: var(--danger);
}
.textarea {
  min-height: 132px;
  resize: vertical;
  line-height: 1.7;
}
.select {
  font-family: var(--font-sans);
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%234a5568' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 34px;
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-4);
}
.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--space-4);
}

/* ── result block ─────────────────────────────────────────────────────── */
.result {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-sunken);
  overflow: hidden;
}
.result__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: 10px var(--space-4);
  border-bottom: 1px solid var(--border);
}
.result__row:last-child {
  border-bottom: 0;
}
.result__key {
  font-size: var(--text-xs);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted-foreground);
  white-space: nowrap;
}
.result__val {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  font-weight: 500;
  text-align: right;
  word-break: break-all;
}
.copy-btn {
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted-foreground);
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  display: inline-grid;
  place-items: center;
  cursor: pointer;
  flex: none;
  transition: color var(--transition), background var(--transition);
}
.copy-btn:hover {
  color: var(--primary);
  background: var(--primary-soft);
}
.copy-btn svg {
  width: 15px;
  height: 15px;
}
.result__val-group {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.notice {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  border: 1px solid var(--border);
  background: var(--surface-sunken);
  color: var(--muted-foreground);
}
.notice svg {
  width: 16px;
  height: 16px;
  flex: none;
  margin-top: 2px;
}
.notice--warn {
  border-color: color-mix(in srgb, var(--primary) 30%, var(--border));
  background: var(--primary-soft);
  color: var(--primary-ink);
}
.notice--danger {
  border-color: color-mix(in srgb, var(--danger) 34%, var(--border));
  background: var(--danger-soft);
  color: var(--danger);
}

/* segmented control */
.segmented {
  display: inline-flex;
  padding: 3px;
  gap: 2px;
  background: var(--surface-sunken);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
}
.segmented button {
  border: 0;
  background: transparent;
  color: var(--muted-foreground);
  font-size: var(--text-sm);
  font-weight: 500;
  padding: 7px 14px;
  border-radius: var(--radius-pill);
  cursor: pointer;
  min-height: 34px;
  transition: background var(--transition), color var(--transition);
}
.segmented button[aria-pressed="true"] {
  background: var(--surface);
  color: var(--primary-ink);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.12);
}

/* ── tables ────────────────────────────────────────────────────────────── */
.table-wrap {
  width: 100%;
  overflow-x: auto;
}
table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
}
table.data th,
table.data td {
  text-align: left;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
table.data th {
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted-foreground);
  font-weight: 500;
  background: var(--surface-sunken);
  white-space: nowrap;
}
table.data tbody tr:hover {
  background: var(--surface-sunken);
}
table.data td.mono,
.num {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  white-space: nowrap;
}
table.data tbody tr:last-child td {
  border-bottom: 0;
}
.col-actions {
  width: 1%;
  white-space: nowrap;
  text-align: right;
}

/* ── phonebook ─────────────────────────────────────────────────────────── */
.pb-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  align-items: center;
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--border);
}
.search {
  position: relative;
  flex: 1 1 260px;
  min-width: 200px;
}
.search svg {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--muted-foreground);
  pointer-events: none;
}
.search .input {
  padding-left: 38px;
  font-family: var(--font-sans);
}
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.chip {
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--muted-foreground);
  border-radius: var(--radius-pill);
  padding: 6px 12px;
  font-size: var(--text-xs);
  font-weight: 500;
  cursor: pointer;
  min-height: 34px;
  transition: all var(--transition);
}
.chip:hover {
  color: var(--foreground);
  border-color: var(--primary);
}
.chip[aria-pressed="true"] {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--on-primary);
}

.contact-cell {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.avatar {
  width: 34px;
  height: 34px;
  flex: none;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: var(--text-sm);
  font-weight: 700;
  background: var(--primary-soft);
  color: var(--primary-ink);
}
.contact-name {
  font-weight: 500;
  white-space: nowrap;
}
.contact-sub {
  font-size: var(--text-xs);
  color: var(--muted-foreground);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.row-actions {
  display: inline-flex;
  gap: 2px;
  justify-content: flex-end;
}

/* ── camera (กล้องแยกโฟลเดอร์) ─────────────────────────────────────────── */
.cam-folders {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: var(--space-3);
  padding: var(--space-4) var(--space-5) var(--space-5);
}
.cam-folder {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  transition: border-color var(--transition), box-shadow var(--transition);
}
.cam-folder:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-card);
}
.cam-folder__icon {
  width: 38px;
  height: 38px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: var(--radius-sm);
  background: var(--primary-soft);
  color: var(--primary);
}
.cam-folder__icon svg {
  width: 20px;
  height: 20px;
}
.cam-folder__open {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 6px 0;
  border: 0;
  background: none;
  text-align: left;
  cursor: pointer;
}
.cam-folder__name {
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cam-folder__meta {
  font-size: var(--text-xs);
  color: var(--muted-foreground);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cam-folder__actions {
  display: inline-flex;
  gap: 2px;
  flex: none;
}
.cam-folder__actions .icon-btn {
  width: 36px;
  height: 36px;
}

.cam-body {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.9fr);
  gap: var(--space-5);
  align-items: start;
}
.cam-capture {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}
.cam-stage {
  position: relative;
  display: grid;
  place-items: center;
  aspect-ratio: 4 / 3;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: #0b1222;
  overflow: hidden;
}
.cam-stage video {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}
.cam-stage--mirror video {
  transform: scaleX(-1);
}
.cam-stage__grid {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.cam-stage__grid i {
  position: absolute;
  background: color-mix(in srgb, #ffffff 26%, transparent);
}
.cam-stage__grid i:nth-child(1) {
  left: 33.333%;
  top: 0;
  bottom: 0;
  width: 1px;
}
.cam-stage__grid i:nth-child(2) {
  left: 66.666%;
  top: 0;
  bottom: 0;
  width: 1px;
}
.cam-stage__grid i:nth-child(3) {
  top: 33.333%;
  left: 0;
  right: 0;
  height: 1px;
}
.cam-stage__grid i:nth-child(4) {
  top: 66.666%;
  left: 0;
  right: 0;
  height: 1px;
}
.cam-stage__hint {
  position: absolute;
  inset: auto var(--space-4) var(--space-4);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, #0b1222 88%, transparent);
  color: #f1f5fb;
  font-size: var(--text-xs);
  line-height: 1.5;
  text-align: center;
}
.cam-stage--shoot::after {
  content: "";
  position: absolute;
  inset: 0;
  background: #ffffff;
  animation: cam-shoot 160ms ease-out;
}
@keyframes cam-shoot {
  from {
    opacity: 0.7;
  }
  to {
    opacity: 0;
  }
}
.cam-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-4);
}
.cam-shutter {
  width: 62px;
  height: 62px;
  flex: none;
  border-radius: 50%;
  border: 3px solid var(--primary-soft);
  background: var(--primary);
  cursor: pointer;
  transition: transform var(--transition), background var(--transition);
}
.cam-shutter:hover {
  background: var(--primary-hover);
}
.cam-shutter:active {
  transform: scale(0.94);
}
.cam-shutter[disabled] {
  background: var(--border-strong);
  border-color: var(--border);
  cursor: not-allowed;
}
.cam-gallery {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}
.cam-gallery__title {
  font-size: var(--text-sm);
  font-weight: 500;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--muted-foreground);
}
.cam-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(92px, 1fr));
  gap: 8px;
}
.cam-thumb {
  aspect-ratio: 1;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--surface-sunken);
  cursor: pointer;
}
.cam-thumb img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}
.cam-thumb:hover {
  border-color: var(--primary);
}

/* ── travel schedule (ตารางเดินทาง) ────────────────────────────────────── */
.trip-next {
  margin-bottom: var(--space-4);
}
.trip-next__label {
  font-size: var(--text-xs);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted-foreground);
  margin-bottom: 6px;
}
.trip-next__body {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3) var(--space-4);
  padding: var(--space-3) var(--space-4);
  border: 1px solid color-mix(in srgb, var(--primary) 26%, var(--border));
  border-radius: var(--radius-md);
  background: var(--primary-soft);
}
.trip-next__when {
  font-weight: 500;
  color: var(--primary-ink);
}
.trip-next__route {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  font-size: var(--text-sm);
  color: var(--primary-ink);
}
.trip-next__contact {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
  padding: 5px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  background: var(--surface);
  font-size: var(--text-sm);
}
.trip-next__contact svg {
  width: 15px;
  height: 15px;
}
.trip-route {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px;
  line-height: 1.45;
}
.trip-route__leg--end {
  font-weight: 500;
}
.trip-route__arrow {
  color: var(--muted-foreground);
  font-size: var(--text-sm);
}
.trip-note {
  margin-top: 2px;
}
.trip-when {
  display: block;
  font-weight: 500;
}
.trip-check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 32px;
  font-size: var(--text-sm);
  cursor: pointer;
}
.trip-check input {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
  cursor: pointer;
}
.trip-row--done .trip-route__leg,
.trip-row--done .trip-when {
  color: var(--muted-foreground);
}

/* ── modal ─────────────────────────────────────────────────────────────── */
dialog.modal {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 0;
  width: min(560px, calc(100vw - 32px));
  background: var(--surface);
  color: var(--foreground);
  box-shadow: var(--shadow-pop);
}
dialog.modal::backdrop {
  background: rgba(15, 23, 42, 0.48);
  backdrop-filter: blur(2px);
}
.modal__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--border);
}
.modal__head h2 {
  font-size: var(--text-lg);
}
.modal__body {
  padding: var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  max-height: min(62vh, 520px);
  overflow-y: auto;
}
.modal__foot {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  border-top: 1px solid var(--border);
  background: var(--surface-sunken);
  flex-wrap: wrap;
}

/* ── toast ─────────────────────────────────────────────────────────────── */
.toasts {
  position: fixed;
  inset-inline: 0;
  bottom: 22px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  z-index: 90;
  pointer-events: none;
}
.toast {
  background: var(--foreground);
  color: var(--background);
  padding: 10px 18px;
  border-radius: var(--radius-pill);
  font-size: var(--text-sm);
  box-shadow: var(--shadow-pop);
  display: flex;
  align-items: center;
  gap: 8px;
  animation: toast-in 200ms ease-out;
}
.toast svg {
  width: 15px;
  height: 15px;
}
@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
}

/* ── footer ────────────────────────────────────────────────────────────── */
.footer {
  border-top: 1px solid var(--border);
  padding-block: var(--space-5);
  color: var(--muted-foreground);
  font-size: var(--text-sm);
}
.footer__inner {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3) var(--space-5);
  justify-content: space-between;
  align-items: center;
}

/* ── misc ──────────────────────────────────────────────────────────────── */
.muted {
  color: var(--muted-foreground);
}
.mono {
  font-family: var(--font-mono);
}
.small {
  font-size: var(--text-xs);
}
.row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-wrap: wrap;
}
.spacer {
  flex: 1;
}
.stack {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}
.is-hidden {
  display: none !important;
}
[hidden] {
  display: none !important;
}
.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;
}

@media (max-width: 900px) {
  .hero {
    grid-template-columns: minmax(0, 1fr);
    padding-block: var(--space-5);
  }
  .hero__stats {
    grid-template-rows: none;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .cam-body {
    grid-template-columns: minmax(0, 1fr);
  }
  .tool-card,
  .info-card {
    grid-column: span 6;
  }
  .bento {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* five nav items no longer fit with labels on a tablet */
@media (max-width: 860px) {
  .nav a span {
    display: none;
  }
  .nav a {
    padding: 9px 11px;
  }
}

@media (max-width: 700px) {
  /* contacts become stacked cards on a phone: no horizontal scrolling */
  .col-position,
  .col-email {
    display: none !important;
  }
  #pb-table {
    overflow: visible;
  }
  #pb-table table.data,
  #pb-table table.data tbody,
  #pb-table table.data tr,
  #pb-table table.data td {
    display: block;
    width: auto;
    min-width: 0 !important;
    white-space: normal;
  }
  #pb-table table.data {
    min-width: 0 !important;
  }
  #pb-table table.data thead {
    display: none;
  }
  #pb-table table.data tbody tr {
    position: relative;
    padding: 14px var(--space-4);
    border-bottom: 1px solid var(--border);
  }
  #pb-table table.data tbody tr:last-child {
    border-bottom: 0;
  }
  #pb-table table.data tbody td {
    border: 0;
    padding: 0;
  }
  #pb-table td.col-actions {
    position: absolute;
    inset-inline-end: 10px;
    top: 10px;
    width: auto;
  }
  #pb-table .contact-cell {
    padding-inline-end: 88px;
  }
  #pb-table .contact-name,
  #pb-table .contact-sub {
    white-space: normal;
  }
  #pb-table td:nth-child(3) {
    margin-top: 6px;
  }
  #pb-table td.mono {
    margin-top: 4px;
    font-size: var(--text-sm);
  }
  #pb-table td.mono a {
    font-weight: 500;
  }

  /* travel schedule becomes stacked cards too */
  #trip-table {
    overflow: visible;
  }
  #trip-table table.data,
  #trip-table table.data tbody,
  #trip-table table.data tr,
  #trip-table table.data td {
    display: block;
    width: auto;
    min-width: 0 !important;
    white-space: normal;
  }
  #trip-table table.data {
    min-width: 0 !important;
  }
  #trip-table table.data thead {
    display: none;
  }
  #trip-table table.data tbody tr {
    position: relative;
    padding: 14px var(--space-4);
    border-bottom: 1px solid var(--border);
  }
  #trip-table table.data tbody tr:last-child {
    border-bottom: 0;
  }
  #trip-table table.data tbody td {
    border: 0;
    padding: 0;
  }
  #trip-table td.col-actions {
    position: absolute;
    inset-inline-end: 8px;
    top: 8px;
    width: auto;
  }
  #trip-table td:first-child {
    padding-inline-end: 92px;
  }
  #trip-table td:nth-child(3),
  #trip-table td:nth-child(4) {
    margin-top: 6px;
  }

  /* camera panel header reads better stacked on a phone */
  #cam-detail .panel__head > .row {
    width: 100%;
  }
  #cam-detail .panel__head #cam-folder-title {
    font-size: var(--text-base);
    overflow-wrap: anywhere;
  }
}

@media (max-width: 640px) {
  :root {
    --space-6: 24px;
    --space-7: 32px;
  }
  .wrap {
    padding-inline: var(--space-4);
  }
  .nav a span {
    display: none;
  }
  .nav a {
    padding: 9px 11px;
  }
  .grid-2,
  .grid-3 {
    grid-template-columns: minmax(0, 1fr);
  }
  .panel,
  .panel__body {
    padding: var(--space-4);
  }
  .hero__stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .brand > span:last-child {
    display: none;
  }
  .stat-card {
    padding: var(--space-3) var(--space-4);
  }
  .stat-card__hint {
    font-size: var(--text-xs);
  }
  .footer__inner {
    flex-direction: column;
    align-items: flex-start;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  .tool-card:hover {
    transform: none;
  }
}

@media print {
  .topbar,
  .footer,
  .toasts,
  .row-actions {
    display: none;
  }
  body {
    background: #fff;
  }
}
