/* ============================================================
   structure-viewer.css — embedded 3Dmol.js structure viewers
   ============================================================ */

   .sv {
    margin: 2rem 0 2.5rem;
    border: 1px solid #d9d9d9;
    border-radius: 10px;
    background: #fbfbfd;
    overflow: hidden;
  }
  
  /* ---- structure selector ---- */
  .sv-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    padding: 0.9rem 1rem;
    border-bottom: 1px solid #ececf1;
    background: #f4f4f8;
  }
  
  .sv-tab {
    border: 1px solid #c9cbdd;
    background: #fff;
    color: #243763;
    border-radius: 999px;
    padding: 0.35rem 0.9rem;
    font-size: 0.85rem;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
  }
  
  .sv-tab:hover { border-color: #848dc6; color: #848dc6; }
  
  .sv-tab.is-active {
    background: #848dc6;
    border-color: #848dc6;
    color: #fff;
  }
  
  /* ---- viewport ---- */
  .sv-stage {
    position: relative;
    width: 100%;
    height: 26rem;
    background: #ffffff;
  }
  
  .sv-stage canvas { display: block; }
  
  .sv-loading {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    color: #5a6280;
    font-style: italic;
    background: #fbfbfd;
    pointer-events: none;
    transition: opacity 0.25s ease;
  }
  
  .sv-loading.is-hidden { opacity: 0; }
  
  /* fallback shown if WebGL / 3Dmol is unavailable */
  .sv-fallback {
    display: none;
    padding: 1.25rem;
    text-align: center;
  }
  .sv-fallback img { max-width: 100%; height: auto; border-radius: 8px; }
  .sv.is-fallback .sv-stage,
  .sv.is-fallback .sv-toolbar { display: none; }
  .sv.is-fallback .sv-fallback { display: block; }
  
  /* ---- toolbar ---- */
  .sv-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 1rem;
    padding: 0.7rem 1rem;
    border-top: 1px solid #ececf1;
    background: #f4f4f8;
    font-size: 0.82rem;
    color: #3a4160;
  }
  
  .sv-toolbar label {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    cursor: pointer;
  }
  
  .sv-toolbar button {
    border: 1px solid #c9cbdd;
    background: #fff;
    color: #243763;
    border-radius: 6px;
    padding: 0.25rem 0.7rem;
    font-size: 0.8rem;
    cursor: pointer;
  }
  .sv-toolbar button:hover { border-color: #848dc6; color: #848dc6; }
  
  .sv-hint {
    margin-left: auto;
    font-style: italic;
    color: #7a819c;
  }
  
  /* ---- legend ---- */
  .sv-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 0.9rem;
    padding: 0.7rem 1rem 0.9rem;
    background: #fff;
    border-top: 1px solid #ececf1;
    font-size: 0.8rem;
    color: #3a4160;
  }
  
  .sv-key {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
  }
  
  .sv-swatch {
    width: 0.85rem;
    height: 0.85rem;
    border-radius: 3px;
    border: 1px solid rgba(0,0,0,0.15);
    flex: 0 0 auto;
  }
  
  /* ---- caption ---- */
  .sv-caption {
    font-size: 0.85rem;
    font-style: italic;
    color: #5a6280;
    line-height: 1.5;
    margin-top: 0.6rem;
    text-align: left;
    max-width: 46rem;
    margin-left: auto;
    margin-right: auto;
  }
  
  @media (max-width: 640px) {
    .sv-stage { height: 20rem; }
    .sv-hint { display: none; }
  }