:root {
  --blue: #4285f4;
  --red: #ea4335;
  --yellow: #fbbc05;
  --green: #34a853;
  --link: #1a0dab;
  --link-visited: #681da8;
  --url: #202124;
  --site: #4d5156;
  --snippet: #4d5156;
  --border: #dfe1e5;
  --text: #202124;
  --muted: #70757a;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  font-family: arial, "Helvetica Neue", Helvetica, sans-serif;
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  overflow-x: clip;
}

/* Reserve bottom space for the floating PWA install badge so it never covers
   the footer (home) or the "Orang lain juga menelusuri" section (results). */
body.has-pwa-badge { padding-bottom: 80px; }
@media (max-width: 480px) {
  body.has-pwa-badge { padding-bottom: 92px; }
}

/* On home (desktop), put the floating badge on the SAME ROW as the footer links:
   the footer sits flush at the bottom and its link row is tall enough to hold the
   badge, so the left-aligned links and the right-corner badge share one row. The
   badge (bottom:16px, ~46px tall → center 39px) lines up with this row's center. */
body.home.has-pwa-badge { padding-bottom: 0; }
body.home.has-pwa-badge .foot-links { min-height: 78px; }
@media (max-width: 480px) {
  /* Mobile: the badge is full-width, so drop it into a grey band below the links. */
  body.home.has-pwa-badge .foot-links { min-height: 0; }
  body.home.has-pwa-badge .home-footer { padding-bottom: 92px; }
}

/* Brand wordmark colors */
.c-blue { color: var(--blue); }
.c-red { color: var(--red); }
.c-yellow { color: var(--yellow); }
.c-green { color: var(--green); }
.dotlink { color: var(--muted); }

a { color: inherit; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* =========================================================
   HOME PAGE
   ========================================================= */
body.home {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}
.home-top {
  display: flex;
  justify-content: flex-end;
  gap: 18px;
  padding: 16px 22px;
  font-size: 13px;
}
.home-top .top-link { color: #000; opacity: .75; text-decoration: none; }
.home-top .top-link:hover { text-decoration: underline; }

.home-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0 16px;
  margin-top: -8vh;
}

.trending {
  margin-top: 36px;
  width: 100%;
  max-width: 560px;
}
.trending-title {
  font-size: 13px;
  color: var(--muted);
  text-align: center;
  margin-bottom: 14px;
}
.trending-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
}
.trending-list a {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 15px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: #fff;
  color: var(--text);
  text-decoration: none;
  font-size: 14px;
  transition: background 0.15s ease, box-shadow 0.15s ease;
}
.trending-list a:hover {
  background: #f8f9fa;
  box-shadow: 0 1px 5px rgba(0, 0, 0, 0.12);
}
.trending-list svg {
  width: 14px;
  height: 14px;
  color: var(--blue);
  flex: 0 0 auto;
}
.logo {
  font-size: clamp(30px, 10vw, 88px);
  font-weight: 500;
  letter-spacing: -3px;
  margin: 0 0 6px;
  user-select: none;
  max-width: 100%;
}
.tagline {
  margin: 0 0 26px;
  color: var(--muted);
  font-size: 15px;
}

