  :root{
    --bg: #0f1011;
    --bg-2: #0b0b0c;
    --chat-bg: linear-gradient(180deg, rgba(22,22,23,0.6), rgba(12,12,13,0.6));
    --glass: rgba(255,255,255,0.03);
    --bubble-ai: rgba(30,31,33,0.9);
    --bubble-user: rgba(44,45,48,0.95);
    --text: #e9eef0;
    --muted: #9aa3a8;
    --accent: #10a37f;
    --accent-glow: rgba(16,163,127,0.18);
    --border: rgba(255,255,255,0.04);
    --radius: 14px;
  }

  /* light theme vars */
  :root.light {
    --bg: #f6f7f8;
    --bg-2: #ffffff;
    --glass: rgba(0,0,0,0.03);
    --chat-bg: linear-gradient(180deg, rgba(255,255,255,0.9), rgba(250,250,250,0.9));
    --bubble-ai: rgba(245,246,247,0.98);
    --bubble-user: rgba(230,231,232,0.98);
    --text: #111214;
    --muted: #6b7176;
    --accent-glow: rgba(16,163,127,0.09);
    --border: rgba(0,0,0,0.06);
  }

  * { box-sizing: border-box; -webkit-font-smoothing:antialiased; -moz-osx-font-smoothing:grayscale; }
  html,body{height:100%; margin:0; font-family:Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial;}
  body {
    display:flex; flex-direction:column; background:var(--bg);
    color:var(--text); min-height:100vh; padding-bottom: 70px;
  }

  header {
    position:sticky; top:0; z-index:12;
    display:flex; align-items:center; justify-content:space-between;
    gap:12px; padding:14px 18px;
    background: linear-gradient(180deg, rgba(0,0,0,0.12), transparent);
    backdrop-filter: blur(6px) saturate(120%);
    border-bottom: 1px solid var(--border);
  }
  .brand {
    display:flex; align-items:center; gap:12px;
  }
  .logo {
    width:40px;
    height:40px;
    border-radius:10px;
    object-fit:contain;
    box-shadow: 0 6px 18px var(--accent-glow);
    border-radius: 50%;
  }
  .title { font-weight:700; font-size:15px; letter-spacing:0.2px; }
  .version { font-size:12px; color:var(--muted); margin-top:2px; }

  .header-actions { display:flex; align-items:center; gap:8px; }

  .toggle {
    display:flex; align-items:center; gap:8px; background:var(--glass);
    padding:6px 8px; border-radius:999px; border:1px solid var(--border);
  }
  .switch {
    width:44px; height:26px; border-radius:999px; background:rgba(255,255,255,0.06); position:relative; cursor:pointer;
    box-shadow: inset 0 -2px 4px rgba(0,0,0,0.25);
  }
  .knob {
    width:20px; height:20px; border-radius:50%; background:#fff; position:absolute; top:3px; left:3px;
    transition: all 260ms cubic-bezier(.2,.9,.2,1);
    box-shadow: 0 4px 10px rgba(2,6,23,0.45);
  }
  .switch.on { background: linear-gradient(90deg, rgba(16,163,127,0.15), rgba(16,163,127,0.03)); }
  .switch.on .knob { transform: translateX(18px); background: white; }

  main { display:flex; flex:1; overflow:hidden; height:calc(100vh - 72px); }
