@import url("https://fonts.googleapis.com/css2?family=DM+Serif+Display&family=Source+Sans+3:wght@300;400;500;600;700&family=Noto+Sans+SC:wght@300;400;500;600;700&display=swap");

:root {
  color-scheme: light;
  --ink: #1d1b16;
  --muted: #5a554c;
  --accent: #c95f2d;
  --accent-dark: #8d3d1e;
  --paper: #f7f0e6;
  --surface: #fffaf4;
  --shadow: 0 24px 60px rgba(25, 20, 10, 0.18);
  --stroke: rgba(36, 30, 20, 0.16);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Noto Sans SC", "Source Sans 3", sans-serif;
  color: var(--ink);
  background: radial-gradient(circle at 20% 20%, #f4e7d5, transparent 55%),
    radial-gradient(circle at 90% 10%, #f6d6c0, transparent 50%),
    radial-gradient(circle at 70% 80%, #e6e2d3, transparent 60%),
    var(--paper);
  min-height: 100vh;
  padding: 40px 28px 80px;
}

.bg-shapes {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image: linear-gradient(
      120deg,
      rgba(255, 255, 255, 0.35),
      rgba(255, 255, 255, 0)
    ),
    repeating-linear-gradient(
      120deg,
      rgba(255, 255, 255, 0.12),
      rgba(255, 255, 255, 0.12) 1px,
      transparent 1px,
      transparent 8px
    );
  mix-blend-mode: multiply;
  opacity: 0.6;
}

.hero {
  max-width: 1200px;
  margin: 0 auto 40px;
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 0.8fr);
  gap: 32px;
  align-items: center;
}

.hero-text h1 {
  font-family: "DM Serif Display", serif;
  font-size: clamp(2.4rem, 4vw, 3.6rem);
  margin: 12px 0;
}

.hero-text p {
  font-size: 1.05rem;
  line-height: 1.7;
  color: var(--muted);
}

.eyebrow {
  text-transform: uppercase;
  font-size: 0.85rem;
  letter-spacing: 0.2em;
  color: var(--accent-dark);
}

.hero-card {
  background: rgba(255, 255, 255, 0.8);
  border: 1px solid var(--stroke);
  border-radius: 20px;
  padding: 24px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
}

.hero-card-title {
  font-weight: 600;
  margin-bottom: 12px;
}

.hero-card ul {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
  line-height: 1.6;
}

.layout {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 32px;
}

.panel {
  background: var(--surface);
  border-radius: 24px;
  padding: 28px;
  border: 1px solid var(--stroke);
  box-shadow: var(--shadow);
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.panel h2,
.results h2 {
  font-size: 1.3rem;
  margin: 0;
}

.toggle {
  font-size: 0.9rem;
  color: var(--muted);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
  font-size: 0.95rem;
}

.field span {
  color: var(--muted);
}

.field input,
.field select,
.field textarea {
  border-radius: 12px;
  border: 1px solid var(--stroke);
  padding: 10px 12px;
  font-size: 0.95rem;
  background: #fff;
  outline: none;
  transition: border 0.2s ease, box-shadow 0.2s ease;
}

.field textarea {
  min-height: 140px;
  resize: vertical;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(201, 95, 45, 0.2);
}

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

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chips button {
  border: 1px solid var(--stroke);
  background: #fff;
  padding: 8px 12px;
  border-radius: 999px;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.chips button.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.advanced {
  margin-top: 12px;
  padding: 12px 0;
}

.advanced summary {
  cursor: pointer;
  color: var(--accent-dark);
  font-weight: 600;
}

.advanced-grid {
  margin-top: 14px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
}

.actions {
  display: flex;
  gap: 12px;
  margin-top: 8px;
}

button {
  font-family: inherit;
}

button.primary {
  background: var(--accent);
  border: 1px solid var(--accent);
  color: #fff;
  padding: 10px 16px;
  border-radius: 12px;
  cursor: pointer;
  font-weight: 600;
  box-shadow: 0 16px 30px rgba(201, 95, 45, 0.25);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

button.primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 20px 40px rgba(201, 95, 45, 0.28);
}

button#reset-btn {
  background: transparent;
  border: 1px solid var(--stroke);
  padding: 10px 16px;
  border-radius: 12px;
  cursor: pointer;
}

.status {
  margin-top: 12px;
  font-size: 0.9rem;
  color: var(--accent-dark);
}

.results {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.results-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.badge {
  min-width: 34px;
  padding: 6px 10px;
  border-radius: 999px;
  background: #fff;
  border: 1px solid var(--stroke);
  text-align: center;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 18px;
}

.card {
  background: #fff;
  border-radius: 18px;
  border: 1px solid var(--stroke);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow);
}

.card-media {
  position: relative;
  aspect-ratio: 3 / 4;
  background: repeating-linear-gradient(
      45deg,
      rgba(233, 225, 212, 0.5),
      rgba(233, 225, 212, 0.5) 6px,
      rgba(247, 240, 230, 0.9) 6px,
      rgba(247, 240, 230, 0.9) 12px
    );
  display: flex;
  align-items: center;
  justify-content: center;
}

.card-media img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: transparent;
  cursor: zoom-in;
}

.card-body {
  padding: 12px 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.card-title {
  font-weight: 600;
  font-size: 0.98rem;
}

.card-meta {
  color: var(--muted);
  font-size: 0.85rem;
}

.card-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.card-actions a,
.card-actions button {
  font-size: 0.85rem;
  border-radius: 999px;
  border: 1px solid var(--stroke);
  padding: 6px 10px;
  background: #fff;
  text-decoration: none;
  color: var(--ink);
  cursor: pointer;
}

.admin {
  margin-top: 16px;
  border-top: 1px dashed var(--stroke);
  padding-top: 12px;
}

.admin summary {
  cursor: pointer;
  color: var(--accent-dark);
  font-weight: 600;
}

.admin-section {
  margin-top: 16px;
  padding: 12px;
  border: 1px solid var(--stroke);
  border-radius: 16px;
  background: #fff;
}

.admin-title {
  font-weight: 600;
  margin-bottom: 10px;
}

.admin-hint {
  margin-top: 10px;
  color: var(--muted);
  font-size: 0.9rem;
}

.admin-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
}

.admin-actions {
  display: flex;
  gap: 10px;
  margin-top: 10px;
}

.admin-actions button {
  border: 1px solid var(--stroke);
  background: #fff;
  padding: 8px 14px;
  border-radius: 999px;
  cursor: pointer;
}

.auth-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border: 1px dashed var(--stroke);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.65);
  margin-bottom: 14px;
}

