/* ============================================================
   RexAi — design tokens + UI
   Mobile-first. Wide screens layer on with min-width.
   Colors: OKLCH. Contrast verified with xias/scripts/contrast.py
   ============================================================ */

:root {
  /* radius */
  --r-xs: 6px;
  --r-sm: 10px;
  --r-md: 14px;
  --r-lg: 20px;
  --r-xl: 28px;
  --r-full: 999px;

  /* spacing (4px rhythm) */
  --sp-1: 4px;  --sp-2: 8px;  --sp-3: 12px; --sp-4: 16px;
  --sp-5: 20px; --sp-6: 24px; --sp-8: 32px; --sp-10: 40px;
  --sp-12: 48px; --sp-16: 64px;

  /* motion */
  --ease-out: cubic-bezier(.22, 1, .36, 1);
  --ease-spring: cubic-bezier(.34, 1.4, .64, 1);
  --dur-fast: 120ms;
  --dur-base: 200ms;
  --dur-slow: 320ms;

  /* type */
  --font-ui: 'Inter var', 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Noto Color Emoji';
  --font-mono: ui-monospace, 'SF Mono', 'JetBrains Mono', 'Cascadia Code', Menlo, Consolas, monospace;
  --shell-w: 860px;
  --sidebar-w: 300px;

  /* layout */
  --topbar-h: 58px;
  --composer-h: 96px;

  /* ---- dark theme (default) ---- */
  --bg:          oklch(15.5% 0.02 275);   /* canvas */
  --bg-deep:     oklch(12% 0.02 275);
  --surface:     oklch(19% 0.022 275);    /* cards, composer */
  --surface-2:   oklch(23.5% 0.024 275);  /* hover, bubbles */
  --surface-3:   oklch(27% 0.026 275);
  --line:        oklch(30% 0.02 275);
  --line-soft:   oklch(25% 0.018 275);
  --text:        oklch(96% 0.008 275);
  --text-2:      oklch(76% 0.014 275);    /* muted, AA on bg */
  --text-3:      oklch(62% 0.014 275);    /* dim, AA-large only */

  /* brand: violet-700 #6d28d9 = white text passes AA (7.1:1) */
  --brand:       oklch(62% 0.23 295);
  --brand-2:     oklch(62% 0.16 210);
  --brand-hover: oklch(58% 0.22 295);
  --brand-soft:  oklch(38% 0.10 290);
  --brand-grad: linear-gradient(135deg, oklch(64% 0.25 295), oklch(60% 0.14 220));
  --on-brand:    #ffffff;
  --accent:      #22d3ee;                 /* cyan, for grafis saja */
  --accent-soft: color-mix(in oklch, #22d3ee 14%, transparent);
  --bubble-user: #4c1d95;
  --bubble-user-line: #6d28d9;
  --user-grad-1: #7c3aed;
  --user-grad-2: #5b21b6;
  --ai-bubble: oklch(20.5% 0.024 275);
  --chat-glow-a: oklch(60% 0.2 290 / .13);
  --chat-glow-b: oklch(70% 0.15 200 / .09);

  --ok:    #7ee2a8;
  --warn:  #fcd34d;
  --danger:#ff9c9c;
  --danger-bg: oklch(30% 0.09 22);

  --shadow-1: 0 1px 2px oklch(0% 0 0 / .35);
  --shadow-2: 0 8px 24px oklch(0% 0 0 / .38), 0 2px 6px oklch(0% 0 0 / .3);
  --shadow-3: 0 24px 60px oklch(0% 0 0 / .55);
  --inset-hi: inset 0 1px 0 oklch(100% 0 0 / .06);
  --glass: oklch(19% 0.022 275 / .72);

  --focus-ring: 0 0 0 2px var(--bg), 0 0 0 4px #a78bfa;
  color-scheme: dark;
}

[data-theme="light"] {
  --bg:          #f4f5f9;
  --bg-deep:     #eceef5;
  --surface:     #ffffff;
  --surface-2:   #f1f2f7;
  --surface-3:   #e6e8f0;
  --line:        #d8dbe6;
  --line-soft:   #e6e8f0;
  --text:        #14161f;
  --text-2:      #5b6180;   /* 5.56:1 on --bg */
  --text-3:      #666c8a;

  --brand:       oklch(50% 0.20 295);
  --brand-2:     oklch(50% 0.14 220);
  --brand-hover: oklch(45% 0.19 295);
  --brand-soft:  oklch(94% 0.03 295);
  --brand-grad: linear-gradient(135deg, oklch(55% 0.22 295), oklch(52% 0.13 220));
  --on-brand:    #ffffff;
  --bubble-user: #ede9fe;
  --bubble-user-line: #c4b5fd;
  --user-grad-1: #7c3aed;
  --user-grad-2: #6d28d9;
  --ai-bubble: #ffffff;
  --chat-glow-a: oklch(70% 0.12 290 / .16);
  --chat-glow-b: oklch(75% 0.1 200 / .12);

  --ok:    #15803d;
  --warn:  #a16207;
  --danger:#b91c1c;
  --danger-bg: #fee2e2;

  --shadow-1: 0 1px 2px oklch(0% 0 0 / .06);
  --shadow-2: 0 8px 24px oklch(0% 0 0 / .09), 0 2px 6px oklch(0% 0 0 / .05);
  --shadow-3: 0 24px 60px oklch(0% 0 0 / .18);
  --inset-hi: inset 0 1px 0 oklch(100% 0 0 / .8);
  --glass: oklch(100% 0 0 / .78);
  --focus-ring: 0 0 0 2px var(--bg), 0 0 0 4px #7c3aed;
  color-scheme: light;
}

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

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow: hidden;
}

body.auth-mode { overflow: auto; }

