/* Style: supabase (NeedMCP) */
:root {
  color-scheme: light dark;
  --bg: #ffffff;
  --bg-soft: #fafafa;
  --bg-side: #f5f5f5;
  --bg-hover: #f0f0f0;
  --surface: #ffffff;
  --text: #0f0f0f;
  --text-body: #171717;
  --muted: #525252;
  --subtle: #737373;
  --border: #e5e5e5;
  --border-hover: #d0d0d0;
  --primary: #3ecf8e;
  --primary-hover: #34b57c;
  --primary-active: #2ea06b;
  --on-primary: #ffffff;
  --link: #00c573;
  --ring: rgba(62, 207, 142, 0.4);
  --danger: #e54d2e;
  --user-bubble: #f5f5f5;
  --code-bg: #0f0f0f;
  --code-text: #fafafa;
  --auth-bg: #fafafa;
  --aside-bg: #eaf7f0;
  --aside-text: #0f2a1d;
  --aside-muted: #456354;
  --aside-accent: #07784a;
  --aside-glow: rgba(62, 207, 142, .38);
  --aside-glow-2: rgba(62, 207, 142, .2);
  --aside-dot: rgba(15, 42, 29, .12);
  --aside-tile-bg: #ffffff;
  --aside-tile-border: rgba(7, 120, 74, .22);
  --radius-xs: 4px;
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 16px;
  --font-sans: Circular, system-ui, -apple-system, "Helvetica Neue", Helvetica, Arial, sans-serif;
  --font-mono: "Source Code Pro", "Office Code Pro", Menlo, monospace;
  --sidebar-w: 280px;
}

