/* Routing Profile Creator — dark liquid glass over a night-mode road map */

:root {
  --night: #0a1120;          /* page background, deep night blue */
  --road: #1c2a45;           /* minor roads */
  --road-major: #2b3e63;     /* major roads */
  --amber: #ff8f00;          /* OsmAnd orange (osmand_orange in the app): route + primary action */
  --amber-deep: #e68200;     /* osmand_orange_dark */
  --blue: #0a84ff;           /* iOS system blue (dark mode): secondary actions */
  --off-zone: rgba(8, 12, 24, 0.72); /* slider range that has no effect */
  --ink: #f2f5fb;            /* primary text */
  --ink-2: rgba(226, 233, 248, 0.66);  /* secondary text */
  --ink-3: rgba(226, 233, 248, 0.42);

  --glass: rgba(150, 175, 225, 0.10);
  --glass-strong: rgba(30, 42, 68, 0.62);
  --glass-edge: rgba(255, 255, 255, 0.16);
  --glass-shine: rgba(255, 255, 255, 0.28);

  --r-sheet: 34px;
  --r-panel: 26px;
  --r-field: 14px;

  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, "Segoe UI", Roboto, sans-serif;
  --font-round: ui-rounded, "SF Pro Rounded", -apple-system, system-ui, sans-serif;

  --gutter: 16px;
  --dock-h: 88px;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--night);
  color: var(--ink);
  font: 17px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* ---------- background map ---------- */
.map {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
}
.map path { fill: none; stroke-linecap: round; }
.map-minor path { stroke: var(--road); stroke-width: 3; }
.map-major path { stroke: var(--road-major); stroke-width: 7; }
.map-route {
  stroke: var(--amber);
  stroke-width: 5;
  filter: drop-shadow(0 0 8px rgba(255, 143, 0, 0.55));
  stroke-dasharray: 1400;
  stroke-dashoffset: 1400;
  animation: draw 2.4s 0.2s cubic-bezier(.6, 0, .2, 1) forwards;
}
.map-pin { fill: var(--night); stroke: var(--amber); stroke-width: 3; }
@keyframes draw { to { stroke-dashoffset: 0; } }

/* ---------- glass material ---------- */
.glass {
  position: relative;
  background:
    linear-gradient(160deg, rgba(255,255,255,0.10), rgba(255,255,255,0.02) 40%, rgba(255,255,255,0.04)),
    var(--glass);
  -webkit-backdrop-filter: blur(22px) saturate(170%);
  backdrop-filter: blur(22px) saturate(170%);
  border: 1px solid var(--glass-edge);
  box-shadow:
    inset 0 1px 0 var(--glass-shine),
    inset 0 -1px 0 rgba(255,255,255,0.04),
    0 12px 32px rgba(0, 0, 0, 0.35);
}

