/* RW Mod Protector's website: the program's own colours (rwtheme.py), light and dark. */
:root {
  color-scheme: light;
  --bg: #f3f4f6; --surface: #ffffff; --surface-alt: #f7f8fa; --field: #ffffff;
  --hover: #eef1f5; --border: #e1e4e9; --border-strong: #c5cbd3; --field-border: #868f9a;
  --text: #1b1f24; --muted: #5b6470; --track: #e4e7ec;
  --accent: #2563eb; --accent-hover: #1f56d4; --on-accent: #ffffff; --accent-text: #1d5bd8;
  --ok-fg: #1a7f37; --ok-bg: #eaf6ed; --warn-fg: #8a5a00; --warn-bg: #fff6dc;
  --err-fg: #c42b1c; --err-bg: #fdeceb; --info-fg: #1d5bd8; --info-bg: #eaf1fe;
  --danger: #c42b1c; --danger-hover: #ad2517; --on-danger: #ffffff;
  --shared: #fff0b3; --shared-edge: #c99a06; --stock: #8a929c;
  --check-a: #e9ebef; --check-b: #ffffff; --check-dark-a: #2a2d32; --check-dark-b: #33373d;
  --mono: ui-monospace, "Cascadia Mono", "Cascadia Code", Consolas, "Liberation Mono", monospace;
  --radius: 10px;
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #1a1c1f; --surface: #24272b; --surface-alt: #2a2d32; --field: #1e2124;
    --hover: #30343a; --border: #33373d; --border-strong: #4a4f57; --field-border: #747b85;
    --text: #e9ebee; --muted: #9ba3ad; --track: #33373d;
    --accent: #2f6feb; --accent-hover: #3a78f0; --on-accent: #ffffff; --accent-text: #7aaeff;
    --ok-fg: #5bd17e; --ok-bg: #17271d; --warn-fg: #e7b84a; --warn-bg: #2b2414;
    --err-fg: #ff8177; --err-bg: #341c1c; --info-fg: #7aaeff; --info-bg: #18243a;
    --danger: #c42b1c; --danger-hover: #d63a2a;
    --shared: #4a3c10; --shared-edge: #e7b84a; --stock: #70767f;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; display: flex; flex-direction: column;
  background: var(--bg); color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
a { color: var(--accent-text); text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }
h1, h2 { line-height: 1.25; margin: 0 0 10px; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.15rem; margin-top: 4px; }
p { margin: 0 0 12px; }
.muted { color: var(--muted); }
.small { font-size: 0.87rem; }
.nowrap { white-space: nowrap; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* the bar at the top */
.top {
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px 20px;
  padding: 10px 24px; background: var(--surface); border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.05rem; color: var(--text); text-decoration: none; }
.top nav { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 18px; }
.top nav a { color: var(--text); text-decoration: none; }
.top nav a:hover { color: var(--accent-text); }
.top nav form { margin: 0; }

main { width: 100%; max-width: 1120px; margin: 0 auto; padding: 24px 24px 8px; flex: 1; }
footer { text-align: center; color: var(--muted); font-size: 0.85rem; padding: 18px 16px 24px; }
.crumbs { margin: 0 0 10px; color: var(--muted); font-size: 0.92rem; }

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 22px 24px; margin-bottom: 18px; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}
.card.narrow { max-width: 460px; margin-left: auto; margin-right: auto; }
.card > :last-child { margin-bottom: 0; }

/* notes */
.note { padding: 10px 14px; border-radius: 8px; border-left: 3px solid var(--border-strong); background: var(--surface-alt); }
.note.ok { color: var(--ok-fg); background: var(--ok-bg); border-left-color: var(--ok-fg); }
.note.warn { color: var(--warn-fg); background: var(--warn-bg); border-left-color: var(--warn-fg); }
.note.error { color: var(--err-fg); background: var(--err-bg); border-left-color: var(--err-fg); }
.note.info { color: var(--info-fg); background: var(--info-bg); border-left-color: var(--info-fg); }
.note p:last-child { margin-bottom: 0; }

/* forms */
label { display: block; margin: 0 0 14px; font-weight: 500; }
label.choice { display: flex; align-items: baseline; gap: 8px; font-weight: 400; margin-bottom: 8px; }
label .muted { font-weight: 400; }
input[type=text], input:not([type]), input[type=password], input[type=file] {
  display: block; width: 100%; margin-top: 5px; padding: 9px 11px; font: inherit; color: var(--text);
  background: var(--field); border: 1px solid var(--field-border); border-radius: 8px;
}
input[readonly] { background: var(--surface-alt); }
input[type=file] { padding: 7px 9px; }
input[type=file]::file-selector-button {
  font: inherit; margin-right: 10px; padding: 5px 12px; border-radius: 6px; cursor: pointer;
  border: 1px solid var(--border-strong); background: var(--surface-alt); color: var(--text);
}
input[type=radio], input[type=checkbox] { accent-color: var(--accent); width: 16px; height: 16px; flex: none; }
fieldset { border: 1px solid var(--border); border-radius: 8px; padding: 12px 16px 6px; margin: 0 0 16px; }
legend { font-weight: 600; padding: 0 6px; }
.for-one { margin: 6px 0 10px 24px; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-top: 4px; }
form.inline { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 6px 16px; }
form.inline label:first-of-type { flex: 1 1 220px; }
form.inline .actions { margin: 0 0 14px; }

button, .button {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font: inherit; font-weight: 500; line-height: 1.2; padding: 8px 16px; border-radius: 8px; cursor: pointer;
  color: var(--text); background: var(--surface); border: 1px solid var(--border-strong); text-decoration: none;
}
button:hover, .button:hover { background: var(--hover); }
button.primary { color: var(--on-accent); background: var(--accent); border-color: var(--accent); }
button.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
button.danger { color: var(--on-danger); background: var(--danger); border-color: var(--danger); }
button.danger:hover { background: var(--danger-hover); border-color: var(--danger-hover); }
button.link { background: none; border: 0; padding: 0; color: var(--text); font-weight: 400; }
button.link:hover { color: var(--accent-text); background: none; }
button:disabled { opacity: 0.6; cursor: default; }
button[aria-pressed=true] { background: var(--info-bg); color: var(--info-fg); border-color: var(--info-fg); }

/* progress */
progress { display: block; width: 100%; height: 10px; border: 0; border-radius: 999px; background: var(--track); overflow: hidden; appearance: none; }
progress::-webkit-progress-bar { background: var(--track); border-radius: 999px; }
progress::-webkit-progress-value { background: var(--accent); border-radius: 999px; }
progress::-moz-progress-bar { background: var(--accent); border-radius: 999px; }
progress:indeterminate {
  background: linear-gradient(90deg, var(--track) 25%, var(--accent) 50%, var(--track) 75%);
  background-size: 200% 100%; animation: slide 1.4s linear infinite;
}
progress:indeterminate::-webkit-progress-bar { background: transparent; }
progress:indeterminate::-moz-progress-bar { background: transparent; }
@keyframes slide { from { background-position: 100% 0; } to { background-position: -100% 0; } }
@media (prefers-reduced-motion: reduce) { progress:indeterminate { animation: none; } }
.progress { margin: 14px 0; }
.progress p { margin-bottom: 8px; }
.uploading { display: flex; flex-direction: column; gap: 6px; margin-top: 14px; }

/* tables */
.table { overflow-x: auto; margin: 0 0 6px; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-weight: 600; font-size: 0.86rem; color: var(--muted); padding: 8px 12px; border-bottom: 1px solid var(--border-strong); }
td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
tbody tr:hover { background: var(--surface-alt); }
tr.common td { opacity: 0.75; }
td.path, dd.path, .path { font-family: var(--mono); font-size: 0.84rem; overflow-wrap: anywhere; }
.counts { display: flex; flex-wrap: wrap; gap: 4px; }
.row-actions { display: flex; gap: 8px; justify-content: flex-end; }
.row-actions form { margin: 0; }
.row-actions button { padding: 5px 10px; font-size: 0.88rem; }
.results td:last-child, .matches td:last-child { text-align: right; white-space: nowrap; }

/* badges */
.badge {
  display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 0.8rem; font-weight: 600; line-height: 1.5;
  background: var(--surface-alt); color: var(--muted); border: 1px solid var(--border); white-space: nowrap;
}
.badge.good { color: var(--ok-fg); background: var(--ok-bg); border-color: transparent; }
.badge.bad, .badge.k-copies, .badge.k-pixels { color: var(--err-fg); background: var(--err-bg); border-color: transparent; }
.badge.warn, .badge.k-similar { color: var(--warn-fg); background: var(--warn-bg); border-color: transparent; }
.badge.info, .badge.k-code, .badge.k-sounds { color: var(--info-fg); background: var(--info-bg); border-color: transparent; }
h1 .badge { font-size: 0.9rem; vertical-align: 3px; }

/* roles, the notice to everyone, the owner's controls */
.badge.role-owner { color: var(--on-accent); background: var(--accent); border-color: transparent; }
.badge.role-admin { color: var(--info-fg); background: var(--info-bg); border-color: transparent; }
.top nav .badge { font-size: 0.72rem; padding: 1px 7px; vertical-align: 1px; }
.banner {
  padding: 10px 24px; background: var(--warn-bg); color: var(--warn-fg); border-bottom: 1px solid var(--border);
  text-align: center; font-weight: 500; overflow-wrap: anywhere;
}
.owner-tabs { margin-bottom: 16px; }
.controls { display: flex; flex-direction: column; gap: 10px; margin: 6px 0 14px; }
.controls form { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; margin: 0; }
.controls form.inline { align-items: flex-end; }
.controls form.inline label { margin-bottom: 0; }
.controls form.inline .actions { margin: 0; }
select, textarea, input[type=number] {
  display: block; width: 100%; margin-top: 5px; padding: 9px 11px; font: inherit; color: var(--text);
  background: var(--field); border: 1px solid var(--field-border); border-radius: 8px;
}
input[type=number] { max-width: 160px; }
textarea { resize: vertical; min-height: 60px; }
form.settings label.choice { margin-bottom: 12px; }
.field-error { display: block; margin-top: 4px; color: var(--err-fg); font-weight: 400; font-size: 0.88rem; }
form.filters label { flex: 0 1 220px; }
tr.failed td:nth-child(3) { color: var(--err-fg); }
meter { display: block; width: 100%; height: 12px; margin: 4px 0 14px; }
.failed-list summary { cursor: pointer; color: var(--accent-text); }
.failed-list ul { margin: 8px 0 0; padding-left: 20px; }

/* tabs and pages */
.tabs { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 14px; }
.tabs a { padding: 5px 12px; border-radius: 999px; border: 1px solid var(--border); color: var(--text); text-decoration: none; font-size: 0.92rem; }
.tabs a:hover { background: var(--hover); }
.tabs a[aria-current] { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.pages { display: flex; gap: 16px; align-items: center; justify-content: center; margin-top: 14px; flex-wrap: wrap; }

/* definition lists */
dl.pairs { display: grid; grid-template-columns: max-content 1fr; gap: 6px 18px; margin: 0 0 12px; }
dl.pairs dt { color: var(--muted); }
dl.pairs dd { margin: 0; }

/* side by side */
.heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.pager { display: flex; gap: 10px; align-items: center; }
.tools { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.pair { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 18px; }
.pair figure { margin: 0; min-width: 0; }
.pair figcaption { font-weight: 600; margin-bottom: 8px; }
.shot {
  display: flex; align-items: center; justify-content: center; min-height: 220px; padding: 14px; border-radius: 8px; overflow: auto;
  background-color: var(--check-dark-a);
  background-image: conic-gradient(var(--check-dark-b) 25%, transparent 0 50%, var(--check-dark-b) 0 75%, transparent 0);
  background-size: 16px 16px;
}
[data-compare].light .shot { background-color: var(--check-b); background-image: conic-gradient(var(--check-a) 25%, transparent 0 50%, var(--check-a) 0 75%, transparent 0); }
.shot img { display: block; width: 100%; max-height: 460px; object-fit: contain; image-rendering: pixelated; }
[data-compare].actual .shot { align-items: flex-start; justify-content: flex-start; }
[data-compare].actual .shot img { width: auto; max-width: none; max-height: none; }
[data-compare].mirror .shot img.yours { transform: scaleX(-1); }
.pair audio { width: 100%; }
.code pre {
  margin: 0; padding: 8px 0; max-height: 72vh; overflow: auto; font: 0.8rem/1.6 var(--mono);
  background: var(--surface-alt); border: 1px solid var(--border); border-radius: 8px;
}
.code pre span { display: block; min-height: 1.6em; padding: 0 12px; white-space: pre; }
.code pre span.shared, .key.shared { background: var(--shared); box-shadow: inset 3px 0 0 var(--shared-edge); }
.code pre span.stock, .key.stock { color: var(--stock); }
.key { padding: 0 6px; border-radius: 4px; }
.copyline { display: flex; gap: 8px; }
.copyline input { margin: 0; font-family: var(--mono); font-size: 0.85rem; }

@media (max-width: 720px) {
  .top { padding: 10px 16px; }
  main { padding: 16px 16px 4px; }
  .card { padding: 18px 16px; }
  .pair { grid-template-columns: minmax(0, 1fr); }
  dl.pairs { grid-template-columns: 1fr; gap: 2px; }
  dl.pairs dd { margin-bottom: 8px; }
  .copyline { flex-direction: column; }
  .banner { padding: 10px 16px; }
  /* the results and matches: each row a small card of its own */
  table.results thead, table.matches thead { display: none; }
  table.results tr, table.matches tr {
    display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px 12px;
    padding: 12px 0; border-bottom: 1px solid var(--border);
  }
  table.results tr { grid-template-areas: "mod mod" "found found" "date open"; }
  table.matches tr { grid-template-areas: "kind open" "theirs theirs" "yours yours"; }
  table.results td, table.matches td { display: block; padding: 0; border: 0; }
  table.results td:nth-child(1) { grid-area: mod; }
  table.results td:nth-child(2) { grid-area: date; align-self: center; }
  table.results td:nth-child(3) { grid-area: found; }
  table.results td:nth-child(4) { grid-area: open; }
  table.matches td:nth-child(1) { grid-area: kind; }
  table.matches td:nth-child(2) { grid-area: theirs; }
  table.matches td:nth-child(3) { grid-area: yours; }
  table.matches td:nth-child(4) { grid-area: open; }
  table.matches td.path::before { content: attr(data-label) ": "; font-family: system-ui, sans-serif; color: var(--muted); }
}
