/* ============================================================
   DESIGN TOKENS
   ============================================================ */

:root {
  /* Typography */
  --font-sans: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --text-xs:   .75rem;
  --text-sm:   .875rem;
  --text-base: 1rem;
  --text-lg:   1.125rem;
  --lh-tight:  1.35;
  --lh-base:   1.6;

  /* Brand */
  --brand:        #4f46e5;
  --brand-hover:  #4338ca;
  --brand-active: #3730a3;
  --brand-light:  #eef2ff;
  --brand-subtle: rgba(79, 70, 229, .08);
  --brand-glow:   rgba(79, 70, 229, .28);
  --gradient-brand: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);

  /* Surfaces */
  --surface:        #f8fafc;
  --surface-raised: #ffffff;
  --surface-soft:   #f1f5f9;

  /* Borders */
  --border: #e2e8f0;

  /* Text */
  --ink:    #0f172a;
  --ink-2:  #334155;
  --muted:  #64748b;
  --muted-2: #94a3b8;

  /* Feedback */
  --success:       #10b981;
  --success-light: #ecfdf5;
  --warning:       #f59e0b;
  --warning-light: #fefce8;
  --danger:        #ef4444;
  --danger-light:  #fef2f2;
  --info:          #3b82f6;
  --info-light:    #eff6ff;

  /* Shadows */
  --shadow-xs:    0 1px 2px rgba(15, 23, 42, .04);
  --shadow-sm:    0 1px 3px rgba(15, 23, 42, .06), 0 1px 2px rgba(15, 23, 42, .04);
  --shadow-md:    0 4px 8px rgba(15, 23, 42, .07), 0 2px 4px rgba(15, 23, 42, .04);
  --shadow-lg:    0 8px 24px rgba(15, 23, 42, .09), 0 2px 6px rgba(15, 23, 42, .05);
  --shadow-xl:    0 20px 40px rgba(15, 23, 42, .10), 0 8px 16px rgba(15, 23, 42, .06);
  --shadow-brand: 0 4px 16px rgba(79, 70, 229, .28);

  /* Radii */
  --r-sm:   6px;
  --r-md:   10px;
  --r-lg:   14px;
  --r-xl:   18px;
  --r-2xl:  24px;
  --r-full: 9999px;

  /* Transitions */
  --t-fast:   120ms ease;
  --t-base:   200ms ease;
  --t-slow:   300ms ease;
  --t-spring: 280ms cubic-bezier(.34, 1.56, .64, 1);

  --spinner-overlay: rgba(255, 255, 255, .65);
  color-scheme: light;
}

html[data-bs-theme="dark"] {
  --brand:        #818cf8;
  --brand-hover:  #6366f1;
  --brand-active: #4f46e5;
  --brand-light:  rgba(99, 102, 241, .15);
  --brand-subtle: rgba(99, 102, 241, .10);
  --brand-glow:   rgba(129, 140, 248, .28);
  --gradient-brand: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);

  --surface:        #060d1a;
  --surface-raised: #0f172a;
  --surface-soft:   #1a2740;

  --border: #1e2d45;

  --ink:    #f1f5f9;
  --ink-2:  #cbd5e1;
  --muted:  #94a3b8;
  --muted-2: #64748b;

  --shadow-xs:    0 1px 2px rgba(0, 0, 0, .25);
  --shadow-sm:    0 1px 3px rgba(0, 0, 0, .30);
  --shadow-md:    0 4px 8px rgba(0, 0, 0, .35);
  --shadow-lg:    0 8px 24px rgba(0, 0, 0, .40);
  --shadow-xl:    0 20px 40px rgba(0, 0, 0, .45);
  --shadow-brand: 0 4px 16px rgba(129, 140, 248, .28);

  --spinner-overlay: rgba(6, 13, 26, .75);
  color-scheme: dark;
}

/* ============================================================
   ANIMATIONS
   ============================================================ */

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes scaleIn {
  from { opacity: 0; transform: scale(.97); }
  to   { opacity: 1; transform: scale(1); }
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

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

/* ============================================================
   RESET + BASE
   ============================================================ */

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

html { -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }

body {
  margin: 0;
  background: var(--surface);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: var(--lh-base);
}

/* ============================================================
   APP SHELL
   ============================================================ */

body:has(#app-container) { overflow: hidden; }

#app-container { display: flex; height: 100vh; }

/* ---- Sidebar ---- */
#sidebar {
  width: 240px;
  flex: 0 0 240px;
  display: flex;
  flex-direction: column;
  background: var(--surface-raised);
  border-right: 1px solid var(--border);
  z-index: 1040;
  transition: transform var(--t-slow), margin-left var(--t-slow);
}

@media (min-width: 992px) {
  #app-container.sidebar-collapsed #sidebar {
    transform: translateX(-100%);
    margin-left: -240px;
  }
}

/* ---- Main wrapper ---- */
#main-wrapper {
  min-width: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
}

#main-wrapper > header {
  height: 52px;
  padding: 0 1.75rem 0 1rem;
  background: var(--surface-raised);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: .75rem;
  box-shadow: var(--shadow-xs);
  flex-shrink: 0;
}

.header-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: none;
  border-radius: var(--r-md);
  background: transparent;
  color: var(--muted);
  font-size: 1.05rem;
  cursor: pointer;
  flex-shrink: 0;
  transition: background var(--t-base), color var(--t-base);
}
.header-icon-btn:hover {
  background: var(--surface-soft);
  color: var(--ink);
}
#app-container.sidebar-collapsed #desktopSidebarToggle {
  color: var(--brand);
  background: var(--brand-light);
}

#main-content {
  overflow-y: auto;
  flex: 1;
  padding: 1rem;
  background:
    radial-gradient(ellipse 70% 40% at 90% 0%, rgba(79, 70, 229, .05) 0%, transparent 60%),
    var(--surface);
  min-height: 0;
}

.content-width { padding-left: 0; padding-right: 0; }
.form-width    { max-width: 900px; }

.skill-picker {
  padding: 0;
  border: 0;
  background: transparent;
}
.skill-picker-list { display: flex; flex-direction: column; gap: .45rem; }
.skill-picker-empty { color: var(--muted); font-size: .78rem; }
.skill-picker-item {
  display: flex;
  align-items: center;
  gap: .65rem;
  padding: .55rem .65rem;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface-raised);
}
.skill-picker-item.is-dragging { opacity: .55; }
.skill-picker-grip { color: var(--muted); cursor: grab; }
.skill-picker-copy { min-width: 0; flex: 1; }
.skill-picker-copy strong,
.skill-picker-copy small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.skill-picker-copy small { color: var(--muted); font-size: .7rem; }
.skill-picker-item > .form-select { width: 105px; flex: 0 0 105px; }
.skill-picker-item > .form-control { width: 130px; flex: 0 0 130px; }
.skill-picker-actions { display: flex; gap: .2rem; }
.skill-picker-actions button { padding: .15rem .35rem; }
@media (max-width: 767.98px) {
  .skill-picker-item { flex-wrap: wrap; }
  .skill-picker-copy { flex-basis: calc(100% - 35px); }
  .skill-picker-item > .form-select,
  .skill-picker-item > .form-control { width: auto; flex: 1 1 120px; }
}

#skillFormModal .modal-content {
  max-height: calc(100dvh - 3.5rem);
}
#skillFormModal #skillForm {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}
#skillFormModal #skillForm .modal-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
}
#skillFormModal #skillForm .modal-footer {
  flex: 0 0 auto;
  background: var(--surface-raised);
}

.runner-output-tabs {
  display: inline-flex;
  align-self: flex-start;
  padding: .2rem;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface-soft);
}
.runner-output-tabs button {
  padding: .35rem .75rem;
  border: 0;
  border-radius: calc(var(--r-md) - 2px);
  background: transparent;
  color: var(--muted);
  font-size: .75rem;
  font-weight: 700;
}
.runner-output-tabs button.active {
  background: var(--surface-raised);
  color: var(--brand);
  box-shadow: var(--shadow-xs);
}

/* ---- Brand / logo ---- */
.brand {
  height: 52px;
  padding: 0 1.5rem;
  display: flex;
  align-items: center;
  gap: .75rem;
  text-decoration: none;
  border-bottom: 1px solid var(--border);
  transition: opacity var(--t-base);
}
.brand:hover { opacity: .82; }
.brand-text { font-size: 1.25rem; font-weight: 800; color: var(--text-primary); }

/* ---- Sidebar workspace row ---- */
.sidebar-workspace {
  min-height: 36px;
  color: var(--muted);
}
#sidebar #libraryNav.mb-3 { margin-bottom: .5rem !important; }
#sidebar .border-top.pt-3 { padding-top: .5rem !important; }
#sidebar .d-flex.mb-2.px-2 { margin-bottom: .25rem !important; }
#sidebar > div.border-top.px-3.py-2 { padding-top: .3rem !important; padding-bottom: .3rem !important; }

.sidebar-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: var(--r-sm);
  color: var(--muted);
  text-decoration: none;
  font-size: .85rem;
  transition: background var(--t-base), color var(--t-base);
}
.sidebar-icon-btn:hover {
  background: var(--brand-light);
  color: var(--brand);
}

.brand-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--r-md);
  background: var(--gradient-brand);
  color: #fff;
  font-size: .95rem;
  box-shadow: var(--shadow-brand);
  flex-shrink: 0;
}

/* ---- Sidebar labels & nav ---- */
.sidebar-label {
  color: var(--muted);
  text-transform: uppercase;
  font-size: .65rem;
  font-weight: 700;
  letter-spacing: 1.2px;
}

.sidebar-svg { width: 18px; height: 18px; }

/* Library menu visibility panel */
.library-menu-panel {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  z-index: 200;
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-xl);
  padding: 6px;
  min-width: 160px;
  animation: fadeInUp 120ms both;
}
.library-menu-panel[hidden] { display: none; }

.library-type-tabs {
  max-width: 100%;
  display: inline-flex;
  align-items: center;
  gap: .25rem;
  padding: .25rem;
  margin-bottom: 1.25rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-soft);
  overflow-x: auto;
  scrollbar-width: none;
}
.library-type-tabs::-webkit-scrollbar { display: none; }
.library-type-tab {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .48rem .8rem;
  border-radius: 9px;
  color: var(--muted);
  font-size: .82rem;
  font-weight: 650;
  text-decoration: none;
}
.library-type-tab:hover {
  color: var(--brand);
  background: var(--surface-raised);
}
.library-type-tab.active {
  color: var(--brand);
  background: var(--surface-raised);
  box-shadow: var(--shadow-sm);
}

