:root{
  --bg: #f5f6f7;
  --text: #111217;
  --topbar-bg: #ffffff;
  --topbar-height: 56px;
  --safe-top: env(safe-area-inset-top, 0px);
  --input-bg: #ffffff;
  --card-bg: #ffffff;
  --muted: #666;
}

.dark{
  --bg: #0b0b0d;
  --text: #e8e8e8;
  --topbar-bg: #0f1113;
  --input-bg: #0b0d0f;
  --card-bg: #0b0d0f;
  --muted: #a8a8a8;
}

body {
  margin: 0;
  font-family: sans-serif;
  background: var(--bg);
  color: var(--text);
  padding-top: calc(var(--topbar-height) + var(--safe-top));
}

/* 顶栏 */
.topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  background: var(--topbar-bg);
  padding-top: var(--safe-top);
  padding: 6px 10px;
  display: flex;
  justify-content: flex-start;
  align-items: center;
  box-shadow: 0 1px 6px rgba(0,0,0,0.05);
  gap: 8px;
  z-index: 1000;
  height: var(--topbar-height);
  box-sizing: border-box;
  width: 100%;
}

.topbar h1 {
  margin: 0;
  color: var(--text);
  font-size: 15px; /* de-emphasized base text */
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

/* The clickable brand link: larger and touch-friendly */
#brand {
  display: inline-block;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
  padding: 0;
  border-radius: 8px;
}

.brand-blue {
  color: #1e90ff; /* DodgerBlue */
  font-size: 26px; /* make 阿喵喵 visually prominent */
  font-weight: 700;
  line-height: 1;
}

#brand:focus{ outline: 3px solid rgba(30,144,255,0.18); outline-offset: 2px; }
#brand:hover .brand-blue{ text-decoration: underline; }

.topbar h1 a:hover{ text-decoration: underline; }

.center-block{
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 8px;
  align-items: center;
}

.center-search { }

.controls-right{
  display: flex;
  gap: 8px;
  align-items: center;
}

input, select {
  padding: 6px 8px;
  border-radius: 6px;
  border: 1px solid rgba(0,0,0,0.12);
  background: var(--input-bg);
  color: var(--text);
  font-size: 13px;
}

/* narrow search input to fit one line */
input#search{ min-width:160px; max-width:260px; width:22vw; }
select#pageSize{ min-width:84px; }

/* inline dark toggle (not fixed) */
.dark-toggle{
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid rgba(0,0,0,0.12);
  background: var(--topbar-bg);
  color: var(--text);
  cursor: pointer;
  font-size: 14px;
}

.dark-toggle:focus{outline: none; box-shadow: 0 0 0 3px rgba(0,0,0,0.06);} 

/* 注意事项按钮 */
.note-btn{
  padding: 6px 8px;
  border-radius: 6px;
  border: 1px solid rgba(0,0,0,0.12);
  background: var(--topbar-bg);
  color: var(--text);
  cursor: pointer;
  font-size: 14px;
}

/* 弹窗 */
.modal{
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  justify-content: center;
  align-items: center;
  z-index: 20000;
}

.modal[aria-hidden="false"]{ display: flex; }

.modal-content{
  background: var(--topbar-bg);
  color: var(--text);
  padding: 18px;
  border-radius: 10px;
  max-width: 520px;
  width: 92%;
  box-shadow: 0 8px 30px rgba(0,0,0,0.2);
  position: relative;
}

.modal-close{
  position: absolute;
  top: 8px;
  right: 8px;
  border: none;
  background: transparent;
  font-size: 16px;
  cursor: pointer;
  color: var(--muted);
}

.modal-content h3{ margin-top: 0; }

/* 瀑布流 */
#gallery{
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: 6px;
  padding: 8px;
}

@media (max-width: 1400px) { #gallery { grid-template-columns: repeat(8, 1fr); } }
@media (max-width: 1200px) { #gallery { grid-template-columns: repeat(6, 1fr); } }
@media (max-width: 900px) { #gallery { grid-template-columns: repeat(4, 1fr); } }

}

.item {
  position: relative;
  margin: 0;
  /* 固定每个缩略图占位比例，保证每格相同大小 */
  aspect-ratio: 1/1;
  overflow: hidden;
  background: var(--card-bg);
  border-radius: 6px;
}

.item img {
  width: 100%;
  height: 100%;
  object-fit: contain; /* 保持比例并完整显示图片 */
  object-position: center center;
  display: block;
  cursor: pointer;
  transition: transform 0.12s ease;
}

.item:hover img{ transform: scale(1.03); }
/* actions removed */

/* GIF badge in bottom-left of thumbnail */
.gif-badge { display: none !important; }

/* 预览 */
#viewer {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.8);
  justify-content: center;
  align-items: center;
  z-index: 30000; /* keep viewer above badges and other UI */
}

#viewer img {
  max-width: 90%;
  max-height: 90%;
  border-radius: 10px;
  transition: transform 0.12s ease;
  transform-origin: center center;
  cursor: zoom-out;
}

/* viewer controls (copy/download) */
.viewer-controls{
  position: fixed;
  top: 14px;
  right: 18px;
  display: flex;
  gap: 8px;
  z-index: 40000;
}
.viewer-controls button{
  padding: 8px 10px;
  border-radius: 8px;
  border: none;
  font-size: 14px;
  cursor: pointer;
}
.viewer-controls .vc-copy{ background: rgba(255,255,255,0.08); color: #fff; }
.viewer-controls .vc-download{ background: #fff; color: #111; border: 1px solid rgba(0,0,0,0.08); }

/* When viewer is open, de-emphasize GIF badges so they look attached but subdued */
.viewer-open .gif-badge { display: none !important; }
/* inline pagination inside header controls-right */
.inline-pagination{
  display: flex;
  gap: 8px;
  align-items: center;
}

.inline-pagination button{
  padding: 6px 10px;
  border-radius: 6px;
  border: 1px solid rgba(0,0,0,0.12);
  background: var(--card-bg);
  color: var(--text);
  cursor: pointer;
}
.inline-pagination button:disabled{opacity:0.45; cursor:default}

.inline-pagination span{color:var(--muted)}

/* Toast notification used for copy feedback */
.toast{
  position: fixed;
  top: calc(var(--topbar-height) + 10px);
  left: 50%;
  transform: translateX(-50%) translateY(-6px);
  background: rgba(0,0,0,0.78);
  color: #fff;
  padding: 8px 12px;
  border-radius: 10px;
  z-index: 60000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 160ms ease, transform 160ms ease;
  font-size: 14px;
}
.toast.show{ opacity: 1; transform: translateX(-50%) translateY(0); }