@import url('/fonts/plex.css');

/* ================================================================
   Design tokens
   ================================================================ */
:root {
  --accent: #6366f1;

  /* พื้นหลังไล่ชั้นความลึก */
  --bg:        #070912;
  --bg-2:      #0c1020;
  --surface:   rgba(255, 255, 255, .042);
  --surface-2: rgba(255, 255, 255, .075);
  --line:      rgba(255, 255, 255, .085);
  --line-2:    rgba(255, 255, 255, .16);

  --text:  #eef1fa;
  --dim:   #a6b0cc;
  --faint: #6f7b9c;

  --radius:   18px;
  --radius-s: 12px;

  --shadow-1: 0 1px 2px rgba(0,0,0,.30), 0 8px 24px -8px rgba(0,0,0,.45);
  --shadow-2: 0 2px 6px rgba(0,0,0,.28), 0 28px 60px -20px rgba(0,0,0,.65);

  /* easing: ออกแรงเร็ว หน่วงนุ่มตอนจบ */
  --ease:   cubic-bezier(.22, 1, .36, 1);
  --spring: cubic-bezier(.34, 1.56, .64, 1);
}

html[data-theme="light"] {
  --bg:        #f7f8fc;
  --bg-2:      #ffffff;
  --surface:   rgba(255, 255, 255, .78);
  --surface-2: #ffffff;
  --line:      rgba(16, 24, 48, .09);
  --line-2:    rgba(16, 24, 48, .18);

  --text:  #0d1426;
  --dim:   #4d5978;
  --faint: #8590ac;

  --shadow-1: 0 1px 2px rgba(16,24,48,.05), 0 8px 24px -10px rgba(16,24,48,.16);
  --shadow-2: 0 2px 8px rgba(16,24,48,.07), 0 28px 56px -22px rgba(16,24,48,.28);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  padding: clamp(22px, 3.5vw, 40px) clamp(16px, 5vw, 64px) 72px;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: 'IBM Plex Sans Thai', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  font-weight: 400;
  font-feature-settings: 'kern' 1;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  transition: background .5s var(--ease), color .5s var(--ease);
}

a { color: inherit; text-decoration: none; }
.muted { color: var(--dim); }

/* ================================================================
   พื้นหลังภาพ blur แบบ nexterz.com
   inset ติดลบ + scale กัน blur กินขอบจนเห็นเป็นกรอบจาง
   ================================================================ */
.bg-glow {
  position: fixed; inset: -40px; z-index: -3; pointer-events: none;
  background: url('/img/bgdark.jpg') center center / cover no-repeat;
  filter: blur(10px);
  transform: translateZ(0) scale(1.03);
  will-change: transform;
  animation: drift 46s var(--ease) infinite alternate;
}
@keyframes drift {
  from { transform: translateZ(0) scale(1.03); }
  to   { transform: translateZ(0) scale(1.09) translate3d(-1%, -1%, 0); }
}

/* ชั้นกรองความสว่าง ให้ตัวหนังสืออ่านง่ายบนภาพ */
.bg-scrim {
  position: fixed; inset: 0; z-index: -2; pointer-events: none;
  background:
    linear-gradient(180deg,
      color-mix(in oklab, var(--bg) 20%, transparent),
      color-mix(in oklab, var(--bg) 46%, transparent));
}
/* ธีมสว่างต้องหนากว่า เพราะภาพต้นฉบับเป็นโทนมืด */
html[data-theme="light"] .bg-scrim {
  background:
    linear-gradient(180deg,
      color-mix(in oklab, var(--bg) 82%, transparent),
      color-mix(in oklab, var(--bg) 92%, transparent));
}
html[data-theme="light"] .bg-glow { opacity: .45; }

