:root {
  --denim: #1e325c;
  --sapphire: #1c58d9;
  --sapphire-dark: #164bb8;
  --sunglow: #ffbc1f;
  --ink: #1b1d22;
  --dim: #5c6270;
  --line: #e3e6ed;
  --bg: #f6f7fb;
  --card: #ffffff;
  --danger: #b3261e;
  --danger-bg: #fdecea;
  --danger-line: #f3c6c2;
  --heading: #1e325c;
  --tint: #eef3ff;
  --tint-line: #d3e0fb;
  --warn-bg: #fff8e8;
  --warn-line: #f3dca0;
  --danger-text: #7a1b14;
  --hover: #f3f4f8;
  --bg-soft: #fbfcfe;
  --badge-opt-bg: #e8f0ff;
  --badge-never-bg: #eef0f3;
  --badge-rec-bg: #fff1d6;
  --badge-rec-fg: #8a5a00;
  --focus-ring: rgba(28, 88, 217, .18);
  --link: #1c58d9;
  color-scheme: light;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(20, 24, 38, .04), 0 6px 16px rgba(20, 24, 38, .06);
}


:root[data-theme="dark"] {
  --sapphire: #6b9bff;
  --sapphire-dark: #8fb2ff;
  --ink: #e6e8ee;
  --dim: #9aa2b2;
  --line: #2f3545;
  --bg: #11141b;
  --card: #1a1e28;
  --danger: #ff8a80;
  --danger-bg: #3a1c1a;
  --danger-line: #6b2f2b;
  --danger-text: #ffb4ab;
  --heading: #dbe5fb;
  --tint: #1f2a44;
  --tint-line: #2f4272;
  --warn-bg: #3a3017;
  --warn-line: #6b5a22;
  --hover: #252b39;
  --bg-soft: #151922;
  --badge-opt-bg: #1f2a44;
  --badge-never-bg: #262b38;
  --badge-rec-bg: #3a3017;
  --badge-rec-fg: #ffcf66;
  --focus-ring: rgba(107, 155, 255, .35);
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 16px rgba(0, 0, 0, .35);
  color-scheme: dark;
}
:root[data-theme="dark"] button.primary { background: #2f66e8; color: #fff; }

.theme-toggle {
  float: right;
  margin: 0 0 0 12px;
  width: 36px;
  height: 36px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,.35);
  background: rgba(255,255,255,.12);
  color: #fff;
  cursor: pointer;
}
.theme-toggle .icon-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
.theme-toggle:hover { background: rgba(255,255,255,.22); }

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Inter", -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--sapphire); }

header.banner {
  background: var(--denim);
  color: #fff;
  padding: 20px max(16px, calc((100% - 860px) / 2));
  border-bottom: 3px solid var(--sunglow);
}

header.banner h1 { margin: 0; font-size: 1.25rem; font-weight: 600; }
header.banner .version { margin-left: 8px; padding: 2px 8px; border-radius: 999px; background: rgba(255,255,255,.14); color: #fff; font-size: .78rem; font-weight: 500; vertical-align: middle; }
header.banner p { margin: 6px 0 0; color: #c9d3e6; font-size: .92rem; max-width: 60ch; }

main {
  max-width: 860px;
  margin: 0 auto;
  padding: 20px 16px 8px;
}

.steps {
  display: flex;
  gap: 8px;
  margin: 20px 0 24px;
  flex-wrap: wrap;
}
.steps .step {
  flex: 1;
  min-width: 120px;
  padding: 9px 12px;
  border-radius: 8px;
  background: transparent;
  border: 1px solid var(--line);
  font-size: .82rem;
  color: var(--dim);
  text-align: center;
  cursor: pointer;
  user-select: none;
  transition: border-color .15s ease, color .15s ease, background-color .15s ease;
}
.steps .step:hover { border-color: var(--sapphire); color: var(--sapphire); }
.steps .step.active { border-color: var(--sapphire); color: var(--sapphire); font-weight: 600; background: var(--card); }
.steps .step.done { background: var(--tint); border-color: var(--tint-line); }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px 26px;
  margin-bottom: 20px;
}

.card h2 { margin-top: 0; font-size: 1.15rem; font-weight: 600; color: var(--heading); }
.card h3 { font-size: .98rem; font-weight: 600; color: var(--heading); }
.card p.hint { color: var(--dim); font-size: .9rem; margin-top: -6px; }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 560px) { .grid2 { grid-template-columns: 1fr; } }

