:root {
  --primary: #e91e8c;
  --primary-dark: #c41775;
  --primary-light: #fce4f3;
  --primary-soft: #fdf2f8;
  --bg: #f5f6fa;
  --card: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --border: #e8eaed;
  --border-strong: #ced0d6;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(0,0,0,0.04), 0 4px 16px rgba(0,0,0,0.04);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.12);
  --font: "Vazirmatn", Tahoma, sans-serif;
  --success: #059669;
  --danger: #dc2626;
  --danger-bg: #fef2f2;
  --warning: #d97706;
  --warning-bg: #fffbeb;
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  height: -webkit-fill-available;
  overflow-x: hidden;
  max-width: 100%;
}

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
  min-height: 100dvh;
  min-height: -webkit-fill-available;
  overflow-x: hidden;
  max-width: 100%;
}

img,
video,
canvas {
  max-width: 100%;
}

.hidden {
  display: none !important;
}

/* ── Auth (legacy kept for compat) ── */
.auth-step {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.auth-info {
  margin: 0 0 16px;
  padding: 12px 14px;
  background: var(--primary-soft);
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  color: var(--text);
  line-height: 1.5;
}

.input-otp {
  text-align: center;
  letter-spacing: 0.35em;
  font-size: 1.2rem !important;
  font-weight: 600;
}

.error {
  color: var(--danger);
  font-size: 0.85rem;
  margin-top: 16px;
  padding: 10px 12px;
  background: var(--danger-bg);
  border-radius: var(--radius-sm);
}

/* ── Login page redesign ── */
.login-shell {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: row-reverse;
}

/* Form side */
.login-form-side {
  flex: 0 0 420px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #fff;
  padding: max(32px, env(safe-area-inset-top)) 40px max(32px, env(safe-area-inset-bottom));
  position: relative;
  z-index: 1;
}

.login-form-inner {
  width: 100%;
  max-width: 340px;
}

.login-form-logo {
  margin-bottom: 28px;
}

.login-form-logo img {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  box-shadow: 0 4px 16px rgba(233, 30, 140, 0.18);
  display: block;
}

.login-form-head {
  margin-bottom: 32px;
}

.login-form-head h1 {
  margin: 0 0 6px;
  font-size: 1.6rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--text);
}

.login-form-head p {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.auth-step {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.login-field {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.login-field label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text);
}

.login-input-wrap {
  position: relative;
}

.login-input-wrap svg {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  pointer-events: none;
}

.login-input-wrap input {
  padding-right: 42px;
}

.login-otp-input {
  text-align: center;
  letter-spacing: 0.4em;
  font-size: 1.4rem !important;
  font-weight: 700;
  padding: 16px !important;
}

.login-otp-info {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 11px 14px;
  background: var(--primary-soft);
  border: 1px solid rgba(233, 30, 140, 0.15);
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  color: var(--text);
  line-height: 1.5;
}

.login-otp-info svg {
  flex-shrink: 0;
  color: var(--primary);
}

.login-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 14px 20px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  transition: box-shadow 0.2s, opacity 0.15s;
  box-shadow: 0 4px 18px rgba(233, 30, 140, 0.28);
  margin-top: 4px;
}

.login-btn:hover {
  box-shadow: 0 6px 24px rgba(233, 30, 140, 0.38);
  opacity: 0.96;
}

.login-btn:active {
  transform: scale(0.985);
}

.login-btn:disabled,
.login-btn.is-loading {
  opacity: 0.7;
  cursor: not-allowed;
  pointer-events: none;
}

.login-btn-ghost {
  display: block;
  width: 100%;
  padding: 10px;
  background: transparent;
  border: none;
  font-family: var(--font);
  font-size: 0.88rem;
  color: var(--muted);
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: background 0.15s, color 0.15s;
  text-align: center;
}

.login-btn-ghost:hover {
  background: var(--bg);
  color: var(--text);
}

.login-error {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  padding: 11px 14px;
  background: var(--danger-bg);
  border: 1px solid rgba(220, 38, 38, 0.15);
  border-radius: var(--radius-sm);
  color: var(--danger);
  font-size: 0.85rem;
}

/* Brand side */
.login-brand-side {
  flex: 1;
  background: linear-gradient(145deg, #e91e8c 0%, #c41775 45%, #8b0f56 100%);
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 60px 56px;
}

.login-brand-blobs {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.login-blob {
  position: absolute;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.07);
}

.login-blob-1 {
  width: 420px;
  height: 420px;
  top: -140px;
  right: -80px;
}

.login-blob-2 {
  width: 300px;
  height: 300px;
  bottom: -100px;
  left: -60px;
  background: rgba(255, 255, 255, 0.05);
}

.login-blob-3 {
  width: 180px;
  height: 180px;
  top: 40%;
  right: 60%;
  background: rgba(255, 255, 255, 0.04);
}

.login-brand-content {
  position: relative;
  z-index: 1;
  color: #fff;
  max-width: 420px;
  width: 100%;
}

.login-brand-logo-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 36px;
}

.login-brand-logo {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.15);
  padding: 4px;
  object-fit: contain;
}

.login-brand-name {
  font-size: 1rem;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.9);
}

.login-brand-headline {
  margin: 0 0 14px;
  font-size: 2rem;
  font-weight: 800;
  line-height: 1.3;
  letter-spacing: -0.03em;
  color: #fff;
}

.login-brand-sub {
  margin: 0 0 36px;
  font-size: 0.95rem;
  color: rgba(255, 255, 255, 0.72);
  line-height: 1.7;
}

.login-features {
  list-style: none;
  margin: 0 0 40px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.login-feature {
  display: flex;
  align-items: flex-start;
  gap: 14px;
}

.login-feature-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: #fff;
  backdrop-filter: blur(8px);
}

.login-feature div {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding-top: 4px;
}

.login-feature strong {
  font-size: 0.9rem;
  font-weight: 700;
  color: #fff;
}

.login-feature span {
  font-size: 0.8rem;
  color: rgba(255, 255, 255, 0.65);
}

.login-brand-illustration {
  display: flex;
  justify-content: center;
}

.login-brand-illustration img {
  max-width: 260px;
  width: 100%;
  opacity: 0.88;
  filter: drop-shadow(0 20px 40px rgba(0, 0, 0, 0.25));
}

/* ── Responsive login (mobile bottom-sheet style) ── */
@media (max-width: 860px) {
  .login-shell {
    flex-direction: column;
    min-height: 100vh;
    min-height: 100dvh;
    background: linear-gradient(145deg, #e91e8c 0%, #c41775 50%, #8b0f56 100%);
    position: relative;
    overflow: hidden;
  }

  /* Brand panel: compact header — pushed to top via order */
  .login-brand-side {
    order: -1;
    flex: none;
    background: transparent;
    padding: max(36px, env(safe-area-inset-top)) 28px 0;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .login-brand-content {
    text-align: center;
    align-items: center;
    display: flex;
    flex-direction: column;
  }

  .login-brand-logo-wrap {
    flex-direction: column;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
  }

  .login-brand-logo {
    width: 56px;
    height: 56px;
    border-radius: 16px;
    padding: 6px;
    background: rgba(255,255,255,0.2);
  }

  .login-brand-name {
    font-size: 1.1rem;
  }

  .login-brand-headline {
    font-size: 1.4rem;
    margin-bottom: 8px;
    text-align: center;
  }

  .login-brand-sub {
    display: block;
    font-size: 0.85rem;
    margin-bottom: 0;
    text-align: center;
    color: rgba(255,255,255,0.75);
  }

  .login-features {
    display: none;
  }

  .login-brand-illustration {
    display: none;
  }

  .login-brand-blobs {
    display: none;
  }

  /* Form panel: bottom sheet */
  .login-form-side {
    order: 1;
    flex: 1;
    width: 100%;
    background: #fff;
    border-radius: 28px 28px 0 0;
    margin-top: 16px;
    padding: 28px 24px max(28px, env(safe-area-inset-bottom));
    justify-content: flex-start;
    align-items: stretch;
    box-shadow: 0 -8px 40px rgba(0, 0, 0, 0.18);
    position: relative;
    z-index: 2;
    overflow-y: auto;
  }

  .login-form-side::before {
    display: none;
  }

  .login-form-inner {
    max-width: 100%;
    width: 100%;
  }

  .login-form-logo {
    display: none !important;
  }

  .login-form-head {
    margin-bottom: 24px;
  }

  .login-form-head h1 {
    font-size: 1.4rem;
  }
}

@media (max-width: 520px) {
  .login-brand-side {
    padding-top: max(28px, env(safe-area-inset-top));
    padding-bottom: 0;
  }

  .login-brand-headline {
    font-size: 1.2rem;
  }

  .login-brand-logo {
    width: 50px;
    height: 50px;
  }

  .login-form-side {
    border-radius: 24px 24px 0 0;
    padding: 28px 20px max(24px, env(safe-area-inset-bottom));
    margin-top: 24px;
  }

  .login-otp-input {
    font-size: 1.2rem !important;
    letter-spacing: 0.3em;
    padding: 14px !important;
  }
}

@media (max-width: 360px) {
  .login-form-side {
    padding: 24px 16px max(20px, env(safe-area-inset-bottom));
  }

  .login-btn {
    padding: 13px 16px;
    font-size: 0.9rem;
  }
}

/* ── Layout ── */
.app-shell {
  display: block;
  min-height: 100vh;
  min-height: 100dvh;
  min-height: -webkit-fill-available;
  max-width: 100%;
  overflow-x: hidden;
}

.sidebar {
  width: 256px;
  background: var(--card);
  border-left: 1px solid var(--border);
  display: grid;
  grid-template-rows: auto 1fr auto;
  position: fixed;
  top: 0;
  right: 0;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  z-index: 200;
  box-shadow: -4px 0 24px rgba(0, 0, 0, 0.04);
}

.mobile-topbar,
.sidebar-backdrop,
.sidebar-close-btn {
  display: none;
}

.mobile-topbar {
  align-items: center;
  gap: 12px;
  padding:
    max(10px, env(safe-area-inset-top))
    max(14px, env(safe-area-inset-right))
    10px
    max(14px, env(safe-area-inset-left));
  background: var(--card);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 450;
}

.mobile-menu-btn {
  width: 42px;
  height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s;
}

.mobile-menu-btn:hover {
  background: var(--primary-soft);
  color: var(--primary-dark);
}

.mobile-topbar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 1;
}

.mobile-topbar-logo {
  width: 32px;
  height: 32px;
  object-fit: contain;
  border-radius: 8px;
  flex-shrink: 0;
}

.mobile-topbar-title {
  font-weight: 700;
  font-size: 0.92rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-backdrop {
  position: fixed;
  inset: 0;
  z-index: 300;
  background: rgba(17, 24, 39, 0.45);
  backdrop-filter: blur(2px);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease;
}

.sidebar-backdrop.is-visible {
  opacity: 1;
  visibility: visible;
}

.sidebar-close-btn {
  margin-right: auto;
  width: 36px;
  height: 36px;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--muted);
  cursor: pointer;
  flex-shrink: 0;
}

.sidebar-close-btn:hover {
  background: var(--border);
  color: var(--text);
}

body.sidebar-open {
  overflow: hidden;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 0;
  padding: 22px 20px 16px;
  border-bottom: 1px solid var(--border);
  position: relative;
}

.sidebar-logo {
  width: 38px;
  height: 38px;
  object-fit: contain;
  border-radius: 10px;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(233, 30, 140, 0.18);
}

.sidebar-brand-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidebar-title {
  font-weight: 700;
  font-size: 0.95rem;
}

.sidebar-subtitle {
  font-size: 0.75rem;
  color: var(--muted);
}

.sidebar nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 0 10px 10px;
  min-height: 0;
}

