:root {
  --bg: #f5f6f4;
  --surface: #ffffff;
  --surface-2: #eef0ec;
  --text: #1c211c;
  --muted: #5f685f;
  --border: #d8ddd5;
  --accent: #3f8f3a;
  --accent-strong: #2f7a2b;
  --accent-text: #ffffff;
  --danger: #c2412d;
  --warning-bg: #fff4d6;
  --warning-text: #7a5600;
  --ok-bg: #e3f3df;
  --ok-text: #2b6427;
  --radius: 10px;
  --shadow: 0 1px 2px rgb(0 0 0 / 6%), 0 4px 16px rgb(0 0 0 / 4%);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141714;
    --surface: #1c201c;
    --surface-2: #252a25;
    --text: #e6ebe4;
    --muted: #9aa39a;
    --border: #323832;
    --accent: #5cb356;
    --accent-strong: #6cc466;
    --accent-text: #0f140f;
    --danger: #ef7a66;
    --warning-bg: #3a3014;
    --warning-text: #f4d27a;
    --ok-bg: #1f3a1d;
    --ok-text: #9fdc98;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
input[type=checkbox] { accent-color: var(--accent); width: 1.1rem; height: 1.1rem; min-height: 0; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

h1, h2, h3 { margin: 0 0 .5rem; line-height: 1.25; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; margin-top: 1rem; }
code, .mono, .code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .85em; }
a { color: var(--accent-strong); }
[hidden] { display: none !important; }

.muted { color: var(--muted); }
.small { font-size: .85rem; }
.error { color: var(--danger); min-height: 1.2em; margin: 0; }
.hint { background: var(--warning-bg); color: var(--warning-text); padding: .6rem .8rem; border-radius: 8px; font-size: .85rem; margin: 0; }

.logo {
  display: inline-block; width: 1.3em; height: 1.3em; vertical-align: -0.25em;
  background: url("/logo.svg") center / contain no-repeat;
}

button, input, select {
  font: inherit; color: inherit; border-radius: 8px; border: 1px solid var(--border); background: var(--surface);
  padding: .5rem .75rem; min-height: 2.4rem;
}
input, select { width: 100%; }
/* Masks secrets in plain text fields, which password managers leave alone. */
.secret-input:not(:placeholder-shown) { -webkit-text-security: disc; text-security: disc; }
button { cursor: pointer; background: var(--surface-2); white-space: nowrap; }
button:hover:not(:disabled) { border-color: var(--accent); }
button:disabled { opacity: .5; cursor: not-allowed; }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 600; }
button.primary:hover:not(:disabled) { background: var(--accent-strong); }
button.danger { color: var(--danger); }
button.ghost { background: transparent; }
button.small { min-height: 2rem; padding: .25rem .6rem; font-size: .85rem; }
input:focus-visible, select:focus-visible, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

label { display: flex; flex-direction: column; gap: .25rem; font-size: .9rem; }
label.check { flex-direction: row; align-items: center; gap: .5rem; }
label.check input { width: auto; min-height: 0; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; box-shadow: var(--shadow); margin-bottom: 1rem; }
.stack { display: flex; flex-direction: column; gap: .75rem; }
.row { display: flex; gap: .5rem; flex-wrap: wrap; align-items: flex-end; }
.row > select { width: auto; }
.grow { flex: 1 1 12rem; }
.narrow { max-width: 760px; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 1rem; }
.grid-2 > .card { margin-bottom: 0; }
.tab-panel > .grid-2 { margin-bottom: 1rem; }

.login { min-height: 100vh; display: grid; place-items: center; padding: 1rem; }
.login-card { width: min(380px, 100%); display: flex; flex-direction: column; gap: .9rem; }

