:root {
  --bg: #0f1016;
  --bg-raised: #171924;
  --bg-sunken: #0b0c11;
  --panel: #1c1f2c;
  --panel-hover: #232737;
  --border: #2a2f42;
  --border-soft: #22263447;
  --text: #e8eaf2;
  --text-dim: #9aa0b4;
  --text-faint: #6d738a;
  --accent: #f0b429;
  --accent-soft: #f0b42922;
  --accent-text: #1a1405;
  --green: #4ade80;
  --green-soft: #4ade8018;
  /*
   * A whole card's worth of green, so much fainter than a tag's -- but it has
   * to be seen across a grid at a glance, which 6% was not.
   */
  --green-tint: #4ade8016;
  --green-tint-hover: #4ade8024;
  --red: #f87171;
  --red-soft: #f8717118;
  --blue: #60a5fa;
  --purple: #c084fc;
  --radius: 10px;
  --radius-sm: 7px;
  --shadow: 0 8px 28px #00000055;
  --mono: ui-monospace, "Cascadia Mono", Consolas, monospace;
}

:root[data-theme='light'] {
  --bg: #f4f5f8;
  --bg-raised: #ffffff;
  --bg-sunken: #e9ebf0;
  --panel: #ffffff;
  --panel-hover: #f0f2f7;
  --border: #d8dbe4;
  --border-soft: #e4e7ee;
  --text: #1b1e28;
  --text-dim: #5c6378;
  --text-faint: #878ea3;
  --accent: #b47c05;
  --accent-soft: #f0b42922;
  --accent-text: #ffffff;
  --green-tint: #16a34a1a;
  --green-tint-hover: #16a34a2b;
  --shadow: 0 8px 24px #0f172a1a;
}

* {
  box-sizing: border-box;
}

/**
 * The `hidden` attribute only works through a UA rule of `display: none`, which
 * ANY author `display` declaration outranks. Several elements here are laid out
 * with grid or flex and toggled by that attribute, so without this they are
 * never actually hidden -- including the modal backdrop, which would sit
 * invisible over the whole page eating every click.
 */
[hidden] {
  display: none !important;
}

html,
body {
  height: 100%;
  margin: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

h1,
h2,
h3 {
  margin: 0;
  font-weight: 650;
  letter-spacing: -0.01em;
}

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

/* ---------------------------------------------------------------- layout */

.app {
  display: grid;
  grid-template-columns: 252px 1fr;
  height: 100vh;
}

.sidebar {
  background: var(--bg-sunken);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 18px 14px;
  gap: 18px;
  overflow: hidden;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: linear-gradient(145deg, var(--accent), #c98a0c);
  color: var(--accent-text);
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 17px;
  flex: none;
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.25;
  min-width: 0;
}

.brand-text strong {
  font-size: 14px;
}

.brand-text span {
  font-size: 11px;
  color: var(--text-faint);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.field label {
  display: block;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-faint);
  margin-bottom: 6px;
  font-weight: 600;
}

.select,
.input {
  width: 100%;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  outline: none;
}

.select:focus,
.input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.flavor-meta {
  margin-top: 7px;
  font-size: 11px;
  color: var(--text-faint);
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  background: none;
  border: 0;
  border-radius: var(--radius-sm);
  padding: 9px 11px;
  cursor: pointer;
  color: var(--text-dim);
  text-align: left;
  font-weight: 500;
}

.nav-item:hover {
  background: var(--panel-hover);
  color: var(--text);
}

.nav-item.is-active {
  background: var(--accent-soft);
  color: var(--accent);
}

.nav-icon {
  width: 16px;
  text-align: center;
  opacity: 0.85;
}

.nav-badge {
  margin-left: auto;
  background: var(--accent);
  color: var(--accent-text);
  border-radius: 999px;
  padding: 1px 7px;
  font-size: 11px;
  font-weight: 700;
}

.sidebar-foot {
  border-top: 1px solid var(--border);
  padding-top: 12px;
}

.auto-status {
  display: flex;
  gap: 9px;
  align-items: flex-start;
  font-size: 11px;
}

.auto-status .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-faint);
  margin-top: 4px;
  flex: none;
}

