:root {
    --bg-white: #FFFFFF;
    --panel-blue: #EAF2FC;
    --panel-blue-hover: #DCEBFB;
    --accent-blue: #2D6CDF;
    --accent-blue-hover: #2559BE;
    --ink: #14171F;
    --ink-soft: #383D47;
    --muted: #6B7280;
    --border: #E4EAF2;
    --sidebar-w: 280px;
  }

  /* ---------- Mode gelap (diterapkan lewat atribut data-theme="dark" di <html>) ---------- */
  html[data-theme="dark"] {
    --bg-white: #14171F;
    --panel-blue: #1C2230;
    --panel-blue-hover: #262E40;
    --accent-blue: #4C8DFF;
    --accent-blue-hover: #6BA0FF;
    --ink: #F2F4F8;
    --ink-soft: #C7CDD9;
    --muted: #8B93A3;
    --border: #2A3244;
  }

  html, body, .sidebar, .topbar, .prompt-box, .card {
    transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
  }

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

  html, body {
    height: 100%;
    width: 100%;
    max-width: 100vw;
    font-family: 'Manrope', sans-serif;
    background: var(--bg-white);
    color: var(--ink);
    overflow: hidden;
  }

  .material-symbols-outlined {
    font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24;
    font-size: 22px;
    line-height: 1;
    user-select: none;
  }

  /* ---------- App shell ---------- */
  .app {
    position: relative;
    height: 100vh;
    width: 100vw;
    display: flex;
  }

  /* ---------- Topbar ---------- */
  .topbar {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    background: var(--bg-white);
    z-index: 30;
  }

  .icon-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    border-radius: 12px;
    border: none;
    background: transparent;
    color: var(--ink);
    cursor: pointer;
    transition: background 0.15s ease;
  }
  .icon-btn:hover { background: var(--panel-blue); }
  .icon-btn:active { background: var(--panel-blue-hover); }
  .icon-btn:focus-visible {
    outline: 2px solid var(--accent-blue);
    outline-offset: 2px;
  }

  .brand {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 800;
    font-size: 16px;
    letter-spacing: -0.01em;
    color: var(--ink);
  }
  .brand .dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent-blue);
  }

  .avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--accent-blue);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 14px;
    cursor: pointer;
  }

  /* ---------- CTA "Masuk" untuk state belum login ---------- */
  .signin-cta-topbar {
    display: flex;
    align-items: center;
    gap: 6px;
    height: 36px;
    padding: 0 16px;
    border-radius: 999px;
    background: var(--ink);
    color: #fff;
    border: none;
    font-family: 'Manrope', sans-serif;
    font-weight: 700;
    font-size: 13.5px;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.15s ease;
  }
  .signin-cta-topbar:hover { background: #000; }
  .signin-cta-topbar .material-symbols-outlined { font-size: 18px; color: #fff; }

  .signin-cta-sidebar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    height: 44px;
    border-radius: 12px;
    background: var(--ink);
    color: #fff;
    border: none;
    font-family: 'Manrope', sans-serif;
    font-weight: 700;
    font-size: 14px;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.15s ease;
  }
  .signin-cta-sidebar:hover { background: #000; }
  .signin-cta-sidebar .material-symbols-outlined { font-size: 19px; color: #fff; }

  /* ---------- Sidebar (overlay) ---------- */
  .backdrop {
    position: fixed;
    inset: 0;
    background: rgba(20, 23, 31, 0.28);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
    z-index: 40;
  }
  .backdrop.open {
    opacity: 1;
    pointer-events: auto;
  }

  .sidebar {
    position: fixed;
    top: 0; left: 0;
    height: 100%;
    width: var(--sidebar-w);
    max-width: 85vw;
    background: var(--panel-blue);
    border-right: 1px solid var(--border);
    transform: translateX(-100%);
    transition: transform 0.22s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 50;
    display: flex;
    flex-direction: column;
    padding: 16px 12px;
  }
  .sidebar.open { transform: translateX(0); }

  .sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 4px 8px 16px 8px;
  }

  .new-chat-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 11px 14px;
    border-radius: 12px;
    border: none;
    background: var(--accent-blue);
    color: #fff;
    font-family: inherit;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: background 0.15s ease;
  }
  .new-chat-btn:hover { background: var(--accent-blue-hover); }

  .history-label {
    font-size: 12px;
    font-weight: 700;
    color: var(--muted);
    text-transform: none;
    margin: 20px 10px 8px 10px;
  }

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

  .history-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 10px;
    border-radius: 10px;
    color: var(--ink-soft);
    font-size: 13.5px;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: background 0.15s ease;
  }
  .history-item:hover { background: var(--panel-blue-hover); }
  .history-item.active {
    background: var(--bg-white);
    color: var(--ink);
    font-weight: 600;
  }
  .history-item .material-symbols-outlined {
    font-size: 18px;
    color: var(--muted);
    flex-shrink: 0;
  }

  .sidebar-footer {
    border-top: 1px solid var(--border);
    padding-top: 12px;
    display: flex;
    align-items: center;
    gap: 10px;
    padding-left: 8px;
  }
  .sidebar-footer .name {
    font-size: 13.5px;
    font-weight: 600;
  }
  .sidebar-footer .plan {
    font-size: 11.5px;
    color: var(--muted);
  }

  /* ---------- Main chat area ---------- */
  .main {
    flex: 1;
    height: 100vh;
    height: 100dvh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 0 20px;
  }

  .hero {
    width: 100%;
    max-width: 680px;
    text-align: center;
    margin-bottom: 28px;
  }

  .hero h1 {
    font-size: 30px;
    font-weight: 800;
    letter-spacing: -0.02em;
    color: var(--ink);
    margin-bottom: 8px;
  }
  .hero h1 span {
    color: var(--accent-blue);
  }

  .hero p {
    font-size: 15.5px;
    color: var(--muted);
    font-weight: 500;
  }

  /* ---------- Prompt input ---------- */
  .prompt-wrap {
    position: fixed;
    left: 50%;
    bottom: 28px;
    transform: translateX(-50%);
    width: calc(100% - 40px);
    max-width: 680px;
    z-index: 20;
  }

  .prompt-box {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    background: var(--panel-blue);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 10px 10px 10px 10px;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
  }
  .prompt-box:focus-within {
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 3px rgba(45, 108, 223, 0.12);
  }

  .prompt-box textarea {
    flex: 1;
    resize: none;
    border: none;
    background: transparent;
    outline: none;
    font-family: inherit;
    font-size: 15px;
    color: var(--ink);
    padding: 9px 4px;
    max-height: 160px;
    line-height: 1.4;
  }
  .prompt-box textarea::placeholder { color: var(--muted); }

  .round-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.15s ease, transform 0.1s ease;
  }

  .plus-btn {
    background: var(--bg-white);
    color: var(--ink);
    border: 1px solid var(--border);
  }
  .plus-btn:hover { background: var(--panel-blue-hover); }
  .plus-btn.active {
    background: var(--ink);
    color: var(--bg-white);
    transform: rotate(45deg);
  }

  .send-btn {
    background: var(--accent-blue);
    color: #fff;
  }
  .send-btn:hover { background: var(--accent-blue-hover); }
  .send-btn:disabled {
    background: var(--border);
    color: var(--muted);
    cursor: not-allowed;
  }

  .hint {
    text-align: center;
    font-size: 12px;
    color: var(--muted);
    margin-top: 12px;
  }

  /* ---------- Area pesan chat (percakapan berjalan) ---------- */
  .chat-messages {
    display: none;
    position: fixed;
    top: 64px;
    bottom: 140px;
    left: 0;
    right: 0;
    overflow-y: auto;
    z-index: 5;
  }
  .chat-messages.active { display: block; }

  .chat-messages-inner {
    max-width: 680px;
    margin: 0 auto;
    padding: 24px 20px 8px;
  }

  .msg-row {
    display: flex;
    margin-bottom: 24px;
  }
  .msg-row.user { justify-content: flex-end; }
  .msg-row.assistant { justify-content: flex-start; }

  /* Bubble tetap dipakai HANYA untuk pesan user (kanan) */
  .msg-bubble.user {
    max-width: 78%;
    padding: 12px 16px;
    border-radius: 18px;
    font-size: 14.5px;
    line-height: 1.6;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    background: var(--accent-blue);
    color: #fff;
    border-bottom-right-radius: 4px;
  }

  /* Pesan AI: TANPA bubble, TANPA border — teks polos selebar container */
  .msg-text.assistant {
    width: 100%;
    max-width: 100%;
    color: var(--ink);
    font-size: 15px;
    line-height: 1.8;
    letter-spacing: -0.005em;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
  }
  .msg-text.assistant.error {
    color: #A6392F;
  }

  /* ---------- Animasi typing (AI sedang mengetik) — tanpa bubble/border ---------- */
  .typing-indicator {
    display: flex;
    align-items: center;
    gap: 6px;
    height: 24px;
    padding: 2px 0;
  }
  .typing-indicator span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--accent-blue);
    opacity: 0.35;
    animation: typingPulse 1.1s cubic-bezier(0.4, 0, 0.2, 1) infinite;
  }
  .typing-indicator span:nth-child(2) { animation-delay: 0.18s; }
  .typing-indicator span:nth-child(3) { animation-delay: 0.36s; }

  @keyframes typingPulse {
    0%, 80%, 100% { transform: scale(0.7); opacity: 0.3; }
    40% { transform: scale(1.15); opacity: 1; }
  }

  /* ---------- Formatting teks AI (markdown-lite) ---------- */
  .msg-text.assistant {
    font-weight: 450;
  }
  .msg-text.assistant strong { font-weight: 700; color: var(--ink); }
  .msg-text.assistant em { font-style: italic; }

  .msg-text.assistant code.inline-code {
    font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
    font-size: 0.87em;
    background: var(--panel-blue);
    border: 1px solid var(--border);
    color: var(--accent-blue-hover);
    padding: 2px 6px;
    border-radius: 6px;
    white-space: nowrap;
  }

  .msg-text.assistant .code-block-wrap {
    margin: 14px 0;
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
    background: #FBFCFE;
  }

  .code-block-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 8px 8px 14px;
    background: #F1F4F9;
    border-bottom: 1px solid var(--border);
  }

  .code-lang-label {
    font-size: 12px;
    font-weight: 700;
    color: var(--ink-soft);
    font-family: 'Manrope', sans-serif;
  }

  .code-block-actions { display: flex; gap: 2px; }

  .code-action-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 7px;
    border: none;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
  }
  .code-action-btn:hover { background: var(--panel-blue-hover); color: var(--ink); }
  .code-action-btn.copied { color: #1E8E3E; }
  .code-action-btn .material-symbols-outlined { font-size: 16px; }

  .msg-text.assistant pre.code-block {
    margin: 0;
    border: none;
    border-radius: 0;
    background: #FBFCFE;
    padding: 16px;
    overflow-x: auto;
    font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
    font-size: 13px;
    line-height: 1.65;
    color: #24292E;
  }
  .msg-text.assistant pre.code-block code { background: none; border: none; padding: 0; }

  /* ---------- Syntax highlight custom — muted, mirip GitHub/VSCode light ---------- */
  .hljs-keyword, .hljs-selector-tag, .hljs-literal { color: #A626A4; }
  .hljs-string, .hljs-attr-value, .hljs-regexp { color: #0A7B55; }
  .hljs-number { color: #B35900; }
  .hljs-comment, .hljs-quote { color: #6B7280; font-style: italic; }
  .hljs-function, .hljs-title, .hljs-title.function_ { color: #1B6FC9; }
  .hljs-built_in, .hljs-type, .hljs-class .hljs-title { color: #C2410C; }
  .hljs-attr, .hljs-attribute, .hljs-symbol { color: #B35900; }
  .hljs-tag { color: #22863A; }
  .hljs-name { color: #22863A; }
  .hljs-variable, .hljs-template-variable, .hljs-params { color: var(--ink-soft); }
  .hljs-punctuation, .hljs-operator, .hljs-meta { color: var(--ink-soft); }
  .hljs-deletion { background: #FFEEF0; }
  .hljs-addition { background: #E6FFED; }

  /* ---------- Code block di mode gelap (warna hardcoded, tidak ikut var otomatis) ---------- */
  html[data-theme="dark"] .msg-text.assistant .code-block-wrap { background: #10131A; border-color: var(--border); }
  html[data-theme="dark"] .code-block-header { background: #1A1F2B; border-color: var(--border); }
  html[data-theme="dark"] .msg-text.assistant pre.code-block { background: #10131A; color: #E2E6EE; }

  /* ---------- Tema syntax: Dracula (data-code-theme="dracula" di <html>) ---------- */
  html[data-code-theme="dracula"] .msg-text.assistant .code-block-wrap { background: #282A36; border-color: #44475A; }
  html[data-code-theme="dracula"] .code-block-header { background: #21222C; border-color: #44475A; }
  html[data-code-theme="dracula"] .code-lang-label { color: #F8F8F2; }
  html[data-code-theme="dracula"] .code-action-btn { color: #BFC3D6; }
  html[data-code-theme="dracula"] .code-action-btn:hover { background: #44475A; color: #F8F8F2; }
  html[data-code-theme="dracula"] .msg-text.assistant pre.code-block { background: #282A36; color: #F8F8F2; }
  html[data-code-theme="dracula"] .hljs-keyword, html[data-code-theme="dracula"] .hljs-selector-tag, html[data-code-theme="dracula"] .hljs-literal { color: #FF79C6; }
  html[data-code-theme="dracula"] .hljs-string, html[data-code-theme="dracula"] .hljs-regexp { color: #F1FA8C; }
  html[data-code-theme="dracula"] .hljs-number { color: #BD93F9; }
  html[data-code-theme="dracula"] .hljs-comment, html[data-code-theme="dracula"] .hljs-quote { color: #6272A4; }
  html[data-code-theme="dracula"] .hljs-function, html[data-code-theme="dracula"] .hljs-title { color: #50FA7B; }
  html[data-code-theme="dracula"] .hljs-built_in, html[data-code-theme="dracula"] .hljs-type { color: #8BE9FD; }
  html[data-code-theme="dracula"] .hljs-attr, html[data-code-theme="dracula"] .hljs-attribute { color: #FFB86C; }
  html[data-code-theme="dracula"] .hljs-tag, html[data-code-theme="dracula"] .hljs-name { color: #FF79C6; }
  html[data-code-theme="dracula"] .hljs-variable, html[data-code-theme="dracula"] .hljs-params { color: #F8F8F2; }
  html[data-code-theme="dracula"] .msg-text.assistant code.inline-code { background: #282A36; border-color: #44475A; color: #FF79C6; }

  /* ---------- Tema syntax: Monokai (data-code-theme="monokai" di <html>) ---------- */
  html[data-code-theme="monokai"] .msg-text.assistant .code-block-wrap { background: #272822; border-color: #49483E; }
  html[data-code-theme="monokai"] .code-block-header { background: #1E1F1C; border-color: #49483E; }
  html[data-code-theme="monokai"] .code-lang-label { color: #F8F8F2; }
  html[data-code-theme="monokai"] .code-action-btn { color: #C4C5B7; }
  html[data-code-theme="monokai"] .code-action-btn:hover { background: #49483E; color: #F8F8F2; }
  html[data-code-theme="monokai"] .msg-text.assistant pre.code-block { background: #272822; color: #F8F8F2; }
  html[data-code-theme="monokai"] .hljs-keyword, html[data-code-theme="monokai"] .hljs-selector-tag, html[data-code-theme="monokai"] .hljs-literal { color: #F92672; }
  html[data-code-theme="monokai"] .hljs-string, html[data-code-theme="monokai"] .hljs-regexp { color: #E6DB74; }
  html[data-code-theme="monokai"] .hljs-number { color: #AE81FF; }
  html[data-code-theme="monokai"] .hljs-comment, html[data-code-theme="monokai"] .hljs-quote { color: #75715E; }
  html[data-code-theme="monokai"] .hljs-function, html[data-code-theme="monokai"] .hljs-title { color: #A6E22E; }
  html[data-code-theme="monokai"] .hljs-built_in, html[data-code-theme="monokai"] .hljs-type { color: #66D9EF; }
  html[data-code-theme="monokai"] .hljs-attr, html[data-code-theme="monokai"] .hljs-attribute { color: #FD971F; }
  html[data-code-theme="monokai"] .hljs-tag, html[data-code-theme="monokai"] .hljs-name { color: #F92672; }
  html[data-code-theme="monokai"] .hljs-variable, html[data-code-theme="monokai"] .hljs-params { color: #F8F8F2; }
  html[data-code-theme="monokai"] .msg-text.assistant code.inline-code { background: #272822; border-color: #49483E; color: #A6E22E; }

  /* ---------- Ukuran font pesan (data-font-size di <html>) ---------- */
  html[data-font-size="small"] .msg-text.assistant,
  html[data-font-size="small"] .msg-bubble.user { font-size: 13.5px; }
  html[data-font-size="large"] .msg-text.assistant,
  html[data-font-size="large"] .msg-bubble.user { font-size: 17px; }

  .msg-text.assistant ul, .msg-text.assistant ol {
    margin: 8px 0 8px 20px;
    padding: 0;
  }
  .msg-text.assistant li { margin-bottom: 4px; }

  .msg-text.assistant h2 {
    font-size: 1.22em;
    font-weight: 800;
    margin: 18px 0 8px;
    color: var(--ink);
  }
  .msg-text.assistant h3 {
    font-size: 1.08em;
    font-weight: 700;
    margin: 16px 0 6px;
    color: var(--ink);
  }
  .msg-text.assistant h4 {
    font-size: 1em;
    font-weight: 700;
    margin: 14px 0 4px;
    color: var(--ink);
  }

  .msg-text.assistant .md-table-wrap {
    margin: 14px 0;
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: 12px;
  }
  .msg-text.assistant table.md-table {
    border-collapse: collapse;
    width: 100%;
    min-width: 100%;
    font-size: 13.5px;
  }
  .msg-text.assistant table.md-table th,
  .msg-text.assistant table.md-table td {
    padding: 10px 14px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    vertical-align: top;
  }
  .msg-text.assistant table.md-table th {
    background: #F1F4F9;
    font-weight: 700;
    color: var(--ink-soft);
    font-size: 12.5px;
    white-space: nowrap;
  }
  .msg-text.assistant table.md-table tr:last-child td { border-bottom: none; }
  .msg-text.assistant table.md-table tbody tr:nth-child(even) td { background: #FBFCFE; }

  .msg-text.assistant p { margin-bottom: 10px; }
  .msg-text.assistant p:last-child { margin-bottom: 0; }

  /* ---------- Tombol aksi pesan (like, dislike, copy, share) ---------- */
  .msg-actions {
    display: flex;
    align-items: center;
    gap: 2px;
    margin-top: 10px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
  }
  .msg-actions.ready { opacity: 1; pointer-events: auto; }

  .action-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: none;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
  }
  .action-btn:hover { background: var(--panel-blue); color: var(--ink); }
  .action-btn .material-symbols-outlined { font-size: 18px; }

  .action-btn.like-btn.active { color: #1E8E3E; }
  .action-btn.dislike-btn.active { color: #D93025; }
  .action-btn.copy-btn.copied { color: #1E8E3E; }

  @keyframes actionPulse {
    0% { transform: scale(1); }
    40% { transform: scale(1.3); }
    100% { transform: scale(1); }
  }
  .action-btn.pulse .material-symbols-outlined { animation: actionPulse 0.35s ease; }

  /* ---------- Dropdown avatar (Profile / Settings) ---------- */
  .avatar-dropdown-wrap { position: relative; }

  .avatar-dropdown-menu {
    position: absolute;
    width: 190px;
    background: var(--bg-white);
    border: 1px solid var(--border);
    border-radius: 14px;
    box-shadow: 0 12px 32px rgba(20, 23, 31, 0.14);
    padding: 6px;
    opacity: 0;
    transform: translateY(6px) scale(0.97);
    pointer-events: none;
    transition: opacity 0.15s ease, transform 0.15s ease;
    z-index: 60;
  }
  .avatar-dropdown-menu.open {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
  }

  /* Topbar: buka ke bawah, rata kanan */
  .avatar-dropdown-menu.down { top: calc(100% + 8px); right: 0; }
  /* Sidebar: buka ke atas, rata kiri */
  .avatar-dropdown-menu.up { bottom: calc(100% + 8px); left: 0; }

  .dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 10px;
    cursor: pointer;
    font-size: 13.5px;
    font-weight: 600;
    color: var(--ink);
    transition: background 0.15s ease;
  }
  .dropdown-item:hover { background: var(--panel-blue); }
  .dropdown-item .material-symbols-outlined { font-size: 19px; color: var(--muted); }
  .dropdown-item.danger { color: #D93025; }
  .dropdown-item.danger .material-symbols-outlined { color: #D93025; }

  .dropdown-divider {
    height: 1px;
    background: var(--border);
    margin: 6px 4px;
  }

  .chat-messages::-webkit-scrollbar { width: 6px; }
  .chat-messages::-webkit-scrollbar-thumb {
    background: var(--panel-blue-hover);
    border-radius: 10px;
  }

  /* ---------- Attach dropup menu ---------- */
  .attach-menu {
    position: absolute;
    bottom: calc(100% + 12px);
    left: 0;
    width: 268px;
    background: var(--bg-white);
    border: 1px solid var(--border);
    border-radius: 20px;
    box-shadow: 0 12px 32px rgba(20, 23, 31, 0.14);
    padding: 8px;
    opacity: 0;
    transform: translateY(8px) scale(0.97);
    pointer-events: none;
    transition: opacity 0.15s ease, transform 0.15s ease;
    z-index: 20;
  }
  .attach-menu.open {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
  }

  .attach-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 9px 10px;
    border-radius: 12px;
    cursor: pointer;
    transition: background 0.15s ease;
  }
  .attach-item:hover { background: var(--panel-blue); }

  .attach-icon-circle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--panel-blue);
    color: var(--accent-blue);
    flex-shrink: 0;
  }
  .attach-icon-circle .material-symbols-outlined { font-size: 19px; }

  .attach-text {
    display: flex;
    flex-direction: column;
    gap: 1px;
  }
  .attach-text .title {
    font-size: 13.5px;
    font-weight: 700;
    color: var(--ink);
  }
  .attach-text .subtitle {
    font-size: 11.5px;
    color: var(--muted);
    font-weight: 500;
  }

  .attach-divider {
    height: 1px;
    background: var(--border);
    margin: 6px 4px;
  }

  .attach-item.toggle-item { cursor: pointer; }
  .attach-item.toggle-item .attach-icon-circle {
    background: var(--panel-blue);
    color: var(--accent-blue);
  }
  .attach-item.toggle-item.on .attach-icon-circle {
    background: var(--accent-blue);
    color: #fff;
  }

  .switch {
    margin-left: auto;
    width: 38px;
    height: 22px;
    border-radius: 20px;
    background: var(--border);
    position: relative;
    flex-shrink: 0;
    transition: background 0.15s ease;
  }
  .switch::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
    transition: transform 0.18s ease;
  }
  .attach-item.toggle-item.on .switch {
    background: var(--accent-blue);
  }
  .attach-item.toggle-item.on .switch::after {
    transform: translateX(16px);
  }

  /* ---------- Search mode chip (baris terpisah di bawah input) ---------- */
  .search-chip-row {
    display: none;
    margin-top: 10px;
    padding-left: 4px;
  }
  .search-chip-row.show { display: flex; }

  .search-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--panel-blue);
    border: 1px solid var(--border);
    color: var(--accent-blue);
    border-radius: 14px;
    padding: 7px 10px 7px 12px;
    font-size: 12.5px;
    font-weight: 700;
  }
  .search-chip .material-symbols-outlined { font-size: 16px; }
  .search-chip .chip-close {
    font-size: 15px;
    cursor: pointer;
    margin-left: 2px;
    opacity: 0.6;
    padding: 2px;
    border-radius: 50%;
  }
  .search-chip .chip-close:hover {
    opacity: 1;
    background: var(--panel-blue-hover);
  }

  /* ---------- Scrollbar ---------- */
  .history-list::-webkit-scrollbar { width: 6px; }
  .history-list::-webkit-scrollbar-thumb {
    background: var(--panel-blue-hover);
    border-radius: 10px;
  }

  @media (max-width: 560px) {
    .hero h1 { font-size: 24px; }
    .prompt-wrap { width: calc(100% - 32px); }
  }

  @media (max-height: 560px) {
    .hero { margin-bottom: 16px; }
    .hero h1 { font-size: 22px; margin-bottom: 4px; }
    .hero p { font-size: 14px; }
    .prompt-wrap { bottom: 16px; }
  }

  /* ---------- Skeleton Loading Animation ---------- */
  @keyframes skeleton-shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
  }

  .skeleton-shimmer {
    background: linear-gradient(90deg, var(--panel-blue) 25%, var(--panel-blue-hover) 50%, var(--panel-blue) 75%);
    background-size: 200% 100%;
    animation: skeleton-shimmer 1.5s infinite ease-in-out;
    border-radius: 8px;
  }

  html[data-theme="dark"] .skeleton-shimmer {
    background: linear-gradient(90deg, #1C2230 25%, #262E40 50%, #1C2230 75%);
    background-size: 200% 100%;
  }

  .skeleton-chat-wrap {
    display: flex;
    flex-direction: column;
    gap: 20px;
    width: 100%;
    padding: 12px 0;
  }

  .skeleton-bubble {
    display: flex;
    flex-direction: column;
    gap: 8px;
  }

  .skeleton-bubble.user {
    align-self: flex-end;
    width: 55%;
    background: var(--panel-blue);
    padding: 14px 16px;
    border-radius: 18px;
    border-bottom-right-radius: 4px;
  }

  .skeleton-bubble.assistant {
    align-self: flex-start;
    width: 85%;
    padding: 8px 0;
  }

  .skeleton-line {
    height: 14px;
    border-radius: 7px;
  }

  .skeleton-history-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 12px;
  }

  .skeleton-icon {
    width: 20px;
    height: 20px;
    border-radius: 6px;
    flex-shrink: 0;
  }

  /* ---------- Stop Button Mode ---------- */
  .send-btn.stop-mode {
    background: #D93025 !important;
    color: #fff !important;
    cursor: pointer !important;
    animation: stop-pulse 1.4s infinite;
  }
  .send-btn.stop-mode:hover {
    background: #B3261E !important;
  }
  @keyframes stop-pulse {
    0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(217, 48, 37, 0.4); }
    70% { transform: scale(1.05); box-shadow: 0 0 0 6px rgba(217, 48, 37, 0); }
    100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(217, 48, 37, 0); }
  }

  /* ---------- Image Preview & Attached Image Styles ---------- */
  .image-preview-wrap {
    display: none;
    align-items: center;
    gap: 10px;
    padding: 8px 12px 6px;
    width: 100%;
  }

  .image-preview-card {
    position: relative;
    display: inline-flex;
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid var(--border);
    background: var(--panel-blue);
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  }

  .image-preview-card img {
    width: 64px;
    height: 64px;
    object-fit: cover;
    display: block;
  }

  .image-preview-remove {
    position: absolute;
    top: 3px;
    right: 3px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: rgba(20, 23, 31, 0.78);
    color: #fff;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.15s ease;
  }
  .image-preview-remove:hover {
    background: #D93025;
  }
  .image-preview-remove .material-symbols-outlined {
    font-size: 13px;
  }

  .user-msg-image {
    max-width: 240px;
    max-height: 240px;
    border-radius: 12px;
    object-fit: cover;
    display: block;
    margin-bottom: 8px;
    cursor: pointer;
    border: 1px solid rgba(255, 255, 255, 0.2);
    transition: transform 0.15s ease;
  }
  .user-msg-image:hover {
    transform: scale(1.02);
  }

  /* ---------- Research Cards, Dummy Reference, and Sources ---------- */
  .research-banner {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-radius: 10px;
    background: var(--panel-blue);
    border: 1px solid var(--border);
    color: var(--accent-blue);
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 12px;
  }
  .research-banner .material-symbols-outlined { font-size: 18px; }

  .research-sources-wrap {
    margin-top: 16px;
    padding-top: 12px;
    border-top: 1px dashed var(--border);
  }

  .research-sources-title {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12.5px;
    font-weight: 700;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 10px;
  }

  .research-cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 10px;
  }

  .research-card {
    display: flex;
    flex-direction: column;
    padding: 10px 12px;
    background: var(--panel-blue);
    border: 1px solid var(--border);
    border-radius: 12px;
    text-decoration: none;
    color: inherit;
    transition: transform 0.15s ease, background 0.15s ease, border-color 0.15s ease;
  }
  .research-card:hover {
    transform: translateY(-2px);
    background: var(--panel-blue-hover);
    border-color: var(--accent-blue);
  }

  .research-card-header {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    color: var(--accent-blue);
    font-weight: 700;
    margin-bottom: 4px;
  }
  .research-card-header .material-symbols-outlined { font-size: 14px; }

  .research-card-title {
    font-size: 13px;
    font-weight: 700;
    color: var(--ink);
    line-height: 1.3;
    margin-bottom: 4px;
  }

  .research-card-snippet {
    font-size: 11.5px;
    color: var(--muted);
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }

  .stream-stopped-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: 10px;
    padding: 4px 10px;
    border-radius: 8px;
    background: rgba(217, 48, 37, 0.1);
    color: #D93025;
    font-size: 12px;
    font-weight: 600;
  }
  .stream-stopped-badge .material-symbols-outlined { font-size: 15px; }

  .md-link {
    color: var(--accent-blue);
    text-decoration: underline;
    text-underline-offset: 3px;
    font-weight: 600;
    transition: opacity 0.15s ease;
  }
  .md-link:hover { opacity: 0.8; }
