:root {
  --bg: #fbf7f3;
  --surface: #ffffff;
  --text: #1f1612;
  --muted: #8a7b72;
  --line: #ece3dc;
  --accent: #ff5a36;
  --accent-text: #ffffff;
  --radius: 18px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #151110;
    --surface: #1f1916;
    --text: #f7eee9;
    --muted: #a39087;
    --line: #2f2622;
    --accent: #ff6b4a;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

main {
  max-width: 440px;
  min-height: 100svh;
  margin: 0 auto;
  padding: max(24px, env(safe-area-inset-top)) 16px max(24px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
}

[hidden] { display: none !important; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

a { color: inherit; }

button { font: inherit; color: inherit; cursor: pointer; }

.text-button {
  background: none;
  border: 0;
  padding: 0;
  color: var(--accent);
  font-weight: 600;
}
.small { font-size: 0.875rem; }

/* Home */

.home {
  margin: auto 0;
  padding-bottom: 8vh;
  text-align: center;
}

.logo { border-radius: 14px; }

h1 {
  margin: 16px 0 4px;
  font-size: 1.75rem;
  line-height: 1.2;
  letter-spacing: -0.02em;
}

.lede { margin: 0 0 28px; color: var(--muted); }

.search {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 6px 6px 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  box-shadow: 0 1px 2px rgb(40 20 10 / 4%), 0 8px 24px rgb(40 20 10 / 6%);
}
.search:focus-within { border-color: var(--accent); }

.search input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: none;
  color: var(--text);
  font: inherit;
  padding: 10px 0;
  outline: none;
}
.search input::placeholder { color: var(--muted); }

.paste {
  border: 0;
  background: none;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 600;
  padding: 8px 10px;
}

.go {
  flex: none;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-text);
  display: grid;
  place-items: center;
}
.go:active { transform: scale(0.95); }

.setup {
  margin-top: 32px;
  text-align: left;
  font-size: 0.925rem;
}
.setup summary {
  list-style: none;
  text-align: center;
  color: var(--muted);
  cursor: pointer;
}
.setup summary::-webkit-details-marker { display: none; }
.setup summary::after { content: " ›"; }
.setup[open] summary { color: var(--text); margin-bottom: 14px; }
.setup[open] summary::after { content: ""; }

.setup ol {
  margin: 0 0 12px;
  padding: 16px 16px 16px 36px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 10px;
}
.add-shortcut {
  display: inline-block;
  margin-right: 4px;
  padding: 4px 12px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-text);
  font-weight: 700;
  text-decoration: none;
}
.setup .manual { margin: 0 0 12px; }
.setup .manual summary { text-align: left; font-size: 0.875rem; margin: 0 0 10px; }
.setup .manual summary::after { content: " ›"; }
.setup .manual[open] summary::after { content: ""; }
.setup #other-platform { display: block; margin: 0 auto; }

.copy {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 6px;
}
.copy code {
  flex: 1;
  min-width: 0;
  overflow-x: auto;
  white-space: nowrap;
  font-size: 0.8rem;
  padding: 6px 8px;
  background: var(--bg);
  border-radius: 8px;
}

/* Loading */

.status {
  margin: auto 0;
  padding-bottom: 6vh;
  text-align: center;
}

.loader {
  position: relative;
  width: 76px;
  height: 76px;
  margin: 0 auto 20px;
  display: grid;
  place-items: center;
}
.loader img { border-radius: 11px; }
.loader::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 3px solid var(--line);
  border-top-color: var(--accent);
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .loader::before { animation-duration: 2.4s; } }

.status h2 { margin: 0; font-size: 1.25rem; letter-spacing: -0.01em; }
.status-step { margin: 4px 0 0; color: var(--muted); min-height: 1.5em; }
.status-who {
  display: inline-block;
  margin: 16px 0 0;
  padding: 4px 12px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.875rem;
}

.ad-slot {
  width: 300px;
  max-width: 100%;
  height: 250px;
  margin: 36px auto 0;
  border-radius: 12px;
  background: var(--surface);
  border: 1px dashed var(--line);
  display: grid;
  place-items: center;
  overflow: hidden;
}
.result .ad-slot { margin-top: 8px; }
.ad-slot:not(:empty) { border: 0; background: none; }
.ad-slot:empty::before { content: "Advertisement"; color: var(--muted); font-size: 0.75rem; letter-spacing: 0.04em; text-transform: uppercase; }

