:root {
  color-scheme: light;
  --bg: #f4f6f3;
  --panel: #ffffff;
  --panel-2: #f9faf7;
  --ink: #1f2420;
  --muted: #6d746d;
  --line: #dfe4dc;
  --accent: #0f766e;
  --accent-2: #b45309;
  --danger: #a33a3a;
  --shadow: 0 12px 34px rgba(24, 31, 27, 0.1);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  border-right: 1px solid var(--line);
  background: #fbfcfa;
  padding: 24px 18px;
  overflow-y: auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  font-weight: 800;
}

.brand h1,
.brand p,
.content-header h2,
.content-header p,
.drawer-header h2,
.drawer-header p {
  margin: 0;
}

.brand h1 {
  font-size: 20px;
  line-height: 1.2;
}

.brand p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.search {
  display: grid;
  gap: 8px;
  margin-bottom: 20px;
  color: var(--muted);
  font-size: 13px;
}

.search input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 11px 12px;
  outline: none;
}

.search input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.14);
}

.region-nav {
  display: grid;
  gap: 8px;
}

.region-button,
.district-button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
  padding: 10px 11px;
  text-align: left;
}

.region-button:hover,
.district-button:hover {
  background: #eef3ed;
}

.region-button.active,
.district-button.active {
  border-color: rgba(15, 118, 110, 0.34);
  background: #e7f3f0;
  color: #0b5f59;
  font-weight: 700;
}

.count-pill {
  flex: 0 0 auto;
  min-width: 30px;
  border-radius: 999px;
  background: #e5e8e3;
  color: var(--muted);
  padding: 3px 8px;
  font-size: 12px;
  text-align: center;
}

.active .count-pill {
  background: rgba(15, 118, 110, 0.16);
  color: #0b5f59;
}

.content {
  min-width: 0;
  padding: 28px;
}

.content-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.eyebrow {
  color: var(--accent-2);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
}

.content-header h2 {
  margin-top: 3px;
  font-size: 30px;
  line-height: 1.1;
}

.stats {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.stat {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 8px 10px;
  min-width: 84px;
}

.stat span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.stat strong {
  display: block;
  margin-top: 2px;
  font-size: 18px;
}

.district-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 18px;
}

.district-button {
  width: auto;
  background: var(--panel);
}

.note-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}

.note-card {
  display: grid;
  grid-template-rows: 170px auto;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  overflow: hidden;
  box-shadow: 0 1px 2px rgba(24, 31, 27, 0.04);
  transition:
    transform 150ms ease,
    box-shadow 150ms ease,
    border-color 150ms ease;
}

.note-card:hover {
  border-color: rgba(15, 118, 110, 0.36);
  box-shadow: var(--shadow);
  transform: translateY(-2px);
}

.preview {
  position: relative;
  min-width: 0;
  background:
    linear-gradient(135deg, rgba(15, 118, 110, 0.18), transparent 50%),
    #e9ede7;
  overflow: hidden;
}

.preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.preview-fallback {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  color: var(--muted);
  font-weight: 700;
}

.media-chip {
  position: absolute;
  right: 10px;
  bottom: 10px;
  border-radius: 999px;
  background: rgba(31, 36, 32, 0.82);
  color: #fff;
  padding: 4px 8px;
  font-size: 12px;
}

.card-body {
  min-width: 0;
  padding: 13px;
}

.card-topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 12px;
}

.area-tag {
  color: #0b5f59;
  font-weight: 800;
}

.note-title {
  margin: 0 0 8px;
  min-height: 24px;
  font-size: 17px;
  line-height: 1.35;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.note-text {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  white-space: pre-wrap;
}

.location-line {
  margin-top: 12px;
  color: var(--ink);
  font-size: 13px;
  line-height: 1.45;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.card-media-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  margin-top: 12px;
}

.card-media-item {
  min-width: 0;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #e9ede7;
  overflow: hidden;
}

.card-media-item img,
.card-media-item video {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  background: #e9ede7;
}

.card-media-item audio {
  width: 100%;
  height: 34px;
}

.card-media-item-audio {
  grid-column: span 3;
  padding: 6px;
}

.empty-state {
  grid-column: 1 / -1;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: var(--panel-2);
  padding: 38px 18px;
  color: var(--muted);
  text-align: center;
}

.drawer {
  position: fixed;
  inset: 0;
  display: none;
  z-index: 20;
}

.drawer.open {
  display: block;
}

.drawer-backdrop {
  position: absolute;
  inset: 0;
  border: 0;
  background: rgba(23, 28, 24, 0.52);
}

.drawer-panel {
  position: absolute;
  top: 0;
  right: 0;
  width: min(760px, 100vw);
  height: 100%;
  margin: 0;
  background: var(--panel);
  box-shadow: -18px 0 45px rgba(0, 0, 0, 0.18);
  overflow-y: auto;
}

.drawer-header {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(10px);
  padding: 20px;
}

.drawer-header h2 {
  margin-top: 4px;
  font-size: 24px;
  line-height: 1.24;
}

.icon-button {
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font-size: 24px;
  line-height: 1;
}

.drawer-body {
  padding: 20px;
}

.detail-section {
  border-bottom: 1px solid var(--line);
  padding: 0 0 18px;
  margin-bottom: 18px;
}

.detail-section h3 {
  margin: 0 0 10px;
  font-size: 15px;
}

.detail-text {
  margin: 0;
  color: #2d332e;
  line-height: 1.65;
  white-space: pre-wrap;
}

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

.meta-row {
  display: grid;
  grid-template-columns: 90px minmax(0, 1fr);
  gap: 10px;
  color: var(--muted);
  font-size: 14px;
}

.meta-row strong {
  color: var(--ink);
  font-weight: 700;
}

.media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 10px;
}

.media-item {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
  overflow: hidden;
}

.media-item img,
.media-item video {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  background: #e9ede7;
}

.media-caption {
  padding: 8px;
  color: var(--muted);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.danger {
  color: var(--danger);
}

@media (max-width: 820px) {
  .app-shell {
    display: block;
  }

  .sidebar {
    position: relative;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .region-nav {
    grid-template-columns: repeat(auto-fit, minmax(132px, 1fr));
  }

  .content {
    padding: 18px;
  }

  .content-header {
    display: grid;
  }

  .stats {
    justify-content: flex-start;
  }
}

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

  .note-card {
    grid-template-rows: 150px auto;
  }

  .drawer-header,
  .drawer-body {
    padding: 16px;
  }

  .meta-row {
    grid-template-columns: 1fr;
    gap: 2px;
  }
}