.nav-section-label {
  display: block;
  padding: 14px 6px 5px;
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  opacity: 0.6;
  user-select: none;
}

.nav-section-label:first-child {
  padding-top: 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 500;
  transition: background 0.15s, color 0.15s, box-shadow 0.15s;
  min-width: 0;
  max-width: 100%;
  position: relative;
}

.nav-icon {
  width: 17px;
  height: 17px;
  flex-shrink: 0;
  opacity: 0.6;
  transition: opacity 0.15s;
}

.nav-item:hover {
  background: var(--bg);
  color: var(--text);
}

.nav-item:hover .nav-icon {
  opacity: 0.85;
}

.nav-item.active {
  background: var(--primary-light);
  color: var(--primary-dark);
  font-weight: 600;
}

.nav-item.active .nav-icon {
  opacity: 1;
}

.nav-item.active::before {
  content: '';
  position: absolute;
  left: -10px;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 60%;
  background: var(--primary);
  border-radius: 0 999px 999px 0;
}

.sidebar-footer {
  border-top: 1px solid var(--border);
  padding: 14px 14px calc(16px + env(safe-area-inset-bottom, 0px));
  background: var(--card);
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.85rem;
  color: var(--text);
  margin-bottom: 10px;
  padding: 8px 4px;
  border-radius: var(--radius);
  transition: background 0.15s ease;
}

a.user-chip {
  text-decoration: none;
}

a.user-chip:hover {
  background: var(--surface-2, rgba(255, 255, 255, 0.06));
}

a.user-chip.active {
  background: rgba(99, 102, 241, 0.12);
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  font-weight: 700;
  flex-shrink: 0;
  overflow: hidden;
}

.user-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

.main-content {
  margin-right: 256px;
  min-width: 0;
  width: calc(100% - 256px);
  max-width: 100%;
  padding: 32px 40px;
  overflow-x: hidden;
}

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 28px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--border);
}

.page-eyebrow {
  margin: 0 0 4px;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.page-header h1 {
  margin: 0 0 6px;
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
}

.page-desc,
.page-header p {
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.5;
}

.page-header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.page-header-actions .btn {
  white-space: nowrap;
}


/* ── Cards ── */
.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04), 0 4px 16px rgba(0,0,0,0.04);
  margin-bottom: 20px;
  border: 1px solid var(--border);
  max-width: 100%;
  overflow-wrap: anywhere;
  transition: box-shadow 0.18s, border-color 0.18s;
}

.card:hover {
  box-shadow: 0 2px 4px rgba(0,0,0,0.05), 0 8px 24px rgba(0,0,0,0.07);
}

.card h2 {
  margin: 0 0 4px;
  font-size: 1.05rem;
  font-weight: 600;
}

.response-style-card {
  padding: 0;
  overflow: hidden;
}

.response-style-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 22px;
  border: 0;
  background: transparent;
  cursor: pointer;
  text-align: right;
  font: inherit;
  color: inherit;
}

.response-style-toggle-copy {
  flex: 1;
  min-width: 0;
}

.response-style-title {
  margin: 0 0 4px;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
}

.response-style-sub {
  margin: 0;
  font-size: 0.84rem;
  color: var(--muted);
}

.response-style-chevron {
  flex-shrink: 0;
  color: var(--primary-dark);
  transition: transform 0.2s ease;
  font-size: 0.85rem;
}

.response-style-card.is-open .response-style-chevron {
  transform: rotate(180deg);
}

.response-style-panel {
  padding: 0 22px 22px;
  border-top: 1px solid var(--border);
}

.response-style-panel.hidden {
  display: none;
}

.response-style-hint {
  margin: 16px 0 12px;
  line-height: 1.75;
}

.response-style-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
}

.response-style-actions .btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.response-style-upload {
  cursor: pointer;
  margin: 0;
}

.response-guidelines-page {
  padding: 22px 24px 24px;
}

.response-guidelines-page .response-style-hint {
  margin-top: 0;
}

.response-guidelines-page .field-group {
  margin-top: 8px;
}

#guidelines-save-status.is-success {
  color: #047857;
}

#guidelines-save-status.is-error {
  color: var(--danger);
}

.ai-activation-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.ai-activation-section {
  padding: 20px 22px;
}

.ai-activation-section h2 {
  margin: 0 0 4px;
  font-size: 1rem;
}

.ai-activation-head {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 16px;
}

.ai-activation-icon {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  flex-shrink: 0;
  margin-top: 2px;
}

.ai-activation-icon--on {
  background: #d1fae5;
  color: #059669;
}

.ai-activation-icon--off {
  background: #fee2e2;
  color: #dc2626;
}

.ai-activation-section--on {
  border-color: rgba(16, 185, 129, 0.2);
}

.ai-activation-section--off {
  border-color: rgba(239, 68, 68, 0.18);
}

.ai-activation-list-head {
  display: flex;
  justify-content: flex-end;
  margin: 16px 0 8px;
}

.ai-activation-add-row {
  display: flex;
  gap: 10px;
  align-items: stretch;
}

.ai-activation-add-row input {
  flex: 1;
  min-width: 0;
}

.ai-activation-add-row .btn {
  flex-shrink: 0;
  min-width: 88px;
}

.ai-activation-section .paragraph-source {
  display: none;
}

.ai-activation-section .paragraph-meta {
  justify-content: flex-end;
}

.paragraphs-list-compact {
  gap: 8px;
}

.paragraphs-list-compact .paragraph-card {
  padding: 12px 14px;
}

.paragraphs-list-compact .paragraph-content {
  font-size: 0.92rem;
}

.paragraph-card[data-source="activate"] {
  border-right-color: #10b981;
}

.paragraph-card[data-source="deactivate"] {
  border-right-color: #ef4444;
}

.paragraph-source.source-activate {
  background: #d1fae5;
  color: #047857;
}

.paragraph-source.source-deactivate {
  background: #fee2e2;
  color: #b91c1c;
}

.section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.section-head h2 {
  margin: 0 0 4px;
}

.section-desc {
  margin: 0;
  font-size: 0.85rem;
  color: var(--muted);
}

.kb-badge {
  flex-shrink: 0;
  padding: 6px 14px;
  background: var(--primary-light);
  color: var(--primary-dark);
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
}

.kb-warn-banner {
  display: block;
  background: var(--warning-bg);
  border: 1px solid #fde68a;
  border-right: 4px solid var(--warning);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 12px;
  color: #92400e;
  font-size: 0.9rem;
  line-height: 1.55;
}
.kb-warn-banner:last-child {
  margin-bottom: 20px;
}
.kb-warn-banner.hidden {
  display: none;
}

.kb-list-toolbar {
  margin-bottom: 16px;
}

.kb-search {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  min-width: 0;
}

.kb-search svg {
  flex-shrink: 0;
  color: var(--muted);
}

.kb-search input {
  flex: 1;
  min-width: 0;
  border: none;
  background: transparent;
  padding: 12px 0;
  font-size: 0.95rem;
  font-family: var(--font);
}

.kb-search input:focus {
  outline: none;
  box-shadow: none;
}

.kb-search-clear {
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 999px;
  background: var(--border);
  color: var(--muted);
  cursor: pointer;
  flex-shrink: 0;
  line-height: 1;
  font-size: 1.1rem;
}

.kb-search-clear:hover {
  background: var(--primary-light);
  color: var(--primary-dark);
}

.kb-pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
}

