:root {
  --void:    #03040a;
  --deep:    #080d1a;
  --panel:   #0d1425;
  --surface: #111c35;
  --rim:     #1a2a4a;
  --pulse:   #00c8ff;
  --glow:    #0af;
  --nova:    #7b4fff;
  --star:    #e8f0ff;
  --dim:     #5a6a8a;
  --danger:  #ff4466;
  --success: #00ffaa;

  --font-head: 'Orbitron', monospace;
  --font-body: 'Exo 2', sans-serif;

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 18px;
}

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

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--void);
  color: var(--star);
  font-family: var(--font-body);
  font-weight: 300;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

button { font-family: inherit; cursor: pointer; }
:focus-visible { outline: 2px solid var(--pulse); outline-offset: 2px; }

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--rim); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--pulse); }

#starfield {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  overflow: hidden;
}
.star-dot {
  position: absolute;
  border-radius: 50%;
  background: white;
  animation: twinkle var(--d, 3s) ease-in-out infinite alternate;
  opacity: var(--o, 0.6);
}
@keyframes twinkle {
  from { opacity: var(--o, 0.6); transform: scale(1); }
  to   { opacity: calc(var(--o, 0.6) * 0.2); transform: scale(0.6); }
}

.nebula {
  position: fixed; border-radius: 50%; filter: blur(80px);
  pointer-events: none; z-index: 0;
}
.nebula-1 {
  width: 500px; height: 500px;
  background: radial-gradient(circle, rgba(0,160,255,0.07) 0%, transparent 70%);
  top: -100px; left: -100px;
  animation: drift1 20s ease-in-out infinite alternate;
}
.nebula-2 {
  width: 600px; height: 600px;
  background: radial-gradient(circle, rgba(123,79,255,0.08) 0%, transparent 70%);
  bottom: -150px; right: -150px;
  animation: drift2 25s ease-in-out infinite alternate;
}
.nebula-3 {
  width: 300px; height: 300px;
  background: radial-gradient(circle, rgba(0,255,170,0.05) 0%, transparent 70%);
  top: 40%; left: 50%;
  animation: drift3 18s ease-in-out infinite alternate;
}
@keyframes drift1 { to { transform: translate(60px, 80px); } }
@keyframes drift2 { to { transform: translate(-50px, -60px); } }
@keyframes drift3 { to { transform: translate(30px, -40px); } }

.scanline {
  position: fixed; inset: 0; pointer-events: none; z-index: 999;
  background: repeating-linear-gradient(
    0deg, transparent, transparent 2px,
    rgba(0,0,0,0.015) 2px, rgba(0,0,0,0.015) 4px
  );
}

.app {
  position: relative;
  z-index: 1;
  display: flex;
  height: 100vh;
  overflow: hidden;
}

.sidebar {
  width: 280px;
  min-width: 280px;
  background: linear-gradient(180deg, rgba(8,13,26,0.98), rgba(8,13,26,0.9));
  border-right: 1px solid rgba(0,200,255,0.12);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  display: flex;
  flex-direction: column;
  padding: 16px;
  transition: margin-left 0.25s ease;
  z-index: 30;
}

.sidebar-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
  gap: 8px;
}

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

.logo-orb {
  width: 34px; height: 34px;
  flex-shrink: 0;
  position: relative;
}
.logo-orb svg { width: 100%; height: 100%; }
.logo-ring { animation: spin 8s linear infinite; transform-origin: center; }
@keyframes spin { to { transform: rotate(360deg); } }

.brand-name {
  font-family: var(--font-head);
  font-size: 1.05rem;
  font-weight: 900;
  letter-spacing: 0.15em;
  background: var(--pulse);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  display: block;
}
.brand-tag {
  font-size: 0.58rem;
  letter-spacing: 0.2em;
  color: var(--dim);
  text-transform: uppercase;
  margin-top: 2px;
}

#closeSidebarBtn { display: none; }

.icon-btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--dim);
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  flex-shrink: 0;
}
.icon-btn:hover {
  border-color: var(--pulse);
  color: var(--pulse);
  box-shadow: 0 0 10px rgba(0,200,255,0.2);
}
.icon-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  pointer-events: none;
}

.new-chat-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 10px 14px;
  background: var(--panel);
  border: 1px solid var(--rim);
  color: var(--star);
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  font-weight: 500;
  margin-bottom: 14px;
  transition: all 0.2s;
}
.new-chat-btn:hover {
  border-color: var(--pulse);
  box-shadow: 0 0 12px rgba(0,200,255,0.15);
}

