:root {
  --bg: #f4f2ee;
  --panel: #ffffff;
  --ink: #14110f;
  --ink-2: #4a443e;
  --muted: #8b837a;
  --line: rgba(20, 17, 15, 0.09);
  --line-strong: rgba(20, 17, 15, 0.16);
  --accent: #0b5cff;
  --accent-soft: #e8efff;
  --ok: #0f9d58;
  --warn: #b26b00;
  --danger: #d33a2c;
  --radius: 18px;
  --shadow: 0 1px 2px rgba(20, 17, 15, 0.06), 0 12px 32px -12px rgba(20, 17, 15, 0.18);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
}

body { overflow: hidden; }

button { font: inherit; cursor: pointer; }

/* ------------------------------- app shell -------------------------------- */

.app {
  display: grid;
  grid-template-columns: 268px minmax(0, 1fr) 400px;
  height: 100vh;
  height: 100dvh;
}

/* -------------------------------- sidebar --------------------------------- */

.sidebar {
  border-right: 1px solid var(--line);
  background: #efece6;
  display: flex;
  flex-direction: column;
  padding: 18px 14px;
  gap: 14px;
  min-height: 0;
}

.brand { display: flex; align-items: center; gap: 10px; padding: 2px 6px; }
.brand .name { font-weight: 650; letter-spacing: -0.02em; font-size: 17px; }
.brand .tag { font-size: 10.5px; color: var(--muted); letter-spacing: .04em; text-transform: uppercase; }

