/* ============================================================
   SAMCODER v6 — styles (redesign 21 Agu 2026)
   Perubahan: warna lebih premium, spacing konsisten,
   mobile-first, settings grouping, smooth UX
   Semua fitur asli tetap — hanya disempurnakan.
   ============================================================ */

/* ===== CSS Variables ===== */
:root {
  /* Dark theme (default) */
  --bg:          #0d0f18;
  --bg-soft:     #111420;
  --panel:       #161923;
  --panel-2:     #1c2030;
  --border:      #252a3a;
  --border-soft: #1e2232;
  --text:        #e2e5ef;
  --text-soft:   #c4c9d8;
  --muted:       #8891a8;
  --muted-soft:  #5e6880;

  /* Brand */
  --accent:      #7c5cfc;
  --accent-2:    #00d4aa;
  --accent-glow: rgba(124,92,252,.22);
  --gold:        #f0c040;

  /* Semantic */
  --user-bubble: #1e2338;
  --asst-bubble: #13161f;
  --danger:      #f05555;
  --ok:          #00d4aa;
  --warn:        #ffb347;

  /* Layout */
  --sidebar-w:   268px;
  --radius:      12px;
  --radius-sm:   8px;
  --radius-lg:   16px;

  /* Transition */
  --ease:        cubic-bezier(.25,.46,.45,.94);
}

html[data-theme="light"] {
  --bg:          #f0f2f7;
  --bg-soft:     #ffffff;
  --panel:       #ffffff;
  --panel-2:     #e8ebf2;
  --border:      #d0d5e2;
  --border-soft: #e2e6ef;
  --text:        #111728;
  --text-soft:   #2a3040;
  --muted:       #5e6880;
  --muted-soft:  #8891a8;
  --user-bubble: #dde1ef;
  --asst-bubble: #ffffff;
  --accent-glow: rgba(124,92,252,.12);
}

/* ===== Reset ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Inter", sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
button { font-family: inherit; cursor: pointer; }
a { color: inherit; }

/* ===== Buttons ===== */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  transition: border-color .18s var(--ease), color .18s var(--ease), background .18s var(--ease);
  white-space: nowrap;
}
.btn:hover { border-color: var(--accent); color: var(--text); }
.btn.primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  border: none;
  font-weight: 700;
  box-shadow: 0 4px 14px var(--accent-glow);
}
.btn.primary:hover { filter: brightness(1.08); box-shadow: 0 6px 20px var(--accent-glow); transform: translateY(-1px); }
.btn.primary:active { transform: none; }
.btn.danger { color: var(--danger); border-color: rgba(240,85,85,.35); }
.btn.danger:hover { background: rgba(240,85,85,.1); border-color: var(--danger); }
.btn.gold { color: var(--gold); border-color: rgba(240,192,64,.35); }
.btn.gold:hover { background: rgba(240,192,64,.1); border-color: var(--gold); }
.btn.small { padding: 4px 10px; font-size: 12px; border-radius: 6px; }
.btn:disabled { opacity: .4; cursor: not-allowed; pointer-events: none; }

.icon-btn {
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 17px;
  width: 34px; height: 34px;
  border-radius: var(--radius-sm);
  display: inline-flex; align-items: center; justify-content: center;
  transition: background .15s var(--ease), color .15s var(--ease);
  flex-shrink: 0;
}
.icon-btn:hover { background: var(--panel-2); color: var(--text); }

/* ===== Layout ===== */
#app { flex: 1; display: flex; min-height: 0; overflow: hidden; }

/* ===== Sidebar ===== */
#sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg-soft);
  border-right: 1px solid var(--border-soft);
  transition: margin-left .24s var(--ease);
  overflow: hidden;
}
#sidebar.collapsed { margin-left: calc(var(--sidebar-w) * -1); }
#sidebar-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 70;
  backdrop-filter: blur(2px);
}
#sidebar-overlay.show { display: block; }

.side-head {
  display: flex; align-items: center; gap: 9px;
  padding: 11px 13px;
  border-bottom: 1px solid var(--border-soft);
  flex-shrink: 0;
}
.side-head .logo-badge {
  width: 30px; height: 30px;
  border-radius: 9px;
  object-fit: cover;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border: 1.5px solid var(--border);
  flex-shrink: 0;
}
.side-title {
  font-weight: 700; font-size: 14px;
  flex: 1;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  letter-spacing: .01em;
}

#new-chat-btn {
  margin: 10px 12px;
  width: calc(100% - 24px);
  padding: 9px 14px;
  border-radius: var(--radius-sm);
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 13px; font-weight: 600;
  display: flex; align-items: center; justify-content: center; gap: 7px;
  transition: border-color .18s, background .18s;
}
#new-chat-btn:hover { border-color: var(--accent); background: var(--accent-glow); }

#session-search {
  display: none;
  margin: 0 12px 6px;
  width: calc(100% - 24px);
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  font-size: 12.5px;
  outline: none;
  transition: border-color .18s;
}
#session-search:focus { border-color: var(--accent); }

#session-list { flex: 1; overflow-y: auto; padding: 2px 8px 8px; }

