:root {

  --bg: #070b10;

  --surface: #121820;

  --surface-2: #1a2230;

  --surface-3: #222c3c;

  --border: rgba(255, 255, 255, 0.07);

  --border-strong: rgba(0, 212, 170, 0.28);

  --text: #f2f6fb;

  --muted: #8fa0b3;

  --accent: #00e5b8;

  --accent-2: #00b894;

  --accent-dim: rgba(0, 229, 184, 0.12);

  --accent-glow: rgba(0, 229, 184, 0.22);

  --user-bg: #3f3f46;
  --user-text: #f4f4f5;
  --user-border: rgba(255, 255, 255, 0.08);

  --assistant-bg: linear-gradient(180deg, rgba(255,255,255,0.04), rgba(255,255,255,0.02));

  --warn: #f59e0b;

  --error: #ef4444;

  --ok: #10b981;

  --shadow: 0 16px 48px rgba(0, 0, 0, 0.42);

  --radius-lg: 20px;

  --radius-md: 14px;

  --radius-sm: 10px;

}



* { box-sizing: border-box; }

html, body {

  margin: 0;

  height: 100%;

  font-family: 'Inter', 'Noto Sans Thai', system-ui, -apple-system, sans-serif;

  background: var(--bg);

  color: var(--text);

}

body.theme-light {
  --bg: #ffffff;
  --surface: #f7f7f8;
  --surface-2: #ececf1;
  --text: #0d0d0d;
  --muted: #6e6e80;
  --border: rgba(0,0,0,0.08);
  --accent: #10a37f;
  --accent-2: #0d8f6e;
  --user-bg: #10a37f;
  --assistant-bg: #f7f7f8;
}

.hidden { display: none !important; }

.app-root {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 100dvh;
}
.app-root .nkbk-ai-shell {
  display: flex;
  flex: 1;
  min-height: 0;
  width: 100%;
}
.app-root .nkbk-ai-app { flex: 1; min-height: 0; }

