:root {
  /* Palet Simontov: biru brand #0056b3, abu-abu netral, amber dari logo. */
  --bg: #f9fafb;
  --surface: #ffffff;
  --surface-2: #f3f4f6;
  --border: #e5e7eb;
  --text: #111827;
  --muted: #6b7280;
  --accent: #0056b3;
  --accent-text: #ffffff;
  --accent-soft: #e3eefa;
  --brand-amber: #f8a93f;
  --danger: #b42318;
  --danger-soft: #fdecea;
  --ok: #1a7f37;
  --warn-soft: #fff6dd;
  --radius: 10px;
  --sidebar: 288px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111827;
    --surface: #1f2937;
    --surface-2: #283344;
    --border: #374151;
    --text: #f3f4f6;
    --muted: #9ca3af;
    --accent: #60a5fa;
    --accent-text: #0b1220;
    --accent-soft: #1e3a5f;
    --danger: #ff8a80;
    --danger-soft: #3a1f1d;
    --ok: #56d364;
    --warn-soft: #3a3320;
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
#app { height: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }

/* ---------- Kontrol dasar ---------- */
.btn {
  border: 1px solid var(--border);
  background: var(--surface);
  padding: 7px 14px;
  border-radius: 8px;
  cursor: pointer;
  line-height: 1.3;
}
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--danger); }
.btn.block { width: 100%; }
.btn.small { padding: 4px 10px; font-size: 13px; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--surface-2); }

label.field { display: block; margin-bottom: 14px; }
label.field > span { display: block; font-size: 13px; font-weight: 600; margin-bottom: 4px; color: var(--muted); }
.input, label.field input, label.field select, label.field textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}
label.field textarea { min-height: 110px; resize: vertical; }
.input:focus, label.field input:focus, label.field select:focus, label.field textarea:focus, .composer textarea:focus {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
}
.hint { font-size: 12.5px; color: var(--muted); margin: -8px 0 14px; }
.error-text { color: var(--danger); font-size: 13.5px; margin: 6px 0 0; min-height: 1.4em; }

/* ---------- Layar login ---------- */
.auth-wrap { min-height: 100%; display: grid; place-items: center; padding: 24px; }
.auth-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 28px;
}
.auth-card h1 { margin: 0 0 4px; font-size: 20px; }
.auth-card p.sub { margin: 0 0 22px; color: var(--muted); font-size: 14px; text-align: center; }
.auth-card .btn.primary { width: 100%; padding: 10px; margin-top: 4px; }

/* ---------- Kerangka aplikasi ---------- */
.shell { display: grid; grid-template-columns: var(--sidebar) 1fr; height: 100%; }
.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  min-height: 0;
}
/* Logo Simontov: varian teks hitam untuk tema terang, teks putih untuk tema gelap. */
.brand { padding: 20px 16px 14px; display: flex; align-items: center; }
.logo { display: inline-flex; align-items: center; gap: 10px; }
.logo img { display: block; height: 30px; width: auto; }
/* "Agent": teks halus di samping logo, dipisah garis tipis (bukan lencana, agar tidak bersaing dengan logo). */
.logo-tag { font-size: 14px; font-weight: 500; letter-spacing: 0.01em; color: var(--muted); border-left: 1px solid color-mix(in srgb, var(--muted) 45%, transparent); padding-left: 10px; line-height: 20px; }
.logo .logo-dark { display: none; }
@media (prefers-color-scheme: dark) {
  .logo .logo-light { display: none; }
  .logo .logo-dark { display: block; }
}
.auth-card .logo { display: flex; justify-content: center; margin-bottom: 8px; }
.auth-card .logo img { height: 40px; }
.auth-card .logo-tag { font-size: 16px; line-height: 26px; padding-left: 12px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.side-section { padding: 10px 12px; min-height: 0; }
.side-section .btn.block { margin-bottom: 12px; }
.side-section.grow { flex: 1; overflow-y: auto; }
.side-title {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--muted); padding: 8px 10px 6px;
}
.nav-item {
  display: flex; align-items: center; gap: 8px; width: 100%;
  text-align: left; padding: 9px 12px; border: 0; border-radius: 8px;
  background: transparent; cursor: pointer; overflow: hidden;
}
.nav-item + .nav-item { margin-top: 3px; }
.nav-item:hover { background: var(--surface-2); }
.nav-item.active { background: var(--accent-soft); font-weight: 600; box-shadow: inset 3px 0 0 var(--brand-amber); }
.nav-item .label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-item .tag { font-size: 11px; color: var(--muted); }
.nav-item .del { visibility: hidden; border: 0; background: transparent; color: var(--muted); cursor: pointer; padding: 0 4px; font-size: 16px; line-height: 1; }
.nav-item:hover .del { visibility: visible; }
.nav-item .del:hover { color: var(--danger); }
.empty-note { color: var(--muted); font-size: 13.5px; padding: 6px 12px; }
.side-footer { border-top: 1px solid var(--border); padding: 10px; display: flex; align-items: center; gap: 8px; }
.side-footer .who { flex: 1; min-width: 0; }
.side-footer .who b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.side-footer .who small { color: var(--muted); }