#chat {
  flex: 1;
  overflow: auto;
  padding: 28px;
  background: var(--chat-bg);
  transition: background 360ms ease;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 100px; /* ⬅️ Tambahkan ini! */
}

  .msg { display:flex; margin:12px 0; gap:12px; align-items:flex-end; }
  .msg.you { justify-content:flex-end; }
  .bubble {
    max-width:78%; padding:12px 14px; border-radius:var(--radius);
    line-height:1.5; font-size:15px; word-wrap:break-word; white-space:pre-wrap;
    border:1px solid var(--border); backdrop-filter: blur(6px) saturate(120%);
    box-shadow: 0 6px 20px rgba(2,6,23,0.35);
    transition: transform 220ms ease, box-shadow 220ms ease;
  }
  .ai .bubble { background:var(--bubble-ai); border-top-left-radius:8px; }
  .you .bubble { background:var(--bubble-user); border-top-right-radius:8px; transform: translateY(0); }

  .bubble:hover { transform: translateY(-4px); }

  .typing { font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, "Roboto Mono", monospace; color:var(--muted); }

  /* code & pre */
  .bubble pre, .bubble code { background: rgba(0,0,0,0.12); padding:6px 8px; border-radius:8px; font-family: ui-monospace, monospace; display:block; }
  .bubble a { color:var(--accent); text-decoration:none; }
  .bubble a:hover { text-decoration: underline; }

  /* controls */
  #controls {
    position:fixed; left:0; right:0; bottom:0; padding:12px 16px;
    display:flex; gap:10px; align-items:center; background: linear-gradient(180deg, rgba(0,0,0,0.18), rgba(0,0,0,0.03));
    border-top:1px solid var(--border);
    backdrop-filter: blur(8px);
  }
  textarea {
    flex:1; resize:none; min-height:44px; max-height:220px; padding:12px 14px;
    background: transparent; color:var(--text); border-radius:12px; border:1px solid var(--border); outline:none;
    font-size:15px;
  }
  textarea::placeholder { color:var(--muted); opacity:0.9; }
  .btn {
    padding:10px 14px; border-radius:12px; border:none; background:linear-gradient(90deg,var(--accent), #0bb39a);
    color:white; font-weight:600; cursor:pointer;
  }
  .icon-btn { background:transparent; border:none; color:var(--text); font-size:18px; cursor:pointer; padding:8px; border-radius:8px; }
  .icon-btn:hover { background:var(--glass); }

  /* modern scrollbar */
  #chat::-webkit-scrollbar { width:10px; }
  #chat::-webkit-scrollbar-thumb { background:linear-gradient(180deg, rgba(255,255,255,0.02), rgba(255,255,255,0.04)); border-radius:999px; border:2px solid transparent; background-clip: padding-box; }
  #chat::-webkit-scrollbar-track { background:transparent; }

  /* responsive */
  @media (max-width:720px){
    header{ padding:10px 12px; }
    .logo{ width:36px; height:36px; }
    .bubble{ max-width:88%; font-size:14px; }
    #chat{ padding:16px; }
    #controls{ padding:10px; }
  }

  /* small helper */
  .muted { color:var(--muted); font-size:13px; }
  .meta { font-size:12px; color:var(--muted); margin-left:8px; }

.bubble-appear {
  opacity: 0;
  transform: translateY(10px);
  animation: bubbleFadeSlide 0.28s ease forwards;
}

@keyframes bubbleFadeSlide {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

#loading-screen {
  position: fixed;
  inset: 0;
  background: radial-gradient(circle at center, #030303 0%, #000000 100%);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 9999;
  font-family: ui-monospace, "SFMono-Regular", Menlo, Monaco, "Roboto Mono", monospace;
  color: #00ff99;
  -webkit-font-smoothing: subpixel-antialiased;
}

.terminal-boot {
  width: min(920px, calc(100% - 40px));
  max-height: 72vh;
  padding: 22px;
  border-radius: 10px;
  background: linear-gradient(180deg, rgba(0,0,0,0.36), rgba(0,0,0,0.14));
  border: 1px solid rgba(0,255,153,0.06);
  box-shadow: 0 18px 60px rgba(0,0,0,0.6), inset 0 1px 0 rgba(255,255,255,0.02);
  overflow: hidden;
  display: flex;
  gap: 18px;
  align-items: center;
}

/* left terminal area */
.boot-screen {
  flex: 1;
  min-width: 380px;
  max-height: 56vh;
  overflow: hidden;
  position: relative;
}

/* inner viewport that scrolls the lines */
.boot-window {
  max-height: 56vh;
  overflow: hidden;
  position: relative;
}

/* container for log lines */
.boot-lines {
  display: block;
  white-space: pre-wrap;
  line-height: 1.25;
  font-size: 13.6px;
  letter-spacing: 0.02em;
  color: rgba(0,255,153,0.95);
  transform-origin: left top;
}

/* small right panel with DUTA AI label for final flash */
.boot-right {
  width: 140px;
  display:flex;
  flex-direction:column;
  align-items:center;
  gap:8px;
  justify-content:center;
  color: rgba(255,255,255,0.8);
  font-weight:700;
  font-family: "Poppins", ui-sans-serif, system-ui;
  letter-spacing:0.08em;
  text-transform:uppercase;
}

/* ready/flash style */
.boot-final {
  display:block;
  margin-top:10px;
  font-size:16px;
  color: rgba(0,255,153,1);
  text-shadow: 0 6px 18px rgba(0,255,153,0.06);
  opacity: 0;
  transform: translateY(6px) scale(0.98);
  transition: all 260ms ease;
}

@keyframes loaderFadeOut {
  0% { opacity: 1; }
  100% { opacity: 0; visibility: hidden; }
}

/* fade out applied to entire loading-screen */
.loader-exit {
  animation: loaderFadeOut 420ms ease-in-out forwards;
}

/* quick flicker flash for DUTA label */
.boot-right .duta-flash {
  font-size:18px;
  color: rgba(0,255,153,0.0);
  -webkit-text-stroke: 0.8px rgba(0,255,153,0.06);
  transition: color 160ms ease, transform 220ms ease;
}

/* small caret effect for typing feel */
.caret {
  display: inline-block;
  width: 8px;
  height: 14px;
  background: rgba(0,255,153,0.9);
  margin-left: 6px;
  vertical-align: middle;
  animation: blink 680ms steps(2,end) infinite;
}
@keyframes blink { 0%,49% { opacity:1 } 50%,100% { opacity:0 } }

/* responsive tweaks */
@media (max-width:720px){
  .terminal-boot { padding:14px; }
  .boot-right { display:none; }
  .boot-lines { font-size:13px; }
}

/* ===== Toast Animation ===== */
@keyframes toastIn {
  0% { opacity: 0; transform: translate(-50%, -20px) scale(0.95); filter: blur(6px); }
  60% { opacity: 1; transform: translate(-50%, 0) scale(1.02); filter: blur(0); }
  100% { opacity: 1; transform: translate(-50%, 0) scale(1); filter: blur(0); }
}

@keyframes toastOut {
  0% { opacity: 1; transform: translate(-50%, 0) scale(1); filter: blur(0); }
  100% { opacity: 0; transform: translate(-50%, 10px) scale(0.95); filter: blur(6px); }
}

.toast-popup {
  position: fixed;
  left: 50%;
  top: 20%;
  transform: translateX(-50%);
  background: rgba(0,0,0,0.75);
  color: white;
  padding: 10px 16px;
  border-radius: 12px;
  z-index: 9999;
  font-weight: 600;
  font-size: 15px;
  letter-spacing: 0.3px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.3);
  backdrop-filter: blur(8px);
  animation: toastIn 0.4s cubic-bezier(.25,.9,.3,1.2) forwards;
}

/* ✅ Responsive overhaul */
@media (max-width: 720px) {
  header {
    padding: 10px 12px;
  }

  .logo {
    width: 34px;
    height: 34px;
  }

  .bubble {
    max-width: 90%;
    font-size: 14px;
    padding: 10px 12px;
    line-height: 1.45;
  }

  #chat {
    padding: 12px;
    height: auto; /* biar adaptif */
    min-height: calc(100dvh - 150px);
  }

  #controls {
    position: sticky;
    bottom: 0;
    padding: 8px 10px;
    gap: 8px;
  }

  textarea {
    font-size: 14px;
    min-height: 40px;
    max-height: 180px;
  }

  .btn {
    padding: 10px 16px;
    font-size: 14px;
  }

  .icon-btn {
    padding: 10px;
    font-size: 20px;
  }

  /* ✅ Fix untuk loading screen di mobile */
  .terminal-boot {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
    padding: 14px;
  }
  .boot-lines {
    font-size: 12px;
  }
  .boot-right {
    display: none;
  }
}