/* ผ้าคลุมเนื้อละเอียด กัน gradient เป็นแถบ (banding) */
.bg-grain {
  position: fixed; inset: 0; z-index: -1; pointer-events: none;
  opacity: .035; mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ================================================================
   Entrance choreography
   ================================================================ */
@keyframes rise {
  from { opacity: 0; transform: translate3d(0, 16px, 0) scale(.985); }
  to   { opacity: 1; transform: none; }
}
@keyframes fade { from { opacity: 0 } to { opacity: 1 } }

.reveal { opacity: 0; animation: rise .62s var(--ease) forwards; }

/* ================================================================
   Header
   ================================================================ */
.top {
  display: flex; justify-content: space-between; align-items: center;
  gap: 20px; margin-bottom: clamp(26px, 4vw, 44px);
  animation: rise .7s var(--ease) both;
}
.brand { display: flex; align-items: center; gap: 15px; min-width: 0; }
.brand img {
  width: 50px; height: 50px; border-radius: 14px; object-fit: cover;
  box-shadow: var(--shadow-1);
}
.brand h1 {
  margin: 0;
  font-size: clamp(22px, 3.2vw, 31px);
  font-weight: 600;
  letter-spacing: -.022em;
  line-height: 1.18;
  background: linear-gradient(180deg, var(--text), color-mix(in oklab, var(--text) 62%, transparent));
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
}
.brand p { margin: 5px 0 0; font-size: 14px; font-weight: 300; color: var(--dim); }

.top-actions { display: flex; gap: 10px; flex: none; }
.icon-btn {
  display: grid; place-items: center;
  width: 44px; height: 44px; border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--surface);
  backdrop-filter: blur(16px) saturate(160%);
  -webkit-backdrop-filter: blur(16px) saturate(160%);
  color: var(--text); cursor: pointer; font-size: 17px;
  box-shadow: var(--shadow-1);
  transition: transform .4s var(--spring), background .3s var(--ease),
              border-color .3s var(--ease), box-shadow .3s var(--ease);
}
.icon-btn:hover { background: var(--surface-2); border-color: var(--line-2); transform: translateY(-2px); }
.icon-btn:active { transform: translateY(0) scale(.94); transition-duration: .1s; }
.icon-btn span { display: block; transition: transform .55s var(--spring); }
#themeBtn:hover span { transform: rotate(-22deg) scale(1.1); }

/* ================================================================
   Search
   ================================================================ */
.searchbar {
  position: relative;
  display: flex; align-items: center; gap: 14px;
  max-width: 660px; margin: 0 auto clamp(22px, 3vw, 32px);
  padding: 15px 20px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  backdrop-filter: blur(20px) saturate(170%);
  -webkit-backdrop-filter: blur(20px) saturate(170%);
  box-shadow: var(--shadow-1);
  animation: rise .7s .06s var(--ease) both;
  transition: border-color .35s var(--ease), box-shadow .45s var(--ease), transform .45s var(--spring);
}
.searchbar::after {
  content: ""; position: absolute; inset: -1px; border-radius: inherit;
  padding: 1px; pointer-events: none; opacity: 0;
  background: linear-gradient(120deg,
    color-mix(in oklab, var(--accent) 85%, transparent), transparent 42%, transparent 60%,
    color-mix(in oklab, var(--accent) 55%, transparent));
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor; mask-composite: exclude;
  transition: opacity .4s var(--ease);
}
.searchbar:focus-within {
  transform: translateY(-2px);
  box-shadow: var(--shadow-2), 0 0 0 4px color-mix(in oklab, var(--accent) 16%, transparent);
}
.searchbar:focus-within::after { opacity: 1; }
.searchbar .s-ico { font-size: 15px; opacity: .65; transition: opacity .3s var(--ease), transform .5s var(--spring); }
.searchbar:focus-within .s-ico { opacity: 1; transform: scale(1.12); }
.searchbar input {
  flex: 1; min-width: 0;
  border: 0; background: transparent; outline: none;
  color: var(--text); font: inherit; font-size: 15px; font-weight: 400;
}
.searchbar input::placeholder { color: var(--faint); font-weight: 300; }
.searchbar input::-webkit-search-cancel-button { display: none; }

kbd {
  flex: none;
  border: 1px solid var(--line); border-radius: 7px;
  padding: 2px 8px; font-family: inherit; font-size: 11.5px;
  color: var(--faint); background: color-mix(in oklab, var(--text) 5%, transparent);
  transition: opacity .3s var(--ease);
}
.searchbar:focus-within kbd { opacity: 0; }

/* ================================================================
   Category chips
   ================================================================ */