/* Workspace skills */
.skills-page { padding-bottom: 3rem; }
.skills-hero {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: .75rem;
}
.skills-title {
  margin: 0;
  color: var(--ink);
  font-size: clamp(1.55rem, 3vw, 2rem);
  font-weight: 800;
  letter-spacing: -.035em;
}
.skills-title i { color: var(--brand); }
.skills-subtitle {
  max-width: 720px;
  margin: .3rem 0 0;
  color: var(--muted);
  font-size: .9rem;
}
.skills-toolbar {
  display: flex;
  align-items: center;
  gap: .65rem;
  margin-bottom: 1rem;
}
.skills-count-badge {
  color: var(--muted);
  background: var(--surface-soft);
  border: 1px solid var(--border);
  font-size: .72rem;
  font-weight: 600;
}
.skills-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
}
.skill-card {
  display: flex;
  flex-direction: column;
  min-height: 250px;
  padding: 1rem;
  border-radius: var(--r-xl);
  cursor: pointer;
}
.skill-card:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.skill-card-icon {
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border-radius: 12px;
  color: var(--brand);
  background: var(--brand-light);
  font-size: 1.1rem;
}
.skill-card h3 { margin: .8rem 0 .2rem; color: var(--ink); font-size: 1rem; font-weight: 750; }
.skill-purpose-badge {
  --skill-purpose-color: var(--brand);
  --skill-purpose-bg: var(--brand-light);
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  width: fit-content;
  padding: .28rem .58rem;
  border: 1px solid color-mix(in srgb, var(--skill-purpose-color) 20%, transparent);
  border-radius: var(--r-full);
  color: var(--skill-purpose-color);
  background: var(--skill-purpose-bg);
  font-size: .7rem;
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: .01em;
  white-space: nowrap;
}
.skill-purpose-badge i {
  font-size: .72rem;
  line-height: 1;
}
.skill-purpose-badge--viet-tao {
  --skill-purpose-color: #7c3aed;
  --skill-purpose-bg: color-mix(in srgb, #7c3aed 10%, var(--surface-raised));
}
.skill-purpose-badge--phan-tich {
  --skill-purpose-color: #d97706;
  --skill-purpose-bg: color-mix(in srgb, #d97706 10%, var(--surface-raised));
}
.skill-purpose-badge--lap-ke-hoach {
  --skill-purpose-color: #2563eb;
  --skill-purpose-bg: color-mix(in srgb, #2563eb 10%, var(--surface-raised));
}
.skill-purpose-badge--quan-ly {
  --skill-purpose-color: #db2777;
  --skill-purpose-bg: color-mix(in srgb, #db2777 10%, var(--surface-raised));
}
.skill-purpose-badge--nghien-cuu {
  --skill-purpose-color: #0f766e;
  --skill-purpose-bg: color-mix(in srgb, #0f766e 10%, var(--surface-raised));
}
.skill-purpose-badge--tu-van {
  --skill-purpose-color: #059669;
  --skill-purpose-bg: color-mix(in srgb, #059669 10%, var(--surface-raised));
}
.skill-purpose-filters {
  display: flex;
  gap: .45rem;
  overflow-x: auto;
  margin: 0 0 1rem;
  padding: .1rem 0 .35rem;
  scrollbar-width: thin;
}
.skill-purpose-filter {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  gap: .4rem;
  padding: .4rem .7rem;
  border: 1px solid var(--border);
  border-radius: var(--r-full);
  color: var(--muted);
  background: var(--surface-raised);
  font-size: .75rem;
  font-weight: 650;
  text-decoration: none;
  transition: color var(--t-base), border-color var(--t-base), background var(--t-base);
}
.skill-purpose-filter:hover,
.skill-purpose-filter.active {
  border-color: color-mix(in srgb, var(--brand) 28%, var(--border));
  color: var(--brand);
  background: var(--brand-light);
}
.skill-slug { color: var(--brand); font: 600 .7rem var(--font-mono); }
.skill-description { margin: .65rem 0; color: var(--muted); font-size: .82rem; line-height: 1.55; }
.skill-instructions {
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 4;
  color: var(--ink-2);
  font-size: .78rem;
  white-space: pre-line;
}
.skill-actions { margin-top: auto; padding-top: 1rem; }
.skill-prompt-count-inline { display: none; }
.skills-grid.list-view { grid-template-columns: 1fr; gap: .55rem; }
.skills-grid.list-view .skill-card {
  display: grid;
  grid-template-columns: 44px minmax(260px, .8fr) minmax(320px, 1.2fr) auto;
  min-height: 0;
  align-items: center;
  gap: .8rem;
  padding: .6rem .8rem;
}
.skills-grid.list-view .skill-card-heading { min-width: 0; }
.skills-grid.list-view .skill-card-title-row { display: flex; align-items: center; gap: .5rem; min-width: 0; }
.skills-grid.list-view .skill-card h3 { min-width: 0; margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.skills-grid.list-view .skill-prompt-count-inline { display: inline-flex; flex: 0 0 auto; }
.skills-grid.list-view .skill-slug,
.skills-grid.list-view .skill-action-label { display: none; }
.skills-grid.list-view .skill-card-top { display: block !important; grid-column: 1; grid-row: 1; }
.skills-grid.list-view .skill-prompt-count { display: none; }
.skills-grid.list-view .skill-card-body {
  display: grid;
  grid-template-columns: minmax(260px, .8fr) minmax(320px, 1.2fr);
  align-items: center;
  gap: .8rem;
  grid-column: 2 / 4;
  grid-row: 1;
}
.skills-grid.list-view .skill-description { margin: 0; }
.skills-grid.list-view .skill-instructions { display: none; }
.skills-grid.list-view .skill-actions {
  grid-column: 4;
  grid-row: 1;
  align-self: end;
  justify-content: flex-end;
  margin: 0;
  padding: 0;
}
.skill-empty {
  padding: 4rem 1rem;
  text-align: center;
  color: var(--muted);
  background: var(--surface-raised);
  border: 1px dashed var(--border);
  border-radius: var(--r-xl);
}
.skill-preview {
  max-height: 55vh;
  overflow: auto;
  padding: 1rem;
  white-space: pre-wrap;
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  font-family: var(--font-mono);
  font-size: .78rem;
}
@media (max-width: 991px) {
  .skills-grid:not(.list-view) { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .skills-grid.list-view .skill-card { grid-template-columns: 44px minmax(0, 1fr) auto; }
  .skills-grid.list-view .skill-card-body { display: block; grid-column: 2; }
  .skills-grid.list-view .skill-description { display: none; }
  .skills-grid.list-view .skill-actions { grid-column: 3; }
}
@media (max-width: 640px) {
  .skills-grid { grid-template-columns: 1fr; }
  .skills-hero { gap: .75rem; }
}
.lmp-header {
  font-size: .65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--muted);
  padding: 2px 8px 6px;
}
.lmp-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 8px;
  border-radius: var(--r-md);
  font-size: var(--text-sm);
  cursor: pointer;
  color: var(--ink);
  user-select: none;
}
.lmp-item:hover { background: var(--surface-soft); }
.lmp-item input[type="checkbox"] { cursor: pointer; accent-color: var(--brand); }
[data-menu-key].menu-hidden { display: none !important; }

.category-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 6px 12px;
  margin-bottom: 1px;
  border-radius: var(--r-md);
  color: var(--muted);
  font-size: var(--text-sm);
  font-weight: 500;
  text-decoration: none;
  transition: color var(--t-base), background var(--t-base);
}
.category-btn:hover {
  color: var(--brand);
  background: var(--brand-light);
}
.category-btn.active {
  color: var(--brand);
  background: var(--brand-light);
  font-weight: 600;
}
.sidebar-badge {
  margin-left: auto;
  padding: 1px 7px;
  border-radius: var(--r-full);
  font-size: .7rem;
  font-weight: 600;
  line-height: 1.6;
  letter-spacing: .01em;
  background: var(--surface-soft);
  color: var(--muted-2);
  transition: background var(--t-base), color var(--t-base);
  flex-shrink: 0;
}
.category-btn:hover .sidebar-badge,
.category-btn.active .sidebar-badge {
  background: var(--brand-light);
  color: var(--brand);
}

/* ---- Role badges ---- */
.role-badge {
  display: inline-flex;
  align-items: center;
  gap: .3em;
  padding: .22em .65em;
  border-radius: var(--r-full);
  font-size: .7rem;
  font-weight: 600;
  line-height: 1.5;
  letter-spacing: .03em;
  white-space: nowrap;
}
.role-badge--owner {
  background: var(--brand-light);
  color: var(--brand);
  border: 1px solid color-mix(in srgb, var(--brand) 20%, transparent);
}
.role-badge--member {
  background: var(--surface-soft);
  color: var(--ink-2);
  border: 1px solid var(--border);
}
.role-badge--viewer {
  background: #f0fdf4;
  color: #15803d;
  border: 1px solid #bbf7d0;
}
[data-bs-theme="dark"] .role-badge--viewer {
  background: #052e16;
  color: #4ade80;
  border: 1px solid #166534;
}
.role-badge--pending {
  background: #fffbeb;
  color: #92400e;
  border: 1px solid #fde68a;
}
[data-bs-theme="dark"] .role-badge--pending {
  background: #1c1200;
  color: #fbbf24;
  border: 1px solid #78350f;
}

/* ---- Avatar ---- */
.avatar {
  width: 28px;
  height: 28px;
  flex: 0 0 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: .68rem;
  font-weight: 700;
  border-radius: var(--r-full);
  background: var(--gradient-brand);
  box-shadow: 0 2px 8px var(--brand-glow);
  letter-spacing: .5px;
}

.avatar-lg {
  width: 56px;
  height: 56px;
  flex: 0 0 56px;
  font-size: 1.1rem;
}

/* ---- Account card ---- */
.account-card {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 8px;
  border-radius: var(--r-md);
  text-decoration: none;
  color: inherit;
  transition: background 150ms ease, color 150ms ease;
}
.account-card:hover { background: var(--surface-soft); color: inherit; }
.account-card:hover .account-card-chevron { opacity: 1; transform: translateX(2px); }
.account-card.active,
.account-card.is-pressing {
  background: var(--brand-light);
  color: var(--brand);
}
.account-card.active .account-card-chevron,
.account-card.is-pressing .account-card-chevron { opacity: 1; }
.account-card-chevron {
  font-size: .7rem;
  opacity: .35;
  flex-shrink: 0;
  transition: opacity var(--t-base), transform var(--t-base);
}

/* ---- Sidebar overlay ---- */
.sidebar-overlay { display: none; }

/* ============================================================
   SEARCH + HEADER CONTROLS
   ============================================================ */

.search-input-wrapper {
  position: relative;
  width: 100%;
  max-width: 520px;
}
.search-input-wrapper > i {
  position: absolute;
  top: 50%;
  left: 14px;
  transform: translateY(-50%);
  color: var(--muted-2);
  pointer-events: none;
}
.search-input {
  width: 100%;
  height: 34px;
  padding: 0 14px 0 38px;
  border: 1.5px solid var(--border);
  border-radius: var(--r-full);
  outline: none;
  color: var(--ink);
  background: var(--surface-soft);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  transition: border-color var(--t-base), box-shadow var(--t-base), background var(--t-base);
}
.search-input-has-clear { padding-right: 40px; }
.search-input-has-clear::-webkit-search-cancel-button { display: none; }
.search-input-has-clear::-ms-clear { display: none; }
.search-clear-btn {
  position: absolute;
  top: 50%;
  right: 10px;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  padding: 0;
  transform: translateY(-50%);
  color: var(--muted);
  background: transparent;
  border: 0;
  border-radius: 50%;
  cursor: pointer;
}
.search-clear-btn:hover,
.search-clear-btn:focus-visible {
  color: var(--ink);
  background: var(--surface-soft);
  outline: none;
}
.search-clear-btn[hidden] { display: none; }
.search-input::placeholder { color: var(--muted-2); }
.search-input:hover  { border-color: var(--muted-2); }
.search-input:focus  {
  border-color: var(--brand);
  box-shadow: 0 0 0 3.5px var(--brand-light);
  background: var(--surface-raised);
  outline: none;
}

/* Search autocomplete dropdown */
.search-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-xl);
  z-index: 1080;
  overflow: hidden;
}
.search-dropdown[hidden] { display: none; }
.search-drop-item {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 12px;
  padding: 9px 14px;
  cursor: pointer;
  text-decoration: none;
  color: var(--ink);
  border-bottom: 1px solid var(--border);
  transition: background var(--t-fast);
}
button.search-drop-item {
  background: none;
  border: none;
  border-bottom: 1px solid var(--border);
  text-align: left;
  width: 100%;
}
.search-drop-item:last-child { border-bottom: none; }
.search-drop-item:hover,
.search-drop-item.active { background: var(--brand-light); color: var(--brand); }
.drop-icon-box {
  width: 32px;
  height: 32px;
  border-radius: var(--r-md);
  background: var(--surface-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: .9rem;
  transition: background var(--t-fast);
}
.search-drop-item:hover .drop-icon-box,
.search-drop-item.active .drop-icon-box { background: rgba(99,102,241,.15); }
.drop-body { display: flex; flex-direction: column; min-width: 0; }
.drop-title { font-size: var(--text-sm); font-weight: 600; }
.drop-desc  { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.search-drop-item:hover .drop-desc,
.search-drop-item.active .drop-desc { color: var(--brand); }
.search-drop-empty {
  padding: 12px 16px;
  font-size: var(--text-sm);
  color: var(--muted);
  text-align: center;
}

/* ============================================================
   BUTTONS
   ============================================================ */

/* Primary brand button */
.btn-brand {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 34px;
  padding: 0 18px;
  border: 0;
  border-radius: var(--r-md);
  background: var(--gradient-brand);
  color: #fff;
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  font-weight: 600;
  letter-spacing: .1px;
  cursor: pointer;
  text-decoration: none;
  box-shadow: var(--shadow-brand);
  transition: filter var(--t-base), box-shadow var(--t-base), transform var(--t-fast);
}
.btn-brand:hover {
  color: #fff;
  filter: brightness(1.1) saturate(1.1);
  box-shadow: 0 6px 20px var(--brand-glow);
  transform: translateY(-1px);
}
.btn-brand:active {
  filter: brightness(.94);
  transform: translateY(0);
  box-shadow: var(--shadow-brand);
}

/* Action icon buttons */
.action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  width: 32px;
  height: 32px;
  border-radius: var(--r-md);
  color: var(--muted);
  background: transparent;
  text-decoration: none;
  font-size: var(--text-sm);
  transition: color var(--t-base), background var(--t-base), transform var(--t-fast);
  cursor: pointer;
  padding: 0;
}
.action-btn:hover {
  color: var(--brand);
  background: var(--brand-light);
  transform: translateY(-1px);
}
.action-btn.delete:hover {
  color: var(--danger);
  background: var(--danger-light);
}

/* Theme toggle */
.theme-toggle {
  width: 38px;
  height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border-radius: var(--r-md);
  border: 1.5px solid var(--border) !important;
  transition: background var(--t-base), border-color var(--t-base), transform var(--t-spring);
  flex-shrink: 0;
}
.theme-toggle:hover { border-color: var(--brand) !important; }
.theme-toggle:hover { transform: rotate(12deg) scale(1.08); }

.auth-theme-toggle { position: absolute; top: 1.25rem; right: 1.25rem; }

/* Color theme picker */
.color-theme-picker {
  position: relative;
}
.color-theme-dot {
  width: 14px;
  height: 14px;
  border-radius: var(--r-full);
  background: var(--brand);
  display: inline-block;
  transition: background var(--t-base);
  pointer-events: none;
  flex-shrink: 0;
}
/* Combined theme button (dot + mode icon) */
.color-theme-btn {
  height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 0 10px;
  border-radius: var(--r-md);
  border: 1.5px solid var(--border) !important;
  transition: background var(--t-base), border-color var(--t-base), transform var(--t-spring);
  flex-shrink: 0;
}
.color-theme-btn:hover { border-color: var(--brand) !important; transform: scale(1.05); }
.color-theme-btn .theme-icon { font-size: .92rem; pointer-events: none; }
.color-theme-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 1080;
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-xl);
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 0;
  width: max-content;
  min-width: 170px;
  animation: fadeInUp 120ms both;
}
.color-theme-dropdown[hidden] { display: none; }
/* Mode toggle row inside dropdown */
.ctd-mode {
  display: flex;
  gap: 4px;
  margin-bottom: 8px;
}
.ctd-mode-btn {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 5px 6px;
  border-radius: var(--r-md);
  border: 1.5px solid transparent;
  background: transparent;
  color: var(--muted);
  font-size: .8rem;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--t-base), color var(--t-base), border-color var(--t-base);
  white-space: nowrap;
}
.ctd-mode-btn:hover { background: var(--surface-soft); color: var(--ink); }
.ctd-mode-btn.active { background: var(--brand-subtle); color: var(--brand); border-color: var(--brand); }
.ctd-divider { height: 1px; background: var(--border); margin: 0 0 8px; }
.ctd-install { padding-top: 4px; }
.ctd-install-btn {
  display: flex; align-items: center; gap: 6px;
  width: 100%; padding: 6px 10px;
  border: 1px solid var(--border); border-radius: var(--r-md);
  background: var(--surface); color: var(--ink);
  font-size: .82rem; font-weight: 500; cursor: pointer;
  transition: background .15s, color .15s;
}
.ctd-install-btn:hover { background: var(--brand-subtle); color: var(--brand); border-color: var(--brand); }
/* Color swatches row */
.ctd-colors { display: flex; gap: 6px; flex-wrap: nowrap; }
.color-theme-swatch {
  width: 28px;
  height: 28px;
  border-radius: var(--r-full);
  border: 2.5px solid transparent;
  cursor: pointer;
  transition: transform var(--t-spring), border-color var(--t-base), box-shadow var(--t-base);
  flex-shrink: 0;
  outline: none;
  padding: 0;
}
.color-theme-swatch:hover { transform: scale(1.18); box-shadow: 0 2px 8px rgba(0,0,0,.25); }
.color-theme-swatch.active { border-color: var(--ink); transform: scale(1.08); }

/* Bootstrap btn-primary override */
.btn-primary {
  background: var(--gradient-brand) !important;
  border-color: transparent !important;
  box-shadow: var(--shadow-brand);
  transition: filter var(--t-base), box-shadow var(--t-base), transform var(--t-fast) !important;
}
.btn-primary:hover {
  filter: brightness(1.1);
  transform: translateY(-1px);
  box-shadow: 0 6px 20px var(--brand-glow) !important;
  border-color: transparent !important;
}
.btn-primary:active {
  transform: translateY(0) !important;
  filter: brightness(.94) !important;
}

/* Ghost secondary button — brand hover, used for secondary actions */
.btn-ghost {
  color: var(--ink-2) !important;
  background: transparent !important;
  border: 1.5px solid var(--border) !important;
  font-weight: 500;
  box-shadow: none !important;
  transition: color var(--t-base), background var(--t-base), border-color var(--t-base), transform var(--t-fast) !important;
}
.btn-ghost:hover {
  color: var(--brand) !important;
  background: var(--brand-light) !important;
  border-color: var(--brand) !important;
  transform: translateY(-1px);
}
.btn-ghost:active { transform: translateY(0) !important; }
.btn-ghost.danger:hover {
  color: var(--danger) !important;
  background: var(--danger-light) !important;
  border-color: var(--danger) !important;
}

/* Ghost danger button — for destructive secondary actions */
.btn-ghost-danger {
  color: var(--danger) !important;
  background: transparent !important;
  border: 1.5px solid rgba(239, 68, 68, .3) !important;
  font-weight: 500;
  box-shadow: none !important;
  transition: color var(--t-base), background var(--t-base), border-color var(--t-base), transform var(--t-fast) !important;
}
.btn-ghost-danger:hover {
  color: #fff !important;
  background: var(--danger) !important;
  border-color: var(--danger) !important;
  transform: translateY(-1px);
}
.btn-ghost-danger:active { transform: translateY(0) !important; }

/* Ghost warning button — for role elevation actions */
.btn-ghost-warning {
  color: #92400e !important;
  background: transparent !important;
  border: 1.5px solid rgba(245, 158, 11, .35) !important;
  font-weight: 500;
  box-shadow: none !important;
  transition: color var(--t-base), background var(--t-base), border-color var(--t-base), transform var(--t-fast) !important;
}
.btn-ghost-warning:hover {
  color: #78350f !important;
  background: #fef3c7 !important;
  border-color: var(--warning) !important;
  transform: translateY(-1px);
}
.btn-ghost-warning:active { transform: translateY(0) !important; }

html[data-bs-theme="dark"] .btn-ghost-warning { color: var(--warning) !important; }
html[data-bs-theme="dark"] .btn-ghost-warning:hover {
  color: #fde68a !important;
  background: rgba(245, 158, 11, .15) !important;
}

/* Gallery / filter pill tabs */
.gallery-filter-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 16px;
  border-radius: var(--r-full);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--ink-2);
  background: var(--surface-raised);
  border: 1.5px solid var(--border);
  text-decoration: none;
  box-shadow: var(--shadow-xs);
  white-space: nowrap;
  cursor: pointer;
  transition: color var(--t-base), background var(--t-base), border-color var(--t-base), box-shadow var(--t-base), transform var(--t-fast);
}
.gallery-filter-pill:hover:not(.active) {
  color: var(--brand);
  border-color: var(--brand);
  background: var(--brand-light);
  transform: translateY(-1px);
}
.gallery-filter-pill.active {
  color: #fff;
  background: var(--gradient-brand);
  border-color: transparent;
  box-shadow: var(--shadow-brand);
}

