/* ============================================================
   MyAI v3.0 — Tema ala Kimi
   Bersih, terang, minimal: sidebar abu muda, area chat putih,
   composer kartu membulat, gelembung pengguna abu lembut.
   ============================================================ */

:root {
  --bg: #ffffff;
  --sidebar: #f7f8fa;
  --panel: #ffffff;
  --panel-2: #f2f4f7;
  --panel-3: #e9ecf1;
  --border: #e6e9ee;
  --border-strong: #d4d9e0;
  --text: #1f2329;
  --muted: #8a919e;
  --accent: #4d6bfe;
  --accent-2: #3b5bfd;
  --accent-soft: rgba(77, 107, 254, .1);
  --danger: #e5484d;
  --shadow-menu: 0 12px 40px rgba(15, 23, 42, .12), 0 2px 8px rgba(15, 23, 42, .06);
  --shadow-composer: 0 6px 28px rgba(15, 23, 42, .07), 0 1px 4px rgba(15, 23, 42, .04);
  --radius: 12px;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
}

:root[data-theme="dark"] {
  --bg: #131417;
  --sidebar: #17181c;
  --panel: #1c1d22;
  --panel-2: #23242b;
  --panel-3: #2b2d34;
  --border: #2c2e36;
  --border-strong: #3a3d47;
  --text: #e9ebef;
  --muted: #9299a5;
  --accent: #7a92ff;
  --accent-2: #93a7ff;
  --accent-soft: rgba(122, 146, 255, .16);
  --danger: #ff6b6f;
  --shadow-menu: 0 12px 40px rgba(0, 0, 0, .5), 0 2px 8px rgba(0, 0, 0, .35);
  --shadow-composer: 0 6px 28px rgba(0, 0, 0, .35), 0 1px 4px rgba(0, 0, 0, .25);
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.65 var(--font);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); }
.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 13px; }
button { font-family: inherit; }

::selection { background: var(--accent-soft); }
* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
*::-webkit-scrollbar { width: 6px; height: 6px; }
*::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 3px; }
*::-webkit-scrollbar-track { background: transparent; }

.app { display: flex; height: 100vh; height: 100dvh; }

