/* ============================================================
   书卷 · 文学记录 UI 设计系统
   配色：宣纸暖白 + 墨色文字 + 黛蓝主色 + 朱砂强调 + 鎏金点缀
   字体：标题衬线（宋体系），正文系统无衬线
   ============================================================ */
:root {
  --bg: #f4efe5;
  --bg-grad: linear-gradient(180deg, #f7f2e8 0%, #efe7d7 100%);
  --surface: #fffcf5;
  --surface-2: #faf4e9;
  --ink: #2c2620;
  --ink-2: #6f6558;
  --ink-3: #a79c8b;
  --primary: #3d5a75;
  --primary-deep: #2f475e;
  --primary-soft: #e6edf3;
  --accent: #b0493b;
  --accent-deep: #8e3a2f;
  --accent-soft: #f6e7e2;
  --gold: #9a7b3f;
  --gold-soft: #f4ead3;
  --green: #3d7a55;
  --green-soft: #e6efe8;
  --border: #e7dcc6;
  --border-soft: #efe8d8;
  --shadow: 0 2px 8px rgba(96, 74, 42, .14);
  --radius: 14px;
  --font-title: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Segoe UI", sans-serif;
  --font-body: -apple-system, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box
}

button {
  font-family: inherit
}

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--ink);
  max-width: 480px;
  margin: 0 auto;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px
}

/* ---------- 通用 ---------- */
.one-row {
  display: flex;
  gap: 8px;
  align-items: center
}

.tag-area {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.sub-area {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  padding: 8px;
  margin-bottom: 4px;
  border-radius: 10px;
  background: #f4eee1;
  border: 1px solid #eadfc9;
}

.kinAtom {
  position: relative;
  flex-shrink: 0;
  display: inline-block;
  padding: 7px 14px;
  border-radius: 20px;
  font-size: 15px;
  cursor: pointer;
  user-select: none;
  margin: 3px;
  background: #e6edf3;
  color: #2c2620;
}

.kinChoice {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 4px 0;
  padding: 8px 10px;
  border: 1.5px solid #e7dcc6;
  border-radius: 10px;
  background: #fff;
  cursor: pointer;
  user-select: none
}

.kinChoice .ra {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 1.5px solid #b9ab93;
  flex-shrink: 0;
  box-sizing: border-box
}

.kinChoice .te {
  flex: 1;
  font-size: 15px;
  color: #2c2620
}

.kinChoice.selected {
  border-color: #3d7a55;
  background: #e6efe8;
}

.kinChoice.selected>.ra {
  border-color: #3d7a55;
  background: #3d7a55;
}

#relFilterBar:empty {
  display: none;
}

/*虚线边框按钮*/
.sub-btn {
  flex-shrink: 0;
  display: inline-block;
  width: auto;
  padding: 5px 12px;
  border: 1.5px dashed #d8cbb2;
  border-radius: 14px;
  background: #fffcf5;
  color: #6f6558;
  font-size: 13px;
}

