:root {
  --nav: #142235;
  --nav-soft: #2d4560;
  --nav-line: #22344d;
  --bg: #edf2f7;
  --map-board: #d5dfe9;
  --card: #fafcff;
  --primary: #345875;
  --primary-hover: #284862;
  --primary-soft: #e2eaf2;
  --brass: #c7a775;
  --brass-soft: #f0e7d8;
  --text: #243449;
  --muted: #586c80;
  --line: #cfdae6;
  --line-strong: #a8bacb;
  --danger: #a63f3f;
  --danger-soft: #f6e5e5;
  --ok: #3d6b57;
  --ok-soft: #e3efe9;
  --warn: #8a6a1f;
  --warn-soft: #f4ecda;
  --shadow: 0 10px 30px rgba(20, 34, 53, 0.08);
  --radius: 12px;
  --radius-sm: 8px;
  --sidebar-w: 236px;
  --topbar-h: 72px;
  --font: "Microsoft YaHei", "PingFang SC", "Noto Sans CJK SC", "Source Han Sans SC", "Hiragino Sans GB", sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.6;
}

h1,
h2,
h3,
h4,
p {
  margin: 0;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

a {
  color: var(--primary);
}

:focus-visible {
  outline: 3px solid var(--brass);
  outline-offset: 2px;
  border-radius: 4px;
}

.skip-link {
  position: absolute;
  left: 12px;
  top: -80px;
  z-index: 100;
  background: var(--card);
  color: var(--text);
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  transition: top 0.15s;
}

.skip-link:focus {
  top: 12px;
}

.app-shell {
  min-height: 100vh;
}

/* ---------------------------------------------------------------- 侧栏 */
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar-w);
  background: var(--nav);
  color: #edf2f7;
  display: flex;
  flex-direction: column;
  padding: 34px 16px 24px;
  z-index: 20;
}

.brand {
  padding: 0 16px 40px;
}

.brand strong {
  display: block;
  color: #d9bf94;
  font-size: 25px;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.brand span {
  display: block;
  margin-top: 6px;
  color: #9fb1c4;
  font-size: 13px;
  letter-spacing: 0.08em;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.nav a {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 52px;
  padding: 0 16px;
  border-radius: var(--radius-sm);
  color: #e4ecf4;
  text-decoration: none;
  font-size: 18px;
  transition: background 0.15s, color 0.15s;
}

.nav a svg {
  width: 20px;
  height: 20px;
  flex: none;
  opacity: 0.8;
}

.nav a:hover {
  background: #1c2f46;
}

.nav a.is-active {
  background: var(--nav-soft);
  color: #fff;
}

.nav a.is-active::before {
  content: "";
  position: absolute;
  left: -16px;
  top: 11px;
  width: 3px;
  height: 30px;
  border-radius: 2px;
  background: var(--brass);
}

.sidebar-foot {
  margin-top: auto;
  padding: 0 16px;
  color: #8fa3b8;
  font-size: 14px;
}

.sidebar-foot span {
  display: block;
  margin-top: 4px;
  font-size: 12px;
  color: #71859b;
}

/* ---------------------------------------------------------------- 主区 */
.main-wrap {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 15;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: var(--topbar-h);
  padding: 12px 32px;
  background: rgba(237, 242, 247, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid rgba(168, 186, 203, 0.35);
}

.crumb {
  font-size: 15px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.crumb strong {
  color: var(--text);
  font-weight: 600;
}

.crumb .site-name {
  color: var(--primary);
  font-weight: 600;
}

.crumb-sep {
  color: var(--muted);
}

.topbar-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: none;
}

.session-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  color: var(--muted);
}

.session-chip::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--brass);
}

.dm-badge {
  display: inline-flex;
  align-items: center;
  height: 30px;
  padding: 0 12px;
  border-radius: 999px;
  background: var(--nav);
  color: #e9dcc4;
  font-size: 13px;
  letter-spacing: 0.08em;
}

.role-toggle {
  min-height: 44px;
  padding: 0 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong);
  background: var(--card);
  color: var(--primary);
  cursor: pointer;
}

.role-toggle:hover {
  background: var(--primary-soft);
}

.preview-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 32px;
  background: var(--brass-soft);
  border-bottom: 1px solid #dccaab;
  color: #5c4a2c;
  font-size: 14px;
}

.preview-banner strong {
  color: #4a3a1f;
}

.preview-banner button {
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid #b8a077;
  border-radius: var(--radius-sm);
  background: transparent;
  color: #5c4a2c;
  cursor: pointer;
}

.page {
  width: 100%;
  max-width: 1560px;
  margin: 0 auto;
  padding: 30px 32px 72px;
  outline: none;
}

/* ------------------------------------------------------------ 页头/卡片 */
.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 24px;
}

.eyebrow {
  font-size: 14px;
  letter-spacing: 0.1em;
  color: var(--muted);
  text-transform: uppercase;
}

.page-head h1 {
  margin-top: 6px;
  font-size: 30px;
  line-height: 1.3;
  letter-spacing: 0.01em;
}

.page-head .sub {
  margin-top: 8px;
  color: var(--muted);
  font-size: 15px;
}

.head-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 24px;
  align-items: end;
  padding: 4px 0 26px;
}

.hero h1 {
  margin-top: 8px;
  font-size: clamp(30px, 3.4vw, 42px);
  line-height: 1.2;
  letter-spacing: 0.02em;
}

.hero p {
  margin-top: 10px;
  color: var(--muted);
  font-size: 16px;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 1px 2px rgba(20, 34, 53, 0.04);
}

