/* Tinur — tema biru malam */
:root {
  --bg: #0b1e3a;
  --bg2: #16294d;
  --panel: #0e2547;
  --panel2: #122c55;
  --text: #eef3fb;
  --muted: #9db1d0;
  --border: #23406e;
  --accent: #ffd34d;
  --mint: #4ade80;
  --danger: #f87171;
  --radius: 14px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: linear-gradient(160deg, var(--bg), var(--bg2));
  color: var(--text);
}
.hidden { display: none !important; }
button { font-family: inherit; cursor: pointer; }

/* Logo */
.logo { font-size: 28px; font-weight: 800; letter-spacing: .5px; }
.logo span { color: var(--accent); }
.logo.big { font-size: 54px; }
.logo.small { font-size: 24px; }

/* Login */
.login-view { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 36px 32px; width: 100%; max-width: 380px; text-align: center; }
.login-sub { color: var(--muted); margin: 12px 0 20px; font-size: 14px; line-height: 1.5; }
.login-card input, .modal-card textarea, .modal-card select {
  width: 100%; padding: 12px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--bg); color: var(--text); font-size: 15px; outline: none; margin-bottom: 12px;
}
.login-card input:focus, .modal-card textarea:focus { border-color: var(--accent); }
.error { color: var(--danger); font-size: 13px; margin-top: 4px; }

