/* BIOMED REWIRED - Device Library directory, tiles, chips, and preview dialog */
.lib { padding: 22px 16px 48px; }
.crumbs { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; font-size: .85rem; color: var(--muted); margin-bottom: 14px; }
.crumbs a { color: var(--cyan); }
.crumbs a:hover { text-decoration: underline; }
.lib-head h1 { font-size: clamp(1.7rem, 3.2vw, 2.3rem); font-weight: 800; letter-spacing: -.01em; }
.lib-head h1:focus { outline: none; }
.lib-head p { margin-top: 8px; max-width: 72ch; color: #d4e2f5; }

.lib-controls { display: flex; flex-wrap: wrap; gap: 14px 18px; align-items: flex-end; margin: 22px 0 12px; padding: 14px; border: 1.5px solid var(--line); border-radius: 12px; background: linear-gradient(180deg, rgba(12,34,68,.85), rgba(7,20,42,.9)); }
.f-search { position: relative; flex: 1 1 280px; }
.f-search .ic { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; color: var(--muted); }
.f-search input { width: 100%; font: inherit; font-size: .95rem; color: var(--text); background: #07142b; border: 1.5px solid rgba(255,255,255,.55); border-radius: 8px; padding: 11px 14px 11px 40px; }
.f-search input::placeholder { color: #aebfd9; }
.f-sel { display: grid; gap: 4px; font-size: .78rem; font-weight: 600; color: var(--muted); flex: 0 1 280px; }
.f-sel select { font: inherit; font-size: .92rem; color: var(--text); background: #07142b; border: 1.5px solid rgba(255,255,255,.55); border-radius: 8px; padding: 10px 12px; }
.f-seg { border: 0; margin: 0; padding: 0; min-width: 0; }
.f-seg legend { font-size: .78rem; font-weight: 600; color: var(--muted); padding: 0; margin-bottom: 4px; }
.seg { display: inline-flex; border: 1.5px solid rgba(255,255,255,.55); border-radius: 8px; overflow: hidden; }
.seg-opt { position: relative; }
.seg-opt input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.seg-opt span { display: block; padding: 10px 14px; font-size: .88rem; font-weight: 600; background: #07142b; cursor: pointer; border-left: 1px solid rgba(255,255,255,.25); }
.seg-opt:first-child span { border-left: 0; }
.seg-opt input:checked + span { background: #129fb4; color: #fff; }
.seg-opt input:focus-visible + span { outline: 2px solid var(--cyan); outline-offset: -3px; }
.lib-clear { font: inherit; font-size: .85rem; font-weight: 600; color: var(--cyan); background: none; border: 1px solid var(--line); border-radius: 8px; padding: 10px 14px; cursor: pointer; }
.lib-clear:hover { background: rgba(25,211,240,.1); }
.lib-count { font-size: .85rem; color: var(--muted); margin: 8px 2px 4px; min-height: 1.2em; }

.lib-group { margin-top: 22px; }
.lib-group-h { display: flex; align-items: center; gap: 10px; font-size: 1.05rem; font-weight: 700; margin-bottom: 12px; padding-bottom: 8px; border-bottom: 1px solid rgba(40,200,255,.25); }
.lib-group-h .n { margin-left: auto; font-size: .78rem; font-weight: 600; color: var(--muted); }
.cat-ic { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
.cat-ic.sm { width: 20px; height: 20px; color: var(--cyan); }

.lib-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(176px, 1fr)); gap: 12px; }
.dev-tile { display: flex; flex-direction: column; gap: 6px; min-height: 176px; aspect-ratio: 1 / 1; padding: 14px; border-radius: 12px; background: linear-gradient(170deg, rgba(16,44,86,.95), rgba(8,22,46,.95)); border: 1.5px solid rgba(40,200,255,.3); box-shadow: 0 6px 18px rgba(0,0,0,.3); transition: transform .15s, border-color .15s, box-shadow .15s; }
.dev-tile:hover { transform: translateY(-3px); border-color: var(--cyan); box-shadow: 0 10px 26px rgba(25,211,240,.28); }
.dev-ic { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 10px; background: rgba(25,211,240,.12); color: var(--cyan); }
.dev-name { font-weight: 700; font-size: .98rem; line-height: 1.2; margin-top: 2px; }
.dev-cat { font-size: .74rem; color: var(--muted); line-height: 1.25; }
.dev-meta { margin-top: auto; display: flex; flex-wrap: wrap; gap: 5px; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-block; font-size: .68rem; font-weight: 700; letter-spacing: .02em; padding: 3px 8px; border-radius: 999px; border: 1px solid rgba(255,255,255,.3); color: #e4eefc; background: rgba(255,255,255,.07); white-space: nowrap; }
.d-beginner { color: #8ff0b4; border-color: rgba(143,240,180,.55); background: rgba(49,211,106,.12); }
.d-intermediate { color: #ffd98a; border-color: rgba(255,217,138,.55); background: rgba(255,185,40,.12); }
.d-advanced { color: #ffb3c1; border-color: rgba(255,179,193,.55); background: rgba(255,90,120,.12); }
.st-ok { color: #8fe8f7; border-color: rgba(25,211,240,.6); background: rgba(25,211,240,.14); }
.st-dev { color: #c3d1e8; border-style: dashed; background: transparent; }

.lib-empty { margin-top: 30px; padding: 28px; text-align: center; border: 1.5px dashed var(--line); border-radius: 12px; }
.lib-empty p { margin-bottom: 10px; color: #d4e2f5; }

/* Preview dialog */
dialog.pv { width: min(780px, calc(100% - 24px)); }
.pv-x { position: absolute; top: 10px; right: 12px; z-index: 2; }
.pv-grid { display: grid; grid-template-columns: 1fr 1.1fr; }
.pv-art { padding: 28px 22px 20px; background: radial-gradient(400px 300px at 50% 30%, #12315f, #07142b); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; min-height: 300px; }
.pv-art img { width: 100%; max-width: 330px; height: auto; }
.pv-glyph { width: 130px; height: 130px; display: grid; place-items: center; border-radius: 26px; border: 1.5px solid rgba(40,200,255,.45); background: rgba(25,211,240,.08); color: var(--cyan); }
.pv-ic { width: 72px; height: 72px; fill: none; stroke: currentColor; stroke-width: 1.4; stroke-linecap: round; stroke-linejoin: round; }
.pv-cap { font-size: .74rem; color: var(--muted); text-align: center; }
.pv-main { padding: 28px 28px 26px; display: flex; flex-direction: column; gap: 12px; }
.pv-cat { font-size: .78rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--cyan); }
.pv-main h2 { font-size: 1.6rem; line-height: 1.15; }
.pv-sum { color: #dce8fa; line-height: 1.55; }
.pv-note { padding: 12px 14px; border: 1px dashed rgba(255,255,255,.35); border-radius: 10px; font-size: .9rem; color: #dce8fa; }
.pv-main .btn { align-self: flex-start; margin-top: 6px; }

@media (max-width: 720px) {
  .pv-grid { grid-template-columns: 1fr; }
  .pv-art { min-height: 0; padding: 36px 20px 14px; }
  .pv-art img { max-width: 240px; }
  .lib-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .dev-tile { padding: 12px; min-height: 160px; }
  .lib-controls { padding: 12px; }
  .f-sel { flex: 1 1 100%; }
  .seg-opt span { padding: 10px 11px; }
}
@media (prefers-reduced-motion: reduce) { .dev-tile { transition: none; } }

/* device thumbnails: line-art of each instrument, same style as the home-page study topic cards */
.dev-tile { aspect-ratio: auto; min-height: 0; padding: 10px 10px 12px; }
.dev-thumb { display: block; border-radius: 9px; overflow: hidden; background: radial-gradient(200px 140px at 50% 35%, #12315f, #07142b); border: 1px solid rgba(40,200,255,.18); }
.dev-thumb img { display: block; width: 100%; height: auto; aspect-ratio: 420 / 300; }
.dev-tile .dev-name { margin-top: 6px; }
.f-sel { min-width: 0; max-width: 100%; }
.f-sel select { width: 100%; min-width: 0; max-width: 100%; box-sizing: border-box; text-overflow: ellipsis; }