/* Mode gelap (default bila sistem gelap, kecuali dipaksa terang). */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f0f0f;
    --bg-soft: #171717;
    --bg-side: #141414;
    --bg-hover: #1e1e1e;
    --surface: #1a1a1a;
    --text: #fafafa;
    --text-body: #fafafa;
    --muted: #b4b4b4;
    --subtle: #898989;
    --border: #2e2e2e;
    --border-hover: #363636;
    --link: #00c573;
    --user-bubble: #1a1a1a;
    --code-bg: #0a0a0a;
    --code-text: #fafafa;
    --auth-bg: #0f0f0f;
    --aside-bg: #0b1f17;
    --aside-text: #f2faf6;
    --aside-muted: #b7d3c6;
    --aside-accent: #8fe3bd;
    --aside-glow: rgba(62, 207, 142, .35);
    --aside-glow-2: rgba(62, 207, 142, .16);
    --aside-dot: rgba(255, 255, 255, .09);
    --aside-tile-bg: rgba(62, 207, 142, .12);
    --aside-tile-border: rgba(62, 207, 142, .25);
  }
}
:root[data-theme="dark"] {
  --bg: #0f0f0f;
  --bg-soft: #171717;
  --bg-side: #141414;
  --bg-hover: #1e1e1e;
  --surface: #1a1a1a;
  --text: #fafafa;
  --text-body: #fafafa;
  --muted: #b4b4b4;
  --subtle: #898989;
  --border: #2e2e2e;
  --border-hover: #363636;
  --link: #00c573;
  --user-bubble: #1a1a1a;
  --code-bg: #0a0a0a;
  --code-text: #fafafa;
  --auth-bg: #0f0f0f;
  --aside-bg: #0b1f17;
  --aside-text: #f2faf6;
  --aside-muted: #b7d3c6;
  --aside-accent: #8fe3bd;
  --aside-glow: rgba(62, 207, 142, .35);
  --aside-glow-2: rgba(62, 207, 142, .16);
  --aside-dot: rgba(255, 255, 255, .09);
  --aside-tile-bg: rgba(62, 207, 142, .12);
  --aside-tile-border: rgba(62, 207, 142, .25);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { height: 100%; margin: 0; }
body {
  font: 400 16px/1.5 var(--font-sans);
  background: var(--bg);
  color: var(--text);
  -webkit-text-size-adjust: 100%;
}

button, input, textarea { font: inherit; color: inherit; }

/* Ikon garis (sprite /icons.svg) */
.icon {
  width: 18px; height: 18px; flex: none; display: block;
  fill: none; stroke: currentColor; stroke-width: 1.75;
  stroke-linecap: round; stroke-linejoin: round;
}
.icon-btn .icon { margin: 0 auto; }
.btn .icon { width: 16px; height: 16px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.btn.link .icon { width: 15px; height: 15px; opacity: .85; }
.chip .icon { width: 14px; height: 14px; color: var(--muted); }
.conv-actions .icon { width: 15px; height: 15px; }
.branch-nav .icon { width: 14px; height: 14px; }
.msg-actions .icon { width: 14px; height: 14px; }
.msg-actions button, .branch-nav button { display: inline-flex; align-items: center; gap: 4px; }
.codeblock .icon { width: 13px; height: 13px; display: inline-block; vertical-align: -2px; margin-right: 4px; }
.project-badge { display: inline-flex; align-items: center; gap: 5px; }
.project-badge .icon { width: 13px; height: 13px; }
.saved { display: inline-flex; align-items: center; gap: 5px; }
.saved .icon { width: 14px; height: 14px; color: var(--primary); }
#s-key-hint { display: inline-flex; align-items: flex-start; gap: 6px; }
#s-key-hint .icon { width: 14px; height: 14px; margin-top: 3px; color: var(--danger); }
.test-result { display: inline-flex; align-items: center; gap: 6px; }
.test-result .icon { width: 15px; height: 15px; }
.muted { color: var(--muted); }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.error { color: var(--danger); font-size: 14px; margin: 0; }

/* Tombol */
.btn {
  border: 1px solid var(--border);
  background: transparent;
  border-radius: var(--radius-sm);
  padding: 8px 16px;
  min-height: 40px;
  font-size: 14px;
  font-weight: 500;
  line-height: 1.14;
  cursor: pointer;
  transition: background .15s, border-color .15s, opacity .15s;
}
.btn:hover { border-color: var(--border-hover); background: var(--bg-hover); }
.btn.small { padding: 6px 12px; min-height: 32px; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.btn.primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn.primary:active { background: var(--primary-active); border-color: var(--primary-active); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.link { border: 0; background: none; color: var(--muted); padding: 6px; min-height: 0; }
.btn.link:hover { color: var(--text); background: none; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.icon-btn {
  border: 0; background: none; cursor: pointer; color: var(--muted);
  display: inline-grid; place-items: center;
  min-width: 40px; height: 40px; border-radius: var(--radius-sm);
  transition: background .15s, color .15s;
}
.icon-btn:hover { color: var(--text); }
.icon-btn:hover { background: var(--bg-hover); }
.icon-btn.recording { color: var(--danger); background: var(--bg-hover); animation: mic-pulse 1.2s ease-in-out infinite; }
@keyframes mic-pulse { 50% { opacity: .45; } }
@media (prefers-reduced-motion: reduce) { .icon-btn.recording { animation: none; } }
:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }

.brand { display: flex; align-items: center; gap: 10px; font-weight: 500; font-size: 16px; }
.logo {
  display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: var(--radius-sm);
  background: var(--primary); color: var(--on-primary); font-family: var(--font-mono); font-weight: 500;
}
.logo.big { width: 56px; height: 56px; border-radius: var(--radius-lg); font-size: 28px; box-shadow: 0 8px 28px -6px rgba(62, 207, 142, .55); }

/* Auth */
.auth {
  min-height: 100%; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr); background: var(--auth-bg);
}
.auth[hidden] { display: none; }
.auth-panel { display: grid; place-items: center; padding: 32px 24px; }
.auth-card { width: min(380px, 100%); display: flex; flex-direction: column; gap: 20px; }
.auth-brand { display: flex; align-items: center; gap: 10px; font-weight: 500; font-size: 16px; margin-bottom: 12px; }
.auth-head { display: flex; flex-direction: column; gap: 8px; }
.auth-title { margin: 0; font-size: 28px; font-weight: 500; line-height: 1.2; letter-spacing: -0.4px; text-wrap: balance; }
.auth-lead { margin: 0; color: var(--muted); font-size: 15px; line-height: 1.5; }
.auth-fields { display: flex; flex-direction: column; gap: 16px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field-label { font-size: 14px; font-weight: 500; color: var(--muted); }
.input-wrap {
  display: flex; align-items: center; gap: 10px; padding: 0 4px 0 12px; min-height: 44px;
  border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface);
  transition: border-color .15s, box-shadow .15s;
}
.input-wrap > .icon { width: 17px; height: 17px; color: var(--subtle); transition: color .15s; }
.input-wrap:hover { border-color: var(--border-hover); }
.input-wrap:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px var(--ring); }
.input-wrap:focus-within > .icon { color: var(--primary); }
.input-wrap input {
  flex: 1; min-width: 0; align-self: stretch; padding: 8px 8px 8px 0; border: 0; outline: 0; background: transparent;
  color: var(--text); font-size: 15px;
}
.input-wrap input::placeholder { color: var(--subtle); }
.input-wrap input:-webkit-autofill { -webkit-text-fill-color: var(--text); transition: background-color 9999s; }
.pw-toggle {
  border: 0; background: none; cursor: pointer; color: var(--subtle); width: 36px; height: 36px; flex: none;
  display: grid; place-items: center; border-radius: var(--radius-sm); transition: color .15s, background .15s;
}
.pw-toggle:hover { color: var(--text); background: var(--bg-hover); }
.pw-toggle .icon { margin: auto; }
.pw-toggle .icon-eye-off, .pw-toggle[aria-pressed="true"] .icon-eye { display: none; }
.pw-toggle[aria-pressed="true"] .icon-eye-off { display: block; }
.auth-submit { width: 100%; min-height: 44px; font-size: 15px; }
.auth-submit:disabled { opacity: .7; cursor: progress; }
.auth-card .error { margin-top: -4px; padding: 10px 12px; border-radius: var(--radius-sm); background: rgba(229, 77, 46, .1); }
.auth-card .error.info { color: var(--text-body); background: rgba(62, 207, 142, .12); }
.auth-divider { display: flex; align-items: center; gap: 12px; color: var(--subtle); font-size: 13px; }
.auth-divider::before, .auth-divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.auth-google {
  width: 100%; min-height: 44px; font-size: 15px; display: inline-flex; align-items: center; justify-content: center;
  gap: 10px; text-decoration: none; background: var(--surface); color: var(--text);
}
.auth-google:visited { color: var(--text); }
.auth-switch { margin: 0; display: flex; justify-content: center; align-items: center; gap: 4px; font-size: 14px; color: var(--muted); }
.btn.link.auth-toggle { color: var(--aside-accent); font-weight: 600; padding: 6px 4px; }
.btn.link.auth-toggle:hover { color: var(--aside-accent); text-decoration: underline; }

.auth-aside {
  position: relative; overflow: hidden; display: grid; align-items: center; padding: 48px;
  background-color: var(--aside-bg); color: var(--aside-text); border-left: 1px solid var(--border);
  background-image:
    radial-gradient(520px 360px at 85% 0%, var(--aside-glow), transparent 70%),
    radial-gradient(420px 320px at 0% 100%, var(--aside-glow-2), transparent 70%);
}
.auth-aside::after {
  content: ""; position: absolute; inset: 0; pointer-events: none; opacity: .6;
  background-image: radial-gradient(var(--aside-dot) 1px, transparent 1px); background-size: 22px 22px;
  mask-image: linear-gradient(to bottom, transparent, #000 40%, transparent);
  -webkit-mask-image: linear-gradient(to bottom, transparent, #000 40%, transparent);
}
.aside-inner { position: relative; z-index: 1; max-width: 460px; display: flex; flex-direction: column; gap: 20px; }
.aside-kicker { margin: 0; font-size: 13px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--aside-accent); }
.aside-title { margin: 0; font-size: 38px; font-weight: 500; line-height: 1.15; letter-spacing: -0.8px; text-wrap: balance; }
.aside-title span { color: var(--aside-accent); }
.aside-list { list-style: none; margin: 12px 0 0; padding: 0; display: flex; flex-direction: column; gap: 18px; }
.aside-list li { display: flex; gap: 14px; align-items: flex-start; font-size: 14px; line-height: 1.5; color: var(--aside-muted); }
.aside-list li .icon {
  width: 38px; height: 38px; padding: 9px; border-radius: var(--radius-md); flex: none; color: var(--aside-accent);
  background: var(--aside-tile-bg); border: 1px solid var(--aside-tile-border);
}
.aside-list b { display: block; margin-bottom: 2px; font-weight: 500; font-size: 15px; color: var(--aside-text); }

/* Layout */
.app { display: flex; height: 100vh; height: 100dvh; }
.sidebar {
  width: var(--sidebar-w); flex: none; background: var(--bg-side); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; min-height: 0;
}
.side-head { display: flex; align-items: center; padding: 16px 16px 12px; }
.side-actions { display: flex; gap: 8px; padding: 0 12px 12px; }
.side-actions .btn.primary { flex: 1; min-height: 40px; }
.side-actions .icon-search { width: 40px; padding: 0; color: var(--muted); background: var(--surface); }
.side-actions .icon-search:hover { color: var(--text); }
.side-tools { display: grid; grid-template-columns: repeat(4, 1fr); gap: 2px; padding: 0 8px 8px; margin: 0 4px; border-bottom: 1px solid var(--border); }
.side-tool {
  display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 8px 2px 6px; border: 0; background: none;
  border-radius: var(--radius-md); color: var(--muted); font-size: 11.5px; font-weight: 500; text-decoration: none; cursor: pointer;
  transition: background .15s, color .15s;
}
.side-tool[hidden] { display: none; }
.side-tool .icon { width: 18px; height: 18px; }
.side-tool:hover { background: var(--bg-hover); color: var(--text); }
.side-tool:hover .icon { color: var(--primary); }
.side-foot { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-top: 1px solid var(--border); font-size: 14px; }
.avatar {
  width: 30px; height: 30px; flex: none; border-radius: 50%; display: grid; place-items: center; font-size: 13px; font-weight: 600;
  text-transform: uppercase; color: var(--primary); background: rgba(62, 207, 142, .14); border: 1px solid rgba(62, 207, 142, .3);
}
.user-email { flex: 1; min-width: 0; color: var(--muted); font-size: 13px; }
.conv-list { flex: 1; overflow-y: auto; padding: 4px 8px 8px; display: flex; flex-direction: column; gap: 2px; }
.conv {
  display: flex; align-items: center; gap: 4px; border-radius: var(--radius-sm); padding: 2px 4px 2px 10px; cursor: pointer;
}
.conv { position: relative; transition: background .15s; }
.conv:hover, .conv.active { background: var(--bg-hover); }
.conv.active::before { content: ""; position: absolute; left: 0; top: 8px; bottom: 8px; width: 3px; border-radius: 3px; background: var(--primary); }
.conv.active .conv-title { font-weight: 500; }
.conv-title { flex: 1; min-width: 0; padding: 8px 0; font-size: 14px; background: none; border: 0; text-align: left; cursor: pointer; }
.conv-actions { display: none; gap: 0; }
.conv:hover .conv-actions, .conv.active .conv-actions, .conv:focus-within .conv-actions { display: flex; }
.conv-actions button {
  border: 0; background: none; cursor: pointer; padding: 4px 6px; border-radius: var(--radius-xs); font-size: 13px; opacity: .7;
  display: inline-flex; align-items: center; color: var(--muted);
}
.conv-actions button:hover { opacity: 1; background: var(--bg); }
.conv-rename { flex: 1; min-width: 0; padding: 6px 8px; border: 1px solid var(--primary); border-radius: var(--radius-sm); background: var(--bg); }
.list-empty { display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; padding: 28px 16px; font-size: 13px; }
.list-empty .icon { width: 28px; height: 28px; padding: 6px; box-sizing: content-box; border-radius: var(--radius-md); background: var(--bg-hover); color: var(--subtle); }
.conv-group { margin: 14px 0 4px; padding: 0 10px; font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--subtle); }
.conv-actions button.pinned { color: var(--primary); opacity: 1; }

.chat { flex: 1; min-width: 0; display: flex; flex-direction: column; min-height: 0; }
.topbar {
  display: flex; align-items: center; gap: 8px; padding: 10px 64px 10px 20px; min-height: 56px;
  border-bottom: 1px solid var(--border); background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); position: sticky; top: 0; z-index: 5;
}
.topbar h1 { margin: 0; font-size: 15px; font-weight: 500; min-width: 0; flex: 1; }
#menu { display: none; }

.messages { flex: 1; overflow-y: auto; padding: 28px 16px 12px; scroll-behavior: smooth; }
.messages > * { max-width: 760px; margin-left: auto; margin-right: auto; }
.empty { text-align: center; margin-top: 12vh; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.empty h2 { margin: 16px 0 4px; font-size: 36px; font-weight: 500; line-height: 1.15; letter-spacing: -0.6px; }
.empty p { margin: 0; }
.suggestions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-top: 28px; width: 100%; max-width: 620px; }
.suggestion {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px; text-align: left; cursor: pointer;
  padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface);
  color: var(--text); font: inherit; font-size: 14px;
}
.suggestion { transition: border-color .15s, background .15s, transform .15s; }
.suggestion:hover { border-color: var(--primary); background: var(--bg-soft); transform: translateY(-1px); }
.suggestion .icon { width: 32px; height: 32px; padding: 7px; margin-bottom: 6px; color: var(--primary); background: rgba(62, 207, 142, .12); border-radius: var(--radius-sm); }
@media (prefers-reduced-motion: reduce) { .suggestion:hover { transform: none; } }
.suggestion strong { font-weight: 500; }
.suggestion span { font-size: 13px; line-height: 1.4; }

