:root {
  --bg: #0e0e0e;
  --card: #1a1a1a;
  --card-raised: #222222;
  --text: #e8e8e8;
  --text-secondary: #8a8a8a;
  --border: #2a2a2a;
  --border-focus: #2dd4bf;
  --teal-400: #2dd4bf;
  --teal-500: #14b8a6;
  --teal-600: #0d9488;
  --teal-900: #0c3b36;
  --amber-400: #fbbf24;
  --amber-900: #3b2a08;
  --green-400: #4ade80;
  --green-900: #14532d;
  --red-400: #f87171;
  --red-900: #450a0a;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.4);
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
}

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

body {
  font-family: "DM Sans", ui-sans-serif, system-ui, -apple-system, sans-serif;
  color: var(--text);
  background: var(--bg);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ── Geometric background ── */
.geo-bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  opacity: 0.12;
  pointer-events: none;
  background:
    radial-gradient(circle at 20% 10%, rgba(45, 212, 191, 0.2), transparent 30%),
    radial-gradient(circle at 80% 85%, rgba(251, 191, 36, 0.12), transparent 28%),
    repeating-conic-gradient(from 0deg at 50% 50%, transparent 0deg 30deg, rgba(45, 212, 191, 0.03) 30deg 60deg);
  background-size: 100% 100%, 100% 100%, 80px 80px;
}

/* ── Layout — fixed max-width, never grows ── */
main {
  width: 100%;
  max-width: 640px;
  margin: 0 auto;
  padding: 0.75rem 0.75rem 2rem;
  display: grid;
  gap: 0.65rem;
  overflow: hidden;
}

/* ── Cards ── */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.85rem;
  box-shadow: var(--shadow);
  overflow: hidden;
}

/* ── Hero ── */
.hero {
  background: linear-gradient(135deg, #0d9488, #115e59);
  border-radius: var(--radius);
  padding: 1rem;
  color: #fff;
  box-shadow: var(--shadow-md);
}

.hero-inner {
  display: flex;
  align-items: center;
  gap: 0.7rem;
}

.hero-icon {
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  background: transparent;
  border-radius: 50%;
  flex-shrink: 0;
}

.hero-icon img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.25);
}

h1 {
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.025em;
  line-height: 1.2;
}

.hero-sub {
  font-size: 0.88rem;
  opacity: 0.75;
  margin-top: 0.15rem;
}

/* ── Location blocks ── */
.loc-row {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 0.5rem;
  align-items: start;
}

.loc-block {
  min-width: 0;
}

.loc-label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-secondary);
  margin-bottom: 0.35rem;
}

.loc-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.from-dot { background: var(--teal-400); }
.to-dot { background: var(--amber-400); }

/* ── Search input with icon on the right ── */
.search-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  right: 0.7rem;
  top: 50%;
  translate: 0 -50%;
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  color: var(--text-secondary);
  opacity: 0.4;
  pointer-events: none;
}

.search-wrap input {
  padding-right: 2.2rem;
}

input[type="text"],
input[type="number"] {
  width: 100%;
  height: 42px;
  padding: 0 0.7rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font: inherit;
  font-size: 0.9rem;
  background: var(--card-raised);
  color: var(--text);
  transition: border-color 0.15s;
}

input::placeholder {
  color: var(--text-secondary);
  opacity: 0.6;
}

input:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(45, 212, 191, 0.15);
}

.loc-divider {
  display: grid;
  place-items: center;
  padding-top: 1.7rem;
  color: var(--text-secondary);
}

.loc-summary {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-top: 0.3rem;
  min-height: 1.3em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.loc-summary.active {
  color: var(--teal-400);
  font-weight: 500;
}

.btn-geo {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin-top: 0.4rem;
  padding: 0.38rem 0.65rem;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--teal-400);
  background: var(--teal-900);
  border: 1px solid rgba(45, 212, 191, 0.2);
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-geo:hover {
  background: rgba(45, 212, 191, 0.15);
}

/* ── Suggestions dropdown ── */
.suggestions {
  display: grid;
  gap: 0;
  margin-top: 0.25rem;
}

.suggestions:empty {
  display: none;
}

.suggestions .sug-btn {
  display: block;
  width: 100%;
  padding: 0.55rem 0.6rem;
  text-align: left;
  font: inherit;
  font-size: 0.85rem;
  color: var(--text);
  background: var(--card-raised);
  border: 1px solid var(--border);
  border-top: none;
  cursor: pointer;
  transition: background 0.1s;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.suggestions .sug-btn:first-child {
  border-top: 1px solid var(--border);
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
}

.suggestions .sug-btn:last-child {
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
}

.suggestions .sug-btn:hover {
  background: var(--teal-900);
}

.suggestions .sug-hint {
  padding: 0.45rem 0.6rem;
  font-size: 0.83rem;
  color: var(--text-secondary);
}

/* ── Map ── */
.card-map {
  padding: 0;
  overflow: hidden;
}

.map-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.55rem 0.85rem;
  border-bottom: 1px solid var(--border);
}

.map-label {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.map-target-toggle {
  display: flex;
  background: var(--bg);
  border-radius: 999px;
  padding: 3px;
}

.toggle-btn {
  padding: 0.3rem 0.7rem;
  font: inherit;
  font-size: 0.76rem;
  font-weight: 600;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s;
}

.toggle-btn.active {
  background: var(--teal-600);
  color: #fff;
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.3);
}

.map-container { position: relative; }

#map {
  width: 100%;
  height: 280px;
}