.card-pad {
  padding: 22px 24px;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.card-head h2 {
  font-size: 19px;
}

.card-head .hint {
  color: var(--muted);
  font-size: 14px;
}

.stat-strip {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 1px;
  overflow: hidden;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: 24px;
}

.stat {
  background: var(--card);
  padding: 18px 22px;
}

.stat dt {
  color: var(--muted);
  font-size: 13px;
  letter-spacing: 0.04em;
}

.stat dd {
  margin: 6px 0 0;
  font-size: 22px;
  font-weight: 600;
}

.stat dd small {
  display: block;
  margin-top: 2px;
  font-size: 13px;
  font-weight: 400;
  color: var(--muted);
}

.overview-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(320px, 1fr);
  gap: 20px;
  align-items: start;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.notice {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 14px 18px;
  border-radius: var(--radius-sm);
  background: var(--primary-soft);
  color: #2f4a63;
  font-size: 14px;
}

.notice--warn {
  background: var(--warn-soft);
  color: #6b531d;
}

.notice--ok {
  background: #e6f1e9;
  color: #2b5a3d;
}

.notice code {
  padding: 1px 5px;
  border-radius: 4px;
  background: rgba(20, 34, 53, 0.08);
  font-size: 12px;
  word-break: break-all;
}

.notice svg {
  flex: none;
  width: 18px;
  height: 18px;
  margin-top: 2px;
}

/* ---------------------------------------------------------------- 按钮 */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 18px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: transparent;
  color: var(--text);
  font-size: 15px;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}

.btn-primary:hover:not(:disabled) {
  background: var(--primary-hover);
}

.btn-secondary {
  background: var(--card);
  border-color: var(--line-strong);
  color: var(--primary);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--primary-soft);
}

.btn-ghost {
  color: var(--primary);
}

.btn-ghost:hover:not(:disabled) {
  background: var(--primary-soft);
}

.btn-danger {
  background: var(--card);
  border-color: #d9b3b3;
  color: var(--danger);
}

.btn-danger:hover:not(:disabled) {
  background: var(--danger-soft);
}

.btn-sm {
  min-height: 44px;
  padding: 0 14px;
  font-size: 14px;
}

input[type="file"] {
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: #fff;
}

.btn-icon {
  width: 44px;
  padding: 0;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--primary);
  cursor: pointer;
}

.icon-btn:hover {
  background: var(--primary-soft);
}

/* ---------------------------------------------------------------- 标签 */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 28px;
  padding: 2px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #f1f5fa;
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.chip--brass {
  border-color: #dccaab;
  background: var(--brass-soft);
  color: #6b5630;
}

.chip--ok {
  border-color: #b8d2c4;
  background: var(--ok-soft);
  color: var(--ok);
}

.chip--warn {
  border-color: #ddc99e;
  background: var(--warn-soft);
  color: var(--warn);
}

.chip--danger {
  border-color: #d9b3b3;
  background: var(--danger-soft);
  color: var(--danger);
}

.chip--nav {
  border-color: #334b66;
  background: var(--nav);
  color: #e9dcc4;
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* ---------------------------------------------------------------- 表格 */
.table-wrap {
  overflow-x: auto;
}

table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 15px;
}

table.data th,
table.data td {
  padding: 12px 14px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

table.data th {
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.04em;
  background: #f3f7fb;
  white-space: nowrap;
}

table.data tbody tr:last-child td {
  border-bottom: 0;
}

table.data tbody tr:hover {
  background: #f6f9fc;
}

.table-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.hp-cell strong {
  font-variant-numeric: tabular-nums;
}

.hp-status {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-left: 6px;
  font-size: 13px;
  color: var(--muted);
}

.hp-status::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--muted);
}

.hp-status.is-full::before {
  background: var(--ok);
}

.hp-status.is-hurt::before {
  background: var(--warn);
}

.hp-status.is-down::before {
  background: var(--danger);
}

.hp-bar {
  width: 84px;
  height: 6px;
  margin-top: 5px;
  border-radius: 3px;
  background: #e2e9f0;
  overflow: hidden;
}

.hp-bar span {
  display: block;
  height: 100%;
  background: var(--primary);
}

.hp-bar.is-hurt span {
  background: var(--warn);
}

.hp-bar.is-down span {
  background: var(--danger);
}

.muted {
  color: var(--muted);
}

.small {
  font-size: 13px;
}

.mono {
  font-family: "Cascadia Code", "Consolas", "Microsoft YaHei", monospace;
  font-size: 13px;
}

.nowrap {
  white-space: nowrap;
}

/* ------------------------------------------------------------ 空状态 */
.empty {
  padding: 40px 28px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  background: #f7fafd;
  text-align: center;
}

.empty h3 {
  font-size: 19px;
  margin-bottom: 8px;
}

.empty p {
  color: var(--muted);
  font-size: 14px;
  max-width: 560px;
  margin: 0 auto 18px;
}

.empty--large {
  padding: 64px 28px;
}

/* ---------------------------------------------------------------- 总览 */
.party-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.party-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #fbfdff;
}

.party-row .who strong {
  display: block;
  font-size: 16px;
}

.party-row .who span {
  color: var(--muted);
  font-size: 13px;
}

.party-stats {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.plan-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.plan-item {
  display: grid;
  grid-template-columns: 26px minmax(0, 1fr);
  gap: 12px;
  padding: 13px 0;
  border-bottom: 1px solid var(--line);
}

.plan-item:last-child {
  border-bottom: 0;
}

.plan-item .index {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--brass-soft);
  color: #6b5630;
  font-size: 13px;
  font-weight: 600;
}

.plan-item h3 {
  font-size: 15px;
  font-weight: 600;
}

.plan-item p {
  margin-top: 3px;
  color: var(--muted);
  font-size: 13px;
}

.archive-note {
  margin-top: 16px;
  padding: 12px 14px;
  border-left: 3px solid var(--line-strong);
  background: #f4f7fa;
  color: var(--muted);
  font-size: 13px;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.tool-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.source-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.source-list li {
  display: flex;
  gap: 10px;
  font-size: 14px;
  color: var(--muted);
}

.source-list li::before {
  content: "·";
  color: var(--brass);
  font-weight: 700;
}

/* ---------------------------------------------------------------- 地图 */
.map-page {
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr) 380px;
  gap: 18px;
  height: calc(100vh - var(--topbar-h) - 150px);
  min-height: 540px;
}

.map-list-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 16px 16px 10px;
}

