:root {
    --navy: #f0f4f8;
    --navy-mid: #e8eef5;
    --navy-light: #dde6f0;
    --blue: #4a90d9;
    --accent: #6b21a8;
    --accent-bright: #7c3aed;
    --gold: #6b21a8;
    --gold-light: #a855f7;
    --white: #1a1a2e;
    --gray: #64748b;
    --gray-light: #334155;
    --success: #059669;
    --danger: #dc2626;
    --glass: rgba(255,255,255,0.75);
    --glass-border: rgba(107,33,168,0.15);
    --we-purple: #6b21a8;
    --we-purple-light: #9333ea;
    --we-purple-soft: rgba(107,33,168,0.08);
    --text-main: #1e1b4b;
    --text-sub: #64748b;
  }

  * { margin: 0; padding: 0; box-sizing: border-box; }

  body {
    font-family: 'Cairo', 'Tajawal', sans-serif;
    background: #f8f7ff;
    color: var(--text-main);
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
  }

  /* Background soft purple glow */
  body::before {
    content: '';
    position: fixed;
    inset: 0;
    background:
      radial-gradient(ellipse 70% 50% at 50% -5%, rgba(107,33,168,0.10) 0%, transparent 60%),
      radial-gradient(ellipse 40% 40% at 90% 85%, rgba(147,51,234,0.07) 0%, transparent 50%),
      linear-gradient(180deg, #f8f7ff 0%, #f0eeff 100%);
    pointer-events: none;
    z-index: 0;
  }

  body::after {
    content: '';
    position: fixed;
    inset: 0;
    background-image:
      linear-gradient(rgba(107,33,168,0.03) 1px, transparent 1px),
      linear-gradient(90deg, rgba(107,33,168,0.03) 1px, transparent 1px);
    background-size: 40px 40px;
    pointer-events: none;
    z-index: 0;
  }
  .back-btn:hover{background:rgba(255,255,255,0.25);}


  .container {
    position: relative;
    z-index: 1;
    max-width: 820px;
    margin: 0 auto;
    padding: 2rem 1.2rem 4rem;
  }

  /* ===== HEADER ===== */
  header {
    text-align: center;
    padding: 3rem 0 2.5rem;
  }

  .badge {
    display: inline-flex;
    align-items: center;
    gap: .5rem;
    background: rgba(107,33,168,0.10);
    border: 1px solid rgba(107,33,168,0.25);
    color: var(--we-purple);
    font-size: .72rem;
    font-weight: 700;
    letter-spacing: .12em;
    padding: .35rem .9rem;
    border-radius: 2rem;
    margin-bottom: 1.4rem;
    text-transform: uppercase;
  }

  .badge::before {
    content: '📡';
    font-size: 1rem;
  }

  h1 {
    font-size: clamp(2rem, 5vw, 3.2rem);
    font-weight: 900;
    line-height: 1.15;
    letter-spacing: -.02em;
    background: linear-gradient(135deg, var(--we-purple) 30%, var(--we-purple-light) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: .6rem;
  }

  .subtitle {
    color: var(--text-sub);
    font-size: 1rem;
    font-weight: 400;
    max-width: 480px;
    margin: 0 auto;
    line-height: 1.7;
  }

  /* ===== STATS BAR ===== */
  .stats-bar {
    display: flex;
    justify-content: center;
    gap: 2rem;
    margin: 2rem 0;
    flex-wrap: wrap;
  }

  .stat {
    text-align: center;
  }

  .stat-num {
    font-size: 1.6rem;
    font-weight: 900;
    color: var(--we-purple);
    display: block;
  }

  .stat-label {
    font-size: .72rem;
    color: var(--text-sub);
    font-weight: 400;
    letter-spacing: .05em;
  }

  /* ===== SEARCH CARD ===== */
  .search-card {
    background: rgba(255,255,255,0.92);
    border: 1px solid rgba(107,33,168,0.12);
    border-radius: 20px;
    padding: 2rem;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    margin-bottom: 2rem;
    box-shadow: 0 8px 40px rgba(107,33,168,0.10), inset 0 1px 0 rgba(255,255,255,0.9);
  }

  .search-label {
    font-size: .82rem;
    font-weight: 600;
    color: var(--text-main);
    letter-spacing: .06em;
    margin-bottom: .7rem;
    display: block;
  }

  .input-wrap {
    position: relative;
    margin-bottom: 1rem;
  }

  .input-wrap svg {
    position: absolute;
    right: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--gray);
    pointer-events: none;
    transition: color .2s;
  }

  input[type="text"] {
    width: 100%;
    background: #f8f7ff;
    border: 1.5px solid rgba(107,33,168,0.2);
    border-radius: 12px;
    padding: .9rem 3rem .9rem 1.1rem;
    font-family: 'Cairo', sans-serif;
    font-size: 1rem;
    color: var(--text-main);
    outline: none;
    transition: border-color .2s, box-shadow .2s, background .2s;
    direction: rtl;
  }

  input[type="text"]::placeholder { color: var(--text-sub); }

  input[type="text"]:focus {
    border-color: var(--we-purple);
    background: #fff;
    box-shadow: 0 0 0 3px rgba(107,33,168,0.12);
  }

  input[type="text"]:focus + svg { color: var(--we-purple); }

  .btn-row {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: .8rem;
  }

  .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .55rem;
    font-family: 'Cairo', sans-serif;
    font-size: .95rem;
    font-weight: 700;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: all .2s;
    padding: .85rem 1.5rem;
    white-space: nowrap;
  }

  .btn-primary {
    background: linear-gradient(135deg, var(--we-purple) 0%, var(--we-purple-light) 100%);
    color: #fff;
    box-shadow: 0 4px 20px rgba(107,33,168,0.30);
  }

  .btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 28px rgba(107,33,168,0.45);
    background: linear-gradient(135deg, var(--we-purple-light) 0%, var(--we-purple) 100%);
  }

  .btn-primary:active { transform: translateY(0); }

  .btn-gps {
    background: rgba(107,33,168,0.08);
    border: 1.5px solid rgba(107,33,168,0.3);
    color: var(--we-purple);
    flex-shrink: 0;
  }

  .btn-gps:hover {
    background: rgba(107,33,168,0.15);
    border-color: var(--we-purple);
    transform: translateY(-2px);
  }

  /* ===== STATUS ===== */
  #status {
    margin-top: 1rem;
    min-height: 1.4rem;
    font-size: .85rem;
    font-weight: 500;
    text-align: center;
    transition: all .3s;
  }

  .status-loading { color: var(--we-purple); }
  .status-success { color: var(--success); }
  .status-error   { color: var(--danger); }

  .spinner {
    display: inline-block;
    width: 14px; height: 14px;
    border: 2px solid rgba(107,33,168,0.2);
    border-top-color: var(--we-purple);
    border-radius: 50%;
    animation: spin .7s linear infinite;
    vertical-align: middle;
    margin-left: .4rem;
  }

  @keyframes spin { to { transform: rotate(360deg); } }

  /* ===== RESULTS ===== */
  #results {
    display: none;
  }

  #results.visible { display: block; }

  .results-title {
    font-size: .82rem;
    font-weight: 700;
    color: var(--text-sub);
    letter-spacing: .1em;
    text-transform: uppercase;
    margin-bottom: 1.2rem;
    display: flex;
    align-items: center;
    gap: .5rem;
  }

  .results-title::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--glass-border);
  }

  .station-card {
    background: rgba(255,255,255,0.92);
    border: 1px solid rgba(107,33,168,0.12);
    border-radius: 16px;
    padding: 1.5rem;
    margin-bottom: 1rem;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    gap: 1.2rem;
    box-shadow: 0 4px 20px rgba(107,33,168,0.08);
    opacity: 0;
    transform: translateY(20px);
    transition: opacity .4s ease, transform .4s ease, border-color .2s, box-shadow .2s;
    cursor: default;
  }

  .station-card.show {
    opacity: 1;
    transform: translateY(0);
  }

  .station-card:hover {
    border-color: rgba(107,33,168,0.30);
    box-shadow: 0 8px 30px rgba(107,33,168,0.12);
  }

  .station-card.rank-1 {
    border-color: rgba(107,33,168,0.25);
  }

  .station-card.rank-1:hover {
    border-color: rgba(107,33,168,0.5);
    box-shadow: 0 8px 30px rgba(107,33,168,0.15);
  }

  .rank-badge {
    flex-shrink: 0;
    width: 52px;
    height: 52px;
    border-radius: 14px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-weight: 900;
    font-size: 1.4rem;
    line-height: 1;
  }

  .rank-1 .rank-badge {
    background: linear-gradient(135deg, rgba(107,33,168,0.18), rgba(107,33,168,0.08));
    border: 1.5px solid rgba(107,33,168,0.35);
    color: var(--we-purple);
  }

  .rank-2 .rank-badge {
    background: linear-gradient(135deg, rgba(147,51,234,0.15), rgba(147,51,234,0.06));
    border: 1.5px solid rgba(147,51,234,0.30);
    color: var(--we-purple-light);
  }

  .rank-label {
    font-size: .55rem;
    font-weight: 700;
    letter-spacing: .05em;
    margin-top: .1rem;
    opacity: .8;
  }

  .station-info {
    flex: 1;
    min-width: 0;
  }

  .station-name {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: .25rem;
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .station-id {
    font-size: .75rem;
    color: var(--text-sub);
    font-weight: 400;
  }

  .distance-badge {
    flex-shrink: 0;
    text-align: center;
  }

  .distance-num {
    font-size: 1.5rem;
    font-weight: 900;
    line-height: 1;
    display: block;
  }

  .rank-1 .distance-num { color: var(--we-purple); }
  .rank-2 .distance-num { color: var(--we-purple-light); }

  .distance-unit {
    font-size: .7rem;
    color: var(--text-sub);
    font-weight: 500;
    letter-spacing: .04em;
  }

  /* ===== MAP LINK ===== */
  .map-link {
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    font-size: .75rem;
    color: var(--we-purple);
    text-decoration: none;
    margin-top: .3rem;
    opacity: .8;
    transition: opacity .2s;
  }
  .map-link:hover { opacity: 1; }

  /* ===== USER LOCATION CHIP ===== */
  #location-chip {
    display: none;
    align-items: center;
    gap: .5rem;
    background: rgba(45,201,138,0.1);
    border: 1px solid rgba(45,201,138,0.3);
    border-radius: 8px;
    padding: .5rem .9rem;
    font-size: .8rem;
    color: var(--success);
    margin-top: 1rem;
  }

  #location-chip.visible { display: flex; }

  /* ===== FOOTER ===== */
  footer {
    text-align: center;
    margin-top: 3rem;
    color: var(--text-sub);
    font-size: .75rem;
    opacity: .7;
  }

  .footer-logo {
    display: block;
    margin: 0 auto .5rem;
    height: 28px;
    width: auto;
    opacity: .85;
  }
  /* ================= NOTE BOX ================= */
.note-box{
    background:#fff8e1;
    border-radius:14px;
    padding:14px 18px;
    margin-bottom:28px;
    display:flex;
    align-items:center;
    gap:12px;
    border-right:4px solid #ff9800;
    font-size:13px;
    color:#5d4037;
    font-weight:600;
}

.note-box i{color:#ff9800;font-size:18px;flex-shrink:0;}


  /* ===== RESPONSIVE ===== */
  @media (max-width: 520px) {
    .btn-row { grid-template-columns: 1fr; }
    .station-name { font-size: .95rem; }
    .distance-num { font-size: 1.2rem; }
    h1 { font-size: 1.8rem; }
    .stats-bar { gap: 1.2rem; }
  }