/* Pesan */
.msg { margin-bottom: 28px; display: flex; flex-direction: column; }
.msg.user { align-items: flex-end; }
.msg.user .bubble {
  background: var(--user-bubble); border: 1px solid var(--border); border-radius: 18px 18px 4px 18px;
  padding: 10px 16px; max-width: 80%; white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.55;
}
.msg.assistant .bubble { width: 100%; overflow-wrap: anywhere; }
.msg .role { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); margin-bottom: 8px; font-weight: 600; }
.logo.sm { width: 22px; height: 22px; border-radius: 6px; font-size: 12px; }
.msg.assistant .bubble { line-height: 1.7; }
.msg.error-msg .bubble { color: var(--danger); }
.cursor::after { content: "▍"; animation: blink 1s steps(2) infinite; color: var(--primary); }
@keyframes blink { 50% { opacity: 0; } }
.typing { display: inline-flex; gap: 4px; padding: 6px 0; }
.typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--primary); animation: bounce 1.2s infinite ease-in-out; }
.typing i:nth-child(2) { animation-delay: .15s; }
.typing i:nth-child(3) { animation-delay: .3s; }
@keyframes bounce { 0%, 80%, 100% { transform: scale(.6); opacity: .5; } 40% { transform: scale(1); opacity: 1; } }

