/*
 * 本文件负责全站公共样式。
 * 包含黑白主题、日夜模式、前台布局、后台表格和三端适配。
 */

:root {
  --bg: #f8f8f6;
  --panel: #ffffff;
  --panel-2: #eeeeeb;
  --text: #111111;
  --muted: #626262;
  --line: #d6d6d2;
  --strong: #000000;
  --invert: #ffffff;
  --footer: #f8f8f6;
  --footer-text: #111111;
  --footer-muted: #626262;
  --footer-link: #f8f8f6;
  --danger: #a72727;
  --shadow: 0 18px 42px rgba(0, 0, 0, .08);
  --line-art-1: rgba(0, 0, 0, .08);
  --line-art-2: rgba(0, 0, 0, .04);
  --line-art-3: rgba(0, 0, 0, .025);
}

body[data-theme="dark"] {
  --bg: #101010;
  --panel: #191919;
  --panel-2: #242424;
  --text: #f4f4f1;
  --muted: #b8b8b2;
  --line: #383838;
  --strong: #ffffff;
  --invert: #000000;
  --footer: #050505;
  --footer-text: #f5f5f2;
  --footer-muted: #c8c8c2;
  --footer-link: #050505;
  --shadow: 0 18px 42px rgba(0, 0, 0, .35);
  --line-art-1: rgba(255, 255, 255, .11);
  --line-art-2: rgba(255, 255, 255, .055);
  --line-art-3: rgba(255, 255, 255, .035);
}

* { box-sizing: border-box; }
body { min-height: 100vh; margin: 0; display: flex; flex-direction: column; color: var(--text); background-color: var(--bg); background-image: linear-gradient(120deg, transparent 0 22%, var(--line-art-2) 22.08%, transparent 22.16% 100%), linear-gradient(60deg, transparent 0 64%, var(--line-art-1) 64.08%, transparent 64.16% 100%), linear-gradient(90deg, var(--line-art-3) 1px, transparent 1px), linear-gradient(0deg, var(--line-art-3) 1px, transparent 1px); background-size: 420px 420px, 560px 560px, 72px 72px, 72px 72px; background-position: 0 0, 120px 60px, 0 0, 0 0; font-family: Arial, "Microsoft YaHei", sans-serif; line-height: 1.65; animation: lineDrift 28s linear infinite; transition: background-color .35s ease, background-image .35s ease; }
body > main { flex: 1 0 auto; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }
img { max-width: 100%; display: block; }

.site-header { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 16px clamp(16px, 4vw, 56px); border-bottom: 1px solid var(--line); background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(16px); }
.brand { font-size: 20px; font-weight: 800; letter-spacing: 0; }
.top-nav { display: flex; align-items: center; gap: 16px; color: var(--muted); font-size: 14px; }
.top-nav a.active, .top-nav a:hover { color: var(--text); }

.theme-toggle { width: 54px; height: 29px; border: 1px solid var(--strong); border-radius: 999px; padding: 3px; background: var(--panel); cursor: pointer; }
.theme-toggle span { display: block; width: 21px; height: 21px; border-radius: 50%; background: var(--strong); transition: transform .2s ease; }
body[data-theme="dark"] .theme-toggle span { transform: translateX(23px); }

.hero { min-height: 76vh; display: grid; grid-template-columns: minmax(0, .94fr) minmax(300px, 1.06fr); gap: clamp(26px, 5vw, 74px); align-items: center; padding: clamp(42px, 8vw, 92px) clamp(16px, 5vw, 72px) 46px; border-bottom: 1px solid var(--line); }
.eyebrow { margin: 0 0 12px; color: var(--muted); font-size: 13px; text-transform: uppercase; }
h1 { margin: 0; font-size: clamp(40px, 7vw, 82px); line-height: 1; letter-spacing: 0; }
.lead { max-width: 680px; color: var(--muted); font-size: 18px; }
.hero .lead { margin: 24px 0 30px; }
.button-row, .form-actions, .copy-bar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.primary-btn, .ghost-btn, .mini-btn { display: inline-flex; align-items: center; justify-content: center; min-height: 42px; border: 1px solid var(--strong); border-radius: 6px; padding: 8px 15px; background: transparent; color: var(--text); cursor: pointer; }
.primary-btn { background: var(--strong); color: var(--invert); }
.mini-btn { min-height: 32px; padding: 5px 10px; font-size: 13px; }
.danger { border-color: var(--danger); color: var(--danger); }