.kb-pagination-info {
  font-size: 0.85rem;
  color: var(--muted);
}

.kb-pagination-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.kb-pagination .btn {
  min-width: 88px;
}

.card-icon-head {
  display: flex;
  gap: 14px;
  margin-bottom: 20px;
}

.card-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--primary-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  flex-shrink: 0;
}

/* ── Form fields ── */
.field-group {
  margin-bottom: 16px;
}

.field-label {
  display: block;
  margin-bottom: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
}

.field-hint {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.5;
}

.crawl-progress {
  margin: 16px 0;
  padding: 16px;
  background: var(--primary-soft);
  border: 1px solid var(--primary-light);
  border-radius: var(--radius-sm);
}

.crawl-status-card {
  background: linear-gradient(135deg, #fff 0%, var(--primary-soft) 100%);
  border: 1px solid rgba(233, 30, 140, 0.18);
  border-radius: var(--radius);
  padding: 20px 22px;
  margin-bottom: 20px;
  box-shadow: 0 8px 32px rgba(233, 30, 140, 0.1);
  text-align: center;
  scroll-margin-top: 16px;
}

.crawl-status-top {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 14px;
}

.crawl-status-pulse {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--primary);
  margin-top: 0;
  flex-shrink: 0;
  animation: crawl-pulse 1.2s ease-in-out infinite;
}

@keyframes crawl-pulse {
  0%, 100% { opacity: 1; transform: scale(1); box-shadow: 0 0 0 0 rgba(233, 30, 140, 0.45); }
  50% { opacity: 0.75; transform: scale(0.92); box-shadow: 0 0 0 8px rgba(233, 30, 140, 0); }
}

.crawl-status-copy {
  width: 100%;
  max-width: 520px;
}

.crawl-status-title {
  margin: 0 0 4px;
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  word-break: break-word;
  text-align: center;
}

.crawl-status-sub {
  margin: 0;
  font-size: 0.82rem;
  color: var(--muted);
  text-align: center;
}

.crawl-status-pct {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--primary-dark);
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}

.crawl-status-bar {
  margin-bottom: 16px;
  height: 10px;
}

.crawl-status-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.crawl-stat {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  direction: rtl;
  background: rgba(255, 255, 255, 0.85);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  text-align: right;
  min-width: 0;
}

.crawl-stat-label {
  flex: 1;
  font-size: 0.72rem;
  color: var(--muted);
  text-align: right;
}

.crawl-stat-value {
  flex-shrink: 0;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  direction: rtl;
  unicode-bidi: plaintext;
  text-align: right;
}

.crawl-stat-clock {
  direction: ltr;
  unicode-bidi: isolate;
  text-align: right;
}

.crawl-status-detail {
  margin: 0 0 6px;
  font-size: 0.84rem;
  color: var(--text);
  line-height: 1.5;
  text-align: center;
}

.crawl-status-actions {
  display: flex;
  justify-content: center;
  margin-top: 14px;
}

.crawl-cancel-btn {
  min-width: 140px;
}

.crawl-status-hint {
  margin: 0;
  font-size: 0.78rem;
  color: var(--muted);
  text-align: center;
}

.crawl-progress-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.crawl-progress-pct {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--primary-dark);
  flex-shrink: 0;
}

.crawl-progress-msg {
  font-size: 0.85rem;
  color: var(--text);
  text-align: left;
  line-height: 1.4;
}

.crawl-progress-bar {
  height: 8px;
  background: rgba(255, 255, 255, 0.7);
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid var(--primary-light);
}

.crawl-progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--primary), var(--primary-dark));
  border-radius: 999px;
  transition: width 0.4s ease;
}

.crawl-progress-url {
  margin: 10px 0 0;
  font-size: 0.75rem;
  color: var(--muted);
  word-break: break-all;
  direction: ltr;
  text-align: left;
}

.crawl-progress-hint {
  margin: 8px 0 0;
  font-size: 0.75rem;
  color: var(--muted);
}

input[type="text"],
input[type="tel"],
input[type="url"],
textarea {
  width: 100%;
  max-width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 0.95rem;
  background: #fff;
  transition: border-color 0.15s, box-shadow 0.15s;
  color: var(--text);
}

input:focus,
textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(233, 30, 140, 0.12);
}

textarea {
  resize: vertical;
  min-height: 120px;
  line-height: 1.7;
}

.input-with-icon {
  position: relative;
}

.input-with-icon svg {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  pointer-events: none;
}

.input-with-icon input {
  padding-right: 42px;
}

/* ── Dropzone ── */
.dropzone {
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius);
  padding: 32px 24px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s, transform 0.15s;
  background: var(--bg);
  margin-bottom: 16px;
}

.dropzone:hover,
.dropzone:focus-visible {
  border-color: var(--primary);
  background: var(--primary-soft);
  outline: none;
}

.dropzone.dragover {
  border-color: var(--primary);
  background: var(--primary-light);
  transform: scale(1.005);
}

.dropzone.has-file {
  border-color: var(--primary);
  border-style: solid;
  background: var(--primary-soft);
}

.dropzone-compact {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  text-align: center;
  padding: 20px;
}

.dropzone-compact .dropzone-icon {
  margin: 0 auto;
}

.dropzone-icon {
  width: 64px;
  height: 64px;
  margin: 0 auto 12px;
  border-radius: 50%;
  background: var(--card);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--primary);
  box-shadow: var(--shadow);
}

.dropzone-icon.sm {
  width: 48px;
  height: 48px;
  margin: 0;
  flex-shrink: 0;
}

.dropzone-title {
  margin: 0 0 4px;
  font-weight: 600;
  font-size: 0.95rem;
}

.dropzone-sub {
  margin: 0;
  font-size: 0.82rem;
  color: var(--muted);
}

.dropzone-filename {
  margin: 12px 0 0;
  padding: 8px 14px;
  background: var(--card);
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--primary-dark);
  display: inline-block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dropzone-compact .dropzone-filename {
  margin: 8px 0 0;
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 20px;
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s, background 0.15s, box-shadow 0.15s;
  white-space: nowrap;
}

.btn:active:not(:disabled) {
  transform: scale(0.98);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn.is-loading {
  pointer-events: none;
  opacity: 0.85;
  position: relative;
}

.btn-spinner {
  display: inline-block;
  width: 15px;
  height: 15px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: btn-spin 0.65s linear infinite;
  vertical-align: -3px;
  margin-left: 8px;
}

.btn-secondary.is-loading .btn-spinner,
.btn-outline.is-loading .btn-spinner,
.btn-ghost.is-loading .btn-spinner {
  border-color: rgba(233, 30, 140, 0.22);
  border-top-color: var(--primary);
}

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

.btn-block {
  width: 100%;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: #fff;
  box-shadow: 0 2px 8px rgba(233, 30, 140, 0.25), 0 1px 2px rgba(233, 30, 140, 0.15);
}

.btn-primary:hover:not(:disabled) {
  box-shadow: 0 4px 16px rgba(233, 30, 140, 0.35), 0 2px 4px rgba(233, 30, 140, 0.2);
  opacity: 0.95;
}

.btn-secondary {
  background: var(--primary-light);
  color: var(--primary-dark);
}

.btn-secondary:hover:not(:disabled) {
  background: #f9d0ea;
}

.btn-outline {
  background: transparent;
  border: 1.5px solid var(--primary);
  color: var(--primary);
  padding: 10px 18px;
}

.btn-outline:hover:not(:disabled) {
  background: var(--primary-soft);
}

.btn-ghost {
  background: transparent;
  color: var(--muted);
}

.btn-ghost:hover:not(:disabled) {
  background: var(--bg);
  color: var(--text);
}

.btn-ghost.sm {
  padding: 7px 14px;
  font-size: 0.82rem;
}

.btn-danger {
  background: linear-gradient(135deg, #ef4444, #dc2626);
  color: #fff;
  box-shadow: 0 4px 14px rgba(220, 38, 38, 0.28);
}

.btn-danger:hover:not(:disabled) {
  box-shadow: 0 6px 20px rgba(220, 38, 38, 0.34);
}

/* ── Ingest panel ── */
.ingest-panel {
  padding: 0;
  overflow: hidden;
}

.ingest-panel-head {
  padding: 24px 24px 0;
}

.ingest-panel-head h2 {
  margin: 0 0 4px;
}

.ingest-panel-head p {
  margin: 0 0 20px;
  color: var(--muted);
  font-size: 0.88rem;
}

.ingest-tabs {
  display: flex;
  gap: 6px;
  margin: 0 24px 20px;
  padding: 5px;
  background: var(--bg);
  border-radius: 12px;
  border: 1px solid var(--border);
}

.tab {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 12px;
  border: none;
  border-radius: 8px;
  background: transparent;
  font-family: var(--font);
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--muted);
  transition: background 0.15s, color 0.15s, box-shadow 0.15s;
}

.tab:hover {
  color: var(--text);
}

.tab.active {
  background: var(--card);
  color: var(--primary-dark);
  font-weight: 600;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}

.tab-panel {
  display: none;
  padding: 0 24px 24px;
}

.tab-panel.active {
  display: block;
}

.tab-panel .btn {
  margin-top: 4px;
}

.ingest-tab-hint {
  margin: 12px 0 0;
}

/* ── Voice recorder (compact) ── */
.voice-recorder-box {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.voice-recorder-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.voice-mic-btn {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(145deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  box-shadow: 0 4px 14px rgba(233, 30, 140, 0.25);
}

.voice-mic-btn:hover {
  transform: scale(1.04);
}

.voice-mic-btn:active {
  transform: scale(0.96);
}

.voice-recorder-box.is-recording .voice-mic-btn {
  background: linear-gradient(145deg, #f87171 0%, #dc2626 100%);
  box-shadow: 0 4px 14px rgba(239, 68, 68, 0.35);
}

.voice-mic-icon {
  display: flex;
  align-items: center;
  justify-content: center;
}

.voice-recorder-box.is-recording .voice-mic-icon--record {
  display: none;
}

.voice-recorder-box.is-recording .voice-mic-icon--stop {
  display: flex !important;
}

.voice-recorder-meta {
  flex: 1;
  min-width: 0;
}

.voice-recorder-status {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 2px;
}

.voice-state-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 999px;
  background: #fff;
  color: var(--primary-dark);
  font-size: 0.72rem;
  font-weight: 700;
  border: 1px solid var(--primary-light);
}

.voice-state-badge::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--primary);
}

.voice-recorder-box.is-recording .voice-state-badge {
  background: #fff5f5;
  color: #b91c1c;
  border-color: #fecaca;
}

.voice-recorder-box.is-recording .voice-state-badge::before {
  background: #ef4444;
  animation: pulse-rec 1s infinite;
}

.voice-recorder-box.is-ready .voice-state-badge {
  background: #ecfdf5;
  color: #047857;
  border-color: #a7f3d0;
}

.voice-recorder-box.is-ready .voice-state-badge::before {
  background: #10b981;
}

.voice-recorder-time {
  font-size: 1rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  line-height: 1;
}

.voice-recorder-box.is-recording .voice-recorder-time {
  color: #b91c1c;
}

.voice-recorder-hint {
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.45;
}

.voice-waveform {
  display: none;
  align-items: flex-end;
  gap: 3px;
  height: 18px;
  margin-top: 6px;
}

.voice-recorder-box.is-recording .voice-waveform {
  display: flex;
}

.voice-waveform span {
  width: 3px;
  height: 8px;
  border-radius: 999px;
  background: linear-gradient(180deg, #f472b6, var(--primary));
  animation: voice-wave-bar 0.9s ease-in-out infinite;
}

.voice-recorder-box.is-recording .voice-waveform span:nth-child(1) { animation-delay: 0s; }
.voice-recorder-box.is-recording .voice-waveform span:nth-child(2) { animation-delay: 0.1s; }
.voice-recorder-box.is-recording .voice-waveform span:nth-child(3) { animation-delay: 0.2s; }
.voice-recorder-box.is-recording .voice-waveform span:nth-child(4) { animation-delay: 0.15s; }
.voice-recorder-box.is-recording .voice-waveform span:nth-child(5) { animation-delay: 0.05s; }
.voice-recorder-box.is-recording .voice-waveform span:nth-child(6) { animation-delay: 0.25s; }

@keyframes voice-wave-bar {
  0%, 100% { height: 6px; opacity: 0.55; }
  50% { height: 16px; opacity: 1; }
}

.voice-send-btn {
  flex-shrink: 0;
  min-width: 72px;
  padding-inline: 16px;
  white-space: nowrap;
}

.voice-send-btn:disabled {
  opacity: 0.45;
}

.voice-preview-wrap {
  padding: 8px 10px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.voice-preview {
  width: 100%;
  height: 32px;
}

.voice-upload-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--border);
}

.voice-dropzone-compact {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--card);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  color: var(--muted);
  font-size: 0.82rem;
}

