:root {
  color-scheme: light;
  font-family: "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
  background: #eef3f7;
  color: #1f2937;
}

* { box-sizing: border-box; }
body { margin: 0; overflow: hidden; }
body.settings-page { overflow: auto; min-height: 100vh; }

.topbar {
  height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  background: rgba(255, 255, 255, 0.94);
  border-bottom: 1px solid #d6dee8;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
  position: relative;
  z-index: 10;
}

h1 { margin: 0; font-size: 24px; }
.topbar p { margin: 4px 0 0; color: #64748b; font-size: 13px; }
.topbar-actions { display: flex; align-items: center; gap: 12px; }
.scale-control { flex-direction: row; align-items: center; gap: 8px; color: #475569; }
.scale-control input { width: 160px; padding: 0; }
#cardScaleValue { min-width: 42px; color: #2563eb; font-weight: 800; }
button, .upload-inline {
  border: 0;
  border-radius: 10px;
  padding: 9px 16px;
  cursor: pointer;
  font-weight: 700;
}
.primary { background: #2563eb; color: white; }
.secondary { background: #e2e8f0; color: #1e293b; }
.danger { background: #dc2626; color: white; }
.hidden { display: none !important; }

.workspace { height: calc(100vh - 72px); }
.map-wrap {
  position: relative;
  height: 100%;
  overflow: hidden;
  background: radial-gradient(circle at 30% 20%, #ffffff 0, #e7f0fb 42%, #dbe8f5 100%);
}
#mapSvg, #linkSvg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
#linkSvg { pointer-events: none; z-index: 3; }
.map-wrap.picking-coordinate, .map-wrap.picking-coordinate .province { cursor: crosshair; }
.province {
  stroke: rgba(255, 255, 255, 0.78);
  stroke-width: 0.55;
  cursor: grab;
  filter: drop-shadow(0 1px 1px rgba(15, 23, 42, 0.12));
}
.province:hover { stroke: #334155; stroke-width: 0.9; }
.province-label {
  pointer-events: none;
  text-anchor: middle;
  dominant-baseline: middle;
  fill: #1e293b;
  font-size: 12px;
  font-weight: 800;
  stroke-width: 1px;
}
.pin { fill: #e11d48; stroke: #fff; stroke-width: 2; pointer-events: auto; }
.pin-label { fill: #0f172a; font-size: 12px; paint-order: stroke; stroke: white; stroke-width: 3; }
.cards-layer { position: absolute; inset: 0; z-index: 4; pointer-events: none; }
.trip-card {
  position: absolute;
  width: 210px;
  min-height: 120px;
  pointer-events: auto;
  touch-action: none;
  user-select: none;
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid #d9e2ef;
  border-radius: 16px;
  box-shadow: 0 18px 45px rgba(15, 23, 42, 0.16);
  overflow: hidden;
  cursor: grab;
  transform-origin: top left;
}
.trip-card:active { cursor: grabbing; }
.trip-card .card-cover { width: 100%; height: auto; display: block; background: #f8fafc; user-select: none; pointer-events: none; }
.trip-card .no-cover { aspect-ratio: 4 / 3; display: grid; place-items: center; color: #94a3b8; }
.trip-card.portrait-card .body { padding: 0.5em 0.65em 0.6em; }
.trip-card .body { padding: 0.6em 0.75em 0.7em; }
.trip-card strong { display: block; margin-bottom: 0.15em; font-size: var(--card-title-font-size, 16px); line-height: 1.2; }
.trip-card span { color: #64748b; font-size: var(--card-meta-font-size, 13px); line-height: 1.2; }
.map-hint {
  position: absolute;
  left: 20px;
  bottom: 18px;
  z-index: 5;
  color: #475569;
  background: rgba(255, 255, 255, 0.78);
  padding: 8px 12px;
  border-radius: 999px;
  font-size: 13px;
}

.trip-overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(15, 23, 42, 0.35);
}
.trip-dialog {
  width: 920px;
  max-width: calc(100vw - 48px);
  max-height: calc(100vh - 48px);
  overflow: hidden;
  border-radius: 22px;
  background: white;
  box-shadow: 0 30px 80px rgba(15, 23, 42, 0.3);
}
.trip-dialog-scroll {
  max-height: calc(100vh - 48px);
  overflow: auto;
  scrollbar-width: thin;
  scrollbar-color: #cbd5e1 transparent;
  padding-right: 4px;
}
.trip-dialog-scroll::-webkit-scrollbar { width: 6px; height: 6px; }
.trip-dialog-scroll::-webkit-scrollbar-track { background: transparent; border-radius: 999px; }
.trip-dialog-scroll::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 999px;
}
.trip-dialog-scroll::-webkit-scrollbar-thumb:hover { background: #94a3b8; }
.rich-editor .ql-editor::-webkit-scrollbar,
.cleanup-result::-webkit-scrollbar { width: 6px; height: 6px; }
.rich-editor .ql-editor::-webkit-scrollbar-track,
.cleanup-result::-webkit-scrollbar-track { background: transparent; border-radius: 999px; }
.rich-editor .ql-editor::-webkit-scrollbar-thumb,
.cleanup-result::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 999px;
}
.rich-editor .ql-editor::-webkit-scrollbar-thumb:hover,
.cleanup-result::-webkit-scrollbar-thumb:hover { background: #94a3b8; }
.glightbox-container { z-index: 2147483647 !important; }
.export-card {
  background: white;
  border-radius: 18px;
  padding: 28px;
  width: 380px;
  max-width: calc(100vw - 48px);
  box-shadow: 0 30px 80px rgba(15, 23, 42, 0.3);
}
.export-card h2 { margin: 0 0 18px; font-size: 18px; }
.export-options { display: flex; flex-direction: column; gap: 14px; margin-bottom: 20px; }
.export-options label { flex-direction: row; align-items: center; gap: 10px; }
.export-options select {
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  padding: 7px 10px;
  font: inherit;
}
.export-actions { display: flex; gap: 10px; justify-content: flex-end; }
#tripForm { padding: 22px; }
.dialog-head { display: flex; justify-content: space-between; gap: 20px; align-items: center; margin-bottom: 18px; }
.dialog-head h2 { margin: 0; color: #0f172a; font-size: 18px; font-weight: 700; }
.dialog-actions { display: flex; gap: 8px; }
.form-grid, .upload-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}
.upload-grid { grid-template-columns: repeat(3, 1fr); margin-top: 14px; }
label { display: flex; flex-direction: column; gap: 6px; color: #334155; font-size: 13px; font-weight: 700; }
label.wide { grid-column: 1 / span 2; }
label.wide-row { grid-column: 1 / -1; }
.coord-inline, .date-inline {
  display: flex;
  align-items: center;
  gap: 8px;
}
.coord-inline input, .date-inline input { flex: 1; min-width: 0; }
.coord-inline button { flex-shrink: 0; white-space: nowrap; }
.date-inline span { color: #94a3b8; font-weight: 400; flex-shrink: 0; }
input, .coordinate-picker-field button {
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  padding: 9px 10px;
  font: inherit;
  background: white;
}
.editor-section { margin-top: 16px; }
.section-title { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; font-size: 14px; font-weight: 700; color: #1e293b; }
.rich-editor { background: white; }
.rich-editor .ql-editor { min-height: 170px; max-height: 300px; overflow: auto; line-height: 1.6; }
.rich-editor img { max-width: 100%; border-radius: 10px; }
.media-editor {
  margin-top: 16px;
  display: grid;
  grid-template-columns: 90px minmax(0, 1fr);
  gap: 10px 14px;
  align-items: start;
}
.media-row-title { padding-top: 9px; font-size: 14px; font-weight: 700; color: #1e293b; }
.cover-picker {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
  cursor: pointer;
}
.cover-picker input { display: none; }
#coverPreviewText {
  min-width: 150px;
  color: #2563eb;
  padding-top: 9px;
  word-break: break-all;
}
#coverPreview {
  display: none;
  max-width: 220px;
  max-height: 280px;
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 12px;
  border: 1px solid #dbe3ee;
  background: #f8fafc;
}
.coordinate-picker-field button { width: max-content; background: #e2e8f0; color: #1e293b; font-weight: 700; }
.album-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(86px, 86px)); gap: 10px; }
.album-tile {
  position: relative;
  width: 86px;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border: 1px solid #dbe3ee;
  border-radius: 10px;
  background: #f8fafc;
  overflow: hidden;
}
.album-tile .delete-btn {
  position: absolute;
  top: 3px;
  right: 3px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: rgba(220, 38, 38, 0.88);
  color: white;
  border: none;
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
  line-height: 22px;
  text-align: center;
  padding: 0;
  z-index: 2;
}
.album-tile .delete-btn:hover { background: #dc2626; }
.album-tile > a { display: contents; }
.album-tile img { width: 100%; height: 100%; object-fit: contain; display: block; }
.empty-text { color: #94a3b8; font-size: 13px; }
.files-panel {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid #e2e8f0;
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
}
.files-section-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.files-section-head h3 { margin: 0; font-size: 14px; font-weight: 700; color: #1e293b; }
.del-badge { font-weight: 400; font-size: 12px; color: #dc2626; }
.upload-inline {
  display: inline-flex;
  align-items: center;
  padding: 4px 11px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  background: #dbeafe;
  color: #1d4ed8;
}
.upload-inline:hover { background: #bfdbfe; }
.files-panel .album-grid { margin-bottom: 0; }
.file-list { margin: 0; padding-left: 0; list-style: none; }
.file-list li { display: flex; align-items: center; gap: 8px; padding: 4px 0; }
.file-list li a { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-list .delete-btn {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: rgba(220, 38, 38, 0.82);
  color: white;
  border: none;
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
  line-height: 20px;
  text-align: center;
  padding: 0;
}
.file-list .delete-btn:hover { background: #dc2626; }
.ql-disabled { background: #f8fafc; }
input:disabled { background: #f8fafc; color: #64748b; }

.settings-main {
  max-width: 880px;
  margin: 28px auto;
  padding: 0 24px 40px;
}
.settings-card {
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid #d9e2ef;
  border-radius: 18px;
  box-shadow: 0 18px 45px rgba(15, 23, 42, 0.1);
  padding: 22px;
  margin-bottom: 18px;
}
.settings-card h2 { margin: 0 0 16px; }
.settings-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.settings-actions { display: flex; align-items: center; gap: 12px; margin-top: 18px; }
.status-text { color: #16a34a; font-weight: 800; }
.settings-note { color: #64748b; margin-top: 0; }
.cleanup-result {
  margin-top: 14px;
  padding: 12px;
  border-radius: 12px;
  background: #0f172a;
  color: #e2e8f0;
  white-space: pre-wrap;
  max-height: 360px;
  overflow: auto;
}

.tag-selector { position: relative; }
.tag-selector-container {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px;
  padding: 6px 8px;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  background: white;
  cursor: text;
  min-height: 39px;
}
.tag-selector-container:focus-within {
  border-color: #2563eb;
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.15);
}
.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.tag-item {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 3px 8px;
  background: #dbeafe;
  color: #1d4ed8;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
  cursor: default;
  user-select: none;
}
.tag-item .tag-remove {
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  opacity: 0.65;
  margin-left: 1px;
}
.tag-item .tag-remove:hover { opacity: 1; }
.tag-input {
  flex: 1;
  min-width: 80px;
  border: none !important;
  outline: none;
  padding: 3px 2px;
  font: inherit;
  font-size: 13px;
  background: transparent;
}
.tag-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  margin-top: 4px;
  background: white;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.15);
  max-height: 220px;
  overflow-y: auto;
  z-index: 100;
  list-style: none;
  padding: 6px;
}
.tag-dropdown-item {
  padding: 7px 10px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.tag-dropdown-item.available {
  background: #eff6ff;
  color: #1e293b;
}
.tag-dropdown-item.available:hover { background: #dbeafe; }
.tag-dropdown-item.selected {
  background: #e2e8f0;
  color: #64748b;
  cursor: default;
}
.tag-dropdown-item .count { color: #94a3b8; font-size: 12px; }
.tag-dropdown-item.selected .count { color: #94a3b8; }
.tag-dropdown-empty { padding: 10px; color: #94a3b8; font-size: 13px; text-align: center; }

.participant-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  margin-bottom: 12px;
}
.participant-search {
  display: flex;
  align-items: center;
  gap: 8px;
}
.participant-search input {
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  padding: 7px 10px;
  font: inherit;
  font-size: 13px;
  width: 180px;
}
.participant-controls {
  display: flex;
  align-items: center;
}
.participant-controls label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: #64748b;
}
.participant-controls select {
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  padding: 5px 8px;
  font: inherit;
}
.participant-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: auto;
}
.participant-table th, .participant-table td {
  padding: 9px 8px;
  border-bottom: 1px solid #e2e8f0;
  font-size: 13px;
  text-align: center;
}
.participant-table th { color: #64748b; font-weight: 800; }
.participant-table th:first-child { text-align: left; }
.participant-table td { color: #1e293b; white-space: nowrap; }
.participant-table td:first-child { text-align: left; font-weight: 700; }
.participant-table .col-date { font-size: 12px; color: #64748b; font-variant-numeric: tabular-nums; }
.participant-table .col-count { font-variant-numeric: tabular-nums; }
.participant-table .col-actions { width: 50px; }
.participant-table .delete-btn {
  background: none;
  border: none;
  color: #dc2626;
  cursor: pointer;
  font-weight: 700;
  font-size: 13px;
  padding: 4px 8px;
  border-radius: 6px;
}
.participant-table .delete-btn:hover { background: #fef2f2; }

.participant-add-form {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
}
.add-toggle-btn {
  width: 36px;
  height: 36px;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  background: white;
  color: #475569;
  font-size: 22px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  line-height: 1;
  flex-shrink: 0;
}
.add-toggle-btn.expanded {
  background: #e2e8f0;
  color: #94a3b8;
}
.add-fields {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.add-fields input {
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  padding: 7px 10px;
  font: inherit;
  font-size: 13px;
}
.add-fields input[type="text"] { width: 140px; }
.add-fields input[type="datetime-local"] { width: auto; }
.add-fields input[type="number"] { width: 80px; }
.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
}
.pagination button {
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: white;
  padding: 5px 10px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
  color: #475569;
}
.pagination button:disabled { opacity: 0.4; cursor: default; }
.pagination button.active { background: #2563eb; color: white; border-color: #2563eb; }
.pagination span { color: #64748b; font-size: 13px; }