.auto-status.is-on .dot {
  background: var(--green);
  box-shadow: 0 0 0 3px var(--green-soft);
}

.auto-title {
  color: var(--text);
  font-weight: 600;
}

.auto-sub {
  color: var(--text-faint);
}

.main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 24px 14px;
  border-bottom: 1px solid var(--border);
}

.topbar h1 {
  font-size: 19px;
}

.subtitle {
  margin: 3px 0 0;
  color: var(--text-faint);
  font-size: 12.5px;
}

.topbar-right {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.view {
  flex: 1;
  overflow-y: auto;
  padding: 18px 24px 40px;
}

/* --------------------------------------------------------------- buttons */

.btn {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 7px 13px;
  cursor: pointer;
  font-weight: 550;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.btn:hover:not(:disabled) {
  background: var(--panel-hover);
  border-color: #3a4159;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
}

.btn-primary:hover:not(:disabled) {
  filter: brightness(1.08);
  background: var(--accent);
}

.btn-ghost {
  background: none;
  border-color: transparent;
  color: var(--text-dim);
}

.btn-ghost:hover:not(:disabled) {
  color: var(--text);
}

.btn-danger {
  color: var(--red);
}

.btn-danger:hover:not(:disabled) {
  background: var(--red-soft);
  border-color: var(--red);
}

.btn-sm {
  padding: 4px 9px;
  font-size: 12.5px;
}

/* ---------------------------------------------------------------- pieces */

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.panel + .panel {
  margin-top: 16px;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 13px 16px;
  border-bottom: 1px solid var(--border);
}

.panel-head h2 {
  font-size: 14px;
}

.panel-head .hint {
  color: var(--text-faint);
  font-size: 12px;
  font-weight: 400;
}

.panel-body {
  padding: 16px;
}

.toolbar {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.toolbar .input {
  width: auto;
  flex: 1;
  min-width: 180px;
}

.chips {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.chip {
  border: 1px solid var(--border);
  background: var(--panel);
  border-radius: 999px;
  padding: 4px 11px;
  font-size: 12px;
  cursor: pointer;
  color: var(--text-dim);
}

.chip.is-on {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
}

.chip:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.tag {
  display: inline-block;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.03em;
  padding: 2px 7px;
  border-radius: 5px;
  background: var(--bg-sunken);
  color: var(--text-dim);
  border: 1px solid var(--border-soft);
}

.tag-accent {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: transparent;
}

.tag-green {
  background: var(--green-soft);
  color: var(--green);
  border-color: transparent;
}

.tag-red {
  background: var(--red-soft);
  color: var(--red);
  border-color: transparent;
}

.tag-test {
  background: #c084fc22;
  color: var(--purple);
  border-color: transparent;
}

/* --------------------------------------------------------------- tables */

.rows {
  display: flex;
  flex-direction: column;
}

/*
 * The width of the last column, which holds the buttons.
 *
 * Fixed rather than `auto`, and this is the whole reason it has a name. Every
 * row is its own grid, so an `auto` track is sized by that row's own buttons:
 * a row with an update waiting carries an Update button and is sixty pixels
 * wider there than one without. The `1fr` name column absorbs the difference,
 * which drags both version columns sideways -- so the table zigzagged, the
 * header lined up with nothing, and the whole thing shifted as updates
 * appeared and again as each one finished. Fixed, every row agrees with every
 * other and with the header, whatever is in the actions cell.
 *
 * Wide enough for the widest of them (Update beside the menu button) with a
 * little room to spare; the buttons are right-aligned, so anything left over
 * is invisible.
 */
.row {
  --row-actions: 108px;
  display: grid;
  grid-template-columns: 1fr 150px 130px var(--row-actions);
  gap: 14px;
  align-items: center;
  padding: 11px 16px;
  border-bottom: 1px solid var(--border-soft);
}

.row:last-child {
  border-bottom: 0;
}

.row:hover {
  background: var(--panel-hover);
}

.row.is-disabled .row-name {
  opacity: 0.5;
}

.row-name {
  min-width: 0;
}

.row-title {
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 7px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.row-sub {
  color: var(--text-faint);
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 1px;
}

.row-version {
  font-size: 12.5px;
  color: var(--text-dim);
  font-family: var(--mono);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/*
 * A badge has to stay inside its column.
 *
 * The cell clips, but a badge is a box with a background and a border, so
 * clipping one cuts it off square in the middle of a word with no ellipsis
 * and no right-hand edge -- it stops looking like a badge at all. The "by
 * hand" variant carries a version and an explanation and does this with any
 * long version string. Giving it its own ellipsis keeps the version, which is
 * the part worth reading, and the whole thing still looks like a badge.
 */
.row-version .tag {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: middle;
}

.row-actions {
  display: flex;
  gap: 5px;
  justify-content: flex-end;
}

.row-head {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-faint);
  font-weight: 600;
  background: var(--bg-sunken);
}

.row-head:hover {
  background: var(--bg-sunken);
}

/* ---------------------------------------------------------------- cards */

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 12px;
}

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 13px;
  display: flex;
  gap: 11px;
  min-width: 0;
}

.card:hover {
  border-color: #3a4159;
}

.card-thumb {
  width: 46px;
  height: 46px;
  border-radius: 8px;
  object-fit: cover;
  background: var(--bg-sunken);
  flex: none;
}

.card-body {
  min-width: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.card-title {
  font-weight: 620;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-sub {
  font-size: 12px;
  color: var(--text-faint);
}

.card-summary {
  font-size: 12.5px;
  color: var(--text-dim);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-foot {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
}

/* -------------------------------------------------------------- feedback */

.empty {
  text-align: center;
  padding: 50px 20px;
  color: var(--text-faint);
}

.empty h3 {
  color: var(--text-dim);
  margin-bottom: 6px;
  font-size: 15px;
}

.notice {
  display: flex;
  gap: 11px;
  align-items: flex-start;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
  border: 1px solid #f0b42944;
  margin-bottom: 14px;
  font-size: 13px;
}

.notice-red {
  background: var(--red-soft);
  border-color: #f8717144;
}

.notice strong {
  display: block;
  margin-bottom: 2px;
}

.progress {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-raised);
}

.progress-bar {
  flex: 1;
  height: 5px;
  border-radius: 3px;
  background: var(--bg-sunken);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0;
  background: var(--accent);
  transition: width 0.18s ease;
}

.progress-label {
  font-size: 12px;
  color: var(--text-dim);
  white-space: nowrap;
  max-width: 45%;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* One addon another one needs, named in the summary panel. */
.dep {
  display: inline-block;
  font-size: 12px;
  padding: 2px 8px;
  margin: 2px 2px 0 0;
  border-radius: 999px;
  background: var(--bg-sunken);
  border: 1px solid var(--border);
}

.dep.is-here {
  border-color: transparent;
  background: var(--green-soft);
}

/* --------------------------------------------------------------- guild */

/*
 * Picking the addons that satisfy a requirement.
 *
 * The alternatives are equals -- "DBM or BigWigs" -- so they are chips on one
 * line rather than a list of rows with one on top, and the search below them
 * is a bounded list you scroll rather than something that grows the dialog
 * until the buttons are off the bottom of the screen.
 */
/* Works as a span inside a <label> and as a caption over a group of controls. */
.field-label {
  display: block;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-faint);
  font-weight: 600;
  margin-bottom: 8px;
}

.chips-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.chips-or {
  font-size: 11.5px;
  color: var(--text-faint);
  padding: 0 2px;
}

.chip-pick {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 4px 5px 4px 6px;
  background: var(--bg-sunken);
  border: 1px solid var(--border);
  border-radius: 999px;
  max-width: 100%;
}

.chip-pick-name {
  font-size: 12.5px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chip-pick-btn {
  border: 0;
  background: transparent;
  color: var(--text-faint);
  cursor: pointer;
  font-size: 13px;
  line-height: 1;
  padding: 3px 4px;
  border-radius: 6px;
}

.chip-pick-btn:hover {
  background: var(--panel-hover);
  color: var(--text);
}

.chip-pick-drop:hover {
  color: var(--red);
}

.pick-empty,
.pick-note {
  font-size: 12.5px;
  color: var(--text-faint);
  margin: 0;
}

.pick-note {
  margin-top: 8px;
}

.picker {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--panel);
}

.picker-input.input {
  border: 0;
  border-bottom: 1px solid var(--border);
  border-radius: 0;
  background: transparent;
}

.picker-input.input:focus {
  outline: none;
  box-shadow: none;
  border-color: var(--accent);
}

/*
 * Bounded and scrollable. Without a ceiling the results push the dialog past
 * the bottom of the window, so you cannot see what you are picking and the
 * buttons you need are off screen.
 */
.picker-results {
  max-height: 232px;
  /*
   * The picker gives way before the dialog does, so on a short window it
   * shrinks rather than pushing the buttons off. The floor keeps it to three
   * rows or so, below which it stops being a list you can choose from.
   */
  min-height: 132px;
  overflow-y: auto;
}

.pick-row {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  border: 0;
  border-bottom: 1px solid var(--border-soft);
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
  font: inherit;
}

.pick-row:last-child {
  border-bottom: 0;
}

.pick-row:hover:not([disabled]),
.pick-row:focus-visible {
  background: var(--panel-hover);
}

.pick-row[disabled] {
  cursor: default;
  opacity: 0.55;
}

.pick-thumb {
  width: 26px;
  height: 26px;
  border-radius: 6px;
  flex: none;
  object-fit: cover;
  background: var(--bg-sunken);
}

.pick-thumb-blank {
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-faint);
}

.pick-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
}

.pick-name {
  font-size: 13px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pick-sub {
  font-size: 11.5px;
  color: var(--text-faint);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pick-add {
  flex: none;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--accent);
  padding: 3px 9px;
  border-radius: 6px;
  background: var(--accent-soft);
}

.pick-row[disabled] .pick-add {
  color: var(--text-faint);
  background: var(--bg-sunken);
}

.pick-state {
  padding: 22px 12px;
  text-align: center;
  font-size: 12.5px;
  color: var(--text-faint);
}

/*
 * A tick means every required addon and nothing less, so it is the one green
 * thing on the row and reads at a glance down a column of forty people.
 *
 * Named with their containers as well as on their own: `.setting-text span`
 * is two classes and would otherwise win, which painted every tick the same
 * grey as the text beside it and made the column say nothing at all.
 */
.tick-ok,
.setting-text .tick-ok,
.roster-row .tick-ok {
  color: var(--green);
  font-weight: 700;
}

.tick-no,
.setting-text .tick-no,
.roster-row .tick-no {
  color: var(--red);
  font-weight: 600;
  font-size: 12px;
}

/*
 * Consecutive spans inside .setting-text are inline, so a second line of
 * explanation ran straight on from the first: "...Either is fineYou have
 * BigWigs". These are separate sentences and get separate lines.
 */
.setting-text .setting-line {
  display: block;
}

.roster {
  display: flex;
  flex-direction: column;
}

.roster-row,
.roster-head {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) 110px minmax(0, 1.6fr) minmax(0, 1.2fr) auto;
  gap: 12px;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--border-soft);
  font-size: 13px;
}

.roster-row:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.roster-head {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-faint);
  font-weight: 600;
}

.roster-name,
.roster-has {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.roster-actions {
  display: flex;
  gap: 4px;
  justify-content: flex-end;
}

/* The roster is the one table here that genuinely needs the width. */
@media (max-width: 900px) {
  .roster-row,
  .roster-head {
    grid-template-columns: minmax(0, 1fr) 100px auto;
  }
  .roster-has,
  .roster-row > span:nth-child(4),
  .roster-head > span:nth-child(3),
  .roster-head > span:nth-child(4) {
    display: none;
  }
}

/* The foot of the browse list, where the next page is fetched. */
.load-more {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 22px 0 8px;
  font-size: 13px;
}

/* The helper replacing itself, shown inside its own dialog. */
.update-progress {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/*
 * `flex: none` matters. The shared .progress-bar carries `flex: 1` for the
 * toolbar it was written for, where the row is horizontal; in this column it
 * makes flex-basis the *height*, which collapses the bar to nothing however
 * many pixels `height` asks for. It rendered at exactly 0px.
 */
.update-progress .progress-bar {
  flex: none;
  width: 100%;
  height: 7px;
}

/*
 * For a download whose size we were never told -- an older helper reports no
 * byte counts at all. A bar that cannot move is how a working update comes to
 * look like a hung one, so this one moves without claiming to know how far
 * along it is.
 */
.progress-fill.is-waiting {
  width: 35% !important;
  animation: progress-waiting 1.4s ease-in-out infinite;
}

@keyframes progress-waiting {
  0% { margin-left: -35%; }
  100% { margin-left: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  .progress-fill.is-waiting {
    animation: none;
    width: 100% !important;
    opacity: 0.4;
  }
}

.toasts {
  position: fixed;
  right: 18px;
  bottom: 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 50;
  max-width: 380px;
}

.toast {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: 11px 13px;
  box-shadow: var(--shadow);
  font-size: 13px;
  animation: slide-in 0.18s ease;
}

.toast.is-error {
  border-left-color: var(--red);
}

.toast.is-ok {
  border-left-color: var(--green);
}

.toast-title {
  font-weight: 620;
  margin-bottom: 2px;
}

.toast-body {
  color: var(--text-dim);
  word-break: break-word;
}

@keyframes slide-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
}

.spinner {
  width: 13px;
  height: 13px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: inline-block;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* --------------------------------------------------------------- modals */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: #00000088;
  display: grid;
  place-items: center;
  z-index: 60;
  padding: 24px;
}

/*
 * The whole box used to scroll, which put the buttons below the fold on any
 * dialog taller than the window -- you had to scroll a dialog to find out how
 * to dismiss it. Only the body scrolls now, so the title and the actions stay
 * where they are.
 */
.modal {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
  width: min(560px, 100%);
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-head {
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
  flex: none;
}

.modal-body {
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  /* min-height is what actually lets a flex child shrink and scroll. */
  min-height: 0;
  overflow-y: auto;
}

.modal-foot {
  padding: 14px 18px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  flex: none;
}

/* -------------------------------------------------------------- settings */

.setting {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
  padding: 14px 0;
  border-bottom: 1px solid var(--border-soft);
}

.setting:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.setting-text {
  max-width: 62%;
}

.setting-text strong {
  display: block;
  font-weight: 600;
}

.setting-text span {
  color: var(--text-faint);
  font-size: 12.5px;
}

.setting-control {
  display: flex;
  gap: 8px;
  align-items: center;
  flex: none;
}

.switch {
  width: 40px;
  height: 22px;
  border-radius: 999px;
  background: var(--border);
  border: 0;
  position: relative;
  cursor: pointer;
  flex: none;
  transition: background 0.15s;
}

.switch::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--text);
  transition: transform 0.15s;
}

.switch.is-on {
  background: var(--accent);
}

.switch.is-on::after {
  transform: translateX(18px);
  background: var(--accent-text);
}

.key-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.key-row .input {
  flex: 1;
  font-family: var(--mono);
  font-size: 12.5px;
}

.mono {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-faint);
  word-break: break-all;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.muted {
  color: var(--text-faint);
}

.inline-link {
  background: none;
  border: 0;
  padding: 0;
  color: var(--blue);
  cursor: pointer;
  text-decoration: underline;
  font-size: inherit;
}

::-webkit-scrollbar {
  width: 11px;
  height: 11px;
}

::-webkit-scrollbar-thumb {
  background: #333a52;
  border-radius: 6px;
  border: 3px solid transparent;
  background-clip: content-box;
}

::-webkit-scrollbar-thumb:hover {
  background: #434b69;
  background-clip: content-box;
}

::-webkit-scrollbar-track {
  background: transparent;
}

/* ------------------------------------------------- the helper's card */

.gate-card {
  width: min(560px, 100%);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 32px;
  box-shadow: var(--shadow);
  text-align: center;
}

.brand-mark-lg {
  width: 58px;
  height: 58px;
  border-radius: 15px;
  font-size: 28px;
  margin: 0 auto 18px;
}

.gate-card h2 {
  font-size: 20px;
  margin-bottom: 8px;
}

.gate-text {
  color: var(--text-dim);
  margin: 0 0 22px;
  line-height: 1.55;
}

.gate-actions {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-top: 20px;
}

.steps {
  text-align: left;
  margin: 0;
  padding-left: 20px;
  color: var(--text-dim);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.steps strong {
  color: var(--text);
}

.code {
  background: var(--bg-sunken);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  margin: 7px 0 0;
  font-family: var(--mono);
  font-size: 12.5px;
  color: var(--text);
  overflow-x: auto;
  user-select: all;
}

.pair-row {
  display: flex;
  gap: 8px;
  justify-content: center;
}

.pair-input {
  width: 190px;
  text-align: center;
  font-family: var(--mono);
  font-size: 19px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

/* --------------------------------------------------------- sidebar chips */

.agent-chip,
.account-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  background: none;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 7px 8px;
  cursor: pointer;
  color: var(--text-dim);
  font-size: 12px;
  text-align: left;
  margin-bottom: 8px;
}

.agent-chip:hover,
.account-chip:hover {
  background: var(--panel-hover);
  color: var(--text);
}

.agent-chip .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-faint);
  flex: none;
}

/* Sits at the far end of the chip: present when wanted, quiet otherwise. */
.agent-version {
  margin-left: auto;
  flex: none;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  color: var(--text-faint);
}

.agent-chip.is-on .dot {
  background: var(--green);
  box-shadow: 0 0 0 3px var(--green-soft);
}

.agent-chip.is-bad .dot {
  background: var(--red);
  box-shadow: 0 0 0 3px var(--red-soft);
}

.account-chip {
  margin-top: 8px;
  margin-bottom: 0;
  border-top: 1px solid var(--border);
  border-radius: 0;
  padding-top: 11px;
}

.avatar {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--border);
  color: var(--text-dim);
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 700;
  flex: none;
}

