:root {
  --bg: #000;
  --text: #fff;
  --soft: rgba(255, 255, 255, .66);
  --line: rgba(255, 255, 255, .14);
  --press: rgba(255, 255, 255, .07);
  --accent: #7cff41;
  --warn: #ffc14d;
  --bad: #ff6a5c;
  --pad: 20px;
}

* { box-sizing: border-box; margin: 0; }
[hidden] { display: none !important; }

html { height: 100%; background: var(--bg); -webkit-text-size-adjust: 100%; }

/* Обвивка като на приложение: лента горе, съдържание, меню долу. Страницата не се скролира. */
body {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  max-width: 480px;
  margin: 0 auto;
  overflow: hidden;
  overscroll-behavior: none;
  background: var(--bg);
  color: var(--text);
  font: 400 16px/1.45 Inter, -apple-system, system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

button, input { font: inherit; color: inherit; }
button { cursor: pointer; touch-action: manipulation; }
input { -webkit-user-select: text; user-select: text; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Горна лента */
.top {
  flex: none;
  display: grid;
  gap: 10px;
  padding: calc(env(safe-area-inset-top) + 14px) var(--pad) 8px;
}
.top__brand { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 32px; }
.top__logo { display: block; width: 95px; height: 20px; }
.top__row { display: flex; align-items: center; gap: 8px; min-height: 44px; }
.top__title { flex: 1; font-size: 28px; font-weight: 900; letter-spacing: -.04em; line-height: 1.1; }
.top__back {
  width: 44px;
  height: 44px;
  margin-left: -12px;
  border: 0;
  background: none;
}
.top__back svg, .tab svg {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* GPS показател */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 32px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 2px;
  color: var(--soft);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.pill i { width: 8px; height: 8px; border-radius: 50%; background: var(--warn); }
.pill[data-level="ok"] i { background: var(--accent); }
.pill[data-level="bad"] i { background: var(--bad); }
.pill[data-level="wait"] i { animation: pulse 1.2s ease-in-out infinite; }

/* Съдържание */
main {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}
.view, #set-form { min-height: 100%; display: flex; flex-direction: column; }
#set-form { flex: 1; }
.view { animation: enter .22s ease-out; }
.view__body { flex: 1; display: flex; flex-direction: column; gap: 20px; padding: 12px var(--pad) 20px; }
.view__body--center { justify-content: center; }
.view__foot {
  position: sticky;
  bottom: 0;
  z-index: 2;
  display: grid;
  gap: 10px;
  padding: 12px var(--pad) 16px;
  background: var(--bg);
}
/* Докато курсът върви, менюто е скрито и бутоните стигат до ръба на екрана. */
.is-run .view__foot { padding-bottom: calc(16px + env(safe-area-inset-bottom)); }

.label {
  color: var(--soft);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .14em;
  text-transform: uppercase;
}

/* Цена */
.price {
  font-size: clamp(56px, 19vw, 96px);
  font-weight: 900;
  line-height: 1;
  letter-spacing: -.055em;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.price--xl { font-size: clamp(60px, 21vw, 104px); }

.pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  padding: 20px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}
.big {
  font-size: 30px;
  font-weight: 900;
  letter-spacing: -.03em;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
  margin-bottom: 6px;
}

/* Редове с тънки линии */
.rows { border-top: 1px solid var(--line); }
.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  width: 100%;
  min-height: 60px;
  padding: 14px 0;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: none;
  text-align: left;
}
.row span { color: var(--soft); }
.row b { font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.row--total span { color: var(--text); font-weight: 600; }
.row small { display: block; color: var(--soft); font-size: 13px; }
button.row span { color: var(--text); }
button.row:active { background: var(--press); }

/* Избор на фиксиран маршрут */
.pick { justify-content: flex-start; }
.pick::before {
  content: "";
  flex: none;
  width: 22px;
  height: 22px;
  border: 2px solid var(--soft);
  border-radius: 50%;
}
.pick[aria-checked="true"]::before { border: 7px solid var(--accent); }
.pick span { flex: 1; }
.pick[aria-checked="false"] span, .pick[aria-checked="false"] b { color: var(--soft); }

/* Курсове: ден и сбор */
.day { display: flex; justify-content: space-between; gap: 12px; padding: 24px 0 12px; }
.day:first-child { padding-top: 4px; }
.day span { letter-spacing: 0; text-transform: none; font-size: 13px; font-variant-numeric: tabular-nums; }

.empty { margin: auto 0; padding-bottom: 40px; color: var(--soft); text-align: center; }
.empty__title { margin-bottom: 8px; color: var(--text); font-size: 22px; font-weight: 900; letter-spacing: -.03em; }

/* Предупреждения */
.notice {
  padding: 12px 14px;
  border-left: 2px solid var(--warn);
  background: rgba(255, 193, 77, .1);
  color: var(--warn);
  font-size: 14px;
}

/* Съвет за слагане на началния екран */
.tip {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-top: auto;
  padding: 14px 6px 14px 14px;
  border: 1px solid var(--line);
  border-radius: 2px;
  color: var(--soft);
  font-size: 14px;
}
.tip p { flex: 1; }
.tip button { flex: none; width: 44px; height: 44px; margin: -10px 0; border: 0; background: none; font-size: 22px; line-height: 1; }

/* Бутони */
.btn {
  width: 100%;
  min-height: 56px;
  padding: 0 20px;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: none;
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .14em;
  text-transform: uppercase;
  transition: transform .08s ease-out, opacity .08s ease-out;
}
.btn:active { transform: scale(.98); opacity: .85; }
.btn--go { min-height: 72px; border-color: var(--accent); background: var(--accent); color: #000; font-size: 17px; }
.btn--stop { min-height: 72px; border-color: #fff; background: #fff; color: #000; font-size: 17px; }

/* Избор на вид курс */
.seg { display: grid; grid-template-columns: 1fr 1fr; padding: 3px; border: 1px solid var(--line); border-radius: 2px; }
.seg__btn {
  min-height: 48px;
  padding: 0 8px;
  border: 0;
  border-radius: 1px;
  background: none;
  color: var(--soft);
  font-size: 14px;
  font-weight: 600;
}
.seg__btn[aria-checked="true"] { background: #fff; color: #000; }

/* Полета */
.field {
  width: 100%;
  min-height: 52px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: #0d0d0d;
  color: var(--text);
  font-size: 16px;
}
.field:focus { border-color: #fff; outline: 0; }
.fld { display: grid; gap: 8px; }
.fld span { color: var(--soft); font-size: 14px; }
#set-form .label:not(:first-child) { margin-top: 16px; }
.route { display: grid; grid-template-columns: 1fr 52px; gap: 8px; margin-bottom: 16px; }
.route input:first-child { grid-column: 1 / -1; }
.route__del { border: 1px solid var(--line); border-radius: 2px; background: none; font-size: 20px; line-height: 1; }

/* Карта */
.map {
  position: relative;
  z-index: 0;
  isolation: isolate; /* слоевете на картата да не излизат над бутоните */
  flex: none;
  height: 300px;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: #0d0d0d;
  display: grid;
  place-items: center;
  color: var(--soft);
  font-size: 14px;
  text-align: center;
  overflow: hidden;
}

/* Долно меню */
.tabs {
  flex: none;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  padding-bottom: env(safe-area-inset-bottom);
  border-top: 1px solid var(--line);
  background: var(--bg);
}
.tab {
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 3px;
  min-height: 58px;
  border: 0;
  background: none;
  color: rgba(255, 255, 255, .5);
  font-size: 11px;
  font-weight: 600;
}
.tab[aria-current="page"] { color: var(--text); }
.tab:active { background: var(--press); }

/* Потвърждение за край: излиза отдолу */
.sheet {
  position: fixed;
  inset: auto 0 0 0;
  width: 100%;
  max-width: 480px;
  max-height: none;
  margin: 0 auto;
  padding: 24px var(--pad) calc(20px + env(safe-area-inset-bottom));
  border: 0;
  border-top: 1px solid var(--line);
  background: #111;
  color: var(--text);
}
.sheet[open] { display: grid; gap: 12px; animation: rise .22s ease-out; }
.sheet::backdrop { background: rgba(0, 0, 0, .7); }
.sheet__q { font-size: 26px; font-weight: 900; letter-spacing: -.03em; }
.sheet__sum { margin-bottom: 8px; color: var(--soft); font-variant-numeric: tabular-nums; }

/* Кратко съобщение */
.toast {
  position: fixed;
  left: 50%;
  top: calc(env(safe-area-inset-top) + 12px);
  z-index: 1500;
  transform: translateX(-50%);
  padding: 10px 16px;
  border-radius: 2px;
  background: #fff;
  color: #000;
  font-size: 14px;
  font-weight: 600;
  animation: toast .2s ease-out;
}

/* Затъмнен екран: пести батерия, екранът остава включен */
.dim {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  border: 0;
  background: #000;
  color: #2e2e2e;
}
.dim__price { font-size: 44px; font-weight: 900; letter-spacing: -.04em; font-variant-numeric: tabular-nums; }
.dim__hint { font-size: 13px; }

@keyframes enter { from { opacity: 0; transform: translateY(8px); } }
@keyframes rise { from { transform: translateY(100%); } }
@keyframes toast { from { opacity: 0; transform: translate(-50%, -8px); } }
@keyframes pulse { 50% { opacity: .25; } }

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