/* ==========================================================================
   班级相册 · 编辑排版（Editorial / Archive）风格
   纸白底 + 墨黑字 + 朱砂强调；衬线标题、等宽数字标签、错落瀑布流。
   全部字体使用系统内已有字形，零外部字体请求（国内网络更稳）。
   ========================================================================== */

:root {
  --paper: #f6f3ec;
  --paper-2: #efeae0;
  --paper-3: #e7e0d3;
  --ink: #16150f;
  --ink-2: #2c2a22;
  --ink-soft: #5c5a50;
  --ink-faint: #8d8a7d;
  --rule: #dcd6c8;
  --rule-2: #c9c1ad;
  --accent: #b33a25;
  --accent-deep: #8e2c1b;
  --accent-wash: rgba(179, 58, 37, 0.09);

  --serif: "Songti SC", "STSong", "Noto Serif CJK SC", "Source Han Serif SC", "SimSun", "宋体", serif;
  --sans: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "微软雅黑", "Segoe UI", sans-serif;
  --mono: "Cascadia Mono", "Consolas", "SFMono-Regular", "Menlo", "Courier New", monospace;

  --shadow-lift: 0 1px 2px rgba(22, 21, 15, .06), 0 12px 28px -18px rgba(22, 21, 15, .35);
  --shadow-deep: 0 24px 70px -20px rgba(10, 9, 6, .55);
  --ease: cubic-bezier(.22, .8, .28, 1);
}

* { box-sizing: border-box; }

/* 必须放在所有组件样式之前并提高优先级：
   .lightbox / .notice / .spinner 等都显式声明了 display，
   会盖过浏览器默认的 [hidden] { display: none }，导致「隐藏」元素仍然可见。 */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body {
  min-height: 100vh;
  background-image:
    radial-gradient(120% 70% at 82% -10%, #fffdf8 0%, rgba(255, 253, 248, 0) 60%),
    linear-gradient(180deg, var(--paper) 0%, var(--paper-2) 100%);
  background-attachment: fixed;
}

/* 极细纸纹，让纯色底有质感 */
.grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 90;
  opacity: .35;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)' opacity='0.28'/%3E%3C/svg%3E");
}

.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

.ico,
.empty__ico,
.drop__ico {
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.ico {
  width: 1.05em;
  height: 1.05em;
}

/* --------------------------------- 通用件 -------------------------------- */

.kicker {
  margin: 0 0 10px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: .22em;
  text-transform: uppercase;
  color: var(--accent);
}

/* 管理员身份标识：只在用管理口令进入时出现 */
.rolechip {
  display: inline-block;
  margin-left: 10px;
  padding: 2px 8px;
  border: 1px solid var(--accent);
  border-radius: 999px;
  font-size: 11px;
  letter-spacing: .08em;
  text-transform: none;
  vertical-align: 1px;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 11px 18px;
  border: 1px solid var(--ink);
  border-radius: 2px;
  background: transparent;
  color: var(--ink);
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: .02em;
  cursor: pointer;
  transition: background .18s var(--ease), color .18s var(--ease),
              border-color .18s var(--ease), transform .18s var(--ease);
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn[disabled] { opacity: .45; cursor: not-allowed; transform: none; }

.btn--primary { background: var(--accent); border-color: var(--accent); color: #fff8f4; }
.btn--primary:hover { background: var(--accent-deep); border-color: var(--accent-deep); }

.btn--solid { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.btn--solid:hover { background: var(--ink-2); }

.btn--ghost { border-color: var(--rule-2); color: var(--ink-soft); }
.btn--ghost:hover { border-color: var(--ink); color: var(--ink); background: #fff; }

.btn--danger { border-color: var(--accent); color: var(--accent); }
.btn--danger:hover { background: var(--accent); color: #fff; }

.iconbtn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px; height: 34px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 2px;
  background: transparent;
  color: inherit;
  font-size: 17px;
  cursor: pointer;
  transition: background .16s var(--ease), border-color .16s var(--ease);
}
.iconbtn:hover { background: rgba(255, 255, 255, .12); border-color: rgba(255, 255, 255, .28); }

.field { display: block; margin-bottom: 18px; }
.field__label {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 7px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-2);
}
.field__label i { font-style: normal; font-weight: 400; color: var(--ink-faint); font-size: 12px; }

.field input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--rule-2);
  border-radius: 2px;
  background: #fffdf9;
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  transition: border-color .16s var(--ease), box-shadow .16s var(--ease);
}
.field input::placeholder { color: var(--ink-faint); }
.field input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-wash);
}

