:root {
  --bg: #0f1115;
  --panel: #181b22;
  --panel-2: #20242d;
  --border: #2c313c;
  --text: #e6e8ee;
  --muted: #8a91a0;
  --accent: #4f8cff;
  --ok: #3ecf8e;
  --warn: #f5b041;
  --err: #ef5b5b;
  --tile: 200px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 13px/1.4 system-ui, -apple-system, "Segoe UI", sans-serif;
}

button, input {
  font: inherit;
  color: inherit;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 5px 9px;
}
button { cursor: pointer; }
button:hover { border-color: var(--accent); }
input[type="checkbox"] { padding: 0; accent-color: var(--accent); }
input[type="range"] { padding: 0; vertical-align: middle; }

.toolbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}
.brand { font-weight: 600; display: flex; align-items: center; gap: 8px; }
.group { display: flex; gap: 4px; }
.muted { color: var(--muted); }
.switch { display: flex; align-items: center; gap: 6px; cursor: pointer; }
.switch:has(input:checked) span { color: var(--warn); font-weight: 600; }

.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--err); }
.dot.on { background: var(--ok); }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(var(--tile), 1fr));
  gap: 10px;
  padding: 12px;
  align-items: start;
}
.empty { color: var(--muted); grid-column: 1 / -1; text-align: center; padding: 60px 0; }