.attach-list { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 6px; justify-content: flex-end; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; max-width: 240px; padding: 4px 10px; border: 1px solid var(--border);
  border-radius: 9999px; background: var(--bg-soft); font-size: 13px; text-decoration: none; color: var(--text);
}
.chip button { border: 0; background: none; cursor: pointer; padding: 0 2px; color: var(--muted); display: inline-flex; align-items: center; }
.chip button:hover { color: var(--danger); }
.thumb { max-width: 220px; max-height: 180px; border-radius: var(--radius-md); border: 1px solid var(--border); display: block; }

/* Markdown */
.md > :first-child { margin-top: 0; }
.md > :last-child { margin-bottom: 0; }
.md p { margin: 0 0 12px; }
.md h1, .md h2, .md h3, .md h4 { margin: 20px 0 8px; line-height: 1.25; font-weight: 400; }
.md h1 { font-size: 2.25rem; } .md h2 { font-size: 1.5rem; } .md h3 { font-size: 1.25rem; } .md h4 { font-size: 1rem; font-weight: 500; }
.md ul, .md ol { margin: 0 0 12px; padding-left: 1.5em; }
.md li { margin: 2px 0; }
.md blockquote { margin: 0 0 12px; padding: 2px 14px; border-left: 2px solid var(--primary); color: var(--muted); }
.md hr { border: 0; border-top: 1px solid var(--border); margin: 16px 0; }
.md a { color: var(--link); text-decoration: underline; text-underline-offset: 2px; }
.md code { font-family: var(--font-mono); font-size: .75rem; background: var(--bg-hover); border: 1px solid var(--border); padding: 2px 6px; border-radius: var(--radius-xs); }
.md .table-wrap { overflow-x: auto; margin: 0 0 12px; }
.md table { border-collapse: collapse; font-size: 14px; }
.md th, .md td { border: 1px solid var(--border); padding: 6px 12px; text-align: left; }
.md th { background: var(--bg-soft); font-weight: 500; }
.codeblock { margin: 0 0 12px; border-radius: var(--radius-md); overflow: hidden; background: var(--code-bg); border: 1px solid var(--border); }
.codeblock .code-head { display: flex; justify-content: space-between; align-items: center; padding: 6px 12px; background: rgba(255,255,255,.04); border-bottom: 1px solid var(--border); font-family: var(--font-mono); font-size: 12px; color: var(--muted); }
.codeblock .copy { border: 0; background: none; color: var(--code-text); cursor: pointer; padding: 2px 8px; border-radius: var(--radius-xs); font-size: 12px; display: inline-flex; align-items: center; }
.codeblock .copy:hover { background: rgba(255,255,255,.08); }
.codeblock pre { margin: 0; padding: 12px 14px; overflow-x: auto; }
.codeblock pre code { background: none; border: 0; padding: 0; color: var(--code-text); font-family: var(--font-mono); font-size: 13px; line-height: 1.55; }