.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.topbar {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 18px; border-bottom: 1px solid var(--border); background: var(--surface);
}
.topbar h2 { margin: 0; font-size: 16px; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar .status-pill { font-size: 12px; padding: 2px 8px; border-radius: 99px; background: var(--surface-2); color: var(--muted); }
.menu-btn { display: none; }

.messages { flex: 1; overflow-y: auto; padding: 22px 0 8px; }
.thread { max-width: 780px; margin: 0 auto; padding: 0 18px; }
.empty-state { text-align: center; color: var(--muted); padding: 12vh 12px 0; }
.empty-state h3 { color: var(--text); margin: 0 0 6px; font-size: 20px; }
.empty-state p { max-width: 520px; margin: 6px auto; }

.msg { margin: 0 0 20px; }
.msg.user { display: flex; justify-content: flex-end; }
.msg.user .bubble {
  background: var(--accent); color: var(--accent-text);
  border-radius: 14px 14px 4px 14px; padding: 9px 14px; max-width: 85%;
  white-space: pre-wrap; overflow-wrap: anywhere;
}
.msg.assistant .bubble { overflow-wrap: anywhere; }
.msg-tools { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 8px; }
.chip { font-size: 12px; padding: 2px 9px; border-radius: 99px; background: var(--surface-2); color: var(--muted); }
.chip.running::before {
  content: ""; display: inline-block; width: 8px; height: 8px; margin-right: 6px;
  border-radius: 50%; border: 2px solid var(--muted); border-top-color: transparent;
  animation: spin 0.8s linear infinite; vertical-align: -1px;
}
@keyframes spin { to { transform: rotate(360deg); } }
.notice { margin-top: 8px; padding: 8px 12px; border-radius: 8px; background: var(--warn-soft); font-size: 13.5px; }
.msg-error { margin-top: 8px; padding: 8px 12px; border-radius: 8px; background: var(--danger-soft); color: var(--danger); font-size: 13.5px; }
.cursor::after { content: "▍"; animation: blink 1s steps(2) infinite; margin-left: 1px; color: var(--muted); }
@keyframes blink { 50% { opacity: 0; } }

.msg-actions { display: flex; align-items: center; gap: 4px; margin-top: 6px; }
.msg-actions .btn { padding: 2px 9px; font-size: 12.5px; color: var(--muted); }
.msg-actions .btn.on { background: var(--accent-soft); color: var(--text); border-color: var(--accent); }
details.sources { margin-top: 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); }
details.sources > summary { cursor: pointer; padding: 7px 12px; font-size: 13.5px; color: var(--muted); }
.source { padding: 8px 12px; border-top: 1px solid var(--border); font-size: 13.5px; }
.source.flash { background: var(--accent-soft); }
.source .ref { display: inline-block; min-width: 1.6em; font-weight: 700; color: var(--accent); }
.source .meta { color: var(--muted); font-size: 12.5px; }

