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

  :root {
    --bg: #0a0d14;
    --surface: #111622;
    --surface2: #161d2e;
    --border: #1e2a42;
    --accent: #3b82f6;
    --accent2: #60a5fa;
    --accent-glow: rgba(59,130,246,0.25);
    --green: #22c55e;
    --green-glow: rgba(34,197,94,0.2);
    --text: #e8edf5;
    --text-muted: #8896b0;
    --text-dim: #4a5568;
    --gold: #f59e0b;
  }

  /* ===== LIGHT MODE VARIABLES ===== */
  html.light {
    --bg: #f0f4f8;
    --surface: #ffffff;
    --surface2: #e8edf5;
    --border: #c8d4e8;
    --accent: #2563eb;
    --accent2: #1d4ed8;
    --accent-glow: rgba(37,99,235,0.18);
    --green: #16a34a;
    --green-glow: rgba(22,163,74,0.15);
    --text: #0f172a;
    --text-muted: #475569;
    --text-dim: #94a3b8;
    --gold: #d97706;
  }

  /* ===== THEME TOGGLE BUTTON ===== */
  #themeToggleBtn {
    display: flex; align-items: center; gap: 7px;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 6px 13px;
    font-size: 13px; font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.22s;
    font-family: 'Heebo', sans-serif;
    flex-shrink: 0;
    white-space: nowrap;
    user-select: none;
  }
  #themeToggleBtn:hover {
    border-color: var(--accent);
    color: var(--accent2);
    background: var(--surface);
  }
  #themeToggleBtn .theme-icon {
    font-size: 15px;
    transition: transform 0.4s ease;
  }
  #themeToggleBtn:hover .theme-icon {
    transform: rotate(20deg);
  }

  /* Light mode body/background overrides */
  html.light body {
    background: var(--bg);
  }
  html.light body::before {
    background:
      radial-gradient(ellipse 60% 40% at 20% 10%, rgba(37,99,235,0.05) 0%, transparent 70%),
      radial-gradient(ellipse 40% 60% at 80% 90%, rgba(22,163,74,0.04) 0%, transparent 70%);
  }
  html.light body::after {
    background-image:
      linear-gradient(rgba(37,99,235,0.04) 1px, transparent 1px),
      linear-gradient(90deg, rgba(37,99,235,0.04) 1px, transparent 1px);
  }
  html.light header {
    background: rgba(240,244,248,0.88);
  }
  html.light .contact-bar {
    background: rgba(240,244,248,0.95);
  }
  html.light #preloader {
    background: #f0f4f8;
  }
  html.light .welcome-modal {
    background: #ffffff;
    border-color: #c8d4e8;
    box-shadow: 0 0 0 1px rgba(37,99,235,0.1), 0 24px 60px rgba(0,0,0,0.12), 0 0 80px rgba(37,99,235,0.06);
  }
  html.light .welcome-modal-divider {
    background: linear-gradient(90deg, transparent, #c8d4e8, transparent);
  }
  html.light .welcome-modal h4,
  html.light .welcome-modal-name {
    background: linear-gradient(135deg, #0f172a 60%, #2563eb);
    -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
  }
  html.light .welcome-modal p { color: #475569; }
  html.light .welcome-modal p strong { color: #0f172a; }
  html.light .welcome-modal-tagline { color: #475569; }
  html.light #welcomeOverlay {
    background: rgba(240,244,248,0.82);
  }
  html.light .logo-text {
    background: linear-gradient(135deg, #0f172a, #2563eb);
    -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
  }
  html.light .result-title {
    background: linear-gradient(135deg, #0f172a, #16a34a);
    -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
  }
  html.light .card:hover {
    box-shadow: 0 8px 30px rgba(37,99,235,0.12);
  }
  html.light .secondary-btn {
    background: var(--surface);
  }
  html.light h2 {
    background: linear-gradient(135deg, #0f172a 60%, #2563eb);
    -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
  }
  html.light .screen-desc {
    color: #334155;
  }
  html.light .step-label {
    color: var(--accent);
  }

  html, body {
    width: 100%;
    background: var(--bg);
    color: var(--text);
    font-family: 'Heebo', sans-serif;
    overflow-x: hidden;
  }

  #bgParticles {
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    opacity: 1;
  }

  /* Color swatches for bg animation */
  .color-swatch:hover { transform: scale(1.2); border-color: rgba(255,255,255,0.6) !important; }
  .color-swatch.selected { border-color: #fff !important; }

  /* Animated background */
  body::before {
    content: '';
    position: fixed; inset: 0;
    background: 
      radial-gradient(ellipse 60% 40% at 20% 10%, rgba(59,130,246,0.06) 0%, transparent 70%),
      radial-gradient(ellipse 40% 60% at 80% 90%, rgba(34,197,94,0.04) 0%, transparent 70%);
    pointer-events: none;
    z-index: 0;
  }

  /* Grid lines */
  body::after {
    content: '';
    position: fixed; inset: 0;
    background-image: 
      linear-gradient(rgba(59,130,246,0.03) 1px, transparent 1px),
      linear-gradient(90deg, rgba(59,130,246,0.03) 1px, transparent 1px);
    background-size: 60px 60px;
    pointer-events: none;
    z-index: 0;
  }

  #app {
    position: relative; z-index: 1;
    width: 100%;
    min-height: 100vh;
    min-height: 100dvh;
    display: flex; flex-direction: column;
  }

  /* Header */
  header {
    display: flex; flex-direction: column;
    padding: 14px 24px 0;
    border-bottom: 1px solid var(--border);
    background: rgba(10,13,20,0.8);
    backdrop-filter: blur(10px);
    flex-shrink: 0;
    position: sticky; top: 0; z-index: 100;
    gap: 0;
  }

  .header-top {
    display: flex; align-items: center; justify-content: space-between;
    padding-bottom: 14px;
  }

  .header-controls {
    display: flex; align-items: center; gap: 12px;
  }

  .logo {
    display: flex; align-items: center; gap: 12px;
  }

  .logo-icon {
    width: 38px; height: 38px;
    background: linear-gradient(135deg, var(--accent), #1d4ed8);
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-size: 20px;
    box-shadow: 0 0 20px var(--accent-glow);
  }

  .logo-text {
    font-size: 20px; font-weight: 800;
    background: linear-gradient(135deg, #fff, var(--accent2));
    -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
    letter-spacing: -0.5px;
  }

  .logo-sub {
    font-size: 11px; color: var(--text-muted); font-weight: 400;
    margin-top: -3px;
  }

  /* Steps bar */
  .steps-bar {
    display: flex; align-items: center; gap: 0; width: 100%;
  }

  .step-item {
    display: flex; align-items: center; gap: 8px;
    font-size: 12px; font-weight: 500; color: var(--text-dim);
    transition: color 0.3s;
    white-space: nowrap;
  }

  .step-item.active { color: var(--accent2); }
  .step-item.done { color: var(--green); }

  .step-num {
    width: 24px; height: 24px; border-radius: 50%;
    border: 2px solid var(--text-dim);
    display: flex; align-items: center; justify-content: center;
    font-size: 11px; font-weight: 700;
    transition: all 0.3s;
    flex-shrink: 0;
  }

  .step-item.active .step-num {
    border-color: var(--accent);
    background: var(--accent-glow);
    color: var(--accent2);
    box-shadow: 0 0 10px var(--accent-glow);
  }

  .step-item.done .step-num {
    border-color: var(--green);
    background: var(--green-glow);
    color: var(--green);
  }

  .step-connector {
    width: 28px; height: 2px;
    background: var(--border);
    margin: 0 4px;
    transition: background 0.3s;
  }

  .step-connector.done { background: var(--green); }

  /* Main content */
  main {
    flex: 1;
    display: flex; align-items: flex-start; justify-content: center;
    padding: 20px 24px 24px;
  }

  .screen {
    display: none;
    width: 100%; max-width: 820px;
    animation: fadeIn 0.4s ease;
    align-self: flex-start;
  }

  .screen.active { display: block; }

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

  .step-label {
    font-size: 11px; font-weight: 700; letter-spacing: 2px;
    color: var(--accent); text-transform: uppercase;
    margin-bottom: 8px;
    display: flex; align-items: center; gap: 8px;
  }

  .step-label::before {
    content: '';
    width: 20px; height: 2px;
    background: var(--accent);
  }

  h2 {
    font-size: clamp(22px, 3vw, 34px);
    font-weight: 800; line-height: 1.25;
    margin-bottom: 8px;
    background: linear-gradient(135deg, #fff 60%, var(--accent2));
    -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
  }

  .screen-desc {
    font-size: 15px; color: var(--text-muted);
    margin-bottom: 28px; line-height: 1.6;
  }

  /* Cards grid */
  .cards-grid {
    display: grid;
    gap: 12px;
  }

  .cards-grid.cols-2 { grid-template-columns: 1fr 1fr; }
  .cards-grid.cols-3 { grid-template-columns: 1fr 1fr 1fr; }
  .cards-grid.cols-auto { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }

  .card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 18px 20px;
    cursor: pointer;
    transition: all 0.25s;
    display: flex; align-items: center; gap: 14px;
    position: relative; overflow: hidden;
  }

  .card::before {
    content: '';
    position: absolute; inset: 0;
    background: linear-gradient(135deg, var(--accent-glow), transparent);
    opacity: 0; transition: opacity 0.25s;
  }

  .card:hover::before { opacity: 1; }
  .card:hover {
    border-color: var(--accent);
    transform: translateY(-2px);
    box-shadow: 0 8px 30px rgba(59,130,246,0.15);
  }

  .card.selected {
    border-color: var(--accent);
    background: var(--surface2);
    box-shadow: 0 0 20px var(--accent-glow);
  }

  .card-icon {
    font-size: 26px; flex-shrink: 0; line-height: 1;
  }

  .card-content { flex: 1; min-width: 0; }

  .card-title {
    font-size: 14px; font-weight: 700;
    color: var(--text); line-height: 1.3;
  }

  .card-sub {
    font-size: 12px; color: var(--text-muted); margin-top: 3px;
  }

  .card-arrow {
    font-size: 16px; color: var(--text-dim);
    transition: color 0.2s, transform 0.2s;
    flex-shrink: 0;
  }

  .card:hover .card-arrow { color: var(--accent2); transform: translateX(-4px); }

  /* Problem sub-cards - compact */
  .prob-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 14px 18px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex; align-items: center; gap: 12px;
  }

  .prob-card:hover {
    border-color: var(--accent);
    background: var(--surface2);
    transform: translateY(-1px);
  }

  .prob-card.selected {
    border-color: var(--accent);
    box-shadow: 0 0 15px var(--accent-glow);
  }

  .prob-dot {
    width: 8px; height: 8px; border-radius: 50%;
    background: var(--accent); flex-shrink: 0;
    box-shadow: 0 0 6px var(--accent);
  }

  /* Result screen */
  .result-box {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: 30px 36px;
    position: relative; overflow: hidden;
  }

  .result-box::before {
    content: '';
    position: absolute; top: 0; right: 0;
    width: 200px; height: 200px;
    background: radial-gradient(circle, var(--accent-glow), transparent 70%);
    pointer-events: none;
  }

  .result-header {
    display: flex; align-items: center; gap: 14px;
    margin-bottom: 20px;
  }

  .result-check {
    width: 50px; height: 50px; border-radius: 50%;
    background: var(--green-glow);
    border: 2px solid var(--green);
    display: flex; align-items: center; justify-content: center;
    font-size: 22px;
    box-shadow: 0 0 20px var(--green-glow);
    flex-shrink: 0;
  }

  .result-title {
    font-size: 22px; font-weight: 800;
    background: linear-gradient(135deg, #fff, var(--green));
    -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
  }

  .result-summary {
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px 20px;
    margin-bottom: 20px;
    font-size: 13px; color: var(--text-muted);
    line-height: 1.8;
  }

  .result-summary span { color: var(--text); font-weight: 600; }

  .result-desc {
    font-size: 15px; color: var(--text-muted);
    line-height: 1.7; margin-bottom: 10px; padding-right:15px; padding-left:15px;
  }

  .guides-section h4 {
    font-size: 13px; font-weight: 700; letter-spacing: 1.5px;
    color: var(--accent); text-transform: uppercase; margin-bottom: 12px;
  }

  .guide-links {
    display: flex; flex-direction: column; gap: 8px;
  }

  .guide-link {
    display: flex; align-items: center; gap: 10px;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 12px 16px;
    text-decoration: none;
    color: var(--text);
    transition: all 0.2s;
    font-size: 14px; font-weight: 500;
  }

  .guide-link:hover {
    border-color: var(--accent);
    background: rgba(59,130,246,0.08);
    transform: translateX(-3px);
    color: var(--accent2);
  }

  .guide-link-icon { font-size: 16px; flex-shrink: 0; }
  .guide-link-text { flex: 1; }
  .guide-link-arrow { color: var(--text-dim); font-size: 14px; }

  .primary-btn {
    display: inline-flex; align-items: center; gap: 8px;
    background: linear-gradient(135deg, var(--accent), #1d4ed8);
    color: #fff; border: none; border-radius: 10px;
    padding: 13px 28px;
    font-size: 15px; font-weight: 700;
    cursor: pointer; transition: all 0.2s;
    font-family: 'Heebo', sans-serif;
    text-decoration: none;
    box-shadow: 0 4px 20px var(--accent-glow);
  }

  .primary-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 30px rgba(59,130,246,0.4);
  }

  .secondary-btn {
    display: inline-flex; align-items: center; gap: 8px;
    background: transparent;
    color: var(--text-muted); border: 1px solid var(--border);
    border-radius: 10px;
    padding: 13px 28px;
    font-size: 15px; font-weight: 600;
    cursor: pointer; transition: all 0.2s;
    font-family: 'Heebo', sans-serif;
  }

  .secondary-btn:hover {
    border-color: var(--accent);
    color: var(--accent2);
  }

  .btn-row {
    display: flex; gap: 10px; margin-top: 28px;
    justify-content: flex-end; align-items: center;
    flex-wrap: wrap;
  }

  .btn-row a.secondary-btn {
    text-decoration: none;
    display: inline-flex; align-items: center; justify-content: center;
  }

  /* Progress bar */
  .progress-wrap {
    display: flex; flex-direction: column; gap: 8px;
    padding: 10px 0 14px;
    flex-shrink: 0;
    width: 100%; max-width: 820px; margin: 0 auto;
  }

  .progress-bar {
    height: 2px;
    background: var(--border);
    border-radius: 2px;
    overflow: hidden;
    width: 100%;
  }

  .progress-fill {
    width: 0%;
    height: 100%;
    background: linear-gradient(90deg, var(--accent), var(--green));
    transition: width 0.5s ease;
    border-radius: 2px;
  }

  /* Scrollable content area */
  .scroll-content {
    width: 100%;
    padding-bottom: 16px;
  }

  /* Footer */
  .contact-bar {
    padding: 12px 24px;
    border-top: 1px solid var(--border);
    background: rgba(10,13,20,0.9);
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
    font-size: 11px; color: var(--text-dim);
    text-align: center; letter-spacing: 0.5px;
    font-weight: 500;
    direction: ltr;
    unicode-bidi: isolate;
  }

  .contact-bar a {
    color: var(--text-muted); text-decoration: none;
    transition: color 0.2s; font-weight: 600;
  }

  .contact-bar a:hover { color: var(--accent2); }

  @media (max-width: 600px) {
    header { padding: 12px 16px; }
    .logo-text { font-size: 17px; }
    .logo-sub { display: none; }
    .logo-icon { width: 32px; height: 32px; font-size: 17px; }
    main { padding: 14px 16px 20px; }
    .progress-wrap { padding: 0 16px; }
    .cards-grid.cols-3, .cards-grid.cols-2 { grid-template-columns: 1fr; }
    .cards-grid.cols-auto { grid-template-columns: 1fr; }
    .steps-bar { display: none; }
    .contact-bar { padding: 16px 16px 32px; }
    @supports (padding-bottom: env(safe-area-inset-bottom)) {
      .contact-bar { padding-bottom: calc(32px + env(safe-area-inset-bottom)); }
    }
    .contact-links { gap: 10px; }
    .result-box { padding: 16px; }
    .result-title { font-size: 18px; }
    .result-check { width: 40px; height: 40px; font-size: 18px; }
    h2 { font-size: 20px; }
    .screen-desc { font-size: 13px; margin-bottom: 16px; }
    .card { padding: 14px 16px; }
    .card-icon { font-size: 22px; }
    .card-title { font-size: 13px; }
    .primary-btn { padding: 12px 20px; font-size: 14px; }
    .secondary-btn { padding: 12px 16px; font-size: 13px; }
    .btn-row { margin-top: 18px; justify-content: flex-start; }
    .result-summary { font-size: 12px; padding: 12px 14px; }
    .result-desc { font-size: 13px; margin-bottom: 16px; }
    .guide-link { padding: 11px 14px; font-size: 13px; }
    #themeToggleBtn #themeLabel { display: none; }
    #themeToggleBtn { padding: 6px 10px; }
  }

  /* Support contact section */
  .support-contact {
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
  }

  .support-contact-title {
    font-size: 13px; font-weight: 700;
    color: var(--text-muted); margin-bottom: 14px;
    letter-spacing: 0.3px;
  }

  .support-contact-buttons {
    display: flex; gap: 10px; flex-wrap: wrap;
  }

  .support-btn {
    display: flex; align-items: center; gap: 10px;
    padding: 11px 16px;
    border-radius: 12px;
    text-decoration: none;
    border: 1px solid var(--border);
    background: var(--surface2);
    transition: all 0.2s;
    flex: 1; min-width: 140px;
  }

  .support-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0,0,0,0.3);
  }

  .support-btn-phone { border-color: rgba(99,179,237,0.3); }
  .support-btn-phone:hover { border-color: #63b3ed; background: rgba(99,179,237,0.08); }

  .support-btn-wa { border-color: rgba(72,187,120,0.3); }
  .support-btn-wa:hover { border-color: #48bb78; background: rgba(72,187,120,0.08); }

  .support-btn-web { border-color: rgba(159,122,234,0.3); }
  .support-btn-web:hover { border-color: #9f7aea; background: rgba(159,122,234,0.08); }

  .support-btn-icon { font-size: 20px; flex-shrink: 0; }

  .support-btn-text {
    display: flex; flex-direction: column;
    color: var(--text); font-size: 14px;
  }

  .support-btn-sub {
    font-size: 11px; color: var(--text-muted);
    font-weight: 400; margin-top: 1px;
  }

  .support-hours {
    margin-top: 12px;
    font-size: 11px; color: var(--text-dim);
    text-align: center;
  }

  @media (max-width: 600px) {
    .support-contact-buttons { gap: 8px; }
    .support-btn { flex: 0 0 calc(50% - 4px); padding: 10px 12px; }
    .support-btn-text { font-size: 13px; }
  }
/* ===== PRELOADER ===== */
#preloader {
  position: fixed; inset: 0; z-index: 9999;
  background: #0a0d14;
  display: flex; align-items: center; justify-content: center;
  transition: opacity 0.5s ease, visibility 0.5s ease;
}

#preloader.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.preloader-inner {
  display: flex; flex-direction: column; align-items: center; gap: 20px;
  text-align: center;
}

.preloader-logo {
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  animation: preloaderFadeIn 0.6s ease forwards;
}

.preloader-icon {
  font-size: 52px;
  filter: drop-shadow(0 0 20px rgba(59,130,246,0.6));
  animation: preloaderPulse 1.8s ease-in-out infinite;
}

.preloader-brand {
  font-size: 22px; font-weight: 800; letter-spacing: -0.5px;
  background: linear-gradient(135deg, #fff, #60a5fa);
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
}

.preloader-spinner {
  position: relative; width: 56px; height: 56px;
  margin: 4px 0;
}

.spinner-ring {
  position: absolute; inset: 0;
  border-radius: 50%;
  border: 2.5px solid transparent;
  border-top-color: #3b82f6;
  animation: spinRing 1s linear infinite;
}

.spinner-ring-2 {
  inset: 8px;
  border-top-color: #22c55e;
  animation-duration: 0.75s;
  animation-direction: reverse;
}

.preloader-text {
  font-size: 13px; color: #8896b0; font-weight: 500;
  letter-spacing: 0.5px;
  animation: preloaderFadeIn 0.8s ease 0.3s forwards;
  opacity: 0;
}

.preloader-bar-wrap {
  width: 180px; height: 2px;
  background: #1e2a42; border-radius: 2px; overflow: hidden;
  animation: preloaderFadeIn 0.8s ease 0.4s forwards;
  opacity: 0;
}

.preloader-bar {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, #3b82f6, #22c55e);
  border-radius: 2px;
  transition: width 0.08s linear;
}

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

@keyframes preloaderPulse {
  0%, 100% { transform: scale(1); filter: drop-shadow(0 0 20px rgba(59,130,246,0.5)); }
  50% { transform: scale(1.08); filter: drop-shadow(0 0 30px rgba(59,130,246,0.9)); }
}

@keyframes preloaderFadeIn {
  to { opacity: 1; }
}

/* ===== AI RESULT STATES ===== */
.ai-thinking {
  display: inline-flex; align-items: center; gap: 5px;
  vertical-align: middle;
}

.ai-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--accent);
  animation: aiDotBounce 1.2s ease-in-out infinite;
  display: inline-block;
}

.ai-dot:nth-child(2) { animation-delay: 0.2s; background: var(--accent2); }
.ai-dot:nth-child(3) { animation-delay: 0.4s; background: var(--green); }

@keyframes aiDotBounce {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
  40% { transform: scale(1.2); opacity: 1; }
}

.ai-loading-text {
  color: var(--text-muted);
  font-style: italic;
  font-size: 14px;
  animation: aiPulse 1.5s ease-in-out infinite;
}

@keyframes aiPulse {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 1; }
}

.ai-badge {
  display: inline-flex; align-items: center;
  background: linear-gradient(135deg, rgba(59,130,246,0.2), rgba(34,197,94,0.15));
  border: 1px solid rgba(59,130,246,0.4);
  border-radius: 6px;
  padding: 1px 7px;
  font-size: 11px; font-weight: 700; letter-spacing: 0.5px;
  color: var(--accent2);
  vertical-align: middle;
  margin-left: 6px;
}

.rep-badge {
  display: inline-flex; align-items: center;
  background: linear-gradient(135deg, rgba(251,146,60,0.2), rgba(234,179,8,0.15));
  border: 1px solid rgba(251,146,60,0.45);
  border-radius: 6px;
  padding: 1px 7px;
  font-size: 11px; font-weight: 700; letter-spacing: 0.5px;
  color: #f97316;
  vertical-align: middle;
  margin-left: 6px;
}

/* ===== AI DESC UPDATED HIGHLIGHT ===== */
.ai-updated-highlight {
  background: rgba(34, 197, 94, 0.15);
  border: 1px solid rgba(34, 197, 94, 0.5);
  border-radius: 10px;
  padding: 10px 14px;
  box-shadow: 0 0 18px rgba(34, 197, 94, 0.2);
  animation: aiHighlightFadeOut 5s ease forwards;
}

@keyframes aiHighlightFadeOut {
  0%   { background: rgba(34,197,94,0.18); border-color: rgba(34,197,94,0.6); box-shadow: 0 0 22px rgba(34,197,94,0.3); }
  60%  { background: rgba(34,197,94,0.10); border-color: rgba(34,197,94,0.3); box-shadow: 0 0 10px rgba(34,197,94,0.1); }
  100% { background: transparent; border-color: transparent; box-shadow: none; padding: 0; }
}

.ai-separator { border: none; border-top: 1px dashed rgba(128,128,128,0.2); margin: 12px 0 5px; }
.ai-result-extra {
  font-size: 15px; color: var(--text-muted); line-height: 1.7; margin-top: 0px; margin-bottom: 20px;
  padding: 10px 16px; border-radius: 10px;
  animation: aiResultAppear 0.5s cubic-bezier(0.22,1,0.36,1), aiResultGlow 6s ease forwards;
}
@keyframes aiResultAppear {
  from { opacity: 0; transform: translateY(10px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes aiResultGlow {
  0%   {
    box-shadow: inset 0 0 0 1000px rgba(34,197,94,0.14), 0 0 24px rgba(34,197,94,0.35), 0 4px 16px rgba(34,197,94,0.2);
    border: 1px solid rgba(34,197,94,0.55);
  }
  60%  {
    box-shadow: inset 0 0 0 1000px rgba(34,197,94,0.05), 0 0 8px rgba(34,197,94,0.1);
    border: 1px solid rgba(34,197,94,0.15);
  }
  100% {
    box-shadow: none;
    border: 1px solid transparent;
  }
}

/* ===== WELCOME MODAL ===== */
#welcomeOverlay {
  position: fixed; inset: 0; z-index: 9998;
  background: rgba(10, 13, 20, 0.85);
  backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  animation: overlayFadeIn 0.4s ease forwards;
}
#welcomeOverlay.hiding {
  animation: overlayFadeOut 0.35s ease forwards;
}
@keyframes overlayFadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes overlayFadeOut {
  from { opacity: 1; }
  to   { opacity: 0; }
}
.welcome-modal {
  background: #111622;
  border: 1px solid #1e2a42;
  border-radius: 20px;
  padding: 40px 44px;
  max-width: 480px;
  width: 100%;
  position: relative;
  box-shadow:
    0 0 0 1px rgba(59,130,246,0.15),
    0 24px 60px rgba(0,0,0,0.6),
    0 0 80px rgba(59,130,246,0.08);
  animation: modalSlideIn 0.45s cubic-bezier(0.22,1,0.36,1) forwards;
  overflow: hidden;
}
.welcome-modal::before {
  content: '';
  position: absolute; top: 0; right: 0;
  width: 180px; height: 180px;
  background: radial-gradient(circle, rgba(59,130,246,0.12), transparent 70%);
  pointer-events: none;
}
.welcome-modal::after {
  content: '';
  position: absolute; bottom: 0; left: 0;
  width: 120px; height: 120px;
  background: radial-gradient(circle, rgba(34,197,94,0.07), transparent 70%);
  pointer-events: none;
}
@keyframes modalSlideIn {
  from { opacity: 0; transform: translateY(24px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0)   scale(1);    }
}
.welcome-modal-logo {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 26px;
}
.welcome-modal-icon {
  width: 48px; height: 48px;
  background: linear-gradient(135deg, #3b82f6, #1d4ed8);
  border-radius: 13px;
  display: flex; align-items: center; justify-content: center;
  font-size: 24px;
  box-shadow: 0 0 24px rgba(59,130,246,0.35);
  flex-shrink: 0;
}
.welcome-modal-brand {
  display: flex; flex-direction: column;
}
.welcome-modal-name {
  font-size: 19px; font-weight: 800; letter-spacing: -0.4px;
  background: linear-gradient(135deg, #fff, #60a5fa);
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
}
.welcome-modal-tagline {
  font-size: 12px; color: #8896b0; font-weight: 400; margin-top: 2px;
}
.welcome-modal-divider {
  height: 1px;
  background: linear-gradient(90deg, transparent, #1e2a42, transparent);
  margin-bottom: 26px;
}
.welcome-modal h4 {
  font-size: 22px; font-weight: 800; line-height: 1.25;
  background: linear-gradient(135deg, #fff 60%, #60a5fa);
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
  margin-bottom: 14px;
}
.welcome-modal p {
  font-size: 14px; color: #8896b0; line-height: 1.75;
  margin-bottom: 0;
}
.welcome-modal p strong {
  color: #e8edf5; font-weight: 600;
}
.welcome-modal-btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%;
  background: linear-gradient(135deg, #3b82f6, #1d4ed8);
  color: #fff; border: none; border-radius: 12px;
  padding: 14px 28px;
  font-size: 16px; font-weight: 700;
  cursor: pointer; transition: all 0.2s;
  font-family: 'Heebo', sans-serif;
  margin-top: 28px;
  box-shadow: 0 4px 20px rgba(59,130,246,0.35);
  position: relative; z-index: 1;
  letter-spacing: 0.2px;
}
.welcome-modal-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 32px rgba(59,130,246,0.5);
}
.welcome-modal-btn:active { transform: translateY(0); }
.welcome-modal-btn-arrow {
  font-size: 18px;
  transition: transform 0.2s;
}
.welcome-modal-btn:hover .welcome-modal-btn-arrow {
  transform: translateX(-4px);
}
@media (max-width: 600px) {
  .welcome-modal { padding: 28px 22px; border-radius: 16px; }
  .welcome-modal h4 { font-size: 19px; }
  .welcome-modal p  { font-size: 13px; }
  .welcome-modal-btn { font-size: 15px; padding: 13px 20px; }
}


/* ========================================
   ADMIN PANEL STYLES
   ======================================== */

/* ===== ADMIN GEAR BUTTON ===== */
#adminGearBtn {
  position: fixed;
  bottom: 20px;
  left: 20px;
  width: 44px;
  height: 44px;
  background: rgba(17,22,34,0.9);
  border: 1px solid #1e2a42;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 100000;
  transition: all 0.25s;
  backdrop-filter: blur(8px);
  box-shadow: 0 4px 20px rgba(0,0,0,0.4);
}
#adminGearBtn:hover {
  border-color: #3b82f6;
  box-shadow: 0 0 16px rgba(59,130,246,0.3);
  transform: rotate(30deg);
}
#adminGearBtn svg {
  width: 20px; height: 20px;
  fill: #4a5568;
  transition: fill 0.2s;
}
#adminGearBtn:hover svg { fill: #60a5fa; }

html.light #adminGearBtn {
  background: rgba(255,255,255,0.92);
  border-color: #c8d4e8;
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
}
html.light #adminGearBtn svg { fill: #475569; }
html.light #adminGearBtn:hover { border-color: #2563eb; box-shadow: 0 0 16px rgba(37,99,235,0.2); }
html.light #adminGearBtn:hover svg { fill: #2563eb; }

/* ===== LOGIN OVERLAY ===== */
#adminLoginOverlay {
  display: none;
  position: fixed; inset: 0; z-index: 100000;
  background: rgba(10,13,20,0.92);
  backdrop-filter: blur(8px);
  align-items: center; justify-content: center;
}
#adminLoginOverlay.open { display: flex; animation: adminFadeIn 0.3s ease; }

.admin-login-box {
  background: #111622;
  border: 1px solid #1e2a42;
  border-radius: 20px;
  padding: 44px 48px;
  width: 100%; max-width: 420px;
  box-shadow: 0 0 0 1px rgba(59,130,246,0.1), 0 30px 80px rgba(0,0,0,0.7);
  animation: adminSlideIn 0.4s cubic-bezier(0.22,1,0.36,1);
  text-align: center;
}
.admin-login-icon {
  font-size: 40px; margin-bottom: 16px;
  animation: adminGearSpin 4s linear infinite;
  display: inline-block;
}
@keyframes adminGearSpin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}
.admin-login-title {
  font-size: 22px; font-weight: 800;
  background: linear-gradient(135deg, #fff, #60a5fa);
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
  margin-bottom: 6px;
}
.admin-login-sub {
  font-size: 13px; color: #8896b0; margin-bottom: 28px;
}
.admin-login-input {
  width: 100%;
  background: #161d2e;
  border: 1px solid #1e2a42;
  border-radius: 10px;
  padding: 12px 16px;
  font-size: 15px; font-weight: 500;
  color: #e8edf5;
  font-family: 'Heebo', sans-serif;
  margin-bottom: 14px;
  text-align: center;
  letter-spacing: 2px;
  transition: border-color 0.2s;
}
.admin-login-input:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59,130,246,0.15);
}
.admin-login-input.error { border-color: #ef4444; animation: adminShake 0.4s ease; }
@keyframes adminShake {
  0%,100%{transform:translateX(0)} 25%{transform:translateX(-6px)} 75%{transform:translateX(6px)}
}
.admin-login-remember {
  display: flex; align-items: center; gap: 8px;
  font-size: 12px; color: #8896b0;
  cursor: pointer; margin-bottom: 18px; user-select: none;
}
.admin-login-remember input[type="checkbox"] {
  width: 15px; height: 15px; accent-color: #3b82f6; cursor: pointer; flex-shrink: 0;
}
.admin-login-btn {
  width: 100%;
  background: linear-gradient(135deg, #3b82f6, #1d4ed8);
  color: #fff; border: none; border-radius: 10px;
  padding: 13px; font-size: 15px; font-weight: 700;
  cursor: pointer; transition: all 0.2s;
  font-family: 'Heebo', sans-serif;
  box-shadow: 0 4px 20px rgba(59,130,246,0.3);
  margin-bottom: 12px;
}
.admin-login-btn:hover { transform: translateY(-2px); box-shadow: 0 8px 28px rgba(59,130,246,0.45); }
.admin-login-cancel {
  font-size: 13px; color: #4a5568; cursor: pointer;
  background: none; border: none; font-family: 'Heebo', sans-serif;
  transition: color 0.2s;
}
.admin-login-cancel:hover { color: #8896b0; }
.admin-login-error {
  font-size: 13px; color: #ef4444; margin-bottom: 10px;
  display: none;
}
.admin-login-error.show { display: block; }

/* ===== CHANGE PASSWORD MODAL ===== */
#adminChangePwOverlay {
  display: none;
  position: fixed; inset: 0; z-index: 100000;
  background: rgba(10,13,20,0.88);
  backdrop-filter: blur(8px);
  align-items: center; justify-content: center;
}
#adminChangePwOverlay.open { display: flex; animation: adminFadeIn 0.25s ease; }
.changepw-box {
  background: #111622;
  border: 1px solid #1e2a42;
  border-radius: 20px;
  padding: 36px 40px;
  width: 100%; max-width: 400px;
  box-shadow: 0 0 0 1px rgba(59,130,246,0.1), 0 30px 80px rgba(0,0,0,0.7);
  animation: adminSlideIn 0.35s cubic-bezier(0.22,1,0.36,1);
  text-align: center;
}
.changepw-title {
  font-size: 20px; font-weight: 800;
  background: linear-gradient(135deg, #fff, #60a5fa);
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
  margin-bottom: 6px;
}
.changepw-sub { font-size: 13px; color: #8896b0; margin-bottom: 24px; }
.changepw-label {
  display: block; text-align: right;
  font-size: 12px; font-weight: 600; color: #8896b0;
  margin-bottom: 6px; margin-top: 14px;
  font-family: 'Heebo', sans-serif;
}
.changepw-input {
  width: 100%;
  background: #161d2e; border: 1px solid #1e2a42; border-radius: 10px;
  padding: 11px 14px; font-size: 14px; font-weight: 500; color: #e8edf5;
  font-family: 'Heebo', sans-serif; text-align: right; direction: ltr;
  transition: border-color 0.2s;
}
.changepw-input:focus { outline: none; border-color: #3b82f6; }
.changepw-input.error { border-color: #ef4444; animation: adminShake 0.4s ease; }
.changepw-error { font-size: 12px; color: #ef4444; margin-top: 8px; min-height: 18px; text-align: right; }
.changepw-actions { display: flex; gap: 10px; margin-top: 24px; }
.changepw-save-btn {
  flex: 1; background: linear-gradient(135deg, #3b82f6, #1d4ed8);
  color: #fff; border: none; border-radius: 10px;
  padding: 12px; font-size: 15px; font-weight: 700;
  cursor: pointer; transition: all 0.2s; font-family: 'Heebo', sans-serif;
}
.changepw-save-btn:hover { transform: translateY(-1px); box-shadow: 0 6px 24px rgba(59,130,246,0.4); }
.changepw-cancel-btn {
  padding: 12px 18px; background: transparent; color: #8896b0;
  border: 1px solid #1e2a42; border-radius: 10px;
  font-size: 14px; font-weight: 600; cursor: pointer; transition: all 0.2s;
  font-family: 'Heebo', sans-serif;
}
.changepw-cancel-btn:hover { border-color: #4a5568; color: #e8edf5; }
.admin-changepw-btn {
  width: 100%; margin-top: 8px; background: transparent;
  border: 1px solid #1e2a42; border-radius: 10px; padding: 9px 14px;
  font-size: 12px; font-weight: 600; color: #4a5568;
  cursor: pointer; transition: all 0.2s; font-family: 'Heebo', sans-serif;
  display: flex; align-items: center; gap: 7px; justify-content: center;
}
.admin-changepw-btn:hover { border-color: #3b82f6; color: #60a5fa; background: rgba(59,130,246,0.06); }

/* ===== BACKUP UI ===== */
.backup-card { background: #111622; border: 1px solid #1e2a42; border-radius: 14px; padding: 20px 22px; }
.backup-card + .backup-card { margin-top: 16px; }
.backup-card-header { display: flex; align-items: center; gap: 14px; }
.backup-card-icon { font-size: 24px; width: 44px; height: 44px; background: rgba(59,130,246,0.08); border-radius: 10px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.backup-card-title { font-size: 15px; font-weight: 700; color: #e8edf5; }
.backup-card-sub { font-size: 12px; color: #8896b0; margin-top: 2px; }
.backup-limit-btn { padding: 8px 20px; background: #161d2e; border: 1px solid #1e2a42; border-radius: 8px; color: #8896b0; font-size: 14px; font-weight: 600; cursor: pointer; transition: all 0.18s; font-family: 'Heebo', sans-serif; }
.backup-limit-btn:hover { border-color: #3b82f6; color: #60a5fa; }
.backup-limit-btn.active { background: rgba(59,130,246,0.15); border-color: #3b82f6; color: #60a5fa; }
.backup-row { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px; background: #0d1117; border: 1px solid #1a2238; border-radius: 10px; margin-bottom: 8px; gap: 10px; transition: border-color 0.18s; }
.backup-row:last-child { margin-bottom: 0; }
.backup-row:hover { border-color: #253352; }
.backup-row-info { flex: 1; min-width: 0; }
.backup-row-date { font-size: 13px; font-weight: 600; color: #e8edf5; }
.backup-row-size { font-size: 11px; color: #4a5568; margin-top: 2px; }
.backup-row-actions { display: flex; gap: 6px; flex-shrink: 0; }
.backup-action-btn { padding: 6px 12px; border-radius: 7px; font-size: 12px; font-weight: 600; cursor: pointer; transition: all 0.18s; font-family: 'Heebo', sans-serif; border: 1px solid transparent; white-space: nowrap; }
.backup-action-btn.restore { background: rgba(59,130,246,0.1); color: #60a5fa; border-color: rgba(59,130,246,0.3); }
.backup-action-btn.restore:hover { background: rgba(59,130,246,0.22); }
.backup-action-btn.export { background: rgba(52,211,153,0.08); color: #34d399; border-color: rgba(52,211,153,0.3); }
.backup-action-btn.export:hover { background: rgba(52,211,153,0.2); }
.backup-action-btn.delete { background: rgba(239,68,68,0.07); color: #f87171; border-color: rgba(239,68,68,0.25); }
.backup-action-btn.delete:hover { background: rgba(239,68,68,0.18); }

/* ===== ADMIN PANEL ===== */
#adminPanel {
  display: none;
  position: fixed; inset: 0; z-index: 9400;
  background: #0a0d14;
  flex-direction: row;
  overflow: hidden;
}
#adminPanel.open { display: flex; animation: adminFadeIn 0.3s ease; }

@keyframes adminFadeIn { from{opacity:0} to{opacity:1} }
@keyframes adminSlideIn {
  from { opacity:0; transform: translateY(24px) scale(0.97); }
  to { opacity:1; transform: translateY(0) scale(1); }
}

/* Sidebar */
.admin-sidebar {
  width: 240px; flex-shrink: 0;
  background: #0d1117;
  border-left: 1px solid #1e2a42;
  display: flex; flex-direction: column;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.admin-sidebar-header {
  padding: 20px 18px 16px;
  border-bottom: 1px solid #1e2a42;
}
.admin-sidebar-logo {
  display: flex; align-items: center; gap: 10px;
}
.admin-sidebar-logo-icon {
  width: 34px; height: 34px;
  background: linear-gradient(135deg, #3b82f6, #1d4ed8);
  border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
}
.admin-sidebar-logo-text {
  font-size: 15px; font-weight: 800;
  background: linear-gradient(135deg, #fff, #60a5fa);
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
}
.admin-sidebar-logo-sub {
  font-size: 10px; color: #4a5568; font-weight: 400;
}
.admin-nav {
  padding: 12px 10px;
  flex: 1;
}
.admin-nav-label {
  font-size: 10px; font-weight: 700; letter-spacing: 1.5px;
  color: #2d3748; text-transform: uppercase;
  padding: 6px 8px 4px;
}
.admin-nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px;
  border-radius: 9px;
  cursor: pointer;
  font-size: 13px; font-weight: 600; color: #8896b0;
  transition: all 0.18s;
  margin-bottom: 2px;
}
.admin-nav-item:hover { background: #161d2e; color: #e8edf5; }
.admin-nav-item.active { background: rgba(59,130,246,0.15); color: #60a5fa; }
.admin-nav-item .nav-icon { font-size: 16px; }
.admin-nav-badge {
  margin-right: auto;
  background: #1e2a42;
  border-radius: 10px;
  padding: 1px 7px;
  font-size: 10px;
  color: #8896b0;
}
.admin-sidebar-footer {
  padding: 14px 10px;
  border-top: 1px solid #1e2a42;
}
.admin-logout-btn {
  display: flex; align-items: center; gap: 8px;
  width: 100%;
  padding: 9px 10px;
  border-radius: 9px;
  border: none;
  background: transparent;
  color: #4a5568; font-size: 13px; font-weight: 600;
  cursor: pointer; transition: all 0.18s;
  font-family: 'Heebo', sans-serif;
}
.admin-logout-btn:hover { background: rgba(239,68,68,0.1); color: #ef4444; }

/* Main content area */
.admin-main {
  flex: 1;
  display: flex; flex-direction: column;
  overflow: hidden;
}
.admin-topbar {
  padding: 16px 28px;
  border-bottom: 1px solid #1e2a42;
  background: #0d1117;
  display: flex; align-items: center; justify-content: space-between;
  flex-shrink: 0;
}
.admin-topbar-title {
  font-size: 18px; font-weight: 800;
  color: #e8edf5;
}
.admin-topbar-sub { font-size: 12px; color: #4a5568; margin-top: 2px; }
.admin-actions { display: flex; gap: 10px; align-items: center; }
.chat-style-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 13px; border-radius: 20px; cursor: pointer;
  font-size: 13px; font-family: 'Heebo', sans-serif;
  border: 1.5px solid rgba(255,255,255,0.1);
  background: rgba(255,255,255,0.03);
  color: #8896b0;
  transition: border-color .15s, background .15s, color .15s;
  user-select: none;
}
.chat-style-btn input { display: none; }
.chat-style-btn:has(input:checked) {
  border-color: #6366f1;
  background: rgba(99,102,241,0.15);
  color: #a5b4fc;
}
.admin-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px;
  border-radius: 9px;
  border: 1px solid #1e2a42;
  background: #161d2e;
  color: #e8edf5; font-size: 13px; font-weight: 600;
  cursor: pointer; transition: all 0.18s;
  font-family: 'Heebo', sans-serif;
}
.admin-btn:hover { border-color: #3b82f6; color: #60a5fa; }
.admin-btn.primary {
  background: linear-gradient(135deg, #3b82f6, #1d4ed8);
  border-color: transparent; color: #fff;
  box-shadow: 0 3px 12px rgba(59,130,246,0.3);
}
.admin-btn.primary:hover { transform: translateY(-1px); box-shadow: 0 6px 20px rgba(59,130,246,0.4); }
.admin-btn.danger { color: #ef4444; }
.admin-btn.danger:hover { border-color: #ef4444; background: rgba(239,68,68,0.1); }
.admin-btn.warning { color: #f97316; }
.admin-btn.warning:hover { border-color: #f97316; background: rgba(249,115,22,0.1); }
.admin-btn.success { color: #22c55e; }
.admin-btn.success:hover { border-color: #22c55e; background: rgba(34,197,94,0.1); }
.admin-btn:disabled { opacity: 0.55; cursor: not-allowed; pointer-events: none; transform: none !important; box-shadow: none !important; }
.admin-btn-spinner {
  display: inline-block; width: 13px; height: 13px;
  border: 2px solid currentColor; border-top-color: transparent;
  border-radius: 50%;
  animation: admin-spin 0.7s linear infinite;
  vertical-align: middle;
}
@keyframes admin-spin { to { transform: rotate(360deg); } }

/* ── Privacy policy textarea ─────────────────────────────── */
.privacy-clear-btn {
  position: absolute; top: 8px; right: 8px;
  width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  background: rgba(239,68,68,0.12);
  border: 1px solid rgba(239,68,68,0.25);
  border-radius: 6px;
  font-size: 14px; cursor: pointer;
  transition: background 0.18s, border-color 0.18s, transform 0.15s;
  z-index: 2;
}
.privacy-clear-btn:hover {
  background: rgba(239,68,68,0.28);
  border-color: rgba(239,68,68,0.55);
  transform: scale(1.1);
}
.privacy-policy-textarea::-webkit-scrollbar { width: 6px; }
.privacy-policy-textarea::-webkit-scrollbar-track {
  background: rgba(255,255,255,0.03);
  border-radius: 4px;
}
.privacy-policy-textarea::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, #3b82f6 0%, #6366f1 100%);
  border-radius: 4px;
}
.privacy-policy-textarea::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, #60a5fa 0%, #818cf8 100%);
}
.privacy-policy-textarea { scrollbar-width: thin; scrollbar-color: #6366f1 rgba(255,255,255,0.03); }

.admin-content {
  flex: 1; overflow-y: auto;
  padding: 24px 28px;
  overscroll-behavior: contain;
}

/* ===== OVERVIEW SECTION ===== */
.admin-overview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}
.admin-stat-card {
  background: #111622;
  border: 1px solid #1e2a42;
  border-radius: 14px;
  padding: 20px 18px;
}
.admin-stat-icon { font-size: 24px; margin-bottom: 10px; }
.admin-stat-num { font-size: 28px; font-weight: 800; color: #e8edf5; line-height: 1; }
.admin-stat-label { font-size: 12px; color: #8896b0; margin-top: 4px; }

/* Tree view */
.admin-tree {
  background: #111622;
  border: 1px solid #1e2a42;
  border-radius: 14px;
  overflow: hidden;
}
.admin-tree-header {
  padding: 14px 18px;
  border-bottom: 1px solid #1e2a42;
  font-size: 13px; font-weight: 700; color: #8896b0;
  letter-spacing: 0.5px;
}
.admin-tree-root {
  padding: 8px 0;
}
.tree-node {
  user-select: none;
}
.tree-node-row {
  display: flex; align-items: center;
  padding: 6px 16px;
  cursor: pointer;
  transition: background 0.15s;
  font-size: 13px;
  gap: 6px;
}
.tree-node-row:hover { background: #161d2e; }
.tree-node-row.tree-selected { background: rgba(59,130,246,0.12); color: #60a5fa; }
.tree-toggle { width: 16px; font-size: 10px; color: #4a5568; flex-shrink: 0; }
.tree-icon { font-size: 14px; flex-shrink: 0; }
.tree-label { flex: 1; color: #e8edf5; font-weight: 500; }
.tree-node-row:hover .tree-label { color: #e8edf5; }
.tree-badge {
  font-size: 10px; background: #1e2a42; border-radius: 8px; padding: 1px 7px;
  color: #8896b0;
}
.tree-children {
  padding-right: 18px;
  border-right: 1px dashed #1e2a42;
  margin-right: 24px;
  display: none;
}
.tree-children.open { display: block; }
.tree-edit-btn {
  opacity: 0;
  background: none;
  border: 1px solid #1e2a42;
  border-radius: 6px;
  color: #8896b0;
  font-size: 11px;
  padding: 2px 6px;
  cursor: pointer;
  transition: opacity 0.15s, background 0.15s, color 0.15s;
  flex-shrink: 0;
  line-height: 1.4;
}
.tree-node-row:hover .tree-edit-btn {
  opacity: 1;
}
.tree-edit-btn:hover {
  background: #1e2a42;
  color: #60a5fa;
  border-color: #3b82f6;
}

/* ===== ADMIN COMPONENT CLASSES (extracted from inline styles) ===== */

/* Section body wrapper - used as top-level content container per section */
.admin-section-body {
  padding: 24px 28px;
  max-width: 820px;
  margin: 0 auto;
  font-family: 'Heebo', sans-serif;
}

/* Form group wrapper - spacing between form fields */
.admin-edit-form {
  margin-bottom: 20px;
}

/* Section field label - uppercase colored heading above an input */
.admin-field-label {
  font-size: 12px;
  font-weight: 700;
  color: #6366f1;
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-bottom: 12px;
}

/* Empty / loading state message - centered muted text */
.admin-empty-msg {
  color: #4a5568;
  font-size: 13px;
  text-align: center;
  padding: 28px 0;
}

/* Flex row - horizontal stack with gap-8 */
.admin-flex-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Flex between - space-between header row with gap-16 */
.admin-flex-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

/* 2-column grid with gap-12 */
.admin-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

/* ===== LIST/EDIT SECTION ===== */
.admin-section-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px;
}
.admin-section-title {
  font-size: 16px; font-weight: 700; color: #e8edf5;
}
.admin-section-sub { font-size: 12px; color: #4a5568; }

.admin-list {
  display: flex; flex-direction: column; gap: 8px;
}
.admin-list-item {
  background: #111622;
  border: 1px solid #1e2a42;
  border-radius: 12px;
  padding: 14px 16px;
  display: flex; align-items: center; gap: 12px;
  transition: all 0.18s;
  cursor: grab;
}
.admin-list-item:hover { border-color: #2d3748; }
.admin-list-item.dragging { opacity: 0.4; cursor: grabbing; }
.admin-list-item.drag-over { border-color: #3b82f6; background: rgba(59,130,246,0.06); }
.drag-handle {
  color: #2d3748; font-size: 14px; cursor: grab; flex-shrink: 0;
  display: flex; flex-direction: column; gap: 3px;
}
.drag-handle span { width: 14px; height: 2px; background: currentColor; display: block; border-radius: 2px; }
.item-icon { font-size: 20px; flex-shrink: 0; min-width: 28px; text-align: center; }
.item-body { flex: 1; min-width: 0; }
.item-title { font-size: 14px; font-weight: 600; color: #e8edf5; }
.item-sub { font-size: 12px; color: #8896b0; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item-actions { display: flex; gap: 6px; flex-shrink: 0; }
.item-btn {
  width: 30px; height: 30px; border-radius: 7px;
  border: 1px solid #1e2a42;
  background: transparent;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: all 0.18s;
  font-size: 13px;
  color: #8896b0;
}
.item-btn:hover { border-color: #3b82f6; color: #60a5fa; background: rgba(59,130,246,0.1); }
.item-btn.del:hover { border-color: #ef4444; color: #ef4444; background: rgba(239,68,68,0.1); }
.item-tag {
  font-size: 10px; padding: 2px 8px; border-radius: 20px;
  background: #161d2e; border: 1px solid #1e2a42;
  color: #8896b0; flex-shrink: 0;
}
.item-tag.robot { border-color: rgba(59,130,246,0.3); color: #60a5fa; }
.item-tag.standing { border-color: rgba(34,197,94,0.3); color: #22c55e; }

/* ===== EDIT MODAL ===== */
#adminEditModal {
  display: none;
  position: fixed; inset: 0; z-index: 9600;
  background: rgba(10,13,20,0.88);
  backdrop-filter: blur(6px);
  align-items: center; justify-content: center;
  padding: 20px;
}
#adminEditModal.open { display: flex; animation: adminFadeIn 0.25s ease; }
.admin-modal-box {
  background: #111622;
  border: 1px solid #1e2a42;
  border-radius: 18px;
  padding: 28px 32px;
  width: 100%; max-width: 560px;
  max-height: 90vh; overflow-y: auto;
  overscroll-behavior: contain;
  box-shadow: 0 30px 80px rgba(0,0,0,0.7);
  animation: adminSlideIn 0.35s cubic-bezier(0.22,1,0.36,1);
}
.admin-modal-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 22px;
}
.admin-modal-title { font-size: 17px; font-weight: 800; color: #e8edf5; }
.admin-modal-close {
  width: 30px; height: 30px; border-radius: 7px;
  border: 1px solid #1e2a42; background: transparent;
  color: #8896b0; font-size: 15px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.18s;
}
.admin-modal-close:hover { border-color: #ef4444; color: #ef4444; }
.admin-field { margin-bottom: 16px; }
.admin-field label {
  display: block; font-size: 12px; font-weight: 700; color: #8896b0;
  margin-bottom: 6px; letter-spacing: 0.3px;
}
.admin-field input, .admin-field textarea, .admin-field select {
  width: 100%;
  background: #161d2e;
  border: 1px solid #1e2a42;
  border-radius: 9px;
  padding: 10px 13px;
  font-size: 14px; color: #e8edf5;
  font-family: 'Heebo', sans-serif;
  transition: border-color 0.18s;
  direction: rtl;
}
.admin-field input:focus, .admin-field textarea:focus, .admin-field select:focus {
  outline: none; border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59,130,246,0.12);
}
.admin-field textarea { resize: vertical; min-height: 80px; scrollbar-width: thin; scrollbar-color: #1e2a42 transparent; }
.admin-field textarea::-webkit-scrollbar { width: 4px; }
.admin-field textarea::-webkit-scrollbar-track { background: transparent; }
.admin-field textarea::-webkit-scrollbar-thumb { background: #1e2a42; border-radius: 4px; }
#ui_welcomeIntervalDays::-webkit-inner-spin-button,
#ui_welcomeIntervalDays::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.admin-field select option { background: #161d2e; }
.admin-modal-footer {
  display: flex; gap: 10px; justify-content: flex-end;
  margin-top: 24px; padding-top: 20px;
  border-top: 1px solid #1e2a42;
}

/* Guide links editor */
.guides-editor { display: flex; flex-direction: column; gap: 8px; }
.guide-row {
  background: #161d2e;
  border: 1px solid #1e2a42;
  border-radius: 9px;
  padding: 10px 12px;
  display: flex; flex-direction: column; gap: 0;
  transition: border-color .15s, opacity .15s;
}
.guide-row.dragging { opacity: 0.4; cursor: grabbing; }
.guide-row.drag-over { border-color: #3b82f6; background: rgba(59,130,246,0.05); }
.ci-card.ci-dragging { opacity: 0.35; cursor: grabbing; transform: scale(0.98); }
.ci-card.ci-drag-over { outline: 2px solid #6366f1; outline-offset: -2px; }
.guide-row-top { display: flex; gap: 8px; align-items: flex-start; }
.guide-row-drag {
  color: #2d3748; cursor: grab; flex-shrink: 0; padding-top: 6px;
  display: flex; flex-direction: column; gap: 3px;
  transition: color .15s;
}
.guide-row-drag:hover { color: #6366f1; }
.guide-row-drag span { width: 13px; height: 2px; background: currentColor; display: block; border-radius: 2px; }
.guide-row-fields { flex: 1; display: flex; flex-direction: column; gap: 6px; }
.guide-row-fields input { font-size: 12px; padding: 6px 10px; }
.g-icon { width: 46px !important; text-align: center !important; font-size: 18px !important; padding: 4px 2px !important; border-color: rgba(251,191,36,0.4) !important; cursor: text; }
.g-icon:focus { border-color: rgba(251,191,36,0.8) !important; }
.guide-row-models {
  border-top: 1px solid #1e2a42;
  margin-top: 10px; padding-top: 10px;
}
.guide-row-models-label { font-size:11px; color:#8896b0; margin-bottom:6px; }
.guide-row-del {
  width: 28px; height: 28px; border-radius: 6px;
  border: 1px solid #2d3748; background: transparent;
  color: #4a5568; cursor: pointer; transition: all 0.18s;
  font-size: 13px; flex-shrink: 0;
}
.guide-row-del:hover { border-color: #ef4444; color: #ef4444; background: rgba(239,68,68,0.1); }
.guide-row-eye {
  width: 28px; height: 28px; border-radius: 6px;
  border: 1px solid #2d3748; background: transparent;
  color: #4a5568; cursor: pointer; transition: all 0.18s;
  font-size: 13px; flex-shrink: 0;
}
.guide-row-eye:hover { border-color: #3b82f6; color: #60a5fa; background: rgba(59,130,246,0.1); }
.add-guide-btn {
  padding: 7px 14px;
  background: transparent; border: 1px dashed #2d3748;
  border-radius: 8px; color: #4a5568; font-size: 12px; font-weight: 600;
  cursor: pointer; transition: all 0.18s; font-family: 'Heebo', sans-serif;
  width: 100%; margin-top: 4px;
}
.add-guide-btn:hover { border-color: #3b82f6; color: #60a5fa; }

/* Mini model chips - guide rows */
.guide-model-chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 8px; border-radius: 6px;
  background: transparent; border: 1px solid #1e2a42;
  cursor: pointer; font-size: 11px; color: #4a5568;
  font-family: 'Heebo', sans-serif; font-weight: 500;
  transition: border-color .12s, background .12s, color .12s;
  user-select: none;
}
.guide-model-chip:hover { border-color: #4f46e5; color: #a5b4fc; }
.guide-model-chip.active { background: rgba(99,102,241,0.1); border-color: #6366f1; color: #c7d2fe; }
.guide-model-chip input[type="checkbox"] { position: absolute; opacity: 0; width: 0; height: 0; }

/* Model chips (problem edit) */
.model-chip {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 7px 13px;
  background: #0d1424; border: 1px solid #1e2a42; border-radius: 9px;
  cursor: pointer; font-size: 13px; color: #8896b0;
  font-family: 'Heebo', sans-serif; font-weight: 500;
  transition: border-color .15s, background .15s, color .15s;
  user-select: none;
}
.model-chip:hover { border-color: #4f46e5; color: #c7d2fe; }
.model-chip.active { background: rgba(99,102,241,0.12); border-color: #6366f1; color: #e8edf5; }
.model-chip input[type="checkbox"] { position: absolute; opacity: 0; width: 0; height: 0; }
.model-chip-icon { font-size: 16px; opacity: .5; transition: opacity .15s; }
.model-chip.active .model-chip-icon { opacity: 1; }
.model-chip-check {
  width: 15px; height: 15px; border-radius: 4px;
  border: 1.5px solid #2d3748; background: transparent;
  display: flex; align-items: center; justify-content: center;
  font-size: 9px; color: transparent; flex-shrink: 0;
  transition: all .15s;
}
.model-chip.active .model-chip-check { background: #6366f1; border-color: #6366f1; color: #fff; }

/* ===== BUILD WARNING BANNER ===== */
#adminBuildWarning {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: linear-gradient(90deg, #7f1d1d 0%, #991b1b 40%, #7f1d1d 100%);
  color: #fecaca;
  padding: 14px 24px;
  display: none;
  align-items: center;
  justify-content: center;
  gap: 12px;
  z-index: 10001;
  box-shadow: 0 -4px 32px rgba(127,29,29,0.7);
  border-top: 1px solid #450a0a;
}
#adminBuildWarning.show { display: flex; animation: adminBuildWarningSlideUp 0.4s cubic-bezier(0.34,1.56,0.64,1) both; }
#adminBuildWarning .bw-icon {
  font-size: 22px;
  animation: adminBuildWarningPulse 1.2s ease-in-out infinite;
  flex-shrink: 0;
}
#adminBuildWarning .bw-text {
  font-size: 14px; font-weight: 700;
  font-family: Heebo, sans-serif;
  line-height: 1.4; text-align: center;
}
#adminBuildWarning .bw-sub {
  font-size: 11px; font-weight: 400;
  opacity: 0.85; display: block; margin-top: 2px;
}
#adminBuildWarning .bw-spinner {
  width: 18px; height: 18px;
  border: 2.5px solid rgba(255,255,255,0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: admin-spin 0.8s linear infinite;
  flex-shrink: 0;
}
@keyframes adminBuildWarningSlideUp {
  from { transform: translateY(100%); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}
@keyframes adminBuildWarningPulse {
  0%, 100% { transform: scale(1);    opacity: 1; }
  50%       { transform: scale(1.18); opacity: 0.75; }
}

/* ===== AI CREDIT WARNING BUBBLE ===== */
.ai-credit-warning {
  display: flex;
  align-items: center;
  gap: 10px;
  background: linear-gradient(135deg, #1c1407 0%, #2a1e08 100%);
  border: 1px solid #92400e;
  border-inline-start: 4px solid #f59e0b;
  color: #fde68a;
  padding: 12px 16px;
  border-radius: 10px;
  margin-bottom: 18px;
  font-size: 13px;
  font-family: Heebo, sans-serif;
  animation: chatMsgIn 0.3s ease;
  box-shadow: 0 2px 12px rgba(245,158,11,0.15);
}
.ai-credit-icon { font-size: 18px; flex-shrink: 0; }
.ai-credit-text { flex: 1; line-height: 1.5; }
.ai-credit-link {
  background: none; border: none; padding: 0;
  color: #fbbf24; font-weight: 700; font-size: 13px;
  cursor: pointer; text-decoration: underline;
  font-family: inherit;
}
.ai-credit-link:hover { color: #fde68a; }
.ai-credit-close {
  background: none; border: none;
  color: #92400e; font-size: 14px; cursor: pointer;
  padding: 2px 6px; border-radius: 4px;
  line-height: 1; flex-shrink: 0;
  transition: color 0.15s, background 0.15s;
}
.ai-credit-close:hover { color: #fbbf24; background: rgba(245,158,11,0.1); }

/* ===== TOAST ===== */
#adminToast {
  position: fixed;
  bottom: 28px; left: 50%; transform: translateX(-50%) translateY(12px);
  background: linear-gradient(135deg, #0f172a, #1e293b);
  color: #e2e8f0;
  padding: 11px 22px 11px 18px;
  border-radius: 12px;
  border: 1px solid rgba(99,102,241,0.35);
  font-size: 13px; font-weight: 600;
  font-family: Heebo, sans-serif;
  letter-spacing: 0.01em;
  z-index: 100001;
  display: none;
  opacity: 0;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5), 0 0 0 1px rgba(99,102,241,0.1);
  animation: adminToastIn 0.25s cubic-bezier(0.34,1.56,0.64,1) forwards;
  white-space: nowrap;
  backdrop-filter: blur(8px);
}
#adminToast.show { display: block; }
#adminToast.show::before {
  content: '';
  display: inline-block;
  width: 7px; height: 7px;
  background: #6ee7b7;
  border-radius: 50%;
  margin-left: 8px;
  vertical-align: middle;
  box-shadow: 0 0 6px #6ee7b7;
}
#adminToast.error {
  border-color: rgba(239,68,68,0.4);
  box-shadow: 0 8px 32px rgba(0,0,0,0.5), 0 0 0 1px rgba(239,68,68,0.15);
}
#adminToast.error::before { background: #f87171; box-shadow: 0 0 6px #f87171; }
@keyframes adminToastIn {
  from { opacity:0; transform:translateX(-50%) translateY(12px); }
  to   { opacity:1; transform:translateX(-50%) translateY(0); }
}

/* ===== CONFIRM DIALOG ===== */
#adminConfirm {
  display: none;
  position: fixed; inset: 0; z-index: 100002;
  background: rgba(10,13,20,0.88);
  align-items: center; justify-content: center;
}
#adminConfirm.open { display: flex; }
.admin-confirm-box {
  background: #111622;
  border: 1px solid #1e2a42;
  border-radius: 16px;
  padding: 28px 32px;
  max-width: 380px; width: 100%;
  text-align: center;
  box-shadow: 0 30px 80px rgba(0,0,0,0.7);
  animation: adminSlideIn 0.3s cubic-bezier(0.22,1,0.36,1);
}
.admin-confirm-icon { font-size: 36px; margin-bottom: 12px; }
.admin-confirm-title { font-size: 17px; font-weight: 800; color: #e8edf5; margin-bottom: 8px; }
.admin-confirm-sub { font-size: 13px; color: #8896b0; margin-bottom: 22px; }
.admin-confirm-btns { display: flex; gap: 10px; justify-content: center; }
.admin-confirm-box.wide { max-width: 500px; }
.tp-sum-list { display: flex; flex-direction: column; gap: 7px; margin-bottom: 16px; text-align: right; }
.tp-sum-row { display: flex; align-items: center; gap: 8px; font-size: 13px; color: #c8d4e8; background: rgba(255,255,255,0.04); border-radius: 8px; padding: 7px 12px; }
.tp-sum-row span { margin-right: auto; font-weight: 700; font-size: 12px; }
.tp-sum-ok { color: #22c55e; }
.tp-sum-err { color: #f87171; }
.tp-sum-tip { font-size: 12px; color: #6b7fa3; background: rgba(99,102,241,0.08); border-radius: 8px; padding: 10px 14px; text-align: right; line-height: 1.6; }
.tp-sum-link { color: #818cf8; text-decoration: underline; cursor: pointer; }

/* ===== SEARCH BAR ===== */
.admin-search-wrap { position: relative; margin-bottom: 16px; }
.admin-search-input {
  width: 100%;
  background: #111622;
  border: 1px solid #1e2a42;
  border-radius: 10px;
  padding: 10px 14px 10px 36px;
  font-size: 13px; color: #e8edf5;
  font-family: 'Heebo', sans-serif;
  direction: rtl;
  transition: border-color 0.18s;
}
.admin-search-input:focus { outline: none; border-color: #3b82f6; }
.admin-search-icon {
  position: absolute;
  left: 12px; top: 50%; transform: translateY(-50%);
  color: #4a5568; font-size: 14px;
  pointer-events: none;
}

/* Scrollbar */
.admin-content::-webkit-scrollbar,
.admin-modal-box::-webkit-scrollbar,
.admin-sidebar::-webkit-scrollbar { width: 4px; }
.admin-content::-webkit-scrollbar-track,
.admin-modal-box::-webkit-scrollbar-track,
.admin-sidebar::-webkit-scrollbar-track { background: transparent; }
.admin-content::-webkit-scrollbar-thumb,
.admin-modal-box::-webkit-scrollbar-thumb,
.admin-sidebar::-webkit-scrollbar-thumb { background: #1e2a42; border-radius: 4px; }

/* Tabs */
.admin-tabs {
  display: flex; gap: 4px; margin-bottom: 18px;
  background: #0d1117;
  border: 1px solid #1e2a42;
  border-radius: 10px;
  padding: 4px;
}
.admin-tab {
  flex: 1; text-align: center;
  padding: 7px 10px;
  border-radius: 7px;
  font-size: 12px; font-weight: 600; color: #8896b0;
  cursor: pointer; transition: all 0.18s;
  border: none; background: none;
  font-family: 'Heebo', sans-serif;
}
.admin-tab.active { background: #1e2a42; color: #e8edf5; }
.admin-tab:hover:not(.active) { color: #e8edf5; }

/* Responsive */
@media (max-width: 700px) {
  .admin-sidebar { width: 200px; }
  .admin-content { padding: 16px; }
  .admin-topbar { padding: 12px 16px; }
  .admin-modal-box { padding: 20px; }
}
/* Mobile nav backdrop */
.admin-nav-backdrop {
  display: none;
  position: fixed; inset: 0; z-index: 9499;
  background: rgba(0,0,0,0.55);
  animation: adminFadeIn 0.2s ease;
}
.admin-nav-backdrop.visible { display: block; }

/* Mobile hamburger button - hidden on desktop */
.admin-mobile-menu-btn {
  display: none;
  background: none; border: none; color: #8896b0; cursor: pointer;
  padding: 6px 8px; border-radius: 6px; font-size: 22px; line-height: 1;
  align-items: center; justify-content: center;
  transition: color 0.15s;
}
.admin-mobile-menu-btn:hover { color: #e8edf5; }

@media (max-width: 500px) {
  .admin-mobile-menu-btn { display: flex; }

  .admin-sidebar {
    position: fixed; top: 0; right: -270px; bottom: 0;
    width: 260px; z-index: 9500;
    transition: right 0.28s cubic-bezier(.4,0,.2,1);
    display: flex; flex-direction: column;
  }
  .admin-sidebar.mobile-open { right: 0; }

  .admin-topbar { padding: 10px 14px; }
  .admin-content { padding: 14px; }
  .admin-modal-box { padding: 18px; margin: 10px; }
}

/* ===== SYSTEM SETTINGS & LEARNING - MOBILE ===== */
@media (max-width: 600px) {
  .sys-settings-wrap,
  .learn-page-wrap {
    padding: 12px 10px !important;
  }

  /* AI engine grid - single column */
  .sys-engine-grid {
    grid-template-columns: 1fr !important;
  }

  /* Test connection row - wrap */
  .sys-test-row {
    flex-wrap: wrap;
    gap: 8px;
  }

  /* Cache & token action buttons - wrap into 2×2 */
  .sys-cache-actions,
  .sys-token-actions {
    flex-wrap: wrap;
    gap: 5px !important;
  }
  .sys-token-actions > button {
    flex: 1 1 calc(50% - 5px);
    justify-content: center;
  }

  /* Learning - source cards stack vertically */
  .learn-sources-grid {
    grid-template-columns: 1fr !important;
  }

  /* Learning - sitemap header wraps toggle below title */
  .learn-sitemap-header {
    flex-wrap: wrap;
  }

  /* Feedback & examples - smaller max-height on mobile (when not expanded) */
  #learn_feedback_table_wrap:not([data-expanded="1"]) {
    max-height: 220px !important;
  }
  #learn_examples_list_wrap:not([data-expanded="1"]) {
    max-height: 200px !important;
  }

  /* Learning - chat input: textarea on top, buttons below */
  .learn-chat-input {
    flex-direction: column !important;
  }
  .learn-chat-btns {
    flex-direction: row !important;
    align-self: stretch !important;
    gap: 8px !important;
  }
  .learn-chat-btns > button {
    flex: 1;
  }
}

/* ===== CHATBOT WIDGET ===== */
#chatBtn {
  position: fixed;
  bottom: 28px;
  right: 28px;
  width: 58px; height: 58px;
  border-radius: 50%;
  background: linear-gradient(135deg, #3b82f6 0%, #6366f1 100%);
  color: #fff;
  border: none;
  cursor: grab;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 24px rgba(99,102,241,0.55);
  z-index: 8100;
  transition: transform 0.2s, box-shadow 0.2s, background 0.3s;
  padding: 0;
}
#chatBtn:hover  { transform: scale(1.1); box-shadow: 0 6px 32px rgba(99,102,241,0.7); }
#chatBtn:active { cursor: grabbing !important; transform: scale(0.97); }
#chatBtn.open   { background: linear-gradient(135deg, #3b4fd8 0%, #5048c8 100%); }
#chatBtn.btn-chat-hidden { display: none; }

.chat-badge {
  position: absolute; top: 3px; right: 3px;
  width: 19px; height: 19px;
  background: #ef4444; border-radius: 50%;
  font-size: 11px; font-weight: 800; color: #fff;
  display: flex; align-items: center; justify-content: center;
  pointer-events: none; border: 2px solid var(--bg, #0a0d14);
}

.chat-panel {
  position: fixed;
  bottom: 90px; right: 22px;
  width: 360px; height: 520px;
  background: var(--surface, #111622);
  border: 1px solid var(--border, #1e2a42);
  border-radius: 18px 18px 0 0;
  display: flex; flex-direction: column;
  box-shadow: 0 24px 64px rgba(0,0,0,0.55), 0 0 0 1px rgba(255,255,255,0.04);
  z-index: 8099;
  overflow: hidden;
  transform: scale(0.9) translateY(24px);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.28s cubic-bezier(0.22,1,0.36,1), opacity 0.22s, height 0.25s ease;
  transform-origin: bottom right;
}
.chat-panel.open {
  transform: scale(1) translateY(0);
  opacity: 1;
  pointer-events: all;
  bottom: 0;
  right: 22px;
  z-index: 9950;
}
body:has(.chat-panel.open) #chatBtn { z-index: 9951; }
.chat-panel.chat-expanded {
  height: 100dvh !important;
  border-radius: 18px 18px 0 0 !important;
}
.chat-panel.chat-snap-left {
  right: auto; left: 0; bottom: 0;
  border-radius: 0 18px 0 0;
  height: 100dvh; width: 360px;
  transform-origin: bottom left;
}
.chat-panel.chat-snap-right {
  right: 0; bottom: 0;
  border-radius: 18px 0 0 0;
  height: 100dvh; width: 360px;
  transform-origin: bottom right;
}

.chat-panel-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border, #1e2a42);
  background: var(--surface2, #161d2e);
  cursor: grab;
  user-select: none;
  flex-shrink: 0;
}
.chat-panel-header:active { cursor: grabbing; }
.chat-panel.chat-snap-left .chat-panel-header,
.chat-panel.chat-snap-right .chat-panel-header { cursor: default; }

.chat-header-left { display: flex; align-items: center; gap: 10px; }
.chat-header-icon  {
  font-size: 24px;
  width: 38px; height: 38px;
  border-radius: 50%;
  overflow: hidden;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  background: var(--surface2, #161d2e);
  border: 1px solid var(--border, #1e2a42);
}
.chat-header-icon:has(img) { background: none; border-color: transparent; }
.chat-header-icon img { width: 100%; height: 100%; object-fit: cover; display: block; }
.chat-header-title { font-size: 14px; font-weight: 700; color: var(--text, #e8edf5); }
.chat-header-sub   { font-size: 11px; color: var(--text-muted, #8896b0); margin-top: 1px; }

.chat-header-actions { display: flex; gap: 6px; align-items: center; }
.chat-action-btn {
  background: none; border: 1px solid var(--border, #1e2a42);
  border-radius: 8px; color: var(--text-muted, #8896b0);
  width: 28px; height: 28px;
  font-size: 13px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s, color 0.15s;
}
.chat-action-btn:hover { background: var(--border, #1e2a42); color: var(--text, #e8edf5); }

.chat-messages {
  flex: 1; overflow-y: auto;
  padding: 14px 12px;
  display: flex; flex-direction: column; gap: 14px;
  scroll-behavior: smooth;
  overscroll-behavior: contain;
}
.chat-messages::-webkit-scrollbar { width: 4px; }
.chat-messages::-webkit-scrollbar-thumb { background: var(--border, #1e2a42); border-radius: 4px; }

.chat-msg {
  max-width: 84%; padding: 10px 13px;
  border-radius: 14px; font-size: 13px;
  line-height: 1.8; font-family: 'Heebo', sans-serif;
  word-break: break-word; white-space: pre-wrap;
  text-align: start;
  animation: chatMsgIn 0.2s ease;
}
@keyframes chatMsgIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.chat-msg[dir="rtl"] { padding-inline-start: 22px; }
.chat-msg.user {
  align-self: flex-start;
  background: linear-gradient(135deg, #3b82f6, #6366f1);
  color: #fff;
  border-radius: 14px 14px 4px 14px;
  display: flex; align-items: flex-start; gap: 8px;
}
.chat-user-icon {
  flex-shrink: 0;
  width: 22px; height: 22px;
  background: rgba(255,255,255,0.18);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; line-height: 1;
  margin-top: 1px;
}
.chat-user-body { flex: 1; display: flex; flex-direction: column; }
.chat-user-text { flex: 1; }
.chat-msg.bot {
  align-self: flex-end;
  background: var(--surface2, #161d2e);
  color: var(--text, #e8edf5);
  border: 1px solid var(--border, #1e2a42);
  border-radius: 14px 14px 14px 4px;
}

.chat-bot-row {
  display: flex;
  direction: ltr;
  align-items: flex-end;
  gap: 8px;
  align-self: flex-end;
  max-width: 88%;
}
.chat-bot-row .chat-msg.bot {
  align-self: auto;
  max-width: 100%;
}
.chat-bot-avatar {
  flex-shrink: 0;
  width: 30px; height: 30px;
  border-radius: 50%;
  overflow: hidden;
  display: flex; align-items: center; justify-content: center;
  background: var(--surface2, #161d2e);
  border: 1px solid var(--border, #1e2a42);
  font-size: 17px; line-height: 1;
}
.chat-bot-avatar:has(img) { background: none; border-color: transparent; }
.chat-bot-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.chat-msg.error {
  align-self: center;
  background: rgba(239,68,68,0.1);
  border: 1px solid rgba(239,68,68,0.25);
  color: #fca5a5;
  font-size: 12px; border-radius: 10px; max-width: 92%;
}

.chat-typing {
  padding: 6px 16px 2px;
  display: flex; align-items: center; gap: 5px;
  justify-content: flex-end;
}
.chat-typing span {
  width: 7px; height: 7px;
  background: var(--accent, #3b82f6);
  border-radius: 50%; opacity: 0.4;
  animation: chatBounce 1.2s infinite;
}
.chat-typing span:nth-child(2) { animation-delay: 0.2s; }
.chat-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes chatBounce {
  0%,60%,100% { transform: translateY(0); opacity: 0.4; }
  30%          { transform: translateY(-6px); opacity: 1; }
}

.chat-input-row {
  display: flex; gap: 8px; padding: 10px 12px;
  border-top: 1px solid var(--border, #1e2a42);
  background: var(--surface2, #161d2e);
  align-items: flex-end; flex-shrink: 0;
}
.chat-input {
  flex: 1;
  background: var(--surface, #111622);
  border: 1px solid var(--border, #1e2a42);
  border-radius: 10px;
  padding: 9px 12px; color: var(--text, #e8edf5);
  font-size: 13px; font-family: 'Heebo', sans-serif;
  resize: none; max-height: 100px; overflow-y: auto;
  transition: border-color 0.18s;
  line-height: 1.5;
}
.chat-input:focus { outline: none; border-color: var(--accent, #3b82f6); }
.chat-input::placeholder { color: var(--text-dim, #4a5568); }
.chat-input::-webkit-scrollbar { width: 4px; }
.chat-input::-webkit-scrollbar-track { background: transparent; }
.chat-input::-webkit-scrollbar-thumb { background: #2a3a58; border-radius: 4px; }
.chat-input { scrollbar-width: thin; scrollbar-color: #2a3a58 transparent; }

.chat-send-btn {
  width: 38px; height: 38px; flex-shrink: 0;
  background: linear-gradient(135deg, #3b82f6, #6366f1);
  border: none; border-radius: 10px;
  color: #fff; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: opacity 0.15s, transform 0.15s;
}
.chat-send-btn:hover   { opacity: 0.88; transform: scale(1.06); }
.chat-send-btn:disabled { opacity: 0.35; cursor: default; transform: none; }

#chatPrivacyBar label { color: #8896b0; }
#chatPrivacyBar label:hover { color: #c0cad8; }
html.light #chatPrivacyBar { background: var(--surface2) !important; border-top: 1px solid var(--border) !important; }
html.light #chatPrivacyBar label { color: var(--text-muted); }
html.light #chatPrivacyBar label:hover { color: var(--text); }
html.light #chatNewConfirm { background: rgba(200,212,232,0.88) !important; }
html.light #chatNewConfirm div[style*="color:#e8edf5"] { color: var(--text) !important; }
html.light #chatNewConfirm div[style*="color:#8896b0"] { color: var(--text-muted) !important; }
html.light #chatNewConfirm button[style*="#1e2a42"] { border-color: var(--border) !important; color: var(--text-muted) !important; }
#chatInputRow { transition: opacity 0.2s; }

.chat-stream-cursor {
  display: inline-block;
  position: relative;
  width: 7px; height: 7px;
  border-radius: 50%;
  background: #3b82f6;
  margin: 0 10px 1px 16px;
  vertical-align: middle;
  animation: thinking-bounce 1.3s ease-in-out infinite;
  animation-delay: 0.26s;
}
.chat-stream-cursor::before,
.chat-stream-cursor::after {
  content: '';
  position: absolute;
  top: 0;
  width: 7px; height: 7px;
  border-radius: 50%;
  background: #3b82f6;
}
.chat-stream-cursor::before {
  left: -12px;
  animation: thinking-bounce 1.3s ease-in-out infinite;
  animation-delay: 0s;
}
.chat-stream-cursor::after {
  left: 12px;
  animation: thinking-bounce 1.3s ease-in-out infinite;
  animation-delay: 0.52s;
}
@keyframes thinking-bounce {
  0%, 65%, 100% { transform: translateY(0);    opacity: 0.35; }
  32%           { transform: translateY(-6px); opacity: 1;    }
}

.chat-msg-actions {
  display: flex; gap: 2px; margin-top: 12px;
  justify-content: flex-start;
}
.chat-question-block {
  display: flex; flex-direction: row; align-items: flex-start; gap: 8px;
  margin-top: 8px;
  padding: 10px 14px;
  border: 1px solid rgba(99,102,241,0.2);
  border-radius: 12px;
  background: rgba(99,102,241,0.05);
  color: var(--text, #e8edf5);
  font-size: 13px; line-height: 1.5;
}
.chat-question-intro {
  font-size: 12.5px;
  color: var(--text, #e8edf5);
  line-height: 1.5;
  margin-top: 16px;
  margin-bottom: 4px;
}
.chat-question-icon {
  display: inline-flex; align-items: center; flex-shrink: 0;
  font-size: 16px; line-height: 1; margin-top: 1px;
}
.chat-persist-msg {
  margin-top: 12px;
  font-size: 13px; line-height: 1.5;
  color: var(--text, #e8edf5);
  opacity: 0.8;
}
.chat-like-btn {
  background: none; border: none; padding: 3px 5px;
  font-size: 13px; cursor: pointer; opacity: 0.35;
  border-radius: 5px; transition: opacity 0.15s, transform 0.15s, background 0.15s;
  line-height: 1;
}
.chat-like-btn:hover:not(:disabled) { opacity: 0.75; transform: scale(1.2); }
.chat-like-btn.liked  { opacity: 1; background: rgba(99,102,241,0.15); }
.chat-like-btn.disliked { opacity: 1; background: rgba(239,68,68,0.12); }
.chat-like-btn.dim    { opacity: 0.12; }
.chat-like-btn:disabled { cursor: default; }

/* Goodbye / session-end rating card */
.chat-goodbye-card {
  margin: 16px 0 8px;
  padding: 18px 16px 14px;
  border-radius: 14px;
  background: linear-gradient(135deg, rgba(99,102,241,0.12), rgba(129,140,248,0.07));
  border: 1px solid rgba(99,102,241,0.25);
  text-align: center;
  animation: fadeInUp 0.35s ease;
}
@keyframes fadeInUp {
  from { opacity:0; transform:translateY(10px); }
  to   { opacity:1; transform:translateY(0);    }
}
.chat-goodbye-msg {
  font-size: 14px; line-height: 1.55;
  color: var(--text, #e8edf5);
  margin-bottom: 14px;
}
.chat-goodbye-rating-label {
  font-size: 12px; opacity: 0.65;
  margin-bottom: 8px;
}
.chat-stars-row {
  display: flex; justify-content: center; gap: 6px;
  margin-bottom: 14px;
}
.chat-star {
  background: none; border: none; padding: 2px;
  font-size: 26px; cursor: pointer; line-height: 1;
  color: #d1d5db;
  transition: color 0.15s, transform 0.15s;
  filter: drop-shadow(0 0 0 transparent);
}
.chat-star:hover, .chat-star.hover { color: #f59e0b; transform: scale(1.2); }
.chat-star.selected { color: #f59e0b; filter: drop-shadow(0 1px 4px rgba(245,158,11,0.5)); }
.chat-star:disabled { cursor: default; }
.chat-goodbye-thanks {
  font-size: 13px; color: #6366f1; font-weight: 600;
  margin-bottom: 12px; display: none;
}
.chat-goodbye-actions {
  display: flex; gap: 8px; justify-content: center; flex-wrap: wrap;
  margin-top: 4px;
}
.chat-goodbye-btn {
  padding: 7px 18px; border-radius: 8px; font-size: 13px;
  cursor: pointer; border: none; font-weight: 500;
  transition: opacity 0.15s, transform 0.12s;
}
.chat-goodbye-btn:hover { opacity: 0.85; transform: scale(1.03); }
.chat-goodbye-btn.primary {
  background: linear-gradient(135deg, #6366f1, #818cf8);
  color: #fff;
}
.chat-goodbye-btn.secondary {
  background: rgba(255,255,255,0.08);
  color: var(--text, #e8edf5);
  border: 1px solid rgba(255,255,255,0.15);
}
/* Locked state - hide input */
.chat-panel.chat-locked .chat-input-row { display: none !important; }

/* Copy button */
.chat-copy-btn {
  background: none; border: none; padding: 3px 5px;
  cursor: pointer; opacity: 0.35; border-radius: 5px;
  transition: opacity 0.15s, transform 0.15s, color 0.15s;
  line-height: 1; color: inherit; display: inline-flex; align-items: center;
}
.chat-copy-btn:hover { opacity: 0.75; transform: scale(1.1); }
.chat-msg.user .chat-copy-btn { color: rgba(255,255,255,0.8); }

/* TTS controls */
.chat-tts-controls { display: inline-flex; align-items: center; gap: 1px; }
.chat-tts-btn {
  background: none; border: none; padding: 3px 5px;
  cursor: pointer; opacity: 0.35; border-radius: 5px;
  transition: opacity 0.15s, transform 0.15s, background 0.15s, color 0.15s;
  line-height: 1; color: inherit; display: inline-flex; align-items: center;
}
.chat-tts-btn:hover { opacity: 0.75; transform: scale(1.1); }
/* כפתור עצור - hover אדמדם */
.tts-btn-stop:hover { color: #ef4444 !important; opacity: 0.85 !important; }
/* כפתורי השהיה/עצור - מוסתרים בברירת מחדל */
.chat-tts-controls .tts-btn-pause,
.chat-tts-controls .tts-btn-stop { display: none; }
/* מוצגים בזמן השמעה או השהיה */
.chat-tts-controls.tts-playing .tts-btn-pause,
.chat-tts-controls.tts-playing .tts-btn-stop,
.chat-tts-controls.tts-paused  .tts-btn-pause,
.chat-tts-controls.tts-paused  .tts-btn-stop { display: inline-flex; }
/* כפתור רמקול - active בזמן השמעה */
.chat-tts-controls.tts-playing .tts-btn-speak,
.chat-tts-controls.tts-paused  .tts-btn-speak { opacity: 1; color: #6366f1; }
.chat-tts-controls.tts-playing .tts-btn-speak { animation: tts-pulse 1.2s ease-in-out infinite; }
/* אייקון pause vs resume */
.tts-pause-icon  { display: inline-flex; }
.tts-resume-icon { display: none; }
.chat-tts-controls.tts-paused .tts-btn-pause .tts-pause-icon  { display: none; }
.chat-tts-controls.tts-paused .tts-btn-pause .tts-resume-icon { display: inline-flex; }
@keyframes tts-pulse { 0%,100% { opacity: 0.75; } 50% { opacity: 1; } }
/* בהודעות משתמש - צבע הפוך */
.chat-msg.user .chat-tts-btn { color: rgba(255,255,255,0.8); }
.chat-msg.user .chat-tts-controls.tts-playing .tts-btn-speak,
.chat-msg.user .chat-tts-controls.tts-paused  .tts-btn-speak { color: #fff; }
.chat-msg.user .chat-msg-actions { margin-top: 6px; }

@media (max-width: 500px) {
  .chat-panel { width: calc(100vw - 14px); right: 7px; bottom: 86px; height: 70dvh; }
  .chat-panel.open { bottom: 0; right: 0; width: 100vw; height: 100dvh; border-radius: 0; }
  #chatBtn    { bottom: 16px; right: 16px; }
  #chatCompactBtn, #chatSnapBtn { display: none; }
  body:has(.chat-panel.open) #adminGearBtn { display: none; }
  /* מניעת זום אוטומטי של iOS בעת פוקוס על שדה קלט */
  .chat-input { font-size: 16px; }
  /* רווח תחתון גדול יותר ב-footer לנייד - רק כשהצ'אט פתוח מסך מלא */
  .chat-panel.open .chat-input-row { padding-bottom: 24px; }
  @supports (padding-bottom: env(safe-area-inset-bottom)) {
    .chat-panel.open .chat-input-row { padding-bottom: calc(24px + env(safe-area-inset-bottom)); }
  }
}

/* ===== CHAT LTR POSITION (non-RTL languages) ===== */
body.chat-pos-ltr #adminGearBtn {
  left: auto;
  right: 20px;
}
body.chat-pos-ltr #chatBtn {
  right: auto;
  left: 28px;
}
body.chat-pos-ltr .chat-panel {
  right: auto;
  left: 22px;
  transform-origin: bottom left;
  border-radius: 18px 18px 0 0;
}
body.chat-pos-ltr .chat-panel.open {
  right: auto;
  left: 22px;
}
@media (max-width: 500px) {
  body.chat-pos-ltr .chat-panel      { left: 7px; right: auto; }
  body.chat-pos-ltr .chat-panel.open { left: 0;   right: auto; }
  body.chat-pos-ltr #chatBtn         { left: 16px; right: auto; }
}

/* ===== EXTRACTED INLINE STYLES ===== */

/* --- Maintenance overlay --- */
#maintenanceOverlay {
  display: none; position: fixed; inset: 0; z-index: 99999;
  align-items: center; justify-content: center;
  background: rgba(0,0,0,0.88); backdrop-filter: blur(10px);
  font-family: Heebo,sans-serif; direction: rtl;
}
#maintenanceOverlay > div {
  background: rgba(21,27,46,0.97); border: 1px solid rgba(255,255,255,0.09);
  border-radius: 22px; padding: 44px 52px; text-align: center;
  max-width: 340px; box-shadow: 0 30px 80px rgba(0,0,0,0.65);
}
#maintGear { font-size: 52px; display: inline-block; }
.maint-title { font-size: 21px; font-weight: 700; color: #fff; margin: 18px 0 8px; }
.maint-desc  { font-size: 14px; color: rgba(255,255,255,0.55); line-height: 1.7; }
.maint-dots  { display: flex; gap: 7px; justify-content: center; margin-top: 24px; }

/* --- Welcome overlay --- */
#welcomeOverlay { display: none; }

/* --- App root --- */
#app { opacity: 0; transition: opacity 0.5s ease; }

/* --- Preloader error state --- */
.preloader-error-wrap  { color: #e8edf5; text-align: center; font-family: Heebo,sans-serif; padding: 40px; }
.preloader-error-icon  { font-size: 48px; margin-bottom: 16px; }
.preloader-error-title { font-size: 20px; margin-bottom: 8px; font-weight: 700; }
.preloader-error-desc  { color: #8896b0; font-size: 14px; }
.preloader-error-btn   {
  margin-top: 20px; padding: 10px 24px;
  background: #3b82f6; color: #fff; border: none;
  border-radius: 8px; font-size: 14px; cursor: pointer; font-family: inherit;
}

/* --- Problem grid inner elements --- */
.prob-title       { flex: 1; font-size: 14px; font-weight: 600; color: var(--text); }
.prob-title-muted { flex: 1; font-size: 14px; font-weight: 600; color: var(--text-muted); }
.prob-arrow       { font-size: 14px; color: var(--text-dim); }

/* --- Language switcher emoji flag --- */
.lang-emoji-flag { font-size: 18px; line-height: 1; flex-shrink: 0; }

/* --- Chat: new-chat confirm dialog --- */
#chatNewConfirm {
  display: none; position: absolute; inset: 0;
  background: rgba(8,11,22,0.82); backdrop-filter: blur(4px);
  z-index: 20; border-radius: 18px;
  align-items: center; justify-content: center; flex-direction: column; gap: 14px;
}
.chat-confirm-icon    { font-size: 22px; line-height: 1; }
.chat-confirm-title   { font-size: 15px; font-weight: 700; color: #e8edf5; }
.chat-confirm-desc    { font-size: 12px; color: #8896b0; text-align: center; padding: 0 20px; }
.chat-confirm-actions { display: flex; gap: 8px; margin-top: 4px; }
.chat-confirm-ok {
  padding: 8px 20px; border-radius: 8px; border: none;
  background: linear-gradient(135deg,#3b82f6,#6366f1);
  color: #fff; font-size: 13px; font-weight: 600; cursor: pointer; font-family: inherit;
}
.chat-confirm-cancel {
  padding: 8px 16px; border-radius: 8px;
  border: 1px solid #1e2a42; background: transparent;
  color: #8896b0; font-size: 13px; cursor: pointer; font-family: inherit;
}

/* --- Chat: privacy bar --- */
#chatPrivacyBar {
  display: none; padding: 10px 14px;
  border-top: 1px solid rgba(255,255,255,0.06);
  background: rgba(10,11,22,0.6); flex-shrink: 0;
}
#chatPrivacyBar label {
  display: flex; align-items: flex-start; gap: 9px;
  cursor: pointer; font-size: 12px; line-height: 1.5;
}
#chatPrivacyBar input[type="checkbox"] {
  width: 15px; height: 15px; margin-top: 2px;
  cursor: pointer; accent-color: #6366f1; flex-shrink: 0;
}
.chat-privacy-link-btn {
  background: none; border: none; padding: 0;
  color: #60a5fa; text-decoration: underline;
  cursor: pointer; font-size: 12px; font-family: inherit;
}

/* --- Chat: privacy popup --- */
#chatPrivacyPopup {
  display: none; position: absolute; inset: 0;
  background: rgba(8,11,22,0.85); backdrop-filter: blur(6px);
  z-index: 25; border-radius: 18px 18px 0 0;
  align-items: flex-end; justify-content: center;
}
.chat-privacy-popup-inner {
  width: 100%; background: var(--surface2,#161d2e);
  border-top: 1px solid rgba(99,102,241,0.25);
  border-radius: 18px 18px 0 0; padding: 20px 20px 24px;
  max-height: 75%; display: flex; flex-direction: column; gap: 12px;
}
.chat-privacy-popup-header { display: flex; align-items: center; justify-content: space-between; }
.chat-privacy-popup-title  { font-size: 14px; font-weight: 700; color: #e8edf5; }
.chat-privacy-popup-close  {
  background: none; border: none; color: #8896b0;
  font-size: 18px; cursor: pointer; line-height: 1; padding: 2px 6px;
}
#chatPrivacyText { font-size: 12px; color: #8896b0; line-height: 1.7; overflow-y: auto; flex: 1; white-space: pre-wrap; scrollbar-width: thin; scrollbar-color: #2a3a58 transparent; }
#chatPrivacyText::-webkit-scrollbar { width: 4px; }
#chatPrivacyText::-webkit-scrollbar-track { background: transparent; }
#chatPrivacyText::-webkit-scrollbar-thumb { background: #2a3a58; border-radius: 4px; }

/* --- _renderMarkdown generated elements --- */
.chat-code {
  background: rgba(255,255,255,0.08); padding: 1px 5px;
  border-radius: 4px; font-size: 12px; font-family: monospace;
}
.chat-ol { margin: 4px 0; padding-inline-start: 22px; list-style-type: decimal; white-space: normal; }
.chat-ul { margin: 4px 0; padding-inline-start: 20px; list-style-type: disc; white-space: normal; }
.chat-ol li, .chat-ul li { margin-bottom: 2px; line-height: 1.5; white-space: normal; }
.chat-list-title { display: block; margin-bottom: 2px; margin-top:5px }
.chat-bold-title { display: block; margin-bottom: 0px; margin-top:10px}
.chat-link-raw { word-break: break-all; color: var(--chat-link-color, #f97316); }
.chat-link-fmt { text-decoration: underline; text-underline-offset: 2px; font-weight: 600; color: var(--chat-link-color, #f97316); }

/* ===== LANGUAGE SWITCHER ===== */
.lang-switcher {
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

.lang-pills {
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.13);
  border-radius: 26px;
  padding: 4px 5px;
  backdrop-filter: blur(6px);
  direction: ltr;
}

html.light .lang-pills {
  background: rgba(0,0,0,0.06);
  border-color: rgba(0,0,0,0.12);
}

.lang-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 5px 7px;
  border-radius: 18px;
  border: 1.5px solid transparent;
  background: transparent;
  cursor: pointer;
  transition: all 0.18s ease;
  position: relative;
  user-select: none;
  flex-shrink: 0;
}

/* SVG Flag icon */
.lang-flag-icon {
  width: 22px !important;
  height: 16px !important;
  border-radius: 3px;
  display: block;
  box-shadow: 0 1px 3px rgba(0,0,0,0.35);
  object-fit: cover;
  overflow: hidden;
  flex-shrink: 0;
}

/* Short language code label */
.lang-code {
  font-size: 9px;
  font-weight: 700;
  font-family: 'Heebo', 'Arial', sans-serif;
  color: rgba(255,255,255,0.65);
  line-height: 1;
  letter-spacing: 0.3px;
  transition: color 0.18s;
}

html.light .lang-code {
  color: rgba(0,0,0,0.5);
}

.lang-btn:hover {
  background: rgba(255,255,255,0.12);
  transform: translateY(-1px);
}

.lang-btn:hover .lang-code {
  color: #fff;
}

html.light .lang-btn:hover {
  background: rgba(0,0,0,0.08);
}
html.light .lang-btn:hover .lang-code {
  color: #000;
}

.lang-btn.active {
  background: linear-gradient(135deg, rgba(59,130,246,0.3), rgba(99,102,241,0.25));
  border-color: rgba(99,102,241,0.55);
  box-shadow: 0 0 0 2px rgba(99,102,241,0.2), 0 2px 8px rgba(59,130,246,0.2);
}

.lang-btn.active .lang-code {
  color: #93c5fd;
  font-weight: 800;
}

html.light .lang-btn.active {
  background: linear-gradient(135deg, rgba(37,99,235,0.15), rgba(99,102,241,0.12));
  border-color: rgba(37,99,235,0.4);
}
html.light .lang-btn.active .lang-code {
  color: #1d4ed8;
}

/* Tooltip */
.lang-btn::after {
  content: attr(title);
  position: absolute;
  top: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 11px;
  font-weight: 600;
  font-family: 'Heebo', sans-serif;
  white-space: nowrap;
  padding: 4px 9px;
  border-radius: 7px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s;
  z-index: 200;
  box-shadow: 0 4px 14px rgba(0,0,0,0.35);
}

.lang-btn:hover::after {
  opacity: 1;
}

/* Desktop: pills visible, dropdown hidden */
.lang-pills { display: flex; align-items: center; gap: 2px; }
.lang-dropdown-wrap { display: none; position: relative; }

/* Compact pills on medium screens */
@media (max-width: 700px) {
  .lang-btn { padding: 4px 5px; gap: 1px; }
  .lang-flag-icon { width: 19px !important; height: 14px !important; }
  .lang-code { font-size: 8px; }
  .lang-btn::after { display: none; }
}

/* Mobile: hide pills, show dropdown */ 
@media (max-width: 680px) {
  .lang-pills { display: none; }
  .lang-dropdown-wrap { display: block; }
}

/* ===== LANG DROPDOWN ===== */
.lang-dropdown-trigger {
  display: flex; align-items: center; gap: 6px;
  padding: 5px 10px 5px 8px;
  border-radius: 20px;
  border: 1.5px solid rgba(255,255,255,0.18);
  background: rgba(255,255,255,0.07);
  cursor: pointer;
  color: #e8edf5;
  font-size: 12px; font-weight: 700;
  backdrop-filter: blur(6px);
  transition: background 0.15s, border-color 0.15s;
  white-space: nowrap;
}
.lang-dropdown-trigger:hover {
  background: rgba(255,255,255,0.13);
  border-color: rgba(99,102,241,0.5);
}
html.light .lang-dropdown-trigger {
  border-color: rgba(0,0,0,0.15);
  background: rgba(0,0,0,0.05);
  color: #1a1a2e;
}
.lang-dropdown-label { font-size: 11px; font-weight: 800; letter-spacing: 0.3px; }
.lang-dropdown-arrow { font-size: 10px; opacity: 0.7; transition: transform 0.2s; }
.lang-dropdown-wrap.open .lang-dropdown-arrow { transform: rotate(180deg); }

.lang-dropdown-menu {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 160px;
  background: var(--surface2, #161d2e);
  border: 1px solid var(--border, #1e2a42);
  border-radius: 12px;
  box-shadow: 0 8px 28px rgba(0,0,0,0.45);
  padding: 6px;
  z-index: 9999;
  flex-direction: column;
  gap: 2px;
}
[dir="ltr"] .lang-dropdown-menu { right: auto; left: 0; }

.lang-dropdown-wrap.open .lang-dropdown-menu { display: flex; }

.lang-dropdown-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px;
  border-radius: 8px;
  border: none;
  background: transparent;
  cursor: pointer;
  color: var(--text, #e8edf5);
  font-size: 13px; font-weight: 600;
  font-family: 'Heebo', sans-serif;
  text-align: right;
  width: 100%;
  transition: background 0.12s;
}
.lang-dropdown-item:hover { background: rgba(255,255,255,0.08); }
.lang-dropdown-item.active {
  background: linear-gradient(135deg, rgba(59,130,246,0.25), rgba(99,102,241,0.2));
  color: #93c5fd;
}
html.light .lang-dropdown-item { color: #1a1a2e; }
html.light .lang-dropdown-item:hover { background: rgba(0,0,0,0.06); }
html.light .lang-dropdown-item.active { color: #1d4ed8; background: rgba(37,99,235,0.1); }

/* LTR layout adjustments - arrows handled via JS t('arrow') */

/* Font adjustments per language */
html[lang="ar"] body, html[lang="ar"] * { font-family: 'Noto Sans Arabic', 'Heebo', sans-serif; }
html[lang="zh"] body, html[lang="zh"] * { font-family: 'Noto Sans SC', 'Heebo', sans-serif; }

/* ===== UTILITY CLASSES ===== */
/* hidden state - use classList.add/remove('hidden') instead of style.display */
.hidden { display: none !important; }

/* problem dot - gold highlight variant */
.prob-dot--gold { background: var(--gold); box-shadow: 0 0 6px rgba(245,158,11,0.5); }

/* guide link - secondary/dashed variant (e.g. "all guides" link) */
.guide-link--secondary { border-style: dashed; opacity: 0.7; }

/* problem grid - single column (step 3) */
#problemGrid { grid-template-columns: 1fr; }

/* chat input row - disabled state when privacy not accepted */
.chat-input-disabled { opacity: 0.35; pointer-events: none; }

/* ===== ADMIN PANEL - FORM COMPONENTS ===== */
/* Select / dropdown in admin panel */
.admin-select {
  width: 100%;
  background: #161d2e;
  border: 1px solid #1e2a42;
  border-radius: 9px;
  padding: 10px 13px;
  font-size: 14px;
  color: #e8edf5;
  font-family: 'Heebo', sans-serif;
}

/* Hint / helper text under fields */
.admin-hint {
  font-size: 11px;
  color: #8896b0;
}




