:root {
  color-scheme: light;
  font: 12px/1.5 "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  color: #171715; background: #fff; --muted: #60605d; --rule: #dededb;
}
* { box-sizing: border-box; }
body { margin: 0 auto; width: min(100%, 1700px); padding: 0 clamp(20px, 4vw, 70px) 48px; }
h1, h2, p { margin: 0; }
h1 { font-size: 15px; font-weight: 600; letter-spacing: -.035em; }
h2 { font-size: 13px; font-weight: 500; }
button, a, input { font: inherit; color: inherit; }
a { text-underline-offset: 3px; }
button { cursor: pointer; background: white; border: 0; padding: 0; }
button:disabled { cursor: default; opacity: .35; }
:focus-visible { outline: 2px solid #222; outline-offset: 4px; }
[hidden] { display: none !important; }
.masthead, .reader-bar, .reader-foot { display: flex; align-items: center; justify-content: space-between; gap: 15px; }
.masthead { min-height: 94px; border-bottom: 1px solid var(--rule); }
.masthead > a { padding: 12px 0; font-size: 11px; }
#status:not(:empty), #access:not(:empty) { margin-bottom: 20px; }
.collection { padding-top: clamp(20px, 4vw, 70px); }
.sound-toggle { font-size: 11px; color: var(--muted); padding: 6px 0; }
.sound-toggle:hover { text-decoration: underline; text-underline-offset: 3px; }
.collection > .sound-toggle { display: block; margin: 0 0 10px auto; }
.reader-tools { display: flex; align-items: center; gap: 16px; }
#sound-name { overflow-wrap: anywhere; margin-bottom: 12px; }
#sound-preview { display: block; max-width: 100%; margin-bottom: 16px; }
.gallery { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 35px clamp(16px, 2.3vw, 38px); }
.gallery.album-index {
  width: 100%;
  max-width: 1200px;
  margin-inline: auto;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 32px clamp(16px, 2vw, 28px);
}
.album { display: block; min-width: 0; text-decoration: none; }
.album-media {
  display: grid;
  grid-template: minmax(0, 1fr) / minmax(0, 1fr);
  place-items: center;
  container-type: size;
  width: 100%;
  aspect-ratio: 4 / 5;
  background: #f7f7f5;
}
.album-bar { display: flex; align-items: baseline; justify-content: space-between; gap: 18px; margin-bottom: 18px; font-size: 11px; }
#back-to-albums { margin-right: 18px; }
.gallery { align-items: start; }
.photo { display: block; width: 100%; }
.picture { display: block; position: relative; width: 100%; aspect-ratio: var(--ratio, 1); }
.picture img { position: absolute; left: 50%; top: 50%; width: 100%; height: auto; max-width: none; display: block; }
.album-media .picture {
  width: min(88cqw, calc(92cqh * var(--ratio, 1)));
}
.album-media video {
  display: block;
  width: 88cqw;
  height: 92cqh;
  object-fit: contain;
  pointer-events: none;
}
.sheet { display: grid; place-items: center; container-type: size; }
.sheet .picture { width: min(100cqw, calc(100cqh * var(--ratio, 1))); }
.sheet > video { display: block; max-width: 100cqw; max-height: 100cqh; }
.photo > video { display: block; width: 100%; height: auto; pointer-events: none; }
.source { display: block; padding-top: 9px; font-size: 11px; line-height: 1.45; overflow-wrap: anywhere; }
.album:hover .source { text-decoration: underline; text-underline-offset: 3px; }
.album:focus-visible .source { text-decoration: underline; }
@media (max-width: 1100px) {
  .gallery.album-index { max-width: 840px; grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
  .gallery.album-index { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 540px) {
  .gallery.album-index { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 22px 14px; }
}
#position, .hint { color: var(--muted); font-size: 11px; }
#album-source { font-size: 11px; overflow-wrap: anywhere; }
dialog {
  position: fixed; inset: 0; margin: 0; border: 0; color: inherit; background: #fff;
  width: 100%; max-width: none; height: 100%; height: 100dvh; max-height: none; padding: 0 clamp(20px, 4vw, 70px);
}
dialog[open] { display: grid; grid-template-rows: auto minmax(0,1fr) auto; }
body:has(dialog[open]) { overflow: hidden; }
dialog::backdrop { background: white; }
.reader-bar { min-height: 58px; border-bottom: 1px solid var(--rule); }
.reader-bar button { padding: 10px 0; }
.sheet { min-height: 0; padding: clamp(16px, 3.5vh, 40px) 0; }
.reader-foot { padding: 15px 0; border-top: 1px solid var(--rule); }
.paging { display: flex; gap: 6px; }
.paging button { border: 1px solid var(--rule); width: 40px; height: 40px; font-size: 17px; }
.paging button:hover:enabled { background: #f5f5f4; }
fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
label { display: block; margin-bottom: 7px; }
input[type=text] { width: 100%; padding: 9px; border: 1px solid #aaa; border-radius: 0; margin-bottom: 20px; }
input[type=file] { width: 100%; font-size: 11px; }
input::file-selector-button { font: inherit; padding: 7px 10px; background: white; border: 1px solid #aaa; margin-right: 10px; cursor: pointer; }
.hint { margin-top: 8px; }
.submit { background: #171715; color: white; padding: 9px 14px; margin-top: 24px; }
#result:not(:empty) { margin-top: 16px; }
@media(max-width: 850px) { .gallery { grid-template-columns: repeat(2,minmax(0,1fr)); } }
@media(max-width: 540px) {
  .gallery { grid-template-columns: minmax(0,1fr); gap: 28px; }
  .masthead { min-height: 78px; }
}

.card-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px clamp(10px, 1.7vw, 28px); }
@media (max-width: 1050px) { .card-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
@media (max-width: 760px) { .card-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 490px) { .card-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }


.admin-page { max-width: 1440px; }
.admin-workspace { margin: 28px 0 48px; }
.admin-workspace #back { display: inline-block; margin-bottom: 15px; font-size: 11px; }
.admin-toolbar, .admin-heading { display: flex; align-items: baseline; gap: 12px; }
.admin-toolbar { align-items: center; justify-content: space-between; margin-bottom: 20px; }
.admin-heading { min-width: 0; flex-wrap: wrap; gap: 4px 10px; }
.admin-heading h2 { font-size: 15px; font-weight: 500; overflow-wrap: anywhere; }
.admin-heading #count, .admin-count { font-size: 11px; color: var(--muted); }
.admin-command { flex: none; border: 1px solid var(--rule); padding: 8px 12px; text-decoration: none; }
.admin-command:hover { border-color: currentColor; }
.admin-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.admin-toolbar { flex-wrap: wrap; }
.admin-command[aria-pressed=true] { border-color: currentColor; }
#order-hint { color: var(--muted); font-size: 11px; margin: 0 0 16px; }
.album-name { display: flex; align-items: center; gap: 7px; margin-top: 8px; }
.album-name input { min-width: 0; margin: 0; padding: 6px; }
.album-name button { font-size: 11px; padding: 5px 0; }
[data-order-id], .movable { position: relative; }
.movable, .grip { cursor: grab; user-select: none; -webkit-user-select: none; }
.grip {
  position: absolute; top: 5px; left: 5px; width: 32px; height: 32px;
  display: grid; place-items: center; border: 1px solid var(--rule); touch-action: none;
}
.grip::after {
  content: ""; width: 10px; height: 15px;
  background: radial-gradient(circle, currentColor 1px, transparent 1.4px) 0 0 / 5px 5px;
}
.reordering, .reordering * { cursor: grabbing !important; user-select: none; }
.dragging .movable { opacity: .5; }
[data-drop]::after {
  content: ""; position: absolute; inset-block: 0; width: 2px;
  background: currentColor; pointer-events: none;
}
[data-drop=before]::after { left: -6px; }
[data-drop=after]::after { right: -6px; }
#album-picker { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(160px, 100%), 1fr)); gap: 25px 20px; }
#album-picker .album-media { aspect-ratio: 1; }
#album-picker .admin-poster { width: 100%; height: 92%; object-fit: contain; }
.admin-count { display: block; margin-top: 2px; }
#contents { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 30px clamp(14px, 2vw, 28px); }
.edit-photo { min-width: 0; }
.edit-preview {
  display: grid; place-items: center; container-type: size; width: 100%;
  aspect-ratio: 6 / 5; background: #f7f7f5;
}
.edit-preview .picture { width: min(94cqw, calc(94cqh * var(--ratio, 1))); }
.filename { margin-top: 8px; overflow-wrap: anywhere; }
.image-actions { display: flex; gap: 15px; flex-wrap: wrap; }
.image-actions button { padding: 7px 0; font-size: 11px; color: var(--muted); }
.image-actions button:last-child { margin-left: auto; }
.image-actions button:hover { color: inherit; text-decoration: underline; text-underline-offset: 3px; }
#create-form { max-width: 430px; }
#result:not(:empty) { margin: 0 0 16px; overflow-wrap: anywhere; }
@media (max-width: 960px) { #contents { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 580px) {
  #album-picker { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px 14px; }
  #contents { grid-template-columns: minmax(0, 1fr); }
  #contents [data-drop]::after { inset-inline: 0; width: auto; height: 2px; }
  #contents [data-drop=before]::after { inset-block: -8px auto; }
  #contents [data-drop=after]::after { inset-block: auto -8px; }
}