/* Composer */
.composer-wrap { padding: 8px 16px calc(12px + env(safe-area-inset-bottom)); background: linear-gradient(to top, var(--bg) 70%, transparent); }
.composer-wrap > * { max-width: 760px; margin-left: auto; margin-right: auto; }
.composer {
  display: flex; align-items: flex-end; gap: 6px; border: 1px solid var(--border); background: var(--surface);
  border-radius: var(--radius-lg); padding: 8px; box-shadow: 0 1px 2px rgba(0, 0, 0, .06);
}
.composer:hover { border-color: var(--border-hover); }
.composer:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px var(--ring); }
.composer textarea {
  flex: 1; min-width: 0; resize: none; border: 0; outline: 0; background: none; padding: 8px 6px;
  max-height: 200px; line-height: 1.5;
}
.composer .btn { align-self: flex-end; margin-bottom: 2px; }
.pending { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
.composer-tools { display: flex; gap: 6px; margin-bottom: 6px; }
.tool-select {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 6px; border: 1px solid var(--border);
  border-radius: 9999px; background: var(--bg-soft); color: var(--muted); font-size: 12px;
}
.tool-select .icon { width: 14px; height: 14px; }
.tool-select select {
  border: 0; background: none; color: inherit; font: inherit; padding: 2px 0; max-width: 180px; cursor: pointer;
  appearance: none; -webkit-appearance: none; padding-right: 2px;
}
.tool-select .chevron { width: 12px; height: 12px; opacity: .7; }
.tool-select select:focus-visible { outline: 2px solid var(--ring); border-radius: var(--radius-xs); }
.hint { text-align: center; font-size: 12px; margin: 6px auto 0; }

.toast {
  position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%); background: var(--text); color: var(--bg);
  padding: 10px 14px; border-radius: var(--radius-sm); font-size: 14px; z-index: 50; max-width: calc(100vw - 32px);
}