.auth-screen {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: linear-gradient(160deg, #f0fdf4 0%, #ffffff 45%, #ecfdf5 100%);
}
.auth-card {
  width: min(420px, 100%);
  background: #fff;
  border-radius: 20px;
  padding: 36px 28px;
  box-shadow: 0 20px 60px rgba(16, 163, 127, 0.12), 0 4px 16px rgba(0,0,0,0.06);
  text-align: center;
}
.auth-logo {
  width: 64px;
  height: 64px;
  margin: 0 auto 16px;
  border-radius: 16px;
  background: #f0fdf4;
  display: flex;
  align-items: center;
  justify-content: center;
}
.auth-title { margin: 0 0 8px; font-size: 1.5rem; font-weight: 700; color: #0d0d0d; }
.auth-sub { margin: 0 0 24px; color: #6e6e80; font-size: 0.92rem; line-height: 1.5; }
.auth-card:has(#authLoading:not(.hidden)) .auth-logo,
.auth-card:has(#authLoading:not(.hidden)) .auth-title,
.auth-card:has(#authLoading:not(.hidden)) .auth-sub {
  display: none;
}
.auth-loading { margin-top: 0; }
.auth-boot-logo-wrap {
  position: relative;
  width: 72px;
  height: 72px;
  margin: 0 auto 14px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.auth-boot-logo {
  position: relative;
  z-index: 2;
  border-radius: 14px;
  animation: boot-logo-float 2.4s ease-in-out infinite;
}
.auth-boot-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid rgba(16, 163, 127, 0.22);
  animation: boot-ring-pulse 1.8s ease-out infinite;
}
.auth-boot-ring--delay { animation-delay: 0.65s; }
.auth-boot-brand {
  margin: 0 0 6px;
  font-size: 1.05rem;
  font-weight: 700;
  color: #0d0d0d;
  letter-spacing: -0.02em;
}
.auth-boot-status {
  margin: 0 0 14px;
  color: #6e6e80;
  font-size: 0.88rem;
}
.auth-boot-dots {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.auth-boot-dots span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #10a37f;
  animation: boot-dot-bounce 1.1s ease-in-out infinite;
}
.auth-boot-dots span:nth-child(2) { animation-delay: 0.15s; }
.auth-boot-dots span:nth-child(3) { animation-delay: 0.3s; }
.auth-spinner {
  width: 36px; height: 36px; margin: 0 auto;
  border: 3px solid #d1fae5; border-top-color: #10a37f;
  border-radius: 50%; animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.btn-line {
  width: 100%;
  padding: 14px 20px;
  border: none;
  border-radius: 12px;
  background: #06c755;
  color: #fff;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
}
.btn-line:hover { background: #05b64d; }
.auth-hint { margin: 16px 0 0; font-size: 0.78rem; color: #9ca3af; line-height: 1.45; }
.auth-error { margin-top: 8px; }
.auth-error p { color: #dc2626; font-size: 0.9rem; margin: 0 0 12px; }
.btn-link-account {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  margin-bottom: 10px;
  padding: 12px 16px;
  border-radius: 12px;
  background: #06C755;
  color: #fff;
  font: inherit;
  font-size: 0.92rem;
  font-weight: 600;
  text-decoration: none;
  transition: background 0.15s ease;
}
.btn-link-account:hover { background: #05b34c; }
.btn-ghost {
  padding: 10px 18px; border-radius: 10px; border: 1px solid rgba(0,0,0,0.12);
  background: #fff; color: #374151; cursor: pointer;   font-weight: 500;
}

.btn-menu {
  display: none;
  width: 40px; height: 40px; border: none; border-radius: 10px;
  background: transparent; color: var(--text); cursor: pointer;
  flex-shrink: 0; align-items: center; justify-content: center;
}
.btn-sidebar-expand { display: none !important; }
.sidebar-close {
  display: none;
  width: 36px; height: 36px; border: none; border-radius: 8px;
  background: transparent; color: var(--muted); font-size: 1.4rem; cursor: pointer;
}
.sidebar-backdrop {
  display: none;
  position: fixed; inset: 0; background: rgba(0,0,0,0.35); z-index: 40;
}
.sidebar-top { display: flex; align-items: center; gap: 8px; padding: 0 12px 8px; }
.sidebar-foot {
  margin-top: auto;
  padding: 8px 6px 6px;
  position: relative;
}
.user-chip {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; margin-bottom: 8px;
  border-radius: 10px; background: var(--surface-2);
}
.user-chip-img { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; }
.user-chip-name { font-size: 0.85rem; font-weight: 500; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.btn-logout {
  width: 100%; padding: 10px; border-radius: 10px;
  border: 1px solid var(--border); background: transparent;
  color: var(--muted); font-size: 0.85rem; cursor: pointer;
}
.btn-logout:hover { background: var(--surface-2); color: var(--text); }

@media (max-width: 768px) {
  .btn-menu { display: inline-flex; align-items: center; justify-content: center; }
  .sidebar-close { display: inline-flex; align-items: center; justify-content: center; }
  body:not(.is-viewer-open) .nkbk-ai-sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; z-index: 120;
    width: min(280px, 86vw);
    min-width: 0;
    transform: translateX(-105%);
    transition: transform 0.22s ease;
    box-shadow: 4px 0 24px rgba(0,0,0,0.15);
  }
  body.sidebar-open:not(.is-viewer-open) { overflow: hidden; }
  body.sidebar-open:not(.is-viewer-open) .nkbk-ai-sidebar { transform: translateX(0); }
  body.sidebar-open:not(.is-viewer-open) .sidebar-backdrop { display: block; z-index: 110; }
  body.is-viewer-open .sidebar-backdrop { display: none !important; }
  body.is-viewer-open .sidebar-close { display: none; }
}

button, input, textarea, select { font-family: inherit; }



.nkbk-ai-app {
  position: relative;
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
  min-height: 0;
  height: auto;
  background:
    radial-gradient(ellipse 90% 55% at 15% -10%, rgba(0, 229, 184, 0.14), transparent 55%),
    radial-gradient(ellipse 70% 45% at 95% 0%, rgba(56, 120, 255, 0.08), transparent 50%),
    linear-gradient(180deg, #0a1018 0%, var(--bg) 100%);
}



/* ── Header ── */

.nkbk-ai-header {

  position: relative;

  z-index: 100;

  flex-shrink: 0;

  display: flex;

  align-items: center;

  justify-content: space-between;

  gap: 12px;

  padding: 16px 20px;

  border-bottom: 1px solid var(--border);

  background: rgba(12, 17, 24, 0.82);

  backdrop-filter: blur(16px);

  -webkit-backdrop-filter: blur(16px);

}



.nkbk-ai-header-main {

  display: flex;

  align-items: center;

  gap: 14px;

  min-width: 0;

}



.nkbk-ai-avatar {

  position: relative;

  width: 46px;

  height: 46px;

  border-radius: 14px;

  background: linear-gradient(145deg, rgba(0,229,184,0.18), rgba(0,184,148,0.08));

  border: 1px solid rgba(0, 229, 184, 0.35);

  display: flex;

  align-items: center;

  justify-content: center;

  flex-shrink: 0;

  box-shadow: 0 0 24px rgba(0, 229, 184, 0.12);

}

.nkbk-ai-avatar-ring {

  position: absolute;

  inset: -3px;

  border-radius: 17px;

  border: 1px solid rgba(0, 229, 184, 0.15);

  pointer-events: none;

}



.nkbk-ai-header-text { min-width: 0; }



.nkbk-ai-title-row {

  display: flex;

  align-items: center;

  gap: 8px;

  flex-wrap: wrap;

}



.nkbk-ai-header h1 {

  margin: 0;

  font-size: 1.06rem;

  font-weight: 700;

  letter-spacing: -0.02em;

}



.nkbk-ai-call-badge {

  display: inline-flex;

  align-items: center;

  gap: 4px;

  padding: 3px 10px;

  border-radius: 999px;

  font-size: 0.72rem;

  font-weight: 600;

  color: var(--text);

  background: var(--surface-2);

  border: 1px solid var(--border);

  white-space: nowrap;

}

.nkbk-ai-call-badge::before {

  content: '🏷';

  font-size: 0.68rem;

}



.nkbk-ai-sub {

  margin: 3px 0 0;

  font-size: 0.74rem;

  color: var(--muted);

  letter-spacing: 0.01em;

}



.nkbk-ai-header-actions { display: flex; gap: 6px; }

.nkbk-ai-thread-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-bottom: 1px solid var(--border);
  background: rgba(10, 14, 20, 0.6);
}
.nkbk-ai-thread-select {
  flex: 1;
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: rgba(255,255,255,0.04);
  color: var(--text);
  padding: 7px 10px;
  font: inherit;
  font-size: 0.82rem;
}
.nkbk-ai-thread-btn {
  padding: 7px 10px !important;
  font-size: 0.78rem !important;
  white-space: nowrap;
}



.nkbk-ai-btn-ghost {

  border: 1px solid var(--border);

  background: rgba(255,255,255,0.03);

  color: var(--text);

  border-radius: var(--radius-sm);

  padding: 7px 11px;

  font-size: 0.82rem;

  cursor: pointer;

  transition: background 0.15s, border-color 0.15s, transform 0.12s;

}

.nkbk-ai-btn-ghost:hover {

  background: rgba(255,255,255,0.07);

  border-color: rgba(255,255,255,0.14);

  transform: translateY(-1px);

}

.nkbk-ai-btn-ghost:active:not(:disabled),
.nkbk-ai-btn-ghost.is-pressed:not(:disabled) {
  transform: scale(0.97) translateY(0);
  filter: brightness(0.96);
}

.nkbk-ai-btn-icon-sm {

  width: 38px;

  height: 38px;

  padding: 0;

  display: inline-flex;

  align-items: center;

  justify-content: center;

  font-size: 1rem;

}



/* ── Banner ── */

.nkbk-ai-banner {

  padding: 10px 20px;

  font-size: 0.85rem;

  border-bottom: 1px solid var(--border);

}

.nkbk-ai-banner--warn {
  background: rgba(245, 158, 11, 0.16);
  color: #92400e;
  font-weight: 600;
}

.nkbk-ai-banner--error {
  background: rgba(239, 68, 68, 0.14);
  color: #b91c1c;
  font-weight: 600;
}

.nkbk-ai-banner--ok {
  background: rgba(16, 185, 129, 0.14);
  color: #047857;
  font-weight: 600;
}

body.theme-light .nkbk-ai-banner--warn {
  background: #fef3c7;
  color: #92400e;
  border-bottom-color: rgba(245, 158, 11, 0.35);
}

body.theme-light .nkbk-ai-banner--error {
  background: #fee2e2;
  color: #b91c1c;
  border-bottom-color: rgba(239, 68, 68, 0.25);
}

body.theme-light .nkbk-ai-banner--ok {
  background: #d1fae5;
  color: #047857;
  border-bottom-color: rgba(16, 185, 129, 0.25);
}

body.theme-dark .nkbk-ai-banner--warn {
  background: rgba(245, 158, 11, 0.2);
  color: #fbbf24;
}

body.theme-dark .nkbk-ai-banner--error {
  background: rgba(239, 68, 68, 0.18);
  color: #fca5a5;
}

body.theme-dark .nkbk-ai-banner--ok {
  background: rgba(16, 185, 129, 0.18);
  color: #6ee7b7;
}

.hidden { display: none !important; }



/* ── Messages ── */

.nkbk-ai-messages {

  flex: 1;

  overflow-y: auto;

  padding: 22px max(16px, calc((100% - 768px) / 2)) 14px;

  display: flex;

  flex-direction: column;

  align-items: center;

  gap: 16px;

  scroll-behavior: smooth;

}

.nkbk-ai-body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.nkbk-ai-app.is-landing .nkbk-ai-body {
  flex: 1;
  justify-content: center;
  align-items: center;
  padding: 24px 16px 32px;
}

.nkbk-ai-app.is-landing .nkbk-ai-messages {
  flex: 0 0 auto;
  overflow: visible;
  padding: 0 16px 20px;
  width: 100%;
  max-width: 768px;
}

.nkbk-ai-app.is-landing .nkbk-ai-composer-wrap {
  width: 100%;
  max-width: 768px;
  border-top: none;
  padding: 0 16px 8px;
}



/* ── Welcome ── */

.nkbk-ai-welcome {

  position: relative;

  margin: auto;

  max-width: 420px;

  text-align: center;

  padding: 32px 24px 28px;

  border-radius: var(--radius-lg);

  background: rgba(255,255,255,0.025);

  border: 1px solid var(--border);

  overflow: hidden;

}

.nkbk-ai-app.is-landing .nkbk-ai-welcome {
  max-width: none;
  background: transparent;
  border: none;
  padding: 0 0 8px;
  margin: 0;
  overflow: visible;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.5s ease, transform 0.5s ease;
}
.nkbk-ai-app.is-landing:not(.is-booting) .nkbk-ai-welcome {
  opacity: 1;
  transform: none;
}
.nkbk-ai-welcome-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  text-align: center;
  overflow: visible;
}
.nkbk-ai-welcome-logo {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  background: linear-gradient(145deg, rgba(16, 163, 127, 0.12), rgba(16, 163, 127, 0.04));
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 28px rgba(16, 163, 127, 0.12);
  animation: boot-logo-float 3s ease-in-out infinite;
}
.nkbk-ai-welcome-logo img {
  width: 36px;
  height: 36px;
  border-radius: 10px;
}

/* Boot splash — โหลดเริ่มต้นหลัง login */
.nkbk-ai-app.is-booting .nkbk-ai-composer-wrap,
.nkbk-ai-app.is-booting .nkbk-ai-starter-actions {
  opacity: 0;
  pointer-events: none;
}
.nkbk-ai-app:not(.is-booting) .nkbk-ai-composer-wrap {
  animation: boot-content-in 0.45s ease 0.05s both;
}
.nkbk-ai-boot-splash {
  position: absolute;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(ellipse 80% 50% at 50% -10%, rgba(16, 163, 127, 0.1), transparent 60%),
    radial-gradient(ellipse 60% 40% at 90% 10%, rgba(99, 102, 241, 0.07), transparent 55%),
    linear-gradient(165deg, #f8fafc 0%, #f3f6fa 50%, #eef2f7 100%);
  transition: opacity 0.45s ease, visibility 0.45s ease;
}
body.theme-dark .nkbk-ai-boot-splash {
  background:
    radial-gradient(ellipse 80% 50% at 50% -10%, rgba(16, 163, 127, 0.14), transparent 60%),
    linear-gradient(165deg, #171717 0%, #1a1a1a 50%, #141414 100%);
}
.nkbk-ai-boot-splash.is-hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}
.nkbk-ai-boot-inner {
  text-align: center;
  padding: 24px;
  animation: boot-content-in 0.55s ease both;
}
.nkbk-ai-boot-logo-wrap {
  position: relative;
  width: 80px;
  height: 80px;
  margin: 0 auto 18px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.nkbk-ai-boot-logo {
  position: relative;
  z-index: 2;
  border-radius: 16px;
  animation: boot-logo-float 2.4s ease-in-out infinite;
}
.nkbk-ai-boot-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid rgba(16, 163, 127, 0.28);
  animation: boot-ring-pulse 1.8s ease-out infinite;
}
.nkbk-ai-boot-ring--delay { animation-delay: 0.65s; }
.nkbk-ai-boot-brand {
  margin: 0 0 8px;
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
}
.nkbk-ai-boot-status {
  margin: 0 0 16px;
  font-size: 0.9rem;
  color: var(--muted);
}
.nkbk-ai-boot-dots {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
}
.nkbk-ai-boot-dots span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #10a37f;
  animation: boot-dot-bounce 1.1s ease-in-out infinite;
}
.nkbk-ai-boot-dots span:nth-child(2) { animation-delay: 0.15s; }
.nkbk-ai-boot-dots span:nth-child(3) { animation-delay: 0.3s; }

@keyframes boot-logo-float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-5px); }
}
@keyframes boot-ring-pulse {
  0% { transform: scale(0.82); opacity: 0.75; }
  70%, 100% { transform: scale(1.18); opacity: 0; }
}
@keyframes boot-dot-bounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.45; }
  40% { transform: translateY(-6px); opacity: 1; }
}
@keyframes boot-content-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

.nkbk-ai-welcome-glow {

  position: absolute;

  inset: -40% -20% auto;

  height: 120px;

  background: radial-gradient(circle, rgba(0,229,184,0.15), transparent 70%);

  pointer-events: none;

}

.nkbk-ai-welcome-icon {

  position: relative;

  font-size: 2.2rem;

  margin-bottom: 10px;

  filter: drop-shadow(0 0 12px rgba(0,229,184,0.3));

}

.nkbk-ai-welcome-title {

  position: relative;

  margin: 0 0 8px;

  font-size: 1.12rem;

  font-weight: 700;

  letter-spacing: -0.01em;

  line-height: 1.45;

  padding-top: 0.1em;

  overflow: visible;

}

.nkbk-ai-app.is-landing .nkbk-ai-welcome-title {
  font-size: clamp(1.65rem, 4vw, 2rem);
  font-weight: 600;
  margin: 0;
  color: var(--text);
  line-height: 1.5;
  padding: 0.14em 0.06em 0.08em;
  overflow: visible;
  display: inline-block;
  max-width: 100%;
  background: linear-gradient(120deg, var(--text) 0%, #10a37f 55%, var(--text) 100%);
  background-size: 200% auto;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
  animation: welcome-shimmer 4s ease-in-out infinite;
}
@keyframes welcome-shimmer {
  0%, 100% { background-position: 0% center; }
  50% { background-position: 100% center; }
}

.nkbk-ai-app.is-landing .nkbk-ai-welcome-title.is-loading {
  background: none;
  -webkit-text-fill-color: unset;
  animation: none;
}

.nkbk-ai-welcome-loading-dots {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 1.15em;
}

.nkbk-ai-welcome-loading-dots .dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #10a37f;
  animation: nkbk-bounce 1.2s infinite;
}

.nkbk-ai-welcome-loading-dots .dot:nth-child(2) { animation-delay: 0.15s; }
.nkbk-ai-welcome-loading-dots .dot:nth-child(3) { animation-delay: 0.3s; }

body.theme-dark .nkbk-ai-welcome-loading-dots .dot {
  background: #34d399;
}
body.theme-dark .nkbk-ai-app.is-landing .nkbk-ai-welcome-title {
  background: linear-gradient(120deg, #ececec 0%, #34d399 55%, #ececec 100%);
  background-size: 200% auto;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.nkbk-ai-welcome-hints {

  position: relative;

  margin: 0 0 18px;

  font-size: 0.84rem;

  color: var(--muted);

  line-height: 1.55;

}

.nkbk-ai-welcome-chips {

  position: relative;

  display: flex;

  flex-wrap: wrap;

  gap: 8px;

  justify-content: center;

}

.nkbk-ai-chip {

  border: 1px solid var(--border);

  background: rgba(255,255,255,0.04);

  color: var(--text);

  border-radius: 999px;

  padding: 7px 14px;

  font-size: 0.78rem;

  cursor: pointer;

  transition: all 0.15s;

}

.nkbk-ai-chip:hover {

  background: var(--accent-dim);

  border-color: var(--border-strong);

  transform: translateY(-1px);

}



/* ── Message bubbles ── */

.nkbk-ai-msg {

  display: flex;

  gap: 10px;

  max-width: 768px;

  width: 100%;

  animation: nkbk-fade-in 0.28s ease;

}

@keyframes nkbk-fade-in {

  from { opacity: 0; transform: translateY(8px); }

  to { opacity: 1; transform: translateY(0); }

}

.nkbk-ai-msg--assistant {
  align-self: center;
  max-width: 768px;
}

.nkbk-ai-msg--user {
  align-self: flex-end;
  flex-direction: row-reverse;
  width: auto;
  max-width: min(768px, 100%);
}

.nkbk-ai-msg--user .nkbk-ai-msg-body {
  width: fit-content;
  max-width: 88%;
  margin-left: auto;
}

.nkbk-ai-msg--user.is-editing {
  align-self: center;
  width: 100%;
  max-width: 768px;
}

.nkbk-ai-msg--user.is-editing .nkbk-ai-msg-body {
  max-width: 88%;
  width: 100%;
}

.nkbk-ai-msg--assistant .nkbk-ai-msg-content {
  max-width: 100%;
}



.nkbk-ai-msg-avatar {

  width: 32px;

  height: 32px;

  border-radius: 50%;

  flex-shrink: 0;

  align-self: flex-start;

  display: flex;

  align-items: center;

  justify-content: center;

  font-size: 0.82rem;

  margin-top: 2px;

}

.nkbk-ai-msg--user .nkbk-ai-msg-avatar--user {

  background: linear-gradient(135deg, #2563eb, #0891b2);

  color: #fff;

}

.nkbk-ai-msg-avatar--user svg {

  width: 17px;

  height: 17px;

  fill: currentColor;

}

.nkbk-ai-msg--user .nkbk-ai-msg-avatar--user.has-photo {
  background: none;
  padding: 0;
  overflow: hidden;
}

.nkbk-ai-msg--user .nkbk-ai-msg-avatar--user.has-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.nkbk-ai-msg-body {

  display: flex;

  flex-direction: column;

  align-items: flex-end;

  gap: 5px;

  min-width: 0;

  max-width: 100%;

}

.nkbk-ai-msg-callname {

  font-size: 0.72rem;

  font-weight: 600;

  color: rgba(147, 197, 253, 0.95);

  padding: 0 6px;

  line-height: 1.2;

  max-width: min(280px, 100%);

  overflow: hidden;

  text-overflow: ellipsis;

  white-space: nowrap;

}

body.theme-light .nkbk-ai-msg-callname { color: #6e6e80; }

.nkbk-ai-msg--assistant .nkbk-ai-msg-avatar {

  background: var(--accent-dim);

  border: 1px solid rgba(0,229,184,0.25);

}

.nkbk-ai-msg--assistant .nkbk-ai-msg-avatar img {

  width: 18px;

  height: 18px;

}



.nkbk-ai-bubble {

  padding: 13px 16px;

  border-radius: var(--radius-md);

  font-size: 0.93rem;

  line-height: 1.58;

  word-break: break-word;

  box-shadow: var(--shadow);

  display: flex;

  flex-direction: column;

}

.nkbk-ai-msg--user .nkbk-ai-bubble {

  background: var(--user-bg);

  border-bottom-right-radius: 4px;

  color: var(--user-text, #0d0d0d);

  border: 1px solid var(--user-border, rgba(0, 0, 0, 0.08));

  box-shadow: none;

}

.nkbk-ai-msg--assistant .nkbk-ai-bubble {

  background: var(--assistant-bg);

  border: 1px solid var(--border);

  border-bottom-left-radius: 4px;

  backdrop-filter: blur(8px);

}

.nkbk-ai-text-wrap {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.nkbk-ai-text { white-space: pre-wrap; }

.nkbk-ai-text-wrap .nkbk-ai-text.is-collapsed {
  max-height: 168px;
  overflow: hidden;
  mask-image: linear-gradient(to bottom, #000 65%, transparent);
  -webkit-mask-image: linear-gradient(to bottom, #000 65%, transparent);
}

.nkbk-ai-expand-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 6px;
  padding: 2px 0;
  border: none;
  background: none;
  color: var(--muted);
  font: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  position: relative;
  z-index: 1;
}

.nkbk-ai-expand-btn:hover { color: var(--accent); }

body.theme-dark .nkbk-ai-msg--user .nkbk-ai-expand-btn {
  color: #d4d4d8;
}

body.theme-dark .nkbk-ai-msg--user .nkbk-ai-expand-btn:hover {
  color: #fff;
}

body.theme-dark .nkbk-ai-msg--assistant .nkbk-ai-expand-btn {
  color: #a1a1aa;
}

body.theme-dark .nkbk-ai-msg--assistant .nkbk-ai-expand-btn:hover {
  color: var(--accent);
}

.nkbk-ai-expand-btn svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.nkbk-ai-bubble--image-only {
  padding: 0;
  border: none;
  background: transparent !important;
  box-shadow: none !important;
  overflow: visible;
  width: fit-content;
  max-width: min(100%, 480px);
}

.nkbk-ai-bubble--image-only .nkbk-ai-gallery {
  gap: 0;
  width: fit-content;
  max-width: 100%;
}

.nkbk-ai-bubble--image-only .nkbk-ai-image-card {
  border: none;
  border-radius: 12px;
  background: transparent !important;
  width: fit-content;
  max-width: min(100%, 480px);
  display: inline-block;
}

.nkbk-ai-msg--assistant .nkbk-ai-bubble--image-only .nkbk-ai-image-card img {
  display: block;
  width: auto;
  max-width: min(100%, 480px);
  height: auto;
  border-radius: 12px;
  border: none;
  background: transparent;
}

.nkbk-ai-msg--user .nkbk-ai-bubble--image-only {
  padding: 0;
  border: none;
  background: transparent !important;
  box-shadow: none !important;
  overflow: visible;
  width: fit-content;
  max-width: min(100%, 432px);
}

.nkbk-ai-msg--user .nkbk-ai-bubble--image-only .nkbk-ai-gallery {
  gap: 0;
  width: fit-content;
  max-width: 100%;
}

.nkbk-ai-msg--user .nkbk-ai-bubble--image-only .nkbk-ai-image-card {
  border: none;
  border-radius: 12px;
  background: transparent !important;
  width: fit-content;
  max-width: min(100%, 432px);
  display: inline-block;
}

.nkbk-ai-msg--user .nkbk-ai-bubble--image-only .nkbk-ai-image-card img {
  display: block;
  width: auto;
  max-width: min(100%, 432px);
  height: auto;
  border-radius: 12px;
  background: transparent;
}

body.theme-light .nkbk-ai-msg--user .nkbk-ai-bubble--image-only .nkbk-ai-image-card {
  background: transparent !important;
  border: none;
}

body.theme-light .nkbk-ai-msg--assistant .nkbk-ai-bubble--image-only {
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
}

body.theme-light .nkbk-ai-msg--assistant .nkbk-ai-bubble--image-only .nkbk-ai-image-card {
  background: transparent !important;
}

body.theme-light .nkbk-ai-msg--assistant .nkbk-ai-bubble--image-only .nkbk-ai-image-card img {
  background: transparent;
  border: none;
}

/* User-uploaded images: shrink-wrap to image — no white letterbox beside the photo */
.nkbk-ai-msg--user .nkbk-ai-bubble--with-user-image .nkbk-ai-gallery {
  width: fit-content;
  max-width: 100%;
  align-self: flex-end;
}

.nkbk-ai-msg--user .nkbk-ai-bubble--with-user-image .nkbk-ai-image-card {
  width: fit-content;
  max-width: min(100%, 432px);
  display: inline-block;
  background: transparent !important;
  border: none;
  box-shadow: none;
}

.nkbk-ai-msg--user .nkbk-ai-bubble--with-user-image .nkbk-ai-image-card img {
  display: block;
  width: auto;
  max-width: min(100%, 432px);
  height: auto;
  max-height: min(63vh, 576px);
  object-fit: unset;
  border-radius: 12px;
  background: transparent;
}

.nkbk-ai-msg--user .nkbk-ai-bubble--with-user-image:not(.nkbk-ai-bubble--image-only) {
  padding: 0;
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  gap: 8px;
  align-items: flex-end;
}

.nkbk-ai-msg--user .nkbk-ai-bubble--with-user-image:not(.nkbk-ai-bubble--image-only) .nkbk-ai-gallery {
  margin-bottom: 0;
  align-self: flex-end;
}

.nkbk-ai-msg--user .nkbk-ai-bubble--with-user-image:not(.nkbk-ai-bubble--image-only) .nkbk-ai-text-wrap {
  padding: 13px 16px;
  border-radius: var(--radius-md);
  border-bottom-right-radius: 4px;
  background: var(--user-bg);
  border: 1px solid var(--user-border, rgba(0, 0, 0, 0.08));
  box-shadow: none;
  width: fit-content;
  max-width: 100%;
  align-self: flex-end;
}

body.theme-light .nkbk-ai-msg--user .nkbk-ai-bubble--with-user-image:not(.nkbk-ai-bubble--image-only) {
  background: transparent !important;
  border: none !important;
}

body.theme-light .nkbk-ai-msg--user .nkbk-ai-bubble--with-user-image:not(.nkbk-ai-bubble--image-only) .nkbk-ai-text-wrap {
  background: #ececf1;
  border-color: rgba(0, 0, 0, 0.06);
  color: #0d0d0d;
}

body.theme-light .nkbk-ai-msg--user .nkbk-ai-bubble--with-user-image .nkbk-ai-image-card {
  background: transparent !important;
  border: none;
}

.nkbk-ai-inline-edit {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  min-width: 0;
}

.nkbk-ai-inline-edit-input {
  width: 100%;
  min-height: 120px;
  max-height: 480px;
  padding: 13px 16px;
  border: none;
  border-radius: 16px;
  background: #ececec;
  color: #0d0d0d;
  font: inherit;
  font-size: 0.93rem;
  line-height: 1.58;
  resize: none;
  box-sizing: border-box;
}

.nkbk-ai-inline-edit-input:focus {
  outline: none;
  box-shadow: 0 0 0 2px rgba(16, 163, 127, 0.25);
}

.nkbk-ai-inline-edit-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.nkbk-ai-inline-edit-cancel {
  border: none;
  background: transparent;
  color: #0d0d0d;
  font: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  padding: 8px 14px;
  border-radius: 999px;
  cursor: pointer;
}

.nkbk-ai-inline-edit-cancel:hover {
  background: rgba(0, 0, 0, 0.06);
}

.nkbk-ai-inline-edit-send {
  border: none;
  background: #0d0d0d;
  color: #fff;
  font: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  padding: 8px 18px;
  border-radius: 999px;
  cursor: pointer;
}

.nkbk-ai-inline-edit-send:hover {
  background: #262626;
}

body.theme-dark .nkbk-ai-inline-edit-input {
  background: #2a2a2e;
  color: #f4f4f5;
}

body.theme-dark .nkbk-ai-inline-edit-input:focus {
  box-shadow: 0 0 0 2px rgba(0, 229, 184, 0.35);
}

body.theme-dark .nkbk-ai-inline-edit-cancel {
  color: #e4e4e7;
}

body.theme-dark .nkbk-ai-inline-edit-cancel:hover {
  background: rgba(255, 255, 255, 0.08);
}

body.theme-dark .nkbk-ai-inline-edit-send {
  background: #fff;
  color: #0d0d0d;
}

body.theme-dark .nkbk-ai-inline-edit-send:hover {
  background: #e4e4e7;
}

.nkbk-ai-msg.is-editing .nkbk-ai-msg-actions {
  display: none;
}

.nkbk-ai-msg-view.hidden {
  display: none;
}

.nkbk-ai-msg-content {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  max-width: 100%;
  flex: 1;
}

.nkbk-ai-msg--user .nkbk-ai-msg-content {
  flex: 0 1 auto;
  width: fit-content;
  max-width: 100%;
}

.nkbk-ai-msg--user .nkbk-ai-bubble {
  width: fit-content;
  max-width: 100%;
}

.nkbk-ai-msg-actions {
  display: flex;
  gap: 2px;
  align-items: center;
  opacity: 0;
  transition: opacity 0.15s ease;
  padding: 0 2px;
}

.nkbk-ai-msg:hover .nkbk-ai-msg-actions,
.nkbk-ai-msg-actions:focus-within {
  opacity: 1;
}

.nkbk-ai-msg--user .nkbk-ai-msg-actions {
  justify-content: flex-end;
}

.nkbk-ai-msg-action-btn {
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: #6e6e80;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease, color 0.15s ease;
}

.nkbk-ai-msg-action-btn:hover {
  background: rgba(0, 0, 0, 0.06);
  color: #0d0d0d;
}

.nkbk-ai-msg-action-btn svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.nkbk-ai-msg-action-btn.is-copied {
  color: #10a37f;
}

@media (hover: none) {
  .nkbk-ai-msg-actions {
    opacity: 1;
  }
}

.nkbk-ai-prompt-used {
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(15, 23, 42, 0.35);
  border: 1px dashed rgba(148, 163, 184, 0.35);
}

.nkbk-ai-prompt-used-label {
  font-size: 0.72rem;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: #94a3b8;
  margin-bottom: 6px;
}

.nkbk-ai-prompt-used-text {
  font-size: 0.82rem;
  line-height: 1.45;
  color: #cbd5e1;
  white-space: pre-wrap;
  max-height: 120px;
  overflow: auto;
}

body.theme-light .nkbk-ai-msg-action-btn {
  color: #6e6e80;
}

body.theme-light .nkbk-ai-msg-action-btn:hover {
  background: rgba(0, 0, 0, 0.06);
  color: #0d0d0d;
}

body.theme-light .nkbk-ai-prompt-used {
  background: rgba(241, 245, 249, 0.9);
  border-color: rgba(148, 163, 184, 0.45);
}

body.theme-light .nkbk-ai-prompt-used-text {
  color: #334155;
}

/* ข้อความแก้ไขรูป — อ้างอิง thumb + ลูกศร */
.nkbk-ai-edit-ref {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0;
  margin: 0 0 4px;
  max-width: 100%;
  padding-right: 2px;
}
.nkbk-ai-edit-ref-thumb {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid rgba(0, 0, 0, 0.06);
  background: #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
  flex-shrink: 0;
}
body.theme-dark .nkbk-ai-edit-ref-thumb {
  background: #2f2f2f;
  border-color: rgba(255, 255, 255, 0.08);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
}
.nkbk-ai-edit-ref-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.nkbk-ai-edit-ref-arrow {
  display: flex;
  justify-content: flex-end;
  width: 48px;
  height: 32px;
  margin: 0 0 4px;
  line-height: 0;
}
.nkbk-ai-edit-ref-arrow img {
  width: auto;
  height: 30px;
  max-width: 36px;
  display: block;
  object-fit: contain;
  opacity: 0.85;
}
body.theme-dark .nkbk-ai-edit-ref-arrow img { opacity: 0.92; }

.nkbk-ai-edit-extras {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
  margin: 0 0 6px;
  padding-right: 2px;
}
.nkbk-ai-edit-extra-thumb {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid rgba(0, 0, 0, 0.08);
  background: #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
  flex-shrink: 0;
}
body.theme-dark .nkbk-ai-edit-extra-thumb {
  background: #2f2f2f;
  border-color: rgba(255, 255, 255, 0.08);
}
.nkbk-ai-edit-extra-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.nkbk-ai-user-attach-thumbs {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
  margin: 0 0 6px;
  padding-right: 2px;
}
.nkbk-ai-user-attach-thumb {
  width: 48px;
  height: 48px;
  padding: 0;
  border: none;
  border-radius: 10px;
  overflow: hidden;
  cursor: pointer;
  background: #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
  flex-shrink: 0;
}
body.theme-dark .nkbk-ai-user-attach-thumb {
  background: #2f2f2f;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
}
.nkbk-ai-user-attach-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.nkbk-ai-attach-preview.is-compact {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0 8px 8px;
}
.nkbk-ai-attach-preview.is-compact .nkbk-ai-attach-chip {
  width: 52px;
  height: 52px;
}
.nkbk-ai-attach-preview.is-compact .nkbk-ai-attach-chip--doc {
  width: auto;
  min-width: 96px;
  max-width: 132px;
  height: 52px;
  padding: 6px 24px 6px 8px;
}
.nkbk-ai-viewer.is-edit-mode .nkbk-ai-viewer-composer-inner textarea::placeholder {
  color: #6e6e80;
}

.nkbk-ai-text:not(:first-child) { margin-top: 10px; }



/* ── Image gallery ── */

.nkbk-ai-gallery {

  display: flex;

  flex-direction: column;

  gap: 10px;

}

.nkbk-ai-image-card {

  position: relative;

  border-radius: var(--radius-md);

  overflow: hidden;

  border: 1px solid rgba(255,255,255,0.1);

  background: #0a0e13;

}

.nkbk-ai-image-card img {

  display: block;

  position: relative;

  z-index: 0;

  width: 100%;

  max-width: min(100%, 520px);

  height: auto;

  max-height: min(70vh, 640px);

  object-fit: contain;

  cursor: zoom-in;

  transition: transform 0.2s;

  background: transparent;

}

.nkbk-ai-image-card img:hover { transform: scale(1.01); }

.nkbk-ai-image-hover {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.nkbk-ai-image-edit-btn {
  position: absolute;
  left: 10px;
  bottom: 10px;
  border: none;
  border-radius: 999px;
  padding: 7px 14px;
  background: rgba(15, 15, 15, 0.72);
  color: #fff;
  font: inherit;
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  opacity: 0;
  pointer-events: auto;
  transition: opacity 0.15s ease, background 0.15s ease;
}

.nkbk-ai-image-edit-btn:hover {
  background: rgba(15, 15, 15, 0.88);
}

.nkbk-ai-image-dl-btn {
  position: absolute;
  right: 10px;
  bottom: 10px;
  width: 34px;
  height: 34px;
  border: none;
  border-radius: 10px;
  background: rgba(15, 15, 15, 0.72);
  color: #fff;
  cursor: pointer;
  opacity: 0;
  pointer-events: auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.15s ease, background 0.15s ease;
}

.nkbk-ai-image-edit-btn,
.nkbk-ai-image-dl-btn {
  z-index: 2;
}

.nkbk-ai-image-dl-btn svg {
  width: 18px;
  height: 18px;
}

.nkbk-ai-image-dl-btn:hover {
  background: rgba(15, 15, 15, 0.88);
}

.nkbk-ai-image-card:hover .nkbk-ai-image-edit-btn,
.nkbk-ai-image-card:hover .nkbk-ai-image-dl-btn {
  opacity: 1;
}

@media (hover: none) {
  .nkbk-ai-image-edit-btn,
  .nkbk-ai-image-dl-btn {
    opacity: 1;
  }
}

.nkbk-ai-image-actions {

  display: flex;

  gap: 8px;

  padding: 8px 10px;

  background: rgba(0,0,0,0.5);

  border-top: 1px solid rgba(255,255,255,0.06);

}

.nkbk-ai-img-btn {

  border: none;

  background: rgba(0, 229, 184, 0.18);

  color: #a7f3e8;

  border-radius: 8px;

  padding: 6px 12px;

  font-size: 0.78rem;

  cursor: pointer;

  font-weight: 600;

  transition: background 0.15s;

}

.nkbk-ai-img-btn:hover { background: rgba(0, 229, 184, 0.3); }



/* ── Typing ── */

.nkbk-ai-msg--typing .dot {

  display: inline-block;

  width: 7px;

  height: 7px;

  margin: 0 2px;

  background: var(--muted);

  border-radius: 50%;

  animation: nkbk-bounce 1.2s infinite;

}

.nkbk-ai-msg--typing .dot:nth-child(2) { animation-delay: 0.15s; }

.nkbk-ai-msg--typing .dot:nth-child(3) { animation-delay: 0.3s; }

@keyframes nkbk-bounce {

  0%, 80%, 100% { transform: translateY(0); opacity: 0.4; }

  40% { transform: translateY(-5px); opacity: 1; }

}



.nkbk-ai-bubble--generating {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 12px;
  padding: 14px;
  min-width: 220px;
  max-width: 280px;
  background: linear-gradient(145deg, rgba(16, 163, 127, 0.04), rgba(255, 255, 255, 0.95));
  border: 1px solid rgba(16, 163, 127, 0.12);
  box-shadow: 0 8px 28px rgba(16, 163, 127, 0.08);
}
body.theme-dark .nkbk-ai-bubble--generating {
  background: linear-gradient(145deg, rgba(16, 163, 127, 0.08), rgba(47, 47, 47, 0.98));
  border-color: rgba(16, 163, 127, 0.18);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.25);
}
.nkbk-ai-gen-preview {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  border-radius: 14px;
  overflow: hidden;
  background:
    linear-gradient(135deg, rgba(16, 163, 127, 0.12) 0%, rgba(99, 102, 241, 0.08) 50%, rgba(16, 163, 127, 0.06) 100%);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.35);
}
body.theme-dark .nkbk-ai-gen-preview {
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06);
}
.nkbk-ai-gen-shimmer {
  position: absolute;
  inset: -40%;
  background: linear-gradient(
    105deg,
    transparent 38%,
    rgba(255, 255, 255, 0.55) 48%,
    rgba(255, 255, 255, 0.75) 50%,
    rgba(255, 255, 255, 0.55) 52%,
    transparent 62%
  );
  animation: nkbk-gen-shimmer 2.2s ease-in-out infinite;
}
body.theme-dark .nkbk-ai-gen-shimmer {
  background: linear-gradient(
    105deg,
    transparent 38%,
    rgba(255, 255, 255, 0.08) 48%,
    rgba(255, 255, 255, 0.14) 50%,
    rgba(255, 255, 255, 0.08) 52%,
    transparent 62%
  );
}
.nkbk-ai-gen-shimmer--delay { animation-delay: 1.1s; opacity: 0.7; }
.nkbk-ai-gen-orbit {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.nkbk-ai-gen-orbit span {
  position: absolute;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #10a37f;
  box-shadow: 0 0 12px rgba(16, 163, 127, 0.55);
  animation: nkbk-gen-orbit 2.4s ease-in-out infinite;
}
.nkbk-ai-gen-orbit span:nth-child(1) { animation-delay: 0s; }
.nkbk-ai-gen-orbit span:nth-child(2) { animation-delay: 0.35s; opacity: 0.75; }
.nkbk-ai-gen-orbit span:nth-child(3) { animation-delay: 0.7s; opacity: 0.5; }
.nkbk-ai-gen-meta {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.nkbk-ai-gen-label {
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--text);
  letter-spacing: -0.01em;
}
.nkbk-ai-gen-bar {
  height: 3px;
  border-radius: 999px;
  background: rgba(16, 163, 127, 0.14);
  overflow: hidden;
}
.nkbk-ai-gen-bar span {
  display: block;
  height: 100%;
  width: 38%;
  border-radius: inherit;
  background: linear-gradient(90deg, #10a37f, #34d399);
  animation: nkbk-gen-bar 1.8s ease-in-out infinite;
}
@keyframes nkbk-gen-shimmer {
  0% { transform: translateX(-55%) rotate(8deg); }
  100% { transform: translateX(55%) rotate(8deg); }
}
@keyframes nkbk-gen-orbit {
  0%, 100% { transform: translate(0, 0) scale(0.85); opacity: 0.35; }
  50% { transform: translate(0, -14px) scale(1); opacity: 1; }
}
@keyframes nkbk-gen-bar {
  0% { transform: translateX(-120%); }
  100% { transform: translateX(320%); }
}

.nkbk-ai-gen-spinner {

  width: 18px;

  height: 18px;

  border: 2px solid rgba(0,229,184,0.25);

  border-top-color: var(--accent);

  border-radius: 50%;

  animation: nkbk-spin 0.8s linear infinite;

}

@keyframes nkbk-spin { to { transform: rotate(360deg); } }



/* ── Composer ── */

.nkbk-ai-composer-wrap {

  border-top: 1px solid var(--border);

  background: rgba(10, 14, 20, 0.92);

  backdrop-filter: blur(14px);

  padding: 0 16px 16px;

}



.nkbk-ai-attach-preview {

  display: flex;

  flex-wrap: wrap;

  gap: 8px;

  padding: 0 8px 8px;

  width: 100%;

}

.nkbk-ai-attach-chip {

  position: relative;

  width: 68px;

  height: 68px;

  border-radius: var(--radius-sm);

  overflow: hidden;

  border: 1px solid var(--border-strong);

  box-shadow: 0 4px 12px rgba(0,0,0,0.3);

}

.nkbk-ai-attach-chip img { width: 100%; height: 100%; object-fit: cover; }

.nkbk-ai-attach-chip--doc {
  width: auto;
  min-width: 132px;
  max-width: 180px;
  height: 68px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 4px;
  padding: 8px 28px 8px 10px;
  background: rgba(255,255,255,0.06);
}

.nkbk-ai-attach-doc-badge {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--accent);
}

.nkbk-ai-attach-doc-name {
  font-size: 0.72rem;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

body.theme-light .nkbk-ai-attach-chip--doc {
  background: #f7f7f8;
}

.nkbk-ai-attach-remove {

  position: absolute;

  top: 3px;

  right: 3px;

  width: 20px;

  height: 20px;

  border: none;

  border-radius: 50%;

  background: rgba(0,0,0,0.7);

  color: #fff;

  cursor: pointer;

  font-size: 14px;

  line-height: 1;

}



.nkbk-ai-composer {

  display: flex;

  align-items: center;

  gap: 10px;

  padding: 10px 12px;

  border-radius: var(--radius-lg);

  border: 1px solid var(--border);

  background: rgba(255,255,255,0.025);

  box-shadow: inset 0 1px 0 rgba(255,255,255,0.04);

}



.nkbk-ai-composer-tools {

  display: flex;

  flex-direction: column;

  gap: 6px;

  flex-shrink: 0;

}



.nkbk-ai-composer-input {

  flex: 1;

  min-width: 0;

}



.nkbk-ai-btn-icon {

  width: 40px;

  height: 40px;

  border: 1px solid var(--border);

  border-radius: 12px;

  background: rgba(255,255,255,0.04);

  color: var(--text);

  font-size: 1.05rem;

  cursor: pointer;

  flex-shrink: 0;

  transition: all 0.15s;

}

.nkbk-ai-btn-icon:hover { background: rgba(255,255,255,0.08); }

.nkbk-ai-btn-icon--accent.active,

.nkbk-ai-btn-icon--accent:hover {

  background: var(--accent-dim);

  border-color: var(--border-strong);

  box-shadow: 0 0 18px var(--accent-glow);

}



.nkbk-ai-composer textarea {

  width: 100%;

  resize: none;

  border: none;

  border-radius: 0;

  background: transparent;

  color: var(--text);

  padding: 8px 4px;

  font: inherit;

  line-height: 1.45;

  min-height: 24px;

  max-height: 320px;

  overflow-x: hidden;

  overflow-y: hidden;

}

.nkbk-ai-composer textarea:focus { outline: none; }

.nkbk-ai-composer:focus-within {

  border-color: var(--border-strong);

  box-shadow: 0 0 0 3px rgba(0,229,184,0.1), inset 0 1px 0 rgba(255,255,255,0.04);

}



.nkbk-ai-btn-send {

  width: 44px;

  height: 44px;

  border: none;

  border-radius: 14px;

  background: linear-gradient(135deg, var(--accent), var(--accent-2));

  color: #042;

  cursor: pointer;

  flex-shrink: 0;

  display: flex;

  align-items: center;

  justify-content: center;

  box-shadow: 0 4px 20px rgba(0,229,184,0.35);

  transition: transform 0.12s, opacity 0.12s, box-shadow 0.15s;

}

.nkbk-ai-btn-send:hover:not(:disabled) {

  transform: scale(1.05);

  box-shadow: 0 6px 24px rgba(0,229,184,0.45);

}

.nkbk-ai-btn-send:active:not(:disabled),
.nkbk-ai-btn-send.is-pressed:not(:disabled) {
  transform: scale(0.94);
  filter: brightness(0.94);
  box-shadow: 0 2px 10px rgba(0,229,184,0.25);
}

.nkbk-ai-btn-send:disabled {

  opacity: 0.3;

  cursor: not-allowed;

  box-shadow: none;

}



/* ── Call name inside field box (shared with settings) ── */

.nkbk-field-stack {

  display: flex;

  flex-direction: column;

  border: 1px solid var(--border);

  border-radius: var(--radius-md);

  overflow: hidden;

  background: var(--bg);

}

.nkbk-callname-inbox {

  display: flex;

  align-items: center;

  gap: 10px;

  padding: 10px 14px;

  background: linear-gradient(90deg, rgba(0,229,184,0.1), rgba(0,229,184,0.04));

  border-bottom: 1px solid rgba(0,229,184,0.18);

}

.nkbk-callname-icon { font-size: 1rem; flex-shrink: 0; }

.nkbk-callname-copy { flex: 1; min-width: 0; }

.nkbk-callname-label {

  display: block;

  font-size: 0.68rem;

  color: var(--muted);

  text-transform: uppercase;

  letter-spacing: 0.04em;

  margin-bottom: 2px;

}

.nkbk-callname-value {

  display: block;

  font-size: 0.95rem;

  font-weight: 700;

  color: #a7f3e8;

}

.nkbk-callname-note {

  font-size: 0.68rem;

  color: var(--muted);

  white-space: nowrap;

}

.nkbk-field-stack textarea {

  width: 100%;

  border: none;

  border-radius: 0;

  background: transparent;

  color: var(--text);

  padding: 12px 14px;

  font: inherit;

  line-height: 1.5;

  resize: vertical;

  min-height: 100px;

}

.nkbk-field-stack textarea:focus { outline: none; }



/* ── Modal ── */

.nkbk-ai-modal {

  position: fixed;

  inset: 0;

  z-index: 100;

  display: flex;

  align-items: center;

  justify-content: center;

  opacity: 0;

  pointer-events: none;

  transition: opacity 0.2s;

  font-family: 'Inter', 'Noto Sans Thai', system-ui, -apple-system, sans-serif;

}

.nkbk-ai-modal.open { opacity: 1; pointer-events: auto; }

.nkbk-ai-modal.is-stack { z-index: 1100; }

.nkbk-ai-modal-panel {
  position: relative;
  z-index: 1;
  width: min(560px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.nkbk-ai-modal-backdrop {

  position: absolute;

  inset: 0;

  background: rgba(0,0,0,0.65);

  backdrop-filter: blur(6px);

}

.nkbk-ai-modal-box {

  position: relative;

  width: min(500px, calc(100vw - 32px));

  background: var(--surface);

  border: 1px solid var(--border);

  border-radius: var(--radius-lg);

  overflow: hidden;

  box-shadow: var(--shadow);

}

.nkbk-ai-modal-head {

  display: flex;

  align-items: center;

  justify-content: space-between;

  padding: 16px 18px;

  border-bottom: 1px solid var(--border);

  background: rgba(255,255,255,0.02);

}

.nkbk-ai-modal-head h2 { margin: 0; font-size: 1rem; font-weight: 700; }

.nkbk-ai-modal-close {

  border: none;

  background: transparent;

  color: var(--muted);

  font-size: 1.4rem;

  cursor: pointer;

  line-height: 1;

}

.nkbk-ai-modal-body { padding: 16px 18px; }

.nkbk-ai-modal-foot {

  display: flex;

  justify-content: flex-end;

  gap: 8px;

  padding: 12px 18px 18px;

}

.nkbk-ai-btn-primary {

  border: none;

  background: linear-gradient(135deg, var(--accent), var(--accent-2));

  color: #042;

  border-radius: var(--radius-sm);

  padding: 9px 18px;

  font-weight: 700;

  cursor: pointer;

  transition: transform 0.14s ease, filter 0.14s ease, box-shadow 0.14s ease;

}

.nkbk-ai-btn-primary:hover { transform: translateY(-1px); }

.nkbk-ai-btn-primary:active:not(:disabled),
.nkbk-ai-btn-primary.is-pressed:not(:disabled) {
  transform: scale(0.96) translateY(0);
  filter: brightness(0.94);
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.12);
}

.nkbk-ai-btn-primary:disabled {
  opacity: 0.72;
  cursor: wait;
  transform: none;
  filter: none;
}

.nkbk-ai-btn-primary.is-saving,
.nkbk-ai-btn-primary.is-saved {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: 7.5rem;
}

.nkbk-ai-btn-primary.is-saving {
  min-width: auto;
  padding-left: 14px;
  padding-right: 14px;
}

.nkbk-ai-btn-spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(4, 34, 34, 0.2);
  border-top-color: #042;
  border-radius: 50%;
  animation: nkbk-spin 0.65s linear infinite;
  flex-shrink: 0;
}

.nkbk-ai-btn-primary.is-saved {
  background: linear-gradient(135deg, #0d966f, #0a7d5c);
}



/* ── Lightbox ── */

.nkbk-ai-lightbox {

  position: fixed;

  inset: 0;

  z-index: 200;

  display: flex;

  align-items: center;

  justify-content: center;

  opacity: 0;

  pointer-events: none;

  transition: opacity 0.2s;

}

.nkbk-ai-lightbox.open { opacity: 1; pointer-events: auto; }

.nkbk-ai-lightbox-backdrop {

  position: absolute;

  inset: 0;

  background: rgba(0,0,0,0.88);

  backdrop-filter: blur(10px);

}

.nkbk-ai-lightbox-inner {

  position: relative;

  z-index: 1;

  max-width: min(92vw, 900px);

  max-height: 92vh;

  display: flex;

  flex-direction: column;

  align-items: center;

  gap: 14px;

}

.nkbk-ai-lightbox-inner img {

  max-width: 100%;

  max-height: calc(92vh - 60px);

  border-radius: var(--radius-md);

  box-shadow: var(--shadow);

}

.nkbk-ai-lightbox-actions { display: flex; gap: 10px; }



.muted { color: var(--muted); }



::-webkit-scrollbar { width: 7px; }

::-webkit-scrollbar-thumb {

  background: rgba(255,255,255,0.1);

  border-radius: 8px;

}

::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.16); }

/* overrides — title bar + single-row composer */
html, body { display: flex; flex-direction: column; overflow: hidden; }
body.electron .title-bar { display: flex; }
.title-bar {
  display: none; height: 36px; min-height: 36px;
  background: linear-gradient(180deg, #161a22 0%, #0d0f14 100%);
  border-bottom: 1px solid var(--border); align-items: center; justify-content: space-between; flex-shrink: 0;
}
.title-bar-drag { display: flex; align-items: center; padding-left: 12px; flex: 1; min-width: 0; -webkit-app-region: drag; }
.title-bar-title { font-size: 0.78rem; font-weight: 600; color: var(--muted); letter-spacing: 0.02em; }
.title-bar-controls { display: flex; -webkit-app-region: no-drag; }
.title-bar-btn {
  width: 46px; height: 36px; border: none; background: transparent; color: var(--muted);
  font-size: 1rem; cursor: pointer;
}
.title-bar-btn:hover { background: rgba(255,255,255,0.08); color: var(--text); }
.title-bar-btn-close:hover { background: #e81123; color: #fff; }
.nkbk-ai-app { flex: 1; min-height: 0; height: auto; }

/* ── GPT-style composer ── */
.nkbk-ai-composer-wrap {
  position: relative;
  padding: 8px 16px 16px;
  background: transparent;
  border-top: none;
}
.nkbk-ai-composer-shell {
  max-width: 768px;
  margin: 0 auto;
  width: 100%;
}
.nkbk-ai-composer-shell .nkbk-ai-attach-preview {
  padding: 0 6px 8px;
}
.nkbk-ai-composer-shell .nkbk-ai-attach-chip {
  border: 1px solid rgba(0, 0, 0, 0.1);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}
body.theme-dark .nkbk-ai-composer-shell .nkbk-ai-attach-chip,
body:not(.theme-light) .nkbk-ai-composer-shell .nkbk-ai-attach-chip {
  border-color: rgba(255, 255, 255, 0.12);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}
.nkbk-ai-composer {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 8px 6px 6px;
  border: 1px solid rgba(0, 0, 0, 0.12);
  border-radius: 28px;
  background: #fff;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.nkbk-ai-composer:focus-within {
  border-color: rgba(0, 0, 0, 0.18);
  box-shadow: 0 2px 16px rgba(0, 0, 0, 0.08);
}
.nkbk-ai-composer-plus {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  margin-bottom: 2px;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: #6e6e80;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
}
.nkbk-ai-composer-plus:hover {
  background: rgba(0, 0, 0, 0.06);
  color: #0d0d0d;
}
.nkbk-ai-composer textarea {
  flex: 1;
  min-width: 0;
  border: none !important;
  border-radius: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
  padding: 10px 4px !important;
  min-height: 24px !important;
  max-height: 320px !important;
  height: auto !important;
  line-height: 1.45 !important;
  font-size: 1rem;
  resize: none;
  overflow-x: hidden;
  field-sizing: content;
}
.nkbk-ai-composer textarea:focus {
  outline: none !important;
  border: none !important;
  box-shadow: none !important;
}
.nkbk-ai-composer-send {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  margin-bottom: 2px;
  border: none;
  border-radius: 50%;
  background: #0d0d0d;
  color: #fff;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.15s, transform 0.12s;
}
.nkbk-ai-composer-send:hover:not(:disabled) {
  transform: scale(1.04);
}
.nkbk-ai-composer-send:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}
.nkbk-ai-composer-modes {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
  padding: 0 4px;
}
.nkbk-ai-starter-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
  padding: 0 4px;
  justify-content: center;
}

.nkbk-ai-composer-disclaimer {
  margin: 6px 0 0;
  padding: 0 8px;
  text-align: center;
  font-size: 0.625rem;
  line-height: 1.4;
  color: var(--muted);
  opacity: 0.72;
  letter-spacing: 0.01em;
}

body.theme-light .nkbk-ai-composer-disclaimer {
  color: #8e8ea0;
  opacity: 1;
}
.nkbk-ai-starter-pill svg {
  flex-shrink: 0;
  color: #6e6e80;
}
.nkbk-ai-starter-pill:hover {
  background: #f7f7f8;
}
.nkbk-ai-starter-pill.is-active {
  background: #ecfdf5;
  border-color: #10a37f;
  color: #065f46;
}
.nkbk-ai-starter-pill.is-active svg {
  color: #10a37f;
}
body.theme-dark .nkbk-ai-starter-pill {
  background: #2f2f2f;
  border-color: rgba(255,255,255,0.12);
  color: #ececec;
}
body.theme-dark .nkbk-ai-starter-pill svg { color: #9ca3af; }
body.theme-dark .nkbk-ai-starter-pill:hover { background: #3a3a3a; }
body.theme-dark .nkbk-ai-starter-pill.is-active {
  background: rgba(16, 163, 127, 0.18);
  border-color: #10a37f;
  color: #6ee7b7;
}
.nkbk-ai-starter-pill,
.nkbk-ai-mode-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border: 1px solid rgba(0, 0, 0, 0.12);
  border-radius: 999px;
  background: #fff;
  color: #0d0d0d;
  font: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.nkbk-ai-mode-pill svg {
  flex-shrink: 0;
  color: #6e6e80;
}
.nkbk-ai-mode-pill:hover {
  background: #f7f7f8;
}
.nkbk-ai-mode-pill.is-active {
  background: #ecfdf5;
  border-color: #10a37f;
  color: #065f46;
}
.nkbk-ai-mode-pill.is-active svg {
  color: #10a37f;
}
.nkbk-ai-drop-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(8, 10, 14, 0.52);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.16s ease, visibility 0.16s ease;
}

.nkbk-ai-drop-overlay:not(.hidden) {
  opacity: 1;
  visibility: visible;
}

.nkbk-ai-drop-overlay-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 0;
  text-align: center;
  border: none;
  background: transparent;
  box-shadow: none;
}

.nkbk-ai-drop-overlay-icon {
  width: 56px;
  height: 56px;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.1);
  color: #f4f4f5;
  margin-bottom: 4px;
}

.nkbk-ai-drop-overlay-icon svg {
  width: 28px;
  height: 28px;
}

.nkbk-ai-drop-overlay-title {
  margin: 0;
  font-size: 1.125rem;
  font-weight: 600;
  color: #f4f4f5;
  letter-spacing: -0.01em;
}

.nkbk-ai-drop-overlay-hint {
  margin: 0;
  font-size: 0.875rem;
  color: #d4d4d8;
  max-width: 28rem;
  line-height: 1.45;
}

body.nkbk-ai-file-dragging .nkbk-ai-composer {
  border-color: rgba(0, 229, 184, 0.45);
  box-shadow: 0 0 0 3px rgba(0, 229, 184, 0.12);
}

body.theme-light .nkbk-ai-drop-overlay {
  background: rgba(255, 255, 255, 0.58);
}

body.theme-light .nkbk-ai-drop-overlay-icon {
  background: rgba(16, 163, 127, 0.14);
  color: #065f46;
}

body.theme-light .nkbk-ai-drop-overlay-title {
  color: #0d0d0d;
}

body.theme-light .nkbk-ai-drop-overlay-hint {
  color: #52525b;
}

body.theme-light.nkbk-ai-file-dragging .nkbk-ai-composer {
  border-color: rgba(16, 163, 127, 0.45);
  box-shadow: 0 0 0 3px rgba(16, 163, 127, 0.12);
}

.nkbk-ai-composer-wrap.is-dragover .nkbk-ai-composer,
.nkbk-ai-messages.is-dragover {
  outline: none;
}
body.theme-light .nkbk-ai-composer-wrap {
  background: transparent;
}
body.theme-dark .nkbk-ai-composer,
body:not(.theme-light) .nkbk-ai-composer {
  background: var(--surface);
  border-color: var(--border);
}
body.theme-dark .nkbk-ai-mode-pill,
body:not(.theme-light) .nkbk-ai-mode-pill {
  background: var(--surface);
  border-color: var(--border);
  color: var(--text);
}

.nkbk-ai-field-label { display: block; font-size: 0.82rem; font-weight: 600; margin: 0 0 8px; }
.nkbk-ai-field-label + .nkbk-field-stack { margin-bottom: 14px; }
.nkbk-field-stack--callname { margin-bottom: 14px; }
.nkbk-callname-input {
  width: 100%; border: none; background: transparent; color: var(--text);
  font: inherit; font-size: 1rem; font-weight: 600; padding: 12px 14px;
}
.nkbk-callname-input:focus { outline: none; }
.nkbk-callname-input::placeholder { color: var(--muted); font-weight: 400; }
.nkbk-field-stack input.nkbk-callname-input { padding: 12px 14px; }

.nkbk-ai-memory-files-section {
  margin-bottom: 18px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.015) 0%, transparent 100%);
}
body.theme-dark .nkbk-ai-memory-files-section {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.03) 0%, transparent 100%);
}
.nkbk-ai-memory-files-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 12px;
}
.nkbk-ai-memory-files-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 22px 16px;
  border: 1.5px dashed var(--border);
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.02);
}
body.theme-dark .nkbk-ai-memory-files-empty {
  background: rgba(255, 255, 255, 0.02);
}
.nkbk-ai-memory-files-empty-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.05);
  color: var(--muted);
  margin-bottom: 10px;
}
body.theme-dark .nkbk-ai-memory-files-empty-icon {
  background: rgba(255, 255, 255, 0.06);
}
.nkbk-ai-memory-files-empty-icon svg {
  width: 22px;
  height: 22px;
}
.nkbk-ai-memory-files-empty-title {
  margin: 0;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text);
}
.nkbk-ai-memory-files-empty-desc {
  margin: 4px 0 0;
  font-size: 0.8125rem;
  color: var(--muted);
  line-height: 1.45;
  max-width: 280px;
}
.nkbk-ai-memory-file-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface, #fff);
}
body.theme-dark .nkbk-ai-memory-file-item {
  background: rgba(255, 255, 255, 0.03);
}
.nkbk-ai-memory-file-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.05);
  color: var(--text);
  flex-shrink: 0;
  overflow: hidden;
}
.nkbk-ai-memory-file-icon--thumb {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.04);
  border: 1px solid var(--border);
}
.nkbk-ai-memory-file-thumb-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
body.theme-dark .nkbk-ai-memory-file-icon {
  background: rgba(255, 255, 255, 0.08);
}
.nkbk-ai-memory-file-icon svg {
  width: 18px;
  height: 18px;
}
.nkbk-ai-memory-file-main { min-width: 0; flex: 1; }
.nkbk-ai-memory-file-title {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.nkbk-ai-memory-file-sub { font-size: 0.75rem; color: var(--muted); margin-top: 2px; }
.nkbk-ai-memory-file-call {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}
.nkbk-ai-memory-file-call-label {
  display: inline;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 0;
  flex-shrink: 0;
  white-space: nowrap;
}
.nkbk-ai-memory-file-call-input {
  width: auto;
  min-width: 100px;
  max-width: 168px;
  flex: 0 1 140px;
  box-sizing: border-box;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg, rgba(0, 0, 0, 0.02));
  color: var(--text);
  font: inherit;
  font-size: 0.8125rem;
  padding: 7px 10px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.nkbk-ai-memory-file-call-input::placeholder {
  color: var(--muted);
  opacity: 0.85;
}
.nkbk-ai-memory-file-call-input:focus {
  outline: none;
  border-color: rgba(0, 168, 132, 0.45);
  box-shadow: 0 0 0 3px rgba(0, 229, 184, 0.12);
}
body.theme-dark .nkbk-ai-memory-file-call-input {
  background: rgba(255, 255, 255, 0.04);
}
.nkbk-ai-memory-file-remove {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s, color 0.15s;
}
.nkbk-ai-memory-file-remove svg {
  width: 16px;
  height: 16px;
}
.nkbk-ai-memory-file-remove:hover {
  background: rgba(255, 80, 80, 0.1);
  color: #e5484d;
}
.nkbk-ai-memory-files-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
@media (max-width: 520px) {
  .nkbk-ai-memory-files-actions {
    grid-template-columns: 1fr;
  }
}
.nkbk-ai-memory-action {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 1.5px solid var(--border);
  border-radius: 14px;
  background: var(--surface, #fff);
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s, transform 0.1s;
}
.nkbk-ai-memory-action:hover {
  border-color: rgba(0, 0, 0, 0.22);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.06);
}
.nkbk-ai-memory-action:active {
  transform: scale(0.99);
}
.nkbk-ai-memory-action.is-loading {
  opacity: 0.65;
  pointer-events: none;
}
body.theme-dark .nkbk-ai-memory-action {
  background: rgba(255, 255, 255, 0.03);
}
body.theme-dark .nkbk-ai-memory-action:hover {
  border-color: rgba(255, 255, 255, 0.22);
}
.nkbk-ai-memory-action--library {
  border-color: rgba(0, 229, 184, 0.35);
  background: rgba(0, 229, 184, 0.06);
}
.nkbk-ai-memory-action--library:hover {
  border-color: rgba(0, 229, 184, 0.55);
  background: rgba(0, 229, 184, 0.1);
}
.nkbk-ai-memory-action-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 11px;
  background: rgba(0, 0, 0, 0.05);
  flex-shrink: 0;
}
.nkbk-ai-memory-action--library .nkbk-ai-memory-action-icon {
  background: rgba(0, 229, 184, 0.14);
  color: #00a884;
}
body.theme-dark .nkbk-ai-memory-action--library .nkbk-ai-memory-action-icon {
  color: #00e5b8;
}
.nkbk-ai-memory-action-icon svg {
  width: 20px;
  height: 20px;
}
.nkbk-ai-memory-action-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.nkbk-ai-memory-action-label {
  font-size: 0.875rem;
  font-weight: 600;
}
.nkbk-ai-memory-action-desc {
  font-size: 0.75rem;
  color: var(--muted);
  line-height: 1.35;
}