/* ── Results ── */
.results-empty {
  text-align: center;
  padding: 1.2rem 0.5rem;
  color: var(--text-secondary);
}

.results-empty svg {
  margin-bottom: 0.4rem;
  opacity: 0.3;
}

.results-empty p { font-size: 0.88rem; }

.distance-banner {
  text-align: center;
  padding: 0.6rem;
  background: var(--card-raised);
  border-radius: var(--radius-sm);
  margin-bottom: 0.55rem;
}

.distance-banner .dist-value {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--teal-400);
}

.distance-banner .dist-miles {
  font-size: 0.88rem;
  color: var(--text-secondary);
}

.result-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 0.45rem;
}

.result-item {
  padding: 0.6rem;
  border-radius: var(--radius-sm);
  text-align: center;
}

.result-item.eligible {
  background: var(--green-900);
  border: 1.5px solid rgba(74, 222, 128, 0.25);
}

.result-item.not-eligible {
  background: var(--red-900);
  border: 1.5px solid rgba(248, 113, 113, 0.25);
}

.result-item h4 {
  font-size: 0.8rem;
  font-weight: 600;
  margin-bottom: 0.2rem;
}

.result-badge {
  display: inline-block;
  padding: 0.18rem 0.55rem;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 600;
}

.result-item.eligible .result-badge {
  background: rgba(74, 222, 128, 0.15);
  color: var(--green-400);
}

.result-item.not-eligible .result-badge {
  background: rgba(248, 113, 113, 0.15);
  color: var(--red-400);
}

.result-detail {
  font-size: 0.74rem;
  color: var(--text-secondary);
  margin-top: 0.25rem;
}

/* ── Options ── */
.opts-row {
  display: flex;
  gap: 1rem;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
}

.opts-title {
  font-size: 0.76rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-secondary);
  margin-bottom: 0.4rem;
}

.madhhab-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.pill { display: block; cursor: pointer; }
.pill input { display: none; }

.pill span {
  display: inline-block;
  padding: 0.35rem 0.7rem;
  font-size: 0.84rem;
  font-weight: 500;
  border: 1.5px solid var(--border);
  border-radius: 999px;
  color: var(--text-secondary);
  background: var(--card);
  transition: all 0.15s;
  user-select: none;
}

.pill input:checked + span {
  background: var(--teal-900);
  border-color: rgba(45, 212, 191, 0.35);
  color: var(--teal-400);
}

.stay-group { text-align: right; }

.stay-input-wrap {
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.stay-btn {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 1.5px solid var(--border);
  border-radius: 999px;
  background: var(--card-raised);
  color: var(--text);
  font-size: 1.1rem;
  font-weight: 600;
  cursor: pointer;
  padding: 0;
  transition: background 0.1s;
}

.stay-btn:hover { background: var(--border); }

.stay-input-wrap input {
  width: 48px;
  height: 34px;
  text-align: center;
  font-weight: 600;
  padding: 0;
}

.stay-unit {
  font-size: 0.84rem;
  color: var(--text-secondary);
  margin-left: 0.1rem;
}

input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

input[type="number"] { -moz-appearance: textfield; }

/* ── Info accordion ── */
.card-info { padding: 0; }

.info-toggle {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.75rem 0.85rem;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  list-style: none;
  color: var(--text);
}

.info-toggle::-webkit-details-marker { display: none; }

.info-toggle svg {
  flex-shrink: 0;
  color: var(--teal-400);
}

.info-body {
  padding: 0 0.85rem 0.85rem;
  font-size: 0.88rem;
  line-height: 1.6;
}

.info-body h3 {
  font-size: 0.88rem;
  font-weight: 600;
  margin: 0.9rem 0 0.3rem;
}

.info-body h3:first-child { margin-top: 0; }

.info-body blockquote {
  margin: 0.4rem 0;
  padding: 0.55rem 0.7rem;
  border-left: 3px solid var(--amber-400);
  background: var(--amber-900);
  border-radius: 8px;
  font-style: italic;
  color: #e0c97a;
}

.info-body blockquote cite {
  display: block;
  margin-top: 0.3rem;
  font-style: normal;
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.info-body a { color: var(--teal-400); }

.info-table {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  margin: 0.5rem 0;
}

.info-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  padding: 0.4rem 0.6rem;
  font-size: 0.8rem;
  border-bottom: 1px solid var(--border);
}

.info-row:last-child { border-bottom: none; }

.info-row-header {
  font-weight: 600;
  background: var(--card-raised);
}

.info-body ul {
  padding-left: 1.1rem;
  font-size: 0.84rem;
}

.info-body li { margin-bottom: 0.3rem; }

.info-disclaimer {
  margin-top: 0.8rem;
  padding: 0.55rem;
  background: var(--amber-900);
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  color: var(--text-secondary);
}

/* ── Footer ── */
.footer {
  text-align: center;
  padding: 0.5rem;
  font-size: 0.76rem;
  color: var(--text-secondary);
}

/* ── Mobile ── */
@media (max-width: 520px) {
  main { padding: 0.5rem 0.5rem 2rem; }

  .loc-row {
    grid-template-columns: 1fr;
    gap: 0;
  }

  .loc-divider {
    padding: 0.3rem 0;
    justify-items: center;
  }

  .loc-divider svg { rotate: 90deg; }
  #map { height: 220px; }

  .opts-row {
    flex-direction: column;
    gap: 0.7rem;
  }

  .stay-group { text-align: left; }
  h1 { font-size: 1.2rem; }
  .result-grid { grid-template-columns: 1fr 1fr; }
}