.form-error {
  min-height: 20px;
  margin: 12px 0 0;
  font-size: 13px;
  color: var(--accent-deep);
}

/* --------------------------------- 口令门 -------------------------------- */

.gate {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 128px;
  gap: 0;
  align-items: center;
  min-height: 100vh;
  padding: 8vh 6vw 8vh 8vw;
}

.gate__inner { max-width: 520px; }

.gate__title {
  margin: 0 0 22px;
  font-family: var(--serif);
  font-size: clamp(56px, 11vw, 104px);
  font-weight: 700;
  line-height: .92;
  letter-spacing: -.02em;
}

.gate__desc {
  max-width: 42ch;
  margin: 0 0 38px;
  padding-left: 16px;
  border-left: 2px solid var(--rule-2);
  font-size: 15px;
  line-height: 1.85;
  color: var(--ink-soft);
}

.gate__form { max-width: 400px; }

.gate__side {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 14px;
  height: 62vh;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: .26em;
  color: var(--ink-faint);
  writing-mode: vertical-rl;
}
.gate__index { color: var(--accent); letter-spacing: .3em; }
.gate__rule { flex: 1; width: 1px; background: linear-gradient(180deg, var(--rule-2), transparent); }
.gate__note { text-align: right; line-height: 2.1; }

/* -------------------------------- 相册主体 ------------------------------- */

.app { padding: 0 0 96px; }

.masthead {
  display: flex;
  flex-wrap: wrap;
  gap: 28px;
  align-items: flex-end;
  justify-content: space-between;
  padding: 56px 6vw 26px 8vw;
  border-bottom: 2px solid var(--ink);
}

.masthead__title {
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(42px, 7vw, 76px);
  font-weight: 700;
  line-height: .95;
  letter-spacing: -.02em;
}

.masthead__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 22px;
  margin: 18px 0 0;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--ink-soft);
}
.stat { display: inline-flex; align-items: baseline; gap: 6px; }
.stat b { font-size: 20px; color: var(--ink); font-weight: 700; }
.stat i { font-style: normal; letter-spacing: .08em; }
.masthead__hint { color: var(--ink-faint); letter-spacing: .04em; }

.masthead__actions { display: flex; gap: 10px; padding-bottom: 6px; }

.notice {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 22px 6vw 0 8vw;
  padding: 13px 16px;
  border: 1px solid var(--rule-2);
  border-left: 3px solid var(--accent);
  background: #fffdf9;
  font-size: 13.5px;
  line-height: 1.7;
  color: var(--ink-soft);
}
.notice p { margin: 0; flex: 1; }
.notice__close { border: none; background: none; color: var(--ink-faint); cursor: pointer; padding: 0; font-size: 15px; }
.notice__close:hover { color: var(--ink); }
.notice .ico { margin-top: 2px; color: var(--accent); }

.stage { padding: 30px 6vw 0 8vw; }

/* 错落瀑布流：保持图片原始比例，不做等高裁切 */
.grid { column-count: 4; column-gap: 16px; }
@media (max-width: 1180px) { .grid { column-count: 3; } }
@media (max-width: 760px)  { .grid { column-count: 2; column-gap: 10px; } }
@media (max-width: 420px)  { .grid { column-count: 2; column-gap: 8px; } }

.tile {
  break-inside: avoid;
  margin: 0 0 16px;
  animation: rise .5s var(--ease) both;
}
@media (max-width: 760px) { .tile { margin-bottom: 10px; } }

.tile__btn {
  display: block;
  width: 100%;
  padding: 0;
  border: none;
  background: none;
  cursor: zoom-in;
  text-align: left;
}

.tile__frame {
  position: relative;
  display: block;
  overflow: hidden;
  background: var(--paper-3);
  border: 1px solid var(--rule);
}
.tile__btn:hover .tile__frame { border-color: var(--ink); }

.tile__img {
  display: block;
  width: 100%;
  height: auto;
  opacity: 0;
  transform: scale(1.015);
  transition: opacity .5s var(--ease), transform .5s var(--ease);
}
.tile__img.is-loaded { opacity: 1; transform: scale(1); }
.tile__btn:hover .tile__img.is-loaded { transform: scale(1.035); }