h1, h2, h3, h4 { margin: 0; letter-spacing: -0.02em; font-weight: 650; line-height: 1.25; }
p { margin: 0; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
a { color: var(--brand); text-underline-offset: 2px; }
[data-theme="dark"] a { color: #a78bfa; }
a:hover { text-decoration: underline; }
svg { display: block; flex-shrink: 0; }
img { max-width: 100%; }

:focus-visible { outline: none; box-shadow: var(--focus-ring); border-radius: var(--r-xs); }
::selection { background: color-mix(in oklch, var(--brand) 45%, transparent); color: var(--text); }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* Atribut hidden harus selalu menang atas display dari komponen
   (auth-view/app/attach-bar/nav-admin pakai display grid/flex). */
[hidden] { display: none !important; }

.skip-link {
  position: fixed; top: -60px; left: 12px; z-index: 200;
  background: var(--brand); color: #fff; padding: 10px 16px;
  border-radius: var(--r-sm); transition: top var(--dur-base) var(--ease-out);
}
.skip-link:focus { top: 12px; }

.muted { color: var(--text-2); }
.small { font-size: 13px; }

/* scrollbars */
* { scrollbar-width: thin; scrollbar-color: var(--line) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--line); border-radius: var(--r-full); border: 3px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: var(--text-3); background-clip: padding-box; border: 3px solid transparent; }

/* ---------------- buttons ---------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2);
  min-height: 42px; padding: 0 var(--sp-4);
  border-radius: 12px; border: 1px solid transparent;
  font-size: 14px; font-weight: 550; letter-spacing: -0.01em;
  transition: background var(--dur-fast) var(--ease-out),
              border-color var(--dur-fast) var(--ease-out),
              transform var(--dur-fast) var(--ease-out),
              box-shadow var(--dur-fast) var(--ease-out);
}
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; }

.btn-primary {
  background: var(--brand-grad, var(--brand));
  color: var(--on-brand);
  box-shadow: var(--shadow-1), var(--inset-hi),
    0 0 18px oklch(from var(--brand) l c h / .25);
}
.btn-primary:hover:not(:disabled) {
  background: linear-gradient(135deg, var(--brand-hover), oklch(50% 0.20 295));
  box-shadow: var(--shadow-2), var(--inset-hi),
    0 0 26px oklch(from var(--brand) l c h / .35);
  transform: translateY(-1px);
}
.btn-primary:focus-visible { box-shadow: var(--focus-ring); }

.btn-ghost {
  background: var(--surface-2); color: var(--text);
  border-color: var(--line);
}
.btn-ghost:hover:not(:disabled) { background: var(--surface-3); border-color: var(--text-3); }

.btn-danger { background: var(--danger); color: #2a0808; font-weight: 600; }
.btn-danger:hover:not(:disabled) { filter: brightness(1.08); }

.btn-block { width: 100%; }
.btn-sm { min-height: 34px; padding: 0 var(--sp-3); font-size: 13px; }

kbd {
  font-family: var(--font-mono); font-size: 10.5px; line-height: 1;
  padding: 3px 5px; border-radius: 5px;
  background: oklch(100% 0 0 / .14); border: 1px solid oklch(100% 0 0 / .16);
  color: inherit; opacity: .85;
  margin-left: auto;
}

.icon-btn {
  display: inline-grid; place-items: center;
  width: 36px; height: 36px; flex-shrink: 0;
  border-radius: var(--r-sm); color: var(--text-2);
  transition: background var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out);
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn[aria-pressed="true"] { color: var(--text); background: var(--surface-2); }

.spinner {
  width: 15px; height: 15px; border-radius: 50%;
  border: 2px solid oklch(100% 0 0 / .35); border-top-color: #fff;
  animation: spin .6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------------- auth ---------------- */
.auth-view {
  position: relative; min-height: 100dvh; display: grid; place-items: center;
  padding: var(--sp-6) var(--sp-4);
  background: radial-gradient(120% 80% at 50% -10%, color-mix(in oklch, var(--brand) 22%, var(--bg)), var(--bg) 60%);
  overflow: hidden;
}
.auth-bg { position: absolute; inset: 0; pointer-events: none; }
.orb {
  position: absolute; border-radius: 50%; filter: blur(70px); opacity: .5;
  animation: float 18s var(--ease-out) infinite alternate;
}
[data-theme="dark"] .orb { opacity: .38; }
.orb-a { width: 380px; height: 380px; background: #6d28d9; top: -120px; left: -80px; }
.orb-b { width: 320px; height: 320px; background: #22d3ee; bottom: -140px; right: -60px; animation-delay: -6s; }
.orb-c { width: 260px; height: 260px; background: #db2777; top: 40%; left: 55%; animation-delay: -12s; }
@keyframes float {
  from { transform: translate3d(0, 0, 0) scale(1); }
  to   { transform: translate3d(30px, -30px, 0) scale(1.12); }
}

.auth-card {
  position: relative; width: 100%; max-width: 400px;
  padding: var(--sp-6);
  background: var(--glass);
  backdrop-filter: blur(28px) saturate(160%);
  -webkit-backdrop-filter: blur(28px) saturate(160%);
  border: 1px solid var(--line);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-3), var(--inset-hi);
  animation: rise var(--dur-slow) var(--ease-out) both;
}
@keyframes rise { from { opacity: 0; transform: translateY(14px) scale(.985); } to { opacity: 1; transform: none; } }

.auth-brand { display: flex; align-items: center; gap: var(--sp-3); margin-bottom: var(--sp-6); }
.auth-brand h1 { font-size: 22px; letter-spacing: -0.03em; }
.auth-brand p { font-size: 13px; color: var(--text-2); }
.brand-mark {
  display: grid; place-items: center; width: 42px; height: 42px;
  border-radius: var(--r-md); background: var(--surface-2);
  box-shadow: var(--inset-hi);
}

.auth-tabs {
  display: grid; grid-template-columns: 1fr 1fr; gap: 2px;
  padding: 3px; margin-bottom: var(--sp-5);
  background: var(--surface-2); border: 1px solid var(--line-soft);
  border-radius: var(--r-sm);
}
.auth-tab {
  padding: 8px; border-radius: 7px; font-size: 13.5px; font-weight: 550;
  color: var(--text-2); transition: all var(--dur-fast) var(--ease-out);
}
.auth-tab:hover { color: var(--text); }
.auth-tab.is-active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-1); }
[data-theme="dark"] .auth-tab.is-active { background: var(--surface-3); }

.field { margin-bottom: var(--sp-4); }
.field label {
  display: block; margin-bottom: 6px;
  font-size: 12.5px; font-weight: 550; color: var(--text-2); letter-spacing: .01em;
}
.field input, .field textarea, .search-wrap input {
  width: 100%; padding: 11px var(--sp-3);
  background: color-mix(in oklab, var(--bg-deep) 80%, transparent); color: var(--text);
  border: 1px solid var(--line); border-radius: 12px;
  font-size: 14px;
  transition: border-color var(--dur-fast) var(--ease-out), box-shadow var(--dur-fast) var(--ease-out), background var(--dur-fast) var(--ease-out);
}
.field textarea { resize: vertical; min-height: 76px; line-height: 1.55; font-family: var(--font-ui); }
.field input::placeholder, .field textarea::placeholder { color: var(--text-3); }
.field input:hover, .field textarea:hover { border-color: var(--text-3); }
.field input:focus, .field textarea:focus {
  outline: none; border-color: var(--brand); background: var(--surface);
  box-shadow: 0 0 0 3px oklch(from var(--brand) l c h / .2);
}
.field input:disabled, .field textarea:disabled { opacity: .6; cursor: not-allowed; }
.field input[aria-invalid="true"] { border-color: var(--danger); }

.pass-wrap { position: relative; }
.pass-wrap input { padding-right: 44px; }
.pass-wrap .icon-btn { position: absolute; right: 3px; top: 50%; transform: translateY(-50%); width: 32px; height: 32px; }

.form-msg {
  margin: 0 0 var(--sp-4); padding: 9px var(--sp-3);
  font-size: 13px; border-radius: var(--r-sm);
  display: flex; gap: var(--sp-2); align-items: flex-start;
  background: var(--danger-bg); color: var(--danger);
  border: 1px solid color-mix(in oklch, var(--danger) 35%, transparent);
}
.form-msg.ok { background: color-mix(in oklch, var(--ok) 16%, var(--surface)); color: var(--ok); border-color: color-mix(in oklch, var(--ok) 35%, transparent); }

.auth-note { margin-top: var(--sp-3); font-size: 12px; color: var(--text-3); text-align: center; }

/* ---------------- app shell ---------------- */
.app {
  display: grid;
  grid-template-columns: 1fr;
  height: 100dvh;
  background: var(--bg);
}

/* sidebar: off-canvas di mobile / panel kaca tetap di desktop */
.sidebar {
  position: fixed; inset: 0 auto 0 0; z-index: 60;
  width: min(88vw, var(--sidebar-w));
  display: flex; flex-direction: column;
  background: color-mix(in oklab, var(--bg-deep) 78%, transparent);
  backdrop-filter: blur(28px) saturate(150%);
  -webkit-backdrop-filter: blur(28px) saturate(150%);
  border-right: 1px solid color-mix(in oklab, var(--line) 80%, transparent);
  transform: translateX(-102%);
  transition: transform var(--dur-slow) var(--ease-out), box-shadow var(--dur-slow) var(--ease-out), background var(--dur-slow) var(--ease-out);
  will-change: transform;
}
.sidebar.is-open { transform: none; box-shadow: 24px 0 60px -30px oklch(0% 0 0 / .55); }

.scrim {
  position: fixed; inset: 0; z-index: 50;
  background: oklch(0% 0 0 / .5); backdrop-filter: blur(2px);
  animation: fade-in var(--dur-base) var(--ease-out);
}
@keyframes fade-in { from { opacity: 0; } }

.side-top { padding: var(--sp-4) var(--sp-4) var(--sp-3); display: grid; gap: var(--sp-3); flex-shrink: 0; }
.brand { display: flex; align-items: center; gap: var(--sp-2); }
.brand-name { font-size: 16.5px; font-weight: 700; letter-spacing: -0.035em;
  background: linear-gradient(100deg, var(--text), oklch(72% 0.17 295) 70%, oklch(72% 0.10 220));
  -webkit-background-clip: text; background-clip: text; color: transparent; }
.brand .only-mobile { margin-left: auto; }

#btn-new {
  justify-content: flex-start; min-height: 44px;
  background: var(--brand-grad); color: var(--on-brand);
  border: 0; font-weight: 600;
  box-shadow: 0 8px 22px -6px oklch(from var(--brand) l c h / .55), var(--inset-hi);
}
#btn-new span { margin-right: auto; }
#btn-new:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 12px 30px -6px oklch(from var(--brand) l c h / .7), var(--inset-hi); }
#btn-new svg { width: 15px; height: 15px; }

.search-wrap { position: relative; }
.search-wrap svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--text-3); pointer-events: none; }
.search-wrap input { padding-left: 33px; height: 36px; font-size: 13.5px; border-radius: var(--r-sm); }
.search-wrap input::-webkit-search-cancel-button { -webkit-appearance: none; }

.side-nav {
  display: grid; gap: 4px; padding: var(--sp-2) var(--sp-3) var(--sp-3);
  flex-shrink: 0;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 12px;
  font-size: 13.5px; font-weight: 500; color: var(--text-2);
  position: relative;
  transition: background var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out), transform .16s var(--ease-out), box-shadow .16s;
}
.nav-item svg { flex-shrink: 0; }
.nav-item:hover { background: var(--surface-2); color: var(--text); transform: translateY(-1px); }
.nav-item.is-active {
  background: linear-gradient(135deg, color-mix(in oklab, var(--brand) 24%, var(--surface)), color-mix(in oklab, oklch(66% 0.15 220) 16%, var(--surface)));
  color: var(--text); font-weight: 650;
  box-shadow: inset 0 0 0 1px color-mix(in oklab, var(--brand) 40%, transparent), 0 4px 18px -8px oklch(from var(--brand) l c h / .55);
}
.nav-item.is-active svg { color: var(--brand-2); fill: none; }
.nav-item.is-active::after {
  content: ""; position: absolute; right: 12px; top: 50%; transform: translateY(-50%);
  width: 6px; height: 6px; border-radius: 50%; background: var(--brand-2);
  box-shadow: 0 0 10px var(--brand-2);
}
.nav-badge {
  margin-left: auto; min-width: 20px; height: 20px; padding: 0 6px;
  display: grid; place-items: center; border-radius: var(--r-full);
  background: oklch(from var(--brand) l c h / .9); color: #fff; font-size: 11px; font-weight: 650;
}

.side-list-wrap { flex: 1 1 0; min-height: 0; display: flex; flex-direction: column; padding: 0 var(--sp-2); overflow: hidden; }
.side-label {
  padding: 0 10px 6px; font-size: 11px; font-weight: 650;
  letter-spacing: .08em; text-transform: uppercase; color: var(--text-3);
  flex-shrink: 0;
}
.chat-list { list-style: none; margin: 0; padding: 0 0 var(--sp-2); overflow-y: auto; overscroll-behavior: contain; flex: 1 1 0; min-height: 0; scrollbar-width: thin; }