/* ---------------- Sidebar ---------------- */
.sidebar {
  width: 264px; flex-shrink: 0;
  background: var(--sidebar);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  padding: 14px 12px; gap: 10px;
  overflow: hidden;
  transition: width .18s ease, padding .18s ease;
}
.app.sidebar-collapsed .sidebar { width: 0; padding-left: 0; padding-right: 0; border-right: 0; }
.brand { display: flex; align-items: center; gap: 10px; padding: 2px 6px 6px; }
.brand-logo { width: 30px; height: 30px; border-radius: 9px; }
.brand-name { font-weight: 700; font-size: 17px; letter-spacing: -.01em; color: var(--text); }
.version-badge {
  font-size: 10px; font-weight: 600; color: var(--muted);
  border: 1px solid var(--border); border-radius: 999px; padding: 1px 7px;
}
.sidebar-actions { display: grid; gap: 2px; }
.sidebar-action {
  display: flex; align-items: center; gap: 11px; min-height: 38px; width: 100%;
  border: 1px solid transparent; border-radius: 10px; background: transparent;
  color: var(--text); padding: 7px 10px; text-align: left; font: inherit; font-size: 13.5px; cursor: pointer;
  transition: background .12s;
}
.sidebar-action:hover { background: var(--panel-2); }
.sidebar-action.primary {
  background: var(--panel); border-color: var(--border); font-weight: 600;
  border-radius: 999px; box-shadow: 0 1px 3px rgba(15, 23, 42, .05);
}
.sidebar-action.primary:hover { border-color: var(--border-strong); }
.sidebar-icon { width: 20px; flex: 0 0 20px; color: var(--muted); text-align: center; font-size: 16px; line-height: 1; }
.sidebar-action.primary .sidebar-icon { color: var(--accent); }
.recent-heading { padding: 10px 10px 4px; color: var(--muted); font-size: 11px; font-weight: 650; letter-spacing: .04em; }
.folder-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 10px 4px; color: var(--muted); font-size: 11px; font-weight: 650; letter-spacing: .04em;
}
.folder-toolbar button, .chat-folder-remove {
  display: grid; place-items: center; width: 24px; height: 24px; padding: 0;
  border: 0; border-radius: 7px; background: transparent; color: var(--muted);
  font: inherit; font-size: 17px; cursor: pointer;
}
.folder-toolbar button:hover, .chat-folder-remove:hover { background: var(--panel-2); color: var(--text); }
.chat-search {
  width: 100%; padding: 8px 12px; border: 1px solid var(--border); border-radius: 999px;
  background: var(--panel); color: var(--text); font: inherit; font-size: 12.5px; outline: none;
}
.chat-search:focus { border-color: var(--border-strong); }
.chat-list { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 1px; margin: 0 -4px; padding: 0 4px; }
.chat-section { display: flex; flex-direction: column; gap: 1px; }
.chat-section-heading { display: flex; align-items: center; justify-content: space-between; min-height: 29px; padding: 2px 8px 2px 10px; }
.chat-section-toggle {
  min-width: 0; overflow: hidden; border: 0; background: transparent; color: var(--muted);
  font: inherit; font-size: 11.5px; font-weight: 600; text-align: left; text-overflow: ellipsis;
  white-space: nowrap; cursor: pointer;
}
.chat-section-toggle:hover { color: var(--text); }
.chat-section-content { display: flex; flex-direction: column; gap: 1px; }
.chat-item {
  position: relative;
  display: flex; align-items: center; gap: 6px;
  padding: 8px 10px; border-radius: 10px; cursor: pointer; color: var(--muted);
  transition: background .12s;
}
.chat-item:hover { background: var(--panel-2); color: var(--text); }
.chat-item.active { background: var(--panel-3); color: var(--text); }
.chat-item .title { flex: 1; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: 13.5px; }
.chat-item .del { opacity: 0; background: none; border: 0; color: var(--muted); cursor: pointer; font-size: 13px; padding: 2px 4px; border-radius: 6px; }
.chat-item .chat-folder-action { opacity: 0; background: none; border: 0; color: var(--muted); cursor: pointer; font-size: 12px; padding: 3px 4px; border-radius: 6px; }
.chat-item:hover .del, .chat-item:hover .chat-folder-action, .chat-item:focus-within .del, .chat-item:focus-within .chat-folder-action { opacity: 1; }
.chat-item .del:hover { color: var(--danger); background: var(--panel); }
.chat-item .chat-folder-action:hover { color: var(--accent); background: var(--panel); }
.chat-folder-menu {
  position: absolute; top: calc(100% - 2px); right: 24px; z-index: 45;
  display: flex; flex-direction: column; min-width: 150px; max-width: 220px; max-height: 220px; overflow: auto;
  padding: 4px; border: 1px solid var(--border); border-radius: 10px; background: var(--panel);
  box-shadow: var(--shadow-menu);
}
.chat-folder-menu button {
  overflow: hidden; padding: 7px 9px; border: 0; border-radius: 6px; background: transparent;
  color: var(--text); font: inherit; font-size: 12px; text-align: left; text-overflow: ellipsis;
  white-space: nowrap; cursor: pointer;
}
.chat-folder-menu button:hover { background: var(--panel-2); }
.chat-folder-empty { padding: 7px 9px; color: var(--muted); font-size: 11px; }
.sidebar-footer { display: flex; flex-direction: column; gap: 6px; border-top: 1px solid var(--border); padding-top: 10px; }
.sidebar-settings {
  display: flex; align-items: center; gap: 9px; width: 100%; min-height: 34px; padding: 6px 10px;
  border: 0; border-radius: 10px; background: transparent; color: var(--muted);
  text-align: left; font: inherit; font-size: 12.5px; cursor: pointer;
}
.sidebar-settings:hover { background: var(--panel-2); color: var(--text); }
.account { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); padding: 0 4px; }
.account img { width: 28px; height: 28px; border-radius: 50%; }
.account .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); }

/* ---------------- Tombol umum ---------------- */
.btn {
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  padding: 9px 16px;
  border-radius: 999px;
  cursor: pointer;
  font: inherit; font-size: 14px; font-weight: 550;
  transition: border-color .12s, background .12s;
}
.btn:hover { border-color: var(--border-strong); background: var(--panel-2); }
.btn.primary { background: var(--text); border-color: var(--text); color: var(--bg); }
.btn.primary:hover { background: var(--text); opacity: .88; }
.btn.ghost { background: transparent; }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.block { width: 100%; }
.btn.small { padding: 5px 12px; font-size: 12px; }
.icon-btn {
  display: inline-grid; place-items: center; flex: 0 0 36px; width: 36px; height: 36px;
  border: 0; border-radius: 10px; background: transparent; color: var(--muted);
  font-size: 17px; cursor: pointer; transition: background .12s;
}
.icon-btn:hover { background: var(--panel-2); color: var(--text); }
.hamburger-lines { display: grid; gap: 4px; width: 16px; }
.hamburger-lines i { display: block; width: 16px; height: 1.8px; border-radius: 2px; background: currentColor; }