/* Tombol */
.btn-primary { background: var(--accent); color: #1a1405; border: none; padding: 12px 22px; border-radius: 10px; font-weight: 700; font-size: 15px; width: 100%; }
.btn-primary:hover { filter: brightness(1.08); }
.btn-new { background: var(--accent); color: #1a1405; border: none; padding: 10px; border-radius: 10px; font-weight: 700; width: 100%; }
.btn-ghost { background: transparent; color: var(--muted); border: 1px solid var(--border); padding: 9px 12px; border-radius: 10px; font-size: 14px; width: 100%; }
.btn-ghost:hover { color: var(--text); border-color: var(--muted); }
.btn-icon { background: transparent; border: none; color: var(--text); font-size: 20px; padding: 6px 10px; display: none; }

/* Layout */
.app { display: flex; height: 100vh; height: 100dvh; }
.sidebar { width: 280px; flex-shrink: 0; background: var(--panel); border-right: 1px solid var(--border); display: flex; flex-direction: column; padding: 16px; gap: 14px; }
.side-top { display: flex; flex-direction: column; gap: 12px; }
.conv-list { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 4px; }
.conv-item { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-radius: 10px; cursor: pointer; font-size: 14px; }
.conv-item:hover { background: var(--panel2); }
.conv-item.active { background: var(--panel2); border-left: 3px solid var(--accent); }
.conv-item .title { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-item .del { background: none; border: none; color: var(--muted); font-size: 16px; padding: 0 4px; }
.conv-item .del:hover { color: var(--danger); }
.side-bottom { display: flex; flex-direction: column; gap: 8px; }
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }

.topbar { display: flex; align-items: center; gap: 12px; padding: 12px 18px; border-bottom: 1px solid var(--border); background: rgba(11,30,58,.6); }
.topbar-info { flex: 1; min-width: 0; }
.topbar-info strong { font-size: 16px; }
.key-status { display: block; font-size: 12px; color: var(--muted); margin-top: 2px; }
.model-select { background: var(--panel); color: var(--text); border: 1px solid var(--border); border-radius: 10px; padding: 8px 10px; font-size: 13px; max-width: 230px; }
.model-select.wide { width: 100%; max-width: none; margin-bottom: 12px; }

.messages { flex: 1; overflow-y: auto; padding: 24px 18px; display: flex; flex-direction: column; gap: 16px; }
.empty-state { margin: auto; text-align: center; max-width: 520px; }
.empty-state h1 { margin: 14px 0 8px; font-size: 26px; }
.empty-state p { color: var(--muted); line-height: 1.6; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 20px; }
.chip { background: var(--panel); border: 1px solid var(--border); color: var(--text); padding: 9px 14px; border-radius: 999px; font-size: 13px; }
.chip:hover { border-color: var(--accent); }

.msg { max-width: 780px; width: 100%; margin: 0 auto; display: flex; flex-direction: column; gap: 6px; }
.msg .who { font-size: 12px; color: var(--muted); font-weight: 700; }
/* v7: catatan kecil di bawah balasan — "via 9Router" atau fallback ke Gemini. */
.provider-note { font-size: 12px; color: var(--muted); margin-top: 4px; }
.msg.user .bubble { background: var(--panel2); border: 1px solid var(--border); align-self: flex-end; }
.msg.assistant .bubble { background: transparent; border: none; padding: 2px 0; }
.bubble { padding: 12px 16px; border-radius: var(--radius); line-height: 1.65; font-size: 15px; max-width: 100%; overflow-wrap: anywhere; }
.bubble p { margin-bottom: 10px; }
.bubble p:last-child { margin-bottom: 0; }
.bubble ul, .bubble ol { margin: 0 0 10px 20px; }
.bubble li { margin-bottom: 4px; }
.bubble code { background: rgba(255,211,77,.14); padding: 2px 6px; border-radius: 6px; font-size: 13px; }
.bubble pre { background: #081426; border: 1px solid var(--border); padding: 12px; border-radius: 10px; overflow-x: auto; margin-bottom: 10px; }
.bubble pre code { background: none; padding: 0; }
.bubble strong { color: var(--accent); }
.typing { display: inline-flex; gap: 5px; padding: 6px 0; }
.typing i { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); animation: blink 1s infinite; }
.typing i:nth-child(2) { animation-delay: .2s; }
.typing i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%,100% { opacity: .3; } 50% { opacity: 1; } }

.composer { display: flex; gap: 10px; padding: 14px 18px 6px; max-width: 820px; width: 100%; margin: 0 auto; }
.composer textarea { flex: 1; resize: none; background: var(--panel); border: 1px solid var(--border); color: var(--text); border-radius: 12px; padding: 13px 16px; font-size: 15px; font-family: inherit; outline: none; max-height: 140px; }
.composer textarea:focus { border-color: var(--accent); }
.btn-send { width: 48px; height: 48px; border-radius: 12px; border: none; background: var(--accent); color: #1a1405; font-size: 20px; flex-shrink: 0; }
.btn-send:disabled { opacity: .5; cursor: default; }
.disclaimer { text-align: center; color: var(--muted); font-size: 11px; padding: 4px 12px 12px; }

/* Modal */
.modal { position: fixed; inset: 0; background: rgba(4,10,24,.7); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 10; }
.modal-card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; width: 100%; max-width: 480px; max-height: 90vh; overflow-y: auto; }
.modal-card h2 { margin-bottom: 16px; }
.modal-card label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.modal-card textarea { resize: vertical; }
.modal-actions { display: flex; gap: 10px; margin-top: 6px; }
.modal-actions .btn-primary, .modal-actions .btn-ghost { width: auto; flex: 1; }
.key-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.key-row { display: flex; justify-content: space-between; background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 8px 12px; font-size: 13px; }
.key-row .ok { color: var(--mint); }
.key-row .cool { color: var(--accent); }
.key-row .empty { color: var(--muted); }
.hint { font-size: 12px; color: var(--muted); line-height: 1.5; margin-bottom: 10px; }

/* Google Drive + memori file (v2) */
.drive-box, .files-box { border-top: 1px solid var(--border); padding-top: 12px; display: flex; flex-direction: column; gap: 8px; }
.drive-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.drive-title { font-size: 13px; font-weight: 700; color: var(--text); }
.drive-status { font-size: 11px; color: var(--muted); white-space: nowrap; }
.drive-status.ok { color: var(--mint); }
.drive-status.empty { color: var(--muted); }
.file-search { width: 100%; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--border); background: var(--bg); color: var(--text); font-size: 13px; outline: none; }
.file-search:focus { border-color: var(--accent); }
.file-list { display: flex; flex-direction: column; gap: 4px; max-height: 180px; overflow-y: auto; }
.file-item { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 8px; cursor: pointer; font-size: 13px; background: var(--bg); border: 1px solid transparent; }
.file-item:hover { border-color: var(--border); background: var(--panel2); }
.file-item .file-name { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-item .del { background: none; border: none; color: var(--muted); font-size: 15px; padding: 0 4px; }
.file-item .del:hover { color: var(--danger); }
.file-empty { font-size: 12px; color: var(--muted); line-height: 1.5; padding: 4px 2px; }

/* Tugas & dokumen (v3) */
.tasks-box, .docs-box { border-top: 1px solid var(--border); padding-top: 12px; display: flex; flex-direction: column; gap: 8px; }
.task-badge { font-size: 11px; background: var(--danger); color: #fff; border-radius: 999px; padding: 2px 8px; margin-left: 6px; font-weight: 700; }
.task-quick { display: flex; gap: 6px; }
.task-quick input { flex: 1; min-width: 0; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--border); background: var(--bg); color: var(--text); font-size: 13px; outline: none; }
.task-quick input:focus { border-color: var(--accent); }
.btn-mini { background: var(--panel2); color: var(--text); border: 1px solid var(--border); border-radius: 8px; padding: 6px 10px; font-size: 14px; }
.btn-mini:hover { border-color: var(--accent); }
.task-filters { display: flex; gap: 6px; }
.task-filter { flex: 1; background: transparent; border: 1px solid var(--border); color: var(--muted); border-radius: 999px; padding: 5px 8px; font-size: 12px; }
.task-filter.active { background: var(--accent); color: #1a1405; border-color: var(--accent); font-weight: 700; }
.task-list { display: flex; flex-direction: column; gap: 6px; max-height: 220px; overflow-y: auto; }
.task-item { display: flex; align-items: flex-start; gap: 8px; padding: 8px 10px; border-radius: 8px; background: var(--bg); border: 1px solid transparent; font-size: 13px; }
.task-item.done { opacity: .55; }
.task-item.done .task-title { text-decoration: line-through; }
.task-check { margin-top: 2px; accent-color: var(--mint); width: 16px; height: 16px; flex-shrink: 0; cursor: pointer; }
.task-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.task-title { overflow-wrap: anywhere; line-height: 1.4; }
.task-meta { font-size: 11px; color: var(--muted); }
.task-meta.late { color: var(--danger); font-weight: 700; }
.task-item .del { background: none; border: none; color: var(--muted); font-size: 15px; padding: 0 4px; }
.task-item .del:hover { color: var(--danger); }
.doc-dl { color: var(--accent); text-decoration: none; font-size: 15px; padding: 0 4px; }
.briefing { margin: 12px 18px 0; background: var(--panel); border: 1px solid var(--accent); border-radius: var(--radius); padding: 12px 14px; }
.briefing-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 14px; }
.briefing-count { font-size: 12px; color: var(--danger); font-weight: 700; margin-left: 6px; }
.briefing-actions { display: flex; gap: 6px; }
.briefing-body { margin-top: 8px; font-size: 13.5px; line-height: 1.6; color: var(--text); }
.briefing-body p { margin-bottom: 6px; }
.briefing-body ul { margin: 0 0 6px 18px; }
.bubble a, .briefing-body a { color: var(--accent); }

/* Terhubung, ingatan & jadwal (v4) */
.conn-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 13px; padding: 2px 0; }

