:root {
  --bg: #1b1c1f;
  --bg-side: #131416;
  --bg-elev: #26272b;
  --bg-hover: #2e3035;
  --border: #33353b;
  --text: #ececec;
  --muted: #9a9ca3;
  --accent: #19c37d;
  --accent-ink: #062b1b;
  --danger: #ff6b6b;
  --user-bubble: #2f3136;
  --radius: 14px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--text); font: 15px/1.6 var(--font); -webkit-font-smoothing: antialiased; }
button { font: inherit; color: inherit; cursor: pointer; }
[hidden] { display: none !important; }

.logo-dot { display: inline-block; width: 22px; height: 22px; border-radius: 50%;
  background: conic-gradient(from 210deg, #19c37d, #3b82f6, #a855f7, #19c37d); flex: none; }
.logo-dot.big { width: 52px; height: 52px; }

/* ── Layout ─────────────────────────────── */
.app { display: flex; height: 100vh; height: 100dvh; overflow: hidden; }

.sidebar { width: 272px; flex: none; background: var(--bg-side); display: flex; flex-direction: column;
  padding: 12px; gap: 6px; border-right: 1px solid #000; }
.sidebar-top { display: flex; align-items: center; justify-content: space-between; padding: 4px 6px 8px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 650; font-size: 16px; }

.new-chat { display: flex; align-items: center; gap: 8px; width: 100%; padding: 10px 12px;
  background: var(--bg-elev); border: 1px solid var(--border); border-radius: 10px; text-align: left; }
.new-chat:hover { background: var(--bg-hover); }

.conv-label { font-size: 12px; color: var(--muted); padding: 12px 8px 4px; text-transform: uppercase; letter-spacing: .04em; }
.conv-list { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; margin: 0 -4px; padding: 0 4px; }
.conv-empty { color: var(--muted); font-size: 13px; padding: 6px 8px; }
.conv-item { display: flex; align-items: center; border-radius: 8px; }
.conv-item:hover, .conv-item.active { background: var(--bg-elev); }
.conv-open { flex: 1; min-width: 0; text-align: left; background: none; border: 0; padding: 8px 8px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 14px; }
.conv-act { background: none; border: 0; opacity: 0; padding: 6px 6px; font-size: 13px; color: var(--muted); }
.conv-item:hover .conv-act, .conv-item.active .conv-act { opacity: 1; }
.conv-act:hover { color: var(--text); }

.sidebar-bottom { border-top: 1px solid var(--border); padding-top: 10px; display: flex; flex-direction: column; gap: 10px; }
.quota { font-size: 12px; color: var(--muted); padding: 0 6px; }
.quota-bar { height: 4px; background: var(--bg-elev); border-radius: 4px; margin-top: 6px; overflow: hidden; }
.quota-bar span { display: block; height: 100%; background: var(--accent); }
.me { display: flex; align-items: center; gap: 10px; padding: 4px 4px; }
.me form { margin: 0; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: #3b82f6; display: grid; place-items: center; font-weight: 700; flex: none; }
.me-info { flex: 1; min-width: 0; }
.me-name { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.me-email { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.icon-btn { background: none; border: 0; padding: 8px; border-radius: 8px; color: var(--muted); display: inline-grid; place-items: center; }
.icon-btn:hover { background: var(--bg-hover); color: var(--text); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: 8px; padding: 10px 14px; min-height: 52px; }
.topbar-title { flex: 1; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: #d6d6d6; }

.thread { flex: 1; overflow-y: auto; scroll-behavior: auto; }
.messages { max-width: 780px; margin: 0 auto; padding: 8px 20px 24px; display: flex; flex-direction: column; gap: 22px; }

/* ── Sambutan ───────────────────────────── */
.welcome { max-width: 720px; margin: 0 auto; min-height: 100%; display: flex; flex-direction: column;
  align-items: center; justify-content: center; text-align: center; padding: 24px 20px 40px; gap: 14px; }
.welcome h1 { font-size: 26px; font-weight: 650; margin: 6px 0 10px; }
.suggestions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; width: 100%; max-width: 560px; }
.chip { background: transparent; border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; text-align: left; color: #cfd0d4; font-size: 14px; }
.chip:hover { background: var(--bg-elev); }

/* ── Pesan ──────────────────────────────── */
.msg { display: flex; flex-direction: column; }
.msg.user { align-items: flex-end; }
.msg.user .msg-body { background: var(--user-bubble); padding: 10px 16px; border-radius: 20px; max-width: 85%;
  white-space: pre-wrap; word-wrap: break-word; }
.msg.user.failed .msg-body { opacity: .7; }
.msg-error { margin-top: 6px; font-size: 13px; color: var(--danger); display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }

.msg.assistant .msg-body { word-wrap: break-word; overflow-wrap: anywhere; }
.msg-body > :first-child { margin-top: 0; }
.msg-body > :last-child { margin-bottom: 0; }
.msg-body p { margin: 0 0 .8em; }
.msg-body h1, .msg-body h2, .msg-body h3 { line-height: 1.3; margin: 1.2em 0 .5em; }
.msg-body h1 { font-size: 1.4em; } .msg-body h2 { font-size: 1.25em; } .msg-body h3 { font-size: 1.1em; }
.msg-body ul, .msg-body ol { padding-left: 1.5em; margin: 0 0 .8em; }
.msg-body li { margin: .25em 0; }
.msg-body a { color: #7cc4ff; }
.msg-body blockquote { margin: 0 0 .8em; padding-left: 12px; border-left: 3px solid var(--border); color: #c9cad0; }
.msg-body table { border-collapse: collapse; margin: 0 0 1em; display: block; overflow-x: auto; max-width: 100%; }
.msg-body th, .msg-body td { border: 1px solid var(--border); padding: 6px 10px; text-align: left; }
.msg-body th { background: var(--bg-elev); }
.msg-body hr { border: 0; border-top: 1px solid var(--border); margin: 1.2em 0; }
.msg-body code { font-family: var(--mono); font-size: .88em; background: var(--bg-elev); padding: .15em .4em; border-radius: 6px; }
.msg-body pre { background: #0f1012; border: 1px solid var(--border); border-radius: 10px; margin: 0 0 1em; overflow: hidden; }
.msg-body pre code { display: block; padding: 12px 14px; overflow-x: auto; background: none; font-size: 13px; line-height: 1.55; }
.code-head { display: flex; justify-content: space-between; align-items: center; padding: 6px 12px; background: #1d1f23;
  font-size: 12px; color: var(--muted); font-family: var(--font); }
.code-copy { background: none; border: 0; color: var(--muted); font-size: 12px; padding: 2px 4px; }
.code-copy:hover { color: var(--text); }

.msg-actions { display: flex; gap: 4px; margin-top: 6px; opacity: 0; transition: opacity .15s; }
.msg.assistant:hover .msg-actions, .msg.assistant:last-child .msg-actions { opacity: 1; }
.msg.streaming .msg-actions { display: none; }
.mini-btn { background: none; border: 1px solid var(--border); border-radius: 8px; padding: 2px 10px; font-size: 12px; color: var(--muted); }
.mini-btn:hover { color: var(--text); background: var(--bg-elev); }

.typing { display: inline-flex; gap: 4px; padding: 6px 0; }
.typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); animation: blink 1.2s infinite ease-in-out; }
.typing i:nth-child(2) { animation-delay: .15s; } .typing i:nth-child(3) { animation-delay: .3s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }
.cursor { display: inline-block; width: 8px; height: 1em; background: var(--text); vertical-align: -2px; margin-left: 2px; animation: caret 1s steps(1) infinite; }
@keyframes caret { 50% { opacity: 0; } }

/* ── Kotak tulis ────────────────────────── */
.composer-wrap { padding: 8px 16px 10px; }
.composer { max-width: 780px; margin: 0 auto; display: flex; align-items: flex-end; gap: 8px;
  background: var(--bg-elev); border: 1px solid var(--border); border-radius: 24px; padding: 8px 8px 8px 18px; }
.composer:focus-within { border-color: #4a4d55; }
.composer textarea { flex: 1; resize: none; border: 0; outline: 0; background: transparent; color: var(--text);
  font: inherit; line-height: 1.5; max-height: 220px; padding: 7px 0; }
.composer textarea::placeholder { color: var(--muted); }
.send-btn { width: 36px; height: 36px; flex: none; border-radius: 50%; border: 0; background: var(--text); color: #111;
  display: grid; place-items: center; }
.send-btn:disabled { background: #4a4c52; color: #2a2b2f; cursor: default; }
.send-btn .ic-stop { display: none; }
.send-btn.stop .ic-send { display: none; }
.send-btn.stop .ic-stop { display: block; }
.disclaimer { text-align: center; font-size: 12px; color: var(--muted); margin-top: 8px; }

.toast { position: fixed; left: 50%; bottom: 96px; transform: translate(-50%, 20px); background: #3a3c42; color: #fff;
  padding: 10px 16px; border-radius: 10px; font-size: 14px; opacity: 0; pointer-events: none; transition: .2s; z-index: 50; max-width: 90vw; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.scrim { display: none; }
.only-mobile { display: none; }

/* ── Mode jendela di dalam RAS Genesis ─ */
.quota-link { color: var(--accent); font-size: 12px; display: inline-block; margin-top: 4px; }
body.embed .disclaimer { display: none; }
body.embed .composer-wrap { padding-bottom: 8px; }
body.embed .welcome h1 { font-size: 19px; }

/* ── Mobile ─────────────────────────────── */
@media (max-width: 820px) {
  .only-mobile { display: inline-grid; }
  .sidebar { position: fixed; inset: 0 auto 0 0; z-index: 40; width: 84vw; max-width: 300px;
    transform: translateX(-100%); transition: transform .22s ease; }
  .sidebar.open { transform: none; }
  .scrim { position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 30; }
  .scrim.show { display: block; }
  .conv-act { opacity: 1; }
  .topbar { border-bottom: 1px solid #000; }
  .topbar-title { text-align: center; }
  .messages { padding: 12px 14px 20px; }
  .welcome h1 { font-size: 21px; }
  .suggestions { grid-template-columns: 1fr; }
  .composer-wrap { padding: 6px 10px calc(8px + env(safe-area-inset-bottom)); }
  .msg.user .msg-body { max-width: 92%; }
}

/* ── Halaman masuk / daftar ─────────────── */
.auth-body { display: grid; place-items: center; min-height: 100vh; padding: 24px; background:
  radial-gradient(1200px 600px at 50% -10%, #23362c 0%, var(--bg) 60%); }
.auth-card { width: 100%; max-width: 380px; background: var(--bg-side); border: 1px solid var(--border); border-radius: 18px; padding: 28px; }
.auth-logo { display: flex; align-items: center; gap: 10px; font-weight: 650; margin-bottom: 18px; }
.auth-card h1 { font-size: 22px; margin: 0 0 16px; }
.auth-form { display: flex; flex-direction: column; gap: 14px; }
.auth-form label { display: flex; flex-direction: column; gap: 6px; font-size: 14px; color: #cfd0d4; }
.auth-form small { color: var(--muted); }
.auth-form input { background: var(--bg-elev); border: 1px solid var(--border); border-radius: 10px; padding: 11px 12px; color: var(--text); font: inherit; }
.auth-form input:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
.btn-primary { background: var(--accent); color: var(--accent-ink); border: 0; border-radius: 10px; padding: 12px; font-weight: 700; margin-top: 4px; }
.btn-primary:hover { filter: brightness(1.08); }
.alert { background: rgba(255,107,107,.12); border: 1px solid rgba(255,107,107,.4); color: #ffb3b3; padding: 10px 12px; border-radius: 10px; margin-bottom: 14px; font-size: 14px; }
.auth-switch { text-align: center; font-size: 14px; color: var(--muted); margin: 18px 0 0; }
.auth-switch a { color: var(--accent); }
.muted { color: var(--muted); }

/* Tombol masuk lewat RAS */
.btn-block { display: block; text-align: center; text-decoration: none; margin-top: 16px; }
.auth-card .muted strong { color: var(--text); }
.small-link { font-size: 12px; margin-top: 10px; }
.small-link a { color: var(--muted); }