/*不换行，过长裁剪，填...*/
.long-title {
  flex: 1;
  font-weight: 600;
  color: #3d7a55;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}


/* ---------- 顶部工具栏 ---------- */
.toolbar {
  background: rgba(255, 252, 245, .92);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  padding: 8px 12px;
  display: flex;
  align-items: center;
  gap: 6px;
  border-bottom: 1px solid var(--border-soft);
  position: sticky;
  top: 0;
  z-index: 10;
}

.toolbar .tb-title {
  font-family: var(--font-title);
  font-size: 17px;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: .06em;
  flex-shrink: 0;
  margin: auto 8px;
}

.tb-icon {
  font-size: 15px;
  background: none;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
  line-height: 1;
  width: 34px;
  height: 34px;
  color: var(--ink);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform .15s, background .15s;
}

.tb-icon:active {
  transform: scale(.92);
  background: var(--primary-soft)
}

.tb-icon.has-text {
  width: auto;
}

.tb-icon>svg {
  width: 20px;
  height: 20px;
  flex: 0 0 auto;
  display: block;
}

.toolbar .tb-search {
  flex: 1;
  padding: 7px 12px;
  border: 1px solid var(--border);
  border-radius: 18px;
  font-size: 14px;
  background: var(--surface-2);
  outline: none;
  min-width: 0;
  transition: border-color .2s, background .2s, box-shadow .2s;
}

.toolbar .tb-search:focus {
  border-color: var(--primary);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(61, 90, 117, .12)
}

/* ---------- 工具栏更多菜单 ---------- */
/* .tb-menu-wrap{position:relative;flex-shrink:0} */
.tb-menu {
  position: absolute;
  top: calc(100%);
  right: 0;
  min-width: 160px;
  background: #fffdf8;
  border: 1px solid var(--border-soft);
  border-radius: 12px;
  box-shadow: 0 6px 18px rgba(60, 50, 30, .06);
  padding: 6px;
  display: none;
  flex-direction: column;
  gap: 2px;
  z-index: 50;
}

.tb-menu.open {
  display: flex
}

/* 菜单打开时的透明拦截层：阻止点击穿透到下层条目 */
.tb-menu-mask {
  position: fixed;
  inset: 0;
  z-index: 5;
  display: none;
  background: transparent
}

.tb-menu-mask.open {
  display: block
}

.tb-menu button {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 9px 12px;
  font-size: 14px;
  color: var(--ink);
  background: transparent;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  text-align: left;
  transition: background .15s;
}

.tb-menu button:active {
  background: var(--primary-soft)
}

/* ---------- 头部tabs ---------- */
.tabs {
  display: flex;
  background: rgba(255, 252, 245, .94);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border-soft);
  position: sticky;
  top: 48px;
  z-index: 8;
}

.tab {
  flex: 1;
  text-align: center;
  padding: 11px 0;
  font-size: 14px;
  color: var(--ink-2);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: color .2s, border-color .2s, background .2s;
  font-weight: 500;
}

.tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  font-weight: 600
}

.tab:active {
  background: var(--primary-soft)
}

/* ---------- 主区域与列表卡片 ---------- */
.main {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 10px 12px 90px
}

.swipe-wrapper {
  position: relative;
  overflow: hidden;
  margin: 0 0 10px;
  border-radius: var(--radius);
  touch-action: pan-y
}

.swipe-bg {
  position: absolute;
  top: 0;
  left: 2px;
  right: 2px;
  bottom: 0;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 500;
  border-radius: var(--radius);
  cursor: pointer;
  z-index: 0;
}

.swipe-bg:active {
  background: var(--accent-deep)
}

.swipe-bg-full {
  width: auto;
  left: 2px;
  right: 2px
}

.list-item {
  background: var(--surface);
  padding: 14px 16px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  transition: transform .25s cubic-bezier(.2, .8, .2, 1);
  touch-action: pan-y;
  border: 1px solid var(--border-soft);
}

.list-item:active {
  background: #fdf8ee
}

.list-item .title {
  font-size: 16px;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 4px;
  pointer-events: none;
  letter-spacing: .01em;
}

.list-item .title-row {
  display: flex;
  align-items: baseline;
  gap: 8px
}

.list-item .title-row .title {
  margin-bottom: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap
}

.list-item .order-no {
  flex-shrink: 0;
  min-width: 36px;
  font-family: var(--font-title);
  font-size: 13px;
  color: var(--gold);
  font-weight: 700;
  text-align: center;
}

.list-item .preview {
  margin: 6px 2px 2px;
  font-size: 13px;
  color: var(--ink-3);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  pointer-events: none;
  line-height: 1.6;
}

.list-item .preview-multi {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  white-space: normal;
  overflow: hidden;
  margin: 6px 2px 2px;
  line-height: 1.7;
}

.list-item .cred-badge {
  display: table;
  margin: 0 0 6px;
  font-size: 12px;
  color: var(--primary);
  font-weight: 600;
  background: var(--primary-soft);
  padding: 2px 9px;
  border-radius: 9px;
}

.list-item .badge-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0 0 6px
}

.list-item .badge-row .cred-badge {
  margin: 0
}