.tile {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}
.tile.selected { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.tile.active { border-color: var(--warn); box-shadow: 0 0 0 2px var(--warn); }
.tile.active .slot { background: var(--warn); color: #000; }
.tile.focused { grid-column: 1 / -1; justify-self: center; width: min(100%, 520px); }

.tile-head {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 7px;
  font-size: 12px;
  border-bottom: 1px solid var(--border);
}
.tile-head .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile-head .expand, .tile-head .settings { padding: 0 6px; }
.stream { font-size: 10.5px; color: var(--muted); white-space: nowrap; }
.stream.custom { color: var(--accent); }
.tile[data-source="agent"] .stream { color: var(--ok); }
.tile[data-source="agent"] .tile-head { border-bottom: 1px solid color-mix(in srgb, var(--ok) 30%, transparent); }
.tile-head .slot {
  min-width: 18px;
  padding: 0 4px;
  border-radius: 4px;
  background: var(--panel-2);
  color: var(--muted);
  font-size: 11px;
  text-align: center;
}
.tile-head { cursor: pointer; }
.kbd-target { color: var(--warn); font-weight: 600; }
.switch:has(#kbd:not(:checked)) + .kbd-target { opacity: 0.4; }
.status { font-size: 11px; color: var(--muted); }
.tile[data-status="online"] .status { color: var(--ok); }
.tile[data-status="connecting"] .status { color: var(--warn); }
.tile[data-status="error"] .status { color: var(--err); }

.screen { position: relative; background: #000; }
.screen canvas {
  display: block;
  width: 100%;
  height: auto;
  touch-action: none;
  cursor: crosshair;
}
.tile.focused .screen canvas { max-height: 82vh; object-fit: contain; }
.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 10px;
  text-align: center;
  font-size: 12px;
  color: var(--muted);
  pointer-events: none;
}
.overlay:empty { display: none; }

.shell-panel {
  position: fixed;
  right: 12px;
  bottom: 12px;
  width: min(640px, calc(100vw - 24px));
  max-height: 50vh;
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 10px 30px rgb(0 0 0 / 0.5);
}
.shell-panel[hidden], .empty[hidden] { display: none; }
.shell-head { display: flex; justify-content: space-between; align-items: center; padding: 8px 10px; border-bottom: 1px solid var(--border); }
#shell-output { overflow: auto; padding: 8px 10px; font: 12px/1.45 ui-monospace, Menlo, monospace; }
#shell-output h4 { margin: 8px 0 2px; font-size: 12px; }
#shell-output h4.fail { color: var(--err); }
#shell-output pre { margin: 0; white-space: pre-wrap; word-break: break-all; }

@media (max-width: 700px) {
  .toolbar { gap: 6px; }
  .group input { width: 140px; }
  .size { display: none; }
}

/* ---- panel script ---- */
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
select {
  font: inherit; color: inherit; background: var(--panel-2);
  border: 1px solid var(--border); border-radius: 6px; padding: 5px 6px;
}
body.with-script .grid { margin-right: min(460px, 100vw); }
.script-panel {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 20;
  width: min(460px, 100vw);
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px;
  background: var(--panel);
  border-left: 1px solid var(--border);
  box-shadow: -10px 0 30px rgb(0 0 0 / 0.35);
}
.script-panel[hidden] { display: none; }
.sp-row { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
#script-list { flex: 1; min-width: 0; }
#script-code {
  flex: 1 1 45%;
  min-height: 180px;
  resize: none;
  font: 12.5px/1.5 ui-monospace, Menlo, monospace;
  tab-size: 2;
  white-space: pre;
  color: var(--text);
  background: #0b0d11;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px;
}
#script-code.dirty { border-color: var(--warn); }
.sp-help summary { cursor: pointer; color: var(--muted); }
.sp-help pre {
  margin: 6px 0 0; padding: 8px; max-height: 30vh; overflow: auto;
  font: 11.5px/1.45 ui-monospace, Menlo, monospace;
  background: #0b0d11; border-radius: 6px;
}
.run-list { display: flex; flex-direction: column; gap: 4px; max-height: 20vh; overflow: auto; }
.run { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; font-size: 12px; }
.run .title { color: var(--muted); }
.chip { padding: 1px 6px; border-radius: 10px; font-size: 11px; background: var(--panel-2); }
.chip.running { color: var(--warn); }
.chip.done { color: var(--ok); }
.chip.error { color: var(--err); }
.chip.stopped { color: var(--muted); }
.run button { padding: 1px 8px; font-size: 11px; }
.sp-log-head { justify-content: space-between; color: var(--muted); }
.script-log {
  flex: 1 1 30%;
  min-height: 100px;
  overflow: auto;
  font: 11.5px/1.45 ui-monospace, Menlo, monospace;
  background: #0b0d11;
  border-radius: 6px;
  padding: 6px 8px;
}
.script-log div { white-space: pre-wrap; word-break: break-word; }
.script-log .t { color: var(--muted); }
.script-log .d { color: var(--accent); }
.script-log .warn { color: var(--warn); }
.script-log .error { color: var(--err); }
.tile[data-script="running"] .slot::after { content: " ⚡"; }

/* ---- dialog pengaturan stream ---- */
.settings-dialog {
  width: min(380px, calc(100vw - 32px));
  padding: 16px;
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
}
.settings-dialog::backdrop { background: rgb(0 0 0 / 0.55); }
.settings-dialog h3 { margin: 0 0 12px; font-size: 15px; }
.settings-dialog form > label { display: flex; flex-direction: column; gap: 4px; margin-bottom: 10px; }
.settings-dialog label.check { flex-direction: row; align-items: center; gap: 8px; }
.settings-dialog .hint { font-size: 12px; margin: 8px 0; }
.settings-dialog .error { color: var(--err); font-size: 12px; min-height: 1em; margin: 4px 0; }
.settings-dialog .actions { display: flex; gap: 6px; }
.settings-dialog .spacer { flex: 1; }
.settings-dialog label[hidden] { display: none; }
button:disabled { opacity: 0.45; cursor: not-allowed; }

/* ---- pick-mode koordinat ---- */
.pick-banner {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 12px 20px;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  font-size: 14px;
  animation: pick-slide 0.2s ease;
}
.pick-banner[hidden] { display: none; }
@keyframes pick-slide { from { transform: translateY(100%); } to { transform: translateY(0); } }
.pick-banner button {
  background: rgba(255,255,255,0.2);
  border-color: rgba(255,255,255,0.4);
  color: #fff;
  font-size: 12px;
  padding: 3px 10px;
}
body.pick-mode canvas { cursor: crosshair; outline: 3px solid var(--accent); outline-offset: -3px; }
body.pick-mode .tile { box-shadow: 0 0 0 2px var(--accent); }

/* ---- workflow builder panel ---- */
body.with-workflow .grid { margin-right: min(520px, 100vw); }
.workflow-panel {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 20;
  width: min(520px, 100vw);
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px;
  background: var(--panel);
  border-left: 1px solid var(--border);
  box-shadow: -10px 0 30px rgb(0 0 0 / 0.35);
  overflow-y: auto;
}
.workflow-panel[hidden] { display: none; }
#wf-list { flex: 1; min-width: 0; }
.wf-name-row { display: flex; gap: 6px; }
#wf-name {
  flex: 1;
  font-weight: 600;
  font-size: 14px;
  background: #0b0d11;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 10px;
}
#wf-name.dirty { border-color: var(--warn); }

.wf-steps {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
  overflow-y: auto;
  min-height: 60px;
}
.wf-step {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  flex-shrink: 0;
}
.wf-footer {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.wf-step-head {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  background: #1e2130;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
}
.wf-num {
  min-width: 20px;
  height: 20px;
  line-height: 20px;
  text-align: center;
  border-radius: 50%;
  background: var(--border);
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
}
.wf-type {
  flex: 1;
  font-weight: 600;
  font-size: 13px;
}
.wf-step-head button {
  padding: 1px 7px;
  font-size: 11px;
  min-width: 0;
}
.wf-del { color: var(--err); border-color: transparent; background: transparent; }
.wf-del:hover { background: var(--panel-2); border-color: var(--err); }

.wf-params {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  padding: 8px 10px;
}
.wf-params label {
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 11px;
  color: var(--muted);
}
.wf-params label span { color: var(--text); font-size: 12px; font-weight: 500; }
.wf-params input, .wf-params select {
  font-size: 12px;
  padding: 4px 7px;
  background: #0b0d11;
  border: 1px solid var(--border);
  border-radius: 5px;
  color: var(--text);
}
input.wf-num-input { width: 68px; }
input.wf-pct-input { width: 58px; }
input.wf-wide-input { width: 200px; }
input.wf-ms-input { width: 80px; }

.wf-pick-btn {
  align-self: flex-end;
  padding: 4px 9px;
  font-size: 16px;
  border-radius: 6px;
  background: var(--panel-2);
  border-color: var(--border);
  cursor: pointer;
  line-height: 1;
}
.wf-pick-btn:hover { border-color: var(--accent); background: #1e2a45; }

.wf-wordlist-wrap { display: flex; flex-direction: column; gap: 6px; flex: 1; min-width: 240px; }
.wf-wordlist-ta {
  width: 100%;
  font: 12px/1.5 ui-monospace, Menlo, monospace;
  padding: 6px 8px;
  background: #0b0d11;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  resize: vertical;
}
.wf-wordlist-hint {
  font-size: 11px;
  color: var(--muted);
  margin: 0;
  line-height: 1.5;
}
.wf-wordlist-hint code {
  background: var(--panel-2);
  padding: 1px 5px;
  border-radius: 4px;
  color: var(--accent);
  font-size: 11px;
}

.wf-add-row { display: flex; justify-content: center; padding: 4px 0; }
#wf-add-step { width: 100%; }

/* ---- dialog pilih jenis langkah ---- */
.step-type-dialog {
  padding: 16px;
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  width: min(480px, calc(100vw - 32px));
}
.step-type-dialog::backdrop { background: rgb(0 0 0 / 0.55); }
.step-type-dialog h3 { margin: 0 0 12px; font-size: 15px; }
.step-type-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.step-type-grid button {
  text-align: left;
  padding: 9px 12px;
  font-size: 13px;
  border-radius: 8px;
  background: var(--panel-2);
}
.step-type-grid button:hover { background: #2a2f3e; border-color: var(--accent); }

/* ─── Tooltip ─────────────────────── (posisi diatur JS, bukan CSS) */
[data-tip] { cursor: default; }

/* ─── Recorder ─────────────────────────────────────────────────── */
#rec-toggle { color: var(--err); }
body.recording #rec-toggle {
  background: var(--err);
  color: #fff;
  border-color: var(--err);
  animation: rec-pulse 1.4s ease-in-out infinite;
}
@keyframes rec-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: .65; }
}
/* Counter rekaman di pojok kanan bawah layar */
#rec-hud {
  position: fixed;
  bottom: 16px;
  right: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: rgba(239,91,91,.92);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  border-radius: 20px;
  box-shadow: 0 4px 18px rgba(0,0,0,.5);
  z-index: 9990;
  pointer-events: none;
}
#rec-hud .rec-dot {
  width: 9px; height: 9px;
  border-radius: 50%;
  background: #fff;
  animation: rec-pulse 1.4s ease-in-out infinite;
}
body.with-workflow #rec-hud { right: 532px; }