.voice-dropzone-compact:hover,
.voice-dropzone-compact:focus-visible,
.voice-dropzone-compact.dragover {
  border-color: var(--primary);
  background: var(--primary-soft);
  color: var(--primary-dark);
}

.voice-dropzone-compact.has-file {
  border-style: solid;
  border-color: var(--primary-light);
}

.voice-dropzone-compact.has-file .voice-dropzone-label {
  display: none;
}

.voice-dropzone-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.voice-file-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text);
  font-size: 0.8rem;
  font-weight: 500;
}

.voice-upload-btn {
  flex-shrink: 0;
  white-space: nowrap;
}

.voice-tab-hint {
  margin: 0;
  font-size: 0.78rem;
  text-align: right;
}

@keyframes pulse-rec {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.45; transform: scale(0.85); }
}

/* ── Paragraphs ── */
#guidelines-list .paragraph-card {
  border-right-color: #7c3aed;
}

#guidelines-list .paragraph-card[data-source="manual"] {
  border-right-color: #7c3aed;
}

#guidelines-list .paragraph-card[data-source="text"] {
  border-right-color: #10b981;
}

#guidelines-list .paragraph-card[data-source="voice"] {
  border-right-color: #8b5cf6;
}

.paragraphs-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.paragraph-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px 18px;
  background: var(--card);
  transition: border-color 0.15s, box-shadow 0.15s;
  border-right: 3px solid var(--border-strong);
}

