:root {
  --bg: #f4f6f9;
  --card: #ffffff;
  --ink: #1a2230;
  --muted: #5c6b80;
  --line: #dce3ec;
  --accent: #2f6df6;
  --accent-ink: #ffffff;
  --ok: #1f9d55;
  --warn: #b7791f;
  --err: #d64545;
  --add-bg: #e7f6ec;
  --add-ink: #1f7a44;
  --del-bg: #fdecec;
  --del-ink: #b23b3b;
  --code: "SF Mono", "JetBrains Mono", Menlo, Consolas, "Liberation Mono", monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f141c;
    --card: #182029;
    --ink: #e8edf4;
    --muted: #9aa7b8;
    --line: #29323f;
    --accent: #5b8dff;
    --accent-ink: #0f141c;
    --ok: #4ecb7a;
    --warn: #e0b055;
    --err: #ff6b6b;
    --add-bg: #14301f;
    --add-ink: #7fdca0;
    --del-bg: #351a1a;
    --del-ink: #ff9a9a;
  }
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
code { font-family: var(--code); font-size: 0.92em; background: rgba(127,127,127,0.14); padding: 0.05em 0.35em; border-radius: 4px; }
a { color: var(--accent); }

.wrap { max-width: 940px; margin: 0 auto; padding: 0 20px; }

.site-header { background: linear-gradient(120deg, var(--accent), #7a4df6); color: #fff; padding: 32px 0 28px; }
.site-header h1 { margin: 0 0 6px; font-size: 26px; letter-spacing: -0.3px; }
.site-header .tagline { margin: 0; max-width: 640px; opacity: 0.95; }
.site-header code { background: rgba(255,255,255,0.2); color: #fff; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 20px 22px;
  margin: 20px 0;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}
.card h2 { margin: 0 0 16px; font-size: 17px; display: flex; align-items: center; gap: 10px; }
.step {
  display: inline-grid; place-items: center;
  width: 24px; height: 24px; border-radius: 50%;
  background: var(--accent); color: var(--accent-ink);
  font-size: 13px; font-weight: 700;
}

.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 12px; }
@media (max-width: 620px) { .grid { grid-template-columns: 1fr; } }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { font-size: 13px; color: var(--muted); }
input[type="text"], input[type="password"], select {
  width: 100%; padding: 9px 11px; border: 1px solid var(--line); border-radius: 9px;
  background: var(--bg); color: var(--ink); font: inherit;
}
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: transparent; }
.input-with-btn { display: flex; gap: 8px; }
.input-with-btn > input, .input-with-btn > select { flex: 1; min-width: 0; }