html[data-bs-theme="dark"] .gallery-filter-pill {
  background: var(--surface-soft);
  border-color: var(--border);
  color: var(--ink-2);
}
html[data-bs-theme="dark"] .gallery-filter-pill:hover:not(.active) {
  background: var(--brand-light);
  border-color: var(--brand);
  color: var(--brand);
}
html[data-bs-theme="dark"] .btn-ghost {
  color: var(--ink-2) !important;
  background: transparent !important;
  border-color: var(--border) !important;
}
html[data-bs-theme="dark"] .btn-ghost:hover {
  color: var(--brand) !important;
  background: var(--brand-light) !important;
  border-color: var(--brand) !important;
}

/* ============================================================
   FORM CONTROLS
   ============================================================ */

.custom-input {
  width: 100%;
  padding: 9px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--r-md);
  outline: none;
  color: var(--ink);
  background: var(--surface-raised);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  line-height: var(--lh-base);
  transition: border-color var(--t-base), box-shadow var(--t-base);
  resize: vertical;
}
.custom-input:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3.5px var(--brand-light);
}

.form-control, .form-select {
  border-radius: var(--r-md) !important;
  border-color: var(--border) !important;
  font-family: var(--font-sans);
  font-size: var(--text-sm) !important;
  color: var(--ink);
  background-color: var(--surface-raised) !important;
  transition: border-color var(--t-base), box-shadow var(--t-base) !important;
}
.form-control:focus, .form-select:focus {
  border-color: var(--brand) !important;
  box-shadow: 0 0 0 3.5px var(--brand-light) !important;
  background-color: var(--surface-raised) !important;
  color: var(--ink) !important;
}

.form-label {
  font-weight: 600;
  font-size: var(--text-sm);
  color: var(--ink-2);
  margin-bottom: .35rem;
}
.form-text  { font-size: var(--text-xs); color: var(--muted); }

.errorlist {
  margin: .3rem 0 0;
  padding: 0;
  color: var(--danger);
  font-size: var(--text-xs);
  list-style: none;
}

/* ============================================================
   CARDS
   ============================================================ */

/* Shared card interaction across library tabs. */
.app-hover-card {
  position: relative;
  z-index: 0;
  border: 1px solid var(--border) !important;
  background: var(--surface-raised);
  box-shadow: var(--shadow-xs);
  transition:
    transform var(--t-base),
    border-color var(--t-base),
    box-shadow var(--t-base) !important;
}
.app-hover-card:hover,
.app-hover-card:focus-within {
  z-index: 2;
  transform: translateY(-2px) !important;
  border-color: color-mix(in srgb, var(--brand) 38%, var(--border)) !important;
  box-shadow: var(--shadow-md) !important;
}
.app-hover-card:has(.dropdown-menu.show) {
  z-index: 1055;
}

