:root {
  --bg: #f5f6f8;
  --card: #ffffff;
  --ink: #1b2130;
  --muted: #6b7280;
  --line: #e6e8ec;
  --accent: #4f46e5;
  --accent-ink: #ffffff;
  --ok: #0f9d58;
  --warn: #d97706;
  --err: #dc2626;
  --shadow: 0 1px 3px rgba(16,24,40,.06), 0 8px 24px rgba(16,24,40,.05);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 24px; background: var(--card); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 10;
}
.brand { display: flex; align-items: center; gap: 12px; }
.logo {
  width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center;
  background: var(--accent); color: #fff; font-weight: 700; letter-spacing: .5px;
}
.brand-name { font-weight: 700; font-size: 17px; }
.brand-sub { color: var(--muted); font-size: 12px; }

.container { max-width: 940px; margin: 24px auto; padding: 0 20px; display: grid; gap: 18px; }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  padding: 20px; box-shadow: var(--shadow);
}

.downloads { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.download-card { display: flex; gap: 14px; align-items: center; }
.dl-icon { font-size: 34px; }
.dl-body h3 { margin: 0 0 4px; }
.dl-body p { margin: 0 0 12px; color: var(--muted); font-size: 13px; }

.step-head { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; }
.step-head h2 { font-size: 16px; margin: 0; }
.step-num {
  width: 24px; height: 24px; border-radius: 50%; background: var(--accent); color: #fff;
  display: grid; place-items: center; font-size: 13px; font-weight: 700;
}
.muted { color: var(--muted); font-size: 13px; margin: 4px 0 14px; }

.row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.toolbar { margin-bottom: 14px; }
.options { margin-top: 16px; gap: 18px; }

.input {
  border: 1px solid var(--line); border-radius: 9px; padding: 9px 11px; font-size: 14px;
  background: #fff; color: var(--ink); min-width: 120px;
}
.input:focus { outline: 2px solid rgba(79,70,229,.25); border-color: var(--accent); }
.code-input { text-transform: uppercase; letter-spacing: 3px; font-weight: 600; width: 150px; }
.field-inline { display: flex; flex-direction: column; gap: 5px; font-size: 12px; color: var(--muted); }
.field-inline .input { min-width: 220px; }
.checkbox { display: flex; align-items: center; gap: 8px; font-size: 13px; }

.btn {
  border: 1px solid transparent; border-radius: 9px; padding: 9px 15px; font-size: 14px;
  font-weight: 600; cursor: pointer; transition: .15s; text-decoration: none; display: inline-block;
}
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-primary:not(:disabled):hover { filter: brightness(1.07); }
.btn-ghost { background: #fff; border-color: var(--line); color: var(--ink); }
.btn-ghost:hover { background: #f3f4f6; }
.btn-tiny { padding: 3px 9px; font-size: 12px; background: #fff; border-color: var(--line); color: var(--muted); }

.pill { padding: 5px 12px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.pill-idle { background: #eef0f3; color: var(--muted); }
.pill-ok { background: rgba(15,157,88,.12); color: var(--ok); }
.pill-warn { background: rgba(217,119,6,.12); color: var(--warn); }
.pill-err { background: rgba(220,38,38,.10); color: var(--err); }

.agent-info { margin-top: 12px; font-size: 13px; color: var(--muted); }
.hidden { display: none !important; }

.detect-result { margin-top: 14px; padding: 14px; border: 1px dashed var(--line); border-radius: 10px; background: #fafbfc; }
.mode-badge { display: inline-block; padding: 4px 12px; border-radius: 8px; font-weight: 700; font-size: 13px; }
.mode-auto { background: rgba(15,157,88,.12); color: var(--ok); }
.mode-keyboard { background: rgba(217,119,6,.12); color: var(--warn); }
.mode-none { background: rgba(220,38,38,.10); color: var(--err); }
.detect-meta { margin-top: 8px; font-size: 13px; color: var(--muted); }
.field-chips { margin-top: 10px; display: flex; flex-wrap: wrap; gap: 6px; }
.chip { background: #eef2ff; color: var(--accent); border-radius: 6px; padding: 3px 8px; font-size: 12px; }

.rx-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.rx-field { display: flex; flex-direction: column; gap: 5px; }
.rx-field label { font-size: 12px; color: var(--muted); }
.rx-field input { width: 100%; }
.rx-field.wide { grid-column: 1 / -1; }

.log-card .step-head { justify-content: space-between; }
.log { font-family: ui-monospace, "Cascadia Code", Consolas, monospace; font-size: 12.5px;
  background: #0f1420; color: #cbd5e1; border-radius: 10px; padding: 12px; height: 220px;
  overflow-y: auto; white-space: pre-wrap; }
.log .t { color: #64748b; }
.log .ok { color: #4ade80; }
.log .err { color: #f87171; }
.log .info { color: #93c5fd; }

.toasts { position: fixed; right: 18px; bottom: 18px; display: grid; gap: 10px; z-index: 50; }
.toast { background: #111827; color: #fff; padding: 11px 15px; border-radius: 10px; box-shadow: var(--shadow);
  font-size: 13px; max-width: 320px; animation: slidein .2s ease; }
.toast.ok { background: #0f9d58; } .toast.err { background: #dc2626; } .toast.warn { background: #d97706; }
@keyframes slidein { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }

@media (max-width: 720px) {
  .downloads, .rx-grid { grid-template-columns: 1fr; }
}
