/* Kurama AI — tema "Titanium & Obsidian" dengan aksen teal dan violet.
   Tema "Sistem" diterjemahkan ke data-theme oleh app.js dan skrip di <head>. */

/* ───────── Token ───────── */
:root {
  /* Netral hangat satu keluarga + satu aksen oranye (kurama). */
  --bg: #f5f2ee;
  --panel: #ece7e0;
  --surface: #fffefc;
  --text: #1d160f;
  --muted: #6f6357;
  --border: #e0d7cc;
  --border-soft: #e9e2d8;
  --accent: #e8730c;
  --accent-hover: #d2650a;
  --accent-soft: #fbe9d6;
  --accent-text: #1d160f;
  --violet: var(--accent);
  --user-bubble: #ece6dd;
  --danger: #c0392b;
  --code-bg: #2b2219;
  --code-head: #2b2219;
  --code-text: #eee4d8;
  --shadow-sm: 0 1px 2px rgba(17, 21, 26, .06);
  --shadow: 0 4px 16px rgba(17, 21, 26, .08);
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 18px;
  --gutter: 16px;
  --font: "Inter", "Noto Sans Arabic", "Noto Sans SC", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  --sidebar-w: 284px;
  --col: 780px;
}

:root[data-theme="dark"] {
  --bg: #121010;
  --panel: #171413;
  --surface: #1e1a18;
  --text: #f3ede8;
  --muted: #9b9189;
  --border: #2e2824;
  --border-soft: #26211d;
  --accent: #ff9a2e;
  --accent-hover: #ffb35c;
  --accent-soft: #2b1e11;
  --accent-text: #1a0f04;
  --violet: var(--accent);
  --user-bubble: #2a2420;
  --code-bg: #0d0b0a;
  --code-head: #0d0b0a;
  --code-text: #eee4d8;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
  --shadow: 0 6px 20px rgba(0, 0, 0, .45);
}

/* ───────── Transisi tema (gelap ↔ terang) ───────── */
html.theme-anim, html.theme-anim *, html.theme-anim *::before, html.theme-anim *::after {
  transition: background-color .4s ease, border-color .4s ease, color .4s ease, fill .4s ease, stroke .4s ease, box-shadow .4s ease !important;
}
/* Perpindahan tema: lingkaran mengembang dari tombol (diatur di theme.js). */
::view-transition-old(root), ::view-transition-new(root) { animation: none; mix-blend-mode: normal; }
@media (prefers-reduced-motion: reduce) { html.theme-anim *, html.theme-anim *::before, html.theme-anim *::after { transition: none !important; } }

/* ───────── Dasar ───────── */
* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-feature-settings: "cv11", "ss01";
  font-size: 15px;
  line-height: 1.6;
  -webkit-text-size-adjust: 100%;
}
html[data-font="sm"] body { font-size: 14px; }
html[data-font="lg"] body { font-size: 17px; }

button, textarea, select, input { font: inherit; color: inherit; }
button { -webkit-tap-highlight-color: transparent; }
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }
kbd {
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 6px;
  padding: 0 6px;
  font-family: var(--mono);
  font-size: 12px;
  background: var(--panel);
}

.app { display: flex; height: 100vh; height: 100dvh; overflow: hidden; }
.app.collapsed .sidebar { display: none; }
.backdrop { position: fixed; inset: 0; background: rgba(0, 0, 0, .3); z-index: 15; }

/* ───────── Sidebar ───────── */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--panel);
  border-right: 1px solid var(--border-soft);
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px 10px 10px;
  min-height: 0;
}
.side-top { display: flex; align-items: center; justify-content: space-between; padding: 2px 2px 0 6px; }
.brand { display: flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; padding: 4px 0; }
.brand img { width: 30px; height: 30px; filter: drop-shadow(0 4px 10px color-mix(in srgb, var(--accent) 35%, transparent)); }
.brand-text { display: flex; align-items: baseline; gap: 5px; font-weight: 700; font-size: 16px; letter-spacing: -.015em; }
.brand-text small { font-size: 10.5px; font-weight: 700; letter-spacing: .16em; text-transform: uppercase; color: var(--accent); }
.icon-btn.close-side { display: none; }

.side-actions { display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 10px;
  border: 0;
  border-radius: 10px;
  background: none;
  color: var(--text);
  font-size: 14.5px;
  font-weight: 500;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
  transition: background-color .15s ease;
}
.nav-item svg { width: 18px; height: 18px; color: var(--muted); }
.nav-item span { flex: 1; min-width: 0; }
.nav-item kbd { font-size: 10.5px; color: var(--muted); background: none; border-color: transparent; padding: 0; font-family: var(--mono); }
.nav-item:hover { background: var(--border-soft); }
.nav-item.accent {
  font-weight: 600;
  background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 16%, transparent), color-mix(in srgb, var(--violet) 14%, transparent));
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 30%, transparent);
}
.nav-item.accent svg { color: var(--accent); }
.nav-item.accent:hover { box-shadow: inset 0 0 0 1px var(--accent); }

.ws { position: relative; }
.ws-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  font-size: 13.5px;
  text-align: left;
  cursor: pointer;
  transition: border-color .15s ease;
}
.ws-btn:hover { border-color: color-mix(in srgb, var(--accent) 50%, var(--border)); }
.ws-btn #wsName { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ws-caret svg { width: 14px; height: 14px; color: var(--muted); }
.ws-menu { top: calc(100% + 6px); bottom: auto; }

.search-wrap { position: relative; display: flex; align-items: center; }
.search-wrap > svg { position: absolute; left: 10px; width: 15px; height: 15px; color: var(--muted); pointer-events: none; }
.search {
  width: 100%;
  padding: 8px 10px 8px 32px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  font-size: 13.5px;
}
.search::placeholder { color: var(--muted); }
.search:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 14%, transparent); }

.section-head { display: flex; align-items: center; justify-content: space-between; padding: 4px 8px 0; }
.section-head.riwayat { margin-top: 2px; }
.section-label { font-size: 10.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .12em; font-weight: 650; }
.mini-btn {
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 7px;
  background: none;
  color: var(--muted);
  cursor: pointer;
}
.mini-btn svg { width: 15px; height: 15px; }
.mini-btn:hover { background: var(--border-soft); color: var(--text); }

.projectlist, .chatlist { list-style: none; margin: 0; padding: 0; }
.projectlist { display: flex; flex-direction: column; gap: 1px; max-height: 24vh; overflow-y: auto; }
.projectlist li { display: flex; }
.projectlist button {
  flex: 1;
  min-width: 0;
  padding: 7px 10px;
  border: 0;
  border-radius: 9px;
  background: none;
  text-align: left;
  font-size: 13.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
}
.projectlist button:hover { background: var(--border-soft); }
.projectlist button.active { background: var(--surface); box-shadow: var(--shadow-sm), inset 2px 0 0 var(--violet); font-weight: 600; }
.projectlist li.empty, .chatlist li.empty { color: var(--muted); font-size: 12.5px; padding: 10px; }