.panel-head h2 {
  font-size: 15px;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.map-list {
  flex: 1;
  overflow-y: auto;
  padding: 0 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.map-list-item {
  display: block;
  width: 100%;
  padding: 12px 12px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.map-list-item strong {
  display: block;
  font-size: 15px;
}

.map-list-item span {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.map-list-item:hover {
  background: #f1f5fa;
}

.map-list-item.is-active {
  border-color: var(--line-strong);
  background: var(--primary-soft);
}

.map-center {
  position: relative;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.map-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.map-toolbar .tools {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.map-toolbar .hint {
  color: var(--muted);
  font-size: 13px;
}

.map-frame {
  position: relative;
  flex: 1;
  min-height: 380px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--map-board);
  overflow: hidden;
}

.map-viewport {
  position: absolute;
  inset: 0;
  overflow: hidden;
  touch-action: none;
  cursor: grab;
  outline: none;
}

.map-viewport.is-dragging {
  cursor: grabbing;
}

.map-viewport.is-adding {
  cursor: crosshair;
}

.map-stage {
  position: absolute;
  top: 0;
  left: 0;
  transform-origin: 0 0;
  will-change: transform;
}

.map-stage img {
  display: block;
  width: 100%;
  height: 100%;
  user-select: none;
  -webkit-user-drag: none;
  pointer-events: none;
}

.map-marker {
  position: absolute;
  transform: scale(var(--marker-scale, 1));
  transform-origin: 0 0;
  width: 0;
  height: 0;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  overflow: visible;
  z-index: 2;
}

.map-marker-dot {
  position: absolute;
  left: -15px;
  top: -15px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 2px solid #f8f4ea;
  background: var(--nav);
  color: #f4e9d4;
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(20, 34, 53, 0.35);
}

.map-marker::after {
  content: "";
  position: absolute;
  inset: -22px;
  border-radius: 50%;
}

.map-marker-name {
  position: absolute;
  left: 21px;
  top: 0;
  transform: translateY(-50%);
  max-width: 170px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 2px 7px;
  border-radius: 6px;
  border: 1px solid var(--line-strong);
  background: rgba(250, 252, 255, 0.96);
  color: var(--text);
  font-size: 12px;
  font-weight: 500;
  line-height: 1.5;
  box-shadow: 0 2px 6px rgba(20, 34, 53, 0.18);
}

.map-marker:hover .map-marker-dot,
.map-marker.is-selected .map-marker-dot {
  background: var(--primary);
  border-color: var(--brass);
}

.map-marker:focus-visible {
  outline: none;
}

.map-marker:focus-visible .map-marker-dot {
  outline: 3px solid var(--brass);
  outline-offset: 3px;
}

.map-marker.is-selected {
  z-index: 4;
}

.map-marker--npc .map-marker-dot {
  background: #6b5630;
}

.map-marker--public .map-marker-dot {
  background: var(--primary);
}

.map-viewport.is-dense .map-marker-name {
  display: none;
}

.map-viewport.is-dense .map-marker:hover .map-marker-name,
.map-viewport.is-dense .map-marker:focus-visible .map-marker-name,
.map-viewport.is-dense .map-marker.is-selected .map-marker-name {
  display: block;
}

/* ------------------------------------------------- 地图层级 / 入口 / 浮层 */
.map-crumbs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  color: var(--muted);
}

.crumb-link {
  border: 0;
  background: none;
  padding: 4px 6px;
  border-radius: 6px;
  color: var(--primary);
  font-size: 13px;
  text-decoration: underline dotted;
  cursor: pointer;
}

.crumb-link:hover {
  background: var(--primary-soft);
}

.crumb-sep {
  color: var(--muted);
}

.crumb-current {
  padding: 4px 2px;
  color: var(--text);
  font-weight: 600;
}

.map-tiles {
  position: absolute;
  inset: 0;
}

.map-tile {
  position: absolute;
  display: block;
  max-width: none;
  user-select: none;
  -webkit-user-drag: none;
  pointer-events: none;
}

.map-entry {
  position: absolute;
  transform: scale(var(--marker-scale, 1));
  transform-origin: 0 0;
  width: 0;
  height: 0;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  overflow: visible;
  z-index: 3;
}

.map-entry::after {
  content: "";
  position: absolute;
  inset: -22px;
  border-radius: 10px;
}

.map-entry-dot {
  position: absolute;
  left: -16px;
  top: -16px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 2px solid #d9b979;
  background: #27445f;
  color: #f6e8cd;
  font-size: 15px;
  font-weight: 700;
  box-shadow: 0 2px 10px rgba(20, 34, 53, 0.4);
}

.map-entry-name {
  position: absolute;
  left: 22px;
  top: 0;
  transform: translateY(-50%);
  max-width: 190px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 2px 7px;
  border-radius: 6px;
  border: 1px solid #d9b979;
  background: #fbf3e2;
  color: #3d2f16;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.5;
  box-shadow: 0 2px 6px rgba(20, 34, 53, 0.2);
}

.map-entry:hover .map-entry-dot,
.map-entry.is-selected .map-entry-dot {
  background: #b98a3e;
  color: #fff8ea;
}

.map-entry:focus-visible {
  outline: none;
}

.map-entry:focus-visible .map-entry-dot {
  outline: 3px solid var(--brass);
  outline-offset: 3px;
}

.map-entry.is-selected {
  z-index: 4;
}

.map-viewport.is-dense .map-entry-name {
  display: none;
}

.map-viewport.is-dense .map-entry:hover .map-entry-name,
.map-viewport.is-dense .map-entry:focus-visible .map-entry-name,
.map-viewport.is-dense .map-entry.is-selected .map-entry-name {
  display: block;
}

.map-popup {
  position: absolute;
  z-index: 8;
  width: min(390px, calc(100% - 20px));
  max-height: calc(100% - 20px);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 16px 18px 18px;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: var(--card);
  box-shadow: 0 18px 50px rgba(20, 34, 53, 0.35);
}

.map-popup[hidden] {
  display: none;
}

.map-popup-topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.map-popup-close {
  flex: none;
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--card);
  color: var(--muted);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}

.map-popup-close:hover {
  background: var(--primary-soft);
  color: var(--text);
}

.map-popup-title {
  margin: 6px 0 8px;
  font-size: 21px;
  line-height: 1.35;
}

.map-popup .detail-section {
  margin-top: 14px;
}

.map-popup .detail-section ul {
  gap: 4px;
}

.map-popup-loading {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 13px;
}

.entry-row {
  flex-wrap: wrap;
}

.entry-row .marker-row-actions {
  flex-wrap: wrap;
}


.map-empty {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 32px;
  text-align: center;
  color: var(--muted);
  background:
    repeating-linear-gradient(0deg, transparent, transparent 47px, rgba(168, 186, 203, 0.18) 47px, rgba(168, 186, 203, 0.18) 48px),
    repeating-linear-gradient(90deg, transparent, transparent 47px, rgba(168, 186, 203, 0.18) 47px, rgba(168, 186, 203, 0.18) 48px),
    var(--map-board);
}

.map-empty h3 {
  font-size: 23px;
  color: var(--text);
}

.map-empty p {
  max-width: 440px;
  font-size: 14px;
}

.map-hint {
  position: absolute;
  left: 14px;
  bottom: 12px;
  z-index: 4;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(20, 34, 53, 0.72);
  color: #e8eef5;
  font-size: 12px;
  pointer-events: none;
}

.map-missing {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 32px;
  text-align: center;
  background: rgba(213, 223, 233, 0.94);
}

.map-detail {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow-y: auto;
  padding: 22px;
}

.detail-topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.detail-close {
  flex: none;
  width: 44px;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--card);
  color: var(--muted);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}

.detail-close:hover {
  background: var(--primary-soft);
  color: var(--text);
}

.marker-row-actions {
  display: flex;
  gap: 4px;
  flex: none;
}

.detail-kicker {
  color: var(--muted);
  font-size: 13px;
  letter-spacing: 0.06em;
}

.detail-title {
  margin: 6px 0 4px;
  font-size: 24px;
  line-height: 1.35;
}

.detail-sub {
  color: var(--muted);
  font-size: 14px;
}

.detail-section {
  margin-top: 20px;
}

.detail-section h3 {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  font-size: 15px;
  letter-spacing: 0.03em;
  color: var(--primary);
}

.detail-section h3::before {
  content: "";
  width: 14px;
  height: 2px;
  background: var(--brass);
}

.detail-section ul {
  margin: 0;
  padding-left: 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 14px;
}

.detail-section p {
  font-size: 14px;
  color: var(--text);
}

.detail-section--secret {
  padding: 14px;
  border: 1px solid #e0cfa9;
  border-radius: var(--radius-sm);
  background: #fbf5e9;
}

.detail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.meta-grid {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 6px 14px;
  font-size: 13px;
  color: var(--muted);
}

.meta-grid dt {
  white-space: nowrap;
}

.meta-grid dd {
  margin: 0;
  word-break: break-all;
}

.marker-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 8px;
}

.marker-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #fbfdff;
  font-size: 13px;
}

