:root {
  color-scheme: light dark;
  --accent: #2f6fd0; --bg: #f4f6fa; --ink: #1d2430; --card: #fff;
  --muted: #5d6b7f; --edge: #dfe5ef; --danger: #b42318; --ok: #027a48;
  --danger-bg: #fef3f2; --ok-bg: #ecfdf3;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141922; --ink: #e8edf5; --card: #1c232f; --muted: #9aa8bd;
    --edge: #2b3542; --danger: #f97066; --ok: #6ce9a6;
    --danger-bg: #2a1614; --ok-bg: #12261c;
  }
}
* { box-sizing: border-box; }
body {
  margin: 0; padding: 0 20px 80px; background: var(--bg); color: var(--ink);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
.wrap { width: min(880px, 100%); margin: 0 auto; }

.topbar {
  position: sticky; top: 0; z-index: 10; background: var(--bg);
  border-bottom: 1px solid var(--edge); margin-bottom: 28px;
}
.topbar .wrap:first-child {
  display: flex; align-items: center; gap: 16px; padding: 14px 0 10px;
}
.tabs { display: flex; gap: 2px; }
.tab {
  border: 0; border-bottom: 2px solid transparent; background: none;
  color: var(--muted); padding: 9px 14px; border-radius: 8px 8px 0 0;
  font: inherit; font-weight: 500; cursor: pointer;
}
.tab:hover { color: var(--ink); }
.tab[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--accent); }
.tab:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.topbar h1 { margin: 0; font-size: 1.05rem; letter-spacing: -.01em; }
.topbar .spacer { flex: 1; }
.dirty { font-size: .8rem; color: var(--muted); }
.dirty[hidden] { display: none; }

section {
  background: var(--card); border: 1px solid var(--edge); border-radius: 14px;
  padding: 22px 24px; margin-bottom: 18px;
}
section > h2 {
  margin: 0 0 4px; font-size: .95rem; font-weight: 650; letter-spacing: -.01em;
}
section > .hint { margin: 0 0 18px; font-size: .84rem; color: var(--muted); }

label { display: block; font-size: .8rem; font-weight: 600; color: var(--muted); margin-bottom: 5px; }
input[type=text], input[type=url], input[type=password], input[type=number], select, textarea {
  width: 100%; padding: 9px 11px; border: 1px solid var(--edge); border-radius: 9px;
  background: var(--bg); color: var(--ink); font: inherit;
}
input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent;
}
textarea { resize: vertical; min-height: 62px; }
.field { margin-bottom: 16px; }
.cols { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }

.check { display: flex; align-items: flex-start; gap: 10px; margin-bottom: 12px; }
.check input { margin-top: 3px; flex: none; }
.check label { margin: 0; font-size: .9rem; font-weight: 500; color: var(--ink); }
.check .hint { margin: 2px 0 0; font-size: .8rem; color: var(--muted); }

button {
  appearance: none; border: 1px solid var(--edge); background: var(--card);
  color: var(--ink); border-radius: 9px; padding: 8px 14px; font: inherit;
  cursor: pointer;
}
button:hover { border-color: var(--accent); }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.primary:disabled { opacity: .5; cursor: default; border-color: var(--accent); }
button.link { border: 0; background: none; color: var(--muted); padding: 6px 8px; white-space: nowrap; }
button.link:hover { color: var(--danger); }
button.add { border-style: dashed; color: var(--muted); width: 100%; margin-top: 4px; }

.rows { display: flex; flex-direction: column; gap: 8px; margin-bottom: 8px; }
.row { display: flex; gap: 8px; align-items: center; }
.row > .grow { flex: 1 1 auto; min-width: 0; }
.row > .fixed { flex: 0 0 120px; }
.row .drop { flex: none; }
.empty-row { color: var(--muted); font-size: .86rem; padding: 10px 2px; }

.banner { border-radius: 10px; padding: 12px 14px; margin-bottom: 16px; font-size: .88rem; }
.banner.error { background: var(--danger-bg); color: var(--danger); }
.banner.ok { background: var(--ok-bg); color: var(--ok); }
.banner ul { margin: 6px 0 0; padding-left: 18px; }

