/* General reset */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: system-ui, -apple-system, "PingFang SC", "Microsoft Yahei", sans-serif;
  color: #fff;
  background: #020826 url("../assets/bg-main.png") no-repeat center top;
  background-size: cover;
  overflow: hidden;
}

/* Sidebar */
.sidebar {
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  width: 180px;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-top: 40px;
  z-index: 10;
}

.sidebar-title {
  font-size: 20px;
  letter-spacing: 2px;
  margin-bottom: 40px;
  text-shadow: 0 0 8px rgba(0, 0, 0, 0.6);
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.nav-item {
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
}

.nav-icon-wrap {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 74px;
  height: 74px;
  border-radius: 999px;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.nav-icon-wrap img {
  display: block;
  max-width: 100%;
  max-height: 100%;
}

.nav-item .nav-icon-wrap {
  transform: scale(0.9);
}

.nav-item.active .nav-icon-wrap {
  transform: scale(1.08);
  box-shadow: 0 0 12px rgba(255, 230, 180, 0.45);
}

.nav-item:hover .nav-icon-wrap {
  transform: scale(1.02);
}

/* Main scrollable area */
.main-scroll {
  position: absolute;
  left: 180px;
  top: 0;
  right: 0;
  bottom: 0;
  overflow-y: auto;
  padding: 24px 40px 40px;
  z-index: 5;
}

/* Content wrapper used on multiple pages */
.content-area {
  max-width: 1032px;
  margin: 0 auto;
}

/* Hero section */
.hero {
  margin-bottom: 32px;
}

.hero-inner {
  position: relative;
  width: 100%;
  padding-top: 31%;
  border-radius: 26px;
  overflow: hidden;
}

.hero-bg {
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 30% 20%, #4f46e5, #15163b 55%, #020617);
  background-size: cover;
}

.hero-btn {
  position: absolute;
  left: 50%;
  top: 65%;
  transform: translate(-50%, -50%);
  padding: 14px 40px;
  border-radius: 999px;
  border: none;
  font-size: 18px;
  letter-spacing: 1px;
  cursor: pointer;
  background: linear-gradient(90deg, #a855f7, #3b82f6);
  color: #fff;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.5);
  transition: transform 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease;
}

.hero-btn:hover {
  transform: translate(-50%, -52%);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.7);
  opacity: 0.95;
}

/* Gallery grid */
.gallery {
  padding-bottom: 40px;
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 24px;
}

.gallery-item {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: 20px;
  overflow: hidden;
  background: radial-gradient(circle at 10% 0%, #1f2937, #020617);
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.7);
  transition: transform 0.16s ease, box-shadow 0.16s ease, opacity 0.16s ease;
}

.gallery-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.gallery-item:hover {
  transform: translateY(-4px);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.75);
  opacity: 0.96;
}

/* Upload modal backdrop */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(3, 7, 18, 0.75);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 50;
}

.modal-backdrop.show {
  display: flex;
}

/* Upload modal */
.modal {
  width: 540px;
  max-width: calc(100% - 40px);
  background: linear-gradient(145deg, #020617, #020617d9);
  border-radius: 18px;
  padding: 24px 28px 20px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.9);
  border: 1px solid rgba(148, 163, 184, 0.3);
  display: flex;
  flex-direction: column;
}

.modal.small {
  width: 420px;
}

.modal-header {
  font-size: 18px;
  margin-bottom: 18px;
}

.modal-body {
  padding: 8px 0 16px;
}

