/* Packshot Flow — library modal (full view) + confirm/prompt modals */
  /* ========= LIBRARY MODAL ========= */
  .modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(8px);
    z-index: 100;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 32px;
    opacity: 0;
    transition: opacity 0.2s;
  }
  .modal-backdrop.open {
    display: flex;
    opacity: 1;
  }
  .modal {
    width: 100%;
    max-width: 1080px;
    max-height: 90vh;
    background: #fff;
    border-radius: 18px;
    box-shadow: var(--shadow-xl);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: scale(0.96);
    transition: transform 0.25s cubic-bezier(0.2, 0.7, 0.2, 1);
  }
  .modal-backdrop.open .modal { transform: scale(1); }
  .modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 24px;
    border-bottom: 1px solid var(--border);
  }
  .modal-title {
    font-size: 17px;
    font-weight: 700;
    letter-spacing: -0.015em;
  }
  .modal-sub {
    font-size: 12.5px;
    color: var(--text-3);
    margin-top: 2px;
  }
  .modal-close {
    width: 32px; height: 32px;
    border-radius: 50%;
    background: var(--surface);
    border: none;
    color: var(--text-2);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
  }
  .modal-close:hover { background: var(--surface-2); color: var(--text-1); }

  .modal-toolbar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 24px;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
  }
  .modal-toolbar .library-search {
    flex: 1;
    margin: 0;
    max-width: 360px;
  }
  .modal-toolbar .library-filters {
    margin: 0;
    padding: 0;
    flex: 1;
  }

  .modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 22px 24px;
    /* Standard height even when a filter has no matches — the modal keeps a
       calm, consistent size instead of collapsing to a strip. */
    min-height: min(440px, 60vh);
  }
  .modal-grid {
    /* Uniform 3:4 grid (see .library-grid). */
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 14px;
  }
  .modal-card {
    position: relative;
    aspect-ratio: 3 / 4;
    border-radius: 12px;
    overflow: hidden;
    border: 2px solid var(--border);
    cursor: pointer;
    background: var(--surface);
    transition: all 0.18s ease;
  }
  .modal-card:hover {
    border-color: var(--text-1);
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
  }
  .modal-card.selected {
    border-color: var(--target-ring);
    box-shadow: 0 0 0 3px var(--target-soft);
  }
  .modal-card img, .modal-card svg { width: 100%; height: 100%; object-fit: contain; display: block; }
  .modal-card-info {
    position: absolute;
    bottom: 0; left: 0; right: 0;
    padding: 24px 10px 8px;
    background: linear-gradient(to top, rgba(0,0,0,0.85) 0%, rgba(0,0,0,0.4) 60%, transparent 100%);
    color: #fff;
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
  }
  .modal-card-name {
    font-size: 11.5px;
    font-weight: 600;
    line-height: 1.3;
    margin-bottom: 2px;
  }
  .modal-card-meta {
    font-size: 10px;
    color: rgba(255,255,255,0.7);
  }
  
  .modal-card-actions {
    display: flex;
    gap: 6px;
  }

  /* Favorite star stays top right */
  .modal-card-fav {
    position: absolute;
    top: 8px; right: 7px;
    width: 24px; height: 24px;
    background: transparent;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-3);
    padding: 0;
    transition: all 0.2s cubic-bezier(0.2, 0.8, 0.2, 1);
    filter: drop-shadow(0 1px 3px rgba(255,255,255,0.9));
    z-index: 2;
  }
  .modal-card-fav:hover { color: #f59e0b; transform: scale(1.12); }
  .modal-card-fav.is-fav { color: #f59e0b; }
  .modal-card-fav.is-fav svg { fill: currentColor; }

  /* Edit and Delete are inside the dark info bar */
  .modal-card-edit, .modal-card-del {
    background: transparent;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px; height: 24px;
    color: rgba(255,255,255,0.6);
    padding: 0;
    transition: all 0.2s ease;
  }
  .modal-card-edit:hover { color: #fff; transform: scale(1.12); }
  .modal-card-del:hover { color: #ef4444; transform: scale(1.12); }

  .modal-card-tag {
    position: absolute;
    top: 8px; left: 8px;
    padding: 3px 7px;
    background: rgba(255,255,255,0.95);
    backdrop-filter: blur(6px);
    border-radius: 6px;
    font-size: 9.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-1);
  }

  .modal-foot {
    padding: 14px 24px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--surface);
  }
  .modal-foot-info {
    font-size: 12.5px;
    color: var(--text-2);
  }
  .modal-actions {
    display: flex;
    gap: 8px;
  }
  .btn-secondary {
    padding: 8px 14px;
    border: 1px solid var(--border);
    background: #fff;
    border-radius: 9px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-1);
    transition: all 0.15s;
  }
  .btn-secondary:hover { background: var(--surface); border-color: var(--border-strong); }
  .btn-primary {
    padding: 8px 16px;
    border: none;
    background: var(--accent);
    border-radius: 9px;
    font-size: 13px;
    font-weight: 600;
    color: #fff;
    transition: all 0.15s;
  }
  .btn-primary:hover { transform: translateY(-1px); box-shadow: var(--shadow-md); }
  .btn-primary:disabled { background: #ededed; color: #aaa; cursor: not-allowed; }

  /* ========= HISTORY MODAL ========= */
  .history-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 14px;
  }
  .history-card {
    border: 1px solid var(--border);
    border-radius: 14px;
    background: #fff;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    transition: all 0.18s ease;
  }
  .history-card:hover { border-color: var(--border-strong); box-shadow: var(--shadow-md); }
  .history-shots {
    display: flex;
    gap: 8px;
  }
  .history-shot {
    position: relative;
    flex: 1;
    aspect-ratio: 3 / 4;
    border-radius: 10px;
    overflow: hidden;
    background: var(--surface);
    border: 1px solid var(--border);
  }
  .history-shot img { width: 100%; height: 100%; object-fit: contain; display: block; background: #fff; }
  .history-shot span {
    position: absolute;
    bottom: 5px; left: 5px;
    padding: 2px 6px;
    border-radius: 5px;
    background: rgba(255,255,255,0.92);
    font-size: 9px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-2);
  }
  .history-title { font-size: 12.5px; font-weight: 600; }
  .history-sub { font-size: 11px; color: var(--text-3); margin-top: 2px; }
  .history-actions { display: flex; gap: 8px; }
  .history-actions button { flex: 1; justify-content: center; font-size: 12px; padding: 7px 10px; }
  .history-empty {
    grid-column: 1 / -1;
    padding: 40px 16px;
    text-align: center;
    color: var(--text-3);
    font-size: 12.5px;
  }