.chatlist { overflow-y: auto; flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 1px; padding-right: 2px; }
.chatlist .group-label, .chatlist li.group-label { font-size: 10.5px; color: var(--muted); padding: 12px 10px 4px; font-weight: 650; letter-spacing: .1em; text-transform: uppercase; background: none; }
.chatlist li {
  display: flex;
  align-items: center;
  border-radius: 10px;
  padding: 0 4px 0 12px;
  transition: background-color .15s ease, box-shadow .15s ease;
}
.chatlist li:hover { background: var(--border-soft); }
.chatlist li.active { background: var(--surface); box-shadow: var(--shadow-sm), inset 2px 0 0 var(--accent); }
.chatlist .pick {
  flex: 1;
  min-width: 0;
  padding: 8px 0;
  border: 0;
  background: none;
  text-align: left;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
}
.act {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border: 0;
  border-radius: 7px;
  background: none;
  color: var(--muted);
  cursor: pointer;
  opacity: 0;
  transition: opacity .15s ease, background-color .15s ease;
}
.act svg { width: 14px; height: 14px; }
.act:hover { background: var(--border); color: var(--text); }
.chatlist li:hover .act, .chatlist li.active .act, .projectlist li:hover .act, .act:focus-visible, .act.on { opacity: 1; }
.act.on { color: var(--accent); }

/* Footer sidebar: kuota, status, profil */
.side-foot { position: relative; border-top: 1px solid var(--border-soft); padding-top: 10px; display: flex; flex-direction: column; gap: 8px; }
.quota-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px 12px;
  border: 1px solid var(--border-soft);
  border-radius: 12px;
  background: var(--surface);
  font-size: 11.5px;
  color: var(--muted);
}
.quota-row { display: flex; justify-content: space-between; font-variant-numeric: tabular-nums; }
.quota-bar { height: 4px; border-radius: 99px; background: var(--border); overflow: hidden; }
.quota-bar i { display: block; height: 100%; width: 0; border-radius: inherit; background: var(--accent); transition: width .3s ease; }
.status-line { display: flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--muted); padding: 0 6px; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); flex-shrink: 0; }
.dot.ok { background: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); }
.dot.bad { background: var(--danger); }

.profile {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 7px 8px;
  border: 0;
  border-radius: 12px;
  background: none;
  text-align: left;
  cursor: pointer;
}
.profile:hover { background: var(--border-soft); }
.profile-text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.profile-name { font-weight: 600; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.profile-sub { font-size: 11.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.profile-chevron svg { width: 14px; height: 14px; color: var(--muted); }
.avatar-initial {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-text);
  display: grid;
  place-items: center;
  font-weight: 700;
  flex-shrink: 0;
  overflow: hidden;
}
.avatar-img { width: 34px; height: 34px; border-radius: 50%; object-fit: cover; }
.avatar-initial.avatar-img { padding: 0; }

.profile-menu {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(100% + 8px);
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 24px 48px -16px rgba(0, 0, 0, .35);
  z-index: 30;
  animation: pop .16s ease both;
}
@keyframes pop { from { opacity: 0; transform: translateY(6px) scale(.98); } to { opacity: 1; transform: none; } }
.menu-label { font-size: 10.5px; color: var(--muted); padding: 6px 8px 4px; font-weight: 650; text-transform: uppercase; letter-spacing: .1em; }
.segmented {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 2px;
  padding: 3px;
  background: var(--panel);
  border-radius: 12px;
  margin-bottom: 4px;
}
.segmented button {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 8px 4px;
  border: 0;
  border-radius: 9px;
  background: none;
  color: var(--muted);
  font-size: 12px;
  cursor: pointer;
}
.segmented button svg { width: 16px; height: 16px; }
.segmented button:hover { color: var(--text); }
.segmented button[aria-checked="true"] { background: var(--surface); color: var(--text); font-weight: 600; box-shadow: var(--shadow-sm); }
.menu-sep { height: 1px; background: var(--border-soft); margin: 6px 4px; }
.menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border: 0;
  border-radius: 10px;
  background: none;
  color: var(--text);
  font-size: 13.5px;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}
.menu-item svg { width: 16px; height: 16px; color: var(--muted); flex-shrink: 0; }
.menu-item span { flex: 1; min-width: 0; }
.menu-item kbd { font-family: var(--mono); font-size: 10.5px; color: var(--muted); background: none; border-color: transparent; padding: 0; }
.menu-item:hover { background: var(--border-soft); }
.menu-item.on { background: var(--accent-soft); font-weight: 600; }
.auth-menu { display: flex; flex-direction: column; gap: 2px; padding-bottom: 2px; }
.auth-menu:not(:empty) { margin-bottom: 2px; }
.auth-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border: 0;
  border-radius: 10px;
  background: none;
  color: var(--text);
  font-size: 13.5px;
  text-decoration: none;
  cursor: pointer;
}
.auth-btn svg { width: 16px; height: 16px; color: var(--muted); }
.auth-btn:hover { background: var(--border-soft); }
.auth-row { display: flex; flex-wrap: wrap; gap: 8px; }
.account-card { display: flex; flex-direction: column; gap: 10px; }

/* ───────── Area utama ───────── */
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; min-height: 0; position: relative; }
.topbar {
  position: sticky;
  top: 0;
  z-index: 4;
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 56px;
  padding: 8px var(--gutter);
  padding-top: max(8px, env(safe-area-inset-top));
  border-bottom: 1px solid var(--border-soft);
  background: color-mix(in srgb, var(--bg) 80%, transparent);
  backdrop-filter: blur(14px) saturate(1.3);
}
.title-wrap { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; }
.topbar h1 {
  margin: 0;
  font-size: 14.5px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
.project-tag { font-size: 11.5px; background: var(--accent-soft); color: var(--text); border-radius: 999px; padding: 2px 10px; white-space: nowrap; }
.top-actions { display: flex; gap: 2px; }
.icon-btn {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: none;
  color: var(--muted);
  cursor: pointer;
  flex-shrink: 0;
  transition: background-color .15s ease, color .15s ease, border-color .15s ease;
}
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn:hover:not(:disabled) { background: var(--border-soft); color: var(--text); }
.icon-btn:disabled { opacity: .4; cursor: default; }
.menu { display: none; }

.chat-area { flex: 1; overflow-y: auto; min-height: 0; scroll-behavior: smooth; }

/* Sambutan */
.welcome {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 72px var(--gutter) 24px;
  gap: 8px;
  max-width: var(--col);
  margin: 0 auto;
}
.welcome h2 { margin: 0; font-size: 30px; font-weight: 650; letter-spacing: -.02em; }
.welcome p { margin: 0; color: var(--muted); font-size: 16px; }
.suggestions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-top: 24px;
  max-width: 640px;
}
.suggestions button {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 999px;
  padding: 7px 14px;
  cursor: pointer;
  font-size: 14px;
  box-shadow: var(--shadow-sm);
  transition: border-color .15s ease, background-color .15s ease;
}
.suggestions button:hover { border-color: var(--accent); background: var(--accent-soft); }