.marker-row button {
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--card);
  color: var(--danger);
  cursor: pointer;
  font-size: 13px;
}

button.chip {
  min-height: 44px;
  padding: 0 14px;
  cursor: pointer;
}

/* ---------------------------------------------------------------- 百科 */
.wiki-page {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  gap: 18px;
  align-items: stretch;
  min-height: calc(100vh - var(--topbar-h) - 210px);
}

.wiki-list-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  max-height: calc(100vh - var(--topbar-h) - 150px);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

.wiki-search {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 14px;
  border-bottom: 1px solid var(--line);
}

.wiki-search input,
.wiki-search select {
  width: 100%;
  min-height: 42px;
}

.wiki-search .result-count {
  font-size: 12px;
  color: var(--muted);
  text-align: right;
}

.wiki-list {
  flex: 1;
  overflow-y: auto;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.wiki-card {
  text-align: left;
}

.wiki-card .meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
}

.wiki-list-empty {
  padding: 16px;
}

.wiki-content {
  min-height: 0;
  max-height: calc(100vh - var(--topbar-h) - 150px);
  overflow-y: auto;
  padding: 24px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.wiki-summary {
  margin-top: 12px;
  font-size: 15px;
  color: var(--muted);
  line-height: 1.7;
}

.wiki-body {
  margin-top: 16px;
  font-size: 15px;
  line-height: 1.8;
  color: var(--text);
  overflow-wrap: anywhere;
}

.wiki-body h1,
.wiki-body h2,
.wiki-body h3,
.wiki-body h4,
.wiki-body h5,
.wiki-body h6 {
  margin: 18px 0 8px;
  line-height: 1.4;
}

.wiki-body h1 {
  font-size: 1.5em;
}

.wiki-body h2 {
  font-size: 1.3em;
}

.wiki-body h3 {
  font-size: 1.15em;
}

.wiki-body p {
  margin: 10px 0;
}

.wiki-body ul,
.wiki-body ol {
  margin: 10px 0;
  padding-left: 22px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.wiki-body blockquote {
  margin: 12px 0;
  padding: 8px 14px;
  border-left: 3px solid var(--brass);
  background: var(--primary-soft);
  color: #33506b;
}

.wiki-body a {
  color: var(--primary);
  text-decoration: underline;
}

.wiki-body code {
  padding: 1px 5px;
  border-radius: 4px;
  background: rgba(20, 34, 53, 0.08);
  font-size: 0.92em;
}

.wiki-body hr {
  margin: 18px 0;
  border: 0;
  border-top: 1px solid var(--line);
}

.wiki-editor {
  max-width: 900px;
}

.wiki-editor-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.wiki-editor .field {
  margin-top: 16px;
}

.wiki-editor textarea#wiki-body {
  min-height: 340px;
  font-family: "Consolas", "Cascadia Mono", "Microsoft YaHei Mono", monospace;
  line-height: 1.6;
}

.wiki-actions {
  border-top: 1px solid var(--line);
  padding-top: 16px;
  margin-top: 20px;
}

.wiki-preview {
  max-height: 62vh;
  overflow-y: auto;
}

/* -------------------------------------------------------------- 地点页 */
.split-page {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 440px;
  gap: 20px;
  align-items: start;
}

.search-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

.search-field {
  position: relative;
  flex: 1;
  min-width: 240px;
}

.search-field svg {
  position: absolute;
  left: 14px;
  top: 50%;
  width: 18px;
  height: 18px;
  transform: translateY(-50%);
  color: var(--muted);
  pointer-events: none;
}

.search-field input {
  width: 100%;
  min-height: 48px;
  padding: 0 16px 0 42px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--card);
}