/* Session items */
.sess-item {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 12.5px;
  color: var(--text-soft);
  border: 1px solid transparent;
  margin-bottom: 2px;
  transition: background .15s, border-color .15s;
}
.sess-item:hover { background: var(--panel-2); }
.sess-item.active { background: var(--panel-2); border-color: var(--accent); color: var(--text); }
.sess-item .s-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--ok); flex-shrink: 0;
}
.sess-item.busy .s-dot {
  background: var(--warn);
  box-shadow: 0 0 6px var(--warn);
  animation: blink 1.2s infinite;
}
.sess-item .s-main { flex: 1; min-width: 0; }
.sess-item .s-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 12.5px; }
.sess-item .s-sub { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 1px; }
.sess-item .s-pin, .sess-item .s-close {
  color: var(--muted); font-size: 14px;
  border: none; background: none;
  padding: 2px 3px; border-radius: 4px;
  opacity: 0; transition: opacity .15s, color .15s;
  flex-shrink: 0;
}
.sess-item:hover .s-pin,
.sess-item:hover .s-close { opacity: 1; }
.sess-item .s-close:hover { color: var(--danger); }
.sess-item .s-pin:hover { color: var(--gold); }

@keyframes blink { 0%,80%,100% { opacity:.3 } 40% { opacity:1 } }

/* Sidebar footer */
.side-foot { border-top: 1px solid var(--border-soft); padding: 6px 8px; flex-shrink: 0; }
.side-foot-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: var(--radius-sm);
  font-size: 12.5px; color: var(--text-soft);
  width: 100%; background: none; border: none; text-align: left;
  transition: background .15s, color .15s;
}
.side-foot-item:hover { background: var(--panel-2); color: var(--text); }
.side-foot-item .f-ico { font-size: 15px; width: 20px; text-align: center; flex-shrink: 0; }
.side-foot-item .f-name { flex: 1; }
.side-foot-item .f-badge { font-size: 10px; color: var(--muted); }

.side-user {
  display: flex; align-items: center; gap: 9px;
  padding: 9px 12px;
  border-top: 1px solid var(--border-soft);
  flex-shrink: 0;
}
.user-avatar {
  width: 30px; height: 30px; border-radius: 50%;
  object-fit: cover; background: #2e354f;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px; color: #fff;
  flex-shrink: 0; overflow: hidden;
}
.user-meta { flex: 1; min-width: 0; }
.user-name { font-size: 12.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 10.5px; color: var(--muted); }

/* ===== Main Area ===== */
#main { flex: 1; display: flex; flex-direction: column; min-width: 0; overflow: hidden; }

/* ===== Topbar ===== */
#topbar {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 14px;
  border-bottom: 1px solid var(--border-soft);
  background: var(--panel);
  flex-shrink: 0;
  min-height: 50px;
}
#topbar .tb-title {
  font-weight: 600; font-size: 13.5px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  flex: 1;
  color: var(--text-soft);
}
.spacer { flex: 1; }
.status-pill {
  display: flex; align-items: center; gap: 5px;
  font-size: 11.5px; color: var(--muted);
  white-space: nowrap;
}
.status-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 7px var(--ok);
  display: inline-block;
  flex-shrink: 0;
}
.status-pill.busy .status-dot { background: var(--warn); box-shadow: 0 0 7px var(--warn); }

/* ===== Chat ===== */
#chat { flex: 1; overflow-y: auto; padding: 20px 0 8px; scroll-behavior: smooth; }
.container { max-width: 800px; margin: 0 auto; padding: 0 18px; }

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

.avatar {
  width: 30px; height: 30px; border-radius: 50%;
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 15px;
  margin-top: 3px;
  overflow: hidden;
  background: #262b3a;
}
.assistant .avatar {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  margin-right: 10px;
}
.assistant .avatar.thinking { animation: pulse 1.3s ease-in-out infinite; }
.user .avatar {
  background: #2e354f;
  margin-left: 10px;
  order: 2;
}

@keyframes pulse { 0%,100% { transform:scale(1) } 50% { transform:scale(1.07) } }

.bubble {
  max-width: 86%;
  padding: 11px 15px;
  border-radius: var(--radius-lg);
  line-height: 1.65; font-size: 14px;
  word-wrap: break-word; min-width: 0;
}
.bubble p { margin: 0 0 7px; }
.bubble p:last-child { margin-bottom: 0; }
.bubble h1, .bubble h2, .bubble h3, .bubble h4 { margin: 12px 0 5px; line-height: 1.3; }
.bubble h1 { font-size: 18px; } .bubble h2 { font-size: 16px; } .bubble h3 { font-size: 15px; }
.bubble ul, .bubble ol { margin: 5px 0 9px; padding-left: 20px; }
.bubble li { margin-bottom: 3px; }
.bubble a { color: var(--accent-2); text-decoration: underline; text-underline-offset: 2px; }
.bubble table { border-collapse: collapse; margin: 8px 0; width: 100%; font-size: 13px; }
.bubble th, .bubble td { border: 1px solid var(--border); padding: 6px 10px; text-align: left; }
.bubble th { background: var(--panel-2); font-weight: 600; }
.bubble blockquote { border-left: 3px solid var(--accent); margin: 8px 0; padding: 3px 12px; color: var(--muted); font-style: italic; }
.bubble img { max-width: 100%; border-radius: var(--radius-sm); margin: 4px 0; }