.conv-list {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.conv-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  color: var(--dim);
  font-size: 0.82rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
  transition: all 0.2s;
  border: 1px solid transparent;
}
.conv-item:hover { background: var(--panel); color: var(--star); }
.conv-item.active {
  background: var(--panel);
  color: var(--star);
  border-color: rgba(0,200,255,0.25);
}
.conv-item .conv-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.conv-item .conv-del {
  opacity: 0;
  background: transparent;
  border: none;
  color: var(--dim);
  width: 22px;
  height: 22px;
  border-radius: 6px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.conv-item:hover .conv-del { opacity: 1; }
.conv-item .conv-del:hover { color: var(--danger); background: rgba(255,68,102,0.1); }

.sidebar-bottom { padding-top: 12px; border-top: 1px solid var(--rim); }

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 0.65rem;
  letter-spacing: 0.12em;
  font-family: var(--font-head);
  color: var(--dim);
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--panel);
}
.status-pill .dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 8px var(--success);
  animation: pulse-dot 2s ease-in-out infinite;
}
@keyframes pulse-dot {
  0%,100% { box-shadow: 0 0 6px var(--success); }
  50% { box-shadow: 0 0 14px var(--success), 0 0 24px rgba(0,255,170,0.3); }
}

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 20;
}

.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  position: relative;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 28px;
  height: 64px;
  background: linear-gradient(180deg, rgba(8,13,26,0.98) 0%, rgba(8,13,26,0.85) 100%);
  border-bottom: 1px solid rgba(0,200,255,0.12);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  flex-shrink: 0;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

#openSidebarBtn { display: none; }

.conv-title {
  flex: 1;
  font-family: var(--font-head);
  font-size: 0.85rem;
  letter-spacing: 0.05em;
  font-weight: 600;
  color: var(--star);
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 28px 0;
  scroll-behavior: smooth;
}

.empty-state {
  max-width: 600px;
  margin: 0 auto;
  text-align: center;
  padding: 40px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  animation: fadeUp 0.8s ease both;
}
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(24px); }
  to { opacity: 1; transform: translateY(0); }
}

.welcome-orb {
  width: 90px; height: 90px;
  margin-bottom: 8px;
}
.welcome-orb svg { width: 100%; height: 100%; }
.ellipse-ring-1 { animation: spin 8s linear infinite; transform-origin: 45px 45px; }

.welcome-title {
  font-family: var(--font-head);
  font-size: 2rem;
  font-weight: 900;
  letter-spacing: 0.2em;
  margin: 0 auto;
  color: var(--pulse);
  display: inline-block;
  position: relative;
}

.welcome-title::after {
  content: '';
  position: absolute;
  top: 50%;
  right: -10px;
  width: 3px;
  height: 1em;
  background: var(--pulse);
  transform: translateY(-50%);
  animation: title-blink 0.3s step-end 4 forwards;
}

.welcome-title.intro-done::after {
  animation: none;
  opacity: 0;
}

.welcome-title .char {
  opacity: 0;
  display: inline-block;
  animation: char-appear 0.05s forwards;
}

@keyframes char-appear {
  to { opacity: 1; }
}

@keyframes title-blink {
  from, to { opacity: 0; }
  50% { opacity: 1; }
}

.welcome-sub {
  color: var(--dim);
  font-size: 0.9rem;
  letter-spacing: 0.03em;
  line-height: 1.6;
  max-width: 400px;
  margin: 0;
}