/* Alur kerja multi-langkah (v5) */
.workflow-card { background: var(--panel); border: 1px solid var(--accent); border-radius: var(--radius); padding: 12px 14px; margin-top: 4px; font-size: 14px; }
.wf-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.wf-title { font-weight: 700; overflow-wrap: anywhere; }
.wf-badge { font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 999px; background: var(--panel2); border: 1px solid var(--border); white-space: nowrap; }
.wf-badge.berjalan { color: var(--accent); border-color: var(--accent); }
.wf-badge.menunggu_persetujuan { color: var(--accent); border-color: var(--accent); }
.wf-badge.selesai { color: var(--mint); border-color: var(--mint); }
.wf-badge.gagal { color: var(--danger); border-color: var(--danger); }
.wf-badge.dibatalkan { color: var(--muted); }
.wf-steps { display: flex; flex-direction: column; gap: 6px; }
.wf-step { background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; font-size: 13px; }
.wf-step.selesai { border-color: var(--mint); }
.wf-step.gagal { border-color: var(--danger); }
.wf-step.berjalan { border-color: var(--accent); }
.wf-step.menunggu_persetujuan { border-color: var(--accent); background: rgba(255,211,77,.08); }
.wf-step-label { display: block; line-height: 1.4; }
.wf-actions { display: flex; gap: 8px; margin-top: 8px; }
.wf-approve { border-color: var(--mint); color: var(--mint); }
.wf-reject { border-color: var(--danger); color: var(--danger); }
.wf-error { color: var(--danger); font-size: 12px; margin-top: 4px; line-height: 1.5; }
.wf-note { color: var(--muted); font-size: 12px; margin-top: 4px; line-height: 1.5; }
.wf-link { color: var(--accent); font-size: 12px; }
.wf-summary { margin-top: 10px; font-size: 13px; line-height: 1.6; white-space: pre-wrap; }
.check-row { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--text); margin-bottom: 8px; }
.check-row input { accent-color: var(--mint); width: 16px; height: 16px; flex-shrink: 0; }
.wa-qr { display: flex; flex-direction: column; gap: 8px; align-items: center; background: var(--bg); border: 1px solid var(--border); border-radius: 10px; padding: 10px; }
.wa-qr-img { width: 180px; height: 180px; background: #fff; border-radius: 8px; padding: 6px; }
.job-form { display: flex; flex-direction: column; gap: 6px; }
.job-form .btn-mini { width: 100%; padding: 8px; }

/* Toast */
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: var(--panel2); border: 1px solid var(--accent); color: var(--text); padding: 12px 18px; border-radius: 10px; font-size: 14px; z-index: 50; max-width: 90vw; text-align: center; box-shadow: 0 4px 24px rgba(0,0,0,.4); }