label { display: block; font-size: .85rem; font-weight: 600; margin-bottom: 6px; }
label.inline { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.field { margin-bottom: 16px; }
.field .sub { color: var(--dim); font-size: .78rem; font-weight: 400; display: block; margin-top: 2px; }

input[type="text"], input[type="number"], input[type="url"], select, textarea {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 7px;
  font-size: .92rem;
  font-family: inherit;
  background: var(--card);
  color: var(--ink);
  transition: border-color .15s ease, box-shadow .15s ease;
}
textarea { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .82rem; }

input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible,
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--sapphire);
  box-shadow: 0 0 0 3px var(--focus-ring);
}

fieldset { border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; margin: 0 0 16px; }
fieldset legend { font-size: .85rem; font-weight: 600; padding: 0 4px; }
.radio-row { display: flex; gap: 18px; flex-wrap: wrap; }
.radio-row label { font-weight: 400; display: flex; align-items: center; gap: 6px; }

/* Stacked choices, so every option is readable without opening anything. */
.choices { display: flex; flex-direction: column; gap: 8px; }
.choices label {
  font-weight: 400;
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: .92rem;
  line-height: 1.4;
}
.choices input { margin-top: 2px; flex: none; }
.choices input:disabled + *, .choices label:has(input:disabled) { color: var(--dim); }

/* The first choice on the page, because everything below it changes with the
   answer. Not an even pair, though: nearly everyone is here to plan an estate,
   so that one is the card and a lab is the quieter row under it. Giving both
   equal weight would ask people to weigh up a choice they have already made. */
.mode-cards { display: grid; grid-template-columns: 1fr; gap: 8px; margin: 0 0 22px; }
.mode-card {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 0;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  font-weight: 400;
  cursor: pointer;
  transition: border-color .15s ease, background-color .15s ease, box-shadow .15s ease;
}
.mode-card:hover { border-color: var(--tint-line); background: var(--hover); }
.mode-card input { margin: 3px 0 0; flex: none; accent-color: var(--sapphire); }
/* Selected reads as an accent border over a quiet tint. The glow is kept for
   keyboard focus, where it is telling you where you are: carrying it on every
   selected card put a bright halo on the page at all times, which in dark mode
   is a hard thing to look at and says nothing the border hasn't. */
.mode-card:has(input:checked) {
  border-color: var(--sapphire);
  background: var(--tint);
  box-shadow: inset 0 0 0 1px var(--sapphire);
}
.mode-card:has(input:focus-visible) { box-shadow: 0 0 0 3px var(--focus-ring); }
.mode-text { display: block; }
.mode-title { display: block; font-size: .92rem; font-weight: 600; color: var(--heading); }
.mode-sub { display: block; margin-top: 3px; font-size: .82rem; line-height: 1.45; color: var(--dim); }

/* The secondary way out: one line, no card weight of its own until you pick it.
   It still selects, hovers and focuses like the other one, because a quieter
   option is not a harder one to reach. */
.mode-card.quiet { padding: 9px 16px; background: none; border-color: transparent; align-items: baseline; }
.mode-card.quiet:hover { background: var(--hover); border-color: var(--line); }
.mode-card.quiet .mode-text { display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px; }
.mode-card.quiet .mode-title { display: inline; font-size: .88rem; font-weight: 500; }
.mode-card.quiet .mode-sub { display: inline; margin-top: 0; font-size: .8rem; }