.orb {
  width: 26px; height: 26px; border-radius: 50%;
  background: conic-gradient(from 210deg, #58c7ff, #6a5cff, #ff6ac1, #ffb86b, #58c7ff);
  box-shadow: inset -3px -4px 8px rgba(0,0,0,.28), 0 0 0 1px rgba(255,255,255,.5), 0 4px 12px -2px rgba(106,92,255,.5);
  animation: spin 9s linear infinite;
  flex: none;
}
@keyframes spin { to { transform: rotate(360deg); } }

.new-chat {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; padding: 11px 14px; border-radius: 13px; border: 1px solid var(--line-strong);
  background: var(--panel); color: var(--ink); font-weight: 550; font-size: 14px;
  transition: .15s;
}
.new-chat:hover { background: #fff; box-shadow: var(--shadow); transform: translateY(-1px); }

.section-label {
  font-size: 11px; text-transform: uppercase; letter-spacing: .08em;
  color: var(--muted); font-weight: 600; padding: 4px 8px 2px;
}

.thread-list { display: flex; flex-direction: column; gap: 2px; overflow-y: auto; min-height: 0; }
.thread-item {
  text-align: left; border: 0; background: transparent; padding: 9px 10px; border-radius: 10px;
  font-size: 13.5px; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.thread-item:hover { background: rgba(20,17,15,.05); }
.thread-item.active { background: var(--panel); color: var(--ink); font-weight: 550; box-shadow: var(--shadow); }

.spacer { flex: 1; }

.connectors { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 6px; }
.conn {
  display: flex; align-items: center; gap: 5px; font-size: 11.5px; color: var(--ink-2);
  background: rgba(255,255,255,.7); border: 1px solid var(--line); border-radius: 999px; padding: 4px 9px 4px 6px;
}
.conn i { width: 7px; height: 7px; border-radius: 50%; display: block; }
.conn.off { opacity: .45; text-decoration: line-through; }

.plan-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 12px;
  display: flex; flex-direction: column; gap: 8px;
}
.plan-card .row { display: flex; align-items: center; justify-content: space-between; font-size: 12.5px; }
.plan-card .pill { background: var(--accent-soft); color: var(--accent); font-weight: 600; padding: 2px 8px; border-radius: 999px; font-size: 11px; }
.usage { height: 5px; border-radius: 99px; background: rgba(20,17,15,.09); overflow: hidden; }
.usage > i { display: block; height: 100%; background: linear-gradient(90deg, #6a5cff, #0b5cff); border-radius: 99px; }
.plan-card small { color: var(--muted); font-size: 11px; }

.me { display: flex; align-items: center; gap: 9px; padding: 6px 8px; }
.avatar {
  width: 28px; height: 28px; border-radius: 50%; background: #14110f; color: #fff;
  display: grid; place-items: center; font-size: 12px; font-weight: 600;
}
.me .who { font-size: 13px; font-weight: 550; }
.me .sub { font-size: 11px; color: var(--muted); }

/* ---------------------------------- chat ---------------------------------- */

.chat { display: flex; flex-direction: column; min-height: 0; background: var(--bg); }

.chat-head {
  display: flex; align-items: center; gap: 10px; padding: 14px 22px;
  border-bottom: 1px solid var(--line); backdrop-filter: blur(8px);
}
.chat-head h1 { font-size: 15px; margin: 0; letter-spacing: -0.01em; }
.chat-head .sub { font-size: 11.5px; color: var(--muted); display: flex; align-items: center; gap: 5px; }
.live-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 3px rgba(15,157,88,.16); }
.chat-head .right { margin-left: auto; display: flex; gap: 6px; }
.ghost-btn {
  border: 1px solid var(--line-strong); background: transparent; color: var(--ink-2);
  border-radius: 10px; padding: 7px 11px; font-size: 12.5px;
}
.ghost-btn:hover { background: rgba(255,255,255,.7); }
.ghost-btn:disabled { opacity: .4; cursor: default; }

.thread {
  flex: 1; overflow-y: auto; padding: 26px 22px 10px; display: flex; flex-direction: column; gap: 16px;
  scroll-behavior: smooth;
}
.thread > * { max-width: 760px; width: 100%; margin: 0 auto; }

.empty { text-align: center; padding: 8vh 0 0; }
.empty .orb { width: 54px; height: 54px; margin: 0 auto 18px; }
.empty h2 { font-size: 26px; margin: 0 0 6px; letter-spacing: -0.03em; }
.empty p { color: var(--muted); margin: 0 auto; max-width: 420px; font-size: 14px; line-height: 1.5; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 22px; }
.chip {
  border: 1px solid var(--line-strong); background: var(--panel); border-radius: 999px;
  padding: 8px 13px; font-size: 13px; color: var(--ink-2);
}
.chip:hover { border-color: var(--accent); color: var(--accent); }

.msg { display: flex; gap: 11px; }
.msg.user { justify-content: flex-end; }
.msg.user .bubble {
  background: #14110f; color: #fff; border-radius: 16px 16px 4px 16px; padding: 10px 14px;
  font-size: 14.5px; line-height: 1.5; max-width: 78%;
}
.msg.assistant .bubble {
  background: var(--panel); border: 1px solid var(--line); border-radius: 16px 16px 16px 4px;
  padding: 12px 15px; font-size: 14.5px; line-height: 1.6; box-shadow: var(--shadow); white-space: pre-wrap;
}
.msg .orb { width: 26px; height: 26px; margin-top: 2px; }

.typing { display: inline-flex; gap: 4px; padding: 3px 2px; }
.typing i { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); animation: bob 1.1s infinite; }
.typing i:nth-child(2) { animation-delay: .15s; }
.typing i:nth-child(3) { animation-delay: .3s; }
@keyframes bob { 0%,60%,100% { transform: translateY(0); opacity: .45 } 30% { transform: translateY(-4px); opacity: 1 } }

/* plan / task card */
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden;
}
.card-head { display: flex; align-items: center; gap: 9px; padding: 13px 15px; border-bottom: 1px solid var(--line); }
.card-head .t { font-size: 13.5px; font-weight: 600; }
.card-head .badge {
  margin-left: auto; font-size: 11px; font-weight: 600; padding: 3px 8px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent);
}
.card-head .badge.done { background: rgba(15,157,88,.12); color: var(--ok); }
.card-head .badge.declined { background: rgba(211,58,44,.1); color: var(--danger); }