.nkbk-ai-library-picker-panel {
  max-width: 640px;
  width: calc(100% - 32px);
  max-height: min(82vh, calc(100dvh - 24px));
  display: flex;
  flex-direction: column;
}
@media (max-width: 768px) {
  #nkbkAiLibraryPickerModal {
    align-items: center;
    justify-content: center;
    padding:
      max(16px, env(safe-area-inset-top, 0px))
      16px
      max(16px, env(safe-area-inset-bottom, 0px));
  }
  #nkbkAiLibraryPickerModal .nkbk-ai-library-picker-panel {
    width: min(400px, calc(100vw - 32px));
    max-width: calc(100vw - 32px);
    max-height: min(640px, calc(100dvh - 32px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px)));
    min-height: 0;
    margin: 0;
    border-radius: 16px;
    animation: nkbk-ai-composer-modal-in 0.28s cubic-bezier(0.32, 0.72, 0, 1);
  }
  .nkbk-ai-library-picker-list {
    max-height: none;
    flex: 1;
    min-height: 0;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .nkbk-ai-library-picker-foot {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    flex-shrink: 0;
  }
  .nkbk-ai-library-picker-foot-actions {
    width: 100%;
  }
  .nkbk-ai-library-picker-foot-actions .nkbk-ai-btn-ghost,
  .nkbk-ai-library-picker-foot-actions .nkbk-ai-btn-primary {
    flex: 1;
    justify-content: center;
  }
}
@media (max-width: 560px) {
  #nkbkAiLibraryPickerModal .nkbk-ai-library-picker-panel {
    width: calc(100vw - 32px);
    max-width: calc(100vw - 32px);
  }
}
.nkbk-ai-library-picker-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px 12px;
  border-bottom: 1px solid var(--border);
}
.nkbk-ai-library-picker-head h3 {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
}
.nkbk-ai-library-picker-sub {
  margin: 4px 0 0;
  font-size: 0.8125rem;
  color: var(--muted);
}
.nkbk-ai-library-picker-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
}
.nkbk-ai-library-picker-toolbar svg {
  width: 18px;
  height: 18px;
  color: var(--muted);
  flex-shrink: 0;
}
.nkbk-ai-library-picker-search {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 0.875rem;
  padding: 6px 0;
}
.nkbk-ai-library-picker-search:focus {
  outline: none;
}
.nkbk-ai-library-picker-list {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  min-height: 160px;
  max-height: 52vh;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  align-content: start;
}
@media (min-width: 560px) {
  .nkbk-ai-library-picker-list {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}
.nkbk-ai-library-picker-empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 28px 16px;
  font-size: 0.875rem;
  color: var(--muted);
}
.nkbk-ai-library-picker-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  padding: 0;
  border: 1.5px solid var(--border);
  border-radius: 12px;
  background: var(--surface, #fff);
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
  overflow: hidden;
  min-width: 0;
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.1s;
}
.nkbk-ai-library-picker-card:hover:not(:disabled) {
  border-color: rgba(0, 0, 0, 0.22);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
}
.nkbk-ai-library-picker-card.is-selected {
  border-color: #00a884;
  box-shadow: 0 0 0 1px rgba(0, 168, 132, 0.35);
}
.nkbk-ai-library-picker-card.is-added {
  opacity: 0.55;
  cursor: not-allowed;
}
body.theme-dark .nkbk-ai-library-picker-card {
  background: rgba(255, 255, 255, 0.03);
}
.nkbk-ai-library-picker-check {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 22px;
  height: 22px;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #00a884;
  color: #fff;
  opacity: 0;
  transform: scale(0.85);
  transition: opacity 0.15s, transform 0.15s;
  z-index: 2;
}
.nkbk-ai-library-picker-card.is-selected .nkbk-ai-library-picker-check {
  opacity: 1;
  transform: scale(1);
}
.nkbk-ai-library-picker-check svg {
  width: 12px;
  height: 12px;
}
.nkbk-ai-library-picker-thumb {
  display: flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 4 / 3;
  background: rgba(0, 0, 0, 0.04);
  overflow: hidden;
}
body.theme-dark .nkbk-ai-library-picker-thumb {
  background: rgba(255, 255, 255, 0.05);
}
.nkbk-ai-library-picker-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.nkbk-ai-library-picker-doc {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--muted);
}
.nkbk-ai-library-picker-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 10px 10px;
  min-width: 0;
}
.nkbk-ai-library-picker-title {
  font-size: 0.8125rem;
  font-weight: 600;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
  overflow-wrap: anywhere;
}
.nkbk-ai-library-picker-subline {
  font-size: 0.6875rem;
  color: var(--muted);
}
.nkbk-ai-library-picker-badge {
  display: inline-flex;
  margin-top: 4px;
  font-size: 0.625rem;
  font-weight: 600;
  color: #00a884;
}
.nkbk-ai-library-picker-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px 16px;
  border-top: 1px solid var(--border);
}
.nkbk-ai-library-picker-count {
  font-size: 0.8125rem;
  color: var(--muted);
  font-weight: 500;
}
.nkbk-ai-library-picker-foot-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ── Layout shell + sidebar (ChatGPT style) ── */
.nkbk-ai-shell {
  display: flex;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}
