/* CARD3D Flow — photo library panel (2026-10-28), copied from /studio/photos.css and made into an overlay. */
.lib-overlay [hidden] { display: none !important; }
body.lib-open { overflow: hidden; }
.lib-overlay { position: fixed; inset: 0; z-index: 60; background: rgba(16, 43, 69, .45); display: grid; place-items: center; padding: 16px; }
.lib-card {
  background: var(--paper); border-radius: 12px; width: min(1100px, 100%); height: min(860px, calc(100vh - 32px)); height: min(860px, calc(100dvh - 32px));
  display: flex; flex-direction: column; overflow: hidden; box-shadow: 0 20px 60px rgba(16, 43, 69, .3);
}
.lib-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 16px; border-bottom: 1px dashed var(--crease); }
.lib-head h2 { margin: 0; font-size: 1.6rem; }
.lib-head-btns { display: flex; gap: 8px; align-items: center; }
.lib-head-btns label.btn { cursor: pointer; }
.lib-body { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.lib-list { flex: 1; overflow-y: auto; padding: 14px 16px 20px; }
.lib-lede { margin: 0 0 12px; color: var(--ink-soft); font-size: .95rem; }
.lib-error { color: var(--danger); min-height: 1.5em; margin: .5rem 0 0; font-size: .95rem; }
.lib-note { color: var(--ink-faint); font-size: .85rem; margin: 6px 0 0; }
.btn.danger { border-color: var(--danger); color: var(--danger); background: var(--sheet); }
.btn.danger:hover { background: #FBEDED; }

/* ---------- grid ---------- */
.lib-drop { position: relative; border-radius: 10px; min-height: 240px; }
.lib-drop-hint {
  position: absolute; inset: 0; display: none; place-items: center;
  border: 2px dashed var(--teal); border-radius: 10px; background: rgba(227, 241, 240, .85);
  color: var(--teal-deep); font-family: var(--serif); font-size: 1.6rem; pointer-events: none;
}
.lib-drop.dragging .lib-drop-hint { display: grid; }
.lib-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; }
.lib-empty { border: 1px dashed var(--crease); border-radius: 10px; padding: 48px 24px; text-align: center; color: var(--ink-soft); }
.lib-empty p { margin: 0 auto .4rem; }
.lib-item {
  position: relative; background: var(--sheet); border: 1px solid var(--crease-soft); border-radius: 8px;
  overflow: hidden; display: flex; flex-direction: column; transition: box-shadow .15s, transform .15s;
}
.lib-item:hover { box-shadow: 0 6px 18px rgba(16, 43, 69, .10); transform: translateY(-1px); }
.lib-item.used { border-color: var(--teal); }
.lib-tag { position: absolute; left: 6px; top: 6px; font-size: .7rem; font-weight: 600; background: var(--teal); color: #fff; padding: 2px 7px; border-radius: 999px; pointer-events: none; }
.lib-thumb {
  all: unset; cursor: pointer; display: block; aspect-ratio: 1 / 1;
  background: #fff conic-gradient(#EFEAE1 90deg, #fff 90deg 180deg, #EFEAE1 180deg 270deg, #fff 270deg) 0 0 / 16px 16px;
}
.lib-thumb:focus-visible { outline: 2px solid var(--teal); outline-offset: -2px; }
.lib-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.lib-thumb.loading { background: var(--crease-soft); }
.lib-meta { display: flex; align-items: center; justify-content: space-between; gap: 6px; padding: 6px 6px 6px 10px; font-size: .82rem; color: var(--ink-faint); }
.lib-item .btn.danger { padding: 4px 8px; min-height: 0; font-size: .85rem; }
.lib-item.pending .lib-thumb { display: grid; place-items: center; color: var(--ink-faint); font-size: .9rem; background: var(--crease-soft); }

/* ---------- editor ---------- */
.lib-edit { flex: 1; min-height: 0; display: flex; }
.lib-ed-body { display: grid; grid-template-columns: 1fr 290px; min-height: 0; flex: 1; }
.lib-stage {
  position: relative; display: grid; place-items: center; padding: 16px; min-height: 0; overflow: hidden;
  background: #fff conic-gradient(#EFEAE1 90deg, #fff 90deg 180deg, #EFEAE1 180deg 270deg, #fff 270deg) 0 0 / 20px 20px;
}
/* (2026-10-28) the whole photo always fits the panel: the canvas fills the stage and scales its picture down to fit */
.lib-ed-body { grid-template-rows: minmax(0, 1fr); }
.lib-stage canvas { position: absolute; inset: 16px; width: calc(100% - 32px); height: calc(100% - 32px); object-fit: contain; filter: drop-shadow(0 2px 6px rgba(16, 43, 69, .18)); }
.lib-busy { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 10px; background: rgba(251, 248, 243, .85); color: var(--ink); }
.lib-busy p { margin: 0; text-align: center; }
.lib-spinner { width: 34px; height: 34px; border-radius: 50%; border: 3px solid var(--teal-wash); border-top-color: var(--teal); animation: lib-spin .9s linear infinite; }
@keyframes lib-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .lib-spinner { animation-duration: 3s; } .lib-item { transition: none; } }
.lib-tools { border-left: 1px dashed var(--crease); padding: 14px 16px; overflow-y: auto; display: flex; flex-direction: column; gap: 18px; }
.lib-back { align-self: flex-start; }
.lib-group h3 { font-family: var(--sans); font-size: .78rem; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-soft); margin: 0 0 8px; }
.lib-seg { display: grid; grid-template-columns: repeat(3, 1fr); border: 1px solid var(--crease); border-radius: 8px; overflow: hidden; }
.lib-seg button { border: 0; border-left: 1px solid var(--crease); background: var(--sheet); padding: 8px 4px; cursor: pointer; font-size: .88rem; line-height: 1.2; }
.lib-seg button:first-child { border-left: 0; }
.lib-seg button[aria-checked="true"] { background: var(--teal); color: #fff; }
.lib-strength { margin: 12px 0 0; display: flex; flex-direction: column; gap: 4px; font-size: .9rem; color: var(--ink-soft); }
.lib-strength input { width: 100%; accent-color: var(--teal); }
.lib-toggle { width: 100%; }
.lib-toggle[aria-pressed="true"] { background: var(--teal-wash); border-color: var(--teal); color: var(--teal-deep); }
.lib-save { margin-top: auto; display: flex; flex-direction: column; gap: 8px; }
.lib-save .btn { width: 100%; }

@media (max-width: 760px) {
  .lib-overlay { padding: 0; }
  .lib-card { height: 100vh; height: 100dvh; border-radius: 0; }
  .lib-ed-body { grid-template-columns: 1fr; grid-template-rows: auto; overflow-y: auto; }
  .lib-stage { height: 50vh; height: 50dvh; min-height: 260px; }
  .lib-tools { border-left: 0; border-top: 1px dashed var(--crease); }
  .lib-grid { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; }
}