.upload-list {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.upload-slot {
  width: 110px;
  height: 80px;
  border-radius: 12px;
  border: 1px dashed rgba(148, 163, 184, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: #94a3b8;
  font-size: 32px;
}

.upload-thumb {
  position: relative;
  width: 110px;
  height: 80px;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.7);
}

.upload-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.upload-remove {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 18px;
  height: 18px;
  border-radius: 999px;
  border: none;
  background: rgba(15, 23, 42, 0.86);
  color: #cbd5f5;
  font-size: 12px;
  cursor: pointer;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

.upload-error {
  flex: 1;
  color: #fda4af;
  font-size: 13px;
  min-height: 18px;
  align-self: center;
}

.login-form label {
  display: block;
  margin-bottom: 10px;
}

.login-form input {
  width: 100%;
  padding: 8px;
  border-radius: 8px;
  border: 1px solid rgba(148, 163, 184, 0.4);
  background: #0b1224;
  color: #e5e7eb;
}

.login-form .code-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.login-error {
  color: #fca5a5;
  min-height: 18px;
  font-size: 13px;
}

.modal.small .modal-body {
  padding: 8px 0 4px;
}

.invite-text {
  white-space: pre-wrap;
  margin-bottom: 10px;
  color: #e5e7eb;
}

.btn {
  min-width: 88px;
  height: 34px;
  border-radius: 999px;
  border: none;
  cursor: pointer;
  font-size: 14px;
}

.btn.plain {
  background: transparent;
  border: 1px solid rgba(148, 163, 184, 0.7);
  color: #e5e7eb;
}

.btn.primary {
  background: linear-gradient(90deg, #6366f1, #a855f7);
  color: #fff;
}

/* ============== Responsive tweaks ============== */
@media (max-width: 1024px) {
  .sidebar {
    width: 120px;
    padding-top: 24px;
  }
  .nav-icon-wrap {
    width: 60px;
    height: 60px;
  }
  .main-scroll {
    left: 120px;
    padding: 16px 20px 28px;
  }
  .gallery-grid {
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
  }
  .hero-btn {
    width: 70%;
    left: 50%;
    transform: translate(-50%, -50%);
  }
  .modal,
  .note-modal {
    width: 90vw;
    max-width: 600px;
    padding: 16px;
  }
  .modal-footer {
    flex-wrap: wrap;
    justify-content: center;
  }
  .modal-footer .btn {
    min-width: 120px;
  }
}

@media (max-width: 768px) {
  .sidebar {
    width: 72px;
    padding-top: 16px;
  }
  .sidebar-title {
    display: none;
  }
  .nav-icon-wrap {
    width: 52px;
    height: 52px;
  }
  .main-scroll {
    left: 72px;
    padding: 12px 14px 24px;
  }
  .content-area {
    margin: 0;
    width: 100%;
  }
  .hero-inner {
    padding-top: 45%;
  }
  .hero-btn {
    width: 80%;
    font-size: 16px;
    padding: 12px 0;
  }
  .gallery-grid {
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 12px;
  }
  .note-item {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }
  .note-paper-thumb {
    width: 100%;
    max-width: 260px;
    height: auto;
    aspect-ratio: 16 / 9;
  }
  .note-outer-text {
    width: 100%;
  }
  .note-modal,
  .modal {
    width: 92vw;
    padding: 14px;
  }
  .modal-footer {
    flex-direction: column;
    align-items: stretch;
  }
  .modal-footer .btn {
    width: 100%;
  }
  .upload-list {
    gap: 10px;
  }
  .upload-slot,
  .upload-thumb {
    width: 100%;
    max-width: 220px;
  }
  .paper-card-large {
    max-width: 100%;
  }
  .note-modal-hint {
    font-size: 12px;
  }
  .login-form input,
  .invite-text {
    font-size: 14px;
  }
}

/* Preview modal */
.preview-modal-inner {
  position: relative;
  max-width: 70vw;
  max-height: 70vh;
  border-radius: 18px;
  overflow: hidden;
  background: #020617;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.9);
}

#preview-image {
  display: block;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.preview-close {
  position: absolute;
  top: 8px;
  right: 12px;
  width: 26px;
  height: 26px;
  border-radius: 999px;
  border: none;
  background: rgba(15, 23, 42, 0.85);
  color: #e5e7eb;
  font-size: 18px;
  cursor: pointer;
}

/* Notes page styles */
.notes-page {
  padding-top: 32px;
  padding-bottom: 40px;
}

.notes-day {
  margin-bottom: 32px;
}

.notes-date {
  font-size: 20px;
  color: #b09474;
  margin-bottom: 12px;
}

.notes-day-body {
  background: radial-gradient(circle at 0% 0%, #111827, #020617);
  border-radius: 18px;
  padding: 16px 20px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.7);
}

.note-item {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 10px 0;
  border-bottom: 1px solid rgba(15, 23, 42, 0.6);
  cursor: pointer;
}

.note-item:last-child {
  border-bottom: none;
}

.note-outer-text {
  font-size: 14px;
  color: #b09474;
  line-height: 1.6;
}

.note-paper-thumb {
  position: relative;
  width: 160px;
  height: 90px;
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.8);
  background: #000;
}

.note-paper-thumb .paper-inner {
  width: 100%;
  height: 100%;
  position: relative;
}

.note-paper-thumb .paper-front,
.note-paper-thumb .paper-back {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  border-radius: 14px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.note-paper-thumb .paper-front {
  background: #fdf7ec;
  color: #4b5563;
  font-size: 13px;
  padding: 10px 12px;
}

.note-paper-thumb .paper-back {
  background-color: #000;
  display: none;
}

.note-paper-thumb .paper-back img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  display: block;
  image-rendering: crisp-edges;
}

.note-paper-thumb.is-back .paper-front {
  display: none;
}

.note-paper-thumb.is-back .paper-back {
  display: block;
}

.notes-pending-bar {
  padding: 12px 0 4px;
  font-size: 14px;
  color: #b09474;
  opacity: 0.9;
}

/* Large note modal for flipping */
.note-modal {
  position: relative;
  width: 640px;
  max-width: calc(100% - 40px);
  background: #020617ee;
  border-radius: 20px;
  padding: 24px 24px 22px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.9);
  border: 1px solid rgba(148, 163, 184, 0.4);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
}

.paper-card-large {
  width: 100%;
  max-width: 520px;
  height: 0;
  padding-top: 56.25%; /* 16:9 */
  position: relative;
  overflow: hidden;
  perspective: 1200px;
}

.paper-card-large .paper-inner {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
  transition: transform 0.5s ease;
}

.paper-face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  border-radius: 20px;
  overflow: hidden;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
}