/* ---------- page ---------- */
.page {
  position: relative;
  z-index: 1;
  max-width: 520px;
  margin: 0 auto;
  padding: max(36px, calc(env(safe-area-inset-top) + 20px)) var(--gutter) calc(var(--dock-h) + 40px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.intro { padding: 8px 4px 10px; }
.intro h1 {
  margin: 0 0 10px;
  font-size: clamp(32px, 9vw, 42px);
  line-height: 1.05;
  letter-spacing: -0.03em;
  font-weight: 700;
  text-wrap: balance;
}
.intro p { margin: 0; color: var(--ink-2); max-width: 34ch; }
.btn-secondary {
  margin-top: 8px;
  min-height: 44px;
  padding: 0 18px;
  border-radius: 999px;
  border: 1px solid rgba(10, 132, 255, 0.45);
  background: rgba(10, 132, 255, 0.18);
  color: #4da3ff;
  font: 600 15px var(--font);
  cursor: pointer;
  transition: transform .12s, background .12s;
}
.btn-secondary:hover { background: rgba(10, 132, 255, 0.26); }
.btn-secondary:active { transform: scale(0.97); }

/* ---------- text wrapping ---------- */
p, li, dd, .card-desc, .hint { text-wrap: pretty; }
h1, h2, h3, dt, .card-title, .f-label { text-wrap: balance; }
.nw { white-space: nowrap; }

/* ---------- panels ---------- */
.panel {
  border-radius: var(--r-panel);
  padding: 18px 18px 20px;
}
.panel-head h2 {
  margin: 0;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.panel-head h2 label { cursor: pointer; }
.hint {
  margin: 4px 0 0;
  font-size: 14px;
  line-height: 1.4;
  color: var(--ink-2);
}

/* ---------- sections ---------- */
.sections { display: flex; flex-direction: column; gap: 10px; }
.sec { padding: 0; }
.sec > summary {
  list-style: none;
  display: flex; align-items: center; gap: 10px;
  min-height: 56px; padding: 0 18px;
  cursor: pointer;
}
.sec > summary::-webkit-details-marker { display: none; }
/* Title on top, summary ("OsmAnd default" / "3 changed") below, so the title gets the full width */
.sec-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; padding: 10px 0; }
.sec-title { font-weight: 600; font-size: 17px; letter-spacing: -0.01em; text-wrap: balance; }
.sec-sum { font-size: 13px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.sec-sum.changed { color: var(--amber); }
.chev {
  flex: none; width: 9px; height: 9px;
  border-right: 2px solid var(--ink-2); border-bottom: 2px solid var(--ink-2);
  transform: rotate(45deg) translateY(-3px); transition: transform .2s;
}
details[open] > summary .chev { transform: rotate(-135deg) translateY(-1px); }
.sec-body { padding: 0 18px 14px; }

.group { padding-top: 6px; }
.group + .group { margin-top: 6px; border-top: 1px solid rgba(255,255,255,0.08); }
.group-head { display: flex; align-items: center; gap: 6px; min-height: 40px; }
.group-head h3 { margin: 0; font-size: 13px; font-weight: 600; color: var(--ink-2); letter-spacing: 0.01em; }
details.group > summary { list-style: none; cursor: pointer; }
details.group > summary::-webkit-details-marker { display: none; }
details.group > summary .chev { width: 7px; height: 7px; margin-left: 4px; }

/* ---------- road / surface cards ---------- */
.card { margin: 6px 0; border-radius: var(--r-field); background: rgba(255,255,255,0.04); border: 1px solid rgba(255,255,255,0.07); }
.card > summary { list-style: none; display: flex; align-items: center; gap: 10px; min-height: 48px; padding: 0 14px; cursor: pointer; }
.card > summary::-webkit-details-marker { display: none; }
.card-title { font-size: 15px; font-weight: 500; white-space: nowrap; }
.card-sum { margin-left: auto; font-size: 13px; color: var(--ink-2); font-variant-numeric: tabular-nums; text-align: right; text-wrap: balance; }
.card-sum.changed { color: var(--amber); }
.card > summary .chev { width: 7px; height: 7px; }
.card-body { padding: 0 14px 8px; }
.card-desc { margin: 0 0 4px; font-size: 13px; line-height: 1.4; color: var(--ink-2); }

/* ---------- field rows ---------- */
.f { padding: 2px 0; }
.f + .f { border-top: 1px solid rgba(255,255,255,0.05); }
.f-row { display: flex; align-items: center; gap: 8px; min-height: 46px; }
.f-label { font-size: 15px; }
.f-end { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.f-val { font: 600 16px var(--font-round); font-variant-numeric: tabular-nums; color: var(--ink); white-space: nowrap; }
.unit { font-size: 13px; color: var(--ink-3); min-width: 30px; }
.f.changed .f-val, .f.changed .num { color: var(--amber); }
.f.changed .num { border-color: rgba(255, 170, 60, 0.45); }
.f-box { display: flex; align-items: center; gap: 8px; margin: 0 0 4px; }
.f-limit { display: flex; align-items: center; gap: 8px; min-height: 36px; font-size: 14px; color: var(--ink-2); cursor: pointer; width: fit-content; }
.f-limit .check { width: 18px; height: 18px; margin: 0; accent-color: var(--amber); }
.f-limit.changed { color: var(--amber); }

/* settings OsmAnd ignores with the current values */
.f.clamped .f-val { color: var(--ink-3) !important; }
.f.inactive > .f-row, .f.inactive > .range,
.f.off > *, .f.box-off > .f-box { opacity: 0.35; }
.card-sum .dim { color: var(--ink-3); }

.num {
  width: 74px; height: 36px; padding: 0 10px;
  border-radius: 10px; border: 1px solid rgba(255,255,255,0.14);
  background: rgba(5, 10, 22, 0.45); color: var(--ink);
  font: 600 16px var(--font-round); text-align: right; font-variant-numeric: tabular-nums;
}
.num:focus { outline: none; border-color: rgba(255, 170, 60, 0.7); }

.info-btn {
  flex: none; width: 22px; height: 22px; padding: 0;
  border-radius: 50%; border: 1.5px solid var(--ink-3);
  background: transparent; color: var(--ink-2);
  font: italic 600 12px/1 Georgia, "Times New Roman", serif;
  display: grid; place-items: center; cursor: pointer;
  position: relative;
}
.info-btn::before { content: ""; position: absolute; inset: -11px; } /* 44px tap target */
.info-btn[aria-expanded="true"] { background: var(--amber); border-color: var(--amber); color: #1d1205; }
.f-info, .group-info {
  margin: 0 0 10px; padding: 10px 12px;
  border-radius: 12px; background: rgba(255,255,255,0.05);
  font-size: 14px; line-height: 1.45; color: var(--ink-2);
}
.f-info p, .group-info p { margin: 0; }
.f-info ul, .group-info ul { margin: 0; padding-left: 18px; }
.f-info > :not(:first-child), .group-info > :not(:first-child) { margin-top: 8px; }
.f-info li + li, .group-info li + li { margin-top: 4px; }
.f-info li::marker, .group-info li::marker { color: var(--ink-3); }
.sec-intro { margin: 0 0 4px; font-size: 14px; line-height: 1.45; color: var(--ink-2); }
.f-info .f-default { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 8px; color: var(--ink-3); }
.f-info code, .group-info code { font-size: 13px; color: var(--ink); }
.link-btn {
  min-height: 32px; padding: 0 12px;
  border-radius: 999px; border: 1px solid var(--glass-edge);
  background: rgba(255,255,255,0.06); color: var(--ink);
  font: 500 13px var(--font); cursor: pointer; white-space: nowrap;
}

/* ---------- home screen tip (iPhone browser only) ---------- */
.home-tip[hidden] { display: none; }
.home-tip {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px 8px 12px 16px;
  border-radius: var(--r-field);
  border: 1px solid rgba(10, 132, 255, 0.4);
  background: rgba(10, 132, 255, 0.12);
  font-size: 14px; line-height: 1.45; color: var(--ink-2);
}
.home-tip p { margin: 0; flex: 1; }
.home-tip b { color: var(--ink); font-weight: 600; }
.home-tip-share { vertical-align: -3px; color: #4da3ff; }
.home-tip-x {
  flex: none; display: grid; place-items: center;
  width: 32px; height: 32px; margin: -4px 0;
  border: 0; border-radius: 50%; background: transparent; color: var(--ink-2); cursor: pointer;
}
.home-tip-x:hover { background: rgba(255, 255, 255, 0.08); }

/* ---------- top buttons, save sheet, coffee ---------- */
.intro-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.intro-top h1 { flex: 1; }
/* Three levels: orange = Save & share (main action), solid blue = help, glass = tools. */
.help-btn {
  flex: none; display: grid; place-items: center;
  width: 58px; height: 58px;
  border: 0; border-radius: 50%;
  background: linear-gradient(180deg, #3d9cff, #0a84ff);
  color: #fff; cursor: pointer;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.35), 0 4px 14px rgba(10, 132, 255, 0.35);
  transition: transform .12s;
}
.help-btn:hover { background: linear-gradient(180deg, #52a8ff, #1a8cff); }
.help-btn:active { transform: scale(0.94); }
.intro-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 12px; }
.intro-btns .btn-secondary { margin-top: 0; display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 0 12px; white-space: nowrap; }
.btn-tool {
  border-color: var(--glass-edge);
  background: rgba(255, 255, 255, 0.08);
  color: var(--ink);
  box-shadow: inset 0 1px 0 var(--glass-shine);
}
.btn-tool:hover { background: rgba(255, 255, 255, 0.14); }

.save-view { display: flex; flex-direction: column; }
.save-view[hidden] { display: none; }
.save-view .text { margin-top: 8px; }
.save-view .hint { margin: 6px 2px 18px; }
.save-view .btn-primary { display: flex; align-items: center; justify-content: center; gap: 8px; flex: none; }
.save-view .btn-secondary { margin-top: 10px; }
.save-view > .hint:last-child { margin: 14px 2px 18px; }
.save-status:empty { display: none; }
.save-status { margin-top: 12px; font-size: 15px; color: var(--ink); }
.save-status .text { margin-top: 8px; font-size: 15px; }
.sheet .sheet-action { width: 100%; display: flex; align-items: center; justify-content: center; gap: 8px; margin-bottom: 10px; }
.sheet #mailStatus { margin: 4px 2px 16px; }
.sheet .sheet-close {
  width: 100%; margin-top: 0;
  border-color: var(--glass-edge); background: rgba(255, 255, 255, 0.05); color: var(--ink-2);
}
.sheet .sheet-close:hover { background: rgba(255, 255, 255, 0.1); }

.coffee {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px;
  margin: 0 0 18px; padding: 12px 14px;
  border-radius: var(--r-field); border: 1px solid var(--glass-edge);
  background: rgba(255, 255, 255, 0.05);
  font-size: 14px; color: var(--ink-2);
}
.coffee-btn {
  display: inline-flex; align-items: center; gap: 8px;
  min-height: 40px; padding: 0 16px;
  border-radius: 999px; border: 1px solid rgba(255, 221, 0, 0.45);
  background: rgba(255, 221, 0, 0.12);
  color: #ffe45c; font: 600 15px var(--font); text-decoration: none;
  transition: background .12s, transform .12s;
}
.coffee-btn:hover { background: rgba(255, 221, 0, 0.2); }
.coffee-btn:active { transform: scale(0.97); }

/* ---------- range slider ---------- */
.range {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 34px;
  margin: 0 0 4px;
  display: block;
  background: transparent;
  --fill: 50%;
  --lo: 0%;    /* road speeds: below minimum speed has no effect */
  --hi: 100%;  /* road speeds: above max cruising speed has no effect */
}
.range::-webkit-slider-runnable-track {
  height: 8px;
  border-radius: 999px;
  background:
    linear-gradient(90deg, var(--off-zone) var(--lo), transparent var(--lo), transparent var(--hi), var(--off-zone) var(--hi)),
    linear-gradient(90deg, var(--amber) var(--fill), rgba(255,255,255,0.14) var(--fill));
}
.range::-moz-range-track {
  height: 8px; border-radius: 999px;
  background:
    linear-gradient(90deg, var(--off-zone) var(--lo), transparent var(--lo), transparent var(--hi), var(--off-zone) var(--hi)),
    rgba(255,255,255,0.14);
}
.range::-moz-range-progress { height: 8px; border-radius: 999px; background: var(--amber); }
.range::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 30px; height: 30px;
  margin-top: -11px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff, #dfe6f3);
  box-shadow: 0 2px 10px rgba(0,0,0,0.45), inset 0 -1px 2px rgba(0,0,0,0.15);
}
.range::-moz-range-thumb {
  width: 30px; height: 30px; border: 0; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff, #dfe6f3);
  box-shadow: 0 2px 10px rgba(0,0,0,0.45);
}
.range-ends {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  color: var(--ink-3);
}

.switch {
  -webkit-appearance: none;
  appearance: none;
  flex: none;
  width: 52px; height: 32px;
  margin: 0;
  border-radius: 999px;
  background: rgba(255,255,255,0.16);
  position: relative;
  cursor: pointer;
  transition: background .2s;
}
.switch::after {
  content: "";
  position: absolute;
  top: 2px; left: 2px;
  width: 28px; height: 28px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 6px rgba(0,0,0,0.35);
  transition: transform .22s cubic-bezier(.3, 1.4, .5, 1);
}
.switch:checked { background: var(--amber); }
.switch:checked::after { transform: translateX(20px); }

/* ---------- text fields ---------- */
.text {
  width: 100%;
  margin-top: 12px;
  min-height: 48px;
  padding: 0 14px;
  border-radius: var(--r-field);
  border: 1px solid rgba(255,255,255,0.14);
  background: rgba(5, 10, 22, 0.45);
  color: var(--ink);
  font: 17px var(--font);   /* >=16px stops iOS zoom on focus */
}
.text:focus { border-color: rgba(255, 170, 60, 0.7); outline: none; }

.footnote {
  margin: 14px 4px 0;
  font-size: 13px;
  line-height: 1.5;
  color: var(--ink-3);
}
.footnote p { margin: 0 0 6px; text-wrap: balance; }
.footnote .fn-links { font-size: 14px; }
.footnote .fn-links a { color: var(--ink); }
.footnote a { color: var(--ink-2); }
.status:empty { display: none; }
.status { margin: 0 4px; color: #ffb36b; font-size: 15px; }
.sheet .small { margin: 0 0 18px; font-size: 14px; color: var(--ink-2); }

/* ---------- dock ---------- */
.dock {
  position: fixed;
  z-index: 6;
  left: 50%;
  transform: translateX(-50%);
  bottom: max(12px, env(safe-area-inset-bottom));
  width: calc(min(520px, 100%) - 2 * var(--gutter));
  padding: 8px;
  border-radius: 999px;
  display: flex;
  gap: 8px;
  background:
    linear-gradient(160deg, rgba(255,255,255,0.12), rgba(255,255,255,0.03)),
    var(--glass-strong);
}

.btn-primary {
  flex: 1;
  min-height: 56px;
  border: 0;
  border-radius: 999px;
  background: linear-gradient(180deg, #ffad40, var(--amber) 45%, var(--amber-deep));
  color: #1d1205;
  font: 600 17px var(--font);
  letter-spacing: -0.01em;
  cursor: pointer;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.6), 0 6px 18px rgba(255, 130, 0, 0.30);
  transition: transform .12s;
}
.btn-primary:active { transform: scale(0.97); }
.btn-primary:disabled { opacity: 0.5; cursor: progress; }
.dock .btn-primary { display: flex; align-items: center; justify-content: center; gap: 8px; }

/* ---------- sheet ---------- */
.scrim {
  position: fixed;
  inset: 0;
  z-index: 9;
  background: rgba(3, 6, 14, 0.5);
  animation: fade .25s ease-out;
}
.sheet {
  position: fixed;
  z-index: 10;
  left: 50%;
  bottom: 0;
  /* --drag: how far the sheet is pulled down (swipe to close, js/app.js) */
  transform: translate(-50%, var(--drag, 0px));
  width: min(560px, 100%);
  max-height: 88dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-radius: var(--r-sheet) var(--r-sheet) 0 0;
  background:
    linear-gradient(170deg, rgba(255,255,255,0.12), rgba(255,255,255,0.02) 50%),
    rgba(22, 32, 54, 0.78);
  animation: rise .38s cubic-bezier(.2, .9, .25, 1.05);
}
.sheet[hidden], .scrim[hidden] { display: none; }
/* Head (handle + title) and foot (Done/Close) stay put; only the middle scrolls, and its scroll
   never carries over to the page behind. The head takes the swipe-down gesture. */
.sheet-head { flex: none; padding: 10px 22px 0; touch-action: none; cursor: grab; }
.sheet-scroll { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 0 22px; }
.sheet-foot { flex: none; padding: 12px 22px calc(16px + env(safe-area-inset-bottom)); border-top: 1px solid rgba(255,255,255,0.08); }
.sheet.settling { transition: transform .22s cubic-bezier(.2, .8, .3, 1); }
.scrim { touch-action: none; }
.grabber { width: 40px; height: 5px; border-radius: 999px; background: rgba(255,255,255,0.3); margin: 0 auto 16px; }
.sheet h2 { margin: 0 0 6px; font-size: 24px; letter-spacing: -0.02em; }
.sheet .lead { margin: 0 0 14px; color: var(--ink-2); }
.help { display: flex; flex-direction: column; gap: 10px; margin: 8px 0 18px; }
.help-card { padding: 14px 16px; border-radius: 18px; background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.08); }
.help-card h3 { margin: 0 0 6px; font-size: 16px; letter-spacing: -0.01em; }
.help-card p { margin: 0; font-size: 15px; color: var(--ink-2); }
.help-card .steps { margin: 0; font-size: 15px; }
.help-card a { color: var(--amber); }
.help-warn { background: rgba(255, 143, 0, 0.10); border-color: rgba(255, 143, 0, 0.28); }
.recipes { margin: 0; font-size: 15px; }
.recipes dt { font-weight: 600; margin-top: 10px; }
.recipes dt:first-child { margin-top: 0; }
.recipes dd { margin: 2px 0 0; color: var(--ink-2); }
.steps { margin: 0 0 18px; padding: 0; list-style: none; counter-reset: step; }
.steps li {
  counter-increment: step;
  position: relative;
  padding: 12px 0 12px 44px;
  border-top: 1px solid rgba(255,255,255,0.08);
}
.steps li::before {
  content: counter(step);
  position: absolute;
  left: 0; top: 10px;
  width: 30px; height: 30px;
  border-radius: 50%;
  display: grid; place-items: center;
  font: 600 15px var(--font-round);
  color: var(--amber);
  background: rgba(255, 143, 0, 0.12);
  border: 1px solid rgba(255, 143, 0, 0.35);
}
.steps b { font-weight: 600; }
.note {
  margin: 0 0 18px;
  padding: 12px 14px;
  border-radius: 16px;
  background: rgba(255, 143, 0, 0.10);
  border: 1px solid rgba(255, 143, 0, 0.28);
  font-size: 15px;
}
.sheet .btn-primary { width: 100%; }

@keyframes rise { from { transform: translate(-50%, 100%); } to { transform: translate(-50%, 0); } }
@keyframes fade { from { opacity: 0; } }

/* ---------- focus & motion ---------- */
:focus-visible { outline: 2px solid var(--amber); outline-offset: 3px; }
.text:focus-visible { outline: none; }

@media (prefers-reduced-motion: reduce) {
  .map-route { animation: none; stroke-dashoffset: 0; }
  .sheet, .scrim { animation: none; }
  * { transition: none !important; }
}

/* fallback where backdrop-filter is missing */
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .glass { background: rgba(24, 34, 56, 0.94); }
}
