/* ============================================================
   0xssec — design system
   Hitam-ungu bersih · font tebal · SEMUA sudut membulat
   (tidak ada neon, tidak ada efek hacker, tanpa gaya terminal)
   ============================================================ */

:root {
  --bg: #0b0813;
  --bg2: #0d0a16;
  --side: #0e0b17;
  --card: #161024;
  --card2: #1b1430;
  --deep: #0d0a16;
  --line: #2a2042;
  --line2: #3a2c5e;
  --text: #f3effb;
  --muted: #a99cc9;
  --faint: #7d6fa8;
  --acc: #8b5cf6;
  --acc2: #a78bfa;
  --accdeep: #6d28d9;
  --accsoft: rgba(139, 92, 246, 0.13);
  --accsofter: rgba(139, 92, 246, 0.07);
  --ok: #7ce0a8;
  --bad: #f88a8a;
  --warn: #f2c374;
  --r-xl: 24px;
  --r-lg: 18px;
  --r-md: 12px;
  --r-pill: 999px;
  --mono: "SF Mono", "Cascadia Code", "JetBrains Mono", Consolas, "Roboto Mono", monospace;
}

* { box-sizing: border-box; font-weight: 700; }

[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

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

::selection { background: rgba(139, 92, 246, 0.35); }

/* ---------- scrollbar (tipis, membulat, gelap) ---------- */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--line2);
  border-radius: var(--r-pill);
  border: 3px solid var(--bg);
}
::-webkit-scrollbar-thumb:hover { background: var(--accdeep); }

/* ============================================================
   TOKEN GATE
   ============================================================ */

.gate {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at 50% 20%, #130e22 0%, var(--bg) 60%);
  padding: 24px;
}

.gate-card {
  width: min(400px, 100%);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 32px;
  padding: 44px 36px 36px;
  text-align: center;
}

.gate-logo {
  width: 96px;
  height: 96px;
  border-radius: 28px;
  object-fit: cover;
  border: 1px solid var(--line2);
}

.gate-name {
  font-size: 30px;
  font-weight: 900;
  letter-spacing: 1px;
  margin-top: 16px;
}

.gate-sub {
  color: var(--muted);
  font-size: 13px;
  margin-top: 6px;
}

.gate-form { margin-top: 26px; display: grid; gap: 12px; }

.gate-error {
  margin-top: 14px;
  background: rgba(248, 138, 138, 0.1);
  border: 1px solid rgba(248, 138, 138, 0.35);
  color: var(--bad);
  border-radius: var(--r-pill);
  padding: 10px 16px;
  font-size: 13px;
}

/* ============================================================
   SHELL — sidebar + main
   ============================================================ */

.shell { display: flex; height: 100vh; }

.side {
  width: 262px;
  flex: 0 0 262px;
  background: var(--side);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  padding: 20px 14px;
  gap: 18px;
}

.side-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 10px;
  border-radius: var(--r-lg);
}

.side-logo {
  width: 46px;
  height: 46px;
  border-radius: 15px;
  object-fit: cover;
  border: 1px solid var(--line2);
}

.side-title {
  font-size: 21px;
  font-weight: 900;
  letter-spacing: 0.5px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.side-dot {
  width: 9px;
  height: 9px;
  border-radius: var(--r-pill);
  background: var(--faint);
}
.side-dot.on { background: var(--ok); }
.side-dot.busy { background: var(--warn); animation: breathe 1.6s ease-in-out infinite; }

@keyframes breathe { 50% { opacity: 0.35; } }

.side-nav { display: grid; gap: 6px; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: var(--r-pill);
  background: transparent;
  border: 1px solid transparent;
  color: var(--muted);
  font-size: 14.5px;
  cursor: pointer;
  text-align: left;
  transition: background 0.15s ease, color 0.15s ease;
}

.nav-item:hover { background: var(--card); color: var(--text); }

.nav-item.active {
  background: var(--accdeep);
  border-color: var(--accdeep);
  color: #fff;
}

.nav-item svg { width: 20px; height: 20px; flex: 0 0 20px; }

.side-foot {
  margin-top: auto;
  display: grid;
  gap: 10px;
  padding: 14px 12px;
  border-radius: var(--r-lg);
  background: var(--card);
  border: 1px solid var(--line);
}

.side-engine {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.4;
}

/* ---------- main ---------- */

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.view { display: none; flex-direction: column; height: 100%; min-height: 0; }
.view.active { display: flex; }

/* ---------- header bar ---------- */

.bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 18px 26px;
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}

.bar-title { font-size: 19px; font-weight: 900; }
.bar-sub { font-size: 12.5px; color: var(--muted); margin-top: 2px; }

