:root {
  --cream: #f7f3e9;
  --cream-deep: #efe8d7;
  --card: #fffdf7;
  --ink: #2f4237;
  --muted: #78867c;
  --green: #326b55;
  --green-soft: #e2efe6;
  --orange: #e49a56;
  --orange-soft: #fbeedd;
  --line: #e2dbc9;
  --danger: #b4453a;
  --danger-soft: #fbe9e6;
  --shadow: 0 12px 34px rgba(66, 89, 60, 0.12);
  --shadow-soft: 0 4px 14px rgba(66, 89, 60, 0.08);
  --radius: 18px;
  color-scheme: light;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body { margin: 0; }

body {
  min-height: 100vh;
  background:
    radial-gradient(1200px 520px at 12% -10%, #eef4e4 0%, transparent 60%),
    radial-gradient(900px 480px at 92% 4%, #fbeee0 0%, transparent 55%),
    var(--cream);
  color: var(--ink);
  font-family: "Microsoft YaHei", "PingFang SC", "Hiragino Sans GB", system-ui, -apple-system, sans-serif;
  font-size: 15px;
  line-height: 1.6;
}

h1, h2, h3 { margin: 0; line-height: 1.3; }

a { color: var(--green); }

button, input, select { font: inherit; color: inherit; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------- 顶栏 ---------- */

.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 14px clamp(16px, 4vw, 40px);
  background: rgba(247, 243, 233, 0.88);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}

.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }

.brand-mark {
  display: grid; place-items: center;
  width: 44px; height: 44px; flex: none;
  background: var(--green-soft); border-radius: 14px; font-size: 22px;
}

.brand-text h1 { font-size: 19px; letter-spacing: .5px; }
.brand-text p { margin: 0; color: var(--muted); font-size: 12.5px; }

/* ---------- 按钮 ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 16px; border: 1px solid var(--line); border-radius: 999px;
  background: var(--card); color: var(--ink);
  cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: transform .12s ease, box-shadow .12s ease, background .12s ease, border-color .12s ease;
}

.btn:hover { border-color: var(--green); box-shadow: var(--shadow-soft); transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn:focus-visible, .tab:focus-visible, .chip:focus-visible, input:focus-visible, select:focus-visible {
  outline: 3px solid var(--orange); outline-offset: 2px;
}

.btn-primary { background: var(--green); border-color: var(--green); color: #fff; font-weight: 600; }
.btn-primary:hover { background: #295944; }
.btn-primary:disabled { opacity: .6; cursor: progress; transform: none; }
.btn-ghost { background: transparent; border-color: transparent; font-size: 18px; padding: 4px 10px; }
.btn-small { padding: 6px 13px; font-size: 13.5px; }

/* ---------- 展馆标签 ---------- */

.tabs {
  display: flex; gap: 8px; flex-wrap: wrap;
  padding: 18px clamp(16px, 4vw, 40px) 0;
  max-width: 1360px; margin: 0 auto;
}

.tab {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 20px; border: 1px solid var(--line); border-radius: 999px;
  background: var(--card); cursor: pointer; font-size: 15px;
  transition: background .12s ease, box-shadow .12s ease, transform .12s ease;
}
.tab:hover { box-shadow: var(--shadow-soft); transform: translateY(-1px); }
.tab.is-active { background: var(--green); border-color: var(--green); color: #fff; font-weight: 600; }
.tab-count {
  min-width: 24px; padding: 0 7px; border-radius: 999px;
  background: var(--cream-deep); color: var(--muted);
  font-size: 12px; line-height: 20px; text-align: center;
}
.tab.is-active .tab-count { background: rgba(255, 255, 255, 0.24); color: #fff; }

/* ---------- 工具栏 ---------- */

.toolbar {
  display: flex; gap: 12px; flex-wrap: wrap;
  max-width: 1360px; margin: 0 auto;
  padding: 14px clamp(16px, 4vw, 40px);
}

.field { display: flex; }
.field.grow { flex: 1 1 260px; min-width: 200px; }

.toolbar input, .toolbar select {
  width: 100%; padding: 10px 14px;
  border: 1px solid var(--line); border-radius: 12px; background: var(--card);
}
.toolbar select { cursor: pointer; }
.toolbar input::placeholder { color: #a8b0a5; }

/* ---------- 列表 ---------- */

main { max-width: 1360px; margin: 0 auto; padding: 0 clamp(16px, 4vw, 40px) 48px; }

.result-meta { margin: 4px 2px 14px; color: var(--muted); font-size: 13px; }

.grid {
  display: grid; gap: 22px;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
}

.card {
  display: flex; flex-direction: column; overflow: hidden;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
  transition: transform .16s ease, box-shadow .16s ease;
}
.card:hover { transform: translateY(-3px); box-shadow: var(--shadow); }

.preview {
  position: relative; display: block; width: 100%;
  border-bottom: 1px solid var(--line); background: #fff;
  aspect-ratio: 4 / 3; overflow: hidden;
}

.preview-frame {
  width: 100%; height: 100%; border: 0; display: block;
  pointer-events: none; background: #fff;
}

.preview-cover {
  position: absolute; inset: 0; padding: 0;
  border: 0; background: transparent; cursor: pointer;
}
.preview-cover:focus-visible { outline: 3px solid var(--orange); outline-offset: -3px; }

.preview-badge {
  position: absolute; top: 10px; left: 10px;
  padding: 3px 10px; border-radius: 999px;
  background: rgba(50, 107, 85, 0.86); color: #fff; font-size: 12px;
  pointer-events: none;
}

.preview-hint {
  position: absolute; right: 10px; bottom: 10px;
  padding: 3px 10px; border-radius: 999px;
  background: rgba(47, 66, 55, 0.72); color: #fff; font-size: 12px;
  opacity: 0; transition: opacity .16s ease; pointer-events: none;
}
.card:hover .preview-hint { opacity: 1; }

.card-body { flex: 1; padding: 14px 16px 6px; }

.card-title {
  font-size: 16px; font-weight: 600;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}

.card-meta {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  margin: 8px 0 0; font-size: 13px;
}

.tag.author {
  padding: 2px 10px; border-radius: 999px;
  background: var(--orange-soft); color: #9a5c1d; font-weight: 600;
}

.time { color: var(--muted); }

.card-sub {
  margin: 6px 0 0; color: var(--muted); font-size: 12.5px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.card-actions { display: flex; gap: 8px; padding: 12px 16px 16px; }

/* ---------- 空状态 ---------- */

.empty {
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  padding: 64px 24px; text-align: center;
  background: rgba(255, 253, 247, 0.7);
  border: 1px dashed var(--line); border-radius: var(--radius);
}
.empty-emoji { font-size: 46px; margin: 0; }
.empty h2 { font-size: 19px; }
.empty p { margin: 0; color: var(--muted); max-width: 460px; }
.empty .btn { margin-top: 8px; }

/* ---------- 页脚 ---------- */

.foot {
  display: flex; gap: 8px 26px; flex-wrap: wrap; justify-content: center;
  padding: 22px clamp(16px, 4vw, 40px) 34px;
  border-top: 1px solid var(--line); color: var(--muted); font-size: 12.5px;
}

/* ---------- 弹窗 ---------- */

.modal {
  width: min(560px, 94vw); padding: 0;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--card); color: var(--ink); box-shadow: var(--shadow);
  max-height: 92vh;
}
.modal::backdrop { background: rgba(38, 50, 42, 0.5); backdrop-filter: blur(3px); }
.modal-wide { width: min(1060px, 96vw); }

.modal-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
  padding: 18px 20px 12px; border-bottom: 1px solid var(--line);
}
.modal-head h2 { font-size: 17px; }

.modal-body { padding: 16px 20px 4px; max-height: 62vh; overflow: auto; }

.modal-foot {
  display: flex; justify-content: flex-end; gap: 10px;
  padding: 14px 20px 18px; border-top: 1px solid var(--line);
}

/* ---------- 表单 ---------- */

.form-row { display: block; margin-bottom: 16px; }
.form-label { display: block; margin-bottom: 6px; font-size: 13.5px; color: var(--muted); }
.form-label em { font-style: normal; color: var(--orange); font-size: 12px; }

.form-row input[type="text"], .form-row > select {
  width: 100%; padding: 10px 14px;
  border: 1px solid var(--line); border-radius: 12px; background: #fff;
}

.chips { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: -6px 0 16px; }
.chips-label { color: var(--muted); font-size: 13px; }
.chip {
  padding: 4px 12px; border: 1px solid var(--line); border-radius: 999px;
  background: var(--cream-deep); cursor: pointer; font-size: 13px;
}
.chip:hover { border-color: var(--green); background: var(--green-soft); }

.dropzone {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 22px 16px; text-align: center;
  border: 1.5px dashed var(--line); border-radius: 14px;
  background: #fff; cursor: pointer; transition: border-color .12s ease, background .12s ease;
}
.dropzone:hover, .dropzone.is-dragging { border-color: var(--green); background: var(--green-soft); }
.dropzone-icon { font-size: 26px; }
.dropzone-main { font-weight: 600; word-break: break-all; }
.dropzone-hint { color: var(--muted); font-size: 12.5px; }

.form-status { margin: 0 0 12px; font-size: 13.5px; }
.status-info { color: var(--muted); }
.status-error { color: var(--danger); }
.status-success { color: var(--green); font-weight: 600; }

.progress {
  height: 8px; margin: 0 0 16px; border-radius: 999px;
  background: var(--cream-deep); overflow: hidden;
}
.progress-bar {
  height: 100%; width: 0;
  background: linear-gradient(90deg, var(--green), var(--orange));
  border-radius: 999px; transition: width .2s ease;
}
.progress-bar.is-indeterminate {
  width: 40% !important; animation: slide 1.1s ease-in-out infinite;
}

@keyframes slide {
  0% { margin-left: -40%; }
  100% { margin-left: 100%; }
}

/* ---------- 预览弹窗 ---------- */

.viewer-title-wrap { min-width: 0; }
.viewer-meta { margin: 2px 0 0; color: var(--muted); font-size: 12.5px; }
.viewer-stage { background: #fff; height: min(72vh, 780px); }
#viewer-frame { width: 100%; height: 100%; border: 0; display: block; background: #fff; }

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

.toast {
  position: fixed; left: 50%; bottom: 28px; z-index: 60;
  transform: translateX(-50%);
  padding: 11px 22px; border-radius: 999px;
  background: var(--ink); color: #fff; font-size: 14px; box-shadow: var(--shadow);
  animation: rise .2s ease;
}
.toast-success { background: var(--green); }
.toast-error { background: var(--danger); }

@keyframes rise {
  from { opacity: 0; transform: translate(-50%, 12px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

/* ---------- 响应式 ---------- */

@media (max-width: 720px) {
  .topbar { flex-wrap: wrap; }
  .brand-text h1 { font-size: 17px; }
  .toolbar { padding-top: 10px; }
  .toolbar .field { flex: 1 1 100%; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }
  .modal-body { max-height: 58vh; }
  .viewer-stage { height: 60vh; }
  .preview-hint { display: none; }
}
@media (max-width: 480px) {
  body { font-size: 14px; padding-bottom: env(safe-area-inset-bottom); }
  .topbar { gap: 10px; padding: 10px 14px; }
  .brand { flex: 1 1 100%; }
  .brand-mark { width: 38px; height: 38px; border-radius: 12px; font-size: 19px; }
  .brand-text h1 { font-size: 16px; }
  .brand-text p { font-size: 11px; }
  .topbar > .btn { width: 100%; min-height: 42px; }
  .tabs { flex-wrap: nowrap; overflow-x: auto; padding: 12px 14px 0; scrollbar-width: none; }
  .tabs::-webkit-scrollbar { display: none; }
  .tab { flex: 0 0 auto; padding: 9px 15px; }
  .toolbar { gap: 8px; padding: 10px 14px; }
  .toolbar .field { min-width: 0; }
  .toolbar input, .toolbar select { min-height: 42px; }
  main { padding: 0 14px 34px; }
  .grid { grid-template-columns: 1fr; gap: 14px; }
  .preview { aspect-ratio: 16 / 11; }
  .card-actions { padding: 10px 12px 13px; }
  .card-actions .btn { flex: 1; min-height: 40px; padding-inline: 8px; }
  .modal, .modal-wide { width: calc(100vw - 20px); max-height: calc(100dvh - 20px); border-radius: 14px; }
  .modal-head { padding: 14px 14px 10px; }
  .modal-body { padding: 14px 14px 2px; max-height: 64dvh; }
  .modal-foot { padding: 11px 14px 14px; }
  .modal-foot .btn { flex: 1; min-height: 42px; }
  .viewer-stage { height: 58dvh; min-height: 280px; }
  .viewer-meta { overflow-wrap: anywhere; }
  .dropzone { padding: 20px 12px; }
  .foot { padding: 18px 14px 26px; text-align: center; }
  .toast { width: calc(100vw - 28px); bottom: calc(14px + env(safe-area-inset-bottom)); text-align: center; }
}

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