.topbar { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: .75rem 1.25rem; background: var(--surface); border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.topbar-right { display: flex; align-items: center; gap: .75rem; }
.pill { background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; padding: .05rem .6rem; font-size: .8rem; }

.tabs { display: flex; gap: .25rem; overflow-x: auto; border-bottom: 1px solid var(--border); }
.tabs button { border: none; border-bottom: 2px solid transparent; border-radius: 0; background: transparent; color: var(--muted); }
.tabs button.active { color: var(--text); border-bottom-color: var(--accent); font-weight: 600; }

.page { padding: 1.25rem; max-width: 1200px; margin: 0 auto; }
.tab-panel { padding-top: 1rem; }
.toolbar { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; flex-wrap: wrap; margin-bottom: .75rem; }
.toolbar-actions { display: flex; gap: .5rem; flex-wrap: wrap; }
.filter { max-width: 320px; margin-bottom: .75rem; }

.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
table.mods { width: 100%; border-collapse: collapse; }
table.mods th, table.mods td { padding: .6rem .75rem; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; }
table.mods th { font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); background: var(--surface-2); }
table.mods tr:last-child td { border-bottom: none; }
table.mods tr.disabled td:not(:last-child) { opacity: .55; }
table.mods select { width: auto; min-height: 2rem; padding: .2rem .4rem; }
.mod-name { font-weight: 600; }
.mod-meta { font-size: .8rem; color: var(--muted); word-break: break-all; }
.actions { display: flex; gap: .35rem; justify-content: flex-end; }