.chat-item {
  position: relative; display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; margin-bottom: 4px;
  border-radius: 14px; color: var(--text-2);
  font-size: 13.5px; cursor: pointer;
  border: 1px solid transparent;
  transition: background var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out), border-color .16s, transform .16s var(--ease-out), box-shadow .16s;
}
.chat-item:hover { background: var(--surface-2); color: var(--text); border-color: var(--line-soft); transform: translateY(-1px); }
.chat-item.is-active {
  background: color-mix(in oklab, var(--brand) 16%, transparent);
  border-color: color-mix(in oklab, var(--brand) 45%, transparent);
  color: var(--text); font-weight: 600;
  box-shadow: 0 6px 18px -8px oklch(from var(--brand) l c h / .5);
}
.chat-item.is-active::before {
  content: ""; position: absolute; left: -2px; top: 50%; transform: translateY(-50%);
  width: 4px; height: 26px; border-radius: 4px; background: var(--brand-grad);
  box-shadow: 0 0 12px oklch(from var(--brand) l c h / .7);
}
.chat-item-av {
  flex-shrink: 0; width: 34px; height: 34px; border-radius: 12px;
  display: grid; place-items: center;
  background: var(--brand-grad); color: #fff; font-size: 13px; font-weight: 700;
  box-shadow: 0 4px 12px -4px oklch(from var(--brand) l c h / .5);
}
.chat-item.is-pinned .chat-item-av {
  background: linear-gradient(135deg, var(--warn, #d97706), oklch(70% 0.13 80));
}
.chat-item-text { flex: 1; min-width: 0; }
.chat-item-title { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-item-meta { display: block; font-size: 11px; color: var(--text-3); margin-top: 1px; }
.chat-item .pin-ic { color: var(--warn); }
.chat-item-menu {
  width: 26px; height: 26px; display: grid; place-items: center; border-radius: 6px;
  color: var(--text-3); opacity: 0;
  transition: opacity var(--dur-fast), background var(--dur-fast), color var(--dur-fast);
}
.chat-item:hover .chat-item-menu, .chat-item-menu:focus-visible, .chat-item.is-active .chat-item-menu { opacity: 1; }
.chat-item-menu:hover { background: var(--surface-3); color: var(--text); }
@media (hover: none) { .chat-item-menu { opacity: 1; } }

.side-empty { padding: 14px 10px; font-size: 12.5px; color: var(--text-3); line-height: 1.6; }

.side-foot {
  display: flex; align-items: center; gap: 6px;
  padding: var(--sp-3); border-top: 1px solid var(--line-soft);
  flex-shrink: 0;
}
.user-chip {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 9px;
  padding: 5px 8px; border-radius: 12px; text-align: left;
  transition: background var(--dur-fast) var(--ease-out);
}
.user-chip:hover { background: var(--surface-2); }
.avatar {
  display: grid; place-items: center; width: 32px; height: 32px; flex-shrink: 0;
  border-radius: 11px; background: var(--brand-grad); color: #fff;
  font-size: 12.5px; font-weight: 700; text-transform: uppercase;
  box-shadow: 0 4px 14px -4px oklch(from var(--brand) l c h / .55);
}
.user-meta { min-width: 0; }
.user-meta strong { display: block; font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-meta small { display: block; font-size: 11px; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* theme toggle icon swap */
#theme-toggle .ic-sun { display: none; }
[data-theme="light"] #theme-toggle .ic-moon { display: none; }
[data-theme="light"] #theme-toggle .ic-sun { display: block; }

/* ---------------- main + topbar ---------------- */
.main { display: flex; flex-direction: column; min-width: 0; height: 100dvh; overflow: hidden; }

.topbar {
  display: flex; align-items: center; gap: var(--sp-2);
  height: var(--topbar-h); flex-shrink: 0;
  margin: 10px 14px 0;
  padding: 8px 14px;
  background: color-mix(in oklab, var(--bg-deep) 60%, transparent);
  backdrop-filter: blur(24px) saturate(160%);
  -webkit-backdrop-filter: blur(24px) saturate(160%);
  border: 1px solid var(--line-soft); border-radius: 18px;
  box-shadow: 0 10px 30px -14px oklch(0% 0 0 / .6), var(--inset-hi);
  z-index: 10;
}
.top-title { display: flex; align-items: center; gap: var(--sp-2); min-width: 0; flex: 1; position: relative; }
.top-title h2 {
  font-size: 15px; font-weight: 600; letter-spacing: -0.015em;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 46vw;
}
.model-badge {
  display: inline-flex; align-items: center; gap: 5px; flex-shrink: 0;
  padding: 5px 11px 5px 8px; border-radius: var(--r-full);
  background: color-mix(in oklab, var(--brand) 12%, var(--surface));
  border: 1px solid color-mix(in oklab, var(--brand) 34%, transparent);
  font-size: 11px; font-weight: 600; color: oklch(from var(--brand) calc(l + 0.08) c h);
  font-family: var(--font-mono); cursor: pointer;
  box-shadow: inset 0 1px 0 var(--inset-hi), 0 4px 14px -6px oklch(from var(--brand) l c h / .5);
  transition: transform .16s var(--ease-out), box-shadow .16s, border-color .16s;
}
.model-badge:hover { border-color: var(--brand); transform: translateY(-1px); box-shadow: 0 6px 18px -6px oklch(from var(--brand) l c h / .6); }
.model-badge .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--brand); }
.model-menu {
  position: absolute; top: calc(100% + 8px); left: 0; z-index: 60;
  width: min(340px, 86vw); max-height: min(420px, 70vh);
  display: flex; flex-direction: column; overflow: hidden;
  background: var(--glass);
  backdrop-filter: blur(28px) saturate(160%);
  -webkit-backdrop-filter: blur(28px) saturate(160%);
  border: 1px solid var(--border); border-radius: 18px;
  box-shadow: var(--shadow-3), var(--inset-hi); padding: var(--sp-2);
  animation: menu-pop .16s var(--ease-spring);
}
.model-search {
  width: 100%; padding: 8px 10px; margin-bottom: 6px; flex-shrink: 0;
  background: var(--bg-deep); color: var(--text);
  border: 1px solid var(--line); border-radius: var(--r-sm); font-size: 13px;
}
.model-search::placeholder { color: var(--text-3); }
.model-search:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in oklch, var(--brand) 28%, transparent); }
.model-list { overflow-y: auto; overscroll-behavior: contain; min-height: 0; }
.model-group {
  padding: 8px 10px 3px; font-size: 10.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  color: var(--text-3); position: sticky; top: 0; background: var(--surface); z-index: 1;
}
.model-count { padding: 6px 10px 2px; font-size: 11.5px; color: var(--text-3); }
.model-menu button[role="option"] {
  display: flex; align-items: center; gap: var(--sp-2); width: 100%;
  padding: 7px 10px; border: 0; border-radius: var(--r-sm); background: transparent;
  color: var(--text); font-size: 13px; cursor: pointer; text-align: left;
  transition: background .12s;
}
.model-menu button[role="option"]:hover { background: var(--surface-2); }
.model-menu button[role="option"][aria-selected="true"] { background: var(--accent-soft); }
.model-name {
  font-family: var(--font-mono); font-size: 12.5px; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap; flex: 1; min-width: 0;
}
.model-prov {
  flex-shrink: 0; font-size: 10px; font-weight: 600; color: var(--text-3);
  background: var(--surface-2); border: 1px solid var(--line-soft);
  padding: 1px 6px; border-radius: var(--r-full); max-width: 110px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.model-menu .model-check { margin-left: auto; color: var(--accent); font-weight: 700; flex-shrink: 0; }
.model-menu .model-empty { padding: var(--sp-3); text-align: center; color: var(--text-2); font-size: 12.5px; }
.pulse-dot {
  width: 6px; height: 6px; border-radius: 50%; background: var(--ok);
  box-shadow: 0 0 0 0 color-mix(in oklch, var(--ok) 60%, transparent);
  animation: pulse 2.4s var(--ease-out) infinite;
}
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 color-mix(in oklch, var(--ok) 55%, transparent); }
  50% { box-shadow: 0 0 0 4px color-mix(in oklch, var(--ok) 0%, transparent); }
}
.top-actions { display: flex; align-items: center; gap: 2px; flex-shrink: 0; }
.top-actions .icon-btn:disabled { opacity: .35; cursor: not-allowed; }

