:root {
  --bg: #f5f6f4;
  --surface: #ffffff;
  --ink: #17191c;
  --muted: #6b7280;
  --line: #e7e9e6;
  --wa: #25d366;
  --wa-dark: #128c7e;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 4px 14px rgba(16, 24, 40, .04);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  padding-top: calc(64px + 52px + env(safe-area-inset-top));
  padding-bottom: env(safe-area-inset-bottom);
}

svg { width: 22px; height: 22px; fill: currentColor; display: block; }

button, input { font: inherit; }
button { cursor: pointer; }

.topbar {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 20;
  height: calc(64px + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) 14px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: rgba(255, 255, 255, .94);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}

.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.avatar {
  width: 38px; height: 38px; flex: none;
  border-radius: 50%;
  display: grid; place-items: center;
  background: linear-gradient(135deg, #25d366, #0f9d8f);
  color: #fff; font-weight: 700; font-size: 17px;
}
.brand-text { min-width: 0; }
.brand-text h1 {
  margin: 0; font-size: 16px; line-height: 1.2; font-weight: 700;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.brand-text p { margin: 2px 0 0; font-size: 11px; color: var(--muted); white-space: nowrap; }

.lang {
  flex: none; max-width: 92px; height: 34px;
  border: 1px solid var(--line); border-radius: 999px;
  background: #fff; color: var(--ink);
  padding: 0 10px; font-size: 12px; font-weight: 600;
  outline: none;
}
.lang:focus { border-color: var(--wa); }

.icon-btn {
  width: 40px; height: 40px; flex: none;
  border: 0; border-radius: 50%;
  background: #e8f8ee; color: var(--wa-dark);
  display: grid; place-items: center;
}
.icon-btn:active { transform: scale(.94); }

.searchbar {
  position: fixed;
  top: calc(64px + env(safe-area-inset-top));
  inset-inline: 0;
  z-index: 19;
  height: 52px;
  padding: 7px 14px;
  background: rgba(255, 255, 255, .94);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 8px;
}
.search-icon { width: 18px; height: 18px; flex: none; color: var(--muted); }
.searchbar input {
  flex: 1; min-width: 0; height: 36px;
  border: 1px solid var(--line); border-radius: 999px;
  background: var(--bg); padding: 0 14px;
  outline: none; color: var(--ink);
}
.searchbar input:focus { border-color: var(--wa); background: #fff; box-shadow: 0 0 0 3px rgba(37, 211, 102, .12); }
.clear-btn {
  border: 0; background: transparent; color: var(--muted);
  font-size: 24px; line-height: 1; width: 28px; padding: 0;
}

main { padding: 12px 10px 28px; max-width: 1400px; margin: 0 auto; }
.status { margin: 2px 4px 12px; color: var(--muted); font-size: 12px; }

.grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  content-visibility: auto;
  contain-intrinsic-size: 340px;
  display: flex; flex-direction: column;
}
.card-media {
  position: relative; aspect-ratio: 1 / 1; overflow: hidden;
  background: linear-gradient(100deg, #eee 30%, #f7f7f7 50%, #eee 70%);
  background-size: 200% 100%;
  animation: shimmer 1.4s linear infinite;
}
.card-media.loaded { animation: none; background: #eee; }
@keyframes shimmer { to { background-position: -200% 0; } }
.card-media img { width: 100%; height: 100%; object-fit: cover; display: block; opacity: 0; transition: opacity .25s; }
.card-media img.ok { opacity: 1; }
.card-media .count {
  position: absolute; right: 6px; top: 6px;
  background: rgba(0, 0, 0, .55); color: #fff;
  font-size: 10px; padding: 2px 6px; border-radius: 999px;
}
.card-body { padding: 9px 10px 10px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.card-title {
  margin: 0; font-size: 12.5px; line-height: 1.4;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical;
  overflow: hidden; word-break: break-word;
}
.card-date { margin: -4px 0 0; font-size: 10px; color: var(--muted); }
.card-share {
  margin-top: auto;
  width: 100%; min-height: 34px;
  border: 0; border-radius: 9px;
  background: var(--wa); color: #fff;
  font-size: 12px; font-weight: 700;
  display: flex; align-items: center; justify-content: center; gap: 6px;
}
.card-share svg { width: 15px; height: 15px; }
.card-share:active { background: var(--wa-dark); }

.sentinel { min-height: 80px; display: grid; place-items: center; padding: 18px 0 8px; }
.spinner {
  width: 24px; height: 24px; border-radius: 50%;
  border: 3px solid #dfe3e0; border-top-color: var(--wa);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.load-more {
  border: 1px solid var(--line); background: #fff; color: var(--ink);
  padding: 10px 18px; border-radius: 999px; font-weight: 600;
}
.empty, .error { text-align: center; color: var(--muted); padding: 40px 16px; }
.empty strong, .error p { display: block; color: var(--ink); margin: 0 0 4px; }
.error button {
  border: 0; background: var(--ink); color: #fff;
  padding: 10px 18px; border-radius: 999px; margin-top: 10px;
}

.modal { position: fixed; inset: 0; z-index: 50; background: rgba(10, 12, 14, .55); display: flex; align-items: flex-end; }
.sheet {
  position: relative; width: 100%; max-height: 92dvh;
  background: var(--surface); border-radius: 18px 18px 0 0;
  overflow-y: auto; overscroll-behavior: contain;
  animation: slide .22s ease-out;
}
@keyframes slide { from { transform: translateY(18px); opacity: .6; } }
.sheet-close {
  position: absolute; z-index: 2; top: 10px; right: 10px;
  width: 34px; height: 34px; border: 0; border-radius: 50%;
  background: rgba(255, 255, 255, .92); color: #111;
  font-size: 24px; line-height: 1; display: grid; place-items: center;
  box-shadow: var(--shadow);
}
.gallery { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; background: #eee; }
.gallery img { width: 100%; flex: none; scroll-snap-align: start; aspect-ratio: 1 / 1; object-fit: cover; }
.dots { display: flex; justify-content: center; gap: 5px; padding: 9px 0 0; }
.dots i { width: 6px; height: 6px; border-radius: 50%; background: #d1d5db; }
.dots i.on { background: var(--wa-dark); width: 16px; border-radius: 999px; }
.sheet-body { padding: 10px 16px calc(24px + env(safe-area-inset-bottom)); }
.detail-date { margin: 0 0 8px; font-size: 11px; color: var(--muted); }
.detail-desc {
  margin: 0 0 18px;
  font-size: 14px; line-height: 1.6;
  text-align: justify; hyphens: auto;
  word-break: break-word; white-space: pre-wrap;
}
.detail-actions { display: grid; gap: 9px; }
.btn-wa, .btn-outline, .btn-link {
  min-height: 44px; border-radius: 11px; font-weight: 700; font-size: 14px;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  text-decoration: none; text-align: center; padding: 10px 14px;
}
.btn-wa { border: 0; background: var(--wa); color: #fff; }
.btn-wa svg { width: 18px; height: 18px; }
.btn-outline { border: 1px solid var(--line); background: #fff; color: var(--ink); }
.btn-link { color: var(--wa-dark); font-weight: 600; min-height: 32px; font-size: 13px; }

.toast {
  position: fixed; z-index: 60; left: 50%; bottom: 26px; transform: translate(-50%, 20px);
  background: #17191c; color: #fff; padding: 10px 16px; border-radius: 999px;
  font-size: 13px; opacity: 0; pointer-events: none; transition: .2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (min-width: 600px) {
  .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
  .card-title { font-size: 13.5px; }
  .modal { align-items: center; justify-content: center; padding: 20px; }
  .sheet { max-width: 520px; max-height: 88dvh; border-radius: 18px; }
}
@media (min-width: 950px) { .grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
@media (min-width: 1250px) { .grid { grid-template-columns: repeat(5, minmax(0, 1fr)); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition: none !important; }
}