.avatar.is-on {
  background: var(--accent);
  color: var(--accent-text);
}

.auto-status {
  margin-bottom: 4px;
}

/* -------------------------------------------------------- folder browser */

.fb-path {
  background: var(--bg-sunken);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 11px;
  font-size: 12px;
  overflow-x: auto;
  white-space: nowrap;
}

.fb-list {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  max-height: 300px;
  overflow-y: auto;
  background: var(--bg-sunken);
}

.fb-row {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  background: none;
  border: 0;
  border-bottom: 1px solid var(--border-soft);
  padding: 8px 11px;
  cursor: pointer;
  text-align: left;
  color: var(--text-dim);
}

.fb-row:hover {
  background: var(--panel-hover);
  color: var(--text);
}

.fb-row span {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.fb-row.is-install {
  color: var(--accent);
  font-weight: 600;
}

.fb-row em {
  font-style: normal;
  font-size: 11px;
  color: var(--text-faint);
}

.field input.input {
  margin-top: 4px;
}

/* --------------------------------------------------------- small screens */

@media (max-width: 860px) {
  .app {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
  }

  .sidebar {
    flex-direction: row;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    padding: 10px 12px;
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  .sidebar .field {
    flex: 1;
    min-width: 150px;
  }

  .sidebar .field label,
  .flavor-meta,
  .auto-status,
  .brand-text {
    display: none;
  }

  .nav {
    flex-direction: row;
    flex: none;
    width: 100%;
    overflow-x: auto;
  }

  .sidebar-foot {
    border-top: 0;
    padding-top: 0;
    display: flex;
    gap: 8px;
  }

  .account-chip {
    border-top: 0;
    padding-top: 7px;
    width: auto;
  }

  .row {
    /* Fixed here too, for the same reason: otherwise the name column is a
       different width on a row that has an update than on one that does not. */
    grid-template-columns: 1fr var(--row-actions);
    row-gap: 6px;
  }

  .row-version {
    grid-column: 1;
  }

  .row-head {
    display: none;
  }
}

/* A pairing code has to be read off the screen and typed somewhere else, so
   it gets room, spacing and unambiguous glyphs. */
.pair-code-shown {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-top: 10px;
}

.pair-code-shown code {
  font-family: var(--mono);
  font-size: 19px;
  letter-spacing: 0.14em;
  color: var(--text);
  background: var(--panel-hover);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 12px;
  user-select: all;
}

/* ------------------------------------------------------- provider colours */

/*
 * Each source gets a colour so a page of results can be read at a glance --
 * which addon came from where, without reading every line. Taken from each
 * provider's own branding, and used only as an accent: the text stays on the
 * normal background so contrast never depends on the accent being legible.
 */
:root {
  --p-curseforge: #f16436;
  --p-github: #a78bfa;
  --p-wowinterface: #4aa3df;
  --p-url: #34d399;
  --p-unknown: var(--text-faint);
}

[data-provider] {
  --provider: var(--p-unknown);
}
[data-provider='curseforge'] {
  --provider: var(--p-curseforge);
}
[data-provider='github'] {
  --provider: var(--p-github);
}
[data-provider='wowinterface'] {
  --provider: var(--p-wowinterface);
}
[data-provider='url'] {
  --provider: var(--p-url);
}

/* The accent reads as a spine down the left of the card. */
.card[data-provider] {
  border-left: 3px solid var(--provider);
}

.card[data-provider]:hover {
  border-color: var(--border);
  border-left-color: var(--provider);
  background: var(--panel-hover);
}

/*
 * Built for the patch that is actually installed.
 *
 * The list already only shows addons for this expansion, which is what
 * decides whether an addon works at all. This is the finer one on top: whose
 * author has published for *this* patch, and so loads without the game having
 * to be told to allow out-of-date addons. On a beta client that is 405 of the
 * 5,826 listed, which is exactly when it is worth being able to see at a
 * glance.
 *
 * A tint rather than a border, because the left border already says which
 * source the addon comes from and two things cannot use the same three pixels.
 * It is deliberately faint: it marks the good case, which is the common one on
 * retail, and a list where two thirds of the rows shout is a list that says
 * nothing.
 */
.card.is-current {
  background: var(--green-tint);
}

.card.is-current[data-provider]:hover,
.card.is-current:hover {
  background: var(--green-tint-hover);
}

.card-thumb {
  box-shadow: 0 0 0 1px var(--provider);
}

.provider-name {
  color: var(--provider);
  font-weight: 600;
}

/* A card that opens something on click should say so. */
.card.is-clickable {
  cursor: pointer;
}

.card.is-clickable:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.row.is-clickable {
  cursor: pointer;
}

.row-provider-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--provider);
  margin-right: 6px;
  vertical-align: middle;
  flex: none;
}

