:root {
  --bg: #0f1117;
  --bg-2: #161922;
  --panel: #1a1e29;
  --panel-2: #20242f;
  --border: #262a36;
  --border-2: #313747;
  --text: #c8cdd7;
  --text-strong: #e8ebf2;
  --muted: #7a8294;
  --accent: #7aa2f7;
  --accent-dim: #3a4a73;
  --green: #3ec98e;
  --yellow: #e0af68;
  --red: #e06c75;
  --radius: 10px;
  --radius-sm: 7px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  user-select: none;
  overflow: hidden;
}

.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.mono { font-family: "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace; }

h1 { font-size: 20px; color: var(--text-strong); }
h2 { font-size: 18px; color: var(--text-strong); font-weight: 600; }
h3 { font-size: 13px; color: var(--text-strong); font-weight: 600; }

/* ---------- buttons ---------- */
button { font-family: inherit; font-size: 13px; cursor: pointer; border: none; border-radius: var(--radius-sm); padding: 8px 14px; transition: background .15s, border-color .15s, opacity .15s; }
.btn-primary { background: var(--accent); color: #0b1020; font-weight: 600; }
.btn-primary:hover { background: #8fb2ff; }
.btn-primary:disabled { opacity: .5; cursor: default; }
.btn-ghost { background: var(--panel-2); color: var(--text); border: 1px solid var(--border-2); }
.btn-ghost:hover { background: #2a3040; }
.btn-danger { background: transparent; color: var(--red); border: 1px solid var(--red); }
.btn-danger:hover { background: rgba(224,108,117,.12); }
.small-btn { padding: 5px 10px; font-size: 12px; margin-top: 8px; }

/* ---------- inputs ---------- */
label { display: block; color: var(--muted); font-size: 12.5px; margin-bottom: 12px; }
input[type=text], input[type=password], input[type=number], textarea, select {
  display: block; width: 100%; margin-top: 6px;
  background: var(--bg-2); color: var(--text-strong);
  border: 1px solid var(--border-2); border-radius: var(--radius-sm);
  padding: 9px 11px; font-size: 13px; font-family: inherit;
  user-select: text;
}
input:focus, textarea:focus { outline: none; border-color: var(--accent); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

/* ---------- setup wizard ---------- */
.setup { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; background: radial-gradient(circle at 50% 0%, #161b29, var(--bg) 60%); padding: 24px; overflow: auto; }
.setup-card { width: 460px; max-width: 100%; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 28px; box-shadow: 0 24px 60px rgba(0,0,0,.45); }
.brand { display: flex; gap: 14px; align-items: center; margin-bottom: 22px; }
.brand-mark { font-size: 34px; }
.wizard-steps { display: flex; gap: 8px; margin-bottom: 20px; }
.step { font-size: 12px; color: var(--muted); padding: 5px 10px; border-radius: 20px; background: var(--bg-2); }
.step.active { color: var(--accent); background: var(--accent-dim); }
.paste-row { display: flex; gap: 8px; }
.paste-row input { margin-top: 0; }
.divider { text-align: center; margin: 16px 0; position: relative; color: var(--muted); font-size: 12px; }
.divider::before { content: ""; position: absolute; top: 50%; left: 0; right: 0; height: 1px; background: var(--border); }
.divider span { background: var(--panel); padding: 0 10px; position: relative; }
.wizard-actions, .modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }
.wizard-actions .btn-ghost { margin-right: auto; }

/* ---------- app shell ---------- */
.app { display: flex; height: 100vh; }
.sidebar { width: 216px; background: var(--bg-2); border-right: 1px solid var(--border); display: flex; flex-direction: column; padding: 18px 12px; flex-shrink: 0; }
.logo { display: flex; align-items: center; gap: 9px; padding: 4px 8px 18px; }
.logo-mark { font-size: 20px; }
.logo-text { font-size: 15px; color: var(--text); }
.logo-text strong { color: var(--accent); font-weight: 700; }
nav { display: flex; flex-direction: column; gap: 3px; }
.nav-item { display: flex; align-items: center; gap: 10px; text-align: left; width: 100%; background: transparent; color: var(--muted); padding: 9px 12px; border-radius: var(--radius-sm); font-size: 13.5px; }
.nav-item span { width: 16px; text-align: center; opacity: .8; }
.nav-item:hover { background: var(--panel); color: var(--text); }
.nav-item.active { background: var(--accent-dim); color: var(--text-strong); }
.sidebar-status { margin-top: auto; display: flex; align-items: center; gap: 8px; padding: 10px 12px 4px; border-top: 1px solid var(--border); }

.content { flex: 1; overflow-y: auto; padding: 26px 32px; }
.view-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 22px; }
.head-actions { display: flex; gap: 10px; }
.section-title { margin: 26px 0 12px; padding-bottom: 8px; border-bottom: 1px solid var(--border); }

/* ---------- dots ---------- */
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
.dot.big { width: 14px; height: 14px; }
.dot-green { background: var(--green); box-shadow: 0 0 8px rgba(62,201,142,.6); }
.dot-yellow { background: var(--yellow); box-shadow: 0 0 8px rgba(224,175,104,.6); }
.dot-red { background: var(--red); box-shadow: 0 0 8px rgba(224,108,117,.6); }
.dot-grey { background: var(--muted); }

/* ---------- dashboard ---------- */
.status-banner { display: flex; align-items: center; gap: 14px; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; margin-bottom: 18px; }
.status-title { font-size: 15px; color: var(--text-strong); font-weight: 600; }
.cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.card-label { font-size: 12px; color: var(--muted); margin-bottom: 8px; }
.card-value { font-size: 18px; color: var(--text-strong); font-weight: 600; }

.progress-wrap { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 20px; margin-bottom: 18px; }
.progress-head { display: flex; justify-content: space-between; margin-bottom: 8px; font-size: 13px; color: var(--text-strong); }
.progress-bar { height: 8px; background: var(--bg-2); border-radius: 6px; overflow: hidden; }
.progress-fill { height: 100%; width: 0%; background: linear-gradient(90deg, var(--accent), #9bb8ff); transition: width .3s; }
#progressDetail { margin-top: 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.history { display: flex; flex-direction: column; gap: 8px; }
.history-row { display: flex; align-items: center; gap: 10px; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 14px; }

/* ---------- folders ---------- */
.folder-list { display: flex; flex-direction: column; gap: 8px; }
.folder-row { display: flex; align-items: center; gap: 12px; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 11px 14px; }
.folder-row input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--accent); flex-shrink: 0; }
.folder-path { flex: 1; color: var(--text-strong); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.folder-remove { color: var(--muted); background: transparent; padding: 4px 8px; font-size: 16px; }
.folder-remove:hover { color: var(--red); }
.excludes { width: 100%; min-height: 140px; resize: vertical; font-family: "SF Mono", Menlo, Consolas, monospace; font-size: 12.5px; line-height: 1.6; }
.schedule-opts { display: flex; flex-wrap: wrap; gap: 10px; }
.radio { display: inline-flex; align-items: center; gap: 8px; margin: 0; background: var(--panel); border: 1px solid var(--border-2); border-radius: var(--radius-sm); padding: 9px 14px; cursor: pointer; color: var(--text); }
.radio input { accent-color: var(--accent); }
.radio:has(input:checked) { border-color: var(--accent); background: var(--accent-dim); }

/* ---------- snapshots ---------- */
.snap-layout { display: grid; grid-template-columns: 240px 1fr; gap: 16px; height: calc(100vh - 130px); }
.snap-list { overflow-y: auto; display: flex; flex-direction: column; gap: 6px; padding-right: 4px; }
.snap-item { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 11px 13px; cursor: pointer; }
.snap-item:hover { border-color: var(--border-2); }
.snap-item.active { border-color: var(--accent); background: var(--accent-dim); }
.snap-date { color: var(--text-strong); font-size: 13px; font-weight: 600; }
.snap-meta { color: var(--muted); font-size: 11.5px; margin-top: 3px; }
.snap-browser { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); display: flex; flex-direction: column; overflow: hidden; }
.breadcrumb { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--border); font-size: 12.5px; min-height: 44px; }
.crumb { color: var(--accent); cursor: pointer; }
.crumb:hover { text-decoration: underline; }
.crumb-sep { color: var(--muted); }
.file-list { overflow-y: auto; flex: 1; }
.empty-hint { padding: 24px; }
.file-row { display: flex; align-items: center; gap: 10px; padding: 9px 16px; border-bottom: 1px solid var(--bg-2); }
.file-row:hover { background: var(--bg-2); }
.file-icon { width: 18px; text-align: center; opacity: .85; }
.file-name { flex: 1; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-name.dir { color: var(--text-strong); cursor: pointer; }
.file-name.dir:hover { color: var(--accent); }
.file-size { color: var(--muted); font-size: 12px; width: 80px; text-align: right; }
.file-restore { opacity: 0; background: var(--panel-2); border: 1px solid var(--border-2); color: var(--text); padding: 4px 10px; font-size: 12px; }
.file-row:hover .file-restore { opacity: 1; }

/* ---------- settings ---------- */
.toggle-row { display: flex; align-items: center; gap: 10px; color: var(--text); cursor: pointer; }
.toggle-row input { width: 16px; height: 16px; accent-color: var(--accent); }
.warn { color: var(--yellow); margin-top: 4px; }
.repo-info { margin-top: 8px; }

/* ---------- modal ---------- */
.modal { position: fixed; inset: 0; background: rgba(8,10,16,.66); display: flex; align-items: center; justify-content: center; z-index: 50; }
.modal-card { width: 440px; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; box-shadow: 0 24px 60px rgba(0,0,0,.5); }
.modal-card h3 { font-size: 16px; margin-bottom: 10px; }
.restore-opts { display: flex; flex-direction: column; gap: 8px; margin: 16px 0; }

/* ---------- messages / toast ---------- */
.msg { margin-top: 14px; padding: 10px 13px; border-radius: var(--radius-sm); font-size: 12.5px; }
.msg.ok { background: rgba(62,201,142,.12); color: var(--green); border: 1px solid rgba(62,201,142,.3); }
.msg.err { background: rgba(224,108,117,.12); color: var(--red); border: 1px solid rgba(224,108,117,.3); }
.msg.info { background: rgba(122,162,247,.1); color: var(--accent); border: 1px solid rgba(122,162,247,.3); }
.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: var(--panel-2); border: 1px solid var(--border-2); color: var(--text-strong); padding: 11px 18px; border-radius: var(--radius-sm); font-size: 13px; z-index: 60; box-shadow: 0 10px 30px rgba(0,0,0,.4); }
.toast.ok { border-color: rgba(62,201,142,.4); }
.toast.err { border-color: rgba(224,108,117,.4); }

/* ---------- scrollbars ---------- */
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: #2a3040; border-radius: 6px; }
::-webkit-scrollbar-thumb:hover { background: #353c4e; }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- preview banner (browser demo only) ---------- */
#previewBanner { position: fixed; bottom: 0; left: 0; right: 0; background: #161b29; border-top: 1px solid #313747; color: #7a8294; font-size: 12.5px; text-align: center; padding: 9px 14px; z-index: 80; }
#previewBanner strong { color: #7aa2f7; }
#previewBanner a { color: #7aa2f7; text-decoration: none; margin-left: 6px; }
#previewBanner a:hover { text-decoration: underline; }
.content { padding-bottom: 52px; }
.snap-layout { height: calc(100vh - 178px) !important; }