.auth-bar button {
  border: 1px solid var(--stroke);
  background: #fff;
  padding: 8px 14px;
  border-radius: 999px;
  cursor: pointer;
}

.auth-current {
  font-size: 0.92rem;
  color: var(--muted);
}

.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(20, 16, 10, 0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  z-index: 30;
}

.lightbox.show {
  opacity: 1;
  pointer-events: auto;
}

.lightbox img {
  max-width: min(860px, 90vw);
  max-height: 85vh;
  border-radius: 18px;
  box-shadow: var(--shadow);
  background: #fff;
  object-fit: contain;
}

.lightbox button {
  position: absolute;
  top: 20px;
  right: 20px;
  border: 1px solid rgba(255, 255, 255, 0.5);
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  padding: 8px 14px;
  border-radius: 999px;
  cursor: pointer;
}

.auth-mask {
  position: fixed;
  inset: 0;
  background: rgba(245, 239, 230, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  z-index: 40;
}

.auth-mask.show {
  opacity: 1;
  pointer-events: auto;
}

.auth-mask-card {
  background: #fff;
  border: 1px solid var(--stroke);
  border-radius: 18px;
  padding: 18px 22px;
  box-shadow: var(--shadow);
  color: var(--muted);
}

/* 登录页面容器 - 居中单列 */
.login-shell {
  max-width: 380px;
  margin: 0 auto;
  display: block;
}

/* 登录卡片 */
.login-card {
  background: var(--surface);
  border-radius: 20px;
  padding: 32px 28px;
  border: 1px solid var(--stroke);
  box-shadow: var(--shadow);
}

/* Tab 导航 */
.auth-tabs {
  display: flex;
  margin-bottom: 28px;
  border-bottom: 1px solid var(--stroke);
}

.auth-tab {
  flex: 1;
  padding: 14px 0;
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 1rem;
  font-weight: 600;
  color: var(--muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color 0.2s, border-color 0.2s;
}

.auth-tab:hover {
  color: var(--ink);
}

.auth-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* 全宽主按钮 */
.auth-submit {
  width: 100%;
  padding: 14px;
  margin-top: 8px;
  border: none;
  border-radius: 12px;
  background: var(--accent);
  color: #fff;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 8px 20px rgba(201, 95, 45, 0.25);
  transition: transform 0.2s, box-shadow 0.2s;
}

.auth-submit:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 28px rgba(201, 95, 45, 0.3);
}

/* 底部信息 */
.auth-footer {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--stroke);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.9rem;
  color: var(--muted);
}

.auth-footer button {
  background: none;
  border: none;
  color: var(--accent-dark);
  cursor: pointer;
  font-size: 0.9rem;
}

