/* ==========================================================================
   期刊定位检索 · 视觉样式
   纸质卡片目录的质感：暖纸底 + 墨绿主色 + 宋体标题
   ========================================================================== */

:root {
  --ink: #191713;
  --ink-2: #4d473d;
  --ink-3: #8b8474;
  --paper: #f4efe3;
  --card: #fffdf8;
  --line: #e5dbc7;
  --line-2: #d5c8ad;
  --accent: #155a4d;
  --accent-2: #0d4038;
  --accent-soft: #e2efe9;
  --gold: #a8762a;
  --gold-soft: #f7ead1;
  --danger: #a3342b;
  --radius: 14px;
  --shadow-sm: 0 1px 2px rgba(25, 23, 19, 0.05);
  --shadow: 0 1px 2px rgba(25, 23, 19, 0.05), 0 10px 28px -14px rgba(25, 23, 19, 0.3);
  --serif: "Songti SC", "Source Han Serif SC", "Noto Serif CJK SC", "SimSun", Georgia, serif;
  --sans: "PingFang SC", "HarmonyOS Sans SC", "Microsoft YaHei", "Noto Sans CJK SC", system-ui, -apple-system,
    "Segoe UI", sans-serif;
  --mono: "SFMono-Regular", "Cascadia Mono", Consolas, monospace;
}

* {
  box-sizing: border-box;
}

/* hidden 属性必须能压过下面所有 display 声明 */
[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.6;
  color: var(--ink);
  background:
    radial-gradient(1100px 560px at 12% -12%, #fcf8ef 0%, rgba(252, 248, 239, 0) 62%),
    radial-gradient(900px 520px at 100% 0%, #edf3ee 0%, rgba(237, 243, 238, 0) 58%),
    var(--paper);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a {
  color: var(--accent);
  text-decoration: none;
}

button {
  font-family: inherit;
}

.wrap {
  width: min(880px, 100% - 40px);
  margin: 0 auto;
}

.wrap-wide {
  width: min(1180px, 100% - 40px);
  margin: 0 auto;
}

/* ───────────────────────── 顶栏 ───────────────────────── */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: blur(10px);
  background: rgba(244, 239, 227, 0.82);
  border-bottom: 1px solid rgba(213, 200, 173, 0.55);
}

.topbar-inner {
  height: 62px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--ink);
}

.brand-mark {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: var(--accent);
  color: #f7f3e8;
  display: grid;
  place-items: center;
  font-family: var(--serif);
  font-size: 17px;
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.18);
}

.brand small {
  font-weight: 400;
  color: var(--ink-3);
  font-size: 12px;
  letter-spacing: 0.06em;
  margin-left: 2px;
}

.topbar .spacer {
  flex: 1;
}

.ghost-link {
  font-size: 13px;
  color: var(--ink-3);
  padding: 7px 12px;
  border-radius: 8px;
  border: 1px solid transparent;
  transition: 0.16s;
}

.ghost-link:hover {
  color: var(--accent);
  border-color: var(--line-2);
  background: rgba(255, 253, 248, 0.7);
}

/* ───────────────────────── 首屏 ───────────────────────── */

.hero {
  padding: 54px 0 26px;
  text-align: center;
}

.hero h1 {
  font-family: var(--serif);
  font-size: clamp(28px, 5vw, 40px);
  font-weight: 600;
  letter-spacing: 0.02em;
  margin: 0 0 10px;
}

.hero h1 em {
  font-style: normal;
  color: var(--accent);
  position: relative;
  white-space: nowrap;
}

.hero h1 em::after {
  content: "";
  position: absolute;
  left: 2%;
  right: 2%;
  bottom: 2px;
  height: 8px;
  background: var(--gold-soft);
  border-radius: 4px;
  z-index: -1;
}

.hero p {
  margin: 0;
  color: var(--ink-3);
  font-size: 14.5px;
}

/* ───────────────────────── 搜索框 ───────────────────────── */

.searchbox {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 26px 0 14px;
  padding: 4px 6px 4px 18px;
  background: var(--card);
  border: 1.5px solid var(--line-2);
  border-radius: 16px;
  box-shadow: var(--shadow);
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.searchbox:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(21, 90, 77, 0.09), var(--shadow);
}

.searchbox svg {
  flex: none;
  color: var(--ink-3);
}

.searchbox input[type="search"] {
  flex: 1;
  min-width: 0;
  border: 0;
  border-radius: 0;
  outline: 0;
  background: transparent;
  box-shadow: none;
  -webkit-appearance: none;
  appearance: none;
  font-family: var(--sans);
  font-size: 19px;
  color: var(--ink);
  padding: 16px 0;
}

.searchbox input[type="search"]:focus {
  border: 0;
  box-shadow: none;
}

.searchbox input[type="search"]::-webkit-search-cancel-button {
  -webkit-appearance: none;
  appearance: none;
}