.result-count {
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}

.entity-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 18px 18px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
}

.entity-card:hover {
  border-color: var(--line-strong);
  box-shadow: var(--shadow);
}

.entity-card.is-active {
  border-color: var(--primary);
  box-shadow: 0 0 0 1px var(--primary) inset;
}

.entity-card h3 {
  font-size: 18px;
}

.entity-card .summary {
  color: var(--muted);
  font-size: 14px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.entity-card .meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: auto;
}

.detail-panel {
  position: sticky;
  top: calc(var(--topbar-h) + 16px);
  max-height: calc(100vh - var(--topbar-h) - 32px);
  overflow-y: auto;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px;
}

.detail-panel .placeholder {
  color: var(--muted);
  font-size: 14px;
  padding: 12px 0;
}

.items-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.items-table th,
.items-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
}

.items-table th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  background: #f3f7fb;
}

.items-table tbody tr:last-child td {
  border-bottom: 0;
}

.service-table .chip {
  min-height: 24px;
}

.service-editor-block {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #fbfdff;
}

.service-editor-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.service-editor-head h3 {
  margin: 0 0 4px;
  color: var(--primary);
  font-size: 16px;
}

.service-editor-head .help {
  max-width: 640px;
}

.service-rows {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 14px;
}

.service-row {
  display: grid;
  grid-template-columns: 130px minmax(0, 1fr) 140px minmax(0, 1.2fr) auto;
  gap: 10px;
  align-items: end;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #fff;
}

.service-row .field {
  gap: 4px;
}

.service-row .field label {
  font-size: 12px;
}

.service-row .btn {
  min-height: 44px;
  align-self: end;
}

.service-editor-actions {
  margin-top: 12px;
}

.service-copy-list {
  display: flex;
  flex-direction: column;
  max-height: 55vh;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}

.service-copy-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  background: #fbfdff;
  cursor: pointer;
}

.service-copy-row:last-child {
  border-bottom: 0;
}

.service-copy-row:hover {
  background: var(--primary-soft);
}

.service-copy-row input {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
}

.service-copy-price {
  color: var(--muted);
  font-size: 13px;
}

@media (max-width: 900px) {
  .service-row {
    grid-template-columns: 1fr;
  }

  .service-row .btn {
    justify-self: start;
  }
}

.stock-unknown {
  color: var(--warn);
  font-size: 13px;
}

.source-line {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  line-height: 1.7;
  word-break: break-all;
}

.relation-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 14px;
}

.relation-list .rel-target {
  font-weight: 600;
  color: var(--primary);
}

/* ---------------------------------------------------------------- 弹窗 */
dialog.modal {
  width: min(720px, calc(100vw - 32px));
  max-height: calc(100vh - 64px);
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  color: var(--text);
  box-shadow: 0 24px 80px rgba(20, 34, 53, 0.3);
}

dialog.modal--wide {
  width: min(1040px, calc(100vw - 32px));
}

dialog.modal::backdrop {
  background: rgba(20, 34, 53, 0.5);
  backdrop-filter: blur(2px);
}

.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 24px 12px;
  border-bottom: 1px solid var(--line);
}

.modal-head h2 {
  font-size: 20px;
}

.modal-head p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.modal-close {
  flex: none;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  font-size: 24px;
  cursor: pointer;
}

.modal-close:hover {
  background: var(--primary-soft);
}

.modal-body {
  padding: 20px 24px;
  overflow-y: auto;
  max-height: calc(100vh - 260px);
}

.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 24px 20px;
  border-top: 1px solid var(--line);
  flex-wrap: wrap;
}

/* ---------------------------------------------------------------- 表单 */
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.field--full {
  grid-column: 1 / -1;
}

.field label {
  font-size: 14px;
  color: var(--muted);
}

.field label .req {
  color: var(--danger);
  margin-left: 2px;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: #fff;
}

.field textarea {
  min-height: 84px;
  resize: vertical;
}

.field .help {
  color: var(--muted);
  font-size: 12px;
}

.field .error-text {
  color: var(--danger);
  font-size: 12px;
}

.field.has-error input,
.field.has-error select,
.field.has-error textarea {
  border-color: var(--danger);
}

.form-error {
  margin-top: 14px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 14px;
}

.attendance-options,
.condition-options {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.check-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  padding: 0 14px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: #fff;
  font-size: 14px;
  cursor: pointer;
}

.check-pill input {
  width: 18px;
  height: 18px;
  min-height: 0;
  margin: 0;
  accent-color: var(--primary);
}

/* -------------------------------------------------------------- 导入/备份 */
.import-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.import-summary {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 13px;
}

.import-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 46vh;
  overflow-y: auto;
}

.import-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #fbfdff;
}

.import-row .info {
  min-width: 0;
  flex: 1;
}

.import-row .info strong {
  display: block;
  font-size: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.import-row .info span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.import-row .actions {
  display: flex;
  gap: 6px;
  flex: none;
}

.diff {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #fbfdff;
  overflow: auto;
  max-height: 52vh;
  font-family: "Cascadia Code", "Consolas", monospace;
  font-size: 13px;
  line-height: 1.55;
}

.diff-line {
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr);
  gap: 8px;
  padding: 1px 10px;
  white-space: pre-wrap;
  word-break: break-word;
}

.diff-line .sign {
  color: var(--muted);
  text-align: right;
  user-select: none;
}

.diff-line--add {
  background: #e6f2ea;
  color: #28543f;
}

.diff-line--del {
  background: #f8e7e7;
  color: #7d2f2f;
}

.diff-line--same {
  color: #55687c;
}

.preview-md {
  font-size: 14px;
  line-height: 1.8;
  max-height: 46vh;
  overflow-y: auto;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #fbfdff;
}

.preview-md h1,
.preview-md h2,
.preview-md h3 {
  margin: 14px 0 8px;
}

.preview-md p {
  margin: 8px 0;
}