.suggestions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 12px;
  width: 100%;
  max-width: 500px;
}
.sugg-card {
  background: var(--panel);
  border: 1px solid var(--rim);
  border-radius: 12px;
  padding: 14px 16px;
  color: var(--dim);
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.8rem;
  line-height: 1.4;
  text-align: left;
  transition: all 0.22s;
}
.sugg-card:hover {
  border-color: var(--pulse);
  color: var(--star);
  background: rgba(0,200,255,0.05);
  transform: translateY(-2px);
  box-shadow: 0 4px 20px rgba(0,200,255,0.1);
}
.sugg-card .s-icon {
  font-family: var(--font-head);
  font-size: 1rem;
  color: var(--pulse);
}
.messages {
  max-width: 780px;
  margin: 0 auto;
  padding: 0 20px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.msg {
  display: flex;
  gap: 14px;
  animation: fadeUp 0.35s ease both;
}
.msg.user { flex-direction: row-reverse; }

.msg-avatar {
  width: 36px; height: 36px;
  border-radius: 10px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
  font-family: var(--font-head);
  font-weight: 700;
  letter-spacing: 0.04em;
}
.msg.assistant .msg-avatar {
  background: linear-gradient(135deg, rgba(0,200,255,0.2), rgba(123,79,255,0.2));
  border: 1px solid rgba(0,200,255,0.3);
  color: var(--pulse);
}
.msg.user .msg-avatar {
  background: linear-gradient(135deg, rgba(123,79,255,0.25), rgba(0,200,255,0.1));
  border: 1px solid rgba(123,79,255,0.35);
  color: var(--nova);
}

.msg-body { flex: 1; min-width: 0; max-width: calc(100% - 50px); }
.msg.user .msg-body { display: flex; flex-direction: column; align-items: flex-end; }

.msg.user .bubble {
  background: linear-gradient(135deg, rgba(123,79,255,0.18), rgba(0,200,255,0.1));
  border: 1px solid rgba(123,79,255,0.25);
  border-top-right-radius: 4px;
  border-radius: 16px;
  padding: 14px 18px;
  max-width: 100%;
  color: var(--star);
  font-size: 0.9rem;
  line-height: 1.7;
  white-space: pre-wrap;
  word-break: break-word;
}

.msg.assistant .bubble {
  background: var(--panel);
  border: 1px solid var(--rim);
  border-top-left-radius: 4px;
  border-radius: 16px;
  padding: 14px 18px;
  color: var(--star);
  font-size: 0.9rem;
  line-height: 1.7;
}

.bubble .katex { color: inherit; font-size: 1.05em; }
.bubble .katex-display {
  margin: 10px 0;
  padding-bottom: 4px;
  overflow-x: auto;
  overflow-y: hidden;
}
.bubble p { margin: 0 0 10px; }
.bubble p:last-child { margin-bottom: 0; }
.bubble ul, .bubble ol { margin: 6px 0 12px; padding-left: 22px; }
.bubble li { margin-bottom: 4px; }
.bubble h1, .bubble h2, .bubble h3 {
  margin: 16px 0 8px;
  color: var(--star);
  font-weight: 700;
  font-family: var(--font-head);
}
.bubble h3 { font-size: 0.95rem; }
.bubble h2 { font-size: 1.05rem; }
.bubble a { color: var(--pulse); }
.bubble strong { color: var(--star); }
.bubble code {
  background: var(--surface);
  padding: 2px 6px;
  border-radius: 5px;
  font-family: 'JetBrains Mono', 'Fira Code', Consolas, monospace;
  font-size: 0.8rem;
}
.bubble pre {
  background: #060a14 !important;
  border: 1px solid var(--rim);
  border-radius: var(--radius-md);
  padding: 0;
  margin: 10px 0;
  overflow: hidden;
}
.bubble pre code {
  background: transparent;
  display: block;
  padding: 14px 16px;
  overflow-x: auto;
  font-size: 0.8rem;
  line-height: 1.55;
}
.code-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  background: #070d1c;
  border-bottom: 1px solid var(--rim);
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.7rem;
  color: var(--dim);
}
.copy-btn {
  background: var(--surface);
  border: 1px solid var(--rim);
  color: var(--dim);
  font-size: 0.68rem;
  padding: 4px 9px;
  border-radius: 6px;
}
.copy-btn:hover { color: var(--star); border-color: var(--pulse); }

.typing-dots {
  display: inline-flex;
  gap: 5px;
  padding: 6px 0;
  align-items: center;
}
.typing-dots span {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--pulse);
  animation: typing 1.2s ease-in-out infinite;
  opacity: 0.4;
}
.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes typing {
  0%,80%,100% { transform: translateY(0); opacity: 0.4; }
  40% { transform: translateY(-7px); opacity: 1; }
}

.thinking-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}
.thinking-status {
  font-size: 0.72rem;
  color: var(--dim);
  opacity: 0;
  transition: opacity 0.3s ease;
}
.thinking-status.visible { opacity: 0.85; }