button {
  font: inherit;
  cursor: pointer;
  border-radius: 7px;
  border: 1px solid transparent;
  padding: 10px 18px;
  font-weight: 600;
  transition: background-color .15s ease, border-color .15s ease, box-shadow .15s ease;
}
button.primary { background: var(--sapphire); color: #fff; box-shadow: 0 1px 2px rgba(28, 88, 217, .25); }
button.primary:hover { background: var(--sapphire-dark); }
button.secondary { background: var(--card); border-color: var(--line); color: var(--ink); }
button.secondary:hover { background: var(--hover); }
button.link { background: none; border: none; color: var(--sapphire); padding: 4px 6px; font-weight: 600; }
button.small { padding: 5px 10px; font-size: .78rem; }
button:disabled { opacity: .5; cursor: not-allowed; }

.actions { display: flex; justify-content: space-between; margin-top: 20px; gap: 10px; }

/* Table look follows the Mattermost docs "bill of materials" tables. */
table.nodes { width: 100%; border-collapse: collapse; font-size: .85rem; }
table.nodes th, table.nodes td { text-align: left; vertical-align: top; padding: .55rem .75rem; border-bottom: 1px solid var(--line); }
table.nodes th {
  text-transform: uppercase; letter-spacing: .08em; font-size: .7rem; font-weight: 700;
  color: var(--heading); background: rgba(30, 50, 92, .04); border-bottom: 2px solid var(--denim);
}
:root[data-theme="dark"] table.nodes th { color: #fff; background: rgba(255, 255, 255, .03); border-bottom-color: var(--tint-line); }
table.nodes select, table.nodes input { padding: 6px 8px; font-size: .85rem; }

.rationale {
  background: var(--tint);
  border: 1px solid var(--tint-line);
  border-radius: 8px;
  padding: 12px 16px;
  font-size: .9rem;
  margin-bottom: 16px;
}
.note {
  background: var(--warn-bg);
  border: 1px solid var(--warn-line);
  border-radius: 8px;
  padding: 12px 16px;
  font-size: .86rem;
  margin-bottom: 16px;
}
.error-message {
  background: var(--danger-bg);
  border: 1px solid var(--danger-line);
  color: var(--danger-text);
  border-radius: 8px;
  padding: 10px 14px;
  font-size: .86rem;
  margin: 12px 0;
}

.diagram-head { display: flex; justify-content: flex-end; align-items: center; gap: 14px; margin-bottom: 8px; }
.diagram-toggle { display: flex; align-items: center; gap: 6px; font-size: .84rem; color: var(--dim); }
.diagram-toggle input { margin: 0; }
.diagram { overflow: auto; background: var(--bg-soft); border: 1px solid var(--line); border-radius: 8px; padding: 16px; }

/* Expanded: the diagram takes the window, because a real estate does not fit in
   a column of text. */
body.diagram-open { overflow: hidden; }
.diagram.expanded {
  position: fixed; inset: 16px; z-index: 50; margin: 0;
  background: var(--card); box-shadow: var(--shadow); padding: 24px;
  overflow: hidden;
}
.diagram.expanded .mermaid { height: 100%; margin: 0; }
.diagram.expanded svg { width: 100%; height: 100%; }
.diagram-close { position: absolute; top: 12px; right: 12px; z-index: 1; }
.diagram-backdrop { position: fixed; inset: 0; z-index: 40; background: rgba(20, 24, 38, .45); }
.diagram svg { max-width: none; font-family: inherit; }
.diagram .edgeLabel, .diagram .edgeLabel p { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; color: var(--dim); background: var(--tint); }
.diagram .edgeLabel { border-radius: 3px; }


.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: .74rem; font-weight: 600; }
.badge.never { background: var(--badge-never-bg); color: var(--dim); }
.badge.optional { background: var(--badge-opt-bg); color: var(--sapphire); }
.badge.recommended { background: var(--badge-rec-bg); color: var(--badge-rec-fg); }
.badge.required { background: var(--danger-bg); color: var(--danger); }
.badge.always { background: var(--badge-never-bg); color: var(--dim); }

/* The lab component list: one tick per thing that goes on the box, with room
   between them so a row and the hint under it stay a pair. */
#group-lab-components label.inline { margin-bottom: 12px; font-size: .92rem; }
#group-lab-components label.inline:last-of-type { margin-bottom: 0; }
/* A tick the licence puts out of reach reads as unavailable, the same way a
   disabled option does in the stacked choice lists. */
#group-lab-components label.inline:has(input:disabled) { color: var(--dim); }
#group-lab-components input:disabled { accent-color: var(--dim); }

code.blob {
  display: block;
  white-space: pre-wrap;
  word-break: break-all;
  background: #10131a;
  color: #d7e4ff;
  border-radius: 8px;
  padding: 14px;
  font-size: .78rem;
  max-height: 160px;
  overflow: auto;
}

.copy-row { display: flex; flex-direction: column; gap: 8px; align-items: stretch; margin-bottom: 16px; }
.copy-row > button { align-self: flex-end; }
.copy-row > div { min-width: 0; }
.copy-row .row-actions { flex: none; display: flex; flex-direction: row; justify-content: flex-end; gap: 6px; }
.copy-row .row-actions button { white-space: nowrap; }

.followups { font-size: .88rem; padding-left: 20px; }
.followups li { margin-bottom: 6px; }

/* Step 4 reads top to bottom: what to do, then the detail behind it. */
.run-steps {
  background: var(--tint);
  border: 1px solid var(--tint-line);
  border-radius: 8px;
  padding: 12px 16px 12px 8px;
  margin-bottom: 18px;
}
.run-steps ol { margin: 0; padding-left: 24px; font-size: .9rem; }
.run-steps li { margin: 2px 0; }

details.section { border-top: 1px solid var(--line); }
details.section > summary {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 8px;
  margin: 0 -8px;
  border-radius: 6px;
  cursor: pointer;
  font-size: .98rem;
  font-weight: 600;
  color: var(--heading);
  list-style: none;
  user-select: none;
  transition: background-color .15s ease;
}
details.section > summary::-webkit-details-marker { display: none; }
details.section > summary::before {
  content: "";
  flex: none;
  width: 7px;
  height: 7px;
  border-right: 2px solid var(--dim);
  border-bottom: 2px solid var(--dim);
  transform: rotate(-45deg);
  transition: transform .15s ease;
}
details.section[open] > summary::before { transform: rotate(45deg); }
details.section > summary:hover { background: var(--bg); }
details.section > summary:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--focus-ring);
}
details.section .count { color: var(--dim); font-weight: 400; font-size: .85rem; }
details.section > *:not(summary) { margin: 4px 0 16px; }