.list-item .tag-badge {
  display: inline-block;
  font-size: 12px;
  color: var(--gold);
  font-weight: 600;
  background: var(--gold-soft);
  padding: 2px 9px;
  border-radius: 9px;
}

.empty,
.search-empty {
  text-align: center;
  color: var(--ink-3);
  padding: 70px 20px;
  font-size: 15px
}

.empty .empty-icon {
  font-size: 44px;
  margin-bottom: 14px;
  opacity: .55
}

/* ---------- 人物网格 ---------- */
.char-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
  padding: 2px 0;
  align-content: start
}

.char-grid .swipe-wrapper {
  margin: 0;
  border-radius: var(--radius)
}

.char-grid .swipe-bg {
  border-radius: var(--radius)
}

.char-grid .list-item {
  padding: 12px 4px 10px;
  border-radius: var(--radius);
  min-height: 64px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  box-shadow: 0 1px 4px rgba(96, 74, 42, .08);
}

.char-grid .list-item:active {
  transform: scale(.94);
  background: var(--primary-soft)
}

.char-grid .list-item .title {
  margin: 0;
  font-size: 13px;
  line-height: 1.4;
  color: var(--ink);
  font-weight: 600;
  word-break: break-all;
  max-width: 100%;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ---------- 右下角添加按钮 ---------- */
.add-btn {
  position: fixed;
  bottom: 26px;
  right: 22px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(145deg, var(--primary), var(--primary-deep));
  color: #fff;
  font-size: 30px;
  font-weight: 300;
  border: none;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(47, 71, 94, .38), inset 0 1px 0 rgba(255, 255, 255, .2);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 20;
  transition: transform .2s, box-shadow .2s;
}

.add-btn:active {
  transform: scale(.9);
  box-shadow: 0 3px 10px rgba(47, 71, 94, .3)
}

/* ---------- 模态框（底部弹层） ---------- */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(40, 30, 15, .45);
  z-index: 100;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  animation: fadeIn .2s;
}

@keyframes fadeIn {
  from {
    opacity: 0
  }

  to {
    opacity: 1
  }
}

.modal {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  /* gap: 12px; */
  width: 100%;
  max-width: 480px;
  border-radius: 22px 22px 0 0;
  max-height: 90vh;
  overflow: hidden;
  padding: 20px;
  animation: slideUp .28s cubic-bezier(.2, .8, .2, 1);
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

@keyframes slideUp {
  from {
    transform: translateY(100%)
  }

  to {
    transform: translateY(0)
  }
}

.modal h3 {
  margin-bottom: 8px;
  font-size: 18px;
  font-family: var(--font-title);
  font-weight: 700;
  color: var(--ink)
}

.modal .sub-row {
  font-size: 13px;
  color: var(--ink-2);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sub-row .tb-icon {
  font-size: 13px;
  color: var(--ink-2);
}

.sub-row .tb-icon>svg {
  width: 13px;
  height: 13px;
}

/* ---------- 表单控件（高特异性避免子按钮被覆盖） ---------- */
.modal input,
.modal textarea {
  width: 100%;
  padding: 9px 9px;
  border: 1px solid var(--border);
  border-radius: 11px;
  font-size: 15px;
  font-family: inherit;
  background: var(--surface-2);
  color: var(--ink);
  outline: none;
  transition: border-color .2s, box-shadow .2s, background .2s;
}

.modal .main-area {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow-y: auto;
  min-height: 0;
}

.modal .label {
  font-size: 13px;
  color: #6f6558;
  margin: 8px 2px 4px;
}

.modal input:focus,
.modal textarea:focus {
  border-color: var(--primary);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(61, 90, 117, .12)
}

.modal textarea {
  min-height: 120px;
  resize: vertical;
  line-height: 1.7
}

.modal .btn-row {
  display: flex;
  margin-top: 12px;
  gap: 10px
}

.modal .btn-primary,
.modal .btn-cancel,
.modal .btn-danger {
  padding: 12px 20px;
  border-radius: 12px;
  font-size: 15px;
  border: none;
  cursor: pointer;
  flex: 1;
  font-weight: 500;
  transition: transform .15s, filter .15s, background .15s;
}

.modal .btn-primary:active,
.modal .btn-cancel:active,
.modal .btn-danger:active {
  transform: scale(.97)
}

.modal .btn-primary {
  background: var(--primary);
  color: #fff
}

.modal .btn-primary:active {
  filter: brightness(.92)
}

.modal .btn-cancel {
  background: var(--surface-2);
  color: var(--ink-2);
  border: 1px solid var(--border)
}

.modal .btn-danger {
  background: var(--accent);
  color: #fff
}

.modal .btn-danger:active {
  filter: brightness(.92)
}

/* ---------- 通用按钮 ---------- */
.btn-outline {
  display: block;
  width: 100%;
  padding: 12px 0;
  margin-bottom: 16px;
  border: 1.5px dashed var(--border);
  border-radius: 12px;
  background: var(--surface-2);
  color: var(--ink-2);
  font-size: 15px;
  cursor: pointer;
  text-align: center;
  transition: all .2s;
}

.btn-outline:hover,
.btn-outline:active {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-soft)
}

.btn-save {
  display: block;
  width: 100%;
  padding: 14px 0;
  margin-top: 4px;
  border: none;
  border-radius: 13px;
  background: linear-gradient(145deg, var(--primary), var(--primary-deep));
  color: #fff;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(47, 71, 94, .25);
  transition: all .2s;
}

.btn-save:active {
  transform: scale(.98);
  box-shadow: 0 2px 6px rgba(47, 71, 94, .18)
}

/* ---------- 详情页 ---------- */
.detail-page {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--bg);
  z-index: 90;
  display: flex;
  flex-direction: column;
  max-width: 480px;
  margin: 0 auto;
}