.paragraph-card:hover {
  border-color: var(--border-strong);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.paragraph-card[data-source="pdf"] { border-right-color: #f59e0b; }
.paragraph-card[data-source="crawl"] { border-right-color: #3b82f6; }
.paragraph-card[data-source="voice"] { border-right-color: #8b5cf6; }
.paragraph-card[data-source="text"] { border-right-color: #10b981; }
.paragraph-card[data-source="docx"] { border-right-color: #2563eb; }
.paragraph-card[data-source="manual"] { border-right-color: var(--muted); }

.paragraph-card.editing {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(233, 30, 140, 0.1);
}

.paragraph-textarea {
  width: 100%;
  min-height: 100px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 0.9rem;
  line-height: 1.7;
  resize: vertical;
}

.paragraph-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  gap: 12px;
}

.paragraph-source {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--bg);
  color: var(--muted);
}

.paragraph-source.source-pdf { background: #fef3c7; color: #b45309; }
.paragraph-source.source-crawl { background: #dbeafe; color: #1d4ed8; }
.paragraph-source.source-voice { background: #ede9fe; color: #6d28d9; }
.paragraph-source.source-text { background: #d1fae5; color: #047857; }
.paragraph-source.source-docx { background: #dbeafe; color: #1e40af; }

.paragraph-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.paragraph-actions button {
  padding: 5px 12px;
  border: none;
  border-radius: 6px;
  font-family: var(--font);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
}

.paragraph-actions button:hover {
  opacity: 0.85;
}

.btn-edit {
  background: var(--primary-light);
  color: var(--primary-dark);
}

.btn-delete {
  background: var(--danger-bg);
  color: var(--danger);
}

.paragraph-content {
  font-size: 0.9rem;
  white-space: pre-wrap;
  line-height: 1.75;
  color: var(--text);
  overflow-wrap: anywhere;
  word-break: break-word;
}

.paragraph-page-link,
.paragraph-page-label {
  display: inline-block;
  font-size: 0.82rem;
  font-weight: 600;
  margin-bottom: 6px;
}

.paragraph-page-link {
  color: #1d4ed8;
  text-decoration: none;
  cursor: pointer;
}

.paragraph-page-link:hover {
  text-decoration: underline;
}

.paragraph-page-label {
  color: var(--muted);
}

.empty-state {
  text-align: center;
  color: var(--muted);
  padding: 48px 24px;
  background: var(--bg);
  border-radius: var(--radius-sm);
  border: 1px dashed var(--border);
  font-size: 0.9rem;
}

.hint {
  color: var(--muted);
  font-size: 0.85rem;
  margin: 0 0 12px;
}

.copy-row {
  display: flex;
  gap: 10px;
  max-width: 100%;
  min-width: 0;
}

.copy-row input {
  flex: 1;
  min-width: 0;
  max-width: 100%;
  background: var(--bg);
  overflow: hidden;
  text-overflow: ellipsis;
}

.copy-row .btn {
  flex-shrink: 0;
}

.status-msg {
  margin-top: 14px;
  padding: 10px 14px;
  font-size: 0.85rem;
  color: var(--success);
  background: #ecfdf5;
  border-radius: var(--radius-sm);
}

.card-icon.card-icon-avatar {
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff;
  font-size: 1.1rem;
  font-weight: 700;
  overflow: hidden;
}

.card-icon.card-icon-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

.webhook-log-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.webhook-log-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 520px;
  overflow: auto;
}

.webhook-log-item {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  background: #fafafa;
}

.webhook-log-head {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  align-items: center;
  margin-bottom: 8px;
}

.webhook-log-time {
  font-size: 0.82rem;
  color: var(--text-muted);
}

.webhook-log-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
}

.webhook-log-badge.is-ok {
  color: #166534;
  background: #dcfce7;
}

.webhook-log-badge.is-warn {
  color: #92400e;
  background: #fef3c7;
}

.webhook-log-badge.is-error {
  color: #991b1b;
  background: #fee2e2;
}

.webhook-log-meta {
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.7;
}

.webhook-log-detail {
  margin-top: 8px;
  padding: 10px;
  border-radius: var(--radius-sm);
  background: #fff;
  border: 1px dashed var(--border);
  font-size: 0.8rem;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: anywhere;
  overflow-x: auto;
  max-width: 100%;
}

.webhook-log-empty {
  padding: 16px;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.88rem;
}

/* ── Modal ── */
body.modal-open {
  overflow: hidden;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding:
    max(16px, env(safe-area-inset-top))
    max(16px, env(safe-area-inset-right))
    max(16px, env(safe-area-inset-bottom))
    max(16px, env(safe-area-inset-left));
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.modal:not(.hidden) {
  pointer-events: auto;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  z-index: 0;
  background: rgba(17, 24, 39, 0.55);
  backdrop-filter: blur(4px);
}

.modal-card {
  position: relative;
  z-index: 1;
  background: var(--card);
  border-radius: var(--radius);
  width: 100%;
  max-width: 540px;
  max-height: calc(100dvh - 32px);
  max-height: calc(100vh - 32px);
  margin: auto;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
}

.modal-card-wide {
  max-width: 680px;
}


.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 22px 24px;
  border-bottom: 1px solid var(--border);
}

.modal-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.chat-empty-state {
  margin: auto;
  max-width: 320px;
  text-align: center;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.7;
  padding: 24px 12px;
}

.modal-header h2 {
  margin: 0 0 2px;
  font-size: 1.1rem;
}

.modal-sub {
  margin: 0;
  font-size: 0.82rem;
  color: var(--muted);
}

.icon-btn {
  width: 36px;
  height: 36px;
  border: none;
  background: var(--bg);
  border-radius: var(--radius-sm);
  font-size: 1.3rem;
  cursor: pointer;
  line-height: 1;
  color: var(--muted);
  flex-shrink: 0;
  transition: background 0.15s;
}

.icon-btn:hover {
  background: var(--border);
  color: var(--text);
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px;
  min-height: 300px;
  max-height: 52vh;
  background: var(--bg);
}

.chat-bubble {
  max-width: 82%;
  padding: 12px 16px;
  border-radius: 16px;
  margin-bottom: 12px;
  font-size: 0.9rem;
  white-space: pre-wrap;
  line-height: 1.6;
}

.chat-bubble.user {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff;
  margin-right: auto;
  border-bottom-right-radius: 4px;
}

.chat-bubble.ai {
  background: var(--card);
  border: 1px solid var(--border);
  margin-left: auto;
  border-bottom-left-radius: 4px;
}

.chat-bubble.loading {
  color: var(--muted);
  font-style: italic;
  background: transparent;
  border: none;
}

.chat-input {
  display: flex;
  gap: 10px;
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  background: var(--card);
}

.chat-input input {
  flex: 1;
  min-width: 0;
}

.chat-voice-btn,
.chat-attach-btn {
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.chat-voice-btn:hover,
.chat-attach-btn:hover {
  background: var(--card);
  border-color: var(--primary);
  color: var(--primary);
}

.chat-voice-btn.is-recording {
  background: rgba(239, 68, 68, 0.12);
  border-color: #ef4444;
  color: #ef4444;
}

.chat-voice-btn:disabled,
.chat-attach-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.chat-voice-icon.hidden {
  display: none;
}

.chat-bubble.user.loading {
  opacity: 0.75;
  font-style: italic;
}

/* ── App dialog (success / error / confirm / info) ── */
.app-dialog {
  position: fixed;
  inset: 0;
  z-index: 10050;
  display: flex;
  align-items: center;
  justify-content: center;
  padding:
    max(16px, env(safe-area-inset-top))
    max(16px, env(safe-area-inset-right))
    max(16px, env(safe-area-inset-bottom))
    max(16px, env(safe-area-inset-left));
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.app-dialog.hidden {
  display: none;
}

.app-dialog-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(17, 24, 39, 0.58);
  backdrop-filter: blur(6px);
  animation: app-dialog-fade-in 0.25s ease;
}

.app-dialog-card {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 400px;
  margin: auto;
  flex-shrink: 0;
  padding: 32px 28px 24px;
  text-align: center;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) + 4px);
  box-shadow: 0 24px 64px rgba(17, 24, 39, 0.22);
  animation: app-dialog-pop 0.38s cubic-bezier(0.22, 1, 0.36, 1);
}

.app-dialog.is-success .app-dialog-card {
  background: linear-gradient(180deg, #ffffff 0%, #f0fdf8 100%);
}

.app-dialog.is-error .app-dialog-card {
  background: linear-gradient(180deg, #ffffff 0%, #fff5f5 100%);
}

.app-dialog.is-warning .app-dialog-card {
  background: linear-gradient(180deg, #ffffff 0%, #fffbeb 100%);
}

.app-dialog.is-info .app-dialog-card {
  background: linear-gradient(180deg, #ffffff 0%, #f5f3ff 100%);
}

.app-dialog-icon-wrap {
  margin-bottom: 18px;
}

.app-dialog-icon {
  width: 76px;
  height: 76px;
  margin: 0 auto;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: app-dialog-icon-pop 0.45s cubic-bezier(0.22, 1, 0.36, 1) 0.08s both;
}

.app-dialog.is-success .app-dialog-icon {
  background: linear-gradient(135deg, #ecfdf5 0%, #a7f3d0 100%);
  color: var(--success);
  box-shadow: 0 10px 28px rgba(5, 150, 105, 0.22);
}

.app-dialog.is-error .app-dialog-icon {
  background: linear-gradient(135deg, #fef2f2 0%, #fecaca 100%);
  color: #dc2626;
  box-shadow: 0 10px 28px rgba(220, 38, 38, 0.18);
}

.app-dialog.is-warning .app-dialog-icon {
  background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
  color: #d97706;
  box-shadow: 0 10px 28px rgba(217, 119, 6, 0.18);
}

.app-dialog.is-info .app-dialog-icon {
  background: linear-gradient(135deg, #ede9fe 0%, #ddd6fe 100%);
  color: #7c3aed;
  box-shadow: 0 10px 28px rgba(124, 58, 237, 0.16);
}

.app-dialog-icon svg {
  width: 38px;
  height: 38px;
}

.app-dialog-title {
  margin: 0 0 8px;
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text);
}

.app-dialog-message {
  margin: 0;
  color: var(--muted);
  line-height: 1.7;
  font-size: 0.95rem;
}

.app-dialog-detail {
  margin: 14px 0 0;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.72);
  border: 1px dashed var(--border);
  color: var(--text);
  font-size: 0.85rem;
  line-height: 1.65;
  text-align: right;
}

.app-dialog-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-top: 22px;
  flex-wrap: wrap;
}

.app-dialog-btn {
  min-width: 120px;
}

@keyframes app-dialog-fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes app-dialog-pop {
  from {
    opacity: 0;
    transform: scale(0.9) translateY(12px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

@keyframes app-dialog-icon-pop {
  from {
    opacity: 0;
    transform: scale(0.5);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* ── AI Comments page ── */
.aic-posts-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  background: var(--border);
}

.aic-post-card {
  display: flex;
  flex-direction: column;
  background: var(--card);
  border: none;
  padding: 0;
  cursor: pointer;
  text-align: right;
  font: inherit;
  color: inherit;
  transition: background 0.15s;
  min-width: 0;
}

.aic-post-card:hover {
  background: var(--primary-soft);
}

.aic-post-card--active .aic-post-thumb {
  outline: 3px solid var(--primary);
  outline-offset: -3px;
}

.aic-post-thumb {
  width: 100%;
  aspect-ratio: 1;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.aic-post-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.aic-post-thumb-lg {
  width: 72px;
  height: 72px;
  border-radius: var(--radius-sm);
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
  position: relative;
}

.aic-post-thumb-lg .aic-post-img {
  border-radius: var(--radius-sm);
}

.aic-post-active-badge {
  position: absolute;
  bottom: 6px;
  right: 6px;
  background: var(--primary);
  color: #fff;
  font-size: 0.68rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 999px;
}

.aic-post-info {
  padding: 10px 12px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.aic-post-caption {
  margin: 0;
  font-size: 0.82rem;
  font-weight: 500;
  line-height: 1.5;
  color: var(--text);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.aic-post-meta {
  margin: 0;
  font-size: 0.75rem;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 4px;
}

.aic-post-caption-preview {
  margin: 0;
  font-size: 0.9rem;
  line-height: 1.6;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Toggle switch */
.aic-toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.aic-toggle-copy {
  flex: 1;
  min-width: 0;
}

.aic-toggle-copy strong {
  display: block;
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 2px;
}

.aic-toggle-copy p {
  margin: 0;
  font-size: 0.82rem;
  color: var(--muted);
}

.aic-toggle-label {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  cursor: pointer;
}

.aic-toggle-input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.aic-toggle-track {
  width: 46px;
  height: 26px;
  border-radius: 999px;
  background: var(--border-strong);
  position: relative;
  transition: background 0.2s;
  display: block;
}

.aic-toggle-input:checked + .aic-toggle-track {
  background: var(--primary);
}

.aic-toggle-thumb {
  position: absolute;
  top: 3px;
  right: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,0.2);
  transition: transform 0.2s;
}

.aic-toggle-input:checked + .aic-toggle-track .aic-toggle-thumb {
  transform: translateX(-20px);
}

/* Reply channel selector */
.aic-channel-group {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.aic-channel-option {
  cursor: pointer;
}

.aic-channel-option input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.aic-channel-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 14px 10px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--muted);
  text-align: center;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
}

.aic-channel-option input:checked + .aic-channel-card {
  border-color: var(--primary);
  background: var(--primary-soft);
  color: var(--primary-dark);
}

.aic-channel-card:hover {
  border-color: var(--primary);
}

.aic-instructions-preview {
  margin: 0;
  flex: 1;
  font-size: 0.85rem;
  font-family: var(--font);
  white-space: pre-wrap;
  line-height: 1.65;
  color: var(--text);
  overflow-wrap: anywhere;
}

/* ── Responsive ── */
@media (max-width: 768px) {
  .app-shell {
    --mobile-topbar-h: calc(52px + env(safe-area-inset-top, 0px));
  }

  .mobile-topbar {
    display: flex;
  }

  .sidebar-backdrop {
    display: block;
    top: var(--mobile-topbar-h, 58px);
  }

  .sidebar-close-btn {
    display: inline-flex;
  }

  .auth-card {
    padding: 28px 20px;
  }

  .input-otp {
    letter-spacing: 0.2em;
    font-size: 16px !important;
  }

  input[type="text"],
  input[type="tel"],
  input[type="url"],
  textarea {
    font-size: 16px;
  }

  .btn,
  .mobile-menu-btn,
  .icon-btn,
  .tab {
    touch-action: manipulation;
  }

  #test-modal {
    padding: 12px;
    align-items: center;
    justify-content: center;
    touch-action: manipulation;
  }

  #test-modal .modal-card {
    width: 100%;
    max-width: 100%;
    height: auto;
    max-height: min(88dvh, calc(100svh - 24px));
    border-radius: var(--radius);
    border: 1px solid var(--border);
    margin: 0;
    box-shadow: var(--shadow-lg);
    min-height: 0;
  }

  #test-modal.test-modal-viewport-fit {
    position: fixed;
    inset: auto;
    z-index: 10000;
    padding: 8px;
    overflow: hidden;
    align-items: center;
    justify-content: center;
  }

  #test-modal.test-modal-viewport-fit .modal-card {
    flex: 0 1 auto;
    width: 100%;
    max-height: 100%;
  }

  #test-modal .chat-messages {
    flex: 1;
    min-height: 120px;
    max-height: none;
  }

  #test-modal .chat-input {
    flex-wrap: nowrap;
    gap: 8px;
    padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
    flex-shrink: 0;
  }

  #test-modal .chat-input input,
  #test-input {
    flex: 1 1 auto;
    min-width: 0;
    font-size: 16px !important;
    transform: scale(1);
  }

  #test-modal .chat-input .btn-primary {
    flex-shrink: 0;
    min-width: 68px;
    padding: 10px 12px;
  }

  #btn-open-test {
    touch-action: manipulation;
  }

  .modal-card,
  .modal-card-wide {
    max-width: 100%;
    max-height: none;
  }

  .modal-header {
    flex-direction: column;
    align-items: stretch;
    padding: 18px 16px;
  }

  .modal-header-actions {
    width: 100%;
    justify-content: flex-end;
  }

  .chat-messages {
    min-height: 160px;
    max-height: min(50dvh, calc(100dvh - 240px));
    max-height: min(50vh, calc(100vh - 240px));
    padding: 16px;
  }

  .chat-input {
    flex-wrap: nowrap;
    padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  }

  .chat-input input {
    flex: 1 1 auto;
    min-width: 0;
    font-size: 16px;
  }

  .chat-bubble {
    max-width: 92%;
  }

  .app-dialog-card {
    padding: 24px 20px 20px;
  }

  .sidebar {
    top: var(--mobile-topbar-h, 58px);
    right: 0;
    bottom: 0;
    height: auto;
    width: min(288px, 88vw);
    max-width: none;
    z-index: 400;
    transform: translateX(100%);
    transition: transform 0.24s ease;
    border-left: 1px solid var(--border);
    border-bottom: none;
    overflow: hidden;
    overscroll-behavior: contain;
    padding: 0;
    box-shadow: -8px 0 32px rgba(0, 0, 0, 0.12);
  }

  .sidebar.is-open {
    transform: translateX(0);
  }

  .sidebar nav {
    flex-direction: column;
    flex-wrap: nowrap;
    width: 100%;
  }

  .sidebar-footer {
    padding-bottom: max(20px, env(safe-area-inset-bottom));
  }

  .sidebar-brand {
    padding-top: max(20px, env(safe-area-inset-top));
  }

  .nav-item {
    flex: none;
    width: 100%;
    font-size: 0.88rem;
    padding: 12px 14px;
  }

  .nav-item.active::before {
    display: none;
  }

  .nav-section-label {
    padding: 12px 8px 4px;
    font-size: 0.65rem;
  }

  .sidebar-brand {
    margin-bottom: 0;
    padding: max(20px, env(safe-area-inset-top)) 16px 16px;
  }

  .sidebar-brand-text {
    min-width: 0;
    flex: 1;
  }

  .sidebar-title,
  .sidebar-subtitle {
    overflow-wrap: anywhere;
  }

  .main-content {
    margin-right: 0;
    width: 100%;
    padding: 16px 14px max(20px, env(safe-area-inset-bottom));
    padding-top: calc(var(--mobile-topbar-h, 58px) + 16px);
    max-width: 100%;
  }

  .page-header {
    flex-direction: column;
    gap: 14px;
    margin-bottom: 20px;
    padding-bottom: 16px;
  }

  .page-header h1 {
    font-size: 1.3rem;
  }

  .page-desc,
  .page-header p {
    font-size: 0.85rem;
  }

  .page-header > .btn,
  .page-header-actions {
    width: 100%;
  }

  .page-header > .btn,
  .page-header-actions .btn {
    width: 100%;
    white-space: normal;
    justify-content: center;
  }

  .card {
    padding: 18px 16px;
  }

  .card-icon-head {
    align-items: flex-start;
  }

  .card-icon-head > div {
    min-width: 0;
  }

  .copy-row {
    flex-direction: column;
    align-items: stretch;
  }

  .copy-row .btn {
    width: 100%;
  }

  .ingest-panel-head {
    padding: 18px 16px 0;
  }

  .ingest-tabs {
    flex-wrap: wrap;
    margin: 0 16px 16px;
  }

  .tab {
    flex: 1 1 45%;
    min-width: 0;
    font-size: 0.78rem;
    padding: 9px 8px;
  }

  .tab-panel {
    padding: 0 16px 18px;
  }

  .section-head {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }

  .kb-search input {
    font-size: 16px;
  }

  .kb-pagination {
    flex-direction: column;
    align-items: stretch;
  }

  .kb-pagination-actions {
    width: 100%;
  }

  .kb-pagination-actions .btn {
    flex: 1;
  }

  .paragraph-meta {
    flex-wrap: wrap;
  }

  .paragraph-actions {
    width: 100%;
    justify-content: flex-end;
  }

  .ai-activation-grid {
    grid-template-columns: 1fr;
  }

  .ai-activation-section {
    padding: 16px;
  }

  .ai-activation-add-row {
    flex-direction: column;
  }

  .ai-activation-add-row .btn {
    width: 100%;
  }

  .voice-recorder-row {
    flex-wrap: wrap;
  }

  .voice-send-btn {
    width: 100%;
  }

  .voice-upload-row {
    flex-direction: column;
    align-items: stretch;
  }

  .voice-upload-btn {
    width: 100%;
  }

  .crawl-status-card {
    padding: 16px;
  }

  .crawl-status-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .crawl-stat {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
  }

  .response-style-actions {
    flex-direction: column;
  }

  .response-style-actions .btn,
  .response-style-upload {
    width: 100%;
    justify-content: center;
  }

  .webhook-log-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .webhook-log-toolbar .btn {
    width: 100%;
  }

  .webhook-log-list {
    max-height: min(55dvh, 420px);
  }

  .webhook-log-head {
    flex-direction: column;
    align-items: flex-start;
  }

  /* ── Action button rows ── */
  .page-action-row {
    flex-direction: column;
  }

  .page-action-row .btn {
    width: 100%;
    justify-content: center;
  }

  /* ── Back buttons ── */
  #aic-back-btn {
    font-size: 0.88rem;
  }

  /* ── Ingest tabs inside padded cards ── */
  .card .ingest-tabs {
    margin-left: 0;
    margin-right: 0;
  }

  /* ── Card list header ── */
  .card-list-header {
    padding: 16px;
    gap: 10px;
  }

  /* ── AI Comments posts grid ── */
  .aic-post-info {
    padding: 8px 10px;
  }

  .aic-post-caption {
    font-size: 0.78rem;
    -webkit-line-clamp: 1;
  }

  /* ── AI Comments preview card ── */
  .aic-preview-card-inner {
    padding: 14px 16px;
    gap: 12px;
  }

  .aic-preview-badge {
    display: none;
  }

  /* ── Story active configs list edit/delete buttons ── */
  .paragraph-card .paragraph-actions {
    flex-wrap: wrap;
  }

  /* ── Instagram action row ── */
  .ig-action-row {
    flex-direction: column;
  }

  .ig-action-row .btn,
  .ig-action-row a.btn {
    width: 100%;
    justify-content: center;
    text-align: center;
  }

  /* ── Story preview card ── */
  .ais-preview-card-inner {
    padding: 14px 16px;
    gap: 12px;
  }

  .ais-preview-story {
    width: 56px;
  }

  /* ── AIC channel group on mobile ── */
  .aic-channel-group {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  /* ── AI activation add row ── */
  .ai-activation-add-row {
    gap: 8px;
  }

  /* ── Tab panels ── */
  #panel-aic-text,
  #panel-aic-voice,
  #panel-aic-file,
  #panel-ais-text,
  #panel-ais-voice,
  #panel-ais-file {
    padding: 0;
  }

  /* ── Dropzone compact ── */
  .dropzone-compact {
    padding: 16px;
  }

  /* ── Voice recorder ── */
  .voice-recorder-box {
    padding: 12px;
  }

  /* ── Story config panel padding ── */
  #ais-config-panel .card[style*="padding:0"] > div {
    padding: 14px 16px 12px;
  }
}

@media (max-width: 480px) {
  .aic-posts-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* ── Story AI grid ─────────────────────────────────────────────────────────── */
.ais-story-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
}

.ais-story-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  font: inherit;
  color: inherit;
  text-align: center;
}

.ais-story-ring {
  position: relative;
  width: 100%;
  padding: 3px;
  border-radius: 16px;
  background: var(--border);
  transition: transform 0.18s;
}

.ais-story-card:hover .ais-story-ring {
  transform: scale(1.03);
}

.ais-story-card--active .ais-story-ring {
  background: linear-gradient(135deg, #f09433, #e6683c, #dc2743, #cc2366, #bc1888);
}

.ais-story-inner {
  width: 100%;
  aspect-ratio: 9 / 16;
  border-radius: 13px;
  overflow: hidden;
  background: var(--bg-soft, var(--bg));
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ais-story-inner img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.ais-story-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(0,0,0,0.65) 0%, transparent 55%);
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 8px 6px;
  gap: 3px;
}

.ais-story-badge-ai {
  position: absolute;
  top: 7px;
  right: 7px;
  background: var(--primary);
  color: #fff;
  font-size: 0.6rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 999px;
  letter-spacing: 0.02em;
}

.ais-story-time {
  color: #fff;
  font-size: 0.68rem;
  font-weight: 500;
  line-height: 1.3;
  text-shadow: 0 1px 3px rgba(0,0,0,0.5);
}

.ais-story-type-tag {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  background: rgba(255,255,255,0.18);
  backdrop-filter: blur(4px);
  color: #fff;
  font-size: 0.6rem;
  padding: 2px 6px;
  border-radius: 999px;
  align-self: flex-start;
}

.ais-story-label {
  font-size: 0.72rem;
  color: var(--muted);
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

/* ── Card flush (no padding, overflow hidden) ── */
.card-flush {
  padding: 0;
  overflow: hidden;
}

/* ── Card list header (posts/stories list header) ── */
.card-list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 20px 22px 16px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

/* ── AI Comments preview card ── */
.aic-preview-card {
  padding: 0;
  overflow: hidden;
  margin-bottom: 16px;
}

.aic-preview-card-inner {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 18px;
}

.aic-preview-info {
  flex: 1;
  min-width: 0;
}

.aic-preview-link {
  font-size: 0.8rem;
  color: var(--primary);
  text-decoration: none;
}

.aic-preview-link:hover {
  text-decoration: underline;
}

.aic-preview-badge {
  flex-shrink: 0;
}

/* ── Page action row ── */
.page-action-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

/* ── Instagram action row ── */
.ig-action-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

/* ── Visual improvements ── */

/* Subtle main content background pattern */
.main-content {
  background: var(--bg);
  min-height: 100vh;
  min-height: 100dvh;
}

/* Smooth card transitions for clickable cards */
.card-clickable {
  cursor: pointer;
  transition: box-shadow 0.18s, border-color 0.18s, transform 0.15s;
}

.card-clickable:hover {
  border-color: var(--primary-light);
  box-shadow: 0 4px 20px rgba(233, 30, 140, 0.1);
  transform: translateY(-1px);
}

/* Better badge styles */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge-success {
  background: #dcfce7;
  color: #166534;
}

.badge-danger {
  background: #fee2e2;
  color: #991b1b;
}

.badge-primary {
  background: var(--primary-light);
  color: var(--primary-dark);
}

.badge-neutral {
  background: var(--bg);
  color: var(--muted);
  border: 1px solid var(--border);
}

/* Story preview card in config panel */
.ais-preview-card {
  padding: 0;
  overflow: hidden;
  margin-bottom: 16px;
}

.ais-preview-card-inner {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 18px;
}

.ais-preview-info {
  flex: 1;
  min-width: 0;
}

.ais-preview-title {
  font-weight: 600;
  margin: 0 0 4px;
  font-size: 0.92rem;
}

.ais-preview-subtitle {
  color: var(--muted);
  font-size: 0.82rem;
  margin: 0 0 10px;
}

.ais-preview-story {
  width: 72px;
  flex-shrink: 0;
}

.ais-preview-ring {
  width: 80px;
  padding: 3px;
  border-radius: 14px;
  background: linear-gradient(135deg, #f09433, #e6683c, #dc2743, #cc2366, #bc1888);
}

.ais-preview-inner {
  width: 100%;
  aspect-ratio: 9 / 16;
  border-radius: 11px;
  overflow: hidden;
  background: var(--bg-soft, var(--bg));
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ais-preview-inner img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

@media (max-width: 768px) {
  .ais-story-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
  }
}

@media (max-width: 480px) {
  .ais-story-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
  }
}

@media (max-width: 400px) {
  .ingest-tabs {
    flex-direction: column;
  }

  .tab {
    flex: 1 1 100%;
    width: 100%;
  }

  .crawl-status-stats {
    grid-template-columns: 1fr;
  }

  .mobile-topbar-title {
    font-size: 0.84rem;
  }
}

/* ── Bottom Navigation Bar ── */
.bottom-nav {
  display: none;
}

.more-nav-backdrop,
.more-nav-drawer {
  display: none;
}

@media (max-width: 768px) {
  /* Hide entire topbar since bottom nav replaces it */
  .mobile-topbar {
    display: none !important;
  }

  /* ── Bottom Nav Bar ── */
  .bottom-nav {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 500;
    background: var(--card);
    border-top: 1px solid var(--border);
    padding-bottom: env(safe-area-inset-bottom, 0px);
    box-shadow: 0 -2px 20px rgba(0, 0, 0, 0.07);
  }

  .bottom-nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 10px 4px 8px;
    text-decoration: none;
    color: var(--muted);
    font-size: 0.65rem;
    font-weight: 500;
    border: none;
    background: transparent;
    cursor: pointer;
    font-family: var(--font);
    transition: color 0.15s;
    min-width: 0;
    position: relative;
  }

  .bottom-nav-item.active {
    color: var(--primary);
  }

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

  .bottom-nav-icon {
    width: 22px;
    height: 22px;
    flex-shrink: 0;
    transition: transform 0.15s;
  }

  .bottom-nav-item.active .bottom-nav-icon {
    transform: scale(1.1);
  }

  /* Center feature button */
  .bottom-nav-item--primary {
    color: var(--muted);
  }

  .bottom-nav-item--primary.active {
    color: var(--primary);
  }

  .bottom-nav-pill {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 14px rgba(233, 30, 140, 0.35);
    margin-bottom: -2px;
    margin-top: -10px;
    transition: box-shadow 0.15s, transform 0.15s;
  }

  .bottom-nav-item--primary .bottom-nav-pill .bottom-nav-icon {
    color: #fff;
    transform: none;
  }

  .bottom-nav-item--primary.active .bottom-nav-pill {
    box-shadow: 0 6px 20px rgba(233, 30, 140, 0.5);
  }

  .bottom-nav-item--primary::before {
    display: none;
  }

  /* Adjust main content — no topbar, add space for bottom nav */
  .main-content {
    padding-top: max(16px, env(safe-area-inset-top, 0px)) !important;
    padding-bottom: calc(68px + env(safe-area-inset-bottom, 0px) + 16px) !important;
  }

  /* ── More Nav Backdrop ── */
  .more-nav-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 590;
    background: rgba(17, 24, 39, 0.45);
    backdrop-filter: blur(2px);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s ease, visibility 0.25s ease;
  }

  .more-nav-backdrop.is-visible {
    opacity: 1;
    visibility: visible;
  }

  /* ── More Nav Drawer ── */
  .more-nav-drawer {
    display: block;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 600;
    background: var(--card);
    border-radius: 20px 20px 0 0;
    padding: 10px 0 calc(env(safe-area-inset-bottom, 0px) + 76px);
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.22, 1, 0.36, 1);
    box-shadow: 0 -8px 40px rgba(0, 0, 0, 0.14);
    border-top: 1px solid var(--border);
    max-height: 85dvh;
    overflow-y: auto;
    overscroll-behavior: contain;
  }

  .more-nav-drawer.is-open {
    transform: translateY(0);
  }

  .more-nav-handle {
    width: 36px;
    height: 4px;
    border-radius: 2px;
    background: var(--border-strong);
    margin: 0 auto 14px;
  }

  .more-nav-items {
    display: flex;
    flex-direction: column;
    padding: 0 12px;
    gap: 2px;
  }

  .more-nav-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 16px;
    border-radius: var(--radius-sm);
    text-decoration: none;
    color: var(--text);
    font-size: 0.95rem;
    font-weight: 500;
    transition: background 0.15s, color 0.15s;
    border: none;
    background: transparent;
    cursor: pointer;
    font-family: var(--font);
    width: 100%;
    text-align: right;
  }

  .more-nav-item:hover {
    background: var(--bg);
  }

  .more-nav-item.active {
    background: var(--primary-light);
    color: var(--primary-dark);
    font-weight: 600;
  }

  .more-nav-icon-wrap {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    background: var(--bg);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: var(--muted);
    transition: background 0.15s;
  }

  .more-nav-icon-wrap svg {
    width: 18px;
    height: 18px;
  }

  .more-nav-item.active .more-nav-icon-wrap {
    background: var(--primary-light);
    color: var(--primary-dark);
  }

  .more-nav-icon-wrap--danger {
    background: var(--danger-bg);
    color: var(--danger);
  }

  .more-nav-divider {
    height: 1px;
    background: var(--border);
    margin: 6px 4px;
  }

  .more-nav-logout {
    color: var(--danger);
    font-weight: 500;
  }

  .more-nav-logout:hover {
    background: var(--danger-bg);
    color: var(--danger);
  }
}

/* ── Dashboard ─────────────────────────────────────────────────────────────── */

/* Instagram connection alert */
.ig-alert {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 18px;
  background: linear-gradient(135deg, #fff7ed 0%, #fff3e0 100%);
  border: 1.5px solid #fb923c;
  border-radius: var(--radius);
  margin-bottom: 20px;
  animation: ig-alert-in 0.35s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes ig-alert-in {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.ig-alert-icon {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: rgba(251, 146, 60, 0.15);
  color: #ea580c;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.ig-alert-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.ig-alert-body strong {
  font-size: 0.9rem;
  font-weight: 700;
  color: #9a3412;
}

.ig-alert-body span {
  font-size: 0.82rem;
  color: #c2410c;
  line-height: 1.5;
}

.ig-alert-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 16px;
  background: #ea580c;
  color: #fff;
  border-radius: var(--radius-sm);
  font-size: 0.84rem;
  font-weight: 700;
  text-decoration: none !important;
  white-space: nowrap;
  flex-shrink: 0;
  transition: background 0.15s, box-shadow 0.15s;
  box-shadow: 0 3px 10px rgba(234, 88, 12, 0.3);
}

.ig-alert-btn:hover {
  background: #c2410c;
  box-shadow: 0 4px 14px rgba(234, 88, 12, 0.4);
}

@media (max-width: 600px) {
  .ig-alert {
    flex-wrap: wrap;
    gap: 12px;
  }
  .ig-alert-btn {
    width: 100%;
    justify-content: center;
  }
}

/* Stats grid */
.dash-stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 20px;
}

.dash-stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 18px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  position: relative;
  overflow: hidden;
  transition: box-shadow 0.18s, border-color 0.18s;
  box-shadow: var(--shadow);
}

.dash-stat-card:hover {
  box-shadow: 0 4px 24px rgba(0,0,0,0.08);
}

.dash-stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  border-radius: var(--radius) var(--radius) 0 0;
}