.nkbk-ai-sidebar {
  width: 240px;
  min-width: 200px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
  background: rgba(8, 12, 18, 0.95);
  padding: 12px 10px;
  gap: 8px;
}
.nkbk-ai-sidebar-new {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(255,255,255,0.04);
  color: var(--text);
  font: inherit;
  font-size: 0.88rem;
  font-weight: 500;
  padding: 10px 12px;
  cursor: pointer;
  text-align: left;
  transition: background 0.15s, border-color 0.15s;
}
.nkbk-ai-sidebar-new:hover {
  background: var(--accent-dim);
  border-color: var(--border-strong);
}
.nkbk-ai-sidebar-label {
  font-size: 0.68rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 4px 6px 0;
}
.nkbk-ai-thread-list {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-height: 0;
}
.nkbk-ai-thread-item {
  display: flex;
  align-items: center;
  gap: 4px;
  border-radius: 10px;
  padding: 2px;
}
.nkbk-ai-thread-item.is-active {
  background: rgba(0, 229, 184, 0.12);
}
.nkbk-ai-thread-item-btn {
  flex: 1;
  min-width: 0;
  border: none;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 0.82rem;
  text-align: left;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.nkbk-ai-thread-item-btn:hover { background: rgba(255,255,255,0.05); }
.nkbk-ai-thread-item.is-active .nkbk-ai-thread-item-btn { font-weight: 600; color: #a7f3e8; }
.nkbk-ai-thread-item-del {
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  opacity: 0;
  font-size: 1.1rem;
  line-height: 1;
  flex-shrink: 0;
}
.nkbk-ai-thread-item:hover .nkbk-ai-thread-item-del { opacity: 1; }
.nkbk-ai-thread-item-del:hover { background: rgba(239,68,68,0.15); color: #fca5a5; }
.nkbk-ai-app { position: relative; flex: 1; min-width: 0; display: flex; flex-direction: column; min-height: 0; height: auto; }

/* ── Light theme (sync โปรแกรมหลัก) ── */
body.theme-light {
  --bg: #f0f2f5;
  --surface: #ffffff;
  --surface-2: #f5f6f8;
  --border: rgba(0, 0, 0, 0.08);
  --border-strong: rgba(0, 180, 140, 0.35);
  --text: #1a1d21;
  --muted: #5c6066;
  --accent-dim: rgba(0, 180, 140, 0.12);
  --accent-glow: rgba(0, 180, 140, 0.2);
  --user-bg: #ececf1;
  --user-text: #0d0d0d;
  --user-border: rgba(0, 0, 0, 0.06);
  --assistant-bg: #ffffff;
  --shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
  background: #f0f2f5;
}
body.theme-light .nkbk-ai-app {
  background: linear-gradient(180deg, #f8f9fb 0%, #f0f2f5 100%);
}
body.theme-light .nkbk-ai-sidebar {
  background: #eceef1;
  border-right-color: rgba(0,0,0,0.08);
}
body.theme-light .nkbk-ai-sidebar-new {
  background: #fff;
  border-color: rgba(0,0,0,0.1);
  color: #1a1d21;
}
body.theme-light .nkbk-ai-header {
  background: rgba(255,255,255,0.92);
  border-bottom-color: rgba(0,0,0,0.08);
}
body.theme-light .nkbk-ai-msg--assistant .nkbk-ai-bubble:not(.nkbk-ai-bubble--image-only) {
  background: #fff;
  border-color: rgba(0,0,0,0.08);
  color: #1a1d21;
}
body.theme-light .nkbk-ai-composer-wrap {
  background: transparent;
  border-top-color: transparent;
}
body.theme-light .nkbk-ai-composer textarea {
  color: #0d0d0d;
}
body.theme-light .nkbk-ai-welcome {
  background: transparent;
  border-color: transparent;
}
body.theme-light .title-bar {
  background: linear-gradient(180deg, #e8eaed 0%, #dadce0 100%);
}
body.theme-light .title-bar-title { color: #1a1d21; }
body.theme-light .title-bar-btn { color: #5c6066; }
body.theme-light .nkbk-ai-call-badge {
  color: #065f46;
  background: #ecfdf5;
  border-color: #a7f3d0;
}
body.theme-light .nkbk-callname-input { color: #111827; font-weight: 600; }
body.theme-light .nkbk-callname-value { color: #111827; }
body.theme-light .nkbk-ai-btn-primary {
  background: #10a37f;
  color: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}
body.theme-light .nkbk-ai-btn-primary:hover {
  background: #0d8f6e;
  transform: none;
}
body.theme-light .nkbk-ai-image-card {
  background: #f3f4f6;
  border-color: rgba(0, 0, 0, 0.08);
}
body.theme-light .nkbk-ai-msg--user .nkbk-ai-bubble {
  background: #ececf1;
  color: #0d0d0d;
  border: 1px solid rgba(0, 0, 0, 0.06);
}

body.theme-light .nkbk-ai-msg--user .nkbk-ai-expand-btn {
  color: #6e6e80;
}

body.theme-light .nkbk-ai-msg--user .nkbk-ai-expand-btn:hover {
  color: #0d0d0d;
}

body.theme-light .nkbk-ai-msg--user .nkbk-ai-image-card {
  background: #fff;
  border-color: rgba(0, 0, 0, 0.1);
}
body.theme-light .nkbk-ai-img-btn {
  background: rgba(16, 163, 127, 0.15);
  color: #065f46;
}
body.theme-light .nkbk-field-stack {
  background: #f9fafb;
  border-color: rgba(0, 0, 0, 0.1);
}
body.theme-light .nkbk-ai-modal-box {
  background: #fff;
}
.nkbk-ai-image-card--error {
  min-height: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 0.85rem;
  padding: 16px;
}
body.theme-light .nkbk-ai-thread-item-btn { color: #1a1d21; }
body.theme-light .nkbk-ai-thread-item.is-active {
  background: rgba(0, 160, 120, 0.18);
  border: 1px solid rgba(0, 140, 100, 0.25);
}
body.theme-light .nkbk-ai-thread-item.is-active .nkbk-ai-thread-item-btn {
  color: #065f46;
  font-weight: 600;
}
body.theme-light .nkbk-ai-thread-item-del { color: #6b7280; }
body.theme-light .nkbk-ai-sidebar-label { color: #4b5563; font-weight: 600; }

/* ── App modal (confirm) ── */
.nkbk-modal-backdrop {
  position: fixed; inset: 0; z-index: 500;
  background: rgba(5, 12, 22, 0.65);
  backdrop-filter: blur(8px);
  display: flex; align-items: center; justify-content: center;
  opacity: 0; transition: opacity 0.2s ease;
  font-family: 'Inter', 'Noto Sans Thai', system-ui, -apple-system, sans-serif;
}
.nkbk-modal-backdrop.show { opacity: 1; }
.nkbk-modal {
  width: min(92vw, 420px);
  background: linear-gradient(180deg, #161a22, #0f1218);
  border: 1px solid rgba(148, 163, 184, 0.12);
  border-radius: 18px;
  box-shadow: 0 30px 60px -20px rgba(0, 0, 0, 0.7);
  overflow: hidden;
  transform: scale(0.94); opacity: 0;
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.2s ease;
}
.nkbk-modal-backdrop.show .nkbk-modal { transform: scale(1); opacity: 1; }
.nkbk-modal-body { padding: 1.4rem 1.2rem 1rem; display: grid; grid-template-columns: auto 1fr; gap: 0.85rem; }
.nkbk-modal-icon {
  width: 48px; height: 48px; border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.3rem; background: rgba(16, 185, 129, 0.15); color: var(--accent);
}
.nkbk-modal.variant-danger .nkbk-modal-icon { background: rgba(239, 68, 68, 0.16); color: #f87171; }
.nkbk-modal-title { font-size: 1.02rem; font-weight: 600; color: var(--text); margin-bottom: 0.3rem; }
.nkbk-modal-msg { color: var(--muted); font-size: 0.88rem; line-height: 1.5; }
.nkbk-modal-actions {
  padding: 0.85rem 1rem; border-top: 1px solid rgba(148, 163, 184, 0.08);
  display: flex; justify-content: flex-end; gap: 0.5rem;
  background: rgba(10, 14, 20, 0.5);
}
.nkbk-modal-btn {
  padding: 0.5rem 1.1rem; border-radius: 10px; font-size: 0.88rem; font-weight: 600;
  font-family: inherit; cursor: pointer; border: 1px solid transparent; min-width: 88px;
}
.nkbk-modal-btn-cancel {
  background: transparent; color: var(--muted); border-color: rgba(148, 163, 184, 0.25);
}
.nkbk-modal-btn-cancel:hover { color: var(--text); background: rgba(255,255,255,0.04); }
.nkbk-modal-btn-ok {
  background: linear-gradient(135deg, var(--accent), #059669); color: #001b18;
}
.nkbk-modal.variant-danger .nkbk-modal-btn-ok {
  background: linear-gradient(135deg, #ef4444, #dc2626); color: #fff;
}
body.theme-light .nkbk-modal {
  background: linear-gradient(180deg, #ffffff, #f3f4f6);
  border-color: rgba(0,0,0,0.08);
}
body.theme-light .nkbk-modal-title { color: #1a1d21; }
body.theme-light .nkbk-modal-msg { color: #5c6066; }
body.theme-light .nkbk-modal-actions { background: #f9fafb; border-top-color: rgba(0,0,0,0.06); }
body.theme-light .nkbk-modal-btn-cancel { color: #5c6066; border-color: rgba(0,0,0,0.12); }

.nkbk-modal-body--prompt {
  display: block;
  padding: 1.25rem 1.2rem 0.5rem;
}
.nkbk-modal-content--full { width: 100%; }
.nkbk-modal-input {
  width: 100%;
  margin-top: 0.75rem;
  padding: 0.65rem 0.85rem;
  border-radius: 10px;
  border: 1px solid rgba(148, 163, 184, 0.25);
  background: rgba(10, 14, 20, 0.5);
  color: var(--text);
  font: inherit;
  font-size: 0.92rem;
}
.nkbk-modal-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.2);
}
body.theme-light .nkbk-modal-input {
  background: #fff;
  border-color: rgba(0,0,0,0.12);
  color: #1a1d21;
}
body.theme-light .nkbk-modal-input:focus {
  border-color: #10a37f;
  box-shadow: 0 0 0 2px rgba(16, 163, 127, 0.15);
}

/* ── Composer idle / thread pick ── */
.nkbk-ai-composer-hint {
  text-align: center;
  font-size: 0.82rem;
  color: #6e6e80;
  margin: 0 0 8px;
}

/* ── Header menu + share ── */
.nkbk-ai-header-share {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.82rem;
  padding: 7px 12px;
  border-radius: 999px;
}
.nkbk-ai-header-menu-wrap { position: relative; z-index: 2; }
.nkbk-ai-header-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 240px;
  background: #fff;
  border: 1px solid rgba(0,0,0,0.08);
  border-radius: 14px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.12);
  padding: 6px;
  z-index: 150;
  font-family: 'Inter', 'Noto Sans Thai', system-ui, -apple-system, sans-serif;
}
.nkbk-ai-header-menu-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  border: none;
  background: transparent;
  color: #0d0d0d;
  font: inherit;
  font-size: 0.875rem;
  padding: 10px 12px;
  border-radius: 10px;
  cursor: pointer;
  text-align: left;
}
.nkbk-ai-header-menu-item svg { width: 18px; height: 18px; flex-shrink: 0; }
.nkbk-ai-header-menu-item .menu-chevron { margin-left: auto; width: 16px; height: 16px; opacity: 0.45; }
.nkbk-ai-header-menu-item:hover { background: rgba(0,0,0,0.05); }
.nkbk-ai-header-menu-item--danger { color: #dc2626; }
.nkbk-ai-header-menu-item--danger:hover { background: rgba(220,38,38,0.08); }
.nkbk-ai-header-menu-item.is-disabled { opacity: 0.45; pointer-events: none; }

.nkbk-ai-thread-item.is-pinned .nkbk-ai-thread-item-btn::before {
  content: '📌';
  margin-right: 6px;
  font-size: 0.72rem;
}

/* โหมดดูรูป — desktop: sidebar + viewer เป็น flex row (ไม่ทับกัน) */
@media (min-width: 769px) {
  body.is-viewer-open .nkbk-ai-shell {
    display: flex;
    flex-direction: row;
    width: 100%;
  }
  body.is-viewer-open .nkbk-ai-sidebar {
    position: relative;
    transform: none;
    flex-shrink: 0;
    display: flex;
    height: 100%;
    box-shadow: none;
    transition: width 0.18s ease, min-width 0.18s ease;
  }
  body.is-viewer-open:not(.sidebar-collapsed) .nkbk-ai-sidebar {
    width: 260px;
    min-width: 260px;
  }
  body.is-viewer-open.sidebar-collapsed .nkbk-ai-sidebar {
    width: 52px;
    min-width: 52px;
    padding: 8px 6px 6px;
  }
  body.is-viewer-open .nkbk-ai-app {
    display: none !important;
  }
  body.is-viewer-open .sidebar-backdrop {
    display: none !important;
  }
  body.is-viewer-open.sidebar-collapsed .sidebar-logo {
    display: inline-flex;
    opacity: 1;
    pointer-events: auto;
  }
}

.nkbk-ai-viewer-rail { display: none !important; }

.nkbk-ai-viewer {
  display: none;
  flex: 1;
  min-width: 0;
  min-height: 0;
  background: #f3f3f3;
}
body.theme-dark .nkbk-ai-viewer { background: #171717; }
.nkbk-ai-viewer.open {
  display: flex;
  flex-direction: column;
}
@media (min-width: 769px) {
  .nkbk-ai-viewer.open {
    flex: 1;
    min-width: 0;
  }
}
@media (max-width: 768px) {
  .nkbk-ai-viewer {
    position: fixed;
    inset: 0;
    z-index: 200;
    flex: none;
    width: auto;
  }
}
.nkbk-ai-viewer-shell {
  height: 100%;
  display: flex;
  flex-direction: column;
  color: #0d0d0d;
}
body.theme-dark .nkbk-ai-viewer-shell { color: #ececec; }

.nkbk-ai-viewer-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 12px 8px 8px;
  background: #f3f3f3;
  flex-shrink: 0;
  min-height: 52px;
  position: relative;
  z-index: 30;
}
body.theme-dark .nkbk-ai-viewer-top { background: #171717; }

.nkbk-ai-viewer-top-left {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
  flex: 1;
}

.nkbk-ai-viewer-close-btn {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: #0d0d0d;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.nkbk-ai-viewer-close-btn:hover { background: rgba(0,0,0,0.06); }
body.theme-dark .nkbk-ai-viewer-close-btn { color: #ececec; }
body.theme-dark .nkbk-ai-viewer-close-btn:hover { background: rgba(255,255,255,0.08); }

.nkbk-ai-viewer-title {
  font-size: 0.9375rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
.nkbk-ai-viewer-top-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.nkbk-ai-viewer-text-btn,
.nkbk-ai-viewer-aspect-btn,
.nkbk-ai-viewer-icon-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid rgba(0,0,0,0.1);
  background: #fff;
  color: #0d0d0d;
  font: inherit;
  font-size: 0.8125rem;
  padding: 7px 12px;
  border-radius: 999px;
  cursor: pointer;
}
body.theme-dark .nkbk-ai-viewer-text-btn,
body.theme-dark .nkbk-ai-viewer-aspect-btn,
body.theme-dark .nkbk-ai-viewer-icon-btn {
  background: #2f2f2f;
  border-color: rgba(255,255,255,0.12);
  color: #ececec;
}
.nkbk-ai-viewer-icon-btn { padding: 8px; border-radius: 10px; }
.nkbk-ai-viewer-share-btn {
  border: none;
  background: #0d0d0d;
  color: #fff;
  font: inherit;
  font-size: 0.8125rem;
  font-weight: 600;
  padding: 8px 16px;
  border-radius: 999px;
  cursor: pointer;
}
body.theme-dark .nkbk-ai-viewer-share-btn {
  background: #fff;
  color: #0d0d0d;
}
.nkbk-ai-viewer-text-btn:hover,
.nkbk-ai-viewer-aspect-btn:hover,
.nkbk-ai-viewer-icon-btn:hover { background: rgba(255,255,255,0.92); }
body.theme-dark .nkbk-ai-viewer-text-btn:hover,
body.theme-dark .nkbk-ai-viewer-aspect-btn:hover,
body.theme-dark .nkbk-ai-viewer-icon-btn:hover { background: #3a3a3a; }
.nkbk-ai-viewer-share-btn:hover { background: #262626; }
body.theme-dark .nkbk-ai-viewer-share-btn:hover { background: #e5e5e5; }
.nkbk-ai-viewer-aspect-wrap { position: relative; }
.nkbk-ai-viewer-aspect-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 260px;
  background: #fff;
  border: 1px solid rgba(0,0,0,0.08);
  border-radius: 14px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.14);
  padding: 8px;
  z-index: 5;
}
.nkbk-ai-viewer-aspect-menu-title {
  font-size: 0.78rem;
  color: #6e6e80;
  padding: 6px 10px 8px;
}
.nkbk-ai-viewer-aspect-menu button {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  border: none;
  background: transparent;
  font: inherit;
  font-size: 0.875rem;
  padding: 9px 10px;
  border-radius: 10px;
  cursor: pointer;
  text-align: left;
}
.nkbk-ai-viewer-aspect-menu button:hover { background: rgba(0,0,0,0.05); }
.aspect-icon {
  display: inline-block;
  border: 1.5px solid currentColor;
  border-radius: 3px;
  flex-shrink: 0;
}
.aspect-1-1 { width: 16px; height: 16px; }
.aspect-3-4 { width: 12px; height: 16px; }
.aspect-9-16 { width: 9px; height: 16px; }
.aspect-4-3 { width: 16px; height: 12px; }
.aspect-16-9 { width: 16px; height: 9px; }
.nkbk-ai-viewer-main {
  flex: 1;
  min-height: 0;
  display: flex;
}
.nkbk-ai-viewer-rail {
  width: 52px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 12px 6px;
  border-right: 1px solid rgba(0,0,0,0.06);
  background: #f9f9f9;
}
body.theme-dark .nkbk-ai-viewer-rail {
  background: #171717;
  border-right-color: rgba(255,255,255,0.08);
}
.nkbk-ai-viewer-rail-btn {
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: #5d5d5d;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
body.theme-dark .nkbk-ai-viewer-rail-btn { color: #b4b4b4; }
.nkbk-ai-viewer-rail-btn:hover { background: rgba(0,0,0,0.06); color: #0d0d0d; }
body.theme-dark .nkbk-ai-viewer-rail-btn:hover { background: rgba(255,255,255,0.08); color: #fff; }
@media (min-width: 769px) {
  .nkbk-ai-viewer-rail { display: none !important; }
}
.nkbk-ai-viewer-thumbs {
  width: 88px;
  flex-shrink: 0;
  overflow-y: auto;
  padding: 12px 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: #f3f3f3;
}
body.theme-dark .nkbk-ai-viewer-thumbs { background: #171717; }

.nkbk-ai-viewer-thumb {
  border: 2px solid transparent;
  border-radius: 12px;
  overflow: hidden;
  padding: 0;
  background: #fff;
  cursor: pointer;
  aspect-ratio: 1;
  flex-shrink: 0;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.nkbk-ai-viewer-thumb.is-active {
  border-color: #93c5fd;
  box-shadow: 0 0 0 2px rgba(147, 197, 253, 0.45);
  background: #eff6ff;
}
body.theme-dark .nkbk-ai-viewer-thumb { background: #2f2f2f; }
body.theme-dark .nkbk-ai-viewer-thumb.is-active {
  border-color: #3b82f6;
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.35);
  background: rgba(59, 130, 246, 0.12);
}
.nkbk-ai-viewer-thumb img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #f4f4f5;
}
.nkbk-ai-viewer-center {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 4px 20px 24px;
  overflow: hidden;
}
.nkbk-ai-viewer-stage-wrap {
  width: 100%;
  max-width: 820px;
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 8px;
}
.nkbk-ai-viewer-stage-wrap img {
  display: block;
  max-width: 100%;
  max-height: calc(100vh - 200px);
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 2px 16px rgba(0,0,0,0.08), 0 0 0 1px rgba(0,0,0,0.04);
}
body.theme-dark .nkbk-ai-viewer-stage-wrap img {
  background: #2f2f2f;
  box-shadow: 0 2px 16px rgba(0,0,0,0.35), 0 0 0 1px rgba(255,255,255,0.06);
}
.nkbk-ai-viewer-composer {
  width: 100%;
  max-width: 768px;
  margin-top: 8px;
  flex-shrink: 0;
}
.nkbk-ai-viewer-attach-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
  padding: 0 4px;
}
.nkbk-ai-viewer-attach-chip {
  position: relative;
  width: 52px;
  height: 52px;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid rgba(0,0,0,0.08);
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}
.nkbk-ai-viewer-attach-chip img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.nkbk-ai-viewer-attach-remove {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 18px;
  height: 18px;
  border: none;
  border-radius: 50%;
  background: rgba(0,0,0,0.55);
  color: #fff;
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.nkbk-ai-viewer.is-dragover .nkbk-ai-viewer-composer-inner {
  border-color: #10a37f;
  box-shadow: 0 0 0 2px rgba(16, 163, 127, 0.2);
}
body.theme-dark .nkbk-ai-viewer-composer-inner {
  background: #2f2f2f;
  border-color: rgba(255,255,255,0.12);
}
body.theme-dark .nkbk-ai-viewer-composer-inner textarea { color: #ececec; }
body.theme-dark .nkbk-ai-viewer-composer-plus { color: #9ca3af; }
body.theme-dark .nkbk-ai-viewer-composer-send { background: #fff; color: #0d0d0d; }
body.theme-dark .nkbk-ai-viewer-composer-send:disabled { background: #4b5563; color: #9ca3af; }

@media (max-width: 768px) {
  .nkbk-ai-viewer-text-btn span,
  .nkbk-ai-viewer-aspect-btn span { display: none; }
  .nkbk-ai-viewer-text-btn,
  .nkbk-ai-viewer-aspect-btn { padding: 8px; border-radius: 10px; }
  .nkbk-ai-viewer-title { max-width: 40vw; }
  .nkbk-ai-viewer-top {
    overflow: visible;
    z-index: 50;
  }
  .nkbk-ai-viewer-top-actions {
    overflow: visible;
  }
  .nkbk-ai-viewer-aspect-menu {
    position: fixed;
    left: 12px;
    right: 12px;
    top: calc(env(safe-area-inset-top, 0px) + 56px);
    min-width: 0;
    width: auto;
    z-index: 250;
  }
}
.nkbk-ai-viewer-composer-inner {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  padding: 6px 8px 6px 6px;
  border: 1px solid rgba(0,0,0,0.12);
  border-radius: 28px;
  background: #fff;
  box-shadow: 0 2px 12px rgba(0,0,0,0.06);
}
.nkbk-ai-viewer-composer-plus {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: #6e6e80;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.nkbk-ai-viewer-composer-inner textarea {
  flex: 1;
  border: none;
  outline: none;
  resize: none;
  font: inherit;
  font-size: 0.95rem;
  line-height: 1.45;
  max-height: 120px;
  padding: 8px 4px;
  background: transparent;
  color: #0d0d0d;
}
.nkbk-ai-viewer-composer-send {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 50%;
  background: #0d0d0d;
  color: #fff;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.nkbk-ai-viewer-composer-send:disabled {
  background: #d1d1d6;
  cursor: not-allowed;
}

.nkbk-ai-drawer {
  position: fixed;
  inset: 0;
  z-index: 180;
  pointer-events: none;
}
.nkbk-ai-drawer.open { pointer-events: auto; }
.nkbk-ai-drawer-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.35);
  opacity: 0;
  transition: opacity 0.2s;
}
.nkbk-ai-drawer.open .nkbk-ai-drawer-backdrop { opacity: 1; }
.nkbk-ai-drawer-panel {
  position: absolute;
  top: 0;
  right: 0;
  width: min(100%, 360px);
  height: 100%;
  background: #fff;
  box-shadow: -8px 0 32px rgba(0,0,0,0.12);
  transform: translateX(100%);
  transition: transform 0.24s ease;
  display: flex;
  flex-direction: column;
}
.nkbk-ai-drawer.open .nkbk-ai-drawer-panel { transform: translateX(0); }
.nkbk-ai-drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  border-bottom: 1px solid rgba(0,0,0,0.08);
}
.nkbk-ai-drawer-head h2 { margin: 0; font-size: 1rem; font-weight: 600; }
.nkbk-ai-drawer-close {
  border: none;
  background: transparent;
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  color: #6e6e80;
  padding: 4px 8px;
  border-radius: 8px;
}
.nkbk-ai-drawer-close:hover { background: rgba(0,0,0,0.06); color: #0d0d0d; }
.nkbk-ai-drawer-body { flex: 1; overflow-y: auto; padding: 8px; }
.nkbk-ai-file-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  border: none;
  background: transparent;
  text-align: left;
  padding: 10px 12px;
  border-radius: 12px;
  cursor: pointer;
  font: inherit;
}
.nkbk-ai-file-item:hover { background: rgba(0,0,0,0.05); }
.nkbk-ai-file-thumb {
  width: 48px;
  height: 48px;
  border-radius: 10px;
  overflow: hidden;
  flex-shrink: 0;
  background: #f3f4f6;
  border: 1px solid rgba(0,0,0,0.06);
}
body.theme-dark .nkbk-ai-file-thumb { background: #2f2f2f; border-color: rgba(255,255,255,0.08); }
.nkbk-ai-file-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.nkbk-ai-file-badge {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.62rem;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}
.nkbk-ai-file-badge--png { background: #10a37f; }
.nkbk-ai-file-badge--jpg { background: #8b5cf6; }
.nkbk-ai-file-badge--webp { background: #0891b2; }
.nkbk-ai-file-meta { min-width: 0; }
.nkbk-ai-file-name {
  display: block;
  font-size: 0.875rem;
  color: #0d0d0d;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.nkbk-ai-file-type {
  display: block;
  font-size: 0.75rem;
  color: #6e6e80;
  margin-top: 2px;
}
.nkbk-ai-drawer-empty {
  padding: 24px 16px;
  text-align: center;
  color: #6e6e80;
  font-size: 0.875rem;
}

/* ── GPT-style sidebar v2 ── */
.nkbk-ai-sidebar {
  width: 260px;
  min-width: 260px;
  height: 100%;
  padding: 8px 8px 6px;
  gap: 0;
  background: #f9f9f9;
  border-right-color: rgba(0,0,0,0.06);
}
body.theme-dark .nkbk-ai-sidebar {
  background: #171717;
  border-right-color: rgba(255,255,255,0.08);
}
.sidebar-head {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 4px 8px;
  min-height: 40px;
  position: relative;
}
.sidebar-logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  flex-shrink: 0;
  transition: opacity 0.12s;
}
.sidebar-logo:hover { background: rgba(0,0,0,0.05); }
body.theme-dark .sidebar-logo:hover { background: rgba(255,255,255,0.06); }
.sidebar-expand-btn {
  display: none;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: #5d5d5d;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.sidebar-expand-btn:hover { background: rgba(0,0,0,0.06); }
body.theme-dark .sidebar-expand-btn { color: #b4b4b4; }
body.theme-dark .sidebar-expand-btn:hover { background: rgba(255,255,255,0.06); }
.sidebar-icon-btn {
  margin-left: auto;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: #5d5d5d;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.sidebar-icon-btn:hover { background: rgba(0,0,0,0.06); }
body.theme-dark .sidebar-icon-btn { color: #b4b4b4; }
body.theme-dark .sidebar-icon-btn:hover { background: rgba(255,255,255,0.06); }
.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 0 2px 8px;
}
.sidebar-nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: #0d0d0d;
  font: inherit;
  font-size: 0.875rem;
  padding: 10px 12px;
  cursor: pointer;
  text-align: left;
  transition: background 0.12s;
}
.sidebar-nav-item svg { flex-shrink: 0; color: #5d5d5d; }
.sidebar-nav-item:hover { background: rgba(0,0,0,0.06); }
body.theme-dark .sidebar-nav-item { color: #ececec; }
body.theme-dark .sidebar-nav-item svg { color: #b4b4b4; }
body.theme-dark .sidebar-nav-item:hover { background: rgba(255,255,255,0.06); }
.sidebar-section {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 0 2px;
}
.sidebar-section-label {
  font-size: 0.72rem;
  font-weight: 600;
  color: #6e6e80;
  padding: 8px 10px 6px;
}
body.theme-dark .sidebar-section-label { color: #9b9b9b; }
.nkbk-ai-thread-list {
  gap: 1px;
  padding-right: 2px;
}
.nkbk-ai-thread-item {
  position: relative;
  border-radius: 10px;
  padding: 0;
}
.nkbk-ai-thread-item.is-active {
  background: rgba(0,0,0,0.08);
}
body.theme-dark .nkbk-ai-thread-item.is-active {
  background: rgba(255,255,255,0.08);
  border: none;
}
.nkbk-ai-thread-item-btn {
  flex: 1;
  font-size: 0.875rem;
  padding: 9px 72px 9px 12px;
  border-radius: 10px;
  color: #0d0d0d;
}
body.theme-dark .nkbk-ai-thread-item-btn { color: #ececec; }
.nkbk-ai-thread-item.is-active .nkbk-ai-thread-item-btn {
  font-weight: 500;
  color: #0d0d0d;
}
body.theme-dark .nkbk-ai-thread-item.is-active .nkbk-ai-thread-item-btn { color: #fff; }
.nkbk-ai-thread-item-actions {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  gap: 2px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.12s;
}
.nkbk-ai-thread-item:hover .nkbk-ai-thread-item-actions,
.nkbk-ai-thread-item.is-menu-open .nkbk-ai-thread-item-actions {
  opacity: 1;
  pointer-events: auto;
}
.nkbk-ai-thread-item.is-active .nkbk-ai-thread-item-actions { opacity: 1; pointer-events: auto; }
.nkbk-ai-thread-item.is-pinned .nkbk-ai-thread-item-actions {
  opacity: 1;
  pointer-events: auto;
}
.nkbk-ai-thread-item.is-pinned .nkbk-ai-thread-pin {
  display: inline-flex;
  opacity: 1;
}
.nkbk-ai-thread-item.is-pinned .nkbk-ai-thread-more {
  opacity: 0;
  pointer-events: none;
}
.nkbk-ai-thread-item.is-pinned:hover .nkbk-ai-thread-more,
.nkbk-ai-thread-item.is-pinned.is-menu-open .nkbk-ai-thread-more,
.nkbk-ai-thread-item.is-pinned.is-active .nkbk-ai-thread-more {
  opacity: 1;
  pointer-events: auto;
}
.nkbk-ai-thread-pin {
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: #6e6e80;
  cursor: default;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.nkbk-ai-thread-pin svg { width: 14px; height: 14px; }
.nkbk-ai-thread-item:not(.is-pinned) .nkbk-ai-thread-pin { display: none; }
.nkbk-ai-thread-more {
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: #6e6e80;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.nkbk-ai-thread-more:hover { background: rgba(0,0,0,0.06); color: #0d0d0d; }
body.theme-dark .nkbk-ai-thread-more:hover { background: rgba(255,255,255,0.08); color: #fff; }
.nkbk-ai-thread-item-del { display: none; }
.nkbk-ai-thread-item.is-pinned .nkbk-ai-thread-item-btn::before { content: none; }

.sidebar-profile {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  border: none;
  border-radius: 12px;
  background: transparent;
  padding: 8px 10px;
  cursor: pointer;
  text-align: left;
}
.sidebar-profile:hover { background: rgba(0,0,0,0.06); }
body.theme-dark .sidebar-profile:hover { background: rgba(255,255,255,0.06); }
.sidebar-profile-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, #f97316, #ea580c);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
}
.sidebar-profile-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.sidebar-profile-text {
  min-width: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.sidebar-profile-name {
  font-size: 0.875rem;
  font-weight: 600;
  color: #0d0d0d;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.nkbk-ai-header-text h1 {
  margin: 0;
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.3;
}
.sidebar-profile-sub {
  font-size: 0.75rem;
  color: #6e6e80;
}
body.theme-dark .sidebar-profile-sub { color: #9b9b9b; }
.sidebar-profile-sub.hidden { display: none; }
body.theme-dark .sidebar-profile-name { color: #ececec; }
.sidebar-profile-store {
  flex-shrink: 0;
  color: #6e6e80;
  opacity: 0.7;
}
.sidebar-profile-menu {
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: calc(100% + 6px);
  background: #fff;
  border: 1px solid rgba(0,0,0,0.08);
  border-radius: 16px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.14);
  padding: 6px;
  z-index: 130;
  font-family: 'Inter', 'Noto Sans Thai', system-ui, -apple-system, sans-serif;
}
body.theme-dark .sidebar-profile-menu {
  background: #2f2f2f;
  border-color: rgba(255,255,255,0.08);
  box-shadow: 0 12px 40px rgba(0,0,0,0.45);
}
.sidebar-profile-menu-head,
.sidebar-profile-menu-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  border: none;
  background: transparent;
  color: #0d0d0d;
  font: inherit;
  font-size: 0.875rem;
  padding: 10px 12px;
  border-radius: 10px;
  cursor: pointer;
  text-align: left;
}
body.theme-dark .sidebar-profile-menu-head,
body.theme-dark .sidebar-profile-menu-item { color: #ececec; }
.sidebar-profile-menu-head:hover,
.sidebar-profile-menu-item:hover { background: rgba(0,0,0,0.05); }
body.theme-dark .sidebar-profile-menu-head:hover,
body.theme-dark .sidebar-profile-menu-item:hover { background: rgba(255,255,255,0.06); }
.sidebar-profile-menu-head .sidebar-profile-text { flex: 1; }
.sidebar-profile-menu-head--static {
  cursor: default;
  pointer-events: none;
}
.sidebar-profile-menu-head--static:hover {
  background: transparent !important;
}
body.theme-dark .sidebar-profile-menu-head--static:hover {
  background: transparent !important;
}
.sidebar-profile-menu-head .menu-chevron,
.sidebar-profile-menu-item .menu-chevron {
  margin-left: auto;
  width: 16px;
  height: 16px;
  opacity: 0.45;
}
.sidebar-profile-menu-item svg:not(.menu-chevron) {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  color: #5d5d5d;
}
body.theme-dark .sidebar-profile-menu-item svg:not(.menu-chevron) { color: #b4b4b4; }
.sidebar-profile-menu-divider {
  height: 1px;
  background: rgba(0,0,0,0.08);
  margin: 4px 8px;
}
body.theme-dark .sidebar-profile-menu-divider { background: rgba(255,255,255,0.08); }

.sidebar-profile-help-menu {
  position: absolute;
  left: calc(100% + 6px);
  bottom: 0;
  min-width: 240px;
  background: #fff;
  border: 1px solid rgba(0,0,0,0.08);
  border-radius: 14px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.14);
  padding: 6px;
  z-index: 140;
  font-family: 'Inter', 'Noto Sans Thai', system-ui, -apple-system, sans-serif;
}

body.theme-dark .sidebar-profile-help-menu {
  background: #2f2f2f;
  border-color: rgba(255,255,255,0.08);
  box-shadow: 0 12px 40px rgba(0,0,0,0.45);
}

.sidebar-profile-help-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  border: none;
  background: transparent;
  color: #0d0d0d;
  font: inherit;
  font-size: 0.875rem;
  padding: 10px 12px;
  border-radius: 10px;
  cursor: pointer;
  text-align: left;
}

body.theme-dark .sidebar-profile-help-item {
  color: #ececec;
}

.sidebar-profile-help-item:hover {
  background: rgba(0,0,0,0.05);
}

body.theme-dark .sidebar-profile-help-item:hover {
  background: rgba(255,255,255,0.06);
}

.sidebar-profile-help-item svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  color: #5d5d5d;
}

body.theme-dark .sidebar-profile-help-item svg {
  color: #b4b4b4;
}

@media (max-width: 768px) {
  .sidebar-profile-help-menu {
    left: 8px;
    right: 8px;
    bottom: calc(100% + 6px);
    min-width: 0;
  }
}

body.sidebar-collapsed .sidebar-profile-help-menu {
  left: calc(100% + 8px);
  right: auto;
  bottom: 0;
  min-width: 240px;
}

.nkbk-ai-help-main {
  overflow: auto;
}

.nkbk-ai-help-head {
  margin-bottom: 16px;
}

.nkbk-ai-help-head h2 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.nkbk-ai-help-panel.hidden {
  display: none;
}

.nkbk-ai-help-prose {
  color: var(--text);
  font-size: 0.9375rem;
  line-height: 1.6;
}

.nkbk-ai-help-prose h3 {
  margin: 20px 0 8px;
  font-size: 0.9375rem;
  font-weight: 600;
}

.nkbk-ai-help-prose h3:first-child {
  margin-top: 0;
}

.nkbk-ai-help-prose ul {
  margin: 0 0 12px;
  padding-left: 1.25rem;
}

.nkbk-ai-help-prose li {
  margin-bottom: 6px;
}

.nkbk-ai-help-lead {
  margin: 0 0 16px;
  color: var(--muted);
}

.nkbk-ai-help-faq {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0 14px;
  margin-bottom: 8px;
  background: rgba(0,0,0,0.02);
}

body.theme-dark .nkbk-ai-help-faq {
  background: rgba(255,255,255,0.03);
}

.nkbk-ai-help-faq summary {
  cursor: pointer;
  font-weight: 500;
  padding: 12px 0;
  list-style: none;
}

.nkbk-ai-help-faq summary::-webkit-details-marker {
  display: none;
}

.nkbk-ai-help-faq p {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 0.875rem;
}

.nkbk-ai-help-contact-card {
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px 16px;
  margin-bottom: 16px;
  background: rgba(0,0,0,0.02);
}

body.theme-dark .nkbk-ai-help-contact-card {
  background: rgba(255,255,255,0.03);
}

.nkbk-ai-help-contact-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 0;
}

.nkbk-ai-help-contact-row + .nkbk-ai-help-contact-row {
  border-top: 1px solid var(--border);
  margin-top: 4px;
  padding-top: 10px;
}

.nkbk-ai-help-contact-label {
  color: var(--muted);
  font-size: 0.875rem;
}

.nkbk-ai-help-contact-row a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
}

.nkbk-ai-help-link-animated {
  position: relative;
  display: inline-block;
  text-decoration: none;
}

.nkbk-ai-help-link-animated::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: -3px;
  height: 2px;
  border-radius: 1px;
  opacity: 0;
  background: linear-gradient(
    90deg,
    transparent 0%,
    transparent 28%,
    var(--accent) 50%,
    transparent 72%,
    transparent 100%
  );
  background-size: 220% 100%;
}

.nkbk-ai-help-link-animated:hover::after {
  opacity: 1;
  animation: nkbk-help-link-underline 1.6s linear infinite;
}

@keyframes nkbk-help-link-underline {
  0% {
    background-position: 120% 0;
  }
  100% {
    background-position: -120% 0;
  }
}

.nkbk-ai-help-contact-row a:hover {
  opacity: 0.92;
}

.nkbk-ai-help-kbd-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 12px;
}

.nkbk-ai-help-kbd-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: rgba(0,0,0,0.02);
}

body.theme-dark .nkbk-ai-help-kbd-row {
  background: rgba(255,255,255,0.03);
}

.nkbk-ai-help-kbd-row kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.75rem;
  padding: 3px 7px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  font: inherit;
  font-size: 0.75rem;
  font-weight: 600;
}

.nkbk-ai-help-kbd-plus {
  color: var(--muted);
  font-size: 0.75rem;
}

.nkbk-ai-help-note {
  margin: 0;
  color: var(--muted);
  font-size: 0.8125rem;
}

.nkbk-ai-help-disclaimer {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.8125rem;
}

.sidebar-search-modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 48px 16px 16px;
}
.sidebar-search-modal.hidden { display: none; }
.sidebar-search-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.35);
}
.sidebar-search-panel {
  position: relative;
  width: min(640px, 100%);
  max-height: min(70vh, 560px);
  background: #fff;
  border-radius: 20px;
  box-shadow: 0 24px 80px rgba(0,0,0,0.18);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  font-family: 'Inter', 'Noto Sans Thai', system-ui, -apple-system, sans-serif;
}
body.theme-dark .sidebar-search-panel {
  background: #2f2f2f;
  box-shadow: 0 24px 80px rgba(0,0,0,0.5);
}
.sidebar-search-input-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 16px;
  border-bottom: 1px solid rgba(0,0,0,0.06);
}
body.theme-dark .sidebar-search-input-wrap { border-bottom-color: rgba(255,255,255,0.08); }
.sidebar-search-input-wrap input {
  flex: 1;
  border: none;
  background: transparent;
  font: inherit;
  font-size: 1rem;
  color: #0d0d0d;
  outline: none;
}
body.theme-dark .sidebar-search-input-wrap input { color: #ececec; }
.sidebar-search-input-wrap input::placeholder { color: #9ca3af; }
.sidebar-search-close {
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: #6e6e80;
  font-size: 1.25rem;
  cursor: pointer;
}
.sidebar-search-close:hover { background: rgba(0,0,0,0.06); }
.sidebar-search-new {
  display: flex;
  align-items: center;
  gap: 10px;
  width: calc(100% - 24px);
  margin: 10px 12px 4px;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: #0d0d0d;
  font: inherit;
  font-size: 0.875rem;
  padding: 10px 12px;
  cursor: pointer;
  text-align: left;
}
body.theme-dark .sidebar-search-new { color: #ececec; }
.sidebar-search-new:hover { background: rgba(0,0,0,0.05); }
body.theme-dark .sidebar-search-new:hover { background: rgba(255,255,255,0.06); }
.sidebar-search-results {
  flex: 1;
  overflow-y: auto;
  padding: 4px 8px 12px;
}
.sidebar-search-group-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: #6e6e80;
  padding: 10px 12px 6px;
}
.sidebar-search-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: #0d0d0d;
  font: inherit;
  font-size: 0.875rem;
  padding: 10px 12px;
  cursor: pointer;
  text-align: left;
}
body.theme-dark .sidebar-search-item { color: #ececec; }
.sidebar-search-item:hover { background: rgba(0,0,0,0.05); }
body.theme-dark .sidebar-search-item:hover { background: rgba(255,255,255,0.06); }
.sidebar-search-item svg { width: 18px; height: 18px; flex-shrink: 0; color: #6e6e80; }
.sidebar-search-empty {
  padding: 24px 16px;
  text-align: center;
  color: #6e6e80;
  font-size: 0.875rem;
}

.sidebar-thread-menu {
  position: fixed;
  z-index: 180;
  min-width: 220px;
  background: #fff;
  border: 1px solid rgba(0,0,0,0.08);
  border-radius: 14px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.14);
  padding: 6px;
  font-family: 'Inter', 'Noto Sans Thai', system-ui, -apple-system, sans-serif;
}
body.theme-dark .sidebar-thread-menu {
  background: #2f2f2f;
  border-color: rgba(255,255,255,0.08);
}
.sidebar-thread-menu.hidden { display: none; }
.sidebar-thread-menu-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  border: none;
  background: transparent;
  color: #0d0d0d;
  font: inherit;
  font-size: 0.875rem;
  padding: 10px 12px;
  border-radius: 10px;
  cursor: pointer;
  text-align: left;
}
body.theme-dark .sidebar-thread-menu-item { color: #ececec; }
.sidebar-thread-menu-item svg { width: 18px; height: 18px; flex-shrink: 0; }
.sidebar-thread-menu-item:hover { background: rgba(0,0,0,0.05); }
body.theme-dark .sidebar-thread-menu-item:hover { background: rgba(255,255,255,0.06); }
.sidebar-thread-menu-item--danger { color: #dc2626; }
.sidebar-thread-menu-divider {
  height: 1px;
  background: rgba(0,0,0,0.08);
  margin: 4px 8px;
}
body.theme-dark .sidebar-thread-menu-divider { background: rgba(255,255,255,0.08); }

.nkbk-ai-chat-view {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  position: relative;
}

.nkbk-ai-app.is-library-open .nkbk-ai-chat-view { display: none; }

.nkbk-ai-library {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: #fff;
  color: #0d0d0d;
}
body.theme-dark .nkbk-ai-library { background: #212121; color: #ececec; }
.nkbk-ai-library.hidden { display: none; }

.nkbk-ai-library-inner {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  max-width: 960px;
  width: 100%;
  margin: 0 auto;
  padding: 0 24px;
}

.nkbk-ai-library-head {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 28px 0 16px;
  flex-shrink: 0;
}
.nkbk-ai-library-head h1 {
  margin: 0;
  font-size: 1.75rem;
  font-weight: 600;
  flex-shrink: 0;
  letter-spacing: -0.02em;
}
.nkbk-ai-library-search-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid rgba(0,0,0,0.1);
  border-radius: 999px;
  padding: 9px 16px;
  background: #fff;
  min-width: 0;
}
body.theme-dark .nkbk-ai-library-search-wrap {
  background: #2f2f2f;
  border-color: rgba(255,255,255,0.1);
}
.nkbk-ai-library-search-wrap svg { color: #6e6e80; flex-shrink: 0; }
.nkbk-ai-library-search-wrap input {
  flex: 1;
  border: none;
  background: transparent;
  font: inherit;
  font-size: 0.875rem;
  outline: none;
  color: inherit;
  min-width: 0;
}
.nkbk-ai-library-upload {
  flex-shrink: 0;
  border: none;
  border-radius: 999px;
  background: #0d0d0d;
  color: #fff;
  font: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  padding: 9px 18px;
  cursor: pointer;
  transition: opacity 0.15s;
}
.nkbk-ai-library-upload:hover { opacity: 0.88; }
body.theme-dark .nkbk-ai-library-upload {
  background: #fff;
  color: #0d0d0d;
}

.nkbk-ai-library-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 0 12px;
  flex-shrink: 0;
}
.nkbk-ai-library-toolbar.is-hidden { display: none; }

.nkbk-ai-library-tabs {
  display: inline-flex;
  gap: 4px;
  background: rgba(0,0,0,0.05);
  border-radius: 999px;
  padding: 3px;
}
body.theme-dark .nkbk-ai-library-tabs { background: rgba(255,255,255,0.08); }
.nkbk-ai-library-tab {
  border: none;
  border-radius: 999px;
  background: transparent;
  color: #6e6e80;
  font: inherit;
  font-size: 0.8125rem;
  font-weight: 500;
  padding: 7px 14px;
  cursor: pointer;
}
.nkbk-ai-library-tab.is-active {
  background: #fff;
  color: #0d0d0d;
  box-shadow: 0 1px 2px rgba(0,0,0,0.06);
}
body.theme-dark .nkbk-ai-library-tab.is-active {
  background: #424242;
  color: #fff;
}

.nkbk-ai-library-toolbar-right {
  display: flex;
  align-items: center;
  gap: 4px;
}
.nkbk-ai-library-view-btn {
  width: 34px;
  height: 34px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: #6e6e80;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.nkbk-ai-library-view-btn:hover { background: rgba(0,0,0,0.05); }
.nkbk-ai-library-view-btn.is-active {
  background: rgba(0,0,0,0.06);
  color: #0d0d0d;
}
body.theme-dark .nkbk-ai-library-view-btn.is-active {
  background: rgba(255,255,255,0.1);
  color: #fff;
}

.nkbk-ai-library-selection-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 0 14px;
  flex-shrink: 0;
}
.nkbk-ai-library-selection-bar.hidden { display: none; }
.nkbk-ai-library-selection-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}
.nkbk-ai-library-action {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 1px solid rgba(0,0,0,0.12);
  border-radius: 999px;
  background: #fff;
  color: #0d0d0d;
  font: inherit;
  font-size: 0.8125rem;
  font-weight: 500;
  padding: 7px 14px;
  cursor: pointer;
}
.nkbk-ai-library-action:hover { background: #f7f7f8; }
.nkbk-ai-library-action--primary {
  background: #0d0d0d;
  border-color: #0d0d0d;
  color: #fff;
}
.nkbk-ai-library-action--primary:hover { opacity: 0.9; background: #0d0d0d; }
.nkbk-ai-library-action--danger { color: #dc2626; border-color: rgba(220,38,38,0.25); }
.nkbk-ai-library-action--danger:hover { background: rgba(220,38,38,0.06); }
body.theme-dark .nkbk-ai-library-action {
  background: #2f2f2f;
  border-color: rgba(255,255,255,0.12);
  color: #ececec;
}
body.theme-dark .nkbk-ai-library-action--primary {
  background: #fff;
  color: #0d0d0d;
}
.nkbk-ai-library-selection-count {
  font-size: 0.8125rem;
  color: #6e6e80;
  white-space: nowrap;
}

.nkbk-ai-library-list-view {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.nkbk-ai-library-list-view.hidden { display: none; }

.nkbk-ai-library-table-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 140px 88px 40px;
  gap: 12px;
  padding: 6px 8px 10px;
  font-size: 0.75rem;
  font-weight: 600;
  color: #6e6e80;
  border-bottom: 1px solid rgba(0,0,0,0.06);
  flex-shrink: 0;
}
.nkbk-ai-library-table-head .col-date {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
body.theme-dark .nkbk-ai-library-table-head { border-bottom-color: rgba(255,255,255,0.08); }

.nkbk-ai-library-list {
  flex: 1;
  overflow-y: auto;
  padding: 2px 0 24px;
}

.nkbk-ai-library-row {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) 140px 88px 40px;
  gap: 12px;
  align-items: center;
  padding: 8px;
  border-radius: 10px;
  cursor: pointer;
  border: none;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  width: 100%;
}
.nkbk-ai-library-row:hover,
.nkbk-ai-library-row.is-selected { background: rgba(0,0,0,0.04); }
body.theme-dark .nkbk-ai-library-row:hover,
body.theme-dark .nkbk-ai-library-row.is-selected { background: rgba(255,255,255,0.05); }

.nkbk-ai-library-row-check {
  width: 18px;
  height: 18px;
  border: 1.5px solid rgba(0,0,0,0.2);
  border-radius: 4px;
  background: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.12s;
  flex-shrink: 0;
  padding: 0;
}
.nkbk-ai-library-row:hover .nkbk-ai-library-row-check,
.nkbk-ai-library-row.is-selected .nkbk-ai-library-row-check,
.nkbk-ai-library-row-check.is-checked,
.nkbk-ai-library-row-check:focus-visible {
  opacity: 1;
}
.nkbk-ai-library-row-check.is-checked {
  background: #0d0d0d;
  border-color: #0d0d0d;
  color: #fff;
}
.nkbk-ai-library-row-check svg { width: 12px; height: 12px; }

.nkbk-ai-library-row-name {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}
.nkbk-ai-library-thumb {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  background: #f3f4f6;
  flex-shrink: 0;
}
.nkbk-ai-library-thumb--doc {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  font-size: 0.62rem;
  font-weight: 700;
  color: #6e6e80;
  letter-spacing: 0.03em;
}
.nkbk-ai-library-row-title {
  font-size: 0.875rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.nkbk-ai-library-row-date,
.nkbk-ai-library-row-size {
  font-size: 0.8125rem;
  color: #6e6e80;
}

.nkbk-ai-library-row-menu-wrap {
  position: relative;
  display: flex;
  justify-content: flex-end;
}
.nkbk-ai-library-row-more {
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: #6e6e80;
  cursor: pointer;
  opacity: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.nkbk-ai-library-row:hover .nkbk-ai-library-row-more,
.nkbk-ai-library-row-menu-wrap.is-open .nkbk-ai-library-row-more { opacity: 1; }
.nkbk-ai-library-row-more:hover { background: rgba(0,0,0,0.06); }

.nkbk-ai-library-row-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  min-width: 160px;
  background: #fff;
  border: 1px solid rgba(0,0,0,0.08);
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.12);
  padding: 4px;
  z-index: 30;
}
.nkbk-ai-library-row-dropdown.hidden { display: none; }
.nkbk-ai-library-row-dropdown button {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  border: none;
  background: transparent;
  color: #0d0d0d;
  font: inherit;
  font-size: 0.8125rem;
  padding: 9px 12px;
  border-radius: 8px;
  cursor: pointer;
  text-align: left;
}
.nkbk-ai-library-row-dropdown button:hover { background: rgba(0,0,0,0.05); }
.nkbk-ai-library-row-dropdown button.is-danger { color: #dc2626; }

.nkbk-ai-library-grid-view {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 4px 0 24px;
}
.nkbk-ai-library-grid-view.hidden { display: none; }

.nkbk-ai-library-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
}

.nkbk-ai-library-card {
  position: relative;
  aspect-ratio: 1;
  border: none;
  border-radius: 14px;
  overflow: hidden;
  cursor: pointer;
  padding: 0;
  background: #f3f4f6;
}
.nkbk-ai-library-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.nkbk-ai-library-card.is-selected::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.45);
  pointer-events: none;
}
.nkbk-ai-library-card-check {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.85);
  background: rgba(0,0,0,0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  z-index: 2;
  cursor: pointer;
  padding: 0;
  color: #fff;
}
.nkbk-ai-library-card:hover .nkbk-ai-library-card-check,
.nkbk-ai-library-card.is-selected .nkbk-ai-library-card-check,
.nkbk-ai-library-card-check.is-checked,
.nkbk-ai-library-card-check:focus-visible {
  opacity: 1;
}
.nkbk-ai-library-card.is-selected .nkbk-ai-library-card-check,
.nkbk-ai-library-card-check.is-checked {
  background: #fff;
  border-color: #fff;
  color: #0d0d0d;
}
.nkbk-ai-library-card-meta {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 28px 10px 10px;
  background: linear-gradient(transparent, rgba(0,0,0,0.72));
  color: #fff;
  font-size: 0.72rem;
  line-height: 1.35;
  text-align: left;
  opacity: 0;
  transition: opacity 0.15s;
  pointer-events: none;
}
.nkbk-ai-library-card:hover .nkbk-ai-library-card-meta,
.nkbk-ai-library-card.is-selected .nkbk-ai-library-card-meta { opacity: 1; }
.nkbk-ai-library-card-title {
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.nkbk-ai-library-card-sub { opacity: 0.85; margin-top: 2px; }

.nkbk-ai-library-empty {
  padding: 48px 24px;
  text-align: center;
  color: #6e6e80;
  font-size: 0.875rem;
}

.sidebar-nav-item.is-active {
  background: rgba(0,0,0,0.06);
}
body.theme-dark .sidebar-nav-item.is-active {
  background: rgba(255,255,255,0.08);
}

@media (max-width: 768px) {
  .sidebar-icon-btn { display: none; }
  .sidebar-expand-btn { display: none; }
  .sidebar-head .sidebar-close { display: inline-flex; align-items: center; justify-content: center; margin-left: auto; }
  .nkbk-ai-library-inner { padding: 0 12px; }
  .nkbk-ai-library-head {
    flex-wrap: wrap;
    padding-top: 16px;
  }
  .nkbk-ai-library-head h1 { width: 100%; }
  .nkbk-ai-library-search-wrap { order: 3; flex: 1 1 100%; }
  .nkbk-ai-library-upload { margin-left: auto; }
  .nkbk-ai-library-table-head,
  .nkbk-ai-library-row {
    grid-template-columns: 24px minmax(0, 1fr) 90px 36px;
  }
  .nkbk-ai-library-table-head .col-size,
  .nkbk-ai-library-row-size { display: none; }
  .nkbk-ai-header {
    justify-content: flex-start;
    padding: 10px 12px;
    gap: 6px;
  }
  .nkbk-ai-header-main {
    flex: 0 0 auto;
    min-width: 0;
  }
  .nkbk-ai-header-actions {
    margin-left: auto;
    flex-shrink: 0;
  }
  .nkbk-ai-header-text h1 {
    font-size: 1.05rem;
    white-space: nowrap;
  }
}
@media (min-width: 769px) {
  .sidebar-head .sidebar-close { display: none; }
  body.sidebar-collapsed .sidebar-head:hover .sidebar-logo {
    opacity: 0;
    pointer-events: none;
  }
  body.sidebar-collapsed .sidebar-head:hover .sidebar-expand-btn {
    display: inline-flex;
  }
  body.sidebar-collapsed .sidebar-profile-menu {
    left: calc(100% + 8px);
    right: auto;
    bottom: 0;
    min-width: 260px;
  }
}

/* Mini sidebar (icon rail) — ใช้ได้ทุก viewport เมื่อ sidebar-collapsed */
body.sidebar-collapsed .nkbk-ai-sidebar {
  width: 52px;
  min-width: 52px;
  padding: 8px 6px 6px;
}
body.sidebar-collapsed .sidebar-icon-btn {
  display: none;
}
body.sidebar-collapsed .sidebar-expand-btn {
  display: none;
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
}
body.sidebar-collapsed .sidebar-head {
  justify-content: center;
  padding: 4px 0 8px;
  min-height: 44px;
}
body.sidebar-collapsed .sidebar-nav {
  padding: 0 0 8px;
}
body.sidebar-collapsed .sidebar-nav-item {
  justify-content: center;
  padding: 10px 8px;
  gap: 0;
}
body.sidebar-collapsed .sidebar-nav-item span { display: none; }
body.sidebar-collapsed .sidebar-section { display: none; }
body.sidebar-collapsed .sidebar-foot {
  padding: 8px 2px 4px;
  margin-top: auto;
}
body.sidebar-collapsed .sidebar-profile {
  justify-content: center;
  padding: 8px 4px;
}
body.sidebar-collapsed .sidebar-profile-text,
body.sidebar-collapsed .sidebar-profile-store { display: none; }

.nkbk-ai-settings-body {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding-top: 8px !important;
  padding-bottom: 12px !important;
}

.nkbk-ai-settings-box {
  width: min(960px, calc(100vw - 32px));
  max-height: min(720px, calc(100vh - 48px));
  display: flex;
  flex-direction: column;
  font-family: 'Inter', 'Noto Sans Thai', system-ui, -apple-system, sans-serif;
}
.nkbk-ai-settings-shell {
  display: flex;
  min-height: min(520px, calc(100vh - 80px));
  overflow: hidden;
}
.nkbk-ai-settings-nav {
  width: 260px;
  flex-shrink: 0;
  border-right: 1px solid var(--border);
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: rgba(0,0,0,0.02);
}
body.theme-dark .nkbk-ai-settings-nav {
  background: rgba(255,255,255,0.02);
}
.nkbk-ai-settings-close {
  align-self: flex-start;
  border: none;
  background: transparent;
  color: var(--muted);
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  margin-bottom: 4px;
}
.nkbk-ai-settings-close:hover {
  background: rgba(0,0,0,0.06);
  color: var(--text);
}
body.theme-dark .nkbk-ai-settings-close:hover {
  background: rgba(255,255,255,0.08);
}
.nkbk-ai-settings-nav-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.nkbk-ai-settings-nav-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  border: none;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 0.875rem;
  padding: 10px 12px;
  border-radius: 10px;
  cursor: pointer;
  text-align: left;
}
.nkbk-ai-settings-nav-item svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  color: #6e6e80;
}
.nkbk-ai-settings-nav-item:hover {
  background: rgba(0,0,0,0.05);
}
body.theme-dark .nkbk-ai-settings-nav-item:hover {
  background: rgba(255,255,255,0.06);
}
.nkbk-ai-settings-nav-item.is-active {
  background: rgba(0,0,0,0.06);
  font-weight: 600;
}
body.theme-dark .nkbk-ai-settings-nav-item.is-active {
  background: rgba(255,255,255,0.08);
}
.nkbk-ai-settings-main {
  flex: 1;
  overflow-y: auto;
  padding: 24px 28px 28px;
  min-width: 0;
}
.nkbk-ai-settings-panel.hidden { display: none; }
.nkbk-ai-settings-panel-title {
  margin: 0 0 20px;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text);
}
.nkbk-ai-settings-panel-desc {
  margin: -12px 0 20px;
  color: var(--muted);
  font-size: 0.875rem;
  line-height: 1.5;
}
.nkbk-ai-settings-rows {
  display: flex;
  flex-direction: column;
  border-top: 1px solid var(--border);
}
.nkbk-ai-settings-row {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border: none;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 0.9375rem;
  padding: 16px 4px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  text-align: left;
}
.nkbk-ai-settings-row:hover {
  background: rgba(0,0,0,0.03);
}
body.theme-dark .nkbk-ai-settings-row:hover {
  background: rgba(255,255,255,0.04);
}
.nkbk-ai-settings-row-label { font-weight: 500; }
.nkbk-ai-settings-row-value {
  color: var(--muted);
  font-size: 0.875rem;
}
.nkbk-ai-settings-panel-foot {
  display: flex;
  justify-content: flex-end;
  margin-top: 20px;
  padding-top: 8px;
}
@media (max-width: 640px) {
  .nkbk-ai-settings-shell {
    flex-direction: column;
    min-height: auto;
  }
  .nkbk-ai-settings-nav {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--border);
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    padding: 10px;
  }
  .nkbk-ai-settings-nav-list {
    flex-direction: row;
    flex-wrap: wrap;
    flex: 1;
  }
  .nkbk-ai-settings-main {
    padding: 18px 16px 20px;
  }
}

.nkbk-ai-settings-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  border: none;
  border-radius: 12px;
  background: transparent;
  color: var(--text);
  font: inherit;
  padding: 12px 14px;
  cursor: pointer;
  text-align: left;
}
.nkbk-ai-settings-item:hover { background: rgba(0,0,0,0.05); }
body.theme-dark .nkbk-ai-settings-item:hover { background: rgba(255,255,255,0.06); }
.nkbk-ai-settings-item svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  color: #5d5d5d;
}
.nkbk-ai-settings-item-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.nkbk-ai-settings-item-title {
  font-size: 0.9rem;
  font-weight: 500;
}
.nkbk-ai-settings-item-sub {
  font-size: 0.78rem;
  color: #6e6e80;
}

/* Settings — extended panels */
.nkbk-ai-settings-section {
  margin-bottom: 28px;
}
.nkbk-ai-settings-section:last-child { margin-bottom: 0; }
.nkbk-ai-settings-section-title {
  margin: 0 0 12px;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.nkbk-ai-settings-row-static {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 4px;
  border-bottom: 1px solid var(--border);
}
.nkbk-ai-settings-row-static .nkbk-ai-settings-row-label {
  font-weight: 500;
  flex: 1;
  min-width: 0;
}
.nkbk-ai-settings-row-desc {
  margin: 4px 0 0;
  font-size: 0.8125rem;
  color: var(--muted);
  line-height: 1.45;
  font-weight: 400;
}
.nkbk-ai-settings-row-action {
  flex-shrink: 0;
  display: flex;
  align-items: center;
}

/* Theme picker */
.nkbk-ai-settings-group--theme {
  padding-bottom: 8px;
}
.nkbk-ai-settings-group-title {
  display: block;
  font-weight: 600;
  font-size: 0.9375rem;
}
.nkbk-ai-settings-group-desc {
  margin: 4px 0 0;
  font-size: 0.8125rem;
  color: var(--muted, #8e8e93);
  line-height: 1.45;
  max-width: 36rem;
}
.nkbk-ai-theme-picker {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
}
@media (max-width: 640px) {
  .nkbk-ai-theme-picker {
    grid-template-columns: 1fr;
  }
}
.nkbk-ai-theme-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
  min-height: 118px;
  padding: 14px 14px 12px;
  border: 1.5px solid var(--border, rgba(0, 0, 0, 0.1));
  border-radius: 14px;
  background: var(--surface, #fff);
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.18s, background 0.18s, box-shadow 0.18s, transform 0.12s;
}
.nkbk-ai-theme-card:hover {
  border-color: rgba(0, 0, 0, 0.22);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.06);
}
body.theme-dark .nkbk-ai-theme-card {
  background: rgba(255, 255, 255, 0.03);
  border-color: rgba(255, 255, 255, 0.1);
}
body.theme-dark .nkbk-ai-theme-card:hover {
  border-color: rgba(255, 255, 255, 0.22);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.28);
}
.nkbk-ai-theme-card.is-active {
  border-color: var(--text);
  box-shadow: 0 0 0 1px var(--text);
  background: rgba(0, 0, 0, 0.03);
}
body.theme-dark .nkbk-ai-theme-card.is-active {
  background: rgba(255, 255, 255, 0.06);
}
.nkbk-ai-theme-card-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.05);
  color: var(--text);
}
body.theme-dark .nkbk-ai-theme-card-icon {
  background: rgba(255, 255, 255, 0.08);
}
.nkbk-ai-theme-card-icon svg {
  width: 20px;
  height: 20px;
}
.nkbk-ai-theme-card-body {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
}
.nkbk-ai-theme-card-label {
  font-size: 0.875rem;
  font-weight: 600;
}
.nkbk-ai-theme-card-desc {
  font-size: 0.75rem;
  line-height: 1.4;
  color: var(--muted, #8e8e93);
}
.nkbk-ai-theme-card-check {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 20px;
  height: 20px;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--text);
  color: var(--surface, #fff);
  opacity: 0;
  transform: scale(0.85);
  transition: opacity 0.15s, transform 0.15s;
}
.nkbk-ai-theme-card-check svg {
  width: 12px;
  height: 12px;
}
.nkbk-ai-theme-card.is-active .nkbk-ai-theme-card-check {
  opacity: 1;
  transform: scale(1);
}

.nkbk-ai-settings-row-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
.nkbk-ai-notify-sound-panel {
  margin-top: 20px;
  padding-top: 4px;
}
.nkbk-ai-notify-sound-panel-inner {
  padding: 18px;
  border-radius: 16px;
  border: 1px solid var(--border, rgba(0, 0, 0, 0.1));
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.02) 0%, rgba(0, 0, 0, 0.01) 100%);
}
body.theme-dark .nkbk-ai-notify-sound-panel-inner {
  border-color: rgba(255, 255, 255, 0.1);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.05) 0%, rgba(255, 255, 255, 0.02) 100%);
}
.nkbk-ai-notify-sound-panel-title {
  margin: 0;
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text);
}
.nkbk-ai-notify-sound-panel-desc {
  margin: 6px 0 0;
  font-size: 0.8125rem;
  color: var(--muted, #8e8e93);
  line-height: 1.45;
}
.nkbk-ai-sound-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 16px;
}
@media (min-width: 520px) {
  .nkbk-ai-sound-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}
.nkbk-ai-sound-chip {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  padding: 12px 10px;
  border: 1.5px solid var(--border, rgba(0, 0, 0, 0.1));
  border-radius: 12px;
  background: var(--surface, #fff);
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s, transform 0.1s;
}
.nkbk-ai-sound-chip:hover {
  border-color: rgba(0, 0, 0, 0.22);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
}
.nkbk-ai-sound-chip.is-active {
  border-color: var(--text);
  box-shadow: 0 0 0 1px var(--text);
  background: rgba(0, 0, 0, 0.03);
}
body.theme-dark .nkbk-ai-sound-chip {
  background: rgba(255, 255, 255, 0.03);
  border-color: rgba(255, 255, 255, 0.1);
}
body.theme-dark .nkbk-ai-sound-chip:hover {
  border-color: rgba(255, 255, 255, 0.22);
}
body.theme-dark .nkbk-ai-sound-chip.is-active {
  background: rgba(255, 255, 255, 0.07);
}
.nkbk-ai-sound-chip-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.05);
  color: var(--text);
}
body.theme-dark .nkbk-ai-sound-chip-icon {
  background: rgba(255, 255, 255, 0.08);
}
.nkbk-ai-sound-chip-icon svg {
  width: 16px;
  height: 16px;
}
.nkbk-ai-sound-chip-label {
  font-size: 0.8125rem;
  font-weight: 600;
}
.nkbk-ai-sound-chip-hint {
  font-size: 0.6875rem;
  color: var(--muted, #8e8e93);
  line-height: 1.3;
}
.nkbk-ai-sound-play-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  margin-top: 14px;
  padding: 12px 16px;
  border: none;
  border-radius: 12px;
  background: var(--text);
  color: var(--surface, #fff);
  font: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
}
.nkbk-ai-sound-play-btn svg {
  width: 16px;
  height: 16px;
}
.nkbk-ai-sound-play-btn:hover {
  opacity: 0.92;
}
.nkbk-ai-sound-play-btn:active {
  transform: scale(0.99);
}
body.theme-dark .nkbk-ai-sound-play-btn {
  background: #fff;
  color: #111;
}

/* Toggle switch */
.nkbk-ai-switch {
  position: relative;
  display: inline-flex;
  width: 44px;
  height: 26px;
  flex-shrink: 0;
}
.nkbk-ai-switch input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}
.nkbk-ai-switch-slider {
  position: absolute;
  inset: 0;
  background: #c4c4c4;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.2s;
}
.nkbk-ai-switch-slider::before {
  content: '';
  position: absolute;
  width: 20px;
  height: 20px;
  left: 3px;
  top: 3px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}
.nkbk-ai-switch input:checked + .nkbk-ai-switch-slider {
  background: #10a37f;
}
.nkbk-ai-switch input:checked + .nkbk-ai-switch-slider::before {
  transform: translateX(18px);
}
.nkbk-ai-switch input:focus-visible + .nkbk-ai-switch-slider {
  outline: 2px solid #10a37f;
  outline-offset: 2px;
}

/* Text fields in settings */
.nkbk-ai-settings-field {
  width: 100%;
  max-width: 320px;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  font: inherit;
  font-size: 0.875rem;
  background: var(--surface, #fff);
  color: var(--text);
}
.nkbk-ai-settings-field:focus {
  outline: 2px solid rgba(16,163,127,0.35);
  border-color: #10a37f;
}
.nkbk-ai-settings-textarea {
  max-width: 100%;
  min-height: 88px;
  resize: vertical;
}

/* Storage */
.nkbk-ai-storage-overview {
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: rgba(0,0,0,0.02);
  margin-bottom: 20px;
}
body.theme-dark .nkbk-ai-storage-overview {
  background: rgba(255,255,255,0.03);
}
.nkbk-ai-storage-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 12px;
}
.nkbk-ai-storage-used {
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--text);
}
.nkbk-ai-storage-quota {
  font-size: 0.8125rem;
  color: var(--muted);
}
.nkbk-ai-storage-bar {
  height: 10px;
  border-radius: 999px;
  background: rgba(0,0,0,0.08);
  overflow: hidden;
}
body.theme-dark .nkbk-ai-storage-bar {
  background: rgba(255,255,255,0.1);
}
.nkbk-ai-storage-bar-fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #10a37f, #0d8f6e);
  transition: width 0.35s ease;
}
.nkbk-ai-storage-bar-fill.is-warning {
  background: linear-gradient(90deg, #f5a623, #e67e22);
}
.nkbk-ai-storage-bar-fill.is-danger {
  background: linear-gradient(90deg, #ef4444, #dc2626);
}
.nkbk-ai-storage-breakdown {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}
.nkbk-ai-storage-card {
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface, #fff);
}
.nkbk-ai-storage-card-title {
  font-size: 0.8125rem;
  color: var(--muted);
  margin-bottom: 6px;
}
.nkbk-ai-storage-card-value {
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--text);
}
.nkbk-ai-storage-card-sub {
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 4px;
}

/* List items (shared links, archived) */
.nkbk-ai-settings-list {
  display: flex;
  flex-direction: column;
  border-top: 1px solid var(--border);
}
.nkbk-ai-settings-list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 4px;
  border-bottom: 1px solid var(--border);
}
.nkbk-ai-settings-list-main {
  flex: 1;
  min-width: 0;
}
.nkbk-ai-settings-list-title {
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.nkbk-ai-settings-list-meta {
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 2px;
}
.nkbk-ai-settings-list-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}
.nkbk-ai-settings-btn {
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 0.8125rem;
  padding: 6px 12px;
  border-radius: 8px;
  cursor: pointer;
  white-space: nowrap;
}
.nkbk-ai-settings-btn:hover {
  background: rgba(0,0,0,0.04);
}
body.theme-dark .nkbk-ai-settings-btn:hover {
  background: rgba(255,255,255,0.06);
}
.nkbk-ai-settings-btn-danger {
  border-color: rgba(239,68,68,0.4);
  color: #ef4444;
}
.nkbk-ai-settings-btn-danger:hover {
  background: rgba(239,68,68,0.08);
}
.nkbk-ai-settings-empty {
  padding: 24px 4px;
  text-align: center;
  color: var(--muted);
  font-size: 0.875rem;
}

/* Danger zone */
.nkbk-ai-settings-danger {
  margin-top: 24px;
  padding: 18px;
  border: 1px solid rgba(239,68,68,0.35);
  border-radius: 12px;
  background: rgba(239,68,68,0.04);
}
.nkbk-ai-settings-danger-title {
  margin: 0 0 6px;
  font-size: 0.9375rem;
  font-weight: 600;
  color: #ef4444;
}
.nkbk-ai-settings-danger-desc {
  margin: 0 0 14px;
  font-size: 0.8125rem;
  color: var(--muted);
  line-height: 1.45;
}

/* Account */
.nkbk-ai-account-card {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 4px;
  border-bottom: 1px solid var(--border);
}
.nkbk-ai-account-avatar {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  object-fit: cover;
  background: rgba(0,0,0,0.06);
  flex-shrink: 0;
}
.nkbk-ai-account-avatar-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--muted);
}
.nkbk-ai-account-fields {
  display: flex;
  flex-direction: column;
  border-top: 1px solid var(--border);
}
.nkbk-ai-account-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 16px 4px;
  border-bottom: 1px solid var(--border);
}
.nkbk-ai-account-label {
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--text);
}
.nkbk-ai-account-value {
  font-size: 0.875rem;
  color: var(--muted);
  text-align: right;
  word-break: break-word;
}

.nkbk-ai-settings-save-btn {
  border: none;
  background: #10a37f;
  color: #fff;
  font: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  padding: 10px 18px;
  border-radius: 10px;
  cursor: pointer;
}
.nkbk-ai-settings-save-btn:hover { background: #0d8f6e; }
.nkbk-ai-settings-save-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

@media (max-width: 640px) {
  .nkbk-ai-settings-row-static {
    flex-direction: column;
    align-items: stretch;
  }
  .nkbk-ai-settings-row-action {
    justify-content: flex-start;
  }
  .nkbk-ai-settings-list-item {
    flex-direction: column;
    align-items: stretch;
  }
  .nkbk-ai-settings-list-actions {
    justify-content: flex-end;
  }
}

/* Settings — layout helpers used in index.html */
.nkbk-ai-settings-group {
  padding: 4px 0 8px;
  border-bottom: 1px solid var(--border);
}
.nkbk-ai-settings-group-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  font-weight: 500;
  font-size: 0.9375rem;
}
.nkbk-ai-settings-subtitle {
  margin: 24px 0 12px;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.nkbk-ai-settings-subtitle:first-of-type { margin-top: 0; }
.nkbk-ai-settings-toggle-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 4px;
  border-bottom: 1px solid var(--border);
}
.nkbk-ai-settings-toggle-text { flex: 1; min-width: 0; }
.nkbk-ai-settings-toggle-label {
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--text);
}
.nkbk-ai-settings-toggle-desc {
  margin-top: 4px;
  font-size: 0.8125rem;
  color: var(--muted);
  line-height: 1.45;
}
.nkbk-ai-settings-row--static {
  cursor: default;
}
.nkbk-ai-settings-row--static:hover { background: transparent; }
.nkbk-ai-settings-row--static .nkbk-ai-settings-row-label {
  pointer-events: none;
}
.nkbk-ai-settings-row--static button,
.nkbk-ai-settings-row--static a {
  pointer-events: auto;
  cursor: pointer;
}
.nkbk-ai-settings-list-sub {
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 2px;
}
.nkbk-ai-btn-sm {
  padding: 5px 10px !important;
  font-size: 0.78rem !important;
}
.nkbk-ai-btn-danger-text {
  color: #ef4444 !important;
  border-color: rgba(239,68,68,0.35) !important;
}
.nkbk-ai-btn-danger-text:hover {
  background: rgba(239,68,68,0.08) !important;
}
.nkbk-ai-btn-danger {
  border: none;
  background: #ef4444;
  color: #fff;
  font: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  padding: 10px 18px;
  border-radius: 10px;
  cursor: pointer;
}
.nkbk-ai-btn-danger:hover { background: #dc2626; }
.nkbk-ai-settings-danger-zone {
  margin-top: 28px;
  padding: 18px;
  border: 1px solid rgba(239,68,68,0.35);
  border-radius: 12px;
  background: rgba(239,68,68,0.04);
}
.nkbk-ai-settings-danger-zone .nkbk-ai-settings-subtitle {
  margin-top: 0;
  color: #ef4444;
  text-transform: none;
  letter-spacing: 0;
  font-size: 0.9375rem;
}
.nkbk-ai-storage-bar-wrap { margin: 8px 0 10px; }
.nkbk-ai-storage-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.8125rem;
  color: var(--muted);
}
.nkbk-ai-storage-meta strong { color: var(--text); }
.nkbk-ai-settings-rows--data {
  margin-top: 0;
  border-top: 1px solid var(--border);
}
.nkbk-ai-settings-rows--data .nkbk-ai-settings-toggle-row {
  border-bottom: 1px solid var(--border);
  margin: 0;
}
.nkbk-ai-settings-row--danger-action {
  border-bottom: none;
}
.nkbk-ai-settings-row-label--danger { color: #ef4444; }
.nkbk-ai-data-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.25rem;
  height: 1.25rem;
  padding: 0 6px;
  margin-left: 4px;
  border-radius: 999px;
  background: rgba(0,0,0,0.08);
  font-size: 0.75rem;
  font-weight: 600;
}
body.theme-dark .nkbk-ai-data-badge { background: rgba(255,255,255,0.12); }
.nkbk-ai-data-table-modal {
  max-width: 640px;
  width: calc(100% - 32px);
  max-height: 80vh;
  display: flex;
  flex-direction: column;
}
.nkbk-ai-data-table-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
}
.nkbk-ai-data-table-head h3 { margin: 0; font-size: 1rem; font-weight: 600; }
.nkbk-ai-data-table-wrap {
  flex: 1;
  overflow: auto;
  padding: 8px 12px 16px;
  min-height: 120px;
}
.nkbk-ai-data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}
.nkbk-ai-data-table th {
  text-align: left;
  font-weight: 600;
  color: var(--muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.nkbk-ai-data-table td {
  padding: 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.nkbk-ai-data-table tr:last-child td { border-bottom: none; }
.nkbk-ai-data-table-title {
  font-weight: 500;
  color: var(--text);
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.nkbk-ai-data-table-date {
  color: var(--muted);
  white-space: nowrap;
  font-size: 0.8125rem;
}
.nkbk-ai-data-table-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  white-space: nowrap;
}
.nkbk-ai-data-table-actions-col { text-align: right; width: 140px; }

.nkbk-ai-account-rows { border-top: none; width: 100%; }
.nkbk-ai-account-card {
  display: flex;
  align-items: flex-start;
  gap: 20px;
  padding-top: 4px;
}
.nkbk-ai-account-card .nkbk-ai-account-avatar {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
  background: rgba(0,0,0,0.06);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--muted);
}
.nkbk-ai-account-card .nkbk-ai-account-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Global button press feedback */
.nkbk-ai-memory-action,
.nkbk-ai-settings-nav-item,
.nkbk-ai-theme-card,
.nkbk-ai-sound-chip,
.nkbk-ai-sound-play-btn,
.nkbk-ai-library-picker-card,
.nkbk-ai-settings-row:not(.nkbk-ai-settings-row--static),
.nkbk-ai-btn-danger,
.nkbk-ai-btn-danger-text,
.nkbk-ai-sidebar-new,
.nkbk-ai-viewer-composer-send {
  transition: transform 0.14s ease, filter 0.14s ease, background 0.15s, border-color 0.15s, box-shadow 0.15s;
}
.nkbk-ai-memory-action.is-pressed:not(:disabled),
.nkbk-ai-settings-nav-item.is-pressed,
.nkbk-ai-theme-card.is-pressed,
.nkbk-ai-sound-chip.is-pressed,
.nkbk-ai-library-picker-card.is-pressed:not(:disabled),
.nkbk-ai-settings-row.is-pressed:not(.nkbk-ai-settings-row--static),
.nkbk-ai-btn-danger.is-pressed:not(:disabled),
.nkbk-ai-btn-danger-text.is-pressed:not(:disabled) {
  transform: scale(0.97);
  filter: brightness(0.96);
}
.nkbk-ai-sound-play-btn.is-pressed {
  transform: scale(0.98);
  filter: brightness(0.92);
}
.nkbk-ai-memory-file-remove.is-pressed {
  transform: scale(0.9);
  background: rgba(255, 80, 80, 0.16);
}

/* ── Saved prompts ── */
.nkbk-ai-composer-wrap {
  position: relative;
}
.nkbk-ai-composer-prompts {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s, color 0.15s, transform 0.14s;
}
.nkbk-ai-composer-prompts:hover {
  background: rgba(0, 229, 184, 0.1);
  color: var(--accent, #10a37f);
}
.nkbk-ai-prompt-suggest {
  margin: 0 auto 10px;
  max-width: min(720px, calc(100% - 24px));
  animation: nkbk-prompt-suggest-in 0.28s ease;
}
@keyframes nkbk-prompt-suggest-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}
.nkbk-ai-prompt-suggest-inner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid rgba(0, 229, 184, 0.35);
  background: linear-gradient(135deg, rgba(0, 229, 184, 0.1), rgba(0, 168, 132, 0.06));
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.06);
}
.nkbk-ai-prompt-suggest-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 229, 184, 0.16);
  color: var(--accent, #10a37f);
  flex-shrink: 0;
}
.nkbk-ai-prompt-suggest-icon svg { width: 18px; height: 18px; }
.nkbk-ai-prompt-suggest-text { flex: 1; min-width: 0; }
.nkbk-ai-prompt-suggest-title {
  margin: 0;
  font-size: 0.8125rem;
  font-weight: 700;
  color: var(--text);
}
.nkbk-ai-prompt-suggest-preview,
.nkbk-ai-prompt-suggest-count {
  margin: 2px 0 0;
  font-size: 0.75rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.nkbk-ai-prompt-suggest-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}
.nkbk-ai-prompt-picker {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 8px);
  transform: translateX(-50%);
  width: min(420px, calc(100vw - 32px));
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface, #fff);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.14);
  z-index: 40;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
}
.nkbk-ai-prompt-picker.open {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(-50%) translateY(-2px);
}
body.theme-dark .nkbk-ai-prompt-picker {
  background: #1e1e1e;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.45);
}
.nkbk-ai-prompt-picker-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px 8px;
}
.nkbk-ai-prompt-picker-head h3 {
  margin: 0;
  font-size: 0.9375rem;
  font-weight: 700;
}
.nkbk-ai-prompt-picker-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 12px 8px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.02);
}
.nkbk-ai-prompt-picker-toolbar svg {
  width: 16px;
  height: 16px;
  color: var(--muted);
  flex-shrink: 0;
}
.nkbk-ai-prompt-picker-search {
  flex: 1;
  border: none;
  background: transparent;
  font: inherit;
  font-size: 0.875rem;
  color: var(--text);
  outline: none;
}
.nkbk-ai-prompt-picker-list {
  max-height: 280px;
  overflow: auto;
  padding: 0 8px 8px;
}
.nkbk-ai-prompt-picker-item {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  width: 100%;
  border: 1px solid transparent;
  border-radius: 12px;
  background: transparent;
  padding: 10px 12px;
  text-align: left;
  cursor: pointer;
  font: inherit;
  color: var(--text);
  transition: background 0.15s, border-color 0.15s;
}
.nkbk-ai-prompt-picker-item:hover {
  background: rgba(0, 229, 184, 0.08);
  border-color: rgba(0, 229, 184, 0.2);
}
.nkbk-ai-prompt-picker-item-title {
  font-size: 0.875rem;
  font-weight: 600;
}
.nkbk-ai-prompt-picker-item-preview {
  font-size: 0.75rem;
  color: var(--muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.nkbk-ai-prompt-picker-empty {
  padding: 24px 16px;
  text-align: center;
  font-size: 0.8125rem;
  color: var(--muted);
}
.nkbk-ai-prompt-picker-foot {
  padding: 8px 12px 12px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: center;
}
.nkbk-ai-prompts-hero {
  margin: 4px 0 16px;
  padding: 14px 16px;
  border-radius: 14px;
  background: linear-gradient(135deg, rgba(0, 229, 184, 0.12), rgba(0, 168, 132, 0.05));
  border: 1px solid rgba(0, 229, 184, 0.22);
}
.nkbk-ai-prompts-hero-stat { display: flex; flex-direction: column; gap: 2px; }
.nkbk-ai-prompts-hero-num {
  font-size: 1.75rem;
  font-weight: 800;
  line-height: 1;
  color: var(--accent, #10a37f);
}
.nkbk-ai-prompts-hero-label {
  font-size: 0.8125rem;
  color: var(--muted);
}
.nkbk-ai-prompts-compose {
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.02);
  margin-bottom: 18px;
}
body.theme-dark .nkbk-ai-prompts-compose {
  background: rgba(255, 255, 255, 0.03);
}
.nkbk-ai-prompts-textarea {
  width: 100%;
  box-sizing: border-box;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface, #fff);
  color: var(--text);
  font: inherit;
  font-size: 0.875rem;
  padding: 10px 12px;
  resize: vertical;
  min-height: 96px;
}
.nkbk-ai-prompts-compose-foot {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
}
.nkbk-ai-prompt-card-thumb {
  display: block;
  width: 52px;
  height: 52px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  background: rgba(0, 0, 0, 0.04);
  cursor: zoom-in;
  flex-shrink: 0;
  transition: transform 0.14s ease, box-shadow 0.14s ease;
}
.nkbk-ai-prompt-card-thumb:hover {
  transform: scale(1.04);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12);
}
.nkbk-ai-prompt-card-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.nkbk-ai-prompts-list-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}
.nkbk-ai-prompts-list-head .nkbk-ai-settings-subtitle { margin: 0; }
.nkbk-ai-prompts-search {
  width: 160px;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 7px 12px;
  font: inherit;
  font-size: 0.8125rem;
  background: var(--surface, #fff);
  color: var(--text);
}
.nkbk-ai-prompts-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.nkbk-ai-prompt-card {
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface, #fff);
  overflow: hidden;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.nkbk-ai-prompt-card.is-editing {
  border-color: rgba(0, 229, 184, 0.45);
  box-shadow: 0 0 0 3px rgba(0, 229, 184, 0.1);
}
body.theme-dark .nkbk-ai-prompt-card {
  background: rgba(255, 255, 255, 0.03);
}
.nkbk-ai-prompt-card-head {
  display: flex;
  gap: 12px;
  padding: 12px 14px;
  align-items: flex-start;
}
.nkbk-ai-prompt-card-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 229, 184, 0.12);
  color: var(--accent, #10a37f);
  flex-shrink: 0;
}
.nkbk-ai-prompt-card-icon svg { width: 18px; height: 18px; }
.nkbk-ai-prompt-card-main { flex: 1; min-width: 0; }
.nkbk-ai-prompt-card-title {
  margin: 0;
  font-size: 0.9375rem;
  font-weight: 700;
}
.nkbk-ai-prompt-card-preview {
  margin: 4px 0 0;
  font-size: 0.8125rem;
  color: var(--muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.nkbk-ai-prompt-card-meta {
  margin-top: 6px;
  font-size: 0.6875rem;
  color: var(--muted);
}
.nkbk-ai-prompt-card-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex-shrink: 0;
}
.nkbk-ai-prompt-card-btn {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface, #fff);
  color: var(--text);
  font: inherit;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 5px 10px;
  cursor: pointer;
  white-space: nowrap;
}
.nkbk-ai-prompt-card-btn:hover { background: rgba(0, 0, 0, 0.04); }
.nkbk-ai-prompt-card-btn--ghost { color: var(--muted); }
.nkbk-ai-prompt-card-btn--danger {
  color: #ef4444;
  border-color: rgba(239, 68, 68, 0.25);
}
.nkbk-ai-prompts-empty {
  text-align: center;
  padding: 32px 16px;
  border: 1.5px dashed var(--border);
  border-radius: 14px;
}
.nkbk-ai-prompts-empty-icon {
  display: inline-flex;
  width: 44px;
  height: 44px;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  background: rgba(0, 229, 184, 0.1);
  color: var(--accent, #10a37f);
  margin-bottom: 10px;
}
.nkbk-ai-prompts-empty-icon svg { width: 22px; height: 22px; }
.nkbk-ai-prompts-empty-title {
  margin: 0;
  font-weight: 700;
  font-size: 0.9375rem;
}
.nkbk-ai-prompts-empty-desc {
  margin: 6px 0 0;
  font-size: 0.8125rem;
  color: var(--muted);
}
@media (max-width: 640px) {
  .nkbk-ai-prompt-suggest-inner {
    flex-direction: column;
    align-items: stretch;
  }
  .nkbk-ai-prompt-suggest-actions { justify-content: flex-end; }
  .nkbk-ai-prompt-card-head { flex-wrap: wrap; }
  .nkbk-ai-prompt-card-actions {
    flex-direction: row;
    width: 100%;
    justify-content: flex-end;
  }
  .nkbk-ai-prompts-list-head {
    flex-direction: column;
    align-items: stretch;
  }
  .nkbk-ai-prompts-search { width: 100%; }
}

/* Composer + menu */
.nkbk-ai-composer-wrap,
.nkbk-ai-composer,
.nkbk-ai-composer-plus-wrap {
  overflow: visible;
}

.nkbk-ai-composer-plus-wrap {
  position: relative;
  flex-shrink: 0;
  z-index: 2;
}

.nkbk-ai-composer-menu-host {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 0;
  z-index: 1000;
  display: flex;
  flex-direction: row;
  align-items: flex-end;
  gap: 8px;
  pointer-events: auto;
}

.nkbk-ai-composer-menu-host.hidden {
  display: none !important;
}

.nkbk-ai-composer-menu {
  position: relative;
  flex-shrink: 0;
  min-width: 240px;
  width: 240px;
  padding: 6px;
  border-radius: 16px;
  border: 1px solid rgba(0, 0, 0, 0.08);
  background: #fff;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
}

.nkbk-ai-composer-menu-main {
  min-width: 0;
}

body.theme-dark .nkbk-ai-composer-menu {
  background: #2f2f2f;
  border-color: rgba(255, 255, 255, 0.1);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.45);
}

.nkbk-ai-composer-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: inherit;
  font: inherit;
  font-size: 0.875rem;
  text-align: left;
  cursor: pointer;
}

.nkbk-ai-composer-menu-item svg:first-child {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  color: #6e6e80;
}

.nkbk-ai-composer-menu-item span {
  flex: 1;
  min-width: 0;
}

.nkbk-ai-composer-menu-chevron {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  color: #9ca3af;
}

.nkbk-ai-composer-menu-item:hover,
.nkbk-ai-composer-menu-item.is-active {
  background: rgba(0, 0, 0, 0.05);
}

body.theme-dark .nkbk-ai-composer-menu-item:hover,
body.theme-dark .nkbk-ai-composer-menu-item.is-active {
  background: rgba(255, 255, 255, 0.08);
}

.nkbk-ai-composer-flyout {
  position: relative;
  flex-shrink: 0;
  width: min(300px, calc(100vw - 48px));
  max-height: min(420px, 52vh);
  padding: 8px;
  border-radius: 16px;
  border: 1px solid rgba(0, 0, 0, 0.08);
  background: #fff;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
  pointer-events: auto;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

@media (max-width: 768px) {
  .nkbk-ai-composer-menu-portal {
    position: fixed;
    inset: 0;
    z-index: 1300;
    pointer-events: none;
  }

  .nkbk-ai-composer-menu-portal:not(.hidden) {
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: auto;
    padding:
      max(16px, env(safe-area-inset-top, 0px))
      16px
      max(16px, env(safe-area-inset-bottom, 0px));
  }

  .nkbk-ai-composer-menu-portal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.48);
    animation: nkbk-ai-composer-backdrop-in 0.24s ease;
  }

  .nkbk-ai-composer-menu-portal .nkbk-ai-composer-menu-host:not(.hidden) {
    position: relative;
    z-index: 1;
    left: auto;
    right: auto;
    top: auto;
    bottom: auto;
    transform: none;
    width: min(360px, calc(100vw - 32px));
    max-width: calc(100vw - 32px);
    max-height: min(560px, calc(100dvh - 32px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px)));
    min-height: 0;
    flex-shrink: 1;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    pointer-events: auto;
    overflow: hidden;
    background: #fff;
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 16px;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.28);
    animation: nkbk-ai-composer-modal-in 0.28s cubic-bezier(0.32, 0.72, 0, 1);
  }

  body.theme-dark .nkbk-ai-composer-menu-portal .nkbk-ai-composer-menu-host:not(.hidden) {
    background: #2f2f2f;
    border-color: rgba(255, 255, 255, 0.1);
  }

  .nkbk-ai-composer-menu-portal .nkbk-ai-composer-menu-host:has(.nkbk-ai-composer-flyout:not(.hidden)) .nkbk-ai-composer-menu {
    display: none;
  }

  .nkbk-ai-composer-menu {
    width: 100%;
    min-width: 0;
    flex-shrink: 0;
    border: none;
    box-shadow: none;
    background: transparent;
    padding: 6px;
  }

  .nkbk-ai-composer-flyout:not(.hidden) {
    width: 100%;
    max-width: 100%;
    flex: 1;
    min-height: 0;
    max-height: none;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    border: none;
    box-shadow: none;
    background: transparent;
    border-radius: 0;
    padding: 8px 10px 10px;
  }

  .nkbk-ai-composer-submenu-head {
    flex-shrink: 0;
    padding: 2px 2px 8px;
  }

  .nkbk-ai-composer-submenu-list {
    flex: 1;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    max-height: none;
    -webkit-overflow-scrolling: touch;
  }

  .nkbk-ai-composer-recent-foot {
    flex-shrink: 0;
    padding: 8px 2px 2px;
    margin-top: 0;
  }

  .nkbk-ai-composer-recent-grid {
    overflow: hidden;
  }

  .nkbk-ai-composer-recent-cell {
    min-width: 0;
    overflow: hidden;
  }

  .nkbk-ai-composer-recent-name {
    display: none;
  }
}

@keyframes nkbk-ai-composer-modal-in {
  from {
    transform: scale(0.96);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

@keyframes nkbk-ai-composer-backdrop-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

body.theme-dark .nkbk-ai-composer-flyout {
  background: #2f2f2f;
  border-color: rgba(255, 255, 255, 0.1);
}

.nkbk-ai-composer-flyout.hidden {
  display: none !important;
}

.nkbk-ai-composer-submenu-head {
  padding: 4px 4px 8px;
}

.nkbk-ai-composer-library-open {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 11px 14px;
  border: 1.5px dashed rgba(0, 0, 0, 0.14);
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.02);
  color: inherit;
  font: inherit;
  font-size: 0.8125rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, box-shadow 0.15s;
}

.nkbk-ai-composer-library-open:hover {
  background: rgba(0, 0, 0, 0.04);
  border-color: rgba(0, 0, 0, 0.22);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

body.theme-dark .nkbk-ai-composer-library-open {
  border-color: rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.03);
}

body.theme-dark .nkbk-ai-composer-library-open:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.24);
}

.nkbk-ai-composer-library-open svg {
  width: 18px;
  height: 18px;
  color: #6e6e80;
  flex-shrink: 0;
}

.nkbk-ai-composer-recent-label {
  padding: 2px 6px 8px;
  font-size: 0.75rem;
  color: var(--muted);
}

.nkbk-ai-composer-recent-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  padding: 0 2px 2px;
  min-width: 0;
  overflow: hidden;
}

.nkbk-ai-composer-recent-cell {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 6px;
  border: 1.5px solid rgba(0, 0, 0, 0.08);
  border-radius: 12px;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
  min-width: 0;
  overflow: hidden;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
}

.nkbk-ai-composer-recent-cell.is-selected {
  border-color: #00a884;
  box-shadow: 0 0 0 1px rgba(0, 168, 132, 0.35);
  background: rgba(0, 168, 132, 0.06);
}

.nkbk-ai-composer-recent-check {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 2;
  width: 22px;
  height: 22px;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.92);
  border: 1.5px solid rgba(0, 0, 0, 0.12);
  color: transparent;
  pointer-events: none;
}

.nkbk-ai-composer-recent-cell.is-selected .nkbk-ai-composer-recent-check {
  background: #00a884;
  border-color: #00a884;
  color: #fff;
}

.nkbk-ai-composer-recent-check svg {
  width: 14px;
  height: 14px;
}

.nkbk-ai-composer-recent-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 4px 2px;
  margin-top: 4px;
  border-top: 1px solid rgba(0, 0, 0, 0.08);
}

.nkbk-ai-composer-recent-foot.hidden {
  display: none !important;
}

body.theme-dark .nkbk-ai-composer-recent-foot {
  border-top-color: rgba(255, 255, 255, 0.1);
}

.nkbk-ai-composer-recent-count {
  font-size: 0.75rem;
  color: var(--muted);
  font-weight: 500;
  flex: 1;
  min-width: 0;
}

.nkbk-ai-composer-recent-foot-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

@media (max-width: 768px) {
  .nkbk-ai-composer-recent-foot {
    flex-direction: column;
    align-items: stretch;
  }
  .nkbk-ai-composer-recent-foot-actions {
    width: 100%;
  }
  .nkbk-ai-composer-recent-foot-actions button {
    flex: 1;
  }
}

.nkbk-ai-composer-recent-cell:hover {
  border-color: rgba(0, 0, 0, 0.16);
  background: rgba(0, 0, 0, 0.03);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

body.theme-dark .nkbk-ai-composer-recent-cell {
  border-color: rgba(255, 255, 255, 0.1);
}

body.theme-dark .nkbk-ai-composer-recent-cell:hover {
  border-color: rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.05);
}

.nkbk-ai-composer-recent-thumb {
  aspect-ratio: 1;
  width: 100%;
  border-radius: 8px;
  overflow: hidden;
  background: rgba(0, 0, 0, 0.04);
  border: 1px solid rgba(0, 0, 0, 0.06);
}

body.theme-dark .nkbk-ai-composer-recent-thumb {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.08);
}

.nkbk-ai-composer-recent-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.nkbk-ai-composer-recent-name {
  font-size: 0.72rem;
  font-weight: 500;
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
  padding: 0 2px;
}

.nkbk-ai-composer-flyout-title {
  display: block;
  padding: 2px 4px;
}

.nkbk-ai-composer-submenu-label {
  padding: 4px 10px 6px;
  font-size: 0.75rem;
  color: var(--muted);
}

.nkbk-ai-composer-submenu-list {
  flex: 1;
  min-height: 0;
  max-height: none;
  overflow-y: auto;
}

.nkbk-ai-composer-submenu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.nkbk-ai-composer-submenu-item:hover {
  background: rgba(0, 0, 0, 0.05);
}

body.theme-dark .nkbk-ai-composer-submenu-item:hover {
  background: rgba(255, 255, 255, 0.08);
}

.nkbk-ai-composer-submenu-thumb {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  overflow: hidden;
  flex-shrink: 0;
  background: #f3f4f6;
}

.nkbk-ai-composer-submenu-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.nkbk-ai-composer-submenu-meta {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nkbk-ai-composer-submenu-name {
  font-size: 0.8125rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.nkbk-ai-composer-submenu-date {
  font-size: 0.75rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nkbk-ai-composer-submenu-item--prompt .nkbk-ai-composer-submenu-date {
  white-space: normal;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.nkbk-ai-composer-submenu-empty {
  padding: 12px 10px;
  font-size: 0.8125rem;
  color: var(--muted);
  line-height: 1.45;
}

/* Simple image viewer */
.nkbk-ai-viewer.is-simple-view {
  background: rgba(0, 0, 0, 0.88);
}

.nkbk-ai-viewer.is-simple-view .nkbk-ai-viewer-shell {
  background: transparent;
}

.nkbk-ai-viewer.is-simple-view .nkbk-ai-viewer-top {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 3;
  background: transparent;
  border: none;
  pointer-events: none;
  min-height: 0;
  padding: 12px 16px;
}

.nkbk-ai-viewer.is-simple-view .nkbk-ai-viewer-top-left {
  position: absolute;
  top: 12px;
  right: 12px;
  left: auto;
  pointer-events: auto;
  gap: 0;
}

.nkbk-ai-viewer.is-simple-view .nkbk-ai-viewer-title,
.nkbk-ai-viewer.is-simple-view .nkbk-ai-viewer-top-actions,
.nkbk-ai-viewer.is-simple-view .nkbk-ai-viewer-thumbs,
.nkbk-ai-viewer.is-simple-view .nkbk-ai-viewer-composer,
.nkbk-ai-viewer.is-simple-view .nkbk-ai-viewer-rail {
  display: none !important;
}

.nkbk-ai-viewer.is-simple-view .nkbk-ai-viewer-close-btn {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  border-radius: 50%;
  width: 40px;
  height: 40px;
}

.nkbk-ai-viewer.is-simple-view .nkbk-ai-viewer-close-btn:hover {
  background: rgba(255, 255, 255, 0.2);
}

.nkbk-ai-viewer.is-simple-view .nkbk-ai-viewer-main {
  min-height: 100vh;
}

.nkbk-ai-viewer.is-simple-view .nkbk-ai-viewer-stage-wrap img {
  box-shadow: none;
  border-radius: 0;
}
