:root {
  --bg: #f9fafb;
  --card-bg: #ffffff;
  --primary: #2563eb;
  --text: #111827;
  --text-light: #6b7280;
  --radius: 12px;
  --shadow: 0 2px 6px rgba(0,0,0,.05);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

header {
  padding: 1.5rem 1rem;
  text-align: center;
}

h1 {
  margin: 0;
  font-size: 1.75rem;
}

#search {
  margin-top: .75rem;
  width: 100%;
  max-width: 480px;
  padding: .65rem 1rem;
  border: 1px solid #d1d5db;
  border-radius: var(--radius);
  font-size: 1rem;
}

main {
  max-width: 960px;
  margin: 2rem auto;
  padding: 0 1rem;
  display: grid;
  gap: 1rem;
}

.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: .75rem;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: .5rem;
}

.lib-name {
  font-size: 1.1rem;
  font-weight: 600;
}

.badge {
  background: var(--primary);
  color: #fff;
  padding: .2rem .55rem;
  border-radius: .375rem;
  font-size: .75rem;
}

.links {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
}

.btn {
  padding: .45rem .75rem;
  border-radius: .375rem;
  border: 1px solid #d1d5db;
  background: #f3f4f6;
  font-size: .85rem;
  cursor: pointer;
  transition: background .15s;
}

.btn:hover {
  background: #e5e7eb;
}

footer {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--text-light);
  font-size: .85rem;
}

@media (min-width: 640px) {
  main {
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  }
}

.group {
  grid-column: 1 / -1;
  margin: 1rem 0 .25rem;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-light);
}

/* ------------ карточки ------------- */
.scope .hint {
  margin: .25rem 0 0;
  color: var(--text-light);
  font-size: .85rem;
}

/* ------------ модалка -------------- */
#modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  display: flex;
  align-items: center;
  justify-content: center;
  visibility: hidden;
  opacity: 0;
  transition: opacity .25s;
  z-index: 1000;
}

#modal.show {
  visibility: visible;
  opacity: 1;
}

.modal-content {
  background: var(--card-bg);
  color: var(--text);
  max-width: 700px;
  max-height: 80vh;
  overflow-y: auto;
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  box-shadow: var(--shadow);
  position: relative;
}

.modal-close {
  position: absolute;
  top: .5rem;
  right: .5rem;
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
}

.lib-block + .lib-block {
  margin-top: 1rem;
}

.lib-block h3 {
  margin: 0 0 .5rem;
  font-size: 1rem;
}

.row input {
  flex: 1 1 260px;
  padding: .4rem .55rem;
  border: 1px solid #d1d5db;
  border-radius: var(--radius);
  background: #f3f4f6;
  font-family: monospace;
  font-size: .85rem;
}

.row {
  display: flex;
  flex-direction: column;
  gap: .1rem;
}

.row-body {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
}

.badge-top {
  align-self: flex-start;
  color: var(--text);
  font-size: 7pt;
  font-weight: 600;
  text-transform: uppercase;
  padding: .07rem .4rem;
  border-radius: .375rem;
  display: inline-flex;
  gap: .25rem;
}

.badge-top .sub {}

.kind {
  font-weight: 600;
  min-width: 46px;
}

.kind .tag {
  font-size: .7rem;
  margin-left: .25rem;
  background: var(--primary);
  color: #fff;
  padding: .05rem .4rem;
  border-radius: .25rem;
}

.actions {
  display: flex;
  gap: .25rem;
}

.icon-btn {
  width: 2.25rem;
  height: 2.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #d1d5db;
  border-radius: .375rem;
  background: #f3f4f6;
  cursor: pointer;
  font-size: 1.05rem;
  line-height: 1;
  transition: background .15s;
}

.icon-btn:hover {
  background: #e5e7eb;
}

.icon-btn svg {
  width: 1rem;
  height: 1rem;
  fill: currentColor;
  pointer-events: none;
}