.chips {
  display: flex; flex-wrap: wrap; gap: 9px; justify-content: center;
  margin-bottom: clamp(30px, 4.5vw, 46px);
  animation: rise .7s .12s var(--ease) both;
}
.chip {
  position: relative;
  border: 1px solid var(--line);
  background: var(--surface);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: var(--dim);
  padding: 8px 17px; border-radius: 999px;
  font: inherit; font-size: 13.5px; font-weight: 400;
  cursor: pointer; white-space: nowrap;
  transition: color .3s var(--ease), border-color .3s var(--ease),
              background .3s var(--ease), transform .4s var(--spring);
}
.chip:hover { color: var(--text); border-color: var(--line-2); transform: translateY(-2px); }
.chip:active { transform: translateY(0) scale(.96); transition-duration: .1s; }
.chip.active {
  color: #fff; border-color: transparent; font-weight: 500;
  background: linear-gradient(135deg,
    color-mix(in oklab, var(--accent) 100%, transparent),
    color-mix(in oklab, var(--accent) 74%, #000));
  box-shadow: 0 6px 20px -6px color-mix(in oklab, var(--accent) 70%, transparent);
}
.chip .n { opacity: .6; font-size: 12px; margin-left: 3px; font-weight: 400; }

/* ================================================================
   Groups
   ================================================================ */
.group { margin-bottom: clamp(32px, 4.5vw, 50px); }
.group-head {
  display: flex; align-items: center; gap: 11px;
  margin: 0 0 16px;
  font-size: 14.5px; font-weight: 500; letter-spacing: .002em;
}
.group-head .dot {
  width: 8px; height: 8px; border-radius: 50%; flex: none;
  background: var(--c);
  box-shadow: 0 0 0 3px color-mix(in oklab, var(--c) 22%, transparent),
              0 0 14px color-mix(in oklab, var(--c) 60%, transparent);
}
.group-head .g-ico { font-size: 15px; }
.group-head .rule {
  flex: 1; height: 1px; min-width: 16px;
  background: linear-gradient(90deg, var(--line), transparent);
}
.group-head .count { font-size: 12px; color: var(--faint); font-variant-numeric: tabular-nums; }

.grid {
  display: grid; gap: 13px;
  grid-template-columns: repeat(auto-fill, minmax(244px, 1fr));
}

/* ================================================================
   Link card
   ================================================================ */
.card {
  --c: var(--accent);
  position: relative; isolation: isolate;
  display: flex; gap: 14px; align-items: center;
  padding: 15px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--surface);
  backdrop-filter: blur(14px) saturate(150%);
  -webkit-backdrop-filter: blur(14px) saturate(150%);
  box-shadow: var(--shadow-1);
  overflow: hidden;
  transition: transform .45s var(--ease), border-color .35s var(--ease),
              box-shadow .45s var(--ease), background .35s var(--ease);
}

/* แสงวิ่งตามเมาส์ */
.card::before {
  content: ""; position: absolute; inset: 0; z-index: -1;
  background: radial-gradient(220px circle at var(--mx, 50%) var(--my, 0%),
              color-mix(in oklab, var(--c) 17%, transparent), transparent 68%);
  opacity: 0; transition: opacity .45s var(--ease);
}
/* ขอบเรืองแสง */
.card::after {
  content: ""; position: absolute; inset: 0; border-radius: inherit;
  padding: 1px; pointer-events: none; opacity: 0;
  background: linear-gradient(140deg, color-mix(in oklab, var(--c) 80%, transparent), transparent 55%);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor; mask-composite: exclude;
  transition: opacity .45s var(--ease);
}
.card:hover {
  transform: translateY(-4px);
  background: var(--surface-2);
  border-color: transparent;
  box-shadow: var(--shadow-2), 0 20px 44px -24px color-mix(in oklab, var(--c) 62%, transparent);
}
.card:hover::before, .card:hover::after { opacity: 1; }
.card:active { transform: translateY(-1px) scale(.988); transition-duration: .12s; }

.card .ico {
  flex: none;
  width: 42px; height: 42px; border-radius: 13px;
  display: grid; place-items: center;
  font-size: 18px; font-weight: 600;
  color: var(--c);
  background: linear-gradient(145deg,
    color-mix(in oklab, var(--c) 26%, transparent),
    color-mix(in oklab, var(--c) 11%, transparent));
  border: 1px solid color-mix(in oklab, var(--c) 24%, transparent);
  transition: transform .5s var(--spring);
}
.card:hover .ico { transform: scale(1.07) rotate(-3deg); }
.card .ico img { width: 22px; height: 22px; border-radius: 6px; object-fit: contain; }

.card .body { min-width: 0; }
.card .t {
  font-size: 14.5px; font-weight: 500; letter-spacing: -.004em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.card .d {
  margin-top: 3px;
  font-size: 12.5px; font-weight: 300; line-height: 1.5; color: var(--dim);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.card .pin {
  position: absolute; top: 10px; right: 12px;
  font-size: 10.5px; opacity: .55;
  transition: opacity .3s var(--ease), transform .5s var(--spring);
}
.card:hover .pin { opacity: 1; transform: rotate(12deg) scale(1.1); }

/* ================================================================
   Empty state / footer
   ================================================================ */
.empty {
  text-align: center; padding: 74px 20px; color: var(--dim);
  animation: fade .5s var(--ease) both;
}
.empty .big { font-size: 34px; margin-bottom: 14px; opacity: .5; }
.empty .hint { margin-top: 10px; font-size: 13px; color: var(--faint); font-weight: 300; }
.empty b { font-weight: 500; color: var(--text); }

.foot {
  text-align: center; font-size: 12.5px; font-weight: 300;
  color: var(--faint); margin-top: 44px;
  animation: fade .8s .3s var(--ease) both;
}
.foot a { color: var(--dim); border-bottom: 1px solid transparent; transition: color .3s, border-color .3s; }
.foot a:hover { color: var(--text); border-color: var(--line-2); }
.foot .sep { opacity: .4; margin: 0 8px; }

/* ================================================================
   Admin
   ================================================================ */
.admin-shell { display: grid; grid-template-columns: 232px 1fr; gap: 24px; align-items: start; }
@media (max-width: 820px) { .admin-shell { grid-template-columns: 1fr; } }

.side {
  position: sticky; top: 24px;
  display: flex; flex-direction: column; gap: 4px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 12px;
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  box-shadow: var(--shadow-1);
  animation: rise .6s var(--ease) both;
}
@media (max-width: 820px) {
  .side { position: static; flex-direction: row; overflow-x: auto; }
  .side button { white-space: nowrap; }
}
.side button {
  text-align: left; padding: 11px 14px; border-radius: var(--radius-s);
  border: 0; background: transparent; color: var(--dim);
  cursor: pointer; font: inherit; font-size: 14px;
  transition: background .3s var(--ease), color .3s var(--ease), transform .35s var(--spring);
}
.side button:hover { background: var(--surface-2); color: var(--text); }
.side button:active { transform: scale(.97); }
.side button.active {
  color: #fff; font-weight: 500;
  background: linear-gradient(135deg, var(--accent), color-mix(in oklab, var(--accent) 72%, #000));
  box-shadow: 0 8px 22px -10px color-mix(in oklab, var(--accent) 80%, transparent);
}

.panel {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: clamp(18px, 2.5vw, 26px);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  box-shadow: var(--shadow-1);
  animation: rise .55s var(--ease) both;
}
.panel h2 { margin: 0 0 4px; font-size: 19px; font-weight: 600; letter-spacing: -.014em; }
.panel h3 { font-size: 14.5px; font-weight: 500; }
.panel > p.muted { margin: 0 0 20px; font-size: 13.5px; font-weight: 300; }

label { display: block; font-size: 12.5px; color: var(--dim); margin-bottom: 7px; font-weight: 400; }
input[type=text], input[type=url], input[type=password], input[type=search], select, textarea {
  width: 100%; padding: 11px 13px;
  border-radius: var(--radius-s);
  border: 1px solid var(--line);
  background: color-mix(in oklab, var(--bg-2) 70%, transparent);
  color: var(--text); font: inherit; font-size: 14px; outline: none;
  transition: border-color .3s var(--ease), box-shadow .3s var(--ease), background .3s var(--ease);
}
input:focus, select:focus, textarea:focus {
  border-color: color-mix(in oklab, var(--accent) 62%, transparent);
  box-shadow: 0 0 0 3.5px color-mix(in oklab, var(--accent) 15%, transparent);
}
input::placeholder, textarea::placeholder { color: var(--faint); font-weight: 300; }
textarea { resize: vertical; min-height: 76px; line-height: 1.55; }
input[type=color] { padding: 4px; height: 43px; cursor: pointer; }
select { cursor: pointer; }

.row { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); margin-bottom: 15px; }
.checkline { display: flex; align-items: center; gap: 9px; font-size: 14px; color: var(--text); cursor: pointer; }
.checkline input { width: auto; accent-color: var(--accent); cursor: pointer; }

.btn {
  padding: 11px 18px; border-radius: var(--radius-s);
  border: 1px solid var(--line);
  background: var(--surface-2); color: var(--text);
  cursor: pointer; font: inherit; font-size: 14px;
  transition: background .3s var(--ease), border-color .3s var(--ease),
              transform .35s var(--spring), box-shadow .3s var(--ease);
}
.btn:hover { border-color: var(--line-2); transform: translateY(-2px); box-shadow: var(--shadow-1); }
.btn:active { transform: translateY(0) scale(.97); transition-duration: .1s; }
.btn.primary {
  border-color: transparent; color: #fff; font-weight: 500;
  background: linear-gradient(135deg, var(--accent), color-mix(in oklab, var(--accent) 70%, #000));
  box-shadow: 0 10px 26px -12px color-mix(in oklab, var(--accent) 90%, transparent);
}
.btn.primary:hover { box-shadow: 0 14px 32px -12px color-mix(in oklab, var(--accent) 95%, transparent); }
.btn.danger { color: #ff7a7a; }
.btn.danger:hover { background: color-mix(in oklab, #ff5c5c 13%, transparent); border-color: color-mix(in oklab, #ff5c5c 32%, transparent); }
.btn.sm { padding: 7px 12px; font-size: 13px; border-radius: 9px; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 11px 9px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { color: var(--faint); font-weight: 400; font-size: 12px; letter-spacing: .03em; text-transform: uppercase; }
tbody tr { transition: background .25s var(--ease); }
tbody tr:hover { background: color-mix(in oklab, var(--text) 3.5%, transparent); }
tr.dragging { opacity: .35; }
.handle { cursor: grab; color: var(--faint); user-select: none; }
.handle:active { cursor: grabbing; }
.badge {
  display: inline-block; padding: 3px 10px; border-radius: 999px;
  font-size: 11.5px; border: 1px solid var(--line); color: var(--dim);
}

.stat-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(158px, 1fr)); margin-bottom: 24px; }
.stat {
  position: relative; overflow: hidden;
  background: color-mix(in oklab, var(--bg-2) 55%, transparent);
  border: 1px solid var(--line);
  border-radius: var(--radius); padding: 17px 18px;
  transition: transform .4s var(--ease), border-color .3s var(--ease);
}
.stat:hover { transform: translateY(-3px); border-color: var(--line-2); }
.stat span { font-size: 12.5px; color: var(--dim); font-weight: 300; }
.stat b {
  display: block; font-size: 30px; font-weight: 600; margin-top: 6px;
  letter-spacing: -.03em; font-variant-numeric: tabular-nums;
}

.modal {
  position: fixed; inset: 0; z-index: 60;
  display: grid; place-items: center; padding: 20px;
  background: color-mix(in oklab, #04060f 62%, transparent);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  animation: fade .28s var(--ease);
}
.modal .box {
  width: min(580px, 100%); max-height: 88vh; overflow: auto;
  background: var(--bg-2); border: 1px solid var(--line);
  border-radius: 22px; padding: clamp(20px, 3vw, 28px);
  box-shadow: var(--shadow-2);
  animation: pop .42s var(--spring) both;
}
@keyframes pop {
  from { opacity: 0; transform: translate3d(0, 18px, 0) scale(.96); }
  to   { opacity: 1; transform: none; }
}

.toast {
  position: fixed; left: 50%; bottom: 28px; z-index: 99;
  padding: 13px 22px; border-radius: 14px;
  background: var(--bg-2); color: var(--text);
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  font-size: 14px; box-shadow: var(--shadow-2);
  animation: toastIn .5s var(--spring) both;
}
@keyframes toastIn {
  from { opacity: 0; transform: translate(-50%, 22px) scale(.94); }
  to   { opacity: 1; transform: translate(-50%, 0) scale(1); }
}

/* ---------------------------------------------------------------- ตัวเลือกสี/อีโมจิ */
.swatches {
  display: grid; gap: 9px;
  grid-template-columns: repeat(auto-fill, minmax(40px, 1fr));
  margin-bottom: 14px;
}
.swatch {
  position: relative;
  aspect-ratio: 1; border-radius: 11px;
  border: 1px solid var(--line); cursor: pointer; padding: 0;
  background: var(--sw);
  transition: transform .35s var(--spring), box-shadow .3s var(--ease);
}
.swatch:hover { transform: translateY(-2px) scale(1.06); }
.swatch:active { transform: scale(.94); transition-duration: .1s; }
.swatch.on {
  box-shadow: 0 0 0 2px var(--bg-2), 0 0 0 4px var(--sw), 0 8px 18px -8px var(--sw);
}
.swatch.on::after {
  content: "✓"; position: absolute; inset: 0;
  display: grid; place-items: center;
  color: #fff; font-size: 15px; font-weight: 700;
  text-shadow: 0 1px 3px rgba(0,0,0,.5);
}

.picker { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 12px; }
.picker button {
  width: 38px; height: 38px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--surface);
  cursor: pointer; font-size: 17px; line-height: 1; padding: 0;
  transition: transform .35s var(--spring), background .25s var(--ease), border-color .25s var(--ease);
}
.picker button:hover { transform: translateY(-2px) scale(1.08); background: var(--surface-2); }
.picker button:active { transform: scale(.92); transition-duration: .1s; }
.picker button.on { border-color: var(--accent); background: color-mix(in oklab, var(--accent) 20%, transparent); }

.preview {
  display: flex; align-items: center; gap: 11px;
  padding: 15px 17px; margin-bottom: 20px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: color-mix(in oklab, var(--c, var(--accent)) 9%, transparent);
}
.preview .dot {
  width: 10px; height: 10px; border-radius: 50%; flex: none;
  background: var(--c, var(--accent));
  box-shadow: 0 0 0 3px color-mix(in oklab, var(--c, var(--accent)) 24%, transparent),
              0 0 14px color-mix(in oklab, var(--c, var(--accent)) 60%, transparent);
}
.preview .pv-ico { font-size: 18px; }
.preview .pv-name { font-weight: 500; font-size: 15px; }

/* ---------------------------------------------------------------- แถบเลือกโหมด */
.seg {
  display: inline-flex; gap: 4px; padding: 4px; margin-bottom: 10px;
  border-radius: 12px; border: 1px solid var(--line);
  background: color-mix(in oklab, var(--bg-2) 70%, transparent);
}
.seg button {
  border: 0; background: transparent; color: var(--dim);
  padding: 8px 14px; border-radius: 9px;
  font: inherit; font-size: 13.5px; cursor: pointer; white-space: nowrap;
  transition: background .25s var(--ease), color .25s var(--ease), transform .3s var(--spring);
}
.seg button:hover { color: var(--text); }
.seg button:active { transform: scale(.96); }
.seg button.on {
  color: #fff; font-weight: 500;
  background: linear-gradient(135deg, var(--accent), color-mix(in oklab, var(--accent) 72%, #000));
}
.hint-line { font-size: 12.5px; margin: 0 0 12px; }

/* ตัวเลือกหมวดหมู่แบบชิปสี */
.cat-picker { margin-bottom: 18px; }
.cat-picker button {
  width: auto; height: auto; padding: 8px 14px; border-radius: 999px;
  font-size: 13.5px; color: var(--dim); display: inline-flex; align-items: center; gap: 7px;
}
.cat-picker button .cdot { width: 8px; height: 8px; border-radius: 50%; background: var(--cc); flex: none; }
.cat-picker button.on {
  color: var(--text); font-weight: 500;
  border-color: var(--cc);
  background: color-mix(in oklab, var(--cc) 18%, transparent);
}

/* แท็กที่เคยใช้ */
.tag-picker { margin: 10px 0 16px; }
.tag-picker button {
  width: auto; height: auto; padding: 5px 12px; border-radius: 999px;
  font-size: 12.5px; color: var(--dim);
}
.tag-picker button.on { border-color: var(--accent); color: var(--text);
  background: color-mix(in oklab, var(--accent) 18%, transparent); }

/* การ์ดตัวอย่างในหน้าแก้ไขลิงก์ — ปิด hover/animation ของการ์ดจริง */
.preview-card {
  margin-bottom: 20px; cursor: default; animation: none;
  background: color-mix(in oklab, var(--c, var(--accent)) 8%, transparent);
}
.preview-card:hover { transform: none; box-shadow: var(--shadow-1); border-color: var(--line); }
.preview-card:hover::before, .preview-card:hover::after { opacity: 0; }
.preview-card .d:empty { display: none; }

.login-wrap { display: grid; place-items: center; min-height: 80vh; }
.login-wrap .panel { width: min(392px, 100%); }
.err { color: #ff7a7a; font-size: 13px; min-height: 19px; margin: 0 0 4px; }

/* ================================================================
   เคารพการตั้งค่าลดการเคลื่อนไหวของระบบ
   ================================================================ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
  .reveal { opacity: 1; }
}