/* Pesan */
.messages { max-width: var(--col); margin: 0 auto; padding: 8px var(--gutter) 32px; }
.row { display: flex; gap: 12px; margin: 22px 0; }
.row.user { justify-content: flex-end; }
.row.assistant { justify-content: flex-start; align-items: flex-start; }
.avatar { width: 28px; height: 28px; flex-shrink: 0; margin-top: 2px; }
.avatar img { width: 28px; height: 28px; }
.bubble { min-width: 0; max-width: 100%; overflow-wrap: anywhere; }
.row.user .bubble { max-width: 82%; display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.row.assistant .bubble { flex: 1; padding-top: 2px; }
.utext {
  background: var(--user-bubble);
  padding: 10px 14px;
  border-radius: 18px 18px 4px 18px;
  white-space: pre-wrap;
  line-height: 1.55;
}
.bubble > :first-child { margin-top: 0; }
.bubble > :last-child { margin-bottom: 0; }
.bubble p { margin: 0 0 .85em; }
.bubble ul, .bubble ol { padding-left: 1.4em; margin: 0 0 .85em; }
.bubble li { margin: .2em 0; }
.bubble h1, .bubble h2, .bubble h3 { line-height: 1.3; margin: 1.2em 0 .5em; font-weight: 650; }
.bubble h1 { font-size: 1.35em; }
.bubble h2 { font-size: 1.2em; }
.bubble h3 { font-size: 1.08em; }
.bubble table { border-collapse: collapse; display: block; overflow-x: auto; max-width: 100%; margin: .6em 0 1em; font-size: 14px; }
.bubble th, .bubble td { border: 1px solid var(--border); padding: 6px 10px; text-align: left; }
.bubble th { background: var(--surface); font-weight: 600; }
.bubble a { color: var(--accent-hover); text-underline-offset: 2px; }
.bubble :not(pre) > code {
  background: var(--border-soft);
  border: 1px solid var(--border);
  padding: 1px 5px;
  border-radius: 6px;
  font-size: .9em;
  font-family: var(--mono);
}
.bubble blockquote { margin: .6em 0; padding: 2px 12px; border-left: 3px solid var(--accent); color: var(--muted); }
.bubble hr { border: 0; border-top: 1px solid var(--border); margin: 1.2em 0; }
.msg-images { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; margin-bottom: 4px; }
.msg-images img { max-width: 220px; max-height: 180px; border-radius: var(--radius); border: 1px solid var(--border); }
.msg-files { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; margin-bottom: 4px; }
.msg-files span { font-size: 12px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 3px 8px; color: var(--muted); }

.codeblock {
  margin: 12px 0;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--code-bg);
  border: 1px solid color-mix(in srgb, var(--border) 60%, transparent);
}
.codehead {
  border-bottom: 1px solid color-mix(in srgb, var(--text) 8%, transparent);
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 8px 6px 12px;
  color: #aab3bf;
  font-size: 12px;
  background: var(--code-head);
  gap: 8px;
}
.codehead .lang { font-family: var(--mono); text-transform: lowercase; }
.codehead .actions { display: flex; gap: 4px; }
.codehead button {
  border: 0;
  background: none;
  color: #aab3bf;
  cursor: pointer;
  font-size: 12px;
  padding: 3px 8px;
  border-radius: 6px;
}
.codehead button:hover { background: rgba(255, 255, 255, .08); color: #f4ede6; }
.codeblock pre { margin: 0; padding: 12px 14px; overflow-x: auto; }
.codeblock code { font-family: var(--mono); font-size: 13px; line-height: 1.55; }
pre {
  background: var(--code-bg);
  color: var(--code-text);
  border-radius: var(--radius);
  padding: 14px 16px;
  overflow-x: auto;
  font-size: 13.5px;
  margin: 0;
}

.msg-actions { display: flex; margin-top: 4px; }
.msg-actions button {
  border: 0;
  background: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 12px;
  padding: 4px 8px;
  border-radius: 8px;
}
.msg-actions button:hover { background: var(--border-soft); color: var(--text); }

.user-actions { display: flex; gap: 4px; justify-content: flex-end; opacity: 1; }
.user-actions button {
  border: 0;
  background: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 12px;
  padding: 3px 8px;
  border-radius: 8px;
}
.user-actions button:hover { background: var(--border-soft); color: var(--text); }
@media (hover: none) { .user-actions { opacity: 1; } }

.dots::after { content: "●●●"; letter-spacing: 4px; color: var(--muted); animation: blink 1.2s infinite; font-size: 10px; }
@keyframes blink { 0%, 100% { opacity: .2; } 50% { opacity: 1; } }

/* ───────── Composer ───────── */
.composer-wrap { padding: 6px var(--gutter) 12px; padding-bottom: max(12px, env(safe-area-inset-bottom)); }
.controls { max-width: var(--col); margin: 0 auto 8px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 12.5px; color: var(--muted); }
.seg {
  display: inline-flex;
  padding: 3px;
  gap: 2px;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: 999px;
}
.seg button {
  padding: 4px 12px;
  border: 0;
  border-radius: 999px;
  background: none;
  color: var(--muted);
  font-size: 12.5px;
  cursor: pointer;
  transition: background-color .15s ease, color .15s ease;
}
.seg button:hover { color: var(--text); }
.seg button.on { background: var(--accent-soft); color: var(--text); font-weight: 600; box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 35%, transparent); }
.engine-wrap { position: relative; }
.engine-card {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 0;
  width: 290px;
  display: none;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
  font-size: 13px;
  color: var(--text);
  z-index: 10;
}
.engine-wrap:hover .engine-card, .engine-wrap:focus-within .engine-card { display: block; }
.engine-card b { display: block; margin-bottom: 2px; }
.engine-card p { margin: 0 0 8px; color: var(--muted); }
.engine-card p:last-child { margin: 0; }

.attachments { max-width: var(--col); margin: 0 auto 8px; display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: flex; align-items: center; gap: 8px; max-width: 260px; padding: 4px 6px 4px 4px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; font-size: 13px; }
.chip img { width: 40px; height: 40px; object-fit: cover; border-radius: 7px; }
.chip span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chip button { display: grid; place-items: center; width: 24px; height: 24px; border: 0; border-radius: 6px; background: none; color: var(--muted); cursor: pointer; }
.chip button svg { width: 14px; height: 14px; }
.chip button:hover { color: var(--danger); background: var(--border-soft); }
.chip.uploading { opacity: .85; }
.chip-meta { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.chip-meta b { font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 170px; }
.chip-meta small { font-size: 11.5px; color: var(--muted); }
.spin { width: 16px; height: 16px; margin: 0 6px; flex-shrink: 0; border: 2px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.composer {
  max-width: var(--col);
  margin: 0 auto;
  display: flex;
  align-items: flex-end;
  gap: 2px;
  padding: 6px 6px 6px 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 22px;
  box-shadow: var(--shadow);
  transition: border-color .15s ease, box-shadow .2s ease;
}
.composer:focus-within { border-color: color-mix(in srgb, var(--accent) 55%, var(--border)); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 12%, transparent), var(--shadow); }
.composer.dragging { border-color: var(--accent); background: var(--accent-soft); }
.composer textarea {
  flex: 1;
  min-width: 0;
  padding: 9px 6px;
  border: 0;
  outline: 0;
  resize: none;
  background: transparent;
  font-size: 15px;
  line-height: 1.5;
  max-height: 200px;
}
.composer textarea::placeholder { color: var(--muted); }
.composer .icon-btn { width: 34px; height: 34px; border-radius: 11px; }
.mic { display: grid; place-items: center; }
.mic.listening { background: var(--accent); color: var(--accent-text); animation: pulse 1.2s infinite; }
.mic:disabled { opacity: .4; cursor: not-allowed; }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(232, 115, 12, .5); }
  70% { box-shadow: 0 0 0 10px rgba(232, 115, 12, 0); }
  100% { box-shadow: 0 0 0 0 rgba(232, 115, 12, 0); }
}
.send {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  margin-left: 2px;
  border: 0;
  border-radius: 12px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  flex-shrink: 0;
  transition: transform .12s ease, filter .15s ease;
}
.send svg { width: 18px; height: 18px; stroke-width: 2.2; }
.send:hover:not(:disabled) { filter: brightness(1.08); }
.send:active:not(:disabled) { transform: scale(.94); }
.send:disabled { background: var(--border); color: var(--muted); cursor: default; filter: none; }
.send[data-mode="stop"] { background: var(--text); color: var(--bg); }
.send[data-mode="stop"] svg { display: none; }
.send[data-mode="stop"]::before { content: ""; width: 10px; height: 10px; border-radius: 2px; background: currentColor; }

