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

:root {
  --bg: #0b0e14;
  --bg-elev: #131823;
  --bg-card: #181f2e;
  --bg-hover: #212a3d;
  --border: #263147;
  --text: #e8edf7;
  --text-muted: #93a1be;
  --primary: #4f8cff;
  --primary-hover: #3b76e8;
  --accent: #7c5cff;
  --danger: #ef4444;
  --success: #22c55e;
  --warning: #f59e0b;
  --radius: 12px;
  --sidebar-w: 272px;
}

html, body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100%;
  height: 100dvh;
  width: 100%;
  overflow: hidden;
  line-height: 1.55;
  -webkit-text-size-adjust: 100%;
}

/* Scrollbar halus */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #2b3750; border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: #3b4b6b; }

.hidden { display: none !important; }
.muted { color: var(--text-muted); font-size: 0.9rem; }
.center-text { text-align: center; }

/* Toast */
#toast-container {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: calc(100vw - 32px);
}
.toast {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-left: 4px solid var(--primary);
  color: var(--text);
  padding: 12px 16px;
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.45);
  font-size: 0.9rem;
  max-width: 360px;
  animation: slideIn 0.2s ease;
}
.toast.error { border-left-color: var(--danger); }
.toast.success { border-left-color: var(--success); }
@keyframes slideIn { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: translateX(0); } }