/* Shared action buttons used by Prompt, Gallery, Skill and Preset cards. */
.app-card-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: .4rem;
}
.app-card-actions .btn,
.app-card-actions .action-btn {
  min-height: 32px;
  border-radius: var(--r-sm) !important;
  font-size: .74rem;
  font-weight: 600;
  line-height: 1.2;
  transition:
    color var(--t-base),
    background var(--t-base),
    border-color var(--t-base),
    box-shadow var(--t-base),
    transform var(--t-fast) !important;
}
.app-card-actions .btn:not(.dropdown-toggle-split) {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .3rem;
  padding: .35rem .65rem;
}
.app-card-actions .dropdown-toggle-split {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  align-self: stretch;
  min-width: 34px;
  padding: .35rem .45rem !important;
  line-height: 1;
  z-index: 2;
}
.app-card-actions .btn-group {
  position: relative;
  z-index: 1;
  align-items: stretch;
}
.app-card-actions .btn-group:has(.dropdown-menu.show) {
  z-index: 1060;
}
.app-card-actions .dropdown-menu {
  z-index: 1070;
}
.app-card-actions .action-btn {
  width: 32px;
  height: 32px;
  color: var(--ink-2);
  border: 1.5px solid var(--border);
  background: transparent;
}
.app-card-actions .btn:hover,
.app-card-actions .action-btn:hover {
  transform: translateY(-1px);
}
.app-card-actions .btn:active,
.app-card-actions .action-btn:active {
  transform: translateY(0) !important;
}
.app-card-actions .btn-outline-secondary,
.app-card-actions .btn-ghost {
  color: var(--ink-2) !important;
  border-color: var(--border) !important;
  background: transparent !important;
}
.app-card-actions .btn-outline-secondary:hover,
.app-card-actions .btn-ghost:hover {
  color: var(--brand) !important;
  border-color: var(--brand) !important;
  background: var(--brand-light) !important;
}
.app-card-actions .btn-outline-primary {
  color: var(--brand) !important;
  border-color: var(--brand) !important;
  background: transparent !important;
}
.app-card-actions .btn-outline-primary:hover {
  color: #fff !important;
  border-color: var(--brand) !important;
  background: var(--brand) !important;
}
.app-card-actions .btn-outline-danger:hover {
  color: #fff !important;
  border-color: var(--danger) !important;
  background: var(--danger) !important;
}
.app-card-actions .preset-edit-link {
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .3rem;
  padding: .35rem .65rem;
  border: 1.5px solid var(--border);
  border-radius: var(--r-sm);
  color: var(--ink-2);
  background: transparent;
  font-size: .74rem;
  font-weight: 600;
  transition:
    color var(--t-base),
    background var(--t-base),
    border-color var(--t-base),
    transform var(--t-fast);
}
.app-card-actions .preset-edit-link:hover {
  color: var(--brand);
  border-color: var(--brand);
  background: var(--brand-light);
  transform: translateY(-1px);
}
.app-view-toggle {
  display: grid !important;
  width: 32px !important;
  height: 32px !important;
  min-width: 32px;
  flex: 0 0 32px;
  padding: 0 !important;
  place-items: center;
  border-radius: var(--r-sm) !important;
  color: var(--ink-2) !important;
  border-color: var(--border) !important;
  background: var(--surface-raised) !important;
  box-shadow: none !important;
}
.app-view-toggle:hover {
  color: var(--brand) !important;
  border-color: var(--brand) !important;
  background: var(--brand-light) !important;
  transform: translateY(-1px);
}
.app-view-toggle:active {
  transform: translateY(0) !important;
}

/* Prompt card */
.prompt-card {
  --prompt-icon-box-size: 40px;
  height: 100%;
  display: grid;
  grid-template-columns: var(--prompt-icon-box-size) minmax(0, 1fr);
  grid-template-rows: auto 1fr auto;
  grid-template-areas:
    "icon actions"
    "body body"
    "foot foot";
  column-gap: 8px;
  row-gap: 0;
  padding: 22px;
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  background: var(--surface-raised);
  box-shadow: var(--shadow-sm);
  transition: border-color var(--t-base), box-shadow var(--t-slow), transform var(--t-slow);
  animation: fadeInUp var(--t-slow) both;
}
.prompt-card > .icon-box {
  grid-area: icon;
  align-self: center;
  width: var(--prompt-icon-box-size);
  min-width: var(--prompt-icon-box-size);
  max-width: var(--prompt-icon-box-size);
  height: var(--prompt-icon-box-size);
  min-height: var(--prompt-icon-box-size);
  max-height: var(--prompt-icon-box-size);
  box-sizing: border-box;
  overflow: hidden;
}
.prompt-icon-viewport {
  display: flex;
  width: 16px;
  height: 16px;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex: 0 0 16px;
  line-height: 1;
}
.prompt-icon-viewport > i,
.prompt-icon-viewport > svg {
  display: block;
  width: 16px !important;
  height: 16px !important;
  max-width: 16px;
  max-height: 16px;
  font-size: 16px;
  line-height: 1;
  flex: 0 0 16px;
  text-align: center;
}
.prompt-icon-viewport > i::before {
  display: block;
  width: 16px;
  height: 16px;
  line-height: 1;
}
.prompt-card > .card-body-link { grid-area: body; padding-top: 12px; }
.prompt-card > .card-actions {
  grid-area: actions;
  width: 100%;
  min-width: 0;
  justify-self: stretch;
  justify-content: flex-end;
  align-self: center;
  flex-wrap: nowrap;
}
.prompt-card > .card-footer    { grid-area: foot; padding-top: 12px; border-top: 1px solid var(--border); margin-top: 4px; }
.prompt-card:hover {
  border-color: color-mix(in srgb, var(--brand) 38%, var(--border));
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

/* Stagger cards */
.row > div:nth-child(1) .prompt-card { animation-delay:   0ms; }
.row > div:nth-child(2) .prompt-card { animation-delay:  50ms; }
.row > div:nth-child(3) .prompt-card { animation-delay: 100ms; }
.row > div:nth-child(4) .prompt-card { animation-delay: 150ms; }
.row > div:nth-child(5) .prompt-card { animation-delay: 200ms; }
.row > div:nth-child(6) .prompt-card { animation-delay: 250ms; }

/* Prompt grid: CSS auto-fill để tự điền đầy hàng */
.prompt-grid:not(.list-view) {
  display: grid !important;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
  margin-left: 0 !important;
  margin-right: 0 !important;
}
.prompt-grid:not(.list-view) > [class*="col-"] {
  padding-left: 0 !important;
  padding-right: 0 !important;
  margin-bottom: 0 !important;
  width: auto !important;
  max-width: none !important;
}

/* List / card view toggle */
.prompt-grid.list-view > div {
  flex: 0 0 100%;
  max-width: 100%;
  width: 100%;
  margin-bottom: 4px !important;
}
.prompt-grid.list-view .prompt-card {
  --prompt-icon-box-size: 32px;
  display: flex;
  flex-direction: row;
  align-items: center;
  flex-wrap: nowrap;
  gap: 10px;
  padding: 7px 12px;
  height: auto;
}
.prompt-grid.list-view .prompt-card > .icon-box {
  width: 32px;
  height: 32px;
  font-size: .85rem;
  border-radius: var(--r-md);
  flex-shrink: 0;
}
.prompt-grid.list-view .prompt-card > .card-body-link {
  flex: 1 1 0;
  min-width: 0;
  padding-top: 0;
}
.prompt-grid.list-view .prompt-card > .card-body-link h5 {
  margin-bottom: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: .9rem;
  line-height: 1.3;
}
.prompt-grid.list-view .prompt-card > .card-body-link p { display: none; }
.prompt-grid.list-view .prompt-card > .prompt-tags-row { display: none; }
.prompt-grid.list-view .prompt-card > .card-actions {
  flex: 0 0 auto;
  width: auto;
  justify-self: unset;
}
.prompt-grid.list-view .prompt-card > .card-actions .action-btn {
  width: 28px;
  height: 28px;
  font-size: .8rem;
}
.prompt-grid.list-view .prompt-card > .card-footer { display: none !important; }

/* ── Pagination ──────────────────────────────────────────────── */
.prompt-pagination .page-link {
  border-color: var(--border);
  color: var(--ink);
  background: var(--surface-raised);
  border-radius: var(--r-md) !important;
  font-size: var(--text-sm);
  padding: .35rem .65rem;
  line-height: 1.4;
  transition: background var(--t-fast), color var(--t-fast), border-color var(--t-fast);
}
.prompt-pagination .page-item.active .page-link {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}
.prompt-pagination .page-link:hover {
  background: var(--brand-light);
  color: var(--brand);
  border-color: var(--border);
}
.prompt-pagination .page-item.disabled .page-link {
  background: var(--surface-soft);
  color: var(--muted-2);
  border-color: var(--border);
}

/* ── Gallery filter pills: wrap on desktop, scroll on mobile ── */
.gallery-filter-row { flex-wrap: wrap; }

.gallery-filter-wrap {
  position: relative;
}

@media (max-width: 991.98px) {
  .gallery-filter-row {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .gallery-filter-row::-webkit-scrollbar { display: none; }
  .gallery-filter-row .gallery-filter-pill { flex-shrink: 0; }

  /* Gradient fade edges */
  .gallery-filter-wrap::before,
  .gallery-filter-wrap::after {
    content: '';
    position: absolute;
    top: 0; bottom: 0;
    width: 36px;
    z-index: 4;
    pointer-events: none;
    transition: opacity var(--t-base);
  }
  .gallery-filter-wrap::before {
    left: 0;
    background: linear-gradient(to right, var(--surface) 30%, transparent);
  }
  .gallery-filter-wrap::after {
    right: 0;
    background: linear-gradient(to left, var(--surface) 30%, transparent);
  }
  .gallery-filter-wrap.at-start::before { opacity: 0; }
  .gallery-filter-wrap.at-end::after    { opacity: 0; }
}

.gallery-scroll-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 6;
  width: 26px;
  height: 26px;
  border-radius: var(--r-full);
  border: 1.5px solid var(--border);
  background: var(--surface-raised);
  color: var(--ink-2);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-md);
  cursor: pointer;
  padding: 0;
  font-size: .72rem;
  transition: background var(--t-base), color var(--t-base), border-color var(--t-base);
  touch-action: manipulation;
}
.gallery-scroll-prev { left: 0; }
.gallery-scroll-next { right: 0; }
.gallery-scroll-btn:hover { background: var(--brand-light); color: var(--brand); border-color: var(--brand); }

/* ── Gallery card-main wrapper ── */
/* In card view: transparent — children behave as direct card-body children */
.gallery-card-main {
  display: contents;
}

#galleryGrid:not(.list-view) .gallery-card-main {
  cursor: pointer;
}
.gallery-card-col:has(.dropdown-menu.show) {
  position: relative;
  z-index: 1055;
}
#galleryGrid:not(.list-view) .app-hover-card:hover .gallery-card-text h6,
#galleryGrid.list-view .app-hover-card:hover .gallery-card-text h6 {
  color: var(--brand);
}

/* In list view: horizontal clickable row */
#galleryGrid.list-view .gallery-card-main {
  display: flex;
  flex: 1 1 0;
  min-width: 0;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  border-radius: var(--r-md);
  transition: background var(--t-base);
  margin: -4px;
  padding: 4px;
}
#galleryGrid.list-view .gallery-card-main:hover {
  background: transparent;
}
#galleryGrid.list-view .gallery-card-main:hover .gallery-card-text h6 {
  color: var(--brand);
}