.searchbox input::placeholder {
  color: #b3aa99;
}

.searchbox .kbd {
  flex: none;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--ink-3);
  border: 1px solid var(--line-2);
  border-bottom-width: 2px;
  border-radius: 6px;
  padding: 2px 7px;
  margin-right: 8px;
}

.searchbox .clear-btn {
  flex: none;
  border: 0;
  background: transparent;
  color: var(--ink-3);
  cursor: pointer;
  font-size: 18px;
  padding: 6px 10px;
  border-radius: 8px;
  display: none;
}

.searchbox .clear-btn:hover {
  background: var(--paper);
  color: var(--ink);
}

.searchbox.has-value .clear-btn {
  display: block;
}

.searchbox.has-value .kbd {
  display: none;
}

/* 区域筛选 */
.chips {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 22px;
}

.chip {
  border: 1px solid var(--line-2);
  background: rgba(255, 253, 248, 0.6);
  color: var(--ink-2);
  font-size: 13px;
  padding: 5px 13px;
  border-radius: 999px;
  cursor: pointer;
  transition: 0.15s;
}

.chip:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.chip[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.chips .meta {
  margin-left: auto;
  font-size: 12.5px;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}

/* ───────────────────────── 结果列表 ───────────────────────── */

.results {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-bottom: 80px;
}

.result-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  font-size: 13px;
  color: var(--ink-3);
  margin: 6px 2px 2px;
}

.result-head b {
  color: var(--accent);
  font-weight: 600;
}

.hit {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 20px 16px;
  box-shadow: var(--shadow-sm);
  transition: transform 0.16s ease, box-shadow 0.16s ease, border-color 0.16s;
  animation: rise 0.32s ease both;
}