button { cursor: pointer; font: inherit; border-radius: 9px; border: 1px solid transparent; padding: 9px 14px; }
button:disabled { opacity: 0.5; cursor: not-allowed; }
.primary { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.secondary { background: transparent; color: var(--accent); border-color: var(--accent); }
.ghost { background: transparent; color: var(--muted); border-color: var(--line); }
.linklike { background: none; border: none; color: var(--accent); padding: 0; text-decoration: underline; }

.method { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-bottom: 8px; }
.method-label { font-size: 13px; color: var(--muted); }
.segmented { display: inline-flex; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; }
.segmented .seg {
  border: none; border-radius: 0; padding: 8px 14px; font-size: 13px; font-weight: 600;
  background: var(--card); color: var(--muted);
}
.segmented .seg + .seg { border-left: 1px solid var(--line); }
.segmented .seg[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }
.method-hint { margin: 0 0 12px; font-size: 12.5px; color: var(--muted); min-height: 1em; }
#connFields.hidden { display: none; }

.options {
  margin-top: 4px; padding: 14px 16px; border: 1px solid var(--line);
  border-radius: 10px; background: var(--bg); display: flex; flex-direction: column; gap: 14px;
}
.check { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; }
.check > input[type="checkbox"] { width: 17px; height: 17px; margin-top: 2px; flex: 0 0 auto; accent-color: var(--accent); cursor: pointer; }
.check-body { display: flex; flex-direction: column; gap: 3px; }
.check-body strong { font-size: 14px; }
.check-body small, .field .hint { font-size: 12.5px; color: var(--muted); line-height: 1.45; }
.field .hint { margin-top: 2px; }
#levelField.disabled { opacity: 0.5; }
#levelField.disabled select { cursor: not-allowed; }

.status { margin: 12px 0 0; font-size: 13.5px; min-height: 1.2em; }
.status.ok { color: var(--ok); }
.status.err { color: var(--err); }
.status.busy { color: var(--muted); }

.dropzone {
  border: 2px dashed var(--line); border-radius: 12px; padding: 34px 20px; text-align: center;
  transition: border-color 0.15s, background 0.15s;
}
.dropzone.drag { border-color: var(--accent); background: rgba(47,109,246,0.06); }
.dz-big { margin: 0 0 6px; font-size: 16px; }
.dz-sub { margin: 0 0 6px; color: var(--muted); }
.dz-note { margin: 0; font-size: 12.5px; color: var(--muted); }

.files-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.files-head h2 { margin: 0; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; }

.progress { display: flex; align-items: center; gap: 12px; margin: 14px 0 4px; }
.bar { flex: 1; height: 8px; background: var(--bg); border-radius: 99px; overflow: hidden; border: 1px solid var(--line); }
.bar-fill { height: 100%; width: 0; background: var(--accent); transition: width 0.2s; }
#progressText { font-size: 13px; color: var(--muted); white-space: nowrap; }

.file-list { list-style: none; margin: 16px 0 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.file-item { border: 1px solid var(--line); border-radius: 11px; overflow: hidden; }
.file-row { display: flex; align-items: center; gap: 12px; padding: 12px 14px; flex-wrap: wrap; }
.file-name { font-family: var(--code); font-size: 13.5px; font-weight: 600; flex: 1; min-width: 160px; word-break: break-all; }
.file-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.file-actions button { padding: 6px 11px; font-size: 13px; }

.badge { font-size: 11.5px; font-weight: 700; padding: 3px 9px; border-radius: 99px; text-transform: uppercase; letter-spacing: 0.4px; }
.badge.queued { background: rgba(127,127,127,0.16); color: var(--muted); }
.badge.busy { background: rgba(47,109,246,0.16); color: var(--accent); }
.badge.done { background: var(--add-bg); color: var(--add-ink); }
.badge.unchanged { background: rgba(127,127,127,0.16); color: var(--muted); }
.badge.error { background: var(--del-bg); color: var(--del-ink); }
.changes { font-size: 12.5px; color: var(--muted); }
.changes .plus { color: var(--add-ink); font-weight: 600; }
.changes .minus { color: var(--del-ink); font-weight: 600; }

.file-detail { border-top: 1px solid var(--line); padding: 0 14px; display: none; }
.file-detail.open { display: block; padding: 12px 14px; }
.notes { margin: 0 0 12px; padding-left: 18px; font-size: 13px; color: var(--muted); }
.notes li { margin: 2px 0; }
.err-msg { color: var(--err); font-size: 13px; margin: 4px 0 12px; font-family: var(--code); white-space: pre-wrap; }

.diff-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.diff-title { font-size: 12.5px; color: var(--muted); font-weight: 600; }
.diff-actions { display: flex; gap: 6px; }
.code-editor {
  width: 100%; box-sizing: border-box; min-height: 320px; max-height: 460px; resize: vertical;
  border: 1px solid var(--accent); border-radius: 8px; padding: 10px 12px;
  font-family: var(--code); font-size: 12.5px; line-height: 1.5; tab-size: 4;
  background: var(--bg); color: var(--ink); white-space: pre; overflow: auto;
}
.code-editor:focus { outline: 2px solid var(--accent); outline-offset: 0; }
.copy-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 10px; font-size: 12.5px; font-weight: 600;
  background: transparent; color: var(--accent); border: 1px solid var(--line); border-radius: 8px;
}
.copy-btn:hover { border-color: var(--accent); }
.copy-btn.copied { color: var(--ok); border-color: var(--ok); }
.copy-btn svg { flex: 0 0 auto; }

.diff { border: 1px solid var(--line); border-radius: 8px; overflow: auto; max-height: 460px; font-family: var(--code); font-size: 12.5px; }
.diff-line { display: flex; white-space: pre; }
.diff-line .gutter { flex: 0 0 78px; text-align: right; padding: 0 10px; color: var(--muted); user-select: none; opacity: 0.7; }
.diff-line .txt { flex: 1; padding: 0 12px; }
/* +/- markers are CSS-generated so they are never included when copying lines. */
.diff-line .txt::before { content: "  "; }
.diff-line.add .txt::before { content: "+ "; }
.diff-line.del .txt::before { content: "- "; }
.diff-line.add { background: var(--add-bg); }
.diff-line.add .txt { color: var(--add-ink); }
.diff-line.del { background: var(--del-bg); }
.diff-line.del .txt { color: var(--del-ink); }

.site-footer { padding: 8px 20px 40px; color: var(--muted); font-size: 12.5px; }