.user .bubble { background: var(--user-bubble); border-bottom-right-radius: 4px; }
.assistant .bubble { background: var(--asst-bubble); border: 1px solid var(--border-soft); border-bottom-left-radius: 4px; }

.typing { color: var(--muted); font-size: 14px; padding: 14px 16px; }
.typing span { animation: blink 1.2s infinite; display: inline-block; }
.typing span:nth-child(2) { animation-delay: .2s; }
.typing span:nth-child(3) { animation-delay: .4s; }

/* Message actions */
.msg-actions {
  display: flex; align-items: center; gap: 3px;
  margin-top: 7px; flex-wrap: wrap;
  opacity: 0; transition: opacity .15s;
}
.msg:hover .msg-actions { opacity: 1; }
.msg-actions .icon-btn { font-size: 13px; width: 26px; height: 26px; border-radius: 6px; }
.msg-time { font-size: 10.5px; color: var(--muted-soft); margin-left: 4px; }

/* Code blocks */
.code-block { position: relative; margin: 9px 0; border-radius: var(--radius-sm); overflow: hidden; border: 1px solid var(--border); }
.code-block .code-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 6px 12px;
  background: #0a0c14;
  border-bottom: 1px solid var(--border);
  font-size: 11.5px; color: var(--muted);
}
html[data-theme="light"] .code-block .code-head { background: #e8eaf0; }
.code-block pre { margin: 0; padding: 14px; overflow-x: auto; max-height: 400px; }
.code-block code { font-family: "JetBrains Mono", "Fira Code", Consolas, monospace; font-size: 12.5px; background: transparent !important; }

/* Diff view */
.diff-card { margin: 10px 0; border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; background: var(--bg); }
.diff-head { display: flex; align-items: center; gap: 10px; padding: 8px 12px; background: rgba(255,255,255,.03); font-size: 12.5px; }
.diff-head .fname { font-weight: 700; word-break: break-all; }
.diff-head .badge { font-size: 10.5px; border-radius: 999px; padding: 2px 8px; }
.badge.add { background: rgba(0,212,170,.15); color: var(--ok); }
.badge.mod { background: rgba(255,149,0,.15); color: #ff9500; }
.badge.del { background: rgba(240,85,85,.15); color: var(--danger); }
.diff-body { padding: 8px 12px; font-family: 'JetBrains Mono', Consolas, monospace; font-size: 12px; max-height: 240px; overflow: auto; white-space: pre; }
.diff-body .ln { display: block; }
.diff-body .ln.add { background: rgba(0,212,170,.1); color: var(--ok); }
.diff-body .ln.del { background: rgba(240,85,85,.1); color: var(--danger); }
.diff-body .ln.ctx { color: var(--muted); }
.diff-actions { padding: 6px 12px; border-top: 1px solid var(--border); display: flex; gap: 8px; }

/* ===== Input Area ===== */
#input-area {
  border-top: 1px solid var(--border-soft);
  background: var(--panel);
  padding: 12px 16px 14px;
  flex-shrink: 0;
}
.input-wrap {
  max-width: 800px; margin: 0 auto;
  display: flex; gap: 9px; align-items: flex-end;
}
.input-side { display: flex; flex-direction: column; gap: 5px; justify-content: flex-end; }
.input-side button {
  width: 38px; height: 38px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--muted);
  font-size: 15px;
  transition: border-color .18s, color .18s;
}
.input-side button:hover { border-color: var(--accent); color: var(--text); }
.input-right { display: flex; flex-direction: column; gap: 5px; justify-content: flex-end; }
.input-right button { width: 38px; height: 38px; border-radius: var(--radius-sm); }

#message {
  flex: 1;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 14px 16px;
  border-radius: var(--radius);
  font-size: 14.5px; line-height: 1.55;
  outline: none; resize: none;
  min-height: 68px; max-height: 220px;
  transition: border-color .18s;
}
#message:focus { border-color: var(--accent); }
#message::placeholder { color: var(--muted-soft); }

#send {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff; border: none;
  width: 38px; height: 38px;
  border-radius: var(--radius-sm);
  font-size: 15px; font-weight: 700;
  transition: opacity .2s, transform .15s;
}
#send:disabled { opacity: .4; cursor: not-allowed; }
#send:hover:not(:disabled) { transform: scale(1.05); }
#stop-btn {
  background: var(--danger);
  color: #fff; border: none;
  width: 38px; height: 38px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  transition: background .18s;
}
#stop-btn:hover { background: #c83a3a; }

/* Input tools row */
.input-tools {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 7px; flex-wrap: wrap;
  max-width: 800px; margin-left: auto; margin-right: auto;
}
.tool-chip {
  background: var(--bg);
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 11px; font-size: 12px;
  transition: all .18s;
}
.tool-chip.active {
  background: rgba(240,192,64,.1);
  color: var(--gold);
  border-color: rgba(240,192,64,.45);
}
.tool-hint { font-size: 11px; color: var(--muted); }