/* ─── Workflow tabs ─────────────────────────────────────────────── */
.wf-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
  flex-shrink: 0;
}
.wf-tab {
  flex: 1;
  padding: 9px 4px;
  border: none;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  cursor: pointer;
}
.wf-tab.active {
  color: var(--text);
  border-bottom-color: var(--accent);
}
.wf-tab-body { display: flex; flex-direction: column; flex: 1; overflow: hidden; }
.wf-tab-body[hidden] { display: none; }

/* Export / Import buttons */
.wf-io-row { gap: 6px; }
.wf-import-label {
  padding: 5px 9px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text);
}
.wf-import-label:hover { border-color: var(--accent); color: var(--accent); }

/* Workflow history */
.wf-history-list { flex: 1; overflow-y: auto; padding: 8px 0; }
.wf-hist-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}
.wf-hist-item:hover { background: var(--panel-2); }
.wf-hist-info { flex: 1; min-width: 0; }
.wf-hist-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wf-hist-meta { font-size: 11px; color: var(--muted); margin-top: 2px; }
.wf-hist-play {
  background: var(--accent); color: #fff; border: none;
  border-radius: 5px; padding: 4px 10px; font-size: 12px; cursor: pointer;
}

/* ─── AI Panel ──────────────────────────────────────────────────── */
.ai-panel {
  position: fixed;
  right: 0; top: 0; bottom: 0;
  width: 400px;
  background: var(--panel);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 20;
}
.ai-panel[hidden] { display: none; }
body.with-ai .grid { margin-right: min(400px, 100vw); }
body.with-ai.with-workflow .grid { margin-right: min(920px, 100vw); }
body.with-ai #rec-hud { right: 412px; }

