/* 书架管理页 */

body.admin {
  min-height: 100dvh;
  background: var(--bg);
  overscroll-behavior-y: auto;
}

.admin-wrap {
  width: min(100%, 920px);
  margin: 0 auto;
  padding: calc(28px + env(safe-area-inset-top)) 18px
    calc(40px + env(safe-area-inset-bottom));
}

/* ---------- 头部 ---------- */

.admin-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 24px;
}

.admin-title {
  margin: 12px 0 8px;
  font-family: "Songti SC", "Noto Serif SC", "Source Han Serif SC", "STSong",
    serif;
  font-size: clamp(38px, 9vw, 56px);
  line-height: 1.02;
  letter-spacing: -0.02em;
  font-weight: 600;
}

.admin-lead {
  margin: 0;
  font-size: 13.5px;
  line-height: 1.75;
  color: var(--muted);
  max-width: 34em;
}

.count-pill {
  flex: none;
  margin-top: 6px;
  padding: 7px 13px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--line);
  font-size: 12px;
  letter-spacing: 0.06em;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* ---------- 添加 ---------- */

.add-panel {
  padding: 18px;
  border-radius: 24px;
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: 0 14px 38px rgba(55, 42, 22, 0.09);
}

.add-grid {
  display: grid;
  gap: 12px;
}

@media (min-width: 640px) {
  .add-grid {
    grid-template-columns: minmax(0, 1fr) 116px;
  }
}

.field {
  display: grid;
  gap: 7px;
  min-width: 0;
}

.field-label {
  padding-left: 2px;
  font-size: 11px;
  letter-spacing: 0.16em;
  color: var(--muted);
}

.field input {
  width: 100%;
  height: 50px;
  padding: 0 16px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--paper) 72%, transparent);
  color: var(--ink);
  font-size: 15px;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.field input::placeholder {
  color: var(--muted);
  font-size: 13.5px;
}

.field input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 14%, transparent);
}

.add-btn {
  width: 100%;
  height: 50px;
  margin-top: 12px;
  border-radius: 14px;
  font-size: 15px;
}

.add-btn[disabled] {
  opacity: 0.6;
  cursor: progress;
}

.add-msg {
  margin: 12px 2px 0;
  font-size: 12.5px;
  line-height: 1.65;
  color: #b3452f;
}

html[data-theme="ink"] .add-msg {
  color: #f08b74;
}

.add-hint {
  margin: 10px 2px 0;
  font-size: 11.5px;
  line-height: 1.65;
  color: var(--muted);
}

/* ---------- 搜索 ---------- */

.shelf-tools {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 26px 0 14px;
}

.search {
  flex: 1;
  height: 44px;
  padding: 0 15px;
  border-radius: 13px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  font-size: 14px;
  outline: none;
}

.search:focus {
  border-color: var(--accent);
}

.tools-note {
  flex: none;
  font-size: 11.5px;
  color: var(--muted);
  letter-spacing: 0.04em;
}

/* ---------- 书架 ---------- */

.shelf-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 12px;
}

@media (min-width: 720px) {
  .shelf-list {
    grid-template-columns: 1fr 1fr;
  }
}

.book-card {
  display: grid;
  grid-template-columns: 60px minmax(0, 1fr);
  gap: 14px 14px;
  padding: 14px;
  border-radius: 20px;
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: 0 8px 22px rgba(55, 42, 22, 0.06);
  transition: transform 0.16s ease, box-shadow 0.2s ease;
}

.book-card:active {
  transform: scale(0.995);
}