/* Activity bar */
.activity-bar {
  flex: 1; min-width: 180px;
  display: flex; align-items: center; gap: 7px;
  font-size: 12px; color: var(--gold);
  background: rgba(240,192,64,.07);
  border: 1px solid rgba(240,192,64,.22);
  border-radius: 999px; padding: 4px 12px;
}
.activity-spin { display: inline-block; animation: spin 1s linear infinite; }
.activity-bubble { color: var(--muted); font-style: italic; font-size: 13px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Model select */
.input-model-bar { max-width: 800px; margin: 8px auto 0; display: flex; align-items: center; gap: 8px; }
.input-model-bar .model-select { flex: 1; }
.input-model-bar .tool-chip { flex-shrink: 0; white-space: nowrap; }
.input-model-bar .tool-hint { font-size: 11px; color: var(--muted); flex-shrink: 0; }
.model-select {
  background: var(--bg); border: 1px solid var(--border);
  color: var(--text); padding: 5px 10px;
  border-radius: var(--radius-sm); font-size: 12px;
  outline: none; max-width: 100%; width: 100%;
  transition: border-color .18s;
}
.model-select:focus { border-color: var(--accent); }

/* Image / file preview */
#image-preview { display: flex; flex-wrap: wrap; gap: 7px; max-width: 800px; margin: 0 auto 8px; }
#image-preview img { width: 60px; height: 60px; object-fit: cover; border-radius: var(--radius-sm); border: 1px solid var(--border); cursor: pointer; }

.file-chip {
  display: inline-flex; align-items: center; gap: 7px;
  background: rgba(240,192,64,.07);
  border: 1px solid rgba(240,192,64,.3);
  border-radius: var(--radius-sm); padding: 5px 9px;
  font-size: 12px; color: var(--text);
}
.file-chip .fc-ico { font-size: 14px; }
.file-chip .fc-name { font-weight: 700; max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-chip .fc-desc { color: var(--muted); font-size: 10.5px; }
.file-chip .fc-x { cursor: pointer; color: var(--muted); font-size: 14px; }
.file-chip .fc-x:hover { color: var(--danger); }

/* Scroll-down button */
#scroll-down {
  position: sticky; bottom: 14px;
  float: right; right: 14px;
  width: 38px; height: 38px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text-soft);
  font-size: 18px;
  cursor: pointer;
  z-index: 20;
  box-shadow: 0 4px 16px rgba(0,0,0,.3);
  transition: background .15s, transform .15s;
}
#scroll-down:hover { background: var(--panel-2); transform: translateY(-2px); }

/* ===== Artifacts panel ===== */
#artifacts {
  width: 290px;
  border-left: 1px solid var(--border-soft);
  background: var(--panel);
  display: flex; flex-direction: column;
  flex-shrink: 0;
}
#artifacts.hidden { display: none !important; }
.art-head {
  padding: 11px 15px;
  border-bottom: 1px solid var(--border-soft);
  display: flex; align-items: center;
  font-weight: 700; font-size: 13.5px;
  flex-shrink: 0;
}
.art-count { color: var(--muted); font-size: 11.5px; font-weight: 400; margin-left: 6px; }
#artifact-list { flex: 1; overflow-y: auto; padding: 8px; }

.art-item {
  display: flex; align-items: center; gap: 7px;
  padding: 7px 9px; border-radius: var(--radius-sm);
  cursor: pointer; font-size: 12px; color: var(--text-soft);
  transition: background .14s;
  margin-bottom: 1px;
}
.art-item:hover { background: var(--panel-2); }
.art-item .fname { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: "JetBrains Mono", Consolas, monospace; font-size: 11.5px; }
.art-item .fsize { color: var(--muted); font-size: 10.5px; flex-shrink: 0; }
.art-del { margin-left: auto; background: none; border: none; color: var(--muted); font-size: 15px; cursor: pointer; padding: 0 3px; line-height: 1; border-radius: 4px; }
.art-del:hover { color: var(--danger); background: rgba(240,85,85,.08); }

.art-empty { padding: 28px 14px; text-align: center; color: var(--muted); font-size: 13px; line-height: 1.7; }
.art-empty b { color: var(--accent-2); }

/* File tree */
.art-folder { margin-bottom: 2px; }
.art-folder-head { display: flex; align-items: center; gap: 6px; padding: 4px 6px; cursor: pointer; font-size: 12px; color: var(--muted); border-radius: 6px; }
.art-folder-head:hover { background: rgba(255,255,255,.04); }
.art-folder-head::after { content: '▸'; margin-left: auto; font-size: 10px; transition: transform .2s; }
.art-folder.open > .art-folder-head::after { transform: rotate(90deg); }
.art-folder-body { display: none; padding-left: 12px; border-left: 1px solid var(--border); margin-left: 7px; }
.art-folder.open > .art-folder-body { display: block; }

/* ===== Artifact Viewer ===== */
#artifact-viewer {
  position: fixed; inset: 0;
  background: rgba(7,8,14,.95);
  backdrop-filter: blur(5px);
  display: none; flex-direction: column;
  z-index: 90;
}
#artifact-viewer.open { display: flex; }
.av-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
}
.av-title { font-weight: 700; font-family: "JetBrains Mono", Consolas, monospace; font-size: 13.5px; }
.av-actions { display: flex; gap: 8px; }
.av-body { flex: 1; overflow: auto; }
.av-body pre { margin: 0; padding: 22px; font-size: 13px; }
.av-body iframe { width: 100%; height: 100%; border: none; background: #fff; }
.av-body img { max-width: 100%; display: block; margin: 0 auto; }

/* ===== Settings (fullscreen overlay) ===== */
#settings {
  position: fixed; inset: 0;
  background: rgba(7,8,14,.95);
  backdrop-filter: blur(5px);
  display: none; flex-direction: column;
  z-index: 95;
}
#settings.open { display: flex; }

