/* ==========================================================================
   班级图书角 · 样式
   ========================================================================== */

:root {
  --paper: #fbf6ee;
  --paper-2: #f4ece0;
  --card: #ffffff;
  --ink: #2f2a26;
  --ink-2: #5b5148;
  --muted: #948a80;
  --line: #ece2d5;
  --primary: #f4813f;
  --primary-dark: #d96a26;
  --primary-soft: #fff1e6;
  --teal: #21a394;
  --teal-soft: #e6f7f4;
  --red: #e2564a;
  --red-soft: #fdeceb;
  --amber: #e6a03a;
  --amber-soft: #fdf3e2;
  --blue: #4a7fd8;
  --blue-soft: #ecf2fd;
  --shadow-sm: 0 1px 2px rgba(78, 61, 44, .06), 0 2px 8px rgba(78, 61, 44, .05);
  --shadow-md: 0 6px 24px rgba(78, 61, 44, .10);
  --shadow-lg: 0 18px 48px rgba(78, 61, 44, .18);
  --r-sm: 10px;
  --r-md: 16px;
  --r-lg: 22px;
}

* { box-sizing: border-box; }

/* hidden 属性必须能覆盖组件自身的 display 声明 */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

/* 防止微信 / iOS 自动放大文字；去掉点按时的灰色高亮块 */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Noto Sans SC", sans-serif;
  color: var(--ink);
  background: var(--paper);
  background-image:
    radial-gradient(circle at 12% 8%, rgba(244, 129, 63, .09), transparent 42%),
    radial-gradient(circle at 88% 4%, rgba(33, 163, 148, .08), transparent 38%);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  line-height: 1.6;
}

h1, h2, h3, h4 { margin: 0; font-weight: 700; letter-spacing: -.01em; }
p { margin: 0; }
button { font: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, textarea { font: inherit; color: inherit; }
code {
  background: var(--paper-2);
  padding: 1px 6px;
  border-radius: 6px;
  font-size: .88em;
}

/* ---------------------------- 通用组件 ---------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 600;
  transition: transform .14s ease, box-shadow .14s ease, background .14s ease;
  white-space: nowrap;
}
.btn:active { transform: scale(.97); }
.btn-primary {
  background: linear-gradient(135deg, #ff9a5a, var(--primary));
  color: #fff;
  box-shadow: 0 4px 14px rgba(244, 129, 63, .34);
}
.btn-primary:hover { box-shadow: 0 6px 20px rgba(244, 129, 63, .46); }
.btn-ghost {
  background: #fff;
  border: 1.5px solid var(--line);
  color: var(--ink-2);
}
.btn-ghost:hover { border-color: #dccfbe; background: #fffdfa; }
.btn-teal { background: var(--teal); color: #fff; box-shadow: 0 4px 14px rgba(33, 163, 148, .3); }
.btn-danger { background: #fff; border: 1.5px solid #f2c9c5; color: var(--red); }
.btn-danger:hover { background: var(--red-soft); }
.btn-sm { padding: 7px 14px; font-size: 13px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-width: 38px;
  height: 38px;
  padding: 0 12px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-2);
  background: #fff;
  border: 1.5px solid var(--line);
  transition: background .14s ease, border-color .14s ease;
  position: relative;
}
.icon-btn:hover { background: #fffdfa; border-color: #dccfbe; }

.badge {
  position: absolute;
  top: -5px;
  right: -5px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--red);
  color: #fff;
  font-size: 11px;
  font-style: normal;
  font-weight: 700;
  line-height: 18px;
  text-align: center;
}

.count-pill {
  display: inline-block;
  min-width: 22px;
  padding: 1px 8px;
  margin-left: 4px;
  border-radius: 999px;
  background: var(--paper-2);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  vertical-align: middle;
}

.muted { color: var(--muted); font-size: 13px; }
.ta-right { text-align: right; }
.ta-center { text-align: center; }

/* ---------------------------- 登录页 ---------------------------- */

.login-wrap {
  min-height: 100vh;
  min-height: 100dvh; /* 移动端地址栏 / 微信工具栏收起展开时不会被顶出屏幕 */
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
}

.login-card {
  width: 100%;
  max-width: 420px;
  background: var(--card);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  padding: 34px 30px 26px;
  border: 1px solid var(--line);
}

.login-brand { text-align: center; margin-bottom: 26px; }
.login-logo {
  font-size: 52px;
  line-height: 1;
  margin-bottom: 12px;
  filter: drop-shadow(0 8px 16px rgba(244, 129, 63, .3));
}
.login-brand h1 { font-size: 25px; }
.login-sub {
  margin-top: 8px;
  font-size: 13.5px;
  color: var(--muted);
  line-height: 1.7;
}

.field { display: block; margin-bottom: 15px; }
.field-label {
  display: block;
  font-size: 13px;
  font-weight: 700;
  color: var(--ink-2);
  margin-bottom: 6px;
}
.field input {
  width: 100%;
  padding: 12px 15px;
  border-radius: var(--r-sm);
  border: 1.5px solid var(--line);
  background: #fffdfa;
  font-size: 15px;
  outline: none;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.field input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px var(--primary-soft);
  background: #fff;
}

.form-error {
  margin: -4px 0 12px;
  padding: 9px 13px;
  border-radius: var(--r-sm);
  background: var(--red-soft);
  color: var(--red);
  font-size: 13.5px;
  font-weight: 600;
}

.login-help {
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px dashed var(--line);
  font-size: 12.5px;
  color: var(--muted);
  line-height: 1.8;
}
.login-help p + p { margin-top: 6px; }
.login-help strong { color: var(--ink-2); }
.login-help a { color: var(--primary-dark); font-weight: 700; text-decoration: none; }
.login-help a:hover { text-decoration: underline; }

.link-back {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-bottom: 14px;
  padding: 4px 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  transition: color .14s ease;
}
.link-back:hover { color: var(--primary-dark); }

/* ---------------------------- 管理控制台 ---------------------------- */

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 0 14px;
}
.form-grid .field { margin-bottom: 15px; }