.steps { padding: 6px 4px 8px; }
.step { display: flex; align-items: flex-start; gap: 10px; padding: 7px 12px; font-size: 13.5px; color: var(--muted); }
.step .mark {
  width: 16px; height: 16px; border-radius: 50%; border: 1.5px solid var(--line-strong);
  flex: none; margin-top: 1px; display: grid; place-items: center; font-size: 9px; color: #fff;
}
.step.active { color: var(--ink); }
.step.active .mark { border-color: var(--accent); border-right-color: transparent; animation: spin .7s linear infinite; }
.step.done { color: var(--ink-2); }
.step.done .mark { background: var(--ok); border-color: var(--ok); }
.step.done .mark::after { content: "✓"; font-size: 10px; }
.step.waiting { color: var(--warn); font-weight: 550; }
.step.waiting .mark { border-color: var(--warn); background: rgba(178,107,0,.12); }
.step.approved { color: var(--ink-2); }
.step.approved .mark { background: var(--ok); border-color: var(--ok); }
.step.approved .mark::after { content: "✓"; font-size: 10px; color: #fff; }
.step.declined { color: var(--danger); }
.step.declined .mark { background: var(--danger); border-color: var(--danger); }
.step.declined .mark::after { content: "×"; font-size: 10px; color: #fff; }
.step .lbl { line-height: 1.45; }

/* result card */
.result .card-head { background: linear-gradient(180deg, rgba(15,157,88,.07), transparent); }
.result .rows { padding: 10px 15px 14px; display: flex; flex-direction: column; gap: 7px; }
.result .row { display: flex; justify-content: space-between; font-size: 13px; }
.result .row .k { color: var(--muted); }
.result .row .v { font-weight: 550; }
.result .sub { font-size: 12.5px; color: var(--muted); padding: 0 15px 12px; margin-top: -4px; }

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

.composer-wrap { padding: 10px 22px 20px; }
.composer {
  max-width: 760px; margin: 0 auto; background: var(--panel); border: 1px solid var(--line-strong);
  border-radius: 20px; padding: 10px 10px 8px 14px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 6px; transition: border-color .15s;
}
.composer:focus-within { border-color: rgba(11,92,255,.5); }
.composer textarea {
  border: 0; outline: 0; resize: none; font: inherit; font-size: 14.5px; line-height: 1.5;
  background: transparent; color: var(--ink); max-height: 140px; padding: 4px 2px;
}
.composer .row { display: flex; align-items: center; gap: 8px; }
.composer .hint { font-size: 11px; color: var(--muted); margin-right: auto; }
.send {
  width: 34px; height: 34px; border-radius: 50%; border: 0; background: var(--ink); color: #fff;
  display: grid; place-items: center; transition: .15s;
}
.send:hover { background: var(--accent); }
.send:disabled { opacity: .35; background: var(--ink); }
.stop {
  border: 1px solid var(--line-strong); background: transparent; border-radius: 999px;
  font-size: 12px; padding: 6px 11px; display: none; align-items: center; gap: 6px;
}
.stop.on { display: inline-flex; }
.stop i { width: 8px; height: 8px; background: var(--danger); border-radius: 2px; display: block; }

/* ------------------------------ secure VM -------------------------------- */

.vm {
  border-left: 1px solid var(--line); background: #e9e5de; display: flex; flex-direction: column;
  min-height: 0; padding: 14px; gap: 12px;
}
.vm-head { display: flex; align-items: center; gap: 8px; padding: 0 2px; }
.vm-head .t { font-size: 12.5px; font-weight: 650; letter-spacing: -0.01em; }
.vm-head .lock { margin-left: auto; font-size: 10.5px; color: var(--muted); display: flex; align-items: center; gap: 4px; }

.browser {
  background: var(--panel); border: 1px solid var(--line-strong); border-radius: 14px;
  overflow: hidden; display: flex; flex-direction: column; flex: 1; min-height: 0; box-shadow: var(--shadow);
}
.browser-bar {
  display: flex; align-items: center; gap: 7px; padding: 9px 10px; background: #f7f5f1;
  border-bottom: 1px solid var(--line);
}
.browser-bar .dots { display: flex; gap: 4px; }
.browser-bar .dots i { width: 8px; height: 8px; border-radius: 50%; background: #d6d1c9; display: block; }
.browser-bar .url {
  flex: 1; background: #edeae4; border-radius: 7px; padding: 4px 9px; font-size: 11px; color: var(--ink-2);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.browser-body { flex: 1; overflow-y: auto; padding: 14px; font-size: 12.5px; }

.vm-idle { height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; color: var(--muted); text-align: center; padding: 0 20px; }
.vm-idle svg { opacity: .4; }

/* fake web pages */
.page-site { font-size: 10.5px; color: var(--muted); text-transform: lowercase; margin-bottom: 8px; letter-spacing: .02em; }
.page-title { font-size: 14px; font-weight: 650; margin-bottom: 10px; letter-spacing: -0.01em; }
.field { display: flex; justify-content: space-between; gap: 10px; padding: 8px 10px; background: #f7f5f1; border-radius: 9px; margin-bottom: 6px; font-size: 12px; }
.field .k { color: var(--muted); }
.field .v { font-weight: 550; text-align: right; }
.item {
  display: flex; align-items: center; gap: 9px; padding: 9px 10px; border: 1px solid var(--line);
  border-radius: 10px; margin-bottom: 7px; background: #fff;
}
.item .main { font-size: 12.5px; font-weight: 600; }
.item .sub { font-size: 11px; color: var(--muted); margin-top: 1px; }
.item .price { margin-left: auto; font-size: 12px; font-weight: 650; white-space: nowrap; }
.item .badge { font-size: 9.5px; font-weight: 700; color: var(--ok); background: rgba(15,157,88,.1); border-radius: 5px; padding: 2px 5px; }
.pay {
  margin-top: 10px; background: var(--ink); color: #fff; text-align: center; border-radius: 10px;
  padding: 10px; font-size: 12.5px; font-weight: 600;
}
.pay-note { font-size: 10.5px; color: var(--muted); margin-top: 7px; line-height: 1.4; }
.total { display: flex; justify-content: space-between; padding: 10px 0 2px; border-top: 1px dashed var(--line-strong); margin-top: 8px; font-weight: 650; font-size: 13px; }
.compose-body {
  white-space: pre-wrap; font-size: 11.5px; line-height: 1.6; color: var(--ink-2);
  background: #f7f5f1; border-radius: 10px; padding: 10px; margin-top: 8px; max-height: 170px; overflow: auto;
}
.ok-banner {
  display: flex; align-items: center; gap: 8px; background: rgba(15,157,88,.1); color: #0b6b3d;
  border-radius: 10px; padding: 10px; font-weight: 600; font-size: 12.5px; margin-bottom: 10px;
}
.cal { display: grid; grid-template-columns: repeat(5, 1fr); gap: 5px; }
.cal .day { font-size: 10px; text-align: center; color: var(--muted); font-weight: 600; margin-bottom: 4px; }
.cal .slot {
  background: #f2efe9; border-radius: 6px; padding: 5px 4px; font-size: 9.5px; line-height: 1.25;
  margin-bottom: 4px; color: var(--ink-2); border-left: 2px solid transparent;
}
.cal .slot b { display: block; font-size: 9px; color: var(--muted); font-weight: 600; }
.cal .slot.moved { background: var(--accent-soft); border-left-color: var(--accent); }

.vm-log {
  background: #17141a; color: #cfc9d6; border-radius: 12px; padding: 10px 12px; font-size: 11px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; height: 116px; overflow-y: auto;
  display: flex; flex-direction: column-reverse; gap: 3px; flex: none;
}
.vm-log .ln { display: flex; gap: 7px; opacity: 0; animation: fade .3s forwards; }
.vm-log .ln .ts { color: #6d6579; flex: none; }
@keyframes fade { to { opacity: 1 } }

/* ------------------------------- approval -------------------------------- */

.scrim {
  position: fixed; inset: 0; background: rgba(20,17,15,.42); backdrop-filter: blur(3px);
  display: none; align-items: flex-end; justify-content: center; z-index: 40; padding: 20px;
}
.scrim.on { display: flex; }
.sheet {
  width: 100%; max-width: 460px; background: var(--panel); border-radius: 22px; padding: 20px;
  box-shadow: 0 24px 64px -12px rgba(0,0,0,.5); animation: rise .22s ease-out; margin-bottom: 4vh;
}
@keyframes rise { from { transform: translateY(16px); opacity: 0 } }
.sheet .kicker { display: flex; align-items: center; gap: 7px; font-size: 11px; text-transform: uppercase; letter-spacing: .07em; color: var(--warn); font-weight: 700; }
.sheet h3 { margin: 8px 0 6px; font-size: 18px; letter-spacing: -0.02em; }
.sheet .amount { font-size: 26px; font-weight: 700; letter-spacing: -0.03em; margin: 4px 0 10px; }
.sheet p { color: var(--ink-2); font-size: 13.5px; line-height: 1.55; margin: 0 0 12px; }
.sheet .preview { background: #f7f5f1; border-radius: 10px; padding: 10px 12px; font-size: 12.5px; color: var(--ink-2); margin-bottom: 12px; }
.sheet .safety { display: flex; gap: 8px; font-size: 11.5px; color: var(--muted); line-height: 1.45; margin-bottom: 16px; }
.sheet .actions { display: flex; gap: 8px; }
.btn { flex: 1; border-radius: 12px; padding: 12px; font-size: 14px; font-weight: 600; border: 1px solid transparent; }
.btn.primary { background: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.07); }
.btn.secondary { background: transparent; border-color: var(--line-strong); color: var(--ink-2); }

/* -------------------------------- mobile --------------------------------- */

.mobile-tabs { display: none; }

@media (max-width: 1180px) {
  .app { grid-template-columns: 240px minmax(0, 1fr); }
  .vm {
    position: fixed; inset: 0 0 0 auto; width: min(420px, 96vw); z-index: 30;
    transform: translateX(102%); transition: transform .24s ease; box-shadow: -20px 0 60px rgba(0,0,0,.2);
  }
  .vm.open { transform: none; }
}

@media (max-width: 860px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: fixed; inset: 0 auto 0 0; width: 280px; z-index: 35; transform: translateX(-102%);
    transition: transform .24s ease;
  }
  .sidebar.open { transform: none; }
  .chat-head { padding: 12px 14px; }
  .thread { padding: 18px 14px 8px; }
  .composer-wrap { padding: 8px 12px 12px; }
  .empty { padding-top: 4vh; }
  .empty h2 { font-size: 22px; }
  .mobile-tabs { display: flex; }
}

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: rgba(20,17,15,.16); border-radius: 99px; }
::-webkit-scrollbar-track { background: transparent; }

/* ------------------------- form pengaturan provider ----------------------- */

.seg {
  display: flex;
  gap: 4px;
  background: #f2efe9;
  border-radius: 12px;
  padding: 4px;
  margin: 4px 0 14px;
}
.seg button {
  flex: 1;
  border: 0;
  background: transparent;
  border-radius: 9px;
  padding: 9px;
  font-size: 13px;
  font-weight: 550;
  color: var(--ink-2);
}
.seg button.on {
  background: var(--panel);
  color: var(--ink);
  box-shadow: 0 1px 2px rgba(20, 17, 15, 0.12);
}

.sheet .form { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.sheet .form label { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; margin-top: 4px; }
.sheet .form input,
.sheet .form select {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  padding: 10px 12px;
  font: inherit;
  font-size: 13.5px;
  color: var(--ink);
  background: #fbfaf8;
  outline: none;
}
.sheet .form input:focus,
.sheet .form select:focus { border-color: rgba(11, 92, 255, 0.55); background: #fff; }

.sheet .status { min-height: 16px; font-size: 12px; color: var(--muted); margin-bottom: 10px; line-height: 1.4; }
.sheet .status.ok { color: var(--ok); }
.sheet .status.bad { color: var(--danger); }
.sheet .safety code { background: rgba(20,17,15,.06); padding: 1px 4px; border-radius: 4px; font-size: 11px; }