.bar-right { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

/* ============================================================
   BUTTONS & PILLS — semua pill / membulat penuh
   ============================================================ */

.btn {
  border: 1px solid var(--line2);
  background: var(--card);
  color: var(--text);
  border-radius: var(--r-pill);
  padding: 11px 20px;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
}

.btn:hover { background: var(--card2); border-color: var(--acc); }
.btn:active { transform: translateY(1px); }

.btn-primary {
  background: var(--accdeep);
  border-color: var(--accdeep);
  color: #fff;
}
.btn-primary:hover { background: var(--acc); border-color: var(--acc); }

.btn-ghost { background: transparent; }
.btn-danger {
  background: rgba(248, 138, 138, 0.12);
  border-color: rgba(248, 138, 138, 0.4);
  color: var(--bad);
}
.btn-danger:hover { background: rgba(248, 138, 138, 0.2); border-color: var(--bad); }

.btn-small { padding: 8px 16px; font-size: 13px; }
.btn-block { width: 100%; }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border-radius: var(--r-pill);
  background: var(--card);
  border: 1px solid var(--line2);
  padding: 7px 14px;
  font-size: 12.5px;
  color: var(--muted);
  white-space: nowrap;
}

.pill-live { border-color: var(--acc); color: var(--text); background: var(--accsofter); }

.pulse {
  width: 8px;
  height: 8px;
  border-radius: var(--r-pill);
  background: var(--acc2);
  animation: breathe 1.4s ease-in-out infinite;
}

.pill .ok-dot { background: var(--ok); }
.pill .bad-dot { background: var(--bad); }

/* ============================================================
   INPUT
   ============================================================ */

.input {
  width: 100%;
  background: var(--deep);
  border: 1px solid var(--line2);
  border-radius: var(--r-pill);
  padding: 13px 20px;
  font-size: 14.5px;
  outline: none;
  transition: border-color 0.15s ease;
}
.input:focus { border-color: var(--acc); }

/* ============================================================
   CHAT
   ============================================================ */

.chat-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 26px 26px 12px;
  scroll-behavior: smooth;
}

.chat-list {
  max-width: 880px;
  margin: 0 auto;
  display: grid;
  gap: 18px;
}

/* pesan user */
.msg-user {
  justify-self: end;
  max-width: 78%;
  background: var(--accsoft);
  border: 1px solid rgba(139, 92, 246, 0.4);
  border-radius: 22px 22px 8px 22px;
  padding: 14px 20px;
  white-space: pre-wrap;
  word-break: break-word;
}

/* pesan agent */
.msg-agent {
  display: flex;
  gap: 14px;
  max-width: 100%;
}

.agent-avatar {
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  border-radius: 14px;
  object-fit: cover;
  border: 1px solid var(--line2);
  margin-top: 2px;
}

.agent-body { flex: 1; min-width: 0; display: grid; gap: 10px; }

.agent-name { font-size: 12.5px; color: var(--faint); display: flex; gap: 10px; align-items: center; }

.agent-text {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 20px 20px 20px 8px;
  padding: 14px 20px;
  white-space: pre-wrap;
  word-break: break-word;
}

.agent-text.live { border-color: var(--line2); }

.agent-text code, .tool-out code {
  font-family: var(--mono);
  font-size: 13px;
  background: var(--deep);
  border-radius: 8px;
  padding: 1px 7px;
}

.agent-text pre {
  font-family: var(--mono);
  font-size: 13px;
  background: var(--deep);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px 16px;
  overflow-x: auto;
  white-space: pre;
}

/* laporan akhir */
.msg-report .agent-text {
  background: linear-gradient(180deg, rgba(139,92,246,0.09), rgba(139,92,246,0.03)), var(--card);
  border-color: var(--line2);
}

.report-tag {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--accsoft);
  border: 1px solid rgba(139, 92, 246, 0.4);
  color: var(--acc2);
  border-radius: var(--r-pill);
  padding: 5px 14px;
  font-size: 12px;
}

/* penalaran (muted, bisa dilipat) */
.think-block {
  border: 1px dashed var(--line2);
  border-radius: var(--r-lg);
  padding: 10px 16px;
  color: var(--muted);
  font-size: 13px;
}

.think-toggle {
  background: none;
  border: none;
  color: var(--faint);
  font-size: 12px;
  cursor: pointer;
  padding: 0;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: var(--r-pill);
}
.think-toggle:hover { color: var(--acc2); }

.think-content {
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 180px;
  overflow-y: auto;
  margin-top: 8px;
  opacity: 0.85;
}