.dash-stat-card:nth-child(1)::before { background: linear-gradient(90deg, #e91e8c, #c41775); }
.dash-stat-card:nth-child(2)::before { background: linear-gradient(90deg, #7c3aed, #5b21b6); }
.dash-stat-card:nth-child(3)::before { background: linear-gradient(90deg, #0891b2, #0e7490); }

.dash-stat-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.dash-stat-icon svg {
  width: 22px;
  height: 22px;
}

.dash-stat-icon--users {
  background: rgba(233, 30, 140, 0.1);
  color: #e91e8c;
}

.dash-stat-icon--comments {
  background: rgba(124, 58, 237, 0.1);
  color: #7c3aed;
}

.dash-stat-icon--directs {
  background: rgba(8, 145, 178, 0.1);
  color: #0891b2;
}

.dash-stat-body {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
}

.dash-stat-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.dash-stat-value {
  font-size: 2rem;
  font-weight: 800;
  color: var(--text);
  line-height: 1.1;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
  display: block;
}

.dash-stat-sub {
  font-size: 0.78rem;
  color: var(--muted);
}

.dash-ai-label {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  background: rgba(124, 58, 237, 0.1);
  color: #6d28d9;
  align-self: flex-start;
  margin-top: 2px;
  letter-spacing: 0.01em;
}

.dash-ai-label--directs {
  background: rgba(8, 145, 178, 0.1);
  color: #0e7490;
}

.dash-stat-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 700;
  align-self: flex-start;
}

.dash-stat-badge--comments {
  background: rgba(124, 58, 237, 0.1);
  color: #6d28d9;
}

.dash-stat-badge--directs {
  background: rgba(8, 145, 178, 0.1);
  color: #0e7490;
}

/* Chart card */
.dash-chart-card {
  margin-bottom: 20px;
  padding: 22px 22px 16px;
}

.dash-chart-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.dash-chart-title {
  margin: 0 0 3px;
  font-size: 1rem;
  font-weight: 700;
}

.dash-chart-sub {
  margin: 0;
  font-size: 0.82rem;
  color: var(--muted);
}

.dash-chart-badge {
  flex-shrink: 0;
  padding: 5px 14px;
  background: var(--primary-light);
  color: var(--primary-dark);
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  white-space: nowrap;
}

.dash-chart-wrap {
  position: relative;
  height: 200px;
}

/* Setup cards */
.dash-setup-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  margin-bottom: 28px;
}

.dash-setup-card {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 22px 20px 18px;
}

.dash-setup-icon {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.dash-setup-icon svg {
  width: 24px;
  height: 24px;
}

.dash-setup-icon--kb {
  background: rgba(233, 30, 140, 0.1);
  color: var(--primary);
}

.dash-setup-icon--guide {
  background: rgba(124, 58, 237, 0.1);
  color: #7c3aed;
}

.dash-setup-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.dash-setup-title {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text);
}

.dash-setup-desc {
  margin: 0;
  font-size: 0.84rem;
  color: var(--muted);
  line-height: 1.7;
}

.dash-progress-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}

.dash-progress-bar {
  flex: 1;
  height: 8px;
  background: var(--bg);
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.dash-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--primary-dark));
  border-radius: 999px;
  transition: width 0.6s ease;
  min-width: 0;
}

.dash-progress-fill--guide {
  background: linear-gradient(90deg, #7c3aed, #5b21b6);
}

.dash-progress-label {
  flex-shrink: 0;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
  min-width: 60px;
  text-align: left;
  direction: ltr;
}

.dash-setup-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  color: var(--muted);
}

.dash-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.dash-status-dot--empty {
  background: var(--border-strong);
}

.dash-status-dot--ok {
  background: var(--success);
}

.dash-setup-action {
  align-self: flex-start;
  font-size: 0.84rem;
  padding: 9px 16px;
  text-decoration: none !important;
}

/* Tips section */
.dash-tips-head {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 14px;
}

.dash-tips-head svg {
  color: var(--primary);
}

.dash-tips-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  margin-bottom: 20px;
}