.detail-header {
  display: flex;
  align-items: center;
  padding: 12px 12px;
  border-bottom: 1px solid var(--border-soft);
  background: rgba(255, 252, 245, .94);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  flex-shrink: 0;
}

.detail-header .back {
  font-size: 22px;
  cursor: pointer;
  padding: 4px 10px;
  color: var(--primary);
  font-weight: 700;
  line-height: 1
}

.detail-header .detail-title {
  flex: 1;
  font-size: 18px;
  font-weight: 600;
  text-align: center;
  margin-right: 40px;
  font-family: var(--font-title);
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.detail-content {
  flex: 1;
  overflow-y: auto;
  padding: 16px 16px 92px;
  gap: 12px;
  display: flex;
  flex-direction: column
}

.detail-footer {
  flex-shrink: 0;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--border-soft);
  background: rgba(255, 252, 245, .95);
}

.detail-content .meta input {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 16px;
  font-weight: 500;
  background: var(--surface);
  outline: none;
  font-family: var(--font-title);
}

.detail-content .meta input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(61, 90, 117, .12)
}

.detail-textarea {
  width: 100%;
  min-height: 120px;
  box-sizing: border-box;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  font-size: 15px;
  line-height: 1.8;
  resize: none;
  overflow: hidden;
  outline: none;
  font-family: inherit;
  flex-shrink: 0;
  background: var(--surface);
  color: var(--ink);
  transition: border-color .2s, box-shadow .2s;
}

.detail-textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(61, 90, 117, .12)
}

/* ---------- 性别滑块 ---------- */
.gender-slider {
  position: relative;
  flex-shrink: 0;
  width: 100px;
  height: 38px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 19px;
  padding: 3px;
  box-sizing: border-box;
  cursor: pointer;
  touch-action: pan-y;
}

.gender-track {
  position: relative;
  height: 100%
}

.gender-opt {
  position: relative;
  z-index: 2;
  float: left;
  width: 50%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink-3);
  user-select: none;
  -webkit-user-select: none;
  transition: color .2s;
}

.gender-opt.active {
  color: #fff
}