/* Buttons & Inputs */
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, textarea, select {
  font-family: inherit;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 12px;
  border-radius: 9px;
  font-size: 0.93rem;
  width: 100%;
  outline: none;
  transition: border-color 0.15s;
}
input:focus, textarea:focus, select:focus { border-color: var(--primary); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 16px;
  border-radius: 9px;
  font-weight: 600;
  font-size: 0.9rem;
  white-space: nowrap;
  transition: background 0.15s, transform 0.1s;
}
.btn:active { transform: scale(0.98); }
.btn-primary { background: linear-gradient(135deg, var(--primary), var(--accent)); color: #fff; }
.btn-primary:hover { filter: brightness(1.08); }
.btn-secondary { background: var(--bg-hover); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: #2a354d; }
.btn-danger { background: rgba(239, 68, 68, 0.16); color: #fca5a5; border: 1px solid rgba(239, 68, 68, 0.35); }
.btn-danger:hover { background: rgba(239, 68, 68, 0.28); }
.btn-success { background: rgba(34, 197, 94, 0.16); color: #86efac; border: 1px solid rgba(34, 197, 94, 0.35); }
.btn-success:hover { background: rgba(34, 197, 94, 0.28); }
.btn-sm { padding: 6px 11px; font-size: 0.8rem; }
.btn-block { width: 100%; }

.icon-btn {
  width: 36px; height: 36px;
  border-radius: 9px;
  display: inline-flex; align-items: center; justify-content: center;
  background: transparent;
  color: var(--text-muted);
  flex-shrink: 0;
  transition: background 0.15s, color 0.15s;
}
.icon-btn:hover { background: var(--bg-hover); color: var(--text); }
.icon-btn.danger:hover { background: rgba(239,68,68,0.2); color: #fca5a5; }

/* Auth Screen */
.auth-screen {
  display: flex; align-items: center; justify-content: center;
  min-height: 100dvh; height: 100dvh; overflow-y: auto; padding: 20px;
  background: radial-gradient(circle at top, #18233a 0%, var(--bg) 60%);
}
.auth-card {
  width: 100%; max-width: 440px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 28px 24px;
  box-shadow: 0 20px 50px rgba(0,0,0,0.5);
  margin: auto;
}
.brand-header { text-align: center; margin-bottom: 22px; }
.brand-logo {
  width: 54px; height: 54px; margin: 0 auto 12px;
  border-radius: 15px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  display: flex; align-items: center; justify-content: center;
  font-size: 1.6rem; color: #fff;
}
.brand-logo.warn { background: rgba(245, 158, 11, 0.2); color: var(--warning); }
.subtitle { color: var(--text-muted); font-size: 0.9rem; margin-top: 4px; }

.auth-tabs {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 4px; margin-bottom: 18px;
  background: var(--bg); padding: 4px; border-radius: 11px;
}
.auth-tab {
  display: flex; align-items: center; justify-content: center; text-align: center;
  padding: 9px 6px; border-radius: 8px; font-size: 0.82rem; font-weight: 600;
  color: var(--text-muted); line-height: 1.25;
}
.auth-tab.active { background: var(--bg-card); color: var(--text); }
.auth-form { display: flex; flex-direction: column; gap: 14px; }
.form-group { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.form-group label { font-size: 0.85rem; color: var(--text-muted); font-weight: 500; }
.form-note { font-size: 0.8rem; color: var(--text-muted); margin-top: 6px; }
.alert-banner {
  background: rgba(245, 158, 11, 0.15);
  border: 1px solid rgba(245, 158, 11, 0.4);
  color: #fde68a; padding: 10px 12px; border-radius: 8px;
  font-size: 0.86rem; margin-bottom: 14px;
}
.auth-message {
  margin-top: 14px; padding: 10px 12px; border-radius: 8px; font-size: 0.86rem;
  background: rgba(79,140,255,0.14); border: 1px solid rgba(79,140,255,0.35);
}
.auth-message.error { background: rgba(239,68,68,0.14); border-color: rgba(239,68,68,0.4); color: #fecaca; }
.action-row { display: flex; gap: 10px; justify-content: center; margin-top: 20px; }

/* App Shell (Desktop & Mobile Full Height Fix) */
.app-shell { display: flex; height: 100%; height: 100dvh; width: 100%; overflow: hidden; }

.sidebar {
  width: var(--sidebar-w);
  background: var(--bg-elev);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  padding: 16px 14px; gap: 12px;
  flex-shrink: 0;
  z-index: 50;
  height: 100%;
}
.sidebar-header { display: flex; align-items: center; justify-content: space-between; }
.brand-mini { display: flex; align-items: center; gap: 9px; font-weight: 700; font-size: 1.05rem; }
.brand-icon {
  width: 30px; height: 30px; border-radius: 8px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  display: inline-flex; align-items: center; justify-content: center; font-size: 0.95rem;
}
.btn-new-chat { width: 100%; }

.sidebar-nav { display: flex; flex-direction: column; gap: 4px; }
.nav-btn {
  text-align: left; padding: 10px 12px; border-radius: 9px;
  font-size: 0.92rem; color: var(--text-muted); font-weight: 500;
}
.nav-btn:hover { background: var(--bg-hover); color: var(--text); }
.nav-btn.active { background: rgba(79, 140, 255, 0.16); color: #93c5fd; }

.sidebar-section-title {
  font-size: 0.74rem; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--text-muted); margin-top: 6px; padding: 0 6px;
}

.chat-list {
  flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 4px;
}
.chat-item {
  display: flex; align-items: center; justify-content: space-between; gap: 6px;
  padding: 9px 10px; border-radius: 9px; cursor: pointer;
  color: var(--text-muted); font-size: 0.88rem;
}
.chat-item:hover { background: var(--bg-hover); color: var(--text); }
.chat-item.active { background: var(--bg-card); color: var(--text); border: 1px solid var(--border); }
.chat-item-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.chat-item-actions { display: flex; gap: 2px; opacity: 0.8; flex-shrink: 0; }
.chat-item-actions button { padding: 4px 6px; border-radius: 6px; font-size: 0.8rem; }
.chat-item-actions button:hover { background: rgba(255,255,255,0.1); }

.sidebar-footer {
  border-top: 1px solid var(--border); padding-top: 12px;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.user-badge { display: flex; align-items: center; gap: 10px; min-width: 0; }
.avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; flex-shrink: 0;
}
.user-meta { min-width: 0; }
.user-name { font-weight: 600; font-size: 0.9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 0.75rem; color: var(--text-muted); }

/* Main Content */
.main-content {
  flex: 1; display: flex; flex-direction: column;
  min-width: 0; height: 100%; overflow: hidden;
}

.topbar {
  min-height: 60px; padding: 10px 22px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-elev);
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  flex-shrink: 0;
}
.topbar-left { display: flex; align-items: center; gap: 10px; min-width: 0; }
.view-title { font-weight: 600; font-size: 1rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-controls { display: flex; align-items: center; gap: 8px; min-width: 0; }
.compact-select { width: auto; max-width: 240px; padding: 7px 11px; font-size: 0.85rem; }

.view-panel { display: none; flex: 1; min-height: 0; overflow: hidden; flex-direction: column; }
.view-panel.active { display: flex; }

/* Chat Messages (Spacious Desktop) */
.messages-container {
  flex: 1; min-height: 0; overflow-y: auto; padding: 26px 28px;
  display: flex; flex-direction: column; gap: 18px;
  max-width: 1040px; width: 100%; margin: 0 auto;
}
.welcome-empty {
  margin: auto; text-align: center; max-width: 640px; padding: 24px 12px;
}
.welcome-icon {
  width: 60px; height: 60px; margin: 0 auto 14px; border-radius: 16px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  display: flex; align-items: center; justify-content: center; font-size: 1.8rem;
}
.welcome-empty h2 { font-size: 1.5rem; }
.welcome-empty p { color: var(--text-muted); margin-top: 8px; font-size: 0.95rem; }
.quick-chips { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-top: 20px; }
.chip {
  background: var(--bg-card); border: 1px solid var(--border);
  padding: 9px 15px; border-radius: 22px; font-size: 0.87rem; color: var(--text);
  transition: border-color 0.15s, background 0.15s;
}
.chip:hover { border-color: var(--primary); background: var(--bg-hover); }

.message-row { display: flex; flex-direction: column; gap: 6px; }
.message-row.user { align-items: flex-end; }
.message-row.assistant { align-items: flex-start; }

.message-bubble {
  max-width: 82%; padding: 14px 18px; border-radius: 15px;
  font-size: 0.95rem; word-wrap: break-word; overflow-wrap: anywhere;
}
.message-row.user .message-bubble {
  background: linear-gradient(135deg, #2556b8, #3d48b8);
  color: #fff; border-bottom-right-radius: 4px;
}
.message-row.assistant .message-bubble {
  background: var(--bg-card); border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}

.msg-meta { font-size: 0.74rem; color: var(--text-muted); display: flex; gap: 8px; align-items: center; }
.msg-actions { display: flex; gap: 5px; flex-wrap: wrap; }
.msg-action-btn {
  font-size: 0.77rem; color: var(--text-muted);
  padding: 4px 9px; border-radius: 7px; background: var(--bg-elev); border: 1px solid var(--border);
}
.msg-action-btn:hover { color: var(--text); border-color: var(--primary); }

.msg-images-grid { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
.msg-images-grid img {
  max-width: 200px; max-height: 200px; border-radius: 10px;
  object-fit: cover; border: 1px solid rgba(255,255,255,0.2);
}

.generated-media { margin-top: 10px; display: flex; flex-direction: column; gap: 8px; }
.generated-media img, .generated-media video {
  max-width: 100%; max-height: 460px; border-radius: 12px; border: 1px solid var(--border);
}

.sources-box {
  margin-top: 10px; padding-top: 8px; border-top: 1px solid var(--border);
  display: flex; flex-wrap: wrap; gap: 6px;
}
.source-pill {
  font-size: 0.77rem; color: #93c5fd; text-decoration: none;
  background: rgba(79,140,255,0.12); padding: 4px 10px; border-radius: 14px;
  border: 1px solid rgba(79,140,255,0.25);
}
.source-pill:hover { background: rgba(79,140,255,0.24); }

/* Markdown Rendering */
.md-content p { margin-bottom: 8px; }
.md-content p:last-child { margin-bottom: 0; }
.md-content h1, .md-content h2, .md-content h3 { margin: 12px 0 6px; line-height: 1.3; }
.md-content ul, .md-content ol { padding-left: 22px; margin-bottom: 8px; }
.md-content blockquote {
  border-left: 3px solid var(--primary); padding-left: 10px; color: var(--text-muted); margin: 8px 0;
}
.md-content code {
  background: rgba(0,0,0,0.35); padding: 2px 6px; border-radius: 5px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.86em;
}
.code-block-wrap {
  position: relative; margin: 10px 0; background: #070a10;
  border: 1px solid var(--border); border-radius: 10px; overflow: hidden;
}
.code-block-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 6px 12px; background: #101624; font-size: 0.77rem; color: var(--text-muted);
}
.code-block-wrap pre { padding: 12px; overflow-x: auto; }
.code-block-wrap pre code { background: none; padding: 0; }

/* Composer */
.composer-wrapper {
  border-top: 1px solid var(--border);
  background: var(--bg-elev);
  padding: 12px 24px calc(14px + env(safe-area-inset-bottom));
  flex-shrink: 0;
}
.mode-bar {
  max-width: 1040px; margin: 0 auto 9px;
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
}
.mode-pill {
  padding: 6px 12px; border-radius: 20px; font-size: 0.82rem; font-weight: 500;
  background: var(--bg-card); border: 1px solid var(--border); color: var(--text-muted);
  white-space: nowrap; flex-shrink: 0;
}
.mode-pill:hover { color: var(--text); border-color: var(--primary); }
.mode-pill.active {
  background: rgba(79, 140, 255, 0.2); border-color: var(--primary); color: #bfdbfe;
}
.mode-hint { margin-left: auto; font-size: 0.8rem; color: var(--text-muted); white-space: nowrap; }

.upload-preview-bar {
  max-width: 1040px; margin: 0 auto 8px;
  display: flex; flex-wrap: wrap; gap: 8px;
}
.preview-thumb {
  position: relative; width: 64px; height: 64px; border-radius: 8px;
  overflow: hidden; border: 1px solid var(--border);
}
.preview-thumb img { width: 100%; height: 100%; object-fit: cover; }
.preview-thumb button {
  position: absolute; top: 2px; right: 2px; width: 18px; height: 18px;
  border-radius: 50%; background: rgba(0,0,0,0.75); color: #fff; font-size: 0.7rem;
}

.composer-box {
  max-width: 1040px; margin: 0 auto;
  display: flex; align-items: flex-end; gap: 8px;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 15px; padding: 8px 10px;
}
.composer-box:focus-within { border-color: var(--primary); }
.composer-box textarea {
  border: none; background: transparent; resize: none;
  max-height: 150px; min-height: 36px; padding: 6px 6px; line-height: 1.45;
}
.composer-icon-btn {
  width: 38px; height: 38px; border-radius: 10px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-card); font-size: 1.05rem;
}
.composer-icon-btn:hover { background: var(--bg-hover); }
.composer-icon-btn.recording {
  background: rgba(239, 68, 68, 0.25); border: 1px solid var(--danger);
  animation: pulse 1s infinite;
}
@keyframes pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.08); } }

.btn-send {
  width: 38px; height: 38px; border-radius: 10px; flex-shrink: 0;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: #fff; font-size: 1.05rem;
  display: flex; align-items: center; justify-content: center;
}
.btn-send:disabled { opacity: 0.5; cursor: not-allowed; }

/* Panels (Prompts, API Docs, Admin) - Desktop Wide & Airy */
.panel-container {
  flex: 1; min-height: 0; overflow-y: auto; padding: 28px 32px 36px;
  max-width: 1280px; width: 100%; margin: 0 auto;
  display: flex; flex-direction: column; gap: 20px;
}
.panel-header { display: flex; justify-content: space-between; align-items: center; gap: 14px; flex-wrap: wrap; }
.panel-header h2 { font-size: 1.35rem; margin-bottom: 3px; }
.card {
  background: var(--bg-elev); border: 1px solid var(--border);
  border-radius: 14px; padding: 20px;
  display: flex; flex-direction: column; gap: 14px;
}
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.full-width { grid-column: 1 / -1; }
.align-end { justify-content: flex-end; }
.form-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.divider { border: none; border-top: 1px solid var(--border); margin: 4px 0; }
.key-mask { font-size: 0.78rem; color: #86efac; margin-left: 6px; }

.cards-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.prompt-card {
  background: var(--bg-elev); border: 1px solid var(--border);
  border-radius: 14px; padding: 16px;
  display: flex; flex-direction: column; gap: 8px;
}
.prompt-card-preview {
  font-size: 0.85rem; color: var(--text-muted);
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}

.apikey-box { display: flex; gap: 8px; flex-wrap: wrap; }
.apikey-box input { flex: 1; min-width: 220px; font-family: monospace; }

.endpoint-list { display: flex; flex-direction: column; gap: 10px; font-size: 0.88rem; word-break: break-word; }
.badge {
  display: inline-block; padding: 3px 8px; border-radius: 6px;
  font-size: 0.72rem; font-weight: 700; text-transform: uppercase; white-space: nowrap;
}
.badge.get { background: rgba(34,197,94,0.2); color: #86efac; }
.badge.post { background: rgba(79,140,255,0.2); color: #93c5fd; }
.badge.approved { background: rgba(34,197,94,0.2); color: #86efac; }
.badge.pending { background: rgba(245,158,11,0.2); color: #fde68a; }
.badge.suspended { background: rgba(239,68,68,0.2); color: #fca5a5; }
.badge.admin { background: rgba(124,92,255,0.25); color: #d8b4fe; }
.badge.user { background: rgba(148,163,184,0.2); color: #cbd5e1; }

.card pre {
  background: #070a10; border: 1px solid var(--border);
  padding: 14px; border-radius: 10px; overflow-x: auto; font-size: 0.83rem;
}

/* Admin Stats & Tables */
.stats-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 14px; }
.stat-card {
  background: var(--bg-elev); border: 1px solid var(--border);
  border-radius: 14px; padding: 16px 18px;
}
.stat-label { font-size: 0.8rem; color: var(--text-muted); }
.stat-value { font-size: 1.65rem; font-weight: 700; margin-top: 6px; }

.admin-tabs { display: flex; gap: 8px; flex-wrap: wrap; }
.admin-tab {
  padding: 9px 15px; border-radius: 10px; font-size: 0.87rem; font-weight: 600;
  background: var(--bg-elev); border: 1px solid var(--border); color: var(--text-muted);
  white-space: nowrap; flex-shrink: 0;
}
.admin-tab.active { background: rgba(79,140,255,0.2); border-color: var(--primary); color: #bfdbfe; }
.admin-tab-content { display: none; }
.admin-tab-content.active { display: block; }

.table-wrap {
  width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; padding: 0;
}
.data-table {
  width: 100%; min-width: 720px; border-collapse: collapse; font-size: 0.86rem;
}
.data-table th, .data-table td {
  text-align: left; padding: 12px 14px; border-bottom: 1px solid var(--border);
  white-space: nowrap; vertical-align: middle;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table th { color: var(--text-muted); font-weight: 600; background: rgba(255,255,255,0.02); }
#admin-logs-tbody td:last-child { white-space: normal; min-width: 240px; }
.table-actions { display: flex; gap: 6px; flex-wrap: nowrap; }

/* Responsive Tablet */
.mobile-only { display: none; }
.sidebar-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.62); z-index: 40;
  backdrop-filter: blur(2px);
}

@media (max-width: 1080px) {
  .stats-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .panel-container { padding: 20px; }
}

/* Responsive Mobile (Rapi, Lega & Tidak Terpotong) */
@media (max-width: 820px) {
  .mobile-only { display: inline-flex; }
  .sidebar {
    position: fixed; top: 0; bottom: 0; left: -300px; width: 280px;
    transition: left 0.22s ease; box-shadow: 8px 0 30px rgba(0,0,0,0.5);
  }
  .sidebar.open { left: 0; }

  /* Topbar 2 baris rapi saat di Chat, 1 baris saat di Panel Admin/Lainnya */
  .topbar {
    flex-wrap: wrap; padding: 8px 12px; gap: 8px; min-height: 52px;
  }
  .topbar-left { flex: 1 1 100%; }
  .topbar-controls {
    width: 100%; display: flex; align-items: center; gap: 6px;
  }
  .compact-select {
    flex: 1 1 0; min-width: 0; max-width: none;
    padding: 7px 8px; font-size: 0.82rem;
  }

  /* Area Chat & Welcome */
  .messages-container { padding: 14px 12px; gap: 14px; }
  .welcome-empty { padding: 12px 6px; }
  .welcome-icon { width: 48px; height: 48px; font-size: 1.45rem; margin-bottom: 10px; }
  .welcome-empty h2 { font-size: 1.25rem; }
  .welcome-empty p { font-size: 0.88rem; }
  .quick-chips { gap: 8px; margin-top: 14px; }
  .chip { padding: 7px 12px; font-size: 0.82rem; }
  .message-bubble { max-width: 92%; padding: 11px 14px; font-size: 0.92rem; }

  /* Composer & Mode Bar 1 baris geser samping */
  .composer-wrapper { padding: 8px 10px calc(10px + env(safe-area-inset-bottom)); }
  .mode-bar {
    flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch;
    scrollbar-width: none; margin-bottom: 8px; gap: 6px; padding-bottom: 2px;
  }
  .mode-bar::-webkit-scrollbar { display: none; }
  .mode-pill { padding: 5px 10px; font-size: 0.78rem; }
  .mode-hint { display: none; }
  .composer-box { padding: 6px 8px; gap: 6px; border-radius: 13px; }
  .composer-icon-btn, .btn-send { width: 35px; height: 35px; font-size: 1rem; }
  .composer-box textarea { font-size: 0.92rem; padding: 5px 4px; }

  /* Panel Admin, Prompt & API Docs */
  .panel-container { padding: 14px 12px 28px; gap: 14px; }
  .panel-header h2 { font-size: 1.18rem; }
  .card { padding: 14px; gap: 12px; }
  .form-grid { grid-template-columns: 1fr; gap: 12px; }
  .cards-grid { grid-template-columns: 1fr; }

  /* Stats Grid rapi 2 kolom, kartu ke-5 penuh 1 baris */
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .stat-card { padding: 12px 14px; }
  .stat-value { font-size: 1.4rem; }
  .stat-card:last-child:nth-child(odd) { grid-column: 1 / -1; }

  /* Tab Admin 1 baris geser samping */
  .admin-tabs {
    flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch;
    scrollbar-width: none; gap: 6px; padding-bottom: 2px;
  }
  .admin-tabs::-webkit-scrollbar { display: none; }
  .admin-tab { padding: 8px 12px; font-size: 0.82rem; }

  /* Auth Card HP */
  .auth-card { padding: 22px 16px; border-radius: 15px; }
  .auth-tab { font-size: 0.78rem; padding: 8px 4px; }
}

/* Sticky Admin Tabs agar tidak hilang saat scroll atau diklik di HP */
.sticky-admin-tabs {
  position: sticky;
  top: -14px;
  z-index: 20;
  background: var(--bg);
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

/* Light Mode & Komponen Tambahan */
body.light-theme {
  --bg: #f3f5f9;
  --bg-elev: #ffffff;
  --bg-card: #eef2f8;
  --bg-hover: #e2e8f2;
  --border: #d5deec;
  --text: #0f172a;
  --text-muted: #475569;
}
.announcement-bar {
  background: linear-gradient(90deg, rgba(79,140,255,0.2), rgba(124,92,255,0.2));
  border-bottom: 1px solid var(--border);
  padding: 7px 16px;
  font-size: 0.84rem;
  text-align: center;
  font-weight: 500;
}
.preview-doc-chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--bg-card); border: 1px solid var(--border);
  padding: 6px 10px; border-radius: 8px; font-size: 0.8rem;
}
.preview-doc-chip button { color: var(--danger); font-weight: 700; }

/* Model Spec Strip, Modal & Unlimited Bulk Preview */
.model-spec-strip {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 6px 16px; font-size: 0.78rem; color: var(--text-muted);
  background: rgba(79,140,255,0.06); border-bottom: 1px solid var(--border);
}
.spec-tag {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: 12px; background: var(--bg-card);
  border: 1px solid var(--border); font-size: 0.74rem; color: var(--text);
}
.spec-tag.vision { border-color: rgba(34,197,94,0.45); color: #86efac; }
.modal-backdrop {
  position: fixed; inset: 0; z-index: 500;
  background: rgba(0,0,0,0.7); backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center; padding: 14px;
}
.modal-box {
  width: 100%; max-width: 760px; max-height: 86dvh; overflow-y: auto;
  background: var(--bg-elev); border: 1px solid var(--border);
  border-radius: 16px; padding: 18px;
}
.modal-header {
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: 10px; margin-bottom: 12px;
}
.specs-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px;
}
.spec-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 12px; padding: 12px; display: flex; flex-direction: column; gap: 6px;
}
.spec-card.active { border-color: var(--primary); }
.upload-preview-header {
  max-width: 1040px; margin: 0 auto 6px;
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
}
.upload-preview-bar {
  max-height: 150px; overflow-y: auto;
}
.msg-footer-meta {
  font-size: 0.72rem; color: var(--text-muted); margin-top: 6px; opacity: 0.85;
}

/* Markdown Table, Zoomable Image & Perbaikan Placeholder HP */
.md-table-wrap { overflow-x: auto; margin: 10px 0; border-radius: 8px; border: 1px solid var(--border); }
.md-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.md-table th, .md-table td { padding: 8px 10px; border-bottom: 1px solid var(--border); text-align: left; }
.md-table th { background: rgba(79,140,255,0.14); font-weight: 600; }
.zoomable-img { cursor: zoom-in; transition: transform 0.15s; }
.zoomable-img:hover { transform: scale(1.02); }
.composer-box textarea { min-height: 38px; line-height: 1.4; overflow-y: auto; }

/* Kotak Proses Berpikir (DeepSeek/Reasoning) */
.thinking-box {
  margin-bottom: 8px; padding: 8px 10px; border-radius: 9px;
  background: rgba(124, 92, 255, 0.08); border: 1px solid rgba(124, 92, 255, 0.28);
  font-size: 0.82rem; color: var(--text-muted);
}
.thinking-box summary { cursor: pointer; font-weight: 600; color: #c4b5fd; }
.thinking-body { margin-top: 6px; max-height: 220px; overflow-y: auto; line-height: 1.45; }

/* Code Analyzer Styles (Rapi di HP & Desktop) */
.anl-dropzone {
  border: 2px dashed var(--border);
  border-radius: 12px;
  padding: 20px 14px;
  text-align: center;
  cursor: pointer;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: center;
  transition: border-color 0.15s, background 0.15s;
}
.anl-dropzone:hover { border-color: var(--primary); background: var(--bg-card); }
.anl-stats-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
}
.anl-stat-box {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 13px 14px;
}
.anl-stat-box .lbl { font-size: 0.78rem; color: var(--text-muted); }
.anl-stat-box .val { font-size: 1.45rem; font-weight: 700; margin-top: 4px; }
.anl-list { display: flex; flex-direction: column; }
.anl-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  word-break: break-word;
}
.anl-row:last-child { border-bottom: none; }
.anl-row.clickable { cursor: pointer; padding: 10px 8px; border-radius: 8px; }
.anl-row.clickable:hover { background: var(--bg-hover); }
.anl-code-title { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-weight: 600; font-size: 0.87rem; }
.anl-sub { font-size: 0.78rem; color: var(--text-muted); margin-top: 2px; word-break: break-all; }
.anl-pills { display: flex; flex-wrap: wrap; gap: 8px; }
.anl-pill {
  padding: 6px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg);
  font-size: 0.84rem;
  font-weight: 500;
}
.fv-code-box {
  background: #070a10;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  max-height: 68dvh;
  overflow: auto;
  font-size: 0.82rem;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}
@media (max-width: 820px) {
  .anl-stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* DeepSeek / Gemini Modern Chat UI */
.messages-container {
  max-width: 900px;
  gap: 22px;
}
.message-row.user .message-bubble {
  border-radius: 20px 20px 6px 20px;
  padding: 12px 16px;
  box-shadow: 0 4px 16px rgba(37, 86, 184, 0.22);
  user-select: text;
}
.message-row.assistant .message-bubble {
  max-width: 100%;
  width: 100%;
  background: transparent;
  border: none;
  padding: 4px 2px;
  border-radius: 0;
  user-select: text;
}
.ai-msg-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--text);
}
.ai-spark {
  width: 24px; height: 24px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 0.8rem;
  flex-shrink: 0;
}
.ai-model-chip {
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--text-muted);
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: 2px 8px;
  border-radius: 99px;
}
.md-content { font-size: 0.96rem; line-height: 1.68; }
.md-content h1, .md-content h2, .md-content h3 { margin: 16px 0 8px; font-weight: 700; }
.md-content p { margin-bottom: 10px; }
.md-content ul, .md-content ol { padding-left: 22px; margin-bottom: 10px; }
.md-content li { margin-bottom: 4px; }
.md-link { color: var(--primary); text-decoration: underline; text-underline-offset: 2px; }

/* Code Block ala DeepSeek / Gemini */
.code-block-wrap {
  margin: 12px 0;
  background: #0d1117;
  border: 1px solid #2b3446;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
}
.code-block-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 14px;
  background: #161b22;
  border-bottom: 1px solid #2b3446;
  font-size: 0.78rem;
  color: #9fb0cc;
}
.code-lang {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  text-transform: lowercase;
  font-weight: 600;
  letter-spacing: 0.02em;
}
.code-copy-btn {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 10px;
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: #e6edf3;
  font-size: 0.76rem;
  font-weight: 600;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.code-copy-btn:hover { background: rgba(79, 140, 255, 0.22); border-color: var(--primary); }
.code-copy-btn.copied { background: rgba(34, 197, 94, 0.22); border-color: var(--success); color: #86efac; }
.code-block-wrap pre {
  padding: 14px;
  overflow-x: auto;
  font-size: 0.86rem;
  line-height: 1.55;
  color: #e6edf3;
  margin: 0;
}
.code-block-wrap pre code { background: none; padding: 0; color: inherit; font-size: inherit; }

/* Syntax Highlight Colors */
.hl-kw { color: #ff7b72; font-weight: 600; }
.hl-str { color: #a5d6ff; }
.hl-com { color: #8b949e; font-style: italic; }
.hl-num { color: #79c0ff; }

/* Inline Code / Import yang Bisa Diketuk Langsung untuk Disalin */
.inline-copy-code {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: rgba(79, 140, 255, 0.13);
  border: 1px solid rgba(79, 140, 255, 0.3);
  color: #93c5fd;
  padding: 1px 7px;
  border-radius: 6px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.85em;
  cursor: pointer;
  vertical-align: baseline;
  transition: background 0.15s, border-color 0.15s;
}
.inline-copy-code:hover { background: rgba(79, 140, 255, 0.26); border-color: var(--primary); }
.inline-copy-code.copied { background: rgba(34, 197, 94, 0.25); border-color: var(--success); color: #86efac; }
.inline-copy-code .ic-badge { font-size: 0.78em; opacity: 0.75; }
body.light-theme .inline-copy-code { color: #1d4ed8; background: rgba(37, 99, 235, 0.09); border-color: rgba(37, 99, 235, 0.28); }

/* Tabel ala Gemini / DeepSeek */
.md-table-card {
  margin: 12px 0;
  border: 1px solid var(--border);
  border-radius: 11px;
  overflow: hidden;
  background: var(--bg-elev);
}
.md-table-bar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 6px 12px; background: var(--bg-card);
  border-bottom: 1px solid var(--border); font-size: 0.78rem; color: var(--text-muted);
}
.md-table-card .md-table-wrap { margin: 0; border: none; border-radius: 0; }
.md-table-bar .code-copy-btn { color: var(--text); border-color: var(--border); }

@media (max-width: 820px) {
  .message-row.user .message-bubble { max-width: 88%; }
  .code-block-wrap pre { font-size: 0.82rem; padding: 11px; }
}

.anl-stat-box.clickable-stat { cursor: pointer; border-color: rgba(79,140,255,0.45); }
.anl-stat-box.clickable-stat:hover { background: var(--bg-hover); }

.anl-progress-wrap { margin-top: 8px; display: flex; flex-direction: column; gap: 5px; }
.anl-progress-track { width: 100%; height: 8px; background: var(--bg); border: 1px solid var(--border); border-radius: 99px; overflow: hidden; }
.anl-progress-fill { height: 100%; background: linear-gradient(90deg, var(--primary), var(--accent)); transition: width 0.15s ease; }

.deep-search-box {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 10px;
  max-height: 210px;
  overflow-y: auto;
  margin-top: 2px;
}
.deep-search-item {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  font-size: 0.8rem;
}
.deep-search-item:last-child { border-bottom: none; }
.deep-search-item:hover { background: var(--bg-hover); }

/* Compare 2 AI, Galeri Gambar, & Grafik Analitik Admin */
.compare-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.compare-hdr { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding-bottom: 8px; border-bottom: 1px solid var(--border); margin-bottom: 8px; }
.gallery-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.gallery-card { background: var(--bg-elev); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; display: flex; flex-direction: column; }
.gallery-img { width: 100%; aspect-ratio: 1 / 1; object-fit: cover; display: block; }
.gallery-body { padding: 10px 12px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.gallery-prompt { font-size: 0.8rem; color: var(--text-muted); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.bar-chart { display: flex; align-items: flex-end; gap: 6px; height: 170px; padding-top: 18px; overflow-x: auto; }
.chart-col { flex: 1; min-width: 28px; display: flex; flex-direction: column; align-items: center; gap: 4px; height: 100%; }
.chart-val { font-size: 0.68rem; color: var(--text-muted); }
.chart-bar-wrap { flex: 1; width: 100%; max-width: 28px; display: flex; align-items: flex-end; background: var(--bg); border-radius: 6px; overflow: hidden; }
.chart-bar { width: 100%; background: linear-gradient(180deg, var(--primary), #2563eb); border-radius: 6px 6px 0 0; }
.chart-bar.tok { background: linear-gradient(180deg, #a855f7, #6d28d9); }
.chart-lbl { font-size: 0.66rem; color: var(--text-muted); white-space: nowrap; }
@media (max-width: 820px) { .compare-grid { grid-template-columns: 1fr; } }

/* Halaman Tata Cara Pakai */
.guide-cats { display: flex; flex-wrap: wrap; gap: 6px; }
.guide-card { display: flex; flex-direction: column; gap: 10px; }
.guide-card-hdr { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.guide-steps { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 6px; font-size: 0.85rem; color: var(--text-muted); line-height: 1.5; }
.guide-steps li { padding-left: 2px; }

/* Dokumentasi API Lengkap */
.apidoc-card { display: flex; flex-direction: column; gap: 8px; }
.apidoc-card-top { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px; }
.apidoc-path { font-size: 0.84rem; color: var(--primary); word-break: break-all; }
.apidoc-lang-tabs { display: flex; gap: 4px; }
.apidoc-lang-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.apidoc-pre { margin: 0; padding: 10px 12px; background: var(--bg); border: 1px solid var(--border); border-radius: 8px; overflow-x: auto; font-size: 0.78rem; line-height: 1.45; }
.apidoc-res-details summary { font-size: 0.78rem; color: var(--text-muted); cursor: pointer; user-select: none; }

/* SIDEBAR CHAT-FIRST FIX v30 */
.sidebar {
  overflow-y: auto !important;
  overflow-x: hidden !important;
  -webkit-overflow-scrolling: touch;
}
#chat-list {
  display: flex !important;
  flex-direction: column;
  gap: 4px;
  min-height: 150px;
  max-height: 36vh;
  overflow-y: auto !important;
  flex: 0 0 auto !important;
  padding: 4px 2px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  margin-bottom: 4px;
}
.compact-nav-grid {
  display: grid !important;
  grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  gap: 5px !important;
  flex: 0 0 auto !important;
  margin-top: 4px;
}
.compact-nav-grid .nav-btn {
  padding: 7px 8px !important;
  font-size: 0.76rem !important;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  justify-content: flex-start !important;
}

/* Banner Pengumuman, Slash Commands, Live Canvas, & Custom Bot (v31) */
.ann-banner {
  position: sticky; top: 0; z-index: 9999;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 8px 14px; font-size: 0.82rem; font-weight: 600; color: #fff;
  backdrop-filter: blur(12px);
}
.ann-info { background: linear-gradient(90deg, rgba(37,99,235,0.92), rgba(79,70,229,0.92)); }
.ann-success { background: linear-gradient(90deg, rgba(16,185,129,0.92), rgba(13,148,136,0.92)); }
.ann-warning { background: linear-gradient(90deg, rgba(217,119,6,0.94), rgba(180,83,9,0.94)); }
.ann-danger { background: linear-gradient(90deg, rgba(220,38,38,0.94), rgba(159,18,57,0.94)); }
.ann-close { background: rgba(255,255,255,0.2); border: none; color: #fff; border-radius: 6px; padding: 2px 8px; cursor: pointer; }

.slash-popup {
  position: fixed; z-index: 9990;
  background: rgba(13, 19, 34, 0.96); border: 1px solid rgba(116, 168, 255, 0.35);
  border-radius: 12px; padding: 6px; box-shadow: 0 16px 40px rgba(0,0,0,0.75);
  display: flex; flex-direction: column; gap: 4px; max-height: 260px; overflow-y: auto;
}
.slash-item {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px;
  padding: 7px 10px; border: none; border-radius: 8px; background: transparent;
  color: #e2e8f0; cursor: pointer; text-align: left; font-size: 0.8rem;
}
.slash-item:hover { background: rgba(79, 140, 255, 0.2); }
.slash-item strong { color: #60a5fa; }
.slash-item span { font-size: 0.73rem; color: #94a3b8; }

.canvas-split { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; height: 68vh; }
.canvas-editor { width: 100%; height: 100%; font-family: monospace; font-size: 0.8rem; resize: none; }
.canvas-iframe { width: 100%; height: 100%; border: 1px solid var(--border); border-radius: 10px; background: #fff; }
.canvas-inline-btn { position: absolute; top: 6px; right: 78px; font-size: 0.72rem !important; padding: 3px 8px !important; }
@media (max-width: 760px) { .canvas-split { grid-template-columns: 1fr; grid-template-rows: 1fr 1fr; } }

.bot-chat-messages { display: flex; flex-direction: column; gap: 8px; max-height: 360px; overflow-y: auto; padding: 6px; background: rgba(0,0,0,0.2); border-radius: 10px; }
.bot-msg { padding: 8px 12px; border-radius: 10px; font-size: 0.85rem; }
.bot-msg.user { background: rgba(79, 140, 255, 0.22); align-self: flex-end; max-width: 88%; }
.bot-msg.ai { background: rgba(255, 255, 255, 0.06); align-self: flex-start; max-width: 95%; }