.listening {
  max-width: var(--col);
  margin: 0 auto 8px;
  display: flex;
  align-items: center;
  gap: 10px;
  width: fit-content;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 13px;
}
.wave { display: inline-flex; gap: 3px; align-items: center; height: 14px; }
.wave i { width: 3px; height: 100%; background: var(--accent); border-radius: 2px; animation: wave 1s ease-in-out infinite; }
.wave i:nth-child(2) { animation-delay: .15s; }
.wave i:nth-child(3) { animation-delay: .3s; }
@keyframes wave { 0%, 100% { transform: scaleY(.35); } 50% { transform: scaleY(1); } }

.composer-foot {
  max-width: var(--col);
  margin: 8px auto 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 14px;
  font-size: 12px;
  color: var(--muted);
}
.foot-left { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.link-btn { display: inline-flex; align-items: center; gap: 5px; padding: 2px 6px; margin-left: -6px; border: 0; border-radius: 6px; background: none; color: var(--accent-hover); font-size: 12px; cursor: pointer; }
.link-btn svg { width: 13px; height: 13px; }
.link-btn:hover { background: var(--border-soft); }

.ctx { display: flex; align-items: center; gap: 8px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.ctx-bar { width: 72px; height: 4px; border-radius: 99px; background: var(--border); overflow: hidden; }
.ctx-bar i { display: block; height: 100%; width: 0; border-radius: inherit; background: var(--accent); transition: width .2s; }
.ctx.warn .ctx-bar i { background: var(--danger); }
.ctx.warn #ctxText { color: var(--danger); }

/* ───────── Panel artifact ───────── */
.artifact {
  width: min(46vw, 620px);
  min-width: 360px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  border-left: 1px solid var(--border);
  background: var(--surface);
  min-height: 0;
}
.artifact-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  min-height: 56px;
  border-bottom: 1px solid var(--border-soft);
}
.tabs { display: flex; background: var(--panel); border-radius: 10px; padding: 3px; gap: 2px; }
.tabs button { border: 0; background: none; border-radius: 8px; padding: 4px 12px; cursor: pointer; font-size: 13px; color: var(--muted); }
.tabs button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); font-weight: 600; }
.artifact-name { flex: 1; min-width: 0; font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.artifact-frame { flex: 1; border: 0; width: 100%; background: #fff; min-height: 0; }
.artifact-code { flex: 1; margin: 0; padding: 14px; overflow: auto; background: var(--code-bg); color: var(--code-text); font-size: 13px; min-height: 0; }
.artifact-code code { font-family: var(--mono); }
.artifact-editor {
  flex: 1;
  margin: 0;
  padding: 14px;
  border: 0;
  outline: none;
  resize: none;
  background: var(--code-bg);
  color: var(--code-text);
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.5;
  min-height: 0;
}

/* ───────── Kontrol form (select, toggle) ───────── */
select {
  appearance: none;
  -webkit-appearance: none;
  background-color: var(--surface);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238b95a3' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 9px center;
  background-size: 14px;
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 7px 30px 7px 10px;
  font-size: 13.5px;
  cursor: pointer;
  transition: border-color .15s ease;
}
select:hover { border-color: color-mix(in srgb, var(--accent) 50%, var(--border)); }
select:focus-visible { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 16%, transparent); }

input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  position: relative;
  width: 38px;
  height: 22px;
  margin: 0;
  flex-shrink: 0;
  border-radius: 99px;
  background: var(--border);
  cursor: pointer;
  transition: background-color .2s ease;
}
input[type="checkbox"]::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .25);
  transition: transform .2s ease;
}
input[type="checkbox"]:checked { background: var(--accent); }
input[type="checkbox"]:checked::after { transform: translateX(16px); }
input[type="checkbox"]:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ───────── Dialog & pengaturan ───────── */
.dialog {
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 0;
  background: var(--surface);
  color: var(--text);
  width: min(540px, calc(100vw - 32px));
  max-height: calc(100dvh - 32px);
  box-shadow: 0 24px 60px -12px rgba(0, 0, 0, .35);
}
.dialog::backdrop { background: rgba(8, 10, 14, .45); backdrop-filter: blur(4px); }
.dialog-box { padding: 22px 24px 20px; display: flex; flex-direction: column; gap: 2px; margin: 0; }
.dialog-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.dialog-head h2 { font-size: 18px; margin: 0; font-weight: 650; letter-spacing: -.01em; }
.dialog-narrow { width: min(420px, calc(100vw - 32px)); }
.dialog-wide { width: min(600px, calc(100vw - 32px)); }
.confirm-title { font-size: 18px; margin: 4px 0 6px; }
.confirm-text { margin: 0 0 8px; color: var(--muted); }
.set-head {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--muted);
  margin: 20px 0 0;
  padding-bottom: 6px;
  font-weight: 650;
}
.setting {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 13px 0;
  border-top: 1px solid var(--border-soft);
}
.setting-title { font-weight: 600; font-size: 14.5px; }
.setting-desc { font-size: 13px; color: var(--muted); line-height: 1.5; }
.setting-note { font-size: 12.5px; color: var(--danger); padding: 4px 0 8px; }
.text-input {
  border: 1px solid var(--border);
  background: var(--panel);
  border-radius: 9px;
  padding: 7px 10px;
  width: 200px;
  flex-shrink: 0;
  font-size: 13.5px;
}
.text-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 16%, transparent); }
.account-box { border-top: 1px solid var(--border-soft); padding: 12px 0 4px; }
.account-card { display: flex; flex-direction: column; gap: 10px; }
.account-line b { display: block; }
.account-line span, .account-note { font-size: 13px; color: var(--muted); margin: 0; }
.danger {
  border: 1px solid color-mix(in srgb, var(--danger) 60%, transparent);
  background: none;
  color: var(--danger);
  border-radius: 9px;
  padding: 7px 14px;
  cursor: pointer;
  flex-shrink: 0;
  font-size: 13.5px;
}
.danger:hover { background: color-mix(in srgb, var(--danger) 10%, transparent); }
.danger-solid { background: var(--danger) !important; border-color: var(--danger) !important; color: #fff !important; }
.btn {
  padding: 8px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  font-size: 13.5px;
  flex-shrink: 0;
  box-shadow: var(--shadow-sm);
  transition: border-color .15s ease, background-color .15s ease;
}
.btn:hover:not(:disabled) { border-color: var(--accent); }
.btn.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); font-weight: 600; }
.btn.primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 60%, transparent); }
.btn:disabled { opacity: .5; cursor: default; }
.field { display: flex; flex-direction: column; gap: 6px; padding: 14px 0; border-top: 1px solid var(--border-soft); }
.field textarea {
  border: 1px solid var(--border);
  background: var(--panel);
  border-radius: 10px;
  padding: 9px 11px;
  resize: vertical;
  font-size: 14px;
  line-height: 1.5;
}
.field textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 16%, transparent); }
.dialog-actions { display: flex; align-items: center; gap: 8px; padding-top: 16px; border-top: 1px solid var(--border-soft); margin-top: 10px; flex-wrap: wrap; }
.spacer { flex: 1; }
.ghost-btn, .primary-btn { border-radius: 10px; padding: 8px 16px; cursor: pointer; border: 1px solid var(--border); background: none; font-size: 13.5px; }
.ghost-btn:hover { background: var(--border-soft); }
.primary-btn { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 600; }
.primary-btn:hover { background: var(--accent-hover); }
.dialog-foot { font-size: 12px; color: var(--muted); border-top: 1px solid var(--border-soft); padding-top: 12px; margin-top: 8px; }
.shortcuts { width: 100%; border-collapse: collapse; font-size: 14px; }
.shortcuts td { border-top: 1px solid var(--border-soft); padding: 10px 4px; vertical-align: middle; }
.shortcuts td:last-child { color: var(--muted); text-align: right; }