.composer {
  flex-shrink: 0;
  padding: 16px 20px 20px;
  background: linear-gradient(0deg, rgba(3,4,10,0.98) 0%, rgba(3,4,10,0.85) 100%);
  border-top: 1px solid rgba(0,200,255,0.08);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.composer-inner {
  max-width: 780px;
  margin: 0 auto;
  display: flex;
  align-items: flex-end;
  gap: 10px;
  background: var(--panel);
  border: 1px solid var(--rim);
  border-radius: 16px;
  padding: 10px 12px;
  transition: all 0.2s;
}
.composer-inner:focus-within {
  border-color: rgba(0,200,255,0.4);
  box-shadow: 0 0 0 3px rgba(0,200,255,0.06), 0 0 24px rgba(0,200,255,0.08);
}

#messageInput {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--star);
  font-family: var(--font-body);
  font-size: 0.88rem;
  font-weight: 300;
  resize: none;
  max-height: 140px;
  min-height: 24px;
  line-height: 1.6;
  padding: 4px;
}
#messageInput::placeholder { color: var(--dim); }

.send-btn {
  position: relative;
  width: 40px; height: 40px;
  border-radius: 12px;
  border: none;
  background: var(--pulse);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.2s;
  box-shadow: 0 2px 12px rgba(0,200,255,0.3);
}
.send-btn svg { width: 18px; height: 18px; }
.send-btn:hover { transform: scale(1.08); box-shadow: 0 4px 20px rgba(0,200,255,0.45); }

/* Saat AI belum "berpikir": tampilkan ikon kirim, sembunyikan ikon stop */
.send-btn .icon-stop { display: none; }

/* Saat AI sedang memproses jawaban (is-sending):
   - ikon berganti jadi kotak "stop" (isyarat: proses masih berjalan)
   - tombol tetap bisa diklik untuk membatalkan permintaan
   - ring berdenyut di sekeliling tombol jadi penanda visual "masih berpikir" */
.send-btn.is-sending {
  background: #1c2430;
  cursor: pointer;
  box-shadow: 0 2px 12px rgba(0,200,255,0.15);
}
.send-btn.is-sending .icon-send { display: none; }
.send-btn.is-sending .icon-stop { display: block; }
.send-btn.is-sending:hover { transform: none; box-shadow: 0 2px 12px rgba(0,200,255,0.15); }

.send-btn:disabled:not(.is-sending) { opacity: 0.4; cursor: not-allowed; transform: none; }

.send-btn-ring {
  position: absolute;
  inset: -4px;
  border-radius: 14px;
  border: 2px solid rgba(0,200,255,0.55);
  opacity: 0;
  pointer-events: none;
}
.send-btn.is-sending .send-btn-ring {
  opacity: 1;
  animation: sendRingPulse 1.3s ease-out infinite;
}
@keyframes sendRingPulse {
  0%   { transform: scale(0.85); opacity: 0.7; }
  70%  { transform: scale(1.25); opacity: 0; }
  100% { transform: scale(1.25); opacity: 0; }
}

/* Label kecil di bawah composer saat AI sedang memproses,
   supaya user tahu ini masih jalan (bukan error) kalau agak lama */
.composer-hint.is-thinking {
  color: var(--star, #cfefff);
  opacity: 0.9;
}

.composer-hint {
  max-width: 780px; margin: 8px auto 0;
  text-align: center;
  font-size: 0.62rem;
  letter-spacing: 0.06em;
  color: var(--dim);
}

.attach-wrap { position: relative; flex-shrink: 0; }

.attach-btn {
  width: 40px; height: 40px;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--rim);
}
.attach-btn.open {
  background: var(--nova);
  border-color: transparent;
  color: #fff;
}

.attach-menu {
  position: absolute;
  bottom: 48px;
  left: 0;
  background: var(--panel);
  border: 1px solid var(--rim);
  border-radius: var(--radius-md);
  padding: 6px;
  display: none;
  flex-direction: column;
  gap: 2px;
  min-width: 180px;
  box-shadow: 0 8px 28px rgba(0,0,0,0.5);
  z-index: 40;
}
.attach-menu.open { display: flex; }

.attach-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  background: transparent;
  border: none;
  color: var(--star);
  font-size: 0.82rem;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  text-align: left;
  width: 100%;
}
.attach-menu-item:hover { background: var(--surface); }
.attach-menu-item svg { color: var(--pulse); flex-shrink: 0; }