/* ── Gallery list view ── */
#galleryGrid.list-view > div {
  flex: 0 0 100%;
  max-width: 100%;
}
#galleryGrid.list-view .card {
  height: auto !important;
}
#galleryGrid.list-view .card-body {
  flex-direction: row !important;
  align-items: center !important;
  padding: 10px 12px !important;
  gap: 10px !important;
}

/* Remove flex-grow-1 from text inside wrapper (wrapper handles it) */
#galleryGrid.list-view .gallery-card-text { flex: 1 1 0; }

/* Icon-only category pill */
#galleryGrid.list-view .gallery-card-badges {
  flex-shrink: 0;
}
#galleryGrid.list-view .gallery-cat-text { display: none; }
#galleryGrid.list-view .gallery-cat-icon { margin: 0 !important; font-size: .9rem; }
#galleryGrid.list-view .gallery-card-badges .badge {
  width: 30px;
  height: 30px;
  padding: 0;
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  border-radius: var(--r-full) !important;
  flex-shrink: 0;
}
/* Hide the "Đã thêm" badge — action button already shows this state */
#galleryGrid.list-view .gallery-card-badges .badge:last-child:not(:first-child) { display: none !important; }

/* Title: flex-grow, 2 lines max */
#galleryGrid.list-view .gallery-card-text {
  flex: 1 1 0;
  min-width: 0;
}
#galleryGrid.list-view .gallery-card-text h6 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: 0;
  font-size: .875rem;
  line-height: 1.35;
}
#galleryGrid.list-view .gallery-card-desc { display: none; }
#galleryGrid.list-view .gallery-card-vars { display: none !important; }

/* Action: compact, hide "Xem mẫu" */
#galleryGrid.list-view .gallery-card-actions {
  flex-shrink: 0;
  padding-top: 0 !important;
}
#galleryGrid.list-view .gallery-card-actions .btn-ghost { display: none !important; }
#galleryGrid.list-view .gallery-card-actions .btn-group { display: flex; }
#galleryGrid.list-view .gallery-card-actions .btn-group .btn {
  font-size: .78rem;
  padding: .3rem .65rem;
  white-space: nowrap;
}
/* Compact split arrow */
#galleryGrid.list-view .gallery-card-actions .dropdown-toggle-split {
  padding: .3rem .4rem;
}

/* ── List view: mobile optimisation ── */
@media (max-width: 767.98px) {
  .prompt-grid.list-view .prompt-card {
    gap: 10px;
    padding: 10px 12px;
  }

  /* Smaller icon */
  .prompt-grid.list-view .prompt-card > .icon-box {
    width: 32px;
    height: 32px;
    font-size: .85rem;
    border-radius: var(--r-md);
    flex-shrink: 0;
  }

  /* Allow title to wrap up to 2 lines instead of truncating */
  .prompt-grid.list-view .prompt-card > .card-body-link h5 {
    white-space: normal;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    font-size: .875rem;
    line-height: 1.35;
  }

  /* Show only star + edit + copy — hide duplicate, share, delete */
  .prompt-grid.list-view .prompt-card > .card-actions > :nth-child(n+4) {
    display: none;
  }

  /* Slightly smaller action buttons in list view */
  .prompt-grid.list-view .prompt-card > .card-actions .action-btn {
    width: 30px;
    height: 30px;
    font-size: .8rem;
  }
}

/* Panel card (detail / form) */
.panel-card {
  height: 100%;
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  background: var(--surface-raised);
  box-shadow: var(--shadow-md);
}

/* Workspace card */
.workspace-card {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1.25rem;
  border: 1.5px solid var(--border);
  border-radius: var(--r-xl);
  background: var(--surface-raised);
  color: var(--ink);
  text-decoration: none;
  box-shadow: var(--shadow-sm);
  transition: border-color var(--t-base), box-shadow var(--t-base), transform var(--t-base);
  animation: fadeInUp .28s both;
}
.workspace-card:hover {
  border-color: var(--brand);
  box-shadow: var(--shadow-brand);
  color: var(--ink);
  transform: translateY(-2px);
}

/* Auth card */
.auth-card {
  width: min(100%, 460px);
  padding: 2.25rem;
  border: 1px solid var(--border);
  border-radius: var(--r-2xl);
  background: var(--surface-raised);
  box-shadow: var(--shadow-xl);
  animation: scaleIn .22s both;
}