/* Panel artifact: aksi sebagai tombol ringan */
.artifact-head .link-btn { padding: 6px 10px; border-radius: 8px; color: var(--muted); font-size: 13px; }
.artifact-head .link-btn:hover { background: var(--border-soft); color: var(--text); text-decoration: none; }
.artifact-name { font-family: var(--mono); font-size: 12.5px; }

/* ───────── Command palette (Ctrl/⌘ + K) ───────── */
.palette-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(8, 10, 14, .4);
  backdrop-filter: blur(4px);
  z-index: 50;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 12vh;
}
.palette {
  width: min(580px, calc(100vw - 24px));
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: 0 24px 60px -12px rgba(0, 0, 0, .35);
  overflow: hidden;
}
.palette input {
  width: 100%;
  border: 0;
  border-bottom: 1px solid var(--border-soft);
  background: transparent;
  padding: 16px 18px;
  font-size: 15px;
  outline: none;
}
.palette input::placeholder { color: var(--muted); }
.palette ul { list-style: none; margin: 0; padding: 6px; max-height: 50vh; overflow-y: auto; }
.palette li button {
  width: 100%;
  text-align: left;
  border: 0;
  background: none;
  padding: 10px 12px;
  border-radius: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 14px;
}
.palette li button.sel, .palette li button:hover { background: var(--accent-soft); }
.palette .kind {
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
  background: var(--panel);
  border-radius: 999px;
  padding: 2px 8px;
}
.palette .empty { padding: 14px; color: var(--muted); font-size: 13px; }

/* ───────── Toast ───────── */
.toasts {
  position: fixed;
  left: 50%;
  bottom: 110px;
  transform: translateX(-50%);
  z-index: 80;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  pointer-events: none;
  width: min(480px, calc(100vw - 32px));
}
.toast {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--muted);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 10px 14px;
  font-size: 13.5px;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity .2s ease, transform .2s ease;
  pointer-events: auto;
  max-width: 100%;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { border-left-color: var(--danger); }
.toast.success { border-left-color: var(--accent); }

/* ───────── Halaman Codex ───────── */
.codex {
  display: grid;
  grid-template-columns: 280px 1fr;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  background: var(--bg);
}
.codex-side {
  border-right: 1px solid var(--border);
  background: var(--panel);
  padding: 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
  min-height: 0;
}
.codex-side .brand { padding: 4px 6px 2px; }
.codex-side .btn.primary { width: 100%; padding: 9px 12px; font-size: 14px; }
.codex-side .codex-note { padding: 0 6px; }
.codex-main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.codex-top {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 20px;
  min-height: 56px;
  border-bottom: 1px solid var(--border-soft);
  flex-wrap: wrap;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(8px);
}
.codex-top h1 { font-size: 15px; font-weight: 650; margin: 0; flex: 1; }
.codex-top .codex-note { white-space: nowrap; }
.codex-task {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-soft);
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.codex-task textarea {
  width: 100%;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 14px;
  padding: 12px 14px;
  font-size: 15px;
  line-height: 1.5;
  resize: vertical;
  min-height: 84px;
  box-shadow: var(--shadow-sm);
}
.codex-task textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 16%, transparent); }
.codex-task .row2 { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 13px; color: var(--muted); }
.codex-task label { display: inline-flex; align-items: center; gap: 8px; }
.codex-task select { width: auto; }
.codex-side select { width: 100%; }
.run-item {
  width: 100%;
  text-align: left;
  border: 0;
  background: none;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.run-item:hover { background: var(--border-soft); }
.run-item.on { background: var(--surface); box-shadow: var(--shadow-sm), inset 2px 0 0 var(--accent); }
.run-item small { display: block; color: var(--muted); font-size: 11.5px; }
.fleet { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 10px; padding: 14px 20px 0; }
.fleet:empty { display: none; }
.agent-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px 14px;
  font-size: 13px;
  box-shadow: var(--shadow-sm);
}
.agent-card .st { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; font-weight: 600; }
.agent-card .nm { font-weight: 600; margin-top: 2px; }
.timeline { flex: 1; overflow-y: auto; padding: 14px 20px; min-height: 0; }
.timeline:empty::before {
  content: "Belum ada log. Tulis tugas di atas lalu tekan Jalankan.";
  display: block;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
  padding: 48px 16px;
  border: 1px dashed var(--border);
  border-radius: 16px;
}
.ev {
  padding: 10px 12px;
  border-radius: 12px;
  margin-bottom: 8px;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  font-size: 13.5px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  box-shadow: var(--shadow-sm);
}
.ev .tag {
  font-size: 10.5px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-right: 8px;
  font-weight: 650;
}
.ev.tool, .ev.result { font-family: var(--mono); font-size: 12.5px; }
.ev.error { border-color: color-mix(in srgb, var(--danger) 60%, transparent); }
.ev.file { border-color: color-mix(in srgb, var(--accent) 60%, transparent); }
.ctrl {
  display: flex;
  gap: 8px;
  padding: 12px 20px;
  border-top: 1px solid var(--border-soft);
  flex-wrap: wrap;
  background: var(--surface);
}
.toggle { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.codex-note { font-size: 12px; color: var(--muted); margin: 0; line-height: 1.5; }

/* ───────── Responsif (ponsel) ───────── */
@media (max-width: 760px) {
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 20;
    width: min(300px, 84vw);
    transform: translateX(-100%);
    transition: transform .22s ease;
    padding-top: max(14px, env(safe-area-inset-top));
  }
  .sidebar.open { transform: translateX(0); box-shadow: 0 0 30px rgba(0, 0, 0, .2); }
  .app.collapsed .sidebar { display: flex; }
  .icon-btn.close-side { display: grid; }
  .menu { display: grid; }
  .welcome { padding-top: 40px; }
  .welcome h2 { font-size: 24px; }
  .row.user .bubble { max-width: 90%; }
  .row { gap: 10px; }
  .composer { border-radius: 18px; }
  .icon-btn { width: 40px; height: 40px; }
  .send { width: 38px; height: 38px; }
  .artifact {
    position: fixed;
    inset: 0;
    z-index: 25;
    width: 100%;
    min-width: 0;
    border-left: 0;
  }
  .dialog { width: calc(100vw - 32px); }
  .setting { flex-wrap: wrap; }
  .text-input { width: 100%; }
  .codex { grid-template-columns: 1fr; height: auto; min-height: 100dvh; overflow: visible; }
  .codex-top .codex-note { display: none; }
  .codex-side { border-right: 0; border-bottom: 1px solid var(--border); max-height: 40vh; }
  .codex-main { min-height: 70vh; }
}