.image-placeholder { min-height: 250px; display: grid; place-content: center; gap: 8px; border: 1px dashed var(--line); background: var(--panel-2); color: var(--muted); text-align: center; }
.image-placeholder strong { color: var(--text); font-size: 20px; }
.hero .image-placeholder { aspect-ratio: 4 / 3; min-height: 360px; }
.media-frame { overflow: hidden; background: var(--panel-2); }
.media-frame > img, .hero > img, .grid-2 > img { width: 100%; height: 100%; min-height: 250px; object-fit: cover; border: 1px solid var(--line); border-radius: 8px; }
.hero > img { aspect-ratio: 4 / 3; min-height: 360px; }
.placeholder-small > img { min-height: 170px; }

.section { padding: clamp(42px, 7vw, 82px) clamp(16px, 5vw, 72px); border-bottom: 1px solid var(--line); }
.section-head { display: flex; justify-content: space-between; gap: 24px; align-items: end; margin-bottom: 28px; }
.section-head h2, .admin-main h1 { margin: 0; font-size: clamp(28px, 4vw, 46px); line-height: 1.1; }
.section-head p { max-width: 560px; margin: 0; color: var(--muted); }
.grid-2, .grid-3, .grid-4 { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.card { border: 1px solid var(--line); border-radius: 8px; padding: 20px; background: var(--panel); box-shadow: var(--shadow); }
.flat-card { border: 1px solid var(--line); padding: 22px; background: var(--panel); }
.card h3, .flat-card h3 { margin: 0 0 8px; }
.card p, .flat-card p { margin: 0; color: var(--muted); }
.placeholder-small { min-height: 170px; margin-bottom: 14px; }

.site-footer { position: relative; flex-shrink: 0; display: flex; justify-content: space-between; gap: 20px; flex-wrap: wrap; margin-top: auto; padding: 34px clamp(16px, 5vw, 72px); color: var(--footer-text); background: var(--footer); border-top: 1px solid var(--line); }
.site-footer p { margin: 4px 0; color: var(--footer-muted); }
.admin-secret { position: static; display: inline-flex; align-items: center; justify-content: center; min-height: 36px; margin-top: 12px; border: 1px solid var(--footer-text); border-radius: 6px; padding: 6px 14px; overflow: visible; color: var(--footer-text); font-size: 14px; }
.admin-secret:hover { color: var(--footer); background: var(--footer-text); }

.admin-shell { min-height: 100vh; display: grid; grid-template-columns: 260px minmax(0, 1fr); }
.admin-sidebar { position: sticky; top: 0; height: 100vh; padding: 22px; border-right: 1px solid var(--line); background: var(--panel); overflow-y: auto; }
.admin-sidebar .brand { display: block; margin-bottom: 20px; }
.admin-nav { display: grid; gap: 7px; }
.admin-nav a { border: 1px solid var(--line); border-radius: 6px; padding: 9px 11px; color: var(--muted); background: var(--bg); }
.admin-nav a.active { color: var(--invert); border-color: var(--strong); background: var(--strong); }
.admin-main { min-width: 0; padding: 26px clamp(16px, 4vw, 46px) 56px; }
.admin-top { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 22px; }
.notice { margin: 0 0 16px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel); color: var(--muted); }
.admin-panel { margin-bottom: 18px; padding: 18px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); box-shadow: var(--shadow); }
.metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 18px; }
.metric { padding: 18px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); }
.metric strong { display: block; font-size: 30px; line-height: 1; }
.metric span { color: var(--muted); }