.brand-class {
  padding: 2px 10px;
  margin-left: 2px;
  border-radius: 999px;
  background: var(--paper-2);
  color: var(--ink-2);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
  max-width: 40vw;
  overflow: hidden;
  text-overflow: ellipsis;
}

.code-chip {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 8px;
  background: var(--paper-2);
  border: 1px solid var(--line);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: .08em;
  color: var(--primary-dark);
}

.link-cell { display: flex; align-items: center; gap: 8px; }
.link-text {
  display: inline-block;
  max-width: 230px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  color: var(--blue);
}

/* 管理控制台 · 班级列表布局 */
.cls-cell b { display: block; }
.cls-cell .muted { display: block; font-size: 12.5px; margin-top: 1px; }
.table .col-code { width: 120px; white-space: nowrap; }
.table .col-code .code-chip { max-width: 116px; overflow: hidden; text-overflow: ellipsis; vertical-align: middle; }
.table .col-link { width: 210px; }
.table .col-link .link-text { max-width: 128px; }
.ops-cell { display: flex; align-items: center; justify-content: flex-end; gap: 6px; white-space: nowrap; }
.more-wrap { position: relative; display: inline-block; }
.more-menu {
  display: none;
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  z-index: 60;
  min-width: 108px;
  padding: 4px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(60, 42, 20, .14);
}
.more-menu.open { display: block; }
.more-menu button {
  display: block;
  width: 100%;
  padding: 7px 12px;
  border: none;
  border-radius: 7px;
  background: none;
  text-align: left;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  cursor: pointer;
  white-space: nowrap;
}
.more-menu button:hover { background: var(--paper-2); }
.more-menu button.danger { color: var(--red); }

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

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgba(251, 246, 238, .9);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--line);
}