.search-form { width: 100%; max-width: 580px; }
.ac-host { position: relative; }
.ac-list {
  position: absolute; left: 0; right: 0; top: 100%; margin: 6px 0 0; padding: 6px 0;
  list-style: none; background: #fff; border: 1px solid var(--border, #dfe1e5);
  border-radius: 14px; box-shadow: 0 4px 18px rgba(32, 33, 36, 0.18); z-index: 60;
  overflow: hidden;
}
.ac-item { padding: 9px 20px; cursor: pointer; font-size: 15px; color: #202124; }
.ac-item:hover, .ac-item.active { background: #f1f3f4; }
.search-box {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 11px 18px;
  box-shadow: none;
  transition: box-shadow .15s, border-color .15s;
}
.search-box:hover,
.search-box:focus-within {
  box-shadow: 0 1px 6px rgba(32,33,36,.28);
  border-color: rgba(223,225,229,0);
}
.search-icon { color: var(--muted); flex: 0 0 auto; }
.search-input {
  flex: 1;
  border: none;
  outline: none;
  font-size: 16px;
  background: transparent;
  color: var(--text);
}
.buttons {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-top: 28px;
}
.btn {
  background: #f8f9fa;
  border: 1px solid #f8f9fa;
  border-radius: 4px;
  color: #3c4043;
  font-size: 14px;
  padding: 0 16px;
  height: 36px;
  cursor: pointer;
}
.btn:hover {
  border-color: #dadce0;
  box-shadow: 0 1px 1px rgba(0,0,0,.1);
  color: #202124;
}

.home-footer {
  background: #f2f2f2;
  border-top: 1px solid #e4e4e4;
  font-size: 14px;
  color: var(--muted);
}
.foot-row { padding: 14px 22px; }
.foot-row + .foot-row { border-top: 1px solid #e4e4e4; }
.foot-links { display: flex; gap: 22px; flex-wrap: wrap; align-items: center; }
.foot-install {
  background: none;
  border: 0;
  padding: 0;
  font: inherit;
  color: var(--blue);
  cursor: pointer;
  text-decoration: none;
}
.foot-install:hover { text-decoration: underline; }

/* =========================================================
   RESULTS PAGE
   ========================================================= */
body.results { background: #fff; }

.results-header {
  border-bottom: 1px solid #ebebeb;
  position: sticky;
  top: 0;
  background: #fff;
  z-index: 10;
}
.header-inner {
  display: flex;
  align-items: center;
  gap: 28px;
  padding: 18px 24px 0;
  max-width: 1100px;
}
.logo-small {
  font-size: 26px;
  font-weight: 500;
  letter-spacing: -1px;
  text-decoration: none;
  white-space: nowrap;
}
.search-form-top { flex: 1; max-width: 600px; min-width: 0; }
.search-form-top .search-box { padding: 8px 16px; }
.search-go {
  background: none;
  border: none;
  color: var(--blue);
  cursor: pointer;
  display: flex;
  padding: 0;
}

.tabs {
  display: flex;
  gap: 26px;
  padding: 14px 24px 0;
  max-width: 1100px;
  margin-left: 0;
  padding-left: calc(24px + 26px + 28px);
  font-size: 13px;
}
.tab {
  text-decoration: none;
  color: var(--muted);
  padding-bottom: 12px;
  border-bottom: 3px solid transparent;
}
.tab.active { color: var(--blue); border-bottom-color: var(--blue); }
.tab.disabled { color: #bdc1c6; cursor: default; }

.results-main {
  max-width: 652px;
  padding: 22px 24px 60px;
  margin-left: calc(24px + 26px + 28px);
}
@media (max-width: 760px) {
  .header-inner { gap: 14px; }
  .logo-small { font-size: 20px; }
  .tabs, .results-main { padding-left: 24px; margin-left: 0; }
}

.stats {
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 18px;
}

.suggestion {
  color: var(--text);
  font-size: 15px;
  margin: -8px 0 18px;
}
.suggestion a { color: var(--blue); text-decoration: none; }
.suggestion a:hover { text-decoration: underline; }

.results-list { display: flex; flex-direction: column; gap: 26px; }

.related { margin-top: 40px; }
.related-title {
  font-size: 18px;
  font-weight: 400;
  color: var(--text);
  margin: 0 0 16px;
}
.related-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  max-width: 640px;
}
.related-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 11px 16px;
  background: #f1f3f4;
  border-radius: 24px;
  color: var(--text);
  text-decoration: none;
  font-size: 15px;
}
.related-item:hover { background: #e8eaed; }
.related-item svg { width: 16px; height: 16px; color: var(--text); flex: 0 0 auto; }
@media (max-width: 640px) {
  .related-grid { grid-template-columns: 1fr; }
}

.result { max-width: 600px; transition: opacity .3s ease; }
.result.dying { opacity: 0; }
.result-site {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 3px;
}
.result-favicon {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 1px solid #ec;
  background: #f1f3f4;
  flex: 0 0 auto;
  object-fit: contain;
}
.result-sitemeta { line-height: 1.3; overflow: hidden; }
.result-host { font-size: 14px; color: var(--url); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.result-url { font-size: 12px; color: var(--site); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.result-title {
  font-size: 20px;
  line-height: 1.3;
  color: var(--link);
  text-decoration: none;
  display: inline-block;
  margin: 2px 0 3px;
}
.result-title:hover { text-decoration: underline; }
.result-title:visited { color: var(--link-visited); }
.result-snippet {
  font-size: 14px;
  line-height: 1.58;
  color: var(--snippet);
}
.badge {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .4px;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 1px 5px;
  margin-left: 6px;
  vertical-align: middle;
}

.empty, .error {
  padding: 30px 0;
  color: var(--text);
  font-size: 15px;
  line-height: 1.6;
}
.error { color: var(--red); }

.loading {
  padding: 40px 0;
  color: var(--muted);
  font-size: 14px;
}

.offline-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  text-align: center;
  padding: 56px 20px;
  color: var(--text);
}
.offline-state img { width: 80px; height: 80px; opacity: 0.9; }
.offline-state h2 { margin: 0; font-size: 20px; font-weight: 500; }
.offline-state p { margin: 0; color: var(--muted); max-width: 340px; line-height: 1.6; }
.offline-retry {
  margin-top: 4px;
  padding: 10px 24px;
  border: 0;
  border-radius: 24px;
  background: var(--red);
  color: #fff;
  font-size: 15px;
  cursor: pointer;
}
.offline-retry:hover { filter: brightness(0.95); }

/* Image grid (Gambar tab) */
body.results.images-mode .results-main {
  max-width: 1180px;
}
@media (max-width: 760px) {
  body.results.images-mode .results-main { margin-left: 0; padding-left: 16px; padding-right: 16px; }
}

.image-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 16px;
}
.img-tile {
  display: flex;
  flex-direction: column;
  text-decoration: none;
  color: var(--site);
}
.img-wrap {
  display: block;
  width: 100%;
  height: 150px;
  border-radius: 8px;
  overflow: hidden;
  background: #f1f3f4;
}
.img-tile img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform .15s ease;
}
.img-tile:hover img { transform: scale(1.03); }
.img-host {
  font-size: 12px;
  color: var(--site);
  margin-top: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Pagination */
.pagination {
  display: flex;
  gap: 18px;
  align-items: center;
  margin-top: 46px;
  font-size: 14px;
}
.page-link {
  color: var(--blue);
  text-decoration: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.page-link:hover { text-decoration: underline; }
.page-link.disabled { color: #bdc1c6; cursor: default; pointer-events: none; }
.page-current { color: var(--text); font-weight: 600; }

/* =========================================================
   RESPONSIVE / MOBILE
   Phones: smaller wordmark, tighter padding, fluid grids.
   Note: search inputs stay at 16px so iOS Safari doesn't auto-zoom on focus.
   ========================================================= */
@media (max-width: 600px) {
  /* Home */
  .home-top { padding: 12px 16px; gap: 14px; }
  .home-main { margin-top: -4vh; padding: 0 20px; }
  .logo { letter-spacing: -2px; }
  .tagline { font-size: 14px; margin-bottom: 22px; }
  .buttons { flex-wrap: wrap; }
  .btn { flex: 1 1 auto; min-width: 140px; height: 40px; }
  .foot-row { padding: 12px 16px; }
  .foot-links { gap: 14px; }

  /* Results header */
  .results-header { padding-bottom: 2px; }
  .header-inner { gap: 10px; padding: 12px 14px 0; }
  .logo-small { font-size: 18px; }
  .search-form-top .search-box { padding: 9px 14px; }

  /* Tabs + main content (override the desktop indentation) */
  .tabs { padding: 12px 14px 0; gap: 22px; }
  .results-main { padding: 16px 14px 48px; }
  .stats { margin-bottom: 14px; }

  /* Web results */
  .results-list { gap: 22px; }
  .result-title { font-size: 18px; }

  /* Image grid */
  .image-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
  .img-wrap { height: 120px; }

  /* Pagination — larger tap targets, more spacing */
  .pagination { gap: 20px; margin-top: 32px; }
  .page-link { padding: 6px 0; }
}

@media (max-width: 380px) {
  .image-grid { grid-template-columns: repeat(2, 1fr); }
  .img-wrap { height: 108px; }
}

/* Long unbroken strings (URLs/keywords in titles) must never push the page
   wide on a phone. */
.result-title,
.result-snippet { overflow-wrap: anywhere; }
.result { max-width: 100%; }

/* Extra-small phones: compact results header so the search box keeps room. */
@media (max-width: 440px) {
  .header-inner { gap: 8px; padding: 10px 12px 0; }
  .logo-small { font-size: 16px; }
  .search-form-top .search-box { padding: 8px 12px; gap: 8px; }
  .tabs { padding: 10px 12px 0; gap: 18px; }
  .results-main { padding: 14px 12px 44px; }
  .result-title { font-size: 17px; }
  .stats { font-size: 12px; }
}