.cover {
  position: relative;
  width: 60px;
  height: 82px;
  border-radius: 3px 9px 9px 3px;
  background: linear-gradient(145deg, var(--cover-a, #b98d62), var(--cover-b, #8a5a33));
  color: rgba(255, 252, 245, 0.94);
  display: grid;
  place-items: center;
  font-family: "Songti SC", "Noto Serif SC", "STSong", serif;
  font-size: 19px;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-align: center;
  line-height: 1.1;
  padding: 6px;
  overflow: hidden;
  box-shadow: inset -4px 0 8px rgba(0, 0, 0, 0.2),
    inset 4px 0 4px rgba(255, 255, 255, 0.12), 0 3px 8px rgba(40, 28, 14, 0.2);
  cursor: pointer;
}

.cover::before {
  content: "";
  position: absolute;
  left: 5px;
  top: 0;
  bottom: 0;
  width: 1px;
  background: rgba(255, 255, 255, 0.28);
}

.cover span {
  display: block;
  max-height: 3.3em;
  overflow: hidden;
}

.book-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-top: 2px;
  cursor: pointer;
}

.book-title {
  margin: 0;
  font-size: 15.5px;
  font-weight: 600;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  overflow-wrap: anywhere;
}

.book-meta,
.book-date {
  margin: 0;
  font-size: 12px;
  line-height: 1.5;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.book-date {
  font-size: 11px;
  opacity: 0.8;
}

.book-actions {
  grid-column: 1 / -1;
  display: flex;
  gap: 8px;
}

.book-actions button {
  flex: 1;
  min-width: 0;
  height: 38px;
  padding: 0 4px;
  border-radius: 11px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  font-size: 12.5px;
  transition: background 0.18s ease, color 0.18s ease;
  white-space: nowrap;
}

.book-actions button:active {
  background: var(--line);
}

.book-actions .act-read {
  border-color: transparent;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 600;
}

.book-actions .act-delete {
  flex: 0 0 58px;
  color: #b3452f;
}

html[data-theme="ink"] .book-actions .act-delete {
  color: #f08b74;
}

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

.empty {
  padding: 54px 20px 60px;
  text-align: center;
  color: var(--muted);
}

.empty-mark {
  width: 72px;
  height: 72px;
  margin: 0 auto 18px;
  border-radius: 16px 22px 22px 16px;
  display: grid;
  place-items: center;
  background: var(--surface);
  border: 1px dashed var(--line);
  font-family: "Songti SC", "Noto Serif SC", "STSong", serif;
  font-size: 24px;
  color: var(--muted);
}

.empty-title {
  margin: 0 0 8px;
  font-size: 16px;
  font-weight: 600;
  color: var(--ink);
}

.empty-text {
  margin: 0 auto;
  max-width: 26em;
  font-size: 12.5px;
  line-height: 1.8;
}

.admin-foot {
  margin-top: 34px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
  font-size: 11.5px;
  line-height: 1.8;
  color: var(--muted);
}

.admin-foot p {
  margin: 0;
  max-width: 40em;
}

.foot-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 16px;
  margin-top: 10px;
}

.foot-link {
  padding: 0;
  font-size: 11.5px;
  color: var(--accent);
  letter-spacing: 0.04em;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  transition: opacity 0.15s ease;
}

.foot-link:active {
  opacity: 0.6;
}

/* ---------- 管理页弹窗 ---------- */

.modal-card.wide {
  width: min(100%, 400px);
  text-align: left;
}

.qr-wrap canvas {
  display: block;
}

.modal-card.wide h2 {
  text-align: center;
}

.modal-card.wide .modal-lead {
  text-align: center;
}

.share-link {
  width: 100%;
  height: 42px;
  margin-top: 10px;
  padding: 0 12px;
  border-radius: 11px;
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--paper) 70%, transparent);
  color: var(--ink);
  font-size: 11.5px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  outline: none;
}

.share-link:focus {
  border-color: var(--accent);
}

.share-meta {
  margin: 9px 2px 0;
  font-size: 11px;
  line-height: 1.65;
  color: var(--muted);
  text-align: center;
}

/* ---------- 管理密码 ---------- */

.auth-gate {
  max-width: 440px;
  margin: 18px auto 0;
  padding: 22px;
  border-radius: 24px;
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: 0 14px 38px rgba(55, 42, 22, 0.09);
}

.auth-title {
  margin: 0 0 8px;
  font-family: "Songti SC", "Noto Serif SC", "Source Han Serif SC", "STSong",
    serif;
  font-size: 28px;
  font-weight: 600;
}

.auth-lead {
  margin: 0 0 18px;
  font-size: 13px;
  line-height: 1.75;
  color: var(--muted);
}

.auth-btn {
  width: 100%;
  height: 50px;
  margin-top: 14px;
  border-radius: 14px;
  font-size: 15px;
}

.auth-msg {
  margin: 12px 2px 0;
  font-size: 12.5px;
  line-height: 1.6;
  color: #b3452f;
}

html[data-theme="ink"] .auth-msg {
  color: #f08b74;
}

.share-meta.warn {
  color: #b3452f;
}

html[data-theme="ink"] .share-meta.warn {
  color: #f08b74;
}

.preview-stage {
  position: relative;
  margin-top: 14px;
  min-height: 180px;
  max-height: 52vh;
  border-radius: 14px;
  background: color-mix(in srgb, var(--ink) 6%, transparent);
  display: grid;
  place-items: center;
  overflow: hidden;
}

.preview-stage img {
  display: block;
  max-width: 100%;
  max-height: 52vh;
  object-fit: contain;
}

.preview-loading {
  font-size: 12.5px;
  color: var(--muted);
}

.preview-error {
  margin: 0;
  padding: 18px;
  font-size: 12.5px;
  line-height: 1.7;
  color: #b3452f;
  text-align: center;
}

html[data-theme="ink"] .preview-error {
  color: #f08b74;
}

.link-button {
  display: grid;
  place-items: center;
  text-decoration: none;
  height: 46px;
  border-radius: 14px;
  font-size: 14.5px;
}

.danger-solid {
  background: #b3452f;
  color: #fff8f2;
}

@media (min-width: 700px) {
  .admin-wrap {
    padding-left: 28px;
    padding-right: 28px;
  }

  .book-card {
    grid-template-columns: 64px minmax(0, 1fr);
  }

  .cover {
    width: 64px;
    height: 88px;
  }
}