.gender-thumb {
  position: absolute;
  z-index: 1;
  top: 0;
  left: 0;
  width: 50%;
  height: 100%;
  background: linear-gradient(145deg, var(--primary), var(--primary-deep));
  border-radius: 16px;
  transition: transform .2s cubic-bezier(.2, .8, .2, 1);
  box-shadow: 0 2px 6px rgba(47, 71, 94, .3);
}

.gender-thumb.right {
  transform: translateX(100%)
}

/* ---------- 属性/关系滑块 ---------- */
.attr-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  padding: 8px 0
}

.attr-row .attr-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
  min-width: 48px;
  flex-shrink: 0
}

.attr-row .attr-range,
.rel-row .attr-range {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 7px;
  background: var(--border-soft);
  border-radius: 4px;
  outline: none;
  min-width: 0;
  margin: 0;
  cursor: pointer;
}

.attr-row .attr-range::-webkit-slider-runnable-track,
.rel-row .attr-range::-webkit-slider-runnable-track {
  height: 7px;
  border-radius: 4px;
  background: transparent
}

.attr-row .attr-range::-webkit-slider-thumb,
.rel-row .attr-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 22px;
  height: 22px;
  margin-top: -7.5px;
  border-radius: 50%;
  background: #fff;
  border: 2.5px solid var(--primary);
  box-shadow: 0 1px 4px rgba(60, 45, 20, .25);
  cursor: pointer;
}

.rel-row .attr-range::-webkit-slider-thumb {
  border-color: var(--gold)
}

.attr-row .attr-range::-moz-range-thumb,
.rel-row .attr-range::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  border: 2.5px solid var(--primary);
  cursor: pointer;
}

.rel-row .attr-range::-moz-range-thumb {
  border-color: var(--gold)
}

.attr-row .attr-val,
.rel-row .attr-val {
  font-size: 13px;
  font-weight: 700;
  width: 22px;
  text-align: center;
  flex-shrink: 0;
  font-family: var(--font-title);
}

.attr-row .attr-val {
  color: var(--primary)
}

.rel-row .attr-val {
  color: var(--gold)
}

.attr-row .attr-del,
.rel-row .rel-del {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 9px;
  font-size: 12px;
  padding: 5px 12px;
  cursor: pointer;
  flex-shrink: 0;
  user-select: none;
  line-height: 1.4;
  transition: background .15s;
}

.attr-row .attr-del:active,
.rel-row .rel-del:active {
  background: var(--accent-deep)
}

/* ---------- 选择 chip / 内容块 ---------- */
.char-chip {
  padding: 7px 15px;
  border-radius: 20px;
  font-size: 14px;
  cursor: pointer;
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--ink-2);
  transition: all .2s;
}

.char-chip.selected {
  border-color: var(--primary);
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 600
}

.char-block {
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px 14px;
  background: var(--surface);
}

.char-block-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 8px;
  font-family: var(--font-title);
  letter-spacing: .03em;
}

.char-block-title .title-btns {
  display: flex;
  gap: 6px;
  flex-shrink: 0
}

.btn-block-add {
  font-size: 12px;
  padding: 5px 13px;
  border-radius: 15px;
  border: 1px solid var(--primary);
  color: var(--primary);
  background: var(--surface);
  cursor: pointer;
  font-weight: 500;
  flex-shrink: 0;
  transition: background .15s;
}

.btn-block-add:active {
  background: var(--primary-soft)
}

.assoc-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 8px
}

.assoc-tag {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  vertical-align: middle;
  flex: 0 0 auto;
  background: var(--green-soft);
  color: var(--green);
  padding: 4px 10px 4px 10px;
  border-radius: 13px;
  font-size: 12px;
  cursor: pointer;
  transition: background .15s;
}

.assoc-tag .assoc-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0
}

.assoc-tag:active {
  background: #d3e3d9
}

.assoc-tag {
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
  touch-action: manipulation
}

.assoc-stack {
  display: flex;
  flex-direction: column;
  gap: 6px
}

.assoc-stack .assoc-tag {
  width: 100%;
  justify-content: flex-start
}