.auth-footer button:hover {
  text-decoration: underline;
}

.debug {
  font-size: 0.85rem;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.6);
  border-radius: 12px;
  padding: 12px;
  border: 1px dashed var(--stroke);
  white-space: pre-wrap;
}

/* 调试信息折叠样式 */
.debug-details {
  margin-top: 16px;
}

.debug-details summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 0.9rem;
  padding: 8px 0;
}

.debug-details summary:hover {
  color: var(--accent-dark);
}

/* 顶部导航栏 */
.top-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  margin-bottom: 20px;
}

.top-nav-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.top-nav-brand {
  font-weight: 600;
  font-size: 1.1rem;
  color: var(--ink);
}

.top-nav-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

/* 管理员新增按钮 */
.admin-add-btn {
  padding: 8px 16px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  border-radius: 999px;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
}

.admin-add-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(201, 95, 45, 0.3);
}

/* 用户头像菜单 */
.user-menu {
  position: relative;
}

.user-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 2px solid var(--stroke);
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  color: #fff;
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s, box-shadow 0.2s;
}

.user-avatar:hover {
  transform: scale(1.05);
  box-shadow: 0 4px 12px rgba(201, 95, 45, 0.25);
}

.user-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 180px;
  background: var(--surface);
  border: 1px solid var(--stroke);
  border-radius: 12px;
  box-shadow: var(--shadow);
  z-index: 50;
  overflow: hidden;
}

.user-dropdown-header {
  padding: 14px 16px;
  background: rgba(201, 95, 45, 0.05);
}

.dropdown-username {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--ink);
}

.dropdown-role {
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: 2px;
}

.user-dropdown-divider {
  height: 1px;
  background: var(--stroke);
}

.dropdown-item {
  display: block;
  width: 100%;
  padding: 12px 16px;
  border: none;
  background: transparent;
  text-align: left;
  font-size: 0.9rem;
  color: var(--ink);
  cursor: pointer;
  transition: background 0.15s;
}

.dropdown-item:hover {
  background: rgba(201, 95, 45, 0.08);
}

/* 卡片管理员操作按钮 */
.card-admin-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dashed var(--stroke);
}

.card-admin-actions button {
  flex: 1;
  padding: 6px 10px;
  border: 1px solid var(--stroke);
  background: #fff;
  border-radius: 8px;
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.15s;
}

.card-admin-actions button:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.card-admin-actions button.danger:hover {
  border-color: #d32f2f;
  color: #d32f2f;
  background: rgba(211, 47, 47, 0.05);
}

/* 管理员弹窗 */
.admin-modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
}

.admin-modal[hidden] {
  display: none;
}

.admin-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(20, 16, 10, 0.5);
}

.admin-modal-content {
  position: relative;
  width: 90%;
  max-width: 560px;
  max-height: 85vh;
  background: var(--surface);
  border-radius: 20px;
  box-shadow: var(--shadow);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.admin-modal-small {
  max-width: 400px;
}

.admin-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 24px;
  border-bottom: 1px solid var(--stroke);
}

.admin-modal-header h3 {
  margin: 0;
  font-size: 1.15rem;
}

.admin-modal-close {
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  font-size: 1.5rem;
  color: var(--muted);
  cursor: pointer;
  border-radius: 8px;
  transition: background 0.15s;
}

.admin-modal-close:hover {
  background: rgba(0, 0, 0, 0.05);
}

.admin-modal-body {
  padding: 20px 24px;
  overflow-y: auto;
  flex: 1;
}

.admin-modal-footer {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  padding: 16px 24px;
  border-top: 1px solid var(--stroke);
}

.admin-modal-btn {
  padding: 10px 20px;
  border: 1px solid var(--stroke);
  background: #fff;
  border-radius: 10px;
  font-size: 0.95rem;
  cursor: pointer;
  transition: all 0.15s;
}

.admin-modal-btn:hover {
  border-color: var(--accent);
}

.admin-modal-btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.admin-modal-btn.primary:hover {
  background: var(--accent-dark);
  border-color: var(--accent-dark);
}

.admin-modal-btn.danger {
  background: #d32f2f;
  border-color: #d32f2f;
  color: #fff;
}

.admin-modal-btn.danger:hover {
  background: #b71c1c;
  border-color: #b71c1c;
}

@media (max-width: 1024px) {
  .hero {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  body {
    padding: 24px 16px 60px;
  }
  .field-row {
    grid-template-columns: 1fr;
  }
  .grid {
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  }
  .card-body {
    padding: 10px 12px 14px;
  }
  .lightbox img {
    max-width: 92vw;
  }
}