.hit:hover {
  transform: translateY(-1px);
  border-color: var(--line-2);
  box-shadow: var(--shadow);
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.hit-title {
  font-family: var(--serif);
  font-size: 21px;
  font-weight: 600;
  line-height: 1.35;
  margin: 0;
  letter-spacing: 0.01em;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.hit-title mark {
  background: linear-gradient(transparent 58%, #f8dfa4 58%);
  color: inherit;
  padding: 0 1px;
  border-radius: 2px;
}

.badge {
  font-family: var(--sans);
  font-size: 11.5px;
  font-weight: 500;
  letter-spacing: 0.04em;
  padding: 2px 9px;
  border-radius: 999px;
  border: 1px solid transparent;
  white-space: nowrap;
}

.badge.on {
  background: var(--accent-soft);
  color: var(--accent-2);
  border-color: #c6ded4;
}

.badge.off {
  background: #efe9df;
  color: #7a7263;
  border-color: var(--line-2);
}

.hit-meta {
  margin: 6px 0 0;
  font-size: 13px;
  color: var(--ink-3);
}

/* 定位条 —— 这是整个页面的答案 */
.loc {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 13px;
  padding-top: 13px;
  border-top: 1px dashed var(--line-2);
  flex-wrap: wrap;
}

.loc-parts {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 14.5px;
  color: var(--ink-2);
}

.loc-parts .seg {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 2px 10px;
  font-variant-numeric: tabular-nums;
}

.loc-parts .seg.strong {
  background: #fff;
  border-color: var(--line-2);
  color: var(--ink);
  font-weight: 500;
}

.loc-fill {
  flex: 1 1 40px;
  min-width: 24px;
  border-bottom: 1px dotted var(--line-2);
  transform: translateY(-3px);
}

.loc-row {
  display: inline-flex;
  align-items: baseline;
  gap: 5px;
  background: var(--accent);
  color: #fff;
  border-radius: 10px;
  padding: 6px 14px 7px;
  box-shadow: 0 4px 12px -6px rgba(13, 64, 56, 0.75);
  white-space: nowrap;
}

.loc-row .label {
  font-size: 12.5px;
  opacity: 0.78;
  letter-spacing: 0.04em;
}

.loc-row .num {
  font-family: var(--serif);
  font-size: 21px;
  font-weight: 600;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.loc-row.empty {
  background: #efe9df;
  color: #7a7263;
  box-shadow: none;
}

.hit-note {
  margin: 10px 0 0;
  font-size: 12.5px;
  color: var(--ink-3);
  background: var(--paper);
  border-left: 3px solid var(--line-2);
  padding: 6px 10px;
  border-radius: 0 6px 6px 0;
}

/* ───────────────────────── 状态页 ───────────────────────── */

.state {
  text-align: center;
  padding: 46px 20px 70px;
  color: var(--ink-3);
}

.state .glyph {
  font-family: var(--serif);
  font-size: 40px;
  color: var(--line-2);
  line-height: 1;
  margin-bottom: 14px;
}

.state h3 {
  margin: 0 0 6px;
  font-size: 16px;
  font-weight: 600;
  color: var(--ink-2);
}

.state p {
  margin: 4px 0;
  font-size: 13.5px;
}

.state .hint {
  display: inline-block;
  margin-top: 14px;
  padding: 8px 14px;
  border-radius: 10px;
  background: rgba(255, 253, 248, 0.75);
  border: 1px dashed var(--line-2);
  font-size: 13px;
}

.fuzzy-note {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--ink-3);
  background: var(--gold-soft);
  border: 1px solid #ecd7a9;
  border-radius: 10px;
  padding: 8px 13px;
  margin-bottom: 2px;
}

/* 骨架屏 */
.skel {
  height: 96px;
  border-radius: var(--radius);
  background: linear-gradient(100deg, #f0eade 30%, #f8f4ea 50%, #f0eade 70%);
  background-size: 220% 100%;
  animation: shimmer 1.2s infinite linear;
  border: 1px solid var(--line);
}

@keyframes shimmer {
  to {
    background-position: -120% 0;
  }
}

/* ───────────────────────── 页脚 ───────────────────────── */

.footer {
  flex: none;
  padding: 26px 0 40px;
  text-align: center;
  font-size: 12.5px;
  color: #a49c8b;
  border-top: 1px solid rgba(213, 200, 173, 0.4);
}

/* ───────────────────────── 通用控件 ───────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 1px solid var(--line-2);
  background: var(--card);
  color: var(--ink-2);
  font-size: 13.5px;
  font-weight: 500;
  padding: 8px 15px;
  border-radius: 9px;
  cursor: pointer;
  transition: 0.15s;
  white-space: nowrap;
}

.btn:hover {
  border-color: var(--ink-3);
  color: var(--ink);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  box-shadow: 0 4px 12px -8px rgba(13, 64, 56, 0.9);
}

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

.btn.danger {
  color: var(--danger);
  border-color: #e3c4bf;
}

.btn.danger:hover {
  background: #fbf0ee;
  border-color: var(--danger);
}

.btn.sm {
  font-size: 12.5px;
  padding: 5px 11px;
  border-radius: 7px;
}

input[type="text"],
input[type="password"],
input[type="search"],
select,
textarea {
  font-family: var(--sans);
  font-size: 14px;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line-2);
  border-radius: 8px;
  padding: 8px 11px;
  outline: 0;
  width: 100%;
  transition: border-color 0.15s, box-shadow 0.15s;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(21, 90, 77, 0.08);
}

/* ───────────────────────── 后台 ───────────────────────── */

.admin-body {
  background:
    radial-gradient(900px 480px at 8% -10%, #fcf8ef 0%, rgba(252, 248, 239, 0) 60%),
    var(--paper);
}

.login-shell {
  min-height: calc(100vh - 62px);
  display: grid;
  place-items: center;
  padding: 40px 20px 80px;
}

.login-card {
  width: min(380px, 100%);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 32px 28px 28px;
  box-shadow: var(--shadow);
}

.login-card h2 {
  font-family: var(--serif);
  font-size: 22px;
  margin: 0 0 4px;
}

.login-card p {
  margin: 0 0 22px;
  font-size: 13px;
  color: var(--ink-3);
}

.field {
  margin-bottom: 16px;
}

.field label {
  display: block;
  font-size: 12.5px;
  color: var(--ink-2);
  margin-bottom: 6px;
  letter-spacing: 0.02em;
}

.field .req {
  color: var(--danger);
  margin-left: 2px;
}

.field-hint {
  font-size: 12px;
  color: var(--ink-3);
  margin-top: 5px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0 16px;
}

.form-grid .col-2 {
  grid-column: 1 / -1;
}

.alert {
  font-size: 13px;
  padding: 9px 13px;
  border-radius: 9px;
  margin-bottom: 14px;
  display: none;
}

.alert.show {
  display: block;
}

.alert.err {
  background: #fbf0ee;
  border: 1px solid #e8cbc6;
  color: var(--danger);
}

.alert.ok {
  background: var(--accent-soft);
  border: 1px solid #c6ded4;
  color: var(--accent-2);
}

/* 后台主体 */
.admin-main {
  padding: 26px 0 90px;
}

.admin-head {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.admin-head h1 {
  font-family: var(--serif);
  font-size: 24px;
  margin: 0;
  font-weight: 600;
}

.stat-row {
  display: flex;
  gap: 22px;
  margin: 0 0 20px;
  flex-wrap: wrap;
}

.stat {
  display: flex;
  align-items: baseline;
  gap: 7px;
  font-size: 13px;
  color: var(--ink-3);
}

.stat b {
  font-family: var(--serif);
  font-size: 20px;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.toolbar {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.toolbar .grow {
  flex: 1;
  min-width: 200px;
}

.toolbar input[type="search"] {
  max-width: 340px;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.table-wrap {
  overflow-x: auto;
}

table.grid {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

table.grid th,
table.grid td {
  text-align: left;
  padding: 11px 14px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
  white-space: nowrap;
}

table.grid th {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-3);
  letter-spacing: 0.05em;
  background: #faf6ec;
  position: sticky;
  top: 0;
}

table.grid tbody tr:hover {
  background: #fdfaf3;
}

table.grid td.title-cell {
  white-space: normal;
  min-width: 180px;
  font-family: var(--serif);
  font-size: 15px;
}

table.grid .muted {
  color: var(--ink-3);
}

.loc-mini {
  font-variant-numeric: tabular-nums;
  font-size: 13px;
  color: var(--ink-2);
}

.loc-mini b {
  color: var(--accent);
}

.row-actions {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
}

.pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  font-size: 13px;
  color: var(--ink-3);
  flex-wrap: wrap;
}

/* 弹窗 */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(25, 23, 19, 0.42);
  backdrop-filter: blur(2px);
  display: none;
  place-items: center;
  z-index: 60;
  padding: 20px;
}

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

.modal {
  width: min(720px, 100%);
  max-height: 90vh;
  overflow-y: auto;
  background: var(--card);
  border-radius: 18px;
  box-shadow: 0 24px 60px -20px rgba(25, 23, 19, 0.5);
  padding: 24px 26px 20px;
  animation: rise 0.2s ease both;
}

.modal h3 {
  font-family: var(--serif);
  font-size: 20px;
  margin: 0 0 18px;
  font-weight: 600;
}

.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding-top: 14px;
  margin-top: 6px;
  border-top: 1px solid var(--line);
  position: sticky;
  bottom: -20px;
  background: var(--card);
}

.section-label {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--ink-3);
  margin: 20px 0 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.section-label::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}

/* 导入 */
.dropzone {
  border: 1.5px dashed var(--line-2);
  border-radius: 12px;
  padding: 30px 20px;
  text-align: center;
  color: var(--ink-3);
  background: #fdfaf3;
  cursor: pointer;
  transition: 0.16s;
  font-size: 13.5px;
}

.dropzone:hover,
.dropzone.drag {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-2);
}

.dropzone b {
  display: block;
  font-size: 15px;
  color: var(--ink);
  margin-bottom: 4px;
}

.mapping-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  margin-top: 14px;
}

.mapping-table th,
.mapping-table td {
  border: 1px solid var(--line);
  padding: 6px 9px;
  text-align: left;
}

.mapping-table th {
  background: #faf6ec;
  font-weight: 600;
  font-size: 12px;
  color: var(--ink-3);
}

.import-summary {
  font-size: 13px;
  color: var(--ink-2);
  margin-top: 12px;
}

.progress {
  height: 6px;
  background: var(--line);
  border-radius: 99px;
  overflow: hidden;
  margin-top: 10px;
}

.progress > i {
  display: block;
  height: 100%;
  width: 0;
  background: var(--accent);
  transition: width 0.2s;
}

.rejected-list {
  max-height: 150px;
  overflow: auto;
  font-size: 12.5px;
  color: var(--danger);
  margin-top: 10px;
  padding-left: 16px;
}

/* Toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: 30px;
  transform: translate(-50%, 20px);
  background: var(--ink);
  color: #fdfaf3;
  font-size: 13.5px;
  padding: 10px 18px;
  border-radius: 10px;
  opacity: 0;
  pointer-events: none;
  transition: 0.22s;
  z-index: 90;
  box-shadow: 0 12px 30px -12px rgba(0, 0, 0, 0.5);
  max-width: 90vw;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

.toast.err {
  background: var(--danger);
}

/* 空状态 */
.empty {
  padding: 60px 20px;
  text-align: center;
  color: var(--ink-3);
  font-size: 14px;
}

/* ───────────────────────── 响应式 ───────────────────────── */

@media (max-width: 640px) {
  .wrap,
  .wrap-wide {
    width: calc(100% - 28px);
  }

  .brand {
    white-space: nowrap;
    font-size: 14.5px;
    gap: 8px;
  }

  .brand small {
    display: none;
  }

  .ghost-link {
    white-space: nowrap;
    font-size: 12.5px;
    padding: 6px 7px;
  }

  .hero {
    padding: 34px 0 18px;
  }

  .searchbox {
    margin: 18px 0 12px;
    padding-left: 14px;
  }

  .searchbox input[type="search"] {
    font-size: 17px;
    padding: 13px 0;
  }

  .hit {
    padding: 16px 16px 14px;
  }

  .hit-title {
    font-size: 18.5px;
  }

  .loc-row .num {
    font-size: 19px;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .toolbar input[type="search"] {
    max-width: none;
  }

  .chips .meta {
    margin-left: 0;
    width: 100%;
  }
}

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