.set-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
  flex-shrink: 0;
}
.set-title { font-weight: 700; font-size: 15px; }

.set-body { flex: 1; overflow: hidden; display: flex; min-height: 0; }

/* Settings sidebar nav */
.set-tabs {
  width: 200px; flex-shrink: 0;
  border-right: 1px solid var(--border-soft);
  padding: 10px 8px;
  overflow-y: auto;
  background: var(--bg-soft);
}

/* Group headers in settings nav */
.set-group-label {
  padding: 14px 12px 5px;
  font-size: 10px; font-weight: 800;
  letter-spacing: .1em; text-transform: uppercase;
  color: var(--muted-soft);
}
.set-group-label:first-child { padding-top: 6px; }

.set-tab {
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer; font-size: 13px;
  color: var(--muted); margin-bottom: 1px;
  transition: background .14s, color .14s;
  display: flex; align-items: center; gap: 8px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.set-tab:hover { background: var(--panel-2); color: var(--text); }
.set-tab.active { background: var(--panel-2); color: var(--text); border-left: 3px solid var(--accent); padding-left: 9px; }

/* Accordion submenus in settings */
.set-menu { margin-bottom: 2px; }
.set-menu-head {
  padding: 8px 12px; border-radius: var(--radius-sm);
  cursor: pointer; font-size: 13px; color: var(--muted);
  display: flex; justify-content: space-between; align-items: center;
  transition: background .14s, color .14s;
  gap: 6px;
}
.set-menu-head:hover { background: var(--panel-2); color: var(--text); }
.set-menu.open .set-menu-head { color: var(--text); }
.set-menu-arrow { transition: transform .2s; font-size: 10px; flex-shrink: 0; }
.set-menu.open .set-menu-arrow { transform: rotate(90deg); }
.set-sub {
  padding: 7px 12px 7px 28px;
  border-radius: var(--radius-sm);
  cursor: pointer; font-size: 12.5px;
  color: var(--muted); display: block; margin-bottom: 1px;
  transition: background .14s, color .14s;
}
.set-sub:hover { background: var(--panel-2); color: var(--text); }
.set-sub.active { background: var(--panel-2); color: var(--text); border-left: 3px solid var(--accent); padding-left: 25px; }

/* Settings content panel */
.set-panel { flex: 1; padding: 22px 26px; overflow-y: auto; }
.set-panel h3 { margin-bottom: 16px; font-size: 15.5px; }

/* Form fields */
.field { margin-bottom: 15px; }
.field label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 5px; font-weight: 500; }
.field input[type="text"],
.field input[type="password"],
.field input[type="email"],
.field input[type="file"],
.field select,
.field textarea {
  width: 100%; max-width: 440px;
  padding: 10px 13px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 13.5px; outline: none;
  transition: border-color .18s;
  font-family: inherit;
}
.field textarea { resize: vertical; max-width: 440px; min-height: 80px; line-height: 1.5; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--accent); }

.pw-eye {
  position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
  background: none; border: none; color: var(--muted); font-size: 14px;
  cursor: pointer; padding: 4px;
}

.avatar-preview {
  width: 80px; height: 80px; border-radius: 50%;
  object-fit: cover; background: #2e354f;
  border: 2px solid var(--border);
  margin-bottom: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 30px; font-weight: 800; color: #fff;
  overflow: hidden;
}

.msg-ok { color: var(--ok); font-size: 12.5px; margin-top: 5px; min-height: 16px; }
.msg-err { color: var(--danger); font-size: 12.5px; margin-top: 5px; min-height: 16px; }

/* Key row */
.key-row {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 0; border-bottom: 1px solid var(--border-soft); flex-wrap: wrap;
}
.key-row .k-prov { font-weight: 700; font-size: 13.5px; width: 110px; }
.key-row .k-mask { font-family: "JetBrains Mono", Consolas, monospace; font-size: 12px; color: var(--muted); flex: 1; min-width: 100px; }
.key-row .k-actions { display: flex; gap: 6px; }