.dash-tip-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  transition: box-shadow 0.18s;
}

.dash-tip-card:hover {
  box-shadow: 0 4px 24px rgba(0,0,0,0.09);
}

.dash-tip-visual {
  padding: 22px 20px 16px;
  display: flex;
  align-items: center;
  gap: 14px;
  position: relative;
}

.dash-tip-card--comments .dash-tip-visual {
  background: linear-gradient(135deg, rgba(124, 58, 237, 0.08) 0%, rgba(233, 30, 140, 0.06) 100%);
  border-bottom: 1px solid rgba(124, 58, 237, 0.1);
}

.dash-tip-card--stories .dash-tip-visual {
  background: linear-gradient(135deg, rgba(233, 30, 140, 0.08) 0%, rgba(234, 88, 12, 0.06) 100%);
  border-bottom: 1px solid rgba(233, 30, 140, 0.1);
}

.dash-tip-icon-ring {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 4px 16px rgba(124, 58, 237, 0.18);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #7c3aed;
  flex-shrink: 0;
}

.dash-tip-icon-ring--stories {
  box-shadow: 0 4px 16px rgba(233, 30, 140, 0.18);
  color: var(--primary);
}

.dash-tip-metric {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.dash-tip-metric-icon {
  font-size: 1.3rem;
  line-height: 1;
}

.dash-tip-metric span:last-child {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
}

.dash-tip-body {
  padding: 18px 20px 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1;
}

.dash-tip-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  background: rgba(124, 58, 237, 0.1);
  color: #6d28d9;
  align-self: flex-start;
}