/* ───────── Gerak yang lebih halus ───────── */
.messages .row { animation: rise .25s ease both; }
@keyframes rise { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) {
  .messages .row, .spin, .wave i, .mic.listening, .dots::after { animation: none; }
  .toast, .chatlist li, .composer, .quota-bar i { transition: none; }
  .chat-area { scroll-behavior: auto; }
}

/* ───────── Scrollbar, gulir, dan detail sentuh ───────── */
* { scrollbar-width: thin; scrollbar-color: color-mix(in srgb, var(--muted) 40%, transparent) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: color-mix(in srgb, var(--muted) 35%, transparent); border-radius: 99px; border: 3px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background-color: color-mix(in srgb, var(--muted) 60%, transparent); }
.sidebar, .chat-area, .chatlist, .projectlist, .timeline, .codex-side, .palette ul { overscroll-behavior: contain; }
.sidebar, .codex-side { scrollbar-gutter: stable; }
a, button, [role="radio"], select, summary { -webkit-tap-highlight-color: transparent; }
@media (pointer: coarse) {
  .seg button, .segmented button, .menu-item, .chatlist .pick, .projectlist button { min-height: 36px; }
  .chatlist li { padding-right: 6px; }
  .act { opacity: 1; padding: 6px 7px; }
}

/* Tombol ke pesan terbaru */
.jump-btn {
  position: absolute;
  left: 50%;
  bottom: 168px;
  transform: translateX(-50%);
  z-index: 5;
  width: 38px;
  height: 38px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
  display: grid;
  place-items: center;
  cursor: pointer;
  animation: rise .2s ease both;
  transition: border-color .15s ease, color .15s ease;
}
.jump-btn:hover { border-color: var(--accent); color: var(--accent); }
.jump-btn svg { width: 18px; height: 18px; }

/* Maskot Kurama di layar sambutan */
.welcome .mascot { width: 72px; height: 72px; margin-bottom: 6px; animation: float 4.5s ease-in-out infinite; filter: drop-shadow(0 10px 18px color-mix(in srgb, var(--accent) 35%, transparent)); }
@keyframes float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }

/* Tabel tetap utuh; kolom tidak dipecah per huruf */
.bubble table { display: block; width: max-content; max-width: 100%; }
.bubble th, .bubble td { white-space: nowrap; vertical-align: top; }
.bubble td:nth-child(n+2), .bubble th:nth-child(n+2) { font-variant-numeric: tabular-nums; }

/* Layar sangat kecil (≤ 380px): composer tetap lega */
@media (max-width: 380px) {
  .composer-wrap { padding-inline: 10px; }
  .composer { gap: 2px; padding: 5px 5px 5px 6px; }
  .composer .icon-btn { width: 32px; height: 32px; }
  #enhanceBtn { display: none; }
  .send { width: 34px; height: 34px; }
  .controls { gap: 6px; }
  .welcome h2 { font-size: 22px; }
  .topbar h1 { font-size: 14px; }
  .top-actions .icon-btn { width: 34px; }
}
@media (max-width: 760px) {
  .sidebar { box-shadow: none; }
  .sidebar.open { box-shadow: 16px 0 40px -12px rgba(0, 0, 0, .35); }
  .jump-btn { bottom: 150px; }
}
@media (prefers-reduced-motion: reduce) {
  .welcome .mascot, .jump-btn { animation: none; }
}

/* Codex: ikon dan tombol utama */
.codex .btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; }
.codex .btn svg { width: 15px; height: 15px; }
.codex .btn.primary { background: var(--accent); border-color: transparent; color: var(--accent-text); }
.codex .btn.primary:hover:not(:disabled) { filter: brightness(1.06); }
.codex-side .brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.codex-side .brand-text b { font-size: 15px; font-weight: 700; }
.codex-side .brand-text small { font-size: 10.5px; letter-spacing: .14em; text-transform: uppercase; color: var(--accent); font-weight: 700; }
.codex-side .brand { padding: 4px 4px 2px; }

/* ───────── Edit pesan di tempat ───────── */
.edit-box {
  width: min(100%, 560px);
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px;
  border-radius: 16px;
  background: var(--surface);
  border: 1.5px solid var(--accent);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 14%, transparent);
}
.edit-box textarea {
  width: 100%;
  min-height: 44px;
  padding: 6px 8px;
  border: 0;
  outline: 0;
  resize: none;
  background: transparent;
  font-size: 15px;
  line-height: 1.55;
}
.edit-bar { display: flex; align-items: center; gap: 8px; justify-content: flex-end; flex-wrap: wrap; border-top: 1px solid var(--border-soft); padding-top: 8px; }
.edit-hint { margin-right: auto; font-size: 12px; color: var(--muted); }
.ghost-btn.sm, .primary-btn.sm { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; font-size: 13px; border-radius: 9px; }
.primary-btn.sm svg { width: 14px; height: 14px; }
.user-actions[hidden] { display: none; }

/* Link "Lihat semua" di header Riwayat */
.section-head .see-all {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  font-size: 12px;
  color: var(--muted);
  text-decoration: none;
  padding: 2px 6px;
  border-radius: 7px;
}
.section-head .see-all svg { width: 13px; height: 13px; transform: rotate(-90deg); }
.section-head .see-all:hover { color: var(--accent); background: var(--border-soft); }

/* Tombol tema (matahari / bulan) di semua halaman */
#themeToggle svg, [data-theme-toggle] svg { width: 18px; height: 18px; fill: none; stroke: currentColor; }
#themeToggle .i-sun, [data-theme-toggle] .i-sun { display: none; }
#themeToggle .i-moon, [data-theme-toggle] .i-moon { display: block; }
:root[data-theme="dark"] #themeToggle .i-sun, :root[data-theme="dark"] [data-theme-toggle] .i-sun { display: block; }
:root[data-theme="dark"] #themeToggle .i-moon, :root[data-theme="dark"] [data-theme-toggle] .i-moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) #themeToggle .i-sun, :root:not([data-theme="light"]) [data-theme-toggle] .i-sun { display: block; }
  :root:not([data-theme="light"]) #themeToggle .i-moon, :root:not([data-theme="light"]) [data-theme-toggle] .i-moon { display: none; }
}

