#library .page-title { margin: 10px 0 24px; }
#library .page-title h1 { font-size: clamp(34px, 6vw, 68px); line-height: 1.08; letter-spacing: -.035em; text-transform: uppercase; }
.library-tabs { display: flex; gap: 9px; margin-bottom: 29px; padding: 6px; width: max-content; max-width: 100%; border: 1px solid #373c38; border-radius: 13px; background: #15191a; }
.library-tabs button { display: inline-flex; align-items: center; justify-content: center; gap: 10px; min-height: 47px; padding: 10px 19px; border: 1px solid transparent; border-radius: 9px; background: transparent; color: #b5bab4; font: 700 15px/1.2 'Manrope', Arial, sans-serif; white-space: nowrap; }
.library-tabs button:hover { color: #fff; background: #252b24; }
.library-tabs button[aria-selected="true"] { color: #18210c; background: #cbfb48; box-shadow: 0 3px 10px #0005; }
.library-tab-count { display: inline-grid; place-items: center; min-width: 26px; height: 24px; padding: 0 6px; border-radius: 6px; background: #30362d; color: #d9e5d0; font: 700 12px 'DM Mono', monospace; }
.library-tabs button[aria-selected="true"] .library-tab-count { background: #a6cc39; color: #15210b; }
.library-view[hidden] { display: none; }
.library-section-heading { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 20px; }
.library-section-heading h2 { margin: 0 0 5px; color: #f5f5f1; font: 800 clamp(21px, 2vw, 28px)/1.2 'Manrope', Arial, sans-serif; letter-spacing: -.04em; }
.library-section-heading p { margin: 0; color: #aeb5ad; font-size: 14px; line-height: 1.45; }
.library-groups { display: grid; gap: 18px; }
#library [hidden] { display: none; }
.library-identity { min-width: 0; border: 1px solid #3b403d; border-radius: 13px; background: #181b20; overflow: hidden; }
#library .model { min-width: 0; padding: 16px 22px; border: 0; border-top: 1px solid #353a36; border-radius: 0; background: transparent; }
.library-album-grid { display: grid; grid-template-columns: repeat(auto-fill,minmax(min(100%,194px),1fr)); gap: 16px; }
.library-album {
  display: grid;
  min-width: 0;
  overflow: hidden;
  padding: 0;
  border: 1px solid #404740;
  border-radius: 13px;
  background: #181d1b;
  color: #f5f7ee;
  text-align: left;
}
.library-album:hover { border-color: #a5be67; background: #212820; }
.library-album-cover, .library-gallery-frame {
  position: relative;
  display: grid;
  place-items: center;
  width: 100%;
  aspect-ratio: 1;
  overflow: hidden;
  background: #252b25;
}
.library-album-cover img, .library-gallery-frame img {
  position: absolute;
  inset: 0;
  z-index: 1;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 38%;
}
.library-image-placeholder {
  width: 32px;
  aspect-ratio: 1;
  border: 1px solid #66725a;
  border-radius: 6px;
  box-shadow: 5px 5px 0 -1px #252b25, 5px 5px 0 0 #66725a;
}
.library-album-caption { display: grid; gap: 3px; padding: 13px 14px; }
.library-album-caption strong { overflow-wrap: anywhere; font-size: 17px; line-height: 1.2; }
.library-album-caption span, #library-gallery-count { color: #b6c1b0; font-size: 14px; }
#library-gallery-back { min-height: 44px; margin-bottom: 18px; }
.library-gallery-heading { display: flex; align-items: baseline; flex-wrap: wrap; gap: 5px 14px; margin-bottom: 16px; }
.library-gallery-heading h2 { margin: 0; font-size: clamp(25px,4vw,37px); line-height: 1.1; overflow-wrap: anywhere; }
.library-gallery-tools { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin: 0 0 14px; }
.library-gallery-tools .btn { min-height: 43px; padding: 9px 13px; font-size: 13px; }
.library-gallery-tools .btn:disabled { opacity: .5; cursor: not-allowed; }
#library-gallery-selected { padding: 8px 12px; border: 1px solid #9bbc3a; border-radius: 9px; background: #26331a; color: #e8ffc1; font-size: 16px; font-weight: 800; }
.library-gallery-selection-status { margin: -3px 0 14px; padding: 13px 16px; border: 1px solid #627d3f; border-radius: 9px; background: #20291b; color: #e7f7d2; font-size: 15px; font-weight: 700; }
.library-gallery-grid { display: grid; grid-template-columns: repeat(auto-fill,minmax(140px,1fr)); gap: 6px; }
#library-gallery-open-videos { margin-bottom: 14px; }
.library-video-heading label { display:flex; flex-wrap:wrap; align-items:center; gap:9px; }
#library-video-status:empty, #library-video-feedback:empty { display:none; }
.library-video-list { display:grid; grid-template-columns:repeat(auto-fill,minmax(min(100%,260px),1fr)); gap:12px; }
.library-video-card { display:grid; min-width:0; padding:0; overflow:hidden; border:1px solid #434b40; border-radius:12px; background:#1a2019; color:#eef4eb; text-align:left; }
.library-video-card:hover, .library-video-card:focus-visible { border-color:#cbfb48; }
.library-video-preview { position:relative; display:grid; place-items:center; aspect-ratio:4/5; background:#111613; }
.library-video-preview img { position:absolute; inset:0; width:100%; height:100%; object-fit:contain; }
.library-video-placeholder { padding:12px; color:#adb9a9; font-size:13px; text-align:center; }
.library-video-play { position:absolute; bottom:10px; right:10px; display:grid; place-items:center; width:38px; height:38px; border-radius:9px; color:#17210b; background:#cbfb48; }
.library-video-caption { padding:12px 14px; }
.library-video-card strong,.library-video-card time { display:block; overflow-wrap:anywhere; }
.library-video-card time { margin-top:5px; color:#bac6b5; font-size:13px; }
@media(max-width:650px){
  .library-video-list { grid-template-columns:repeat(2,minmax(0,1fr)); gap:8px; }
  .library-video-caption { padding:10px; }
  .library-video-play { width:32px; height:32px; bottom:7px; right:7px; }
}
.library-video-dialog { width:min(660px,calc(100% - 24px)); max-height:calc(100dvh - 24px); padding:clamp(14px,3vw,24px); border:1px solid #526147; border-radius:16px; background:#171b1a; color:#f5f5f1; }
.library-video-dialog::backdrop { background:#050706dc; backdrop-filter:blur(6px); }
.library-video-dialog-header { display:flex; align-items:center; justify-content:space-between; gap:12px; margin-bottom:14px; }
.library-video-dialog-header h2 { margin:0; overflow-wrap:anywhere; }
#library-video-close { flex:0 0 42px; height:42px; border:1px solid #596257; border-radius:8px; background:#292e29; color:#fff; font-size:24px; }
#library-video-player { display:block; width:100%; max-height:64dvh; background:#080a09; border-radius:9px; }
#library-video-player[poster] { min-height:min(50dvh,360px); }
.library-video-dialog [hidden] { display:none !important; }
#library-video-speed-control { margin-block:14px 0; }
#library-video-speed { flex:1; min-width:0; padding:0; accent-color:#c9ff46; }
#library-video-speed-value { min-width:5ch; text-align:right; font-variant-numeric:tabular-nums; }
#library-video-feedback { color:#c9d3c4; }
.library-gallery-photo { position: relative; display: block; min-width: 0; overflow: hidden; padding: 0; border: 0; border-radius: 5px; background: #222921; }
.library-gallery-photo.is-selecting::after { content: ''; position: absolute; top: 7px; right: 7px; z-index: 2; width: 24px; height: 24px; border: 2px solid #fff; border-radius: 7px; background: #131916bd; box-shadow: 0 1px 5px #0008; }
.library-gallery-photo.is-selected::after { content: '✓'; display: grid; place-items: center; border-color: #cbfb48; background: #cbfb48; color: #11180c; font: 800 17px/1 'Manrope', Arial, sans-serif; }
.library-gallery-photo.is-selected { outline: 3px solid #cbfb48; outline-offset: -3px; }
.library-gallery-date { position: absolute; z-index: 2; bottom: 5px; left: 5px; display: grid; gap: 1px; padding: 4px 6px; border: 1px solid #ffffff36; border-radius: 5px; background: #111816d9; color: #fff; font: 600 10px/1.1 'DM Mono', monospace; font-variant-numeric: tabular-nums; text-align: left; pointer-events: none; }
.library-gallery-photo:hover img { filter: brightness(1.1); }
.library-gallery-photo:focus-visible, .library-album:focus-visible { position: relative; z-index: 2; outline: 2px solid #cbfb48; outline-offset: 2px; }
#library-gallery-activity details { margin-top: 24px; padding: 12px 0; border-top: 1px solid #3b403d; }
#library-gallery-activity summary { min-height: 44px; padding: 10px 4px; color: #cedac6; cursor: pointer; }
.library-activity-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 4px; color: #bbc4b8; }
#library .model strong { color: #f5f6f1; font-size: 15px; overflow-wrap: anywhere; }
#library .model small { margin-top: 5px; color: #aeb5b0; font-size: 13px; }
#library .model .btn { min-height: 42px; padding: 9px 13px; font-size: 13px; }
#library .library-identity > .model { border-top: 0; }
.library-portrait-summary { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 22px 17px; border-top: 1px solid #353a36; color: #bfc9ba; font-size: 13px; }
.library-text-action { padding: 6px 0; border: 0; background: transparent; color: #cbfb48; font: 700 13px 'Manrope', Arial, sans-serif; text-decoration: underline; text-underline-offset: 3px; }
.library-text-action:hover { color: #e3ff99; }
#library .empty { padding: 45px 20px; border: 1px dashed #4a5544; border-radius: 13px; background: #171c17; color: #bdc8b4; font-size: 14px; }
.library-photo-dialog { width: min(94vw, 860px); max-height: 92vh; padding: 21px; border: 1px solid #526147; border-radius: 16px; background: #171b1a; color: #f5f5f1; box-shadow: 0 28px 90px #000b; }
.library-photo-dialog::backdrop { background: #050706dc; backdrop-filter: blur(6px); }
.library-photo-dialog-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 15px; }
.library-photo-dialog-header span { color: #cbfb48; font: 600 10px 'DM Mono', monospace; letter-spacing: .1em; }
.library-photo-dialog-header h2 { margin: 7px 0 0; font: 750 clamp(19px,3vw,27px)/1.2 'Manrope',Arial,sans-serif; overflow-wrap: anywhere; }
.library-photo-dialog-header button { width: 40px; height: 40px; flex: 0 0 40px; border: 1px solid #596257; border-radius: 9px; background: #292e29; color: #f7f8f2; font-size: 26px; line-height: 1; }
.library-photo-dialog-header button:hover { background: #3b4534; }
#library-photo-status { min-height: 22px; margin: 13px 0; color: #c4cfc0; font-size: 14px; }
#library-photo-full { display: block; max-width: 100%; max-height: min(67vh,750px); margin: 0 auto 19px; border-radius: 9px; object-fit: contain; }
#library-photo-full[hidden] { display: none; }
.library-photo-dialog .btn { min-height: 48px; padding: 12px 18px; font-size: 14px; }
.library-photo-dialog .btn:disabled { opacity: .5; cursor: not-allowed; }
.rename-identity-dialog { width: min(440px, calc(100% - 32px)); max-height: calc(100dvh - 32px); padding: clamp(20px, 4vw, 30px); border: 1px solid #4c5845; border-radius: 16px; background: #191c1c; color: #f5f6f2; box-shadow: 0 24px 80px #000b; }
.rename-identity-dialog::backdrop { background: #060708d9; backdrop-filter: blur(5px); }
.rename-identity-dialog h2 { margin: 0 0 20px; font-size: 24px; }
.rename-identity-dialog .field { margin: 0; }
.rename-identity-status { min-height: 1.5em; margin: 8px 0 12px; color: #d3ddd0; font-size: 14px; }
.rename-identity-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 9px; }
@media (max-width: 650px) {
  .library-album-grid { grid-template-columns: repeat(2,minmax(0,1fr)); gap: 9px; }
  .library-album-caption { padding: 11px; }
  .library-gallery-grid { grid-template-columns: repeat(3,minmax(0,1fr)); gap: 4px; }
  .library-gallery-photo { border-radius: 3px; }
  .library-gallery-photo.is-selecting::after { width: 19px; height: 19px; top: 4px; right: 4px; font-size: 14px; }
  .library-gallery-date { bottom: 3px; left: 3px; padding: 3px 4px; font-size: 9px; }
  .library-tabs { width: 100%; gap: 2px; padding: 4px; }
  .library-tabs button { flex: 1; gap: 5px; padding: 9px 6px; font-size: 12px; }
  .library-tab-count { min-width: 22px; height: 21px; font-size: 11px; }
  .library-section-heading { align-items: stretch; flex-direction: column; gap: 15px; }
  .library-section-heading .btn { align-self: flex-start; }
  #library .model { align-items: stretch; padding: 17px; }
  #library .model .buttons { display: flex; flex-wrap: wrap; width: 100%; }
  #library .model .buttons .btn { flex: 1; }
  .library-portrait-summary { align-items: flex-start; flex-direction: column; padding: 14px 17px; }
}

.result-zoom-trigger { display: block; position: relative; width: min(100%,640px); padding: 0; border: 0; border-radius: 12px; background: transparent; color: white; cursor: zoom-in; }
.result-zoom-trigger span { position: absolute; bottom: 9px; right: 9px; padding: 5px 10px; border: 1px solid #ffffff5c; border-radius: 6px; background: #111516de; color: #fff; font-family: inherit; font-size: 13px; font-weight: 650; line-height: 1.25; }
.result-zoom-trigger:hover span,.result-zoom-trigger:focus-visible span { background: #cbfb48; color: #18210c; }
.photo-dialog-controls { display: flex; gap: 8px; align-items: center; }
.library-photo-dialog[open] { display: flex; flex-direction: column; box-sizing: border-box; width: 100%; max-width: none; height: 100vh; height: 100dvh; max-height: none; margin: 0; padding: max(12px,env(safe-area-inset-top)) max(14px,env(safe-area-inset-right)) max(12px,env(safe-area-inset-bottom)) max(14px,env(safe-area-inset-left)); border: 0; border-radius: 0; overflow: hidden; background: #0c0e10; }
.library-photo-dialog .library-photo-dialog-header { align-items: center; min-height: 44px; margin-bottom: 10px; }
.library-photo-dialog .library-photo-dialog-header span { display: none; }
.library-photo-dialog .library-photo-dialog-header h2 { margin: 0; font-size: clamp(17px,3vw,24px); }
.library-photo-dialog .library-photo-dialog-header button { min-height: 44px; min-width: 44px; }
#photo-detail-zoom { width: auto; flex: none; padding: 0 14px; font: 650 15px/1.2 'Manrope',Arial,sans-serif; }
.library-photo-dialog #library-photo-status:empty { display: none; }
.library-photo-dialog #library-photo-stage { position: relative; display: flex; overflow: auto; flex: 1; min-height: 0; min-width: 0; overscroll-behavior: contain; }
.library-photo-dialog #library-photo-full { display: block; flex: none; margin: auto; max-width: 100%; max-height: 100%; width: auto; height: auto; object-fit: contain; border-radius: 3px; cursor: zoom-in; user-select: none; -webkit-user-drag: none; }
.library-photo-dialog #library-photo-full[hidden] { display:none; }
.library-photo-dialog #library-photo-stage[data-zoom] #library-photo-full { max-width: none; max-height: none; cursor: grab; }
.library-photo-dialog #library-photo-stage[data-dragging] #library-photo-full { cursor: grabbing; }
html:has(.library-photo-dialog[open]) { overflow: hidden; }

.library-viewer-footer {
  display: grid;
  justify-items: center;
  gap: 8px;
  max-height: 40dvh;
  overflow: auto;
  padding-top: 8px;
}
.library-viewer-navigation, .library-viewer-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 7px;
}
.library-viewer-navigation[hidden], .library-viewer-actions [hidden] { display: none; }
.library-viewer-navigation .btn { min-width: 44px; min-height: 44px; padding: 3px 12px; font-size: 23px; line-height: 1; }
#library-photo-position { min-width: 72px; text-align: center; color: #d3ddcd; font-variant-numeric: tabular-nums; }
.library-viewer-actions .btn { min-height: 44px; padding: 8px 12px; }
.library-viewer-feedback { margin: 0; color: #c4cfc0; }
.library-viewer-feedback:empty { display: none; }

@media (min-height:520px) {
  .library-gallery-tools:has(#library-gallery-select[aria-pressed="true"]) {position:sticky; top:0; z-index:4; padding:8px; background:#121516; border:1px solid #41483d; border-radius:9px}
}
@media (max-width:360px) {
  .library-tabs {display:grid; grid-template-columns:repeat(3,minmax(0,1fr))}
  .library-tabs button {min-width:0; flex-direction:column; padding:6px 3px}
}