.attachment-preview {
  max-width: 780px;
  margin: 0 auto 8px;
  padding: 0 4px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.attachment-preview:empty { display: none; }

.attach-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--panel);
  border: 1px solid var(--rim);
  border-radius: var(--radius-sm);
  padding: 6px 10px 6px 6px;
  font-size: 0.72rem;
  color: var(--dim);
  max-width: 220px;
}
.attach-chip img {
  width: 32px; height: 32px;
  border-radius: 6px;
  object-fit: cover;
  flex-shrink: 0;
}
.attach-chip .chip-icon {
  width: 32px; height: 32px;
  border-radius: 6px;
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--pulse);
}
.attach-chip .chip-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--star);
}
.attach-chip .chip-remove {
  background: var(--surface);
  border: none;
  color: var(--dim);
  width: 18px; height: 18px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 0.7rem;
  margin-left: 2px;
}
.attach-chip .chip-remove:hover { color: var(--danger); }

.msg-attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
  justify-content: flex-end;
}
.msg-attachments img {
  width: 90px; height: 90px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  border: 1px solid var(--rim);
}
.msg-attachments .file-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--surface);
  border: 1px solid var(--rim);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  font-size: 0.7rem;
  color: var(--dim);
}

@media (max-width: 860px) {
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    margin-left: -280px;
  }
  .sidebar.open { margin-left: 0; }
  .sidebar.open ~ .sidebar-overlay { display: block; }
  #closeSidebarBtn { display: flex; }
  #openSidebarBtn { display: flex; }
  .suggestions { grid-template-columns: 1fr; }
  .messages { padding: 0 14px; }
  .welcome-title { font-size: 1.4rem; }
  .topbar { padding: 0 16px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}
/* =========================================================
   INPUT FIELD AGAR TIDAK TENGGELAM
   ========================================================= */

/* Pastikan tinggi aplikasi benar-benar pas dengan tinggi layar browser mobile */
.app {
  height: 100vh;
  height: 100dvh; /* Menggunakan Dynamic Viewport Height agar pas di segala browser */
}

/* Atur ulang padding composer agar presisi dan aman dari navigasi HP */
.composer {
  flex-shrink: 0;
  padding: 16px 20px calc(16px + env(safe-area-inset-bottom, 0px));
  background: linear-gradient(0deg, rgba(3,4,10,0.98) 0%, rgba(3,4,10,0.85) 100%);
  border-top: 1px solid rgba(0,200,255,0.08);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

/* Responsif untuk ukuran layar mobile */
@media (max-width: 860px) {
  .composer {
    padding: 12px 14px calc(12px + env(safe-area-inset-bottom, 0px));
  }
}

/* =========================================================
   NASA EPIC_Earth Today Card
   ========================================================= */
.earth-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: var(--surface);
  border: 1px solid rgba(0, 200, 255, 0.25);
  border-radius: var(--radius-md);
  padding: 12px;
  max-width: 380px;
  animation: fadeUp 0.35s ease both;
}

.earth-card-imgwrap {
  width: 100%;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--void);
  border: 1px solid var(--rim);
  aspect-ratio: 1 / 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.earth-card-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.earth-card-broken .earth-card-imgwrap {
  aspect-ratio: auto;
  padding: 24px 10px;
}
.earth-card-broken .earth-card-img {
  width: 40px;
  height: 40px;
  object-fit: contain;
  opacity: 0.5;
}