/* Ikon lebih jelas dan seragam */
svg { stroke-width: 1.9; }
.icon-btn svg { width: 20px; height: 20px; }
.nav-item svg { width: 18px; height: 18px; }
.act svg { width: 15px; height: 15px; }
.mini-btn svg { width: 16px; height: 16px; }
.chip button svg { width: 15px; height: 15px; }
.menu-item svg, .auth-btn svg { width: 17px; height: 17px; }
.segmented button svg { width: 17px; height: 17px; }
.ws-caret svg { width: 15px; height: 15px; }
.search-wrap > svg { width: 16px; height: 16px; }

/* ───────── Menu baris chat (titik tiga) ───────── */
.chatlist li { position: relative; }
.chatlist .act.more { opacity: 1; width: 28px; height: 28px; color: var(--muted); }
.chatlist li:not(:hover):not(.active) .act.more { opacity: 0; }
.chatlist li:hover .act.more, .chatlist li.active .act.more { opacity: 1; }
@media (hover: none) { .chatlist .act.more { opacity: 1; } }
.act.more svg { width: 16px; height: 16px; }
.row-menu {
  position: absolute;
  right: 6px;
  top: calc(100% - 2px);
  z-index: 40;
  min-width: 190px;
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 18px 40px -14px rgba(0, 0, 0, .35);
  animation: pop .14s ease both;
}
.row-menu button {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border: 0;
  border-radius: 9px;
  background: none;
  color: var(--text);
  font-size: 13.5px;
  text-align: left;
  cursor: pointer;
}
.row-menu button svg { width: 16px; height: 16px; color: var(--muted); }
.row-menu button:hover, .row-menu button:focus-visible { background: var(--border-soft); outline: none; }
.row-menu button.danger { color: var(--danger); }
.row-menu button.danger svg { color: var(--danger); }

/* Pemisah dan urutan ikon topbar */
.top-sep { width: 1px; height: 20px; margin: 0 6px; background: var(--border); align-self: center; }

/* Tombol tema di landing: pojok kanan, terpisah dari tautan */
.nav-links .theme-fab { margin-left: 6px; }

.row-menu.up { top: auto; bottom: calc(100% - 2px); }

/* ───────── Bahasa: pemilih, dan tata letak RTL (Arab) ───────── */
.lang-select {
  height: 36px;
  padding: 0 28px 0 10px;
  border-radius: 10px;
  font-size: 13px;
  max-width: 150px;
}
.codex-top .lang-select, .hist-top .lang-select { margin-inline-start: auto; }
html[dir="rtl"] .sidebar { border-right: 0; border-left: 1px solid var(--border-soft); }
html[dir="rtl"] .icon-btn svg, html[dir="rtl"] .nav-item svg { transform: none; }
html[dir="rtl"] .row-menu { right: auto; left: 6px; }
html[dir="rtl"] .composer textarea, html[dir="rtl"] .edit-box textarea { text-align: start; }
html[dir="rtl"] .back svg { transform: rotate(-90deg); }
html[dir="rtl"] .section-head .see-all svg { transform: rotate(90deg); }
@media (max-width: 760px) {
  html[dir="rtl"] .sidebar { transform: translateX(100%); }
  html[dir="rtl"] .sidebar.open { transform: translateX(0); }
  html[dir="rtl"] .sidebar.open { box-shadow: -16px 0 40px -12px rgba(0, 0, 0, .35); }
}
@media (max-width: 420px) {
  .codex-top .lang-select, .hist-top .lang-select { max-width: 112px; }
  .codex-top h1 { min-width: 0; }
}
@media (max-width: 420px) {
  .codex-task select, .codex-task label { max-width: 100%; min-width: 0; }
  .codex-task .row2 { gap: 8px; }
}

.text-input-wide { width: 100%; margin: 6px 0 2px; padding: 9px 12px; font-size: 15px; }
.user-actions button { display: inline-flex; align-items: center; gap: 5px; padding: 4px 9px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); font-size: 12px; color: var(--muted); }
.user-actions button svg { width: 13px; height: 13px; }
.user-actions button:hover { color: var(--text); border-color: var(--accent); }

/* ───────── Sidebar gaya baru: navigasi ikon, lipatan, mode samaran, bantuan ───────── */
.side-collapse { width: 32px; height: 32px; }
.side-top .brand { flex: 1; }
.side-actions .nav-item kbd { margin-inline-start: auto; }
.nav-item[id="openSearch"] { color: var(--text); }
.group-label { padding: 0; background: none; }
.group-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 14px 10px 6px;
  border: 0;
  background: none;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
  cursor: pointer;
  text-align: start;
}
.group-toggle svg { width: 12px; height: 12px; transition: transform .18s ease; }
.group-toggle[aria-expanded="false"] svg { transform: rotate(-90deg); }
.group-toggle span { flex: 1; }
.group-toggle em { font-style: normal; font-size: 11px; color: var(--muted); opacity: .8; }
.group-toggle:hover { color: var(--text); }

.incog {
  max-width: 640px;
  margin: 14px auto 0;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 14px;
  border: 1px dashed color-mix(in srgb, var(--accent) 55%, var(--border));
  border-radius: 14px;
  background: var(--accent-soft);
  font-size: 13.5px;
  color: var(--text);
}
.incog svg { width: 22px; height: 22px; flex-shrink: 0; color: var(--accent); }
.incog b { display: block; font-size: 14px; margin-bottom: 2px; }
.incog span { color: var(--muted); line-height: 1.5; }

  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border: 0;
  border-radius: 9px;
  background: none;
  color: var(--text);
  font-size: 13.5px;
  text-decoration: none;
  text-align: start;
  cursor: pointer;
}
.help-pop span { flex: 1; }
.help-pop a:hover, .help-pop button:hover { background: var(--border-soft); }

/* ───────── Sidebar: seluruh panel bisa digulir, bantuan di dalam sidebar ───────── */
.sidebar { overflow-y: auto; overflow-x: hidden; overscroll-behavior: contain; scrollbar-gutter: stable; }
.sidebar > * { flex-shrink: 0; }
.chatlist { flex: none; overflow: visible; min-height: auto; }
.projectlist { max-height: none; }
.side-foot { margin-top: auto; position: sticky; bottom: 0; background: var(--panel); padding-bottom: 4px; }
@media (max-width: 760px) {
  .sidebar { padding-bottom: max(14px, env(safe-area-inset-bottom)); }
}
/* Tombol buka sidebar selalu tersedia saat sidebar disembunyikan (desktop) */
.app.collapsed .menu { display: grid; }
.nav-item .nav-caret { width: 12px; height: 12px; margin-inline-start: 2px; transition: transform .18s ease; color: var(--muted); }
#helpBtn[aria-expanded="true"] .nav-caret { transform: rotate(180deg); }
.help-inline { display: flex; flex-direction: column; gap: 2px; margin: 0 0 2px 10px; padding-inline-start: 10px; border-inline-start: 1px solid var(--border-soft); }
.help-inline a, .help-inline button {
  display: flex; align-items: center; gap: 10px; padding: 7px 8px; border: 0; border-radius: 9px;
  background: none; color: var(--text); font-size: 13.5px; text-decoration: none; text-align: start; cursor: pointer;
}
.help-inline svg { width: 15px; height: 15px; color: var(--muted); }
.help-inline span { flex: 1; }
.help-inline kbd { font-family: var(--mono); font-size: 10.5px; }
.help-inline a:hover, .help-inline button:hover { background: var(--border-soft); }