.view { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.view[hidden] { display: none; }

/* View panel (catatan/pengaturan/admin): lapisan kaca di atas canvas */
.view-panel {
  padding: clamp(20px, 4vw, 42px) clamp(14px, 3vw, 32px) var(--sp-10);
  padding-block-end: var(--sp-10);
  overflow-y: auto; overflow-x: hidden;
  position: relative;
  background:
    radial-gradient(720px 380px at 12% 0%, oklch(from var(--brand) l c h / .10), transparent 62%),
    radial-gradient(680px 420px at 95% 8%, oklch(72% 0.14 200 / .08), transparent 60%);
}
.view-panel .panel-head { margin-bottom: clamp(18px, 3vh, 28px); }
@media (prefers-reduced-motion: no-preference) {
  .view-panel { animation: rise var(--dur-slow) var(--ease-out) both; }
}

/* ---------------- chat scroll area ---------------- */
.scroll-area {
  flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden;
  scroll-behavior: smooth; overscroll-behavior: contain;
  padding: var(--sp-6) 0 var(--sp-4);
}
@media (prefers-reduced-motion: reduce) { .scroll-area { scroll-behavior: auto; } }

.messages {
  width: 100%; max-width: var(--shell-w);
  margin: 0 auto; padding: 0 var(--sp-4);
  display: flex; flex-direction: column; gap: var(--sp-5);
}

/* welcome / empty state */
.welcome {
  max-width: var(--shell-w); margin: 0 auto;
  padding: clamp(var(--sp-6), 8vh, 96px) var(--sp-4) var(--sp-8);
  text-align: center;
  display: grid; justify-items: center; gap: var(--sp-3);
  animation: rise var(--dur-slow) var(--ease-out) both;
}
.welcome[hidden] { display: none; }
.welcome-mark {
  display: grid; place-items: center; width: 74px; height: 74px;
  border-radius: 26px;
  background: var(--brand-grad);
  box-shadow: 0 18px 44px -14px oklch(from var(--brand) l c h / .55), var(--inset-hi);
  position: relative;
  margin-bottom: var(--sp-2);
}
.welcome-mark::after {
  content: ""; position: absolute; inset: -1px; border-radius: inherit;
  padding: 1px; background: linear-gradient(140deg, color-mix(in oklab, var(--brand) 40%, white), transparent 60%);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor; mask-composite: exclude;
  pointer-events: none;
}
.welcome-mark svg { width: 36px; height: 36px; fill: transparent; stroke: #fff; stroke-width: 2.6; }
.welcome h3 { font-size: clamp(24px, 4.8vw, 32px); letter-spacing: -0.04em; font-weight: 750; }
.welcome-sub { color: var(--text-2); font-size: 14.5px; max-width: 44ch; line-height: 1.65; }
.chips { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin-top: var(--sp-4); }
.chip {
  padding: 10px 16px; border-radius: var(--r-full);
  background: var(--glass);
  backdrop-filter: blur(10px) saturate(140%);
  -webkit-backdrop-filter: blur(10px) saturate(140%);
  border: 1px solid var(--line);
  font-size: 13px; font-weight: 500; color: var(--text-2);
  display: inline-flex; align-items: center; gap: 8px;
  transition: transform .16s var(--ease-spring), border-color .16s, box-shadow .16s, background .16s;
}
.chip:hover { background: color-mix(in oklab, var(--brand) 10%, var(--surface)); border-color: var(--brand); color: var(--text); transform: translateY(-2px); box-shadow: 0 10px 24px -10px oklch(from var(--brand) l c h / .5); }
.chip:active { transform: none; }
.chip-ico { font-size: 16px; line-height: 1; width: 16px; height: 16px; }
.chip-ico svg { width: 16px; height: 16px; }

/* Statistik + tips di welcome */
.welcome-stats {
  display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin-top: var(--sp-5);
  width: 100%; max-width: var(--shell-w);
}
.welcome-stats[hidden] { display: none; }
.wstat {
  min-width: 96px; flex: 0 1 auto; padding: 12px 16px;
  background: var(--glass); border: 1px solid var(--line-soft);
  border-radius: 18px; box-shadow: 0 8px 26px -14px oklch(0% 0 0 / .6), var(--inset-hi);
  display: grid; gap: 2px;
}
.wstat b { font-size: 22px; letter-spacing: -.02em; font-weight: 750; }
.wstat span { font-size: 11px; color: var(--text-3); }
.welcome-tips { color: var(--text-3); font-size: 12px; margin-top: var(--sp-3); }
.welcome-tips kbd {
  font-family: inherit; font-size: 11px; padding: 1px 6px;
  background: var(--surface-2); border: 1px solid var(--line-soft);
  border-bottom-width: 2px; border-radius: 5px;
}

/* Modal bagikan chat */
.share-row { display: flex; gap: var(--sp-2); margin: 12px 0 var(--sp-2); }
.share-row input {
  flex: 1; min-width: 0; padding: 9px var(--sp-3);
  background: var(--surface-2); color: var(--text);
  border: 1px solid var(--line); border-radius: var(--r-sm); font-size: 13px;
}
.share-note { margin-top: var(--sp-2); }

/* Daftar pintasan */
.keys-table { display: grid; gap: 7px; margin-top: 10px; }
.keys-table div { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); font-size: 13.5px; }
.keys-table kbd {
  font-family: inherit; font-size: 11.5px; padding: 2px 8px; white-space: nowrap;
  background: var(--surface-2); border: 1px solid var(--line-soft);
  border-bottom-width: 2px; border-radius: 6px;
}

.view#view-chat { position: relative; overflow: hidden; }
/* Background hidup: orb bergerak + grid halus */
.chat-ambience { position: absolute; inset: 0; pointer-events: none; z-index: 0; }
.chat-ambience::before {
  content: ""; position: absolute; inset: 0;
  background-image:
    linear-gradient(var(--line-soft) 1px, transparent 1px),
    linear-gradient(90deg, var(--line-soft) 1px, transparent 1px);
  background-size: 34px 34px;
  opacity: .28;
  mask-image: radial-gradient(120% 90% at 50% 20%, #000 30%, transparent 75%);
}
.chat-ambience::after {
  content: ""; position: absolute; inset: 0;
  background:
    radial-gradient(640px 300px at 12% -4%, var(--chat-glow-a), transparent 62%),
    radial-gradient(720px 340px at 92% 102%, var(--chat-glow-b), transparent 62%);
}
.ca-orb { position: absolute; border-radius: 50%; filter: blur(70px); opacity: .55; mix-blend-mode: screen; }
.ca-a { width: 340px; height: 340px; left: -90px; top: 6%; background: #7c3aed; animation: ca-drift 16s ease-in-out infinite; }
.ca-b { width: 280px; height: 280px; right: -70px; bottom: 12%; background: #0ea5e9; animation: ca-drift 20s ease-in-out infinite reverse; }
@keyframes ca-drift { 0%, 100% { transform: translate(0, 0) scale(1); } 50% { transform: translate(46px, 34px) scale(1.08); } }
:root[data-theme="light"] .ca-orb { opacity: .3; mix-blend-mode: multiply; }
:root[data-theme="light"] .chat-ambience::before { opacity: .5; }
@media (prefers-reduced-motion: reduce) { .ca-a, .ca-b { animation: none; } }

/* Progress kirim: bar tipis di atas area chat */
.chat-progress {
  position: absolute; top: 0; left: 0; right: 0; height: 2px; z-index: 5;
  background: linear-gradient(90deg, #7c3aed, #22d3ee);
  transform-origin: left; transform: scaleX(0); opacity: 0;
  transition: transform .18s ease-out, opacity .2s;
  box-shadow: 0 0 12px rgba(124, 58, 237, .6);
}
.chat-progress.on { opacity: 1; transform: scaleX(1); }
.chat-progress.done { opacity: 0; transition: opacity .4s; }

/* Find bar: cari di chat ini */
.find-bar {
  position: absolute; top: var(--sp-2); right: var(--sp-3); z-index: 6;
  display: flex; align-items: center; gap: 4px;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--line); border-radius: var(--r-md);
  padding: 5px 6px 5px 10px; box-shadow: var(--shadow-2);
  animation: msg-in var(--dur-fast) var(--ease-out) both;
}
.find-bar[hidden] { display: none; }
.find-bar > svg { color: var(--text-3); flex: none; }
#find-input { width: 170px; background: transparent; border: 0; outline: 0; color: var(--text); font-size: 13px; }
.find-count { font-size: 11.5px; color: var(--text-3); white-space: nowrap; min-width: 40px; text-align: center; font-variant-numeric: tabular-nums; }
.find-bar .icon-btn { width: 26px; height: 26px; }
mark.find-hit { background: rgba(124, 58, 237, .4); color: inherit; border-radius: 3px; padding: 0 1px; }
mark.find-hit.current { background: #f59e0b; color: #111; }

/* Tombol mic: merah berdenyut saat merekam */
#btn-mic.listening { background: rgba(239, 68, 68, .15); color: #ef4444; border-color: rgba(239, 68, 68, .5); animation: mic-pulse 1.2s ease-in-out infinite; }
@keyframes mic-pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, .4); } 50% { box-shadow: 0 0 0 6px rgba(239, 68, 68, 0); } }

/* Bubble: grup berurutan lebih rapat (padat) */
.msg.tight { margin-top: -10px; }
.msg.tight .msg-head { display: none; }

/* Tombol aksi pesan: selalu terlihat di layar sentuh */
@media (hover: none) { .msg-foot { opacity: 1; } }
#view-chat .scroll-area, #view-chat .composer-zone { position: relative; z-index: 1; }

/* ---------------- messages ---------------- */
.msg {
  display: flex; flex-direction: column; max-width: 100%;
  animation: msg-in var(--dur-base) var(--ease-out) both;
}
@keyframes msg-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* Header mungil: avatar + nama (+ jam). User rata kanan. */
.msg-head {
  display: flex; align-items: center; gap: 7px; margin: 0 2px 5px;
  font-size: 11.5px; font-weight: 600; color: var(--text-3);
  letter-spacing: .02em; text-transform: uppercase;
}
.msg.user .msg-head { flex-direction: row-reverse; }
.msg-avatar {
  width: 22px; height: 22px; border-radius: 7px; display: grid; place-items: center;
  background: var(--surface-2); color: var(--text-2); font-size: 10px; font-weight: 700;
  border: 1px solid var(--line-soft);
}
.msg.assistant .msg-avatar {
  background: var(--brand-grad); color: #fff; border: 0;
  box-shadow: 0 2px 12px oklch(from var(--brand) l c h / .5);
}
.chip { transition: transform .16s var(--ease-spring), border-color .16s, background .16s, box-shadow .16s; }
.msg-time { font-weight: 400; text-transform: none; letter-spacing: 0; opacity: .8; }
.stopped-tag {
  font-weight: 500; text-transform: none; letter-spacing: 0;
  color: var(--warn); font-size: 11px;
}

/* Bubble dasar — sudut “ekor” per sisi kayak aplikasi chat. */
.bubble {
  position: relative; width: fit-content; max-width: min(88%, 640px);
  padding: 12px 18px;
  border-radius: 20px;
  overflow-wrap: anywhere;
  transition: transform .16s var(--ease-out), box-shadow .2s var(--ease-out);
}

/* user: kanan, gradasi ungu, ekor kanan-atas */
.msg.user { align-items: flex-end; }
.msg.user .bubble {
  background: linear-gradient(135deg, var(--user-grad-1), var(--user-grad-2));
  color: #fff;
  border-bottom-right-radius: 10px;
  box-shadow: 0 8px 22px -8px oklch(from var(--brand) l c h / .4), var(--inset-hi);
}
.msg.user .bubble:hover { transform: translateY(-1px); box-shadow: 0 12px 28px -8px oklch(from var(--brand) l c h / .5), var(--inset-hi); }
.msg.user .bubble ::selection { background: rgba(255, 255, 255, .35); }
/* inline code di bubble user: kaca gelap biar kontras di atas ungu */
.msg.user .bubble :not(pre) > code {
  background: rgba(0, 0, 0, .28); border-color: rgba(255, 255, 255, .22); color: #fff;
}
.msg.user .bubble blockquote { border-left-color: rgba(255,255,255,.55); color: rgba(255,255,255,.85); }
.msg.user .bubble .code-block { border-color: rgba(255,255,255,.2); }
.msg.user .bubble .file-link { background: rgba(0,0,0,.25); border-color: rgba(255,255,255,.25); color: #fff; }
.msg.user .bubble a { color: #fff; text-decoration: underline; text-underline-offset: 2px; }

/* assistant: kiri, permukaan kartu, ekor kiri-atas, garis aksen */
.msg.assistant { align-items: flex-start; }
.msg.assistant .bubble {
  background: color-mix(in oklab, var(--ai-bubble) 92%, transparent);
  backdrop-filter: blur(14px) saturate(140%);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  border: 1px solid var(--line-soft);
  border-bottom-left-radius: 10px;
  box-shadow: 0 14px 36px -18px oklch(0% 0 0 / .55), var(--inset-hi);
  color: var(--text);
  font-size: 15px; line-height: 1.72;
}
.msg.assistant .bubble:hover { box-shadow: 0 18px 44px -18px oklch(from var(--brand) l c h / .45), var(--inset-hi); }
.msg.assistant .bubble::before {
  content: ""; position: absolute; left: 0; top: 12px; bottom: 12px; width: 3px;
  border-radius: var(--r-full);
  background: linear-gradient(180deg, oklch(from var(--brand) l c h), oklch(73% 0.13 210));
  opacity: .9;
}
.msg.assistant .bubble { padding-left: calc(var(--sp-4) + 7px); }
.msg.assistant.thinking .bubble { color: var(--text-2); }
.msg.user .bubble :is(p, ul, ol, pre, blockquote):last-child { margin-bottom: 0; }

/* Aksi tiap pesan: tombol teks mungil (muncul saat hover) */
.msg-act {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 10px; border-radius: var(--r-full);
  background: transparent; border: 1px solid transparent;
  color: var(--text-3); font-size: 11.5px; font-weight: 600;
  cursor: pointer; transition: all var(--dur-fast) var(--ease-out);
}
.msg-act svg { width: 13px; height: 13px; }
.msg-act:hover { background: var(--surface-2); border-color: var(--line-soft); color: var(--text); }
.msg-act:active { transform: scale(.96); }
.msg-foot .msg-act.is-done { color: var(--ok); }
.msg-foot .msg-act.is-speaking { color: var(--brand-2); border-color: var(--brand); }

/* Pembatas hari ala aplikasi chat */
.day-div {
  display: flex; align-items: center; gap: var(--sp-3);
  margin: var(--sp-3) auto var(--sp-1); max-width: min(88%, 640px);
}
.day-div::before, .day-div::after {
  content: ""; flex: 1; height: 1px; background: var(--line-soft);
}
.day-div span {
  font-size: 11px; font-weight: 600; color: var(--text-3);
  background: var(--surface); border: 1px solid var(--line-soft);
  padding: 3px 12px; border-radius: var(--r-full); white-space: nowrap;
}

/* Badge model per jawaban — klik untuk pakai model yang sama */
.model-chip {
  font-size: 10.5px; font-weight: 700; letter-spacing: .02em;
  padding: 2px 9px; border-radius: var(--r-full); cursor: pointer;
  color: #fff; background: var(--brand-grad);
  border: 0; box-shadow: 0 2px 8px oklch(from var(--brand) l c h / .4);
  transition: transform var(--dur-fast) var(--ease-out), box-shadow var(--dur-fast) var(--ease-out);
}
.model-chip:hover { transform: translateY(-1px); box-shadow: 0 4px 12px oklch(from var(--brand) l c h / .55); }
.model-chip:active { transform: none; }

.msg-foot {
  display: flex; align-items: center; gap: 2px; margin-top: 6px;
  opacity: 0; transition: opacity var(--dur-base) var(--ease-out);
}
.msg:hover .msg-foot, .msg:focus-within .msg-foot, .msg-foot.is-visible { opacity: 1; }
@media (hover: none) { .msg-foot { opacity: 1; } }
.msg-foot .icon-btn { width: 30px; height: 30px; }
.msg-foot .icon-btn svg { width: 15px; height: 15px; }
.msg-foot .icon-btn.is-done { color: var(--ok); }

/* edit mode */
.edit-box { width: 100%; display: grid; gap: var(--sp-2); }
.edit-box textarea {
  width: 100%; min-height: 72px; padding: 10px var(--sp-3); resize: vertical;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--brand); border-radius: var(--r-sm); font-size: 14px; line-height: 1.55;
}
.edit-box textarea:focus { outline: none; box-shadow: 0 0 0 3px color-mix(in oklch, var(--brand) 28%, transparent); }
.edit-actions { display: flex; gap: var(--sp-2); justify-content: flex-end; }

/* typing indicator */
.typing { display: inline-flex; align-items: center; gap: 4px; padding: 4px 0; }
.typing span {
  width: 6px; height: 6px; border-radius: 50%; background: var(--text-3);
  animation: blink 1.3s var(--ease-out) infinite;
}
.typing span:nth-child(2) { animation-delay: .18s; }
.typing span:nth-child(3) { animation-delay: .36s; }
@keyframes blink { 0%, 60%, 100% { opacity: .28; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-2px); } }

.caret {
  display: inline-block; width: 2px; height: 1.05em; vertical-align: text-bottom;
  background: var(--brand); margin-left: 2px; border-radius: 1px;
  animation: caret 1s steps(2) infinite;
}
@keyframes caret { 50% { opacity: 0; } }

/* ---------------- markdown ---------------- */
.bubble > :first-child { margin-top: 0; }
.bubble > :last-child { margin-bottom: 0; }
.bubble p { margin: 0 0 .85em; }
.bubble h1, .bubble h2, .bubble h3, .bubble h4 { margin: 1.3em 0 .55em; letter-spacing: -0.02em; }
.bubble h1 { font-size: 1.45em; }
.bubble h2 { font-size: 1.25em; }
.bubble h3 { font-size: 1.1em; }
.bubble h4 { font-size: 1em; }
.bubble ul, .bubble ol { margin: 0 0 .85em; padding-left: 1.4em; }
.bubble li { margin: .18em 0; }
.bubble li::marker { color: var(--text-3); }
.bubble strong { font-weight: 650; }
.bubble hr { border: 0; border-top: 1px solid var(--line); margin: 1.2em 0; }
.bubble blockquote {
  margin: 0 0 .85em; padding: .2em 0 .2em 1em;
  border-left: 3px solid var(--brand);
  color: var(--text-2); font-style: italic;
}
.bubble table { width: 100%; border-collapse: collapse; margin: 0 0 .9em; font-size: 13.5px; display: block; overflow-x: auto; }
.bubble th, .bubble td { padding: 7px 11px; border: 1px solid var(--line); text-align: left; }
.bubble th { background: var(--surface-2); font-weight: 600; }
.bubble :not(pre) > code {
  font-family: var(--font-mono); font-size: .875em;
  padding: .15em .4em; border-radius: 5px;
  background: var(--surface-2); border: 1px solid var(--line-soft);
  color: var(--text); overflow-wrap: break-word;
}
[data-theme="dark"] .bubble :not(pre) > code { color: #c4b5fd; }

/* code block */
.code-block {
  margin: 0 0 .9em; border-radius: var(--r-sm); overflow: hidden;
  border: 1px solid var(--line); background: var(--bg-deep);
}
.code-head {
  display: flex; align-items: center; gap: var(--sp-2);
  padding: 6px 8px 6px 12px;
  background: var(--surface-2); border-bottom: 1px solid var(--line-soft);
}
.code-lang {
  font-family: var(--font-mono); font-size: 11px; font-weight: 600;
  color: var(--text-2); letter-spacing: .04em; text-transform: uppercase;
}
.copy-code {
  margin-left: auto; display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 10px; border-radius: 7px; font-size: 11.5px; font-weight: 600;
  color: var(--text-2); background: var(--surface-3); border: 1px solid var(--line);
  transition: all var(--dur-fast) var(--ease-out);
}
.copy-code:hover { border-color: var(--brand); color: var(--text); transform: translateY(-1px); }
.copy-code:active { transform: none; }
.copy-code.is-done { color: var(--ok); border-color: var(--ok); }
.code-block pre { margin: 0; padding: var(--sp-3) var(--sp-4); overflow-x: auto; }
.code-block code {
  font-family: var(--font-mono); font-size: 13px; line-height: 1.65;
  color: var(--text); background: none; border: 0; padding: 0;
  white-space: pre; tab-size: 2;
}

/* highlight.js palet minimal (ikut tema) */
.hljs-comment, .hljs-quote { color: var(--text-3); font-style: italic; }
.hljs-keyword, .hljs-selector-tag, .hljs-literal, .hljs-doctag { color: #c4b5fd; }
.hljs-string, .hljs-regexp, .hljs-addition { color: #86efac; }
.hljs-number, .hljs-symbol, .hljs-bullet { color: #fcd34d; }
.hljs-title, .hljs-section, .hljs-name { color: #93c5fd; }
.hljs-attr, .hljs-attribute, .hljs-variable, .hljs-template-variable { color: #f0abfc; }
.hljs-built_in, .hljs-type { color: #7dd3fc; }
.hljs-deletion { color: #ff9c9c; }
.hljs-emphasis { font-style: italic; }
.hljs-strong { font-weight: 700; }
[data-theme="light"] .hljs-keyword, [data-theme="light"] .hljs-selector-tag, [data-theme="light"] .hljs-literal, [data-theme="light"] .hljs-doctag { color: #6d28d9; }
[data-theme="light"] .hljs-string, [data-theme="light"] .hljs-regexp, [data-theme="light"] .hljs-addition { color: #047857; }
[data-theme="light"] .hljs-number, [data-theme="light"] .hljs-symbol, [data-theme="light"] .hljs-bullet { color: #a16207; }
[data-theme="light"] .hljs-title, [data-theme="light"] .hljs-section, [data-theme="light"] .hljs-name { color: #1d4ed8; }
[data-theme="light"] .hljs-attr, [data-theme="light"] .hljs-attribute, [data-theme="light"] .hljs-variable { color: #a21caf; }
[data-theme="light"] .hljs-built_in, [data-theme="light"] .hljs-type { color: #0369a1; }

/* images + file links di pesan */
.chat-img { display: block; margin: 6px 0; border-radius: var(--r-sm); overflow: hidden; border: 1px solid var(--line); position: relative; min-height: 120px; background: var(--surface-3); }
.chat-img::before {
  content: "🎨 Membuat gambar…";
  position: absolute; inset: 0; display: grid; place-items: center;
  font-size: 13px; color: var(--text-3); letter-spacing: .02em;
  background: repeating-linear-gradient(115deg, var(--surface-3) 0 22px, var(--surface-2) 22px 44px);
  background-size: 200% 100%;
  animation: shimmer 1.4s linear infinite;
}
@keyframes shimmer { to { background-position: -200% 0; } }
.chat-img img { display: block; max-height: 320px; width: auto; object-fit: cover; position: relative; }
.file-link {
  display: inline-flex; align-items: center; gap: 7px; margin: 4px 6px 4px 0;
  padding: 8px 12px; border-radius: var(--r-sm);
  background: var(--surface-2); border: 1px solid var(--line);
  font-size: 13px; font-weight: 600; color: var(--text); text-decoration: none;
  transition: all var(--dur-fast) var(--ease-out);
}
.file-link:hover { border-color: var(--brand); text-decoration: none; transform: translateY(-1px); box-shadow: var(--shadow-1); }
.file-link::before {
  content: ""; width: 13px; height: 15px; flex-shrink: 0;
  background: currentColor; opacity: .55;
  clip-path: polygon(0 0, 65% 0, 100% 32%, 100% 100%, 0 100%);
}

/* ---------------- composer ---------------- */
.composer-zone {
  flex-shrink: 0; padding: var(--sp-2) var(--sp-3) calc(var(--sp-2) + env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--bg) 62%, color-mix(in oklch, var(--bg) 0%, transparent));
}
.composer {
  display: flex; align-items: flex-end; gap: 4px;
  width: 100%; max-width: var(--shell-w); margin: 0 auto;
  padding: 8px 8px 8px 12px;
  background: color-mix(in oklab, var(--surface) 82%, transparent);
  backdrop-filter: blur(24px) saturate(170%);
  -webkit-backdrop-filter: blur(24px) saturate(170%);
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: 0 16px 44px -16px oklch(0% 0 0 / .55), var(--inset-hi);
  transition: border-color var(--dur-fast) var(--ease-out), box-shadow var(--dur-fast) var(--ease-out), transform .18s var(--ease-out);
}
.composer:focus-within {
  border-color: oklch(from var(--brand) l c h / .55);
  box-shadow: 0 0 0 3px oklch(from var(--brand) l c h / .14),
    0 8px 30px oklch(0% 0 0 / .22), var(--inset-hi);
}
.composer .icon-btn { margin-bottom: 1px; }
#composer-input {
  flex: 1; min-width: 0; min-height: 38px; max-height: 220px;
  padding: 8px 4px; margin: 0;
  background: none; border: 0; outline: none; resize: none;
  font-size: 15px; line-height: 1.55; color: var(--text);
  overflow-y: auto;
}
#composer-input::placeholder { color: var(--text-3); }
#composer-input:disabled { opacity: .6; cursor: not-allowed; }

.btn-send {
  display: grid; place-items: center; width: 40px; height: 40px; flex-shrink: 0;
  border-radius: 50%; background: var(--brand-grad); color: #fff;
  border: 0;
  box-shadow: 0 6px 18px -4px oklch(from var(--brand) l c h / .55), var(--inset-hi);
  transition: background var(--dur-fast) var(--ease-out), transform var(--dur-fast) var(--ease-out), opacity var(--dur-fast), box-shadow var(--dur-fast);
}
.btn-send:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 10px 24px -4px oklch(from var(--brand) l c h / .7), var(--inset-hi); }
.btn-send:active:not(:disabled) { transform: scale(.94); }
.btn-send:disabled { background: var(--surface-3); color: var(--text-3); cursor: not-allowed; box-shadow: none; }

.btn-stop {
  display: grid; place-items: center; width: 38px; height: 38px; flex-shrink: 0;
  border-radius: var(--r-sm); background: var(--surface-3); color: var(--text);
  border: 1px solid var(--line);
  transition: background var(--dur-fast) var(--ease-out);
}
.btn-stop:hover { background: var(--danger-bg); color: var(--danger); border-color: var(--danger); }
.btn-stop[hidden] { display: none; }

.composer-hint {
  max-width: var(--shell-w); margin: 6px auto 0;
  font-size: 11px; color: var(--text-3); text-align: center;
}

.attach-bar {
  width: 100%; max-width: var(--shell-w); margin: 0 auto var(--sp-2);
  display: flex; flex-wrap: wrap; gap: 8px;
}
/* Kartu lampiran: thumbnail/ikon + nama + ukuran + progress */
.attach-card {
  display: inline-flex; align-items: center; gap: 9px;
  padding: 7px 8px 7px 9px; border-radius: var(--r-md);
  background: var(--surface); border: 1px solid var(--line);
  box-shadow: var(--shadow-1); font-size: 12.5px; color: var(--text);
  max-width: min(280px, 100%);
  animation: msg-in var(--dur-fast) var(--ease-out) both;
}
.attach-card.is-loading { border-color: var(--brand); }
.attach-thumb { width: 40px; height: 40px; border-radius: 7px; object-fit: cover; flex: none; }
.attach-ico { font-size: 26px; line-height: 1; flex: none; }
.attach-meta { display: grid; gap: 1px; min-width: 0; flex: 1; }
.attach-meta .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.attach-meta .sub { font-size: 11px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.attach-card .icon-btn { width: 22px; height: 22px; border-radius: 50%; flex: none; }
/* Progress upload */
.up-track { display: block; height: 4px; border-radius: 99px; background: var(--surface-3); margin-top: 4px; overflow: hidden; }
.up-fill { display: block; height: 100%; border-radius: 99px;
  background: linear-gradient(90deg, #7c3aed, #22d3ee);
  transition: width .2s ease-out; }
/* Drop hint: overlay tarik-letakkan file */
.composer-zone.is-dragover .composer { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(124, 58, 237, .25); }
.drop-hint {
  position: absolute; inset: -6px; z-index: 8;
  display: grid; place-items: center;
  background: color-mix(in srgb, var(--bg) 72%, transparent);
  backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
  border: 2px dashed var(--brand); border-radius: var(--r-lg);
  pointer-events: none;
}
.drop-hint[hidden] { display: none; }
.drop-hint > div { display: grid; gap: 4px; text-align: center; }
.drop-hint b { font-size: 15px; }
.drop-hint span { font-size: 12px; color: var(--text-3); }
/* Ikon unduh di kartu file pesan */
.file-link .file-dl-ico { display: inline-flex; margin-left: 2px; opacity: .7; }
.file-link:hover .file-dl-ico { opacity: 1; }
/* Mode fokus: sembunyikan sidebar + lebarkan chat (desktop) */
@media (min-width: 900px) {
  .app.is-focus { grid-template-columns: 0 1fr; gap: 0; padding: 0; }
  .app.is-focus .sidebar { display: none; }
  .app.is-focus .main {
    border-radius: 0; border: 0; max-height: none; height: 100dvh;
  }
}
@media (max-width: 899px) {
  .app.is-focus .sidebar { transform: translateX(-102%); }
}
#btn-focus.is-active { color: var(--brand); border-color: var(--brand); background: color-mix(in srgb, var(--brand) 12%, transparent); }
/* Saran pertanyaan lanjutan di bawah jawaban AI */
.suggest-row { display: flex; flex-wrap: wrap; gap: 6px; padding: 12px 0 2px; max-width: 100%; }
.suggest-row .suggest-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 13px; border-radius: 12px;
  background: color-mix(in srgb, var(--surface) 90%, transparent);
  border: 1px solid var(--line); color: var(--text-2);
  font-size: 12.5px; line-height: 1.35; text-align: left;
  cursor: pointer; transition: all var(--dur-fast) var(--ease-out);
}
.suggest-row .suggest-chip:hover { border-color: var(--brand); color: var(--text); background: color-mix(in srgb, var(--brand) 8%, var(--surface)); transform: translateY(-1px); }
/* Tombol Unduh di header code-block: jangan auto-margin ganda */
.code-head .copy-code:first-of-type { margin-left: auto; }
.code-head .copy-code + .copy-code { margin-left: 0; }
/* (legacy) pill kecil — dipertahankan untuk kompatibilitas */
.attach-pill {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 4px 4px 4px 10px; border-radius: var(--r-full);
  background: var(--surface-2); border: 1px solid var(--line);
  font-size: 12px; color: var(--text-2); max-width: 100%;
}
.attach-pill .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 42vw; }
.attach-pill .icon-btn { width: 22px; height: 22px; border-radius: 50%; }
.attach-pill.is-loading .name { opacity: .6; }
/* (legacy) thumbnail kecil */
.attach-thumb { width: 26px; height: 26px; border-radius: 5px; object-fit: cover; flex: none; }

.to-bottom {
  position: absolute; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--composer-h) + 76px); z-index: 5;
  width: 34px; height: 34px; display: grid; place-items: center;
  border-radius: 50%; background: var(--surface); color: var(--text);
  border: 1px solid var(--line); box-shadow: var(--shadow-2);
  animation: rise var(--dur-base) var(--ease-out);
}
.to-bottom:hover { background: var(--surface-2); }
.to-bottom[hidden] { display: none; }

/* ---------------- panels (notes / settings / admin) ---------------- */
.view#view-notes, .view#view-settings, .view#view-admin {
  overflow-y: auto; padding: var(--sp-5) var(--sp-4) var(--sp-10);
  gap: var(--sp-4);
}
.panel-head {
  width: 100%; max-width: 900px; margin: 0 auto;
  display: flex; align-items: flex-start; justify-content: space-between; gap: var(--sp-3);
  flex-wrap: wrap;
}
.panel-head h3 {
  font-size: 24px; letter-spacing: -0.02em;
  background: linear-gradient(100deg, var(--text), oklch(74% 0.16 295) 70%, oklch(74% 0.10 220));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.panel-head p { font-size: 13.5px; margin-top: 4px; color: var(--text-3); }

.notes-grid {
  width: 100%; max-width: 900px; margin: 0 auto;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 250px), 1fr));
  gap: 14px;
}
.note-card {
  display: flex; flex-direction: column; gap: var(--sp-2);
  padding: 16px; min-height: 160px; position: relative;
  background: var(--glass);
  backdrop-filter: blur(18px) saturate(150%);
  -webkit-backdrop-filter: blur(18px) saturate(150%);
  border: 1px solid var(--line); border-radius: 20px;
  box-shadow: 0 10px 30px -12px oklch(0% 0 0 / .5), var(--inset-hi);
  transition: transform .18s var(--ease-out), border-color .18s, box-shadow .18s;
  overflow: hidden;
}
/* lengkung aksen gradient di ujung atas kartu catatan */
.note-card::before {
  content: ""; position: absolute; top: 0; left: 16px; right: 16px; height: 2px;
  border-radius: 0 0 4px 4px;
  background: linear-gradient(90deg, transparent, oklch(from var(--brand) l c h / .7), oklch(72% 0.14 200 / .7), transparent);
  opacity: .8; pointer-events: none;
}
.note-card:hover { transform: translateY(-3px); border-color: color-mix(in oklch, oklch(72% 0.16 300), oklch(72% 0.10 220) 60%); box-shadow: 0 16px 40px -14px oklch(from var(--brand) l c h / .4), var(--inset-hi); }
.note-card:focus-within { border-color: var(--brand); box-shadow: 0 0 0 2px oklch(from var(--brand) l c h / .16), 0 16px 40px -14px oklch(from var(--brand) l c h / .45); }
.note-card input.note-title {
  width: 100%; background: none; border: 0; padding: 0;
  font-size: 15px; font-weight: 700; color: var(--text); letter-spacing: -0.02em;
}
.note-card input.note-title:focus { outline: none; box-shadow: none; }
.note-card textarea.note-body {
  flex: 1; width: 100%; min-height: 72px; resize: vertical;
  background: none; border: 0; padding: 0;
  font-size: 13.5px; line-height: 1.65; color: var(--text-2);
}
.note-card textarea.note-body:focus { outline: none; box-shadow: none; color: var(--text); }
.note-foot { display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--text-3); padding-top: 10px; border-top: 1px solid var(--line-soft); }
.note-foot .icon-btn { width: 26px; height: 26px; margin-left: auto; }
.note-foot .icon-btn:hover { color: var(--danger); background: var(--danger-bg); }
.note-status { margin-left: auto; }

.settings-grid {
  width: 100%; max-width: 900px; margin: 0 auto;
  display: grid; grid-template-columns: 1fr; gap: var(--sp-3);
}
.card {
  padding: var(--sp-5);
  position: relative;
  background: var(--glass);
  backdrop-filter: blur(18px) saturate(150%);
  -webkit-backdrop-filter: blur(18px) saturate(150%);
  border: 1px solid var(--line); border-radius: 22px;
  box-shadow: 0 12px 34px -14px oklch(0% 0 0 / .5), var(--inset-hi);
  overflow: hidden;
}
/* highlight glossy di tepi atas card */
.card::before {
  content: ""; position: absolute; inset: 0 0 auto; height: 1px;
  background: linear-gradient(90deg, transparent, color-mix(in oklab, #fff 22%, transparent), transparent);
  pointer-events: none;
}
.card h4 { font-size: 14.5px; margin-bottom: var(--sp-3); font-weight: 700; }
.card .muted { margin-bottom: var(--sp-3); }
.card .field:last-of-type { margin-bottom: var(--sp-3); }

.theme-pick { display: flex; gap: var(--sp-2); }
.theme-opt {
  flex: 1; display: flex; align-items: center; gap: 8px;
  padding: 11px var(--sp-3); border-radius: 14px;
  background: var(--surface-2); border: 1px solid var(--line);
  font-size: 13.5px; color: var(--text-2);
  transition: transform .16s var(--ease-out), border-color var(--dur-fast), box-shadow var(--dur-fast);
}
.theme-opt:hover { transform: translateY(-1px); color: var(--text); border-color: var(--text-3); }
.theme-opt.is-active { border-color: var(--brand); color: var(--text); box-shadow: 0 0 0 2px oklch(from var(--brand) l c h / .22), 0 6px 18px -8px oklch(from var(--brand) l c h / .5); }
.theme-swatch { width: 16px; height: 16px; border-radius: 5px; border: 1px solid var(--line); }
.sw-dark { background: #0b0d14; }
.sw-light { background: #f4f5f9; }

.table-card { padding: 0; overflow: hidden; border-radius: 22px; }
.table-wrap { overflow-x: auto; }
.users-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.users-table th, .users-table td { padding: 13px var(--sp-4); text-align: left; border-bottom: 1px solid var(--line-soft); white-space: nowrap; }
.users-table th { font-size: 11px; text-transform: uppercase; letter-spacing: .07em; color: var(--text-3); font-weight: 700; background: color-mix(in oklab, var(--surface-2) 60%, transparent); }
.users-table tr:last-child td { border-bottom: 0; }
.users-table tbody tr { transition: background var(--dur-fast) var(--ease-out); }
.users-table tbody tr:hover { background: var(--surface-2); }
.users-table .row-actions { display: flex; gap: 6px; flex-wrap: wrap; }

.tag {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: var(--r-full);
  font-size: 11px; font-weight: 600;
  border: 1px solid var(--line); color: var(--text-2); background: var(--surface-2);
}
.tag.ok { color: var(--ok); border-color: color-mix(in oklch, var(--ok) 40%, transparent); background: color-mix(in oklch, var(--ok) 12%, var(--surface)); }
.tag.pending { color: var(--warn); border-color: color-mix(in oklch, var(--warn) 40%, transparent); background: color-mix(in oklch, var(--warn) 12%, var(--surface)); }
.tag.admin { color: var(--brand); border-color: color-mix(in oklch, var(--brand) 40%, transparent); background: color-mix(in oklch, var(--brand) 14%, var(--surface)); }
[data-theme="dark"] .tag.admin { color: #c4b5fd; }

.empty-state {
  width: 100%; max-width: 900px; margin: var(--sp-8) auto;
  padding: var(--sp-12) var(--sp-6); text-align: center;
  color: var(--text-3); font-size: 14px; line-height: 1.7;
  border: 1px dashed var(--line); border-radius: 24px;
  background: color-mix(in oklch, transparent 55%, var(--surface));
}

/* ---------------- toasts ---------------- */
.toasts {
  position: fixed; z-index: 200; bottom: 20px; left: 50%; transform: translateX(-50%);
  display: flex; flex-direction: column; gap: var(--sp-2); align-items: center;
  pointer-events: none; width: min(92vw, 400px);
}
.toast {
  display: flex; align-items: center; gap: var(--sp-2);
  width: 100%; padding: 11px var(--sp-4);
  background: var(--glass);
  backdrop-filter: blur(20px) saturate(160%);
  -webkit-backdrop-filter: blur(20px) saturate(160%);
  color: var(--text);
  border: 1px solid var(--line); border-radius: 16px;
  box-shadow: 0 12px 34px -10px oklch(0% 0 0 / .6), var(--inset-hi); font-size: 13.5px;
  animation: toast-in var(--dur-base) var(--ease-spring) both;
  pointer-events: auto;
}
.toast.is-out { animation: toast-out var(--dur-fast) var(--ease-out) forwards; }
.toast.err { border-color: var(--danger); }
.toast.err .toast-dot { background: var(--danger); }
.toast.ok .toast-dot { background: var(--ok); }
.toast-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--text-3); flex-shrink: 0; }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px) scale(.97); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(6px); } }

/* ---------------- modal ---------------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 150;
  display: grid; place-items: center; padding: var(--sp-4);
  background: oklch(0% 0 0 / .55); backdrop-filter: blur(3px);
  animation: fade-in var(--dur-fast) var(--ease-out);
}
.modal {
  width: 100%; max-width: 400px;
  background: var(--glass);
  backdrop-filter: blur(28px) saturate(160%);
  -webkit-backdrop-filter: blur(28px) saturate(160%);
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: 0 24px 60px -18px oklch(0% 0 0 / .7), var(--inset-hi);
  padding: var(--sp-5);
  animation: modal-in var(--dur-base) var(--ease-spring);
}
@keyframes modal-in { from { opacity: 0; transform: scale(.96) translateY(8px); } }
.modal h4 { font-size: 16px; margin-bottom: 6px; }
.modal p { font-size: 13.5px; color: var(--text-2); margin-bottom: var(--sp-4); }
.modal .field:last-of-type { margin-bottom: var(--sp-4); }
.modal-actions { display: flex; gap: var(--sp-2); justify-content: flex-end; }

/* ---------------- responsive ---------------- */
.only-mobile { display: inline-grid; }

@media (min-width: 900px) {
  .app {
    grid-template-columns: var(--sidebar-w) 1fr;
    gap: 18px; padding: 18px 18px 18px 18px;
    background:
      radial-gradient(900px 520px at -6% -8%, oklch(from var(--brand) l c h / .14), transparent 55%),
      radial-gradient(820px 540px at 108% 8%, oklch(72% 0.13 210 / .1), transparent 55%),
      oklch(9% 0.015 275);
  }
  .sidebar { position: static; width: auto; height: 100%; transform: none; z-index: 1;
    border-radius: 22px; overflow: hidden;
    border: 1px solid var(--line-soft);
    background: color-mix(in oklab, var(--bg-deep) 96%, white 0%); }
  .sidebar.is-open { box-shadow: none; }
  .scrim { display: none !important; }
  .only-mobile { display: none !important; }
  .main { border-radius: 22px; height: auto; max-height: 100%;
    background: color-mix(in oklab, var(--bg-deep) 92%, var(--surface) 8%);
    border: 1px solid var(--line-soft);
    box-shadow: 0 24px 60px -30px oklch(0% 0 0 / .8), var(--inset-hi); }
  .topbar { margin: 12px auto 0; padding: 8px 18px; width: min(100% - 28px, calc(var(--shell-w) + 60px)); }
  .top-title h2 { max-width: none; }
  .composer-zone { padding: var(--sp-2) var(--sp-6) var(--sp-4); }
  .scroll-area { padding-top: var(--sp-8); }
  .settings-grid { grid-template-columns: 1fr 1fr; }
  .to-bottom { bottom: calc(var(--composer-h) + 40px); }
}

@media (max-width: 899px) {
  .sidebar { box-shadow: var(--shadow-3); }
  .msg.user .bubble { max-width: 88%; }
}

@media (max-width: 380px) {
  .messages { padding: 0 var(--sp-3); }
  .composer-zone { padding-left: var(--sp-2); padding-right: var(--sp-2); }
  .composer-hint { display: none; }
  .chip { font-size: 12.5px; }
}

/* ---------------- motion prefs ---------------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
    scroll-behavior: auto !important;
  }
}

/* ============ WOW v4: splash, aurora, brand menu, palette ============ */
.splash { position: fixed; inset: 0; z-index: 300; display: grid; place-items: center;
  background: var(--bg); transition: opacity .45s ease; }
.splash.is-done { opacity: 0; pointer-events: none; }
.splash-inner { display: grid; justify-items: center; gap: var(--sp-3); }
.splash-inner strong { font-size: 22px; letter-spacing: .14em; text-transform: uppercase;
  background: linear-gradient(100deg, oklch(72% 0.17 295), oklch(73% 0.12 220)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.splash-mark { animation: splash-float 1.6s ease-in-out infinite; filter: drop-shadow(0 8px 28px oklch(from var(--brand) l c h / .45)); }
@keyframes splash-float { 0%, 100% { transform: translateY(0) scale(1); } 50% { transform: translateY(-7px) scale(1.04); } }
.splash-bar { width: 150px; height: 4px; border-radius: var(--r-full); background: var(--surface-2); overflow: hidden; }
.splash-bar span { display: block; height: 100%; width: 40%; border-radius: inherit;
  background: linear-gradient(90deg, #6d28d9, #22d3ee); animation: splash-slide 1s ease-in-out infinite; }
@keyframes splash-slide { 0% { transform: translateX(-110%); } 100% { transform: translateX(400%); } }

.welcome { position: relative; overflow: hidden; }
.aurora { position: absolute; inset: -40% -20% auto; height: 340px; pointer-events: none; filter: blur(60px); opacity: .5; }
.aurora span { position: absolute; border-radius: 50%; mix-blend-mode: screen; }
.aurora span:nth-child(1) { width: 260px; height: 260px; left: 8%; background: #6d28d9; animation: drift1 11s ease-in-out infinite; }
.aurora span:nth-child(2) { width: 200px; height: 200px; right: 12%; background: #0ea5e9; animation: drift2 13s ease-in-out infinite; }
.aurora span:nth-child(3) { width: 150px; height: 150px; left: 42%; top: 40px; background: #db2777; opacity: .7; animation: drift1 9s ease-in-out infinite reverse; }
@keyframes drift1 { 0%, 100% { transform: translate(0, 0); } 50% { transform: translate(46px, 30px); } }
@keyframes drift2 { 0%, 100% { transform: translate(0, 0); } 50% { transform: translate(-40px, 24px); } }
.welcome > *:not(.aurora) { position: relative; }
.welcome-mark { display: inline-grid; animation: splash-float 3.2s ease-in-out infinite;
  filter: drop-shadow(0 6px 22px oklch(from var(--brand) l c h / .5)); }
.welcome h3 { font-size: clamp(24px, 4.8vw, 32px); letter-spacing: -0.04em; font-weight: 750;
  background: var(--brand-grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.chip { transition: transform .16s var(--ease-spring), border-color .16s, background .16s; }
.chip:hover { transform: translateY(-2px); border-color: var(--brand); box-shadow: 0 6px 20px oklch(from var(--brand) l c h / .14); }

.brand { position: relative; }
.brand-btn { display: flex; align-items: center; gap: var(--sp-2); flex: 1; padding: var(--sp-1) var(--sp-2);
  margin: calc(var(--sp-1) * -1) calc(var(--sp-2) * -1); border: 0; border-radius: var(--r-sm);
  background: transparent; color: inherit; cursor: pointer; text-align: left; min-width: 0; }
.brand-btn:hover { background: var(--surface-2); }
.brand-chev { opacity: .55; transition: transform .18s; }
.brand-btn[aria-expanded="true"] .brand-chev { transform: rotate(180deg); }
.brand-menu { position: absolute; top: calc(100% + 6px); left: 0; min-width: 248px; z-index: 60;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md);
  box-shadow: var(--shadow-3); padding: var(--sp-2);
  animation: menu-pop .16s var(--ease-spring); }
@keyframes menu-pop { from { opacity: 0; transform: translateY(-6px) scale(.98); } to { opacity: 1; transform: none; } }
.brand-menu .bm-head { padding: var(--sp-2) var(--sp-2) var(--sp-1); }
.brand-menu .bm-head strong { display: block; font-size: 14px; }
.brand-menu .bm-head small { color: var(--text-2); font-size: 12px; }
.brand-menu .bm-stats { display: flex; gap: var(--sp-2); padding: 0 var(--sp-2) var(--sp-2); }
.brand-menu .bm-stat { flex: 1; background: var(--surface-2); border-radius: var(--r-sm); padding: var(--sp-2); text-align: center; }
.brand-menu .bm-stat b { display: block; font-size: 17px; }
.brand-menu .bm-stat span { font-size: 11px; color: var(--text-2); }
.brand-menu button[role="menuitem"] { display: flex; align-items: center; gap: var(--sp-2); width: 100%;
  padding: var(--sp-2); border: 0; border-radius: var(--r-sm); background: transparent;
  color: var(--text); font-size: 13.5px; cursor: pointer; }
.brand-menu button[role="menuitem"]:hover { background: var(--surface-2); }
.brand-menu kbd { margin-left: auto; }

kbd { font-family: inherit; font-size: 11px; color: var(--text-2); background: var(--surface-2);
  border: 1px solid var(--border); border-bottom-width: 2px; border-radius: 6px; padding: 1px 6px; white-space: nowrap; }
.composer-hint kbd { font-size: 10.5px; }

.palette-backdrop { position: fixed; inset: 0; z-index: 250; background: rgba(3, 5, 12, .6);
  backdrop-filter: blur(3px); display: flex; justify-content: center; align-items: flex-start;
  padding: 12vh var(--sp-4) var(--sp-4); animation: fade-in .15s ease; }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
.palette { width: min(560px, 100%); background: var(--glass);
  backdrop-filter: blur(30px) saturate(170%);
  -webkit-backdrop-filter: blur(30px) saturate(170%);
  border: 1px solid var(--border);
  border-radius: 24px; box-shadow: var(--shadow-3), var(--inset-hi); overflow: hidden;
  animation: menu-pop .18s var(--ease-spring); }
.palette-input-row { display: flex; align-items: center; gap: var(--sp-2); padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--border); }
.palette-input-row svg { flex: none; opacity: .55; }
.palette-input-row input { flex: 1; border: 0; background: transparent; color: var(--text);
  font-size: 15px; outline: none; min-width: 0; }
.palette-list { max-height: 320px; overflow-y: auto; padding: var(--sp-2); }
.palette-group { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--text-2);
  padding: var(--sp-2) var(--sp-2) var(--sp-1); }
.palette-item { display: flex; align-items: center; gap: var(--sp-2); width: 100%; text-align: left;
  padding: var(--sp-2) var(--sp-2); border: 0; border-radius: var(--r-sm); background: transparent;
  color: var(--text); font-size: 13.5px; cursor: pointer; }
.palette-item small { margin-left: auto; color: var(--text-2); font-size: 11.5px; }
.palette-item.is-sel { background: var(--accent-soft); }
.palette-empty { padding: var(--sp-5); text-align: center; color: var(--text-2); font-size: 13px; }

.chat-group-label { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--text-2);
  padding: var(--sp-3) var(--sp-1) var(--sp-1); }

/* pesan masuk: animasi halus */
.btn-send:not(:disabled) { background: var(--brand-grad);
  box-shadow: 0 4px 18px oklch(from var(--brand) l c h / .4); }
.btn-send:not(:disabled):hover { transform: translateY(-1px); box-shadow: 0 8px 24px oklch(from var(--brand) l c h / .5); }
.icon-btn.is-speaking { color: var(--accent); border-color: var(--accent); }