/* User rows */
.user-row { display: flex; align-items: center; gap: 11px; padding: 10px 0; border-bottom: 1px solid var(--border-soft); flex-wrap: wrap; }
.user-row .u-avatar { width: 32px; height: 32px; border-radius: 50%; background: #2e354f; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 12.5px; color: #fff; flex-shrink: 0; overflow: hidden; }
.user-row .u-info { flex: 1; min-width: 0; }
.user-row .u-info .u-name { font-size: 13.5px; font-weight: 600; }
.user-row .u-info .u-username { font-size: 11.5px; color: var(--muted); }

/* Badge */
.badge { display: inline-block; font-size: 10.5px; padding: 2px 7px; border-radius: 10px; background: rgba(124,92,252,.16); color: var(--accent); font-weight: 600; }
.badge.member { background: rgba(140,150,180,.13); color: var(--muted); }

/* Stat cards */
.stat-card { background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 12px; }
.stat-label { color: var(--muted); font-size: 11px; margin-bottom: 3px; font-weight: 500; text-transform: uppercase; letter-spacing: .04em; }
.stat-value { font-size: 14.5px; font-weight: 700; word-break: break-all; }

/* Quota bar */
.quota-bar { width: 100%; height: 8px; background: var(--panel-2); border-radius: 999px; overflow: hidden; margin: 5px 0; }
.quota-fill { height: 100%; border-radius: 999px; transition: width .5s var(--ease); background: linear-gradient(135deg, var(--accent), var(--accent-2)); }

/* ===== Plan mode, home btn ===== */
.home-btn { font-size: 15px; }
.home-btn:hover { transform: rotate(-12deg); }

/* ===== Slash autocomplete ===== */
#slash-box { position: absolute; bottom: calc(100% + 6px); left: 0; right: 0; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: 0 8px 30px rgba(0,0,0,.35); z-index: 99; overflow: hidden; max-height: 240px; overflow-y: auto; }

/* ===== Toast ===== */
.toast {
  position: fixed; bottom: 24px; left: 50%;
  transform: translateX(-50%);
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 9px 16px; border-radius: var(--radius);
  font-size: 13px; z-index: 200;
  display: none;
  box-shadow: 0 6px 24px rgba(0,0,0,.4);
  max-width: calc(100vw - 32px); text-align: center;
  animation: toastIn .2s var(--ease);
}
@keyframes toastIn { from { opacity:0; transform:translateX(-50%) translateY(8px); } to { opacity:1; transform:translateX(-50%) translateY(0); } }

/* ===== In-app confirm modal ===== */
#confirm-modal {
  display: none;
  position: fixed; inset: 0; z-index: 300;
  background: rgba(0,0,0,.55);
  backdrop-filter: blur(3px);
  align-items: center; justify-content: center;
}
#confirm-modal.show { display: flex; }
.confirm-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px 26px;
  max-width: min(380px, 88vw);
  width: 100%;
  box-shadow: 0 20px 60px rgba(0,0,0,.5);
  animation: confirmIn .22s var(--ease);
}
@keyframes confirmIn { from { opacity:0; transform:scale(.96) translateY(8px); } to { opacity:1; transform:none; } }
.confirm-card p { font-size: 13.5px; color: var(--text-soft); line-height: 1.6; margin-bottom: 18px; }
.confirm-actions { display: flex; gap: 10px; justify-content: flex-end; }

/* ===== Login Page ===== */
#login-overlay {
  position: fixed; inset: 0; z-index: 100;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(1100px 700px at 15% -10%, #141730 0%, #0a0c16 55%, #08090f 100%);
  overflow: hidden;
}
#login-overlay.hidden { display: none; }