/* Compact prompt icon and color pickers */
.prompt-style-toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: .55rem;
}
.prompt-style-picker,
.category-style-picker {
  position: relative;
}
.prompt-style-trigger {
  display: flex;
  min-width: 150px;
  height: 44px;
  align-items: center;
  gap: .55rem;
  padding: .3rem .65rem .3rem .35rem;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  color: var(--ink);
  background: var(--surface-raised);
  text-align: left;
  transition: border-color var(--t-base), box-shadow var(--t-base), background var(--t-base);
}
.prompt-style-trigger:hover {
  border-color: color-mix(in srgb, var(--brand) 35%, var(--border));
  background: color-mix(in srgb, var(--brand-light) 18%, var(--surface-raised));
}
.prompt-style-trigger:focus,
.prompt-style-trigger[aria-expanded="true"] {
  outline: 0;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-light);
}
.prompt-style-trigger > span:nth-child(2) {
  display: flex;
  min-width: 0;
  flex: 1;
  flex-direction: column;
  line-height: 1.2;
}
.prompt-style-trigger strong {
  font-size: .75rem;
}
.prompt-style-trigger small {
  overflow: hidden;
  margin-top: 2px;
  color: var(--muted);
  font-size: .61rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.prompt-style-trigger-preview {
  display: grid;
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  place-items: center;
  border-radius: 9px;
}
.prompt-style-trigger-preview.is-icon {
  color: var(--brand);
  background: var(--brand-light);
  font-size: 1rem;
}
.prompt-style-trigger-preview.is-color {
  border: 1px solid var(--border);
  background:
    linear-gradient(135deg, transparent 46%, #ef4444 47%, #ef4444 53%, transparent 54%),
    var(--surface-soft);
}
.prompt-style-chevron {
  color: var(--muted);
  font-size: .68rem;
  transition: transform var(--t-base);
}
.prompt-style-trigger[aria-expanded="true"] .prompt-style-chevron {
  transform: rotate(180deg);
}
.prompt-style-help {
  color: var(--muted);
  font-size: .68rem;
}
.prompt-style-popover {
  position: absolute;
  z-index: 1085;
  top: calc(100% + 7px);
  left: 0;
  width: min(370px, calc(100vw - 3rem));
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--surface-raised);
  box-shadow: var(--shadow-xl);
  animation: scaleIn .14s both;
}
.prompt-style-picker.opens-up .prompt-style-popover,
.category-style-picker.opens-up .prompt-style-popover {
  top: auto;
  bottom: calc(100% + 7px);
  transform-origin: bottom left;
}
.prompt-style-popover-header {
  display: flex;
  min-height: 45px;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  padding: .55rem .7rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface-soft);
}
.prompt-style-popover-header strong {
  font-size: .75rem;
}
.prompt-style-popover-header select {
  width: auto;
  min-width: 135px;
  height: 30px;
  padding: .15rem 1.8rem .15rem .5rem;
  font-size: .68rem;
}
.prompt-icon-grid {
  display: grid;
  max-height: 230px;
  grid-template-columns: repeat(auto-fill, 34px);
  gap: .35rem;
  overflow-y: auto;
  padding: .7rem;
  overscroll-behavior: contain;
}
.prompt-icon-grid .icon-pick-btn {
  width: 34px !important;
  height: 34px !important;
  border-color: var(--border);
  border-radius: 8px;
}
.prompt-icon-grid .icon-pick-btn.active {
  border-color: var(--brand);
  color: var(--brand);
  background: var(--brand-light);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--brand) 15%, transparent);
}
.prompt-color-popover {
  right: 0;
  left: auto;
  width: min(310px, calc(100vw - 3rem));
}
.prompt-style-clear {
  padding: .2rem .45rem;
  border: 0;
  border-radius: 6px;
  color: var(--muted);
  background: transparent;
  font-size: .67rem;
}
.prompt-style-clear:hover {
  color: var(--danger);
  background: color-mix(in srgb, var(--danger) 8%, transparent);
}
.prompt-color-grid {
  display: grid;
  grid-template-columns: repeat(7, 28px);
  gap: .45rem;
  padding: .7rem;
}
.prompt-color-grid .color-swatch {
  position: relative;
  width: 28px !important;
  height: 28px !important;
  border: 2px solid transparent !important;
  border-radius: 8px !important;
}
.prompt-color-grid .color-swatch.is-selected {
  border-color: var(--surface-raised) !important;
  box-shadow: 0 0 0 2px var(--ink);
}
.prompt-color-custom,
.prompt-color-scope {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  padding: .55rem .7rem;
  border-top: 1px solid var(--border);
  font-size: .7rem;
}
.prompt-color-custom input[type="color"] {
  width: 34px;
  height: 28px;
  padding: 2px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface-raised);
  cursor: pointer;
}
.prompt-color-scope {
  justify-content: flex-start;
  cursor: pointer;
}
@media (max-width: 575.98px) {
  .prompt-style-toolbar {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .prompt-style-picker,
  .category-style-picker,
  .prompt-style-trigger {
    width: 100%;
    min-width: 0;
  }
  .prompt-style-help {
    grid-column: 1 / -1;
  }
}

/* Variable row in form builder */
.variable-builder-section {
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}
.variable-builder-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}
.variable-builder-heading-icon {
  display: grid;
  width: 40px;
  height: 40px;
  flex: 0 0 40px;
  place-items: center;
  border-radius: 12px;
  color: var(--brand);
  background: var(--brand-light);
}
.variable-count-badge {
  min-width: 22px;
  padding: 2px 7px;
  border-radius: var(--r-full);
  color: var(--brand);
  background: var(--brand-light);
  font-size: .68rem;
  font-weight: 700;
  text-align: center;
}
.variable-add-btn { white-space: nowrap; }
.variable-builder-empty {
  display: flex;
  align-items: center;
  gap: .8rem;
  padding: 1rem;
  border: 1.5px dashed var(--border);
  border-radius: var(--r-lg);
  color: var(--muted);
  background: color-mix(in srgb, var(--surface-raised) 70%, transparent);
}
.variable-builder-empty > span {
  display: grid;
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  place-items: center;
  border-radius: 11px;
  color: var(--brand);
  background: var(--brand-light);
}
.variable-builder-empty strong {
  display: block;
  color: var(--ink-2);
  font-size: .8rem;
}
.variable-builder-empty p {
  margin: .15rem 0 0;
  font-size: .72rem;
}
.variable-builder-empty code {
  color: var(--brand);
  font-size: .7rem;
}
.variable-row {
  border: 1.5px solid var(--border) !important;
  border-radius: var(--r-xl) !important;
  overflow: visible;
  background: var(--surface-raised) !important;
  box-shadow: var(--shadow-xs);
  transition: border-color var(--t-base), box-shadow var(--t-base);
}
.variable-row:focus-within {
  border-color: var(--brand) !important;
  box-shadow: 0 0 0 3px var(--brand-light) !important;
}
.variable-row-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  padding: .75rem .9rem;
  border-bottom: 1px solid var(--border);
  border-radius: calc(var(--r-xl) - 2px) calc(var(--r-xl) - 2px) 0 0;
  background: color-mix(in srgb, var(--surface-soft) 70%, var(--surface-raised));
}
.variable-row-actions {
  display: flex;
  align-items: center;
  gap: .45rem;
  flex-shrink: 0;
}
.variable-required-toggle {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  min-height: 30px;
  margin: 0;
  padding: .25rem .5rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--muted);
  background: var(--surface-raised);
  cursor: pointer;
  transition: border-color var(--t-base), color var(--t-base), background var(--t-base);
}
.variable-required-toggle.form-switch { padding-left: .5rem; }
.variable-required-toggle:has(.var-required:checked) {
  border-color: color-mix(in srgb, var(--brand) 38%, var(--border));
  color: var(--brand);
  background: var(--brand-light);
}
.variable-required-toggle .form-check-input {
  width: 1.65rem;
  height: .9rem;
  margin: 0;
  float: none;
  cursor: pointer;
}
.variable-required-text {
  font-size: .64rem;
  font-weight: 700;
  white-space: nowrap;
}
.variable-row-number {
  display: grid;
  width: 27px;
  height: 27px;
  flex: 0 0 27px;
  place-items: center;
  border-radius: 8px;
  color: var(--brand);
  background: var(--brand-light);
  font-size: .7rem;
  font-weight: 800;
}
.variable-row-title {
  overflow: hidden;
  color: var(--ink);
  font-size: .78rem;
  font-weight: 700;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.variable-row-code {
  overflow: hidden;
  margin-top: 1px;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: .64rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.variable-row-body { padding: .9rem; }
.variable-fields-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: .8rem;
}
.variable-field { min-width: 0; }
.variable-field-wide { grid-column: span 2; }
.variable-field .form-label,
.var-preset-row .form-label {
  margin-bottom: .3rem;
  color: var(--ink-2);
  font-size: .68rem;
  font-weight: 650;
}
.variable-field .input-group-text {
  border-color: var(--border);
  color: var(--muted);
  background: var(--surface-soft);
  font-family: var(--font-mono);
  font-size: .7rem;
}
.variable-text-control {
  display: flex;
  min-width: 0;
  min-height: 42px;
  align-items: center;
  gap: .45rem;
  padding: .25rem .35rem .25rem .25rem;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface-raised);
  transition: border-color var(--t-base), box-shadow var(--t-base), background var(--t-base);
}
.variable-text-control:hover {
  border-color: color-mix(in srgb, var(--brand) 28%, var(--border));
}
.variable-text-control:focus-within {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-light);
}
.variable-text-control .form-control {
  min-width: 0;
  height: 32px;
  padding: .25rem .35rem;
  border: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
  font-size: .72rem !important;
}
.variable-text-control .var-helper-textarea {
  min-height: 70px;
  height: 70px;
  padding-top: .35rem;
  line-height: 1.45;
  resize: vertical;
}
.variable-text-control.is-multiline {
  align-items: flex-start;
}
.variable-text-control.is-multiline .variable-text-icon {
  margin-top: 1px;
}
.variable-text-icon {
  display: grid;
  width: 34px;
  height: 32px;
  flex: 0 0 34px;
  place-items: center;
  border-radius: 8px;
  font-size: .76rem;
  pointer-events: none;
}
.variable-text-icon.is-blue { color: #2563eb; background: #eff6ff; }
.variable-text-icon.is-violet { color: #7c3aed; background: #f5f3ff; }
.variable-text-icon.is-emerald { color: #059669; background: #ecfdf5; }
.variable-text-icon.is-amber { color: #d97706; background: #fffbeb; }
.variable-key-control {
  gap: .25rem;
}
.variable-key-control .var-key {
  font-family: var(--font-mono);
  font-weight: 650;
}
.variable-key-brace {
  flex-shrink: 0;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: .7rem;
  font-weight: 700;
  pointer-events: none;
}
.variable-control-hint code {
  color: var(--brand);
  font-family: var(--font-mono);
  font-size: inherit;
}
.variable-custom-select {
  position: relative;
  min-width: 0;
}
.variable-select-trigger {
  display: flex;
  width: 100%;
  min-height: 42px;
  align-items: center;
  gap: .55rem;
  padding: .25rem .65rem .25rem .25rem;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  color: var(--ink);
  background: var(--surface-raised);
  text-align: left;
  transition: border-color var(--t-base), box-shadow var(--t-base), background var(--t-base);
}
.variable-select-trigger:hover {
  border-color: color-mix(in srgb, var(--brand) 35%, var(--border));
  background: color-mix(in srgb, var(--brand-light) 18%, var(--surface-raised));
}
.variable-select-trigger:focus,
.variable-select-trigger[aria-expanded="true"] {
  outline: 0;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-light);
}
.variable-select-icon {
  display: grid;
  width: 34px;
  height: 30px;
  flex: 0 0 34px;
  place-items: center;
  margin-left: 2px;
  border-radius: 8px;
  color: var(--brand);
  background: var(--brand-light);
  font-size: .76rem;
  pointer-events: none;
}
.variable-select-copy {
  display: flex;
  min-width: 0;
  flex: 1;
  flex-direction: column;
  line-height: 1.25;
}
.variable-select-copy strong {
  overflow: hidden;
  color: var(--ink);
  font-size: .72rem;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.variable-select-copy small {
  overflow: hidden;
  margin-top: 1px;
  color: var(--muted);
  font-size: .59rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.variable-select-chevron {
  flex-shrink: 0;
  color: var(--muted);
  font-size: .68rem;
  pointer-events: none;
  transition: transform var(--t-base);
}
.variable-select-trigger[aria-expanded="true"] .variable-select-chevron {
  transform: rotate(180deg);
}
.variable-select-menu {
  inset: calc(100% + .35rem) 0 auto 0 !important;
  width: auto;
  min-width: 100%;
  max-width: 100%;
  max-height: 300px;
  padding: .4rem;
  overflow-y: auto;
  overflow-x: hidden;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--surface-raised);
  box-shadow: var(--shadow-xl);
  transform: none !important;
  z-index: 1080;
}
.variable-custom-select.opens-up .variable-select-menu {
  inset: auto 0 calc(100% + .35rem) 0 !important;
}
.variable-select-option {
  display: grid;
  width: 100%;
  grid-template-columns: 34px minmax(0, 1fr) 20px;
  align-items: center;
  gap: .6rem;
  padding: .5rem;
  border: 0;
  border-radius: 9px;
  color: var(--ink);
  background: transparent;
  text-align: left;
  transition: background var(--t-fast), color var(--t-fast);
}
.variable-select-option:hover,
.variable-select-option:focus {
  outline: 0;
  background: var(--surface-soft);
}
.variable-select-option.is-selected {
  color: var(--brand);
  background: var(--brand-light);
}
.variable-select-option strong {
  display: block;
  overflow: hidden;
  font-size: .72rem;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.variable-select-option small {
  display: block;
  overflow: hidden;
  margin-top: 1px;
  color: var(--muted);
  font-size: .59rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.variable-select-option > span:nth-child(2) { min-width: 0; }
.variable-option-icon {
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border-radius: 9px;
  font-size: .76rem;
}
.variable-option-icon.is-blue { color: #2563eb; background: #eff6ff; }
.variable-option-icon.is-violet { color: #7c3aed; background: #f5f3ff; }
.variable-option-icon.is-emerald { color: #059669; background: #ecfdf5; }
.variable-option-icon.is-slate { color: #64748b; background: #f1f5f9; }
.variable-option-icon.is-amber { color: #d97706; background: #fffbeb; }
.variable-option-check {
  visibility: hidden;
  color: var(--brand);
  font-size: .9rem;
}
.variable-select-option.is-selected .variable-option-check { visibility: visible; }
.variable-select-group-label {
  display: block;
  padding: .45rem .5rem .25rem;
  color: var(--muted);
  font-size: .58rem;
  font-weight: 800;
  letter-spacing: .06em;
  text-transform: uppercase;
}
.variable-control-hint {
  margin-top: .3rem;
  color: var(--muted);
  font-size: .62rem;
  line-height: 1.4;
}
.var-preset-row {
  margin-top: 1rem;
}
.variable-preset-control.is-selected {
  border-color: color-mix(in srgb, var(--brand) 35%, var(--border));
}
.variable-preset-control.is-selected .variable-select-trigger {
  border-color: color-mix(in srgb, var(--brand) 35%, var(--border));
  background: color-mix(in srgb, var(--brand-light) 25%, var(--surface-raised));
}
.variable-optional-label {
  padding: 2px 7px;
  border-radius: var(--r-full);
  color: var(--muted);
  background: var(--surface-soft);
  font-size: .6rem;
  font-weight: 650;
}
.variable-optional-label.is-active {
  color: var(--brand);
  background: var(--brand-light);
}
html[data-bs-theme="dark"] .variable-option-icon {
  background: var(--surface-soft);
}
html[data-bs-theme="dark"] .variable-text-icon {
  background: var(--surface-soft);
}

@keyframes varRowFlash {
  0%   { border-color: var(--brand) !important; box-shadow: 0 0 0 4px var(--brand-light) !important; background: var(--brand-light) !important; }
  70%  { border-color: var(--brand) !important; box-shadow: 0 0 0 4px var(--brand-light) !important; background: var(--brand-light) !important; }
  100% { border-color: var(--border) !important; box-shadow: var(--shadow-xs) !important; background: var(--surface-raised) !important; }
}
.var-row-flash {
  animation: varRowFlash 1.2s ease forwards !important;
}

/* ============================================================
   PROMPT RESULT BOX
   ============================================================ */

.result-box {
  overflow: hidden;
  border-radius: var(--r-xl);
  background: #ffffff;
  box-shadow: var(--shadow-xl);
  border: 1px solid #e2e8f0;
}
.result-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px;
  border-bottom: 1px solid #e2e8f0;
  background: #f8fafc;
}
.result-content {
  min-height: 380px;
  max-height: 580px;
  overflow: auto;
  padding: 22px;
  color: #334155;
  white-space: pre-wrap;
  font: var(--text-sm)/1.8 var(--font-mono);
  letter-spacing: .01em;
}

html[data-bs-theme="dark"] .result-box {
  background: #0d1524;
  border-color: #1e2d45;
}
html[data-bs-theme="dark"] .result-header {
  border-bottom-color: #1e2d45;
  background: #111c30;
}
html[data-bs-theme="dark"] .result-content {
  color: #cdd5e0;
}
.highlight-var {
  padding: 1px 6px;
  color: #92400e;
  border: 1px solid rgba(202, 138, 4, .5);
  border-radius: var(--r-sm);
  background: rgba(254, 240, 138, .6);
  font-weight: 600;
}
html[data-bs-theme="dark"] .highlight-var {
  color: #fde68a;
  border-color: rgba(234, 179, 8, .4);
  background: rgba(234, 179, 8, .14);
  font-weight: 500;
}

/* ============================================================
   ICON BOX
   ============================================================ */

.icon-box {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: var(--r-lg);
  color: var(--brand);
  background: var(--brand-light);
  flex-shrink: 0;
}

/* ============================================================
   EMPTY STATE
   ============================================================ */

.empty-state {
  padding: 4.5rem 1.5rem;
  border: 1.5px dashed var(--border);
  border-radius: var(--r-2xl);
  background: var(--surface-raised);
  text-align: center;
  animation: fadeInUp .3s both;
}

/* ============================================================
   AUTH SHELL
   ============================================================ */

.auth-shell {
  position: relative;
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 2rem;
  background:
    radial-gradient(ellipse 80% 50% at 20% -10%, rgba(79, 70, 229, .12) 0%, transparent 60%),
    radial-gradient(ellipse 60% 40% at 80% 110%, rgba(124, 58, 237, .10) 0%, transparent 60%),
    var(--surface);
}
/* When auth-shell contains a split panel, align to start so it doesn't clip on tall forms */
.auth-shell:has(.auth-split) {
  align-items: start;
  padding-block: 3rem;
}

/* ============================================================
   AUTH SPLIT (two-panel login/register layout)
   ============================================================ */

.auth-split {
  display: flex;
  width: min(100%, 1200px);
  min-height: 580px;
  border-radius: var(--r-2xl);
  overflow: hidden;
  box-shadow: var(--shadow-xl);
  border: 1px solid var(--border);
  animation: scaleIn .22s both;
}

.auth-split-left {
  flex: 0 0 50%;
  background: var(--gradient-brand);
  padding: 2.75rem 2.5rem;
  display: flex;
  flex-direction: column;
  color: #fff;
  position: relative;
  overflow: hidden;
}
.auth-split-left::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 70% 60% at 110% -10%, rgba(255,255,255,.12) 0%, transparent 55%),
    radial-gradient(ellipse 50% 50% at -10% 110%, rgba(255,255,255,.08) 0%, transparent 55%);
  pointer-events: none;
}

.auth-split-left-brand {
  display: flex;
  align-items: center;
  gap: .75rem;
  margin-bottom: 2.5rem;
  position: relative;
}
.auth-split-left-brand img { width: 38px; height: 38px; object-fit: contain; }
.auth-split-left-brand span { font-size: 1.15rem; font-weight: 700; letter-spacing: -.01em; color: #fff; }
.auth-split-left-brand small { display: block; font-size: .72rem; font-weight: 400; opacity: .8; margin-top: 1px; color: #fff; }

.auth-split-left-hero {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  position: relative;
}
.auth-split-left-hero h2 {
  font-size: clamp(1.5rem, 2.8vw, 2rem);
  font-weight: 800;
  line-height: 1.22;
  margin-bottom: 1rem;
  color: #fff;
}
.auth-split-left-hero p {
  font-size: .875rem;
  color: rgba(255,255,255,.82);
  line-height: 1.6;
  margin-bottom: 1.75rem;
}

.auth-split-feature {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .6rem .875rem;
  border: 1px solid rgba(255,255,255,.22);
  border-radius: var(--r-full);
  font-size: .8rem;
  font-weight: 500;
  margin-bottom: .5rem;
  backdrop-filter: blur(4px);
  background: rgba(255,255,255,.10);
  color: #fff;
}
.auth-split-feature i { font-size: 1rem; opacity: .9; }

.auth-split-stats {
  display: flex;
  margin-bottom: 1.75rem;
  background: rgba(255,255,255,.12);
  border-radius: var(--r-lg);
  padding: .75rem .5rem;
  position: relative;
}
.auth-split-stat {
  flex: 1;
  text-align: center;
  padding: 0 .5rem;
}
.auth-split-stat + .auth-split-stat {
  border-left: 1px solid rgba(255,255,255,.2);
}
.auth-split-stat strong {
  display: block;
  font-size: 1.3rem;
  font-weight: 800;
  color: #fff;
  line-height: 1.2;
  letter-spacing: -.02em;
}
.auth-split-stat span {
  font-size: .7rem;
  color: rgba(255,255,255,.68);
  font-weight: 500;
}

.auth-split-left-footer {
  font-size: .73rem;
  color: rgba(255,255,255,.55);
  margin-top: 2rem;
  position: relative;
}

.auth-split-right {
  flex: 1;
  background: var(--surface-raised);
  padding: 2.75rem 2.5rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
  overflow-y: auto;
}

/* Password field with inline eye icon */
.pw-wrap {
  position: relative;
}
.pw-wrap .form-control {
  padding-right: 2.25rem;
}
.pw-wrap .pw-eye {
  position: absolute;
  right: .6rem;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  padding: 0;
  color: var(--muted);
  font-size: .8rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  z-index: 5;
}
.pw-wrap .pw-eye:hover { color: var(--ink); }

/* Responsive: stack vertically on small screens */
@media (max-width: 767.98px) {
  .auth-shell { padding-inline: 1rem; }
  .auth-split { flex-direction: column; width: min(100%, 480px); }
  .auth-split-left { flex: none; padding: 1.75rem; }
  .auth-split-left-hero p,
  .auth-split-feature,
  .auth-split-left-footer { display: none; }
  .auth-split-left-hero { flex: none; }
  .auth-split-left-brand { margin-bottom: 0; }
  .auth-split-stats { margin-bottom: 0; }
  .auth-split-right { padding: 2rem 1.75rem; }
}

/* ============================================================
   GLOBAL SPINNER
   ============================================================ */

.global-spinner {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: grid;
  place-items: center;
  background: var(--spinner-overlay);
  backdrop-filter: blur(3px);
}

/* ============================================================
   MISCELLANEOUS
   ============================================================ */

.remove-variable {
  display: grid;
  width: 30px;
  height: 30px;
  padding: 0;
  flex: 0 0 30px;
  place-items: center;
  border: 0;
  border-radius: 8px;
  color: var(--muted);
  background: transparent;
  font-size: .8rem;
  transition: color var(--t-base), background var(--t-base);
}
.remove-variable:hover {
  color: var(--danger);
  background: var(--danger-light);
}

.runner-sticky { top: 1rem; }
.min-w-0       { min-width: 0; }

/* Runner modal header: badge+close on row 1, action buttons on row 2 */
.runner-modal-header {
  flex-wrap: wrap;
  gap: .25rem;
  align-items: flex-start;
}
.runner-modal-header > .flex-grow-1 {
  flex: 1 1 0;
  min-width: 0;
  order: 1;
}
.runner-modal-header > .btn-close {
  order: 1;
  align-self: flex-start;
  margin-top: 2px;
  flex-shrink: 0;
}
.runner-modal-header > .runner-actions {
  order: 2;
  flex: 0 0 100%;
  justify-content: flex-start;
  padding-top: .25rem;
  margin-top: .25rem;
}
.x-small       { font-size: var(--text-xs); }
.clamp-3       { display: -webkit-box; overflow: hidden; -webkit-box-orient: vertical; -webkit-line-clamp: 3; }

/* ============================================================
   PILL TABS
   ============================================================ */

.nav-pills {
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  padding: 4px;
  display: inline-flex;
  gap: 2px;
}

.nav-pills .nav-link {
  color: var(--muted);
  font-size: var(--text-sm);
  font-weight: 500;
  padding: 6px 18px;
  border-radius: var(--r-lg);
  border: 0;
  background: transparent;
  transition: color var(--t-base), background var(--t-base), box-shadow var(--t-base);
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.nav-pills .nav-link:hover:not(.active) {
  color: var(--brand);
  background: var(--brand-subtle);
}

.nav-pills .nav-link.active {
  color: #fff;
  background: var(--gradient-brand);
  box-shadow: var(--shadow-brand);
}

html[data-bs-theme="dark"] .nav-pills {
  background: var(--surface-soft);
  border-color: var(--border);
}

html[data-bs-theme="dark"] .nav-pills .nav-link.active {
  color: #fff;
}

/* ============================================================
   DARK MODE — BOOTSTRAP OVERRIDES
   ============================================================ */

html[data-bs-theme="dark"] .text-dark  { color: var(--ink) !important; }
html[data-bs-theme="dark"] .bg-white   { background-color: var(--surface-raised) !important; }
html[data-bs-theme="dark"] .bg-light   { background-color: var(--surface-soft) !important; }

html[data-bs-theme="dark"] .btn-light {
  --bs-btn-color:              var(--ink);
  --bs-btn-bg:                 var(--surface-soft);
  --bs-btn-border-color:       var(--border);
  --bs-btn-hover-color:        var(--ink);
  --bs-btn-hover-bg:           var(--surface-soft);
  --bs-btn-hover-border-color: var(--brand);
  --bs-btn-active-bg:          var(--brand-light);
}

html[data-bs-theme="dark"] .form-control,
html[data-bs-theme="dark"] .form-select {
  color: var(--ink) !important;
  border-color: var(--border) !important;
  background-color: var(--surface-soft) !important;
}
html[data-bs-theme="dark"] .form-control:focus,
html[data-bs-theme="dark"] .form-select:focus {
  background-color: var(--surface-raised) !important;
}

html[data-bs-theme="dark"] .list-group-item {
  color: var(--ink);
  border-color: var(--border);
  background-color: var(--surface-raised);
}
html[data-bs-theme="dark"] .modal-content {
  color: var(--ink);
  border-color: var(--border);
  background-color: var(--surface-raised);
}

@media (min-width: 992px) {
  #categoryModal .modal-dialog {
    max-width: min(1100px, 92vw);
  }
  #categoryModal .modal-content {
    min-height: 72vh;
  }
}

html[data-bs-theme="dark"] .card {
  color: var(--ink);
  border-color: var(--border);
  background-color: var(--surface-raised);
}

html[data-bs-theme="dark"] .border,
html[data-bs-theme="dark"] .border-top,
html[data-bs-theme="dark"] .border-bottom {
  border-color: var(--border) !important;
}

html[data-bs-theme="dark"] .custom-input {
  background: var(--surface-soft);
  border-color: var(--border);
  color: var(--ink);
}
html[data-bs-theme="dark"] .custom-input:focus {
  background: var(--surface-raised);
  border-color: var(--brand);
}

html[data-bs-theme="dark"] .variable-row {
  background: var(--surface-raised) !important;
  border-color: var(--border) !important;
}

html[data-bs-theme="dark"] .search-input {
  background: var(--surface-soft);
  border-color: var(--border);
  color: var(--ink);
}
html[data-bs-theme="dark"] .search-input:focus {
  background: var(--surface-raised);
  border-color: var(--brand);
}

html[data-bs-theme="dark"] .badge.bg-primary-subtle {
  background-color: var(--brand-light) !important;
  color: var(--brand) !important;
}

html[data-bs-theme="dark"] .alert-info {
  background-color: rgba(59, 130, 246, .12);
  border-color: rgba(59, 130, 246, .25);
  color: #93c5fd;
}

/* ============================================================
   RESPONSIVE BREAKPOINTS
   ============================================================ */

/* LG → narrow padding */
@media (max-width: 1199.98px) {
  #main-content { padding: 1.5rem 1.25rem; }
}

/* MD → slide-out sidebar */
@media (max-width: 991.98px) {
  #sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    transform: translateX(-100%);
    box-shadow: var(--shadow-xl);
  }
  #sidebar.show { transform: translateX(0); }
  .sidebar-overlay.show {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 1030;
    background: rgba(15, 23, 42, .5);
    backdrop-filter: blur(2px);
  }
  #main-content          { padding: 1rem .625rem; }
  #main-wrapper > header { min-height: 52px; padding: .625rem .75rem; gap: .5rem; }
}

/* SM → tighter spacing */
@media (max-width: 767.98px) {
  .auth-card  { padding: 1.75rem; }
  #main-content { padding: .875rem .75rem; }
  .prompt-card  { padding: 16px; }
}

/* XS */
@media (max-width: 575.98px) {
  .auth-theme-toggle { top: .75rem; right: .75rem; }
}

.category-edit.drag-over-top { border-top: 2px solid var(--bs-primary) !important; }
.category-edit.drag-over-bottom { border-bottom: 2px solid var(--bs-primary) !important; }
.category-edit.dragging { opacity: .4; }

.skill-category-picker {
  max-height: 210px;
  overflow: auto;
  padding: .65rem .75rem;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--surface-soft);
}

.skill-category-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: .45rem .75rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.skill-category-options label {
  display: flex;
  align-items: center;
  gap: .45rem;
  margin: 0;
  font-size: .82rem;
}

@media (max-width: 640px) {
  .skill-category-options {
    grid-template-columns: 1fr;
  }
}

/* ============================================================
   MOBILE BOTTOM NAV
   ============================================================ */

.mobile-bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 1025;
  background: var(--surface-raised);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: stretch;
  padding-bottom: env(safe-area-inset-bottom, 0px);
  box-shadow: 0 -2px 20px rgba(15, 23, 42, .07);
}

html[data-bs-theme="dark"] .mobile-bottom-nav {
  box-shadow: 0 -2px 20px rgba(0, 0, 0, .30);
}

.mobile-nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 10px 4px 12px;
  color: var(--muted);
  text-decoration: none;
  font-size: .6rem;
  font-weight: 500;
  letter-spacing: .01em;
  transition: color var(--t-base);
  position: relative;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.mobile-nav-item:hover { color: var(--brand); }

.mobile-nav-item.active { color: var(--brand); }

.mobile-nav-item.active::before {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 32px;
  height: 3px;
  background: var(--brand);
  border-radius: 0 0 var(--r-sm) var(--r-sm);
}

.mobile-nav-item i {
  font-size: 1.2rem;
  line-height: 1;
  display: block;
}

/* Add bottom padding so content isn't hidden behind the nav */
@media (max-width: 991.98px) {
  #main-content {
    padding-bottom: calc(4.25rem + env(safe-area-inset-bottom, 0px)) !important;
  }
}

/* ============================================================
   MOBILE UX IMPROVEMENTS
   ============================================================ */

/* iOS Safari zooms the page when a focused form control is below 16px. */
@supports (-webkit-touch-callout: none) {
  @media (max-width: 991.98px) {
    input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]),
    textarea,
    select {
      font-size: 16px !important;
    }
  }
}

/* Prevent double-tap zoom on interactive elements */
.action-btn, .btn-brand, .category-btn, .theme-toggle,
.mobile-nav-item, .gallery-filter-pill, .btn {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

@media (max-width: 767.98px) {
  /* Slightly larger touch targets for action buttons */
  .action-btn {
    width: 36px;
    height: 36px;
  }

  /* Runner modal: show icon only on buttons to prevent overflow */
  .runner-btn-label { display: none; }
  .runner-actions .btn i { margin-right: 0 !important; }

  /* Share modal: full width */
  #promptShareModal .modal-dialog {
    margin: .5rem auto;
  }
}

/* XS: hide least-used card actions to prevent overflow */
@media (max-width: 479.98px) {
  .account-page > .row {
    --bs-gutter-x: 1.25rem;
  }

  .prompt-card > .card-actions .action-btn:nth-child(n+5) {
    display: none;
  }
  .prompt-card { padding: 14px; }
  #main-content { padding: .75rem .625rem; }
}

/* Compact search + header controls on mobile */
@media (max-width: 991.98px) {
  .search-input { height: 30px; font-size: .8rem; }
  .theme-toggle { width: 32px; height: 32px; }
  .btn-brand    { height: 30px; padding: 0 12px; font-size: .8rem; }
}

/* Safe area inset for notched phones */
@media (max-width: 991.98px) {
  #main-wrapper > header {
    padding-left: max(.875rem, env(safe-area-inset-left, .875rem));
    padding-right: max(.875rem, env(safe-area-inset-right, .875rem));
  }
  .mobile-bottom-nav {
    padding-left: env(safe-area-inset-left, 0px);
    padding-right: env(safe-area-inset-right, 0px);
  }
}

/* ============================================================
   PROMPT HINT PANEL
   ============================================================ */

.hint-card {
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  background: var(--surface-raised);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.hint-card-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  cursor: pointer;
  user-select: none;
  transition: background var(--t-base);
}
.hint-card-header:hover { background: var(--surface-soft); }

.hint-card-body { padding: 0 16px 16px; }

.hint-example-box {
  border-radius: var(--r-md);
  padding: 10px 12px;
  font-size: var(--text-xs);
  line-height: 1.65;
  border: 1px solid var(--border);
  background: var(--surface-soft);
  color: var(--ink-2);
}
.hint-example-box.is-after {
  background: var(--brand-subtle);
  border-color: rgba(79, 70, 229, .2);
}
.hint-example-label {
  font-size: .62rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .9px;
  margin-bottom: 5px;
  color: var(--muted);
}
.hint-example-box.is-after .hint-example-label { color: var(--brand); }

.hint-arrow {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: var(--text-xs);
  color: var(--muted);
  padding: 4px 0;
}
.hint-arrow::before,
.hint-arrow::after { content: ''; flex: 1; height: 1px; background: var(--border); }

/* Quick-insert chips */
.variable-library {
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--surface-raised);
}
.variable-library-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  padding: .75rem .8rem;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface-soft) 65%, var(--surface-raised));
}
.variable-library-icon {
  display: grid;
  width: 30px;
  height: 30px;
  flex: 0 0 30px;
  place-items: center;
  border-radius: 9px;
  color: var(--brand);
  background: var(--brand-light);
  font-size: .8rem;
}
.variable-library-title {
  color: var(--ink-2);
  font-size: .74rem;
  font-weight: 700;
}
.variable-library-subtitle {
  margin-top: 1px;
  color: var(--muted);
  font-size: .64rem;
}
.variable-library-toggle {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  padding: .3rem .5rem;
  border: 0;
  border-radius: 7px;
  color: var(--brand);
  background: transparent;
  font-size: .68rem;
  font-weight: 650;
  white-space: nowrap;
}
.variable-library-toggle:hover { background: var(--brand-light); }
.variable-library-popular { padding: .7rem .8rem .75rem; }
.variable-library-label {
  display: block;
  margin-bottom: .4rem;
  color: var(--muted);
  font-size: .61rem;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
}
.var-chip {
  display: inline-flex;
  align-items: center;
  padding: 2px 9px;
  border-radius: var(--r-full);
  font-size: .68rem;
  font-weight: 600;
  font-family: var(--font-mono);
  color: var(--brand);
  background: var(--brand-light);
  border: 1px solid rgba(79, 70, 229, .2);
  cursor: pointer;
  transition: background var(--t-base), color var(--t-base), border-color var(--t-base), transform var(--t-fast);
  white-space: nowrap;
}
.var-chip:hover {
  background: var(--brand);
  color: #fff;
  border-color: transparent;
  transform: translateY(-1px);
}
.var-chip:active { transform: translateY(0); }