.tile__skel {
  position: absolute;
  inset: 0;
  background: linear-gradient(100deg, var(--paper-3) 30%, #f3eee4 50%, var(--paper-3) 70%);
  background-size: 220% 100%;
  animation: shimmer 1.3s linear infinite;
}
.tile__img.is-loaded + .tile__skel { display: none; }

.tile__zoom {
  position: absolute;
  right: 8px; bottom: 8px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 9px;
  background: rgba(22, 21, 15, .82);
  color: var(--paper);
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: .1em;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity .2s var(--ease), transform .2s var(--ease);
}
.tile__btn:hover .tile__zoom { opacity: 1; transform: translateY(0); }

.tile__cap {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 7px 2px 0;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--ink-faint);
}
.tile__who { color: var(--ink-2); font-weight: 700; }
.tile__note {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: var(--sans);
  color: var(--ink-soft);
}

.empty {
  max-width: 460px;
  margin: 12vh auto 0;
  padding: 0 4vw;
  text-align: left;
}
.empty__ico { width: 44px; height: 44px; color: var(--ink-soft); stroke-width: 1.4; }
.empty__title { margin: 16px 0 10px; font-family: var(--serif); font-size: 30px; }
.empty__desc { margin: 0 0 26px; font-size: 14.5px; line-height: 1.8; color: var(--ink-soft); }

.stage__foot { display: flex; justify-content: center; padding: 26px 0 0; }

.fab {
  position: fixed;
  right: 22px; bottom: 22px;
  display: none;
  align-items: center;
  justify-content: center;
  width: 54px; height: 54px;
  border: none;
  border-radius: 2px;
  background: var(--accent);
  color: #fff8f4;
  font-size: 24px;
  box-shadow: var(--shadow-lift);
  cursor: pointer;
  z-index: 40;
}
/* 移动端：上传让位给右下角悬浮按钮，但「退出」必须保留（否则手机上无法清除本机口令） */
@media (max-width: 760px) {
  .fab { display: inline-flex; }
  .masthead__actions #upload-open { display: none; }
  .masthead__actions .btn { padding: 9px 12px; font-size: 13px; }
}

/* --------------------------------- 灯箱 --------------------------------- */

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  flex-direction: column;
  background: #100f0b;
  color: var(--paper);
  animation: fade .22s var(--ease) both;
}

.lightbox__bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 18px;
  border-bottom: 1px solid rgba(246, 243, 236, .14);
}
.lightbox__id { display: flex; align-items: baseline; gap: 12px; min-width: 0; }
.lightbox__index { font-family: var(--mono); font-size: 11px; letter-spacing: .18em; color: var(--accent); }
.lightbox__name {
  font-size: 13px;
  color: rgba(246, 243, 236, .78);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.lightbox__tools { display: flex; align-items: center; gap: 10px; }

.quality {
  padding: 4px 9px;
  border: 1px solid rgba(246, 243, 236, .26);
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: .12em;
  color: rgba(246, 243, 236, .7);
}
.quality[data-state="loading"] { border-color: var(--accent); color: #f0b6a6; }
.quality[data-state="original"] { border-color: #7fa06a; color: #b6d4a4; }

.lightbox__canvas {
  position: relative;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
  padding: 18px;
  overflow: hidden;
}
.lightbox__img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  box-shadow: var(--shadow-deep);
  transition: filter .35s var(--ease);
}
/* 低画质预览放大后会有轻微模糊感，这是预期效果 */
.lightbox__img[data-state="preview"] { filter: saturate(1.02); }

.arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px; height: 44px;
  border: 1px solid rgba(246, 243, 236, .22);
  background: rgba(16, 15, 11, .5);
  color: var(--paper);
  font-size: 20px;
  cursor: pointer;
  transition: background .16s var(--ease), border-color .16s var(--ease);
}
.arrow:hover { background: rgba(246, 243, 236, .14); border-color: var(--paper); }
.arrow--prev { left: 16px; }
.arrow--next { right: 16px; }
.arrow[disabled] { opacity: .28; cursor: default; }

.lightbox__foot {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px calc(16px + env(safe-area-inset-bottom));
  border-top: 1px solid rgba(246, 243, 236, .14);
}
.lightbox__info { min-width: 0; }
.lightbox__by { margin: 0; font-size: 14px; font-weight: 600; }
.lightbox__note { margin: 4px 0 0; font-size: 13px; color: rgba(246, 243, 236, .62); }
.lightbox__acts { display: flex; gap: 10px; flex-wrap: wrap; }
.lightbox .btn--primary { background: var(--accent); border-color: var(--accent); }
.lightbox .btn--solid { background: var(--paper); border-color: var(--paper); color: var(--ink); }
.lightbox .btn--danger { border-color: rgba(240, 182, 166, .6); color: #f0b6a6; }
.lightbox .btn--danger:hover { background: var(--accent); border-color: var(--accent); color: #fff; }

.spinner {
  position: absolute;
  display: flex;
  gap: 6px;
}
.spinner span {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--paper);
  animation: bounce 1s infinite ease-in-out;
}
.spinner span:nth-child(2) { animation-delay: .15s; }
.spinner span:nth-child(3) { animation-delay: .3s; }

/* -------------------------------- 上传面板 ------------------------------- */

.sheet { position: fixed; inset: 0; z-index: 70; }
.sheet__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(16, 15, 11, .42);
  animation: fade .2s var(--ease) both;
}
.sheet__panel {
  position: absolute;
  top: 0; right: 0; bottom: 0;
  width: min(440px, 100%);
  display: flex;
  flex-direction: column;
  background: var(--paper);
  border-left: 2px solid var(--ink);
  animation: slide .28s var(--ease) both;
}
@media (max-width: 640px) {
  .sheet__panel {
    top: auto; left: 0; right: 0; bottom: 0;
    width: 100%;
    max-height: 88vh;
    border-left: none;
    border-top: 2px solid var(--ink);
    animation: sheetup .28s var(--ease) both;
  }
}
.sheet__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px;
  border-bottom: 1px solid var(--rule);
}
.sheet__title { margin: 0; font-family: var(--serif); font-size: 24px; }
.sheet__head .iconbtn { color: var(--ink-soft); }
.sheet__head .iconbtn:hover { background: var(--paper-3); border-color: transparent; color: var(--ink); }
.sheet__body { flex: 1; overflow-y: auto; padding: 20px; }