/* chip alat */
.tool-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  background: var(--card2);
  border: 1px solid var(--line2);
  border-radius: var(--r-pill);
  padding: 9px 16px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text);
  transition: border-color 0.15s ease;
  width: fit-content;
  max-width: 100%;
}
.tool-chip:hover { border-color: var(--acc); }

.tool-chip .tool-name { color: var(--acc2); }
.tool-chip .tool-arg {
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 380px;
  font-family: var(--mono);
  font-size: 12px;
}
.tool-chip .tool-ms { color: var(--faint); font-size: 12px; margin-left: auto; }
.tool-chip.ok .tool-name::before { content: ""; }
.tool-chip.fail { border-color: rgba(248, 138, 138, 0.5); }
.tool-chip.fail .tool-name { color: var(--bad); }

.tool-out {
  margin-top: 8px;
  background: var(--deep);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 14px 16px;
  font-family: var(--mono);
  font-size: 12.5px;
  color: #c8bbee;
  max-height: 300px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

/* error */
.msg-error {
  background: rgba(248, 138, 138, 0.08);
  border: 1px solid rgba(248, 138, 138, 0.35);
  color: var(--bad);
  border-radius: var(--r-lg);
  padding: 12px 18px;
  font-size: 13.5px;
}

/* status kecil saat menunggu */
.hint-row { color: var(--faint); font-size: 13px; padding: 4px 8px; }

/* ---------- composer ---------- */

.composer-wrap { padding: 14px 26px 20px; }

.composer {
  max-width: 880px;
  margin: 0 auto;
  display: flex;
  align-items: flex-end;
  gap: 12px;
  background: var(--card);
  border: 1px solid var(--line2);
  border-radius: 26px;
  padding: 10px 10px 10px 22px;
  transition: border-color 0.15s ease;
}
.composer:focus-within { border-color: var(--acc); }

.composer-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  resize: none;
  font-size: 14.5px;
  line-height: 1.5;
  max-height: 160px;
  padding: 8px 0;
}

.send-btn {
  width: 46px;
  height: 46px;
  border-radius: var(--r-pill);
  border: none;
  background: var(--accdeep);
  color: #fff;
  cursor: pointer;
  display: grid;
  place-items: center;
  flex: 0 0 46px;
  transition: background 0.15s ease;
}
.send-btn:hover { background: var(--acc); }
.send-btn:disabled { opacity: 0.45; cursor: default; }
.send-btn svg { width: 20px; height: 20px; }

.composer-hint {
  max-width: 880px;
  margin: 10px auto 0;
  text-align: center;
  color: var(--faint);
  font-size: 12px;
}

/* ============================================================
   PANE (riwayat, browser, tools, terminal)
   ============================================================ */

.pane-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 24px 26px 40px;
}

.cards {
  max-width: 880px;
  margin: 0 auto;
  display: grid;
  gap: 14px;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-xl);
  padding: 20px 22px;
}

.card-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.card-title { font-size: 15px; font-weight: 800; }
.card-sub { font-size: 12.5px; color: var(--muted); margin-top: 3px; }

.card-actions { display: flex; gap: 8px; }

.badge-run {
  border-radius: var(--r-pill);
  background: var(--accsofter);
  border: 1px solid var(--acc);
  color: var(--acc2);
  font-size: 11.5px;
  padding: 4px 12px;
}

.section-title {
  max-width: 880px;
  margin: 26px auto 12px;
  font-size: 13px;
  color: var(--faint);
  text-transform: uppercase;
  letter-spacing: 1.2px;
}
.pane-scroll > .section-title:first-child { margin-top: 0; }

/* ---------- browser mcp ---------- */

.browser-live {
  max-width: 880px;
  margin: 0 auto;
  display: grid;
  gap: 8px;
}

.browser-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 12px 18px;
  font-size: 13.5px;
}

.browser-item .b-act {
  color: var(--acc2);
  background: var(--accsofter);
  border-radius: var(--r-pill);
  padding: 3px 12px;
  font-size: 11.5px;
  white-space: nowrap;
}

.browser-item .b-url {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 12.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  min-width: 0;
}

.browser-item .b-time { color: var(--faint); font-size: 11.5px; white-space: nowrap; }

.shots {
  max-width: 880px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px;
}

.shot-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-xl);
  padding: 10px;
  display: grid;
  gap: 8px;
}

.shot-card img {
  width: 100%;
  border-radius: 14px;
  display: block;
  border: 1px solid var(--line);
}

.shot-name {
  font-size: 11.5px;
  color: var(--muted);
  font-family: var(--mono);
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------- tools ---------- */

.stat-row {
  max-width: 880px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
}

.stat-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-xl);
  padding: 18px 20px;
}

