:root {
  --bg: #f6f2f3;
  --card: #fff;
  --text: #1d1b1c;
  --muted: #6d6669;
  --line: #e6dfe1;
  --brand: #ea476b;
  --old: #8a5a00;
  --new: #1f6f43;
  --pass: #e5f5ea;
  --fail: #fde7ea;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161415;
    --card: #211e1f;
    --text: #f1eced;
    --muted: #a39b9e;
    --line: #353032;
    --old: #f0b44c;
    --new: #6fd39b;
    --pass: #17321f;
    --fail: #3d1a20;
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 system-ui, -apple-system, sans-serif;
  padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom);
}

.splash {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 10;
  background: var(--brand);
  color: #fff;
  font-size: 72px;
  align-items: center;
  justify-content: center;
}

body.loading .splash {
  display: flex;
}

header {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--card);
  position: sticky;
  top: 0;
  z-index: 2;
}

.role {
  font-weight: 800;
  padding: 2px 10px;
  border-radius: 999px;
  color: #fff;
  background: var(--muted);
}

.role[data-role='old'] {
  background: var(--old);
}

.role[data-role='new'] {
  background: var(--new);
}

header code {
  color: var(--muted);
  overflow-wrap: anywhere;
}

header a {
  margin-left: auto;
  color: var(--brand);
  font-weight: 600;
}

main {
  display: grid;
  gap: 12px;
  padding: 12px 16px 48px;
  max-width: 1100px;
  margin: 0 auto;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px 16px;
  min-width: 0;
}

.card h2 {
  margin: 0 0 10px;
  font-size: 16px;
}

.card h3 {
  margin: 16px 0 8px;
  font-size: 14px;
}

.result[data-status='pass'] {
  background: var(--pass);
}

.result[data-status='fail'],
.result[data-status='error'] {
  background: var(--fail);
}

dl {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: 4px 12px;
  margin: 0 0 10px;
}

dt {
  color: var(--muted);
}

dd {
  margin: 0;
  overflow-wrap: anywhere;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 10px;
  margin-bottom: 10px;
}

label {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 12px;
}

label.check {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  font-size: 14px;
}

input,
select {
  font: inherit;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--text);
  min-width: 0;
}

input[type='checkbox'] {
  width: 20px;
  height: 20px;
}

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

button {
  font: inherit;
  font-weight: 600;
  padding: 10px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
}

button:disabled {
  opacity: 0.5;
}

button.primary {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}

button.danger {
  color: #c0223f;
}

button.ghost {
  background: transparent;
}

.hint {
  color: var(--muted);
  font-size: 12px;
  margin: 8px 0;
}

.warn {
  color: #c0223f;
}

pre {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font: 12px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace;
}

pre.log,
pre.sw-status {
  background: var(--bg);
  border-radius: 8px;
  padding: 10px;
  max-height: 420px;
  overflow: auto;
  margin-bottom: 10px;
}

.thumbs {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(84px, 1fr));
  gap: 8px;
  margin: 10px 0;
}

.thumbs figure {
  margin: 0;
}

.thumbs img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 8px;
  display: block;
}

.thumbs figcaption {
  font-size: 10px;
  color: var(--muted);
  overflow-wrap: anywhere;
}

table {
  border-collapse: collapse;
  width: 100%;
  font-size: 12px;
  margin-top: 8px;
}

th,
td {
  text-align: left;
  border-bottom: 1px solid var(--line);
  padding: 4px 6px;
  overflow-wrap: anywhere;
}

details summary {
  cursor: pointer;
  color: var(--muted);
  margin: 6px 0;
}

.gate {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgb(0 0 0 / 0.45);
}

.gate__box {
  background: var(--card);
  border-radius: 16px;
  padding: 18px;
  width: min(560px, 100%);
  max-height: 90vh;
  overflow: auto;
  display: grid;
  gap: 10px;
}

.gate__side {
  font-size: 12px;
  color: var(--muted);
}

.gate__box h2 {
  margin: 0;
  font-size: 17px;
}

.gate__box button {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}

.migrate-error {
  position: fixed;
  inset: auto 16px 16px;
  z-index: 30;
  background: var(--card);
  border-radius: 16px;
  padding: 16px;
}

.migrate-error h2 {
  margin: 0 0 8px;
}
