.card {
  background: transparent;
  padding: 4px 0 12px;
  border-bottom: 1px dashed var(--border);
  margin-bottom: 12px;
}
.card:last-of-type { border-bottom: 0; }
.card-title { font-size: 14px; font-weight: 700; margin-bottom: 8px; color: var(--text); }

.field { margin-bottom: 10px; }
.field label, .field legend { display: block; font-size: var(--font-sm); color: var(--text-muted); margin-bottom: 4px; }
.field input[type=text],
.field input[type=search],
.field textarea,
.field select {
  width: 100%;
  padding: 7px 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
}
.field input[type=search]::-webkit-search-cancel-button {
  cursor: pointer;
}
.field input[type=search]:focus,
.field input[type=text]:focus,
.field textarea:focus,
.field select:focus {
  border-color: var(--primary);
  outline: none;
  box-shadow: 0 0 0 2px rgba(91, 161, 230, 0.18);
}
.field textarea { resize: vertical; min-height: 60px; font-family: ui-monospace, Consolas, monospace; }

.row { display: flex; gap: 8px; align-items: center; }
.row > * { flex: 1; }
.row > .btn { flex: 0 0 auto; }

.radio-row {
  display: flex; gap: 6px 12px; align-items: center;
  padding: 0; border: 0;
  flex-wrap: wrap;
}
.radio-row legend { width: 100%; margin-bottom: 4px; }
.radio-row label {
  display: inline-flex; gap: 4px; align-items: center;
  margin-bottom: 0; color: var(--text);
  white-space: nowrap;
}

.check { display: inline-flex; gap: 6px; align-items: center; }

.btn {
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  background: var(--surface-alt);
  color: var(--text);
  border: 1px solid var(--border);
  font-weight: 500;
  transition: background .15s ease;
}
.btn:hover { background: var(--border); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: var(--primary-text); border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary { background: var(--surface-alt); }
.btn-block { width: 100%; }

.icon-btn {
  width: 36px; height: 36px; border-radius: 50%;
  display: inline-grid; place-items: center;
  background: var(--surface-alt);
}

.pill {
  display: inline-flex; gap: 4px; align-items: center;
  padding: 3px 10px; border-radius: 999px;
  background: var(--accent); color: var(--primary-text);
  font-size: var(--font-sm); font-weight: 600;
}

.chips { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.chip {
  font-size: 12px; padding: 2px 8px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 999px;
  display: inline-flex; gap: 4px; align-items: center;
  max-width: 100%;
}
.chip > :first-child {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 220px;
}
.chip code {
  font-family: ui-monospace, Consolas, monospace;
  font-size: 11px;
  color: var(--text-muted);
}
.chip button { font-size: 11px; color: var(--text-muted); flex-shrink: 0; }

.muted { color: var(--text-muted); font-size: var(--font-sm); }

.check-grid {
  display: flex; flex-direction: column; gap: 4px;
  font-size: var(--font-sm);
}
.check-grid label { display: inline-flex; gap: 4px; align-items: center; padding: 2px 0; }
.sem-group {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 8px 8px;
  margin: 4px 0;
}
.sem-group legend {
  padding: 0 6px;
  font-weight: 600;
  font-size: var(--font-sm);
  color: var(--text);
}
.sem-group label {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 2px 0;
}
.sem-tree { display: flex; flex-direction: column; gap: 6px; }
.year-block { border: 0; padding: 0; }
.year-block > summary {
  list-style: none;
  cursor: pointer;
  padding: 4px 6px;
  font-weight: 600;
  border-radius: var(--radius-sm);
  user-select: none;
  display: flex;
  align-items: center;
  gap: 6px;
}
.year-block > summary::-webkit-details-marker { display: none; }
.year-block > summary::before {
  content: '▸';
  display: inline-block;
  color: var(--text-muted);
  transition: transform 0.15s ease;
}
.year-block[open] > summary::before { transform: rotate(90deg); }
.year-block > summary:hover { background: rgba(127, 127, 127, 0.08); }
.cat-block {
  border-left: 2px solid var(--border);
  padding-left: 8px;
  margin: 4px 0;
}
.cat-head {
  font-size: var(--font-sm);
  color: var(--text-muted);
  font-weight: 600;
  margin-bottom: 2px;
}
.src-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 2px 0;
}
.sem-group--recommended { background: rgba(46, 122, 123, 0.05); }
.sem-group--empty { opacity: 0.55; }
.sem-group--empty legend { font-weight: 500; }
.empty-hint {
  color: var(--text-muted);
  font-size: var(--font-sm);
  font-style: italic;
  padding: 4px 2px;
}

/* 결과 카드 */
.library-list { display: flex; flex-direction: column; gap: 10px; padding: 4px 0; }
.library-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  background: var(--surface);
  display: grid;
  gap: 6px;
  cursor: pointer;
  transition: border-color .15s ease, background .15s ease, box-shadow .15s ease;
}
.library-card:hover {
  border-color: var(--primary);
  background: var(--surface-alt);
}
.library-card:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 1px;
}
.library-card.active {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(91, 161, 230, 0.20);
  background: var(--surface-alt);
}
/* 카드 내부 버튼·링크는 cursor 따로 (카드 click 영역과 구분) */
.library-card a, .library-card button { cursor: pointer; }
.library-card h3 { font-size: 14px; font-weight: 700; margin: 0; }
.library-card .meta { color: var(--text-muted); font-size: var(--font-sm); }
.library-card .badges { display: flex; flex-wrap: wrap; gap: 4px; }
.badge {
  font-size: 11px; padding: 2px 6px;
  border-radius: var(--radius-sm);
  background: var(--surface-alt);
  border: 1px solid var(--border);
}
.badge-ok      { background: var(--success); color: white; border-color: var(--success); }
.badge-no      { background: var(--surface-alt); color: var(--text-muted); text-decoration: line-through; }
.badge-warn    { background: var(--warn); color: white; border-color: var(--warn); }
.badge-neutral { background: var(--surface-alt); color: var(--text); border-color: var(--border); }