/* ----------------------------------------------------------- detail modal */

.detail-head {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  margin-bottom: 14px;
}

.detail-thumb {
  width: 64px;
  height: 64px;
  border-radius: 10px;
  object-fit: cover;
  background: var(--bg-sunken);
  flex: none;
  box-shadow: 0 0 0 1px var(--provider);
}

.detail-facts {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 7px 14px;
  margin-top: 4px;
}

.detail-facts dt {
  color: var(--text-faint);
  font-size: 12.5px;
}

.detail-facts dd {
  margin: 0;
  min-width: 0;
  overflow-wrap: anywhere;
}

.detail-description {
  margin-top: 14px;
  color: var(--text-dim);
  line-height: 1.55;
  max-height: 220px;
  overflow-y: auto;
  white-space: pre-wrap;
}

/* A heading over a list that is not search results. */
.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin: 4px 0 12px;
}

.section-head h2 {
  font-size: 14px;
}

.section-head .hint {
  color: var(--text-faint);
  font-size: 12px;
}

/* ------------------------------------------------ account, admin, helper */

/*
 * Where the helper used to cover the whole app: now a card in place of the
 * views that need it, so the account, the guild and the admin panel stay
 * usable from any browser.
 */
.connect-card {
  margin: 32px auto;
}

.connect-purpose {
  margin: -8px 0 18px;
  font-size: 12.5px;
}