/* markdown */
.md > :first-child { margin-top: 0; }
.md > :last-child { margin-bottom: 0; }
.md p { margin: 0 0 10px; }
.md h3, .md h4, .md h5 { margin: 16px 0 6px; line-height: 1.3; }
.md h3 { font-size: 17px; } .md h4 { font-size: 15.5px; } .md h5 { font-size: 15px; }
.md ul, .md ol { margin: 0 0 10px; padding-left: 22px; }
.md li { margin: 2px 0; }
.md code { background: var(--surface-2); padding: 1px 5px; border-radius: 5px; font: 13px ui-monospace, Menlo, Consolas, monospace; }
.md pre { background: var(--surface-2); padding: 10px 12px; border-radius: 8px; overflow-x: auto; margin: 0 0 10px; }
.md pre code { background: transparent; padding: 0; }
.md blockquote { margin: 0 0 10px; padding: 2px 12px; border-left: 3px solid var(--border); color: var(--muted); white-space: pre-wrap; }
.md hr { border: 0; border-top: 1px solid var(--border); margin: 14px 0; }
.table-wrap { overflow-x: auto; margin: 0 0 10px; }
.md table { border-collapse: collapse; font-size: 14px; }
.md th, .md td { border: 1px solid var(--border); padding: 5px 10px; text-align: left; vertical-align: top; }
.md th { background: var(--surface-2); }
.cite {
  border: 0; cursor: pointer; font: 600 11px/1 system-ui, sans-serif;
  min-width: 17px; height: 17px; padding: 0 4px; margin: 0 1px;
  border-radius: 99px; background: var(--accent-soft); color: var(--accent); vertical-align: 2px;
}
.cite:hover { background: var(--accent); color: var(--accent-text); }

.composer-wrap { padding: 8px 18px 16px; }
.composer {
  max-width: 780px; margin: 0 auto; display: flex; gap: 8px; align-items: flex-end;
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 8px;
}
.composer textarea {
  flex: 1; border: 0; background: transparent; resize: none; max-height: 200px; padding: 6px 8px;
}
.composer textarea:focus { outline: none; }
.composer:focus-within { border-color: var(--accent); }
.composer .btn { padding: 8px 16px; }
.disclaimer { text-align: center; color: var(--muted); font-size: 12px; margin: 8px 0 0; }


/* ---------- Tab & tampilan pelacakan ---------- */
.tabs { display: flex; gap: 2px; padding: 0 18px; background: var(--surface); border-bottom: 1px solid var(--border); }
.tab { border: 0; background: transparent; padding: 9px 14px; cursor: pointer; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tab:hover { color: var(--text); }
.tab.active { color: var(--text); font-weight: 600; border-bottom-color: var(--accent); }
.content { flex: 1; overflow: auto; min-height: 0; }
.view { padding: 16px 18px 24px; max-width: 1200px; margin: 0 auto; }
.toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.toolbar .grow, .card-meta .grow { flex: 1; }
.input.small { padding: 4px 8px; font-size: 13.5px; width: auto; }
.seg { display: inline-flex; gap: 0; }
.seg .btn { border-radius: 0; }
.seg .btn:first-child { border-radius: 8px 0 0 8px; }
.seg .btn:last-child { border-radius: 0 8px 8px 0; margin-left: -1px; }
.btn.on { background: var(--accent-soft); border-color: var(--accent); }

.board { display: grid; grid-template-columns: repeat(4, minmax(210px, 1fr)); gap: 12px; align-items: start; overflow-x: auto; padding-bottom: 8px; }
.board.cols-3 { grid-template-columns: repeat(3, minmax(210px, 1fr)); }
.col { background: var(--surface-2); border-radius: var(--radius); padding: 8px; min-height: 140px; border: 2px dashed transparent; }
.col.over { border-color: var(--accent); }
.col-head { display: flex; justify-content: space-between; align-items: center; font-size: 12.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); padding: 4px 6px 8px; }
.count { background: var(--surface); border-radius: 99px; padding: 0 8px; font-size: 12px; }
.col-empty { color: var(--muted); font-size: 13px; text-align: center; padding: 18px 0; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 9px 11px; margin-bottom: 8px; cursor: grab; }
.card:hover, .card:focus-visible { border-color: var(--accent); outline: none; }
.card.dragging { opacity: 0.45; }
.card.done .card-title { text-decoration: line-through; color: var(--muted); }
.card-title { font-size: 14.5px; overflow-wrap: anywhere; }
.card-meta { display: flex; align-items: center; gap: 8px; margin-top: 7px; min-height: 22px; }
.due { font-size: 12px; padding: 1px 8px; border-radius: 99px; background: var(--surface-2); color: var(--muted); }
.due.overdue { background: var(--danger-soft); color: var(--danger); font-weight: 600; }
.due.today { background: var(--warn-soft); font-weight: 600; }
.avatar { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); font-size: 10.5px; font-weight: 700; }

