:root {
  color-scheme: light;
  --bg: #f5f7f6;
  --panel: #ffffff;
  --ink: #17211d;
  --muted: #65736d;
  --line: #d9e0dc;
  --green: #1f7a5a;
  --green-dark: #13543e;
  --amber: #b66b12;
  --blue: #315f9c;
  --accent: #35757a;
  --shadow: 0 18px 45px rgba(26, 40, 34, 0.14);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

button,
input,
select {
  font: inherit;
}

.shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
}

.panel {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 22px;
  background: var(--panel);
  border-right: 1px solid var(--line);
  box-shadow: var(--shadow);
  overflow-y: auto;
}

.title-block {
  display: grid;
  gap: 8px;
}

.eyebrow {
  margin: 0;
  color: var(--green);
  font-size: 13px;
  font-weight: 700;
}

h1 {
  margin: 0;
  font-size: 26px;
  line-height: 1.18;
  letter-spacing: 0;
}

.status-text {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
  font-size: 14px;
}

.mode-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.mode-button {
  min-height: 42px;
  border: 0;
  border-right: 1px solid var(--line);
  background: #f8faf9;
  color: var(--muted);
  cursor: pointer;
}

.mode-button:last-child {
  border-right: 0;
}

.mode-button.active {
  background: var(--green);
  color: #fff;
}

.summary-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.summary-card {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  min-height: 70px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
}

.summary-icon {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: #e3f2ec;
  color: var(--green);
}

.summary-icon svg {
  width: 21px;
  height: 21px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.summary-card p {
  margin: 0 0 3px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.2;
}

.summary-card strong {
  display: block;
  overflow-wrap: anywhere;
  color: var(--ink);
  font-size: 15px;
  line-height: 1.2;
}

.control-group {
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
}

.control-group > label:first-child {
  color: var(--ink);
  font-size: 13px;
  font-weight: 700;
}

.volunteer-card {
  background:
    linear-gradient(135deg, rgba(144, 194, 231, 0.22), rgba(182, 219, 171, 0.2)),
    #fbfcfb;
}

.profile-row {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
}

.avatar-upload {
  display: block;
  width: 48px;
  height: 48px;
  cursor: pointer;
}

.avatar-upload input {
  display: none;
}

.avatar-preview,
.thanks-avatar,
.village-avatar {
  display: grid;
  place-items: center;
  overflow: hidden;
  border-radius: 50%;
  color: #fff;
  font-weight: 850;
  background: linear-gradient(135deg, #0f4460, #35757a);
  box-shadow: 0 12px 26px rgba(15, 68, 96, 0.22);
}

.avatar-preview {
  width: 48px;
  height: 48px;
  border: 3px solid #fff;
  font-size: 19px;
}

.avatar-preview img,
.thanks-avatar img,
.village-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.group-picker {
  display: grid;
  grid-template-columns: 1fr;
  gap: 7px;
}

.group-option {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  align-items: center;
  gap: 9px;
  min-height: 42px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  text-align: left;
}

.group-option.active {
  border-color: var(--group-color);
  box-shadow: inset 0 0 0 1px var(--group-color), 0 10px 22px rgba(23, 33, 29, 0.07);
}

.group-swatch {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255, 255, 255, 0.84);
  border-radius: 50%;
  background: var(--group-color);
  box-shadow: 0 0 0 1px rgba(23, 33, 29, 0.16);
}

.group-copy {
  display: grid;
  min-width: 0;
  gap: 2px;
}

.group-copy strong,
.group-copy span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.group-copy strong {
  font-size: 13px;
}

.group-copy span {
  color: var(--muted);
  font-size: 12px;
}

.search-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 64px;
  gap: 8px;
}

input,
select {
  width: 100%;
  min-height: 40px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
}

button {
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
}

button:hover {
  border-color: var(--green);
}

.result-list {
  display: grid;
  gap: 6px;
  max-height: 180px;
  overflow-y: auto;
}

.result-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 44px;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  text-align: left;
}

.result-main {
  display: grid;
  min-width: 0;
  gap: 2px;
  min-height: 30px;
  padding: 0;
  border: 0;
  background: transparent;
  text-align: left;
}

.result-main span,
.result-main small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.result-item small {
  color: var(--muted);
}

.result-action {
  min-height: 30px;
  padding: 0 10px;
  border-color: transparent;
  color: #fff;
  background: var(--group-color, var(--accent));
  font-size: 12px;
  font-weight: 800;
}