.theme-toggle { position: fixed; top: 12px; right: 12px; z-index: 60; border: 1px solid var(--border); background: var(--surface); }
.theme-toggle .icon { display: block; margin: auto; }
.theme-toggle .icon-sun { display: none; }
.theme-toggle[data-current="dark"] .icon-sun { display: block; }
.theme-toggle[data-current="dark"] .icon-moon { display: none; }

@media (max-width: 900px) {
  .auth { grid-template-columns: 1fr; }
  .auth-aside { display: none; }
  .auth-panel { padding: 56px 20px 32px; align-items: start; }
}

/* Mobile */
.backdrop { position: fixed; inset: 0; background: rgba(0, 0, 0, .5); z-index: 30; }
@media (max-width: 800px) {
  .sidebar {
    position: fixed; z-index: 40; inset: 0 auto 0 0; width: min(86vw, 320px);
    transform: translateX(-100%); transition: transform .2s ease;
  }
  .app.sidebar-open .sidebar { transform: none; border-right-color: transparent; }
  #menu { display: inline-grid; }
  .chat .topbar { padding: 8px 56px 8px 10px; flex-wrap: nowrap; }
  .topbar h1 { min-width: 0; flex: 1; }
  .topbar-actions { margin-left: auto; flex: none; }
  .topbar-actions .btn span { display: none; }
  .topbar-actions .btn { padding: 6px; min-height: 32px; }
  #app.sidebar-open ~ #theme-toggle, #app.artifact-open ~ #theme-toggle { display: none; }
  .app.artifact-open .artifact-head { padding-right: 12px; }
  .conv-actions { display: flex; }
  .msg.user .bubble { max-width: 92%; }
  .messages { padding: 16px 12px 8px; }
  .empty h2 { font-size: 28px; }
  .suggestions { grid-template-columns: 1fr; margin-top: 20px; }
  .auth-title { font-size: 24px; }
  .composer-wrap { padding-left: 10px; padding-right: 10px; }
  .hint { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

/* SweetAlert2: dialog konfirmasi bergaya takon-takon (mengikuti variabel tema). */
.swal2-container { z-index: 1000; }
.swal2-popup.swal-takon {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: 0 16px 48px rgba(0, 0, 0, .25);
  width: min(440px, calc(100vw - 32px));
  padding: 22px;
  font-family: var(--font-sans);
}
.swal2-popup.swal-takon .swal-takon-title {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
  text-align: left;
}
.swal2-popup.swal-takon .swal-takon-text {
  margin: 10px 0 0;
  font-size: 14px;
  line-height: 1.5;
  color: var(--muted);
  text-align: left;
  white-space: pre-line;
}
.swal2-popup.swal-takon .swal-takon-icon {
  margin: 0 auto 12px;
  border-color: var(--border-hover);
  color: var(--primary);
  font-size: 0;
}
.swal2-popup.swal-takon .swal-takon-icon.swal2-warning { color: var(--danger); border-color: var(--danger); }
.swal2-popup.swal-takon .swal-takon-actions {
  margin: 22px 0 0;
  width: 100%;
  justify-content: flex-end;
  gap: 8px;
}
.swal2-popup.swal-takon .swal-takon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 36px;
  padding: 0 14px;
  margin: 0;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background .15s, border-color .15s;
}
.swal2-popup.swal-takon .swal-takon-btn:hover { background: var(--bg-hover); border-color: var(--border-hover); }
.swal2-popup.swal-takon .swal-takon-btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--ring); }
.swal2-popup.swal-takon .swal-takon-btn-primary {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--on-primary);
}
.swal2-popup.swal-takon .swal-takon-btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.swal2-popup.swal-takon .swal-takon-btn-danger {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
}
.swal2-popup.swal-takon .swal-takon-btn-danger:hover { filter: brightness(.92); }