.tlist { display: flex; flex-direction: column; }
.trow { display: grid; grid-template-columns: 22px 1fr auto auto 26px; gap: 10px; align-items: center; padding: 8px 4px; border-bottom: 1px solid var(--border); }
.group .trow { grid-template-columns: 22px 1fr auto auto; }
.trow.done .ttitle { text-decoration: line-through; color: var(--muted); }
.ttitle { border: 0; background: transparent; text-align: left; cursor: pointer; padding: 0; overflow-wrap: anywhere; }
.ttitle:hover { text-decoration: underline; }
.group { margin-bottom: 22px; }
.group-title { border: 0; background: transparent; cursor: pointer; font-weight: 700; font-size: 15px; padding: 4px 0; color: var(--accent); }

.notes { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.note-card { text-align: left; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; cursor: pointer; display: flex; flex-direction: column; gap: 6px; }
.note-card:hover { border-color: var(--accent); }
.note-title { font-weight: 600; overflow-wrap: anywhere; }
.note-preview { color: var(--muted); font-size: 13.5px; display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; white-space: pre-wrap; }
.note-meta { font-size: 12px; color: var(--muted); display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
label.field textarea.tall { min-height: 280px; font: 14px/1.5 ui-monospace, Menlo, Consolas, monospace; }
.activity .row { padding: 9px 2px; }
.notice.block { margin: 0 0 12px; }

/* ---------- Modal & toast ---------- */
.overlay { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.45); display: grid; place-items: center; padding: 16px; z-index: 20; }
.modal { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; width: 100%; max-width: 520px; max-height: 90vh; display: flex; flex-direction: column; }
.modal.wide { max-width: 760px; }
.modal-head { display: flex; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.modal-head h3 { margin: 0; flex: 1; font-size: 16px; }
.modal-body { padding: 18px; overflow-y: auto; }
.modal-foot { display: flex; gap: 8px; justify-content: flex-end; padding: 12px 18px; border-top: 1px solid var(--border); }
.section-title { font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); margin: 20px 0 8px; }
.row { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 14px; }
.row:last-child { border-bottom: 0; }
.row .grow { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.row small { color: var(--muted); display: block; }
.inline-form { display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-end; }
.inline-form label.field { margin: 0; flex: 1; min-width: 140px; }
.secret-box { margin: 12px 0; padding: 10px 12px; border-radius: 8px; background: var(--warn-soft); font-size: 14px; }
.secret-box code { font: 15px ui-monospace, Menlo, Consolas, monospace; user-select: all; }
progress { width: 100%; height: 6px; }

.toast-stack { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 30; }
.toast { background: var(--text); color: var(--bg); padding: 9px 14px; border-radius: 8px; font-size: 14px; max-width: 340px; }
.toast.error { background: var(--danger); color: #fff; }

/* ---------- Mobile ---------- */
@media (max-width: 800px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: min(86vw, 320px); z-index: 15; transform: translateX(-100%); transition: transform 0.2s; }
  .shell.nav-open .sidebar { transform: none; }
  .backdrop { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.4); z-index: 14; }
  .menu-btn { display: inline-block; }
  .msg.user .bubble { max-width: 94%; }
  .board { grid-template-columns: repeat(4, 78vw); }
  .trow { grid-template-columns: 22px 1fr auto; }
  .trow > :nth-child(n+4) { display: none; }
  .tabs { padding: 0 8px; overflow-x: auto; }
  .view { padding: 12px 10px 20px; }
}
