:root {
  --bg: #f7f7f5;
  --panel: #ffffff;
  --ink: #1f1f1f;
  --muted: #8a8a8a;
  --line: #e6e6e3;
  --accent: #b8472f;
  --accent2: #2f6db8;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0; font-family: -apple-system, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  background: var(--bg); color: var(--ink); line-height: 1.5;
}
.topbar {
  position: sticky; top: 0; z-index: 20; background: var(--panel);
  border-bottom: 1px solid var(--line); padding: 14px 20px;
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
}
.topbar h1 { font-size: 20px; margin: 0; letter-spacing: 2px; }
.controls { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-left: auto; }
.controls input[type=search], .controls select {
  padding: 8px 12px; border: 1px solid var(--line); border-radius: 8px; background: #fff; font-size: 14px;
}
.admin-link { font-size: 13px; color: var(--accent2); text-decoration: none; border: 1px solid var(--line); padding: 7px 12px; border-radius: 8px; }
button {
  font: inherit; cursor: pointer; border: none; border-radius: 8px; padding: 8px 14px;
  background: var(--accent); color: #fff;
}
button.ghost { background: #fff; color: var(--ink); border: 1px solid var(--line); }
button.primary { background: var(--accent); }
button.del { background: #fff; color: #c0392b; border: 1px solid var(--line); }
main { max-width: 1100px; margin: 0 auto; padding: 24px 20px 60px; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 18px; }
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 18px;
  text-align: center; cursor: pointer; transition: .15s; 
}
.card:hover { transform: translateY(-3px); box-shadow: 0 8px 24px rgba(0,0,0,.08); }
.avatar {
  width: 84px; height: 84px; border-radius: 50%; margin: 0 auto 10px; overflow: hidden;
  background: #ececec; display: flex; align-items: center; justify-content: center;
  font-size: 30px; color: var(--muted);
}
.avatar.big { width: 110px; height: 110px; font-size: 40px; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.card .name { font-weight: 600; font-size: 16px; }
.card .cat { font-size: 12px; color: var(--muted); margin-top: 2px; }
.card .count { font-size: 12px; color: var(--accent2); margin-top: 6px; }
.empty { color: var(--muted); text-align: center; padding: 40px; }

.modal { position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal.hidden { display: none; }
.modal-bg { position: absolute; inset: 0; background: rgba(0,0,0,.45); }
.modal-panel {
  position: relative; background: var(--panel); border-radius: 16px; max-width: 560px; width: 100%;
  max-height: 88vh; overflow: auto; padding: 28px;
}
.modal-panel.wide { max-width: 820px; }
.close { position: absolute; top: 12px; right: 16px; background: none; color: var(--muted); font-size: 26px; line-height: 1; padding: 0 6px; }
.ad-head { display: flex; gap: 16px; align-items: center; margin-bottom: 14px; }
.ad-head h2 { margin: 0; }
.intro { color: #444; white-space: pre-wrap; }
h3 { margin: 22px 0 10px; font-size: 15px; color: var(--muted); }
.works { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px,1fr)); gap: 14px; }
.work { cursor: pointer; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: #fff; }
.work:hover { box-shadow: 0 6px 18px rgba(0,0,0,.1); }
.cover { width: 100%; aspect-ratio: 1/1; background: #eee; display: flex; align-items: center; justify-content: center; font-size: 30px; color: var(--muted); }
.cover img { width: 100%; height: 100%; object-fit: cover; }
.vbadge { font-size: 30px; color: var(--muted); }
.wt { font-size: 13px; font-weight: 600; padding: 8px 10px 0; }
.wm { font-size: 11px; color: var(--muted); padding: 2px 10px 10px; }

.viewer { background: #111; border-radius: 12px; overflow: hidden; min-height: 240px; display: flex; align-items: center; justify-content: center; }
.viewer img, .viewer video { max-width: 100%; max-height: 320px; width: auto; display: block; object-fit: contain; }
/* 单图作品直接渲染在详情里，也要限制显示尺寸，约一个巴掌大，避免竖图撑爆弹窗 */
.workDetail img { max-width: 100%; max-height: 320px; width: auto; object-fit: contain; display: block; margin: 0 auto; }
.viewer iframe { width: 100%; aspect-ratio: 16/9; border: 0; }
.thumbs { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 12px; }
.thumb { width: 72px; height: 72px; border-radius: 8px; overflow: hidden; background: #eee; display: flex; align-items: center; justify-content: center; cursor: pointer; border: 2px solid transparent; font-size: 20px; }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb.active { border-color: var(--accent); }
.meta { display: flex; gap: 18px; flex-wrap: wrap; font-size: 13px; color: var(--muted); margin: 8px 0; }
.meta span { background: #f0f0ee; padding: 4px 10px; border-radius: 6px; }
.desc { white-space: pre-wrap; color: #333; }

/* admin */
body.admin { background: var(--bg); }
.gate { position: fixed; inset: 0; z-index: 200; display: flex; align-items: center; justify-content: center; background: var(--bg); }
.gate.hidden, .admin-list.hidden { display: none; }
.gate-box { background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 30px; width: 320px; text-align: center; }
.gate-box input { width: 100%; padding: 10px; border: 1px solid var(--line); border-radius: 8px; margin: 10px 0; }
.gate-box .hint { font-size: 12px; color: var(--muted); }
.admin-list { max-width: 900px; margin: 0 auto; padding: 24px 20px; display: flex; flex-direction: column; gap: 12px; }
.arow { display: flex; align-items: center; gap: 14px; background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 12px 16px; }
.arow .info { flex: 1; }
.arow .name { font-weight: 600; }
.arow .cat { font-size: 12px; color: var(--muted); }
.arow .ops { display: flex; gap: 8px; }
label { display: block; font-size: 13px; color: var(--muted); margin: 10px 0 4px; }
input, textarea, select { width: 100%; padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px; font: inherit; background: #fff; }
.wrow { border: 1px solid var(--line); border-radius: 10px; padding: 12px; margin: 10px 0; background: #fafafa; }
.whead { font-weight: 600; font-size: 13px; display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.media-edit { margin-top: 8px; border-top: 1px dashed var(--line); padding-top: 8px; }
.media-tip { font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.media-hint { font-size: 12px; color: var(--muted); margin-top: 8px; background: #f0f0ee; border-radius: 6px; padding: 7px 9px; line-height: 1.5; }
.mline { display: flex; gap: 8px; align-items: center; margin: 6px 0; }
.mline select { width: 90px; }
.mline input { flex: 1; }
.actions { display: flex; gap: 10px; margin-top: 16px; }
.imgfield { margin-top: 4px; }
.imgfield .mode { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
.imgfield .mode-opt {
  display: flex; align-items: center; gap: 9px;
  padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px;
  cursor: pointer; font-size: 13px; color: var(--ink); background: #fff; transition: .15s;
}
.imgfield .mode-opt:hover { border-color: #d9c3bc; }
.imgfield .mode-opt.active { border-color: var(--accent); background: #fdf3f0; color: var(--accent); font-weight: 600; }
.imgfield .mode-opt input { width: auto; margin: 0 2px 0 0; accent-color: var(--accent); }
.imgfield .mode-ico { font-size: 15px; }
.imgfield .img-up { display: flex; gap: 6px; align-items: center; margin-top: 4px; }
.imgfield .img-up input[type=file] { flex: 1; }
.imgfield .img-prev { max-width: 130px; max-height: 130px; display: block; margin-top: 6px; border-radius: 6px; border: 1px solid var(--line); }
.imgfield .img-loaderr { display: none; color: #c0392b; font-size: 12px; margin-top: 4px; background: #fdecea; border: 1px solid #f5c6cb; border-radius: 6px; padding: 6px 8px; }
.img-broken { background: #f3f3f3; border: 1px dashed #ccc; min-height: 60px; }
.thumbimg, .work .cover img { min-height: 60px; }

/* ---- tab 切换 ---- */
.tabs { display: flex; gap: 6px; }
.tab { background: #fff; color: var(--muted); border: 1px solid var(--line); padding: 7px 16px; font-size: 14px; }
.tab.active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* 公开页：艺术家库 / 策展人库 独立页面导航 */
.pagetabs { display: flex; gap: 6px; }
.pagetabs a { display: inline-block; background: #fff; color: var(--muted); border: 1px solid var(--line); padding: 7px 16px; font-size: 14px; text-decoration: none; border-radius: 6px; }
.pagetabs a:hover { border-color: var(--accent); color: var(--accent); }
.pagetabs a.active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* 列表容器改为块级，卡片网格交给 .sec-items */
#artistGrid, #curatorGrid { display: block; }

/* ---- 拼音首字母分栏 ---- */
.index-bar { position: sticky; top: 64px; z-index: 15; display: flex; flex-wrap: wrap; gap: 4px; background: var(--bg); padding: 8px 0; margin-bottom: 8px; }
.index-bar .idx { font-size: 12px; color: var(--muted); width: 22px; height: 22px; line-height: 22px; text-align: center; border-radius: 6px; cursor: default; }
.index-bar .idx.on { color: #fff; background: var(--accent); cursor: pointer; }
.sec { margin-bottom: 26px; }
.sec-head { font-size: 22px; font-weight: 700; color: var(--accent); border-bottom: 2px solid var(--accent); display: inline-block; padding: 0 14px 4px; margin-bottom: 14px; letter-spacing: 1px; }
.sec-items { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 18px; }

/* ---- 策展人展览 ---- */
.exh-list { display: flex; flex-direction: column; gap: 14px; }
.exh { border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; background: #fafafa; }
.exh-title { font-weight: 600; font-size: 15px; }
.exh-meta { font-size: 12px; color: var(--muted); margin: 2px 0 6px; }
.exh-desc { font-size: 13px; color: #444; }
.exh-artists { margin-top: 8px; font-size: 13px; }
.exh-artists .lab { color: var(--muted); }
.chip { display: inline-block; background: #eef2f8; color: var(--accent2); border-radius: 20px; padding: 2px 10px; margin: 2px 4px 2px 0; font-size: 12px; }
.muted { color: var(--muted); }

/* ---- 后台展览编辑 ---- */
.exhrow { border: 1px solid var(--line); border-radius: 10px; padding: 12px; margin: 10px 0; background: #fafafa; }
.arow .avatar img { width: 100%; height: 100%; object-fit: cover; }

/* 后台列表：按拼音首字母分栏（行式，纵向堆叠） */
.admin-list .sec-items { display: flex; flex-direction: column; gap: 10px; }
.admin-list .sec { margin-bottom: 22px; }
.admin-list .empty { text-align: center; color: var(--muted); padding: 30px 0; }

/* ============ 手机适配（≤640px） ============ */
@media (max-width: 640px) {
  .topbar { padding: 10px 12px; gap: 10px; }
  .topbar h1 { font-size: 17px; letter-spacing: 1px; flex: 1 1 100%; }
  .controls { margin-left: 0; width: 100%; }
  .controls input[type=search], .controls select { flex: 1 1 auto; min-width: 0; font-size: 16px; }
  .pagetabs, .tabs { flex: 1 1 100%; }
  .pagetabs a, .tab { flex: 1 1 auto; text-align: center; }
  main { padding: 16px 12px 50px; }
  .grid, .sec-items { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 12px; }
  .card { padding: 12px; }
  .avatar { width: 64px; height: 64px; font-size: 24px; }
  .avatar.big { width: 84px; height: 84px; font-size: 30px; }
  .sec-head { font-size: 18px; }
  .index-bar { top: 56px; gap: 3px; padding: 6px 0; }
  .index-bar .idx { width: 20px; height: 20px; line-height: 20px; font-size: 11px; }
  .works { grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 10px; }
  /* 弹窗全屏化，方便手机操作 */
  .modal { padding: 0; }
  .modal-panel { max-width: 100%; width: 100%; max-height: 100vh; height: 100vh; border-radius: 0; padding: 22px 16px; }
  .modal-panel.wide { max-width: 100%; }
  .viewer { min-height: 180px; border-radius: 8px; }
  .viewer img, .viewer video { max-height: 320px; }
  /* 后台行式卡片在手机上换行，按钮占满 */
  .arow { flex-wrap: wrap; gap: 10px; }
  .arow .info { flex: 1 1 60%; }
  .arow .ops { width: 100%; justify-content: flex-end; }
  .gate-box { width: 88%; max-width: 340px; padding: 24px 20px; }
  .imgfield .img-up { flex-wrap: wrap; }
  .imgfield .img-up input[type=file] { width: 100%; }
  .mline { flex-wrap: wrap; }
  .mline select { width: 100%; }
  /* 输入框 16px 防止 iOS 聚焦时自动放大；按钮加大更好点 */
  input, textarea, select { font-size: 16px; }
  button { padding: 11px 16px; font-size: 15px; }
  .close { font-size: 30px; top: 10px; right: 12px; }
}