.dash-tip-badge--stories {
  background: rgba(233, 30, 140, 0.1);
  color: var(--primary-dark);
}

.dash-tip-badge.is-active {
  background: #dcfce7;
  color: #166534;
}

.dash-tip-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #7c3aed;
  flex-shrink: 0;
}

.dash-tip-dot--stories {
  background: var(--primary);
}

.dash-tip-badge.is-active .dash-tip-dot,
.dash-tip-badge.is-active .dash-tip-dot--stories {
  background: #059669;
  animation: pulse-active 1.5s infinite;
}

@keyframes pulse-active {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.6; transform: scale(0.8); }
}

.dash-tip-title {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text);
}

.dash-tip-desc {
  margin: 0;
  font-size: 0.84rem;
  color: var(--muted);
  line-height: 1.7;
}

.dash-tip-desc strong {
  color: var(--text);
  font-weight: 600;
}

.dash-tip-action {
  align-self: flex-start;
  font-size: 0.84rem;
  padding: 9px 16px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
  text-decoration: none !important;
}

.dash-tip-action--stories {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  box-shadow: 0 3px 12px rgba(233, 30, 140, 0.3);
}


/* Responsive */
@media (max-width: 768px) {
  .dash-stats-grid {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto auto;
    gap: 10px;
  }

  /* Total users spans full width */
  .dash-stats-grid .dash-stat-card:first-child {
    grid-column: 1 / -1;
    flex-direction: row;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
  }

  .dash-stats-grid .dash-stat-card:first-child .dash-stat-value {
    font-size: 1.8rem;
  }

  /* Comments and directs side by side */
  .dash-stats-grid .dash-stat-card:not(:first-child) {
    padding: 14px 12px;
    gap: 8px;
  }

  .dash-stat-card {
    gap: 10px;
    padding: 14px 12px;
  }

  .dash-stat-value {
    font-size: 1.5rem;
  }

  .dash-stat-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
  }

  .dash-stat-icon svg {
    width: 18px;
    height: 18px;
  }

  .dash-ai-label {
    font-size: 0.65rem;
    padding: 3px 7px;
  }

  .dash-chart-card {
    padding: 16px 14px 12px;
  }

  .dash-chart-wrap {
    height: 160px;
  }

  .dash-setup-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .dash-tips-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }
}

@media (max-width: 480px) {
  .dash-stats-grid {
    gap: 8px;
  }

  .dash-stat-value {
    font-size: 1.3rem;
  }

  .dash-stat-label {
    font-size: 0.7rem;
  }
}