.login-bg { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
.login-blob { position: absolute; border-radius: 50%; filter: blur(65px); opacity: .45; animation: loginFloat 14s ease-in-out infinite alternate; will-change: transform; }
.login-blob.b1 { width: 480px; height: 480px; left: -80px; top: -60px; background: radial-gradient(circle, rgba(124,92,252,.5), transparent 65%); }
.login-blob.b2 { width: 380px; height: 380px; right: -100px; bottom: -40px; background: radial-gradient(circle, rgba(0,212,170,.38), transparent 65%); animation-delay: -5s; }
.login-blob.b3 { width: 300px; height: 300px; left: 40%; top: 50%; background: radial-gradient(circle, rgba(64,156,255,.28), transparent 65%); animation-delay: -9s; }
.login-grid { position: absolute; inset: 0; background-image: linear-gradient(rgba(255,255,255,.022) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.022) 1px, transparent 1px); background-size: 44px 44px; mask-image: radial-gradient(circle at 50% 40%, #000 0%, transparent 72%); -webkit-mask-image: radial-gradient(circle at 50% 40%, #000 0%, transparent 72%); }
@keyframes loginFloat { 0% { transform: translate(0,0) scale(1); } 100% { transform: translate(38px,-26px) scale(1.07); } }

.login-card {
  position: relative; z-index: 2;
  width: 390px; max-width: 92%; text-align: center;
  padding: 38px 34px 26px;
  border-radius: 22px;
  background: linear-gradient(160deg, rgba(255,255,255,.065), rgba(255,255,255,.02));
  border: 1px solid rgba(255,255,255,.1);
  box-shadow: 0 28px 72px rgba(0,0,0,.52), inset 0 1px 0 rgba(255,255,255,.07);
  backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
  animation: loginIn .45s cubic-bezier(.2,.9,.3,1.15) both;
}
@keyframes loginIn { from { opacity:0; transform:translateY(16px) scale(.97); } to { opacity:1; transform:none; } }

.login-logo-wrap { display: flex; flex-direction: column; align-items: center; gap: 9px; margin-bottom: 18px; }
.login-logo-wrap .logo-badge { width: 66px; height: 66px; border-radius: 18px; border: 1.5px solid rgba(255,255,255,.12); box-shadow: 0 8px 30px rgba(124,92,252,.4), 0 0 0 8px rgba(124,92,252,.07); }
.login-brand { font-size: 14px; font-weight: 800; letter-spacing: .12em; color: rgba(255,255,255,.8); text-transform: uppercase; }
.login-card h2 { font-size: 22px; font-weight: 800; margin-bottom: 5px; background: linear-gradient(90deg, #c0afff, #7cf7e0); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.login-card .login-sub { color: rgba(255,255,255,.5); font-size: 13px; margin-bottom: 22px; }
.login-field { position: relative; margin-bottom: 12px; }
.login-field .lf-ico { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); font-size: 14px; opacity: .55; pointer-events: none; }
.login-field input {
  width: 100%; padding: 13px 13px 13px 40px;
  background: rgba(255,255,255,.05); color: #fff;
  border: 1px solid rgba(255,255,255,.1); border-radius: 12px;
  font-size: 14px; outline: none; transition: all .2s;
}
.login-field input::placeholder { color: rgba(255,255,255,.3); }
.login-field input:focus { border-color: var(--accent); background: rgba(124,92,252,.08); box-shadow: 0 0 0 3px rgba(124,92,252,.13); }
#login-btn, #mfa-verify-btn {
  width: 100%; margin-top: 5px; padding: 13px;
  border: none; border-radius: 12px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff; font-weight: 800; font-size: 14.5px; cursor: pointer;
  box-shadow: 0 8px 24px rgba(124,92,252,.3);
  transition: transform .14s, box-shadow .2s, filter .18s;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
#login-btn:hover, #mfa-verify-btn:hover { transform: translateY(-1px); box-shadow: 0 12px 30px rgba(124,92,252,.45); filter: brightness(1.06); }
#login-btn:active, #mfa-verify-btn:active { transform: none; }
#login-btn:disabled { opacity: .7; cursor: wait; transform: none; }
.spinner { width: 15px; height: 15px; border: 2px solid rgba(255,255,255,.3); border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite; }
#login-error { margin-top: 12px; font-size: 12px; color: #f08080; background: rgba(240,85,85,.1); border: 1px solid rgba(240,85,85,.22); border-radius: var(--radius-sm); padding: 7px 10px; display: none; }
#login-error:not(:empty) { display: block; }
.login-foot { margin-top: 20px; font-size: 11px; color: rgba(255,255,255,.28); letter-spacing: .07em; }
.login-home { display: inline-flex; align-items: center; gap: 6px; color: rgba(255,255,255,.6); font-size: 12.5px; text-decoration: none; padding: 7px 13px; border: 1px solid rgba(255,255,255,.12); border-radius: var(--radius-sm); background: rgba(255,255,255,.03); backdrop-filter: blur(6px); transition: all .2s; }
.login-home:hover { color: #fff; border-color: rgba(124,92,252,.55); background: rgba(124,92,252,.1); }

/* ===== Payment ===== */
.pay-method-btn {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 11px 8px; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--bg); color: var(--text); cursor: pointer; transition: all .15s;
  font-family: inherit; text-align: center;
}
.pay-method-btn .pm-ico { font-size: 20px; }
.pay-method-btn .pm-name { font-weight: 800; font-size: 12.5px; }
.pay-method-btn .pm-desc { font-size: 10px; color: var(--muted); }
.pay-method-btn:hover { border-color: var(--accent); }
.pay-method-btn.active { border-color: var(--accent); background: var(--accent-glow); box-shadow: 0 0 0 3px rgba(124,92,252,.16); }

/* ===== Sub-agents modal ===== */
#subagents-modal, #cmd-palette {
  position: fixed; z-index: 999;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: 0 12px 40px rgba(0,0,0,.45);
  overflow: hidden;
}

/* ===== Canvas modal ===== */
#canvas-modal {
  position: fixed; inset: 0; z-index: 125;
  background: rgba(0,0,0,.7);
  align-items: center; justify-content: center;
}

/* ===== Misc ===== */
.close-x { cursor: pointer; color: var(--muted); font-size: 21px; line-height: 1; background: none; border: none; transition: color .14s; }
.close-x:hover { color: var(--text); }
.hint { text-align: center; color: var(--muted); font-size: 12px; margin-top: 9px; }

/* Share dropdown */
.share-wrap { position: relative; display: inline-block; }
.export-menu { position: absolute; bottom: 100%; left: 0; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 5px; z-index: 99; box-shadow: 0 8px 24px rgba(0,0,0,.45); min-width: 180px; }

/* Scrollbar */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: var(--muted-soft); }