.preview-md ul,
.preview-md ol {
  margin: 8px 0;
  padding-left: 22px;
}

.preview-md blockquote {
  margin: 10px 0;
  padding: 6px 14px;
  border-left: 3px solid var(--brass);
  color: var(--muted);
  background: #f7f4ec;
}

.preview-md code {
  padding: 1px 5px;
  border-radius: 4px;
  background: #eef3f8;
  font-family: "Cascadia Code", "Consolas", monospace;
  font-size: 13px;
}

.preview-md .wikilink {
  color: var(--primary);
  text-decoration: underline dotted;
}

.backup-actions {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.backup-block {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #fbfdff;
}

.backup-block h3 {
  margin-bottom: 6px;
  font-size: 16px;
}

.backup-block p {
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 12px;
}

/* ---------------------------------------------------------------- 提示 */
.toast-root {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 60;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: min(420px, calc(100vw - 32px));
}

.toast {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 13px 16px;
  border-radius: var(--radius-sm);
  background: var(--nav);
  color: #edf2f7;
  box-shadow: var(--shadow);
  font-size: 14px;
  animation: toast-in 0.18s ease-out;
}

.toast--ok {
  background: #26473a;
}

.toast--error {
  background: #6f2c2c;
}

.toast--warn {
  background: #5d4a22;
}

.toast button {
  flex: none;
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid rgba(255, 255, 255, 0.4);
  border-radius: 6px;
  background: transparent;
  color: #fff;
  cursor: pointer;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.loading {
  padding: 60px 20px;
  text-align: center;
  color: var(--muted);
}

.spinner {
  width: 26px;
  height: 26px;
  margin: 0 auto 12px;
  border: 3px solid var(--line);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ------------------------------------------------------------ 移动导航 */
.bottom-nav {
  display: none;
}

/* ------------------------------------------------------------ 响应式 */
@media (max-width: 1300px) {
  .map-page {
    grid-template-columns: 220px minmax(0, 1fr) 330px;
  }

  .split-page {
    grid-template-columns: minmax(0, 1fr) 390px;
  }
}

@media (max-width: 1100px) {
  .map-page {
    grid-template-columns: 200px minmax(0, 1fr);
    height: auto;
  }

  .map-detail {
    grid-column: 1 / -1;
    max-height: none;
  }

  .overview-grid {
    grid-template-columns: 1fr;
  }

  .split-page {
    grid-template-columns: 1fr;
  }

  .detail-panel {
    position: static;
    max-height: none;
  }

  .stat-strip {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 900px) {
  .sidebar {
    display: none;
  }

  .main-wrap {
    margin-left: 0;
    padding-bottom: 76px;
  }

  .topbar {
    padding: 10px 16px;
    min-height: 64px;
  }

  .topbar .session-chip {
    display: none;
  }

  .page {
    padding: 22px 16px 40px;
  }

  .hero {
    grid-template-columns: 1fr;
  }

  .hero h1 {
    font-size: 28px;
  }

  .stat-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .page-head {
    flex-direction: column;
    align-items: stretch;
    gap: 14px;
  }

  .preview-banner {
    padding: 10px 16px;
    font-size: 13px;
  }

  .bottom-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 30;
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    background: var(--nav);
    border-top: 1px solid #22344d;
    padding-bottom: env(safe-area-inset-bottom);
  }

  .bottom-nav a {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    min-height: 62px;
    color: #b9c8d8;
    text-decoration: none;
    font-size: 10px;
    letter-spacing: -0.02em;
    white-space: nowrap;
  }

  .bottom-nav a svg {
    width: 20px;
    height: 20px;
  }

  .bottom-nav a.is-active {
    color: #f0e2c8;
    background: rgba(45, 69, 96, 0.65);
  }

  .map-page {
    grid-template-columns: 1fr;
    height: auto;
  }

  .map-list-panel {
    max-height: 220px;
  }

  .map-center {
    min-height: 60vh;
  }

  .map-frame {
    min-height: 60vh;
  }

  .map-detail {
    grid-column: auto;
  }

  .wiki-page {
    grid-template-columns: 1fr;
    min-height: 0;
  }

  .wiki-list-panel {
    max-height: 300px;
  }

  .wiki-content {
    max-height: none;
    padding: 18px;
  }

  .map-detail.has-selection {
    position: fixed;
    left: 12px;
    right: 12px;
    bottom: calc(76px + env(safe-area-inset-bottom));
    z-index: 45;
    max-height: 64vh;
    padding: 18px 18px 24px;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(20, 34, 53, 0.42);
  }

  .map-popup {
    position: fixed;
    left: 12px;
    right: 12px;
    bottom: calc(76px + env(safe-area-inset-bottom));
    top: auto;
    width: auto;
    max-height: min(64vh, 540px);
    z-index: 46;
    padding: 18px;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(20, 34, 53, 0.42);
  }

  .map-detail.has-selection .detail-title {
    font-size: 21px;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .modal-body {
    max-height: calc(100vh - 240px);
  }

  .toast-root {
    bottom: 84px;
    left: 16px;
    right: 16px;
    max-width: none;
  }

  .table-wrap {
    overflow: visible;
  }

  table.data,
  table.data thead,
  table.data tbody,
  table.data th,
  table.data td,
  table.data tr {
    display: block;
  }

  table.data thead {
    display: none;
  }

  table.data tbody tr {
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--card);
    margin-bottom: 10px;
    padding: 10px 12px;
  }

  table.data tbody td {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 6px 0;
    border: 0;
  }

  table.data tbody td::before {
    content: attr(data-label);
    flex: none;
    color: var(--muted);
    font-size: 12px;
    padding-top: 2px;
  }

  .table-actions {
    width: 100%;
  }

  .table-actions .btn {
    flex: 1;
  }
}

@media (max-width: 560px) {
  .stat-strip {
    grid-template-columns: 1fr;
  }

  .card-pad {
    padding: 18px 16px;
  }

  .tool-grid {
    grid-template-columns: 1fr;
  }

  .page-head h1 {
    font-size: 25px;
  }

  .topbar .role-toggle {
    display: none;
  }

  .topbar-meta {
    gap: 8px;
  }

  .crumb {
    font-size: 13px;
  }
}

@media (max-width: 430px) {
  #crumb-campaign,
  .crumb-sep--campaign {
    display: none;
  }

  /* 六个导航项不硬挤：底部导航内部横向滚动，标签与点击区域保持可读。 */
  .bottom-nav {
    display: flex;
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }

  .bottom-nav::-webkit-scrollbar {
    display: none;
  }

  .bottom-nav a {
    flex: 0 0 20%;
    min-width: 74px;
    scroll-snap-align: start;
  }

  .bottom-nav a span {
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* ---------------------------------------------------------- 登录与身份 */
body.auth-locked {
  background: #eef1f5;
}

body.auth-locked .app-shell {
  display: none;
}

body.auth-locked .bottom-nav {
  display: none;
}

.auth-gate[hidden],
#app-shell[hidden] {
  display: none;
}

.auth-gate {
  min-height: 100vh;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 24px;
  overflow-y: auto;
}

.auth-card {
  width: min(420px, 100%);
  padding: 30px;
  border: 1px solid #d5dce6;
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 18px 50px rgba(20, 38, 60, 0.12);
}

.auth-card--wide {
  width: min(980px, 100%);
  margin: auto;
  max-height: none;
}

.role-choice h1 {
  margin: 0 0 6px;
  font-size: 28px;
}

.role-choice-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 230px));
  gap: 14px;
  margin-top: 18px;
}

.role-choice-status {
  min-height: 20px;
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
}

.role-choice-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  padding: 10px;
  border: 1px solid #d5dce6;
  border-radius: 12px;
  background: #fbfdff;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
}