.result-item.lit {
  background: color-mix(in srgb, var(--group-color, #35757a) 12%, #fff);
}

.memorial-control {
  background:
    linear-gradient(135deg, rgba(15, 68, 96, 0.06), rgba(182, 219, 171, 0.14)),
    #fbfcfb;
}

.memorial-button {
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  color: #fff;
  background: linear-gradient(135deg, #0f4460, #35757a);
  font-weight: 850;
  box-shadow: 0 12px 24px rgba(15, 68, 96, 0.18);
}

.compact {
  gap: 8px;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 30px;
  color: var(--ink);
}

.check-row input {
  width: 16px;
  min-height: 16px;
}

.check-row.disabled {
  color: #929d98;
}

.meta-list {
  display: grid;
  gap: 7px;
  margin: 0;
}

.meta-list div {
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr);
  gap: 10px;
}

.meta-list dt {
  color: var(--muted);
}

.meta-list dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.warnings {
  display: grid;
  gap: 8px;
}

.warning-item {
  padding: 10px 12px;
  border-left: 4px solid var(--amber);
  border-radius: 7px;
  background: #fff8ed;
  color: #5d3b0b;
  font-size: 13px;
  line-height: 1.45;
}

.site-footer {
  display: grid;
  gap: 5px;
  margin-top: auto;
  padding: 12px 0 2px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.site-footer span:first-child {
  color: var(--ink);
  font-weight: 700;
}

.workspace {
  min-width: 0;
  position: relative;
}

.view {
  display: none;
  width: 100%;
  height: 100vh;
}

.view.active {
  display: block;
}

#map {
  width: 100%;
  height: 100%;
}

.map-badge {
  position: absolute;
  top: 18px;
  right: 18px;
  z-index: 500;
  padding: 8px 12px;
  border: 1px solid rgba(255, 255, 255, 0.65);
  border-radius: 8px;
  background: rgba(23, 33, 29, 0.78);
  color: #fff;
  font-size: 13px;
  backdrop-filter: blur(10px);
}

.reference-frame {
  display: grid;
  place-items: center;
  gap: 12px;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 24px;
  background: #eef2f0;
}

.reference-frame img {
  max-width: 100%;
  max-height: calc(100vh - 74px);
  object-fit: contain;
  border: 1px solid var(--line);
  background: #fff;
  box-shadow: var(--shadow);
}

.reference-frame figcaption {
  color: var(--muted);
  font-size: 14px;
}

.leaflet-popup-content {
  margin: 12px 14px;
  min-width: 210px;
}

.popup-title {
  margin: 0 0 8px;
  font-weight: 800;
  font-size: 16px;
}

.popup-grid {
  display: grid;
  grid-template-columns: 70px minmax(0, 1fr);
  gap: 5px 8px;
  font-size: 13px;
}

.popup-grid span:nth-child(odd) {
  color: var(--muted);
}

.popup-actions {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.popup-light-button,
.primary-button {
  min-height: 38px;
  border: 0;
  border-radius: 8px;
  color: #fff;
  background: linear-gradient(135deg, var(--group-color, #0f4460), #35757a);
  font-weight: 850;
  box-shadow: 0 10px 24px rgba(15, 68, 96, 0.2);
}

.popup-light-button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.leaflet-div-icon.avatar-marker-icon {
  border: 0;
  background: transparent;
}

.village-avatar {
  position: relative;
  width: 34px;
  height: 34px;
  border: 3px solid #fff;
  font-size: 13px;
}

.village-avatar::after {
  position: absolute;
  inset: -5px;
  z-index: -1;
  border-radius: 50%;
  background: var(--group-color, #35757a);
  opacity: 0.3;
  content: "";
}

.thanks-dialog {
  width: min(430px, calc(100% - 32px));
  border: 0;
  border-radius: 14px;
  padding: 0;
  color: var(--ink);
  background: transparent;
}

.thanks-dialog::backdrop {
  background: rgba(15, 35, 42, 0.42);
  backdrop-filter: blur(5px);
}

.thanks-card {
  position: relative;
  display: grid;
  justify-items: center;
  gap: 12px;
  overflow: hidden;
  padding: 34px 26px 24px;
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 14px;
  background:
    radial-gradient(circle at 22% 16%, rgba(175, 216, 242, 0.8), transparent 34%),
    radial-gradient(circle at 88% 20%, rgba(182, 219, 171, 0.8), transparent 30%),
    #ffffff;
  box-shadow: 0 26px 70px rgba(15, 35, 42, 0.28);
  text-align: center;
}

.thanks-ribbon {
  position: absolute;
  inset: 0 0 auto;
  height: 8px;
  background: linear-gradient(
    90deg,
    #90c2e7,
    #0f4460,
    #3d8792,
    #afd8f2,
    #b6dbab,
    #35757a
  );
}

.thanks-avatar {
  width: 86px;
  height: 86px;
  border: 4px solid #fff;
  font-size: 30px;
}

.thanks-card h2 {
  margin: 0;
  font-size: 24px;
  letter-spacing: 0;
}

.thanks-card p {
  margin: 0;
  color: #26352f;
  font-size: 17px;
  font-weight: 750;
  line-height: 1.55;
}

.primary-button {
  min-width: 120px;
  padding: 0 18px;
}

.memorial-dialog {
  width: min(760px, calc(100% - 28px));
  border: 0;
  border-radius: 14px;
  padding: 0;
  background: transparent;
}

.memorial-dialog::backdrop {
  background: rgba(15, 35, 42, 0.48);
  backdrop-filter: blur(5px);
}

.memorial-dialog-card {
  display: grid;
  gap: 14px;
  max-height: calc(100vh - 36px);
  overflow: auto;
  padding: 18px;
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 26px 70px rgba(15, 35, 42, 0.28);
}

.memorial-dialog-card h2 {
  margin: 0;
  font-size: 20px;
  letter-spacing: 0;
}

#memorialCanvas {
  width: 100%;
  height: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #f8faf9;
}

.memorial-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.memorial-actions button {
  min-height: 38px;
  padding: 0 16px;
}

@media (max-width: 860px) {
  .shell {
    grid-template-columns: 1fr;
  }

  .panel {
    max-height: 48vh;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .view {
    height: 52vh;
  }

  h1 {
    font-size: 22px;
  }

  .map-badge {
    top: auto;
    right: 12px;
    bottom: 12px;
  }

  .group-copy span {
    white-space: normal;
  }
}