/* ---------- Fitur chat tambahan ---------- */

.topbar { flex-wrap: wrap; }
.topbar-actions { margin-left: auto; display: flex; gap: 4px; }
.project-badge { font-size: 12px; color: var(--muted); border: 1px solid var(--border); border-radius: var(--radius-xs); padding: 2px 8px; white-space: nowrap; }

.msg-actions, .branch-nav { display: flex; gap: 2px; align-items: center; margin-top: 6px; opacity: 0; transition: opacity .15s; }
.msg:hover .msg-actions, .msg:focus-within .msg-actions, .msg:hover .branch-nav, .msg:focus-within .branch-nav { opacity: 1; }
.msg:last-child .msg-actions { opacity: 1; }
@media (hover: none) { .msg-actions, .branch-nav { opacity: 1; } }
.msg-actions button, .branch-nav button { border: 0; background: none; color: var(--subtle); cursor: pointer; font-size: 12.5px; padding: 5px 8px; border-radius: var(--radius-sm); }
.branch-nav .muted { font-size: 12px; font-variant-numeric: tabular-nums; }
.msg-actions button:hover, .branch-nav button:hover:not(:disabled) { background: var(--bg-hover); color: var(--text); }
.branch-nav button:disabled { opacity: .3; cursor: default; }
.msg.user .msg-actions, .msg.user .branch-nav { justify-content: flex-end; }

.thinking { margin: 0 0 12px; font-size: 13px; color: var(--muted); max-width: 100%; }
.thinking summary {
  display: inline-flex; align-items: center; gap: 6px; cursor: pointer; user-select: none; list-style: none;
  padding: 4px 10px; border: 1px solid var(--border); border-radius: 9999px; background: var(--bg-soft);
  transition: background .15s, border-color .15s;
}
.thinking summary::-webkit-details-marker { display: none; }
.thinking summary:hover { border-color: var(--border-hover); background: var(--bg-hover); }
.thinking summary .icon { width: 14px; height: 14px; color: var(--primary); }
.thinking summary .chev { width: 12px; height: 12px; transition: transform .15s; }
.thinking[open] summary .chev { transform: rotate(180deg); }
.thinking-body { white-space: pre-wrap; overflow-wrap: anywhere; margin-top: 8px; padding: 2px 0 2px 12px; border-left: 2px solid var(--border); }

