@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+SC:wght@400;500;600;700;800&display=swap');

:root {
  color-scheme: light;
  --ink: #152238;
  --ink-soft: #5f6b80;
  --ink-faint: #8d98aa;
  --line: #e6eaf1;
  --line-strong: #d6dce7;
  --paper: #ffffff;
  --canvas: #f6f8fc;
  --blue: #3767e8;
  --blue-deep: #234bbb;
  --blue-pale: #edf2ff;
  --mint: #31a889;
  --mint-pale: #e9f8f3;
  --orange: #dd8244;
  --shadow: 0 12px 34px rgba(28, 49, 91, 0.08);
  font-family: 'Noto Sans SC', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--canvas);
  -webkit-text-size-adjust: 100%;
  overscroll-behavior-x: none;
}

body.is-swiping {
  overscroll-behavior-x: none;
}

body.is-swiping * {
  touch-action: pan-y;
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  overscroll-behavior-x: none;
  color: var(--ink);
  background:
    radial-gradient(circle at 90% -10%, rgba(116, 154, 255, 0.14), transparent 32rem),
    var(--canvas);
}

button,
input,
select {
  font: inherit;
}

button {
  border: 0;
}

button,
select {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 3px solid rgba(55, 103, 232, 0.25);
  outline-offset: 2px;
}

.is-hidden {
  display: none !important;
}

.loading-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 32px;
  text-align: center;
  background: var(--canvas);
}