.earth-card-info {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.earth-card-title {
  font-family: var(--font-head);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  color: var(--pulse);
  margin-bottom: 2px;
}

.earth-card-row {
  font-size: 0.78rem;
  color: var(--star);
  line-height: 1.5;
}

.earth-card-label {
  display: inline-block;
  min-width: 96px;
  color: var(--dim);
}

.earth-card-caption {
  margin-top: 4px;
  padding-top: 8px;
  border-top: 1px solid var(--rim);
  font-size: 0.78rem;
  color: var(--dim);
  line-height: 1.6;
  font-style: italic;
}

.earth-card-error {
  flex-direction: row;
  align-items: flex-start;
  gap: 10px;
  border-color: rgba(255, 68, 102, 0.35);
  background: rgba(255, 68, 102, 0.06);
}
.earth-card-error-icon,
.earth-error-icon {
  font-size: 1.1rem;
  flex-shrink: 0;
}
.earth-error-text {
  font-size: 0.82rem;
  color: var(--star);
  line-height: 1.6;
}

@media (max-width: 560px) {
  .earth-card { max-width: 100%; }
}

/* =========================================================
   SISTEM AUTH & GUEST / MEMBER UI (POJOK KIRI ATAS)
   ========================================================= */

.auth-topbar-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.auth-pill-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(17, 28, 53, 0.7);
  border: 1px solid rgba(0, 200, 255, 0.25);
  border-radius: 999px;
  padding: 5px 12px 5px 8px;
  color: var(--star);
  font-family: var(--font-body);
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 0 10px rgba(0, 200, 255, 0.08);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.auth-pill-btn:hover {
  border-color: var(--pulse);
  background: rgba(17, 28, 53, 0.95);
  box-shadow: 0 0 16px rgba(0, 200, 255, 0.25);
  transform: translateY(-1px);
}

.auth-avatar-icon {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: linear-gradient(135deg, rgba(0, 200, 255, 0.2), rgba(123, 79, 255, 0.3));
  border: 1px solid rgba(0, 200, 255, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--pulse);
  font-size: 0.75rem;
  font-weight: 700;
  flex-shrink: 0;
}

.auth-pill-text {
  display: flex;
  align-items: center;
  gap: 7px;
}

.auth-role-tag {
  font-family: var(--font-head);
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  padding: 2px 6px;
  border-radius: 4px;
  text-transform: uppercase;
}

.auth-role-tag.guest {
  background: rgba(90, 106, 138, 0.25);
  color: #a0aec0;
  border: 1px solid rgba(90, 106, 138, 0.4);
}

.auth-role-tag.member {
  background: rgba(0, 255, 170, 0.15);
  color: var(--success);
  border: 1px solid rgba(0, 255, 170, 0.4);
  box-shadow: 0 0 8px rgba(0, 255, 170, 0.25);
}

.auth-user-name {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--star);
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.auth-caret {
  color: var(--dim);
  transition: transform 0.2s ease;
  margin-left: -2px;
}

.auth-topbar-wrap.menu-open .auth-caret {
  transform: rotate(180deg);
}

/* User Menu Popover Dropdown */
.user-menu-popover {
  position: absolute;
  top: calc(100% + 10px);
  left: 0;
  min-width: 240px;
  background: rgba(8, 13, 26, 0.96);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(0, 200, 255, 0.25);
  border-radius: var(--radius-md);
  padding: 12px;
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.7), 0 0 20px rgba(0, 200, 255, 0.12);
  display: none;
  flex-direction: column;
  gap: 10px;
  z-index: 200;
  animation: fadeUp 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.user-menu-popover.open {
  display: flex;
}

.user-menu-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px;
}

.user-menu-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--pulse), var(--nova));
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
  font-family: var(--font-head);
  font-size: 0.9rem;
  box-shadow: 0 0 10px rgba(0, 200, 255, 0.3);
  flex-shrink: 0;
}

.user-menu-meta {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.user-menu-name {
  font-weight: 600;
  font-size: 0.86rem;
  color: var(--star);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-menu-email {
  font-size: 0.72rem;
  color: var(--dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-menu-divider {
  height: 1px;
  background: rgba(0, 200, 255, 0.12);
  margin: 2px 0;
}

.user-menu-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.75rem;
  color: var(--success);
  padding: 4px 6px;
  background: rgba(0, 255, 170, 0.08);
  border-radius: var(--radius-sm);
  border: 1px solid rgba(0, 255, 170, 0.2);
}

.pulse-indicator {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 8px var(--success);
  animation: pulse-dot 2s infinite;
}

.user-menu-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  background: transparent;
  border: none;
  color: var(--star);
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.2s;
  width: 100%;
  text-align: left;
}

.user-menu-logout {
  color: var(--danger);
  border: 1px solid rgba(255, 68, 102, 0.2);
  background: rgba(255, 68, 102, 0.05);
  font-weight: 500;
}

.user-menu-logout:hover {
  background: rgba(255, 68, 102, 0.18);
  border-color: var(--danger);
  box-shadow: 0 0 12px rgba(255, 68, 102, 0.2);
}

/* =========================================================
   AUTH MODAL (FUTURISTIK CYBERPUNK)
   ========================================================= */

.auth-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(3, 4, 10, 0.82);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  z-index: 3000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.auth-modal-overlay.open {
  display: flex;
  animation: fadeIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.auth-modal {
  background: linear-gradient(165deg, rgba(17, 28, 53, 0.96) 0%, rgba(8, 13, 26, 0.99) 100%);
  border: 1px solid rgba(0, 200, 255, 0.35);
  border-radius: var(--radius-lg);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.85), 0 0 35px rgba(0, 200, 255, 0.18);
  width: 100%;
  max-width: 420px;
  padding: 30px;
  position: relative;
  animation: scaleUp 0.28s cubic-bezier(0.16, 1, 0.3, 1);
}

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

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.auth-modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--rim);
  color: var(--dim);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
  font-size: 0.85rem;
}