.badge { display: inline-block; font-size: .75rem; font-weight: 600; padding: .1rem .5rem; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); }
.badge.modrinth { color: #1bd96a; border-color: currentColor; }
.badge.curseforge { color: #f16436; border-color: currentColor; }
.status { font-size: .85rem; }
.status.ok { color: var(--ok-text); }
.status.available { background: var(--warning-bg); color: var(--warning-text); padding: .1rem .45rem; border-radius: 6px; }
.status.error { color: var(--danger); }

.empty { text-align: center; color: var(--muted); padding: 2rem; }

.drop-zone { border: 2px dashed var(--border); border-radius: var(--radius); padding: 1.75rem 1rem; text-align: center; color: var(--muted); cursor: pointer; margin-bottom: .75rem; }
.drop-zone.dragging { border-color: var(--accent); background: var(--ok-bg); }
.drop-zone input { display: none; }

.plain-list { list-style: none; margin: .5rem 0; padding: 0; display: flex; flex-direction: column; gap: .4rem; }
.plain-list li { display: flex; justify-content: space-between; align-items: center; gap: .5rem; font-size: .9rem; }

.results { list-style: none; margin: 1rem 0 0; padding: 0; display: grid; gap: .5rem; }
.results li { display: grid; grid-template-columns: 48px 1fr auto; gap: .75rem; align-items: center; padding: .6rem; border: 1px solid var(--border); border-radius: 8px; }
.results img, .results .icon-placeholder { width: 48px; height: 48px; border-radius: 8px; object-fit: cover; background: var(--surface-2); }
.results .description { font-size: .85rem; color: var(--muted); }
.results .result-actions { display: flex; gap: .4rem; align-items: center; }
.results .result-actions select { width: auto; }

.steps { padding-left: 1.2rem; display: flex; flex-direction: column; gap: .6rem; }
.code { background: var(--surface-2); border: 1px solid var(--border); padding: .75rem; border-radius: 8px; white-space: pre-wrap; word-break: break-all; margin: 0; }

.audit { list-style: none; padding: 0; margin: 0; }
.audit li { display: grid; grid-template-columns: 11rem 7rem 1fr; gap: .75rem; padding: .45rem 0; border-bottom: 1px solid var(--border); font-size: .88rem; }
.audit time { color: var(--muted); }

.toast-area { position: fixed; right: 1rem; bottom: 1rem; display: flex; flex-direction: column; gap: .5rem; z-index: 10; max-width: min(420px, calc(100vw - 2rem)); }
.toast { background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--accent); border-radius: 8px; padding: .65rem .9rem; box-shadow: 0 6px 24px rgb(0 0 0 / 18%); font-size: .9rem; }
.toast.error { border-left-color: var(--danger); }
.toast.warning { border-left-color: #d9a400; }

@media (max-width: 640px) {
  .page { padding: 1rem; }
  .audit li { grid-template-columns: 1fr; gap: .1rem; }
  .results li { grid-template-columns: 40px 1fr; }
  .results .result-actions { grid-column: 1 / -1; }
}

/* ---------- navigation & packs ---------- */
.brand { color: inherit; text-decoration: none; }
.mainnav { display: flex; gap: .25rem; flex-wrap: wrap; }
.mainnav a { color: var(--muted); text-decoration: none; padding: .35rem .7rem; border-radius: 8px; }
.mainnav a.active { color: var(--text); background: var(--surface-2); font-weight: 600; }
.pack-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 1.25rem; margin-bottom: 1rem; }

/* CurseForge-style tiles: artwork, name, two-line description. */
.pack-tile { position: relative; display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; overflow: hidden; box-shadow: var(--shadow); transition: transform .12s ease, border-color .12s ease; }
.pack-tile:hover, .pack-tile:focus-within { transform: translateY(-2px); border-color: var(--accent); }
.pack-tile-link { display: flex; flex-direction: column; color: inherit; text-decoration: none; height: 100%; }
.pack-tile-image { position: relative; aspect-ratio: 1 / 1; background: var(--surface-2); }
.pack-tile-art { width: 100%; height: 100%; object-fit: cover; display: block; }
.placeholder { display: grid; place-items: center; color: #fff; font-weight: 700; letter-spacing: .02em;
  background: linear-gradient(140deg, hsl(var(--hue, 120) 55% 42%), hsl(calc(var(--hue, 120) + 40) 60% 28%)); }
.pack-tile-art.placeholder { font-size: 3.2rem; }
.pack-tile-badge { position: absolute; left: .6rem; bottom: .6rem; font-size: .75rem; font-weight: 600; color: #fff;
  background: rgb(0 0 0 / 55%); padding: .15rem .55rem; border-radius: 999px; backdrop-filter: blur(4px); }
.pack-tile-body { padding: .8rem .9rem .9rem; display: flex; flex-direction: column; gap: .25rem; flex: 1; }
.pack-tile-name { font-weight: 700; font-size: 1.02rem; }
.pack-tile-description { margin: 0; color: var(--muted); font-size: .88rem; line-height: 1.4;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; min-height: 2.8em; }
.pack-tile-meta { font-size: .78rem; color: var(--muted); margin-top: auto; padding-top: .35rem; }
.pack-tile-copy { position: absolute; top: .55rem; right: .55rem; width: 2.2rem; height: 2.2rem; min-height: 0; padding: 0;
  display: grid; place-items: center; border-radius: 10px; border: none; background: rgb(0 0 0 / 55%); color: #fff;
  backdrop-filter: blur(4px); opacity: 0; transition: opacity .12s ease; }
.pack-tile-copy svg { width: 1.05rem; height: 1.05rem; fill: none; stroke: currentColor; stroke-width: 2; }
.pack-tile:hover .pack-tile-copy, .pack-tile-copy:focus-visible { opacity: 1; }
@media (hover: none) { .pack-tile-copy { opacity: 1; } }
.pack-tile.new { align-items: center; justify-content: center; gap: .5rem; min-height: 260px; border-style: dashed;
  background: transparent; color: var(--muted); font-size: 1rem; cursor: pointer; box-shadow: none; }
.pack-tile.new .plus { font-size: 2.5rem; line-height: 1; }

.pack-title-row { display: flex; align-items: center; gap: .75rem; }
.pack-thumb { display: inline-block; width: 3rem; height: 3rem; border-radius: 10px; overflow: hidden; flex: none; }
.pack-thumb.large { width: 6.5rem; height: 6.5rem; border-radius: 16px; }
.pack-thumb-art { width: 100%; height: 100%; object-fit: cover; display: block; font-size: 1.1rem; }
.pack-thumb.large .pack-thumb-art.placeholder { font-size: 2.2rem; }
.icon-editor { display: flex; gap: 1.25rem; align-items: center; }
.icon-editor h3 { margin: 0; }
.file-button input { display: none; }
textarea { font: inherit; color: inherit; background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  padding: .5rem .75rem; resize: vertical; width: 100%; }
.row.end { justify-content: flex-end; }

dialog.modal { border: 1px solid var(--border); border-radius: 14px; padding: 1.5rem; width: min(520px, calc(100vw - 2rem));
  background: var(--surface); color: var(--text); box-shadow: 0 20px 60px rgb(0 0 0 / 35%); }
dialog.modal::backdrop { background: rgb(0 0 0 / 45%); }

.pack-titlebar { display: flex; flex-direction: column; gap: .35rem; margin-bottom: 1rem; }
.pack-titlebar h2 { font-size: 1.5rem; margin: 0; }
.pack-titlebar a { word-break: break-all; }
fieldset { border: 1px solid var(--border); border-radius: 8px; padding: .75rem 1rem 1rem; margin: 0; }
legend { padding: 0 .35rem; font-weight: 600; }
label.check input[type=radio] { width: auto; min-height: 0; margin-top: .2rem; align-self: flex-start; accent-color: var(--accent); }
.login-card.wide { width: min(560px, 100%); }
a.button, label.button { display: inline-flex; cursor: pointer; align-items: center; justify-content: center; padding: .5rem .9rem; border-radius: 8px;
  border: 1px solid var(--border); background: var(--surface-2); color: inherit; text-decoration: none; min-height: 2.4rem; }
a.button.primary, label.button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 600; }