html[data-bs-theme="dark"] .hint-example-box { background: var(--surface-soft); border-color: var(--border); }
html[data-bs-theme="dark"] .hint-example-box.is-after { background: var(--brand-subtle); border-color: rgba(99,102,241,.2); }
html[data-bs-theme="dark"] .hint-card { background: var(--surface-raised); border-color: var(--border); }

/* ── Custom confirm overlay ────────────────────────────── */
.confirm-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, .52);
  backdrop-filter: blur(3px);
  animation: confirmFadeIn .14s ease;
}
.confirm-dialog {
  background: var(--surface-raised);
  color: var(--ink);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 1.5rem 1.5rem 1.25rem;
  max-width: 340px;
  width: 92%;
  box-shadow: 0 24px 64px rgba(0, 0, 0, .28);
  animation: confirmSlideUp .18s cubic-bezier(.34, 1.4, .64, 1);
}
@keyframes confirmFadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes confirmSlideUp {
  from { opacity: 0; transform: translateY(10px) scale(.97); }
  to   { opacity: 1; transform: translateY(0)    scale(1);   }
}

/* ── Tag chips (prompt cards) ──────────────────────────── */
.prompt-tags-row {
  display: flex;
  flex-wrap: wrap;
  gap: .25rem;
  margin-top: .35rem;
}
.prompt-tag {
  display: inline-flex;
  align-items: center;
  font-size: .68rem;
  font-weight: 500;
  line-height: 1;
  padding: .2rem .5rem;
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--muted);
  border: 1px solid var(--border);
  text-decoration: none;
  transition: background .15s, color .15s;
  white-space: nowrap;
  cursor: pointer;
}
.prompt-tag:hover,
.prompt-tag.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}
[data-bs-theme="dark"] .prompt-tag {
  background: #1e2533;
  color: #9ba8bf;
  border-color: #2d3648;
}
[data-bs-theme="dark"] .prompt-tag:hover,
[data-bs-theme="dark"] .prompt-tag.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