.role-choice-card:hover,
.role-choice-card:focus-visible {
  border-color: #4a7fb5;
  box-shadow: 0 6px 18px rgba(30, 65, 100, 0.12);
  outline: none;
  transform: translateY(-1px);
}

.role-choice-card:disabled {
  cursor: wait;
  opacity: 0.66;
}

.role-choice-portrait {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  border-radius: 9px;
  background: #e8eef5;
  color: #8fa2b6;
  font-size: 34px;
  font-weight: 700;
}

.role-choice-portrait img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform-origin: center;
}

.role-choice-name {
  margin: 0;
  font-size: 18px;
}

.role-choice-meta {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.auth-separator {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 24px 0 16px;
  color: var(--muted);
  font-size: 13px;
}

.auth-separator::before,
.auth-separator::after {
  content: '';
  flex: 1;
  height: 1px;
  background: #dbe3ec;
}

.auth-dm-panel {
  width: min(460px, 100%);
  margin: 0 auto;
}

.auth-dm-panel h2 {
  margin: 0 0 4px;
  font-size: 21px;
}

.auth-dm-panel .field {
  margin-top: 12px;
}

.auth-dm-panel .btn-primary {
  width: 100%;
  margin-top: 14px;
}

.auth-dm-panel .source-line {
  margin-top: 14px;
}

@media (max-width: 640px) {
  .auth-gate {
    align-items: flex-start;
    padding: 12px;
  }
  .auth-card--wide {
    max-height: none;
    padding: 18px;
  }
  .role-choice-grid {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 10px;
  }
  .role-choice h1 {
    font-size: 23px;
  }
  .role-choice-portrait {
    aspect-ratio: 1 / 1;
  }
}

.auth-card .brand {
  margin-bottom: 20px;
}

.auth-card h1 {
  margin: 0 0 6px;
  font-size: 26px;
}

.auth-card .field {
  margin-top: 14px;
}

.auth-card .btn-primary {
  width: 100%;
  margin-top: 16px;
}

.auth-card .source-line {
  margin-top: 16px;
}

.account-chip {
  display: inline-flex;
  align-items: center;
  padding: 4px 9px;
  border-radius: 999px;
  background: #eef2f7;
  color: #33465a;
  font-size: 12px;
  white-space: nowrap;
}

.account-create {
  padding: 14px;
  border: 1px dashed #d5dce6;
  border-radius: 10px;
  background: #f8fafc;
}

.select-compact {
  max-width: 180px;
  margin-right: 8px;
  padding: 6px 8px;
  border: 1px solid #d5dce6;
  border-radius: 6px;
  background: #fff;
  font: inherit;
  font-size: 13px;
}

@media (max-width: 900px) {
  .account-chip {
    display: none;
  }
}

/* ---------------------------------------------------------- 地图标题原位编辑 */
.map-title-trigger {
  display: inline-block;
  padding: 2px 6px;
  margin-left: -6px;
  border: 1px dashed transparent;
  border-radius: 6px;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: text;
}

.map-title-trigger:hover,
.map-title-trigger:focus-visible {
  border-color: #9fb1c4;
  background: #f1f5f9;
}

.map-title-form {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 6px 0 4px;
}

.map-title-form input {
  flex: 1 1 260px;
  min-width: 180px;
  padding: 7px 9px;
  border: 1px solid var(--line, #c9d4e0);
  border-radius: 6px;
  background: #fff;
  font: inherit;
  font-size: 20px;
  font-weight: 700;
}

.map-title-form .form-error {
  flex-basis: 100%;
}

/* ---------------------------------------------------------- 百科富文本 */
.wiki-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  padding: 8px;
  margin-bottom: 8px;
  border: 1px solid #d5dce6;
  border-radius: 8px;
  background: #f7fafc;
}

.wiki-toolbar select {
  max-width: 130px;
  padding: 5px 6px;
  border: 1px solid #d5dce6;
  border-radius: 6px;
  background: #fff;
  font: inherit;
  font-size: 12px;
}

.wiki-color-label {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: var(--muted);
}

.wiki-color-label input[type="color"] {
  width: 28px;
  height: 26px;
  padding: 0;
  border: 1px solid #d5dce6;
  border-radius: 4px;
  background: #fff;
}

.wiki-editor-body {
  min-height: 300px;
  max-height: 56vh;
  overflow: auto;
  padding: 14px;
  border: 1px solid #c9d4e0;
  border-radius: 8px;
  background: #fff;
  font-size: 15px;
  line-height: 1.8;
  outline: none;
}

.wiki-editor-body:focus {
  border-color: #4a7fb5;
  box-shadow: 0 0 0 3px rgba(74, 127, 181, 0.14);
}

.wiki-editor-body:empty::before {
  content: attr(data-placeholder);
  color: #9aa9ba;
}

.wiki-editor-body h1,
.wiki-editor-body h2,
.wiki-editor-body h3,
.wiki-editor-body h4,
.wiki-editor-body h5,
.wiki-editor-body h6 {
  margin: 0.8em 0 0.35em;
  line-height: 1.4;
}

.wiki-editor-body p,
.wiki-editor-body div {
  margin: 0.5em 0;
}

.wiki-editor-body ul,
.wiki-editor-body ol {
  padding-left: 1.6em;
}

.wiki-editor-body blockquote {
  margin: 0.8em 0;
  padding: 6px 12px;
  border-left: 3px solid #b9c7d6;
  color: #52667a;
  background: #f7fafc;
}

.wiki-editor-body figure {
  margin: 12px 0;
}

.wiki-editor-body figure.is-selected {
  outline: 2px dashed #4a7fb5;
  outline-offset: 4px;
}

.wiki-editor-body img {
  max-width: 100%;
  height: auto;
  border-radius: 6px;
}

.wiki-editor-body figcaption {
  color: var(--muted);
  font-size: 12px;
  text-align: center;
  margin-top: 4px;
}

.wiki-body figure {
  margin: 14px 0;
}

.wiki-body figure img {
  max-width: 100%;
  height: auto;
  border-radius: 6px;
}

.wiki-body figcaption {
  color: var(--muted);
  font-size: 12px;
  text-align: center;
  margin-top: 4px;
}

.npc-card {
  align-items: flex-start;
}

.npc-card-thumb {
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  border-radius: 10px;
  background: #e8eef5;
  margin-bottom: 10px;
}

.npc-card-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform-origin: center;
}