.cancel { display: block; margin: 28px auto 0; color: var(--muted); font-weight: 500; }

/* Results */

.result { display: grid; grid-template-columns: minmax(0, 1fr); gap: 20px; padding-top: 8px; }

.back { justify-self: start; color: var(--muted); font-weight: 600; text-decoration: none; }

.result h2 { margin: 0; font-size: 1.4rem; letter-spacing: -0.01em; line-height: 1.25; }
.result .meta { margin: 4px 0 0; color: var(--muted); }

.matches { display: grid; gap: 10px; }
.label { margin: 0; color: var(--muted); font-size: 0.925rem; }

.found h2 { font-size: 1.6rem; }
.kicker {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.open-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 54px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-text);
  font-weight: 700;
  font-size: 1.05rem;
  text-decoration: none;
  box-shadow: 0 6px 20px rgb(255 90 54 / 28%);
}
.open-button:active { transform: scale(0.98); }

.match {
  display: block;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  text-decoration: none;
}
.match:active { transform: scale(0.99); }
.match.top { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.match .title { display: block; font-weight: 600; }
.match .host { display: block; color: var(--muted); font-size: 0.875rem; }

.more { margin: 0; display: flex; flex-wrap: wrap; gap: 6px 16px; color: var(--muted); font-size: 0.925rem; }
.more a { color: var(--text); font-weight: 600; text-decoration: none; white-space: nowrap; }

/* Supporters */

.supporter { margin-top: 28px; font-size: 0.875rem; color: var(--muted); }
.supporter p { margin: 0; display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 6px 16px; }
.supporter a { text-decoration: none; }
.badge { color: var(--accent); font-weight: 700; }
.muted-button { color: var(--muted); font-weight: 500; }
#my-code { margin-top: 12px; }

.code-form {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}
.code-form input {
  flex: 1;
  min-width: 0;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
}
.code-form input:focus { outline: none; border-color: var(--accent); }
.code-form button {
  border: 0;
  border-radius: 999px;
  padding: 0 18px;
  background: var(--accent);
  color: var(--accent-text);
  font-weight: 700;
}
.code-form p { flex-basis: 100%; justify-content: flex-start; }

.code-box {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
}
.code-box code {
  flex: 1;
  min-width: 0;
  overflow-wrap: anywhere;
  font-size: 0.8rem;
  text-align: left;
  color: var(--text);
}

.nudge {
  display: grid;
  gap: 2px;
  padding: 14px 16px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px dashed var(--accent);
  text-decoration: none;
}
.nudge span { color: var(--muted); font-size: 0.9rem; }

button.open-button { border: 0; width: 100%; cursor: pointer; }

/* Footer links (all screens) */

.site-foot {
  display: flex;
  justify-content: center;
  gap: 20px;
  padding-top: 32px;
  font-size: 0.8rem;
}
.site-foot a { color: var(--muted); text-decoration: none; }
.site-foot a:hover { color: var(--text); }

/* About / Privacy pages */

.doc { display: block; padding-top: max(24px, env(safe-area-inset-top)); }
.doc h1 { margin: 20px 0 4px; }
.doc h2 { margin: 32px 0 8px; font-size: 1.15rem; letter-spacing: -0.01em; }
.doc h3 { margin: 20px 0 4px; font-size: 1rem; }
.doc p, .doc li { color: var(--text); line-height: 1.6; }
.doc p { margin: 0 0 12px; }
.doc ul, .doc ol { margin: 0 0 12px; padding-left: 1.25em; display: grid; gap: 6px; }
.doc a { color: var(--accent); }
.doc .back { color: var(--muted); }
.doc .lede-left { margin: 0 0 20px; color: var(--muted); }
.doc .fine { color: var(--muted); font-size: 0.85rem; }

.caption summary { cursor: pointer; color: var(--muted); font-size: 0.925rem; }
.caption p { white-space: pre-wrap; font-size: 0.925rem; margin: 10px 0 0; }