/* ── Tag input (form modal) ────────────────────────────── */
.tag-input-wrap {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  gap: .35rem;
  align-items: center;
  min-height: 38px;
  padding: .3rem .5rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  cursor: text;
  transition: border-color .15s;
}
.tag-input-wrap:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 15%, transparent);
}
.tag-pill {
  display: inline-flex;
  align-items: center;
  gap: .25rem;
  font-size: .72rem;
  font-weight: 500;
  padding: .18rem .5rem .18rem .55rem;
  border-radius: 999px;
  background: color-mix(in srgb, var(--primary) 15%, transparent);
  color: var(--primary);
  border: 1px solid color-mix(in srgb, var(--primary) 30%, transparent);
  white-space: nowrap;
}
.tag-pill button {
  all: unset;
  cursor: pointer;
  display: flex;
  align-items: center;
  opacity: .65;
  font-size: .8rem;
  line-height: 1;
}
.tag-pill button:hover { opacity: 1; }
.tag-text-input {
  all: unset;
  font-size: .85rem;
  min-width: 80px;
  flex: 1;
  color: var(--ink);
}
.tag-suggestions {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,.12);
  z-index: 9999;
  max-height: 180px;
  overflow-y: auto;
}
.tag-suggestion-item {
  padding: .45rem .75rem;
  font-size: .82rem;
  cursor: pointer;
  color: var(--ink);
  transition: background .1s;
}
.tag-suggestion-item:hover,
.tag-suggestion-item.focused {
  background: var(--surface-soft);
}

/* ── Audit Log ─────────────────────────────────────────── */
.audit-row {
  transition: background .12s;
}
.audit-row:hover {
  background: var(--surface-soft);
}
.audit-action-dot {
  background: var(--surface);
  border-radius: 50%;
  padding: 1px;
  line-height: 1;
  font-size: .65rem;
}

/* ── Preset Combobox (runner) ───────────────────────────── */
.preset-hint {
  opacity: .8;
}

/* ── Variable chip groups (form modal) ──────────────────── */
.var-chip-groups {
  padding: .75rem .8rem .35rem;
  border-top: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface-soft) 55%, transparent);
}
.var-chip-group-row {
  display: grid;
  grid-template-columns: 6.5rem minmax(0, 1fr);
  align-items: start;
  gap: .65rem;
  padding: .55rem 0;
  border-top: 1px solid color-mix(in srgb, var(--border) 70%, transparent);
}
.var-chip-group-row:first-of-type { border-top: 0; }
.var-chip-group-label {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  font-size: .65rem;
  font-weight: 600;
  color: var(--ink-2);
  white-space: nowrap;
  margin-top: .2rem;
}
.var-chip-group-label i { color: var(--brand); }

/* ── Variable preset row ────────────────────────────────── */
.var-preset-preview {
  font-size: .7rem;
  opacity: .85;
}

@media (max-width: 767.98px) {
  .variable-library-header,
  .variable-builder-heading {
    align-items: flex-start;
  }
  .variable-builder-heading {
    flex-direction: column;
  }
  .variable-add-btn { width: 100%; }
  .variable-fields-grid { grid-template-columns: 1fr; }
  .variable-field-wide { grid-column: auto; }
  .var-chip-group-row { grid-template-columns: 1fr; gap: .35rem; }
  .variable-library-subtitle { display: none; }
  .variable-required-text { display: none; }
  .variable-required-toggle { padding-inline: .4rem; }
}