.topbar-inner {
  max-width: 1180px;
  margin: 0 auto;
  padding: 12px 20px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.brand { display: flex; align-items: center; gap: 9px; }
.brand-logo { font-size: 24px; }
.brand-name { font-size: 17px; font-weight: 800; letter-spacing: -.02em; }

.topbar-right { display: flex; align-items: center; gap: 9px; }

.user-chip {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 4px 14px 4px 4px;
  background: #fff;
  border: 1.5px solid var(--line);
  border-radius: 999px;
}
.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #ffb27a, var(--primary));
  color: #fff;
  font-weight: 800;
  font-size: 14px;
}
.user-meta { display: flex; flex-direction: column; line-height: 1.25; }
.user-meta b { font-size: 13.5px; }
.user-meta small { font-size: 11px; color: var(--muted); }

.tabs {
  max-width: 1180px;
  margin: 0 auto;
  padding: 10px 20px 0;
  display: flex;
  gap: 4px;
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }

.tab {
  padding: 9px 16px 12px;
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
  border-bottom: 2.5px solid transparent;
  white-space: nowrap;
  transition: color .14s ease, border-color .14s ease;
}
.tab:hover { color: var(--ink-2); }
.tab.is-active { color: var(--primary-dark); border-bottom-color: var(--primary); }

/* ---------------------------- 提醒条 ---------------------------- */

.alert-bar {
  max-width: 1180px;
  margin: 16px auto 0;
  padding: 0 20px;
}
.alert-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 18px;
  border-radius: var(--r-md);
  font-size: 14px;
  font-weight: 600;
  line-height: 1.6;
}
.alert-card.warn { background: var(--amber-soft); border: 1.5px solid #f5dfb4; color: #96631a; }
.alert-card.danger { background: var(--red-soft); border: 1.5px solid #f6cdc9; color: #a8342a; }
.alert-card .alert-emoji { font-size: 20px; }
.alert-card button { margin-left: auto; }

/* ---------------------------- 主体 ---------------------------- */

.main {
  max-width: 1180px;
  margin: 0 auto;
  padding: 20px 20px 60px;
}

.panel { display: none; }
.panel.is-active { display: block; animation: fadeUp .28s ease; }

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.panel-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}
.panel-head h2 { font-size: 22px; }
.panel-desc { font-size: 13.5px; color: var(--muted); margin-top: 5px; }

.sub-block { margin-bottom: 34px; }
.sub-title {
  font-size: 16px;
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* ---------------------------- 筛选区 ---------------------------- */

.filters {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}
.search {
  flex: 1 1 240px;
  min-width: 200px;
  padding: 11px 16px;
  border-radius: 999px;
  border: 1.5px solid var(--line);
  background: #fff;
  outline: none;
  font-size: 14px;
  -webkit-appearance: none;
  appearance: none;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.search::-webkit-search-decoration, .search::-webkit-search-cancel-button { -webkit-appearance: none; }
.search:focus { border-color: var(--primary); box-shadow: 0 0 0 4px var(--primary-soft); }

.chips { display: flex; gap: 7px; flex-wrap: wrap; }
.chip {
  padding: 7px 14px;
  border-radius: 999px;
  background: #fff;
  border: 1.5px solid var(--line);
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-2);
  transition: all .14s ease;
}
.chip:hover { border-color: #dccfbe; }
.chip.is-active {
  background: var(--primary-soft);
  border-color: #f8c39a;
  color: var(--primary-dark);
}

.switch { display: inline-flex; align-items: center; gap: 7px; font-size: 13.5px; font-weight: 600; color: var(--ink-2); cursor: pointer; }
.switch input { width: 17px; height: 17px; accent-color: var(--primary); cursor: pointer; }

/* ---------------------------- 图书卡片 ---------------------------- */

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

.book-card {
  background: var(--card);
  border-radius: var(--r-md);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: transform .18s ease, box-shadow .18s ease;
  position: relative;
  overflow: hidden;
}
.book-card::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 5px;
  background: var(--spine, var(--primary));
}
.book-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); }
.book-card.is-out { opacity: .74; }
.book-card.is-offline { opacity: .55; }