/* ---------- public pack page ---------- */
.pack-main { max-width: 760px; margin: 0 auto; padding: 2rem 1rem; }
.test-banner { margin: 0 0 1rem; padding: .7rem 1rem; border-radius: 10px; background: var(--warning-bg); color: var(--warning-text); }
.pack-header { display: flex; gap: .9rem; align-items: center; margin-bottom: 1.25rem; }
.pack-header .logo { width: 4rem; height: 4rem; }
.pack-header .pack-icon { width: 5rem; height: 5rem; border-radius: 14px; object-fit: cover; flex: none; box-shadow: var(--shadow); }
.pack-header .description { margin: .35rem 0 0; color: var(--text); }
.pack-header h1 { font-size: 1.6rem; margin: 0; }
.pack-header p { margin: .1rem 0 0; }
.pack-mods { list-style: none; margin: 0; padding: 0; }
.pack-mods li { display: grid; grid-template-columns: 1fr auto auto; gap: .75rem; align-items: center; padding: .45rem 0; border-bottom: 1px solid var(--border); }
.pack-mods li:last-child { border-bottom: none; }
@media (max-width: 640px) {
  .pack-mods li { grid-template-columns: 1fr auto; }
  .pack-mods li .muted { display: none; }
}

.background-preview { aspect-ratio: 16 / 9; max-width: 480px; border-radius: 12px; overflow: hidden; display: grid; place-items: center;
  background: var(--surface-2); border: 1px dashed var(--border); }
.background-preview img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* Public pack page with a background: a banner behind the header. */
.pack-banner { position: relative; margin: -2rem -1rem 1.5rem; min-height: 260px; display: flex; align-items: flex-end; overflow: hidden; border-radius: 0 0 18px 18px; }
.pack-banner-image { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; }
.pack-banner .pack-header { position: relative; width: 100%; margin: 0; padding: 7rem 1.25rem 1.25rem; align-items: flex-end; color: #fff;
  background: linear-gradient(to top, rgb(0 0 0 / 70%) 0%, rgb(0 0 0 / 45%) 45%, rgb(0 0 0 / 0%) 100%); }