.npc-card-thumb--empty {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 44px;
  color: #8fa2b6;
}

.npc-detail-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.npc-media-grid {
  display: grid;
  grid-template-columns: minmax(120px, 180px) 1fr;
  gap: 16px;
  margin: 16px 0;
  align-items: start;
}

.npc-media-figure {
  margin: 0;
  cursor: zoom-in;
}

.npc-media-frame {
  overflow: hidden;
  border-radius: 10px;
  background: #e8eef5;
}

.npc-media-frame img {
  display: block;
  width: 100%;
  height: auto;
  transform-origin: center;
}

.npc-media-frame--avatar {
  aspect-ratio: 1 / 1;
}

.npc-media-frame--avatar img {
  height: 100%;
  object-fit: cover;
}

.npc-media-figure figcaption {
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
}

.npc-media-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 110px;
  border: 1px dashed #c6d2df;
  border-radius: 10px;
  color: #8a9aad;
  font-size: 13px;
  background: #f7fafc;
}

.npc-media-block {
  padding: 14px;
  border: 1px solid #dbe3ec;
  border-radius: 12px;
  margin-bottom: 14px;
  background: #fbfdff;
}

.npc-media-block-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 10px;
}

.npc-media-manage-preview {
  width: min(260px, 100%);
  aspect-ratio: 4 / 3;
  overflow: hidden;
  border-radius: 10px;
  background: #e8eef5;
  margin-bottom: 10px;
}

.npc-media-manage-preview--avatar {
  width: 180px;
  aspect-ratio: 1 / 1;
}

.npc-media-manage-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform-origin: center;
}

.npc-crop-controls {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 10px 0;
}

.npc-crop-controls label {
  display: grid;
  gap: 4px;
  font-size: 12px;
  color: var(--muted);
}

.npc-media-full {
  max-height: 72vh;
  overflow: auto;
  text-align: center;
}

.npc-media-full img {
  max-width: 100%;
  height: auto;
}

.map-popup-avatar {
  display: block;
  width: 84px;
  height: 84px;
  object-fit: cover;
  border-radius: 10px;
  margin: 0 0 8px;
  transform: none !important;
}

@media (max-width: 720px) {
  .npc-media-grid {
    grid-template-columns: 1fr;
  }
  .npc-media-manage-preview--avatar {
    width: 140px;
  }
  .npc-crop-controls {
    grid-template-columns: 1fr;
  }
}




/* ---------------------------------------------------- 玩家角色登录立绘 */
.character-cell { display: flex; align-items: center; gap: 10px; }
.character-thumb { display: inline-flex; align-items: center; justify-content: center; width: 54px; height: 68px; flex: 0 0 54px; overflow: hidden; border-radius: 7px; background: #e8eef5; color: #8fa2b6; font-size: 11px; }
.character-thumb img { width: 100%; height: 100%; object-fit: cover; transform-origin: center; }
.character-thumb--empty { font-size: 11px; }
.character-portrait-manager-preview { display: flex; align-items: center; justify-content: center; width: min(260px, 100%); aspect-ratio: 4 / 5; overflow: hidden; border-radius: 10px; background: #e8eef5; margin-bottom: 12px; }
.character-portrait-manager-preview img { width: 100%; height: 100%; object-fit: cover; transform-origin: center; }

/* ---------------------------------------------------- 玩家自己的登录立绘 */
.my-character-summary {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  margin-top: 10px;
}
.my-character-portrait {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 150px;
  flex: 0 0 150px;
  aspect-ratio: 4 / 5;
  overflow: hidden;
  border-radius: 10px;
  background: #e8eef5;
  color: #8fa2b6;
  font-size: 12px;
  text-align: center;
}
.my-character-portrait img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform-origin: center;
}
@media (max-width: 640px) {
  .my-character-summary { flex-direction: column; }
  .my-character-portrait { width: 120px; flex-basis: 120px; }
}

@media (max-width: 640px) {
  dialog.modal { max-height: calc(100vh - 16px); margin: 8px auto; }
  .modal-head { padding: 14px 16px 10px; }
  .modal-body { padding: 14px 16px; max-height: calc(100vh - 230px); }
  .modal-foot { position: sticky; bottom: 0; background: var(--card); padding: 10px 16px 14px; }
}