/* Responsif HP */
@media (max-width: 760px) {
  .btn-icon { display: block; }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; z-index: 20; transform: translateX(-100%); transition: transform .2s; }
  .sidebar.open { transform: translateX(0); box-shadow: 0 0 40px rgba(0,0,0,.5); }
  .model-select { max-width: 150px; }
  .messages { padding: 16px 12px; }
}

/* Umpan balik & belajar sendiri (v6) */
.fb-row { display: flex; gap: 6px; margin-top: 8px; }
.fb-btn { background: transparent; border: 1px solid var(--border); color: var(--muted); border-radius: 8px; padding: 4px 10px; font-size: 13px; }
.fb-btn:hover { color: var(--text); border-color: var(--muted); }
.fb-btn.active { background: var(--panel2); color: var(--accent); border-color: var(--accent); }
.fb-btn:disabled { opacity: .5; cursor: default; }
.fb-correction { display: flex; gap: 6px; margin-top: 8px; }
.fb-correction input { flex: 1; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--border); background: var(--bg); color: var(--text); font-size: 13px; outline: none; }
.learn-item { display: flex; align-items: flex-start; gap: 8px; padding: 8px 10px; border-radius: 10px; font-size: 13px; }
.learn-item:hover { background: var(--panel2); }
.learn-badge { font-size: 11px; padding: 2px 7px; border-radius: 20px; background: var(--panel2); color: var(--accent); white-space: nowrap; }
.learn-text { flex: 1; line-height: 1.45; }
.sugg-item { padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; margin-bottom: 8px; }
.sugg-item .sugg-title { font-weight: 700; font-size: 14px; }
.sugg-item .sugg-reason { color: var(--muted); font-size: 13px; margin: 4px 0 8px; line-height: 1.5; }
.sugg-actions { display: flex; gap: 8px; }