.form-grid, .filter-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; align-items: end; }
label span { display: block; margin-bottom: 5px; color: var(--muted); font-size: 13px; }
input, select, textarea { width: 100%; min-height: 40px; border: 1px solid var(--line); border-radius: 6px; padding: 9px 10px; color: var(--text); background: var(--bg); }
select[multiple] { min-height: 116px; }
textarea { resize: vertical; }
.combo-field { display: grid; grid-template-columns: minmax(0, 1fr) 160px; gap: 8px; }
.combo-field select { cursor: pointer; }
.wide { grid-column: 1 / -1; }

.table-wrap { width: 100%; overflow-x: auto; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); }
.data-table { width: 100%; min-width: 1040px; border-collapse: collapse; font-size: 14px; }
.data-table th, .data-table td { padding: 10px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.data-table th { color: var(--muted); background: var(--panel-2); white-space: nowrap; }
.row-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.row-actions form { margin: 0; }
.empty { text-align: center; color: var(--muted); }
.clickable-row { cursor: pointer; }
.clickable-row:hover { background: var(--panel-2); }
.mobile-card-list { display: none; }
.image-list { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 12px; }
.image-list img, .image-tile { width: 110px; height: 82px; object-fit: cover; border: 1px solid var(--line); border-radius: 6px; background: var(--panel-2); }
.image-tile { display: grid; place-content: center; color: var(--muted); text-align: center; font-size: 12px; padding: 8px; }
.detail-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1px; border: 1px solid var(--line); background: var(--line); }
.detail-item { padding: 14px; background: var(--panel); }
.detail-item strong { display: block; margin-bottom: 4px; color: var(--muted); font-size: 13px; }
.detail-item.wide { grid-column: 1 / -1; }
.detail-images { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.detail-images img, .detail-image-url { min-height: 150px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel-2); }
.detail-images img { width: 100%; height: 180px; object-fit: cover; }
.detail-image-url { display: grid; place-content: center; padding: 14px; color: var(--muted); overflow-wrap: anywhere; text-align: center; }
.login-page { min-height: 100vh; display: grid; place-items: center; padding: 18px; }
.login-card { width: min(420px, 100%); padding: 24px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); box-shadow: var(--shadow); }

@media (max-width: 1199px) {
  .grid-4, .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .admin-shell { grid-template-columns: 1fr; }
  .admin-sidebar { position: static; height: auto; border-right: 0; border-bottom: 1px solid var(--line); }
  .admin-nav { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 767px) {
  .site-header, .admin-top, .section-head { align-items: flex-start; flex-direction: column; }
  .top-nav { width: 100%; overflow-x: auto; gap: 12px; }
  .hero { min-height: auto; grid-template-columns: 1fr; }
  h1 { font-size: 42px; }
  .grid-2, .grid-3, .grid-4, .metrics, .form-grid, .filter-grid, .admin-nav { grid-template-columns: 1fr; }
  .detail-grid, .detail-images { grid-template-columns: 1fr; }
  .combo-field { grid-template-columns: 1fr; }
  .primary-btn, .ghost-btn { width: 100%; }
  .mobile-card-list { display: grid; gap: 12px; }
  .material-table-mobile-hide { display: none; }
  .data-table { min-width: 920px; font-size: 13px; }
  .admin-main { padding-bottom: 86px; }
.sticky-actions { position: sticky; bottom: 0; z-index: 15; padding: 10px; margin-inline: -16px; background: var(--bg); border-top: 1px solid var(--line); }
}

@keyframes lineDrift {
  from { background-position: 0 0, 120px 60px, 0 0, 0 0; }
  to { background-position: 420px 120px, -160px 260px, 72px 72px, 72px 72px; }
}

@media (prefers-reduced-motion: reduce) {
  body { animation: none; }
}