.small {
  font-size: 12.5px;
}

.mono {
  font-family: var(--mono);
}

/* A dialog that holds a table or several sections. */
.modal.modal-wide {
  width: min(820px, 100%);
  max-height: 86vh;
}

.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  margin: 14px 0 12px;
}

.panel-head .tabs {
  margin: 0;
  border-bottom: 0;
}

.tab {
  background: none;
  border: 0;
  border-bottom: 2px solid transparent;
  color: var(--text-dim);
  padding: 8px 12px;
  font: inherit;
  font-weight: 550;
  cursor: pointer;
}

.tab:hover {
  color: var(--text);
}

.tab.is-active {
  color: var(--text);
  border-bottom-color: var(--accent);
}

/* A name with actions beside it: a passkey, a session, a guild member. */
.kv-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border-soft);
}

.kv-row:last-child {
  border-bottom: 0;
}

.kv-main {
  min-width: 0;
}

.kv-title {
  font-weight: 600;
  overflow-wrap: anywhere;
}

.kv-actions {
  display: flex;
  gap: 6px;
  flex: none;
}

.inline-form {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 12px;
}

.inline-form .input {
  flex: 1;
  min-width: 0;
}

.account-head {
  display: grid;
  gap: 6px;
}

.auth-links {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 14px;
}

