:root {
  --bg: #0f1217;
  --panel: #161b22;
  --card: #181e27;
  --card-hover: #1f2733;
  --card-active: #232d3d;
  --border: #27303f;
  --accent: #5893ff;
  --ok-bg: #173422;
  --ok-border: #2b8a4e;
  --ok-text: #7ce39c;
  --text: #eef2f7;
  --muted: #939fb0;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 20px 24px 36px;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.wrap {
  max-width: 1240px;
  margin: 0 auto;
}

.wrap.legal {
  max-width: 800px;
}

header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

h1 {
  margin: 0;
  font-size: 1.3rem;
  font-weight: 650;
}

.header-right {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}

.size-control {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.84rem;
  color: var(--muted);
}

select#size-mode {
  padding: 5px 10px;
  border-radius: 8px;
  background: var(--panel);
  border: 1px solid var(--border);
  font-size: 0.84rem;
  color: var(--text);
  cursor: pointer;
  outline: none;
}

select#size-mode:focus {
  border-color: var(--accent);
}

.hint {
  font-size: 0.85rem;
  color: var(--muted);
}

.inspector {
  display: none;
  grid-template-columns: 96px 1fr auto;
  align-items: center;
  gap: 18px;
  padding: 14px 18px;
  margin-bottom: 14px;
  border-radius: 12px;
  background: var(--panel);
  border: 1px solid var(--border);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.35);
}

.inspector.open {
  display: grid;
}

.preview-box {
  width: 96px;
  height: 96px;
  border-radius: 10px;
  background:
    linear-gradient(45deg, #1e2530 25%, transparent 25%),
    linear-gradient(-45deg, #1e2530 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #1e2530 75%),
    linear-gradient(-45deg, transparent 75%, #1e2530 75%);
  background-size: 16px 16px;
  background-position:
    0 0,
    0 8px,
    8px -8px,
    -8px 0;
  background-color: #12161c;
  border: 1px solid var(--border);
  display: grid;
  place-items: center;
  overflow: hidden;
}

.preview-box img {
  width: 76px;
  height: 76px;
  object-fit: contain;
}

.no-img {
  font-size: 0.75rem;
  color: var(--muted);
  text-align: center;
  padding: 6px;
}

.insp-meta {
  min-width: 0;
}

.insp-title {
  font-size: 1.05rem;
  font-weight: 650;
  word-break: break-word;
}

.insp-sub {
  margin-top: 4px;
  font-size: 0.85rem;
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  word-break: break-all;
}

.insp-status {
  margin-top: 6px;
  font-size: 0.82rem;
  color: var(--ok-text);
  min-height: 1.1em;
}

.insp-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

button {
  cursor: pointer;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #202836;
  color: var(--text);
  font-size: 0.84rem;
  font-weight: 500;
  transition:
    background 0.12s ease,
    border-color 0.12s ease;
}

button:hover {
  background: #293345;
  border-color: #3a475e;
}

button.copied {
  background: var(--ok-bg);
  border-color: var(--ok-border);
  color: var(--ok-text);
}

button.ghost {
  background: transparent;
  color: var(--muted);
}

.search-row {
  position: relative;
  display: flex;
  align-items: center;
}

input#search {
  width: 100%;
  padding: 12px 40px 12px 14px;
  font-size: 1rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  outline: none;
}

input#search:focus {
  border-color: var(--accent);
}

input#search::-webkit-search-cancel-button {
  -webkit-appearance: none;
  appearance: none;
}

.clear-btn {
  display: none;
  position: absolute;
  right: 8px;
  width: 26px;
  height: 26px;
  padding: 0;
  border-radius: 6px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  font-size: 1.05rem;
  line-height: 1;
  align-items: center;
  justify-content: center;
}

.clear-btn.visible {
  display: inline-flex;
}

.clear-btn:hover {
  background: #242c3b;
  color: var(--text);
  border-color: var(--border);
}

.stats {
  margin: 10px 0 14px;
  font-size: 0.85rem;
  color: var(--muted);
}

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

.card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 5px;
  padding: 8px 6px 7px;
  border-radius: 8px;
  background: var(--card);
  border: 1px solid var(--border);
  cursor: pointer;
  user-select: none;
  transition:
    transform 0.1s ease,
    background 0.12s ease,
    border-color 0.12s ease;
}

.card:hover {
  background: var(--card-hover);
  border-color: #384459;
  transform: translateY(-1px);
}

.card.selected {
  background: var(--card-active);
  border-color: var(--accent);
}

.card.just-copied {
  border-color: var(--ok-border);
  background: var(--ok-bg);
}

.thumb {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
}

.thumb img {
  width: 34px;
  height: 34px;
  object-fit: contain;
}

.card-name {
  width: 100%;
  font-size: 0.68rem;
  line-height: 1.15;
  color: var(--text);
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  word-break: break-word;
}

body.view-large .grid {
  grid-template-columns: repeat(auto-fill, minmax(126px, 1fr));
  gap: 10px;
}

body.view-large .card {
  gap: 8px;
  padding: 12px 8px 10px;
  border-radius: 10px;
}

body.view-large .thumb {
  width: 56px;
  height: 56px;
}

body.view-large .thumb img {
  width: 48px;
  height: 48px;
}

body.view-large .card-name {
  font-size: 0.78rem;
  line-height: 1.25;
  -webkit-line-clamp: 2;
}

body.view-compact .grid {
  grid-template-columns: repeat(auto-fill, 54px);
  gap: 6px;
  justify-content: start;
}

body.view-compact .card {
  width: 54px;
  height: 54px;
  padding: 0;
  gap: 0;
  border-radius: 8px;
}

body.view-compact .thumb {
  width: 34px;
  height: 34px;
}

body.view-compact .thumb img {
  width: 34px;
  height: 34px;
}

body.view-compact .card-name {
  display: none;
}

footer.site-footer {
  margin-top: 32px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  font-size: 0.82rem;
  line-height: 1.5;
  color: var(--muted);
}

.footer-left {
  flex-shrink: 0;
}

.footer-right {
  max-width: 720px;
  text-align: right;
}

a {
  color: var(--accent);
  text-decoration: none;
  word-break: break-word;
}

a:hover {
  text-decoration: underline;
}

.disclaimer {
  margin: 0 0 14px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--panel);
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.45;
}

.legal-nav {
  margin-bottom: 18px;
  font-size: 0.9rem;
}

.legal-body h2 {
  margin: 1.6em 0 0.5em;
  font-size: 1.05rem;
}

.legal-body p,
.legal-body li {
  color: var(--muted);
  line-height: 1.55;
  font-size: 0.95rem;
}

.legal-body ul {
  padding-left: 1.2em;
}

pre.license {
  overflow: auto;
  padding: 14px;
  border-radius: 10px;
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 0.78rem;
  line-height: 1.45;
  white-space: pre-wrap;
}

@media (max-width: 720px) {
  .inspector.open {
    grid-template-columns: 72px 1fr;
  }

  .preview-box {
    width: 72px;
    height: 72px;
  }

  .preview-box img {
    width: 56px;
    height: 56px;
  }

  .insp-actions {
    grid-column: 1 / -1;
    justify-content: flex-start;
  }

  .footer-right {
    text-align: left;
  }
}
