:root {
  color-scheme: dark;
  --bg: #15130f;
  --panel: #201d17;
  --line: #3a352b;
  --text: #ece6da;
  --muted: #a9a090;
  --accent: #e0a64a;
  --error: #ff8f7a;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", "Noto Sans", sans-serif;
}

main {
  flex: 1;
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  padding: 32px 16px;
}

h1 { font-size: 1.6rem; margin: 0 0 20px; }
h2 { font-size: 1.15rem; margin: 0 0 12px; }
p { margin: 0 0 12px; }
code { font-size: 0.95em; }

.hint, .note { color: var(--muted); }

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin: 20px 0 12px;
}

button {
  font: inherit;
  padding: 10px 18px;
  border: 1px solid var(--accent);
  border-radius: 6px;
  background: var(--accent);
  color: #1b1408;
  font-weight: 600;
  cursor: pointer;
}
button#continue { background: transparent; color: var(--accent); }
button:disabled { opacity: 0.5; cursor: progress; }
button:focus-visible { outline: 2px solid var(--text); outline-offset: 2px; }

#picker-status { color: var(--muted); min-height: 1.5em; }
#picker-error, .failed p:first-of-type { color: var(--error); white-space: pre-line; }
#fatal {
  padding: 12px 16px;
  margin: 0 0 16px;
  border: 1px solid var(--error);
  border-radius: 8px;
  color: var(--error);
  white-space: pre-line;
}

.screen {
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

progress {
  display: block;
  width: 100%;
  height: 14px;
  margin: 8px 0 12px;
  accent-color: var(--accent);
}

table { width: 100%; border-collapse: collapse; margin: 8px 0 16px; }
th, td { padding: 4px 8px; border-bottom: 1px solid var(--line); text-align: left; }
th { color: var(--muted); font-weight: 600; }
.num { text-align: right; font-variant-numeric: tabular-nums; }

footer {
  padding: 16px;
  color: var(--muted);
  font-size: 0.85rem;
  text-align: center;
  border-top: 1px solid var(--line);
}

/* ---- the card gallery (crates/cs-web/src/app.rs) ------------------------------------------- */

main:has(.screen.gallery) { max-width: none; padding: 16px 20px; }
main:has(.screen.gallery) h1 { font-size: 1.2rem; margin-bottom: 12px; }

.screen.gallery { padding: 12px 16px; }
.strip p { margin: 0 0 4px; font-variant-numeric: tabular-nums; }
.strip .images { color: var(--muted); }

.filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 18px;
  margin: 12px 0;
}
.filters label { color: var(--muted); }
.filters select, .filters input {
  font: inherit;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 6px 8px;
}
.filters input { width: 16em; }
.filters .shown { color: var(--muted); font-variant-numeric: tabular-nums; }

.grid-scroll {
  height: calc(100vh - 230px);
  min-height: 360px;
  overflow-y: auto;
  border-top: 1px solid var(--line);
}
.grid { position: relative; }

/* The original's card face (CardGraphics): the frame image fills the card, the art sits in its
   lower part, the title in the upper left. */
.card {
  position: absolute;
  top: 0;
  left: 0;
  width: 150px;
  height: 220px;
  border-radius: 6px;
  overflow: hidden;
  background: #cfae8c;
  box-shadow: 0 2px 6px rgb(0 0 0 / 45%);
  cursor: pointer;
  user-select: none;
}
.card:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.card .card-bg { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: fill; }
.card .card-art {
  position: absolute;
  left: 7%;
  bottom: 6%;
  width: 86%;
  height: 62%;
  object-fit: contain;
}
.card .card-title {
  position: absolute;
  top: 5%;
  left: 8%;
  right: 6%;
  font-size: 19px;
  line-height: 1.15;
  color: #2b2118;
  overflow-wrap: anywhere;
  word-break: keep-all;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card .img-failed {
  position: absolute;
  bottom: 6px;
  left: 6px;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--error);
  color: #1b1408;
  font-size: 0.7rem;
}
.card .card-bg.img-failed { inset: 6px 6px auto auto; }

.panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(460px, 100vw);
  overflow-y: auto;
  padding: 20px;
  background: var(--panel);
  border-left: 1px solid var(--line);
  box-shadow: -6px 0 18px rgb(0 0 0 / 50%);
  z-index: 10;
}
.panel .close { float: right; padding: 6px 12px; }
.panel h3 { font-size: 1.3rem; margin: 0 0 6px; }
.panel .meta { color: var(--muted); font-size: 0.85rem; }
.panel .description { white-space: pre-line; }
.panel h4 { margin: 18px 0 6px; color: var(--muted); }
.panel .dump {
  margin: 0;
  padding: 10px;
  font-size: 0.75rem;
  line-height: 1.35;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow-x: auto;
}
.failed .error-text { overflow-wrap: anywhere; }