.book-top { display: flex; gap: 12px; padding-left: 6px; }
.book-cover {
  width: 46px;
  height: 60px;
  border-radius: 6px 10px 10px 6px;
  background: linear-gradient(140deg, var(--spine, var(--primary)), color-mix(in srgb, var(--spine, var(--primary)) 62%, #fff));
  display: grid;
  place-items: center;
  font-size: 22px;
  flex: none;
  box-shadow: 0 3px 10px rgba(78, 61, 44, .16);
}
.book-info { min-width: 0; flex: 1; }
.book-title {
  font-size: 15px;
  font-weight: 700;
  line-height: 1.35;
  margin-bottom: 3px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.book-author { font-size: 12.5px; color: var(--muted); }

.book-tags { display: flex; gap: 6px; flex-wrap: wrap; padding-left: 6px; }
.tag {
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 700;
  background: var(--paper-2);
  color: var(--ink-2);
}
.tag.cat { background: var(--blue-soft); color: var(--blue); }
.tag.ok { background: var(--teal-soft); color: var(--teal); }
.tag.busy { background: var(--amber-soft); color: #a8711c; }
.tag.off { background: #f0ece6; color: var(--muted); }

.book-note {
  font-size: 12.5px;
  color: var(--ink-2);
  background: var(--paper);
  border-radius: var(--r-sm);
  padding: 9px 12px;
  line-height: 1.6;
  margin-left: 6px;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.book-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: auto;
  padding: 10px 0 0 6px;
  border-top: 1px dashed var(--line);
}
.book-owner { font-size: 12.5px; color: var(--muted); min-width: 0; }
.book-owner b { color: var(--ink-2); }
.book-due { font-size: 12.5px; font-weight: 700; }
.book-due.overdue { color: var(--red); }
.book-due.due { color: var(--amber); }

/* ---------------------------- 借阅列表 ---------------------------- */

.list { display: flex; flex-direction: column; gap: 10px; }

.borrow-item {
  background: var(--card);
  border: 1px solid var(--line);
  border-left: 5px solid var(--teal);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-sm);
  padding: 15px 18px;
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}
.borrow-item.urgency-due { border-left-color: var(--amber); }
.borrow-item.urgency-overdue { border-left-color: var(--red); background: linear-gradient(90deg, #fffaf9, #fff); }
.borrow-item.urgency-done { border-left-color: #cdc4b8; opacity: .78; }

.bi-main { flex: 1 1 240px; min-width: 0; }
.bi-title { font-size: 15px; font-weight: 700; }
.bi-meta { font-size: 12.5px; color: var(--muted); margin-top: 3px; }

.bi-due { text-align: right; font-size: 12.5px; line-height: 1.65; }
.bi-due .d-day { font-weight: 800; font-size: 14px; }
.bi-due.overdue .d-day { color: var(--red); }
.bi-due.due .d-day { color: var(--amber); }
.bi-due.normal .d-day, .bi-due.done .d-day { color: var(--teal); }
.bi-due.done .d-day { color: var(--muted); }

.bi-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------------------------- 卡片 / 统计 ---------------------------- */

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-sm);
  padding: 22px;
  margin-bottom: 18px;
}
.card-title { font-size: 16px; display: flex; align-items: center; gap: 6px; }
.card-sub { font-size: 12.5px; color: var(--muted); margin: 5px 0 16px; }

.rank-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; }

.rank-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.rank-list li {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 12px;
  border-radius: var(--r-sm);
  background: var(--paper);
  font-size: 14px;
}
.rank-list li.is-me { background: var(--primary-soft); outline: 1.5px solid #f8c39a; }
.rk-no {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: #fff;
  font-size: 12px;
  font-weight: 800;
  color: var(--muted);
  flex: none;
}
.rank-list li:nth-child(1) .rk-no { background: #ffd76e; color: #8a6410; }
.rank-list li:nth-child(2) .rk-no { background: #e2e6ea; color: #6b737a; }
.rank-list li:nth-child(3) .rk-no { background: #f0cdae; color: #8a5a2b; }
.rk-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rk-val { font-weight: 800; color: var(--primary-dark); font-size: 13px; }

.stat-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}
.stat {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-sm);
  padding: 16px 18px;
}
.stat-num { font-size: 25px; font-weight: 800; letter-spacing: -.02em; }
.stat-num.accent { color: var(--primary-dark); }
.stat-num.danger { color: var(--red); }
.stat-lbl { font-size: 12.5px; color: var(--muted); margin-top: 2px; }

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

.table-wrap { overflow-x: auto; border-radius: var(--r-sm); border: 1px solid var(--line); }
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; min-width: 520px; }
.table th {
  text-align: left;
  padding: 10px 14px;
  background: var(--paper-2);
  font-size: 12.5px;
  font-weight: 700;
  color: var(--ink-2);
  white-space: nowrap;
}
.table td { padding: 10px 14px; border-top: 1px solid var(--line); vertical-align: middle; }
.table tr:hover td { background: #fffdfa; }
.table .pill {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 700;
}
.pill.ok { background: var(--teal-soft); color: var(--teal); }
.pill.busy { background: var(--amber-soft); color: #a8711c; }
.pill.over { background: var(--red-soft); color: var(--red); }
.pill.done { background: #f0ece6; color: var(--muted); }

.textarea, .input {
  width: 100%;
  padding: 12px 15px;
  border-radius: var(--r-sm);
  border: 1.5px solid var(--line);
  background: #fffdfa;
  outline: none;
  font-size: 14px;
  resize: vertical;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.textarea:focus, .input:focus { border-color: var(--primary); box-shadow: 0 0 0 4px var(--primary-soft); background: #fff; }

.row-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin: 12px 0 18px;
}
.row-actions .input { flex: 1 1 200px; width: auto; }

.danger-card { border-color: #f2ded9; }

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

.empty {
  text-align: center;
  padding: 56px 20px;
  color: var(--muted);
  font-size: 14px;
}
.empty.small { padding: 26px 20px; }
.empty-emoji { font-size: 42px; margin-bottom: 12px; opacity: .85; }

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

.footer {
  text-align: center;
  padding: 26px 20px 40px;
  font-size: 12.5px;
  color: var(--muted);
}

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

.modal-mask, .notice-mask {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(47, 42, 38, .42);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn .18s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal {
  width: 100%;
  max-width: 480px;
  max-height: 88vh;
  max-height: 88dvh;
  background: var(--card);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  animation: pop .22s cubic-bezier(.2, 1.2, .5, 1);
}
@keyframes pop { from { opacity: 0; transform: translateY(18px) scale(.97); } to { opacity: 1; transform: none; } }

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 22px 14px;
}
.modal-head h3 { font-size: 18px; }
.modal-body { padding: 0 22px; overflow-y: auto; }
.modal-foot {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  padding: 18px 22px 22px;
}
.modal-foot:empty { display: none; }

.notice-panel {
  width: 100%;
  max-width: 460px;
  max-height: 82vh;
  max-height: 82dvh;
  background: var(--card);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  animation: pop .22s cubic-bezier(.2, 1.2, .5, 1);
}
.notice-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 22px 14px;
  border-bottom: 1px solid var(--line);
}
.notice-head h3 { font-size: 17px; }
.notice-body { padding: 14px 18px 20px; overflow-y: auto; display: flex; flex-direction: column; gap: 9px; }

.notice-item {
  padding: 13px 15px;
  border-radius: var(--r-md);
  background: var(--paper);
  border-left: 4px solid var(--teal);
  font-size: 13.5px;
  line-height: 1.65;
}
.notice-item.unread { background: var(--primary-soft); border-left-color: var(--primary); }
.notice-item.remind { border-left-color: var(--red); background: var(--red-soft); }
.notice-item .nt-time { display: block; font-size: 11.5px; color: var(--muted); margin-top: 5px; }

/* ---------------------------- Toast ---------------------------- */

.toast-wrap {
  position: fixed;
  left: 50%;
  bottom: 32px;
  transform: translateX(-50%);
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  pointer-events: none;
}
.toast {
  padding: 11px 20px;
  border-radius: 999px;
  background: rgba(47, 42, 38, .93);
  color: #fff;
  font-size: 13.5px;
  font-weight: 600;
  box-shadow: var(--shadow-md);
  animation: toastIn .24s ease;
  max-width: 86vw;
  text-align: center;
}
.toast.err { background: rgba(200, 60, 50, .95); }
.toast.ok { background: rgba(30, 150, 135, .95); }
@keyframes toastIn { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

/* ---------------------------- 减少动态效果 ---------------------------- */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ---------------------------- 触屏设备 ---------------------------- */

/* 手机上 :hover 会「粘住」——点一下卡片就一直浮着，这里关掉位移类效果 */
@media (hover: none) {
  .book-card:hover { transform: none; box-shadow: var(--shadow-sm); }
  .table tr:hover td { background: transparent; }
}

/* ---------------------------- 移动端 / 微信 H5 ---------------------------- */

@media (max-width: 620px) {

  /* ---- 输入焦点放大问题：iOS / 微信内核会对字号 <16px 的输入框自动放大页面且不回弹 ---- */
  .field input,
  .input,
  .textarea,
  .search,
  select.input,
  .row-actions .input {
    font-size: 16px;
  }

  /* ---- 顶栏：压成一行，给内容多留一屏高度 ---- */
  .topbar-inner {
    padding: 9px 14px 0;
    flex-wrap: nowrap;
    gap: 8px;
  }
  .brand { min-width: 0; flex: 0 1 auto; }
  .brand-class { max-width: 34vw; min-width: 0; }
  .topbar-right { gap: 6px; flex: none; }
  .icon-btn { min-width: 36px; height: 36px; padding: 0 10px; font-size: 12.5px; }
  .user-chip { padding: 3px 8px 3px 3px; gap: 6px; }
  .avatar { width: 30px; height: 30px; font-size: 13px; }
  .tabs { padding: 6px 12px 0; gap: 2px; -webkit-overflow-scrolling: touch; }
  .tab { padding: 10px 12px 12px; font-size: 13.5px; }

  /* ---- 主体留出 iPhone 底部小黑条（Home Indicator）---- */
  .main { padding: 14px 14px calc(56px + env(safe-area-inset-bottom)); }
  .alert-bar { margin-top: 12px; padding: 0 14px; }
  .alert-card { flex-wrap: wrap; padding: 12px 14px; }
  .footer { padding: 20px 16px calc(30px + env(safe-area-inset-bottom)); }

  /* ---- 登录页 ---- */
  .login-wrap { padding: 14px 14px calc(24px + env(safe-area-inset-bottom)); }
  .login-card { padding: 24px 18px 22px; border-radius: var(--r-md); }
  .login-logo { font-size: 44px; margin-bottom: 10px; }
  .login-brand h1 { font-size: 22px; }
  .login-brand { margin-bottom: 20px; }
  .link-back { padding: 10px 0; min-height: 44px; margin-bottom: 6px; } /* 44px 是手指点按的舒适下限 */

  /* ---- 面板与筛选 ---- */
  .panel-head { align-items: flex-start; gap: 10px; margin-bottom: 16px; }
  .panel-head h2 { font-size: 20px; }
  .panel-desc { font-size: 13px; }
  .search { flex: 1 1 100%; min-width: 0; }
  .filters { gap: 10px; }
  .chip { padding: 8px 14px; }
  .switch { padding: 6px 0; }

  /* ---- 图书卡片：两列，按钮整行可点 ---- */
  .book-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .book-card { padding: 12px 12px 10px; gap: 8px; }
  .book-top { gap: 10px; padding-left: 4px; }
  .book-cover { width: 36px; height: 48px; font-size: 17px; }
  .book-title { font-size: 14px; }
  .book-author { font-size: 11.5px; }
  .tag { font-size: 10.5px; padding: 2px 8px; }
  .book-note { display: none; }
  .book-foot { flex-direction: column; align-items: stretch; gap: 8px; padding: 10px 0 0 4px; }
  .book-foot .btn { width: 100%; }

  /* ---- 借阅条目 ---- */
  .borrow-item { padding: 13px 14px; gap: 10px; }
  .bi-main { flex: 1 1 100%; }
  .bi-due { text-align: left; }
  .bi-actions { width: 100%; }
  .bi-actions .btn { flex: 1 1 auto; }

  /* ---- 统计 / 卡片 / 排行 ---- */
  .stat-row { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .stat { padding: 12px 14px; }
  .stat-num { font-size: 22px; }
  .card { padding: 16px 14px; }
  .rank-grid { grid-template-columns: 1fr; gap: 12px; }

  /* ---- 表格 → 卡片列表（横滑表格在手机上根本用不了）---- */
  .table-wrap { overflow: visible; border: none; border-radius: 0; }
  .table { min-width: 0; }
  .table thead { display: none; }
  .table, .table tbody, .table tr, .table td { display: block; width: 100%; }
  .table tr {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--r-sm);
    box-shadow: var(--shadow-sm);
    padding: 10px 12px;
    margin-bottom: 10px;
  }
  .table td {
    border-top: none;
    padding: 5px 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    text-align: right;
  }
  .table td::before {
    content: attr(data-label);
    flex: none;
    color: var(--muted);
    font-size: 12px;
    font-weight: 600;
    text-align: left;
  }
  .table td[colspan] { display: block; text-align: center; }
  .table td[colspan]::before { content: none; }
  .link-cell { flex-wrap: wrap; justify-content: flex-end; }
  .link-text { max-width: 100%; white-space: normal; word-break: break-all; text-align: right; }

  /* ---- 表单与操作按钮 ---- */
  .row-actions { gap: 8px; }
  .row-actions .btn { flex: 1 1 100%; }
  .row-actions .muted { flex: 1 1 100%; }
  .form-grid { grid-template-columns: 1fr; }

  /* ---- 弹窗改为底部弹层：手指够得着，键盘弹起也不遮按钮 ---- */
  .modal-mask, .notice-mask { padding: 12px 0 0; align-items: flex-end; }
  .modal, .notice-panel { max-width: 100%; border-radius: var(--r-lg) var(--r-lg) 0 0; }
  .modal { animation: sheetUp .26s cubic-bezier(.2, 1, .4, 1); }
  .modal-head, .notice-head { padding: 16px 18px 10px; }
  .modal-head h3 { font-size: 17px; }
  .modal-head .icon-btn, .notice-head .icon-btn { min-width: 40px; height: 40px; }
  .modal-body { padding: 0 18px; }
  .modal-foot {
    flex-direction: column-reverse;
    padding: 14px 18px calc(16px + env(safe-area-inset-bottom));
  }
  .modal-foot .btn { width: 100%; }
  .notice-body { padding: 12px 14px calc(18px + env(safe-area-inset-bottom)); }

  .toast-wrap { bottom: calc(20px + env(safe-area-inset-bottom)); }
}

@keyframes sheetUp {
  from { transform: translateY(28px); opacity: .5; }
  to { transform: none; opacity: 1; }
}

/* ---- 超窄屏（iPhone SE / 折叠屏外屏）：用户名放不下就只留头像 ---- */
@media (max-width: 380px) {
  .user-meta { display: none; }
  .brand-class { max-width: 40vw; }
}

/* ---- 注册 / 激活 ---- */

.form-warn {
  background: #fff7e8;
  border: 1px solid #f3d9a4;
  color: #8a5a12;
  border-radius: 10px;
  padding: 9px 12px;
  font-size: 12.5px;
  line-height: 1.6;
  margin-bottom: 12px;
}

.act-block { margin-bottom: 16px; }

.act-code-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 7px;
}

.act-code {
  flex: 1;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 19px;
  font-weight: 700;
  letter-spacing: 2px;
  background: var(--paper, #fbf6ee);
  border: 1.5px dashed var(--line, #e5dcc8);
  border-radius: 10px;
  padding: 10px 14px;
  text-align: center;
  user-select: all;
  word-break: break-all;
}

.act-code.act-card { color: var(--primary, #2f7d6d); }

.act-note {
  background: #eef6ff;
  border: 1px solid #c8ddf5;
  color: #1c4a75;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 12.5px;
  line-height: 1.7;
  margin-bottom: 16px;
}

.act-success {
  text-align: center;
  padding: 8px 0 4px;
}

.act-success-emoji { font-size: 42px; margin-bottom: 6px; }
.act-success p { margin: 6px 0; }

@media (max-width: 620px) {
  .act-code { font-size: 16px; letter-spacing: 1.2px; padding: 9px 10px; }
  .act-code-row { flex-wrap: wrap; }
}