/* ===== RESPONSIVE — MOBILE ===== */
@media (max-width: 768px) {
  /* Sidebar becomes drawer */
  #sidebar {
    position: fixed; left: 0; top: 0; bottom: 0;
    z-index: 80;
    box-shadow: 4px 0 30px rgba(0,0,0,.5);
  }

  /* Status pill hidden on mobile to save topbar space */
  .status-pill { display: none; }

  /* Artifacts: full-screen overlay on mobile */
  #artifacts { display: none; }
  #artifacts.open-mobile {
    display: flex;
    position: fixed; right: 0; top: 0; bottom: 0;
    z-index: 85;
    box-shadow: -4px 0 30px rgba(0,0,0,.5);
    width: min(300px, 85vw);
  }

  /* Settings: single column on mobile */
  .set-body { flex-direction: column; }
  .set-tabs {
    width: 100%; border-right: none;
    border-bottom: 1px solid var(--border-soft);
    max-height: 42vh; overflow-y: auto;
    padding: 8px;
  }
  .set-panel { padding: 16px; }
  .set-group-label { padding-top: 10px; }
  .field input[type="text"],
  .field input[type="password"],
  .field select,
  .field textarea { max-width: 100%; }

  /* Msg actions always visible on last message (no hover) */
  .msg:last-child .msg-actions { opacity: 1; }

  /* Topbar compact */
  #topbar { padding: 6px 10px; gap: 6px; }
  #topbar .tb-title { font-size: 13px; }

  /* Input area compact */
  #input-area { padding: 10px 12px 12px; }
  .input-wrap { gap: 7px; }
  #message { font-size: 14px; }

  /* Toast: top position on mobile (avoids keyboard overlap) */
  .toast { bottom: auto; top: 72px; }

  /* Chat padding */
  .container { padding: 0 12px; }
  .bubble { max-width: 90%; font-size: 13.5px; }

  /* Model select full width on mobile */
  .model-select { max-width: 100%; }
}

@media (min-width: 769px) {
  #sidebar-overlay { display: none !important; }
  #menu-btn { display: none; }
}

/* ===== msg-cost (token usage display) ===== */
.msg-cost {
  margin-top: 8px;
  font-size: 11px;
  color: var(--muted-soft);
  border-top: 1px solid var(--border-soft);
  padding-top: 6px;
  line-height: 1.5;
}

/* ===== Typing indicator dots ===== */
.typing-dots { display: inline-flex; gap: 4px; align-items: center; padding: 4px 0; }
.typing-dots span { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); display: inline-block; animation: typingBounce 1.2s ease-in-out infinite; }
.typing-dots span:nth-child(2) { animation-delay: .2s; }
.typing-dots span:nth-child(3) { animation-delay: .4s; }
@keyframes typingBounce { 0%,80%,100% { transform:scale(.6); opacity:.4; } 40% { transform:scale(1); opacity:1; } }

/* ===== Session search visible ===== */
#session-search { display: block !important; }

/* ===== Slash box positioned properly ===== */
.input-wrap { position: relative; }
#slash-box { position: absolute; bottom: calc(100% + 4px); left: 0; right: 0; z-index: 99; }

/* ===== Confirm modal backdrop click area ===== */
#confirm-modal { cursor: default; }
.confirm-card { cursor: default; }

/* ===== Settings mobile: model select full width ===== */
@media (max-width: 768px) {
  .model-select { font-size: 12px; }
  .input-tools { gap: 6px; }
  .tool-chip { padding: 3px 9px; font-size: 11.5px; }
  /* Branch items with visual connector */
  .sess-item[style*="paddingLeft"] {
    border-left: 2px solid var(--border);
    margin-left: 14px;
  }
}

/* ===== Branch session connector line (desktop) ===== */
.sess-item.branch-item {
  padding-left: 20px;
  border-left: 2px solid var(--border-soft);
  margin-left: 12px;
}

/* COBLAI high-tech - 3 tombol Copy/Refresh/Share + dropdown glass (Ayank 26 Agu 2026) */
.msg-actions{display:flex;gap:8px;align-items:center;margin-top:10px;position:relative}
.msg-actions .icon-btn{width:32px;height:32px;border-radius:999px;border:1px solid rgba(255,255,255,0.12);background:rgba(255,255,255,0.06);backdrop-filter:blur(8px);transition:all 0.2s}
.msg-actions .icon-btn:hover{background:linear-gradient(135deg,#7c3aed,#d946ef);border-color:transparent;color:white;transform:scale(1.08)}
/* COBLAI high-tech - keep original position bottom:100% left:0, just glass skin */
.export-menu{background:rgba(15,15,20,0.95)!important;backdrop-filter:blur(16px)!important;border:1px solid rgba(255,255,255,0.12)!important;border-radius:14px!important;box-shadow:0 12px 40px rgba(0,0,0,0.6)!important;overflow:hidden!important}
.export-menu button:hover{background:linear-gradient(135deg,rgba(124,58,237,0.2),rgba(217,70,239,0.2))!important;color:white!important}
.msg-time{font-size:11px;color:#71717a;margin-left:auto}
#messages .bubble{border-radius:1rem;box-shadow:0 4px 20px rgba(124,58,237,0.1)}

/* Token & biaya badge high-tech */
#st-tokens, .stat-value{font-family:monospace;font-weight:700;color:#7c3aed}
.token-badge{display:inline-flex;gap:6px;align-items:center;padding:4px 10px;border-radius:999px;background:rgba(124,58,237,0.12);border:1px solid rgba(124,58,237,0.2);font-size:11px;color:#a78bfa}
#topbar{position:sticky;top:0;z-index:40!important}

/* Fix sidebar hidden di web - menu-btn harus selalu kelihatan */
#menu-btn{display:flex!important;align-items:center;justify-content:center;width:36px;height:36px;border-radius:8px}
#sidebar.collapsed + #sidebar-overlay + #main #menu-btn,
#sidebar.collapsed ~ #main #menu-btn{opacity:1!important;visibility:visible!important}
#topbar{position:sticky;top:0;z-index:41!important}
#coblai-brand{z-index:30!important}