.logo-row { display: flex; align-items: center; gap: 14px; }
.logo-row img { max-height: 52px; max-width: 160px; border-radius: 8px; }
.swatch { display: flex; align-items: center; gap: 8px; }
.swatch input[type=color] {
  width: 38px; height: 38px; padding: 2px; border: 1px solid var(--edge);
  border-radius: 8px; background: var(--bg); cursor: pointer; flex: none;
}

.centre { min-height: 100vh; display: grid; place-items: center; }
.centre section { width: min(420px, 100%); }
.mono { font: 12px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--muted); }

/* ---- link groups ---- */
.group {
  border: 1px solid var(--edge); border-radius: 12px;
  padding: 14px 16px; margin-bottom: 12px; background: var(--bg);
}
.group.drag-over { border-color: var(--accent); }
.group.dragging { opacity: .45; }

.group-head { display: flex; gap: 8px; align-items: center; margin-bottom: 4px; }
.group-head .title-input { flex: 1 1 auto; font-weight: 600; }
.group-desc-input { margin: 8px 0 12px; }

.handle {
  flex: none; width: 26px; height: 32px; border: 0; background: none;
  color: var(--muted); cursor: grab; padding: 0; border-radius: 6px;
  font-size: 15px; line-height: 1;
}
.handle:hover { color: var(--ink); background: var(--card); }
.handle:active { cursor: grabbing; }

.nudge {
  flex: none; width: 26px; height: 26px; padding: 0; line-height: 1;
  font-size: 11px; color: var(--muted); border-radius: 6px;
}
.nudge:disabled { opacity: .3; cursor: default; border-color: var(--edge); }

.group-links { padding-left: 4px; }
.group-links .row { padding: 3px 0; border-radius: 8px; }
.group-links .row.dragging { opacity: .45; }
.group-links .row.drag-over { box-shadow: 0 -2px 0 var(--accent); }
.link-desc-input { flex: 1 1 30%; min-width: 0; }
.group-empty { color: var(--muted); font-size: .84rem; padding: 6px 2px; }

/* Drag handles are keyboard-operable: focus one and use the arrow keys. That
   replaces a second set of move buttons rather than adding clutter beside it. */
.handle:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; color: var(--ink); }
.handle[aria-grabbed="true"] { background: var(--accent); color: #fff; }

.drop-zone { min-height: 12px; border-radius: 8px; }
.drop-zone.drag-over { box-shadow: inset 0 0 0 2px var(--accent); min-height: 30px; }

.category { border: 1px solid var(--edge); border-radius: 12px;
  padding: 14px 16px; margin-bottom: 12px; background: var(--bg); }
.category.drag-over { border-color: var(--accent); }
.category-head { display: flex; gap: 8px; align-items: center; margin-bottom: 10px; }
.category-head .title-input { flex: 1 1 auto; font-weight: 600; }

.version { font: 11px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--muted); opacity: .75; }

.check-result {
  margin-top: 12px; padding: 12px 14px; border-radius: 10px;
  border: 1px solid var(--edge); font-size: .9rem;
}
.check-result.allowed { background: var(--ok-bg); border-color: transparent; color: var(--ok); }
.check-result.blocked { background: var(--danger-bg); border-color: transparent; color: var(--danger); }
.check-result .verdict { font-weight: 650; display: block; margin-bottom: 3px; }
.check-result .because { opacity: .85; }

.steps { margin: 0 0 4px; padding-left: 20px; color: var(--ink); font-size: .92rem; }
.steps li { margin-bottom: 7px; }
.setup-step { border-bottom: 1px solid var(--edge); padding: 12px 0; }
.setup-step:last-child { border-bottom: 0; }
.setup-step .check { margin: 0; }

.badge {
  display: inline-block; min-width: 20px; padding: 1px 7px; border-radius: 10px;
  background: var(--accent); color: #fff; font-size: .74rem; font-weight: 650;
  vertical-align: middle; margin-left: 4px;
}
.request { border: 1px solid var(--edge); border-radius: 10px; padding: 12px 14px; margin-bottom: 8px; }
.request .host { font-weight: 600; }
.request .full { font: 12px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace;
  color: var(--muted); word-break: break-all; margin: 3px 0 10px; }
.request .row { gap: 8px; }

.facts { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; margin: 0 0 12px; font-size: .9rem; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }

/* Brand mark beside the product name. */
h1 .mark, h2 .mark { width: 1.15em; height: 1.15em; vertical-align: -0.2em; margin-right: 0.35em; color: var(--accent); }