.ai-panel-title { font-weight: 600; flex: 1; }
.ai-model-info {
  padding: 6px 14px;
  font-size: 11px;
  border-bottom: 1px solid var(--border);
}
.ai-model-info a { color: var(--accent); text-decoration: none; }

.ai-messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.ai-msg { display: flex; gap: 8px; align-items: flex-start; }
.ai-msg.user { flex-direction: row-reverse; }
.ai-bubble {
  max-width: 85%;
  padding: 8px 12px;
  border-radius: 12px;
  font-size: 13px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}
.ai-msg.user .ai-bubble {
  background: var(--accent);
  color: #fff;
  border-bottom-right-radius: 3px;
}
.ai-msg.assistant .ai-bubble {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-bottom-left-radius: 3px;
}
.ai-msg.error .ai-bubble { background: #3a1818; border-color: var(--err); color: var(--err); }
.ai-typing { display: flex; gap: 4px; padding: 12px; }
.ai-typing span {
  width: 7px; height: 7px; border-radius: 50%; background: var(--muted);
  animation: typing-bounce .9s ease-in-out infinite;
}
.ai-typing span:nth-child(2) { animation-delay: .15s; }
.ai-typing span:nth-child(3) { animation-delay: .3s; }
@keyframes typing-bounce { 0%,60%,100%{transform:translateY(0)} 30%{transform:translateY(-6px)} }

.ai-input-row {
  display: flex;
  gap: 6px;
  padding: 10px 14px;
  border-top: 1px solid var(--border);
}
.ai-input-row textarea {
  flex: 1;
  resize: none;
  min-height: 56px;
  max-height: 120px;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 13px;
  line-height: 1.45;
}
.ai-input-row button { align-self: flex-end; }

/* ─── Dialog Pengaturan AI ──────────────────────────────────────── */
.ai-settings-dialog {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px 28px;
  width: 380px;
  max-width: 95vw;
}
.ai-settings-dialog::backdrop { background: rgba(0,0,0,.55); }
.ai-settings-dialog h3 { margin: 0 0 18px; font-size: 15px; }
.ai-settings-dialog label {
  display: flex; flex-direction: column; gap: 5px;
  font-size: 12px; color: var(--muted); margin-bottom: 14px;
}
.ai-settings-dialog label select,
.ai-settings-dialog label input[type="password"],
.ai-settings-dialog label input[type="text"] {
  width: 100%; font-size: 13px; padding: 6px 9px;
}
.ais-key-row, .ais-model-row { display: flex; gap: 6px; }
.ais-key-row input, .ais-model-row select { flex: 1; }

/* ─── APK Manager Panel ──────────────────────────────────────────────── */
.apk-panel {
  position: fixed; top: 48px; right: 0; bottom: 0; width: 380px;
  background: var(--panel); border-left: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 0; z-index: 90;
  overflow: hidden;
  padding: 10px;
  gap: 8px;
}
.apk-panel[hidden] { display: none; }

.apk-drop {
  border: 2px dashed var(--border); border-radius: 8px;
  padding: 20px; text-align: center; cursor: pointer;
  transition: border-color .15s, background .15s;
  flex-shrink: 0;
}
.apk-drop.drag-over { border-color: var(--accent); background: rgba(79,140,255,.06); }
.apk-drop-inner { display: flex; align-items: center; justify-content: center; gap: 6px; flex-wrap: wrap; font-size: 12px; color: var(--muted); }
.primary-link { color: var(--accent); cursor: pointer; text-decoration: underline; }
.apk-progress { margin-top: 8px; }
.apk-progress-bar {
  height: 4px; background: var(--accent); border-radius: 2px;
  width: 0%; transition: width .2s;
}
#apk-progress-label { font-size: 11px; color: var(--muted); }

.apk-section-head {
  display: flex; align-items: center; gap: 8px;
  font-size: 11px; font-weight: 600; color: var(--muted);
  text-transform: uppercase; letter-spacing: .5px;
  margin-top: 4px;
}
.apk-section-head button { padding: 2px 7px; font-size: 12px; }
.apk-section-head span { flex: 1; }

.apk-list { flex: 0 0 auto; max-height: 160px; overflow-y: auto; display: flex; flex-direction: column; gap: 4px; }
.apk-item {
  display: flex; align-items: center; gap: 8px;
  background: var(--panel-2); border-radius: 6px; padding: 6px 10px;
  font-size: 12px;
}
.apk-item-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.apk-item-size { color: var(--muted); flex-shrink: 0; }
.apk-item button { padding: 2px 8px; font-size: 11px; }
.apk-item .btn-install { background: var(--accent); color: #fff; border-color: transparent; }
.apk-item .btn-del { color: var(--err); }

.apk-device-select {
  display: flex; flex-wrap: wrap; gap: 6px;
  max-height: 80px; overflow-y: auto;
}
.apk-dev-chip {
  display: flex; align-items: center; gap: 4px;
  background: var(--panel-2); border: 1px solid var(--border);
  border-radius: 20px; padding: 3px 10px; font-size: 11px; cursor: pointer;
}
.apk-dev-chip input { width: auto; padding: 0; border: none; background: none; }

/* ─── Logcat Viewer Panel ────────────────────────────────────────────── */
.logcat-panel {
  position: fixed; top: 48px; right: 0; bottom: 0; width: 460px;
  background: var(--panel); border-left: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 8px; z-index: 90;
  padding: 10px; overflow: hidden;
}
.logcat-panel[hidden] { display: none; }

.logcat-controls { flex-wrap: wrap; gap: 6px; }
.logcat-controls select { min-width: 120px; }

.logcat-level-btns { display: flex; gap: 4px; flex-shrink: 0; }
.lc-level {
  padding: 3px 10px; font-size: 11px; font-weight: 600;
  border-radius: 20px; border: 1px solid var(--border);
  background: var(--panel-2); cursor: pointer; opacity: .7;
}
.lc-level.active { border-color: var(--accent); background: rgba(79,140,255,.15); opacity: 1; }

.logcat-output {
  flex: 1; overflow-y: auto; font-family: 'Fira Code', 'Cascadia Code', monospace;
  font-size: 11px; line-height: 1.5; color: var(--text);
  background: #0d1117; border-radius: 6px; padding: 8px;
}
.logcat-output .lc-V { color: #666; }
.logcat-output .lc-D { color: #5ab4cc; }
.logcat-output .lc-I { color: #56c56e; }
.logcat-output .lc-W { color: #f5b041; }
.logcat-output .lc-E { color: #ef5b5b; }
.logcat-output .lc-F { color: #ff4444; font-weight: bold; }

/* ─── Schedule Panel ──────────────────────────────────────────────── */
body.with-schedule .grid { margin-right: min(400px, 100vw); }

.schedule-panel {
  position: fixed; top: 0; right: 0; z-index: 20;
  width: min(400px, 100vw); height: 100vh;
  display: flex; flex-direction: column; gap: 8px;
  padding: 10px; background: var(--panel);
  border-left: 1px solid var(--border); overflow-y: auto;
}
.schedule-panel[hidden] { display: none; }

.sched-divider { border: none; border-top: 1px solid var(--border); margin: 6px 0; }

/* List */
.sched-list { display: flex; flex-direction: column; gap: 6px; }
.sched-empty { padding: 8px 0; font-size: .85rem; }

.sched-item {
  background: var(--panel-2); border: 1px solid var(--border);
  border-radius: 8px; padding: 8px 10px;
  display: flex; flex-direction: column; gap: 4px;
}
.sched-item.disabled { opacity: .5; }
.sched-item-head {
  display: flex; align-items: center; gap: 6px;
}
.sched-item-name { font-weight: 600; flex: 1; font-size: .9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sched-item-script { font-size: .78rem; color: var(--muted); }
.sched-item-next {
  font-size: .78rem; color: var(--accent);
}
.sched-item-last { font-size: .78rem; color: var(--muted); }
.sched-toggle { font-size: .8rem; padding: 2px 8px; }
.sched-edit-btn { font-size: .8rem; padding: 2px 6px; }
.sched-del-btn { font-size: .8rem; padding: 2px 6px; color: #f55; border-color: #f55; }

/* Form */
.sched-form { display: flex; flex-direction: column; gap: 8px; }
.sched-form-title { font-weight: 600; font-size: .9rem; }
.sched-label { font-size: .8rem; color: var(--muted); margin-top: 2px; }
.sched-input { width: 100%; box-sizing: border-box; }
.sched-interval-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.sched-check { display: flex; align-items: center; gap: 4px; font-size: .85rem; cursor: pointer; white-space: nowrap; }
.sched-times { display: flex; flex-wrap: wrap; gap: 6px; min-height: 28px; }
.sched-time-chip {
  background: var(--panel-2); border: 1px solid var(--border); border-radius: 16px;
  padding: 2px 10px 2px 10px; font-size: .82rem; display: flex; align-items: center; gap: 4px;
}
.sched-time-chip button { background: none; border: none; color: var(--muted); cursor: pointer; font-size: .9rem; padding: 0 2px; }
.sched-no-time { font-size: .82rem; color: var(--muted); }
.sched-add-time-row { display: flex; gap: 6px; align-items: center; }

/* ─── Notification Bell ────────────────────────────────────────────── */
.notif-btn { position: relative; }
.notif-badge {
  position: absolute; top: 2px; right: 2px;
  min-width: 16px; height: 16px; border-radius: 8px;
  background: #e74; color: #fff; font-size: 10px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  padding: 0 3px; pointer-events: none;
}

/* ─── Activity / API Keys Panel ─────────────────────────────────── */
body.with-activity .grid { margin-right: min(480px, 100vw); }

.activity-panel {
  position: fixed; top: 0; right: 0; z-index: 20;
  width: min(480px, 100vw); height: 100vh;
  display: flex; flex-direction: column; gap: 0;
  background: var(--panel); border-left: 1px solid var(--border);
  overflow: hidden;
}
.activity-panel[hidden] { display: none; }
.activity-header { padding: 6px 10px 4px; border-bottom: 1px solid var(--border); flex-shrink: 0; }

.act-tab-body { flex: 1; overflow-y: auto; padding: 8px 10px; display: flex; flex-direction: column; gap: 8px; }
.act-tab-body[hidden] { display: none; }

/* Activity list */
.activity-list { display: flex; flex-direction: column; gap: 4px; }
.activity-entry {
  display: flex; flex-direction: column; gap: 2px;
  padding: 7px 10px; border-radius: 6px;
  background: var(--panel-2); border: 1px solid var(--border);
  font-size: .82rem;
}
.activity-entry.status-error { border-color: rgba(255,80,80,.3); }
.activity-entry-head { display: flex; align-items: center; gap: 6px; }
.activity-icon { font-size: 14px; flex-shrink: 0; }
.activity-action { font-weight: 600; flex: 1; }
.activity-time { color: var(--muted); font-size: .75rem; white-space: nowrap; }
.activity-detail { color: var(--muted); font-size: .78rem; padding-left: 20px; }
.activity-user { font-size: .75rem; color: var(--accent); }
.activity-load-more { padding: 6px 0; text-align: center; }

/* API Keys */
.apikey-form { display: flex; gap: 6px; align-items: center; padding-bottom: 8px; border-bottom: 1px solid var(--border); }
.apikey-form input { flex: 1; }
.apikey-reveal { background: #1a2a0a; border: 1px solid #3a6a1a; border-radius: 8px; padding: 10px; margin-bottom: 8px; }
.apikey-warn { color: #8f8; font-size: .82rem; margin-bottom: 8px; }
.apikey-copy-row { display: flex; gap: 8px; align-items: center; }
.apikey-copy-row code { flex: 1; font-size: .78rem; word-break: break-all; color: #af8; background: #111; padding: 6px 8px; border-radius: 4px; }
.apikey-list { display: flex; flex-direction: column; gap: 6px; }
.apikey-item {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px; border-radius: 6px;
  background: var(--panel-2); border: 1px solid var(--border);
  font-size: .82rem;
}
.apikey-item-name { font-weight: 600; flex: 1; }
.apikey-item-meta { color: var(--muted); font-size: .75rem; }
.apikey-del { color: #f55; border-color: #f55; font-size: .78rem; padding: 2px 8px; }
.apikey-docs {
  font-size: .75rem; background: var(--panel-2); border: 1px solid var(--border);
  border-radius: 6px; padding: 10px; overflow-x: auto; white-space: pre;
  color: #8f8; margin-top: 6px;
}
.activity-section-head { padding: 4px 0; }

/* ── Groups & Dashboard ───────────────────────────────────────── */

.group-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 4px;
}

.sec-btn {
  background: var(--surface3);
  border: 1px solid var(--border);
  color: var(--fg);
  border-radius: 4px;
  padding: 3px 8px;
  font-size: 11px;
  cursor: pointer;
}
.sec-btn:hover { background: var(--border); }

.step-chip {
  display: inline-block;
  background: var(--surface3);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 6px;
  font-size: 11px;
  color: var(--muted);
  font-family: monospace;
}

/* Dashboard dialog */
.dashboard-dialog {
  width: min(600px, 90vw);
  max-height: 85vh;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  padding: 0;
  overflow: hidden;
}
.dashboard-dialog[open] {
  display: flex;
  flex-direction: column;
}
.dashboard-dialog::backdrop {
  background: rgba(0,0,0,.45);
}

.dash-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(90px, 1fr));
  gap: 10px;
  margin-bottom: 4px;
}

.dash-card {
  background: var(--surface2, #22263a);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 10px;
  text-align: center;
}

.dash-val {
  font-size: 22px;
  font-weight: 700;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.dash-label {
  font-size: 11px;
  color: var(--muted);
  margin-top: 4px;
  text-transform: uppercase;
  letter-spacing: .04em;
}