.auth-modal-close:hover {
  color: var(--star);
  border-color: var(--pulse);
  background: rgba(0, 200, 255, 0.1);
}

.auth-modal-header {
  text-align: center;
  margin-bottom: 22px;
}

.auth-modal-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-head);
  font-size: 0.65rem;
  letter-spacing: 0.1em;
  color: var(--pulse);
  background: rgba(0, 200, 255, 0.08);
  border: 1px solid rgba(0, 200, 255, 0.25);
  padding: 4px 10px;
  border-radius: 999px;
  margin-bottom: 12px;
}

.status-pulse-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--pulse);
  box-shadow: 0 0 6px var(--pulse);
  animation: pulse-dot 1.8s infinite;
}

.auth-modal-title {
  font-family: var(--font-head);
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--star);
  margin: 0 0 8px;
}

.auth-modal-sub {
  font-size: 0.82rem;
  color: var(--dim);
  line-height: 1.5;
  margin: 0;
}

.auth-tabs {
  display: flex;
  gap: 6px;
  background: rgba(8, 13, 26, 0.7);
  padding: 4px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--rim);
  margin-bottom: 20px;
}

.auth-tab-btn {
  flex: 1;
  padding: 9px 12px;
  border: none;
  background: transparent;
  color: var(--dim);
  font-family: var(--font-body);
  font-size: 0.82rem;
  font-weight: 500;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.auth-tab-btn.active {
  background: rgba(0, 200, 255, 0.15);
  color: var(--pulse);
  font-weight: 600;
  border: 1px solid rgba(0, 200, 255, 0.3);
  box-shadow: 0 0 12px rgba(0, 200, 255, 0.15);
}

.auth-alert {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  line-height: 1.4;
  margin-bottom: 16px;
  display: none;
}

.auth-alert.error {
  display: block;
  background: rgba(255, 68, 102, 0.12);
  border: 1px solid rgba(255, 68, 102, 0.35);
  color: #ff99aa;
}

.auth-alert.success {
  display: block;
  background: rgba(0, 255, 170, 0.12);
  border: 1px solid rgba(0, 255, 170, 0.35);
  color: #88ffcc;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.auth-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.auth-field label {
  font-size: 0.76rem;
  font-weight: 500;
  letter-spacing: 0.03em;
  color: var(--dim);
}

.auth-field input {
  width: 100%;
  padding: 11px 14px;
  background: rgba(8, 13, 26, 0.8);
  border: 1px solid var(--rim);
  border-radius: var(--radius-sm);
  color: var(--star);
  font-family: var(--font-body);
  font-size: 0.88rem;
  outline: none;
  transition: all 0.2s ease;
}

.auth-field input:focus {
  border-color: var(--pulse);
  box-shadow: 0 0 12px rgba(0, 200, 255, 0.25);
  background: rgba(17, 28, 53, 0.6);
}

.auth-submit-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 18px;
  background: linear-gradient(135deg, #00c8ff 0%, #7b4fff 100%);
  border: none;
  border-radius: var(--radius-sm);
  color: #fff;
  font-family: var(--font-body);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.25s ease;
  box-shadow: 0 0 18px rgba(0, 200, 255, 0.3);
  margin-top: 6px;
}

.auth-submit-btn:hover {
  box-shadow: 0 0 24px rgba(0, 200, 255, 0.5);
  transform: translateY(-1px);
}

.auth-submit-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.auth-modal-footer {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  text-align: center;
}

.guest-bypass-btn {
  background: transparent;
  border: none;
  color: var(--dim);
  font-size: 0.78rem;
  cursor: pointer;
  transition: color 0.2s;
  padding: 4px;
}

.guest-bypass-btn:hover {
  color: var(--pulse);
}

/* Responsiveness on small screens */
@media (max-width: 600px) {
  .auth-user-name {
    display: none; /* di HP cukup tampilkan icon + badge GUEST / MEMBER */
  }
  .auth-pill-btn {
    padding: 5px 8px;
  }
  .user-menu-popover {
    left: auto;
    right: 0;
  }
}