/* 도서관 카드 상단 요약 (대출가능/대출중/보유/미확인 카운트) */
.lc-summary { display: flex; flex-wrap: wrap; gap: 6px; font-size: 11px; margin: 2px 0 0; }
.lc-stat { padding: 1px 7px; border-radius: 999px; font-weight: 600; }
.lc-stat.ok      { background: var(--success);   color: white; }
.lc-stat.no      { background: var(--text-muted); color: white; }
.lc-stat.neutral { background: var(--surface-alt); color: var(--text); border: 1px solid var(--border); }
.lc-stat.warn    { background: var(--warn);     color: white; }

.actions { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.actions a, .actions button {
  font-size: 12px; padding: 3px 10px;
  border-radius: var(--radius-sm);
  background: var(--surface-alt);
  color: var(--text);
  text-decoration: none;
  border: 1px solid var(--border);
}
.actions a:hover, .actions button:hover { background: var(--primary); color: var(--primary-text); border-color: var(--primary); }

/* 모달 */
.modal {
  border: 0; border-radius: var(--radius);
  padding: 0; max-width: 720px; width: 92%;
  background: var(--surface); color: var(--text);
  box-shadow: var(--shadow);
}
.modal::backdrop { background: rgba(0,0,0,.45); }
.modal-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}
.modal-body { padding: 14px 16px; }

.toast {
  position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%);
  padding: 8px 14px;
  background: var(--text); color: var(--bg);
  border-radius: 999px;
  box-shadow: var(--shadow);
  z-index: 100;
}

.place-candidates {
  margin-top: 6px;
  max-height: 240px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-alt);
}
.place-candidates header {
  padding: 6px 10px;
  font-size: 12px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: center;
  position: sticky; top: 0;
  background: var(--surface-alt);
}
.place-candidates ul { display: flex; flex-direction: column; }
.place-candidates li {
  padding: 6px 10px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  display: grid;
  gap: 1px;
}
.place-candidates li:last-child { border-bottom: 0; }
.place-candidates li:hover, .place-candidates li:focus {
  background: var(--primary);
  color: var(--primary-text);
  outline: none;
}
.place-candidates li.selected { background: var(--accent); color: var(--primary-text); }
.place-candidates .pc-title { font-weight: 600; }
.place-candidates .pc-addr { color: var(--text-muted); font-size: 11px; }
.place-candidates li:hover .pc-addr,
.place-candidates li:focus .pc-addr,
.place-candidates li.selected .pc-addr { color: rgba(255,255,255,0.85); }

/* DB 검색 결과 리스트 */
.db-search-results {
  margin-top: 6px;
  max-height: 260px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-alt);
}
.db-search-results header {
  padding: 6px 10px;
  font-size: 11px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0;
  background: var(--surface-alt);
  display: flex; justify-content: space-between; align-items: center;
}
.db-search-results ul { display: flex; flex-direction: column; }
.db-search-results li {
  padding: 6px 10px;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px;
  align-items: center;
}
.db-search-results li:last-child { border-bottom: 0; }
.db-search-results li.selected { background: rgba(46, 122, 123, 0.10); }
.db-search-results .dbr-title { font-weight: 600; }
.db-search-results .dbr-cat {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 6px;
  border-radius: 8px;
  background: rgba(46, 122, 123, 0.15);
  color: var(--accent);
  font-size: 10px;
  font-weight: 500;
  vertical-align: middle;
}
.db-search-results .dbr-meta { color: var(--text-muted); font-size: 11px; }
.db-search-results .dbr-src { color: var(--accent); font-size: 11px; }
.db-search-results .dbr-add {
  padding: 3px 10px; min-width: 56px;
  border-radius: var(--radius-sm);
  background: var(--primary); color: var(--primary-text);
  border: 1px solid var(--primary);
  font-size: 11px;
}
.db-search-results .dbr-add[data-state="added"] {
  background: var(--success); color: white; border-color: var(--success);
}
.db-search-results .dbr-add:disabled { opacity: 0.6; cursor: default; }

/* 지도 마커 hover 툴팁 (ol.Overlay) */
.map-tooltip {
  pointer-events: none;
  background: rgba(20, 24, 32, 0.92);
  color: #fff;
  font-size: 12px;
  padding: 4px 8px;
  border-radius: 4px;
  white-space: nowrap;
  box-shadow: 0 2px 6px rgba(0,0,0,0.25);
  max-width: 280px;
  overflow: hidden;
  text-overflow: ellipsis;
  z-index: 80;
}
.map-tooltip[hidden] { display: none; }

/* 지도 우클릭 컨텍스트 메뉴 */
.map-context-menu {
  position: absolute;
  z-index: 90;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: 0 6px 16px rgba(0,0,0,.18);
  min-width: 220px;
  font-size: 12px;
  overflow: hidden;
}
.map-context-menu .mcm-coord {
  padding: 8px 10px 6px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  font-family: ui-monospace, Consolas, monospace;
  font-size: 11px;
}
.map-context-menu button {
  display: block;
  width: 100%;
  padding: 8px 12px;
  text-align: left;
  background: transparent;
  color: var(--text);
  border: 0;
  font-size: 12px;
}
.map-context-menu button:hover,
.map-context-menu button:focus {
  background: var(--primary);
  color: var(--primary-text);
  outline: none;
}
.map-context-menu .mcm-cancel {
  border-top: 1px solid var(--border);
  color: var(--text-muted);
}