/* ✅ Biar input ga ketiban keyboard */
@supports (-webkit-touch-callout: none) {
  #controls {
    position: fixed;
    inset-inline: 0;
    bottom: env(safe-area-inset-bottom);
  }

  textarea:focus {
    scroll-margin-bottom: 140px; /* ngasih jarak biar tetep kelihatan */
  }
}

/* ✅ Small phones */
@media (max-width: 400px) {
  .bubble {
    max-width: 94%;
    font-size: 13px;
  }
  textarea {
    font-size: 13px;
  }
}

@supports (height: 100dvh) {
  body { min-height: 100dvh; }
  main { height: calc(100dvh - 72px); }
}

/* ✅ Compact boot-right untuk mobile */
@media (max-width: 720px) {
  .boot-right {
    display: flex !important;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    width: 100%;
    gap: 6px;
    padding-top: 4px;
    border-top: 1px solid rgba(0,255,153,0.08);
    margin-top: 10px;
    font-size: 11.5px;
    opacity: 0.85;
  }

  .boot-right > div {
    margin: 0;
  }

  .boot-right .duta-flash {
    font-size: 13px;
    color: rgba(0,255,153,1);
    -webkit-text-stroke: none;
  }

  .boot-right .duta-version {
    font-size: 11px;
    color: rgba(255,255,255,0.6);
  }

  .boot-final {
    margin-top: 0;
    font-size: 12px;
  }
}