/* Written down once, so they are laid out to be read and copied. */
.recovery-codes {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px 24px;
  margin: 14px 0;
  padding-left: 22px;
}

.recovery-codes code {
  font-family: var(--mono);
  font-size: 14px;
  letter-spacing: 0.04em;
}

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  border-bottom: 1px solid var(--border-soft);
}

.stat {
  padding: 14px 16px;
  border-right: 1px solid var(--border-soft);
}

.stat:last-child {
  border-right: 0;
}

.stat-value {
  font-size: 22px;
  font-weight: 650;
}

.stat-label {
  color: var(--text-faint);
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.stat.is-warn .stat-value {
  color: var(--red);
}

.admin-catalog {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.admin-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.admin-search {
  display: flex;
  gap: 8px;
}

.admin-search .input {
  width: 240px;
}

/*
 * The admin tables, with a fixed trailing column for the same reason the
 * addon rows have one: every row lines up with every other.
 */
.admin-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 110px 110px 130px;
  gap: 14px;
  align-items: center;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border-soft);
}

.admin-row:last-child {
  border-bottom: 0;
}

.admin-row.is-clickable {
  cursor: pointer;
}

.admin-row.is-clickable:hover {
  background: var(--panel-hover);
}

.admin-row-head {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-faint);
  font-weight: 600;
}

.admin-cell-main {
  min-width: 0;
}

.audit-row {
  display: grid;
  grid-template-columns: 90px minmax(0, 1fr) 200px;
  gap: 14px;
  padding: 8px 16px;
  border-bottom: 1px solid var(--border-soft);
  font-size: 13px;
}

.modal .audit-row {
  padding-left: 0;
  padding-right: 0;
}

.facts {
  display: grid;
  gap: 4px;
  margin-bottom: 8px;
}

.section-title {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-faint);
  margin: 20px 0 6px;
}

.admin-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

@media (max-width: 860px) {
  .admin-row {
    grid-template-columns: minmax(0, 1fr);
    gap: 2px;
  }

  .admin-row-head {
    display: none;
  }

  .audit-row {
    grid-template-columns: minmax(0, 1fr);
    gap: 2px;
  }

  .admin-search .input {
    width: 100%;
  }

  .recovery-codes {
    grid-template-columns: minmax(0, 1fr);
  }
}