.loading-mark {
  display: grid;
  width: 68px;
  height: 68px;
  place-items: center;
  margin-bottom: 20px;
  color: #fff;
  font-size: 27px;
  font-weight: 800;
  letter-spacing: -0.08em;
  background: linear-gradient(145deg, #4d79ed, #274dbb);
  border-radius: 22px;
  box-shadow: 0 15px 30px rgba(55, 103, 232, 0.25);
}

.loading-copy {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.loading-copy strong {
  font-size: 17px;
  font-weight: 700;
}

.loading-copy span {
  color: var(--ink-soft);
  font-size: 13px;
}

.loading-bar {
  width: 160px;
  height: 4px;
  margin-top: 25px;
  overflow: hidden;
  background: #e4e9f4;
  border-radius: 99px;
}

.loading-bar span {
  display: block;
  width: 46%;
  height: 100%;
  background: var(--blue);
  border-radius: inherit;
  animation: loading 1.1s ease-in-out infinite;
}

@keyframes loading {
  from { transform: translateX(-120%); }
  to { transform: translateX(340%); }
}

.app-shell,
.detail-view {
  width: min(100%, 720px);
  min-height: 100vh;
  margin: 0 auto;
}

.page-header {
  padding: calc(20px + env(safe-area-inset-top)) 20px 26px;
  background: linear-gradient(180deg, #f9fbff 0%, var(--canvas) 100%);
}

.brand-row {
  display: flex;
  align-items: center;
  gap: 11px;
}

.brand-mark {
  display: grid;
  width: 40px;
  height: 40px;
  flex: 0 0 auto;
  place-items: center;
  color: var(--blue);
  background: var(--blue-pale);
  border: 1px solid #dfe7ff;
  border-radius: 13px;
}

.brand-mark svg {
  width: 23px;
  height: 23px;
}

.icon-button {
  display: grid;
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  margin-left: auto;
  place-items: center;
  color: var(--ink-soft);
  background: rgba(255, 255, 255, 0.8);
  border: 1px solid var(--line);
  border-radius: 12px;
  transition: color 160ms ease, background 160ms ease, transform 160ms ease;
}

.icon-button:hover {
  color: var(--blue);
  background: #fff;
}

.icon-button:active {
  transform: scale(0.94);
}

.icon-button.is-loading svg {
  animation: spin 900ms linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.icon-button svg {
  width: 18px;
  height: 18px;
}

.section-kicker,
.detail-eyebrow {
  margin: 0;
  color: var(--blue);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.summary-grid {
  margin-top: 22px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.summary-card {
  display: flex;
  min-height: 95px;
  flex-direction: column;
  justify-content: center;
  padding: 14px 15px;
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid rgba(222, 228, 239, 0.95);
  border-radius: 16px;
  box-shadow: 0 7px 22px rgba(37, 57, 96, 0.04);
}

.summary-card-primary {
  background: linear-gradient(145deg, #eef3ff, #f9fbff);
  border-color: #dbe5ff;
}

.summary-card span {
  color: var(--ink-soft);
  font-size: 11px;
  font-weight: 600;
}

.summary-card strong {
  margin: 3px 0 1px;
  color: var(--ink);
  font-size: 25px;
  font-weight: 800;
  letter-spacing: -0.05em;
  line-height: 1.15;
}

.summary-card-primary strong {
  color: var(--blue);
}

.summary-card small {
  overflow: hidden;
  color: var(--ink-faint);
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.search-section {
  position: relative;
  z-index: 3;
  padding: 0 20px 20px;
}

.search-box {
  display: flex;
  height: 48px;
  align-items: center;
  gap: 9px;
  padding: 0 13px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 15px;
  box-shadow: 0 8px 22px rgba(29, 51, 90, 0.06);
}

.search-box > svg {
  width: 19px;
  height: 19px;
  flex: 0 0 auto;
  color: var(--blue);
}

.search-box input {
  min-width: 0;
  flex: 1;
  padding: 0;
  color: var(--ink);
  font-size: 13px;
  background: transparent;
  border: 0;
  outline: 0;
}

.search-box input::placeholder {
  color: #a4adbc;
}

.search-box input::-webkit-search-cancel-button {
  display: none;
}

.clear-button {
  display: grid;
  width: 25px;
  height: 25px;
  flex: 0 0 auto;
  place-items: center;
  color: #7f8ba0;
  font-size: 20px;
  line-height: 1;
  background: #eef1f6;
  border-radius: 50%;
}

.filter-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
  margin-top: 10px;
}

.filter-field {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 5px;
}

.filter-field > span {
  padding-left: 2px;
  color: var(--ink-faint);
  font-size: 10px;
  font-weight: 700;
}

.filter-field select {
  width: 100%;
  height: 40px;
  padding: 0 30px 0 11px;
  overflow: hidden;
  color: var(--ink);
  font-size: 12px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
  background-color: var(--paper);
  background-image: linear-gradient(45deg, transparent 50%, #8d98aa 50%), linear-gradient(135deg, #8d98aa 50%, transparent 50%);
  background-position: calc(100% - 14px) 17px, calc(100% - 10px) 17px;
  background-repeat: no-repeat;
  background-size: 4px 4px, 4px 4px;
  border: 1px solid var(--line);
  border-radius: 11px;
  outline: 0;
  appearance: none;
}

.filter-field select:focus {
  border-color: #9cb4fa;
  box-shadow: 0 0 0 3px rgba(55, 103, 232, 0.1);
}

.active-filters {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-top: 10px;
}

.active-filter-list {
  display: flex;
  min-width: 0;
  flex: 1;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
}

.active-filter-list::-webkit-scrollbar {
  display: none;
}

.filter-chip {
  display: inline-flex;
  max-width: 190px;
  flex: 0 0 auto;
  align-items: center;
  padding: 5px 9px;
  overflow: hidden;
  color: var(--blue-deep);
  font-size: 10px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
  background: var(--blue-pale);
  border-radius: 99px;
}

.filter-chip::after {
  margin-left: 5px;
  color: #7692dd;
  content: '×';
  font-size: 14px;
  font-weight: 500;
  line-height: 10px;
}

.reset-button {
  flex: 0 0 auto;
  padding: 5px 2px;
  color: var(--ink-faint);
  font-size: 10px;
  font-weight: 700;
  background: transparent;
}

.records-section {
  padding: 4px 20px calc(32px + env(safe-area-inset-bottom));
}

.section-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin: 0 2px 13px;
}

.section-heading h2 {
  margin: 4px 0 0;
  color: var(--ink);
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.035em;
}

.section-count {
  margin-bottom: 2px;
  color: var(--ink-faint);
  font-size: 11px;
  font-weight: 700;
}

.record-list {
  display: grid;
  gap: 9px;
}

.record-card {
  display: block;
  width: 100%;
  padding: 15px 15px 13px;
  color: inherit;
  text-align: left;
  background: var(--paper);
  border: 1px solid rgba(226, 231, 240, 0.95);
  border-radius: 17px;
  box-shadow: 0 6px 20px rgba(31, 51, 87, 0.045);
  transition: border-color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.record-card:hover {
  border-color: #cdd9f7;
  box-shadow: 0 10px 25px rgba(41, 72, 137, 0.1);
}

.record-card:active {
  transform: scale(0.985);
}

.record-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.person-summary {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 10px;
}

.person-avatar,
.detail-avatar {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  color: #4566bc;
  font-weight: 800;
  background: linear-gradient(145deg, #eaf0ff, #f4f7ff);
  border: 1px solid #dbe5ff;
}

.person-avatar {
  width: 37px;
  height: 37px;
  font-size: 15px;
  border-radius: 12px;
}

.person-copy {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 2px;
}

.person-name-row {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.person-name {
  overflow: hidden;
  min-width: 0;
  color: var(--ink);
  font-size: 15px;
  font-weight: 800;
  letter-spacing: -0.025em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.photo-badge {
  flex: 0 0 auto;
  padding: 2px 6px;
  color: #0f7a4d;
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.02em;
  white-space: nowrap;
  background: #e2f6ec;
  border: 1px solid #b9e6d0;
  border-radius: 999px;
}

.person-context {
  overflow: hidden;
  color: var(--ink-faint);
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.age-badge {
  flex: 0 0 auto;
  padding: 5px 8px;
  color: #b76632;
  font-size: 10px;
  font-weight: 800;
  background: #fff3e9;
  border-radius: 8px;
}

.record-location {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 5px;
  margin: 13px 0 12px;
  color: var(--ink-soft);
  font-size: 11px;
}

.record-location svg {
  width: 15px;
  height: 15px;
  flex: 0 0 auto;
  color: #7890d8;
}

.location-town {
  overflow: hidden;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.location-separator {
  color: #bbc2ce;
}

.location-community {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.record-card-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 10px;
  border-top: 1px solid #f0f2f6;
}

.source-badge {
  max-width: 58%;
  overflow: hidden;
  padding: 4px 7px;
  color: #63728a;
  font-size: 9px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
  background: #f4f6f9;
  border-radius: 6px;
}

.card-action {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  color: var(--blue);
  font-size: 10px;
  font-weight: 800;
}

.card-action svg {
  width: 14px;
  height: 14px;
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 250px;
  padding: 25px;
  text-align: center;
  background: rgba(255, 255, 255, 0.65);
  border: 1px dashed var(--line-strong);
  border-radius: 18px;
}

.empty-icon {
  display: grid;
  width: 54px;
  height: 54px;
  place-items: center;
  margin-bottom: 13px;
  color: #8b9bc0;
  background: #edf2fc;
  border-radius: 17px;
}

.empty-icon svg {
  width: 27px;
  height: 27px;
}

.empty-state strong {
  font-size: 14px;
}

.empty-state > span {
  margin-top: 6px;
  color: var(--ink-faint);
  font-size: 11px;
}

.text-button {
  margin-top: 15px;
  padding: 8px 13px;
  color: var(--blue);
  font-size: 11px;
  font-weight: 800;
  background: var(--blue-pale);
  border-radius: 9px;
}

.list-sentinel {
  height: 1px;
}

.load-more {
  display: block;
  width: 100%;
  margin-top: 15px;
  padding: 12px;
  color: var(--blue);
  font-size: 11px;
  font-weight: 800;
  background: #edf2ff;
  border-radius: 12px;
}

.load-more:hover {
  background: #e4ecff;
}

.list-footnote {
  margin: 14px 0 0;
  color: var(--ink-faint);
  font-size: 10px;
  text-align: center;
}

.detail-view {
  background: var(--canvas);
  overscroll-behavior-x: none;
}

.lightbox {
  overscroll-behavior: none;
}

.detail-topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  height: calc(61px + env(safe-area-inset-top));
  align-items: flex-end;
  justify-content: space-between;
  padding: 0 18px 12px;
  background: rgba(246, 248, 252, 0.9);
  border-bottom: 1px solid rgba(225, 230, 239, 0.78);
  backdrop-filter: blur(18px);
}

.back-button {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 4px 0;
  color: var(--blue);
  font-size: 12px;
  font-weight: 800;
  background: transparent;
}

.back-button svg {
  width: 19px;
  height: 19px;
}

.detail-topbar-label {
  color: var(--ink-soft);
  font-size: 12px;
  font-weight: 700;
}

.detail-topbar-spacer {
  width: 62px;
}

.detail-content {
  padding: 20px 20px calc(38px + env(safe-area-inset-bottom));
}

.detail-hero {
  padding: 20px;
  background: linear-gradient(145deg, #eaf0ff 0%, #f9fbff 100%);
  border: 1px solid #dce6ff;
  border-radius: 21px;
  box-shadow: var(--shadow);
}

.detail-hero-top {
  display: flex;
  align-items: center;
  gap: 13px;
}

.detail-avatar {
  width: 57px;
  height: 57px;
  font-size: 22px;
  border-radius: 18px;
}

.detail-identity {
  min-width: 0;
}

.detail-eyebrow {
  font-size: 9px;
}

.detail-identity h1 {
  overflow: hidden;
  margin: 4px 0 3px;
  color: var(--ink);
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.05em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.detail-subtitle {
  margin: 0;
  color: var(--ink-soft);
  font-size: 11px;
}

.detail-category {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 19px;
  padding-top: 14px;
  border-top: 1px solid #dce6f9;
}

.detail-category-label {
  color: var(--ink-soft);
  font-size: 10px;
  font-weight: 700;
}

.detail-category strong {
  overflow: hidden;
  color: var(--blue-deep);
  font-size: 11px;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.detail-source {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 13px 3px 24px;
  color: var(--ink-faint);
  font-size: 10px;
}

.source-dot {
  color: #bbc3d0;
}

.detail-section-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin: 0 2px 11px;
}

.detail-section-heading h2 {
  margin: 0;
  font-size: 17px;
  font-weight: 800;
  letter-spacing: -0.035em;
}

.detail-section-heading span {
  color: var(--ink-faint);
  font-size: 10px;
}

.detail-fields {
  overflow: hidden;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 17px;
  box-shadow: 0 7px 22px rgba(31, 51, 87, 0.04);
}

.detail-field {
  display: grid;
  grid-template-columns: 91px minmax(0, 1fr);
  gap: 13px;
  padding: 13px 15px;
  border-bottom: 1px solid #edf0f4;
  animation: field-in 260ms ease both;
  animation-delay: calc(var(--field-index) * 24ms);
}

.detail-field:last-child {
  border-bottom: 0;
}

@keyframes field-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.detail-label {
  color: var(--ink-soft);
  font-size: 11px;
  font-weight: 600;
  line-height: 1.6;
}

.detail-value {
  min-width: 0;
  color: var(--ink);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.75;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.detail-value.is-empty {
  color: #b1b9c6;
  font-weight: 400;
}

.detail-end-note {
  margin: 19px 3px 0;
  color: var(--ink-faint);
  font-size: 10px;
  line-height: 1.7;
  text-align: center;
}

.map-section {
  margin-top: 30px;
}

.detail-section-heading span[data-state='saved'] {
  color: var(--mint);
}

.detail-section-heading span[data-state='pending'] {
  color: var(--orange);
}

.map-search {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.map-search input {
  flex: 1 1 150px;
  min-width: 0;
  padding: 11px 13px;
  color: var(--ink);
  font-size: 12px;
  font-weight: 600;
  background: var(--paper);
  border: 1px solid var(--line-strong);
  border-radius: 13px;
}

.map-search input::placeholder {
  color: var(--ink-faint);
  font-weight: 500;
}

.map-search-button,
.map-locate-button {
  flex: none;
  padding: 0 16px;
  font-size: 12px;
  font-weight: 800;
  border-radius: 13px;
}

.map-search-button {
  color: #fff;
  background: linear-gradient(145deg, #4d79ed, #274dbb);
}

.map-search-button:disabled {
  opacity: 0.6;
  cursor: default;
}

.map-locate-button {
  color: var(--blue);
  background: var(--blue-pale);
  border: 1px solid rgba(55, 103, 232, 0.3);
}

.map-locate-button:disabled {
  opacity: 0.55;
  cursor: default;
}

.map-results {
  margin: 9px 0 0;
  padding: 0;
  overflow: hidden;
  list-style: none;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 13px;
  box-shadow: 0 7px 22px rgba(31, 51, 87, 0.04);
}

.map-result {
  display: block;
  width: 100%;
  padding: 12px 14px;
  text-align: left;
  background: transparent;
  border-bottom: 1px solid #edf0f4;
}

.map-result:last-child {
  border-bottom: 0;
}

.map-result strong {
  display: block;
  overflow: hidden;
  color: var(--ink);
  font-size: 12px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.map-result span {
  display: block;
  margin-top: 3px;
  color: var(--ink-faint);
  font-size: 10px;
  line-height: 1.6;
}

.map-result.is-empty {
  color: var(--ink-faint);
  font-size: 11px;
  line-height: 1.6;
  cursor: default;
}

.map-canvas {
  height: clamp(230px, 52vw, 340px);
  margin-top: 11px;
  overflow: hidden;
  background: var(--blue-pale);
  border: 1px solid var(--line-strong);
  border-radius: 17px;
}

.map-coords {
  margin: 11px 2px 0;
  color: var(--ink-soft);
  font-size: 11px;
  font-weight: 600;
  line-height: 1.6;
  font-variant-numeric: tabular-nums;
}

.map-convert-toggle {
  display: flex;
  gap: 6px;
  align-items: flex-start;
  margin: 7px 2px 0;
  color: var(--ink-faint);
  font-size: 11px;
  line-height: 1.6;
  cursor: pointer;
  user-select: none;
}

.map-convert-toggle input {
  flex: none;
  margin: 2px 0 0;
}

.map-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  margin-top: 12px;
}

.map-primary-button {
  flex: 1;
  min-width: 130px;
  padding: 13px;
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  background: linear-gradient(145deg, #4d79ed, #274dbb);
  border-radius: 13px;
  box-shadow: 0 8px 18px rgba(55, 103, 232, 0.2);
}

.map-primary-button:disabled {
  opacity: 0.42;
  box-shadow: none;
  cursor: default;
}

.map-ghost-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 13px 18px;
  color: var(--ink-soft);
  font-size: 12px;
  font-weight: 700;
  text-decoration: none;
  background: var(--paper);
  border: 1px solid var(--line-strong);
  border-radius: 13px;
}

.map-ghost-button:disabled {
  opacity: 0.42;
  cursor: default;
}

.map-ghost-button.is-disabled {
  opacity: 0.4;
  pointer-events: none;
}

.map-error {
  margin: 11px 2px 0;
  padding: 10px 13px;
  color: #b4433a;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.6;
  background: #fdefee;
  border: 1px solid #f6d5d1;
  border-radius: 11px;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: calc(22px + env(safe-area-inset-bottom));
  z-index: 20;
  max-width: min(340px, calc(100% - 40px));
  padding: 11px 14px;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  line-height: 1.5;
  background: rgba(24, 37, 63, 0.92);
  border-radius: 11px;
  box-shadow: 0 12px 30px rgba(17, 29, 55, 0.2);
  animation: toast-in 180ms ease both;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(7px); }
  to { opacity: 1; transform: translateY(0); }
}

.detail-hero .photo-section {
  margin: 16px 0 0;
  padding: 14px;
  background: var(--blue-pale);
  border: 1px dashed rgba(55, 103, 232, 0.28);
  border-radius: 14px;
  box-shadow: none;
}

.photo-actions {
  display: flex;
  gap: 9px;
}

.photo-button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 46px;
  height: 46px;
  padding: 0;
  color: #fff;
  background: linear-gradient(145deg, #4d79ed, #274dbb);
  border-radius: 13px;
  box-shadow: 0 8px 18px rgba(55, 103, 232, 0.2);
  cursor: pointer;
}

.photo-button svg {
  width: 21px;
  height: 21px;
  flex-shrink: 0;
}

.photo-button.is-busy {
  opacity: 0.55;
  pointer-events: none;
}

.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 9px;
  margin-top: 12px;
}

.photo-tile {
  position: relative;
  aspect-ratio: 3 / 2;
  overflow: hidden;
  background: var(--canvas);
  border: 1px solid var(--line);
  border-radius: 12px;
}

.photo-tile img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.photo-tile-open {
  position: absolute;
  inset: 0;
  z-index: 1;
  padding: 0;
  background: none;
  border: 0;
  cursor: pointer;
}

.photo-remove {
  position: absolute;
  top: 5px;
  right: 5px;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 23px;
  height: 23px;
  padding: 0 0 2px;
  color: #fff;
  font-size: 16px;
  font-weight: 400;
  line-height: 1;
  background: rgba(21, 34, 56, 0.66);
  border: 0;
  border-radius: 50%;
  cursor: pointer;
}

.photo-remove:hover,
.photo-remove:focus-visible {
  background: #d93a30;
}

.photo-tile-tag {
  position: absolute;
  right: 5px;
  bottom: 5px;
  left: 5px;
  padding: 3px 6px;
  overflow: hidden;
  color: #fff;
  font-size: 9.5px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
  pointer-events: none;
  background: rgba(21, 34, 56, 0.7);
  border-radius: 6px;
}

.stats-body {
  background: var(--canvas);
}

.stats-shell {
  display: flex;
  min-height: 100vh;
  flex-direction: column;
}

.stats-header {
  padding: calc(20px + env(safe-area-inset-top)) 20px 18px;
  background: linear-gradient(180deg, #f9fbff 0%, var(--canvas) 100%);
  border-bottom: 1px solid var(--line);
}

.stats-title {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.stats-title strong {
  font-size: 15px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.stats-title span {
  overflow: hidden;
  color: var(--ink-faint);
  font-size: 10.5px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stats-back {
  text-decoration: none;
}

.stats-main {
  flex: 1;
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  padding: 18px 20px 26px;
}

.stats-summary {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 18px;
}

.stats-summary .summary-card {
  margin: 0;
  text-align: center;
}

.stats-summary .summary-card strong {
  font-size: 40px;
}

.stats-summary-note {
  margin: 0;
  color: var(--ink-soft);
  font-size: 11.5px;
  text-align: center;
}

.stat-total-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-top: 13px;
  padding-top: 11px;
  color: var(--ink-soft);
  font-size: 12px;
  border-top: 1px dashed var(--line);
}

.stat-total-row strong {
  color: var(--blue);
  font-size: 13.5px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.stats-section {
  margin: 0 0 14px;
}

.stat-list {
  display: flex;
  flex-direction: column;
  gap: 11px;
}

.stat-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: baseline;
  gap: 4px 10px;
}

.stat-row-main {
  display: flex;
  align-items: baseline;
  gap: 7px;
  min-width: 0;
}

.stat-row-label {
  overflow: hidden;
  color: var(--ink);
  font-size: 13px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stat-row-sub {
  flex: 0 0 auto;
  color: var(--ink-faint);
  font-size: 10.5px;
}

.stat-row-count {
  color: var(--blue);
  font-size: 13px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.stat-bar {
  grid-column: 1 / -1;
  height: 5px;
  overflow: hidden;
  background: var(--blue-pale);
  border-radius: 999px;
}

.stat-bar-fill {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, #6f95f2, #2f57c4);
  border-radius: 999px;
}

.stat-empty {
  margin: 4px 0 0;
  color: var(--ink-faint);
  font-size: 11.5px;
  text-align: center;
}

.stats-error {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 44px 20px;
  color: var(--ink-soft);
  text-align: center;
}

.stats-error strong {
  color: var(--ink);
  font-size: 14px;
}

.stats-error span {
  font-size: 11.5px;
}

.stats-error .text-button {
  margin-top: 8px;
}

@media (min-width: 700px) {
  .stats-summary {
    flex-direction: row;
    align-items: stretch;
    gap: 12px;
  }

  .stats-summary .summary-card {
    flex: 0 0 220px;
    display: flex;
    flex-direction: column;
    justify-content: center;
  }

  .stats-summary-note {
    display: flex;
    align-items: center;
    text-align: left;
  }
}

.site-footer {
  padding: 22px 20px calc(26px + env(safe-area-inset-bottom));
  text-align: center;
  border-top: 1px solid var(--line);
}

.site-footer p {
  margin: 0;
}

.site-footer-name {
  color: var(--ink-soft);
  font-size: 12px;
  font-weight: 600;
}

.site-footer-record {
  margin-top: 7px !important;
  color: var(--ink-faint);
  font-size: 11px;
  line-height: 1.9;
}

.site-footer-record a {
  color: var(--ink-faint);
  text-decoration: none;
}

.site-footer-record a:hover {
  color: var(--blue);
  text-decoration: underline;
}

.site-footer-dot {
  margin: 0 7px;
}

.site-footer-note {
  margin-top: 7px !important;
  color: var(--ink-faint);
  font-size: 10.5px;
}

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 50;
  overscroll-behavior: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 56px 18px calc(28px + env(safe-area-inset-bottom));
  background: rgba(12, 20, 35, 0.92);
}

.lightbox-image {
  max-width: 100%;
  max-height: 78vh;
  object-fit: contain;
  border-radius: 12px;
}

.lightbox-caption {
  margin: 0;
  color: rgba(255, 255, 255, 0.72);
  font-size: 11px;
  word-break: break-all;
}

.lightbox-close {
  position: absolute;
  top: calc(14px + env(safe-area-inset-top));
  right: 16px;
  width: 38px;
  height: 38px;
  color: #fff;
  font-size: 26px;
  line-height: 1;
  background: rgba(255, 255, 255, 0.14);
  border-radius: 50%;
}

@media (min-width: 600px) {
  .photo-section {
    margin: 0 28px 32px;
  }
}

@media (min-width: 600px) {
  .page-header,
  .search-section,
  .records-section,
  .detail-content {
    padding-right: 28px;
    padding-left: 28px;
  }

  .record-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 370px) {
  .page-header,
  .search-section,
  .records-section,
  .detail-content {
    padding-right: 14px;
    padding-left: 14px;
  }

  .detail-field {
    grid-template-columns: 80px minmax(0, 1fr);
    gap: 9px;
    padding-right: 12px;
    padding-left: 12px;
  }
}

.lstats-filter {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 14px;
  padding: 14px 2px 4px;
}

.lstats-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 140px;
  flex: 1 1 140px;
}

.lstats-field > span {
  color: var(--ink-faint);
  font-size: 11px;
}

.lstats-field input,
.lstats-field select {
  width: 100%;
  padding: 10px 12px;
  font-size: 13px;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--line-strong);
  border-radius: 11px;
}

.loc-date {
  margin: 16px 2px 6px;
  color: var(--ink-faint);
  font-size: 11px;
  font-weight: 700;
}

.loc-row {
  display: grid;
  grid-template-columns: 52px 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 11px 2px;
  border-bottom: 1px solid var(--line);
}

.loc-row-time {
  color: var(--ink-soft);
  font-size: 12px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.loc-row-main {
  min-width: 0;
}

.loc-row-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.loc-row-meta {
  margin-top: 3px;
  color: var(--ink-faint);
  font-size: 11px;
  line-height: 1.5;
  font-variant-numeric: tabular-nums;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.loc-row-device {
  margin-top: 3px;
  color: var(--ink-faint);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.loc-badge {
  padding: 3px 8px;
  font-size: 10px;
  font-weight: 800;
  border-radius: 999px;
}

.loc-badge-save {
  color: #fff;
  background: #2f6df6;
}

.loc-badge-update {
  color: #7a4d00;
  background: #ffd97a;
}

.loc-badge-clear {
  color: #a33a36;
  background: #ffd0cd;
}