/* ---------------- Area utama ---------------- */
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--bg); }
.topbar { display: flex; align-items: center; gap: 10px; padding: 10px 14px; }
.app-theme { margin-left: auto; }
.theme-toggle {
  border: 0; background: transparent; color: var(--muted);
  border-radius: 10px; width: 36px; height: 36px; padding: 0; cursor: pointer; font-size: 16px;
  display: inline-grid; place-items: center; transition: background .12s;
}
.theme-toggle:hover { background: var(--panel-2); color: var(--text); }

/* Kolom chat: pesan memenuhi ruang kosong, lalu composer dan hint di bawah. */
.chat-wrap { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.chat-wrap.empty { justify-content: flex-start; overflow: hidden; }
.chat-wrap.empty .messages {
  display: flex; flex: 1 1 auto; align-items: center; justify-content: center;
  overflow: hidden; padding-top: 12px; padding-bottom: 12px;
}

.messages { flex: 1; min-height: 0; overflow-y: auto; padding: 20px 24px 28px; }

/* ---------------- Pesan ---------------- */
.msg { max-width: 768px; margin: 0 auto 26px; display: flex; flex-direction: column; }
.msg .label { display: flex; align-items: center; gap: 8px; font-size: 12.5px; font-weight: 600; color: var(--muted); margin-bottom: 8px; }
.msg.user { align-items: flex-end; }
.msg.user .body {
  background: var(--panel-2);
  padding: 10px 16px;
  border-radius: 20px 20px 6px 20px;
  white-space: pre-wrap;
  word-wrap: break-word;
  max-width: min(85%, 640px);
  font-size: 15px;
}
.msg.assistant { padding: 0 2px; }
.msg.assistant .body { word-wrap: break-word; min-width: 0; font-size: 15px; }
.msg.error .body { border-left: 3px solid var(--danger); padding-left: 14px; }
.body p:first-child { margin-top: 0; }
.body p:last-child { margin-bottom: 0; }
.body pre { position: relative; background: #101218; border: 1px solid var(--border); border-radius: 12px; padding: 0; overflow: hidden; margin: 12px 0; }
.body pre code { display: block; padding: 14px 16px; overflow-x: auto; font-size: 13px; background: transparent !important; color: #e6e9ef; }
.body code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.body :not(pre) > code { background: var(--panel-2); padding: 2px 6px; border-radius: 6px; font-size: 13px; }
.body table { border-collapse: collapse; display: block; overflow-x: auto; margin: 12px 0; }
.body th, .body td { border: 1px solid var(--border); padding: 7px 12px; }
.body th { background: var(--panel-2); }
.body blockquote { border-left: 3px solid var(--border-strong); margin: 10px 0; padding-left: 14px; color: var(--muted); }
.body img { max-width: 100%; }
.copy-btn {
  position: absolute; top: 8px; right: 8px;
  background: rgba(255, 255, 255, .08); color: #b7bdc9; backdrop-filter: blur(4px);
  border: 1px solid rgba(255, 255, 255, .12); border-radius: 8px;
  font-size: 11px; padding: 4px 10px; cursor: pointer;
}
.copy-btn:hover { color: #fff; background: rgba(255, 255, 255, .16); }
details.think {
  background: var(--panel-2); border: 0; border-radius: 12px;
  padding: 10px 14px; margin-bottom: 14px; color: var(--muted); font-size: 13px;
}
details.think summary { cursor: pointer; font-weight: 600; }

/* Kursor mengetik */
.typing::after { content: "▍"; animation: blink 1s steps(1) infinite; color: var(--accent); }
@keyframes blink { 50% { opacity: 0; } }

/* ---------------- Loading ala Kimi: teks shimmer ---------------- */
.ai-thinking {
  display: inline-flex; align-items: center; gap: 10px; min-height: 32px;
  font-size: 14px; font-weight: 550;
}
.ai-thinking .ai-thinking-star {
  width: 18px; height: 18px; flex: 0 0 18px; color: var(--accent);
  animation: ai-star-spin 2.4s linear infinite;
}
.ai-thinking-text {
  background: linear-gradient(90deg, var(--muted) 0%, var(--muted) 35%, var(--text) 50%, var(--muted) 65%, var(--muted) 100%);
  background-size: 220% 100%;
  -webkit-background-clip: text; background-clip: text; color: transparent;
  animation: ai-shimmer 1.6s linear infinite;
}
@keyframes ai-shimmer { 0% { background-position: 130% 0; } 100% { background-position: -90% 0; } }
@keyframes ai-star-spin { to { transform: rotate(360deg); } }

.ai-thinking-dots { display: inline-flex; align-items: center; gap: 4px; height: 16px; }
.ai-thinking-dots i { display: block; width: 5px; height: 5px; border-radius: 50%; background: var(--muted); animation: ai-dot-bounce 1.1s infinite ease-in-out; }
.ai-thinking-dots i:nth-child(2) { animation-delay: .14s; }
.ai-thinking-dots i:nth-child(3) { animation-delay: .28s; }
@keyframes ai-dot-bounce { 0%, 60%, 100% { opacity: .35; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-4px); } }

.ai-spinner { display: inline-block; width: 14px; height: 14px; flex: 0 0 14px; border: 2px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: ai-spin .75s linear infinite; }
@keyframes ai-spin { to { transform: rotate(360deg); } }

/* ---------------- Layar sambutan (empty state) ---------------- */
.welcome { max-width: 720px; margin: 0 auto; text-align: center; padding: 0 8px; }
.welcome-logo {
  width: 52px; height: 52px; border-radius: 15px; margin: 0 auto 14px; display: block;
  box-shadow: 0 8px 24px rgba(77, 107, 254, .18);
}
.welcome h1 { font-size: clamp(22px, 4vw, 28px); font-weight: 700; letter-spacing: -.03em; margin: 0 0 5px; }
.welcome .brand-name { font-size: inherit; font-weight: inherit; }
.welcome .muted { font-size: 13.5px; margin: 0; }
.brand-strip { display: flex; justify-content: center; flex-wrap: wrap; gap: 8px; margin-top: 15px; opacity: .9; }
.brand-strip .mlogo { background: var(--panel-2); }

/* ---------------- Composer (kartu prompt ala Kimi) ---------------- */
.composer {
  position: relative; display: block; flex: 0 0 auto;
  width: min(768px, calc(100% - 32px)); margin: 10px auto 0; padding: 12px 14px 10px;
  border: 1px solid var(--border); border-radius: 24px; background: var(--panel);
  box-shadow: var(--shadow-composer);
  transition: border-color .15s;
}
.composer:focus-within { border-color: var(--border-strong); }
.composer textarea {
  display: block; width: 100%; min-height: 30px; max-height: 200px; resize: none;
  border: 0; outline: none; background: transparent; color: var(--text);
  padding: 4px 6px 10px; font: inherit; font-size: 15px;
}
.composer textarea::placeholder { color: var(--muted); }
.composer-bar { display: flex; align-items: center; gap: 6px; min-width: 0; }
.composer-spacer { flex: 1; min-width: 4px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; }

.attach-btn {
  flex: 0 0 34px; width: 34px; height: 34px; border-radius: 50%;
  border: 1px solid var(--border); background: var(--panel); color: var(--muted);
  font-size: 20px; line-height: 1; cursor: pointer; display: grid; place-items: center;
  transition: background .12s, color .12s, border-color .12s;
}
.attach-btn:hover { background: var(--panel-2); color: var(--text); border-color: var(--border-strong); }
#attachBtn:disabled { opacity: .45; cursor: progress; }

.attach-menu {
  position: absolute; left: 10px; bottom: calc(100% + 10px); z-index: 60;
  width: min(220px, calc(100vw - 24px)); max-height: min(40dvh, 240px); overflow-y: auto;
  padding: 5px; background: var(--panel); border: 1px solid var(--border);
  border-radius: 13px; box-shadow: var(--shadow-menu);
}
.attach-menu button {
  display: flex; align-items: center; gap: 10px; width: 100%; min-height: 38px; text-align: left;
  padding: 7px 9px; border: 0; border-radius: 9px; color: var(--text);
  background: transparent; cursor: pointer; font: inherit; font-size: 13px;
}
.attach-menu button:hover { background: var(--panel-2); }
.attach-icon { width: 20px; flex: 0 0 20px; color: var(--accent); font-size: 16px; text-align: center; }

/* Pemilih mode tugas */
.task-mode-picker { position: relative; flex: 0 0 auto; }
.task-mode-btn {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  height: 34px; padding: 0 11px;
  border: 0; border-radius: 999px; background: transparent;
  color: var(--muted); font: inherit; font-size: 12.5px; font-weight: 550; cursor: pointer;
  transition: background .12s, color .12s;
}
.task-mode-btn:hover, .task-mode-btn[aria-expanded="true"] { background: var(--panel-2); color: var(--text); }
.task-mode-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
#taskModeIcon { color: var(--accent); font-size: 13px; }
.task-mode-chevron, .model-btn .chev {
  display: inline-block; flex: 0 0 6px; width: 6px; height: 6px;
  border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor;
  color: var(--muted); transform: rotate(45deg); margin: -3px 2px 0 1px;
  transition: transform .15s, margin .15s;
}
.task-mode-btn[aria-expanded="true"] .task-mode-chevron,
.model-btn[aria-expanded="true"] .chev { transform: rotate(225deg); margin-top: 3px; }
.task-mode-menu {
  position: absolute; left: 0; bottom: calc(100% + 10px); z-index: 70;
  display: grid; gap: 1px; width: min(176px, calc(100vw - 24px)); max-height: min(48dvh, 320px); overflow-y: auto; padding: 5px;
  border: 1px solid var(--border); border-radius: 12px;
  background: var(--panel); box-shadow: var(--shadow-menu);
}
.task-mode-menu button {
  display: flex; align-items: center; gap: 10px; min-height: 35px; padding: 6px 9px;
  border: 0; border-radius: 9px; background: transparent; color: var(--text);
  text-align: left; font: inherit; font-size: 13px; cursor: pointer;
}
.task-mode-menu button:hover { background: var(--panel-2); }
.task-mode-menu button[aria-checked="true"] { background: var(--accent-soft); }
.task-mode-menu button > span { width: 20px; color: var(--accent); text-align: center; }
.task-mode-menu button b { font-weight: 600; }

/* Pemilih model */
.model-picker { position: relative; min-width: 0; flex: 0 1 auto; max-width: min(260px, 34vw); }
.model-btn {
  display: flex; align-items: center; gap: 7px; max-width: 100%; min-width: 0;
  background: transparent; color: var(--text);
  border: 0; border-radius: 999px;
  padding: 4px 10px 4px 5px; cursor: pointer; font: inherit; text-align: left;
  transition: background .12s;
}
.model-btn:hover, .model-btn[aria-expanded="true"] { background: var(--panel-2); }
.model-btn-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
#modelBtnName { font-size: 12.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chev { color: var(--muted); font-size: 11px; }
.model-menu {
  position: absolute; top: auto; bottom: calc(100% + 10px); left: auto; right: 0; z-index: 40;
  width: min(300px, calc(100vw - 32px)); max-height: min(38dvh, 300px);
  display: flex; flex-direction: column;
  background: var(--panel); border: 1px solid var(--border); border-radius: 16px;
  box-shadow: var(--shadow-menu); overflow: hidden;
}
#modelSearch {
  flex: 0 0 auto; margin: 8px; padding: 7px 12px; border-radius: 999px;
  background: var(--panel-2); color: var(--text); border: 1px solid transparent; font: inherit; font-size: 12.5px; outline: none;
}
#modelSearch:focus { border-color: var(--accent); background: var(--panel); }
.model-list { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 0 5px 6px; }
.model-refresh {
  flex: 0 0 auto; margin: 0 8px 8px; padding: 6px 9px;
  border: 1px solid var(--border); border-radius: 999px; background: var(--panel);
  color: var(--muted); font: inherit; font-size: 11.5px; cursor: pointer;
}
.model-refresh:hover { border-color: var(--accent); color: var(--accent); }
.model-refresh:disabled { cursor: progress; opacity: .7; }
.model-group-head {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  width: 100%; min-height: 35px; margin: 1px 0; padding: 5px 8px;
  border: 0; border-radius: 10px; background: transparent;
  color: var(--text); font: inherit; font-size: 12.5px; text-align: left; cursor: pointer;
}
.model-group-head:hover { background: var(--panel-2); }
.model-group-title { display: flex; align-items: center; gap: 10px; min-width: 0; }
.model-group-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.model-group-chevron { flex: 0 0 auto; color: var(--muted); font-size: 16px; line-height: 1; }
.model-family-head {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  width: calc(100% - 8px); min-height: 30px; margin: 1px 0 1px 8px; padding: 4px 8px;
  border: 0; border-radius: 9px; background: transparent; color: var(--muted);
  font: inherit; font-size: 11.5px; text-align: left; cursor: pointer;
}
.model-family-title { display: flex; align-items: center; gap: 8px; min-width: 0; }
.model-family-title > span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.model-family-head:hover { background: var(--panel-2); color: var(--text); }
.model-family-head > span:last-child { color: var(--muted); font-size: 11px; }
.model-item {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 5px 8px; border-radius: 9px; border: 0; background: none;
  color: var(--text); font: inherit; font-size: 12.5px; text-align: left; cursor: pointer;
}
.model-item:hover, .model-item.focus { background: var(--panel-2); }
.model-item.selected { background: var(--accent-soft); }
.model-item .mi-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.model-item .mi-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.model-item .mi-sub { font-size: 11px; color: var(--muted); }
.model-empty { padding: 16px; color: var(--muted); font-size: 13px; text-align: center; }

/* Logo model */
.mlogo {
  flex-shrink: 0; width: 24px; height: 24px; border-radius: 7px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--panel-2); color: var(--text); font-size: 11px; font-weight: 700; overflow: hidden;
}
.mlogo img { width: 16px; height: 16px; }
:root[data-theme="dark"] .mlogo img.mono { filter: invert(1); }
.mlogo.sm { width: 19px; height: 19px; border-radius: 6px; font-size: 9.5px; }
.mlogo.sm img { width: 13px; height: 13px; }

/* Tombol kirim bulat (hitam ala Kimi) */
.send-round {
  display: grid; place-items: center; flex: 0 0 36px; width: 36px; height: 36px;
  border: 0; border-radius: 50%; cursor: pointer; font: inherit; font-size: 19px; line-height: 1;
  background: var(--text); color: var(--bg);
  transition: opacity .12s, transform .1s, background .12s;
}
.send-round:hover { opacity: .85; }
.send-round:active { transform: scale(.94); }
.send-round.primary { background: var(--text); color: var(--bg); }
.send-round.idle { background: var(--panel-3); color: var(--muted); cursor: default; }
.send-round.idle:hover { opacity: 1; }
.send-round.danger { background: var(--danger); color: #fff; }
.send-round:focus-visible, .attach-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.hint { text-align: center; color: var(--muted); font-size: 11.5px; margin: 8px 0 20px; }

/* Status mode aktif */
.mode-status {
  display: flex; align-items: center; justify-content: space-between;
  max-width: 768px; width: calc(100% - 40px); margin: 8px auto 0; padding: 0 6px;
  color: var(--muted); font-size: 12px;
}
.mode-status button { border: 0; background: transparent; color: var(--muted); font-size: 18px; cursor: pointer; }

/* Bilah progres (model lokal) */
.progress { display: flex; align-items: center; gap: 10px; padding: 8px 18px; font-size: 12px; color: var(--muted); border-bottom: 1px solid var(--border); }
.progress-bar { flex: 0 0 160px; height: 5px; background: var(--panel-2); border-radius: 3px; overflow: hidden; }
#progressFill { height: 100%; width: 0; background: var(--accent); transition: width .2s; }
#progressText { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------------- Lampiran: chip ringkas ---------------- */
.attachment-processing { display: flex; align-items: center; gap: 9px; padding: 2px 6px 8px; color: var(--muted); font-size: 12.5px; overflow: hidden; }
.attachment-processing span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attachment-list { display: flex; flex-wrap: wrap; gap: 7px; width: 100%; margin: 0 0 4px; padding: 0 2px 6px; }
.attachment-chip {
  display: flex; align-items: center; gap: 8px; max-width: 230px; min-width: 0;
  border: 1px solid var(--border); background: var(--panel-2); color: var(--text);
  border-radius: 11px; padding: 6px 8px 6px 10px; font-size: 12.5px;
}
.attachment-preview {
  min-width: 0; padding: 0; border: 0; background: transparent; color: inherit;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: left; cursor: pointer;
}
.attachment-preview:hover { color: var(--accent); }
.attachment-chip .file-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attachment-chip button { border: 0; background: transparent; color: var(--muted); cursor: pointer; font-size: 16px; padding: 0 2px; border-radius: 6px; }
.attachment-chip button:hover { color: var(--danger); }
.attachment-more { color: var(--muted); background: transparent; border-style: dashed; align-items: center; display: flex; }
.attachment-clear-all { align-self: center; padding: 5px 6px; border: 0; color: var(--muted); background: transparent; font: inherit; font-size: 11.5px; cursor: pointer; border-radius: 8px; }
.attachment-clear-all:hover { color: var(--danger); background: var(--panel-2); }

/* Chip file di dalam gelembung pengguna (nama saja, isi tidak ditampilkan) */
.message-attachments { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.file-chip {
  display: inline-flex; align-items: center; gap: 7px; max-width: 240px;
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 10px; padding: 5px 10px 5px 8px;
  font: inherit; font-size: 12px; color: var(--text); line-height: 1.35; cursor: pointer;
}
.file-chip:hover { border-color: var(--accent); color: var(--accent); }
.file-chip .fc-icon { font-size: 14px; flex: 0 0 auto; }
.file-chip .fc-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.message-attachments-more { font-size: 11px; color: var(--muted); align-self: center; }

/* Aksi pesan: salin, jawab ulang */
.message-tools { display: flex; gap: 4px; margin: 8px 0 0; }
.message-tool-btn {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 5px 11px; border: 1px solid transparent; border-radius: 999px;
  color: var(--muted); background: transparent; font: inherit; font-size: 11.5px; cursor: pointer;
  transition: background .12s, color .12s;
}
.message-tool-btn:hover { background: var(--panel-2); color: var(--text); }

/* ---------------- Dialog ---------------- */
dialog {
  background: var(--panel); color: var(--text);
  border: 1px solid var(--border); border-radius: 20px;
  width: min(480px, calc(100vw - 24px)); max-height: min(86dvh, 720px); overflow-y: auto; padding: 20px;
  box-shadow: var(--shadow-menu);
}
dialog::backdrop { background: rgba(15, 23, 42, .45); backdrop-filter: blur(2px); }
dialog h2 { margin: 0 0 4px; letter-spacing: -.01em; }
dialog form label { display: block; margin-top: 14px; font-size: 13.5px; font-weight: 550; }
dialog form label a { font-size: 12px; margin-left: 6px; }
dialog input[type="password"], dialog input[type="text"], dialog input[type="url"], dialog textarea {
  display: block; width: 100%; margin-top: 6px;
  background: var(--panel-2); color: var(--text);
  border: 1px solid transparent; border-radius: 10px;
  padding: 10px 12px; font: inherit; font-size: 14px; outline: none;
}
dialog select {
  display: block; width: 100%; margin-top: 6px;
  background: var(--panel-2); color: var(--text);
  border: 1px solid transparent; border-radius: 10px;
  padding: 10px 12px; font: inherit; font-size: 14px; outline: none;
}
dialog input:focus, dialog textarea:focus { border-color: var(--accent); background: var(--panel); }
dialog select:focus { border-color: var(--accent); }
dialog input[type="range"] { width: 100%; accent-color: var(--accent); }
dialog label.check { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; font-weight: 400; }
dialog label.check input { accent-color: var(--accent); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; }
.dialog-close { float: right; border: 0; background: transparent; color: var(--muted); font-size: 24px; cursor: pointer; border-radius: 8px; line-height: 1; padding: 2px 6px; }
.dialog-close:hover { background: var(--panel-2); color: var(--text); }
.api-dialog { width: min(520px, calc(100vw - 24px)); }
.api-dialog form > label { display: block; margin-top: 14px; font-size: 13.5px; font-weight: 550; }
.api-dialog .muted, .api-provider-hint, .api-key-status { line-height: 1.5; }
.api-provider-hint { margin: 8px 0 0; color: var(--muted); font-size: 12px; }
.api-key-status { margin: 8px 0 0; color: var(--muted); font-size: 12px; }

/* Toast: pil gelap di atas, ala Kimi */
.toast {
  position: fixed; top: 18px; left: 50%; transform: translateX(-50%);
  background: var(--text); color: var(--bg);
  border-radius: 999px; box-shadow: var(--shadow-menu);
  padding: 10px 18px; font-size: 13px; max-width: min(92vw, 560px); z-index: 90;
  animation: toast-in .18s ease-out;
}
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, -8px); } to { opacity: 1; transform: translate(-50%, 0); } }