.paper-front {
  background: #fdf7ec;
  color: #4b5563;
}

.paper-front-text {
  padding: 24px 28px;
  font-size: 16px;
  color: #4b5563;
  line-height: 1.8;
}

.paper-back {
  background: #020617;
  transform: rotateY(180deg);
}

.paper-back img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
}

.paper-card-large.flipped .paper-inner {
  transform: rotateY(180deg);
}

.note-modal-hint {
  color: #94a3b8;
  font-size: 13px;
  margin-top: 6px;
  text-align: center;
}

.flip-btn {
  align-self: center;
  margin-top: 6px;
}

.image-loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  background: rgba(0, 0, 0, 0.4);
  font-size: 14px;
  z-index: 2;
}

.image-loading.error {
  background: rgba(127, 29, 29, 0.65);
  color: #fee2e2;
}

/* Admin page */
.admin-page {
  padding-top: 32px;
  padding-bottom: 40px;
}

.admin-section {
  margin-bottom: 32px;
}

.admin-section h2 {
  font-size: 20px;
  margin-bottom: 12px;
  color: #b09474;
}

.admin-section label {
  display: block;
  margin-bottom: 8px;
  font-size: 14px;
}

.admin-head-preview {
  width: 100%;
  max-width: 480px;
  aspect-ratio: 16 / 9;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.7);
  margin-bottom: 12px;
}

.admin-head-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.admin-samples {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 12px;
}

.admin-sample-item {
  position: relative;
  width: 150px;
  aspect-ratio: 16 / 9;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.7);
}

.admin-sample-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.admin-sample-remove {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 20px;
  height: 20px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.85);
  border: none;
  color: #e5e7eb;
  font-size: 14px;
  cursor: pointer;
}

.admin-role-preview {
  width: 100%;
  max-width: 320px;
  aspect-ratio: 16 / 9;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.7);
  margin-bottom: 8px;
}

.admin-role-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.admin-role-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.admin-file-input {
  margin-top: 8px;
  margin-bottom: 16px;
}

.admin-test-workflow {
  margin-top: 12px;
}

#workflow-test-modal {
  position: fixed;
  inset: 0;
  background: rgba(3, 7, 18, 0.78);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 80;
}

#workflow-test-modal.show {
  display: flex;
}

#workflow-test-modal .modal-content {
  position: relative;
  width: 560px;
  max-width: calc(100% - 40px);
  background: #020617f2;
  border: 1px solid rgba(148, 163, 184, 0.35);
  border-radius: 18px;
  padding: 18px 18px 22px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.9);
}

.modal-close {
  position: absolute;
  top: 8px;
  right: 10px;
  width: 28px;
  height: 28px;
  border-radius: 999px;
  border: none;
  background: rgba(15, 23, 42, 0.85);
  color: #e5e7eb;
  font-size: 18px;
  cursor: pointer;
}

#workflow-test-result .test-preview {
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: center;
}

#workflow-test-result img {
  max-width: 100%;
  border-radius: 12px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.8);
}

#workflow-test-result .test-text {
  width: 100%;
  background: #0b1224;
  border-radius: 12px;
  padding: 12px 14px;
  color: #e5e7eb;
  line-height: 1.6;
  border: 1px solid rgba(148, 163, 184, 0.25);
}

/* Responsive tweaks */
@media (max-width: 1400px) {
  .main-scroll {
    padding: 20px 20px 32px;
  }
}

@media (max-width: 1200px) {
  .gallery-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
.image-preview-modal .preview-modal-inner,
#image-preview-modal .preview-modal-inner {
  max-width: 95vw;
  max-height: 95vh;
}

#image-preview-img {
  max-width: 95vw;
  max-height: 90vh;
  width: auto;
  height: auto;
  object-fit: contain;
  display: block;
}

/* 弹窗小图居中裁切，避免顶部对齐 */
#note-modal .paper-back img {
  width: 100% !important;
  height: 100% !important;
  display: block !important;
  object-fit: cover !important;
  object-position: center 40% !important;
}

/* Ensure modal (view mode) image在16:9容器内居中裁切 */
#paper-back-image {
  object-fit: cover;
  object-position: center center;
}


/* ===== 缩略图强制显示图片（关键修复） ===== */
.note-paper-thumb .paper-back {
  background: transparent !important;
  position: relative !important;
  z-index: 1 !important;
}

.note-paper-thumb .paper-back img {
  position: absolute !important;
  inset: 0 !important;
  width: 100% !important;
  height: 100% !important;
  display: block !important;
  object-fit: cover !important;
  object-position: center !important;
  z-index: 9999 !important;
  opacity: 1 !important;
  mix-blend-mode: normal !important;
  filter: none !important;
}

/* 缩略图前后面层级/显示控制，避免被覆盖后只剩黑底 */
.note-paper-thumb .paper-front {
  z-index: 2;
}
.note-paper-thumb .paper-back {
  z-index: 1;
  opacity: 0;
}
.note-paper-thumb.is-back .paper-front {
  display: none;
}
.note-paper-thumb.is-back .paper-back {
  opacity: 1;
}