/* ───────── Tata letak chat v3: sidebar navigasi, kontrol di dalam composer ───────── */
.side-nav { display: flex; flex-direction: column; gap: 2px; }
.side-sec { display: flex; flex-direction: column; gap: 2px; }
.side-sec.grow { margin-top: 6px; }
.side-sec .section-head { padding: 8px 10px 4px; }
.side-sec .section-head.riwayat { padding-top: 10px; }


/* Composer: textarea di atas, kontrol mode di baris bawah dalam kotak */
.composer { flex-direction: column; align-items: stretch; gap: 0; padding: 10px 10px 8px 14px; border-radius: 22px; }
.composer textarea { width: 100%; padding: 6px 2px 8px; min-height: 28px; }
.composer-bar { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 2px; }
.cb-left, .cb-right { display: flex; align-items: center; gap: 6px; min-width: 0; }
.cb-left { flex-wrap: wrap; }
.cb-left .icon-btn { width: 32px; height: 32px; }
.cb-left .engine-wrap .seg, .cb-left > .seg { padding: 2px; }
.cb-right .icon-btn { width: 32px; height: 32px; }
.controls { display: none; }
.composer .engine-card { bottom: calc(100% + 10px); left: 0; }

/* Mode samaran: jendela terpisah, isi di tengah seperti referensi */
.incog-link { color: var(--accent); text-decoration: none; font-weight: 600; margin-top: 4px; }
.incog-link:hover { text-decoration: underline; }
.incognito-window .sidebar, .incognito-window .menu, .incognito-window #exportBtn { display: none !important; }
.incognito-window .topbar { justify-content: center; }
.incognito-window .title-wrap { flex: none; }
.incognito-window #welcome { display: none !important; }
.incognito-window .chat-area { display: flex; flex-direction: column; justify-content: center; }
.incognito-window .incog {
  margin: 0 auto;
  max-width: 520px;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 0 var(--gutter);
  border: 0;
  background: none;
  gap: 10px;
}
.incognito-window .incog svg { width: 56px; height: 56px; color: var(--muted); }
.incognito-window .incog b { font-size: 22px; font-weight: 650; }
.incognito-window .incog span { font-size: 14.5px; }

/* Submenu profil: panel melayang ke samping (posisi tetap, tidak terpotong sidebar) */
.pm-sub { position: relative; }
.pm-trigger svg:last-child { width: 13px; height: 13px; margin-inline-start: auto; transform: rotate(-90deg); color: var(--muted); }
.pm-trigger[aria-expanded="true"] { background: var(--border-soft); }
.pm-fly {
  position: fixed;
  z-index: 80;
  width: 232px;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 22px 48px -16px rgba(0, 0, 0, .4);
  animation: pop .14s ease both;
}
.pm-fly .segmented { margin: 0; }
.pm-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 1px; max-height: 60vh; overflow-y: auto; }
.pm-list .menu-item[aria-selected="true"] { color: var(--accent); font-weight: 600; }
.pm-list .menu-item span { flex: 1; }
.pm-fly .menu-item { padding-inline-start: 10px; }

/* Riwayat run Codex: ubah judul dan hapus (seperti riwayat chat) */
.run-row { position: relative; display: flex; align-items: center; border-radius: 10px; }
.run-row.on { background: var(--surface); box-shadow: var(--shadow-sm), inset 2px 0 0 var(--accent); }
.run-row:hover { background: var(--border-soft); }
.run-row .run-item { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.run-acts { display: flex; gap: 2px; padding-inline-end: 4px; opacity: 0; transition: opacity .15s ease; }
.run-row:hover .run-acts, .run-row.on .run-acts { opacity: 1; }
@media (hover: none) { .run-acts { opacity: 1; } }
.run-act { display: grid; place-items: center; width: 26px; height: 26px; border: 0; border-radius: 7px; background: none; color: var(--muted); cursor: pointer; }
.run-act svg { width: 14px; height: 14px; }
.run-act:hover { background: var(--border); color: var(--text); }
.run-act.danger:hover { color: var(--danger); }
.danger-solid { background: var(--danger) !important; border-color: var(--danger) !important; color: #fff !important; }

/* Polish v4: ritme sidebar dan composer dibuat lebih lapang, mengikuti referensi Claude */
.status-line { display: none; }
.side-foot .quota-card { padding: 8px 12px; }
.profile-sub { font-size: 12px; }
.composer { max-width: 720px; border-radius: 22px; }
.welcome h2 { font-size: 32px; font-weight: 600; }
.chatlist li { min-height: 36px; }
.projectlist button { font-size: 14px; }
@media (max-width: 760px) {
  .sidebar { width: min(300px, 86vw); }
  .composer-bar { flex-wrap: wrap; }
  .cb-left { flex-wrap: wrap; gap: 4px; }
}
@media (max-width: 760px) {
  .side-collapse { display: none; }
}

/* Sidebar: bagian daftar digulir sendiri; footer profil menempel di bawah */
.sidebar { overflow: hidden; }
.sidebar > .side-top, .sidebar > .side-foot { flex-shrink: 0; }
.side-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; overflow-x: hidden; display: flex; flex-direction: column; gap: 10px; overscroll-behavior: contain; scrollbar-gutter: stable; padding-bottom: 8px; }
.side-body > * { flex-shrink: 0; }
.side-body > .side-sec.grow { flex-shrink: 0; }
.side-foot { position: relative; margin: 0 -12px; padding: 10px 12px 12px; border-top: 1px solid var(--border-soft); background: var(--panel); }
.sidebar { padding-bottom: 0; }
.sidebar .side-foot { padding-bottom: max(12px, env(safe-area-inset-bottom)); }

/* Teks antarmuka tidak bisa diseleksi; jawaban dan input tetap bisa */
body { user-select: none; -webkit-user-select: none; }
.bubble, .bubble *, .messages, .messages *, .codeblock pre, .codeblock code, .artifact-code, .artifact-code *, textarea, input, [contenteditable="true"] { user-select: text; -webkit-user-select: text; }

/* Gambar dan logo tidak bisa ditarik */
img, svg { -webkit-user-drag: none; user-drag: none; -webkit-user-select: none; user-select: none; }

/* Maskot ikut menoleh ke kursor (mascot.js) */
img[src$="/static/kurama.png"] { display: inline-block; }

/* Maskot SVG: ekor bergoyang, kedip, dan ukuran mengikuti tempat tampil */
.kmascot { display: inline-block; vertical-align: middle; flex-shrink: 0; }
.kmascot svg { width: 100
/* Maskot SVG: ekor bergoyang, kedip, dan ukuran mengikuti tempat tampil */
.kmascot { display: inline-block; vertical-align: middle; flex-shrink: 0; }
.kmascot svg { width: 100%; height: 100%; display: block; overflow: visible; }
.kmascot .km-tail { transform-box: fill-box; transform-origin: 50% 100%; animation: km-sway 3.6s ease-in-out infinite; animation-delay: var(--d, 0s); }
@keyframes km-sway { 0%, 100% { transform: rotate(-4deg); } 50% { transform: rotate(5deg); } }
.kmascot .km-lid { transform: scaleY(0); transition: transform .06s ease-in; }
.kmascot.km-blink .km-lid { transform: scaleY(1); }
.kmascot .km-pupil { transition: transform .08s linear; }
.kmascot .km-head { transition: transform .15s ease-out; }