.detail-assoc-fab {
  position: fixed;
  bottom: 26px;
  right: 22px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(145deg, var(--primary), var(--primary-deep));
  color: #fff;
  font-size: 24px;
  border: none;
  cursor: pointer;
  z-index: 95;
  box-shadow: 0 6px 18px rgba(47, 71, 94, .38), inset 0 1px 0 rgba(255, 255, 255, .2);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform .2s, box-shadow .2s;
}

.detail-assoc-fab:active {
  transform: scale(.9);
  box-shadow: 0 3px 10px rgba(47, 71, 94, .3)
}

.assoc-menu {
  position: fixed;
  z-index: 400;
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, .18);
  padding: 6px;
  min-width: 120px
}

.assoc-menu-del {
  display: block;
  width: 100%;
  padding: 4px;
  border: none;
  background: none;
  font-size: 14px;
  color: #b0493b;
  text-align: left;
  border-radius: 8px
}

.assoc-menu-del:active {
  background: #f6ecea
}

/* ---------- 关系行 ---------- */
.rel-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border-soft)
}

.rel-row:last-child {
  border-bottom: none
}

.rel-row .rel-info {
  display: flex;
  align-items: baseline;
  gap: 6px;
  font-size: 14px;
  min-width: 0
}

.rel-row .rel-info .rel-desc {
  font-size: 12px;
  color: var(--ink-3);
  display: inline;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1
}

.rel-row .rel-mid {
  display: flex;
  align-items: center;
  gap: 8px
}

.rel-row .rel-label {
  font-size: 13px;
  color: var(--ink-2);
  flex-shrink: 0
}

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  top: 100px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: #f5efe2;
  padding: 11px 22px;
  border-radius: 22px;
  animation: toastIn .3s, toastOut .3s 1.5s forwards;
  pointer-events: none;
  letter-spacing: .02em;
  z-index: 200;
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(-10px)
  }

  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0)
  }
}

@keyframes toastOut {
  from {
    opacity: 1
  }

  to {
    opacity: 0
  }
}

/* ---------- 全局搜索覆盖层 ---------- */
.search-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--surface);
  z-index: 110;
  display: flex;
  flex-direction: column;
  max-width: 480px;
  margin: 0 auto;
  animation: fadeIn .15s;
}

.search-header {
  display: flex;
  align-items: center;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-soft);
  background: var(--surface);
  flex-shrink: 0;
}

.search-title {
  font-size: 16px;
  font-weight: 600;
  flex: 1;
  font-family: var(--font-title)
}

.search-close {
  font-size: 16px;
  color: var(--ink-3);
  background: var(--surface-2);
  border: 1px solid var(--border-soft);
  border-radius: 50%;
  width: 30px;
  height: 30px;
  cursor: pointer;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.search-body {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0
}

.search-item {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-soft);
  cursor: pointer;
  transition: background .15s
}

.search-item:active {
  background: var(--surface-2)
}

.search-module-badge {
  display: inline-block;
  font-size: 11px;
  padding: 2px 9px;
  border-radius: 11px;
  margin-right: 8px;
  vertical-align: middle;
  color: #fff;
  font-weight: 600;
  letter-spacing: .02em;
}

.badge-chapter {
  background: var(--primary)
}

.badge-character {
  background: var(--accent)
}

.badge-story {
  background: var(--gold)
}

.badge-analysis {
  background: var(--green)
}

.search-item-title {
  font-size: 15px;
  font-weight: 500;
  vertical-align: middle
}

.search-item-preview {
  font-size: 13px;
  color: var(--ink-3);
  margin-top: 5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  line-height: 1.6
}

/* ---------- 选择器 ---------- */
.sel-item {
  cursor: pointer;
  transition: transform .12s
}

.sel-item:active {
  transform: scale(.97)
}

.sel-item.selected {
  background: var(--primary-soft);
  border: 1.5px solid var(--primary);
  color: var(--primary)
}

.sel-item.selected .title {
  color: var(--primary)
}

.modal .sel-item {
  box-shadow: none;
  margin-bottom: 8px
}

.modal .sel-item:last-child {
  margin-bottom: 0
}