.backdrop { display: none; }

/* ---------------- Landing ---------------- */
.landing {
  position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 24px;
  background:
    radial-gradient(ellipse at 18% 12%, rgba(77, 107, 254, .1), transparent 45%),
    radial-gradient(ellipse at 85% 88%, rgba(77, 107, 254, .08), transparent 42%),
    var(--bg);
}
.landing.hidden { display: none; }
.landing > .theme-toggle { position: absolute; top: 22px; right: 22px; border: 1px solid var(--border); width: auto; padding: 8px 12px; }
.landing-card {
  width: min(640px, 100%); text-align: center; padding: clamp(28px, 6vw, 56px);
  border: 1px solid var(--border); border-radius: 28px;
  background: var(--panel); box-shadow: var(--shadow-menu);
}
.landing-logo { display: block; width: min(180px, 52vw); height: auto; max-height: 180px; object-fit: contain; margin: 0 auto 10px; border-radius: 26px; }
.eyebrow { font-size: 11px; font-weight: 800; letter-spacing: .22em; color: var(--accent); }
.landing-card h1 { font-size: clamp(30px, 6vw, 48px); line-height: 1.1; letter-spacing: -.04em; margin: 12px 0; }
.landing-card h1 span { background: linear-gradient(90deg, var(--accent), var(--accent-2)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.landing-copy { max-width: 460px; margin: 0 auto; color: var(--muted); font-size: 14.5px; }
.landing-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin-top: 26px; }
.landing-actions .btn { min-width: 190px; }
.landing-note { margin: 24px 0 0; color: var(--muted); font-size: 12px; }
.login-dialog { text-align: center; max-width: 420px; }
.login-logo { display: block; width: min(160px, 60%); height: auto; margin: 6px auto 14px; border-radius: 20px; }
.login-dialog .btn { margin-top: 10px; }
.login-error { color: var(--danger); font-size: 13px; }

/* ---------------- Upload, sketsa, hasil gambar ---------------- */
.generated-image { display: block; width: min(100%, 640px); max-height: 70vh; object-fit: contain; margin: 14px 0 8px; border: 1px solid var(--border); border-radius: 14px; }
.file-preview-dialog { width: min(680px, calc(100vw - 24px)); }
.file-preview-content { max-height: min(68dvh, 560px); margin-top: 14px; overflow: auto; border: 1px solid var(--border); border-radius: 12px; background: var(--panel-2); }
.file-preview-content img { display: block; max-width: 100%; max-height: 64dvh; margin: auto; object-fit: contain; }
.file-preview-content pre { margin: 0; padding: 14px; color: var(--text); font: 12.5px/1.6 ui-monospace, "Cascadia Code", Consolas, monospace; white-space: pre-wrap; overflow-wrap: anywhere; }
.citations { margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--border); font-size: 13px; }
.citations ul { margin: 6px 0 0; padding-left: 20px; }
.citations a { overflow-wrap: anywhere; }