.drop {
  display: block;
  padding: 30px 18px;
  border: 1px dashed var(--rule-2);
  background: #fffdf9;
  text-align: center;
  cursor: pointer;
  transition: border-color .18s var(--ease), background .18s var(--ease);
}
.drop:hover, .drop.is-over { border-color: var(--accent); background: var(--accent-wash); }
.drop__ico { width: 26px; height: 26px; color: var(--accent); }
.drop__title { margin: 12px 0 6px; font-size: 14.5px; font-weight: 600; }
.drop__hint { margin: 0; font-size: 12.5px; line-height: 1.7; color: var(--ink-faint); }

.queue { list-style: none; margin: 20px 0 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.qitem {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--rule);
  background: #fffdf9;
}
.qitem__thumb { width: 42px; height: 42px; object-fit: cover; background: var(--paper-3); }
.qitem__name {
  margin: 0;
  font-size: 13px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.qitem__bar { height: 3px; margin-top: 7px; background: var(--paper-3); overflow: hidden; }
.qitem__bar i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .25s var(--ease); }
.qitem__state { font-family: var(--mono); font-size: 11px; color: var(--ink-faint); white-space: nowrap; }
.qitem.is-done .qitem__bar i { background: #6d8a55; }
.qitem.is-error { border-color: var(--accent); }
.qitem.is-error .qitem__state { color: var(--accent-deep); }

/* --------------------------------- 提示条 -------------------------------- */

.toasts {
  position: fixed;
  left: 50%; bottom: 26px;
  transform: translateX(-50%);
  z-index: 95;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  pointer-events: none;
}
.toast {
  max-width: 84vw;
  padding: 11px 18px;
  background: var(--ink);
  color: var(--paper);
  font-size: 13.5px;
  box-shadow: var(--shadow-lift);
  animation: rise .26s var(--ease) both;
}
.toast--error { background: var(--accent-deep); }

/* -------------------------------- 动效 -------------------------------- */

@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes slide { from { transform: translateX(24px); opacity: .4; } to { transform: none; opacity: 1; } }
@keyframes sheetup { from { transform: translateY(28px); opacity: .5; } to { transform: none; opacity: 1; } }
@keyframes shimmer { from { background-position: 120% 0; } to { background-position: -120% 0; } }
@keyframes bounce {
  0%, 80%, 100% { transform: scale(.5); opacity: .45; }
  40% { transform: scale(1); opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}