.stat-num { font-size: 26px; font-weight: 900; color: var(--acc2); }
.stat-label { font-size: 12px; color: var(--muted); margin-top: 2px; }

.engine-card {
  max-width: 880px;
  margin: 0 auto;
  background: linear-gradient(180deg, rgba(139,92,246,0.08), transparent), var(--card);
  border: 1px solid var(--line2);
  border-radius: var(--r-xl);
  padding: 22px 24px;
  display: grid;
  gap: 10px;
}

.engine-line { display: flex; gap: 10px; align-items: center; font-size: 13.5px; flex-wrap: wrap; }
.engine-line .k { color: var(--faint); min-width: 110px; }

.tools-groups {
  max-width: 880px;
  margin: 0 auto;
  display: grid;
  gap: 14px;
}

.tool-group { background: var(--card); border: 1px solid var(--line); border-radius: var(--r-xl); padding: 18px 20px; }
.tool-group-title { font-size: 13px; color: var(--acc2); margin-bottom: 12px; }

.tool-item {
  display: flex;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}
.tool-item:last-child { border-bottom: none; }
.tool-item .t-name {
  font-family: var(--mono);
  color: var(--text);
  white-space: nowrap;
  font-size: 12.5px;
  min-width: 170px;
}
.tool-item .t-desc { color: var(--muted); }

.activity-list { max-width: 880px; margin: 0 auto; display: grid; gap: 8px; }

.act-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 11px 18px;
  font-size: 13px;
}

.act-item .a-title { color: var(--text); white-space: nowrap; }
.act-item .a-detail {
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  min-width: 0;
  font-size: 12px;
  font-family: var(--mono);
}
.act-item .a-time { color: var(--faint); font-size: 11.5px; white-space: nowrap; }

/* ---------- output terminal ---------- */

.term-feed {
  max-width: 920px;
  margin: 0 auto;
  display: grid;
  gap: 12px;
}

.term-item {
  background: var(--deep);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  overflow: hidden;
}

.term-head {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
  font-size: 12.5px;
}

.term-name { color: var(--acc2); }
.term-arg {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  min-width: 120px;
}
.term-meta { color: var(--faint); font-size: 11.5px; white-space: nowrap; margin-left: auto; }

.term-body {
  font-family: var(--mono);
  font-size: 12.5px;
  color: #c8bbee;
  padding: 14px 16px;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 340px;
  overflow-y: auto;
}

.term-empty { color: var(--faint); text-align: center; padding: 60px 20px; font-size: 14px; }

/* ---------- empty states ---------- */

.empty {
  max-width: 880px;
  margin: 0 auto;
  text-align: center;
  color: var(--muted);
  padding: 44px 20px;
  background: var(--card);
  border: 1px dashed var(--line2);
  border-radius: var(--r-xl);
  font-size: 14px;
}

.empty img { width: 72px; height: 72px; border-radius: 22px; margin-bottom: 14px; opacity: 0.9; }

/* ============================================================
   RESPONSIVE — mobile (bottom nav)
   ============================================================ */

@media (max-width: 880px) {
  .shell { flex-direction: column; }

  .side {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    top: auto;
    width: 100%;
    flex: 0 0 auto;
    flex-direction: row;
    align-items: center;
    padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
    border-right: none;
    border-top: 1px solid var(--line);
    gap: 4px;
    z-index: 50;
  }

  .side-brand, .side-foot { display: none; }

  .side-nav { display: flex; gap: 2px; width: 100%; }

  .nav-item {
    flex: 1;
    flex-direction: column;
    gap: 3px;
    padding: 8px 4px;
    font-size: 10.5px;
    text-align: center;
    border-radius: var(--r-lg);
    min-width: 0;
  }
  .nav-item svg { width: 21px; height: 21px; flex: 0 0 21px; }
  .nav-item.active { color: var(--acc2); background: var(--accsofter); border-color: transparent; }

  .main { padding-bottom: 78px; height: 100vh; }

  .bar { padding: 14px 16px; }
  .pane-scroll { padding: 16px 14px 120px; }
  .chat-scroll { padding: 16px 14px 8px; }
  .composer-wrap { padding: 8px 14px 16px; }
  .composer { border-radius: 24px; }

  .msg-user { max-width: 92%; }
  .tool-chip .tool-arg { max-width: 160px; }
  .bar-title { font-size: 17px; }
  .tool-item { flex-direction: column; gap: 4px; }
  .tool-item .t-name { min-width: 0; }
}

@media (min-width: 881px) {
  .mobile-brand { display: none; }
}
