@font-face {
  font-family: "Vazirmatn";
  src: url("../fonts/Vazirmatn-Variable.woff2") format("woff2-variations"),
    url("../fonts/Vazirmatn-Variable.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #f3f0e8;
  --surface: #fcfbf7;
  --surface-2: #ebe6d9;
  --ink: #141816;
  --muted: #5e6862;
  --subtle: #8a928c;
  --accent: #1a5c4c;
  --accent-hover: #154c3f;
  --accent-fg: #f6f4ef;
  --accent-soft: #d7ebe4;
  --line: #d8d2c4;
  --danger: #8f2d2d;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 20px;
  --radius-xl: 28px;
  --shadow: 0 0 0 1px color-mix(in oklab, var(--ink) 8%, transparent),
    0 12px 32px -18px rgba(20, 24, 22, 0.28);
  --font: "Vazirmatn", ui-sans-serif, system-ui, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-font-smoothing: antialiased; background: var(--bg); color: var(--ink); }
body {
  margin: 0;
  font-family: var(--font);
  background-color: var(--bg);
  background-image:
    radial-gradient(ellipse 80% 50% at 100% -10%, color-mix(in oklab, var(--accent) 8%, transparent), transparent 55%),
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160' viewBox='0 0 160 160'><path d='M8 40c24 8 40-16 72-8s48 20 72 8' fill='none' stroke='%231a5c4c' stroke-opacity='0.07' stroke-width='1.2'/><path d='M0 88c28 10 44-14 80-6s52 18 80 6' fill='none' stroke='%231a5c4c' stroke-opacity='0.055' stroke-width='1.2'/></svg>");
  min-height: 100dvh;
}
button:not(:disabled), [role="button"]:not(:disabled) { cursor: pointer; }
h1, h2, h3 { text-wrap: balance; }
p { text-wrap: pretty; }
a { color: inherit; }

.wrap { max-width: 64rem; margin: 0 auto; padding: 1.25rem 1rem 4rem; }
header { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.brand { display: flex; align-items: center; gap: 0.75rem; text-decoration: none; color: var(--ink); }
.brand b { display: block; font-size: 1rem; }
.brand span { display: block; font-size: 0.75rem; color: var(--muted); font-weight: 400; }
main { display: grid; gap: 1.1rem; margin-top: 1.5rem; }
.panel {
  background: var(--surface);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
  padding: 1.25rem 1.35rem;
}
.panel h2 { margin: 0; font-size: 1rem; }
.muted { color: var(--muted); font-size: 0.9rem; line-height: 1.7; }
.kicker { margin: 0; font-size: 0.75rem; font-weight: 600; color: var(--accent); }
h1 { margin: 0.5rem 0 0; font-size: clamp(1.6rem, 4vw, 2.25rem); letter-spacing: -0.02em; }

.row { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.hero { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 1.25rem; align-items: end; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
  min-height: 3rem; padding: 0 1.15rem; border: 0; border-radius: var(--radius-lg);
  font-family: inherit; font-size: 0.95rem; font-weight: 600;
  transition: background-color 150ms ease, transform 150ms ease;
}
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--accent); color: var(--accent-fg); }
.btn-primary:hover { background: var(--accent-hover); }
.btn-outline { background: var(--surface); color: var(--ink); box-shadow: inset 0 0 0 1px var(--line); }
.btn-outline:hover { background: var(--surface-2); }
.btn-soft { background: var(--accent-soft); color: var(--accent); }
.btn:disabled { opacity: 0.55; }

.status { min-height: 1.5rem; margin: 1rem 0 0; color: var(--muted); font-size: 0.9rem; }
details.manual { margin-top: 1.1rem; padding-top: 0.9rem; border-top: 1px solid var(--line); }
details.manual summary { color: var(--accent); font-weight: 600; font-size: 0.9rem; }
.manual-form { display: flex; gap: 0.5rem; margin-top: 0.75rem; flex-wrap: wrap; }
.manual-form input {
  flex: 1; min-width: 12rem; height: 3rem; border: 1px solid var(--line);
  border-radius: var(--radius-md); background: var(--bg); padding: 0 0.75rem;
  font-family: inherit; font-size: 0.9rem; color: var(--ink); text-align: left;
}
.manual-form input:focus { outline: 2px solid color-mix(in oklab, var(--accent) 35%, transparent); }

.map-wrap { padding: 0; overflow: hidden; }
.map-tabs { display: flex; gap: 0.25rem; padding: 0.5rem 0.75rem; border-bottom: 1px solid var(--line); overflow-x: auto; }
.map-tabs button {
  height: 2.5rem; padding: 0 0.85rem; border: 0; border-radius: var(--radius-md);
  background: transparent; color: var(--muted); font-family: inherit; font-weight: 600;
}
.map-tabs button.active { background: var(--accent); color: var(--accent-fg); }
.map-stage { position: relative; height: min(52vh, 520px); min-height: 280px; background: var(--surface-2); direction: ltr; }
#osm-map, #google-frame, #neshan-frame { width: 100%; height: 100%; border: 0; display: none; }
#osm-map.active, #google-frame.active, #neshan-frame.active { display: block; }
.leaflet-container { font-family: var(--font); background: #e4dfd2; direction: ltr !important; text-align: left; }
.leaflet-pane, .leaflet-map-pane, .leaflet-tile-pane, .leaflet-overlay-pane, .leaflet-marker-pane, .leaflet-control { left: 0; right: auto; }
.neshan-open {
  position: absolute; bottom: 0.75rem; left: 0.75rem; background: var(--surface);
  border-radius: var(--radius-md); padding: 0.55rem 0.8rem; font-size: 0.75rem;
  font-weight: 600; text-decoration: none; box-shadow: var(--shadow);
}

.split { display: grid; gap: 1.1rem; }
@media (min-width: 960px) { .split { grid-template-columns: 3fr 2fr; } }

.grid2 { display: grid; gap: 0.75rem; margin-top: 1rem; }
@media (min-width: 640px) { .grid2 { grid-template-columns: 1fr 1fr; } }
.cell { background: var(--bg); border-radius: var(--radius-lg); padding: 0.85rem 1rem; }
.cell dt { font-size: 0.75rem; color: var(--muted); display: flex; justify-content: space-between; }
.cell dd { margin: 0.35rem 0 0; font-variant-numeric: tabular-nums; font-size: 0.9rem; text-align: left; }
.copy {
  border: 0; background: transparent; color: var(--muted); width: 1.8rem; height: 1.8rem;
  border-radius: 6px; font-size: 0.85rem;
}
.copy:hover { background: var(--surface-2); color: var(--ink); }

.share-grid, .apps { display: grid; gap: 0.5rem; margin-top: 0.5rem; }
.share-grid { grid-template-columns: 1fr 1fr; }
@media (min-width: 640px) { .share-grid { grid-template-columns: 1fr 1fr 1fr; } }
.share-grid a, .share-grid button {
  height: 3rem; display: flex; align-items: center; justify-content: center;
  background: var(--bg); border: 0; border-radius: var(--radius-md);
  text-decoration: none; font-family: inherit; font-weight: 600; font-size: 0.9rem; color: var(--ink);
}
.share-grid a:hover, .share-grid button:hover { background: var(--accent-soft); }
.apps { display: flex; flex-wrap: wrap; }
.apps a {
  height: 2.5rem; padding: 0 0.9rem; border-radius: 999px; border: 1px solid var(--line);
  display: inline-flex; align-items: center; text-decoration: none; font-size: 0.85rem;
}
.apps a:hover { background: var(--surface-2); }

.qr { display: flex; gap: 1rem; align-items: center; background: var(--bg); border-radius: var(--radius-lg); padding: 1rem; margin-top: 1.1rem; flex-wrap: wrap; }
.qr img { width: 140px; height: 140px; border-radius: var(--radius-md); background: var(--surface); }
.qr small { display: block; margin-top: 0.4rem; color: var(--subtle); word-break: break-all; direction: ltr; text-align: left; }

.history { list-style: none; padding: 0; margin: 0.75rem 0 0; }
.history li { border-top: 1px solid var(--line); }
.history button {
  width: 100%; background: none; border: 0; text-align: right; padding: 0.75rem 0;
  font-family: inherit; display: flex; justify-content: space-between; gap: 0.75rem;
}
.history button:hover { background: var(--bg); }
.history .meta { color: var(--subtle); font-size: 0.75rem; }
.history .coords { display: block; color: var(--muted); font-size: 0.75rem; direction: ltr; text-align: left; }

.steps { display: grid; gap: 0.75rem; margin-top: 0.9rem; }
@media (min-width: 640px) { .steps { grid-template-columns: 1fr 1fr 1fr; } }
.step { background: var(--bg); border-radius: var(--radius-lg); padding: 1rem; }
.step .n { font-size: 0.75rem; color: var(--accent); font-variant-numeric: tabular-nums; direction: ltr; }
.step h3 { margin: 0.4rem 0 0.3rem; font-size: 0.9rem; }

footer {
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0.5rem;
  margin-top: 2.2rem; padding-top: 1.2rem; border-top: 1px solid var(--line);
  color: var(--muted); font-size: 0.85rem;
}

.toast {
  position: fixed; top: 1rem; left: 50%; transform: translateX(-50%) translateY(-120%);
  background: var(--ink); color: var(--accent-fg); padding: 0.7rem 1rem;
  border-radius: var(--radius-md); font-size: 0.85rem; z-index: 50; opacity: 0;
  transition: transform 200ms ease, opacity 200ms ease;
}
.toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