.modal .sel-char-grid {
  grid-template-columns: repeat(auto-fill, minmax(76px, 1fr));
  gap: 6px;
  padding: 0 0 8px
}

.modal .sel-char-grid .list-item {
  min-height: 48px;
  padding: 8px 4px;
  box-shadow: none;
  margin-bottom: 0
}

/* ---------- 标签过滤与管理 ---------- */
/* ---------- 关联窗口中标签过滤栏 ---------- */
.tag-filter-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 4px;
  overflow-x: auto;
  border-bottom: none;
  flex-shrink: 0;
  scrollbar-width: none;
}

.tag-filter-bar::-webkit-scrollbar {
  display: none
}

.tag-filter-wrap {
  display: flex;
  align-items: center;
  background: var(--bg);
  border-bottom: 1px solid var(--border-soft);
  flex-shrink: 0;
  margin-bottom: 4px;
}

.tag-filter-wrap .tag-filter-bar {
  flex: 1;
  border-bottom: none
}

.tag-chip {
  display: inline-block;
  padding: 6px 13px;
  border-radius: 16px;
  background: var(--surface-2);
  border: 1px solid var(--border-soft);
  color: var(--ink-2);
  font-size: 13px;
  cursor: pointer;
  flex-shrink: 0;
  user-select: none;
  transition: all .15s;
}

.tag-chip:active {
  transform: scale(.95)
}

.tag-chip.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  font-weight: 500
}

#tagList {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 4px 0
}

/* --------------------标签管理器----------------------- */
.tag-mg-tabs .tag-mg-tab {
  padding: 9px 20px;
  border-radius: 11px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--ink-2);
  transition: background .15s, color .15s, border-color .15s
}

.tag-mg-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  padding: 10px 4px 14px;
}

.tag-mg-swipe {
  position: relative;
  overflow: hidden;
  border-radius: 10px;
  touch-action: pan-y
}

.tag-mg-item {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 6px 4px;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  text-align: center;
  font-size: 12px;
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(96, 74, 42, .08);
  transition: transform .25s cubic-bezier(.2, .8, .2, 1);
  touch-action: pan-y;
  word-break: break-all;
  transform: translateX(0)
}

/* ---------- 家庭关系编辑器 ---------- */
#familyRelRow {
  scrollbar-width: none;
  -ms-overflow-style: none
}

#familyRelRow::-webkit-scrollbar {
  display: none
}

/* “同时添加的人物关系”面板：主行统一使用 .kinChoice 模板类（外层样式固定），
   勾选态即 .kinChoice.selected；仅保留子选区换行占满整行的布局规则
   （子选区挂载在主行 .kinChoice 内部，依赖 .kinChoice 的 flex-wrap） */
.modal .kinChoice [id^="simulSub_"] {
  flex: 0 0 100%;
  box-sizing: border-box
}

/* ---------- 人物详情关系行：可点击跳转的人物名 ---------- */
.rel-row .rel-info .rel-name {
  min-width: 0
}

.rel-row .rel-info .rel-target {
  color: var(--primary);
  font-weight: 600;
  cursor: pointer;
  flex-shrink: 1;
  min-width: 0;
  max-width: 46%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------- 悬浮标签选择器（再次点击当前分类 tab 弹出） ---------- */
.tag-pop-mask {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  top: 96px;
  background: rgba(40, 30, 15, .28);
  z-index: 60;
  animation: fadeIn .18s;
}

.tag-pop-panel {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  background: var(--surface);
  border-bottom-left-radius: 16px;
  border-bottom-right-radius: 16px;
  z-index: 61;
  padding: 10px 12px 14px;
  box-sizing: border-box;
  box-shadow: 0 0 0 1px rgba(61, 90, 117, .12);
  animation: popDown .2s cubic-bezier(.2, .8, .2, 1);
}

@keyframes popDown {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(-8px)
  }

  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0)
  }
}

@keyframes fadeIn {
  from {
    opacity: 0
  }

  to {
    opacity: 1
  }
}

/* ---------- 其它 ---------- */
@media(display-mode:standalone) {
  body {
    padding-top: env(safe-area-inset-top)
  }
}