@media (prefers-reduced-motion: reduce) {
  details.section > summary, details.section > summary::before { transition: none; }
}

/* The estate, grouped by what each tier does. */
.tier { border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; margin-bottom: 10px; background: var(--card); }
.tier-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.tier-head h4 { margin: 0; font-size: .92rem; font-weight: 600; }
.tier-head .shape { color: var(--dim); font-size: .85rem; }
.tier ul { margin: 8px 0 0; padding-left: 18px; font-size: .88rem; }
.tier li { margin-bottom: 3px; }
.tier li .role-note { color: var(--dim); }
.tier li button { margin-left: 6px; }

/* One row per server, name and address side by side. */
.address-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  align-items: end;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}
.address-row:last-of-type { border-bottom: none; }
.address-row label span {
  display: block;
  font-weight: 400;
  color: var(--dim);
  font-size: .78rem;
  margin-top: 2px;
}
@media (max-width: 560px) { .address-row { grid-template-columns: 1fr; } }

.install-order { font-size: .9rem; padding-left: 22px; }
.install-order li { margin-bottom: 8px; }
.install-order .sametime { color: var(--dim); font-size: .8rem; display: block; }

footer { text-align: center; color: var(--dim); font-size: .8rem; padding: 24px 0 48px; }

/* An escape hatch, not the task: quiet enough to ignore. */
.import-box { margin: -4px 0 20px; }
.import-box summary {
  cursor: pointer;
  font-size: .85rem;
  color: var(--dim);
  width: fit-content;
}
.import-box summary:hover { color: var(--sapphire); }
.import-box[open] summary { color: var(--ink); margin-bottom: 4px; }
.import-box textarea { font-size: .78rem; }

/* Same visual language as every other group on the page. */
.group {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px 16px;
  margin-bottom: 16px;
  background: var(--bg-soft);
}
.group > h3 { margin: 0 0 10px; font-size: .85rem; font-weight: 600; color: var(--ink); }

/* Inputs sized to what goes in them. */
input.short { max-width: 160px; }
select.medium { max-width: 320px; }

.field.invalid input, .field.invalid select { border-color: var(--danger); }
input.invalid, select.invalid { border-color: var(--danger); }
.inline-error { color: var(--danger); font-size: .8rem; margin-top: 4px; display: block; }
.optional { color: var(--dim); font-weight: 400; }

.table-wrap { overflow-x: auto; }
.table-wrap table { min-width: 560px; }

/* The product name where prose refers to the installer, not the install.sh file. */
strong.product { font-weight: 600; color: var(--ink); }