.edit-box { width: 100%; max-width: 85%; align-self: flex-end; font: inherit; padding: 10px 12px; border-radius: var(--radius-md); border: 1px solid var(--primary); background: var(--bg); color: var(--text); resize: vertical; }
.edit-actions { display: flex; gap: 6px; justify-content: flex-end; margin-top: 6px; }

.think-toggle.on { background: var(--bg-hover); color: var(--primary); outline: 1px solid var(--primary); }
.messages.hide-thinking .thinking { display: none; }

.modal { border: 0; padding: 0; border-radius: var(--radius-md); background: var(--surface); color: var(--text); width: min(560px, calc(100vw - 32px)); max-height: 80vh; }
.modal::backdrop { background: rgba(0, 0, 0, .45); }
.modal-card { display: flex; flex-direction: column; max-height: 80vh; }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.modal-head h2 { margin: 0; font-size: 16px; font-weight: 600; }
.modal-body { padding: 16px; display: flex; flex-direction: column; gap: 12px; overflow-y: auto; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; }
.modal-textarea { width: 100%; font: inherit; padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--bg); color: var(--text); resize: vertical; }
.modal-body input:not([type="file"]) { width: 100%; font: inherit; padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--bg); color: var(--text); }

.search-results, .project-list, .project-files { display: flex; flex-direction: column; gap: 4px; }
.search-row, .project-row > button { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; width: 100%; text-align: left; border: 1px solid var(--border); border-radius: var(--radius-sm); background: none; color: var(--text); padding: 8px 10px; cursor: pointer; font: inherit; }
.search-row:hover, .project-row > button:hover { background: var(--bg-hover); }
.project-row > button { border: 0; }
.project-list .btn { justify-content: flex-start; }

.modal-body label.check { display: flex; flex-direction: row; align-items: center; gap: 8px; font-size: 14px; }
.modal-body label.check input { width: auto; margin: 0; }
.memory-list, .prompt-list { display: flex; flex-direction: column; gap: 4px; max-height: 40vh; overflow-y: auto; }
.memory-row, .prompt-row { display: flex; align-items: center; gap: 8px; border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 6px 8px; }
.memory-text { flex: 1; min-width: 0; font-size: 14px; }
.memory-tag { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); border: 1px solid var(--border); border-radius: 999px; padding: 1px 6px; }
.prompt-row > button.conv-title { flex: 1; min-width: 0; text-align: left; border: 0; background: none; color: var(--text); font: inherit; cursor: pointer; padding: 2px 0; }
.prompt-row > button.conv-title:hover { color: var(--link); }
.task-info { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.day-row { display: flex; flex-wrap: wrap; gap: 8px; }
.day-check { display: inline-flex; align-items: center; gap: 4px; font-size: 0.9rem; }

.code-actions { display: inline-flex; gap: 4px; }
.codeblock .open-artifact { border: 0; background: none; color: var(--code-text); cursor: pointer; padding: 2px 8px; border-radius: var(--radius-xs); font-size: 12px; display: inline-flex; align-items: center; }
.codeblock .open-artifact:hover { background: rgba(255,255,255,.08); }

.artifact { display: flex; flex-direction: column; width: min(48vw, 640px); min-width: 320px; border-left: 1px solid var(--border); background: var(--bg); min-height: 0; }
.artifact[hidden] { display: none; }
.artifact-head { display: flex; align-items: center; gap: 8px; padding: 8px 56px 8px 12px; border-bottom: 1px solid var(--border); font-size: 14px; }
.artifact-head > span { flex: 1; min-width: 0; font-weight: 500; }
.artifact-frame { flex: 1; width: 100%; border: 0; background: #fff; min-height: 0; }
.artifact-edit { resize: none; border: 0; outline: none; width: 100%; }
.artifact-code { flex: 1; margin: 0; padding: 12px; overflow: auto; font-family: var(--font-mono); font-size: 13px; line-height: 1.55; background: var(--code-bg); color: var(--code-text); white-space: pre; }
@media (max-width: 1100px) {
  .app.artifact-open .artifact { position: fixed; inset: 0; width: auto; min-width: 0; z-index: 45; }
}