/* ---------------- Responsif ---------------- */
@media (max-width: 800px) {
  .sidebar { position: fixed; inset: 0 auto 0 0; z-index: 30; transform: translateX(-100%); transition: transform .2s; box-shadow: var(--shadow-menu); }
  .sidebar.open { transform: none; }
  .app.sidebar-collapsed .sidebar { width: 264px; padding: 14px 12px; border-right: 1px solid var(--border); }
  .backdrop.show { display: block; position: fixed; inset: 0; background: rgba(15, 23, 42, .4); z-index: 20; }
  .model-picker { flex: 0 1 auto; max-width: min(260px, 44vw); }
  .messages { padding: 16px 14px 22px; }
}
@media (max-width: 560px) {
  .composer { width: calc(100% - 20px); padding: 10px 10px 8px; border-radius: 22px;   }
  @media (hover: none) {
    .chat-item .del, .chat-item .chat-folder-action { opacity: 1; }
  }
  .composer-bar { gap: 4px; }
  .task-mode-btn { min-width: 0; height: 32px; gap: 4px; padding: 0 9px; font-size: 11.5px; }
  .composer .model-picker { flex: 0 1 auto; max-width: 44vw; }
  .attach-menu { left: 0; width: min(208px, calc(100vw - 24px)); }
  .task-mode-menu { width: min(166px, calc(100vw - 24px)); }
  .model-menu { right: -2px; width: min(280px, calc(100vw - 24px)); max-height: min(36dvh, 260px); }
  #modelBtnName { max-width: 24vw; font-size: 11.5px; }
  .send-round { flex-basis: 34px; width: 34px; height: 34px; }
  .msg.user .body { max-width: 94%; }
  .progress-bar { flex-basis: 72px; }
  .landing-card { border-radius: 22px; }
  .landing-actions { flex-direction: column; }
  .landing-actions .btn { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  .ai-thinking-dots i, .ai-spinner, .ai-thinking .ai-thinking-star { animation-duration: 2.4s; }
  .ai-thinking-text { animation: none; background: none; color: var(--muted); }
}
