/* ── Reset & Base ── */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg: #0d1117;
  --surface: #161b22;
  --surface-2: #1c2129;
  --border: #30363d;
  --text: #e6edf3;
  --text-muted: #8b949e;
  --accent: #58a6ff;
  --accent-dim: rgba(88, 166, 255, 0.12);
  --accent-border: rgba(88, 166, 255, 0.3);
  --green: #3fb950;
  --green-dim: rgba(63, 185, 80, 0.15);
  --orange: #d2991d;
  --red: #f85149;
  --red-dim: rgba(248, 81, 73, 0.12);
  --radius: 8px;
  --radius-sm: 6px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
  --url-bar-h: 62px;
}

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

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  padding-bottom: calc(var(--url-bar-h) + 20px);
}

a {
  color: var(--accent);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

code {
  font-family: var(--mono);
  font-size: 0.875em;
  background: var(--surface-2);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  color: var(--orange);
}

/* ── Layout ── */
.wrap {
  max-width: 780px;
  margin: 0 auto;
  padding: 24px 16px 0;
}

header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 32px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

header h1 {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

header .sub {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-top: 4px;
}

.btn-ghost {
  display: inline-flex;
  align-items: center;
  padding: 6px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 0.85rem;
  flex-shrink: 0;
  transition: border-color 0.15s, color 0.15s;
}
.btn-ghost:hover {
  border-color: var(--accent-border);
  color: var(--accent);
  text-decoration: none;
}

main {
  display: flex;
  flex-direction: column;
  gap: 20px;
  margin-bottom: 24px;
}

/* ── Card ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.card h2 {
  font-size: 1rem;
  font-weight: 600;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  color: var(--text-muted);
  letter-spacing: 0.02em;
}

.card > :not(h2) {
  padding: 20px 24px;
}

/* ── Form inputs ── */
input[type="text"] {
  font-family: var(--font);
  font-size: 0.95rem;
  padding: 10px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
input[type="text"]:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}
input[type="text"]::placeholder {
  color: var(--text-muted);
  opacity: 0.6;
}

/* ── Route List (unified origin / waypoints / destination) ── */
.route-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-left: 44px;   /* room for the offset + column */
  position: relative;
}

.route-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.route-row input[type="text"] {
  flex: 1;
}

.route-tag {
  font-family: var(--mono);
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  min-width: 58px;
  text-align: center;
  user-select: none;
  flex-shrink: 0;
}
.route-tag.origin {
  background: rgba(63, 185, 80, 0.12);
  color: var(--green);
  border: 1px solid rgba(63, 185, 80, 0.2);
}
.route-tag.dest {
  background: rgba(248, 81, 73, 0.1);
  color: var(--red);
  border: 1px solid rgba(248, 81, 73, 0.18);
}
.route-tag.wp {
  background: var(--surface-2);
  color: var(--text-muted);
  border: 1px solid var(--border);
}

/* ── Offset + column (add-waypoint gaps) ── */
.route-gap {
  height: 0;
  position: relative;
}

.plus-btn {
  position: absolute;
  left: -34px;
  top: 50%;
  transform: translateY(-50%);
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  z-index: 2;
}

.plus-btn:hover,
.plus-btn:focus-visible {
  border-color: var(--accent-border);
  color: var(--accent);
  background: var(--accent-dim);
}

/* ── Waypoint action buttons ── */
.wp-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.85rem;
  transition: all 0.15s;
  flex-shrink: 0;
}
.wp-btn:hover {
  border-color: var(--accent-border);
  color: var(--text);
  background: var(--surface);
}
.wp-btn:disabled {
  opacity: 0.3;
  cursor: default;
}
.wp-btn:disabled:hover {
  border-color: var(--border);
  color: var(--text-muted);
  background: var(--surface-2);
}
.wp-btn.danger:hover {
  border-color: var(--red);
  color: var(--red);
  background: var(--red-dim);
}

.wp-via-toggle {
  font-family: var(--mono);
  font-size: 0.72rem;
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
  user-select: none;
  flex-shrink: 0;
}
.wp-via-toggle.active {
  border-color: var(--orange);
  color: var(--orange);
  background: rgba(210, 153, 29, 0.1);
}
.wp-via-toggle:hover {
  border-color: var(--accent-border);
}

/* ── Buttons ── */
.btn {
  font-family: var(--font);
  font-size: 0.9rem;
  font-weight: 500;
  padding: 10px 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
  white-space: nowrap;
}

.btn-primary {
  background: var(--green);
  border-color: var(--green);
  color: #fff;
}
.btn-primary:hover {
  filter: brightness(1.1);
}

.btn-accent {
  background: var(--accent-dim);
  border-color: var(--accent-border);
  color: var(--accent);
}
.btn-accent:hover {
  background: rgba(88, 166, 255, 0.2);
}

/* ── Segmented Control ── */
.segmented {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  flex-wrap: wrap;
}

.seg-btn {
  font-family: var(--font);
  font-size: 0.85rem;
  padding: 6px 14px;
  background: var(--surface-2);
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}
.seg-btn:not(:last-child) {
  border-right: 1px solid var(--border);
}
.seg-btn:hover {
  background: var(--surface);
  color: var(--text);
}
.seg-btn.selected {
  background: var(--accent-dim);
  color: var(--accent);
  font-weight: 600;
}

/* ── Options Card ── */
.options-body {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.option-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.option-label {
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.check-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 20px;
}

.check-item {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 0.92rem;
}

.check-item input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
  flex-shrink: 0;
  cursor: pointer;
}

.param-hint {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-left: 4px;
}

/* ── Fixed URL Bar ── */
.url-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--url-bar-h);
  background: var(--surface);
  border-top: 1px solid var(--accent-border);
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.4);
  z-index: 100;
  display: flex;
  align-items: center;
  padding: 0 16px;
}

.url-bar-inner {
  max-width: 780px;
  width: 100%;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 10px;
}

.url-bar-inner input[type="text"] {
  flex: 1;
  font-family: var(--mono);
  font-size: 0.82rem;
  padding: 8px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--green);
  cursor: text;
  min-width: 0;
}
.url-bar-inner input[type="text"]::placeholder {
  color: var(--text-muted);
  font-family: var(--font);
  font-size: 0.82rem;
}

.url-bar-inner .btn {
  flex-shrink: 0;
  padding: 8px 14px;
  font-size: 0.85rem;
}

/* ── Toast ── */
.toast {
  position: fixed;
  bottom: calc(var(--url-bar-h) + 12px);
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: var(--green);
  color: #fff;
  padding: 8px 20px;
  border-radius: 99px;
  font-weight: 600;
  font-size: 0.85rem;
  pointer-events: none;
  opacity: 0;
  transition: transform 0.25s ease, opacity 0.25s ease;
  z-index: 110;
}
.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

/* ── Responsive ── */
@media (max-width: 540px) {
  .url-bar-inner .btn {
    font-size: 0.8rem;
    padding: 8px 10px;
  }
  .segmented {
    width: 100%;
  }
  .seg-btn {
    flex: 1;
    text-align: center;
    padding: 6px 8px;
    font-size: 0.8rem;
  }
}