.pack-banner .pack-icon, .pack-banner .logo { width: 5.5rem; height: 5.5rem; }
.pack-banner .pack-header-text { text-shadow: 0 1px 4px rgb(0 0 0 / 60%); }
.pack-banner .pack-header-text .muted, .pack-banner .pack-header-text .description { color: #e8ece6; }
@media (min-width: 800px) { .pack-banner { margin: -2rem 0 1.5rem; border-radius: 18px; } }

/* Modpack import */
.toolbar-actions { display: flex; gap: .5rem; }
.progress-track { height: .6rem; border-radius: 999px; background: var(--border); overflow: hidden; }
.progress-fill { height: 100%; width: 0; border-radius: inherit; background: var(--accent); transition: width .2s ease; }
.import-report { margin: 0; padding-left: 1.1rem; max-height: 14rem; overflow: auto; font-size: .85rem; }
.import-report li.failure { color: var(--danger); }
.import-report li.note { color: var(--muted); }

/* Ordered lists: resource packs and servers */
.ordered-list { list-style: none; margin: 1rem 0 0; padding: 0; border: 1px solid var(--border); border-radius: 12px; background: var(--surface, transparent); }
.ordered-list:empty { display: none; }
.ordered-list li { display: grid; grid-template-columns: auto 1fr auto; gap: .75rem; align-items: center; padding: .65rem .9rem; border-bottom: 1px solid var(--border); }
.ordered-list li:last-child { border-bottom: none; }
.ordered-list .order-buttons { display: flex; flex-direction: column; gap: .15rem; }
.ordered-list .order-buttons button { min-height: 1.4rem; padding: 0 .45rem; font-size: .7rem; line-height: 1; }
.ordered-list .item-name { font-weight: 600; }
.ordered-list .item-meta { color: var(--muted); font-size: .85rem; overflow-wrap: anywhere; }
.ordered-list .actions { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; justify-content: flex-end; }

/* One-click instance downloads on the public pack page */
.instance-download { padding: 1rem; border: 1px solid var(--accent); border-radius: var(--radius); background: var(--surface-2); }
.instance-download p, .pack-main h3 { margin: 0; }
.pack-main h3 { font-size: 1rem; }
.instance-options { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: .9rem; }
.instance-option { display: flex; flex-direction: column; gap: .4rem; }
.instance-option a.button { text-align: center; text-decoration: none; }

/* Version pickers: dropdowns that fill the (hidden) version inputs */
.version-select { width: 100%; }

/* Version choice dialog */
.version-list { list-style: none; margin: 0; padding: 0; max-height: 55vh; overflow: auto; border: 1px solid var(--border); border-radius: 10px; }
.version-list li { display: grid; grid-template-columns: 1fr auto; gap: .6rem; align-items: center; padding: .55rem .75rem; border-bottom: 1px solid var(--border); }
.version-list li:last-child { border-bottom: none; }
.version-list li.current { background: var(--surface-2); }
.version-list .version-name { font-weight: 600; overflow-wrap: anywhere; }
.version-list .version-meta { color: var(--muted); font-size: .8rem; }
.version-list .badge { margin-left: .4rem; }
.badge.prerelease { color: #9a6700; border-color: #e3c16f; }

/* Pack problems: mods that are not sent because the game would not start */
.problems { border-color: #e3b341; background: color-mix(in srgb, #e3b341 10%, var(--surface, transparent)); }
.problems h3 { margin: 0 0 .35rem; }
.problems ul { margin: .5rem 0; padding-left: 1.1rem; }
.problems li { margin: .3rem 0; }
.problems .problem-actions { display: inline-flex; gap: .4rem; margin-left: .4rem; vertical-align: middle; }
.badge.withheld { color: var(--danger); border-color: var(--danger); }
.mod-name .badge { margin-left: .4rem; vertical-align: middle; }

/* Manual publishing */
.release-card .checkbox-row { display: flex; flex-direction: row; gap: .6rem; align-items: flex-start; cursor: pointer; }
.release-card .checkbox-row > span { display: flex; flex-direction: column; gap: .15rem; }
.release-card .checkbox-row input { margin-top: .2rem; }
.release-card #release-details { margin-top: .9rem; }
.release-changes { margin: 0; padding-left: 1.2rem; max-height: 12rem; overflow: auto; }
.release-changes li { margin: .1rem 0; }
.release-changes .added::marker { content: "+  "; color: #2f9e44; }
.release-changes .removed::marker { content: "−  "; color: var(--danger); }
.release-changes .changed::marker { content: "~  "; color: var(--warning-text); }
