* { box-sizing: border-box; }

:root {
  --accent: #2F5D50;
  --bg: #FAF7F1;
  --card-bg: #FFFFFF;
  --border: #E3DCCC;
  --border-light: #EEE7D9;
  --text: #1F241E;
  --muted: #7A7568;
  --muted-light: #9A9385;
  --live: #B0362F;

  --cat-all: #44403A;
  --cat-kebaktian: #C9702E;
  --cat-doapagi: #1F7A72;
  --cat-sms: #6B4FA0;
  --cat-lagupujian: #3F7D4D;
}

body {
  margin: 0;
  background: var(--bg);
  font-family: 'Work Sans', system-ui, sans-serif;
  color: var(--text);
}

.app {
  max-width: 640px;
  margin: 0 auto;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.header {
  position: sticky;
  top: 0;
  z-index: 5;
  background: var(--bg);
  border-bottom: 1px solid var(--border-light);
  /* Safe-area insets (notch, rounded corners) are 0 unless viewport-fit=cover applies. */
  padding: calc(22px + env(safe-area-inset-top)) calc(20px + env(safe-area-inset-right)) 14px
    calc(20px + env(safe-area-inset-left));
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--accent);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.title {
  font-family: 'Fraunces', Georgia, serif;
  font-weight: 600;
  font-size: 20px;
  line-height: 1.1;
}

.subtitle {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 14px;
}

.search-box input {
  border: none;
  outline: none;
  flex-grow: 1;
  font-size: 16px; /* below 16px, iOS (Safari and WKWebView) zooms the page on focus */
  font-family: 'Work Sans', sans-serif;
  color: var(--text);
  background: transparent;
}

.chip-row {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 2px;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.chip-row::-webkit-scrollbar {
  display: none;
}

.chip {
  flex-shrink: 0;
  padding: 7px 14px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 500;
  font-family: 'Work Sans', sans-serif;
  cursor: pointer;
  white-space: nowrap;
  background: var(--card-bg);
  color: var(--accent);
  border: 1px solid var(--border);
}

.chip.active {
  background: var(--chip-color, var(--accent));
  color: var(--bg);
  border-color: var(--chip-color, var(--accent));
}

/* Per-category result count, shown on primary chips only while searching. */
.chip-count {
  margin-left: 6px;
  font-size: 11.5px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  opacity: 0.6;
}

.chip.active .chip-count {
  opacity: 0.85;
}

.chip.chip-empty:not(.active) {
  opacity: 0.45;
}

.secondary-filter {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-top: -2px;
}

.secondary-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted-light);
  padding-left: 2px;
}

.chip-row-secondary {
  gap: 0;
}

.chip-row-secondary .chip {
  padding: 4px 2px;
  border: none;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  background: transparent;
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 500;
  margin-right: 14px;
}

.chip-row-secondary .chip.active {
  color: var(--text);
  border-bottom-color: var(--accent);
  font-weight: 600;
}

.meta-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.result-count {
  font-size: 12px;
  color: var(--muted-light);
}

.sort-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.sort-wrap select {
  appearance: none;
  -webkit-appearance: none;
  border: 1px solid var(--border);
  background: var(--card-bg);
  border-radius: 8px;
  padding: 6px 28px 6px 10px;
  font-size: 12px;
  font-family: 'Work Sans', sans-serif;
  color: var(--text);
}

.sort-wrap .chevron {
  position: absolute;
  right: 8px;
  pointer-events: none;
}

.list {
  flex-grow: 1;
  padding: 16px calc(16px + env(safe-area-inset-right)) calc(8px + env(safe-area-inset-bottom))
    calc(16px + env(safe-area-inset-left));
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.card {
  flex-shrink: 0;
  background: var(--card-bg);
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid var(--border-light);
  box-shadow: 0 1px 2px rgba(31, 36, 30, 0.04);
}

.thumb-wrap {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: var(--border);
}

.thumb-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.badge {
  position: absolute;
  font-size: 11px;
  font-weight: 500;
  padding: 3px 7px;
  border-radius: 5px;
}

.badge-duration {
  bottom: 8px;
  right: 8px;
  background: rgba(0, 0, 0, 0.72);
  color: #fff;
  font-variant-numeric: tabular-nums;
}

.badge-live {
  bottom: 8px;
  right: 8px;
  background: var(--live);
  color: #fff;
  font-weight: 600;
  letter-spacing: 0.04em;
}

.badge-category {
  top: 8px;
  left: 8px;
  background: var(--cat-color, var(--accent));
  color: #fff;
  font-weight: 600;
  font-size: 10px;
}

.pill-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 7px;
}

.pill {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 500;
  background: var(--border-light);
  color: var(--muted);
  white-space: nowrap;
}

.card-body {
  padding: 12px 14px 13px;
}

.card-title {
  font-size: 14.5px;
  font-weight: 600;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 39px;
}

.card-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 9px;
}

.card-meta-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.stat {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: var(--muted);
}

.date {
  font-size: 12px;
  color: var(--muted-light);
}

.empty-state, .error-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 60px 20px;
  gap: 10px;
  color: var(--muted-light);
  font-size: 14px;
}

.error-state {
  color: var(--live);
}

.skeleton {
  flex-shrink: 0;
  background: var(--card-bg);
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid var(--border-light);
  height: 260px;
}

.skeleton .thumb-wrap {
  background: linear-gradient(90deg, #EEE7D9 25%, #F5F0E4 37%, #EEE7D9 63%);
  background-size: 400% 100%;
  animation: shimmer 1.4s ease infinite;
}

@keyframes shimmer {
  0% { background-position: 100% 50%; }
  100% { background-position: 0 50%; }
}

.load-more-wrap {
  padding: 4px 16px calc(28px + env(safe-area-inset-bottom));
  display: flex;
  justify-content: center;
}

.load-more {
  padding: 10px 24px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--card-bg);
  color: var(--accent);
  font-family: 'Work Sans', sans-serif;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.load-more:disabled {
  opacity: 0.5;
  cursor: default;
}

/* ---- Embedded in the mobile app's WebView (?embed=1) ---- */

/* The app's native title bar replaces the page header. */
.embed .brand {
  display: none;
}

.embed .header {
  padding-top: calc(12px + env(safe-area-inset-top));
}

/* Feel like part of the app: no grey tap flash, no long-press callouts on images. */
.embed {
  -webkit-tap-highlight-color: transparent;
}

.embed .thumb-wrap img {
  -webkit-touch-callout: none;
}
